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

33,770 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 key: "createWpDashPayload",
366 value: function createWpDashPayload() {
367 var _config$appTypes$wpDa, _config$appTypes5, _config$locations11;
368 var overrides = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
369 var config = this.getConfig();
370 return this.createBasePayload(_objectSpread({
371 window_name: (_config$appTypes$wpDa = config === null || config === void 0 || (_config$appTypes5 = config.appTypes) === null || _config$appTypes5 === void 0 ? void 0 : _config$appTypes5.wpDash) !== null && _config$appTypes$wpDa !== void 0 ? _config$appTypes$wpDa : 'wpdash',
372 target_location: this.toLowerSnake(config === null || config === void 0 || (_config$locations11 = config.locations) === null || _config$locations11 === void 0 ? void 0 : _config$locations11.wpDashAdmin),
373 location_l2: ''
374 }, overrides));
375 }
376 }, {
377 key: "sendWpDashElementorMenuClick",
378 value: function sendWpDashElementorMenuClick() {
379 var _config$names10, _config$triggers10, _config$targetTypes11, _config$interactionRe13, _config$secondaryLoca11;
380 var config = this.getConfig();
381 return this.dispatchEvent(config === null || config === void 0 || (_config$names10 = config.names) === null || _config$names10 === void 0 || (_config$names10 = _config$names10.editorOne) === null || _config$names10 === void 0 ? void 0 : _config$names10.wpDashElementorMenuClick, this.createWpDashPayload({
382 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers10 = config.triggers) === null || _config$triggers10 === void 0 ? void 0 : _config$triggers10.click),
383 target_type: config === null || config === void 0 || (_config$targetTypes11 = config.targetTypes) === null || _config$targetTypes11 === void 0 ? void 0 : _config$targetTypes11.wpDashAdminMenuItem,
384 target_name: 'elementor_menu_item',
385 interaction_result: config === null || config === void 0 || (_config$interactionRe13 = config.interactionResults) === null || _config$interactionRe13 === void 0 ? void 0 : _config$interactionRe13.elementorSideMenuOpened,
386 location_l1: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca11 = config.secondaryLocations) === null || _config$secondaryLoca11 === void 0 ? void 0 : _config$secondaryLoca11.wpDashElementorCoreMenu),
387 interaction_description: 'core_user_clicked_elementor_menu_item'
388 }));
389 }
390 }, {
391 key: "sendWpDashEditorSubMenuHover",
392 value: function sendWpDashEditorSubMenuHover() {
393 var _config$names11, _config$triggers11, _config$targetTypes12, _config$interactionRe14, _config$secondaryLoca12;
394 var config = this.getConfig();
395 return this.dispatchEvent(config === null || config === void 0 || (_config$names11 = config.names) === null || _config$names11 === void 0 || (_config$names11 = _config$names11.editorOne) === null || _config$names11 === void 0 ? void 0 : _config$names11.wpDashEditorSubMenuHover, this.createWpDashPayload({
396 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers11 = config.triggers) === null || _config$triggers11 === void 0 ? void 0 : _config$triggers11.hover),
397 target_type: config === null || config === void 0 || (_config$targetTypes12 = config.targetTypes) === null || _config$targetTypes12 === void 0 ? void 0 : _config$targetTypes12.wpDashEditorMenu,
398 target_name: 'wpdash_editor_sub_menu',
399 interaction_result: config === null || config === void 0 || (_config$interactionRe14 = config.interactionResults) === null || _config$interactionRe14 === void 0 ? void 0 : _config$interactionRe14.editorSubMenuOpened,
400 location_l1: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca12 = config.secondaryLocations) === null || _config$secondaryLoca12 === void 0 ? void 0 : _config$secondaryLoca12.wpDashElementorCoreSubMenu),
401 interaction_description: 'core_user_hovered_sub_menu'
402 }));
403 }
404 }, {
405 key: "sendWpDashThemeBuilderClick",
406 value: function sendWpDashThemeBuilderClick() {
407 var _config$names12, _config$triggers12, _config$targetTypes13, _config$interactionRe15, _config$secondaryLoca13;
408 var config = this.getConfig();
409 return this.dispatchEvent(config === null || config === void 0 || (_config$names12 = config.names) === null || _config$names12 === void 0 || (_config$names12 = _config$names12.editorOne) === null || _config$names12 === void 0 ? void 0 : _config$names12.wpDashThemeBuilderClick, this.createWpDashPayload({
410 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers12 = config.triggers) === null || _config$triggers12 === void 0 ? void 0 : _config$triggers12.click),
411 target_type: config === null || config === void 0 || (_config$targetTypes13 = config.targetTypes) === null || _config$targetTypes13 === void 0 ? void 0 : _config$targetTypes13.wpDashSubMenuItem,
412 target_name: 'theme_builder_menu_item',
413 interaction_result: config === null || config === void 0 || (_config$interactionRe15 = config.interactionResults) === null || _config$interactionRe15 === void 0 ? void 0 : _config$interactionRe15.themeBuilderPromotionWindow,
414 location_l1: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca13 = config.secondaryLocations) === null || _config$secondaryLoca13 === void 0 ? void 0 : _config$secondaryLoca13.wpDashThemeBuilder),
415 interaction_description: 'core_user_clicked_theme_builder_menu_item'
416 }));
417 }
418 }]);
419 }();
420 var createDebouncedFinderSearch = exports.createDebouncedFinderSearch = function createDebouncedFinderSearch() {
421 var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 300;
422 return _.debounce(function (resultsCount, searchTerm) {
423 EditorOneEventManager.sendFinderSearchInput({
424 resultsCount: resultsCount,
425 searchTerm: searchTerm
426 });
427 }, delay);
428 };
429 var createDebouncedWidgetPanelSearch = exports.createDebouncedWidgetPanelSearch = function createDebouncedWidgetPanelSearch() {
430 var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2000;
431 return _.debounce(function (resultsCount, userInput) {
432 EditorOneEventManager.sendWidgetPanelSearch({
433 resultsCount: resultsCount,
434 userInput: userInput
435 });
436 }, delay);
437 };
438 var _default = exports["default"] = EditorOneEventManager;
439
440 /***/ }),
441
442 /***/ "../assets/dev/js/editor/utils/files-upload-handler.js":
443 /*!*************************************************************!*\
444 !*** ../assets/dev/js/editor/utils/files-upload-handler.js ***!
445 \*************************************************************/
446 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
447
448 "use strict";
449 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
450
451
452 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
453 Object.defineProperty(exports, "__esModule", ({
454 value: true
455 }));
456 exports["default"] = void 0;
457 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
458 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
459 var FilesUploadHandler = exports["default"] = /*#__PURE__*/function () {
460 function FilesUploadHandler() {
461 (0, _classCallCheck2.default)(this, FilesUploadHandler);
462 }
463 return (0, _createClass2.default)(FilesUploadHandler, null, [{
464 key: "isUploadEnabled",
465 value: function isUploadEnabled(mediaType) {
466 var unfilteredFilesTypes = ['svg', 'application/json'];
467 if (!unfilteredFilesTypes.includes(mediaType)) {
468 return true;
469 }
470 return elementorCommon.config.filesUpload.unfilteredFiles;
471 }
472 }, {
473 key: "setUploadTypeCaller",
474 value: function setUploadTypeCaller(frame) {
475 frame.uploader.uploader.param('uploadTypeCaller', 'elementor-wp-media-upload');
476 }
477 }, {
478 key: "getUnfilteredFilesNonAdminDialog",
479 value: function getUnfilteredFilesNonAdminDialog() {
480 return elementorCommon.dialogsManager.createWidget('alert', {
481 id: 'e-unfiltered-files-disabled-dialog',
482 headerMessage: __('Sorry, you can\'t upload that file yet', 'elementor'),
483 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'),
484 strings: {
485 confirm: __('Got it', 'elementor')
486 }
487 });
488 }
489 }, {
490 key: "getUnfilteredFilesNotEnabledDialog",
491 value: function getUnfilteredFilesNotEnabledDialog(callback) {
492 var elementorInstance = window.elementorAdmin || window.elementor;
493 if (!elementorInstance.config.user.is_administrator) {
494 return this.getUnfilteredFilesNonAdminDialog();
495 }
496 var onConfirm = function onConfirm() {
497 elementorCommon.ajax.addRequest('enable_unfiltered_files_upload', {}, true);
498 elementorCommon.config.filesUpload.unfilteredFiles = true;
499 callback();
500 };
501 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);
502 }
503 }, {
504 key: "getUnfilteredFilesNotEnabledImportTemplateDialog",
505 value: function getUnfilteredFilesNotEnabledImportTemplateDialog(callback) {
506 if (!(window.elementorAdmin || window.elementor).config.user.is_administrator) {
507 return this.getUnfilteredFilesNonAdminDialog();
508 }
509 return elementorCommon.dialogsManager.createWidget('confirm', {
510 id: 'e-enable-unfiltered-files-dialog-import-template',
511 headerMessage: __('Enable Unfiltered File Uploads', 'elementor'),
512 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'),
513 position: {
514 my: 'center center',
515 at: 'center center'
516 },
517 strings: {
518 confirm: __('Enable and Import', 'elementor'),
519 cancel: __('Import Without Enabling', 'elementor')
520 },
521 onConfirm: function onConfirm() {
522 elementorCommon.ajax.addRequest('enable_unfiltered_files_upload', {
523 success: function success() {
524 // This utility is used in both the admin and the Editor.
525 elementorCommon.config.filesUpload.unfilteredFiles = true;
526 callback();
527 }
528 }, true);
529 },
530 onCancel: function onCancel() {
531 return callback();
532 }
533 });
534 }
535 }]);
536 }();
537
538 /***/ }),
539
540 /***/ "../assets/dev/js/editor/utils/is-instanceof.js":
541 /*!******************************************************!*\
542 !*** ../assets/dev/js/editor/utils/is-instanceof.js ***!
543 \******************************************************/
544 /***/ ((__unused_webpack_module, exports) => {
545
546 "use strict";
547
548
549 Object.defineProperty(exports, "__esModule", ({
550 value: true
551 }));
552 exports["default"] = void 0;
553 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; } } }; }
554 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; } }
555 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; }
556 /**
557 * Some FileAPI objects such as FileList, DataTransferItem and DataTransferItemList has inconsistency with the retrieved
558 * object (from events, etc.) and the actual JavaScript object so a regular instanceof doesn't work. This function can
559 * check whether it's instanceof by using the objects constructor and prototype names.
560 *
561 * @param object
562 * @param constructors
563 * @return {boolean}
564 */
565 var _default = exports["default"] = function _default(object, constructors) {
566 constructors = Array.isArray(constructors) ? constructors : [constructors];
567 var _iterator = _createForOfIteratorHelper(constructors),
568 _step;
569 try {
570 for (_iterator.s(); !(_step = _iterator.n()).done;) {
571 var constructor = _step.value;
572 if (object.constructor.name === constructor.prototype[Symbol.toStringTag]) {
573 return true;
574 }
575 }
576 } catch (err) {
577 _iterator.e(err);
578 } finally {
579 _iterator.f();
580 }
581 return false;
582 };
583
584 /***/ }),
585
586 /***/ "../assets/dev/js/modules/imports/args-object.js":
587 /*!*******************************************************!*\
588 !*** ../assets/dev/js/modules/imports/args-object.js ***!
589 \*******************************************************/
590 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
591
592 "use strict";
593
594
595 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
596 Object.defineProperty(exports, "__esModule", ({
597 value: true
598 }));
599 exports["default"] = void 0;
600 var _typeof2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js"));
601 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
602 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
603 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
604 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
605 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
606 var _instanceType = _interopRequireDefault(__webpack_require__(/*! ./instance-type */ "../assets/dev/js/modules/imports/instance-type.js"));
607 var _isInstanceof = _interopRequireDefault(__webpack_require__(/*! ../../editor/utils/is-instanceof */ "../assets/dev/js/editor/utils/is-instanceof.js"));
608 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)); }
609 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
610 var ArgsObject = exports["default"] = /*#__PURE__*/function (_InstanceType) {
611 /**
612 * Function constructor().
613 *
614 * Create ArgsObject.
615 *
616 * @param {{}} args
617 */
618 function ArgsObject(args) {
619 var _this;
620 (0, _classCallCheck2.default)(this, ArgsObject);
621 _this = _callSuper(this, ArgsObject);
622 _this.args = args;
623 return _this;
624 }
625
626 /**
627 * Function requireArgument().
628 *
629 * Validate property in args.
630 *
631 * @param {string} property
632 * @param {{}} args
633 *
634 * @throws {Error}
635 */
636 (0, _inherits2.default)(ArgsObject, _InstanceType);
637 return (0, _createClass2.default)(ArgsObject, [{
638 key: "requireArgument",
639 value: function requireArgument(property) {
640 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.args;
641 if (!Object.prototype.hasOwnProperty.call(args, property)) {
642 throw Error("".concat(property, " is required."));
643 }
644 }
645
646 /**
647 * Function requireArgumentType().
648 *
649 * Validate property in args using `type === typeof(args.whatever)`.
650 *
651 * @param {string} property
652 * @param {string} type
653 * @param {{}} args
654 *
655 * @throws {Error}
656 */
657 }, {
658 key: "requireArgumentType",
659 value: function requireArgumentType(property, type) {
660 var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.args;
661 this.requireArgument(property, args);
662 if ((0, _typeof2.default)(args[property]) !== type) {
663 throw Error("".concat(property, " invalid type: ").concat(type, "."));
664 }
665 }
666
667 /**
668 * Function requireArgumentInstance().
669 *
670 * Validate property in args using `args.whatever instanceof instance`.
671 *
672 * @param {string} property
673 * @param {*} instance
674 * @param {{}} args
675 *
676 * @throws {Error}
677 */
678 }, {
679 key: "requireArgumentInstance",
680 value: function requireArgumentInstance(property, instance) {
681 var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.args;
682 this.requireArgument(property, args);
683 if (!(args[property] instanceof instance) && !(0, _isInstanceof.default)(args[property], instance)) {
684 throw Error("".concat(property, " invalid instance."));
685 }
686 }
687
688 /**
689 * Function requireArgumentConstructor().
690 *
691 * Validate property in args using `type === args.whatever.constructor`.
692 *
693 * @param {string} property
694 * @param {*} type
695 * @param {{}} args
696 *
697 * @throws {Error}
698 */
699 }, {
700 key: "requireArgumentConstructor",
701 value: function requireArgumentConstructor(property, type) {
702 var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.args;
703 this.requireArgument(property, args);
704
705 // Note: Converting the constructor to string in order to avoid equation issues
706 // due to different memory addresses between iframes (window.Object !== window.top.Object).
707 if (args[property].constructor.toString() !== type.prototype.constructor.toString()) {
708 throw Error("".concat(property, " invalid constructor type."));
709 }
710 }
711 }], [{
712 key: "getInstanceType",
713 value: function getInstanceType() {
714 return 'ArgsObject';
715 }
716 }]);
717 }(_instanceType.default);
718
719 /***/ }),
720
721 /***/ "../assets/dev/js/modules/imports/instance-type.js":
722 /*!*********************************************************!*\
723 !*** ../assets/dev/js/modules/imports/instance-type.js ***!
724 \*********************************************************/
725 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
726
727 "use strict";
728
729
730 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
731 Object.defineProperty(exports, "__esModule", ({
732 value: true
733 }));
734 exports["default"] = void 0;
735 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
736 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
737 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
738 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
739 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; }
740 var InstanceType = exports["default"] = /*#__PURE__*/function () {
741 function InstanceType() {
742 var _this = this;
743 (0, _classCallCheck2.default)(this, InstanceType);
744 // Since anonymous classes sometimes do not get validated by babel, do it manually.
745 var target = this instanceof InstanceType ? this.constructor : void 0;
746 var prototypes = [];
747 while (target.__proto__ && target.__proto__.name) {
748 prototypes.push(target.__proto__);
749 target = target.__proto__;
750 }
751 prototypes.reverse().forEach(function (proto) {
752 return _this instanceof proto;
753 });
754 }
755 return (0, _createClass2.default)(InstanceType, null, [{
756 key: Symbol.hasInstance,
757 value: function value(target) {
758 /**
759 * This is function extending being called each time JS uses instanceOf, since babel use it each time it create new class
760 * its give's opportunity to mange capabilities of instanceOf operator.
761 * saving current class each time will give option later to handle instanceOf manually.
762 */
763 var result = _superPropGet(InstanceType, Symbol.hasInstance, this, 2)([target]);
764
765 // Act normal when validate a class, which does not have instance type.
766 if (target && !target.constructor.getInstanceType) {
767 return result;
768 }
769 if (target) {
770 if (!target.instanceTypes) {
771 target.instanceTypes = [];
772 }
773 if (!result) {
774 if (this.getInstanceType() === target.constructor.getInstanceType()) {
775 result = true;
776 }
777 }
778 if (result) {
779 var name = this.getInstanceType === InstanceType.getInstanceType ? 'BaseInstanceType' : this.getInstanceType();
780 if (-1 === target.instanceTypes.indexOf(name)) {
781 target.instanceTypes.push(name);
782 }
783 }
784 }
785 if (!result && target) {
786 // Check if the given 'target', is instance of known types.
787 result = target.instanceTypes && Array.isArray(target.instanceTypes) && -1 !== target.instanceTypes.indexOf(this.getInstanceType());
788 }
789 return result;
790 }
791 }, {
792 key: "getInstanceType",
793 value: function getInstanceType() {
794 elementorModules.ForceMethodImplementation();
795 }
796 }]);
797 }();
798
799 /***/ }),
800
801 /***/ "../assets/dev/js/modules/imports/module.js":
802 /*!**************************************************!*\
803 !*** ../assets/dev/js/modules/imports/module.js ***!
804 \**************************************************/
805 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
806
807 "use strict";
808
809
810 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
811 var _typeof2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js"));
812 var Module = function Module() {
813 var $ = jQuery,
814 instanceParams = arguments,
815 self = this,
816 events = {};
817 var settings;
818 var ensureClosureMethods = function ensureClosureMethods() {
819 $.each(self, function (methodName) {
820 var oldMethod = self[methodName];
821 if ('function' !== typeof oldMethod) {
822 return;
823 }
824 self[methodName] = function () {
825 return oldMethod.apply(self, arguments);
826 };
827 });
828 };
829 var initSettings = function initSettings() {
830 settings = self.getDefaultSettings();
831 var instanceSettings = instanceParams[0];
832 if (instanceSettings) {
833 $.extend(true, settings, instanceSettings);
834 }
835 };
836 var init = function init() {
837 self.__construct.apply(self, instanceParams);
838 ensureClosureMethods();
839 initSettings();
840 self.trigger('init');
841 };
842 this.getItems = function (items, itemKey) {
843 if (itemKey) {
844 var keyStack = itemKey.split('.'),
845 currentKey = keyStack.splice(0, 1);
846 if (!keyStack.length) {
847 return items[currentKey];
848 }
849 if (!items[currentKey]) {
850 return;
851 }
852 return this.getItems(items[currentKey], keyStack.join('.'));
853 }
854 return items;
855 };
856 this.getSettings = function (setting) {
857 return this.getItems(settings, setting);
858 };
859 this.setSettings = function (settingKey, value, settingsContainer) {
860 if (!settingsContainer) {
861 settingsContainer = settings;
862 }
863 if ('object' === (0, _typeof2.default)(settingKey)) {
864 $.extend(settingsContainer, settingKey);
865 return self;
866 }
867 var keyStack = settingKey.split('.'),
868 currentKey = keyStack.splice(0, 1);
869 if (!keyStack.length) {
870 settingsContainer[currentKey] = value;
871 return self;
872 }
873 if (!settingsContainer[currentKey]) {
874 settingsContainer[currentKey] = {};
875 }
876 return self.setSettings(keyStack.join('.'), value, settingsContainer[currentKey]);
877 };
878 this.getErrorMessage = function (type, functionName) {
879 var message;
880 switch (type) {
881 case 'forceMethodImplementation':
882 message = "The method '".concat(functionName, "' must to be implemented in the inheritor child.");
883 break;
884 default:
885 message = 'An error occurs';
886 }
887 return message;
888 };
889
890 // TODO: This function should be deleted ?.
891 this.forceMethodImplementation = function (functionName) {
892 throw new Error(this.getErrorMessage('forceMethodImplementation', functionName));
893 };
894 this.on = function (eventName, callback) {
895 if ('object' === (0, _typeof2.default)(eventName)) {
896 $.each(eventName, function (singleEventName) {
897 self.on(singleEventName, this);
898 });
899 return self;
900 }
901 var eventNames = eventName.split(' ');
902 eventNames.forEach(function (singleEventName) {
903 if (!events[singleEventName]) {
904 events[singleEventName] = [];
905 }
906 events[singleEventName].push(callback);
907 });
908 return self;
909 };
910 this.off = function (eventName, callback) {
911 if (!events[eventName]) {
912 return self;
913 }
914 if (!callback) {
915 delete events[eventName];
916 return self;
917 }
918 var callbackIndex = events[eventName].indexOf(callback);
919 if (-1 !== callbackIndex) {
920 delete events[eventName][callbackIndex];
921
922 // Reset array index (for next off on same event).
923 events[eventName] = events[eventName].filter(function (val) {
924 return val;
925 });
926 }
927 return self;
928 };
929 this.trigger = function (eventName) {
930 var methodName = 'on' + eventName[0].toUpperCase() + eventName.slice(1),
931 params = Array.prototype.slice.call(arguments, 1);
932 if (self[methodName]) {
933 self[methodName].apply(self, params);
934 }
935 var callbacks = events[eventName];
936 if (!callbacks) {
937 return self;
938 }
939 $.each(callbacks, function (index, callback) {
940 callback.apply(self, params);
941 });
942 return self;
943 };
944 init();
945 };
946 Module.prototype.__construct = function () {};
947 Module.prototype.getDefaultSettings = function () {
948 return {};
949 };
950 Module.prototype.getConstructorID = function () {
951 return this.constructor.name;
952 };
953 Module.extend = function (properties) {
954 var $ = jQuery,
955 parent = this;
956 var child = function child() {
957 return parent.apply(this, arguments);
958 };
959 $.extend(child, parent);
960 child.prototype = Object.create($.extend({}, parent.prototype, properties));
961 child.prototype.constructor = child;
962 child.__super__ = parent.prototype;
963 return child;
964 };
965 module.exports = Module;
966
967 /***/ }),
968
969 /***/ "../assets/dev/js/utils/notifications.js":
970 /*!***********************************************!*\
971 !*** ../assets/dev/js/utils/notifications.js ***!
972 \***********************************************/
973 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
974
975 "use strict";
976
977
978 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
979 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
980 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; }
981 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; }
982 module.exports = elementorModules.Module.extend({
983 initToast: function initToast() {
984 var toast = elementorCommon.dialogsManager.createWidget('buttons', {
985 id: 'elementor-toast',
986 position: {
987 my: 'center bottom',
988 at: 'center bottom-10',
989 of: '#elementor-panel-inner',
990 autoRefresh: true
991 },
992 hide: {
993 onClick: true,
994 auto: true,
995 autoDelay: 10000
996 },
997 effects: {
998 show: function show() {
999 var $widget = toast.getElements('widget');
1000 $widget.show();
1001 toast.refreshPosition();
1002 var top = parseInt($widget.css('top'), 10);
1003 $widget.hide().css('top', top + 100);
1004 $widget.animate({
1005 opacity: 'show',
1006 height: 'show',
1007 paddingBottom: 'show',
1008 paddingTop: 'show',
1009 top: top
1010 }, {
1011 easing: 'linear',
1012 duration: 300
1013 });
1014 },
1015 hide: function hide() {
1016 var $widget = toast.getElements('widget'),
1017 top = parseInt($widget.css('top'), 10);
1018 $widget.animate({
1019 opacity: 'hide',
1020 height: 'hide',
1021 paddingBottom: 'hide',
1022 paddingTop: 'hide',
1023 top: top + 100
1024 }, {
1025 easing: 'linear',
1026 duration: 300
1027 });
1028 }
1029 },
1030 button: {
1031 tag: 'button'
1032 }
1033 });
1034
1035 // Add role="status" and aria-live for screen reader announcement
1036 toast.getElements('widget').attr({
1037 role: 'status',
1038 'aria-live': 'polite',
1039 'aria-atomic': 'true'
1040 });
1041 this.getToast = function () {
1042 return toast;
1043 };
1044 },
1045 showToast: function showToast(options) {
1046 var toast = this.getToast();
1047 toast.setMessage(options.message);
1048 toast.getElements('buttonsWrapper').empty();
1049 toast.focusedButton = null;
1050 toast.buttons = [];
1051 var isPositionValid = this.isPositionValid(options === null || options === void 0 ? void 0 : options.position);
1052 if (!isPositionValid) {
1053 this.positionToWindow();
1054 }
1055 if (options !== null && options !== void 0 && options.position && isPositionValid) {
1056 toast.setSettings('position', options.position);
1057 }
1058 if (options.buttons) {
1059 options.buttons.forEach(function (button) {
1060 toast.addButton(button);
1061 });
1062 }
1063 if (options.classes) {
1064 toast.getElements('widget').addClass(options.classes);
1065 }
1066 if (options.sticky) {
1067 toast.setSettings({
1068 hide: {
1069 auto: false,
1070 onClick: false
1071 }
1072 });
1073 }
1074 return toast.show();
1075 },
1076 isPositionValid: function isPositionValid(position) {
1077 var _position$of;
1078 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;
1079 if (!positionToCheck) {
1080 return false;
1081 }
1082 return !!document.querySelector(positionToCheck);
1083 },
1084 positionToWindow: function positionToWindow() {
1085 var toast = this.getToast();
1086 var position = _objectSpread(_objectSpread({}, toast.getSettings('position')), {}, {
1087 my: 'right top',
1088 at: 'right-10 top+42',
1089 // 42px is the default admin bar height + 10px
1090 of: ''
1091 });
1092 toast.setSettings('position', position);
1093 toast.getElements('widget').addClass('dialog-position-window');
1094 },
1095 onInit: function onInit() {
1096 this.initToast();
1097 }
1098 });
1099
1100 /***/ }),
1101
1102 /***/ "../assets/dev/js/utils/tiers.js":
1103 /*!***************************************!*\
1104 !*** ../assets/dev/js/utils/tiers.js ***!
1105 \***************************************/
1106 /***/ ((__unused_webpack_module, exports) => {
1107
1108 "use strict";
1109
1110
1111 Object.defineProperty(exports, "__esModule", ({
1112 value: true
1113 }));
1114 exports.isTierAtLeast = exports.TIERS_PRIORITY = exports.TIERS = void 0;
1115 var TIERS_PRIORITY = exports.TIERS_PRIORITY = Object.freeze(['free', 'essential', 'essential-oct2023', 'advanced', 'expert', 'agency']);
1116
1117 /**
1118 * @type {Readonly<{
1119 * free: string;
1120 * essential: string;
1121 * 'essential-oct2023': string;
1122 * advanced: string;
1123 * expert: string;
1124 * agency: string;
1125 * }>}
1126 */
1127 var TIERS = exports.TIERS = Object.freeze(TIERS_PRIORITY.reduce(function (acc, tier) {
1128 acc[tier] = tier;
1129 return acc;
1130 }, {}));
1131 var isTierAtLeast = exports.isTierAtLeast = function isTierAtLeast(currentTier, expectedTier) {
1132 var currentTierIndex = TIERS_PRIORITY.indexOf(currentTier);
1133 var expectedTierIndex = TIERS_PRIORITY.indexOf(expectedTier);
1134 if (-1 === currentTierIndex || -1 === expectedTierIndex) {
1135 return false;
1136 }
1137 return currentTierIndex >= expectedTierIndex;
1138 };
1139
1140 /***/ }),
1141
1142 /***/ "../assets/dev/js/utils/time.js":
1143 /*!**************************************!*\
1144 !*** ../assets/dev/js/utils/time.js ***!
1145 \**************************************/
1146 /***/ ((__unused_webpack_module, exports) => {
1147
1148 "use strict";
1149
1150
1151 Object.defineProperty(exports, "__esModule", ({
1152 value: true
1153 }));
1154 exports["default"] = getUserTimestamp;
1155 /**
1156 * Returns the timestamp in ISO8601 format with the UTC timezone offset.
1157 *
1158 * @since 3.6.0
1159 *
1160 * @param {Date} date
1161 * @return {Date} timestamp
1162 */
1163 function getUserTimestamp() {
1164 var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
1165 var timezoneOffset = date.getTimezoneOffset();
1166
1167 // Local time for the user
1168 var UTCTimestamp = new Date(date.getTime() - timezoneOffset * 60000).toISOString();
1169
1170 // Remove the Z suffix from the string.
1171 UTCTimestamp = UTCTimestamp.slice(0, -1);
1172
1173 // Create the offset string in the format `+HH:00` (or minus (-) prefix for negative offset instead of plus)
1174 var decimalTimezoneOffset = timezoneOffset / 60,
1175 // Negative offsets include a '-' sign in the getTimezoneOffset value, positive values need a '+' prefix (ISO8601).
1176 sign = 0 <= decimalTimezoneOffset ? '+' : '-',
1177 hours = Math.abs(Math.floor(decimalTimezoneOffset)),
1178 minutes = Math.abs(decimalTimezoneOffset % 1) * 60,
1179 addZeroToHour = 10 > hours ? '0' : '',
1180 addZeroToMinutes = 10 > minutes ? '0' : '';
1181 var formattedTimezoneOffset = sign + addZeroToHour + hours + ':' + addZeroToMinutes + minutes;
1182 return UTCTimestamp + formattedTimezoneOffset;
1183 }
1184
1185 /***/ }),
1186
1187 /***/ "../core/common/assets/js/components/wordpress/commands-data/index.js":
1188 /*!****************************************************************************!*\
1189 !*** ../core/common/assets/js/components/wordpress/commands-data/index.js ***!
1190 \****************************************************************************/
1191 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1192
1193 "use strict";
1194
1195
1196 Object.defineProperty(exports, "__esModule", ({
1197 value: true
1198 }));
1199 Object.defineProperty(exports, "Media", ({
1200 enumerable: true,
1201 get: function get() {
1202 return _media.Media;
1203 }
1204 }));
1205 var _media = __webpack_require__(/*! ./media */ "../core/common/assets/js/components/wordpress/commands-data/media.js");
1206
1207 /***/ }),
1208
1209 /***/ "../core/common/assets/js/components/wordpress/commands-data/media.js":
1210 /*!****************************************************************************!*\
1211 !*** ../core/common/assets/js/components/wordpress/commands-data/media.js ***!
1212 \****************************************************************************/
1213 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1214
1215 "use strict";
1216 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
1217
1218
1219 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1220 Object.defineProperty(exports, "__esModule", ({
1221 value: true
1222 }));
1223 exports.Media = void 0;
1224 var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "../node_modules/@babel/runtime/regenerator/index.js"));
1225 var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "../node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
1226 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1227 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1228 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1229 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1230 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
1231 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1232 var _commandData = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-data */ "../modules/web-cli/assets/js/modules/command-data.js"));
1233 var _filesUploadHandler = _interopRequireDefault(__webpack_require__(/*! elementor-editor/utils/files-upload-handler */ "../assets/dev/js/editor/utils/files-upload-handler.js"));
1234 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)); }
1235 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1236 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; }
1237 var Media = exports.Media = /*#__PURE__*/function (_CommandData) {
1238 function Media() {
1239 (0, _classCallCheck2.default)(this, Media);
1240 return _callSuper(this, Media, arguments);
1241 }
1242 (0, _inherits2.default)(Media, _CommandData);
1243 return (0, _createClass2.default)(Media, [{
1244 key: "validateArgs",
1245 value: function validateArgs() {
1246 this.requireArgumentInstance('file', File);
1247 }
1248 }, {
1249 key: "getRequestData",
1250 value: function getRequestData() {
1251 var requestData = _superPropGet(Media, "getRequestData", this, 3)([]);
1252 requestData.namespace = 'wp';
1253 requestData.version = '2';
1254 return requestData;
1255 }
1256 }, {
1257 key: "applyBeforeCreate",
1258 value: function applyBeforeCreate(args) {
1259 var _args$options;
1260 args.headers = {
1261 'Content-Disposition': "attachment; filename=".concat(this.file.name),
1262 'Content-Type': this.file.type
1263 };
1264 args.query = {
1265 uploadTypeCaller: 'elementor-wp-media-upload'
1266 };
1267 args.data = this.file;
1268 if ((_args$options = args.options) !== null && _args$options !== void 0 && _args$options.progress) {
1269 this.toast = elementor.notifications.showToast({
1270 // eslint-disable-next-line @wordpress/i18n-ellipsis
1271 message: __('Uploading...'),
1272 sticky: true
1273 });
1274 }
1275 return args;
1276 }
1277 }, {
1278 key: "applyAfterCreate",
1279 value: function applyAfterCreate(data, args) {
1280 var _args$options2;
1281 if ((_args$options2 = args.options) !== null && _args$options2 !== void 0 && _args$options2.progress) {
1282 this.toast.hide();
1283 }
1284 return data;
1285 }
1286 }, {
1287 key: "run",
1288 value: function () {
1289 var _run = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee() {
1290 return _regenerator.default.wrap(function (_context) {
1291 while (1) switch (_context.prev = _context.next) {
1292 case 0:
1293 this.file = this.args.file;
1294 if (!(this.file.size > parseInt(window._wpPluploadSettings.defaults.filters.max_file_size, 10))) {
1295 _context.next = 1;
1296 break;
1297 }
1298 throw new Error(__('The file exceeds the maximum upload size for this site.', 'elementor'));
1299 case 1:
1300 if (!(!window._wpPluploadSettings.defaults.filters.mime_types[0].extensions.split(',').includes(this.file.name.split('.').pop()) && !elementor.config.filesUpload.unfilteredFiles)) {
1301 _context.next = 2;
1302 break;
1303 }
1304 _filesUploadHandler.default.getUnfilteredFilesNotEnabledDialog(function () {}).show();
1305 return _context.abrupt("return");
1306 case 2:
1307 _context.next = 3;
1308 return _superPropGet(Media, "run", this, 3)([]);
1309 case 3:
1310 return _context.abrupt("return", _context.sent);
1311 case 4:
1312 case "end":
1313 return _context.stop();
1314 }
1315 }, _callee, this);
1316 }));
1317 function run() {
1318 return _run.apply(this, arguments);
1319 }
1320 return run;
1321 }()
1322 }], [{
1323 key: "getEndpointFormat",
1324 value: function getEndpointFormat() {
1325 // 'wp/media' to 'media' since `requestData.namespace` is 'wp'.
1326 return 'media';
1327 }
1328 }]);
1329 }(_commandData.default);
1330
1331 /***/ }),
1332
1333 /***/ "../core/common/assets/js/components/wordpress/component.js":
1334 /*!******************************************************************!*\
1335 !*** ../core/common/assets/js/components/wordpress/component.js ***!
1336 \******************************************************************/
1337 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1338
1339 "use strict";
1340
1341
1342 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1343 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
1344 Object.defineProperty(exports, "__esModule", ({
1345 value: true
1346 }));
1347 exports["default"] = void 0;
1348 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1349 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1350 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1351 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1352 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1353 var _componentBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/component-base */ "../modules/web-cli/assets/js/modules/component-base.js"));
1354 var dataCommands = _interopRequireWildcard(__webpack_require__(/*! ./commands-data/ */ "../core/common/assets/js/components/wordpress/commands-data/index.js"));
1355 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); }
1356 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)); }
1357 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1358 var Component = exports["default"] = /*#__PURE__*/function (_ComponentBase) {
1359 function Component() {
1360 (0, _classCallCheck2.default)(this, Component);
1361 return _callSuper(this, Component, arguments);
1362 }
1363 (0, _inherits2.default)(Component, _ComponentBase);
1364 return (0, _createClass2.default)(Component, [{
1365 key: "getNamespace",
1366 value: function getNamespace() {
1367 return 'wp';
1368 }
1369 }, {
1370 key: "defaultData",
1371 value: function defaultData() {
1372 return this.importCommands(dataCommands);
1373 }
1374 }]);
1375 }(_componentBase.default);
1376
1377 /***/ }),
1378
1379 /***/ "../core/common/assets/js/utils/debug.js":
1380 /*!***********************************************!*\
1381 !*** ../core/common/assets/js/utils/debug.js ***!
1382 \***********************************************/
1383 /***/ ((module) => {
1384
1385 "use strict";
1386
1387
1388 // Moved from assets/dev/js/editor/utils
1389 var Debug = function Debug() {
1390 var self = this,
1391 errorStack = [],
1392 settings = {},
1393 elements = {};
1394 var initSettings = function initSettings() {
1395 settings = {
1396 debounceDelay: 500,
1397 urlsToWatch: ['elementor/assets']
1398 };
1399 };
1400 var initElements = function initElements() {
1401 elements.$window = jQuery(window);
1402 };
1403 var onError = function onError(event) {
1404 var _event$originalEvent;
1405 var error = (_event$originalEvent = event.originalEvent) === null || _event$originalEvent === void 0 ? void 0 : _event$originalEvent.error;
1406 if (!error) {
1407 return;
1408 }
1409 var isInWatchList = false,
1410 urlsToWatch = settings.urlsToWatch;
1411 jQuery.each(urlsToWatch, function () {
1412 if (-1 !== error.stack.indexOf(this)) {
1413 isInWatchList = true;
1414 return false;
1415 }
1416 });
1417 if (!isInWatchList) {
1418 return;
1419 }
1420 self.addError({
1421 type: error.name,
1422 message: error.message,
1423 url: event.originalEvent.filename,
1424 line: event.originalEvent.lineno,
1425 column: event.originalEvent.colno
1426 });
1427 };
1428 var bindEvents = function bindEvents() {
1429 elements.$window.on('error', onError);
1430 };
1431 var init = function init() {
1432 initSettings();
1433 initElements();
1434 bindEvents();
1435 self.sendErrors = _.debounce(self.sendErrors, settings.debounceDelay);
1436 };
1437 this.addURLToWatch = function (url) {
1438 settings.urlsToWatch.push(url);
1439 };
1440 this.addCustomError = function (error, category, tag) {
1441 var errorInfo = {
1442 type: error.name,
1443 message: error.message,
1444 url: error.fileName || error.sourceURL,
1445 line: error.lineNumber || error.line,
1446 column: error.columnNumber || error.column,
1447 customFields: {
1448 category: category || 'general',
1449 tag: tag
1450 }
1451 };
1452 if (!errorInfo.url) {
1453 var stackInfo = error.stack.match(/\n {4}at (.*?(?=:(\d+):(\d+)))/);
1454 if (stackInfo) {
1455 errorInfo.url = stackInfo[1];
1456 errorInfo.line = stackInfo[2];
1457 errorInfo.column = stackInfo[3];
1458 }
1459 }
1460 this.addError(errorInfo);
1461 };
1462 this.addError = function (errorParams) {
1463 var defaultParams = {
1464 type: 'Error',
1465 timestamp: Math.floor(new Date().getTime() / 1000),
1466 message: null,
1467 url: null,
1468 line: null,
1469 column: null,
1470 customFields: {}
1471 };
1472 errorStack.push(jQuery.extend(true, defaultParams, errorParams));
1473 self.sendErrors();
1474 };
1475 this.sendErrors = function () {
1476 // Avoid recursions on errors in ajax
1477 elements.$window.off('error', onError);
1478 jQuery.ajax({
1479 url: elementorCommon.config.ajax.url,
1480 method: 'POST',
1481 data: {
1482 action: 'elementor_js_log',
1483 _nonce: elementorCommon.ajax.getSettings('nonce'),
1484 data: errorStack
1485 },
1486 success: function success() {
1487 errorStack = [];
1488
1489 // Restore error handler
1490 elements.$window.on('error', onError);
1491 }
1492 });
1493 };
1494 init();
1495 };
1496 module.exports = Debug;
1497
1498 /***/ }),
1499
1500 /***/ "../core/common/assets/js/utils/helpers.js":
1501 /*!*************************************************!*\
1502 !*** ../core/common/assets/js/utils/helpers.js ***!
1503 \*************************************************/
1504 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1505
1506 "use strict";
1507
1508
1509 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1510 Object.defineProperty(exports, "__esModule", ({
1511 value: true
1512 }));
1513 exports["default"] = void 0;
1514 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1515 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1516 var Helpers = exports["default"] = /*#__PURE__*/function () {
1517 function Helpers() {
1518 (0, _classCallCheck2.default)(this, Helpers);
1519 }
1520 return (0, _createClass2.default)(Helpers, [{
1521 key: "consoleWarn",
1522 value:
1523 /**
1524 * @param {*} args
1525 * @deprecated since 3.7.0, use `elementorDevTools.consoleWarn()` instead.
1526 */
1527 function consoleWarn() {
1528 var _elementorDevTools;
1529 (_elementorDevTools = elementorDevTools).consoleWarn.apply(_elementorDevTools, arguments);
1530
1531 // This is is self is deprecated.
1532 elementorDevTools.deprecation.deprecated('elementorCommon.helpers.consoleWarn()', '3.7.0', 'elementorDevTools.consoleWarn()');
1533 }
1534
1535 /**
1536 * @param {string} message
1537 * @deprecated since 3.7.0, use `console.error()` instead.
1538 */
1539 }, {
1540 key: "consoleError",
1541 value: function consoleError(message) {
1542 // eslint-disable-next-line no-console
1543 console.error(message);
1544
1545 // This is is self is deprecated.
1546 elementorDevTools.deprecation.deprecated('elementorCommon.helpers.consoleError()', '3.7.0', 'console.error()');
1547 }
1548 }, {
1549 key: "cloneObject",
1550 value: function cloneObject(object) {
1551 return JSON.parse(JSON.stringify(object));
1552 }
1553 }, {
1554 key: "upperCaseWords",
1555 value: function upperCaseWords(string) {
1556 return (string + '').replace(/^(.)|\s+(.)/g, function ($1) {
1557 return $1.toUpperCase();
1558 });
1559 }
1560 }, {
1561 key: "getUniqueId",
1562 value: function getUniqueId() {
1563 return Math.random().toString(16).substr(2, 7);
1564 }
1565 }]);
1566 }();
1567
1568 /***/ }),
1569
1570 /***/ "../core/common/assets/js/utils/storage.js":
1571 /*!*************************************************!*\
1572 !*** ../core/common/assets/js/utils/storage.js ***!
1573 \*************************************************/
1574 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1575
1576 "use strict";
1577
1578
1579 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1580 Object.defineProperty(exports, "__esModule", ({
1581 value: true
1582 }));
1583 exports["default"] = void 0;
1584 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1585 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1586 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1587 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1588 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1589 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)); }
1590 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1591 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
1592 function _default() {
1593 (0, _classCallCheck2.default)(this, _default);
1594 return _callSuper(this, _default, arguments);
1595 }
1596 (0, _inherits2.default)(_default, _elementorModules$Mod);
1597 return (0, _createClass2.default)(_default, [{
1598 key: "get",
1599 value: function get(key, options) {
1600 options = options || {};
1601 var storage;
1602 try {
1603 storage = options.session ? sessionStorage : localStorage;
1604 } catch (e) {
1605 return key ? undefined : {};
1606 }
1607 var elementorStorage = storage.getItem('elementor');
1608 if (elementorStorage) {
1609 elementorStorage = JSON.parse(elementorStorage);
1610 } else {
1611 elementorStorage = {};
1612 }
1613 if (!elementorStorage.__expiration) {
1614 elementorStorage.__expiration = {};
1615 }
1616 var expiration = elementorStorage.__expiration;
1617 var expirationToCheck = [];
1618 if (key) {
1619 if (expiration[key]) {
1620 expirationToCheck = [key];
1621 }
1622 } else {
1623 expirationToCheck = Object.keys(expiration);
1624 }
1625 var entryExpired = false;
1626 expirationToCheck.forEach(function (expirationKey) {
1627 if (new Date(expiration[expirationKey]) < new Date()) {
1628 delete elementorStorage[expirationKey];
1629 delete expiration[expirationKey];
1630 entryExpired = true;
1631 }
1632 });
1633 if (entryExpired) {
1634 this.save(elementorStorage, options.session);
1635 }
1636 if (key) {
1637 return elementorStorage[key];
1638 }
1639 return elementorStorage;
1640 }
1641 }, {
1642 key: "set",
1643 value: function set(key, value, options) {
1644 options = options || {};
1645 var elementorStorage = this.get(null, options);
1646 elementorStorage[key] = value;
1647 if (options.lifetimeInSeconds) {
1648 var date = new Date();
1649 date.setTime(date.getTime() + options.lifetimeInSeconds * 1000);
1650 elementorStorage.__expiration[key] = date.getTime();
1651 }
1652 this.save(elementorStorage, options.session);
1653 }
1654 }, {
1655 key: "save",
1656 value: function save(object, session) {
1657 var storage;
1658 try {
1659 storage = session ? sessionStorage : localStorage;
1660 } catch (e) {
1661 return;
1662 }
1663 storage.setItem('elementor', JSON.stringify(object));
1664 }
1665 }]);
1666 }(elementorModules.Module);
1667
1668 /***/ }),
1669
1670 /***/ "../core/common/modules/ajax/assets/js/ajax.js":
1671 /*!*****************************************************!*\
1672 !*** ../core/common/modules/ajax/assets/js/ajax.js ***!
1673 \*****************************************************/
1674 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1675
1676 "use strict";
1677
1678
1679 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1680 Object.defineProperty(exports, "__esModule", ({
1681 value: true
1682 }));
1683 exports["default"] = void 0;
1684 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
1685 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1686 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1687 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1688 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1689 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1690 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)); }
1691 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1692 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
1693 function _default() {
1694 var _this;
1695 (0, _classCallCheck2.default)(this, _default);
1696 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1697 args[_key] = arguments[_key];
1698 }
1699 _this = _callSuper(this, _default, [].concat(args));
1700 _this.requests = {};
1701 _this.cache = {};
1702 _this.initRequestConstants();
1703 _this.debounceSendBatch = _.debounce(_this.sendBatch.bind(_this), 500);
1704 return _this;
1705 }
1706 (0, _inherits2.default)(_default, _elementorModules$Mod);
1707 return (0, _createClass2.default)(_default, [{
1708 key: "getDefaultSettings",
1709 value: function getDefaultSettings() {
1710 return {
1711 ajaxParams: {
1712 type: 'POST',
1713 url: elementorCommon.config.ajax.url,
1714 data: {},
1715 dataType: 'json'
1716 },
1717 actionPrefix: 'elementor_'
1718 };
1719 }
1720 }, {
1721 key: "initRequestConstants",
1722 value: function initRequestConstants() {
1723 this.requestConstants = {
1724 _nonce: this.getSettings('nonce')
1725 };
1726 }
1727 }, {
1728 key: "addRequestConstant",
1729 value: function addRequestConstant(key, value) {
1730 this.requestConstants[key] = value;
1731 }
1732 }, {
1733 key: "getCacheKey",
1734 value: function getCacheKey(request) {
1735 return JSON.stringify({
1736 unique_id: request.unique_id,
1737 data: request.data
1738 });
1739 }
1740 }, {
1741 key: "loadObjects",
1742 value: function loadObjects(options) {
1743 var _this2 = this;
1744 var dataCollection = {};
1745 var deferredArray = [];
1746 if (options.before) {
1747 options.before();
1748 }
1749 options.ids.forEach(function (objectId) {
1750 deferredArray.push(_this2.load({
1751 action: options.action,
1752 unique_id: options.data.unique_id + objectId,
1753 data: jQuery.extend({
1754 id: objectId
1755 }, options.data)
1756 }).done(function (data) {
1757 return dataCollection = jQuery.extend(dataCollection, data);
1758 }));
1759 });
1760 jQuery.when.apply(jQuery, deferredArray).done(function () {
1761 return options.success(dataCollection);
1762 });
1763 }
1764 }, {
1765 key: "load",
1766 value: function load(request, immediately) {
1767 var _this3 = this;
1768 if (!request.unique_id) {
1769 request.unique_id = request.action;
1770 }
1771 if (request.before) {
1772 request.before();
1773 }
1774 var deferred;
1775 var cacheKey = this.getCacheKey(request);
1776 if (_.has(this.cache, cacheKey)) {
1777 deferred = jQuery.Deferred().done(request.success).resolve(this.cache[cacheKey]);
1778 } else {
1779 var _request$error;
1780 deferred = this.addRequest(request.action, {
1781 data: request.data,
1782 unique_id: request.unique_id,
1783 success: function success(data) {
1784 return _this3.cache[cacheKey] = data;
1785 },
1786 error: (_request$error = request.error) !== null && _request$error !== void 0 ? _request$error : function () {}
1787 }, immediately).done(request.success);
1788 }
1789 return deferred;
1790 }
1791 }, {
1792 key: "cancelRequest",
1793 value: function cancelRequest(requestId) {
1794 var request = this.requests[requestId];
1795 if (!request) {
1796 return null;
1797 }
1798 if (request.options.deferred.jqXhr) {
1799 return request.options.deferred.jqXhr.abort('Request canceled');
1800 }
1801 if (request.options.deferred) {
1802 return request.options.deferred.reject('Request canceled');
1803 }
1804 }
1805 }, {
1806 key: "addRequest",
1807 value: function addRequest(action, options, immediately) {
1808 options = options || {};
1809 if (!options.unique_id) {
1810 options.unique_id = action;
1811 }
1812 options.deferred = jQuery.Deferred().done(options.success).fail(options.error).always(options.complete);
1813 var request = {
1814 action: action,
1815 options: options
1816 };
1817 if (immediately) {
1818 var requests = {};
1819 requests[options.unique_id] = request;
1820 options.deferred.jqXhr = this.sendBatch(requests);
1821 } else {
1822 this.requests[options.unique_id] = request;
1823 this.debounceSendBatch();
1824 }
1825 return options.deferred;
1826 }
1827 }, {
1828 key: "sendBatch",
1829 value: function sendBatch(requests) {
1830 var actions = {};
1831 if (!requests) {
1832 requests = this.requests;
1833
1834 // Empty for next batch.
1835 this.requests = {};
1836 }
1837 Object.entries(requests).forEach(function (_ref) {
1838 var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
1839 id = _ref2[0],
1840 request = _ref2[1];
1841 return actions[id] = {
1842 action: request.action,
1843 data: request.options.data
1844 };
1845 });
1846 return this.send('ajax', {
1847 data: {
1848 actions: JSON.stringify(actions)
1849 },
1850 success: function success(data) {
1851 Object.entries(data.responses).forEach(function (_ref3) {
1852 var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
1853 id = _ref4[0],
1854 response = _ref4[1];
1855 var options = requests[id].options;
1856 if (options) {
1857 if (response.success) {
1858 options.deferred.resolve(response.data);
1859 } else if (!response.success) {
1860 options.deferred.reject(response.data);
1861 }
1862 }
1863 });
1864 },
1865 error: function error(data) {
1866 return Object.values(requests).forEach(function (args) {
1867 if (args.options) {
1868 args.options.deferred.reject(data);
1869 }
1870 });
1871 }
1872 });
1873 }
1874 }, {
1875 key: "prepareSend",
1876 value: function prepareSend(action, options) {
1877 var _this4 = this;
1878 var settings = this.getSettings(),
1879 ajaxParams = elementorCommon.helpers.cloneObject(settings.ajaxParams);
1880 options = options || {};
1881 action = settings.actionPrefix + action;
1882 jQuery.extend(ajaxParams, options);
1883 var requestConstants = elementorCommon.helpers.cloneObject(this.requestConstants);
1884 requestConstants.action = action;
1885 var isFormData = ajaxParams.data instanceof FormData;
1886 Object.entries(requestConstants).forEach(function (_ref5) {
1887 var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
1888 key = _ref6[0],
1889 value = _ref6[1];
1890 if (isFormData) {
1891 ajaxParams.data.append(key, value);
1892 } else {
1893 ajaxParams.data[key] = value;
1894 }
1895 });
1896 var successCallback = ajaxParams.success,
1897 errorCallback = ajaxParams.error;
1898 if (successCallback || errorCallback) {
1899 ajaxParams.success = function (response) {
1900 if (response.success && successCallback) {
1901 successCallback(response.data);
1902 }
1903 if (!response.success && errorCallback) {
1904 errorCallback(response.data);
1905 }
1906 };
1907 if (errorCallback) {
1908 ajaxParams.error = function (data) {
1909 return errorCallback(data);
1910 };
1911 } else {
1912 ajaxParams.error = function (xmlHttpRequest) {
1913 if (xmlHttpRequest.readyState || 'abort' !== xmlHttpRequest.statusText) {
1914 _this4.trigger('request:unhandledError', xmlHttpRequest);
1915 }
1916 };
1917 }
1918 }
1919 return ajaxParams;
1920 }
1921 }, {
1922 key: "send",
1923 value: function send(action, options) {
1924 return jQuery.ajax(this.prepareSend(action, options));
1925 }
1926 }, {
1927 key: "addRequestCache",
1928 value: function addRequestCache(request, data) {
1929 var cacheKey = this.getCacheKey(request);
1930 this.cache[cacheKey] = data;
1931 }
1932 }, {
1933 key: "invalidateCache",
1934 value: function invalidateCache(request) {
1935 var cacheKey = this.getCacheKey(request);
1936 delete this.cache[cacheKey];
1937 }
1938 }]);
1939 }(elementorModules.Module);
1940
1941 /***/ }),
1942
1943 /***/ "../core/common/modules/connect/assets/js/connect.js":
1944 /*!***********************************************************!*\
1945 !*** ../core/common/modules/connect/assets/js/connect.js ***!
1946 \***********************************************************/
1947 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1948
1949 "use strict";
1950 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
1951
1952
1953 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1954 Object.defineProperty(exports, "__esModule", ({
1955 value: true
1956 }));
1957 exports["default"] = void 0;
1958 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1959 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1960 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1961 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1962 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
1963 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1964 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)); }
1965 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1966 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; }
1967 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Vie) {
1968 function _default() {
1969 (0, _classCallCheck2.default)(this, _default);
1970 return _callSuper(this, _default, arguments);
1971 }
1972 (0, _inherits2.default)(_default, _elementorModules$Vie);
1973 return (0, _createClass2.default)(_default, [{
1974 key: "addPopupPlugin",
1975 value: function addPopupPlugin() {
1976 var counter = 0;
1977 jQuery.fn.elementorConnect = function (options) {
1978 var _this = this;
1979 // Open the Connect Dialog in a popup window.
1980 if (options !== null && options !== void 0 && options.popup) {
1981 jQuery(this).on('click', function (event) {
1982 var _options$popup, _options$popup2;
1983 event.preventDefault();
1984 var width = ((_options$popup = options.popup) === null || _options$popup === void 0 ? void 0 : _options$popup.width) || 600,
1985 height = ((_options$popup2 = options.popup) === null || _options$popup2 === void 0 ? void 0 : _options$popup2.height) || 700;
1986 window.open(jQuery(_this).attr('href') + '&mode=popup', 'elementorConnect', "toolbar=no, menubar=no, width=".concat(width, ", height=").concat(height, ", top=200, left=0"));
1987 });
1988 delete options.popup;
1989 }
1990 var settings = jQuery.extend({
1991 // These are the defaults.
1992 success: function success() {
1993 return location.reload();
1994 },
1995 error: function error() {
1996 elementor.notifications.showToast({
1997 message: __('Unable to connect', 'elementor')
1998 });
1999 },
2000 parseUrl: function parseUrl(url) {
2001 return url;
2002 } // Allow to change the url, e.g: replace placeholders like '%%template_type%%' with actual value.
2003 }, options);
2004 this.each(function () {
2005 counter++;
2006 var $this = jQuery(this),
2007 callbackId = 'cb' + counter;
2008 $this.attr({
2009 target: '_blank',
2010 rel: 'opener',
2011 href: settings.parseUrl($this.attr('href') + '&mode=popup&callback_id=' + callbackId)
2012 });
2013 elementorCommon.elements.$window.on('elementor/connect/success/' + callbackId, settings.success).on('elementor/connect/error/' + callbackId, settings.error);
2014 });
2015 return this;
2016 };
2017 }
2018 }, {
2019 key: "getDefaultSettings",
2020 value: function getDefaultSettings() {
2021 return {
2022 selectors: {
2023 connectButton: '#elementor-template-library-connect__button'
2024 }
2025 };
2026 }
2027 }, {
2028 key: "getDefaultElements",
2029 value: function getDefaultElements() {
2030 return {
2031 $connectButton: jQuery(this.getSettings('selectors.connectButton'))
2032 };
2033 }
2034 }, {
2035 key: "applyPopup",
2036 value: function applyPopup() {
2037 this.elements.$connectButton.elementorConnect();
2038 }
2039 }, {
2040 key: "onInit",
2041 value: function onInit() {
2042 _superPropGet(_default, "onInit", this, 3)([]);
2043 this.addPopupPlugin();
2044 this.applyPopup();
2045 }
2046 }]);
2047 }(elementorModules.ViewModule);
2048
2049 /***/ }),
2050
2051 /***/ "../core/common/modules/event-tracker/assets/js/data/commands-data/index.js":
2052 /*!**********************************************************************************!*\
2053 !*** ../core/common/modules/event-tracker/assets/js/data/commands-data/index.js ***!
2054 \**********************************************************************************/
2055 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2056
2057 "use strict";
2058
2059
2060 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2061 Object.defineProperty(exports, "__esModule", ({
2062 value: true
2063 }));
2064 exports.Index = void 0;
2065 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2066 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2067 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2068 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2069 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2070 var _commandData = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-data */ "../modules/web-cli/assets/js/modules/command-data.js"));
2071 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)); }
2072 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2073 var Index = exports.Index = /*#__PURE__*/function (_CommandData) {
2074 function Index() {
2075 (0, _classCallCheck2.default)(this, Index);
2076 return _callSuper(this, Index, arguments);
2077 }
2078 (0, _inherits2.default)(Index, _CommandData);
2079 return (0, _createClass2.default)(Index, null, [{
2080 key: "getEndpointFormat",
2081 value: function getEndpointFormat() {
2082 return 'send-event';
2083 }
2084 }]);
2085 }(_commandData.default);
2086
2087 /***/ }),
2088
2089 /***/ "../core/common/modules/event-tracker/assets/js/data/component.js":
2090 /*!************************************************************************!*\
2091 !*** ../core/common/modules/event-tracker/assets/js/data/component.js ***!
2092 \************************************************************************/
2093 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2094
2095 "use strict";
2096
2097
2098 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2099 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
2100 Object.defineProperty(exports, "__esModule", ({
2101 value: true
2102 }));
2103 exports["default"] = void 0;
2104 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2105 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2106 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2107 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2108 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2109 var _componentBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/component-base */ "../modules/web-cli/assets/js/modules/component-base.js"));
2110 var commandsData = _interopRequireWildcard(__webpack_require__(/*! ./commands-data/ */ "../core/common/modules/event-tracker/assets/js/data/commands-data/index.js"));
2111 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); }
2112 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)); }
2113 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2114 var Component = exports["default"] = /*#__PURE__*/function (_ComponentBase) {
2115 function Component() {
2116 (0, _classCallCheck2.default)(this, Component);
2117 return _callSuper(this, Component, arguments);
2118 }
2119 (0, _inherits2.default)(Component, _ComponentBase);
2120 return (0, _createClass2.default)(Component, [{
2121 key: "getNamespace",
2122 value: function getNamespace() {
2123 return 'event-tracker';
2124 }
2125 }, {
2126 key: "defaultData",
2127 value: function defaultData() {
2128 return this.importCommands(commandsData);
2129 }
2130 }]);
2131 }(_componentBase.default);
2132
2133 /***/ }),
2134
2135 /***/ "../core/common/modules/event-tracker/assets/js/events.js":
2136 /*!****************************************************************!*\
2137 !*** ../core/common/modules/event-tracker/assets/js/events.js ***!
2138 \****************************************************************/
2139 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2140
2141 "use strict";
2142
2143
2144 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2145 Object.defineProperty(exports, "__esModule", ({
2146 value: true
2147 }));
2148 exports["default"] = void 0;
2149 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2150 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2151 var _time = _interopRequireDefault(__webpack_require__(/*! elementor-utils/time */ "../assets/dev/js/utils/time.js"));
2152 var Events = exports["default"] = /*#__PURE__*/function () {
2153 function Events() {
2154 (0, _classCallCheck2.default)(this, Events);
2155 }
2156 return (0, _createClass2.default)(Events, [{
2157 key: "dispatchEvent",
2158 value: function dispatchEvent(eventData) {
2159 if (!eventData) {
2160 return;
2161 }
2162 eventData.ts = (0, _time.default)();
2163
2164 // No need to wait for response, no need to block browser in any way.
2165 $e.data.create('event-tracker/index', {
2166 event_data: eventData
2167 });
2168 }
2169 }]);
2170 }();
2171
2172 /***/ }),
2173
2174 /***/ "../core/common/modules/events-manager/assets/js/events-config.js":
2175 /*!************************************************************************!*\
2176 !*** ../core/common/modules/events-manager/assets/js/events-config.js ***!
2177 \************************************************************************/
2178 /***/ ((__unused_webpack_module, exports) => {
2179
2180 "use strict";
2181
2182
2183 Object.defineProperty(exports, "__esModule", ({
2184 value: true
2185 }));
2186 exports["default"] = void 0;
2187 var eventsConfig = {
2188 appTypes: {
2189 editor: 'editor',
2190 wpAdmin: 'wpadmin',
2191 wpDash: 'wpdash'
2192 },
2193 targetTypes: {
2194 dropdownItem: 'dropdown_item',
2195 button: 'button',
2196 tab: 'tab',
2197 toggle: 'toggle',
2198 searchInput: 'search_input',
2199 searchResult: 'search_result',
2200 buttons: 'buttons',
2201 searchWidget: 'search_widget',
2202 wpDashAdminMenuItem: 'wpdash_admin_menu_item',
2203 wpDashEditorMenu: 'wpdash_editor_menu',
2204 wpDashSubMenuItem: 'wpdash_sub_menu_item'
2205 },
2206 interactionResults: {
2207 actionSelected: 'action_selected',
2208 navigate: 'navigate',
2209 create: 'create',
2210 sessionEnd: 'session_end',
2211 tabChanged: 'tab_changed',
2212 assetInserted: 'asset_inserted',
2213 assetFavorite: 'asset_favorite',
2214 aiGenerate: 'ai_generate',
2215 resultsUpdated: 'results_updated',
2216 noResults: 'no_results',
2217 selected: 'selected',
2218 promotionViewed: 'promotion_viewed',
2219 upgradeNow: 'upgrade_now',
2220 elementorSideMenuOpened: 'elementor_side_menu_opened',
2221 editorSubMenuOpened: 'wpdash_editor_sub_menu_opened',
2222 themeBuilderPromotionWindow: 'theme_builder_promotion_window'
2223 },
2224 targetNames: {
2225 publishDropdown: {
2226 saveDraft: 'save_draft',
2227 saveAsTemplate: 'save_as_template',
2228 viewPage: 'view_page',
2229 copyAndShare: 'copy_and_share'
2230 },
2231 pageList: {
2232 addNewPage: 'add_new_page'
2233 }
2234 },
2235 triggers: {
2236 click: 'Click',
2237 rightClick: 'Right Click',
2238 doubleClick: 'Double Click',
2239 accordionClick: 'Accordion Click',
2240 toggleClick: 'Toggle Click',
2241 dropdownClick: 'Click Dropdown',
2242 editorLoaded: 'Editor Loaded',
2243 visible: 'Visible',
2244 pageLoaded: 'Page Loaded',
2245 typing: 'Typing',
2246 tabSelect: 'Tab Select',
2247 insert: 'Insert',
2248 hover: 'Hover'
2249 },
2250 locations: {
2251 widgetPanel: 'Widget Panel',
2252 topBar: 'Top Bar',
2253 sidebar: 'Sidebar',
2254 elementorEditor: 'Elementor Editor',
2255 templatesLibrary: {
2256 library: 'Templates Library'
2257 },
2258 app: {
2259 import: 'Import Kit',
2260 export: 'Export Kit',
2261 kitLibrary: 'Kit Library',
2262 cloudKitLibrary: 'Cloud Kit Library'
2263 },
2264 variables: 'Variables Panel',
2265 variablesManager: 'Variables Manager',
2266 admin: 'WP admin',
2267 wpDashAdmin: 'wpdash_admin',
2268 structurePanel: 'Structure Panel',
2269 canvas: 'Canvas',
2270 leftPanel: 'Left Panel',
2271 elementorLibrary: 'Elementor Library',
2272 components: {
2273 instanceEditingPanel: 'Instance Editing Panel'
2274 }
2275 },
2276 secondaryLocations: {
2277 layout: 'Layout Section',
2278 basic: 'Basic Section',
2279 'pro-elements': 'Pro Section',
2280 general: 'General Section',
2281 'theme-elements': 'Site Section',
2282 'theme-elements-single': 'Single Section',
2283 'woocommerce-elements': 'WooCommerce Section',
2284 wordpress: 'WordPress Section',
2285 categories: 'Widgets Tab',
2286 global: 'Globals Tab',
2287 'whats-new': 'What\'s New',
2288 'document-settings': 'Document Settings icon',
2289 'preview-page': 'Preview Page',
2290 'publish-button': 'Publish Button',
2291 'widget-panel': 'Widget Panel Icon',
2292 finder: 'Finder',
2293 help: 'Help',
2294 elementorLogoDropdown: 'top_bar_elementor_logo_dropdown',
2295 elementorLogo: 'Elementor Logo',
2296 eLogoMenu: 'E-logo Menu',
2297 notes: 'Notes',
2298 siteSettings: 'Site Settings',
2299 structure: 'Structure',
2300 documentNameDropdown: 'Document Name dropdown',
2301 responsiveControls: 'Responsive controls',
2302 launchpad: 'launchpad',
2303 checklistHeader: 'Checklist Header',
2304 checklistSteps: 'Checklist Steps',
2305 userPreferences: 'User Preferences',
2306 contextMenu: 'Context Menu',
2307 templateLibrary: {
2308 saveModal: 'Save to Modal',
2309 moveModal: 'Move to Modal',
2310 bulkMoveModal: 'Bulk Move to Modal',
2311 copyModal: 'Copy to Modal',
2312 bulkCopyModal: 'Bulk Copy to Modal',
2313 saveModalSelectFolder: 'Save to Modal - select folder',
2314 saveModalSelectConnect: 'Save to Modal - connect',
2315 saveModalSelectUpgrade: 'Save to Modal - upgrade',
2316 importModal: 'Import Modal',
2317 newFolderModal: 'New Folder Modal',
2318 deleteDialog: 'Delete Dialog',
2319 deleteFolderDialog: 'Delete Folder Dialog',
2320 renameDialog: 'Rename Dialog',
2321 createFolderDialog: 'Create Folder Dialog',
2322 applySettingsDialog: 'Apply Settings Dialog',
2323 cloudTab: 'Cloud Tab',
2324 siteTab: 'Site Tab',
2325 cloudTabFolder: 'Cloud Tab - Folder',
2326 cloudTabConnect: 'Cloud Tab - Connect',
2327 cloudTabUpgrade: 'Cloud Tab - Upgrade',
2328 morePopup: 'Context Menu',
2329 quotaBar: 'Quota Bar'
2330 },
2331 kitLibrary: {
2332 cloudKitLibrary: 'kits_cloud_library',
2333 cloudKitLibraryConnect: 'kits_cloud_library_connect',
2334 cloudKitLibraryUpgrade: 'kits_cloud_library_upgrade',
2335 kitExportCustomization: 'kit_export_customization',
2336 kitExport: 'kit_export',
2337 kitExportCustomizationEdit: 'kit_export_customization_edit',
2338 kitExportSummary: 'kit_export_summary',
2339 kitImportUploadBox: 'kit_import_upload_box',
2340 kitImportCustomization: 'kit_import_customization',
2341 kitImportSummary: 'kit_import_summary'
2342 },
2343 variablesPopover: 'Variables Popover',
2344 admin: {
2345 pluginToolsTab: 'plugin_tools_tab',
2346 pluginWebsiteTemplatesTab: 'plugin_website_templates_tab'
2347 },
2348 componentsTab: 'Components Tab',
2349 canvasElement: 'Canvas Element',
2350 publishDropdown: 'Publish Dropdown',
2351 pageListDropdown: 'Page List Dropdown',
2352 emptyBox: 'Empty Box',
2353 searchBar: 'Search Bar',
2354 finderResults: 'Finder Results',
2355 libraryTabs: 'Library Tabs',
2356 assetCard: 'Asset Card',
2357 wpDashElementorCoreMenu: 'elementor_editor_core_menu',
2358 wpDashElementorCoreSubMenu: 'elementor_editor_core_sub_menu',
2359 wpDashThemeBuilder: 'wpdash_core_sub_menu_theme_builder'
2360 },
2361 elements: {
2362 accordionSection: 'Accordion section',
2363 buttonIcon: 'Button Icon',
2364 mainCta: 'Main CTA',
2365 button: 'Button',
2366 link: 'Link',
2367 dropdown: 'Dropdown',
2368 toggle: 'Toggle',
2369 launchpadChecklist: 'Checklist popup'
2370 },
2371 names: {
2372 v1: {
2373 layout: 'v1_widgets_tab_layout_section',
2374 basic: 'v1_widgets_tab_basic_section',
2375 'pro-elements': 'v1_widgets_tab_pro_section',
2376 general: 'v1_widgets_tab_general_section',
2377 'theme-elements': 'v1_widgets_tab_site_section',
2378 'theme-elements-single': 'v1_widgets_tab_single_section',
2379 'woocommerce-elements': 'v1_widgets_tab_woocommerce_section',
2380 wordpress: 'v1_widgets_tab_wordpress_section',
2381 categories: 'v1_widgets_tab',
2382 global: 'v1_globals_tab'
2383 },
2384 topBar: {
2385 whatsNew: 'top_bar_whats_new',
2386 documentSettings: 'top_bar_document_settings_icon',
2387 previewPage: 'top_bar_preview_page',
2388 publishButton: 'top_bar_publish_button',
2389 widgetPanel: 'top_bar_widget_panel_icon',
2390 finder: 'top_bar_finder',
2391 help: 'top_bar_help',
2392 history: 'top_bar_elementor_logo_dropdown_history',
2393 userPreferences: 'top_bar_elementor_logo_dropdown_user_preferences',
2394 keyboardShortcuts: 'top_bar_elementor_logo_dropdown_keyboard_shortcuts',
2395 exitToWordpress: 'top_bar_elementor_logo_dropdown_exit_to_wordpress',
2396 themeBuilder: 'top_bar_elementor_logo_dropdown_theme_builder',
2397 notes: 'top_bar_notes',
2398 siteSettings: 'top_bar_site_setting',
2399 structure: 'top_bar_structure',
2400 documentNameDropdown: 'top_bar_document_name_dropdown',
2401 responsiveControls: 'top_bar_responsive_controls',
2402 launchpadOn: 'top_bar_checklist_icon_show',
2403 launchpadOff: 'top_bar_checklist_icon_hide',
2404 elementorLogoDropdown: 'open_e_menu',
2405 connectAccount: 'connect_account',
2406 accountConnected: 'account_connected'
2407 },
2408 // ChecklistSteps event names are generated dynamically, based on stepId and action type taken: title, action, done, undone, upgrade
2409 elementorEditor: {
2410 editorLoaded: 'editor_loaded',
2411 checklist: {
2412 checklistHeaderClose: 'checklist_header_close_icon',
2413 checklistFirstPopup: 'checklist popup triggered'
2414 },
2415 userPreferences: {
2416 checklistShow: 'checklist_userpreferences_toggle_show',
2417 checklistHide: 'checklist_userpreferences_toggle_hide'
2418 }
2419 },
2420 variables: {
2421 open: 'open_variables_popover',
2422 add: 'add_new_variable',
2423 connect: 'connect_variable',
2424 save: 'save_new_variable',
2425 openManager: 'open_variables_manager',
2426 saveChanges: 'save_variables_changes',
2427 delete: 'delete_variable',
2428 variableSyncToV3: 'variable_sync_to_v3'
2429 },
2430 design_system: {
2431 importOpened: 'design_system_import_opened',
2432 fileSelected: 'design_system_file_selected',
2433 validationFailed: 'design_system_validation_failed',
2434 conflictChoice: 'design_system_conflict_choice',
2435 confirmed: 'design_system_import_confirmed',
2436 imported: 'design_system_imported',
2437 importFailed: 'design_system_import_failed'
2438 },
2439 components: {
2440 createClicked: 'component_create_clicked',
2441 createCancelled: 'component_creation_cancelled',
2442 created: 'component_created',
2443 instanceAdded: 'component_instance_added',
2444 edited: 'component_edited',
2445 propertiesPanelOpened: 'component_properties_panel_opened',
2446 propertiesGroupCreated: 'component_properties_group_created',
2447 propertyExposed: 'component_property_exposed',
2448 propertyRemoved: 'component_property_removed',
2449 detached: 'component_detached'
2450 },
2451 global_classes: {
2452 classApplied: 'class_applied',
2453 classRemoved: 'class_removed',
2454 classManagerFilterCleared: 'class_manager_filter_cleared',
2455 classDeleted: 'class_deleted',
2456 classPublishConflict: 'class_publish_conflict',
2457 classRenamed: 'class_renamed',
2458 classCreated: 'class_created',
2459 classManagerSearched: 'class_manager_searched',
2460 classManagerFiltersOpened: 'class_manager_filters_opened',
2461 classManagerOpened: 'class_manager_opened',
2462 classManagerReorder: 'class_manager_reorder',
2463 classManagerFilterUsed: 'class_manager_filter_used',
2464 classUsageLocate: 'class_usage_locate',
2465 classUsageHovered: 'class_usage_hovered',
2466 classStyled: 'class_styled',
2467 classStateClicked: 'class_state_clicked',
2468 classUsageClicked: 'class_usage_clicked',
2469 classDuplicate: 'class_duplicate',
2470 classSyncToV3PopupShown: 'class_sync_to_v3_popup_shown',
2471 classSyncToV3: 'class_sync_to_v3',
2472 classSyncToV3PopupClick: 'class_sync_to_v3_popup_click'
2473 },
2474 editorOne: {
2475 topBarPublishDropdown: 'top_bar_publish_dropdown',
2476 topBarPageList: 'top_bar_page_list',
2477 siteSettingsSession: 'site_settings_session',
2478 eLibraryNav: 'e_library_nav',
2479 eLibraryInsert: 'e_library_insert',
2480 eLibraryFavorite: 'e_library_favorite',
2481 eLibraryGenerateAi: 'e_library_generate_ai',
2482 finderSearchInput: 'finder_search_input',
2483 finderResultSelect: 'finder_result_select',
2484 canvasEmptyBoxAction: 'canvas_empty_box_action',
2485 widgetPanelSearch: 'widget_panel_search',
2486 wpDashElementorMenuClick: 'wpdash_elementor_menu_click',
2487 wpDashEditorSubMenuHover: 'wpdash_editor_sub_menu_hover',
2488 wpDashThemeBuilderClick: 'wpdash_theme_builder_click'
2489 },
2490 interactions: {
2491 created: 'interactions_created'
2492 },
2493 promotions: {
2494 viewPromotion: 'view_promotion',
2495 upgradePromotionClick: 'upgrade_promotion_click'
2496 }
2497 }
2498 };
2499 var _default = exports["default"] = eventsConfig;
2500
2501 /***/ }),
2502
2503 /***/ "../core/common/modules/events-manager/assets/js/module.js":
2504 /*!*****************************************************************!*\
2505 !*** ../core/common/modules/events-manager/assets/js/module.js ***!
2506 \*****************************************************************/
2507 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2508
2509 "use strict";
2510
2511
2512 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2513 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
2514 Object.defineProperty(exports, "__esModule", ({
2515 value: true
2516 }));
2517 exports["default"] = void 0;
2518 var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "../node_modules/@babel/runtime/regenerator/index.js"));
2519 var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "../node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
2520 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2521 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2522 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2523 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2524 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2525 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
2526 var _eventsConfig = _interopRequireDefault(__webpack_require__(/*! ./events-config */ "../core/common/modules/events-manager/assets/js/events-config.js"));
2527 var _mixpanelBrowser = _interopRequireWildcard(__webpack_require__(/*! mixpanel-browser */ "../node_modules/mixpanel-browser/dist/mixpanel.module.js"));
2528 var _tiers = __webpack_require__(/*! elementor-utils/tiers */ "../assets/dev/js/utils/tiers.js");
2529 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 _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
2530 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; }
2531 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; }
2532 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)); }
2533 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2534 /** @type {Mixpanel | null} */
2535 var mixpanelInstance = null;
2536 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
2537 function _default() {
2538 var _this;
2539 (0, _classCallCheck2.default)(this, _default);
2540 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2541 args[_key] = arguments[_key];
2542 }
2543 _this = _callSuper(this, _default, [].concat(args));
2544 (0, _defineProperty2.default)(_this, "trackingEnabled", false);
2545 (0, _defineProperty2.default)(_this, "availableExperiments", []);
2546 return _this;
2547 }
2548 (0, _inherits2.default)(_default, _elementorModules$Mod);
2549 return (0, _createClass2.default)(_default, [{
2550 key: "onInit",
2551 value: function onInit() {
2552 var _this2 = this;
2553 this.config = _eventsConfig.default;
2554 if (!this.canSendEvents()) {
2555 return;
2556 }
2557 this.initializeMixpanel(function () {
2558 return _this2.enableTracking();
2559 });
2560 }
2561 }, {
2562 key: "initializeMixpanel",
2563 value: function initializeMixpanel(onLoaded) {
2564 if (mixpanelInstance && mixpanelInstance.isInitialized) {
2565 onLoaded(mixpanelInstance);
2566 } else {
2567 var _elementorCommon$conf, _elementorCommon$conf2, _elementorCommon$conf3, _elementorCommon$conf4, _elementorCommon$conf5;
2568 mixpanelInstance = _mixpanelBrowser.default.init((_elementorCommon$conf = elementorCommon.config.editor_events) === null || _elementorCommon$conf === void 0 ? void 0 : _elementorCommon$conf.token, {
2569 persistence: 'localStorage',
2570 debug: (_elementorCommon$conf2 = (_elementorCommon$conf3 = elementorCommon.config.editor_events) === null || _elementorCommon$conf3 === void 0 ? void 0 : _elementorCommon$conf3.debug) !== null && _elementorCommon$conf2 !== void 0 ? _elementorCommon$conf2 : false,
2571 autocapture: false,
2572 flags: true,
2573 api_host: 'https://api-eu.mixpanel.com',
2574 loaded: onLoaded,
2575 record_sessions_percent: (_elementorCommon$conf4 = (_elementorCommon$conf5 = elementorCommon.config.editor_events) === null || _elementorCommon$conf5 === void 0 ? void 0 : _elementorCommon$conf5.session_recording_percent) !== null && _elementorCommon$conf4 !== void 0 ? _elementorCommon$conf4 : 0,
2576 record_idle_timeout_ms: 60 * 1000,
2577 // 60 Seconds
2578 record_min_ms: 5 * 1000,
2579 // 5 Seconds
2580 record_mask_text_selector: '',
2581 remote_settings_mode: 'strict'
2582 }, 'elementor-editor');
2583 }
2584 elementorCommon.config.editor_events.mixpanelInstance = mixpanelInstance;
2585 }
2586 }, {
2587 key: "enableTracking",
2588 value: function enableTracking() {
2589 var _elementorCommon$conf6;
2590 if (!this.isMixpanelReady()) {
2591 return;
2592 }
2593 var userId = (_elementorCommon$conf6 = elementorCommon.config.editor_events) === null || _elementorCommon$conf6 === void 0 ? void 0 : _elementorCommon$conf6.user_id;
2594 mixpanelInstance.register({
2595 appType: 'Editor'
2596 });
2597 if (userId) {
2598 var _elementorCommon$conf7;
2599 mixpanelInstance.identify(userId);
2600 mixpanelInstance.people.set_once({
2601 $user_id: userId,
2602 $last_login: new Date().toISOString(),
2603 $plan_type: ((_elementorCommon$conf7 = elementorCommon.config.library_connect) === null || _elementorCommon$conf7 === void 0 ? void 0 : _elementorCommon$conf7.plan_type) || _tiers.TIERS.free
2604 });
2605 }
2606 this.trackingEnabled = true;
2607 this.availableExperiments = Object.keys(elementorCommon.config.experimentalFeatures || {});
2608 }
2609 }, {
2610 key: "dispatchEvent",
2611 value: function dispatchEvent(name, data) {
2612 var _elementorCommon$conf8, _elementorCommon$conf9, _elementorCommon$conf0, _elementorCommon$conf1, _elementorCommon$conf10, _elementorCommon$conf11, _elementorCommon$conf12, _elementorCommon$conf13, _elementorCommon$conf14;
2613 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2614 if (!this.canSendEvents()) {
2615 return;
2616 }
2617 if (!this.trackingEnabled) {
2618 this.enableTracking();
2619 }
2620 var eventData = _objectSpread({
2621 user_id: ((_elementorCommon$conf8 = elementorCommon.config.editor_events) === null || _elementorCommon$conf8 === void 0 ? void 0 : _elementorCommon$conf8.user_id) || null,
2622 user_roles: ((_elementorCommon$conf9 = elementorCommon.config.library_connect) === null || _elementorCommon$conf9 === void 0 ? void 0 : _elementorCommon$conf9.user_roles) || [],
2623 subscription_id: ((_elementorCommon$conf0 = elementorCommon.config.editor_events) === null || _elementorCommon$conf0 === void 0 ? void 0 : _elementorCommon$conf0.subscription_id) || null,
2624 user_tier: ((_elementorCommon$conf1 = elementorCommon.config.library_connect) === null || _elementorCommon$conf1 === void 0 ? void 0 : _elementorCommon$conf1.current_access_tier) || null,
2625 url: (_elementorCommon$conf10 = elementorCommon.config.editor_events) === null || _elementorCommon$conf10 === void 0 ? void 0 : _elementorCommon$conf10.site_url,
2626 wp_version: (_elementorCommon$conf11 = elementorCommon.config.editor_events) === null || _elementorCommon$conf11 === void 0 ? void 0 : _elementorCommon$conf11.wp_version,
2627 client_id: (_elementorCommon$conf12 = elementorCommon.config.editor_events) === null || _elementorCommon$conf12 === void 0 ? void 0 : _elementorCommon$conf12.site_key,
2628 app_version: (_elementorCommon$conf13 = elementorCommon.config.editor_events) === null || _elementorCommon$conf13 === void 0 ? void 0 : _elementorCommon$conf13.elementor_version,
2629 site_language: (_elementorCommon$conf14 = elementorCommon.config.editor_events) === null || _elementorCommon$conf14 === void 0 ? void 0 : _elementorCommon$conf14.site_language,
2630 experiments: this.availableExperiments
2631 }, data);
2632 mixpanelInstance.track(name, eventData, options);
2633 }
2634 }, {
2635 key: "featureFlagIsActive",
2636 value: function () {
2637 var _featureFlagIsActive = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(flagName) {
2638 var _mixpanelInstance;
2639 var isEnabled;
2640 return _regenerator.default.wrap(function (_context) {
2641 while (1) switch (_context.prev = _context.next) {
2642 case 0:
2643 if (!('function' !== typeof ((_mixpanelInstance = mixpanelInstance) === null || _mixpanelInstance === void 0 || (_mixpanelInstance = _mixpanelInstance.flags) === null || _mixpanelInstance === void 0 ? void 0 : _mixpanelInstance.is_enabled))) {
2644 _context.next = 1;
2645 break;
2646 }
2647 return _context.abrupt("return", false);
2648 case 1:
2649 _context.next = 2;
2650 return mixpanelInstance.flags.is_enabled(flagName, false);
2651 case 2:
2652 isEnabled = _context.sent;
2653 return _context.abrupt("return", true === isEnabled);
2654 case 3:
2655 case "end":
2656 return _context.stop();
2657 }
2658 }, _callee);
2659 }));
2660 function featureFlagIsActive(_x) {
2661 return _featureFlagIsActive.apply(this, arguments);
2662 }
2663 return featureFlagIsActive;
2664 }()
2665 }, {
2666 key: "getExperimentVariant",
2667 value: function () {
2668 var _getExperimentVariant = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2(experimentName) {
2669 var defaultValue,
2670 _elementorCommon$conf15,
2671 _elementorCommon$conf16,
2672 isAbTestingEnabled,
2673 variant,
2674 _args2 = arguments,
2675 _t;
2676 return _regenerator.default.wrap(function (_context2) {
2677 while (1) switch (_context2.prev = _context2.next) {
2678 case 0:
2679 defaultValue = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : 'control';
2680 _context2.prev = 1;
2681 if (this.canSendEvents()) {
2682 _context2.next = 2;
2683 break;
2684 }
2685 return _context2.abrupt("return", defaultValue);
2686 case 2:
2687 isAbTestingEnabled = (_elementorCommon$conf15 = (_elementorCommon$conf16 = elementorCommon.config.editor_events) === null || _elementorCommon$conf16 === void 0 ? void 0 : _elementorCommon$conf16.flags_enabled) !== null && _elementorCommon$conf15 !== void 0 ? _elementorCommon$conf15 : false;
2688 if (isAbTestingEnabled) {
2689 _context2.next = 3;
2690 break;
2691 }
2692 return _context2.abrupt("return", defaultValue);
2693 case 3:
2694 if (mixpanelInstance) {
2695 _context2.next = 4;
2696 break;
2697 }
2698 return _context2.abrupt("return", defaultValue);
2699 case 4:
2700 if (!this.trackingEnabled) {
2701 this.enableTracking();
2702 }
2703 if (mixpanelInstance.flags) {
2704 _context2.next = 5;
2705 break;
2706 }
2707 return _context2.abrupt("return", defaultValue);
2708 case 5:
2709 if (!('function' !== typeof mixpanelInstance.flags.get_variant_value)) {
2710 _context2.next = 6;
2711 break;
2712 }
2713 return _context2.abrupt("return", defaultValue);
2714 case 6:
2715 _context2.next = 7;
2716 return mixpanelInstance.flags.get_variant_value(experimentName, defaultValue);
2717 case 7:
2718 variant = _context2.sent;
2719 if (!(undefined === variant || null === variant)) {
2720 _context2.next = 8;
2721 break;
2722 }
2723 return _context2.abrupt("return", defaultValue);
2724 case 8:
2725 return _context2.abrupt("return", variant);
2726 case 9:
2727 _context2.prev = 9;
2728 _t = _context2["catch"](1);
2729 return _context2.abrupt("return", defaultValue);
2730 case 10:
2731 case "end":
2732 return _context2.stop();
2733 }
2734 }, _callee2, this, [[1, 9]]);
2735 }));
2736 function getExperimentVariant(_x2) {
2737 return _getExperimentVariant.apply(this, arguments);
2738 }
2739 return getExperimentVariant;
2740 }()
2741 }, {
2742 key: "startExperiment",
2743 value: function startExperiment(experimentName, experimentVariant) {
2744 if (!this.trackingEnabled) {
2745 return;
2746 }
2747 mixpanelInstance.track('$experiment_started', {
2748 'Experiment name': experimentName,
2749 'Variant name': experimentVariant
2750 });
2751 }
2752 }, {
2753 key: "isMixpanelReady",
2754 value: function isMixpanelReady() {
2755 if ('undefined' === typeof mixpanelInstance || !mixpanelInstance) {
2756 return false;
2757 }
2758 try {
2759 var distinctId = mixpanelInstance.get_distinct_id();
2760 return distinctId !== undefined && distinctId !== null;
2761 } catch (error) {
2762 return false;
2763 }
2764 }
2765 }, {
2766 key: "canSendEvents",
2767 value: function canSendEvents() {
2768 var _elementorCommon;
2769 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);
2770 }
2771 }, {
2772 key: "getMixpanelInstance",
2773 value: function getMixpanelInstance() {
2774 return this.isMixpanelReady() ? mixpanelInstance : undefined;
2775 }
2776 }]);
2777 }(elementorModules.Module);
2778
2779 /***/ }),
2780
2781 /***/ "../core/common/modules/finder/assets/js/commands/index.js":
2782 /*!*****************************************************************!*\
2783 !*** ../core/common/modules/finder/assets/js/commands/index.js ***!
2784 \*****************************************************************/
2785 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2786
2787 "use strict";
2788
2789
2790 Object.defineProperty(exports, "__esModule", ({
2791 value: true
2792 }));
2793 Object.defineProperty(exports, "NavigateDown", ({
2794 enumerable: true,
2795 get: function get() {
2796 return _navigateDown.NavigateDown;
2797 }
2798 }));
2799 Object.defineProperty(exports, "NavigateSelect", ({
2800 enumerable: true,
2801 get: function get() {
2802 return _navigateSelect.NavigateSelect;
2803 }
2804 }));
2805 Object.defineProperty(exports, "NavigateUp", ({
2806 enumerable: true,
2807 get: function get() {
2808 return _navigateUp.NavigateUp;
2809 }
2810 }));
2811 var _navigateDown = __webpack_require__(/*! ./navigate-down */ "../core/common/modules/finder/assets/js/commands/navigate-down.js");
2812 var _navigateSelect = __webpack_require__(/*! ./navigate-select */ "../core/common/modules/finder/assets/js/commands/navigate-select.js");
2813 var _navigateUp = __webpack_require__(/*! ./navigate-up */ "../core/common/modules/finder/assets/js/commands/navigate-up.js");
2814
2815 /***/ }),
2816
2817 /***/ "../core/common/modules/finder/assets/js/commands/navigate-down.js":
2818 /*!*************************************************************************!*\
2819 !*** ../core/common/modules/finder/assets/js/commands/navigate-down.js ***!
2820 \*************************************************************************/
2821 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2822
2823 "use strict";
2824
2825
2826 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2827 Object.defineProperty(exports, "__esModule", ({
2828 value: true
2829 }));
2830 exports["default"] = exports.NavigateDown = void 0;
2831 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2832 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2833 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2834 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2835 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2836 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2837 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)); }
2838 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2839 var NavigateDown = exports.NavigateDown = /*#__PURE__*/function (_CommandBase) {
2840 function NavigateDown() {
2841 (0, _classCallCheck2.default)(this, NavigateDown);
2842 return _callSuper(this, NavigateDown, arguments);
2843 }
2844 (0, _inherits2.default)(NavigateDown, _CommandBase);
2845 return (0, _createClass2.default)(NavigateDown, [{
2846 key: "apply",
2847 value: function apply() {
2848 this.component.getItemsView().activateNextItem();
2849 }
2850 }]);
2851 }(_commandBase.default);
2852 var _default = exports["default"] = NavigateDown;
2853
2854 /***/ }),
2855
2856 /***/ "../core/common/modules/finder/assets/js/commands/navigate-select.js":
2857 /*!***************************************************************************!*\
2858 !*** ../core/common/modules/finder/assets/js/commands/navigate-select.js ***!
2859 \***************************************************************************/
2860 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2861
2862 "use strict";
2863
2864
2865 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2866 Object.defineProperty(exports, "__esModule", ({
2867 value: true
2868 }));
2869 exports["default"] = exports.NavigateSelect = void 0;
2870 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2871 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2872 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2873 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2874 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2875 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2876 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)); }
2877 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2878 var NavigateSelect = exports.NavigateSelect = /*#__PURE__*/function (_CommandBase) {
2879 function NavigateSelect() {
2880 (0, _classCallCheck2.default)(this, NavigateSelect);
2881 return _callSuper(this, NavigateSelect, arguments);
2882 }
2883 (0, _inherits2.default)(NavigateSelect, _CommandBase);
2884 return (0, _createClass2.default)(NavigateSelect, [{
2885 key: "apply",
2886 value: function apply(args) {
2887 this.component.getItemsView().goToActiveItem(args);
2888 }
2889 }]);
2890 }(_commandBase.default);
2891 var _default = exports["default"] = NavigateSelect;
2892
2893 /***/ }),
2894
2895 /***/ "../core/common/modules/finder/assets/js/commands/navigate-up.js":
2896 /*!***********************************************************************!*\
2897 !*** ../core/common/modules/finder/assets/js/commands/navigate-up.js ***!
2898 \***********************************************************************/
2899 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2900
2901 "use strict";
2902
2903
2904 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2905 Object.defineProperty(exports, "__esModule", ({
2906 value: true
2907 }));
2908 exports["default"] = exports.NavigateUp = void 0;
2909 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2910 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2911 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2912 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2913 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2914 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2915 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)); }
2916 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2917 var NavigateUp = exports.NavigateUp = /*#__PURE__*/function (_CommandBase) {
2918 function NavigateUp() {
2919 (0, _classCallCheck2.default)(this, NavigateUp);
2920 return _callSuper(this, NavigateUp, arguments);
2921 }
2922 (0, _inherits2.default)(NavigateUp, _CommandBase);
2923 return (0, _createClass2.default)(NavigateUp, [{
2924 key: "apply",
2925 value: function apply() {
2926 this.component.getItemsView().activateNextItem(true);
2927 }
2928 }]);
2929 }(_commandBase.default);
2930 var _default = exports["default"] = NavigateUp;
2931
2932 /***/ }),
2933
2934 /***/ "../core/common/modules/finder/assets/js/component.js":
2935 /*!************************************************************!*\
2936 !*** ../core/common/modules/finder/assets/js/component.js ***!
2937 \************************************************************/
2938 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2939
2940 "use strict";
2941
2942
2943 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2944 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
2945 Object.defineProperty(exports, "__esModule", ({
2946 value: true
2947 }));
2948 exports["default"] = void 0;
2949 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
2950 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2951 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2952 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2953 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2954 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
2955 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2956 var _componentModalBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/component-modal-base */ "../modules/web-cli/assets/js/modules/component-modal-base.js"));
2957 var _layout = _interopRequireDefault(__webpack_require__(/*! ./modal/views/layout */ "../core/common/modules/finder/assets/js/modal/views/layout.js"));
2958 var commands = _interopRequireWildcard(__webpack_require__(/*! ./commands/ */ "../core/common/modules/finder/assets/js/commands/index.js"));
2959 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); }
2960 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; }
2961 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; }
2962 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)); }
2963 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2964 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; }
2965 var Component = exports["default"] = /*#__PURE__*/function (_ComponentModalBase) {
2966 function Component() {
2967 (0, _classCallCheck2.default)(this, Component);
2968 return _callSuper(this, Component, arguments);
2969 }
2970 (0, _inherits2.default)(Component, _ComponentModalBase);
2971 return (0, _createClass2.default)(Component, [{
2972 key: "getNamespace",
2973 value: function getNamespace() {
2974 return 'finder';
2975 }
2976 }, {
2977 key: "defaultShortcuts",
2978 value: function defaultShortcuts() {
2979 var _this = this;
2980 return {
2981 '': {
2982 keys: 'ctrl+e'
2983 },
2984 'navigate-down': {
2985 keys: 'down',
2986 scopes: [this.getNamespace()],
2987 dependency: function dependency() {
2988 return _this.getItemsView();
2989 }
2990 },
2991 'navigate-up': {
2992 keys: 'up',
2993 scopes: [this.getNamespace()],
2994 dependency: function dependency() {
2995 return _this.getItemsView();
2996 }
2997 },
2998 'navigate-select': {
2999 keys: 'enter',
3000 scopes: [this.getNamespace()],
3001 dependency: function dependency() {
3002 return _this.getItemsView().$activeItem;
3003 }
3004 }
3005 };
3006 }
3007 }, {
3008 key: "defaultCommands",
3009 value: function defaultCommands() {
3010 var modalCommands = _superPropGet(Component, "defaultCommands", this, 3)([]);
3011 return _objectSpread(_objectSpread({
3012 'navigate/down': function navigate_down() {
3013 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/down' )", '3.0.0', "$e.run( 'finder/navigate-down' )");
3014 $e.run('finder/navigate-down');
3015 },
3016 'navigate/up': function navigate_up() {
3017 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/up' )", '3.0.0', "$e.run( 'finder/navigate-up' )");
3018 $e.run('finder/navigate-up');
3019 },
3020 'navigate/select': function navigate_select(event) {
3021 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/select', event )", '3.0.0', "$e.run( 'finder/navigate-select', event )");
3022
3023 // TODO: Fix $e.shortcuts use args. ( args.event ).
3024 $e.run('finder/navigate-select', event);
3025 }
3026 }, modalCommands), this.importCommands(commands));
3027 }
3028 }, {
3029 key: "getModalLayout",
3030 value: function getModalLayout() {
3031 return _layout.default;
3032 }
3033 }, {
3034 key: "getItemsView",
3035 value: function getItemsView() {
3036 return this.layout.modalContent.currentView.content.currentView;
3037 }
3038 }]);
3039 }(_componentModalBase.default);
3040
3041 /***/ }),
3042
3043 /***/ "../core/common/modules/finder/assets/js/finder.js":
3044 /*!*********************************************************!*\
3045 !*** ../core/common/modules/finder/assets/js/finder.js ***!
3046 \*********************************************************/
3047 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3048
3049 "use strict";
3050
3051
3052 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3053 Object.defineProperty(exports, "__esModule", ({
3054 value: true
3055 }));
3056 exports["default"] = void 0;
3057 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3058 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3059 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3060 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3061 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3062 var _component = _interopRequireDefault(__webpack_require__(/*! ./component */ "../core/common/modules/finder/assets/js/component.js"));
3063 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)); }
3064 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3065 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
3066 function _default() {
3067 (0, _classCallCheck2.default)(this, _default);
3068 return _callSuper(this, _default, arguments);
3069 }
3070 (0, _inherits2.default)(_default, _elementorModules$Mod);
3071 return (0, _createClass2.default)(_default, [{
3072 key: "onInit",
3073 value: function onInit() {
3074 // TODO: Temp fix, do not load finder in theme-builder.
3075 // Better to pass into '$e' constructor the app owner. ( admin, editor, preview, iframe ).
3076 if (window.top !== window) {
3077 return;
3078 }
3079 this.channel = Backbone.Radio.channel('ELEMENTOR:finder');
3080 $e.components.register(new _component.default({
3081 manager: this
3082 }));
3083 }
3084 }]);
3085 }(elementorModules.Module);
3086
3087 /***/ }),
3088
3089 /***/ "../core/common/modules/finder/assets/js/modal/model/item.js":
3090 /*!*******************************************************************!*\
3091 !*** ../core/common/modules/finder/assets/js/modal/model/item.js ***!
3092 \*******************************************************************/
3093 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3094
3095 "use strict";
3096
3097
3098 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3099 Object.defineProperty(exports, "__esModule", ({
3100 value: true
3101 }));
3102 exports["default"] = void 0;
3103 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3104 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3105 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3106 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3107 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3108 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)); }
3109 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3110 var _default = exports["default"] = /*#__PURE__*/function (_Backbone$Model) {
3111 function _default() {
3112 (0, _classCallCheck2.default)(this, _default);
3113 return _callSuper(this, _default, arguments);
3114 }
3115 (0, _inherits2.default)(_default, _Backbone$Model);
3116 return (0, _createClass2.default)(_default, [{
3117 key: "defaults",
3118 value: function defaults() {
3119 return {
3120 description: '',
3121 icon: 'settings',
3122 url: '',
3123 keywords: [],
3124 actions: [],
3125 lock: null
3126 };
3127 }
3128 }]);
3129 }(Backbone.Model);
3130
3131 /***/ }),
3132
3133 /***/ "../core/common/modules/finder/assets/js/modal/views/categories.js":
3134 /*!*************************************************************************!*\
3135 !*** ../core/common/modules/finder/assets/js/modal/views/categories.js ***!
3136 \*************************************************************************/
3137 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3138
3139 "use strict";
3140
3141
3142 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3143 Object.defineProperty(exports, "__esModule", ({
3144 value: true
3145 }));
3146 exports["default"] = void 0;
3147 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3148 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3149 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3150 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3151 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3152 var _category = _interopRequireDefault(__webpack_require__(/*! ./category */ "../core/common/modules/finder/assets/js/modal/views/category.js"));
3153 var _dynamicCategory = _interopRequireDefault(__webpack_require__(/*! ./dynamic-category */ "../core/common/modules/finder/assets/js/modal/views/dynamic-category.js"));
3154 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)); }
3155 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3156 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$Composite) {
3157 function _default() {
3158 (0, _classCallCheck2.default)(this, _default);
3159 return _callSuper(this, _default, arguments);
3160 }
3161 (0, _inherits2.default)(_default, _Marionette$Composite);
3162 return (0, _createClass2.default)(_default, [{
3163 key: "id",
3164 value: function id() {
3165 return 'elementor-finder__results-container';
3166 }
3167 }, {
3168 key: "ui",
3169 value: function ui() {
3170 this.selectors = {
3171 noResults: '#elementor-finder__no-results',
3172 categoryItem: '.elementor-finder__results__item'
3173 };
3174 return this.selectors;
3175 }
3176 }, {
3177 key: "events",
3178 value: function events() {
3179 return {
3180 'mouseenter @ui.categoryItem': 'onCategoryItemMouseEnter'
3181 };
3182 }
3183 }, {
3184 key: "getTemplate",
3185 value: function getTemplate() {
3186 return '#tmpl-elementor-finder-results-container';
3187 }
3188 }, {
3189 key: "getChildView",
3190 value: function getChildView(childModel) {
3191 return childModel.get('dynamic') ? _dynamicCategory.default : _category.default;
3192 }
3193 }, {
3194 key: "initialize",
3195 value: function initialize() {
3196 this.$activeItem = null;
3197 this.childViewContainer = '#elementor-finder__results';
3198 this.collection = new Backbone.Collection(Object.values(elementorCommon.finder.getSettings('data')));
3199 }
3200 }, {
3201 key: "activateItem",
3202 value: function activateItem($item) {
3203 if (this.$activeItem) {
3204 this.$activeItem.removeClass('elementor-active');
3205 }
3206 $item.addClass('elementor-active');
3207 this.$activeItem = $item;
3208 }
3209 }, {
3210 key: "activateNextItem",
3211 value: function activateNextItem(reverse) {
3212 var $allItems = jQuery(this.selectors.categoryItem);
3213 var nextItemIndex = 0;
3214 if (this.$activeItem) {
3215 nextItemIndex = $allItems.index(this.$activeItem) + (reverse ? -1 : 1);
3216 if (nextItemIndex >= $allItems.length) {
3217 nextItemIndex = 0;
3218 } else if (nextItemIndex < 0) {
3219 nextItemIndex = $allItems.length - 1;
3220 }
3221 }
3222 var $nextItem = $allItems.eq(nextItemIndex);
3223 this.activateItem($nextItem);
3224 $nextItem[0].scrollIntoView({
3225 block: 'nearest'
3226 });
3227 }
3228 }, {
3229 key: "goToActiveItem",
3230 value: function goToActiveItem(event) {
3231 var $a = this.$activeItem.children('a'),
3232 isControlClicked = $e.shortcuts.isControlEvent(event);
3233 if (isControlClicked) {
3234 $a.attr('target', '_blank');
3235 }
3236 $a[0].click();
3237 if (isControlClicked) {
3238 $a.removeAttr('target');
3239 }
3240 }
3241 }, {
3242 key: "onCategoryItemMouseEnter",
3243 value: function onCategoryItemMouseEnter(event) {
3244 this.activateItem(jQuery(event.currentTarget));
3245 }
3246 }, {
3247 key: "onChildviewToggleVisibility",
3248 value: function onChildviewToggleVisibility() {
3249 var allCategoriesAreEmpty = this.children.every(function (child) {
3250 return !child.isVisible;
3251 });
3252 this.ui.noResults.toggle(allCategoriesAreEmpty);
3253 }
3254 }]);
3255 }(Marionette.CompositeView);
3256
3257 /***/ }),
3258
3259 /***/ "../core/common/modules/finder/assets/js/modal/views/category.js":
3260 /*!***********************************************************************!*\
3261 !*** ../core/common/modules/finder/assets/js/modal/views/category.js ***!
3262 \***********************************************************************/
3263 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3264
3265 "use strict";
3266
3267
3268 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3269 Object.defineProperty(exports, "__esModule", ({
3270 value: true
3271 }));
3272 exports["default"] = void 0;
3273 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3274 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3275 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3276 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3277 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3278 var _item = _interopRequireDefault(__webpack_require__(/*! ./item */ "../core/common/modules/finder/assets/js/modal/views/item.js"));
3279 var _item2 = _interopRequireDefault(__webpack_require__(/*! ../model/item */ "../core/common/modules/finder/assets/js/modal/model/item.js"));
3280 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)); }
3281 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3282 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$Composite) {
3283 function _default() {
3284 (0, _classCallCheck2.default)(this, _default);
3285 return _callSuper(this, _default, arguments);
3286 }
3287 (0, _inherits2.default)(_default, _Marionette$Composite);
3288 return (0, _createClass2.default)(_default, [{
3289 key: "className",
3290 value: function className() {
3291 return 'elementor-finder__results__category';
3292 }
3293 }, {
3294 key: "getTemplate",
3295 value: function getTemplate() {
3296 return '#tmpl-elementor-finder__results__category';
3297 }
3298 }, {
3299 key: "getChildView",
3300 value: function getChildView() {
3301 return _item.default;
3302 }
3303 }, {
3304 key: "initialize",
3305 value: function initialize() {
3306 this.childViewContainer = '.elementor-finder__results__category__items';
3307 this.isVisible = true;
3308 var items = this.model.get('items');
3309 if (items) {
3310 items = Object.values(items);
3311 }
3312 this.collection = new Backbone.Collection(items, {
3313 model: _item2.default
3314 });
3315 }
3316 }, {
3317 key: "filter",
3318 value: function filter(childModel) {
3319 var textFilter = this.getTextFilter();
3320 if (childModel.get('title').toLowerCase().indexOf(textFilter) >= 0) {
3321 return true;
3322 }
3323 return childModel.get('keywords').some(function (keyword) {
3324 return keyword.indexOf(textFilter) >= 0;
3325 });
3326 }
3327 }, {
3328 key: "getTextFilter",
3329 value: function getTextFilter() {
3330 return elementorCommon.finder.channel.request('filter:text').trim().toLowerCase();
3331 }
3332 }, {
3333 key: "toggleElement",
3334 value: function toggleElement() {
3335 var isCurrentlyVisible = !!this.children.length;
3336 if (isCurrentlyVisible !== this.isVisible) {
3337 this.isVisible = isCurrentlyVisible;
3338 this.$el.toggle(isCurrentlyVisible);
3339 this.triggerMethod('toggle:visibility');
3340 }
3341 }
3342 }, {
3343 key: "onRender",
3344 value: function onRender() {
3345 this.listenTo(elementorCommon.finder.channel, 'filter:change', this.onFilterChange.bind(this));
3346 }
3347 }, {
3348 key: "onFilterChange",
3349 value: function onFilterChange() {
3350 this._renderChildren();
3351 }
3352 }, {
3353 key: "onRenderCollection",
3354 value: function onRenderCollection() {
3355 this.toggleElement();
3356 }
3357 }]);
3358 }(Marionette.CompositeView);
3359
3360 /***/ }),
3361
3362 /***/ "../core/common/modules/finder/assets/js/modal/views/content.js":
3363 /*!**********************************************************************!*\
3364 !*** ../core/common/modules/finder/assets/js/modal/views/content.js ***!
3365 \**********************************************************************/
3366 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3367
3368 "use strict";
3369
3370
3371 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3372 Object.defineProperty(exports, "__esModule", ({
3373 value: true
3374 }));
3375 exports["default"] = void 0;
3376 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3377 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3378 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3379 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3380 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3381 var _categories = _interopRequireDefault(__webpack_require__(/*! ./categories */ "../core/common/modules/finder/assets/js/modal/views/categories.js"));
3382 var _editorOneEvents = __webpack_require__(/*! elementor-editor-utils/editor-one-events */ "../assets/dev/js/editor/utils/editor-one-events.js");
3383 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)); }
3384 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3385 var FINDER_SEARCH_DEBOUNCE_MS = 300;
3386 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$LayoutVie) {
3387 function _default() {
3388 (0, _classCallCheck2.default)(this, _default);
3389 return _callSuper(this, _default, arguments);
3390 }
3391 (0, _inherits2.default)(_default, _Marionette$LayoutVie);
3392 return (0, _createClass2.default)(_default, [{
3393 key: "id",
3394 value: function id() {
3395 return 'elementor-finder';
3396 }
3397 }, {
3398 key: "getTemplate",
3399 value: function getTemplate() {
3400 return '#tmpl-elementor-finder';
3401 }
3402 }, {
3403 key: "ui",
3404 value: function ui() {
3405 return {
3406 searchInput: '#elementor-finder__search__input'
3407 };
3408 }
3409 }, {
3410 key: "events",
3411 value: function events() {
3412 return {
3413 'input @ui.searchInput': 'onSearchInputInput'
3414 };
3415 }
3416 }, {
3417 key: "regions",
3418 value: function regions() {
3419 return {
3420 content: '#elementor-finder__content'
3421 };
3422 }
3423 }, {
3424 key: "initialize",
3425 value: function initialize() {
3426 this.debouncedTrackSearch = (0, _editorOneEvents.createDebouncedFinderSearch)(FINDER_SEARCH_DEBOUNCE_MS);
3427 }
3428 }, {
3429 key: "showCategoriesView",
3430 value: function showCategoriesView() {
3431 this.content.show(new _categories.default());
3432 }
3433 }, {
3434 key: "getResultsCount",
3435 value: function getResultsCount() {
3436 if (!this.content.currentView) {
3437 return 0;
3438 }
3439 var $visibleItems = this.content.currentView.$el.find('.elementor-finder__results__item:visible');
3440 return $visibleItems.length;
3441 }
3442 }, {
3443 key: "onSearchInputInput",
3444 value: function onSearchInputInput() {
3445 var _this = this;
3446 var value = this.ui.searchInput.val();
3447 if (value) {
3448 elementorCommon.finder.channel.reply('filter:text', value).trigger('filter:change');
3449 if (!(this.content.currentView instanceof _categories.default)) {
3450 this.showCategoriesView();
3451 }
3452 setTimeout(function () {
3453 var resultsCount = _this.getResultsCount();
3454 _this.debouncedTrackSearch(resultsCount, value);
3455 }, 50);
3456 }
3457 this.content.currentView.$el.toggle(!!value);
3458 }
3459 }, {
3460 key: "onDestroy",
3461 value: function onDestroy() {
3462 var _this$debouncedTrackS;
3463 if ((_this$debouncedTrackS = this.debouncedTrackSearch) !== null && _this$debouncedTrackS !== void 0 && _this$debouncedTrackS.cancel) {
3464 this.debouncedTrackSearch.cancel();
3465 }
3466 }
3467 }]);
3468 }(Marionette.LayoutView);
3469
3470 /***/ }),
3471
3472 /***/ "../core/common/modules/finder/assets/js/modal/views/dynamic-category.js":
3473 /*!*******************************************************************************!*\
3474 !*** ../core/common/modules/finder/assets/js/modal/views/dynamic-category.js ***!
3475 \*******************************************************************************/
3476 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3477
3478 "use strict";
3479
3480
3481 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3482 Object.defineProperty(exports, "__esModule", ({
3483 value: true
3484 }));
3485 exports["default"] = void 0;
3486 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3487 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3488 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3489 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3490 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
3491 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3492 var _category = _interopRequireDefault(__webpack_require__(/*! ./category */ "../core/common/modules/finder/assets/js/modal/views/category.js"));
3493 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)); }
3494 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3495 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; }
3496 var _default = exports["default"] = /*#__PURE__*/function (_Category) {
3497 function _default() {
3498 (0, _classCallCheck2.default)(this, _default);
3499 return _callSuper(this, _default, arguments);
3500 }
3501 (0, _inherits2.default)(_default, _Category);
3502 return (0, _createClass2.default)(_default, [{
3503 key: "className",
3504 value: function className() {
3505 return _superPropGet(_default, "className", this, 3)([]) + ' elementor-finder__results__category--dynamic';
3506 }
3507 }, {
3508 key: "ui",
3509 value: function ui() {
3510 return {
3511 title: '.elementor-finder__results__category__title'
3512 };
3513 }
3514 }, {
3515 key: "fetchData",
3516 value: function fetchData() {
3517 var _this = this;
3518 this.ui.loadingIcon.show();
3519 elementorCommon.ajax.addRequest('finder_get_category_items', {
3520 data: {
3521 category: this.model.get('name'),
3522 filter: this.getTextFilter()
3523 },
3524 success: function success(data) {
3525 if (_this.isDestroyed) {
3526 return;
3527 }
3528 _this.collection.set(data);
3529 _this.toggleElement();
3530 _this.ui.loadingIcon.hide();
3531 }
3532 });
3533 }
3534 }, {
3535 key: "filter",
3536 value: function filter() {
3537 return true;
3538 }
3539 }, {
3540 key: "onFilterChange",
3541 value: function onFilterChange() {
3542 this.fetchData();
3543 }
3544 }, {
3545 key: "onRender",
3546 value: function onRender() {
3547 _superPropGet(_default, "onRender", this, 3)([]);
3548 this.ui.loadingIcon = jQuery('<i>', {
3549 class: 'eicon-loading eicon-animation-spin'
3550 });
3551 this.ui.title.after(this.ui.loadingIcon);
3552 this.fetchData();
3553 }
3554 }]);
3555 }(_category.default);
3556
3557 /***/ }),
3558
3559 /***/ "../core/common/modules/finder/assets/js/modal/views/item.js":
3560 /*!*******************************************************************!*\
3561 !*** ../core/common/modules/finder/assets/js/modal/views/item.js ***!
3562 \*******************************************************************/
3563 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3564
3565 "use strict";
3566 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
3567
3568
3569 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3570 Object.defineProperty(exports, "__esModule", ({
3571 value: true
3572 }));
3573 exports["default"] = void 0;
3574 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3575 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3576 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3577 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3578 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3579 var _editorOneEvents = __webpack_require__(/*! elementor-editor-utils/editor-one-events */ "../assets/dev/js/editor/utils/editor-one-events.js");
3580 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)); }
3581 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3582 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$ItemView) {
3583 function _default() {
3584 (0, _classCallCheck2.default)(this, _default);
3585 return _callSuper(this, _default, arguments);
3586 }
3587 (0, _inherits2.default)(_default, _Marionette$ItemView);
3588 return (0, _createClass2.default)(_default, [{
3589 key: "className",
3590 value: function className() {
3591 return 'elementor-finder__results__item';
3592 }
3593 }, {
3594 key: "getTemplate",
3595 value: function getTemplate() {
3596 return '#tmpl-elementor-finder__results__item';
3597 }
3598 }, {
3599 key: "events",
3600 value: function events() {
3601 this.$el[0].addEventListener('click', this.onClick.bind(this), true);
3602 }
3603 }, {
3604 key: "trackResultSelect",
3605 value: function trackResultSelect() {
3606 var title = this.model.get('title');
3607 _editorOneEvents.EditorOneEventManager.sendFinderResultSelect(title);
3608 }
3609 }, {
3610 key: "onClick",
3611 value: function onClick(e) {
3612 var _this = this;
3613 var lockOptions = this.model.get('lock');
3614 if (!(lockOptions !== null && lockOptions !== void 0 && lockOptions.is_locked)) {
3615 this.trackResultSelect();
3616 return;
3617 }
3618 e.preventDefault();
3619 e.stopImmediatePropagation();
3620 elementorCommon.dialogsManager.createWidget('confirm', {
3621 id: 'elementor-finder__lock-dialog',
3622 headerMessage: lockOptions.content.heading,
3623 message: lockOptions.content.description,
3624 position: {
3625 my: 'center center',
3626 at: 'center center'
3627 },
3628 strings: {
3629 confirm: lockOptions.button.text,
3630 cancel: __('Cancel', 'elementor')
3631 },
3632 onConfirm: function onConfirm() {
3633 _this.trackResultSelect();
3634 var link = _this.replaceLockLinkPlaceholders(lockOptions.button.url);
3635 window.open(link, '_blank');
3636 }
3637 }).show();
3638 }
3639 }, {
3640 key: "replaceLockLinkPlaceholders",
3641 value: function replaceLockLinkPlaceholders(link) {
3642 return link.replace(/%%utm_source%%/g, 'finder').replace(/%%utm_medium%%/g, 'wp-dash');
3643 }
3644 }]);
3645 }(Marionette.ItemView);
3646
3647 /***/ }),
3648
3649 /***/ "../core/common/modules/finder/assets/js/modal/views/layout.js":
3650 /*!*********************************************************************!*\
3651 !*** ../core/common/modules/finder/assets/js/modal/views/layout.js ***!
3652 \*********************************************************************/
3653 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3654
3655 "use strict";
3656 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
3657
3658
3659 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3660 Object.defineProperty(exports, "__esModule", ({
3661 value: true
3662 }));
3663 exports["default"] = void 0;
3664 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3665 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3666 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3667 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3668 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
3669 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3670 var _content = _interopRequireDefault(__webpack_require__(/*! ./content */ "../core/common/modules/finder/assets/js/modal/views/content.js"));
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 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; }
3674 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$com) {
3675 function _default() {
3676 (0, _classCallCheck2.default)(this, _default);
3677 return _callSuper(this, _default, arguments);
3678 }
3679 (0, _inherits2.default)(_default, _elementorModules$com);
3680 return (0, _createClass2.default)(_default, [{
3681 key: "getModalOptions",
3682 value: function getModalOptions() {
3683 return {
3684 id: 'elementor-finder__modal',
3685 draggable: true,
3686 effects: {
3687 show: 'show',
3688 hide: 'hide'
3689 },
3690 position: {
3691 enable: false
3692 }
3693 };
3694 }
3695 }, {
3696 key: "getLogoOptions",
3697 value: function getLogoOptions() {
3698 return {
3699 title: __('Finder', 'elementor')
3700 };
3701 }
3702 }, {
3703 key: "initialize",
3704 value: function initialize() {
3705 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3706 args[_key] = arguments[_key];
3707 }
3708 _superPropGet(_default, "initialize", this, 3)(args);
3709 this.showLogo();
3710 this.showContentView();
3711 }
3712 }, {
3713 key: "showContentView",
3714 value: function showContentView() {
3715 this.modalContent.show(new _content.default());
3716 }
3717 }, {
3718 key: "showModal",
3719 value: function showModal() {
3720 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
3721 args[_key2] = arguments[_key2];
3722 }
3723 _superPropGet(_default, "showModal", this, 3)(args);
3724 this.modalContent.currentView.ui.searchInput.focus();
3725 }
3726 }]);
3727 }(elementorModules.common.views.modal.Layout);
3728
3729 /***/ }),
3730
3731 /***/ "../modules/web-cli/assets/js/core/data/errors/base-error.js":
3732 /*!*******************************************************************!*\
3733 !*** ../modules/web-cli/assets/js/core/data/errors/base-error.js ***!
3734 \*******************************************************************/
3735 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3736
3737 "use strict";
3738
3739
3740 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3741 Object.defineProperty(exports, "__esModule", ({
3742 value: true
3743 }));
3744 exports["default"] = void 0;
3745 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3746 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3747 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3748 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3749 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3750 var _wrapNativeSuper2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/wrapNativeSuper */ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js"));
3751 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
3752 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
3753 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../../../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
3754 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; }
3755 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; }
3756 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)); }
3757 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3758 var BaseError = exports["default"] = /*#__PURE__*/function (_Error) {
3759 /**
3760 * Error constructor.
3761 *
3762 * @param {string} message
3763 * @param {string} code
3764 * @param {*} data
3765 */
3766 function BaseError() {
3767 var _this;
3768 var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
3769 var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
3770 var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
3771 (0, _classCallCheck2.default)(this, BaseError);
3772 _this = _callSuper(this, BaseError, [message]);
3773 /**
3774 * The server error code.
3775 *
3776 * @type {string}
3777 */
3778 (0, _defineProperty2.default)(_this, "code", '');
3779 /**
3780 * Additional data about the current error.
3781 *
3782 * @type {*[]}
3783 */
3784 (0, _defineProperty2.default)(_this, "data", []);
3785 _this.code = code;
3786 _this.data = data;
3787 return _this;
3788 }
3789
3790 /**
3791 * Notify a message when the error occurs.
3792 */
3793 (0, _inherits2.default)(BaseError, _Error);
3794 return (0, _createClass2.default)(BaseError, [{
3795 key: "notify",
3796 value: function notify() {
3797 _console.default.error(_objectSpread({
3798 message: this.message
3799 }, this));
3800 }
3801 }], [{
3802 key: "create",
3803 value:
3804 /**
3805 * Static helper function to create the error.
3806 *
3807 * @param {string} message
3808 * @param {string} code
3809 * @param {*} data
3810 * @return {BaseError} error
3811 */
3812 function create(message) {
3813 var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
3814 var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
3815 return new this(message, code, data);
3816 }
3817
3818 /**
3819 * Returns the status code of the error.
3820 */
3821 }, {
3822 key: "getHTTPErrorCode",
3823 value: function getHTTPErrorCode() {
3824 (0, _forceMethodImplementation.default)();
3825 }
3826 }]);
3827 }(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
3828
3829 /***/ }),
3830
3831 /***/ "../modules/web-cli/assets/js/core/data/errors/default-error.js":
3832 /*!**********************************************************************!*\
3833 !*** ../modules/web-cli/assets/js/core/data/errors/default-error.js ***!
3834 \**********************************************************************/
3835 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3836
3837 "use strict";
3838
3839
3840 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3841 Object.defineProperty(exports, "__esModule", ({
3842 value: true
3843 }));
3844 exports["default"] = exports.DefaultError = void 0;
3845 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3846 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3847 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3848 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3849 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3850 var _baseError = _interopRequireDefault(__webpack_require__(/*! ./base-error */ "../modules/web-cli/assets/js/core/data/errors/base-error.js"));
3851 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)); }
3852 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3853 var DefaultError = exports.DefaultError = /*#__PURE__*/function (_BaseError) {
3854 function DefaultError() {
3855 (0, _classCallCheck2.default)(this, DefaultError);
3856 return _callSuper(this, DefaultError, arguments);
3857 }
3858 (0, _inherits2.default)(DefaultError, _BaseError);
3859 return (0, _createClass2.default)(DefaultError, null, [{
3860 key: "getHTTPErrorCode",
3861 value: function getHTTPErrorCode() {
3862 return 501;
3863 }
3864 }]);
3865 }(_baseError.default);
3866 var _default = exports["default"] = DefaultError;
3867
3868 /***/ }),
3869
3870 /***/ "../modules/web-cli/assets/js/core/data/errors/error-404.js":
3871 /*!******************************************************************!*\
3872 !*** ../modules/web-cli/assets/js/core/data/errors/error-404.js ***!
3873 \******************************************************************/
3874 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3875
3876 "use strict";
3877
3878
3879 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3880 Object.defineProperty(exports, "__esModule", ({
3881 value: true
3882 }));
3883 exports["default"] = exports.Error404 = void 0;
3884 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3885 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3886 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3887 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3888 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3889 var _baseError = _interopRequireDefault(__webpack_require__(/*! ./base-error */ "../modules/web-cli/assets/js/core/data/errors/base-error.js"));
3890 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
3891 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)); }
3892 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3893 var Error404 = exports.Error404 = /*#__PURE__*/function (_BaseError) {
3894 function Error404() {
3895 (0, _classCallCheck2.default)(this, Error404);
3896 return _callSuper(this, Error404, arguments);
3897 }
3898 (0, _inherits2.default)(Error404, _BaseError);
3899 return (0, _createClass2.default)(Error404, [{
3900 key: "notify",
3901 value: function notify() {
3902 _console.default.warn(this.message);
3903 }
3904 }], [{
3905 key: "getHTTPErrorCode",
3906 value: function getHTTPErrorCode() {
3907 return 404;
3908 }
3909 }]);
3910 }(_baseError.default);
3911 var _default = exports["default"] = Error404;
3912
3913 /***/ }),
3914
3915 /***/ "../modules/web-cli/assets/js/core/data/errors/index.js":
3916 /*!**************************************************************!*\
3917 !*** ../modules/web-cli/assets/js/core/data/errors/index.js ***!
3918 \**************************************************************/
3919 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3920
3921 "use strict";
3922
3923
3924 Object.defineProperty(exports, "__esModule", ({
3925 value: true
3926 }));
3927 Object.defineProperty(exports, "DefaultError", ({
3928 enumerable: true,
3929 get: function get() {
3930 return _defaultError.DefaultError;
3931 }
3932 }));
3933 Object.defineProperty(exports, "Error404", ({
3934 enumerable: true,
3935 get: function get() {
3936 return _error.Error404;
3937 }
3938 }));
3939 var _defaultError = __webpack_require__(/*! ./default-error */ "../modules/web-cli/assets/js/core/data/errors/default-error.js");
3940 var _error = __webpack_require__(/*! ./error-404 */ "../modules/web-cli/assets/js/core/data/errors/error-404.js");
3941
3942 /***/ }),
3943
3944 /***/ "../modules/web-cli/assets/js/modules/command-base.js":
3945 /*!************************************************************!*\
3946 !*** ../modules/web-cli/assets/js/modules/command-base.js ***!
3947 \************************************************************/
3948 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3949
3950 "use strict";
3951
3952
3953 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3954 Object.defineProperty(exports, "__esModule", ({
3955 value: true
3956 }));
3957 exports["default"] = void 0;
3958 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3959 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3960 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3961 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3962 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3963 var _commandInfra = _interopRequireDefault(__webpack_require__(/*! ./command-infra */ "../modules/web-cli/assets/js/modules/command-infra.js"));
3964 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
3965 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)); }
3966 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3967 /**
3968 * @name $e.modules.CommandBase
3969 */
3970 var CommandBase = exports["default"] = /*#__PURE__*/function (_CommandInfra) {
3971 function CommandBase() {
3972 (0, _classCallCheck2.default)(this, CommandBase);
3973 return _callSuper(this, CommandBase, arguments);
3974 }
3975 (0, _inherits2.default)(CommandBase, _CommandInfra);
3976 return (0, _createClass2.default)(CommandBase, [{
3977 key: "onBeforeRun",
3978 value: function onBeforeRun() {
3979 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3980 $e.hooks.runUIBefore(this.command, args);
3981 }
3982 }, {
3983 key: "onAfterRun",
3984 value: function onAfterRun() {
3985 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3986 var result = arguments.length > 1 ? arguments[1] : undefined;
3987 $e.hooks.runUIAfter(this.command, args, result);
3988 }
3989 }, {
3990 key: "onBeforeApply",
3991 value: function onBeforeApply() {
3992 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3993 $e.hooks.runDataDependency(this.command, args);
3994 }
3995 }, {
3996 key: "onAfterApply",
3997 value: function onAfterApply() {
3998 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3999 var result = arguments.length > 1 ? arguments[1] : undefined;
4000 return $e.hooks.runDataAfter(this.command, args, result);
4001 }
4002 }, {
4003 key: "onCatchApply",
4004 value: function onCatchApply(e) {
4005 this.runCatchHooks(e);
4006 }
4007
4008 /**
4009 * Run all the catch hooks.
4010 *
4011 * @param {Error} e
4012 */
4013 }, {
4014 key: "runCatchHooks",
4015 value: function runCatchHooks(e) {
4016 $e.hooks.runDataCatch(this.command, this.args, e);
4017 $e.hooks.runUICatch(this.command, this.args, e);
4018 }
4019
4020 /**
4021 * TODO - Remove - Backwards compatibility.
4022 *
4023 * Function requireContainer().
4024 *
4025 * Validate `arg.container` & `arg.containers`.
4026 *
4027 * @param {{}} args
4028 * @deprecated since 3.7.0, extend `$e.modules.editor.CommandContainerBase` or `$e.modules.editor.CommandContainerInternalBase` instead.
4029 *
4030 * @throws {Error}
4031 */
4032 }, {
4033 key: "requireContainer",
4034 value: function requireContainer() {
4035 var _this = this;
4036 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.args;
4037 _deprecation.default.deprecated('requireContainer()', '3.7.0', 'Extend `$e.modules.editor.CommandContainerBase` or `$e.modules.editor.CommandContainerInternalBase`');
4038 if (!args.container && !args.containers) {
4039 throw Error('container or containers are required.');
4040 }
4041 if (args.container && args.containers) {
4042 throw Error('container and containers cannot go together please select one of them.');
4043 }
4044 var containers = args.containers || [args.container];
4045 containers.forEach(function (container) {
4046 _this.requireArgumentInstance('container', elementorModules.editor.Container, {
4047 container: container
4048 });
4049 });
4050 }
4051 }], [{
4052 key: "getInstanceType",
4053 value: function getInstanceType() {
4054 return 'CommandBase';
4055 }
4056 }]);
4057 }(_commandInfra.default);
4058
4059 /***/ }),
4060
4061 /***/ "../modules/web-cli/assets/js/modules/command-callback-base.js":
4062 /*!*********************************************************************!*\
4063 !*** ../modules/web-cli/assets/js/modules/command-callback-base.js ***!
4064 \*********************************************************************/
4065 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4066
4067 "use strict";
4068
4069
4070 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4071 Object.defineProperty(exports, "__esModule", ({
4072 value: true
4073 }));
4074 exports["default"] = void 0;
4075 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4076 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4077 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4078 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4079 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4080 var _commandBase = _interopRequireDefault(__webpack_require__(/*! ./command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4081 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)); }
4082 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4083 /**
4084 * To support pure callbacks in the API(commands.js), to ensure they have registered with the proper context.
4085 */
4086 var CommandCallbackBase = exports["default"] = /*#__PURE__*/function (_CommandBase) {
4087 function CommandCallbackBase() {
4088 (0, _classCallCheck2.default)(this, CommandCallbackBase);
4089 return _callSuper(this, CommandCallbackBase, arguments);
4090 }
4091 (0, _inherits2.default)(CommandCallbackBase, _CommandBase);
4092 return (0, _createClass2.default)(CommandCallbackBase, [{
4093 key: "apply",
4094 value: function apply() {
4095 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4096 return this.constructor.getCallback()(args);
4097 }
4098 }], [{
4099 key: "getInstanceType",
4100 value: function getInstanceType() {
4101 return 'CommandCallbackBase';
4102 }
4103
4104 /**
4105 * Get original callback of the command.
4106 *
4107 * Support pure callbacks ( Non command-base ).
4108 *
4109 * @return {()=>{}} Command Results.
4110 */
4111 }, {
4112 key: "getCallback",
4113 value: function getCallback() {
4114 return this.registerConfig.callback;
4115 }
4116 }]);
4117 }(_commandBase.default);
4118
4119 /***/ }),
4120
4121 /***/ "../modules/web-cli/assets/js/modules/command-data.js":
4122 /*!************************************************************!*\
4123 !*** ../modules/web-cli/assets/js/modules/command-data.js ***!
4124 \************************************************************/
4125 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4126
4127 "use strict";
4128
4129
4130 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4131 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
4132 Object.defineProperty(exports, "__esModule", ({
4133 value: true
4134 }));
4135 exports["default"] = void 0;
4136 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4137 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4138 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4139 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4140 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4141 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
4142 var _commandBase = _interopRequireDefault(__webpack_require__(/*! ./command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4143 var errors = _interopRequireWildcard(__webpack_require__(/*! ../core/data/errors/ */ "../modules/web-cli/assets/js/core/data/errors/index.js"));
4144 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); }
4145 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)); }
4146 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4147 /**
4148 * @name $e.modules.CommandData
4149 */
4150 /**
4151 * @typedef {('create'|'delete'|'get'|'update'|'options')} DataTypes
4152 */
4153 /**
4154 * @typedef {{}} RequestData
4155 */
4156 /**
4157 * @typedef {import('../core/data/errors/base-error')} BaseError
4158 */
4159 var CommandData = exports["default"] = /*#__PURE__*/function (_CommandBase) {
4160 function CommandData(args) {
4161 var _this$args$options;
4162 var _this;
4163 var commandsAPI = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : $e.data;
4164 (0, _classCallCheck2.default)(this, CommandData);
4165 _this = _callSuper(this, CommandData, [args, commandsAPI]);
4166 /**
4167 * Data returned from remote.
4168 *
4169 * @type {*}
4170 */
4171 (0, _defineProperty2.default)(_this, "data", void 0);
4172 /**
4173 * Fetch type.
4174 *
4175 * @type {DataTypes}
4176 */
4177 (0, _defineProperty2.default)(_this, "type", void 0);
4178 if ((_this$args$options = _this.args.options) !== null && _this$args$options !== void 0 && _this$args$options.type) {
4179 _this.type = _this.args.options.type;
4180 }
4181 return _this;
4182 }
4183
4184 /**
4185 * Function getEndpointFormat().
4186 *
4187 * @return {null|string} endpoint format
4188 */
4189 (0, _inherits2.default)(CommandData, _CommandBase);
4190 return (0, _createClass2.default)(CommandData, [{
4191 key: "getApplyMethods",
4192 value:
4193 /**
4194 * @param {DataTypes} type
4195 *
4196 * @return {boolean|{before: (function(*=): {}), after: (function({}, *=): {})}} apply methods
4197 */
4198 function getApplyMethods() {
4199 var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.type;
4200 var before, after;
4201 switch (type) {
4202 case 'create':
4203 before = this.applyBeforeCreate;
4204 after = this.applyAfterCreate;
4205 break;
4206 case 'delete':
4207 before = this.applyBeforeDelete;
4208 after = this.applyAfterDelete;
4209 break;
4210 case 'get':
4211 before = this.applyBeforeGet;
4212 after = this.applyAfterGet;
4213 break;
4214 case 'update':
4215 before = this.applyBeforeUpdate;
4216 after = this.applyAfterUpdate;
4217 break;
4218 case 'options':
4219 before = this.applyBeforeOptions;
4220 after = this.applyAfterOptions;
4221 break;
4222 default:
4223 return false;
4224 }
4225 return {
4226 before: before.bind(this),
4227 after: after.bind(this)
4228 };
4229 }
4230
4231 /**
4232 * Function getRequestData().
4233 *
4234 * @return {RequestData} request data
4235 */
4236 }, {
4237 key: "getRequestData",
4238 value: function getRequestData() {
4239 return {
4240 type: this.type,
4241 args: this.args,
4242 timestamp: new Date().getTime(),
4243 component: this.component,
4244 command: this.command,
4245 endpoint: $e.data.commandToEndpoint(this.command, JSON.parse(JSON.stringify(this.args)), this.constructor.getEndpointFormat())
4246 };
4247 }
4248 }, {
4249 key: "apply",
4250 value: function apply() {
4251 var _this2 = this;
4252 var applyMethods = this.getApplyMethods();
4253
4254 // Run 'before' method.
4255 this.args = applyMethods.before(this.args);
4256 var requestData = this.getRequestData();
4257 return $e.data.fetch(requestData).then(function (data) {
4258 _this2.data = data;
4259
4260 // Run 'after' method.
4261 _this2.data = applyMethods.after(data, _this2.args);
4262 _this2.data = {
4263 data: _this2.data
4264 };
4265
4266 // Append requestData.
4267 _this2.data = Object.assign({
4268 __requestData__: requestData
4269 }, _this2.data);
4270 return _this2.data;
4271 });
4272 }
4273
4274 /**
4275 * @param {*} [args={}]
4276 * @return {{}} filtered args
4277 */
4278 }, {
4279 key: "applyBeforeCreate",
4280 value: function applyBeforeCreate() {
4281 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4282 return args;
4283 }
4284
4285 /**
4286 * @param {{}} data
4287 * @param {*} [args={}]
4288 * @return {{}} filtered result
4289 */
4290 }, {
4291 key: "applyAfterCreate",
4292 value: function applyAfterCreate(data) {
4293 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4294 // eslint-disable-line no-unused-vars
4295 return data;
4296 }
4297
4298 /**
4299 * @param {*} [args={}]
4300 * @return {{}} filtered args
4301 */
4302 }, {
4303 key: "applyBeforeDelete",
4304 value: function applyBeforeDelete() {
4305 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4306 return args;
4307 }
4308
4309 /**
4310 * @param {{}} data
4311 * @param {*} [args={}]
4312 * @return {{}} filtered result
4313 */
4314 }, {
4315 key: "applyAfterDelete",
4316 value: function applyAfterDelete(data) {
4317 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4318 // eslint-disable-line no-unused-vars
4319 return data;
4320 }
4321
4322 /**
4323 * @param {*} [args={}]
4324 * @return {{}} filtered args
4325 */
4326 }, {
4327 key: "applyBeforeGet",
4328 value: function applyBeforeGet() {
4329 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4330 return args;
4331 }
4332
4333 /**
4334 * @param {{}} data
4335 * @param {*} [args={}]
4336 * @return {{}} filtered result
4337 */
4338 }, {
4339 key: "applyAfterGet",
4340 value: function applyAfterGet(data) {
4341 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4342 // eslint-disable-line no-unused-vars
4343 return data;
4344 }
4345
4346 /**
4347 * @param {*} [args={}]
4348 * @return {{}} filtered args
4349 */
4350 }, {
4351 key: "applyBeforeUpdate",
4352 value: function applyBeforeUpdate() {
4353 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4354 return args;
4355 }
4356
4357 /**
4358 * @param {{}} data
4359 * @param {*} [args={}]
4360 * @return {{}} filtered result
4361 */
4362 }, {
4363 key: "applyAfterUpdate",
4364 value: function applyAfterUpdate(data) {
4365 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4366 // eslint-disable-line no-unused-vars
4367 return data;
4368 }
4369
4370 /**
4371 * @param {*} [args={}]
4372 * @return {{}} filtered args
4373 */
4374 }, {
4375 key: "applyBeforeOptions",
4376 value: function applyBeforeOptions() {
4377 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4378 return args;
4379 }
4380
4381 /**
4382 * @param {{}} data
4383 * @param {*} [args={}]
4384 * @return {{}} filtered result
4385 */
4386 }, {
4387 key: "applyAfterOptions",
4388 value: function applyAfterOptions(data) {
4389 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4390 // eslint-disable-line no-unused-vars
4391 return data;
4392 }
4393
4394 /**
4395 * @param {BaseError} e
4396 */
4397 }, {
4398 key: "applyAfterCatch",
4399 value: function applyAfterCatch(e) {
4400 e.notify();
4401 }
4402 }, {
4403 key: "onCatchApply",
4404 value: function onCatchApply(e) {
4405 var _e;
4406 // TODO: If the errors that returns from the server is consistent remove the '?' from 'e'
4407 var httpErrorCode = ((_e = e) === null || _e === void 0 || (_e = _e.data) === null || _e === void 0 ? void 0 : _e.status) || 501;
4408 var dataError = Object.values(errors).find(function (error) {
4409 return error.getHTTPErrorCode() === httpErrorCode;
4410 });
4411 if (!dataError) {
4412 dataError = errors.DefaultError;
4413 }
4414 e = dataError.create(e.message, e.code, e.data || []);
4415 this.runCatchHooks(e);
4416 this.applyAfterCatch(e);
4417 }
4418 }], [{
4419 key: "getInstanceType",
4420 value: function getInstanceType() {
4421 return 'CommandData';
4422 }
4423 }, {
4424 key: "getEndpointFormat",
4425 value: function getEndpointFormat() {
4426 return null;
4427 }
4428 }]);
4429 }(_commandBase.default);
4430
4431 /***/ }),
4432
4433 /***/ "../modules/web-cli/assets/js/modules/command-infra.js":
4434 /*!*************************************************************!*\
4435 !*** ../modules/web-cli/assets/js/modules/command-infra.js ***!
4436 \*************************************************************/
4437 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4438
4439 "use strict";
4440
4441
4442 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4443 Object.defineProperty(exports, "__esModule", ({
4444 value: true
4445 }));
4446 exports["default"] = void 0;
4447 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4448 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4449 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4450 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4451 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4452 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
4453 var _argsObject = _interopRequireDefault(__webpack_require__(/*! elementor-assets-js/modules/imports/args-object */ "../assets/dev/js/modules/imports/args-object.js"));
4454 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
4455 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)); }
4456 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4457 /**
4458 * @typedef {import('../modules/component-base')} ComponentBase
4459 */
4460 var CommandInfra = exports["default"] = /*#__PURE__*/function (_ArgsObject) {
4461 /**
4462 * Function constructor().
4463 *
4464 * Create Commands Base.
4465 *
4466 * @param {{}} args
4467 */
4468 function CommandInfra() {
4469 var _this;
4470 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4471 (0, _classCallCheck2.default)(this, CommandInfra);
4472 _this = _callSuper(this, CommandInfra, [args]);
4473 if (!_this.constructor.registerConfig) {
4474 throw RangeError('Doing it wrong: Each command type should have `registerConfig`.');
4475 }
4476
4477 // Acknowledge self about which command it run.
4478 _this.command = _this.constructor.getCommand();
4479
4480 // Assign instance of current component.
4481 _this.component = _this.constructor.getComponent();
4482
4483 // Who ever need do something before without `super` the constructor can use `initialize` method.
4484 _this.initialize(args);
4485
4486 // Refresh args, maybe the changed via `initialize`.
4487 args = _this.args;
4488
4489 // Validate args before run.
4490 _this.validateArgs(args);
4491 return _this;
4492 }
4493
4494 /**
4495 * Function initialize().
4496 *
4497 * Initialize command, called after construction.
4498 *
4499 * @param {{}} args
4500 */
4501 (0, _inherits2.default)(CommandInfra, _ArgsObject);
4502 return (0, _createClass2.default)(CommandInfra, [{
4503 key: "currentCommand",
4504 get:
4505 /**
4506 * @deprecated since 3.7.0, use `this.command` instead.
4507 */
4508 function get() {
4509 _deprecation.default.deprecated('this.currentCommand', '3.7.0', 'this.command');
4510 return this.command;
4511 }
4512 }, {
4513 key: "initialize",
4514 value: function initialize() {
4515 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4516 } // eslint-disable-line no-unused-vars
4517
4518 /**
4519 * Function validateArgs().
4520 *
4521 * Validate command arguments.
4522 *
4523 * @param {{}} args
4524 */
4525 }, {
4526 key: "validateArgs",
4527 value: function validateArgs() {
4528 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4529 } // eslint-disable-line no-unused-vars
4530
4531 // eslint-disable-next-line jsdoc/require-returns-check
4532 /**
4533 * Function apply().
4534 *
4535 * Do the actual command.
4536 *
4537 * @param {{}} args
4538 *
4539 * @return {*} Command results.
4540 */
4541 }, {
4542 key: "apply",
4543 value: function apply() {
4544 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4545 // eslint-disable-line no-unused-vars
4546 elementorModules.ForceMethodImplementation();
4547 }
4548
4549 /**
4550 * Function run().
4551 *
4552 * Run command with history & hooks.
4553 *
4554 * @return {*} Command results.
4555 */
4556 }, {
4557 key: "run",
4558 value: function run() {
4559 return this.apply(this.args);
4560 }
4561
4562 /**
4563 * Function onBeforeRun.
4564 *
4565 * Called before run().
4566 *
4567 * @param {{}} args
4568 */
4569 }, {
4570 key: "onBeforeRun",
4571 value: function onBeforeRun() {
4572 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4573 } // eslint-disable-line no-unused-vars
4574
4575 /**
4576 * Function onAfterRun.
4577 *
4578 * Called after run().
4579 *
4580 * @param {{}} args
4581 * @param {*} result
4582 */
4583 }, {
4584 key: "onAfterRun",
4585 value: function onAfterRun() {
4586 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4587 var result = arguments.length > 1 ? arguments[1] : undefined;
4588 } // eslint-disable-line no-unused-vars
4589
4590 /**
4591 * Function onBeforeApply.
4592 *
4593 * Called before apply().
4594 *
4595 * @param {{}} args
4596 */
4597 }, {
4598 key: "onBeforeApply",
4599 value: function onBeforeApply() {
4600 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4601 } // eslint-disable-line no-unused-vars
4602
4603 /**
4604 * Function onAfterApply.
4605 *
4606 * Called after apply().
4607 *
4608 * @param {{}} args
4609 * @param {*} result
4610 */
4611 }, {
4612 key: "onAfterApply",
4613 value: function onAfterApply() {
4614 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4615 var result = arguments.length > 1 ? arguments[1] : undefined;
4616 } // eslint-disable-line no-unused-vars
4617
4618 /**
4619 * Function onCatchApply.
4620 *
4621 * Called after apply() failed.
4622 *
4623 * @param {Error} e
4624 */
4625 }, {
4626 key: "onCatchApply",
4627 value: function onCatchApply(e) {} // eslint-disable-line no-unused-vars
4628 }], [{
4629 key: "getInstanceType",
4630 value: function getInstanceType() {
4631 return 'CommandInfra';
4632 }
4633
4634 /**
4635 * Get info of command.
4636 *
4637 * @return {Object} Extra information about the command.
4638 */
4639 }, {
4640 key: "getInfo",
4641 value: function getInfo() {
4642 return {};
4643 }
4644
4645 /**
4646 * @return {string} Self command name.
4647 */
4648 }, {
4649 key: "getCommand",
4650 value: function getCommand() {
4651 return this.registerConfig.command;
4652 }
4653
4654 /**
4655 * @return {ComponentBase} Self component
4656 */
4657 }, {
4658 key: "getComponent",
4659 value: function getComponent() {
4660 return this.registerConfig.component;
4661 }
4662 }, {
4663 key: "setRegisterConfig",
4664 value: function setRegisterConfig(config) {
4665 this.registerConfig = Object.freeze(config);
4666 }
4667 }]);
4668 }(_argsObject.default);
4669 /**
4670 * @type {Object}
4671 */
4672 (0, _defineProperty2.default)(CommandInfra, "registerConfig", null);
4673
4674 /***/ }),
4675
4676 /***/ "../modules/web-cli/assets/js/modules/commands/close.js":
4677 /*!**************************************************************!*\
4678 !*** ../modules/web-cli/assets/js/modules/commands/close.js ***!
4679 \**************************************************************/
4680 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4681
4682 "use strict";
4683
4684
4685 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4686 Object.defineProperty(exports, "__esModule", ({
4687 value: true
4688 }));
4689 exports["default"] = exports.Close = void 0;
4690 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4691 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4692 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4693 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4694 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4695 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4696 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)); }
4697 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4698 var Close = exports.Close = /*#__PURE__*/function (_CommandBase) {
4699 function Close() {
4700 (0, _classCallCheck2.default)(this, Close);
4701 return _callSuper(this, Close, arguments);
4702 }
4703 (0, _inherits2.default)(Close, _CommandBase);
4704 return (0, _createClass2.default)(Close, [{
4705 key: "apply",
4706 value: function apply() {
4707 this.component.close();
4708 }
4709 }]);
4710 }(_commandBase.default);
4711 var _default = exports["default"] = Close;
4712
4713 /***/ }),
4714
4715 /***/ "../modules/web-cli/assets/js/modules/commands/index.js":
4716 /*!**************************************************************!*\
4717 !*** ../modules/web-cli/assets/js/modules/commands/index.js ***!
4718 \**************************************************************/
4719 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4720
4721 "use strict";
4722
4723
4724 Object.defineProperty(exports, "__esModule", ({
4725 value: true
4726 }));
4727 Object.defineProperty(exports, "Close", ({
4728 enumerable: true,
4729 get: function get() {
4730 return _close.Close;
4731 }
4732 }));
4733 Object.defineProperty(exports, "Open", ({
4734 enumerable: true,
4735 get: function get() {
4736 return _open.Open;
4737 }
4738 }));
4739 Object.defineProperty(exports, "Toggle", ({
4740 enumerable: true,
4741 get: function get() {
4742 return _toggle.Toggle;
4743 }
4744 }));
4745 var _close = __webpack_require__(/*! ./close */ "../modules/web-cli/assets/js/modules/commands/close.js");
4746 var _open = __webpack_require__(/*! ./open */ "../modules/web-cli/assets/js/modules/commands/open.js");
4747 var _toggle = __webpack_require__(/*! ./toggle */ "../modules/web-cli/assets/js/modules/commands/toggle.js");
4748
4749 /***/ }),
4750
4751 /***/ "../modules/web-cli/assets/js/modules/commands/open.js":
4752 /*!*************************************************************!*\
4753 !*** ../modules/web-cli/assets/js/modules/commands/open.js ***!
4754 \*************************************************************/
4755 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4756
4757 "use strict";
4758
4759
4760 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4761 Object.defineProperty(exports, "__esModule", ({
4762 value: true
4763 }));
4764 exports["default"] = exports.Open = void 0;
4765 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4766 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4767 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4768 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4769 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4770 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4771 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)); }
4772 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4773 var Open = exports.Open = /*#__PURE__*/function (_CommandBase) {
4774 function Open() {
4775 (0, _classCallCheck2.default)(this, Open);
4776 return _callSuper(this, Open, arguments);
4777 }
4778 (0, _inherits2.default)(Open, _CommandBase);
4779 return (0, _createClass2.default)(Open, [{
4780 key: "apply",
4781 value: function apply() {
4782 $e.route(this.component.getNamespace());
4783 }
4784 }]);
4785 }(_commandBase.default);
4786 var _default = exports["default"] = Open;
4787
4788 /***/ }),
4789
4790 /***/ "../modules/web-cli/assets/js/modules/commands/toggle.js":
4791 /*!***************************************************************!*\
4792 !*** ../modules/web-cli/assets/js/modules/commands/toggle.js ***!
4793 \***************************************************************/
4794 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4795
4796 "use strict";
4797
4798
4799 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4800 Object.defineProperty(exports, "__esModule", ({
4801 value: true
4802 }));
4803 exports["default"] = exports.Toggle = void 0;
4804 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4805 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4806 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4807 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4808 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4809 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4810 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)); }
4811 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4812 var Toggle = exports.Toggle = /*#__PURE__*/function (_CommandBase) {
4813 function Toggle() {
4814 (0, _classCallCheck2.default)(this, Toggle);
4815 return _callSuper(this, Toggle, arguments);
4816 }
4817 (0, _inherits2.default)(Toggle, _CommandBase);
4818 return (0, _createClass2.default)(Toggle, [{
4819 key: "apply",
4820 value: function apply() {
4821 if (this.component.isOpen) {
4822 this.component.close();
4823 } else {
4824 $e.route(this.component.getNamespace());
4825 }
4826 }
4827 }]);
4828 }(_commandBase.default);
4829 var _default = exports["default"] = Toggle;
4830
4831 /***/ }),
4832
4833 /***/ "../modules/web-cli/assets/js/modules/component-base.js":
4834 /*!**************************************************************!*\
4835 !*** ../modules/web-cli/assets/js/modules/component-base.js ***!
4836 \**************************************************************/
4837 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4838
4839 "use strict";
4840
4841
4842 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4843 Object.defineProperty(exports, "__esModule", ({
4844 value: true
4845 }));
4846 exports["default"] = void 0;
4847 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
4848 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
4849 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4850 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4851 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4852 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4853 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4854 var _commandCallbackBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-callback-base */ "../modules/web-cli/assets/js/modules/command-callback-base.js"));
4855 var _toolkit = __webpack_require__(/*! @reduxjs/toolkit */ "../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js");
4856 var _module = _interopRequireDefault(__webpack_require__(/*! elementor/assets/dev/js/modules/imports/module.js */ "../assets/dev/js/modules/imports/module.js"));
4857 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
4858 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
4859 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; }
4860 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; }
4861 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)); }
4862 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4863 /**
4864 * @typedef {import('./command-infra')} CommandInfra
4865 * @typedef {import('./hook-base')} HookBase
4866 * @typedef {import('../core/states/ui-state-base')} UiStateBase
4867 */
4868 var ComponentBase = exports["default"] = /*#__PURE__*/function (_Module) {
4869 function ComponentBase() {
4870 (0, _classCallCheck2.default)(this, ComponentBase);
4871 return _callSuper(this, ComponentBase, arguments);
4872 }
4873 (0, _inherits2.default)(ComponentBase, _Module);
4874 return (0, _createClass2.default)(ComponentBase, [{
4875 key: "__construct",
4876 value: function __construct() {
4877 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4878 if (args.manager) {
4879 this.manager = args.manager;
4880 }
4881 this.commands = this.defaultCommands();
4882 this.commandsInternal = this.defaultCommandsInternal();
4883 this.hooks = this.defaultHooks();
4884 this.routes = this.defaultRoutes();
4885 this.tabs = this.defaultTabs();
4886 this.shortcuts = this.defaultShortcuts();
4887 this.utils = this.defaultUtils();
4888 this.data = this.defaultData();
4889 this.uiStates = this.defaultUiStates();
4890 this.states = this.defaultStates();
4891 this.defaultRoute = '';
4892 this.currentTab = '';
4893 }
4894 }, {
4895 key: "registerAPI",
4896 value: function registerAPI() {
4897 var _this = this;
4898 Object.entries(this.getTabs()).forEach(function (tab) {
4899 return _this.registerTabRoute(tab[0]);
4900 });
4901 Object.entries(this.getRoutes()).forEach(function (_ref) {
4902 var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
4903 route = _ref2[0],
4904 callback = _ref2[1];
4905 return _this.registerRoute(route, callback);
4906 });
4907 Object.entries(this.getCommands()).forEach(function (_ref3) {
4908 var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
4909 command = _ref4[0],
4910 callback = _ref4[1];
4911 return _this.registerCommand(command, callback);
4912 });
4913 Object.entries(this.getCommandsInternal()).forEach(function (_ref5) {
4914 var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
4915 command = _ref6[0],
4916 callback = _ref6[1];
4917 return _this.registerCommandInternal(command, callback);
4918 });
4919 Object.values(this.getHooks()).forEach(function (instance) {
4920 return _this.registerHook(instance);
4921 });
4922 Object.entries(this.getData()).forEach(function (_ref7) {
4923 var _ref8 = (0, _slicedToArray2.default)(_ref7, 2),
4924 command = _ref8[0],
4925 callback = _ref8[1];
4926 return _this.registerData(command, callback);
4927 });
4928 Object.values(this.getUiStates()).forEach(function (instance) {
4929 return _this.registerUiState(instance);
4930 });
4931 Object.entries(this.getStates()).forEach(function (_ref9) {
4932 var _ref0 = (0, _slicedToArray2.default)(_ref9, 2),
4933 id = _ref0[0],
4934 state = _ref0[1];
4935 return _this.registerState(id, state);
4936 });
4937 }
4938
4939 // eslint-disable-next-line jsdoc/require-returns-check
4940 /**
4941 * @return {string} namespace
4942 */
4943 }, {
4944 key: "getNamespace",
4945 value: function getNamespace() {
4946 (0, _forceMethodImplementation.default)();
4947 }
4948
4949 /**
4950 * @deprecated since 3.7.0, use `getServiceName()` instead.
4951 */
4952 }, {
4953 key: "getRootContainer",
4954 value: function getRootContainer() {
4955 _deprecation.default.deprecated('getRootContainer()', '3.7.0', 'getServiceName()');
4956 return this.getServiceName();
4957 }
4958 }, {
4959 key: "getServiceName",
4960 value: function getServiceName() {
4961 return this.getNamespace().split('/')[0];
4962 }
4963 }, {
4964 key: "store",
4965 get: function get() {
4966 return $e.store.get(this.getNamespace());
4967 }
4968 }, {
4969 key: "defaultTabs",
4970 value: function defaultTabs() {
4971 return {};
4972 }
4973 }, {
4974 key: "defaultRoutes",
4975 value: function defaultRoutes() {
4976 return {};
4977 }
4978 }, {
4979 key: "defaultCommands",
4980 value: function defaultCommands() {
4981 return {};
4982 }
4983 }, {
4984 key: "defaultCommandsInternal",
4985 value: function defaultCommandsInternal() {
4986 return {};
4987 }
4988 }, {
4989 key: "defaultHooks",
4990 value: function defaultHooks() {
4991 return {};
4992 }
4993
4994 /**
4995 * Get the component's default UI states.
4996 *
4997 * @return {Object} default UI states
4998 */
4999 }, {
5000 key: "defaultUiStates",
5001 value: function defaultUiStates() {
5002 return {};
5003 }
5004
5005 /**
5006 * Get the component's Redux slice settings.
5007 *
5008 * @return {Object} Redux slice settings
5009 */
5010 }, {
5011 key: "defaultStates",
5012 value: function defaultStates() {
5013 return {};
5014 }
5015 }, {
5016 key: "defaultShortcuts",
5017 value: function defaultShortcuts() {
5018 return {};
5019 }
5020 }, {
5021 key: "defaultUtils",
5022 value: function defaultUtils() {
5023 return {};
5024 }
5025 }, {
5026 key: "defaultData",
5027 value: function defaultData() {
5028 return {};
5029 }
5030 }, {
5031 key: "getCommands",
5032 value: function getCommands() {
5033 return this.commands;
5034 }
5035 }, {
5036 key: "getCommandsInternal",
5037 value: function getCommandsInternal() {
5038 return this.commandsInternal;
5039 }
5040 }, {
5041 key: "getHooks",
5042 value: function getHooks() {
5043 return this.hooks;
5044 }
5045
5046 /**
5047 * Retrieve the component's UI states.
5048 *
5049 * @return {Object} UI states
5050 */
5051 }, {
5052 key: "getUiStates",
5053 value: function getUiStates() {
5054 return this.uiStates;
5055 }
5056
5057 /**
5058 * Retrieve the component's Redux Slice.
5059 *
5060 * @return {Object} Redux Slice
5061 */
5062 }, {
5063 key: "getStates",
5064 value: function getStates() {
5065 return this.states;
5066 }
5067 }, {
5068 key: "getRoutes",
5069 value: function getRoutes() {
5070 return this.routes;
5071 }
5072 }, {
5073 key: "getTabs",
5074 value: function getTabs() {
5075 return this.tabs;
5076 }
5077 }, {
5078 key: "getShortcuts",
5079 value: function getShortcuts() {
5080 return this.shortcuts;
5081 }
5082 }, {
5083 key: "getData",
5084 value: function getData() {
5085 return this.data;
5086 }
5087
5088 /**
5089 * @param {string} command
5090 * @param {(()=>{}|CommandInfra)} context
5091 * @param {'default'|'internal'|'data'} commandsType
5092 */
5093 }, {
5094 key: "registerCommand",
5095 value: function registerCommand(command, context) {
5096 var commandsType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'default';
5097 var commandsManager;
5098 switch (commandsType) {
5099 case 'default':
5100 commandsManager = $e.commands;
5101 break;
5102 case 'internal':
5103 commandsManager = $e.commandsInternal;
5104 break;
5105 case 'data':
5106 commandsManager = $e.data;
5107 break;
5108 default:
5109 throw new Error("Invalid commands type: '".concat(command, "'"));
5110 }
5111 var fullCommand = this.getNamespace() + '/' + command,
5112 instanceType = context.getInstanceType ? context.getInstanceType() : false,
5113 registerConfig = {
5114 command: fullCommand,
5115 component: this
5116 };
5117
5118 // Support pure callback.
5119 if (!instanceType) {
5120 if ($e.devTools) {
5121 $e.devTools.log.warn("Attach command-callback-base, on command: '".concat(fullCommand, "', context is unknown type."));
5122 }
5123 registerConfig.callback = context;
5124
5125 // Unique class.
5126 context = /*#__PURE__*/function (_CommandCallbackBase) {
5127 function context() {
5128 (0, _classCallCheck2.default)(this, context);
5129 return _callSuper(this, context, arguments);
5130 }
5131 (0, _inherits2.default)(context, _CommandCallbackBase);
5132 return (0, _createClass2.default)(context);
5133 }(_commandCallbackBase.default);
5134 }
5135 context.setRegisterConfig(registerConfig);
5136 commandsManager.register(this, command, context);
5137 }
5138
5139 /**
5140 * @param {HookBase} instance
5141 */
5142 }, {
5143 key: "registerHook",
5144 value: function registerHook(instance) {
5145 return instance.register();
5146 }
5147 }, {
5148 key: "registerCommandInternal",
5149 value: function registerCommandInternal(command, context) {
5150 this.registerCommand(command, context, 'internal');
5151 }
5152
5153 /**
5154 * Register a UI state.
5155 *
5156 * @param {UiStateBase} instance - UI state instance.
5157 *
5158 * @return {void}
5159 */
5160 }, {
5161 key: "registerUiState",
5162 value: function registerUiState(instance) {
5163 $e.uiStates.register(instance);
5164 }
5165
5166 /**
5167 * Register a Redux Slice.
5168 *
5169 * @param {string} id - State id.
5170 * @param {Object} stateConfig - The state config.
5171 *
5172 * @return {void}
5173 */
5174 }, {
5175 key: "registerState",
5176 value: function registerState(id, stateConfig) {
5177 id = this.getNamespace() + (id ? "/".concat(id) : '');
5178 var slice = (0, _toolkit.createSlice)(_objectSpread(_objectSpread({}, stateConfig), {}, {
5179 name: id
5180 }));
5181 $e.store.register(id, slice);
5182 }
5183 }, {
5184 key: "registerRoute",
5185 value: function registerRoute(route, callback) {
5186 $e.routes.register(this, route, callback);
5187 }
5188 }, {
5189 key: "registerData",
5190 value: function registerData(command, context) {
5191 this.registerCommand(command, context, 'data');
5192 }
5193 }, {
5194 key: "unregisterRoute",
5195 value: function unregisterRoute(route) {
5196 $e.routes.unregister(this, route);
5197 }
5198 }, {
5199 key: "registerTabRoute",
5200 value: function registerTabRoute(tab) {
5201 var _this2 = this;
5202 this.registerRoute(tab, function (args) {
5203 return _this2.activateTab(tab, args);
5204 });
5205 }
5206 }, {
5207 key: "dependency",
5208 value: function dependency() {
5209 return true;
5210 }
5211 }, {
5212 key: "open",
5213 value: function open() {
5214 return true;
5215 }
5216 }, {
5217 key: "close",
5218 value: function close() {
5219 if (!this.isOpen) {
5220 return false;
5221 }
5222 this.isOpen = false;
5223 this.inactivate();
5224 $e.routes.clearCurrent(this.getNamespace());
5225 $e.routes.clearHistory(this.getServiceName());
5226 return true;
5227 }
5228 }, {
5229 key: "activate",
5230 value: function activate() {
5231 $e.components.activate(this.getNamespace());
5232 }
5233 }, {
5234 key: "inactivate",
5235 value: function inactivate() {
5236 $e.components.inactivate(this.getNamespace());
5237 }
5238 }, {
5239 key: "isActive",
5240 value: function isActive() {
5241 return $e.components.isActive(this.getNamespace());
5242 }
5243 }, {
5244 key: "onRoute",
5245 value: function onRoute(route) {
5246 this.toggleRouteClass(route, true);
5247 this.toggleHistoryClass();
5248 this.activate();
5249 this.trigger('route/open', route);
5250 }
5251 }, {
5252 key: "onCloseRoute",
5253 value: function onCloseRoute(route) {
5254 this.toggleRouteClass(route, false);
5255 this.inactivate();
5256 this.trigger('route/close', route);
5257 }
5258 }, {
5259 key: "setDefaultRoute",
5260 value: function setDefaultRoute(route) {
5261 this.defaultRoute = this.getNamespace() + '/' + route;
5262 }
5263 }, {
5264 key: "getDefaultRoute",
5265 value: function getDefaultRoute() {
5266 return this.defaultRoute;
5267 }
5268 }, {
5269 key: "removeTab",
5270 value: function removeTab(tab) {
5271 delete this.tabs[tab];
5272 this.unregisterRoute(tab);
5273 }
5274 }, {
5275 key: "hasTab",
5276 value: function hasTab(tab) {
5277 return !!this.tabs[tab];
5278 }
5279 }, {
5280 key: "addTab",
5281 value: function addTab(tab, args, position) {
5282 var _this3 = this;
5283 this.tabs[tab] = args;
5284 // It can be 0.
5285 if ('undefined' !== typeof position) {
5286 var newTabs = {};
5287 var ids = Object.keys(this.tabs);
5288 // Remove new tab
5289 ids.pop();
5290
5291 // Add it to position.
5292 ids.splice(position, 0, tab);
5293 ids.forEach(function (id) {
5294 newTabs[id] = _this3.tabs[id];
5295 });
5296 this.tabs = newTabs;
5297 }
5298 this.registerTabRoute(tab);
5299 }
5300 }, {
5301 key: "getTabsWrapperSelector",
5302 value: function getTabsWrapperSelector() {
5303 return '';
5304 }
5305 }, {
5306 key: "getTabRoute",
5307 value: function getTabRoute(tab) {
5308 return this.getNamespace() + '/' + tab;
5309 }
5310 }, {
5311 key: "renderTab",
5312 value: function renderTab(tab) {} // eslint-disable-line
5313 }, {
5314 key: "activateTab",
5315 value: function activateTab(tab, args) {
5316 var _this4 = this;
5317 this.renderTab(tab, args);
5318 jQuery(this.getTabsWrapperSelector() + ' .elementor-component-tab').off('click').on('click', function (event) {
5319 $e.route(_this4.getTabRoute(event.currentTarget.dataset.tab), args);
5320 }).removeClass('elementor-active').filter('[data-tab="' + tab + '"]').addClass('elementor-active');
5321 }
5322 }, {
5323 key: "getActiveTabConfig",
5324 value: function getActiveTabConfig() {
5325 return this.tabs[this.currentTab] || {};
5326 }
5327 }, {
5328 key: "getBodyClass",
5329 value: function getBodyClass(route) {
5330 return 'e-route-' + route.replace(/\//g, '-');
5331 }
5332
5333 /**
5334 * If command includes uppercase character convert it to lowercase and add `-`.
5335 * e.g: `CopyAll` is converted to `copy-all`.
5336 *
5337 * @param {string} commandName
5338 */
5339 }, {
5340 key: "normalizeCommandName",
5341 value: function normalizeCommandName(commandName) {
5342 return commandName.replace(/[A-Z]/g, function (match, offset) {
5343 return (offset > 0 ? '-' : '') + match.toLowerCase();
5344 });
5345 }
5346
5347 /**
5348 * @param {{}} commandsFromImport
5349 * @return {{}} imported commands
5350 */
5351 }, {
5352 key: "importCommands",
5353 value: function importCommands(commandsFromImport) {
5354 var _this5 = this;
5355 var commands = {};
5356
5357 // Convert `Commands` to `ComponentBase` workable format.
5358 Object.entries(commandsFromImport).forEach(function (_ref1) {
5359 var _ref10 = (0, _slicedToArray2.default)(_ref1, 2),
5360 className = _ref10[0],
5361 Class = _ref10[1];
5362 var command = _this5.normalizeCommandName(className);
5363 commands[command] = Class;
5364 });
5365 return commands;
5366 }
5367 }, {
5368 key: "importHooks",
5369 value: function importHooks(hooksFromImport) {
5370 var hooks = {};
5371 for (var key in hooksFromImport) {
5372 var hook = new hooksFromImport[key]();
5373 hooks[hook.getId()] = hook;
5374 }
5375 return hooks;
5376 }
5377
5378 /**
5379 * Import & initialize the component's UI states.
5380 * Should be used inside `defaultUiState()`.
5381 *
5382 * @param {Object} statesFromImport - UI states from import.
5383 *
5384 * @return {Object} UI States
5385 */
5386 }, {
5387 key: "importUiStates",
5388 value: function importUiStates(statesFromImport) {
5389 var _this6 = this;
5390 var uiStates = {};
5391 Object.values(statesFromImport).forEach(function (className) {
5392 var uiState = new className(_this6);
5393 uiStates[uiState.getId()] = uiState;
5394 });
5395 return uiStates;
5396 }
5397
5398 /**
5399 * Set a UI state value.
5400 * TODO: Should we provide such function? Maybe the developer should implicitly pass the full state ID?
5401 *
5402 * @param {string} state - Non-prefixed state ID.
5403 * @param {*} value - New state value.
5404 *
5405 * @return {void}
5406 */
5407 }, {
5408 key: "setUiState",
5409 value: function setUiState(state, value) {
5410 $e.uiStates.set("".concat(this.getNamespace(), "/").concat(state), value);
5411 }
5412 }, {
5413 key: "toggleRouteClass",
5414 value: function toggleRouteClass(route, state) {
5415 document.body.classList.toggle(this.getBodyClass(route), state);
5416 }
5417 }, {
5418 key: "toggleHistoryClass",
5419 value: function toggleHistoryClass() {
5420 document.body.classList.toggle('e-routes-has-history', !!$e.routes.getHistory(this.getServiceName()).length);
5421 }
5422 }]);
5423 }(_module.default);
5424
5425 /***/ }),
5426
5427 /***/ "../modules/web-cli/assets/js/modules/component-modal-base.js":
5428 /*!********************************************************************!*\
5429 !*** ../modules/web-cli/assets/js/modules/component-modal-base.js ***!
5430 \********************************************************************/
5431 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5432
5433 "use strict";
5434
5435
5436 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5437 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
5438 Object.defineProperty(exports, "__esModule", ({
5439 value: true
5440 }));
5441 exports["default"] = void 0;
5442 var _readOnlyError2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/readOnlyError */ "../node_modules/@babel/runtime/helpers/readOnlyError.js"));
5443 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
5444 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
5445 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
5446 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
5447 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
5448 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
5449 var _componentBase = _interopRequireDefault(__webpack_require__(/*! ./component-base */ "../modules/web-cli/assets/js/modules/component-base.js"));
5450 var commands = _interopRequireWildcard(__webpack_require__(/*! ./commands/ */ "../modules/web-cli/assets/js/modules/commands/index.js"));
5451 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
5452 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); }
5453 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)); }
5454 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
5455 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; }
5456 var ComponentModalBase = exports["default"] = /*#__PURE__*/function (_ComponentBase) {
5457 function ComponentModalBase() {
5458 (0, _classCallCheck2.default)(this, ComponentModalBase);
5459 return _callSuper(this, ComponentModalBase, arguments);
5460 }
5461 (0, _inherits2.default)(ComponentModalBase, _ComponentBase);
5462 return (0, _createClass2.default)(ComponentModalBase, [{
5463 key: "registerAPI",
5464 value: function registerAPI() {
5465 var _this = this;
5466 _superPropGet(ComponentModalBase, "registerAPI", this, 3)([]);
5467 $e.shortcuts.register('esc', {
5468 scopes: [this.getNamespace()],
5469 callback: function callback() {
5470 return _this.close();
5471 }
5472 });
5473 }
5474 }, {
5475 key: "defaultCommands",
5476 value: function defaultCommands() {
5477 return this.importCommands(commands);
5478 }
5479 }, {
5480 key: "defaultRoutes",
5481 value: function defaultRoutes() {
5482 return {
5483 '': function _() {/* Nothing to do, it's already rendered. */}
5484 };
5485 }
5486 }, {
5487 key: "open",
5488 value: function open() {
5489 var _this2 = this;
5490 if (!this.layout) {
5491 var layout = this.getModalLayout();
5492 this.layout = new layout({
5493 component: this
5494 });
5495 this.layout.getModal().on('hide', function () {
5496 return _this2.close();
5497 });
5498 }
5499 this.layout.showModal();
5500 return true;
5501 }
5502 }, {
5503 key: "close",
5504 value: function close() {
5505 if (!_superPropGet(ComponentModalBase, "close", this, 3)([])) {
5506 return false;
5507 }
5508 var close = elementor.hooks.applyFilters('component/modal/close', this.layout.getModal().hide.bind(this.layout.getModal()), this);
5509 close();
5510 return true;
5511 }
5512 }, {
5513 key: "getModalLayout",
5514 value: function getModalLayout() {
5515 (0, _forceMethodImplementation.default)();
5516 }
5517 }]);
5518 }(_componentBase.default);
5519
5520 /***/ }),
5521
5522 /***/ "../modules/web-cli/assets/js/utils/console.js":
5523 /*!*****************************************************!*\
5524 !*** ../modules/web-cli/assets/js/utils/console.js ***!
5525 \*****************************************************/
5526 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5527
5528 "use strict";
5529
5530
5531 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5532 Object.defineProperty(exports, "__esModule", ({
5533 value: true
5534 }));
5535 exports["default"] = void 0;
5536 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
5537 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
5538 var Console = exports["default"] = /*#__PURE__*/function () {
5539 function Console() {
5540 (0, _classCallCheck2.default)(this, Console);
5541 }
5542 return (0, _createClass2.default)(Console, null, [{
5543 key: "error",
5544 value: function error(message) {
5545 // Show an error if devTools is available.
5546 if ($e.devTools) {
5547 $e.devTools.log.error(message);
5548 }
5549
5550 // If not a 'Hook-Break' then show error.
5551 if (!(message instanceof $e.modules.HookBreak)) {
5552 // eslint-disable-next-line no-console
5553 console.error(message);
5554 }
5555 }
5556 }, {
5557 key: "warn",
5558 value: function warn() {
5559 var _console;
5560 var style = "font-size: 12px; background-image: url(\"".concat(elementorWebCliConfig.urls.assets, "images/logo-icon.png\"); background-repeat: no-repeat; background-size: contain;");
5561 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5562 args[_key] = arguments[_key];
5563 }
5564 args.unshift('%c %c', style, '');
5565 (_console = console).warn.apply(_console, args); // eslint-disable-line no-console
5566 }
5567 }]);
5568 }();
5569
5570 /***/ }),
5571
5572 /***/ "../modules/web-cli/assets/js/utils/deprecation.js":
5573 /*!*********************************************************!*\
5574 !*** ../modules/web-cli/assets/js/utils/deprecation.js ***!
5575 \*********************************************************/
5576 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5577
5578 "use strict";
5579
5580
5581 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5582 Object.defineProperty(exports, "__esModule", ({
5583 value: true
5584 }));
5585 exports["default"] = void 0;
5586 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
5587 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
5588 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
5589 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
5590 // Copied from `modules/dev-tools/assets/js/deprecation.js`
5591 /**
5592 * @typedef {Object} Version
5593 * @property {number} major1 The first number
5594 * @property {number} major2 The second number
5595 * @property {number} minor The third number
5596 * @property {string} build The fourth number
5597 */
5598
5599 var softDeprecated = function softDeprecated(name, version, replacement) {
5600 if (elementorWebCliConfig.isDebug) {
5601 deprecatedMessage('soft', name, version, replacement);
5602 }
5603 };
5604 var hardDeprecated = function hardDeprecated(name, version, replacement) {
5605 deprecatedMessage('hard', name, version, replacement);
5606 };
5607 var deprecatedMessage = function deprecatedMessage(type, name, version, replacement) {
5608 var message = "`".concat(name, "` is ").concat(type, " deprecated since ").concat(version);
5609 if (replacement) {
5610 message += " - Use `".concat(replacement, "` instead");
5611 }
5612 _console.default.warn(message);
5613 };
5614 var Deprecation = exports["default"] = /*#__PURE__*/function () {
5615 function Deprecation() {
5616 (0, _classCallCheck2.default)(this, Deprecation);
5617 }
5618 return (0, _createClass2.default)(Deprecation, null, [{
5619 key: "deprecated",
5620 value: function deprecated(name, version, replacement) {
5621 if (this.isHardDeprecated(version)) {
5622 hardDeprecated(name, version, replacement);
5623 } else {
5624 softDeprecated(name, version, replacement);
5625 }
5626 }
5627
5628 /**
5629 * @param {string} version
5630 *
5631 * @return {Version}
5632 */
5633 }, {
5634 key: "parseVersion",
5635 value: function parseVersion(version) {
5636 var versionParts = version.split('.');
5637 if (versionParts.length < 3 || versionParts.length > 4) {
5638 throw new RangeError('Invalid Semantic Version string provided');
5639 }
5640 var _versionParts = (0, _slicedToArray2.default)(versionParts, 4),
5641 major1 = _versionParts[0],
5642 major2 = _versionParts[1],
5643 minor = _versionParts[2],
5644 _versionParts$ = _versionParts[3],
5645 build = _versionParts$ === void 0 ? '' : _versionParts$;
5646 return {
5647 major1: parseInt(major1),
5648 major2: parseInt(major2),
5649 minor: parseInt(minor),
5650 build: build
5651 };
5652 }
5653
5654 /**
5655 * Get total of major.
5656 *
5657 * 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,
5658 * versions with major2 more then 9 will be added to total.
5659 *
5660 * @param {Version} versionObj
5661 *
5662 * @return {number}
5663 */
5664 }, {
5665 key: "getTotalMajor",
5666 value: function getTotalMajor(versionObj) {
5667 var total = parseInt("".concat(versionObj.major1).concat(versionObj.major2, "0"));
5668 total = Number((total / 10).toFixed(0));
5669 if (versionObj.major2 > 9) {
5670 total = versionObj.major2 - 9;
5671 }
5672 return total;
5673 }
5674
5675 /**
5676 * @param {string} version1
5677 * @param {string} version2
5678 *
5679 * @return {number}
5680 */
5681 }, {
5682 key: "compareVersion",
5683 value: function compareVersion(version1, version2) {
5684 var _this = this;
5685 return [this.parseVersion(version1), this.parseVersion(version2)].map(function (versionObj) {
5686 return _this.getTotalMajor(versionObj);
5687 }).reduce(function (acc, major) {
5688 return acc - major;
5689 });
5690 }
5691
5692 /**
5693 * @param {string} version
5694 *
5695 * @return {boolean}
5696 */
5697 }, {
5698 key: "isSoftDeprecated",
5699 value: function isSoftDeprecated(version) {
5700 var total = this.compareVersion(version, elementorWebCliConfig.version);
5701 return total <= 4;
5702 }
5703
5704 /**
5705 * @param {string} version
5706 * @return {boolean}
5707 */
5708 }, {
5709 key: "isHardDeprecated",
5710 value: function isHardDeprecated(version) {
5711 var total = this.compareVersion(version, elementorWebCliConfig.version);
5712 return total < 0 || total >= 8;
5713 }
5714 }]);
5715 }();
5716
5717 /***/ }),
5718
5719 /***/ "../modules/web-cli/assets/js/utils/force-method-implementation.js":
5720 /*!*************************************************************************!*\
5721 !*** ../modules/web-cli/assets/js/utils/force-method-implementation.js ***!
5722 \*************************************************************************/
5723 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5724
5725 "use strict";
5726
5727
5728 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5729 Object.defineProperty(exports, "__esModule", ({
5730 value: true
5731 }));
5732 exports["default"] = exports.ForceMethodImplementation = void 0;
5733 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
5734 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
5735 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
5736 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
5737 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
5738 var _wrapNativeSuper2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/wrapNativeSuper */ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js"));
5739 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)); }
5740 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
5741 // TODO: Copied from `assets/dev/js/modules/imports/force-method-implementation.js`;
5742 var ForceMethodImplementation = exports.ForceMethodImplementation = /*#__PURE__*/function (_Error) {
5743 function ForceMethodImplementation() {
5744 var _this;
5745 var info = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5746 (0, _classCallCheck2.default)(this, ForceMethodImplementation);
5747 _this = _callSuper(this, ForceMethodImplementation, ["".concat(info.isStatic ? 'static ' : '').concat(info.fullName, "() should be implemented, please provide '").concat(info.functionName || info.fullName, "' functionality.")]);
5748 Error.captureStackTrace(_this, ForceMethodImplementation);
5749 return _this;
5750 }
5751 (0, _inherits2.default)(ForceMethodImplementation, _Error);
5752 return (0, _createClass2.default)(ForceMethodImplementation);
5753 }(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
5754 var _default = exports["default"] = function _default() {
5755 var stack = Error().stack,
5756 caller = stack.split('\n')[2].trim(),
5757 callerName = caller.startsWith('at new') ? 'constructor' : caller.split(' ')[1],
5758 info = {};
5759 info.functionName = callerName;
5760 info.fullName = callerName;
5761 if (info.functionName.includes('.')) {
5762 var parts = info.functionName.split('.');
5763 info.className = parts[0];
5764 info.functionName = parts[1];
5765 } else {
5766 info.isStatic = true;
5767 }
5768 throw new ForceMethodImplementation(info);
5769 };
5770
5771 /***/ }),
5772
5773 /***/ "../node_modules/@babel/runtime/helpers/OverloadYield.js":
5774 /*!***************************************************************!*\
5775 !*** ../node_modules/@babel/runtime/helpers/OverloadYield.js ***!
5776 \***************************************************************/
5777 /***/ ((module) => {
5778
5779 function _OverloadYield(e, d) {
5780 this.v = e, this.k = d;
5781 }
5782 module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
5783
5784 /***/ }),
5785
5786 /***/ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js":
5787 /*!******************************************************************!*\
5788 !*** ../node_modules/@babel/runtime/helpers/arrayLikeToArray.js ***!
5789 \******************************************************************/
5790 /***/ ((module) => {
5791
5792 function _arrayLikeToArray(r, a) {
5793 (null == a || a > r.length) && (a = r.length);
5794 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
5795 return n;
5796 }
5797 module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
5798
5799 /***/ }),
5800
5801 /***/ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js":
5802 /*!****************************************************************!*\
5803 !*** ../node_modules/@babel/runtime/helpers/arrayWithHoles.js ***!
5804 \****************************************************************/
5805 /***/ ((module) => {
5806
5807 function _arrayWithHoles(r) {
5808 if (Array.isArray(r)) return r;
5809 }
5810 module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
5811
5812 /***/ }),
5813
5814 /***/ "../node_modules/@babel/runtime/helpers/assertThisInitialized.js":
5815 /*!***********************************************************************!*\
5816 !*** ../node_modules/@babel/runtime/helpers/assertThisInitialized.js ***!
5817 \***********************************************************************/
5818 /***/ ((module) => {
5819
5820 function _assertThisInitialized(e) {
5821 if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
5822 return e;
5823 }
5824 module.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports["default"] = module.exports;
5825
5826 /***/ }),
5827
5828 /***/ "../node_modules/@babel/runtime/helpers/asyncToGenerator.js":
5829 /*!******************************************************************!*\
5830 !*** ../node_modules/@babel/runtime/helpers/asyncToGenerator.js ***!
5831 \******************************************************************/
5832 /***/ ((module) => {
5833
5834 function asyncGeneratorStep(n, t, e, r, o, a, c) {
5835 try {
5836 var i = n[a](c),
5837 u = i.value;
5838 } catch (n) {
5839 return void e(n);
5840 }
5841 i.done ? t(u) : Promise.resolve(u).then(r, o);
5842 }
5843 function _asyncToGenerator(n) {
5844 return function () {
5845 var t = this,
5846 e = arguments;
5847 return new Promise(function (r, o) {
5848 var a = n.apply(t, e);
5849 function _next(n) {
5850 asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
5851 }
5852 function _throw(n) {
5853 asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
5854 }
5855 _next(void 0);
5856 });
5857 };
5858 }
5859 module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
5860
5861 /***/ }),
5862
5863 /***/ "../node_modules/@babel/runtime/helpers/classCallCheck.js":
5864 /*!****************************************************************!*\
5865 !*** ../node_modules/@babel/runtime/helpers/classCallCheck.js ***!
5866 \****************************************************************/
5867 /***/ ((module) => {
5868
5869 function _classCallCheck(a, n) {
5870 if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
5871 }
5872 module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
5873
5874 /***/ }),
5875
5876 /***/ "../node_modules/@babel/runtime/helpers/construct.js":
5877 /*!***********************************************************!*\
5878 !*** ../node_modules/@babel/runtime/helpers/construct.js ***!
5879 \***********************************************************/
5880 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5881
5882 var isNativeReflectConstruct = __webpack_require__(/*! ./isNativeReflectConstruct.js */ "../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js");
5883 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
5884 function _construct(t, e, r) {
5885 if (isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
5886 var o = [null];
5887 o.push.apply(o, e);
5888 var p = new (t.bind.apply(t, o))();
5889 return r && setPrototypeOf(p, r.prototype), p;
5890 }
5891 module.exports = _construct, module.exports.__esModule = true, module.exports["default"] = module.exports;
5892
5893 /***/ }),
5894
5895 /***/ "../node_modules/@babel/runtime/helpers/createClass.js":
5896 /*!*************************************************************!*\
5897 !*** ../node_modules/@babel/runtime/helpers/createClass.js ***!
5898 \*************************************************************/
5899 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5900
5901 var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/toPropertyKey.js");
5902 function _defineProperties(e, r) {
5903 for (var t = 0; t < r.length; t++) {
5904 var o = r[t];
5905 o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey(o.key), o);
5906 }
5907 }
5908 function _createClass(e, r, t) {
5909 return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
5910 writable: !1
5911 }), e;
5912 }
5913 module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
5914
5915 /***/ }),
5916
5917 /***/ "../node_modules/@babel/runtime/helpers/defineProperty.js":
5918 /*!****************************************************************!*\
5919 !*** ../node_modules/@babel/runtime/helpers/defineProperty.js ***!
5920 \****************************************************************/
5921 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5922
5923 var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/toPropertyKey.js");
5924 function _defineProperty(e, r, t) {
5925 return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
5926 value: t,
5927 enumerable: !0,
5928 configurable: !0,
5929 writable: !0
5930 }) : e[r] = t, e;
5931 }
5932 module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
5933
5934 /***/ }),
5935
5936 /***/ "../node_modules/@babel/runtime/helpers/esm/defineProperty.js":
5937 /*!********************************************************************!*\
5938 !*** ../node_modules/@babel/runtime/helpers/esm/defineProperty.js ***!
5939 \********************************************************************/
5940 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5941
5942 "use strict";
5943 __webpack_require__.r(__webpack_exports__);
5944 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5945 /* harmony export */ "default": () => (/* binding */ _defineProperty)
5946 /* harmony export */ });
5947 /* harmony import */ var _toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js");
5948
5949 function _defineProperty(e, r, t) {
5950 return (r = (0,_toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__["default"])(r)) in e ? Object.defineProperty(e, r, {
5951 value: t,
5952 enumerable: !0,
5953 configurable: !0,
5954 writable: !0
5955 }) : e[r] = t, e;
5956 }
5957
5958
5959 /***/ }),
5960
5961 /***/ "../node_modules/@babel/runtime/helpers/esm/objectSpread2.js":
5962 /*!*******************************************************************!*\
5963 !*** ../node_modules/@babel/runtime/helpers/esm/objectSpread2.js ***!
5964 \*******************************************************************/
5965 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5966
5967 "use strict";
5968 __webpack_require__.r(__webpack_exports__);
5969 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5970 /* harmony export */ "default": () => (/* binding */ _objectSpread2)
5971 /* harmony export */ });
5972 /* harmony import */ var _defineProperty_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defineProperty.js */ "../node_modules/@babel/runtime/helpers/esm/defineProperty.js");
5973
5974 function ownKeys(e, r) {
5975 var t = Object.keys(e);
5976 if (Object.getOwnPropertySymbols) {
5977 var o = Object.getOwnPropertySymbols(e);
5978 r && (o = o.filter(function (r) {
5979 return Object.getOwnPropertyDescriptor(e, r).enumerable;
5980 })), t.push.apply(t, o);
5981 }
5982 return t;
5983 }
5984 function _objectSpread2(e) {
5985 for (var r = 1; r < arguments.length; r++) {
5986 var t = null != arguments[r] ? arguments[r] : {};
5987 r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
5988 (0,_defineProperty_js__WEBPACK_IMPORTED_MODULE_0__["default"])(e, r, t[r]);
5989 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
5990 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
5991 });
5992 }
5993 return e;
5994 }
5995
5996
5997 /***/ }),
5998
5999 /***/ "../node_modules/@babel/runtime/helpers/esm/toPrimitive.js":
6000 /*!*****************************************************************!*\
6001 !*** ../node_modules/@babel/runtime/helpers/esm/toPrimitive.js ***!
6002 \*****************************************************************/
6003 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
6004
6005 "use strict";
6006 __webpack_require__.r(__webpack_exports__);
6007 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
6008 /* harmony export */ "default": () => (/* binding */ toPrimitive)
6009 /* harmony export */ });
6010 /* harmony import */ var _typeof_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/esm/typeof.js");
6011
6012 function toPrimitive(t, r) {
6013 if ("object" != (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(t) || !t) return t;
6014 var e = t[Symbol.toPrimitive];
6015 if (void 0 !== e) {
6016 var i = e.call(t, r || "default");
6017 if ("object" != (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(i)) return i;
6018 throw new TypeError("@@toPrimitive must return a primitive value.");
6019 }
6020 return ("string" === r ? String : Number)(t);
6021 }
6022
6023
6024 /***/ }),
6025
6026 /***/ "../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js":
6027 /*!*******************************************************************!*\
6028 !*** ../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js ***!
6029 \*******************************************************************/
6030 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
6031
6032 "use strict";
6033 __webpack_require__.r(__webpack_exports__);
6034 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
6035 /* harmony export */ "default": () => (/* binding */ toPropertyKey)
6036 /* harmony export */ });
6037 /* harmony import */ var _typeof_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/esm/typeof.js");
6038 /* harmony import */ var _toPrimitive_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./toPrimitive.js */ "../node_modules/@babel/runtime/helpers/esm/toPrimitive.js");
6039
6040
6041 function toPropertyKey(t) {
6042 var i = (0,_toPrimitive_js__WEBPACK_IMPORTED_MODULE_1__["default"])(t, "string");
6043 return "symbol" == (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(i) ? i : i + "";
6044 }
6045
6046
6047 /***/ }),
6048
6049 /***/ "../node_modules/@babel/runtime/helpers/esm/typeof.js":
6050 /*!************************************************************!*\
6051 !*** ../node_modules/@babel/runtime/helpers/esm/typeof.js ***!
6052 \************************************************************/
6053 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
6054
6055 "use strict";
6056 __webpack_require__.r(__webpack_exports__);
6057 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
6058 /* harmony export */ "default": () => (/* binding */ _typeof)
6059 /* harmony export */ });
6060 function _typeof(o) {
6061 "@babel/helpers - typeof";
6062
6063 return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
6064 return typeof o;
6065 } : function (o) {
6066 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
6067 }, _typeof(o);
6068 }
6069
6070
6071 /***/ }),
6072
6073 /***/ "../node_modules/@babel/runtime/helpers/get.js":
6074 /*!*****************************************************!*\
6075 !*** ../node_modules/@babel/runtime/helpers/get.js ***!
6076 \*****************************************************/
6077 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6078
6079 var superPropBase = __webpack_require__(/*! ./superPropBase.js */ "../node_modules/@babel/runtime/helpers/superPropBase.js");
6080 function _get() {
6081 return module.exports = _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) {
6082 var p = superPropBase(e, t);
6083 if (p) {
6084 var n = Object.getOwnPropertyDescriptor(p, t);
6085 return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value;
6086 }
6087 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _get.apply(null, arguments);
6088 }
6089 module.exports = _get, module.exports.__esModule = true, module.exports["default"] = module.exports;
6090
6091 /***/ }),
6092
6093 /***/ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js":
6094 /*!****************************************************************!*\
6095 !*** ../node_modules/@babel/runtime/helpers/getPrototypeOf.js ***!
6096 \****************************************************************/
6097 /***/ ((module) => {
6098
6099 function _getPrototypeOf(t) {
6100 return module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
6101 return t.__proto__ || Object.getPrototypeOf(t);
6102 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _getPrototypeOf(t);
6103 }
6104 module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
6105
6106 /***/ }),
6107
6108 /***/ "../node_modules/@babel/runtime/helpers/inherits.js":
6109 /*!**********************************************************!*\
6110 !*** ../node_modules/@babel/runtime/helpers/inherits.js ***!
6111 \**********************************************************/
6112 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6113
6114 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
6115 function _inherits(t, e) {
6116 if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
6117 t.prototype = Object.create(e && e.prototype, {
6118 constructor: {
6119 value: t,
6120 writable: !0,
6121 configurable: !0
6122 }
6123 }), Object.defineProperty(t, "prototype", {
6124 writable: !1
6125 }), e && setPrototypeOf(t, e);
6126 }
6127 module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports;
6128
6129 /***/ }),
6130
6131 /***/ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js":
6132 /*!***********************************************************************!*\
6133 !*** ../node_modules/@babel/runtime/helpers/interopRequireDefault.js ***!
6134 \***********************************************************************/
6135 /***/ ((module) => {
6136
6137 function _interopRequireDefault(e) {
6138 return e && e.__esModule ? e : {
6139 "default": e
6140 };
6141 }
6142 module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
6143
6144 /***/ }),
6145
6146 /***/ "../node_modules/@babel/runtime/helpers/isNativeFunction.js":
6147 /*!******************************************************************!*\
6148 !*** ../node_modules/@babel/runtime/helpers/isNativeFunction.js ***!
6149 \******************************************************************/
6150 /***/ ((module) => {
6151
6152 function _isNativeFunction(t) {
6153 try {
6154 return -1 !== Function.toString.call(t).indexOf("[native code]");
6155 } catch (n) {
6156 return "function" == typeof t;
6157 }
6158 }
6159 module.exports = _isNativeFunction, module.exports.__esModule = true, module.exports["default"] = module.exports;
6160
6161 /***/ }),
6162
6163 /***/ "../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js":
6164 /*!**************************************************************************!*\
6165 !*** ../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js ***!
6166 \**************************************************************************/
6167 /***/ ((module) => {
6168
6169 function _isNativeReflectConstruct() {
6170 try {
6171 var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
6172 } catch (t) {}
6173 return (module.exports = _isNativeReflectConstruct = function _isNativeReflectConstruct() {
6174 return !!t;
6175 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
6176 }
6177 module.exports = _isNativeReflectConstruct, module.exports.__esModule = true, module.exports["default"] = module.exports;
6178
6179 /***/ }),
6180
6181 /***/ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js":
6182 /*!**********************************************************************!*\
6183 !*** ../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js ***!
6184 \**********************************************************************/
6185 /***/ ((module) => {
6186
6187 function _iterableToArrayLimit(r, l) {
6188 var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
6189 if (null != t) {
6190 var e,
6191 n,
6192 i,
6193 u,
6194 a = [],
6195 f = !0,
6196 o = !1;
6197 try {
6198 if (i = (t = t.call(r)).next, 0 === l) {
6199 if (Object(t) !== t) return;
6200 f = !1;
6201 } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
6202 } catch (r) {
6203 o = !0, n = r;
6204 } finally {
6205 try {
6206 if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
6207 } finally {
6208 if (o) throw n;
6209 }
6210 }
6211 return a;
6212 }
6213 }
6214 module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports;
6215
6216 /***/ }),
6217
6218 /***/ "../node_modules/@babel/runtime/helpers/nonIterableRest.js":
6219 /*!*****************************************************************!*\
6220 !*** ../node_modules/@babel/runtime/helpers/nonIterableRest.js ***!
6221 \*****************************************************************/
6222 /***/ ((module) => {
6223
6224 function _nonIterableRest() {
6225 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
6226 }
6227 module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports;
6228
6229 /***/ }),
6230
6231 /***/ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js":
6232 /*!***************************************************************************!*\
6233 !*** ../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js ***!
6234 \***************************************************************************/
6235 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6236
6237 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6238 var assertThisInitialized = __webpack_require__(/*! ./assertThisInitialized.js */ "../node_modules/@babel/runtime/helpers/assertThisInitialized.js");
6239 function _possibleConstructorReturn(t, e) {
6240 if (e && ("object" == _typeof(e) || "function" == typeof e)) return e;
6241 if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
6242 return assertThisInitialized(t);
6243 }
6244 module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
6245
6246 /***/ }),
6247
6248 /***/ "../node_modules/@babel/runtime/helpers/readOnlyError.js":
6249 /*!***************************************************************!*\
6250 !*** ../node_modules/@babel/runtime/helpers/readOnlyError.js ***!
6251 \***************************************************************/
6252 /***/ ((module) => {
6253
6254 function _readOnlyError(r) {
6255 throw new TypeError('"' + r + '" is read-only');
6256 }
6257 module.exports = _readOnlyError, module.exports.__esModule = true, module.exports["default"] = module.exports;
6258
6259 /***/ }),
6260
6261 /***/ "../node_modules/@babel/runtime/helpers/regenerator.js":
6262 /*!*************************************************************!*\
6263 !*** ../node_modules/@babel/runtime/helpers/regenerator.js ***!
6264 \*************************************************************/
6265 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6266
6267 var regeneratorDefine = __webpack_require__(/*! ./regeneratorDefine.js */ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js");
6268 function _regenerator() {
6269 /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
6270 var e,
6271 t,
6272 r = "function" == typeof Symbol ? Symbol : {},
6273 n = r.iterator || "@@iterator",
6274 o = r.toStringTag || "@@toStringTag";
6275 function i(r, n, o, i) {
6276 var c = n && n.prototype instanceof Generator ? n : Generator,
6277 u = Object.create(c.prototype);
6278 return regeneratorDefine(u, "_invoke", function (r, n, o) {
6279 var i,
6280 c,
6281 u,
6282 f = 0,
6283 p = o || [],
6284 y = !1,
6285 G = {
6286 p: 0,
6287 n: 0,
6288 v: e,
6289 a: d,
6290 f: d.bind(e, 4),
6291 d: function d(t, r) {
6292 return i = t, c = 0, u = e, G.n = r, a;
6293 }
6294 };
6295 function d(r, n) {
6296 for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
6297 var o,
6298 i = p[t],
6299 d = G.p,
6300 l = i[2];
6301 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));
6302 }
6303 if (o || r > 1) return a;
6304 throw y = !0, n;
6305 }
6306 return function (o, p, l) {
6307 if (f > 1) throw TypeError("Generator is already running");
6308 for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
6309 i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
6310 try {
6311 if (f = 2, i) {
6312 if (c || (o = "next"), t = i[o]) {
6313 if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
6314 if (!t.done) return t;
6315 u = t.value, c < 2 && (c = 0);
6316 } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
6317 i = e;
6318 } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
6319 } catch (t) {
6320 i = e, c = 1, u = t;
6321 } finally {
6322 f = 1;
6323 }
6324 }
6325 return {
6326 value: t,
6327 done: y
6328 };
6329 };
6330 }(r, o, i), !0), u;
6331 }
6332 var a = {};
6333 function Generator() {}
6334 function GeneratorFunction() {}
6335 function GeneratorFunctionPrototype() {}
6336 t = Object.getPrototypeOf;
6337 var c = [][n] ? t(t([][n]())) : (regeneratorDefine(t = {}, n, function () {
6338 return this;
6339 }), t),
6340 u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
6341 function f(e) {
6342 return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
6343 }
6344 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 () {
6345 return this;
6346 }), regeneratorDefine(u, "toString", function () {
6347 return "[object Generator]";
6348 }), (module.exports = _regenerator = function _regenerator() {
6349 return {
6350 w: i,
6351 m: f
6352 };
6353 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
6354 }
6355 module.exports = _regenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
6356
6357 /***/ }),
6358
6359 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsync.js":
6360 /*!******************************************************************!*\
6361 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsync.js ***!
6362 \******************************************************************/
6363 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6364
6365 var regeneratorAsyncGen = __webpack_require__(/*! ./regeneratorAsyncGen.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js");
6366 function _regeneratorAsync(n, e, r, t, o) {
6367 var a = regeneratorAsyncGen(n, e, r, t, o);
6368 return a.next().then(function (n) {
6369 return n.done ? n.value : a.next();
6370 });
6371 }
6372 module.exports = _regeneratorAsync, module.exports.__esModule = true, module.exports["default"] = module.exports;
6373
6374 /***/ }),
6375
6376 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js":
6377 /*!*********************************************************************!*\
6378 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js ***!
6379 \*********************************************************************/
6380 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6381
6382 var regenerator = __webpack_require__(/*! ./regenerator.js */ "../node_modules/@babel/runtime/helpers/regenerator.js");
6383 var regeneratorAsyncIterator = __webpack_require__(/*! ./regeneratorAsyncIterator.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js");
6384 function _regeneratorAsyncGen(r, e, t, o, n) {
6385 return new regeneratorAsyncIterator(regenerator().w(r, e, t, o), n || Promise);
6386 }
6387 module.exports = _regeneratorAsyncGen, module.exports.__esModule = true, module.exports["default"] = module.exports;
6388
6389 /***/ }),
6390
6391 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js":
6392 /*!**************************************************************************!*\
6393 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js ***!
6394 \**************************************************************************/
6395 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6396
6397 var OverloadYield = __webpack_require__(/*! ./OverloadYield.js */ "../node_modules/@babel/runtime/helpers/OverloadYield.js");
6398 var regeneratorDefine = __webpack_require__(/*! ./regeneratorDefine.js */ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js");
6399 function AsyncIterator(t, e) {
6400 function n(r, o, i, f) {
6401 try {
6402 var c = t[r](o),
6403 u = c.value;
6404 return u instanceof OverloadYield ? e.resolve(u.v).then(function (t) {
6405 n("next", t, i, f);
6406 }, function (t) {
6407 n("throw", t, i, f);
6408 }) : e.resolve(u).then(function (t) {
6409 c.value = t, i(c);
6410 }, function (t) {
6411 return n("throw", t, i, f);
6412 });
6413 } catch (t) {
6414 f(t);
6415 }
6416 }
6417 var r;
6418 this.next || (regeneratorDefine(AsyncIterator.prototype), regeneratorDefine(AsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () {
6419 return this;
6420 })), regeneratorDefine(this, "_invoke", function (t, o, i) {
6421 function f() {
6422 return new e(function (e, r) {
6423 n(t, i, e, r);
6424 });
6425 }
6426 return r = r ? r.then(f, f) : f();
6427 }, !0);
6428 }
6429 module.exports = AsyncIterator, module.exports.__esModule = true, module.exports["default"] = module.exports;
6430
6431 /***/ }),
6432
6433 /***/ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js":
6434 /*!*******************************************************************!*\
6435 !*** ../node_modules/@babel/runtime/helpers/regeneratorDefine.js ***!
6436 \*******************************************************************/
6437 /***/ ((module) => {
6438
6439 function _regeneratorDefine(e, r, n, t) {
6440 var i = Object.defineProperty;
6441 try {
6442 i({}, "", {});
6443 } catch (e) {
6444 i = 0;
6445 }
6446 module.exports = _regeneratorDefine = function regeneratorDefine(e, r, n, t) {
6447 function o(r, n) {
6448 _regeneratorDefine(e, r, function (e) {
6449 return this._invoke(r, n, e);
6450 });
6451 }
6452 r ? i ? i(e, r, {
6453 value: n,
6454 enumerable: !t,
6455 configurable: !t,
6456 writable: !t
6457 }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
6458 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _regeneratorDefine(e, r, n, t);
6459 }
6460 module.exports = _regeneratorDefine, module.exports.__esModule = true, module.exports["default"] = module.exports;
6461
6462 /***/ }),
6463
6464 /***/ "../node_modules/@babel/runtime/helpers/regeneratorKeys.js":
6465 /*!*****************************************************************!*\
6466 !*** ../node_modules/@babel/runtime/helpers/regeneratorKeys.js ***!
6467 \*****************************************************************/
6468 /***/ ((module) => {
6469
6470 function _regeneratorKeys(e) {
6471 var n = Object(e),
6472 r = [];
6473 for (var t in n) r.unshift(t);
6474 return function e() {
6475 for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e;
6476 return e.done = !0, e;
6477 };
6478 }
6479 module.exports = _regeneratorKeys, module.exports.__esModule = true, module.exports["default"] = module.exports;
6480
6481 /***/ }),
6482
6483 /***/ "../node_modules/@babel/runtime/helpers/regeneratorRuntime.js":
6484 /*!********************************************************************!*\
6485 !*** ../node_modules/@babel/runtime/helpers/regeneratorRuntime.js ***!
6486 \********************************************************************/
6487 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6488
6489 var OverloadYield = __webpack_require__(/*! ./OverloadYield.js */ "../node_modules/@babel/runtime/helpers/OverloadYield.js");
6490 var regenerator = __webpack_require__(/*! ./regenerator.js */ "../node_modules/@babel/runtime/helpers/regenerator.js");
6491 var regeneratorAsync = __webpack_require__(/*! ./regeneratorAsync.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsync.js");
6492 var regeneratorAsyncGen = __webpack_require__(/*! ./regeneratorAsyncGen.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js");
6493 var regeneratorAsyncIterator = __webpack_require__(/*! ./regeneratorAsyncIterator.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js");
6494 var regeneratorKeys = __webpack_require__(/*! ./regeneratorKeys.js */ "../node_modules/@babel/runtime/helpers/regeneratorKeys.js");
6495 var regeneratorValues = __webpack_require__(/*! ./regeneratorValues.js */ "../node_modules/@babel/runtime/helpers/regeneratorValues.js");
6496 function _regeneratorRuntime() {
6497 "use strict";
6498
6499 var r = regenerator(),
6500 e = r.m(_regeneratorRuntime),
6501 t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
6502 function n(r) {
6503 var e = "function" == typeof r && r.constructor;
6504 return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
6505 }
6506 var o = {
6507 "throw": 1,
6508 "return": 2,
6509 "break": 3,
6510 "continue": 3
6511 };
6512 function a(r) {
6513 var e, t;
6514 return function (n) {
6515 e || (e = {
6516 stop: function stop() {
6517 return t(n.a, 2);
6518 },
6519 "catch": function _catch() {
6520 return n.v;
6521 },
6522 abrupt: function abrupt(r, e) {
6523 return t(n.a, o[r], e);
6524 },
6525 delegateYield: function delegateYield(r, o, a) {
6526 return e.resultName = o, t(n.d, regeneratorValues(r), a);
6527 },
6528 finish: function finish(r) {
6529 return t(n.f, r);
6530 }
6531 }, t = function t(r, _t, o) {
6532 n.p = e.prev, n.n = e.next;
6533 try {
6534 return r(_t, o);
6535 } finally {
6536 e.next = n.n;
6537 }
6538 }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
6539 try {
6540 return r.call(this, e);
6541 } finally {
6542 n.p = e.prev, n.n = e.next;
6543 }
6544 };
6545 }
6546 return (module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
6547 return {
6548 wrap: function wrap(e, t, n, o) {
6549 return r.w(a(e), t, n, o && o.reverse());
6550 },
6551 isGeneratorFunction: n,
6552 mark: r.m,
6553 awrap: function awrap(r, e) {
6554 return new OverloadYield(r, e);
6555 },
6556 AsyncIterator: regeneratorAsyncIterator,
6557 async: function async(r, e, t, o, u) {
6558 return (n(e) ? regeneratorAsyncGen : regeneratorAsync)(a(r), e, t, o, u);
6559 },
6560 keys: regeneratorKeys,
6561 values: regeneratorValues
6562 };
6563 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
6564 }
6565 module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
6566
6567 /***/ }),
6568
6569 /***/ "../node_modules/@babel/runtime/helpers/regeneratorValues.js":
6570 /*!*******************************************************************!*\
6571 !*** ../node_modules/@babel/runtime/helpers/regeneratorValues.js ***!
6572 \*******************************************************************/
6573 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6574
6575 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6576 function _regeneratorValues(e) {
6577 if (null != e) {
6578 var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
6579 r = 0;
6580 if (t) return t.call(e);
6581 if ("function" == typeof e.next) return e;
6582 if (!isNaN(e.length)) return {
6583 next: function next() {
6584 return e && r >= e.length && (e = void 0), {
6585 value: e && e[r++],
6586 done: !e
6587 };
6588 }
6589 };
6590 }
6591 throw new TypeError(_typeof(e) + " is not iterable");
6592 }
6593 module.exports = _regeneratorValues, module.exports.__esModule = true, module.exports["default"] = module.exports;
6594
6595 /***/ }),
6596
6597 /***/ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js":
6598 /*!****************************************************************!*\
6599 !*** ../node_modules/@babel/runtime/helpers/setPrototypeOf.js ***!
6600 \****************************************************************/
6601 /***/ ((module) => {
6602
6603 function _setPrototypeOf(t, e) {
6604 return module.exports = _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
6605 return t.__proto__ = e, t;
6606 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _setPrototypeOf(t, e);
6607 }
6608 module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
6609
6610 /***/ }),
6611
6612 /***/ "../node_modules/@babel/runtime/helpers/slicedToArray.js":
6613 /*!***************************************************************!*\
6614 !*** ../node_modules/@babel/runtime/helpers/slicedToArray.js ***!
6615 \***************************************************************/
6616 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6617
6618 var arrayWithHoles = __webpack_require__(/*! ./arrayWithHoles.js */ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js");
6619 var iterableToArrayLimit = __webpack_require__(/*! ./iterableToArrayLimit.js */ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js");
6620 var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray.js */ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js");
6621 var nonIterableRest = __webpack_require__(/*! ./nonIterableRest.js */ "../node_modules/@babel/runtime/helpers/nonIterableRest.js");
6622 function _slicedToArray(r, e) {
6623 return arrayWithHoles(r) || iterableToArrayLimit(r, e) || unsupportedIterableToArray(r, e) || nonIterableRest();
6624 }
6625 module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
6626
6627 /***/ }),
6628
6629 /***/ "../node_modules/@babel/runtime/helpers/superPropBase.js":
6630 /*!***************************************************************!*\
6631 !*** ../node_modules/@babel/runtime/helpers/superPropBase.js ***!
6632 \***************************************************************/
6633 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6634
6635 var getPrototypeOf = __webpack_require__(/*! ./getPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js");
6636 function _superPropBase(t, o) {
6637 for (; !{}.hasOwnProperty.call(t, o) && null !== (t = getPrototypeOf(t)););
6638 return t;
6639 }
6640 module.exports = _superPropBase, module.exports.__esModule = true, module.exports["default"] = module.exports;
6641
6642 /***/ }),
6643
6644 /***/ "../node_modules/@babel/runtime/helpers/toPrimitive.js":
6645 /*!*************************************************************!*\
6646 !*** ../node_modules/@babel/runtime/helpers/toPrimitive.js ***!
6647 \*************************************************************/
6648 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6649
6650 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6651 function toPrimitive(t, r) {
6652 if ("object" != _typeof(t) || !t) return t;
6653 var e = t[Symbol.toPrimitive];
6654 if (void 0 !== e) {
6655 var i = e.call(t, r || "default");
6656 if ("object" != _typeof(i)) return i;
6657 throw new TypeError("@@toPrimitive must return a primitive value.");
6658 }
6659 return ("string" === r ? String : Number)(t);
6660 }
6661 module.exports = toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
6662
6663 /***/ }),
6664
6665 /***/ "../node_modules/@babel/runtime/helpers/toPropertyKey.js":
6666 /*!***************************************************************!*\
6667 !*** ../node_modules/@babel/runtime/helpers/toPropertyKey.js ***!
6668 \***************************************************************/
6669 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6670
6671 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6672 var toPrimitive = __webpack_require__(/*! ./toPrimitive.js */ "../node_modules/@babel/runtime/helpers/toPrimitive.js");
6673 function toPropertyKey(t) {
6674 var i = toPrimitive(t, "string");
6675 return "symbol" == _typeof(i) ? i : i + "";
6676 }
6677 module.exports = toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
6678
6679 /***/ }),
6680
6681 /***/ "../node_modules/@babel/runtime/helpers/typeof.js":
6682 /*!********************************************************!*\
6683 !*** ../node_modules/@babel/runtime/helpers/typeof.js ***!
6684 \********************************************************/
6685 /***/ ((module) => {
6686
6687 function _typeof(o) {
6688 "@babel/helpers - typeof";
6689
6690 return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
6691 return typeof o;
6692 } : function (o) {
6693 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
6694 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
6695 }
6696 module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
6697
6698 /***/ }),
6699
6700 /***/ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js":
6701 /*!****************************************************************************!*\
6702 !*** ../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js ***!
6703 \****************************************************************************/
6704 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6705
6706 var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray.js */ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js");
6707 function _unsupportedIterableToArray(r, a) {
6708 if (r) {
6709 if ("string" == typeof r) return arrayLikeToArray(r, a);
6710 var t = {}.toString.call(r).slice(8, -1);
6711 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;
6712 }
6713 }
6714 module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
6715
6716 /***/ }),
6717
6718 /***/ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js":
6719 /*!*****************************************************************!*\
6720 !*** ../node_modules/@babel/runtime/helpers/wrapNativeSuper.js ***!
6721 \*****************************************************************/
6722 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6723
6724 var getPrototypeOf = __webpack_require__(/*! ./getPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js");
6725 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
6726 var isNativeFunction = __webpack_require__(/*! ./isNativeFunction.js */ "../node_modules/@babel/runtime/helpers/isNativeFunction.js");
6727 var construct = __webpack_require__(/*! ./construct.js */ "../node_modules/@babel/runtime/helpers/construct.js");
6728 function _wrapNativeSuper(t) {
6729 var r = "function" == typeof Map ? new Map() : void 0;
6730 return module.exports = _wrapNativeSuper = function _wrapNativeSuper(t) {
6731 if (null === t || !isNativeFunction(t)) return t;
6732 if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
6733 if (void 0 !== r) {
6734 if (r.has(t)) return r.get(t);
6735 r.set(t, Wrapper);
6736 }
6737 function Wrapper() {
6738 return construct(t, arguments, getPrototypeOf(this).constructor);
6739 }
6740 return Wrapper.prototype = Object.create(t.prototype, {
6741 constructor: {
6742 value: Wrapper,
6743 enumerable: !1,
6744 writable: !0,
6745 configurable: !0
6746 }
6747 }), setPrototypeOf(Wrapper, t);
6748 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _wrapNativeSuper(t);
6749 }
6750 module.exports = _wrapNativeSuper, module.exports.__esModule = true, module.exports["default"] = module.exports;
6751
6752 /***/ }),
6753
6754 /***/ "../node_modules/@babel/runtime/regenerator/index.js":
6755 /*!***********************************************************!*\
6756 !*** ../node_modules/@babel/runtime/regenerator/index.js ***!
6757 \***********************************************************/
6758 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6759
6760 // TODO(Babel 8): Remove this file.
6761
6762 var runtime = __webpack_require__(/*! ../helpers/regeneratorRuntime */ "../node_modules/@babel/runtime/helpers/regeneratorRuntime.js")();
6763 module.exports = runtime;
6764
6765 // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
6766 try {
6767 regeneratorRuntime = runtime;
6768 } catch (accidentalStrictMode) {
6769 if (typeof globalThis === "object") {
6770 globalThis.regeneratorRuntime = runtime;
6771 } else {
6772 Function("r", "regeneratorRuntime = r")(runtime);
6773 }
6774 }
6775
6776
6777 /***/ }),
6778
6779 /***/ "../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js":
6780 /*!******************************************************************!*\
6781 !*** ../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js ***!
6782 \******************************************************************/
6783 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
6784
6785 "use strict";
6786 __webpack_require__.r(__webpack_exports__);
6787 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
6788 /* harmony export */ EnhancerArray: () => (/* binding */ EnhancerArray),
6789 /* harmony export */ MiddlewareArray: () => (/* binding */ MiddlewareArray),
6790 /* harmony export */ SHOULD_AUTOBATCH: () => (/* binding */ SHOULD_AUTOBATCH),
6791 /* harmony export */ TaskAbortError: () => (/* binding */ TaskAbortError),
6792 /* harmony export */ __DO_NOT_USE__ActionTypes: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.__DO_NOT_USE__ActionTypes),
6793 /* harmony export */ addListener: () => (/* binding */ addListener),
6794 /* harmony export */ applyMiddleware: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.applyMiddleware),
6795 /* harmony export */ autoBatchEnhancer: () => (/* binding */ autoBatchEnhancer),
6796 /* harmony export */ bindActionCreators: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.bindActionCreators),
6797 /* harmony export */ clearAllListeners: () => (/* binding */ clearAllListeners),
6798 /* harmony export */ combineReducers: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.combineReducers),
6799 /* harmony export */ compose: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.compose),
6800 /* harmony export */ configureStore: () => (/* binding */ configureStore),
6801 /* harmony export */ createAction: () => (/* binding */ createAction),
6802 /* harmony export */ createActionCreatorInvariantMiddleware: () => (/* binding */ createActionCreatorInvariantMiddleware),
6803 /* harmony export */ createAsyncThunk: () => (/* binding */ createAsyncThunk),
6804 /* harmony export */ createDraftSafeSelector: () => (/* binding */ createDraftSafeSelector),
6805 /* harmony export */ createEntityAdapter: () => (/* binding */ createEntityAdapter),
6806 /* harmony export */ createImmutableStateInvariantMiddleware: () => (/* binding */ createImmutableStateInvariantMiddleware),
6807 /* harmony export */ createListenerMiddleware: () => (/* binding */ createListenerMiddleware),
6808 /* harmony export */ createNextState: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__["default"]),
6809 /* harmony export */ createReducer: () => (/* binding */ createReducer),
6810 /* harmony export */ createSelector: () => (/* reexport safe */ reselect__WEBPACK_IMPORTED_MODULE_2__.createSelector),
6811 /* harmony export */ createSerializableStateInvariantMiddleware: () => (/* binding */ createSerializableStateInvariantMiddleware),
6812 /* harmony export */ createSlice: () => (/* binding */ createSlice),
6813 /* harmony export */ createStore: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.createStore),
6814 /* harmony export */ current: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.current),
6815 /* harmony export */ findNonSerializableValue: () => (/* binding */ findNonSerializableValue),
6816 /* harmony export */ freeze: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.freeze),
6817 /* harmony export */ getDefaultMiddleware: () => (/* binding */ getDefaultMiddleware),
6818 /* harmony export */ getType: () => (/* binding */ getType),
6819 /* harmony export */ isAction: () => (/* binding */ isAction),
6820 /* harmony export */ isActionCreator: () => (/* binding */ isActionCreator),
6821 /* harmony export */ isAllOf: () => (/* binding */ isAllOf),
6822 /* harmony export */ isAnyOf: () => (/* binding */ isAnyOf),
6823 /* harmony export */ isAsyncThunkAction: () => (/* binding */ isAsyncThunkAction),
6824 /* harmony export */ isDraft: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.isDraft),
6825 /* harmony export */ isFluxStandardAction: () => (/* binding */ isFSA),
6826 /* harmony export */ isFulfilled: () => (/* binding */ isFulfilled),
6827 /* harmony export */ isImmutableDefault: () => (/* binding */ isImmutableDefault),
6828 /* harmony export */ isPending: () => (/* binding */ isPending),
6829 /* harmony export */ isPlain: () => (/* binding */ isPlain),
6830 /* harmony export */ isPlainObject: () => (/* binding */ isPlainObject),
6831 /* harmony export */ isRejected: () => (/* binding */ isRejected),
6832 /* harmony export */ isRejectedWithValue: () => (/* binding */ isRejectedWithValue),
6833 /* harmony export */ legacy_createStore: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.legacy_createStore),
6834 /* harmony export */ miniSerializeError: () => (/* binding */ miniSerializeError),
6835 /* harmony export */ nanoid: () => (/* binding */ nanoid),
6836 /* harmony export */ original: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.original),
6837 /* harmony export */ prepareAutoBatched: () => (/* binding */ prepareAutoBatched),
6838 /* harmony export */ removeListener: () => (/* binding */ removeListener),
6839 /* harmony export */ unwrapResult: () => (/* binding */ unwrapResult)
6840 /* harmony export */ });
6841 /* harmony import */ var immer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! immer */ "../node_modules/immer/dist/immer.esm.mjs");
6842 /* harmony import */ var redux__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! redux */ "../node_modules/redux/es/redux.js");
6843 /* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! reselect */ "../node_modules/reselect/es/index.js");
6844 /* harmony import */ var redux_thunk__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! redux-thunk */ "../node_modules/redux-thunk/es/index.js");
6845 var __extends = (undefined && undefined.__extends) || (function () {
6846 var extendStatics = function (d, b) {
6847 extendStatics = Object.setPrototypeOf ||
6848 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6849 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6850 return extendStatics(d, b);
6851 };
6852 return function (d, b) {
6853 if (typeof b !== "function" && b !== null)
6854 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
6855 extendStatics(d, b);
6856 function __() { this.constructor = d; }
6857 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6858 };
6859 })();
6860 var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
6861 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
6862 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
6863 function verb(n) { return function (v) { return step([n, v]); }; }
6864 function step(op) {
6865 if (f) throw new TypeError("Generator is already executing.");
6866 while (_) try {
6867 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;
6868 if (y = 0, t) op = [op[0] & 2, t.value];
6869 switch (op[0]) {
6870 case 0: case 1: t = op; break;
6871 case 4: _.label++; return { value: op[1], done: false };
6872 case 5: _.label++; y = op[1]; op = [0]; continue;
6873 case 7: op = _.ops.pop(); _.trys.pop(); continue;
6874 default:
6875 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
6876 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
6877 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
6878 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
6879 if (t[2]) _.ops.pop();
6880 _.trys.pop(); continue;
6881 }
6882 op = body.call(thisArg, _);
6883 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
6884 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
6885 }
6886 };
6887 var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
6888 for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
6889 to[j] = from[i];
6890 return to;
6891 };
6892 var __defProp = Object.defineProperty;
6893 var __defProps = Object.defineProperties;
6894 var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6895 var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6896 var __hasOwnProp = Object.prototype.hasOwnProperty;
6897 var __propIsEnum = Object.prototype.propertyIsEnumerable;
6898 var __defNormalProp = function (obj, key, value) { return key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value }) : obj[key] = value; };
6899 var __spreadValues = function (a, b) {
6900 for (var prop in b || (b = {}))
6901 if (__hasOwnProp.call(b, prop))
6902 __defNormalProp(a, prop, b[prop]);
6903 if (__getOwnPropSymbols)
6904 for (var _i = 0, _c = __getOwnPropSymbols(b); _i < _c.length; _i++) {
6905 var prop = _c[_i];
6906 if (__propIsEnum.call(b, prop))
6907 __defNormalProp(a, prop, b[prop]);
6908 }
6909 return a;
6910 };
6911 var __spreadProps = function (a, b) { return __defProps(a, __getOwnPropDescs(b)); };
6912 var __async = function (__this, __arguments, generator) {
6913 return new Promise(function (resolve, reject) {
6914 var fulfilled = function (value) {
6915 try {
6916 step(generator.next(value));
6917 }
6918 catch (e) {
6919 reject(e);
6920 }
6921 };
6922 var rejected = function (value) {
6923 try {
6924 step(generator.throw(value));
6925 }
6926 catch (e) {
6927 reject(e);
6928 }
6929 };
6930 var step = function (x) { return x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); };
6931 step((generator = generator.apply(__this, __arguments)).next());
6932 });
6933 };
6934 // src/index.ts
6935
6936
6937
6938
6939 // src/createDraftSafeSelector.ts
6940
6941
6942 var createDraftSafeSelector = function () {
6943 var args = [];
6944 for (var _i = 0; _i < arguments.length; _i++) {
6945 args[_i] = arguments[_i];
6946 }
6947 var selector = reselect__WEBPACK_IMPORTED_MODULE_2__.createSelector.apply(void 0, args);
6948 var wrappedSelector = function (value) {
6949 var rest = [];
6950 for (var _i = 1; _i < arguments.length; _i++) {
6951 rest[_i - 1] = arguments[_i];
6952 }
6953 return selector.apply(void 0, __spreadArray([(0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(value) ? (0,immer__WEBPACK_IMPORTED_MODULE_0__.current)(value) : value], rest));
6954 };
6955 return wrappedSelector;
6956 };
6957 // src/configureStore.ts
6958
6959 // src/devtoolsExtension.ts
6960
6961 var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function () {
6962 if (arguments.length === 0)
6963 return void 0;
6964 if (typeof arguments[0] === "object")
6965 return redux__WEBPACK_IMPORTED_MODULE_1__.compose;
6966 return redux__WEBPACK_IMPORTED_MODULE_1__.compose.apply(null, arguments);
6967 };
6968 var devToolsEnhancer = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__ : function () {
6969 return function (noop2) {
6970 return noop2;
6971 };
6972 };
6973 // src/isPlainObject.ts
6974 function isPlainObject(value) {
6975 if (typeof value !== "object" || value === null)
6976 return false;
6977 var proto = Object.getPrototypeOf(value);
6978 if (proto === null)
6979 return true;
6980 var baseProto = proto;
6981 while (Object.getPrototypeOf(baseProto) !== null) {
6982 baseProto = Object.getPrototypeOf(baseProto);
6983 }
6984 return proto === baseProto;
6985 }
6986 // src/getDefaultMiddleware.ts
6987
6988 // src/tsHelpers.ts
6989 var hasMatchFunction = function (v) {
6990 return v && typeof v.match === "function";
6991 };
6992 // src/createAction.ts
6993 function createAction(type, prepareAction) {
6994 function actionCreator() {
6995 var args = [];
6996 for (var _i = 0; _i < arguments.length; _i++) {
6997 args[_i] = arguments[_i];
6998 }
6999 if (prepareAction) {
7000 var prepared = prepareAction.apply(void 0, args);
7001 if (!prepared) {
7002 throw new Error("prepareAction did not return an object");
7003 }
7004 return __spreadValues(__spreadValues({
7005 type: type,
7006 payload: prepared.payload
7007 }, "meta" in prepared && { meta: prepared.meta }), "error" in prepared && { error: prepared.error });
7008 }
7009 return { type: type, payload: args[0] };
7010 }
7011 actionCreator.toString = function () { return "" + type; };
7012 actionCreator.type = type;
7013 actionCreator.match = function (action) { return action.type === type; };
7014 return actionCreator;
7015 }
7016 function isAction(action) {
7017 return isPlainObject(action) && "type" in action;
7018 }
7019 function isActionCreator(action) {
7020 return typeof action === "function" && "type" in action && hasMatchFunction(action);
7021 }
7022 function isFSA(action) {
7023 return isAction(action) && typeof action.type === "string" && Object.keys(action).every(isValidKey);
7024 }
7025 function isValidKey(key) {
7026 return ["type", "payload", "error", "meta"].indexOf(key) > -1;
7027 }
7028 function getType(actionCreator) {
7029 return "" + actionCreator;
7030 }
7031 // src/actionCreatorInvariantMiddleware.ts
7032 function getMessage(type) {
7033 var splitType = type ? ("" + type).split("/") : [];
7034 var actionName = splitType[splitType.length - 1] || "actionCreator";
7035 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.";
7036 }
7037 function createActionCreatorInvariantMiddleware(options) {
7038 if (options === void 0) { options = {}; }
7039 if (false) // removed by dead control flow
7040 {}
7041 var _c = options.isActionCreator, isActionCreator2 = _c === void 0 ? isActionCreator : _c;
7042 return function () { return function (next) { return function (action) {
7043 if (isActionCreator2(action)) {
7044 console.warn(getMessage(action.type));
7045 }
7046 return next(action);
7047 }; }; };
7048 }
7049 // src/utils.ts
7050
7051 function getTimeMeasureUtils(maxDelay, fnName) {
7052 var elapsed = 0;
7053 return {
7054 measureTime: function (fn) {
7055 var started = Date.now();
7056 try {
7057 return fn();
7058 }
7059 finally {
7060 var finished = Date.now();
7061 elapsed += finished - started;
7062 }
7063 },
7064 warnIfExceeded: function () {
7065 if (elapsed > maxDelay) {
7066 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.");
7067 }
7068 }
7069 };
7070 }
7071 var MiddlewareArray = /** @class */ (function (_super) {
7072 __extends(MiddlewareArray, _super);
7073 function MiddlewareArray() {
7074 var args = [];
7075 for (var _i = 0; _i < arguments.length; _i++) {
7076 args[_i] = arguments[_i];
7077 }
7078 var _this = _super.apply(this, args) || this;
7079 Object.setPrototypeOf(_this, MiddlewareArray.prototype);
7080 return _this;
7081 }
7082 Object.defineProperty(MiddlewareArray, Symbol.species, {
7083 get: function () {
7084 return MiddlewareArray;
7085 },
7086 enumerable: false,
7087 configurable: true
7088 });
7089 MiddlewareArray.prototype.concat = function () {
7090 var arr = [];
7091 for (var _i = 0; _i < arguments.length; _i++) {
7092 arr[_i] = arguments[_i];
7093 }
7094 return _super.prototype.concat.apply(this, arr);
7095 };
7096 MiddlewareArray.prototype.prepend = function () {
7097 var arr = [];
7098 for (var _i = 0; _i < arguments.length; _i++) {
7099 arr[_i] = arguments[_i];
7100 }
7101 if (arr.length === 1 && Array.isArray(arr[0])) {
7102 return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr[0].concat(this))))();
7103 }
7104 return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr.concat(this))))();
7105 };
7106 return MiddlewareArray;
7107 }(Array));
7108 var EnhancerArray = /** @class */ (function (_super) {
7109 __extends(EnhancerArray, _super);
7110 function EnhancerArray() {
7111 var args = [];
7112 for (var _i = 0; _i < arguments.length; _i++) {
7113 args[_i] = arguments[_i];
7114 }
7115 var _this = _super.apply(this, args) || this;
7116 Object.setPrototypeOf(_this, EnhancerArray.prototype);
7117 return _this;
7118 }
7119 Object.defineProperty(EnhancerArray, Symbol.species, {
7120 get: function () {
7121 return EnhancerArray;
7122 },
7123 enumerable: false,
7124 configurable: true
7125 });
7126 EnhancerArray.prototype.concat = function () {
7127 var arr = [];
7128 for (var _i = 0; _i < arguments.length; _i++) {
7129 arr[_i] = arguments[_i];
7130 }
7131 return _super.prototype.concat.apply(this, arr);
7132 };
7133 EnhancerArray.prototype.prepend = function () {
7134 var arr = [];
7135 for (var _i = 0; _i < arguments.length; _i++) {
7136 arr[_i] = arguments[_i];
7137 }
7138 if (arr.length === 1 && Array.isArray(arr[0])) {
7139 return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr[0].concat(this))))();
7140 }
7141 return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr.concat(this))))();
7142 };
7143 return EnhancerArray;
7144 }(Array));
7145 function freezeDraftable(val) {
7146 return (0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraftable)(val) ? (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(val, function () {
7147 }) : val;
7148 }
7149 // src/immutableStateInvariantMiddleware.ts
7150 var isProduction = "development" === "production";
7151 var prefix = "Invariant failed";
7152 function invariant(condition, message) {
7153 if (condition) {
7154 return;
7155 }
7156 if (isProduction) {
7157 throw new Error(prefix);
7158 }
7159 throw new Error(prefix + ": " + (message || ""));
7160 }
7161 function stringify(obj, serializer, indent, decycler) {
7162 return JSON.stringify(obj, getSerialize(serializer, decycler), indent);
7163 }
7164 function getSerialize(serializer, decycler) {
7165 var stack = [], keys = [];
7166 if (!decycler)
7167 decycler = function (_, value) {
7168 if (stack[0] === value)
7169 return "[Circular ~]";
7170 return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
7171 };
7172 return function (key, value) {
7173 if (stack.length > 0) {
7174 var thisPos = stack.indexOf(this);
7175 ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
7176 ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
7177 if (~stack.indexOf(value))
7178 value = decycler.call(this, key, value);
7179 }
7180 else
7181 stack.push(value);
7182 return serializer == null ? value : serializer.call(this, key, value);
7183 };
7184 }
7185 function isImmutableDefault(value) {
7186 return typeof value !== "object" || value == null || Object.isFrozen(value);
7187 }
7188 function trackForMutations(isImmutable, ignorePaths, obj) {
7189 var trackedProperties = trackProperties(isImmutable, ignorePaths, obj);
7190 return {
7191 detectMutations: function () {
7192 return detectMutations(isImmutable, ignorePaths, trackedProperties, obj);
7193 }
7194 };
7195 }
7196 function trackProperties(isImmutable, ignorePaths, obj, path, checkedObjects) {
7197 if (ignorePaths === void 0) { ignorePaths = []; }
7198 if (path === void 0) { path = ""; }
7199 if (checkedObjects === void 0) { checkedObjects = new Set(); }
7200 var tracked = { value: obj };
7201 if (!isImmutable(obj) && !checkedObjects.has(obj)) {
7202 checkedObjects.add(obj);
7203 tracked.children = {};
7204 for (var key in obj) {
7205 var childPath = path ? path + "." + key : key;
7206 if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
7207 continue;
7208 }
7209 tracked.children[key] = trackProperties(isImmutable, ignorePaths, obj[key], childPath);
7210 }
7211 }
7212 return tracked;
7213 }
7214 function detectMutations(isImmutable, ignoredPaths, trackedProperty, obj, sameParentRef, path) {
7215 if (ignoredPaths === void 0) { ignoredPaths = []; }
7216 if (sameParentRef === void 0) { sameParentRef = false; }
7217 if (path === void 0) { path = ""; }
7218 var prevObj = trackedProperty ? trackedProperty.value : void 0;
7219 var sameRef = prevObj === obj;
7220 if (sameParentRef && !sameRef && !Number.isNaN(obj)) {
7221 return { wasMutated: true, path: path };
7222 }
7223 if (isImmutable(prevObj) || isImmutable(obj)) {
7224 return { wasMutated: false };
7225 }
7226 var keysToDetect = {};
7227 for (var key in trackedProperty.children) {
7228 keysToDetect[key] = true;
7229 }
7230 for (var key in obj) {
7231 keysToDetect[key] = true;
7232 }
7233 var hasIgnoredPaths = ignoredPaths.length > 0;
7234 var _loop_1 = function (key) {
7235 var nestedPath = path ? path + "." + key : key;
7236 if (hasIgnoredPaths) {
7237 var hasMatches = ignoredPaths.some(function (ignored) {
7238 if (ignored instanceof RegExp) {
7239 return ignored.test(nestedPath);
7240 }
7241 return nestedPath === ignored;
7242 });
7243 if (hasMatches) {
7244 return "continue";
7245 }
7246 }
7247 var result = detectMutations(isImmutable, ignoredPaths, trackedProperty.children[key], obj[key], sameRef, nestedPath);
7248 if (result.wasMutated) {
7249 return { value: result };
7250 }
7251 };
7252 for (var key in keysToDetect) {
7253 var state_1 = _loop_1(key);
7254 if (typeof state_1 === "object")
7255 return state_1.value;
7256 }
7257 return { wasMutated: false };
7258 }
7259 function createImmutableStateInvariantMiddleware(options) {
7260 if (options === void 0) { options = {}; }
7261 if (false) // removed by dead control flow
7262 {}
7263 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;
7264 ignoredPaths = ignoredPaths || ignore;
7265 var track = trackForMutations.bind(null, isImmutable, ignoredPaths);
7266 return function (_c) {
7267 var getState = _c.getState;
7268 var state = getState();
7269 var tracker = track(state);
7270 var result;
7271 return function (next) { return function (action) {
7272 var measureUtils = getTimeMeasureUtils(warnAfter, "ImmutableStateInvariantMiddleware");
7273 measureUtils.measureTime(function () {
7274 state = getState();
7275 result = tracker.detectMutations();
7276 tracker = track(state);
7277 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)");
7278 });
7279 var dispatchedAction = next(action);
7280 measureUtils.measureTime(function () {
7281 state = getState();
7282 result = tracker.detectMutations();
7283 tracker = track(state);
7284 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)");
7285 });
7286 measureUtils.warnIfExceeded();
7287 return dispatchedAction;
7288 }; };
7289 };
7290 }
7291 // src/serializableStateInvariantMiddleware.ts
7292 function isPlain(val) {
7293 var type = typeof val;
7294 return val == null || type === "string" || type === "boolean" || type === "number" || Array.isArray(val) || isPlainObject(val);
7295 }
7296 function findNonSerializableValue(value, path, isSerializable, getEntries, ignoredPaths, cache) {
7297 if (path === void 0) { path = ""; }
7298 if (isSerializable === void 0) { isSerializable = isPlain; }
7299 if (ignoredPaths === void 0) { ignoredPaths = []; }
7300 var foundNestedSerializable;
7301 if (!isSerializable(value)) {
7302 return {
7303 keyPath: path || "<root>",
7304 value: value
7305 };
7306 }
7307 if (typeof value !== "object" || value === null) {
7308 return false;
7309 }
7310 if (cache == null ? void 0 : cache.has(value))
7311 return false;
7312 var entries = getEntries != null ? getEntries(value) : Object.entries(value);
7313 var hasIgnoredPaths = ignoredPaths.length > 0;
7314 var _loop_2 = function (key, nestedValue) {
7315 var nestedPath = path ? path + "." + key : key;
7316 if (hasIgnoredPaths) {
7317 var hasMatches = ignoredPaths.some(function (ignored) {
7318 if (ignored instanceof RegExp) {
7319 return ignored.test(nestedPath);
7320 }
7321 return nestedPath === ignored;
7322 });
7323 if (hasMatches) {
7324 return "continue";
7325 }
7326 }
7327 if (!isSerializable(nestedValue)) {
7328 return { value: {
7329 keyPath: nestedPath,
7330 value: nestedValue
7331 } };
7332 }
7333 if (typeof nestedValue === "object") {
7334 foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths, cache);
7335 if (foundNestedSerializable) {
7336 return { value: foundNestedSerializable };
7337 }
7338 }
7339 };
7340 for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
7341 var _c = entries_1[_i], key = _c[0], nestedValue = _c[1];
7342 var state_2 = _loop_2(key, nestedValue);
7343 if (typeof state_2 === "object")
7344 return state_2.value;
7345 }
7346 if (cache && isNestedFrozen(value))
7347 cache.add(value);
7348 return false;
7349 }
7350 function isNestedFrozen(value) {
7351 if (!Object.isFrozen(value))
7352 return false;
7353 for (var _i = 0, _c = Object.values(value); _i < _c.length; _i++) {
7354 var nestedValue = _c[_i];
7355 if (typeof nestedValue !== "object" || nestedValue === null)
7356 continue;
7357 if (!isNestedFrozen(nestedValue))
7358 return false;
7359 }
7360 return true;
7361 }
7362 function createSerializableStateInvariantMiddleware(options) {
7363 if (options === void 0) { options = {}; }
7364 if (false) // removed by dead control flow
7365 {}
7366 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;
7367 var cache = !disableCache && WeakSet ? new WeakSet() : void 0;
7368 return function (storeAPI) { return function (next) { return function (action) {
7369 var result = next(action);
7370 var measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware");
7371 if (!ignoreActions && !(ignoredActions.length && ignoredActions.indexOf(action.type) !== -1)) {
7372 measureUtils.measureTime(function () {
7373 var foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths, cache);
7374 if (foundActionNonSerializableValue) {
7375 var keyPath = foundActionNonSerializableValue.keyPath, value = foundActionNonSerializableValue.value;
7376 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)");
7377 }
7378 });
7379 }
7380 if (!ignoreState) {
7381 measureUtils.measureTime(function () {
7382 var state = storeAPI.getState();
7383 var foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths, cache);
7384 if (foundStateNonSerializableValue) {
7385 var keyPath = foundStateNonSerializableValue.keyPath, value = foundStateNonSerializableValue.value;
7386 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)");
7387 }
7388 });
7389 measureUtils.warnIfExceeded();
7390 }
7391 return result;
7392 }; }; };
7393 }
7394 // src/getDefaultMiddleware.ts
7395 function isBoolean(x) {
7396 return typeof x === "boolean";
7397 }
7398 function curryGetDefaultMiddleware() {
7399 return function curriedGetDefaultMiddleware(options) {
7400 return getDefaultMiddleware(options);
7401 };
7402 }
7403 function getDefaultMiddleware(options) {
7404 if (options === void 0) { options = {}; }
7405 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;
7406 var middlewareArray = new MiddlewareArray();
7407 if (thunk) {
7408 if (isBoolean(thunk)) {
7409 middlewareArray.push(redux_thunk__WEBPACK_IMPORTED_MODULE_3__["default"]);
7410 }
7411 else {
7412 middlewareArray.push(redux_thunk__WEBPACK_IMPORTED_MODULE_3__["default"].withExtraArgument(thunk.extraArgument));
7413 }
7414 }
7415 if (true) {
7416 if (immutableCheck) {
7417 var immutableOptions = {};
7418 if (!isBoolean(immutableCheck)) {
7419 immutableOptions = immutableCheck;
7420 }
7421 middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));
7422 }
7423 if (serializableCheck) {
7424 var serializableOptions = {};
7425 if (!isBoolean(serializableCheck)) {
7426 serializableOptions = serializableCheck;
7427 }
7428 middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions));
7429 }
7430 if (actionCreatorCheck) {
7431 var actionCreatorOptions = {};
7432 if (!isBoolean(actionCreatorCheck)) {
7433 actionCreatorOptions = actionCreatorCheck;
7434 }
7435 middlewareArray.unshift(createActionCreatorInvariantMiddleware(actionCreatorOptions));
7436 }
7437 }
7438 return middlewareArray;
7439 }
7440 // src/configureStore.ts
7441 var IS_PRODUCTION = "development" === "production";
7442 function configureStore(options) {
7443 var curriedGetDefaultMiddleware = curryGetDefaultMiddleware();
7444 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;
7445 var rootReducer;
7446 if (typeof reducer === "function") {
7447 rootReducer = reducer;
7448 }
7449 else if (isPlainObject(reducer)) {
7450 rootReducer = (0,redux__WEBPACK_IMPORTED_MODULE_1__.combineReducers)(reducer);
7451 }
7452 else {
7453 throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');
7454 }
7455 var finalMiddleware = middleware;
7456 if (typeof finalMiddleware === "function") {
7457 finalMiddleware = finalMiddleware(curriedGetDefaultMiddleware);
7458 if (!IS_PRODUCTION && !Array.isArray(finalMiddleware)) {
7459 throw new Error("when using a middleware builder function, an array of middleware must be returned");
7460 }
7461 }
7462 if (!IS_PRODUCTION && finalMiddleware.some(function (item) { return typeof item !== "function"; })) {
7463 throw new Error("each middleware provided to configureStore must be a function");
7464 }
7465 var middlewareEnhancer = redux__WEBPACK_IMPORTED_MODULE_1__.applyMiddleware.apply(void 0, finalMiddleware);
7466 var finalCompose = redux__WEBPACK_IMPORTED_MODULE_1__.compose;
7467 if (devTools) {
7468 finalCompose = composeWithDevTools(__spreadValues({
7469 trace: !IS_PRODUCTION
7470 }, typeof devTools === "object" && devTools));
7471 }
7472 var defaultEnhancers = new EnhancerArray(middlewareEnhancer);
7473 var storeEnhancers = defaultEnhancers;
7474 if (Array.isArray(enhancers)) {
7475 storeEnhancers = __spreadArray([middlewareEnhancer], enhancers);
7476 }
7477 else if (typeof enhancers === "function") {
7478 storeEnhancers = enhancers(defaultEnhancers);
7479 }
7480 var composedEnhancer = finalCompose.apply(void 0, storeEnhancers);
7481 return (0,redux__WEBPACK_IMPORTED_MODULE_1__.createStore)(rootReducer, preloadedState, composedEnhancer);
7482 }
7483 // src/createReducer.ts
7484
7485 // src/mapBuilders.ts
7486 function executeReducerBuilderCallback(builderCallback) {
7487 var actionsMap = {};
7488 var actionMatchers = [];
7489 var defaultCaseReducer;
7490 var builder = {
7491 addCase: function (typeOrActionCreator, reducer) {
7492 if (true) {
7493 if (actionMatchers.length > 0) {
7494 throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");
7495 }
7496 if (defaultCaseReducer) {
7497 throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");
7498 }
7499 }
7500 var type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
7501 if (!type) {
7502 throw new Error("`builder.addCase` cannot be called with an empty action type");
7503 }
7504 if (type in actionsMap) {
7505 throw new Error("`builder.addCase` cannot be called with two reducers for the same action type");
7506 }
7507 actionsMap[type] = reducer;
7508 return builder;
7509 },
7510 addMatcher: function (matcher, reducer) {
7511 if (true) {
7512 if (defaultCaseReducer) {
7513 throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");
7514 }
7515 }
7516 actionMatchers.push({ matcher: matcher, reducer: reducer });
7517 return builder;
7518 },
7519 addDefaultCase: function (reducer) {
7520 if (true) {
7521 if (defaultCaseReducer) {
7522 throw new Error("`builder.addDefaultCase` can only be called once");
7523 }
7524 }
7525 defaultCaseReducer = reducer;
7526 return builder;
7527 }
7528 };
7529 builderCallback(builder);
7530 return [actionsMap, actionMatchers, defaultCaseReducer];
7531 }
7532 // src/createReducer.ts
7533 function isStateFunction(x) {
7534 return typeof x === "function";
7535 }
7536 var hasWarnedAboutObjectNotation = false;
7537 function createReducer(initialState, mapOrBuilderCallback, actionMatchers, defaultCaseReducer) {
7538 if (actionMatchers === void 0) { actionMatchers = []; }
7539 if (true) {
7540 if (typeof mapOrBuilderCallback === "object") {
7541 if (!hasWarnedAboutObjectNotation) {
7542 hasWarnedAboutObjectNotation = true;
7543 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");
7544 }
7545 }
7546 }
7547 var _c = typeof mapOrBuilderCallback === "function" ? executeReducerBuilderCallback(mapOrBuilderCallback) : [mapOrBuilderCallback, actionMatchers, defaultCaseReducer], actionsMap = _c[0], finalActionMatchers = _c[1], finalDefaultCaseReducer = _c[2];
7548 var getInitialState;
7549 if (isStateFunction(initialState)) {
7550 getInitialState = function () { return freezeDraftable(initialState()); };
7551 }
7552 else {
7553 var frozenInitialState_1 = freezeDraftable(initialState);
7554 getInitialState = function () { return frozenInitialState_1; };
7555 }
7556 function reducer(state, action) {
7557 if (state === void 0) { state = getInitialState(); }
7558 var caseReducers = __spreadArray([
7559 actionsMap[action.type]
7560 ], finalActionMatchers.filter(function (_c) {
7561 var matcher = _c.matcher;
7562 return matcher(action);
7563 }).map(function (_c) {
7564 var reducer2 = _c.reducer;
7565 return reducer2;
7566 }));
7567 if (caseReducers.filter(function (cr) { return !!cr; }).length === 0) {
7568 caseReducers = [finalDefaultCaseReducer];
7569 }
7570 return caseReducers.reduce(function (previousState, caseReducer) {
7571 if (caseReducer) {
7572 if ((0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(previousState)) {
7573 var draft = previousState;
7574 var result = caseReducer(draft, action);
7575 if (result === void 0) {
7576 return previousState;
7577 }
7578 return result;
7579 }
7580 else if (!(0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraftable)(previousState)) {
7581 var result = caseReducer(previousState, action);
7582 if (result === void 0) {
7583 if (previousState === null) {
7584 return previousState;
7585 }
7586 throw Error("A case reducer on a non-draftable value must not return undefined");
7587 }
7588 return result;
7589 }
7590 else {
7591 return (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(previousState, function (draft) {
7592 return caseReducer(draft, action);
7593 });
7594 }
7595 }
7596 return previousState;
7597 }, state);
7598 }
7599 reducer.getInitialState = getInitialState;
7600 return reducer;
7601 }
7602 // src/createSlice.ts
7603 var hasWarnedAboutObjectNotation2 = false;
7604 function getType2(slice, actionKey) {
7605 return slice + "/" + actionKey;
7606 }
7607 function createSlice(options) {
7608 var name = options.name;
7609 if (!name) {
7610 throw new Error("`name` is a required option for createSlice");
7611 }
7612 if (typeof process !== "undefined" && "development" === "development") {
7613 if (options.initialState === void 0) {
7614 console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");
7615 }
7616 }
7617 var initialState = typeof options.initialState == "function" ? options.initialState : freezeDraftable(options.initialState);
7618 var reducers = options.reducers || {};
7619 var reducerNames = Object.keys(reducers);
7620 var sliceCaseReducersByName = {};
7621 var sliceCaseReducersByType = {};
7622 var actionCreators = {};
7623 reducerNames.forEach(function (reducerName) {
7624 var maybeReducerWithPrepare = reducers[reducerName];
7625 var type = getType2(name, reducerName);
7626 var caseReducer;
7627 var prepareCallback;
7628 if ("reducer" in maybeReducerWithPrepare) {
7629 caseReducer = maybeReducerWithPrepare.reducer;
7630 prepareCallback = maybeReducerWithPrepare.prepare;
7631 }
7632 else {
7633 caseReducer = maybeReducerWithPrepare;
7634 }
7635 sliceCaseReducersByName[reducerName] = caseReducer;
7636 sliceCaseReducersByType[type] = caseReducer;
7637 actionCreators[reducerName] = prepareCallback ? createAction(type, prepareCallback) : createAction(type);
7638 });
7639 function buildReducer() {
7640 if (true) {
7641 if (typeof options.extraReducers === "object") {
7642 if (!hasWarnedAboutObjectNotation2) {
7643 hasWarnedAboutObjectNotation2 = true;
7644 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");
7645 }
7646 }
7647 }
7648 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;
7649 var finalCaseReducers = __spreadValues(__spreadValues({}, extraReducers), sliceCaseReducersByType);
7650 return createReducer(initialState, function (builder) {
7651 for (var key in finalCaseReducers) {
7652 builder.addCase(key, finalCaseReducers[key]);
7653 }
7654 for (var _i = 0, actionMatchers_1 = actionMatchers; _i < actionMatchers_1.length; _i++) {
7655 var m = actionMatchers_1[_i];
7656 builder.addMatcher(m.matcher, m.reducer);
7657 }
7658 if (defaultCaseReducer) {
7659 builder.addDefaultCase(defaultCaseReducer);
7660 }
7661 });
7662 }
7663 var _reducer;
7664 return {
7665 name: name,
7666 reducer: function (state, action) {
7667 if (!_reducer)
7668 _reducer = buildReducer();
7669 return _reducer(state, action);
7670 },
7671 actions: actionCreators,
7672 caseReducers: sliceCaseReducersByName,
7673 getInitialState: function () {
7674 if (!_reducer)
7675 _reducer = buildReducer();
7676 return _reducer.getInitialState();
7677 }
7678 };
7679 }
7680 // src/entities/entity_state.ts
7681 function getInitialEntityState() {
7682 return {
7683 ids: [],
7684 entities: {}
7685 };
7686 }
7687 function createInitialStateFactory() {
7688 function getInitialState(additionalState) {
7689 if (additionalState === void 0) { additionalState = {}; }
7690 return Object.assign(getInitialEntityState(), additionalState);
7691 }
7692 return { getInitialState: getInitialState };
7693 }
7694 // src/entities/state_selectors.ts
7695 function createSelectorsFactory() {
7696 function getSelectors(selectState) {
7697 var selectIds = function (state) { return state.ids; };
7698 var selectEntities = function (state) { return state.entities; };
7699 var selectAll = createDraftSafeSelector(selectIds, selectEntities, function (ids, entities) { return ids.map(function (id) { return entities[id]; }); });
7700 var selectId = function (_, id) { return id; };
7701 var selectById = function (entities, id) { return entities[id]; };
7702 var selectTotal = createDraftSafeSelector(selectIds, function (ids) { return ids.length; });
7703 if (!selectState) {
7704 return {
7705 selectIds: selectIds,
7706 selectEntities: selectEntities,
7707 selectAll: selectAll,
7708 selectTotal: selectTotal,
7709 selectById: createDraftSafeSelector(selectEntities, selectId, selectById)
7710 };
7711 }
7712 var selectGlobalizedEntities = createDraftSafeSelector(selectState, selectEntities);
7713 return {
7714 selectIds: createDraftSafeSelector(selectState, selectIds),
7715 selectEntities: selectGlobalizedEntities,
7716 selectAll: createDraftSafeSelector(selectState, selectAll),
7717 selectTotal: createDraftSafeSelector(selectState, selectTotal),
7718 selectById: createDraftSafeSelector(selectGlobalizedEntities, selectId, selectById)
7719 };
7720 }
7721 return { getSelectors: getSelectors };
7722 }
7723 // src/entities/state_adapter.ts
7724
7725 function createSingleArgumentStateOperator(mutator) {
7726 var operator = createStateOperator(function (_, state) { return mutator(state); });
7727 return function operation(state) {
7728 return operator(state, void 0);
7729 };
7730 }
7731 function createStateOperator(mutator) {
7732 return function operation(state, arg) {
7733 function isPayloadActionArgument(arg2) {
7734 return isFSA(arg2);
7735 }
7736 var runMutator = function (draft) {
7737 if (isPayloadActionArgument(arg)) {
7738 mutator(arg.payload, draft);
7739 }
7740 else {
7741 mutator(arg, draft);
7742 }
7743 };
7744 if ((0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(state)) {
7745 runMutator(state);
7746 return state;
7747 }
7748 else {
7749 return (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(state, runMutator);
7750 }
7751 };
7752 }
7753 // src/entities/utils.ts
7754 function selectIdValue(entity, selectId) {
7755 var key = selectId(entity);
7756 if ( true && key === void 0) {
7757 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());
7758 }
7759 return key;
7760 }
7761 function ensureEntitiesArray(entities) {
7762 if (!Array.isArray(entities)) {
7763 entities = Object.values(entities);
7764 }
7765 return entities;
7766 }
7767 function splitAddedUpdatedEntities(newEntities, selectId, state) {
7768 newEntities = ensureEntitiesArray(newEntities);
7769 var added = [];
7770 var updated = [];
7771 for (var _i = 0, newEntities_1 = newEntities; _i < newEntities_1.length; _i++) {
7772 var entity = newEntities_1[_i];
7773 var id = selectIdValue(entity, selectId);
7774 if (id in state.entities) {
7775 updated.push({ id: id, changes: entity });
7776 }
7777 else {
7778 added.push(entity);
7779 }
7780 }
7781 return [added, updated];
7782 }
7783 // src/entities/unsorted_state_adapter.ts
7784 function createUnsortedStateAdapter(selectId) {
7785 function addOneMutably(entity, state) {
7786 var key = selectIdValue(entity, selectId);
7787 if (key in state.entities) {
7788 return;
7789 }
7790 state.ids.push(key);
7791 state.entities[key] = entity;
7792 }
7793 function addManyMutably(newEntities, state) {
7794 newEntities = ensureEntitiesArray(newEntities);
7795 for (var _i = 0, newEntities_2 = newEntities; _i < newEntities_2.length; _i++) {
7796 var entity = newEntities_2[_i];
7797 addOneMutably(entity, state);
7798 }
7799 }
7800 function setOneMutably(entity, state) {
7801 var key = selectIdValue(entity, selectId);
7802 if (!(key in state.entities)) {
7803 state.ids.push(key);
7804 }
7805 state.entities[key] = entity;
7806 }
7807 function setManyMutably(newEntities, state) {
7808 newEntities = ensureEntitiesArray(newEntities);
7809 for (var _i = 0, newEntities_3 = newEntities; _i < newEntities_3.length; _i++) {
7810 var entity = newEntities_3[_i];
7811 setOneMutably(entity, state);
7812 }
7813 }
7814 function setAllMutably(newEntities, state) {
7815 newEntities = ensureEntitiesArray(newEntities);
7816 state.ids = [];
7817 state.entities = {};
7818 addManyMutably(newEntities, state);
7819 }
7820 function removeOneMutably(key, state) {
7821 return removeManyMutably([key], state);
7822 }
7823 function removeManyMutably(keys, state) {
7824 var didMutate = false;
7825 keys.forEach(function (key) {
7826 if (key in state.entities) {
7827 delete state.entities[key];
7828 didMutate = true;
7829 }
7830 });
7831 if (didMutate) {
7832 state.ids = state.ids.filter(function (id) { return id in state.entities; });
7833 }
7834 }
7835 function removeAllMutably(state) {
7836 Object.assign(state, {
7837 ids: [],
7838 entities: {}
7839 });
7840 }
7841 function takeNewKey(keys, update, state) {
7842 var original2 = state.entities[update.id];
7843 var updated = Object.assign({}, original2, update.changes);
7844 var newKey = selectIdValue(updated, selectId);
7845 var hasNewKey = newKey !== update.id;
7846 if (hasNewKey) {
7847 keys[update.id] = newKey;
7848 delete state.entities[update.id];
7849 }
7850 state.entities[newKey] = updated;
7851 return hasNewKey;
7852 }
7853 function updateOneMutably(update, state) {
7854 return updateManyMutably([update], state);
7855 }
7856 function updateManyMutably(updates, state) {
7857 var newKeys = {};
7858 var updatesPerEntity = {};
7859 updates.forEach(function (update) {
7860 if (update.id in state.entities) {
7861 updatesPerEntity[update.id] = {
7862 id: update.id,
7863 changes: __spreadValues(__spreadValues({}, updatesPerEntity[update.id] ? updatesPerEntity[update.id].changes : null), update.changes)
7864 };
7865 }
7866 });
7867 updates = Object.values(updatesPerEntity);
7868 var didMutateEntities = updates.length > 0;
7869 if (didMutateEntities) {
7870 var didMutateIds = updates.filter(function (update) { return takeNewKey(newKeys, update, state); }).length > 0;
7871 if (didMutateIds) {
7872 state.ids = Object.keys(state.entities);
7873 }
7874 }
7875 }
7876 function upsertOneMutably(entity, state) {
7877 return upsertManyMutably([entity], state);
7878 }
7879 function upsertManyMutably(newEntities, state) {
7880 var _c = splitAddedUpdatedEntities(newEntities, selectId, state), added = _c[0], updated = _c[1];
7881 updateManyMutably(updated, state);
7882 addManyMutably(added, state);
7883 }
7884 return {
7885 removeAll: createSingleArgumentStateOperator(removeAllMutably),
7886 addOne: createStateOperator(addOneMutably),
7887 addMany: createStateOperator(addManyMutably),
7888 setOne: createStateOperator(setOneMutably),
7889 setMany: createStateOperator(setManyMutably),
7890 setAll: createStateOperator(setAllMutably),
7891 updateOne: createStateOperator(updateOneMutably),
7892 updateMany: createStateOperator(updateManyMutably),
7893 upsertOne: createStateOperator(upsertOneMutably),
7894 upsertMany: createStateOperator(upsertManyMutably),
7895 removeOne: createStateOperator(removeOneMutably),
7896 removeMany: createStateOperator(removeManyMutably)
7897 };
7898 }
7899 // src/entities/sorted_state_adapter.ts
7900 function createSortedStateAdapter(selectId, sort) {
7901 var _c = createUnsortedStateAdapter(selectId), removeOne = _c.removeOne, removeMany = _c.removeMany, removeAll = _c.removeAll;
7902 function addOneMutably(entity, state) {
7903 return addManyMutably([entity], state);
7904 }
7905 function addManyMutably(newEntities, state) {
7906 newEntities = ensureEntitiesArray(newEntities);
7907 var models = newEntities.filter(function (model) { return !(selectIdValue(model, selectId) in state.entities); });
7908 if (models.length !== 0) {
7909 merge(models, state);
7910 }
7911 }
7912 function setOneMutably(entity, state) {
7913 return setManyMutably([entity], state);
7914 }
7915 function setManyMutably(newEntities, state) {
7916 newEntities = ensureEntitiesArray(newEntities);
7917 if (newEntities.length !== 0) {
7918 merge(newEntities, state);
7919 }
7920 }
7921 function setAllMutably(newEntities, state) {
7922 newEntities = ensureEntitiesArray(newEntities);
7923 state.entities = {};
7924 state.ids = [];
7925 addManyMutably(newEntities, state);
7926 }
7927 function updateOneMutably(update, state) {
7928 return updateManyMutably([update], state);
7929 }
7930 function updateManyMutably(updates, state) {
7931 var appliedUpdates = false;
7932 for (var _i = 0, updates_1 = updates; _i < updates_1.length; _i++) {
7933 var update = updates_1[_i];
7934 var entity = state.entities[update.id];
7935 if (!entity) {
7936 continue;
7937 }
7938 appliedUpdates = true;
7939 Object.assign(entity, update.changes);
7940 var newId = selectId(entity);
7941 if (update.id !== newId) {
7942 delete state.entities[update.id];
7943 state.entities[newId] = entity;
7944 }
7945 }
7946 if (appliedUpdates) {
7947 resortEntities(state);
7948 }
7949 }
7950 function upsertOneMutably(entity, state) {
7951 return upsertManyMutably([entity], state);
7952 }
7953 function upsertManyMutably(newEntities, state) {
7954 var _c = splitAddedUpdatedEntities(newEntities, selectId, state), added = _c[0], updated = _c[1];
7955 updateManyMutably(updated, state);
7956 addManyMutably(added, state);
7957 }
7958 function areArraysEqual(a, b) {
7959 if (a.length !== b.length) {
7960 return false;
7961 }
7962 for (var i = 0; i < a.length && i < b.length; i++) {
7963 if (a[i] === b[i]) {
7964 continue;
7965 }
7966 return false;
7967 }
7968 return true;
7969 }
7970 function merge(models, state) {
7971 models.forEach(function (model) {
7972 state.entities[selectId(model)] = model;
7973 });
7974 resortEntities(state);
7975 }
7976 function resortEntities(state) {
7977 var allEntities = Object.values(state.entities);
7978 allEntities.sort(sort);
7979 var newSortedIds = allEntities.map(selectId);
7980 var ids = state.ids;
7981 if (!areArraysEqual(ids, newSortedIds)) {
7982 state.ids = newSortedIds;
7983 }
7984 }
7985 return {
7986 removeOne: removeOne,
7987 removeMany: removeMany,
7988 removeAll: removeAll,
7989 addOne: createStateOperator(addOneMutably),
7990 updateOne: createStateOperator(updateOneMutably),
7991 upsertOne: createStateOperator(upsertOneMutably),
7992 setOne: createStateOperator(setOneMutably),
7993 setMany: createStateOperator(setManyMutably),
7994 setAll: createStateOperator(setAllMutably),
7995 addMany: createStateOperator(addManyMutably),
7996 updateMany: createStateOperator(updateManyMutably),
7997 upsertMany: createStateOperator(upsertManyMutably)
7998 };
7999 }
8000 // src/entities/create_adapter.ts
8001 function createEntityAdapter(options) {
8002 if (options === void 0) { options = {}; }
8003 var _c = __spreadValues({
8004 sortComparer: false,
8005 selectId: function (instance) { return instance.id; }
8006 }, options), selectId = _c.selectId, sortComparer = _c.sortComparer;
8007 var stateFactory = createInitialStateFactory();
8008 var selectorsFactory = createSelectorsFactory();
8009 var stateAdapter = sortComparer ? createSortedStateAdapter(selectId, sortComparer) : createUnsortedStateAdapter(selectId);
8010 return __spreadValues(__spreadValues(__spreadValues({
8011 selectId: selectId,
8012 sortComparer: sortComparer
8013 }, stateFactory), selectorsFactory), stateAdapter);
8014 }
8015 // src/nanoid.ts
8016 var urlAlphabet = "ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";
8017 var nanoid = function (size) {
8018 if (size === void 0) { size = 21; }
8019 var id = "";
8020 var i = size;
8021 while (i--) {
8022 id += urlAlphabet[Math.random() * 64 | 0];
8023 }
8024 return id;
8025 };
8026 // src/createAsyncThunk.ts
8027 var commonProperties = [
8028 "name",
8029 "message",
8030 "stack",
8031 "code"
8032 ];
8033 var RejectWithValue = /** @class */ (function () {
8034 function RejectWithValue(payload, meta) {
8035 this.payload = payload;
8036 this.meta = meta;
8037 }
8038 return RejectWithValue;
8039 }());
8040 var FulfillWithMeta = /** @class */ (function () {
8041 function FulfillWithMeta(payload, meta) {
8042 this.payload = payload;
8043 this.meta = meta;
8044 }
8045 return FulfillWithMeta;
8046 }());
8047 var miniSerializeError = function (value) {
8048 if (typeof value === "object" && value !== null) {
8049 var simpleError = {};
8050 for (var _i = 0, commonProperties_1 = commonProperties; _i < commonProperties_1.length; _i++) {
8051 var property = commonProperties_1[_i];
8052 if (typeof value[property] === "string") {
8053 simpleError[property] = value[property];
8054 }
8055 }
8056 return simpleError;
8057 }
8058 return { message: String(value) };
8059 };
8060 var createAsyncThunk = (function () {
8061 function createAsyncThunk2(typePrefix, payloadCreator, options) {
8062 var fulfilled = createAction(typePrefix + "/fulfilled", function (payload, requestId, arg, meta) { return ({
8063 payload: payload,
8064 meta: __spreadProps(__spreadValues({}, meta || {}), {
8065 arg: arg,
8066 requestId: requestId,
8067 requestStatus: "fulfilled"
8068 })
8069 }); });
8070 var pending = createAction(typePrefix + "/pending", function (requestId, arg, meta) { return ({
8071 payload: void 0,
8072 meta: __spreadProps(__spreadValues({}, meta || {}), {
8073 arg: arg,
8074 requestId: requestId,
8075 requestStatus: "pending"
8076 })
8077 }); });
8078 var rejected = createAction(typePrefix + "/rejected", function (error, requestId, arg, payload, meta) { return ({
8079 payload: payload,
8080 error: (options && options.serializeError || miniSerializeError)(error || "Rejected"),
8081 meta: __spreadProps(__spreadValues({}, meta || {}), {
8082 arg: arg,
8083 requestId: requestId,
8084 rejectedWithValue: !!payload,
8085 requestStatus: "rejected",
8086 aborted: (error == null ? void 0 : error.name) === "AbortError",
8087 condition: (error == null ? void 0 : error.name) === "ConditionError"
8088 })
8089 }); });
8090 var displayedWarning = false;
8091 var AC = typeof AbortController !== "undefined" ? AbortController : /** @class */ (function () {
8092 function class_1() {
8093 this.signal = {
8094 aborted: false,
8095 addEventListener: function () {
8096 },
8097 dispatchEvent: function () {
8098 return false;
8099 },
8100 onabort: function () {
8101 },
8102 removeEventListener: function () {
8103 },
8104 reason: void 0,
8105 throwIfAborted: function () {
8106 }
8107 };
8108 }
8109 class_1.prototype.abort = function () {
8110 if (true) {
8111 if (!displayedWarning) {
8112 displayedWarning = true;
8113 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'.");
8114 }
8115 }
8116 };
8117 return class_1;
8118 }());
8119 function actionCreator(arg) {
8120 return function (dispatch, getState, extra) {
8121 var requestId = (options == null ? void 0 : options.idGenerator) ? options.idGenerator(arg) : nanoid();
8122 var abortController = new AC();
8123 var abortReason;
8124 var started = false;
8125 function abort(reason) {
8126 abortReason = reason;
8127 abortController.abort();
8128 }
8129 var promise2 = function () {
8130 return __async(this, null, function () {
8131 var _a, _b, finalAction, conditionResult, abortedPromise, err_1, skipDispatch;
8132 return __generator(this, function (_c) {
8133 switch (_c.label) {
8134 case 0:
8135 _c.trys.push([0, 4, , 5]);
8136 conditionResult = (_a = options == null ? void 0 : options.condition) == null ? void 0 : _a.call(options, arg, { getState: getState, extra: extra });
8137 if (!isThenable(conditionResult)) return [3 /*break*/, 2];
8138 return [4 /*yield*/, conditionResult];
8139 case 1:
8140 conditionResult = _c.sent();
8141 _c.label = 2;
8142 case 2:
8143 if (conditionResult === false || abortController.signal.aborted) {
8144 throw {
8145 name: "ConditionError",
8146 message: "Aborted due to condition callback returning false."
8147 };
8148 }
8149 started = true;
8150 abortedPromise = new Promise(function (_, reject) { return abortController.signal.addEventListener("abort", function () { return reject({
8151 name: "AbortError",
8152 message: abortReason || "Aborted"
8153 }); }); });
8154 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 })));
8155 return [4 /*yield*/, Promise.race([
8156 abortedPromise,
8157 Promise.resolve(payloadCreator(arg, {
8158 dispatch: dispatch,
8159 getState: getState,
8160 extra: extra,
8161 requestId: requestId,
8162 signal: abortController.signal,
8163 abort: abort,
8164 rejectWithValue: function (value, meta) {
8165 return new RejectWithValue(value, meta);
8166 },
8167 fulfillWithValue: function (value, meta) {
8168 return new FulfillWithMeta(value, meta);
8169 }
8170 })).then(function (result) {
8171 if (result instanceof RejectWithValue) {
8172 throw result;
8173 }
8174 if (result instanceof FulfillWithMeta) {
8175 return fulfilled(result.payload, requestId, arg, result.meta);
8176 }
8177 return fulfilled(result, requestId, arg);
8178 })
8179 ])];
8180 case 3:
8181 finalAction = _c.sent();
8182 return [3 /*break*/, 5];
8183 case 4:
8184 err_1 = _c.sent();
8185 finalAction = err_1 instanceof RejectWithValue ? rejected(null, requestId, arg, err_1.payload, err_1.meta) : rejected(err_1, requestId, arg);
8186 return [3 /*break*/, 5];
8187 case 5:
8188 skipDispatch = options && !options.dispatchConditionRejection && rejected.match(finalAction) && finalAction.meta.condition;
8189 if (!skipDispatch) {
8190 dispatch(finalAction);
8191 }
8192 return [2 /*return*/, finalAction];
8193 }
8194 });
8195 });
8196 }();
8197 return Object.assign(promise2, {
8198 abort: abort,
8199 requestId: requestId,
8200 arg: arg,
8201 unwrap: function () {
8202 return promise2.then(unwrapResult);
8203 }
8204 });
8205 };
8206 }
8207 return Object.assign(actionCreator, {
8208 pending: pending,
8209 rejected: rejected,
8210 fulfilled: fulfilled,
8211 typePrefix: typePrefix
8212 });
8213 }
8214 createAsyncThunk2.withTypes = function () { return createAsyncThunk2; };
8215 return createAsyncThunk2;
8216 })();
8217 function unwrapResult(action) {
8218 if (action.meta && action.meta.rejectedWithValue) {
8219 throw action.payload;
8220 }
8221 if (action.error) {
8222 throw action.error;
8223 }
8224 return action.payload;
8225 }
8226 function isThenable(value) {
8227 return value !== null && typeof value === "object" && typeof value.then === "function";
8228 }
8229 // src/matchers.ts
8230 var matches = function (matcher, action) {
8231 if (hasMatchFunction(matcher)) {
8232 return matcher.match(action);
8233 }
8234 else {
8235 return matcher(action);
8236 }
8237 };
8238 function isAnyOf() {
8239 var matchers = [];
8240 for (var _i = 0; _i < arguments.length; _i++) {
8241 matchers[_i] = arguments[_i];
8242 }
8243 return function (action) {
8244 return matchers.some(function (matcher) { return matches(matcher, action); });
8245 };
8246 }
8247 function isAllOf() {
8248 var matchers = [];
8249 for (var _i = 0; _i < arguments.length; _i++) {
8250 matchers[_i] = arguments[_i];
8251 }
8252 return function (action) {
8253 return matchers.every(function (matcher) { return matches(matcher, action); });
8254 };
8255 }
8256 function hasExpectedRequestMetadata(action, validStatus) {
8257 if (!action || !action.meta)
8258 return false;
8259 var hasValidRequestId = typeof action.meta.requestId === "string";
8260 var hasValidRequestStatus = validStatus.indexOf(action.meta.requestStatus) > -1;
8261 return hasValidRequestId && hasValidRequestStatus;
8262 }
8263 function isAsyncThunkArray(a) {
8264 return typeof a[0] === "function" && "pending" in a[0] && "fulfilled" in a[0] && "rejected" in a[0];
8265 }
8266 function isPending() {
8267 var asyncThunks = [];
8268 for (var _i = 0; _i < arguments.length; _i++) {
8269 asyncThunks[_i] = arguments[_i];
8270 }
8271 if (asyncThunks.length === 0) {
8272 return function (action) { return hasExpectedRequestMetadata(action, ["pending"]); };
8273 }
8274 if (!isAsyncThunkArray(asyncThunks)) {
8275 return isPending()(asyncThunks[0]);
8276 }
8277 return function (action) {
8278 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.pending; });
8279 var combinedMatcher = isAnyOf.apply(void 0, matchers);
8280 return combinedMatcher(action);
8281 };
8282 }
8283 function isRejected() {
8284 var asyncThunks = [];
8285 for (var _i = 0; _i < arguments.length; _i++) {
8286 asyncThunks[_i] = arguments[_i];
8287 }
8288 if (asyncThunks.length === 0) {
8289 return function (action) { return hasExpectedRequestMetadata(action, ["rejected"]); };
8290 }
8291 if (!isAsyncThunkArray(asyncThunks)) {
8292 return isRejected()(asyncThunks[0]);
8293 }
8294 return function (action) {
8295 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.rejected; });
8296 var combinedMatcher = isAnyOf.apply(void 0, matchers);
8297 return combinedMatcher(action);
8298 };
8299 }
8300 function isRejectedWithValue() {
8301 var asyncThunks = [];
8302 for (var _i = 0; _i < arguments.length; _i++) {
8303 asyncThunks[_i] = arguments[_i];
8304 }
8305 var hasFlag = function (action) {
8306 return action && action.meta && action.meta.rejectedWithValue;
8307 };
8308 if (asyncThunks.length === 0) {
8309 return function (action) {
8310 var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
8311 return combinedMatcher(action);
8312 };
8313 }
8314 if (!isAsyncThunkArray(asyncThunks)) {
8315 return isRejectedWithValue()(asyncThunks[0]);
8316 }
8317 return function (action) {
8318 var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
8319 return combinedMatcher(action);
8320 };
8321 }
8322 function isFulfilled() {
8323 var asyncThunks = [];
8324 for (var _i = 0; _i < arguments.length; _i++) {
8325 asyncThunks[_i] = arguments[_i];
8326 }
8327 if (asyncThunks.length === 0) {
8328 return function (action) { return hasExpectedRequestMetadata(action, ["fulfilled"]); };
8329 }
8330 if (!isAsyncThunkArray(asyncThunks)) {
8331 return isFulfilled()(asyncThunks[0]);
8332 }
8333 return function (action) {
8334 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.fulfilled; });
8335 var combinedMatcher = isAnyOf.apply(void 0, matchers);
8336 return combinedMatcher(action);
8337 };
8338 }
8339 function isAsyncThunkAction() {
8340 var asyncThunks = [];
8341 for (var _i = 0; _i < arguments.length; _i++) {
8342 asyncThunks[_i] = arguments[_i];
8343 }
8344 if (asyncThunks.length === 0) {
8345 return function (action) { return hasExpectedRequestMetadata(action, ["pending", "fulfilled", "rejected"]); };
8346 }
8347 if (!isAsyncThunkArray(asyncThunks)) {
8348 return isAsyncThunkAction()(asyncThunks[0]);
8349 }
8350 return function (action) {
8351 var matchers = [];
8352 for (var _i = 0, asyncThunks_1 = asyncThunks; _i < asyncThunks_1.length; _i++) {
8353 var asyncThunk = asyncThunks_1[_i];
8354 matchers.push(asyncThunk.pending, asyncThunk.rejected, asyncThunk.fulfilled);
8355 }
8356 var combinedMatcher = isAnyOf.apply(void 0, matchers);
8357 return combinedMatcher(action);
8358 };
8359 }
8360 // src/listenerMiddleware/utils.ts
8361 var assertFunction = function (func, expected) {
8362 if (typeof func !== "function") {
8363 throw new TypeError(expected + " is not a function");
8364 }
8365 };
8366 var noop = function () {
8367 };
8368 var catchRejection = function (promise2, onError) {
8369 if (onError === void 0) { onError = noop; }
8370 promise2.catch(onError);
8371 return promise2;
8372 };
8373 var addAbortSignalListener = function (abortSignal, callback) {
8374 abortSignal.addEventListener("abort", callback, { once: true });
8375 return function () { return abortSignal.removeEventListener("abort", callback); };
8376 };
8377 var abortControllerWithReason = function (abortController, reason) {
8378 var signal = abortController.signal;
8379 if (signal.aborted) {
8380 return;
8381 }
8382 if (!("reason" in signal)) {
8383 Object.defineProperty(signal, "reason", {
8384 enumerable: true,
8385 value: reason,
8386 configurable: true,
8387 writable: true
8388 });
8389 }
8390 ;
8391 abortController.abort(reason);
8392 };
8393 // src/listenerMiddleware/exceptions.ts
8394 var task = "task";
8395 var listener = "listener";
8396 var completed = "completed";
8397 var cancelled = "cancelled";
8398 var taskCancelled = "task-" + cancelled;
8399 var taskCompleted = "task-" + completed;
8400 var listenerCancelled = listener + "-" + cancelled;
8401 var listenerCompleted = listener + "-" + completed;
8402 var TaskAbortError = /** @class */ (function () {
8403 function TaskAbortError(code) {
8404 this.code = code;
8405 this.name = "TaskAbortError";
8406 this.message = task + " " + cancelled + " (reason: " + code + ")";
8407 }
8408 return TaskAbortError;
8409 }());
8410 // src/listenerMiddleware/task.ts
8411 var validateActive = function (signal) {
8412 if (signal.aborted) {
8413 throw new TaskAbortError(signal.reason);
8414 }
8415 };
8416 function raceWithSignal(signal, promise2) {
8417 var cleanup = noop;
8418 return new Promise(function (resolve, reject) {
8419 var notifyRejection = function () { return reject(new TaskAbortError(signal.reason)); };
8420 if (signal.aborted) {
8421 notifyRejection();
8422 return;
8423 }
8424 cleanup = addAbortSignalListener(signal, notifyRejection);
8425 promise2.finally(function () { return cleanup(); }).then(resolve, reject);
8426 }).finally(function () {
8427 cleanup = noop;
8428 });
8429 }
8430 var runTask = function (task2, cleanUp) { return __async(void 0, null, function () {
8431 var value, error_1;
8432 return __generator(this, function (_c) {
8433 switch (_c.label) {
8434 case 0:
8435 _c.trys.push([0, 3, 4, 5]);
8436 return [4 /*yield*/, Promise.resolve()];
8437 case 1:
8438 _c.sent();
8439 return [4 /*yield*/, task2()];
8440 case 2:
8441 value = _c.sent();
8442 return [2 /*return*/, {
8443 status: "ok",
8444 value: value
8445 }];
8446 case 3:
8447 error_1 = _c.sent();
8448 return [2 /*return*/, {
8449 status: error_1 instanceof TaskAbortError ? "cancelled" : "rejected",
8450 error: error_1
8451 }];
8452 case 4:
8453 cleanUp == null ? void 0 : cleanUp();
8454 return [7 /*endfinally*/];
8455 case 5: return [2 /*return*/];
8456 }
8457 });
8458 }); };
8459 var createPause = function (signal) {
8460 return function (promise2) {
8461 return catchRejection(raceWithSignal(signal, promise2).then(function (output) {
8462 validateActive(signal);
8463 return output;
8464 }));
8465 };
8466 };
8467 var createDelay = function (signal) {
8468 var pause = createPause(signal);
8469 return function (timeoutMs) {
8470 return pause(new Promise(function (resolve) { return setTimeout(resolve, timeoutMs); }));
8471 };
8472 };
8473 // src/listenerMiddleware/index.ts
8474 var assign = Object.assign;
8475 var INTERNAL_NIL_TOKEN = {};
8476 var alm = "listenerMiddleware";
8477 var createFork = function (parentAbortSignal, parentBlockingPromises) {
8478 var linkControllers = function (controller) { return addAbortSignalListener(parentAbortSignal, function () { return abortControllerWithReason(controller, parentAbortSignal.reason); }); };
8479 return function (taskExecutor, opts) {
8480 assertFunction(taskExecutor, "taskExecutor");
8481 var childAbortController = new AbortController();
8482 linkControllers(childAbortController);
8483 var result = runTask(function () { return __async(void 0, null, function () {
8484 var result2;
8485 return __generator(this, function (_c) {
8486 switch (_c.label) {
8487 case 0:
8488 validateActive(parentAbortSignal);
8489 validateActive(childAbortController.signal);
8490 return [4 /*yield*/, taskExecutor({
8491 pause: createPause(childAbortController.signal),
8492 delay: createDelay(childAbortController.signal),
8493 signal: childAbortController.signal
8494 })];
8495 case 1:
8496 result2 = _c.sent();
8497 validateActive(childAbortController.signal);
8498 return [2 /*return*/, result2];
8499 }
8500 });
8501 }); }, function () { return abortControllerWithReason(childAbortController, taskCompleted); });
8502 if (opts == null ? void 0 : opts.autoJoin) {
8503 parentBlockingPromises.push(result);
8504 }
8505 return {
8506 result: createPause(parentAbortSignal)(result),
8507 cancel: function () {
8508 abortControllerWithReason(childAbortController, taskCancelled);
8509 }
8510 };
8511 };
8512 };
8513 var createTakePattern = function (startListening, signal) {
8514 var take = function (predicate, timeout) { return __async(void 0, null, function () {
8515 var unsubscribe, tuplePromise, promises, output;
8516 return __generator(this, function (_c) {
8517 switch (_c.label) {
8518 case 0:
8519 validateActive(signal);
8520 unsubscribe = function () {
8521 };
8522 tuplePromise = new Promise(function (resolve, reject) {
8523 var stopListening = startListening({
8524 predicate: predicate,
8525 effect: function (action, listenerApi) {
8526 listenerApi.unsubscribe();
8527 resolve([
8528 action,
8529 listenerApi.getState(),
8530 listenerApi.getOriginalState()
8531 ]);
8532 }
8533 });
8534 unsubscribe = function () {
8535 stopListening();
8536 reject();
8537 };
8538 });
8539 promises = [
8540 tuplePromise
8541 ];
8542 if (timeout != null) {
8543 promises.push(new Promise(function (resolve) { return setTimeout(resolve, timeout, null); }));
8544 }
8545 _c.label = 1;
8546 case 1:
8547 _c.trys.push([1, , 3, 4]);
8548 return [4 /*yield*/, raceWithSignal(signal, Promise.race(promises))];
8549 case 2:
8550 output = _c.sent();
8551 validateActive(signal);
8552 return [2 /*return*/, output];
8553 case 3:
8554 unsubscribe();
8555 return [7 /*endfinally*/];
8556 case 4: return [2 /*return*/];
8557 }
8558 });
8559 }); };
8560 return function (predicate, timeout) { return catchRejection(take(predicate, timeout)); };
8561 };
8562 var getListenerEntryPropsFrom = function (options) {
8563 var type = options.type, actionCreator = options.actionCreator, matcher = options.matcher, predicate = options.predicate, effect = options.effect;
8564 if (type) {
8565 predicate = createAction(type).match;
8566 }
8567 else if (actionCreator) {
8568 type = actionCreator.type;
8569 predicate = actionCreator.match;
8570 }
8571 else if (matcher) {
8572 predicate = matcher;
8573 }
8574 else if (predicate) {
8575 }
8576 else {
8577 throw new Error("Creating or removing a listener requires one of the known fields for matching an action");
8578 }
8579 assertFunction(effect, "options.listener");
8580 return { predicate: predicate, type: type, effect: effect };
8581 };
8582 var createListenerEntry = function (options) {
8583 var _c = getListenerEntryPropsFrom(options), type = _c.type, predicate = _c.predicate, effect = _c.effect;
8584 var id = nanoid();
8585 var entry = {
8586 id: id,
8587 effect: effect,
8588 type: type,
8589 predicate: predicate,
8590 pending: new Set(),
8591 unsubscribe: function () {
8592 throw new Error("Unsubscribe not initialized");
8593 }
8594 };
8595 return entry;
8596 };
8597 var cancelActiveListeners = function (entry) {
8598 entry.pending.forEach(function (controller) {
8599 abortControllerWithReason(controller, listenerCancelled);
8600 });
8601 };
8602 var createClearListenerMiddleware = function (listenerMap) {
8603 return function () {
8604 listenerMap.forEach(cancelActiveListeners);
8605 listenerMap.clear();
8606 };
8607 };
8608 var safelyNotifyError = function (errorHandler, errorToNotify, errorInfo) {
8609 try {
8610 errorHandler(errorToNotify, errorInfo);
8611 }
8612 catch (errorHandlerError) {
8613 setTimeout(function () {
8614 throw errorHandlerError;
8615 }, 0);
8616 }
8617 };
8618 var addListener = createAction(alm + "/add");
8619 var clearAllListeners = createAction(alm + "/removeAll");
8620 var removeListener = createAction(alm + "/remove");
8621 var defaultErrorHandler = function () {
8622 var args = [];
8623 for (var _i = 0; _i < arguments.length; _i++) {
8624 args[_i] = arguments[_i];
8625 }
8626 console.error.apply(console, __spreadArray([alm + "/error"], args));
8627 };
8628 function createListenerMiddleware(middlewareOptions) {
8629 var _this = this;
8630 if (middlewareOptions === void 0) { middlewareOptions = {}; }
8631 var listenerMap = new Map();
8632 var extra = middlewareOptions.extra, _c = middlewareOptions.onError, onError = _c === void 0 ? defaultErrorHandler : _c;
8633 assertFunction(onError, "onError");
8634 var insertEntry = function (entry) {
8635 entry.unsubscribe = function () { return listenerMap.delete(entry.id); };
8636 listenerMap.set(entry.id, entry);
8637 return function (cancelOptions) {
8638 entry.unsubscribe();
8639 if (cancelOptions == null ? void 0 : cancelOptions.cancelActive) {
8640 cancelActiveListeners(entry);
8641 }
8642 };
8643 };
8644 var findListenerEntry = function (comparator) {
8645 for (var _i = 0, _c = Array.from(listenerMap.values()); _i < _c.length; _i++) {
8646 var entry = _c[_i];
8647 if (comparator(entry)) {
8648 return entry;
8649 }
8650 }
8651 return void 0;
8652 };
8653 var startListening = function (options) {
8654 var entry = findListenerEntry(function (existingEntry) { return existingEntry.effect === options.effect; });
8655 if (!entry) {
8656 entry = createListenerEntry(options);
8657 }
8658 return insertEntry(entry);
8659 };
8660 var stopListening = function (options) {
8661 var _c = getListenerEntryPropsFrom(options), type = _c.type, effect = _c.effect, predicate = _c.predicate;
8662 var entry = findListenerEntry(function (entry2) {
8663 var matchPredicateOrType = typeof type === "string" ? entry2.type === type : entry2.predicate === predicate;
8664 return matchPredicateOrType && entry2.effect === effect;
8665 });
8666 if (entry) {
8667 entry.unsubscribe();
8668 if (options.cancelActive) {
8669 cancelActiveListeners(entry);
8670 }
8671 }
8672 return !!entry;
8673 };
8674 var notifyListener = function (entry, action, api, getOriginalState) { return __async(_this, null, function () {
8675 var internalTaskController, take, autoJoinPromises, listenerError_1;
8676 return __generator(this, function (_c) {
8677 switch (_c.label) {
8678 case 0:
8679 internalTaskController = new AbortController();
8680 take = createTakePattern(startListening, internalTaskController.signal);
8681 autoJoinPromises = [];
8682 _c.label = 1;
8683 case 1:
8684 _c.trys.push([1, 3, 4, 6]);
8685 entry.pending.add(internalTaskController);
8686 return [4 /*yield*/, Promise.resolve(entry.effect(action, assign({}, api, {
8687 getOriginalState: getOriginalState,
8688 condition: function (predicate, timeout) { return take(predicate, timeout).then(Boolean); },
8689 take: take,
8690 delay: createDelay(internalTaskController.signal),
8691 pause: createPause(internalTaskController.signal),
8692 extra: extra,
8693 signal: internalTaskController.signal,
8694 fork: createFork(internalTaskController.signal, autoJoinPromises),
8695 unsubscribe: entry.unsubscribe,
8696 subscribe: function () {
8697 listenerMap.set(entry.id, entry);
8698 },
8699 cancelActiveListeners: function () {
8700 entry.pending.forEach(function (controller, _, set) {
8701 if (controller !== internalTaskController) {
8702 abortControllerWithReason(controller, listenerCancelled);
8703 set.delete(controller);
8704 }
8705 });
8706 }
8707 })))];
8708 case 2:
8709 _c.sent();
8710 return [3 /*break*/, 6];
8711 case 3:
8712 listenerError_1 = _c.sent();
8713 if (!(listenerError_1 instanceof TaskAbortError)) {
8714 safelyNotifyError(onError, listenerError_1, {
8715 raisedBy: "effect"
8716 });
8717 }
8718 return [3 /*break*/, 6];
8719 case 4: return [4 /*yield*/, Promise.allSettled(autoJoinPromises)];
8720 case 5:
8721 _c.sent();
8722 abortControllerWithReason(internalTaskController, listenerCompleted);
8723 entry.pending.delete(internalTaskController);
8724 return [7 /*endfinally*/];
8725 case 6: return [2 /*return*/];
8726 }
8727 });
8728 }); };
8729 var clearListenerMiddleware = createClearListenerMiddleware(listenerMap);
8730 var middleware = function (api) { return function (next) { return function (action) {
8731 if (!isAction(action)) {
8732 return next(action);
8733 }
8734 if (addListener.match(action)) {
8735 return startListening(action.payload);
8736 }
8737 if (clearAllListeners.match(action)) {
8738 clearListenerMiddleware();
8739 return;
8740 }
8741 if (removeListener.match(action)) {
8742 return stopListening(action.payload);
8743 }
8744 var originalState = api.getState();
8745 var getOriginalState = function () {
8746 if (originalState === INTERNAL_NIL_TOKEN) {
8747 throw new Error(alm + ": getOriginalState can only be called synchronously");
8748 }
8749 return originalState;
8750 };
8751 var result;
8752 try {
8753 result = next(action);
8754 if (listenerMap.size > 0) {
8755 var currentState = api.getState();
8756 var listenerEntries = Array.from(listenerMap.values());
8757 for (var _i = 0, listenerEntries_1 = listenerEntries; _i < listenerEntries_1.length; _i++) {
8758 var entry = listenerEntries_1[_i];
8759 var runListener = false;
8760 try {
8761 runListener = entry.predicate(action, currentState, originalState);
8762 }
8763 catch (predicateError) {
8764 runListener = false;
8765 safelyNotifyError(onError, predicateError, {
8766 raisedBy: "predicate"
8767 });
8768 }
8769 if (!runListener) {
8770 continue;
8771 }
8772 notifyListener(entry, action, api, getOriginalState);
8773 }
8774 }
8775 }
8776 finally {
8777 originalState = INTERNAL_NIL_TOKEN;
8778 }
8779 return result;
8780 }; }; };
8781 return {
8782 middleware: middleware,
8783 startListening: startListening,
8784 stopListening: stopListening,
8785 clearListeners: clearListenerMiddleware
8786 };
8787 }
8788 // src/autoBatchEnhancer.ts
8789 var SHOULD_AUTOBATCH = "RTK_autoBatch";
8790 var prepareAutoBatched = function () { return function (payload) {
8791 var _c;
8792 return ({
8793 payload: payload,
8794 meta: (_c = {}, _c[SHOULD_AUTOBATCH] = true, _c)
8795 });
8796 }; };
8797 var promise;
8798 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 () {
8799 throw err;
8800 }, 0); }); };
8801 var createQueueWithTimer = function (timeout) {
8802 return function (notify) {
8803 setTimeout(notify, timeout);
8804 };
8805 };
8806 var rAF = typeof window !== "undefined" && window.requestAnimationFrame ? window.requestAnimationFrame : createQueueWithTimer(10);
8807 var autoBatchEnhancer = function (options) {
8808 if (options === void 0) { options = { type: "raf" }; }
8809 return function (next) { return function () {
8810 var args = [];
8811 for (var _i = 0; _i < arguments.length; _i++) {
8812 args[_i] = arguments[_i];
8813 }
8814 var store = next.apply(void 0, args);
8815 var notifying = true;
8816 var shouldNotifyAtEndOfTick = false;
8817 var notificationQueued = false;
8818 var listeners = new Set();
8819 var queueCallback = options.type === "tick" ? queueMicrotaskShim : options.type === "raf" ? rAF : options.type === "callback" ? options.queueNotification : createQueueWithTimer(options.timeout);
8820 var notifyListeners = function () {
8821 notificationQueued = false;
8822 if (shouldNotifyAtEndOfTick) {
8823 shouldNotifyAtEndOfTick = false;
8824 listeners.forEach(function (l) { return l(); });
8825 }
8826 };
8827 return Object.assign({}, store, {
8828 subscribe: function (listener2) {
8829 var wrappedListener = function () { return notifying && listener2(); };
8830 var unsubscribe = store.subscribe(wrappedListener);
8831 listeners.add(listener2);
8832 return function () {
8833 unsubscribe();
8834 listeners.delete(listener2);
8835 };
8836 },
8837 dispatch: function (action) {
8838 var _a;
8839 try {
8840 notifying = !((_a = action == null ? void 0 : action.meta) == null ? void 0 : _a[SHOULD_AUTOBATCH]);
8841 shouldNotifyAtEndOfTick = !notifying;
8842 if (shouldNotifyAtEndOfTick) {
8843 if (!notificationQueued) {
8844 notificationQueued = true;
8845 queueCallback(notifyListeners);
8846 }
8847 }
8848 return store.dispatch(action);
8849 }
8850 finally {
8851 notifying = true;
8852 }
8853 }
8854 });
8855 }; };
8856 };
8857 // src/index.ts
8858 (0,immer__WEBPACK_IMPORTED_MODULE_0__.enableES5)();
8859
8860 //# sourceMappingURL=redux-toolkit.esm.js.map
8861
8862 /***/ }),
8863
8864 /***/ "../node_modules/immer/dist/immer.esm.mjs":
8865 /*!************************************************!*\
8866 !*** ../node_modules/immer/dist/immer.esm.mjs ***!
8867 \************************************************/
8868 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
8869
8870 "use strict";
8871 __webpack_require__.r(__webpack_exports__);
8872 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8873 /* harmony export */ Immer: () => (/* binding */ un),
8874 /* harmony export */ applyPatches: () => (/* binding */ pn),
8875 /* harmony export */ castDraft: () => (/* binding */ K),
8876 /* harmony export */ castImmutable: () => (/* binding */ $),
8877 /* harmony export */ createDraft: () => (/* binding */ ln),
8878 /* harmony export */ current: () => (/* binding */ R),
8879 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
8880 /* harmony export */ enableAllPlugins: () => (/* binding */ J),
8881 /* harmony export */ enableES5: () => (/* binding */ F),
8882 /* harmony export */ enableMapSet: () => (/* binding */ C),
8883 /* harmony export */ enablePatches: () => (/* binding */ T),
8884 /* harmony export */ finishDraft: () => (/* binding */ dn),
8885 /* harmony export */ freeze: () => (/* binding */ d),
8886 /* harmony export */ immerable: () => (/* binding */ L),
8887 /* harmony export */ isDraft: () => (/* binding */ r),
8888 /* harmony export */ isDraftable: () => (/* binding */ t),
8889 /* harmony export */ nothing: () => (/* binding */ H),
8890 /* harmony export */ original: () => (/* binding */ e),
8891 /* harmony export */ produce: () => (/* binding */ fn),
8892 /* harmony export */ produceWithPatches: () => (/* binding */ cn),
8893 /* harmony export */ setAutoFreeze: () => (/* binding */ sn),
8894 /* harmony export */ setUseProxies: () => (/* binding */ vn)
8895 /* harmony export */ });
8896 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
8897 }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);
8898 //# sourceMappingURL=immer.esm.js.map
8899
8900
8901 /***/ }),
8902
8903 /***/ "../node_modules/mixpanel-browser/dist/mixpanel.module.js":
8904 /*!****************************************************************!*\
8905 !*** ../node_modules/mixpanel-browser/dist/mixpanel.module.js ***!
8906 \****************************************************************/
8907 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8908
8909 "use strict";
8910 __webpack_require__.r(__webpack_exports__);
8911 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8912 /* harmony export */ "default": () => (/* binding */ mixpanel)
8913 /* harmony export */ });
8914 // since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
8915 var win;
8916 if (typeof(window) === 'undefined') {
8917 var loc = {
8918 hostname: ''
8919 };
8920 win = {
8921 crypto: {randomUUID: function() {throw Error('unsupported');}},
8922 navigator: { userAgent: '', onLine: true },
8923 document: {
8924 createElement: function() { return {}; },
8925 location: loc,
8926 referrer: ''
8927 },
8928 screen: { width: 0, height: 0 },
8929 location: loc,
8930 addEventListener: function() {},
8931 removeEventListener: function() {}
8932 };
8933 } else {
8934 win = window;
8935 }
8936
8937 function _array_like_to_array(arr, len) {
8938 if (len == null || len > arr.length) len = arr.length;
8939 for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
8940 return arr2;
8941 }
8942 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
8943 try {
8944 var info = gen[key](arg);
8945 var value = info.value;
8946 } catch (error) {
8947 reject(error);
8948 return;
8949 }
8950 if (info.done) {
8951 resolve(value);
8952 } else {
8953 Promise.resolve(value).then(_next, _throw);
8954 }
8955 }
8956 function _async_to_generator(fn) {
8957 return function() {
8958 var self = this, args = arguments;
8959 return new Promise(function(resolve, reject) {
8960 var gen = fn.apply(self, args);
8961 function _next(value) {
8962 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
8963 }
8964 function _throw(err) {
8965 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
8966 }
8967 _next(undefined);
8968 });
8969 };
8970 }
8971 function _construct(Parent, args, Class) {
8972 if (_is_native_reflect_construct()) {
8973 _construct = Reflect.construct;
8974 } else {
8975 _construct = function construct(Parent, args, Class) {
8976 var a = [
8977 null
8978 ];
8979 a.push.apply(a, args);
8980 var Constructor = Function.bind.apply(Parent, a);
8981 var instance = new Constructor();
8982 if (Class) _set_prototype_of(instance, Class.prototype);
8983 return instance;
8984 };
8985 }
8986 return _construct.apply(null, arguments);
8987 }
8988 function _defineProperties(target, props) {
8989 for(var i = 0; i < props.length; i++){
8990 var descriptor = props[i];
8991 descriptor.enumerable = descriptor.enumerable || false;
8992 descriptor.configurable = true;
8993 if ("value" in descriptor) descriptor.writable = true;
8994 Object.defineProperty(target, descriptor.key, descriptor);
8995 }
8996 }
8997 function _create_class(Constructor, protoProps, staticProps) {
8998 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
8999 return Constructor;
9000 }
9001 function _extends() {
9002 _extends = Object.assign || function(target) {
9003 for(var i = 1; i < arguments.length; i++){
9004 var source = arguments[i];
9005 for(var key in source){
9006 if (Object.prototype.hasOwnProperty.call(source, key)) {
9007 target[key] = source[key];
9008 }
9009 }
9010 }
9011 return target;
9012 };
9013 return _extends.apply(this, arguments);
9014 }
9015 function _get_prototype_of(o) {
9016 _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
9017 return o.__proto__ || Object.getPrototypeOf(o);
9018 };
9019 return _get_prototype_of(o);
9020 }
9021 function _inherits(subClass, superClass) {
9022 if (typeof superClass !== "function" && superClass !== null) {
9023 throw new TypeError("Super expression must either be null or a function");
9024 }
9025 subClass.prototype = Object.create(superClass && superClass.prototype, {
9026 constructor: {
9027 value: subClass,
9028 writable: true,
9029 configurable: true
9030 }
9031 });
9032 if (superClass) _set_prototype_of(subClass, superClass);
9033 }
9034 function _instanceof(left, right) {
9035 if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
9036 return !!right[Symbol.hasInstance](left);
9037 } else {
9038 return left instanceof right;
9039 }
9040 }
9041 function _is_native_function(fn) {
9042 return Function.toString.call(fn).indexOf("[native code]") !== -1;
9043 }
9044 function _object_without_properties_loose(source, excluded) {
9045 if (source == null) return {};
9046 var target = {};
9047 var sourceKeys = Object.keys(source);
9048 var key, i;
9049 for(i = 0; i < sourceKeys.length; i++){
9050 key = sourceKeys[i];
9051 if (excluded.indexOf(key) >= 0) continue;
9052 target[key] = source[key];
9053 }
9054 return target;
9055 }
9056 function _set_prototype_of(o, p) {
9057 _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
9058 o.__proto__ = p;
9059 return o;
9060 };
9061 return _set_prototype_of(o, p);
9062 }
9063 function _type_of(obj) {
9064 "@swc/helpers - typeof";
9065 return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
9066 }
9067 function _unsupported_iterable_to_array(o, minLen) {
9068 if (!o) return;
9069 if (typeof o === "string") return _array_like_to_array(o, minLen);
9070 var n = Object.prototype.toString.call(o).slice(8, -1);
9071 if (n === "Object" && o.constructor) n = o.constructor.name;
9072 if (n === "Map" || n === "Set") return Array.from(n);
9073 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
9074 }
9075 function _wrap_native_super(Class) {
9076 var _cache = typeof Map === "function" ? new Map() : undefined;
9077 _wrap_native_super = function wrapNativeSuper(Class) {
9078 if (Class === null || !_is_native_function(Class)) return Class;
9079 if (typeof Class !== "function") {
9080 throw new TypeError("Super expression must either be null or a function");
9081 }
9082 if (typeof _cache !== "undefined") {
9083 if (_cache.has(Class)) return _cache.get(Class);
9084 _cache.set(Class, Wrapper);
9085 }
9086 function Wrapper() {
9087 return _construct(Class, arguments, _get_prototype_of(this).constructor);
9088 }
9089 Wrapper.prototype = Object.create(Class.prototype, {
9090 constructor: {
9091 value: Wrapper,
9092 enumerable: false,
9093 writable: true,
9094 configurable: true
9095 }
9096 });
9097 return _set_prototype_of(Wrapper, Class);
9098 };
9099 return _wrap_native_super(Class);
9100 }
9101 function _is_native_reflect_construct() {
9102 try {
9103 var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
9104 } catch (_) {}
9105 return (_is_native_reflect_construct = function() {
9106 return !!result;
9107 })();
9108 }
9109 function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
9110 var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
9111 if (it) return (it = it.call(o)).next.bind(it);
9112 if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike) {
9113 if (it) o = it;
9114 var i = 0;
9115 return function() {
9116 if (i >= o.length) {
9117 return {
9118 done: true
9119 };
9120 }
9121 return {
9122 done: false,
9123 value: o[i++]
9124 };
9125 };
9126 }
9127 throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
9128 }
9129 function _ts_generator(thisArg, body) {
9130 var f, y, t, g, _ = {
9131 label: 0,
9132 sent: function() {
9133 if (t[0] & 1) throw t[1];
9134 return t[1];
9135 },
9136 trys: [],
9137 ops: []
9138 };
9139 return g = {
9140 next: verb(0),
9141 "throw": verb(1),
9142 "return": verb(2)
9143 }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
9144 return this;
9145 }), g;
9146 function verb(n) {
9147 return function(v) {
9148 return step([
9149 n,
9150 v
9151 ]);
9152 };
9153 }
9154 function step(op) {
9155 if (f) throw new TypeError("Generator is already executing.");
9156 while(_)try {
9157 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;
9158 if (y = 0, t) op = [
9159 op[0] & 2,
9160 t.value
9161 ];
9162 switch(op[0]){
9163 case 0:
9164 case 1:
9165 t = op;
9166 break;
9167 case 4:
9168 _.label++;
9169 return {
9170 value: op[1],
9171 done: false
9172 };
9173 case 5:
9174 _.label++;
9175 y = op[1];
9176 op = [
9177 0
9178 ];
9179 continue;
9180 case 7:
9181 op = _.ops.pop();
9182 _.trys.pop();
9183 continue;
9184 default:
9185 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
9186 _ = 0;
9187 continue;
9188 }
9189 if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
9190 _.label = op[1];
9191 break;
9192 }
9193 if (op[0] === 6 && _.label < t[1]) {
9194 _.label = t[1];
9195 t = op;
9196 break;
9197 }
9198 if (t && _.label < t[2]) {
9199 _.label = t[2];
9200 _.ops.push(op);
9201 break;
9202 }
9203 if (t[2]) _.ops.pop();
9204 _.trys.pop();
9205 continue;
9206 }
9207 op = body.call(thisArg, _);
9208 } catch (e) {
9209 op = [
9210 6,
9211 e
9212 ];
9213 y = 0;
9214 } finally{
9215 f = t = 0;
9216 }
9217 if (op[0] & 5) throw op[1];
9218 return {
9219 value: op[0] ? op[1] : void 0,
9220 done: true
9221 };
9222 }
9223 }
9224 function _ts_values(o) {
9225 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
9226 if (m) return m.call(o);
9227 if (o && typeof o.length === "number") return {
9228 next: function() {
9229 if (o && i >= o.length) o = void 0;
9230 return {
9231 value: o && o[i++],
9232 done: !o
9233 };
9234 }
9235 };
9236 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
9237 }
9238 var __defProp = Object.defineProperty;
9239 var __defNormalProp = function(obj, key, value) {
9240 return key in obj ? __defProp(obj, key, {
9241 enumerable: true,
9242 configurable: true,
9243 writable: true,
9244 value: value
9245 }) : obj[key] = value;
9246 };
9247 var __publicField = function(obj, key, value) {
9248 return __defNormalProp(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
9249 };
9250 var _a;
9251 var __defProp$1 = Object.defineProperty;
9252 var __defNormalProp$1 = function(obj, key, value) {
9253 return key in obj ? __defProp$1(obj, key, {
9254 enumerable: true,
9255 configurable: true,
9256 writable: true,
9257 value: value
9258 }) : obj[key] = value;
9259 };
9260 var __publicField$1 = function(obj, key, value) {
9261 return __defNormalProp$1(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
9262 };
9263 var NodeType$3 = /* @__PURE__ */ function(NodeType2) {
9264 NodeType2[NodeType2["Document"] = 0] = "Document";
9265 NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
9266 NodeType2[NodeType2["Element"] = 2] = "Element";
9267 NodeType2[NodeType2["Text"] = 3] = "Text";
9268 NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
9269 NodeType2[NodeType2["Comment"] = 5] = "Comment";
9270 return NodeType2;
9271 }(NodeType$3 || {});
9272 var testableAccessors$1 = {
9273 Node: [
9274 "childNodes",
9275 "parentNode",
9276 "parentElement",
9277 "textContent"
9278 ],
9279 ShadowRoot: [
9280 "host",
9281 "styleSheets"
9282 ],
9283 Element: [
9284 "shadowRoot",
9285 "querySelector",
9286 "querySelectorAll"
9287 ],
9288 MutationObserver: []
9289 };
9290 var testableMethods$1 = {
9291 Node: [
9292 "contains",
9293 "getRootNode"
9294 ],
9295 ShadowRoot: [
9296 "getSelection"
9297 ],
9298 Element: [],
9299 MutationObserver: [
9300 "constructor"
9301 ]
9302 };
9303 var untaintedBasePrototype$1 = {};
9304 var isAngularZonePresent$1 = function() {
9305 return !!globalThis.Zone;
9306 };
9307 function getUntaintedPrototype$1(key) {
9308 if (untaintedBasePrototype$1[key]) return untaintedBasePrototype$1[key];
9309 var defaultObj = globalThis[key];
9310 var defaultPrototype = defaultObj.prototype;
9311 var accessorNames = key in testableAccessors$1 ? testableAccessors$1[key] : void 0;
9312 var isUntaintedAccessors = Boolean(accessorNames && // @ts-expect-error 2345
9313 accessorNames.every(function(accessor) {
9314 var _a2, _b;
9315 return Boolean((_b = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b.toString().includes("[native code]"));
9316 }));
9317 var methodNames = key in testableMethods$1 ? testableMethods$1[key] : void 0;
9318 var isUntaintedMethods = Boolean(methodNames && methodNames.every(// @ts-expect-error 2345
9319 function(method) {
9320 var _a2;
9321 return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
9322 }));
9323 if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent$1()) {
9324 untaintedBasePrototype$1[key] = defaultObj.prototype;
9325 return defaultObj.prototype;
9326 }
9327 try {
9328 var iframeEl = document.createElement("iframe");
9329 document.body.appendChild(iframeEl);
9330 var win = iframeEl.contentWindow;
9331 if (!win) return defaultObj.prototype;
9332 var untaintedObject = win[key].prototype;
9333 document.body.removeChild(iframeEl);
9334 if (!untaintedObject) return defaultPrototype;
9335 return untaintedBasePrototype$1[key] = untaintedObject;
9336 } catch (e) {
9337 return defaultPrototype;
9338 }
9339 }
9340 var untaintedAccessorCache$1 = {};
9341 function getUntaintedAccessor$1(key, instance, accessor) {
9342 var _a2;
9343 var cacheKey = key + "." + String(accessor);
9344 if (untaintedAccessorCache$1[cacheKey]) return untaintedAccessorCache$1[cacheKey].call(instance);
9345 var untaintedPrototype = getUntaintedPrototype$1(key);
9346 var untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(untaintedPrototype, accessor)) == null ? void 0 : _a2.get;
9347 if (!untaintedAccessor) return instance[accessor];
9348 untaintedAccessorCache$1[cacheKey] = untaintedAccessor;
9349 return untaintedAccessor.call(instance);
9350 }
9351 var untaintedMethodCache$1 = {};
9352 function getUntaintedMethod$1(key, instance, method) {
9353 var cacheKey = key + "." + String(method);
9354 if (untaintedMethodCache$1[cacheKey]) return untaintedMethodCache$1[cacheKey].bind(instance);
9355 var untaintedPrototype = getUntaintedPrototype$1(key);
9356 var untaintedMethod = untaintedPrototype[method];
9357 if (typeof untaintedMethod !== "function") return instance[method];
9358 untaintedMethodCache$1[cacheKey] = untaintedMethod;
9359 return untaintedMethod.bind(instance);
9360 }
9361 function childNodes$1(n2) {
9362 return getUntaintedAccessor$1("Node", n2, "childNodes");
9363 }
9364 function parentNode$1(n2) {
9365 return getUntaintedAccessor$1("Node", n2, "parentNode");
9366 }
9367 function parentElement$1(n2) {
9368 return getUntaintedAccessor$1("Node", n2, "parentElement");
9369 }
9370 function textContent$1(n2) {
9371 return getUntaintedAccessor$1("Node", n2, "textContent");
9372 }
9373 function contains$1(n2, other) {
9374 return getUntaintedMethod$1("Node", n2, "contains")(other);
9375 }
9376 function getRootNode$1(n2) {
9377 return getUntaintedMethod$1("Node", n2, "getRootNode")();
9378 }
9379 function host$1(n2) {
9380 if (!n2 || !("host" in n2)) return null;
9381 return getUntaintedAccessor$1("ShadowRoot", n2, "host");
9382 }
9383 function styleSheets$1(n2) {
9384 return n2.styleSheets;
9385 }
9386 function shadowRoot$1(n2) {
9387 if (!n2 || !("shadowRoot" in n2)) return null;
9388 return getUntaintedAccessor$1("Element", n2, "shadowRoot");
9389 }
9390 function querySelector$1(n2, selectors) {
9391 return getUntaintedAccessor$1("Element", n2, "querySelector")(selectors);
9392 }
9393 function querySelectorAll$1(n2, selectors) {
9394 return getUntaintedAccessor$1("Element", n2, "querySelectorAll")(selectors);
9395 }
9396 function mutationObserverCtor$1() {
9397 return getUntaintedPrototype$1("MutationObserver").constructor;
9398 }
9399 function patch$1(source, name, replacement) {
9400 try {
9401 if (!(name in source)) {
9402 return function() {};
9403 }
9404 var original = source[name];
9405 var wrapped = replacement(original);
9406 if (typeof wrapped === "function") {
9407 wrapped.prototype = wrapped.prototype || {};
9408 Object.defineProperties(wrapped, {
9409 __rrweb_original__: {
9410 enumerable: false,
9411 value: original
9412 }
9413 });
9414 }
9415 source[name] = wrapped;
9416 return function() {
9417 source[name] = original;
9418 };
9419 } catch (e) {
9420 return function() {};
9421 }
9422 }
9423 var index$1 = {
9424 childNodes: childNodes$1,
9425 parentNode: parentNode$1,
9426 parentElement: parentElement$1,
9427 textContent: textContent$1,
9428 contains: contains$1,
9429 getRootNode: getRootNode$1,
9430 host: host$1,
9431 styleSheets: styleSheets$1,
9432 shadowRoot: shadowRoot$1,
9433 querySelector: querySelector$1,
9434 querySelectorAll: querySelectorAll$1,
9435 mutationObserver: mutationObserverCtor$1,
9436 patch: patch$1
9437 };
9438 function isElement(n2) {
9439 return n2.nodeType === n2.ELEMENT_NODE;
9440 }
9441 function isShadowRoot(n2) {
9442 var hostEl = // anchor and textarea elements also have a `host` property
9443 // but only shadow roots have a `mode` property
9444 n2 && "host" in n2 && "mode" in n2 && index$1.host(n2) || null;
9445 return Boolean(hostEl && "shadowRoot" in hostEl && index$1.shadowRoot(hostEl) === n2);
9446 }
9447 function isNativeShadowDom(shadowRoot2) {
9448 return Object.prototype.toString.call(shadowRoot2) === "[object ShadowRoot]";
9449 }
9450 function fixBrowserCompatibilityIssuesInCSS(cssText) {
9451 if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
9452 cssText = cssText.replace(/\sbackground-clip:\s*text;/g, " -webkit-background-clip: text; background-clip: text;");
9453 }
9454 return cssText;
9455 }
9456 function escapeImportStatement(rule2) {
9457 var cssText = rule2.cssText;
9458 if (cssText.split('"').length < 3) return cssText;
9459 var statement = [
9460 "@import",
9461 "url(" + JSON.stringify(rule2.href) + ")"
9462 ];
9463 if (rule2.layerName === "") {
9464 statement.push("layer");
9465 } else if (rule2.layerName) {
9466 statement.push("layer(" + rule2.layerName + ")");
9467 }
9468 if (rule2.supportsText) {
9469 statement.push("supports(" + rule2.supportsText + ")");
9470 }
9471 if (rule2.media.length) {
9472 statement.push(rule2.media.mediaText);
9473 }
9474 return statement.join(" ") + ";";
9475 }
9476 function stringifyStylesheet(s2) {
9477 try {
9478 var rules2 = s2.rules || s2.cssRules;
9479 if (!rules2) {
9480 return null;
9481 }
9482 var sheetHref = s2.href;
9483 if (!sheetHref && s2.ownerNode && s2.ownerNode.ownerDocument) {
9484 sheetHref = s2.ownerNode.ownerDocument.location.href;
9485 }
9486 var stringifiedRules = Array.from(rules2, function(rule2) {
9487 return stringifyRule(rule2, sheetHref);
9488 }).join("");
9489 return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
9490 } catch (error) {
9491 return null;
9492 }
9493 }
9494 function stringifyRule(rule2, sheetHref) {
9495 if (isCSSImportRule(rule2)) {
9496 var importStringified;
9497 try {
9498 importStringified = // we can access the imported stylesheet rules directly
9499 stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
9500 escapeImportStatement(rule2);
9501 } catch (error) {
9502 importStringified = rule2.cssText;
9503 }
9504 if (rule2.styleSheet.href) {
9505 return absolutifyURLs(importStringified, rule2.styleSheet.href);
9506 }
9507 return importStringified;
9508 } else {
9509 var ruleStringified = rule2.cssText;
9510 if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
9511 ruleStringified = fixSafariColons(ruleStringified);
9512 }
9513 if (sheetHref) {
9514 return absolutifyURLs(ruleStringified, sheetHref);
9515 }
9516 return ruleStringified;
9517 }
9518 }
9519 function fixSafariColons(cssStringified) {
9520 var regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
9521 return cssStringified.replace(regex, "$1\\$2");
9522 }
9523 function isCSSImportRule(rule2) {
9524 return "styleSheet" in rule2;
9525 }
9526 function isCSSStyleRule(rule2) {
9527 return "selectorText" in rule2;
9528 }
9529 var Mirror = /*#__PURE__*/ function() {
9530 function Mirror() {
9531 __publicField$1(this, "idNodeMap", /* @__PURE__ */ new Map());
9532 __publicField$1(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap());
9533 }
9534 var _proto = Mirror.prototype;
9535 _proto.getId = function getId(n2) {
9536 var _a2;
9537 if (!n2) return -1;
9538 var id = (_a2 = this.getMeta(n2)) == null ? void 0 : _a2.id;
9539 return id != null ? id : -1;
9540 };
9541 _proto.getNode = function getNode(id) {
9542 return this.idNodeMap.get(id) || null;
9543 };
9544 _proto.getIds = function getIds() {
9545 return Array.from(this.idNodeMap.keys());
9546 };
9547 _proto.getMeta = function getMeta(n2) {
9548 return this.nodeMetaMap.get(n2) || null;
9549 };
9550 // removes the node from idNodeMap
9551 // doesn't remove the node from nodeMetaMap
9552 _proto.removeNodeFromMap = function removeNodeFromMap(n2) {
9553 var _this = this;
9554 var id = this.getId(n2);
9555 this.idNodeMap.delete(id);
9556 if (n2.childNodes) {
9557 n2.childNodes.forEach(function(childNode) {
9558 return _this.removeNodeFromMap(childNode);
9559 });
9560 }
9561 };
9562 _proto.has = function has(id) {
9563 return this.idNodeMap.has(id);
9564 };
9565 _proto.hasNode = function hasNode(node2) {
9566 return this.nodeMetaMap.has(node2);
9567 };
9568 _proto.add = function add(n2, meta) {
9569 var id = meta.id;
9570 this.idNodeMap.set(id, n2);
9571 this.nodeMetaMap.set(n2, meta);
9572 };
9573 _proto.replace = function replace(id, n2) {
9574 var oldNode = this.getNode(id);
9575 if (oldNode) {
9576 var meta = this.nodeMetaMap.get(oldNode);
9577 if (meta) this.nodeMetaMap.set(n2, meta);
9578 }
9579 this.idNodeMap.set(id, n2);
9580 };
9581 _proto.reset = function reset() {
9582 this.idNodeMap = /* @__PURE__ */ new Map();
9583 this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
9584 };
9585 return Mirror;
9586 }();
9587 function createMirror$2() {
9588 return new Mirror();
9589 }
9590 function maskInputValue(param) {
9591 var element = param.element, maskInputOptions = param.maskInputOptions, tagName = param.tagName, type = param.type, value = param.value, maskInputFn = param.maskInputFn;
9592 var text = value || "";
9593 var actualType = type && toLowerCase(type);
9594 if (maskInputOptions[tagName.toLowerCase()] || actualType && maskInputOptions[actualType]) {
9595 if (maskInputFn) {
9596 text = maskInputFn(text, element);
9597 } else {
9598 text = "*".repeat(text.length);
9599 }
9600 }
9601 return text;
9602 }
9603 function toLowerCase(str) {
9604 return str.toLowerCase();
9605 }
9606 var ORIGINAL_ATTRIBUTE_NAME = "__rrweb_original__";
9607 function is2DCanvasBlank(canvas) {
9608 var ctx = canvas.getContext("2d");
9609 if (!ctx) return true;
9610 var chunkSize = 50;
9611 for(var x2 = 0; x2 < canvas.width; x2 += chunkSize){
9612 for(var y = 0; y < canvas.height; y += chunkSize){
9613 var getImageData = ctx.getImageData;
9614 var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData ? getImageData[ORIGINAL_ATTRIBUTE_NAME] : getImageData;
9615 var pixelBuffer = new Uint32Array(// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
9616 originalGetImageData.call(ctx, x2, y, Math.min(chunkSize, canvas.width - x2), Math.min(chunkSize, canvas.height - y)).data.buffer);
9617 if (pixelBuffer.some(function(pixel) {
9618 return pixel !== 0;
9619 })) return false;
9620 }
9621 }
9622 return true;
9623 }
9624 function getInputType(element) {
9625 var type = element.type;
9626 return element.hasAttribute("data-rr-is-password") ? "password" : type ? // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
9627 toLowerCase(type) : null;
9628 }
9629 function extractFileExtension(path, baseURL) {
9630 var url;
9631 try {
9632 url = new URL(path, baseURL != null ? baseURL : window.location.href);
9633 } catch (err) {
9634 return null;
9635 }
9636 var regex = /\.([0-9a-z]+)(?:$)/i;
9637 var match = url.pathname.match(regex);
9638 var _ref;
9639 return (_ref = match == null ? void 0 : match[1]) != null ? _ref : null;
9640 }
9641 function extractOrigin(url) {
9642 var origin = "";
9643 if (url.indexOf("//") > -1) {
9644 origin = url.split("/").slice(0, 3).join("/");
9645 } else {
9646 origin = url.split("/")[0];
9647 }
9648 origin = origin.split("?")[0];
9649 return origin;
9650 }
9651 var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
9652 var URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
9653 var URL_WWW_MATCH = /^www\..*/i;
9654 var DATA_URI = /^(data:)([^,]*),(.*)/i;
9655 function absolutifyURLs(cssText, href) {
9656 return (cssText || "").replace(URL_IN_CSS_REF, function(origin, quote1, path1, quote2, path2, path3) {
9657 var filePath = path1 || path2 || path3;
9658 var maybeQuote = quote1 || quote2 || "";
9659 if (!filePath) {
9660 return origin;
9661 }
9662 if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {
9663 return "url(" + maybeQuote + filePath + maybeQuote + ")";
9664 }
9665 if (DATA_URI.test(filePath)) {
9666 return "url(" + maybeQuote + filePath + maybeQuote + ")";
9667 }
9668 if (filePath[0] === "/") {
9669 return "url(" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + ")";
9670 }
9671 var stack = href.split("/");
9672 var parts = filePath.split("/");
9673 stack.pop();
9674 for(var _iterator = _create_for_of_iterator_helper_loose(parts), _step; !(_step = _iterator()).done;){
9675 var part = _step.value;
9676 if (part === ".") {
9677 continue;
9678 } else if (part === "..") {
9679 stack.pop();
9680 } else {
9681 stack.push(part);
9682 }
9683 }
9684 return "url(" + maybeQuote + stack.join("/") + maybeQuote + ")";
9685 });
9686 }
9687 function normalizeCssString(cssText, _testNoPxNorm) {
9688 if (_testNoPxNorm === void 0) _testNoPxNorm = false;
9689 if (_testNoPxNorm) {
9690 return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "");
9691 } else {
9692 return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "").replace(/0px/g, "0");
9693 }
9694 }
9695 function splitCssText(cssText, style, _testNoPxNorm) {
9696 if (_testNoPxNorm === void 0) _testNoPxNorm = false;
9697 var childNodes2 = Array.from(style.childNodes);
9698 var splits = [];
9699 var iterCount = 0;
9700 if (childNodes2.length > 1 && cssText && typeof cssText === "string") {
9701 var cssTextNorm = normalizeCssString(cssText, _testNoPxNorm);
9702 var normFactor = cssTextNorm.length / cssText.length;
9703 for(var i2 = 1; i2 < childNodes2.length; i2++){
9704 if (childNodes2[i2].textContent && typeof childNodes2[i2].textContent === "string") {
9705 var textContentNorm = normalizeCssString(childNodes2[i2].textContent, _testNoPxNorm);
9706 var jLimit = 100;
9707 var j = 3;
9708 for(; j < textContentNorm.length; j++){
9709 if (// keep consuming css identifiers (to get a decent chunk more quickly)
9710 textContentNorm[j].match(/[a-zA-Z0-9]/) || // substring needs to be unique to this section
9711 textContentNorm.indexOf(textContentNorm.substring(0, j), 1) !== -1) {
9712 continue;
9713 }
9714 break;
9715 }
9716 for(; j < textContentNorm.length; j++){
9717 var startSubstring = textContentNorm.substring(0, j);
9718 var cssNormSplits = cssTextNorm.split(startSubstring);
9719 var splitNorm = -1;
9720 if (cssNormSplits.length === 2) {
9721 splitNorm = cssNormSplits[0].length;
9722 } else if (cssNormSplits.length > 2 && cssNormSplits[0] === "" && childNodes2[i2 - 1].textContent !== "") {
9723 splitNorm = cssTextNorm.indexOf(startSubstring, 1);
9724 } else if (cssNormSplits.length === 1) {
9725 startSubstring = startSubstring.substring(0, startSubstring.length - 1);
9726 cssNormSplits = cssTextNorm.split(startSubstring);
9727 if (cssNormSplits.length <= 1) {
9728 splits.push(cssText);
9729 return splits;
9730 }
9731 j = jLimit + 1;
9732 } else if (j === textContentNorm.length - 1) {
9733 splitNorm = cssTextNorm.indexOf(startSubstring);
9734 }
9735 if (cssNormSplits.length >= 2 && j > jLimit) {
9736 var prevTextContent = childNodes2[i2 - 1].textContent;
9737 if (prevTextContent && typeof prevTextContent === "string") {
9738 var prevMinLength = normalizeCssString(prevTextContent).length;
9739 splitNorm = cssTextNorm.indexOf(startSubstring, prevMinLength);
9740 }
9741 if (splitNorm === -1) {
9742 splitNorm = cssNormSplits[0].length;
9743 }
9744 }
9745 if (splitNorm !== -1) {
9746 var k = Math.floor(splitNorm / normFactor);
9747 for(; k > 0 && k < cssText.length;){
9748 iterCount += 1;
9749 if (iterCount > 50 * childNodes2.length) {
9750 splits.push(cssText);
9751 return splits;
9752 }
9753 var normPart = normalizeCssString(cssText.substring(0, k), _testNoPxNorm);
9754 if (normPart.length === splitNorm) {
9755 splits.push(cssText.substring(0, k));
9756 cssText = cssText.substring(k);
9757 cssTextNorm = cssTextNorm.substring(splitNorm);
9758 break;
9759 } else if (normPart.length < splitNorm) {
9760 k += Math.max(1, Math.floor((splitNorm - normPart.length) / normFactor));
9761 } else {
9762 k -= Math.max(1, Math.floor((normPart.length - splitNorm) * normFactor));
9763 }
9764 }
9765 break;
9766 }
9767 }
9768 }
9769 }
9770 }
9771 splits.push(cssText);
9772 return splits;
9773 }
9774 function markCssSplits(cssText, style) {
9775 return splitCssText(cssText, style).join("/* rr_split */");
9776 }
9777 var _id = 1;
9778 var tagNameRegex = new RegExp("[^a-z0-9-_:]");
9779 var IGNORED_NODE = -2;
9780 function genId() {
9781 return _id++;
9782 }
9783 function getValidTagName$1(element) {
9784 if (_instanceof(element, HTMLFormElement)) {
9785 return "form";
9786 }
9787 var processedTagName = toLowerCase(element.tagName);
9788 if (tagNameRegex.test(processedTagName)) {
9789 return "div";
9790 }
9791 return processedTagName;
9792 }
9793 var canvasService;
9794 var canvasCtx;
9795 var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
9796 var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
9797 function getAbsoluteSrcsetString(doc, attributeValue) {
9798 if (attributeValue.trim() === "") {
9799 return attributeValue;
9800 }
9801 var pos = 0;
9802 function collectCharacters(regEx) {
9803 var chars2;
9804 var match = regEx.exec(attributeValue.substring(pos));
9805 if (match) {
9806 chars2 = match[0];
9807 pos += chars2.length;
9808 return chars2;
9809 }
9810 return "";
9811 }
9812 var output = [];
9813 while(true){
9814 collectCharacters(SRCSET_COMMAS_OR_SPACES);
9815 if (pos >= attributeValue.length) {
9816 break;
9817 }
9818 var url = collectCharacters(SRCSET_NOT_SPACES);
9819 if (url.slice(-1) === ",") {
9820 url = absoluteToDoc(doc, url.substring(0, url.length - 1));
9821 output.push(url);
9822 } else {
9823 var descriptorsStr = "";
9824 url = absoluteToDoc(doc, url);
9825 var inParens = false;
9826 while(true){
9827 var c2 = attributeValue.charAt(pos);
9828 if (c2 === "") {
9829 output.push((url + descriptorsStr).trim());
9830 break;
9831 } else if (!inParens) {
9832 if (c2 === ",") {
9833 pos += 1;
9834 output.push((url + descriptorsStr).trim());
9835 break;
9836 } else if (c2 === "(") {
9837 inParens = true;
9838 }
9839 } else {
9840 if (c2 === ")") {
9841 inParens = false;
9842 }
9843 }
9844 descriptorsStr += c2;
9845 pos += 1;
9846 }
9847 }
9848 }
9849 return output.join(", ");
9850 }
9851 var cachedDocument = /* @__PURE__ */ new WeakMap();
9852 function absoluteToDoc(doc, attributeValue) {
9853 if (!attributeValue || attributeValue.trim() === "") {
9854 return attributeValue;
9855 }
9856 return getHref(doc, attributeValue);
9857 }
9858 function isSVGElement(el) {
9859 return Boolean(el.tagName === "svg" || el.ownerSVGElement);
9860 }
9861 function getHref(doc, customHref) {
9862 var a2 = cachedDocument.get(doc);
9863 if (!a2) {
9864 a2 = doc.createElement("a");
9865 cachedDocument.set(doc, a2);
9866 }
9867 if (!customHref) {
9868 customHref = "";
9869 } else if (customHref.startsWith("blob:") || customHref.startsWith("data:")) {
9870 return customHref;
9871 }
9872 a2.setAttribute("href", customHref);
9873 return a2.href;
9874 }
9875 function transformAttribute(doc, tagName, name, value) {
9876 if (!value) {
9877 return value;
9878 }
9879 if (name === "src" || name === "href" && !(tagName === "use" && value[0] === "#")) {
9880 return absoluteToDoc(doc, value);
9881 } else if (name === "xlink:href" && value[0] !== "#") {
9882 return absoluteToDoc(doc, value);
9883 } else if (name === "background" && (tagName === "table" || tagName === "td" || tagName === "th")) {
9884 return absoluteToDoc(doc, value);
9885 } else if (name === "srcset") {
9886 return getAbsoluteSrcsetString(doc, value);
9887 } else if (name === "style") {
9888 return absolutifyURLs(value, getHref(doc));
9889 } else if (tagName === "object" && name === "data") {
9890 return absoluteToDoc(doc, value);
9891 }
9892 return value;
9893 }
9894 function ignoreAttribute(tagName, name, _value) {
9895 return (tagName === "video" || tagName === "audio") && name === "autoplay";
9896 }
9897 function _isBlockedElement(element, blockClass, blockSelector) {
9898 try {
9899 if (typeof blockClass === "string") {
9900 if (element.classList.contains(blockClass)) {
9901 return true;
9902 }
9903 } else {
9904 for(var eIndex = element.classList.length; eIndex--;){
9905 var className = element.classList[eIndex];
9906 if (blockClass.test(className)) {
9907 return true;
9908 }
9909 }
9910 }
9911 if (blockSelector) {
9912 return element.matches(blockSelector);
9913 }
9914 } catch (e2) {}
9915 return false;
9916 }
9917 function classMatchesRegex(node2, regex, checkAncestors) {
9918 if (!node2) return false;
9919 if (node2.nodeType !== node2.ELEMENT_NODE) {
9920 if (!checkAncestors) return false;
9921 return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
9922 }
9923 for(var eIndex = node2.classList.length; eIndex--;){
9924 var className = node2.classList[eIndex];
9925 if (regex.test(className)) {
9926 return true;
9927 }
9928 }
9929 if (!checkAncestors) return false;
9930 return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
9931 }
9932 function needMaskingText(node2, maskTextClass, maskTextSelector, checkAncestors) {
9933 var el;
9934 if (isElement(node2)) {
9935 el = node2;
9936 if (!index$1.childNodes(el).length) {
9937 return false;
9938 }
9939 } else if (index$1.parentElement(node2) === null) {
9940 return false;
9941 } else {
9942 el = index$1.parentElement(node2);
9943 }
9944 try {
9945 if (typeof maskTextClass === "string") {
9946 if (checkAncestors) {
9947 if (el.closest("." + maskTextClass)) return true;
9948 } else {
9949 if (el.classList.contains(maskTextClass)) return true;
9950 }
9951 } else {
9952 if (classMatchesRegex(el, maskTextClass, checkAncestors)) return true;
9953 }
9954 if (maskTextSelector) {
9955 if (checkAncestors) {
9956 if (el.closest(maskTextSelector)) return true;
9957 } else {
9958 if (el.matches(maskTextSelector)) return true;
9959 }
9960 }
9961 } catch (e2) {}
9962 return false;
9963 }
9964 function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
9965 var win = iframeEl.contentWindow;
9966 if (!win) {
9967 return;
9968 }
9969 var fired = false;
9970 var readyState;
9971 try {
9972 readyState = win.document.readyState;
9973 } catch (error) {
9974 return;
9975 }
9976 if (readyState !== "complete") {
9977 var timer = setTimeout(function() {
9978 if (!fired) {
9979 listener();
9980 fired = true;
9981 }
9982 }, iframeLoadTimeout);
9983 iframeEl.addEventListener("load", function() {
9984 clearTimeout(timer);
9985 fired = true;
9986 listener();
9987 });
9988 return;
9989 }
9990 var blankUrl = "about:blank";
9991 if (win.location.href !== blankUrl || iframeEl.src === blankUrl || iframeEl.src === "") {
9992 setTimeout(listener, 0);
9993 return iframeEl.addEventListener("load", listener);
9994 }
9995 iframeEl.addEventListener("load", listener);
9996 }
9997 function onceStylesheetLoaded(link, listener, styleSheetLoadTimeout) {
9998 var fired = false;
9999 var styleSheetLoaded;
10000 try {
10001 styleSheetLoaded = link.sheet;
10002 } catch (error) {
10003 return;
10004 }
10005 if (styleSheetLoaded) return;
10006 var timer = setTimeout(function() {
10007 if (!fired) {
10008 listener();
10009 fired = true;
10010 }
10011 }, styleSheetLoadTimeout);
10012 link.addEventListener("load", function() {
10013 clearTimeout(timer);
10014 fired = true;
10015 listener();
10016 });
10017 }
10018 function serializeNode(n2, options) {
10019 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;
10020 var rootId = getRootId(doc, mirror2);
10021 switch(n2.nodeType){
10022 case n2.DOCUMENT_NODE:
10023 if (n2.compatMode !== "CSS1Compat") {
10024 return {
10025 type: NodeType$3.Document,
10026 childNodes: [],
10027 compatMode: n2.compatMode
10028 };
10029 } else {
10030 return {
10031 type: NodeType$3.Document,
10032 childNodes: []
10033 };
10034 }
10035 case n2.DOCUMENT_TYPE_NODE:
10036 return {
10037 type: NodeType$3.DocumentType,
10038 name: n2.name,
10039 publicId: n2.publicId,
10040 systemId: n2.systemId,
10041 rootId: rootId
10042 };
10043 case n2.ELEMENT_NODE:
10044 return serializeElementNode(n2, {
10045 doc: doc,
10046 blockClass: blockClass,
10047 blockSelector: blockSelector,
10048 inlineStylesheet: inlineStylesheet,
10049 maskInputOptions: maskInputOptions,
10050 maskInputFn: maskInputFn,
10051 dataURLOptions: dataURLOptions,
10052 inlineImages: inlineImages,
10053 recordCanvas: recordCanvas,
10054 keepIframeSrcFn: keepIframeSrcFn,
10055 newlyAddedElement: newlyAddedElement,
10056 rootId: rootId
10057 });
10058 case n2.TEXT_NODE:
10059 return serializeTextNode(n2, {
10060 doc: doc,
10061 needsMask: needsMask,
10062 maskTextFn: maskTextFn,
10063 rootId: rootId,
10064 cssCaptured: cssCaptured
10065 });
10066 case n2.CDATA_SECTION_NODE:
10067 return {
10068 type: NodeType$3.CDATA,
10069 textContent: "",
10070 rootId: rootId
10071 };
10072 case n2.COMMENT_NODE:
10073 return {
10074 type: NodeType$3.Comment,
10075 textContent: index$1.textContent(n2) || "",
10076 rootId: rootId
10077 };
10078 default:
10079 return false;
10080 }
10081 }
10082 function getRootId(doc, mirror2) {
10083 if (!mirror2.hasNode(doc)) return void 0;
10084 var docId = mirror2.getId(doc);
10085 return docId === 1 ? void 0 : docId;
10086 }
10087 function serializeTextNode(n2, options) {
10088 var needsMask = options.needsMask, maskTextFn = options.maskTextFn, rootId = options.rootId, cssCaptured = options.cssCaptured;
10089 var parent = index$1.parentNode(n2);
10090 var parentTagName = parent && parent.tagName;
10091 var textContent2 = "";
10092 var isStyle = parentTagName === "STYLE" ? true : void 0;
10093 var isScript = parentTagName === "SCRIPT" ? true : void 0;
10094 if (isScript) {
10095 textContent2 = "SCRIPT_PLACEHOLDER";
10096 } else if (!cssCaptured) {
10097 textContent2 = index$1.textContent(n2);
10098 if (isStyle && textContent2) {
10099 textContent2 = absolutifyURLs(textContent2, getHref(options.doc));
10100 }
10101 }
10102 if (!isStyle && !isScript && textContent2 && needsMask) {
10103 textContent2 = maskTextFn ? maskTextFn(textContent2, index$1.parentElement(n2)) : textContent2.replace(/[\S]/g, "*");
10104 }
10105 return {
10106 type: NodeType$3.Text,
10107 textContent: textContent2 || "",
10108 rootId: rootId
10109 };
10110 }
10111 function serializeElementNode(n2, options) {
10112 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;
10113 var needBlock = _isBlockedElement(n2, blockClass, blockSelector);
10114 var tagName = getValidTagName$1(n2);
10115 var attributes = {};
10116 var len = n2.attributes.length;
10117 for(var i2 = 0; i2 < len; i2++){
10118 var attr = n2.attributes[i2];
10119 if (!ignoreAttribute(tagName, attr.name, attr.value)) {
10120 attributes[attr.name] = transformAttribute(doc, tagName, toLowerCase(attr.name), attr.value);
10121 }
10122 }
10123 if (tagName === "link" && inlineStylesheet) {
10124 var stylesheet = Array.from(doc.styleSheets).find(function(s2) {
10125 return s2.href === n2.href;
10126 });
10127 var cssText = null;
10128 if (stylesheet) {
10129 cssText = stringifyStylesheet(stylesheet);
10130 }
10131 if (cssText) {
10132 delete attributes.rel;
10133 delete attributes.href;
10134 attributes._cssText = cssText;
10135 }
10136 }
10137 if (tagName === "style" && n2.sheet) {
10138 var cssText1 = stringifyStylesheet(n2.sheet);
10139 if (cssText1) {
10140 if (n2.childNodes.length > 1) {
10141 cssText1 = markCssSplits(cssText1, n2);
10142 }
10143 attributes._cssText = cssText1;
10144 }
10145 }
10146 if (tagName === "input" || tagName === "textarea" || tagName === "select") {
10147 var value = n2.value;
10148 var checked = n2.checked;
10149 if (attributes.type !== "radio" && attributes.type !== "checkbox" && attributes.type !== "submit" && attributes.type !== "button" && value) {
10150 attributes.value = maskInputValue({
10151 element: n2,
10152 type: getInputType(n2),
10153 tagName: tagName,
10154 value: value,
10155 maskInputOptions: maskInputOptions,
10156 maskInputFn: maskInputFn
10157 });
10158 } else if (checked) {
10159 attributes.checked = checked;
10160 }
10161 }
10162 if (tagName === "option") {
10163 if (n2.selected && !maskInputOptions["select"]) {
10164 attributes.selected = true;
10165 } else {
10166 delete attributes.selected;
10167 }
10168 }
10169 if (tagName === "dialog" && n2.open) {
10170 attributes.rr_open_mode = n2.matches("dialog:modal") ? "modal" : "non-modal";
10171 }
10172 if (tagName === "canvas" && recordCanvas) {
10173 if (n2.__context === "2d") {
10174 if (!is2DCanvasBlank(n2)) {
10175 attributes.rr_dataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
10176 }
10177 } else if (!("__context" in n2)) {
10178 var canvasDataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
10179 var blankCanvas = doc.createElement("canvas");
10180 blankCanvas.width = n2.width;
10181 blankCanvas.height = n2.height;
10182 var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);
10183 if (canvasDataURL !== blankCanvasDataURL) {
10184 attributes.rr_dataURL = canvasDataURL;
10185 }
10186 }
10187 }
10188 if (tagName === "img" && inlineImages) {
10189 if (!canvasService) {
10190 canvasService = doc.createElement("canvas");
10191 canvasCtx = canvasService.getContext("2d");
10192 }
10193 var image = n2;
10194 var imageSrc = image.currentSrc || image.getAttribute("src") || "<unknown-src>";
10195 var priorCrossOrigin = image.crossOrigin;
10196 var recordInlineImage = function() {
10197 image.removeEventListener("load", recordInlineImage);
10198 try {
10199 canvasService.width = image.naturalWidth;
10200 canvasService.height = image.naturalHeight;
10201 canvasCtx.drawImage(image, 0, 0);
10202 attributes.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);
10203 } catch (err) {
10204 if (image.crossOrigin !== "anonymous") {
10205 image.crossOrigin = "anonymous";
10206 if (image.complete && image.naturalWidth !== 0) recordInlineImage();
10207 else image.addEventListener("load", recordInlineImage);
10208 return;
10209 } else {
10210 console.warn("Cannot inline img src=" + imageSrc + "! Error: " + err);
10211 }
10212 }
10213 if (image.crossOrigin === "anonymous") {
10214 priorCrossOrigin ? attributes.crossOrigin = priorCrossOrigin : image.removeAttribute("crossorigin");
10215 }
10216 };
10217 if (image.complete && image.naturalWidth !== 0) recordInlineImage();
10218 else image.addEventListener("load", recordInlineImage);
10219 }
10220 if (tagName === "audio" || tagName === "video") {
10221 var mediaAttributes = attributes;
10222 mediaAttributes.rr_mediaState = n2.paused ? "paused" : "played";
10223 mediaAttributes.rr_mediaCurrentTime = n2.currentTime;
10224 mediaAttributes.rr_mediaPlaybackRate = n2.playbackRate;
10225 mediaAttributes.rr_mediaMuted = n2.muted;
10226 mediaAttributes.rr_mediaLoop = n2.loop;
10227 mediaAttributes.rr_mediaVolume = n2.volume;
10228 }
10229 if (!newlyAddedElement) {
10230 if (n2.scrollLeft) {
10231 attributes.rr_scrollLeft = n2.scrollLeft;
10232 }
10233 if (n2.scrollTop) {
10234 attributes.rr_scrollTop = n2.scrollTop;
10235 }
10236 }
10237 if (needBlock) {
10238 var _n2_getBoundingClientRect = n2.getBoundingClientRect(), width = _n2_getBoundingClientRect.width, height = _n2_getBoundingClientRect.height;
10239 attributes = {
10240 class: attributes.class,
10241 rr_width: "" + width + "px",
10242 rr_height: "" + height + "px"
10243 };
10244 }
10245 if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
10246 if (!n2.contentDocument) {
10247 attributes.rr_src = attributes.src;
10248 }
10249 delete attributes.src;
10250 }
10251 var isCustomElement;
10252 try {
10253 if (customElements.get(tagName)) isCustomElement = true;
10254 } catch (e2) {}
10255 return {
10256 type: NodeType$3.Element,
10257 tagName: tagName,
10258 attributes: attributes,
10259 childNodes: [],
10260 isSVG: isSVGElement(n2) || void 0,
10261 needBlock: needBlock,
10262 rootId: rootId,
10263 isCustom: isCustomElement
10264 };
10265 }
10266 function lowerIfExists(maybeAttr) {
10267 if (maybeAttr === void 0 || maybeAttr === null) {
10268 return "";
10269 } else {
10270 return maybeAttr.toLowerCase();
10271 }
10272 }
10273 function slimDOMExcluded(sn, slimDOMOptions) {
10274 if (slimDOMOptions.comment && sn.type === NodeType$3.Comment) {
10275 return true;
10276 } else if (sn.type === NodeType$3.Element) {
10277 if (slimDOMOptions.script && // script tag
10278 (sn.tagName === "script" || // (module)preload link
10279 sn.tagName === "link" && (sn.attributes.rel === "preload" && sn.attributes.as === "script" || sn.attributes.rel === "modulepreload") || // prefetch link
10280 sn.tagName === "link" && sn.attributes.rel === "prefetch" && typeof sn.attributes.href === "string" && extractFileExtension(sn.attributes.href) === "js")) {
10281 return true;
10282 } 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"))) {
10283 return true;
10284 } else if (sn.tagName === "meta") {
10285 if (slimDOMOptions.headMetaDescKeywords && lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
10286 return true;
10287 } else if (slimDOMOptions.headMetaSocial && (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || // og = opengraph (facebook)
10288 lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || lowerIfExists(sn.attributes.name) === "pinterest")) {
10289 return true;
10290 } else if (slimDOMOptions.headMetaRobots && (lowerIfExists(sn.attributes.name) === "robots" || lowerIfExists(sn.attributes.name) === "googlebot" || lowerIfExists(sn.attributes.name) === "bingbot")) {
10291 return true;
10292 } else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== void 0) {
10293 return true;
10294 } 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:/))) {
10295 return true;
10296 } 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")) {
10297 return true;
10298 }
10299 }
10300 }
10301 return false;
10302 }
10303 function serializeNodeWithId(n2, options) {
10304 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() {
10305 return false;
10306 } : _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;
10307 var needsMask = options.needsMask;
10308 var _options_preserveWhiteSpace = options.preserveWhiteSpace, preserveWhiteSpace = _options_preserveWhiteSpace === void 0 ? true : _options_preserveWhiteSpace;
10309 if (!needsMask) {
10310 var checkAncestors = needsMask === void 0;
10311 needsMask = needMaskingText(n2, maskTextClass, maskTextSelector, checkAncestors);
10312 }
10313 var _serializedNode = serializeNode(n2, {
10314 doc: doc,
10315 mirror: mirror2,
10316 blockClass: blockClass,
10317 blockSelector: blockSelector,
10318 needsMask: needsMask,
10319 inlineStylesheet: inlineStylesheet,
10320 maskInputOptions: maskInputOptions,
10321 maskTextFn: maskTextFn,
10322 maskInputFn: maskInputFn,
10323 dataURLOptions: dataURLOptions,
10324 inlineImages: inlineImages,
10325 recordCanvas: recordCanvas,
10326 keepIframeSrcFn: keepIframeSrcFn,
10327 newlyAddedElement: newlyAddedElement,
10328 cssCaptured: cssCaptured
10329 });
10330 if (!_serializedNode) {
10331 console.warn(n2, "not serialized");
10332 return null;
10333 }
10334 var id;
10335 if (mirror2.hasNode(n2)) {
10336 id = mirror2.getId(n2);
10337 } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType$3.Text && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
10338 id = IGNORED_NODE;
10339 } else {
10340 id = genId();
10341 }
10342 var serializedNode = Object.assign(_serializedNode, {
10343 id: id
10344 });
10345 mirror2.add(n2, serializedNode);
10346 if (id === IGNORED_NODE) {
10347 return null;
10348 }
10349 if (onSerialize) {
10350 onSerialize(n2);
10351 }
10352 var recordChild = !skipChild;
10353 if (serializedNode.type === NodeType$3.Element) {
10354 recordChild = recordChild && !serializedNode.needBlock;
10355 delete serializedNode.needBlock;
10356 var shadowRootEl = index$1.shadowRoot(n2);
10357 if (shadowRootEl && isNativeShadowDom(shadowRootEl)) serializedNode.isShadowHost = true;
10358 }
10359 if ((serializedNode.type === NodeType$3.Document || serializedNode.type === NodeType$3.Element) && recordChild) {
10360 if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType$3.Element && serializedNode.tagName === "head") {
10361 preserveWhiteSpace = false;
10362 }
10363 var bypassOptions = {
10364 doc: doc,
10365 mirror: mirror2,
10366 blockClass: blockClass,
10367 blockSelector: blockSelector,
10368 needsMask: needsMask,
10369 maskTextClass: maskTextClass,
10370 maskTextSelector: maskTextSelector,
10371 skipChild: skipChild,
10372 inlineStylesheet: inlineStylesheet,
10373 maskInputOptions: maskInputOptions,
10374 maskTextFn: maskTextFn,
10375 maskInputFn: maskInputFn,
10376 slimDOMOptions: slimDOMOptions,
10377 dataURLOptions: dataURLOptions,
10378 inlineImages: inlineImages,
10379 recordCanvas: recordCanvas,
10380 preserveWhiteSpace: preserveWhiteSpace,
10381 onSerialize: onSerialize,
10382 onIframeLoad: onIframeLoad,
10383 iframeLoadTimeout: iframeLoadTimeout,
10384 onStylesheetLoad: onStylesheetLoad,
10385 stylesheetLoadTimeout: stylesheetLoadTimeout,
10386 keepIframeSrcFn: keepIframeSrcFn,
10387 cssCaptured: false
10388 };
10389 if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
10390 else {
10391 if (serializedNode.type === NodeType$3.Element && serializedNode.attributes._cssText !== void 0 && typeof serializedNode.attributes._cssText === "string") {
10392 bypassOptions.cssCaptured = true;
10393 }
10394 for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(index$1.childNodes(n2))), _step; !(_step = _iterator()).done;){
10395 var childN = _step.value;
10396 var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
10397 if (serializedChildNode) {
10398 serializedNode.childNodes.push(serializedChildNode);
10399 }
10400 }
10401 }
10402 var shadowRootEl1 = null;
10403 if (isElement(n2) && (shadowRootEl1 = index$1.shadowRoot(n2))) {
10404 for(var _iterator1 = _create_for_of_iterator_helper_loose(Array.from(index$1.childNodes(shadowRootEl1))), _step1; !(_step1 = _iterator1()).done;){
10405 var childN1 = _step1.value;
10406 var serializedChildNode1 = serializeNodeWithId(childN1, bypassOptions);
10407 if (serializedChildNode1) {
10408 isNativeShadowDom(shadowRootEl1) && (serializedChildNode1.isShadow = true);
10409 serializedNode.childNodes.push(serializedChildNode1);
10410 }
10411 }
10412 }
10413 }
10414 var parent = index$1.parentNode(n2);
10415 if (parent && isShadowRoot(parent) && isNativeShadowDom(parent)) {
10416 serializedNode.isShadow = true;
10417 }
10418 if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "iframe") {
10419 onceIframeLoaded(n2, function() {
10420 var iframeDoc = n2.contentDocument;
10421 if (iframeDoc && onIframeLoad) {
10422 var serializedIframeNode = serializeNodeWithId(iframeDoc, {
10423 doc: iframeDoc,
10424 mirror: mirror2,
10425 blockClass: blockClass,
10426 blockSelector: blockSelector,
10427 needsMask: needsMask,
10428 maskTextClass: maskTextClass,
10429 maskTextSelector: maskTextSelector,
10430 skipChild: false,
10431 inlineStylesheet: inlineStylesheet,
10432 maskInputOptions: maskInputOptions,
10433 maskTextFn: maskTextFn,
10434 maskInputFn: maskInputFn,
10435 slimDOMOptions: slimDOMOptions,
10436 dataURLOptions: dataURLOptions,
10437 inlineImages: inlineImages,
10438 recordCanvas: recordCanvas,
10439 preserveWhiteSpace: preserveWhiteSpace,
10440 onSerialize: onSerialize,
10441 onIframeLoad: onIframeLoad,
10442 iframeLoadTimeout: iframeLoadTimeout,
10443 onStylesheetLoad: onStylesheetLoad,
10444 stylesheetLoadTimeout: stylesheetLoadTimeout,
10445 keepIframeSrcFn: keepIframeSrcFn
10446 });
10447 if (serializedIframeNode) {
10448 onIframeLoad(n2, serializedIframeNode);
10449 }
10450 }
10451 }, iframeLoadTimeout);
10452 }
10453 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")) {
10454 onceStylesheetLoaded(n2, function() {
10455 if (onStylesheetLoad) {
10456 var serializedLinkNode = serializeNodeWithId(n2, {
10457 doc: doc,
10458 mirror: mirror2,
10459 blockClass: blockClass,
10460 blockSelector: blockSelector,
10461 needsMask: needsMask,
10462 maskTextClass: maskTextClass,
10463 maskTextSelector: maskTextSelector,
10464 skipChild: false,
10465 inlineStylesheet: inlineStylesheet,
10466 maskInputOptions: maskInputOptions,
10467 maskTextFn: maskTextFn,
10468 maskInputFn: maskInputFn,
10469 slimDOMOptions: slimDOMOptions,
10470 dataURLOptions: dataURLOptions,
10471 inlineImages: inlineImages,
10472 recordCanvas: recordCanvas,
10473 preserveWhiteSpace: preserveWhiteSpace,
10474 onSerialize: onSerialize,
10475 onIframeLoad: onIframeLoad,
10476 iframeLoadTimeout: iframeLoadTimeout,
10477 onStylesheetLoad: onStylesheetLoad,
10478 stylesheetLoadTimeout: stylesheetLoadTimeout,
10479 keepIframeSrcFn: keepIframeSrcFn
10480 });
10481 if (serializedLinkNode) {
10482 onStylesheetLoad(n2, serializedLinkNode);
10483 }
10484 }
10485 }, stylesheetLoadTimeout);
10486 }
10487 return serializedNode;
10488 }
10489 function snapshot(n2, options) {
10490 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() {
10491 return false;
10492 } : _ref_keepIframeSrcFn;
10493 var maskInputOptions = maskAllInputs === true ? {
10494 color: true,
10495 date: true,
10496 "datetime-local": true,
10497 email: true,
10498 month: true,
10499 number: true,
10500 range: true,
10501 search: true,
10502 tel: true,
10503 text: true,
10504 time: true,
10505 url: true,
10506 week: true,
10507 textarea: true,
10508 select: true,
10509 password: true,
10510 hidden: true
10511 } : maskAllInputs === false ? {
10512 password: true
10513 } : maskAllInputs;
10514 var slimDOMOptions = slimDOM === true || slimDOM === "all" ? // if true: set of sensible options that should not throw away any information
10515 {
10516 script: true,
10517 comment: true,
10518 headFavicon: true,
10519 headWhitespace: true,
10520 headMetaDescKeywords: slimDOM === "all",
10521 // destructive
10522 headMetaSocial: true,
10523 headMetaRobots: true,
10524 headMetaHttpEquiv: true,
10525 headMetaAuthorship: true,
10526 headMetaVerification: true
10527 } : slimDOM === false ? {} : slimDOM;
10528 return serializeNodeWithId(n2, {
10529 doc: n2,
10530 mirror: mirror2,
10531 blockClass: blockClass,
10532 blockSelector: blockSelector,
10533 maskTextClass: maskTextClass,
10534 maskTextSelector: maskTextSelector,
10535 skipChild: false,
10536 inlineStylesheet: inlineStylesheet,
10537 maskInputOptions: maskInputOptions,
10538 maskTextFn: maskTextFn,
10539 maskInputFn: maskInputFn,
10540 slimDOMOptions: slimDOMOptions,
10541 dataURLOptions: dataURLOptions,
10542 inlineImages: inlineImages,
10543 recordCanvas: recordCanvas,
10544 preserveWhiteSpace: preserveWhiteSpace,
10545 onSerialize: onSerialize,
10546 onIframeLoad: onIframeLoad,
10547 iframeLoadTimeout: iframeLoadTimeout,
10548 onStylesheetLoad: onStylesheetLoad,
10549 stylesheetLoadTimeout: stylesheetLoadTimeout,
10550 keepIframeSrcFn: keepIframeSrcFn,
10551 newlyAddedElement: false
10552 });
10553 }
10554 function getDefaultExportFromCjs$1(x2) {
10555 return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
10556 }
10557 function getAugmentedNamespace$1(n2) {
10558 if (n2.__esModule) return n2;
10559 var f2 = n2.default;
10560 if (typeof f2 == "function") {
10561 var a2 = function a22() {
10562 if (_instanceof(this, a22)) {
10563 return Reflect.construct(f2, arguments, this.constructor);
10564 }
10565 return f2.apply(this, arguments);
10566 };
10567 a2.prototype = f2.prototype;
10568 } else a2 = {};
10569 Object.defineProperty(a2, "__esModule", {
10570 value: true
10571 });
10572 Object.keys(n2).forEach(function(k) {
10573 var d = Object.getOwnPropertyDescriptor(n2, k);
10574 Object.defineProperty(a2, k, d.get ? d : {
10575 enumerable: true,
10576 get: function get() {
10577 return n2[k];
10578 }
10579 });
10580 });
10581 return a2;
10582 }
10583 var picocolors_browser$1 = {
10584 exports: {}
10585 };
10586 var x$1 = String;
10587 var create$1 = function create$1() {
10588 return {
10589 isColorSupported: false,
10590 reset: x$1,
10591 bold: x$1,
10592 dim: x$1,
10593 italic: x$1,
10594 underline: x$1,
10595 inverse: x$1,
10596 hidden: x$1,
10597 strikethrough: x$1,
10598 black: x$1,
10599 red: x$1,
10600 green: x$1,
10601 yellow: x$1,
10602 blue: x$1,
10603 magenta: x$1,
10604 cyan: x$1,
10605 white: x$1,
10606 gray: x$1,
10607 bgBlack: x$1,
10608 bgRed: x$1,
10609 bgGreen: x$1,
10610 bgYellow: x$1,
10611 bgBlue: x$1,
10612 bgMagenta: x$1,
10613 bgCyan: x$1,
10614 bgWhite: x$1
10615 };
10616 };
10617 picocolors_browser$1.exports = create$1();
10618 picocolors_browser$1.exports.createColors = create$1;
10619 var picocolors_browserExports$1 = picocolors_browser$1.exports;
10620 var __viteBrowserExternal$2 = {};
10621 var __viteBrowserExternal$1$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10622 __proto__: null,
10623 default: __viteBrowserExternal$2
10624 }, Symbol.toStringTag, {
10625 value: "Module"
10626 }));
10627 var require$$2$1 = /* @__PURE__ */ getAugmentedNamespace$1(__viteBrowserExternal$1$1);
10628 var pico$1 = picocolors_browserExports$1;
10629 var terminalHighlight$1$1 = require$$2$1;
10630 var CssSyntaxError$3$1 = /*#__PURE__*/ function(Error1) {
10631 _inherits(CssSyntaxError, Error1);
10632 function CssSyntaxError(message, line, column, source, file, plugin22) {
10633 var _this;
10634 _this = Error1.call(this, message) || this;
10635 _this.name = "CssSyntaxError";
10636 _this.reason = message;
10637 if (file) {
10638 _this.file = file;
10639 }
10640 if (source) {
10641 _this.source = source;
10642 }
10643 if (plugin22) {
10644 _this.plugin = plugin22;
10645 }
10646 if (typeof line !== "undefined" && typeof column !== "undefined") {
10647 if (typeof line === "number") {
10648 _this.line = line;
10649 _this.column = column;
10650 } else {
10651 _this.line = line.line;
10652 _this.column = line.column;
10653 _this.endLine = column.line;
10654 _this.endColumn = column.column;
10655 }
10656 }
10657 _this.setMessage();
10658 if (Error.captureStackTrace) {
10659 Error.captureStackTrace(_this, CssSyntaxError);
10660 }
10661 return _this;
10662 }
10663 var _proto = CssSyntaxError.prototype;
10664 _proto.setMessage = function setMessage() {
10665 this.message = this.plugin ? this.plugin + ": " : "";
10666 this.message += this.file ? this.file : "<css input>";
10667 if (typeof this.line !== "undefined") {
10668 this.message += ":" + this.line + ":" + this.column;
10669 }
10670 this.message += ": " + this.reason;
10671 };
10672 _proto.showSourceCode = function showSourceCode(color) {
10673 var _this = this;
10674 if (!this.source) return "";
10675 var css = this.source;
10676 if (color == null) color = pico$1.isColorSupported;
10677 if (terminalHighlight$1$1) {
10678 if (color) css = terminalHighlight$1$1(css);
10679 }
10680 var lines = css.split(/\r?\n/);
10681 var start = Math.max(this.line - 3, 0);
10682 var end = Math.min(this.line + 2, lines.length);
10683 var maxWidth = String(end).length;
10684 var mark, aside;
10685 if (color) {
10686 var _pico$1_createColors = pico$1.createColors(true), bold = _pico$1_createColors.bold, gray = _pico$1_createColors.gray, red = _pico$1_createColors.red;
10687 mark = function(text) {
10688 return bold(red(text));
10689 };
10690 aside = function(text) {
10691 return gray(text);
10692 };
10693 } else {
10694 mark = aside = function(str) {
10695 return str;
10696 };
10697 }
10698 return lines.slice(start, end).map(function(line, index2) {
10699 var number = start + 1 + index2;
10700 var gutter = " " + (" " + number).slice(-maxWidth) + " | ";
10701 if (number === _this.line) {
10702 var spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, _this.column - 1).replace(/[^\t]/g, " ");
10703 return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^");
10704 }
10705 return " " + aside(gutter) + line;
10706 }).join("\n");
10707 };
10708 _proto.toString = function toString() {
10709 var code = this.showSourceCode();
10710 if (code) {
10711 code = "\n\n" + code + "\n";
10712 }
10713 return this.name + ": " + this.message + code;
10714 };
10715 return CssSyntaxError;
10716 }(_wrap_native_super(Error));
10717 var cssSyntaxError$1 = CssSyntaxError$3$1;
10718 CssSyntaxError$3$1.default = CssSyntaxError$3$1;
10719 var symbols$1 = {};
10720 symbols$1.isClean = Symbol("isClean");
10721 symbols$1.my = Symbol("my");
10722 var DEFAULT_RAW$1 = {
10723 after: "\n",
10724 beforeClose: "\n",
10725 beforeComment: "\n",
10726 beforeDecl: "\n",
10727 beforeOpen: " ",
10728 beforeRule: "\n",
10729 colon: ": ",
10730 commentLeft: " ",
10731 commentRight: " ",
10732 emptyBody: "",
10733 indent: " ",
10734 semicolon: false
10735 };
10736 function capitalize$1(str) {
10737 return str[0].toUpperCase() + str.slice(1);
10738 }
10739 var Stringifier$2$1 = /*#__PURE__*/ function() {
10740 function Stringifier(builder) {
10741 this.builder = builder;
10742 }
10743 var _proto = Stringifier.prototype;
10744 _proto.atrule = function atrule(node2, semicolon) {
10745 var name = "@" + node2.name;
10746 var params = node2.params ? this.rawValue(node2, "params") : "";
10747 if (typeof node2.raws.afterName !== "undefined") {
10748 name += node2.raws.afterName;
10749 } else if (params) {
10750 name += " ";
10751 }
10752 if (node2.nodes) {
10753 this.block(node2, name + params);
10754 } else {
10755 var end = (node2.raws.between || "") + (semicolon ? ";" : "");
10756 this.builder(name + params + end, node2);
10757 }
10758 };
10759 _proto.beforeAfter = function beforeAfter(node2, detect) {
10760 var value;
10761 if (node2.type === "decl") {
10762 value = this.raw(node2, null, "beforeDecl");
10763 } else if (node2.type === "comment") {
10764 value = this.raw(node2, null, "beforeComment");
10765 } else if (detect === "before") {
10766 value = this.raw(node2, null, "beforeRule");
10767 } else {
10768 value = this.raw(node2, null, "beforeClose");
10769 }
10770 var buf = node2.parent;
10771 var depth = 0;
10772 while(buf && buf.type !== "root"){
10773 depth += 1;
10774 buf = buf.parent;
10775 }
10776 if (value.includes("\n")) {
10777 var indent = this.raw(node2, null, "indent");
10778 if (indent.length) {
10779 for(var step = 0; step < depth; step++)value += indent;
10780 }
10781 }
10782 return value;
10783 };
10784 _proto.block = function block(node2, start) {
10785 var between = this.raw(node2, "between", "beforeOpen");
10786 this.builder(start + between + "{", node2, "start");
10787 var after;
10788 if (node2.nodes && node2.nodes.length) {
10789 this.body(node2);
10790 after = this.raw(node2, "after");
10791 } else {
10792 after = this.raw(node2, "after", "emptyBody");
10793 }
10794 if (after) this.builder(after);
10795 this.builder("}", node2, "end");
10796 };
10797 _proto.body = function body(node2) {
10798 var last = node2.nodes.length - 1;
10799 while(last > 0){
10800 if (node2.nodes[last].type !== "comment") break;
10801 last -= 1;
10802 }
10803 var semicolon = this.raw(node2, "semicolon");
10804 for(var i2 = 0; i2 < node2.nodes.length; i2++){
10805 var child = node2.nodes[i2];
10806 var before = this.raw(child, "before");
10807 if (before) this.builder(before);
10808 this.stringify(child, last !== i2 || semicolon);
10809 }
10810 };
10811 _proto.comment = function comment(node2) {
10812 var left = this.raw(node2, "left", "commentLeft");
10813 var right = this.raw(node2, "right", "commentRight");
10814 this.builder("/*" + left + node2.text + right + "*/", node2);
10815 };
10816 _proto.decl = function decl(node2, semicolon) {
10817 var between = this.raw(node2, "between", "colon");
10818 var string = node2.prop + between + this.rawValue(node2, "value");
10819 if (node2.important) {
10820 string += node2.raws.important || " !important";
10821 }
10822 if (semicolon) string += ";";
10823 this.builder(string, node2);
10824 };
10825 _proto.document = function document1(node2) {
10826 this.body(node2);
10827 };
10828 _proto.raw = function raw(node2, own, detect) {
10829 var value;
10830 if (!detect) detect = own;
10831 if (own) {
10832 value = node2.raws[own];
10833 if (typeof value !== "undefined") return value;
10834 }
10835 var parent = node2.parent;
10836 if (detect === "before") {
10837 if (!parent || parent.type === "root" && parent.first === node2) {
10838 return "";
10839 }
10840 if (parent && parent.type === "document") {
10841 return "";
10842 }
10843 }
10844 if (!parent) return DEFAULT_RAW$1[detect];
10845 var root2 = node2.root();
10846 if (!root2.rawCache) root2.rawCache = {};
10847 if (typeof root2.rawCache[detect] !== "undefined") {
10848 return root2.rawCache[detect];
10849 }
10850 if (detect === "before" || detect === "after") {
10851 return this.beforeAfter(node2, detect);
10852 } else {
10853 var method = "raw" + capitalize$1(detect);
10854 if (this[method]) {
10855 value = this[method](root2, node2);
10856 } else {
10857 root2.walk(function(i2) {
10858 value = i2.raws[own];
10859 if (typeof value !== "undefined") return false;
10860 });
10861 }
10862 }
10863 if (typeof value === "undefined") value = DEFAULT_RAW$1[detect];
10864 root2.rawCache[detect] = value;
10865 return value;
10866 };
10867 _proto.rawBeforeClose = function rawBeforeClose(root2) {
10868 var value;
10869 root2.walk(function(i2) {
10870 if (i2.nodes && i2.nodes.length > 0) {
10871 if (typeof i2.raws.after !== "undefined") {
10872 value = i2.raws.after;
10873 if (value.includes("\n")) {
10874 value = value.replace(/[^\n]+$/, "");
10875 }
10876 return false;
10877 }
10878 }
10879 });
10880 if (value) value = value.replace(/\S/g, "");
10881 return value;
10882 };
10883 _proto.rawBeforeComment = function rawBeforeComment(root2, node2) {
10884 var value;
10885 root2.walkComments(function(i2) {
10886 if (typeof i2.raws.before !== "undefined") {
10887 value = i2.raws.before;
10888 if (value.includes("\n")) {
10889 value = value.replace(/[^\n]+$/, "");
10890 }
10891 return false;
10892 }
10893 });
10894 if (typeof value === "undefined") {
10895 value = this.raw(node2, null, "beforeDecl");
10896 } else if (value) {
10897 value = value.replace(/\S/g, "");
10898 }
10899 return value;
10900 };
10901 _proto.rawBeforeDecl = function rawBeforeDecl(root2, node2) {
10902 var value;
10903 root2.walkDecls(function(i2) {
10904 if (typeof i2.raws.before !== "undefined") {
10905 value = i2.raws.before;
10906 if (value.includes("\n")) {
10907 value = value.replace(/[^\n]+$/, "");
10908 }
10909 return false;
10910 }
10911 });
10912 if (typeof value === "undefined") {
10913 value = this.raw(node2, null, "beforeRule");
10914 } else if (value) {
10915 value = value.replace(/\S/g, "");
10916 }
10917 return value;
10918 };
10919 _proto.rawBeforeOpen = function rawBeforeOpen(root2) {
10920 var value;
10921 root2.walk(function(i2) {
10922 if (i2.type !== "decl") {
10923 value = i2.raws.between;
10924 if (typeof value !== "undefined") return false;
10925 }
10926 });
10927 return value;
10928 };
10929 _proto.rawBeforeRule = function rawBeforeRule(root2) {
10930 var value;
10931 root2.walk(function(i2) {
10932 if (i2.nodes && (i2.parent !== root2 || root2.first !== i2)) {
10933 if (typeof i2.raws.before !== "undefined") {
10934 value = i2.raws.before;
10935 if (value.includes("\n")) {
10936 value = value.replace(/[^\n]+$/, "");
10937 }
10938 return false;
10939 }
10940 }
10941 });
10942 if (value) value = value.replace(/\S/g, "");
10943 return value;
10944 };
10945 _proto.rawColon = function rawColon(root2) {
10946 var value;
10947 root2.walkDecls(function(i2) {
10948 if (typeof i2.raws.between !== "undefined") {
10949 value = i2.raws.between.replace(/[^\s:]/g, "");
10950 return false;
10951 }
10952 });
10953 return value;
10954 };
10955 _proto.rawEmptyBody = function rawEmptyBody(root2) {
10956 var value;
10957 root2.walk(function(i2) {
10958 if (i2.nodes && i2.nodes.length === 0) {
10959 value = i2.raws.after;
10960 if (typeof value !== "undefined") return false;
10961 }
10962 });
10963 return value;
10964 };
10965 _proto.rawIndent = function rawIndent(root2) {
10966 if (root2.raws.indent) return root2.raws.indent;
10967 var value;
10968 root2.walk(function(i2) {
10969 var p = i2.parent;
10970 if (p && p !== root2 && p.parent && p.parent === root2) {
10971 if (typeof i2.raws.before !== "undefined") {
10972 var parts = i2.raws.before.split("\n");
10973 value = parts[parts.length - 1];
10974 value = value.replace(/\S/g, "");
10975 return false;
10976 }
10977 }
10978 });
10979 return value;
10980 };
10981 _proto.rawSemicolon = function rawSemicolon(root2) {
10982 var value;
10983 root2.walk(function(i2) {
10984 if (i2.nodes && i2.nodes.length && i2.last.type === "decl") {
10985 value = i2.raws.semicolon;
10986 if (typeof value !== "undefined") return false;
10987 }
10988 });
10989 return value;
10990 };
10991 _proto.rawValue = function rawValue(node2, prop) {
10992 var value = node2[prop];
10993 var raw = node2.raws[prop];
10994 if (raw && raw.value === value) {
10995 return raw.raw;
10996 }
10997 return value;
10998 };
10999 _proto.root = function root(node2) {
11000 this.body(node2);
11001 if (node2.raws.after) this.builder(node2.raws.after);
11002 };
11003 _proto.rule = function rule(node2) {
11004 this.block(node2, this.rawValue(node2, "selector"));
11005 if (node2.raws.ownSemicolon) {
11006 this.builder(node2.raws.ownSemicolon, node2, "end");
11007 }
11008 };
11009 _proto.stringify = function stringify(node2, semicolon) {
11010 if (!this[node2.type]) {
11011 throw new Error("Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier.");
11012 }
11013 this[node2.type](node2, semicolon);
11014 };
11015 return Stringifier;
11016 }();
11017 var stringifier$1 = Stringifier$2$1;
11018 Stringifier$2$1.default = Stringifier$2$1;
11019 var Stringifier$1$1 = stringifier$1;
11020 function stringify$4$1(node2, builder) {
11021 var str = new Stringifier$1$1(builder);
11022 str.stringify(node2);
11023 }
11024 var stringify_1$1 = stringify$4$1;
11025 stringify$4$1.default = stringify$4$1;
11026 var isClean$2$1 = symbols$1.isClean, my$2$1 = symbols$1.my;
11027 var CssSyntaxError$2$1 = cssSyntaxError$1;
11028 var Stringifier2$1 = stringifier$1;
11029 var stringify$3$1 = stringify_1$1;
11030 function cloneNode$1(obj, parent) {
11031 var cloned = new obj.constructor();
11032 for(var i2 in obj){
11033 if (!Object.prototype.hasOwnProperty.call(obj, i2)) {
11034 continue;
11035 }
11036 if (i2 === "proxyCache") continue;
11037 var value = obj[i2];
11038 var type = typeof value === "undefined" ? "undefined" : _type_of(value);
11039 if (i2 === "parent" && type === "object") {
11040 if (parent) cloned[i2] = parent;
11041 } else if (i2 === "source") {
11042 cloned[i2] = value;
11043 } else if (Array.isArray(value)) {
11044 cloned[i2] = value.map(function(j) {
11045 return cloneNode$1(j, cloned);
11046 });
11047 } else {
11048 if (type === "object" && value !== null) value = cloneNode$1(value);
11049 cloned[i2] = value;
11050 }
11051 }
11052 return cloned;
11053 }
11054 var Node$4$1 = /*#__PURE__*/ function() {
11055 function Node2(defaults) {
11056 if (defaults === void 0) defaults = {};
11057 this.raws = {};
11058 this[isClean$2$1] = false;
11059 this[my$2$1] = true;
11060 for(var name in defaults){
11061 if (name === "nodes") {
11062 this.nodes = [];
11063 for(var _iterator = _create_for_of_iterator_helper_loose(defaults[name]), _step; !(_step = _iterator()).done;){
11064 var node2 = _step.value;
11065 if (typeof node2.clone === "function") {
11066 this.append(node2.clone());
11067 } else {
11068 this.append(node2);
11069 }
11070 }
11071 } else {
11072 this[name] = defaults[name];
11073 }
11074 }
11075 }
11076 var _proto = Node2.prototype;
11077 _proto.addToError = function addToError(error) {
11078 error.postcssNode = this;
11079 if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
11080 var s2 = this.source;
11081 error.stack = error.stack.replace(/\n\s{4}at /, "$&" + s2.input.from + ":" + s2.start.line + ":" + s2.start.column + "$&");
11082 }
11083 return error;
11084 };
11085 _proto.after = function after(add) {
11086 this.parent.insertAfter(this, add);
11087 return this;
11088 };
11089 _proto.assign = function assign(overrides) {
11090 if (overrides === void 0) overrides = {};
11091 for(var name in overrides){
11092 this[name] = overrides[name];
11093 }
11094 return this;
11095 };
11096 _proto.before = function before(add) {
11097 this.parent.insertBefore(this, add);
11098 return this;
11099 };
11100 _proto.cleanRaws = function cleanRaws(keepBetween) {
11101 delete this.raws.before;
11102 delete this.raws.after;
11103 if (!keepBetween) delete this.raws.between;
11104 };
11105 _proto.clone = function clone(overrides) {
11106 if (overrides === void 0) overrides = {};
11107 var cloned = cloneNode$1(this);
11108 for(var name in overrides){
11109 cloned[name] = overrides[name];
11110 }
11111 return cloned;
11112 };
11113 _proto.cloneAfter = function cloneAfter(overrides) {
11114 if (overrides === void 0) overrides = {};
11115 var cloned = this.clone(overrides);
11116 this.parent.insertAfter(this, cloned);
11117 return cloned;
11118 };
11119 _proto.cloneBefore = function cloneBefore(overrides) {
11120 if (overrides === void 0) overrides = {};
11121 var cloned = this.clone(overrides);
11122 this.parent.insertBefore(this, cloned);
11123 return cloned;
11124 };
11125 _proto.error = function error(message, opts) {
11126 if (opts === void 0) opts = {};
11127 if (this.source) {
11128 var _this_rangeBy = this.rangeBy(opts), end = _this_rangeBy.end, start = _this_rangeBy.start;
11129 return this.source.input.error(message, {
11130 column: start.column,
11131 line: start.line
11132 }, {
11133 column: end.column,
11134 line: end.line
11135 }, opts);
11136 }
11137 return new CssSyntaxError$2$1(message);
11138 };
11139 _proto.getProxyProcessor = function getProxyProcessor() {
11140 return {
11141 get: function get(node2, prop) {
11142 if (prop === "proxyOf") {
11143 return node2;
11144 } else if (prop === "root") {
11145 return function() {
11146 return node2.root().toProxy();
11147 };
11148 } else {
11149 return node2[prop];
11150 }
11151 },
11152 set: function set(node2, prop, value) {
11153 if (node2[prop] === value) return true;
11154 node2[prop] = value;
11155 if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ prop === "text") {
11156 node2.markDirty();
11157 }
11158 return true;
11159 }
11160 };
11161 };
11162 _proto.markDirty = function markDirty() {
11163 if (this[isClean$2$1]) {
11164 this[isClean$2$1] = false;
11165 var next = this;
11166 while(next = next.parent){
11167 next[isClean$2$1] = false;
11168 }
11169 }
11170 };
11171 _proto.next = function next() {
11172 if (!this.parent) return void 0;
11173 var index2 = this.parent.index(this);
11174 return this.parent.nodes[index2 + 1];
11175 };
11176 _proto.positionBy = function positionBy(opts, stringRepresentation) {
11177 var pos = this.source.start;
11178 if (opts.index) {
11179 pos = this.positionInside(opts.index, stringRepresentation);
11180 } else if (opts.word) {
11181 stringRepresentation = this.toString();
11182 var index2 = stringRepresentation.indexOf(opts.word);
11183 if (index2 !== -1) pos = this.positionInside(index2, stringRepresentation);
11184 }
11185 return pos;
11186 };
11187 _proto.positionInside = function positionInside(index2, stringRepresentation) {
11188 var string = stringRepresentation || this.toString();
11189 var column = this.source.start.column;
11190 var line = this.source.start.line;
11191 for(var i2 = 0; i2 < index2; i2++){
11192 if (string[i2] === "\n") {
11193 column = 1;
11194 line += 1;
11195 } else {
11196 column += 1;
11197 }
11198 }
11199 return {
11200 column: column,
11201 line: line
11202 };
11203 };
11204 _proto.prev = function prev() {
11205 if (!this.parent) return void 0;
11206 var index2 = this.parent.index(this);
11207 return this.parent.nodes[index2 - 1];
11208 };
11209 _proto.rangeBy = function rangeBy(opts) {
11210 var start = {
11211 column: this.source.start.column,
11212 line: this.source.start.line
11213 };
11214 var end = this.source.end ? {
11215 column: this.source.end.column + 1,
11216 line: this.source.end.line
11217 } : {
11218 column: start.column + 1,
11219 line: start.line
11220 };
11221 if (opts.word) {
11222 var stringRepresentation = this.toString();
11223 var index2 = stringRepresentation.indexOf(opts.word);
11224 if (index2 !== -1) {
11225 start = this.positionInside(index2, stringRepresentation);
11226 end = this.positionInside(index2 + opts.word.length, stringRepresentation);
11227 }
11228 } else {
11229 if (opts.start) {
11230 start = {
11231 column: opts.start.column,
11232 line: opts.start.line
11233 };
11234 } else if (opts.index) {
11235 start = this.positionInside(opts.index);
11236 }
11237 if (opts.end) {
11238 end = {
11239 column: opts.end.column,
11240 line: opts.end.line
11241 };
11242 } else if (typeof opts.endIndex === "number") {
11243 end = this.positionInside(opts.endIndex);
11244 } else if (opts.index) {
11245 end = this.positionInside(opts.index + 1);
11246 }
11247 }
11248 if (end.line < start.line || end.line === start.line && end.column <= start.column) {
11249 end = {
11250 column: start.column + 1,
11251 line: start.line
11252 };
11253 }
11254 return {
11255 end: end,
11256 start: start
11257 };
11258 };
11259 _proto.raw = function raw(prop, defaultType) {
11260 var str = new Stringifier2$1();
11261 return str.raw(this, prop, defaultType);
11262 };
11263 _proto.remove = function remove() {
11264 if (this.parent) {
11265 this.parent.removeChild(this);
11266 }
11267 this.parent = void 0;
11268 return this;
11269 };
11270 _proto.replaceWith = function replaceWith() {
11271 for(var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++){
11272 nodes[_key] = arguments[_key];
11273 }
11274 if (this.parent) {
11275 var bookmark = this;
11276 var foundSelf = false;
11277 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
11278 var node2 = _step.value;
11279 if (node2 === this) {
11280 foundSelf = true;
11281 } else if (foundSelf) {
11282 this.parent.insertAfter(bookmark, node2);
11283 bookmark = node2;
11284 } else {
11285 this.parent.insertBefore(bookmark, node2);
11286 }
11287 }
11288 if (!foundSelf) {
11289 this.remove();
11290 }
11291 }
11292 return this;
11293 };
11294 _proto.root = function root() {
11295 var result2 = this;
11296 while(result2.parent && result2.parent.type !== "document"){
11297 result2 = result2.parent;
11298 }
11299 return result2;
11300 };
11301 _proto.toJSON = function toJSON(_, inputs) {
11302 var fixed = {};
11303 var emitInputs = inputs == null;
11304 inputs = inputs || /* @__PURE__ */ new Map();
11305 var inputsNextIndex = 0;
11306 for(var name in this){
11307 if (!Object.prototype.hasOwnProperty.call(this, name)) {
11308 continue;
11309 }
11310 if (name === "parent" || name === "proxyCache") continue;
11311 var value = this[name];
11312 if (Array.isArray(value)) {
11313 fixed[name] = value.map(function(i2) {
11314 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.toJSON) {
11315 return i2.toJSON(null, inputs);
11316 } else {
11317 return i2;
11318 }
11319 });
11320 } else if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value.toJSON) {
11321 fixed[name] = value.toJSON(null, inputs);
11322 } else if (name === "source") {
11323 var inputId = inputs.get(value.input);
11324 if (inputId == null) {
11325 inputId = inputsNextIndex;
11326 inputs.set(value.input, inputsNextIndex);
11327 inputsNextIndex++;
11328 }
11329 fixed[name] = {
11330 end: value.end,
11331 inputId: inputId,
11332 start: value.start
11333 };
11334 } else {
11335 fixed[name] = value;
11336 }
11337 }
11338 if (emitInputs) {
11339 fixed.inputs = [].concat(inputs.keys()).map(function(input2) {
11340 return input2.toJSON();
11341 });
11342 }
11343 return fixed;
11344 };
11345 _proto.toProxy = function toProxy() {
11346 if (!this.proxyCache) {
11347 this.proxyCache = new Proxy(this, this.getProxyProcessor());
11348 }
11349 return this.proxyCache;
11350 };
11351 _proto.toString = function toString(stringifier2) {
11352 if (stringifier2 === void 0) stringifier2 = stringify$3$1;
11353 if (stringifier2.stringify) stringifier2 = stringifier2.stringify;
11354 var result2 = "";
11355 stringifier2(this, function(i2) {
11356 result2 += i2;
11357 });
11358 return result2;
11359 };
11360 _proto.warn = function warn(result2, text, opts) {
11361 var data = {
11362 node: this
11363 };
11364 for(var i2 in opts)data[i2] = opts[i2];
11365 return result2.warn(text, data);
11366 };
11367 _create_class(Node2, [
11368 {
11369 key: "proxyOf",
11370 get: function get() {
11371 return this;
11372 }
11373 }
11374 ]);
11375 return Node2;
11376 }();
11377 var node$1 = Node$4$1;
11378 Node$4$1.default = Node$4$1;
11379 var Node$3$1 = node$1;
11380 var Declaration$4$1 = /*#__PURE__*/ function(Node$3$1) {
11381 _inherits(Declaration, Node$3$1);
11382 function Declaration(defaults) {
11383 var _this;
11384 if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
11385 defaults = _extends({}, defaults, {
11386 value: String(defaults.value)
11387 });
11388 }
11389 _this = Node$3$1.call(this, defaults) || this;
11390 _this.type = "decl";
11391 return _this;
11392 }
11393 _create_class(Declaration, [
11394 {
11395 key: "variable",
11396 get: function get() {
11397 return this.prop.startsWith("--") || this.prop[0] === "$";
11398 }
11399 }
11400 ]);
11401 return Declaration;
11402 }(Node$3$1);
11403 var declaration$1 = Declaration$4$1;
11404 Declaration$4$1.default = Declaration$4$1;
11405 var urlAlphabet$1 = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
11406 var nanoid$1$1 = function(size) {
11407 if (size === void 0) size = 21;
11408 var id = "";
11409 var i2 = size;
11410 while(i2--){
11411 id += urlAlphabet$1[Math.random() * 64 | 0];
11412 }
11413 return id;
11414 };
11415 var nonSecure$1 = {
11416 nanoid: nanoid$1$1};
11417 var SourceMapConsumer$2$1 = require$$2$1.SourceMapConsumer, SourceMapGenerator$2$1 = require$$2$1.SourceMapGenerator;
11418 var existsSync$1 = require$$2$1.existsSync, readFileSync$1 = require$$2$1.readFileSync;
11419 var dirname$1$1 = require$$2$1.dirname, join$1 = require$$2$1.join;
11420 function fromBase64$1(str) {
11421 if (Buffer) {
11422 return Buffer.from(str, "base64").toString();
11423 } else {
11424 return window.atob(str);
11425 }
11426 }
11427 var PreviousMap$2$1 = /*#__PURE__*/ function() {
11428 function PreviousMap(css, opts) {
11429 if (opts.map === false) return;
11430 this.loadAnnotation(css);
11431 this.inline = this.startWith(this.annotation, "data:");
11432 var prev = opts.map ? opts.map.prev : void 0;
11433 var text = this.loadMap(opts.from, prev);
11434 if (!this.mapFile && opts.from) {
11435 this.mapFile = opts.from;
11436 }
11437 if (this.mapFile) this.root = dirname$1$1(this.mapFile);
11438 if (text) this.text = text;
11439 }
11440 var _proto = PreviousMap.prototype;
11441 _proto.consumer = function consumer() {
11442 if (!this.consumerCache) {
11443 this.consumerCache = new SourceMapConsumer$2$1(this.text);
11444 }
11445 return this.consumerCache;
11446 };
11447 _proto.decodeInline = function decodeInline(text) {
11448 var baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
11449 var baseUri = /^data:application\/json;base64,/;
11450 var charsetUri = /^data:application\/json;charset=utf-?8,/;
11451 var uri = /^data:application\/json,/;
11452 if (charsetUri.test(text) || uri.test(text)) {
11453 return decodeURIComponent(text.substr(RegExp.lastMatch.length));
11454 }
11455 if (baseCharsetUri.test(text) || baseUri.test(text)) {
11456 return fromBase64$1(text.substr(RegExp.lastMatch.length));
11457 }
11458 var encoding = text.match(/data:application\/json;([^,]+),/)[1];
11459 throw new Error("Unsupported source map encoding " + encoding);
11460 };
11461 _proto.getAnnotationURL = function getAnnotationURL(sourceMapString) {
11462 return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
11463 };
11464 _proto.isMap = function isMap(map) {
11465 if ((typeof map === "undefined" ? "undefined" : _type_of(map)) !== "object") return false;
11466 return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
11467 };
11468 _proto.loadAnnotation = function loadAnnotation(css) {
11469 var comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
11470 if (!comments) return;
11471 var start = css.lastIndexOf(comments.pop());
11472 var end = css.indexOf("*/", start);
11473 if (start > -1 && end > -1) {
11474 this.annotation = this.getAnnotationURL(css.substring(start, end));
11475 }
11476 };
11477 _proto.loadFile = function loadFile(path) {
11478 this.root = dirname$1$1(path);
11479 if (existsSync$1(path)) {
11480 this.mapFile = path;
11481 return readFileSync$1(path, "utf-8").toString().trim();
11482 }
11483 };
11484 _proto.loadMap = function loadMap(file, prev) {
11485 if (prev === false) return false;
11486 if (prev) {
11487 if (typeof prev === "string") {
11488 return prev;
11489 } else if (typeof prev === "function") {
11490 var prevPath = prev(file);
11491 if (prevPath) {
11492 var map = this.loadFile(prevPath);
11493 if (!map) {
11494 throw new Error("Unable to load previous source map: " + prevPath.toString());
11495 }
11496 return map;
11497 }
11498 } else if (_instanceof(prev, SourceMapConsumer$2$1)) {
11499 return SourceMapGenerator$2$1.fromSourceMap(prev).toString();
11500 } else if (_instanceof(prev, SourceMapGenerator$2$1)) {
11501 return prev.toString();
11502 } else if (this.isMap(prev)) {
11503 return JSON.stringify(prev);
11504 } else {
11505 throw new Error("Unsupported previous source map format: " + prev.toString());
11506 }
11507 } else if (this.inline) {
11508 return this.decodeInline(this.annotation);
11509 } else if (this.annotation) {
11510 var map1 = this.annotation;
11511 if (file) map1 = join$1(dirname$1$1(file), map1);
11512 return this.loadFile(map1);
11513 }
11514 };
11515 _proto.startWith = function startWith(string, start) {
11516 if (!string) return false;
11517 return string.substr(0, start.length) === start;
11518 };
11519 _proto.withContent = function withContent() {
11520 return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
11521 };
11522 return PreviousMap;
11523 }();
11524 var previousMap$1 = PreviousMap$2$1;
11525 PreviousMap$2$1.default = PreviousMap$2$1;
11526 var SourceMapConsumer$1$1 = require$$2$1.SourceMapConsumer, SourceMapGenerator$1$1 = require$$2$1.SourceMapGenerator;
11527 var fileURLToPath$1 = require$$2$1.fileURLToPath, pathToFileURL$1$1 = require$$2$1.pathToFileURL;
11528 var isAbsolute$1 = require$$2$1.isAbsolute, resolve$1$1 = require$$2$1.resolve;
11529 var nanoid$2 = nonSecure$1.nanoid;
11530 var terminalHighlight$2 = require$$2$1;
11531 var CssSyntaxError$1$1 = cssSyntaxError$1;
11532 var PreviousMap$1$1 = previousMap$1;
11533 var fromOffsetCache$1 = Symbol("fromOffsetCache");
11534 var sourceMapAvailable$1$1 = Boolean(SourceMapConsumer$1$1 && SourceMapGenerator$1$1);
11535 var pathAvailable$1$1 = Boolean(resolve$1$1 && isAbsolute$1);
11536 var Input$4$1 = /*#__PURE__*/ function() {
11537 function Input(css, opts) {
11538 if (opts === void 0) opts = {};
11539 if (css === null || typeof css === "undefined" || (typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && !css.toString) {
11540 throw new Error("PostCSS received " + css + " instead of CSS string");
11541 }
11542 this.css = css.toString();
11543 if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
11544 this.hasBOM = true;
11545 this.css = this.css.slice(1);
11546 } else {
11547 this.hasBOM = false;
11548 }
11549 if (opts.from) {
11550 if (!pathAvailable$1$1 || /^\w+:\/\//.test(opts.from) || isAbsolute$1(opts.from)) {
11551 this.file = opts.from;
11552 } else {
11553 this.file = resolve$1$1(opts.from);
11554 }
11555 }
11556 if (pathAvailable$1$1 && sourceMapAvailable$1$1) {
11557 var map = new PreviousMap$1$1(this.css, opts);
11558 if (map.text) {
11559 this.map = map;
11560 var file = map.consumer().file;
11561 if (!this.file && file) this.file = this.mapResolve(file);
11562 }
11563 }
11564 if (!this.file) {
11565 this.id = "<input css " + nanoid$2(6) + ">";
11566 }
11567 if (this.map) this.map.file = this.from;
11568 }
11569 var _proto = Input.prototype;
11570 _proto.error = function error(message, line, column, opts) {
11571 if (opts === void 0) opts = {};
11572 var result2, endLine, endColumn;
11573 if (line && (typeof line === "undefined" ? "undefined" : _type_of(line)) === "object") {
11574 var start = line;
11575 var end = column;
11576 if (typeof start.offset === "number") {
11577 var pos = this.fromOffset(start.offset);
11578 line = pos.line;
11579 column = pos.col;
11580 } else {
11581 line = start.line;
11582 column = start.column;
11583 }
11584 if (typeof end.offset === "number") {
11585 var pos1 = this.fromOffset(end.offset);
11586 endLine = pos1.line;
11587 endColumn = pos1.col;
11588 } else {
11589 endLine = end.line;
11590 endColumn = end.column;
11591 }
11592 } else if (!column) {
11593 var pos2 = this.fromOffset(line);
11594 line = pos2.line;
11595 column = pos2.col;
11596 }
11597 var origin = this.origin(line, column, endLine, endColumn);
11598 if (origin) {
11599 result2 = new CssSyntaxError$1$1(message, origin.endLine === void 0 ? origin.line : {
11600 column: origin.column,
11601 line: origin.line
11602 }, origin.endLine === void 0 ? origin.column : {
11603 column: origin.endColumn,
11604 line: origin.endLine
11605 }, origin.source, origin.file, opts.plugin);
11606 } else {
11607 result2 = new CssSyntaxError$1$1(message, endLine === void 0 ? line : {
11608 column: column,
11609 line: line
11610 }, endLine === void 0 ? column : {
11611 column: endColumn,
11612 line: endLine
11613 }, this.css, this.file, opts.plugin);
11614 }
11615 result2.input = {
11616 column: column,
11617 endColumn: endColumn,
11618 endLine: endLine,
11619 line: line,
11620 source: this.css
11621 };
11622 if (this.file) {
11623 if (pathToFileURL$1$1) {
11624 result2.input.url = pathToFileURL$1$1(this.file).toString();
11625 }
11626 result2.input.file = this.file;
11627 }
11628 return result2;
11629 };
11630 _proto.fromOffset = function fromOffset(offset) {
11631 var lastLine, lineToIndex;
11632 if (!this[fromOffsetCache$1]) {
11633 var lines = this.css.split("\n");
11634 lineToIndex = new Array(lines.length);
11635 var prevIndex = 0;
11636 for(var i2 = 0, l2 = lines.length; i2 < l2; i2++){
11637 lineToIndex[i2] = prevIndex;
11638 prevIndex += lines[i2].length + 1;
11639 }
11640 this[fromOffsetCache$1] = lineToIndex;
11641 } else {
11642 lineToIndex = this[fromOffsetCache$1];
11643 }
11644 lastLine = lineToIndex[lineToIndex.length - 1];
11645 var min = 0;
11646 if (offset >= lastLine) {
11647 min = lineToIndex.length - 1;
11648 } else {
11649 var max = lineToIndex.length - 2;
11650 var mid;
11651 while(min < max){
11652 mid = min + (max - min >> 1);
11653 if (offset < lineToIndex[mid]) {
11654 max = mid - 1;
11655 } else if (offset >= lineToIndex[mid + 1]) {
11656 min = mid + 1;
11657 } else {
11658 min = mid;
11659 break;
11660 }
11661 }
11662 }
11663 return {
11664 col: offset - lineToIndex[min] + 1,
11665 line: min + 1
11666 };
11667 };
11668 _proto.mapResolve = function mapResolve(file) {
11669 if (/^\w+:\/\//.test(file)) {
11670 return file;
11671 }
11672 return resolve$1$1(this.map.consumer().sourceRoot || this.map.root || ".", file);
11673 };
11674 _proto.origin = function origin(line, column, endLine, endColumn) {
11675 if (!this.map) return false;
11676 var consumer = this.map.consumer();
11677 var from = consumer.originalPositionFor({
11678 column: column,
11679 line: line
11680 });
11681 if (!from.source) return false;
11682 var to;
11683 if (typeof endLine === "number") {
11684 to = consumer.originalPositionFor({
11685 column: endColumn,
11686 line: endLine
11687 });
11688 }
11689 var fromUrl;
11690 if (isAbsolute$1(from.source)) {
11691 fromUrl = pathToFileURL$1$1(from.source);
11692 } else {
11693 fromUrl = new URL(from.source, this.map.consumer().sourceRoot || pathToFileURL$1$1(this.map.mapFile));
11694 }
11695 var result2 = {
11696 column: from.column,
11697 endColumn: to && to.column,
11698 endLine: to && to.line,
11699 line: from.line,
11700 url: fromUrl.toString()
11701 };
11702 if (fromUrl.protocol === "file:") {
11703 if (fileURLToPath$1) {
11704 result2.file = fileURLToPath$1(fromUrl);
11705 } else {
11706 throw new Error("file: protocol is not available in this PostCSS build");
11707 }
11708 }
11709 var source = consumer.sourceContentFor(from.source);
11710 if (source) result2.source = source;
11711 return result2;
11712 };
11713 _proto.toJSON = function toJSON() {
11714 var json = {};
11715 for(var _i = 0, _iter = [
11716 "hasBOM",
11717 "css",
11718 "file",
11719 "id"
11720 ]; _i < _iter.length; _i++){
11721 var name = _iter[_i];
11722 if (this[name] != null) {
11723 json[name] = this[name];
11724 }
11725 }
11726 if (this.map) {
11727 json.map = _extends({}, this.map);
11728 if (json.map.consumerCache) {
11729 json.map.consumerCache = void 0;
11730 }
11731 }
11732 return json;
11733 };
11734 _create_class(Input, [
11735 {
11736 key: "from",
11737 get: function get() {
11738 return this.file || this.id;
11739 }
11740 }
11741 ]);
11742 return Input;
11743 }();
11744 var input$1 = Input$4$1;
11745 Input$4$1.default = Input$4$1;
11746 if (terminalHighlight$2 && terminalHighlight$2.registerInput) {
11747 terminalHighlight$2.registerInput(Input$4$1);
11748 }
11749 var SourceMapConsumer$3 = require$$2$1.SourceMapConsumer, SourceMapGenerator$3 = require$$2$1.SourceMapGenerator;
11750 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;
11751 var pathToFileURL$2 = require$$2$1.pathToFileURL;
11752 var Input$3$1 = input$1;
11753 var sourceMapAvailable$2 = Boolean(SourceMapConsumer$3 && SourceMapGenerator$3);
11754 var pathAvailable$2 = Boolean(dirname$2 && resolve$2 && relative$1 && sep$1);
11755 var MapGenerator$2$1 = /*#__PURE__*/ function() {
11756 function MapGenerator(stringify2, root2, opts, cssString) {
11757 this.stringify = stringify2;
11758 this.mapOpts = opts.map || {};
11759 this.root = root2;
11760 this.opts = opts;
11761 this.css = cssString;
11762 this.originalCSS = cssString;
11763 this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
11764 this.memoizedFileURLs = /* @__PURE__ */ new Map();
11765 this.memoizedPaths = /* @__PURE__ */ new Map();
11766 this.memoizedURLs = /* @__PURE__ */ new Map();
11767 }
11768 var _proto = MapGenerator.prototype;
11769 _proto.addAnnotation = function addAnnotation() {
11770 var content;
11771 if (this.isInline()) {
11772 content = "data:application/json;base64," + this.toBase64(this.map.toString());
11773 } else if (typeof this.mapOpts.annotation === "string") {
11774 content = this.mapOpts.annotation;
11775 } else if (typeof this.mapOpts.annotation === "function") {
11776 content = this.mapOpts.annotation(this.opts.to, this.root);
11777 } else {
11778 content = this.outputFile() + ".map";
11779 }
11780 var eol = "\n";
11781 if (this.css.includes("\r\n")) eol = "\r\n";
11782 this.css += eol + "/*# sourceMappingURL=" + content + " */";
11783 };
11784 _proto.applyPrevMaps = function applyPrevMaps() {
11785 for(var _iterator = _create_for_of_iterator_helper_loose(this.previous()), _step; !(_step = _iterator()).done;){
11786 var prev = _step.value;
11787 var from = this.toUrl(this.path(prev.file));
11788 var root2 = prev.root || dirname$2(prev.file);
11789 var map = void 0;
11790 if (this.mapOpts.sourcesContent === false) {
11791 map = new SourceMapConsumer$3(prev.text);
11792 if (map.sourcesContent) {
11793 map.sourcesContent = null;
11794 }
11795 } else {
11796 map = prev.consumer();
11797 }
11798 this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
11799 }
11800 };
11801 _proto.clearAnnotation = function clearAnnotation() {
11802 if (this.mapOpts.annotation === false) return;
11803 if (this.root) {
11804 var node2;
11805 for(var i2 = this.root.nodes.length - 1; i2 >= 0; i2--){
11806 node2 = this.root.nodes[i2];
11807 if (node2.type !== "comment") continue;
11808 if (node2.text.indexOf("# sourceMappingURL=") === 0) {
11809 this.root.removeChild(i2);
11810 }
11811 }
11812 } else if (this.css) {
11813 this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, "");
11814 }
11815 };
11816 _proto.generate = function generate() {
11817 this.clearAnnotation();
11818 if (pathAvailable$2 && sourceMapAvailable$2 && this.isMap()) {
11819 return this.generateMap();
11820 } else {
11821 var result2 = "";
11822 this.stringify(this.root, function(i2) {
11823 result2 += i2;
11824 });
11825 return [
11826 result2
11827 ];
11828 }
11829 };
11830 _proto.generateMap = function generateMap() {
11831 if (this.root) {
11832 this.generateString();
11833 } else if (this.previous().length === 1) {
11834 var prev = this.previous()[0].consumer();
11835 prev.file = this.outputFile();
11836 this.map = SourceMapGenerator$3.fromSourceMap(prev, {
11837 ignoreInvalidMapping: true
11838 });
11839 } else {
11840 this.map = new SourceMapGenerator$3({
11841 file: this.outputFile(),
11842 ignoreInvalidMapping: true
11843 });
11844 this.map.addMapping({
11845 generated: {
11846 column: 0,
11847 line: 1
11848 },
11849 original: {
11850 column: 0,
11851 line: 1
11852 },
11853 source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
11854 });
11855 }
11856 if (this.isSourcesContent()) this.setSourcesContent();
11857 if (this.root && this.previous().length > 0) this.applyPrevMaps();
11858 if (this.isAnnotation()) this.addAnnotation();
11859 if (this.isInline()) {
11860 return [
11861 this.css
11862 ];
11863 } else {
11864 return [
11865 this.css,
11866 this.map
11867 ];
11868 }
11869 };
11870 _proto.generateString = function generateString() {
11871 var _this = this;
11872 this.css = "";
11873 this.map = new SourceMapGenerator$3({
11874 file: this.outputFile(),
11875 ignoreInvalidMapping: true
11876 });
11877 var line = 1;
11878 var column = 1;
11879 var noSource = "<no source>";
11880 var mapping = {
11881 generated: {
11882 column: 0,
11883 line: 0
11884 },
11885 original: {
11886 column: 0,
11887 line: 0
11888 },
11889 source: ""
11890 };
11891 var lines, last;
11892 this.stringify(this.root, function(str, node2, type) {
11893 _this.css += str;
11894 if (node2 && type !== "end") {
11895 mapping.generated.line = line;
11896 mapping.generated.column = column - 1;
11897 if (node2.source && node2.source.start) {
11898 mapping.source = _this.sourcePath(node2);
11899 mapping.original.line = node2.source.start.line;
11900 mapping.original.column = node2.source.start.column - 1;
11901 _this.map.addMapping(mapping);
11902 } else {
11903 mapping.source = noSource;
11904 mapping.original.line = 1;
11905 mapping.original.column = 0;
11906 _this.map.addMapping(mapping);
11907 }
11908 }
11909 lines = str.match(/\n/g);
11910 if (lines) {
11911 line += lines.length;
11912 last = str.lastIndexOf("\n");
11913 column = str.length - last;
11914 } else {
11915 column += str.length;
11916 }
11917 if (node2 && type !== "start") {
11918 var p = node2.parent || {
11919 raws: {}
11920 };
11921 var childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
11922 if (!childless || node2 !== p.last || p.raws.semicolon) {
11923 if (node2.source && node2.source.end) {
11924 mapping.source = _this.sourcePath(node2);
11925 mapping.original.line = node2.source.end.line;
11926 mapping.original.column = node2.source.end.column - 1;
11927 mapping.generated.line = line;
11928 mapping.generated.column = column - 2;
11929 _this.map.addMapping(mapping);
11930 } else {
11931 mapping.source = noSource;
11932 mapping.original.line = 1;
11933 mapping.original.column = 0;
11934 mapping.generated.line = line;
11935 mapping.generated.column = column - 1;
11936 _this.map.addMapping(mapping);
11937 }
11938 }
11939 }
11940 });
11941 };
11942 _proto.isAnnotation = function isAnnotation() {
11943 if (this.isInline()) {
11944 return true;
11945 }
11946 if (typeof this.mapOpts.annotation !== "undefined") {
11947 return this.mapOpts.annotation;
11948 }
11949 if (this.previous().length) {
11950 return this.previous().some(function(i2) {
11951 return i2.annotation;
11952 });
11953 }
11954 return true;
11955 };
11956 _proto.isInline = function isInline() {
11957 if (typeof this.mapOpts.inline !== "undefined") {
11958 return this.mapOpts.inline;
11959 }
11960 var annotation = this.mapOpts.annotation;
11961 if (typeof annotation !== "undefined" && annotation !== true) {
11962 return false;
11963 }
11964 if (this.previous().length) {
11965 return this.previous().some(function(i2) {
11966 return i2.inline;
11967 });
11968 }
11969 return true;
11970 };
11971 _proto.isMap = function isMap() {
11972 if (typeof this.opts.map !== "undefined") {
11973 return !!this.opts.map;
11974 }
11975 return this.previous().length > 0;
11976 };
11977 _proto.isSourcesContent = function isSourcesContent() {
11978 if (typeof this.mapOpts.sourcesContent !== "undefined") {
11979 return this.mapOpts.sourcesContent;
11980 }
11981 if (this.previous().length) {
11982 return this.previous().some(function(i2) {
11983 return i2.withContent();
11984 });
11985 }
11986 return true;
11987 };
11988 _proto.outputFile = function outputFile() {
11989 if (this.opts.to) {
11990 return this.path(this.opts.to);
11991 } else if (this.opts.from) {
11992 return this.path(this.opts.from);
11993 } else {
11994 return "to.css";
11995 }
11996 };
11997 _proto.path = function path(file) {
11998 if (this.mapOpts.absolute) return file;
11999 if (file.charCodeAt(0) === 60) return file;
12000 if (/^\w+:\/\//.test(file)) return file;
12001 var cached = this.memoizedPaths.get(file);
12002 if (cached) return cached;
12003 var from = this.opts.to ? dirname$2(this.opts.to) : ".";
12004 if (typeof this.mapOpts.annotation === "string") {
12005 from = dirname$2(resolve$2(from, this.mapOpts.annotation));
12006 }
12007 var path = relative$1(from, file);
12008 this.memoizedPaths.set(file, path);
12009 return path;
12010 };
12011 _proto.previous = function previous() {
12012 var _this = this;
12013 if (!this.previousMaps) {
12014 this.previousMaps = [];
12015 if (this.root) {
12016 this.root.walk(function(node2) {
12017 if (node2.source && node2.source.input.map) {
12018 var map = node2.source.input.map;
12019 if (!_this.previousMaps.includes(map)) {
12020 _this.previousMaps.push(map);
12021 }
12022 }
12023 });
12024 } else {
12025 var input2 = new Input$3$1(this.originalCSS, this.opts);
12026 if (input2.map) this.previousMaps.push(input2.map);
12027 }
12028 }
12029 return this.previousMaps;
12030 };
12031 _proto.setSourcesContent = function setSourcesContent() {
12032 var _this = this;
12033 var already = {};
12034 if (this.root) {
12035 this.root.walk(function(node2) {
12036 if (node2.source) {
12037 var from = node2.source.input.from;
12038 if (from && !already[from]) {
12039 already[from] = true;
12040 var fromUrl = _this.usesFileUrls ? _this.toFileUrl(from) : _this.toUrl(_this.path(from));
12041 _this.map.setSourceContent(fromUrl, node2.source.input.css);
12042 }
12043 }
12044 });
12045 } else if (this.css) {
12046 var from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
12047 this.map.setSourceContent(from, this.css);
12048 }
12049 };
12050 _proto.sourcePath = function sourcePath(node2) {
12051 if (this.mapOpts.from) {
12052 return this.toUrl(this.mapOpts.from);
12053 } else if (this.usesFileUrls) {
12054 return this.toFileUrl(node2.source.input.from);
12055 } else {
12056 return this.toUrl(this.path(node2.source.input.from));
12057 }
12058 };
12059 _proto.toBase64 = function toBase64(str) {
12060 if (Buffer) {
12061 return Buffer.from(str).toString("base64");
12062 } else {
12063 return window.btoa(unescape(encodeURIComponent(str)));
12064 }
12065 };
12066 _proto.toFileUrl = function toFileUrl(path) {
12067 var cached = this.memoizedFileURLs.get(path);
12068 if (cached) return cached;
12069 if (pathToFileURL$2) {
12070 var fileURL = pathToFileURL$2(path).toString();
12071 this.memoizedFileURLs.set(path, fileURL);
12072 return fileURL;
12073 } else {
12074 throw new Error("`map.absolute` option is not available in this PostCSS build");
12075 }
12076 };
12077 _proto.toUrl = function toUrl(path) {
12078 var cached = this.memoizedURLs.get(path);
12079 if (cached) return cached;
12080 if (sep$1 === "\\") {
12081 path = path.replace(/\\/g, "/");
12082 }
12083 var url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
12084 this.memoizedURLs.set(path, url);
12085 return url;
12086 };
12087 return MapGenerator;
12088 }();
12089 var mapGenerator$1 = MapGenerator$2$1;
12090 var Node$2$1 = node$1;
12091 var Comment$4$1 = /*#__PURE__*/ function(Node$2$1) {
12092 _inherits(Comment, Node$2$1);
12093 function Comment(defaults) {
12094 var _this;
12095 _this = Node$2$1.call(this, defaults) || this;
12096 _this.type = "comment";
12097 return _this;
12098 }
12099 return Comment;
12100 }(Node$2$1);
12101 var comment$1 = Comment$4$1;
12102 Comment$4$1.default = Comment$4$1;
12103 var isClean$1$1 = symbols$1.isClean, my$1$1 = symbols$1.my;
12104 var Declaration$3$1 = declaration$1;
12105 var Comment$3$1 = comment$1;
12106 var Node$1$1 = node$1;
12107 var parse$4$1, Rule$4$1, AtRule$4$1, Root$6$1;
12108 function cleanSource$1(nodes) {
12109 return nodes.map(function(i2) {
12110 if (i2.nodes) i2.nodes = cleanSource$1(i2.nodes);
12111 delete i2.source;
12112 return i2;
12113 });
12114 }
12115 function markDirtyUp$1(node2) {
12116 node2[isClean$1$1] = false;
12117 if (node2.proxyOf.nodes) {
12118 for(var _iterator = _create_for_of_iterator_helper_loose(node2.proxyOf.nodes), _step; !(_step = _iterator()).done;){
12119 var i2 = _step.value;
12120 markDirtyUp$1(i2);
12121 }
12122 }
12123 }
12124 var Container$7$1 = /*#__PURE__*/ function(Node$1$1) {
12125 _inherits(Container, Node$1$1);
12126 function Container() {
12127 return Node$1$1.apply(this, arguments) || this;
12128 }
12129 var _proto = Container.prototype;
12130 _proto.append = function append() {
12131 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12132 children[_key] = arguments[_key];
12133 }
12134 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
12135 var child = _step.value;
12136 var nodes = this.normalize(child, this.last);
12137 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
12138 var node2 = _step1.value;
12139 this.proxyOf.nodes.push(node2);
12140 }
12141 }
12142 this.markDirty();
12143 return this;
12144 };
12145 _proto.cleanRaws = function cleanRaws(keepBetween) {
12146 Node$1$1.prototype.cleanRaws.call(this, keepBetween);
12147 if (this.nodes) {
12148 for(var _iterator = _create_for_of_iterator_helper_loose(this.nodes), _step; !(_step = _iterator()).done;){
12149 var node2 = _step.value;
12150 node2.cleanRaws(keepBetween);
12151 }
12152 }
12153 };
12154 _proto.each = function each(callback) {
12155 if (!this.proxyOf.nodes) return void 0;
12156 var iterator = this.getIterator();
12157 var index2, result2;
12158 while(this.indexes[iterator] < this.proxyOf.nodes.length){
12159 index2 = this.indexes[iterator];
12160 result2 = callback(this.proxyOf.nodes[index2], index2);
12161 if (result2 === false) break;
12162 this.indexes[iterator] += 1;
12163 }
12164 delete this.indexes[iterator];
12165 return result2;
12166 };
12167 _proto.every = function every(condition) {
12168 return this.nodes.every(condition);
12169 };
12170 _proto.getIterator = function getIterator() {
12171 if (!this.lastEach) this.lastEach = 0;
12172 if (!this.indexes) this.indexes = {};
12173 this.lastEach += 1;
12174 var iterator = this.lastEach;
12175 this.indexes[iterator] = 0;
12176 return iterator;
12177 };
12178 _proto.getProxyProcessor = function getProxyProcessor() {
12179 return {
12180 get: function get(node2, prop) {
12181 if (prop === "proxyOf") {
12182 return node2;
12183 } else if (!node2[prop]) {
12184 return node2[prop];
12185 } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
12186 return function() {
12187 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
12188 args[_key] = arguments[_key];
12189 }
12190 var _node2;
12191 return (_node2 = node2)[prop].apply(_node2, [].concat(args.map(function(i2) {
12192 if (typeof i2 === "function") {
12193 return function(child, index2) {
12194 return i2(child.toProxy(), index2);
12195 };
12196 } else {
12197 return i2;
12198 }
12199 })));
12200 };
12201 } else if (prop === "every" || prop === "some") {
12202 return function(cb) {
12203 return node2[prop](function(child) {
12204 for(var _len = arguments.length, other = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
12205 other[_key - 1] = arguments[_key];
12206 }
12207 return cb.apply(void 0, [].concat([
12208 child.toProxy()
12209 ], other));
12210 });
12211 };
12212 } else if (prop === "root") {
12213 return function() {
12214 return node2.root().toProxy();
12215 };
12216 } else if (prop === "nodes") {
12217 return node2.nodes.map(function(i2) {
12218 return i2.toProxy();
12219 });
12220 } else if (prop === "first" || prop === "last") {
12221 return node2[prop].toProxy();
12222 } else {
12223 return node2[prop];
12224 }
12225 },
12226 set: function set(node2, prop, value) {
12227 if (node2[prop] === value) return true;
12228 node2[prop] = value;
12229 if (prop === "name" || prop === "params" || prop === "selector") {
12230 node2.markDirty();
12231 }
12232 return true;
12233 }
12234 };
12235 };
12236 _proto.index = function index(child) {
12237 if (typeof child === "number") return child;
12238 if (child.proxyOf) child = child.proxyOf;
12239 return this.proxyOf.nodes.indexOf(child);
12240 };
12241 _proto.insertAfter = function insertAfter(exist, add) {
12242 var existIndex = this.index(exist);
12243 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
12244 existIndex = this.index(exist);
12245 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12246 var node2 = _step.value;
12247 this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
12248 }
12249 var index2;
12250 for(var id in this.indexes){
12251 index2 = this.indexes[id];
12252 if (existIndex < index2) {
12253 this.indexes[id] = index2 + nodes.length;
12254 }
12255 }
12256 this.markDirty();
12257 return this;
12258 };
12259 _proto.insertBefore = function insertBefore(exist, add) {
12260 var existIndex = this.index(exist);
12261 var type = existIndex === 0 ? "prepend" : false;
12262 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
12263 existIndex = this.index(exist);
12264 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12265 var node2 = _step.value;
12266 this.proxyOf.nodes.splice(existIndex, 0, node2);
12267 }
12268 var index2;
12269 for(var id in this.indexes){
12270 index2 = this.indexes[id];
12271 if (existIndex <= index2) {
12272 this.indexes[id] = index2 + nodes.length;
12273 }
12274 }
12275 this.markDirty();
12276 return this;
12277 };
12278 _proto.normalize = function normalize(nodes, sample) {
12279 var _this = this;
12280 if (typeof nodes === "string") {
12281 nodes = cleanSource$1(parse$4$1(nodes).nodes);
12282 } else if (typeof nodes === "undefined") {
12283 nodes = [];
12284 } else if (Array.isArray(nodes)) {
12285 nodes = nodes.slice(0);
12286 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12287 var i2 = _step.value;
12288 if (i2.parent) i2.parent.removeChild(i2, "ignore");
12289 }
12290 } else if (nodes.type === "root" && this.type !== "document") {
12291 nodes = nodes.nodes.slice(0);
12292 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
12293 var i21 = _step1.value;
12294 if (i21.parent) i21.parent.removeChild(i21, "ignore");
12295 }
12296 } else if (nodes.type) {
12297 nodes = [
12298 nodes
12299 ];
12300 } else if (nodes.prop) {
12301 if (typeof nodes.value === "undefined") {
12302 throw new Error("Value field is missed in node creation");
12303 } else if (typeof nodes.value !== "string") {
12304 nodes.value = String(nodes.value);
12305 }
12306 nodes = [
12307 new Declaration$3$1(nodes)
12308 ];
12309 } else if (nodes.selector) {
12310 nodes = [
12311 new Rule$4$1(nodes)
12312 ];
12313 } else if (nodes.name) {
12314 nodes = [
12315 new AtRule$4$1(nodes)
12316 ];
12317 } else if (nodes.text) {
12318 nodes = [
12319 new Comment$3$1(nodes)
12320 ];
12321 } else {
12322 throw new Error("Unknown node type in node creation");
12323 }
12324 var processed = nodes.map(function(i2) {
12325 if (!i2[my$1$1]) Container.rebuild(i2);
12326 i2 = i2.proxyOf;
12327 if (i2.parent) i2.parent.removeChild(i2);
12328 if (i2[isClean$1$1]) markDirtyUp$1(i2);
12329 if (typeof i2.raws.before === "undefined") {
12330 if (sample && typeof sample.raws.before !== "undefined") {
12331 i2.raws.before = sample.raws.before.replace(/\S/g, "");
12332 }
12333 }
12334 i2.parent = _this.proxyOf;
12335 return i2;
12336 });
12337 return processed;
12338 };
12339 _proto.prepend = function prepend() {
12340 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12341 children[_key] = arguments[_key];
12342 }
12343 children = children.reverse();
12344 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
12345 var child = _step.value;
12346 var nodes = this.normalize(child, this.first, "prepend").reverse();
12347 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
12348 var node2 = _step1.value;
12349 this.proxyOf.nodes.unshift(node2);
12350 }
12351 for(var id in this.indexes){
12352 this.indexes[id] = this.indexes[id] + nodes.length;
12353 }
12354 }
12355 this.markDirty();
12356 return this;
12357 };
12358 _proto.push = function push(child) {
12359 child.parent = this;
12360 this.proxyOf.nodes.push(child);
12361 return this;
12362 };
12363 _proto.removeAll = function removeAll() {
12364 for(var _iterator = _create_for_of_iterator_helper_loose(this.proxyOf.nodes), _step; !(_step = _iterator()).done;){
12365 var node2 = _step.value;
12366 node2.parent = void 0;
12367 }
12368 this.proxyOf.nodes = [];
12369 this.markDirty();
12370 return this;
12371 };
12372 _proto.removeChild = function removeChild(child) {
12373 child = this.index(child);
12374 this.proxyOf.nodes[child].parent = void 0;
12375 this.proxyOf.nodes.splice(child, 1);
12376 var index2;
12377 for(var id in this.indexes){
12378 index2 = this.indexes[id];
12379 if (index2 >= child) {
12380 this.indexes[id] = index2 - 1;
12381 }
12382 }
12383 this.markDirty();
12384 return this;
12385 };
12386 _proto.replaceValues = function replaceValues(pattern, opts, callback) {
12387 if (!callback) {
12388 callback = opts;
12389 opts = {};
12390 }
12391 this.walkDecls(function(decl) {
12392 if (opts.props && !opts.props.includes(decl.prop)) return;
12393 if (opts.fast && !decl.value.includes(opts.fast)) return;
12394 decl.value = decl.value.replace(pattern, callback);
12395 });
12396 this.markDirty();
12397 return this;
12398 };
12399 _proto.some = function some(condition) {
12400 return this.nodes.some(condition);
12401 };
12402 _proto.walk = function walk(callback) {
12403 return this.each(function(child, i2) {
12404 var result2;
12405 try {
12406 result2 = callback(child, i2);
12407 } catch (e2) {
12408 throw child.addToError(e2);
12409 }
12410 if (result2 !== false && child.walk) {
12411 result2 = child.walk(callback);
12412 }
12413 return result2;
12414 });
12415 };
12416 _proto.walkAtRules = function walkAtRules(name, callback) {
12417 if (!callback) {
12418 callback = name;
12419 return this.walk(function(child, i2) {
12420 if (child.type === "atrule") {
12421 return callback(child, i2);
12422 }
12423 });
12424 }
12425 if (_instanceof(name, RegExp)) {
12426 return this.walk(function(child, i2) {
12427 if (child.type === "atrule" && name.test(child.name)) {
12428 return callback(child, i2);
12429 }
12430 });
12431 }
12432 return this.walk(function(child, i2) {
12433 if (child.type === "atrule" && child.name === name) {
12434 return callback(child, i2);
12435 }
12436 });
12437 };
12438 _proto.walkComments = function walkComments(callback) {
12439 return this.walk(function(child, i2) {
12440 if (child.type === "comment") {
12441 return callback(child, i2);
12442 }
12443 });
12444 };
12445 _proto.walkDecls = function walkDecls(prop, callback) {
12446 if (!callback) {
12447 callback = prop;
12448 return this.walk(function(child, i2) {
12449 if (child.type === "decl") {
12450 return callback(child, i2);
12451 }
12452 });
12453 }
12454 if (_instanceof(prop, RegExp)) {
12455 return this.walk(function(child, i2) {
12456 if (child.type === "decl" && prop.test(child.prop)) {
12457 return callback(child, i2);
12458 }
12459 });
12460 }
12461 return this.walk(function(child, i2) {
12462 if (child.type === "decl" && child.prop === prop) {
12463 return callback(child, i2);
12464 }
12465 });
12466 };
12467 _proto.walkRules = function walkRules(selector, callback) {
12468 if (!callback) {
12469 callback = selector;
12470 return this.walk(function(child, i2) {
12471 if (child.type === "rule") {
12472 return callback(child, i2);
12473 }
12474 });
12475 }
12476 if (_instanceof(selector, RegExp)) {
12477 return this.walk(function(child, i2) {
12478 if (child.type === "rule" && selector.test(child.selector)) {
12479 return callback(child, i2);
12480 }
12481 });
12482 }
12483 return this.walk(function(child, i2) {
12484 if (child.type === "rule" && child.selector === selector) {
12485 return callback(child, i2);
12486 }
12487 });
12488 };
12489 _create_class(Container, [
12490 {
12491 key: "first",
12492 get: function get() {
12493 if (!this.proxyOf.nodes) return void 0;
12494 return this.proxyOf.nodes[0];
12495 }
12496 },
12497 {
12498 key: "last",
12499 get: function get() {
12500 if (!this.proxyOf.nodes) return void 0;
12501 return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
12502 }
12503 }
12504 ]);
12505 return Container;
12506 }(Node$1$1);
12507 Container$7$1.registerParse = function(dependant) {
12508 parse$4$1 = dependant;
12509 };
12510 Container$7$1.registerRule = function(dependant) {
12511 Rule$4$1 = dependant;
12512 };
12513 Container$7$1.registerAtRule = function(dependant) {
12514 AtRule$4$1 = dependant;
12515 };
12516 Container$7$1.registerRoot = function(dependant) {
12517 Root$6$1 = dependant;
12518 };
12519 var container$1 = Container$7$1;
12520 Container$7$1.default = Container$7$1;
12521 Container$7$1.rebuild = function(node2) {
12522 if (node2.type === "atrule") {
12523 Object.setPrototypeOf(node2, AtRule$4$1.prototype);
12524 } else if (node2.type === "rule") {
12525 Object.setPrototypeOf(node2, Rule$4$1.prototype);
12526 } else if (node2.type === "decl") {
12527 Object.setPrototypeOf(node2, Declaration$3$1.prototype);
12528 } else if (node2.type === "comment") {
12529 Object.setPrototypeOf(node2, Comment$3$1.prototype);
12530 } else if (node2.type === "root") {
12531 Object.setPrototypeOf(node2, Root$6$1.prototype);
12532 }
12533 node2[my$1$1] = true;
12534 if (node2.nodes) {
12535 node2.nodes.forEach(function(child) {
12536 Container$7$1.rebuild(child);
12537 });
12538 }
12539 };
12540 var Container$6$1 = container$1;
12541 var LazyResult$4$1, Processor$3$1;
12542 var Document$3$1 = /*#__PURE__*/ function(Container$6$1) {
12543 _inherits(Document2, Container$6$1);
12544 function Document2(defaults) {
12545 var _this;
12546 _this = Container$6$1.call(this, _extends({
12547 type: "document"
12548 }, defaults)) || this;
12549 if (!_this.nodes) {
12550 _this.nodes = [];
12551 }
12552 return _this;
12553 }
12554 var _proto = Document2.prototype;
12555 _proto.toResult = function toResult(opts) {
12556 if (opts === void 0) opts = {};
12557 var lazy = new LazyResult$4$1(new Processor$3$1(), this, opts);
12558 return lazy.stringify();
12559 };
12560 return Document2;
12561 }(Container$6$1);
12562 Document$3$1.registerLazyResult = function(dependant) {
12563 LazyResult$4$1 = dependant;
12564 };
12565 Document$3$1.registerProcessor = function(dependant) {
12566 Processor$3$1 = dependant;
12567 };
12568 var document$1$1 = Document$3$1;
12569 Document$3$1.default = Document$3$1;
12570 var printed$1 = {};
12571 var warnOnce$2$1 = function warnOnce(message) {
12572 if (printed$1[message]) return;
12573 printed$1[message] = true;
12574 if (typeof console !== "undefined" && console.warn) {
12575 console.warn(message);
12576 }
12577 };
12578 var Warning$2$1 = /*#__PURE__*/ function() {
12579 function Warning(text, opts) {
12580 if (opts === void 0) opts = {};
12581 this.type = "warning";
12582 this.text = text;
12583 if (opts.node && opts.node.source) {
12584 var range = opts.node.rangeBy(opts);
12585 this.line = range.start.line;
12586 this.column = range.start.column;
12587 this.endLine = range.end.line;
12588 this.endColumn = range.end.column;
12589 }
12590 for(var opt in opts)this[opt] = opts[opt];
12591 }
12592 var _proto = Warning.prototype;
12593 _proto.toString = function toString() {
12594 if (this.node) {
12595 return this.node.error(this.text, {
12596 index: this.index,
12597 plugin: this.plugin,
12598 word: this.word
12599 }).message;
12600 }
12601 if (this.plugin) {
12602 return this.plugin + ": " + this.text;
12603 }
12604 return this.text;
12605 };
12606 return Warning;
12607 }();
12608 var warning$1 = Warning$2$1;
12609 Warning$2$1.default = Warning$2$1;
12610 var Warning$1$1 = warning$1;
12611 var Result$3$1 = /*#__PURE__*/ function() {
12612 function Result(processor2, root2, opts) {
12613 this.processor = processor2;
12614 this.messages = [];
12615 this.root = root2;
12616 this.opts = opts;
12617 this.css = void 0;
12618 this.map = void 0;
12619 }
12620 var _proto = Result.prototype;
12621 _proto.toString = function toString() {
12622 return this.css;
12623 };
12624 _proto.warn = function warn(text, opts) {
12625 if (opts === void 0) opts = {};
12626 if (!opts.plugin) {
12627 if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
12628 opts.plugin = this.lastPlugin.postcssPlugin;
12629 }
12630 }
12631 var warning2 = new Warning$1$1(text, opts);
12632 this.messages.push(warning2);
12633 return warning2;
12634 };
12635 _proto.warnings = function warnings() {
12636 return this.messages.filter(function(i2) {
12637 return i2.type === "warning";
12638 });
12639 };
12640 _create_class(Result, [
12641 {
12642 key: "content",
12643 get: function get() {
12644 return this.css;
12645 }
12646 }
12647 ]);
12648 return Result;
12649 }();
12650 var result$1 = Result$3$1;
12651 Result$3$1.default = Result$3$1;
12652 var SINGLE_QUOTE$1 = "'".charCodeAt(0);
12653 var DOUBLE_QUOTE$1 = '"'.charCodeAt(0);
12654 var BACKSLASH$1 = "\\".charCodeAt(0);
12655 var SLASH$1 = "/".charCodeAt(0);
12656 var NEWLINE$1 = "\n".charCodeAt(0);
12657 var SPACE$1 = " ".charCodeAt(0);
12658 var FEED$1 = "\f".charCodeAt(0);
12659 var TAB$1 = " ".charCodeAt(0);
12660 var CR$1 = "\r".charCodeAt(0);
12661 var OPEN_SQUARE$1 = "[".charCodeAt(0);
12662 var CLOSE_SQUARE$1 = "]".charCodeAt(0);
12663 var OPEN_PARENTHESES$1 = "(".charCodeAt(0);
12664 var CLOSE_PARENTHESES$1 = ")".charCodeAt(0);
12665 var OPEN_CURLY$1 = "{".charCodeAt(0);
12666 var CLOSE_CURLY$1 = "}".charCodeAt(0);
12667 var SEMICOLON$1 = ";".charCodeAt(0);
12668 var ASTERISK$1 = "*".charCodeAt(0);
12669 var COLON$1 = ":".charCodeAt(0);
12670 var AT$1 = "@".charCodeAt(0);
12671 var RE_AT_END$1 = /[\t\n\f\r "#'()/;[\\\]{}]/g;
12672 var RE_WORD_END$1 = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
12673 var RE_BAD_BRACKET$1 = /.[\r\n"'(/\\]/;
12674 var RE_HEX_ESCAPE$1 = /[\da-f]/i;
12675 var tokenize$1 = function tokenizer(input2, options) {
12676 if (options === void 0) options = {};
12677 var css = input2.css.valueOf();
12678 var ignore = options.ignoreErrors;
12679 var code, next, quote, content, escape;
12680 var escaped, escapePos, prev, n2, currentToken;
12681 var length = css.length;
12682 var pos = 0;
12683 var buffer = [];
12684 var returned = [];
12685 function position() {
12686 return pos;
12687 }
12688 function unclosed(what) {
12689 throw input2.error("Unclosed " + what, pos);
12690 }
12691 function endOfFile() {
12692 return returned.length === 0 && pos >= length;
12693 }
12694 function nextToken(opts) {
12695 if (returned.length) return returned.pop();
12696 if (pos >= length) return;
12697 var ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
12698 code = css.charCodeAt(pos);
12699 switch(code){
12700 case NEWLINE$1:
12701 case SPACE$1:
12702 case TAB$1:
12703 case CR$1:
12704 case FEED$1:
12705 {
12706 next = pos;
12707 do {
12708 next += 1;
12709 code = css.charCodeAt(next);
12710 }while (code === SPACE$1 || code === NEWLINE$1 || code === TAB$1 || code === CR$1 || code === FEED$1);
12711 currentToken = [
12712 "space",
12713 css.slice(pos, next)
12714 ];
12715 pos = next - 1;
12716 break;
12717 }
12718 case OPEN_SQUARE$1:
12719 case CLOSE_SQUARE$1:
12720 case OPEN_CURLY$1:
12721 case CLOSE_CURLY$1:
12722 case COLON$1:
12723 case SEMICOLON$1:
12724 case CLOSE_PARENTHESES$1:
12725 {
12726 var controlChar = String.fromCharCode(code);
12727 currentToken = [
12728 controlChar,
12729 controlChar,
12730 pos
12731 ];
12732 break;
12733 }
12734 case OPEN_PARENTHESES$1:
12735 {
12736 prev = buffer.length ? buffer.pop()[1] : "";
12737 n2 = css.charCodeAt(pos + 1);
12738 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) {
12739 next = pos;
12740 do {
12741 escaped = false;
12742 next = css.indexOf(")", next + 1);
12743 if (next === -1) {
12744 if (ignore || ignoreUnclosed) {
12745 next = pos;
12746 break;
12747 } else {
12748 unclosed("bracket");
12749 }
12750 }
12751 escapePos = next;
12752 while(css.charCodeAt(escapePos - 1) === BACKSLASH$1){
12753 escapePos -= 1;
12754 escaped = !escaped;
12755 }
12756 }while (escaped);
12757 currentToken = [
12758 "brackets",
12759 css.slice(pos, next + 1),
12760 pos,
12761 next
12762 ];
12763 pos = next;
12764 } else {
12765 next = css.indexOf(")", pos + 1);
12766 content = css.slice(pos, next + 1);
12767 if (next === -1 || RE_BAD_BRACKET$1.test(content)) {
12768 currentToken = [
12769 "(",
12770 "(",
12771 pos
12772 ];
12773 } else {
12774 currentToken = [
12775 "brackets",
12776 content,
12777 pos,
12778 next
12779 ];
12780 pos = next;
12781 }
12782 }
12783 break;
12784 }
12785 case SINGLE_QUOTE$1:
12786 case DOUBLE_QUOTE$1:
12787 {
12788 quote = code === SINGLE_QUOTE$1 ? "'" : '"';
12789 next = pos;
12790 do {
12791 escaped = false;
12792 next = css.indexOf(quote, next + 1);
12793 if (next === -1) {
12794 if (ignore || ignoreUnclosed) {
12795 next = pos + 1;
12796 break;
12797 } else {
12798 unclosed("string");
12799 }
12800 }
12801 escapePos = next;
12802 while(css.charCodeAt(escapePos - 1) === BACKSLASH$1){
12803 escapePos -= 1;
12804 escaped = !escaped;
12805 }
12806 }while (escaped);
12807 currentToken = [
12808 "string",
12809 css.slice(pos, next + 1),
12810 pos,
12811 next
12812 ];
12813 pos = next;
12814 break;
12815 }
12816 case AT$1:
12817 {
12818 RE_AT_END$1.lastIndex = pos + 1;
12819 RE_AT_END$1.test(css);
12820 if (RE_AT_END$1.lastIndex === 0) {
12821 next = css.length - 1;
12822 } else {
12823 next = RE_AT_END$1.lastIndex - 2;
12824 }
12825 currentToken = [
12826 "at-word",
12827 css.slice(pos, next + 1),
12828 pos,
12829 next
12830 ];
12831 pos = next;
12832 break;
12833 }
12834 case BACKSLASH$1:
12835 {
12836 next = pos;
12837 escape = true;
12838 while(css.charCodeAt(next + 1) === BACKSLASH$1){
12839 next += 1;
12840 escape = !escape;
12841 }
12842 code = css.charCodeAt(next + 1);
12843 if (escape && code !== SLASH$1 && code !== SPACE$1 && code !== NEWLINE$1 && code !== TAB$1 && code !== CR$1 && code !== FEED$1) {
12844 next += 1;
12845 if (RE_HEX_ESCAPE$1.test(css.charAt(next))) {
12846 while(RE_HEX_ESCAPE$1.test(css.charAt(next + 1))){
12847 next += 1;
12848 }
12849 if (css.charCodeAt(next + 1) === SPACE$1) {
12850 next += 1;
12851 }
12852 }
12853 }
12854 currentToken = [
12855 "word",
12856 css.slice(pos, next + 1),
12857 pos,
12858 next
12859 ];
12860 pos = next;
12861 break;
12862 }
12863 default:
12864 {
12865 if (code === SLASH$1 && css.charCodeAt(pos + 1) === ASTERISK$1) {
12866 next = css.indexOf("*/", pos + 2) + 1;
12867 if (next === 0) {
12868 if (ignore || ignoreUnclosed) {
12869 next = css.length;
12870 } else {
12871 unclosed("comment");
12872 }
12873 }
12874 currentToken = [
12875 "comment",
12876 css.slice(pos, next + 1),
12877 pos,
12878 next
12879 ];
12880 pos = next;
12881 } else {
12882 RE_WORD_END$1.lastIndex = pos + 1;
12883 RE_WORD_END$1.test(css);
12884 if (RE_WORD_END$1.lastIndex === 0) {
12885 next = css.length - 1;
12886 } else {
12887 next = RE_WORD_END$1.lastIndex - 2;
12888 }
12889 currentToken = [
12890 "word",
12891 css.slice(pos, next + 1),
12892 pos,
12893 next
12894 ];
12895 buffer.push(currentToken);
12896 pos = next;
12897 }
12898 break;
12899 }
12900 }
12901 pos++;
12902 return currentToken;
12903 }
12904 function back(token) {
12905 returned.push(token);
12906 }
12907 return {
12908 back: back,
12909 endOfFile: endOfFile,
12910 nextToken: nextToken,
12911 position: position
12912 };
12913 };
12914 var Container$5$1 = container$1;
12915 var AtRule$3$1 = /*#__PURE__*/ function(Container$5$1) {
12916 _inherits(AtRule, Container$5$1);
12917 function AtRule(defaults) {
12918 var _this;
12919 _this = Container$5$1.call(this, defaults) || this;
12920 _this.type = "atrule";
12921 return _this;
12922 }
12923 var _proto = AtRule.prototype;
12924 _proto.append = function append() {
12925 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12926 children[_key] = arguments[_key];
12927 }
12928 var _Container$5$1_prototype_append;
12929 if (!this.proxyOf.nodes) this.nodes = [];
12930 return (_Container$5$1_prototype_append = Container$5$1.prototype.append).call.apply(_Container$5$1_prototype_append, [].concat([
12931 this
12932 ], children));
12933 };
12934 _proto.prepend = function prepend() {
12935 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12936 children[_key] = arguments[_key];
12937 }
12938 var _Container$5$1_prototype_prepend;
12939 if (!this.proxyOf.nodes) this.nodes = [];
12940 return (_Container$5$1_prototype_prepend = Container$5$1.prototype.prepend).call.apply(_Container$5$1_prototype_prepend, [].concat([
12941 this
12942 ], children));
12943 };
12944 return AtRule;
12945 }(Container$5$1);
12946 var atRule$1 = AtRule$3$1;
12947 AtRule$3$1.default = AtRule$3$1;
12948 Container$5$1.registerAtRule(AtRule$3$1);
12949 var Container$4$1 = container$1;
12950 var LazyResult$3$1, Processor$2$1;
12951 var Root$5$1 = /*#__PURE__*/ function(Container$4$1) {
12952 _inherits(Root, Container$4$1);
12953 function Root(defaults) {
12954 var _this;
12955 _this = Container$4$1.call(this, defaults) || this;
12956 _this.type = "root";
12957 if (!_this.nodes) _this.nodes = [];
12958 return _this;
12959 }
12960 var _proto = Root.prototype;
12961 _proto.normalize = function normalize(child, sample, type) {
12962 var nodes = Container$4$1.prototype.normalize.call(this, child);
12963 if (sample) {
12964 if (type === "prepend") {
12965 if (this.nodes.length > 1) {
12966 sample.raws.before = this.nodes[1].raws.before;
12967 } else {
12968 delete sample.raws.before;
12969 }
12970 } else if (this.first !== sample) {
12971 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12972 var node2 = _step.value;
12973 node2.raws.before = sample.raws.before;
12974 }
12975 }
12976 }
12977 return nodes;
12978 };
12979 _proto.removeChild = function removeChild(child, ignore) {
12980 var index2 = this.index(child);
12981 if (!ignore && index2 === 0 && this.nodes.length > 1) {
12982 this.nodes[1].raws.before = this.nodes[index2].raws.before;
12983 }
12984 return Container$4$1.prototype.removeChild.call(this, child);
12985 };
12986 _proto.toResult = function toResult(opts) {
12987 if (opts === void 0) opts = {};
12988 var lazy = new LazyResult$3$1(new Processor$2$1(), this, opts);
12989 return lazy.stringify();
12990 };
12991 return Root;
12992 }(Container$4$1);
12993 Root$5$1.registerLazyResult = function(dependant) {
12994 LazyResult$3$1 = dependant;
12995 };
12996 Root$5$1.registerProcessor = function(dependant) {
12997 Processor$2$1 = dependant;
12998 };
12999 var root$1 = Root$5$1;
13000 Root$5$1.default = Root$5$1;
13001 Container$4$1.registerRoot(Root$5$1);
13002 var list$2$1 = {
13003 comma: function comma(string) {
13004 return list$2$1.split(string, [
13005 ","
13006 ], true);
13007 },
13008 space: function space(string) {
13009 var spaces = [
13010 " ",
13011 "\n",
13012 " "
13013 ];
13014 return list$2$1.split(string, spaces);
13015 },
13016 split: function split(string, separators, last) {
13017 var array = [];
13018 var current = "";
13019 var split = false;
13020 var func = 0;
13021 var inQuote = false;
13022 var prevQuote = "";
13023 var escape = false;
13024 for(var _iterator = _create_for_of_iterator_helper_loose(string), _step; !(_step = _iterator()).done;){
13025 var letter = _step.value;
13026 if (escape) {
13027 escape = false;
13028 } else if (letter === "\\") {
13029 escape = true;
13030 } else if (inQuote) {
13031 if (letter === prevQuote) {
13032 inQuote = false;
13033 }
13034 } else if (letter === '"' || letter === "'") {
13035 inQuote = true;
13036 prevQuote = letter;
13037 } else if (letter === "(") {
13038 func += 1;
13039 } else if (letter === ")") {
13040 if (func > 0) func -= 1;
13041 } else if (func === 0) {
13042 if (separators.includes(letter)) split = true;
13043 }
13044 if (split) {
13045 if (current !== "") array.push(current.trim());
13046 current = "";
13047 split = false;
13048 } else {
13049 current += letter;
13050 }
13051 }
13052 if (last || current !== "") array.push(current.trim());
13053 return array;
13054 }
13055 };
13056 var list_1$1 = list$2$1;
13057 list$2$1.default = list$2$1;
13058 var Container$3$1 = container$1;
13059 var list$1$1 = list_1$1;
13060 var Rule$3$1 = /*#__PURE__*/ function(Container$3$1) {
13061 _inherits(Rule, Container$3$1);
13062 function Rule(defaults) {
13063 var _this;
13064 _this = Container$3$1.call(this, defaults) || this;
13065 _this.type = "rule";
13066 if (!_this.nodes) _this.nodes = [];
13067 return _this;
13068 }
13069 _create_class(Rule, [
13070 {
13071 key: "selectors",
13072 get: function get() {
13073 return list$1$1.comma(this.selector);
13074 },
13075 set: function set(values) {
13076 var match = this.selector ? this.selector.match(/,\s*/) : null;
13077 var sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen");
13078 this.selector = values.join(sep2);
13079 }
13080 }
13081 ]);
13082 return Rule;
13083 }(Container$3$1);
13084 var rule$1 = Rule$3$1;
13085 Rule$3$1.default = Rule$3$1;
13086 Container$3$1.registerRule(Rule$3$1);
13087 var Declaration$2$1 = declaration$1;
13088 var tokenizer2$1 = tokenize$1;
13089 var Comment$2$1 = comment$1;
13090 var AtRule$2$1 = atRule$1;
13091 var Root$4$1 = root$1;
13092 var Rule$2$1 = rule$1;
13093 var SAFE_COMMENT_NEIGHBOR$1 = {
13094 empty: true,
13095 space: true
13096 };
13097 function findLastWithPosition$1(tokens) {
13098 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
13099 var token = tokens[i2];
13100 var pos = token[3] || token[2];
13101 if (pos) return pos;
13102 }
13103 }
13104 var Parser$1$1 = /*#__PURE__*/ function() {
13105 function Parser(input2) {
13106 this.input = input2;
13107 this.root = new Root$4$1();
13108 this.current = this.root;
13109 this.spaces = "";
13110 this.semicolon = false;
13111 this.createTokenizer();
13112 this.root.source = {
13113 input: input2,
13114 start: {
13115 column: 1,
13116 line: 1,
13117 offset: 0
13118 }
13119 };
13120 }
13121 var _proto = Parser.prototype;
13122 _proto.atrule = function atrule(token) {
13123 var node2 = new AtRule$2$1();
13124 node2.name = token[1].slice(1);
13125 if (node2.name === "") {
13126 this.unnamedAtrule(node2, token);
13127 }
13128 this.init(node2, token[2]);
13129 var type;
13130 var prev;
13131 var shift;
13132 var last = false;
13133 var open = false;
13134 var params = [];
13135 var brackets = [];
13136 while(!this.tokenizer.endOfFile()){
13137 token = this.tokenizer.nextToken();
13138 type = token[0];
13139 if (type === "(" || type === "[") {
13140 brackets.push(type === "(" ? ")" : "]");
13141 } else if (type === "{" && brackets.length > 0) {
13142 brackets.push("}");
13143 } else if (type === brackets[brackets.length - 1]) {
13144 brackets.pop();
13145 }
13146 if (brackets.length === 0) {
13147 if (type === ";") {
13148 node2.source.end = this.getPosition(token[2]);
13149 node2.source.end.offset++;
13150 this.semicolon = true;
13151 break;
13152 } else if (type === "{") {
13153 open = true;
13154 break;
13155 } else if (type === "}") {
13156 if (params.length > 0) {
13157 shift = params.length - 1;
13158 prev = params[shift];
13159 while(prev && prev[0] === "space"){
13160 prev = params[--shift];
13161 }
13162 if (prev) {
13163 node2.source.end = this.getPosition(prev[3] || prev[2]);
13164 node2.source.end.offset++;
13165 }
13166 }
13167 this.end(token);
13168 break;
13169 } else {
13170 params.push(token);
13171 }
13172 } else {
13173 params.push(token);
13174 }
13175 if (this.tokenizer.endOfFile()) {
13176 last = true;
13177 break;
13178 }
13179 }
13180 node2.raws.between = this.spacesAndCommentsFromEnd(params);
13181 if (params.length) {
13182 node2.raws.afterName = this.spacesAndCommentsFromStart(params);
13183 this.raw(node2, "params", params);
13184 if (last) {
13185 token = params[params.length - 1];
13186 node2.source.end = this.getPosition(token[3] || token[2]);
13187 node2.source.end.offset++;
13188 this.spaces = node2.raws.between;
13189 node2.raws.between = "";
13190 }
13191 } else {
13192 node2.raws.afterName = "";
13193 node2.params = "";
13194 }
13195 if (open) {
13196 node2.nodes = [];
13197 this.current = node2;
13198 }
13199 };
13200 _proto.checkMissedSemicolon = function checkMissedSemicolon(tokens) {
13201 var colon = this.colon(tokens);
13202 if (colon === false) return;
13203 var founded = 0;
13204 var token;
13205 for(var j = colon - 1; j >= 0; j--){
13206 token = tokens[j];
13207 if (token[0] !== "space") {
13208 founded += 1;
13209 if (founded === 2) break;
13210 }
13211 }
13212 throw this.input.error("Missed semicolon", token[0] === "word" ? token[3] + 1 : token[2]);
13213 };
13214 _proto.colon = function colon(tokens) {
13215 var brackets = 0;
13216 var token, type, prev;
13217 for(var _iterator = _create_for_of_iterator_helper_loose(tokens.entries()), _step; !(_step = _iterator()).done;){
13218 var _step_value = _step.value, i2 = _step_value[0], element = _step_value[1];
13219 token = element;
13220 type = token[0];
13221 if (type === "(") {
13222 brackets += 1;
13223 }
13224 if (type === ")") {
13225 brackets -= 1;
13226 }
13227 if (brackets === 0 && type === ":") {
13228 if (!prev) {
13229 this.doubleColon(token);
13230 } else if (prev[0] === "word" && prev[1] === "progid") {
13231 continue;
13232 } else {
13233 return i2;
13234 }
13235 }
13236 prev = token;
13237 }
13238 return false;
13239 };
13240 _proto.comment = function comment(token) {
13241 var node2 = new Comment$2$1();
13242 this.init(node2, token[2]);
13243 node2.source.end = this.getPosition(token[3] || token[2]);
13244 node2.source.end.offset++;
13245 var text = token[1].slice(2, -2);
13246 if (/^\s*$/.test(text)) {
13247 node2.text = "";
13248 node2.raws.left = text;
13249 node2.raws.right = "";
13250 } else {
13251 var match = text.match(/^(\s*)([^]*\S)(\s*)$/);
13252 node2.text = match[2];
13253 node2.raws.left = match[1];
13254 node2.raws.right = match[3];
13255 }
13256 };
13257 _proto.createTokenizer = function createTokenizer() {
13258 this.tokenizer = tokenizer2$1(this.input);
13259 };
13260 _proto.decl = function decl(tokens, customProperty) {
13261 var node2 = new Declaration$2$1();
13262 this.init(node2, tokens[0][2]);
13263 var last = tokens[tokens.length - 1];
13264 if (last[0] === ";") {
13265 this.semicolon = true;
13266 tokens.pop();
13267 }
13268 node2.source.end = this.getPosition(last[3] || last[2] || findLastWithPosition$1(tokens));
13269 node2.source.end.offset++;
13270 while(tokens[0][0] !== "word"){
13271 if (tokens.length === 1) this.unknownWord(tokens);
13272 node2.raws.before += tokens.shift()[1];
13273 }
13274 node2.source.start = this.getPosition(tokens[0][2]);
13275 node2.prop = "";
13276 while(tokens.length){
13277 var type = tokens[0][0];
13278 if (type === ":" || type === "space" || type === "comment") {
13279 break;
13280 }
13281 node2.prop += tokens.shift()[1];
13282 }
13283 node2.raws.between = "";
13284 var token;
13285 while(tokens.length){
13286 token = tokens.shift();
13287 if (token[0] === ":") {
13288 node2.raws.between += token[1];
13289 break;
13290 } else {
13291 if (token[0] === "word" && /\w/.test(token[1])) {
13292 this.unknownWord([
13293 token
13294 ]);
13295 }
13296 node2.raws.between += token[1];
13297 }
13298 }
13299 if (node2.prop[0] === "_" || node2.prop[0] === "*") {
13300 node2.raws.before += node2.prop[0];
13301 node2.prop = node2.prop.slice(1);
13302 }
13303 var firstSpaces = [];
13304 var next;
13305 while(tokens.length){
13306 next = tokens[0][0];
13307 if (next !== "space" && next !== "comment") break;
13308 firstSpaces.push(tokens.shift());
13309 }
13310 this.precheckMissedSemicolon(tokens);
13311 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
13312 token = tokens[i2];
13313 if (token[1].toLowerCase() === "!important") {
13314 node2.important = true;
13315 var string = this.stringFrom(tokens, i2);
13316 string = this.spacesFromEnd(tokens) + string;
13317 if (string !== " !important") node2.raws.important = string;
13318 break;
13319 } else if (token[1].toLowerCase() === "important") {
13320 var cache = tokens.slice(0);
13321 var str = "";
13322 for(var j = i2; j > 0; j--){
13323 var type1 = cache[j][0];
13324 if (str.trim().indexOf("!") === 0 && type1 !== "space") {
13325 break;
13326 }
13327 str = cache.pop()[1] + str;
13328 }
13329 if (str.trim().indexOf("!") === 0) {
13330 node2.important = true;
13331 node2.raws.important = str;
13332 tokens = cache;
13333 }
13334 }
13335 if (token[0] !== "space" && token[0] !== "comment") {
13336 break;
13337 }
13338 }
13339 var hasWord = tokens.some(function(i2) {
13340 return i2[0] !== "space" && i2[0] !== "comment";
13341 });
13342 if (hasWord) {
13343 node2.raws.between += firstSpaces.map(function(i2) {
13344 return i2[1];
13345 }).join("");
13346 firstSpaces = [];
13347 }
13348 this.raw(node2, "value", firstSpaces.concat(tokens), customProperty);
13349 if (node2.value.includes(":") && !customProperty) {
13350 this.checkMissedSemicolon(tokens);
13351 }
13352 };
13353 _proto.doubleColon = function doubleColon(token) {
13354 throw this.input.error("Double colon", {
13355 offset: token[2]
13356 }, {
13357 offset: token[2] + token[1].length
13358 });
13359 };
13360 _proto.emptyRule = function emptyRule(token) {
13361 var node2 = new Rule$2$1();
13362 this.init(node2, token[2]);
13363 node2.selector = "";
13364 node2.raws.between = "";
13365 this.current = node2;
13366 };
13367 _proto.end = function end(token) {
13368 if (this.current.nodes && this.current.nodes.length) {
13369 this.current.raws.semicolon = this.semicolon;
13370 }
13371 this.semicolon = false;
13372 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
13373 this.spaces = "";
13374 if (this.current.parent) {
13375 this.current.source.end = this.getPosition(token[2]);
13376 this.current.source.end.offset++;
13377 this.current = this.current.parent;
13378 } else {
13379 this.unexpectedClose(token);
13380 }
13381 };
13382 _proto.endFile = function endFile() {
13383 if (this.current.parent) this.unclosedBlock();
13384 if (this.current.nodes && this.current.nodes.length) {
13385 this.current.raws.semicolon = this.semicolon;
13386 }
13387 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
13388 this.root.source.end = this.getPosition(this.tokenizer.position());
13389 };
13390 _proto.freeSemicolon = function freeSemicolon(token) {
13391 this.spaces += token[1];
13392 if (this.current.nodes) {
13393 var prev = this.current.nodes[this.current.nodes.length - 1];
13394 if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
13395 prev.raws.ownSemicolon = this.spaces;
13396 this.spaces = "";
13397 }
13398 }
13399 };
13400 // Helpers
13401 _proto.getPosition = function getPosition(offset) {
13402 var pos = this.input.fromOffset(offset);
13403 return {
13404 column: pos.col,
13405 line: pos.line,
13406 offset: offset
13407 };
13408 };
13409 _proto.init = function init(node2, offset) {
13410 this.current.push(node2);
13411 node2.source = {
13412 input: this.input,
13413 start: this.getPosition(offset)
13414 };
13415 node2.raws.before = this.spaces;
13416 this.spaces = "";
13417 if (node2.type !== "comment") this.semicolon = false;
13418 };
13419 _proto.other = function other(start) {
13420 var end = false;
13421 var type = null;
13422 var colon = false;
13423 var bracket = null;
13424 var brackets = [];
13425 var customProperty = start[1].startsWith("--");
13426 var tokens = [];
13427 var token = start;
13428 while(token){
13429 type = token[0];
13430 tokens.push(token);
13431 if (type === "(" || type === "[") {
13432 if (!bracket) bracket = token;
13433 brackets.push(type === "(" ? ")" : "]");
13434 } else if (customProperty && colon && type === "{") {
13435 if (!bracket) bracket = token;
13436 brackets.push("}");
13437 } else if (brackets.length === 0) {
13438 if (type === ";") {
13439 if (colon) {
13440 this.decl(tokens, customProperty);
13441 return;
13442 } else {
13443 break;
13444 }
13445 } else if (type === "{") {
13446 this.rule(tokens);
13447 return;
13448 } else if (type === "}") {
13449 this.tokenizer.back(tokens.pop());
13450 end = true;
13451 break;
13452 } else if (type === ":") {
13453 colon = true;
13454 }
13455 } else if (type === brackets[brackets.length - 1]) {
13456 brackets.pop();
13457 if (brackets.length === 0) bracket = null;
13458 }
13459 token = this.tokenizer.nextToken();
13460 }
13461 if (this.tokenizer.endOfFile()) end = true;
13462 if (brackets.length > 0) this.unclosedBracket(bracket);
13463 if (end && colon) {
13464 if (!customProperty) {
13465 while(tokens.length){
13466 token = tokens[tokens.length - 1][0];
13467 if (token !== "space" && token !== "comment") break;
13468 this.tokenizer.back(tokens.pop());
13469 }
13470 }
13471 this.decl(tokens, customProperty);
13472 } else {
13473 this.unknownWord(tokens);
13474 }
13475 };
13476 _proto.parse = function parse() {
13477 var token;
13478 while(!this.tokenizer.endOfFile()){
13479 token = this.tokenizer.nextToken();
13480 switch(token[0]){
13481 case "space":
13482 this.spaces += token[1];
13483 break;
13484 case ";":
13485 this.freeSemicolon(token);
13486 break;
13487 case "}":
13488 this.end(token);
13489 break;
13490 case "comment":
13491 this.comment(token);
13492 break;
13493 case "at-word":
13494 this.atrule(token);
13495 break;
13496 case "{":
13497 this.emptyRule(token);
13498 break;
13499 default:
13500 this.other(token);
13501 break;
13502 }
13503 }
13504 this.endFile();
13505 };
13506 _proto.precheckMissedSemicolon = function precheckMissedSemicolon() {};
13507 _proto.raw = function raw(node2, prop, tokens, customProperty) {
13508 var token, type;
13509 var length = tokens.length;
13510 var value = "";
13511 var clean = true;
13512 var next, prev;
13513 for(var i2 = 0; i2 < length; i2 += 1){
13514 token = tokens[i2];
13515 type = token[0];
13516 if (type === "space" && i2 === length - 1 && !customProperty) {
13517 clean = false;
13518 } else if (type === "comment") {
13519 prev = tokens[i2 - 1] ? tokens[i2 - 1][0] : "empty";
13520 next = tokens[i2 + 1] ? tokens[i2 + 1][0] : "empty";
13521 if (!SAFE_COMMENT_NEIGHBOR$1[prev] && !SAFE_COMMENT_NEIGHBOR$1[next]) {
13522 if (value.slice(-1) === ",") {
13523 clean = false;
13524 } else {
13525 value += token[1];
13526 }
13527 } else {
13528 clean = false;
13529 }
13530 } else {
13531 value += token[1];
13532 }
13533 }
13534 if (!clean) {
13535 var raw = tokens.reduce(function(all, i2) {
13536 return all + i2[1];
13537 }, "");
13538 node2.raws[prop] = {
13539 raw: raw,
13540 value: value
13541 };
13542 }
13543 node2[prop] = value;
13544 };
13545 _proto.rule = function rule(tokens) {
13546 tokens.pop();
13547 var node2 = new Rule$2$1();
13548 this.init(node2, tokens[0][2]);
13549 node2.raws.between = this.spacesAndCommentsFromEnd(tokens);
13550 this.raw(node2, "selector", tokens);
13551 this.current = node2;
13552 };
13553 _proto.spacesAndCommentsFromEnd = function spacesAndCommentsFromEnd(tokens) {
13554 var lastTokenType;
13555 var spaces = "";
13556 while(tokens.length){
13557 lastTokenType = tokens[tokens.length - 1][0];
13558 if (lastTokenType !== "space" && lastTokenType !== "comment") break;
13559 spaces = tokens.pop()[1] + spaces;
13560 }
13561 return spaces;
13562 };
13563 // Errors
13564 _proto.spacesAndCommentsFromStart = function spacesAndCommentsFromStart(tokens) {
13565 var next;
13566 var spaces = "";
13567 while(tokens.length){
13568 next = tokens[0][0];
13569 if (next !== "space" && next !== "comment") break;
13570 spaces += tokens.shift()[1];
13571 }
13572 return spaces;
13573 };
13574 _proto.spacesFromEnd = function spacesFromEnd(tokens) {
13575 var lastTokenType;
13576 var spaces = "";
13577 while(tokens.length){
13578 lastTokenType = tokens[tokens.length - 1][0];
13579 if (lastTokenType !== "space") break;
13580 spaces = tokens.pop()[1] + spaces;
13581 }
13582 return spaces;
13583 };
13584 _proto.stringFrom = function stringFrom(tokens, from) {
13585 var result2 = "";
13586 for(var i2 = from; i2 < tokens.length; i2++){
13587 result2 += tokens[i2][1];
13588 }
13589 tokens.splice(from, tokens.length - from);
13590 return result2;
13591 };
13592 _proto.unclosedBlock = function unclosedBlock() {
13593 var pos = this.current.source.start;
13594 throw this.input.error("Unclosed block", pos.line, pos.column);
13595 };
13596 _proto.unclosedBracket = function unclosedBracket(bracket) {
13597 throw this.input.error("Unclosed bracket", {
13598 offset: bracket[2]
13599 }, {
13600 offset: bracket[2] + 1
13601 });
13602 };
13603 _proto.unexpectedClose = function unexpectedClose(token) {
13604 throw this.input.error("Unexpected }", {
13605 offset: token[2]
13606 }, {
13607 offset: token[2] + 1
13608 });
13609 };
13610 _proto.unknownWord = function unknownWord(tokens) {
13611 throw this.input.error("Unknown word", {
13612 offset: tokens[0][2]
13613 }, {
13614 offset: tokens[0][2] + tokens[0][1].length
13615 });
13616 };
13617 _proto.unnamedAtrule = function unnamedAtrule(node2, token) {
13618 throw this.input.error("At-rule without name", {
13619 offset: token[2]
13620 }, {
13621 offset: token[2] + token[1].length
13622 });
13623 };
13624 return Parser;
13625 }();
13626 var parser$1 = Parser$1$1;
13627 var Container$2$1 = container$1;
13628 var Parser2$1 = parser$1;
13629 var Input$2$1 = input$1;
13630 function parse$3$1(css, opts) {
13631 var input2 = new Input$2$1(css, opts);
13632 var parser2 = new Parser2$1(input2);
13633 try {
13634 parser2.parse();
13635 } catch (e2) {
13636 if (true) {
13637 if (e2.name === "CssSyntaxError" && opts && opts.from) {
13638 if (/\.scss$/i.test(opts.from)) {
13639 e2.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser";
13640 } else if (/\.sass/i.test(opts.from)) {
13641 e2.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser";
13642 } else if (/\.less$/i.test(opts.from)) {
13643 e2.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser";
13644 }
13645 }
13646 }
13647 throw e2;
13648 }
13649 return parser2.root;
13650 }
13651 var parse_1$1 = parse$3$1;
13652 parse$3$1.default = parse$3$1;
13653 Container$2$1.registerParse(parse$3$1);
13654 var isClean$3 = symbols$1.isClean, my$3 = symbols$1.my;
13655 var MapGenerator$1$1 = mapGenerator$1;
13656 var stringify$2$1 = stringify_1$1;
13657 var Container$1$1 = container$1;
13658 var Document$2$1 = document$1$1;
13659 var warnOnce$1$1 = warnOnce$2$1;
13660 var Result$2$1 = result$1;
13661 var parse$2$1 = parse_1$1;
13662 var Root$3$1 = root$1;
13663 var TYPE_TO_CLASS_NAME$1 = {
13664 atrule: "AtRule",
13665 comment: "Comment",
13666 decl: "Declaration",
13667 document: "Document",
13668 root: "Root",
13669 rule: "Rule"
13670 };
13671 var PLUGIN_PROPS$1 = {
13672 AtRule: true,
13673 AtRuleExit: true,
13674 Comment: true,
13675 CommentExit: true,
13676 Declaration: true,
13677 DeclarationExit: true,
13678 Document: true,
13679 DocumentExit: true,
13680 Once: true,
13681 OnceExit: true,
13682 postcssPlugin: true,
13683 prepare: true,
13684 Root: true,
13685 RootExit: true,
13686 Rule: true,
13687 RuleExit: true
13688 };
13689 var NOT_VISITORS$1 = {
13690 Once: true,
13691 postcssPlugin: true,
13692 prepare: true
13693 };
13694 var CHILDREN$1 = 0;
13695 function isPromise$1(obj) {
13696 return (typeof obj === "undefined" ? "undefined" : _type_of(obj)) === "object" && typeof obj.then === "function";
13697 }
13698 function getEvents$1(node2) {
13699 var key = false;
13700 var type = TYPE_TO_CLASS_NAME$1[node2.type];
13701 if (node2.type === "decl") {
13702 key = node2.prop.toLowerCase();
13703 } else if (node2.type === "atrule") {
13704 key = node2.name.toLowerCase();
13705 }
13706 if (key && node2.append) {
13707 return [
13708 type,
13709 type + "-" + key,
13710 CHILDREN$1,
13711 type + "Exit",
13712 type + "Exit-" + key
13713 ];
13714 } else if (key) {
13715 return [
13716 type,
13717 type + "-" + key,
13718 type + "Exit",
13719 type + "Exit-" + key
13720 ];
13721 } else if (node2.append) {
13722 return [
13723 type,
13724 CHILDREN$1,
13725 type + "Exit"
13726 ];
13727 } else {
13728 return [
13729 type,
13730 type + "Exit"
13731 ];
13732 }
13733 }
13734 function toStack$1(node2) {
13735 var events;
13736 if (node2.type === "document") {
13737 events = [
13738 "Document",
13739 CHILDREN$1,
13740 "DocumentExit"
13741 ];
13742 } else if (node2.type === "root") {
13743 events = [
13744 "Root",
13745 CHILDREN$1,
13746 "RootExit"
13747 ];
13748 } else {
13749 events = getEvents$1(node2);
13750 }
13751 return {
13752 eventIndex: 0,
13753 events: events,
13754 iterator: 0,
13755 node: node2,
13756 visitorIndex: 0,
13757 visitors: []
13758 };
13759 }
13760 function cleanMarks$1(node2) {
13761 node2[isClean$3] = false;
13762 if (node2.nodes) node2.nodes.forEach(function(i2) {
13763 return cleanMarks$1(i2);
13764 });
13765 return node2;
13766 }
13767 var postcss$2$1 = {};
13768 var LazyResult$2$1 = /*#__PURE__*/ function() {
13769 function LazyResult(processor2, css, opts) {
13770 var _this = this;
13771 this.stringified = false;
13772 this.processed = false;
13773 var root2;
13774 if ((typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && css !== null && (css.type === "root" || css.type === "document")) {
13775 root2 = cleanMarks$1(css);
13776 } else if (_instanceof(css, LazyResult) || _instanceof(css, Result$2$1)) {
13777 root2 = cleanMarks$1(css.root);
13778 if (css.map) {
13779 if (typeof opts.map === "undefined") opts.map = {};
13780 if (!opts.map.inline) opts.map.inline = false;
13781 opts.map.prev = css.map;
13782 }
13783 } else {
13784 var parser2 = parse$2$1;
13785 if (opts.syntax) parser2 = opts.syntax.parse;
13786 if (opts.parser) parser2 = opts.parser;
13787 if (parser2.parse) parser2 = parser2.parse;
13788 try {
13789 root2 = parser2(css, opts);
13790 } catch (error) {
13791 this.processed = true;
13792 this.error = error;
13793 }
13794 if (root2 && !root2[my$3]) {
13795 Container$1$1.rebuild(root2);
13796 }
13797 }
13798 this.result = new Result$2$1(processor2, root2, opts);
13799 this.helpers = _extends({}, postcss$2$1, {
13800 postcss: postcss$2$1,
13801 result: this.result
13802 });
13803 this.plugins = this.processor.plugins.map(function(plugin22) {
13804 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.prepare) {
13805 return _extends({}, plugin22, plugin22.prepare(_this.result));
13806 } else {
13807 return plugin22;
13808 }
13809 });
13810 }
13811 var _proto = LazyResult.prototype;
13812 _proto.async = function async() {
13813 if (this.error) return Promise.reject(this.error);
13814 if (this.processed) return Promise.resolve(this.result);
13815 if (!this.processing) {
13816 this.processing = this.runAsync();
13817 }
13818 return this.processing;
13819 };
13820 _proto.catch = function _catch(onRejected) {
13821 return this.async().catch(onRejected);
13822 };
13823 _proto.finally = function _finally(onFinally) {
13824 return this.async().then(onFinally, onFinally);
13825 };
13826 _proto.getAsyncError = function getAsyncError() {
13827 throw new Error("Use process(css).then(cb) to work with async plugins");
13828 };
13829 _proto.handleError = function handleError(error, node2) {
13830 var plugin22 = this.result.lastPlugin;
13831 try {
13832 if (node2) node2.addToError(error);
13833 this.error = error;
13834 if (error.name === "CssSyntaxError" && !error.plugin) {
13835 error.plugin = plugin22.postcssPlugin;
13836 error.setMessage();
13837 } else if (plugin22.postcssVersion) {
13838 if (true) {
13839 var pluginName = plugin22.postcssPlugin;
13840 var pluginVer = plugin22.postcssVersion;
13841 var runtimeVer = this.result.processor.version;
13842 var a2 = pluginVer.split(".");
13843 var b = runtimeVer.split(".");
13844 if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) {
13845 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.");
13846 }
13847 }
13848 }
13849 } catch (err) {
13850 if (console && console.error) console.error(err);
13851 }
13852 return error;
13853 };
13854 _proto.prepareVisitors = function prepareVisitors() {
13855 var _this = this;
13856 this.listeners = {};
13857 var add = function(plugin22, type, cb) {
13858 if (!_this.listeners[type]) _this.listeners[type] = [];
13859 _this.listeners[type].push([
13860 plugin22,
13861 cb
13862 ]);
13863 };
13864 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
13865 var plugin22 = _step.value;
13866 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object") {
13867 for(var event in plugin22){
13868 if (!PLUGIN_PROPS$1[event] && /^[A-Z]/.test(event)) {
13869 throw new Error("Unknown event " + event + " in " + plugin22.postcssPlugin + ". Try to update PostCSS (" + this.processor.version + " now).");
13870 }
13871 if (!NOT_VISITORS$1[event]) {
13872 if (_type_of(plugin22[event]) === "object") {
13873 for(var filter in plugin22[event]){
13874 if (filter === "*") {
13875 add(plugin22, event, plugin22[event][filter]);
13876 } else {
13877 add(plugin22, event + "-" + filter.toLowerCase(), plugin22[event][filter]);
13878 }
13879 }
13880 } else if (typeof plugin22[event] === "function") {
13881 add(plugin22, event, plugin22[event]);
13882 }
13883 }
13884 }
13885 }
13886 }
13887 this.hasListener = Object.keys(this.listeners).length > 0;
13888 };
13889 _proto.runAsync = function runAsync() {
13890 var _this = this;
13891 return _async_to_generator(function() {
13892 var i2, plugin22, promise, error, root2, stack, promise1, e2, node2, _loop, _iterator, _step;
13893 return _ts_generator(this, function(_state) {
13894 switch(_state.label){
13895 case 0:
13896 _this.plugin = 0;
13897 i2 = 0;
13898 _state.label = 1;
13899 case 1:
13900 if (!(i2 < _this.plugins.length)) return [
13901 3,
13902 6
13903 ];
13904 plugin22 = _this.plugins[i2];
13905 promise = _this.runOnRoot(plugin22);
13906 if (!isPromise$1(promise)) return [
13907 3,
13908 5
13909 ];
13910 _state.label = 2;
13911 case 2:
13912 _state.trys.push([
13913 2,
13914 4,
13915 ,
13916 5
13917 ]);
13918 return [
13919 4,
13920 promise
13921 ];
13922 case 3:
13923 _state.sent();
13924 return [
13925 3,
13926 5
13927 ];
13928 case 4:
13929 error = _state.sent();
13930 throw _this.handleError(error);
13931 case 5:
13932 i2++;
13933 return [
13934 3,
13935 1
13936 ];
13937 case 6:
13938 _this.prepareVisitors();
13939 if (!_this.hasListener) return [
13940 3,
13941 18
13942 ];
13943 root2 = _this.result.root;
13944 _state.label = 7;
13945 case 7:
13946 if (!!root2[isClean$3]) return [
13947 3,
13948 14
13949 ];
13950 root2[isClean$3] = true;
13951 stack = [
13952 toStack$1(root2)
13953 ];
13954 _state.label = 8;
13955 case 8:
13956 if (!(stack.length > 0)) return [
13957 3,
13958 13
13959 ];
13960 promise1 = _this.visitTick(stack);
13961 if (!isPromise$1(promise1)) return [
13962 3,
13963 12
13964 ];
13965 _state.label = 9;
13966 case 9:
13967 _state.trys.push([
13968 9,
13969 11,
13970 ,
13971 12
13972 ]);
13973 return [
13974 4,
13975 promise1
13976 ];
13977 case 10:
13978 _state.sent();
13979 return [
13980 3,
13981 12
13982 ];
13983 case 11:
13984 e2 = _state.sent();
13985 node2 = stack[stack.length - 1].node;
13986 throw _this.handleError(e2, node2);
13987 case 12:
13988 return [
13989 3,
13990 8
13991 ];
13992 case 13:
13993 return [
13994 3,
13995 7
13996 ];
13997 case 14:
13998 if (!_this.listeners.OnceExit) return [
13999 3,
14000 18
14001 ];
14002 _loop = function() {
14003 var _step_value, plugin22, visitor, roots, e2;
14004 return _ts_generator(this, function(_state) {
14005 switch(_state.label){
14006 case 0:
14007 _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
14008 _this.result.lastPlugin = plugin22;
14009 _state.label = 1;
14010 case 1:
14011 _state.trys.push([
14012 1,
14013 6,
14014 ,
14015 7
14016 ]);
14017 if (!(root2.type === "document")) return [
14018 3,
14019 3
14020 ];
14021 roots = root2.nodes.map(function(subRoot) {
14022 return visitor(subRoot, _this.helpers);
14023 });
14024 return [
14025 4,
14026 Promise.all(roots)
14027 ];
14028 case 2:
14029 _state.sent();
14030 return [
14031 3,
14032 5
14033 ];
14034 case 3:
14035 return [
14036 4,
14037 visitor(root2, _this.helpers)
14038 ];
14039 case 4:
14040 _state.sent();
14041 _state.label = 5;
14042 case 5:
14043 return [
14044 3,
14045 7
14046 ];
14047 case 6:
14048 e2 = _state.sent();
14049 throw _this.handleError(e2);
14050 case 7:
14051 return [
14052 2
14053 ];
14054 }
14055 });
14056 };
14057 _iterator = _create_for_of_iterator_helper_loose(_this.listeners.OnceExit);
14058 _state.label = 15;
14059 case 15:
14060 if (!!(_step = _iterator()).done) return [
14061 3,
14062 18
14063 ];
14064 return [
14065 5,
14066 _ts_values(_loop())
14067 ];
14068 case 16:
14069 _state.sent();
14070 _state.label = 17;
14071 case 17:
14072 return [
14073 3,
14074 15
14075 ];
14076 case 18:
14077 _this.processed = true;
14078 return [
14079 2,
14080 _this.stringify()
14081 ];
14082 }
14083 });
14084 })();
14085 };
14086 _proto.runOnRoot = function runOnRoot(plugin22) {
14087 var _this = this;
14088 this.result.lastPlugin = plugin22;
14089 try {
14090 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.Once) {
14091 if (this.result.root.type === "document") {
14092 var roots = this.result.root.nodes.map(function(root2) {
14093 return plugin22.Once(root2, _this.helpers);
14094 });
14095 if (isPromise$1(roots[0])) {
14096 return Promise.all(roots);
14097 }
14098 return roots;
14099 }
14100 return plugin22.Once(this.result.root, this.helpers);
14101 } else if (typeof plugin22 === "function") {
14102 return plugin22(this.result.root, this.result);
14103 }
14104 } catch (error) {
14105 throw this.handleError(error);
14106 }
14107 };
14108 _proto.stringify = function stringify() {
14109 if (this.error) throw this.error;
14110 if (this.stringified) return this.result;
14111 this.stringified = true;
14112 this.sync();
14113 var opts = this.result.opts;
14114 var str = stringify$2$1;
14115 if (opts.syntax) str = opts.syntax.stringify;
14116 if (opts.stringifier) str = opts.stringifier;
14117 if (str.stringify) str = str.stringify;
14118 var map = new MapGenerator$1$1(str, this.result.root, this.result.opts);
14119 var data = map.generate();
14120 this.result.css = data[0];
14121 this.result.map = data[1];
14122 return this.result;
14123 };
14124 _proto.sync = function sync() {
14125 if (this.error) throw this.error;
14126 if (this.processed) return this.result;
14127 this.processed = true;
14128 if (this.processing) {
14129 throw this.getAsyncError();
14130 }
14131 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
14132 var plugin22 = _step.value;
14133 var promise = this.runOnRoot(plugin22);
14134 if (isPromise$1(promise)) {
14135 throw this.getAsyncError();
14136 }
14137 }
14138 this.prepareVisitors();
14139 if (this.hasListener) {
14140 var root2 = this.result.root;
14141 while(!root2[isClean$3]){
14142 root2[isClean$3] = true;
14143 this.walkSync(root2);
14144 }
14145 if (this.listeners.OnceExit) {
14146 if (root2.type === "document") {
14147 for(var _iterator1 = _create_for_of_iterator_helper_loose(root2.nodes), _step1; !(_step1 = _iterator1()).done;){
14148 var subRoot = _step1.value;
14149 this.visitSync(this.listeners.OnceExit, subRoot);
14150 }
14151 } else {
14152 this.visitSync(this.listeners.OnceExit, root2);
14153 }
14154 }
14155 }
14156 return this.result;
14157 };
14158 _proto.then = function then(onFulfilled, onRejected) {
14159 if (true) {
14160 if (!("from" in this.opts)) {
14161 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.");
14162 }
14163 }
14164 return this.async().then(onFulfilled, onRejected);
14165 };
14166 _proto.toString = function toString() {
14167 return this.css;
14168 };
14169 _proto.visitSync = function visitSync(visitors, node2) {
14170 for(var _iterator = _create_for_of_iterator_helper_loose(visitors), _step; !(_step = _iterator()).done;){
14171 var _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
14172 this.result.lastPlugin = plugin22;
14173 var promise = void 0;
14174 try {
14175 promise = visitor(node2, this.helpers);
14176 } catch (e2) {
14177 throw this.handleError(e2, node2.proxyOf);
14178 }
14179 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
14180 return true;
14181 }
14182 if (isPromise$1(promise)) {
14183 throw this.getAsyncError();
14184 }
14185 }
14186 };
14187 _proto.visitTick = function visitTick(stack) {
14188 var visit2 = stack[stack.length - 1];
14189 var node2 = visit2.node, visitors = visit2.visitors;
14190 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
14191 stack.pop();
14192 return;
14193 }
14194 if (visitors.length > 0 && visit2.visitorIndex < visitors.length) {
14195 var _visitors_visit2_visitorIndex = visitors[visit2.visitorIndex], plugin22 = _visitors_visit2_visitorIndex[0], visitor = _visitors_visit2_visitorIndex[1];
14196 visit2.visitorIndex += 1;
14197 if (visit2.visitorIndex === visitors.length) {
14198 visit2.visitors = [];
14199 visit2.visitorIndex = 0;
14200 }
14201 this.result.lastPlugin = plugin22;
14202 try {
14203 return visitor(node2.toProxy(), this.helpers);
14204 } catch (e2) {
14205 throw this.handleError(e2, node2);
14206 }
14207 }
14208 if (visit2.iterator !== 0) {
14209 var iterator = visit2.iterator;
14210 var child;
14211 while(child = node2.nodes[node2.indexes[iterator]]){
14212 node2.indexes[iterator] += 1;
14213 if (!child[isClean$3]) {
14214 child[isClean$3] = true;
14215 stack.push(toStack$1(child));
14216 return;
14217 }
14218 }
14219 visit2.iterator = 0;
14220 delete node2.indexes[iterator];
14221 }
14222 var events = visit2.events;
14223 while(visit2.eventIndex < events.length){
14224 var event = events[visit2.eventIndex];
14225 visit2.eventIndex += 1;
14226 if (event === CHILDREN$1) {
14227 if (node2.nodes && node2.nodes.length) {
14228 node2[isClean$3] = true;
14229 visit2.iterator = node2.getIterator();
14230 }
14231 return;
14232 } else if (this.listeners[event]) {
14233 visit2.visitors = this.listeners[event];
14234 return;
14235 }
14236 }
14237 stack.pop();
14238 };
14239 _proto.walkSync = function walkSync(node2) {
14240 var _this = this;
14241 node2[isClean$3] = true;
14242 var events = getEvents$1(node2);
14243 for(var _iterator = _create_for_of_iterator_helper_loose(events), _step; !(_step = _iterator()).done;){
14244 var event = _step.value;
14245 if (event === CHILDREN$1) {
14246 if (node2.nodes) {
14247 node2.each(function(child) {
14248 if (!child[isClean$3]) _this.walkSync(child);
14249 });
14250 }
14251 } else {
14252 var visitors = this.listeners[event];
14253 if (visitors) {
14254 if (this.visitSync(visitors, node2.toProxy())) return;
14255 }
14256 }
14257 }
14258 };
14259 _proto.warnings = function warnings() {
14260 return this.sync().warnings();
14261 };
14262 _create_class(LazyResult, [
14263 {
14264 key: "content",
14265 get: function get() {
14266 return this.stringify().content;
14267 }
14268 },
14269 {
14270 key: "css",
14271 get: function get() {
14272 return this.stringify().css;
14273 }
14274 },
14275 {
14276 key: "map",
14277 get: function get() {
14278 return this.stringify().map;
14279 }
14280 },
14281 {
14282 key: "messages",
14283 get: function get() {
14284 return this.sync().messages;
14285 }
14286 },
14287 {
14288 key: "opts",
14289 get: function get() {
14290 return this.result.opts;
14291 }
14292 },
14293 {
14294 key: "processor",
14295 get: function get() {
14296 return this.result.processor;
14297 }
14298 },
14299 {
14300 key: "root",
14301 get: function get() {
14302 return this.sync().root;
14303 }
14304 },
14305 {
14306 key: Symbol.toStringTag,
14307 get: function get() {
14308 return "LazyResult";
14309 }
14310 }
14311 ]);
14312 return LazyResult;
14313 }();
14314 LazyResult$2$1.registerPostcss = function(dependant) {
14315 postcss$2$1 = dependant;
14316 };
14317 var lazyResult$1 = LazyResult$2$1;
14318 LazyResult$2$1.default = LazyResult$2$1;
14319 Root$3$1.registerLazyResult(LazyResult$2$1);
14320 Document$2$1.registerLazyResult(LazyResult$2$1);
14321 var MapGenerator2$1 = mapGenerator$1;
14322 var stringify$1$1 = stringify_1$1;
14323 var warnOnce2$1 = warnOnce$2$1;
14324 var parse$1$1 = parse_1$1;
14325 var Result$1$1 = result$1;
14326 var NoWorkResult$1$1 = /*#__PURE__*/ function() {
14327 function NoWorkResult(processor2, css, opts) {
14328 css = css.toString();
14329 this.stringified = false;
14330 this._processor = processor2;
14331 this._css = css;
14332 this._opts = opts;
14333 this._map = void 0;
14334 var root2;
14335 var str = stringify$1$1;
14336 this.result = new Result$1$1(this._processor, root2, this._opts);
14337 this.result.css = css;
14338 var self = this;
14339 Object.defineProperty(this.result, "root", {
14340 get: function get() {
14341 return self.root;
14342 }
14343 });
14344 var map = new MapGenerator2$1(str, root2, this._opts, css);
14345 if (map.isMap()) {
14346 var _map_generate = map.generate(), generatedCSS = _map_generate[0], generatedMap = _map_generate[1];
14347 if (generatedCSS) {
14348 this.result.css = generatedCSS;
14349 }
14350 if (generatedMap) {
14351 this.result.map = generatedMap;
14352 }
14353 } else {
14354 map.clearAnnotation();
14355 this.result.css = map.css;
14356 }
14357 }
14358 var _proto = NoWorkResult.prototype;
14359 _proto.async = function async() {
14360 if (this.error) return Promise.reject(this.error);
14361 return Promise.resolve(this.result);
14362 };
14363 _proto.catch = function _catch(onRejected) {
14364 return this.async().catch(onRejected);
14365 };
14366 _proto.finally = function _finally(onFinally) {
14367 return this.async().then(onFinally, onFinally);
14368 };
14369 _proto.sync = function sync() {
14370 if (this.error) throw this.error;
14371 return this.result;
14372 };
14373 _proto.then = function then(onFulfilled, onRejected) {
14374 if (true) {
14375 if (!("from" in this._opts)) {
14376 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.");
14377 }
14378 }
14379 return this.async().then(onFulfilled, onRejected);
14380 };
14381 _proto.toString = function toString() {
14382 return this._css;
14383 };
14384 _proto.warnings = function warnings() {
14385 return [];
14386 };
14387 _create_class(NoWorkResult, [
14388 {
14389 key: "content",
14390 get: function get() {
14391 return this.result.css;
14392 }
14393 },
14394 {
14395 key: "css",
14396 get: function get() {
14397 return this.result.css;
14398 }
14399 },
14400 {
14401 key: "map",
14402 get: function get() {
14403 return this.result.map;
14404 }
14405 },
14406 {
14407 key: "messages",
14408 get: function get() {
14409 return [];
14410 }
14411 },
14412 {
14413 key: "opts",
14414 get: function get() {
14415 return this.result.opts;
14416 }
14417 },
14418 {
14419 key: "processor",
14420 get: function get() {
14421 return this.result.processor;
14422 }
14423 },
14424 {
14425 key: "root",
14426 get: function get() {
14427 if (this._root) {
14428 return this._root;
14429 }
14430 var root2;
14431 var parser2 = parse$1$1;
14432 try {
14433 root2 = parser2(this._css, this._opts);
14434 } catch (error) {
14435 this.error = error;
14436 }
14437 if (this.error) {
14438 throw this.error;
14439 } else {
14440 this._root = root2;
14441 return root2;
14442 }
14443 }
14444 },
14445 {
14446 key: Symbol.toStringTag,
14447 get: function get() {
14448 return "NoWorkResult";
14449 }
14450 }
14451 ]);
14452 return NoWorkResult;
14453 }();
14454 var noWorkResult$1 = NoWorkResult$1$1;
14455 NoWorkResult$1$1.default = NoWorkResult$1$1;
14456 var NoWorkResult2$1 = noWorkResult$1;
14457 var LazyResult$1$1 = lazyResult$1;
14458 var Document$1$1 = document$1$1;
14459 var Root$2$1 = root$1;
14460 var Processor$1$1 = /*#__PURE__*/ function() {
14461 function Processor(plugins) {
14462 if (plugins === void 0) plugins = [];
14463 this.version = "8.4.38";
14464 this.plugins = this.normalize(plugins);
14465 }
14466 var _proto = Processor.prototype;
14467 _proto.normalize = function normalize(plugins) {
14468 var normalized = [];
14469 for(var _iterator = _create_for_of_iterator_helper_loose(plugins), _step; !(_step = _iterator()).done;){
14470 var i2 = _step.value;
14471 if (i2.postcss === true) {
14472 i2 = i2();
14473 } else if (i2.postcss) {
14474 i2 = i2.postcss;
14475 }
14476 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && Array.isArray(i2.plugins)) {
14477 normalized = normalized.concat(i2.plugins);
14478 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.postcssPlugin) {
14479 normalized.push(i2);
14480 } else if (typeof i2 === "function") {
14481 normalized.push(i2);
14482 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && (i2.parse || i2.stringify)) {
14483 if (true) {
14484 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.");
14485 }
14486 } else {
14487 throw new Error(i2 + " is not a PostCSS plugin");
14488 }
14489 }
14490 return normalized;
14491 };
14492 _proto.process = function process1(css, opts) {
14493 if (opts === void 0) opts = {};
14494 if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) {
14495 return new NoWorkResult2$1(this, css, opts);
14496 } else {
14497 return new LazyResult$1$1(this, css, opts);
14498 }
14499 };
14500 _proto.use = function use(plugin22) {
14501 this.plugins = this.plugins.concat(this.normalize([
14502 plugin22
14503 ]));
14504 return this;
14505 };
14506 return Processor;
14507 }();
14508 var processor$1 = Processor$1$1;
14509 Processor$1$1.default = Processor$1$1;
14510 Root$2$1.registerProcessor(Processor$1$1);
14511 Document$1$1.registerProcessor(Processor$1$1);
14512 var Declaration$1$1 = declaration$1;
14513 var PreviousMap2$1 = previousMap$1;
14514 var Comment$1$1 = comment$1;
14515 var AtRule$1$1 = atRule$1;
14516 var Input$1$1 = input$1;
14517 var Root$1$1 = root$1;
14518 var Rule$1$1 = rule$1;
14519 function fromJSON$1$1(json, inputs) {
14520 if (Array.isArray(json)) return json.map(function(n2) {
14521 return fromJSON$1$1(n2);
14522 });
14523 var ownInputs = json.inputs, defaults = _object_without_properties_loose(json, [
14524 "inputs"
14525 ]);
14526 if (ownInputs) {
14527 inputs = [];
14528 for(var _iterator = _create_for_of_iterator_helper_loose(ownInputs), _step; !(_step = _iterator()).done;){
14529 var input2 = _step.value;
14530 var inputHydrated = _extends({}, input2, {
14531 __proto__: Input$1$1.prototype
14532 });
14533 if (inputHydrated.map) {
14534 inputHydrated.map = _extends({}, inputHydrated.map, {
14535 __proto__: PreviousMap2$1.prototype
14536 });
14537 }
14538 inputs.push(inputHydrated);
14539 }
14540 }
14541 if (defaults.nodes) {
14542 defaults.nodes = json.nodes.map(function(n2) {
14543 return fromJSON$1$1(n2, inputs);
14544 });
14545 }
14546 if (defaults.source) {
14547 var _defaults_source = defaults.source, inputId = _defaults_source.inputId, source = _object_without_properties_loose(_defaults_source, [
14548 "inputId"
14549 ]);
14550 defaults.source = source;
14551 if (inputId != null) {
14552 defaults.source.input = inputs[inputId];
14553 }
14554 }
14555 if (defaults.type === "root") {
14556 return new Root$1$1(defaults);
14557 } else if (defaults.type === "decl") {
14558 return new Declaration$1$1(defaults);
14559 } else if (defaults.type === "rule") {
14560 return new Rule$1$1(defaults);
14561 } else if (defaults.type === "comment") {
14562 return new Comment$1$1(defaults);
14563 } else if (defaults.type === "atrule") {
14564 return new AtRule$1$1(defaults);
14565 } else {
14566 throw new Error("Unknown node type: " + json.type);
14567 }
14568 }
14569 var fromJSON_1$1 = fromJSON$1$1;
14570 fromJSON$1$1.default = fromJSON$1$1;
14571 var CssSyntaxError2$1 = cssSyntaxError$1;
14572 var Declaration2$1 = declaration$1;
14573 var LazyResult2$1 = lazyResult$1;
14574 var Container2$1 = container$1;
14575 var Processor2$1 = processor$1;
14576 var stringify$5 = stringify_1$1;
14577 var fromJSON$2 = fromJSON_1$1;
14578 var Document22 = document$1$1;
14579 var Warning2$1 = warning$1;
14580 var Comment2$1 = comment$1;
14581 var AtRule2$1 = atRule$1;
14582 var Result2$1 = result$1;
14583 var Input2$1 = input$1;
14584 var parse$5 = parse_1$1;
14585 var list$3 = list_1$1;
14586 var Rule2$1 = rule$1;
14587 var Root2$1 = root$1;
14588 var Node2$1 = node$1;
14589 function postcss$3() {
14590 for(var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++){
14591 plugins[_key] = arguments[_key];
14592 }
14593 if (plugins.length === 1 && Array.isArray(plugins[0])) {
14594 plugins = plugins[0];
14595 }
14596 return new Processor2$1(plugins);
14597 }
14598 postcss$3.plugin = function plugin(name, initializer) {
14599 var warningPrinted = false;
14600 function creator() {
14601 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
14602 args[_key] = arguments[_key];
14603 }
14604 if (console && console.warn && !warningPrinted) {
14605 warningPrinted = true;
14606 console.warn(name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration");
14607 if (process.env.LANG && process.env.LANG.startsWith("cn")) {
14608 console.warn(name + ": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226");
14609 }
14610 }
14611 var transformer = initializer.apply(void 0, [].concat(args));
14612 transformer.postcssPlugin = name;
14613 transformer.postcssVersion = new Processor2$1().version;
14614 return transformer;
14615 }
14616 var cache;
14617 Object.defineProperty(creator, "postcss", {
14618 get: function get() {
14619 if (!cache) cache = creator();
14620 return cache;
14621 }
14622 });
14623 creator.process = function(css, processOpts, pluginOpts) {
14624 return postcss$3([
14625 creator(pluginOpts)
14626 ]).process(css, processOpts);
14627 };
14628 return creator;
14629 };
14630 postcss$3.stringify = stringify$5;
14631 postcss$3.parse = parse$5;
14632 postcss$3.fromJSON = fromJSON$2;
14633 postcss$3.list = list$3;
14634 postcss$3.comment = function(defaults) {
14635 return new Comment2$1(defaults);
14636 };
14637 postcss$3.atRule = function(defaults) {
14638 return new AtRule2$1(defaults);
14639 };
14640 postcss$3.decl = function(defaults) {
14641 return new Declaration2$1(defaults);
14642 };
14643 postcss$3.rule = function(defaults) {
14644 return new Rule2$1(defaults);
14645 };
14646 postcss$3.root = function(defaults) {
14647 return new Root2$1(defaults);
14648 };
14649 postcss$3.document = function(defaults) {
14650 return new Document22(defaults);
14651 };
14652 postcss$3.CssSyntaxError = CssSyntaxError2$1;
14653 postcss$3.Declaration = Declaration2$1;
14654 postcss$3.Container = Container2$1;
14655 postcss$3.Processor = Processor2$1;
14656 postcss$3.Document = Document22;
14657 postcss$3.Comment = Comment2$1;
14658 postcss$3.Warning = Warning2$1;
14659 postcss$3.AtRule = AtRule2$1;
14660 postcss$3.Result = Result2$1;
14661 postcss$3.Input = Input2$1;
14662 postcss$3.Rule = Rule2$1;
14663 postcss$3.Root = Root2$1;
14664 postcss$3.Node = Node2$1;
14665 LazyResult2$1.registerPostcss(postcss$3);
14666 var postcss_1$1 = postcss$3;
14667 postcss$3.default = postcss$3;
14668 var postcss$1$1 = /* @__PURE__ */ getDefaultExportFromCjs$1(postcss_1$1);
14669 postcss$1$1.stringify;
14670 postcss$1$1.fromJSON;
14671 postcss$1$1.plugin;
14672 postcss$1$1.parse;
14673 postcss$1$1.list;
14674 postcss$1$1.document;
14675 postcss$1$1.comment;
14676 postcss$1$1.atRule;
14677 postcss$1$1.rule;
14678 postcss$1$1.decl;
14679 postcss$1$1.root;
14680 postcss$1$1.CssSyntaxError;
14681 postcss$1$1.Declaration;
14682 postcss$1$1.Container;
14683 postcss$1$1.Processor;
14684 postcss$1$1.Document;
14685 postcss$1$1.Comment;
14686 postcss$1$1.Warning;
14687 postcss$1$1.AtRule;
14688 postcss$1$1.Result;
14689 postcss$1$1.Input;
14690 postcss$1$1.Rule;
14691 postcss$1$1.Root;
14692 postcss$1$1.Node;
14693 var __defProp2 = Object.defineProperty;
14694 var __defNormalProp2 = function(obj, key, value) {
14695 return key in obj ? __defProp2(obj, key, {
14696 enumerable: true,
14697 configurable: true,
14698 writable: true,
14699 value: value
14700 }) : obj[key] = value;
14701 };
14702 var __publicField2 = function(obj, key, value) {
14703 return __defNormalProp2(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
14704 };
14705 function getDefaultExportFromCjs(x2) {
14706 return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
14707 }
14708 function getAugmentedNamespace(n2) {
14709 if (n2.__esModule) return n2;
14710 var f2 = n2.default;
14711 if (typeof f2 == "function") {
14712 var a2 = function a22() {
14713 if (_instanceof(this, a22)) {
14714 return Reflect.construct(f2, arguments, this.constructor);
14715 }
14716 return f2.apply(this, arguments);
14717 };
14718 a2.prototype = f2.prototype;
14719 } else a2 = {};
14720 Object.defineProperty(a2, "__esModule", {
14721 value: true
14722 });
14723 Object.keys(n2).forEach(function(k) {
14724 var d = Object.getOwnPropertyDescriptor(n2, k);
14725 Object.defineProperty(a2, k, d.get ? d : {
14726 enumerable: true,
14727 get: function get() {
14728 return n2[k];
14729 }
14730 });
14731 });
14732 return a2;
14733 }
14734 var picocolors_browser = {
14735 exports: {}
14736 };
14737 var x = String;
14738 var create = function create() {
14739 return {
14740 isColorSupported: false,
14741 reset: x,
14742 bold: x,
14743 dim: x,
14744 italic: x,
14745 underline: x,
14746 inverse: x,
14747 hidden: x,
14748 strikethrough: x,
14749 black: x,
14750 red: x,
14751 green: x,
14752 yellow: x,
14753 blue: x,
14754 magenta: x,
14755 cyan: x,
14756 white: x,
14757 gray: x,
14758 bgBlack: x,
14759 bgRed: x,
14760 bgGreen: x,
14761 bgYellow: x,
14762 bgBlue: x,
14763 bgMagenta: x,
14764 bgCyan: x,
14765 bgWhite: x
14766 };
14767 };
14768 picocolors_browser.exports = create();
14769 picocolors_browser.exports.createColors = create;
14770 var picocolors_browserExports = picocolors_browser.exports;
14771 var __viteBrowserExternal = {};
14772 var __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
14773 __proto__: null,
14774 default: __viteBrowserExternal
14775 }, Symbol.toStringTag, {
14776 value: "Module"
14777 }));
14778 var require$$2 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1);
14779 var pico = picocolors_browserExports;
14780 var terminalHighlight$1 = require$$2;
14781 var CssSyntaxError$3 = /*#__PURE__*/ function(Error1) {
14782 _inherits(CssSyntaxError2, Error1);
14783 function CssSyntaxError2(message, line, column, source, file, plugin22) {
14784 var _this;
14785 _this = Error1.call(this, message) || this;
14786 _this.name = "CssSyntaxError";
14787 _this.reason = message;
14788 if (file) {
14789 _this.file = file;
14790 }
14791 if (source) {
14792 _this.source = source;
14793 }
14794 if (plugin22) {
14795 _this.plugin = plugin22;
14796 }
14797 if (typeof line !== "undefined" && typeof column !== "undefined") {
14798 if (typeof line === "number") {
14799 _this.line = line;
14800 _this.column = column;
14801 } else {
14802 _this.line = line.line;
14803 _this.column = line.column;
14804 _this.endLine = column.line;
14805 _this.endColumn = column.column;
14806 }
14807 }
14808 _this.setMessage();
14809 if (Error.captureStackTrace) {
14810 Error.captureStackTrace(_this, CssSyntaxError2);
14811 }
14812 return _this;
14813 }
14814 var _proto = CssSyntaxError2.prototype;
14815 _proto.setMessage = function setMessage() {
14816 this.message = this.plugin ? this.plugin + ": " : "";
14817 this.message += this.file ? this.file : "<css input>";
14818 if (typeof this.line !== "undefined") {
14819 this.message += ":" + this.line + ":" + this.column;
14820 }
14821 this.message += ": " + this.reason;
14822 };
14823 _proto.showSourceCode = function showSourceCode(color) {
14824 var _this = this;
14825 if (!this.source) return "";
14826 var css = this.source;
14827 if (color == null) color = pico.isColorSupported;
14828 if (terminalHighlight$1) {
14829 if (color) css = terminalHighlight$1(css);
14830 }
14831 var lines = css.split(/\r?\n/);
14832 var start = Math.max(this.line - 3, 0);
14833 var end = Math.min(this.line + 2, lines.length);
14834 var maxWidth = String(end).length;
14835 var mark, aside;
14836 if (color) {
14837 var _pico_createColors = pico.createColors(true), bold = _pico_createColors.bold, gray = _pico_createColors.gray, red = _pico_createColors.red;
14838 mark = function(text) {
14839 return bold(red(text));
14840 };
14841 aside = function(text) {
14842 return gray(text);
14843 };
14844 } else {
14845 mark = aside = function(str) {
14846 return str;
14847 };
14848 }
14849 return lines.slice(start, end).map(function(line, index2) {
14850 var number = start + 1 + index2;
14851 var gutter = " " + (" " + number).slice(-maxWidth) + " | ";
14852 if (number === _this.line) {
14853 var spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, _this.column - 1).replace(/[^\t]/g, " ");
14854 return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^");
14855 }
14856 return " " + aside(gutter) + line;
14857 }).join("\n");
14858 };
14859 _proto.toString = function toString() {
14860 var code = this.showSourceCode();
14861 if (code) {
14862 code = "\n\n" + code + "\n";
14863 }
14864 return this.name + ": " + this.message + code;
14865 };
14866 return CssSyntaxError2;
14867 }(_wrap_native_super(Error));
14868 var cssSyntaxError = CssSyntaxError$3;
14869 CssSyntaxError$3.default = CssSyntaxError$3;
14870 var symbols = {};
14871 symbols.isClean = Symbol("isClean");
14872 symbols.my = Symbol("my");
14873 var DEFAULT_RAW = {
14874 after: "\n",
14875 beforeClose: "\n",
14876 beforeComment: "\n",
14877 beforeDecl: "\n",
14878 beforeOpen: " ",
14879 beforeRule: "\n",
14880 colon: ": ",
14881 commentLeft: " ",
14882 commentRight: " ",
14883 emptyBody: "",
14884 indent: " ",
14885 semicolon: false
14886 };
14887 function capitalize(str) {
14888 return str[0].toUpperCase() + str.slice(1);
14889 }
14890 var Stringifier$2 = /*#__PURE__*/ function() {
14891 function Stringifier2(builder) {
14892 this.builder = builder;
14893 }
14894 var _proto = Stringifier2.prototype;
14895 _proto.atrule = function atrule(node2, semicolon) {
14896 var name = "@" + node2.name;
14897 var params = node2.params ? this.rawValue(node2, "params") : "";
14898 if (typeof node2.raws.afterName !== "undefined") {
14899 name += node2.raws.afterName;
14900 } else if (params) {
14901 name += " ";
14902 }
14903 if (node2.nodes) {
14904 this.block(node2, name + params);
14905 } else {
14906 var end = (node2.raws.between || "") + (semicolon ? ";" : "");
14907 this.builder(name + params + end, node2);
14908 }
14909 };
14910 _proto.beforeAfter = function beforeAfter(node2, detect) {
14911 var value;
14912 if (node2.type === "decl") {
14913 value = this.raw(node2, null, "beforeDecl");
14914 } else if (node2.type === "comment") {
14915 value = this.raw(node2, null, "beforeComment");
14916 } else if (detect === "before") {
14917 value = this.raw(node2, null, "beforeRule");
14918 } else {
14919 value = this.raw(node2, null, "beforeClose");
14920 }
14921 var buf = node2.parent;
14922 var depth = 0;
14923 while(buf && buf.type !== "root"){
14924 depth += 1;
14925 buf = buf.parent;
14926 }
14927 if (value.includes("\n")) {
14928 var indent = this.raw(node2, null, "indent");
14929 if (indent.length) {
14930 for(var step = 0; step < depth; step++)value += indent;
14931 }
14932 }
14933 return value;
14934 };
14935 _proto.block = function block(node2, start) {
14936 var between = this.raw(node2, "between", "beforeOpen");
14937 this.builder(start + between + "{", node2, "start");
14938 var after;
14939 if (node2.nodes && node2.nodes.length) {
14940 this.body(node2);
14941 after = this.raw(node2, "after");
14942 } else {
14943 after = this.raw(node2, "after", "emptyBody");
14944 }
14945 if (after) this.builder(after);
14946 this.builder("}", node2, "end");
14947 };
14948 _proto.body = function body(node2) {
14949 var last = node2.nodes.length - 1;
14950 while(last > 0){
14951 if (node2.nodes[last].type !== "comment") break;
14952 last -= 1;
14953 }
14954 var semicolon = this.raw(node2, "semicolon");
14955 for(var i2 = 0; i2 < node2.nodes.length; i2++){
14956 var child = node2.nodes[i2];
14957 var before = this.raw(child, "before");
14958 if (before) this.builder(before);
14959 this.stringify(child, last !== i2 || semicolon);
14960 }
14961 };
14962 _proto.comment = function comment(node2) {
14963 var left = this.raw(node2, "left", "commentLeft");
14964 var right = this.raw(node2, "right", "commentRight");
14965 this.builder("/*" + left + node2.text + right + "*/", node2);
14966 };
14967 _proto.decl = function decl(node2, semicolon) {
14968 var between = this.raw(node2, "between", "colon");
14969 var string = node2.prop + between + this.rawValue(node2, "value");
14970 if (node2.important) {
14971 string += node2.raws.important || " !important";
14972 }
14973 if (semicolon) string += ";";
14974 this.builder(string, node2);
14975 };
14976 _proto.document = function document1(node2) {
14977 this.body(node2);
14978 };
14979 _proto.raw = function raw(node2, own, detect) {
14980 var value;
14981 if (!detect) detect = own;
14982 if (own) {
14983 value = node2.raws[own];
14984 if (typeof value !== "undefined") return value;
14985 }
14986 var parent = node2.parent;
14987 if (detect === "before") {
14988 if (!parent || parent.type === "root" && parent.first === node2) {
14989 return "";
14990 }
14991 if (parent && parent.type === "document") {
14992 return "";
14993 }
14994 }
14995 if (!parent) return DEFAULT_RAW[detect];
14996 var root2 = node2.root();
14997 if (!root2.rawCache) root2.rawCache = {};
14998 if (typeof root2.rawCache[detect] !== "undefined") {
14999 return root2.rawCache[detect];
15000 }
15001 if (detect === "before" || detect === "after") {
15002 return this.beforeAfter(node2, detect);
15003 } else {
15004 var method = "raw" + capitalize(detect);
15005 if (this[method]) {
15006 value = this[method](root2, node2);
15007 } else {
15008 root2.walk(function(i2) {
15009 value = i2.raws[own];
15010 if (typeof value !== "undefined") return false;
15011 });
15012 }
15013 }
15014 if (typeof value === "undefined") value = DEFAULT_RAW[detect];
15015 root2.rawCache[detect] = value;
15016 return value;
15017 };
15018 _proto.rawBeforeClose = function rawBeforeClose(root2) {
15019 var value;
15020 root2.walk(function(i2) {
15021 if (i2.nodes && i2.nodes.length > 0) {
15022 if (typeof i2.raws.after !== "undefined") {
15023 value = i2.raws.after;
15024 if (value.includes("\n")) {
15025 value = value.replace(/[^\n]+$/, "");
15026 }
15027 return false;
15028 }
15029 }
15030 });
15031 if (value) value = value.replace(/\S/g, "");
15032 return value;
15033 };
15034 _proto.rawBeforeComment = function rawBeforeComment(root2, node2) {
15035 var value;
15036 root2.walkComments(function(i2) {
15037 if (typeof i2.raws.before !== "undefined") {
15038 value = i2.raws.before;
15039 if (value.includes("\n")) {
15040 value = value.replace(/[^\n]+$/, "");
15041 }
15042 return false;
15043 }
15044 });
15045 if (typeof value === "undefined") {
15046 value = this.raw(node2, null, "beforeDecl");
15047 } else if (value) {
15048 value = value.replace(/\S/g, "");
15049 }
15050 return value;
15051 };
15052 _proto.rawBeforeDecl = function rawBeforeDecl(root2, node2) {
15053 var value;
15054 root2.walkDecls(function(i2) {
15055 if (typeof i2.raws.before !== "undefined") {
15056 value = i2.raws.before;
15057 if (value.includes("\n")) {
15058 value = value.replace(/[^\n]+$/, "");
15059 }
15060 return false;
15061 }
15062 });
15063 if (typeof value === "undefined") {
15064 value = this.raw(node2, null, "beforeRule");
15065 } else if (value) {
15066 value = value.replace(/\S/g, "");
15067 }
15068 return value;
15069 };
15070 _proto.rawBeforeOpen = function rawBeforeOpen(root2) {
15071 var value;
15072 root2.walk(function(i2) {
15073 if (i2.type !== "decl") {
15074 value = i2.raws.between;
15075 if (typeof value !== "undefined") return false;
15076 }
15077 });
15078 return value;
15079 };
15080 _proto.rawBeforeRule = function rawBeforeRule(root2) {
15081 var value;
15082 root2.walk(function(i2) {
15083 if (i2.nodes && (i2.parent !== root2 || root2.first !== i2)) {
15084 if (typeof i2.raws.before !== "undefined") {
15085 value = i2.raws.before;
15086 if (value.includes("\n")) {
15087 value = value.replace(/[^\n]+$/, "");
15088 }
15089 return false;
15090 }
15091 }
15092 });
15093 if (value) value = value.replace(/\S/g, "");
15094 return value;
15095 };
15096 _proto.rawColon = function rawColon(root2) {
15097 var value;
15098 root2.walkDecls(function(i2) {
15099 if (typeof i2.raws.between !== "undefined") {
15100 value = i2.raws.between.replace(/[^\s:]/g, "");
15101 return false;
15102 }
15103 });
15104 return value;
15105 };
15106 _proto.rawEmptyBody = function rawEmptyBody(root2) {
15107 var value;
15108 root2.walk(function(i2) {
15109 if (i2.nodes && i2.nodes.length === 0) {
15110 value = i2.raws.after;
15111 if (typeof value !== "undefined") return false;
15112 }
15113 });
15114 return value;
15115 };
15116 _proto.rawIndent = function rawIndent(root2) {
15117 if (root2.raws.indent) return root2.raws.indent;
15118 var value;
15119 root2.walk(function(i2) {
15120 var p = i2.parent;
15121 if (p && p !== root2 && p.parent && p.parent === root2) {
15122 if (typeof i2.raws.before !== "undefined") {
15123 var parts = i2.raws.before.split("\n");
15124 value = parts[parts.length - 1];
15125 value = value.replace(/\S/g, "");
15126 return false;
15127 }
15128 }
15129 });
15130 return value;
15131 };
15132 _proto.rawSemicolon = function rawSemicolon(root2) {
15133 var value;
15134 root2.walk(function(i2) {
15135 if (i2.nodes && i2.nodes.length && i2.last.type === "decl") {
15136 value = i2.raws.semicolon;
15137 if (typeof value !== "undefined") return false;
15138 }
15139 });
15140 return value;
15141 };
15142 _proto.rawValue = function rawValue(node2, prop) {
15143 var value = node2[prop];
15144 var raw = node2.raws[prop];
15145 if (raw && raw.value === value) {
15146 return raw.raw;
15147 }
15148 return value;
15149 };
15150 _proto.root = function root(node2) {
15151 this.body(node2);
15152 if (node2.raws.after) this.builder(node2.raws.after);
15153 };
15154 _proto.rule = function rule(node2) {
15155 this.block(node2, this.rawValue(node2, "selector"));
15156 if (node2.raws.ownSemicolon) {
15157 this.builder(node2.raws.ownSemicolon, node2, "end");
15158 }
15159 };
15160 _proto.stringify = function stringify(node2, semicolon) {
15161 if (!this[node2.type]) {
15162 throw new Error("Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier.");
15163 }
15164 this[node2.type](node2, semicolon);
15165 };
15166 return Stringifier2;
15167 }();
15168 var stringifier = Stringifier$2;
15169 Stringifier$2.default = Stringifier$2;
15170 var Stringifier$1 = stringifier;
15171 function stringify$4(node2, builder) {
15172 var str = new Stringifier$1(builder);
15173 str.stringify(node2);
15174 }
15175 var stringify_1 = stringify$4;
15176 stringify$4.default = stringify$4;
15177 var isClean$2 = symbols.isClean, my$2 = symbols.my;
15178 var CssSyntaxError$2 = cssSyntaxError;
15179 var Stringifier22 = stringifier;
15180 var stringify$3 = stringify_1;
15181 function cloneNode(obj, parent) {
15182 var cloned = new obj.constructor();
15183 for(var i2 in obj){
15184 if (!Object.prototype.hasOwnProperty.call(obj, i2)) {
15185 continue;
15186 }
15187 if (i2 === "proxyCache") continue;
15188 var value = obj[i2];
15189 var type = typeof value === "undefined" ? "undefined" : _type_of(value);
15190 if (i2 === "parent" && type === "object") {
15191 if (parent) cloned[i2] = parent;
15192 } else if (i2 === "source") {
15193 cloned[i2] = value;
15194 } else if (Array.isArray(value)) {
15195 cloned[i2] = value.map(function(j) {
15196 return cloneNode(j, cloned);
15197 });
15198 } else {
15199 if (type === "object" && value !== null) value = cloneNode(value);
15200 cloned[i2] = value;
15201 }
15202 }
15203 return cloned;
15204 }
15205 var Node$4 = /*#__PURE__*/ function() {
15206 function Node3(defaults) {
15207 if (defaults === void 0) defaults = {};
15208 this.raws = {};
15209 this[isClean$2] = false;
15210 this[my$2] = true;
15211 for(var name in defaults){
15212 if (name === "nodes") {
15213 this.nodes = [];
15214 for(var _iterator = _create_for_of_iterator_helper_loose(defaults[name]), _step; !(_step = _iterator()).done;){
15215 var node2 = _step.value;
15216 if (typeof node2.clone === "function") {
15217 this.append(node2.clone());
15218 } else {
15219 this.append(node2);
15220 }
15221 }
15222 } else {
15223 this[name] = defaults[name];
15224 }
15225 }
15226 }
15227 var _proto = Node3.prototype;
15228 _proto.addToError = function addToError(error) {
15229 error.postcssNode = this;
15230 if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
15231 var s2 = this.source;
15232 error.stack = error.stack.replace(/\n\s{4}at /, "$&" + s2.input.from + ":" + s2.start.line + ":" + s2.start.column + "$&");
15233 }
15234 return error;
15235 };
15236 _proto.after = function after(add) {
15237 this.parent.insertAfter(this, add);
15238 return this;
15239 };
15240 _proto.assign = function assign(overrides) {
15241 if (overrides === void 0) overrides = {};
15242 for(var name in overrides){
15243 this[name] = overrides[name];
15244 }
15245 return this;
15246 };
15247 _proto.before = function before(add) {
15248 this.parent.insertBefore(this, add);
15249 return this;
15250 };
15251 _proto.cleanRaws = function cleanRaws(keepBetween) {
15252 delete this.raws.before;
15253 delete this.raws.after;
15254 if (!keepBetween) delete this.raws.between;
15255 };
15256 _proto.clone = function clone(overrides) {
15257 if (overrides === void 0) overrides = {};
15258 var cloned = cloneNode(this);
15259 for(var name in overrides){
15260 cloned[name] = overrides[name];
15261 }
15262 return cloned;
15263 };
15264 _proto.cloneAfter = function cloneAfter(overrides) {
15265 if (overrides === void 0) overrides = {};
15266 var cloned = this.clone(overrides);
15267 this.parent.insertAfter(this, cloned);
15268 return cloned;
15269 };
15270 _proto.cloneBefore = function cloneBefore(overrides) {
15271 if (overrides === void 0) overrides = {};
15272 var cloned = this.clone(overrides);
15273 this.parent.insertBefore(this, cloned);
15274 return cloned;
15275 };
15276 _proto.error = function error(message, opts) {
15277 if (opts === void 0) opts = {};
15278 if (this.source) {
15279 var _this_rangeBy = this.rangeBy(opts), end = _this_rangeBy.end, start = _this_rangeBy.start;
15280 return this.source.input.error(message, {
15281 column: start.column,
15282 line: start.line
15283 }, {
15284 column: end.column,
15285 line: end.line
15286 }, opts);
15287 }
15288 return new CssSyntaxError$2(message);
15289 };
15290 _proto.getProxyProcessor = function getProxyProcessor() {
15291 return {
15292 get: function get(node2, prop) {
15293 if (prop === "proxyOf") {
15294 return node2;
15295 } else if (prop === "root") {
15296 return function() {
15297 return node2.root().toProxy();
15298 };
15299 } else {
15300 return node2[prop];
15301 }
15302 },
15303 set: function set(node2, prop, value) {
15304 if (node2[prop] === value) return true;
15305 node2[prop] = value;
15306 if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ prop === "text") {
15307 node2.markDirty();
15308 }
15309 return true;
15310 }
15311 };
15312 };
15313 _proto.markDirty = function markDirty() {
15314 if (this[isClean$2]) {
15315 this[isClean$2] = false;
15316 var next = this;
15317 while(next = next.parent){
15318 next[isClean$2] = false;
15319 }
15320 }
15321 };
15322 _proto.next = function next() {
15323 if (!this.parent) return void 0;
15324 var index2 = this.parent.index(this);
15325 return this.parent.nodes[index2 + 1];
15326 };
15327 _proto.positionBy = function positionBy(opts, stringRepresentation) {
15328 var pos = this.source.start;
15329 if (opts.index) {
15330 pos = this.positionInside(opts.index, stringRepresentation);
15331 } else if (opts.word) {
15332 stringRepresentation = this.toString();
15333 var index2 = stringRepresentation.indexOf(opts.word);
15334 if (index2 !== -1) pos = this.positionInside(index2, stringRepresentation);
15335 }
15336 return pos;
15337 };
15338 _proto.positionInside = function positionInside(index2, stringRepresentation) {
15339 var string = stringRepresentation || this.toString();
15340 var column = this.source.start.column;
15341 var line = this.source.start.line;
15342 for(var i2 = 0; i2 < index2; i2++){
15343 if (string[i2] === "\n") {
15344 column = 1;
15345 line += 1;
15346 } else {
15347 column += 1;
15348 }
15349 }
15350 return {
15351 column: column,
15352 line: line
15353 };
15354 };
15355 _proto.prev = function prev() {
15356 if (!this.parent) return void 0;
15357 var index2 = this.parent.index(this);
15358 return this.parent.nodes[index2 - 1];
15359 };
15360 _proto.rangeBy = function rangeBy(opts) {
15361 var start = {
15362 column: this.source.start.column,
15363 line: this.source.start.line
15364 };
15365 var end = this.source.end ? {
15366 column: this.source.end.column + 1,
15367 line: this.source.end.line
15368 } : {
15369 column: start.column + 1,
15370 line: start.line
15371 };
15372 if (opts.word) {
15373 var stringRepresentation = this.toString();
15374 var index2 = stringRepresentation.indexOf(opts.word);
15375 if (index2 !== -1) {
15376 start = this.positionInside(index2, stringRepresentation);
15377 end = this.positionInside(index2 + opts.word.length, stringRepresentation);
15378 }
15379 } else {
15380 if (opts.start) {
15381 start = {
15382 column: opts.start.column,
15383 line: opts.start.line
15384 };
15385 } else if (opts.index) {
15386 start = this.positionInside(opts.index);
15387 }
15388 if (opts.end) {
15389 end = {
15390 column: opts.end.column,
15391 line: opts.end.line
15392 };
15393 } else if (typeof opts.endIndex === "number") {
15394 end = this.positionInside(opts.endIndex);
15395 } else if (opts.index) {
15396 end = this.positionInside(opts.index + 1);
15397 }
15398 }
15399 if (end.line < start.line || end.line === start.line && end.column <= start.column) {
15400 end = {
15401 column: start.column + 1,
15402 line: start.line
15403 };
15404 }
15405 return {
15406 end: end,
15407 start: start
15408 };
15409 };
15410 _proto.raw = function raw(prop, defaultType) {
15411 var str = new Stringifier22();
15412 return str.raw(this, prop, defaultType);
15413 };
15414 _proto.remove = function remove() {
15415 if (this.parent) {
15416 this.parent.removeChild(this);
15417 }
15418 this.parent = void 0;
15419 return this;
15420 };
15421 _proto.replaceWith = function replaceWith() {
15422 for(var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++){
15423 nodes[_key] = arguments[_key];
15424 }
15425 if (this.parent) {
15426 var bookmark = this;
15427 var foundSelf = false;
15428 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
15429 var node2 = _step.value;
15430 if (node2 === this) {
15431 foundSelf = true;
15432 } else if (foundSelf) {
15433 this.parent.insertAfter(bookmark, node2);
15434 bookmark = node2;
15435 } else {
15436 this.parent.insertBefore(bookmark, node2);
15437 }
15438 }
15439 if (!foundSelf) {
15440 this.remove();
15441 }
15442 }
15443 return this;
15444 };
15445 _proto.root = function root() {
15446 var result2 = this;
15447 while(result2.parent && result2.parent.type !== "document"){
15448 result2 = result2.parent;
15449 }
15450 return result2;
15451 };
15452 _proto.toJSON = function toJSON(_, inputs) {
15453 var fixed = {};
15454 var emitInputs = inputs == null;
15455 inputs = inputs || /* @__PURE__ */ new Map();
15456 var inputsNextIndex = 0;
15457 for(var name in this){
15458 if (!Object.prototype.hasOwnProperty.call(this, name)) {
15459 continue;
15460 }
15461 if (name === "parent" || name === "proxyCache") continue;
15462 var value = this[name];
15463 if (Array.isArray(value)) {
15464 fixed[name] = value.map(function(i2) {
15465 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.toJSON) {
15466 return i2.toJSON(null, inputs);
15467 } else {
15468 return i2;
15469 }
15470 });
15471 } else if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value.toJSON) {
15472 fixed[name] = value.toJSON(null, inputs);
15473 } else if (name === "source") {
15474 var inputId = inputs.get(value.input);
15475 if (inputId == null) {
15476 inputId = inputsNextIndex;
15477 inputs.set(value.input, inputsNextIndex);
15478 inputsNextIndex++;
15479 }
15480 fixed[name] = {
15481 end: value.end,
15482 inputId: inputId,
15483 start: value.start
15484 };
15485 } else {
15486 fixed[name] = value;
15487 }
15488 }
15489 if (emitInputs) {
15490 fixed.inputs = [].concat(inputs.keys()).map(function(input2) {
15491 return input2.toJSON();
15492 });
15493 }
15494 return fixed;
15495 };
15496 _proto.toProxy = function toProxy() {
15497 if (!this.proxyCache) {
15498 this.proxyCache = new Proxy(this, this.getProxyProcessor());
15499 }
15500 return this.proxyCache;
15501 };
15502 _proto.toString = function toString(stringifier2) {
15503 if (stringifier2 === void 0) stringifier2 = stringify$3;
15504 if (stringifier2.stringify) stringifier2 = stringifier2.stringify;
15505 var result2 = "";
15506 stringifier2(this, function(i2) {
15507 result2 += i2;
15508 });
15509 return result2;
15510 };
15511 _proto.warn = function warn(result2, text, opts) {
15512 var data = {
15513 node: this
15514 };
15515 for(var i2 in opts)data[i2] = opts[i2];
15516 return result2.warn(text, data);
15517 };
15518 _create_class(Node3, [
15519 {
15520 key: "proxyOf",
15521 get: function get() {
15522 return this;
15523 }
15524 }
15525 ]);
15526 return Node3;
15527 }();
15528 var node = Node$4;
15529 Node$4.default = Node$4;
15530 var Node$3 = node;
15531 var Declaration$4 = /*#__PURE__*/ function(Node$3) {
15532 _inherits(Declaration2, Node$3);
15533 function Declaration2(defaults) {
15534 var _this;
15535 if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
15536 defaults = _extends({}, defaults, {
15537 value: String(defaults.value)
15538 });
15539 }
15540 _this = Node$3.call(this, defaults) || this;
15541 _this.type = "decl";
15542 return _this;
15543 }
15544 _create_class(Declaration2, [
15545 {
15546 key: "variable",
15547 get: function get() {
15548 return this.prop.startsWith("--") || this.prop[0] === "$";
15549 }
15550 }
15551 ]);
15552 return Declaration2;
15553 }(Node$3);
15554 var declaration = Declaration$4;
15555 Declaration$4.default = Declaration$4;
15556 var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
15557 var nanoid$1 = function(size) {
15558 if (size === void 0) size = 21;
15559 var id = "";
15560 var i2 = size;
15561 while(i2--){
15562 id += urlAlphabet[Math.random() * 64 | 0];
15563 }
15564 return id;
15565 };
15566 var nonSecure = {
15567 nanoid: nanoid$1};
15568 var SourceMapConsumer$2 = require$$2.SourceMapConsumer, SourceMapGenerator$2 = require$$2.SourceMapGenerator;
15569 var existsSync = require$$2.existsSync, readFileSync = require$$2.readFileSync;
15570 var dirname$1 = require$$2.dirname, join = require$$2.join;
15571 function fromBase64(str) {
15572 if (Buffer) {
15573 return Buffer.from(str, "base64").toString();
15574 } else {
15575 return window.atob(str);
15576 }
15577 }
15578 var PreviousMap$2 = /*#__PURE__*/ function() {
15579 function PreviousMap2(css, opts) {
15580 if (opts.map === false) return;
15581 this.loadAnnotation(css);
15582 this.inline = this.startWith(this.annotation, "data:");
15583 var prev = opts.map ? opts.map.prev : void 0;
15584 var text = this.loadMap(opts.from, prev);
15585 if (!this.mapFile && opts.from) {
15586 this.mapFile = opts.from;
15587 }
15588 if (this.mapFile) this.root = dirname$1(this.mapFile);
15589 if (text) this.text = text;
15590 }
15591 var _proto = PreviousMap2.prototype;
15592 _proto.consumer = function consumer() {
15593 if (!this.consumerCache) {
15594 this.consumerCache = new SourceMapConsumer$2(this.text);
15595 }
15596 return this.consumerCache;
15597 };
15598 _proto.decodeInline = function decodeInline(text) {
15599 var baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
15600 var baseUri = /^data:application\/json;base64,/;
15601 var charsetUri = /^data:application\/json;charset=utf-?8,/;
15602 var uri = /^data:application\/json,/;
15603 if (charsetUri.test(text) || uri.test(text)) {
15604 return decodeURIComponent(text.substr(RegExp.lastMatch.length));
15605 }
15606 if (baseCharsetUri.test(text) || baseUri.test(text)) {
15607 return fromBase64(text.substr(RegExp.lastMatch.length));
15608 }
15609 var encoding = text.match(/data:application\/json;([^,]+),/)[1];
15610 throw new Error("Unsupported source map encoding " + encoding);
15611 };
15612 _proto.getAnnotationURL = function getAnnotationURL(sourceMapString) {
15613 return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
15614 };
15615 _proto.isMap = function isMap(map) {
15616 if ((typeof map === "undefined" ? "undefined" : _type_of(map)) !== "object") return false;
15617 return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
15618 };
15619 _proto.loadAnnotation = function loadAnnotation(css) {
15620 var comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
15621 if (!comments) return;
15622 var start = css.lastIndexOf(comments.pop());
15623 var end = css.indexOf("*/", start);
15624 if (start > -1 && end > -1) {
15625 this.annotation = this.getAnnotationURL(css.substring(start, end));
15626 }
15627 };
15628 _proto.loadFile = function loadFile(path) {
15629 this.root = dirname$1(path);
15630 if (existsSync(path)) {
15631 this.mapFile = path;
15632 return readFileSync(path, "utf-8").toString().trim();
15633 }
15634 };
15635 _proto.loadMap = function loadMap(file, prev) {
15636 if (prev === false) return false;
15637 if (prev) {
15638 if (typeof prev === "string") {
15639 return prev;
15640 } else if (typeof prev === "function") {
15641 var prevPath = prev(file);
15642 if (prevPath) {
15643 var map = this.loadFile(prevPath);
15644 if (!map) {
15645 throw new Error("Unable to load previous source map: " + prevPath.toString());
15646 }
15647 return map;
15648 }
15649 } else if (_instanceof(prev, SourceMapConsumer$2)) {
15650 return SourceMapGenerator$2.fromSourceMap(prev).toString();
15651 } else if (_instanceof(prev, SourceMapGenerator$2)) {
15652 return prev.toString();
15653 } else if (this.isMap(prev)) {
15654 return JSON.stringify(prev);
15655 } else {
15656 throw new Error("Unsupported previous source map format: " + prev.toString());
15657 }
15658 } else if (this.inline) {
15659 return this.decodeInline(this.annotation);
15660 } else if (this.annotation) {
15661 var map1 = this.annotation;
15662 if (file) map1 = join(dirname$1(file), map1);
15663 return this.loadFile(map1);
15664 }
15665 };
15666 _proto.startWith = function startWith(string, start) {
15667 if (!string) return false;
15668 return string.substr(0, start.length) === start;
15669 };
15670 _proto.withContent = function withContent() {
15671 return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
15672 };
15673 return PreviousMap2;
15674 }();
15675 var previousMap = PreviousMap$2;
15676 PreviousMap$2.default = PreviousMap$2;
15677 var SourceMapConsumer$1 = require$$2.SourceMapConsumer, SourceMapGenerator$1 = require$$2.SourceMapGenerator;
15678 var fileURLToPath = require$$2.fileURLToPath, pathToFileURL$1 = require$$2.pathToFileURL;
15679 var isAbsolute = require$$2.isAbsolute, resolve$1 = require$$2.resolve;
15680 var nanoid = nonSecure.nanoid;
15681 var terminalHighlight = require$$2;
15682 var CssSyntaxError$1 = cssSyntaxError;
15683 var PreviousMap$1 = previousMap;
15684 var fromOffsetCache = Symbol("fromOffsetCache");
15685 var sourceMapAvailable$1 = Boolean(SourceMapConsumer$1 && SourceMapGenerator$1);
15686 var pathAvailable$1 = Boolean(resolve$1 && isAbsolute);
15687 var Input$4 = /*#__PURE__*/ function() {
15688 function Input2(css, opts) {
15689 if (opts === void 0) opts = {};
15690 if (css === null || typeof css === "undefined" || (typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && !css.toString) {
15691 throw new Error("PostCSS received " + css + " instead of CSS string");
15692 }
15693 this.css = css.toString();
15694 if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
15695 this.hasBOM = true;
15696 this.css = this.css.slice(1);
15697 } else {
15698 this.hasBOM = false;
15699 }
15700 if (opts.from) {
15701 if (!pathAvailable$1 || /^\w+:\/\//.test(opts.from) || isAbsolute(opts.from)) {
15702 this.file = opts.from;
15703 } else {
15704 this.file = resolve$1(opts.from);
15705 }
15706 }
15707 if (pathAvailable$1 && sourceMapAvailable$1) {
15708 var map = new PreviousMap$1(this.css, opts);
15709 if (map.text) {
15710 this.map = map;
15711 var file = map.consumer().file;
15712 if (!this.file && file) this.file = this.mapResolve(file);
15713 }
15714 }
15715 if (!this.file) {
15716 this.id = "<input css " + nanoid(6) + ">";
15717 }
15718 if (this.map) this.map.file = this.from;
15719 }
15720 var _proto = Input2.prototype;
15721 _proto.error = function error(message, line, column, opts) {
15722 if (opts === void 0) opts = {};
15723 var result2, endLine, endColumn;
15724 if (line && (typeof line === "undefined" ? "undefined" : _type_of(line)) === "object") {
15725 var start = line;
15726 var end = column;
15727 if (typeof start.offset === "number") {
15728 var pos = this.fromOffset(start.offset);
15729 line = pos.line;
15730 column = pos.col;
15731 } else {
15732 line = start.line;
15733 column = start.column;
15734 }
15735 if (typeof end.offset === "number") {
15736 var pos1 = this.fromOffset(end.offset);
15737 endLine = pos1.line;
15738 endColumn = pos1.col;
15739 } else {
15740 endLine = end.line;
15741 endColumn = end.column;
15742 }
15743 } else if (!column) {
15744 var pos2 = this.fromOffset(line);
15745 line = pos2.line;
15746 column = pos2.col;
15747 }
15748 var origin = this.origin(line, column, endLine, endColumn);
15749 if (origin) {
15750 result2 = new CssSyntaxError$1(message, origin.endLine === void 0 ? origin.line : {
15751 column: origin.column,
15752 line: origin.line
15753 }, origin.endLine === void 0 ? origin.column : {
15754 column: origin.endColumn,
15755 line: origin.endLine
15756 }, origin.source, origin.file, opts.plugin);
15757 } else {
15758 result2 = new CssSyntaxError$1(message, endLine === void 0 ? line : {
15759 column: column,
15760 line: line
15761 }, endLine === void 0 ? column : {
15762 column: endColumn,
15763 line: endLine
15764 }, this.css, this.file, opts.plugin);
15765 }
15766 result2.input = {
15767 column: column,
15768 endColumn: endColumn,
15769 endLine: endLine,
15770 line: line,
15771 source: this.css
15772 };
15773 if (this.file) {
15774 if (pathToFileURL$1) {
15775 result2.input.url = pathToFileURL$1(this.file).toString();
15776 }
15777 result2.input.file = this.file;
15778 }
15779 return result2;
15780 };
15781 _proto.fromOffset = function fromOffset(offset) {
15782 var lastLine, lineToIndex;
15783 if (!this[fromOffsetCache]) {
15784 var lines = this.css.split("\n");
15785 lineToIndex = new Array(lines.length);
15786 var prevIndex = 0;
15787 for(var i2 = 0, l2 = lines.length; i2 < l2; i2++){
15788 lineToIndex[i2] = prevIndex;
15789 prevIndex += lines[i2].length + 1;
15790 }
15791 this[fromOffsetCache] = lineToIndex;
15792 } else {
15793 lineToIndex = this[fromOffsetCache];
15794 }
15795 lastLine = lineToIndex[lineToIndex.length - 1];
15796 var min = 0;
15797 if (offset >= lastLine) {
15798 min = lineToIndex.length - 1;
15799 } else {
15800 var max = lineToIndex.length - 2;
15801 var mid;
15802 while(min < max){
15803 mid = min + (max - min >> 1);
15804 if (offset < lineToIndex[mid]) {
15805 max = mid - 1;
15806 } else if (offset >= lineToIndex[mid + 1]) {
15807 min = mid + 1;
15808 } else {
15809 min = mid;
15810 break;
15811 }
15812 }
15813 }
15814 return {
15815 col: offset - lineToIndex[min] + 1,
15816 line: min + 1
15817 };
15818 };
15819 _proto.mapResolve = function mapResolve(file) {
15820 if (/^\w+:\/\//.test(file)) {
15821 return file;
15822 }
15823 return resolve$1(this.map.consumer().sourceRoot || this.map.root || ".", file);
15824 };
15825 _proto.origin = function origin(line, column, endLine, endColumn) {
15826 if (!this.map) return false;
15827 var consumer = this.map.consumer();
15828 var from = consumer.originalPositionFor({
15829 column: column,
15830 line: line
15831 });
15832 if (!from.source) return false;
15833 var to;
15834 if (typeof endLine === "number") {
15835 to = consumer.originalPositionFor({
15836 column: endColumn,
15837 line: endLine
15838 });
15839 }
15840 var fromUrl;
15841 if (isAbsolute(from.source)) {
15842 fromUrl = pathToFileURL$1(from.source);
15843 } else {
15844 fromUrl = new URL(from.source, this.map.consumer().sourceRoot || pathToFileURL$1(this.map.mapFile));
15845 }
15846 var result2 = {
15847 column: from.column,
15848 endColumn: to && to.column,
15849 endLine: to && to.line,
15850 line: from.line,
15851 url: fromUrl.toString()
15852 };
15853 if (fromUrl.protocol === "file:") {
15854 if (fileURLToPath) {
15855 result2.file = fileURLToPath(fromUrl);
15856 } else {
15857 throw new Error("file: protocol is not available in this PostCSS build");
15858 }
15859 }
15860 var source = consumer.sourceContentFor(from.source);
15861 if (source) result2.source = source;
15862 return result2;
15863 };
15864 _proto.toJSON = function toJSON() {
15865 var json = {};
15866 for(var _i = 0, _iter = [
15867 "hasBOM",
15868 "css",
15869 "file",
15870 "id"
15871 ]; _i < _iter.length; _i++){
15872 var name = _iter[_i];
15873 if (this[name] != null) {
15874 json[name] = this[name];
15875 }
15876 }
15877 if (this.map) {
15878 json.map = _extends({}, this.map);
15879 if (json.map.consumerCache) {
15880 json.map.consumerCache = void 0;
15881 }
15882 }
15883 return json;
15884 };
15885 _create_class(Input2, [
15886 {
15887 key: "from",
15888 get: function get() {
15889 return this.file || this.id;
15890 }
15891 }
15892 ]);
15893 return Input2;
15894 }();
15895 var input = Input$4;
15896 Input$4.default = Input$4;
15897 if (terminalHighlight && terminalHighlight.registerInput) {
15898 terminalHighlight.registerInput(Input$4);
15899 }
15900 var SourceMapConsumer = require$$2.SourceMapConsumer, SourceMapGenerator = require$$2.SourceMapGenerator;
15901 var dirname = require$$2.dirname, relative = require$$2.relative, resolve$3 = require$$2.resolve, sep = require$$2.sep;
15902 var pathToFileURL = require$$2.pathToFileURL;
15903 var Input$3 = input;
15904 var sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
15905 var pathAvailable = Boolean(dirname && resolve$3 && relative && sep);
15906 var MapGenerator$2 = /*#__PURE__*/ function() {
15907 function MapGenerator2(stringify2, root2, opts, cssString) {
15908 this.stringify = stringify2;
15909 this.mapOpts = opts.map || {};
15910 this.root = root2;
15911 this.opts = opts;
15912 this.css = cssString;
15913 this.originalCSS = cssString;
15914 this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
15915 this.memoizedFileURLs = /* @__PURE__ */ new Map();
15916 this.memoizedPaths = /* @__PURE__ */ new Map();
15917 this.memoizedURLs = /* @__PURE__ */ new Map();
15918 }
15919 var _proto = MapGenerator2.prototype;
15920 _proto.addAnnotation = function addAnnotation() {
15921 var content;
15922 if (this.isInline()) {
15923 content = "data:application/json;base64," + this.toBase64(this.map.toString());
15924 } else if (typeof this.mapOpts.annotation === "string") {
15925 content = this.mapOpts.annotation;
15926 } else if (typeof this.mapOpts.annotation === "function") {
15927 content = this.mapOpts.annotation(this.opts.to, this.root);
15928 } else {
15929 content = this.outputFile() + ".map";
15930 }
15931 var eol = "\n";
15932 if (this.css.includes("\r\n")) eol = "\r\n";
15933 this.css += eol + "/*# sourceMappingURL=" + content + " */";
15934 };
15935 _proto.applyPrevMaps = function applyPrevMaps() {
15936 for(var _iterator = _create_for_of_iterator_helper_loose(this.previous()), _step; !(_step = _iterator()).done;){
15937 var prev = _step.value;
15938 var from = this.toUrl(this.path(prev.file));
15939 var root2 = prev.root || dirname(prev.file);
15940 var map = void 0;
15941 if (this.mapOpts.sourcesContent === false) {
15942 map = new SourceMapConsumer(prev.text);
15943 if (map.sourcesContent) {
15944 map.sourcesContent = null;
15945 }
15946 } else {
15947 map = prev.consumer();
15948 }
15949 this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
15950 }
15951 };
15952 _proto.clearAnnotation = function clearAnnotation() {
15953 if (this.mapOpts.annotation === false) return;
15954 if (this.root) {
15955 var node2;
15956 for(var i2 = this.root.nodes.length - 1; i2 >= 0; i2--){
15957 node2 = this.root.nodes[i2];
15958 if (node2.type !== "comment") continue;
15959 if (node2.text.indexOf("# sourceMappingURL=") === 0) {
15960 this.root.removeChild(i2);
15961 }
15962 }
15963 } else if (this.css) {
15964 this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, "");
15965 }
15966 };
15967 _proto.generate = function generate() {
15968 this.clearAnnotation();
15969 if (pathAvailable && sourceMapAvailable && this.isMap()) {
15970 return this.generateMap();
15971 } else {
15972 var result2 = "";
15973 this.stringify(this.root, function(i2) {
15974 result2 += i2;
15975 });
15976 return [
15977 result2
15978 ];
15979 }
15980 };
15981 _proto.generateMap = function generateMap() {
15982 if (this.root) {
15983 this.generateString();
15984 } else if (this.previous().length === 1) {
15985 var prev = this.previous()[0].consumer();
15986 prev.file = this.outputFile();
15987 this.map = SourceMapGenerator.fromSourceMap(prev, {
15988 ignoreInvalidMapping: true
15989 });
15990 } else {
15991 this.map = new SourceMapGenerator({
15992 file: this.outputFile(),
15993 ignoreInvalidMapping: true
15994 });
15995 this.map.addMapping({
15996 generated: {
15997 column: 0,
15998 line: 1
15999 },
16000 original: {
16001 column: 0,
16002 line: 1
16003 },
16004 source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
16005 });
16006 }
16007 if (this.isSourcesContent()) this.setSourcesContent();
16008 if (this.root && this.previous().length > 0) this.applyPrevMaps();
16009 if (this.isAnnotation()) this.addAnnotation();
16010 if (this.isInline()) {
16011 return [
16012 this.css
16013 ];
16014 } else {
16015 return [
16016 this.css,
16017 this.map
16018 ];
16019 }
16020 };
16021 _proto.generateString = function generateString() {
16022 var _this = this;
16023 this.css = "";
16024 this.map = new SourceMapGenerator({
16025 file: this.outputFile(),
16026 ignoreInvalidMapping: true
16027 });
16028 var line = 1;
16029 var column = 1;
16030 var noSource = "<no source>";
16031 var mapping = {
16032 generated: {
16033 column: 0,
16034 line: 0
16035 },
16036 original: {
16037 column: 0,
16038 line: 0
16039 },
16040 source: ""
16041 };
16042 var lines, last;
16043 this.stringify(this.root, function(str, node2, type) {
16044 _this.css += str;
16045 if (node2 && type !== "end") {
16046 mapping.generated.line = line;
16047 mapping.generated.column = column - 1;
16048 if (node2.source && node2.source.start) {
16049 mapping.source = _this.sourcePath(node2);
16050 mapping.original.line = node2.source.start.line;
16051 mapping.original.column = node2.source.start.column - 1;
16052 _this.map.addMapping(mapping);
16053 } else {
16054 mapping.source = noSource;
16055 mapping.original.line = 1;
16056 mapping.original.column = 0;
16057 _this.map.addMapping(mapping);
16058 }
16059 }
16060 lines = str.match(/\n/g);
16061 if (lines) {
16062 line += lines.length;
16063 last = str.lastIndexOf("\n");
16064 column = str.length - last;
16065 } else {
16066 column += str.length;
16067 }
16068 if (node2 && type !== "start") {
16069 var p = node2.parent || {
16070 raws: {}
16071 };
16072 var childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
16073 if (!childless || node2 !== p.last || p.raws.semicolon) {
16074 if (node2.source && node2.source.end) {
16075 mapping.source = _this.sourcePath(node2);
16076 mapping.original.line = node2.source.end.line;
16077 mapping.original.column = node2.source.end.column - 1;
16078 mapping.generated.line = line;
16079 mapping.generated.column = column - 2;
16080 _this.map.addMapping(mapping);
16081 } else {
16082 mapping.source = noSource;
16083 mapping.original.line = 1;
16084 mapping.original.column = 0;
16085 mapping.generated.line = line;
16086 mapping.generated.column = column - 1;
16087 _this.map.addMapping(mapping);
16088 }
16089 }
16090 }
16091 });
16092 };
16093 _proto.isAnnotation = function isAnnotation() {
16094 if (this.isInline()) {
16095 return true;
16096 }
16097 if (typeof this.mapOpts.annotation !== "undefined") {
16098 return this.mapOpts.annotation;
16099 }
16100 if (this.previous().length) {
16101 return this.previous().some(function(i2) {
16102 return i2.annotation;
16103 });
16104 }
16105 return true;
16106 };
16107 _proto.isInline = function isInline() {
16108 if (typeof this.mapOpts.inline !== "undefined") {
16109 return this.mapOpts.inline;
16110 }
16111 var annotation = this.mapOpts.annotation;
16112 if (typeof annotation !== "undefined" && annotation !== true) {
16113 return false;
16114 }
16115 if (this.previous().length) {
16116 return this.previous().some(function(i2) {
16117 return i2.inline;
16118 });
16119 }
16120 return true;
16121 };
16122 _proto.isMap = function isMap() {
16123 if (typeof this.opts.map !== "undefined") {
16124 return !!this.opts.map;
16125 }
16126 return this.previous().length > 0;
16127 };
16128 _proto.isSourcesContent = function isSourcesContent() {
16129 if (typeof this.mapOpts.sourcesContent !== "undefined") {
16130 return this.mapOpts.sourcesContent;
16131 }
16132 if (this.previous().length) {
16133 return this.previous().some(function(i2) {
16134 return i2.withContent();
16135 });
16136 }
16137 return true;
16138 };
16139 _proto.outputFile = function outputFile() {
16140 if (this.opts.to) {
16141 return this.path(this.opts.to);
16142 } else if (this.opts.from) {
16143 return this.path(this.opts.from);
16144 } else {
16145 return "to.css";
16146 }
16147 };
16148 _proto.path = function path(file) {
16149 if (this.mapOpts.absolute) return file;
16150 if (file.charCodeAt(0) === 60) return file;
16151 if (/^\w+:\/\//.test(file)) return file;
16152 var cached = this.memoizedPaths.get(file);
16153 if (cached) return cached;
16154 var from = this.opts.to ? dirname(this.opts.to) : ".";
16155 if (typeof this.mapOpts.annotation === "string") {
16156 from = dirname(resolve$3(from, this.mapOpts.annotation));
16157 }
16158 var path = relative(from, file);
16159 this.memoizedPaths.set(file, path);
16160 return path;
16161 };
16162 _proto.previous = function previous() {
16163 var _this = this;
16164 if (!this.previousMaps) {
16165 this.previousMaps = [];
16166 if (this.root) {
16167 this.root.walk(function(node2) {
16168 if (node2.source && node2.source.input.map) {
16169 var map = node2.source.input.map;
16170 if (!_this.previousMaps.includes(map)) {
16171 _this.previousMaps.push(map);
16172 }
16173 }
16174 });
16175 } else {
16176 var input2 = new Input$3(this.originalCSS, this.opts);
16177 if (input2.map) this.previousMaps.push(input2.map);
16178 }
16179 }
16180 return this.previousMaps;
16181 };
16182 _proto.setSourcesContent = function setSourcesContent() {
16183 var _this = this;
16184 var already = {};
16185 if (this.root) {
16186 this.root.walk(function(node2) {
16187 if (node2.source) {
16188 var from = node2.source.input.from;
16189 if (from && !already[from]) {
16190 already[from] = true;
16191 var fromUrl = _this.usesFileUrls ? _this.toFileUrl(from) : _this.toUrl(_this.path(from));
16192 _this.map.setSourceContent(fromUrl, node2.source.input.css);
16193 }
16194 }
16195 });
16196 } else if (this.css) {
16197 var from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
16198 this.map.setSourceContent(from, this.css);
16199 }
16200 };
16201 _proto.sourcePath = function sourcePath(node2) {
16202 if (this.mapOpts.from) {
16203 return this.toUrl(this.mapOpts.from);
16204 } else if (this.usesFileUrls) {
16205 return this.toFileUrl(node2.source.input.from);
16206 } else {
16207 return this.toUrl(this.path(node2.source.input.from));
16208 }
16209 };
16210 _proto.toBase64 = function toBase64(str) {
16211 if (Buffer) {
16212 return Buffer.from(str).toString("base64");
16213 } else {
16214 return window.btoa(unescape(encodeURIComponent(str)));
16215 }
16216 };
16217 _proto.toFileUrl = function toFileUrl(path) {
16218 var cached = this.memoizedFileURLs.get(path);
16219 if (cached) return cached;
16220 if (pathToFileURL) {
16221 var fileURL = pathToFileURL(path).toString();
16222 this.memoizedFileURLs.set(path, fileURL);
16223 return fileURL;
16224 } else {
16225 throw new Error("`map.absolute` option is not available in this PostCSS build");
16226 }
16227 };
16228 _proto.toUrl = function toUrl(path) {
16229 var cached = this.memoizedURLs.get(path);
16230 if (cached) return cached;
16231 if (sep === "\\") {
16232 path = path.replace(/\\/g, "/");
16233 }
16234 var url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
16235 this.memoizedURLs.set(path, url);
16236 return url;
16237 };
16238 return MapGenerator2;
16239 }();
16240 var mapGenerator = MapGenerator$2;
16241 var Node$2 = node;
16242 var Comment$4 = /*#__PURE__*/ function(Node$2) {
16243 _inherits(Comment2, Node$2);
16244 function Comment2(defaults) {
16245 var _this;
16246 _this = Node$2.call(this, defaults) || this;
16247 _this.type = "comment";
16248 return _this;
16249 }
16250 return Comment2;
16251 }(Node$2);
16252 var comment = Comment$4;
16253 Comment$4.default = Comment$4;
16254 var isClean$1 = symbols.isClean, my$1 = symbols.my;
16255 var Declaration$3 = declaration;
16256 var Comment$3 = comment;
16257 var Node$1 = node;
16258 var parse$4, Rule$4, AtRule$4, Root$6;
16259 function cleanSource(nodes) {
16260 return nodes.map(function(i2) {
16261 if (i2.nodes) i2.nodes = cleanSource(i2.nodes);
16262 delete i2.source;
16263 return i2;
16264 });
16265 }
16266 function markDirtyUp(node2) {
16267 node2[isClean$1] = false;
16268 if (node2.proxyOf.nodes) {
16269 for(var _iterator = _create_for_of_iterator_helper_loose(node2.proxyOf.nodes), _step; !(_step = _iterator()).done;){
16270 var i2 = _step.value;
16271 markDirtyUp(i2);
16272 }
16273 }
16274 }
16275 var Container$7 = /*#__PURE__*/ function(Node$1) {
16276 _inherits(Container2, Node$1);
16277 function Container2() {
16278 return Node$1.apply(this, arguments) || this;
16279 }
16280 var _proto = Container2.prototype;
16281 _proto.append = function append() {
16282 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16283 children[_key] = arguments[_key];
16284 }
16285 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
16286 var child = _step.value;
16287 var nodes = this.normalize(child, this.last);
16288 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
16289 var node2 = _step1.value;
16290 this.proxyOf.nodes.push(node2);
16291 }
16292 }
16293 this.markDirty();
16294 return this;
16295 };
16296 _proto.cleanRaws = function cleanRaws(keepBetween) {
16297 Node$1.prototype.cleanRaws.call(this, keepBetween);
16298 if (this.nodes) {
16299 for(var _iterator = _create_for_of_iterator_helper_loose(this.nodes), _step; !(_step = _iterator()).done;){
16300 var node2 = _step.value;
16301 node2.cleanRaws(keepBetween);
16302 }
16303 }
16304 };
16305 _proto.each = function each(callback) {
16306 if (!this.proxyOf.nodes) return void 0;
16307 var iterator = this.getIterator();
16308 var index2, result2;
16309 while(this.indexes[iterator] < this.proxyOf.nodes.length){
16310 index2 = this.indexes[iterator];
16311 result2 = callback(this.proxyOf.nodes[index2], index2);
16312 if (result2 === false) break;
16313 this.indexes[iterator] += 1;
16314 }
16315 delete this.indexes[iterator];
16316 return result2;
16317 };
16318 _proto.every = function every(condition) {
16319 return this.nodes.every(condition);
16320 };
16321 _proto.getIterator = function getIterator() {
16322 if (!this.lastEach) this.lastEach = 0;
16323 if (!this.indexes) this.indexes = {};
16324 this.lastEach += 1;
16325 var iterator = this.lastEach;
16326 this.indexes[iterator] = 0;
16327 return iterator;
16328 };
16329 _proto.getProxyProcessor = function getProxyProcessor() {
16330 return {
16331 get: function get(node2, prop) {
16332 if (prop === "proxyOf") {
16333 return node2;
16334 } else if (!node2[prop]) {
16335 return node2[prop];
16336 } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
16337 return function() {
16338 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
16339 args[_key] = arguments[_key];
16340 }
16341 var _node2;
16342 return (_node2 = node2)[prop].apply(_node2, [].concat(args.map(function(i2) {
16343 if (typeof i2 === "function") {
16344 return function(child, index2) {
16345 return i2(child.toProxy(), index2);
16346 };
16347 } else {
16348 return i2;
16349 }
16350 })));
16351 };
16352 } else if (prop === "every" || prop === "some") {
16353 return function(cb) {
16354 return node2[prop](function(child) {
16355 for(var _len = arguments.length, other = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
16356 other[_key - 1] = arguments[_key];
16357 }
16358 return cb.apply(void 0, [].concat([
16359 child.toProxy()
16360 ], other));
16361 });
16362 };
16363 } else if (prop === "root") {
16364 return function() {
16365 return node2.root().toProxy();
16366 };
16367 } else if (prop === "nodes") {
16368 return node2.nodes.map(function(i2) {
16369 return i2.toProxy();
16370 });
16371 } else if (prop === "first" || prop === "last") {
16372 return node2[prop].toProxy();
16373 } else {
16374 return node2[prop];
16375 }
16376 },
16377 set: function set(node2, prop, value) {
16378 if (node2[prop] === value) return true;
16379 node2[prop] = value;
16380 if (prop === "name" || prop === "params" || prop === "selector") {
16381 node2.markDirty();
16382 }
16383 return true;
16384 }
16385 };
16386 };
16387 _proto.index = function index(child) {
16388 if (typeof child === "number") return child;
16389 if (child.proxyOf) child = child.proxyOf;
16390 return this.proxyOf.nodes.indexOf(child);
16391 };
16392 _proto.insertAfter = function insertAfter(exist, add) {
16393 var existIndex = this.index(exist);
16394 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
16395 existIndex = this.index(exist);
16396 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
16397 var node2 = _step.value;
16398 this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
16399 }
16400 var index2;
16401 for(var id in this.indexes){
16402 index2 = this.indexes[id];
16403 if (existIndex < index2) {
16404 this.indexes[id] = index2 + nodes.length;
16405 }
16406 }
16407 this.markDirty();
16408 return this;
16409 };
16410 _proto.insertBefore = function insertBefore(exist, add) {
16411 var existIndex = this.index(exist);
16412 var type = existIndex === 0 ? "prepend" : false;
16413 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
16414 existIndex = this.index(exist);
16415 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
16416 var node2 = _step.value;
16417 this.proxyOf.nodes.splice(existIndex, 0, node2);
16418 }
16419 var index2;
16420 for(var id in this.indexes){
16421 index2 = this.indexes[id];
16422 if (existIndex <= index2) {
16423 this.indexes[id] = index2 + nodes.length;
16424 }
16425 }
16426 this.markDirty();
16427 return this;
16428 };
16429 _proto.normalize = function normalize(nodes, sample) {
16430 var _this = this;
16431 if (typeof nodes === "string") {
16432 nodes = cleanSource(parse$4(nodes).nodes);
16433 } else if (typeof nodes === "undefined") {
16434 nodes = [];
16435 } else if (Array.isArray(nodes)) {
16436 nodes = nodes.slice(0);
16437 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
16438 var i2 = _step.value;
16439 if (i2.parent) i2.parent.removeChild(i2, "ignore");
16440 }
16441 } else if (nodes.type === "root" && this.type !== "document") {
16442 nodes = nodes.nodes.slice(0);
16443 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
16444 var i21 = _step1.value;
16445 if (i21.parent) i21.parent.removeChild(i21, "ignore");
16446 }
16447 } else if (nodes.type) {
16448 nodes = [
16449 nodes
16450 ];
16451 } else if (nodes.prop) {
16452 if (typeof nodes.value === "undefined") {
16453 throw new Error("Value field is missed in node creation");
16454 } else if (typeof nodes.value !== "string") {
16455 nodes.value = String(nodes.value);
16456 }
16457 nodes = [
16458 new Declaration$3(nodes)
16459 ];
16460 } else if (nodes.selector) {
16461 nodes = [
16462 new Rule$4(nodes)
16463 ];
16464 } else if (nodes.name) {
16465 nodes = [
16466 new AtRule$4(nodes)
16467 ];
16468 } else if (nodes.text) {
16469 nodes = [
16470 new Comment$3(nodes)
16471 ];
16472 } else {
16473 throw new Error("Unknown node type in node creation");
16474 }
16475 var processed = nodes.map(function(i2) {
16476 if (!i2[my$1]) Container2.rebuild(i2);
16477 i2 = i2.proxyOf;
16478 if (i2.parent) i2.parent.removeChild(i2);
16479 if (i2[isClean$1]) markDirtyUp(i2);
16480 if (typeof i2.raws.before === "undefined") {
16481 if (sample && typeof sample.raws.before !== "undefined") {
16482 i2.raws.before = sample.raws.before.replace(/\S/g, "");
16483 }
16484 }
16485 i2.parent = _this.proxyOf;
16486 return i2;
16487 });
16488 return processed;
16489 };
16490 _proto.prepend = function prepend() {
16491 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16492 children[_key] = arguments[_key];
16493 }
16494 children = children.reverse();
16495 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
16496 var child = _step.value;
16497 var nodes = this.normalize(child, this.first, "prepend").reverse();
16498 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
16499 var node2 = _step1.value;
16500 this.proxyOf.nodes.unshift(node2);
16501 }
16502 for(var id in this.indexes){
16503 this.indexes[id] = this.indexes[id] + nodes.length;
16504 }
16505 }
16506 this.markDirty();
16507 return this;
16508 };
16509 _proto.push = function push(child) {
16510 child.parent = this;
16511 this.proxyOf.nodes.push(child);
16512 return this;
16513 };
16514 _proto.removeAll = function removeAll() {
16515 for(var _iterator = _create_for_of_iterator_helper_loose(this.proxyOf.nodes), _step; !(_step = _iterator()).done;){
16516 var node2 = _step.value;
16517 node2.parent = void 0;
16518 }
16519 this.proxyOf.nodes = [];
16520 this.markDirty();
16521 return this;
16522 };
16523 _proto.removeChild = function removeChild(child) {
16524 child = this.index(child);
16525 this.proxyOf.nodes[child].parent = void 0;
16526 this.proxyOf.nodes.splice(child, 1);
16527 var index2;
16528 for(var id in this.indexes){
16529 index2 = this.indexes[id];
16530 if (index2 >= child) {
16531 this.indexes[id] = index2 - 1;
16532 }
16533 }
16534 this.markDirty();
16535 return this;
16536 };
16537 _proto.replaceValues = function replaceValues(pattern, opts, callback) {
16538 if (!callback) {
16539 callback = opts;
16540 opts = {};
16541 }
16542 this.walkDecls(function(decl) {
16543 if (opts.props && !opts.props.includes(decl.prop)) return;
16544 if (opts.fast && !decl.value.includes(opts.fast)) return;
16545 decl.value = decl.value.replace(pattern, callback);
16546 });
16547 this.markDirty();
16548 return this;
16549 };
16550 _proto.some = function some(condition) {
16551 return this.nodes.some(condition);
16552 };
16553 _proto.walk = function walk(callback) {
16554 return this.each(function(child, i2) {
16555 var result2;
16556 try {
16557 result2 = callback(child, i2);
16558 } catch (e2) {
16559 throw child.addToError(e2);
16560 }
16561 if (result2 !== false && child.walk) {
16562 result2 = child.walk(callback);
16563 }
16564 return result2;
16565 });
16566 };
16567 _proto.walkAtRules = function walkAtRules(name, callback) {
16568 if (!callback) {
16569 callback = name;
16570 return this.walk(function(child, i2) {
16571 if (child.type === "atrule") {
16572 return callback(child, i2);
16573 }
16574 });
16575 }
16576 if (_instanceof(name, RegExp)) {
16577 return this.walk(function(child, i2) {
16578 if (child.type === "atrule" && name.test(child.name)) {
16579 return callback(child, i2);
16580 }
16581 });
16582 }
16583 return this.walk(function(child, i2) {
16584 if (child.type === "atrule" && child.name === name) {
16585 return callback(child, i2);
16586 }
16587 });
16588 };
16589 _proto.walkComments = function walkComments(callback) {
16590 return this.walk(function(child, i2) {
16591 if (child.type === "comment") {
16592 return callback(child, i2);
16593 }
16594 });
16595 };
16596 _proto.walkDecls = function walkDecls(prop, callback) {
16597 if (!callback) {
16598 callback = prop;
16599 return this.walk(function(child, i2) {
16600 if (child.type === "decl") {
16601 return callback(child, i2);
16602 }
16603 });
16604 }
16605 if (_instanceof(prop, RegExp)) {
16606 return this.walk(function(child, i2) {
16607 if (child.type === "decl" && prop.test(child.prop)) {
16608 return callback(child, i2);
16609 }
16610 });
16611 }
16612 return this.walk(function(child, i2) {
16613 if (child.type === "decl" && child.prop === prop) {
16614 return callback(child, i2);
16615 }
16616 });
16617 };
16618 _proto.walkRules = function walkRules(selector, callback) {
16619 if (!callback) {
16620 callback = selector;
16621 return this.walk(function(child, i2) {
16622 if (child.type === "rule") {
16623 return callback(child, i2);
16624 }
16625 });
16626 }
16627 if (_instanceof(selector, RegExp)) {
16628 return this.walk(function(child, i2) {
16629 if (child.type === "rule" && selector.test(child.selector)) {
16630 return callback(child, i2);
16631 }
16632 });
16633 }
16634 return this.walk(function(child, i2) {
16635 if (child.type === "rule" && child.selector === selector) {
16636 return callback(child, i2);
16637 }
16638 });
16639 };
16640 _create_class(Container2, [
16641 {
16642 key: "first",
16643 get: function get() {
16644 if (!this.proxyOf.nodes) return void 0;
16645 return this.proxyOf.nodes[0];
16646 }
16647 },
16648 {
16649 key: "last",
16650 get: function get() {
16651 if (!this.proxyOf.nodes) return void 0;
16652 return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
16653 }
16654 }
16655 ]);
16656 return Container2;
16657 }(Node$1);
16658 Container$7.registerParse = function(dependant) {
16659 parse$4 = dependant;
16660 };
16661 Container$7.registerRule = function(dependant) {
16662 Rule$4 = dependant;
16663 };
16664 Container$7.registerAtRule = function(dependant) {
16665 AtRule$4 = dependant;
16666 };
16667 Container$7.registerRoot = function(dependant) {
16668 Root$6 = dependant;
16669 };
16670 var container = Container$7;
16671 Container$7.default = Container$7;
16672 Container$7.rebuild = function(node2) {
16673 if (node2.type === "atrule") {
16674 Object.setPrototypeOf(node2, AtRule$4.prototype);
16675 } else if (node2.type === "rule") {
16676 Object.setPrototypeOf(node2, Rule$4.prototype);
16677 } else if (node2.type === "decl") {
16678 Object.setPrototypeOf(node2, Declaration$3.prototype);
16679 } else if (node2.type === "comment") {
16680 Object.setPrototypeOf(node2, Comment$3.prototype);
16681 } else if (node2.type === "root") {
16682 Object.setPrototypeOf(node2, Root$6.prototype);
16683 }
16684 node2[my$1] = true;
16685 if (node2.nodes) {
16686 node2.nodes.forEach(function(child) {
16687 Container$7.rebuild(child);
16688 });
16689 }
16690 };
16691 var Container$6 = container;
16692 var LazyResult$4, Processor$3;
16693 var Document$3 = /*#__PURE__*/ function(Container$6) {
16694 _inherits(Document23, Container$6);
16695 function Document23(defaults) {
16696 var _this;
16697 _this = Container$6.call(this, _extends({
16698 type: "document"
16699 }, defaults)) || this;
16700 if (!_this.nodes) {
16701 _this.nodes = [];
16702 }
16703 return _this;
16704 }
16705 var _proto = Document23.prototype;
16706 _proto.toResult = function toResult(opts) {
16707 if (opts === void 0) opts = {};
16708 var lazy = new LazyResult$4(new Processor$3(), this, opts);
16709 return lazy.stringify();
16710 };
16711 return Document23;
16712 }(Container$6);
16713 Document$3.registerLazyResult = function(dependant) {
16714 LazyResult$4 = dependant;
16715 };
16716 Document$3.registerProcessor = function(dependant) {
16717 Processor$3 = dependant;
16718 };
16719 var document$1$2 = Document$3;
16720 Document$3.default = Document$3;
16721 var printed = {};
16722 var warnOnce$2 = function warnOnce2(message) {
16723 if (printed[message]) return;
16724 printed[message] = true;
16725 if (typeof console !== "undefined" && console.warn) {
16726 console.warn(message);
16727 }
16728 };
16729 var Warning$2 = /*#__PURE__*/ function() {
16730 function Warning2(text, opts) {
16731 if (opts === void 0) opts = {};
16732 this.type = "warning";
16733 this.text = text;
16734 if (opts.node && opts.node.source) {
16735 var range = opts.node.rangeBy(opts);
16736 this.line = range.start.line;
16737 this.column = range.start.column;
16738 this.endLine = range.end.line;
16739 this.endColumn = range.end.column;
16740 }
16741 for(var opt in opts)this[opt] = opts[opt];
16742 }
16743 var _proto = Warning2.prototype;
16744 _proto.toString = function toString() {
16745 if (this.node) {
16746 return this.node.error(this.text, {
16747 index: this.index,
16748 plugin: this.plugin,
16749 word: this.word
16750 }).message;
16751 }
16752 if (this.plugin) {
16753 return this.plugin + ": " + this.text;
16754 }
16755 return this.text;
16756 };
16757 return Warning2;
16758 }();
16759 var warning = Warning$2;
16760 Warning$2.default = Warning$2;
16761 var Warning$1 = warning;
16762 var Result$3 = /*#__PURE__*/ function() {
16763 function Result2(processor2, root2, opts) {
16764 this.processor = processor2;
16765 this.messages = [];
16766 this.root = root2;
16767 this.opts = opts;
16768 this.css = void 0;
16769 this.map = void 0;
16770 }
16771 var _proto = Result2.prototype;
16772 _proto.toString = function toString() {
16773 return this.css;
16774 };
16775 _proto.warn = function warn(text, opts) {
16776 if (opts === void 0) opts = {};
16777 if (!opts.plugin) {
16778 if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
16779 opts.plugin = this.lastPlugin.postcssPlugin;
16780 }
16781 }
16782 var warning2 = new Warning$1(text, opts);
16783 this.messages.push(warning2);
16784 return warning2;
16785 };
16786 _proto.warnings = function warnings() {
16787 return this.messages.filter(function(i2) {
16788 return i2.type === "warning";
16789 });
16790 };
16791 _create_class(Result2, [
16792 {
16793 key: "content",
16794 get: function get() {
16795 return this.css;
16796 }
16797 }
16798 ]);
16799 return Result2;
16800 }();
16801 var result = Result$3;
16802 Result$3.default = Result$3;
16803 var SINGLE_QUOTE = "'".charCodeAt(0);
16804 var DOUBLE_QUOTE = '"'.charCodeAt(0);
16805 var BACKSLASH = "\\".charCodeAt(0);
16806 var SLASH = "/".charCodeAt(0);
16807 var NEWLINE = "\n".charCodeAt(0);
16808 var SPACE = " ".charCodeAt(0);
16809 var FEED = "\f".charCodeAt(0);
16810 var TAB = " ".charCodeAt(0);
16811 var CR = "\r".charCodeAt(0);
16812 var OPEN_SQUARE = "[".charCodeAt(0);
16813 var CLOSE_SQUARE = "]".charCodeAt(0);
16814 var OPEN_PARENTHESES = "(".charCodeAt(0);
16815 var CLOSE_PARENTHESES = ")".charCodeAt(0);
16816 var OPEN_CURLY = "{".charCodeAt(0);
16817 var CLOSE_CURLY = "}".charCodeAt(0);
16818 var SEMICOLON = ";".charCodeAt(0);
16819 var ASTERISK = "*".charCodeAt(0);
16820 var COLON = ":".charCodeAt(0);
16821 var AT = "@".charCodeAt(0);
16822 var RE_AT_END = /[\t\n\f\r "#'()/;[\\\]{}]/g;
16823 var RE_WORD_END = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
16824 var RE_BAD_BRACKET = /.[\r\n"'(/\\]/;
16825 var RE_HEX_ESCAPE = /[\da-f]/i;
16826 var tokenize = function tokenizer2(input2, options) {
16827 if (options === void 0) options = {};
16828 var css = input2.css.valueOf();
16829 var ignore = options.ignoreErrors;
16830 var code, next, quote, content, escape;
16831 var escaped, escapePos, prev, n2, currentToken;
16832 var length = css.length;
16833 var pos = 0;
16834 var buffer = [];
16835 var returned = [];
16836 function position() {
16837 return pos;
16838 }
16839 function unclosed(what) {
16840 throw input2.error("Unclosed " + what, pos);
16841 }
16842 function endOfFile() {
16843 return returned.length === 0 && pos >= length;
16844 }
16845 function nextToken(opts) {
16846 if (returned.length) return returned.pop();
16847 if (pos >= length) return;
16848 var ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
16849 code = css.charCodeAt(pos);
16850 switch(code){
16851 case NEWLINE:
16852 case SPACE:
16853 case TAB:
16854 case CR:
16855 case FEED:
16856 {
16857 next = pos;
16858 do {
16859 next += 1;
16860 code = css.charCodeAt(next);
16861 }while (code === SPACE || code === NEWLINE || code === TAB || code === CR || code === FEED);
16862 currentToken = [
16863 "space",
16864 css.slice(pos, next)
16865 ];
16866 pos = next - 1;
16867 break;
16868 }
16869 case OPEN_SQUARE:
16870 case CLOSE_SQUARE:
16871 case OPEN_CURLY:
16872 case CLOSE_CURLY:
16873 case COLON:
16874 case SEMICOLON:
16875 case CLOSE_PARENTHESES:
16876 {
16877 var controlChar = String.fromCharCode(code);
16878 currentToken = [
16879 controlChar,
16880 controlChar,
16881 pos
16882 ];
16883 break;
16884 }
16885 case OPEN_PARENTHESES:
16886 {
16887 prev = buffer.length ? buffer.pop()[1] : "";
16888 n2 = css.charCodeAt(pos + 1);
16889 if (prev === "url" && n2 !== SINGLE_QUOTE && n2 !== DOUBLE_QUOTE && n2 !== SPACE && n2 !== NEWLINE && n2 !== TAB && n2 !== FEED && n2 !== CR) {
16890 next = pos;
16891 do {
16892 escaped = false;
16893 next = css.indexOf(")", next + 1);
16894 if (next === -1) {
16895 if (ignore || ignoreUnclosed) {
16896 next = pos;
16897 break;
16898 } else {
16899 unclosed("bracket");
16900 }
16901 }
16902 escapePos = next;
16903 while(css.charCodeAt(escapePos - 1) === BACKSLASH){
16904 escapePos -= 1;
16905 escaped = !escaped;
16906 }
16907 }while (escaped);
16908 currentToken = [
16909 "brackets",
16910 css.slice(pos, next + 1),
16911 pos,
16912 next
16913 ];
16914 pos = next;
16915 } else {
16916 next = css.indexOf(")", pos + 1);
16917 content = css.slice(pos, next + 1);
16918 if (next === -1 || RE_BAD_BRACKET.test(content)) {
16919 currentToken = [
16920 "(",
16921 "(",
16922 pos
16923 ];
16924 } else {
16925 currentToken = [
16926 "brackets",
16927 content,
16928 pos,
16929 next
16930 ];
16931 pos = next;
16932 }
16933 }
16934 break;
16935 }
16936 case SINGLE_QUOTE:
16937 case DOUBLE_QUOTE:
16938 {
16939 quote = code === SINGLE_QUOTE ? "'" : '"';
16940 next = pos;
16941 do {
16942 escaped = false;
16943 next = css.indexOf(quote, next + 1);
16944 if (next === -1) {
16945 if (ignore || ignoreUnclosed) {
16946 next = pos + 1;
16947 break;
16948 } else {
16949 unclosed("string");
16950 }
16951 }
16952 escapePos = next;
16953 while(css.charCodeAt(escapePos - 1) === BACKSLASH){
16954 escapePos -= 1;
16955 escaped = !escaped;
16956 }
16957 }while (escaped);
16958 currentToken = [
16959 "string",
16960 css.slice(pos, next + 1),
16961 pos,
16962 next
16963 ];
16964 pos = next;
16965 break;
16966 }
16967 case AT:
16968 {
16969 RE_AT_END.lastIndex = pos + 1;
16970 RE_AT_END.test(css);
16971 if (RE_AT_END.lastIndex === 0) {
16972 next = css.length - 1;
16973 } else {
16974 next = RE_AT_END.lastIndex - 2;
16975 }
16976 currentToken = [
16977 "at-word",
16978 css.slice(pos, next + 1),
16979 pos,
16980 next
16981 ];
16982 pos = next;
16983 break;
16984 }
16985 case BACKSLASH:
16986 {
16987 next = pos;
16988 escape = true;
16989 while(css.charCodeAt(next + 1) === BACKSLASH){
16990 next += 1;
16991 escape = !escape;
16992 }
16993 code = css.charCodeAt(next + 1);
16994 if (escape && code !== SLASH && code !== SPACE && code !== NEWLINE && code !== TAB && code !== CR && code !== FEED) {
16995 next += 1;
16996 if (RE_HEX_ESCAPE.test(css.charAt(next))) {
16997 while(RE_HEX_ESCAPE.test(css.charAt(next + 1))){
16998 next += 1;
16999 }
17000 if (css.charCodeAt(next + 1) === SPACE) {
17001 next += 1;
17002 }
17003 }
17004 }
17005 currentToken = [
17006 "word",
17007 css.slice(pos, next + 1),
17008 pos,
17009 next
17010 ];
17011 pos = next;
17012 break;
17013 }
17014 default:
17015 {
17016 if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
17017 next = css.indexOf("*/", pos + 2) + 1;
17018 if (next === 0) {
17019 if (ignore || ignoreUnclosed) {
17020 next = css.length;
17021 } else {
17022 unclosed("comment");
17023 }
17024 }
17025 currentToken = [
17026 "comment",
17027 css.slice(pos, next + 1),
17028 pos,
17029 next
17030 ];
17031 pos = next;
17032 } else {
17033 RE_WORD_END.lastIndex = pos + 1;
17034 RE_WORD_END.test(css);
17035 if (RE_WORD_END.lastIndex === 0) {
17036 next = css.length - 1;
17037 } else {
17038 next = RE_WORD_END.lastIndex - 2;
17039 }
17040 currentToken = [
17041 "word",
17042 css.slice(pos, next + 1),
17043 pos,
17044 next
17045 ];
17046 buffer.push(currentToken);
17047 pos = next;
17048 }
17049 break;
17050 }
17051 }
17052 pos++;
17053 return currentToken;
17054 }
17055 function back(token) {
17056 returned.push(token);
17057 }
17058 return {
17059 back: back,
17060 endOfFile: endOfFile,
17061 nextToken: nextToken,
17062 position: position
17063 };
17064 };
17065 var Container$5 = container;
17066 var AtRule$3 = /*#__PURE__*/ function(Container$5) {
17067 _inherits(AtRule2, Container$5);
17068 function AtRule2(defaults) {
17069 var _this;
17070 _this = Container$5.call(this, defaults) || this;
17071 _this.type = "atrule";
17072 return _this;
17073 }
17074 var _proto = AtRule2.prototype;
17075 _proto.append = function append() {
17076 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
17077 children[_key] = arguments[_key];
17078 }
17079 var _Container$5_prototype_append;
17080 if (!this.proxyOf.nodes) this.nodes = [];
17081 return (_Container$5_prototype_append = Container$5.prototype.append).call.apply(_Container$5_prototype_append, [].concat([
17082 this
17083 ], children));
17084 };
17085 _proto.prepend = function prepend() {
17086 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
17087 children[_key] = arguments[_key];
17088 }
17089 var _Container$5_prototype_prepend;
17090 if (!this.proxyOf.nodes) this.nodes = [];
17091 return (_Container$5_prototype_prepend = Container$5.prototype.prepend).call.apply(_Container$5_prototype_prepend, [].concat([
17092 this
17093 ], children));
17094 };
17095 return AtRule2;
17096 }(Container$5);
17097 var atRule = AtRule$3;
17098 AtRule$3.default = AtRule$3;
17099 Container$5.registerAtRule(AtRule$3);
17100 var Container$4 = container;
17101 var LazyResult$3, Processor$2;
17102 var Root$5 = /*#__PURE__*/ function(Container$4) {
17103 _inherits(Root2, Container$4);
17104 function Root2(defaults) {
17105 var _this;
17106 _this = Container$4.call(this, defaults) || this;
17107 _this.type = "root";
17108 if (!_this.nodes) _this.nodes = [];
17109 return _this;
17110 }
17111 var _proto = Root2.prototype;
17112 _proto.normalize = function normalize(child, sample, type) {
17113 var nodes = Container$4.prototype.normalize.call(this, child);
17114 if (sample) {
17115 if (type === "prepend") {
17116 if (this.nodes.length > 1) {
17117 sample.raws.before = this.nodes[1].raws.before;
17118 } else {
17119 delete sample.raws.before;
17120 }
17121 } else if (this.first !== sample) {
17122 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
17123 var node2 = _step.value;
17124 node2.raws.before = sample.raws.before;
17125 }
17126 }
17127 }
17128 return nodes;
17129 };
17130 _proto.removeChild = function removeChild(child, ignore) {
17131 var index2 = this.index(child);
17132 if (!ignore && index2 === 0 && this.nodes.length > 1) {
17133 this.nodes[1].raws.before = this.nodes[index2].raws.before;
17134 }
17135 return Container$4.prototype.removeChild.call(this, child);
17136 };
17137 _proto.toResult = function toResult(opts) {
17138 if (opts === void 0) opts = {};
17139 var lazy = new LazyResult$3(new Processor$2(), this, opts);
17140 return lazy.stringify();
17141 };
17142 return Root2;
17143 }(Container$4);
17144 Root$5.registerLazyResult = function(dependant) {
17145 LazyResult$3 = dependant;
17146 };
17147 Root$5.registerProcessor = function(dependant) {
17148 Processor$2 = dependant;
17149 };
17150 var root = Root$5;
17151 Root$5.default = Root$5;
17152 Container$4.registerRoot(Root$5);
17153 var list$2 = {
17154 comma: function comma(string) {
17155 return list$2.split(string, [
17156 ","
17157 ], true);
17158 },
17159 space: function space(string) {
17160 var spaces = [
17161 " ",
17162 "\n",
17163 " "
17164 ];
17165 return list$2.split(string, spaces);
17166 },
17167 split: function split(string, separators, last) {
17168 var array = [];
17169 var current = "";
17170 var split = false;
17171 var func = 0;
17172 var inQuote = false;
17173 var prevQuote = "";
17174 var escape = false;
17175 for(var _iterator = _create_for_of_iterator_helper_loose(string), _step; !(_step = _iterator()).done;){
17176 var letter = _step.value;
17177 if (escape) {
17178 escape = false;
17179 } else if (letter === "\\") {
17180 escape = true;
17181 } else if (inQuote) {
17182 if (letter === prevQuote) {
17183 inQuote = false;
17184 }
17185 } else if (letter === '"' || letter === "'") {
17186 inQuote = true;
17187 prevQuote = letter;
17188 } else if (letter === "(") {
17189 func += 1;
17190 } else if (letter === ")") {
17191 if (func > 0) func -= 1;
17192 } else if (func === 0) {
17193 if (separators.includes(letter)) split = true;
17194 }
17195 if (split) {
17196 if (current !== "") array.push(current.trim());
17197 current = "";
17198 split = false;
17199 } else {
17200 current += letter;
17201 }
17202 }
17203 if (last || current !== "") array.push(current.trim());
17204 return array;
17205 }
17206 };
17207 var list_1 = list$2;
17208 list$2.default = list$2;
17209 var Container$3 = container;
17210 var list$1 = list_1;
17211 var Rule$3 = /*#__PURE__*/ function(Container$3) {
17212 _inherits(Rule2, Container$3);
17213 function Rule2(defaults) {
17214 var _this;
17215 _this = Container$3.call(this, defaults) || this;
17216 _this.type = "rule";
17217 if (!_this.nodes) _this.nodes = [];
17218 return _this;
17219 }
17220 _create_class(Rule2, [
17221 {
17222 key: "selectors",
17223 get: function get() {
17224 return list$1.comma(this.selector);
17225 },
17226 set: function set(values) {
17227 var match = this.selector ? this.selector.match(/,\s*/) : null;
17228 var sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen");
17229 this.selector = values.join(sep2);
17230 }
17231 }
17232 ]);
17233 return Rule2;
17234 }(Container$3);
17235 var rule = Rule$3;
17236 Rule$3.default = Rule$3;
17237 Container$3.registerRule(Rule$3);
17238 var Declaration$2 = declaration;
17239 var tokenizer22 = tokenize;
17240 var Comment$2 = comment;
17241 var AtRule$2 = atRule;
17242 var Root$4 = root;
17243 var Rule$2 = rule;
17244 var SAFE_COMMENT_NEIGHBOR = {
17245 empty: true,
17246 space: true
17247 };
17248 function findLastWithPosition(tokens) {
17249 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
17250 var token = tokens[i2];
17251 var pos = token[3] || token[2];
17252 if (pos) return pos;
17253 }
17254 }
17255 var Parser$1 = /*#__PURE__*/ function() {
17256 function Parser2(input2) {
17257 this.input = input2;
17258 this.root = new Root$4();
17259 this.current = this.root;
17260 this.spaces = "";
17261 this.semicolon = false;
17262 this.createTokenizer();
17263 this.root.source = {
17264 input: input2,
17265 start: {
17266 column: 1,
17267 line: 1,
17268 offset: 0
17269 }
17270 };
17271 }
17272 var _proto = Parser2.prototype;
17273 _proto.atrule = function atrule(token) {
17274 var node2 = new AtRule$2();
17275 node2.name = token[1].slice(1);
17276 if (node2.name === "") {
17277 this.unnamedAtrule(node2, token);
17278 }
17279 this.init(node2, token[2]);
17280 var type;
17281 var prev;
17282 var shift;
17283 var last = false;
17284 var open = false;
17285 var params = [];
17286 var brackets = [];
17287 while(!this.tokenizer.endOfFile()){
17288 token = this.tokenizer.nextToken();
17289 type = token[0];
17290 if (type === "(" || type === "[") {
17291 brackets.push(type === "(" ? ")" : "]");
17292 } else if (type === "{" && brackets.length > 0) {
17293 brackets.push("}");
17294 } else if (type === brackets[brackets.length - 1]) {
17295 brackets.pop();
17296 }
17297 if (brackets.length === 0) {
17298 if (type === ";") {
17299 node2.source.end = this.getPosition(token[2]);
17300 node2.source.end.offset++;
17301 this.semicolon = true;
17302 break;
17303 } else if (type === "{") {
17304 open = true;
17305 break;
17306 } else if (type === "}") {
17307 if (params.length > 0) {
17308 shift = params.length - 1;
17309 prev = params[shift];
17310 while(prev && prev[0] === "space"){
17311 prev = params[--shift];
17312 }
17313 if (prev) {
17314 node2.source.end = this.getPosition(prev[3] || prev[2]);
17315 node2.source.end.offset++;
17316 }
17317 }
17318 this.end(token);
17319 break;
17320 } else {
17321 params.push(token);
17322 }
17323 } else {
17324 params.push(token);
17325 }
17326 if (this.tokenizer.endOfFile()) {
17327 last = true;
17328 break;
17329 }
17330 }
17331 node2.raws.between = this.spacesAndCommentsFromEnd(params);
17332 if (params.length) {
17333 node2.raws.afterName = this.spacesAndCommentsFromStart(params);
17334 this.raw(node2, "params", params);
17335 if (last) {
17336 token = params[params.length - 1];
17337 node2.source.end = this.getPosition(token[3] || token[2]);
17338 node2.source.end.offset++;
17339 this.spaces = node2.raws.between;
17340 node2.raws.between = "";
17341 }
17342 } else {
17343 node2.raws.afterName = "";
17344 node2.params = "";
17345 }
17346 if (open) {
17347 node2.nodes = [];
17348 this.current = node2;
17349 }
17350 };
17351 _proto.checkMissedSemicolon = function checkMissedSemicolon(tokens) {
17352 var colon = this.colon(tokens);
17353 if (colon === false) return;
17354 var founded = 0;
17355 var token;
17356 for(var j = colon - 1; j >= 0; j--){
17357 token = tokens[j];
17358 if (token[0] !== "space") {
17359 founded += 1;
17360 if (founded === 2) break;
17361 }
17362 }
17363 throw this.input.error("Missed semicolon", token[0] === "word" ? token[3] + 1 : token[2]);
17364 };
17365 _proto.colon = function colon(tokens) {
17366 var brackets = 0;
17367 var token, type, prev;
17368 for(var _iterator = _create_for_of_iterator_helper_loose(tokens.entries()), _step; !(_step = _iterator()).done;){
17369 var _step_value = _step.value, i2 = _step_value[0], element = _step_value[1];
17370 token = element;
17371 type = token[0];
17372 if (type === "(") {
17373 brackets += 1;
17374 }
17375 if (type === ")") {
17376 brackets -= 1;
17377 }
17378 if (brackets === 0 && type === ":") {
17379 if (!prev) {
17380 this.doubleColon(token);
17381 } else if (prev[0] === "word" && prev[1] === "progid") {
17382 continue;
17383 } else {
17384 return i2;
17385 }
17386 }
17387 prev = token;
17388 }
17389 return false;
17390 };
17391 _proto.comment = function comment(token) {
17392 var node2 = new Comment$2();
17393 this.init(node2, token[2]);
17394 node2.source.end = this.getPosition(token[3] || token[2]);
17395 node2.source.end.offset++;
17396 var text = token[1].slice(2, -2);
17397 if (/^\s*$/.test(text)) {
17398 node2.text = "";
17399 node2.raws.left = text;
17400 node2.raws.right = "";
17401 } else {
17402 var match = text.match(/^(\s*)([^]*\S)(\s*)$/);
17403 node2.text = match[2];
17404 node2.raws.left = match[1];
17405 node2.raws.right = match[3];
17406 }
17407 };
17408 _proto.createTokenizer = function createTokenizer() {
17409 this.tokenizer = tokenizer22(this.input);
17410 };
17411 _proto.decl = function decl(tokens, customProperty) {
17412 var node2 = new Declaration$2();
17413 this.init(node2, tokens[0][2]);
17414 var last = tokens[tokens.length - 1];
17415 if (last[0] === ";") {
17416 this.semicolon = true;
17417 tokens.pop();
17418 }
17419 node2.source.end = this.getPosition(last[3] || last[2] || findLastWithPosition(tokens));
17420 node2.source.end.offset++;
17421 while(tokens[0][0] !== "word"){
17422 if (tokens.length === 1) this.unknownWord(tokens);
17423 node2.raws.before += tokens.shift()[1];
17424 }
17425 node2.source.start = this.getPosition(tokens[0][2]);
17426 node2.prop = "";
17427 while(tokens.length){
17428 var type = tokens[0][0];
17429 if (type === ":" || type === "space" || type === "comment") {
17430 break;
17431 }
17432 node2.prop += tokens.shift()[1];
17433 }
17434 node2.raws.between = "";
17435 var token;
17436 while(tokens.length){
17437 token = tokens.shift();
17438 if (token[0] === ":") {
17439 node2.raws.between += token[1];
17440 break;
17441 } else {
17442 if (token[0] === "word" && /\w/.test(token[1])) {
17443 this.unknownWord([
17444 token
17445 ]);
17446 }
17447 node2.raws.between += token[1];
17448 }
17449 }
17450 if (node2.prop[0] === "_" || node2.prop[0] === "*") {
17451 node2.raws.before += node2.prop[0];
17452 node2.prop = node2.prop.slice(1);
17453 }
17454 var firstSpaces = [];
17455 var next;
17456 while(tokens.length){
17457 next = tokens[0][0];
17458 if (next !== "space" && next !== "comment") break;
17459 firstSpaces.push(tokens.shift());
17460 }
17461 this.precheckMissedSemicolon(tokens);
17462 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
17463 token = tokens[i2];
17464 if (token[1].toLowerCase() === "!important") {
17465 node2.important = true;
17466 var string = this.stringFrom(tokens, i2);
17467 string = this.spacesFromEnd(tokens) + string;
17468 if (string !== " !important") node2.raws.important = string;
17469 break;
17470 } else if (token[1].toLowerCase() === "important") {
17471 var cache = tokens.slice(0);
17472 var str = "";
17473 for(var j = i2; j > 0; j--){
17474 var type1 = cache[j][0];
17475 if (str.trim().indexOf("!") === 0 && type1 !== "space") {
17476 break;
17477 }
17478 str = cache.pop()[1] + str;
17479 }
17480 if (str.trim().indexOf("!") === 0) {
17481 node2.important = true;
17482 node2.raws.important = str;
17483 tokens = cache;
17484 }
17485 }
17486 if (token[0] !== "space" && token[0] !== "comment") {
17487 break;
17488 }
17489 }
17490 var hasWord = tokens.some(function(i2) {
17491 return i2[0] !== "space" && i2[0] !== "comment";
17492 });
17493 if (hasWord) {
17494 node2.raws.between += firstSpaces.map(function(i2) {
17495 return i2[1];
17496 }).join("");
17497 firstSpaces = [];
17498 }
17499 this.raw(node2, "value", firstSpaces.concat(tokens), customProperty);
17500 if (node2.value.includes(":") && !customProperty) {
17501 this.checkMissedSemicolon(tokens);
17502 }
17503 };
17504 _proto.doubleColon = function doubleColon(token) {
17505 throw this.input.error("Double colon", {
17506 offset: token[2]
17507 }, {
17508 offset: token[2] + token[1].length
17509 });
17510 };
17511 _proto.emptyRule = function emptyRule(token) {
17512 var node2 = new Rule$2();
17513 this.init(node2, token[2]);
17514 node2.selector = "";
17515 node2.raws.between = "";
17516 this.current = node2;
17517 };
17518 _proto.end = function end(token) {
17519 if (this.current.nodes && this.current.nodes.length) {
17520 this.current.raws.semicolon = this.semicolon;
17521 }
17522 this.semicolon = false;
17523 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
17524 this.spaces = "";
17525 if (this.current.parent) {
17526 this.current.source.end = this.getPosition(token[2]);
17527 this.current.source.end.offset++;
17528 this.current = this.current.parent;
17529 } else {
17530 this.unexpectedClose(token);
17531 }
17532 };
17533 _proto.endFile = function endFile() {
17534 if (this.current.parent) this.unclosedBlock();
17535 if (this.current.nodes && this.current.nodes.length) {
17536 this.current.raws.semicolon = this.semicolon;
17537 }
17538 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
17539 this.root.source.end = this.getPosition(this.tokenizer.position());
17540 };
17541 _proto.freeSemicolon = function freeSemicolon(token) {
17542 this.spaces += token[1];
17543 if (this.current.nodes) {
17544 var prev = this.current.nodes[this.current.nodes.length - 1];
17545 if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
17546 prev.raws.ownSemicolon = this.spaces;
17547 this.spaces = "";
17548 }
17549 }
17550 };
17551 // Helpers
17552 _proto.getPosition = function getPosition(offset) {
17553 var pos = this.input.fromOffset(offset);
17554 return {
17555 column: pos.col,
17556 line: pos.line,
17557 offset: offset
17558 };
17559 };
17560 _proto.init = function init(node2, offset) {
17561 this.current.push(node2);
17562 node2.source = {
17563 input: this.input,
17564 start: this.getPosition(offset)
17565 };
17566 node2.raws.before = this.spaces;
17567 this.spaces = "";
17568 if (node2.type !== "comment") this.semicolon = false;
17569 };
17570 _proto.other = function other(start) {
17571 var end = false;
17572 var type = null;
17573 var colon = false;
17574 var bracket = null;
17575 var brackets = [];
17576 var customProperty = start[1].startsWith("--");
17577 var tokens = [];
17578 var token = start;
17579 while(token){
17580 type = token[0];
17581 tokens.push(token);
17582 if (type === "(" || type === "[") {
17583 if (!bracket) bracket = token;
17584 brackets.push(type === "(" ? ")" : "]");
17585 } else if (customProperty && colon && type === "{") {
17586 if (!bracket) bracket = token;
17587 brackets.push("}");
17588 } else if (brackets.length === 0) {
17589 if (type === ";") {
17590 if (colon) {
17591 this.decl(tokens, customProperty);
17592 return;
17593 } else {
17594 break;
17595 }
17596 } else if (type === "{") {
17597 this.rule(tokens);
17598 return;
17599 } else if (type === "}") {
17600 this.tokenizer.back(tokens.pop());
17601 end = true;
17602 break;
17603 } else if (type === ":") {
17604 colon = true;
17605 }
17606 } else if (type === brackets[brackets.length - 1]) {
17607 brackets.pop();
17608 if (brackets.length === 0) bracket = null;
17609 }
17610 token = this.tokenizer.nextToken();
17611 }
17612 if (this.tokenizer.endOfFile()) end = true;
17613 if (brackets.length > 0) this.unclosedBracket(bracket);
17614 if (end && colon) {
17615 if (!customProperty) {
17616 while(tokens.length){
17617 token = tokens[tokens.length - 1][0];
17618 if (token !== "space" && token !== "comment") break;
17619 this.tokenizer.back(tokens.pop());
17620 }
17621 }
17622 this.decl(tokens, customProperty);
17623 } else {
17624 this.unknownWord(tokens);
17625 }
17626 };
17627 _proto.parse = function parse() {
17628 var token;
17629 while(!this.tokenizer.endOfFile()){
17630 token = this.tokenizer.nextToken();
17631 switch(token[0]){
17632 case "space":
17633 this.spaces += token[1];
17634 break;
17635 case ";":
17636 this.freeSemicolon(token);
17637 break;
17638 case "}":
17639 this.end(token);
17640 break;
17641 case "comment":
17642 this.comment(token);
17643 break;
17644 case "at-word":
17645 this.atrule(token);
17646 break;
17647 case "{":
17648 this.emptyRule(token);
17649 break;
17650 default:
17651 this.other(token);
17652 break;
17653 }
17654 }
17655 this.endFile();
17656 };
17657 _proto.precheckMissedSemicolon = function precheckMissedSemicolon() {};
17658 _proto.raw = function raw(node2, prop, tokens, customProperty) {
17659 var token, type;
17660 var length = tokens.length;
17661 var value = "";
17662 var clean = true;
17663 var next, prev;
17664 for(var i2 = 0; i2 < length; i2 += 1){
17665 token = tokens[i2];
17666 type = token[0];
17667 if (type === "space" && i2 === length - 1 && !customProperty) {
17668 clean = false;
17669 } else if (type === "comment") {
17670 prev = tokens[i2 - 1] ? tokens[i2 - 1][0] : "empty";
17671 next = tokens[i2 + 1] ? tokens[i2 + 1][0] : "empty";
17672 if (!SAFE_COMMENT_NEIGHBOR[prev] && !SAFE_COMMENT_NEIGHBOR[next]) {
17673 if (value.slice(-1) === ",") {
17674 clean = false;
17675 } else {
17676 value += token[1];
17677 }
17678 } else {
17679 clean = false;
17680 }
17681 } else {
17682 value += token[1];
17683 }
17684 }
17685 if (!clean) {
17686 var raw = tokens.reduce(function(all, i2) {
17687 return all + i2[1];
17688 }, "");
17689 node2.raws[prop] = {
17690 raw: raw,
17691 value: value
17692 };
17693 }
17694 node2[prop] = value;
17695 };
17696 _proto.rule = function rule(tokens) {
17697 tokens.pop();
17698 var node2 = new Rule$2();
17699 this.init(node2, tokens[0][2]);
17700 node2.raws.between = this.spacesAndCommentsFromEnd(tokens);
17701 this.raw(node2, "selector", tokens);
17702 this.current = node2;
17703 };
17704 _proto.spacesAndCommentsFromEnd = function spacesAndCommentsFromEnd(tokens) {
17705 var lastTokenType;
17706 var spaces = "";
17707 while(tokens.length){
17708 lastTokenType = tokens[tokens.length - 1][0];
17709 if (lastTokenType !== "space" && lastTokenType !== "comment") break;
17710 spaces = tokens.pop()[1] + spaces;
17711 }
17712 return spaces;
17713 };
17714 // Errors
17715 _proto.spacesAndCommentsFromStart = function spacesAndCommentsFromStart(tokens) {
17716 var next;
17717 var spaces = "";
17718 while(tokens.length){
17719 next = tokens[0][0];
17720 if (next !== "space" && next !== "comment") break;
17721 spaces += tokens.shift()[1];
17722 }
17723 return spaces;
17724 };
17725 _proto.spacesFromEnd = function spacesFromEnd(tokens) {
17726 var lastTokenType;
17727 var spaces = "";
17728 while(tokens.length){
17729 lastTokenType = tokens[tokens.length - 1][0];
17730 if (lastTokenType !== "space") break;
17731 spaces = tokens.pop()[1] + spaces;
17732 }
17733 return spaces;
17734 };
17735 _proto.stringFrom = function stringFrom(tokens, from) {
17736 var result2 = "";
17737 for(var i2 = from; i2 < tokens.length; i2++){
17738 result2 += tokens[i2][1];
17739 }
17740 tokens.splice(from, tokens.length - from);
17741 return result2;
17742 };
17743 _proto.unclosedBlock = function unclosedBlock() {
17744 var pos = this.current.source.start;
17745 throw this.input.error("Unclosed block", pos.line, pos.column);
17746 };
17747 _proto.unclosedBracket = function unclosedBracket(bracket) {
17748 throw this.input.error("Unclosed bracket", {
17749 offset: bracket[2]
17750 }, {
17751 offset: bracket[2] + 1
17752 });
17753 };
17754 _proto.unexpectedClose = function unexpectedClose(token) {
17755 throw this.input.error("Unexpected }", {
17756 offset: token[2]
17757 }, {
17758 offset: token[2] + 1
17759 });
17760 };
17761 _proto.unknownWord = function unknownWord(tokens) {
17762 throw this.input.error("Unknown word", {
17763 offset: tokens[0][2]
17764 }, {
17765 offset: tokens[0][2] + tokens[0][1].length
17766 });
17767 };
17768 _proto.unnamedAtrule = function unnamedAtrule(node2, token) {
17769 throw this.input.error("At-rule without name", {
17770 offset: token[2]
17771 }, {
17772 offset: token[2] + token[1].length
17773 });
17774 };
17775 return Parser2;
17776 }();
17777 var parser = Parser$1;
17778 var Container$2 = container;
17779 var Parser22 = parser;
17780 var Input$2 = input;
17781 function parse$3(css, opts) {
17782 var input2 = new Input$2(css, opts);
17783 var parser2 = new Parser22(input2);
17784 try {
17785 parser2.parse();
17786 } catch (e2) {
17787 if (true) {
17788 if (e2.name === "CssSyntaxError" && opts && opts.from) {
17789 if (/\.scss$/i.test(opts.from)) {
17790 e2.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser";
17791 } else if (/\.sass/i.test(opts.from)) {
17792 e2.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser";
17793 } else if (/\.less$/i.test(opts.from)) {
17794 e2.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser";
17795 }
17796 }
17797 }
17798 throw e2;
17799 }
17800 return parser2.root;
17801 }
17802 var parse_1 = parse$3;
17803 parse$3.default = parse$3;
17804 Container$2.registerParse(parse$3);
17805 var isClean = symbols.isClean, my = symbols.my;
17806 var MapGenerator$1 = mapGenerator;
17807 var stringify$2 = stringify_1;
17808 var Container$1 = container;
17809 var Document$2 = document$1$2;
17810 var warnOnce$1 = warnOnce$2;
17811 var Result$2 = result;
17812 var parse$2 = parse_1;
17813 var Root$3 = root;
17814 var TYPE_TO_CLASS_NAME = {
17815 atrule: "AtRule",
17816 comment: "Comment",
17817 decl: "Declaration",
17818 document: "Document",
17819 root: "Root",
17820 rule: "Rule"
17821 };
17822 var PLUGIN_PROPS = {
17823 AtRule: true,
17824 AtRuleExit: true,
17825 Comment: true,
17826 CommentExit: true,
17827 Declaration: true,
17828 DeclarationExit: true,
17829 Document: true,
17830 DocumentExit: true,
17831 Once: true,
17832 OnceExit: true,
17833 postcssPlugin: true,
17834 prepare: true,
17835 Root: true,
17836 RootExit: true,
17837 Rule: true,
17838 RuleExit: true
17839 };
17840 var NOT_VISITORS = {
17841 Once: true,
17842 postcssPlugin: true,
17843 prepare: true
17844 };
17845 var CHILDREN = 0;
17846 function isPromise(obj) {
17847 return (typeof obj === "undefined" ? "undefined" : _type_of(obj)) === "object" && typeof obj.then === "function";
17848 }
17849 function getEvents(node2) {
17850 var key = false;
17851 var type = TYPE_TO_CLASS_NAME[node2.type];
17852 if (node2.type === "decl") {
17853 key = node2.prop.toLowerCase();
17854 } else if (node2.type === "atrule") {
17855 key = node2.name.toLowerCase();
17856 }
17857 if (key && node2.append) {
17858 return [
17859 type,
17860 type + "-" + key,
17861 CHILDREN,
17862 type + "Exit",
17863 type + "Exit-" + key
17864 ];
17865 } else if (key) {
17866 return [
17867 type,
17868 type + "-" + key,
17869 type + "Exit",
17870 type + "Exit-" + key
17871 ];
17872 } else if (node2.append) {
17873 return [
17874 type,
17875 CHILDREN,
17876 type + "Exit"
17877 ];
17878 } else {
17879 return [
17880 type,
17881 type + "Exit"
17882 ];
17883 }
17884 }
17885 function toStack(node2) {
17886 var events;
17887 if (node2.type === "document") {
17888 events = [
17889 "Document",
17890 CHILDREN,
17891 "DocumentExit"
17892 ];
17893 } else if (node2.type === "root") {
17894 events = [
17895 "Root",
17896 CHILDREN,
17897 "RootExit"
17898 ];
17899 } else {
17900 events = getEvents(node2);
17901 }
17902 return {
17903 eventIndex: 0,
17904 events: events,
17905 iterator: 0,
17906 node: node2,
17907 visitorIndex: 0,
17908 visitors: []
17909 };
17910 }
17911 function cleanMarks(node2) {
17912 node2[isClean] = false;
17913 if (node2.nodes) node2.nodes.forEach(function(i2) {
17914 return cleanMarks(i2);
17915 });
17916 return node2;
17917 }
17918 var postcss$2 = {};
17919 var LazyResult$2 = /*#__PURE__*/ function() {
17920 function LazyResult2(processor2, css, opts) {
17921 var _this = this;
17922 this.stringified = false;
17923 this.processed = false;
17924 var root2;
17925 if ((typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && css !== null && (css.type === "root" || css.type === "document")) {
17926 root2 = cleanMarks(css);
17927 } else if (_instanceof(css, LazyResult2) || _instanceof(css, Result$2)) {
17928 root2 = cleanMarks(css.root);
17929 if (css.map) {
17930 if (typeof opts.map === "undefined") opts.map = {};
17931 if (!opts.map.inline) opts.map.inline = false;
17932 opts.map.prev = css.map;
17933 }
17934 } else {
17935 var parser2 = parse$2;
17936 if (opts.syntax) parser2 = opts.syntax.parse;
17937 if (opts.parser) parser2 = opts.parser;
17938 if (parser2.parse) parser2 = parser2.parse;
17939 try {
17940 root2 = parser2(css, opts);
17941 } catch (error) {
17942 this.processed = true;
17943 this.error = error;
17944 }
17945 if (root2 && !root2[my]) {
17946 Container$1.rebuild(root2);
17947 }
17948 }
17949 this.result = new Result$2(processor2, root2, opts);
17950 this.helpers = _extends({}, postcss$2, {
17951 postcss: postcss$2,
17952 result: this.result
17953 });
17954 this.plugins = this.processor.plugins.map(function(plugin22) {
17955 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.prepare) {
17956 return _extends({}, plugin22, plugin22.prepare(_this.result));
17957 } else {
17958 return plugin22;
17959 }
17960 });
17961 }
17962 var _proto = LazyResult2.prototype;
17963 _proto.async = function async() {
17964 if (this.error) return Promise.reject(this.error);
17965 if (this.processed) return Promise.resolve(this.result);
17966 if (!this.processing) {
17967 this.processing = this.runAsync();
17968 }
17969 return this.processing;
17970 };
17971 _proto.catch = function _catch(onRejected) {
17972 return this.async().catch(onRejected);
17973 };
17974 _proto.finally = function _finally(onFinally) {
17975 return this.async().then(onFinally, onFinally);
17976 };
17977 _proto.getAsyncError = function getAsyncError() {
17978 throw new Error("Use process(css).then(cb) to work with async plugins");
17979 };
17980 _proto.handleError = function handleError(error, node2) {
17981 var plugin22 = this.result.lastPlugin;
17982 try {
17983 if (node2) node2.addToError(error);
17984 this.error = error;
17985 if (error.name === "CssSyntaxError" && !error.plugin) {
17986 error.plugin = plugin22.postcssPlugin;
17987 error.setMessage();
17988 } else if (plugin22.postcssVersion) {
17989 if (true) {
17990 var pluginName = plugin22.postcssPlugin;
17991 var pluginVer = plugin22.postcssVersion;
17992 var runtimeVer = this.result.processor.version;
17993 var a2 = pluginVer.split(".");
17994 var b = runtimeVer.split(".");
17995 if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) {
17996 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.");
17997 }
17998 }
17999 }
18000 } catch (err) {
18001 if (console && console.error) console.error(err);
18002 }
18003 return error;
18004 };
18005 _proto.prepareVisitors = function prepareVisitors() {
18006 var _this = this;
18007 this.listeners = {};
18008 var add = function(plugin22, type, cb) {
18009 if (!_this.listeners[type]) _this.listeners[type] = [];
18010 _this.listeners[type].push([
18011 plugin22,
18012 cb
18013 ]);
18014 };
18015 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
18016 var plugin22 = _step.value;
18017 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object") {
18018 for(var event in plugin22){
18019 if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) {
18020 throw new Error("Unknown event " + event + " in " + plugin22.postcssPlugin + ". Try to update PostCSS (" + this.processor.version + " now).");
18021 }
18022 if (!NOT_VISITORS[event]) {
18023 if (_type_of(plugin22[event]) === "object") {
18024 for(var filter in plugin22[event]){
18025 if (filter === "*") {
18026 add(plugin22, event, plugin22[event][filter]);
18027 } else {
18028 add(plugin22, event + "-" + filter.toLowerCase(), plugin22[event][filter]);
18029 }
18030 }
18031 } else if (typeof plugin22[event] === "function") {
18032 add(plugin22, event, plugin22[event]);
18033 }
18034 }
18035 }
18036 }
18037 }
18038 this.hasListener = Object.keys(this.listeners).length > 0;
18039 };
18040 _proto.runAsync = function runAsync() {
18041 var _this = this;
18042 return _async_to_generator(function() {
18043 var i2, plugin22, promise, error, root2, stack, promise1, e2, node2, _loop, _iterator, _step;
18044 return _ts_generator(this, function(_state) {
18045 switch(_state.label){
18046 case 0:
18047 _this.plugin = 0;
18048 i2 = 0;
18049 _state.label = 1;
18050 case 1:
18051 if (!(i2 < _this.plugins.length)) return [
18052 3,
18053 6
18054 ];
18055 plugin22 = _this.plugins[i2];
18056 promise = _this.runOnRoot(plugin22);
18057 if (!isPromise(promise)) return [
18058 3,
18059 5
18060 ];
18061 _state.label = 2;
18062 case 2:
18063 _state.trys.push([
18064 2,
18065 4,
18066 ,
18067 5
18068 ]);
18069 return [
18070 4,
18071 promise
18072 ];
18073 case 3:
18074 _state.sent();
18075 return [
18076 3,
18077 5
18078 ];
18079 case 4:
18080 error = _state.sent();
18081 throw _this.handleError(error);
18082 case 5:
18083 i2++;
18084 return [
18085 3,
18086 1
18087 ];
18088 case 6:
18089 _this.prepareVisitors();
18090 if (!_this.hasListener) return [
18091 3,
18092 18
18093 ];
18094 root2 = _this.result.root;
18095 _state.label = 7;
18096 case 7:
18097 if (!!root2[isClean]) return [
18098 3,
18099 14
18100 ];
18101 root2[isClean] = true;
18102 stack = [
18103 toStack(root2)
18104 ];
18105 _state.label = 8;
18106 case 8:
18107 if (!(stack.length > 0)) return [
18108 3,
18109 13
18110 ];
18111 promise1 = _this.visitTick(stack);
18112 if (!isPromise(promise1)) return [
18113 3,
18114 12
18115 ];
18116 _state.label = 9;
18117 case 9:
18118 _state.trys.push([
18119 9,
18120 11,
18121 ,
18122 12
18123 ]);
18124 return [
18125 4,
18126 promise1
18127 ];
18128 case 10:
18129 _state.sent();
18130 return [
18131 3,
18132 12
18133 ];
18134 case 11:
18135 e2 = _state.sent();
18136 node2 = stack[stack.length - 1].node;
18137 throw _this.handleError(e2, node2);
18138 case 12:
18139 return [
18140 3,
18141 8
18142 ];
18143 case 13:
18144 return [
18145 3,
18146 7
18147 ];
18148 case 14:
18149 if (!_this.listeners.OnceExit) return [
18150 3,
18151 18
18152 ];
18153 _loop = function() {
18154 var _step_value, plugin22, visitor, roots, e2;
18155 return _ts_generator(this, function(_state) {
18156 switch(_state.label){
18157 case 0:
18158 _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
18159 _this.result.lastPlugin = plugin22;
18160 _state.label = 1;
18161 case 1:
18162 _state.trys.push([
18163 1,
18164 6,
18165 ,
18166 7
18167 ]);
18168 if (!(root2.type === "document")) return [
18169 3,
18170 3
18171 ];
18172 roots = root2.nodes.map(function(subRoot) {
18173 return visitor(subRoot, _this.helpers);
18174 });
18175 return [
18176 4,
18177 Promise.all(roots)
18178 ];
18179 case 2:
18180 _state.sent();
18181 return [
18182 3,
18183 5
18184 ];
18185 case 3:
18186 return [
18187 4,
18188 visitor(root2, _this.helpers)
18189 ];
18190 case 4:
18191 _state.sent();
18192 _state.label = 5;
18193 case 5:
18194 return [
18195 3,
18196 7
18197 ];
18198 case 6:
18199 e2 = _state.sent();
18200 throw _this.handleError(e2);
18201 case 7:
18202 return [
18203 2
18204 ];
18205 }
18206 });
18207 };
18208 _iterator = _create_for_of_iterator_helper_loose(_this.listeners.OnceExit);
18209 _state.label = 15;
18210 case 15:
18211 if (!!(_step = _iterator()).done) return [
18212 3,
18213 18
18214 ];
18215 return [
18216 5,
18217 _ts_values(_loop())
18218 ];
18219 case 16:
18220 _state.sent();
18221 _state.label = 17;
18222 case 17:
18223 return [
18224 3,
18225 15
18226 ];
18227 case 18:
18228 _this.processed = true;
18229 return [
18230 2,
18231 _this.stringify()
18232 ];
18233 }
18234 });
18235 })();
18236 };
18237 _proto.runOnRoot = function runOnRoot(plugin22) {
18238 var _this = this;
18239 this.result.lastPlugin = plugin22;
18240 try {
18241 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.Once) {
18242 if (this.result.root.type === "document") {
18243 var roots = this.result.root.nodes.map(function(root2) {
18244 return plugin22.Once(root2, _this.helpers);
18245 });
18246 if (isPromise(roots[0])) {
18247 return Promise.all(roots);
18248 }
18249 return roots;
18250 }
18251 return plugin22.Once(this.result.root, this.helpers);
18252 } else if (typeof plugin22 === "function") {
18253 return plugin22(this.result.root, this.result);
18254 }
18255 } catch (error) {
18256 throw this.handleError(error);
18257 }
18258 };
18259 _proto.stringify = function stringify() {
18260 if (this.error) throw this.error;
18261 if (this.stringified) return this.result;
18262 this.stringified = true;
18263 this.sync();
18264 var opts = this.result.opts;
18265 var str = stringify$2;
18266 if (opts.syntax) str = opts.syntax.stringify;
18267 if (opts.stringifier) str = opts.stringifier;
18268 if (str.stringify) str = str.stringify;
18269 var map = new MapGenerator$1(str, this.result.root, this.result.opts);
18270 var data = map.generate();
18271 this.result.css = data[0];
18272 this.result.map = data[1];
18273 return this.result;
18274 };
18275 _proto.sync = function sync() {
18276 if (this.error) throw this.error;
18277 if (this.processed) return this.result;
18278 this.processed = true;
18279 if (this.processing) {
18280 throw this.getAsyncError();
18281 }
18282 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
18283 var plugin22 = _step.value;
18284 var promise = this.runOnRoot(plugin22);
18285 if (isPromise(promise)) {
18286 throw this.getAsyncError();
18287 }
18288 }
18289 this.prepareVisitors();
18290 if (this.hasListener) {
18291 var root2 = this.result.root;
18292 while(!root2[isClean]){
18293 root2[isClean] = true;
18294 this.walkSync(root2);
18295 }
18296 if (this.listeners.OnceExit) {
18297 if (root2.type === "document") {
18298 for(var _iterator1 = _create_for_of_iterator_helper_loose(root2.nodes), _step1; !(_step1 = _iterator1()).done;){
18299 var subRoot = _step1.value;
18300 this.visitSync(this.listeners.OnceExit, subRoot);
18301 }
18302 } else {
18303 this.visitSync(this.listeners.OnceExit, root2);
18304 }
18305 }
18306 }
18307 return this.result;
18308 };
18309 _proto.then = function then(onFulfilled, onRejected) {
18310 if (true) {
18311 if (!("from" in this.opts)) {
18312 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.");
18313 }
18314 }
18315 return this.async().then(onFulfilled, onRejected);
18316 };
18317 _proto.toString = function toString() {
18318 return this.css;
18319 };
18320 _proto.visitSync = function visitSync(visitors, node2) {
18321 for(var _iterator = _create_for_of_iterator_helper_loose(visitors), _step; !(_step = _iterator()).done;){
18322 var _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
18323 this.result.lastPlugin = plugin22;
18324 var promise = void 0;
18325 try {
18326 promise = visitor(node2, this.helpers);
18327 } catch (e2) {
18328 throw this.handleError(e2, node2.proxyOf);
18329 }
18330 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
18331 return true;
18332 }
18333 if (isPromise(promise)) {
18334 throw this.getAsyncError();
18335 }
18336 }
18337 };
18338 _proto.visitTick = function visitTick(stack) {
18339 var visit2 = stack[stack.length - 1];
18340 var node2 = visit2.node, visitors = visit2.visitors;
18341 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
18342 stack.pop();
18343 return;
18344 }
18345 if (visitors.length > 0 && visit2.visitorIndex < visitors.length) {
18346 var _visitors_visit2_visitorIndex = visitors[visit2.visitorIndex], plugin22 = _visitors_visit2_visitorIndex[0], visitor = _visitors_visit2_visitorIndex[1];
18347 visit2.visitorIndex += 1;
18348 if (visit2.visitorIndex === visitors.length) {
18349 visit2.visitors = [];
18350 visit2.visitorIndex = 0;
18351 }
18352 this.result.lastPlugin = plugin22;
18353 try {
18354 return visitor(node2.toProxy(), this.helpers);
18355 } catch (e2) {
18356 throw this.handleError(e2, node2);
18357 }
18358 }
18359 if (visit2.iterator !== 0) {
18360 var iterator = visit2.iterator;
18361 var child;
18362 while(child = node2.nodes[node2.indexes[iterator]]){
18363 node2.indexes[iterator] += 1;
18364 if (!child[isClean]) {
18365 child[isClean] = true;
18366 stack.push(toStack(child));
18367 return;
18368 }
18369 }
18370 visit2.iterator = 0;
18371 delete node2.indexes[iterator];
18372 }
18373 var events = visit2.events;
18374 while(visit2.eventIndex < events.length){
18375 var event = events[visit2.eventIndex];
18376 visit2.eventIndex += 1;
18377 if (event === CHILDREN) {
18378 if (node2.nodes && node2.nodes.length) {
18379 node2[isClean] = true;
18380 visit2.iterator = node2.getIterator();
18381 }
18382 return;
18383 } else if (this.listeners[event]) {
18384 visit2.visitors = this.listeners[event];
18385 return;
18386 }
18387 }
18388 stack.pop();
18389 };
18390 _proto.walkSync = function walkSync(node2) {
18391 var _this = this;
18392 node2[isClean] = true;
18393 var events = getEvents(node2);
18394 for(var _iterator = _create_for_of_iterator_helper_loose(events), _step; !(_step = _iterator()).done;){
18395 var event = _step.value;
18396 if (event === CHILDREN) {
18397 if (node2.nodes) {
18398 node2.each(function(child) {
18399 if (!child[isClean]) _this.walkSync(child);
18400 });
18401 }
18402 } else {
18403 var visitors = this.listeners[event];
18404 if (visitors) {
18405 if (this.visitSync(visitors, node2.toProxy())) return;
18406 }
18407 }
18408 }
18409 };
18410 _proto.warnings = function warnings() {
18411 return this.sync().warnings();
18412 };
18413 _create_class(LazyResult2, [
18414 {
18415 key: "content",
18416 get: function get() {
18417 return this.stringify().content;
18418 }
18419 },
18420 {
18421 key: "css",
18422 get: function get() {
18423 return this.stringify().css;
18424 }
18425 },
18426 {
18427 key: "map",
18428 get: function get() {
18429 return this.stringify().map;
18430 }
18431 },
18432 {
18433 key: "messages",
18434 get: function get() {
18435 return this.sync().messages;
18436 }
18437 },
18438 {
18439 key: "opts",
18440 get: function get() {
18441 return this.result.opts;
18442 }
18443 },
18444 {
18445 key: "processor",
18446 get: function get() {
18447 return this.result.processor;
18448 }
18449 },
18450 {
18451 key: "root",
18452 get: function get() {
18453 return this.sync().root;
18454 }
18455 },
18456 {
18457 key: Symbol.toStringTag,
18458 get: function get() {
18459 return "LazyResult";
18460 }
18461 }
18462 ]);
18463 return LazyResult2;
18464 }();
18465 LazyResult$2.registerPostcss = function(dependant) {
18466 postcss$2 = dependant;
18467 };
18468 var lazyResult = LazyResult$2;
18469 LazyResult$2.default = LazyResult$2;
18470 Root$3.registerLazyResult(LazyResult$2);
18471 Document$2.registerLazyResult(LazyResult$2);
18472 var MapGenerator22 = mapGenerator;
18473 var stringify$1 = stringify_1;
18474 var warnOnce22 = warnOnce$2;
18475 var parse$1 = parse_1;
18476 var Result$1 = result;
18477 var NoWorkResult$1 = /*#__PURE__*/ function() {
18478 function NoWorkResult2(processor2, css, opts) {
18479 css = css.toString();
18480 this.stringified = false;
18481 this._processor = processor2;
18482 this._css = css;
18483 this._opts = opts;
18484 this._map = void 0;
18485 var root2;
18486 var str = stringify$1;
18487 this.result = new Result$1(this._processor, root2, this._opts);
18488 this.result.css = css;
18489 var self = this;
18490 Object.defineProperty(this.result, "root", {
18491 get: function get() {
18492 return self.root;
18493 }
18494 });
18495 var map = new MapGenerator22(str, root2, this._opts, css);
18496 if (map.isMap()) {
18497 var _map_generate = map.generate(), generatedCSS = _map_generate[0], generatedMap = _map_generate[1];
18498 if (generatedCSS) {
18499 this.result.css = generatedCSS;
18500 }
18501 if (generatedMap) {
18502 this.result.map = generatedMap;
18503 }
18504 } else {
18505 map.clearAnnotation();
18506 this.result.css = map.css;
18507 }
18508 }
18509 var _proto = NoWorkResult2.prototype;
18510 _proto.async = function async() {
18511 if (this.error) return Promise.reject(this.error);
18512 return Promise.resolve(this.result);
18513 };
18514 _proto.catch = function _catch(onRejected) {
18515 return this.async().catch(onRejected);
18516 };
18517 _proto.finally = function _finally(onFinally) {
18518 return this.async().then(onFinally, onFinally);
18519 };
18520 _proto.sync = function sync() {
18521 if (this.error) throw this.error;
18522 return this.result;
18523 };
18524 _proto.then = function then(onFulfilled, onRejected) {
18525 if (true) {
18526 if (!("from" in this._opts)) {
18527 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.");
18528 }
18529 }
18530 return this.async().then(onFulfilled, onRejected);
18531 };
18532 _proto.toString = function toString() {
18533 return this._css;
18534 };
18535 _proto.warnings = function warnings() {
18536 return [];
18537 };
18538 _create_class(NoWorkResult2, [
18539 {
18540 key: "content",
18541 get: function get() {
18542 return this.result.css;
18543 }
18544 },
18545 {
18546 key: "css",
18547 get: function get() {
18548 return this.result.css;
18549 }
18550 },
18551 {
18552 key: "map",
18553 get: function get() {
18554 return this.result.map;
18555 }
18556 },
18557 {
18558 key: "messages",
18559 get: function get() {
18560 return [];
18561 }
18562 },
18563 {
18564 key: "opts",
18565 get: function get() {
18566 return this.result.opts;
18567 }
18568 },
18569 {
18570 key: "processor",
18571 get: function get() {
18572 return this.result.processor;
18573 }
18574 },
18575 {
18576 key: "root",
18577 get: function get() {
18578 if (this._root) {
18579 return this._root;
18580 }
18581 var root2;
18582 var parser2 = parse$1;
18583 try {
18584 root2 = parser2(this._css, this._opts);
18585 } catch (error) {
18586 this.error = error;
18587 }
18588 if (this.error) {
18589 throw this.error;
18590 } else {
18591 this._root = root2;
18592 return root2;
18593 }
18594 }
18595 },
18596 {
18597 key: Symbol.toStringTag,
18598 get: function get() {
18599 return "NoWorkResult";
18600 }
18601 }
18602 ]);
18603 return NoWorkResult2;
18604 }();
18605 var noWorkResult = NoWorkResult$1;
18606 NoWorkResult$1.default = NoWorkResult$1;
18607 var NoWorkResult22 = noWorkResult;
18608 var LazyResult$1 = lazyResult;
18609 var Document$1 = document$1$2;
18610 var Root$2 = root;
18611 var Processor$1 = /*#__PURE__*/ function() {
18612 function Processor2(plugins) {
18613 if (plugins === void 0) plugins = [];
18614 this.version = "8.4.38";
18615 this.plugins = this.normalize(plugins);
18616 }
18617 var _proto = Processor2.prototype;
18618 _proto.normalize = function normalize(plugins) {
18619 var normalized = [];
18620 for(var _iterator = _create_for_of_iterator_helper_loose(plugins), _step; !(_step = _iterator()).done;){
18621 var i2 = _step.value;
18622 if (i2.postcss === true) {
18623 i2 = i2();
18624 } else if (i2.postcss) {
18625 i2 = i2.postcss;
18626 }
18627 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && Array.isArray(i2.plugins)) {
18628 normalized = normalized.concat(i2.plugins);
18629 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.postcssPlugin) {
18630 normalized.push(i2);
18631 } else if (typeof i2 === "function") {
18632 normalized.push(i2);
18633 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && (i2.parse || i2.stringify)) {
18634 if (true) {
18635 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.");
18636 }
18637 } else {
18638 throw new Error(i2 + " is not a PostCSS plugin");
18639 }
18640 }
18641 return normalized;
18642 };
18643 _proto.process = function process1(css, opts) {
18644 if (opts === void 0) opts = {};
18645 if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) {
18646 return new NoWorkResult22(this, css, opts);
18647 } else {
18648 return new LazyResult$1(this, css, opts);
18649 }
18650 };
18651 _proto.use = function use(plugin22) {
18652 this.plugins = this.plugins.concat(this.normalize([
18653 plugin22
18654 ]));
18655 return this;
18656 };
18657 return Processor2;
18658 }();
18659 var processor = Processor$1;
18660 Processor$1.default = Processor$1;
18661 Root$2.registerProcessor(Processor$1);
18662 Document$1.registerProcessor(Processor$1);
18663 var Declaration$1 = declaration;
18664 var PreviousMap22 = previousMap;
18665 var Comment$1 = comment;
18666 var AtRule$1 = atRule;
18667 var Input$1 = input;
18668 var Root$1 = root;
18669 var Rule$1 = rule;
18670 function fromJSON$1(json, inputs) {
18671 if (Array.isArray(json)) return json.map(function(n2) {
18672 return fromJSON$1(n2);
18673 });
18674 var ownInputs = json.inputs, defaults = _object_without_properties_loose(json, [
18675 "inputs"
18676 ]);
18677 if (ownInputs) {
18678 inputs = [];
18679 for(var _iterator = _create_for_of_iterator_helper_loose(ownInputs), _step; !(_step = _iterator()).done;){
18680 var input2 = _step.value;
18681 var inputHydrated = _extends({}, input2, {
18682 __proto__: Input$1.prototype
18683 });
18684 if (inputHydrated.map) {
18685 inputHydrated.map = _extends({}, inputHydrated.map, {
18686 __proto__: PreviousMap22.prototype
18687 });
18688 }
18689 inputs.push(inputHydrated);
18690 }
18691 }
18692 if (defaults.nodes) {
18693 defaults.nodes = json.nodes.map(function(n2) {
18694 return fromJSON$1(n2, inputs);
18695 });
18696 }
18697 if (defaults.source) {
18698 var _defaults_source = defaults.source, inputId = _defaults_source.inputId, source = _object_without_properties_loose(_defaults_source, [
18699 "inputId"
18700 ]);
18701 defaults.source = source;
18702 if (inputId != null) {
18703 defaults.source.input = inputs[inputId];
18704 }
18705 }
18706 if (defaults.type === "root") {
18707 return new Root$1(defaults);
18708 } else if (defaults.type === "decl") {
18709 return new Declaration$1(defaults);
18710 } else if (defaults.type === "rule") {
18711 return new Rule$1(defaults);
18712 } else if (defaults.type === "comment") {
18713 return new Comment$1(defaults);
18714 } else if (defaults.type === "atrule") {
18715 return new AtRule$1(defaults);
18716 } else {
18717 throw new Error("Unknown node type: " + json.type);
18718 }
18719 }
18720 var fromJSON_1 = fromJSON$1;
18721 fromJSON$1.default = fromJSON$1;
18722 var CssSyntaxError22 = cssSyntaxError;
18723 var Declaration22 = declaration;
18724 var LazyResult22 = lazyResult;
18725 var Container22 = container;
18726 var Processor22 = processor;
18727 var stringify = stringify_1;
18728 var fromJSON = fromJSON_1;
18729 var Document222 = document$1$2;
18730 var Warning22 = warning;
18731 var Comment22 = comment;
18732 var AtRule22 = atRule;
18733 var Result22 = result;
18734 var Input22 = input;
18735 var parse = parse_1;
18736 var list = list_1;
18737 var Rule22 = rule;
18738 var Root22 = root;
18739 var Node22 = node;
18740 function postcss() {
18741 for(var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++){
18742 plugins[_key] = arguments[_key];
18743 }
18744 if (plugins.length === 1 && Array.isArray(plugins[0])) {
18745 plugins = plugins[0];
18746 }
18747 return new Processor22(plugins);
18748 }
18749 postcss.plugin = function plugin2(name, initializer) {
18750 var warningPrinted = false;
18751 function creator() {
18752 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
18753 args[_key] = arguments[_key];
18754 }
18755 if (console && console.warn && !warningPrinted) {
18756 warningPrinted = true;
18757 console.warn(name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration");
18758 if (process.env.LANG && process.env.LANG.startsWith("cn")) {
18759 console.warn(name + ": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226");
18760 }
18761 }
18762 var transformer = initializer.apply(void 0, [].concat(args));
18763 transformer.postcssPlugin = name;
18764 transformer.postcssVersion = new Processor22().version;
18765 return transformer;
18766 }
18767 var cache;
18768 Object.defineProperty(creator, "postcss", {
18769 get: function get() {
18770 if (!cache) cache = creator();
18771 return cache;
18772 }
18773 });
18774 creator.process = function(css, processOpts, pluginOpts) {
18775 return postcss([
18776 creator(pluginOpts)
18777 ]).process(css, processOpts);
18778 };
18779 return creator;
18780 };
18781 postcss.stringify = stringify;
18782 postcss.parse = parse;
18783 postcss.fromJSON = fromJSON;
18784 postcss.list = list;
18785 postcss.comment = function(defaults) {
18786 return new Comment22(defaults);
18787 };
18788 postcss.atRule = function(defaults) {
18789 return new AtRule22(defaults);
18790 };
18791 postcss.decl = function(defaults) {
18792 return new Declaration22(defaults);
18793 };
18794 postcss.rule = function(defaults) {
18795 return new Rule22(defaults);
18796 };
18797 postcss.root = function(defaults) {
18798 return new Root22(defaults);
18799 };
18800 postcss.document = function(defaults) {
18801 return new Document222(defaults);
18802 };
18803 postcss.CssSyntaxError = CssSyntaxError22;
18804 postcss.Declaration = Declaration22;
18805 postcss.Container = Container22;
18806 postcss.Processor = Processor22;
18807 postcss.Document = Document222;
18808 postcss.Comment = Comment22;
18809 postcss.Warning = Warning22;
18810 postcss.AtRule = AtRule22;
18811 postcss.Result = Result22;
18812 postcss.Input = Input22;
18813 postcss.Rule = Rule22;
18814 postcss.Root = Root22;
18815 postcss.Node = Node22;
18816 LazyResult22.registerPostcss(postcss);
18817 var postcss_1 = postcss;
18818 postcss.default = postcss;
18819 var postcss$1 = /* @__PURE__ */ getDefaultExportFromCjs(postcss_1);
18820 postcss$1.stringify;
18821 postcss$1.fromJSON;
18822 postcss$1.plugin;
18823 postcss$1.parse;
18824 postcss$1.list;
18825 postcss$1.document;
18826 postcss$1.comment;
18827 postcss$1.atRule;
18828 postcss$1.rule;
18829 postcss$1.decl;
18830 postcss$1.root;
18831 postcss$1.CssSyntaxError;
18832 postcss$1.Declaration;
18833 postcss$1.Container;
18834 postcss$1.Processor;
18835 postcss$1.Document;
18836 postcss$1.Comment;
18837 postcss$1.Warning;
18838 postcss$1.AtRule;
18839 postcss$1.Result;
18840 postcss$1.Input;
18841 postcss$1.Rule;
18842 postcss$1.Root;
18843 postcss$1.Node;
18844 var BaseRRNode = /*#__PURE__*/ function() {
18845 function BaseRRNode() {
18846 for(var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++){
18847 _args[_key] = arguments[_key];
18848 }
18849 __publicField2(this, "parentElement", null);
18850 __publicField2(this, "parentNode", null);
18851 __publicField2(this, "ownerDocument");
18852 __publicField2(this, "firstChild", null);
18853 __publicField2(this, "lastChild", null);
18854 __publicField2(this, "previousSibling", null);
18855 __publicField2(this, "nextSibling", null);
18856 __publicField2(this, "ELEMENT_NODE", 1);
18857 __publicField2(this, "TEXT_NODE", 3);
18858 __publicField2(this, "nodeType");
18859 __publicField2(this, "nodeName");
18860 __publicField2(this, "RRNodeType");
18861 }
18862 var _proto = BaseRRNode.prototype;
18863 _proto.contains = function contains(node2) {
18864 if (!_instanceof(node2, BaseRRNode)) return false;
18865 else if (node2.ownerDocument !== this.ownerDocument) return false;
18866 else if (node2 === this) return true;
18867 while(node2.parentNode){
18868 if (node2.parentNode === this) return true;
18869 node2 = node2.parentNode;
18870 }
18871 return false;
18872 };
18873 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18874 _proto.appendChild = function appendChild(_newChild) {
18875 throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.");
18876 };
18877 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18878 _proto.insertBefore = function insertBefore(_newChild, _refChild) {
18879 throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.");
18880 };
18881 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18882 _proto.removeChild = function removeChild(_node) {
18883 throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.");
18884 };
18885 _proto.toString = function toString() {
18886 return "RRNode";
18887 };
18888 _create_class(BaseRRNode, [
18889 {
18890 key: "childNodes",
18891 get: function get() {
18892 var childNodes2 = [];
18893 var childIterator = this.firstChild;
18894 while(childIterator){
18895 childNodes2.push(childIterator);
18896 childIterator = childIterator.nextSibling;
18897 }
18898 return childNodes2;
18899 }
18900 }
18901 ]);
18902 return BaseRRNode;
18903 }();
18904 var testableAccessors = {
18905 Node: [
18906 "childNodes",
18907 "parentNode",
18908 "parentElement",
18909 "textContent"
18910 ],
18911 ShadowRoot: [
18912 "host",
18913 "styleSheets"
18914 ],
18915 Element: [
18916 "shadowRoot",
18917 "querySelector",
18918 "querySelectorAll"
18919 ],
18920 MutationObserver: []
18921 };
18922 var testableMethods = {
18923 Node: [
18924 "contains",
18925 "getRootNode"
18926 ],
18927 ShadowRoot: [
18928 "getSelection"
18929 ],
18930 Element: [],
18931 MutationObserver: [
18932 "constructor"
18933 ]
18934 };
18935 var untaintedBasePrototype = {};
18936 var isAngularZonePresent = function() {
18937 return !!globalThis.Zone;
18938 };
18939 function getUntaintedPrototype(key) {
18940 if (untaintedBasePrototype[key]) return untaintedBasePrototype[key];
18941 var defaultObj = globalThis[key];
18942 var defaultPrototype = defaultObj.prototype;
18943 var accessorNames = key in testableAccessors ? testableAccessors[key] : void 0;
18944 var isUntaintedAccessors = Boolean(accessorNames && // @ts-expect-error 2345
18945 accessorNames.every(function(accessor) {
18946 var _a2, _b;
18947 return Boolean((_b = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b.toString().includes("[native code]"));
18948 }));
18949 var methodNames = key in testableMethods ? testableMethods[key] : void 0;
18950 var isUntaintedMethods = Boolean(methodNames && methodNames.every(// @ts-expect-error 2345
18951 function(method) {
18952 var _a2;
18953 return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
18954 }));
18955 if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent()) {
18956 untaintedBasePrototype[key] = defaultObj.prototype;
18957 return defaultObj.prototype;
18958 }
18959 try {
18960 var iframeEl = document.createElement("iframe");
18961 document.body.appendChild(iframeEl);
18962 var win = iframeEl.contentWindow;
18963 if (!win) return defaultObj.prototype;
18964 var untaintedObject = win[key].prototype;
18965 document.body.removeChild(iframeEl);
18966 if (!untaintedObject) return defaultPrototype;
18967 return untaintedBasePrototype[key] = untaintedObject;
18968 } catch (e) {
18969 return defaultPrototype;
18970 }
18971 }
18972 var untaintedAccessorCache = {};
18973 function getUntaintedAccessor(key, instance, accessor) {
18974 var _a2;
18975 var cacheKey = key + "." + String(accessor);
18976 if (untaintedAccessorCache[cacheKey]) return untaintedAccessorCache[cacheKey].call(instance);
18977 var untaintedPrototype = getUntaintedPrototype(key);
18978 var untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(untaintedPrototype, accessor)) == null ? void 0 : _a2.get;
18979 if (!untaintedAccessor) return instance[accessor];
18980 untaintedAccessorCache[cacheKey] = untaintedAccessor;
18981 return untaintedAccessor.call(instance);
18982 }
18983 var untaintedMethodCache = {};
18984 function getUntaintedMethod(key, instance, method) {
18985 var cacheKey = key + "." + String(method);
18986 if (untaintedMethodCache[cacheKey]) return untaintedMethodCache[cacheKey].bind(instance);
18987 var untaintedPrototype = getUntaintedPrototype(key);
18988 var untaintedMethod = untaintedPrototype[method];
18989 if (typeof untaintedMethod !== "function") return instance[method];
18990 untaintedMethodCache[cacheKey] = untaintedMethod;
18991 return untaintedMethod.bind(instance);
18992 }
18993 function childNodes(n2) {
18994 return getUntaintedAccessor("Node", n2, "childNodes");
18995 }
18996 function parentNode(n2) {
18997 return getUntaintedAccessor("Node", n2, "parentNode");
18998 }
18999 function parentElement(n2) {
19000 return getUntaintedAccessor("Node", n2, "parentElement");
19001 }
19002 function textContent(n2) {
19003 return getUntaintedAccessor("Node", n2, "textContent");
19004 }
19005 function contains(n2, other) {
19006 return getUntaintedMethod("Node", n2, "contains")(other);
19007 }
19008 function getRootNode(n2) {
19009 return getUntaintedMethod("Node", n2, "getRootNode")();
19010 }
19011 function host(n2) {
19012 if (!n2 || !("host" in n2)) return null;
19013 return getUntaintedAccessor("ShadowRoot", n2, "host");
19014 }
19015 function styleSheets(n2) {
19016 return n2.styleSheets;
19017 }
19018 function shadowRoot(n2) {
19019 if (!n2 || !("shadowRoot" in n2)) return null;
19020 return getUntaintedAccessor("Element", n2, "shadowRoot");
19021 }
19022 function querySelector(n2, selectors) {
19023 return getUntaintedAccessor("Element", n2, "querySelector")(selectors);
19024 }
19025 function querySelectorAll(n2, selectors) {
19026 return getUntaintedAccessor("Element", n2, "querySelectorAll")(selectors);
19027 }
19028 function mutationObserverCtor() {
19029 return getUntaintedPrototype("MutationObserver").constructor;
19030 }
19031 function patch(source, name, replacement) {
19032 try {
19033 if (!(name in source)) {
19034 return function() {};
19035 }
19036 var original = source[name];
19037 var wrapped = replacement(original);
19038 if (typeof wrapped === "function") {
19039 wrapped.prototype = wrapped.prototype || {};
19040 Object.defineProperties(wrapped, {
19041 __rrweb_original__: {
19042 enumerable: false,
19043 value: original
19044 }
19045 });
19046 }
19047 source[name] = wrapped;
19048 return function() {
19049 source[name] = original;
19050 };
19051 } catch (e) {
19052 return function() {};
19053 }
19054 }
19055 var index = {
19056 childNodes: childNodes,
19057 parentNode: parentNode,
19058 parentElement: parentElement,
19059 textContent: textContent,
19060 contains: contains,
19061 getRootNode: getRootNode,
19062 host: host,
19063 styleSheets: styleSheets,
19064 shadowRoot: shadowRoot,
19065 querySelector: querySelector,
19066 querySelectorAll: querySelectorAll,
19067 mutationObserver: mutationObserverCtor,
19068 patch: patch
19069 };
19070 function on(type, fn, target) {
19071 if (target === void 0) target = document;
19072 var options = {
19073 capture: true,
19074 passive: true
19075 };
19076 target.addEventListener(type, fn, options);
19077 return function() {
19078 return target.removeEventListener(type, fn, options);
19079 };
19080 }
19081 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.";
19082 var _mirror = {
19083 map: {},
19084 getId: function getId() {
19085 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
19086 return -1;
19087 },
19088 getNode: function getNode() {
19089 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
19090 return null;
19091 },
19092 removeNodeFromMap: function removeNodeFromMap() {
19093 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
19094 },
19095 has: function has() {
19096 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
19097 return false;
19098 },
19099 reset: function reset() {
19100 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
19101 }
19102 };
19103 if (typeof window !== "undefined" && window.Proxy && window.Reflect) {
19104 _mirror = new Proxy(_mirror, {
19105 get: function get(target, prop, receiver) {
19106 if (prop === "map") {
19107 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
19108 }
19109 return Reflect.get(target, prop, receiver);
19110 }
19111 });
19112 }
19113 function throttle(func, wait, options) {
19114 if (options === void 0) options = {};
19115 var timeout = null;
19116 var previous = 0;
19117 return function() {
19118 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
19119 args[_key] = arguments[_key];
19120 }
19121 var now = Date.now();
19122 if (!previous && options.leading === false) {
19123 previous = now;
19124 }
19125 var remaining = wait - (now - previous);
19126 var context = this;
19127 if (remaining <= 0 || remaining > wait) {
19128 if (timeout) {
19129 clearTimeout(timeout);
19130 timeout = null;
19131 }
19132 previous = now;
19133 func.apply(context, args);
19134 } else if (!timeout && options.trailing !== false) {
19135 timeout = setTimeout(function() {
19136 previous = options.leading === false ? 0 : Date.now();
19137 timeout = null;
19138 func.apply(context, args);
19139 }, remaining);
19140 }
19141 };
19142 }
19143 function hookSetter(target, key, d, isRevoked, win) {
19144 if (win === void 0) win = window;
19145 var original = win.Object.getOwnPropertyDescriptor(target, key);
19146 win.Object.defineProperty(target, key, isRevoked ? d : {
19147 set: function set(value) {
19148 var _this = this;
19149 setTimeout(function() {
19150 d.set.call(_this, value);
19151 }, 0);
19152 if (original && original.set) {
19153 original.set.call(this, value);
19154 }
19155 }
19156 });
19157 return function() {
19158 return hookSetter(target, key, original || {}, true);
19159 };
19160 }
19161 var nowTimestamp = Date.now;
19162 if (!/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())) {
19163 nowTimestamp = function() {
19164 return /* @__PURE__ */ new Date().getTime();
19165 };
19166 }
19167 function getWindowScroll(win) {
19168 var _a2, _b, _c, _d;
19169 var doc = win.document;
19170 return {
19171 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,
19172 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
19173 };
19174 }
19175 function getWindowHeight() {
19176 return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body && document.body.clientHeight;
19177 }
19178 function getWindowWidth() {
19179 return window.innerWidth || document.documentElement && document.documentElement.clientWidth || document.body && document.body.clientWidth;
19180 }
19181 function closestElementOfNode(node2) {
19182 if (!node2) {
19183 return null;
19184 }
19185 var el = node2.nodeType === node2.ELEMENT_NODE ? node2 : index.parentElement(node2);
19186 return el;
19187 }
19188 function isBlocked(node2, blockClass, blockSelector, checkAncestors) {
19189 if (!node2) {
19190 return false;
19191 }
19192 var el = closestElementOfNode(node2);
19193 if (!el) {
19194 return false;
19195 }
19196 try {
19197 if (typeof blockClass === "string") {
19198 if (el.classList.contains(blockClass)) return true;
19199 if (checkAncestors && el.closest("." + blockClass) !== null) return true;
19200 } else {
19201 if (classMatchesRegex(el, blockClass, checkAncestors)) return true;
19202 }
19203 } catch (e2) {}
19204 if (blockSelector) {
19205 if (el.matches(blockSelector)) return true;
19206 if (checkAncestors && el.closest(blockSelector) !== null) return true;
19207 }
19208 return false;
19209 }
19210 function isSerialized(n2, mirror2) {
19211 return mirror2.getId(n2) !== -1;
19212 }
19213 function isIgnored(n2, mirror2, slimDOMOptions) {
19214 if (n2.tagName === "TITLE" && slimDOMOptions.headTitleMutations) {
19215 return true;
19216 }
19217 return mirror2.getId(n2) === IGNORED_NODE;
19218 }
19219 function isAncestorRemoved(target, mirror2) {
19220 if (isShadowRoot(target)) {
19221 return false;
19222 }
19223 var id = mirror2.getId(target);
19224 if (!mirror2.has(id)) {
19225 return true;
19226 }
19227 var parent = index.parentNode(target);
19228 if (parent && parent.nodeType === target.DOCUMENT_NODE) {
19229 return false;
19230 }
19231 if (!parent) {
19232 return true;
19233 }
19234 return isAncestorRemoved(parent, mirror2);
19235 }
19236 function legacy_isTouchEvent(event) {
19237 return Boolean(event.changedTouches);
19238 }
19239 function polyfill$1(win) {
19240 if (win === void 0) win = window;
19241 if ("NodeList" in win && !win.NodeList.prototype.forEach) {
19242 win.NodeList.prototype.forEach = Array.prototype.forEach;
19243 }
19244 if ("DOMTokenList" in win && !win.DOMTokenList.prototype.forEach) {
19245 win.DOMTokenList.prototype.forEach = Array.prototype.forEach;
19246 }
19247 }
19248 function isSerializedIframe(n2, mirror2) {
19249 return Boolean(n2.nodeName === "IFRAME" && mirror2.getMeta(n2));
19250 }
19251 function isSerializedStylesheet(n2, mirror2) {
19252 return Boolean(n2.nodeName === "LINK" && n2.nodeType === n2.ELEMENT_NODE && n2.getAttribute && n2.getAttribute("rel") === "stylesheet" && mirror2.getMeta(n2));
19253 }
19254 function hasShadowRoot(n2) {
19255 if (!n2) return false;
19256 if (_instanceof(n2, BaseRRNode) && "shadowRoot" in n2) {
19257 return Boolean(n2.shadowRoot);
19258 }
19259 return Boolean(index.shadowRoot(n2));
19260 }
19261 var StyleSheetMirror = /*#__PURE__*/ function() {
19262 function StyleSheetMirror() {
19263 __publicField(this, "id", 1);
19264 __publicField(this, "styleIDMap", /* @__PURE__ */ new WeakMap());
19265 __publicField(this, "idStyleMap", /* @__PURE__ */ new Map());
19266 }
19267 var _proto = StyleSheetMirror.prototype;
19268 _proto.getId = function getId(stylesheet) {
19269 var _this_styleIDMap_get;
19270 return (_this_styleIDMap_get = this.styleIDMap.get(stylesheet)) != null ? _this_styleIDMap_get : -1;
19271 };
19272 _proto.has = function has(stylesheet) {
19273 return this.styleIDMap.has(stylesheet);
19274 };
19275 /**
19276 * @returns If the stylesheet is in the mirror, returns the id of the stylesheet. If not, return the new assigned id.
19277 */ _proto.add = function add(stylesheet, id) {
19278 if (this.has(stylesheet)) return this.getId(stylesheet);
19279 var newId;
19280 if (id === void 0) {
19281 newId = this.id++;
19282 } else newId = id;
19283 this.styleIDMap.set(stylesheet, newId);
19284 this.idStyleMap.set(newId, stylesheet);
19285 return newId;
19286 };
19287 _proto.getStyle = function getStyle(id) {
19288 return this.idStyleMap.get(id) || null;
19289 };
19290 _proto.reset = function reset() {
19291 this.styleIDMap = /* @__PURE__ */ new WeakMap();
19292 this.idStyleMap = /* @__PURE__ */ new Map();
19293 this.id = 1;
19294 };
19295 _proto.generateId = function generateId() {
19296 return this.id++;
19297 };
19298 return StyleSheetMirror;
19299 }();
19300 function getShadowHost(n2) {
19301 var _a2;
19302 var shadowHost = null;
19303 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));
19304 return shadowHost;
19305 }
19306 function getRootShadowHost(n2) {
19307 var rootShadowHost = n2;
19308 var shadowHost;
19309 while(shadowHost = getShadowHost(rootShadowHost))rootShadowHost = shadowHost;
19310 return rootShadowHost;
19311 }
19312 function shadowHostInDom(n2) {
19313 var doc = n2.ownerDocument;
19314 if (!doc) return false;
19315 var shadowHost = getRootShadowHost(n2);
19316 return index.contains(doc, shadowHost);
19317 }
19318 function inDom(n2) {
19319 var doc = n2.ownerDocument;
19320 if (!doc) return false;
19321 return index.contains(doc, n2) || shadowHostInDom(n2);
19322 }
19323 var EventType = /* @__PURE__ */ function(EventType2) {
19324 EventType2[EventType2["DomContentLoaded"] = 0] = "DomContentLoaded";
19325 EventType2[EventType2["Load"] = 1] = "Load";
19326 EventType2[EventType2["FullSnapshot"] = 2] = "FullSnapshot";
19327 EventType2[EventType2["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
19328 EventType2[EventType2["Meta"] = 4] = "Meta";
19329 EventType2[EventType2["Custom"] = 5] = "Custom";
19330 EventType2[EventType2["Plugin"] = 6] = "Plugin";
19331 return EventType2;
19332 }(EventType || {});
19333 var IncrementalSource = /* @__PURE__ */ function(IncrementalSource2) {
19334 IncrementalSource2[IncrementalSource2["Mutation"] = 0] = "Mutation";
19335 IncrementalSource2[IncrementalSource2["MouseMove"] = 1] = "MouseMove";
19336 IncrementalSource2[IncrementalSource2["MouseInteraction"] = 2] = "MouseInteraction";
19337 IncrementalSource2[IncrementalSource2["Scroll"] = 3] = "Scroll";
19338 IncrementalSource2[IncrementalSource2["ViewportResize"] = 4] = "ViewportResize";
19339 IncrementalSource2[IncrementalSource2["Input"] = 5] = "Input";
19340 IncrementalSource2[IncrementalSource2["TouchMove"] = 6] = "TouchMove";
19341 IncrementalSource2[IncrementalSource2["MediaInteraction"] = 7] = "MediaInteraction";
19342 IncrementalSource2[IncrementalSource2["StyleSheetRule"] = 8] = "StyleSheetRule";
19343 IncrementalSource2[IncrementalSource2["CanvasMutation"] = 9] = "CanvasMutation";
19344 IncrementalSource2[IncrementalSource2["Font"] = 10] = "Font";
19345 IncrementalSource2[IncrementalSource2["Log"] = 11] = "Log";
19346 IncrementalSource2[IncrementalSource2["Drag"] = 12] = "Drag";
19347 IncrementalSource2[IncrementalSource2["StyleDeclaration"] = 13] = "StyleDeclaration";
19348 IncrementalSource2[IncrementalSource2["Selection"] = 14] = "Selection";
19349 IncrementalSource2[IncrementalSource2["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
19350 IncrementalSource2[IncrementalSource2["CustomElement"] = 16] = "CustomElement";
19351 return IncrementalSource2;
19352 }(IncrementalSource || {});
19353 var MouseInteractions = /* @__PURE__ */ function(MouseInteractions2) {
19354 MouseInteractions2[MouseInteractions2["MouseUp"] = 0] = "MouseUp";
19355 MouseInteractions2[MouseInteractions2["MouseDown"] = 1] = "MouseDown";
19356 MouseInteractions2[MouseInteractions2["Click"] = 2] = "Click";
19357 MouseInteractions2[MouseInteractions2["ContextMenu"] = 3] = "ContextMenu";
19358 MouseInteractions2[MouseInteractions2["DblClick"] = 4] = "DblClick";
19359 MouseInteractions2[MouseInteractions2["Focus"] = 5] = "Focus";
19360 MouseInteractions2[MouseInteractions2["Blur"] = 6] = "Blur";
19361 MouseInteractions2[MouseInteractions2["TouchStart"] = 7] = "TouchStart";
19362 MouseInteractions2[MouseInteractions2["TouchMove_Departed"] = 8] = "TouchMove_Departed";
19363 MouseInteractions2[MouseInteractions2["TouchEnd"] = 9] = "TouchEnd";
19364 MouseInteractions2[MouseInteractions2["TouchCancel"] = 10] = "TouchCancel";
19365 return MouseInteractions2;
19366 }(MouseInteractions || {});
19367 var PointerTypes = /* @__PURE__ */ function(PointerTypes2) {
19368 PointerTypes2[PointerTypes2["Mouse"] = 0] = "Mouse";
19369 PointerTypes2[PointerTypes2["Pen"] = 1] = "Pen";
19370 PointerTypes2[PointerTypes2["Touch"] = 2] = "Touch";
19371 return PointerTypes2;
19372 }(PointerTypes || {});
19373 var CanvasContext = /* @__PURE__ */ function(CanvasContext2) {
19374 CanvasContext2[CanvasContext2["2D"] = 0] = "2D";
19375 CanvasContext2[CanvasContext2["WebGL"] = 1] = "WebGL";
19376 CanvasContext2[CanvasContext2["WebGL2"] = 2] = "WebGL2";
19377 return CanvasContext2;
19378 }(CanvasContext || {});
19379 var MediaInteractions = /* @__PURE__ */ function(MediaInteractions2) {
19380 MediaInteractions2[MediaInteractions2["Play"] = 0] = "Play";
19381 MediaInteractions2[MediaInteractions2["Pause"] = 1] = "Pause";
19382 MediaInteractions2[MediaInteractions2["Seeked"] = 2] = "Seeked";
19383 MediaInteractions2[MediaInteractions2["VolumeChange"] = 3] = "VolumeChange";
19384 MediaInteractions2[MediaInteractions2["RateChange"] = 4] = "RateChange";
19385 return MediaInteractions2;
19386 }(MediaInteractions || {});
19387 var NodeType = /* @__PURE__ */ function(NodeType2) {
19388 NodeType2[NodeType2["Document"] = 0] = "Document";
19389 NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
19390 NodeType2[NodeType2["Element"] = 2] = "Element";
19391 NodeType2[NodeType2["Text"] = 3] = "Text";
19392 NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
19393 NodeType2[NodeType2["Comment"] = 5] = "Comment";
19394 return NodeType2;
19395 }(NodeType || {});
19396 function isNodeInLinkedList(n2) {
19397 return "__ln" in n2;
19398 }
19399 var DoubleLinkedList = /*#__PURE__*/ function() {
19400 function DoubleLinkedList() {
19401 __publicField(this, "length", 0);
19402 __publicField(this, "head", null);
19403 __publicField(this, "tail", null);
19404 }
19405 var _proto = DoubleLinkedList.prototype;
19406 _proto.get = function get(position) {
19407 if (position >= this.length) {
19408 throw new Error("Position outside of list range");
19409 }
19410 var current = this.head;
19411 for(var index2 = 0; index2 < position; index2++){
19412 current = (current == null ? void 0 : current.next) || null;
19413 }
19414 return current;
19415 };
19416 _proto.addNode = function addNode(n2) {
19417 var node2 = {
19418 value: n2,
19419 previous: null,
19420 next: null
19421 };
19422 n2.__ln = node2;
19423 if (n2.previousSibling && isNodeInLinkedList(n2.previousSibling)) {
19424 var current = n2.previousSibling.__ln.next;
19425 node2.next = current;
19426 node2.previous = n2.previousSibling.__ln;
19427 n2.previousSibling.__ln.next = node2;
19428 if (current) {
19429 current.previous = node2;
19430 }
19431 } else if (n2.nextSibling && isNodeInLinkedList(n2.nextSibling) && n2.nextSibling.__ln.previous) {
19432 var current1 = n2.nextSibling.__ln.previous;
19433 node2.previous = current1;
19434 node2.next = n2.nextSibling.__ln;
19435 n2.nextSibling.__ln.previous = node2;
19436 if (current1) {
19437 current1.next = node2;
19438 }
19439 } else {
19440 if (this.head) {
19441 this.head.previous = node2;
19442 }
19443 node2.next = this.head;
19444 this.head = node2;
19445 }
19446 if (node2.next === null) {
19447 this.tail = node2;
19448 }
19449 this.length++;
19450 };
19451 _proto.removeNode = function removeNode(n2) {
19452 var current = n2.__ln;
19453 if (!this.head) {
19454 return;
19455 }
19456 if (!current.previous) {
19457 this.head = current.next;
19458 if (this.head) {
19459 this.head.previous = null;
19460 } else {
19461 this.tail = null;
19462 }
19463 } else {
19464 current.previous.next = current.next;
19465 if (current.next) {
19466 current.next.previous = current.previous;
19467 } else {
19468 this.tail = current.previous;
19469 }
19470 }
19471 if (n2.__ln) {
19472 delete n2.__ln;
19473 }
19474 this.length--;
19475 };
19476 return DoubleLinkedList;
19477 }();
19478 var moveKey = function(id, parentId) {
19479 return id + "@" + parentId;
19480 };
19481 var MutationBuffer = /*#__PURE__*/ function() {
19482 function MutationBuffer() {
19483 var _this = this;
19484 __publicField(this, "frozen", false);
19485 __publicField(this, "locked", false);
19486 __publicField(this, "texts", []);
19487 __publicField(this, "attributes", []);
19488 __publicField(this, "attributeMap", /* @__PURE__ */ new WeakMap());
19489 __publicField(this, "removes", []);
19490 __publicField(this, "mapRemoves", []);
19491 __publicField(this, "movedMap", {});
19492 /**
19493 * the browser MutationObserver emits multiple mutations after
19494 * a delay for performance reasons, making tracing added nodes hard
19495 * in our `processMutations` callback function.
19496 * For example, if we append an element el_1 into body, and then append
19497 * another element el_2 into el_1, these two mutations may be passed to the
19498 * callback function together when the two operations were done.
19499 * Generally we need to trace child nodes of newly added nodes, but in this
19500 * case if we count el_2 as el_1's child node in the first mutation record,
19501 * then we will count el_2 again in the second mutation record which was
19502 * duplicated.
19503 * To avoid of duplicate counting added nodes, we use a Set to store
19504 * added nodes and its child nodes during iterate mutation records. Then
19505 * collect added nodes from the Set which have no duplicate copy. But
19506 * this also causes newly added nodes will not be serialized with id ASAP,
19507 * which means all the id related calculation should be lazy too.
19508 */ __publicField(this, "addedSet", /* @__PURE__ */ new Set());
19509 __publicField(this, "movedSet", /* @__PURE__ */ new Set());
19510 __publicField(this, "droppedSet", /* @__PURE__ */ new Set());
19511 __publicField(this, "removesSubTreeCache", /* @__PURE__ */ new Set());
19512 __publicField(this, "mutationCb");
19513 __publicField(this, "blockClass");
19514 __publicField(this, "blockSelector");
19515 __publicField(this, "maskTextClass");
19516 __publicField(this, "maskTextSelector");
19517 __publicField(this, "inlineStylesheet");
19518 __publicField(this, "maskInputOptions");
19519 __publicField(this, "maskTextFn");
19520 __publicField(this, "maskInputFn");
19521 __publicField(this, "keepIframeSrcFn");
19522 __publicField(this, "recordCanvas");
19523 __publicField(this, "inlineImages");
19524 __publicField(this, "slimDOMOptions");
19525 __publicField(this, "dataURLOptions");
19526 __publicField(this, "doc");
19527 __publicField(this, "mirror");
19528 __publicField(this, "iframeManager");
19529 __publicField(this, "stylesheetManager");
19530 __publicField(this, "shadowDomManager");
19531 __publicField(this, "canvasManager");
19532 __publicField(this, "processedNodeManager");
19533 __publicField(this, "unattachedDoc");
19534 __publicField(this, "processMutations", function(mutations) {
19535 mutations.forEach(_this.processMutation);
19536 _this.emit();
19537 });
19538 __publicField(this, "emit", function() {
19539 if (_this.frozen || _this.locked) {
19540 return;
19541 }
19542 var adds = [];
19543 var addedIds = /* @__PURE__ */ new Set();
19544 var addList = new DoubleLinkedList();
19545 var getNextId = function(n2) {
19546 var ns = n2;
19547 var nextId = IGNORED_NODE;
19548 while(nextId === IGNORED_NODE){
19549 ns = ns && ns.nextSibling;
19550 nextId = ns && _this.mirror.getId(ns);
19551 }
19552 return nextId;
19553 };
19554 var pushAdd = function(n2) {
19555 var parent = index.parentNode(n2);
19556 if (!parent || !inDom(n2)) {
19557 return;
19558 }
19559 var cssCaptured = false;
19560 if (n2.nodeType === Node.TEXT_NODE) {
19561 var parentTag = parent.tagName;
19562 if (parentTag === "TEXTAREA") {
19563 return;
19564 } else if (parentTag === "STYLE" && _this.addedSet.has(parent)) {
19565 cssCaptured = true;
19566 }
19567 }
19568 var parentId = isShadowRoot(parent) ? _this.mirror.getId(getShadowHost(n2)) : _this.mirror.getId(parent);
19569 var nextId = getNextId(n2);
19570 if (parentId === -1 || nextId === -1) {
19571 return addList.addNode(n2);
19572 }
19573 var sn = serializeNodeWithId(n2, {
19574 doc: _this.doc,
19575 mirror: _this.mirror,
19576 blockClass: _this.blockClass,
19577 blockSelector: _this.blockSelector,
19578 maskTextClass: _this.maskTextClass,
19579 maskTextSelector: _this.maskTextSelector,
19580 skipChild: true,
19581 newlyAddedElement: true,
19582 inlineStylesheet: _this.inlineStylesheet,
19583 maskInputOptions: _this.maskInputOptions,
19584 maskTextFn: _this.maskTextFn,
19585 maskInputFn: _this.maskInputFn,
19586 slimDOMOptions: _this.slimDOMOptions,
19587 dataURLOptions: _this.dataURLOptions,
19588 recordCanvas: _this.recordCanvas,
19589 inlineImages: _this.inlineImages,
19590 onSerialize: function(currentN) {
19591 if (isSerializedIframe(currentN, _this.mirror)) {
19592 _this.iframeManager.addIframe(currentN);
19593 }
19594 if (isSerializedStylesheet(currentN, _this.mirror)) {
19595 _this.stylesheetManager.trackLinkElement(currentN);
19596 }
19597 if (hasShadowRoot(n2)) {
19598 _this.shadowDomManager.addShadowRoot(index.shadowRoot(n2), _this.doc);
19599 }
19600 },
19601 onIframeLoad: function(iframe, childSn) {
19602 _this.iframeManager.attachIframe(iframe, childSn);
19603 _this.shadowDomManager.observeAttachShadow(iframe);
19604 },
19605 onStylesheetLoad: function(link, childSn) {
19606 _this.stylesheetManager.attachLinkElement(link, childSn);
19607 },
19608 cssCaptured: cssCaptured
19609 });
19610 if (sn) {
19611 adds.push({
19612 parentId: parentId,
19613 nextId: nextId,
19614 node: sn
19615 });
19616 addedIds.add(sn.id);
19617 }
19618 };
19619 while(_this.mapRemoves.length){
19620 _this.mirror.removeNodeFromMap(_this.mapRemoves.shift());
19621 }
19622 for(var _iterator = _create_for_of_iterator_helper_loose(_this.movedSet), _step; !(_step = _iterator()).done;){
19623 var n2 = _step.value;
19624 if (isParentRemoved(_this.removesSubTreeCache, n2, _this.mirror) && !_this.movedSet.has(index.parentNode(n2))) {
19625 continue;
19626 }
19627 pushAdd(n2);
19628 }
19629 for(var _iterator1 = _create_for_of_iterator_helper_loose(_this.addedSet), _step1; !(_step1 = _iterator1()).done;){
19630 var n21 = _step1.value;
19631 if (!isAncestorInSet(_this.droppedSet, n21) && !isParentRemoved(_this.removesSubTreeCache, n21, _this.mirror)) {
19632 pushAdd(n21);
19633 } else if (isAncestorInSet(_this.movedSet, n21)) {
19634 pushAdd(n21);
19635 } else {
19636 _this.droppedSet.add(n21);
19637 }
19638 }
19639 var candidate = null;
19640 while(addList.length){
19641 var node2 = null;
19642 if (candidate) {
19643 var parentId = _this.mirror.getId(index.parentNode(candidate.value));
19644 var nextId = getNextId(candidate.value);
19645 if (parentId !== -1 && nextId !== -1) {
19646 node2 = candidate;
19647 }
19648 }
19649 if (!node2) {
19650 var tailNode = addList.tail;
19651 while(tailNode){
19652 var _node = tailNode;
19653 tailNode = tailNode.previous;
19654 if (_node) {
19655 var parentId1 = _this.mirror.getId(index.parentNode(_node.value));
19656 var nextId1 = getNextId(_node.value);
19657 if (nextId1 === -1) continue;
19658 else if (parentId1 !== -1) {
19659 node2 = _node;
19660 break;
19661 } else {
19662 var unhandledNode = _node.value;
19663 var parent = index.parentNode(unhandledNode);
19664 if (parent && parent.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
19665 var shadowHost = index.host(parent);
19666 var parentId2 = _this.mirror.getId(shadowHost);
19667 if (parentId2 !== -1) {
19668 node2 = _node;
19669 break;
19670 }
19671 }
19672 }
19673 }
19674 }
19675 }
19676 if (!node2) {
19677 while(addList.head){
19678 addList.removeNode(addList.head.value);
19679 }
19680 break;
19681 }
19682 candidate = node2.previous;
19683 addList.removeNode(node2.value);
19684 pushAdd(node2.value);
19685 }
19686 var payload = {
19687 texts: _this.texts.map(function(text) {
19688 var n2 = text.node;
19689 var parent = index.parentNode(n2);
19690 if (parent && parent.tagName === "TEXTAREA") {
19691 _this.genTextAreaValueMutation(parent);
19692 }
19693 return {
19694 id: _this.mirror.getId(n2),
19695 value: text.value
19696 };
19697 }).filter(function(text) {
19698 return !addedIds.has(text.id);
19699 }).filter(function(text) {
19700 return _this.mirror.has(text.id);
19701 }),
19702 attributes: _this.attributes.map(function(attribute) {
19703 var attributes = attribute.attributes;
19704 if (typeof attributes.style === "string") {
19705 var diffAsStr = JSON.stringify(attribute.styleDiff);
19706 var unchangedAsStr = JSON.stringify(attribute._unchangedStyles);
19707 if (diffAsStr.length < attributes.style.length) {
19708 if ((diffAsStr + unchangedAsStr).split("var(").length === attributes.style.split("var(").length) {
19709 attributes.style = attribute.styleDiff;
19710 }
19711 }
19712 }
19713 return {
19714 id: _this.mirror.getId(attribute.node),
19715 attributes: attributes
19716 };
19717 }).filter(function(attribute) {
19718 return !addedIds.has(attribute.id);
19719 }).filter(function(attribute) {
19720 return _this.mirror.has(attribute.id);
19721 }),
19722 removes: _this.removes,
19723 adds: adds
19724 };
19725 if (!payload.texts.length && !payload.attributes.length && !payload.removes.length && !payload.adds.length) {
19726 return;
19727 }
19728 _this.texts = [];
19729 _this.attributes = [];
19730 _this.attributeMap = /* @__PURE__ */ new WeakMap();
19731 _this.removes = [];
19732 _this.addedSet = /* @__PURE__ */ new Set();
19733 _this.movedSet = /* @__PURE__ */ new Set();
19734 _this.droppedSet = /* @__PURE__ */ new Set();
19735 _this.removesSubTreeCache = /* @__PURE__ */ new Set();
19736 _this.movedMap = {};
19737 _this.mutationCb(payload);
19738 });
19739 __publicField(this, "genTextAreaValueMutation", function(textarea) {
19740 var item = _this.attributeMap.get(textarea);
19741 if (!item) {
19742 item = {
19743 node: textarea,
19744 attributes: {},
19745 styleDiff: {},
19746 _unchangedStyles: {}
19747 };
19748 _this.attributes.push(item);
19749 _this.attributeMap.set(textarea, item);
19750 }
19751 var value = Array.from(index.childNodes(textarea), function(cn) {
19752 return index.textContent(cn) || "";
19753 }).join("");
19754 item.attributes.value = maskInputValue({
19755 element: textarea,
19756 maskInputOptions: _this.maskInputOptions,
19757 tagName: textarea.tagName,
19758 type: getInputType(textarea),
19759 value: value,
19760 maskInputFn: _this.maskInputFn
19761 });
19762 });
19763 __publicField(this, "processMutation", function(m) {
19764 if (isIgnored(m.target, _this.mirror, _this.slimDOMOptions)) {
19765 return;
19766 }
19767 switch(m.type){
19768 case "characterData":
19769 {
19770 var value = index.textContent(m.target);
19771 if (!isBlocked(m.target, _this.blockClass, _this.blockSelector, false) && value !== m.oldValue) {
19772 _this.texts.push({
19773 value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector, true) && value ? _this.maskTextFn ? _this.maskTextFn(value, closestElementOfNode(m.target)) : value.replace(/[\S]/g, "*") : value,
19774 node: m.target
19775 });
19776 }
19777 break;
19778 }
19779 case "attributes":
19780 {
19781 var target = m.target;
19782 var attributeName = m.attributeName;
19783 var value1 = m.target.getAttribute(attributeName);
19784 if (attributeName === "value") {
19785 var type = getInputType(target);
19786 value1 = maskInputValue({
19787 element: target,
19788 maskInputOptions: _this.maskInputOptions,
19789 tagName: target.tagName,
19790 type: type,
19791 value: value1,
19792 maskInputFn: _this.maskInputFn
19793 });
19794 }
19795 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, false) || value1 === m.oldValue) {
19796 return;
19797 }
19798 var item = _this.attributeMap.get(m.target);
19799 if (target.tagName === "IFRAME" && attributeName === "src" && !_this.keepIframeSrcFn(value1)) {
19800 if (!target.contentDocument) {
19801 attributeName = "rr_src";
19802 } else {
19803 return;
19804 }
19805 }
19806 if (!item) {
19807 item = {
19808 node: m.target,
19809 attributes: {},
19810 styleDiff: {},
19811 _unchangedStyles: {}
19812 };
19813 _this.attributes.push(item);
19814 _this.attributeMap.set(m.target, item);
19815 }
19816 if (attributeName === "type" && target.tagName === "INPUT" && (m.oldValue || "").toLowerCase() === "password") {
19817 target.setAttribute("data-rr-is-password", "true");
19818 }
19819 if (!ignoreAttribute(target.tagName, attributeName)) {
19820 item.attributes[attributeName] = transformAttribute(_this.doc, toLowerCase(target.tagName), toLowerCase(attributeName), value1);
19821 if (attributeName === "style") {
19822 if (!_this.unattachedDoc) {
19823 try {
19824 _this.unattachedDoc = document.implementation.createHTMLDocument();
19825 } catch (e2) {
19826 _this.unattachedDoc = _this.doc;
19827 }
19828 }
19829 var old = _this.unattachedDoc.createElement("span");
19830 if (m.oldValue) {
19831 old.setAttribute("style", m.oldValue);
19832 }
19833 for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(target.style)), _step; !(_step = _iterator()).done;){
19834 var pname = _step.value;
19835 var newValue = target.style.getPropertyValue(pname);
19836 var newPriority = target.style.getPropertyPriority(pname);
19837 if (newValue !== old.style.getPropertyValue(pname) || newPriority !== old.style.getPropertyPriority(pname)) {
19838 if (newPriority === "") {
19839 item.styleDiff[pname] = newValue;
19840 } else {
19841 item.styleDiff[pname] = [
19842 newValue,
19843 newPriority
19844 ];
19845 }
19846 } else {
19847 item._unchangedStyles[pname] = [
19848 newValue,
19849 newPriority
19850 ];
19851 }
19852 }
19853 for(var _iterator1 = _create_for_of_iterator_helper_loose(Array.from(old.style)), _step1; !(_step1 = _iterator1()).done;){
19854 var pname1 = _step1.value;
19855 if (target.style.getPropertyValue(pname1) === "") {
19856 item.styleDiff[pname1] = false;
19857 }
19858 }
19859 } else if (attributeName === "open" && target.tagName === "DIALOG") {
19860 if (target.matches("dialog:modal")) {
19861 item.attributes["rr_open_mode"] = "modal";
19862 } else {
19863 item.attributes["rr_open_mode"] = "non-modal";
19864 }
19865 }
19866 }
19867 break;
19868 }
19869 case "childList":
19870 {
19871 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, true)) return;
19872 if (m.target.tagName === "TEXTAREA") {
19873 _this.genTextAreaValueMutation(m.target);
19874 return;
19875 }
19876 m.addedNodes.forEach(function(n2) {
19877 return _this.genAdds(n2, m.target);
19878 });
19879 m.removedNodes.forEach(function(n2) {
19880 var nodeId = _this.mirror.getId(n2);
19881 var parentId = isShadowRoot(m.target) ? _this.mirror.getId(index.host(m.target)) : _this.mirror.getId(m.target);
19882 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, false) || isIgnored(n2, _this.mirror, _this.slimDOMOptions) || !isSerialized(n2, _this.mirror)) {
19883 return;
19884 }
19885 if (_this.addedSet.has(n2)) {
19886 deepDelete(_this.addedSet, n2);
19887 _this.droppedSet.add(n2);
19888 } else if (_this.addedSet.has(m.target) && nodeId === -1) ;
19889 else if (isAncestorRemoved(m.target, _this.mirror)) ;
19890 else if (_this.movedSet.has(n2) && _this.movedMap[moveKey(nodeId, parentId)]) {
19891 deepDelete(_this.movedSet, n2);
19892 } else {
19893 _this.removes.push({
19894 parentId: parentId,
19895 id: nodeId,
19896 isShadow: isShadowRoot(m.target) && isNativeShadowDom(m.target) ? true : void 0
19897 });
19898 processRemoves(n2, _this.removesSubTreeCache);
19899 }
19900 _this.mapRemoves.push(n2);
19901 });
19902 break;
19903 }
19904 }
19905 });
19906 /**
19907 * Make sure you check if `n`'s parent is blocked before calling this function
19908 * */ __publicField(this, "genAdds", function(n2, target) {
19909 if (_this.processedNodeManager.inOtherBuffer(n2, _this)) return;
19910 if (_this.addedSet.has(n2) || _this.movedSet.has(n2)) return;
19911 if (_this.mirror.hasNode(n2)) {
19912 if (isIgnored(n2, _this.mirror, _this.slimDOMOptions)) {
19913 return;
19914 }
19915 _this.movedSet.add(n2);
19916 var targetId = null;
19917 if (target && _this.mirror.hasNode(target)) {
19918 targetId = _this.mirror.getId(target);
19919 }
19920 if (targetId && targetId !== -1) {
19921 _this.movedMap[moveKey(_this.mirror.getId(n2), targetId)] = true;
19922 }
19923 } else {
19924 _this.addedSet.add(n2);
19925 _this.droppedSet.delete(n2);
19926 }
19927 if (!isBlocked(n2, _this.blockClass, _this.blockSelector, false)) {
19928 index.childNodes(n2).forEach(function(childN) {
19929 return _this.genAdds(childN);
19930 });
19931 if (hasShadowRoot(n2)) {
19932 index.childNodes(index.shadowRoot(n2)).forEach(function(childN) {
19933 _this.processedNodeManager.add(childN, _this);
19934 _this.genAdds(childN, n2);
19935 });
19936 }
19937 }
19938 });
19939 }
19940 var _proto = MutationBuffer.prototype;
19941 _proto.init = function init(options) {
19942 var _this = this;
19943 [
19944 "mutationCb",
19945 "blockClass",
19946 "blockSelector",
19947 "maskTextClass",
19948 "maskTextSelector",
19949 "inlineStylesheet",
19950 "maskInputOptions",
19951 "maskTextFn",
19952 "maskInputFn",
19953 "keepIframeSrcFn",
19954 "recordCanvas",
19955 "inlineImages",
19956 "slimDOMOptions",
19957 "dataURLOptions",
19958 "doc",
19959 "mirror",
19960 "iframeManager",
19961 "stylesheetManager",
19962 "shadowDomManager",
19963 "canvasManager",
19964 "processedNodeManager"
19965 ].forEach(function(key) {
19966 _this[key] = options[key];
19967 });
19968 };
19969 _proto.freeze = function freeze() {
19970 this.frozen = true;
19971 this.canvasManager.freeze();
19972 };
19973 _proto.unfreeze = function unfreeze() {
19974 this.frozen = false;
19975 this.canvasManager.unfreeze();
19976 this.emit();
19977 };
19978 _proto.isFrozen = function isFrozen() {
19979 return this.frozen;
19980 };
19981 _proto.lock = function lock() {
19982 this.locked = true;
19983 this.canvasManager.lock();
19984 };
19985 _proto.unlock = function unlock() {
19986 this.locked = false;
19987 this.canvasManager.unlock();
19988 this.emit();
19989 };
19990 _proto.reset = function reset() {
19991 this.shadowDomManager.reset();
19992 this.canvasManager.reset();
19993 };
19994 return MutationBuffer;
19995 }();
19996 function deepDelete(addsSet, n2) {
19997 addsSet.delete(n2);
19998 index.childNodes(n2).forEach(function(childN) {
19999 return deepDelete(addsSet, childN);
20000 });
20001 }
20002 function processRemoves(n2, cache) {
20003 var queue = [
20004 n2
20005 ];
20006 while(queue.length){
20007 var next = queue.pop();
20008 if (cache.has(next)) continue;
20009 cache.add(next);
20010 index.childNodes(next).forEach(function(n22) {
20011 return queue.push(n22);
20012 });
20013 }
20014 return;
20015 }
20016 function isParentRemoved(removes, n2, mirror2) {
20017 if (removes.size === 0) return false;
20018 return _isParentRemoved(removes, n2);
20019 }
20020 function _isParentRemoved(removes, n2, _mirror2) {
20021 var node2 = index.parentNode(n2);
20022 if (!node2) return false;
20023 return removes.has(node2);
20024 }
20025 function isAncestorInSet(set, n2) {
20026 if (set.size === 0) return false;
20027 return _isAncestorInSet(set, n2);
20028 }
20029 function _isAncestorInSet(set, n2) {
20030 var parent = index.parentNode(n2);
20031 if (!parent) {
20032 return false;
20033 }
20034 if (set.has(parent)) {
20035 return true;
20036 }
20037 return _isAncestorInSet(set, parent);
20038 }
20039 var errorHandler;
20040 function registerErrorHandler(handler) {
20041 errorHandler = handler;
20042 }
20043 function unregisterErrorHandler() {
20044 errorHandler = void 0;
20045 }
20046 var callbackWrapper = function(cb) {
20047 if (!errorHandler) {
20048 return cb;
20049 }
20050 var rrwebWrapped = function() {
20051 for(var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++){
20052 rest[_key] = arguments[_key];
20053 }
20054 try {
20055 return cb.apply(void 0, [].concat(rest));
20056 } catch (error) {
20057 if (errorHandler && errorHandler(error) === true) {
20058 return;
20059 }
20060 throw error;
20061 }
20062 };
20063 return rrwebWrapped;
20064 };
20065 var mutationBuffers = [];
20066 function getEventTarget(event) {
20067 try {
20068 if ("composedPath" in event) {
20069 var path = event.composedPath();
20070 if (path.length) {
20071 return path[0];
20072 }
20073 } else if ("path" in event && event.path.length) {
20074 return event.path[0];
20075 }
20076 } catch (e) {}
20077 return event && event.target;
20078 }
20079 function initMutationObserver(options, rootEl) {
20080 var mutationBuffer = new MutationBuffer();
20081 mutationBuffers.push(mutationBuffer);
20082 mutationBuffer.init(options);
20083 var observer = new (mutationObserverCtor())(callbackWrapper(mutationBuffer.processMutations.bind(mutationBuffer)));
20084 observer.observe(rootEl, {
20085 attributes: true,
20086 attributeOldValue: true,
20087 characterData: true,
20088 characterDataOldValue: true,
20089 childList: true,
20090 subtree: true
20091 });
20092 return observer;
20093 }
20094 function initMoveObserver(param) {
20095 var mousemoveCb = param.mousemoveCb, sampling = param.sampling, doc = param.doc, mirror2 = param.mirror;
20096 if (sampling.mousemove === false) {
20097 return function() {};
20098 }
20099 var threshold = typeof sampling.mousemove === "number" ? sampling.mousemove : 50;
20100 var callbackThreshold = typeof sampling.mousemoveCallback === "number" ? sampling.mousemoveCallback : 500;
20101 var positions = [];
20102 var timeBaseline;
20103 var wrappedCb = throttle(callbackWrapper(function(source) {
20104 var totalOffset = Date.now() - timeBaseline;
20105 mousemoveCb(positions.map(function(p) {
20106 p.timeOffset -= totalOffset;
20107 return p;
20108 }), source);
20109 positions = [];
20110 timeBaseline = null;
20111 }), callbackThreshold);
20112 var updatePosition = callbackWrapper(throttle(callbackWrapper(function(evt) {
20113 var target = getEventTarget(evt);
20114 var _ref = legacy_isTouchEvent(evt) ? evt.changedTouches[0] : evt, clientX = _ref.clientX, clientY = _ref.clientY;
20115 if (!timeBaseline) {
20116 timeBaseline = nowTimestamp();
20117 }
20118 positions.push({
20119 x: clientX,
20120 y: clientY,
20121 id: mirror2.getId(target),
20122 timeOffset: nowTimestamp() - timeBaseline
20123 });
20124 wrappedCb(typeof DragEvent !== "undefined" && _instanceof(evt, DragEvent) ? IncrementalSource.Drag : _instanceof(evt, MouseEvent) ? IncrementalSource.MouseMove : IncrementalSource.TouchMove);
20125 }), threshold, {
20126 trailing: false
20127 }));
20128 var handlers = [
20129 on("mousemove", updatePosition, doc),
20130 on("touchmove", updatePosition, doc),
20131 on("drag", updatePosition, doc)
20132 ];
20133 return callbackWrapper(function() {
20134 handlers.forEach(function(h) {
20135 return h();
20136 });
20137 });
20138 }
20139 function initMouseInteractionObserver(param) {
20140 var mouseInteractionCb = param.mouseInteractionCb, doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, sampling = param.sampling;
20141 if (sampling.mouseInteraction === false) {
20142 return function() {};
20143 }
20144 var disableMap = sampling.mouseInteraction === true || sampling.mouseInteraction === void 0 ? {} : sampling.mouseInteraction;
20145 var handlers = [];
20146 var currentPointerType = null;
20147 var getHandler = function(eventKey) {
20148 return function(event) {
20149 var target = getEventTarget(event);
20150 if (isBlocked(target, blockClass, blockSelector, true)) {
20151 return;
20152 }
20153 var pointerType = null;
20154 var thisEventKey = eventKey;
20155 if ("pointerType" in event) {
20156 switch(event.pointerType){
20157 case "mouse":
20158 pointerType = PointerTypes.Mouse;
20159 break;
20160 case "touch":
20161 pointerType = PointerTypes.Touch;
20162 break;
20163 case "pen":
20164 pointerType = PointerTypes.Pen;
20165 break;
20166 }
20167 if (pointerType === PointerTypes.Touch) {
20168 if (MouseInteractions[eventKey] === MouseInteractions.MouseDown) {
20169 thisEventKey = "TouchStart";
20170 } else if (MouseInteractions[eventKey] === MouseInteractions.MouseUp) {
20171 thisEventKey = "TouchEnd";
20172 }
20173 } else if (pointerType === PointerTypes.Pen) ;
20174 } else if (legacy_isTouchEvent(event)) {
20175 pointerType = PointerTypes.Touch;
20176 }
20177 if (pointerType !== null) {
20178 currentPointerType = pointerType;
20179 if (thisEventKey.startsWith("Touch") && pointerType === PointerTypes.Touch || thisEventKey.startsWith("Mouse") && pointerType === PointerTypes.Mouse) {
20180 pointerType = null;
20181 }
20182 } else if (MouseInteractions[eventKey] === MouseInteractions.Click) {
20183 pointerType = currentPointerType;
20184 currentPointerType = null;
20185 }
20186 var e2 = legacy_isTouchEvent(event) ? event.changedTouches[0] : event;
20187 if (!e2) {
20188 return;
20189 }
20190 var id = mirror2.getId(target);
20191 var clientX = e2.clientX, clientY = e2.clientY;
20192 callbackWrapper(mouseInteractionCb)(_extends({
20193 type: MouseInteractions[thisEventKey],
20194 id: id,
20195 x: clientX,
20196 y: clientY
20197 }, pointerType !== null && {
20198 pointerType: pointerType
20199 }));
20200 };
20201 };
20202 Object.keys(MouseInteractions).filter(function(key) {
20203 return Number.isNaN(Number(key)) && !key.endsWith("_Departed") && disableMap[key] !== false;
20204 }).forEach(function(eventKey) {
20205 var eventName = toLowerCase(eventKey);
20206 var handler = getHandler(eventKey);
20207 if (window.PointerEvent) {
20208 switch(MouseInteractions[eventKey]){
20209 case MouseInteractions.MouseDown:
20210 case MouseInteractions.MouseUp:
20211 eventName = eventName.replace("mouse", "pointer");
20212 break;
20213 case MouseInteractions.TouchStart:
20214 case MouseInteractions.TouchEnd:
20215 return;
20216 }
20217 }
20218 handlers.push(on(eventName, handler, doc));
20219 });
20220 return callbackWrapper(function() {
20221 handlers.forEach(function(h) {
20222 return h();
20223 });
20224 });
20225 }
20226 function initScrollObserver(param) {
20227 var scrollCb = param.scrollCb, doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, sampling = param.sampling;
20228 var updatePosition = callbackWrapper(throttle(callbackWrapper(function(evt) {
20229 var target = getEventTarget(evt);
20230 if (!target || isBlocked(target, blockClass, blockSelector, true)) {
20231 return;
20232 }
20233 var id = mirror2.getId(target);
20234 if (target === doc && doc.defaultView) {
20235 var scrollLeftTop = getWindowScroll(doc.defaultView);
20236 scrollCb({
20237 id: id,
20238 x: scrollLeftTop.left,
20239 y: scrollLeftTop.top
20240 });
20241 } else {
20242 scrollCb({
20243 id: id,
20244 x: target.scrollLeft,
20245 y: target.scrollTop
20246 });
20247 }
20248 }), sampling.scroll || 100));
20249 return on("scroll", updatePosition, doc);
20250 }
20251 function initViewportResizeObserver(param, param1) {
20252 var viewportResizeCb = param.viewportResizeCb;
20253 var win = param1.win;
20254 var lastH = -1;
20255 var lastW = -1;
20256 var updateDimension = callbackWrapper(throttle(callbackWrapper(function() {
20257 var height = getWindowHeight();
20258 var width = getWindowWidth();
20259 if (lastH !== height || lastW !== width) {
20260 viewportResizeCb({
20261 width: Number(width),
20262 height: Number(height)
20263 });
20264 lastH = height;
20265 lastW = width;
20266 }
20267 }), 200));
20268 return on("resize", updateDimension, win);
20269 }
20270 var INPUT_TAGS = [
20271 "INPUT",
20272 "TEXTAREA",
20273 "SELECT"
20274 ];
20275 var lastInputValueMap = /* @__PURE__ */ new WeakMap();
20276 function initInputObserver(param) {
20277 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;
20278 function eventHandler(event) {
20279 var target = getEventTarget(event);
20280 var userTriggered = event.isTrusted;
20281 var tagName = target && target.tagName;
20282 if (target && tagName === "OPTION") {
20283 target = index.parentElement(target);
20284 }
20285 if (!target || !tagName || INPUT_TAGS.indexOf(tagName) < 0 || isBlocked(target, blockClass, blockSelector, true)) {
20286 return;
20287 }
20288 if (target.classList.contains(ignoreClass) || ignoreSelector && target.matches(ignoreSelector)) {
20289 return;
20290 }
20291 var text = target.value;
20292 var isChecked = false;
20293 var type = getInputType(target) || "";
20294 if (type === "radio" || type === "checkbox") {
20295 isChecked = target.checked;
20296 } else if (maskInputOptions[tagName.toLowerCase()] || maskInputOptions[type]) {
20297 text = maskInputValue({
20298 element: target,
20299 maskInputOptions: maskInputOptions,
20300 tagName: tagName,
20301 type: type,
20302 value: text,
20303 maskInputFn: maskInputFn
20304 });
20305 }
20306 cbWithDedup(target, userTriggeredOnInput ? {
20307 text: text,
20308 isChecked: isChecked,
20309 userTriggered: userTriggered
20310 } : {
20311 text: text,
20312 isChecked: isChecked
20313 });
20314 var name = target.name;
20315 if (type === "radio" && name && isChecked) {
20316 doc.querySelectorAll('input[type="radio"][name="' + name + '"]').forEach(function(el) {
20317 if (el !== target) {
20318 var text2 = el.value;
20319 cbWithDedup(el, userTriggeredOnInput ? {
20320 text: text2,
20321 isChecked: !isChecked,
20322 userTriggered: false
20323 } : {
20324 text: text2,
20325 isChecked: !isChecked
20326 });
20327 }
20328 });
20329 }
20330 }
20331 function cbWithDedup(target, v2) {
20332 var lastInputValue = lastInputValueMap.get(target);
20333 if (!lastInputValue || lastInputValue.text !== v2.text || lastInputValue.isChecked !== v2.isChecked) {
20334 lastInputValueMap.set(target, v2);
20335 var id = mirror2.getId(target);
20336 callbackWrapper(inputCb)(_extends({}, v2, {
20337 id: id
20338 }));
20339 }
20340 }
20341 var events = sampling.input === "last" ? [
20342 "change"
20343 ] : [
20344 "input",
20345 "change"
20346 ];
20347 var handlers = events.map(function(eventName) {
20348 return on(eventName, callbackWrapper(eventHandler), doc);
20349 });
20350 var currentWindow = doc.defaultView;
20351 if (!currentWindow) {
20352 return function() {
20353 handlers.forEach(function(h) {
20354 return h();
20355 });
20356 };
20357 }
20358 var propertyDescriptor = currentWindow.Object.getOwnPropertyDescriptor(currentWindow.HTMLInputElement.prototype, "value");
20359 var hookProperties = [
20360 [
20361 currentWindow.HTMLInputElement.prototype,
20362 "value"
20363 ],
20364 [
20365 currentWindow.HTMLInputElement.prototype,
20366 "checked"
20367 ],
20368 [
20369 currentWindow.HTMLSelectElement.prototype,
20370 "value"
20371 ],
20372 [
20373 currentWindow.HTMLTextAreaElement.prototype,
20374 "value"
20375 ],
20376 // Some UI library use selectedIndex to set select value
20377 [
20378 currentWindow.HTMLSelectElement.prototype,
20379 "selectedIndex"
20380 ],
20381 [
20382 currentWindow.HTMLOptionElement.prototype,
20383 "selected"
20384 ]
20385 ];
20386 if (propertyDescriptor && propertyDescriptor.set) {
20387 var _handlers;
20388 (_handlers = handlers).push.apply(_handlers, [].concat(hookProperties.map(function(p) {
20389 return hookSetter(p[0], p[1], {
20390 set: function set() {
20391 callbackWrapper(eventHandler)({
20392 target: this,
20393 isTrusted: false
20394 });
20395 }
20396 }, false, currentWindow);
20397 })));
20398 }
20399 return callbackWrapper(function() {
20400 handlers.forEach(function(h) {
20401 return h();
20402 });
20403 });
20404 }
20405 function getNestedCSSRulePositions(rule2) {
20406 var positions = [];
20407 function recurse(childRule, pos) {
20408 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)) {
20409 var rules2 = Array.from(childRule.parentRule.cssRules);
20410 var index2 = rules2.indexOf(childRule);
20411 pos.unshift(index2);
20412 } else if (childRule.parentStyleSheet) {
20413 var rules21 = Array.from(childRule.parentStyleSheet.cssRules);
20414 var index21 = rules21.indexOf(childRule);
20415 pos.unshift(index21);
20416 }
20417 return pos;
20418 }
20419 return recurse(rule2, positions);
20420 }
20421 function getIdAndStyleId(sheet, mirror2, styleMirror) {
20422 var id, styleId;
20423 if (!sheet) return {};
20424 if (sheet.ownerNode) id = mirror2.getId(sheet.ownerNode);
20425 else styleId = styleMirror.getId(sheet);
20426 return {
20427 styleId: styleId,
20428 id: id
20429 };
20430 }
20431 function initStyleSheetObserver(param, param1) {
20432 var styleSheetRuleCb = param.styleSheetRuleCb, mirror2 = param.mirror, stylesheetManager = param.stylesheetManager;
20433 var win = param1.win;
20434 if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) {
20435 return function() {};
20436 }
20437 var insertRule = win.CSSStyleSheet.prototype.insertRule;
20438 win.CSSStyleSheet.prototype.insertRule = new Proxy(insertRule, {
20439 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20440 var rule2 = argumentsList[0], index2 = argumentsList[1];
20441 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20442 if (id && id !== -1 || styleId && styleId !== -1) {
20443 styleSheetRuleCb({
20444 id: id,
20445 styleId: styleId,
20446 adds: [
20447 {
20448 rule: rule2,
20449 index: index2
20450 }
20451 ]
20452 });
20453 }
20454 return target.apply(thisArg, argumentsList);
20455 })
20456 });
20457 win.CSSStyleSheet.prototype.addRule = function(selector, styleBlock, index2) {
20458 if (index2 === void 0) index2 = this.cssRules.length;
20459 var rule2 = selector + " { " + styleBlock + " }";
20460 return win.CSSStyleSheet.prototype.insertRule.apply(this, [
20461 rule2,
20462 index2
20463 ]);
20464 };
20465 var deleteRule = win.CSSStyleSheet.prototype.deleteRule;
20466 win.CSSStyleSheet.prototype.deleteRule = new Proxy(deleteRule, {
20467 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20468 var index2 = argumentsList[0];
20469 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20470 if (id && id !== -1 || styleId && styleId !== -1) {
20471 styleSheetRuleCb({
20472 id: id,
20473 styleId: styleId,
20474 removes: [
20475 {
20476 index: index2
20477 }
20478 ]
20479 });
20480 }
20481 return target.apply(thisArg, argumentsList);
20482 })
20483 });
20484 win.CSSStyleSheet.prototype.removeRule = function(index2) {
20485 return win.CSSStyleSheet.prototype.deleteRule.apply(this, [
20486 index2
20487 ]);
20488 };
20489 var replace;
20490 if (win.CSSStyleSheet.prototype.replace) {
20491 replace = win.CSSStyleSheet.prototype.replace;
20492 win.CSSStyleSheet.prototype.replace = new Proxy(replace, {
20493 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20494 var text = argumentsList[0];
20495 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20496 if (id && id !== -1 || styleId && styleId !== -1) {
20497 styleSheetRuleCb({
20498 id: id,
20499 styleId: styleId,
20500 replace: text
20501 });
20502 }
20503 return target.apply(thisArg, argumentsList);
20504 })
20505 });
20506 }
20507 var replaceSync;
20508 if (win.CSSStyleSheet.prototype.replaceSync) {
20509 replaceSync = win.CSSStyleSheet.prototype.replaceSync;
20510 win.CSSStyleSheet.prototype.replaceSync = new Proxy(replaceSync, {
20511 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20512 var text = argumentsList[0];
20513 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20514 if (id && id !== -1 || styleId && styleId !== -1) {
20515 styleSheetRuleCb({
20516 id: id,
20517 styleId: styleId,
20518 replaceSync: text
20519 });
20520 }
20521 return target.apply(thisArg, argumentsList);
20522 })
20523 });
20524 }
20525 var supportedNestedCSSRuleTypes = {};
20526 if (canMonkeyPatchNestedCSSRule("CSSGroupingRule")) {
20527 supportedNestedCSSRuleTypes.CSSGroupingRule = win.CSSGroupingRule;
20528 } else {
20529 if (canMonkeyPatchNestedCSSRule("CSSMediaRule")) {
20530 supportedNestedCSSRuleTypes.CSSMediaRule = win.CSSMediaRule;
20531 }
20532 if (canMonkeyPatchNestedCSSRule("CSSConditionRule")) {
20533 supportedNestedCSSRuleTypes.CSSConditionRule = win.CSSConditionRule;
20534 }
20535 if (canMonkeyPatchNestedCSSRule("CSSSupportsRule")) {
20536 supportedNestedCSSRuleTypes.CSSSupportsRule = win.CSSSupportsRule;
20537 }
20538 }
20539 var unmodifiedFunctions = {};
20540 Object.entries(supportedNestedCSSRuleTypes).forEach(function(param) {
20541 var typeKey = param[0], type = param[1];
20542 unmodifiedFunctions[typeKey] = {
20543 // eslint-disable-next-line @typescript-eslint/unbound-method
20544 insertRule: type.prototype.insertRule,
20545 // eslint-disable-next-line @typescript-eslint/unbound-method
20546 deleteRule: type.prototype.deleteRule
20547 };
20548 type.prototype.insertRule = new Proxy(unmodifiedFunctions[typeKey].insertRule, {
20549 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20550 var rule2 = argumentsList[0], index2 = argumentsList[1];
20551 var _getIdAndStyleId = getIdAndStyleId(thisArg.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20552 if (id && id !== -1 || styleId && styleId !== -1) {
20553 styleSheetRuleCb({
20554 id: id,
20555 styleId: styleId,
20556 adds: [
20557 {
20558 rule: rule2,
20559 index: [].concat(getNestedCSSRulePositions(thisArg), [
20560 index2 || 0
20561 ])
20562 }
20563 ]
20564 });
20565 }
20566 return target.apply(thisArg, argumentsList);
20567 })
20568 });
20569 type.prototype.deleteRule = new Proxy(unmodifiedFunctions[typeKey].deleteRule, {
20570 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20571 var index2 = argumentsList[0];
20572 var _getIdAndStyleId = getIdAndStyleId(thisArg.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20573 if (id && id !== -1 || styleId && styleId !== -1) {
20574 styleSheetRuleCb({
20575 id: id,
20576 styleId: styleId,
20577 removes: [
20578 {
20579 index: [].concat(getNestedCSSRulePositions(thisArg), [
20580 index2
20581 ])
20582 }
20583 ]
20584 });
20585 }
20586 return target.apply(thisArg, argumentsList);
20587 })
20588 });
20589 });
20590 return callbackWrapper(function() {
20591 win.CSSStyleSheet.prototype.insertRule = insertRule;
20592 win.CSSStyleSheet.prototype.deleteRule = deleteRule;
20593 replace && (win.CSSStyleSheet.prototype.replace = replace);
20594 replaceSync && (win.CSSStyleSheet.prototype.replaceSync = replaceSync);
20595 Object.entries(supportedNestedCSSRuleTypes).forEach(function(param) {
20596 var typeKey = param[0], type = param[1];
20597 type.prototype.insertRule = unmodifiedFunctions[typeKey].insertRule;
20598 type.prototype.deleteRule = unmodifiedFunctions[typeKey].deleteRule;
20599 });
20600 });
20601 }
20602 function initAdoptedStyleSheetObserver(param, host2) {
20603 var mirror2 = param.mirror, stylesheetManager = param.stylesheetManager;
20604 var _a2, _b, _c;
20605 var hostId = null;
20606 if (host2.nodeName === "#document") hostId = mirror2.getId(host2);
20607 else hostId = mirror2.getId(index.host(host2));
20608 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;
20609 var originalPropertyDescriptor = (patchTarget == null ? void 0 : patchTarget.prototype) ? Object.getOwnPropertyDescriptor(patchTarget == null ? void 0 : patchTarget.prototype, "adoptedStyleSheets") : void 0;
20610 if (hostId === null || hostId === -1 || !patchTarget || !originalPropertyDescriptor) return function() {};
20611 Object.defineProperty(host2, "adoptedStyleSheets", {
20612 configurable: originalPropertyDescriptor.configurable,
20613 enumerable: originalPropertyDescriptor.enumerable,
20614 get: function get() {
20615 var _a3;
20616 return (_a3 = originalPropertyDescriptor.get) == null ? void 0 : _a3.call(this);
20617 },
20618 set: function set(sheets) {
20619 var _a3;
20620 var result2 = (_a3 = originalPropertyDescriptor.set) == null ? void 0 : _a3.call(this, sheets);
20621 if (hostId !== null && hostId !== -1) {
20622 try {
20623 stylesheetManager.adoptStyleSheets(sheets, hostId);
20624 } catch (e2) {}
20625 }
20626 return result2;
20627 }
20628 });
20629 return callbackWrapper(function() {
20630 Object.defineProperty(host2, "adoptedStyleSheets", {
20631 configurable: originalPropertyDescriptor.configurable,
20632 enumerable: originalPropertyDescriptor.enumerable,
20633 // eslint-disable-next-line @typescript-eslint/unbound-method
20634 get: originalPropertyDescriptor.get,
20635 // eslint-disable-next-line @typescript-eslint/unbound-method
20636 set: originalPropertyDescriptor.set
20637 });
20638 });
20639 }
20640 function initStyleDeclarationObserver(param, param1) {
20641 var styleDeclarationCb = param.styleDeclarationCb, mirror2 = param.mirror, ignoreCSSAttributes = param.ignoreCSSAttributes, stylesheetManager = param.stylesheetManager;
20642 var win = param1.win;
20643 var setProperty = win.CSSStyleDeclaration.prototype.setProperty;
20644 win.CSSStyleDeclaration.prototype.setProperty = new Proxy(setProperty, {
20645 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20646 var _a2;
20647 var property = argumentsList[0], value = argumentsList[1], priority = argumentsList[2];
20648 if (ignoreCSSAttributes.has(property)) {
20649 return setProperty.apply(thisArg, [
20650 property,
20651 value,
20652 priority
20653 ]);
20654 }
20655 var _getIdAndStyleId = getIdAndStyleId((_a2 = thisArg.parentRule) == null ? void 0 : _a2.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20656 if (id && id !== -1 || styleId && styleId !== -1) {
20657 styleDeclarationCb({
20658 id: id,
20659 styleId: styleId,
20660 set: {
20661 property: property,
20662 value: value,
20663 priority: priority
20664 },
20665 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
20666 index: getNestedCSSRulePositions(thisArg.parentRule)
20667 });
20668 }
20669 return target.apply(thisArg, argumentsList);
20670 })
20671 });
20672 var removeProperty = win.CSSStyleDeclaration.prototype.removeProperty;
20673 win.CSSStyleDeclaration.prototype.removeProperty = new Proxy(removeProperty, {
20674 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20675 var _a2;
20676 var property = argumentsList[0];
20677 if (ignoreCSSAttributes.has(property)) {
20678 return removeProperty.apply(thisArg, [
20679 property
20680 ]);
20681 }
20682 var _getIdAndStyleId = getIdAndStyleId((_a2 = thisArg.parentRule) == null ? void 0 : _a2.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20683 if (id && id !== -1 || styleId && styleId !== -1) {
20684 styleDeclarationCb({
20685 id: id,
20686 styleId: styleId,
20687 remove: {
20688 property: property
20689 },
20690 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
20691 index: getNestedCSSRulePositions(thisArg.parentRule)
20692 });
20693 }
20694 return target.apply(thisArg, argumentsList);
20695 })
20696 });
20697 return callbackWrapper(function() {
20698 win.CSSStyleDeclaration.prototype.setProperty = setProperty;
20699 win.CSSStyleDeclaration.prototype.removeProperty = removeProperty;
20700 });
20701 }
20702 function initMediaInteractionObserver(param) {
20703 var mediaInteractionCb = param.mediaInteractionCb, blockClass = param.blockClass, blockSelector = param.blockSelector, mirror2 = param.mirror, sampling = param.sampling, doc = param.doc;
20704 var handler = callbackWrapper(function(type) {
20705 return throttle(callbackWrapper(function(event) {
20706 var target = getEventTarget(event);
20707 if (!target || isBlocked(target, blockClass, blockSelector, true)) {
20708 return;
20709 }
20710 var currentTime = target.currentTime, volume = target.volume, muted = target.muted, playbackRate = target.playbackRate, loop = target.loop;
20711 mediaInteractionCb({
20712 type: type,
20713 id: mirror2.getId(target),
20714 currentTime: currentTime,
20715 volume: volume,
20716 muted: muted,
20717 playbackRate: playbackRate,
20718 loop: loop
20719 });
20720 }), sampling.media || 500);
20721 });
20722 var handlers = [
20723 on("play", handler(MediaInteractions.Play), doc),
20724 on("pause", handler(MediaInteractions.Pause), doc),
20725 on("seeked", handler(MediaInteractions.Seeked), doc),
20726 on("volumechange", handler(MediaInteractions.VolumeChange), doc),
20727 on("ratechange", handler(MediaInteractions.RateChange), doc)
20728 ];
20729 return callbackWrapper(function() {
20730 handlers.forEach(function(h) {
20731 return h();
20732 });
20733 });
20734 }
20735 function initFontObserver(param) {
20736 var fontCb = param.fontCb, doc = param.doc;
20737 var win = doc.defaultView;
20738 if (!win) {
20739 return function() {};
20740 }
20741 var handlers = [];
20742 var fontMap = /* @__PURE__ */ new WeakMap();
20743 var originalFontFace = win.FontFace;
20744 win.FontFace = function FontFace2(family, source, descriptors) {
20745 var fontFace = new originalFontFace(family, source, descriptors);
20746 fontMap.set(fontFace, {
20747 family: family,
20748 buffer: typeof source !== "string",
20749 descriptors: descriptors,
20750 fontSource: typeof source === "string" ? source : JSON.stringify(Array.from(new Uint8Array(source)))
20751 });
20752 return fontFace;
20753 };
20754 var restoreHandler = patch(doc.fonts, "add", function(original) {
20755 return function(fontFace) {
20756 setTimeout(callbackWrapper(function() {
20757 var p = fontMap.get(fontFace);
20758 if (p) {
20759 fontCb(p);
20760 fontMap.delete(fontFace);
20761 }
20762 }), 0);
20763 return original.apply(this, [
20764 fontFace
20765 ]);
20766 };
20767 });
20768 handlers.push(function() {
20769 win.FontFace = originalFontFace;
20770 });
20771 handlers.push(restoreHandler);
20772 return callbackWrapper(function() {
20773 handlers.forEach(function(h) {
20774 return h();
20775 });
20776 });
20777 }
20778 function initSelectionObserver(param) {
20779 var doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, selectionCb = param.selectionCb;
20780 var collapsed = true;
20781 var updateSelection = callbackWrapper(function() {
20782 var selection = doc.getSelection();
20783 if (!selection || collapsed && (selection == null ? void 0 : selection.isCollapsed)) return;
20784 collapsed = selection.isCollapsed || false;
20785 var ranges = [];
20786 var count = selection.rangeCount || 0;
20787 for(var i2 = 0; i2 < count; i2++){
20788 var range = selection.getRangeAt(i2);
20789 var startContainer = range.startContainer, startOffset = range.startOffset, endContainer = range.endContainer, endOffset = range.endOffset;
20790 var blocked = isBlocked(startContainer, blockClass, blockSelector, true) || isBlocked(endContainer, blockClass, blockSelector, true);
20791 if (blocked) continue;
20792 ranges.push({
20793 start: mirror2.getId(startContainer),
20794 startOffset: startOffset,
20795 end: mirror2.getId(endContainer),
20796 endOffset: endOffset
20797 });
20798 }
20799 selectionCb({
20800 ranges: ranges
20801 });
20802 });
20803 updateSelection();
20804 return on("selectionchange", updateSelection);
20805 }
20806 function initCustomElementObserver(param) {
20807 var doc = param.doc, customElementCb = param.customElementCb;
20808 var win = doc.defaultView;
20809 if (!win || !win.customElements) return function() {};
20810 var restoreHandler = patch(win.customElements, "define", function(original) {
20811 return function(name, constructor, options) {
20812 try {
20813 customElementCb({
20814 define: {
20815 name: name
20816 }
20817 });
20818 } catch (e2) {
20819 console.warn("Custom element callback failed for " + name);
20820 }
20821 return original.apply(this, [
20822 name,
20823 constructor,
20824 options
20825 ]);
20826 };
20827 });
20828 return restoreHandler;
20829 }
20830 function mergeHooks(o2, hooks) {
20831 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;
20832 o2.mutationCb = function() {
20833 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20834 p[_key] = arguments[_key];
20835 }
20836 if (hooks.mutation) {
20837 var _hooks;
20838 (_hooks = hooks).mutation.apply(_hooks, [].concat(p));
20839 }
20840 mutationCb.apply(void 0, [].concat(p));
20841 };
20842 o2.mousemoveCb = function() {
20843 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20844 p[_key] = arguments[_key];
20845 }
20846 if (hooks.mousemove) {
20847 var _hooks;
20848 (_hooks = hooks).mousemove.apply(_hooks, [].concat(p));
20849 }
20850 mousemoveCb.apply(void 0, [].concat(p));
20851 };
20852 o2.mouseInteractionCb = function() {
20853 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20854 p[_key] = arguments[_key];
20855 }
20856 if (hooks.mouseInteraction) {
20857 var _hooks;
20858 (_hooks = hooks).mouseInteraction.apply(_hooks, [].concat(p));
20859 }
20860 mouseInteractionCb.apply(void 0, [].concat(p));
20861 };
20862 o2.scrollCb = function() {
20863 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20864 p[_key] = arguments[_key];
20865 }
20866 if (hooks.scroll) {
20867 var _hooks;
20868 (_hooks = hooks).scroll.apply(_hooks, [].concat(p));
20869 }
20870 scrollCb.apply(void 0, [].concat(p));
20871 };
20872 o2.viewportResizeCb = function() {
20873 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20874 p[_key] = arguments[_key];
20875 }
20876 if (hooks.viewportResize) {
20877 var _hooks;
20878 (_hooks = hooks).viewportResize.apply(_hooks, [].concat(p));
20879 }
20880 viewportResizeCb.apply(void 0, [].concat(p));
20881 };
20882 o2.inputCb = function() {
20883 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20884 p[_key] = arguments[_key];
20885 }
20886 if (hooks.input) {
20887 var _hooks;
20888 (_hooks = hooks).input.apply(_hooks, [].concat(p));
20889 }
20890 inputCb.apply(void 0, [].concat(p));
20891 };
20892 o2.mediaInteractionCb = function() {
20893 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20894 p[_key] = arguments[_key];
20895 }
20896 if (hooks.mediaInteaction) {
20897 var _hooks;
20898 (_hooks = hooks).mediaInteaction.apply(_hooks, [].concat(p));
20899 }
20900 mediaInteractionCb.apply(void 0, [].concat(p));
20901 };
20902 o2.styleSheetRuleCb = function() {
20903 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20904 p[_key] = arguments[_key];
20905 }
20906 if (hooks.styleSheetRule) {
20907 var _hooks;
20908 (_hooks = hooks).styleSheetRule.apply(_hooks, [].concat(p));
20909 }
20910 styleSheetRuleCb.apply(void 0, [].concat(p));
20911 };
20912 o2.styleDeclarationCb = function() {
20913 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20914 p[_key] = arguments[_key];
20915 }
20916 if (hooks.styleDeclaration) {
20917 var _hooks;
20918 (_hooks = hooks).styleDeclaration.apply(_hooks, [].concat(p));
20919 }
20920 styleDeclarationCb.apply(void 0, [].concat(p));
20921 };
20922 o2.canvasMutationCb = function() {
20923 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20924 p[_key] = arguments[_key];
20925 }
20926 if (hooks.canvasMutation) {
20927 var _hooks;
20928 (_hooks = hooks).canvasMutation.apply(_hooks, [].concat(p));
20929 }
20930 canvasMutationCb.apply(void 0, [].concat(p));
20931 };
20932 o2.fontCb = function() {
20933 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20934 p[_key] = arguments[_key];
20935 }
20936 if (hooks.font) {
20937 var _hooks;
20938 (_hooks = hooks).font.apply(_hooks, [].concat(p));
20939 }
20940 fontCb.apply(void 0, [].concat(p));
20941 };
20942 o2.selectionCb = function() {
20943 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20944 p[_key] = arguments[_key];
20945 }
20946 if (hooks.selection) {
20947 var _hooks;
20948 (_hooks = hooks).selection.apply(_hooks, [].concat(p));
20949 }
20950 selectionCb.apply(void 0, [].concat(p));
20951 };
20952 o2.customElementCb = function() {
20953 for(var _len = arguments.length, c2 = new Array(_len), _key = 0; _key < _len; _key++){
20954 c2[_key] = arguments[_key];
20955 }
20956 if (hooks.customElement) {
20957 var _hooks;
20958 (_hooks = hooks).customElement.apply(_hooks, [].concat(c2));
20959 }
20960 customElementCb.apply(void 0, [].concat(c2));
20961 };
20962 }
20963 function initObservers(o2, hooks) {
20964 if (hooks === void 0) hooks = {};
20965 var currentWindow = o2.doc.defaultView;
20966 if (!currentWindow) {
20967 return function() {};
20968 }
20969 mergeHooks(o2, hooks);
20970 var mutationObserver;
20971 if (o2.recordDOM) {
20972 mutationObserver = initMutationObserver(o2, o2.doc);
20973 }
20974 var mousemoveHandler = initMoveObserver(o2);
20975 var mouseInteractionHandler = initMouseInteractionObserver(o2);
20976 var scrollHandler = initScrollObserver(o2);
20977 var viewportResizeHandler = initViewportResizeObserver(o2, {
20978 win: currentWindow
20979 });
20980 var inputHandler = initInputObserver(o2);
20981 var mediaInteractionHandler = initMediaInteractionObserver(o2);
20982 var styleSheetObserver = function() {};
20983 var adoptedStyleSheetObserver = function() {};
20984 var styleDeclarationObserver = function() {};
20985 var fontObserver = function() {};
20986 if (o2.recordDOM) {
20987 styleSheetObserver = initStyleSheetObserver(o2, {
20988 win: currentWindow
20989 });
20990 adoptedStyleSheetObserver = initAdoptedStyleSheetObserver(o2, o2.doc);
20991 styleDeclarationObserver = initStyleDeclarationObserver(o2, {
20992 win: currentWindow
20993 });
20994 if (o2.collectFonts) {
20995 fontObserver = initFontObserver(o2);
20996 }
20997 }
20998 var selectionObserver = initSelectionObserver(o2);
20999 var customElementObserver = initCustomElementObserver(o2);
21000 var pluginHandlers = [];
21001 for(var _iterator = _create_for_of_iterator_helper_loose(o2.plugins), _step; !(_step = _iterator()).done;){
21002 var plugin3 = _step.value;
21003 pluginHandlers.push(plugin3.observer(plugin3.callback, currentWindow, plugin3.options));
21004 }
21005 return callbackWrapper(function() {
21006 mutationBuffers.forEach(function(b) {
21007 return b.reset();
21008 });
21009 mutationObserver == null ? void 0 : mutationObserver.disconnect();
21010 mousemoveHandler();
21011 mouseInteractionHandler();
21012 scrollHandler();
21013 viewportResizeHandler();
21014 inputHandler();
21015 mediaInteractionHandler();
21016 styleSheetObserver();
21017 adoptedStyleSheetObserver();
21018 styleDeclarationObserver();
21019 fontObserver();
21020 selectionObserver();
21021 customElementObserver();
21022 pluginHandlers.forEach(function(h) {
21023 return h();
21024 });
21025 });
21026 }
21027 function hasNestedCSSRule(prop) {
21028 return typeof window[prop] !== "undefined";
21029 }
21030 function canMonkeyPatchNestedCSSRule(prop) {
21031 return Boolean(typeof window[prop] !== "undefined" && // Note: Generally, this check _shouldn't_ be necessary
21032 // However, in some scenarios (e.g. jsdom) this can sometimes fail, so we check for it here
21033 window[prop].prototype && "insertRule" in window[prop].prototype && "deleteRule" in window[prop].prototype);
21034 }
21035 var CrossOriginIframeMirror = /*#__PURE__*/ function() {
21036 function CrossOriginIframeMirror(generateIdFn) {
21037 __publicField(this, "iframeIdToRemoteIdMap", /* @__PURE__ */ new WeakMap());
21038 __publicField(this, "iframeRemoteIdToIdMap", /* @__PURE__ */ new WeakMap());
21039 this.generateIdFn = generateIdFn;
21040 }
21041 var _proto = CrossOriginIframeMirror.prototype;
21042 _proto.getId = function getId(iframe, remoteId, idToRemoteMap, remoteToIdMap) {
21043 var idToRemoteIdMap = idToRemoteMap || this.getIdToRemoteIdMap(iframe);
21044 var remoteIdToIdMap = remoteToIdMap || this.getRemoteIdToIdMap(iframe);
21045 var id = idToRemoteIdMap.get(remoteId);
21046 if (!id) {
21047 id = this.generateIdFn();
21048 idToRemoteIdMap.set(remoteId, id);
21049 remoteIdToIdMap.set(id, remoteId);
21050 }
21051 return id;
21052 };
21053 _proto.getIds = function getIds(iframe, remoteId) {
21054 var _this = this;
21055 var idToRemoteIdMap = this.getIdToRemoteIdMap(iframe);
21056 var remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);
21057 return remoteId.map(function(id) {
21058 return _this.getId(iframe, id, idToRemoteIdMap, remoteIdToIdMap);
21059 });
21060 };
21061 _proto.getRemoteId = function getRemoteId(iframe, id, map) {
21062 var remoteIdToIdMap = map || this.getRemoteIdToIdMap(iframe);
21063 if (typeof id !== "number") return id;
21064 var remoteId = remoteIdToIdMap.get(id);
21065 if (!remoteId) return -1;
21066 return remoteId;
21067 };
21068 _proto.getRemoteIds = function getRemoteIds(iframe, ids) {
21069 var _this = this;
21070 var remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);
21071 return ids.map(function(id) {
21072 return _this.getRemoteId(iframe, id, remoteIdToIdMap);
21073 });
21074 };
21075 _proto.reset = function reset(iframe) {
21076 if (!iframe) {
21077 this.iframeIdToRemoteIdMap = /* @__PURE__ */ new WeakMap();
21078 this.iframeRemoteIdToIdMap = /* @__PURE__ */ new WeakMap();
21079 return;
21080 }
21081 this.iframeIdToRemoteIdMap.delete(iframe);
21082 this.iframeRemoteIdToIdMap.delete(iframe);
21083 };
21084 _proto.getIdToRemoteIdMap = function getIdToRemoteIdMap(iframe) {
21085 var idToRemoteIdMap = this.iframeIdToRemoteIdMap.get(iframe);
21086 if (!idToRemoteIdMap) {
21087 idToRemoteIdMap = /* @__PURE__ */ new Map();
21088 this.iframeIdToRemoteIdMap.set(iframe, idToRemoteIdMap);
21089 }
21090 return idToRemoteIdMap;
21091 };
21092 _proto.getRemoteIdToIdMap = function getRemoteIdToIdMap(iframe) {
21093 var remoteIdToIdMap = this.iframeRemoteIdToIdMap.get(iframe);
21094 if (!remoteIdToIdMap) {
21095 remoteIdToIdMap = /* @__PURE__ */ new Map();
21096 this.iframeRemoteIdToIdMap.set(iframe, remoteIdToIdMap);
21097 }
21098 return remoteIdToIdMap;
21099 };
21100 return CrossOriginIframeMirror;
21101 }();
21102 var IframeManager = /*#__PURE__*/ function() {
21103 function IframeManager(options) {
21104 __publicField(this, "iframes", /* @__PURE__ */ new WeakMap());
21105 __publicField(this, "crossOriginIframeMap", /* @__PURE__ */ new WeakMap());
21106 __publicField(this, "crossOriginIframeMirror", new CrossOriginIframeMirror(genId));
21107 __publicField(this, "crossOriginIframeStyleMirror");
21108 __publicField(this, "crossOriginIframeRootIdMap", /* @__PURE__ */ new WeakMap());
21109 __publicField(this, "mirror");
21110 __publicField(this, "mutationCb");
21111 __publicField(this, "wrappedEmit");
21112 __publicField(this, "loadListener");
21113 __publicField(this, "stylesheetManager");
21114 __publicField(this, "recordCrossOriginIframes");
21115 this.mutationCb = options.mutationCb;
21116 this.wrappedEmit = options.wrappedEmit;
21117 this.stylesheetManager = options.stylesheetManager;
21118 this.recordCrossOriginIframes = options.recordCrossOriginIframes;
21119 this.crossOriginIframeStyleMirror = new CrossOriginIframeMirror(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror));
21120 this.mirror = options.mirror;
21121 if (this.recordCrossOriginIframes) {
21122 window.addEventListener("message", this.handleMessage.bind(this));
21123 }
21124 }
21125 var _proto = IframeManager.prototype;
21126 _proto.addIframe = function addIframe(iframeEl) {
21127 this.iframes.set(iframeEl, true);
21128 if (iframeEl.contentWindow) this.crossOriginIframeMap.set(iframeEl.contentWindow, iframeEl);
21129 };
21130 _proto.addLoadListener = function addLoadListener(cb) {
21131 this.loadListener = cb;
21132 };
21133 _proto.attachIframe = function attachIframe(iframeEl, childSn) {
21134 var _a2, _b;
21135 this.mutationCb({
21136 adds: [
21137 {
21138 parentId: this.mirror.getId(iframeEl),
21139 nextId: null,
21140 node: childSn
21141 }
21142 ],
21143 removes: [],
21144 texts: [],
21145 attributes: [],
21146 isAttachIframe: true
21147 });
21148 if (this.recordCrossOriginIframes) (_a2 = iframeEl.contentWindow) == null ? void 0 : _a2.addEventListener("message", this.handleMessage.bind(this));
21149 (_b = this.loadListener) == null ? void 0 : _b.call(this, iframeEl);
21150 if (iframeEl.contentDocument && iframeEl.contentDocument.adoptedStyleSheets && iframeEl.contentDocument.adoptedStyleSheets.length > 0) this.stylesheetManager.adoptStyleSheets(iframeEl.contentDocument.adoptedStyleSheets, this.mirror.getId(iframeEl.contentDocument));
21151 };
21152 _proto.handleMessage = function handleMessage(message) {
21153 var crossOriginMessageEvent = message;
21154 if (crossOriginMessageEvent.data.type !== "rrweb" || // To filter out the rrweb messages which are forwarded by some sites.
21155 crossOriginMessageEvent.origin !== crossOriginMessageEvent.data.origin) return;
21156 var iframeSourceWindow = message.source;
21157 if (!iframeSourceWindow) return;
21158 var iframeEl = this.crossOriginIframeMap.get(message.source);
21159 if (!iframeEl) return;
21160 var transformedEvent = this.transformCrossOriginEvent(iframeEl, crossOriginMessageEvent.data.event);
21161 if (transformedEvent) this.wrappedEmit(transformedEvent, crossOriginMessageEvent.data.isCheckout);
21162 };
21163 _proto.transformCrossOriginEvent = function transformCrossOriginEvent(iframeEl, e2) {
21164 var _this = this;
21165 var _a2;
21166 switch(e2.type){
21167 case EventType.FullSnapshot:
21168 {
21169 this.crossOriginIframeMirror.reset(iframeEl);
21170 this.crossOriginIframeStyleMirror.reset(iframeEl);
21171 this.replaceIdOnNode(e2.data.node, iframeEl);
21172 var rootId = e2.data.node.id;
21173 this.crossOriginIframeRootIdMap.set(iframeEl, rootId);
21174 this.patchRootIdOnNode(e2.data.node, rootId);
21175 return {
21176 timestamp: e2.timestamp,
21177 type: EventType.IncrementalSnapshot,
21178 data: {
21179 source: IncrementalSource.Mutation,
21180 adds: [
21181 {
21182 parentId: this.mirror.getId(iframeEl),
21183 nextId: null,
21184 node: e2.data.node
21185 }
21186 ],
21187 removes: [],
21188 texts: [],
21189 attributes: [],
21190 isAttachIframe: true
21191 }
21192 };
21193 }
21194 case EventType.Meta:
21195 case EventType.Load:
21196 case EventType.DomContentLoaded:
21197 {
21198 return false;
21199 }
21200 case EventType.Plugin:
21201 {
21202 return e2;
21203 }
21204 case EventType.Custom:
21205 {
21206 this.replaceIds(e2.data.payload, iframeEl, [
21207 "id",
21208 "parentId",
21209 "previousId",
21210 "nextId"
21211 ]);
21212 return e2;
21213 }
21214 case EventType.IncrementalSnapshot:
21215 {
21216 switch(e2.data.source){
21217 case IncrementalSource.Mutation:
21218 {
21219 e2.data.adds.forEach(function(n2) {
21220 _this.replaceIds(n2, iframeEl, [
21221 "parentId",
21222 "nextId",
21223 "previousId"
21224 ]);
21225 _this.replaceIdOnNode(n2.node, iframeEl);
21226 var rootId = _this.crossOriginIframeRootIdMap.get(iframeEl);
21227 rootId && _this.patchRootIdOnNode(n2.node, rootId);
21228 });
21229 e2.data.removes.forEach(function(n2) {
21230 _this.replaceIds(n2, iframeEl, [
21231 "parentId",
21232 "id"
21233 ]);
21234 });
21235 e2.data.attributes.forEach(function(n2) {
21236 _this.replaceIds(n2, iframeEl, [
21237 "id"
21238 ]);
21239 });
21240 e2.data.texts.forEach(function(n2) {
21241 _this.replaceIds(n2, iframeEl, [
21242 "id"
21243 ]);
21244 });
21245 return e2;
21246 }
21247 case IncrementalSource.Drag:
21248 case IncrementalSource.TouchMove:
21249 case IncrementalSource.MouseMove:
21250 {
21251 e2.data.positions.forEach(function(p) {
21252 _this.replaceIds(p, iframeEl, [
21253 "id"
21254 ]);
21255 });
21256 return e2;
21257 }
21258 case IncrementalSource.ViewportResize:
21259 {
21260 return false;
21261 }
21262 case IncrementalSource.MediaInteraction:
21263 case IncrementalSource.MouseInteraction:
21264 case IncrementalSource.Scroll:
21265 case IncrementalSource.CanvasMutation:
21266 case IncrementalSource.Input:
21267 {
21268 this.replaceIds(e2.data, iframeEl, [
21269 "id"
21270 ]);
21271 return e2;
21272 }
21273 case IncrementalSource.StyleSheetRule:
21274 case IncrementalSource.StyleDeclaration:
21275 {
21276 this.replaceIds(e2.data, iframeEl, [
21277 "id"
21278 ]);
21279 this.replaceStyleIds(e2.data, iframeEl, [
21280 "styleId"
21281 ]);
21282 return e2;
21283 }
21284 case IncrementalSource.Font:
21285 {
21286 return e2;
21287 }
21288 case IncrementalSource.Selection:
21289 {
21290 e2.data.ranges.forEach(function(range) {
21291 _this.replaceIds(range, iframeEl, [
21292 "start",
21293 "end"
21294 ]);
21295 });
21296 return e2;
21297 }
21298 case IncrementalSource.AdoptedStyleSheet:
21299 {
21300 this.replaceIds(e2.data, iframeEl, [
21301 "id"
21302 ]);
21303 this.replaceStyleIds(e2.data, iframeEl, [
21304 "styleIds"
21305 ]);
21306 (_a2 = e2.data.styles) == null ? void 0 : _a2.forEach(function(style) {
21307 _this.replaceStyleIds(style, iframeEl, [
21308 "styleId"
21309 ]);
21310 });
21311 return e2;
21312 }
21313 }
21314 }
21315 }
21316 return false;
21317 };
21318 _proto.replace = function replace(iframeMirror, obj, iframeEl, keys) {
21319 for(var _iterator = _create_for_of_iterator_helper_loose(keys), _step; !(_step = _iterator()).done;){
21320 var key = _step.value;
21321 if (!Array.isArray(obj[key]) && typeof obj[key] !== "number") continue;
21322 if (Array.isArray(obj[key])) {
21323 obj[key] = iframeMirror.getIds(iframeEl, obj[key]);
21324 } else {
21325 obj[key] = iframeMirror.getId(iframeEl, obj[key]);
21326 }
21327 }
21328 return obj;
21329 };
21330 _proto.replaceIds = function replaceIds(obj, iframeEl, keys) {
21331 return this.replace(this.crossOriginIframeMirror, obj, iframeEl, keys);
21332 };
21333 _proto.replaceStyleIds = function replaceStyleIds(obj, iframeEl, keys) {
21334 return this.replace(this.crossOriginIframeStyleMirror, obj, iframeEl, keys);
21335 };
21336 _proto.replaceIdOnNode = function replaceIdOnNode(node2, iframeEl) {
21337 var _this = this;
21338 this.replaceIds(node2, iframeEl, [
21339 "id",
21340 "rootId"
21341 ]);
21342 if ("childNodes" in node2) {
21343 node2.childNodes.forEach(function(child) {
21344 _this.replaceIdOnNode(child, iframeEl);
21345 });
21346 }
21347 };
21348 _proto.patchRootIdOnNode = function patchRootIdOnNode(node2, rootId) {
21349 var _this = this;
21350 if (node2.type !== NodeType.Document && !node2.rootId) node2.rootId = rootId;
21351 if ("childNodes" in node2) {
21352 node2.childNodes.forEach(function(child) {
21353 _this.patchRootIdOnNode(child, rootId);
21354 });
21355 }
21356 };
21357 return IframeManager;
21358 }();
21359 var ShadowDomManager = /*#__PURE__*/ function() {
21360 function ShadowDomManager(options) {
21361 __publicField(this, "shadowDoms", /* @__PURE__ */ new WeakSet());
21362 __publicField(this, "mutationCb");
21363 __publicField(this, "scrollCb");
21364 __publicField(this, "bypassOptions");
21365 __publicField(this, "mirror");
21366 __publicField(this, "restoreHandlers", []);
21367 this.mutationCb = options.mutationCb;
21368 this.scrollCb = options.scrollCb;
21369 this.bypassOptions = options.bypassOptions;
21370 this.mirror = options.mirror;
21371 this.init();
21372 }
21373 var _proto = ShadowDomManager.prototype;
21374 _proto.init = function init() {
21375 this.reset();
21376 this.patchAttachShadow(Element, document);
21377 };
21378 _proto.addShadowRoot = function addShadowRoot(shadowRoot2, doc) {
21379 var _this = this;
21380 if (!isNativeShadowDom(shadowRoot2)) return;
21381 if (this.shadowDoms.has(shadowRoot2)) return;
21382 this.shadowDoms.add(shadowRoot2);
21383 var observer = initMutationObserver(_extends({}, this.bypassOptions, {
21384 doc: doc,
21385 mutationCb: this.mutationCb,
21386 mirror: this.mirror,
21387 shadowDomManager: this
21388 }), shadowRoot2);
21389 this.restoreHandlers.push(function() {
21390 return observer.disconnect();
21391 });
21392 this.restoreHandlers.push(initScrollObserver(_extends({}, this.bypassOptions, {
21393 scrollCb: this.scrollCb,
21394 // https://gist.github.com/praveenpuglia/0832da687ed5a5d7a0907046c9ef1813
21395 // scroll is not allowed to pass the boundary, so we need to listen the shadow document
21396 doc: shadowRoot2,
21397 mirror: this.mirror
21398 })));
21399 setTimeout(function() {
21400 if (shadowRoot2.adoptedStyleSheets && shadowRoot2.adoptedStyleSheets.length > 0) _this.bypassOptions.stylesheetManager.adoptStyleSheets(shadowRoot2.adoptedStyleSheets, _this.mirror.getId(index.host(shadowRoot2)));
21401 _this.restoreHandlers.push(initAdoptedStyleSheetObserver({
21402 mirror: _this.mirror,
21403 stylesheetManager: _this.bypassOptions.stylesheetManager
21404 }, shadowRoot2));
21405 }, 0);
21406 };
21407 /**
21408 * Monkey patch 'attachShadow' of an IFrameElement to observe newly added shadow doms.
21409 */ _proto.observeAttachShadow = function observeAttachShadow(iframeElement) {
21410 if (!iframeElement.contentWindow || !iframeElement.contentDocument) return;
21411 this.patchAttachShadow(iframeElement.contentWindow.Element, iframeElement.contentDocument);
21412 };
21413 /**
21414 * Patch 'attachShadow' to observe newly added shadow doms.
21415 */ _proto.patchAttachShadow = function patchAttachShadow(element, doc) {
21416 var manager = this;
21417 this.restoreHandlers.push(patch(element.prototype, "attachShadow", function(original) {
21418 return function(option) {
21419 var sRoot = original.call(this, option);
21420 var shadowRootEl = index.shadowRoot(this);
21421 if (shadowRootEl && inDom(this)) manager.addShadowRoot(shadowRootEl, doc);
21422 return sRoot;
21423 };
21424 }));
21425 };
21426 _proto.reset = function reset() {
21427 this.restoreHandlers.forEach(function(handler) {
21428 try {
21429 handler();
21430 } catch (e2) {}
21431 });
21432 this.restoreHandlers = [];
21433 this.shadowDoms = /* @__PURE__ */ new WeakSet();
21434 };
21435 return ShadowDomManager;
21436 }();
21437 var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
21438 var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
21439 for(var i$1 = 0; i$1 < chars.length; i$1++){
21440 lookup[chars.charCodeAt(i$1)] = i$1;
21441 }
21442 var encode = function encode(arraybuffer) {
21443 var bytes = new Uint8Array(arraybuffer), i2, len = bytes.length, base64 = "";
21444 for(i2 = 0; i2 < len; i2 += 3){
21445 base64 += chars[bytes[i2] >> 2];
21446 base64 += chars[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4];
21447 base64 += chars[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6];
21448 base64 += chars[bytes[i2 + 2] & 63];
21449 }
21450 if (len % 3 === 2) {
21451 base64 = base64.substring(0, base64.length - 1) + "=";
21452 } else if (len % 3 === 1) {
21453 base64 = base64.substring(0, base64.length - 2) + "==";
21454 }
21455 return base64;
21456 };
21457 var canvasVarMap = /* @__PURE__ */ new Map();
21458 function variableListFor$1(ctx, ctor) {
21459 var contextMap = canvasVarMap.get(ctx);
21460 if (!contextMap) {
21461 contextMap = /* @__PURE__ */ new Map();
21462 canvasVarMap.set(ctx, contextMap);
21463 }
21464 if (!contextMap.has(ctor)) {
21465 contextMap.set(ctor, []);
21466 }
21467 return contextMap.get(ctor);
21468 }
21469 var saveWebGLVar = function(value, win, ctx) {
21470 if (!value || !(isInstanceOfWebGLObject(value, win) || (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object")) return;
21471 var name = value.constructor.name;
21472 var list2 = variableListFor$1(ctx, name);
21473 var index2 = list2.indexOf(value);
21474 if (index2 === -1) {
21475 index2 = list2.length;
21476 list2.push(value);
21477 }
21478 return index2;
21479 };
21480 function serializeArg(value, win, ctx) {
21481 if (_instanceof(value, Array)) {
21482 return value.map(function(arg) {
21483 return serializeArg(arg, win, ctx);
21484 });
21485 } else if (value === null) {
21486 return value;
21487 } 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)) {
21488 var name = value.constructor.name;
21489 return {
21490 rr_type: name,
21491 args: [
21492 Object.values(value)
21493 ]
21494 };
21495 } else if (// SharedArrayBuffer disabled on most browsers due to spectre.
21496 // More info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/SharedArrayBuffer
21497 // value instanceof SharedArrayBuffer ||
21498 _instanceof(value, ArrayBuffer)) {
21499 var name1 = value.constructor.name;
21500 var base64 = encode(value);
21501 return {
21502 rr_type: name1,
21503 base64: base64
21504 };
21505 } else if (_instanceof(value, DataView)) {
21506 var name2 = value.constructor.name;
21507 return {
21508 rr_type: name2,
21509 args: [
21510 serializeArg(value.buffer, win, ctx),
21511 value.byteOffset,
21512 value.byteLength
21513 ]
21514 };
21515 } else if (_instanceof(value, HTMLImageElement)) {
21516 var name3 = value.constructor.name;
21517 var src = value.src;
21518 return {
21519 rr_type: name3,
21520 src: src
21521 };
21522 } else if (_instanceof(value, HTMLCanvasElement)) {
21523 var name4 = "HTMLImageElement";
21524 var src1 = value.toDataURL();
21525 return {
21526 rr_type: name4,
21527 src: src1
21528 };
21529 } else if (_instanceof(value, ImageData)) {
21530 var name5 = value.constructor.name;
21531 return {
21532 rr_type: name5,
21533 args: [
21534 serializeArg(value.data, win, ctx),
21535 value.width,
21536 value.height
21537 ]
21538 };
21539 } else if (isInstanceOfWebGLObject(value, win) || (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object") {
21540 var name6 = value.constructor.name;
21541 var index2 = saveWebGLVar(value, win, ctx);
21542 return {
21543 rr_type: name6,
21544 index: index2
21545 };
21546 }
21547 return value;
21548 }
21549 var serializeArgs = function(args, win, ctx) {
21550 return args.map(function(arg) {
21551 return serializeArg(arg, win, ctx);
21552 });
21553 };
21554 var isInstanceOfWebGLObject = function(value, win) {
21555 var webGLConstructorNames = [
21556 "WebGLActiveInfo",
21557 "WebGLBuffer",
21558 "WebGLFramebuffer",
21559 "WebGLProgram",
21560 "WebGLRenderbuffer",
21561 "WebGLShader",
21562 "WebGLShaderPrecisionFormat",
21563 "WebGLTexture",
21564 "WebGLUniformLocation",
21565 "WebGLVertexArrayObject",
21566 // In old Chrome versions, value won't be an instanceof WebGLVertexArrayObject.
21567 "WebGLVertexArrayObjectOES"
21568 ];
21569 var supportedWebGLConstructorNames = webGLConstructorNames.filter(function(name) {
21570 return typeof win[name] === "function";
21571 });
21572 return Boolean(supportedWebGLConstructorNames.find(function(name) {
21573 return _instanceof(value, win[name]);
21574 }));
21575 };
21576 function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector) {
21577 var _loop = function() {
21578 var prop = _step.value;
21579 try {
21580 if (typeof win.CanvasRenderingContext2D.prototype[prop] !== "function") {
21581 return "continue";
21582 }
21583 var restoreHandler = patch(win.CanvasRenderingContext2D.prototype, prop, function(original) {
21584 return function() {
21585 var _this = this;
21586 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
21587 args[_key] = arguments[_key];
21588 }
21589 if (!isBlocked(this.canvas, blockClass, blockSelector, true)) {
21590 setTimeout(function() {
21591 var recordArgs = serializeArgs(args, win, _this);
21592 cb(_this.canvas, {
21593 type: CanvasContext["2D"],
21594 property: prop,
21595 args: recordArgs
21596 });
21597 }, 0);
21598 }
21599 return original.apply(this, args);
21600 };
21601 });
21602 handlers.push(restoreHandler);
21603 } catch (e) {
21604 var hookHandler = hookSetter(win.CanvasRenderingContext2D.prototype, prop, {
21605 set: function set(v2) {
21606 cb(this.canvas, {
21607 type: CanvasContext["2D"],
21608 property: prop,
21609 args: [
21610 v2
21611 ],
21612 setter: true
21613 });
21614 }
21615 });
21616 handlers.push(hookHandler);
21617 }
21618 };
21619 var handlers = [];
21620 var props2D = Object.getOwnPropertyNames(win.CanvasRenderingContext2D.prototype);
21621 for(var _iterator = _create_for_of_iterator_helper_loose(props2D), _step; !(_step = _iterator()).done;)_loop();
21622 return function() {
21623 handlers.forEach(function(h) {
21624 return h();
21625 });
21626 };
21627 }
21628 function getNormalizedContextName(contextType) {
21629 return contextType === "experimental-webgl" ? "webgl" : contextType;
21630 }
21631 function initCanvasContextObserver(win, blockClass, blockSelector, setPreserveDrawingBufferToTrue) {
21632 var handlers = [];
21633 try {
21634 var restoreHandler = patch(win.HTMLCanvasElement.prototype, "getContext", function(original) {
21635 return function(contextType) {
21636 for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
21637 args[_key - 1] = arguments[_key];
21638 }
21639 if (!isBlocked(this, blockClass, blockSelector, true)) {
21640 var ctxName = getNormalizedContextName(contextType);
21641 if (!("__context" in this)) this.__context = ctxName;
21642 if (setPreserveDrawingBufferToTrue && [
21643 "webgl",
21644 "webgl2"
21645 ].includes(ctxName)) {
21646 if (args[0] && _type_of(args[0]) === "object") {
21647 var contextAttributes = args[0];
21648 if (!contextAttributes.preserveDrawingBuffer) {
21649 contextAttributes.preserveDrawingBuffer = true;
21650 }
21651 } else {
21652 args.splice(0, 1, {
21653 preserveDrawingBuffer: true
21654 });
21655 }
21656 }
21657 }
21658 return original.apply(this, [].concat([
21659 contextType
21660 ], args));
21661 };
21662 });
21663 handlers.push(restoreHandler);
21664 } catch (e) {
21665 console.error("failed to patch HTMLCanvasElement.prototype.getContext");
21666 }
21667 return function() {
21668 handlers.forEach(function(h) {
21669 return h();
21670 });
21671 };
21672 }
21673 function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
21674 var _loop = function() {
21675 var prop = _step.value;
21676 if (//prop.startsWith('get') || // e.g. getProgramParameter, but too risky
21677 [
21678 "isContextLost",
21679 "canvas",
21680 "drawingBufferWidth",
21681 "drawingBufferHeight"
21682 ].includes(prop)) {
21683 return "continue";
21684 }
21685 try {
21686 if (typeof prototype[prop] !== "function") {
21687 return "continue";
21688 }
21689 var restoreHandler = patch(prototype, prop, function(original) {
21690 return function() {
21691 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
21692 args[_key] = arguments[_key];
21693 }
21694 var result2 = original.apply(this, args);
21695 saveWebGLVar(result2, win, this);
21696 if ("tagName" in this.canvas && !isBlocked(this.canvas, blockClass, blockSelector, true)) {
21697 var recordArgs = serializeArgs(args, win, this);
21698 var mutation = {
21699 type: type,
21700 property: prop,
21701 args: recordArgs
21702 };
21703 cb(this.canvas, mutation);
21704 }
21705 return result2;
21706 };
21707 });
21708 handlers.push(restoreHandler);
21709 } catch (e) {
21710 var hookHandler = hookSetter(prototype, prop, {
21711 set: function set(v2) {
21712 cb(this.canvas, {
21713 type: type,
21714 property: prop,
21715 args: [
21716 v2
21717 ],
21718 setter: true
21719 });
21720 }
21721 });
21722 handlers.push(hookHandler);
21723 }
21724 };
21725 var handlers = [];
21726 var props = Object.getOwnPropertyNames(prototype);
21727 for(var _iterator = _create_for_of_iterator_helper_loose(props), _step; !(_step = _iterator()).done;)_loop();
21728 return handlers;
21729 }
21730 function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
21731 var _handlers;
21732 var handlers = [];
21733 (_handlers = handlers).push.apply(_handlers, [].concat(patchGLPrototype(win.WebGLRenderingContext.prototype, CanvasContext.WebGL, cb, blockClass, blockSelector, win)));
21734 if (typeof win.WebGL2RenderingContext !== "undefined") {
21735 var _handlers1;
21736 (_handlers1 = handlers).push.apply(_handlers1, [].concat(patchGLPrototype(win.WebGL2RenderingContext.prototype, CanvasContext.WebGL2, cb, blockClass, blockSelector, win)));
21737 }
21738 return function() {
21739 handlers.forEach(function(h) {
21740 return h();
21741 });
21742 };
21743 }
21744 var encodedJs = "KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=";
21745 var decodeBase64 = function(base64) {
21746 return Uint8Array.from(atob(base64), function(c2) {
21747 return c2.charCodeAt(0);
21748 });
21749 };
21750 var blob = typeof window !== "undefined" && window.Blob && new Blob([
21751 decodeBase64(encodedJs)
21752 ], {
21753 type: "text/javascript;charset=utf-8"
21754 });
21755 function WorkerWrapper(options) {
21756 var objURL;
21757 try {
21758 objURL = blob && (window.URL || window.webkitURL).createObjectURL(blob);
21759 if (!objURL) throw "";
21760 var worker = new Worker(objURL, {
21761 name: options == null ? void 0 : options.name
21762 });
21763 worker.addEventListener("error", function() {
21764 (window.URL || window.webkitURL).revokeObjectURL(objURL);
21765 });
21766 return worker;
21767 } catch (e2) {
21768 return new Worker("data:text/javascript;base64," + encodedJs, {
21769 name: options == null ? void 0 : options.name
21770 });
21771 } finally{
21772 objURL && (window.URL || window.webkitURL).revokeObjectURL(objURL);
21773 }
21774 }
21775 var CanvasManager = /*#__PURE__*/ function() {
21776 function CanvasManager(options) {
21777 var _this = this;
21778 __publicField(this, "pendingCanvasMutations", /* @__PURE__ */ new Map());
21779 __publicField(this, "rafStamps", {
21780 latestId: 0,
21781 invokeId: null
21782 });
21783 __publicField(this, "mirror");
21784 __publicField(this, "mutationCb");
21785 __publicField(this, "resetObservers");
21786 __publicField(this, "frozen", false);
21787 __publicField(this, "locked", false);
21788 __publicField(this, "processMutation", function(target, mutation) {
21789 var newFrame = _this.rafStamps.invokeId && _this.rafStamps.latestId !== _this.rafStamps.invokeId;
21790 if (newFrame || !_this.rafStamps.invokeId) _this.rafStamps.invokeId = _this.rafStamps.latestId;
21791 if (!_this.pendingCanvasMutations.has(target)) {
21792 _this.pendingCanvasMutations.set(target, []);
21793 }
21794 _this.pendingCanvasMutations.get(target).push(mutation);
21795 });
21796 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;
21797 this.mutationCb = options.mutationCb;
21798 this.mirror = options.mirror;
21799 if (recordCanvas && sampling === "all") this.initCanvasMutationObserver(win, blockClass, blockSelector);
21800 if (recordCanvas && typeof sampling === "number") this.initCanvasFPSObserver(sampling, win, blockClass, blockSelector, {
21801 dataURLOptions: dataURLOptions
21802 });
21803 }
21804 var _proto = CanvasManager.prototype;
21805 _proto.reset = function reset() {
21806 this.pendingCanvasMutations.clear();
21807 this.resetObservers && this.resetObservers();
21808 };
21809 _proto.freeze = function freeze() {
21810 this.frozen = true;
21811 };
21812 _proto.unfreeze = function unfreeze() {
21813 this.frozen = false;
21814 };
21815 _proto.lock = function lock() {
21816 this.locked = true;
21817 };
21818 _proto.unlock = function unlock() {
21819 this.locked = false;
21820 };
21821 _proto.initCanvasFPSObserver = function initCanvasFPSObserver(fps, win, blockClass, blockSelector, options) {
21822 var _this = this;
21823 var canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, true);
21824 var snapshotInProgressMap = /* @__PURE__ */ new Map();
21825 var worker = new WorkerWrapper();
21826 worker.onmessage = function(e2) {
21827 var id = e2.data.id;
21828 snapshotInProgressMap.set(id, false);
21829 if (!("base64" in e2.data)) return;
21830 var _e2_data = e2.data, base64 = _e2_data.base64, type = _e2_data.type, width = _e2_data.width, height = _e2_data.height;
21831 _this.mutationCb({
21832 id: id,
21833 type: CanvasContext["2D"],
21834 commands: [
21835 {
21836 property: "clearRect",
21837 // wipe canvas
21838 args: [
21839 0,
21840 0,
21841 width,
21842 height
21843 ]
21844 },
21845 {
21846 property: "drawImage",
21847 // draws (semi-transparent) image
21848 args: [
21849 {
21850 rr_type: "ImageBitmap",
21851 args: [
21852 {
21853 rr_type: "Blob",
21854 data: [
21855 {
21856 rr_type: "ArrayBuffer",
21857 base64: base64
21858 }
21859 ],
21860 type: type
21861 }
21862 ]
21863 },
21864 0,
21865 0
21866 ]
21867 }
21868 ]
21869 });
21870 };
21871 var timeBetweenSnapshots = 1e3 / fps;
21872 var lastSnapshotTime = 0;
21873 var rafId;
21874 var getCanvas = function() {
21875 var matchedCanvas = [];
21876 win.document.querySelectorAll("canvas").forEach(function(canvas) {
21877 if (!isBlocked(canvas, blockClass, blockSelector, true)) {
21878 matchedCanvas.push(canvas);
21879 }
21880 });
21881 return matchedCanvas;
21882 };
21883 var takeCanvasSnapshots = function(timestamp) {
21884 if (lastSnapshotTime && timestamp - lastSnapshotTime < timeBetweenSnapshots) {
21885 rafId = requestAnimationFrame(takeCanvasSnapshots);
21886 return;
21887 }
21888 lastSnapshotTime = timestamp;
21889 var _this1 = _this;
21890 getCanvas().forEach(/*#__PURE__*/ _async_to_generator(function(canvas) {
21891 var _a2, id, context, bitmap;
21892 return _ts_generator(this, function(_state) {
21893 switch(_state.label){
21894 case 0:
21895 id = _this1.mirror.getId(canvas);
21896 if (snapshotInProgressMap.get(id)) return [
21897 2
21898 ];
21899 if (canvas.width === 0 || canvas.height === 0) return [
21900 2
21901 ];
21902 snapshotInProgressMap.set(id, true);
21903 if ([
21904 "webgl",
21905 "webgl2"
21906 ].includes(canvas.__context)) {
21907 context = canvas.getContext(canvas.__context);
21908 if (((_a2 = context == null ? void 0 : context.getContextAttributes()) == null ? void 0 : _a2.preserveDrawingBuffer) === false) {
21909 context.clear(context.COLOR_BUFFER_BIT);
21910 }
21911 }
21912 return [
21913 4,
21914 createImageBitmap(canvas)
21915 ];
21916 case 1:
21917 bitmap = _state.sent();
21918 worker.postMessage({
21919 id: id,
21920 bitmap: bitmap,
21921 width: canvas.width,
21922 height: canvas.height,
21923 dataURLOptions: options.dataURLOptions
21924 }, [
21925 bitmap
21926 ]);
21927 return [
21928 2
21929 ];
21930 }
21931 });
21932 }));
21933 rafId = requestAnimationFrame(takeCanvasSnapshots);
21934 };
21935 rafId = requestAnimationFrame(takeCanvasSnapshots);
21936 this.resetObservers = function() {
21937 canvasContextReset();
21938 cancelAnimationFrame(rafId);
21939 };
21940 };
21941 _proto.initCanvasMutationObserver = function initCanvasMutationObserver(win, blockClass, blockSelector) {
21942 this.startRAFTimestamping();
21943 this.startPendingCanvasMutationFlusher();
21944 var canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, false);
21945 var canvas2DReset = initCanvas2DMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector);
21946 var canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector);
21947 this.resetObservers = function() {
21948 canvasContextReset();
21949 canvas2DReset();
21950 canvasWebGL1and2Reset();
21951 };
21952 };
21953 _proto.startPendingCanvasMutationFlusher = function startPendingCanvasMutationFlusher() {
21954 var _this = this;
21955 requestAnimationFrame(function() {
21956 return _this.flushPendingCanvasMutations();
21957 });
21958 };
21959 _proto.startRAFTimestamping = function startRAFTimestamping() {
21960 var _this = this;
21961 var setLatestRAFTimestamp = function(timestamp) {
21962 _this.rafStamps.latestId = timestamp;
21963 requestAnimationFrame(setLatestRAFTimestamp);
21964 };
21965 requestAnimationFrame(setLatestRAFTimestamp);
21966 };
21967 _proto.flushPendingCanvasMutations = function flushPendingCanvasMutations() {
21968 var _this = this;
21969 this.pendingCanvasMutations.forEach(function(_values, canvas) {
21970 var id = _this.mirror.getId(canvas);
21971 _this.flushPendingCanvasMutationFor(canvas, id);
21972 });
21973 requestAnimationFrame(function() {
21974 return _this.flushPendingCanvasMutations();
21975 });
21976 };
21977 _proto.flushPendingCanvasMutationFor = function flushPendingCanvasMutationFor(canvas, id) {
21978 if (this.frozen || this.locked) {
21979 return;
21980 }
21981 var valuesWithType = this.pendingCanvasMutations.get(canvas);
21982 if (!valuesWithType || id === -1) return;
21983 var values = valuesWithType.map(function(value) {
21984 value.type; var rest = _object_without_properties_loose(value, [
21985 "type"
21986 ]);
21987 return rest;
21988 });
21989 var type = valuesWithType[0].type;
21990 this.mutationCb({
21991 id: id,
21992 type: type,
21993 commands: values
21994 });
21995 this.pendingCanvasMutations.delete(canvas);
21996 };
21997 return CanvasManager;
21998 }();
21999 var StylesheetManager = /*#__PURE__*/ function() {
22000 function StylesheetManager(options) {
22001 __publicField(this, "trackedLinkElements", /* @__PURE__ */ new WeakSet());
22002 __publicField(this, "mutationCb");
22003 __publicField(this, "adoptedStyleSheetCb");
22004 __publicField(this, "styleMirror", new StyleSheetMirror());
22005 this.mutationCb = options.mutationCb;
22006 this.adoptedStyleSheetCb = options.adoptedStyleSheetCb;
22007 }
22008 var _proto = StylesheetManager.prototype;
22009 _proto.attachLinkElement = function attachLinkElement(linkEl, childSn) {
22010 if ("_cssText" in childSn.attributes) this.mutationCb({
22011 adds: [],
22012 removes: [],
22013 texts: [],
22014 attributes: [
22015 {
22016 id: childSn.id,
22017 attributes: childSn.attributes
22018 }
22019 ]
22020 });
22021 this.trackLinkElement(linkEl);
22022 };
22023 _proto.trackLinkElement = function trackLinkElement(linkEl) {
22024 if (this.trackedLinkElements.has(linkEl)) return;
22025 this.trackedLinkElements.add(linkEl);
22026 this.trackStylesheetInLinkElement(linkEl);
22027 };
22028 _proto.adoptStyleSheets = function adoptStyleSheets(sheets, hostId) {
22029 var _this, _loop = function() {
22030 var sheet = _step.value;
22031 var styleId = void 0;
22032 if (!_this.styleMirror.has(sheet)) {
22033 styleId = _this.styleMirror.add(sheet);
22034 styles.push({
22035 styleId: styleId,
22036 rules: Array.from(sheet.rules || CSSRule, function(r2, index2) {
22037 return {
22038 rule: stringifyRule(r2, sheet.href),
22039 index: index2
22040 };
22041 })
22042 });
22043 } else styleId = _this.styleMirror.getId(sheet);
22044 adoptedStyleSheetData.styleIds.push(styleId);
22045 };
22046 if (sheets.length === 0) return;
22047 var adoptedStyleSheetData = {
22048 id: hostId,
22049 styleIds: []
22050 };
22051 var styles = [];
22052 for(var _iterator = _create_for_of_iterator_helper_loose(sheets), _step; !(_step = _iterator()).done;)_this = this, _loop();
22053 if (styles.length > 0) adoptedStyleSheetData.styles = styles;
22054 this.adoptedStyleSheetCb(adoptedStyleSheetData);
22055 };
22056 _proto.reset = function reset() {
22057 this.styleMirror.reset();
22058 this.trackedLinkElements = /* @__PURE__ */ new WeakSet();
22059 };
22060 // TODO: take snapshot on stylesheet reload by applying event listener
22061 _proto.trackStylesheetInLinkElement = function trackStylesheetInLinkElement(_linkEl) {};
22062 return StylesheetManager;
22063 }();
22064 var ProcessedNodeManager = /*#__PURE__*/ function() {
22065 function ProcessedNodeManager() {
22066 __publicField(this, "nodeMap", /* @__PURE__ */ new WeakMap());
22067 __publicField(this, "active", false);
22068 }
22069 var _proto = ProcessedNodeManager.prototype;
22070 _proto.inOtherBuffer = function inOtherBuffer(node2, thisBuffer) {
22071 var buffers = this.nodeMap.get(node2);
22072 return buffers && Array.from(buffers).some(function(buffer) {
22073 return buffer !== thisBuffer;
22074 });
22075 };
22076 _proto.add = function add(node2, buffer) {
22077 var _this = this;
22078 if (!this.active) {
22079 this.active = true;
22080 requestAnimationFrame(function() {
22081 _this.nodeMap = /* @__PURE__ */ new WeakMap();
22082 _this.active = false;
22083 });
22084 }
22085 this.nodeMap.set(node2, (this.nodeMap.get(node2) || /* @__PURE__ */ new Set()).add(buffer));
22086 };
22087 _proto.destroy = function destroy() {};
22088 return ProcessedNodeManager;
22089 }();
22090 var wrappedEmit;
22091 var takeFullSnapshot$1;
22092 var canvasManager;
22093 var recording = false;
22094 try {
22095 if (Array.from([
22096 1
22097 ], function(x2) {
22098 return x2 * 2;
22099 })[0] !== 2) {
22100 var cleanFrame = document.createElement("iframe");
22101 document.body.appendChild(cleanFrame);
22102 Array.from = ((_a = cleanFrame.contentWindow) == null ? void 0 : _a.Array.from) || Array.from;
22103 document.body.removeChild(cleanFrame);
22104 }
22105 } catch (err) {
22106 console.debug("Unable to override Array.from", err);
22107 }
22108 var mirror = createMirror$2();
22109 function record(options) {
22110 if (options === void 0) options = {};
22111 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() {
22112 return false;
22113 } : _options_keepIframeSrcFn, _options_ignoreCSSAttributes = options.ignoreCSSAttributes, ignoreCSSAttributes = _options_ignoreCSSAttributes === void 0 ? /* @__PURE__ */ new Set([]) : _options_ignoreCSSAttributes, errorHandler2 = options.errorHandler;
22114 registerErrorHandler(errorHandler2);
22115 var inEmittingFrame = recordCrossOriginIframes ? window.parent === window : true;
22116 var passEmitsToParent = false;
22117 if (!inEmittingFrame) {
22118 try {
22119 if (window.parent.document) {
22120 passEmitsToParent = false;
22121 }
22122 } catch (e2) {
22123 passEmitsToParent = true;
22124 }
22125 }
22126 if (inEmittingFrame && !emit) {
22127 throw new Error("emit function is required");
22128 }
22129 if (!inEmittingFrame && !passEmitsToParent) {
22130 return function() {};
22131 }
22132 if (mousemoveWait !== void 0 && sampling.mousemove === void 0) {
22133 sampling.mousemove = mousemoveWait;
22134 }
22135 mirror.reset();
22136 var maskInputOptions = maskAllInputs === true ? {
22137 color: true,
22138 date: true,
22139 "datetime-local": true,
22140 email: true,
22141 month: true,
22142 number: true,
22143 range: true,
22144 search: true,
22145 tel: true,
22146 text: true,
22147 time: true,
22148 url: true,
22149 week: true,
22150 textarea: true,
22151 select: true,
22152 password: true,
22153 hidden: true
22154 } : _maskInputOptions !== void 0 ? _maskInputOptions : {
22155 password: true
22156 };
22157 var slimDOMOptions = _slimDOMOptions === true || _slimDOMOptions === "all" ? {
22158 script: true,
22159 comment: true,
22160 headFavicon: true,
22161 headWhitespace: true,
22162 headMetaSocial: true,
22163 headMetaRobots: true,
22164 headMetaHttpEquiv: true,
22165 headMetaVerification: true,
22166 // the following are off for slimDOMOptions === true,
22167 // as they destroy some (hidden) info:
22168 headMetaAuthorship: _slimDOMOptions === "all",
22169 headMetaDescKeywords: _slimDOMOptions === "all",
22170 headTitleMutations: _slimDOMOptions === "all"
22171 } : _slimDOMOptions ? _slimDOMOptions : {};
22172 polyfill$1();
22173 var lastFullSnapshotEvent;
22174 var incrementalSnapshotCount = 0;
22175 var eventProcessor = function(e2) {
22176 for(var _iterator = _create_for_of_iterator_helper_loose(plugins || []), _step; !(_step = _iterator()).done;){
22177 var plugin3 = _step.value;
22178 if (plugin3.eventProcessor) {
22179 e2 = plugin3.eventProcessor(e2);
22180 }
22181 }
22182 if (packFn && // Disable packing events which will be emitted to parent frames.
22183 !passEmitsToParent) {
22184 e2 = packFn(e2);
22185 }
22186 return e2;
22187 };
22188 wrappedEmit = function(r2, isCheckout) {
22189 var _a2;
22190 var e2 = r2;
22191 e2.timestamp = nowTimestamp();
22192 if (((_a2 = mutationBuffers[0]) == null ? void 0 : _a2.isFrozen()) && e2.type !== EventType.FullSnapshot && !(e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.Mutation)) {
22193 mutationBuffers.forEach(function(buf) {
22194 return buf.unfreeze();
22195 });
22196 }
22197 if (inEmittingFrame) {
22198 emit == null ? void 0 : emit(eventProcessor(e2), isCheckout);
22199 } else if (passEmitsToParent) {
22200 var message = {
22201 type: "rrweb",
22202 event: eventProcessor(e2),
22203 origin: window.location.origin,
22204 isCheckout: isCheckout
22205 };
22206 window.parent.postMessage(message, "*");
22207 }
22208 if (e2.type === EventType.FullSnapshot) {
22209 lastFullSnapshotEvent = e2;
22210 incrementalSnapshotCount = 0;
22211 } else if (e2.type === EventType.IncrementalSnapshot) {
22212 if (e2.data.source === IncrementalSource.Mutation && e2.data.isAttachIframe) {
22213 return;
22214 }
22215 incrementalSnapshotCount++;
22216 var exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
22217 var exceedTime = checkoutEveryNms && e2.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
22218 if (exceedCount || exceedTime) {
22219 takeFullSnapshot$1(true);
22220 }
22221 }
22222 };
22223 var wrappedMutationEmit = function(m) {
22224 wrappedEmit({
22225 type: EventType.IncrementalSnapshot,
22226 data: _extends({
22227 source: IncrementalSource.Mutation
22228 }, m)
22229 });
22230 };
22231 var wrappedScrollEmit = function(p) {
22232 return wrappedEmit({
22233 type: EventType.IncrementalSnapshot,
22234 data: _extends({
22235 source: IncrementalSource.Scroll
22236 }, p)
22237 });
22238 };
22239 var wrappedCanvasMutationEmit = function(p) {
22240 return wrappedEmit({
22241 type: EventType.IncrementalSnapshot,
22242 data: _extends({
22243 source: IncrementalSource.CanvasMutation
22244 }, p)
22245 });
22246 };
22247 var wrappedAdoptedStyleSheetEmit = function(a2) {
22248 return wrappedEmit({
22249 type: EventType.IncrementalSnapshot,
22250 data: _extends({
22251 source: IncrementalSource.AdoptedStyleSheet
22252 }, a2)
22253 });
22254 };
22255 var stylesheetManager = new StylesheetManager({
22256 mutationCb: wrappedMutationEmit,
22257 adoptedStyleSheetCb: wrappedAdoptedStyleSheetEmit
22258 });
22259 var iframeManager = new IframeManager({
22260 mirror: mirror,
22261 mutationCb: wrappedMutationEmit,
22262 stylesheetManager: stylesheetManager,
22263 recordCrossOriginIframes: recordCrossOriginIframes,
22264 wrappedEmit: wrappedEmit
22265 });
22266 for(var _iterator = _create_for_of_iterator_helper_loose(plugins || []), _step; !(_step = _iterator()).done;){
22267 var plugin3 = _step.value;
22268 if (plugin3.getMirror) plugin3.getMirror({
22269 nodeMirror: mirror,
22270 crossOriginIframeMirror: iframeManager.crossOriginIframeMirror,
22271 crossOriginIframeStyleMirror: iframeManager.crossOriginIframeStyleMirror
22272 });
22273 }
22274 var processedNodeManager = new ProcessedNodeManager();
22275 canvasManager = new CanvasManager({
22276 recordCanvas: recordCanvas,
22277 mutationCb: wrappedCanvasMutationEmit,
22278 win: window,
22279 blockClass: blockClass,
22280 blockSelector: blockSelector,
22281 mirror: mirror,
22282 sampling: sampling.canvas,
22283 dataURLOptions: dataURLOptions
22284 });
22285 var shadowDomManager = new ShadowDomManager({
22286 mutationCb: wrappedMutationEmit,
22287 scrollCb: wrappedScrollEmit,
22288 bypassOptions: {
22289 blockClass: blockClass,
22290 blockSelector: blockSelector,
22291 maskTextClass: maskTextClass,
22292 maskTextSelector: maskTextSelector,
22293 inlineStylesheet: inlineStylesheet,
22294 maskInputOptions: maskInputOptions,
22295 dataURLOptions: dataURLOptions,
22296 maskTextFn: maskTextFn,
22297 maskInputFn: maskInputFn,
22298 recordCanvas: recordCanvas,
22299 inlineImages: inlineImages,
22300 sampling: sampling,
22301 slimDOMOptions: slimDOMOptions,
22302 iframeManager: iframeManager,
22303 stylesheetManager: stylesheetManager,
22304 canvasManager: canvasManager,
22305 keepIframeSrcFn: keepIframeSrcFn,
22306 processedNodeManager: processedNodeManager
22307 },
22308 mirror: mirror
22309 });
22310 takeFullSnapshot$1 = function(isCheckout) {
22311 if (isCheckout === void 0) isCheckout = false;
22312 if (!recordDOM) {
22313 return;
22314 }
22315 wrappedEmit({
22316 type: EventType.Meta,
22317 data: {
22318 href: window.location.href,
22319 width: getWindowWidth(),
22320 height: getWindowHeight()
22321 }
22322 }, isCheckout);
22323 stylesheetManager.reset();
22324 shadowDomManager.init();
22325 mutationBuffers.forEach(function(buf) {
22326 return buf.lock();
22327 });
22328 var node2 = snapshot(document, {
22329 mirror: mirror,
22330 blockClass: blockClass,
22331 blockSelector: blockSelector,
22332 maskTextClass: maskTextClass,
22333 maskTextSelector: maskTextSelector,
22334 inlineStylesheet: inlineStylesheet,
22335 maskAllInputs: maskInputOptions,
22336 maskTextFn: maskTextFn,
22337 maskInputFn: maskInputFn,
22338 slimDOM: slimDOMOptions,
22339 dataURLOptions: dataURLOptions,
22340 recordCanvas: recordCanvas,
22341 inlineImages: inlineImages,
22342 onSerialize: function(n2) {
22343 if (isSerializedIframe(n2, mirror)) {
22344 iframeManager.addIframe(n2);
22345 }
22346 if (isSerializedStylesheet(n2, mirror)) {
22347 stylesheetManager.trackLinkElement(n2);
22348 }
22349 if (hasShadowRoot(n2)) {
22350 shadowDomManager.addShadowRoot(index.shadowRoot(n2), document);
22351 }
22352 },
22353 onIframeLoad: function(iframe, childSn) {
22354 iframeManager.attachIframe(iframe, childSn);
22355 shadowDomManager.observeAttachShadow(iframe);
22356 },
22357 onStylesheetLoad: function(linkEl, childSn) {
22358 stylesheetManager.attachLinkElement(linkEl, childSn);
22359 },
22360 keepIframeSrcFn: keepIframeSrcFn
22361 });
22362 if (!node2) {
22363 return console.warn("Failed to snapshot the document");
22364 }
22365 wrappedEmit({
22366 type: EventType.FullSnapshot,
22367 data: {
22368 node: node2,
22369 initialOffset: getWindowScroll(window)
22370 }
22371 }, isCheckout);
22372 mutationBuffers.forEach(function(buf) {
22373 return buf.unlock();
22374 });
22375 if (document.adoptedStyleSheets && document.adoptedStyleSheets.length > 0) stylesheetManager.adoptStyleSheets(document.adoptedStyleSheets, mirror.getId(document));
22376 };
22377 try {
22378 var handlers = [];
22379 var observe = function(doc) {
22380 var _a2;
22381 return callbackWrapper(initObservers)({
22382 mutationCb: wrappedMutationEmit,
22383 mousemoveCb: function(positions, source) {
22384 return wrappedEmit({
22385 type: EventType.IncrementalSnapshot,
22386 data: {
22387 source: source,
22388 positions: positions
22389 }
22390 });
22391 },
22392 mouseInteractionCb: function(d) {
22393 return wrappedEmit({
22394 type: EventType.IncrementalSnapshot,
22395 data: _extends({
22396 source: IncrementalSource.MouseInteraction
22397 }, d)
22398 });
22399 },
22400 scrollCb: wrappedScrollEmit,
22401 viewportResizeCb: function(d) {
22402 return wrappedEmit({
22403 type: EventType.IncrementalSnapshot,
22404 data: _extends({
22405 source: IncrementalSource.ViewportResize
22406 }, d)
22407 });
22408 },
22409 inputCb: function(v2) {
22410 return wrappedEmit({
22411 type: EventType.IncrementalSnapshot,
22412 data: _extends({
22413 source: IncrementalSource.Input
22414 }, v2)
22415 });
22416 },
22417 mediaInteractionCb: function(p) {
22418 return wrappedEmit({
22419 type: EventType.IncrementalSnapshot,
22420 data: _extends({
22421 source: IncrementalSource.MediaInteraction
22422 }, p)
22423 });
22424 },
22425 styleSheetRuleCb: function(r2) {
22426 return wrappedEmit({
22427 type: EventType.IncrementalSnapshot,
22428 data: _extends({
22429 source: IncrementalSource.StyleSheetRule
22430 }, r2)
22431 });
22432 },
22433 styleDeclarationCb: function(r2) {
22434 return wrappedEmit({
22435 type: EventType.IncrementalSnapshot,
22436 data: _extends({
22437 source: IncrementalSource.StyleDeclaration
22438 }, r2)
22439 });
22440 },
22441 canvasMutationCb: wrappedCanvasMutationEmit,
22442 fontCb: function(p) {
22443 return wrappedEmit({
22444 type: EventType.IncrementalSnapshot,
22445 data: _extends({
22446 source: IncrementalSource.Font
22447 }, p)
22448 });
22449 },
22450 selectionCb: function(p) {
22451 wrappedEmit({
22452 type: EventType.IncrementalSnapshot,
22453 data: _extends({
22454 source: IncrementalSource.Selection
22455 }, p)
22456 });
22457 },
22458 customElementCb: function(c2) {
22459 wrappedEmit({
22460 type: EventType.IncrementalSnapshot,
22461 data: _extends({
22462 source: IncrementalSource.CustomElement
22463 }, c2)
22464 });
22465 },
22466 blockClass: blockClass,
22467 ignoreClass: ignoreClass,
22468 ignoreSelector: ignoreSelector,
22469 maskTextClass: maskTextClass,
22470 maskTextSelector: maskTextSelector,
22471 maskInputOptions: maskInputOptions,
22472 inlineStylesheet: inlineStylesheet,
22473 sampling: sampling,
22474 recordDOM: recordDOM,
22475 recordCanvas: recordCanvas,
22476 inlineImages: inlineImages,
22477 userTriggeredOnInput: userTriggeredOnInput,
22478 collectFonts: collectFonts,
22479 doc: doc,
22480 maskInputFn: maskInputFn,
22481 maskTextFn: maskTextFn,
22482 keepIframeSrcFn: keepIframeSrcFn,
22483 blockSelector: blockSelector,
22484 slimDOMOptions: slimDOMOptions,
22485 dataURLOptions: dataURLOptions,
22486 mirror: mirror,
22487 iframeManager: iframeManager,
22488 stylesheetManager: stylesheetManager,
22489 shadowDomManager: shadowDomManager,
22490 processedNodeManager: processedNodeManager,
22491 canvasManager: canvasManager,
22492 ignoreCSSAttributes: ignoreCSSAttributes,
22493 plugins: ((_a2 = plugins == null ? void 0 : plugins.filter(function(p) {
22494 return p.observer;
22495 })) == null ? void 0 : _a2.map(function(p) {
22496 return {
22497 observer: p.observer,
22498 options: p.options,
22499 callback: function(payload) {
22500 return wrappedEmit({
22501 type: EventType.Plugin,
22502 data: {
22503 plugin: p.name,
22504 payload: payload
22505 }
22506 });
22507 }
22508 };
22509 })) || []
22510 }, hooks);
22511 };
22512 iframeManager.addLoadListener(function(iframeEl) {
22513 try {
22514 handlers.push(observe(iframeEl.contentDocument));
22515 } catch (error) {
22516 console.warn(error);
22517 }
22518 });
22519 var init = function() {
22520 takeFullSnapshot$1();
22521 handlers.push(observe(document));
22522 recording = true;
22523 };
22524 if (document.readyState === "interactive" || document.readyState === "complete") {
22525 init();
22526 } else {
22527 handlers.push(on("DOMContentLoaded", function() {
22528 wrappedEmit({
22529 type: EventType.DomContentLoaded,
22530 data: {}
22531 });
22532 if (recordAfter === "DOMContentLoaded") init();
22533 }));
22534 handlers.push(on("load", function() {
22535 wrappedEmit({
22536 type: EventType.Load,
22537 data: {}
22538 });
22539 if (recordAfter === "load") init();
22540 }, window));
22541 }
22542 return function() {
22543 handlers.forEach(function(handler) {
22544 try {
22545 handler();
22546 } catch (error) {
22547 var msg = String(error).toLowerCase();
22548 if (!msg.includes("cross-origin")) {
22549 console.warn(error);
22550 }
22551 }
22552 });
22553 processedNodeManager.destroy();
22554 recording = false;
22555 unregisterErrorHandler();
22556 };
22557 } catch (error) {
22558 console.warn(error);
22559 }
22560 }
22561 record.addCustomEvent = function(tag, payload) {
22562 if (!recording) {
22563 throw new Error("please add custom event after start recording");
22564 }
22565 wrappedEmit({
22566 type: EventType.Custom,
22567 data: {
22568 tag: tag,
22569 payload: payload
22570 }
22571 });
22572 };
22573 record.freezePage = function() {
22574 mutationBuffers.forEach(function(buf) {
22575 return buf.freeze();
22576 });
22577 };
22578 record.takeFullSnapshot = function(isCheckout) {
22579 if (!recording) {
22580 throw new Error("please take full snapshot after start recording");
22581 }
22582 takeFullSnapshot$1(isCheckout);
22583 };
22584 record.mirror = mirror;
22585 var n;
22586 !function(t2) {
22587 t2[t2.NotStarted = 0] = "NotStarted", t2[t2.Running = 1] = "Running", t2[t2.Stopped = 2] = "Stopped";
22588 }(n || (n = {}));
22589 record.addCustomEvent;
22590 record.freezePage;
22591 record.takeFullSnapshot;
22592
22593 var setImmediate = win['setImmediate'];
22594 var builtInProp, cycle, schedulingQueue,
22595 ToString = Object.prototype.toString,
22596 timer = (typeof setImmediate !== 'undefined') ?
22597 function timer(fn) { return setImmediate(fn); } :
22598 setTimeout;
22599
22600 // dammit, IE8.
22601 try {
22602 Object.defineProperty({},'x',{});
22603 builtInProp = function builtInProp(obj,name,val,config) {
22604 return Object.defineProperty(obj,name,{
22605 value: val,
22606 writable: true,
22607 configurable: config !== false
22608 });
22609 };
22610 }
22611 catch (err) {
22612 builtInProp = function builtInProp(obj,name,val) {
22613 obj[name] = val;
22614 return obj;
22615 };
22616 }
22617
22618 // Note: using a queue instead of array for efficiency
22619 schedulingQueue = (function Queue() {
22620 var first, last, item;
22621
22622 function Item(fn,self) {
22623 this.fn = fn;
22624 this.self = self;
22625 this.next = void 0;
22626 }
22627
22628 return {
22629 add: function add(fn,self) {
22630 item = new Item(fn,self);
22631 if (last) {
22632 last.next = item;
22633 }
22634 else {
22635 first = item;
22636 }
22637 last = item;
22638 item = void 0;
22639 },
22640 drain: function drain() {
22641 var f = first;
22642 first = last = cycle = void 0;
22643
22644 while (f) {
22645 f.fn.call(f.self);
22646 f = f.next;
22647 }
22648 }
22649 };
22650 })();
22651
22652 function schedule(fn,self) {
22653 schedulingQueue.add(fn,self);
22654 if (!cycle) {
22655 cycle = timer(schedulingQueue.drain);
22656 }
22657 }
22658
22659 // promise duck typing
22660 function isThenable(o) {
22661 var _then, oType = typeof o;
22662
22663 if (o !== null && (oType === 'object' || oType === 'function')) {
22664 _then = o.then;
22665 }
22666 return typeof _then === 'function' ? _then : false;
22667 }
22668
22669 function notify() {
22670 for (var i=0; i<this.chain.length; i++) {
22671 notifyIsolated(
22672 this,
22673 (this.state === 1) ? this.chain[i].success : this.chain[i].failure,
22674 this.chain[i]
22675 );
22676 }
22677 this.chain.length = 0;
22678 }
22679
22680 // NOTE: This is a separate function to isolate
22681 // the `try..catch` so that other code can be
22682 // optimized better
22683 function notifyIsolated(self,cb,chain) {
22684 var ret, _then;
22685 try {
22686 if (cb === false) {
22687 chain.reject(self.msg);
22688 }
22689 else {
22690 if (cb === true) {
22691 ret = self.msg;
22692 }
22693 else {
22694 ret = cb.call(void 0,self.msg);
22695 }
22696
22697 if (ret === chain.promise) {
22698 chain.reject(TypeError('Promise-chain cycle'));
22699 }
22700 // eslint-disable-next-line no-cond-assign
22701 else if (_then = isThenable(ret)) {
22702 _then.call(ret,chain.resolve,chain.reject);
22703 }
22704 else {
22705 chain.resolve(ret);
22706 }
22707 }
22708 }
22709 catch (err) {
22710 chain.reject(err);
22711 }
22712 }
22713
22714 function resolve(msg) {
22715 var _then, self = this;
22716
22717 // already triggered?
22718 if (self.triggered) { return; }
22719
22720 self.triggered = true;
22721
22722 // unwrap
22723 if (self.def) {
22724 self = self.def;
22725 }
22726
22727 try {
22728 // eslint-disable-next-line no-cond-assign
22729 if (_then = isThenable(msg)) {
22730 schedule(function(){
22731 var defWrapper = new MakeDefWrapper(self);
22732 try {
22733 _then.call(msg,
22734 function $resolve$(){ resolve.apply(defWrapper,arguments); },
22735 function $reject$(){ reject.apply(defWrapper,arguments); }
22736 );
22737 }
22738 catch (err) {
22739 reject.call(defWrapper,err);
22740 }
22741 });
22742 }
22743 else {
22744 self.msg = msg;
22745 self.state = 1;
22746 if (self.chain.length > 0) {
22747 schedule(notify,self);
22748 }
22749 }
22750 }
22751 catch (err) {
22752 reject.call(new MakeDefWrapper(self),err);
22753 }
22754 }
22755
22756 function reject(msg) {
22757 var self = this;
22758
22759 // already triggered?
22760 if (self.triggered) { return; }
22761
22762 self.triggered = true;
22763
22764 // unwrap
22765 if (self.def) {
22766 self = self.def;
22767 }
22768
22769 self.msg = msg;
22770 self.state = 2;
22771 if (self.chain.length > 0) {
22772 schedule(notify,self);
22773 }
22774 }
22775
22776 function iteratePromises(Constructor,arr,resolver,rejecter) {
22777 for (var idx=0; idx<arr.length; idx++) {
22778 (function IIFE(idx){
22779 Constructor.resolve(arr[idx])
22780 .then(
22781 function $resolver$(msg){
22782 resolver(idx,msg);
22783 },
22784 rejecter
22785 );
22786 })(idx);
22787 }
22788 }
22789
22790 function MakeDefWrapper(self) {
22791 this.def = self;
22792 this.triggered = false;
22793 }
22794
22795 function MakeDef(self) {
22796 this.promise = self;
22797 this.state = 0;
22798 this.triggered = false;
22799 this.chain = [];
22800 this.msg = void 0;
22801 }
22802
22803 function NpoPromise(executor) {
22804 if (typeof executor !== 'function') {
22805 throw TypeError('Not a function');
22806 }
22807
22808 if (this['__NPO__'] !== 0) {
22809 throw TypeError('Not a promise');
22810 }
22811
22812 // instance shadowing the inherited "brand"
22813 // to signal an already "initialized" promise
22814 this['__NPO__'] = 1;
22815
22816 var def = new MakeDef(this);
22817
22818 this['then'] = function then(success,failure) {
22819 var o = {
22820 success: typeof success === 'function' ? success : true,
22821 failure: typeof failure === 'function' ? failure : false
22822 };
22823 // Note: `then(..)` itself can be borrowed to be used against
22824 // a different promise constructor for making the chained promise,
22825 // by substituting a different `this` binding.
22826 o.promise = new this.constructor(function extractChain(resolve,reject) {
22827 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22828 throw TypeError('Not a function');
22829 }
22830
22831 o.resolve = resolve;
22832 o.reject = reject;
22833 });
22834 def.chain.push(o);
22835
22836 if (def.state !== 0) {
22837 schedule(notify,def);
22838 }
22839
22840 return o.promise;
22841 };
22842 this['catch'] = function $catch$(failure) {
22843 return this.then(void 0,failure);
22844 };
22845
22846 try {
22847 executor.call(
22848 void 0,
22849 function publicResolve(msg){
22850 resolve.call(def,msg);
22851 },
22852 function publicReject(msg) {
22853 reject.call(def,msg);
22854 }
22855 );
22856 }
22857 catch (err) {
22858 reject.call(def,err);
22859 }
22860 }
22861
22862 var PromisePrototype = builtInProp({},'constructor',NpoPromise,
22863 /*configurable=*/false
22864 );
22865
22866 // Note: Android 4 cannot use `Object.defineProperty(..)` here
22867 NpoPromise.prototype = PromisePrototype;
22868
22869 // built-in "brand" to signal an "uninitialized" promise
22870 builtInProp(PromisePrototype,'__NPO__',0,
22871 /*configurable=*/false
22872 );
22873
22874 builtInProp(NpoPromise,'resolve',function Promise$resolve(msg) {
22875 var Constructor = this;
22876
22877 // spec mandated checks
22878 // note: best "isPromise" check that's practical for now
22879 if (msg && typeof msg === 'object' && msg['__NPO__'] === 1) {
22880 return msg;
22881 }
22882
22883 return new Constructor(function executor(resolve,reject){
22884 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22885 throw TypeError('Not a function');
22886 }
22887
22888 resolve(msg);
22889 });
22890 });
22891
22892 builtInProp(NpoPromise,'reject',function Promise$reject(msg) {
22893 return new this(function executor(resolve,reject){
22894 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22895 throw TypeError('Not a function');
22896 }
22897
22898 reject(msg);
22899 });
22900 });
22901
22902 builtInProp(NpoPromise,'all',function Promise$all(arr) {
22903 var Constructor = this;
22904
22905 // spec mandated checks
22906 if (ToString.call(arr) !== '[object Array]') {
22907 return Constructor.reject(TypeError('Not an array'));
22908 }
22909 if (arr.length === 0) {
22910 return Constructor.resolve([]);
22911 }
22912
22913 return new Constructor(function executor(resolve,reject){
22914 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22915 throw TypeError('Not a function');
22916 }
22917
22918 var len = arr.length, msgs = Array(len), count = 0;
22919
22920 iteratePromises(Constructor,arr,function resolver(idx,msg) {
22921 msgs[idx] = msg;
22922 if (++count === len) {
22923 resolve(msgs);
22924 }
22925 },reject);
22926 });
22927 });
22928
22929 builtInProp(NpoPromise,'race',function Promise$race(arr) {
22930 var Constructor = this;
22931
22932 // spec mandated checks
22933 if (ToString.call(arr) !== '[object Array]') {
22934 return Constructor.reject(TypeError('Not an array'));
22935 }
22936
22937 return new Constructor(function executor(resolve,reject){
22938 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22939 throw TypeError('Not a function');
22940 }
22941
22942 iteratePromises(Constructor,arr,function resolver(idx,msg){
22943 resolve(msg);
22944 },reject);
22945 });
22946 });
22947
22948 var PromisePolyfill;
22949 if (typeof Promise !== 'undefined' && Promise.toString().indexOf('[native code]') !== -1) {
22950 PromisePolyfill = Promise;
22951 } else {
22952 PromisePolyfill = NpoPromise;
22953 }
22954
22955 var Config = {
22956 DEBUG: false,
22957 LIB_VERSION: '2.71.1'
22958 };
22959
22960 /* eslint camelcase: "off", eqeqeq: "off" */
22961
22962 // Maximum allowed session recording length
22963 var MAX_RECORDING_MS = 24 * 60 * 60 * 1000; // 24 hours
22964 // Maximum allowed value for minimum session recording length
22965 var MAX_VALUE_FOR_MIN_RECORDING_MS = 8 * 1000; // 8 seconds
22966
22967 /*
22968 * Saved references to long variable names, so that closure compiler can
22969 * minimize file size.
22970 */
22971
22972 var ArrayProto = Array.prototype,
22973 FuncProto = Function.prototype,
22974 ObjProto = Object.prototype,
22975 slice = ArrayProto.slice,
22976 toString = ObjProto.toString,
22977 hasOwnProperty = ObjProto.hasOwnProperty,
22978 windowConsole = win.console,
22979 navigator = win.navigator,
22980 document$1 = win.document,
22981 windowOpera = win.opera,
22982 screen = win.screen,
22983 userAgent = navigator.userAgent;
22984
22985 var nativeBind = FuncProto.bind,
22986 nativeForEach = ArrayProto.forEach,
22987 nativeIndexOf = ArrayProto.indexOf,
22988 nativeMap = ArrayProto.map,
22989 nativeIsArray = Array.isArray,
22990 breaker = {};
22991
22992 var _ = {
22993 trim: function(str) {
22994 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
22995 return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
22996 }
22997 };
22998
22999 // Console override
23000 var console$1 = {
23001 /** @type {function(...*)} */
23002 log: function() {
23003 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
23004 try {
23005 windowConsole.log.apply(windowConsole, arguments);
23006 } catch (err) {
23007 _.each(arguments, function(arg) {
23008 windowConsole.log(arg);
23009 });
23010 }
23011 }
23012 },
23013 /** @type {function(...*)} */
23014 warn: function() {
23015 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
23016 var args = ['Mixpanel warning:'].concat(_.toArray(arguments));
23017 try {
23018 windowConsole.warn.apply(windowConsole, args);
23019 } catch (err) {
23020 _.each(args, function(arg) {
23021 windowConsole.warn(arg);
23022 });
23023 }
23024 }
23025 },
23026 /** @type {function(...*)} */
23027 error: function() {
23028 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
23029 var args = ['Mixpanel error:'].concat(_.toArray(arguments));
23030 try {
23031 windowConsole.error.apply(windowConsole, args);
23032 } catch (err) {
23033 _.each(args, function(arg) {
23034 windowConsole.error(arg);
23035 });
23036 }
23037 }
23038 },
23039 /** @type {function(...*)} */
23040 critical: function() {
23041 if (!_.isUndefined(windowConsole) && windowConsole) {
23042 var args = ['Mixpanel error:'].concat(_.toArray(arguments));
23043 try {
23044 windowConsole.error.apply(windowConsole, args);
23045 } catch (err) {
23046 _.each(args, function(arg) {
23047 windowConsole.error(arg);
23048 });
23049 }
23050 }
23051 }
23052 };
23053
23054 var log_func_with_prefix = function(func, prefix) {
23055 return function() {
23056 arguments[0] = '[' + prefix + '] ' + arguments[0];
23057 return func.apply(console$1, arguments);
23058 };
23059 };
23060 var console_with_prefix = function(prefix) {
23061 return {
23062 log: log_func_with_prefix(console$1.log, prefix),
23063 error: log_func_with_prefix(console$1.error, prefix),
23064 critical: log_func_with_prefix(console$1.critical, prefix)
23065 };
23066 };
23067
23068
23069 var safewrap = function(f) {
23070 return function() {
23071 try {
23072 return f.apply(this, arguments);
23073 } catch (e) {
23074 console$1.critical('Implementation error. Please turn on debug and contact support@mixpanel.com.');
23075 if (Config.DEBUG){
23076 console$1.critical(e);
23077 }
23078 }
23079 };
23080 };
23081
23082 var safewrapClass = function(klass) {
23083 var proto = klass.prototype;
23084 for (var func in proto) {
23085 if (typeof(proto[func]) === 'function') {
23086 proto[func] = safewrap(proto[func]);
23087 }
23088 }
23089 };
23090
23091
23092 // UNDERSCORE
23093 // Embed part of the Underscore Library
23094 _.bind = function(func, context) {
23095 var args, bound;
23096 if (nativeBind && func.bind === nativeBind) {
23097 return nativeBind.apply(func, slice.call(arguments, 1));
23098 }
23099 if (!_.isFunction(func)) {
23100 throw new TypeError();
23101 }
23102 args = slice.call(arguments, 2);
23103 bound = function() {
23104 if (!(this instanceof bound)) {
23105 return func.apply(context, args.concat(slice.call(arguments)));
23106 }
23107 var ctor = {};
23108 ctor.prototype = func.prototype;
23109 var self = new ctor();
23110 ctor.prototype = null;
23111 var result = func.apply(self, args.concat(slice.call(arguments)));
23112 if (Object(result) === result) {
23113 return result;
23114 }
23115 return self;
23116 };
23117 return bound;
23118 };
23119
23120 /**
23121 * @param {*=} obj
23122 * @param {function(...*)=} iterator
23123 * @param {Object=} context
23124 */
23125 _.each = function(obj, iterator, context) {
23126 if (obj === null || obj === undefined) {
23127 return;
23128 }
23129 if (nativeForEach && obj.forEach === nativeForEach) {
23130 obj.forEach(iterator, context);
23131 } else if (obj.length === +obj.length) {
23132 for (var i = 0, l = obj.length; i < l; i++) {
23133 if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) {
23134 return;
23135 }
23136 }
23137 } else {
23138 for (var key in obj) {
23139 if (hasOwnProperty.call(obj, key)) {
23140 if (iterator.call(context, obj[key], key, obj) === breaker) {
23141 return;
23142 }
23143 }
23144 }
23145 }
23146 };
23147
23148 _.extend = function(obj) {
23149 _.each(slice.call(arguments, 1), function(source) {
23150 for (var prop in source) {
23151 if (source[prop] !== void 0) {
23152 obj[prop] = source[prop];
23153 }
23154 }
23155 });
23156 return obj;
23157 };
23158
23159 _.isArray = nativeIsArray || function(obj) {
23160 return toString.call(obj) === '[object Array]';
23161 };
23162
23163 // from a comment on http://dbj.org/dbj/?p=286
23164 // fails on only one very rare and deliberate custom object:
23165 // var bomb = { toString : undefined, valueOf: function(o) { return "function BOMBA!"; }};
23166 _.isFunction = function(f) {
23167 try {
23168 return /^\s*\bfunction\b/.test(f);
23169 } catch (x) {
23170 return false;
23171 }
23172 };
23173
23174 _.isArguments = function(obj) {
23175 return !!(obj && hasOwnProperty.call(obj, 'callee'));
23176 };
23177
23178 _.toArray = function(iterable) {
23179 if (!iterable) {
23180 return [];
23181 }
23182 if (iterable.toArray) {
23183 return iterable.toArray();
23184 }
23185 if (_.isArray(iterable)) {
23186 return slice.call(iterable);
23187 }
23188 if (_.isArguments(iterable)) {
23189 return slice.call(iterable);
23190 }
23191 return _.values(iterable);
23192 };
23193
23194 _.map = function(arr, callback, context) {
23195 if (nativeMap && arr.map === nativeMap) {
23196 return arr.map(callback, context);
23197 } else {
23198 var results = [];
23199 _.each(arr, function(item) {
23200 results.push(callback.call(context, item));
23201 });
23202 return results;
23203 }
23204 };
23205
23206 _.keys = function(obj) {
23207 var results = [];
23208 if (obj === null) {
23209 return results;
23210 }
23211 _.each(obj, function(value, key) {
23212 results[results.length] = key;
23213 });
23214 return results;
23215 };
23216
23217 _.values = function(obj) {
23218 var results = [];
23219 if (obj === null) {
23220 return results;
23221 }
23222 _.each(obj, function(value) {
23223 results[results.length] = value;
23224 });
23225 return results;
23226 };
23227
23228 _.include = function(obj, target) {
23229 var found = false;
23230 if (obj === null) {
23231 return found;
23232 }
23233 if (nativeIndexOf && obj.indexOf === nativeIndexOf) {
23234 return obj.indexOf(target) != -1;
23235 }
23236 _.each(obj, function(value) {
23237 if (found || (found = (value === target))) {
23238 return breaker;
23239 }
23240 });
23241 return found;
23242 };
23243
23244 _.includes = function(str, needle) {
23245 return str.indexOf(needle) !== -1;
23246 };
23247
23248 // Underscore Addons
23249 _.inherit = function(subclass, superclass) {
23250 subclass.prototype = new superclass();
23251 subclass.prototype.constructor = subclass;
23252 subclass.superclass = superclass.prototype;
23253 return subclass;
23254 };
23255
23256 _.isObject = function(obj) {
23257 return (obj === Object(obj) && !_.isArray(obj));
23258 };
23259
23260 _.isEmptyObject = function(obj) {
23261 if (_.isObject(obj)) {
23262 for (var key in obj) {
23263 if (hasOwnProperty.call(obj, key)) {
23264 return false;
23265 }
23266 }
23267 return true;
23268 }
23269 return false;
23270 };
23271
23272 _.isUndefined = function(obj) {
23273 return obj === void 0;
23274 };
23275
23276 _.isString = function(obj) {
23277 return toString.call(obj) == '[object String]';
23278 };
23279
23280 _.isDate = function(obj) {
23281 return toString.call(obj) == '[object Date]';
23282 };
23283
23284 _.isNumber = function(obj) {
23285 return toString.call(obj) == '[object Number]';
23286 };
23287
23288 _.isElement = function(obj) {
23289 return !!(obj && obj.nodeType === 1);
23290 };
23291
23292 _.encodeDates = function(obj) {
23293 _.each(obj, function(v, k) {
23294 if (_.isDate(v)) {
23295 obj[k] = _.formatDate(v);
23296 } else if (_.isObject(v)) {
23297 obj[k] = _.encodeDates(v); // recurse
23298 }
23299 });
23300 return obj;
23301 };
23302
23303 _.timestamp = function() {
23304 Date.now = Date.now || function() {
23305 return +new Date;
23306 };
23307 return Date.now();
23308 };
23309
23310 _.formatDate = function(d) {
23311 // YYYY-MM-DDTHH:MM:SS in UTC
23312 function pad(n) {
23313 return n < 10 ? '0' + n : n;
23314 }
23315 return d.getUTCFullYear() + '-' +
23316 pad(d.getUTCMonth() + 1) + '-' +
23317 pad(d.getUTCDate()) + 'T' +
23318 pad(d.getUTCHours()) + ':' +
23319 pad(d.getUTCMinutes()) + ':' +
23320 pad(d.getUTCSeconds());
23321 };
23322
23323 _.strip_empty_properties = function(p) {
23324 var ret = {};
23325 _.each(p, function(v, k) {
23326 if (_.isString(v) && v.length > 0) {
23327 ret[k] = v;
23328 }
23329 });
23330 return ret;
23331 };
23332
23333 /*
23334 * this function returns a copy of object after truncating it. If
23335 * passed an Array or Object it will iterate through obj and
23336 * truncate all the values recursively.
23337 */
23338 _.truncate = function(obj, length) {
23339 var ret;
23340
23341 if (typeof(obj) === 'string') {
23342 ret = obj.slice(0, length);
23343 } else if (_.isArray(obj)) {
23344 ret = [];
23345 _.each(obj, function(val) {
23346 ret.push(_.truncate(val, length));
23347 });
23348 } else if (_.isObject(obj)) {
23349 ret = {};
23350 _.each(obj, function(val, key) {
23351 ret[key] = _.truncate(val, length);
23352 });
23353 } else {
23354 ret = obj;
23355 }
23356
23357 return ret;
23358 };
23359
23360 _.JSONEncode = (function() {
23361 return function(mixed_val) {
23362 var value = mixed_val;
23363 var quote = function(string) {
23364 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
23365 var meta = { // table of character substitutions
23366 '\b': '\\b',
23367 '\t': '\\t',
23368 '\n': '\\n',
23369 '\f': '\\f',
23370 '\r': '\\r',
23371 '"': '\\"',
23372 '\\': '\\\\'
23373 };
23374
23375 escapable.lastIndex = 0;
23376 return escapable.test(string) ?
23377 '"' + string.replace(escapable, function(a) {
23378 var c = meta[a];
23379 return typeof c === 'string' ? c :
23380 '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
23381 }) + '"' :
23382 '"' + string + '"';
23383 };
23384
23385 var str = function(key, holder) {
23386 var gap = '';
23387 var indent = ' ';
23388 var i = 0; // The loop counter.
23389 var k = ''; // The member key.
23390 var v = ''; // The member value.
23391 var length = 0;
23392 var mind = gap;
23393 var partial = [];
23394 var value = holder[key];
23395
23396 // If the value has a toJSON method, call it to obtain a replacement value.
23397 if (value && typeof value === 'object' &&
23398 typeof value.toJSON === 'function') {
23399 value = value.toJSON(key);
23400 }
23401
23402 // What happens next depends on the value's type.
23403 switch (typeof value) {
23404 case 'string':
23405 return quote(value);
23406
23407 case 'number':
23408 // JSON numbers must be finite. Encode non-finite numbers as null.
23409 return isFinite(value) ? String(value) : 'null';
23410
23411 case 'boolean':
23412 case 'null':
23413 // If the value is a boolean or null, convert it to a string. Note:
23414 // typeof null does not produce 'null'. The case is included here in
23415 // the remote chance that this gets fixed someday.
23416
23417 return String(value);
23418
23419 case 'object':
23420 // If the type is 'object', we might be dealing with an object or an array or
23421 // null.
23422 // Due to a specification blunder in ECMAScript, typeof null is 'object',
23423 // so watch out for that case.
23424 if (!value) {
23425 return 'null';
23426 }
23427
23428 // Make an array to hold the partial results of stringifying this object value.
23429 gap += indent;
23430 partial = [];
23431
23432 // Is the value an array?
23433 if (toString.apply(value) === '[object Array]') {
23434 // The value is an array. Stringify every element. Use null as a placeholder
23435 // for non-JSON values.
23436
23437 length = value.length;
23438 for (i = 0; i < length; i += 1) {
23439 partial[i] = str(i, value) || 'null';
23440 }
23441
23442 // Join all of the elements together, separated with commas, and wrap them in
23443 // brackets.
23444 v = partial.length === 0 ? '[]' :
23445 gap ? '[\n' + gap +
23446 partial.join(',\n' + gap) + '\n' +
23447 mind + ']' :
23448 '[' + partial.join(',') + ']';
23449 gap = mind;
23450 return v;
23451 }
23452
23453 // Iterate through all of the keys in the object.
23454 for (k in value) {
23455 if (hasOwnProperty.call(value, k)) {
23456 v = str(k, value);
23457 if (v) {
23458 partial.push(quote(k) + (gap ? ': ' : ':') + v);
23459 }
23460 }
23461 }
23462
23463 // Join all of the member texts together, separated with commas,
23464 // and wrap them in braces.
23465 v = partial.length === 0 ? '{}' :
23466 gap ? '{' + partial.join(',') + '' +
23467 mind + '}' : '{' + partial.join(',') + '}';
23468 gap = mind;
23469 return v;
23470 }
23471 };
23472
23473 // Make a fake root object containing our value under the key of ''.
23474 // Return the result of stringifying the value.
23475 return str('', {
23476 '': value
23477 });
23478 };
23479 })();
23480
23481 /**
23482 * From https://github.com/douglascrockford/JSON-js/blob/master/json_parse.js
23483 * Slightly modified to throw a real Error rather than a POJO
23484 */
23485 _.JSONDecode = (function() {
23486 var at, // The index of the current character
23487 ch, // The current character
23488 escapee = {
23489 '"': '"',
23490 '\\': '\\',
23491 '/': '/',
23492 'b': '\b',
23493 'f': '\f',
23494 'n': '\n',
23495 'r': '\r',
23496 't': '\t'
23497 },
23498 text,
23499 error = function(m) {
23500 var e = new SyntaxError(m);
23501 e.at = at;
23502 e.text = text;
23503 throw e;
23504 },
23505 next = function(c) {
23506 // If a c parameter is provided, verify that it matches the current character.
23507 if (c && c !== ch) {
23508 error('Expected \'' + c + '\' instead of \'' + ch + '\'');
23509 }
23510 // Get the next character. When there are no more characters,
23511 // return the empty string.
23512 ch = text.charAt(at);
23513 at += 1;
23514 return ch;
23515 },
23516 number = function() {
23517 // Parse a number value.
23518 var number,
23519 string = '';
23520
23521 if (ch === '-') {
23522 string = '-';
23523 next('-');
23524 }
23525 while (ch >= '0' && ch <= '9') {
23526 string += ch;
23527 next();
23528 }
23529 if (ch === '.') {
23530 string += '.';
23531 while (next() && ch >= '0' && ch <= '9') {
23532 string += ch;
23533 }
23534 }
23535 if (ch === 'e' || ch === 'E') {
23536 string += ch;
23537 next();
23538 if (ch === '-' || ch === '+') {
23539 string += ch;
23540 next();
23541 }
23542 while (ch >= '0' && ch <= '9') {
23543 string += ch;
23544 next();
23545 }
23546 }
23547 number = +string;
23548 if (!isFinite(number)) {
23549 error('Bad number');
23550 } else {
23551 return number;
23552 }
23553 },
23554
23555 string = function() {
23556 // Parse a string value.
23557 var hex,
23558 i,
23559 string = '',
23560 uffff;
23561 // When parsing for string values, we must look for " and \ characters.
23562 if (ch === '"') {
23563 while (next()) {
23564 if (ch === '"') {
23565 next();
23566 return string;
23567 }
23568 if (ch === '\\') {
23569 next();
23570 if (ch === 'u') {
23571 uffff = 0;
23572 for (i = 0; i < 4; i += 1) {
23573 hex = parseInt(next(), 16);
23574 if (!isFinite(hex)) {
23575 break;
23576 }
23577 uffff = uffff * 16 + hex;
23578 }
23579 string += String.fromCharCode(uffff);
23580 } else if (typeof escapee[ch] === 'string') {
23581 string += escapee[ch];
23582 } else {
23583 break;
23584 }
23585 } else {
23586 string += ch;
23587 }
23588 }
23589 }
23590 error('Bad string');
23591 },
23592 white = function() {
23593 // Skip whitespace.
23594 while (ch && ch <= ' ') {
23595 next();
23596 }
23597 },
23598 word = function() {
23599 // true, false, or null.
23600 switch (ch) {
23601 case 't':
23602 next('t');
23603 next('r');
23604 next('u');
23605 next('e');
23606 return true;
23607 case 'f':
23608 next('f');
23609 next('a');
23610 next('l');
23611 next('s');
23612 next('e');
23613 return false;
23614 case 'n':
23615 next('n');
23616 next('u');
23617 next('l');
23618 next('l');
23619 return null;
23620 }
23621 error('Unexpected "' + ch + '"');
23622 },
23623 value, // Placeholder for the value function.
23624 array = function() {
23625 // Parse an array value.
23626 var array = [];
23627
23628 if (ch === '[') {
23629 next('[');
23630 white();
23631 if (ch === ']') {
23632 next(']');
23633 return array; // empty array
23634 }
23635 while (ch) {
23636 array.push(value());
23637 white();
23638 if (ch === ']') {
23639 next(']');
23640 return array;
23641 }
23642 next(',');
23643 white();
23644 }
23645 }
23646 error('Bad array');
23647 },
23648 object = function() {
23649 // Parse an object value.
23650 var key,
23651 object = {};
23652
23653 if (ch === '{') {
23654 next('{');
23655 white();
23656 if (ch === '}') {
23657 next('}');
23658 return object; // empty object
23659 }
23660 while (ch) {
23661 key = string();
23662 white();
23663 next(':');
23664 if (Object.hasOwnProperty.call(object, key)) {
23665 error('Duplicate key "' + key + '"');
23666 }
23667 object[key] = value();
23668 white();
23669 if (ch === '}') {
23670 next('}');
23671 return object;
23672 }
23673 next(',');
23674 white();
23675 }
23676 }
23677 error('Bad object');
23678 };
23679
23680 value = function() {
23681 // Parse a JSON value. It could be an object, an array, a string,
23682 // a number, or a word.
23683 white();
23684 switch (ch) {
23685 case '{':
23686 return object();
23687 case '[':
23688 return array();
23689 case '"':
23690 return string();
23691 case '-':
23692 return number();
23693 default:
23694 return ch >= '0' && ch <= '9' ? number() : word();
23695 }
23696 };
23697
23698 // Return the json_parse function. It will have access to all of the
23699 // above functions and variables.
23700 return function(source) {
23701 var result;
23702
23703 text = source;
23704 at = 0;
23705 ch = ' ';
23706 result = value();
23707 white();
23708 if (ch) {
23709 error('Syntax error');
23710 }
23711
23712 return result;
23713 };
23714 })();
23715
23716 _.base64Encode = function(data) {
23717 var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
23718 var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
23719 ac = 0,
23720 enc = '',
23721 tmp_arr = [];
23722
23723 if (!data) {
23724 return data;
23725 }
23726
23727 data = _.utf8Encode(data);
23728
23729 do { // pack three octets into four hexets
23730 o1 = data.charCodeAt(i++);
23731 o2 = data.charCodeAt(i++);
23732 o3 = data.charCodeAt(i++);
23733
23734 bits = o1 << 16 | o2 << 8 | o3;
23735
23736 h1 = bits >> 18 & 0x3f;
23737 h2 = bits >> 12 & 0x3f;
23738 h3 = bits >> 6 & 0x3f;
23739 h4 = bits & 0x3f;
23740
23741 // use hexets to index into b64, and append result to encoded string
23742 tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
23743 } while (i < data.length);
23744
23745 enc = tmp_arr.join('');
23746
23747 switch (data.length % 3) {
23748 case 1:
23749 enc = enc.slice(0, -2) + '==';
23750 break;
23751 case 2:
23752 enc = enc.slice(0, -1) + '=';
23753 break;
23754 }
23755
23756 return enc;
23757 };
23758
23759 _.utf8Encode = function(string) {
23760 string = (string + '').replace(/\r\n/g, '\n').replace(/\r/g, '\n');
23761
23762 var utftext = '',
23763 start,
23764 end;
23765 var stringl = 0,
23766 n;
23767
23768 start = end = 0;
23769 stringl = string.length;
23770
23771 for (n = 0; n < stringl; n++) {
23772 var c1 = string.charCodeAt(n);
23773 var enc = null;
23774
23775 if (c1 < 128) {
23776 end++;
23777 } else if ((c1 > 127) && (c1 < 2048)) {
23778 enc = String.fromCharCode((c1 >> 6) | 192, (c1 & 63) | 128);
23779 } else {
23780 enc = String.fromCharCode((c1 >> 12) | 224, ((c1 >> 6) & 63) | 128, (c1 & 63) | 128);
23781 }
23782 if (enc !== null) {
23783 if (end > start) {
23784 utftext += string.substring(start, end);
23785 }
23786 utftext += enc;
23787 start = end = n + 1;
23788 }
23789 }
23790
23791 if (end > start) {
23792 utftext += string.substring(start, string.length);
23793 }
23794
23795 return utftext;
23796 };
23797
23798 _.UUID = function() {
23799 try {
23800 // use native Crypto API when available
23801 return win['crypto']['randomUUID']();
23802 } catch (err) {
23803 // fall back to generating our own UUID
23804 // based on https://gist.github.com/scwood/3bff42cc005cc20ab7ec98f0d8e1d59d
23805 var uuid = new Array(36);
23806 for (var i = 0; i < 36; i++) {
23807 uuid[i] = Math.floor(Math.random() * 16);
23808 }
23809 uuid[14] = 4; // set bits 12-15 of time-high-and-version to 0100
23810 uuid[19] = uuid[19] &= -5; // set bit 6 of clock-seq-and-reserved to zero
23811 uuid[19] = uuid[19] |= (1 << 3); // set bit 7 of clock-seq-and-reserved to one
23812 uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
23813
23814 return _.map(uuid, function(x) {
23815 return x.toString(16);
23816 }).join('');
23817 }
23818 };
23819
23820 // _.isBlockedUA()
23821 // This is to block various web spiders from executing our JS and
23822 // sending false tracking data
23823 var BLOCKED_UA_STRS = [
23824 'ahrefsbot',
23825 'ahrefssiteaudit',
23826 'amazonbot',
23827 'baiduspider',
23828 'bingbot',
23829 'bingpreview',
23830 'chrome-lighthouse',
23831 'facebookexternal',
23832 'petalbot',
23833 'pinterest',
23834 'screaming frog',
23835 'yahoo! slurp',
23836 'yandex',
23837
23838 // a whole bunch of goog-specific crawlers
23839 // https://developers.google.com/search/docs/advanced/crawling/overview-google-crawlers
23840 'adsbot-google',
23841 'apis-google',
23842 'duplexweb-google',
23843 'feedfetcher-google',
23844 'google favicon',
23845 'google web preview',
23846 'google-read-aloud',
23847 'googlebot',
23848 'googleweblight',
23849 'mediapartners-google',
23850 'storebot-google'
23851 ];
23852 _.isBlockedUA = function(ua) {
23853 var i;
23854 ua = ua.toLowerCase();
23855 for (i = 0; i < BLOCKED_UA_STRS.length; i++) {
23856 if (ua.indexOf(BLOCKED_UA_STRS[i]) !== -1) {
23857 return true;
23858 }
23859 }
23860 return false;
23861 };
23862
23863 /**
23864 * @param {Object=} formdata
23865 * @param {string=} arg_separator
23866 */
23867 _.HTTPBuildQuery = function(formdata, arg_separator) {
23868 var use_val, use_key, tmp_arr = [];
23869
23870 if (_.isUndefined(arg_separator)) {
23871 arg_separator = '&';
23872 }
23873
23874 _.each(formdata, function(val, key) {
23875 use_val = encodeURIComponent(val.toString());
23876 use_key = encodeURIComponent(key);
23877 tmp_arr[tmp_arr.length] = use_key + '=' + use_val;
23878 });
23879
23880 return tmp_arr.join(arg_separator);
23881 };
23882
23883 _.getQueryParam = function(url, param) {
23884 // Expects a raw URL
23885
23886 param = param.replace(/[[]/g, '\\[').replace(/[\]]/g, '\\]');
23887 var regexS = '[\\?&]' + param + '=([^&#]*)',
23888 regex = new RegExp(regexS),
23889 results = regex.exec(url);
23890 if (results === null || (results && typeof(results[1]) !== 'string' && results[1].length)) {
23891 return '';
23892 } else {
23893 var result = results[1];
23894 try {
23895 result = decodeURIComponent(result);
23896 } catch(err) {
23897 console$1.error('Skipping decoding for malformed query param: ' + result);
23898 }
23899 return result.replace(/\+/g, ' ');
23900 }
23901 };
23902
23903
23904 // _.cookie
23905 // Methods partially borrowed from quirksmode.org/js/cookies.html
23906 _.cookie = {
23907 get: function(name) {
23908 var nameEQ = name + '=';
23909 var ca = document$1.cookie.split(';');
23910 for (var i = 0; i < ca.length; i++) {
23911 var c = ca[i];
23912 while (c.charAt(0) == ' ') {
23913 c = c.substring(1, c.length);
23914 }
23915 if (c.indexOf(nameEQ) === 0) {
23916 return decodeURIComponent(c.substring(nameEQ.length, c.length));
23917 }
23918 }
23919 return null;
23920 },
23921
23922 parse: function(name) {
23923 var cookie;
23924 try {
23925 cookie = _.JSONDecode(_.cookie.get(name)) || {};
23926 } catch (err) {
23927 // noop
23928 }
23929 return cookie;
23930 },
23931
23932 set_seconds: function(name, value, seconds, is_cross_subdomain, is_secure, is_cross_site, domain_override) {
23933 var cdomain = '',
23934 expires = '',
23935 secure = '';
23936
23937 if (domain_override) {
23938 cdomain = '; domain=' + domain_override;
23939 } else if (is_cross_subdomain) {
23940 var domain = extract_domain(document$1.location.hostname);
23941 cdomain = domain ? '; domain=.' + domain : '';
23942 }
23943
23944 if (seconds) {
23945 var date = new Date();
23946 date.setTime(date.getTime() + (seconds * 1000));
23947 expires = '; expires=' + date.toGMTString();
23948 }
23949
23950 if (is_cross_site) {
23951 is_secure = true;
23952 secure = '; SameSite=None';
23953 }
23954 if (is_secure) {
23955 secure += '; secure';
23956 }
23957
23958 document$1.cookie = name + '=' + encodeURIComponent(value) + expires + '; path=/' + cdomain + secure;
23959 },
23960
23961 set: function(name, value, days, is_cross_subdomain, is_secure, is_cross_site, domain_override) {
23962 var cdomain = '', expires = '', secure = '';
23963
23964 if (domain_override) {
23965 cdomain = '; domain=' + domain_override;
23966 } else if (is_cross_subdomain) {
23967 var domain = extract_domain(document$1.location.hostname);
23968 cdomain = domain ? '; domain=.' + domain : '';
23969 }
23970
23971 if (days) {
23972 var date = new Date();
23973 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
23974 expires = '; expires=' + date.toGMTString();
23975 }
23976
23977 if (is_cross_site) {
23978 is_secure = true;
23979 secure = '; SameSite=None';
23980 }
23981 if (is_secure) {
23982 secure += '; secure';
23983 }
23984
23985 var new_cookie_val = name + '=' + encodeURIComponent(value) + expires + '; path=/' + cdomain + secure;
23986 document$1.cookie = new_cookie_val;
23987 return new_cookie_val;
23988 },
23989
23990 remove: function(name, is_cross_subdomain, domain_override) {
23991 _.cookie.set(name, '', -1, is_cross_subdomain, false, false, domain_override);
23992 }
23993 };
23994
23995 var _testStorageSupported = function (storage) {
23996 var supported = true;
23997 try {
23998 var key = '__mplss_' + cheap_guid(8),
23999 val = 'xyz';
24000 storage.setItem(key, val);
24001 if (storage.getItem(key) !== val) {
24002 supported = false;
24003 }
24004 storage.removeItem(key);
24005 } catch (err) {
24006 supported = false;
24007 }
24008 return supported;
24009 };
24010
24011 var _localStorageSupported = null;
24012 var localStorageSupported = function(storage, forceCheck) {
24013 if (_localStorageSupported !== null && !forceCheck) {
24014 return _localStorageSupported;
24015 }
24016 return _localStorageSupported = _testStorageSupported(storage || win.localStorage);
24017 };
24018
24019 var _sessionStorageSupported = null;
24020 var sessionStorageSupported = function(storage, forceCheck) {
24021 if (_sessionStorageSupported !== null && !forceCheck) {
24022 return _sessionStorageSupported;
24023 }
24024 return _sessionStorageSupported = _testStorageSupported(storage || win.sessionStorage);
24025 };
24026
24027 function _storageWrapper(storage, name, is_supported_fn) {
24028 var log_error = function(msg) {
24029 console$1.error(name + ' error: ' + msg);
24030 };
24031
24032 return {
24033 is_supported: function(forceCheck) {
24034 var supported = is_supported_fn(storage, forceCheck);
24035 if (!supported) {
24036 console$1.error(name + ' unsupported');
24037 }
24038 return supported;
24039 },
24040 error: log_error,
24041 get: function(key) {
24042 try {
24043 return storage.getItem(key);
24044 } catch (err) {
24045 log_error(err);
24046 }
24047 return null;
24048 },
24049 parse: function(key) {
24050 try {
24051 return _.JSONDecode(storage.getItem(key)) || {};
24052 } catch (err) {
24053 // noop
24054 }
24055 return null;
24056 },
24057 set: function(key, value) {
24058 try {
24059 storage.setItem(key, value);
24060 } catch (err) {
24061 log_error(err);
24062 }
24063 },
24064 remove: function(key) {
24065 try {
24066 storage.removeItem(key);
24067 } catch (err) {
24068 log_error(err);
24069 }
24070 }
24071 };
24072 }
24073
24074 _.localStorage = _storageWrapper(win.localStorage, 'localStorage', localStorageSupported);
24075 _.sessionStorage = _storageWrapper(win.sessionStorage, 'sessionStorage', sessionStorageSupported);
24076
24077 _.register_event = (function() {
24078 // written by Dean Edwards, 2005
24079 // with input from Tino Zijdel - crisp@xs4all.nl
24080 // with input from Carl Sverre - mail@carlsverre.com
24081 // with input from Mixpanel
24082 // http://dean.edwards.name/weblog/2005/10/add-event/
24083 // https://gist.github.com/1930440
24084
24085 /**
24086 * @param {Object} element
24087 * @param {string} type
24088 * @param {function(...*)} handler
24089 * @param {boolean=} oldSchool
24090 * @param {boolean=} useCapture
24091 */
24092 var register_event = function(element, type, handler, oldSchool, useCapture) {
24093 if (!element) {
24094 console$1.error('No valid element provided to register_event');
24095 return;
24096 }
24097
24098 if (element.addEventListener && !oldSchool) {
24099 element.addEventListener(type, handler, !!useCapture);
24100 } else {
24101 var ontype = 'on' + type;
24102 var old_handler = element[ontype]; // can be undefined
24103 element[ontype] = makeHandler(element, handler, old_handler);
24104 }
24105 };
24106
24107 function makeHandler(element, new_handler, old_handlers) {
24108 var handler = function(event) {
24109 event = event || fixEvent(win.event);
24110
24111 // this basically happens in firefox whenever another script
24112 // overwrites the onload callback and doesn't pass the event
24113 // object to previously defined callbacks. All the browsers
24114 // that don't define window.event implement addEventListener
24115 // so the dom_loaded handler will still be fired as usual.
24116 if (!event) {
24117 return undefined;
24118 }
24119
24120 var ret = true;
24121 var old_result, new_result;
24122
24123 if (_.isFunction(old_handlers)) {
24124 old_result = old_handlers(event);
24125 }
24126 new_result = new_handler.call(element, event);
24127
24128 if ((false === old_result) || (false === new_result)) {
24129 ret = false;
24130 }
24131
24132 return ret;
24133 };
24134
24135 return handler;
24136 }
24137
24138 function fixEvent(event) {
24139 if (event) {
24140 event.preventDefault = fixEvent.preventDefault;
24141 event.stopPropagation = fixEvent.stopPropagation;
24142 }
24143 return event;
24144 }
24145 fixEvent.preventDefault = function() {
24146 this.returnValue = false;
24147 };
24148 fixEvent.stopPropagation = function() {
24149 this.cancelBubble = true;
24150 };
24151
24152 return register_event;
24153 })();
24154
24155
24156 var TOKEN_MATCH_REGEX = new RegExp('^(\\w*)\\[(\\w+)([=~\\|\\^\\$\\*]?)=?"?([^\\]"]*)"?\\]$');
24157
24158 _.dom_query = (function() {
24159 /* document.getElementsBySelector(selector)
24160 - returns an array of element objects from the current document
24161 matching the CSS selector. Selectors can contain element names,
24162 class names and ids and can be nested. For example:
24163
24164 elements = document.getElementsBySelector('div#main p a.external')
24165
24166 Will return an array of all 'a' elements with 'external' in their
24167 class attribute that are contained inside 'p' elements that are
24168 contained inside the 'div' element which has id="main"
24169
24170 New in version 0.4: Support for CSS2 and CSS3 attribute selectors:
24171 See http://www.w3.org/TR/css3-selectors/#attribute-selectors
24172
24173 Version 0.4 - Simon Willison, March 25th 2003
24174 -- Works in Phoenix 0.5, Mozilla 1.3, Opera 7, Internet Explorer 6, Internet Explorer 5 on Windows
24175 -- Opera 7 fails
24176
24177 Version 0.5 - Carl Sverre, Jan 7th 2013
24178 -- Now uses jQuery-esque `hasClass` for testing class name
24179 equality. This fixes a bug related to '-' characters being
24180 considered not part of a 'word' in regex.
24181 */
24182
24183 function getAllChildren(e) {
24184 // Returns all children of element. Workaround required for IE5/Windows. Ugh.
24185 return e.all ? e.all : e.getElementsByTagName('*');
24186 }
24187
24188 var bad_whitespace = /[\t\r\n]/g;
24189
24190 function hasClass(elem, selector) {
24191 var className = ' ' + selector + ' ';
24192 return ((' ' + elem.className + ' ').replace(bad_whitespace, ' ').indexOf(className) >= 0);
24193 }
24194
24195 function getElementsBySelector(selector) {
24196 // Attempt to fail gracefully in lesser browsers
24197 if (!document$1.getElementsByTagName) {
24198 return [];
24199 }
24200 // Split selector in to tokens
24201 var tokens = selector.split(' ');
24202 var token, bits, tagName, found, foundCount, i, j, k, elements, currentContextIndex;
24203 var currentContext = [document$1];
24204 for (i = 0; i < tokens.length; i++) {
24205 token = tokens[i].replace(/^\s+/, '').replace(/\s+$/, '');
24206 if (token.indexOf('#') > -1) {
24207 // Token is an ID selector
24208 bits = token.split('#');
24209 tagName = bits[0];
24210 var id = bits[1];
24211 var element = document$1.getElementById(id);
24212 if (!element || (tagName && element.nodeName.toLowerCase() != tagName)) {
24213 // element not found or tag with that ID not found, return false
24214 return [];
24215 }
24216 // Set currentContext to contain just this element
24217 currentContext = [element];
24218 continue; // Skip to next token
24219 }
24220 if (token.indexOf('.') > -1) {
24221 // Token contains a class selector
24222 bits = token.split('.');
24223 tagName = bits[0];
24224 var className = bits[1];
24225 if (!tagName) {
24226 tagName = '*';
24227 }
24228 // Get elements matching tag, filter them for class selector
24229 found = [];
24230 foundCount = 0;
24231 for (j = 0; j < currentContext.length; j++) {
24232 if (tagName == '*') {
24233 elements = getAllChildren(currentContext[j]);
24234 } else {
24235 elements = currentContext[j].getElementsByTagName(tagName);
24236 }
24237 for (k = 0; k < elements.length; k++) {
24238 found[foundCount++] = elements[k];
24239 }
24240 }
24241 currentContext = [];
24242 currentContextIndex = 0;
24243 for (j = 0; j < found.length; j++) {
24244 if (found[j].className &&
24245 _.isString(found[j].className) && // some SVG elements have classNames which are not strings
24246 hasClass(found[j], className)
24247 ) {
24248 currentContext[currentContextIndex++] = found[j];
24249 }
24250 }
24251 continue; // Skip to next token
24252 }
24253 // Code to deal with attribute selectors
24254 var token_match = token.match(TOKEN_MATCH_REGEX);
24255 if (token_match) {
24256 tagName = token_match[1];
24257 var attrName = token_match[2];
24258 var attrOperator = token_match[3];
24259 var attrValue = token_match[4];
24260 if (!tagName) {
24261 tagName = '*';
24262 }
24263 // Grab all of the tagName elements within current context
24264 found = [];
24265 foundCount = 0;
24266 for (j = 0; j < currentContext.length; j++) {
24267 if (tagName == '*') {
24268 elements = getAllChildren(currentContext[j]);
24269 } else {
24270 elements = currentContext[j].getElementsByTagName(tagName);
24271 }
24272 for (k = 0; k < elements.length; k++) {
24273 found[foundCount++] = elements[k];
24274 }
24275 }
24276 currentContext = [];
24277 currentContextIndex = 0;
24278 var checkFunction; // This function will be used to filter the elements
24279 switch (attrOperator) {
24280 case '=': // Equality
24281 checkFunction = function(e) {
24282 return (e.getAttribute(attrName) == attrValue);
24283 };
24284 break;
24285 case '~': // Match one of space seperated words
24286 checkFunction = function(e) {
24287 return (e.getAttribute(attrName).match(new RegExp('\\b' + attrValue + '\\b')));
24288 };
24289 break;
24290 case '|': // Match start with value followed by optional hyphen
24291 checkFunction = function(e) {
24292 return (e.getAttribute(attrName).match(new RegExp('^' + attrValue + '-?')));
24293 };
24294 break;
24295 case '^': // Match starts with value
24296 checkFunction = function(e) {
24297 return (e.getAttribute(attrName).indexOf(attrValue) === 0);
24298 };
24299 break;
24300 case '$': // Match ends with value - fails with "Warning" in Opera 7
24301 checkFunction = function(e) {
24302 return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length);
24303 };
24304 break;
24305 case '*': // Match ends with value
24306 checkFunction = function(e) {
24307 return (e.getAttribute(attrName).indexOf(attrValue) > -1);
24308 };
24309 break;
24310 default:
24311 // Just test for existence of attribute
24312 checkFunction = function(e) {
24313 return e.getAttribute(attrName);
24314 };
24315 }
24316 currentContext = [];
24317 currentContextIndex = 0;
24318 for (j = 0; j < found.length; j++) {
24319 if (checkFunction(found[j])) {
24320 currentContext[currentContextIndex++] = found[j];
24321 }
24322 }
24323 // alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue);
24324 continue; // Skip to next token
24325 }
24326 // If we get here, token is JUST an element (not a class or ID selector)
24327 tagName = token;
24328 found = [];
24329 foundCount = 0;
24330 for (j = 0; j < currentContext.length; j++) {
24331 elements = currentContext[j].getElementsByTagName(tagName);
24332 for (k = 0; k < elements.length; k++) {
24333 found[foundCount++] = elements[k];
24334 }
24335 }
24336 currentContext = found;
24337 }
24338 return currentContext;
24339 }
24340
24341 return function(query) {
24342 if (_.isElement(query)) {
24343 return [query];
24344 } else if (_.isObject(query) && !_.isUndefined(query.length)) {
24345 return query;
24346 } else {
24347 return getElementsBySelector.call(this, query);
24348 }
24349 };
24350 })();
24351
24352 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'];
24353 var CLICK_IDS = ['dclid', 'fbclid', 'gclid', 'ko_click_id', 'li_fat_id', 'msclkid', 'sccid', 'ttclid', 'twclid', 'wbraid'];
24354
24355 _.info = {
24356 campaignParams: function(default_value) {
24357 var kw = '',
24358 params = {};
24359 _.each(CAMPAIGN_KEYWORDS, function(kwkey) {
24360 kw = _.getQueryParam(document$1.URL, kwkey);
24361 if (kw.length) {
24362 params[kwkey] = kw;
24363 } else if (default_value !== undefined) {
24364 params[kwkey] = default_value;
24365 }
24366 });
24367
24368 return params;
24369 },
24370
24371 clickParams: function() {
24372 var id = '',
24373 params = {};
24374 _.each(CLICK_IDS, function(idkey) {
24375 id = _.getQueryParam(document$1.URL, idkey);
24376 if (id.length) {
24377 params[idkey] = id;
24378 }
24379 });
24380
24381 return params;
24382 },
24383
24384 marketingParams: function() {
24385 return _.extend(_.info.campaignParams(), _.info.clickParams());
24386 },
24387
24388 searchEngine: function(referrer) {
24389 if (referrer.search('https?://(.*)google.([^/?]*)') === 0) {
24390 return 'google';
24391 } else if (referrer.search('https?://(.*)bing.com') === 0) {
24392 return 'bing';
24393 } else if (referrer.search('https?://(.*)yahoo.com') === 0) {
24394 return 'yahoo';
24395 } else if (referrer.search('https?://(.*)duckduckgo.com') === 0) {
24396 return 'duckduckgo';
24397 } else {
24398 return null;
24399 }
24400 },
24401
24402 searchInfo: function(referrer) {
24403 var search = _.info.searchEngine(referrer),
24404 param = (search != 'yahoo') ? 'q' : 'p',
24405 ret = {};
24406
24407 if (search !== null) {
24408 ret['$search_engine'] = search;
24409
24410 var keyword = _.getQueryParam(referrer, param);
24411 if (keyword.length) {
24412 ret['mp_keyword'] = keyword;
24413 }
24414 }
24415
24416 return ret;
24417 },
24418
24419 /**
24420 * This function detects which browser is running this script.
24421 * The order of the checks are important since many user agents
24422 * include key words used in later checks.
24423 */
24424 browser: function(user_agent, vendor, opera) {
24425 vendor = vendor || ''; // vendor is undefined for at least IE9
24426 if (opera || _.includes(user_agent, ' OPR/')) {
24427 if (_.includes(user_agent, 'Mini')) {
24428 return 'Opera Mini';
24429 }
24430 return 'Opera';
24431 } else if (/(BlackBerry|PlayBook|BB10)/i.test(user_agent)) {
24432 return 'BlackBerry';
24433 } else if (_.includes(user_agent, 'IEMobile') || _.includes(user_agent, 'WPDesktop')) {
24434 return 'Internet Explorer Mobile';
24435 } else if (_.includes(user_agent, 'SamsungBrowser/')) {
24436 // https://developer.samsung.com/internet/user-agent-string-format
24437 return 'Samsung Internet';
24438 } else if (_.includes(user_agent, 'Edge') || _.includes(user_agent, 'Edg/')) {
24439 return 'Microsoft Edge';
24440 } else if (_.includes(user_agent, 'FBIOS')) {
24441 return 'Facebook Mobile';
24442 } else if (_.includes(user_agent, 'Whale/')) {
24443 // https://user-agents.net/browsers/whale-browser
24444 return 'Whale Browser';
24445 } else if (_.includes(user_agent, 'Chrome')) {
24446 return 'Chrome';
24447 } else if (_.includes(user_agent, 'CriOS')) {
24448 return 'Chrome iOS';
24449 } else if (_.includes(user_agent, 'UCWEB') || _.includes(user_agent, 'UCBrowser')) {
24450 return 'UC Browser';
24451 } else if (_.includes(user_agent, 'FxiOS')) {
24452 return 'Firefox iOS';
24453 } else if (_.includes(vendor, 'Apple')) {
24454 if (_.includes(user_agent, 'Mobile')) {
24455 return 'Mobile Safari';
24456 }
24457 return 'Safari';
24458 } else if (_.includes(user_agent, 'Android')) {
24459 return 'Android Mobile';
24460 } else if (_.includes(user_agent, 'Konqueror')) {
24461 return 'Konqueror';
24462 } else if (_.includes(user_agent, 'Firefox')) {
24463 return 'Firefox';
24464 } else if (_.includes(user_agent, 'MSIE') || _.includes(user_agent, 'Trident/')) {
24465 return 'Internet Explorer';
24466 } else if (_.includes(user_agent, 'Gecko')) {
24467 return 'Mozilla';
24468 } else {
24469 return '';
24470 }
24471 },
24472
24473 /**
24474 * This function detects which browser version is running this script,
24475 * parsing major and minor version (e.g., 42.1). User agent strings from:
24476 * http://www.useragentstring.com/pages/useragentstring.php
24477 */
24478 browserVersion: function(userAgent, vendor, opera) {
24479 var browser = _.info.browser(userAgent, vendor, opera);
24480 var versionRegexs = {
24481 'Internet Explorer Mobile': /rv:(\d+(\.\d+)?)/,
24482 'Microsoft Edge': /Edge?\/(\d+(\.\d+)?)/,
24483 'Chrome': /Chrome\/(\d+(\.\d+)?)/,
24484 'Chrome iOS': /CriOS\/(\d+(\.\d+)?)/,
24485 'UC Browser' : /(UCBrowser|UCWEB)\/(\d+(\.\d+)?)/,
24486 'Safari': /Version\/(\d+(\.\d+)?)/,
24487 'Mobile Safari': /Version\/(\d+(\.\d+)?)/,
24488 'Opera': /(Opera|OPR)\/(\d+(\.\d+)?)/,
24489 'Firefox': /Firefox\/(\d+(\.\d+)?)/,
24490 'Firefox iOS': /FxiOS\/(\d+(\.\d+)?)/,
24491 'Konqueror': /Konqueror:(\d+(\.\d+)?)/,
24492 'BlackBerry': /BlackBerry (\d+(\.\d+)?)/,
24493 'Android Mobile': /android\s(\d+(\.\d+)?)/,
24494 'Samsung Internet': /SamsungBrowser\/(\d+(\.\d+)?)/,
24495 'Internet Explorer': /(rv:|MSIE )(\d+(\.\d+)?)/,
24496 'Mozilla': /rv:(\d+(\.\d+)?)/,
24497 'Whale Browser': /Whale\/(\d+(\.\d+)?)/
24498 };
24499 var regex = versionRegexs[browser];
24500 if (regex === undefined) {
24501 return null;
24502 }
24503 var matches = userAgent.match(regex);
24504 if (!matches) {
24505 return null;
24506 }
24507 return parseFloat(matches[matches.length - 2]);
24508 },
24509
24510 os: function() {
24511 var a = userAgent;
24512 if (/Windows/i.test(a)) {
24513 if (/Phone/.test(a) || /WPDesktop/.test(a)) {
24514 return 'Windows Phone';
24515 }
24516 return 'Windows';
24517 } else if (/(iPhone|iPad|iPod)/.test(a)) {
24518 return 'iOS';
24519 } else if (/Android/.test(a)) {
24520 return 'Android';
24521 } else if (/(BlackBerry|PlayBook|BB10)/i.test(a)) {
24522 return 'BlackBerry';
24523 } else if (/Mac/i.test(a)) {
24524 return 'Mac OS X';
24525 } else if (/Linux/.test(a)) {
24526 return 'Linux';
24527 } else if (/CrOS/.test(a)) {
24528 return 'Chrome OS';
24529 } else {
24530 return '';
24531 }
24532 },
24533
24534 device: function(user_agent) {
24535 if (/Windows Phone/i.test(user_agent) || /WPDesktop/.test(user_agent)) {
24536 return 'Windows Phone';
24537 } else if (/iPad/.test(user_agent)) {
24538 return 'iPad';
24539 } else if (/iPod/.test(user_agent)) {
24540 return 'iPod Touch';
24541 } else if (/iPhone/.test(user_agent)) {
24542 return 'iPhone';
24543 } else if (/(BlackBerry|PlayBook|BB10)/i.test(user_agent)) {
24544 return 'BlackBerry';
24545 } else if (/Android/.test(user_agent)) {
24546 return 'Android';
24547 } else {
24548 return '';
24549 }
24550 },
24551
24552 referringDomain: function(referrer) {
24553 var split = referrer.split('/');
24554 if (split.length >= 3) {
24555 return split[2];
24556 }
24557 return '';
24558 },
24559
24560 currentUrl: function() {
24561 return win.location.href;
24562 },
24563
24564 properties: function(extra_props) {
24565 if (typeof extra_props !== 'object') {
24566 extra_props = {};
24567 }
24568 return _.extend(_.strip_empty_properties({
24569 '$os': _.info.os(),
24570 '$browser': _.info.browser(userAgent, navigator.vendor, windowOpera),
24571 '$referrer': document$1.referrer,
24572 '$referring_domain': _.info.referringDomain(document$1.referrer),
24573 '$device': _.info.device(userAgent)
24574 }), {
24575 '$current_url': _.info.currentUrl(),
24576 '$browser_version': _.info.browserVersion(userAgent, navigator.vendor, windowOpera),
24577 '$screen_height': screen.height,
24578 '$screen_width': screen.width,
24579 'mp_lib': 'web',
24580 '$lib_version': Config.LIB_VERSION,
24581 '$insert_id': cheap_guid(),
24582 'time': _.timestamp() / 1000 // epoch time in seconds
24583 }, _.strip_empty_properties(extra_props));
24584 },
24585
24586 people_properties: function() {
24587 return _.extend(_.strip_empty_properties({
24588 '$os': _.info.os(),
24589 '$browser': _.info.browser(userAgent, navigator.vendor, windowOpera)
24590 }), {
24591 '$browser_version': _.info.browserVersion(userAgent, navigator.vendor, windowOpera)
24592 });
24593 },
24594
24595 mpPageViewProperties: function() {
24596 return _.strip_empty_properties({
24597 'current_page_title': document$1.title,
24598 'current_domain': win.location.hostname,
24599 'current_url_path': win.location.pathname,
24600 'current_url_protocol': win.location.protocol,
24601 'current_url_search': win.location.search
24602 });
24603 }
24604 };
24605
24606 /**
24607 * Returns a throttled function that will only run at most every `waitMs` and returns a promise that resolves with the next invocation.
24608 * Throttled calls will build up a batch of args and invoke the callback with all args since the last invocation.
24609 */
24610 var batchedThrottle = function (fn, waitMs) {
24611 var timeoutPromise = null;
24612 var throttledItems = [];
24613 return function (item) {
24614 var self = this;
24615 throttledItems.push(item);
24616
24617 if (!timeoutPromise) {
24618 timeoutPromise = new PromisePolyfill(function (resolve) {
24619 setTimeout(function () {
24620 var returnValue = fn.apply(self, [throttledItems]);
24621 timeoutPromise = null;
24622 throttledItems = [];
24623 resolve(returnValue);
24624 }, waitMs);
24625 });
24626 }
24627 return timeoutPromise;
24628 };
24629 };
24630
24631 var cheap_guid = function(maxlen) {
24632 var guid = Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10);
24633 return maxlen ? guid.substring(0, maxlen) : guid;
24634 };
24635
24636 /**
24637 * Generates a W3C traceparent header for easy interop with distributed tracing systems i.e Open Telemetry
24638 * https://www.w3.org/TR/trace-context/#traceparent-header
24639 */
24640 var generateTraceparent = function() {
24641 var traceID = _.UUID().replace(/-/g, '');
24642 var parentID = _.UUID().replace(/-/g, '').substring(0, 16);
24643
24644 // Sampled trace
24645 var traceFlags = '01';
24646
24647 return '00-' + traceID + '-' + parentID + '-' + traceFlags;
24648 };
24649
24650 // naive way to extract domain name (example.com) from full hostname (my.sub.example.com)
24651 var SIMPLE_DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]*\.[a-z]+$/i;
24652 // this next one attempts to account for some ccSLDs, e.g. extracting oxford.ac.uk from www.oxford.ac.uk
24653 var DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i;
24654 /**
24655 * Attempts to extract main domain name from full hostname, using a few blunt heuristics. For
24656 * common TLDs like .com/.org that always have a simple SLD.TLD structure (example.com), we
24657 * simply extract the last two .-separated parts of the hostname (SIMPLE_DOMAIN_MATCH_REGEX).
24658 * For others, we attempt to account for short ccSLD+TLD combos (.ac.uk) with the legacy
24659 * DOMAIN_MATCH_REGEX (kept to maintain backwards compatibility with existing Mixpanel
24660 * integrations). The only _reliable_ way to extract domain from hostname is with an up-to-date
24661 * list like at https://publicsuffix.org/ so for cases that this helper fails at, the SDK
24662 * offers the 'cookie_domain' config option to set it explicitly.
24663 * @example
24664 * extract_domain('my.sub.example.com')
24665 * // 'example.com'
24666 */
24667 var extract_domain = function(hostname) {
24668 var domain_regex = DOMAIN_MATCH_REGEX;
24669 var parts = hostname.split('.');
24670 var tld = parts[parts.length - 1];
24671 if (tld.length > 4 || tld === 'com' || tld === 'org') {
24672 domain_regex = SIMPLE_DOMAIN_MATCH_REGEX;
24673 }
24674 var matches = hostname.match(domain_regex);
24675 return matches ? matches[0] : '';
24676 };
24677
24678 /**
24679 * Check whether we have network connection. default to true for browsers that don't support navigator.onLine (IE)
24680 * @returns {boolean}
24681 */
24682 var isOnline = function() {
24683 var onLine = win.navigator['onLine'];
24684 return _.isUndefined(onLine) || onLine;
24685 };
24686
24687 var NOOP_FUNC = function () {};
24688
24689 var JSONStringify = null, JSONParse = null;
24690 if (typeof JSON !== 'undefined') {
24691 JSONStringify = JSON.stringify;
24692 JSONParse = JSON.parse;
24693 }
24694 JSONStringify = JSONStringify || _.JSONEncode;
24695 JSONParse = JSONParse || _.JSONDecode;
24696
24697 // UNMINIFIED EXPORTS (for closure compiler)
24698 _['info'] = _.info;
24699 _['info']['browser'] = _.info.browser;
24700 _['info']['browserVersion'] = _.info.browserVersion;
24701 _['info']['device'] = _.info.device;
24702 _['info']['properties'] = _.info.properties;
24703 _['isBlockedUA'] = _.isBlockedUA;
24704 _['isEmptyObject'] = _.isEmptyObject;
24705 _['isObject'] = _.isObject;
24706 _['JSONDecode'] = _.JSONDecode;
24707 _['JSONEncode'] = _.JSONEncode;
24708 _['toArray'] = _.toArray;
24709 _['NPO'] = NpoPromise;
24710
24711 var MIXPANEL_DB_NAME = 'mixpanelBrowserDb';
24712
24713 var RECORDING_EVENTS_STORE_NAME = 'mixpanelRecordingEvents';
24714 var RECORDING_REGISTRY_STORE_NAME = 'mixpanelRecordingRegistry';
24715
24716 // note: increment the version number when adding new object stores
24717 var DB_VERSION = 1;
24718 var OBJECT_STORES = [RECORDING_EVENTS_STORE_NAME, RECORDING_REGISTRY_STORE_NAME];
24719
24720 /**
24721 * @type {import('./wrapper').StorageWrapper}
24722 */
24723 var IDBStorageWrapper = function (storeName) {
24724 /**
24725 * @type {Promise<IDBDatabase>|null}
24726 */
24727 this.dbPromise = null;
24728 this.storeName = storeName;
24729 };
24730
24731 IDBStorageWrapper.prototype._openDb = function () {
24732 return new PromisePolyfill(function (resolve, reject) {
24733 var openRequest = win.indexedDB.open(MIXPANEL_DB_NAME, DB_VERSION);
24734 openRequest['onerror'] = function () {
24735 reject(openRequest.error);
24736 };
24737
24738 openRequest['onsuccess'] = function () {
24739 resolve(openRequest.result);
24740 };
24741
24742 openRequest['onupgradeneeded'] = function (ev) {
24743 var db = ev.target.result;
24744
24745 OBJECT_STORES.forEach(function (storeName) {
24746 db.createObjectStore(storeName);
24747 });
24748 };
24749 });
24750 };
24751
24752 IDBStorageWrapper.prototype.init = function () {
24753 if (!win.indexedDB) {
24754 return PromisePolyfill.reject('indexedDB is not supported in this browser');
24755 }
24756
24757 if (!this.dbPromise) {
24758 this.dbPromise = this._openDb();
24759 }
24760
24761 return this.dbPromise
24762 .then(function (dbOrError) {
24763 if (dbOrError instanceof win['IDBDatabase']) {
24764 return PromisePolyfill.resolve();
24765 } else {
24766 return PromisePolyfill.reject(dbOrError);
24767 }
24768 });
24769 };
24770
24771 IDBStorageWrapper.prototype.isInitialized = function () {
24772 return !!this.dbPromise;
24773 };
24774
24775 /**
24776 * @param {IDBTransactionMode} mode
24777 * @param {function(IDBObjectStore): void} storeCb
24778 */
24779 IDBStorageWrapper.prototype.makeTransaction = function (mode, storeCb) {
24780 var storeName = this.storeName;
24781 var doTransaction = function (db) {
24782 return new PromisePolyfill(function (resolve, reject) {
24783 var transaction = db.transaction(storeName, mode);
24784 transaction.oncomplete = function () {
24785 resolve(transaction);
24786 };
24787 transaction.onabort = transaction.onerror = function () {
24788 reject(transaction.error);
24789 };
24790
24791 storeCb(transaction.objectStore(storeName));
24792 });
24793 };
24794
24795 return this.dbPromise
24796 .then(doTransaction)
24797 .catch(function (err) {
24798 if (err && err['name'] === 'InvalidStateError') {
24799 // try reopening the DB if the connection is closed
24800 this.dbPromise = this._openDb();
24801 return this.dbPromise.then(doTransaction);
24802 } else {
24803 return PromisePolyfill.reject(err);
24804 }
24805 }.bind(this));
24806 };
24807
24808 IDBStorageWrapper.prototype.setItem = function (key, value) {
24809 return this.makeTransaction('readwrite', function (objectStore) {
24810 objectStore.put(value, key);
24811 });
24812 };
24813
24814 IDBStorageWrapper.prototype.getItem = function (key) {
24815 var req;
24816 return this.makeTransaction('readonly', function (objectStore) {
24817 req = objectStore.get(key);
24818 }).then(function () {
24819 return req.result;
24820 });
24821 };
24822
24823 IDBStorageWrapper.prototype.removeItem = function (key) {
24824 return this.makeTransaction('readwrite', function (objectStore) {
24825 objectStore.delete(key);
24826 });
24827 };
24828
24829 IDBStorageWrapper.prototype.getAll = function () {
24830 var req;
24831 return this.makeTransaction('readonly', function (objectStore) {
24832 req = objectStore.getAll();
24833 }).then(function () {
24834 return req.result;
24835 });
24836 };
24837
24838 /**
24839 * GDPR utils
24840 *
24841 * The General Data Protection Regulation (GDPR) is a regulation in EU law on data protection
24842 * and privacy for all individuals within the European Union. It addresses the export of personal
24843 * data outside the EU. The GDPR aims primarily to give control back to citizens and residents
24844 * over their personal data and to simplify the regulatory environment for international business
24845 * by unifying the regulation within the EU.
24846 *
24847 * This set of utilities is intended to enable opt in/out functionality in the Mixpanel JS SDK.
24848 * These functions are used internally by the SDK and are not intended to be publicly exposed.
24849 */
24850
24851
24852 /**
24853 * A function used to track a Mixpanel event (e.g. MixpanelLib.track)
24854 * @callback trackFunction
24855 * @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
24856 * @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.
24857 * @param {Function} [callback] If provided, the callback function will be called after tracking the event.
24858 */
24859
24860 /** Public **/
24861
24862 var GDPR_DEFAULT_PERSISTENCE_PREFIX = '__mp_opt_in_out_';
24863
24864 /**
24865 * Opt the user in to data tracking and cookies/localstorage for the given token
24866 * @param {string} token - Mixpanel project tracking token
24867 * @param {Object} [options]
24868 * @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
24869 * @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
24870 * @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
24871 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24872 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24873 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24874 * @param {string} [options.cookieDomain] - custom cookie domain
24875 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24876 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24877 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24878 */
24879 function optIn(token, options) {
24880 _optInOut(true, token, options);
24881 }
24882
24883 /**
24884 * Opt the user out of data tracking and cookies/localstorage for the given token
24885 * @param {string} token - Mixpanel project tracking token
24886 * @param {Object} [options]
24887 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24888 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24889 * @param {Number} [options.cookieExpiration] - number of days until the opt-out cookie expires
24890 * @param {string} [options.cookieDomain] - custom cookie domain
24891 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24892 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-out cookie is set as cross-subdomain or not
24893 * @param {boolean} [options.secureCookie] - whether the opt-out cookie is set as secure or not
24894 */
24895 function optOut(token, options) {
24896 _optInOut(false, token, options);
24897 }
24898
24899 /**
24900 * Check whether the user has opted in to data tracking and cookies/localstorage for the given token
24901 * @param {string} token - Mixpanel project tracking token
24902 * @param {Object} [options]
24903 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24904 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24905 * @returns {boolean} whether the user has opted in to the given opt type
24906 */
24907 function hasOptedIn(token, options) {
24908 return _getStorageValue(token, options) === '1';
24909 }
24910
24911 /**
24912 * Check whether the user has opted out of data tracking and cookies/localstorage for the given token
24913 * @param {string} token - Mixpanel project tracking token
24914 * @param {Object} [options]
24915 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24916 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24917 * @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
24918 * @returns {boolean} whether the user has opted out of the given opt type
24919 */
24920 function hasOptedOut(token, options) {
24921 if (_hasDoNotTrackFlagOn(options)) {
24922 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"');
24923 return true;
24924 }
24925 var optedOut = _getStorageValue(token, options) === '0';
24926 if (optedOut) {
24927 console$1.warn('You are opted out of Mixpanel tracking. This will prevent the Mixpanel SDK from sending any data.');
24928 }
24929 return optedOut;
24930 }
24931
24932 /**
24933 * Wrap a MixpanelLib method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24934 * If the user has opted out, return early instead of executing the method.
24935 * If a callback argument was provided, execute it passing the 0 error code.
24936 * @param {function} method - wrapped method to be executed if the user has not opted out
24937 * @returns {*} the result of executing method OR undefined if the user has opted out
24938 */
24939 function addOptOutCheckMixpanelLib(method) {
24940 return _addOptOutCheck(method, function(name) {
24941 return this.get_config(name);
24942 });
24943 }
24944
24945 /**
24946 * Wrap a MixpanelPeople method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24947 * If the user has opted out, return early instead of executing the method.
24948 * If a callback argument was provided, execute it passing the 0 error code.
24949 * @param {function} method - wrapped method to be executed if the user has not opted out
24950 * @returns {*} the result of executing method OR undefined if the user has opted out
24951 */
24952 function addOptOutCheckMixpanelPeople(method) {
24953 return _addOptOutCheck(method, function(name) {
24954 return this._get_config(name);
24955 });
24956 }
24957
24958 /**
24959 * Wrap a MixpanelGroup method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24960 * If the user has opted out, return early instead of executing the method.
24961 * If a callback argument was provided, execute it passing the 0 error code.
24962 * @param {function} method - wrapped method to be executed if the user has not opted out
24963 * @returns {*} the result of executing method OR undefined if the user has opted out
24964 */
24965 function addOptOutCheckMixpanelGroup(method) {
24966 return _addOptOutCheck(method, function(name) {
24967 return this._get_config(name);
24968 });
24969 }
24970
24971 /**
24972 * Clear the user's opt in/out status of data tracking and cookies/localstorage for the given token
24973 * @param {string} token - Mixpanel project tracking token
24974 * @param {Object} [options]
24975 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24976 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24977 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24978 * @param {string} [options.cookieDomain] - custom cookie domain
24979 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24980 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24981 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24982 */
24983 function clearOptInOut(token, options) {
24984 options = options || {};
24985 _getStorage(options).remove(
24986 _getStorageKey(token, options), !!options.crossSubdomainCookie, options.cookieDomain
24987 );
24988 }
24989
24990 /** Private **/
24991
24992 /**
24993 * Get storage util
24994 * @param {Object} [options]
24995 * @param {string} [options.persistenceType]
24996 * @returns {object} either _.cookie or _.localstorage
24997 */
24998 function _getStorage(options) {
24999 options = options || {};
25000 return options.persistenceType === 'localStorage' ? _.localStorage : _.cookie;
25001 }
25002
25003 /**
25004 * Get the name of the cookie that is used for the given opt type (tracking, cookie, etc.)
25005 * @param {string} token - Mixpanel project tracking token
25006 * @param {Object} [options]
25007 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
25008 * @returns {string} the name of the cookie for the given opt type
25009 */
25010 function _getStorageKey(token, options) {
25011 options = options || {};
25012 return (options.persistencePrefix || GDPR_DEFAULT_PERSISTENCE_PREFIX) + token;
25013 }
25014
25015 /**
25016 * Get the value of the cookie that is used for the given opt type (tracking, cookie, etc.)
25017 * @param {string} token - Mixpanel project tracking token
25018 * @param {Object} [options]
25019 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
25020 * @returns {string} the value of the cookie for the given opt type
25021 */
25022 function _getStorageValue(token, options) {
25023 return _getStorage(options).get(_getStorageKey(token, options));
25024 }
25025
25026 /**
25027 * Check whether the user has set the DNT/doNotTrack setting to true in their browser
25028 * @param {Object} [options]
25029 * @param {string} [options.window] - alternate window object to check; used to force various DNT settings in browser tests
25030 * @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
25031 * @returns {boolean} whether the DNT setting is true
25032 */
25033 function _hasDoNotTrackFlagOn(options) {
25034 if (options && options.ignoreDnt) {
25035 return false;
25036 }
25037 var win$1 = (options && options.window) || win;
25038 var nav = win$1['navigator'] || {};
25039 var hasDntOn = false;
25040
25041 _.each([
25042 nav['doNotTrack'], // standard
25043 nav['msDoNotTrack'],
25044 win$1['doNotTrack']
25045 ], function(dntValue) {
25046 if (_.includes([true, 1, '1', 'yes'], dntValue)) {
25047 hasDntOn = true;
25048 }
25049 });
25050
25051 return hasDntOn;
25052 }
25053
25054 /**
25055 * Set cookie/localstorage for the user indicating that they are opted in or out for the given opt type
25056 * @param {boolean} optValue - whether to opt the user in or out for the given opt type
25057 * @param {string} token - Mixpanel project tracking token
25058 * @param {Object} [options]
25059 * @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
25060 * @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
25061 * @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
25062 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
25063 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
25064 * @param {string} [options.cookieDomain] - custom cookie domain
25065 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
25066 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
25067 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
25068 */
25069 function _optInOut(optValue, token, options) {
25070 if (!_.isString(token) || !token.length) {
25071 console$1.error('gdpr.' + (optValue ? 'optIn' : 'optOut') + ' called with an invalid token');
25072 return;
25073 }
25074
25075 options = options || {};
25076
25077 _getStorage(options).set(
25078 _getStorageKey(token, options),
25079 optValue ? 1 : 0,
25080 _.isNumber(options.cookieExpiration) ? options.cookieExpiration : null,
25081 !!options.crossSubdomainCookie,
25082 !!options.secureCookie,
25083 !!options.crossSiteCookie,
25084 options.cookieDomain
25085 );
25086
25087 if (options.track && optValue) { // only track event if opting in (optValue=true)
25088 options.track(options.trackEventName || '$opt_in', options.trackProperties, {
25089 'send_immediately': true
25090 });
25091 }
25092 }
25093
25094 /**
25095 * Wrap a method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
25096 * If the user has opted out, return early instead of executing the method.
25097 * If a callback argument was provided, execute it passing the 0 error code.
25098 * @param {function} method - wrapped method to be executed if the user has not opted out
25099 * @param {function} getConfigValue - getter function for the Mixpanel API token and other options to be used with opt-out check
25100 * @returns {*} the result of executing method OR undefined if the user has opted out
25101 */
25102 function _addOptOutCheck(method, getConfigValue) {
25103 return function() {
25104 var optedOut = false;
25105
25106 try {
25107 var token = getConfigValue.call(this, 'token');
25108 var ignoreDnt = getConfigValue.call(this, 'ignore_dnt');
25109 var persistenceType = getConfigValue.call(this, 'opt_out_tracking_persistence_type');
25110 var persistencePrefix = getConfigValue.call(this, 'opt_out_tracking_cookie_prefix');
25111 var win = getConfigValue.call(this, 'window'); // used to override window during browser tests
25112
25113 if (token) { // if there was an issue getting the token, continue method execution as normal
25114 optedOut = hasOptedOut(token, {
25115 ignoreDnt: ignoreDnt,
25116 persistenceType: persistenceType,
25117 persistencePrefix: persistencePrefix,
25118 window: win
25119 });
25120 }
25121 } catch(err) {
25122 console$1.error('Unexpected error when checking tracking opt-out status: ' + err);
25123 }
25124
25125 if (!optedOut) {
25126 return method.apply(this, arguments);
25127 }
25128
25129 var callback = arguments[arguments.length - 1];
25130 if (typeof(callback) === 'function') {
25131 callback(0);
25132 }
25133
25134 return;
25135 };
25136 }
25137
25138 var logger$6 = console_with_prefix('lock');
25139
25140 /**
25141 * SharedLock: a mutex built on HTML5 localStorage, to ensure that only one browser
25142 * window/tab at a time will be able to access shared resources.
25143 *
25144 * Based on the Alur and Taubenfeld fast lock
25145 * (http://www.cs.rochester.edu/research/synchronization/pseudocode/fastlock.html)
25146 * with an added timeout to ensure there will be eventual progress in the event
25147 * that a window is closed in the middle of the callback.
25148 *
25149 * Implementation based on the original version by David Wolever (https://github.com/wolever)
25150 * at https://gist.github.com/wolever/5fd7573d1ef6166e8f8c4af286a69432.
25151 *
25152 * @example
25153 * const myLock = new SharedLock('some-key');
25154 * myLock.withLock(function() {
25155 * console.log('I hold the mutex!');
25156 * });
25157 *
25158 * @constructor
25159 */
25160 var SharedLock = function(key, options) {
25161 options = options || {};
25162
25163 this.storageKey = key;
25164 this.storage = options.storage || win.localStorage;
25165 this.pollIntervalMS = options.pollIntervalMS || 100;
25166 this.timeoutMS = options.timeoutMS || 2000;
25167
25168 // dependency-inject promise implementation for testing purposes
25169 this.promiseImpl = options.promiseImpl || PromisePolyfill;
25170 };
25171
25172 // pass in a specific pid to test contention scenarios; otherwise
25173 // it is chosen randomly for each acquisition attempt
25174 SharedLock.prototype.withLock = function(lockedCB, pid) {
25175 var Promise = this.promiseImpl;
25176 return new Promise(_.bind(function (resolve, reject) {
25177 var i = pid || (new Date().getTime() + '|' + Math.random());
25178 var startTime = new Date().getTime();
25179 var key = this.storageKey;
25180 var pollIntervalMS = this.pollIntervalMS;
25181 var timeoutMS = this.timeoutMS;
25182 var storage = this.storage;
25183
25184 var keyX = key + ':X';
25185 var keyY = key + ':Y';
25186 var keyZ = key + ':Z';
25187
25188 var delay = function(cb) {
25189 if (new Date().getTime() - startTime > timeoutMS) {
25190 logger$6.error('Timeout waiting for mutex on ' + key + '; clearing lock. [' + i + ']');
25191 storage.removeItem(keyZ);
25192 storage.removeItem(keyY);
25193 loop();
25194 return;
25195 }
25196 setTimeout(function() {
25197 try {
25198 cb();
25199 } catch(err) {
25200 reject(err);
25201 }
25202 }, pollIntervalMS * (Math.random() + 0.1));
25203 };
25204
25205 var waitFor = function(predicate, cb) {
25206 if (predicate()) {
25207 cb();
25208 } else {
25209 delay(function() {
25210 waitFor(predicate, cb);
25211 });
25212 }
25213 };
25214
25215 var getSetY = function() {
25216 var valY = storage.getItem(keyY);
25217 if (valY && valY !== i) { // if Y == i then this process already has the lock (useful for test cases)
25218 return false;
25219 } else {
25220 storage.setItem(keyY, i);
25221 if (storage.getItem(keyY) === i) {
25222 return true;
25223 } else {
25224 if (!localStorageSupported(storage, true)) {
25225 reject(new Error('localStorage support dropped while acquiring lock'));
25226 }
25227 return false;
25228 }
25229 }
25230 };
25231
25232 var loop = function() {
25233 storage.setItem(keyX, i);
25234
25235 waitFor(getSetY, function() {
25236 if (storage.getItem(keyX) === i) {
25237 criticalSection();
25238 return;
25239 }
25240
25241 delay(function() {
25242 if (storage.getItem(keyY) !== i) {
25243 loop();
25244 return;
25245 }
25246 waitFor(function() {
25247 return !storage.getItem(keyZ);
25248 }, criticalSection);
25249 });
25250 });
25251 };
25252
25253 var criticalSection = function() {
25254 storage.setItem(keyZ, '1');
25255 var removeLock = function () {
25256 storage.removeItem(keyZ);
25257 if (storage.getItem(keyY) === i) {
25258 storage.removeItem(keyY);
25259 }
25260 if (storage.getItem(keyX) === i) {
25261 storage.removeItem(keyX);
25262 }
25263 };
25264
25265 lockedCB()
25266 .then(function (ret) {
25267 removeLock();
25268 resolve(ret);
25269 })
25270 .catch(function (err) {
25271 removeLock();
25272 reject(err);
25273 });
25274 };
25275
25276 try {
25277 if (localStorageSupported(storage, true)) {
25278 loop();
25279 } else {
25280 throw new Error('localStorage support check failed');
25281 }
25282 } catch(err) {
25283 reject(err);
25284 }
25285 }, this));
25286 };
25287
25288 /**
25289 * @type {import('./wrapper').StorageWrapper}
25290 */
25291 var LocalStorageWrapper = function (storageOverride) {
25292 this.storage = storageOverride || win.localStorage;
25293 };
25294
25295 LocalStorageWrapper.prototype.init = function () {
25296 return PromisePolyfill.resolve();
25297 };
25298
25299 LocalStorageWrapper.prototype.isInitialized = function () {
25300 return true;
25301 };
25302
25303 LocalStorageWrapper.prototype.setItem = function (key, value) {
25304 return new PromisePolyfill(_.bind(function (resolve, reject) {
25305 try {
25306 this.storage.setItem(key, JSONStringify(value));
25307 } catch (e) {
25308 reject(e);
25309 }
25310 resolve();
25311 }, this));
25312 };
25313
25314 LocalStorageWrapper.prototype.getItem = function (key) {
25315 return new PromisePolyfill(_.bind(function (resolve, reject) {
25316 var item;
25317 try {
25318 item = JSONParse(this.storage.getItem(key));
25319 } catch (e) {
25320 reject(e);
25321 }
25322 resolve(item);
25323 }, this));
25324 };
25325
25326 LocalStorageWrapper.prototype.removeItem = function (key) {
25327 return new PromisePolyfill(_.bind(function (resolve, reject) {
25328 try {
25329 this.storage.removeItem(key);
25330 } catch (e) {
25331 reject(e);
25332 }
25333 resolve();
25334 }, this));
25335 };
25336
25337 var logger$5 = console_with_prefix('batch');
25338
25339 /**
25340 * RequestQueue: queue for batching API requests with localStorage backup for retries.
25341 * Maintains an in-memory queue which represents the source of truth for the current
25342 * page, but also writes all items out to a copy in the browser's localStorage, which
25343 * can be read on subsequent pageloads and retried. For batchability, all the request
25344 * items in the queue should be of the same type (events, people updates, group updates)
25345 * so they can be sent in a single request to the same API endpoint.
25346 *
25347 * LocalStorage keying and locking: In order for reloads and subsequent pageloads of
25348 * the same site to access the same persisted data, they must share the same localStorage
25349 * key (for instance based on project token and queue type). Therefore access to the
25350 * localStorage entry is guarded by an asynchronous mutex (SharedLock) to prevent
25351 * simultaneously open windows/tabs from overwriting each other's data (which would lead
25352 * to data loss in some situations).
25353 * @constructor
25354 */
25355 var RequestQueue = function (storageKey, options) {
25356 options = options || {};
25357 this.storageKey = storageKey;
25358 this.usePersistence = options.usePersistence;
25359 if (this.usePersistence) {
25360 this.queueStorage = options.queueStorage || new LocalStorageWrapper();
25361 this.lock = new SharedLock(storageKey, {
25362 storage: options.sharedLockStorage || win.localStorage,
25363 timeoutMS: options.sharedLockTimeoutMS,
25364 });
25365 }
25366 this.reportError = options.errorReporter || _.bind(logger$5.error, logger$5);
25367
25368 this.pid = options.pid || null; // pass pid to test out storage lock contention scenarios
25369
25370 this.memQueue = [];
25371 this.initialized = false;
25372
25373 if (options.enqueueThrottleMs) {
25374 this.enqueuePersisted = batchedThrottle(_.bind(this._enqueuePersisted, this), options.enqueueThrottleMs);
25375 } else {
25376 this.enqueuePersisted = _.bind(function (queueEntry) {
25377 return this._enqueuePersisted([queueEntry]);
25378 }, this);
25379 }
25380 };
25381
25382 RequestQueue.prototype.ensureInit = function () {
25383 if (this.initialized || !this.usePersistence) {
25384 return PromisePolyfill.resolve();
25385 }
25386
25387 return this.queueStorage
25388 .init()
25389 .then(_.bind(function () {
25390 this.initialized = true;
25391 }, this))
25392 .catch(_.bind(function (err) {
25393 this.reportError('Error initializing queue persistence. Disabling persistence', err);
25394 this.initialized = true;
25395 this.usePersistence = false;
25396 }, this));
25397 };
25398
25399 /**
25400 * Add one item to queues (memory and localStorage). The queued entry includes
25401 * the given item along with an auto-generated ID and a "flush-after" timestamp.
25402 * It is expected that the item will be sent over the network and dequeued
25403 * before the flush-after time; if this doesn't happen it is considered orphaned
25404 * (e.g., the original tab where it was enqueued got closed before it could be
25405 * sent) and the item can be sent by any tab that finds it in localStorage.
25406 *
25407 * The final callback param is called with a param indicating success or
25408 * failure of the enqueue operation; it is asynchronous because the localStorage
25409 * lock is asynchronous.
25410 */
25411 RequestQueue.prototype.enqueue = function (item, flushInterval) {
25412 var queueEntry = {
25413 'id': cheap_guid(),
25414 'flushAfter': new Date().getTime() + flushInterval * 2,
25415 'payload': item
25416 };
25417
25418 if (!this.usePersistence) {
25419 this.memQueue.push(queueEntry);
25420 return PromisePolyfill.resolve(true);
25421 } else {
25422 return this.enqueuePersisted(queueEntry);
25423 }
25424 };
25425
25426 RequestQueue.prototype._enqueuePersisted = function (queueEntries) {
25427 var enqueueItem = _.bind(function () {
25428 return this.ensureInit()
25429 .then(_.bind(function () {
25430 return this.readFromStorage();
25431 }, this))
25432 .then(_.bind(function (storedQueue) {
25433 return this.saveToStorage(storedQueue.concat(queueEntries));
25434 }, this))
25435 .then(_.bind(function (succeeded) {
25436 // only add to in-memory queue when storage succeeds
25437 if (succeeded) {
25438 this.memQueue = this.memQueue.concat(queueEntries);
25439 }
25440
25441 return succeeded;
25442 }, this))
25443 .catch(_.bind(function (err) {
25444 this.reportError('Error enqueueing items', err, queueEntries);
25445 return false;
25446 }, this));
25447 }, this);
25448
25449 return this.lock
25450 .withLock(enqueueItem, this.pid)
25451 .catch(_.bind(function (err) {
25452 this.reportError('Error acquiring storage lock', err);
25453 return false;
25454 }, this));
25455 };
25456
25457 /**
25458 * Read out the given number of queue entries. If this.memQueue
25459 * has fewer than batchSize items, then look for "orphaned" items
25460 * in the persisted queue (items where the 'flushAfter' time has
25461 * already passed).
25462 */
25463 RequestQueue.prototype.fillBatch = function (batchSize) {
25464 var batch = this.memQueue.slice(0, batchSize);
25465 if (this.usePersistence && batch.length < batchSize) {
25466 // don't need lock just to read events; localStorage is thread-safe
25467 // and the worst that could happen is a duplicate send of some
25468 // orphaned events, which will be deduplicated on the server side
25469 return this.ensureInit()
25470 .then(_.bind(function () {
25471 return this.readFromStorage();
25472 }, this))
25473 .then(_.bind(function (storedQueue) {
25474 if (storedQueue.length) {
25475 // item IDs already in batch; don't duplicate out of storage
25476 var idsInBatch = {}; // poor man's Set
25477 _.each(batch, function (item) {
25478 idsInBatch[item['id']] = true;
25479 });
25480
25481 for (var i = 0; i < storedQueue.length; i++) {
25482 var item = storedQueue[i];
25483 if (new Date().getTime() > item['flushAfter'] && !idsInBatch[item['id']]) {
25484 item.orphaned = true;
25485 batch.push(item);
25486 if (batch.length >= batchSize) {
25487 break;
25488 }
25489 }
25490 }
25491 }
25492
25493 return batch;
25494 }, this));
25495 } else {
25496 return PromisePolyfill.resolve(batch);
25497 }
25498 };
25499
25500 /**
25501 * Remove items with matching 'id' from array (immutably)
25502 * also remove any item without a valid id (e.g., malformed
25503 * storage entries).
25504 */
25505 var filterOutIDsAndInvalid = function (items, idSet) {
25506 var filteredItems = [];
25507 _.each(items, function (item) {
25508 if (item['id'] && !idSet[item['id']]) {
25509 filteredItems.push(item);
25510 }
25511 });
25512 return filteredItems;
25513 };
25514
25515 /**
25516 * Remove items with matching IDs from both in-memory queue
25517 * and persisted queue
25518 */
25519 RequestQueue.prototype.removeItemsByID = function (ids) {
25520 var idSet = {}; // poor man's Set
25521 _.each(ids, function (id) {
25522 idSet[id] = true;
25523 });
25524
25525 this.memQueue = filterOutIDsAndInvalid(this.memQueue, idSet);
25526 if (!this.usePersistence) {
25527 return PromisePolyfill.resolve(true);
25528 } else {
25529 var removeFromStorage = _.bind(function () {
25530 return this.ensureInit()
25531 .then(_.bind(function () {
25532 return this.readFromStorage();
25533 }, this))
25534 .then(_.bind(function (storedQueue) {
25535 storedQueue = filterOutIDsAndInvalid(storedQueue, idSet);
25536 return this.saveToStorage(storedQueue);
25537 }, this))
25538 .then(_.bind(function () {
25539 return this.readFromStorage();
25540 }, this))
25541 .then(_.bind(function (storedQueue) {
25542 // an extra check: did storage report success but somehow
25543 // the items are still there?
25544 for (var i = 0; i < storedQueue.length; i++) {
25545 var item = storedQueue[i];
25546 if (item['id'] && !!idSet[item['id']]) {
25547 throw new Error('Item not removed from storage');
25548 }
25549 }
25550 return true;
25551 }, this))
25552 .catch(_.bind(function (err) {
25553 this.reportError('Error removing items', err, ids);
25554 return false;
25555 }, this));
25556 }, this);
25557
25558 return this.lock
25559 .withLock(removeFromStorage, this.pid)
25560 .catch(_.bind(function (err) {
25561 this.reportError('Error acquiring storage lock', err);
25562 if (!localStorageSupported(this.lock.storage, true)) {
25563 // Looks like localStorage writes have stopped working sometime after
25564 // initialization (probably full), and so nobody can acquire locks
25565 // anymore. Consider it temporarily safe to remove items without the
25566 // lock, since nobody's writing successfully anyway.
25567 return removeFromStorage()
25568 .then(_.bind(function (success) {
25569 if (!success) {
25570 // OK, we couldn't even write out the smaller queue. Try clearing it
25571 // entirely.
25572 return this.queueStorage.removeItem(this.storageKey).then(function () {
25573 return success;
25574 });
25575 }
25576 return success;
25577 }, this))
25578 .catch(_.bind(function (err) {
25579 this.reportError('Error clearing queue', err);
25580 return false;
25581 }, this));
25582 } else {
25583 return false;
25584 }
25585 }, this));
25586 }
25587 };
25588
25589 // internal helper for RequestQueue.updatePayloads
25590 var updatePayloads = function (existingItems, itemsToUpdate) {
25591 var newItems = [];
25592 _.each(existingItems, function (item) {
25593 var id = item['id'];
25594 if (id in itemsToUpdate) {
25595 var newPayload = itemsToUpdate[id];
25596 if (newPayload !== null) {
25597 item['payload'] = newPayload;
25598 newItems.push(item);
25599 }
25600 } else {
25601 // no update
25602 newItems.push(item);
25603 }
25604 });
25605 return newItems;
25606 };
25607
25608 /**
25609 * Update payloads of given items in both in-memory queue and
25610 * persisted queue. Items set to null are removed from queues.
25611 */
25612 RequestQueue.prototype.updatePayloads = function (itemsToUpdate) {
25613 this.memQueue = updatePayloads(this.memQueue, itemsToUpdate);
25614 if (!this.usePersistence) {
25615 return PromisePolyfill.resolve(true);
25616 } else {
25617 return this.lock
25618 .withLock(_.bind(function lockAcquired() {
25619 return this.ensureInit()
25620 .then(_.bind(function () {
25621 return this.readFromStorage();
25622 }, this))
25623 .then(_.bind(function (storedQueue) {
25624 storedQueue = updatePayloads(storedQueue, itemsToUpdate);
25625 return this.saveToStorage(storedQueue);
25626 }, this))
25627 .catch(_.bind(function (err) {
25628 this.reportError('Error updating items', itemsToUpdate, err);
25629 return false;
25630 }, this));
25631 }, this), this.pid)
25632 .catch(_.bind(function (err) {
25633 this.reportError('Error acquiring storage lock', err);
25634 return false;
25635 }, this));
25636 }
25637 };
25638
25639 /**
25640 * Read and parse items array from localStorage entry, handling
25641 * malformed/missing data if necessary.
25642 */
25643 RequestQueue.prototype.readFromStorage = function () {
25644 return this.ensureInit()
25645 .then(_.bind(function () {
25646 return this.queueStorage.getItem(this.storageKey);
25647 }, this))
25648 .then(_.bind(function (storageEntry) {
25649 if (storageEntry) {
25650 if (!_.isArray(storageEntry)) {
25651 this.reportError('Invalid storage entry:', storageEntry);
25652 storageEntry = null;
25653 }
25654 }
25655 return storageEntry || [];
25656 }, this))
25657 .catch(_.bind(function (err) {
25658 this.reportError('Error retrieving queue', err);
25659 return [];
25660 }, this));
25661 };
25662
25663 /**
25664 * Serialize the given items array to localStorage.
25665 */
25666 RequestQueue.prototype.saveToStorage = function (queue) {
25667 return this.ensureInit()
25668 .then(_.bind(function () {
25669 return this.queueStorage.setItem(this.storageKey, queue);
25670 }, this))
25671 .then(function () {
25672 return true;
25673 })
25674 .catch(_.bind(function (err) {
25675 this.reportError('Error saving queue', err);
25676 return false;
25677 }, this));
25678 };
25679
25680 /**
25681 * Clear out queues (memory and localStorage).
25682 */
25683 RequestQueue.prototype.clear = function () {
25684 this.memQueue = [];
25685
25686 if (this.usePersistence) {
25687 return this.ensureInit()
25688 .then(_.bind(function () {
25689 return this.queueStorage.removeItem(this.storageKey);
25690 }, this));
25691 } else {
25692 return PromisePolyfill.resolve();
25693 }
25694 };
25695
25696 // maximum interval between request retries after exponential backoff
25697 var MAX_RETRY_INTERVAL_MS = 10 * 60 * 1000; // 10 minutes
25698
25699 var logger$4 = console_with_prefix('batch');
25700
25701 /**
25702 * RequestBatcher: manages the queueing, flushing, retry etc of requests of one
25703 * type (events, people, groups).
25704 * Uses RequestQueue to manage the backing store.
25705 * @constructor
25706 */
25707 var RequestBatcher = function(storageKey, options) {
25708 this.errorReporter = options.errorReporter;
25709 this.queue = new RequestQueue(storageKey, {
25710 errorReporter: _.bind(this.reportError, this),
25711 queueStorage: options.queueStorage,
25712 sharedLockStorage: options.sharedLockStorage,
25713 sharedLockTimeoutMS: options.sharedLockTimeoutMS,
25714 usePersistence: options.usePersistence,
25715 enqueueThrottleMs: options.enqueueThrottleMs
25716 });
25717
25718 this.libConfig = options.libConfig;
25719 this.sendRequest = options.sendRequestFunc;
25720 this.beforeSendHook = options.beforeSendHook;
25721 this.stopAllBatching = options.stopAllBatchingFunc;
25722
25723 // seed variable batch size + flush interval with configured values
25724 this.batchSize = this.libConfig['batch_size'];
25725 this.flushInterval = this.libConfig['batch_flush_interval_ms'];
25726
25727 this.stopped = !this.libConfig['batch_autostart'];
25728 this.consecutiveRemovalFailures = 0;
25729
25730 // extra client-side dedupe
25731 this.itemIdsSentSuccessfully = {};
25732
25733 // Make the flush occur at the interval specified by flushIntervalMs, default behavior will attempt consecutive flushes
25734 // as long as the queue is not empty. This is useful for high-frequency events like Session Replay where we might end up
25735 // in a request loop and get ratelimited by the server.
25736 this.flushOnlyOnInterval = options.flushOnlyOnInterval || false;
25737
25738 this._flushPromise = null;
25739 };
25740
25741 /**
25742 * Add one item to queue.
25743 */
25744 RequestBatcher.prototype.enqueue = function(item) {
25745 return this.queue.enqueue(item, this.flushInterval);
25746 };
25747
25748 /**
25749 * Start flushing batches at the configured time interval. Must call
25750 * this method upon SDK init in order to send anything over the network.
25751 */
25752 RequestBatcher.prototype.start = function() {
25753 this.stopped = false;
25754 this.consecutiveRemovalFailures = 0;
25755 return this.flush();
25756 };
25757
25758 /**
25759 * Stop flushing batches. Can be restarted by calling start().
25760 */
25761 RequestBatcher.prototype.stop = function() {
25762 this.stopped = true;
25763 if (this.timeoutID) {
25764 clearTimeout(this.timeoutID);
25765 this.timeoutID = null;
25766 }
25767 };
25768
25769 /**
25770 * Clear out queue.
25771 */
25772 RequestBatcher.prototype.clear = function() {
25773 return this.queue.clear();
25774 };
25775
25776 /**
25777 * Restore batch size configuration to whatever is set in the main SDK.
25778 */
25779 RequestBatcher.prototype.resetBatchSize = function() {
25780 this.batchSize = this.libConfig['batch_size'];
25781 };
25782
25783 /**
25784 * Restore flush interval time configuration to whatever is set in the main SDK.
25785 */
25786 RequestBatcher.prototype.resetFlush = function() {
25787 this.scheduleFlush(this.libConfig['batch_flush_interval_ms']);
25788 };
25789
25790 /**
25791 * Schedule the next flush in the given number of milliseconds.
25792 */
25793 RequestBatcher.prototype.scheduleFlush = function(flushMS) {
25794 this.flushInterval = flushMS;
25795 if (!this.stopped) { // don't schedule anymore if batching has been stopped
25796 this.timeoutID = setTimeout(_.bind(function() {
25797 if (!this.stopped) {
25798 this._flushPromise = this.flush();
25799 }
25800 }, this), this.flushInterval);
25801 }
25802 };
25803
25804 /**
25805 * Send a request using the sendRequest callback, but promisified.
25806 * TODO: sendRequest should be promisified in the first place.
25807 */
25808 RequestBatcher.prototype.sendRequestPromise = function(data, options) {
25809 return new PromisePolyfill(_.bind(function(resolve) {
25810 this.sendRequest(data, options, resolve);
25811 }, this));
25812 };
25813
25814
25815 /**
25816 * Flush one batch to network. Depending on success/failure modes, it will either
25817 * remove the batch from the queue or leave it in for retry, and schedule the next
25818 * flush. In cases of most network or API failures, it will back off exponentially
25819 * when retrying.
25820 * @param {Object} [options]
25821 * @param {boolean} [options.sendBeacon] - whether to send batch with
25822 * navigator.sendBeacon (only useful for sending batches before page unloads, as
25823 * sendBeacon offers no callbacks or status indications)
25824 */
25825 RequestBatcher.prototype.flush = function(options) {
25826 if (this.requestInProgress) {
25827 logger$4.log('Flush: Request already in progress');
25828 return PromisePolyfill.resolve();
25829 }
25830
25831 this.requestInProgress = true;
25832
25833 options = options || {};
25834 var timeoutMS = this.libConfig['batch_request_timeout_ms'];
25835 var startTime = new Date().getTime();
25836 var currentBatchSize = this.batchSize;
25837
25838 return this.queue.fillBatch(currentBatchSize)
25839 .then(_.bind(function(batch) {
25840
25841 // if there's more items in the queue than the batch size, attempt
25842 // to flush again after the current batch is done.
25843 var attemptSecondaryFlush = batch.length === currentBatchSize;
25844 var dataForRequest = [];
25845 var transformedItems = {};
25846 _.each(batch, function(item) {
25847 var payload = item['payload'];
25848 if (this.beforeSendHook && !item.orphaned) {
25849 payload = this.beforeSendHook(payload);
25850 }
25851 if (payload) {
25852 // mp_sent_by_lib_version prop captures which lib version actually
25853 // sends each event (regardless of which version originally queued
25854 // it for sending)
25855 if (payload['event'] && payload['properties']) {
25856 payload['properties'] = _.extend(
25857 {},
25858 payload['properties'],
25859 {'mp_sent_by_lib_version': Config.LIB_VERSION}
25860 );
25861 }
25862 var addPayload = true;
25863 var itemId = item['id'];
25864 if (itemId) {
25865 if ((this.itemIdsSentSuccessfully[itemId] || 0) > 5) {
25866 this.reportError('[dupe] item ID sent too many times, not sending', {
25867 item: item,
25868 batchSize: batch.length,
25869 timesSent: this.itemIdsSentSuccessfully[itemId]
25870 });
25871 addPayload = false;
25872 }
25873 } else {
25874 this.reportError('[dupe] found item with no ID', {item: item});
25875 }
25876
25877 if (addPayload) {
25878 dataForRequest.push(payload);
25879 }
25880 }
25881 transformedItems[item['id']] = payload;
25882 }, this);
25883
25884 if (dataForRequest.length < 1) {
25885 this.requestInProgress = false;
25886 this.resetFlush();
25887 return PromisePolyfill.resolve(); // nothing to do
25888 }
25889
25890 var removeItemsFromQueue = _.bind(function () {
25891 return this.queue
25892 .removeItemsByID(
25893 _.map(batch, function (item) {
25894 return item['id'];
25895 })
25896 )
25897 .then(_.bind(function (succeeded) {
25898 // client-side dedupe
25899 _.each(batch, _.bind(function(item) {
25900 var itemId = item['id'];
25901 if (itemId) {
25902 this.itemIdsSentSuccessfully[itemId] = this.itemIdsSentSuccessfully[itemId] || 0;
25903 this.itemIdsSentSuccessfully[itemId]++;
25904 if (this.itemIdsSentSuccessfully[itemId] > 5) {
25905 this.reportError('[dupe] item ID sent too many times', {
25906 item: item,
25907 batchSize: batch.length,
25908 timesSent: this.itemIdsSentSuccessfully[itemId]
25909 });
25910 }
25911 } else {
25912 this.reportError('[dupe] found item with no ID while removing', {item: item});
25913 }
25914 }, this));
25915
25916 if (succeeded) {
25917 this.consecutiveRemovalFailures = 0;
25918 if (this.flushOnlyOnInterval && !attemptSecondaryFlush) {
25919 this.resetFlush(); // schedule next batch with a delay
25920 return PromisePolyfill.resolve();
25921 } else {
25922 return this.flush(); // handle next batch if the queue isn't empty
25923 }
25924 } else {
25925 if (++this.consecutiveRemovalFailures > 5) {
25926 this.reportError('Too many queue failures; disabling batching system.');
25927 this.stopAllBatching();
25928 } else {
25929 this.resetFlush();
25930 }
25931 return PromisePolyfill.resolve();
25932 }
25933 }, this));
25934 }, this);
25935
25936 var batchSendCallback = _.bind(function(res) {
25937 this.requestInProgress = false;
25938
25939 try {
25940
25941 // handle API response in a try-catch to make sure we can reset the
25942 // flush operation if something goes wrong
25943
25944 if (options.unloading) {
25945 // update persisted data to include hook transformations
25946 return this.queue.updatePayloads(transformedItems);
25947 } else if (
25948 _.isObject(res) &&
25949 res.error === 'timeout' &&
25950 new Date().getTime() - startTime >= timeoutMS
25951 ) {
25952 this.reportError('Network timeout; retrying');
25953 return this.flush();
25954 } else if (
25955 _.isObject(res) &&
25956 (
25957 res.httpStatusCode >= 500
25958 || res.httpStatusCode === 429
25959 || (res.httpStatusCode <= 0 && !isOnline())
25960 || res.error === 'timeout'
25961 )
25962 ) {
25963 // network or API error, or 429 Too Many Requests, retry
25964 var retryMS = this.flushInterval * 2;
25965 if (res.retryAfter) {
25966 retryMS = (parseInt(res.retryAfter, 10) * 1000) || retryMS;
25967 }
25968 retryMS = Math.min(MAX_RETRY_INTERVAL_MS, retryMS);
25969 this.reportError('Error; retry in ' + retryMS + ' ms');
25970 this.scheduleFlush(retryMS);
25971 return PromisePolyfill.resolve();
25972 } else if (_.isObject(res) && res.httpStatusCode === 413) {
25973 // 413 Payload Too Large
25974 if (batch.length > 1) {
25975 var halvedBatchSize = Math.max(1, Math.floor(currentBatchSize / 2));
25976 this.batchSize = Math.min(this.batchSize, halvedBatchSize, batch.length - 1);
25977 this.reportError('413 response; reducing batch size to ' + this.batchSize);
25978 this.resetFlush();
25979 return PromisePolyfill.resolve();
25980 } else {
25981 this.reportError('Single-event request too large; dropping', batch);
25982 this.resetBatchSize();
25983 return removeItemsFromQueue();
25984 }
25985 } else {
25986 // successful network request+response; remove each item in batch from queue
25987 // (even if it was e.g. a 400, in which case retrying won't help)
25988 return removeItemsFromQueue();
25989 }
25990 } catch(err) {
25991 this.reportError('Error handling API response', err);
25992 this.resetFlush();
25993 }
25994 }, this);
25995 var requestOptions = {
25996 method: 'POST',
25997 verbose: true,
25998 ignore_json_errors: true, // eslint-disable-line camelcase
25999 timeout_ms: timeoutMS // eslint-disable-line camelcase
26000 };
26001 if (options.unloading) {
26002 requestOptions.transport = 'sendBeacon';
26003 }
26004 logger$4.log('MIXPANEL REQUEST:', dataForRequest);
26005 return this.sendRequestPromise(dataForRequest, requestOptions).then(batchSendCallback);
26006 }, this))
26007 .catch(_.bind(function(err) {
26008 this.reportError('Error flushing request queue', err);
26009 this.resetFlush();
26010 }, this));
26011 };
26012
26013 /**
26014 * Log error to global logger and optional user-defined logger.
26015 */
26016 RequestBatcher.prototype.reportError = function(msg, err) {
26017 logger$4.error.apply(logger$4.error, arguments);
26018 if (this.errorReporter) {
26019 try {
26020 if (!(err instanceof Error)) {
26021 err = new Error(msg);
26022 }
26023 this.errorReporter(msg, err);
26024 } catch(err) {
26025 logger$4.error(err);
26026 }
26027 }
26028 };
26029
26030 /**
26031 * @param {import('./session-recording').SerializedRecording} serializedRecording
26032 * @returns {boolean}
26033 */
26034 var isRecordingExpired = function(serializedRecording) {
26035 var now = Date.now();
26036 return !serializedRecording || now > serializedRecording['maxExpires'] || now > serializedRecording['idleExpires'];
26037 };
26038
26039 var RECORD_ENQUEUE_THROTTLE_MS = 250;
26040
26041 var logger$3 = console_with_prefix('recorder');
26042 var CompressionStream = win['CompressionStream'];
26043
26044 var RECORDER_BATCHER_LIB_CONFIG = {
26045 'batch_size': 1000,
26046 'batch_flush_interval_ms': 10 * 1000,
26047 'batch_request_timeout_ms': 90 * 1000,
26048 'batch_autostart': true
26049 };
26050
26051 var ACTIVE_SOURCES = new Set([
26052 IncrementalSource.MouseMove,
26053 IncrementalSource.MouseInteraction,
26054 IncrementalSource.Scroll,
26055 IncrementalSource.ViewportResize,
26056 IncrementalSource.Input,
26057 IncrementalSource.TouchMove,
26058 IncrementalSource.MediaInteraction,
26059 IncrementalSource.Drag,
26060 IncrementalSource.Selection,
26061 ]);
26062
26063 function isUserEvent(ev) {
26064 return ev.type === EventType.IncrementalSnapshot && ACTIVE_SOURCES.has(ev.data.source);
26065 }
26066
26067 /**
26068 * @typedef {Object} SerializedRecording
26069 * @property {number} idleExpires
26070 * @property {number} maxExpires
26071 * @property {number} replayStartTime
26072 * @property {number} seqNo
26073 * @property {string} batchStartUrl
26074 * @property {string} replayId
26075 * @property {string} tabId
26076 * @property {string} replayStartUrl
26077 */
26078
26079 /**
26080 * @typedef {Object} SessionRecordingOptions
26081 * @property {Object} [options.mixpanelInstance] - reference to the core MixpanelLib
26082 * @property {String} [options.replayId] - unique uuid for a single replay
26083 * @property {Function} [options.onIdleTimeout] - callback when a recording reaches idle timeout
26084 * @property {Function} [options.onMaxLengthReached] - callback when a recording reaches its maximum length
26085 * @property {Function} [options.rrwebRecord] - rrweb's `record` function
26086 * @property {Function} [options.onBatchSent] - callback when a batch of events is sent to the server
26087 * @property {Storage} [options.sharedLockStorage] - optional storage for shared lock, used for test dependency injection
26088 * optional properties for deserialization:
26089 * @property {number} idleExpires
26090 * @property {number} maxExpires
26091 * @property {number} replayStartTime
26092 * @property {number} seqNo
26093 * @property {string} batchStartUrl
26094 * @property {string} replayStartUrl
26095 */
26096
26097 /**
26098 * @typedef {Object} UserIdInfo
26099 * @property {string} distinct_id
26100 * @property {string} user_id
26101 * @property {string} device_id
26102 */
26103
26104
26105 /**
26106 * This class encapsulates a single session recording and its lifecycle.
26107 * @param {SessionRecordingOptions} options
26108 */
26109 var SessionRecording = function(options) {
26110 this._mixpanel = options.mixpanelInstance;
26111 this._onIdleTimeout = options.onIdleTimeout || NOOP_FUNC;
26112 this._onMaxLengthReached = options.onMaxLengthReached || NOOP_FUNC;
26113 this._onBatchSent = options.onBatchSent || NOOP_FUNC;
26114 this._rrwebRecord = options.rrwebRecord || null;
26115
26116 // internal rrweb stopRecording function
26117 this._stopRecording = null;
26118 this.replayId = options.replayId;
26119
26120 this.batchStartUrl = options.batchStartUrl || null;
26121 this.replayStartUrl = options.replayStartUrl || null;
26122 this.idleExpires = options.idleExpires || null;
26123 this.maxExpires = options.maxExpires || null;
26124 this.replayStartTime = options.replayStartTime || null;
26125 this.seqNo = options.seqNo || 0;
26126
26127 this.idleTimeoutId = null;
26128 this.maxTimeoutId = null;
26129
26130 this.recordMaxMs = MAX_RECORDING_MS;
26131 this.recordMinMs = 0;
26132
26133 // disable persistence if localStorage is not supported
26134 // request-queue will automatically disable persistence if indexedDB fails to initialize
26135 var usePersistence = localStorageSupported(options.sharedLockStorage, true) && !this.getConfig('disable_persistence');
26136
26137 // each replay has its own batcher key to avoid conflicts between rrweb events of different recordings
26138 this.batcherKey = '__mprec_' + this.getConfig('name') + '_' + this.getConfig('token') + '_' + this.replayId;
26139 this.queueStorage = new IDBStorageWrapper(RECORDING_EVENTS_STORE_NAME);
26140 this.batcher = new RequestBatcher(this.batcherKey, {
26141 errorReporter: this.reportError.bind(this),
26142 flushOnlyOnInterval: true,
26143 libConfig: RECORDER_BATCHER_LIB_CONFIG,
26144 sendRequestFunc: this.flushEventsWithOptOut.bind(this),
26145 queueStorage: this.queueStorage,
26146 sharedLockStorage: options.sharedLockStorage,
26147 usePersistence: usePersistence,
26148 stopAllBatchingFunc: this.stopRecording.bind(this),
26149
26150 // increased throttle and shared lock timeout because recording events are very high frequency.
26151 // this will minimize the amount of lock contention between enqueued events.
26152 // for session recordings there is a lock for each tab anyway, so there's no risk of deadlock between tabs.
26153 enqueueThrottleMs: RECORD_ENQUEUE_THROTTLE_MS,
26154 sharedLockTimeoutMS: 10 * 1000,
26155 });
26156 };
26157
26158 /**
26159 * @returns {UserIdInfo}
26160 */
26161 SessionRecording.prototype.getUserIdInfo = function () {
26162 if (this.finalFlushUserIdInfo) {
26163 return this.finalFlushUserIdInfo;
26164 }
26165
26166 var userIdInfo = {
26167 'distinct_id': String(this._mixpanel.get_distinct_id()),
26168 };
26169
26170 // send ID management props if they exist
26171 var deviceId = this._mixpanel.get_property('$device_id');
26172 if (deviceId) {
26173 userIdInfo['$device_id'] = deviceId;
26174 }
26175 var userId = this._mixpanel.get_property('$user_id');
26176 if (userId) {
26177 userIdInfo['$user_id'] = userId;
26178 }
26179 return userIdInfo;
26180 };
26181
26182 SessionRecording.prototype.unloadPersistedData = function () {
26183 this.batcher.stop();
26184 return this.batcher.flush()
26185 .then(function () {
26186 return this.queueStorage.removeItem(this.batcherKey);
26187 }.bind(this));
26188 };
26189
26190 SessionRecording.prototype.getConfig = function(configVar) {
26191 return this._mixpanel.get_config(configVar);
26192 };
26193
26194 // Alias for getConfig, used by the common addOptOutCheckMixpanelLib function which
26195 // reaches into this class instance and expects the snake case version of the function.
26196 // eslint-disable-next-line camelcase
26197 SessionRecording.prototype.get_config = function(configVar) {
26198 return this.getConfig(configVar);
26199 };
26200
26201 SessionRecording.prototype.startRecording = function (shouldStopBatcher) {
26202 if (this._rrwebRecord === null) {
26203 this.reportError('rrweb record function not provided. ');
26204 return;
26205 }
26206
26207 if (this._stopRecording !== null) {
26208 logger$3.log('Recording already in progress, skipping startRecording.');
26209 return;
26210 }
26211
26212 this.recordMaxMs = this.getConfig('record_max_ms');
26213 if (this.recordMaxMs > MAX_RECORDING_MS) {
26214 this.recordMaxMs = MAX_RECORDING_MS;
26215 logger$3.critical('record_max_ms cannot be greater than ' + MAX_RECORDING_MS + 'ms. Capping value.');
26216 }
26217
26218 if (!this.maxExpires) {
26219 this.maxExpires = new Date().getTime() + this.recordMaxMs;
26220 }
26221
26222 this.recordMinMs = this.getConfig('record_min_ms');
26223 if (this.recordMinMs > MAX_VALUE_FOR_MIN_RECORDING_MS) {
26224 this.recordMinMs = MAX_VALUE_FOR_MIN_RECORDING_MS;
26225 logger$3.critical('record_min_ms cannot be greater than ' + MAX_VALUE_FOR_MIN_RECORDING_MS + 'ms. Capping value.');
26226 }
26227
26228 if (!this.replayStartTime) {
26229 this.replayStartTime = new Date().getTime();
26230 this.batchStartUrl = _.info.currentUrl();
26231 this.replayStartUrl = _.info.currentUrl();
26232 }
26233
26234 if (shouldStopBatcher || this.recordMinMs > 0) {
26235 // the primary case for shouldStopBatcher is when we're starting recording after a reset
26236 // and don't want to send anything over the network until there's
26237 // actual user activity
26238 // this also applies if the minimum recording length has not been hit yet
26239 // so that we don't send data until we know the recording will be long enough
26240 this.batcher.stop();
26241 } else {
26242 this.batcher.start();
26243 }
26244
26245 var resetIdleTimeout = function () {
26246 clearTimeout(this.idleTimeoutId);
26247 var idleTimeoutMs = this.getConfig('record_idle_timeout_ms');
26248 this.idleTimeoutId = setTimeout(this._onIdleTimeout, idleTimeoutMs);
26249 this.idleExpires = new Date().getTime() + idleTimeoutMs;
26250 }.bind(this);
26251 resetIdleTimeout();
26252
26253 var blockSelector = this.getConfig('record_block_selector');
26254 if (blockSelector === '' || blockSelector === null) {
26255 blockSelector = undefined;
26256 }
26257
26258 try {
26259 this._stopRecording = this._rrwebRecord({
26260 'emit': function (ev) {
26261 if (this.idleExpires && this.idleExpires < ev.timestamp) {
26262 this._onIdleTimeout();
26263 return;
26264 }
26265 if (isUserEvent(ev)) {
26266 if (this.batcher.stopped && new Date().getTime() - this.replayStartTime >= this.recordMinMs) {
26267 // start flushing again after user activity
26268 this.batcher.start();
26269 }
26270 resetIdleTimeout();
26271 }
26272 // promise only used to await during tests
26273 this.__enqueuePromise = this.batcher.enqueue(ev);
26274 }.bind(this),
26275 'blockClass': this.getConfig('record_block_class'),
26276 'blockSelector': blockSelector,
26277 'collectFonts': this.getConfig('record_collect_fonts'),
26278 'dataURLOptions': { // canvas image options (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL)
26279 'type': 'image/webp',
26280 'quality': 0.6
26281 },
26282 'maskAllInputs': true,
26283 'maskTextClass': this.getConfig('record_mask_text_class'),
26284 'maskTextSelector': this.getConfig('record_mask_text_selector'),
26285 'recordCanvas': this.getConfig('record_canvas'),
26286 'sampling': {
26287 'canvas': 15
26288 }
26289 });
26290 } catch (err) {
26291 this.reportError('Unexpected error when starting rrweb recording.', err);
26292 }
26293
26294 if (typeof this._stopRecording !== 'function') {
26295 this.reportError('rrweb failed to start, skipping this recording.');
26296 this._stopRecording = null;
26297 this.stopRecording(); // stop batcher looping and any timeouts
26298 return;
26299 }
26300
26301 var maxTimeoutMs = this.maxExpires - new Date().getTime();
26302 this.maxTimeoutId = setTimeout(this._onMaxLengthReached.bind(this), maxTimeoutMs);
26303 };
26304
26305 SessionRecording.prototype.stopRecording = function (skipFlush) {
26306 // store the user ID info in case this is getting called in mixpanel.reset()
26307 this.finalFlushUserIdInfo = this.getUserIdInfo();
26308
26309 if (!this.isRrwebStopped()) {
26310 try {
26311 this._stopRecording();
26312 } catch (err) {
26313 this.reportError('Error with rrweb stopRecording', err);
26314 }
26315 this._stopRecording = null;
26316 }
26317
26318 var flushPromise;
26319 if (this.batcher.stopped) {
26320 // never got user activity to flush after reset, so just clear the batcher
26321 flushPromise = this.batcher.clear();
26322 } else if (!skipFlush) {
26323 // flush any remaining events from running batcher
26324 flushPromise = this.batcher.flush();
26325 }
26326 this.batcher.stop();
26327
26328 clearTimeout(this.idleTimeoutId);
26329 clearTimeout(this.maxTimeoutId);
26330 return flushPromise;
26331 };
26332
26333 SessionRecording.prototype.isRrwebStopped = function () {
26334 return this._stopRecording === null;
26335 };
26336
26337
26338 /**
26339 * Flushes the current batch of events to the server, but passes an opt-out callback to make sure
26340 * we stop recording and dump any queued events if the user has opted out.
26341 */
26342 SessionRecording.prototype.flushEventsWithOptOut = function (data, options, cb) {
26343 var onOptOut = function (code) {
26344 // addOptOutCheckMixpanelLib invokes this function with code=0 when the user has opted out
26345 if (code === 0) {
26346 this.stopRecording();
26347 cb({error: 'Tracking has been opted out, stopping recording.'});
26348 }
26349 }.bind(this);
26350
26351 this._flushEvents(data, options, cb, onOptOut);
26352 };
26353
26354 /**
26355 * @returns {SerializedRecording}
26356 */
26357 SessionRecording.prototype.serialize = function () {
26358 // don't break if mixpanel instance was destroyed at some point
26359 var tabId;
26360 try {
26361 tabId = this._mixpanel.get_tab_id();
26362 } catch (e) {
26363 this.reportError('Error getting tab ID for serialization ', e);
26364 tabId = null;
26365 }
26366
26367 return {
26368 'replayId': this.replayId,
26369 'seqNo': this.seqNo,
26370 'replayStartTime': this.replayStartTime,
26371 'batchStartUrl': this.batchStartUrl,
26372 'replayStartUrl': this.replayStartUrl,
26373 'idleExpires': this.idleExpires,
26374 'maxExpires': this.maxExpires,
26375 'tabId': tabId,
26376 };
26377 };
26378
26379
26380 /**
26381 * @static
26382 * @param {SerializedRecording} serializedRecording
26383 * @param {SessionRecordingOptions} options
26384 * @returns {SessionRecording}
26385 */
26386 SessionRecording.deserialize = function (serializedRecording, options) {
26387 var recording = new SessionRecording(_.extend({}, options, {
26388 replayId: serializedRecording['replayId'],
26389 batchStartUrl: serializedRecording['batchStartUrl'],
26390 replayStartUrl: serializedRecording['replayStartUrl'],
26391 idleExpires: serializedRecording['idleExpires'],
26392 maxExpires: serializedRecording['maxExpires'],
26393 replayStartTime: serializedRecording['replayStartTime'],
26394 seqNo: serializedRecording['seqNo'],
26395 sharedLockStorage: options.sharedLockStorage,
26396 }));
26397
26398 return recording;
26399 };
26400
26401 SessionRecording.prototype._sendRequest = function(currentReplayId, reqParams, reqBody, callback) {
26402 var onSuccess = function (response, responseBody) {
26403 // Update batch specific props only if the request was successful to guarantee ordering.
26404 // RequestBatcher will always flush the next batch after the previous one succeeds.
26405 // extra check to see if the replay ID has changed so that we don't increment the seqNo on the wrong replay
26406 if (response.status === 200 && this.replayId === currentReplayId) {
26407 this.seqNo++;
26408 this.batchStartUrl = _.info.currentUrl();
26409 }
26410
26411 this._onBatchSent();
26412 callback({
26413 status: 0,
26414 httpStatusCode: response.status,
26415 responseBody: responseBody,
26416 retryAfter: response.headers.get('Retry-After')
26417 });
26418 }.bind(this);
26419 var apiHost = (this._mixpanel.get_api_host && this._mixpanel.get_api_host('record')) || this.getConfig('api_host');
26420 win['fetch'](apiHost + '/' + this.getConfig('api_routes')['record'] + '?' + new URLSearchParams(reqParams), {
26421 'method': 'POST',
26422 'headers': {
26423 'Authorization': 'Basic ' + btoa(this.getConfig('token') + ':'),
26424 'Content-Type': 'application/octet-stream'
26425 },
26426 'body': reqBody,
26427 }).then(function (response) {
26428 response.json().then(function (responseBody) {
26429 onSuccess(response, responseBody);
26430 }).catch(function (error) {
26431 callback({error: error});
26432 });
26433 }).catch(function (error) {
26434 callback({error: error, httpStatusCode: 0});
26435 });
26436 };
26437
26438 SessionRecording.prototype._flushEvents = addOptOutCheckMixpanelLib(function (data, options, callback) {
26439 var numEvents = data.length;
26440
26441 if (numEvents > 0) {
26442 var replayId = this.replayId;
26443
26444 // each rrweb event has a timestamp - leverage those to get time properties
26445 var batchStartTime = Infinity;
26446 var batchEndTime = -Infinity;
26447 var hasFullSnapshot = false;
26448 for (var i = 0; i < numEvents; i++) {
26449 batchStartTime = Math.min(batchStartTime, data[i].timestamp);
26450 batchEndTime = Math.max(batchEndTime, data[i].timestamp);
26451 if (data[i].type === EventType.FullSnapshot) {
26452 hasFullSnapshot = true;
26453 }
26454 }
26455
26456 if (this.seqNo === 0) {
26457 if (!hasFullSnapshot) {
26458 callback({error: 'First batch does not contain a full snapshot. Aborting recording.'});
26459 this.stopRecording(true);
26460 return;
26461 }
26462 this.replayStartTime = batchStartTime;
26463 } else if (!this.replayStartTime) {
26464 this.reportError('Replay start time not set but seqNo is not 0. Using current batch start time as a fallback.');
26465 this.replayStartTime = batchStartTime;
26466 }
26467
26468 var replayLengthMs = batchEndTime - this.replayStartTime;
26469
26470 var reqParams = {
26471 '$current_url': this.batchStartUrl,
26472 '$lib_version': Config.LIB_VERSION,
26473 'batch_start_time': batchStartTime / 1000,
26474 'mp_lib': 'web',
26475 'replay_id': replayId,
26476 'replay_length_ms': replayLengthMs,
26477 'replay_start_time': this.replayStartTime / 1000,
26478 'replay_start_url': this.replayStartUrl,
26479 'seq': this.seqNo
26480 };
26481 var eventsJson = JSON.stringify(data);
26482 Object.assign(reqParams, this.getUserIdInfo());
26483
26484 if (CompressionStream) {
26485 var jsonStream = new Blob([eventsJson], {type: 'application/json'}).stream();
26486 var gzipStream = jsonStream.pipeThrough(new CompressionStream('gzip'));
26487 new Response(gzipStream)
26488 .blob()
26489 .then(function(compressedBlob) {
26490 reqParams['format'] = 'gzip';
26491 this._sendRequest(replayId, reqParams, compressedBlob, callback);
26492 }.bind(this));
26493 } else {
26494 reqParams['format'] = 'body';
26495 this._sendRequest(replayId, reqParams, eventsJson, callback);
26496 }
26497 }
26498 });
26499
26500
26501 SessionRecording.prototype.reportError = function(msg, err) {
26502 logger$3.error.apply(logger$3.error, arguments);
26503 try {
26504 if (!err && !(msg instanceof Error)) {
26505 msg = new Error(msg);
26506 }
26507 this.getConfig('error_reporter')(msg, err);
26508 } catch(err) {
26509 logger$3.error(err);
26510 }
26511 };
26512
26513 /**
26514 * Module for handling the storage and retrieval of recording metadata as well as any active recordings.
26515 * Makes sure that only one tab can be recording at a time.
26516 */
26517 var RecordingRegistry = function (options) {
26518 /** @type {IDBStorageWrapper} */
26519 this.idb = new IDBStorageWrapper(RECORDING_REGISTRY_STORE_NAME);
26520 this.errorReporter = options.errorReporter;
26521 this.mixpanelInstance = options.mixpanelInstance;
26522 this.sharedLockStorage = options.sharedLockStorage;
26523 };
26524
26525 RecordingRegistry.prototype.isPersistenceEnabled = function() {
26526 return !this.mixpanelInstance.get_config('disable_persistence');
26527 };
26528
26529 RecordingRegistry.prototype.handleError = function (err) {
26530 this.errorReporter('IndexedDB error: ', err);
26531 };
26532
26533 /**
26534 * @param {import('./session-recording').SerializedRecording} serializedRecording
26535 */
26536 RecordingRegistry.prototype.setActiveRecording = function (serializedRecording) {
26537 if (!this.isPersistenceEnabled()) {
26538 return PromisePolyfill.resolve();
26539 }
26540
26541 var tabId = serializedRecording['tabId'];
26542 if (!tabId) {
26543 console.warn('No tab ID is set, cannot persist recording metadata.');
26544 return PromisePolyfill.resolve();
26545 }
26546
26547 return this.idb.init()
26548 .then(function () {
26549 return this.idb.setItem(tabId, serializedRecording);
26550 }.bind(this))
26551 .catch(this.handleError.bind(this));
26552 };
26553
26554 /**
26555 * @returns {Promise<import('./session-recording').SerializedRecording>}
26556 */
26557 RecordingRegistry.prototype.getActiveRecording = function () {
26558 if (!this.isPersistenceEnabled()) {
26559 return PromisePolyfill.resolve(null);
26560 }
26561
26562 return this.idb.init()
26563 .then(function () {
26564 return this.idb.getItem(this.mixpanelInstance.get_tab_id());
26565 }.bind(this))
26566 .then(function (serializedRecording) {
26567 return isRecordingExpired(serializedRecording) ? null : serializedRecording;
26568 }.bind(this))
26569 .catch(this.handleError.bind(this));
26570 };
26571
26572 RecordingRegistry.prototype.clearActiveRecording = function () {
26573 if (this.isPersistenceEnabled()) {
26574 // mark recording as expired instead of deleting it in case the page unloads mid-flush and doesn't make it to ingestion.
26575 // this will ensure the next pageload will flush the remaining events, but not try to continue the recording.
26576 return this.markActiveRecordingExpired();
26577 } else {
26578 return this.deleteActiveRecording();
26579 }
26580 };
26581
26582 RecordingRegistry.prototype.markActiveRecordingExpired = function () {
26583 return this.getActiveRecording()
26584 .then(function (serializedRecording) {
26585 if (serializedRecording) {
26586 serializedRecording['maxExpires'] = 0;
26587 return this.setActiveRecording(serializedRecording);
26588 }
26589 }.bind(this))
26590 .catch(this.handleError.bind(this));
26591 };
26592
26593 RecordingRegistry.prototype.deleteActiveRecording = function () {
26594 // avoid initializing IDB if this registry instance hasn't already written a recording
26595 if (this.idb.isInitialized()) {
26596 return this.idb.removeItem(this.mixpanelInstance.get_tab_id())
26597 .catch(this.handleError.bind(this));
26598 } else {
26599 return PromisePolyfill.resolve();
26600 }
26601 };
26602
26603 /**
26604 * Flush any inactive recordings from the registry to minimize data loss.
26605 * The main idea here is that we can flush remaining rrweb events on the next page load if a tab is closed mid-batch.
26606 */
26607 RecordingRegistry.prototype.flushInactiveRecordings = function () {
26608 if (!this.isPersistenceEnabled()) {
26609 return PromisePolyfill.resolve([]);
26610 }
26611
26612 return this.idb.init()
26613 .then(function() {
26614 return this.idb.getAll();
26615 }.bind(this))
26616 .then(function (serializedRecordings) {
26617 // clean up any expired recordings from the registry, non-expired ones may be active in other tabs
26618 var unloadPromises = serializedRecordings
26619 .filter(function (serializedRecording) {
26620 return isRecordingExpired(serializedRecording);
26621 })
26622 .map(function (serializedRecording) {
26623 var sessionRecording = SessionRecording.deserialize(serializedRecording, {
26624 mixpanelInstance: this.mixpanelInstance,
26625 sharedLockStorage: this.sharedLockStorage
26626 });
26627 return sessionRecording.unloadPersistedData()
26628 .then(function () {
26629 // expired recording was successfully flushed, we can clean it up from the registry
26630 return this.idb.removeItem(serializedRecording['tabId']);
26631 }.bind(this))
26632 .catch(this.handleError.bind(this));
26633 }.bind(this));
26634
26635 return PromisePolyfill.all(unloadPromises);
26636 }.bind(this))
26637 .catch(this.handleError.bind(this));
26638 };
26639
26640 var logger$2 = console_with_prefix('recorder');
26641
26642 /**
26643 * Recorder API: bundles rrweb and and exposes methods to start and stop recordings.
26644 * @param {Object} [options.mixpanelInstance] - reference to the core MixpanelLib
26645 */
26646 var MixpanelRecorder = function(mixpanelInstance, rrwebRecord, sharedLockStorage) {
26647 this.mixpanelInstance = mixpanelInstance;
26648 this.rrwebRecord = rrwebRecord || record;
26649 this.sharedLockStorage = sharedLockStorage;
26650
26651 /**
26652 * @member {import('./registry').RecordingRegistry}
26653 */
26654 this.recordingRegistry = new RecordingRegistry({
26655 mixpanelInstance: this.mixpanelInstance,
26656 errorReporter: logger$2.error,
26657 sharedLockStorage: sharedLockStorage
26658 });
26659 this._flushInactivePromise = this.recordingRegistry.flushInactiveRecordings();
26660
26661 this.activeRecording = null;
26662 this.stopRecordingInProgress = false;
26663 };
26664
26665 MixpanelRecorder.prototype.startRecording = function(options) {
26666 options = options || {};
26667 if (this.activeRecording && !this.activeRecording.isRrwebStopped()) {
26668 logger$2.log('Recording already in progress, skipping startRecording.');
26669 return;
26670 }
26671
26672 var onIdleTimeout = function () {
26673 logger$2.log('Idle timeout reached, restarting recording.');
26674 this.resetRecording();
26675 }.bind(this);
26676
26677 var onMaxLengthReached = function () {
26678 logger$2.log('Max recording length reached, stopping recording.');
26679 this.resetRecording();
26680 }.bind(this);
26681
26682 var onBatchSent = function () {
26683 this.recordingRegistry.setActiveRecording(this.activeRecording.serialize());
26684 this['__flushPromise'] = this.activeRecording.batcher._flushPromise;
26685 }.bind(this);
26686
26687 /**
26688 * @type {import('./session-recording').SessionRecordingOptions}
26689 */
26690 var sessionRecordingOptions = {
26691 mixpanelInstance: this.mixpanelInstance,
26692 onBatchSent: onBatchSent,
26693 onIdleTimeout: onIdleTimeout,
26694 onMaxLengthReached: onMaxLengthReached,
26695 replayId: _.UUID(),
26696 rrwebRecord: this.rrwebRecord,
26697 sharedLockStorage: this.sharedLockStorage
26698 };
26699
26700 if (options.activeSerializedRecording) {
26701 this.activeRecording = SessionRecording.deserialize(options.activeSerializedRecording, sessionRecordingOptions);
26702 } else {
26703 this.activeRecording = new SessionRecording(sessionRecordingOptions);
26704 }
26705
26706 this.activeRecording.startRecording(options.shouldStopBatcher);
26707 return this.recordingRegistry.setActiveRecording(this.activeRecording.serialize());
26708 };
26709
26710 MixpanelRecorder.prototype.stopRecording = function() {
26711 // Prevents activeSerializedRecording from being reused when stopping the recording.
26712 this.stopRecordingInProgress = true;
26713 return this._stopCurrentRecording(false, true).then(function() {
26714 return this.recordingRegistry.clearActiveRecording();
26715 }.bind(this)).then(function() {
26716 this.stopRecordingInProgress = false;
26717 }.bind(this));
26718 };
26719
26720 MixpanelRecorder.prototype.pauseRecording = function() {
26721 return this._stopCurrentRecording(false);
26722 };
26723
26724 MixpanelRecorder.prototype._stopCurrentRecording = function(skipFlush, disableActiveRecording) {
26725 if (this.activeRecording) {
26726 var stopRecordingPromise = this.activeRecording.stopRecording(skipFlush);
26727 if (disableActiveRecording) {
26728 this.activeRecording = null;
26729 }
26730 return stopRecordingPromise;
26731 }
26732 return PromisePolyfill.resolve();
26733 };
26734
26735 MixpanelRecorder.prototype.resumeRecording = function (startNewIfInactive) {
26736 if (this.activeRecording && this.activeRecording.isRrwebStopped()) {
26737 this.activeRecording.startRecording(false);
26738 return PromisePolyfill.resolve(null);
26739 }
26740
26741 return this.recordingRegistry.getActiveRecording()
26742 .then(function (activeSerializedRecording) {
26743 if (activeSerializedRecording && !this.stopRecordingInProgress) {
26744 return this.startRecording({activeSerializedRecording: activeSerializedRecording});
26745 } else if (startNewIfInactive) {
26746 return this.startRecording({shouldStopBatcher: false});
26747 } else {
26748 logger$2.log('No resumable recording found.');
26749 return null;
26750 }
26751 }.bind(this));
26752 };
26753
26754
26755 MixpanelRecorder.prototype.resetRecording = function () {
26756 this.stopRecording();
26757 this.startRecording({shouldStopBatcher: true});
26758 };
26759
26760 MixpanelRecorder.prototype.getActiveReplayId = function () {
26761 if (this.activeRecording && !this.activeRecording.isRrwebStopped()) {
26762 return this.activeRecording.replayId;
26763 } else {
26764 return null;
26765 }
26766 };
26767
26768 // getter so that older mixpanel-core versions can still retrieve the replay ID
26769 // when pulling the latest recorder bundle from the CDN
26770 Object.defineProperty(MixpanelRecorder.prototype, 'replayId', {
26771 get: function () {
26772 return this.getActiveReplayId();
26773 }
26774 });
26775
26776 win['__mp_recorder'] = MixpanelRecorder;
26777
26778 // stateless utils
26779 // mostly from https://github.com/mixpanel/mixpanel-js/blob/989ada50f518edab47b9c4fd9535f9fbd5ec5fc0/src/autotrack-utils.js
26780
26781
26782 var EV_CHANGE = 'change';
26783 var EV_CLICK = 'click';
26784 var EV_HASHCHANGE = 'hashchange';
26785 var EV_INPUT = 'input';
26786 var EV_LOAD = 'load';
26787 var EV_MP_LOCATION_CHANGE = 'mp_locationchange';
26788 var EV_POPSTATE = 'popstate';
26789 // TODO scrollend isn't available in Safari: document or polyfill?
26790 var EV_SCROLLEND = 'scrollend';
26791 var EV_SCROLL = 'scroll';
26792 var EV_SELECT = 'select';
26793 var EV_SUBMIT = 'submit';
26794 var EV_TOGGLE = 'toggle';
26795 var EV_VISIBILITYCHANGE = 'visibilitychange';
26796
26797 var CLICK_EVENT_PROPS = [
26798 'clientX', 'clientY',
26799 'offsetX', 'offsetY',
26800 'pageX', 'pageY',
26801 'screenX', 'screenY',
26802 'x', 'y'
26803 ];
26804 var OPT_IN_CLASSES = ['mp-include'];
26805 var OPT_OUT_CLASSES = ['mp-no-track'];
26806 var SENSITIVE_DATA_CLASSES = OPT_OUT_CLASSES.concat(['mp-sensitive']);
26807 var TRACKED_ATTRS = [
26808 'aria-label', 'aria-labelledby', 'aria-describedby',
26809 'href', 'name', 'role', 'title', 'type'
26810 ];
26811
26812 var INTERACTIVE_ARIA_ROLES = {
26813 'button': true,
26814 'checkbox': true,
26815 'combobox': true,
26816 'grid': true,
26817 'link': true,
26818 'listbox': true,
26819 'menu': true,
26820 'menubar': true,
26821 'menuitem': true,
26822 'menuitemcheckbox': true,
26823 'menuitemradio': true,
26824 'navigation': true,
26825 'option': true,
26826 'radio': true,
26827 'radiogroup': true,
26828 'searchbox': true,
26829 'slider': true,
26830 'spinbutton': true,
26831 'switch': true,
26832 'tab': true,
26833 'tablist': true,
26834 'textbox': true,
26835 'tree': true,
26836 'treegrid': true,
26837 'treeitem': true
26838 };
26839
26840 var ALWAYS_NON_INTERACTIVE_TAGS = {
26841 // Document metadata
26842 'base': true,
26843 'head': true,
26844 'html': true,
26845 'link': true,
26846 'meta': true,
26847 'script': true,
26848 'style': true,
26849 'title': true,
26850 // Text formatting
26851 'br': true,
26852 'hr': true,
26853 'wbr': true,
26854 // Other
26855 'noscript': true,
26856 'picture': true,
26857 'source': true,
26858 'template': true,
26859 'track': true
26860 };
26861
26862 // Common container tags that need additional checks
26863 var TEXT_CONTAINER_TAGS = {
26864 'article': true,
26865 'div': true,
26866 'h1': true,
26867 'h2': true,
26868 'h3': true,
26869 'h4': true,
26870 'h5': true,
26871 'h6': true,
26872 'p': true,
26873 'section': true,
26874 'span': true
26875 };
26876
26877 var EVENT_HANDLER_ATTRIBUTES = [
26878 'onclick', 'onmousedown', 'onmouseup', 'onpointerdown', 'onpointerup', 'ontouchend', 'ontouchstart'
26879 ];
26880
26881 var MAX_DEPTH = 5;
26882
26883 var logger$1 = console_with_prefix('autocapture');
26884
26885
26886 function getClasses(el) {
26887 var classes = {};
26888 var classList = getClassName(el).split(' ');
26889 for (var i = 0; i < classList.length; i++) {
26890 var cls = classList[i];
26891 if (cls) {
26892 classes[cls] = true;
26893 }
26894 }
26895 return classes;
26896 }
26897
26898 /*
26899 * Get the className of an element, accounting for edge cases where element.className is an object
26900 * @param {Element} el - element to get the className of
26901 * @returns {string} the element's class
26902 */
26903 function getClassName(el) {
26904 switch(typeof el.className) {
26905 case 'string':
26906 return el.className;
26907 case 'object': // handle cases where className might be SVGAnimatedString or some other type
26908 return el.className.baseVal || el.getAttribute('class') || '';
26909 default: // future proof
26910 return '';
26911 }
26912 }
26913
26914 function getPreviousElementSibling(el) {
26915 if (el.previousElementSibling) {
26916 return el.previousElementSibling;
26917 } else {
26918 do {
26919 el = el.previousSibling;
26920 } while (el && !isElementNode(el));
26921 return el;
26922 }
26923 }
26924
26925 function getPropertiesFromElement(el, ev, blockAttrsSet, extraAttrs, allowElementCallback, allowSelectors) {
26926 var props = {
26927 '$classes': getClassName(el).split(' '),
26928 '$tag_name': el.tagName.toLowerCase()
26929 };
26930 var elId = el.id;
26931 if (elId) {
26932 props['$id'] = elId;
26933 }
26934
26935 if (shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors)) {
26936 _.each(TRACKED_ATTRS.concat(extraAttrs), function(attr) {
26937 if (el.hasAttribute(attr) && !blockAttrsSet[attr]) {
26938 var attrVal = el.getAttribute(attr);
26939 if (shouldTrackValue(attrVal)) {
26940 props['$attr-' + attr] = attrVal;
26941 }
26942 }
26943 });
26944 }
26945
26946 var nthChild = 1;
26947 var nthOfType = 1;
26948 var currentElem = el;
26949 while (currentElem = getPreviousElementSibling(currentElem)) { // eslint-disable-line no-cond-assign
26950 nthChild++;
26951 if (currentElem.tagName === el.tagName) {
26952 nthOfType++;
26953 }
26954 }
26955 props['$nth_child'] = nthChild;
26956 props['$nth_of_type'] = nthOfType;
26957
26958 return props;
26959 }
26960
26961 function getPropsForDOMEvent(ev, config) {
26962 var allowElementCallback = config.allowElementCallback;
26963 var allowSelectors = config.allowSelectors || [];
26964 var blockAttrs = config.blockAttrs || [];
26965 var blockElementCallback = config.blockElementCallback;
26966 var blockSelectors = config.blockSelectors || [];
26967 var captureTextContent = config.captureTextContent || false;
26968 var captureExtraAttrs = config.captureExtraAttrs || [];
26969 var capturedForHeatMap = config.capturedForHeatMap || false;
26970
26971 // convert array to set every time, as the config may have changed
26972 var blockAttrsSet = {};
26973 _.each(blockAttrs, function(attr) {
26974 blockAttrsSet[attr] = true;
26975 });
26976
26977 var props = null;
26978
26979 var target = typeof ev.target === 'undefined' ? ev.srcElement : ev.target;
26980 if (isTextNode(target)) { // defeat Safari bug (see: http://www.quirksmode.org/js/events_properties.html)
26981 target = target.parentNode;
26982 }
26983
26984 if (
26985 shouldTrackDomEvent(target, ev) &&
26986 isElementAllowed(target, ev, allowElementCallback, allowSelectors) &&
26987 !isElementBlocked(target, ev, blockElementCallback, blockSelectors)
26988 ) {
26989 var targetElementList = [target];
26990 var curEl = target;
26991 while (curEl.parentNode && !isTag(curEl, 'body')) {
26992 targetElementList.push(curEl.parentNode);
26993 curEl = curEl.parentNode;
26994 }
26995
26996 var elementsJson = [];
26997 var href, explicitNoTrack = false;
26998 _.each(targetElementList, function(el) {
26999 var shouldTrackDetails = shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors);
27000
27001 // if the element or a parent element is an anchor tag
27002 // include the href as a property
27003 if (!blockAttrsSet['href'] && el.tagName.toLowerCase() === 'a') {
27004 href = el.getAttribute('href');
27005 href = shouldTrackDetails && shouldTrackValue(href) && href;
27006 }
27007
27008 if (isElementBlocked(el, ev, blockElementCallback, blockSelectors)) {
27009 explicitNoTrack = true;
27010 }
27011
27012 elementsJson.push(getPropertiesFromElement(el, ev, blockAttrsSet, captureExtraAttrs, allowElementCallback, allowSelectors));
27013 }, this);
27014
27015 if (!explicitNoTrack) {
27016 var docElement = document$1['documentElement'];
27017 props = {
27018 '$event_type': ev.type,
27019 '$host': win.location.host,
27020 '$pathname': win.location.pathname,
27021 '$elements': elementsJson,
27022 '$el_attr__href': href,
27023 '$viewportHeight': Math.max(docElement['clientHeight'], win['innerHeight'] || 0),
27024 '$viewportWidth': Math.max(docElement['clientWidth'], win['innerWidth'] || 0),
27025 '$pageHeight': document$1['body']['offsetHeight'] || 0,
27026 '$pageWidth': document$1['body']['offsetWidth'] || 0,
27027 };
27028 _.each(captureExtraAttrs, function(attr) {
27029 if (!blockAttrsSet[attr] && target.hasAttribute(attr)) {
27030 var attrVal = target.getAttribute(attr);
27031 if (shouldTrackValue(attrVal)) {
27032 props['$el_attr__' + attr] = attrVal;
27033 }
27034 }
27035 });
27036
27037 if (captureTextContent) {
27038 elementText = getSafeText(target, ev, allowElementCallback, allowSelectors);
27039 if (elementText && elementText.length) {
27040 props['$el_text'] = elementText;
27041 }
27042 }
27043
27044 if (ev.type === EV_CLICK) {
27045 _.each(CLICK_EVENT_PROPS, function(prop) {
27046 if (prop in ev) {
27047 props['$' + prop] = ev[prop];
27048 }
27049 });
27050 if (capturedForHeatMap) {
27051 props['$captured_for_heatmap'] = true;
27052 }
27053 target = guessRealClickTarget(ev);
27054 }
27055 // prioritize text content from "real" click target if different from original target
27056 if (captureTextContent) {
27057 var elementText = getSafeText(target, ev, allowElementCallback, allowSelectors);
27058 if (elementText && elementText.length) {
27059 props['$el_text'] = elementText;
27060 }
27061 }
27062
27063 if (target) {
27064 // target may have been recalculated; check allowlists and blocklists again
27065 if (
27066 !isElementAllowed(target, ev, allowElementCallback, allowSelectors) ||
27067 isElementBlocked(target, ev, blockElementCallback, blockSelectors)
27068 ) {
27069 return null;
27070 }
27071
27072 var targetProps = getPropertiesFromElement(target, ev, blockAttrsSet, captureExtraAttrs, allowElementCallback, allowSelectors);
27073 props['$target'] = targetProps;
27074 // pull up more props onto main event props
27075 props['$el_classes'] = targetProps['$classes'];
27076 _.extend(props, _.strip_empty_properties({
27077 '$el_id': targetProps['$id'],
27078 '$el_tag_name': targetProps['$tag_name']
27079 }));
27080 }
27081 }
27082 }
27083
27084 return props;
27085 }
27086
27087
27088 /**
27089 * Get the direct text content of an element, protecting against sensitive data collection.
27090 * Concats textContent of each of the element's text node children; this avoids potential
27091 * collection of sensitive data that could happen if we used element.textContent and the
27092 * element had sensitive child elements, since element.textContent includes child content.
27093 * Scrubs values that look like they could be sensitive (i.e. cc or ssn number).
27094 * @param {Element} el - element to get the text of
27095 * @param {Array<string>} allowSelectors - CSS selectors for elements that should be included
27096 * @returns {string} the element's direct text content
27097 */
27098 function getSafeText(el, ev, allowElementCallback, allowSelectors) {
27099 var elText = '';
27100
27101 if (shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors) && el.childNodes && el.childNodes.length) {
27102 _.each(el.childNodes, function(child) {
27103 if (isTextNode(child) && child.textContent) {
27104 elText += _.trim(child.textContent)
27105 // scrub potentially sensitive values
27106 .split(/(\s+)/).filter(shouldTrackValue).join('')
27107 // normalize whitespace
27108 .replace(/[\r\n]/g, ' ').replace(/[ ]+/g, ' ')
27109 // truncate
27110 .substring(0, 255);
27111 }
27112 });
27113 }
27114
27115 return _.trim(elText);
27116 }
27117
27118 function guessRealClickTarget(ev) {
27119 var target = ev.target;
27120 var composedPath = ev['composedPath']();
27121 for (var i = 0; i < composedPath.length; i++) {
27122 var node = composedPath[i];
27123 if (
27124 isTag(node, 'a') ||
27125 isTag(node, 'button') ||
27126 isTag(node, 'input') ||
27127 isTag(node, 'select') ||
27128 (node.getAttribute && node.getAttribute('role') === 'button')
27129 ) {
27130 target = node;
27131 break;
27132 }
27133 if (node === target) {
27134 break;
27135 }
27136 }
27137 return target;
27138 }
27139
27140 function isElementAllowed(el, ev, allowElementCallback, allowSelectors) {
27141 if (allowElementCallback) {
27142 try {
27143 if (!allowElementCallback(el, ev)) {
27144 return false;
27145 }
27146 } catch (err) {
27147 logger$1.critical('Error while checking element in allowElementCallback', err);
27148 return false;
27149 }
27150 }
27151
27152 if (!allowSelectors.length) {
27153 // no allowlist; all elements are fair game
27154 return true;
27155 }
27156
27157 for (var i = 0; i < allowSelectors.length; i++) {
27158 var sel = allowSelectors[i];
27159 try {
27160 if (el['matches'](sel)) {
27161 return true;
27162 }
27163 } catch (err) {
27164 logger$1.critical('Error while checking selector: ' + sel, err);
27165 }
27166 }
27167 return false;
27168 }
27169
27170 function isElementBlocked(el, ev, blockElementCallback, blockSelectors) {
27171 var i;
27172
27173 if (blockElementCallback) {
27174 try {
27175 if (blockElementCallback(el, ev)) {
27176 return true;
27177 }
27178 } catch (err) {
27179 logger$1.critical('Error while checking element in blockElementCallback', err);
27180 return true;
27181 }
27182 }
27183
27184 if (blockSelectors && blockSelectors.length) {
27185 // programmatically prevent tracking of elements that match CSS selectors
27186 for (i = 0; i < blockSelectors.length; i++) {
27187 var sel = blockSelectors[i];
27188 try {
27189 if (el['matches'](sel)) {
27190 return true;
27191 }
27192 } catch (err) {
27193 logger$1.critical('Error while checking selector: ' + sel, err);
27194 }
27195 }
27196 }
27197
27198 // allow users to programmatically prevent tracking of elements by adding default classes such as 'mp-no-track'
27199 var classes = getClasses(el);
27200 for (i = 0; i < OPT_OUT_CLASSES.length; i++) {
27201 if (classes[OPT_OUT_CLASSES[i]]) {
27202 return true;
27203 }
27204 }
27205
27206 return false;
27207 }
27208
27209 /*
27210 * Check whether a DOM node has nodeType Node.ELEMENT_NODE
27211 * @param {Node} node - node to check
27212 * @returns {boolean} whether node is of the correct nodeType
27213 */
27214 function isElementNode(node) {
27215 return node && node.nodeType === 1; // Node.ELEMENT_NODE - use integer constant for browser portability
27216 }
27217
27218 /*
27219 * Check whether an element is of a given tag type.
27220 * Due to potential reference discrepancies (such as the webcomponents.js polyfill),
27221 * we want to match tagNames instead of specific references because something like
27222 * element === document.body won't always work because element might not be a native
27223 * element.
27224 * @param {Element} el - element to check
27225 * @param {string} tag - tag name (e.g., "div")
27226 * @returns {boolean} whether el is of the given tag type
27227 */
27228 function isTag(el, tag) {
27229 return el && el.tagName && el.tagName.toLowerCase() === tag.toLowerCase();
27230 }
27231
27232 /*
27233 * Check whether a DOM node is a TEXT_NODE
27234 * @param {Node} node - node to check
27235 * @returns {boolean} whether node is of type Node.TEXT_NODE
27236 */
27237 function isTextNode(node) {
27238 return node && node.nodeType === 3; // Node.TEXT_NODE - use integer constant for browser portability
27239 }
27240
27241 function minDOMApisSupported() {
27242 try {
27243 var testEl = document$1.createElement('div');
27244 return !!testEl['matches'];
27245 } catch (err) {
27246 return false;
27247 }
27248 }
27249
27250 function weakSetSupported() {
27251 return typeof WeakSet !== 'undefined';
27252 }
27253
27254 /*
27255 * Check whether a DOM event should be "tracked" or if it may contain sensitive data
27256 * using a variety of heuristics.
27257 * @param {Element} el - element to check
27258 * @param {Event} ev - event to check
27259 * @returns {boolean} whether the event should be tracked
27260 */
27261 function shouldTrackDomEvent(el, ev) {
27262 if (!el || isTag(el, 'html') || !isElementNode(el)) {
27263 return false;
27264 }
27265 var tag = el.tagName.toLowerCase();
27266 switch (tag) {
27267 case 'form':
27268 return ev.type === EV_SUBMIT;
27269 case 'input':
27270 if (['button', 'submit'].indexOf(el.getAttribute('type')) === -1) {
27271 return ev.type === EV_CHANGE;
27272 } else {
27273 return ev.type === EV_CLICK;
27274 }
27275 case 'select':
27276 case 'textarea':
27277 return ev.type === EV_CHANGE;
27278 default:
27279 return ev.type === EV_CLICK;
27280 }
27281 }
27282
27283 /*
27284 * Check whether a DOM element should be "tracked" or if it may contain sensitive data
27285 * using a variety of heuristics.
27286 * @param {Element} el - element to check
27287 * @param {Array<string>} allowSelectors - CSS selectors for elements that should be included
27288 * @returns {boolean} whether the element should be tracked
27289 */
27290 function shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors) {
27291 var i;
27292
27293 if (!isElementAllowed(el, ev, allowElementCallback, allowSelectors)) {
27294 return false;
27295 }
27296
27297 for (var curEl = el; curEl.parentNode && !isTag(curEl, 'body'); curEl = curEl.parentNode) {
27298 var classes = getClasses(curEl);
27299 for (i = 0; i < SENSITIVE_DATA_CLASSES.length; i++) {
27300 if (classes[SENSITIVE_DATA_CLASSES[i]]) {
27301 return false;
27302 }
27303 }
27304 }
27305
27306 var elClasses = getClasses(el);
27307 for (i = 0; i < OPT_IN_CLASSES.length; i++) {
27308 if (elClasses[OPT_IN_CLASSES[i]]) {
27309 return true;
27310 }
27311 }
27312
27313 // don't send data from inputs or similar elements since there will always be
27314 // a risk of clientside javascript placing sensitive data in attributes
27315 if (
27316 isTag(el, 'input') ||
27317 isTag(el, 'select') ||
27318 isTag(el, 'textarea') ||
27319 el.getAttribute('contenteditable') === 'true'
27320 ) {
27321 return false;
27322 }
27323
27324 // don't include hidden or password fields
27325 var type = el.type || '';
27326 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"]
27327 switch(type.toLowerCase()) {
27328 case 'hidden':
27329 return false;
27330 case 'password':
27331 return false;
27332 }
27333 }
27334
27335 // filter out data from fields that look like sensitive fields
27336 var name = el.name || el.id || '';
27337 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"]
27338 var sensitiveNameRegex = /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i;
27339 if (sensitiveNameRegex.test(name.replace(/[^a-zA-Z0-9]/g, ''))) {
27340 return false;
27341 }
27342 }
27343
27344 return true;
27345 }
27346
27347
27348 /*
27349 * Check whether a string value should be "tracked" or if it may contain sensitive data
27350 * using a variety of heuristics.
27351 * @param {string} value - string value to check
27352 * @returns {boolean} whether the element should be tracked
27353 */
27354 function shouldTrackValue(value) {
27355 if (value === null || _.isUndefined(value)) {
27356 return false;
27357 }
27358
27359 if (typeof value === 'string') {
27360 value = _.trim(value);
27361
27362 // check to see if input value looks like a credit card number
27363 // see: https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9781449327453/ch04s20.html
27364 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}))$/;
27365 if (ccRegex.test((value || '').replace(/[- ]/g, ''))) {
27366 return false;
27367 }
27368
27369 // check to see if input value looks like a social security number
27370 var ssnRegex = /(^\d{3}-?\d{2}-?\d{4}$)/;
27371 if (ssnRegex.test(value)) {
27372 return false;
27373 }
27374 }
27375
27376 return true;
27377 }
27378
27379 /**
27380 * Creates a cross-browser compatible scroll end function with appropriate event listener.
27381 * For browsers that support scrollend, returns the original function with scrollend event.
27382 * For browsers without scrollend support, returns a debounced function that triggers
27383 * 100ms after the last scroll event to simulate scrollend behavior.
27384 * @param {Function} originalFunction - The function to call when scrolling ends
27385 * @returns {Object} Object containing listener function and eventType string
27386 * @returns {Function} returns.listener - The wrapped function to use as event listener
27387 * @returns {string} returns.eventType - The event type to listen for ('scrollend' or 'scroll')
27388 */
27389 function getPolyfillScrollEndFunction(originalFunction) {
27390 var supportsScrollEnd = 'onscrollend' in win;
27391 var polyfillFunction = safewrap(originalFunction);
27392 var polyfillEvent = EV_SCROLLEND;
27393 if (!supportsScrollEnd) {
27394 // Polyfill for browsers without scrollend support: wait 100ms after the last scroll event
27395 // https://developer.chrome.com/blog/scrollend-a-new-javascript-event
27396 var scrollTimer = null;
27397 var scrollDelayMs = 100;
27398
27399 polyfillFunction = safewrap(function() {
27400 clearTimeout(scrollTimer);
27401 scrollTimer = setTimeout(originalFunction, scrollDelayMs);
27402 });
27403
27404 polyfillEvent = EV_SCROLL;
27405 }
27406
27407 return {
27408 listener: polyfillFunction,
27409 eventType: polyfillEvent
27410 };
27411 }
27412
27413 function hasInlineEventHandlers(element) {
27414 for (var i = 0; i < EVENT_HANDLER_ATTRIBUTES.length; i++) {
27415 if (element.hasAttribute(EVENT_HANDLER_ATTRIBUTES[i])) {
27416 return true;
27417 }
27418 }
27419 return false;
27420 }
27421
27422 function hasInteractiveAriaRole(element) {
27423 var role = element.getAttribute('role');
27424 if (!role) return false;
27425
27426 // Handle invalid markup where multiple roles might be specified
27427 // Only the first token is recognized per ARIA spec
27428 var primaryRole = role.trim().split(/\s+/)[0].toLowerCase();
27429
27430 return INTERACTIVE_ARIA_ROLES[primaryRole];
27431 }
27432
27433 function hasAnyInteractivityIndicators(element) {
27434 var tagName = element.tagName.toLowerCase();
27435
27436 // Check for interactive HTML elements
27437 if (tagName === 'button' ||
27438 tagName === 'input' ||
27439 tagName === 'select' ||
27440 tagName === 'textarea' ||
27441 tagName === 'details' ||
27442 tagName === 'dialog') {
27443 return true;
27444 }
27445
27446 if (element.isContentEditable) {
27447 return true;
27448 }
27449
27450 if (element.onclick || element.onmousedown || element.onmouseup || element.ontouchstart || element.ontouchend) {
27451 return true;
27452 }
27453
27454 if (hasInlineEventHandlers(element)) {
27455 return true;
27456 }
27457
27458 if (hasInteractiveAriaRole(element)) {
27459 return true;
27460 }
27461
27462 if (tagName === 'a' && element.hasAttribute('href')) {
27463 return true;
27464 }
27465
27466 if (element.hasAttribute('tabindex')) {
27467 return true;
27468 }
27469
27470 return false;
27471 }
27472
27473
27474 function isDefinitelyNonInteractive(element) {
27475 if (!element || !element.tagName) {
27476 return true;
27477 }
27478
27479 var tagName = element.tagName.toLowerCase();
27480
27481 // These tags are definitely non-interactive
27482 if (ALWAYS_NON_INTERACTIVE_TAGS[tagName]) {
27483 return true;
27484 }
27485
27486 // For all other elements, we can only be certain they're non-interactive if they lack ALL indicators of interactivity
27487 // Check for any signs of interactivity
27488 if (hasAnyInteractivityIndicators(element)) {
27489 return false;
27490 }
27491
27492 // Check parent chain for interactive context
27493 var parent = element.parentElement;
27494 var depth = 0;
27495
27496 while (parent && depth < MAX_DEPTH) {
27497 if (hasAnyInteractivityIndicators(parent)) {
27498 return false; // Element is inside an interactive parent
27499 }
27500
27501 if (parent.getRootNode && parent.getRootNode() !== document$1) {
27502 var root = parent.getRootNode();
27503 if (root.host && hasAnyInteractivityIndicators(root.host)) {
27504 return false; // Inside an interactive shadow host
27505 }
27506 }
27507
27508 parent = parent.parentElement;
27509 depth++;
27510 }
27511
27512 // Pure text containers without any interactive context
27513 if (TEXT_CONTAINER_TAGS[tagName]) {
27514 // These are non-interactive ONLY if they have no interactive indicators (already checked as part of hasAnyInteractivityIndicators)
27515 return true;
27516 }
27517
27518 // Default: we can't be certain it's non-interactive
27519 return false;
27520 }
27521
27522 /** @const */ var DEFAULT_RAGE_CLICK_THRESHOLD_PX = 30;
27523 /** @const */ var DEFAULT_RAGE_CLICK_TIMEOUT_MS = 1000;
27524 /** @const */ var DEFAULT_RAGE_CLICK_CLICK_COUNT = 4;
27525
27526 function RageClickTracker() {
27527 this.clicks = [];
27528 }
27529
27530 RageClickTracker.prototype.isRageClick = function(x, y, options) {
27531 options = options || {};
27532 var thresholdPx = options['threshold_px'] || DEFAULT_RAGE_CLICK_THRESHOLD_PX;
27533 var timeoutMs = options['timeout_ms'] || DEFAULT_RAGE_CLICK_TIMEOUT_MS;
27534 var clickCount = options['click_count'] || DEFAULT_RAGE_CLICK_CLICK_COUNT;
27535 var timestamp = Date.now();
27536
27537 var lastClick = this.clicks[this.clicks.length - 1];
27538 if (
27539 lastClick &&
27540 timestamp - lastClick.timestamp < timeoutMs &&
27541 Math.sqrt(Math.pow(x - lastClick.x, 2) + Math.pow(y - lastClick.y, 2)) < thresholdPx
27542 ) {
27543 this.clicks.push({ x: x, y: y, timestamp: timestamp });
27544 if (this.clicks.length >= clickCount) {
27545 this.clicks = [];
27546 return true;
27547 }
27548 } else {
27549 this.clicks = [{ x: x, y: y, timestamp: timestamp }];
27550 }
27551 return false;
27552 };
27553
27554 function ShadowDOMObserver(changeCallback, observerConfig) {
27555 this.changeCallback = changeCallback || function() {};
27556 this.observerConfig = observerConfig;
27557
27558 this.observedShadowRoots = null;
27559 this.shadowObservers = [];
27560 }
27561
27562 ShadowDOMObserver.prototype.getEventTarget = function(event) {
27563 if (!this.observedShadowRoots) {
27564 return;
27565 }
27566 var path = this.getComposedPath(event);
27567 if (path && path.length) {
27568 return path[0];
27569 }
27570
27571 return event['target'] || event['srcElement'];
27572 };
27573
27574
27575 ShadowDOMObserver.prototype.getComposedPath = function(event) {
27576 if ('composedPath' in event) {
27577 return event['composedPath']();
27578 }
27579
27580 return [];
27581 };
27582 ShadowDOMObserver.prototype.observeFromEvent = function(event) {
27583 if (!this.observedShadowRoots) {
27584 return;
27585 }
27586
27587 var path = this.getComposedPath(event);
27588
27589 // Check each element in path for shadow roots
27590 for (var i = 0; i < path.length; i++) {
27591 var element = path[i];
27592
27593 if (element && element.shadowRoot) {
27594 this.observeShadowRoot(element.shadowRoot);
27595 }
27596 }
27597 };
27598
27599
27600 ShadowDOMObserver.prototype.observeShadowRoot = function(shadowRoot) {
27601 if (!this.observedShadowRoots || this.observedShadowRoots.has(shadowRoot)) {
27602 return;
27603 }
27604
27605 var self = this;
27606
27607 try {
27608 this.observedShadowRoots.add(shadowRoot);
27609
27610 var observer = new window.MutationObserver(function() {
27611 self.changeCallback();
27612 });
27613
27614 observer.observe(shadowRoot, this.observerConfig);
27615 this.shadowObservers.push(observer);
27616 } catch (e) {
27617 logger$1.critical('Error while observing shadow root', e);
27618 }
27619 };
27620
27621
27622 ShadowDOMObserver.prototype.start = function() {
27623 if (this.observedShadowRoots) {
27624 return;
27625 }
27626
27627 if (!weakSetSupported()) {
27628 logger$1.critical('Shadow DOM observation unavailable: WeakSet not supported');
27629 return;
27630 }
27631
27632 this.observedShadowRoots = new WeakSet();
27633 };
27634
27635 ShadowDOMObserver.prototype.stop = function() {
27636 if (!this.observedShadowRoots) {
27637 return;
27638 }
27639
27640 for (var i = 0; i < this.shadowObservers.length; i++) {
27641 try {
27642 this.shadowObservers[i].disconnect();
27643 } catch (e) {
27644 logger$1.critical('Error while disconnecting shadow DOM observer', e);
27645 }
27646 }
27647 this.shadowObservers = [];
27648 this.observedShadowRoots = null;
27649 };
27650
27651 /** @const */ var DEFAULT_DEAD_CLICK_TIMEOUT_MS = 500;
27652 /** @const */ var INTERACTION_EVENTS = [EV_CHANGE, EV_INPUT, EV_SUBMIT, EV_SELECT, EV_TOGGLE];
27653 /** @const */ var LAYOUT_EVENTS = [EV_SCROLLEND];
27654 /** @const */ var NAVIGATION_EVENTS = [EV_HASHCHANGE];
27655 /** @const */ var MUTATION_OBSERVER_CONFIG = {
27656 characterData: true,
27657 childList: true,
27658 subtree: true,
27659 attributes: true,
27660 attributeFilter: ['style', 'class', 'hidden', 'checked', 'selected', 'value', 'display', 'visibility']
27661 };
27662
27663
27664 function DeadClickTracker(onDeadClickCallback) {
27665 this.eventListeners = [];
27666 this.mutationObserver = null;
27667 this.shadowDOMObserver = null;
27668
27669 this.isTracking = false;
27670 this.lastChangeEventTimestamp = 0;
27671 this.pendingClicks = [];
27672 this.onDeadClickCallback = onDeadClickCallback;
27673 this.processingActive = false;
27674 this.processingTimeout = null;
27675 }
27676
27677
27678 DeadClickTracker.prototype.addClick = function(event) {
27679 var element = this.shadowDOMObserver && this.shadowDOMObserver.getEventTarget(event);
27680
27681 if (!element) {
27682 element = event['target'] || event['srcElement'];
27683 }
27684
27685 if (!element || isDefinitelyNonInteractive(element)) {
27686 return false;
27687 }
27688
27689 if (this.shadowDOMObserver) {
27690 this.shadowDOMObserver.observeFromEvent(event);
27691 }
27692 this.pendingClicks.push({
27693 element: element,
27694 event: event,
27695 timestamp: Date.now()
27696 });
27697 return true;
27698 };
27699
27700 DeadClickTracker.prototype.trackClick = function(event, config) {
27701 if (!this.isTracking) {
27702 return false;
27703 }
27704
27705 var added = this.addClick(event);
27706 if (added) {
27707 this.triggerProcessing(config);
27708 }
27709 return added;
27710 };
27711
27712 DeadClickTracker.prototype.getDeadClicks = function(config) {
27713 if (this.pendingClicks.length === 0) {
27714 return [];
27715 }
27716
27717 var timeoutMs = config['timeout_ms'];
27718 var now = Date.now();
27719 var clicksToEvaluate = this.pendingClicks.slice(); // Copy array
27720 this.pendingClicks = []; // Clear original
27721
27722 var deadClicks = [];
27723
27724 for (var i = 0; i < clicksToEvaluate.length; i++) {
27725 var click = clicksToEvaluate[i];
27726
27727 if (now - click.timestamp >= timeoutMs) {
27728 // Click has exceeded timeout, check if it's dead by looking for changes after this specific click
27729 if (!this.hasChangesAfter(click.timestamp)) {
27730 deadClicks.push(click);
27731 }
27732 } else {
27733 // Still pending - add back
27734 this.pendingClicks.push(click);
27735 }
27736 }
27737
27738 return deadClicks;
27739 };
27740
27741 DeadClickTracker.prototype.hasChangesAfter = function(timestamp) {
27742 // 100ms tolerance for race condition between when we record the click and the change event
27743 return this.lastChangeEventTimestamp >= (timestamp - 100);
27744 };
27745
27746 DeadClickTracker.prototype.recordChangeEvent = function() {
27747 this.lastChangeEventTimestamp = Date.now();
27748 };
27749
27750 DeadClickTracker.prototype.triggerProcessing = function(config) {
27751 // Prevent multiple concurrent processing chains
27752 if (this.processingActive) {
27753 return;
27754 }
27755 this.processingActive = true;
27756 this.processRecursively(config);
27757 };
27758
27759 DeadClickTracker.prototype.processRecursively = function(config) {
27760 if (!this.isTracking || !this.onDeadClickCallback) {
27761 this.processingActive = false;
27762 return;
27763 }
27764
27765 var timeoutMs = config['timeout_ms'];
27766 var self = this;
27767
27768 this.processingTimeout = setTimeout(function() {
27769 if (!self.processingActive) {
27770 return;
27771 }
27772
27773 var deadClicks = self.getDeadClicks(config);
27774
27775 for (var i = 0; i < deadClicks.length; i++) {
27776 self.onDeadClickCallback(deadClicks[i].event);
27777 }
27778
27779 if (self.pendingClicks.length > 0) {
27780 self.processRecursively(config);
27781 } else {
27782 self.processingActive = false;
27783 }
27784 }, timeoutMs);
27785 };
27786
27787 DeadClickTracker.prototype.startTracking = function() {
27788 if (this.isTracking) {
27789 return;
27790 }
27791
27792 this.isTracking = true;
27793
27794 var self = this;
27795
27796 INTERACTION_EVENTS.forEach(function(event) {
27797 var handler = function() {
27798 self.recordChangeEvent();
27799 };
27800 document.addEventListener(event, handler, { capture: true, passive: true });
27801 self.eventListeners.push({ target: document, event: event, handler: handler, options: { capture: true, passive: true } });
27802 });
27803 NAVIGATION_EVENTS.forEach(function(event) {
27804 var handler = function() {
27805 self.recordChangeEvent();
27806 };
27807 window.addEventListener(event, handler);
27808 self.eventListeners.push({ target: window, event: event, handler: handler });
27809 });
27810 LAYOUT_EVENTS.forEach(function(event) {
27811 var handler = function() {
27812 self.recordChangeEvent();
27813 };
27814 window.addEventListener(event, handler, { passive: true });
27815 self.eventListeners.push({ target: window, event: event, handler: handler, options: { passive: true } });
27816 });
27817 var selectionHandler = function() {
27818 self.recordChangeEvent();
27819 };
27820 document.addEventListener('selectionchange', selectionHandler);
27821 self.eventListeners.push({ target: document, event: 'selectionchange', handler: selectionHandler });
27822
27823 // Set up MutationObserver
27824 if (window.MutationObserver) {
27825 try {
27826 this.mutationObserver = new window.MutationObserver(function() {
27827 self.recordChangeEvent();
27828 });
27829
27830 this.mutationObserver.observe(document.body || document.documentElement, MUTATION_OBSERVER_CONFIG);
27831 } catch (e) {
27832 logger$1.critical('Error while setting up mutation observer', e);
27833 }
27834 }
27835
27836 // Set up Shadow DOM observer
27837 if (window.customElements) {
27838 try {
27839 this.shadowDOMObserver = new ShadowDOMObserver(
27840 function() {
27841 self.recordChangeEvent();
27842 },
27843 MUTATION_OBSERVER_CONFIG
27844 );
27845 this.shadowDOMObserver.start();
27846 } catch (e) {
27847 logger$1.critical('Error while setting up shadow DOM observer', e);
27848 this.shadowDOMObserver = null;
27849 }
27850 }
27851 };
27852
27853 DeadClickTracker.prototype.stopTracking = function() {
27854 if (!this.isTracking) {
27855 return;
27856 }
27857
27858 this.isTracking = false;
27859 this.pendingClicks = [];
27860 this.lastChangeEventTimestamp = 0;
27861 this.processingActive = false;
27862
27863 if (this.processingTimeout) {
27864 clearTimeout(this.processingTimeout);
27865 this.processingTimeout = null;
27866 }
27867
27868 // Remove all event listeners
27869 for (var i = 0; i < this.eventListeners.length; i++) {
27870 var listener = this.eventListeners[i];
27871 try {
27872 listener.target.removeEventListener(listener.event, listener.handler, listener.options);
27873 } catch (e) {
27874 logger$1.critical('Error while removing event listener', e);
27875 }
27876 }
27877 this.eventListeners = [];
27878
27879 if (this.mutationObserver) {
27880 try {
27881 this.mutationObserver.disconnect();
27882 } catch (e) {
27883 logger$1.critical('Error while disconnecting mutation observer', e);
27884 }
27885 this.mutationObserver = null;
27886 }
27887
27888 if (this.shadowDOMObserver) {
27889 try {
27890 this.shadowDOMObserver.stop();
27891 } catch (e) {
27892 logger$1.critical('Error while stopping shadow DOM observer', e);
27893 }
27894 this.shadowDOMObserver = null;
27895 }
27896 };
27897
27898 var AUTOCAPTURE_CONFIG_KEY = 'autocapture';
27899 var LEGACY_PAGEVIEW_CONFIG_KEY = 'track_pageview';
27900
27901 var PAGEVIEW_OPTION_FULL_URL = 'full-url';
27902 var PAGEVIEW_OPTION_URL_WITH_PATH_AND_QUERY_STRING = 'url-with-path-and-query-string';
27903 var PAGEVIEW_OPTION_URL_WITH_PATH = 'url-with-path';
27904
27905 var CONFIG_ALLOW_ELEMENT_CALLBACK = 'allow_element_callback';
27906 var CONFIG_ALLOW_SELECTORS = 'allow_selectors';
27907 var CONFIG_ALLOW_URL_REGEXES = 'allow_url_regexes';
27908 var CONFIG_BLOCK_ATTRS = 'block_attrs';
27909 var CONFIG_BLOCK_ELEMENT_CALLBACK = 'block_element_callback';
27910 var CONFIG_BLOCK_SELECTORS = 'block_selectors';
27911 var CONFIG_BLOCK_URL_REGEXES = 'block_url_regexes';
27912 var CONFIG_CAPTURE_EXTRA_ATTRS = 'capture_extra_attrs';
27913 var CONFIG_CAPTURE_TEXT_CONTENT = 'capture_text_content';
27914 var CONFIG_SCROLL_CAPTURE_ALL = 'scroll_capture_all';
27915 var CONFIG_SCROLL_CHECKPOINTS = 'scroll_depth_percent_checkpoints';
27916 var CONFIG_TRACK_CLICK = 'click';
27917 var CONFIG_TRACK_DEAD_CLICK = 'dead_click';
27918 var CONFIG_TRACK_INPUT = 'input';
27919 var CONFIG_TRACK_PAGEVIEW = 'pageview';
27920 var CONFIG_TRACK_RAGE_CLICK = 'rage_click';
27921 var CONFIG_TRACK_SCROLL = 'scroll';
27922 var CONFIG_TRACK_PAGE_LEAVE = 'page_leave';
27923 var CONFIG_TRACK_SUBMIT = 'submit';
27924
27925 var CONFIG_DEFAULTS$1 = {};
27926 CONFIG_DEFAULTS$1[CONFIG_ALLOW_SELECTORS] = [];
27927 CONFIG_DEFAULTS$1[CONFIG_ALLOW_URL_REGEXES] = [];
27928 CONFIG_DEFAULTS$1[CONFIG_BLOCK_ATTRS] = [];
27929 CONFIG_DEFAULTS$1[CONFIG_BLOCK_ELEMENT_CALLBACK] = null;
27930 CONFIG_DEFAULTS$1[CONFIG_BLOCK_SELECTORS] = [];
27931 CONFIG_DEFAULTS$1[CONFIG_BLOCK_URL_REGEXES] = [];
27932 CONFIG_DEFAULTS$1[CONFIG_CAPTURE_EXTRA_ATTRS] = [];
27933 CONFIG_DEFAULTS$1[CONFIG_CAPTURE_TEXT_CONTENT] = false;
27934 CONFIG_DEFAULTS$1[CONFIG_SCROLL_CAPTURE_ALL] = false;
27935 CONFIG_DEFAULTS$1[CONFIG_SCROLL_CHECKPOINTS] = [25, 50, 75, 100];
27936 CONFIG_DEFAULTS$1[CONFIG_TRACK_CLICK] = true;
27937 CONFIG_DEFAULTS$1[CONFIG_TRACK_DEAD_CLICK] = true;
27938 CONFIG_DEFAULTS$1[CONFIG_TRACK_INPUT] = true;
27939 CONFIG_DEFAULTS$1[CONFIG_TRACK_PAGEVIEW] = PAGEVIEW_OPTION_FULL_URL;
27940 CONFIG_DEFAULTS$1[CONFIG_TRACK_RAGE_CLICK] = true;
27941 CONFIG_DEFAULTS$1[CONFIG_TRACK_SCROLL] = true;
27942 CONFIG_DEFAULTS$1[CONFIG_TRACK_PAGE_LEAVE] = false;
27943 CONFIG_DEFAULTS$1[CONFIG_TRACK_SUBMIT] = true;
27944
27945 var DEFAULT_PROPS = {
27946 '$mp_autocapture': true
27947 };
27948
27949 var MP_EV_CLICK = '$mp_click';
27950 var MP_EV_DEAD_CLICK = '$mp_dead_click';
27951 var MP_EV_INPUT = '$mp_input_change';
27952 var MP_EV_RAGE_CLICK = '$mp_rage_click';
27953 var MP_EV_SCROLL = '$mp_scroll';
27954 var MP_EV_SUBMIT = '$mp_submit';
27955 var MP_EV_PAGE_LEAVE = '$mp_page_leave';
27956
27957 /**
27958 * Autocapture: manages automatic event tracking
27959 * @constructor
27960 */
27961 var Autocapture = function(mp) {
27962 this.mp = mp;
27963 this.maxScrollViewDepth = 0;
27964 this.hasTrackedScrollSession = false;
27965 this.previousScrollHeight = 0;
27966 };
27967
27968 Autocapture.prototype.init = function() {
27969 if (!minDOMApisSupported()) {
27970 logger$1.critical('Autocapture unavailable: missing required DOM APIs');
27971 return;
27972 }
27973 this.initPageListeners();
27974 this.initPageviewTracking();
27975 this.initClickTracking();
27976 this.initDeadClickTracking();
27977 this.initInputTracking();
27978 this.initScrollTracking();
27979 this.initSubmitTracking();
27980 this.initRageClickTracking();
27981 this.initPageLeaveTracking();
27982 };
27983
27984 Autocapture.prototype.getFullConfig = function() {
27985 var autocaptureConfig = this.mp.get_config(AUTOCAPTURE_CONFIG_KEY);
27986 if (!autocaptureConfig) {
27987 // Autocapture is completely off
27988 return {};
27989 } else if (_.isObject(autocaptureConfig)) {
27990 return _.extend({}, CONFIG_DEFAULTS$1, autocaptureConfig);
27991 } else {
27992 // Autocapture config is non-object truthy value, return default
27993 return CONFIG_DEFAULTS$1;
27994 }
27995 };
27996
27997 Autocapture.prototype.getConfig = function(key) {
27998 return this.getFullConfig()[key];
27999 };
28000
28001 Autocapture.prototype.currentUrlBlocked = function() {
28002 var i;
28003 var currentUrl = _.info.currentUrl();
28004
28005 var allowUrlRegexes = this.getConfig(CONFIG_ALLOW_URL_REGEXES) || [];
28006 if (allowUrlRegexes.length) {
28007 // we're using an allowlist, only track if current URL matches
28008 var allowed = false;
28009 for (i = 0; i < allowUrlRegexes.length; i++) {
28010 var allowRegex = allowUrlRegexes[i];
28011 try {
28012 if (currentUrl.match(allowRegex)) {
28013 allowed = true;
28014 break;
28015 }
28016 } catch (err) {
28017 logger$1.critical('Error while checking block URL regex: ' + allowRegex, err);
28018 return true;
28019 }
28020 }
28021 if (!allowed) {
28022 // wasn't allowed by any regex
28023 return true;
28024 }
28025 }
28026
28027 var blockUrlRegexes = this.getConfig(CONFIG_BLOCK_URL_REGEXES) || [];
28028 if (!blockUrlRegexes || !blockUrlRegexes.length) {
28029 return false;
28030 }
28031
28032 for (i = 0; i < blockUrlRegexes.length; i++) {
28033 try {
28034 if (currentUrl.match(blockUrlRegexes[i])) {
28035 return true;
28036 }
28037 } catch (err) {
28038 logger$1.critical('Error while checking block URL regex: ' + blockUrlRegexes[i], err);
28039 return true;
28040 }
28041 }
28042 return false;
28043 };
28044
28045 Autocapture.prototype.pageviewTrackingConfig = function() {
28046 // supports both autocapture config and old track_pageview config
28047 if (this.mp.get_config(AUTOCAPTURE_CONFIG_KEY)) {
28048 return this.getConfig(CONFIG_TRACK_PAGEVIEW);
28049 } else {
28050 return this.mp.get_config(LEGACY_PAGEVIEW_CONFIG_KEY);
28051 }
28052 };
28053
28054 // helper for event handlers
28055 Autocapture.prototype.trackDomEvent = function(ev, mpEventName) {
28056 if (this.currentUrlBlocked()) {
28057 return;
28058 }
28059
28060 var isCapturedForHeatMap = this.mp.is_recording_heatmap_data() && (
28061 (mpEventName === MP_EV_CLICK && !this.getConfig(CONFIG_TRACK_CLICK)) ||
28062 (mpEventName === MP_EV_RAGE_CLICK && !this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK)) ||
28063 (mpEventName === MP_EV_DEAD_CLICK && !this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK))
28064 );
28065
28066 var props = getPropsForDOMEvent(ev, {
28067 allowElementCallback: this.getConfig(CONFIG_ALLOW_ELEMENT_CALLBACK),
28068 allowSelectors: this.getConfig(CONFIG_ALLOW_SELECTORS),
28069 blockAttrs: this.getConfig(CONFIG_BLOCK_ATTRS),
28070 blockElementCallback: this.getConfig(CONFIG_BLOCK_ELEMENT_CALLBACK),
28071 blockSelectors: this.getConfig(CONFIG_BLOCK_SELECTORS),
28072 captureExtraAttrs: this.getConfig(CONFIG_CAPTURE_EXTRA_ATTRS),
28073 captureTextContent: this.getConfig(CONFIG_CAPTURE_TEXT_CONTENT),
28074 capturedForHeatMap: isCapturedForHeatMap,
28075 });
28076 if (props) {
28077 _.extend(props, DEFAULT_PROPS);
28078 this.mp.track(mpEventName, props);
28079 }
28080 };
28081
28082 Autocapture.prototype.initPageListeners = function() {
28083 win.removeEventListener(EV_POPSTATE, this.listenerPopstate);
28084 win.removeEventListener(EV_HASHCHANGE, this.listenerHashchange);
28085
28086 if (!this.pageviewTrackingConfig() && !this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.get_config('record_heatmap_data')) {
28087 // These are all the configs that use these listeners
28088 return;
28089 }
28090
28091 this.listenerPopstate = function() {
28092 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
28093 };
28094 this.listenerHashchange = function() {
28095 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
28096 };
28097
28098 win.addEventListener(EV_POPSTATE, this.listenerPopstate);
28099 win.addEventListener(EV_HASHCHANGE, this.listenerHashchange);
28100 var nativePushState = win.history.pushState;
28101 if (typeof nativePushState === 'function') {
28102 win.history.pushState = function(state, unused, url) {
28103 nativePushState.call(win.history, state, unused, url);
28104 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
28105 };
28106 }
28107 var nativeReplaceState = win.history.replaceState;
28108 if (typeof nativeReplaceState === 'function') {
28109 win.history.replaceState = function(state, unused, url) {
28110 nativeReplaceState.call(win.history, state, unused, url);
28111 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
28112 };
28113 }
28114 };
28115
28116 Autocapture.prototype._getClickTrackingConfig = function(configKey) {
28117 var config = this.getConfig(configKey);
28118
28119 if (!config) {
28120 return null; // click tracking disabled
28121 }
28122
28123 if (config === true) {
28124 return {}; // use defaults
28125 }
28126
28127 if (typeof config === 'object') {
28128 return config; // use custom configuration
28129 }
28130
28131 return {}; // fallback to defaults for any other truthy value
28132 };
28133
28134 Autocapture.prototype._trackPageLeave = function(ev, currentUrl, currentScrollHeight) {
28135 if (this.hasTrackedScrollSession) {
28136 // User has navigated away already ending their impression.
28137 return;
28138 }
28139
28140 if (!this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.is_recording_heatmap_data()) {
28141 return;
28142 }
28143
28144 this.hasTrackedScrollSession = true;
28145 var viewportHeight = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
28146 var scrollPercentage = Math.round(Math.max(this.maxScrollViewDepth - viewportHeight, 0) / (currentScrollHeight - viewportHeight) * 100);
28147 var foldLinePercentage = Math.round((viewportHeight / currentScrollHeight) * 100);
28148 if (currentScrollHeight <= viewportHeight) {
28149 // If the content fits within the viewport, consider it fully scrolled
28150 scrollPercentage = 100;
28151 foldLinePercentage = 100;
28152 }
28153
28154 var props = _.extend({
28155 '$max_scroll_view_depth': this.maxScrollViewDepth,
28156 '$max_scroll_percentage': scrollPercentage,
28157 '$fold_line_percentage': foldLinePercentage,
28158 '$scroll_height': currentScrollHeight,
28159 '$event_type': ev.type,
28160 '$current_url': currentUrl || _.info.currentUrl(),
28161 '$viewportHeight': viewportHeight, // This is the fold line
28162 '$viewportWidth': Math.max(document$1.documentElement.clientWidth, win.innerWidth || 0),
28163 '$captured_for_heatmap': this.mp.is_recording_heatmap_data()
28164 }, DEFAULT_PROPS);
28165
28166 // Send with beacon transport to ensure event is sent before unload
28167 this.mp.track(MP_EV_PAGE_LEAVE, props, {transport: 'sendBeacon'});
28168 };
28169
28170 Autocapture.prototype._initScrollDepthTracking = function() {
28171 win.removeEventListener(EV_SCROLL, this.listenerScrollDepth);
28172 win.removeEventListener(EV_SCROLLEND, this.listenerScrollDepth);
28173
28174 if (!this.mp.get_config('record_heatmap_data')) {
28175 return;
28176 }
28177
28178 logger$1.log('Initializing scroll depth tracking');
28179
28180 this.maxScrollViewDepth = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
28181
28182 var updateScrollDepth = function() {
28183 if (this.currentUrlBlocked()) {
28184 return;
28185 }
28186 var scrollViewHeight = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0) + win.scrollY;
28187 if (scrollViewHeight > this.maxScrollViewDepth) {
28188 this.maxScrollViewDepth = scrollViewHeight;
28189 }
28190 this.previousScrollHeight = document$1.body.scrollHeight;
28191 }.bind(this);
28192
28193 var scrollEndPolyfill = getPolyfillScrollEndFunction(updateScrollDepth);
28194 this.listenerScrollDepth = scrollEndPolyfill.listener;
28195 win.addEventListener(scrollEndPolyfill.eventType, this.listenerScrollDepth);
28196 };
28197
28198 Autocapture.prototype.initClickTracking = function() {
28199 win.removeEventListener(EV_CLICK, this.listenerClick);
28200
28201 if (!this.getConfig(CONFIG_TRACK_CLICK) && !this.mp.get_config('record_heatmap_data')) {
28202 return;
28203 }
28204 logger$1.log('Initializing click tracking');
28205
28206 this.listenerClick = function(ev) {
28207 if (!this.getConfig(CONFIG_TRACK_CLICK) && !this.mp.is_recording_heatmap_data()) {
28208 return;
28209 }
28210 this.trackDomEvent(ev, MP_EV_CLICK);
28211 }.bind(this);
28212 win.addEventListener(EV_CLICK, this.listenerClick);
28213 };
28214
28215 Autocapture.prototype.initDeadClickTracking = function() {
28216 var deadClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK);
28217
28218 if (!deadClickConfig && !this.mp.get_config('record_heatmap_data')) {
28219 this.stopDeadClickTracking();
28220 return;
28221 }
28222
28223 logger$1.log('Initializing dead click tracking');
28224 if (!this._deadClickTracker) {
28225 this._deadClickTracker = new DeadClickTracker(function(deadClickEvent) {
28226 this.trackDomEvent(deadClickEvent, MP_EV_DEAD_CLICK);
28227 }.bind(this));
28228 this._deadClickTracker.startTracking();
28229 }
28230
28231 if (!this.listenerDeadClick) {
28232 this.listenerDeadClick = function(ev) {
28233 var currentDeadClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK);
28234 if (!currentDeadClickConfig && !this.mp.is_recording_heatmap_data()) {
28235 return;
28236 }
28237 if (this.currentUrlBlocked()) {
28238 return;
28239 }
28240 // Normalize config to ensure timeout_ms is always set
28241 var normalizedConfig = currentDeadClickConfig || {};
28242 if (!normalizedConfig['timeout_ms']) {
28243 normalizedConfig['timeout_ms'] = DEFAULT_DEAD_CLICK_TIMEOUT_MS;
28244 }
28245 this._deadClickTracker.trackClick(ev, normalizedConfig);
28246 }.bind(this);
28247 win.addEventListener(EV_CLICK, this.listenerDeadClick);
28248 }
28249 };
28250
28251 Autocapture.prototype.initInputTracking = function() {
28252 win.removeEventListener(EV_CHANGE, this.listenerChange);
28253
28254 if (!this.getConfig(CONFIG_TRACK_INPUT)) {
28255 return;
28256 }
28257 logger$1.log('Initializing input tracking');
28258
28259 this.listenerChange = function(ev) {
28260 if (!this.getConfig(CONFIG_TRACK_INPUT)) {
28261 return;
28262 }
28263 this.trackDomEvent(ev, MP_EV_INPUT);
28264 }.bind(this);
28265 win.addEventListener(EV_CHANGE, this.listenerChange);
28266 };
28267
28268 Autocapture.prototype.initPageviewTracking = function() {
28269 win.removeEventListener(EV_MP_LOCATION_CHANGE, this.listenerLocationchange);
28270
28271 if (!this.pageviewTrackingConfig()) {
28272 return;
28273 }
28274 logger$1.log('Initializing pageview tracking');
28275
28276 var previousTrackedUrl = '';
28277 var tracked = false;
28278 if (!this.currentUrlBlocked()) {
28279 tracked = this.mp.track_pageview(DEFAULT_PROPS);
28280 }
28281 if (tracked) {
28282 previousTrackedUrl = _.info.currentUrl();
28283 }
28284
28285 this.listenerLocationchange = safewrap(function() {
28286 if (this.currentUrlBlocked()) {
28287 return;
28288 }
28289
28290 var currentUrl = _.info.currentUrl();
28291 var shouldTrack = false;
28292 var didPathChange = currentUrl.split('#')[0].split('?')[0] !== previousTrackedUrl.split('#')[0].split('?')[0];
28293 var trackPageviewOption = this.pageviewTrackingConfig();
28294 if (trackPageviewOption === PAGEVIEW_OPTION_FULL_URL) {
28295 shouldTrack = currentUrl !== previousTrackedUrl;
28296 } else if (trackPageviewOption === PAGEVIEW_OPTION_URL_WITH_PATH_AND_QUERY_STRING) {
28297 shouldTrack = currentUrl.split('#')[0] !== previousTrackedUrl.split('#')[0];
28298 } else if (trackPageviewOption === PAGEVIEW_OPTION_URL_WITH_PATH) {
28299 shouldTrack = didPathChange;
28300 }
28301
28302 if (shouldTrack) {
28303 var tracked = this.mp.track_pageview(DEFAULT_PROPS);
28304 if (tracked) {
28305 previousTrackedUrl = currentUrl;
28306 }
28307 if (didPathChange) {
28308 this.lastScrollCheckpoint = 0;
28309 logger$1.log('Path change: re-initializing scroll depth checkpoints');
28310 }
28311 }
28312 }.bind(this));
28313 win.addEventListener(EV_MP_LOCATION_CHANGE, this.listenerLocationchange);
28314 };
28315
28316 Autocapture.prototype.initRageClickTracking = function() {
28317 win.removeEventListener(EV_CLICK, this.listenerRageClick);
28318
28319 var rageClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK);
28320 if (!rageClickConfig && !this.mp.get_config('record_heatmap_data')) {
28321 return;
28322 }
28323
28324 logger$1.log('Initializing rage click tracking');
28325 if (!this._rageClickTracker) {
28326 this._rageClickTracker = new RageClickTracker();
28327 }
28328
28329 this.listenerRageClick = function(ev) {
28330 var currentRageClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK);
28331 if (!currentRageClickConfig && !this.mp.is_recording_heatmap_data()) {
28332 return;
28333 }
28334
28335 if (this.currentUrlBlocked()) {
28336 return;
28337 }
28338
28339 if (this._rageClickTracker.isRageClick(ev['pageX'], ev['pageY'], currentRageClickConfig)) {
28340 this.trackDomEvent(ev, MP_EV_RAGE_CLICK);
28341 }
28342 }.bind(this);
28343 win.addEventListener(EV_CLICK, this.listenerRageClick);
28344 };
28345
28346 Autocapture.prototype.initScrollTracking = function() {
28347 win.removeEventListener(EV_SCROLLEND, this.listenerScroll);
28348 win.removeEventListener(EV_SCROLL, this.listenerScroll);
28349
28350
28351 if (!this.getConfig(CONFIG_TRACK_SCROLL)) {
28352 return;
28353 }
28354 logger$1.log('Initializing scroll tracking');
28355 this.lastScrollCheckpoint = 0;
28356
28357 var scrollTrackFunction = function() {
28358 if (!this.getConfig(CONFIG_TRACK_SCROLL)) {
28359 return;
28360 }
28361 if (this.currentUrlBlocked()) {
28362 return;
28363 }
28364
28365 var shouldTrack = this.getConfig(CONFIG_SCROLL_CAPTURE_ALL);
28366 var scrollCheckpoints = (this.getConfig(CONFIG_SCROLL_CHECKPOINTS) || [])
28367 .slice()
28368 .sort(function(a, b) { return a - b; });
28369
28370 var scrollTop = win.scrollY;
28371 var props = _.extend({'$scroll_top': scrollTop}, DEFAULT_PROPS);
28372 try {
28373 var scrollHeight = document$1.body.scrollHeight;
28374 var scrollPercentage = Math.round((scrollTop / (scrollHeight - win.innerHeight)) * 100);
28375 props['$scroll_height'] = scrollHeight;
28376 props['$scroll_percentage'] = scrollPercentage;
28377 if (scrollPercentage > this.lastScrollCheckpoint) {
28378 for (var i = 0; i < scrollCheckpoints.length; i++) {
28379 var checkpoint = scrollCheckpoints[i];
28380 if (
28381 scrollPercentage >= checkpoint &&
28382 this.lastScrollCheckpoint < checkpoint
28383 ) {
28384 props['$scroll_checkpoint'] = checkpoint;
28385 this.lastScrollCheckpoint = checkpoint;
28386 shouldTrack = true;
28387 }
28388 }
28389 }
28390 } catch (err) {
28391 logger$1.critical('Error while calculating scroll percentage', err);
28392 }
28393 if (shouldTrack) {
28394 this.mp.track(MP_EV_SCROLL, props);
28395 }
28396 }.bind(this);
28397
28398 var scrollEndPolyfill = getPolyfillScrollEndFunction(scrollTrackFunction);
28399 this.listenerScroll = scrollEndPolyfill.listener;
28400 win.addEventListener(scrollEndPolyfill.eventType, this.listenerScroll);
28401 };
28402
28403 Autocapture.prototype.initSubmitTracking = function() {
28404 win.removeEventListener(EV_SUBMIT, this.listenerSubmit);
28405
28406 if (!this.getConfig(CONFIG_TRACK_SUBMIT)) {
28407 return;
28408 }
28409 logger$1.log('Initializing submit tracking');
28410
28411 this.listenerSubmit = function(ev) {
28412 if (!this.getConfig(CONFIG_TRACK_SUBMIT)) {
28413 return;
28414 }
28415 this.trackDomEvent(ev, MP_EV_SUBMIT);
28416 }.bind(this);
28417 win.addEventListener(EV_SUBMIT, this.listenerSubmit);
28418 };
28419
28420 Autocapture.prototype.initPageLeaveTracking = function() {
28421 // Capture page_leave both when the user navigates away from the page (visibilitychange) as well
28422 // as when they navigate to a different page within the SPA (popstate/pushstate/hashchange).
28423 document$1.removeEventListener(EV_VISIBILITYCHANGE, this.listenerPageLeaveVisibilitychange);
28424 win.removeEventListener(EV_MP_LOCATION_CHANGE, this.listenerPageLeaveLocationchange);
28425 win.removeEventListener(EV_LOAD, this.listenerPageLoad);
28426
28427 if (!this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.get_config('record_heatmap_data')) {
28428 return;
28429 }
28430
28431 logger$1.log('Initializing page visibility tracking.');
28432 this._initScrollDepthTracking();
28433 var previousTrackedUrl = _.info.currentUrl();
28434
28435 // Initialize previousScrollHeight on `load` which handles async loading
28436 // https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event
28437 this.listenerPageLoad = function() {
28438 this.previousScrollHeight = document$1.body.scrollHeight;
28439 }.bind(this);
28440 win.addEventListener(EV_LOAD, this.listenerPageLoad);
28441
28442 // Track page navigation events similar to how initPageviewTracking does it
28443 this.listenerPageLeaveLocationchange = safewrap(function(ev) {
28444 if (this.currentUrlBlocked()) {
28445 return;
28446 }
28447
28448 var currentUrl = _.info.currentUrl();
28449 // Track all URL changes including query string or fragment changes as separate scroll sessions
28450 var shouldTrack = currentUrl !== previousTrackedUrl;
28451
28452 if (shouldTrack) {
28453 this._trackPageLeave(ev, previousTrackedUrl, this.previousScrollHeight);
28454 previousTrackedUrl = currentUrl;
28455 // Fragment navigation should call scroll(end) and trigger listener, don't add window.scrollY here.
28456 this.maxScrollViewDepth = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
28457 this.previousScrollHeight = document$1.body.scrollHeight;
28458 this.hasTrackedScrollSession = false;
28459 }
28460 }.bind(this));
28461 win.addEventListener(EV_MP_LOCATION_CHANGE, this.listenerPageLeaveLocationchange);
28462
28463 this.listenerPageLeaveVisibilitychange = function(ev) {
28464 if (document$1.hidden) {
28465 this._trackPageLeave(ev, previousTrackedUrl, this.previousScrollHeight);
28466 }
28467 }.bind(this);
28468 document$1.addEventListener(EV_VISIBILITYCHANGE, this.listenerPageLeaveVisibilitychange);
28469 };
28470
28471 Autocapture.prototype.stopDeadClickTracking = function() {
28472 if (this.listenerDeadClick) {
28473 win.removeEventListener(EV_CLICK, this.listenerDeadClick);
28474 this.listenerDeadClick = null;
28475 }
28476
28477 if (this._deadClickTracker) {
28478 this._deadClickTracker.stopTracking();
28479 this._deadClickTracker = null;
28480 }
28481 };
28482
28483 // TODO integrate error_reporter from mixpanel instance
28484 safewrapClass(Autocapture);
28485
28486 var logger = console_with_prefix('flags');
28487
28488 var FLAGS_CONFIG_KEY = 'flags';
28489
28490 var CONFIG_CONTEXT = 'context';
28491 var CONFIG_DEFAULTS = {};
28492 CONFIG_DEFAULTS[CONFIG_CONTEXT] = {};
28493
28494 /**
28495 * FeatureFlagManager: support for Mixpanel's feature flagging product
28496 * @constructor
28497 */
28498 var FeatureFlagManager = function(initOptions) {
28499 this.fetch = win['fetch'];
28500 this.getFullApiRoute = initOptions.getFullApiRoute;
28501 this.getMpConfig = initOptions.getConfigFunc;
28502 this.setMpConfig = initOptions.setConfigFunc;
28503 this.getMpProperty = initOptions.getPropertyFunc;
28504 this.track = initOptions.trackingFunc;
28505 };
28506
28507 FeatureFlagManager.prototype.init = function() {
28508 if (!this.minApisSupported()) {
28509 logger.critical('Feature Flags unavailable: missing minimum required APIs');
28510 return;
28511 }
28512
28513 this.flags = null;
28514 this.fetchFlags();
28515
28516 this.trackedFeatures = new Set();
28517 };
28518
28519 FeatureFlagManager.prototype.getFullConfig = function() {
28520 var ffConfig = this.getMpConfig(FLAGS_CONFIG_KEY);
28521 if (!ffConfig) {
28522 // flags are completely off
28523 return {};
28524 } else if (_.isObject(ffConfig)) {
28525 return _.extend({}, CONFIG_DEFAULTS, ffConfig);
28526 } else {
28527 // config is non-object truthy value, return default
28528 return CONFIG_DEFAULTS;
28529 }
28530 };
28531
28532 FeatureFlagManager.prototype.getConfig = function(key) {
28533 return this.getFullConfig()[key];
28534 };
28535
28536 FeatureFlagManager.prototype.isSystemEnabled = function() {
28537 return !!this.getMpConfig(FLAGS_CONFIG_KEY);
28538 };
28539
28540 FeatureFlagManager.prototype.updateContext = function(newContext, options) {
28541 if (!this.isSystemEnabled()) {
28542 logger.critical('Feature Flags not enabled, cannot update context');
28543 return Promise.resolve();
28544 }
28545
28546 var ffConfig = this.getMpConfig(FLAGS_CONFIG_KEY);
28547 if (!_.isObject(ffConfig)) {
28548 ffConfig = {};
28549 }
28550 var oldContext = (options && options['replace']) ? {} : this.getConfig(CONFIG_CONTEXT);
28551 ffConfig[CONFIG_CONTEXT] = _.extend({}, oldContext, newContext);
28552
28553 this.setMpConfig(FLAGS_CONFIG_KEY, ffConfig);
28554 return this.fetchFlags();
28555 };
28556
28557 FeatureFlagManager.prototype.areFlagsReady = function() {
28558 if (!this.isSystemEnabled()) {
28559 logger.error('Feature Flags not enabled');
28560 }
28561 return !!this.flags;
28562 };
28563
28564 FeatureFlagManager.prototype.fetchFlags = function() {
28565 if (!this.isSystemEnabled()) {
28566 return Promise.resolve();
28567 }
28568
28569 var distinctId = this.getMpProperty('distinct_id');
28570 var deviceId = this.getMpProperty('$device_id');
28571 var traceparent = generateTraceparent();
28572 logger.log('Fetching flags for distinct ID: ' + distinctId);
28573
28574 var context = _.extend({'distinct_id': distinctId, 'device_id': deviceId}, this.getConfig(CONFIG_CONTEXT));
28575 var searchParams = new URLSearchParams();
28576 searchParams.set('context', JSON.stringify(context));
28577 searchParams.set('token', this.getMpConfig('token'));
28578 searchParams.set('mp_lib', 'web');
28579 searchParams.set('$lib_version', Config.LIB_VERSION);
28580 var url = this.getFullApiRoute() + '?' + searchParams.toString();
28581
28582 this._fetchInProgressStartTime = Date.now();
28583 this.fetchPromise = this.fetch.call(win, url, {
28584 'method': 'GET',
28585 'headers': {
28586 'Authorization': 'Basic ' + btoa(this.getMpConfig('token') + ':'),
28587 'traceparent': traceparent
28588 }
28589 }).then(function(response) {
28590 this.markFetchComplete();
28591 return response.json().then(function(responseBody) {
28592 var responseFlags = responseBody['flags'];
28593 if (!responseFlags) {
28594 throw new Error('No flags in API response');
28595 }
28596 var flags = new Map();
28597 _.each(responseFlags, function(data, key) {
28598 flags.set(key, {
28599 'key': data['variant_key'],
28600 'value': data['variant_value'],
28601 'experiment_id': data['experiment_id'],
28602 'is_experiment_active': data['is_experiment_active'],
28603 'is_qa_tester': data['is_qa_tester']
28604 });
28605 });
28606 this.flags = flags;
28607 this._traceparent = traceparent;
28608 }.bind(this)).catch(function(error) {
28609 this.markFetchComplete();
28610 logger.error(error);
28611 }.bind(this));
28612 }.bind(this)).catch(function(error) {
28613 this.markFetchComplete();
28614 logger.error(error);
28615 }.bind(this));
28616
28617 return this.fetchPromise;
28618 };
28619
28620 FeatureFlagManager.prototype.markFetchComplete = function() {
28621 if (!this._fetchInProgressStartTime) {
28622 logger.error('Fetch in progress started time not set, cannot mark fetch complete');
28623 return;
28624 }
28625 this._fetchStartTime = this._fetchInProgressStartTime;
28626 this._fetchCompleteTime = Date.now();
28627 this._fetchLatency = this._fetchCompleteTime - this._fetchStartTime;
28628 this._fetchInProgressStartTime = null;
28629 };
28630
28631 FeatureFlagManager.prototype.getVariant = function(featureName, fallback) {
28632 if (!this.fetchPromise) {
28633 return new Promise(function(resolve) {
28634 logger.critical('Feature Flags not initialized');
28635 resolve(fallback);
28636 });
28637 }
28638
28639 return this.fetchPromise.then(function() {
28640 return this.getVariantSync(featureName, fallback);
28641 }.bind(this)).catch(function(error) {
28642 logger.error(error);
28643 return fallback;
28644 });
28645 };
28646
28647 FeatureFlagManager.prototype.getVariantSync = function(featureName, fallback) {
28648 if (!this.areFlagsReady()) {
28649 logger.log('Flags not loaded yet');
28650 return fallback;
28651 }
28652 var feature = this.flags.get(featureName);
28653 if (!feature) {
28654 logger.log('No flag found: "' + featureName + '"');
28655 return fallback;
28656 }
28657 this.trackFeatureCheck(featureName, feature);
28658 return feature;
28659 };
28660
28661 FeatureFlagManager.prototype.getVariantValue = function(featureName, fallbackValue) {
28662 return this.getVariant(featureName, {'value': fallbackValue}).then(function(feature) {
28663 return feature['value'];
28664 }).catch(function(error) {
28665 logger.error(error);
28666 return fallbackValue;
28667 });
28668 };
28669
28670 // TODO remove deprecated method
28671 FeatureFlagManager.prototype.getFeatureData = function(featureName, fallbackValue) {
28672 logger.critical('mixpanel.flags.get_feature_data() is deprecated and will be removed in a future release. Use mixpanel.flags.get_variant_value() instead.');
28673 return this.getVariantValue(featureName, fallbackValue);
28674 };
28675
28676 FeatureFlagManager.prototype.getVariantValueSync = function(featureName, fallbackValue) {
28677 return this.getVariantSync(featureName, {'value': fallbackValue})['value'];
28678 };
28679
28680 FeatureFlagManager.prototype.isEnabled = function(featureName, fallbackValue) {
28681 return this.getVariantValue(featureName).then(function() {
28682 return this.isEnabledSync(featureName, fallbackValue);
28683 }.bind(this)).catch(function(error) {
28684 logger.error(error);
28685 return fallbackValue;
28686 });
28687 };
28688
28689 FeatureFlagManager.prototype.isEnabledSync = function(featureName, fallbackValue) {
28690 fallbackValue = fallbackValue || false;
28691 var val = this.getVariantValueSync(featureName, fallbackValue);
28692 if (val !== true && val !== false) {
28693 logger.error('Feature flag "' + featureName + '" value: ' + val + ' is not a boolean; returning fallback value: ' + fallbackValue);
28694 val = fallbackValue;
28695 }
28696 return val;
28697 };
28698
28699 FeatureFlagManager.prototype.trackFeatureCheck = function(featureName, feature) {
28700 if (this.trackedFeatures.has(featureName)) {
28701 return;
28702 }
28703 this.trackedFeatures.add(featureName);
28704
28705 var trackingProperties = {
28706 'Experiment name': featureName,
28707 'Variant name': feature['key'],
28708 '$experiment_type': 'feature_flag',
28709 'Variant fetch start time': new Date(this._fetchStartTime).toISOString(),
28710 'Variant fetch complete time': new Date(this._fetchCompleteTime).toISOString(),
28711 'Variant fetch latency (ms)': this._fetchLatency,
28712 'Variant fetch traceparent': this._traceparent,
28713 };
28714
28715 if (feature['experiment_id'] !== 'undefined') {
28716 trackingProperties['$experiment_id'] = feature['experiment_id'];
28717 }
28718 if (feature['is_experiment_active'] !== 'undefined') {
28719 trackingProperties['$is_experiment_active'] = feature['is_experiment_active'];
28720 }
28721 if (feature['is_qa_tester'] !== 'undefined') {
28722 trackingProperties['$is_qa_tester'] = feature['is_qa_tester'];
28723 }
28724
28725 this.track('$experiment_started', trackingProperties);
28726 };
28727
28728 FeatureFlagManager.prototype.minApisSupported = function() {
28729 return !!this.fetch &&
28730 typeof Promise !== 'undefined' &&
28731 typeof Map !== 'undefined' &&
28732 typeof Set !== 'undefined';
28733 };
28734
28735 safewrapClass(FeatureFlagManager);
28736
28737 FeatureFlagManager.prototype['are_flags_ready'] = FeatureFlagManager.prototype.areFlagsReady;
28738 FeatureFlagManager.prototype['get_variant'] = FeatureFlagManager.prototype.getVariant;
28739 FeatureFlagManager.prototype['get_variant_sync'] = FeatureFlagManager.prototype.getVariantSync;
28740 FeatureFlagManager.prototype['get_variant_value'] = FeatureFlagManager.prototype.getVariantValue;
28741 FeatureFlagManager.prototype['get_variant_value_sync'] = FeatureFlagManager.prototype.getVariantValueSync;
28742 FeatureFlagManager.prototype['is_enabled'] = FeatureFlagManager.prototype.isEnabled;
28743 FeatureFlagManager.prototype['is_enabled_sync'] = FeatureFlagManager.prototype.isEnabledSync;
28744 FeatureFlagManager.prototype['update_context'] = FeatureFlagManager.prototype.updateContext;
28745
28746 // Deprecated method
28747 FeatureFlagManager.prototype['get_feature_data'] = FeatureFlagManager.prototype.getFeatureData;
28748
28749 /* eslint camelcase: "off" */
28750
28751
28752 /**
28753 * DomTracker Object
28754 * @constructor
28755 */
28756 var DomTracker = function() {};
28757
28758
28759 // interface
28760 DomTracker.prototype.create_properties = function() {};
28761 DomTracker.prototype.event_handler = function() {};
28762 DomTracker.prototype.after_track_handler = function() {};
28763
28764 DomTracker.prototype.init = function(mixpanel_instance) {
28765 this.mp = mixpanel_instance;
28766 return this;
28767 };
28768
28769 /**
28770 * @param {Object|string} query
28771 * @param {string} event_name
28772 * @param {Object=} properties
28773 * @param {function=} user_callback
28774 */
28775 DomTracker.prototype.track = function(query, event_name, properties, user_callback) {
28776 var that = this;
28777 var elements = _.dom_query(query);
28778
28779 if (elements.length === 0) {
28780 console$1.error('The DOM query (' + query + ') returned 0 elements');
28781 return;
28782 }
28783
28784 _.each(elements, function(element) {
28785 _.register_event(element, this.override_event, function(e) {
28786 var options = {};
28787 var props = that.create_properties(properties, this);
28788 var timeout = that.mp.get_config('track_links_timeout');
28789
28790 that.event_handler(e, this, options);
28791
28792 // in case the mixpanel servers don't get back to us in time
28793 window.setTimeout(that.track_callback(user_callback, props, options, true), timeout);
28794
28795 // fire the tracking event
28796 that.mp.track(event_name, props, that.track_callback(user_callback, props, options));
28797 });
28798 }, this);
28799
28800 return true;
28801 };
28802
28803 /**
28804 * @param {function} user_callback
28805 * @param {Object} props
28806 * @param {boolean=} timeout_occured
28807 */
28808 DomTracker.prototype.track_callback = function(user_callback, props, options, timeout_occured) {
28809 timeout_occured = timeout_occured || false;
28810 var that = this;
28811
28812 return function() {
28813 // options is referenced from both callbacks, so we can have
28814 // a 'lock' of sorts to ensure only one fires
28815 if (options.callback_fired) { return; }
28816 options.callback_fired = true;
28817
28818 if (user_callback && user_callback(timeout_occured, props) === false) {
28819 // user can prevent the default functionality by
28820 // returning false from their callback
28821 return;
28822 }
28823
28824 that.after_track_handler(props, options, timeout_occured);
28825 };
28826 };
28827
28828 DomTracker.prototype.create_properties = function(properties, element) {
28829 var props;
28830
28831 if (typeof(properties) === 'function') {
28832 props = properties(element);
28833 } else {
28834 props = _.extend({}, properties);
28835 }
28836
28837 return props;
28838 };
28839
28840 /**
28841 * LinkTracker Object
28842 * @constructor
28843 * @extends DomTracker
28844 */
28845 var LinkTracker = function() {
28846 this.override_event = 'click';
28847 };
28848 _.inherit(LinkTracker, DomTracker);
28849
28850 LinkTracker.prototype.create_properties = function(properties, element) {
28851 var props = LinkTracker.superclass.create_properties.apply(this, arguments);
28852
28853 if (element.href) { props['url'] = element.href; }
28854
28855 return props;
28856 };
28857
28858 LinkTracker.prototype.event_handler = function(evt, element, options) {
28859 options.new_tab = (
28860 evt.which === 2 ||
28861 evt.metaKey ||
28862 evt.ctrlKey ||
28863 element.target === '_blank'
28864 );
28865 options.href = element.href;
28866
28867 if (!options.new_tab) {
28868 evt.preventDefault();
28869 }
28870 };
28871
28872 LinkTracker.prototype.after_track_handler = function(props, options) {
28873 if (options.new_tab) { return; }
28874
28875 setTimeout(function() {
28876 window.location = options.href;
28877 }, 0);
28878 };
28879
28880 /**
28881 * FormTracker Object
28882 * @constructor
28883 * @extends DomTracker
28884 */
28885 var FormTracker = function() {
28886 this.override_event = 'submit';
28887 };
28888 _.inherit(FormTracker, DomTracker);
28889
28890 FormTracker.prototype.event_handler = function(evt, element, options) {
28891 options.element = element;
28892 evt.preventDefault();
28893 };
28894
28895 FormTracker.prototype.after_track_handler = function(props, options) {
28896 setTimeout(function() {
28897 options.element.submit();
28898 }, 0);
28899 };
28900
28901 /* eslint camelcase: "off" */
28902
28903
28904 /** @const */ var SET_ACTION = '$set';
28905 /** @const */ var SET_ONCE_ACTION = '$set_once';
28906 /** @const */ var UNSET_ACTION = '$unset';
28907 /** @const */ var ADD_ACTION = '$add';
28908 /** @const */ var APPEND_ACTION = '$append';
28909 /** @const */ var UNION_ACTION = '$union';
28910 /** @const */ var REMOVE_ACTION = '$remove';
28911 /** @const */ var DELETE_ACTION = '$delete';
28912
28913 // Common internal methods for mixpanel.people and mixpanel.group APIs.
28914 // These methods shouldn't involve network I/O.
28915 var apiActions = {
28916 set_action: function(prop, to) {
28917 var data = {};
28918 var $set = {};
28919 if (_.isObject(prop)) {
28920 _.each(prop, function(v, k) {
28921 if (!this._is_reserved_property(k)) {
28922 $set[k] = v;
28923 }
28924 }, this);
28925 } else {
28926 $set[prop] = to;
28927 }
28928
28929 data[SET_ACTION] = $set;
28930 return data;
28931 },
28932
28933 unset_action: function(prop) {
28934 var data = {};
28935 var $unset = [];
28936 if (!_.isArray(prop)) {
28937 prop = [prop];
28938 }
28939
28940 _.each(prop, function(k) {
28941 if (!this._is_reserved_property(k)) {
28942 $unset.push(k);
28943 }
28944 }, this);
28945
28946 data[UNSET_ACTION] = $unset;
28947 return data;
28948 },
28949
28950 set_once_action: function(prop, to) {
28951 var data = {};
28952 var $set_once = {};
28953 if (_.isObject(prop)) {
28954 _.each(prop, function(v, k) {
28955 if (!this._is_reserved_property(k)) {
28956 $set_once[k] = v;
28957 }
28958 }, this);
28959 } else {
28960 $set_once[prop] = to;
28961 }
28962 data[SET_ONCE_ACTION] = $set_once;
28963 return data;
28964 },
28965
28966 union_action: function(list_name, values) {
28967 var data = {};
28968 var $union = {};
28969 if (_.isObject(list_name)) {
28970 _.each(list_name, function(v, k) {
28971 if (!this._is_reserved_property(k)) {
28972 $union[k] = _.isArray(v) ? v : [v];
28973 }
28974 }, this);
28975 } else {
28976 $union[list_name] = _.isArray(values) ? values : [values];
28977 }
28978 data[UNION_ACTION] = $union;
28979 return data;
28980 },
28981
28982 append_action: function(list_name, value) {
28983 var data = {};
28984 var $append = {};
28985 if (_.isObject(list_name)) {
28986 _.each(list_name, function(v, k) {
28987 if (!this._is_reserved_property(k)) {
28988 $append[k] = v;
28989 }
28990 }, this);
28991 } else {
28992 $append[list_name] = value;
28993 }
28994 data[APPEND_ACTION] = $append;
28995 return data;
28996 },
28997
28998 remove_action: function(list_name, value) {
28999 var data = {};
29000 var $remove = {};
29001 if (_.isObject(list_name)) {
29002 _.each(list_name, function(v, k) {
29003 if (!this._is_reserved_property(k)) {
29004 $remove[k] = v;
29005 }
29006 }, this);
29007 } else {
29008 $remove[list_name] = value;
29009 }
29010 data[REMOVE_ACTION] = $remove;
29011 return data;
29012 },
29013
29014 delete_action: function() {
29015 var data = {};
29016 data[DELETE_ACTION] = '';
29017 return data;
29018 }
29019 };
29020
29021 /* eslint camelcase: "off" */
29022
29023 /**
29024 * Mixpanel Group Object
29025 * @constructor
29026 */
29027 var MixpanelGroup = function() {};
29028
29029 _.extend(MixpanelGroup.prototype, apiActions);
29030
29031 MixpanelGroup.prototype._init = function(mixpanel_instance, group_key, group_id) {
29032 this._mixpanel = mixpanel_instance;
29033 this._group_key = group_key;
29034 this._group_id = group_id;
29035 };
29036
29037 /**
29038 * Set properties on a group.
29039 *
29040 * ### Usage:
29041 *
29042 * mixpanel.get_group('company', 'mixpanel').set('Location', '405 Howard');
29043 *
29044 * // or set multiple properties at once
29045 * mixpanel.get_group('company', 'mixpanel').set({
29046 * 'Location': '405 Howard',
29047 * 'Founded' : 2009,
29048 * });
29049 * // properties can be strings, integers, dates, or lists
29050 *
29051 * @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.
29052 * @param {*} [to] A value to set on the given property name
29053 * @param {Function} [callback] If provided, the callback will be called after the tracking event
29054 */
29055 MixpanelGroup.prototype.set = addOptOutCheckMixpanelGroup(function(prop, to, callback) {
29056 var data = this.set_action(prop, to);
29057 if (_.isObject(prop)) {
29058 callback = to;
29059 }
29060 return this._send_request(data, callback);
29061 });
29062
29063 /**
29064 * Set properties on a group, only if they do not yet exist.
29065 * This will not overwrite previous group property values, unlike
29066 * group.set().
29067 *
29068 * ### Usage:
29069 *
29070 * mixpanel.get_group('company', 'mixpanel').set_once('Location', '405 Howard');
29071 *
29072 * // or set multiple properties at once
29073 * mixpanel.get_group('company', 'mixpanel').set_once({
29074 * 'Location': '405 Howard',
29075 * 'Founded' : 2009,
29076 * });
29077 * // properties can be strings, integers, lists or dates
29078 *
29079 * @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.
29080 * @param {*} [to] A value to set on the given property name
29081 * @param {Function} [callback] If provided, the callback will be called after the tracking event
29082 */
29083 MixpanelGroup.prototype.set_once = addOptOutCheckMixpanelGroup(function(prop, to, callback) {
29084 var data = this.set_once_action(prop, to);
29085 if (_.isObject(prop)) {
29086 callback = to;
29087 }
29088 return this._send_request(data, callback);
29089 });
29090
29091 /**
29092 * Unset properties on a group permanently.
29093 *
29094 * ### Usage:
29095 *
29096 * mixpanel.get_group('company', 'mixpanel').unset('Founded');
29097 *
29098 * @param {String} prop The name of the property.
29099 * @param {Function} [callback] If provided, the callback will be called after the tracking event
29100 */
29101 MixpanelGroup.prototype.unset = addOptOutCheckMixpanelGroup(function(prop, callback) {
29102 var data = this.unset_action(prop);
29103 return this._send_request(data, callback);
29104 });
29105
29106 /**
29107 * Merge a given list with a list-valued group property, excluding duplicate values.
29108 *
29109 * ### Usage:
29110 *
29111 * // merge a value to a list, creating it if needed
29112 * mixpanel.get_group('company', 'mixpanel').union('Location', ['San Francisco', 'London']);
29113 *
29114 * @param {String} list_name Name of the property.
29115 * @param {Array} values Values to merge with the given property
29116 * @param {Function} [callback] If provided, the callback will be called after the tracking event
29117 */
29118 MixpanelGroup.prototype.union = addOptOutCheckMixpanelGroup(function(list_name, values, callback) {
29119 if (_.isObject(list_name)) {
29120 callback = values;
29121 }
29122 var data = this.union_action(list_name, values);
29123 return this._send_request(data, callback);
29124 });
29125
29126 /**
29127 * Permanently delete a group.
29128 *
29129 * ### Usage:
29130 *
29131 * mixpanel.get_group('company', 'mixpanel').delete();
29132 *
29133 * @param {Function} [callback] If provided, the callback will be called after the tracking event
29134 */
29135 MixpanelGroup.prototype['delete'] = addOptOutCheckMixpanelGroup(function(callback) {
29136 // bracket notation above prevents a minification error related to reserved words
29137 var data = this.delete_action();
29138 return this._send_request(data, callback);
29139 });
29140
29141 /**
29142 * Remove a property from a group. The value will be ignored if doesn't exist.
29143 *
29144 * ### Usage:
29145 *
29146 * mixpanel.get_group('company', 'mixpanel').remove('Location', 'London');
29147 *
29148 * @param {String} list_name Name of the property.
29149 * @param {Object} value Value to remove from the given group property
29150 * @param {Function} [callback] If provided, the callback will be called after the tracking event
29151 */
29152 MixpanelGroup.prototype.remove = addOptOutCheckMixpanelGroup(function(list_name, value, callback) {
29153 var data = this.remove_action(list_name, value);
29154 return this._send_request(data, callback);
29155 });
29156
29157 MixpanelGroup.prototype._send_request = function(data, callback) {
29158 data['$group_key'] = this._group_key;
29159 data['$group_id'] = this._group_id;
29160 data['$token'] = this._get_config('token');
29161
29162 var date_encoded_data = _.encodeDates(data);
29163 return this._mixpanel._track_or_batch({
29164 type: 'groups',
29165 data: date_encoded_data,
29166 endpoint: this._mixpanel.get_api_host('groups') + '/' + this._get_config('api_routes')['groups'],
29167 batcher: this._mixpanel.request_batchers.groups
29168 }, callback);
29169 };
29170
29171 MixpanelGroup.prototype._is_reserved_property = function(prop) {
29172 return prop === '$group_key' || prop === '$group_id';
29173 };
29174
29175 MixpanelGroup.prototype._get_config = function(conf) {
29176 return this._mixpanel.get_config(conf);
29177 };
29178
29179 MixpanelGroup.prototype.toString = function() {
29180 return this._mixpanel.toString() + '.group.' + this._group_key + '.' + this._group_id;
29181 };
29182
29183 // MixpanelGroup Exports
29184 MixpanelGroup.prototype['remove'] = MixpanelGroup.prototype.remove;
29185 MixpanelGroup.prototype['set'] = MixpanelGroup.prototype.set;
29186 MixpanelGroup.prototype['set_once'] = MixpanelGroup.prototype.set_once;
29187 MixpanelGroup.prototype['union'] = MixpanelGroup.prototype.union;
29188 MixpanelGroup.prototype['unset'] = MixpanelGroup.prototype.unset;
29189 MixpanelGroup.prototype['toString'] = MixpanelGroup.prototype.toString;
29190
29191 /* eslint camelcase: "off" */
29192
29193 /**
29194 * Mixpanel People Object
29195 * @constructor
29196 */
29197 var MixpanelPeople = function() {};
29198
29199 _.extend(MixpanelPeople.prototype, apiActions);
29200
29201 MixpanelPeople.prototype._init = function(mixpanel_instance) {
29202 this._mixpanel = mixpanel_instance;
29203 };
29204
29205 /*
29206 * Set properties on a user record.
29207 *
29208 * ### Usage:
29209 *
29210 * mixpanel.people.set('gender', 'm');
29211 *
29212 * // or set multiple properties at once
29213 * mixpanel.people.set({
29214 * 'Company': 'Acme',
29215 * 'Plan': 'Premium',
29216 * 'Upgrade date': new Date()
29217 * });
29218 * // properties can be strings, integers, dates, or lists
29219 *
29220 * @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.
29221 * @param {*} [to] A value to set on the given property name
29222 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29223 */
29224 MixpanelPeople.prototype.set = addOptOutCheckMixpanelPeople(function(prop, to, callback) {
29225 var data = this.set_action(prop, to);
29226 if (_.isObject(prop)) {
29227 callback = to;
29228 }
29229 // make sure that the referrer info has been updated and saved
29230 if (this._get_config('save_referrer')) {
29231 this._mixpanel['persistence'].update_referrer_info(document.referrer);
29232 }
29233
29234 // update $set object with default people properties
29235 data[SET_ACTION] = _.extend(
29236 {},
29237 _.info.people_properties(),
29238 data[SET_ACTION]
29239 );
29240 return this._send_request(data, callback);
29241 });
29242
29243 /*
29244 * Set properties on a user record, only if they do not yet exist.
29245 * This will not overwrite previous people property values, unlike
29246 * people.set().
29247 *
29248 * ### Usage:
29249 *
29250 * mixpanel.people.set_once('First Login Date', new Date());
29251 *
29252 * // or set multiple properties at once
29253 * mixpanel.people.set_once({
29254 * 'First Login Date': new Date(),
29255 * 'Starting Plan': 'Premium'
29256 * });
29257 *
29258 * // properties can be strings, integers or dates
29259 *
29260 * @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.
29261 * @param {*} [to] A value to set on the given property name
29262 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29263 */
29264 MixpanelPeople.prototype.set_once = addOptOutCheckMixpanelPeople(function(prop, to, callback) {
29265 var data = this.set_once_action(prop, to);
29266 if (_.isObject(prop)) {
29267 callback = to;
29268 }
29269 return this._send_request(data, callback);
29270 });
29271
29272 /*
29273 * Unset properties on a user record (permanently removes the properties and their values from a profile).
29274 *
29275 * ### Usage:
29276 *
29277 * mixpanel.people.unset('gender');
29278 *
29279 * // or unset multiple properties at once
29280 * mixpanel.people.unset(['gender', 'Company']);
29281 *
29282 * @param {Array|String} prop If a string, this is the name of the property. If an array, this is a list of property names.
29283 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29284 */
29285 MixpanelPeople.prototype.unset = addOptOutCheckMixpanelPeople(function(prop, callback) {
29286 var data = this.unset_action(prop);
29287 return this._send_request(data, callback);
29288 });
29289
29290 /*
29291 * Increment/decrement numeric people analytics properties.
29292 *
29293 * ### Usage:
29294 *
29295 * mixpanel.people.increment('page_views', 1);
29296 *
29297 * // or, for convenience, if you're just incrementing a counter by
29298 * // 1, you can simply do
29299 * mixpanel.people.increment('page_views');
29300 *
29301 * // to decrement a counter, pass a negative number
29302 * mixpanel.people.increment('credits_left', -1);
29303 *
29304 * // like mixpanel.people.set(), you can increment multiple
29305 * // properties at once:
29306 * mixpanel.people.increment({
29307 * counter1: 1,
29308 * counter2: 6
29309 * });
29310 *
29311 * @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.
29312 * @param {Number} [by] An amount to increment the given property
29313 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29314 */
29315 MixpanelPeople.prototype.increment = addOptOutCheckMixpanelPeople(function(prop, by, callback) {
29316 var data = {};
29317 var $add = {};
29318 if (_.isObject(prop)) {
29319 _.each(prop, function(v, k) {
29320 if (!this._is_reserved_property(k)) {
29321 if (isNaN(parseFloat(v))) {
29322 console$1.error('Invalid increment value passed to mixpanel.people.increment - must be a number');
29323 return;
29324 } else {
29325 $add[k] = v;
29326 }
29327 }
29328 }, this);
29329 callback = by;
29330 } else {
29331 // convenience: mixpanel.people.increment('property'); will
29332 // increment 'property' by 1
29333 if (_.isUndefined(by)) {
29334 by = 1;
29335 }
29336 $add[prop] = by;
29337 }
29338 data[ADD_ACTION] = $add;
29339
29340 return this._send_request(data, callback);
29341 });
29342
29343 /*
29344 * Append a value to a list-valued people analytics property.
29345 *
29346 * ### Usage:
29347 *
29348 * // append a value to a list, creating it if needed
29349 * mixpanel.people.append('pages_visited', 'homepage');
29350 *
29351 * // like mixpanel.people.set(), you can append multiple
29352 * // properties at once:
29353 * mixpanel.people.append({
29354 * list1: 'bob',
29355 * list2: 123
29356 * });
29357 *
29358 * @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.
29359 * @param {*} [value] value An item to append to the list
29360 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29361 */
29362 MixpanelPeople.prototype.append = addOptOutCheckMixpanelPeople(function(list_name, value, callback) {
29363 if (_.isObject(list_name)) {
29364 callback = value;
29365 }
29366 var data = this.append_action(list_name, value);
29367 return this._send_request(data, callback);
29368 });
29369
29370 /*
29371 * Remove a value from a list-valued people analytics property.
29372 *
29373 * ### Usage:
29374 *
29375 * mixpanel.people.remove('School', 'UCB');
29376 *
29377 * @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.
29378 * @param {*} [value] value Item to remove from the list
29379 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29380 */
29381 MixpanelPeople.prototype.remove = addOptOutCheckMixpanelPeople(function(list_name, value, callback) {
29382 if (_.isObject(list_name)) {
29383 callback = value;
29384 }
29385 var data = this.remove_action(list_name, value);
29386 return this._send_request(data, callback);
29387 });
29388
29389 /*
29390 * Merge a given list with a list-valued people analytics property,
29391 * excluding duplicate values.
29392 *
29393 * ### Usage:
29394 *
29395 * // merge a value to a list, creating it if needed
29396 * mixpanel.people.union('pages_visited', 'homepage');
29397 *
29398 * // like mixpanel.people.set(), you can append multiple
29399 * // properties at once:
29400 * mixpanel.people.union({
29401 * list1: 'bob',
29402 * list2: 123
29403 * });
29404 *
29405 * // like mixpanel.people.append(), you can append multiple
29406 * // values to the same list:
29407 * mixpanel.people.union({
29408 * list1: ['bob', 'billy']
29409 * });
29410 *
29411 * @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.
29412 * @param {*} [value] Value / values to merge with the given property
29413 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29414 */
29415 MixpanelPeople.prototype.union = addOptOutCheckMixpanelPeople(function(list_name, values, callback) {
29416 if (_.isObject(list_name)) {
29417 callback = values;
29418 }
29419 var data = this.union_action(list_name, values);
29420 return this._send_request(data, callback);
29421 });
29422
29423 /*
29424 * Record that you have charged the current user a certain amount
29425 * of money. Charges recorded with track_charge() will appear in the
29426 * Mixpanel revenue report.
29427 *
29428 * ### Usage:
29429 *
29430 * // charge a user $50
29431 * mixpanel.people.track_charge(50);
29432 *
29433 * // charge a user $30.50 on the 2nd of january
29434 * mixpanel.people.track_charge(30.50, {
29435 * '$time': new Date('jan 1 2012')
29436 * });
29437 *
29438 * @param {Number} amount The amount of money charged to the current user
29439 * @param {Object} [properties] An associative array of properties associated with the charge
29440 * @param {Function} [callback] If provided, the callback will be called when the server responds
29441 * @deprecated
29442 */
29443 MixpanelPeople.prototype.track_charge = addOptOutCheckMixpanelPeople(function() {
29444 console$1.error('mixpanel.people.track_charge() is deprecated and no longer has any effect.');
29445 });
29446
29447 /*
29448 * Permanently clear all revenue report transactions from the
29449 * current user's people analytics profile.
29450 *
29451 * ### Usage:
29452 *
29453 * mixpanel.people.clear_charges();
29454 *
29455 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29456 * @deprecated
29457 */
29458 MixpanelPeople.prototype.clear_charges = function(callback) {
29459 return this.set('$transactions', [], callback);
29460 };
29461
29462 /*
29463 * Permanently deletes the current people analytics profile from
29464 * Mixpanel (using the current distinct_id).
29465 *
29466 * ### Usage:
29467 *
29468 * // remove the all data you have stored about the current user
29469 * mixpanel.people.delete_user();
29470 *
29471 */
29472 MixpanelPeople.prototype.delete_user = function() {
29473 if (!this._identify_called()) {
29474 console$1.error('mixpanel.people.delete_user() requires you to call identify() first');
29475 return;
29476 }
29477 var data = {'$delete': this._mixpanel.get_distinct_id()};
29478 return this._send_request(data);
29479 };
29480
29481 MixpanelPeople.prototype.toString = function() {
29482 return this._mixpanel.toString() + '.people';
29483 };
29484
29485 MixpanelPeople.prototype._send_request = function(data, callback) {
29486 data['$token'] = this._get_config('token');
29487 data['$distinct_id'] = this._mixpanel.get_distinct_id();
29488 var device_id = this._mixpanel.get_property('$device_id');
29489 var user_id = this._mixpanel.get_property('$user_id');
29490 var had_persisted_distinct_id = this._mixpanel.get_property('$had_persisted_distinct_id');
29491 if (device_id) {
29492 data['$device_id'] = device_id;
29493 }
29494 if (user_id) {
29495 data['$user_id'] = user_id;
29496 }
29497 if (had_persisted_distinct_id) {
29498 data['$had_persisted_distinct_id'] = had_persisted_distinct_id;
29499 }
29500
29501 var date_encoded_data = _.encodeDates(data);
29502
29503 if (!this._identify_called()) {
29504 this._enqueue(data);
29505 if (!_.isUndefined(callback)) {
29506 if (this._get_config('verbose')) {
29507 callback({status: -1, error: null});
29508 } else {
29509 callback(-1);
29510 }
29511 }
29512 return _.truncate(date_encoded_data, 255);
29513 }
29514
29515 return this._mixpanel._track_or_batch({
29516 type: 'people',
29517 data: date_encoded_data,
29518 endpoint: this._mixpanel.get_api_host('people') + '/' + this._get_config('api_routes')['engage'],
29519 batcher: this._mixpanel.request_batchers.people
29520 }, callback);
29521 };
29522
29523 MixpanelPeople.prototype._get_config = function(conf_var) {
29524 return this._mixpanel.get_config(conf_var);
29525 };
29526
29527 MixpanelPeople.prototype._identify_called = function() {
29528 return this._mixpanel._flags.identify_called === true;
29529 };
29530
29531 // Queue up engage operations if identify hasn't been called yet.
29532 MixpanelPeople.prototype._enqueue = function(data) {
29533 if (SET_ACTION in data) {
29534 this._mixpanel['persistence']._add_to_people_queue(SET_ACTION, data);
29535 } else if (SET_ONCE_ACTION in data) {
29536 this._mixpanel['persistence']._add_to_people_queue(SET_ONCE_ACTION, data);
29537 } else if (UNSET_ACTION in data) {
29538 this._mixpanel['persistence']._add_to_people_queue(UNSET_ACTION, data);
29539 } else if (ADD_ACTION in data) {
29540 this._mixpanel['persistence']._add_to_people_queue(ADD_ACTION, data);
29541 } else if (APPEND_ACTION in data) {
29542 this._mixpanel['persistence']._add_to_people_queue(APPEND_ACTION, data);
29543 } else if (REMOVE_ACTION in data) {
29544 this._mixpanel['persistence']._add_to_people_queue(REMOVE_ACTION, data);
29545 } else if (UNION_ACTION in data) {
29546 this._mixpanel['persistence']._add_to_people_queue(UNION_ACTION, data);
29547 } else {
29548 console$1.error('Invalid call to _enqueue():', data);
29549 }
29550 };
29551
29552 MixpanelPeople.prototype._flush_one_queue = function(action, action_method, callback, queue_to_params_fn) {
29553 var _this = this;
29554 var queued_data = _.extend({}, this._mixpanel['persistence'].load_queue(action));
29555 var action_params = queued_data;
29556
29557 if (!_.isUndefined(queued_data) && _.isObject(queued_data) && !_.isEmptyObject(queued_data)) {
29558 _this._mixpanel['persistence']._pop_from_people_queue(action, queued_data);
29559 _this._mixpanel['persistence'].save();
29560 if (queue_to_params_fn) {
29561 action_params = queue_to_params_fn(queued_data);
29562 }
29563 action_method.call(_this, action_params, function(response, data) {
29564 // on bad response, we want to add it back to the queue
29565 if (response === 0) {
29566 _this._mixpanel['persistence']._add_to_people_queue(action, queued_data);
29567 }
29568 if (!_.isUndefined(callback)) {
29569 callback(response, data);
29570 }
29571 });
29572 }
29573 };
29574
29575 // Flush queued engage operations - order does not matter,
29576 // and there are network level race conditions anyway
29577 MixpanelPeople.prototype._flush = function(
29578 _set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback
29579 ) {
29580 var _this = this;
29581
29582 this._flush_one_queue(SET_ACTION, this.set, _set_callback);
29583 this._flush_one_queue(SET_ONCE_ACTION, this.set_once, _set_once_callback);
29584 this._flush_one_queue(UNSET_ACTION, this.unset, _unset_callback, function(queue) { return _.keys(queue); });
29585 this._flush_one_queue(ADD_ACTION, this.increment, _add_callback);
29586 this._flush_one_queue(UNION_ACTION, this.union, _union_callback);
29587
29588 // we have to fire off each $append individually since there is
29589 // no concat method server side
29590 var $append_queue = this._mixpanel['persistence'].load_queue(APPEND_ACTION);
29591 if (!_.isUndefined($append_queue) && _.isArray($append_queue) && $append_queue.length) {
29592 var $append_item;
29593 var append_callback = function(response, data) {
29594 if (response === 0) {
29595 _this._mixpanel['persistence']._add_to_people_queue(APPEND_ACTION, $append_item);
29596 }
29597 if (!_.isUndefined(_append_callback)) {
29598 _append_callback(response, data);
29599 }
29600 };
29601 for (var i = $append_queue.length - 1; i >= 0; i--) {
29602 $append_queue = this._mixpanel['persistence'].load_queue(APPEND_ACTION);
29603 $append_item = $append_queue.pop();
29604 _this._mixpanel['persistence'].save();
29605 if (!_.isEmptyObject($append_item)) {
29606 _this.append($append_item, append_callback);
29607 }
29608 }
29609 }
29610
29611 // same for $remove
29612 var $remove_queue = this._mixpanel['persistence'].load_queue(REMOVE_ACTION);
29613 if (!_.isUndefined($remove_queue) && _.isArray($remove_queue) && $remove_queue.length) {
29614 var $remove_item;
29615 var remove_callback = function(response, data) {
29616 if (response === 0) {
29617 _this._mixpanel['persistence']._add_to_people_queue(REMOVE_ACTION, $remove_item);
29618 }
29619 if (!_.isUndefined(_remove_callback)) {
29620 _remove_callback(response, data);
29621 }
29622 };
29623 for (var j = $remove_queue.length - 1; j >= 0; j--) {
29624 $remove_queue = this._mixpanel['persistence'].load_queue(REMOVE_ACTION);
29625 $remove_item = $remove_queue.pop();
29626 _this._mixpanel['persistence'].save();
29627 if (!_.isEmptyObject($remove_item)) {
29628 _this.remove($remove_item, remove_callback);
29629 }
29630 }
29631 }
29632 };
29633
29634 MixpanelPeople.prototype._is_reserved_property = function(prop) {
29635 return prop === '$distinct_id' || prop === '$token' || prop === '$device_id' || prop === '$user_id' || prop === '$had_persisted_distinct_id';
29636 };
29637
29638 // MixpanelPeople Exports
29639 MixpanelPeople.prototype['set'] = MixpanelPeople.prototype.set;
29640 MixpanelPeople.prototype['set_once'] = MixpanelPeople.prototype.set_once;
29641 MixpanelPeople.prototype['unset'] = MixpanelPeople.prototype.unset;
29642 MixpanelPeople.prototype['increment'] = MixpanelPeople.prototype.increment;
29643 MixpanelPeople.prototype['append'] = MixpanelPeople.prototype.append;
29644 MixpanelPeople.prototype['remove'] = MixpanelPeople.prototype.remove;
29645 MixpanelPeople.prototype['union'] = MixpanelPeople.prototype.union;
29646 MixpanelPeople.prototype['track_charge'] = MixpanelPeople.prototype.track_charge;
29647 MixpanelPeople.prototype['clear_charges'] = MixpanelPeople.prototype.clear_charges;
29648 MixpanelPeople.prototype['delete_user'] = MixpanelPeople.prototype.delete_user;
29649 MixpanelPeople.prototype['toString'] = MixpanelPeople.prototype.toString;
29650
29651 /* eslint camelcase: "off" */
29652
29653
29654 /*
29655 * Constants
29656 */
29657 /** @const */ var SET_QUEUE_KEY = '__mps';
29658 /** @const */ var SET_ONCE_QUEUE_KEY = '__mpso';
29659 /** @const */ var UNSET_QUEUE_KEY = '__mpus';
29660 /** @const */ var ADD_QUEUE_KEY = '__mpa';
29661 /** @const */ var APPEND_QUEUE_KEY = '__mpap';
29662 /** @const */ var REMOVE_QUEUE_KEY = '__mpr';
29663 /** @const */ var UNION_QUEUE_KEY = '__mpu';
29664 // This key is deprecated, but we want to check for it to see whether aliasing is allowed.
29665 /** @const */ var PEOPLE_DISTINCT_ID_KEY = '$people_distinct_id';
29666 /** @const */ var ALIAS_ID_KEY = '__alias';
29667 /** @const */ var EVENT_TIMERS_KEY = '__timers';
29668 /** @const */ var RESERVED_PROPERTIES = [
29669 SET_QUEUE_KEY,
29670 SET_ONCE_QUEUE_KEY,
29671 UNSET_QUEUE_KEY,
29672 ADD_QUEUE_KEY,
29673 APPEND_QUEUE_KEY,
29674 REMOVE_QUEUE_KEY,
29675 UNION_QUEUE_KEY,
29676 PEOPLE_DISTINCT_ID_KEY,
29677 ALIAS_ID_KEY,
29678 EVENT_TIMERS_KEY
29679 ];
29680
29681 /**
29682 * Mixpanel Persistence Object
29683 * @constructor
29684 */
29685 var MixpanelPersistence = function(config) {
29686 this['props'] = {};
29687 this.campaign_params_saved = false;
29688
29689 if (config['persistence_name']) {
29690 this.name = 'mp_' + config['persistence_name'];
29691 } else {
29692 this.name = 'mp_' + config['token'] + '_mixpanel';
29693 }
29694
29695 var storage_type = config['persistence'];
29696 if (storage_type !== 'cookie' && storage_type !== 'localStorage') {
29697 console$1.critical('Unknown persistence type ' + storage_type + '; falling back to cookie');
29698 storage_type = config['persistence'] = 'cookie';
29699 }
29700
29701 if (storage_type === 'localStorage' && _.localStorage.is_supported()) {
29702 this.storage = _.localStorage;
29703 } else {
29704 this.storage = _.cookie;
29705 }
29706
29707 this.load();
29708 this.update_config(config);
29709 this.upgrade();
29710 this.save();
29711 };
29712
29713 MixpanelPersistence.prototype.properties = function() {
29714 var p = {};
29715
29716 this.load();
29717
29718 // Filter out reserved properties
29719 _.each(this['props'], function(v, k) {
29720 if (!_.include(RESERVED_PROPERTIES, k)) {
29721 p[k] = v;
29722 }
29723 });
29724 return p;
29725 };
29726
29727 MixpanelPersistence.prototype.load = function() {
29728 if (this.disabled) { return; }
29729
29730 var entry = this.storage.parse(this.name);
29731
29732 if (entry) {
29733 this['props'] = _.extend({}, entry);
29734 }
29735 };
29736
29737 MixpanelPersistence.prototype.upgrade = function() {
29738 var old_cookie,
29739 old_localstorage;
29740
29741 // if transferring from cookie to localStorage or vice-versa, copy existing
29742 // super properties over to new storage mode
29743 if (this.storage === _.localStorage) {
29744 old_cookie = _.cookie.parse(this.name);
29745
29746 _.cookie.remove(this.name);
29747 _.cookie.remove(this.name, true);
29748
29749 if (old_cookie) {
29750 this.register_once(old_cookie);
29751 }
29752 } else if (this.storage === _.cookie) {
29753 old_localstorage = _.localStorage.parse(this.name);
29754
29755 _.localStorage.remove(this.name);
29756
29757 if (old_localstorage) {
29758 this.register_once(old_localstorage);
29759 }
29760 }
29761 };
29762
29763 MixpanelPersistence.prototype.save = function() {
29764 if (this.disabled) { return; }
29765
29766 this.storage.set(
29767 this.name,
29768 JSONStringify(this['props']),
29769 this.expire_days,
29770 this.cross_subdomain,
29771 this.secure,
29772 this.cross_site,
29773 this.cookie_domain
29774 );
29775 };
29776
29777 MixpanelPersistence.prototype.load_prop = function(key) {
29778 this.load();
29779 return this['props'][key];
29780 };
29781
29782 MixpanelPersistence.prototype.remove = function() {
29783 // remove both domain and subdomain cookies
29784 this.storage.remove(this.name, false, this.cookie_domain);
29785 this.storage.remove(this.name, true, this.cookie_domain);
29786 };
29787
29788 // removes the storage entry and deletes all loaded data
29789 // forced name for tests
29790 MixpanelPersistence.prototype.clear = function() {
29791 this.remove();
29792 this['props'] = {};
29793 };
29794
29795 /**
29796 * @param {Object} props
29797 * @param {*=} default_value
29798 * @param {number=} days
29799 */
29800 MixpanelPersistence.prototype.register_once = function(props, default_value, days) {
29801 if (_.isObject(props)) {
29802 if (typeof(default_value) === 'undefined') { default_value = 'None'; }
29803 this.expire_days = (typeof(days) === 'undefined') ? this.default_expiry : days;
29804
29805 this.load();
29806
29807 _.each(props, function(val, prop) {
29808 if (!this['props'].hasOwnProperty(prop) || this['props'][prop] === default_value) {
29809 this['props'][prop] = val;
29810 }
29811 }, this);
29812
29813 this.save();
29814
29815 return true;
29816 }
29817 return false;
29818 };
29819
29820 /**
29821 * @param {Object} props
29822 * @param {number=} days
29823 */
29824 MixpanelPersistence.prototype.register = function(props, days) {
29825 if (_.isObject(props)) {
29826 this.expire_days = (typeof(days) === 'undefined') ? this.default_expiry : days;
29827
29828 this.load();
29829 _.extend(this['props'], props);
29830 this.save();
29831
29832 return true;
29833 }
29834 return false;
29835 };
29836
29837 MixpanelPersistence.prototype.unregister = function(prop) {
29838 this.load();
29839 if (prop in this['props']) {
29840 delete this['props'][prop];
29841 this.save();
29842 }
29843 };
29844
29845 MixpanelPersistence.prototype.update_search_keyword = function(referrer) {
29846 this.register(_.info.searchInfo(referrer));
29847 };
29848
29849 // EXPORTED METHOD, we test this directly.
29850 MixpanelPersistence.prototype.update_referrer_info = function(referrer) {
29851 // If referrer doesn't exist, we want to note the fact that it was type-in traffic.
29852 this.register_once({
29853 '$initial_referrer': referrer || '$direct',
29854 '$initial_referring_domain': _.info.referringDomain(referrer) || '$direct'
29855 }, '');
29856 };
29857
29858 MixpanelPersistence.prototype.get_referrer_info = function() {
29859 return _.strip_empty_properties({
29860 '$initial_referrer': this['props']['$initial_referrer'],
29861 '$initial_referring_domain': this['props']['$initial_referring_domain']
29862 });
29863 };
29864
29865 MixpanelPersistence.prototype.update_config = function(config) {
29866 this.default_expiry = this.expire_days = config['cookie_expiration'];
29867 this.set_disabled(config['disable_persistence']);
29868 this.set_cookie_domain(config['cookie_domain']);
29869 this.set_cross_site(config['cross_site_cookie']);
29870 this.set_cross_subdomain(config['cross_subdomain_cookie']);
29871 this.set_secure(config['secure_cookie']);
29872 };
29873
29874 MixpanelPersistence.prototype.set_disabled = function(disabled) {
29875 this.disabled = disabled;
29876 if (this.disabled) {
29877 this.remove();
29878 } else {
29879 this.save();
29880 }
29881 };
29882
29883 MixpanelPersistence.prototype.set_cookie_domain = function(cookie_domain) {
29884 if (cookie_domain !== this.cookie_domain) {
29885 this.remove();
29886 this.cookie_domain = cookie_domain;
29887 this.save();
29888 }
29889 };
29890
29891 MixpanelPersistence.prototype.set_cross_site = function(cross_site) {
29892 if (cross_site !== this.cross_site) {
29893 this.cross_site = cross_site;
29894 this.remove();
29895 this.save();
29896 }
29897 };
29898
29899 MixpanelPersistence.prototype.set_cross_subdomain = function(cross_subdomain) {
29900 if (cross_subdomain !== this.cross_subdomain) {
29901 this.cross_subdomain = cross_subdomain;
29902 this.remove();
29903 this.save();
29904 }
29905 };
29906
29907 MixpanelPersistence.prototype.get_cross_subdomain = function() {
29908 return this.cross_subdomain;
29909 };
29910
29911 MixpanelPersistence.prototype.set_secure = function(secure) {
29912 if (secure !== this.secure) {
29913 this.secure = secure ? true : false;
29914 this.remove();
29915 this.save();
29916 }
29917 };
29918
29919 MixpanelPersistence.prototype._add_to_people_queue = function(queue, data) {
29920 var q_key = this._get_queue_key(queue),
29921 q_data = data[queue],
29922 set_q = this._get_or_create_queue(SET_ACTION),
29923 set_once_q = this._get_or_create_queue(SET_ONCE_ACTION),
29924 unset_q = this._get_or_create_queue(UNSET_ACTION),
29925 add_q = this._get_or_create_queue(ADD_ACTION),
29926 union_q = this._get_or_create_queue(UNION_ACTION),
29927 remove_q = this._get_or_create_queue(REMOVE_ACTION, []),
29928 append_q = this._get_or_create_queue(APPEND_ACTION, []);
29929
29930 if (q_key === SET_QUEUE_KEY) {
29931 // Update the set queue - we can override any existing values
29932 _.extend(set_q, q_data);
29933 // if there was a pending increment, override it
29934 // with the set.
29935 this._pop_from_people_queue(ADD_ACTION, q_data);
29936 // if there was a pending union, override it
29937 // with the set.
29938 this._pop_from_people_queue(UNION_ACTION, q_data);
29939 this._pop_from_people_queue(UNSET_ACTION, q_data);
29940 } else if (q_key === SET_ONCE_QUEUE_KEY) {
29941 // only queue the data if there is not already a set_once call for it.
29942 _.each(q_data, function(v, k) {
29943 if (!(k in set_once_q)) {
29944 set_once_q[k] = v;
29945 }
29946 });
29947 this._pop_from_people_queue(UNSET_ACTION, q_data);
29948 } else if (q_key === UNSET_QUEUE_KEY) {
29949 _.each(q_data, function(prop) {
29950
29951 // undo previously-queued actions on this key
29952 _.each([set_q, set_once_q, add_q, union_q], function(enqueued_obj) {
29953 if (prop in enqueued_obj) {
29954 delete enqueued_obj[prop];
29955 }
29956 });
29957 _.each(append_q, function(append_obj) {
29958 if (prop in append_obj) {
29959 delete append_obj[prop];
29960 }
29961 });
29962
29963 unset_q[prop] = true;
29964
29965 });
29966 } else if (q_key === ADD_QUEUE_KEY) {
29967 _.each(q_data, function(v, k) {
29968 // If it exists in the set queue, increment
29969 // the value
29970 if (k in set_q) {
29971 set_q[k] += v;
29972 } else {
29973 // If it doesn't exist, update the add
29974 // queue
29975 if (!(k in add_q)) {
29976 add_q[k] = 0;
29977 }
29978 add_q[k] += v;
29979 }
29980 }, this);
29981 this._pop_from_people_queue(UNSET_ACTION, q_data);
29982 } else if (q_key === UNION_QUEUE_KEY) {
29983 _.each(q_data, function(v, k) {
29984 if (_.isArray(v)) {
29985 if (!(k in union_q)) {
29986 union_q[k] = [];
29987 }
29988 // Prevent duplicate values
29989 _.each(v, function(item) {
29990 if (!_.include(union_q[k], item)) {
29991 union_q[k].push(item);
29992 }
29993 });
29994 }
29995 });
29996 this._pop_from_people_queue(UNSET_ACTION, q_data);
29997 } else if (q_key === REMOVE_QUEUE_KEY) {
29998 remove_q.push(q_data);
29999 this._pop_from_people_queue(APPEND_ACTION, q_data);
30000 } else if (q_key === APPEND_QUEUE_KEY) {
30001 append_q.push(q_data);
30002 this._pop_from_people_queue(UNSET_ACTION, q_data);
30003 }
30004
30005 console$1.log('MIXPANEL PEOPLE REQUEST (QUEUED, PENDING IDENTIFY):');
30006 console$1.log(data);
30007
30008 this.save();
30009 };
30010
30011 MixpanelPersistence.prototype._pop_from_people_queue = function(queue, data) {
30012 var q = this['props'][this._get_queue_key(queue)];
30013 if (!_.isUndefined(q)) {
30014 _.each(data, function(v, k) {
30015 if (queue === APPEND_ACTION || queue === REMOVE_ACTION) {
30016 // list actions: only remove if both k+v match
30017 // e.g. remove should not override append in a case like
30018 // append({foo: 'bar'}); remove({foo: 'qux'})
30019 _.each(q, function(queued_action) {
30020 if (queued_action[k] === v) {
30021 delete queued_action[k];
30022 }
30023 });
30024 } else {
30025 delete q[k];
30026 }
30027 }, this);
30028 }
30029 };
30030
30031 MixpanelPersistence.prototype.load_queue = function(queue) {
30032 return this.load_prop(this._get_queue_key(queue));
30033 };
30034
30035 MixpanelPersistence.prototype._get_queue_key = function(queue) {
30036 if (queue === SET_ACTION) {
30037 return SET_QUEUE_KEY;
30038 } else if (queue === SET_ONCE_ACTION) {
30039 return SET_ONCE_QUEUE_KEY;
30040 } else if (queue === UNSET_ACTION) {
30041 return UNSET_QUEUE_KEY;
30042 } else if (queue === ADD_ACTION) {
30043 return ADD_QUEUE_KEY;
30044 } else if (queue === APPEND_ACTION) {
30045 return APPEND_QUEUE_KEY;
30046 } else if (queue === REMOVE_ACTION) {
30047 return REMOVE_QUEUE_KEY;
30048 } else if (queue === UNION_ACTION) {
30049 return UNION_QUEUE_KEY;
30050 } else {
30051 console$1.error('Invalid queue:', queue);
30052 }
30053 };
30054
30055 MixpanelPersistence.prototype._get_or_create_queue = function(queue, default_val) {
30056 var key = this._get_queue_key(queue);
30057 default_val = _.isUndefined(default_val) ? {} : default_val;
30058 return this['props'][key] || (this['props'][key] = default_val);
30059 };
30060
30061 MixpanelPersistence.prototype.set_event_timer = function(event_name, timestamp) {
30062 var timers = this.load_prop(EVENT_TIMERS_KEY) || {};
30063 timers[event_name] = timestamp;
30064 this['props'][EVENT_TIMERS_KEY] = timers;
30065 this.save();
30066 };
30067
30068 MixpanelPersistence.prototype.remove_event_timer = function(event_name) {
30069 var timers = this.load_prop(EVENT_TIMERS_KEY) || {};
30070 var timestamp = timers[event_name];
30071 if (!_.isUndefined(timestamp)) {
30072 delete this['props'][EVENT_TIMERS_KEY][event_name];
30073 this.save();
30074 }
30075 return timestamp;
30076 };
30077
30078 /* eslint camelcase: "off" */
30079
30080 /*
30081 * Mixpanel JS Library
30082 *
30083 * Copyright 2012, Mixpanel, Inc. All Rights Reserved
30084 * http://mixpanel.com/
30085 *
30086 * Includes portions of Underscore.js
30087 * http://documentcloud.github.com/underscore/
30088 * (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.
30089 * Released under the MIT License.
30090 */
30091
30092 /*
30093 SIMPLE STYLE GUIDE:
30094
30095 this.x === public function
30096 this._x === internal - only use within this file
30097 this.__x === private - only use within the class
30098
30099 Globals should be all caps
30100 */
30101
30102 var init_type; // MODULE or SNIPPET loader
30103 // allow bundlers to specify how extra code (recorder bundle) should be loaded
30104 // eslint-disable-next-line no-unused-vars
30105 var load_extra_bundle = function(src, _onload) {
30106 throw new Error(src + ' not available in this build.');
30107 };
30108
30109 var mixpanel_master; // main mixpanel instance / object
30110 var INIT_MODULE = 0;
30111 var INIT_SNIPPET = 1;
30112
30113 var IDENTITY_FUNC = function(x) {return x;};
30114
30115 /** @const */ var PRIMARY_INSTANCE_NAME = 'mixpanel';
30116 /** @const */ var PAYLOAD_TYPE_BASE64 = 'base64';
30117 /** @const */ var PAYLOAD_TYPE_JSON = 'json';
30118 /** @const */ var DEVICE_ID_PREFIX = '$device:';
30119
30120
30121 /*
30122 * Dynamic... constants? Is that an oxymoron?
30123 */
30124 // http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/
30125 // https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#withCredentials
30126 var USE_XHR = (win.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest());
30127
30128 // IE<10 does not support cross-origin XHR's but script tags
30129 // with defer won't block window.onload; ENQUEUE_REQUESTS
30130 // should only be true for Opera<12
30131 var ENQUEUE_REQUESTS = !USE_XHR && (userAgent.indexOf('MSIE') === -1) && (userAgent.indexOf('Mozilla') === -1);
30132
30133 // save reference to navigator.sendBeacon so it can be minified
30134 var sendBeacon = null;
30135 if (navigator['sendBeacon']) {
30136 sendBeacon = function() {
30137 // late reference to navigator.sendBeacon to allow patching/spying
30138 return navigator['sendBeacon'].apply(navigator, arguments);
30139 };
30140 }
30141
30142 var DEFAULT_API_ROUTES = {
30143 'track': 'track/',
30144 'engage': 'engage/',
30145 'groups': 'groups/',
30146 'record': 'record/',
30147 'flags': 'flags/'
30148 };
30149
30150 /*
30151 * Module-level globals
30152 */
30153 var DEFAULT_CONFIG = {
30154 'api_host': 'https://api-js.mixpanel.com',
30155 'api_hosts': {},
30156 'api_routes': DEFAULT_API_ROUTES,
30157 'api_extra_query_params': {},
30158 'api_method': 'POST',
30159 'api_transport': 'XHR',
30160 'api_payload_format': PAYLOAD_TYPE_BASE64,
30161 'app_host': 'https://mixpanel.com',
30162 'autocapture': false,
30163 'cdn': 'https://cdn.mxpnl.com',
30164 'cross_site_cookie': false,
30165 'cross_subdomain_cookie': true,
30166 'error_reporter': NOOP_FUNC,
30167 'flags': false,
30168 'persistence': 'cookie',
30169 'persistence_name': '',
30170 'cookie_domain': '',
30171 'cookie_name': '',
30172 'loaded': NOOP_FUNC,
30173 'mp_loader': null,
30174 'track_marketing': true,
30175 'track_pageview': false,
30176 'skip_first_touch_marketing': false,
30177 'store_google': true,
30178 'stop_utm_persistence': false,
30179 'save_referrer': true,
30180 'test': false,
30181 'verbose': false,
30182 'img': false,
30183 'debug': false,
30184 'track_links_timeout': 300,
30185 'cookie_expiration': 365,
30186 'upgrade': false,
30187 'disable_persistence': false,
30188 'disable_cookie': false,
30189 'secure_cookie': false,
30190 'ip': true,
30191 'opt_out_tracking_by_default': false,
30192 'opt_out_persistence_by_default': false,
30193 'opt_out_tracking_persistence_type': 'localStorage',
30194 'opt_out_tracking_cookie_prefix': null,
30195 'property_blacklist': [],
30196 'xhr_headers': {}, // { header: value, header2: value }
30197 'ignore_dnt': false,
30198 'batch_requests': true,
30199 'batch_size': 50,
30200 'batch_flush_interval_ms': 5000,
30201 'batch_request_timeout_ms': 90000,
30202 'batch_autostart': true,
30203 'hooks': {},
30204 'record_block_class': new RegExp('^(mp-block|fs-exclude|amp-block|rr-block|ph-no-capture)$'),
30205 'record_block_selector': 'img, video, audio',
30206 'record_canvas': false,
30207 'record_collect_fonts': false,
30208 'record_heatmap_data': false,
30209 'record_idle_timeout_ms': 30 * 60 * 1000, // 30 minutes
30210 'record_mask_text_class': new RegExp('^(mp-mask|fs-mask|amp-mask|rr-mask|ph-mask)$'),
30211 'record_mask_text_selector': '*',
30212 'record_max_ms': MAX_RECORDING_MS,
30213 'record_min_ms': 0,
30214 'record_sessions_percent': 0,
30215 'recorder_src': 'https://cdn.mxpnl.com/libs/mixpanel-recorder.min.js'
30216 };
30217
30218 var DOM_LOADED = false;
30219
30220 /**
30221 * Mixpanel Library Object
30222 * @constructor
30223 */
30224 var MixpanelLib = function() {};
30225
30226
30227 /**
30228 * create_mplib(token:string, config:object, name:string)
30229 *
30230 * This function is used by the init method of MixpanelLib objects
30231 * as well as the main initializer at the end of the JSLib (that
30232 * initializes document.mixpanel as well as any additional instances
30233 * declared before this file has loaded).
30234 */
30235 var create_mplib = function(token, config, name) {
30236 var instance,
30237 target = (name === PRIMARY_INSTANCE_NAME) ? mixpanel_master : mixpanel_master[name];
30238
30239 if (target && init_type === INIT_MODULE) {
30240 instance = target;
30241 } else {
30242 if (target && !_.isArray(target)) {
30243 console$1.error('You have already initialized ' + name);
30244 return;
30245 }
30246 instance = new MixpanelLib();
30247 }
30248
30249 instance._cached_groups = {}; // cache groups in a pool
30250
30251 instance._init(token, config, name);
30252
30253 instance['people'] = new MixpanelPeople();
30254 instance['people']._init(instance);
30255
30256 if (!instance.get_config('skip_first_touch_marketing')) {
30257 // We need null UTM params in the object because
30258 // UTM parameters act as a tuple. If any UTM param
30259 // is present, then we set all UTM params including
30260 // empty ones together
30261 var utm_params = _.info.campaignParams(null);
30262 var initial_utm_params = {};
30263 var has_utm = false;
30264 _.each(utm_params, function(utm_value, utm_key) {
30265 initial_utm_params['initial_' + utm_key] = utm_value;
30266 if (utm_value) {
30267 has_utm = true;
30268 }
30269 });
30270 if (has_utm) {
30271 instance['people'].set_once(initial_utm_params);
30272 }
30273 }
30274
30275 // if any instance on the page has debug = true, we set the
30276 // global debug to be true
30277 Config.DEBUG = Config.DEBUG || instance.get_config('debug');
30278
30279 // if target is not defined, we called init after the lib already
30280 // loaded, so there won't be an array of things to execute
30281 if (!_.isUndefined(target) && _.isArray(target)) {
30282 // Crunch through the people queue first - we queue this data up &
30283 // flush on identify, so it's better to do all these operations first
30284 instance._execute_array.call(instance['people'], target['people']);
30285 instance._execute_array(target);
30286 }
30287
30288 return instance;
30289 };
30290
30291 // Initialization methods
30292
30293 /**
30294 * This function initializes a new instance of the Mixpanel tracking object.
30295 * All new instances are added to the main mixpanel object as sub properties (such as
30296 * mixpanel.library_name) and also returned by this function. To define a
30297 * second instance on the page, you would call:
30298 *
30299 * mixpanel.init('new token', { your: 'config' }, 'library_name');
30300 *
30301 * and use it like so:
30302 *
30303 * mixpanel.library_name.track(...);
30304 *
30305 * @param {String} token Your Mixpanel API token
30306 * @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>.
30307 * @param {String} [name] The name for the new mixpanel instance that you want created
30308 */
30309 MixpanelLib.prototype.init = function (token, config, name) {
30310 if (_.isUndefined(name)) {
30311 this.report_error('You must name your new library: init(token, config, name)');
30312 return;
30313 }
30314 if (name === PRIMARY_INSTANCE_NAME) {
30315 this.report_error('You must initialize the main mixpanel object right after you include the Mixpanel js snippet');
30316 return;
30317 }
30318
30319 var instance = create_mplib(token, config, name);
30320 mixpanel_master[name] = instance;
30321 instance._loaded();
30322
30323 return instance;
30324 };
30325
30326 // mixpanel._init(token:string, config:object, name:string)
30327 //
30328 // This function sets up the current instance of the mixpanel
30329 // library. The difference between this method and the init(...)
30330 // method is this one initializes the actual instance, whereas the
30331 // init(...) method sets up a new library and calls _init on it.
30332 //
30333 MixpanelLib.prototype._init = function(token, config, name) {
30334 config = config || {};
30335
30336 this['__loaded'] = true;
30337 this['config'] = {};
30338
30339 var variable_features = {};
30340
30341 // default to JSON payload for standard mixpanel.com API hosts
30342 if (!('api_payload_format' in config)) {
30343 var api_host = config['api_host'] || DEFAULT_CONFIG['api_host'];
30344 if (api_host.match(/\.mixpanel\.com/)) {
30345 variable_features['api_payload_format'] = PAYLOAD_TYPE_JSON;
30346 }
30347 }
30348
30349 this.set_config(_.extend({}, DEFAULT_CONFIG, variable_features, config, {
30350 'name': name,
30351 'token': token,
30352 'callback_fn': ((name === PRIMARY_INSTANCE_NAME) ? name : PRIMARY_INSTANCE_NAME + '.' + name) + '._jsc'
30353 }));
30354
30355 this['_jsc'] = NOOP_FUNC;
30356
30357 this.__dom_loaded_queue = [];
30358 this.__request_queue = [];
30359 this.__disabled_events = [];
30360 this._flags = {
30361 'disable_all_events': false,
30362 'identify_called': false
30363 };
30364
30365 // set up request queueing/batching
30366 this.request_batchers = {};
30367 this._batch_requests = this.get_config('batch_requests');
30368 if (this._batch_requests) {
30369 if (!_.localStorage.is_supported(true) || !USE_XHR) {
30370 this._batch_requests = false;
30371 console$1.log('Turning off Mixpanel request-queueing; needs XHR and localStorage support');
30372 _.each(this.get_batcher_configs(), function(batcher_config) {
30373 console$1.log('Clearing batch queue ' + batcher_config.queue_key);
30374 _.localStorage.remove(batcher_config.queue_key);
30375 });
30376 } else {
30377 this.init_batchers();
30378 if (sendBeacon && win.addEventListener) {
30379 // Before page closes or hides (user tabs away etc), attempt to flush any events
30380 // queued up via navigator.sendBeacon. Since sendBeacon doesn't report success/failure,
30381 // events will not be removed from the persistent store; if the site is loaded again,
30382 // the events will be flushed again on startup and deduplicated on the Mixpanel server
30383 // side.
30384 // There is no reliable way to capture only page close events, so we lean on the
30385 // visibilitychange and pagehide events as recommended at
30386 // https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event#usage_notes.
30387 // These events fire when the user clicks away from the current page/tab, so will occur
30388 // more frequently than page unload, but are the only mechanism currently for capturing
30389 // this scenario somewhat reliably.
30390 var flush_on_unload = _.bind(function() {
30391 if (!this.request_batchers.events.stopped) {
30392 this.request_batchers.events.flush({unloading: true});
30393 }
30394 }, this);
30395 win.addEventListener('pagehide', function(ev) {
30396 if (ev['persisted']) {
30397 flush_on_unload();
30398 }
30399 });
30400 win.addEventListener('visibilitychange', function() {
30401 if (document$1['visibilityState'] === 'hidden') {
30402 flush_on_unload();
30403 }
30404 });
30405 }
30406 }
30407 }
30408
30409 this['persistence'] = this['cookie'] = new MixpanelPersistence(this['config']);
30410 this.unpersisted_superprops = {};
30411 this._gdpr_init();
30412
30413 var uuid = _.UUID();
30414 if (!this.get_distinct_id()) {
30415 // There is no need to set the distinct id
30416 // or the device id if something was already stored
30417 // in the persitence
30418 this.register_once({
30419 'distinct_id': DEVICE_ID_PREFIX + uuid,
30420 '$device_id': uuid
30421 }, '');
30422 }
30423
30424 this.flags = new FeatureFlagManager({
30425 getFullApiRoute: _.bind(function() {
30426 return this.get_api_host('flags') + '/' + this.get_config('api_routes')['flags'];
30427 }, this),
30428 getConfigFunc: _.bind(this.get_config, this),
30429 setConfigFunc: _.bind(this.set_config, this),
30430 getPropertyFunc: _.bind(this.get_property, this),
30431 trackingFunc: _.bind(this.track, this)
30432 });
30433 this.flags.init();
30434 this['flags'] = this.flags;
30435
30436 this.autocapture = new Autocapture(this);
30437 this.autocapture.init();
30438
30439 this._init_tab_id();
30440 this._check_and_start_session_recording();
30441 };
30442
30443 /**
30444 * Assigns a unique UUID to this tab / window by leveraging sessionStorage.
30445 * This is primarily used for session recording, where data must be isolated to the current tab.
30446 */
30447 MixpanelLib.prototype._init_tab_id = function() {
30448 if (this.get_config('disable_persistence')) {
30449 console$1.log('Tab ID initialization skipped due to disable_persistence config');
30450 } else if (_.sessionStorage.is_supported()) {
30451 try {
30452 var key_suffix = this.get_config('name') + '_' + this.get_config('token');
30453 var tab_id_key = 'mp_tab_id_' + key_suffix;
30454
30455 // A flag is used to determine if sessionStorage is copied over and we need to generate a new tab ID.
30456 // This enforces a unique ID in the cases like duplicated tab, window.open(...)
30457 var should_generate_new_tab_id_key = 'mp_gen_new_tab_id_' + key_suffix;
30458 if (_.sessionStorage.get(should_generate_new_tab_id_key) || !_.sessionStorage.get(tab_id_key)) {
30459 _.sessionStorage.set(tab_id_key, '$tab-' + _.UUID());
30460 }
30461
30462 _.sessionStorage.set(should_generate_new_tab_id_key, '1');
30463 this.tab_id = _.sessionStorage.get(tab_id_key);
30464
30465 // 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,
30466 // but reliable in cases where the user remains in the tab e.g. a refresh or href navigation.
30467 // If the flag is absent, this indicates to the next SDK instance that we can reuse the stored tab_id.
30468 win.addEventListener('beforeunload', function () {
30469 _.sessionStorage.remove(should_generate_new_tab_id_key);
30470 });
30471 } catch(err) {
30472 this.report_error('Error initializing tab id', err);
30473 }
30474 } else {
30475 this.report_error('Session storage is not supported, cannot keep track of unique tab ID.');
30476 }
30477 };
30478
30479 MixpanelLib.prototype.get_tab_id = function () {
30480 return this.tab_id || null;
30481 };
30482
30483 MixpanelLib.prototype._should_load_recorder = function () {
30484 if (this.get_config('disable_persistence')) {
30485 console$1.log('Load recorder check skipped due to disable_persistence config');
30486 return Promise.resolve(false);
30487 }
30488
30489 var recording_registry_idb = new IDBStorageWrapper(RECORDING_REGISTRY_STORE_NAME);
30490 var tab_id = this.get_tab_id();
30491 return recording_registry_idb.init()
30492 .then(function () {
30493 return recording_registry_idb.getAll();
30494 })
30495 .then(function (recordings) {
30496 for (var i = 0; i < recordings.length; i++) {
30497 // if there are expired recordings in the registry, we should load the recorder to flush them
30498 // if there's a recording for this tab id, we should load the recorder to continue the recording
30499 if (isRecordingExpired(recordings[i]) || recordings[i]['tabId'] === tab_id) {
30500 return true;
30501 }
30502 }
30503 return false;
30504 })
30505 .catch(_.bind(function (err) {
30506 this.report_error('Error checking recording registry', err);
30507 }, this));
30508 };
30509
30510 MixpanelLib.prototype._check_and_start_session_recording = addOptOutCheckMixpanelLib(function(force_start) {
30511 if (!win['MutationObserver']) {
30512 console$1.critical('Browser does not support MutationObserver; skipping session recording');
30513 return;
30514 }
30515
30516 var loadRecorder = _.bind(function(startNewIfInactive) {
30517 var handleLoadedRecorder = _.bind(function() {
30518 this._recorder = this._recorder || new win['__mp_recorder'](this);
30519 this._recorder['resumeRecording'](startNewIfInactive);
30520 }, this);
30521
30522 if (_.isUndefined(win['__mp_recorder'])) {
30523 load_extra_bundle(this.get_config('recorder_src'), handleLoadedRecorder);
30524 } else {
30525 handleLoadedRecorder();
30526 }
30527 }, this);
30528
30529 /**
30530 * If the user is sampled or start_session_recording is called, we always load the recorder since it's guaranteed a recording should start.
30531 * 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.
30532 */
30533 var is_sampled = this.get_config('record_sessions_percent') > 0 && Math.random() * 100 <= this.get_config('record_sessions_percent');
30534 if (force_start || is_sampled) {
30535 loadRecorder(true);
30536 } else {
30537 this._should_load_recorder()
30538 .then(function (shouldLoad) {
30539 if (shouldLoad) {
30540 loadRecorder(false);
30541 }
30542 });
30543 }
30544 });
30545
30546 MixpanelLib.prototype.start_session_recording = function () {
30547 this._check_and_start_session_recording(true);
30548 };
30549
30550 MixpanelLib.prototype.stop_session_recording = function () {
30551 if (this._recorder) {
30552 return this._recorder['stopRecording']();
30553 }
30554 return Promise.resolve();
30555 };
30556
30557 MixpanelLib.prototype.pause_session_recording = function () {
30558 if (this._recorder) {
30559 return this._recorder['pauseRecording']();
30560 }
30561 return Promise.resolve();
30562 };
30563
30564 MixpanelLib.prototype.resume_session_recording = function () {
30565 if (this._recorder) {
30566 return this._recorder['resumeRecording']();
30567 }
30568 return Promise.resolve();
30569 };
30570
30571 MixpanelLib.prototype.is_recording_heatmap_data = function () {
30572 return this._get_session_replay_id() && this.get_config('record_heatmap_data');
30573 };
30574
30575 MixpanelLib.prototype.get_session_recording_properties = function () {
30576 var props = {};
30577 var replay_id = this._get_session_replay_id();
30578 if (replay_id) {
30579 props['$mp_replay_id'] = replay_id;
30580 }
30581 return props;
30582 };
30583
30584 MixpanelLib.prototype.get_session_replay_url = function () {
30585 var replay_url = null;
30586 var replay_id = this._get_session_replay_id();
30587 if (replay_id) {
30588 var query_params = _.HTTPBuildQuery({
30589 'replay_id': replay_id,
30590 'distinct_id': this.get_distinct_id(),
30591 'token': this.get_config('token')
30592 });
30593 replay_url = 'https://mixpanel.com/projects/replay-redirect?' + query_params;
30594 }
30595 return replay_url;
30596 };
30597
30598 MixpanelLib.prototype._get_session_replay_id = function () {
30599 var replay_id = null;
30600 if (this._recorder) {
30601 replay_id = this._recorder['replayId'];
30602 }
30603 return replay_id || null;
30604 };
30605
30606 // "private" public method to reach into the recorder in test cases
30607 MixpanelLib.prototype.__get_recorder = function () {
30608 return this._recorder;
30609 };
30610
30611 // Private methods
30612
30613 MixpanelLib.prototype._loaded = function() {
30614 this.get_config('loaded')(this);
30615 this._set_default_superprops();
30616 this['people'].set_once(this['persistence'].get_referrer_info());
30617
30618 // `store_google` is now deprecated and previously stored UTM parameters are cleared
30619 // from persistence by default.
30620 if (this.get_config('store_google') && this.get_config('stop_utm_persistence')) {
30621 var utm_params = _.info.campaignParams(null);
30622 _.each(utm_params, function(_utm_value, utm_key) {
30623 // We need to unregister persisted UTM parameters so old values
30624 // are not mixed with the new UTM parameters
30625 this.unregister(utm_key);
30626 }.bind(this));
30627 }
30628 };
30629
30630 // update persistence with info on referrer, UTM params, etc
30631 MixpanelLib.prototype._set_default_superprops = function() {
30632 this['persistence'].update_search_keyword(document$1.referrer);
30633 // Registering super properties for UTM persistence by 'store_google' is deprecated.
30634 if (this.get_config('store_google') && !this.get_config('stop_utm_persistence')) {
30635 this.register(_.info.campaignParams());
30636 }
30637 if (this.get_config('save_referrer')) {
30638 this['persistence'].update_referrer_info(document$1.referrer);
30639 }
30640 };
30641
30642 MixpanelLib.prototype._dom_loaded = function() {
30643 _.each(this.__dom_loaded_queue, function(item) {
30644 this._track_dom.apply(this, item);
30645 }, this);
30646
30647 if (!this.has_opted_out_tracking()) {
30648 _.each(this.__request_queue, function(item) {
30649 this._send_request.apply(this, item);
30650 }, this);
30651 }
30652
30653 delete this.__dom_loaded_queue;
30654 delete this.__request_queue;
30655 };
30656
30657 MixpanelLib.prototype._track_dom = function(DomClass, args) {
30658 if (this.get_config('img')) {
30659 this.report_error('You can\'t use DOM tracking functions with img = true.');
30660 return false;
30661 }
30662
30663 if (!DOM_LOADED) {
30664 this.__dom_loaded_queue.push([DomClass, args]);
30665 return false;
30666 }
30667
30668 var dt = new DomClass().init(this);
30669 return dt.track.apply(dt, args);
30670 };
30671
30672 /**
30673 * _prepare_callback() should be called by callers of _send_request for use
30674 * as the callback argument.
30675 *
30676 * If there is no callback, this returns null.
30677 * If we are going to make XHR/XDR requests, this returns a function.
30678 * If we are going to use script tags, this returns a string to use as the
30679 * callback GET param.
30680 */
30681 MixpanelLib.prototype._prepare_callback = function(callback, data) {
30682 if (_.isUndefined(callback)) {
30683 return null;
30684 }
30685
30686 if (USE_XHR) {
30687 var callback_function = function(response) {
30688 callback(response, data);
30689 };
30690 return callback_function;
30691 } else {
30692 // if the user gives us a callback, we store as a random
30693 // property on this instances jsc function and update our
30694 // callback string to reflect that.
30695 var jsc = this['_jsc'];
30696 var randomized_cb = '' + Math.floor(Math.random() * 100000000);
30697 var callback_string = this.get_config('callback_fn') + '[' + randomized_cb + ']';
30698 jsc[randomized_cb] = function(response) {
30699 delete jsc[randomized_cb];
30700 callback(response, data);
30701 };
30702 return callback_string;
30703 }
30704 };
30705
30706 MixpanelLib.prototype._send_request = function(url, data, options, callback) {
30707 var succeeded = true;
30708
30709 if (ENQUEUE_REQUESTS) {
30710 this.__request_queue.push(arguments);
30711 return succeeded;
30712 }
30713
30714 var DEFAULT_OPTIONS = {
30715 method: this.get_config('api_method'),
30716 transport: this.get_config('api_transport'),
30717 verbose: this.get_config('verbose')
30718 };
30719 var body_data = null;
30720
30721 if (!callback && (_.isFunction(options) || typeof options === 'string')) {
30722 callback = options;
30723 options = null;
30724 }
30725 options = _.extend(DEFAULT_OPTIONS, options || {});
30726 if (!USE_XHR) {
30727 options.method = 'GET';
30728 }
30729 var use_post = options.method === 'POST';
30730 var use_sendBeacon = sendBeacon && use_post && options.transport.toLowerCase() === 'sendbeacon';
30731
30732 // needed to correctly format responses
30733 var verbose_mode = options.verbose;
30734 if (data['verbose']) { verbose_mode = true; }
30735
30736 if (this.get_config('test')) { data['test'] = 1; }
30737 if (verbose_mode) { data['verbose'] = 1; }
30738 if (this.get_config('img')) { data['img'] = 1; }
30739 if (!USE_XHR) {
30740 if (callback) {
30741 data['callback'] = callback;
30742 } else if (verbose_mode || this.get_config('test')) {
30743 // Verbose output (from verbose mode, or an error in test mode) is a json blob,
30744 // which by itself is not valid javascript. Without a callback, this verbose output will
30745 // cause an error when returned via jsonp, so we force a no-op callback param.
30746 // See the ECMA script spec: http://www.ecma-international.org/ecma-262/5.1/#sec-12.4
30747 data['callback'] = '(function(){})';
30748 }
30749 }
30750
30751 data['ip'] = this.get_config('ip')?1:0;
30752 data['_'] = new Date().getTime().toString();
30753
30754 if (use_post) {
30755 body_data = 'data=' + encodeURIComponent(data['data']);
30756 delete data['data'];
30757 }
30758
30759 _.extend(data, this.get_config('api_extra_query_params'));
30760
30761 url += '?' + _.HTTPBuildQuery(data);
30762
30763 var lib = this;
30764 if ('img' in data) {
30765 var img = document$1.createElement('img');
30766 img.src = url;
30767 document$1.body.appendChild(img);
30768 } else if (use_sendBeacon) {
30769 try {
30770 succeeded = sendBeacon(url, body_data);
30771 } catch (e) {
30772 lib.report_error(e);
30773 succeeded = false;
30774 }
30775 try {
30776 if (callback) {
30777 callback(succeeded ? 1 : 0);
30778 }
30779 } catch (e) {
30780 lib.report_error(e);
30781 }
30782 } else if (USE_XHR) {
30783 try {
30784 var req = new XMLHttpRequest();
30785 req.open(options.method, url, true);
30786
30787 var headers = this.get_config('xhr_headers');
30788 if (use_post) {
30789 headers['Content-Type'] = 'application/x-www-form-urlencoded';
30790 }
30791 _.each(headers, function(headerValue, headerName) {
30792 req.setRequestHeader(headerName, headerValue);
30793 });
30794
30795 if (options.timeout_ms && typeof req.timeout !== 'undefined') {
30796 req.timeout = options.timeout_ms;
30797 var start_time = new Date().getTime();
30798 }
30799
30800 // send the mp_optout cookie
30801 // withCredentials cannot be modified until after calling .open on Android and Mobile Safari
30802 req.withCredentials = true;
30803 req.onreadystatechange = function () {
30804 if (req.readyState === 4) { // XMLHttpRequest.DONE == 4, except in safari 4
30805 if (req.status === 200) {
30806 if (callback) {
30807 if (verbose_mode) {
30808 var response;
30809 try {
30810 response = _.JSONDecode(req.responseText);
30811 } catch (e) {
30812 lib.report_error(e);
30813 if (options.ignore_json_errors) {
30814 response = req.responseText;
30815 } else {
30816 return;
30817 }
30818 }
30819 callback(response);
30820 } else {
30821 callback(Number(req.responseText));
30822 }
30823 }
30824 } else {
30825 var error;
30826 if (
30827 req.timeout &&
30828 !req.status &&
30829 new Date().getTime() - start_time >= req.timeout
30830 ) {
30831 error = 'timeout';
30832 } else {
30833 error = 'Bad HTTP status: ' + req.status + ' ' + req.statusText;
30834 }
30835 lib.report_error(error);
30836 if (callback) {
30837 if (verbose_mode) {
30838 var response_headers = req['responseHeaders'] || {};
30839 callback({status: 0, httpStatusCode: req['status'], error: error, retryAfter: response_headers['Retry-After']});
30840 } else {
30841 callback(0);
30842 }
30843 }
30844 }
30845 }
30846 };
30847 req.send(body_data);
30848 } catch (e) {
30849 lib.report_error(e);
30850 succeeded = false;
30851 }
30852 } else {
30853 var script = document$1.createElement('script');
30854 script.type = 'text/javascript';
30855 script.async = true;
30856 script.defer = true;
30857 script.src = url;
30858 var s = document$1.getElementsByTagName('script')[0];
30859 s.parentNode.insertBefore(script, s);
30860 }
30861
30862 return succeeded;
30863 };
30864
30865 /**
30866 * _execute_array() deals with processing any mixpanel function
30867 * calls that were called before the Mixpanel library were loaded
30868 * (and are thus stored in an array so they can be called later)
30869 *
30870 * Note: we fire off all the mixpanel function calls && user defined
30871 * functions BEFORE we fire off mixpanel tracking calls. This is so
30872 * identify/register/set_config calls can properly modify early
30873 * tracking calls.
30874 *
30875 * @param {Array} array
30876 */
30877 MixpanelLib.prototype._execute_array = function(array) {
30878 var fn_name, alias_calls = [], other_calls = [], tracking_calls = [];
30879 _.each(array, function(item) {
30880 if (item) {
30881 fn_name = item[0];
30882 if (_.isArray(fn_name)) {
30883 tracking_calls.push(item); // chained call e.g. mixpanel.get_group().set()
30884 } else if (typeof(item) === 'function') {
30885 item.call(this);
30886 } else if (_.isArray(item) && fn_name === 'alias') {
30887 alias_calls.push(item);
30888 } else if (_.isArray(item) && fn_name.indexOf('track') !== -1 && typeof(this[fn_name]) === 'function') {
30889 tracking_calls.push(item);
30890 } else {
30891 other_calls.push(item);
30892 }
30893 }
30894 }, this);
30895
30896 var execute = function(calls, context) {
30897 _.each(calls, function(item) {
30898 if (_.isArray(item[0])) {
30899 // chained call
30900 var caller = context;
30901 _.each(item, function(call) {
30902 caller = caller[call[0]].apply(caller, call.slice(1));
30903 });
30904 } else {
30905 this[item[0]].apply(this, item.slice(1));
30906 }
30907 }, context);
30908 };
30909
30910 execute(alias_calls, this);
30911 execute(other_calls, this);
30912 execute(tracking_calls, this);
30913 };
30914
30915 // request queueing utils
30916
30917 MixpanelLib.prototype.are_batchers_initialized = function() {
30918 return !!this.request_batchers.events;
30919 };
30920
30921 MixpanelLib.prototype.get_batcher_configs = function() {
30922 var queue_prefix = '__mpq_' + this.get_config('token');
30923 this._batcher_configs = this._batcher_configs || {
30924 events: {type: 'events', api_name: 'track', queue_key: queue_prefix + '_ev'},
30925 people: {type: 'people', api_name: 'engage', queue_key: queue_prefix + '_pp'},
30926 groups: {type: 'groups', api_name: 'groups', queue_key: queue_prefix + '_gr'}
30927 };
30928 return this._batcher_configs;
30929 };
30930
30931 MixpanelLib.prototype.init_batchers = function() {
30932 if (!this.are_batchers_initialized()) {
30933 var batcher_for = _.bind(function(attrs) {
30934 return new RequestBatcher(
30935 attrs.queue_key,
30936 {
30937 libConfig: this['config'],
30938 errorReporter: this.get_config('error_reporter'),
30939 sendRequestFunc: _.bind(function(data, options, cb) {
30940 var api_routes = this.get_config('api_routes');
30941 this._send_request(
30942 this.get_api_host(attrs.api_name) + '/' + api_routes[attrs.api_name],
30943 this._encode_data_for_request(data),
30944 options,
30945 this._prepare_callback(cb, data)
30946 );
30947 }, this),
30948 beforeSendHook: _.bind(function(item) {
30949 return this._run_hook('before_send_' + attrs.type, item);
30950 }, this),
30951 stopAllBatchingFunc: _.bind(this.stop_batch_senders, this),
30952 usePersistence: true,
30953 }
30954 );
30955 }, this);
30956 var batcher_configs = this.get_batcher_configs();
30957 this.request_batchers = {
30958 events: batcher_for(batcher_configs.events),
30959 people: batcher_for(batcher_configs.people),
30960 groups: batcher_for(batcher_configs.groups)
30961 };
30962 }
30963 if (this.get_config('batch_autostart')) {
30964 this.start_batch_senders();
30965 }
30966 };
30967
30968 MixpanelLib.prototype.start_batch_senders = function() {
30969 this._batchers_were_started = true;
30970 if (this.are_batchers_initialized()) {
30971 this._batch_requests = true;
30972 _.each(this.request_batchers, function(batcher) {
30973 batcher.start();
30974 });
30975 }
30976 };
30977
30978 MixpanelLib.prototype.stop_batch_senders = function() {
30979 this._batch_requests = false;
30980 _.each(this.request_batchers, function(batcher) {
30981 batcher.stop();
30982 batcher.clear();
30983 });
30984 };
30985
30986 /**
30987 * push() keeps the standard async-array-push
30988 * behavior around after the lib is loaded.
30989 * This is only useful for external integrations that
30990 * do not wish to rely on our convenience methods
30991 * (created in the snippet).
30992 *
30993 * ### Usage:
30994 * mixpanel.push(['register', { a: 'b' }]);
30995 *
30996 * @param {Array} item A [function_name, args...] array to be executed
30997 */
30998 MixpanelLib.prototype.push = function(item) {
30999 this._execute_array([item]);
31000 };
31001
31002 /**
31003 * Disable events on the Mixpanel object. If passed no arguments,
31004 * this function disables tracking of any event. If passed an
31005 * array of event names, those events will be disabled, but other
31006 * events will continue to be tracked.
31007 *
31008 * Note: this function does not stop other mixpanel functions from
31009 * firing, such as register() or people.set().
31010 *
31011 * @param {Array} [events] An array of event names to disable
31012 */
31013 MixpanelLib.prototype.disable = function(events) {
31014 if (typeof(events) === 'undefined') {
31015 this._flags.disable_all_events = true;
31016 } else {
31017 this.__disabled_events = this.__disabled_events.concat(events);
31018 }
31019 };
31020
31021 MixpanelLib.prototype._encode_data_for_request = function(data) {
31022 var encoded_data = JSONStringify(data);
31023 if (this.get_config('api_payload_format') === PAYLOAD_TYPE_BASE64) {
31024 encoded_data = _.base64Encode(encoded_data);
31025 }
31026 return {'data': encoded_data};
31027 };
31028
31029 // internal method for handling track vs batch-enqueue logic
31030 MixpanelLib.prototype._track_or_batch = function(options, callback) {
31031 var truncated_data = _.truncate(options.data, 255);
31032 var endpoint = options.endpoint;
31033 var batcher = options.batcher;
31034 var should_send_immediately = options.should_send_immediately;
31035 var send_request_options = options.send_request_options || {};
31036 callback = callback || NOOP_FUNC;
31037
31038 var request_enqueued_or_initiated = true;
31039 var send_request_immediately = _.bind(function() {
31040 if (!send_request_options.skip_hooks) {
31041 truncated_data = this._run_hook('before_send_' + options.type, truncated_data);
31042 }
31043 if (truncated_data) {
31044 console$1.log('MIXPANEL REQUEST:');
31045 console$1.log(truncated_data);
31046 return this._send_request(
31047 endpoint,
31048 this._encode_data_for_request(truncated_data),
31049 send_request_options,
31050 this._prepare_callback(callback, truncated_data)
31051 );
31052 } else {
31053 return null;
31054 }
31055 }, this);
31056
31057 if (this._batch_requests && !should_send_immediately) {
31058 batcher.enqueue(truncated_data).then(function(succeeded) {
31059 if (succeeded) {
31060 callback(1, truncated_data);
31061 } else {
31062 send_request_immediately();
31063 }
31064 });
31065 } else {
31066 request_enqueued_or_initiated = send_request_immediately();
31067 }
31068
31069 return request_enqueued_or_initiated && truncated_data;
31070 };
31071
31072 /**
31073 * Track an event. This is the most important and
31074 * frequently used Mixpanel function.
31075 *
31076 * ### Usage:
31077 *
31078 * // track an event named 'Registered'
31079 * mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
31080 *
31081 * // track an event using navigator.sendBeacon
31082 * mixpanel.track('Left page', {'duration_seconds': 35}, {transport: 'sendBeacon'});
31083 *
31084 * To track link clicks or form submissions, see track_links() or track_forms().
31085 *
31086 * @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
31087 * @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.
31088 * @param {Object} [options] Optional configuration for this track request.
31089 * @param {String} [options.transport] Transport method for network request ('xhr' or 'sendBeacon').
31090 * @param {Boolean} [options.send_immediately] Whether to bypass batching/queueing and send track request immediately.
31091 * @param {Function} [callback] If provided, the callback function will be called after tracking the event.
31092 * @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
31093 * with the tracking payload sent to the API server is returned; otherwise false.
31094 */
31095 MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, properties, options, callback) {
31096 if (!callback && typeof options === 'function') {
31097 callback = options;
31098 options = null;
31099 }
31100 options = options || {};
31101 var transport = options['transport']; // external API, don't minify 'transport' prop
31102 if (transport) {
31103 options.transport = transport; // 'transport' prop name can be minified internally
31104 }
31105 var should_send_immediately = options['send_immediately'];
31106 if (typeof callback !== 'function') {
31107 callback = NOOP_FUNC;
31108 }
31109
31110 if (_.isUndefined(event_name)) {
31111 this.report_error('No event name provided to mixpanel.track');
31112 return;
31113 }
31114
31115 if (this._event_is_disabled(event_name)) {
31116 callback(0);
31117 return;
31118 }
31119
31120 // set defaults
31121 properties = _.extend({}, properties);
31122 properties['token'] = this.get_config('token');
31123
31124 // set $duration if time_event was previously called for this event
31125 var start_timestamp = this['persistence'].remove_event_timer(event_name);
31126 if (!_.isUndefined(start_timestamp)) {
31127 var duration_in_ms = new Date().getTime() - start_timestamp;
31128 properties['$duration'] = parseFloat((duration_in_ms / 1000).toFixed(3));
31129 }
31130
31131 this._set_default_superprops();
31132
31133 var marketing_properties = this.get_config('track_marketing')
31134 ? _.info.marketingParams()
31135 : {};
31136
31137 // note: extend writes to the first object, so lets make sure we
31138 // don't write to the persistence properties object and info
31139 // properties object by passing in a new object
31140
31141 // update properties with pageview info and super-properties
31142 properties = _.extend(
31143 {},
31144 _.info.properties({'mp_loader': this.get_config('mp_loader')}),
31145 marketing_properties,
31146 this['persistence'].properties(),
31147 this.unpersisted_superprops,
31148 this.get_session_recording_properties(),
31149 properties
31150 );
31151
31152 var property_blacklist = this.get_config('property_blacklist');
31153 if (_.isArray(property_blacklist)) {
31154 _.each(property_blacklist, function(blacklisted_prop) {
31155 delete properties[blacklisted_prop];
31156 });
31157 } else {
31158 this.report_error('Invalid value for property_blacklist config: ' + property_blacklist);
31159 }
31160
31161 var data = {
31162 'event': event_name,
31163 'properties': properties
31164 };
31165 var ret = this._track_or_batch({
31166 type: 'events',
31167 data: data,
31168 endpoint: this.get_api_host('events') + '/' + this.get_config('api_routes')['track'],
31169 batcher: this.request_batchers.events,
31170 should_send_immediately: should_send_immediately,
31171 send_request_options: options
31172 }, callback);
31173
31174 return ret;
31175 });
31176
31177 /**
31178 * Register the current user into one/many groups.
31179 *
31180 * ### Usage:
31181 *
31182 * mixpanel.set_group('company', ['mixpanel', 'google']) // an array of IDs
31183 * mixpanel.set_group('company', 'mixpanel')
31184 * mixpanel.set_group('company', 128746312)
31185 *
31186 * @param {String} group_key Group key
31187 * @param {Array|String|Number} group_ids An array of group IDs, or a singular group ID
31188 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
31189 *
31190 */
31191 MixpanelLib.prototype.set_group = addOptOutCheckMixpanelLib(function(group_key, group_ids, callback) {
31192 if (!_.isArray(group_ids)) {
31193 group_ids = [group_ids];
31194 }
31195 var prop = {};
31196 prop[group_key] = group_ids;
31197 this.register(prop);
31198 return this['people'].set(group_key, group_ids, callback);
31199 });
31200
31201 /**
31202 * Add a new group for this user.
31203 *
31204 * ### Usage:
31205 *
31206 * mixpanel.add_group('company', 'mixpanel')
31207 *
31208 * @param {String} group_key Group key
31209 * @param {*} group_id A valid Mixpanel property type
31210 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
31211 */
31212 MixpanelLib.prototype.add_group = addOptOutCheckMixpanelLib(function(group_key, group_id, callback) {
31213 var old_values = this.get_property(group_key);
31214 var prop = {};
31215 if (old_values === undefined) {
31216 prop[group_key] = [group_id];
31217 this.register(prop);
31218 } else {
31219 if (old_values.indexOf(group_id) === -1) {
31220 old_values.push(group_id);
31221 prop[group_key] = old_values;
31222 this.register(prop);
31223 }
31224 }
31225 return this['people'].union(group_key, group_id, callback);
31226 });
31227
31228 /**
31229 * Remove a group from this user.
31230 *
31231 * ### Usage:
31232 *
31233 * mixpanel.remove_group('company', 'mixpanel')
31234 *
31235 * @param {String} group_key Group key
31236 * @param {*} group_id A valid Mixpanel property type
31237 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
31238 */
31239 MixpanelLib.prototype.remove_group = addOptOutCheckMixpanelLib(function(group_key, group_id, callback) {
31240 var old_value = this.get_property(group_key);
31241 // if the value doesn't exist, the persistent store is unchanged
31242 if (old_value !== undefined) {
31243 var idx = old_value.indexOf(group_id);
31244 if (idx > -1) {
31245 old_value.splice(idx, 1);
31246 this.register({group_key: old_value});
31247 }
31248 if (old_value.length === 0) {
31249 this.unregister(group_key);
31250 }
31251 }
31252 return this['people'].remove(group_key, group_id, callback);
31253 });
31254
31255 /**
31256 * Track an event with specific groups.
31257 *
31258 * ### Usage:
31259 *
31260 * mixpanel.track_with_groups('purchase', {'product': 'iphone'}, {'University': ['UCB', 'UCLA']})
31261 *
31262 * @param {String} event_name The name of the event (see `mixpanel.track()`)
31263 * @param {Object=} properties A set of properties to include with the event you're sending (see `mixpanel.track()`)
31264 * @param {Object=} groups An object mapping group name keys to one or more values
31265 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
31266 */
31267 MixpanelLib.prototype.track_with_groups = addOptOutCheckMixpanelLib(function(event_name, properties, groups, callback) {
31268 var tracking_props = _.extend({}, properties || {});
31269 _.each(groups, function(v, k) {
31270 if (v !== null && v !== undefined) {
31271 tracking_props[k] = v;
31272 }
31273 });
31274 return this.track(event_name, tracking_props, callback);
31275 });
31276
31277 MixpanelLib.prototype._create_map_key = function (group_key, group_id) {
31278 return group_key + '_' + JSON.stringify(group_id);
31279 };
31280
31281 MixpanelLib.prototype._remove_group_from_cache = function (group_key, group_id) {
31282 delete this._cached_groups[this._create_map_key(group_key, group_id)];
31283 };
31284
31285 /**
31286 * Look up reference to a Mixpanel group
31287 *
31288 * ### Usage:
31289 *
31290 * mixpanel.get_group(group_key, group_id)
31291 *
31292 * @param {String} group_key Group key
31293 * @param {Object} group_id A valid Mixpanel property type
31294 * @returns {Object} A MixpanelGroup identifier
31295 */
31296 MixpanelLib.prototype.get_group = function (group_key, group_id) {
31297 var map_key = this._create_map_key(group_key, group_id);
31298 var group = this._cached_groups[map_key];
31299 if (group === undefined || group._group_key !== group_key || group._group_id !== group_id) {
31300 group = new MixpanelGroup();
31301 group._init(this, group_key, group_id);
31302 this._cached_groups[map_key] = group;
31303 }
31304 return group;
31305 };
31306
31307 /**
31308 * Track a default Mixpanel page view event, which includes extra default event properties to
31309 * improve page view data.
31310 *
31311 * ### Usage:
31312 *
31313 * // track a default $mp_web_page_view event
31314 * mixpanel.track_pageview();
31315 *
31316 * // track a page view event with additional event properties
31317 * mixpanel.track_pageview({'ab_test_variant': 'card-layout-b'});
31318 *
31319 * // example approach to track page views on different page types as event properties
31320 * mixpanel.track_pageview({'page': 'pricing'});
31321 * mixpanel.track_pageview({'page': 'homepage'});
31322 *
31323 * // UNCOMMON: Tracking a page view event with a custom event_name option. NOT expected to be used for
31324 * // individual pages on the same site or product. Use cases for custom event_name may be page
31325 * // views on different products or internal applications that are considered completely separate
31326 * mixpanel.track_pageview({'page': 'customer-search'}, {'event_name': '[internal] Admin Page View'});
31327 *
31328 * ### Notes:
31329 *
31330 * The `config.track_pageview` option for <a href="#mixpanelinit">mixpanel.init()</a>
31331 * may be turned on for tracking page loads automatically.
31332 *
31333 * // track only page loads
31334 * mixpanel.init(PROJECT_TOKEN, {track_pageview: true});
31335 *
31336 * // track when the URL changes in any manner
31337 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'full-url'});
31338 *
31339 * // track when the URL changes, ignoring any changes in the hash part
31340 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'url-with-path-and-query-string'});
31341 *
31342 * // track when the path changes, ignoring any query parameter or hash changes
31343 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'url-with-path'});
31344 *
31345 * @param {Object} [properties] An optional set of additional properties to send with the page view event
31346 * @param {Object} [options] Page view tracking options
31347 * @param {String} [options.event_name] - Alternate name for the tracking event
31348 * @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
31349 * with the tracking payload sent to the API server is returned; otherwise false.
31350 */
31351 MixpanelLib.prototype.track_pageview = addOptOutCheckMixpanelLib(function(properties, options) {
31352 if (typeof properties !== 'object') {
31353 properties = {};
31354 }
31355 options = options || {};
31356 var event_name = options['event_name'] || '$mp_web_page_view';
31357
31358 var default_page_properties = _.extend(
31359 _.info.mpPageViewProperties(),
31360 _.info.campaignParams(),
31361 _.info.clickParams()
31362 );
31363
31364 var event_properties = _.extend(
31365 {},
31366 default_page_properties,
31367 properties
31368 );
31369
31370 return this.track(event_name, event_properties);
31371 });
31372
31373 /**
31374 * Track clicks on a set of document elements. Selector must be a
31375 * valid query. Elements must exist on the page at the time track_links is called.
31376 *
31377 * ### Usage:
31378 *
31379 * // track click for link id #nav
31380 * mixpanel.track_links('#nav', 'Clicked Nav Link');
31381 *
31382 * ### Notes:
31383 *
31384 * This function will wait up to 300 ms for the Mixpanel
31385 * servers to respond. If they have not responded by that time
31386 * it will head to the link without ensuring that your event
31387 * has been tracked. To configure this timeout please see the
31388 * set_config() documentation below.
31389 *
31390 * If you pass a function in as the properties argument, the
31391 * function will receive the DOMElement that triggered the
31392 * event as an argument. You are expected to return an object
31393 * from the function; any properties defined on this object
31394 * will be sent to mixpanel as event properties.
31395 *
31396 * @type {Function}
31397 * @param {Object|String} query A valid DOM query, element or jQuery-esque list
31398 * @param {String} event_name The name of the event to track
31399 * @param {Object|Function} [properties] A properties object or function that returns a dictionary of properties when passed a DOMElement
31400 */
31401 MixpanelLib.prototype.track_links = function() {
31402 return this._track_dom.call(this, LinkTracker, arguments);
31403 };
31404
31405 /**
31406 * Track form submissions. Selector must be a valid query.
31407 *
31408 * ### Usage:
31409 *
31410 * // track submission for form id 'register'
31411 * mixpanel.track_forms('#register', 'Created Account');
31412 *
31413 * ### Notes:
31414 *
31415 * This function will wait up to 300 ms for the mixpanel
31416 * servers to respond, if they have not responded by that time
31417 * it will head to the link without ensuring that your event
31418 * has been tracked. To configure this timeout please see the
31419 * set_config() documentation below.
31420 *
31421 * If you pass a function in as the properties argument, the
31422 * function will receive the DOMElement that triggered the
31423 * event as an argument. You are expected to return an object
31424 * from the function; any properties defined on this object
31425 * will be sent to mixpanel as event properties.
31426 *
31427 * @type {Function}
31428 * @param {Object|String} query A valid DOM query, element or jQuery-esque list
31429 * @param {String} event_name The name of the event to track
31430 * @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
31431 */
31432 MixpanelLib.prototype.track_forms = function() {
31433 return this._track_dom.call(this, FormTracker, arguments);
31434 };
31435
31436 /**
31437 * Time an event by including the time between this call and a
31438 * later 'track' call for the same event in the properties sent
31439 * with the event.
31440 *
31441 * ### Usage:
31442 *
31443 * // time an event named 'Registered'
31444 * mixpanel.time_event('Registered');
31445 * mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
31446 *
31447 * When called for a particular event name, the next track call for that event
31448 * name will include the elapsed time between the 'time_event' and 'track'
31449 * calls. This value is stored as seconds in the '$duration' property.
31450 *
31451 * @param {String} event_name The name of the event.
31452 */
31453 MixpanelLib.prototype.time_event = function(event_name) {
31454 if (_.isUndefined(event_name)) {
31455 this.report_error('No event name provided to mixpanel.time_event');
31456 return;
31457 }
31458
31459 if (this._event_is_disabled(event_name)) {
31460 return;
31461 }
31462
31463 this['persistence'].set_event_timer(event_name, new Date().getTime());
31464 };
31465
31466 var REGISTER_DEFAULTS = {
31467 'persistent': true
31468 };
31469 /**
31470 * Helper to parse options param for register methods, maintaining
31471 * legacy support for plain "days" param instead of options object
31472 * @param {Number|Object} [days_or_options] 'days' option (Number), or Options object for register methods
31473 * @returns {Object} options object
31474 */
31475 var options_for_register = function(days_or_options) {
31476 var options;
31477 if (_.isObject(days_or_options)) {
31478 options = days_or_options;
31479 } else if (!_.isUndefined(days_or_options)) {
31480 options = {'days': days_or_options};
31481 } else {
31482 options = {};
31483 }
31484 return _.extend({}, REGISTER_DEFAULTS, options);
31485 };
31486
31487 /**
31488 * Register a set of super properties, which are included with all
31489 * events. This will overwrite previous super property values.
31490 *
31491 * ### Usage:
31492 *
31493 * // register 'Gender' as a super property
31494 * mixpanel.register({'Gender': 'Female'});
31495 *
31496 * // register several super properties when a user signs up
31497 * mixpanel.register({
31498 * 'Email': 'jdoe@example.com',
31499 * 'Account Type': 'Free'
31500 * });
31501 *
31502 * // register only for the current pageload
31503 * mixpanel.register({'Name': 'Pat'}, {persistent: false});
31504 *
31505 * @param {Object} properties An associative array of properties to store about the user
31506 * @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)
31507 * @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)
31508 * @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
31509 */
31510 MixpanelLib.prototype.register = function(props, days_or_options) {
31511 var options = options_for_register(days_or_options);
31512 if (options['persistent']) {
31513 this['persistence'].register(props, options['days']);
31514 } else {
31515 _.extend(this.unpersisted_superprops, props);
31516 }
31517 };
31518
31519 /**
31520 * Register a set of super properties only once. This will not
31521 * overwrite previous super property values, unlike register().
31522 *
31523 * ### Usage:
31524 *
31525 * // register a super property for the first time only
31526 * mixpanel.register_once({
31527 * 'First Login Date': new Date().toISOString()
31528 * });
31529 *
31530 * // register once, only for the current pageload
31531 * mixpanel.register_once({
31532 * 'First interaction time': new Date().toISOString()
31533 * }, 'None', {persistent: false});
31534 *
31535 * ### Notes:
31536 *
31537 * If default_value is specified, current super properties
31538 * with that value will be overwritten.
31539 *
31540 * @param {Object} properties An associative array of properties to store about the user
31541 * @param {*} [default_value] Value to override if already set in super properties (ex: 'False') Default: 'None'
31542 * @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)
31543 * @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)
31544 * @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
31545 */
31546 MixpanelLib.prototype.register_once = function(props, default_value, days_or_options) {
31547 var options = options_for_register(days_or_options);
31548 if (options['persistent']) {
31549 this['persistence'].register_once(props, default_value, options['days']);
31550 } else {
31551 if (typeof(default_value) === 'undefined') {
31552 default_value = 'None';
31553 }
31554 _.each(props, function(val, prop) {
31555 if (!this.unpersisted_superprops.hasOwnProperty(prop) || this.unpersisted_superprops[prop] === default_value) {
31556 this.unpersisted_superprops[prop] = val;
31557 }
31558 }, this);
31559 }
31560 };
31561
31562 /**
31563 * Delete a super property stored with the current user.
31564 *
31565 * @param {String} property The name of the super property to remove
31566 * @param {Object} [options]
31567 * @param {boolean} [options.persistent=true] - whether to look in persistent storage (cookie/localStorage)
31568 */
31569 MixpanelLib.prototype.unregister = function(property, options) {
31570 options = options_for_register(options);
31571 if (options['persistent']) {
31572 this['persistence'].unregister(property);
31573 } else {
31574 delete this.unpersisted_superprops[property];
31575 }
31576 };
31577
31578 MixpanelLib.prototype._register_single = function(prop, value) {
31579 var props = {};
31580 props[prop] = value;
31581 this.register(props);
31582 };
31583
31584 /**
31585 * Identify a user with a unique ID to track user activity across
31586 * devices, tie a user to their events, and create a user profile.
31587 * If you never call this method, unique visitors are tracked using
31588 * a UUID generated the first time they visit the site.
31589 *
31590 * Call identify when you know the identity of the current user,
31591 * typically after login or signup. We recommend against using
31592 * identify for anonymous visitors to your site.
31593 *
31594 * ### Notes:
31595 * If your project has
31596 * <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a>
31597 * enabled, the identify method will connect pre- and
31598 * post-authentication events when appropriate.
31599 *
31600 * If your project does not have ID Merge enabled, identify will
31601 * change the user's local distinct_id to the unique ID you pass.
31602 * Events tracked prior to authentication will not be connected
31603 * to the same user identity. If ID Merge is disabled, alias can
31604 * be used to connect pre- and post-registration events.
31605 *
31606 * @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.
31607 */
31608 MixpanelLib.prototype.identify = function(
31609 new_distinct_id, _set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback
31610 ) {
31611 // Optional Parameters
31612 // _set_callback:function A callback to be run if and when the People set queue is flushed
31613 // _add_callback:function A callback to be run if and when the People add queue is flushed
31614 // _append_callback:function A callback to be run if and when the People append queue is flushed
31615 // _set_once_callback:function A callback to be run if and when the People set_once queue is flushed
31616 // _union_callback:function A callback to be run if and when the People union queue is flushed
31617 // _unset_callback:function A callback to be run if and when the People unset queue is flushed
31618
31619 var previous_distinct_id = this.get_distinct_id();
31620 if (new_distinct_id && previous_distinct_id !== new_distinct_id) {
31621 // we allow the following condition if previous distinct_id is same as new_distinct_id
31622 // so that you can force flush people updates for anonymous profiles.
31623 if (typeof new_distinct_id === 'string' && new_distinct_id.indexOf(DEVICE_ID_PREFIX) === 0) {
31624 this.report_error('distinct_id cannot have $device: prefix');
31625 return -1;
31626 }
31627 this.register({'$user_id': new_distinct_id});
31628 }
31629
31630 if (!this.get_property('$device_id')) {
31631 // The persisted distinct id might not actually be a device id at all
31632 // it might be a distinct id of the user from before
31633 var device_id = previous_distinct_id;
31634 this.register_once({
31635 '$had_persisted_distinct_id': true,
31636 '$device_id': device_id
31637 }, '');
31638 }
31639
31640 // identify only changes the distinct id if it doesn't match either the existing or the alias;
31641 // if it's new, blow away the alias as well.
31642 if (new_distinct_id !== previous_distinct_id && new_distinct_id !== this.get_property(ALIAS_ID_KEY)) {
31643 this.unregister(ALIAS_ID_KEY);
31644 this.register({'distinct_id': new_distinct_id});
31645 }
31646 this._flags.identify_called = true;
31647 // Flush any queued up people requests
31648 this['people']._flush(_set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback);
31649
31650 // send an $identify event any time the distinct_id is changing - logic on the server
31651 // will determine whether or not to do anything with it.
31652 if (new_distinct_id !== previous_distinct_id) {
31653 this.track('$identify', {
31654 'distinct_id': new_distinct_id,
31655 '$anon_distinct_id': previous_distinct_id
31656 }, {skip_hooks: true});
31657 }
31658
31659 // check feature flags again if distinct id has changed
31660 if (new_distinct_id !== previous_distinct_id) {
31661 this.flags.fetchFlags();
31662 }
31663 };
31664
31665 /**
31666 * Clears super properties and generates a new random distinct_id for this instance.
31667 * Useful for clearing data when a user logs out.
31668 */
31669 MixpanelLib.prototype.reset = function() {
31670 this.stop_session_recording();
31671 this['persistence'].clear();
31672 this._flags.identify_called = false;
31673 var uuid = _.UUID();
31674 this.register_once({
31675 'distinct_id': DEVICE_ID_PREFIX + uuid,
31676 '$device_id': uuid
31677 }, '');
31678 this._check_and_start_session_recording();
31679 };
31680
31681 /**
31682 * Returns the current distinct id of the user. This is either the id automatically
31683 * generated by the library or the id that has been passed by a call to identify().
31684 *
31685 * ### Notes:
31686 *
31687 * get_distinct_id() can only be called after the Mixpanel library has finished loading.
31688 * init() has a loaded function available to handle this automatically. For example:
31689 *
31690 * // set distinct_id after the mixpanel library has loaded
31691 * mixpanel.init('YOUR PROJECT TOKEN', {
31692 * loaded: function(mixpanel) {
31693 * distinct_id = mixpanel.get_distinct_id();
31694 * }
31695 * });
31696 */
31697 MixpanelLib.prototype.get_distinct_id = function() {
31698 return this.get_property('distinct_id');
31699 };
31700
31701 /**
31702 * The alias method creates an alias which Mixpanel will use to
31703 * remap one id to another. Multiple aliases can point to the
31704 * same identifier.
31705 *
31706 * The following is a valid use of alias:
31707 *
31708 * mixpanel.alias('new_id', 'existing_id');
31709 * // You can add multiple id aliases to the existing ID
31710 * mixpanel.alias('newer_id', 'existing_id');
31711 *
31712 * Aliases can also be chained - the following is a valid example:
31713 *
31714 * mixpanel.alias('new_id', 'existing_id');
31715 * // chain newer_id - new_id - existing_id
31716 * mixpanel.alias('newer_id', 'new_id');
31717 *
31718 * Aliases cannot point to multiple identifiers - the following
31719 * example will not work:
31720 *
31721 * mixpanel.alias('new_id', 'existing_id');
31722 * // this is invalid as 'new_id' already points to 'existing_id'
31723 * mixpanel.alias('new_id', 'newer_id');
31724 *
31725 * ### Notes:
31726 *
31727 * If your project does not have
31728 * <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a>
31729 * enabled, the best practice is to call alias once when a unique
31730 * ID is first created for a user (e.g., when a user first registers
31731 * for an account). Do not use alias multiple times for a single
31732 * user without ID Merge enabled.
31733 *
31734 * @param {String} alias A unique identifier that you want to use for this user in the future.
31735 * @param {String} [original] The current identifier being used for this user.
31736 */
31737 MixpanelLib.prototype.alias = function(alias, original) {
31738 // If the $people_distinct_id key exists in persistence, there has been a previous
31739 // mixpanel.people.identify() call made for this user. It is VERY BAD to make an alias with
31740 // this ID, as it will duplicate users.
31741 if (alias === this.get_property(PEOPLE_DISTINCT_ID_KEY)) {
31742 this.report_error('Attempting to create alias for existing People user - aborting.');
31743 return -2;
31744 }
31745
31746 var _this = this;
31747 if (_.isUndefined(original)) {
31748 original = this.get_distinct_id();
31749 }
31750 if (alias !== original) {
31751 this._register_single(ALIAS_ID_KEY, alias);
31752 return this.track('$create_alias', {
31753 'alias': alias,
31754 'distinct_id': original
31755 }, {
31756 skip_hooks: true
31757 }, function() {
31758 // Flush the people queue
31759 _this.identify(alias);
31760 });
31761 } else {
31762 this.report_error('alias matches current distinct_id - skipping api call.');
31763 this.identify(alias);
31764 return -1;
31765 }
31766 };
31767
31768 /**
31769 * Provide a string to recognize the user by. The string passed to
31770 * this method will appear in the Mixpanel Streams product rather
31771 * than an automatically generated name. Name tags do not have to
31772 * be unique.
31773 *
31774 * This value will only be included in Streams data.
31775 *
31776 * @param {String} name_tag A human readable name for the user
31777 * @deprecated
31778 */
31779 MixpanelLib.prototype.name_tag = function(name_tag) {
31780 this._register_single('mp_name_tag', name_tag);
31781 };
31782
31783 /**
31784 * Update the configuration of a mixpanel library instance.
31785 *
31786 * The default config is:
31787 *
31788 * {
31789 * // host for requests (customizable for e.g. a local proxy)
31790 * api_host: 'https://api-js.mixpanel.com',
31791 *
31792 * // endpoints for different types of requests
31793 * api_routes: {
31794 * track: 'track/',
31795 * engage: 'engage/',
31796 * groups: 'groups/',
31797 * }
31798 *
31799 * // HTTP method for tracking requests
31800 * api_method: 'POST'
31801 *
31802 * // transport for sending requests ('XHR' or 'sendBeacon')
31803 * // NB: sendBeacon should only be used for scenarios such as
31804 * // page unload where a "best-effort" attempt to send is
31805 * // acceptable; the sendBeacon API does not support callbacks
31806 * // or any way to know the result of the request. Mixpanel
31807 * // tracking via sendBeacon will not support any event-
31808 * // batching or retry mechanisms.
31809 * api_transport: 'XHR'
31810 *
31811 * // request-batching/queueing/retry
31812 * batch_requests: true,
31813 *
31814 * // maximum number of events/updates to send in a single
31815 * // network request
31816 * batch_size: 50,
31817 *
31818 * // milliseconds to wait between sending batch requests
31819 * batch_flush_interval_ms: 5000,
31820 *
31821 * // milliseconds to wait for network responses to batch requests
31822 * // before they are considered timed-out and retried
31823 * batch_request_timeout_ms: 90000,
31824 *
31825 * // override value for cookie domain, only useful for ensuring
31826 * // correct cross-subdomain cookies on unusual domains like
31827 * // subdomain.mainsite.avocat.fr; NB this cannot be used to
31828 * // set cookies on a different domain than the current origin
31829 * cookie_domain: ''
31830 *
31831 * // super properties cookie expiration (in days)
31832 * cookie_expiration: 365
31833 *
31834 * // if true, cookie will be set with SameSite=None; Secure
31835 * // this is only useful in special situations, like embedded
31836 * // 3rd-party iframes that set up a Mixpanel instance
31837 * cross_site_cookie: false
31838 *
31839 * // super properties span subdomains
31840 * cross_subdomain_cookie: true
31841 *
31842 * // debug mode
31843 * debug: false
31844 *
31845 * // if this is true, the mixpanel cookie or localStorage entry
31846 * // will be deleted, and no user persistence will take place
31847 * disable_persistence: false
31848 *
31849 * // if this is true, Mixpanel will automatically determine
31850 * // City, Region and Country data using the IP address of
31851 * //the client
31852 * ip: true
31853 *
31854 * // opt users out of tracking by this Mixpanel instance by default
31855 * opt_out_tracking_by_default: false
31856 *
31857 * // opt users out of browser data storage by this Mixpanel instance by default
31858 * opt_out_persistence_by_default: false
31859 *
31860 * // persistence mechanism used by opt-in/opt-out methods - cookie
31861 * // or localStorage - falls back to cookie if localStorage is unavailable
31862 * opt_out_tracking_persistence_type: 'localStorage'
31863 *
31864 * // customize the name of cookie/localStorage set by opt-in/opt-out methods
31865 * opt_out_tracking_cookie_prefix: null
31866 *
31867 * // type of persistent store for super properties (cookie/
31868 * // localStorage) if set to 'localStorage', any existing
31869 * // mixpanel cookie value with the same persistence_name
31870 * // will be transferred to localStorage and deleted
31871 * persistence: 'cookie'
31872 *
31873 * // name for super properties persistent store
31874 * persistence_name: ''
31875 *
31876 * // names of properties/superproperties which should never
31877 * // be sent with track() calls
31878 * property_blacklist: []
31879 *
31880 * // if this is true, mixpanel cookies will be marked as
31881 * // secure, meaning they will only be transmitted over https
31882 * secure_cookie: false
31883 *
31884 * // disables enriching user profiles with first touch marketing data
31885 * skip_first_touch_marketing: false
31886 *
31887 * // the amount of time track_links will
31888 * // wait for Mixpanel's servers to respond
31889 * track_links_timeout: 300
31890 *
31891 * // adds any UTM parameters and click IDs present on the page to any events fired
31892 * track_marketing: true
31893 *
31894 * // enables automatic page view tracking using default page view events through
31895 * // the track_pageview() method
31896 * track_pageview: false
31897 *
31898 * // if you set upgrade to be true, the library will check for
31899 * // a cookie from our old js library and import super
31900 * // properties from it, then the old cookie is deleted
31901 * // The upgrade config option only works in the initialization,
31902 * // so make sure you set it when you create the library.
31903 * upgrade: false
31904 *
31905 * // extra HTTP request headers to set for each API request, in
31906 * // the format {'Header-Name': value}
31907 * xhr_headers: {}
31908 *
31909 * // whether to ignore or respect the web browser's Do Not Track setting
31910 * ignore_dnt: false
31911 * }
31912 *
31913 *
31914 * @param {Object} config A dictionary of new configuration values to update
31915 */
31916 MixpanelLib.prototype.set_config = function(config) {
31917 if (_.isObject(config)) {
31918 _.extend(this['config'], config);
31919
31920 var new_batch_size = config['batch_size'];
31921 if (new_batch_size) {
31922 _.each(this.request_batchers, function(batcher) {
31923 batcher.resetBatchSize();
31924 });
31925 }
31926
31927 if (!this.get_config('persistence_name')) {
31928 this['config']['persistence_name'] = this['config']['cookie_name'];
31929 }
31930 if (!this.get_config('disable_persistence')) {
31931 this['config']['disable_persistence'] = this['config']['disable_cookie'];
31932 }
31933
31934 if (this['persistence']) {
31935 this['persistence'].update_config(this['config']);
31936 }
31937 Config.DEBUG = Config.DEBUG || this.get_config('debug');
31938
31939 if (('autocapture' in config || 'record_heatmap_data' in config) && this.autocapture) {
31940 this.autocapture.init();
31941 }
31942 }
31943 };
31944
31945 /**
31946 * returns the current config object for the library.
31947 */
31948 MixpanelLib.prototype.get_config = function(prop_name) {
31949 return this['config'][prop_name];
31950 };
31951
31952 /**
31953 * Fetch a hook function from config, with safe default, and run it
31954 * against the given arguments
31955 * @param {string} hook_name which hook to retrieve
31956 * @returns {any|null} return value of user-provided hook, or null if nothing was returned
31957 */
31958 MixpanelLib.prototype._run_hook = function(hook_name) {
31959 var ret = (this['config']['hooks'][hook_name] || IDENTITY_FUNC).apply(this, slice.call(arguments, 1));
31960 if (typeof ret === 'undefined') {
31961 this.report_error(hook_name + ' hook did not return a value');
31962 ret = null;
31963 }
31964 return ret;
31965 };
31966
31967 /**
31968 * Returns the value of the super property named property_name. If no such
31969 * property is set, get_property() will return the undefined value.
31970 *
31971 * ### Notes:
31972 *
31973 * get_property() can only be called after the Mixpanel library has finished loading.
31974 * init() has a loaded function available to handle this automatically. For example:
31975 *
31976 * // grab value for 'user_id' after the mixpanel library has loaded
31977 * mixpanel.init('YOUR PROJECT TOKEN', {
31978 * loaded: function(mixpanel) {
31979 * user_id = mixpanel.get_property('user_id');
31980 * }
31981 * });
31982 *
31983 * @param {String} property_name The name of the super property you want to retrieve
31984 */
31985 MixpanelLib.prototype.get_property = function(property_name) {
31986 return this['persistence'].load_prop([property_name]);
31987 };
31988
31989 /**
31990 * Get the API host for a specific endpoint type, falling back to the default api_host if not specified
31991 *
31992 * @param {String} endpoint_type The type of endpoint (e.g., "events", "people", "groups")
31993 * @returns {String} The API host to use for this endpoint
31994 */
31995 MixpanelLib.prototype.get_api_host = function(endpoint_type) {
31996 return this.get_config('api_hosts')[endpoint_type] || this.get_config('api_host');
31997 };
31998
31999 MixpanelLib.prototype.toString = function() {
32000 var name = this.get_config('name');
32001 if (name !== PRIMARY_INSTANCE_NAME) {
32002 name = PRIMARY_INSTANCE_NAME + '.' + name;
32003 }
32004 return name;
32005 };
32006
32007 MixpanelLib.prototype._event_is_disabled = function(event_name) {
32008 return _.isBlockedUA(userAgent) ||
32009 this._flags.disable_all_events ||
32010 _.include(this.__disabled_events, event_name);
32011 };
32012
32013 // perform some housekeeping around GDPR opt-in/out state
32014 MixpanelLib.prototype._gdpr_init = function() {
32015 var is_localStorage_requested = this.get_config('opt_out_tracking_persistence_type') === 'localStorage';
32016
32017 // try to convert opt-in/out cookies to localStorage if possible
32018 if (is_localStorage_requested && _.localStorage.is_supported()) {
32019 if (!this.has_opted_in_tracking() && this.has_opted_in_tracking({'persistence_type': 'cookie'})) {
32020 this.opt_in_tracking({'enable_persistence': false});
32021 }
32022 if (!this.has_opted_out_tracking() && this.has_opted_out_tracking({'persistence_type': 'cookie'})) {
32023 this.opt_out_tracking({'clear_persistence': false});
32024 }
32025 this.clear_opt_in_out_tracking({
32026 'persistence_type': 'cookie',
32027 'enable_persistence': false
32028 });
32029 }
32030
32031 // check whether the user has already opted out - if so, clear & disable persistence
32032 if (this.has_opted_out_tracking()) {
32033 this._gdpr_update_persistence({'clear_persistence': true});
32034
32035 // check whether we should opt out by default
32036 // note: we don't clear persistence here by default since opt-out default state is often
32037 // used as an initial state while GDPR information is being collected
32038 } else if (!this.has_opted_in_tracking() && (
32039 this.get_config('opt_out_tracking_by_default') || _.cookie.get('mp_optout')
32040 )) {
32041 _.cookie.remove('mp_optout');
32042 this.opt_out_tracking({
32043 'clear_persistence': this.get_config('opt_out_persistence_by_default')
32044 });
32045 }
32046 };
32047
32048 /**
32049 * Enable or disable persistence based on options
32050 * only enable/disable if persistence is not already in this state
32051 * @param {boolean} [options.clear_persistence] If true, will delete all data stored by the sdk in persistence and disable it
32052 * @param {boolean} [options.enable_persistence] If true, will re-enable sdk persistence
32053 */
32054 MixpanelLib.prototype._gdpr_update_persistence = function(options) {
32055 var disabled;
32056 if (options && options['clear_persistence']) {
32057 disabled = true;
32058 } else if (options && options['enable_persistence']) {
32059 disabled = false;
32060 } else {
32061 return;
32062 }
32063
32064 if (!this.get_config('disable_persistence') && this['persistence'].disabled !== disabled) {
32065 this['persistence'].set_disabled(disabled);
32066 }
32067
32068 if (disabled) {
32069 this.stop_batch_senders();
32070 this.stop_session_recording();
32071 } else {
32072 // only start batchers after opt-in if they have previously been started
32073 // in order to avoid unintentionally starting up batching for the first time
32074 if (this._batchers_were_started) {
32075 this.start_batch_senders();
32076 }
32077 }
32078 };
32079
32080 // call a base gdpr function after constructing the appropriate token and options args
32081 MixpanelLib.prototype._gdpr_call_func = function(func, options) {
32082 options = _.extend({
32083 'track': _.bind(this.track, this),
32084 'persistence_type': this.get_config('opt_out_tracking_persistence_type'),
32085 'cookie_prefix': this.get_config('opt_out_tracking_cookie_prefix'),
32086 'cookie_expiration': this.get_config('cookie_expiration'),
32087 'cross_site_cookie': this.get_config('cross_site_cookie'),
32088 'cross_subdomain_cookie': this.get_config('cross_subdomain_cookie'),
32089 'cookie_domain': this.get_config('cookie_domain'),
32090 'secure_cookie': this.get_config('secure_cookie'),
32091 'ignore_dnt': this.get_config('ignore_dnt')
32092 }, options);
32093
32094 // check if localStorage can be used for recording opt out status, fall back to cookie if not
32095 if (!_.localStorage.is_supported()) {
32096 options['persistence_type'] = 'cookie';
32097 }
32098
32099 return func(this.get_config('token'), {
32100 track: options['track'],
32101 trackEventName: options['track_event_name'],
32102 trackProperties: options['track_properties'],
32103 persistenceType: options['persistence_type'],
32104 persistencePrefix: options['cookie_prefix'],
32105 cookieDomain: options['cookie_domain'],
32106 cookieExpiration: options['cookie_expiration'],
32107 crossSiteCookie: options['cross_site_cookie'],
32108 crossSubdomainCookie: options['cross_subdomain_cookie'],
32109 secureCookie: options['secure_cookie'],
32110 ignoreDnt: options['ignore_dnt']
32111 });
32112 };
32113
32114 /**
32115 * Opt the user in to data tracking and cookies/localstorage for this Mixpanel instance
32116 *
32117 * ### Usage:
32118 *
32119 * // opt user in
32120 * mixpanel.opt_in_tracking();
32121 *
32122 * // opt user in with specific event name, properties, cookie configuration
32123 * mixpanel.opt_in_tracking({
32124 * track_event_name: 'User opted in',
32125 * track_event_properties: {
32126 * 'Email': 'jdoe@example.com'
32127 * },
32128 * cookie_expiration: 30,
32129 * secure_cookie: true
32130 * });
32131 *
32132 * @param {Object} [options] A dictionary of config options to override
32133 * @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)
32134 * @param {string} [options.track_event_name=$opt_in] Event name to be used for tracking the opt-in action
32135 * @param {Object} [options.track_properties] Set of properties to be tracked along with the opt-in action
32136 * @param {boolean} [options.enable_persistence=true] If true, will re-enable sdk persistence
32137 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32138 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32139 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
32140 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
32141 * @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)
32142 * @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)
32143 * @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)
32144 */
32145 MixpanelLib.prototype.opt_in_tracking = function(options) {
32146 options = _.extend({
32147 'enable_persistence': true
32148 }, options);
32149
32150 this._gdpr_call_func(optIn, options);
32151 this._gdpr_update_persistence(options);
32152 };
32153
32154 /**
32155 * Opt the user out of data tracking and cookies/localstorage for this Mixpanel instance
32156 *
32157 * ### Usage:
32158 *
32159 * // opt user out
32160 * mixpanel.opt_out_tracking();
32161 *
32162 * // opt user out with different cookie configuration from Mixpanel instance
32163 * mixpanel.opt_out_tracking({
32164 * cookie_expiration: 30,
32165 * secure_cookie: true
32166 * });
32167 *
32168 * @param {Object} [options] A dictionary of config options to override
32169 * @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
32170 * @param {boolean} [options.clear_persistence=true] If true, will delete all data stored by the sdk in persistence
32171 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32172 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32173 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
32174 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
32175 * @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)
32176 * @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)
32177 * @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)
32178 */
32179 MixpanelLib.prototype.opt_out_tracking = function(options) {
32180 options = _.extend({
32181 'clear_persistence': true,
32182 'delete_user': true
32183 }, options);
32184
32185 // delete user and clear charges since these methods may be disabled by opt-out
32186 if (options['delete_user'] && this['people'] && this['people']._identify_called()) {
32187 this['people'].delete_user();
32188 this['people'].clear_charges();
32189 }
32190
32191 this._gdpr_call_func(optOut, options);
32192 this._gdpr_update_persistence(options);
32193 };
32194
32195 /**
32196 * Check whether the user has opted in to data tracking and cookies/localstorage for this Mixpanel instance
32197 *
32198 * ### Usage:
32199 *
32200 * var has_opted_in = mixpanel.has_opted_in_tracking();
32201 * // use has_opted_in value
32202 *
32203 * @param {Object} [options] A dictionary of config options to override
32204 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32205 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32206 * @returns {boolean} current opt-in status
32207 */
32208 MixpanelLib.prototype.has_opted_in_tracking = function(options) {
32209 return this._gdpr_call_func(hasOptedIn, options);
32210 };
32211
32212 /**
32213 * Check whether the user has opted out of data tracking and cookies/localstorage for this Mixpanel instance
32214 *
32215 * ### Usage:
32216 *
32217 * var has_opted_out = mixpanel.has_opted_out_tracking();
32218 * // use has_opted_out value
32219 *
32220 * @param {Object} [options] A dictionary of config options to override
32221 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32222 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32223 * @returns {boolean} current opt-out status
32224 */
32225 MixpanelLib.prototype.has_opted_out_tracking = function(options) {
32226 return this._gdpr_call_func(hasOptedOut, options);
32227 };
32228
32229 /**
32230 * Clear the user's opt in/out status of data tracking and cookies/localstorage for this Mixpanel instance
32231 *
32232 * ### Usage:
32233 *
32234 * // clear user's opt-in/out status
32235 * mixpanel.clear_opt_in_out_tracking();
32236 *
32237 * // clear user's opt-in/out status with specific cookie configuration - should match
32238 * // configuration used when opt_in_tracking/opt_out_tracking methods were called.
32239 * mixpanel.clear_opt_in_out_tracking({
32240 * cookie_expiration: 30,
32241 * secure_cookie: true
32242 * });
32243 *
32244 * @param {Object} [options] A dictionary of config options to override
32245 * @param {boolean} [options.enable_persistence=true] If true, will re-enable sdk persistence
32246 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32247 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32248 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
32249 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
32250 * @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)
32251 * @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)
32252 * @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)
32253 */
32254 MixpanelLib.prototype.clear_opt_in_out_tracking = function(options) {
32255 options = _.extend({
32256 'enable_persistence': true
32257 }, options);
32258
32259 this._gdpr_call_func(clearOptInOut, options);
32260 this._gdpr_update_persistence(options);
32261 };
32262
32263 MixpanelLib.prototype.report_error = function(msg, err) {
32264 console$1.error.apply(console$1.error, arguments);
32265 try {
32266 if (!err && !(msg instanceof Error)) {
32267 msg = new Error(msg);
32268 }
32269 this.get_config('error_reporter')(msg, err);
32270 } catch(err) {
32271 console$1.error(err);
32272 }
32273 };
32274
32275 // EXPORTS (for closure compiler)
32276
32277 // MixpanelLib Exports
32278 MixpanelLib.prototype['init'] = MixpanelLib.prototype.init;
32279 MixpanelLib.prototype['reset'] = MixpanelLib.prototype.reset;
32280 MixpanelLib.prototype['disable'] = MixpanelLib.prototype.disable;
32281 MixpanelLib.prototype['time_event'] = MixpanelLib.prototype.time_event;
32282 MixpanelLib.prototype['track'] = MixpanelLib.prototype.track;
32283 MixpanelLib.prototype['track_links'] = MixpanelLib.prototype.track_links;
32284 MixpanelLib.prototype['track_forms'] = MixpanelLib.prototype.track_forms;
32285 MixpanelLib.prototype['track_pageview'] = MixpanelLib.prototype.track_pageview;
32286 MixpanelLib.prototype['register'] = MixpanelLib.prototype.register;
32287 MixpanelLib.prototype['register_once'] = MixpanelLib.prototype.register_once;
32288 MixpanelLib.prototype['unregister'] = MixpanelLib.prototype.unregister;
32289 MixpanelLib.prototype['identify'] = MixpanelLib.prototype.identify;
32290 MixpanelLib.prototype['alias'] = MixpanelLib.prototype.alias;
32291 MixpanelLib.prototype['name_tag'] = MixpanelLib.prototype.name_tag;
32292 MixpanelLib.prototype['set_config'] = MixpanelLib.prototype.set_config;
32293 MixpanelLib.prototype['get_config'] = MixpanelLib.prototype.get_config;
32294 MixpanelLib.prototype['get_api_host'] = MixpanelLib.prototype.get_api_host;
32295 MixpanelLib.prototype['get_property'] = MixpanelLib.prototype.get_property;
32296 MixpanelLib.prototype['get_distinct_id'] = MixpanelLib.prototype.get_distinct_id;
32297 MixpanelLib.prototype['toString'] = MixpanelLib.prototype.toString;
32298 MixpanelLib.prototype['opt_out_tracking'] = MixpanelLib.prototype.opt_out_tracking;
32299 MixpanelLib.prototype['opt_in_tracking'] = MixpanelLib.prototype.opt_in_tracking;
32300 MixpanelLib.prototype['has_opted_out_tracking'] = MixpanelLib.prototype.has_opted_out_tracking;
32301 MixpanelLib.prototype['has_opted_in_tracking'] = MixpanelLib.prototype.has_opted_in_tracking;
32302 MixpanelLib.prototype['clear_opt_in_out_tracking'] = MixpanelLib.prototype.clear_opt_in_out_tracking;
32303 MixpanelLib.prototype['get_group'] = MixpanelLib.prototype.get_group;
32304 MixpanelLib.prototype['set_group'] = MixpanelLib.prototype.set_group;
32305 MixpanelLib.prototype['add_group'] = MixpanelLib.prototype.add_group;
32306 MixpanelLib.prototype['remove_group'] = MixpanelLib.prototype.remove_group;
32307 MixpanelLib.prototype['track_with_groups'] = MixpanelLib.prototype.track_with_groups;
32308 MixpanelLib.prototype['start_batch_senders'] = MixpanelLib.prototype.start_batch_senders;
32309 MixpanelLib.prototype['stop_batch_senders'] = MixpanelLib.prototype.stop_batch_senders;
32310 MixpanelLib.prototype['start_session_recording'] = MixpanelLib.prototype.start_session_recording;
32311 MixpanelLib.prototype['stop_session_recording'] = MixpanelLib.prototype.stop_session_recording;
32312 MixpanelLib.prototype['pause_session_recording'] = MixpanelLib.prototype.pause_session_recording;
32313 MixpanelLib.prototype['resume_session_recording'] = MixpanelLib.prototype.resume_session_recording;
32314 MixpanelLib.prototype['get_session_recording_properties'] = MixpanelLib.prototype.get_session_recording_properties;
32315 MixpanelLib.prototype['get_session_replay_url'] = MixpanelLib.prototype.get_session_replay_url;
32316 MixpanelLib.prototype['get_tab_id'] = MixpanelLib.prototype.get_tab_id;
32317 MixpanelLib.prototype['DEFAULT_API_ROUTES'] = DEFAULT_API_ROUTES;
32318
32319 // Exports intended only for testing
32320 MixpanelLib.prototype['__get_recorder'] = MixpanelLib.prototype.__get_recorder;
32321
32322 // MixpanelPersistence Exports
32323 MixpanelPersistence.prototype['properties'] = MixpanelPersistence.prototype.properties;
32324 MixpanelPersistence.prototype['update_search_keyword'] = MixpanelPersistence.prototype.update_search_keyword;
32325 MixpanelPersistence.prototype['update_referrer_info'] = MixpanelPersistence.prototype.update_referrer_info;
32326 MixpanelPersistence.prototype['get_cross_subdomain'] = MixpanelPersistence.prototype.get_cross_subdomain;
32327 MixpanelPersistence.prototype['clear'] = MixpanelPersistence.prototype.clear;
32328
32329
32330 var instances = {};
32331 var extend_mp = function() {
32332 // add all the sub mixpanel instances
32333 _.each(instances, function(instance, name) {
32334 if (name !== PRIMARY_INSTANCE_NAME) { mixpanel_master[name] = instance; }
32335 });
32336
32337 // add private functions as _
32338 mixpanel_master['_'] = _;
32339 };
32340
32341 var override_mp_init_func = function() {
32342 // we override the snippets init function to handle the case where a
32343 // user initializes the mixpanel library after the script loads & runs
32344 mixpanel_master['init'] = function(token, config, name) {
32345 if (name) {
32346 // initialize a sub library
32347 if (!mixpanel_master[name]) {
32348 mixpanel_master[name] = instances[name] = create_mplib(token, config, name);
32349 mixpanel_master[name]._loaded();
32350 }
32351 return mixpanel_master[name];
32352 } else {
32353 var instance = mixpanel_master;
32354
32355 if (instances[PRIMARY_INSTANCE_NAME]) {
32356 // main mixpanel lib already initialized
32357 instance = instances[PRIMARY_INSTANCE_NAME];
32358 } else if (token) {
32359 // intialize the main mixpanel lib
32360 instance = create_mplib(token, config, PRIMARY_INSTANCE_NAME);
32361 instance._loaded();
32362 instances[PRIMARY_INSTANCE_NAME] = instance;
32363 }
32364
32365 mixpanel_master = instance;
32366 if (init_type === INIT_SNIPPET) {
32367 win[PRIMARY_INSTANCE_NAME] = mixpanel_master;
32368 }
32369 extend_mp();
32370 }
32371 };
32372 };
32373
32374 var add_dom_loaded_handler = function() {
32375 // Cross browser DOM Loaded support
32376 function dom_loaded_handler() {
32377 // function flag since we only want to execute this once
32378 if (dom_loaded_handler.done) { return; }
32379 dom_loaded_handler.done = true;
32380
32381 DOM_LOADED = true;
32382 ENQUEUE_REQUESTS = false;
32383
32384 _.each(instances, function(inst) {
32385 inst._dom_loaded();
32386 });
32387 }
32388
32389 function do_scroll_check() {
32390 try {
32391 document$1.documentElement.doScroll('left');
32392 } catch(e) {
32393 setTimeout(do_scroll_check, 1);
32394 return;
32395 }
32396
32397 dom_loaded_handler();
32398 }
32399
32400 if (document$1.addEventListener) {
32401 if (document$1.readyState === 'complete') {
32402 // safari 4 can fire the DOMContentLoaded event before loading all
32403 // external JS (including this file). you will see some copypasta
32404 // on the internet that checks for 'complete' and 'loaded', but
32405 // 'loaded' is an IE thing
32406 dom_loaded_handler();
32407 } else {
32408 document$1.addEventListener('DOMContentLoaded', dom_loaded_handler, false);
32409 }
32410 } else if (document$1.attachEvent) {
32411 // IE
32412 document$1.attachEvent('onreadystatechange', dom_loaded_handler);
32413
32414 // check to make sure we arn't in a frame
32415 var toplevel = false;
32416 try {
32417 toplevel = win.frameElement === null;
32418 } catch(e) {
32419 // noop
32420 }
32421
32422 if (document$1.documentElement.doScroll && toplevel) {
32423 do_scroll_check();
32424 }
32425 }
32426
32427 // fallback handler, always will work
32428 _.register_event(win, 'load', dom_loaded_handler, true);
32429 };
32430
32431 function init_as_module(bundle_loader) {
32432 load_extra_bundle = bundle_loader;
32433 init_type = INIT_MODULE;
32434 mixpanel_master = new MixpanelLib();
32435
32436 override_mp_init_func();
32437 mixpanel_master['init']();
32438 add_dom_loaded_handler();
32439
32440 return mixpanel_master;
32441 }
32442
32443 // For loading separate bundles asynchronously via script tag
32444 // so that we don't load them until they are needed at runtime.
32445
32446 // For builds that have everything in one bundle, no extra work.
32447 function loadNoop (_src, onload) {
32448 onload();
32449 }
32450
32451 /* eslint camelcase: "off" */
32452
32453 var mixpanel = init_as_module(loadNoop);
32454
32455
32456
32457
32458 /***/ }),
32459
32460 /***/ "../node_modules/redux-thunk/es/index.js":
32461 /*!***********************************************!*\
32462 !*** ../node_modules/redux-thunk/es/index.js ***!
32463 \***********************************************/
32464 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
32465
32466 "use strict";
32467 __webpack_require__.r(__webpack_exports__);
32468 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
32469 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
32470 /* harmony export */ });
32471 /** A function that accepts a potential "extra argument" value to be injected later,
32472 * and returns an instance of the thunk middleware that uses that value
32473 */
32474 function createThunkMiddleware(extraArgument) {
32475 // Standard Redux middleware definition pattern:
32476 // See: https://redux.js.org/tutorials/fundamentals/part-4-store#writing-custom-middleware
32477 var middleware = function middleware(_ref) {
32478 var dispatch = _ref.dispatch,
32479 getState = _ref.getState;
32480 return function (next) {
32481 return function (action) {
32482 // The thunk middleware looks for any functions that were passed to `store.dispatch`.
32483 // If this "action" is really a function, call it and return the result.
32484 if (typeof action === 'function') {
32485 // Inject the store's `dispatch` and `getState` methods, as well as any "extra arg"
32486 return action(dispatch, getState, extraArgument);
32487 } // Otherwise, pass the action down the middleware chain as usual
32488
32489
32490 return next(action);
32491 };
32492 };
32493 };
32494
32495 return middleware;
32496 }
32497
32498 var thunk = createThunkMiddleware(); // Attach the factory function so users can create a customized version
32499 // with whatever "extra arg" they want to inject into their thunks
32500
32501 thunk.withExtraArgument = createThunkMiddleware;
32502 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (thunk);
32503
32504 /***/ }),
32505
32506 /***/ "../node_modules/redux/es/redux.js":
32507 /*!*****************************************!*\
32508 !*** ../node_modules/redux/es/redux.js ***!
32509 \*****************************************/
32510 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
32511
32512 "use strict";
32513 __webpack_require__.r(__webpack_exports__);
32514 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
32515 /* harmony export */ __DO_NOT_USE__ActionTypes: () => (/* binding */ ActionTypes),
32516 /* harmony export */ applyMiddleware: () => (/* binding */ applyMiddleware),
32517 /* harmony export */ bindActionCreators: () => (/* binding */ bindActionCreators),
32518 /* harmony export */ combineReducers: () => (/* binding */ combineReducers),
32519 /* harmony export */ compose: () => (/* binding */ compose),
32520 /* harmony export */ createStore: () => (/* binding */ createStore),
32521 /* harmony export */ legacy_createStore: () => (/* binding */ legacy_createStore)
32522 /* harmony export */ });
32523 /* 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");
32524
32525
32526 /**
32527 * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
32528 *
32529 * Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
32530 * during build.
32531 * @param {number} code
32532 */
32533 function formatProdErrorMessage(code) {
32534 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. ';
32535 }
32536
32537 // Inlined version of the `symbol-observable` polyfill
32538 var $$observable = (function () {
32539 return typeof Symbol === 'function' && Symbol.observable || '@@observable';
32540 })();
32541
32542 /**
32543 * These are private action types reserved by Redux.
32544 * For any unknown actions, you must return the current state.
32545 * If the current state is undefined, you must return the initial state.
32546 * Do not reference these action types directly in your code.
32547 */
32548 var randomString = function randomString() {
32549 return Math.random().toString(36).substring(7).split('').join('.');
32550 };
32551
32552 var ActionTypes = {
32553 INIT: "@@redux/INIT" + randomString(),
32554 REPLACE: "@@redux/REPLACE" + randomString(),
32555 PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
32556 return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
32557 }
32558 };
32559
32560 /**
32561 * @param {any} obj The object to inspect.
32562 * @returns {boolean} True if the argument appears to be a plain object.
32563 */
32564 function isPlainObject(obj) {
32565 if (typeof obj !== 'object' || obj === null) return false;
32566 var proto = obj;
32567
32568 while (Object.getPrototypeOf(proto) !== null) {
32569 proto = Object.getPrototypeOf(proto);
32570 }
32571
32572 return Object.getPrototypeOf(obj) === proto;
32573 }
32574
32575 // Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
32576 function miniKindOf(val) {
32577 if (val === void 0) return 'undefined';
32578 if (val === null) return 'null';
32579 var type = typeof val;
32580
32581 switch (type) {
32582 case 'boolean':
32583 case 'string':
32584 case 'number':
32585 case 'symbol':
32586 case 'function':
32587 {
32588 return type;
32589 }
32590 }
32591
32592 if (Array.isArray(val)) return 'array';
32593 if (isDate(val)) return 'date';
32594 if (isError(val)) return 'error';
32595 var constructorName = ctorName(val);
32596
32597 switch (constructorName) {
32598 case 'Symbol':
32599 case 'Promise':
32600 case 'WeakMap':
32601 case 'WeakSet':
32602 case 'Map':
32603 case 'Set':
32604 return constructorName;
32605 } // other
32606
32607
32608 return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
32609 }
32610
32611 function ctorName(val) {
32612 return typeof val.constructor === 'function' ? val.constructor.name : null;
32613 }
32614
32615 function isError(val) {
32616 return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
32617 }
32618
32619 function isDate(val) {
32620 if (val instanceof Date) return true;
32621 return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function';
32622 }
32623
32624 function kindOf(val) {
32625 var typeOfVal = typeof val;
32626
32627 if (true) {
32628 typeOfVal = miniKindOf(val);
32629 }
32630
32631 return typeOfVal;
32632 }
32633
32634 /**
32635 * @deprecated
32636 *
32637 * **We recommend using the `configureStore` method
32638 * of the `@reduxjs/toolkit` package**, which replaces `createStore`.
32639 *
32640 * Redux Toolkit is our recommended approach for writing Redux logic today,
32641 * including store setup, reducers, data fetching, and more.
32642 *
32643 * **For more details, please read this Redux docs page:**
32644 * **https://redux.js.org/introduction/why-rtk-is-redux-today**
32645 *
32646 * `configureStore` from Redux Toolkit is an improved version of `createStore` that
32647 * simplifies setup and helps avoid common bugs.
32648 *
32649 * You should not be using the `redux` core package by itself today, except for learning purposes.
32650 * The `createStore` method from the core `redux` package will not be removed, but we encourage
32651 * all users to migrate to using Redux Toolkit for all Redux code.
32652 *
32653 * If you want to use `createStore` without this visual deprecation warning, use
32654 * the `legacy_createStore` import instead:
32655 *
32656 * `import { legacy_createStore as createStore} from 'redux'`
32657 *
32658 */
32659
32660 function createStore(reducer, preloadedState, enhancer) {
32661 var _ref2;
32662
32663 if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
32664 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.');
32665 }
32666
32667 if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
32668 enhancer = preloadedState;
32669 preloadedState = undefined;
32670 }
32671
32672 if (typeof enhancer !== 'undefined') {
32673 if (typeof enhancer !== 'function') {
32674 throw new Error( false ? 0 : "Expected the enhancer to be a function. Instead, received: '" + kindOf(enhancer) + "'");
32675 }
32676
32677 return enhancer(createStore)(reducer, preloadedState);
32678 }
32679
32680 if (typeof reducer !== 'function') {
32681 throw new Error( false ? 0 : "Expected the root reducer to be a function. Instead, received: '" + kindOf(reducer) + "'");
32682 }
32683
32684 var currentReducer = reducer;
32685 var currentState = preloadedState;
32686 var currentListeners = [];
32687 var nextListeners = currentListeners;
32688 var isDispatching = false;
32689 /**
32690 * This makes a shallow copy of currentListeners so we can use
32691 * nextListeners as a temporary list while dispatching.
32692 *
32693 * This prevents any bugs around consumers calling
32694 * subscribe/unsubscribe in the middle of a dispatch.
32695 */
32696
32697 function ensureCanMutateNextListeners() {
32698 if (nextListeners === currentListeners) {
32699 nextListeners = currentListeners.slice();
32700 }
32701 }
32702 /**
32703 * Reads the state tree managed by the store.
32704 *
32705 * @returns {any} The current state tree of your application.
32706 */
32707
32708
32709 function getState() {
32710 if (isDispatching) {
32711 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.');
32712 }
32713
32714 return currentState;
32715 }
32716 /**
32717 * Adds a change listener. It will be called any time an action is dispatched,
32718 * and some part of the state tree may potentially have changed. You may then
32719 * call `getState()` to read the current state tree inside the callback.
32720 *
32721 * You may call `dispatch()` from a change listener, with the following
32722 * caveats:
32723 *
32724 * 1. The subscriptions are snapshotted just before every `dispatch()` call.
32725 * If you subscribe or unsubscribe while the listeners are being invoked, this
32726 * will not have any effect on the `dispatch()` that is currently in progress.
32727 * However, the next `dispatch()` call, whether nested or not, will use a more
32728 * recent snapshot of the subscription list.
32729 *
32730 * 2. The listener should not expect to see all state changes, as the state
32731 * might have been updated multiple times during a nested `dispatch()` before
32732 * the listener is called. It is, however, guaranteed that all subscribers
32733 * registered before the `dispatch()` started will be called with the latest
32734 * state by the time it exits.
32735 *
32736 * @param {Function} listener A callback to be invoked on every dispatch.
32737 * @returns {Function} A function to remove this change listener.
32738 */
32739
32740
32741 function subscribe(listener) {
32742 if (typeof listener !== 'function') {
32743 throw new Error( false ? 0 : "Expected the listener to be a function. Instead, received: '" + kindOf(listener) + "'");
32744 }
32745
32746 if (isDispatching) {
32747 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.');
32748 }
32749
32750 var isSubscribed = true;
32751 ensureCanMutateNextListeners();
32752 nextListeners.push(listener);
32753 return function unsubscribe() {
32754 if (!isSubscribed) {
32755 return;
32756 }
32757
32758 if (isDispatching) {
32759 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.');
32760 }
32761
32762 isSubscribed = false;
32763 ensureCanMutateNextListeners();
32764 var index = nextListeners.indexOf(listener);
32765 nextListeners.splice(index, 1);
32766 currentListeners = null;
32767 };
32768 }
32769 /**
32770 * Dispatches an action. It is the only way to trigger a state change.
32771 *
32772 * The `reducer` function, used to create the store, will be called with the
32773 * current state tree and the given `action`. Its return value will
32774 * be considered the **next** state of the tree, and the change listeners
32775 * will be notified.
32776 *
32777 * The base implementation only supports plain object actions. If you want to
32778 * dispatch a Promise, an Observable, a thunk, or something else, you need to
32779 * wrap your store creating function into the corresponding middleware. For
32780 * example, see the documentation for the `redux-thunk` package. Even the
32781 * middleware will eventually dispatch plain object actions using this method.
32782 *
32783 * @param {Object} action A plain object representing “what changed”. It is
32784 * a good idea to keep actions serializable so you can record and replay user
32785 * sessions, or use the time travelling `redux-devtools`. An action must have
32786 * a `type` property which may not be `undefined`. It is a good idea to use
32787 * string constants for action types.
32788 *
32789 * @returns {Object} For convenience, the same action object you dispatched.
32790 *
32791 * Note that, if you use a custom middleware, it may wrap `dispatch()` to
32792 * return something else (for example, a Promise you can await).
32793 */
32794
32795
32796 function dispatch(action) {
32797 if (!isPlainObject(action)) {
32798 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.");
32799 }
32800
32801 if (typeof action.type === 'undefined') {
32802 throw new Error( false ? 0 : 'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');
32803 }
32804
32805 if (isDispatching) {
32806 throw new Error( false ? 0 : 'Reducers may not dispatch actions.');
32807 }
32808
32809 try {
32810 isDispatching = true;
32811 currentState = currentReducer(currentState, action);
32812 } finally {
32813 isDispatching = false;
32814 }
32815
32816 var listeners = currentListeners = nextListeners;
32817
32818 for (var i = 0; i < listeners.length; i++) {
32819 var listener = listeners[i];
32820 listener();
32821 }
32822
32823 return action;
32824 }
32825 /**
32826 * Replaces the reducer currently used by the store to calculate the state.
32827 *
32828 * You might need this if your app implements code splitting and you want to
32829 * load some of the reducers dynamically. You might also need this if you
32830 * implement a hot reloading mechanism for Redux.
32831 *
32832 * @param {Function} nextReducer The reducer for the store to use instead.
32833 * @returns {void}
32834 */
32835
32836
32837 function replaceReducer(nextReducer) {
32838 if (typeof nextReducer !== 'function') {
32839 throw new Error( false ? 0 : "Expected the nextReducer to be a function. Instead, received: '" + kindOf(nextReducer));
32840 }
32841
32842 currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
32843 // Any reducers that existed in both the new and old rootReducer
32844 // will receive the previous state. This effectively populates
32845 // the new state tree with any relevant data from the old one.
32846
32847 dispatch({
32848 type: ActionTypes.REPLACE
32849 });
32850 }
32851 /**
32852 * Interoperability point for observable/reactive libraries.
32853 * @returns {observable} A minimal observable of state changes.
32854 * For more information, see the observable proposal:
32855 * https://github.com/tc39/proposal-observable
32856 */
32857
32858
32859 function observable() {
32860 var _ref;
32861
32862 var outerSubscribe = subscribe;
32863 return _ref = {
32864 /**
32865 * The minimal observable subscription method.
32866 * @param {Object} observer Any object that can be used as an observer.
32867 * The observer object should have a `next` method.
32868 * @returns {subscription} An object with an `unsubscribe` method that can
32869 * be used to unsubscribe the observable from the store, and prevent further
32870 * emission of values from the observable.
32871 */
32872 subscribe: function subscribe(observer) {
32873 if (typeof observer !== 'object' || observer === null) {
32874 throw new Error( false ? 0 : "Expected the observer to be an object. Instead, received: '" + kindOf(observer) + "'");
32875 }
32876
32877 function observeState() {
32878 if (observer.next) {
32879 observer.next(getState());
32880 }
32881 }
32882
32883 observeState();
32884 var unsubscribe = outerSubscribe(observeState);
32885 return {
32886 unsubscribe: unsubscribe
32887 };
32888 }
32889 }, _ref[$$observable] = function () {
32890 return this;
32891 }, _ref;
32892 } // When a store is created, an "INIT" action is dispatched so that every
32893 // reducer returns their initial state. This effectively populates
32894 // the initial state tree.
32895
32896
32897 dispatch({
32898 type: ActionTypes.INIT
32899 });
32900 return _ref2 = {
32901 dispatch: dispatch,
32902 subscribe: subscribe,
32903 getState: getState,
32904 replaceReducer: replaceReducer
32905 }, _ref2[$$observable] = observable, _ref2;
32906 }
32907 /**
32908 * Creates a Redux store that holds the state tree.
32909 *
32910 * **We recommend using `configureStore` from the
32911 * `@reduxjs/toolkit` package**, which replaces `createStore`:
32912 * **https://redux.js.org/introduction/why-rtk-is-redux-today**
32913 *
32914 * The only way to change the data in the store is to call `dispatch()` on it.
32915 *
32916 * There should only be a single store in your app. To specify how different
32917 * parts of the state tree respond to actions, you may combine several reducers
32918 * into a single reducer function by using `combineReducers`.
32919 *
32920 * @param {Function} reducer A function that returns the next state tree, given
32921 * the current state tree and the action to handle.
32922 *
32923 * @param {any} [preloadedState] The initial state. You may optionally specify it
32924 * to hydrate the state from the server in universal apps, or to restore a
32925 * previously serialized user session.
32926 * If you use `combineReducers` to produce the root reducer function, this must be
32927 * an object with the same shape as `combineReducers` keys.
32928 *
32929 * @param {Function} [enhancer] The store enhancer. You may optionally specify it
32930 * to enhance the store with third-party capabilities such as middleware,
32931 * time travel, persistence, etc. The only store enhancer that ships with Redux
32932 * is `applyMiddleware()`.
32933 *
32934 * @returns {Store} A Redux store that lets you read the state, dispatch actions
32935 * and subscribe to changes.
32936 */
32937
32938 var legacy_createStore = createStore;
32939
32940 /**
32941 * Prints a warning in the console if it exists.
32942 *
32943 * @param {String} message The warning message.
32944 * @returns {void}
32945 */
32946 function warning(message) {
32947 /* eslint-disable no-console */
32948 if (typeof console !== 'undefined' && typeof console.error === 'function') {
32949 console.error(message);
32950 }
32951 /* eslint-enable no-console */
32952
32953
32954 try {
32955 // This error was thrown as a convenience so that if you enable
32956 // "break on all exceptions" in your console,
32957 // it would pause the execution at this line.
32958 throw new Error(message);
32959 } catch (e) {} // eslint-disable-line no-empty
32960
32961 }
32962
32963 function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
32964 var reducerKeys = Object.keys(reducers);
32965 var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
32966
32967 if (reducerKeys.length === 0) {
32968 return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
32969 }
32970
32971 if (!isPlainObject(inputState)) {
32972 return "The " + argumentName + " has unexpected type of \"" + kindOf(inputState) + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\"");
32973 }
32974
32975 var unexpectedKeys = Object.keys(inputState).filter(function (key) {
32976 return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
32977 });
32978 unexpectedKeys.forEach(function (key) {
32979 unexpectedKeyCache[key] = true;
32980 });
32981 if (action && action.type === ActionTypes.REPLACE) return;
32982
32983 if (unexpectedKeys.length > 0) {
32984 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.");
32985 }
32986 }
32987
32988 function assertReducerShape(reducers) {
32989 Object.keys(reducers).forEach(function (key) {
32990 var reducer = reducers[key];
32991 var initialState = reducer(undefined, {
32992 type: ActionTypes.INIT
32993 });
32994
32995 if (typeof initialState === 'undefined') {
32996 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.");
32997 }
32998
32999 if (typeof reducer(undefined, {
33000 type: ActionTypes.PROBE_UNKNOWN_ACTION()
33001 }) === 'undefined') {
33002 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.");
33003 }
33004 });
33005 }
33006 /**
33007 * Turns an object whose values are different reducer functions, into a single
33008 * reducer function. It will call every child reducer, and gather their results
33009 * into a single state object, whose keys correspond to the keys of the passed
33010 * reducer functions.
33011 *
33012 * @param {Object} reducers An object whose values correspond to different
33013 * reducer functions that need to be combined into one. One handy way to obtain
33014 * it is to use ES6 `import * as reducers` syntax. The reducers may never return
33015 * undefined for any action. Instead, they should return their initial state
33016 * if the state passed to them was undefined, and the current state for any
33017 * unrecognized action.
33018 *
33019 * @returns {Function} A reducer function that invokes every reducer inside the
33020 * passed object, and builds a state object with the same shape.
33021 */
33022
33023
33024 function combineReducers(reducers) {
33025 var reducerKeys = Object.keys(reducers);
33026 var finalReducers = {};
33027
33028 for (var i = 0; i < reducerKeys.length; i++) {
33029 var key = reducerKeys[i];
33030
33031 if (true) {
33032 if (typeof reducers[key] === 'undefined') {
33033 warning("No reducer provided for key \"" + key + "\"");
33034 }
33035 }
33036
33037 if (typeof reducers[key] === 'function') {
33038 finalReducers[key] = reducers[key];
33039 }
33040 }
33041
33042 var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
33043 // keys multiple times.
33044
33045 var unexpectedKeyCache;
33046
33047 if (true) {
33048 unexpectedKeyCache = {};
33049 }
33050
33051 var shapeAssertionError;
33052
33053 try {
33054 assertReducerShape(finalReducers);
33055 } catch (e) {
33056 shapeAssertionError = e;
33057 }
33058
33059 return function combination(state, action) {
33060 if (state === void 0) {
33061 state = {};
33062 }
33063
33064 if (shapeAssertionError) {
33065 throw shapeAssertionError;
33066 }
33067
33068 if (true) {
33069 var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
33070
33071 if (warningMessage) {
33072 warning(warningMessage);
33073 }
33074 }
33075
33076 var hasChanged = false;
33077 var nextState = {};
33078
33079 for (var _i = 0; _i < finalReducerKeys.length; _i++) {
33080 var _key = finalReducerKeys[_i];
33081 var reducer = finalReducers[_key];
33082 var previousStateForKey = state[_key];
33083 var nextStateForKey = reducer(previousStateForKey, action);
33084
33085 if (typeof nextStateForKey === 'undefined') {
33086 var actionType = action && action.type;
33087 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.");
33088 }
33089
33090 nextState[_key] = nextStateForKey;
33091 hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
33092 }
33093
33094 hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
33095 return hasChanged ? nextState : state;
33096 };
33097 }
33098
33099 function bindActionCreator(actionCreator, dispatch) {
33100 return function () {
33101 return dispatch(actionCreator.apply(this, arguments));
33102 };
33103 }
33104 /**
33105 * Turns an object whose values are action creators, into an object with the
33106 * same keys, but with every function wrapped into a `dispatch` call so they
33107 * may be invoked directly. This is just a convenience method, as you can call
33108 * `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
33109 *
33110 * For convenience, you can also pass an action creator as the first argument,
33111 * and get a dispatch wrapped function in return.
33112 *
33113 * @param {Function|Object} actionCreators An object whose values are action
33114 * creator functions. One handy way to obtain it is to use ES6 `import * as`
33115 * syntax. You may also pass a single function.
33116 *
33117 * @param {Function} dispatch The `dispatch` function available on your Redux
33118 * store.
33119 *
33120 * @returns {Function|Object} The object mimicking the original object, but with
33121 * every action creator wrapped into the `dispatch` call. If you passed a
33122 * function as `actionCreators`, the return value will also be a single
33123 * function.
33124 */
33125
33126
33127 function bindActionCreators(actionCreators, dispatch) {
33128 if (typeof actionCreators === 'function') {
33129 return bindActionCreator(actionCreators, dispatch);
33130 }
33131
33132 if (typeof actionCreators !== 'object' || actionCreators === null) {
33133 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\"?");
33134 }
33135
33136 var boundActionCreators = {};
33137
33138 for (var key in actionCreators) {
33139 var actionCreator = actionCreators[key];
33140
33141 if (typeof actionCreator === 'function') {
33142 boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
33143 }
33144 }
33145
33146 return boundActionCreators;
33147 }
33148
33149 /**
33150 * Composes single-argument functions from right to left. The rightmost
33151 * function can take multiple arguments as it provides the signature for
33152 * the resulting composite function.
33153 *
33154 * @param {...Function} funcs The functions to compose.
33155 * @returns {Function} A function obtained by composing the argument functions
33156 * from right to left. For example, compose(f, g, h) is identical to doing
33157 * (...args) => f(g(h(...args))).
33158 */
33159 function compose() {
33160 for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
33161 funcs[_key] = arguments[_key];
33162 }
33163
33164 if (funcs.length === 0) {
33165 return function (arg) {
33166 return arg;
33167 };
33168 }
33169
33170 if (funcs.length === 1) {
33171 return funcs[0];
33172 }
33173
33174 return funcs.reduce(function (a, b) {
33175 return function () {
33176 return a(b.apply(void 0, arguments));
33177 };
33178 });
33179 }
33180
33181 /**
33182 * Creates a store enhancer that applies middleware to the dispatch method
33183 * of the Redux store. This is handy for a variety of tasks, such as expressing
33184 * asynchronous actions in a concise manner, or logging every action payload.
33185 *
33186 * See `redux-thunk` package as an example of the Redux middleware.
33187 *
33188 * Because middleware is potentially asynchronous, this should be the first
33189 * store enhancer in the composition chain.
33190 *
33191 * Note that each middleware will be given the `dispatch` and `getState` functions
33192 * as named arguments.
33193 *
33194 * @param {...Function} middlewares The middleware chain to be applied.
33195 * @returns {Function} A store enhancer applying the middleware.
33196 */
33197
33198 function applyMiddleware() {
33199 for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
33200 middlewares[_key] = arguments[_key];
33201 }
33202
33203 return function (createStore) {
33204 return function () {
33205 var store = createStore.apply(void 0, arguments);
33206
33207 var _dispatch = function dispatch() {
33208 throw new Error( false ? 0 : 'Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.');
33209 };
33210
33211 var middlewareAPI = {
33212 getState: store.getState,
33213 dispatch: function dispatch() {
33214 return _dispatch.apply(void 0, arguments);
33215 }
33216 };
33217 var chain = middlewares.map(function (middleware) {
33218 return middleware(middlewareAPI);
33219 });
33220 _dispatch = compose.apply(void 0, chain)(store.dispatch);
33221 return (0,_babel_runtime_helpers_esm_objectSpread2__WEBPACK_IMPORTED_MODULE_0__["default"])((0,_babel_runtime_helpers_esm_objectSpread2__WEBPACK_IMPORTED_MODULE_0__["default"])({}, store), {}, {
33222 dispatch: _dispatch
33223 });
33224 };
33225 };
33226 }
33227
33228
33229
33230
33231 /***/ }),
33232
33233 /***/ "../node_modules/reselect/es/defaultMemoize.js":
33234 /*!*****************************************************!*\
33235 !*** ../node_modules/reselect/es/defaultMemoize.js ***!
33236 \*****************************************************/
33237 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
33238
33239 "use strict";
33240 __webpack_require__.r(__webpack_exports__);
33241 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
33242 /* harmony export */ createCacheKeyComparator: () => (/* binding */ createCacheKeyComparator),
33243 /* harmony export */ defaultEqualityCheck: () => (/* binding */ defaultEqualityCheck),
33244 /* harmony export */ defaultMemoize: () => (/* binding */ defaultMemoize)
33245 /* harmony export */ });
33246 // Cache implementation based on Erik Rasmussen's `lru-memoize`:
33247 // https://github.com/erikras/lru-memoize
33248 var NOT_FOUND = 'NOT_FOUND';
33249
33250 function createSingletonCache(equals) {
33251 var entry;
33252 return {
33253 get: function get(key) {
33254 if (entry && equals(entry.key, key)) {
33255 return entry.value;
33256 }
33257
33258 return NOT_FOUND;
33259 },
33260 put: function put(key, value) {
33261 entry = {
33262 key: key,
33263 value: value
33264 };
33265 },
33266 getEntries: function getEntries() {
33267 return entry ? [entry] : [];
33268 },
33269 clear: function clear() {
33270 entry = undefined;
33271 }
33272 };
33273 }
33274
33275 function createLruCache(maxSize, equals) {
33276 var entries = [];
33277
33278 function get(key) {
33279 var cacheIndex = entries.findIndex(function (entry) {
33280 return equals(key, entry.key);
33281 }); // We found a cached entry
33282
33283 if (cacheIndex > -1) {
33284 var entry = entries[cacheIndex]; // Cached entry not at top of cache, move it to the top
33285
33286 if (cacheIndex > 0) {
33287 entries.splice(cacheIndex, 1);
33288 entries.unshift(entry);
33289 }
33290
33291 return entry.value;
33292 } // No entry found in cache, return sentinel
33293
33294
33295 return NOT_FOUND;
33296 }
33297
33298 function put(key, value) {
33299 if (get(key) === NOT_FOUND) {
33300 // TODO Is unshift slow?
33301 entries.unshift({
33302 key: key,
33303 value: value
33304 });
33305
33306 if (entries.length > maxSize) {
33307 entries.pop();
33308 }
33309 }
33310 }
33311
33312 function getEntries() {
33313 return entries;
33314 }
33315
33316 function clear() {
33317 entries = [];
33318 }
33319
33320 return {
33321 get: get,
33322 put: put,
33323 getEntries: getEntries,
33324 clear: clear
33325 };
33326 }
33327
33328 var defaultEqualityCheck = function defaultEqualityCheck(a, b) {
33329 return a === b;
33330 };
33331 function createCacheKeyComparator(equalityCheck) {
33332 return function areArgumentsShallowlyEqual(prev, next) {
33333 if (prev === null || next === null || prev.length !== next.length) {
33334 return false;
33335 } // Do this in a for loop (and not a `forEach` or an `every`) so we can determine equality as fast as possible.
33336
33337
33338 var length = prev.length;
33339
33340 for (var i = 0; i < length; i++) {
33341 if (!equalityCheck(prev[i], next[i])) {
33342 return false;
33343 }
33344 }
33345
33346 return true;
33347 };
33348 }
33349 // defaultMemoize now supports a configurable cache size with LRU behavior,
33350 // and optional comparison of the result value with existing values
33351 function defaultMemoize(func, equalityCheckOrOptions) {
33352 var providedOptions = typeof equalityCheckOrOptions === 'object' ? equalityCheckOrOptions : {
33353 equalityCheck: equalityCheckOrOptions
33354 };
33355 var _providedOptions$equa = providedOptions.equalityCheck,
33356 equalityCheck = _providedOptions$equa === void 0 ? defaultEqualityCheck : _providedOptions$equa,
33357 _providedOptions$maxS = providedOptions.maxSize,
33358 maxSize = _providedOptions$maxS === void 0 ? 1 : _providedOptions$maxS,
33359 resultEqualityCheck = providedOptions.resultEqualityCheck;
33360 var comparator = createCacheKeyComparator(equalityCheck);
33361 var cache = maxSize === 1 ? createSingletonCache(comparator) : createLruCache(maxSize, comparator); // we reference arguments instead of spreading them for performance reasons
33362
33363 function memoized() {
33364 var value = cache.get(arguments);
33365
33366 if (value === NOT_FOUND) {
33367 // @ts-ignore
33368 value = func.apply(null, arguments);
33369
33370 if (resultEqualityCheck) {
33371 var entries = cache.getEntries();
33372 var matchingEntry = entries.find(function (entry) {
33373 return resultEqualityCheck(entry.value, value);
33374 });
33375
33376 if (matchingEntry) {
33377 value = matchingEntry.value;
33378 }
33379 }
33380
33381 cache.put(arguments, value);
33382 }
33383
33384 return value;
33385 }
33386
33387 memoized.clearCache = function () {
33388 return cache.clear();
33389 };
33390
33391 return memoized;
33392 }
33393
33394 /***/ }),
33395
33396 /***/ "../node_modules/reselect/es/index.js":
33397 /*!********************************************!*\
33398 !*** ../node_modules/reselect/es/index.js ***!
33399 \********************************************/
33400 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
33401
33402 "use strict";
33403 __webpack_require__.r(__webpack_exports__);
33404 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
33405 /* harmony export */ createSelector: () => (/* binding */ createSelector),
33406 /* harmony export */ createSelectorCreator: () => (/* binding */ createSelectorCreator),
33407 /* harmony export */ createStructuredSelector: () => (/* binding */ createStructuredSelector),
33408 /* harmony export */ defaultEqualityCheck: () => (/* reexport safe */ _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultEqualityCheck),
33409 /* harmony export */ defaultMemoize: () => (/* reexport safe */ _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultMemoize)
33410 /* harmony export */ });
33411 /* harmony import */ var _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultMemoize */ "../node_modules/reselect/es/defaultMemoize.js");
33412
33413
33414
33415 function getDependencies(funcs) {
33416 var dependencies = Array.isArray(funcs[0]) ? funcs[0] : funcs;
33417
33418 if (!dependencies.every(function (dep) {
33419 return typeof dep === 'function';
33420 })) {
33421 var dependencyTypes = dependencies.map(function (dep) {
33422 return typeof dep === 'function' ? "function " + (dep.name || 'unnamed') + "()" : typeof dep;
33423 }).join(', ');
33424 throw new Error("createSelector expects all input-selectors to be functions, but received the following types: [" + dependencyTypes + "]");
33425 }
33426
33427 return dependencies;
33428 }
33429
33430 function createSelectorCreator(memoize) {
33431 for (var _len = arguments.length, memoizeOptionsFromArgs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
33432 memoizeOptionsFromArgs[_key - 1] = arguments[_key];
33433 }
33434
33435 var createSelector = function createSelector() {
33436 for (var _len2 = arguments.length, funcs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
33437 funcs[_key2] = arguments[_key2];
33438 }
33439
33440 var _recomputations = 0;
33441
33442 var _lastResult; // Due to the intricacies of rest params, we can't do an optional arg after `...funcs`.
33443 // So, start by declaring the default value here.
33444 // (And yes, the words 'memoize' and 'options' appear too many times in this next sequence.)
33445
33446
33447 var directlyPassedOptions = {
33448 memoizeOptions: undefined
33449 }; // Normally, the result func or "output selector" is the last arg
33450
33451 var resultFunc = funcs.pop(); // If the result func is actually an _object_, assume it's our options object
33452
33453 if (typeof resultFunc === 'object') {
33454 directlyPassedOptions = resultFunc; // and pop the real result func off
33455
33456 resultFunc = funcs.pop();
33457 }
33458
33459 if (typeof resultFunc !== 'function') {
33460 throw new Error("createSelector expects an output function after the inputs, but received: [" + typeof resultFunc + "]");
33461 } // Determine which set of options we're using. Prefer options passed directly,
33462 // but fall back to options given to createSelectorCreator.
33463
33464
33465 var _directlyPassedOption = directlyPassedOptions,
33466 _directlyPassedOption2 = _directlyPassedOption.memoizeOptions,
33467 memoizeOptions = _directlyPassedOption2 === void 0 ? memoizeOptionsFromArgs : _directlyPassedOption2; // Simplifying assumption: it's unlikely that the first options arg of the provided memoizer
33468 // is an array. In most libs I've looked at, it's an equality function or options object.
33469 // Based on that, if `memoizeOptions` _is_ an array, we assume it's a full
33470 // user-provided array of options. Otherwise, it must be just the _first_ arg, and so
33471 // we wrap it in an array so we can apply it.
33472
33473 var finalMemoizeOptions = Array.isArray(memoizeOptions) ? memoizeOptions : [memoizeOptions];
33474 var dependencies = getDependencies(funcs);
33475 var memoizedResultFunc = memoize.apply(void 0, [function recomputationWrapper() {
33476 _recomputations++; // apply arguments instead of spreading for performance.
33477
33478 return resultFunc.apply(null, arguments);
33479 }].concat(finalMemoizeOptions)); // If a selector is called with the exact same arguments we don't need to traverse our dependencies again.
33480
33481 var selector = memoize(function dependenciesChecker() {
33482 var params = [];
33483 var length = dependencies.length;
33484
33485 for (var i = 0; i < length; i++) {
33486 // apply arguments instead of spreading and mutate a local list of params for performance.
33487 // @ts-ignore
33488 params.push(dependencies[i].apply(null, arguments));
33489 } // apply arguments instead of spreading for performance.
33490
33491
33492 _lastResult = memoizedResultFunc.apply(null, params);
33493 return _lastResult;
33494 });
33495 Object.assign(selector, {
33496 resultFunc: resultFunc,
33497 memoizedResultFunc: memoizedResultFunc,
33498 dependencies: dependencies,
33499 lastResult: function lastResult() {
33500 return _lastResult;
33501 },
33502 recomputations: function recomputations() {
33503 return _recomputations;
33504 },
33505 resetRecomputations: function resetRecomputations() {
33506 return _recomputations = 0;
33507 }
33508 });
33509 return selector;
33510 }; // @ts-ignore
33511
33512
33513 return createSelector;
33514 }
33515 var createSelector = /* #__PURE__ */createSelectorCreator(_defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultMemoize);
33516 // Manual definition of state and output arguments
33517 var createStructuredSelector = function createStructuredSelector(selectors, selectorCreator) {
33518 if (selectorCreator === void 0) {
33519 selectorCreator = createSelector;
33520 }
33521
33522 if (typeof selectors !== 'object') {
33523 throw new Error('createStructuredSelector expects first argument to be an object ' + ("where each property is a selector, instead received a " + typeof selectors));
33524 }
33525
33526 var objectKeys = Object.keys(selectors);
33527 var resultSelector = selectorCreator( // @ts-ignore
33528 objectKeys.map(function (key) {
33529 return selectors[key];
33530 }), function () {
33531 for (var _len3 = arguments.length, values = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
33532 values[_key3] = arguments[_key3];
33533 }
33534
33535 return values.reduce(function (composition, value, index) {
33536 composition[objectKeys[index]] = value;
33537 return composition;
33538 }, {});
33539 });
33540 return resultSelector;
33541 };
33542
33543 /***/ }),
33544
33545 /***/ "@wordpress/i18n":
33546 /*!**************************!*\
33547 !*** external "wp.i18n" ***!
33548 \**************************/
33549 /***/ ((module) => {
33550
33551 "use strict";
33552 module.exports = wp.i18n;
33553
33554 /***/ })
33555
33556 /******/ });
33557 /************************************************************************/
33558 /******/ // The module cache
33559 /******/ var __webpack_module_cache__ = {};
33560 /******/
33561 /******/ // The require function
33562 /******/ function __webpack_require__(moduleId) {
33563 /******/ // Check if module is in cache
33564 /******/ var cachedModule = __webpack_module_cache__[moduleId];
33565 /******/ if (cachedModule !== undefined) {
33566 /******/ return cachedModule.exports;
33567 /******/ }
33568 /******/ // Create a new module (and put it into the cache)
33569 /******/ var module = __webpack_module_cache__[moduleId] = {
33570 /******/ // no module.id needed
33571 /******/ // no module.loaded needed
33572 /******/ exports: {}
33573 /******/ };
33574 /******/
33575 /******/ // Execute the module function
33576 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
33577 /******/
33578 /******/ // Return the exports of the module
33579 /******/ return module.exports;
33580 /******/ }
33581 /******/
33582 /************************************************************************/
33583 /******/ /* webpack/runtime/define property getters */
33584 /******/ (() => {
33585 /******/ // define getter functions for harmony exports
33586 /******/ __webpack_require__.d = (exports, definition) => {
33587 /******/ for(var key in definition) {
33588 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
33589 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
33590 /******/ }
33591 /******/ }
33592 /******/ };
33593 /******/ })();
33594 /******/
33595 /******/ /* webpack/runtime/global */
33596 /******/ (() => {
33597 /******/ __webpack_require__.g = (function() {
33598 /******/ if (typeof globalThis === 'object') return globalThis;
33599 /******/ try {
33600 /******/ return this || new Function('return this')();
33601 /******/ } catch (e) {
33602 /******/ if (typeof window === 'object') return window;
33603 /******/ }
33604 /******/ })();
33605 /******/ })();
33606 /******/
33607 /******/ /* webpack/runtime/hasOwnProperty shorthand */
33608 /******/ (() => {
33609 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
33610 /******/ })();
33611 /******/
33612 /******/ /* webpack/runtime/make namespace object */
33613 /******/ (() => {
33614 /******/ // define __esModule on exports
33615 /******/ __webpack_require__.r = (exports) => {
33616 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
33617 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
33618 /******/ }
33619 /******/ Object.defineProperty(exports, '__esModule', { value: true });
33620 /******/ };
33621 /******/ })();
33622 /******/
33623 /************************************************************************/
33624 var __webpack_exports__ = {};
33625 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
33626 (() => {
33627 "use strict";
33628 /*!******************************************!*\
33629 !*** ../core/common/assets/js/common.js ***!
33630 \******************************************/
33631
33632
33633 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
33634 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
33635 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
33636 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
33637 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
33638 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
33639 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
33640 var _helpers = _interopRequireDefault(__webpack_require__(/*! ./utils/helpers */ "../core/common/assets/js/utils/helpers.js"));
33641 var _storage = _interopRequireDefault(__webpack_require__(/*! ./utils/storage */ "../core/common/assets/js/utils/storage.js"));
33642 var _debug = _interopRequireDefault(__webpack_require__(/*! ./utils/debug */ "../core/common/assets/js/utils/debug.js"));
33643 var _ajax = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/ajax/assets/js/ajax */ "../core/common/modules/ajax/assets/js/ajax.js"));
33644 var _finder = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/finder/assets/js/finder */ "../core/common/modules/finder/assets/js/finder.js"));
33645 var _connect = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/connect/assets/js/connect */ "../core/common/modules/connect/assets/js/connect.js"));
33646 var _component = _interopRequireDefault(__webpack_require__(/*! ./components/wordpress/component */ "../core/common/assets/js/components/wordpress/component.js"));
33647 var _component2 = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/event-tracker/assets/js/data/component */ "../core/common/modules/event-tracker/assets/js/data/component.js"));
33648 var _events = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/event-tracker/assets/js/events */ "../core/common/modules/event-tracker/assets/js/events.js"));
33649 var _module = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/events-manager/assets/js/module */ "../core/common/modules/events-manager/assets/js/module.js"));
33650 var _notifications = _interopRequireDefault(__webpack_require__(/*! elementor-utils/notifications */ "../assets/dev/js/utils/notifications.js"));
33651 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)); }
33652 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
33653 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; }
33654 var ElementorCommonApp = /*#__PURE__*/function (_elementorModules$Vie) {
33655 function ElementorCommonApp() {
33656 (0, _classCallCheck2.default)(this, ElementorCommonApp);
33657 return _callSuper(this, ElementorCommonApp, arguments);
33658 }
33659 (0, _inherits2.default)(ElementorCommonApp, _elementorModules$Vie);
33660 return (0, _createClass2.default)(ElementorCommonApp, [{
33661 key: "setMarionetteTemplateCompiler",
33662 value: function setMarionetteTemplateCompiler() {
33663 Marionette.TemplateCache.prototype.compileTemplate = function (rawTemplate, options) {
33664 options = {
33665 evaluate: /<#([\s\S]+?)#>/g,
33666 interpolate: /{{{([\s\S]+?)}}}/g,
33667 escape: /{{([^}]+?)}}(?!})/g
33668 };
33669 return _.template(rawTemplate, options);
33670 };
33671 }
33672 }, {
33673 key: "getDefaultElements",
33674 value: function getDefaultElements() {
33675 return {
33676 $window: jQuery(window),
33677 $document: jQuery(document),
33678 $body: jQuery(document.body)
33679 };
33680 }
33681 }, {
33682 key: "initComponents",
33683 value: function initComponents() {
33684 this.events = new _events.default();
33685 this.eventsManager = new _module.default();
33686 this.debug = new _debug.default();
33687 this.helpers = new _helpers.default();
33688 this.storage = new _storage.default();
33689 this.dialogsManager = new DialogsManager.Instance();
33690 this.notifications = new _notifications.default();
33691 this.api = window.$e;
33692 $e.components.register(new _component2.default());
33693 elementorCommon.elements.$window.on('elementor:init-components', function () {
33694 $e.components.register(new _component.default());
33695 });
33696 this.initModules();
33697 }
33698 }, {
33699 key: "initModules",
33700 value: function initModules() {
33701 var _this = this;
33702 var activeModules = this.config.activeModules;
33703 var modules = {
33704 ajax: _ajax.default,
33705 finder: _finder.default,
33706 connect: _connect.default
33707 };
33708 activeModules.forEach(function (name) {
33709 if (modules[name]) {
33710 _this[name] = new modules[name](_this.config[name]);
33711 }
33712 });
33713 }
33714 }, {
33715 key: "compileArrayTemplateArgs",
33716 value: function compileArrayTemplateArgs(template, templateArgs) {
33717 return template.replace(/%(?:(\d+)\$)?s/g, function (match, number) {
33718 if (!number) {
33719 number = 1;
33720 }
33721 number--;
33722 return undefined !== templateArgs[number] ? templateArgs[number] : match;
33723 });
33724 }
33725 }, {
33726 key: "compileObjectTemplateArgs",
33727 value: function compileObjectTemplateArgs(template, templateArgs) {
33728 return template.replace(/{{(?:([ \w]+))}}/g, function (match, name) {
33729 return templateArgs[name] ? templateArgs[name] : match;
33730 });
33731 }
33732 }, {
33733 key: "compileTemplate",
33734 value: function compileTemplate(template, templateArgs) {
33735 return jQuery.isPlainObject(templateArgs) ? this.compileObjectTemplateArgs(template, templateArgs) : this.compileArrayTemplateArgs(template, templateArgs);
33736 }
33737 }, {
33738 key: "translate",
33739 value: function translate(stringKey, context, templateArgs, i18nStack) {
33740 if (context) {
33741 i18nStack = this.config[context].i18n;
33742 }
33743 if (!i18nStack) {
33744 i18nStack = this.config.i18n;
33745 }
33746 var string = i18nStack[stringKey];
33747 if (undefined === string) {
33748 string = stringKey;
33749 }
33750 if (templateArgs) {
33751 string = this.compileTemplate(string, templateArgs);
33752 }
33753 return string;
33754 }
33755 }, {
33756 key: "onInit",
33757 value: function onInit() {
33758 _superPropGet(ElementorCommonApp, "onInit", this, 3)([]);
33759 this.config = elementorCommonConfig;
33760 this.setMarionetteTemplateCompiler();
33761 }
33762 }]);
33763 }(elementorModules.ViewModule);
33764 window.elementorCommon = new ElementorCommonApp();
33765 elementorCommon.initComponents();
33766 })();
33767
33768 /******/ })()
33769 ;
33770 //# sourceMappingURL=common.js.map