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

33,701 lines 1.3 MB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (() => { // webpackBootstrap
2 /******/ var __webpack_modules__ = ({
3
4 /***/ "../assets/dev/js/editor/utils/editor-one-events.js":
5 /*!**********************************************************!*\
6 !*** ../assets/dev/js/editor/utils/editor-one-events.js ***!
7 \**********************************************************/
8 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
9
10 "use strict";
11
12
13 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
14 Object.defineProperty(exports, "__esModule", ({
15 value: true
16 }));
17 exports["default"] = exports.createDebouncedWidgetPanelSearch = exports.createDebouncedFinderSearch = exports.EditorOneEventManager = void 0;
18 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
19 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
20 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
21 function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
22 function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
23 var EditorOneEventManager = exports.EditorOneEventManager = /*#__PURE__*/function () {
24 function EditorOneEventManager() {
25 (0, _classCallCheck2.default)(this, EditorOneEventManager);
26 }
27 return (0, _createClass2.default)(EditorOneEventManager, null, [{
28 key: "getEventsManager",
29 value: function getEventsManager() {
30 var _elementorCommon;
31 return (_elementorCommon = elementorCommon) === null || _elementorCommon === void 0 ? void 0 : _elementorCommon.eventsManager;
32 }
33 }, {
34 key: "getConfig",
35 value: function getConfig() {
36 var _this$getEventsManage;
37 return (_this$getEventsManage = this.getEventsManager()) === null || _this$getEventsManage === void 0 ? void 0 : _this$getEventsManage.config;
38 }
39 }, {
40 key: "canSendEvents",
41 value: function canSendEvents() {
42 var _elementorCommon2;
43 return ((_elementorCommon2 = elementorCommon) === null || _elementorCommon2 === void 0 || (_elementorCommon2 = _elementorCommon2.config) === null || _elementorCommon2 === void 0 || (_elementorCommon2 = _elementorCommon2.editor_events) === null || _elementorCommon2 === void 0 ? void 0 : _elementorCommon2.can_send_events) || false;
44 }
45 }, {
46 key: "isEventsManagerAvailable",
47 value: function isEventsManagerAvailable() {
48 var eventsManager = this.getEventsManager();
49 return eventsManager && 'function' === typeof eventsManager.dispatchEvent;
50 }
51 }, {
52 key: "dispatchEvent",
53 value: function dispatchEvent(eventName, payload) {
54 if (!this.isEventsManagerAvailable() || !this.canSendEvents()) {
55 return false;
56 }
57 try {
58 return this.getEventsManager().dispatchEvent(eventName, payload);
59 } catch (error) {
60 return false;
61 }
62 }
63 }, {
64 key: "toLowerSnake",
65 value: function toLowerSnake(value) {
66 if (!value || 'string' !== typeof value) {
67 return value;
68 }
69 return value.replace(/\s+/g, '_').toLowerCase();
70 }
71 }, {
72 key: "decodeHtmlEntities",
73 value: function decodeHtmlEntities(text) {
74 if (!text || 'string' !== typeof text) {
75 return text;
76 }
77 var doc = new DOMParser().parseFromString(text, 'text/html');
78 return doc.body.textContent || text;
79 }
80 }, {
81 key: "isInEditorContext",
82 value: function isInEditorContext() {
83 var _window$elementor;
84 return 'undefined' !== typeof window.elementor && !!((_window$elementor = window.elementor) !== null && _window$elementor !== void 0 && _window$elementor.documents);
85 }
86 }, {
87 key: "getFinderContext",
88 value: function getFinderContext() {
89 var _config$appTypes, _config$appTypes2, _config$locations, _config$locations2;
90 var config = this.getConfig();
91 var isEditor = this.isInEditorContext();
92 return {
93 windowName: isEditor ? config === null || config === void 0 || (_config$appTypes = config.appTypes) === null || _config$appTypes === void 0 ? void 0 : _config$appTypes.editor : config === null || config === void 0 || (_config$appTypes2 = config.appTypes) === null || _config$appTypes2 === void 0 ? void 0 : _config$appTypes2.wpAdmin,
94 targetLocation: this.toLowerSnake(isEditor ? config === null || config === void 0 || (_config$locations = config.locations) === null || _config$locations === void 0 ? void 0 : _config$locations.topBar : config === null || config === void 0 || (_config$locations2 = config.locations) === null || _config$locations2 === void 0 ? void 0 : _config$locations2.sidebar)
95 };
96 }
97 }, {
98 key: "createBasePayload",
99 value: function createBasePayload() {
100 var _config$appTypes$edit, _config$appTypes3, _config$appTypes$edit2, _config$appTypes4;
101 var overrides = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
102 var config = this.getConfig();
103 return _objectSpread({
104 app_type: (_config$appTypes$edit = config === null || config === void 0 || (_config$appTypes3 = config.appTypes) === null || _config$appTypes3 === void 0 ? void 0 : _config$appTypes3.editor) !== null && _config$appTypes$edit !== void 0 ? _config$appTypes$edit : 'editor',
105 window_name: (_config$appTypes$edit2 = config === null || config === void 0 || (_config$appTypes4 = config.appTypes) === null || _config$appTypes4 === void 0 ? void 0 : _config$appTypes4.editor) !== null && _config$appTypes$edit2 !== void 0 ? _config$appTypes$edit2 : 'editor'
106 }, overrides);
107 }
108 }, {
109 key: "sendTopBarPublishDropdown",
110 value: function sendTopBarPublishDropdown(targetName) {
111 var _config$names, _config$triggers, _config$targetTypes, _config$interactionRe, _config$locations3, _config$secondaryLoca, _config$targetTypes2;
112 var config = this.getConfig();
113 return this.dispatchEvent(config === null || config === void 0 || (_config$names = config.names) === null || _config$names === void 0 || (_config$names = _config$names.editorOne) === null || _config$names === void 0 ? void 0 : _config$names.topBarPublishDropdown, this.createBasePayload({
114 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers = config.triggers) === null || _config$triggers === void 0 ? void 0 : _config$triggers.click),
115 target_type: config === null || config === void 0 || (_config$targetTypes = config.targetTypes) === null || _config$targetTypes === void 0 ? void 0 : _config$targetTypes.dropdownItem,
116 target_name: targetName,
117 interaction_result: config === null || config === void 0 || (_config$interactionRe = config.interactionResults) === null || _config$interactionRe === void 0 ? void 0 : _config$interactionRe.actionSelected,
118 target_location: this.toLowerSnake(config === null || config === void 0 || (_config$locations3 = config.locations) === null || _config$locations3 === void 0 ? void 0 : _config$locations3.topBar),
119 location_l1: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca = config.secondaryLocations) === null || _config$secondaryLoca === void 0 ? void 0 : _config$secondaryLoca.publishDropdown),
120 location_l2: config === null || config === void 0 || (_config$targetTypes2 = config.targetTypes) === null || _config$targetTypes2 === void 0 ? void 0 : _config$targetTypes2.dropdownItem,
121 interaction_description: 'User selected an action from the publish dropdown'
122 }));
123 }
124 }, {
125 key: "sendTopBarPageList",
126 value: function sendTopBarPageList(targetName) {
127 var _config$names2, _config$triggers2, _config$targetTypes3, _config$interactionRe2, _config$interactionRe3, _config$locations4, _config$secondaryLoca2, _config$targetTypes4;
128 var isCreate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
129 var config = this.getConfig();
130 return this.dispatchEvent(config === null || config === void 0 || (_config$names2 = config.names) === null || _config$names2 === void 0 || (_config$names2 = _config$names2.editorOne) === null || _config$names2 === void 0 ? void 0 : _config$names2.topBarPageList, this.createBasePayload({
131 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers2 = config.triggers) === null || _config$triggers2 === void 0 ? void 0 : _config$triggers2.click),
132 target_type: config === null || config === void 0 || (_config$targetTypes3 = config.targetTypes) === null || _config$targetTypes3 === void 0 ? void 0 : _config$targetTypes3.dropdownItem,
133 target_name: targetName,
134 interaction_result: isCreate ? config === null || config === void 0 || (_config$interactionRe2 = config.interactionResults) === null || _config$interactionRe2 === void 0 ? void 0 : _config$interactionRe2.create : config === null || config === void 0 || (_config$interactionRe3 = config.interactionResults) === null || _config$interactionRe3 === void 0 ? void 0 : _config$interactionRe3.navigate,
135 target_location: this.toLowerSnake(config === null || config === void 0 || (_config$locations4 = config.locations) === null || _config$locations4 === void 0 ? void 0 : _config$locations4.topBar),
136 location_l1: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca2 = config.secondaryLocations) === null || _config$secondaryLoca2 === void 0 ? void 0 : _config$secondaryLoca2.pageListDropdown),
137 location_l2: config === null || config === void 0 || (_config$targetTypes4 = config.targetTypes) === null || _config$targetTypes4 === void 0 ? void 0 : _config$targetTypes4.dropdownItem,
138 interaction_description: 'User selected an action from the page list dropdown'
139 }));
140 }
141 }, {
142 key: "sendSiteSettingsSession",
143 value: function sendSiteSettingsSession(_ref) {
144 var _config$names3, _config$triggers3, _config$interactionRe4, _config$locations5, _config$secondaryLoca3;
145 var targetType = _ref.targetType,
146 _ref$visitedItems = _ref.visitedItems,
147 visitedItems = _ref$visitedItems === void 0 ? [] : _ref$visitedItems,
148 _ref$savedItems = _ref.savedItems,
149 savedItems = _ref$savedItems === void 0 ? [] : _ref$savedItems,
150 state = _ref.state;
151 var config = this.getConfig();
152 return this.dispatchEvent(config === null || config === void 0 || (_config$names3 = config.names) === null || _config$names3 === void 0 || (_config$names3 = _config$names3.editorOne) === null || _config$names3 === void 0 ? void 0 : _config$names3.siteSettingsSession, this.createBasePayload({
153 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers3 = config.triggers) === null || _config$triggers3 === void 0 ? void 0 : _config$triggers3.click),
154 target_type: targetType,
155 target_name: 'site_settings',
156 interaction_result: config === null || config === void 0 || (_config$interactionRe4 = config.interactionResults) === null || _config$interactionRe4 === void 0 ? void 0 : _config$interactionRe4.sessionEnd,
157 target_location: this.toLowerSnake(config === null || config === void 0 || (_config$locations5 = config.locations) === null || _config$locations5 === void 0 ? void 0 : _config$locations5.leftPanel),
158 location_l1: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca3 = config.secondaryLocations) === null || _config$secondaryLoca3 === void 0 ? void 0 : _config$secondaryLoca3.siteSettings),
159 interaction_description: 'Records areas visited as part of the site setting session',
160 metadata: {
161 visited_items: visitedItems,
162 saved_items: savedItems
163 },
164 state: state
165 }));
166 }
167 }, {
168 key: "sendELibraryNav",
169 value: function sendELibraryNav(tabName) {
170 var _config$names4, _config$triggers4, _config$targetTypes5, _config$interactionRe5, _config$locations6, _config$secondaryLoca4;
171 var config = this.getConfig();
172 return this.dispatchEvent(config === null || config === void 0 || (_config$names4 = config.names) === null || _config$names4 === void 0 || (_config$names4 = _config$names4.editorOne) === null || _config$names4 === void 0 ? void 0 : _config$names4.eLibraryNav, this.createBasePayload({
173 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers4 = config.triggers) === null || _config$triggers4 === void 0 ? void 0 : _config$triggers4.tabSelect),
174 target_type: config === null || config === void 0 || (_config$targetTypes5 = config.targetTypes) === null || _config$targetTypes5 === void 0 ? void 0 : _config$targetTypes5.tab,
175 target_name: this.toLowerSnake(tabName),
176 interaction_result: config === null || config === void 0 || (_config$interactionRe5 = config.interactionResults) === null || _config$interactionRe5 === void 0 ? void 0 : _config$interactionRe5.tabChanged,
177 target_location: this.toLowerSnake(config === null || config === void 0 || (_config$locations6 = config.locations) === null || _config$locations6 === void 0 ? void 0 : _config$locations6.elementorLibrary),
178 location_l1: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca4 = config.secondaryLocations) === null || _config$secondaryLoca4 === void 0 ? void 0 : _config$secondaryLoca4.libraryTabs),
179 interaction_description: 'User navigates within elementor library'
180 }));
181 }
182 }, {
183 key: "sendELibraryInsert",
184 value: function sendELibraryInsert(_ref2) {
185 var _config$triggers5, _config$targetTypes6, _config$interactionRe6, _config$locations7, _config$secondaryLoca5, _config$names5;
186 var assetId = _ref2.assetId,
187 assetName = _ref2.assetName,
188 libraryType = _ref2.libraryType,
189 _ref2$proRequired = _ref2.proRequired,
190 proRequired = _ref2$proRequired === void 0 ? false : _ref2$proRequired;
191 var config = this.getConfig();
192 var payload = this.createBasePayload({
193 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers5 = config.triggers) === null || _config$triggers5 === void 0 ? void 0 : _config$triggers5.insert),
194 target_type: config === null || config === void 0 || (_config$targetTypes6 = config.targetTypes) === null || _config$targetTypes6 === void 0 ? void 0 : _config$targetTypes6.button,
195 target_name: String(assetId),
196 interaction_result: config === null || config === void 0 || (_config$interactionRe6 = config.interactionResults) === null || _config$interactionRe6 === void 0 ? void 0 : _config$interactionRe6.assetInserted,
197 target_location: this.toLowerSnake(config === null || config === void 0 || (_config$locations7 = config.locations) === null || _config$locations7 === void 0 ? void 0 : _config$locations7.elementorLibrary),
198 location_l1: this.toLowerSnake(libraryType),
199 location_l2: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca5 = config.secondaryLocations) === null || _config$secondaryLoca5 === void 0 ? void 0 : _config$secondaryLoca5.assetCard),
200 interaction_description: 'User inserts block/pages from elementor library',
201 metadata: {
202 template_id: String(assetId),
203 template_name: this.decodeHtmlEntities(assetName) || ''
204 }
205 });
206 if (proRequired) {
207 payload.state = 'pro_plan_required';
208 }
209 return this.dispatchEvent(config === null || config === void 0 || (_config$names5 = config.names) === null || _config$names5 === void 0 || (_config$names5 = _config$names5.editorOne) === null || _config$names5 === void 0 ? void 0 : _config$names5.eLibraryInsert, payload);
210 }
211 }, {
212 key: "sendELibraryFavorite",
213 value: function sendELibraryFavorite(_ref3) {
214 var _config$triggers6, _config$targetTypes7, _config$interactionRe7, _config$locations8, _config$secondaryLoca6, _config$names6;
215 var assetId = _ref3.assetId,
216 assetName = _ref3.assetName,
217 libraryType = _ref3.libraryType,
218 isFavorite = _ref3.isFavorite,
219 _ref3$proRequired = _ref3.proRequired,
220 proRequired = _ref3$proRequired === void 0 ? false : _ref3$proRequired;
221 var config = this.getConfig();
222 var payload = this.createBasePayload({
223 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers6 = config.triggers) === null || _config$triggers6 === void 0 ? void 0 : _config$triggers6.click),
224 target_type: config === null || config === void 0 || (_config$targetTypes7 = config.targetTypes) === null || _config$targetTypes7 === void 0 ? void 0 : _config$targetTypes7.toggle,
225 target_name: String(assetId),
226 interaction_result: config === null || config === void 0 || (_config$interactionRe7 = config.interactionResults) === null || _config$interactionRe7 === void 0 ? void 0 : _config$interactionRe7.assetFavorite,
227 target_value: Boolean(isFavorite),
228 target_location: this.toLowerSnake(config === null || config === void 0 || (_config$locations8 = config.locations) === null || _config$locations8 === void 0 ? void 0 : _config$locations8.elementorLibrary),
229 location_l1: this.toLowerSnake(libraryType),
230 location_l2: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca6 = config.secondaryLocations) === null || _config$secondaryLoca6 === void 0 ? void 0 : _config$secondaryLoca6.assetCard),
231 interaction_description: 'User favorite block/pages from elementor library',
232 metadata: {
233 template_id: String(assetId),
234 template_name: this.decodeHtmlEntities(assetName) || ''
235 }
236 });
237 if (proRequired) {
238 payload.state = 'pro_plan_required';
239 }
240 return this.dispatchEvent(config === null || config === void 0 || (_config$names6 = config.names) === null || _config$names6 === void 0 || (_config$names6 = _config$names6.editorOne) === null || _config$names6 === void 0 ? void 0 : _config$names6.eLibraryFavorite, payload);
241 }
242 }, {
243 key: "sendELibraryGenerateAi",
244 value: function sendELibraryGenerateAi(_ref4) {
245 var _config$names7, _config$triggers7, _config$targetTypes8, _config$interactionRe8, _config$locations9, _config$secondaryLoca7;
246 var assetId = _ref4.assetId,
247 assetName = _ref4.assetName,
248 libraryType = _ref4.libraryType;
249 var config = this.getConfig();
250 return this.dispatchEvent(config === null || config === void 0 || (_config$names7 = config.names) === null || _config$names7 === void 0 || (_config$names7 = _config$names7.editorOne) === null || _config$names7 === void 0 ? void 0 : _config$names7.eLibraryGenerateAi, this.createBasePayload({
251 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers7 = config.triggers) === null || _config$triggers7 === void 0 ? void 0 : _config$triggers7.click),
252 target_type: config === null || config === void 0 || (_config$targetTypes8 = config.targetTypes) === null || _config$targetTypes8 === void 0 ? void 0 : _config$targetTypes8.button,
253 target_name: String(assetId),
254 interaction_result: config === null || config === void 0 || (_config$interactionRe8 = config.interactionResults) === null || _config$interactionRe8 === void 0 ? void 0 : _config$interactionRe8.aiGenerate,
255 target_location: this.toLowerSnake(config === null || config === void 0 || (_config$locations9 = config.locations) === null || _config$locations9 === void 0 ? void 0 : _config$locations9.elementorLibrary),
256 location_l1: this.toLowerSnake(libraryType),
257 location_l2: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca7 = config.secondaryLocations) === null || _config$secondaryLoca7 === void 0 ? void 0 : _config$secondaryLoca7.assetCard),
258 interaction_description: 'User generated block/page based on a library asset',
259 metadata: {
260 template_id: String(assetId),
261 template_name: this.decodeHtmlEntities(assetName) || ''
262 }
263 }));
264 }
265 }, {
266 key: "sendFinderSearchInput",
267 value: function sendFinderSearchInput(_ref5) {
268 var _config$triggers8, _config$targetTypes9, _config$interactionRe9, _config$interactionRe0, _config$secondaryLoca8, _config$names8;
269 var resultsCount = _ref5.resultsCount,
270 _ref5$searchTerm = _ref5.searchTerm,
271 searchTerm = _ref5$searchTerm === void 0 ? null : _ref5$searchTerm;
272 var config = this.getConfig();
273 var hasResults = resultsCount > 0;
274 var finderContext = this.getFinderContext();
275 var payload = this.createBasePayload({
276 window_name: finderContext.windowName,
277 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers8 = config.triggers) === null || _config$triggers8 === void 0 ? void 0 : _config$triggers8.typing),
278 target_type: config === null || config === void 0 || (_config$targetTypes9 = config.targetTypes) === null || _config$targetTypes9 === void 0 ? void 0 : _config$targetTypes9.searchInput,
279 target_name: 'finder',
280 interaction_result: hasResults ? config === null || config === void 0 || (_config$interactionRe9 = config.interactionResults) === null || _config$interactionRe9 === void 0 ? void 0 : _config$interactionRe9.resultsUpdated : config === null || config === void 0 || (_config$interactionRe0 = config.interactionResults) === null || _config$interactionRe0 === void 0 ? void 0 : _config$interactionRe0.noResults,
281 target_location: finderContext.targetLocation,
282 location_l1: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca8 = config.secondaryLocations) === null || _config$secondaryLoca8 === void 0 ? void 0 : _config$secondaryLoca8.finder),
283 interaction_description: 'Finder search input, follows debounce behavior',
284 metadata: {
285 results_count: resultsCount
286 }
287 });
288 if (!hasResults && searchTerm) {
289 payload.metadata.search_term = searchTerm;
290 }
291 return this.dispatchEvent(config === null || config === void 0 || (_config$names8 = config.names) === null || _config$names8 === void 0 || (_config$names8 = _config$names8.editorOne) === null || _config$names8 === void 0 ? void 0 : _config$names8.finderSearchInput, payload);
292 }
293 }, {
294 key: "sendFinderResultSelect",
295 value: function sendFinderResultSelect(choice) {
296 var _config$names9, _config$triggers9, _config$targetTypes0, _config$interactionRe1, _config$secondaryLoca9, _config$secondaryLoca0;
297 var config = this.getConfig();
298 var finderContext = this.getFinderContext();
299 return this.dispatchEvent(config === null || config === void 0 || (_config$names9 = config.names) === null || _config$names9 === void 0 || (_config$names9 = _config$names9.editorOne) === null || _config$names9 === void 0 ? void 0 : _config$names9.finderResultSelect, this.createBasePayload({
300 window_name: finderContext.windowName,
301 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers9 = config.triggers) === null || _config$triggers9 === void 0 ? void 0 : _config$triggers9.click),
302 target_type: config === null || config === void 0 || (_config$targetTypes0 = config.targetTypes) === null || _config$targetTypes0 === void 0 ? void 0 : _config$targetTypes0.searchResult,
303 target_name: choice,
304 interaction_result: config === null || config === void 0 || (_config$interactionRe1 = config.interactionResults) === null || _config$interactionRe1 === void 0 ? void 0 : _config$interactionRe1.selected,
305 target_location: finderContext.targetLocation,
306 location_l1: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca9 = config.secondaryLocations) === null || _config$secondaryLoca9 === void 0 ? void 0 : _config$secondaryLoca9.finder),
307 location_l2: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca0 = config.secondaryLocations) === null || _config$secondaryLoca0 === void 0 ? void 0 : _config$secondaryLoca0.finderResults),
308 interaction_description: 'Finder search results was selected'
309 }));
310 }
311 }, {
312 key: "sendCanvasEmptyBoxAction",
313 value: function sendCanvasEmptyBoxAction(_ref6) {
314 var _config$triggers0, _config$targetTypes1, _config$interactionRe10, _config$locations0, _config$secondaryLoca1, _config$names0;
315 var targetName = _ref6.targetName,
316 _ref6$metadata = _ref6.metadata,
317 metadata = _ref6$metadata === void 0 ? {} : _ref6$metadata,
318 _ref6$containerCreate = _ref6.containerCreated,
319 containerCreated = _ref6$containerCreate === void 0 ? null : _ref6$containerCreate;
320 var config = this.getConfig();
321 var payload = this.createBasePayload({
322 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers0 = config.triggers) === null || _config$triggers0 === void 0 ? void 0 : _config$triggers0.click),
323 target_type: config === null || config === void 0 || (_config$targetTypes1 = config.targetTypes) === null || _config$targetTypes1 === void 0 ? void 0 : _config$targetTypes1.buttons,
324 target_name: targetName,
325 interaction_result: config === null || config === void 0 || (_config$interactionRe10 = config.interactionResults) === null || _config$interactionRe10 === void 0 ? void 0 : _config$interactionRe10.selected,
326 target_location: this.toLowerSnake(config === null || config === void 0 || (_config$locations0 = config.locations) === null || _config$locations0 === void 0 ? void 0 : _config$locations0.canvas),
327 location_l1: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca1 = config.secondaryLocations) === null || _config$secondaryLoca1 === void 0 ? void 0 : _config$secondaryLoca1.emptyBox),
328 interaction_description: 'Empty box on canvas actions'
329 });
330 if (Object.keys(metadata).length > 0) {
331 payload.metadata = metadata;
332 }
333 if (containerCreated !== null) {
334 payload.state = containerCreated;
335 }
336 return this.dispatchEvent(config === null || config === void 0 || (_config$names0 = config.names) === null || _config$names0 === void 0 || (_config$names0 = _config$names0.editorOne) === null || _config$names0 === void 0 ? void 0 : _config$names0.canvasEmptyBoxAction, payload);
337 }
338 }, {
339 key: "sendWidgetPanelSearch",
340 value: function sendWidgetPanelSearch(_ref7) {
341 var _config$triggers1, _config$targetTypes10, _config$interactionRe11, _config$interactionRe12, _config$locations1, _config$locations10, _config$secondaryLoca10, _config$names1;
342 var resultsCount = _ref7.resultsCount,
343 _ref7$userInput = _ref7.userInput,
344 userInput = _ref7$userInput === void 0 ? null : _ref7$userInput;
345 var config = this.getConfig();
346 var hasResults = resultsCount > 0;
347 var payload = this.createBasePayload({
348 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers1 = config.triggers) === null || _config$triggers1 === void 0 ? void 0 : _config$triggers1.typing),
349 target_type: config === null || config === void 0 || (_config$targetTypes10 = config.targetTypes) === null || _config$targetTypes10 === void 0 ? void 0 : _config$targetTypes10.searchWidget,
350 target_name: 'search_widget',
351 interaction_result: hasResults ? config === null || config === void 0 || (_config$interactionRe11 = config.interactionResults) === null || _config$interactionRe11 === void 0 ? void 0 : _config$interactionRe11.resultsUpdated : config === null || config === void 0 || (_config$interactionRe12 = config.interactionResults) === null || _config$interactionRe12 === void 0 ? void 0 : _config$interactionRe12.noResults,
352 target_location: this.toLowerSnake(config === null || config === void 0 || (_config$locations1 = config.locations) === null || _config$locations1 === void 0 ? void 0 : _config$locations1.leftPanel),
353 location_l1: this.toLowerSnake(config === null || config === void 0 || (_config$locations10 = config.locations) === null || _config$locations10 === void 0 ? void 0 : _config$locations10.widgetPanel),
354 location_l2: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca10 = config.secondaryLocations) === null || _config$secondaryLoca10 === void 0 ? void 0 : _config$secondaryLoca10.searchBar),
355 interaction_description: 'Widget search input, follows debounce behavior'
356 });
357 if (!hasResults && userInput) {
358 payload.metadata = {
359 user_input: userInput
360 };
361 }
362 return this.dispatchEvent(config === null || config === void 0 || (_config$names1 = config.names) === null || _config$names1 === void 0 || (_config$names1 = _config$names1.editorOne) === null || _config$names1 === void 0 ? void 0 : _config$names1.widgetPanelSearch, payload);
363 }
364 }]);
365 }();
366 var createDebouncedFinderSearch = exports.createDebouncedFinderSearch = function createDebouncedFinderSearch() {
367 var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 300;
368 return _.debounce(function (resultsCount, searchTerm) {
369 EditorOneEventManager.sendFinderSearchInput({
370 resultsCount: resultsCount,
371 searchTerm: searchTerm
372 });
373 }, delay);
374 };
375 var createDebouncedWidgetPanelSearch = exports.createDebouncedWidgetPanelSearch = function createDebouncedWidgetPanelSearch() {
376 var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2000;
377 return _.debounce(function (resultsCount, userInput) {
378 EditorOneEventManager.sendWidgetPanelSearch({
379 resultsCount: resultsCount,
380 userInput: userInput
381 });
382 }, delay);
383 };
384 var _default = exports["default"] = EditorOneEventManager;
385
386 /***/ }),
387
388 /***/ "../assets/dev/js/editor/utils/files-upload-handler.js":
389 /*!*************************************************************!*\
390 !*** ../assets/dev/js/editor/utils/files-upload-handler.js ***!
391 \*************************************************************/
392 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
393
394 "use strict";
395 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
396
397
398 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
399 Object.defineProperty(exports, "__esModule", ({
400 value: true
401 }));
402 exports["default"] = void 0;
403 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
404 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
405 var FilesUploadHandler = exports["default"] = /*#__PURE__*/function () {
406 function FilesUploadHandler() {
407 (0, _classCallCheck2.default)(this, FilesUploadHandler);
408 }
409 return (0, _createClass2.default)(FilesUploadHandler, null, [{
410 key: "isUploadEnabled",
411 value: function isUploadEnabled(mediaType) {
412 var unfilteredFilesTypes = ['svg', 'application/json'];
413 if (!unfilteredFilesTypes.includes(mediaType)) {
414 return true;
415 }
416 return elementorCommon.config.filesUpload.unfilteredFiles;
417 }
418 }, {
419 key: "setUploadTypeCaller",
420 value: function setUploadTypeCaller(frame) {
421 frame.uploader.uploader.param('uploadTypeCaller', 'elementor-wp-media-upload');
422 }
423 }, {
424 key: "getUnfilteredFilesNonAdminDialog",
425 value: function getUnfilteredFilesNonAdminDialog() {
426 return elementorCommon.dialogsManager.createWidget('alert', {
427 id: 'e-unfiltered-files-disabled-dialog',
428 headerMessage: __('Sorry, you can\'t upload that file yet', 'elementor'),
429 message: __('This is because JSON files may pose a security risk.', 'elementor') + '<br><br>' + __('To upload them anyway, ask the site administrator to enable unfiltered file uploads.', 'elementor'),
430 strings: {
431 confirm: __('Got it', 'elementor')
432 }
433 });
434 }
435 }, {
436 key: "getUnfilteredFilesNotEnabledDialog",
437 value: function getUnfilteredFilesNotEnabledDialog(callback) {
438 var elementorInstance = window.elementorAdmin || window.elementor;
439 if (!elementorInstance.config.user.is_administrator) {
440 return this.getUnfilteredFilesNonAdminDialog();
441 }
442 var onConfirm = function onConfirm() {
443 elementorCommon.ajax.addRequest('enable_unfiltered_files_upload', {}, true);
444 elementorCommon.config.filesUpload.unfilteredFiles = true;
445 callback();
446 };
447 return elementorInstance.helpers.getSimpleDialog('e-enable-unfiltered-files-dialog', __('Enable Unfiltered File Uploads', 'elementor'), __('Before you enable unfiltered files upload, note that such files include a security risk. Elementor does run a process to remove possible malicious code, but there is still risk involved when using such files.', 'elementor'), __('Enable', 'elementor'), onConfirm);
448 }
449 }, {
450 key: "getUnfilteredFilesNotEnabledImportTemplateDialog",
451 value: function getUnfilteredFilesNotEnabledImportTemplateDialog(callback) {
452 if (!(window.elementorAdmin || window.elementor).config.user.is_administrator) {
453 return this.getUnfilteredFilesNonAdminDialog();
454 }
455 return elementorCommon.dialogsManager.createWidget('confirm', {
456 id: 'e-enable-unfiltered-files-dialog-import-template',
457 headerMessage: __('Enable Unfiltered File Uploads', 'elementor'),
458 message: __('Before you enable unfiltered files upload, note that such files include a security risk. Elementor does run a process to remove possible malicious code, but there is still risk involved when using such files.', 'elementor') + '<br /><br />' + __('If you do not enable uploading unfiltered files, any SVG or JSON (including lottie) files used in the uploaded template will not be imported.', 'elementor'),
459 position: {
460 my: 'center center',
461 at: 'center center'
462 },
463 strings: {
464 confirm: __('Enable and Import', 'elementor'),
465 cancel: __('Import Without Enabling', 'elementor')
466 },
467 onConfirm: function onConfirm() {
468 elementorCommon.ajax.addRequest('enable_unfiltered_files_upload', {
469 success: function success() {
470 // This utility is used in both the admin and the Editor.
471 elementorCommon.config.filesUpload.unfilteredFiles = true;
472 callback();
473 }
474 }, true);
475 },
476 onCancel: function onCancel() {
477 return callback();
478 }
479 });
480 }
481 }]);
482 }();
483
484 /***/ }),
485
486 /***/ "../assets/dev/js/editor/utils/is-instanceof.js":
487 /*!******************************************************!*\
488 !*** ../assets/dev/js/editor/utils/is-instanceof.js ***!
489 \******************************************************/
490 /***/ ((__unused_webpack_module, exports) => {
491
492 "use strict";
493
494
495 Object.defineProperty(exports, "__esModule", ({
496 value: true
497 }));
498 exports["default"] = void 0;
499 function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
500 function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
501 function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
502 /**
503 * Some FileAPI objects such as FileList, DataTransferItem and DataTransferItemList has inconsistency with the retrieved
504 * object (from events, etc.) and the actual JavaScript object so a regular instanceof doesn't work. This function can
505 * check whether it's instanceof by using the objects constructor and prototype names.
506 *
507 * @param object
508 * @param constructors
509 * @return {boolean}
510 */
511 var _default = exports["default"] = function _default(object, constructors) {
512 constructors = Array.isArray(constructors) ? constructors : [constructors];
513 var _iterator = _createForOfIteratorHelper(constructors),
514 _step;
515 try {
516 for (_iterator.s(); !(_step = _iterator.n()).done;) {
517 var constructor = _step.value;
518 if (object.constructor.name === constructor.prototype[Symbol.toStringTag]) {
519 return true;
520 }
521 }
522 } catch (err) {
523 _iterator.e(err);
524 } finally {
525 _iterator.f();
526 }
527 return false;
528 };
529
530 /***/ }),
531
532 /***/ "../assets/dev/js/modules/imports/args-object.js":
533 /*!*******************************************************!*\
534 !*** ../assets/dev/js/modules/imports/args-object.js ***!
535 \*******************************************************/
536 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
537
538 "use strict";
539
540
541 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
542 Object.defineProperty(exports, "__esModule", ({
543 value: true
544 }));
545 exports["default"] = void 0;
546 var _typeof2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js"));
547 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
548 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
549 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
550 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
551 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
552 var _instanceType = _interopRequireDefault(__webpack_require__(/*! ./instance-type */ "../assets/dev/js/modules/imports/instance-type.js"));
553 var _isInstanceof = _interopRequireDefault(__webpack_require__(/*! ../../editor/utils/is-instanceof */ "../assets/dev/js/editor/utils/is-instanceof.js"));
554 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
555 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
556 var ArgsObject = exports["default"] = /*#__PURE__*/function (_InstanceType) {
557 /**
558 * Function constructor().
559 *
560 * Create ArgsObject.
561 *
562 * @param {{}} args
563 */
564 function ArgsObject(args) {
565 var _this;
566 (0, _classCallCheck2.default)(this, ArgsObject);
567 _this = _callSuper(this, ArgsObject);
568 _this.args = args;
569 return _this;
570 }
571
572 /**
573 * Function requireArgument().
574 *
575 * Validate property in args.
576 *
577 * @param {string} property
578 * @param {{}} args
579 *
580 * @throws {Error}
581 */
582 (0, _inherits2.default)(ArgsObject, _InstanceType);
583 return (0, _createClass2.default)(ArgsObject, [{
584 key: "requireArgument",
585 value: function requireArgument(property) {
586 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.args;
587 if (!Object.prototype.hasOwnProperty.call(args, property)) {
588 throw Error("".concat(property, " is required."));
589 }
590 }
591
592 /**
593 * Function requireArgumentType().
594 *
595 * Validate property in args using `type === typeof(args.whatever)`.
596 *
597 * @param {string} property
598 * @param {string} type
599 * @param {{}} args
600 *
601 * @throws {Error}
602 */
603 }, {
604 key: "requireArgumentType",
605 value: function requireArgumentType(property, type) {
606 var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.args;
607 this.requireArgument(property, args);
608 if ((0, _typeof2.default)(args[property]) !== type) {
609 throw Error("".concat(property, " invalid type: ").concat(type, "."));
610 }
611 }
612
613 /**
614 * Function requireArgumentInstance().
615 *
616 * Validate property in args using `args.whatever instanceof instance`.
617 *
618 * @param {string} property
619 * @param {*} instance
620 * @param {{}} args
621 *
622 * @throws {Error}
623 */
624 }, {
625 key: "requireArgumentInstance",
626 value: function requireArgumentInstance(property, instance) {
627 var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.args;
628 this.requireArgument(property, args);
629 if (!(args[property] instanceof instance) && !(0, _isInstanceof.default)(args[property], instance)) {
630 throw Error("".concat(property, " invalid instance."));
631 }
632 }
633
634 /**
635 * Function requireArgumentConstructor().
636 *
637 * Validate property in args using `type === args.whatever.constructor`.
638 *
639 * @param {string} property
640 * @param {*} type
641 * @param {{}} args
642 *
643 * @throws {Error}
644 */
645 }, {
646 key: "requireArgumentConstructor",
647 value: function requireArgumentConstructor(property, type) {
648 var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.args;
649 this.requireArgument(property, args);
650
651 // Note: Converting the constructor to string in order to avoid equation issues
652 // due to different memory addresses between iframes (window.Object !== window.top.Object).
653 if (args[property].constructor.toString() !== type.prototype.constructor.toString()) {
654 throw Error("".concat(property, " invalid constructor type."));
655 }
656 }
657 }], [{
658 key: "getInstanceType",
659 value: function getInstanceType() {
660 return 'ArgsObject';
661 }
662 }]);
663 }(_instanceType.default);
664
665 /***/ }),
666
667 /***/ "../assets/dev/js/modules/imports/instance-type.js":
668 /*!*********************************************************!*\
669 !*** ../assets/dev/js/modules/imports/instance-type.js ***!
670 \*********************************************************/
671 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
672
673 "use strict";
674
675
676 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
677 Object.defineProperty(exports, "__esModule", ({
678 value: true
679 }));
680 exports["default"] = void 0;
681 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
682 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
683 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
684 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
685 function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
686 var InstanceType = exports["default"] = /*#__PURE__*/function () {
687 function InstanceType() {
688 var _this = this;
689 (0, _classCallCheck2.default)(this, InstanceType);
690 // Since anonymous classes sometimes do not get validated by babel, do it manually.
691 var target = this instanceof InstanceType ? this.constructor : void 0;
692 var prototypes = [];
693 while (target.__proto__ && target.__proto__.name) {
694 prototypes.push(target.__proto__);
695 target = target.__proto__;
696 }
697 prototypes.reverse().forEach(function (proto) {
698 return _this instanceof proto;
699 });
700 }
701 return (0, _createClass2.default)(InstanceType, null, [{
702 key: Symbol.hasInstance,
703 value: function value(target) {
704 /**
705 * This is function extending being called each time JS uses instanceOf, since babel use it each time it create new class
706 * its give's opportunity to mange capabilities of instanceOf operator.
707 * saving current class each time will give option later to handle instanceOf manually.
708 */
709 var result = _superPropGet(InstanceType, Symbol.hasInstance, this, 2)([target]);
710
711 // Act normal when validate a class, which does not have instance type.
712 if (target && !target.constructor.getInstanceType) {
713 return result;
714 }
715 if (target) {
716 if (!target.instanceTypes) {
717 target.instanceTypes = [];
718 }
719 if (!result) {
720 if (this.getInstanceType() === target.constructor.getInstanceType()) {
721 result = true;
722 }
723 }
724 if (result) {
725 var name = this.getInstanceType === InstanceType.getInstanceType ? 'BaseInstanceType' : this.getInstanceType();
726 if (-1 === target.instanceTypes.indexOf(name)) {
727 target.instanceTypes.push(name);
728 }
729 }
730 }
731 if (!result && target) {
732 // Check if the given 'target', is instance of known types.
733 result = target.instanceTypes && Array.isArray(target.instanceTypes) && -1 !== target.instanceTypes.indexOf(this.getInstanceType());
734 }
735 return result;
736 }
737 }, {
738 key: "getInstanceType",
739 value: function getInstanceType() {
740 elementorModules.ForceMethodImplementation();
741 }
742 }]);
743 }();
744
745 /***/ }),
746
747 /***/ "../assets/dev/js/modules/imports/module.js":
748 /*!**************************************************!*\
749 !*** ../assets/dev/js/modules/imports/module.js ***!
750 \**************************************************/
751 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
752
753 "use strict";
754
755
756 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
757 var _typeof2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js"));
758 var Module = function Module() {
759 var $ = jQuery,
760 instanceParams = arguments,
761 self = this,
762 events = {};
763 var settings;
764 var ensureClosureMethods = function ensureClosureMethods() {
765 $.each(self, function (methodName) {
766 var oldMethod = self[methodName];
767 if ('function' !== typeof oldMethod) {
768 return;
769 }
770 self[methodName] = function () {
771 return oldMethod.apply(self, arguments);
772 };
773 });
774 };
775 var initSettings = function initSettings() {
776 settings = self.getDefaultSettings();
777 var instanceSettings = instanceParams[0];
778 if (instanceSettings) {
779 $.extend(true, settings, instanceSettings);
780 }
781 };
782 var init = function init() {
783 self.__construct.apply(self, instanceParams);
784 ensureClosureMethods();
785 initSettings();
786 self.trigger('init');
787 };
788 this.getItems = function (items, itemKey) {
789 if (itemKey) {
790 var keyStack = itemKey.split('.'),
791 currentKey = keyStack.splice(0, 1);
792 if (!keyStack.length) {
793 return items[currentKey];
794 }
795 if (!items[currentKey]) {
796 return;
797 }
798 return this.getItems(items[currentKey], keyStack.join('.'));
799 }
800 return items;
801 };
802 this.getSettings = function (setting) {
803 return this.getItems(settings, setting);
804 };
805 this.setSettings = function (settingKey, value, settingsContainer) {
806 if (!settingsContainer) {
807 settingsContainer = settings;
808 }
809 if ('object' === (0, _typeof2.default)(settingKey)) {
810 $.extend(settingsContainer, settingKey);
811 return self;
812 }
813 var keyStack = settingKey.split('.'),
814 currentKey = keyStack.splice(0, 1);
815 if (!keyStack.length) {
816 settingsContainer[currentKey] = value;
817 return self;
818 }
819 if (!settingsContainer[currentKey]) {
820 settingsContainer[currentKey] = {};
821 }
822 return self.setSettings(keyStack.join('.'), value, settingsContainer[currentKey]);
823 };
824 this.getErrorMessage = function (type, functionName) {
825 var message;
826 switch (type) {
827 case 'forceMethodImplementation':
828 message = "The method '".concat(functionName, "' must to be implemented in the inheritor child.");
829 break;
830 default:
831 message = 'An error occurs';
832 }
833 return message;
834 };
835
836 // TODO: This function should be deleted ?.
837 this.forceMethodImplementation = function (functionName) {
838 throw new Error(this.getErrorMessage('forceMethodImplementation', functionName));
839 };
840 this.on = function (eventName, callback) {
841 if ('object' === (0, _typeof2.default)(eventName)) {
842 $.each(eventName, function (singleEventName) {
843 self.on(singleEventName, this);
844 });
845 return self;
846 }
847 var eventNames = eventName.split(' ');
848 eventNames.forEach(function (singleEventName) {
849 if (!events[singleEventName]) {
850 events[singleEventName] = [];
851 }
852 events[singleEventName].push(callback);
853 });
854 return self;
855 };
856 this.off = function (eventName, callback) {
857 if (!events[eventName]) {
858 return self;
859 }
860 if (!callback) {
861 delete events[eventName];
862 return self;
863 }
864 var callbackIndex = events[eventName].indexOf(callback);
865 if (-1 !== callbackIndex) {
866 delete events[eventName][callbackIndex];
867
868 // Reset array index (for next off on same event).
869 events[eventName] = events[eventName].filter(function (val) {
870 return val;
871 });
872 }
873 return self;
874 };
875 this.trigger = function (eventName) {
876 var methodName = 'on' + eventName[0].toUpperCase() + eventName.slice(1),
877 params = Array.prototype.slice.call(arguments, 1);
878 if (self[methodName]) {
879 self[methodName].apply(self, params);
880 }
881 var callbacks = events[eventName];
882 if (!callbacks) {
883 return self;
884 }
885 $.each(callbacks, function (index, callback) {
886 callback.apply(self, params);
887 });
888 return self;
889 };
890 init();
891 };
892 Module.prototype.__construct = function () {};
893 Module.prototype.getDefaultSettings = function () {
894 return {};
895 };
896 Module.prototype.getConstructorID = function () {
897 return this.constructor.name;
898 };
899 Module.extend = function (properties) {
900 var $ = jQuery,
901 parent = this;
902 var child = function child() {
903 return parent.apply(this, arguments);
904 };
905 $.extend(child, parent);
906 child.prototype = Object.create($.extend({}, parent.prototype, properties));
907 child.prototype.constructor = child;
908 child.__super__ = parent.prototype;
909 return child;
910 };
911 module.exports = Module;
912
913 /***/ }),
914
915 /***/ "../assets/dev/js/utils/notifications.js":
916 /*!***********************************************!*\
917 !*** ../assets/dev/js/utils/notifications.js ***!
918 \***********************************************/
919 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
920
921 "use strict";
922
923
924 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
925 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
926 function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
927 function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
928 module.exports = elementorModules.Module.extend({
929 initToast: function initToast() {
930 var toast = elementorCommon.dialogsManager.createWidget('buttons', {
931 id: 'elementor-toast',
932 position: {
933 my: 'center bottom',
934 at: 'center bottom-10',
935 of: '#elementor-panel-inner',
936 autoRefresh: true
937 },
938 hide: {
939 onClick: true,
940 auto: true,
941 autoDelay: 10000
942 },
943 effects: {
944 show: function show() {
945 var $widget = toast.getElements('widget');
946 $widget.show();
947 toast.refreshPosition();
948 var top = parseInt($widget.css('top'), 10);
949 $widget.hide().css('top', top + 100);
950 $widget.animate({
951 opacity: 'show',
952 height: 'show',
953 paddingBottom: 'show',
954 paddingTop: 'show',
955 top: top
956 }, {
957 easing: 'linear',
958 duration: 300
959 });
960 },
961 hide: function hide() {
962 var $widget = toast.getElements('widget'),
963 top = parseInt($widget.css('top'), 10);
964 $widget.animate({
965 opacity: 'hide',
966 height: 'hide',
967 paddingBottom: 'hide',
968 paddingTop: 'hide',
969 top: top + 100
970 }, {
971 easing: 'linear',
972 duration: 300
973 });
974 }
975 },
976 button: {
977 tag: 'button'
978 }
979 });
980
981 // Add role="status" and aria-live for screen reader announcement
982 toast.getElements('widget').attr({
983 role: 'status',
984 'aria-live': 'polite',
985 'aria-atomic': 'true'
986 });
987 this.getToast = function () {
988 return toast;
989 };
990 },
991 showToast: function showToast(options) {
992 var toast = this.getToast();
993 toast.setMessage(options.message);
994 toast.getElements('buttonsWrapper').empty();
995 toast.focusedButton = null;
996 toast.buttons = [];
997 var isPositionValid = this.isPositionValid(options === null || options === void 0 ? void 0 : options.position);
998 if (!isPositionValid) {
999 this.positionToWindow();
1000 }
1001 if (options !== null && options !== void 0 && options.position && isPositionValid) {
1002 toast.setSettings('position', options.position);
1003 }
1004 if (options.buttons) {
1005 options.buttons.forEach(function (button) {
1006 toast.addButton(button);
1007 });
1008 }
1009 if (options.classes) {
1010 toast.getElements('widget').addClass(options.classes);
1011 }
1012 if (options.sticky) {
1013 toast.setSettings({
1014 hide: {
1015 auto: false,
1016 onClick: false
1017 }
1018 });
1019 }
1020 return toast.show();
1021 },
1022 isPositionValid: function isPositionValid(position) {
1023 var _position$of;
1024 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;
1025 if (!positionToCheck) {
1026 return false;
1027 }
1028 return !!document.querySelector(positionToCheck);
1029 },
1030 positionToWindow: function positionToWindow() {
1031 var toast = this.getToast();
1032 var position = _objectSpread(_objectSpread({}, toast.getSettings('position')), {}, {
1033 my: 'right top',
1034 at: 'right-10 top+42',
1035 // 42px is the default admin bar height + 10px
1036 of: ''
1037 });
1038 toast.setSettings('position', position);
1039 toast.getElements('widget').addClass('dialog-position-window');
1040 },
1041 onInit: function onInit() {
1042 this.initToast();
1043 }
1044 });
1045
1046 /***/ }),
1047
1048 /***/ "../assets/dev/js/utils/tiers.js":
1049 /*!***************************************!*\
1050 !*** ../assets/dev/js/utils/tiers.js ***!
1051 \***************************************/
1052 /***/ ((__unused_webpack_module, exports) => {
1053
1054 "use strict";
1055
1056
1057 Object.defineProperty(exports, "__esModule", ({
1058 value: true
1059 }));
1060 exports.isTierAtLeast = exports.TIERS_PRIORITY = exports.TIERS = void 0;
1061 var TIERS_PRIORITY = exports.TIERS_PRIORITY = Object.freeze(['free', 'essential', 'essential-oct2023', 'advanced', 'expert', 'agency']);
1062
1063 /**
1064 * @type {Readonly<{
1065 * free: string;
1066 * essential: string;
1067 * 'essential-oct2023': string;
1068 * advanced: string;
1069 * expert: string;
1070 * agency: string;
1071 * }>}
1072 */
1073 var TIERS = exports.TIERS = Object.freeze(TIERS_PRIORITY.reduce(function (acc, tier) {
1074 acc[tier] = tier;
1075 return acc;
1076 }, {}));
1077 var isTierAtLeast = exports.isTierAtLeast = function isTierAtLeast(currentTier, expectedTier) {
1078 var currentTierIndex = TIERS_PRIORITY.indexOf(currentTier);
1079 var expectedTierIndex = TIERS_PRIORITY.indexOf(expectedTier);
1080 if (-1 === currentTierIndex || -1 === expectedTierIndex) {
1081 return false;
1082 }
1083 return currentTierIndex >= expectedTierIndex;
1084 };
1085
1086 /***/ }),
1087
1088 /***/ "../assets/dev/js/utils/time.js":
1089 /*!**************************************!*\
1090 !*** ../assets/dev/js/utils/time.js ***!
1091 \**************************************/
1092 /***/ ((__unused_webpack_module, exports) => {
1093
1094 "use strict";
1095
1096
1097 Object.defineProperty(exports, "__esModule", ({
1098 value: true
1099 }));
1100 exports["default"] = getUserTimestamp;
1101 /**
1102 * Returns the timestamp in ISO8601 format with the UTC timezone offset.
1103 *
1104 * @since 3.6.0
1105 *
1106 * @param {Date} date
1107 * @return {Date} timestamp
1108 */
1109 function getUserTimestamp() {
1110 var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
1111 var timezoneOffset = date.getTimezoneOffset();
1112
1113 // Local time for the user
1114 var UTCTimestamp = new Date(date.getTime() - timezoneOffset * 60000).toISOString();
1115
1116 // Remove the Z suffix from the string.
1117 UTCTimestamp = UTCTimestamp.slice(0, -1);
1118
1119 // Create the offset string in the format `+HH:00` (or minus (-) prefix for negative offset instead of plus)
1120 var decimalTimezoneOffset = timezoneOffset / 60,
1121 // Negative offsets include a '-' sign in the getTimezoneOffset value, positive values need a '+' prefix (ISO8601).
1122 sign = 0 <= decimalTimezoneOffset ? '+' : '-',
1123 hours = Math.abs(Math.floor(decimalTimezoneOffset)),
1124 minutes = Math.abs(decimalTimezoneOffset % 1) * 60,
1125 addZeroToHour = 10 > hours ? '0' : '',
1126 addZeroToMinutes = 10 > minutes ? '0' : '';
1127 var formattedTimezoneOffset = sign + addZeroToHour + hours + ':' + addZeroToMinutes + minutes;
1128 return UTCTimestamp + formattedTimezoneOffset;
1129 }
1130
1131 /***/ }),
1132
1133 /***/ "../core/common/assets/js/components/wordpress/commands-data/index.js":
1134 /*!****************************************************************************!*\
1135 !*** ../core/common/assets/js/components/wordpress/commands-data/index.js ***!
1136 \****************************************************************************/
1137 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1138
1139 "use strict";
1140
1141
1142 Object.defineProperty(exports, "__esModule", ({
1143 value: true
1144 }));
1145 Object.defineProperty(exports, "Media", ({
1146 enumerable: true,
1147 get: function get() {
1148 return _media.Media;
1149 }
1150 }));
1151 var _media = __webpack_require__(/*! ./media */ "../core/common/assets/js/components/wordpress/commands-data/media.js");
1152
1153 /***/ }),
1154
1155 /***/ "../core/common/assets/js/components/wordpress/commands-data/media.js":
1156 /*!****************************************************************************!*\
1157 !*** ../core/common/assets/js/components/wordpress/commands-data/media.js ***!
1158 \****************************************************************************/
1159 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1160
1161 "use strict";
1162 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
1163
1164
1165 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1166 Object.defineProperty(exports, "__esModule", ({
1167 value: true
1168 }));
1169 exports.Media = void 0;
1170 var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "../node_modules/@babel/runtime/regenerator/index.js"));
1171 var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "../node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
1172 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1173 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1174 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1175 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1176 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
1177 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1178 var _commandData = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-data */ "../modules/web-cli/assets/js/modules/command-data.js"));
1179 var _filesUploadHandler = _interopRequireDefault(__webpack_require__(/*! elementor-editor/utils/files-upload-handler */ "../assets/dev/js/editor/utils/files-upload-handler.js"));
1180 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)); }
1181 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1182 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; }
1183 var Media = exports.Media = /*#__PURE__*/function (_CommandData) {
1184 function Media() {
1185 (0, _classCallCheck2.default)(this, Media);
1186 return _callSuper(this, Media, arguments);
1187 }
1188 (0, _inherits2.default)(Media, _CommandData);
1189 return (0, _createClass2.default)(Media, [{
1190 key: "validateArgs",
1191 value: function validateArgs() {
1192 this.requireArgumentInstance('file', File);
1193 }
1194 }, {
1195 key: "getRequestData",
1196 value: function getRequestData() {
1197 var requestData = _superPropGet(Media, "getRequestData", this, 3)([]);
1198 requestData.namespace = 'wp';
1199 requestData.version = '2';
1200 return requestData;
1201 }
1202 }, {
1203 key: "applyBeforeCreate",
1204 value: function applyBeforeCreate(args) {
1205 var _args$options;
1206 args.headers = {
1207 'Content-Disposition': "attachment; filename=".concat(this.file.name),
1208 'Content-Type': this.file.type
1209 };
1210 args.query = {
1211 uploadTypeCaller: 'elementor-wp-media-upload'
1212 };
1213 args.data = this.file;
1214 if ((_args$options = args.options) !== null && _args$options !== void 0 && _args$options.progress) {
1215 this.toast = elementor.notifications.showToast({
1216 // eslint-disable-next-line @wordpress/i18n-ellipsis
1217 message: __('Uploading...'),
1218 sticky: true
1219 });
1220 }
1221 return args;
1222 }
1223 }, {
1224 key: "applyAfterCreate",
1225 value: function applyAfterCreate(data, args) {
1226 var _args$options2;
1227 if ((_args$options2 = args.options) !== null && _args$options2 !== void 0 && _args$options2.progress) {
1228 this.toast.hide();
1229 }
1230 return data;
1231 }
1232 }, {
1233 key: "run",
1234 value: function () {
1235 var _run = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee() {
1236 return _regenerator.default.wrap(function (_context) {
1237 while (1) switch (_context.prev = _context.next) {
1238 case 0:
1239 this.file = this.args.file;
1240 if (!(this.file.size > parseInt(window._wpPluploadSettings.defaults.filters.max_file_size, 10))) {
1241 _context.next = 1;
1242 break;
1243 }
1244 throw new Error(__('The file exceeds the maximum upload size for this site.', 'elementor'));
1245 case 1:
1246 if (!(!window._wpPluploadSettings.defaults.filters.mime_types[0].extensions.split(',').includes(this.file.name.split('.').pop()) && !elementor.config.filesUpload.unfilteredFiles)) {
1247 _context.next = 2;
1248 break;
1249 }
1250 _filesUploadHandler.default.getUnfilteredFilesNotEnabledDialog(function () {}).show();
1251 return _context.abrupt("return");
1252 case 2:
1253 _context.next = 3;
1254 return _superPropGet(Media, "run", this, 3)([]);
1255 case 3:
1256 return _context.abrupt("return", _context.sent);
1257 case 4:
1258 case "end":
1259 return _context.stop();
1260 }
1261 }, _callee, this);
1262 }));
1263 function run() {
1264 return _run.apply(this, arguments);
1265 }
1266 return run;
1267 }()
1268 }], [{
1269 key: "getEndpointFormat",
1270 value: function getEndpointFormat() {
1271 // 'wp/media' to 'media' since `requestData.namespace` is 'wp'.
1272 return 'media';
1273 }
1274 }]);
1275 }(_commandData.default);
1276
1277 /***/ }),
1278
1279 /***/ "../core/common/assets/js/components/wordpress/component.js":
1280 /*!******************************************************************!*\
1281 !*** ../core/common/assets/js/components/wordpress/component.js ***!
1282 \******************************************************************/
1283 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1284
1285 "use strict";
1286
1287
1288 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1289 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
1290 Object.defineProperty(exports, "__esModule", ({
1291 value: true
1292 }));
1293 exports["default"] = void 0;
1294 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1295 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1296 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1297 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1298 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1299 var _componentBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/component-base */ "../modules/web-cli/assets/js/modules/component-base.js"));
1300 var dataCommands = _interopRequireWildcard(__webpack_require__(/*! ./commands-data/ */ "../core/common/assets/js/components/wordpress/commands-data/index.js"));
1301 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); }
1302 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)); }
1303 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1304 var Component = exports["default"] = /*#__PURE__*/function (_ComponentBase) {
1305 function Component() {
1306 (0, _classCallCheck2.default)(this, Component);
1307 return _callSuper(this, Component, arguments);
1308 }
1309 (0, _inherits2.default)(Component, _ComponentBase);
1310 return (0, _createClass2.default)(Component, [{
1311 key: "getNamespace",
1312 value: function getNamespace() {
1313 return 'wp';
1314 }
1315 }, {
1316 key: "defaultData",
1317 value: function defaultData() {
1318 return this.importCommands(dataCommands);
1319 }
1320 }]);
1321 }(_componentBase.default);
1322
1323 /***/ }),
1324
1325 /***/ "../core/common/assets/js/utils/debug.js":
1326 /*!***********************************************!*\
1327 !*** ../core/common/assets/js/utils/debug.js ***!
1328 \***********************************************/
1329 /***/ ((module) => {
1330
1331 "use strict";
1332
1333
1334 // Moved from assets/dev/js/editor/utils
1335 var Debug = function Debug() {
1336 var self = this,
1337 errorStack = [],
1338 settings = {},
1339 elements = {};
1340 var initSettings = function initSettings() {
1341 settings = {
1342 debounceDelay: 500,
1343 urlsToWatch: ['elementor/assets']
1344 };
1345 };
1346 var initElements = function initElements() {
1347 elements.$window = jQuery(window);
1348 };
1349 var onError = function onError(event) {
1350 var _event$originalEvent;
1351 var error = (_event$originalEvent = event.originalEvent) === null || _event$originalEvent === void 0 ? void 0 : _event$originalEvent.error;
1352 if (!error) {
1353 return;
1354 }
1355 var isInWatchList = false,
1356 urlsToWatch = settings.urlsToWatch;
1357 jQuery.each(urlsToWatch, function () {
1358 if (-1 !== error.stack.indexOf(this)) {
1359 isInWatchList = true;
1360 return false;
1361 }
1362 });
1363 if (!isInWatchList) {
1364 return;
1365 }
1366 self.addError({
1367 type: error.name,
1368 message: error.message,
1369 url: event.originalEvent.filename,
1370 line: event.originalEvent.lineno,
1371 column: event.originalEvent.colno
1372 });
1373 };
1374 var bindEvents = function bindEvents() {
1375 elements.$window.on('error', onError);
1376 };
1377 var init = function init() {
1378 initSettings();
1379 initElements();
1380 bindEvents();
1381 self.sendErrors = _.debounce(self.sendErrors, settings.debounceDelay);
1382 };
1383 this.addURLToWatch = function (url) {
1384 settings.urlsToWatch.push(url);
1385 };
1386 this.addCustomError = function (error, category, tag) {
1387 var errorInfo = {
1388 type: error.name,
1389 message: error.message,
1390 url: error.fileName || error.sourceURL,
1391 line: error.lineNumber || error.line,
1392 column: error.columnNumber || error.column,
1393 customFields: {
1394 category: category || 'general',
1395 tag: tag
1396 }
1397 };
1398 if (!errorInfo.url) {
1399 var stackInfo = error.stack.match(/\n {4}at (.*?(?=:(\d+):(\d+)))/);
1400 if (stackInfo) {
1401 errorInfo.url = stackInfo[1];
1402 errorInfo.line = stackInfo[2];
1403 errorInfo.column = stackInfo[3];
1404 }
1405 }
1406 this.addError(errorInfo);
1407 };
1408 this.addError = function (errorParams) {
1409 var defaultParams = {
1410 type: 'Error',
1411 timestamp: Math.floor(new Date().getTime() / 1000),
1412 message: null,
1413 url: null,
1414 line: null,
1415 column: null,
1416 customFields: {}
1417 };
1418 errorStack.push(jQuery.extend(true, defaultParams, errorParams));
1419 self.sendErrors();
1420 };
1421 this.sendErrors = function () {
1422 // Avoid recursions on errors in ajax
1423 elements.$window.off('error', onError);
1424 jQuery.ajax({
1425 url: elementorCommon.config.ajax.url,
1426 method: 'POST',
1427 data: {
1428 action: 'elementor_js_log',
1429 _nonce: elementorCommon.ajax.getSettings('nonce'),
1430 data: errorStack
1431 },
1432 success: function success() {
1433 errorStack = [];
1434
1435 // Restore error handler
1436 elements.$window.on('error', onError);
1437 }
1438 });
1439 };
1440 init();
1441 };
1442 module.exports = Debug;
1443
1444 /***/ }),
1445
1446 /***/ "../core/common/assets/js/utils/helpers.js":
1447 /*!*************************************************!*\
1448 !*** ../core/common/assets/js/utils/helpers.js ***!
1449 \*************************************************/
1450 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1451
1452 "use strict";
1453
1454
1455 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1456 Object.defineProperty(exports, "__esModule", ({
1457 value: true
1458 }));
1459 exports["default"] = void 0;
1460 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1461 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1462 var Helpers = exports["default"] = /*#__PURE__*/function () {
1463 function Helpers() {
1464 (0, _classCallCheck2.default)(this, Helpers);
1465 }
1466 return (0, _createClass2.default)(Helpers, [{
1467 key: "consoleWarn",
1468 value:
1469 /**
1470 * @param {*} args
1471 * @deprecated since 3.7.0, use `elementorDevTools.consoleWarn()` instead.
1472 */
1473 function consoleWarn() {
1474 var _elementorDevTools;
1475 (_elementorDevTools = elementorDevTools).consoleWarn.apply(_elementorDevTools, arguments);
1476
1477 // This is is self is deprecated.
1478 elementorDevTools.deprecation.deprecated('elementorCommon.helpers.consoleWarn()', '3.7.0', 'elementorDevTools.consoleWarn()');
1479 }
1480
1481 /**
1482 * @param {string} message
1483 * @deprecated since 3.7.0, use `console.error()` instead.
1484 */
1485 }, {
1486 key: "consoleError",
1487 value: function consoleError(message) {
1488 // eslint-disable-next-line no-console
1489 console.error(message);
1490
1491 // This is is self is deprecated.
1492 elementorDevTools.deprecation.deprecated('elementorCommon.helpers.consoleError()', '3.7.0', 'console.error()');
1493 }
1494 }, {
1495 key: "cloneObject",
1496 value: function cloneObject(object) {
1497 return JSON.parse(JSON.stringify(object));
1498 }
1499 }, {
1500 key: "upperCaseWords",
1501 value: function upperCaseWords(string) {
1502 return (string + '').replace(/^(.)|\s+(.)/g, function ($1) {
1503 return $1.toUpperCase();
1504 });
1505 }
1506 }, {
1507 key: "getUniqueId",
1508 value: function getUniqueId() {
1509 return Math.random().toString(16).substr(2, 7);
1510 }
1511 }]);
1512 }();
1513
1514 /***/ }),
1515
1516 /***/ "../core/common/assets/js/utils/storage.js":
1517 /*!*************************************************!*\
1518 !*** ../core/common/assets/js/utils/storage.js ***!
1519 \*************************************************/
1520 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1521
1522 "use strict";
1523
1524
1525 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1526 Object.defineProperty(exports, "__esModule", ({
1527 value: true
1528 }));
1529 exports["default"] = void 0;
1530 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1531 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1532 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1533 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1534 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1535 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)); }
1536 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1537 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
1538 function _default() {
1539 (0, _classCallCheck2.default)(this, _default);
1540 return _callSuper(this, _default, arguments);
1541 }
1542 (0, _inherits2.default)(_default, _elementorModules$Mod);
1543 return (0, _createClass2.default)(_default, [{
1544 key: "get",
1545 value: function get(key, options) {
1546 options = options || {};
1547 var storage;
1548 try {
1549 storage = options.session ? sessionStorage : localStorage;
1550 } catch (e) {
1551 return key ? undefined : {};
1552 }
1553 var elementorStorage = storage.getItem('elementor');
1554 if (elementorStorage) {
1555 elementorStorage = JSON.parse(elementorStorage);
1556 } else {
1557 elementorStorage = {};
1558 }
1559 if (!elementorStorage.__expiration) {
1560 elementorStorage.__expiration = {};
1561 }
1562 var expiration = elementorStorage.__expiration;
1563 var expirationToCheck = [];
1564 if (key) {
1565 if (expiration[key]) {
1566 expirationToCheck = [key];
1567 }
1568 } else {
1569 expirationToCheck = Object.keys(expiration);
1570 }
1571 var entryExpired = false;
1572 expirationToCheck.forEach(function (expirationKey) {
1573 if (new Date(expiration[expirationKey]) < new Date()) {
1574 delete elementorStorage[expirationKey];
1575 delete expiration[expirationKey];
1576 entryExpired = true;
1577 }
1578 });
1579 if (entryExpired) {
1580 this.save(elementorStorage, options.session);
1581 }
1582 if (key) {
1583 return elementorStorage[key];
1584 }
1585 return elementorStorage;
1586 }
1587 }, {
1588 key: "set",
1589 value: function set(key, value, options) {
1590 options = options || {};
1591 var elementorStorage = this.get(null, options);
1592 elementorStorage[key] = value;
1593 if (options.lifetimeInSeconds) {
1594 var date = new Date();
1595 date.setTime(date.getTime() + options.lifetimeInSeconds * 1000);
1596 elementorStorage.__expiration[key] = date.getTime();
1597 }
1598 this.save(elementorStorage, options.session);
1599 }
1600 }, {
1601 key: "save",
1602 value: function save(object, session) {
1603 var storage;
1604 try {
1605 storage = session ? sessionStorage : localStorage;
1606 } catch (e) {
1607 return;
1608 }
1609 storage.setItem('elementor', JSON.stringify(object));
1610 }
1611 }]);
1612 }(elementorModules.Module);
1613
1614 /***/ }),
1615
1616 /***/ "../core/common/modules/ajax/assets/js/ajax.js":
1617 /*!*****************************************************!*\
1618 !*** ../core/common/modules/ajax/assets/js/ajax.js ***!
1619 \*****************************************************/
1620 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1621
1622 "use strict";
1623
1624
1625 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1626 Object.defineProperty(exports, "__esModule", ({
1627 value: true
1628 }));
1629 exports["default"] = void 0;
1630 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
1631 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1632 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1633 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1634 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1635 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1636 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)); }
1637 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1638 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
1639 function _default() {
1640 var _this;
1641 (0, _classCallCheck2.default)(this, _default);
1642 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1643 args[_key] = arguments[_key];
1644 }
1645 _this = _callSuper(this, _default, [].concat(args));
1646 _this.requests = {};
1647 _this.cache = {};
1648 _this.initRequestConstants();
1649 _this.debounceSendBatch = _.debounce(_this.sendBatch.bind(_this), 500);
1650 return _this;
1651 }
1652 (0, _inherits2.default)(_default, _elementorModules$Mod);
1653 return (0, _createClass2.default)(_default, [{
1654 key: "getDefaultSettings",
1655 value: function getDefaultSettings() {
1656 return {
1657 ajaxParams: {
1658 type: 'POST',
1659 url: elementorCommon.config.ajax.url,
1660 data: {},
1661 dataType: 'json'
1662 },
1663 actionPrefix: 'elementor_'
1664 };
1665 }
1666 }, {
1667 key: "initRequestConstants",
1668 value: function initRequestConstants() {
1669 this.requestConstants = {
1670 _nonce: this.getSettings('nonce')
1671 };
1672 }
1673 }, {
1674 key: "addRequestConstant",
1675 value: function addRequestConstant(key, value) {
1676 this.requestConstants[key] = value;
1677 }
1678 }, {
1679 key: "getCacheKey",
1680 value: function getCacheKey(request) {
1681 return JSON.stringify({
1682 unique_id: request.unique_id,
1683 data: request.data
1684 });
1685 }
1686 }, {
1687 key: "loadObjects",
1688 value: function loadObjects(options) {
1689 var _this2 = this;
1690 var dataCollection = {};
1691 var deferredArray = [];
1692 if (options.before) {
1693 options.before();
1694 }
1695 options.ids.forEach(function (objectId) {
1696 deferredArray.push(_this2.load({
1697 action: options.action,
1698 unique_id: options.data.unique_id + objectId,
1699 data: jQuery.extend({
1700 id: objectId
1701 }, options.data)
1702 }).done(function (data) {
1703 return dataCollection = jQuery.extend(dataCollection, data);
1704 }));
1705 });
1706 jQuery.when.apply(jQuery, deferredArray).done(function () {
1707 return options.success(dataCollection);
1708 });
1709 }
1710 }, {
1711 key: "load",
1712 value: function load(request, immediately) {
1713 var _this3 = this;
1714 if (!request.unique_id) {
1715 request.unique_id = request.action;
1716 }
1717 if (request.before) {
1718 request.before();
1719 }
1720 var deferred;
1721 var cacheKey = this.getCacheKey(request);
1722 if (_.has(this.cache, cacheKey)) {
1723 deferred = jQuery.Deferred().done(request.success).resolve(this.cache[cacheKey]);
1724 } else {
1725 var _request$error;
1726 deferred = this.addRequest(request.action, {
1727 data: request.data,
1728 unique_id: request.unique_id,
1729 success: function success(data) {
1730 return _this3.cache[cacheKey] = data;
1731 },
1732 error: (_request$error = request.error) !== null && _request$error !== void 0 ? _request$error : function () {}
1733 }, immediately).done(request.success);
1734 }
1735 return deferred;
1736 }
1737 }, {
1738 key: "cancelRequest",
1739 value: function cancelRequest(requestId) {
1740 var request = this.requests[requestId];
1741 if (!request) {
1742 return null;
1743 }
1744 if (request.options.deferred.jqXhr) {
1745 return request.options.deferred.jqXhr.abort('Request canceled');
1746 }
1747 if (request.options.deferred) {
1748 return request.options.deferred.reject('Request canceled');
1749 }
1750 }
1751 }, {
1752 key: "addRequest",
1753 value: function addRequest(action, options, immediately) {
1754 options = options || {};
1755 if (!options.unique_id) {
1756 options.unique_id = action;
1757 }
1758 options.deferred = jQuery.Deferred().done(options.success).fail(options.error).always(options.complete);
1759 var request = {
1760 action: action,
1761 options: options
1762 };
1763 if (immediately) {
1764 var requests = {};
1765 requests[options.unique_id] = request;
1766 options.deferred.jqXhr = this.sendBatch(requests);
1767 } else {
1768 this.requests[options.unique_id] = request;
1769 this.debounceSendBatch();
1770 }
1771 return options.deferred;
1772 }
1773 }, {
1774 key: "sendBatch",
1775 value: function sendBatch(requests) {
1776 var actions = {};
1777 if (!requests) {
1778 requests = this.requests;
1779
1780 // Empty for next batch.
1781 this.requests = {};
1782 }
1783 Object.entries(requests).forEach(function (_ref) {
1784 var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
1785 id = _ref2[0],
1786 request = _ref2[1];
1787 return actions[id] = {
1788 action: request.action,
1789 data: request.options.data
1790 };
1791 });
1792 return this.send('ajax', {
1793 data: {
1794 actions: JSON.stringify(actions)
1795 },
1796 success: function success(data) {
1797 Object.entries(data.responses).forEach(function (_ref3) {
1798 var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
1799 id = _ref4[0],
1800 response = _ref4[1];
1801 var options = requests[id].options;
1802 if (options) {
1803 if (response.success) {
1804 options.deferred.resolve(response.data);
1805 } else if (!response.success) {
1806 options.deferred.reject(response.data);
1807 }
1808 }
1809 });
1810 },
1811 error: function error(data) {
1812 return Object.values(requests).forEach(function (args) {
1813 if (args.options) {
1814 args.options.deferred.reject(data);
1815 }
1816 });
1817 }
1818 });
1819 }
1820 }, {
1821 key: "prepareSend",
1822 value: function prepareSend(action, options) {
1823 var _this4 = this;
1824 var settings = this.getSettings(),
1825 ajaxParams = elementorCommon.helpers.cloneObject(settings.ajaxParams);
1826 options = options || {};
1827 action = settings.actionPrefix + action;
1828 jQuery.extend(ajaxParams, options);
1829 var requestConstants = elementorCommon.helpers.cloneObject(this.requestConstants);
1830 requestConstants.action = action;
1831 var isFormData = ajaxParams.data instanceof FormData;
1832 Object.entries(requestConstants).forEach(function (_ref5) {
1833 var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
1834 key = _ref6[0],
1835 value = _ref6[1];
1836 if (isFormData) {
1837 ajaxParams.data.append(key, value);
1838 } else {
1839 ajaxParams.data[key] = value;
1840 }
1841 });
1842 var successCallback = ajaxParams.success,
1843 errorCallback = ajaxParams.error;
1844 if (successCallback || errorCallback) {
1845 ajaxParams.success = function (response) {
1846 if (response.success && successCallback) {
1847 successCallback(response.data);
1848 }
1849 if (!response.success && errorCallback) {
1850 errorCallback(response.data);
1851 }
1852 };
1853 if (errorCallback) {
1854 ajaxParams.error = function (data) {
1855 return errorCallback(data);
1856 };
1857 } else {
1858 ajaxParams.error = function (xmlHttpRequest) {
1859 if (xmlHttpRequest.readyState || 'abort' !== xmlHttpRequest.statusText) {
1860 _this4.trigger('request:unhandledError', xmlHttpRequest);
1861 }
1862 };
1863 }
1864 }
1865 return ajaxParams;
1866 }
1867 }, {
1868 key: "send",
1869 value: function send(action, options) {
1870 return jQuery.ajax(this.prepareSend(action, options));
1871 }
1872 }, {
1873 key: "addRequestCache",
1874 value: function addRequestCache(request, data) {
1875 var cacheKey = this.getCacheKey(request);
1876 this.cache[cacheKey] = data;
1877 }
1878 }, {
1879 key: "invalidateCache",
1880 value: function invalidateCache(request) {
1881 var cacheKey = this.getCacheKey(request);
1882 delete this.cache[cacheKey];
1883 }
1884 }]);
1885 }(elementorModules.Module);
1886
1887 /***/ }),
1888
1889 /***/ "../core/common/modules/connect/assets/js/connect.js":
1890 /*!***********************************************************!*\
1891 !*** ../core/common/modules/connect/assets/js/connect.js ***!
1892 \***********************************************************/
1893 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1894
1895 "use strict";
1896 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
1897
1898
1899 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1900 Object.defineProperty(exports, "__esModule", ({
1901 value: true
1902 }));
1903 exports["default"] = void 0;
1904 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1905 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1906 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1907 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1908 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
1909 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1910 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)); }
1911 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1912 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; }
1913 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Vie) {
1914 function _default() {
1915 (0, _classCallCheck2.default)(this, _default);
1916 return _callSuper(this, _default, arguments);
1917 }
1918 (0, _inherits2.default)(_default, _elementorModules$Vie);
1919 return (0, _createClass2.default)(_default, [{
1920 key: "addPopupPlugin",
1921 value: function addPopupPlugin() {
1922 var counter = 0;
1923 jQuery.fn.elementorConnect = function (options) {
1924 var _this = this;
1925 // Open the Connect Dialog in a popup window.
1926 if (options !== null && options !== void 0 && options.popup) {
1927 jQuery(this).on('click', function (event) {
1928 var _options$popup, _options$popup2;
1929 event.preventDefault();
1930 var width = ((_options$popup = options.popup) === null || _options$popup === void 0 ? void 0 : _options$popup.width) || 600,
1931 height = ((_options$popup2 = options.popup) === null || _options$popup2 === void 0 ? void 0 : _options$popup2.height) || 700;
1932 window.open(jQuery(_this).attr('href') + '&mode=popup', 'elementorConnect', "toolbar=no, menubar=no, width=".concat(width, ", height=").concat(height, ", top=200, left=0"));
1933 });
1934 delete options.popup;
1935 }
1936 var settings = jQuery.extend({
1937 // These are the defaults.
1938 success: function success() {
1939 return location.reload();
1940 },
1941 error: function error() {
1942 elementor.notifications.showToast({
1943 message: __('Unable to connect', 'elementor')
1944 });
1945 },
1946 parseUrl: function parseUrl(url) {
1947 return url;
1948 } // Allow to change the url, e.g: replace placeholders like '%%template_type%%' with actual value.
1949 }, options);
1950 this.each(function () {
1951 counter++;
1952 var $this = jQuery(this),
1953 callbackId = 'cb' + counter;
1954 $this.attr({
1955 target: '_blank',
1956 rel: 'opener',
1957 href: settings.parseUrl($this.attr('href') + '&mode=popup&callback_id=' + callbackId)
1958 });
1959 elementorCommon.elements.$window.on('elementor/connect/success/' + callbackId, settings.success).on('elementor/connect/error/' + callbackId, settings.error);
1960 });
1961 return this;
1962 };
1963 }
1964 }, {
1965 key: "getDefaultSettings",
1966 value: function getDefaultSettings() {
1967 return {
1968 selectors: {
1969 connectButton: '#elementor-template-library-connect__button'
1970 }
1971 };
1972 }
1973 }, {
1974 key: "getDefaultElements",
1975 value: function getDefaultElements() {
1976 return {
1977 $connectButton: jQuery(this.getSettings('selectors.connectButton'))
1978 };
1979 }
1980 }, {
1981 key: "applyPopup",
1982 value: function applyPopup() {
1983 this.elements.$connectButton.elementorConnect();
1984 }
1985 }, {
1986 key: "onInit",
1987 value: function onInit() {
1988 _superPropGet(_default, "onInit", this, 3)([]);
1989 this.addPopupPlugin();
1990 this.applyPopup();
1991 }
1992 }]);
1993 }(elementorModules.ViewModule);
1994
1995 /***/ }),
1996
1997 /***/ "../core/common/modules/event-tracker/assets/js/data/commands-data/index.js":
1998 /*!**********************************************************************************!*\
1999 !*** ../core/common/modules/event-tracker/assets/js/data/commands-data/index.js ***!
2000 \**********************************************************************************/
2001 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2002
2003 "use strict";
2004
2005
2006 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2007 Object.defineProperty(exports, "__esModule", ({
2008 value: true
2009 }));
2010 exports.Index = void 0;
2011 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2012 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2013 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2014 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2015 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2016 var _commandData = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-data */ "../modules/web-cli/assets/js/modules/command-data.js"));
2017 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)); }
2018 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2019 var Index = exports.Index = /*#__PURE__*/function (_CommandData) {
2020 function Index() {
2021 (0, _classCallCheck2.default)(this, Index);
2022 return _callSuper(this, Index, arguments);
2023 }
2024 (0, _inherits2.default)(Index, _CommandData);
2025 return (0, _createClass2.default)(Index, null, [{
2026 key: "getEndpointFormat",
2027 value: function getEndpointFormat() {
2028 return 'send-event';
2029 }
2030 }]);
2031 }(_commandData.default);
2032
2033 /***/ }),
2034
2035 /***/ "../core/common/modules/event-tracker/assets/js/data/component.js":
2036 /*!************************************************************************!*\
2037 !*** ../core/common/modules/event-tracker/assets/js/data/component.js ***!
2038 \************************************************************************/
2039 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2040
2041 "use strict";
2042
2043
2044 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2045 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
2046 Object.defineProperty(exports, "__esModule", ({
2047 value: true
2048 }));
2049 exports["default"] = void 0;
2050 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2051 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2052 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2053 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2054 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2055 var _componentBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/component-base */ "../modules/web-cli/assets/js/modules/component-base.js"));
2056 var commandsData = _interopRequireWildcard(__webpack_require__(/*! ./commands-data/ */ "../core/common/modules/event-tracker/assets/js/data/commands-data/index.js"));
2057 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); }
2058 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)); }
2059 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2060 var Component = exports["default"] = /*#__PURE__*/function (_ComponentBase) {
2061 function Component() {
2062 (0, _classCallCheck2.default)(this, Component);
2063 return _callSuper(this, Component, arguments);
2064 }
2065 (0, _inherits2.default)(Component, _ComponentBase);
2066 return (0, _createClass2.default)(Component, [{
2067 key: "getNamespace",
2068 value: function getNamespace() {
2069 return 'event-tracker';
2070 }
2071 }, {
2072 key: "defaultData",
2073 value: function defaultData() {
2074 return this.importCommands(commandsData);
2075 }
2076 }]);
2077 }(_componentBase.default);
2078
2079 /***/ }),
2080
2081 /***/ "../core/common/modules/event-tracker/assets/js/events.js":
2082 /*!****************************************************************!*\
2083 !*** ../core/common/modules/event-tracker/assets/js/events.js ***!
2084 \****************************************************************/
2085 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2086
2087 "use strict";
2088
2089
2090 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2091 Object.defineProperty(exports, "__esModule", ({
2092 value: true
2093 }));
2094 exports["default"] = void 0;
2095 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2096 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2097 var _time = _interopRequireDefault(__webpack_require__(/*! elementor-utils/time */ "../assets/dev/js/utils/time.js"));
2098 var Events = exports["default"] = /*#__PURE__*/function () {
2099 function Events() {
2100 (0, _classCallCheck2.default)(this, Events);
2101 }
2102 return (0, _createClass2.default)(Events, [{
2103 key: "dispatchEvent",
2104 value: function dispatchEvent(eventData) {
2105 if (!eventData) {
2106 return;
2107 }
2108 eventData.ts = (0, _time.default)();
2109
2110 // No need to wait for response, no need to block browser in any way.
2111 $e.data.create('event-tracker/index', {
2112 event_data: eventData
2113 });
2114 }
2115 }]);
2116 }();
2117
2118 /***/ }),
2119
2120 /***/ "../core/common/modules/events-manager/assets/js/events-config.js":
2121 /*!************************************************************************!*\
2122 !*** ../core/common/modules/events-manager/assets/js/events-config.js ***!
2123 \************************************************************************/
2124 /***/ ((__unused_webpack_module, exports) => {
2125
2126 "use strict";
2127
2128
2129 Object.defineProperty(exports, "__esModule", ({
2130 value: true
2131 }));
2132 exports["default"] = void 0;
2133 var eventsConfig = {
2134 appTypes: {
2135 editor: 'editor',
2136 wpAdmin: 'wpadmin'
2137 },
2138 targetTypes: {
2139 dropdownItem: 'dropdown_item',
2140 button: 'button',
2141 tab: 'tab',
2142 toggle: 'toggle',
2143 searchInput: 'search_input',
2144 searchResult: 'search_result',
2145 buttons: 'buttons',
2146 searchWidget: 'search_widget'
2147 },
2148 interactionResults: {
2149 actionSelected: 'action_selected',
2150 navigate: 'navigate',
2151 create: 'create',
2152 sessionEnd: 'session_end',
2153 tabChanged: 'tab_changed',
2154 assetInserted: 'asset_inserted',
2155 assetFavorite: 'asset_favorite',
2156 aiGenerate: 'ai_generate',
2157 resultsUpdated: 'results_updated',
2158 noResults: 'no_results',
2159 selected: 'selected',
2160 promotionViewed: 'promotion_viewed',
2161 upgradeNow: 'upgrade_now'
2162 },
2163 targetNames: {
2164 publishDropdown: {
2165 saveDraft: 'save_draft',
2166 saveAsTemplate: 'save_as_template',
2167 viewPage: 'view_page',
2168 copyAndShare: 'copy_and_share'
2169 },
2170 pageList: {
2171 addNewPage: 'add_new_page'
2172 }
2173 },
2174 triggers: {
2175 click: 'Click',
2176 rightClick: 'Right Click',
2177 doubleClick: 'Double Click',
2178 accordionClick: 'Accordion Click',
2179 toggleClick: 'Toggle Click',
2180 dropdownClick: 'Click Dropdown',
2181 editorLoaded: 'Editor Loaded',
2182 visible: 'Visible',
2183 pageLoaded: 'Page Loaded',
2184 typing: 'Typing',
2185 tabSelect: 'Tab Select',
2186 insert: 'Insert'
2187 },
2188 locations: {
2189 widgetPanel: 'Widget Panel',
2190 topBar: 'Top Bar',
2191 sidebar: 'Sidebar',
2192 elementorEditor: 'Elementor Editor',
2193 templatesLibrary: {
2194 library: 'Templates Library'
2195 },
2196 app: {
2197 import: 'Import Kit',
2198 export: 'Export Kit',
2199 kitLibrary: 'Kit Library',
2200 cloudKitLibrary: 'Cloud Kit Library'
2201 },
2202 variables: 'Variables Panel',
2203 variablesManager: 'Variables Manager',
2204 admin: 'WP admin',
2205 structurePanel: 'Structure Panel',
2206 canvas: 'Canvas',
2207 leftPanel: 'Left Panel',
2208 elementorLibrary: 'Elementor Library',
2209 components: {
2210 instanceEditingPanel: 'Instance Editing Panel'
2211 }
2212 },
2213 secondaryLocations: {
2214 layout: 'Layout Section',
2215 basic: 'Basic Section',
2216 'pro-elements': 'Pro Section',
2217 general: 'General Section',
2218 'theme-elements': 'Site Section',
2219 'theme-elements-single': 'Single Section',
2220 'woocommerce-elements': 'WooCommerce Section',
2221 wordpress: 'WordPress Section',
2222 categories: 'Widgets Tab',
2223 global: 'Globals Tab',
2224 'whats-new': 'What\'s New',
2225 'document-settings': 'Document Settings icon',
2226 'preview-page': 'Preview Page',
2227 'publish-button': 'Publish Button',
2228 'widget-panel': 'Widget Panel Icon',
2229 finder: 'Finder',
2230 help: 'Help',
2231 elementorLogoDropdown: 'top_bar_elementor_logo_dropdown',
2232 elementorLogo: 'Elementor Logo',
2233 eLogoMenu: 'E-logo Menu',
2234 notes: 'Notes',
2235 siteSettings: 'Site Settings',
2236 structure: 'Structure',
2237 documentNameDropdown: 'Document Name dropdown',
2238 responsiveControls: 'Responsive controls',
2239 launchpad: 'launchpad',
2240 checklistHeader: 'Checklist Header',
2241 checklistSteps: 'Checklist Steps',
2242 userPreferences: 'User Preferences',
2243 contextMenu: 'Context Menu',
2244 templateLibrary: {
2245 saveModal: 'Save to Modal',
2246 moveModal: 'Move to Modal',
2247 bulkMoveModal: 'Bulk Move to Modal',
2248 copyModal: 'Copy to Modal',
2249 bulkCopyModal: 'Bulk Copy to Modal',
2250 saveModalSelectFolder: 'Save to Modal - select folder',
2251 saveModalSelectConnect: 'Save to Modal - connect',
2252 saveModalSelectUpgrade: 'Save to Modal - upgrade',
2253 importModal: 'Import Modal',
2254 newFolderModal: 'New Folder Modal',
2255 deleteDialog: 'Delete Dialog',
2256 deleteFolderDialog: 'Delete Folder Dialog',
2257 renameDialog: 'Rename Dialog',
2258 createFolderDialog: 'Create Folder Dialog',
2259 applySettingsDialog: 'Apply Settings Dialog',
2260 cloudTab: 'Cloud Tab',
2261 siteTab: 'Site Tab',
2262 cloudTabFolder: 'Cloud Tab - Folder',
2263 cloudTabConnect: 'Cloud Tab - Connect',
2264 cloudTabUpgrade: 'Cloud Tab - Upgrade',
2265 morePopup: 'Context Menu',
2266 quotaBar: 'Quota Bar'
2267 },
2268 kitLibrary: {
2269 cloudKitLibrary: 'kits_cloud_library',
2270 cloudKitLibraryConnect: 'kits_cloud_library_connect',
2271 cloudKitLibraryUpgrade: 'kits_cloud_library_upgrade',
2272 kitExportCustomization: 'kit_export_customization',
2273 kitExport: 'kit_export',
2274 kitExportCustomizationEdit: 'kit_export_customization_edit',
2275 kitExportSummary: 'kit_export_summary',
2276 kitImportUploadBox: 'kit_import_upload_box',
2277 kitImportCustomization: 'kit_import_customization',
2278 kitImportSummary: 'kit_import_summary'
2279 },
2280 variablesPopover: 'Variables Popover',
2281 admin: {
2282 pluginToolsTab: 'plugin_tools_tab',
2283 pluginWebsiteTemplatesTab: 'plugin_website_templates_tab'
2284 },
2285 componentsTab: 'Components Tab',
2286 canvasElement: 'Canvas Element',
2287 publishDropdown: 'Publish Dropdown',
2288 pageListDropdown: 'Page List Dropdown',
2289 emptyBox: 'Empty Box',
2290 searchBar: 'Search Bar',
2291 finderResults: 'Finder Results',
2292 libraryTabs: 'Library Tabs',
2293 assetCard: 'Asset Card'
2294 },
2295 elements: {
2296 accordionSection: 'Accordion section',
2297 buttonIcon: 'Button Icon',
2298 mainCta: 'Main CTA',
2299 button: 'Button',
2300 link: 'Link',
2301 dropdown: 'Dropdown',
2302 toggle: 'Toggle',
2303 launchpadChecklist: 'Checklist popup'
2304 },
2305 names: {
2306 v1: {
2307 layout: 'v1_widgets_tab_layout_section',
2308 basic: 'v1_widgets_tab_basic_section',
2309 'pro-elements': 'v1_widgets_tab_pro_section',
2310 general: 'v1_widgets_tab_general_section',
2311 'theme-elements': 'v1_widgets_tab_site_section',
2312 'theme-elements-single': 'v1_widgets_tab_single_section',
2313 'woocommerce-elements': 'v1_widgets_tab_woocommerce_section',
2314 wordpress: 'v1_widgets_tab_wordpress_section',
2315 categories: 'v1_widgets_tab',
2316 global: 'v1_globals_tab'
2317 },
2318 topBar: {
2319 whatsNew: 'top_bar_whats_new',
2320 documentSettings: 'top_bar_document_settings_icon',
2321 previewPage: 'top_bar_preview_page',
2322 publishButton: 'top_bar_publish_button',
2323 widgetPanel: 'top_bar_widget_panel_icon',
2324 finder: 'top_bar_finder',
2325 help: 'top_bar_help',
2326 history: 'top_bar_elementor_logo_dropdown_history',
2327 userPreferences: 'top_bar_elementor_logo_dropdown_user_preferences',
2328 keyboardShortcuts: 'top_bar_elementor_logo_dropdown_keyboard_shortcuts',
2329 exitToWordpress: 'top_bar_elementor_logo_dropdown_exit_to_wordpress',
2330 themeBuilder: 'top_bar_elementor_logo_dropdown_theme_builder',
2331 notes: 'top_bar_notes',
2332 siteSettings: 'top_bar_site_setting',
2333 structure: 'top_bar_structure',
2334 documentNameDropdown: 'top_bar_document_name_dropdown',
2335 responsiveControls: 'top_bar_responsive_controls',
2336 launchpadOn: 'top_bar_checklist_icon_show',
2337 launchpadOff: 'top_bar_checklist_icon_hide',
2338 elementorLogoDropdown: 'open_e_menu',
2339 connectAccount: 'connect_account',
2340 accountConnected: 'account_connected'
2341 },
2342 // ChecklistSteps event names are generated dynamically, based on stepId and action type taken: title, action, done, undone, upgrade
2343 elementorEditor: {
2344 editorLoaded: 'editor_loaded',
2345 checklist: {
2346 checklistHeaderClose: 'checklist_header_close_icon',
2347 checklistFirstPopup: 'checklist popup triggered'
2348 },
2349 userPreferences: {
2350 checklistShow: 'checklist_userpreferences_toggle_show',
2351 checklistHide: 'checklist_userpreferences_toggle_hide'
2352 }
2353 },
2354 variables: {
2355 open: 'open_variables_popover',
2356 add: 'add_new_variable',
2357 connect: 'connect_variable',
2358 save: 'save_new_variable',
2359 openManager: 'open_variables_manager',
2360 saveChanges: 'save_variables_changes',
2361 delete: 'delete_variable',
2362 variableSyncToV3: 'variable_sync_to_v3'
2363 },
2364 design_system: {
2365 importOpened: 'design_system_import_opened',
2366 fileSelected: 'design_system_file_selected',
2367 validationFailed: 'design_system_validation_failed',
2368 conflictChoice: 'design_system_conflict_choice',
2369 confirmed: 'design_system_import_confirmed',
2370 imported: 'design_system_imported',
2371 importFailed: 'design_system_import_failed'
2372 },
2373 components: {
2374 createClicked: 'component_create_clicked',
2375 createCancelled: 'component_creation_cancelled',
2376 created: 'component_created',
2377 instanceAdded: 'component_instance_added',
2378 edited: 'component_edited',
2379 propertiesPanelOpened: 'component_properties_panel_opened',
2380 propertiesGroupCreated: 'component_properties_group_created',
2381 propertyExposed: 'component_property_exposed',
2382 propertyRemoved: 'component_property_removed',
2383 detached: 'component_detached'
2384 },
2385 global_classes: {
2386 classApplied: 'class_applied',
2387 classRemoved: 'class_removed',
2388 classManagerFilterCleared: 'class_manager_filter_cleared',
2389 classDeleted: 'class_deleted',
2390 classPublishConflict: 'class_publish_conflict',
2391 classRenamed: 'class_renamed',
2392 classCreated: 'class_created',
2393 classManagerSearched: 'class_manager_searched',
2394 classManagerFiltersOpened: 'class_manager_filters_opened',
2395 classManagerOpened: 'class_manager_opened',
2396 classManagerReorder: 'class_manager_reorder',
2397 classManagerFilterUsed: 'class_manager_filter_used',
2398 classUsageLocate: 'class_usage_locate',
2399 classUsageHovered: 'class_usage_hovered',
2400 classStyled: 'class_styled',
2401 classStateClicked: 'class_state_clicked',
2402 classUsageClicked: 'class_usage_clicked',
2403 classDuplicate: 'class_duplicate',
2404 classSyncToV3PopupShown: 'class_sync_to_v3_popup_shown',
2405 classSyncToV3: 'class_sync_to_v3',
2406 classSyncToV3PopupClick: 'class_sync_to_v3_popup_click'
2407 },
2408 editorOne: {
2409 topBarPublishDropdown: 'top_bar_publish_dropdown',
2410 topBarPageList: 'top_bar_page_list',
2411 siteSettingsSession: 'site_settings_session',
2412 eLibraryNav: 'e_library_nav',
2413 eLibraryInsert: 'e_library_insert',
2414 eLibraryFavorite: 'e_library_favorite',
2415 eLibraryGenerateAi: 'e_library_generate_ai',
2416 finderSearchInput: 'finder_search_input',
2417 finderResultSelect: 'finder_result_select',
2418 canvasEmptyBoxAction: 'canvas_empty_box_action',
2419 widgetPanelSearch: 'widget_panel_search'
2420 },
2421 interactions: {
2422 created: 'interactions_created'
2423 },
2424 promotions: {
2425 viewPromotion: 'view_promotion',
2426 upgradePromotionClick: 'upgrade_promotion_click'
2427 }
2428 }
2429 };
2430 var _default = exports["default"] = eventsConfig;
2431
2432 /***/ }),
2433
2434 /***/ "../core/common/modules/events-manager/assets/js/module.js":
2435 /*!*****************************************************************!*\
2436 !*** ../core/common/modules/events-manager/assets/js/module.js ***!
2437 \*****************************************************************/
2438 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2439
2440 "use strict";
2441
2442
2443 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2444 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
2445 Object.defineProperty(exports, "__esModule", ({
2446 value: true
2447 }));
2448 exports["default"] = void 0;
2449 var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "../node_modules/@babel/runtime/regenerator/index.js"));
2450 var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "../node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
2451 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2452 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2453 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2454 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2455 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2456 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
2457 var _eventsConfig = _interopRequireDefault(__webpack_require__(/*! ./events-config */ "../core/common/modules/events-manager/assets/js/events-config.js"));
2458 var _mixpanelBrowser = _interopRequireWildcard(__webpack_require__(/*! mixpanel-browser */ "../node_modules/mixpanel-browser/dist/mixpanel.module.js"));
2459 var _tiers = __webpack_require__(/*! elementor-utils/tiers */ "../assets/dev/js/utils/tiers.js");
2460 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); }
2461 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; }
2462 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; }
2463 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)); }
2464 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2465 /** @type {Mixpanel | null} */
2466 var mixpanelInstance = null;
2467 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
2468 function _default() {
2469 var _this;
2470 (0, _classCallCheck2.default)(this, _default);
2471 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2472 args[_key] = arguments[_key];
2473 }
2474 _this = _callSuper(this, _default, [].concat(args));
2475 (0, _defineProperty2.default)(_this, "trackingEnabled", false);
2476 (0, _defineProperty2.default)(_this, "availableExperiments", []);
2477 return _this;
2478 }
2479 (0, _inherits2.default)(_default, _elementorModules$Mod);
2480 return (0, _createClass2.default)(_default, [{
2481 key: "onInit",
2482 value: function onInit() {
2483 var _this2 = this;
2484 this.config = _eventsConfig.default;
2485 if (!this.canSendEvents()) {
2486 return;
2487 }
2488 this.initializeMixpanel(function () {
2489 return _this2.enableTracking();
2490 });
2491 }
2492 }, {
2493 key: "initializeMixpanel",
2494 value: function initializeMixpanel(onLoaded) {
2495 if (mixpanelInstance && mixpanelInstance.isInitialized) {
2496 onLoaded(mixpanelInstance);
2497 } else {
2498 var _elementorCommon$conf, _elementorCommon$conf2, _elementorCommon$conf3, _elementorCommon$conf4, _elementorCommon$conf5;
2499 mixpanelInstance = _mixpanelBrowser.default.init((_elementorCommon$conf = elementorCommon.config.editor_events) === null || _elementorCommon$conf === void 0 ? void 0 : _elementorCommon$conf.token, {
2500 persistence: 'localStorage',
2501 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,
2502 autocapture: false,
2503 flags: true,
2504 api_host: 'https://api-eu.mixpanel.com',
2505 loaded: onLoaded,
2506 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,
2507 record_idle_timeout_ms: 60 * 1000,
2508 // 60 Seconds
2509 record_min_ms: 5 * 1000,
2510 // 5 Seconds
2511 record_mask_text_selector: '',
2512 remote_settings_mode: 'strict'
2513 }, 'elementor-editor');
2514 }
2515 elementorCommon.config.editor_events.mixpanelInstance = mixpanelInstance;
2516 }
2517 }, {
2518 key: "enableTracking",
2519 value: function enableTracking() {
2520 var _elementorCommon$conf6;
2521 if (!this.isMixpanelReady()) {
2522 return;
2523 }
2524 var userId = (_elementorCommon$conf6 = elementorCommon.config.editor_events) === null || _elementorCommon$conf6 === void 0 ? void 0 : _elementorCommon$conf6.user_id;
2525 mixpanelInstance.register({
2526 appType: 'Editor'
2527 });
2528 if (userId) {
2529 var _elementorCommon$conf7;
2530 mixpanelInstance.identify(userId);
2531 mixpanelInstance.people.set_once({
2532 $user_id: userId,
2533 $last_login: new Date().toISOString(),
2534 $plan_type: ((_elementorCommon$conf7 = elementorCommon.config.library_connect) === null || _elementorCommon$conf7 === void 0 ? void 0 : _elementorCommon$conf7.plan_type) || _tiers.TIERS.free
2535 });
2536 }
2537 this.trackingEnabled = true;
2538 this.availableExperiments = Object.keys(elementorCommon.config.experimentalFeatures || {});
2539 }
2540 }, {
2541 key: "dispatchEvent",
2542 value: function dispatchEvent(name, data) {
2543 var _elementorCommon$conf8, _elementorCommon$conf9, _elementorCommon$conf0, _elementorCommon$conf1, _elementorCommon$conf10, _elementorCommon$conf11, _elementorCommon$conf12, _elementorCommon$conf13, _elementorCommon$conf14;
2544 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2545 if (!this.canSendEvents()) {
2546 return;
2547 }
2548 if (!this.trackingEnabled) {
2549 this.enableTracking();
2550 }
2551 var eventData = _objectSpread({
2552 user_id: ((_elementorCommon$conf8 = elementorCommon.config.editor_events) === null || _elementorCommon$conf8 === void 0 ? void 0 : _elementorCommon$conf8.user_id) || null,
2553 user_roles: ((_elementorCommon$conf9 = elementorCommon.config.library_connect) === null || _elementorCommon$conf9 === void 0 ? void 0 : _elementorCommon$conf9.user_roles) || [],
2554 subscription_id: ((_elementorCommon$conf0 = elementorCommon.config.editor_events) === null || _elementorCommon$conf0 === void 0 ? void 0 : _elementorCommon$conf0.subscription_id) || null,
2555 user_tier: ((_elementorCommon$conf1 = elementorCommon.config.library_connect) === null || _elementorCommon$conf1 === void 0 ? void 0 : _elementorCommon$conf1.current_access_tier) || null,
2556 url: (_elementorCommon$conf10 = elementorCommon.config.editor_events) === null || _elementorCommon$conf10 === void 0 ? void 0 : _elementorCommon$conf10.site_url,
2557 wp_version: (_elementorCommon$conf11 = elementorCommon.config.editor_events) === null || _elementorCommon$conf11 === void 0 ? void 0 : _elementorCommon$conf11.wp_version,
2558 client_id: (_elementorCommon$conf12 = elementorCommon.config.editor_events) === null || _elementorCommon$conf12 === void 0 ? void 0 : _elementorCommon$conf12.site_key,
2559 app_version: (_elementorCommon$conf13 = elementorCommon.config.editor_events) === null || _elementorCommon$conf13 === void 0 ? void 0 : _elementorCommon$conf13.elementor_version,
2560 site_language: (_elementorCommon$conf14 = elementorCommon.config.editor_events) === null || _elementorCommon$conf14 === void 0 ? void 0 : _elementorCommon$conf14.site_language,
2561 experiments: this.availableExperiments
2562 }, data);
2563 mixpanelInstance.track(name, eventData, options);
2564 }
2565 }, {
2566 key: "featureFlagIsActive",
2567 value: function () {
2568 var _featureFlagIsActive = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(flagName) {
2569 var _mixpanelInstance;
2570 var isEnabled;
2571 return _regenerator.default.wrap(function (_context) {
2572 while (1) switch (_context.prev = _context.next) {
2573 case 0:
2574 if (!('function' !== typeof ((_mixpanelInstance = mixpanelInstance) === null || _mixpanelInstance === void 0 || (_mixpanelInstance = _mixpanelInstance.flags) === null || _mixpanelInstance === void 0 ? void 0 : _mixpanelInstance.is_enabled))) {
2575 _context.next = 1;
2576 break;
2577 }
2578 return _context.abrupt("return", false);
2579 case 1:
2580 _context.next = 2;
2581 return mixpanelInstance.flags.is_enabled(flagName, false);
2582 case 2:
2583 isEnabled = _context.sent;
2584 return _context.abrupt("return", true === isEnabled);
2585 case 3:
2586 case "end":
2587 return _context.stop();
2588 }
2589 }, _callee);
2590 }));
2591 function featureFlagIsActive(_x) {
2592 return _featureFlagIsActive.apply(this, arguments);
2593 }
2594 return featureFlagIsActive;
2595 }()
2596 }, {
2597 key: "getExperimentVariant",
2598 value: function () {
2599 var _getExperimentVariant = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2(experimentName) {
2600 var defaultValue,
2601 _elementorCommon$conf15,
2602 _elementorCommon$conf16,
2603 isAbTestingEnabled,
2604 variant,
2605 _args2 = arguments,
2606 _t;
2607 return _regenerator.default.wrap(function (_context2) {
2608 while (1) switch (_context2.prev = _context2.next) {
2609 case 0:
2610 defaultValue = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : 'control';
2611 _context2.prev = 1;
2612 if (this.canSendEvents()) {
2613 _context2.next = 2;
2614 break;
2615 }
2616 return _context2.abrupt("return", defaultValue);
2617 case 2:
2618 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;
2619 if (isAbTestingEnabled) {
2620 _context2.next = 3;
2621 break;
2622 }
2623 return _context2.abrupt("return", defaultValue);
2624 case 3:
2625 if (mixpanelInstance) {
2626 _context2.next = 4;
2627 break;
2628 }
2629 return _context2.abrupt("return", defaultValue);
2630 case 4:
2631 if (!this.trackingEnabled) {
2632 this.enableTracking();
2633 }
2634 if (mixpanelInstance.flags) {
2635 _context2.next = 5;
2636 break;
2637 }
2638 return _context2.abrupt("return", defaultValue);
2639 case 5:
2640 if (!('function' !== typeof mixpanelInstance.flags.get_variant_value)) {
2641 _context2.next = 6;
2642 break;
2643 }
2644 return _context2.abrupt("return", defaultValue);
2645 case 6:
2646 _context2.next = 7;
2647 return mixpanelInstance.flags.get_variant_value(experimentName, defaultValue);
2648 case 7:
2649 variant = _context2.sent;
2650 if (!(undefined === variant || null === variant)) {
2651 _context2.next = 8;
2652 break;
2653 }
2654 return _context2.abrupt("return", defaultValue);
2655 case 8:
2656 return _context2.abrupt("return", variant);
2657 case 9:
2658 _context2.prev = 9;
2659 _t = _context2["catch"](1);
2660 return _context2.abrupt("return", defaultValue);
2661 case 10:
2662 case "end":
2663 return _context2.stop();
2664 }
2665 }, _callee2, this, [[1, 9]]);
2666 }));
2667 function getExperimentVariant(_x2) {
2668 return _getExperimentVariant.apply(this, arguments);
2669 }
2670 return getExperimentVariant;
2671 }()
2672 }, {
2673 key: "startExperiment",
2674 value: function startExperiment(experimentName, experimentVariant) {
2675 if (!this.trackingEnabled) {
2676 return;
2677 }
2678 mixpanelInstance.track('$experiment_started', {
2679 'Experiment name': experimentName,
2680 'Variant name': experimentVariant
2681 });
2682 }
2683 }, {
2684 key: "isMixpanelReady",
2685 value: function isMixpanelReady() {
2686 if ('undefined' === typeof mixpanelInstance || !mixpanelInstance) {
2687 return false;
2688 }
2689 try {
2690 var distinctId = mixpanelInstance.get_distinct_id();
2691 return distinctId !== undefined && distinctId !== null;
2692 } catch (error) {
2693 return false;
2694 }
2695 }
2696 }, {
2697 key: "canSendEvents",
2698 value: function canSendEvents() {
2699 var _elementorCommon;
2700 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);
2701 }
2702 }, {
2703 key: "getMixpanelInstance",
2704 value: function getMixpanelInstance() {
2705 return this.isMixpanelReady() ? mixpanelInstance : undefined;
2706 }
2707 }]);
2708 }(elementorModules.Module);
2709
2710 /***/ }),
2711
2712 /***/ "../core/common/modules/finder/assets/js/commands/index.js":
2713 /*!*****************************************************************!*\
2714 !*** ../core/common/modules/finder/assets/js/commands/index.js ***!
2715 \*****************************************************************/
2716 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2717
2718 "use strict";
2719
2720
2721 Object.defineProperty(exports, "__esModule", ({
2722 value: true
2723 }));
2724 Object.defineProperty(exports, "NavigateDown", ({
2725 enumerable: true,
2726 get: function get() {
2727 return _navigateDown.NavigateDown;
2728 }
2729 }));
2730 Object.defineProperty(exports, "NavigateSelect", ({
2731 enumerable: true,
2732 get: function get() {
2733 return _navigateSelect.NavigateSelect;
2734 }
2735 }));
2736 Object.defineProperty(exports, "NavigateUp", ({
2737 enumerable: true,
2738 get: function get() {
2739 return _navigateUp.NavigateUp;
2740 }
2741 }));
2742 var _navigateDown = __webpack_require__(/*! ./navigate-down */ "../core/common/modules/finder/assets/js/commands/navigate-down.js");
2743 var _navigateSelect = __webpack_require__(/*! ./navigate-select */ "../core/common/modules/finder/assets/js/commands/navigate-select.js");
2744 var _navigateUp = __webpack_require__(/*! ./navigate-up */ "../core/common/modules/finder/assets/js/commands/navigate-up.js");
2745
2746 /***/ }),
2747
2748 /***/ "../core/common/modules/finder/assets/js/commands/navigate-down.js":
2749 /*!*************************************************************************!*\
2750 !*** ../core/common/modules/finder/assets/js/commands/navigate-down.js ***!
2751 \*************************************************************************/
2752 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2753
2754 "use strict";
2755
2756
2757 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2758 Object.defineProperty(exports, "__esModule", ({
2759 value: true
2760 }));
2761 exports["default"] = exports.NavigateDown = void 0;
2762 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2763 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2764 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2765 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2766 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2767 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2768 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)); }
2769 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2770 var NavigateDown = exports.NavigateDown = /*#__PURE__*/function (_CommandBase) {
2771 function NavigateDown() {
2772 (0, _classCallCheck2.default)(this, NavigateDown);
2773 return _callSuper(this, NavigateDown, arguments);
2774 }
2775 (0, _inherits2.default)(NavigateDown, _CommandBase);
2776 return (0, _createClass2.default)(NavigateDown, [{
2777 key: "apply",
2778 value: function apply() {
2779 this.component.getItemsView().activateNextItem();
2780 }
2781 }]);
2782 }(_commandBase.default);
2783 var _default = exports["default"] = NavigateDown;
2784
2785 /***/ }),
2786
2787 /***/ "../core/common/modules/finder/assets/js/commands/navigate-select.js":
2788 /*!***************************************************************************!*\
2789 !*** ../core/common/modules/finder/assets/js/commands/navigate-select.js ***!
2790 \***************************************************************************/
2791 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2792
2793 "use strict";
2794
2795
2796 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2797 Object.defineProperty(exports, "__esModule", ({
2798 value: true
2799 }));
2800 exports["default"] = exports.NavigateSelect = void 0;
2801 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2802 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2803 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2804 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2805 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2806 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2807 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)); }
2808 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2809 var NavigateSelect = exports.NavigateSelect = /*#__PURE__*/function (_CommandBase) {
2810 function NavigateSelect() {
2811 (0, _classCallCheck2.default)(this, NavigateSelect);
2812 return _callSuper(this, NavigateSelect, arguments);
2813 }
2814 (0, _inherits2.default)(NavigateSelect, _CommandBase);
2815 return (0, _createClass2.default)(NavigateSelect, [{
2816 key: "apply",
2817 value: function apply(args) {
2818 this.component.getItemsView().goToActiveItem(args);
2819 }
2820 }]);
2821 }(_commandBase.default);
2822 var _default = exports["default"] = NavigateSelect;
2823
2824 /***/ }),
2825
2826 /***/ "../core/common/modules/finder/assets/js/commands/navigate-up.js":
2827 /*!***********************************************************************!*\
2828 !*** ../core/common/modules/finder/assets/js/commands/navigate-up.js ***!
2829 \***********************************************************************/
2830 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2831
2832 "use strict";
2833
2834
2835 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2836 Object.defineProperty(exports, "__esModule", ({
2837 value: true
2838 }));
2839 exports["default"] = exports.NavigateUp = void 0;
2840 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2841 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2842 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2843 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2844 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2845 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2846 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)); }
2847 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2848 var NavigateUp = exports.NavigateUp = /*#__PURE__*/function (_CommandBase) {
2849 function NavigateUp() {
2850 (0, _classCallCheck2.default)(this, NavigateUp);
2851 return _callSuper(this, NavigateUp, arguments);
2852 }
2853 (0, _inherits2.default)(NavigateUp, _CommandBase);
2854 return (0, _createClass2.default)(NavigateUp, [{
2855 key: "apply",
2856 value: function apply() {
2857 this.component.getItemsView().activateNextItem(true);
2858 }
2859 }]);
2860 }(_commandBase.default);
2861 var _default = exports["default"] = NavigateUp;
2862
2863 /***/ }),
2864
2865 /***/ "../core/common/modules/finder/assets/js/component.js":
2866 /*!************************************************************!*\
2867 !*** ../core/common/modules/finder/assets/js/component.js ***!
2868 \************************************************************/
2869 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2870
2871 "use strict";
2872
2873
2874 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2875 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
2876 Object.defineProperty(exports, "__esModule", ({
2877 value: true
2878 }));
2879 exports["default"] = void 0;
2880 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
2881 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2882 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2883 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2884 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2885 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
2886 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2887 var _componentModalBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/component-modal-base */ "../modules/web-cli/assets/js/modules/component-modal-base.js"));
2888 var _layout = _interopRequireDefault(__webpack_require__(/*! ./modal/views/layout */ "../core/common/modules/finder/assets/js/modal/views/layout.js"));
2889 var commands = _interopRequireWildcard(__webpack_require__(/*! ./commands/ */ "../core/common/modules/finder/assets/js/commands/index.js"));
2890 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); }
2891 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; }
2892 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; }
2893 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)); }
2894 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2895 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; }
2896 var Component = exports["default"] = /*#__PURE__*/function (_ComponentModalBase) {
2897 function Component() {
2898 (0, _classCallCheck2.default)(this, Component);
2899 return _callSuper(this, Component, arguments);
2900 }
2901 (0, _inherits2.default)(Component, _ComponentModalBase);
2902 return (0, _createClass2.default)(Component, [{
2903 key: "getNamespace",
2904 value: function getNamespace() {
2905 return 'finder';
2906 }
2907 }, {
2908 key: "defaultShortcuts",
2909 value: function defaultShortcuts() {
2910 var _this = this;
2911 return {
2912 '': {
2913 keys: 'ctrl+e'
2914 },
2915 'navigate-down': {
2916 keys: 'down',
2917 scopes: [this.getNamespace()],
2918 dependency: function dependency() {
2919 return _this.getItemsView();
2920 }
2921 },
2922 'navigate-up': {
2923 keys: 'up',
2924 scopes: [this.getNamespace()],
2925 dependency: function dependency() {
2926 return _this.getItemsView();
2927 }
2928 },
2929 'navigate-select': {
2930 keys: 'enter',
2931 scopes: [this.getNamespace()],
2932 dependency: function dependency() {
2933 return _this.getItemsView().$activeItem;
2934 }
2935 }
2936 };
2937 }
2938 }, {
2939 key: "defaultCommands",
2940 value: function defaultCommands() {
2941 var modalCommands = _superPropGet(Component, "defaultCommands", this, 3)([]);
2942 return _objectSpread(_objectSpread({
2943 'navigate/down': function navigate_down() {
2944 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/down' )", '3.0.0', "$e.run( 'finder/navigate-down' )");
2945 $e.run('finder/navigate-down');
2946 },
2947 'navigate/up': function navigate_up() {
2948 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/up' )", '3.0.0', "$e.run( 'finder/navigate-up' )");
2949 $e.run('finder/navigate-up');
2950 },
2951 'navigate/select': function navigate_select(event) {
2952 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/select', event )", '3.0.0', "$e.run( 'finder/navigate-select', event )");
2953
2954 // TODO: Fix $e.shortcuts use args. ( args.event ).
2955 $e.run('finder/navigate-select', event);
2956 }
2957 }, modalCommands), this.importCommands(commands));
2958 }
2959 }, {
2960 key: "getModalLayout",
2961 value: function getModalLayout() {
2962 return _layout.default;
2963 }
2964 }, {
2965 key: "getItemsView",
2966 value: function getItemsView() {
2967 return this.layout.modalContent.currentView.content.currentView;
2968 }
2969 }]);
2970 }(_componentModalBase.default);
2971
2972 /***/ }),
2973
2974 /***/ "../core/common/modules/finder/assets/js/finder.js":
2975 /*!*********************************************************!*\
2976 !*** ../core/common/modules/finder/assets/js/finder.js ***!
2977 \*********************************************************/
2978 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2979
2980 "use strict";
2981
2982
2983 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2984 Object.defineProperty(exports, "__esModule", ({
2985 value: true
2986 }));
2987 exports["default"] = void 0;
2988 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2989 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2990 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2991 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2992 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2993 var _component = _interopRequireDefault(__webpack_require__(/*! ./component */ "../core/common/modules/finder/assets/js/component.js"));
2994 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
2995 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2996 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
2997 function _default() {
2998 (0, _classCallCheck2.default)(this, _default);
2999 return _callSuper(this, _default, arguments);
3000 }
3001 (0, _inherits2.default)(_default, _elementorModules$Mod);
3002 return (0, _createClass2.default)(_default, [{
3003 key: "onInit",
3004 value: function onInit() {
3005 // TODO: Temp fix, do not load finder in theme-builder.
3006 // Better to pass into '$e' constructor the app owner. ( admin, editor, preview, iframe ).
3007 if (window.top !== window) {
3008 return;
3009 }
3010 this.channel = Backbone.Radio.channel('ELEMENTOR:finder');
3011 $e.components.register(new _component.default({
3012 manager: this
3013 }));
3014 }
3015 }]);
3016 }(elementorModules.Module);
3017
3018 /***/ }),
3019
3020 /***/ "../core/common/modules/finder/assets/js/modal/model/item.js":
3021 /*!*******************************************************************!*\
3022 !*** ../core/common/modules/finder/assets/js/modal/model/item.js ***!
3023 \*******************************************************************/
3024 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3025
3026 "use strict";
3027
3028
3029 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3030 Object.defineProperty(exports, "__esModule", ({
3031 value: true
3032 }));
3033 exports["default"] = void 0;
3034 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3035 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3036 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3037 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3038 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3039 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)); }
3040 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3041 var _default = exports["default"] = /*#__PURE__*/function (_Backbone$Model) {
3042 function _default() {
3043 (0, _classCallCheck2.default)(this, _default);
3044 return _callSuper(this, _default, arguments);
3045 }
3046 (0, _inherits2.default)(_default, _Backbone$Model);
3047 return (0, _createClass2.default)(_default, [{
3048 key: "defaults",
3049 value: function defaults() {
3050 return {
3051 description: '',
3052 icon: 'settings',
3053 url: '',
3054 keywords: [],
3055 actions: [],
3056 lock: null
3057 };
3058 }
3059 }]);
3060 }(Backbone.Model);
3061
3062 /***/ }),
3063
3064 /***/ "../core/common/modules/finder/assets/js/modal/views/categories.js":
3065 /*!*************************************************************************!*\
3066 !*** ../core/common/modules/finder/assets/js/modal/views/categories.js ***!
3067 \*************************************************************************/
3068 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3069
3070 "use strict";
3071
3072
3073 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3074 Object.defineProperty(exports, "__esModule", ({
3075 value: true
3076 }));
3077 exports["default"] = void 0;
3078 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3079 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3080 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3081 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3082 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3083 var _category = _interopRequireDefault(__webpack_require__(/*! ./category */ "../core/common/modules/finder/assets/js/modal/views/category.js"));
3084 var _dynamicCategory = _interopRequireDefault(__webpack_require__(/*! ./dynamic-category */ "../core/common/modules/finder/assets/js/modal/views/dynamic-category.js"));
3085 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)); }
3086 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3087 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$Composite) {
3088 function _default() {
3089 (0, _classCallCheck2.default)(this, _default);
3090 return _callSuper(this, _default, arguments);
3091 }
3092 (0, _inherits2.default)(_default, _Marionette$Composite);
3093 return (0, _createClass2.default)(_default, [{
3094 key: "id",
3095 value: function id() {
3096 return 'elementor-finder__results-container';
3097 }
3098 }, {
3099 key: "ui",
3100 value: function ui() {
3101 this.selectors = {
3102 noResults: '#elementor-finder__no-results',
3103 categoryItem: '.elementor-finder__results__item'
3104 };
3105 return this.selectors;
3106 }
3107 }, {
3108 key: "events",
3109 value: function events() {
3110 return {
3111 'mouseenter @ui.categoryItem': 'onCategoryItemMouseEnter'
3112 };
3113 }
3114 }, {
3115 key: "getTemplate",
3116 value: function getTemplate() {
3117 return '#tmpl-elementor-finder-results-container';
3118 }
3119 }, {
3120 key: "getChildView",
3121 value: function getChildView(childModel) {
3122 return childModel.get('dynamic') ? _dynamicCategory.default : _category.default;
3123 }
3124 }, {
3125 key: "initialize",
3126 value: function initialize() {
3127 this.$activeItem = null;
3128 this.childViewContainer = '#elementor-finder__results';
3129 this.collection = new Backbone.Collection(Object.values(elementorCommon.finder.getSettings('data')));
3130 }
3131 }, {
3132 key: "activateItem",
3133 value: function activateItem($item) {
3134 if (this.$activeItem) {
3135 this.$activeItem.removeClass('elementor-active');
3136 }
3137 $item.addClass('elementor-active');
3138 this.$activeItem = $item;
3139 }
3140 }, {
3141 key: "activateNextItem",
3142 value: function activateNextItem(reverse) {
3143 var $allItems = jQuery(this.selectors.categoryItem);
3144 var nextItemIndex = 0;
3145 if (this.$activeItem) {
3146 nextItemIndex = $allItems.index(this.$activeItem) + (reverse ? -1 : 1);
3147 if (nextItemIndex >= $allItems.length) {
3148 nextItemIndex = 0;
3149 } else if (nextItemIndex < 0) {
3150 nextItemIndex = $allItems.length - 1;
3151 }
3152 }
3153 var $nextItem = $allItems.eq(nextItemIndex);
3154 this.activateItem($nextItem);
3155 $nextItem[0].scrollIntoView({
3156 block: 'nearest'
3157 });
3158 }
3159 }, {
3160 key: "goToActiveItem",
3161 value: function goToActiveItem(event) {
3162 var $a = this.$activeItem.children('a'),
3163 isControlClicked = $e.shortcuts.isControlEvent(event);
3164 if (isControlClicked) {
3165 $a.attr('target', '_blank');
3166 }
3167 $a[0].click();
3168 if (isControlClicked) {
3169 $a.removeAttr('target');
3170 }
3171 }
3172 }, {
3173 key: "onCategoryItemMouseEnter",
3174 value: function onCategoryItemMouseEnter(event) {
3175 this.activateItem(jQuery(event.currentTarget));
3176 }
3177 }, {
3178 key: "onChildviewToggleVisibility",
3179 value: function onChildviewToggleVisibility() {
3180 var allCategoriesAreEmpty = this.children.every(function (child) {
3181 return !child.isVisible;
3182 });
3183 this.ui.noResults.toggle(allCategoriesAreEmpty);
3184 }
3185 }]);
3186 }(Marionette.CompositeView);
3187
3188 /***/ }),
3189
3190 /***/ "../core/common/modules/finder/assets/js/modal/views/category.js":
3191 /*!***********************************************************************!*\
3192 !*** ../core/common/modules/finder/assets/js/modal/views/category.js ***!
3193 \***********************************************************************/
3194 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3195
3196 "use strict";
3197
3198
3199 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3200 Object.defineProperty(exports, "__esModule", ({
3201 value: true
3202 }));
3203 exports["default"] = void 0;
3204 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3205 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3206 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3207 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3208 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3209 var _item = _interopRequireDefault(__webpack_require__(/*! ./item */ "../core/common/modules/finder/assets/js/modal/views/item.js"));
3210 var _item2 = _interopRequireDefault(__webpack_require__(/*! ../model/item */ "../core/common/modules/finder/assets/js/modal/model/item.js"));
3211 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)); }
3212 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3213 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$Composite) {
3214 function _default() {
3215 (0, _classCallCheck2.default)(this, _default);
3216 return _callSuper(this, _default, arguments);
3217 }
3218 (0, _inherits2.default)(_default, _Marionette$Composite);
3219 return (0, _createClass2.default)(_default, [{
3220 key: "className",
3221 value: function className() {
3222 return 'elementor-finder__results__category';
3223 }
3224 }, {
3225 key: "getTemplate",
3226 value: function getTemplate() {
3227 return '#tmpl-elementor-finder__results__category';
3228 }
3229 }, {
3230 key: "getChildView",
3231 value: function getChildView() {
3232 return _item.default;
3233 }
3234 }, {
3235 key: "initialize",
3236 value: function initialize() {
3237 this.childViewContainer = '.elementor-finder__results__category__items';
3238 this.isVisible = true;
3239 var items = this.model.get('items');
3240 if (items) {
3241 items = Object.values(items);
3242 }
3243 this.collection = new Backbone.Collection(items, {
3244 model: _item2.default
3245 });
3246 }
3247 }, {
3248 key: "filter",
3249 value: function filter(childModel) {
3250 var textFilter = this.getTextFilter();
3251 if (childModel.get('title').toLowerCase().indexOf(textFilter) >= 0) {
3252 return true;
3253 }
3254 return childModel.get('keywords').some(function (keyword) {
3255 return keyword.indexOf(textFilter) >= 0;
3256 });
3257 }
3258 }, {
3259 key: "getTextFilter",
3260 value: function getTextFilter() {
3261 return elementorCommon.finder.channel.request('filter:text').trim().toLowerCase();
3262 }
3263 }, {
3264 key: "toggleElement",
3265 value: function toggleElement() {
3266 var isCurrentlyVisible = !!this.children.length;
3267 if (isCurrentlyVisible !== this.isVisible) {
3268 this.isVisible = isCurrentlyVisible;
3269 this.$el.toggle(isCurrentlyVisible);
3270 this.triggerMethod('toggle:visibility');
3271 }
3272 }
3273 }, {
3274 key: "onRender",
3275 value: function onRender() {
3276 this.listenTo(elementorCommon.finder.channel, 'filter:change', this.onFilterChange.bind(this));
3277 }
3278 }, {
3279 key: "onFilterChange",
3280 value: function onFilterChange() {
3281 this._renderChildren();
3282 }
3283 }, {
3284 key: "onRenderCollection",
3285 value: function onRenderCollection() {
3286 this.toggleElement();
3287 }
3288 }]);
3289 }(Marionette.CompositeView);
3290
3291 /***/ }),
3292
3293 /***/ "../core/common/modules/finder/assets/js/modal/views/content.js":
3294 /*!**********************************************************************!*\
3295 !*** ../core/common/modules/finder/assets/js/modal/views/content.js ***!
3296 \**********************************************************************/
3297 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3298
3299 "use strict";
3300
3301
3302 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3303 Object.defineProperty(exports, "__esModule", ({
3304 value: true
3305 }));
3306 exports["default"] = void 0;
3307 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3308 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3309 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3310 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3311 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3312 var _categories = _interopRequireDefault(__webpack_require__(/*! ./categories */ "../core/common/modules/finder/assets/js/modal/views/categories.js"));
3313 var _editorOneEvents = __webpack_require__(/*! elementor-editor-utils/editor-one-events */ "../assets/dev/js/editor/utils/editor-one-events.js");
3314 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)); }
3315 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3316 var FINDER_SEARCH_DEBOUNCE_MS = 300;
3317 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$LayoutVie) {
3318 function _default() {
3319 (0, _classCallCheck2.default)(this, _default);
3320 return _callSuper(this, _default, arguments);
3321 }
3322 (0, _inherits2.default)(_default, _Marionette$LayoutVie);
3323 return (0, _createClass2.default)(_default, [{
3324 key: "id",
3325 value: function id() {
3326 return 'elementor-finder';
3327 }
3328 }, {
3329 key: "getTemplate",
3330 value: function getTemplate() {
3331 return '#tmpl-elementor-finder';
3332 }
3333 }, {
3334 key: "ui",
3335 value: function ui() {
3336 return {
3337 searchInput: '#elementor-finder__search__input'
3338 };
3339 }
3340 }, {
3341 key: "events",
3342 value: function events() {
3343 return {
3344 'input @ui.searchInput': 'onSearchInputInput'
3345 };
3346 }
3347 }, {
3348 key: "regions",
3349 value: function regions() {
3350 return {
3351 content: '#elementor-finder__content'
3352 };
3353 }
3354 }, {
3355 key: "initialize",
3356 value: function initialize() {
3357 this.debouncedTrackSearch = (0, _editorOneEvents.createDebouncedFinderSearch)(FINDER_SEARCH_DEBOUNCE_MS);
3358 }
3359 }, {
3360 key: "showCategoriesView",
3361 value: function showCategoriesView() {
3362 this.content.show(new _categories.default());
3363 }
3364 }, {
3365 key: "getResultsCount",
3366 value: function getResultsCount() {
3367 if (!this.content.currentView) {
3368 return 0;
3369 }
3370 var $visibleItems = this.content.currentView.$el.find('.elementor-finder__results__item:visible');
3371 return $visibleItems.length;
3372 }
3373 }, {
3374 key: "onSearchInputInput",
3375 value: function onSearchInputInput() {
3376 var _this = this;
3377 var value = this.ui.searchInput.val();
3378 if (value) {
3379 elementorCommon.finder.channel.reply('filter:text', value).trigger('filter:change');
3380 if (!(this.content.currentView instanceof _categories.default)) {
3381 this.showCategoriesView();
3382 }
3383 setTimeout(function () {
3384 var resultsCount = _this.getResultsCount();
3385 _this.debouncedTrackSearch(resultsCount, value);
3386 }, 50);
3387 }
3388 this.content.currentView.$el.toggle(!!value);
3389 }
3390 }, {
3391 key: "onDestroy",
3392 value: function onDestroy() {
3393 var _this$debouncedTrackS;
3394 if ((_this$debouncedTrackS = this.debouncedTrackSearch) !== null && _this$debouncedTrackS !== void 0 && _this$debouncedTrackS.cancel) {
3395 this.debouncedTrackSearch.cancel();
3396 }
3397 }
3398 }]);
3399 }(Marionette.LayoutView);
3400
3401 /***/ }),
3402
3403 /***/ "../core/common/modules/finder/assets/js/modal/views/dynamic-category.js":
3404 /*!*******************************************************************************!*\
3405 !*** ../core/common/modules/finder/assets/js/modal/views/dynamic-category.js ***!
3406 \*******************************************************************************/
3407 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3408
3409 "use strict";
3410
3411
3412 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3413 Object.defineProperty(exports, "__esModule", ({
3414 value: true
3415 }));
3416 exports["default"] = void 0;
3417 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3418 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3419 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3420 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3421 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
3422 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3423 var _category = _interopRequireDefault(__webpack_require__(/*! ./category */ "../core/common/modules/finder/assets/js/modal/views/category.js"));
3424 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)); }
3425 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3426 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; }
3427 var _default = exports["default"] = /*#__PURE__*/function (_Category) {
3428 function _default() {
3429 (0, _classCallCheck2.default)(this, _default);
3430 return _callSuper(this, _default, arguments);
3431 }
3432 (0, _inherits2.default)(_default, _Category);
3433 return (0, _createClass2.default)(_default, [{
3434 key: "className",
3435 value: function className() {
3436 return _superPropGet(_default, "className", this, 3)([]) + ' elementor-finder__results__category--dynamic';
3437 }
3438 }, {
3439 key: "ui",
3440 value: function ui() {
3441 return {
3442 title: '.elementor-finder__results__category__title'
3443 };
3444 }
3445 }, {
3446 key: "fetchData",
3447 value: function fetchData() {
3448 var _this = this;
3449 this.ui.loadingIcon.show();
3450 elementorCommon.ajax.addRequest('finder_get_category_items', {
3451 data: {
3452 category: this.model.get('name'),
3453 filter: this.getTextFilter()
3454 },
3455 success: function success(data) {
3456 if (_this.isDestroyed) {
3457 return;
3458 }
3459 _this.collection.set(data);
3460 _this.toggleElement();
3461 _this.ui.loadingIcon.hide();
3462 }
3463 });
3464 }
3465 }, {
3466 key: "filter",
3467 value: function filter() {
3468 return true;
3469 }
3470 }, {
3471 key: "onFilterChange",
3472 value: function onFilterChange() {
3473 this.fetchData();
3474 }
3475 }, {
3476 key: "onRender",
3477 value: function onRender() {
3478 _superPropGet(_default, "onRender", this, 3)([]);
3479 this.ui.loadingIcon = jQuery('<i>', {
3480 class: 'eicon-loading eicon-animation-spin'
3481 });
3482 this.ui.title.after(this.ui.loadingIcon);
3483 this.fetchData();
3484 }
3485 }]);
3486 }(_category.default);
3487
3488 /***/ }),
3489
3490 /***/ "../core/common/modules/finder/assets/js/modal/views/item.js":
3491 /*!*******************************************************************!*\
3492 !*** ../core/common/modules/finder/assets/js/modal/views/item.js ***!
3493 \*******************************************************************/
3494 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3495
3496 "use strict";
3497 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
3498
3499
3500 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3501 Object.defineProperty(exports, "__esModule", ({
3502 value: true
3503 }));
3504 exports["default"] = void 0;
3505 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3506 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3507 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3508 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3509 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3510 var _editorOneEvents = __webpack_require__(/*! elementor-editor-utils/editor-one-events */ "../assets/dev/js/editor/utils/editor-one-events.js");
3511 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)); }
3512 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3513 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$ItemView) {
3514 function _default() {
3515 (0, _classCallCheck2.default)(this, _default);
3516 return _callSuper(this, _default, arguments);
3517 }
3518 (0, _inherits2.default)(_default, _Marionette$ItemView);
3519 return (0, _createClass2.default)(_default, [{
3520 key: "className",
3521 value: function className() {
3522 return 'elementor-finder__results__item';
3523 }
3524 }, {
3525 key: "getTemplate",
3526 value: function getTemplate() {
3527 return '#tmpl-elementor-finder__results__item';
3528 }
3529 }, {
3530 key: "events",
3531 value: function events() {
3532 this.$el[0].addEventListener('click', this.onClick.bind(this), true);
3533 }
3534 }, {
3535 key: "trackResultSelect",
3536 value: function trackResultSelect() {
3537 var title = this.model.get('title');
3538 _editorOneEvents.EditorOneEventManager.sendFinderResultSelect(title);
3539 }
3540 }, {
3541 key: "onClick",
3542 value: function onClick(e) {
3543 var _this = this;
3544 var lockOptions = this.model.get('lock');
3545 if (!(lockOptions !== null && lockOptions !== void 0 && lockOptions.is_locked)) {
3546 this.trackResultSelect();
3547 return;
3548 }
3549 e.preventDefault();
3550 e.stopImmediatePropagation();
3551 elementorCommon.dialogsManager.createWidget('confirm', {
3552 id: 'elementor-finder__lock-dialog',
3553 headerMessage: lockOptions.content.heading,
3554 message: lockOptions.content.description,
3555 position: {
3556 my: 'center center',
3557 at: 'center center'
3558 },
3559 strings: {
3560 confirm: lockOptions.button.text,
3561 cancel: __('Cancel', 'elementor')
3562 },
3563 onConfirm: function onConfirm() {
3564 _this.trackResultSelect();
3565 var link = _this.replaceLockLinkPlaceholders(lockOptions.button.url);
3566 window.open(link, '_blank');
3567 }
3568 }).show();
3569 }
3570 }, {
3571 key: "replaceLockLinkPlaceholders",
3572 value: function replaceLockLinkPlaceholders(link) {
3573 return link.replace(/%%utm_source%%/g, 'finder').replace(/%%utm_medium%%/g, 'wp-dash');
3574 }
3575 }]);
3576 }(Marionette.ItemView);
3577
3578 /***/ }),
3579
3580 /***/ "../core/common/modules/finder/assets/js/modal/views/layout.js":
3581 /*!*********************************************************************!*\
3582 !*** ../core/common/modules/finder/assets/js/modal/views/layout.js ***!
3583 \*********************************************************************/
3584 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3585
3586 "use strict";
3587 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
3588
3589
3590 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3591 Object.defineProperty(exports, "__esModule", ({
3592 value: true
3593 }));
3594 exports["default"] = void 0;
3595 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3596 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3597 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3598 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3599 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
3600 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3601 var _content = _interopRequireDefault(__webpack_require__(/*! ./content */ "../core/common/modules/finder/assets/js/modal/views/content.js"));
3602 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)); }
3603 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3604 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; }
3605 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$com) {
3606 function _default() {
3607 (0, _classCallCheck2.default)(this, _default);
3608 return _callSuper(this, _default, arguments);
3609 }
3610 (0, _inherits2.default)(_default, _elementorModules$com);
3611 return (0, _createClass2.default)(_default, [{
3612 key: "getModalOptions",
3613 value: function getModalOptions() {
3614 return {
3615 id: 'elementor-finder__modal',
3616 draggable: true,
3617 effects: {
3618 show: 'show',
3619 hide: 'hide'
3620 },
3621 position: {
3622 enable: false
3623 }
3624 };
3625 }
3626 }, {
3627 key: "getLogoOptions",
3628 value: function getLogoOptions() {
3629 return {
3630 title: __('Finder', 'elementor')
3631 };
3632 }
3633 }, {
3634 key: "initialize",
3635 value: function initialize() {
3636 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3637 args[_key] = arguments[_key];
3638 }
3639 _superPropGet(_default, "initialize", this, 3)(args);
3640 this.showLogo();
3641 this.showContentView();
3642 }
3643 }, {
3644 key: "showContentView",
3645 value: function showContentView() {
3646 this.modalContent.show(new _content.default());
3647 }
3648 }, {
3649 key: "showModal",
3650 value: function showModal() {
3651 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
3652 args[_key2] = arguments[_key2];
3653 }
3654 _superPropGet(_default, "showModal", this, 3)(args);
3655 this.modalContent.currentView.ui.searchInput.focus();
3656 }
3657 }]);
3658 }(elementorModules.common.views.modal.Layout);
3659
3660 /***/ }),
3661
3662 /***/ "../modules/web-cli/assets/js/core/data/errors/base-error.js":
3663 /*!*******************************************************************!*\
3664 !*** ../modules/web-cli/assets/js/core/data/errors/base-error.js ***!
3665 \*******************************************************************/
3666 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3667
3668 "use strict";
3669
3670
3671 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3672 Object.defineProperty(exports, "__esModule", ({
3673 value: true
3674 }));
3675 exports["default"] = void 0;
3676 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3677 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3678 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3679 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3680 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3681 var _wrapNativeSuper2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/wrapNativeSuper */ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js"));
3682 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
3683 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
3684 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../../../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
3685 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; }
3686 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; }
3687 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)); }
3688 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3689 var BaseError = exports["default"] = /*#__PURE__*/function (_Error) {
3690 /**
3691 * Error constructor.
3692 *
3693 * @param {string} message
3694 * @param {string} code
3695 * @param {*} data
3696 */
3697 function BaseError() {
3698 var _this;
3699 var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
3700 var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
3701 var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
3702 (0, _classCallCheck2.default)(this, BaseError);
3703 _this = _callSuper(this, BaseError, [message]);
3704 /**
3705 * The server error code.
3706 *
3707 * @type {string}
3708 */
3709 (0, _defineProperty2.default)(_this, "code", '');
3710 /**
3711 * Additional data about the current error.
3712 *
3713 * @type {*[]}
3714 */
3715 (0, _defineProperty2.default)(_this, "data", []);
3716 _this.code = code;
3717 _this.data = data;
3718 return _this;
3719 }
3720
3721 /**
3722 * Notify a message when the error occurs.
3723 */
3724 (0, _inherits2.default)(BaseError, _Error);
3725 return (0, _createClass2.default)(BaseError, [{
3726 key: "notify",
3727 value: function notify() {
3728 _console.default.error(_objectSpread({
3729 message: this.message
3730 }, this));
3731 }
3732 }], [{
3733 key: "create",
3734 value:
3735 /**
3736 * Static helper function to create the error.
3737 *
3738 * @param {string} message
3739 * @param {string} code
3740 * @param {*} data
3741 * @return {BaseError} error
3742 */
3743 function create(message) {
3744 var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
3745 var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
3746 return new this(message, code, data);
3747 }
3748
3749 /**
3750 * Returns the status code of the error.
3751 */
3752 }, {
3753 key: "getHTTPErrorCode",
3754 value: function getHTTPErrorCode() {
3755 (0, _forceMethodImplementation.default)();
3756 }
3757 }]);
3758 }(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
3759
3760 /***/ }),
3761
3762 /***/ "../modules/web-cli/assets/js/core/data/errors/default-error.js":
3763 /*!**********************************************************************!*\
3764 !*** ../modules/web-cli/assets/js/core/data/errors/default-error.js ***!
3765 \**********************************************************************/
3766 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3767
3768 "use strict";
3769
3770
3771 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3772 Object.defineProperty(exports, "__esModule", ({
3773 value: true
3774 }));
3775 exports["default"] = exports.DefaultError = void 0;
3776 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3777 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3778 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3779 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3780 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3781 var _baseError = _interopRequireDefault(__webpack_require__(/*! ./base-error */ "../modules/web-cli/assets/js/core/data/errors/base-error.js"));
3782 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)); }
3783 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3784 var DefaultError = exports.DefaultError = /*#__PURE__*/function (_BaseError) {
3785 function DefaultError() {
3786 (0, _classCallCheck2.default)(this, DefaultError);
3787 return _callSuper(this, DefaultError, arguments);
3788 }
3789 (0, _inherits2.default)(DefaultError, _BaseError);
3790 return (0, _createClass2.default)(DefaultError, null, [{
3791 key: "getHTTPErrorCode",
3792 value: function getHTTPErrorCode() {
3793 return 501;
3794 }
3795 }]);
3796 }(_baseError.default);
3797 var _default = exports["default"] = DefaultError;
3798
3799 /***/ }),
3800
3801 /***/ "../modules/web-cli/assets/js/core/data/errors/error-404.js":
3802 /*!******************************************************************!*\
3803 !*** ../modules/web-cli/assets/js/core/data/errors/error-404.js ***!
3804 \******************************************************************/
3805 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3806
3807 "use strict";
3808
3809
3810 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3811 Object.defineProperty(exports, "__esModule", ({
3812 value: true
3813 }));
3814 exports["default"] = exports.Error404 = void 0;
3815 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3816 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3817 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3818 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3819 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3820 var _baseError = _interopRequireDefault(__webpack_require__(/*! ./base-error */ "../modules/web-cli/assets/js/core/data/errors/base-error.js"));
3821 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
3822 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)); }
3823 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3824 var Error404 = exports.Error404 = /*#__PURE__*/function (_BaseError) {
3825 function Error404() {
3826 (0, _classCallCheck2.default)(this, Error404);
3827 return _callSuper(this, Error404, arguments);
3828 }
3829 (0, _inherits2.default)(Error404, _BaseError);
3830 return (0, _createClass2.default)(Error404, [{
3831 key: "notify",
3832 value: function notify() {
3833 _console.default.warn(this.message);
3834 }
3835 }], [{
3836 key: "getHTTPErrorCode",
3837 value: function getHTTPErrorCode() {
3838 return 404;
3839 }
3840 }]);
3841 }(_baseError.default);
3842 var _default = exports["default"] = Error404;
3843
3844 /***/ }),
3845
3846 /***/ "../modules/web-cli/assets/js/core/data/errors/index.js":
3847 /*!**************************************************************!*\
3848 !*** ../modules/web-cli/assets/js/core/data/errors/index.js ***!
3849 \**************************************************************/
3850 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3851
3852 "use strict";
3853
3854
3855 Object.defineProperty(exports, "__esModule", ({
3856 value: true
3857 }));
3858 Object.defineProperty(exports, "DefaultError", ({
3859 enumerable: true,
3860 get: function get() {
3861 return _defaultError.DefaultError;
3862 }
3863 }));
3864 Object.defineProperty(exports, "Error404", ({
3865 enumerable: true,
3866 get: function get() {
3867 return _error.Error404;
3868 }
3869 }));
3870 var _defaultError = __webpack_require__(/*! ./default-error */ "../modules/web-cli/assets/js/core/data/errors/default-error.js");
3871 var _error = __webpack_require__(/*! ./error-404 */ "../modules/web-cli/assets/js/core/data/errors/error-404.js");
3872
3873 /***/ }),
3874
3875 /***/ "../modules/web-cli/assets/js/modules/command-base.js":
3876 /*!************************************************************!*\
3877 !*** ../modules/web-cli/assets/js/modules/command-base.js ***!
3878 \************************************************************/
3879 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3880
3881 "use strict";
3882
3883
3884 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3885 Object.defineProperty(exports, "__esModule", ({
3886 value: true
3887 }));
3888 exports["default"] = void 0;
3889 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3890 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3891 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3892 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3893 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3894 var _commandInfra = _interopRequireDefault(__webpack_require__(/*! ./command-infra */ "../modules/web-cli/assets/js/modules/command-infra.js"));
3895 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
3896 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)); }
3897 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3898 /**
3899 * @name $e.modules.CommandBase
3900 */
3901 var CommandBase = exports["default"] = /*#__PURE__*/function (_CommandInfra) {
3902 function CommandBase() {
3903 (0, _classCallCheck2.default)(this, CommandBase);
3904 return _callSuper(this, CommandBase, arguments);
3905 }
3906 (0, _inherits2.default)(CommandBase, _CommandInfra);
3907 return (0, _createClass2.default)(CommandBase, [{
3908 key: "onBeforeRun",
3909 value: function onBeforeRun() {
3910 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3911 $e.hooks.runUIBefore(this.command, args);
3912 }
3913 }, {
3914 key: "onAfterRun",
3915 value: function onAfterRun() {
3916 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3917 var result = arguments.length > 1 ? arguments[1] : undefined;
3918 $e.hooks.runUIAfter(this.command, args, result);
3919 }
3920 }, {
3921 key: "onBeforeApply",
3922 value: function onBeforeApply() {
3923 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3924 $e.hooks.runDataDependency(this.command, args);
3925 }
3926 }, {
3927 key: "onAfterApply",
3928 value: function onAfterApply() {
3929 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3930 var result = arguments.length > 1 ? arguments[1] : undefined;
3931 return $e.hooks.runDataAfter(this.command, args, result);
3932 }
3933 }, {
3934 key: "onCatchApply",
3935 value: function onCatchApply(e) {
3936 this.runCatchHooks(e);
3937 }
3938
3939 /**
3940 * Run all the catch hooks.
3941 *
3942 * @param {Error} e
3943 */
3944 }, {
3945 key: "runCatchHooks",
3946 value: function runCatchHooks(e) {
3947 $e.hooks.runDataCatch(this.command, this.args, e);
3948 $e.hooks.runUICatch(this.command, this.args, e);
3949 }
3950
3951 /**
3952 * TODO - Remove - Backwards compatibility.
3953 *
3954 * Function requireContainer().
3955 *
3956 * Validate `arg.container` & `arg.containers`.
3957 *
3958 * @param {{}} args
3959 * @deprecated since 3.7.0, extend `$e.modules.editor.CommandContainerBase` or `$e.modules.editor.CommandContainerInternalBase` instead.
3960 *
3961 * @throws {Error}
3962 */
3963 }, {
3964 key: "requireContainer",
3965 value: function requireContainer() {
3966 var _this = this;
3967 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.args;
3968 _deprecation.default.deprecated('requireContainer()', '3.7.0', 'Extend `$e.modules.editor.CommandContainerBase` or `$e.modules.editor.CommandContainerInternalBase`');
3969 if (!args.container && !args.containers) {
3970 throw Error('container or containers are required.');
3971 }
3972 if (args.container && args.containers) {
3973 throw Error('container and containers cannot go together please select one of them.');
3974 }
3975 var containers = args.containers || [args.container];
3976 containers.forEach(function (container) {
3977 _this.requireArgumentInstance('container', elementorModules.editor.Container, {
3978 container: container
3979 });
3980 });
3981 }
3982 }], [{
3983 key: "getInstanceType",
3984 value: function getInstanceType() {
3985 return 'CommandBase';
3986 }
3987 }]);
3988 }(_commandInfra.default);
3989
3990 /***/ }),
3991
3992 /***/ "../modules/web-cli/assets/js/modules/command-callback-base.js":
3993 /*!*********************************************************************!*\
3994 !*** ../modules/web-cli/assets/js/modules/command-callback-base.js ***!
3995 \*********************************************************************/
3996 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3997
3998 "use strict";
3999
4000
4001 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4002 Object.defineProperty(exports, "__esModule", ({
4003 value: true
4004 }));
4005 exports["default"] = void 0;
4006 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4007 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4008 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4009 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4010 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4011 var _commandBase = _interopRequireDefault(__webpack_require__(/*! ./command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4012 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)); }
4013 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4014 /**
4015 * To support pure callbacks in the API(commands.js), to ensure they have registered with the proper context.
4016 */
4017 var CommandCallbackBase = exports["default"] = /*#__PURE__*/function (_CommandBase) {
4018 function CommandCallbackBase() {
4019 (0, _classCallCheck2.default)(this, CommandCallbackBase);
4020 return _callSuper(this, CommandCallbackBase, arguments);
4021 }
4022 (0, _inherits2.default)(CommandCallbackBase, _CommandBase);
4023 return (0, _createClass2.default)(CommandCallbackBase, [{
4024 key: "apply",
4025 value: function apply() {
4026 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4027 return this.constructor.getCallback()(args);
4028 }
4029 }], [{
4030 key: "getInstanceType",
4031 value: function getInstanceType() {
4032 return 'CommandCallbackBase';
4033 }
4034
4035 /**
4036 * Get original callback of the command.
4037 *
4038 * Support pure callbacks ( Non command-base ).
4039 *
4040 * @return {()=>{}} Command Results.
4041 */
4042 }, {
4043 key: "getCallback",
4044 value: function getCallback() {
4045 return this.registerConfig.callback;
4046 }
4047 }]);
4048 }(_commandBase.default);
4049
4050 /***/ }),
4051
4052 /***/ "../modules/web-cli/assets/js/modules/command-data.js":
4053 /*!************************************************************!*\
4054 !*** ../modules/web-cli/assets/js/modules/command-data.js ***!
4055 \************************************************************/
4056 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4057
4058 "use strict";
4059
4060
4061 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4062 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
4063 Object.defineProperty(exports, "__esModule", ({
4064 value: true
4065 }));
4066 exports["default"] = void 0;
4067 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4068 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4069 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4070 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4071 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4072 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
4073 var _commandBase = _interopRequireDefault(__webpack_require__(/*! ./command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4074 var errors = _interopRequireWildcard(__webpack_require__(/*! ../core/data/errors/ */ "../modules/web-cli/assets/js/core/data/errors/index.js"));
4075 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); }
4076 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)); }
4077 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4078 /**
4079 * @name $e.modules.CommandData
4080 */
4081 /**
4082 * @typedef {('create'|'delete'|'get'|'update'|'options')} DataTypes
4083 */
4084 /**
4085 * @typedef {{}} RequestData
4086 */
4087 /**
4088 * @typedef {import('../core/data/errors/base-error')} BaseError
4089 */
4090 var CommandData = exports["default"] = /*#__PURE__*/function (_CommandBase) {
4091 function CommandData(args) {
4092 var _this$args$options;
4093 var _this;
4094 var commandsAPI = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : $e.data;
4095 (0, _classCallCheck2.default)(this, CommandData);
4096 _this = _callSuper(this, CommandData, [args, commandsAPI]);
4097 /**
4098 * Data returned from remote.
4099 *
4100 * @type {*}
4101 */
4102 (0, _defineProperty2.default)(_this, "data", void 0);
4103 /**
4104 * Fetch type.
4105 *
4106 * @type {DataTypes}
4107 */
4108 (0, _defineProperty2.default)(_this, "type", void 0);
4109 if ((_this$args$options = _this.args.options) !== null && _this$args$options !== void 0 && _this$args$options.type) {
4110 _this.type = _this.args.options.type;
4111 }
4112 return _this;
4113 }
4114
4115 /**
4116 * Function getEndpointFormat().
4117 *
4118 * @return {null|string} endpoint format
4119 */
4120 (0, _inherits2.default)(CommandData, _CommandBase);
4121 return (0, _createClass2.default)(CommandData, [{
4122 key: "getApplyMethods",
4123 value:
4124 /**
4125 * @param {DataTypes} type
4126 *
4127 * @return {boolean|{before: (function(*=): {}), after: (function({}, *=): {})}} apply methods
4128 */
4129 function getApplyMethods() {
4130 var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.type;
4131 var before, after;
4132 switch (type) {
4133 case 'create':
4134 before = this.applyBeforeCreate;
4135 after = this.applyAfterCreate;
4136 break;
4137 case 'delete':
4138 before = this.applyBeforeDelete;
4139 after = this.applyAfterDelete;
4140 break;
4141 case 'get':
4142 before = this.applyBeforeGet;
4143 after = this.applyAfterGet;
4144 break;
4145 case 'update':
4146 before = this.applyBeforeUpdate;
4147 after = this.applyAfterUpdate;
4148 break;
4149 case 'options':
4150 before = this.applyBeforeOptions;
4151 after = this.applyAfterOptions;
4152 break;
4153 default:
4154 return false;
4155 }
4156 return {
4157 before: before.bind(this),
4158 after: after.bind(this)
4159 };
4160 }
4161
4162 /**
4163 * Function getRequestData().
4164 *
4165 * @return {RequestData} request data
4166 */
4167 }, {
4168 key: "getRequestData",
4169 value: function getRequestData() {
4170 return {
4171 type: this.type,
4172 args: this.args,
4173 timestamp: new Date().getTime(),
4174 component: this.component,
4175 command: this.command,
4176 endpoint: $e.data.commandToEndpoint(this.command, JSON.parse(JSON.stringify(this.args)), this.constructor.getEndpointFormat())
4177 };
4178 }
4179 }, {
4180 key: "apply",
4181 value: function apply() {
4182 var _this2 = this;
4183 var applyMethods = this.getApplyMethods();
4184
4185 // Run 'before' method.
4186 this.args = applyMethods.before(this.args);
4187 var requestData = this.getRequestData();
4188 return $e.data.fetch(requestData).then(function (data) {
4189 _this2.data = data;
4190
4191 // Run 'after' method.
4192 _this2.data = applyMethods.after(data, _this2.args);
4193 _this2.data = {
4194 data: _this2.data
4195 };
4196
4197 // Append requestData.
4198 _this2.data = Object.assign({
4199 __requestData__: requestData
4200 }, _this2.data);
4201 return _this2.data;
4202 });
4203 }
4204
4205 /**
4206 * @param {*} [args={}]
4207 * @return {{}} filtered args
4208 */
4209 }, {
4210 key: "applyBeforeCreate",
4211 value: function applyBeforeCreate() {
4212 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4213 return args;
4214 }
4215
4216 /**
4217 * @param {{}} data
4218 * @param {*} [args={}]
4219 * @return {{}} filtered result
4220 */
4221 }, {
4222 key: "applyAfterCreate",
4223 value: function applyAfterCreate(data) {
4224 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4225 // eslint-disable-line no-unused-vars
4226 return data;
4227 }
4228
4229 /**
4230 * @param {*} [args={}]
4231 * @return {{}} filtered args
4232 */
4233 }, {
4234 key: "applyBeforeDelete",
4235 value: function applyBeforeDelete() {
4236 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4237 return args;
4238 }
4239
4240 /**
4241 * @param {{}} data
4242 * @param {*} [args={}]
4243 * @return {{}} filtered result
4244 */
4245 }, {
4246 key: "applyAfterDelete",
4247 value: function applyAfterDelete(data) {
4248 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4249 // eslint-disable-line no-unused-vars
4250 return data;
4251 }
4252
4253 /**
4254 * @param {*} [args={}]
4255 * @return {{}} filtered args
4256 */
4257 }, {
4258 key: "applyBeforeGet",
4259 value: function applyBeforeGet() {
4260 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4261 return args;
4262 }
4263
4264 /**
4265 * @param {{}} data
4266 * @param {*} [args={}]
4267 * @return {{}} filtered result
4268 */
4269 }, {
4270 key: "applyAfterGet",
4271 value: function applyAfterGet(data) {
4272 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4273 // eslint-disable-line no-unused-vars
4274 return data;
4275 }
4276
4277 /**
4278 * @param {*} [args={}]
4279 * @return {{}} filtered args
4280 */
4281 }, {
4282 key: "applyBeforeUpdate",
4283 value: function applyBeforeUpdate() {
4284 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4285 return args;
4286 }
4287
4288 /**
4289 * @param {{}} data
4290 * @param {*} [args={}]
4291 * @return {{}} filtered result
4292 */
4293 }, {
4294 key: "applyAfterUpdate",
4295 value: function applyAfterUpdate(data) {
4296 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4297 // eslint-disable-line no-unused-vars
4298 return data;
4299 }
4300
4301 /**
4302 * @param {*} [args={}]
4303 * @return {{}} filtered args
4304 */
4305 }, {
4306 key: "applyBeforeOptions",
4307 value: function applyBeforeOptions() {
4308 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4309 return args;
4310 }
4311
4312 /**
4313 * @param {{}} data
4314 * @param {*} [args={}]
4315 * @return {{}} filtered result
4316 */
4317 }, {
4318 key: "applyAfterOptions",
4319 value: function applyAfterOptions(data) {
4320 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4321 // eslint-disable-line no-unused-vars
4322 return data;
4323 }
4324
4325 /**
4326 * @param {BaseError} e
4327 */
4328 }, {
4329 key: "applyAfterCatch",
4330 value: function applyAfterCatch(e) {
4331 e.notify();
4332 }
4333 }, {
4334 key: "onCatchApply",
4335 value: function onCatchApply(e) {
4336 var _e;
4337 // TODO: If the errors that returns from the server is consistent remove the '?' from 'e'
4338 var httpErrorCode = ((_e = e) === null || _e === void 0 || (_e = _e.data) === null || _e === void 0 ? void 0 : _e.status) || 501;
4339 var dataError = Object.values(errors).find(function (error) {
4340 return error.getHTTPErrorCode() === httpErrorCode;
4341 });
4342 if (!dataError) {
4343 dataError = errors.DefaultError;
4344 }
4345 e = dataError.create(e.message, e.code, e.data || []);
4346 this.runCatchHooks(e);
4347 this.applyAfterCatch(e);
4348 }
4349 }], [{
4350 key: "getInstanceType",
4351 value: function getInstanceType() {
4352 return 'CommandData';
4353 }
4354 }, {
4355 key: "getEndpointFormat",
4356 value: function getEndpointFormat() {
4357 return null;
4358 }
4359 }]);
4360 }(_commandBase.default);
4361
4362 /***/ }),
4363
4364 /***/ "../modules/web-cli/assets/js/modules/command-infra.js":
4365 /*!*************************************************************!*\
4366 !*** ../modules/web-cli/assets/js/modules/command-infra.js ***!
4367 \*************************************************************/
4368 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4369
4370 "use strict";
4371
4372
4373 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4374 Object.defineProperty(exports, "__esModule", ({
4375 value: true
4376 }));
4377 exports["default"] = void 0;
4378 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4379 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4380 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4381 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4382 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4383 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
4384 var _argsObject = _interopRequireDefault(__webpack_require__(/*! elementor-assets-js/modules/imports/args-object */ "../assets/dev/js/modules/imports/args-object.js"));
4385 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
4386 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)); }
4387 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4388 /**
4389 * @typedef {import('../modules/component-base')} ComponentBase
4390 */
4391 var CommandInfra = exports["default"] = /*#__PURE__*/function (_ArgsObject) {
4392 /**
4393 * Function constructor().
4394 *
4395 * Create Commands Base.
4396 *
4397 * @param {{}} args
4398 */
4399 function CommandInfra() {
4400 var _this;
4401 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4402 (0, _classCallCheck2.default)(this, CommandInfra);
4403 _this = _callSuper(this, CommandInfra, [args]);
4404 if (!_this.constructor.registerConfig) {
4405 throw RangeError('Doing it wrong: Each command type should have `registerConfig`.');
4406 }
4407
4408 // Acknowledge self about which command it run.
4409 _this.command = _this.constructor.getCommand();
4410
4411 // Assign instance of current component.
4412 _this.component = _this.constructor.getComponent();
4413
4414 // Who ever need do something before without `super` the constructor can use `initialize` method.
4415 _this.initialize(args);
4416
4417 // Refresh args, maybe the changed via `initialize`.
4418 args = _this.args;
4419
4420 // Validate args before run.
4421 _this.validateArgs(args);
4422 return _this;
4423 }
4424
4425 /**
4426 * Function initialize().
4427 *
4428 * Initialize command, called after construction.
4429 *
4430 * @param {{}} args
4431 */
4432 (0, _inherits2.default)(CommandInfra, _ArgsObject);
4433 return (0, _createClass2.default)(CommandInfra, [{
4434 key: "currentCommand",
4435 get:
4436 /**
4437 * @deprecated since 3.7.0, use `this.command` instead.
4438 */
4439 function get() {
4440 _deprecation.default.deprecated('this.currentCommand', '3.7.0', 'this.command');
4441 return this.command;
4442 }
4443 }, {
4444 key: "initialize",
4445 value: function initialize() {
4446 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4447 } // eslint-disable-line no-unused-vars
4448
4449 /**
4450 * Function validateArgs().
4451 *
4452 * Validate command arguments.
4453 *
4454 * @param {{}} args
4455 */
4456 }, {
4457 key: "validateArgs",
4458 value: function validateArgs() {
4459 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4460 } // eslint-disable-line no-unused-vars
4461
4462 // eslint-disable-next-line jsdoc/require-returns-check
4463 /**
4464 * Function apply().
4465 *
4466 * Do the actual command.
4467 *
4468 * @param {{}} args
4469 *
4470 * @return {*} Command results.
4471 */
4472 }, {
4473 key: "apply",
4474 value: function apply() {
4475 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4476 // eslint-disable-line no-unused-vars
4477 elementorModules.ForceMethodImplementation();
4478 }
4479
4480 /**
4481 * Function run().
4482 *
4483 * Run command with history & hooks.
4484 *
4485 * @return {*} Command results.
4486 */
4487 }, {
4488 key: "run",
4489 value: function run() {
4490 return this.apply(this.args);
4491 }
4492
4493 /**
4494 * Function onBeforeRun.
4495 *
4496 * Called before run().
4497 *
4498 * @param {{}} args
4499 */
4500 }, {
4501 key: "onBeforeRun",
4502 value: function onBeforeRun() {
4503 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4504 } // eslint-disable-line no-unused-vars
4505
4506 /**
4507 * Function onAfterRun.
4508 *
4509 * Called after run().
4510 *
4511 * @param {{}} args
4512 * @param {*} result
4513 */
4514 }, {
4515 key: "onAfterRun",
4516 value: function onAfterRun() {
4517 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4518 var result = arguments.length > 1 ? arguments[1] : undefined;
4519 } // eslint-disable-line no-unused-vars
4520
4521 /**
4522 * Function onBeforeApply.
4523 *
4524 * Called before apply().
4525 *
4526 * @param {{}} args
4527 */
4528 }, {
4529 key: "onBeforeApply",
4530 value: function onBeforeApply() {
4531 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4532 } // eslint-disable-line no-unused-vars
4533
4534 /**
4535 * Function onAfterApply.
4536 *
4537 * Called after apply().
4538 *
4539 * @param {{}} args
4540 * @param {*} result
4541 */
4542 }, {
4543 key: "onAfterApply",
4544 value: function onAfterApply() {
4545 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4546 var result = arguments.length > 1 ? arguments[1] : undefined;
4547 } // eslint-disable-line no-unused-vars
4548
4549 /**
4550 * Function onCatchApply.
4551 *
4552 * Called after apply() failed.
4553 *
4554 * @param {Error} e
4555 */
4556 }, {
4557 key: "onCatchApply",
4558 value: function onCatchApply(e) {} // eslint-disable-line no-unused-vars
4559 }], [{
4560 key: "getInstanceType",
4561 value: function getInstanceType() {
4562 return 'CommandInfra';
4563 }
4564
4565 /**
4566 * Get info of command.
4567 *
4568 * @return {Object} Extra information about the command.
4569 */
4570 }, {
4571 key: "getInfo",
4572 value: function getInfo() {
4573 return {};
4574 }
4575
4576 /**
4577 * @return {string} Self command name.
4578 */
4579 }, {
4580 key: "getCommand",
4581 value: function getCommand() {
4582 return this.registerConfig.command;
4583 }
4584
4585 /**
4586 * @return {ComponentBase} Self component
4587 */
4588 }, {
4589 key: "getComponent",
4590 value: function getComponent() {
4591 return this.registerConfig.component;
4592 }
4593 }, {
4594 key: "setRegisterConfig",
4595 value: function setRegisterConfig(config) {
4596 this.registerConfig = Object.freeze(config);
4597 }
4598 }]);
4599 }(_argsObject.default);
4600 /**
4601 * @type {Object}
4602 */
4603 (0, _defineProperty2.default)(CommandInfra, "registerConfig", null);
4604
4605 /***/ }),
4606
4607 /***/ "../modules/web-cli/assets/js/modules/commands/close.js":
4608 /*!**************************************************************!*\
4609 !*** ../modules/web-cli/assets/js/modules/commands/close.js ***!
4610 \**************************************************************/
4611 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4612
4613 "use strict";
4614
4615
4616 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4617 Object.defineProperty(exports, "__esModule", ({
4618 value: true
4619 }));
4620 exports["default"] = exports.Close = void 0;
4621 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4622 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4623 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4624 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4625 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4626 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4627 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)); }
4628 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4629 var Close = exports.Close = /*#__PURE__*/function (_CommandBase) {
4630 function Close() {
4631 (0, _classCallCheck2.default)(this, Close);
4632 return _callSuper(this, Close, arguments);
4633 }
4634 (0, _inherits2.default)(Close, _CommandBase);
4635 return (0, _createClass2.default)(Close, [{
4636 key: "apply",
4637 value: function apply() {
4638 this.component.close();
4639 }
4640 }]);
4641 }(_commandBase.default);
4642 var _default = exports["default"] = Close;
4643
4644 /***/ }),
4645
4646 /***/ "../modules/web-cli/assets/js/modules/commands/index.js":
4647 /*!**************************************************************!*\
4648 !*** ../modules/web-cli/assets/js/modules/commands/index.js ***!
4649 \**************************************************************/
4650 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4651
4652 "use strict";
4653
4654
4655 Object.defineProperty(exports, "__esModule", ({
4656 value: true
4657 }));
4658 Object.defineProperty(exports, "Close", ({
4659 enumerable: true,
4660 get: function get() {
4661 return _close.Close;
4662 }
4663 }));
4664 Object.defineProperty(exports, "Open", ({
4665 enumerable: true,
4666 get: function get() {
4667 return _open.Open;
4668 }
4669 }));
4670 Object.defineProperty(exports, "Toggle", ({
4671 enumerable: true,
4672 get: function get() {
4673 return _toggle.Toggle;
4674 }
4675 }));
4676 var _close = __webpack_require__(/*! ./close */ "../modules/web-cli/assets/js/modules/commands/close.js");
4677 var _open = __webpack_require__(/*! ./open */ "../modules/web-cli/assets/js/modules/commands/open.js");
4678 var _toggle = __webpack_require__(/*! ./toggle */ "../modules/web-cli/assets/js/modules/commands/toggle.js");
4679
4680 /***/ }),
4681
4682 /***/ "../modules/web-cli/assets/js/modules/commands/open.js":
4683 /*!*************************************************************!*\
4684 !*** ../modules/web-cli/assets/js/modules/commands/open.js ***!
4685 \*************************************************************/
4686 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4687
4688 "use strict";
4689
4690
4691 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4692 Object.defineProperty(exports, "__esModule", ({
4693 value: true
4694 }));
4695 exports["default"] = exports.Open = void 0;
4696 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4697 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4698 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4699 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4700 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4701 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4702 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)); }
4703 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4704 var Open = exports.Open = /*#__PURE__*/function (_CommandBase) {
4705 function Open() {
4706 (0, _classCallCheck2.default)(this, Open);
4707 return _callSuper(this, Open, arguments);
4708 }
4709 (0, _inherits2.default)(Open, _CommandBase);
4710 return (0, _createClass2.default)(Open, [{
4711 key: "apply",
4712 value: function apply() {
4713 $e.route(this.component.getNamespace());
4714 }
4715 }]);
4716 }(_commandBase.default);
4717 var _default = exports["default"] = Open;
4718
4719 /***/ }),
4720
4721 /***/ "../modules/web-cli/assets/js/modules/commands/toggle.js":
4722 /*!***************************************************************!*\
4723 !*** ../modules/web-cli/assets/js/modules/commands/toggle.js ***!
4724 \***************************************************************/
4725 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4726
4727 "use strict";
4728
4729
4730 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4731 Object.defineProperty(exports, "__esModule", ({
4732 value: true
4733 }));
4734 exports["default"] = exports.Toggle = void 0;
4735 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4736 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4737 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4738 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4739 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4740 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4741 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)); }
4742 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4743 var Toggle = exports.Toggle = /*#__PURE__*/function (_CommandBase) {
4744 function Toggle() {
4745 (0, _classCallCheck2.default)(this, Toggle);
4746 return _callSuper(this, Toggle, arguments);
4747 }
4748 (0, _inherits2.default)(Toggle, _CommandBase);
4749 return (0, _createClass2.default)(Toggle, [{
4750 key: "apply",
4751 value: function apply() {
4752 if (this.component.isOpen) {
4753 this.component.close();
4754 } else {
4755 $e.route(this.component.getNamespace());
4756 }
4757 }
4758 }]);
4759 }(_commandBase.default);
4760 var _default = exports["default"] = Toggle;
4761
4762 /***/ }),
4763
4764 /***/ "../modules/web-cli/assets/js/modules/component-base.js":
4765 /*!**************************************************************!*\
4766 !*** ../modules/web-cli/assets/js/modules/component-base.js ***!
4767 \**************************************************************/
4768 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4769
4770 "use strict";
4771
4772
4773 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4774 Object.defineProperty(exports, "__esModule", ({
4775 value: true
4776 }));
4777 exports["default"] = void 0;
4778 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
4779 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
4780 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4781 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4782 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4783 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4784 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4785 var _commandCallbackBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-callback-base */ "../modules/web-cli/assets/js/modules/command-callback-base.js"));
4786 var _toolkit = __webpack_require__(/*! @reduxjs/toolkit */ "../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js");
4787 var _module = _interopRequireDefault(__webpack_require__(/*! elementor/assets/dev/js/modules/imports/module.js */ "../assets/dev/js/modules/imports/module.js"));
4788 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
4789 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
4790 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; }
4791 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; }
4792 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)); }
4793 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4794 /**
4795 * @typedef {import('./command-infra')} CommandInfra
4796 * @typedef {import('./hook-base')} HookBase
4797 * @typedef {import('../core/states/ui-state-base')} UiStateBase
4798 */
4799 var ComponentBase = exports["default"] = /*#__PURE__*/function (_Module) {
4800 function ComponentBase() {
4801 (0, _classCallCheck2.default)(this, ComponentBase);
4802 return _callSuper(this, ComponentBase, arguments);
4803 }
4804 (0, _inherits2.default)(ComponentBase, _Module);
4805 return (0, _createClass2.default)(ComponentBase, [{
4806 key: "__construct",
4807 value: function __construct() {
4808 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4809 if (args.manager) {
4810 this.manager = args.manager;
4811 }
4812 this.commands = this.defaultCommands();
4813 this.commandsInternal = this.defaultCommandsInternal();
4814 this.hooks = this.defaultHooks();
4815 this.routes = this.defaultRoutes();
4816 this.tabs = this.defaultTabs();
4817 this.shortcuts = this.defaultShortcuts();
4818 this.utils = this.defaultUtils();
4819 this.data = this.defaultData();
4820 this.uiStates = this.defaultUiStates();
4821 this.states = this.defaultStates();
4822 this.defaultRoute = '';
4823 this.currentTab = '';
4824 }
4825 }, {
4826 key: "registerAPI",
4827 value: function registerAPI() {
4828 var _this = this;
4829 Object.entries(this.getTabs()).forEach(function (tab) {
4830 return _this.registerTabRoute(tab[0]);
4831 });
4832 Object.entries(this.getRoutes()).forEach(function (_ref) {
4833 var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
4834 route = _ref2[0],
4835 callback = _ref2[1];
4836 return _this.registerRoute(route, callback);
4837 });
4838 Object.entries(this.getCommands()).forEach(function (_ref3) {
4839 var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
4840 command = _ref4[0],
4841 callback = _ref4[1];
4842 return _this.registerCommand(command, callback);
4843 });
4844 Object.entries(this.getCommandsInternal()).forEach(function (_ref5) {
4845 var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
4846 command = _ref6[0],
4847 callback = _ref6[1];
4848 return _this.registerCommandInternal(command, callback);
4849 });
4850 Object.values(this.getHooks()).forEach(function (instance) {
4851 return _this.registerHook(instance);
4852 });
4853 Object.entries(this.getData()).forEach(function (_ref7) {
4854 var _ref8 = (0, _slicedToArray2.default)(_ref7, 2),
4855 command = _ref8[0],
4856 callback = _ref8[1];
4857 return _this.registerData(command, callback);
4858 });
4859 Object.values(this.getUiStates()).forEach(function (instance) {
4860 return _this.registerUiState(instance);
4861 });
4862 Object.entries(this.getStates()).forEach(function (_ref9) {
4863 var _ref0 = (0, _slicedToArray2.default)(_ref9, 2),
4864 id = _ref0[0],
4865 state = _ref0[1];
4866 return _this.registerState(id, state);
4867 });
4868 }
4869
4870 // eslint-disable-next-line jsdoc/require-returns-check
4871 /**
4872 * @return {string} namespace
4873 */
4874 }, {
4875 key: "getNamespace",
4876 value: function getNamespace() {
4877 (0, _forceMethodImplementation.default)();
4878 }
4879
4880 /**
4881 * @deprecated since 3.7.0, use `getServiceName()` instead.
4882 */
4883 }, {
4884 key: "getRootContainer",
4885 value: function getRootContainer() {
4886 _deprecation.default.deprecated('getRootContainer()', '3.7.0', 'getServiceName()');
4887 return this.getServiceName();
4888 }
4889 }, {
4890 key: "getServiceName",
4891 value: function getServiceName() {
4892 return this.getNamespace().split('/')[0];
4893 }
4894 }, {
4895 key: "store",
4896 get: function get() {
4897 return $e.store.get(this.getNamespace());
4898 }
4899 }, {
4900 key: "defaultTabs",
4901 value: function defaultTabs() {
4902 return {};
4903 }
4904 }, {
4905 key: "defaultRoutes",
4906 value: function defaultRoutes() {
4907 return {};
4908 }
4909 }, {
4910 key: "defaultCommands",
4911 value: function defaultCommands() {
4912 return {};
4913 }
4914 }, {
4915 key: "defaultCommandsInternal",
4916 value: function defaultCommandsInternal() {
4917 return {};
4918 }
4919 }, {
4920 key: "defaultHooks",
4921 value: function defaultHooks() {
4922 return {};
4923 }
4924
4925 /**
4926 * Get the component's default UI states.
4927 *
4928 * @return {Object} default UI states
4929 */
4930 }, {
4931 key: "defaultUiStates",
4932 value: function defaultUiStates() {
4933 return {};
4934 }
4935
4936 /**
4937 * Get the component's Redux slice settings.
4938 *
4939 * @return {Object} Redux slice settings
4940 */
4941 }, {
4942 key: "defaultStates",
4943 value: function defaultStates() {
4944 return {};
4945 }
4946 }, {
4947 key: "defaultShortcuts",
4948 value: function defaultShortcuts() {
4949 return {};
4950 }
4951 }, {
4952 key: "defaultUtils",
4953 value: function defaultUtils() {
4954 return {};
4955 }
4956 }, {
4957 key: "defaultData",
4958 value: function defaultData() {
4959 return {};
4960 }
4961 }, {
4962 key: "getCommands",
4963 value: function getCommands() {
4964 return this.commands;
4965 }
4966 }, {
4967 key: "getCommandsInternal",
4968 value: function getCommandsInternal() {
4969 return this.commandsInternal;
4970 }
4971 }, {
4972 key: "getHooks",
4973 value: function getHooks() {
4974 return this.hooks;
4975 }
4976
4977 /**
4978 * Retrieve the component's UI states.
4979 *
4980 * @return {Object} UI states
4981 */
4982 }, {
4983 key: "getUiStates",
4984 value: function getUiStates() {
4985 return this.uiStates;
4986 }
4987
4988 /**
4989 * Retrieve the component's Redux Slice.
4990 *
4991 * @return {Object} Redux Slice
4992 */
4993 }, {
4994 key: "getStates",
4995 value: function getStates() {
4996 return this.states;
4997 }
4998 }, {
4999 key: "getRoutes",
5000 value: function getRoutes() {
5001 return this.routes;
5002 }
5003 }, {
5004 key: "getTabs",
5005 value: function getTabs() {
5006 return this.tabs;
5007 }
5008 }, {
5009 key: "getShortcuts",
5010 value: function getShortcuts() {
5011 return this.shortcuts;
5012 }
5013 }, {
5014 key: "getData",
5015 value: function getData() {
5016 return this.data;
5017 }
5018
5019 /**
5020 * @param {string} command
5021 * @param {(()=>{}|CommandInfra)} context
5022 * @param {'default'|'internal'|'data'} commandsType
5023 */
5024 }, {
5025 key: "registerCommand",
5026 value: function registerCommand(command, context) {
5027 var commandsType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'default';
5028 var commandsManager;
5029 switch (commandsType) {
5030 case 'default':
5031 commandsManager = $e.commands;
5032 break;
5033 case 'internal':
5034 commandsManager = $e.commandsInternal;
5035 break;
5036 case 'data':
5037 commandsManager = $e.data;
5038 break;
5039 default:
5040 throw new Error("Invalid commands type: '".concat(command, "'"));
5041 }
5042 var fullCommand = this.getNamespace() + '/' + command,
5043 instanceType = context.getInstanceType ? context.getInstanceType() : false,
5044 registerConfig = {
5045 command: fullCommand,
5046 component: this
5047 };
5048
5049 // Support pure callback.
5050 if (!instanceType) {
5051 if ($e.devTools) {
5052 $e.devTools.log.warn("Attach command-callback-base, on command: '".concat(fullCommand, "', context is unknown type."));
5053 }
5054 registerConfig.callback = context;
5055
5056 // Unique class.
5057 context = /*#__PURE__*/function (_CommandCallbackBase) {
5058 function context() {
5059 (0, _classCallCheck2.default)(this, context);
5060 return _callSuper(this, context, arguments);
5061 }
5062 (0, _inherits2.default)(context, _CommandCallbackBase);
5063 return (0, _createClass2.default)(context);
5064 }(_commandCallbackBase.default);
5065 }
5066 context.setRegisterConfig(registerConfig);
5067 commandsManager.register(this, command, context);
5068 }
5069
5070 /**
5071 * @param {HookBase} instance
5072 */
5073 }, {
5074 key: "registerHook",
5075 value: function registerHook(instance) {
5076 return instance.register();
5077 }
5078 }, {
5079 key: "registerCommandInternal",
5080 value: function registerCommandInternal(command, context) {
5081 this.registerCommand(command, context, 'internal');
5082 }
5083
5084 /**
5085 * Register a UI state.
5086 *
5087 * @param {UiStateBase} instance - UI state instance.
5088 *
5089 * @return {void}
5090 */
5091 }, {
5092 key: "registerUiState",
5093 value: function registerUiState(instance) {
5094 $e.uiStates.register(instance);
5095 }
5096
5097 /**
5098 * Register a Redux Slice.
5099 *
5100 * @param {string} id - State id.
5101 * @param {Object} stateConfig - The state config.
5102 *
5103 * @return {void}
5104 */
5105 }, {
5106 key: "registerState",
5107 value: function registerState(id, stateConfig) {
5108 id = this.getNamespace() + (id ? "/".concat(id) : '');
5109 var slice = (0, _toolkit.createSlice)(_objectSpread(_objectSpread({}, stateConfig), {}, {
5110 name: id
5111 }));
5112 $e.store.register(id, slice);
5113 }
5114 }, {
5115 key: "registerRoute",
5116 value: function registerRoute(route, callback) {
5117 $e.routes.register(this, route, callback);
5118 }
5119 }, {
5120 key: "registerData",
5121 value: function registerData(command, context) {
5122 this.registerCommand(command, context, 'data');
5123 }
5124 }, {
5125 key: "unregisterRoute",
5126 value: function unregisterRoute(route) {
5127 $e.routes.unregister(this, route);
5128 }
5129 }, {
5130 key: "registerTabRoute",
5131 value: function registerTabRoute(tab) {
5132 var _this2 = this;
5133 this.registerRoute(tab, function (args) {
5134 return _this2.activateTab(tab, args);
5135 });
5136 }
5137 }, {
5138 key: "dependency",
5139 value: function dependency() {
5140 return true;
5141 }
5142 }, {
5143 key: "open",
5144 value: function open() {
5145 return true;
5146 }
5147 }, {
5148 key: "close",
5149 value: function close() {
5150 if (!this.isOpen) {
5151 return false;
5152 }
5153 this.isOpen = false;
5154 this.inactivate();
5155 $e.routes.clearCurrent(this.getNamespace());
5156 $e.routes.clearHistory(this.getServiceName());
5157 return true;
5158 }
5159 }, {
5160 key: "activate",
5161 value: function activate() {
5162 $e.components.activate(this.getNamespace());
5163 }
5164 }, {
5165 key: "inactivate",
5166 value: function inactivate() {
5167 $e.components.inactivate(this.getNamespace());
5168 }
5169 }, {
5170 key: "isActive",
5171 value: function isActive() {
5172 return $e.components.isActive(this.getNamespace());
5173 }
5174 }, {
5175 key: "onRoute",
5176 value: function onRoute(route) {
5177 this.toggleRouteClass(route, true);
5178 this.toggleHistoryClass();
5179 this.activate();
5180 this.trigger('route/open', route);
5181 }
5182 }, {
5183 key: "onCloseRoute",
5184 value: function onCloseRoute(route) {
5185 this.toggleRouteClass(route, false);
5186 this.inactivate();
5187 this.trigger('route/close', route);
5188 }
5189 }, {
5190 key: "setDefaultRoute",
5191 value: function setDefaultRoute(route) {
5192 this.defaultRoute = this.getNamespace() + '/' + route;
5193 }
5194 }, {
5195 key: "getDefaultRoute",
5196 value: function getDefaultRoute() {
5197 return this.defaultRoute;
5198 }
5199 }, {
5200 key: "removeTab",
5201 value: function removeTab(tab) {
5202 delete this.tabs[tab];
5203 this.unregisterRoute(tab);
5204 }
5205 }, {
5206 key: "hasTab",
5207 value: function hasTab(tab) {
5208 return !!this.tabs[tab];
5209 }
5210 }, {
5211 key: "addTab",
5212 value: function addTab(tab, args, position) {
5213 var _this3 = this;
5214 this.tabs[tab] = args;
5215 // It can be 0.
5216 if ('undefined' !== typeof position) {
5217 var newTabs = {};
5218 var ids = Object.keys(this.tabs);
5219 // Remove new tab
5220 ids.pop();
5221
5222 // Add it to position.
5223 ids.splice(position, 0, tab);
5224 ids.forEach(function (id) {
5225 newTabs[id] = _this3.tabs[id];
5226 });
5227 this.tabs = newTabs;
5228 }
5229 this.registerTabRoute(tab);
5230 }
5231 }, {
5232 key: "getTabsWrapperSelector",
5233 value: function getTabsWrapperSelector() {
5234 return '';
5235 }
5236 }, {
5237 key: "getTabRoute",
5238 value: function getTabRoute(tab) {
5239 return this.getNamespace() + '/' + tab;
5240 }
5241 }, {
5242 key: "renderTab",
5243 value: function renderTab(tab) {} // eslint-disable-line
5244 }, {
5245 key: "activateTab",
5246 value: function activateTab(tab, args) {
5247 var _this4 = this;
5248 this.renderTab(tab, args);
5249 jQuery(this.getTabsWrapperSelector() + ' .elementor-component-tab').off('click').on('click', function (event) {
5250 $e.route(_this4.getTabRoute(event.currentTarget.dataset.tab), args);
5251 }).removeClass('elementor-active').filter('[data-tab="' + tab + '"]').addClass('elementor-active');
5252 }
5253 }, {
5254 key: "getActiveTabConfig",
5255 value: function getActiveTabConfig() {
5256 return this.tabs[this.currentTab] || {};
5257 }
5258 }, {
5259 key: "getBodyClass",
5260 value: function getBodyClass(route) {
5261 return 'e-route-' + route.replace(/\//g, '-');
5262 }
5263
5264 /**
5265 * If command includes uppercase character convert it to lowercase and add `-`.
5266 * e.g: `CopyAll` is converted to `copy-all`.
5267 *
5268 * @param {string} commandName
5269 */
5270 }, {
5271 key: "normalizeCommandName",
5272 value: function normalizeCommandName(commandName) {
5273 return commandName.replace(/[A-Z]/g, function (match, offset) {
5274 return (offset > 0 ? '-' : '') + match.toLowerCase();
5275 });
5276 }
5277
5278 /**
5279 * @param {{}} commandsFromImport
5280 * @return {{}} imported commands
5281 */
5282 }, {
5283 key: "importCommands",
5284 value: function importCommands(commandsFromImport) {
5285 var _this5 = this;
5286 var commands = {};
5287
5288 // Convert `Commands` to `ComponentBase` workable format.
5289 Object.entries(commandsFromImport).forEach(function (_ref1) {
5290 var _ref10 = (0, _slicedToArray2.default)(_ref1, 2),
5291 className = _ref10[0],
5292 Class = _ref10[1];
5293 var command = _this5.normalizeCommandName(className);
5294 commands[command] = Class;
5295 });
5296 return commands;
5297 }
5298 }, {
5299 key: "importHooks",
5300 value: function importHooks(hooksFromImport) {
5301 var hooks = {};
5302 for (var key in hooksFromImport) {
5303 var hook = new hooksFromImport[key]();
5304 hooks[hook.getId()] = hook;
5305 }
5306 return hooks;
5307 }
5308
5309 /**
5310 * Import & initialize the component's UI states.
5311 * Should be used inside `defaultUiState()`.
5312 *
5313 * @param {Object} statesFromImport - UI states from import.
5314 *
5315 * @return {Object} UI States
5316 */
5317 }, {
5318 key: "importUiStates",
5319 value: function importUiStates(statesFromImport) {
5320 var _this6 = this;
5321 var uiStates = {};
5322 Object.values(statesFromImport).forEach(function (className) {
5323 var uiState = new className(_this6);
5324 uiStates[uiState.getId()] = uiState;
5325 });
5326 return uiStates;
5327 }
5328
5329 /**
5330 * Set a UI state value.
5331 * TODO: Should we provide such function? Maybe the developer should implicitly pass the full state ID?
5332 *
5333 * @param {string} state - Non-prefixed state ID.
5334 * @param {*} value - New state value.
5335 *
5336 * @return {void}
5337 */
5338 }, {
5339 key: "setUiState",
5340 value: function setUiState(state, value) {
5341 $e.uiStates.set("".concat(this.getNamespace(), "/").concat(state), value);
5342 }
5343 }, {
5344 key: "toggleRouteClass",
5345 value: function toggleRouteClass(route, state) {
5346 document.body.classList.toggle(this.getBodyClass(route), state);
5347 }
5348 }, {
5349 key: "toggleHistoryClass",
5350 value: function toggleHistoryClass() {
5351 document.body.classList.toggle('e-routes-has-history', !!$e.routes.getHistory(this.getServiceName()).length);
5352 }
5353 }]);
5354 }(_module.default);
5355
5356 /***/ }),
5357
5358 /***/ "../modules/web-cli/assets/js/modules/component-modal-base.js":
5359 /*!********************************************************************!*\
5360 !*** ../modules/web-cli/assets/js/modules/component-modal-base.js ***!
5361 \********************************************************************/
5362 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5363
5364 "use strict";
5365
5366
5367 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5368 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
5369 Object.defineProperty(exports, "__esModule", ({
5370 value: true
5371 }));
5372 exports["default"] = void 0;
5373 var _readOnlyError2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/readOnlyError */ "../node_modules/@babel/runtime/helpers/readOnlyError.js"));
5374 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
5375 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
5376 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
5377 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
5378 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
5379 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
5380 var _componentBase = _interopRequireDefault(__webpack_require__(/*! ./component-base */ "../modules/web-cli/assets/js/modules/component-base.js"));
5381 var commands = _interopRequireWildcard(__webpack_require__(/*! ./commands/ */ "../modules/web-cli/assets/js/modules/commands/index.js"));
5382 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
5383 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); }
5384 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)); }
5385 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
5386 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; }
5387 var ComponentModalBase = exports["default"] = /*#__PURE__*/function (_ComponentBase) {
5388 function ComponentModalBase() {
5389 (0, _classCallCheck2.default)(this, ComponentModalBase);
5390 return _callSuper(this, ComponentModalBase, arguments);
5391 }
5392 (0, _inherits2.default)(ComponentModalBase, _ComponentBase);
5393 return (0, _createClass2.default)(ComponentModalBase, [{
5394 key: "registerAPI",
5395 value: function registerAPI() {
5396 var _this = this;
5397 _superPropGet(ComponentModalBase, "registerAPI", this, 3)([]);
5398 $e.shortcuts.register('esc', {
5399 scopes: [this.getNamespace()],
5400 callback: function callback() {
5401 return _this.close();
5402 }
5403 });
5404 }
5405 }, {
5406 key: "defaultCommands",
5407 value: function defaultCommands() {
5408 return this.importCommands(commands);
5409 }
5410 }, {
5411 key: "defaultRoutes",
5412 value: function defaultRoutes() {
5413 return {
5414 '': function _() {/* Nothing to do, it's already rendered. */}
5415 };
5416 }
5417 }, {
5418 key: "open",
5419 value: function open() {
5420 var _this2 = this;
5421 if (!this.layout) {
5422 var layout = this.getModalLayout();
5423 this.layout = new layout({
5424 component: this
5425 });
5426 this.layout.getModal().on('hide', function () {
5427 return _this2.close();
5428 });
5429 }
5430 this.layout.showModal();
5431 return true;
5432 }
5433 }, {
5434 key: "close",
5435 value: function close() {
5436 if (!_superPropGet(ComponentModalBase, "close", this, 3)([])) {
5437 return false;
5438 }
5439 var close = elementor.hooks.applyFilters('component/modal/close', this.layout.getModal().hide.bind(this.layout.getModal()), this);
5440 close();
5441 return true;
5442 }
5443 }, {
5444 key: "getModalLayout",
5445 value: function getModalLayout() {
5446 (0, _forceMethodImplementation.default)();
5447 }
5448 }]);
5449 }(_componentBase.default);
5450
5451 /***/ }),
5452
5453 /***/ "../modules/web-cli/assets/js/utils/console.js":
5454 /*!*****************************************************!*\
5455 !*** ../modules/web-cli/assets/js/utils/console.js ***!
5456 \*****************************************************/
5457 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5458
5459 "use strict";
5460
5461
5462 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5463 Object.defineProperty(exports, "__esModule", ({
5464 value: true
5465 }));
5466 exports["default"] = void 0;
5467 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
5468 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
5469 var Console = exports["default"] = /*#__PURE__*/function () {
5470 function Console() {
5471 (0, _classCallCheck2.default)(this, Console);
5472 }
5473 return (0, _createClass2.default)(Console, null, [{
5474 key: "error",
5475 value: function error(message) {
5476 // Show an error if devTools is available.
5477 if ($e.devTools) {
5478 $e.devTools.log.error(message);
5479 }
5480
5481 // If not a 'Hook-Break' then show error.
5482 if (!(message instanceof $e.modules.HookBreak)) {
5483 // eslint-disable-next-line no-console
5484 console.error(message);
5485 }
5486 }
5487 }, {
5488 key: "warn",
5489 value: function warn() {
5490 var _console;
5491 var style = "font-size: 12px; background-image: url(\"".concat(elementorWebCliConfig.urls.assets, "images/logo-icon.png\"); background-repeat: no-repeat; background-size: contain;");
5492 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5493 args[_key] = arguments[_key];
5494 }
5495 args.unshift('%c %c', style, '');
5496 (_console = console).warn.apply(_console, args); // eslint-disable-line no-console
5497 }
5498 }]);
5499 }();
5500
5501 /***/ }),
5502
5503 /***/ "../modules/web-cli/assets/js/utils/deprecation.js":
5504 /*!*********************************************************!*\
5505 !*** ../modules/web-cli/assets/js/utils/deprecation.js ***!
5506 \*********************************************************/
5507 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5508
5509 "use strict";
5510
5511
5512 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5513 Object.defineProperty(exports, "__esModule", ({
5514 value: true
5515 }));
5516 exports["default"] = void 0;
5517 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
5518 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
5519 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
5520 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
5521 // Copied from `modules/dev-tools/assets/js/deprecation.js`
5522 /**
5523 * @typedef {Object} Version
5524 * @property {number} major1 The first number
5525 * @property {number} major2 The second number
5526 * @property {number} minor The third number
5527 * @property {string} build The fourth number
5528 */
5529
5530 var softDeprecated = function softDeprecated(name, version, replacement) {
5531 if (elementorWebCliConfig.isDebug) {
5532 deprecatedMessage('soft', name, version, replacement);
5533 }
5534 };
5535 var hardDeprecated = function hardDeprecated(name, version, replacement) {
5536 deprecatedMessage('hard', name, version, replacement);
5537 };
5538 var deprecatedMessage = function deprecatedMessage(type, name, version, replacement) {
5539 var message = "`".concat(name, "` is ").concat(type, " deprecated since ").concat(version);
5540 if (replacement) {
5541 message += " - Use `".concat(replacement, "` instead");
5542 }
5543 _console.default.warn(message);
5544 };
5545 var Deprecation = exports["default"] = /*#__PURE__*/function () {
5546 function Deprecation() {
5547 (0, _classCallCheck2.default)(this, Deprecation);
5548 }
5549 return (0, _createClass2.default)(Deprecation, null, [{
5550 key: "deprecated",
5551 value: function deprecated(name, version, replacement) {
5552 if (this.isHardDeprecated(version)) {
5553 hardDeprecated(name, version, replacement);
5554 } else {
5555 softDeprecated(name, version, replacement);
5556 }
5557 }
5558
5559 /**
5560 * @param {string} version
5561 *
5562 * @return {Version}
5563 */
5564 }, {
5565 key: "parseVersion",
5566 value: function parseVersion(version) {
5567 var versionParts = version.split('.');
5568 if (versionParts.length < 3 || versionParts.length > 4) {
5569 throw new RangeError('Invalid Semantic Version string provided');
5570 }
5571 var _versionParts = (0, _slicedToArray2.default)(versionParts, 4),
5572 major1 = _versionParts[0],
5573 major2 = _versionParts[1],
5574 minor = _versionParts[2],
5575 _versionParts$ = _versionParts[3],
5576 build = _versionParts$ === void 0 ? '' : _versionParts$;
5577 return {
5578 major1: parseInt(major1),
5579 major2: parseInt(major2),
5580 minor: parseInt(minor),
5581 build: build
5582 };
5583 }
5584
5585 /**
5586 * Get total of major.
5587 *
5588 * 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,
5589 * versions with major2 more then 9 will be added to total.
5590 *
5591 * @param {Version} versionObj
5592 *
5593 * @return {number}
5594 */
5595 }, {
5596 key: "getTotalMajor",
5597 value: function getTotalMajor(versionObj) {
5598 var total = parseInt("".concat(versionObj.major1).concat(versionObj.major2, "0"));
5599 total = Number((total / 10).toFixed(0));
5600 if (versionObj.major2 > 9) {
5601 total = versionObj.major2 - 9;
5602 }
5603 return total;
5604 }
5605
5606 /**
5607 * @param {string} version1
5608 * @param {string} version2
5609 *
5610 * @return {number}
5611 */
5612 }, {
5613 key: "compareVersion",
5614 value: function compareVersion(version1, version2) {
5615 var _this = this;
5616 return [this.parseVersion(version1), this.parseVersion(version2)].map(function (versionObj) {
5617 return _this.getTotalMajor(versionObj);
5618 }).reduce(function (acc, major) {
5619 return acc - major;
5620 });
5621 }
5622
5623 /**
5624 * @param {string} version
5625 *
5626 * @return {boolean}
5627 */
5628 }, {
5629 key: "isSoftDeprecated",
5630 value: function isSoftDeprecated(version) {
5631 var total = this.compareVersion(version, elementorWebCliConfig.version);
5632 return total <= 4;
5633 }
5634
5635 /**
5636 * @param {string} version
5637 * @return {boolean}
5638 */
5639 }, {
5640 key: "isHardDeprecated",
5641 value: function isHardDeprecated(version) {
5642 var total = this.compareVersion(version, elementorWebCliConfig.version);
5643 return total < 0 || total >= 8;
5644 }
5645 }]);
5646 }();
5647
5648 /***/ }),
5649
5650 /***/ "../modules/web-cli/assets/js/utils/force-method-implementation.js":
5651 /*!*************************************************************************!*\
5652 !*** ../modules/web-cli/assets/js/utils/force-method-implementation.js ***!
5653 \*************************************************************************/
5654 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5655
5656 "use strict";
5657
5658
5659 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5660 Object.defineProperty(exports, "__esModule", ({
5661 value: true
5662 }));
5663 exports["default"] = exports.ForceMethodImplementation = void 0;
5664 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
5665 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
5666 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
5667 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
5668 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
5669 var _wrapNativeSuper2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/wrapNativeSuper */ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js"));
5670 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)); }
5671 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
5672 // TODO: Copied from `assets/dev/js/modules/imports/force-method-implementation.js`;
5673 var ForceMethodImplementation = exports.ForceMethodImplementation = /*#__PURE__*/function (_Error) {
5674 function ForceMethodImplementation() {
5675 var _this;
5676 var info = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5677 (0, _classCallCheck2.default)(this, ForceMethodImplementation);
5678 _this = _callSuper(this, ForceMethodImplementation, ["".concat(info.isStatic ? 'static ' : '').concat(info.fullName, "() should be implemented, please provide '").concat(info.functionName || info.fullName, "' functionality.")]);
5679 Error.captureStackTrace(_this, ForceMethodImplementation);
5680 return _this;
5681 }
5682 (0, _inherits2.default)(ForceMethodImplementation, _Error);
5683 return (0, _createClass2.default)(ForceMethodImplementation);
5684 }(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
5685 var _default = exports["default"] = function _default() {
5686 var stack = Error().stack,
5687 caller = stack.split('\n')[2].trim(),
5688 callerName = caller.startsWith('at new') ? 'constructor' : caller.split(' ')[1],
5689 info = {};
5690 info.functionName = callerName;
5691 info.fullName = callerName;
5692 if (info.functionName.includes('.')) {
5693 var parts = info.functionName.split('.');
5694 info.className = parts[0];
5695 info.functionName = parts[1];
5696 } else {
5697 info.isStatic = true;
5698 }
5699 throw new ForceMethodImplementation(info);
5700 };
5701
5702 /***/ }),
5703
5704 /***/ "../node_modules/@babel/runtime/helpers/OverloadYield.js":
5705 /*!***************************************************************!*\
5706 !*** ../node_modules/@babel/runtime/helpers/OverloadYield.js ***!
5707 \***************************************************************/
5708 /***/ ((module) => {
5709
5710 function _OverloadYield(e, d) {
5711 this.v = e, this.k = d;
5712 }
5713 module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
5714
5715 /***/ }),
5716
5717 /***/ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js":
5718 /*!******************************************************************!*\
5719 !*** ../node_modules/@babel/runtime/helpers/arrayLikeToArray.js ***!
5720 \******************************************************************/
5721 /***/ ((module) => {
5722
5723 function _arrayLikeToArray(r, a) {
5724 (null == a || a > r.length) && (a = r.length);
5725 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
5726 return n;
5727 }
5728 module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
5729
5730 /***/ }),
5731
5732 /***/ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js":
5733 /*!****************************************************************!*\
5734 !*** ../node_modules/@babel/runtime/helpers/arrayWithHoles.js ***!
5735 \****************************************************************/
5736 /***/ ((module) => {
5737
5738 function _arrayWithHoles(r) {
5739 if (Array.isArray(r)) return r;
5740 }
5741 module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
5742
5743 /***/ }),
5744
5745 /***/ "../node_modules/@babel/runtime/helpers/assertThisInitialized.js":
5746 /*!***********************************************************************!*\
5747 !*** ../node_modules/@babel/runtime/helpers/assertThisInitialized.js ***!
5748 \***********************************************************************/
5749 /***/ ((module) => {
5750
5751 function _assertThisInitialized(e) {
5752 if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
5753 return e;
5754 }
5755 module.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports["default"] = module.exports;
5756
5757 /***/ }),
5758
5759 /***/ "../node_modules/@babel/runtime/helpers/asyncToGenerator.js":
5760 /*!******************************************************************!*\
5761 !*** ../node_modules/@babel/runtime/helpers/asyncToGenerator.js ***!
5762 \******************************************************************/
5763 /***/ ((module) => {
5764
5765 function asyncGeneratorStep(n, t, e, r, o, a, c) {
5766 try {
5767 var i = n[a](c),
5768 u = i.value;
5769 } catch (n) {
5770 return void e(n);
5771 }
5772 i.done ? t(u) : Promise.resolve(u).then(r, o);
5773 }
5774 function _asyncToGenerator(n) {
5775 return function () {
5776 var t = this,
5777 e = arguments;
5778 return new Promise(function (r, o) {
5779 var a = n.apply(t, e);
5780 function _next(n) {
5781 asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
5782 }
5783 function _throw(n) {
5784 asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
5785 }
5786 _next(void 0);
5787 });
5788 };
5789 }
5790 module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
5791
5792 /***/ }),
5793
5794 /***/ "../node_modules/@babel/runtime/helpers/classCallCheck.js":
5795 /*!****************************************************************!*\
5796 !*** ../node_modules/@babel/runtime/helpers/classCallCheck.js ***!
5797 \****************************************************************/
5798 /***/ ((module) => {
5799
5800 function _classCallCheck(a, n) {
5801 if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
5802 }
5803 module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
5804
5805 /***/ }),
5806
5807 /***/ "../node_modules/@babel/runtime/helpers/construct.js":
5808 /*!***********************************************************!*\
5809 !*** ../node_modules/@babel/runtime/helpers/construct.js ***!
5810 \***********************************************************/
5811 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5812
5813 var isNativeReflectConstruct = __webpack_require__(/*! ./isNativeReflectConstruct.js */ "../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js");
5814 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
5815 function _construct(t, e, r) {
5816 if (isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
5817 var o = [null];
5818 o.push.apply(o, e);
5819 var p = new (t.bind.apply(t, o))();
5820 return r && setPrototypeOf(p, r.prototype), p;
5821 }
5822 module.exports = _construct, module.exports.__esModule = true, module.exports["default"] = module.exports;
5823
5824 /***/ }),
5825
5826 /***/ "../node_modules/@babel/runtime/helpers/createClass.js":
5827 /*!*************************************************************!*\
5828 !*** ../node_modules/@babel/runtime/helpers/createClass.js ***!
5829 \*************************************************************/
5830 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5831
5832 var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/toPropertyKey.js");
5833 function _defineProperties(e, r) {
5834 for (var t = 0; t < r.length; t++) {
5835 var o = r[t];
5836 o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey(o.key), o);
5837 }
5838 }
5839 function _createClass(e, r, t) {
5840 return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
5841 writable: !1
5842 }), e;
5843 }
5844 module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
5845
5846 /***/ }),
5847
5848 /***/ "../node_modules/@babel/runtime/helpers/defineProperty.js":
5849 /*!****************************************************************!*\
5850 !*** ../node_modules/@babel/runtime/helpers/defineProperty.js ***!
5851 \****************************************************************/
5852 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5853
5854 var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/toPropertyKey.js");
5855 function _defineProperty(e, r, t) {
5856 return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
5857 value: t,
5858 enumerable: !0,
5859 configurable: !0,
5860 writable: !0
5861 }) : e[r] = t, e;
5862 }
5863 module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
5864
5865 /***/ }),
5866
5867 /***/ "../node_modules/@babel/runtime/helpers/esm/defineProperty.js":
5868 /*!********************************************************************!*\
5869 !*** ../node_modules/@babel/runtime/helpers/esm/defineProperty.js ***!
5870 \********************************************************************/
5871 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5872
5873 "use strict";
5874 __webpack_require__.r(__webpack_exports__);
5875 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5876 /* harmony export */ "default": () => (/* binding */ _defineProperty)
5877 /* harmony export */ });
5878 /* harmony import */ var _toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js");
5879
5880 function _defineProperty(e, r, t) {
5881 return (r = (0,_toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__["default"])(r)) in e ? Object.defineProperty(e, r, {
5882 value: t,
5883 enumerable: !0,
5884 configurable: !0,
5885 writable: !0
5886 }) : e[r] = t, e;
5887 }
5888
5889
5890 /***/ }),
5891
5892 /***/ "../node_modules/@babel/runtime/helpers/esm/objectSpread2.js":
5893 /*!*******************************************************************!*\
5894 !*** ../node_modules/@babel/runtime/helpers/esm/objectSpread2.js ***!
5895 \*******************************************************************/
5896 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5897
5898 "use strict";
5899 __webpack_require__.r(__webpack_exports__);
5900 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5901 /* harmony export */ "default": () => (/* binding */ _objectSpread2)
5902 /* harmony export */ });
5903 /* harmony import */ var _defineProperty_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defineProperty.js */ "../node_modules/@babel/runtime/helpers/esm/defineProperty.js");
5904
5905 function ownKeys(e, r) {
5906 var t = Object.keys(e);
5907 if (Object.getOwnPropertySymbols) {
5908 var o = Object.getOwnPropertySymbols(e);
5909 r && (o = o.filter(function (r) {
5910 return Object.getOwnPropertyDescriptor(e, r).enumerable;
5911 })), t.push.apply(t, o);
5912 }
5913 return t;
5914 }
5915 function _objectSpread2(e) {
5916 for (var r = 1; r < arguments.length; r++) {
5917 var t = null != arguments[r] ? arguments[r] : {};
5918 r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
5919 (0,_defineProperty_js__WEBPACK_IMPORTED_MODULE_0__["default"])(e, r, t[r]);
5920 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
5921 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
5922 });
5923 }
5924 return e;
5925 }
5926
5927
5928 /***/ }),
5929
5930 /***/ "../node_modules/@babel/runtime/helpers/esm/toPrimitive.js":
5931 /*!*****************************************************************!*\
5932 !*** ../node_modules/@babel/runtime/helpers/esm/toPrimitive.js ***!
5933 \*****************************************************************/
5934 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5935
5936 "use strict";
5937 __webpack_require__.r(__webpack_exports__);
5938 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5939 /* harmony export */ "default": () => (/* binding */ toPrimitive)
5940 /* harmony export */ });
5941 /* harmony import */ var _typeof_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/esm/typeof.js");
5942
5943 function toPrimitive(t, r) {
5944 if ("object" != (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(t) || !t) return t;
5945 var e = t[Symbol.toPrimitive];
5946 if (void 0 !== e) {
5947 var i = e.call(t, r || "default");
5948 if ("object" != (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(i)) return i;
5949 throw new TypeError("@@toPrimitive must return a primitive value.");
5950 }
5951 return ("string" === r ? String : Number)(t);
5952 }
5953
5954
5955 /***/ }),
5956
5957 /***/ "../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js":
5958 /*!*******************************************************************!*\
5959 !*** ../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js ***!
5960 \*******************************************************************/
5961 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5962
5963 "use strict";
5964 __webpack_require__.r(__webpack_exports__);
5965 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5966 /* harmony export */ "default": () => (/* binding */ toPropertyKey)
5967 /* harmony export */ });
5968 /* harmony import */ var _typeof_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/esm/typeof.js");
5969 /* harmony import */ var _toPrimitive_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./toPrimitive.js */ "../node_modules/@babel/runtime/helpers/esm/toPrimitive.js");
5970
5971
5972 function toPropertyKey(t) {
5973 var i = (0,_toPrimitive_js__WEBPACK_IMPORTED_MODULE_1__["default"])(t, "string");
5974 return "symbol" == (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(i) ? i : i + "";
5975 }
5976
5977
5978 /***/ }),
5979
5980 /***/ "../node_modules/@babel/runtime/helpers/esm/typeof.js":
5981 /*!************************************************************!*\
5982 !*** ../node_modules/@babel/runtime/helpers/esm/typeof.js ***!
5983 \************************************************************/
5984 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5985
5986 "use strict";
5987 __webpack_require__.r(__webpack_exports__);
5988 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5989 /* harmony export */ "default": () => (/* binding */ _typeof)
5990 /* harmony export */ });
5991 function _typeof(o) {
5992 "@babel/helpers - typeof";
5993
5994 return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
5995 return typeof o;
5996 } : function (o) {
5997 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
5998 }, _typeof(o);
5999 }
6000
6001
6002 /***/ }),
6003
6004 /***/ "../node_modules/@babel/runtime/helpers/get.js":
6005 /*!*****************************************************!*\
6006 !*** ../node_modules/@babel/runtime/helpers/get.js ***!
6007 \*****************************************************/
6008 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6009
6010 var superPropBase = __webpack_require__(/*! ./superPropBase.js */ "../node_modules/@babel/runtime/helpers/superPropBase.js");
6011 function _get() {
6012 return module.exports = _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) {
6013 var p = superPropBase(e, t);
6014 if (p) {
6015 var n = Object.getOwnPropertyDescriptor(p, t);
6016 return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value;
6017 }
6018 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _get.apply(null, arguments);
6019 }
6020 module.exports = _get, module.exports.__esModule = true, module.exports["default"] = module.exports;
6021
6022 /***/ }),
6023
6024 /***/ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js":
6025 /*!****************************************************************!*\
6026 !*** ../node_modules/@babel/runtime/helpers/getPrototypeOf.js ***!
6027 \****************************************************************/
6028 /***/ ((module) => {
6029
6030 function _getPrototypeOf(t) {
6031 return module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
6032 return t.__proto__ || Object.getPrototypeOf(t);
6033 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _getPrototypeOf(t);
6034 }
6035 module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
6036
6037 /***/ }),
6038
6039 /***/ "../node_modules/@babel/runtime/helpers/inherits.js":
6040 /*!**********************************************************!*\
6041 !*** ../node_modules/@babel/runtime/helpers/inherits.js ***!
6042 \**********************************************************/
6043 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6044
6045 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
6046 function _inherits(t, e) {
6047 if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
6048 t.prototype = Object.create(e && e.prototype, {
6049 constructor: {
6050 value: t,
6051 writable: !0,
6052 configurable: !0
6053 }
6054 }), Object.defineProperty(t, "prototype", {
6055 writable: !1
6056 }), e && setPrototypeOf(t, e);
6057 }
6058 module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports;
6059
6060 /***/ }),
6061
6062 /***/ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js":
6063 /*!***********************************************************************!*\
6064 !*** ../node_modules/@babel/runtime/helpers/interopRequireDefault.js ***!
6065 \***********************************************************************/
6066 /***/ ((module) => {
6067
6068 function _interopRequireDefault(e) {
6069 return e && e.__esModule ? e : {
6070 "default": e
6071 };
6072 }
6073 module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
6074
6075 /***/ }),
6076
6077 /***/ "../node_modules/@babel/runtime/helpers/isNativeFunction.js":
6078 /*!******************************************************************!*\
6079 !*** ../node_modules/@babel/runtime/helpers/isNativeFunction.js ***!
6080 \******************************************************************/
6081 /***/ ((module) => {
6082
6083 function _isNativeFunction(t) {
6084 try {
6085 return -1 !== Function.toString.call(t).indexOf("[native code]");
6086 } catch (n) {
6087 return "function" == typeof t;
6088 }
6089 }
6090 module.exports = _isNativeFunction, module.exports.__esModule = true, module.exports["default"] = module.exports;
6091
6092 /***/ }),
6093
6094 /***/ "../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js":
6095 /*!**************************************************************************!*\
6096 !*** ../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js ***!
6097 \**************************************************************************/
6098 /***/ ((module) => {
6099
6100 function _isNativeReflectConstruct() {
6101 try {
6102 var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
6103 } catch (t) {}
6104 return (module.exports = _isNativeReflectConstruct = function _isNativeReflectConstruct() {
6105 return !!t;
6106 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
6107 }
6108 module.exports = _isNativeReflectConstruct, module.exports.__esModule = true, module.exports["default"] = module.exports;
6109
6110 /***/ }),
6111
6112 /***/ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js":
6113 /*!**********************************************************************!*\
6114 !*** ../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js ***!
6115 \**********************************************************************/
6116 /***/ ((module) => {
6117
6118 function _iterableToArrayLimit(r, l) {
6119 var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
6120 if (null != t) {
6121 var e,
6122 n,
6123 i,
6124 u,
6125 a = [],
6126 f = !0,
6127 o = !1;
6128 try {
6129 if (i = (t = t.call(r)).next, 0 === l) {
6130 if (Object(t) !== t) return;
6131 f = !1;
6132 } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
6133 } catch (r) {
6134 o = !0, n = r;
6135 } finally {
6136 try {
6137 if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
6138 } finally {
6139 if (o) throw n;
6140 }
6141 }
6142 return a;
6143 }
6144 }
6145 module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports;
6146
6147 /***/ }),
6148
6149 /***/ "../node_modules/@babel/runtime/helpers/nonIterableRest.js":
6150 /*!*****************************************************************!*\
6151 !*** ../node_modules/@babel/runtime/helpers/nonIterableRest.js ***!
6152 \*****************************************************************/
6153 /***/ ((module) => {
6154
6155 function _nonIterableRest() {
6156 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
6157 }
6158 module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports;
6159
6160 /***/ }),
6161
6162 /***/ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js":
6163 /*!***************************************************************************!*\
6164 !*** ../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js ***!
6165 \***************************************************************************/
6166 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6167
6168 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6169 var assertThisInitialized = __webpack_require__(/*! ./assertThisInitialized.js */ "../node_modules/@babel/runtime/helpers/assertThisInitialized.js");
6170 function _possibleConstructorReturn(t, e) {
6171 if (e && ("object" == _typeof(e) || "function" == typeof e)) return e;
6172 if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
6173 return assertThisInitialized(t);
6174 }
6175 module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
6176
6177 /***/ }),
6178
6179 /***/ "../node_modules/@babel/runtime/helpers/readOnlyError.js":
6180 /*!***************************************************************!*\
6181 !*** ../node_modules/@babel/runtime/helpers/readOnlyError.js ***!
6182 \***************************************************************/
6183 /***/ ((module) => {
6184
6185 function _readOnlyError(r) {
6186 throw new TypeError('"' + r + '" is read-only');
6187 }
6188 module.exports = _readOnlyError, module.exports.__esModule = true, module.exports["default"] = module.exports;
6189
6190 /***/ }),
6191
6192 /***/ "../node_modules/@babel/runtime/helpers/regenerator.js":
6193 /*!*************************************************************!*\
6194 !*** ../node_modules/@babel/runtime/helpers/regenerator.js ***!
6195 \*************************************************************/
6196 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6197
6198 var regeneratorDefine = __webpack_require__(/*! ./regeneratorDefine.js */ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js");
6199 function _regenerator() {
6200 /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
6201 var e,
6202 t,
6203 r = "function" == typeof Symbol ? Symbol : {},
6204 n = r.iterator || "@@iterator",
6205 o = r.toStringTag || "@@toStringTag";
6206 function i(r, n, o, i) {
6207 var c = n && n.prototype instanceof Generator ? n : Generator,
6208 u = Object.create(c.prototype);
6209 return regeneratorDefine(u, "_invoke", function (r, n, o) {
6210 var i,
6211 c,
6212 u,
6213 f = 0,
6214 p = o || [],
6215 y = !1,
6216 G = {
6217 p: 0,
6218 n: 0,
6219 v: e,
6220 a: d,
6221 f: d.bind(e, 4),
6222 d: function d(t, r) {
6223 return i = t, c = 0, u = e, G.n = r, a;
6224 }
6225 };
6226 function d(r, n) {
6227 for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
6228 var o,
6229 i = p[t],
6230 d = G.p,
6231 l = i[2];
6232 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));
6233 }
6234 if (o || r > 1) return a;
6235 throw y = !0, n;
6236 }
6237 return function (o, p, l) {
6238 if (f > 1) throw TypeError("Generator is already running");
6239 for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
6240 i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
6241 try {
6242 if (f = 2, i) {
6243 if (c || (o = "next"), t = i[o]) {
6244 if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
6245 if (!t.done) return t;
6246 u = t.value, c < 2 && (c = 0);
6247 } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
6248 i = e;
6249 } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
6250 } catch (t) {
6251 i = e, c = 1, u = t;
6252 } finally {
6253 f = 1;
6254 }
6255 }
6256 return {
6257 value: t,
6258 done: y
6259 };
6260 };
6261 }(r, o, i), !0), u;
6262 }
6263 var a = {};
6264 function Generator() {}
6265 function GeneratorFunction() {}
6266 function GeneratorFunctionPrototype() {}
6267 t = Object.getPrototypeOf;
6268 var c = [][n] ? t(t([][n]())) : (regeneratorDefine(t = {}, n, function () {
6269 return this;
6270 }), t),
6271 u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
6272 function f(e) {
6273 return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
6274 }
6275 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 () {
6276 return this;
6277 }), regeneratorDefine(u, "toString", function () {
6278 return "[object Generator]";
6279 }), (module.exports = _regenerator = function _regenerator() {
6280 return {
6281 w: i,
6282 m: f
6283 };
6284 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
6285 }
6286 module.exports = _regenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
6287
6288 /***/ }),
6289
6290 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsync.js":
6291 /*!******************************************************************!*\
6292 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsync.js ***!
6293 \******************************************************************/
6294 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6295
6296 var regeneratorAsyncGen = __webpack_require__(/*! ./regeneratorAsyncGen.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js");
6297 function _regeneratorAsync(n, e, r, t, o) {
6298 var a = regeneratorAsyncGen(n, e, r, t, o);
6299 return a.next().then(function (n) {
6300 return n.done ? n.value : a.next();
6301 });
6302 }
6303 module.exports = _regeneratorAsync, module.exports.__esModule = true, module.exports["default"] = module.exports;
6304
6305 /***/ }),
6306
6307 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js":
6308 /*!*********************************************************************!*\
6309 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js ***!
6310 \*********************************************************************/
6311 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6312
6313 var regenerator = __webpack_require__(/*! ./regenerator.js */ "../node_modules/@babel/runtime/helpers/regenerator.js");
6314 var regeneratorAsyncIterator = __webpack_require__(/*! ./regeneratorAsyncIterator.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js");
6315 function _regeneratorAsyncGen(r, e, t, o, n) {
6316 return new regeneratorAsyncIterator(regenerator().w(r, e, t, o), n || Promise);
6317 }
6318 module.exports = _regeneratorAsyncGen, module.exports.__esModule = true, module.exports["default"] = module.exports;
6319
6320 /***/ }),
6321
6322 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js":
6323 /*!**************************************************************************!*\
6324 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js ***!
6325 \**************************************************************************/
6326 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6327
6328 var OverloadYield = __webpack_require__(/*! ./OverloadYield.js */ "../node_modules/@babel/runtime/helpers/OverloadYield.js");
6329 var regeneratorDefine = __webpack_require__(/*! ./regeneratorDefine.js */ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js");
6330 function AsyncIterator(t, e) {
6331 function n(r, o, i, f) {
6332 try {
6333 var c = t[r](o),
6334 u = c.value;
6335 return u instanceof OverloadYield ? e.resolve(u.v).then(function (t) {
6336 n("next", t, i, f);
6337 }, function (t) {
6338 n("throw", t, i, f);
6339 }) : e.resolve(u).then(function (t) {
6340 c.value = t, i(c);
6341 }, function (t) {
6342 return n("throw", t, i, f);
6343 });
6344 } catch (t) {
6345 f(t);
6346 }
6347 }
6348 var r;
6349 this.next || (regeneratorDefine(AsyncIterator.prototype), regeneratorDefine(AsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () {
6350 return this;
6351 })), regeneratorDefine(this, "_invoke", function (t, o, i) {
6352 function f() {
6353 return new e(function (e, r) {
6354 n(t, i, e, r);
6355 });
6356 }
6357 return r = r ? r.then(f, f) : f();
6358 }, !0);
6359 }
6360 module.exports = AsyncIterator, module.exports.__esModule = true, module.exports["default"] = module.exports;
6361
6362 /***/ }),
6363
6364 /***/ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js":
6365 /*!*******************************************************************!*\
6366 !*** ../node_modules/@babel/runtime/helpers/regeneratorDefine.js ***!
6367 \*******************************************************************/
6368 /***/ ((module) => {
6369
6370 function _regeneratorDefine(e, r, n, t) {
6371 var i = Object.defineProperty;
6372 try {
6373 i({}, "", {});
6374 } catch (e) {
6375 i = 0;
6376 }
6377 module.exports = _regeneratorDefine = function regeneratorDefine(e, r, n, t) {
6378 function o(r, n) {
6379 _regeneratorDefine(e, r, function (e) {
6380 return this._invoke(r, n, e);
6381 });
6382 }
6383 r ? i ? i(e, r, {
6384 value: n,
6385 enumerable: !t,
6386 configurable: !t,
6387 writable: !t
6388 }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
6389 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _regeneratorDefine(e, r, n, t);
6390 }
6391 module.exports = _regeneratorDefine, module.exports.__esModule = true, module.exports["default"] = module.exports;
6392
6393 /***/ }),
6394
6395 /***/ "../node_modules/@babel/runtime/helpers/regeneratorKeys.js":
6396 /*!*****************************************************************!*\
6397 !*** ../node_modules/@babel/runtime/helpers/regeneratorKeys.js ***!
6398 \*****************************************************************/
6399 /***/ ((module) => {
6400
6401 function _regeneratorKeys(e) {
6402 var n = Object(e),
6403 r = [];
6404 for (var t in n) r.unshift(t);
6405 return function e() {
6406 for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e;
6407 return e.done = !0, e;
6408 };
6409 }
6410 module.exports = _regeneratorKeys, module.exports.__esModule = true, module.exports["default"] = module.exports;
6411
6412 /***/ }),
6413
6414 /***/ "../node_modules/@babel/runtime/helpers/regeneratorRuntime.js":
6415 /*!********************************************************************!*\
6416 !*** ../node_modules/@babel/runtime/helpers/regeneratorRuntime.js ***!
6417 \********************************************************************/
6418 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6419
6420 var OverloadYield = __webpack_require__(/*! ./OverloadYield.js */ "../node_modules/@babel/runtime/helpers/OverloadYield.js");
6421 var regenerator = __webpack_require__(/*! ./regenerator.js */ "../node_modules/@babel/runtime/helpers/regenerator.js");
6422 var regeneratorAsync = __webpack_require__(/*! ./regeneratorAsync.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsync.js");
6423 var regeneratorAsyncGen = __webpack_require__(/*! ./regeneratorAsyncGen.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js");
6424 var regeneratorAsyncIterator = __webpack_require__(/*! ./regeneratorAsyncIterator.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js");
6425 var regeneratorKeys = __webpack_require__(/*! ./regeneratorKeys.js */ "../node_modules/@babel/runtime/helpers/regeneratorKeys.js");
6426 var regeneratorValues = __webpack_require__(/*! ./regeneratorValues.js */ "../node_modules/@babel/runtime/helpers/regeneratorValues.js");
6427 function _regeneratorRuntime() {
6428 "use strict";
6429
6430 var r = regenerator(),
6431 e = r.m(_regeneratorRuntime),
6432 t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
6433 function n(r) {
6434 var e = "function" == typeof r && r.constructor;
6435 return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
6436 }
6437 var o = {
6438 "throw": 1,
6439 "return": 2,
6440 "break": 3,
6441 "continue": 3
6442 };
6443 function a(r) {
6444 var e, t;
6445 return function (n) {
6446 e || (e = {
6447 stop: function stop() {
6448 return t(n.a, 2);
6449 },
6450 "catch": function _catch() {
6451 return n.v;
6452 },
6453 abrupt: function abrupt(r, e) {
6454 return t(n.a, o[r], e);
6455 },
6456 delegateYield: function delegateYield(r, o, a) {
6457 return e.resultName = o, t(n.d, regeneratorValues(r), a);
6458 },
6459 finish: function finish(r) {
6460 return t(n.f, r);
6461 }
6462 }, t = function t(r, _t, o) {
6463 n.p = e.prev, n.n = e.next;
6464 try {
6465 return r(_t, o);
6466 } finally {
6467 e.next = n.n;
6468 }
6469 }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
6470 try {
6471 return r.call(this, e);
6472 } finally {
6473 n.p = e.prev, n.n = e.next;
6474 }
6475 };
6476 }
6477 return (module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
6478 return {
6479 wrap: function wrap(e, t, n, o) {
6480 return r.w(a(e), t, n, o && o.reverse());
6481 },
6482 isGeneratorFunction: n,
6483 mark: r.m,
6484 awrap: function awrap(r, e) {
6485 return new OverloadYield(r, e);
6486 },
6487 AsyncIterator: regeneratorAsyncIterator,
6488 async: function async(r, e, t, o, u) {
6489 return (n(e) ? regeneratorAsyncGen : regeneratorAsync)(a(r), e, t, o, u);
6490 },
6491 keys: regeneratorKeys,
6492 values: regeneratorValues
6493 };
6494 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
6495 }
6496 module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
6497
6498 /***/ }),
6499
6500 /***/ "../node_modules/@babel/runtime/helpers/regeneratorValues.js":
6501 /*!*******************************************************************!*\
6502 !*** ../node_modules/@babel/runtime/helpers/regeneratorValues.js ***!
6503 \*******************************************************************/
6504 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6505
6506 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6507 function _regeneratorValues(e) {
6508 if (null != e) {
6509 var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
6510 r = 0;
6511 if (t) return t.call(e);
6512 if ("function" == typeof e.next) return e;
6513 if (!isNaN(e.length)) return {
6514 next: function next() {
6515 return e && r >= e.length && (e = void 0), {
6516 value: e && e[r++],
6517 done: !e
6518 };
6519 }
6520 };
6521 }
6522 throw new TypeError(_typeof(e) + " is not iterable");
6523 }
6524 module.exports = _regeneratorValues, module.exports.__esModule = true, module.exports["default"] = module.exports;
6525
6526 /***/ }),
6527
6528 /***/ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js":
6529 /*!****************************************************************!*\
6530 !*** ../node_modules/@babel/runtime/helpers/setPrototypeOf.js ***!
6531 \****************************************************************/
6532 /***/ ((module) => {
6533
6534 function _setPrototypeOf(t, e) {
6535 return module.exports = _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
6536 return t.__proto__ = e, t;
6537 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _setPrototypeOf(t, e);
6538 }
6539 module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
6540
6541 /***/ }),
6542
6543 /***/ "../node_modules/@babel/runtime/helpers/slicedToArray.js":
6544 /*!***************************************************************!*\
6545 !*** ../node_modules/@babel/runtime/helpers/slicedToArray.js ***!
6546 \***************************************************************/
6547 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6548
6549 var arrayWithHoles = __webpack_require__(/*! ./arrayWithHoles.js */ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js");
6550 var iterableToArrayLimit = __webpack_require__(/*! ./iterableToArrayLimit.js */ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js");
6551 var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray.js */ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js");
6552 var nonIterableRest = __webpack_require__(/*! ./nonIterableRest.js */ "../node_modules/@babel/runtime/helpers/nonIterableRest.js");
6553 function _slicedToArray(r, e) {
6554 return arrayWithHoles(r) || iterableToArrayLimit(r, e) || unsupportedIterableToArray(r, e) || nonIterableRest();
6555 }
6556 module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
6557
6558 /***/ }),
6559
6560 /***/ "../node_modules/@babel/runtime/helpers/superPropBase.js":
6561 /*!***************************************************************!*\
6562 !*** ../node_modules/@babel/runtime/helpers/superPropBase.js ***!
6563 \***************************************************************/
6564 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6565
6566 var getPrototypeOf = __webpack_require__(/*! ./getPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js");
6567 function _superPropBase(t, o) {
6568 for (; !{}.hasOwnProperty.call(t, o) && null !== (t = getPrototypeOf(t)););
6569 return t;
6570 }
6571 module.exports = _superPropBase, module.exports.__esModule = true, module.exports["default"] = module.exports;
6572
6573 /***/ }),
6574
6575 /***/ "../node_modules/@babel/runtime/helpers/toPrimitive.js":
6576 /*!*************************************************************!*\
6577 !*** ../node_modules/@babel/runtime/helpers/toPrimitive.js ***!
6578 \*************************************************************/
6579 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6580
6581 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6582 function toPrimitive(t, r) {
6583 if ("object" != _typeof(t) || !t) return t;
6584 var e = t[Symbol.toPrimitive];
6585 if (void 0 !== e) {
6586 var i = e.call(t, r || "default");
6587 if ("object" != _typeof(i)) return i;
6588 throw new TypeError("@@toPrimitive must return a primitive value.");
6589 }
6590 return ("string" === r ? String : Number)(t);
6591 }
6592 module.exports = toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
6593
6594 /***/ }),
6595
6596 /***/ "../node_modules/@babel/runtime/helpers/toPropertyKey.js":
6597 /*!***************************************************************!*\
6598 !*** ../node_modules/@babel/runtime/helpers/toPropertyKey.js ***!
6599 \***************************************************************/
6600 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6601
6602 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6603 var toPrimitive = __webpack_require__(/*! ./toPrimitive.js */ "../node_modules/@babel/runtime/helpers/toPrimitive.js");
6604 function toPropertyKey(t) {
6605 var i = toPrimitive(t, "string");
6606 return "symbol" == _typeof(i) ? i : i + "";
6607 }
6608 module.exports = toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
6609
6610 /***/ }),
6611
6612 /***/ "../node_modules/@babel/runtime/helpers/typeof.js":
6613 /*!********************************************************!*\
6614 !*** ../node_modules/@babel/runtime/helpers/typeof.js ***!
6615 \********************************************************/
6616 /***/ ((module) => {
6617
6618 function _typeof(o) {
6619 "@babel/helpers - typeof";
6620
6621 return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
6622 return typeof o;
6623 } : function (o) {
6624 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
6625 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
6626 }
6627 module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
6628
6629 /***/ }),
6630
6631 /***/ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js":
6632 /*!****************************************************************************!*\
6633 !*** ../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js ***!
6634 \****************************************************************************/
6635 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6636
6637 var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray.js */ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js");
6638 function _unsupportedIterableToArray(r, a) {
6639 if (r) {
6640 if ("string" == typeof r) return arrayLikeToArray(r, a);
6641 var t = {}.toString.call(r).slice(8, -1);
6642 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;
6643 }
6644 }
6645 module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
6646
6647 /***/ }),
6648
6649 /***/ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js":
6650 /*!*****************************************************************!*\
6651 !*** ../node_modules/@babel/runtime/helpers/wrapNativeSuper.js ***!
6652 \*****************************************************************/
6653 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6654
6655 var getPrototypeOf = __webpack_require__(/*! ./getPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js");
6656 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
6657 var isNativeFunction = __webpack_require__(/*! ./isNativeFunction.js */ "../node_modules/@babel/runtime/helpers/isNativeFunction.js");
6658 var construct = __webpack_require__(/*! ./construct.js */ "../node_modules/@babel/runtime/helpers/construct.js");
6659 function _wrapNativeSuper(t) {
6660 var r = "function" == typeof Map ? new Map() : void 0;
6661 return module.exports = _wrapNativeSuper = function _wrapNativeSuper(t) {
6662 if (null === t || !isNativeFunction(t)) return t;
6663 if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
6664 if (void 0 !== r) {
6665 if (r.has(t)) return r.get(t);
6666 r.set(t, Wrapper);
6667 }
6668 function Wrapper() {
6669 return construct(t, arguments, getPrototypeOf(this).constructor);
6670 }
6671 return Wrapper.prototype = Object.create(t.prototype, {
6672 constructor: {
6673 value: Wrapper,
6674 enumerable: !1,
6675 writable: !0,
6676 configurable: !0
6677 }
6678 }), setPrototypeOf(Wrapper, t);
6679 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _wrapNativeSuper(t);
6680 }
6681 module.exports = _wrapNativeSuper, module.exports.__esModule = true, module.exports["default"] = module.exports;
6682
6683 /***/ }),
6684
6685 /***/ "../node_modules/@babel/runtime/regenerator/index.js":
6686 /*!***********************************************************!*\
6687 !*** ../node_modules/@babel/runtime/regenerator/index.js ***!
6688 \***********************************************************/
6689 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6690
6691 // TODO(Babel 8): Remove this file.
6692
6693 var runtime = __webpack_require__(/*! ../helpers/regeneratorRuntime */ "../node_modules/@babel/runtime/helpers/regeneratorRuntime.js")();
6694 module.exports = runtime;
6695
6696 // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
6697 try {
6698 regeneratorRuntime = runtime;
6699 } catch (accidentalStrictMode) {
6700 if (typeof globalThis === "object") {
6701 globalThis.regeneratorRuntime = runtime;
6702 } else {
6703 Function("r", "regeneratorRuntime = r")(runtime);
6704 }
6705 }
6706
6707
6708 /***/ }),
6709
6710 /***/ "../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js":
6711 /*!******************************************************************!*\
6712 !*** ../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js ***!
6713 \******************************************************************/
6714 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
6715
6716 "use strict";
6717 __webpack_require__.r(__webpack_exports__);
6718 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
6719 /* harmony export */ EnhancerArray: () => (/* binding */ EnhancerArray),
6720 /* harmony export */ MiddlewareArray: () => (/* binding */ MiddlewareArray),
6721 /* harmony export */ SHOULD_AUTOBATCH: () => (/* binding */ SHOULD_AUTOBATCH),
6722 /* harmony export */ TaskAbortError: () => (/* binding */ TaskAbortError),
6723 /* harmony export */ __DO_NOT_USE__ActionTypes: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.__DO_NOT_USE__ActionTypes),
6724 /* harmony export */ addListener: () => (/* binding */ addListener),
6725 /* harmony export */ applyMiddleware: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.applyMiddleware),
6726 /* harmony export */ autoBatchEnhancer: () => (/* binding */ autoBatchEnhancer),
6727 /* harmony export */ bindActionCreators: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.bindActionCreators),
6728 /* harmony export */ clearAllListeners: () => (/* binding */ clearAllListeners),
6729 /* harmony export */ combineReducers: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.combineReducers),
6730 /* harmony export */ compose: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.compose),
6731 /* harmony export */ configureStore: () => (/* binding */ configureStore),
6732 /* harmony export */ createAction: () => (/* binding */ createAction),
6733 /* harmony export */ createActionCreatorInvariantMiddleware: () => (/* binding */ createActionCreatorInvariantMiddleware),
6734 /* harmony export */ createAsyncThunk: () => (/* binding */ createAsyncThunk),
6735 /* harmony export */ createDraftSafeSelector: () => (/* binding */ createDraftSafeSelector),
6736 /* harmony export */ createEntityAdapter: () => (/* binding */ createEntityAdapter),
6737 /* harmony export */ createImmutableStateInvariantMiddleware: () => (/* binding */ createImmutableStateInvariantMiddleware),
6738 /* harmony export */ createListenerMiddleware: () => (/* binding */ createListenerMiddleware),
6739 /* harmony export */ createNextState: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__["default"]),
6740 /* harmony export */ createReducer: () => (/* binding */ createReducer),
6741 /* harmony export */ createSelector: () => (/* reexport safe */ reselect__WEBPACK_IMPORTED_MODULE_2__.createSelector),
6742 /* harmony export */ createSerializableStateInvariantMiddleware: () => (/* binding */ createSerializableStateInvariantMiddleware),
6743 /* harmony export */ createSlice: () => (/* binding */ createSlice),
6744 /* harmony export */ createStore: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.createStore),
6745 /* harmony export */ current: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.current),
6746 /* harmony export */ findNonSerializableValue: () => (/* binding */ findNonSerializableValue),
6747 /* harmony export */ freeze: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.freeze),
6748 /* harmony export */ getDefaultMiddleware: () => (/* binding */ getDefaultMiddleware),
6749 /* harmony export */ getType: () => (/* binding */ getType),
6750 /* harmony export */ isAction: () => (/* binding */ isAction),
6751 /* harmony export */ isActionCreator: () => (/* binding */ isActionCreator),
6752 /* harmony export */ isAllOf: () => (/* binding */ isAllOf),
6753 /* harmony export */ isAnyOf: () => (/* binding */ isAnyOf),
6754 /* harmony export */ isAsyncThunkAction: () => (/* binding */ isAsyncThunkAction),
6755 /* harmony export */ isDraft: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.isDraft),
6756 /* harmony export */ isFluxStandardAction: () => (/* binding */ isFSA),
6757 /* harmony export */ isFulfilled: () => (/* binding */ isFulfilled),
6758 /* harmony export */ isImmutableDefault: () => (/* binding */ isImmutableDefault),
6759 /* harmony export */ isPending: () => (/* binding */ isPending),
6760 /* harmony export */ isPlain: () => (/* binding */ isPlain),
6761 /* harmony export */ isPlainObject: () => (/* binding */ isPlainObject),
6762 /* harmony export */ isRejected: () => (/* binding */ isRejected),
6763 /* harmony export */ isRejectedWithValue: () => (/* binding */ isRejectedWithValue),
6764 /* harmony export */ legacy_createStore: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.legacy_createStore),
6765 /* harmony export */ miniSerializeError: () => (/* binding */ miniSerializeError),
6766 /* harmony export */ nanoid: () => (/* binding */ nanoid),
6767 /* harmony export */ original: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.original),
6768 /* harmony export */ prepareAutoBatched: () => (/* binding */ prepareAutoBatched),
6769 /* harmony export */ removeListener: () => (/* binding */ removeListener),
6770 /* harmony export */ unwrapResult: () => (/* binding */ unwrapResult)
6771 /* harmony export */ });
6772 /* harmony import */ var immer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! immer */ "../node_modules/immer/dist/immer.esm.mjs");
6773 /* harmony import */ var redux__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! redux */ "../node_modules/redux/es/redux.js");
6774 /* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! reselect */ "../node_modules/reselect/es/index.js");
6775 /* harmony import */ var redux_thunk__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! redux-thunk */ "../node_modules/redux-thunk/es/index.js");
6776 var __extends = (undefined && undefined.__extends) || (function () {
6777 var extendStatics = function (d, b) {
6778 extendStatics = Object.setPrototypeOf ||
6779 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6780 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6781 return extendStatics(d, b);
6782 };
6783 return function (d, b) {
6784 if (typeof b !== "function" && b !== null)
6785 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
6786 extendStatics(d, b);
6787 function __() { this.constructor = d; }
6788 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6789 };
6790 })();
6791 var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
6792 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
6793 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
6794 function verb(n) { return function (v) { return step([n, v]); }; }
6795 function step(op) {
6796 if (f) throw new TypeError("Generator is already executing.");
6797 while (_) try {
6798 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;
6799 if (y = 0, t) op = [op[0] & 2, t.value];
6800 switch (op[0]) {
6801 case 0: case 1: t = op; break;
6802 case 4: _.label++; return { value: op[1], done: false };
6803 case 5: _.label++; y = op[1]; op = [0]; continue;
6804 case 7: op = _.ops.pop(); _.trys.pop(); continue;
6805 default:
6806 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
6807 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
6808 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
6809 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
6810 if (t[2]) _.ops.pop();
6811 _.trys.pop(); continue;
6812 }
6813 op = body.call(thisArg, _);
6814 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
6815 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
6816 }
6817 };
6818 var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
6819 for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
6820 to[j] = from[i];
6821 return to;
6822 };
6823 var __defProp = Object.defineProperty;
6824 var __defProps = Object.defineProperties;
6825 var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6826 var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6827 var __hasOwnProp = Object.prototype.hasOwnProperty;
6828 var __propIsEnum = Object.prototype.propertyIsEnumerable;
6829 var __defNormalProp = function (obj, key, value) { return key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value }) : obj[key] = value; };
6830 var __spreadValues = function (a, b) {
6831 for (var prop in b || (b = {}))
6832 if (__hasOwnProp.call(b, prop))
6833 __defNormalProp(a, prop, b[prop]);
6834 if (__getOwnPropSymbols)
6835 for (var _i = 0, _c = __getOwnPropSymbols(b); _i < _c.length; _i++) {
6836 var prop = _c[_i];
6837 if (__propIsEnum.call(b, prop))
6838 __defNormalProp(a, prop, b[prop]);
6839 }
6840 return a;
6841 };
6842 var __spreadProps = function (a, b) { return __defProps(a, __getOwnPropDescs(b)); };
6843 var __async = function (__this, __arguments, generator) {
6844 return new Promise(function (resolve, reject) {
6845 var fulfilled = function (value) {
6846 try {
6847 step(generator.next(value));
6848 }
6849 catch (e) {
6850 reject(e);
6851 }
6852 };
6853 var rejected = function (value) {
6854 try {
6855 step(generator.throw(value));
6856 }
6857 catch (e) {
6858 reject(e);
6859 }
6860 };
6861 var step = function (x) { return x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); };
6862 step((generator = generator.apply(__this, __arguments)).next());
6863 });
6864 };
6865 // src/index.ts
6866
6867
6868
6869
6870 // src/createDraftSafeSelector.ts
6871
6872
6873 var createDraftSafeSelector = function () {
6874 var args = [];
6875 for (var _i = 0; _i < arguments.length; _i++) {
6876 args[_i] = arguments[_i];
6877 }
6878 var selector = reselect__WEBPACK_IMPORTED_MODULE_2__.createSelector.apply(void 0, args);
6879 var wrappedSelector = function (value) {
6880 var rest = [];
6881 for (var _i = 1; _i < arguments.length; _i++) {
6882 rest[_i - 1] = arguments[_i];
6883 }
6884 return selector.apply(void 0, __spreadArray([(0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(value) ? (0,immer__WEBPACK_IMPORTED_MODULE_0__.current)(value) : value], rest));
6885 };
6886 return wrappedSelector;
6887 };
6888 // src/configureStore.ts
6889
6890 // src/devtoolsExtension.ts
6891
6892 var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function () {
6893 if (arguments.length === 0)
6894 return void 0;
6895 if (typeof arguments[0] === "object")
6896 return redux__WEBPACK_IMPORTED_MODULE_1__.compose;
6897 return redux__WEBPACK_IMPORTED_MODULE_1__.compose.apply(null, arguments);
6898 };
6899 var devToolsEnhancer = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__ : function () {
6900 return function (noop2) {
6901 return noop2;
6902 };
6903 };
6904 // src/isPlainObject.ts
6905 function isPlainObject(value) {
6906 if (typeof value !== "object" || value === null)
6907 return false;
6908 var proto = Object.getPrototypeOf(value);
6909 if (proto === null)
6910 return true;
6911 var baseProto = proto;
6912 while (Object.getPrototypeOf(baseProto) !== null) {
6913 baseProto = Object.getPrototypeOf(baseProto);
6914 }
6915 return proto === baseProto;
6916 }
6917 // src/getDefaultMiddleware.ts
6918
6919 // src/tsHelpers.ts
6920 var hasMatchFunction = function (v) {
6921 return v && typeof v.match === "function";
6922 };
6923 // src/createAction.ts
6924 function createAction(type, prepareAction) {
6925 function actionCreator() {
6926 var args = [];
6927 for (var _i = 0; _i < arguments.length; _i++) {
6928 args[_i] = arguments[_i];
6929 }
6930 if (prepareAction) {
6931 var prepared = prepareAction.apply(void 0, args);
6932 if (!prepared) {
6933 throw new Error("prepareAction did not return an object");
6934 }
6935 return __spreadValues(__spreadValues({
6936 type: type,
6937 payload: prepared.payload
6938 }, "meta" in prepared && { meta: prepared.meta }), "error" in prepared && { error: prepared.error });
6939 }
6940 return { type: type, payload: args[0] };
6941 }
6942 actionCreator.toString = function () { return "" + type; };
6943 actionCreator.type = type;
6944 actionCreator.match = function (action) { return action.type === type; };
6945 return actionCreator;
6946 }
6947 function isAction(action) {
6948 return isPlainObject(action) && "type" in action;
6949 }
6950 function isActionCreator(action) {
6951 return typeof action === "function" && "type" in action && hasMatchFunction(action);
6952 }
6953 function isFSA(action) {
6954 return isAction(action) && typeof action.type === "string" && Object.keys(action).every(isValidKey);
6955 }
6956 function isValidKey(key) {
6957 return ["type", "payload", "error", "meta"].indexOf(key) > -1;
6958 }
6959 function getType(actionCreator) {
6960 return "" + actionCreator;
6961 }
6962 // src/actionCreatorInvariantMiddleware.ts
6963 function getMessage(type) {
6964 var splitType = type ? ("" + type).split("/") : [];
6965 var actionName = splitType[splitType.length - 1] || "actionCreator";
6966 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.";
6967 }
6968 function createActionCreatorInvariantMiddleware(options) {
6969 if (options === void 0) { options = {}; }
6970 if (false) // removed by dead control flow
6971 {}
6972 var _c = options.isActionCreator, isActionCreator2 = _c === void 0 ? isActionCreator : _c;
6973 return function () { return function (next) { return function (action) {
6974 if (isActionCreator2(action)) {
6975 console.warn(getMessage(action.type));
6976 }
6977 return next(action);
6978 }; }; };
6979 }
6980 // src/utils.ts
6981
6982 function getTimeMeasureUtils(maxDelay, fnName) {
6983 var elapsed = 0;
6984 return {
6985 measureTime: function (fn) {
6986 var started = Date.now();
6987 try {
6988 return fn();
6989 }
6990 finally {
6991 var finished = Date.now();
6992 elapsed += finished - started;
6993 }
6994 },
6995 warnIfExceeded: function () {
6996 if (elapsed > maxDelay) {
6997 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.");
6998 }
6999 }
7000 };
7001 }
7002 var MiddlewareArray = /** @class */ (function (_super) {
7003 __extends(MiddlewareArray, _super);
7004 function MiddlewareArray() {
7005 var args = [];
7006 for (var _i = 0; _i < arguments.length; _i++) {
7007 args[_i] = arguments[_i];
7008 }
7009 var _this = _super.apply(this, args) || this;
7010 Object.setPrototypeOf(_this, MiddlewareArray.prototype);
7011 return _this;
7012 }
7013 Object.defineProperty(MiddlewareArray, Symbol.species, {
7014 get: function () {
7015 return MiddlewareArray;
7016 },
7017 enumerable: false,
7018 configurable: true
7019 });
7020 MiddlewareArray.prototype.concat = function () {
7021 var arr = [];
7022 for (var _i = 0; _i < arguments.length; _i++) {
7023 arr[_i] = arguments[_i];
7024 }
7025 return _super.prototype.concat.apply(this, arr);
7026 };
7027 MiddlewareArray.prototype.prepend = function () {
7028 var arr = [];
7029 for (var _i = 0; _i < arguments.length; _i++) {
7030 arr[_i] = arguments[_i];
7031 }
7032 if (arr.length === 1 && Array.isArray(arr[0])) {
7033 return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr[0].concat(this))))();
7034 }
7035 return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr.concat(this))))();
7036 };
7037 return MiddlewareArray;
7038 }(Array));
7039 var EnhancerArray = /** @class */ (function (_super) {
7040 __extends(EnhancerArray, _super);
7041 function EnhancerArray() {
7042 var args = [];
7043 for (var _i = 0; _i < arguments.length; _i++) {
7044 args[_i] = arguments[_i];
7045 }
7046 var _this = _super.apply(this, args) || this;
7047 Object.setPrototypeOf(_this, EnhancerArray.prototype);
7048 return _this;
7049 }
7050 Object.defineProperty(EnhancerArray, Symbol.species, {
7051 get: function () {
7052 return EnhancerArray;
7053 },
7054 enumerable: false,
7055 configurable: true
7056 });
7057 EnhancerArray.prototype.concat = function () {
7058 var arr = [];
7059 for (var _i = 0; _i < arguments.length; _i++) {
7060 arr[_i] = arguments[_i];
7061 }
7062 return _super.prototype.concat.apply(this, arr);
7063 };
7064 EnhancerArray.prototype.prepend = function () {
7065 var arr = [];
7066 for (var _i = 0; _i < arguments.length; _i++) {
7067 arr[_i] = arguments[_i];
7068 }
7069 if (arr.length === 1 && Array.isArray(arr[0])) {
7070 return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr[0].concat(this))))();
7071 }
7072 return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr.concat(this))))();
7073 };
7074 return EnhancerArray;
7075 }(Array));
7076 function freezeDraftable(val) {
7077 return (0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraftable)(val) ? (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(val, function () {
7078 }) : val;
7079 }
7080 // src/immutableStateInvariantMiddleware.ts
7081 var isProduction = "development" === "production";
7082 var prefix = "Invariant failed";
7083 function invariant(condition, message) {
7084 if (condition) {
7085 return;
7086 }
7087 if (isProduction) {
7088 throw new Error(prefix);
7089 }
7090 throw new Error(prefix + ": " + (message || ""));
7091 }
7092 function stringify(obj, serializer, indent, decycler) {
7093 return JSON.stringify(obj, getSerialize(serializer, decycler), indent);
7094 }
7095 function getSerialize(serializer, decycler) {
7096 var stack = [], keys = [];
7097 if (!decycler)
7098 decycler = function (_, value) {
7099 if (stack[0] === value)
7100 return "[Circular ~]";
7101 return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
7102 };
7103 return function (key, value) {
7104 if (stack.length > 0) {
7105 var thisPos = stack.indexOf(this);
7106 ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
7107 ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
7108 if (~stack.indexOf(value))
7109 value = decycler.call(this, key, value);
7110 }
7111 else
7112 stack.push(value);
7113 return serializer == null ? value : serializer.call(this, key, value);
7114 };
7115 }
7116 function isImmutableDefault(value) {
7117 return typeof value !== "object" || value == null || Object.isFrozen(value);
7118 }
7119 function trackForMutations(isImmutable, ignorePaths, obj) {
7120 var trackedProperties = trackProperties(isImmutable, ignorePaths, obj);
7121 return {
7122 detectMutations: function () {
7123 return detectMutations(isImmutable, ignorePaths, trackedProperties, obj);
7124 }
7125 };
7126 }
7127 function trackProperties(isImmutable, ignorePaths, obj, path, checkedObjects) {
7128 if (ignorePaths === void 0) { ignorePaths = []; }
7129 if (path === void 0) { path = ""; }
7130 if (checkedObjects === void 0) { checkedObjects = new Set(); }
7131 var tracked = { value: obj };
7132 if (!isImmutable(obj) && !checkedObjects.has(obj)) {
7133 checkedObjects.add(obj);
7134 tracked.children = {};
7135 for (var key in obj) {
7136 var childPath = path ? path + "." + key : key;
7137 if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
7138 continue;
7139 }
7140 tracked.children[key] = trackProperties(isImmutable, ignorePaths, obj[key], childPath);
7141 }
7142 }
7143 return tracked;
7144 }
7145 function detectMutations(isImmutable, ignoredPaths, trackedProperty, obj, sameParentRef, path) {
7146 if (ignoredPaths === void 0) { ignoredPaths = []; }
7147 if (sameParentRef === void 0) { sameParentRef = false; }
7148 if (path === void 0) { path = ""; }
7149 var prevObj = trackedProperty ? trackedProperty.value : void 0;
7150 var sameRef = prevObj === obj;
7151 if (sameParentRef && !sameRef && !Number.isNaN(obj)) {
7152 return { wasMutated: true, path: path };
7153 }
7154 if (isImmutable(prevObj) || isImmutable(obj)) {
7155 return { wasMutated: false };
7156 }
7157 var keysToDetect = {};
7158 for (var key in trackedProperty.children) {
7159 keysToDetect[key] = true;
7160 }
7161 for (var key in obj) {
7162 keysToDetect[key] = true;
7163 }
7164 var hasIgnoredPaths = ignoredPaths.length > 0;
7165 var _loop_1 = function (key) {
7166 var nestedPath = path ? path + "." + key : key;
7167 if (hasIgnoredPaths) {
7168 var hasMatches = ignoredPaths.some(function (ignored) {
7169 if (ignored instanceof RegExp) {
7170 return ignored.test(nestedPath);
7171 }
7172 return nestedPath === ignored;
7173 });
7174 if (hasMatches) {
7175 return "continue";
7176 }
7177 }
7178 var result = detectMutations(isImmutable, ignoredPaths, trackedProperty.children[key], obj[key], sameRef, nestedPath);
7179 if (result.wasMutated) {
7180 return { value: result };
7181 }
7182 };
7183 for (var key in keysToDetect) {
7184 var state_1 = _loop_1(key);
7185 if (typeof state_1 === "object")
7186 return state_1.value;
7187 }
7188 return { wasMutated: false };
7189 }
7190 function createImmutableStateInvariantMiddleware(options) {
7191 if (options === void 0) { options = {}; }
7192 if (false) // removed by dead control flow
7193 {}
7194 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;
7195 ignoredPaths = ignoredPaths || ignore;
7196 var track = trackForMutations.bind(null, isImmutable, ignoredPaths);
7197 return function (_c) {
7198 var getState = _c.getState;
7199 var state = getState();
7200 var tracker = track(state);
7201 var result;
7202 return function (next) { return function (action) {
7203 var measureUtils = getTimeMeasureUtils(warnAfter, "ImmutableStateInvariantMiddleware");
7204 measureUtils.measureTime(function () {
7205 state = getState();
7206 result = tracker.detectMutations();
7207 tracker = track(state);
7208 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)");
7209 });
7210 var dispatchedAction = next(action);
7211 measureUtils.measureTime(function () {
7212 state = getState();
7213 result = tracker.detectMutations();
7214 tracker = track(state);
7215 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)");
7216 });
7217 measureUtils.warnIfExceeded();
7218 return dispatchedAction;
7219 }; };
7220 };
7221 }
7222 // src/serializableStateInvariantMiddleware.ts
7223 function isPlain(val) {
7224 var type = typeof val;
7225 return val == null || type === "string" || type === "boolean" || type === "number" || Array.isArray(val) || isPlainObject(val);
7226 }
7227 function findNonSerializableValue(value, path, isSerializable, getEntries, ignoredPaths, cache) {
7228 if (path === void 0) { path = ""; }
7229 if (isSerializable === void 0) { isSerializable = isPlain; }
7230 if (ignoredPaths === void 0) { ignoredPaths = []; }
7231 var foundNestedSerializable;
7232 if (!isSerializable(value)) {
7233 return {
7234 keyPath: path || "<root>",
7235 value: value
7236 };
7237 }
7238 if (typeof value !== "object" || value === null) {
7239 return false;
7240 }
7241 if (cache == null ? void 0 : cache.has(value))
7242 return false;
7243 var entries = getEntries != null ? getEntries(value) : Object.entries(value);
7244 var hasIgnoredPaths = ignoredPaths.length > 0;
7245 var _loop_2 = function (key, nestedValue) {
7246 var nestedPath = path ? path + "." + key : key;
7247 if (hasIgnoredPaths) {
7248 var hasMatches = ignoredPaths.some(function (ignored) {
7249 if (ignored instanceof RegExp) {
7250 return ignored.test(nestedPath);
7251 }
7252 return nestedPath === ignored;
7253 });
7254 if (hasMatches) {
7255 return "continue";
7256 }
7257 }
7258 if (!isSerializable(nestedValue)) {
7259 return { value: {
7260 keyPath: nestedPath,
7261 value: nestedValue
7262 } };
7263 }
7264 if (typeof nestedValue === "object") {
7265 foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths, cache);
7266 if (foundNestedSerializable) {
7267 return { value: foundNestedSerializable };
7268 }
7269 }
7270 };
7271 for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
7272 var _c = entries_1[_i], key = _c[0], nestedValue = _c[1];
7273 var state_2 = _loop_2(key, nestedValue);
7274 if (typeof state_2 === "object")
7275 return state_2.value;
7276 }
7277 if (cache && isNestedFrozen(value))
7278 cache.add(value);
7279 return false;
7280 }
7281 function isNestedFrozen(value) {
7282 if (!Object.isFrozen(value))
7283 return false;
7284 for (var _i = 0, _c = Object.values(value); _i < _c.length; _i++) {
7285 var nestedValue = _c[_i];
7286 if (typeof nestedValue !== "object" || nestedValue === null)
7287 continue;
7288 if (!isNestedFrozen(nestedValue))
7289 return false;
7290 }
7291 return true;
7292 }
7293 function createSerializableStateInvariantMiddleware(options) {
7294 if (options === void 0) { options = {}; }
7295 if (false) // removed by dead control flow
7296 {}
7297 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;
7298 var cache = !disableCache && WeakSet ? new WeakSet() : void 0;
7299 return function (storeAPI) { return function (next) { return function (action) {
7300 var result = next(action);
7301 var measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware");
7302 if (!ignoreActions && !(ignoredActions.length && ignoredActions.indexOf(action.type) !== -1)) {
7303 measureUtils.measureTime(function () {
7304 var foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths, cache);
7305 if (foundActionNonSerializableValue) {
7306 var keyPath = foundActionNonSerializableValue.keyPath, value = foundActionNonSerializableValue.value;
7307 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)");
7308 }
7309 });
7310 }
7311 if (!ignoreState) {
7312 measureUtils.measureTime(function () {
7313 var state = storeAPI.getState();
7314 var foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths, cache);
7315 if (foundStateNonSerializableValue) {
7316 var keyPath = foundStateNonSerializableValue.keyPath, value = foundStateNonSerializableValue.value;
7317 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)");
7318 }
7319 });
7320 measureUtils.warnIfExceeded();
7321 }
7322 return result;
7323 }; }; };
7324 }
7325 // src/getDefaultMiddleware.ts
7326 function isBoolean(x) {
7327 return typeof x === "boolean";
7328 }
7329 function curryGetDefaultMiddleware() {
7330 return function curriedGetDefaultMiddleware(options) {
7331 return getDefaultMiddleware(options);
7332 };
7333 }
7334 function getDefaultMiddleware(options) {
7335 if (options === void 0) { options = {}; }
7336 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;
7337 var middlewareArray = new MiddlewareArray();
7338 if (thunk) {
7339 if (isBoolean(thunk)) {
7340 middlewareArray.push(redux_thunk__WEBPACK_IMPORTED_MODULE_3__["default"]);
7341 }
7342 else {
7343 middlewareArray.push(redux_thunk__WEBPACK_IMPORTED_MODULE_3__["default"].withExtraArgument(thunk.extraArgument));
7344 }
7345 }
7346 if (true) {
7347 if (immutableCheck) {
7348 var immutableOptions = {};
7349 if (!isBoolean(immutableCheck)) {
7350 immutableOptions = immutableCheck;
7351 }
7352 middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));
7353 }
7354 if (serializableCheck) {
7355 var serializableOptions = {};
7356 if (!isBoolean(serializableCheck)) {
7357 serializableOptions = serializableCheck;
7358 }
7359 middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions));
7360 }
7361 if (actionCreatorCheck) {
7362 var actionCreatorOptions = {};
7363 if (!isBoolean(actionCreatorCheck)) {
7364 actionCreatorOptions = actionCreatorCheck;
7365 }
7366 middlewareArray.unshift(createActionCreatorInvariantMiddleware(actionCreatorOptions));
7367 }
7368 }
7369 return middlewareArray;
7370 }
7371 // src/configureStore.ts
7372 var IS_PRODUCTION = "development" === "production";
7373 function configureStore(options) {
7374 var curriedGetDefaultMiddleware = curryGetDefaultMiddleware();
7375 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;
7376 var rootReducer;
7377 if (typeof reducer === "function") {
7378 rootReducer = reducer;
7379 }
7380 else if (isPlainObject(reducer)) {
7381 rootReducer = (0,redux__WEBPACK_IMPORTED_MODULE_1__.combineReducers)(reducer);
7382 }
7383 else {
7384 throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');
7385 }
7386 var finalMiddleware = middleware;
7387 if (typeof finalMiddleware === "function") {
7388 finalMiddleware = finalMiddleware(curriedGetDefaultMiddleware);
7389 if (!IS_PRODUCTION && !Array.isArray(finalMiddleware)) {
7390 throw new Error("when using a middleware builder function, an array of middleware must be returned");
7391 }
7392 }
7393 if (!IS_PRODUCTION && finalMiddleware.some(function (item) { return typeof item !== "function"; })) {
7394 throw new Error("each middleware provided to configureStore must be a function");
7395 }
7396 var middlewareEnhancer = redux__WEBPACK_IMPORTED_MODULE_1__.applyMiddleware.apply(void 0, finalMiddleware);
7397 var finalCompose = redux__WEBPACK_IMPORTED_MODULE_1__.compose;
7398 if (devTools) {
7399 finalCompose = composeWithDevTools(__spreadValues({
7400 trace: !IS_PRODUCTION
7401 }, typeof devTools === "object" && devTools));
7402 }
7403 var defaultEnhancers = new EnhancerArray(middlewareEnhancer);
7404 var storeEnhancers = defaultEnhancers;
7405 if (Array.isArray(enhancers)) {
7406 storeEnhancers = __spreadArray([middlewareEnhancer], enhancers);
7407 }
7408 else if (typeof enhancers === "function") {
7409 storeEnhancers = enhancers(defaultEnhancers);
7410 }
7411 var composedEnhancer = finalCompose.apply(void 0, storeEnhancers);
7412 return (0,redux__WEBPACK_IMPORTED_MODULE_1__.createStore)(rootReducer, preloadedState, composedEnhancer);
7413 }
7414 // src/createReducer.ts
7415
7416 // src/mapBuilders.ts
7417 function executeReducerBuilderCallback(builderCallback) {
7418 var actionsMap = {};
7419 var actionMatchers = [];
7420 var defaultCaseReducer;
7421 var builder = {
7422 addCase: function (typeOrActionCreator, reducer) {
7423 if (true) {
7424 if (actionMatchers.length > 0) {
7425 throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");
7426 }
7427 if (defaultCaseReducer) {
7428 throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");
7429 }
7430 }
7431 var type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
7432 if (!type) {
7433 throw new Error("`builder.addCase` cannot be called with an empty action type");
7434 }
7435 if (type in actionsMap) {
7436 throw new Error("`builder.addCase` cannot be called with two reducers for the same action type");
7437 }
7438 actionsMap[type] = reducer;
7439 return builder;
7440 },
7441 addMatcher: function (matcher, reducer) {
7442 if (true) {
7443 if (defaultCaseReducer) {
7444 throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");
7445 }
7446 }
7447 actionMatchers.push({ matcher: matcher, reducer: reducer });
7448 return builder;
7449 },
7450 addDefaultCase: function (reducer) {
7451 if (true) {
7452 if (defaultCaseReducer) {
7453 throw new Error("`builder.addDefaultCase` can only be called once");
7454 }
7455 }
7456 defaultCaseReducer = reducer;
7457 return builder;
7458 }
7459 };
7460 builderCallback(builder);
7461 return [actionsMap, actionMatchers, defaultCaseReducer];
7462 }
7463 // src/createReducer.ts
7464 function isStateFunction(x) {
7465 return typeof x === "function";
7466 }
7467 var hasWarnedAboutObjectNotation = false;
7468 function createReducer(initialState, mapOrBuilderCallback, actionMatchers, defaultCaseReducer) {
7469 if (actionMatchers === void 0) { actionMatchers = []; }
7470 if (true) {
7471 if (typeof mapOrBuilderCallback === "object") {
7472 if (!hasWarnedAboutObjectNotation) {
7473 hasWarnedAboutObjectNotation = true;
7474 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");
7475 }
7476 }
7477 }
7478 var _c = typeof mapOrBuilderCallback === "function" ? executeReducerBuilderCallback(mapOrBuilderCallback) : [mapOrBuilderCallback, actionMatchers, defaultCaseReducer], actionsMap = _c[0], finalActionMatchers = _c[1], finalDefaultCaseReducer = _c[2];
7479 var getInitialState;
7480 if (isStateFunction(initialState)) {
7481 getInitialState = function () { return freezeDraftable(initialState()); };
7482 }
7483 else {
7484 var frozenInitialState_1 = freezeDraftable(initialState);
7485 getInitialState = function () { return frozenInitialState_1; };
7486 }
7487 function reducer(state, action) {
7488 if (state === void 0) { state = getInitialState(); }
7489 var caseReducers = __spreadArray([
7490 actionsMap[action.type]
7491 ], finalActionMatchers.filter(function (_c) {
7492 var matcher = _c.matcher;
7493 return matcher(action);
7494 }).map(function (_c) {
7495 var reducer2 = _c.reducer;
7496 return reducer2;
7497 }));
7498 if (caseReducers.filter(function (cr) { return !!cr; }).length === 0) {
7499 caseReducers = [finalDefaultCaseReducer];
7500 }
7501 return caseReducers.reduce(function (previousState, caseReducer) {
7502 if (caseReducer) {
7503 if ((0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(previousState)) {
7504 var draft = previousState;
7505 var result = caseReducer(draft, action);
7506 if (result === void 0) {
7507 return previousState;
7508 }
7509 return result;
7510 }
7511 else if (!(0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraftable)(previousState)) {
7512 var result = caseReducer(previousState, action);
7513 if (result === void 0) {
7514 if (previousState === null) {
7515 return previousState;
7516 }
7517 throw Error("A case reducer on a non-draftable value must not return undefined");
7518 }
7519 return result;
7520 }
7521 else {
7522 return (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(previousState, function (draft) {
7523 return caseReducer(draft, action);
7524 });
7525 }
7526 }
7527 return previousState;
7528 }, state);
7529 }
7530 reducer.getInitialState = getInitialState;
7531 return reducer;
7532 }
7533 // src/createSlice.ts
7534 var hasWarnedAboutObjectNotation2 = false;
7535 function getType2(slice, actionKey) {
7536 return slice + "/" + actionKey;
7537 }
7538 function createSlice(options) {
7539 var name = options.name;
7540 if (!name) {
7541 throw new Error("`name` is a required option for createSlice");
7542 }
7543 if (typeof process !== "undefined" && "development" === "development") {
7544 if (options.initialState === void 0) {
7545 console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");
7546 }
7547 }
7548 var initialState = typeof options.initialState == "function" ? options.initialState : freezeDraftable(options.initialState);
7549 var reducers = options.reducers || {};
7550 var reducerNames = Object.keys(reducers);
7551 var sliceCaseReducersByName = {};
7552 var sliceCaseReducersByType = {};
7553 var actionCreators = {};
7554 reducerNames.forEach(function (reducerName) {
7555 var maybeReducerWithPrepare = reducers[reducerName];
7556 var type = getType2(name, reducerName);
7557 var caseReducer;
7558 var prepareCallback;
7559 if ("reducer" in maybeReducerWithPrepare) {
7560 caseReducer = maybeReducerWithPrepare.reducer;
7561 prepareCallback = maybeReducerWithPrepare.prepare;
7562 }
7563 else {
7564 caseReducer = maybeReducerWithPrepare;
7565 }
7566 sliceCaseReducersByName[reducerName] = caseReducer;
7567 sliceCaseReducersByType[type] = caseReducer;
7568 actionCreators[reducerName] = prepareCallback ? createAction(type, prepareCallback) : createAction(type);
7569 });
7570 function buildReducer() {
7571 if (true) {
7572 if (typeof options.extraReducers === "object") {
7573 if (!hasWarnedAboutObjectNotation2) {
7574 hasWarnedAboutObjectNotation2 = true;
7575 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");
7576 }
7577 }
7578 }
7579 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;
7580 var finalCaseReducers = __spreadValues(__spreadValues({}, extraReducers), sliceCaseReducersByType);
7581 return createReducer(initialState, function (builder) {
7582 for (var key in finalCaseReducers) {
7583 builder.addCase(key, finalCaseReducers[key]);
7584 }
7585 for (var _i = 0, actionMatchers_1 = actionMatchers; _i < actionMatchers_1.length; _i++) {
7586 var m = actionMatchers_1[_i];
7587 builder.addMatcher(m.matcher, m.reducer);
7588 }
7589 if (defaultCaseReducer) {
7590 builder.addDefaultCase(defaultCaseReducer);
7591 }
7592 });
7593 }
7594 var _reducer;
7595 return {
7596 name: name,
7597 reducer: function (state, action) {
7598 if (!_reducer)
7599 _reducer = buildReducer();
7600 return _reducer(state, action);
7601 },
7602 actions: actionCreators,
7603 caseReducers: sliceCaseReducersByName,
7604 getInitialState: function () {
7605 if (!_reducer)
7606 _reducer = buildReducer();
7607 return _reducer.getInitialState();
7608 }
7609 };
7610 }
7611 // src/entities/entity_state.ts
7612 function getInitialEntityState() {
7613 return {
7614 ids: [],
7615 entities: {}
7616 };
7617 }
7618 function createInitialStateFactory() {
7619 function getInitialState(additionalState) {
7620 if (additionalState === void 0) { additionalState = {}; }
7621 return Object.assign(getInitialEntityState(), additionalState);
7622 }
7623 return { getInitialState: getInitialState };
7624 }
7625 // src/entities/state_selectors.ts
7626 function createSelectorsFactory() {
7627 function getSelectors(selectState) {
7628 var selectIds = function (state) { return state.ids; };
7629 var selectEntities = function (state) { return state.entities; };
7630 var selectAll = createDraftSafeSelector(selectIds, selectEntities, function (ids, entities) { return ids.map(function (id) { return entities[id]; }); });
7631 var selectId = function (_, id) { return id; };
7632 var selectById = function (entities, id) { return entities[id]; };
7633 var selectTotal = createDraftSafeSelector(selectIds, function (ids) { return ids.length; });
7634 if (!selectState) {
7635 return {
7636 selectIds: selectIds,
7637 selectEntities: selectEntities,
7638 selectAll: selectAll,
7639 selectTotal: selectTotal,
7640 selectById: createDraftSafeSelector(selectEntities, selectId, selectById)
7641 };
7642 }
7643 var selectGlobalizedEntities = createDraftSafeSelector(selectState, selectEntities);
7644 return {
7645 selectIds: createDraftSafeSelector(selectState, selectIds),
7646 selectEntities: selectGlobalizedEntities,
7647 selectAll: createDraftSafeSelector(selectState, selectAll),
7648 selectTotal: createDraftSafeSelector(selectState, selectTotal),
7649 selectById: createDraftSafeSelector(selectGlobalizedEntities, selectId, selectById)
7650 };
7651 }
7652 return { getSelectors: getSelectors };
7653 }
7654 // src/entities/state_adapter.ts
7655
7656 function createSingleArgumentStateOperator(mutator) {
7657 var operator = createStateOperator(function (_, state) { return mutator(state); });
7658 return function operation(state) {
7659 return operator(state, void 0);
7660 };
7661 }
7662 function createStateOperator(mutator) {
7663 return function operation(state, arg) {
7664 function isPayloadActionArgument(arg2) {
7665 return isFSA(arg2);
7666 }
7667 var runMutator = function (draft) {
7668 if (isPayloadActionArgument(arg)) {
7669 mutator(arg.payload, draft);
7670 }
7671 else {
7672 mutator(arg, draft);
7673 }
7674 };
7675 if ((0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(state)) {
7676 runMutator(state);
7677 return state;
7678 }
7679 else {
7680 return (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(state, runMutator);
7681 }
7682 };
7683 }
7684 // src/entities/utils.ts
7685 function selectIdValue(entity, selectId) {
7686 var key = selectId(entity);
7687 if ( true && key === void 0) {
7688 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());
7689 }
7690 return key;
7691 }
7692 function ensureEntitiesArray(entities) {
7693 if (!Array.isArray(entities)) {
7694 entities = Object.values(entities);
7695 }
7696 return entities;
7697 }
7698 function splitAddedUpdatedEntities(newEntities, selectId, state) {
7699 newEntities = ensureEntitiesArray(newEntities);
7700 var added = [];
7701 var updated = [];
7702 for (var _i = 0, newEntities_1 = newEntities; _i < newEntities_1.length; _i++) {
7703 var entity = newEntities_1[_i];
7704 var id = selectIdValue(entity, selectId);
7705 if (id in state.entities) {
7706 updated.push({ id: id, changes: entity });
7707 }
7708 else {
7709 added.push(entity);
7710 }
7711 }
7712 return [added, updated];
7713 }
7714 // src/entities/unsorted_state_adapter.ts
7715 function createUnsortedStateAdapter(selectId) {
7716 function addOneMutably(entity, state) {
7717 var key = selectIdValue(entity, selectId);
7718 if (key in state.entities) {
7719 return;
7720 }
7721 state.ids.push(key);
7722 state.entities[key] = entity;
7723 }
7724 function addManyMutably(newEntities, state) {
7725 newEntities = ensureEntitiesArray(newEntities);
7726 for (var _i = 0, newEntities_2 = newEntities; _i < newEntities_2.length; _i++) {
7727 var entity = newEntities_2[_i];
7728 addOneMutably(entity, state);
7729 }
7730 }
7731 function setOneMutably(entity, state) {
7732 var key = selectIdValue(entity, selectId);
7733 if (!(key in state.entities)) {
7734 state.ids.push(key);
7735 }
7736 state.entities[key] = entity;
7737 }
7738 function setManyMutably(newEntities, state) {
7739 newEntities = ensureEntitiesArray(newEntities);
7740 for (var _i = 0, newEntities_3 = newEntities; _i < newEntities_3.length; _i++) {
7741 var entity = newEntities_3[_i];
7742 setOneMutably(entity, state);
7743 }
7744 }
7745 function setAllMutably(newEntities, state) {
7746 newEntities = ensureEntitiesArray(newEntities);
7747 state.ids = [];
7748 state.entities = {};
7749 addManyMutably(newEntities, state);
7750 }
7751 function removeOneMutably(key, state) {
7752 return removeManyMutably([key], state);
7753 }
7754 function removeManyMutably(keys, state) {
7755 var didMutate = false;
7756 keys.forEach(function (key) {
7757 if (key in state.entities) {
7758 delete state.entities[key];
7759 didMutate = true;
7760 }
7761 });
7762 if (didMutate) {
7763 state.ids = state.ids.filter(function (id) { return id in state.entities; });
7764 }
7765 }
7766 function removeAllMutably(state) {
7767 Object.assign(state, {
7768 ids: [],
7769 entities: {}
7770 });
7771 }
7772 function takeNewKey(keys, update, state) {
7773 var original2 = state.entities[update.id];
7774 var updated = Object.assign({}, original2, update.changes);
7775 var newKey = selectIdValue(updated, selectId);
7776 var hasNewKey = newKey !== update.id;
7777 if (hasNewKey) {
7778 keys[update.id] = newKey;
7779 delete state.entities[update.id];
7780 }
7781 state.entities[newKey] = updated;
7782 return hasNewKey;
7783 }
7784 function updateOneMutably(update, state) {
7785 return updateManyMutably([update], state);
7786 }
7787 function updateManyMutably(updates, state) {
7788 var newKeys = {};
7789 var updatesPerEntity = {};
7790 updates.forEach(function (update) {
7791 if (update.id in state.entities) {
7792 updatesPerEntity[update.id] = {
7793 id: update.id,
7794 changes: __spreadValues(__spreadValues({}, updatesPerEntity[update.id] ? updatesPerEntity[update.id].changes : null), update.changes)
7795 };
7796 }
7797 });
7798 updates = Object.values(updatesPerEntity);
7799 var didMutateEntities = updates.length > 0;
7800 if (didMutateEntities) {
7801 var didMutateIds = updates.filter(function (update) { return takeNewKey(newKeys, update, state); }).length > 0;
7802 if (didMutateIds) {
7803 state.ids = Object.keys(state.entities);
7804 }
7805 }
7806 }
7807 function upsertOneMutably(entity, state) {
7808 return upsertManyMutably([entity], state);
7809 }
7810 function upsertManyMutably(newEntities, state) {
7811 var _c = splitAddedUpdatedEntities(newEntities, selectId, state), added = _c[0], updated = _c[1];
7812 updateManyMutably(updated, state);
7813 addManyMutably(added, state);
7814 }
7815 return {
7816 removeAll: createSingleArgumentStateOperator(removeAllMutably),
7817 addOne: createStateOperator(addOneMutably),
7818 addMany: createStateOperator(addManyMutably),
7819 setOne: createStateOperator(setOneMutably),
7820 setMany: createStateOperator(setManyMutably),
7821 setAll: createStateOperator(setAllMutably),
7822 updateOne: createStateOperator(updateOneMutably),
7823 updateMany: createStateOperator(updateManyMutably),
7824 upsertOne: createStateOperator(upsertOneMutably),
7825 upsertMany: createStateOperator(upsertManyMutably),
7826 removeOne: createStateOperator(removeOneMutably),
7827 removeMany: createStateOperator(removeManyMutably)
7828 };
7829 }
7830 // src/entities/sorted_state_adapter.ts
7831 function createSortedStateAdapter(selectId, sort) {
7832 var _c = createUnsortedStateAdapter(selectId), removeOne = _c.removeOne, removeMany = _c.removeMany, removeAll = _c.removeAll;
7833 function addOneMutably(entity, state) {
7834 return addManyMutably([entity], state);
7835 }
7836 function addManyMutably(newEntities, state) {
7837 newEntities = ensureEntitiesArray(newEntities);
7838 var models = newEntities.filter(function (model) { return !(selectIdValue(model, selectId) in state.entities); });
7839 if (models.length !== 0) {
7840 merge(models, state);
7841 }
7842 }
7843 function setOneMutably(entity, state) {
7844 return setManyMutably([entity], state);
7845 }
7846 function setManyMutably(newEntities, state) {
7847 newEntities = ensureEntitiesArray(newEntities);
7848 if (newEntities.length !== 0) {
7849 merge(newEntities, state);
7850 }
7851 }
7852 function setAllMutably(newEntities, state) {
7853 newEntities = ensureEntitiesArray(newEntities);
7854 state.entities = {};
7855 state.ids = [];
7856 addManyMutably(newEntities, state);
7857 }
7858 function updateOneMutably(update, state) {
7859 return updateManyMutably([update], state);
7860 }
7861 function updateManyMutably(updates, state) {
7862 var appliedUpdates = false;
7863 for (var _i = 0, updates_1 = updates; _i < updates_1.length; _i++) {
7864 var update = updates_1[_i];
7865 var entity = state.entities[update.id];
7866 if (!entity) {
7867 continue;
7868 }
7869 appliedUpdates = true;
7870 Object.assign(entity, update.changes);
7871 var newId = selectId(entity);
7872 if (update.id !== newId) {
7873 delete state.entities[update.id];
7874 state.entities[newId] = entity;
7875 }
7876 }
7877 if (appliedUpdates) {
7878 resortEntities(state);
7879 }
7880 }
7881 function upsertOneMutably(entity, state) {
7882 return upsertManyMutably([entity], state);
7883 }
7884 function upsertManyMutably(newEntities, state) {
7885 var _c = splitAddedUpdatedEntities(newEntities, selectId, state), added = _c[0], updated = _c[1];
7886 updateManyMutably(updated, state);
7887 addManyMutably(added, state);
7888 }
7889 function areArraysEqual(a, b) {
7890 if (a.length !== b.length) {
7891 return false;
7892 }
7893 for (var i = 0; i < a.length && i < b.length; i++) {
7894 if (a[i] === b[i]) {
7895 continue;
7896 }
7897 return false;
7898 }
7899 return true;
7900 }
7901 function merge(models, state) {
7902 models.forEach(function (model) {
7903 state.entities[selectId(model)] = model;
7904 });
7905 resortEntities(state);
7906 }
7907 function resortEntities(state) {
7908 var allEntities = Object.values(state.entities);
7909 allEntities.sort(sort);
7910 var newSortedIds = allEntities.map(selectId);
7911 var ids = state.ids;
7912 if (!areArraysEqual(ids, newSortedIds)) {
7913 state.ids = newSortedIds;
7914 }
7915 }
7916 return {
7917 removeOne: removeOne,
7918 removeMany: removeMany,
7919 removeAll: removeAll,
7920 addOne: createStateOperator(addOneMutably),
7921 updateOne: createStateOperator(updateOneMutably),
7922 upsertOne: createStateOperator(upsertOneMutably),
7923 setOne: createStateOperator(setOneMutably),
7924 setMany: createStateOperator(setManyMutably),
7925 setAll: createStateOperator(setAllMutably),
7926 addMany: createStateOperator(addManyMutably),
7927 updateMany: createStateOperator(updateManyMutably),
7928 upsertMany: createStateOperator(upsertManyMutably)
7929 };
7930 }
7931 // src/entities/create_adapter.ts
7932 function createEntityAdapter(options) {
7933 if (options === void 0) { options = {}; }
7934 var _c = __spreadValues({
7935 sortComparer: false,
7936 selectId: function (instance) { return instance.id; }
7937 }, options), selectId = _c.selectId, sortComparer = _c.sortComparer;
7938 var stateFactory = createInitialStateFactory();
7939 var selectorsFactory = createSelectorsFactory();
7940 var stateAdapter = sortComparer ? createSortedStateAdapter(selectId, sortComparer) : createUnsortedStateAdapter(selectId);
7941 return __spreadValues(__spreadValues(__spreadValues({
7942 selectId: selectId,
7943 sortComparer: sortComparer
7944 }, stateFactory), selectorsFactory), stateAdapter);
7945 }
7946 // src/nanoid.ts
7947 var urlAlphabet = "ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";
7948 var nanoid = function (size) {
7949 if (size === void 0) { size = 21; }
7950 var id = "";
7951 var i = size;
7952 while (i--) {
7953 id += urlAlphabet[Math.random() * 64 | 0];
7954 }
7955 return id;
7956 };
7957 // src/createAsyncThunk.ts
7958 var commonProperties = [
7959 "name",
7960 "message",
7961 "stack",
7962 "code"
7963 ];
7964 var RejectWithValue = /** @class */ (function () {
7965 function RejectWithValue(payload, meta) {
7966 this.payload = payload;
7967 this.meta = meta;
7968 }
7969 return RejectWithValue;
7970 }());
7971 var FulfillWithMeta = /** @class */ (function () {
7972 function FulfillWithMeta(payload, meta) {
7973 this.payload = payload;
7974 this.meta = meta;
7975 }
7976 return FulfillWithMeta;
7977 }());
7978 var miniSerializeError = function (value) {
7979 if (typeof value === "object" && value !== null) {
7980 var simpleError = {};
7981 for (var _i = 0, commonProperties_1 = commonProperties; _i < commonProperties_1.length; _i++) {
7982 var property = commonProperties_1[_i];
7983 if (typeof value[property] === "string") {
7984 simpleError[property] = value[property];
7985 }
7986 }
7987 return simpleError;
7988 }
7989 return { message: String(value) };
7990 };
7991 var createAsyncThunk = (function () {
7992 function createAsyncThunk2(typePrefix, payloadCreator, options) {
7993 var fulfilled = createAction(typePrefix + "/fulfilled", function (payload, requestId, arg, meta) { return ({
7994 payload: payload,
7995 meta: __spreadProps(__spreadValues({}, meta || {}), {
7996 arg: arg,
7997 requestId: requestId,
7998 requestStatus: "fulfilled"
7999 })
8000 }); });
8001 var pending = createAction(typePrefix + "/pending", function (requestId, arg, meta) { return ({
8002 payload: void 0,
8003 meta: __spreadProps(__spreadValues({}, meta || {}), {
8004 arg: arg,
8005 requestId: requestId,
8006 requestStatus: "pending"
8007 })
8008 }); });
8009 var rejected = createAction(typePrefix + "/rejected", function (error, requestId, arg, payload, meta) { return ({
8010 payload: payload,
8011 error: (options && options.serializeError || miniSerializeError)(error || "Rejected"),
8012 meta: __spreadProps(__spreadValues({}, meta || {}), {
8013 arg: arg,
8014 requestId: requestId,
8015 rejectedWithValue: !!payload,
8016 requestStatus: "rejected",
8017 aborted: (error == null ? void 0 : error.name) === "AbortError",
8018 condition: (error == null ? void 0 : error.name) === "ConditionError"
8019 })
8020 }); });
8021 var displayedWarning = false;
8022 var AC = typeof AbortController !== "undefined" ? AbortController : /** @class */ (function () {
8023 function class_1() {
8024 this.signal = {
8025 aborted: false,
8026 addEventListener: function () {
8027 },
8028 dispatchEvent: function () {
8029 return false;
8030 },
8031 onabort: function () {
8032 },
8033 removeEventListener: function () {
8034 },
8035 reason: void 0,
8036 throwIfAborted: function () {
8037 }
8038 };
8039 }
8040 class_1.prototype.abort = function () {
8041 if (true) {
8042 if (!displayedWarning) {
8043 displayedWarning = true;
8044 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'.");
8045 }
8046 }
8047 };
8048 return class_1;
8049 }());
8050 function actionCreator(arg) {
8051 return function (dispatch, getState, extra) {
8052 var requestId = (options == null ? void 0 : options.idGenerator) ? options.idGenerator(arg) : nanoid();
8053 var abortController = new AC();
8054 var abortReason;
8055 var started = false;
8056 function abort(reason) {
8057 abortReason = reason;
8058 abortController.abort();
8059 }
8060 var promise2 = function () {
8061 return __async(this, null, function () {
8062 var _a, _b, finalAction, conditionResult, abortedPromise, err_1, skipDispatch;
8063 return __generator(this, function (_c) {
8064 switch (_c.label) {
8065 case 0:
8066 _c.trys.push([0, 4, , 5]);
8067 conditionResult = (_a = options == null ? void 0 : options.condition) == null ? void 0 : _a.call(options, arg, { getState: getState, extra: extra });
8068 if (!isThenable(conditionResult)) return [3 /*break*/, 2];
8069 return [4 /*yield*/, conditionResult];
8070 case 1:
8071 conditionResult = _c.sent();
8072 _c.label = 2;
8073 case 2:
8074 if (conditionResult === false || abortController.signal.aborted) {
8075 throw {
8076 name: "ConditionError",
8077 message: "Aborted due to condition callback returning false."
8078 };
8079 }
8080 started = true;
8081 abortedPromise = new Promise(function (_, reject) { return abortController.signal.addEventListener("abort", function () { return reject({
8082 name: "AbortError",
8083 message: abortReason || "Aborted"
8084 }); }); });
8085 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 })));
8086 return [4 /*yield*/, Promise.race([
8087 abortedPromise,
8088 Promise.resolve(payloadCreator(arg, {
8089 dispatch: dispatch,
8090 getState: getState,
8091 extra: extra,
8092 requestId: requestId,
8093 signal: abortController.signal,
8094 abort: abort,
8095 rejectWithValue: function (value, meta) {
8096 return new RejectWithValue(value, meta);
8097 },
8098 fulfillWithValue: function (value, meta) {
8099 return new FulfillWithMeta(value, meta);
8100 }
8101 })).then(function (result) {
8102 if (result instanceof RejectWithValue) {
8103 throw result;
8104 }
8105 if (result instanceof FulfillWithMeta) {
8106 return fulfilled(result.payload, requestId, arg, result.meta);
8107 }
8108 return fulfilled(result, requestId, arg);
8109 })
8110 ])];
8111 case 3:
8112 finalAction = _c.sent();
8113 return [3 /*break*/, 5];
8114 case 4:
8115 err_1 = _c.sent();
8116 finalAction = err_1 instanceof RejectWithValue ? rejected(null, requestId, arg, err_1.payload, err_1.meta) : rejected(err_1, requestId, arg);
8117 return [3 /*break*/, 5];
8118 case 5:
8119 skipDispatch = options && !options.dispatchConditionRejection && rejected.match(finalAction) && finalAction.meta.condition;
8120 if (!skipDispatch) {
8121 dispatch(finalAction);
8122 }
8123 return [2 /*return*/, finalAction];
8124 }
8125 });
8126 });
8127 }();
8128 return Object.assign(promise2, {
8129 abort: abort,
8130 requestId: requestId,
8131 arg: arg,
8132 unwrap: function () {
8133 return promise2.then(unwrapResult);
8134 }
8135 });
8136 };
8137 }
8138 return Object.assign(actionCreator, {
8139 pending: pending,
8140 rejected: rejected,
8141 fulfilled: fulfilled,
8142 typePrefix: typePrefix
8143 });
8144 }
8145 createAsyncThunk2.withTypes = function () { return createAsyncThunk2; };
8146 return createAsyncThunk2;
8147 })();
8148 function unwrapResult(action) {
8149 if (action.meta && action.meta.rejectedWithValue) {
8150 throw action.payload;
8151 }
8152 if (action.error) {
8153 throw action.error;
8154 }
8155 return action.payload;
8156 }
8157 function isThenable(value) {
8158 return value !== null && typeof value === "object" && typeof value.then === "function";
8159 }
8160 // src/matchers.ts
8161 var matches = function (matcher, action) {
8162 if (hasMatchFunction(matcher)) {
8163 return matcher.match(action);
8164 }
8165 else {
8166 return matcher(action);
8167 }
8168 };
8169 function isAnyOf() {
8170 var matchers = [];
8171 for (var _i = 0; _i < arguments.length; _i++) {
8172 matchers[_i] = arguments[_i];
8173 }
8174 return function (action) {
8175 return matchers.some(function (matcher) { return matches(matcher, action); });
8176 };
8177 }
8178 function isAllOf() {
8179 var matchers = [];
8180 for (var _i = 0; _i < arguments.length; _i++) {
8181 matchers[_i] = arguments[_i];
8182 }
8183 return function (action) {
8184 return matchers.every(function (matcher) { return matches(matcher, action); });
8185 };
8186 }
8187 function hasExpectedRequestMetadata(action, validStatus) {
8188 if (!action || !action.meta)
8189 return false;
8190 var hasValidRequestId = typeof action.meta.requestId === "string";
8191 var hasValidRequestStatus = validStatus.indexOf(action.meta.requestStatus) > -1;
8192 return hasValidRequestId && hasValidRequestStatus;
8193 }
8194 function isAsyncThunkArray(a) {
8195 return typeof a[0] === "function" && "pending" in a[0] && "fulfilled" in a[0] && "rejected" in a[0];
8196 }
8197 function isPending() {
8198 var asyncThunks = [];
8199 for (var _i = 0; _i < arguments.length; _i++) {
8200 asyncThunks[_i] = arguments[_i];
8201 }
8202 if (asyncThunks.length === 0) {
8203 return function (action) { return hasExpectedRequestMetadata(action, ["pending"]); };
8204 }
8205 if (!isAsyncThunkArray(asyncThunks)) {
8206 return isPending()(asyncThunks[0]);
8207 }
8208 return function (action) {
8209 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.pending; });
8210 var combinedMatcher = isAnyOf.apply(void 0, matchers);
8211 return combinedMatcher(action);
8212 };
8213 }
8214 function isRejected() {
8215 var asyncThunks = [];
8216 for (var _i = 0; _i < arguments.length; _i++) {
8217 asyncThunks[_i] = arguments[_i];
8218 }
8219 if (asyncThunks.length === 0) {
8220 return function (action) { return hasExpectedRequestMetadata(action, ["rejected"]); };
8221 }
8222 if (!isAsyncThunkArray(asyncThunks)) {
8223 return isRejected()(asyncThunks[0]);
8224 }
8225 return function (action) {
8226 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.rejected; });
8227 var combinedMatcher = isAnyOf.apply(void 0, matchers);
8228 return combinedMatcher(action);
8229 };
8230 }
8231 function isRejectedWithValue() {
8232 var asyncThunks = [];
8233 for (var _i = 0; _i < arguments.length; _i++) {
8234 asyncThunks[_i] = arguments[_i];
8235 }
8236 var hasFlag = function (action) {
8237 return action && action.meta && action.meta.rejectedWithValue;
8238 };
8239 if (asyncThunks.length === 0) {
8240 return function (action) {
8241 var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
8242 return combinedMatcher(action);
8243 };
8244 }
8245 if (!isAsyncThunkArray(asyncThunks)) {
8246 return isRejectedWithValue()(asyncThunks[0]);
8247 }
8248 return function (action) {
8249 var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
8250 return combinedMatcher(action);
8251 };
8252 }
8253 function isFulfilled() {
8254 var asyncThunks = [];
8255 for (var _i = 0; _i < arguments.length; _i++) {
8256 asyncThunks[_i] = arguments[_i];
8257 }
8258 if (asyncThunks.length === 0) {
8259 return function (action) { return hasExpectedRequestMetadata(action, ["fulfilled"]); };
8260 }
8261 if (!isAsyncThunkArray(asyncThunks)) {
8262 return isFulfilled()(asyncThunks[0]);
8263 }
8264 return function (action) {
8265 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.fulfilled; });
8266 var combinedMatcher = isAnyOf.apply(void 0, matchers);
8267 return combinedMatcher(action);
8268 };
8269 }
8270 function isAsyncThunkAction() {
8271 var asyncThunks = [];
8272 for (var _i = 0; _i < arguments.length; _i++) {
8273 asyncThunks[_i] = arguments[_i];
8274 }
8275 if (asyncThunks.length === 0) {
8276 return function (action) { return hasExpectedRequestMetadata(action, ["pending", "fulfilled", "rejected"]); };
8277 }
8278 if (!isAsyncThunkArray(asyncThunks)) {
8279 return isAsyncThunkAction()(asyncThunks[0]);
8280 }
8281 return function (action) {
8282 var matchers = [];
8283 for (var _i = 0, asyncThunks_1 = asyncThunks; _i < asyncThunks_1.length; _i++) {
8284 var asyncThunk = asyncThunks_1[_i];
8285 matchers.push(asyncThunk.pending, asyncThunk.rejected, asyncThunk.fulfilled);
8286 }
8287 var combinedMatcher = isAnyOf.apply(void 0, matchers);
8288 return combinedMatcher(action);
8289 };
8290 }
8291 // src/listenerMiddleware/utils.ts
8292 var assertFunction = function (func, expected) {
8293 if (typeof func !== "function") {
8294 throw new TypeError(expected + " is not a function");
8295 }
8296 };
8297 var noop = function () {
8298 };
8299 var catchRejection = function (promise2, onError) {
8300 if (onError === void 0) { onError = noop; }
8301 promise2.catch(onError);
8302 return promise2;
8303 };
8304 var addAbortSignalListener = function (abortSignal, callback) {
8305 abortSignal.addEventListener("abort", callback, { once: true });
8306 return function () { return abortSignal.removeEventListener("abort", callback); };
8307 };
8308 var abortControllerWithReason = function (abortController, reason) {
8309 var signal = abortController.signal;
8310 if (signal.aborted) {
8311 return;
8312 }
8313 if (!("reason" in signal)) {
8314 Object.defineProperty(signal, "reason", {
8315 enumerable: true,
8316 value: reason,
8317 configurable: true,
8318 writable: true
8319 });
8320 }
8321 ;
8322 abortController.abort(reason);
8323 };
8324 // src/listenerMiddleware/exceptions.ts
8325 var task = "task";
8326 var listener = "listener";
8327 var completed = "completed";
8328 var cancelled = "cancelled";
8329 var taskCancelled = "task-" + cancelled;
8330 var taskCompleted = "task-" + completed;
8331 var listenerCancelled = listener + "-" + cancelled;
8332 var listenerCompleted = listener + "-" + completed;
8333 var TaskAbortError = /** @class */ (function () {
8334 function TaskAbortError(code) {
8335 this.code = code;
8336 this.name = "TaskAbortError";
8337 this.message = task + " " + cancelled + " (reason: " + code + ")";
8338 }
8339 return TaskAbortError;
8340 }());
8341 // src/listenerMiddleware/task.ts
8342 var validateActive = function (signal) {
8343 if (signal.aborted) {
8344 throw new TaskAbortError(signal.reason);
8345 }
8346 };
8347 function raceWithSignal(signal, promise2) {
8348 var cleanup = noop;
8349 return new Promise(function (resolve, reject) {
8350 var notifyRejection = function () { return reject(new TaskAbortError(signal.reason)); };
8351 if (signal.aborted) {
8352 notifyRejection();
8353 return;
8354 }
8355 cleanup = addAbortSignalListener(signal, notifyRejection);
8356 promise2.finally(function () { return cleanup(); }).then(resolve, reject);
8357 }).finally(function () {
8358 cleanup = noop;
8359 });
8360 }
8361 var runTask = function (task2, cleanUp) { return __async(void 0, null, function () {
8362 var value, error_1;
8363 return __generator(this, function (_c) {
8364 switch (_c.label) {
8365 case 0:
8366 _c.trys.push([0, 3, 4, 5]);
8367 return [4 /*yield*/, Promise.resolve()];
8368 case 1:
8369 _c.sent();
8370 return [4 /*yield*/, task2()];
8371 case 2:
8372 value = _c.sent();
8373 return [2 /*return*/, {
8374 status: "ok",
8375 value: value
8376 }];
8377 case 3:
8378 error_1 = _c.sent();
8379 return [2 /*return*/, {
8380 status: error_1 instanceof TaskAbortError ? "cancelled" : "rejected",
8381 error: error_1
8382 }];
8383 case 4:
8384 cleanUp == null ? void 0 : cleanUp();
8385 return [7 /*endfinally*/];
8386 case 5: return [2 /*return*/];
8387 }
8388 });
8389 }); };
8390 var createPause = function (signal) {
8391 return function (promise2) {
8392 return catchRejection(raceWithSignal(signal, promise2).then(function (output) {
8393 validateActive(signal);
8394 return output;
8395 }));
8396 };
8397 };
8398 var createDelay = function (signal) {
8399 var pause = createPause(signal);
8400 return function (timeoutMs) {
8401 return pause(new Promise(function (resolve) { return setTimeout(resolve, timeoutMs); }));
8402 };
8403 };
8404 // src/listenerMiddleware/index.ts
8405 var assign = Object.assign;
8406 var INTERNAL_NIL_TOKEN = {};
8407 var alm = "listenerMiddleware";
8408 var createFork = function (parentAbortSignal, parentBlockingPromises) {
8409 var linkControllers = function (controller) { return addAbortSignalListener(parentAbortSignal, function () { return abortControllerWithReason(controller, parentAbortSignal.reason); }); };
8410 return function (taskExecutor, opts) {
8411 assertFunction(taskExecutor, "taskExecutor");
8412 var childAbortController = new AbortController();
8413 linkControllers(childAbortController);
8414 var result = runTask(function () { return __async(void 0, null, function () {
8415 var result2;
8416 return __generator(this, function (_c) {
8417 switch (_c.label) {
8418 case 0:
8419 validateActive(parentAbortSignal);
8420 validateActive(childAbortController.signal);
8421 return [4 /*yield*/, taskExecutor({
8422 pause: createPause(childAbortController.signal),
8423 delay: createDelay(childAbortController.signal),
8424 signal: childAbortController.signal
8425 })];
8426 case 1:
8427 result2 = _c.sent();
8428 validateActive(childAbortController.signal);
8429 return [2 /*return*/, result2];
8430 }
8431 });
8432 }); }, function () { return abortControllerWithReason(childAbortController, taskCompleted); });
8433 if (opts == null ? void 0 : opts.autoJoin) {
8434 parentBlockingPromises.push(result);
8435 }
8436 return {
8437 result: createPause(parentAbortSignal)(result),
8438 cancel: function () {
8439 abortControllerWithReason(childAbortController, taskCancelled);
8440 }
8441 };
8442 };
8443 };
8444 var createTakePattern = function (startListening, signal) {
8445 var take = function (predicate, timeout) { return __async(void 0, null, function () {
8446 var unsubscribe, tuplePromise, promises, output;
8447 return __generator(this, function (_c) {
8448 switch (_c.label) {
8449 case 0:
8450 validateActive(signal);
8451 unsubscribe = function () {
8452 };
8453 tuplePromise = new Promise(function (resolve, reject) {
8454 var stopListening = startListening({
8455 predicate: predicate,
8456 effect: function (action, listenerApi) {
8457 listenerApi.unsubscribe();
8458 resolve([
8459 action,
8460 listenerApi.getState(),
8461 listenerApi.getOriginalState()
8462 ]);
8463 }
8464 });
8465 unsubscribe = function () {
8466 stopListening();
8467 reject();
8468 };
8469 });
8470 promises = [
8471 tuplePromise
8472 ];
8473 if (timeout != null) {
8474 promises.push(new Promise(function (resolve) { return setTimeout(resolve, timeout, null); }));
8475 }
8476 _c.label = 1;
8477 case 1:
8478 _c.trys.push([1, , 3, 4]);
8479 return [4 /*yield*/, raceWithSignal(signal, Promise.race(promises))];
8480 case 2:
8481 output = _c.sent();
8482 validateActive(signal);
8483 return [2 /*return*/, output];
8484 case 3:
8485 unsubscribe();
8486 return [7 /*endfinally*/];
8487 case 4: return [2 /*return*/];
8488 }
8489 });
8490 }); };
8491 return function (predicate, timeout) { return catchRejection(take(predicate, timeout)); };
8492 };
8493 var getListenerEntryPropsFrom = function (options) {
8494 var type = options.type, actionCreator = options.actionCreator, matcher = options.matcher, predicate = options.predicate, effect = options.effect;
8495 if (type) {
8496 predicate = createAction(type).match;
8497 }
8498 else if (actionCreator) {
8499 type = actionCreator.type;
8500 predicate = actionCreator.match;
8501 }
8502 else if (matcher) {
8503 predicate = matcher;
8504 }
8505 else if (predicate) {
8506 }
8507 else {
8508 throw new Error("Creating or removing a listener requires one of the known fields for matching an action");
8509 }
8510 assertFunction(effect, "options.listener");
8511 return { predicate: predicate, type: type, effect: effect };
8512 };
8513 var createListenerEntry = function (options) {
8514 var _c = getListenerEntryPropsFrom(options), type = _c.type, predicate = _c.predicate, effect = _c.effect;
8515 var id = nanoid();
8516 var entry = {
8517 id: id,
8518 effect: effect,
8519 type: type,
8520 predicate: predicate,
8521 pending: new Set(),
8522 unsubscribe: function () {
8523 throw new Error("Unsubscribe not initialized");
8524 }
8525 };
8526 return entry;
8527 };
8528 var cancelActiveListeners = function (entry) {
8529 entry.pending.forEach(function (controller) {
8530 abortControllerWithReason(controller, listenerCancelled);
8531 });
8532 };
8533 var createClearListenerMiddleware = function (listenerMap) {
8534 return function () {
8535 listenerMap.forEach(cancelActiveListeners);
8536 listenerMap.clear();
8537 };
8538 };
8539 var safelyNotifyError = function (errorHandler, errorToNotify, errorInfo) {
8540 try {
8541 errorHandler(errorToNotify, errorInfo);
8542 }
8543 catch (errorHandlerError) {
8544 setTimeout(function () {
8545 throw errorHandlerError;
8546 }, 0);
8547 }
8548 };
8549 var addListener = createAction(alm + "/add");
8550 var clearAllListeners = createAction(alm + "/removeAll");
8551 var removeListener = createAction(alm + "/remove");
8552 var defaultErrorHandler = function () {
8553 var args = [];
8554 for (var _i = 0; _i < arguments.length; _i++) {
8555 args[_i] = arguments[_i];
8556 }
8557 console.error.apply(console, __spreadArray([alm + "/error"], args));
8558 };
8559 function createListenerMiddleware(middlewareOptions) {
8560 var _this = this;
8561 if (middlewareOptions === void 0) { middlewareOptions = {}; }
8562 var listenerMap = new Map();
8563 var extra = middlewareOptions.extra, _c = middlewareOptions.onError, onError = _c === void 0 ? defaultErrorHandler : _c;
8564 assertFunction(onError, "onError");
8565 var insertEntry = function (entry) {
8566 entry.unsubscribe = function () { return listenerMap.delete(entry.id); };
8567 listenerMap.set(entry.id, entry);
8568 return function (cancelOptions) {
8569 entry.unsubscribe();
8570 if (cancelOptions == null ? void 0 : cancelOptions.cancelActive) {
8571 cancelActiveListeners(entry);
8572 }
8573 };
8574 };
8575 var findListenerEntry = function (comparator) {
8576 for (var _i = 0, _c = Array.from(listenerMap.values()); _i < _c.length; _i++) {
8577 var entry = _c[_i];
8578 if (comparator(entry)) {
8579 return entry;
8580 }
8581 }
8582 return void 0;
8583 };
8584 var startListening = function (options) {
8585 var entry = findListenerEntry(function (existingEntry) { return existingEntry.effect === options.effect; });
8586 if (!entry) {
8587 entry = createListenerEntry(options);
8588 }
8589 return insertEntry(entry);
8590 };
8591 var stopListening = function (options) {
8592 var _c = getListenerEntryPropsFrom(options), type = _c.type, effect = _c.effect, predicate = _c.predicate;
8593 var entry = findListenerEntry(function (entry2) {
8594 var matchPredicateOrType = typeof type === "string" ? entry2.type === type : entry2.predicate === predicate;
8595 return matchPredicateOrType && entry2.effect === effect;
8596 });
8597 if (entry) {
8598 entry.unsubscribe();
8599 if (options.cancelActive) {
8600 cancelActiveListeners(entry);
8601 }
8602 }
8603 return !!entry;
8604 };
8605 var notifyListener = function (entry, action, api, getOriginalState) { return __async(_this, null, function () {
8606 var internalTaskController, take, autoJoinPromises, listenerError_1;
8607 return __generator(this, function (_c) {
8608 switch (_c.label) {
8609 case 0:
8610 internalTaskController = new AbortController();
8611 take = createTakePattern(startListening, internalTaskController.signal);
8612 autoJoinPromises = [];
8613 _c.label = 1;
8614 case 1:
8615 _c.trys.push([1, 3, 4, 6]);
8616 entry.pending.add(internalTaskController);
8617 return [4 /*yield*/, Promise.resolve(entry.effect(action, assign({}, api, {
8618 getOriginalState: getOriginalState,
8619 condition: function (predicate, timeout) { return take(predicate, timeout).then(Boolean); },
8620 take: take,
8621 delay: createDelay(internalTaskController.signal),
8622 pause: createPause(internalTaskController.signal),
8623 extra: extra,
8624 signal: internalTaskController.signal,
8625 fork: createFork(internalTaskController.signal, autoJoinPromises),
8626 unsubscribe: entry.unsubscribe,
8627 subscribe: function () {
8628 listenerMap.set(entry.id, entry);
8629 },
8630 cancelActiveListeners: function () {
8631 entry.pending.forEach(function (controller, _, set) {
8632 if (controller !== internalTaskController) {
8633 abortControllerWithReason(controller, listenerCancelled);
8634 set.delete(controller);
8635 }
8636 });
8637 }
8638 })))];
8639 case 2:
8640 _c.sent();
8641 return [3 /*break*/, 6];
8642 case 3:
8643 listenerError_1 = _c.sent();
8644 if (!(listenerError_1 instanceof TaskAbortError)) {
8645 safelyNotifyError(onError, listenerError_1, {
8646 raisedBy: "effect"
8647 });
8648 }
8649 return [3 /*break*/, 6];
8650 case 4: return [4 /*yield*/, Promise.allSettled(autoJoinPromises)];
8651 case 5:
8652 _c.sent();
8653 abortControllerWithReason(internalTaskController, listenerCompleted);
8654 entry.pending.delete(internalTaskController);
8655 return [7 /*endfinally*/];
8656 case 6: return [2 /*return*/];
8657 }
8658 });
8659 }); };
8660 var clearListenerMiddleware = createClearListenerMiddleware(listenerMap);
8661 var middleware = function (api) { return function (next) { return function (action) {
8662 if (!isAction(action)) {
8663 return next(action);
8664 }
8665 if (addListener.match(action)) {
8666 return startListening(action.payload);
8667 }
8668 if (clearAllListeners.match(action)) {
8669 clearListenerMiddleware();
8670 return;
8671 }
8672 if (removeListener.match(action)) {
8673 return stopListening(action.payload);
8674 }
8675 var originalState = api.getState();
8676 var getOriginalState = function () {
8677 if (originalState === INTERNAL_NIL_TOKEN) {
8678 throw new Error(alm + ": getOriginalState can only be called synchronously");
8679 }
8680 return originalState;
8681 };
8682 var result;
8683 try {
8684 result = next(action);
8685 if (listenerMap.size > 0) {
8686 var currentState = api.getState();
8687 var listenerEntries = Array.from(listenerMap.values());
8688 for (var _i = 0, listenerEntries_1 = listenerEntries; _i < listenerEntries_1.length; _i++) {
8689 var entry = listenerEntries_1[_i];
8690 var runListener = false;
8691 try {
8692 runListener = entry.predicate(action, currentState, originalState);
8693 }
8694 catch (predicateError) {
8695 runListener = false;
8696 safelyNotifyError(onError, predicateError, {
8697 raisedBy: "predicate"
8698 });
8699 }
8700 if (!runListener) {
8701 continue;
8702 }
8703 notifyListener(entry, action, api, getOriginalState);
8704 }
8705 }
8706 }
8707 finally {
8708 originalState = INTERNAL_NIL_TOKEN;
8709 }
8710 return result;
8711 }; }; };
8712 return {
8713 middleware: middleware,
8714 startListening: startListening,
8715 stopListening: stopListening,
8716 clearListeners: clearListenerMiddleware
8717 };
8718 }
8719 // src/autoBatchEnhancer.ts
8720 var SHOULD_AUTOBATCH = "RTK_autoBatch";
8721 var prepareAutoBatched = function () { return function (payload) {
8722 var _c;
8723 return ({
8724 payload: payload,
8725 meta: (_c = {}, _c[SHOULD_AUTOBATCH] = true, _c)
8726 });
8727 }; };
8728 var promise;
8729 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 () {
8730 throw err;
8731 }, 0); }); };
8732 var createQueueWithTimer = function (timeout) {
8733 return function (notify) {
8734 setTimeout(notify, timeout);
8735 };
8736 };
8737 var rAF = typeof window !== "undefined" && window.requestAnimationFrame ? window.requestAnimationFrame : createQueueWithTimer(10);
8738 var autoBatchEnhancer = function (options) {
8739 if (options === void 0) { options = { type: "raf" }; }
8740 return function (next) { return function () {
8741 var args = [];
8742 for (var _i = 0; _i < arguments.length; _i++) {
8743 args[_i] = arguments[_i];
8744 }
8745 var store = next.apply(void 0, args);
8746 var notifying = true;
8747 var shouldNotifyAtEndOfTick = false;
8748 var notificationQueued = false;
8749 var listeners = new Set();
8750 var queueCallback = options.type === "tick" ? queueMicrotaskShim : options.type === "raf" ? rAF : options.type === "callback" ? options.queueNotification : createQueueWithTimer(options.timeout);
8751 var notifyListeners = function () {
8752 notificationQueued = false;
8753 if (shouldNotifyAtEndOfTick) {
8754 shouldNotifyAtEndOfTick = false;
8755 listeners.forEach(function (l) { return l(); });
8756 }
8757 };
8758 return Object.assign({}, store, {
8759 subscribe: function (listener2) {
8760 var wrappedListener = function () { return notifying && listener2(); };
8761 var unsubscribe = store.subscribe(wrappedListener);
8762 listeners.add(listener2);
8763 return function () {
8764 unsubscribe();
8765 listeners.delete(listener2);
8766 };
8767 },
8768 dispatch: function (action) {
8769 var _a;
8770 try {
8771 notifying = !((_a = action == null ? void 0 : action.meta) == null ? void 0 : _a[SHOULD_AUTOBATCH]);
8772 shouldNotifyAtEndOfTick = !notifying;
8773 if (shouldNotifyAtEndOfTick) {
8774 if (!notificationQueued) {
8775 notificationQueued = true;
8776 queueCallback(notifyListeners);
8777 }
8778 }
8779 return store.dispatch(action);
8780 }
8781 finally {
8782 notifying = true;
8783 }
8784 }
8785 });
8786 }; };
8787 };
8788 // src/index.ts
8789 (0,immer__WEBPACK_IMPORTED_MODULE_0__.enableES5)();
8790
8791 //# sourceMappingURL=redux-toolkit.esm.js.map
8792
8793 /***/ }),
8794
8795 /***/ "../node_modules/immer/dist/immer.esm.mjs":
8796 /*!************************************************!*\
8797 !*** ../node_modules/immer/dist/immer.esm.mjs ***!
8798 \************************************************/
8799 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
8800
8801 "use strict";
8802 __webpack_require__.r(__webpack_exports__);
8803 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8804 /* harmony export */ Immer: () => (/* binding */ un),
8805 /* harmony export */ applyPatches: () => (/* binding */ pn),
8806 /* harmony export */ castDraft: () => (/* binding */ K),
8807 /* harmony export */ castImmutable: () => (/* binding */ $),
8808 /* harmony export */ createDraft: () => (/* binding */ ln),
8809 /* harmony export */ current: () => (/* binding */ R),
8810 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
8811 /* harmony export */ enableAllPlugins: () => (/* binding */ J),
8812 /* harmony export */ enableES5: () => (/* binding */ F),
8813 /* harmony export */ enableMapSet: () => (/* binding */ C),
8814 /* harmony export */ enablePatches: () => (/* binding */ T),
8815 /* harmony export */ finishDraft: () => (/* binding */ dn),
8816 /* harmony export */ freeze: () => (/* binding */ d),
8817 /* harmony export */ immerable: () => (/* binding */ L),
8818 /* harmony export */ isDraft: () => (/* binding */ r),
8819 /* harmony export */ isDraftable: () => (/* binding */ t),
8820 /* harmony export */ nothing: () => (/* binding */ H),
8821 /* harmony export */ original: () => (/* binding */ e),
8822 /* harmony export */ produce: () => (/* binding */ fn),
8823 /* harmony export */ produceWithPatches: () => (/* binding */ cn),
8824 /* harmony export */ setAutoFreeze: () => (/* binding */ sn),
8825 /* harmony export */ setUseProxies: () => (/* binding */ vn)
8826 /* harmony export */ });
8827 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
8828 }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);
8829 //# sourceMappingURL=immer.esm.js.map
8830
8831
8832 /***/ }),
8833
8834 /***/ "../node_modules/mixpanel-browser/dist/mixpanel.module.js":
8835 /*!****************************************************************!*\
8836 !*** ../node_modules/mixpanel-browser/dist/mixpanel.module.js ***!
8837 \****************************************************************/
8838 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8839
8840 "use strict";
8841 __webpack_require__.r(__webpack_exports__);
8842 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8843 /* harmony export */ "default": () => (/* binding */ mixpanel)
8844 /* harmony export */ });
8845 // since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
8846 var win;
8847 if (typeof(window) === 'undefined') {
8848 var loc = {
8849 hostname: ''
8850 };
8851 win = {
8852 crypto: {randomUUID: function() {throw Error('unsupported');}},
8853 navigator: { userAgent: '', onLine: true },
8854 document: {
8855 createElement: function() { return {}; },
8856 location: loc,
8857 referrer: ''
8858 },
8859 screen: { width: 0, height: 0 },
8860 location: loc,
8861 addEventListener: function() {},
8862 removeEventListener: function() {}
8863 };
8864 } else {
8865 win = window;
8866 }
8867
8868 function _array_like_to_array(arr, len) {
8869 if (len == null || len > arr.length) len = arr.length;
8870 for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
8871 return arr2;
8872 }
8873 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
8874 try {
8875 var info = gen[key](arg);
8876 var value = info.value;
8877 } catch (error) {
8878 reject(error);
8879 return;
8880 }
8881 if (info.done) {
8882 resolve(value);
8883 } else {
8884 Promise.resolve(value).then(_next, _throw);
8885 }
8886 }
8887 function _async_to_generator(fn) {
8888 return function() {
8889 var self = this, args = arguments;
8890 return new Promise(function(resolve, reject) {
8891 var gen = fn.apply(self, args);
8892 function _next(value) {
8893 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
8894 }
8895 function _throw(err) {
8896 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
8897 }
8898 _next(undefined);
8899 });
8900 };
8901 }
8902 function _construct(Parent, args, Class) {
8903 if (_is_native_reflect_construct()) {
8904 _construct = Reflect.construct;
8905 } else {
8906 _construct = function construct(Parent, args, Class) {
8907 var a = [
8908 null
8909 ];
8910 a.push.apply(a, args);
8911 var Constructor = Function.bind.apply(Parent, a);
8912 var instance = new Constructor();
8913 if (Class) _set_prototype_of(instance, Class.prototype);
8914 return instance;
8915 };
8916 }
8917 return _construct.apply(null, arguments);
8918 }
8919 function _defineProperties(target, props) {
8920 for(var i = 0; i < props.length; i++){
8921 var descriptor = props[i];
8922 descriptor.enumerable = descriptor.enumerable || false;
8923 descriptor.configurable = true;
8924 if ("value" in descriptor) descriptor.writable = true;
8925 Object.defineProperty(target, descriptor.key, descriptor);
8926 }
8927 }
8928 function _create_class(Constructor, protoProps, staticProps) {
8929 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
8930 return Constructor;
8931 }
8932 function _extends() {
8933 _extends = Object.assign || function(target) {
8934 for(var i = 1; i < arguments.length; i++){
8935 var source = arguments[i];
8936 for(var key in source){
8937 if (Object.prototype.hasOwnProperty.call(source, key)) {
8938 target[key] = source[key];
8939 }
8940 }
8941 }
8942 return target;
8943 };
8944 return _extends.apply(this, arguments);
8945 }
8946 function _get_prototype_of(o) {
8947 _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
8948 return o.__proto__ || Object.getPrototypeOf(o);
8949 };
8950 return _get_prototype_of(o);
8951 }
8952 function _inherits(subClass, superClass) {
8953 if (typeof superClass !== "function" && superClass !== null) {
8954 throw new TypeError("Super expression must either be null or a function");
8955 }
8956 subClass.prototype = Object.create(superClass && superClass.prototype, {
8957 constructor: {
8958 value: subClass,
8959 writable: true,
8960 configurable: true
8961 }
8962 });
8963 if (superClass) _set_prototype_of(subClass, superClass);
8964 }
8965 function _instanceof(left, right) {
8966 if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
8967 return !!right[Symbol.hasInstance](left);
8968 } else {
8969 return left instanceof right;
8970 }
8971 }
8972 function _is_native_function(fn) {
8973 return Function.toString.call(fn).indexOf("[native code]") !== -1;
8974 }
8975 function _object_without_properties_loose(source, excluded) {
8976 if (source == null) return {};
8977 var target = {};
8978 var sourceKeys = Object.keys(source);
8979 var key, i;
8980 for(i = 0; i < sourceKeys.length; i++){
8981 key = sourceKeys[i];
8982 if (excluded.indexOf(key) >= 0) continue;
8983 target[key] = source[key];
8984 }
8985 return target;
8986 }
8987 function _set_prototype_of(o, p) {
8988 _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
8989 o.__proto__ = p;
8990 return o;
8991 };
8992 return _set_prototype_of(o, p);
8993 }
8994 function _type_of(obj) {
8995 "@swc/helpers - typeof";
8996 return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
8997 }
8998 function _unsupported_iterable_to_array(o, minLen) {
8999 if (!o) return;
9000 if (typeof o === "string") return _array_like_to_array(o, minLen);
9001 var n = Object.prototype.toString.call(o).slice(8, -1);
9002 if (n === "Object" && o.constructor) n = o.constructor.name;
9003 if (n === "Map" || n === "Set") return Array.from(n);
9004 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
9005 }
9006 function _wrap_native_super(Class) {
9007 var _cache = typeof Map === "function" ? new Map() : undefined;
9008 _wrap_native_super = function wrapNativeSuper(Class) {
9009 if (Class === null || !_is_native_function(Class)) return Class;
9010 if (typeof Class !== "function") {
9011 throw new TypeError("Super expression must either be null or a function");
9012 }
9013 if (typeof _cache !== "undefined") {
9014 if (_cache.has(Class)) return _cache.get(Class);
9015 _cache.set(Class, Wrapper);
9016 }
9017 function Wrapper() {
9018 return _construct(Class, arguments, _get_prototype_of(this).constructor);
9019 }
9020 Wrapper.prototype = Object.create(Class.prototype, {
9021 constructor: {
9022 value: Wrapper,
9023 enumerable: false,
9024 writable: true,
9025 configurable: true
9026 }
9027 });
9028 return _set_prototype_of(Wrapper, Class);
9029 };
9030 return _wrap_native_super(Class);
9031 }
9032 function _is_native_reflect_construct() {
9033 try {
9034 var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
9035 } catch (_) {}
9036 return (_is_native_reflect_construct = function() {
9037 return !!result;
9038 })();
9039 }
9040 function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
9041 var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
9042 if (it) return (it = it.call(o)).next.bind(it);
9043 if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike) {
9044 if (it) o = it;
9045 var i = 0;
9046 return function() {
9047 if (i >= o.length) {
9048 return {
9049 done: true
9050 };
9051 }
9052 return {
9053 done: false,
9054 value: o[i++]
9055 };
9056 };
9057 }
9058 throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
9059 }
9060 function _ts_generator(thisArg, body) {
9061 var f, y, t, g, _ = {
9062 label: 0,
9063 sent: function() {
9064 if (t[0] & 1) throw t[1];
9065 return t[1];
9066 },
9067 trys: [],
9068 ops: []
9069 };
9070 return g = {
9071 next: verb(0),
9072 "throw": verb(1),
9073 "return": verb(2)
9074 }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
9075 return this;
9076 }), g;
9077 function verb(n) {
9078 return function(v) {
9079 return step([
9080 n,
9081 v
9082 ]);
9083 };
9084 }
9085 function step(op) {
9086 if (f) throw new TypeError("Generator is already executing.");
9087 while(_)try {
9088 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;
9089 if (y = 0, t) op = [
9090 op[0] & 2,
9091 t.value
9092 ];
9093 switch(op[0]){
9094 case 0:
9095 case 1:
9096 t = op;
9097 break;
9098 case 4:
9099 _.label++;
9100 return {
9101 value: op[1],
9102 done: false
9103 };
9104 case 5:
9105 _.label++;
9106 y = op[1];
9107 op = [
9108 0
9109 ];
9110 continue;
9111 case 7:
9112 op = _.ops.pop();
9113 _.trys.pop();
9114 continue;
9115 default:
9116 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
9117 _ = 0;
9118 continue;
9119 }
9120 if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
9121 _.label = op[1];
9122 break;
9123 }
9124 if (op[0] === 6 && _.label < t[1]) {
9125 _.label = t[1];
9126 t = op;
9127 break;
9128 }
9129 if (t && _.label < t[2]) {
9130 _.label = t[2];
9131 _.ops.push(op);
9132 break;
9133 }
9134 if (t[2]) _.ops.pop();
9135 _.trys.pop();
9136 continue;
9137 }
9138 op = body.call(thisArg, _);
9139 } catch (e) {
9140 op = [
9141 6,
9142 e
9143 ];
9144 y = 0;
9145 } finally{
9146 f = t = 0;
9147 }
9148 if (op[0] & 5) throw op[1];
9149 return {
9150 value: op[0] ? op[1] : void 0,
9151 done: true
9152 };
9153 }
9154 }
9155 function _ts_values(o) {
9156 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
9157 if (m) return m.call(o);
9158 if (o && typeof o.length === "number") return {
9159 next: function() {
9160 if (o && i >= o.length) o = void 0;
9161 return {
9162 value: o && o[i++],
9163 done: !o
9164 };
9165 }
9166 };
9167 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
9168 }
9169 var __defProp = Object.defineProperty;
9170 var __defNormalProp = function(obj, key, value) {
9171 return key in obj ? __defProp(obj, key, {
9172 enumerable: true,
9173 configurable: true,
9174 writable: true,
9175 value: value
9176 }) : obj[key] = value;
9177 };
9178 var __publicField = function(obj, key, value) {
9179 return __defNormalProp(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
9180 };
9181 var _a;
9182 var __defProp$1 = Object.defineProperty;
9183 var __defNormalProp$1 = function(obj, key, value) {
9184 return key in obj ? __defProp$1(obj, key, {
9185 enumerable: true,
9186 configurable: true,
9187 writable: true,
9188 value: value
9189 }) : obj[key] = value;
9190 };
9191 var __publicField$1 = function(obj, key, value) {
9192 return __defNormalProp$1(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
9193 };
9194 var NodeType$3 = /* @__PURE__ */ function(NodeType2) {
9195 NodeType2[NodeType2["Document"] = 0] = "Document";
9196 NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
9197 NodeType2[NodeType2["Element"] = 2] = "Element";
9198 NodeType2[NodeType2["Text"] = 3] = "Text";
9199 NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
9200 NodeType2[NodeType2["Comment"] = 5] = "Comment";
9201 return NodeType2;
9202 }(NodeType$3 || {});
9203 var testableAccessors$1 = {
9204 Node: [
9205 "childNodes",
9206 "parentNode",
9207 "parentElement",
9208 "textContent"
9209 ],
9210 ShadowRoot: [
9211 "host",
9212 "styleSheets"
9213 ],
9214 Element: [
9215 "shadowRoot",
9216 "querySelector",
9217 "querySelectorAll"
9218 ],
9219 MutationObserver: []
9220 };
9221 var testableMethods$1 = {
9222 Node: [
9223 "contains",
9224 "getRootNode"
9225 ],
9226 ShadowRoot: [
9227 "getSelection"
9228 ],
9229 Element: [],
9230 MutationObserver: [
9231 "constructor"
9232 ]
9233 };
9234 var untaintedBasePrototype$1 = {};
9235 var isAngularZonePresent$1 = function() {
9236 return !!globalThis.Zone;
9237 };
9238 function getUntaintedPrototype$1(key) {
9239 if (untaintedBasePrototype$1[key]) return untaintedBasePrototype$1[key];
9240 var defaultObj = globalThis[key];
9241 var defaultPrototype = defaultObj.prototype;
9242 var accessorNames = key in testableAccessors$1 ? testableAccessors$1[key] : void 0;
9243 var isUntaintedAccessors = Boolean(accessorNames && // @ts-expect-error 2345
9244 accessorNames.every(function(accessor) {
9245 var _a2, _b;
9246 return Boolean((_b = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b.toString().includes("[native code]"));
9247 }));
9248 var methodNames = key in testableMethods$1 ? testableMethods$1[key] : void 0;
9249 var isUntaintedMethods = Boolean(methodNames && methodNames.every(// @ts-expect-error 2345
9250 function(method) {
9251 var _a2;
9252 return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
9253 }));
9254 if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent$1()) {
9255 untaintedBasePrototype$1[key] = defaultObj.prototype;
9256 return defaultObj.prototype;
9257 }
9258 try {
9259 var iframeEl = document.createElement("iframe");
9260 document.body.appendChild(iframeEl);
9261 var win = iframeEl.contentWindow;
9262 if (!win) return defaultObj.prototype;
9263 var untaintedObject = win[key].prototype;
9264 document.body.removeChild(iframeEl);
9265 if (!untaintedObject) return defaultPrototype;
9266 return untaintedBasePrototype$1[key] = untaintedObject;
9267 } catch (e) {
9268 return defaultPrototype;
9269 }
9270 }
9271 var untaintedAccessorCache$1 = {};
9272 function getUntaintedAccessor$1(key, instance, accessor) {
9273 var _a2;
9274 var cacheKey = key + "." + String(accessor);
9275 if (untaintedAccessorCache$1[cacheKey]) return untaintedAccessorCache$1[cacheKey].call(instance);
9276 var untaintedPrototype = getUntaintedPrototype$1(key);
9277 var untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(untaintedPrototype, accessor)) == null ? void 0 : _a2.get;
9278 if (!untaintedAccessor) return instance[accessor];
9279 untaintedAccessorCache$1[cacheKey] = untaintedAccessor;
9280 return untaintedAccessor.call(instance);
9281 }
9282 var untaintedMethodCache$1 = {};
9283 function getUntaintedMethod$1(key, instance, method) {
9284 var cacheKey = key + "." + String(method);
9285 if (untaintedMethodCache$1[cacheKey]) return untaintedMethodCache$1[cacheKey].bind(instance);
9286 var untaintedPrototype = getUntaintedPrototype$1(key);
9287 var untaintedMethod = untaintedPrototype[method];
9288 if (typeof untaintedMethod !== "function") return instance[method];
9289 untaintedMethodCache$1[cacheKey] = untaintedMethod;
9290 return untaintedMethod.bind(instance);
9291 }
9292 function childNodes$1(n2) {
9293 return getUntaintedAccessor$1("Node", n2, "childNodes");
9294 }
9295 function parentNode$1(n2) {
9296 return getUntaintedAccessor$1("Node", n2, "parentNode");
9297 }
9298 function parentElement$1(n2) {
9299 return getUntaintedAccessor$1("Node", n2, "parentElement");
9300 }
9301 function textContent$1(n2) {
9302 return getUntaintedAccessor$1("Node", n2, "textContent");
9303 }
9304 function contains$1(n2, other) {
9305 return getUntaintedMethod$1("Node", n2, "contains")(other);
9306 }
9307 function getRootNode$1(n2) {
9308 return getUntaintedMethod$1("Node", n2, "getRootNode")();
9309 }
9310 function host$1(n2) {
9311 if (!n2 || !("host" in n2)) return null;
9312 return getUntaintedAccessor$1("ShadowRoot", n2, "host");
9313 }
9314 function styleSheets$1(n2) {
9315 return n2.styleSheets;
9316 }
9317 function shadowRoot$1(n2) {
9318 if (!n2 || !("shadowRoot" in n2)) return null;
9319 return getUntaintedAccessor$1("Element", n2, "shadowRoot");
9320 }
9321 function querySelector$1(n2, selectors) {
9322 return getUntaintedAccessor$1("Element", n2, "querySelector")(selectors);
9323 }
9324 function querySelectorAll$1(n2, selectors) {
9325 return getUntaintedAccessor$1("Element", n2, "querySelectorAll")(selectors);
9326 }
9327 function mutationObserverCtor$1() {
9328 return getUntaintedPrototype$1("MutationObserver").constructor;
9329 }
9330 function patch$1(source, name, replacement) {
9331 try {
9332 if (!(name in source)) {
9333 return function() {};
9334 }
9335 var original = source[name];
9336 var wrapped = replacement(original);
9337 if (typeof wrapped === "function") {
9338 wrapped.prototype = wrapped.prototype || {};
9339 Object.defineProperties(wrapped, {
9340 __rrweb_original__: {
9341 enumerable: false,
9342 value: original
9343 }
9344 });
9345 }
9346 source[name] = wrapped;
9347 return function() {
9348 source[name] = original;
9349 };
9350 } catch (e) {
9351 return function() {};
9352 }
9353 }
9354 var index$1 = {
9355 childNodes: childNodes$1,
9356 parentNode: parentNode$1,
9357 parentElement: parentElement$1,
9358 textContent: textContent$1,
9359 contains: contains$1,
9360 getRootNode: getRootNode$1,
9361 host: host$1,
9362 styleSheets: styleSheets$1,
9363 shadowRoot: shadowRoot$1,
9364 querySelector: querySelector$1,
9365 querySelectorAll: querySelectorAll$1,
9366 mutationObserver: mutationObserverCtor$1,
9367 patch: patch$1
9368 };
9369 function isElement(n2) {
9370 return n2.nodeType === n2.ELEMENT_NODE;
9371 }
9372 function isShadowRoot(n2) {
9373 var hostEl = // anchor and textarea elements also have a `host` property
9374 // but only shadow roots have a `mode` property
9375 n2 && "host" in n2 && "mode" in n2 && index$1.host(n2) || null;
9376 return Boolean(hostEl && "shadowRoot" in hostEl && index$1.shadowRoot(hostEl) === n2);
9377 }
9378 function isNativeShadowDom(shadowRoot2) {
9379 return Object.prototype.toString.call(shadowRoot2) === "[object ShadowRoot]";
9380 }
9381 function fixBrowserCompatibilityIssuesInCSS(cssText) {
9382 if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
9383 cssText = cssText.replace(/\sbackground-clip:\s*text;/g, " -webkit-background-clip: text; background-clip: text;");
9384 }
9385 return cssText;
9386 }
9387 function escapeImportStatement(rule2) {
9388 var cssText = rule2.cssText;
9389 if (cssText.split('"').length < 3) return cssText;
9390 var statement = [
9391 "@import",
9392 "url(" + JSON.stringify(rule2.href) + ")"
9393 ];
9394 if (rule2.layerName === "") {
9395 statement.push("layer");
9396 } else if (rule2.layerName) {
9397 statement.push("layer(" + rule2.layerName + ")");
9398 }
9399 if (rule2.supportsText) {
9400 statement.push("supports(" + rule2.supportsText + ")");
9401 }
9402 if (rule2.media.length) {
9403 statement.push(rule2.media.mediaText);
9404 }
9405 return statement.join(" ") + ";";
9406 }
9407 function stringifyStylesheet(s2) {
9408 try {
9409 var rules2 = s2.rules || s2.cssRules;
9410 if (!rules2) {
9411 return null;
9412 }
9413 var sheetHref = s2.href;
9414 if (!sheetHref && s2.ownerNode && s2.ownerNode.ownerDocument) {
9415 sheetHref = s2.ownerNode.ownerDocument.location.href;
9416 }
9417 var stringifiedRules = Array.from(rules2, function(rule2) {
9418 return stringifyRule(rule2, sheetHref);
9419 }).join("");
9420 return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
9421 } catch (error) {
9422 return null;
9423 }
9424 }
9425 function stringifyRule(rule2, sheetHref) {
9426 if (isCSSImportRule(rule2)) {
9427 var importStringified;
9428 try {
9429 importStringified = // we can access the imported stylesheet rules directly
9430 stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
9431 escapeImportStatement(rule2);
9432 } catch (error) {
9433 importStringified = rule2.cssText;
9434 }
9435 if (rule2.styleSheet.href) {
9436 return absolutifyURLs(importStringified, rule2.styleSheet.href);
9437 }
9438 return importStringified;
9439 } else {
9440 var ruleStringified = rule2.cssText;
9441 if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
9442 ruleStringified = fixSafariColons(ruleStringified);
9443 }
9444 if (sheetHref) {
9445 return absolutifyURLs(ruleStringified, sheetHref);
9446 }
9447 return ruleStringified;
9448 }
9449 }
9450 function fixSafariColons(cssStringified) {
9451 var regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
9452 return cssStringified.replace(regex, "$1\\$2");
9453 }
9454 function isCSSImportRule(rule2) {
9455 return "styleSheet" in rule2;
9456 }
9457 function isCSSStyleRule(rule2) {
9458 return "selectorText" in rule2;
9459 }
9460 var Mirror = /*#__PURE__*/ function() {
9461 function Mirror() {
9462 __publicField$1(this, "idNodeMap", /* @__PURE__ */ new Map());
9463 __publicField$1(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap());
9464 }
9465 var _proto = Mirror.prototype;
9466 _proto.getId = function getId(n2) {
9467 var _a2;
9468 if (!n2) return -1;
9469 var id = (_a2 = this.getMeta(n2)) == null ? void 0 : _a2.id;
9470 return id != null ? id : -1;
9471 };
9472 _proto.getNode = function getNode(id) {
9473 return this.idNodeMap.get(id) || null;
9474 };
9475 _proto.getIds = function getIds() {
9476 return Array.from(this.idNodeMap.keys());
9477 };
9478 _proto.getMeta = function getMeta(n2) {
9479 return this.nodeMetaMap.get(n2) || null;
9480 };
9481 // removes the node from idNodeMap
9482 // doesn't remove the node from nodeMetaMap
9483 _proto.removeNodeFromMap = function removeNodeFromMap(n2) {
9484 var _this = this;
9485 var id = this.getId(n2);
9486 this.idNodeMap.delete(id);
9487 if (n2.childNodes) {
9488 n2.childNodes.forEach(function(childNode) {
9489 return _this.removeNodeFromMap(childNode);
9490 });
9491 }
9492 };
9493 _proto.has = function has(id) {
9494 return this.idNodeMap.has(id);
9495 };
9496 _proto.hasNode = function hasNode(node2) {
9497 return this.nodeMetaMap.has(node2);
9498 };
9499 _proto.add = function add(n2, meta) {
9500 var id = meta.id;
9501 this.idNodeMap.set(id, n2);
9502 this.nodeMetaMap.set(n2, meta);
9503 };
9504 _proto.replace = function replace(id, n2) {
9505 var oldNode = this.getNode(id);
9506 if (oldNode) {
9507 var meta = this.nodeMetaMap.get(oldNode);
9508 if (meta) this.nodeMetaMap.set(n2, meta);
9509 }
9510 this.idNodeMap.set(id, n2);
9511 };
9512 _proto.reset = function reset() {
9513 this.idNodeMap = /* @__PURE__ */ new Map();
9514 this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
9515 };
9516 return Mirror;
9517 }();
9518 function createMirror$2() {
9519 return new Mirror();
9520 }
9521 function maskInputValue(param) {
9522 var element = param.element, maskInputOptions = param.maskInputOptions, tagName = param.tagName, type = param.type, value = param.value, maskInputFn = param.maskInputFn;
9523 var text = value || "";
9524 var actualType = type && toLowerCase(type);
9525 if (maskInputOptions[tagName.toLowerCase()] || actualType && maskInputOptions[actualType]) {
9526 if (maskInputFn) {
9527 text = maskInputFn(text, element);
9528 } else {
9529 text = "*".repeat(text.length);
9530 }
9531 }
9532 return text;
9533 }
9534 function toLowerCase(str) {
9535 return str.toLowerCase();
9536 }
9537 var ORIGINAL_ATTRIBUTE_NAME = "__rrweb_original__";
9538 function is2DCanvasBlank(canvas) {
9539 var ctx = canvas.getContext("2d");
9540 if (!ctx) return true;
9541 var chunkSize = 50;
9542 for(var x2 = 0; x2 < canvas.width; x2 += chunkSize){
9543 for(var y = 0; y < canvas.height; y += chunkSize){
9544 var getImageData = ctx.getImageData;
9545 var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData ? getImageData[ORIGINAL_ATTRIBUTE_NAME] : getImageData;
9546 var pixelBuffer = new Uint32Array(// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
9547 originalGetImageData.call(ctx, x2, y, Math.min(chunkSize, canvas.width - x2), Math.min(chunkSize, canvas.height - y)).data.buffer);
9548 if (pixelBuffer.some(function(pixel) {
9549 return pixel !== 0;
9550 })) return false;
9551 }
9552 }
9553 return true;
9554 }
9555 function getInputType(element) {
9556 var type = element.type;
9557 return element.hasAttribute("data-rr-is-password") ? "password" : type ? // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
9558 toLowerCase(type) : null;
9559 }
9560 function extractFileExtension(path, baseURL) {
9561 var url;
9562 try {
9563 url = new URL(path, baseURL != null ? baseURL : window.location.href);
9564 } catch (err) {
9565 return null;
9566 }
9567 var regex = /\.([0-9a-z]+)(?:$)/i;
9568 var match = url.pathname.match(regex);
9569 var _ref;
9570 return (_ref = match == null ? void 0 : match[1]) != null ? _ref : null;
9571 }
9572 function extractOrigin(url) {
9573 var origin = "";
9574 if (url.indexOf("//") > -1) {
9575 origin = url.split("/").slice(0, 3).join("/");
9576 } else {
9577 origin = url.split("/")[0];
9578 }
9579 origin = origin.split("?")[0];
9580 return origin;
9581 }
9582 var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
9583 var URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
9584 var URL_WWW_MATCH = /^www\..*/i;
9585 var DATA_URI = /^(data:)([^,]*),(.*)/i;
9586 function absolutifyURLs(cssText, href) {
9587 return (cssText || "").replace(URL_IN_CSS_REF, function(origin, quote1, path1, quote2, path2, path3) {
9588 var filePath = path1 || path2 || path3;
9589 var maybeQuote = quote1 || quote2 || "";
9590 if (!filePath) {
9591 return origin;
9592 }
9593 if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {
9594 return "url(" + maybeQuote + filePath + maybeQuote + ")";
9595 }
9596 if (DATA_URI.test(filePath)) {
9597 return "url(" + maybeQuote + filePath + maybeQuote + ")";
9598 }
9599 if (filePath[0] === "/") {
9600 return "url(" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + ")";
9601 }
9602 var stack = href.split("/");
9603 var parts = filePath.split("/");
9604 stack.pop();
9605 for(var _iterator = _create_for_of_iterator_helper_loose(parts), _step; !(_step = _iterator()).done;){
9606 var part = _step.value;
9607 if (part === ".") {
9608 continue;
9609 } else if (part === "..") {
9610 stack.pop();
9611 } else {
9612 stack.push(part);
9613 }
9614 }
9615 return "url(" + maybeQuote + stack.join("/") + maybeQuote + ")";
9616 });
9617 }
9618 function normalizeCssString(cssText, _testNoPxNorm) {
9619 if (_testNoPxNorm === void 0) _testNoPxNorm = false;
9620 if (_testNoPxNorm) {
9621 return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "");
9622 } else {
9623 return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "").replace(/0px/g, "0");
9624 }
9625 }
9626 function splitCssText(cssText, style, _testNoPxNorm) {
9627 if (_testNoPxNorm === void 0) _testNoPxNorm = false;
9628 var childNodes2 = Array.from(style.childNodes);
9629 var splits = [];
9630 var iterCount = 0;
9631 if (childNodes2.length > 1 && cssText && typeof cssText === "string") {
9632 var cssTextNorm = normalizeCssString(cssText, _testNoPxNorm);
9633 var normFactor = cssTextNorm.length / cssText.length;
9634 for(var i2 = 1; i2 < childNodes2.length; i2++){
9635 if (childNodes2[i2].textContent && typeof childNodes2[i2].textContent === "string") {
9636 var textContentNorm = normalizeCssString(childNodes2[i2].textContent, _testNoPxNorm);
9637 var jLimit = 100;
9638 var j = 3;
9639 for(; j < textContentNorm.length; j++){
9640 if (// keep consuming css identifiers (to get a decent chunk more quickly)
9641 textContentNorm[j].match(/[a-zA-Z0-9]/) || // substring needs to be unique to this section
9642 textContentNorm.indexOf(textContentNorm.substring(0, j), 1) !== -1) {
9643 continue;
9644 }
9645 break;
9646 }
9647 for(; j < textContentNorm.length; j++){
9648 var startSubstring = textContentNorm.substring(0, j);
9649 var cssNormSplits = cssTextNorm.split(startSubstring);
9650 var splitNorm = -1;
9651 if (cssNormSplits.length === 2) {
9652 splitNorm = cssNormSplits[0].length;
9653 } else if (cssNormSplits.length > 2 && cssNormSplits[0] === "" && childNodes2[i2 - 1].textContent !== "") {
9654 splitNorm = cssTextNorm.indexOf(startSubstring, 1);
9655 } else if (cssNormSplits.length === 1) {
9656 startSubstring = startSubstring.substring(0, startSubstring.length - 1);
9657 cssNormSplits = cssTextNorm.split(startSubstring);
9658 if (cssNormSplits.length <= 1) {
9659 splits.push(cssText);
9660 return splits;
9661 }
9662 j = jLimit + 1;
9663 } else if (j === textContentNorm.length - 1) {
9664 splitNorm = cssTextNorm.indexOf(startSubstring);
9665 }
9666 if (cssNormSplits.length >= 2 && j > jLimit) {
9667 var prevTextContent = childNodes2[i2 - 1].textContent;
9668 if (prevTextContent && typeof prevTextContent === "string") {
9669 var prevMinLength = normalizeCssString(prevTextContent).length;
9670 splitNorm = cssTextNorm.indexOf(startSubstring, prevMinLength);
9671 }
9672 if (splitNorm === -1) {
9673 splitNorm = cssNormSplits[0].length;
9674 }
9675 }
9676 if (splitNorm !== -1) {
9677 var k = Math.floor(splitNorm / normFactor);
9678 for(; k > 0 && k < cssText.length;){
9679 iterCount += 1;
9680 if (iterCount > 50 * childNodes2.length) {
9681 splits.push(cssText);
9682 return splits;
9683 }
9684 var normPart = normalizeCssString(cssText.substring(0, k), _testNoPxNorm);
9685 if (normPart.length === splitNorm) {
9686 splits.push(cssText.substring(0, k));
9687 cssText = cssText.substring(k);
9688 cssTextNorm = cssTextNorm.substring(splitNorm);
9689 break;
9690 } else if (normPart.length < splitNorm) {
9691 k += Math.max(1, Math.floor((splitNorm - normPart.length) / normFactor));
9692 } else {
9693 k -= Math.max(1, Math.floor((normPart.length - splitNorm) * normFactor));
9694 }
9695 }
9696 break;
9697 }
9698 }
9699 }
9700 }
9701 }
9702 splits.push(cssText);
9703 return splits;
9704 }
9705 function markCssSplits(cssText, style) {
9706 return splitCssText(cssText, style).join("/* rr_split */");
9707 }
9708 var _id = 1;
9709 var tagNameRegex = new RegExp("[^a-z0-9-_:]");
9710 var IGNORED_NODE = -2;
9711 function genId() {
9712 return _id++;
9713 }
9714 function getValidTagName$1(element) {
9715 if (_instanceof(element, HTMLFormElement)) {
9716 return "form";
9717 }
9718 var processedTagName = toLowerCase(element.tagName);
9719 if (tagNameRegex.test(processedTagName)) {
9720 return "div";
9721 }
9722 return processedTagName;
9723 }
9724 var canvasService;
9725 var canvasCtx;
9726 var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
9727 var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
9728 function getAbsoluteSrcsetString(doc, attributeValue) {
9729 if (attributeValue.trim() === "") {
9730 return attributeValue;
9731 }
9732 var pos = 0;
9733 function collectCharacters(regEx) {
9734 var chars2;
9735 var match = regEx.exec(attributeValue.substring(pos));
9736 if (match) {
9737 chars2 = match[0];
9738 pos += chars2.length;
9739 return chars2;
9740 }
9741 return "";
9742 }
9743 var output = [];
9744 while(true){
9745 collectCharacters(SRCSET_COMMAS_OR_SPACES);
9746 if (pos >= attributeValue.length) {
9747 break;
9748 }
9749 var url = collectCharacters(SRCSET_NOT_SPACES);
9750 if (url.slice(-1) === ",") {
9751 url = absoluteToDoc(doc, url.substring(0, url.length - 1));
9752 output.push(url);
9753 } else {
9754 var descriptorsStr = "";
9755 url = absoluteToDoc(doc, url);
9756 var inParens = false;
9757 while(true){
9758 var c2 = attributeValue.charAt(pos);
9759 if (c2 === "") {
9760 output.push((url + descriptorsStr).trim());
9761 break;
9762 } else if (!inParens) {
9763 if (c2 === ",") {
9764 pos += 1;
9765 output.push((url + descriptorsStr).trim());
9766 break;
9767 } else if (c2 === "(") {
9768 inParens = true;
9769 }
9770 } else {
9771 if (c2 === ")") {
9772 inParens = false;
9773 }
9774 }
9775 descriptorsStr += c2;
9776 pos += 1;
9777 }
9778 }
9779 }
9780 return output.join(", ");
9781 }
9782 var cachedDocument = /* @__PURE__ */ new WeakMap();
9783 function absoluteToDoc(doc, attributeValue) {
9784 if (!attributeValue || attributeValue.trim() === "") {
9785 return attributeValue;
9786 }
9787 return getHref(doc, attributeValue);
9788 }
9789 function isSVGElement(el) {
9790 return Boolean(el.tagName === "svg" || el.ownerSVGElement);
9791 }
9792 function getHref(doc, customHref) {
9793 var a2 = cachedDocument.get(doc);
9794 if (!a2) {
9795 a2 = doc.createElement("a");
9796 cachedDocument.set(doc, a2);
9797 }
9798 if (!customHref) {
9799 customHref = "";
9800 } else if (customHref.startsWith("blob:") || customHref.startsWith("data:")) {
9801 return customHref;
9802 }
9803 a2.setAttribute("href", customHref);
9804 return a2.href;
9805 }
9806 function transformAttribute(doc, tagName, name, value) {
9807 if (!value) {
9808 return value;
9809 }
9810 if (name === "src" || name === "href" && !(tagName === "use" && value[0] === "#")) {
9811 return absoluteToDoc(doc, value);
9812 } else if (name === "xlink:href" && value[0] !== "#") {
9813 return absoluteToDoc(doc, value);
9814 } else if (name === "background" && (tagName === "table" || tagName === "td" || tagName === "th")) {
9815 return absoluteToDoc(doc, value);
9816 } else if (name === "srcset") {
9817 return getAbsoluteSrcsetString(doc, value);
9818 } else if (name === "style") {
9819 return absolutifyURLs(value, getHref(doc));
9820 } else if (tagName === "object" && name === "data") {
9821 return absoluteToDoc(doc, value);
9822 }
9823 return value;
9824 }
9825 function ignoreAttribute(tagName, name, _value) {
9826 return (tagName === "video" || tagName === "audio") && name === "autoplay";
9827 }
9828 function _isBlockedElement(element, blockClass, blockSelector) {
9829 try {
9830 if (typeof blockClass === "string") {
9831 if (element.classList.contains(blockClass)) {
9832 return true;
9833 }
9834 } else {
9835 for(var eIndex = element.classList.length; eIndex--;){
9836 var className = element.classList[eIndex];
9837 if (blockClass.test(className)) {
9838 return true;
9839 }
9840 }
9841 }
9842 if (blockSelector) {
9843 return element.matches(blockSelector);
9844 }
9845 } catch (e2) {}
9846 return false;
9847 }
9848 function classMatchesRegex(node2, regex, checkAncestors) {
9849 if (!node2) return false;
9850 if (node2.nodeType !== node2.ELEMENT_NODE) {
9851 if (!checkAncestors) return false;
9852 return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
9853 }
9854 for(var eIndex = node2.classList.length; eIndex--;){
9855 var className = node2.classList[eIndex];
9856 if (regex.test(className)) {
9857 return true;
9858 }
9859 }
9860 if (!checkAncestors) return false;
9861 return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
9862 }
9863 function needMaskingText(node2, maskTextClass, maskTextSelector, checkAncestors) {
9864 var el;
9865 if (isElement(node2)) {
9866 el = node2;
9867 if (!index$1.childNodes(el).length) {
9868 return false;
9869 }
9870 } else if (index$1.parentElement(node2) === null) {
9871 return false;
9872 } else {
9873 el = index$1.parentElement(node2);
9874 }
9875 try {
9876 if (typeof maskTextClass === "string") {
9877 if (checkAncestors) {
9878 if (el.closest("." + maskTextClass)) return true;
9879 } else {
9880 if (el.classList.contains(maskTextClass)) return true;
9881 }
9882 } else {
9883 if (classMatchesRegex(el, maskTextClass, checkAncestors)) return true;
9884 }
9885 if (maskTextSelector) {
9886 if (checkAncestors) {
9887 if (el.closest(maskTextSelector)) return true;
9888 } else {
9889 if (el.matches(maskTextSelector)) return true;
9890 }
9891 }
9892 } catch (e2) {}
9893 return false;
9894 }
9895 function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
9896 var win = iframeEl.contentWindow;
9897 if (!win) {
9898 return;
9899 }
9900 var fired = false;
9901 var readyState;
9902 try {
9903 readyState = win.document.readyState;
9904 } catch (error) {
9905 return;
9906 }
9907 if (readyState !== "complete") {
9908 var timer = setTimeout(function() {
9909 if (!fired) {
9910 listener();
9911 fired = true;
9912 }
9913 }, iframeLoadTimeout);
9914 iframeEl.addEventListener("load", function() {
9915 clearTimeout(timer);
9916 fired = true;
9917 listener();
9918 });
9919 return;
9920 }
9921 var blankUrl = "about:blank";
9922 if (win.location.href !== blankUrl || iframeEl.src === blankUrl || iframeEl.src === "") {
9923 setTimeout(listener, 0);
9924 return iframeEl.addEventListener("load", listener);
9925 }
9926 iframeEl.addEventListener("load", listener);
9927 }
9928 function onceStylesheetLoaded(link, listener, styleSheetLoadTimeout) {
9929 var fired = false;
9930 var styleSheetLoaded;
9931 try {
9932 styleSheetLoaded = link.sheet;
9933 } catch (error) {
9934 return;
9935 }
9936 if (styleSheetLoaded) return;
9937 var timer = setTimeout(function() {
9938 if (!fired) {
9939 listener();
9940 fired = true;
9941 }
9942 }, styleSheetLoadTimeout);
9943 link.addEventListener("load", function() {
9944 clearTimeout(timer);
9945 fired = true;
9946 listener();
9947 });
9948 }
9949 function serializeNode(n2, options) {
9950 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;
9951 var rootId = getRootId(doc, mirror2);
9952 switch(n2.nodeType){
9953 case n2.DOCUMENT_NODE:
9954 if (n2.compatMode !== "CSS1Compat") {
9955 return {
9956 type: NodeType$3.Document,
9957 childNodes: [],
9958 compatMode: n2.compatMode
9959 };
9960 } else {
9961 return {
9962 type: NodeType$3.Document,
9963 childNodes: []
9964 };
9965 }
9966 case n2.DOCUMENT_TYPE_NODE:
9967 return {
9968 type: NodeType$3.DocumentType,
9969 name: n2.name,
9970 publicId: n2.publicId,
9971 systemId: n2.systemId,
9972 rootId: rootId
9973 };
9974 case n2.ELEMENT_NODE:
9975 return serializeElementNode(n2, {
9976 doc: doc,
9977 blockClass: blockClass,
9978 blockSelector: blockSelector,
9979 inlineStylesheet: inlineStylesheet,
9980 maskInputOptions: maskInputOptions,
9981 maskInputFn: maskInputFn,
9982 dataURLOptions: dataURLOptions,
9983 inlineImages: inlineImages,
9984 recordCanvas: recordCanvas,
9985 keepIframeSrcFn: keepIframeSrcFn,
9986 newlyAddedElement: newlyAddedElement,
9987 rootId: rootId
9988 });
9989 case n2.TEXT_NODE:
9990 return serializeTextNode(n2, {
9991 doc: doc,
9992 needsMask: needsMask,
9993 maskTextFn: maskTextFn,
9994 rootId: rootId,
9995 cssCaptured: cssCaptured
9996 });
9997 case n2.CDATA_SECTION_NODE:
9998 return {
9999 type: NodeType$3.CDATA,
10000 textContent: "",
10001 rootId: rootId
10002 };
10003 case n2.COMMENT_NODE:
10004 return {
10005 type: NodeType$3.Comment,
10006 textContent: index$1.textContent(n2) || "",
10007 rootId: rootId
10008 };
10009 default:
10010 return false;
10011 }
10012 }
10013 function getRootId(doc, mirror2) {
10014 if (!mirror2.hasNode(doc)) return void 0;
10015 var docId = mirror2.getId(doc);
10016 return docId === 1 ? void 0 : docId;
10017 }
10018 function serializeTextNode(n2, options) {
10019 var needsMask = options.needsMask, maskTextFn = options.maskTextFn, rootId = options.rootId, cssCaptured = options.cssCaptured;
10020 var parent = index$1.parentNode(n2);
10021 var parentTagName = parent && parent.tagName;
10022 var textContent2 = "";
10023 var isStyle = parentTagName === "STYLE" ? true : void 0;
10024 var isScript = parentTagName === "SCRIPT" ? true : void 0;
10025 if (isScript) {
10026 textContent2 = "SCRIPT_PLACEHOLDER";
10027 } else if (!cssCaptured) {
10028 textContent2 = index$1.textContent(n2);
10029 if (isStyle && textContent2) {
10030 textContent2 = absolutifyURLs(textContent2, getHref(options.doc));
10031 }
10032 }
10033 if (!isStyle && !isScript && textContent2 && needsMask) {
10034 textContent2 = maskTextFn ? maskTextFn(textContent2, index$1.parentElement(n2)) : textContent2.replace(/[\S]/g, "*");
10035 }
10036 return {
10037 type: NodeType$3.Text,
10038 textContent: textContent2 || "",
10039 rootId: rootId
10040 };
10041 }
10042 function serializeElementNode(n2, options) {
10043 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;
10044 var needBlock = _isBlockedElement(n2, blockClass, blockSelector);
10045 var tagName = getValidTagName$1(n2);
10046 var attributes = {};
10047 var len = n2.attributes.length;
10048 for(var i2 = 0; i2 < len; i2++){
10049 var attr = n2.attributes[i2];
10050 if (!ignoreAttribute(tagName, attr.name, attr.value)) {
10051 attributes[attr.name] = transformAttribute(doc, tagName, toLowerCase(attr.name), attr.value);
10052 }
10053 }
10054 if (tagName === "link" && inlineStylesheet) {
10055 var stylesheet = Array.from(doc.styleSheets).find(function(s2) {
10056 return s2.href === n2.href;
10057 });
10058 var cssText = null;
10059 if (stylesheet) {
10060 cssText = stringifyStylesheet(stylesheet);
10061 }
10062 if (cssText) {
10063 delete attributes.rel;
10064 delete attributes.href;
10065 attributes._cssText = cssText;
10066 }
10067 }
10068 if (tagName === "style" && n2.sheet) {
10069 var cssText1 = stringifyStylesheet(n2.sheet);
10070 if (cssText1) {
10071 if (n2.childNodes.length > 1) {
10072 cssText1 = markCssSplits(cssText1, n2);
10073 }
10074 attributes._cssText = cssText1;
10075 }
10076 }
10077 if (tagName === "input" || tagName === "textarea" || tagName === "select") {
10078 var value = n2.value;
10079 var checked = n2.checked;
10080 if (attributes.type !== "radio" && attributes.type !== "checkbox" && attributes.type !== "submit" && attributes.type !== "button" && value) {
10081 attributes.value = maskInputValue({
10082 element: n2,
10083 type: getInputType(n2),
10084 tagName: tagName,
10085 value: value,
10086 maskInputOptions: maskInputOptions,
10087 maskInputFn: maskInputFn
10088 });
10089 } else if (checked) {
10090 attributes.checked = checked;
10091 }
10092 }
10093 if (tagName === "option") {
10094 if (n2.selected && !maskInputOptions["select"]) {
10095 attributes.selected = true;
10096 } else {
10097 delete attributes.selected;
10098 }
10099 }
10100 if (tagName === "dialog" && n2.open) {
10101 attributes.rr_open_mode = n2.matches("dialog:modal") ? "modal" : "non-modal";
10102 }
10103 if (tagName === "canvas" && recordCanvas) {
10104 if (n2.__context === "2d") {
10105 if (!is2DCanvasBlank(n2)) {
10106 attributes.rr_dataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
10107 }
10108 } else if (!("__context" in n2)) {
10109 var canvasDataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
10110 var blankCanvas = doc.createElement("canvas");
10111 blankCanvas.width = n2.width;
10112 blankCanvas.height = n2.height;
10113 var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);
10114 if (canvasDataURL !== blankCanvasDataURL) {
10115 attributes.rr_dataURL = canvasDataURL;
10116 }
10117 }
10118 }
10119 if (tagName === "img" && inlineImages) {
10120 if (!canvasService) {
10121 canvasService = doc.createElement("canvas");
10122 canvasCtx = canvasService.getContext("2d");
10123 }
10124 var image = n2;
10125 var imageSrc = image.currentSrc || image.getAttribute("src") || "<unknown-src>";
10126 var priorCrossOrigin = image.crossOrigin;
10127 var recordInlineImage = function() {
10128 image.removeEventListener("load", recordInlineImage);
10129 try {
10130 canvasService.width = image.naturalWidth;
10131 canvasService.height = image.naturalHeight;
10132 canvasCtx.drawImage(image, 0, 0);
10133 attributes.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);
10134 } catch (err) {
10135 if (image.crossOrigin !== "anonymous") {
10136 image.crossOrigin = "anonymous";
10137 if (image.complete && image.naturalWidth !== 0) recordInlineImage();
10138 else image.addEventListener("load", recordInlineImage);
10139 return;
10140 } else {
10141 console.warn("Cannot inline img src=" + imageSrc + "! Error: " + err);
10142 }
10143 }
10144 if (image.crossOrigin === "anonymous") {
10145 priorCrossOrigin ? attributes.crossOrigin = priorCrossOrigin : image.removeAttribute("crossorigin");
10146 }
10147 };
10148 if (image.complete && image.naturalWidth !== 0) recordInlineImage();
10149 else image.addEventListener("load", recordInlineImage);
10150 }
10151 if (tagName === "audio" || tagName === "video") {
10152 var mediaAttributes = attributes;
10153 mediaAttributes.rr_mediaState = n2.paused ? "paused" : "played";
10154 mediaAttributes.rr_mediaCurrentTime = n2.currentTime;
10155 mediaAttributes.rr_mediaPlaybackRate = n2.playbackRate;
10156 mediaAttributes.rr_mediaMuted = n2.muted;
10157 mediaAttributes.rr_mediaLoop = n2.loop;
10158 mediaAttributes.rr_mediaVolume = n2.volume;
10159 }
10160 if (!newlyAddedElement) {
10161 if (n2.scrollLeft) {
10162 attributes.rr_scrollLeft = n2.scrollLeft;
10163 }
10164 if (n2.scrollTop) {
10165 attributes.rr_scrollTop = n2.scrollTop;
10166 }
10167 }
10168 if (needBlock) {
10169 var _n2_getBoundingClientRect = n2.getBoundingClientRect(), width = _n2_getBoundingClientRect.width, height = _n2_getBoundingClientRect.height;
10170 attributes = {
10171 class: attributes.class,
10172 rr_width: "" + width + "px",
10173 rr_height: "" + height + "px"
10174 };
10175 }
10176 if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
10177 if (!n2.contentDocument) {
10178 attributes.rr_src = attributes.src;
10179 }
10180 delete attributes.src;
10181 }
10182 var isCustomElement;
10183 try {
10184 if (customElements.get(tagName)) isCustomElement = true;
10185 } catch (e2) {}
10186 return {
10187 type: NodeType$3.Element,
10188 tagName: tagName,
10189 attributes: attributes,
10190 childNodes: [],
10191 isSVG: isSVGElement(n2) || void 0,
10192 needBlock: needBlock,
10193 rootId: rootId,
10194 isCustom: isCustomElement
10195 };
10196 }
10197 function lowerIfExists(maybeAttr) {
10198 if (maybeAttr === void 0 || maybeAttr === null) {
10199 return "";
10200 } else {
10201 return maybeAttr.toLowerCase();
10202 }
10203 }
10204 function slimDOMExcluded(sn, slimDOMOptions) {
10205 if (slimDOMOptions.comment && sn.type === NodeType$3.Comment) {
10206 return true;
10207 } else if (sn.type === NodeType$3.Element) {
10208 if (slimDOMOptions.script && // script tag
10209 (sn.tagName === "script" || // (module)preload link
10210 sn.tagName === "link" && (sn.attributes.rel === "preload" && sn.attributes.as === "script" || sn.attributes.rel === "modulepreload") || // prefetch link
10211 sn.tagName === "link" && sn.attributes.rel === "prefetch" && typeof sn.attributes.href === "string" && extractFileExtension(sn.attributes.href) === "js")) {
10212 return true;
10213 } 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"))) {
10214 return true;
10215 } else if (sn.tagName === "meta") {
10216 if (slimDOMOptions.headMetaDescKeywords && lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
10217 return true;
10218 } else if (slimDOMOptions.headMetaSocial && (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || // og = opengraph (facebook)
10219 lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || lowerIfExists(sn.attributes.name) === "pinterest")) {
10220 return true;
10221 } else if (slimDOMOptions.headMetaRobots && (lowerIfExists(sn.attributes.name) === "robots" || lowerIfExists(sn.attributes.name) === "googlebot" || lowerIfExists(sn.attributes.name) === "bingbot")) {
10222 return true;
10223 } else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== void 0) {
10224 return true;
10225 } 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:/))) {
10226 return true;
10227 } 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")) {
10228 return true;
10229 }
10230 }
10231 }
10232 return false;
10233 }
10234 function serializeNodeWithId(n2, options) {
10235 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() {
10236 return false;
10237 } : _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;
10238 var needsMask = options.needsMask;
10239 var _options_preserveWhiteSpace = options.preserveWhiteSpace, preserveWhiteSpace = _options_preserveWhiteSpace === void 0 ? true : _options_preserveWhiteSpace;
10240 if (!needsMask) {
10241 var checkAncestors = needsMask === void 0;
10242 needsMask = needMaskingText(n2, maskTextClass, maskTextSelector, checkAncestors);
10243 }
10244 var _serializedNode = serializeNode(n2, {
10245 doc: doc,
10246 mirror: mirror2,
10247 blockClass: blockClass,
10248 blockSelector: blockSelector,
10249 needsMask: needsMask,
10250 inlineStylesheet: inlineStylesheet,
10251 maskInputOptions: maskInputOptions,
10252 maskTextFn: maskTextFn,
10253 maskInputFn: maskInputFn,
10254 dataURLOptions: dataURLOptions,
10255 inlineImages: inlineImages,
10256 recordCanvas: recordCanvas,
10257 keepIframeSrcFn: keepIframeSrcFn,
10258 newlyAddedElement: newlyAddedElement,
10259 cssCaptured: cssCaptured
10260 });
10261 if (!_serializedNode) {
10262 console.warn(n2, "not serialized");
10263 return null;
10264 }
10265 var id;
10266 if (mirror2.hasNode(n2)) {
10267 id = mirror2.getId(n2);
10268 } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType$3.Text && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
10269 id = IGNORED_NODE;
10270 } else {
10271 id = genId();
10272 }
10273 var serializedNode = Object.assign(_serializedNode, {
10274 id: id
10275 });
10276 mirror2.add(n2, serializedNode);
10277 if (id === IGNORED_NODE) {
10278 return null;
10279 }
10280 if (onSerialize) {
10281 onSerialize(n2);
10282 }
10283 var recordChild = !skipChild;
10284 if (serializedNode.type === NodeType$3.Element) {
10285 recordChild = recordChild && !serializedNode.needBlock;
10286 delete serializedNode.needBlock;
10287 var shadowRootEl = index$1.shadowRoot(n2);
10288 if (shadowRootEl && isNativeShadowDom(shadowRootEl)) serializedNode.isShadowHost = true;
10289 }
10290 if ((serializedNode.type === NodeType$3.Document || serializedNode.type === NodeType$3.Element) && recordChild) {
10291 if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType$3.Element && serializedNode.tagName === "head") {
10292 preserveWhiteSpace = false;
10293 }
10294 var bypassOptions = {
10295 doc: doc,
10296 mirror: mirror2,
10297 blockClass: blockClass,
10298 blockSelector: blockSelector,
10299 needsMask: needsMask,
10300 maskTextClass: maskTextClass,
10301 maskTextSelector: maskTextSelector,
10302 skipChild: skipChild,
10303 inlineStylesheet: inlineStylesheet,
10304 maskInputOptions: maskInputOptions,
10305 maskTextFn: maskTextFn,
10306 maskInputFn: maskInputFn,
10307 slimDOMOptions: slimDOMOptions,
10308 dataURLOptions: dataURLOptions,
10309 inlineImages: inlineImages,
10310 recordCanvas: recordCanvas,
10311 preserveWhiteSpace: preserveWhiteSpace,
10312 onSerialize: onSerialize,
10313 onIframeLoad: onIframeLoad,
10314 iframeLoadTimeout: iframeLoadTimeout,
10315 onStylesheetLoad: onStylesheetLoad,
10316 stylesheetLoadTimeout: stylesheetLoadTimeout,
10317 keepIframeSrcFn: keepIframeSrcFn,
10318 cssCaptured: false
10319 };
10320 if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
10321 else {
10322 if (serializedNode.type === NodeType$3.Element && serializedNode.attributes._cssText !== void 0 && typeof serializedNode.attributes._cssText === "string") {
10323 bypassOptions.cssCaptured = true;
10324 }
10325 for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(index$1.childNodes(n2))), _step; !(_step = _iterator()).done;){
10326 var childN = _step.value;
10327 var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
10328 if (serializedChildNode) {
10329 serializedNode.childNodes.push(serializedChildNode);
10330 }
10331 }
10332 }
10333 var shadowRootEl1 = null;
10334 if (isElement(n2) && (shadowRootEl1 = index$1.shadowRoot(n2))) {
10335 for(var _iterator1 = _create_for_of_iterator_helper_loose(Array.from(index$1.childNodes(shadowRootEl1))), _step1; !(_step1 = _iterator1()).done;){
10336 var childN1 = _step1.value;
10337 var serializedChildNode1 = serializeNodeWithId(childN1, bypassOptions);
10338 if (serializedChildNode1) {
10339 isNativeShadowDom(shadowRootEl1) && (serializedChildNode1.isShadow = true);
10340 serializedNode.childNodes.push(serializedChildNode1);
10341 }
10342 }
10343 }
10344 }
10345 var parent = index$1.parentNode(n2);
10346 if (parent && isShadowRoot(parent) && isNativeShadowDom(parent)) {
10347 serializedNode.isShadow = true;
10348 }
10349 if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "iframe") {
10350 onceIframeLoaded(n2, function() {
10351 var iframeDoc = n2.contentDocument;
10352 if (iframeDoc && onIframeLoad) {
10353 var serializedIframeNode = serializeNodeWithId(iframeDoc, {
10354 doc: iframeDoc,
10355 mirror: mirror2,
10356 blockClass: blockClass,
10357 blockSelector: blockSelector,
10358 needsMask: needsMask,
10359 maskTextClass: maskTextClass,
10360 maskTextSelector: maskTextSelector,
10361 skipChild: false,
10362 inlineStylesheet: inlineStylesheet,
10363 maskInputOptions: maskInputOptions,
10364 maskTextFn: maskTextFn,
10365 maskInputFn: maskInputFn,
10366 slimDOMOptions: slimDOMOptions,
10367 dataURLOptions: dataURLOptions,
10368 inlineImages: inlineImages,
10369 recordCanvas: recordCanvas,
10370 preserveWhiteSpace: preserveWhiteSpace,
10371 onSerialize: onSerialize,
10372 onIframeLoad: onIframeLoad,
10373 iframeLoadTimeout: iframeLoadTimeout,
10374 onStylesheetLoad: onStylesheetLoad,
10375 stylesheetLoadTimeout: stylesheetLoadTimeout,
10376 keepIframeSrcFn: keepIframeSrcFn
10377 });
10378 if (serializedIframeNode) {
10379 onIframeLoad(n2, serializedIframeNode);
10380 }
10381 }
10382 }, iframeLoadTimeout);
10383 }
10384 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")) {
10385 onceStylesheetLoaded(n2, function() {
10386 if (onStylesheetLoad) {
10387 var serializedLinkNode = serializeNodeWithId(n2, {
10388 doc: doc,
10389 mirror: mirror2,
10390 blockClass: blockClass,
10391 blockSelector: blockSelector,
10392 needsMask: needsMask,
10393 maskTextClass: maskTextClass,
10394 maskTextSelector: maskTextSelector,
10395 skipChild: false,
10396 inlineStylesheet: inlineStylesheet,
10397 maskInputOptions: maskInputOptions,
10398 maskTextFn: maskTextFn,
10399 maskInputFn: maskInputFn,
10400 slimDOMOptions: slimDOMOptions,
10401 dataURLOptions: dataURLOptions,
10402 inlineImages: inlineImages,
10403 recordCanvas: recordCanvas,
10404 preserveWhiteSpace: preserveWhiteSpace,
10405 onSerialize: onSerialize,
10406 onIframeLoad: onIframeLoad,
10407 iframeLoadTimeout: iframeLoadTimeout,
10408 onStylesheetLoad: onStylesheetLoad,
10409 stylesheetLoadTimeout: stylesheetLoadTimeout,
10410 keepIframeSrcFn: keepIframeSrcFn
10411 });
10412 if (serializedLinkNode) {
10413 onStylesheetLoad(n2, serializedLinkNode);
10414 }
10415 }
10416 }, stylesheetLoadTimeout);
10417 }
10418 return serializedNode;
10419 }
10420 function snapshot(n2, options) {
10421 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() {
10422 return false;
10423 } : _ref_keepIframeSrcFn;
10424 var maskInputOptions = maskAllInputs === true ? {
10425 color: true,
10426 date: true,
10427 "datetime-local": true,
10428 email: true,
10429 month: true,
10430 number: true,
10431 range: true,
10432 search: true,
10433 tel: true,
10434 text: true,
10435 time: true,
10436 url: true,
10437 week: true,
10438 textarea: true,
10439 select: true,
10440 password: true,
10441 hidden: true
10442 } : maskAllInputs === false ? {
10443 password: true
10444 } : maskAllInputs;
10445 var slimDOMOptions = slimDOM === true || slimDOM === "all" ? // if true: set of sensible options that should not throw away any information
10446 {
10447 script: true,
10448 comment: true,
10449 headFavicon: true,
10450 headWhitespace: true,
10451 headMetaDescKeywords: slimDOM === "all",
10452 // destructive
10453 headMetaSocial: true,
10454 headMetaRobots: true,
10455 headMetaHttpEquiv: true,
10456 headMetaAuthorship: true,
10457 headMetaVerification: true
10458 } : slimDOM === false ? {} : slimDOM;
10459 return serializeNodeWithId(n2, {
10460 doc: n2,
10461 mirror: mirror2,
10462 blockClass: blockClass,
10463 blockSelector: blockSelector,
10464 maskTextClass: maskTextClass,
10465 maskTextSelector: maskTextSelector,
10466 skipChild: false,
10467 inlineStylesheet: inlineStylesheet,
10468 maskInputOptions: maskInputOptions,
10469 maskTextFn: maskTextFn,
10470 maskInputFn: maskInputFn,
10471 slimDOMOptions: slimDOMOptions,
10472 dataURLOptions: dataURLOptions,
10473 inlineImages: inlineImages,
10474 recordCanvas: recordCanvas,
10475 preserveWhiteSpace: preserveWhiteSpace,
10476 onSerialize: onSerialize,
10477 onIframeLoad: onIframeLoad,
10478 iframeLoadTimeout: iframeLoadTimeout,
10479 onStylesheetLoad: onStylesheetLoad,
10480 stylesheetLoadTimeout: stylesheetLoadTimeout,
10481 keepIframeSrcFn: keepIframeSrcFn,
10482 newlyAddedElement: false
10483 });
10484 }
10485 function getDefaultExportFromCjs$1(x2) {
10486 return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
10487 }
10488 function getAugmentedNamespace$1(n2) {
10489 if (n2.__esModule) return n2;
10490 var f2 = n2.default;
10491 if (typeof f2 == "function") {
10492 var a2 = function a22() {
10493 if (_instanceof(this, a22)) {
10494 return Reflect.construct(f2, arguments, this.constructor);
10495 }
10496 return f2.apply(this, arguments);
10497 };
10498 a2.prototype = f2.prototype;
10499 } else a2 = {};
10500 Object.defineProperty(a2, "__esModule", {
10501 value: true
10502 });
10503 Object.keys(n2).forEach(function(k) {
10504 var d = Object.getOwnPropertyDescriptor(n2, k);
10505 Object.defineProperty(a2, k, d.get ? d : {
10506 enumerable: true,
10507 get: function get() {
10508 return n2[k];
10509 }
10510 });
10511 });
10512 return a2;
10513 }
10514 var picocolors_browser$1 = {
10515 exports: {}
10516 };
10517 var x$1 = String;
10518 var create$1 = function create$1() {
10519 return {
10520 isColorSupported: false,
10521 reset: x$1,
10522 bold: x$1,
10523 dim: x$1,
10524 italic: x$1,
10525 underline: x$1,
10526 inverse: x$1,
10527 hidden: x$1,
10528 strikethrough: x$1,
10529 black: x$1,
10530 red: x$1,
10531 green: x$1,
10532 yellow: x$1,
10533 blue: x$1,
10534 magenta: x$1,
10535 cyan: x$1,
10536 white: x$1,
10537 gray: x$1,
10538 bgBlack: x$1,
10539 bgRed: x$1,
10540 bgGreen: x$1,
10541 bgYellow: x$1,
10542 bgBlue: x$1,
10543 bgMagenta: x$1,
10544 bgCyan: x$1,
10545 bgWhite: x$1
10546 };
10547 };
10548 picocolors_browser$1.exports = create$1();
10549 picocolors_browser$1.exports.createColors = create$1;
10550 var picocolors_browserExports$1 = picocolors_browser$1.exports;
10551 var __viteBrowserExternal$2 = {};
10552 var __viteBrowserExternal$1$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10553 __proto__: null,
10554 default: __viteBrowserExternal$2
10555 }, Symbol.toStringTag, {
10556 value: "Module"
10557 }));
10558 var require$$2$1 = /* @__PURE__ */ getAugmentedNamespace$1(__viteBrowserExternal$1$1);
10559 var pico$1 = picocolors_browserExports$1;
10560 var terminalHighlight$1$1 = require$$2$1;
10561 var CssSyntaxError$3$1 = /*#__PURE__*/ function(Error1) {
10562 _inherits(CssSyntaxError, Error1);
10563 function CssSyntaxError(message, line, column, source, file, plugin22) {
10564 var _this;
10565 _this = Error1.call(this, message) || this;
10566 _this.name = "CssSyntaxError";
10567 _this.reason = message;
10568 if (file) {
10569 _this.file = file;
10570 }
10571 if (source) {
10572 _this.source = source;
10573 }
10574 if (plugin22) {
10575 _this.plugin = plugin22;
10576 }
10577 if (typeof line !== "undefined" && typeof column !== "undefined") {
10578 if (typeof line === "number") {
10579 _this.line = line;
10580 _this.column = column;
10581 } else {
10582 _this.line = line.line;
10583 _this.column = line.column;
10584 _this.endLine = column.line;
10585 _this.endColumn = column.column;
10586 }
10587 }
10588 _this.setMessage();
10589 if (Error.captureStackTrace) {
10590 Error.captureStackTrace(_this, CssSyntaxError);
10591 }
10592 return _this;
10593 }
10594 var _proto = CssSyntaxError.prototype;
10595 _proto.setMessage = function setMessage() {
10596 this.message = this.plugin ? this.plugin + ": " : "";
10597 this.message += this.file ? this.file : "<css input>";
10598 if (typeof this.line !== "undefined") {
10599 this.message += ":" + this.line + ":" + this.column;
10600 }
10601 this.message += ": " + this.reason;
10602 };
10603 _proto.showSourceCode = function showSourceCode(color) {
10604 var _this = this;
10605 if (!this.source) return "";
10606 var css = this.source;
10607 if (color == null) color = pico$1.isColorSupported;
10608 if (terminalHighlight$1$1) {
10609 if (color) css = terminalHighlight$1$1(css);
10610 }
10611 var lines = css.split(/\r?\n/);
10612 var start = Math.max(this.line - 3, 0);
10613 var end = Math.min(this.line + 2, lines.length);
10614 var maxWidth = String(end).length;
10615 var mark, aside;
10616 if (color) {
10617 var _pico$1_createColors = pico$1.createColors(true), bold = _pico$1_createColors.bold, gray = _pico$1_createColors.gray, red = _pico$1_createColors.red;
10618 mark = function(text) {
10619 return bold(red(text));
10620 };
10621 aside = function(text) {
10622 return gray(text);
10623 };
10624 } else {
10625 mark = aside = function(str) {
10626 return str;
10627 };
10628 }
10629 return lines.slice(start, end).map(function(line, index2) {
10630 var number = start + 1 + index2;
10631 var gutter = " " + (" " + number).slice(-maxWidth) + " | ";
10632 if (number === _this.line) {
10633 var spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, _this.column - 1).replace(/[^\t]/g, " ");
10634 return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^");
10635 }
10636 return " " + aside(gutter) + line;
10637 }).join("\n");
10638 };
10639 _proto.toString = function toString() {
10640 var code = this.showSourceCode();
10641 if (code) {
10642 code = "\n\n" + code + "\n";
10643 }
10644 return this.name + ": " + this.message + code;
10645 };
10646 return CssSyntaxError;
10647 }(_wrap_native_super(Error));
10648 var cssSyntaxError$1 = CssSyntaxError$3$1;
10649 CssSyntaxError$3$1.default = CssSyntaxError$3$1;
10650 var symbols$1 = {};
10651 symbols$1.isClean = Symbol("isClean");
10652 symbols$1.my = Symbol("my");
10653 var DEFAULT_RAW$1 = {
10654 after: "\n",
10655 beforeClose: "\n",
10656 beforeComment: "\n",
10657 beforeDecl: "\n",
10658 beforeOpen: " ",
10659 beforeRule: "\n",
10660 colon: ": ",
10661 commentLeft: " ",
10662 commentRight: " ",
10663 emptyBody: "",
10664 indent: " ",
10665 semicolon: false
10666 };
10667 function capitalize$1(str) {
10668 return str[0].toUpperCase() + str.slice(1);
10669 }
10670 var Stringifier$2$1 = /*#__PURE__*/ function() {
10671 function Stringifier(builder) {
10672 this.builder = builder;
10673 }
10674 var _proto = Stringifier.prototype;
10675 _proto.atrule = function atrule(node2, semicolon) {
10676 var name = "@" + node2.name;
10677 var params = node2.params ? this.rawValue(node2, "params") : "";
10678 if (typeof node2.raws.afterName !== "undefined") {
10679 name += node2.raws.afterName;
10680 } else if (params) {
10681 name += " ";
10682 }
10683 if (node2.nodes) {
10684 this.block(node2, name + params);
10685 } else {
10686 var end = (node2.raws.between || "") + (semicolon ? ";" : "");
10687 this.builder(name + params + end, node2);
10688 }
10689 };
10690 _proto.beforeAfter = function beforeAfter(node2, detect) {
10691 var value;
10692 if (node2.type === "decl") {
10693 value = this.raw(node2, null, "beforeDecl");
10694 } else if (node2.type === "comment") {
10695 value = this.raw(node2, null, "beforeComment");
10696 } else if (detect === "before") {
10697 value = this.raw(node2, null, "beforeRule");
10698 } else {
10699 value = this.raw(node2, null, "beforeClose");
10700 }
10701 var buf = node2.parent;
10702 var depth = 0;
10703 while(buf && buf.type !== "root"){
10704 depth += 1;
10705 buf = buf.parent;
10706 }
10707 if (value.includes("\n")) {
10708 var indent = this.raw(node2, null, "indent");
10709 if (indent.length) {
10710 for(var step = 0; step < depth; step++)value += indent;
10711 }
10712 }
10713 return value;
10714 };
10715 _proto.block = function block(node2, start) {
10716 var between = this.raw(node2, "between", "beforeOpen");
10717 this.builder(start + between + "{", node2, "start");
10718 var after;
10719 if (node2.nodes && node2.nodes.length) {
10720 this.body(node2);
10721 after = this.raw(node2, "after");
10722 } else {
10723 after = this.raw(node2, "after", "emptyBody");
10724 }
10725 if (after) this.builder(after);
10726 this.builder("}", node2, "end");
10727 };
10728 _proto.body = function body(node2) {
10729 var last = node2.nodes.length - 1;
10730 while(last > 0){
10731 if (node2.nodes[last].type !== "comment") break;
10732 last -= 1;
10733 }
10734 var semicolon = this.raw(node2, "semicolon");
10735 for(var i2 = 0; i2 < node2.nodes.length; i2++){
10736 var child = node2.nodes[i2];
10737 var before = this.raw(child, "before");
10738 if (before) this.builder(before);
10739 this.stringify(child, last !== i2 || semicolon);
10740 }
10741 };
10742 _proto.comment = function comment(node2) {
10743 var left = this.raw(node2, "left", "commentLeft");
10744 var right = this.raw(node2, "right", "commentRight");
10745 this.builder("/*" + left + node2.text + right + "*/", node2);
10746 };
10747 _proto.decl = function decl(node2, semicolon) {
10748 var between = this.raw(node2, "between", "colon");
10749 var string = node2.prop + between + this.rawValue(node2, "value");
10750 if (node2.important) {
10751 string += node2.raws.important || " !important";
10752 }
10753 if (semicolon) string += ";";
10754 this.builder(string, node2);
10755 };
10756 _proto.document = function document1(node2) {
10757 this.body(node2);
10758 };
10759 _proto.raw = function raw(node2, own, detect) {
10760 var value;
10761 if (!detect) detect = own;
10762 if (own) {
10763 value = node2.raws[own];
10764 if (typeof value !== "undefined") return value;
10765 }
10766 var parent = node2.parent;
10767 if (detect === "before") {
10768 if (!parent || parent.type === "root" && parent.first === node2) {
10769 return "";
10770 }
10771 if (parent && parent.type === "document") {
10772 return "";
10773 }
10774 }
10775 if (!parent) return DEFAULT_RAW$1[detect];
10776 var root2 = node2.root();
10777 if (!root2.rawCache) root2.rawCache = {};
10778 if (typeof root2.rawCache[detect] !== "undefined") {
10779 return root2.rawCache[detect];
10780 }
10781 if (detect === "before" || detect === "after") {
10782 return this.beforeAfter(node2, detect);
10783 } else {
10784 var method = "raw" + capitalize$1(detect);
10785 if (this[method]) {
10786 value = this[method](root2, node2);
10787 } else {
10788 root2.walk(function(i2) {
10789 value = i2.raws[own];
10790 if (typeof value !== "undefined") return false;
10791 });
10792 }
10793 }
10794 if (typeof value === "undefined") value = DEFAULT_RAW$1[detect];
10795 root2.rawCache[detect] = value;
10796 return value;
10797 };
10798 _proto.rawBeforeClose = function rawBeforeClose(root2) {
10799 var value;
10800 root2.walk(function(i2) {
10801 if (i2.nodes && i2.nodes.length > 0) {
10802 if (typeof i2.raws.after !== "undefined") {
10803 value = i2.raws.after;
10804 if (value.includes("\n")) {
10805 value = value.replace(/[^\n]+$/, "");
10806 }
10807 return false;
10808 }
10809 }
10810 });
10811 if (value) value = value.replace(/\S/g, "");
10812 return value;
10813 };
10814 _proto.rawBeforeComment = function rawBeforeComment(root2, node2) {
10815 var value;
10816 root2.walkComments(function(i2) {
10817 if (typeof i2.raws.before !== "undefined") {
10818 value = i2.raws.before;
10819 if (value.includes("\n")) {
10820 value = value.replace(/[^\n]+$/, "");
10821 }
10822 return false;
10823 }
10824 });
10825 if (typeof value === "undefined") {
10826 value = this.raw(node2, null, "beforeDecl");
10827 } else if (value) {
10828 value = value.replace(/\S/g, "");
10829 }
10830 return value;
10831 };
10832 _proto.rawBeforeDecl = function rawBeforeDecl(root2, node2) {
10833 var value;
10834 root2.walkDecls(function(i2) {
10835 if (typeof i2.raws.before !== "undefined") {
10836 value = i2.raws.before;
10837 if (value.includes("\n")) {
10838 value = value.replace(/[^\n]+$/, "");
10839 }
10840 return false;
10841 }
10842 });
10843 if (typeof value === "undefined") {
10844 value = this.raw(node2, null, "beforeRule");
10845 } else if (value) {
10846 value = value.replace(/\S/g, "");
10847 }
10848 return value;
10849 };
10850 _proto.rawBeforeOpen = function rawBeforeOpen(root2) {
10851 var value;
10852 root2.walk(function(i2) {
10853 if (i2.type !== "decl") {
10854 value = i2.raws.between;
10855 if (typeof value !== "undefined") return false;
10856 }
10857 });
10858 return value;
10859 };
10860 _proto.rawBeforeRule = function rawBeforeRule(root2) {
10861 var value;
10862 root2.walk(function(i2) {
10863 if (i2.nodes && (i2.parent !== root2 || root2.first !== i2)) {
10864 if (typeof i2.raws.before !== "undefined") {
10865 value = i2.raws.before;
10866 if (value.includes("\n")) {
10867 value = value.replace(/[^\n]+$/, "");
10868 }
10869 return false;
10870 }
10871 }
10872 });
10873 if (value) value = value.replace(/\S/g, "");
10874 return value;
10875 };
10876 _proto.rawColon = function rawColon(root2) {
10877 var value;
10878 root2.walkDecls(function(i2) {
10879 if (typeof i2.raws.between !== "undefined") {
10880 value = i2.raws.between.replace(/[^\s:]/g, "");
10881 return false;
10882 }
10883 });
10884 return value;
10885 };
10886 _proto.rawEmptyBody = function rawEmptyBody(root2) {
10887 var value;
10888 root2.walk(function(i2) {
10889 if (i2.nodes && i2.nodes.length === 0) {
10890 value = i2.raws.after;
10891 if (typeof value !== "undefined") return false;
10892 }
10893 });
10894 return value;
10895 };
10896 _proto.rawIndent = function rawIndent(root2) {
10897 if (root2.raws.indent) return root2.raws.indent;
10898 var value;
10899 root2.walk(function(i2) {
10900 var p = i2.parent;
10901 if (p && p !== root2 && p.parent && p.parent === root2) {
10902 if (typeof i2.raws.before !== "undefined") {
10903 var parts = i2.raws.before.split("\n");
10904 value = parts[parts.length - 1];
10905 value = value.replace(/\S/g, "");
10906 return false;
10907 }
10908 }
10909 });
10910 return value;
10911 };
10912 _proto.rawSemicolon = function rawSemicolon(root2) {
10913 var value;
10914 root2.walk(function(i2) {
10915 if (i2.nodes && i2.nodes.length && i2.last.type === "decl") {
10916 value = i2.raws.semicolon;
10917 if (typeof value !== "undefined") return false;
10918 }
10919 });
10920 return value;
10921 };
10922 _proto.rawValue = function rawValue(node2, prop) {
10923 var value = node2[prop];
10924 var raw = node2.raws[prop];
10925 if (raw && raw.value === value) {
10926 return raw.raw;
10927 }
10928 return value;
10929 };
10930 _proto.root = function root(node2) {
10931 this.body(node2);
10932 if (node2.raws.after) this.builder(node2.raws.after);
10933 };
10934 _proto.rule = function rule(node2) {
10935 this.block(node2, this.rawValue(node2, "selector"));
10936 if (node2.raws.ownSemicolon) {
10937 this.builder(node2.raws.ownSemicolon, node2, "end");
10938 }
10939 };
10940 _proto.stringify = function stringify(node2, semicolon) {
10941 if (!this[node2.type]) {
10942 throw new Error("Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier.");
10943 }
10944 this[node2.type](node2, semicolon);
10945 };
10946 return Stringifier;
10947 }();
10948 var stringifier$1 = Stringifier$2$1;
10949 Stringifier$2$1.default = Stringifier$2$1;
10950 var Stringifier$1$1 = stringifier$1;
10951 function stringify$4$1(node2, builder) {
10952 var str = new Stringifier$1$1(builder);
10953 str.stringify(node2);
10954 }
10955 var stringify_1$1 = stringify$4$1;
10956 stringify$4$1.default = stringify$4$1;
10957 var isClean$2$1 = symbols$1.isClean, my$2$1 = symbols$1.my;
10958 var CssSyntaxError$2$1 = cssSyntaxError$1;
10959 var Stringifier2$1 = stringifier$1;
10960 var stringify$3$1 = stringify_1$1;
10961 function cloneNode$1(obj, parent) {
10962 var cloned = new obj.constructor();
10963 for(var i2 in obj){
10964 if (!Object.prototype.hasOwnProperty.call(obj, i2)) {
10965 continue;
10966 }
10967 if (i2 === "proxyCache") continue;
10968 var value = obj[i2];
10969 var type = typeof value === "undefined" ? "undefined" : _type_of(value);
10970 if (i2 === "parent" && type === "object") {
10971 if (parent) cloned[i2] = parent;
10972 } else if (i2 === "source") {
10973 cloned[i2] = value;
10974 } else if (Array.isArray(value)) {
10975 cloned[i2] = value.map(function(j) {
10976 return cloneNode$1(j, cloned);
10977 });
10978 } else {
10979 if (type === "object" && value !== null) value = cloneNode$1(value);
10980 cloned[i2] = value;
10981 }
10982 }
10983 return cloned;
10984 }
10985 var Node$4$1 = /*#__PURE__*/ function() {
10986 function Node2(defaults) {
10987 if (defaults === void 0) defaults = {};
10988 this.raws = {};
10989 this[isClean$2$1] = false;
10990 this[my$2$1] = true;
10991 for(var name in defaults){
10992 if (name === "nodes") {
10993 this.nodes = [];
10994 for(var _iterator = _create_for_of_iterator_helper_loose(defaults[name]), _step; !(_step = _iterator()).done;){
10995 var node2 = _step.value;
10996 if (typeof node2.clone === "function") {
10997 this.append(node2.clone());
10998 } else {
10999 this.append(node2);
11000 }
11001 }
11002 } else {
11003 this[name] = defaults[name];
11004 }
11005 }
11006 }
11007 var _proto = Node2.prototype;
11008 _proto.addToError = function addToError(error) {
11009 error.postcssNode = this;
11010 if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
11011 var s2 = this.source;
11012 error.stack = error.stack.replace(/\n\s{4}at /, "$&" + s2.input.from + ":" + s2.start.line + ":" + s2.start.column + "$&");
11013 }
11014 return error;
11015 };
11016 _proto.after = function after(add) {
11017 this.parent.insertAfter(this, add);
11018 return this;
11019 };
11020 _proto.assign = function assign(overrides) {
11021 if (overrides === void 0) overrides = {};
11022 for(var name in overrides){
11023 this[name] = overrides[name];
11024 }
11025 return this;
11026 };
11027 _proto.before = function before(add) {
11028 this.parent.insertBefore(this, add);
11029 return this;
11030 };
11031 _proto.cleanRaws = function cleanRaws(keepBetween) {
11032 delete this.raws.before;
11033 delete this.raws.after;
11034 if (!keepBetween) delete this.raws.between;
11035 };
11036 _proto.clone = function clone(overrides) {
11037 if (overrides === void 0) overrides = {};
11038 var cloned = cloneNode$1(this);
11039 for(var name in overrides){
11040 cloned[name] = overrides[name];
11041 }
11042 return cloned;
11043 };
11044 _proto.cloneAfter = function cloneAfter(overrides) {
11045 if (overrides === void 0) overrides = {};
11046 var cloned = this.clone(overrides);
11047 this.parent.insertAfter(this, cloned);
11048 return cloned;
11049 };
11050 _proto.cloneBefore = function cloneBefore(overrides) {
11051 if (overrides === void 0) overrides = {};
11052 var cloned = this.clone(overrides);
11053 this.parent.insertBefore(this, cloned);
11054 return cloned;
11055 };
11056 _proto.error = function error(message, opts) {
11057 if (opts === void 0) opts = {};
11058 if (this.source) {
11059 var _this_rangeBy = this.rangeBy(opts), end = _this_rangeBy.end, start = _this_rangeBy.start;
11060 return this.source.input.error(message, {
11061 column: start.column,
11062 line: start.line
11063 }, {
11064 column: end.column,
11065 line: end.line
11066 }, opts);
11067 }
11068 return new CssSyntaxError$2$1(message);
11069 };
11070 _proto.getProxyProcessor = function getProxyProcessor() {
11071 return {
11072 get: function get(node2, prop) {
11073 if (prop === "proxyOf") {
11074 return node2;
11075 } else if (prop === "root") {
11076 return function() {
11077 return node2.root().toProxy();
11078 };
11079 } else {
11080 return node2[prop];
11081 }
11082 },
11083 set: function set(node2, prop, value) {
11084 if (node2[prop] === value) return true;
11085 node2[prop] = value;
11086 if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ prop === "text") {
11087 node2.markDirty();
11088 }
11089 return true;
11090 }
11091 };
11092 };
11093 _proto.markDirty = function markDirty() {
11094 if (this[isClean$2$1]) {
11095 this[isClean$2$1] = false;
11096 var next = this;
11097 while(next = next.parent){
11098 next[isClean$2$1] = false;
11099 }
11100 }
11101 };
11102 _proto.next = function next() {
11103 if (!this.parent) return void 0;
11104 var index2 = this.parent.index(this);
11105 return this.parent.nodes[index2 + 1];
11106 };
11107 _proto.positionBy = function positionBy(opts, stringRepresentation) {
11108 var pos = this.source.start;
11109 if (opts.index) {
11110 pos = this.positionInside(opts.index, stringRepresentation);
11111 } else if (opts.word) {
11112 stringRepresentation = this.toString();
11113 var index2 = stringRepresentation.indexOf(opts.word);
11114 if (index2 !== -1) pos = this.positionInside(index2, stringRepresentation);
11115 }
11116 return pos;
11117 };
11118 _proto.positionInside = function positionInside(index2, stringRepresentation) {
11119 var string = stringRepresentation || this.toString();
11120 var column = this.source.start.column;
11121 var line = this.source.start.line;
11122 for(var i2 = 0; i2 < index2; i2++){
11123 if (string[i2] === "\n") {
11124 column = 1;
11125 line += 1;
11126 } else {
11127 column += 1;
11128 }
11129 }
11130 return {
11131 column: column,
11132 line: line
11133 };
11134 };
11135 _proto.prev = function prev() {
11136 if (!this.parent) return void 0;
11137 var index2 = this.parent.index(this);
11138 return this.parent.nodes[index2 - 1];
11139 };
11140 _proto.rangeBy = function rangeBy(opts) {
11141 var start = {
11142 column: this.source.start.column,
11143 line: this.source.start.line
11144 };
11145 var end = this.source.end ? {
11146 column: this.source.end.column + 1,
11147 line: this.source.end.line
11148 } : {
11149 column: start.column + 1,
11150 line: start.line
11151 };
11152 if (opts.word) {
11153 var stringRepresentation = this.toString();
11154 var index2 = stringRepresentation.indexOf(opts.word);
11155 if (index2 !== -1) {
11156 start = this.positionInside(index2, stringRepresentation);
11157 end = this.positionInside(index2 + opts.word.length, stringRepresentation);
11158 }
11159 } else {
11160 if (opts.start) {
11161 start = {
11162 column: opts.start.column,
11163 line: opts.start.line
11164 };
11165 } else if (opts.index) {
11166 start = this.positionInside(opts.index);
11167 }
11168 if (opts.end) {
11169 end = {
11170 column: opts.end.column,
11171 line: opts.end.line
11172 };
11173 } else if (typeof opts.endIndex === "number") {
11174 end = this.positionInside(opts.endIndex);
11175 } else if (opts.index) {
11176 end = this.positionInside(opts.index + 1);
11177 }
11178 }
11179 if (end.line < start.line || end.line === start.line && end.column <= start.column) {
11180 end = {
11181 column: start.column + 1,
11182 line: start.line
11183 };
11184 }
11185 return {
11186 end: end,
11187 start: start
11188 };
11189 };
11190 _proto.raw = function raw(prop, defaultType) {
11191 var str = new Stringifier2$1();
11192 return str.raw(this, prop, defaultType);
11193 };
11194 _proto.remove = function remove() {
11195 if (this.parent) {
11196 this.parent.removeChild(this);
11197 }
11198 this.parent = void 0;
11199 return this;
11200 };
11201 _proto.replaceWith = function replaceWith() {
11202 for(var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++){
11203 nodes[_key] = arguments[_key];
11204 }
11205 if (this.parent) {
11206 var bookmark = this;
11207 var foundSelf = false;
11208 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
11209 var node2 = _step.value;
11210 if (node2 === this) {
11211 foundSelf = true;
11212 } else if (foundSelf) {
11213 this.parent.insertAfter(bookmark, node2);
11214 bookmark = node2;
11215 } else {
11216 this.parent.insertBefore(bookmark, node2);
11217 }
11218 }
11219 if (!foundSelf) {
11220 this.remove();
11221 }
11222 }
11223 return this;
11224 };
11225 _proto.root = function root() {
11226 var result2 = this;
11227 while(result2.parent && result2.parent.type !== "document"){
11228 result2 = result2.parent;
11229 }
11230 return result2;
11231 };
11232 _proto.toJSON = function toJSON(_, inputs) {
11233 var fixed = {};
11234 var emitInputs = inputs == null;
11235 inputs = inputs || /* @__PURE__ */ new Map();
11236 var inputsNextIndex = 0;
11237 for(var name in this){
11238 if (!Object.prototype.hasOwnProperty.call(this, name)) {
11239 continue;
11240 }
11241 if (name === "parent" || name === "proxyCache") continue;
11242 var value = this[name];
11243 if (Array.isArray(value)) {
11244 fixed[name] = value.map(function(i2) {
11245 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.toJSON) {
11246 return i2.toJSON(null, inputs);
11247 } else {
11248 return i2;
11249 }
11250 });
11251 } else if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value.toJSON) {
11252 fixed[name] = value.toJSON(null, inputs);
11253 } else if (name === "source") {
11254 var inputId = inputs.get(value.input);
11255 if (inputId == null) {
11256 inputId = inputsNextIndex;
11257 inputs.set(value.input, inputsNextIndex);
11258 inputsNextIndex++;
11259 }
11260 fixed[name] = {
11261 end: value.end,
11262 inputId: inputId,
11263 start: value.start
11264 };
11265 } else {
11266 fixed[name] = value;
11267 }
11268 }
11269 if (emitInputs) {
11270 fixed.inputs = [].concat(inputs.keys()).map(function(input2) {
11271 return input2.toJSON();
11272 });
11273 }
11274 return fixed;
11275 };
11276 _proto.toProxy = function toProxy() {
11277 if (!this.proxyCache) {
11278 this.proxyCache = new Proxy(this, this.getProxyProcessor());
11279 }
11280 return this.proxyCache;
11281 };
11282 _proto.toString = function toString(stringifier2) {
11283 if (stringifier2 === void 0) stringifier2 = stringify$3$1;
11284 if (stringifier2.stringify) stringifier2 = stringifier2.stringify;
11285 var result2 = "";
11286 stringifier2(this, function(i2) {
11287 result2 += i2;
11288 });
11289 return result2;
11290 };
11291 _proto.warn = function warn(result2, text, opts) {
11292 var data = {
11293 node: this
11294 };
11295 for(var i2 in opts)data[i2] = opts[i2];
11296 return result2.warn(text, data);
11297 };
11298 _create_class(Node2, [
11299 {
11300 key: "proxyOf",
11301 get: function get() {
11302 return this;
11303 }
11304 }
11305 ]);
11306 return Node2;
11307 }();
11308 var node$1 = Node$4$1;
11309 Node$4$1.default = Node$4$1;
11310 var Node$3$1 = node$1;
11311 var Declaration$4$1 = /*#__PURE__*/ function(Node$3$1) {
11312 _inherits(Declaration, Node$3$1);
11313 function Declaration(defaults) {
11314 var _this;
11315 if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
11316 defaults = _extends({}, defaults, {
11317 value: String(defaults.value)
11318 });
11319 }
11320 _this = Node$3$1.call(this, defaults) || this;
11321 _this.type = "decl";
11322 return _this;
11323 }
11324 _create_class(Declaration, [
11325 {
11326 key: "variable",
11327 get: function get() {
11328 return this.prop.startsWith("--") || this.prop[0] === "$";
11329 }
11330 }
11331 ]);
11332 return Declaration;
11333 }(Node$3$1);
11334 var declaration$1 = Declaration$4$1;
11335 Declaration$4$1.default = Declaration$4$1;
11336 var urlAlphabet$1 = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
11337 var nanoid$1$1 = function(size) {
11338 if (size === void 0) size = 21;
11339 var id = "";
11340 var i2 = size;
11341 while(i2--){
11342 id += urlAlphabet$1[Math.random() * 64 | 0];
11343 }
11344 return id;
11345 };
11346 var nonSecure$1 = {
11347 nanoid: nanoid$1$1};
11348 var SourceMapConsumer$2$1 = require$$2$1.SourceMapConsumer, SourceMapGenerator$2$1 = require$$2$1.SourceMapGenerator;
11349 var existsSync$1 = require$$2$1.existsSync, readFileSync$1 = require$$2$1.readFileSync;
11350 var dirname$1$1 = require$$2$1.dirname, join$1 = require$$2$1.join;
11351 function fromBase64$1(str) {
11352 if (Buffer) {
11353 return Buffer.from(str, "base64").toString();
11354 } else {
11355 return window.atob(str);
11356 }
11357 }
11358 var PreviousMap$2$1 = /*#__PURE__*/ function() {
11359 function PreviousMap(css, opts) {
11360 if (opts.map === false) return;
11361 this.loadAnnotation(css);
11362 this.inline = this.startWith(this.annotation, "data:");
11363 var prev = opts.map ? opts.map.prev : void 0;
11364 var text = this.loadMap(opts.from, prev);
11365 if (!this.mapFile && opts.from) {
11366 this.mapFile = opts.from;
11367 }
11368 if (this.mapFile) this.root = dirname$1$1(this.mapFile);
11369 if (text) this.text = text;
11370 }
11371 var _proto = PreviousMap.prototype;
11372 _proto.consumer = function consumer() {
11373 if (!this.consumerCache) {
11374 this.consumerCache = new SourceMapConsumer$2$1(this.text);
11375 }
11376 return this.consumerCache;
11377 };
11378 _proto.decodeInline = function decodeInline(text) {
11379 var baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
11380 var baseUri = /^data:application\/json;base64,/;
11381 var charsetUri = /^data:application\/json;charset=utf-?8,/;
11382 var uri = /^data:application\/json,/;
11383 if (charsetUri.test(text) || uri.test(text)) {
11384 return decodeURIComponent(text.substr(RegExp.lastMatch.length));
11385 }
11386 if (baseCharsetUri.test(text) || baseUri.test(text)) {
11387 return fromBase64$1(text.substr(RegExp.lastMatch.length));
11388 }
11389 var encoding = text.match(/data:application\/json;([^,]+),/)[1];
11390 throw new Error("Unsupported source map encoding " + encoding);
11391 };
11392 _proto.getAnnotationURL = function getAnnotationURL(sourceMapString) {
11393 return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
11394 };
11395 _proto.isMap = function isMap(map) {
11396 if ((typeof map === "undefined" ? "undefined" : _type_of(map)) !== "object") return false;
11397 return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
11398 };
11399 _proto.loadAnnotation = function loadAnnotation(css) {
11400 var comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
11401 if (!comments) return;
11402 var start = css.lastIndexOf(comments.pop());
11403 var end = css.indexOf("*/", start);
11404 if (start > -1 && end > -1) {
11405 this.annotation = this.getAnnotationURL(css.substring(start, end));
11406 }
11407 };
11408 _proto.loadFile = function loadFile(path) {
11409 this.root = dirname$1$1(path);
11410 if (existsSync$1(path)) {
11411 this.mapFile = path;
11412 return readFileSync$1(path, "utf-8").toString().trim();
11413 }
11414 };
11415 _proto.loadMap = function loadMap(file, prev) {
11416 if (prev === false) return false;
11417 if (prev) {
11418 if (typeof prev === "string") {
11419 return prev;
11420 } else if (typeof prev === "function") {
11421 var prevPath = prev(file);
11422 if (prevPath) {
11423 var map = this.loadFile(prevPath);
11424 if (!map) {
11425 throw new Error("Unable to load previous source map: " + prevPath.toString());
11426 }
11427 return map;
11428 }
11429 } else if (_instanceof(prev, SourceMapConsumer$2$1)) {
11430 return SourceMapGenerator$2$1.fromSourceMap(prev).toString();
11431 } else if (_instanceof(prev, SourceMapGenerator$2$1)) {
11432 return prev.toString();
11433 } else if (this.isMap(prev)) {
11434 return JSON.stringify(prev);
11435 } else {
11436 throw new Error("Unsupported previous source map format: " + prev.toString());
11437 }
11438 } else if (this.inline) {
11439 return this.decodeInline(this.annotation);
11440 } else if (this.annotation) {
11441 var map1 = this.annotation;
11442 if (file) map1 = join$1(dirname$1$1(file), map1);
11443 return this.loadFile(map1);
11444 }
11445 };
11446 _proto.startWith = function startWith(string, start) {
11447 if (!string) return false;
11448 return string.substr(0, start.length) === start;
11449 };
11450 _proto.withContent = function withContent() {
11451 return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
11452 };
11453 return PreviousMap;
11454 }();
11455 var previousMap$1 = PreviousMap$2$1;
11456 PreviousMap$2$1.default = PreviousMap$2$1;
11457 var SourceMapConsumer$1$1 = require$$2$1.SourceMapConsumer, SourceMapGenerator$1$1 = require$$2$1.SourceMapGenerator;
11458 var fileURLToPath$1 = require$$2$1.fileURLToPath, pathToFileURL$1$1 = require$$2$1.pathToFileURL;
11459 var isAbsolute$1 = require$$2$1.isAbsolute, resolve$1$1 = require$$2$1.resolve;
11460 var nanoid$2 = nonSecure$1.nanoid;
11461 var terminalHighlight$2 = require$$2$1;
11462 var CssSyntaxError$1$1 = cssSyntaxError$1;
11463 var PreviousMap$1$1 = previousMap$1;
11464 var fromOffsetCache$1 = Symbol("fromOffsetCache");
11465 var sourceMapAvailable$1$1 = Boolean(SourceMapConsumer$1$1 && SourceMapGenerator$1$1);
11466 var pathAvailable$1$1 = Boolean(resolve$1$1 && isAbsolute$1);
11467 var Input$4$1 = /*#__PURE__*/ function() {
11468 function Input(css, opts) {
11469 if (opts === void 0) opts = {};
11470 if (css === null || typeof css === "undefined" || (typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && !css.toString) {
11471 throw new Error("PostCSS received " + css + " instead of CSS string");
11472 }
11473 this.css = css.toString();
11474 if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
11475 this.hasBOM = true;
11476 this.css = this.css.slice(1);
11477 } else {
11478 this.hasBOM = false;
11479 }
11480 if (opts.from) {
11481 if (!pathAvailable$1$1 || /^\w+:\/\//.test(opts.from) || isAbsolute$1(opts.from)) {
11482 this.file = opts.from;
11483 } else {
11484 this.file = resolve$1$1(opts.from);
11485 }
11486 }
11487 if (pathAvailable$1$1 && sourceMapAvailable$1$1) {
11488 var map = new PreviousMap$1$1(this.css, opts);
11489 if (map.text) {
11490 this.map = map;
11491 var file = map.consumer().file;
11492 if (!this.file && file) this.file = this.mapResolve(file);
11493 }
11494 }
11495 if (!this.file) {
11496 this.id = "<input css " + nanoid$2(6) + ">";
11497 }
11498 if (this.map) this.map.file = this.from;
11499 }
11500 var _proto = Input.prototype;
11501 _proto.error = function error(message, line, column, opts) {
11502 if (opts === void 0) opts = {};
11503 var result2, endLine, endColumn;
11504 if (line && (typeof line === "undefined" ? "undefined" : _type_of(line)) === "object") {
11505 var start = line;
11506 var end = column;
11507 if (typeof start.offset === "number") {
11508 var pos = this.fromOffset(start.offset);
11509 line = pos.line;
11510 column = pos.col;
11511 } else {
11512 line = start.line;
11513 column = start.column;
11514 }
11515 if (typeof end.offset === "number") {
11516 var pos1 = this.fromOffset(end.offset);
11517 endLine = pos1.line;
11518 endColumn = pos1.col;
11519 } else {
11520 endLine = end.line;
11521 endColumn = end.column;
11522 }
11523 } else if (!column) {
11524 var pos2 = this.fromOffset(line);
11525 line = pos2.line;
11526 column = pos2.col;
11527 }
11528 var origin = this.origin(line, column, endLine, endColumn);
11529 if (origin) {
11530 result2 = new CssSyntaxError$1$1(message, origin.endLine === void 0 ? origin.line : {
11531 column: origin.column,
11532 line: origin.line
11533 }, origin.endLine === void 0 ? origin.column : {
11534 column: origin.endColumn,
11535 line: origin.endLine
11536 }, origin.source, origin.file, opts.plugin);
11537 } else {
11538 result2 = new CssSyntaxError$1$1(message, endLine === void 0 ? line : {
11539 column: column,
11540 line: line
11541 }, endLine === void 0 ? column : {
11542 column: endColumn,
11543 line: endLine
11544 }, this.css, this.file, opts.plugin);
11545 }
11546 result2.input = {
11547 column: column,
11548 endColumn: endColumn,
11549 endLine: endLine,
11550 line: line,
11551 source: this.css
11552 };
11553 if (this.file) {
11554 if (pathToFileURL$1$1) {
11555 result2.input.url = pathToFileURL$1$1(this.file).toString();
11556 }
11557 result2.input.file = this.file;
11558 }
11559 return result2;
11560 };
11561 _proto.fromOffset = function fromOffset(offset) {
11562 var lastLine, lineToIndex;
11563 if (!this[fromOffsetCache$1]) {
11564 var lines = this.css.split("\n");
11565 lineToIndex = new Array(lines.length);
11566 var prevIndex = 0;
11567 for(var i2 = 0, l2 = lines.length; i2 < l2; i2++){
11568 lineToIndex[i2] = prevIndex;
11569 prevIndex += lines[i2].length + 1;
11570 }
11571 this[fromOffsetCache$1] = lineToIndex;
11572 } else {
11573 lineToIndex = this[fromOffsetCache$1];
11574 }
11575 lastLine = lineToIndex[lineToIndex.length - 1];
11576 var min = 0;
11577 if (offset >= lastLine) {
11578 min = lineToIndex.length - 1;
11579 } else {
11580 var max = lineToIndex.length - 2;
11581 var mid;
11582 while(min < max){
11583 mid = min + (max - min >> 1);
11584 if (offset < lineToIndex[mid]) {
11585 max = mid - 1;
11586 } else if (offset >= lineToIndex[mid + 1]) {
11587 min = mid + 1;
11588 } else {
11589 min = mid;
11590 break;
11591 }
11592 }
11593 }
11594 return {
11595 col: offset - lineToIndex[min] + 1,
11596 line: min + 1
11597 };
11598 };
11599 _proto.mapResolve = function mapResolve(file) {
11600 if (/^\w+:\/\//.test(file)) {
11601 return file;
11602 }
11603 return resolve$1$1(this.map.consumer().sourceRoot || this.map.root || ".", file);
11604 };
11605 _proto.origin = function origin(line, column, endLine, endColumn) {
11606 if (!this.map) return false;
11607 var consumer = this.map.consumer();
11608 var from = consumer.originalPositionFor({
11609 column: column,
11610 line: line
11611 });
11612 if (!from.source) return false;
11613 var to;
11614 if (typeof endLine === "number") {
11615 to = consumer.originalPositionFor({
11616 column: endColumn,
11617 line: endLine
11618 });
11619 }
11620 var fromUrl;
11621 if (isAbsolute$1(from.source)) {
11622 fromUrl = pathToFileURL$1$1(from.source);
11623 } else {
11624 fromUrl = new URL(from.source, this.map.consumer().sourceRoot || pathToFileURL$1$1(this.map.mapFile));
11625 }
11626 var result2 = {
11627 column: from.column,
11628 endColumn: to && to.column,
11629 endLine: to && to.line,
11630 line: from.line,
11631 url: fromUrl.toString()
11632 };
11633 if (fromUrl.protocol === "file:") {
11634 if (fileURLToPath$1) {
11635 result2.file = fileURLToPath$1(fromUrl);
11636 } else {
11637 throw new Error("file: protocol is not available in this PostCSS build");
11638 }
11639 }
11640 var source = consumer.sourceContentFor(from.source);
11641 if (source) result2.source = source;
11642 return result2;
11643 };
11644 _proto.toJSON = function toJSON() {
11645 var json = {};
11646 for(var _i = 0, _iter = [
11647 "hasBOM",
11648 "css",
11649 "file",
11650 "id"
11651 ]; _i < _iter.length; _i++){
11652 var name = _iter[_i];
11653 if (this[name] != null) {
11654 json[name] = this[name];
11655 }
11656 }
11657 if (this.map) {
11658 json.map = _extends({}, this.map);
11659 if (json.map.consumerCache) {
11660 json.map.consumerCache = void 0;
11661 }
11662 }
11663 return json;
11664 };
11665 _create_class(Input, [
11666 {
11667 key: "from",
11668 get: function get() {
11669 return this.file || this.id;
11670 }
11671 }
11672 ]);
11673 return Input;
11674 }();
11675 var input$1 = Input$4$1;
11676 Input$4$1.default = Input$4$1;
11677 if (terminalHighlight$2 && terminalHighlight$2.registerInput) {
11678 terminalHighlight$2.registerInput(Input$4$1);
11679 }
11680 var SourceMapConsumer$3 = require$$2$1.SourceMapConsumer, SourceMapGenerator$3 = require$$2$1.SourceMapGenerator;
11681 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;
11682 var pathToFileURL$2 = require$$2$1.pathToFileURL;
11683 var Input$3$1 = input$1;
11684 var sourceMapAvailable$2 = Boolean(SourceMapConsumer$3 && SourceMapGenerator$3);
11685 var pathAvailable$2 = Boolean(dirname$2 && resolve$2 && relative$1 && sep$1);
11686 var MapGenerator$2$1 = /*#__PURE__*/ function() {
11687 function MapGenerator(stringify2, root2, opts, cssString) {
11688 this.stringify = stringify2;
11689 this.mapOpts = opts.map || {};
11690 this.root = root2;
11691 this.opts = opts;
11692 this.css = cssString;
11693 this.originalCSS = cssString;
11694 this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
11695 this.memoizedFileURLs = /* @__PURE__ */ new Map();
11696 this.memoizedPaths = /* @__PURE__ */ new Map();
11697 this.memoizedURLs = /* @__PURE__ */ new Map();
11698 }
11699 var _proto = MapGenerator.prototype;
11700 _proto.addAnnotation = function addAnnotation() {
11701 var content;
11702 if (this.isInline()) {
11703 content = "data:application/json;base64," + this.toBase64(this.map.toString());
11704 } else if (typeof this.mapOpts.annotation === "string") {
11705 content = this.mapOpts.annotation;
11706 } else if (typeof this.mapOpts.annotation === "function") {
11707 content = this.mapOpts.annotation(this.opts.to, this.root);
11708 } else {
11709 content = this.outputFile() + ".map";
11710 }
11711 var eol = "\n";
11712 if (this.css.includes("\r\n")) eol = "\r\n";
11713 this.css += eol + "/*# sourceMappingURL=" + content + " */";
11714 };
11715 _proto.applyPrevMaps = function applyPrevMaps() {
11716 for(var _iterator = _create_for_of_iterator_helper_loose(this.previous()), _step; !(_step = _iterator()).done;){
11717 var prev = _step.value;
11718 var from = this.toUrl(this.path(prev.file));
11719 var root2 = prev.root || dirname$2(prev.file);
11720 var map = void 0;
11721 if (this.mapOpts.sourcesContent === false) {
11722 map = new SourceMapConsumer$3(prev.text);
11723 if (map.sourcesContent) {
11724 map.sourcesContent = null;
11725 }
11726 } else {
11727 map = prev.consumer();
11728 }
11729 this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
11730 }
11731 };
11732 _proto.clearAnnotation = function clearAnnotation() {
11733 if (this.mapOpts.annotation === false) return;
11734 if (this.root) {
11735 var node2;
11736 for(var i2 = this.root.nodes.length - 1; i2 >= 0; i2--){
11737 node2 = this.root.nodes[i2];
11738 if (node2.type !== "comment") continue;
11739 if (node2.text.indexOf("# sourceMappingURL=") === 0) {
11740 this.root.removeChild(i2);
11741 }
11742 }
11743 } else if (this.css) {
11744 this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, "");
11745 }
11746 };
11747 _proto.generate = function generate() {
11748 this.clearAnnotation();
11749 if (pathAvailable$2 && sourceMapAvailable$2 && this.isMap()) {
11750 return this.generateMap();
11751 } else {
11752 var result2 = "";
11753 this.stringify(this.root, function(i2) {
11754 result2 += i2;
11755 });
11756 return [
11757 result2
11758 ];
11759 }
11760 };
11761 _proto.generateMap = function generateMap() {
11762 if (this.root) {
11763 this.generateString();
11764 } else if (this.previous().length === 1) {
11765 var prev = this.previous()[0].consumer();
11766 prev.file = this.outputFile();
11767 this.map = SourceMapGenerator$3.fromSourceMap(prev, {
11768 ignoreInvalidMapping: true
11769 });
11770 } else {
11771 this.map = new SourceMapGenerator$3({
11772 file: this.outputFile(),
11773 ignoreInvalidMapping: true
11774 });
11775 this.map.addMapping({
11776 generated: {
11777 column: 0,
11778 line: 1
11779 },
11780 original: {
11781 column: 0,
11782 line: 1
11783 },
11784 source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
11785 });
11786 }
11787 if (this.isSourcesContent()) this.setSourcesContent();
11788 if (this.root && this.previous().length > 0) this.applyPrevMaps();
11789 if (this.isAnnotation()) this.addAnnotation();
11790 if (this.isInline()) {
11791 return [
11792 this.css
11793 ];
11794 } else {
11795 return [
11796 this.css,
11797 this.map
11798 ];
11799 }
11800 };
11801 _proto.generateString = function generateString() {
11802 var _this = this;
11803 this.css = "";
11804 this.map = new SourceMapGenerator$3({
11805 file: this.outputFile(),
11806 ignoreInvalidMapping: true
11807 });
11808 var line = 1;
11809 var column = 1;
11810 var noSource = "<no source>";
11811 var mapping = {
11812 generated: {
11813 column: 0,
11814 line: 0
11815 },
11816 original: {
11817 column: 0,
11818 line: 0
11819 },
11820 source: ""
11821 };
11822 var lines, last;
11823 this.stringify(this.root, function(str, node2, type) {
11824 _this.css += str;
11825 if (node2 && type !== "end") {
11826 mapping.generated.line = line;
11827 mapping.generated.column = column - 1;
11828 if (node2.source && node2.source.start) {
11829 mapping.source = _this.sourcePath(node2);
11830 mapping.original.line = node2.source.start.line;
11831 mapping.original.column = node2.source.start.column - 1;
11832 _this.map.addMapping(mapping);
11833 } else {
11834 mapping.source = noSource;
11835 mapping.original.line = 1;
11836 mapping.original.column = 0;
11837 _this.map.addMapping(mapping);
11838 }
11839 }
11840 lines = str.match(/\n/g);
11841 if (lines) {
11842 line += lines.length;
11843 last = str.lastIndexOf("\n");
11844 column = str.length - last;
11845 } else {
11846 column += str.length;
11847 }
11848 if (node2 && type !== "start") {
11849 var p = node2.parent || {
11850 raws: {}
11851 };
11852 var childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
11853 if (!childless || node2 !== p.last || p.raws.semicolon) {
11854 if (node2.source && node2.source.end) {
11855 mapping.source = _this.sourcePath(node2);
11856 mapping.original.line = node2.source.end.line;
11857 mapping.original.column = node2.source.end.column - 1;
11858 mapping.generated.line = line;
11859 mapping.generated.column = column - 2;
11860 _this.map.addMapping(mapping);
11861 } else {
11862 mapping.source = noSource;
11863 mapping.original.line = 1;
11864 mapping.original.column = 0;
11865 mapping.generated.line = line;
11866 mapping.generated.column = column - 1;
11867 _this.map.addMapping(mapping);
11868 }
11869 }
11870 }
11871 });
11872 };
11873 _proto.isAnnotation = function isAnnotation() {
11874 if (this.isInline()) {
11875 return true;
11876 }
11877 if (typeof this.mapOpts.annotation !== "undefined") {
11878 return this.mapOpts.annotation;
11879 }
11880 if (this.previous().length) {
11881 return this.previous().some(function(i2) {
11882 return i2.annotation;
11883 });
11884 }
11885 return true;
11886 };
11887 _proto.isInline = function isInline() {
11888 if (typeof this.mapOpts.inline !== "undefined") {
11889 return this.mapOpts.inline;
11890 }
11891 var annotation = this.mapOpts.annotation;
11892 if (typeof annotation !== "undefined" && annotation !== true) {
11893 return false;
11894 }
11895 if (this.previous().length) {
11896 return this.previous().some(function(i2) {
11897 return i2.inline;
11898 });
11899 }
11900 return true;
11901 };
11902 _proto.isMap = function isMap() {
11903 if (typeof this.opts.map !== "undefined") {
11904 return !!this.opts.map;
11905 }
11906 return this.previous().length > 0;
11907 };
11908 _proto.isSourcesContent = function isSourcesContent() {
11909 if (typeof this.mapOpts.sourcesContent !== "undefined") {
11910 return this.mapOpts.sourcesContent;
11911 }
11912 if (this.previous().length) {
11913 return this.previous().some(function(i2) {
11914 return i2.withContent();
11915 });
11916 }
11917 return true;
11918 };
11919 _proto.outputFile = function outputFile() {
11920 if (this.opts.to) {
11921 return this.path(this.opts.to);
11922 } else if (this.opts.from) {
11923 return this.path(this.opts.from);
11924 } else {
11925 return "to.css";
11926 }
11927 };
11928 _proto.path = function path(file) {
11929 if (this.mapOpts.absolute) return file;
11930 if (file.charCodeAt(0) === 60) return file;
11931 if (/^\w+:\/\//.test(file)) return file;
11932 var cached = this.memoizedPaths.get(file);
11933 if (cached) return cached;
11934 var from = this.opts.to ? dirname$2(this.opts.to) : ".";
11935 if (typeof this.mapOpts.annotation === "string") {
11936 from = dirname$2(resolve$2(from, this.mapOpts.annotation));
11937 }
11938 var path = relative$1(from, file);
11939 this.memoizedPaths.set(file, path);
11940 return path;
11941 };
11942 _proto.previous = function previous() {
11943 var _this = this;
11944 if (!this.previousMaps) {
11945 this.previousMaps = [];
11946 if (this.root) {
11947 this.root.walk(function(node2) {
11948 if (node2.source && node2.source.input.map) {
11949 var map = node2.source.input.map;
11950 if (!_this.previousMaps.includes(map)) {
11951 _this.previousMaps.push(map);
11952 }
11953 }
11954 });
11955 } else {
11956 var input2 = new Input$3$1(this.originalCSS, this.opts);
11957 if (input2.map) this.previousMaps.push(input2.map);
11958 }
11959 }
11960 return this.previousMaps;
11961 };
11962 _proto.setSourcesContent = function setSourcesContent() {
11963 var _this = this;
11964 var already = {};
11965 if (this.root) {
11966 this.root.walk(function(node2) {
11967 if (node2.source) {
11968 var from = node2.source.input.from;
11969 if (from && !already[from]) {
11970 already[from] = true;
11971 var fromUrl = _this.usesFileUrls ? _this.toFileUrl(from) : _this.toUrl(_this.path(from));
11972 _this.map.setSourceContent(fromUrl, node2.source.input.css);
11973 }
11974 }
11975 });
11976 } else if (this.css) {
11977 var from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
11978 this.map.setSourceContent(from, this.css);
11979 }
11980 };
11981 _proto.sourcePath = function sourcePath(node2) {
11982 if (this.mapOpts.from) {
11983 return this.toUrl(this.mapOpts.from);
11984 } else if (this.usesFileUrls) {
11985 return this.toFileUrl(node2.source.input.from);
11986 } else {
11987 return this.toUrl(this.path(node2.source.input.from));
11988 }
11989 };
11990 _proto.toBase64 = function toBase64(str) {
11991 if (Buffer) {
11992 return Buffer.from(str).toString("base64");
11993 } else {
11994 return window.btoa(unescape(encodeURIComponent(str)));
11995 }
11996 };
11997 _proto.toFileUrl = function toFileUrl(path) {
11998 var cached = this.memoizedFileURLs.get(path);
11999 if (cached) return cached;
12000 if (pathToFileURL$2) {
12001 var fileURL = pathToFileURL$2(path).toString();
12002 this.memoizedFileURLs.set(path, fileURL);
12003 return fileURL;
12004 } else {
12005 throw new Error("`map.absolute` option is not available in this PostCSS build");
12006 }
12007 };
12008 _proto.toUrl = function toUrl(path) {
12009 var cached = this.memoizedURLs.get(path);
12010 if (cached) return cached;
12011 if (sep$1 === "\\") {
12012 path = path.replace(/\\/g, "/");
12013 }
12014 var url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
12015 this.memoizedURLs.set(path, url);
12016 return url;
12017 };
12018 return MapGenerator;
12019 }();
12020 var mapGenerator$1 = MapGenerator$2$1;
12021 var Node$2$1 = node$1;
12022 var Comment$4$1 = /*#__PURE__*/ function(Node$2$1) {
12023 _inherits(Comment, Node$2$1);
12024 function Comment(defaults) {
12025 var _this;
12026 _this = Node$2$1.call(this, defaults) || this;
12027 _this.type = "comment";
12028 return _this;
12029 }
12030 return Comment;
12031 }(Node$2$1);
12032 var comment$1 = Comment$4$1;
12033 Comment$4$1.default = Comment$4$1;
12034 var isClean$1$1 = symbols$1.isClean, my$1$1 = symbols$1.my;
12035 var Declaration$3$1 = declaration$1;
12036 var Comment$3$1 = comment$1;
12037 var Node$1$1 = node$1;
12038 var parse$4$1, Rule$4$1, AtRule$4$1, Root$6$1;
12039 function cleanSource$1(nodes) {
12040 return nodes.map(function(i2) {
12041 if (i2.nodes) i2.nodes = cleanSource$1(i2.nodes);
12042 delete i2.source;
12043 return i2;
12044 });
12045 }
12046 function markDirtyUp$1(node2) {
12047 node2[isClean$1$1] = false;
12048 if (node2.proxyOf.nodes) {
12049 for(var _iterator = _create_for_of_iterator_helper_loose(node2.proxyOf.nodes), _step; !(_step = _iterator()).done;){
12050 var i2 = _step.value;
12051 markDirtyUp$1(i2);
12052 }
12053 }
12054 }
12055 var Container$7$1 = /*#__PURE__*/ function(Node$1$1) {
12056 _inherits(Container, Node$1$1);
12057 function Container() {
12058 return Node$1$1.apply(this, arguments) || this;
12059 }
12060 var _proto = Container.prototype;
12061 _proto.append = function append() {
12062 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12063 children[_key] = arguments[_key];
12064 }
12065 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
12066 var child = _step.value;
12067 var nodes = this.normalize(child, this.last);
12068 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
12069 var node2 = _step1.value;
12070 this.proxyOf.nodes.push(node2);
12071 }
12072 }
12073 this.markDirty();
12074 return this;
12075 };
12076 _proto.cleanRaws = function cleanRaws(keepBetween) {
12077 Node$1$1.prototype.cleanRaws.call(this, keepBetween);
12078 if (this.nodes) {
12079 for(var _iterator = _create_for_of_iterator_helper_loose(this.nodes), _step; !(_step = _iterator()).done;){
12080 var node2 = _step.value;
12081 node2.cleanRaws(keepBetween);
12082 }
12083 }
12084 };
12085 _proto.each = function each(callback) {
12086 if (!this.proxyOf.nodes) return void 0;
12087 var iterator = this.getIterator();
12088 var index2, result2;
12089 while(this.indexes[iterator] < this.proxyOf.nodes.length){
12090 index2 = this.indexes[iterator];
12091 result2 = callback(this.proxyOf.nodes[index2], index2);
12092 if (result2 === false) break;
12093 this.indexes[iterator] += 1;
12094 }
12095 delete this.indexes[iterator];
12096 return result2;
12097 };
12098 _proto.every = function every(condition) {
12099 return this.nodes.every(condition);
12100 };
12101 _proto.getIterator = function getIterator() {
12102 if (!this.lastEach) this.lastEach = 0;
12103 if (!this.indexes) this.indexes = {};
12104 this.lastEach += 1;
12105 var iterator = this.lastEach;
12106 this.indexes[iterator] = 0;
12107 return iterator;
12108 };
12109 _proto.getProxyProcessor = function getProxyProcessor() {
12110 return {
12111 get: function get(node2, prop) {
12112 if (prop === "proxyOf") {
12113 return node2;
12114 } else if (!node2[prop]) {
12115 return node2[prop];
12116 } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
12117 return function() {
12118 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
12119 args[_key] = arguments[_key];
12120 }
12121 var _node2;
12122 return (_node2 = node2)[prop].apply(_node2, [].concat(args.map(function(i2) {
12123 if (typeof i2 === "function") {
12124 return function(child, index2) {
12125 return i2(child.toProxy(), index2);
12126 };
12127 } else {
12128 return i2;
12129 }
12130 })));
12131 };
12132 } else if (prop === "every" || prop === "some") {
12133 return function(cb) {
12134 return node2[prop](function(child) {
12135 for(var _len = arguments.length, other = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
12136 other[_key - 1] = arguments[_key];
12137 }
12138 return cb.apply(void 0, [].concat([
12139 child.toProxy()
12140 ], other));
12141 });
12142 };
12143 } else if (prop === "root") {
12144 return function() {
12145 return node2.root().toProxy();
12146 };
12147 } else if (prop === "nodes") {
12148 return node2.nodes.map(function(i2) {
12149 return i2.toProxy();
12150 });
12151 } else if (prop === "first" || prop === "last") {
12152 return node2[prop].toProxy();
12153 } else {
12154 return node2[prop];
12155 }
12156 },
12157 set: function set(node2, prop, value) {
12158 if (node2[prop] === value) return true;
12159 node2[prop] = value;
12160 if (prop === "name" || prop === "params" || prop === "selector") {
12161 node2.markDirty();
12162 }
12163 return true;
12164 }
12165 };
12166 };
12167 _proto.index = function index(child) {
12168 if (typeof child === "number") return child;
12169 if (child.proxyOf) child = child.proxyOf;
12170 return this.proxyOf.nodes.indexOf(child);
12171 };
12172 _proto.insertAfter = function insertAfter(exist, add) {
12173 var existIndex = this.index(exist);
12174 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
12175 existIndex = this.index(exist);
12176 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12177 var node2 = _step.value;
12178 this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
12179 }
12180 var index2;
12181 for(var id in this.indexes){
12182 index2 = this.indexes[id];
12183 if (existIndex < index2) {
12184 this.indexes[id] = index2 + nodes.length;
12185 }
12186 }
12187 this.markDirty();
12188 return this;
12189 };
12190 _proto.insertBefore = function insertBefore(exist, add) {
12191 var existIndex = this.index(exist);
12192 var type = existIndex === 0 ? "prepend" : false;
12193 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
12194 existIndex = this.index(exist);
12195 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12196 var node2 = _step.value;
12197 this.proxyOf.nodes.splice(existIndex, 0, node2);
12198 }
12199 var index2;
12200 for(var id in this.indexes){
12201 index2 = this.indexes[id];
12202 if (existIndex <= index2) {
12203 this.indexes[id] = index2 + nodes.length;
12204 }
12205 }
12206 this.markDirty();
12207 return this;
12208 };
12209 _proto.normalize = function normalize(nodes, sample) {
12210 var _this = this;
12211 if (typeof nodes === "string") {
12212 nodes = cleanSource$1(parse$4$1(nodes).nodes);
12213 } else if (typeof nodes === "undefined") {
12214 nodes = [];
12215 } else if (Array.isArray(nodes)) {
12216 nodes = nodes.slice(0);
12217 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12218 var i2 = _step.value;
12219 if (i2.parent) i2.parent.removeChild(i2, "ignore");
12220 }
12221 } else if (nodes.type === "root" && this.type !== "document") {
12222 nodes = nodes.nodes.slice(0);
12223 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
12224 var i21 = _step1.value;
12225 if (i21.parent) i21.parent.removeChild(i21, "ignore");
12226 }
12227 } else if (nodes.type) {
12228 nodes = [
12229 nodes
12230 ];
12231 } else if (nodes.prop) {
12232 if (typeof nodes.value === "undefined") {
12233 throw new Error("Value field is missed in node creation");
12234 } else if (typeof nodes.value !== "string") {
12235 nodes.value = String(nodes.value);
12236 }
12237 nodes = [
12238 new Declaration$3$1(nodes)
12239 ];
12240 } else if (nodes.selector) {
12241 nodes = [
12242 new Rule$4$1(nodes)
12243 ];
12244 } else if (nodes.name) {
12245 nodes = [
12246 new AtRule$4$1(nodes)
12247 ];
12248 } else if (nodes.text) {
12249 nodes = [
12250 new Comment$3$1(nodes)
12251 ];
12252 } else {
12253 throw new Error("Unknown node type in node creation");
12254 }
12255 var processed = nodes.map(function(i2) {
12256 if (!i2[my$1$1]) Container.rebuild(i2);
12257 i2 = i2.proxyOf;
12258 if (i2.parent) i2.parent.removeChild(i2);
12259 if (i2[isClean$1$1]) markDirtyUp$1(i2);
12260 if (typeof i2.raws.before === "undefined") {
12261 if (sample && typeof sample.raws.before !== "undefined") {
12262 i2.raws.before = sample.raws.before.replace(/\S/g, "");
12263 }
12264 }
12265 i2.parent = _this.proxyOf;
12266 return i2;
12267 });
12268 return processed;
12269 };
12270 _proto.prepend = function prepend() {
12271 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12272 children[_key] = arguments[_key];
12273 }
12274 children = children.reverse();
12275 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
12276 var child = _step.value;
12277 var nodes = this.normalize(child, this.first, "prepend").reverse();
12278 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
12279 var node2 = _step1.value;
12280 this.proxyOf.nodes.unshift(node2);
12281 }
12282 for(var id in this.indexes){
12283 this.indexes[id] = this.indexes[id] + nodes.length;
12284 }
12285 }
12286 this.markDirty();
12287 return this;
12288 };
12289 _proto.push = function push(child) {
12290 child.parent = this;
12291 this.proxyOf.nodes.push(child);
12292 return this;
12293 };
12294 _proto.removeAll = function removeAll() {
12295 for(var _iterator = _create_for_of_iterator_helper_loose(this.proxyOf.nodes), _step; !(_step = _iterator()).done;){
12296 var node2 = _step.value;
12297 node2.parent = void 0;
12298 }
12299 this.proxyOf.nodes = [];
12300 this.markDirty();
12301 return this;
12302 };
12303 _proto.removeChild = function removeChild(child) {
12304 child = this.index(child);
12305 this.proxyOf.nodes[child].parent = void 0;
12306 this.proxyOf.nodes.splice(child, 1);
12307 var index2;
12308 for(var id in this.indexes){
12309 index2 = this.indexes[id];
12310 if (index2 >= child) {
12311 this.indexes[id] = index2 - 1;
12312 }
12313 }
12314 this.markDirty();
12315 return this;
12316 };
12317 _proto.replaceValues = function replaceValues(pattern, opts, callback) {
12318 if (!callback) {
12319 callback = opts;
12320 opts = {};
12321 }
12322 this.walkDecls(function(decl) {
12323 if (opts.props && !opts.props.includes(decl.prop)) return;
12324 if (opts.fast && !decl.value.includes(opts.fast)) return;
12325 decl.value = decl.value.replace(pattern, callback);
12326 });
12327 this.markDirty();
12328 return this;
12329 };
12330 _proto.some = function some(condition) {
12331 return this.nodes.some(condition);
12332 };
12333 _proto.walk = function walk(callback) {
12334 return this.each(function(child, i2) {
12335 var result2;
12336 try {
12337 result2 = callback(child, i2);
12338 } catch (e2) {
12339 throw child.addToError(e2);
12340 }
12341 if (result2 !== false && child.walk) {
12342 result2 = child.walk(callback);
12343 }
12344 return result2;
12345 });
12346 };
12347 _proto.walkAtRules = function walkAtRules(name, callback) {
12348 if (!callback) {
12349 callback = name;
12350 return this.walk(function(child, i2) {
12351 if (child.type === "atrule") {
12352 return callback(child, i2);
12353 }
12354 });
12355 }
12356 if (_instanceof(name, RegExp)) {
12357 return this.walk(function(child, i2) {
12358 if (child.type === "atrule" && name.test(child.name)) {
12359 return callback(child, i2);
12360 }
12361 });
12362 }
12363 return this.walk(function(child, i2) {
12364 if (child.type === "atrule" && child.name === name) {
12365 return callback(child, i2);
12366 }
12367 });
12368 };
12369 _proto.walkComments = function walkComments(callback) {
12370 return this.walk(function(child, i2) {
12371 if (child.type === "comment") {
12372 return callback(child, i2);
12373 }
12374 });
12375 };
12376 _proto.walkDecls = function walkDecls(prop, callback) {
12377 if (!callback) {
12378 callback = prop;
12379 return this.walk(function(child, i2) {
12380 if (child.type === "decl") {
12381 return callback(child, i2);
12382 }
12383 });
12384 }
12385 if (_instanceof(prop, RegExp)) {
12386 return this.walk(function(child, i2) {
12387 if (child.type === "decl" && prop.test(child.prop)) {
12388 return callback(child, i2);
12389 }
12390 });
12391 }
12392 return this.walk(function(child, i2) {
12393 if (child.type === "decl" && child.prop === prop) {
12394 return callback(child, i2);
12395 }
12396 });
12397 };
12398 _proto.walkRules = function walkRules(selector, callback) {
12399 if (!callback) {
12400 callback = selector;
12401 return this.walk(function(child, i2) {
12402 if (child.type === "rule") {
12403 return callback(child, i2);
12404 }
12405 });
12406 }
12407 if (_instanceof(selector, RegExp)) {
12408 return this.walk(function(child, i2) {
12409 if (child.type === "rule" && selector.test(child.selector)) {
12410 return callback(child, i2);
12411 }
12412 });
12413 }
12414 return this.walk(function(child, i2) {
12415 if (child.type === "rule" && child.selector === selector) {
12416 return callback(child, i2);
12417 }
12418 });
12419 };
12420 _create_class(Container, [
12421 {
12422 key: "first",
12423 get: function get() {
12424 if (!this.proxyOf.nodes) return void 0;
12425 return this.proxyOf.nodes[0];
12426 }
12427 },
12428 {
12429 key: "last",
12430 get: function get() {
12431 if (!this.proxyOf.nodes) return void 0;
12432 return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
12433 }
12434 }
12435 ]);
12436 return Container;
12437 }(Node$1$1);
12438 Container$7$1.registerParse = function(dependant) {
12439 parse$4$1 = dependant;
12440 };
12441 Container$7$1.registerRule = function(dependant) {
12442 Rule$4$1 = dependant;
12443 };
12444 Container$7$1.registerAtRule = function(dependant) {
12445 AtRule$4$1 = dependant;
12446 };
12447 Container$7$1.registerRoot = function(dependant) {
12448 Root$6$1 = dependant;
12449 };
12450 var container$1 = Container$7$1;
12451 Container$7$1.default = Container$7$1;
12452 Container$7$1.rebuild = function(node2) {
12453 if (node2.type === "atrule") {
12454 Object.setPrototypeOf(node2, AtRule$4$1.prototype);
12455 } else if (node2.type === "rule") {
12456 Object.setPrototypeOf(node2, Rule$4$1.prototype);
12457 } else if (node2.type === "decl") {
12458 Object.setPrototypeOf(node2, Declaration$3$1.prototype);
12459 } else if (node2.type === "comment") {
12460 Object.setPrototypeOf(node2, Comment$3$1.prototype);
12461 } else if (node2.type === "root") {
12462 Object.setPrototypeOf(node2, Root$6$1.prototype);
12463 }
12464 node2[my$1$1] = true;
12465 if (node2.nodes) {
12466 node2.nodes.forEach(function(child) {
12467 Container$7$1.rebuild(child);
12468 });
12469 }
12470 };
12471 var Container$6$1 = container$1;
12472 var LazyResult$4$1, Processor$3$1;
12473 var Document$3$1 = /*#__PURE__*/ function(Container$6$1) {
12474 _inherits(Document2, Container$6$1);
12475 function Document2(defaults) {
12476 var _this;
12477 _this = Container$6$1.call(this, _extends({
12478 type: "document"
12479 }, defaults)) || this;
12480 if (!_this.nodes) {
12481 _this.nodes = [];
12482 }
12483 return _this;
12484 }
12485 var _proto = Document2.prototype;
12486 _proto.toResult = function toResult(opts) {
12487 if (opts === void 0) opts = {};
12488 var lazy = new LazyResult$4$1(new Processor$3$1(), this, opts);
12489 return lazy.stringify();
12490 };
12491 return Document2;
12492 }(Container$6$1);
12493 Document$3$1.registerLazyResult = function(dependant) {
12494 LazyResult$4$1 = dependant;
12495 };
12496 Document$3$1.registerProcessor = function(dependant) {
12497 Processor$3$1 = dependant;
12498 };
12499 var document$1$1 = Document$3$1;
12500 Document$3$1.default = Document$3$1;
12501 var printed$1 = {};
12502 var warnOnce$2$1 = function warnOnce(message) {
12503 if (printed$1[message]) return;
12504 printed$1[message] = true;
12505 if (typeof console !== "undefined" && console.warn) {
12506 console.warn(message);
12507 }
12508 };
12509 var Warning$2$1 = /*#__PURE__*/ function() {
12510 function Warning(text, opts) {
12511 if (opts === void 0) opts = {};
12512 this.type = "warning";
12513 this.text = text;
12514 if (opts.node && opts.node.source) {
12515 var range = opts.node.rangeBy(opts);
12516 this.line = range.start.line;
12517 this.column = range.start.column;
12518 this.endLine = range.end.line;
12519 this.endColumn = range.end.column;
12520 }
12521 for(var opt in opts)this[opt] = opts[opt];
12522 }
12523 var _proto = Warning.prototype;
12524 _proto.toString = function toString() {
12525 if (this.node) {
12526 return this.node.error(this.text, {
12527 index: this.index,
12528 plugin: this.plugin,
12529 word: this.word
12530 }).message;
12531 }
12532 if (this.plugin) {
12533 return this.plugin + ": " + this.text;
12534 }
12535 return this.text;
12536 };
12537 return Warning;
12538 }();
12539 var warning$1 = Warning$2$1;
12540 Warning$2$1.default = Warning$2$1;
12541 var Warning$1$1 = warning$1;
12542 var Result$3$1 = /*#__PURE__*/ function() {
12543 function Result(processor2, root2, opts) {
12544 this.processor = processor2;
12545 this.messages = [];
12546 this.root = root2;
12547 this.opts = opts;
12548 this.css = void 0;
12549 this.map = void 0;
12550 }
12551 var _proto = Result.prototype;
12552 _proto.toString = function toString() {
12553 return this.css;
12554 };
12555 _proto.warn = function warn(text, opts) {
12556 if (opts === void 0) opts = {};
12557 if (!opts.plugin) {
12558 if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
12559 opts.plugin = this.lastPlugin.postcssPlugin;
12560 }
12561 }
12562 var warning2 = new Warning$1$1(text, opts);
12563 this.messages.push(warning2);
12564 return warning2;
12565 };
12566 _proto.warnings = function warnings() {
12567 return this.messages.filter(function(i2) {
12568 return i2.type === "warning";
12569 });
12570 };
12571 _create_class(Result, [
12572 {
12573 key: "content",
12574 get: function get() {
12575 return this.css;
12576 }
12577 }
12578 ]);
12579 return Result;
12580 }();
12581 var result$1 = Result$3$1;
12582 Result$3$1.default = Result$3$1;
12583 var SINGLE_QUOTE$1 = "'".charCodeAt(0);
12584 var DOUBLE_QUOTE$1 = '"'.charCodeAt(0);
12585 var BACKSLASH$1 = "\\".charCodeAt(0);
12586 var SLASH$1 = "/".charCodeAt(0);
12587 var NEWLINE$1 = "\n".charCodeAt(0);
12588 var SPACE$1 = " ".charCodeAt(0);
12589 var FEED$1 = "\f".charCodeAt(0);
12590 var TAB$1 = " ".charCodeAt(0);
12591 var CR$1 = "\r".charCodeAt(0);
12592 var OPEN_SQUARE$1 = "[".charCodeAt(0);
12593 var CLOSE_SQUARE$1 = "]".charCodeAt(0);
12594 var OPEN_PARENTHESES$1 = "(".charCodeAt(0);
12595 var CLOSE_PARENTHESES$1 = ")".charCodeAt(0);
12596 var OPEN_CURLY$1 = "{".charCodeAt(0);
12597 var CLOSE_CURLY$1 = "}".charCodeAt(0);
12598 var SEMICOLON$1 = ";".charCodeAt(0);
12599 var ASTERISK$1 = "*".charCodeAt(0);
12600 var COLON$1 = ":".charCodeAt(0);
12601 var AT$1 = "@".charCodeAt(0);
12602 var RE_AT_END$1 = /[\t\n\f\r "#'()/;[\\\]{}]/g;
12603 var RE_WORD_END$1 = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
12604 var RE_BAD_BRACKET$1 = /.[\r\n"'(/\\]/;
12605 var RE_HEX_ESCAPE$1 = /[\da-f]/i;
12606 var tokenize$1 = function tokenizer(input2, options) {
12607 if (options === void 0) options = {};
12608 var css = input2.css.valueOf();
12609 var ignore = options.ignoreErrors;
12610 var code, next, quote, content, escape;
12611 var escaped, escapePos, prev, n2, currentToken;
12612 var length = css.length;
12613 var pos = 0;
12614 var buffer = [];
12615 var returned = [];
12616 function position() {
12617 return pos;
12618 }
12619 function unclosed(what) {
12620 throw input2.error("Unclosed " + what, pos);
12621 }
12622 function endOfFile() {
12623 return returned.length === 0 && pos >= length;
12624 }
12625 function nextToken(opts) {
12626 if (returned.length) return returned.pop();
12627 if (pos >= length) return;
12628 var ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
12629 code = css.charCodeAt(pos);
12630 switch(code){
12631 case NEWLINE$1:
12632 case SPACE$1:
12633 case TAB$1:
12634 case CR$1:
12635 case FEED$1:
12636 {
12637 next = pos;
12638 do {
12639 next += 1;
12640 code = css.charCodeAt(next);
12641 }while (code === SPACE$1 || code === NEWLINE$1 || code === TAB$1 || code === CR$1 || code === FEED$1);
12642 currentToken = [
12643 "space",
12644 css.slice(pos, next)
12645 ];
12646 pos = next - 1;
12647 break;
12648 }
12649 case OPEN_SQUARE$1:
12650 case CLOSE_SQUARE$1:
12651 case OPEN_CURLY$1:
12652 case CLOSE_CURLY$1:
12653 case COLON$1:
12654 case SEMICOLON$1:
12655 case CLOSE_PARENTHESES$1:
12656 {
12657 var controlChar = String.fromCharCode(code);
12658 currentToken = [
12659 controlChar,
12660 controlChar,
12661 pos
12662 ];
12663 break;
12664 }
12665 case OPEN_PARENTHESES$1:
12666 {
12667 prev = buffer.length ? buffer.pop()[1] : "";
12668 n2 = css.charCodeAt(pos + 1);
12669 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) {
12670 next = pos;
12671 do {
12672 escaped = false;
12673 next = css.indexOf(")", next + 1);
12674 if (next === -1) {
12675 if (ignore || ignoreUnclosed) {
12676 next = pos;
12677 break;
12678 } else {
12679 unclosed("bracket");
12680 }
12681 }
12682 escapePos = next;
12683 while(css.charCodeAt(escapePos - 1) === BACKSLASH$1){
12684 escapePos -= 1;
12685 escaped = !escaped;
12686 }
12687 }while (escaped);
12688 currentToken = [
12689 "brackets",
12690 css.slice(pos, next + 1),
12691 pos,
12692 next
12693 ];
12694 pos = next;
12695 } else {
12696 next = css.indexOf(")", pos + 1);
12697 content = css.slice(pos, next + 1);
12698 if (next === -1 || RE_BAD_BRACKET$1.test(content)) {
12699 currentToken = [
12700 "(",
12701 "(",
12702 pos
12703 ];
12704 } else {
12705 currentToken = [
12706 "brackets",
12707 content,
12708 pos,
12709 next
12710 ];
12711 pos = next;
12712 }
12713 }
12714 break;
12715 }
12716 case SINGLE_QUOTE$1:
12717 case DOUBLE_QUOTE$1:
12718 {
12719 quote = code === SINGLE_QUOTE$1 ? "'" : '"';
12720 next = pos;
12721 do {
12722 escaped = false;
12723 next = css.indexOf(quote, next + 1);
12724 if (next === -1) {
12725 if (ignore || ignoreUnclosed) {
12726 next = pos + 1;
12727 break;
12728 } else {
12729 unclosed("string");
12730 }
12731 }
12732 escapePos = next;
12733 while(css.charCodeAt(escapePos - 1) === BACKSLASH$1){
12734 escapePos -= 1;
12735 escaped = !escaped;
12736 }
12737 }while (escaped);
12738 currentToken = [
12739 "string",
12740 css.slice(pos, next + 1),
12741 pos,
12742 next
12743 ];
12744 pos = next;
12745 break;
12746 }
12747 case AT$1:
12748 {
12749 RE_AT_END$1.lastIndex = pos + 1;
12750 RE_AT_END$1.test(css);
12751 if (RE_AT_END$1.lastIndex === 0) {
12752 next = css.length - 1;
12753 } else {
12754 next = RE_AT_END$1.lastIndex - 2;
12755 }
12756 currentToken = [
12757 "at-word",
12758 css.slice(pos, next + 1),
12759 pos,
12760 next
12761 ];
12762 pos = next;
12763 break;
12764 }
12765 case BACKSLASH$1:
12766 {
12767 next = pos;
12768 escape = true;
12769 while(css.charCodeAt(next + 1) === BACKSLASH$1){
12770 next += 1;
12771 escape = !escape;
12772 }
12773 code = css.charCodeAt(next + 1);
12774 if (escape && code !== SLASH$1 && code !== SPACE$1 && code !== NEWLINE$1 && code !== TAB$1 && code !== CR$1 && code !== FEED$1) {
12775 next += 1;
12776 if (RE_HEX_ESCAPE$1.test(css.charAt(next))) {
12777 while(RE_HEX_ESCAPE$1.test(css.charAt(next + 1))){
12778 next += 1;
12779 }
12780 if (css.charCodeAt(next + 1) === SPACE$1) {
12781 next += 1;
12782 }
12783 }
12784 }
12785 currentToken = [
12786 "word",
12787 css.slice(pos, next + 1),
12788 pos,
12789 next
12790 ];
12791 pos = next;
12792 break;
12793 }
12794 default:
12795 {
12796 if (code === SLASH$1 && css.charCodeAt(pos + 1) === ASTERISK$1) {
12797 next = css.indexOf("*/", pos + 2) + 1;
12798 if (next === 0) {
12799 if (ignore || ignoreUnclosed) {
12800 next = css.length;
12801 } else {
12802 unclosed("comment");
12803 }
12804 }
12805 currentToken = [
12806 "comment",
12807 css.slice(pos, next + 1),
12808 pos,
12809 next
12810 ];
12811 pos = next;
12812 } else {
12813 RE_WORD_END$1.lastIndex = pos + 1;
12814 RE_WORD_END$1.test(css);
12815 if (RE_WORD_END$1.lastIndex === 0) {
12816 next = css.length - 1;
12817 } else {
12818 next = RE_WORD_END$1.lastIndex - 2;
12819 }
12820 currentToken = [
12821 "word",
12822 css.slice(pos, next + 1),
12823 pos,
12824 next
12825 ];
12826 buffer.push(currentToken);
12827 pos = next;
12828 }
12829 break;
12830 }
12831 }
12832 pos++;
12833 return currentToken;
12834 }
12835 function back(token) {
12836 returned.push(token);
12837 }
12838 return {
12839 back: back,
12840 endOfFile: endOfFile,
12841 nextToken: nextToken,
12842 position: position
12843 };
12844 };
12845 var Container$5$1 = container$1;
12846 var AtRule$3$1 = /*#__PURE__*/ function(Container$5$1) {
12847 _inherits(AtRule, Container$5$1);
12848 function AtRule(defaults) {
12849 var _this;
12850 _this = Container$5$1.call(this, defaults) || this;
12851 _this.type = "atrule";
12852 return _this;
12853 }
12854 var _proto = AtRule.prototype;
12855 _proto.append = function append() {
12856 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12857 children[_key] = arguments[_key];
12858 }
12859 var _Container$5$1_prototype_append;
12860 if (!this.proxyOf.nodes) this.nodes = [];
12861 return (_Container$5$1_prototype_append = Container$5$1.prototype.append).call.apply(_Container$5$1_prototype_append, [].concat([
12862 this
12863 ], children));
12864 };
12865 _proto.prepend = function prepend() {
12866 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12867 children[_key] = arguments[_key];
12868 }
12869 var _Container$5$1_prototype_prepend;
12870 if (!this.proxyOf.nodes) this.nodes = [];
12871 return (_Container$5$1_prototype_prepend = Container$5$1.prototype.prepend).call.apply(_Container$5$1_prototype_prepend, [].concat([
12872 this
12873 ], children));
12874 };
12875 return AtRule;
12876 }(Container$5$1);
12877 var atRule$1 = AtRule$3$1;
12878 AtRule$3$1.default = AtRule$3$1;
12879 Container$5$1.registerAtRule(AtRule$3$1);
12880 var Container$4$1 = container$1;
12881 var LazyResult$3$1, Processor$2$1;
12882 var Root$5$1 = /*#__PURE__*/ function(Container$4$1) {
12883 _inherits(Root, Container$4$1);
12884 function Root(defaults) {
12885 var _this;
12886 _this = Container$4$1.call(this, defaults) || this;
12887 _this.type = "root";
12888 if (!_this.nodes) _this.nodes = [];
12889 return _this;
12890 }
12891 var _proto = Root.prototype;
12892 _proto.normalize = function normalize(child, sample, type) {
12893 var nodes = Container$4$1.prototype.normalize.call(this, child);
12894 if (sample) {
12895 if (type === "prepend") {
12896 if (this.nodes.length > 1) {
12897 sample.raws.before = this.nodes[1].raws.before;
12898 } else {
12899 delete sample.raws.before;
12900 }
12901 } else if (this.first !== sample) {
12902 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12903 var node2 = _step.value;
12904 node2.raws.before = sample.raws.before;
12905 }
12906 }
12907 }
12908 return nodes;
12909 };
12910 _proto.removeChild = function removeChild(child, ignore) {
12911 var index2 = this.index(child);
12912 if (!ignore && index2 === 0 && this.nodes.length > 1) {
12913 this.nodes[1].raws.before = this.nodes[index2].raws.before;
12914 }
12915 return Container$4$1.prototype.removeChild.call(this, child);
12916 };
12917 _proto.toResult = function toResult(opts) {
12918 if (opts === void 0) opts = {};
12919 var lazy = new LazyResult$3$1(new Processor$2$1(), this, opts);
12920 return lazy.stringify();
12921 };
12922 return Root;
12923 }(Container$4$1);
12924 Root$5$1.registerLazyResult = function(dependant) {
12925 LazyResult$3$1 = dependant;
12926 };
12927 Root$5$1.registerProcessor = function(dependant) {
12928 Processor$2$1 = dependant;
12929 };
12930 var root$1 = Root$5$1;
12931 Root$5$1.default = Root$5$1;
12932 Container$4$1.registerRoot(Root$5$1);
12933 var list$2$1 = {
12934 comma: function comma(string) {
12935 return list$2$1.split(string, [
12936 ","
12937 ], true);
12938 },
12939 space: function space(string) {
12940 var spaces = [
12941 " ",
12942 "\n",
12943 " "
12944 ];
12945 return list$2$1.split(string, spaces);
12946 },
12947 split: function split(string, separators, last) {
12948 var array = [];
12949 var current = "";
12950 var split = false;
12951 var func = 0;
12952 var inQuote = false;
12953 var prevQuote = "";
12954 var escape = false;
12955 for(var _iterator = _create_for_of_iterator_helper_loose(string), _step; !(_step = _iterator()).done;){
12956 var letter = _step.value;
12957 if (escape) {
12958 escape = false;
12959 } else if (letter === "\\") {
12960 escape = true;
12961 } else if (inQuote) {
12962 if (letter === prevQuote) {
12963 inQuote = false;
12964 }
12965 } else if (letter === '"' || letter === "'") {
12966 inQuote = true;
12967 prevQuote = letter;
12968 } else if (letter === "(") {
12969 func += 1;
12970 } else if (letter === ")") {
12971 if (func > 0) func -= 1;
12972 } else if (func === 0) {
12973 if (separators.includes(letter)) split = true;
12974 }
12975 if (split) {
12976 if (current !== "") array.push(current.trim());
12977 current = "";
12978 split = false;
12979 } else {
12980 current += letter;
12981 }
12982 }
12983 if (last || current !== "") array.push(current.trim());
12984 return array;
12985 }
12986 };
12987 var list_1$1 = list$2$1;
12988 list$2$1.default = list$2$1;
12989 var Container$3$1 = container$1;
12990 var list$1$1 = list_1$1;
12991 var Rule$3$1 = /*#__PURE__*/ function(Container$3$1) {
12992 _inherits(Rule, Container$3$1);
12993 function Rule(defaults) {
12994 var _this;
12995 _this = Container$3$1.call(this, defaults) || this;
12996 _this.type = "rule";
12997 if (!_this.nodes) _this.nodes = [];
12998 return _this;
12999 }
13000 _create_class(Rule, [
13001 {
13002 key: "selectors",
13003 get: function get() {
13004 return list$1$1.comma(this.selector);
13005 },
13006 set: function set(values) {
13007 var match = this.selector ? this.selector.match(/,\s*/) : null;
13008 var sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen");
13009 this.selector = values.join(sep2);
13010 }
13011 }
13012 ]);
13013 return Rule;
13014 }(Container$3$1);
13015 var rule$1 = Rule$3$1;
13016 Rule$3$1.default = Rule$3$1;
13017 Container$3$1.registerRule(Rule$3$1);
13018 var Declaration$2$1 = declaration$1;
13019 var tokenizer2$1 = tokenize$1;
13020 var Comment$2$1 = comment$1;
13021 var AtRule$2$1 = atRule$1;
13022 var Root$4$1 = root$1;
13023 var Rule$2$1 = rule$1;
13024 var SAFE_COMMENT_NEIGHBOR$1 = {
13025 empty: true,
13026 space: true
13027 };
13028 function findLastWithPosition$1(tokens) {
13029 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
13030 var token = tokens[i2];
13031 var pos = token[3] || token[2];
13032 if (pos) return pos;
13033 }
13034 }
13035 var Parser$1$1 = /*#__PURE__*/ function() {
13036 function Parser(input2) {
13037 this.input = input2;
13038 this.root = new Root$4$1();
13039 this.current = this.root;
13040 this.spaces = "";
13041 this.semicolon = false;
13042 this.createTokenizer();
13043 this.root.source = {
13044 input: input2,
13045 start: {
13046 column: 1,
13047 line: 1,
13048 offset: 0
13049 }
13050 };
13051 }
13052 var _proto = Parser.prototype;
13053 _proto.atrule = function atrule(token) {
13054 var node2 = new AtRule$2$1();
13055 node2.name = token[1].slice(1);
13056 if (node2.name === "") {
13057 this.unnamedAtrule(node2, token);
13058 }
13059 this.init(node2, token[2]);
13060 var type;
13061 var prev;
13062 var shift;
13063 var last = false;
13064 var open = false;
13065 var params = [];
13066 var brackets = [];
13067 while(!this.tokenizer.endOfFile()){
13068 token = this.tokenizer.nextToken();
13069 type = token[0];
13070 if (type === "(" || type === "[") {
13071 brackets.push(type === "(" ? ")" : "]");
13072 } else if (type === "{" && brackets.length > 0) {
13073 brackets.push("}");
13074 } else if (type === brackets[brackets.length - 1]) {
13075 brackets.pop();
13076 }
13077 if (brackets.length === 0) {
13078 if (type === ";") {
13079 node2.source.end = this.getPosition(token[2]);
13080 node2.source.end.offset++;
13081 this.semicolon = true;
13082 break;
13083 } else if (type === "{") {
13084 open = true;
13085 break;
13086 } else if (type === "}") {
13087 if (params.length > 0) {
13088 shift = params.length - 1;
13089 prev = params[shift];
13090 while(prev && prev[0] === "space"){
13091 prev = params[--shift];
13092 }
13093 if (prev) {
13094 node2.source.end = this.getPosition(prev[3] || prev[2]);
13095 node2.source.end.offset++;
13096 }
13097 }
13098 this.end(token);
13099 break;
13100 } else {
13101 params.push(token);
13102 }
13103 } else {
13104 params.push(token);
13105 }
13106 if (this.tokenizer.endOfFile()) {
13107 last = true;
13108 break;
13109 }
13110 }
13111 node2.raws.between = this.spacesAndCommentsFromEnd(params);
13112 if (params.length) {
13113 node2.raws.afterName = this.spacesAndCommentsFromStart(params);
13114 this.raw(node2, "params", params);
13115 if (last) {
13116 token = params[params.length - 1];
13117 node2.source.end = this.getPosition(token[3] || token[2]);
13118 node2.source.end.offset++;
13119 this.spaces = node2.raws.between;
13120 node2.raws.between = "";
13121 }
13122 } else {
13123 node2.raws.afterName = "";
13124 node2.params = "";
13125 }
13126 if (open) {
13127 node2.nodes = [];
13128 this.current = node2;
13129 }
13130 };
13131 _proto.checkMissedSemicolon = function checkMissedSemicolon(tokens) {
13132 var colon = this.colon(tokens);
13133 if (colon === false) return;
13134 var founded = 0;
13135 var token;
13136 for(var j = colon - 1; j >= 0; j--){
13137 token = tokens[j];
13138 if (token[0] !== "space") {
13139 founded += 1;
13140 if (founded === 2) break;
13141 }
13142 }
13143 throw this.input.error("Missed semicolon", token[0] === "word" ? token[3] + 1 : token[2]);
13144 };
13145 _proto.colon = function colon(tokens) {
13146 var brackets = 0;
13147 var token, type, prev;
13148 for(var _iterator = _create_for_of_iterator_helper_loose(tokens.entries()), _step; !(_step = _iterator()).done;){
13149 var _step_value = _step.value, i2 = _step_value[0], element = _step_value[1];
13150 token = element;
13151 type = token[0];
13152 if (type === "(") {
13153 brackets += 1;
13154 }
13155 if (type === ")") {
13156 brackets -= 1;
13157 }
13158 if (brackets === 0 && type === ":") {
13159 if (!prev) {
13160 this.doubleColon(token);
13161 } else if (prev[0] === "word" && prev[1] === "progid") {
13162 continue;
13163 } else {
13164 return i2;
13165 }
13166 }
13167 prev = token;
13168 }
13169 return false;
13170 };
13171 _proto.comment = function comment(token) {
13172 var node2 = new Comment$2$1();
13173 this.init(node2, token[2]);
13174 node2.source.end = this.getPosition(token[3] || token[2]);
13175 node2.source.end.offset++;
13176 var text = token[1].slice(2, -2);
13177 if (/^\s*$/.test(text)) {
13178 node2.text = "";
13179 node2.raws.left = text;
13180 node2.raws.right = "";
13181 } else {
13182 var match = text.match(/^(\s*)([^]*\S)(\s*)$/);
13183 node2.text = match[2];
13184 node2.raws.left = match[1];
13185 node2.raws.right = match[3];
13186 }
13187 };
13188 _proto.createTokenizer = function createTokenizer() {
13189 this.tokenizer = tokenizer2$1(this.input);
13190 };
13191 _proto.decl = function decl(tokens, customProperty) {
13192 var node2 = new Declaration$2$1();
13193 this.init(node2, tokens[0][2]);
13194 var last = tokens[tokens.length - 1];
13195 if (last[0] === ";") {
13196 this.semicolon = true;
13197 tokens.pop();
13198 }
13199 node2.source.end = this.getPosition(last[3] || last[2] || findLastWithPosition$1(tokens));
13200 node2.source.end.offset++;
13201 while(tokens[0][0] !== "word"){
13202 if (tokens.length === 1) this.unknownWord(tokens);
13203 node2.raws.before += tokens.shift()[1];
13204 }
13205 node2.source.start = this.getPosition(tokens[0][2]);
13206 node2.prop = "";
13207 while(tokens.length){
13208 var type = tokens[0][0];
13209 if (type === ":" || type === "space" || type === "comment") {
13210 break;
13211 }
13212 node2.prop += tokens.shift()[1];
13213 }
13214 node2.raws.between = "";
13215 var token;
13216 while(tokens.length){
13217 token = tokens.shift();
13218 if (token[0] === ":") {
13219 node2.raws.between += token[1];
13220 break;
13221 } else {
13222 if (token[0] === "word" && /\w/.test(token[1])) {
13223 this.unknownWord([
13224 token
13225 ]);
13226 }
13227 node2.raws.between += token[1];
13228 }
13229 }
13230 if (node2.prop[0] === "_" || node2.prop[0] === "*") {
13231 node2.raws.before += node2.prop[0];
13232 node2.prop = node2.prop.slice(1);
13233 }
13234 var firstSpaces = [];
13235 var next;
13236 while(tokens.length){
13237 next = tokens[0][0];
13238 if (next !== "space" && next !== "comment") break;
13239 firstSpaces.push(tokens.shift());
13240 }
13241 this.precheckMissedSemicolon(tokens);
13242 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
13243 token = tokens[i2];
13244 if (token[1].toLowerCase() === "!important") {
13245 node2.important = true;
13246 var string = this.stringFrom(tokens, i2);
13247 string = this.spacesFromEnd(tokens) + string;
13248 if (string !== " !important") node2.raws.important = string;
13249 break;
13250 } else if (token[1].toLowerCase() === "important") {
13251 var cache = tokens.slice(0);
13252 var str = "";
13253 for(var j = i2; j > 0; j--){
13254 var type1 = cache[j][0];
13255 if (str.trim().indexOf("!") === 0 && type1 !== "space") {
13256 break;
13257 }
13258 str = cache.pop()[1] + str;
13259 }
13260 if (str.trim().indexOf("!") === 0) {
13261 node2.important = true;
13262 node2.raws.important = str;
13263 tokens = cache;
13264 }
13265 }
13266 if (token[0] !== "space" && token[0] !== "comment") {
13267 break;
13268 }
13269 }
13270 var hasWord = tokens.some(function(i2) {
13271 return i2[0] !== "space" && i2[0] !== "comment";
13272 });
13273 if (hasWord) {
13274 node2.raws.between += firstSpaces.map(function(i2) {
13275 return i2[1];
13276 }).join("");
13277 firstSpaces = [];
13278 }
13279 this.raw(node2, "value", firstSpaces.concat(tokens), customProperty);
13280 if (node2.value.includes(":") && !customProperty) {
13281 this.checkMissedSemicolon(tokens);
13282 }
13283 };
13284 _proto.doubleColon = function doubleColon(token) {
13285 throw this.input.error("Double colon", {
13286 offset: token[2]
13287 }, {
13288 offset: token[2] + token[1].length
13289 });
13290 };
13291 _proto.emptyRule = function emptyRule(token) {
13292 var node2 = new Rule$2$1();
13293 this.init(node2, token[2]);
13294 node2.selector = "";
13295 node2.raws.between = "";
13296 this.current = node2;
13297 };
13298 _proto.end = function end(token) {
13299 if (this.current.nodes && this.current.nodes.length) {
13300 this.current.raws.semicolon = this.semicolon;
13301 }
13302 this.semicolon = false;
13303 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
13304 this.spaces = "";
13305 if (this.current.parent) {
13306 this.current.source.end = this.getPosition(token[2]);
13307 this.current.source.end.offset++;
13308 this.current = this.current.parent;
13309 } else {
13310 this.unexpectedClose(token);
13311 }
13312 };
13313 _proto.endFile = function endFile() {
13314 if (this.current.parent) this.unclosedBlock();
13315 if (this.current.nodes && this.current.nodes.length) {
13316 this.current.raws.semicolon = this.semicolon;
13317 }
13318 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
13319 this.root.source.end = this.getPosition(this.tokenizer.position());
13320 };
13321 _proto.freeSemicolon = function freeSemicolon(token) {
13322 this.spaces += token[1];
13323 if (this.current.nodes) {
13324 var prev = this.current.nodes[this.current.nodes.length - 1];
13325 if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
13326 prev.raws.ownSemicolon = this.spaces;
13327 this.spaces = "";
13328 }
13329 }
13330 };
13331 // Helpers
13332 _proto.getPosition = function getPosition(offset) {
13333 var pos = this.input.fromOffset(offset);
13334 return {
13335 column: pos.col,
13336 line: pos.line,
13337 offset: offset
13338 };
13339 };
13340 _proto.init = function init(node2, offset) {
13341 this.current.push(node2);
13342 node2.source = {
13343 input: this.input,
13344 start: this.getPosition(offset)
13345 };
13346 node2.raws.before = this.spaces;
13347 this.spaces = "";
13348 if (node2.type !== "comment") this.semicolon = false;
13349 };
13350 _proto.other = function other(start) {
13351 var end = false;
13352 var type = null;
13353 var colon = false;
13354 var bracket = null;
13355 var brackets = [];
13356 var customProperty = start[1].startsWith("--");
13357 var tokens = [];
13358 var token = start;
13359 while(token){
13360 type = token[0];
13361 tokens.push(token);
13362 if (type === "(" || type === "[") {
13363 if (!bracket) bracket = token;
13364 brackets.push(type === "(" ? ")" : "]");
13365 } else if (customProperty && colon && type === "{") {
13366 if (!bracket) bracket = token;
13367 brackets.push("}");
13368 } else if (brackets.length === 0) {
13369 if (type === ";") {
13370 if (colon) {
13371 this.decl(tokens, customProperty);
13372 return;
13373 } else {
13374 break;
13375 }
13376 } else if (type === "{") {
13377 this.rule(tokens);
13378 return;
13379 } else if (type === "}") {
13380 this.tokenizer.back(tokens.pop());
13381 end = true;
13382 break;
13383 } else if (type === ":") {
13384 colon = true;
13385 }
13386 } else if (type === brackets[brackets.length - 1]) {
13387 brackets.pop();
13388 if (brackets.length === 0) bracket = null;
13389 }
13390 token = this.tokenizer.nextToken();
13391 }
13392 if (this.tokenizer.endOfFile()) end = true;
13393 if (brackets.length > 0) this.unclosedBracket(bracket);
13394 if (end && colon) {
13395 if (!customProperty) {
13396 while(tokens.length){
13397 token = tokens[tokens.length - 1][0];
13398 if (token !== "space" && token !== "comment") break;
13399 this.tokenizer.back(tokens.pop());
13400 }
13401 }
13402 this.decl(tokens, customProperty);
13403 } else {
13404 this.unknownWord(tokens);
13405 }
13406 };
13407 _proto.parse = function parse() {
13408 var token;
13409 while(!this.tokenizer.endOfFile()){
13410 token = this.tokenizer.nextToken();
13411 switch(token[0]){
13412 case "space":
13413 this.spaces += token[1];
13414 break;
13415 case ";":
13416 this.freeSemicolon(token);
13417 break;
13418 case "}":
13419 this.end(token);
13420 break;
13421 case "comment":
13422 this.comment(token);
13423 break;
13424 case "at-word":
13425 this.atrule(token);
13426 break;
13427 case "{":
13428 this.emptyRule(token);
13429 break;
13430 default:
13431 this.other(token);
13432 break;
13433 }
13434 }
13435 this.endFile();
13436 };
13437 _proto.precheckMissedSemicolon = function precheckMissedSemicolon() {};
13438 _proto.raw = function raw(node2, prop, tokens, customProperty) {
13439 var token, type;
13440 var length = tokens.length;
13441 var value = "";
13442 var clean = true;
13443 var next, prev;
13444 for(var i2 = 0; i2 < length; i2 += 1){
13445 token = tokens[i2];
13446 type = token[0];
13447 if (type === "space" && i2 === length - 1 && !customProperty) {
13448 clean = false;
13449 } else if (type === "comment") {
13450 prev = tokens[i2 - 1] ? tokens[i2 - 1][0] : "empty";
13451 next = tokens[i2 + 1] ? tokens[i2 + 1][0] : "empty";
13452 if (!SAFE_COMMENT_NEIGHBOR$1[prev] && !SAFE_COMMENT_NEIGHBOR$1[next]) {
13453 if (value.slice(-1) === ",") {
13454 clean = false;
13455 } else {
13456 value += token[1];
13457 }
13458 } else {
13459 clean = false;
13460 }
13461 } else {
13462 value += token[1];
13463 }
13464 }
13465 if (!clean) {
13466 var raw = tokens.reduce(function(all, i2) {
13467 return all + i2[1];
13468 }, "");
13469 node2.raws[prop] = {
13470 raw: raw,
13471 value: value
13472 };
13473 }
13474 node2[prop] = value;
13475 };
13476 _proto.rule = function rule(tokens) {
13477 tokens.pop();
13478 var node2 = new Rule$2$1();
13479 this.init(node2, tokens[0][2]);
13480 node2.raws.between = this.spacesAndCommentsFromEnd(tokens);
13481 this.raw(node2, "selector", tokens);
13482 this.current = node2;
13483 };
13484 _proto.spacesAndCommentsFromEnd = function spacesAndCommentsFromEnd(tokens) {
13485 var lastTokenType;
13486 var spaces = "";
13487 while(tokens.length){
13488 lastTokenType = tokens[tokens.length - 1][0];
13489 if (lastTokenType !== "space" && lastTokenType !== "comment") break;
13490 spaces = tokens.pop()[1] + spaces;
13491 }
13492 return spaces;
13493 };
13494 // Errors
13495 _proto.spacesAndCommentsFromStart = function spacesAndCommentsFromStart(tokens) {
13496 var next;
13497 var spaces = "";
13498 while(tokens.length){
13499 next = tokens[0][0];
13500 if (next !== "space" && next !== "comment") break;
13501 spaces += tokens.shift()[1];
13502 }
13503 return spaces;
13504 };
13505 _proto.spacesFromEnd = function spacesFromEnd(tokens) {
13506 var lastTokenType;
13507 var spaces = "";
13508 while(tokens.length){
13509 lastTokenType = tokens[tokens.length - 1][0];
13510 if (lastTokenType !== "space") break;
13511 spaces = tokens.pop()[1] + spaces;
13512 }
13513 return spaces;
13514 };
13515 _proto.stringFrom = function stringFrom(tokens, from) {
13516 var result2 = "";
13517 for(var i2 = from; i2 < tokens.length; i2++){
13518 result2 += tokens[i2][1];
13519 }
13520 tokens.splice(from, tokens.length - from);
13521 return result2;
13522 };
13523 _proto.unclosedBlock = function unclosedBlock() {
13524 var pos = this.current.source.start;
13525 throw this.input.error("Unclosed block", pos.line, pos.column);
13526 };
13527 _proto.unclosedBracket = function unclosedBracket(bracket) {
13528 throw this.input.error("Unclosed bracket", {
13529 offset: bracket[2]
13530 }, {
13531 offset: bracket[2] + 1
13532 });
13533 };
13534 _proto.unexpectedClose = function unexpectedClose(token) {
13535 throw this.input.error("Unexpected }", {
13536 offset: token[2]
13537 }, {
13538 offset: token[2] + 1
13539 });
13540 };
13541 _proto.unknownWord = function unknownWord(tokens) {
13542 throw this.input.error("Unknown word", {
13543 offset: tokens[0][2]
13544 }, {
13545 offset: tokens[0][2] + tokens[0][1].length
13546 });
13547 };
13548 _proto.unnamedAtrule = function unnamedAtrule(node2, token) {
13549 throw this.input.error("At-rule without name", {
13550 offset: token[2]
13551 }, {
13552 offset: token[2] + token[1].length
13553 });
13554 };
13555 return Parser;
13556 }();
13557 var parser$1 = Parser$1$1;
13558 var Container$2$1 = container$1;
13559 var Parser2$1 = parser$1;
13560 var Input$2$1 = input$1;
13561 function parse$3$1(css, opts) {
13562 var input2 = new Input$2$1(css, opts);
13563 var parser2 = new Parser2$1(input2);
13564 try {
13565 parser2.parse();
13566 } catch (e2) {
13567 if (true) {
13568 if (e2.name === "CssSyntaxError" && opts && opts.from) {
13569 if (/\.scss$/i.test(opts.from)) {
13570 e2.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser";
13571 } else if (/\.sass/i.test(opts.from)) {
13572 e2.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser";
13573 } else if (/\.less$/i.test(opts.from)) {
13574 e2.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser";
13575 }
13576 }
13577 }
13578 throw e2;
13579 }
13580 return parser2.root;
13581 }
13582 var parse_1$1 = parse$3$1;
13583 parse$3$1.default = parse$3$1;
13584 Container$2$1.registerParse(parse$3$1);
13585 var isClean$3 = symbols$1.isClean, my$3 = symbols$1.my;
13586 var MapGenerator$1$1 = mapGenerator$1;
13587 var stringify$2$1 = stringify_1$1;
13588 var Container$1$1 = container$1;
13589 var Document$2$1 = document$1$1;
13590 var warnOnce$1$1 = warnOnce$2$1;
13591 var Result$2$1 = result$1;
13592 var parse$2$1 = parse_1$1;
13593 var Root$3$1 = root$1;
13594 var TYPE_TO_CLASS_NAME$1 = {
13595 atrule: "AtRule",
13596 comment: "Comment",
13597 decl: "Declaration",
13598 document: "Document",
13599 root: "Root",
13600 rule: "Rule"
13601 };
13602 var PLUGIN_PROPS$1 = {
13603 AtRule: true,
13604 AtRuleExit: true,
13605 Comment: true,
13606 CommentExit: true,
13607 Declaration: true,
13608 DeclarationExit: true,
13609 Document: true,
13610 DocumentExit: true,
13611 Once: true,
13612 OnceExit: true,
13613 postcssPlugin: true,
13614 prepare: true,
13615 Root: true,
13616 RootExit: true,
13617 Rule: true,
13618 RuleExit: true
13619 };
13620 var NOT_VISITORS$1 = {
13621 Once: true,
13622 postcssPlugin: true,
13623 prepare: true
13624 };
13625 var CHILDREN$1 = 0;
13626 function isPromise$1(obj) {
13627 return (typeof obj === "undefined" ? "undefined" : _type_of(obj)) === "object" && typeof obj.then === "function";
13628 }
13629 function getEvents$1(node2) {
13630 var key = false;
13631 var type = TYPE_TO_CLASS_NAME$1[node2.type];
13632 if (node2.type === "decl") {
13633 key = node2.prop.toLowerCase();
13634 } else if (node2.type === "atrule") {
13635 key = node2.name.toLowerCase();
13636 }
13637 if (key && node2.append) {
13638 return [
13639 type,
13640 type + "-" + key,
13641 CHILDREN$1,
13642 type + "Exit",
13643 type + "Exit-" + key
13644 ];
13645 } else if (key) {
13646 return [
13647 type,
13648 type + "-" + key,
13649 type + "Exit",
13650 type + "Exit-" + key
13651 ];
13652 } else if (node2.append) {
13653 return [
13654 type,
13655 CHILDREN$1,
13656 type + "Exit"
13657 ];
13658 } else {
13659 return [
13660 type,
13661 type + "Exit"
13662 ];
13663 }
13664 }
13665 function toStack$1(node2) {
13666 var events;
13667 if (node2.type === "document") {
13668 events = [
13669 "Document",
13670 CHILDREN$1,
13671 "DocumentExit"
13672 ];
13673 } else if (node2.type === "root") {
13674 events = [
13675 "Root",
13676 CHILDREN$1,
13677 "RootExit"
13678 ];
13679 } else {
13680 events = getEvents$1(node2);
13681 }
13682 return {
13683 eventIndex: 0,
13684 events: events,
13685 iterator: 0,
13686 node: node2,
13687 visitorIndex: 0,
13688 visitors: []
13689 };
13690 }
13691 function cleanMarks$1(node2) {
13692 node2[isClean$3] = false;
13693 if (node2.nodes) node2.nodes.forEach(function(i2) {
13694 return cleanMarks$1(i2);
13695 });
13696 return node2;
13697 }
13698 var postcss$2$1 = {};
13699 var LazyResult$2$1 = /*#__PURE__*/ function() {
13700 function LazyResult(processor2, css, opts) {
13701 var _this = this;
13702 this.stringified = false;
13703 this.processed = false;
13704 var root2;
13705 if ((typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && css !== null && (css.type === "root" || css.type === "document")) {
13706 root2 = cleanMarks$1(css);
13707 } else if (_instanceof(css, LazyResult) || _instanceof(css, Result$2$1)) {
13708 root2 = cleanMarks$1(css.root);
13709 if (css.map) {
13710 if (typeof opts.map === "undefined") opts.map = {};
13711 if (!opts.map.inline) opts.map.inline = false;
13712 opts.map.prev = css.map;
13713 }
13714 } else {
13715 var parser2 = parse$2$1;
13716 if (opts.syntax) parser2 = opts.syntax.parse;
13717 if (opts.parser) parser2 = opts.parser;
13718 if (parser2.parse) parser2 = parser2.parse;
13719 try {
13720 root2 = parser2(css, opts);
13721 } catch (error) {
13722 this.processed = true;
13723 this.error = error;
13724 }
13725 if (root2 && !root2[my$3]) {
13726 Container$1$1.rebuild(root2);
13727 }
13728 }
13729 this.result = new Result$2$1(processor2, root2, opts);
13730 this.helpers = _extends({}, postcss$2$1, {
13731 postcss: postcss$2$1,
13732 result: this.result
13733 });
13734 this.plugins = this.processor.plugins.map(function(plugin22) {
13735 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.prepare) {
13736 return _extends({}, plugin22, plugin22.prepare(_this.result));
13737 } else {
13738 return plugin22;
13739 }
13740 });
13741 }
13742 var _proto = LazyResult.prototype;
13743 _proto.async = function async() {
13744 if (this.error) return Promise.reject(this.error);
13745 if (this.processed) return Promise.resolve(this.result);
13746 if (!this.processing) {
13747 this.processing = this.runAsync();
13748 }
13749 return this.processing;
13750 };
13751 _proto.catch = function _catch(onRejected) {
13752 return this.async().catch(onRejected);
13753 };
13754 _proto.finally = function _finally(onFinally) {
13755 return this.async().then(onFinally, onFinally);
13756 };
13757 _proto.getAsyncError = function getAsyncError() {
13758 throw new Error("Use process(css).then(cb) to work with async plugins");
13759 };
13760 _proto.handleError = function handleError(error, node2) {
13761 var plugin22 = this.result.lastPlugin;
13762 try {
13763 if (node2) node2.addToError(error);
13764 this.error = error;
13765 if (error.name === "CssSyntaxError" && !error.plugin) {
13766 error.plugin = plugin22.postcssPlugin;
13767 error.setMessage();
13768 } else if (plugin22.postcssVersion) {
13769 if (true) {
13770 var pluginName = plugin22.postcssPlugin;
13771 var pluginVer = plugin22.postcssVersion;
13772 var runtimeVer = this.result.processor.version;
13773 var a2 = pluginVer.split(".");
13774 var b = runtimeVer.split(".");
13775 if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) {
13776 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.");
13777 }
13778 }
13779 }
13780 } catch (err) {
13781 if (console && console.error) console.error(err);
13782 }
13783 return error;
13784 };
13785 _proto.prepareVisitors = function prepareVisitors() {
13786 var _this = this;
13787 this.listeners = {};
13788 var add = function(plugin22, type, cb) {
13789 if (!_this.listeners[type]) _this.listeners[type] = [];
13790 _this.listeners[type].push([
13791 plugin22,
13792 cb
13793 ]);
13794 };
13795 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
13796 var plugin22 = _step.value;
13797 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object") {
13798 for(var event in plugin22){
13799 if (!PLUGIN_PROPS$1[event] && /^[A-Z]/.test(event)) {
13800 throw new Error("Unknown event " + event + " in " + plugin22.postcssPlugin + ". Try to update PostCSS (" + this.processor.version + " now).");
13801 }
13802 if (!NOT_VISITORS$1[event]) {
13803 if (_type_of(plugin22[event]) === "object") {
13804 for(var filter in plugin22[event]){
13805 if (filter === "*") {
13806 add(plugin22, event, plugin22[event][filter]);
13807 } else {
13808 add(plugin22, event + "-" + filter.toLowerCase(), plugin22[event][filter]);
13809 }
13810 }
13811 } else if (typeof plugin22[event] === "function") {
13812 add(plugin22, event, plugin22[event]);
13813 }
13814 }
13815 }
13816 }
13817 }
13818 this.hasListener = Object.keys(this.listeners).length > 0;
13819 };
13820 _proto.runAsync = function runAsync() {
13821 var _this = this;
13822 return _async_to_generator(function() {
13823 var i2, plugin22, promise, error, root2, stack, promise1, e2, node2, _loop, _iterator, _step;
13824 return _ts_generator(this, function(_state) {
13825 switch(_state.label){
13826 case 0:
13827 _this.plugin = 0;
13828 i2 = 0;
13829 _state.label = 1;
13830 case 1:
13831 if (!(i2 < _this.plugins.length)) return [
13832 3,
13833 6
13834 ];
13835 plugin22 = _this.plugins[i2];
13836 promise = _this.runOnRoot(plugin22);
13837 if (!isPromise$1(promise)) return [
13838 3,
13839 5
13840 ];
13841 _state.label = 2;
13842 case 2:
13843 _state.trys.push([
13844 2,
13845 4,
13846 ,
13847 5
13848 ]);
13849 return [
13850 4,
13851 promise
13852 ];
13853 case 3:
13854 _state.sent();
13855 return [
13856 3,
13857 5
13858 ];
13859 case 4:
13860 error = _state.sent();
13861 throw _this.handleError(error);
13862 case 5:
13863 i2++;
13864 return [
13865 3,
13866 1
13867 ];
13868 case 6:
13869 _this.prepareVisitors();
13870 if (!_this.hasListener) return [
13871 3,
13872 18
13873 ];
13874 root2 = _this.result.root;
13875 _state.label = 7;
13876 case 7:
13877 if (!!root2[isClean$3]) return [
13878 3,
13879 14
13880 ];
13881 root2[isClean$3] = true;
13882 stack = [
13883 toStack$1(root2)
13884 ];
13885 _state.label = 8;
13886 case 8:
13887 if (!(stack.length > 0)) return [
13888 3,
13889 13
13890 ];
13891 promise1 = _this.visitTick(stack);
13892 if (!isPromise$1(promise1)) return [
13893 3,
13894 12
13895 ];
13896 _state.label = 9;
13897 case 9:
13898 _state.trys.push([
13899 9,
13900 11,
13901 ,
13902 12
13903 ]);
13904 return [
13905 4,
13906 promise1
13907 ];
13908 case 10:
13909 _state.sent();
13910 return [
13911 3,
13912 12
13913 ];
13914 case 11:
13915 e2 = _state.sent();
13916 node2 = stack[stack.length - 1].node;
13917 throw _this.handleError(e2, node2);
13918 case 12:
13919 return [
13920 3,
13921 8
13922 ];
13923 case 13:
13924 return [
13925 3,
13926 7
13927 ];
13928 case 14:
13929 if (!_this.listeners.OnceExit) return [
13930 3,
13931 18
13932 ];
13933 _loop = function() {
13934 var _step_value, plugin22, visitor, roots, e2;
13935 return _ts_generator(this, function(_state) {
13936 switch(_state.label){
13937 case 0:
13938 _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
13939 _this.result.lastPlugin = plugin22;
13940 _state.label = 1;
13941 case 1:
13942 _state.trys.push([
13943 1,
13944 6,
13945 ,
13946 7
13947 ]);
13948 if (!(root2.type === "document")) return [
13949 3,
13950 3
13951 ];
13952 roots = root2.nodes.map(function(subRoot) {
13953 return visitor(subRoot, _this.helpers);
13954 });
13955 return [
13956 4,
13957 Promise.all(roots)
13958 ];
13959 case 2:
13960 _state.sent();
13961 return [
13962 3,
13963 5
13964 ];
13965 case 3:
13966 return [
13967 4,
13968 visitor(root2, _this.helpers)
13969 ];
13970 case 4:
13971 _state.sent();
13972 _state.label = 5;
13973 case 5:
13974 return [
13975 3,
13976 7
13977 ];
13978 case 6:
13979 e2 = _state.sent();
13980 throw _this.handleError(e2);
13981 case 7:
13982 return [
13983 2
13984 ];
13985 }
13986 });
13987 };
13988 _iterator = _create_for_of_iterator_helper_loose(_this.listeners.OnceExit);
13989 _state.label = 15;
13990 case 15:
13991 if (!!(_step = _iterator()).done) return [
13992 3,
13993 18
13994 ];
13995 return [
13996 5,
13997 _ts_values(_loop())
13998 ];
13999 case 16:
14000 _state.sent();
14001 _state.label = 17;
14002 case 17:
14003 return [
14004 3,
14005 15
14006 ];
14007 case 18:
14008 _this.processed = true;
14009 return [
14010 2,
14011 _this.stringify()
14012 ];
14013 }
14014 });
14015 })();
14016 };
14017 _proto.runOnRoot = function runOnRoot(plugin22) {
14018 var _this = this;
14019 this.result.lastPlugin = plugin22;
14020 try {
14021 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.Once) {
14022 if (this.result.root.type === "document") {
14023 var roots = this.result.root.nodes.map(function(root2) {
14024 return plugin22.Once(root2, _this.helpers);
14025 });
14026 if (isPromise$1(roots[0])) {
14027 return Promise.all(roots);
14028 }
14029 return roots;
14030 }
14031 return plugin22.Once(this.result.root, this.helpers);
14032 } else if (typeof plugin22 === "function") {
14033 return plugin22(this.result.root, this.result);
14034 }
14035 } catch (error) {
14036 throw this.handleError(error);
14037 }
14038 };
14039 _proto.stringify = function stringify() {
14040 if (this.error) throw this.error;
14041 if (this.stringified) return this.result;
14042 this.stringified = true;
14043 this.sync();
14044 var opts = this.result.opts;
14045 var str = stringify$2$1;
14046 if (opts.syntax) str = opts.syntax.stringify;
14047 if (opts.stringifier) str = opts.stringifier;
14048 if (str.stringify) str = str.stringify;
14049 var map = new MapGenerator$1$1(str, this.result.root, this.result.opts);
14050 var data = map.generate();
14051 this.result.css = data[0];
14052 this.result.map = data[1];
14053 return this.result;
14054 };
14055 _proto.sync = function sync() {
14056 if (this.error) throw this.error;
14057 if (this.processed) return this.result;
14058 this.processed = true;
14059 if (this.processing) {
14060 throw this.getAsyncError();
14061 }
14062 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
14063 var plugin22 = _step.value;
14064 var promise = this.runOnRoot(plugin22);
14065 if (isPromise$1(promise)) {
14066 throw this.getAsyncError();
14067 }
14068 }
14069 this.prepareVisitors();
14070 if (this.hasListener) {
14071 var root2 = this.result.root;
14072 while(!root2[isClean$3]){
14073 root2[isClean$3] = true;
14074 this.walkSync(root2);
14075 }
14076 if (this.listeners.OnceExit) {
14077 if (root2.type === "document") {
14078 for(var _iterator1 = _create_for_of_iterator_helper_loose(root2.nodes), _step1; !(_step1 = _iterator1()).done;){
14079 var subRoot = _step1.value;
14080 this.visitSync(this.listeners.OnceExit, subRoot);
14081 }
14082 } else {
14083 this.visitSync(this.listeners.OnceExit, root2);
14084 }
14085 }
14086 }
14087 return this.result;
14088 };
14089 _proto.then = function then(onFulfilled, onRejected) {
14090 if (true) {
14091 if (!("from" in this.opts)) {
14092 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.");
14093 }
14094 }
14095 return this.async().then(onFulfilled, onRejected);
14096 };
14097 _proto.toString = function toString() {
14098 return this.css;
14099 };
14100 _proto.visitSync = function visitSync(visitors, node2) {
14101 for(var _iterator = _create_for_of_iterator_helper_loose(visitors), _step; !(_step = _iterator()).done;){
14102 var _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
14103 this.result.lastPlugin = plugin22;
14104 var promise = void 0;
14105 try {
14106 promise = visitor(node2, this.helpers);
14107 } catch (e2) {
14108 throw this.handleError(e2, node2.proxyOf);
14109 }
14110 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
14111 return true;
14112 }
14113 if (isPromise$1(promise)) {
14114 throw this.getAsyncError();
14115 }
14116 }
14117 };
14118 _proto.visitTick = function visitTick(stack) {
14119 var visit2 = stack[stack.length - 1];
14120 var node2 = visit2.node, visitors = visit2.visitors;
14121 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
14122 stack.pop();
14123 return;
14124 }
14125 if (visitors.length > 0 && visit2.visitorIndex < visitors.length) {
14126 var _visitors_visit2_visitorIndex = visitors[visit2.visitorIndex], plugin22 = _visitors_visit2_visitorIndex[0], visitor = _visitors_visit2_visitorIndex[1];
14127 visit2.visitorIndex += 1;
14128 if (visit2.visitorIndex === visitors.length) {
14129 visit2.visitors = [];
14130 visit2.visitorIndex = 0;
14131 }
14132 this.result.lastPlugin = plugin22;
14133 try {
14134 return visitor(node2.toProxy(), this.helpers);
14135 } catch (e2) {
14136 throw this.handleError(e2, node2);
14137 }
14138 }
14139 if (visit2.iterator !== 0) {
14140 var iterator = visit2.iterator;
14141 var child;
14142 while(child = node2.nodes[node2.indexes[iterator]]){
14143 node2.indexes[iterator] += 1;
14144 if (!child[isClean$3]) {
14145 child[isClean$3] = true;
14146 stack.push(toStack$1(child));
14147 return;
14148 }
14149 }
14150 visit2.iterator = 0;
14151 delete node2.indexes[iterator];
14152 }
14153 var events = visit2.events;
14154 while(visit2.eventIndex < events.length){
14155 var event = events[visit2.eventIndex];
14156 visit2.eventIndex += 1;
14157 if (event === CHILDREN$1) {
14158 if (node2.nodes && node2.nodes.length) {
14159 node2[isClean$3] = true;
14160 visit2.iterator = node2.getIterator();
14161 }
14162 return;
14163 } else if (this.listeners[event]) {
14164 visit2.visitors = this.listeners[event];
14165 return;
14166 }
14167 }
14168 stack.pop();
14169 };
14170 _proto.walkSync = function walkSync(node2) {
14171 var _this = this;
14172 node2[isClean$3] = true;
14173 var events = getEvents$1(node2);
14174 for(var _iterator = _create_for_of_iterator_helper_loose(events), _step; !(_step = _iterator()).done;){
14175 var event = _step.value;
14176 if (event === CHILDREN$1) {
14177 if (node2.nodes) {
14178 node2.each(function(child) {
14179 if (!child[isClean$3]) _this.walkSync(child);
14180 });
14181 }
14182 } else {
14183 var visitors = this.listeners[event];
14184 if (visitors) {
14185 if (this.visitSync(visitors, node2.toProxy())) return;
14186 }
14187 }
14188 }
14189 };
14190 _proto.warnings = function warnings() {
14191 return this.sync().warnings();
14192 };
14193 _create_class(LazyResult, [
14194 {
14195 key: "content",
14196 get: function get() {
14197 return this.stringify().content;
14198 }
14199 },
14200 {
14201 key: "css",
14202 get: function get() {
14203 return this.stringify().css;
14204 }
14205 },
14206 {
14207 key: "map",
14208 get: function get() {
14209 return this.stringify().map;
14210 }
14211 },
14212 {
14213 key: "messages",
14214 get: function get() {
14215 return this.sync().messages;
14216 }
14217 },
14218 {
14219 key: "opts",
14220 get: function get() {
14221 return this.result.opts;
14222 }
14223 },
14224 {
14225 key: "processor",
14226 get: function get() {
14227 return this.result.processor;
14228 }
14229 },
14230 {
14231 key: "root",
14232 get: function get() {
14233 return this.sync().root;
14234 }
14235 },
14236 {
14237 key: Symbol.toStringTag,
14238 get: function get() {
14239 return "LazyResult";
14240 }
14241 }
14242 ]);
14243 return LazyResult;
14244 }();
14245 LazyResult$2$1.registerPostcss = function(dependant) {
14246 postcss$2$1 = dependant;
14247 };
14248 var lazyResult$1 = LazyResult$2$1;
14249 LazyResult$2$1.default = LazyResult$2$1;
14250 Root$3$1.registerLazyResult(LazyResult$2$1);
14251 Document$2$1.registerLazyResult(LazyResult$2$1);
14252 var MapGenerator2$1 = mapGenerator$1;
14253 var stringify$1$1 = stringify_1$1;
14254 var warnOnce2$1 = warnOnce$2$1;
14255 var parse$1$1 = parse_1$1;
14256 var Result$1$1 = result$1;
14257 var NoWorkResult$1$1 = /*#__PURE__*/ function() {
14258 function NoWorkResult(processor2, css, opts) {
14259 css = css.toString();
14260 this.stringified = false;
14261 this._processor = processor2;
14262 this._css = css;
14263 this._opts = opts;
14264 this._map = void 0;
14265 var root2;
14266 var str = stringify$1$1;
14267 this.result = new Result$1$1(this._processor, root2, this._opts);
14268 this.result.css = css;
14269 var self = this;
14270 Object.defineProperty(this.result, "root", {
14271 get: function get() {
14272 return self.root;
14273 }
14274 });
14275 var map = new MapGenerator2$1(str, root2, this._opts, css);
14276 if (map.isMap()) {
14277 var _map_generate = map.generate(), generatedCSS = _map_generate[0], generatedMap = _map_generate[1];
14278 if (generatedCSS) {
14279 this.result.css = generatedCSS;
14280 }
14281 if (generatedMap) {
14282 this.result.map = generatedMap;
14283 }
14284 } else {
14285 map.clearAnnotation();
14286 this.result.css = map.css;
14287 }
14288 }
14289 var _proto = NoWorkResult.prototype;
14290 _proto.async = function async() {
14291 if (this.error) return Promise.reject(this.error);
14292 return Promise.resolve(this.result);
14293 };
14294 _proto.catch = function _catch(onRejected) {
14295 return this.async().catch(onRejected);
14296 };
14297 _proto.finally = function _finally(onFinally) {
14298 return this.async().then(onFinally, onFinally);
14299 };
14300 _proto.sync = function sync() {
14301 if (this.error) throw this.error;
14302 return this.result;
14303 };
14304 _proto.then = function then(onFulfilled, onRejected) {
14305 if (true) {
14306 if (!("from" in this._opts)) {
14307 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.");
14308 }
14309 }
14310 return this.async().then(onFulfilled, onRejected);
14311 };
14312 _proto.toString = function toString() {
14313 return this._css;
14314 };
14315 _proto.warnings = function warnings() {
14316 return [];
14317 };
14318 _create_class(NoWorkResult, [
14319 {
14320 key: "content",
14321 get: function get() {
14322 return this.result.css;
14323 }
14324 },
14325 {
14326 key: "css",
14327 get: function get() {
14328 return this.result.css;
14329 }
14330 },
14331 {
14332 key: "map",
14333 get: function get() {
14334 return this.result.map;
14335 }
14336 },
14337 {
14338 key: "messages",
14339 get: function get() {
14340 return [];
14341 }
14342 },
14343 {
14344 key: "opts",
14345 get: function get() {
14346 return this.result.opts;
14347 }
14348 },
14349 {
14350 key: "processor",
14351 get: function get() {
14352 return this.result.processor;
14353 }
14354 },
14355 {
14356 key: "root",
14357 get: function get() {
14358 if (this._root) {
14359 return this._root;
14360 }
14361 var root2;
14362 var parser2 = parse$1$1;
14363 try {
14364 root2 = parser2(this._css, this._opts);
14365 } catch (error) {
14366 this.error = error;
14367 }
14368 if (this.error) {
14369 throw this.error;
14370 } else {
14371 this._root = root2;
14372 return root2;
14373 }
14374 }
14375 },
14376 {
14377 key: Symbol.toStringTag,
14378 get: function get() {
14379 return "NoWorkResult";
14380 }
14381 }
14382 ]);
14383 return NoWorkResult;
14384 }();
14385 var noWorkResult$1 = NoWorkResult$1$1;
14386 NoWorkResult$1$1.default = NoWorkResult$1$1;
14387 var NoWorkResult2$1 = noWorkResult$1;
14388 var LazyResult$1$1 = lazyResult$1;
14389 var Document$1$1 = document$1$1;
14390 var Root$2$1 = root$1;
14391 var Processor$1$1 = /*#__PURE__*/ function() {
14392 function Processor(plugins) {
14393 if (plugins === void 0) plugins = [];
14394 this.version = "8.4.38";
14395 this.plugins = this.normalize(plugins);
14396 }
14397 var _proto = Processor.prototype;
14398 _proto.normalize = function normalize(plugins) {
14399 var normalized = [];
14400 for(var _iterator = _create_for_of_iterator_helper_loose(plugins), _step; !(_step = _iterator()).done;){
14401 var i2 = _step.value;
14402 if (i2.postcss === true) {
14403 i2 = i2();
14404 } else if (i2.postcss) {
14405 i2 = i2.postcss;
14406 }
14407 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && Array.isArray(i2.plugins)) {
14408 normalized = normalized.concat(i2.plugins);
14409 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.postcssPlugin) {
14410 normalized.push(i2);
14411 } else if (typeof i2 === "function") {
14412 normalized.push(i2);
14413 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && (i2.parse || i2.stringify)) {
14414 if (true) {
14415 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.");
14416 }
14417 } else {
14418 throw new Error(i2 + " is not a PostCSS plugin");
14419 }
14420 }
14421 return normalized;
14422 };
14423 _proto.process = function process1(css, opts) {
14424 if (opts === void 0) opts = {};
14425 if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) {
14426 return new NoWorkResult2$1(this, css, opts);
14427 } else {
14428 return new LazyResult$1$1(this, css, opts);
14429 }
14430 };
14431 _proto.use = function use(plugin22) {
14432 this.plugins = this.plugins.concat(this.normalize([
14433 plugin22
14434 ]));
14435 return this;
14436 };
14437 return Processor;
14438 }();
14439 var processor$1 = Processor$1$1;
14440 Processor$1$1.default = Processor$1$1;
14441 Root$2$1.registerProcessor(Processor$1$1);
14442 Document$1$1.registerProcessor(Processor$1$1);
14443 var Declaration$1$1 = declaration$1;
14444 var PreviousMap2$1 = previousMap$1;
14445 var Comment$1$1 = comment$1;
14446 var AtRule$1$1 = atRule$1;
14447 var Input$1$1 = input$1;
14448 var Root$1$1 = root$1;
14449 var Rule$1$1 = rule$1;
14450 function fromJSON$1$1(json, inputs) {
14451 if (Array.isArray(json)) return json.map(function(n2) {
14452 return fromJSON$1$1(n2);
14453 });
14454 var ownInputs = json.inputs, defaults = _object_without_properties_loose(json, [
14455 "inputs"
14456 ]);
14457 if (ownInputs) {
14458 inputs = [];
14459 for(var _iterator = _create_for_of_iterator_helper_loose(ownInputs), _step; !(_step = _iterator()).done;){
14460 var input2 = _step.value;
14461 var inputHydrated = _extends({}, input2, {
14462 __proto__: Input$1$1.prototype
14463 });
14464 if (inputHydrated.map) {
14465 inputHydrated.map = _extends({}, inputHydrated.map, {
14466 __proto__: PreviousMap2$1.prototype
14467 });
14468 }
14469 inputs.push(inputHydrated);
14470 }
14471 }
14472 if (defaults.nodes) {
14473 defaults.nodes = json.nodes.map(function(n2) {
14474 return fromJSON$1$1(n2, inputs);
14475 });
14476 }
14477 if (defaults.source) {
14478 var _defaults_source = defaults.source, inputId = _defaults_source.inputId, source = _object_without_properties_loose(_defaults_source, [
14479 "inputId"
14480 ]);
14481 defaults.source = source;
14482 if (inputId != null) {
14483 defaults.source.input = inputs[inputId];
14484 }
14485 }
14486 if (defaults.type === "root") {
14487 return new Root$1$1(defaults);
14488 } else if (defaults.type === "decl") {
14489 return new Declaration$1$1(defaults);
14490 } else if (defaults.type === "rule") {
14491 return new Rule$1$1(defaults);
14492 } else if (defaults.type === "comment") {
14493 return new Comment$1$1(defaults);
14494 } else if (defaults.type === "atrule") {
14495 return new AtRule$1$1(defaults);
14496 } else {
14497 throw new Error("Unknown node type: " + json.type);
14498 }
14499 }
14500 var fromJSON_1$1 = fromJSON$1$1;
14501 fromJSON$1$1.default = fromJSON$1$1;
14502 var CssSyntaxError2$1 = cssSyntaxError$1;
14503 var Declaration2$1 = declaration$1;
14504 var LazyResult2$1 = lazyResult$1;
14505 var Container2$1 = container$1;
14506 var Processor2$1 = processor$1;
14507 var stringify$5 = stringify_1$1;
14508 var fromJSON$2 = fromJSON_1$1;
14509 var Document22 = document$1$1;
14510 var Warning2$1 = warning$1;
14511 var Comment2$1 = comment$1;
14512 var AtRule2$1 = atRule$1;
14513 var Result2$1 = result$1;
14514 var Input2$1 = input$1;
14515 var parse$5 = parse_1$1;
14516 var list$3 = list_1$1;
14517 var Rule2$1 = rule$1;
14518 var Root2$1 = root$1;
14519 var Node2$1 = node$1;
14520 function postcss$3() {
14521 for(var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++){
14522 plugins[_key] = arguments[_key];
14523 }
14524 if (plugins.length === 1 && Array.isArray(plugins[0])) {
14525 plugins = plugins[0];
14526 }
14527 return new Processor2$1(plugins);
14528 }
14529 postcss$3.plugin = function plugin(name, initializer) {
14530 var warningPrinted = false;
14531 function creator() {
14532 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
14533 args[_key] = arguments[_key];
14534 }
14535 if (console && console.warn && !warningPrinted) {
14536 warningPrinted = true;
14537 console.warn(name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration");
14538 if (process.env.LANG && process.env.LANG.startsWith("cn")) {
14539 console.warn(name + ": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226");
14540 }
14541 }
14542 var transformer = initializer.apply(void 0, [].concat(args));
14543 transformer.postcssPlugin = name;
14544 transformer.postcssVersion = new Processor2$1().version;
14545 return transformer;
14546 }
14547 var cache;
14548 Object.defineProperty(creator, "postcss", {
14549 get: function get() {
14550 if (!cache) cache = creator();
14551 return cache;
14552 }
14553 });
14554 creator.process = function(css, processOpts, pluginOpts) {
14555 return postcss$3([
14556 creator(pluginOpts)
14557 ]).process(css, processOpts);
14558 };
14559 return creator;
14560 };
14561 postcss$3.stringify = stringify$5;
14562 postcss$3.parse = parse$5;
14563 postcss$3.fromJSON = fromJSON$2;
14564 postcss$3.list = list$3;
14565 postcss$3.comment = function(defaults) {
14566 return new Comment2$1(defaults);
14567 };
14568 postcss$3.atRule = function(defaults) {
14569 return new AtRule2$1(defaults);
14570 };
14571 postcss$3.decl = function(defaults) {
14572 return new Declaration2$1(defaults);
14573 };
14574 postcss$3.rule = function(defaults) {
14575 return new Rule2$1(defaults);
14576 };
14577 postcss$3.root = function(defaults) {
14578 return new Root2$1(defaults);
14579 };
14580 postcss$3.document = function(defaults) {
14581 return new Document22(defaults);
14582 };
14583 postcss$3.CssSyntaxError = CssSyntaxError2$1;
14584 postcss$3.Declaration = Declaration2$1;
14585 postcss$3.Container = Container2$1;
14586 postcss$3.Processor = Processor2$1;
14587 postcss$3.Document = Document22;
14588 postcss$3.Comment = Comment2$1;
14589 postcss$3.Warning = Warning2$1;
14590 postcss$3.AtRule = AtRule2$1;
14591 postcss$3.Result = Result2$1;
14592 postcss$3.Input = Input2$1;
14593 postcss$3.Rule = Rule2$1;
14594 postcss$3.Root = Root2$1;
14595 postcss$3.Node = Node2$1;
14596 LazyResult2$1.registerPostcss(postcss$3);
14597 var postcss_1$1 = postcss$3;
14598 postcss$3.default = postcss$3;
14599 var postcss$1$1 = /* @__PURE__ */ getDefaultExportFromCjs$1(postcss_1$1);
14600 postcss$1$1.stringify;
14601 postcss$1$1.fromJSON;
14602 postcss$1$1.plugin;
14603 postcss$1$1.parse;
14604 postcss$1$1.list;
14605 postcss$1$1.document;
14606 postcss$1$1.comment;
14607 postcss$1$1.atRule;
14608 postcss$1$1.rule;
14609 postcss$1$1.decl;
14610 postcss$1$1.root;
14611 postcss$1$1.CssSyntaxError;
14612 postcss$1$1.Declaration;
14613 postcss$1$1.Container;
14614 postcss$1$1.Processor;
14615 postcss$1$1.Document;
14616 postcss$1$1.Comment;
14617 postcss$1$1.Warning;
14618 postcss$1$1.AtRule;
14619 postcss$1$1.Result;
14620 postcss$1$1.Input;
14621 postcss$1$1.Rule;
14622 postcss$1$1.Root;
14623 postcss$1$1.Node;
14624 var __defProp2 = Object.defineProperty;
14625 var __defNormalProp2 = function(obj, key, value) {
14626 return key in obj ? __defProp2(obj, key, {
14627 enumerable: true,
14628 configurable: true,
14629 writable: true,
14630 value: value
14631 }) : obj[key] = value;
14632 };
14633 var __publicField2 = function(obj, key, value) {
14634 return __defNormalProp2(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
14635 };
14636 function getDefaultExportFromCjs(x2) {
14637 return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
14638 }
14639 function getAugmentedNamespace(n2) {
14640 if (n2.__esModule) return n2;
14641 var f2 = n2.default;
14642 if (typeof f2 == "function") {
14643 var a2 = function a22() {
14644 if (_instanceof(this, a22)) {
14645 return Reflect.construct(f2, arguments, this.constructor);
14646 }
14647 return f2.apply(this, arguments);
14648 };
14649 a2.prototype = f2.prototype;
14650 } else a2 = {};
14651 Object.defineProperty(a2, "__esModule", {
14652 value: true
14653 });
14654 Object.keys(n2).forEach(function(k) {
14655 var d = Object.getOwnPropertyDescriptor(n2, k);
14656 Object.defineProperty(a2, k, d.get ? d : {
14657 enumerable: true,
14658 get: function get() {
14659 return n2[k];
14660 }
14661 });
14662 });
14663 return a2;
14664 }
14665 var picocolors_browser = {
14666 exports: {}
14667 };
14668 var x = String;
14669 var create = function create() {
14670 return {
14671 isColorSupported: false,
14672 reset: x,
14673 bold: x,
14674 dim: x,
14675 italic: x,
14676 underline: x,
14677 inverse: x,
14678 hidden: x,
14679 strikethrough: x,
14680 black: x,
14681 red: x,
14682 green: x,
14683 yellow: x,
14684 blue: x,
14685 magenta: x,
14686 cyan: x,
14687 white: x,
14688 gray: x,
14689 bgBlack: x,
14690 bgRed: x,
14691 bgGreen: x,
14692 bgYellow: x,
14693 bgBlue: x,
14694 bgMagenta: x,
14695 bgCyan: x,
14696 bgWhite: x
14697 };
14698 };
14699 picocolors_browser.exports = create();
14700 picocolors_browser.exports.createColors = create;
14701 var picocolors_browserExports = picocolors_browser.exports;
14702 var __viteBrowserExternal = {};
14703 var __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
14704 __proto__: null,
14705 default: __viteBrowserExternal
14706 }, Symbol.toStringTag, {
14707 value: "Module"
14708 }));
14709 var require$$2 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1);
14710 var pico = picocolors_browserExports;
14711 var terminalHighlight$1 = require$$2;
14712 var CssSyntaxError$3 = /*#__PURE__*/ function(Error1) {
14713 _inherits(CssSyntaxError2, Error1);
14714 function CssSyntaxError2(message, line, column, source, file, plugin22) {
14715 var _this;
14716 _this = Error1.call(this, message) || this;
14717 _this.name = "CssSyntaxError";
14718 _this.reason = message;
14719 if (file) {
14720 _this.file = file;
14721 }
14722 if (source) {
14723 _this.source = source;
14724 }
14725 if (plugin22) {
14726 _this.plugin = plugin22;
14727 }
14728 if (typeof line !== "undefined" && typeof column !== "undefined") {
14729 if (typeof line === "number") {
14730 _this.line = line;
14731 _this.column = column;
14732 } else {
14733 _this.line = line.line;
14734 _this.column = line.column;
14735 _this.endLine = column.line;
14736 _this.endColumn = column.column;
14737 }
14738 }
14739 _this.setMessage();
14740 if (Error.captureStackTrace) {
14741 Error.captureStackTrace(_this, CssSyntaxError2);
14742 }
14743 return _this;
14744 }
14745 var _proto = CssSyntaxError2.prototype;
14746 _proto.setMessage = function setMessage() {
14747 this.message = this.plugin ? this.plugin + ": " : "";
14748 this.message += this.file ? this.file : "<css input>";
14749 if (typeof this.line !== "undefined") {
14750 this.message += ":" + this.line + ":" + this.column;
14751 }
14752 this.message += ": " + this.reason;
14753 };
14754 _proto.showSourceCode = function showSourceCode(color) {
14755 var _this = this;
14756 if (!this.source) return "";
14757 var css = this.source;
14758 if (color == null) color = pico.isColorSupported;
14759 if (terminalHighlight$1) {
14760 if (color) css = terminalHighlight$1(css);
14761 }
14762 var lines = css.split(/\r?\n/);
14763 var start = Math.max(this.line - 3, 0);
14764 var end = Math.min(this.line + 2, lines.length);
14765 var maxWidth = String(end).length;
14766 var mark, aside;
14767 if (color) {
14768 var _pico_createColors = pico.createColors(true), bold = _pico_createColors.bold, gray = _pico_createColors.gray, red = _pico_createColors.red;
14769 mark = function(text) {
14770 return bold(red(text));
14771 };
14772 aside = function(text) {
14773 return gray(text);
14774 };
14775 } else {
14776 mark = aside = function(str) {
14777 return str;
14778 };
14779 }
14780 return lines.slice(start, end).map(function(line, index2) {
14781 var number = start + 1 + index2;
14782 var gutter = " " + (" " + number).slice(-maxWidth) + " | ";
14783 if (number === _this.line) {
14784 var spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, _this.column - 1).replace(/[^\t]/g, " ");
14785 return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^");
14786 }
14787 return " " + aside(gutter) + line;
14788 }).join("\n");
14789 };
14790 _proto.toString = function toString() {
14791 var code = this.showSourceCode();
14792 if (code) {
14793 code = "\n\n" + code + "\n";
14794 }
14795 return this.name + ": " + this.message + code;
14796 };
14797 return CssSyntaxError2;
14798 }(_wrap_native_super(Error));
14799 var cssSyntaxError = CssSyntaxError$3;
14800 CssSyntaxError$3.default = CssSyntaxError$3;
14801 var symbols = {};
14802 symbols.isClean = Symbol("isClean");
14803 symbols.my = Symbol("my");
14804 var DEFAULT_RAW = {
14805 after: "\n",
14806 beforeClose: "\n",
14807 beforeComment: "\n",
14808 beforeDecl: "\n",
14809 beforeOpen: " ",
14810 beforeRule: "\n",
14811 colon: ": ",
14812 commentLeft: " ",
14813 commentRight: " ",
14814 emptyBody: "",
14815 indent: " ",
14816 semicolon: false
14817 };
14818 function capitalize(str) {
14819 return str[0].toUpperCase() + str.slice(1);
14820 }
14821 var Stringifier$2 = /*#__PURE__*/ function() {
14822 function Stringifier2(builder) {
14823 this.builder = builder;
14824 }
14825 var _proto = Stringifier2.prototype;
14826 _proto.atrule = function atrule(node2, semicolon) {
14827 var name = "@" + node2.name;
14828 var params = node2.params ? this.rawValue(node2, "params") : "";
14829 if (typeof node2.raws.afterName !== "undefined") {
14830 name += node2.raws.afterName;
14831 } else if (params) {
14832 name += " ";
14833 }
14834 if (node2.nodes) {
14835 this.block(node2, name + params);
14836 } else {
14837 var end = (node2.raws.between || "") + (semicolon ? ";" : "");
14838 this.builder(name + params + end, node2);
14839 }
14840 };
14841 _proto.beforeAfter = function beforeAfter(node2, detect) {
14842 var value;
14843 if (node2.type === "decl") {
14844 value = this.raw(node2, null, "beforeDecl");
14845 } else if (node2.type === "comment") {
14846 value = this.raw(node2, null, "beforeComment");
14847 } else if (detect === "before") {
14848 value = this.raw(node2, null, "beforeRule");
14849 } else {
14850 value = this.raw(node2, null, "beforeClose");
14851 }
14852 var buf = node2.parent;
14853 var depth = 0;
14854 while(buf && buf.type !== "root"){
14855 depth += 1;
14856 buf = buf.parent;
14857 }
14858 if (value.includes("\n")) {
14859 var indent = this.raw(node2, null, "indent");
14860 if (indent.length) {
14861 for(var step = 0; step < depth; step++)value += indent;
14862 }
14863 }
14864 return value;
14865 };
14866 _proto.block = function block(node2, start) {
14867 var between = this.raw(node2, "between", "beforeOpen");
14868 this.builder(start + between + "{", node2, "start");
14869 var after;
14870 if (node2.nodes && node2.nodes.length) {
14871 this.body(node2);
14872 after = this.raw(node2, "after");
14873 } else {
14874 after = this.raw(node2, "after", "emptyBody");
14875 }
14876 if (after) this.builder(after);
14877 this.builder("}", node2, "end");
14878 };
14879 _proto.body = function body(node2) {
14880 var last = node2.nodes.length - 1;
14881 while(last > 0){
14882 if (node2.nodes[last].type !== "comment") break;
14883 last -= 1;
14884 }
14885 var semicolon = this.raw(node2, "semicolon");
14886 for(var i2 = 0; i2 < node2.nodes.length; i2++){
14887 var child = node2.nodes[i2];
14888 var before = this.raw(child, "before");
14889 if (before) this.builder(before);
14890 this.stringify(child, last !== i2 || semicolon);
14891 }
14892 };
14893 _proto.comment = function comment(node2) {
14894 var left = this.raw(node2, "left", "commentLeft");
14895 var right = this.raw(node2, "right", "commentRight");
14896 this.builder("/*" + left + node2.text + right + "*/", node2);
14897 };
14898 _proto.decl = function decl(node2, semicolon) {
14899 var between = this.raw(node2, "between", "colon");
14900 var string = node2.prop + between + this.rawValue(node2, "value");
14901 if (node2.important) {
14902 string += node2.raws.important || " !important";
14903 }
14904 if (semicolon) string += ";";
14905 this.builder(string, node2);
14906 };
14907 _proto.document = function document1(node2) {
14908 this.body(node2);
14909 };
14910 _proto.raw = function raw(node2, own, detect) {
14911 var value;
14912 if (!detect) detect = own;
14913 if (own) {
14914 value = node2.raws[own];
14915 if (typeof value !== "undefined") return value;
14916 }
14917 var parent = node2.parent;
14918 if (detect === "before") {
14919 if (!parent || parent.type === "root" && parent.first === node2) {
14920 return "";
14921 }
14922 if (parent && parent.type === "document") {
14923 return "";
14924 }
14925 }
14926 if (!parent) return DEFAULT_RAW[detect];
14927 var root2 = node2.root();
14928 if (!root2.rawCache) root2.rawCache = {};
14929 if (typeof root2.rawCache[detect] !== "undefined") {
14930 return root2.rawCache[detect];
14931 }
14932 if (detect === "before" || detect === "after") {
14933 return this.beforeAfter(node2, detect);
14934 } else {
14935 var method = "raw" + capitalize(detect);
14936 if (this[method]) {
14937 value = this[method](root2, node2);
14938 } else {
14939 root2.walk(function(i2) {
14940 value = i2.raws[own];
14941 if (typeof value !== "undefined") return false;
14942 });
14943 }
14944 }
14945 if (typeof value === "undefined") value = DEFAULT_RAW[detect];
14946 root2.rawCache[detect] = value;
14947 return value;
14948 };
14949 _proto.rawBeforeClose = function rawBeforeClose(root2) {
14950 var value;
14951 root2.walk(function(i2) {
14952 if (i2.nodes && i2.nodes.length > 0) {
14953 if (typeof i2.raws.after !== "undefined") {
14954 value = i2.raws.after;
14955 if (value.includes("\n")) {
14956 value = value.replace(/[^\n]+$/, "");
14957 }
14958 return false;
14959 }
14960 }
14961 });
14962 if (value) value = value.replace(/\S/g, "");
14963 return value;
14964 };
14965 _proto.rawBeforeComment = function rawBeforeComment(root2, node2) {
14966 var value;
14967 root2.walkComments(function(i2) {
14968 if (typeof i2.raws.before !== "undefined") {
14969 value = i2.raws.before;
14970 if (value.includes("\n")) {
14971 value = value.replace(/[^\n]+$/, "");
14972 }
14973 return false;
14974 }
14975 });
14976 if (typeof value === "undefined") {
14977 value = this.raw(node2, null, "beforeDecl");
14978 } else if (value) {
14979 value = value.replace(/\S/g, "");
14980 }
14981 return value;
14982 };
14983 _proto.rawBeforeDecl = function rawBeforeDecl(root2, node2) {
14984 var value;
14985 root2.walkDecls(function(i2) {
14986 if (typeof i2.raws.before !== "undefined") {
14987 value = i2.raws.before;
14988 if (value.includes("\n")) {
14989 value = value.replace(/[^\n]+$/, "");
14990 }
14991 return false;
14992 }
14993 });
14994 if (typeof value === "undefined") {
14995 value = this.raw(node2, null, "beforeRule");
14996 } else if (value) {
14997 value = value.replace(/\S/g, "");
14998 }
14999 return value;
15000 };
15001 _proto.rawBeforeOpen = function rawBeforeOpen(root2) {
15002 var value;
15003 root2.walk(function(i2) {
15004 if (i2.type !== "decl") {
15005 value = i2.raws.between;
15006 if (typeof value !== "undefined") return false;
15007 }
15008 });
15009 return value;
15010 };
15011 _proto.rawBeforeRule = function rawBeforeRule(root2) {
15012 var value;
15013 root2.walk(function(i2) {
15014 if (i2.nodes && (i2.parent !== root2 || root2.first !== i2)) {
15015 if (typeof i2.raws.before !== "undefined") {
15016 value = i2.raws.before;
15017 if (value.includes("\n")) {
15018 value = value.replace(/[^\n]+$/, "");
15019 }
15020 return false;
15021 }
15022 }
15023 });
15024 if (value) value = value.replace(/\S/g, "");
15025 return value;
15026 };
15027 _proto.rawColon = function rawColon(root2) {
15028 var value;
15029 root2.walkDecls(function(i2) {
15030 if (typeof i2.raws.between !== "undefined") {
15031 value = i2.raws.between.replace(/[^\s:]/g, "");
15032 return false;
15033 }
15034 });
15035 return value;
15036 };
15037 _proto.rawEmptyBody = function rawEmptyBody(root2) {
15038 var value;
15039 root2.walk(function(i2) {
15040 if (i2.nodes && i2.nodes.length === 0) {
15041 value = i2.raws.after;
15042 if (typeof value !== "undefined") return false;
15043 }
15044 });
15045 return value;
15046 };
15047 _proto.rawIndent = function rawIndent(root2) {
15048 if (root2.raws.indent) return root2.raws.indent;
15049 var value;
15050 root2.walk(function(i2) {
15051 var p = i2.parent;
15052 if (p && p !== root2 && p.parent && p.parent === root2) {
15053 if (typeof i2.raws.before !== "undefined") {
15054 var parts = i2.raws.before.split("\n");
15055 value = parts[parts.length - 1];
15056 value = value.replace(/\S/g, "");
15057 return false;
15058 }
15059 }
15060 });
15061 return value;
15062 };
15063 _proto.rawSemicolon = function rawSemicolon(root2) {
15064 var value;
15065 root2.walk(function(i2) {
15066 if (i2.nodes && i2.nodes.length && i2.last.type === "decl") {
15067 value = i2.raws.semicolon;
15068 if (typeof value !== "undefined") return false;
15069 }
15070 });
15071 return value;
15072 };
15073 _proto.rawValue = function rawValue(node2, prop) {
15074 var value = node2[prop];
15075 var raw = node2.raws[prop];
15076 if (raw && raw.value === value) {
15077 return raw.raw;
15078 }
15079 return value;
15080 };
15081 _proto.root = function root(node2) {
15082 this.body(node2);
15083 if (node2.raws.after) this.builder(node2.raws.after);
15084 };
15085 _proto.rule = function rule(node2) {
15086 this.block(node2, this.rawValue(node2, "selector"));
15087 if (node2.raws.ownSemicolon) {
15088 this.builder(node2.raws.ownSemicolon, node2, "end");
15089 }
15090 };
15091 _proto.stringify = function stringify(node2, semicolon) {
15092 if (!this[node2.type]) {
15093 throw new Error("Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier.");
15094 }
15095 this[node2.type](node2, semicolon);
15096 };
15097 return Stringifier2;
15098 }();
15099 var stringifier = Stringifier$2;
15100 Stringifier$2.default = Stringifier$2;
15101 var Stringifier$1 = stringifier;
15102 function stringify$4(node2, builder) {
15103 var str = new Stringifier$1(builder);
15104 str.stringify(node2);
15105 }
15106 var stringify_1 = stringify$4;
15107 stringify$4.default = stringify$4;
15108 var isClean$2 = symbols.isClean, my$2 = symbols.my;
15109 var CssSyntaxError$2 = cssSyntaxError;
15110 var Stringifier22 = stringifier;
15111 var stringify$3 = stringify_1;
15112 function cloneNode(obj, parent) {
15113 var cloned = new obj.constructor();
15114 for(var i2 in obj){
15115 if (!Object.prototype.hasOwnProperty.call(obj, i2)) {
15116 continue;
15117 }
15118 if (i2 === "proxyCache") continue;
15119 var value = obj[i2];
15120 var type = typeof value === "undefined" ? "undefined" : _type_of(value);
15121 if (i2 === "parent" && type === "object") {
15122 if (parent) cloned[i2] = parent;
15123 } else if (i2 === "source") {
15124 cloned[i2] = value;
15125 } else if (Array.isArray(value)) {
15126 cloned[i2] = value.map(function(j) {
15127 return cloneNode(j, cloned);
15128 });
15129 } else {
15130 if (type === "object" && value !== null) value = cloneNode(value);
15131 cloned[i2] = value;
15132 }
15133 }
15134 return cloned;
15135 }
15136 var Node$4 = /*#__PURE__*/ function() {
15137 function Node3(defaults) {
15138 if (defaults === void 0) defaults = {};
15139 this.raws = {};
15140 this[isClean$2] = false;
15141 this[my$2] = true;
15142 for(var name in defaults){
15143 if (name === "nodes") {
15144 this.nodes = [];
15145 for(var _iterator = _create_for_of_iterator_helper_loose(defaults[name]), _step; !(_step = _iterator()).done;){
15146 var node2 = _step.value;
15147 if (typeof node2.clone === "function") {
15148 this.append(node2.clone());
15149 } else {
15150 this.append(node2);
15151 }
15152 }
15153 } else {
15154 this[name] = defaults[name];
15155 }
15156 }
15157 }
15158 var _proto = Node3.prototype;
15159 _proto.addToError = function addToError(error) {
15160 error.postcssNode = this;
15161 if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
15162 var s2 = this.source;
15163 error.stack = error.stack.replace(/\n\s{4}at /, "$&" + s2.input.from + ":" + s2.start.line + ":" + s2.start.column + "$&");
15164 }
15165 return error;
15166 };
15167 _proto.after = function after(add) {
15168 this.parent.insertAfter(this, add);
15169 return this;
15170 };
15171 _proto.assign = function assign(overrides) {
15172 if (overrides === void 0) overrides = {};
15173 for(var name in overrides){
15174 this[name] = overrides[name];
15175 }
15176 return this;
15177 };
15178 _proto.before = function before(add) {
15179 this.parent.insertBefore(this, add);
15180 return this;
15181 };
15182 _proto.cleanRaws = function cleanRaws(keepBetween) {
15183 delete this.raws.before;
15184 delete this.raws.after;
15185 if (!keepBetween) delete this.raws.between;
15186 };
15187 _proto.clone = function clone(overrides) {
15188 if (overrides === void 0) overrides = {};
15189 var cloned = cloneNode(this);
15190 for(var name in overrides){
15191 cloned[name] = overrides[name];
15192 }
15193 return cloned;
15194 };
15195 _proto.cloneAfter = function cloneAfter(overrides) {
15196 if (overrides === void 0) overrides = {};
15197 var cloned = this.clone(overrides);
15198 this.parent.insertAfter(this, cloned);
15199 return cloned;
15200 };
15201 _proto.cloneBefore = function cloneBefore(overrides) {
15202 if (overrides === void 0) overrides = {};
15203 var cloned = this.clone(overrides);
15204 this.parent.insertBefore(this, cloned);
15205 return cloned;
15206 };
15207 _proto.error = function error(message, opts) {
15208 if (opts === void 0) opts = {};
15209 if (this.source) {
15210 var _this_rangeBy = this.rangeBy(opts), end = _this_rangeBy.end, start = _this_rangeBy.start;
15211 return this.source.input.error(message, {
15212 column: start.column,
15213 line: start.line
15214 }, {
15215 column: end.column,
15216 line: end.line
15217 }, opts);
15218 }
15219 return new CssSyntaxError$2(message);
15220 };
15221 _proto.getProxyProcessor = function getProxyProcessor() {
15222 return {
15223 get: function get(node2, prop) {
15224 if (prop === "proxyOf") {
15225 return node2;
15226 } else if (prop === "root") {
15227 return function() {
15228 return node2.root().toProxy();
15229 };
15230 } else {
15231 return node2[prop];
15232 }
15233 },
15234 set: function set(node2, prop, value) {
15235 if (node2[prop] === value) return true;
15236 node2[prop] = value;
15237 if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ prop === "text") {
15238 node2.markDirty();
15239 }
15240 return true;
15241 }
15242 };
15243 };
15244 _proto.markDirty = function markDirty() {
15245 if (this[isClean$2]) {
15246 this[isClean$2] = false;
15247 var next = this;
15248 while(next = next.parent){
15249 next[isClean$2] = false;
15250 }
15251 }
15252 };
15253 _proto.next = function next() {
15254 if (!this.parent) return void 0;
15255 var index2 = this.parent.index(this);
15256 return this.parent.nodes[index2 + 1];
15257 };
15258 _proto.positionBy = function positionBy(opts, stringRepresentation) {
15259 var pos = this.source.start;
15260 if (opts.index) {
15261 pos = this.positionInside(opts.index, stringRepresentation);
15262 } else if (opts.word) {
15263 stringRepresentation = this.toString();
15264 var index2 = stringRepresentation.indexOf(opts.word);
15265 if (index2 !== -1) pos = this.positionInside(index2, stringRepresentation);
15266 }
15267 return pos;
15268 };
15269 _proto.positionInside = function positionInside(index2, stringRepresentation) {
15270 var string = stringRepresentation || this.toString();
15271 var column = this.source.start.column;
15272 var line = this.source.start.line;
15273 for(var i2 = 0; i2 < index2; i2++){
15274 if (string[i2] === "\n") {
15275 column = 1;
15276 line += 1;
15277 } else {
15278 column += 1;
15279 }
15280 }
15281 return {
15282 column: column,
15283 line: line
15284 };
15285 };
15286 _proto.prev = function prev() {
15287 if (!this.parent) return void 0;
15288 var index2 = this.parent.index(this);
15289 return this.parent.nodes[index2 - 1];
15290 };
15291 _proto.rangeBy = function rangeBy(opts) {
15292 var start = {
15293 column: this.source.start.column,
15294 line: this.source.start.line
15295 };
15296 var end = this.source.end ? {
15297 column: this.source.end.column + 1,
15298 line: this.source.end.line
15299 } : {
15300 column: start.column + 1,
15301 line: start.line
15302 };
15303 if (opts.word) {
15304 var stringRepresentation = this.toString();
15305 var index2 = stringRepresentation.indexOf(opts.word);
15306 if (index2 !== -1) {
15307 start = this.positionInside(index2, stringRepresentation);
15308 end = this.positionInside(index2 + opts.word.length, stringRepresentation);
15309 }
15310 } else {
15311 if (opts.start) {
15312 start = {
15313 column: opts.start.column,
15314 line: opts.start.line
15315 };
15316 } else if (opts.index) {
15317 start = this.positionInside(opts.index);
15318 }
15319 if (opts.end) {
15320 end = {
15321 column: opts.end.column,
15322 line: opts.end.line
15323 };
15324 } else if (typeof opts.endIndex === "number") {
15325 end = this.positionInside(opts.endIndex);
15326 } else if (opts.index) {
15327 end = this.positionInside(opts.index + 1);
15328 }
15329 }
15330 if (end.line < start.line || end.line === start.line && end.column <= start.column) {
15331 end = {
15332 column: start.column + 1,
15333 line: start.line
15334 };
15335 }
15336 return {
15337 end: end,
15338 start: start
15339 };
15340 };
15341 _proto.raw = function raw(prop, defaultType) {
15342 var str = new Stringifier22();
15343 return str.raw(this, prop, defaultType);
15344 };
15345 _proto.remove = function remove() {
15346 if (this.parent) {
15347 this.parent.removeChild(this);
15348 }
15349 this.parent = void 0;
15350 return this;
15351 };
15352 _proto.replaceWith = function replaceWith() {
15353 for(var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++){
15354 nodes[_key] = arguments[_key];
15355 }
15356 if (this.parent) {
15357 var bookmark = this;
15358 var foundSelf = false;
15359 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
15360 var node2 = _step.value;
15361 if (node2 === this) {
15362 foundSelf = true;
15363 } else if (foundSelf) {
15364 this.parent.insertAfter(bookmark, node2);
15365 bookmark = node2;
15366 } else {
15367 this.parent.insertBefore(bookmark, node2);
15368 }
15369 }
15370 if (!foundSelf) {
15371 this.remove();
15372 }
15373 }
15374 return this;
15375 };
15376 _proto.root = function root() {
15377 var result2 = this;
15378 while(result2.parent && result2.parent.type !== "document"){
15379 result2 = result2.parent;
15380 }
15381 return result2;
15382 };
15383 _proto.toJSON = function toJSON(_, inputs) {
15384 var fixed = {};
15385 var emitInputs = inputs == null;
15386 inputs = inputs || /* @__PURE__ */ new Map();
15387 var inputsNextIndex = 0;
15388 for(var name in this){
15389 if (!Object.prototype.hasOwnProperty.call(this, name)) {
15390 continue;
15391 }
15392 if (name === "parent" || name === "proxyCache") continue;
15393 var value = this[name];
15394 if (Array.isArray(value)) {
15395 fixed[name] = value.map(function(i2) {
15396 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.toJSON) {
15397 return i2.toJSON(null, inputs);
15398 } else {
15399 return i2;
15400 }
15401 });
15402 } else if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value.toJSON) {
15403 fixed[name] = value.toJSON(null, inputs);
15404 } else if (name === "source") {
15405 var inputId = inputs.get(value.input);
15406 if (inputId == null) {
15407 inputId = inputsNextIndex;
15408 inputs.set(value.input, inputsNextIndex);
15409 inputsNextIndex++;
15410 }
15411 fixed[name] = {
15412 end: value.end,
15413 inputId: inputId,
15414 start: value.start
15415 };
15416 } else {
15417 fixed[name] = value;
15418 }
15419 }
15420 if (emitInputs) {
15421 fixed.inputs = [].concat(inputs.keys()).map(function(input2) {
15422 return input2.toJSON();
15423 });
15424 }
15425 return fixed;
15426 };
15427 _proto.toProxy = function toProxy() {
15428 if (!this.proxyCache) {
15429 this.proxyCache = new Proxy(this, this.getProxyProcessor());
15430 }
15431 return this.proxyCache;
15432 };
15433 _proto.toString = function toString(stringifier2) {
15434 if (stringifier2 === void 0) stringifier2 = stringify$3;
15435 if (stringifier2.stringify) stringifier2 = stringifier2.stringify;
15436 var result2 = "";
15437 stringifier2(this, function(i2) {
15438 result2 += i2;
15439 });
15440 return result2;
15441 };
15442 _proto.warn = function warn(result2, text, opts) {
15443 var data = {
15444 node: this
15445 };
15446 for(var i2 in opts)data[i2] = opts[i2];
15447 return result2.warn(text, data);
15448 };
15449 _create_class(Node3, [
15450 {
15451 key: "proxyOf",
15452 get: function get() {
15453 return this;
15454 }
15455 }
15456 ]);
15457 return Node3;
15458 }();
15459 var node = Node$4;
15460 Node$4.default = Node$4;
15461 var Node$3 = node;
15462 var Declaration$4 = /*#__PURE__*/ function(Node$3) {
15463 _inherits(Declaration2, Node$3);
15464 function Declaration2(defaults) {
15465 var _this;
15466 if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
15467 defaults = _extends({}, defaults, {
15468 value: String(defaults.value)
15469 });
15470 }
15471 _this = Node$3.call(this, defaults) || this;
15472 _this.type = "decl";
15473 return _this;
15474 }
15475 _create_class(Declaration2, [
15476 {
15477 key: "variable",
15478 get: function get() {
15479 return this.prop.startsWith("--") || this.prop[0] === "$";
15480 }
15481 }
15482 ]);
15483 return Declaration2;
15484 }(Node$3);
15485 var declaration = Declaration$4;
15486 Declaration$4.default = Declaration$4;
15487 var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
15488 var nanoid$1 = function(size) {
15489 if (size === void 0) size = 21;
15490 var id = "";
15491 var i2 = size;
15492 while(i2--){
15493 id += urlAlphabet[Math.random() * 64 | 0];
15494 }
15495 return id;
15496 };
15497 var nonSecure = {
15498 nanoid: nanoid$1};
15499 var SourceMapConsumer$2 = require$$2.SourceMapConsumer, SourceMapGenerator$2 = require$$2.SourceMapGenerator;
15500 var existsSync = require$$2.existsSync, readFileSync = require$$2.readFileSync;
15501 var dirname$1 = require$$2.dirname, join = require$$2.join;
15502 function fromBase64(str) {
15503 if (Buffer) {
15504 return Buffer.from(str, "base64").toString();
15505 } else {
15506 return window.atob(str);
15507 }
15508 }
15509 var PreviousMap$2 = /*#__PURE__*/ function() {
15510 function PreviousMap2(css, opts) {
15511 if (opts.map === false) return;
15512 this.loadAnnotation(css);
15513 this.inline = this.startWith(this.annotation, "data:");
15514 var prev = opts.map ? opts.map.prev : void 0;
15515 var text = this.loadMap(opts.from, prev);
15516 if (!this.mapFile && opts.from) {
15517 this.mapFile = opts.from;
15518 }
15519 if (this.mapFile) this.root = dirname$1(this.mapFile);
15520 if (text) this.text = text;
15521 }
15522 var _proto = PreviousMap2.prototype;
15523 _proto.consumer = function consumer() {
15524 if (!this.consumerCache) {
15525 this.consumerCache = new SourceMapConsumer$2(this.text);
15526 }
15527 return this.consumerCache;
15528 };
15529 _proto.decodeInline = function decodeInline(text) {
15530 var baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
15531 var baseUri = /^data:application\/json;base64,/;
15532 var charsetUri = /^data:application\/json;charset=utf-?8,/;
15533 var uri = /^data:application\/json,/;
15534 if (charsetUri.test(text) || uri.test(text)) {
15535 return decodeURIComponent(text.substr(RegExp.lastMatch.length));
15536 }
15537 if (baseCharsetUri.test(text) || baseUri.test(text)) {
15538 return fromBase64(text.substr(RegExp.lastMatch.length));
15539 }
15540 var encoding = text.match(/data:application\/json;([^,]+),/)[1];
15541 throw new Error("Unsupported source map encoding " + encoding);
15542 };
15543 _proto.getAnnotationURL = function getAnnotationURL(sourceMapString) {
15544 return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
15545 };
15546 _proto.isMap = function isMap(map) {
15547 if ((typeof map === "undefined" ? "undefined" : _type_of(map)) !== "object") return false;
15548 return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
15549 };
15550 _proto.loadAnnotation = function loadAnnotation(css) {
15551 var comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
15552 if (!comments) return;
15553 var start = css.lastIndexOf(comments.pop());
15554 var end = css.indexOf("*/", start);
15555 if (start > -1 && end > -1) {
15556 this.annotation = this.getAnnotationURL(css.substring(start, end));
15557 }
15558 };
15559 _proto.loadFile = function loadFile(path) {
15560 this.root = dirname$1(path);
15561 if (existsSync(path)) {
15562 this.mapFile = path;
15563 return readFileSync(path, "utf-8").toString().trim();
15564 }
15565 };
15566 _proto.loadMap = function loadMap(file, prev) {
15567 if (prev === false) return false;
15568 if (prev) {
15569 if (typeof prev === "string") {
15570 return prev;
15571 } else if (typeof prev === "function") {
15572 var prevPath = prev(file);
15573 if (prevPath) {
15574 var map = this.loadFile(prevPath);
15575 if (!map) {
15576 throw new Error("Unable to load previous source map: " + prevPath.toString());
15577 }
15578 return map;
15579 }
15580 } else if (_instanceof(prev, SourceMapConsumer$2)) {
15581 return SourceMapGenerator$2.fromSourceMap(prev).toString();
15582 } else if (_instanceof(prev, SourceMapGenerator$2)) {
15583 return prev.toString();
15584 } else if (this.isMap(prev)) {
15585 return JSON.stringify(prev);
15586 } else {
15587 throw new Error("Unsupported previous source map format: " + prev.toString());
15588 }
15589 } else if (this.inline) {
15590 return this.decodeInline(this.annotation);
15591 } else if (this.annotation) {
15592 var map1 = this.annotation;
15593 if (file) map1 = join(dirname$1(file), map1);
15594 return this.loadFile(map1);
15595 }
15596 };
15597 _proto.startWith = function startWith(string, start) {
15598 if (!string) return false;
15599 return string.substr(0, start.length) === start;
15600 };
15601 _proto.withContent = function withContent() {
15602 return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
15603 };
15604 return PreviousMap2;
15605 }();
15606 var previousMap = PreviousMap$2;
15607 PreviousMap$2.default = PreviousMap$2;
15608 var SourceMapConsumer$1 = require$$2.SourceMapConsumer, SourceMapGenerator$1 = require$$2.SourceMapGenerator;
15609 var fileURLToPath = require$$2.fileURLToPath, pathToFileURL$1 = require$$2.pathToFileURL;
15610 var isAbsolute = require$$2.isAbsolute, resolve$1 = require$$2.resolve;
15611 var nanoid = nonSecure.nanoid;
15612 var terminalHighlight = require$$2;
15613 var CssSyntaxError$1 = cssSyntaxError;
15614 var PreviousMap$1 = previousMap;
15615 var fromOffsetCache = Symbol("fromOffsetCache");
15616 var sourceMapAvailable$1 = Boolean(SourceMapConsumer$1 && SourceMapGenerator$1);
15617 var pathAvailable$1 = Boolean(resolve$1 && isAbsolute);
15618 var Input$4 = /*#__PURE__*/ function() {
15619 function Input2(css, opts) {
15620 if (opts === void 0) opts = {};
15621 if (css === null || typeof css === "undefined" || (typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && !css.toString) {
15622 throw new Error("PostCSS received " + css + " instead of CSS string");
15623 }
15624 this.css = css.toString();
15625 if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
15626 this.hasBOM = true;
15627 this.css = this.css.slice(1);
15628 } else {
15629 this.hasBOM = false;
15630 }
15631 if (opts.from) {
15632 if (!pathAvailable$1 || /^\w+:\/\//.test(opts.from) || isAbsolute(opts.from)) {
15633 this.file = opts.from;
15634 } else {
15635 this.file = resolve$1(opts.from);
15636 }
15637 }
15638 if (pathAvailable$1 && sourceMapAvailable$1) {
15639 var map = new PreviousMap$1(this.css, opts);
15640 if (map.text) {
15641 this.map = map;
15642 var file = map.consumer().file;
15643 if (!this.file && file) this.file = this.mapResolve(file);
15644 }
15645 }
15646 if (!this.file) {
15647 this.id = "<input css " + nanoid(6) + ">";
15648 }
15649 if (this.map) this.map.file = this.from;
15650 }
15651 var _proto = Input2.prototype;
15652 _proto.error = function error(message, line, column, opts) {
15653 if (opts === void 0) opts = {};
15654 var result2, endLine, endColumn;
15655 if (line && (typeof line === "undefined" ? "undefined" : _type_of(line)) === "object") {
15656 var start = line;
15657 var end = column;
15658 if (typeof start.offset === "number") {
15659 var pos = this.fromOffset(start.offset);
15660 line = pos.line;
15661 column = pos.col;
15662 } else {
15663 line = start.line;
15664 column = start.column;
15665 }
15666 if (typeof end.offset === "number") {
15667 var pos1 = this.fromOffset(end.offset);
15668 endLine = pos1.line;
15669 endColumn = pos1.col;
15670 } else {
15671 endLine = end.line;
15672 endColumn = end.column;
15673 }
15674 } else if (!column) {
15675 var pos2 = this.fromOffset(line);
15676 line = pos2.line;
15677 column = pos2.col;
15678 }
15679 var origin = this.origin(line, column, endLine, endColumn);
15680 if (origin) {
15681 result2 = new CssSyntaxError$1(message, origin.endLine === void 0 ? origin.line : {
15682 column: origin.column,
15683 line: origin.line
15684 }, origin.endLine === void 0 ? origin.column : {
15685 column: origin.endColumn,
15686 line: origin.endLine
15687 }, origin.source, origin.file, opts.plugin);
15688 } else {
15689 result2 = new CssSyntaxError$1(message, endLine === void 0 ? line : {
15690 column: column,
15691 line: line
15692 }, endLine === void 0 ? column : {
15693 column: endColumn,
15694 line: endLine
15695 }, this.css, this.file, opts.plugin);
15696 }
15697 result2.input = {
15698 column: column,
15699 endColumn: endColumn,
15700 endLine: endLine,
15701 line: line,
15702 source: this.css
15703 };
15704 if (this.file) {
15705 if (pathToFileURL$1) {
15706 result2.input.url = pathToFileURL$1(this.file).toString();
15707 }
15708 result2.input.file = this.file;
15709 }
15710 return result2;
15711 };
15712 _proto.fromOffset = function fromOffset(offset) {
15713 var lastLine, lineToIndex;
15714 if (!this[fromOffsetCache]) {
15715 var lines = this.css.split("\n");
15716 lineToIndex = new Array(lines.length);
15717 var prevIndex = 0;
15718 for(var i2 = 0, l2 = lines.length; i2 < l2; i2++){
15719 lineToIndex[i2] = prevIndex;
15720 prevIndex += lines[i2].length + 1;
15721 }
15722 this[fromOffsetCache] = lineToIndex;
15723 } else {
15724 lineToIndex = this[fromOffsetCache];
15725 }
15726 lastLine = lineToIndex[lineToIndex.length - 1];
15727 var min = 0;
15728 if (offset >= lastLine) {
15729 min = lineToIndex.length - 1;
15730 } else {
15731 var max = lineToIndex.length - 2;
15732 var mid;
15733 while(min < max){
15734 mid = min + (max - min >> 1);
15735 if (offset < lineToIndex[mid]) {
15736 max = mid - 1;
15737 } else if (offset >= lineToIndex[mid + 1]) {
15738 min = mid + 1;
15739 } else {
15740 min = mid;
15741 break;
15742 }
15743 }
15744 }
15745 return {
15746 col: offset - lineToIndex[min] + 1,
15747 line: min + 1
15748 };
15749 };
15750 _proto.mapResolve = function mapResolve(file) {
15751 if (/^\w+:\/\//.test(file)) {
15752 return file;
15753 }
15754 return resolve$1(this.map.consumer().sourceRoot || this.map.root || ".", file);
15755 };
15756 _proto.origin = function origin(line, column, endLine, endColumn) {
15757 if (!this.map) return false;
15758 var consumer = this.map.consumer();
15759 var from = consumer.originalPositionFor({
15760 column: column,
15761 line: line
15762 });
15763 if (!from.source) return false;
15764 var to;
15765 if (typeof endLine === "number") {
15766 to = consumer.originalPositionFor({
15767 column: endColumn,
15768 line: endLine
15769 });
15770 }
15771 var fromUrl;
15772 if (isAbsolute(from.source)) {
15773 fromUrl = pathToFileURL$1(from.source);
15774 } else {
15775 fromUrl = new URL(from.source, this.map.consumer().sourceRoot || pathToFileURL$1(this.map.mapFile));
15776 }
15777 var result2 = {
15778 column: from.column,
15779 endColumn: to && to.column,
15780 endLine: to && to.line,
15781 line: from.line,
15782 url: fromUrl.toString()
15783 };
15784 if (fromUrl.protocol === "file:") {
15785 if (fileURLToPath) {
15786 result2.file = fileURLToPath(fromUrl);
15787 } else {
15788 throw new Error("file: protocol is not available in this PostCSS build");
15789 }
15790 }
15791 var source = consumer.sourceContentFor(from.source);
15792 if (source) result2.source = source;
15793 return result2;
15794 };
15795 _proto.toJSON = function toJSON() {
15796 var json = {};
15797 for(var _i = 0, _iter = [
15798 "hasBOM",
15799 "css",
15800 "file",
15801 "id"
15802 ]; _i < _iter.length; _i++){
15803 var name = _iter[_i];
15804 if (this[name] != null) {
15805 json[name] = this[name];
15806 }
15807 }
15808 if (this.map) {
15809 json.map = _extends({}, this.map);
15810 if (json.map.consumerCache) {
15811 json.map.consumerCache = void 0;
15812 }
15813 }
15814 return json;
15815 };
15816 _create_class(Input2, [
15817 {
15818 key: "from",
15819 get: function get() {
15820 return this.file || this.id;
15821 }
15822 }
15823 ]);
15824 return Input2;
15825 }();
15826 var input = Input$4;
15827 Input$4.default = Input$4;
15828 if (terminalHighlight && terminalHighlight.registerInput) {
15829 terminalHighlight.registerInput(Input$4);
15830 }
15831 var SourceMapConsumer = require$$2.SourceMapConsumer, SourceMapGenerator = require$$2.SourceMapGenerator;
15832 var dirname = require$$2.dirname, relative = require$$2.relative, resolve$3 = require$$2.resolve, sep = require$$2.sep;
15833 var pathToFileURL = require$$2.pathToFileURL;
15834 var Input$3 = input;
15835 var sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
15836 var pathAvailable = Boolean(dirname && resolve$3 && relative && sep);
15837 var MapGenerator$2 = /*#__PURE__*/ function() {
15838 function MapGenerator2(stringify2, root2, opts, cssString) {
15839 this.stringify = stringify2;
15840 this.mapOpts = opts.map || {};
15841 this.root = root2;
15842 this.opts = opts;
15843 this.css = cssString;
15844 this.originalCSS = cssString;
15845 this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
15846 this.memoizedFileURLs = /* @__PURE__ */ new Map();
15847 this.memoizedPaths = /* @__PURE__ */ new Map();
15848 this.memoizedURLs = /* @__PURE__ */ new Map();
15849 }
15850 var _proto = MapGenerator2.prototype;
15851 _proto.addAnnotation = function addAnnotation() {
15852 var content;
15853 if (this.isInline()) {
15854 content = "data:application/json;base64," + this.toBase64(this.map.toString());
15855 } else if (typeof this.mapOpts.annotation === "string") {
15856 content = this.mapOpts.annotation;
15857 } else if (typeof this.mapOpts.annotation === "function") {
15858 content = this.mapOpts.annotation(this.opts.to, this.root);
15859 } else {
15860 content = this.outputFile() + ".map";
15861 }
15862 var eol = "\n";
15863 if (this.css.includes("\r\n")) eol = "\r\n";
15864 this.css += eol + "/*# sourceMappingURL=" + content + " */";
15865 };
15866 _proto.applyPrevMaps = function applyPrevMaps() {
15867 for(var _iterator = _create_for_of_iterator_helper_loose(this.previous()), _step; !(_step = _iterator()).done;){
15868 var prev = _step.value;
15869 var from = this.toUrl(this.path(prev.file));
15870 var root2 = prev.root || dirname(prev.file);
15871 var map = void 0;
15872 if (this.mapOpts.sourcesContent === false) {
15873 map = new SourceMapConsumer(prev.text);
15874 if (map.sourcesContent) {
15875 map.sourcesContent = null;
15876 }
15877 } else {
15878 map = prev.consumer();
15879 }
15880 this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
15881 }
15882 };
15883 _proto.clearAnnotation = function clearAnnotation() {
15884 if (this.mapOpts.annotation === false) return;
15885 if (this.root) {
15886 var node2;
15887 for(var i2 = this.root.nodes.length - 1; i2 >= 0; i2--){
15888 node2 = this.root.nodes[i2];
15889 if (node2.type !== "comment") continue;
15890 if (node2.text.indexOf("# sourceMappingURL=") === 0) {
15891 this.root.removeChild(i2);
15892 }
15893 }
15894 } else if (this.css) {
15895 this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, "");
15896 }
15897 };
15898 _proto.generate = function generate() {
15899 this.clearAnnotation();
15900 if (pathAvailable && sourceMapAvailable && this.isMap()) {
15901 return this.generateMap();
15902 } else {
15903 var result2 = "";
15904 this.stringify(this.root, function(i2) {
15905 result2 += i2;
15906 });
15907 return [
15908 result2
15909 ];
15910 }
15911 };
15912 _proto.generateMap = function generateMap() {
15913 if (this.root) {
15914 this.generateString();
15915 } else if (this.previous().length === 1) {
15916 var prev = this.previous()[0].consumer();
15917 prev.file = this.outputFile();
15918 this.map = SourceMapGenerator.fromSourceMap(prev, {
15919 ignoreInvalidMapping: true
15920 });
15921 } else {
15922 this.map = new SourceMapGenerator({
15923 file: this.outputFile(),
15924 ignoreInvalidMapping: true
15925 });
15926 this.map.addMapping({
15927 generated: {
15928 column: 0,
15929 line: 1
15930 },
15931 original: {
15932 column: 0,
15933 line: 1
15934 },
15935 source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
15936 });
15937 }
15938 if (this.isSourcesContent()) this.setSourcesContent();
15939 if (this.root && this.previous().length > 0) this.applyPrevMaps();
15940 if (this.isAnnotation()) this.addAnnotation();
15941 if (this.isInline()) {
15942 return [
15943 this.css
15944 ];
15945 } else {
15946 return [
15947 this.css,
15948 this.map
15949 ];
15950 }
15951 };
15952 _proto.generateString = function generateString() {
15953 var _this = this;
15954 this.css = "";
15955 this.map = new SourceMapGenerator({
15956 file: this.outputFile(),
15957 ignoreInvalidMapping: true
15958 });
15959 var line = 1;
15960 var column = 1;
15961 var noSource = "<no source>";
15962 var mapping = {
15963 generated: {
15964 column: 0,
15965 line: 0
15966 },
15967 original: {
15968 column: 0,
15969 line: 0
15970 },
15971 source: ""
15972 };
15973 var lines, last;
15974 this.stringify(this.root, function(str, node2, type) {
15975 _this.css += str;
15976 if (node2 && type !== "end") {
15977 mapping.generated.line = line;
15978 mapping.generated.column = column - 1;
15979 if (node2.source && node2.source.start) {
15980 mapping.source = _this.sourcePath(node2);
15981 mapping.original.line = node2.source.start.line;
15982 mapping.original.column = node2.source.start.column - 1;
15983 _this.map.addMapping(mapping);
15984 } else {
15985 mapping.source = noSource;
15986 mapping.original.line = 1;
15987 mapping.original.column = 0;
15988 _this.map.addMapping(mapping);
15989 }
15990 }
15991 lines = str.match(/\n/g);
15992 if (lines) {
15993 line += lines.length;
15994 last = str.lastIndexOf("\n");
15995 column = str.length - last;
15996 } else {
15997 column += str.length;
15998 }
15999 if (node2 && type !== "start") {
16000 var p = node2.parent || {
16001 raws: {}
16002 };
16003 var childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
16004 if (!childless || node2 !== p.last || p.raws.semicolon) {
16005 if (node2.source && node2.source.end) {
16006 mapping.source = _this.sourcePath(node2);
16007 mapping.original.line = node2.source.end.line;
16008 mapping.original.column = node2.source.end.column - 1;
16009 mapping.generated.line = line;
16010 mapping.generated.column = column - 2;
16011 _this.map.addMapping(mapping);
16012 } else {
16013 mapping.source = noSource;
16014 mapping.original.line = 1;
16015 mapping.original.column = 0;
16016 mapping.generated.line = line;
16017 mapping.generated.column = column - 1;
16018 _this.map.addMapping(mapping);
16019 }
16020 }
16021 }
16022 });
16023 };
16024 _proto.isAnnotation = function isAnnotation() {
16025 if (this.isInline()) {
16026 return true;
16027 }
16028 if (typeof this.mapOpts.annotation !== "undefined") {
16029 return this.mapOpts.annotation;
16030 }
16031 if (this.previous().length) {
16032 return this.previous().some(function(i2) {
16033 return i2.annotation;
16034 });
16035 }
16036 return true;
16037 };
16038 _proto.isInline = function isInline() {
16039 if (typeof this.mapOpts.inline !== "undefined") {
16040 return this.mapOpts.inline;
16041 }
16042 var annotation = this.mapOpts.annotation;
16043 if (typeof annotation !== "undefined" && annotation !== true) {
16044 return false;
16045 }
16046 if (this.previous().length) {
16047 return this.previous().some(function(i2) {
16048 return i2.inline;
16049 });
16050 }
16051 return true;
16052 };
16053 _proto.isMap = function isMap() {
16054 if (typeof this.opts.map !== "undefined") {
16055 return !!this.opts.map;
16056 }
16057 return this.previous().length > 0;
16058 };
16059 _proto.isSourcesContent = function isSourcesContent() {
16060 if (typeof this.mapOpts.sourcesContent !== "undefined") {
16061 return this.mapOpts.sourcesContent;
16062 }
16063 if (this.previous().length) {
16064 return this.previous().some(function(i2) {
16065 return i2.withContent();
16066 });
16067 }
16068 return true;
16069 };
16070 _proto.outputFile = function outputFile() {
16071 if (this.opts.to) {
16072 return this.path(this.opts.to);
16073 } else if (this.opts.from) {
16074 return this.path(this.opts.from);
16075 } else {
16076 return "to.css";
16077 }
16078 };
16079 _proto.path = function path(file) {
16080 if (this.mapOpts.absolute) return file;
16081 if (file.charCodeAt(0) === 60) return file;
16082 if (/^\w+:\/\//.test(file)) return file;
16083 var cached = this.memoizedPaths.get(file);
16084 if (cached) return cached;
16085 var from = this.opts.to ? dirname(this.opts.to) : ".";
16086 if (typeof this.mapOpts.annotation === "string") {
16087 from = dirname(resolve$3(from, this.mapOpts.annotation));
16088 }
16089 var path = relative(from, file);
16090 this.memoizedPaths.set(file, path);
16091 return path;
16092 };
16093 _proto.previous = function previous() {
16094 var _this = this;
16095 if (!this.previousMaps) {
16096 this.previousMaps = [];
16097 if (this.root) {
16098 this.root.walk(function(node2) {
16099 if (node2.source && node2.source.input.map) {
16100 var map = node2.source.input.map;
16101 if (!_this.previousMaps.includes(map)) {
16102 _this.previousMaps.push(map);
16103 }
16104 }
16105 });
16106 } else {
16107 var input2 = new Input$3(this.originalCSS, this.opts);
16108 if (input2.map) this.previousMaps.push(input2.map);
16109 }
16110 }
16111 return this.previousMaps;
16112 };
16113 _proto.setSourcesContent = function setSourcesContent() {
16114 var _this = this;
16115 var already = {};
16116 if (this.root) {
16117 this.root.walk(function(node2) {
16118 if (node2.source) {
16119 var from = node2.source.input.from;
16120 if (from && !already[from]) {
16121 already[from] = true;
16122 var fromUrl = _this.usesFileUrls ? _this.toFileUrl(from) : _this.toUrl(_this.path(from));
16123 _this.map.setSourceContent(fromUrl, node2.source.input.css);
16124 }
16125 }
16126 });
16127 } else if (this.css) {
16128 var from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
16129 this.map.setSourceContent(from, this.css);
16130 }
16131 };
16132 _proto.sourcePath = function sourcePath(node2) {
16133 if (this.mapOpts.from) {
16134 return this.toUrl(this.mapOpts.from);
16135 } else if (this.usesFileUrls) {
16136 return this.toFileUrl(node2.source.input.from);
16137 } else {
16138 return this.toUrl(this.path(node2.source.input.from));
16139 }
16140 };
16141 _proto.toBase64 = function toBase64(str) {
16142 if (Buffer) {
16143 return Buffer.from(str).toString("base64");
16144 } else {
16145 return window.btoa(unescape(encodeURIComponent(str)));
16146 }
16147 };
16148 _proto.toFileUrl = function toFileUrl(path) {
16149 var cached = this.memoizedFileURLs.get(path);
16150 if (cached) return cached;
16151 if (pathToFileURL) {
16152 var fileURL = pathToFileURL(path).toString();
16153 this.memoizedFileURLs.set(path, fileURL);
16154 return fileURL;
16155 } else {
16156 throw new Error("`map.absolute` option is not available in this PostCSS build");
16157 }
16158 };
16159 _proto.toUrl = function toUrl(path) {
16160 var cached = this.memoizedURLs.get(path);
16161 if (cached) return cached;
16162 if (sep === "\\") {
16163 path = path.replace(/\\/g, "/");
16164 }
16165 var url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
16166 this.memoizedURLs.set(path, url);
16167 return url;
16168 };
16169 return MapGenerator2;
16170 }();
16171 var mapGenerator = MapGenerator$2;
16172 var Node$2 = node;
16173 var Comment$4 = /*#__PURE__*/ function(Node$2) {
16174 _inherits(Comment2, Node$2);
16175 function Comment2(defaults) {
16176 var _this;
16177 _this = Node$2.call(this, defaults) || this;
16178 _this.type = "comment";
16179 return _this;
16180 }
16181 return Comment2;
16182 }(Node$2);
16183 var comment = Comment$4;
16184 Comment$4.default = Comment$4;
16185 var isClean$1 = symbols.isClean, my$1 = symbols.my;
16186 var Declaration$3 = declaration;
16187 var Comment$3 = comment;
16188 var Node$1 = node;
16189 var parse$4, Rule$4, AtRule$4, Root$6;
16190 function cleanSource(nodes) {
16191 return nodes.map(function(i2) {
16192 if (i2.nodes) i2.nodes = cleanSource(i2.nodes);
16193 delete i2.source;
16194 return i2;
16195 });
16196 }
16197 function markDirtyUp(node2) {
16198 node2[isClean$1] = false;
16199 if (node2.proxyOf.nodes) {
16200 for(var _iterator = _create_for_of_iterator_helper_loose(node2.proxyOf.nodes), _step; !(_step = _iterator()).done;){
16201 var i2 = _step.value;
16202 markDirtyUp(i2);
16203 }
16204 }
16205 }
16206 var Container$7 = /*#__PURE__*/ function(Node$1) {
16207 _inherits(Container2, Node$1);
16208 function Container2() {
16209 return Node$1.apply(this, arguments) || this;
16210 }
16211 var _proto = Container2.prototype;
16212 _proto.append = function append() {
16213 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16214 children[_key] = arguments[_key];
16215 }
16216 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
16217 var child = _step.value;
16218 var nodes = this.normalize(child, this.last);
16219 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
16220 var node2 = _step1.value;
16221 this.proxyOf.nodes.push(node2);
16222 }
16223 }
16224 this.markDirty();
16225 return this;
16226 };
16227 _proto.cleanRaws = function cleanRaws(keepBetween) {
16228 Node$1.prototype.cleanRaws.call(this, keepBetween);
16229 if (this.nodes) {
16230 for(var _iterator = _create_for_of_iterator_helper_loose(this.nodes), _step; !(_step = _iterator()).done;){
16231 var node2 = _step.value;
16232 node2.cleanRaws(keepBetween);
16233 }
16234 }
16235 };
16236 _proto.each = function each(callback) {
16237 if (!this.proxyOf.nodes) return void 0;
16238 var iterator = this.getIterator();
16239 var index2, result2;
16240 while(this.indexes[iterator] < this.proxyOf.nodes.length){
16241 index2 = this.indexes[iterator];
16242 result2 = callback(this.proxyOf.nodes[index2], index2);
16243 if (result2 === false) break;
16244 this.indexes[iterator] += 1;
16245 }
16246 delete this.indexes[iterator];
16247 return result2;
16248 };
16249 _proto.every = function every(condition) {
16250 return this.nodes.every(condition);
16251 };
16252 _proto.getIterator = function getIterator() {
16253 if (!this.lastEach) this.lastEach = 0;
16254 if (!this.indexes) this.indexes = {};
16255 this.lastEach += 1;
16256 var iterator = this.lastEach;
16257 this.indexes[iterator] = 0;
16258 return iterator;
16259 };
16260 _proto.getProxyProcessor = function getProxyProcessor() {
16261 return {
16262 get: function get(node2, prop) {
16263 if (prop === "proxyOf") {
16264 return node2;
16265 } else if (!node2[prop]) {
16266 return node2[prop];
16267 } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
16268 return function() {
16269 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
16270 args[_key] = arguments[_key];
16271 }
16272 var _node2;
16273 return (_node2 = node2)[prop].apply(_node2, [].concat(args.map(function(i2) {
16274 if (typeof i2 === "function") {
16275 return function(child, index2) {
16276 return i2(child.toProxy(), index2);
16277 };
16278 } else {
16279 return i2;
16280 }
16281 })));
16282 };
16283 } else if (prop === "every" || prop === "some") {
16284 return function(cb) {
16285 return node2[prop](function(child) {
16286 for(var _len = arguments.length, other = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
16287 other[_key - 1] = arguments[_key];
16288 }
16289 return cb.apply(void 0, [].concat([
16290 child.toProxy()
16291 ], other));
16292 });
16293 };
16294 } else if (prop === "root") {
16295 return function() {
16296 return node2.root().toProxy();
16297 };
16298 } else if (prop === "nodes") {
16299 return node2.nodes.map(function(i2) {
16300 return i2.toProxy();
16301 });
16302 } else if (prop === "first" || prop === "last") {
16303 return node2[prop].toProxy();
16304 } else {
16305 return node2[prop];
16306 }
16307 },
16308 set: function set(node2, prop, value) {
16309 if (node2[prop] === value) return true;
16310 node2[prop] = value;
16311 if (prop === "name" || prop === "params" || prop === "selector") {
16312 node2.markDirty();
16313 }
16314 return true;
16315 }
16316 };
16317 };
16318 _proto.index = function index(child) {
16319 if (typeof child === "number") return child;
16320 if (child.proxyOf) child = child.proxyOf;
16321 return this.proxyOf.nodes.indexOf(child);
16322 };
16323 _proto.insertAfter = function insertAfter(exist, add) {
16324 var existIndex = this.index(exist);
16325 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
16326 existIndex = this.index(exist);
16327 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
16328 var node2 = _step.value;
16329 this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
16330 }
16331 var index2;
16332 for(var id in this.indexes){
16333 index2 = this.indexes[id];
16334 if (existIndex < index2) {
16335 this.indexes[id] = index2 + nodes.length;
16336 }
16337 }
16338 this.markDirty();
16339 return this;
16340 };
16341 _proto.insertBefore = function insertBefore(exist, add) {
16342 var existIndex = this.index(exist);
16343 var type = existIndex === 0 ? "prepend" : false;
16344 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
16345 existIndex = this.index(exist);
16346 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
16347 var node2 = _step.value;
16348 this.proxyOf.nodes.splice(existIndex, 0, node2);
16349 }
16350 var index2;
16351 for(var id in this.indexes){
16352 index2 = this.indexes[id];
16353 if (existIndex <= index2) {
16354 this.indexes[id] = index2 + nodes.length;
16355 }
16356 }
16357 this.markDirty();
16358 return this;
16359 };
16360 _proto.normalize = function normalize(nodes, sample) {
16361 var _this = this;
16362 if (typeof nodes === "string") {
16363 nodes = cleanSource(parse$4(nodes).nodes);
16364 } else if (typeof nodes === "undefined") {
16365 nodes = [];
16366 } else if (Array.isArray(nodes)) {
16367 nodes = nodes.slice(0);
16368 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
16369 var i2 = _step.value;
16370 if (i2.parent) i2.parent.removeChild(i2, "ignore");
16371 }
16372 } else if (nodes.type === "root" && this.type !== "document") {
16373 nodes = nodes.nodes.slice(0);
16374 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
16375 var i21 = _step1.value;
16376 if (i21.parent) i21.parent.removeChild(i21, "ignore");
16377 }
16378 } else if (nodes.type) {
16379 nodes = [
16380 nodes
16381 ];
16382 } else if (nodes.prop) {
16383 if (typeof nodes.value === "undefined") {
16384 throw new Error("Value field is missed in node creation");
16385 } else if (typeof nodes.value !== "string") {
16386 nodes.value = String(nodes.value);
16387 }
16388 nodes = [
16389 new Declaration$3(nodes)
16390 ];
16391 } else if (nodes.selector) {
16392 nodes = [
16393 new Rule$4(nodes)
16394 ];
16395 } else if (nodes.name) {
16396 nodes = [
16397 new AtRule$4(nodes)
16398 ];
16399 } else if (nodes.text) {
16400 nodes = [
16401 new Comment$3(nodes)
16402 ];
16403 } else {
16404 throw new Error("Unknown node type in node creation");
16405 }
16406 var processed = nodes.map(function(i2) {
16407 if (!i2[my$1]) Container2.rebuild(i2);
16408 i2 = i2.proxyOf;
16409 if (i2.parent) i2.parent.removeChild(i2);
16410 if (i2[isClean$1]) markDirtyUp(i2);
16411 if (typeof i2.raws.before === "undefined") {
16412 if (sample && typeof sample.raws.before !== "undefined") {
16413 i2.raws.before = sample.raws.before.replace(/\S/g, "");
16414 }
16415 }
16416 i2.parent = _this.proxyOf;
16417 return i2;
16418 });
16419 return processed;
16420 };
16421 _proto.prepend = function prepend() {
16422 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16423 children[_key] = arguments[_key];
16424 }
16425 children = children.reverse();
16426 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
16427 var child = _step.value;
16428 var nodes = this.normalize(child, this.first, "prepend").reverse();
16429 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
16430 var node2 = _step1.value;
16431 this.proxyOf.nodes.unshift(node2);
16432 }
16433 for(var id in this.indexes){
16434 this.indexes[id] = this.indexes[id] + nodes.length;
16435 }
16436 }
16437 this.markDirty();
16438 return this;
16439 };
16440 _proto.push = function push(child) {
16441 child.parent = this;
16442 this.proxyOf.nodes.push(child);
16443 return this;
16444 };
16445 _proto.removeAll = function removeAll() {
16446 for(var _iterator = _create_for_of_iterator_helper_loose(this.proxyOf.nodes), _step; !(_step = _iterator()).done;){
16447 var node2 = _step.value;
16448 node2.parent = void 0;
16449 }
16450 this.proxyOf.nodes = [];
16451 this.markDirty();
16452 return this;
16453 };
16454 _proto.removeChild = function removeChild(child) {
16455 child = this.index(child);
16456 this.proxyOf.nodes[child].parent = void 0;
16457 this.proxyOf.nodes.splice(child, 1);
16458 var index2;
16459 for(var id in this.indexes){
16460 index2 = this.indexes[id];
16461 if (index2 >= child) {
16462 this.indexes[id] = index2 - 1;
16463 }
16464 }
16465 this.markDirty();
16466 return this;
16467 };
16468 _proto.replaceValues = function replaceValues(pattern, opts, callback) {
16469 if (!callback) {
16470 callback = opts;
16471 opts = {};
16472 }
16473 this.walkDecls(function(decl) {
16474 if (opts.props && !opts.props.includes(decl.prop)) return;
16475 if (opts.fast && !decl.value.includes(opts.fast)) return;
16476 decl.value = decl.value.replace(pattern, callback);
16477 });
16478 this.markDirty();
16479 return this;
16480 };
16481 _proto.some = function some(condition) {
16482 return this.nodes.some(condition);
16483 };
16484 _proto.walk = function walk(callback) {
16485 return this.each(function(child, i2) {
16486 var result2;
16487 try {
16488 result2 = callback(child, i2);
16489 } catch (e2) {
16490 throw child.addToError(e2);
16491 }
16492 if (result2 !== false && child.walk) {
16493 result2 = child.walk(callback);
16494 }
16495 return result2;
16496 });
16497 };
16498 _proto.walkAtRules = function walkAtRules(name, callback) {
16499 if (!callback) {
16500 callback = name;
16501 return this.walk(function(child, i2) {
16502 if (child.type === "atrule") {
16503 return callback(child, i2);
16504 }
16505 });
16506 }
16507 if (_instanceof(name, RegExp)) {
16508 return this.walk(function(child, i2) {
16509 if (child.type === "atrule" && name.test(child.name)) {
16510 return callback(child, i2);
16511 }
16512 });
16513 }
16514 return this.walk(function(child, i2) {
16515 if (child.type === "atrule" && child.name === name) {
16516 return callback(child, i2);
16517 }
16518 });
16519 };
16520 _proto.walkComments = function walkComments(callback) {
16521 return this.walk(function(child, i2) {
16522 if (child.type === "comment") {
16523 return callback(child, i2);
16524 }
16525 });
16526 };
16527 _proto.walkDecls = function walkDecls(prop, callback) {
16528 if (!callback) {
16529 callback = prop;
16530 return this.walk(function(child, i2) {
16531 if (child.type === "decl") {
16532 return callback(child, i2);
16533 }
16534 });
16535 }
16536 if (_instanceof(prop, RegExp)) {
16537 return this.walk(function(child, i2) {
16538 if (child.type === "decl" && prop.test(child.prop)) {
16539 return callback(child, i2);
16540 }
16541 });
16542 }
16543 return this.walk(function(child, i2) {
16544 if (child.type === "decl" && child.prop === prop) {
16545 return callback(child, i2);
16546 }
16547 });
16548 };
16549 _proto.walkRules = function walkRules(selector, callback) {
16550 if (!callback) {
16551 callback = selector;
16552 return this.walk(function(child, i2) {
16553 if (child.type === "rule") {
16554 return callback(child, i2);
16555 }
16556 });
16557 }
16558 if (_instanceof(selector, RegExp)) {
16559 return this.walk(function(child, i2) {
16560 if (child.type === "rule" && selector.test(child.selector)) {
16561 return callback(child, i2);
16562 }
16563 });
16564 }
16565 return this.walk(function(child, i2) {
16566 if (child.type === "rule" && child.selector === selector) {
16567 return callback(child, i2);
16568 }
16569 });
16570 };
16571 _create_class(Container2, [
16572 {
16573 key: "first",
16574 get: function get() {
16575 if (!this.proxyOf.nodes) return void 0;
16576 return this.proxyOf.nodes[0];
16577 }
16578 },
16579 {
16580 key: "last",
16581 get: function get() {
16582 if (!this.proxyOf.nodes) return void 0;
16583 return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
16584 }
16585 }
16586 ]);
16587 return Container2;
16588 }(Node$1);
16589 Container$7.registerParse = function(dependant) {
16590 parse$4 = dependant;
16591 };
16592 Container$7.registerRule = function(dependant) {
16593 Rule$4 = dependant;
16594 };
16595 Container$7.registerAtRule = function(dependant) {
16596 AtRule$4 = dependant;
16597 };
16598 Container$7.registerRoot = function(dependant) {
16599 Root$6 = dependant;
16600 };
16601 var container = Container$7;
16602 Container$7.default = Container$7;
16603 Container$7.rebuild = function(node2) {
16604 if (node2.type === "atrule") {
16605 Object.setPrototypeOf(node2, AtRule$4.prototype);
16606 } else if (node2.type === "rule") {
16607 Object.setPrototypeOf(node2, Rule$4.prototype);
16608 } else if (node2.type === "decl") {
16609 Object.setPrototypeOf(node2, Declaration$3.prototype);
16610 } else if (node2.type === "comment") {
16611 Object.setPrototypeOf(node2, Comment$3.prototype);
16612 } else if (node2.type === "root") {
16613 Object.setPrototypeOf(node2, Root$6.prototype);
16614 }
16615 node2[my$1] = true;
16616 if (node2.nodes) {
16617 node2.nodes.forEach(function(child) {
16618 Container$7.rebuild(child);
16619 });
16620 }
16621 };
16622 var Container$6 = container;
16623 var LazyResult$4, Processor$3;
16624 var Document$3 = /*#__PURE__*/ function(Container$6) {
16625 _inherits(Document23, Container$6);
16626 function Document23(defaults) {
16627 var _this;
16628 _this = Container$6.call(this, _extends({
16629 type: "document"
16630 }, defaults)) || this;
16631 if (!_this.nodes) {
16632 _this.nodes = [];
16633 }
16634 return _this;
16635 }
16636 var _proto = Document23.prototype;
16637 _proto.toResult = function toResult(opts) {
16638 if (opts === void 0) opts = {};
16639 var lazy = new LazyResult$4(new Processor$3(), this, opts);
16640 return lazy.stringify();
16641 };
16642 return Document23;
16643 }(Container$6);
16644 Document$3.registerLazyResult = function(dependant) {
16645 LazyResult$4 = dependant;
16646 };
16647 Document$3.registerProcessor = function(dependant) {
16648 Processor$3 = dependant;
16649 };
16650 var document$1$2 = Document$3;
16651 Document$3.default = Document$3;
16652 var printed = {};
16653 var warnOnce$2 = function warnOnce2(message) {
16654 if (printed[message]) return;
16655 printed[message] = true;
16656 if (typeof console !== "undefined" && console.warn) {
16657 console.warn(message);
16658 }
16659 };
16660 var Warning$2 = /*#__PURE__*/ function() {
16661 function Warning2(text, opts) {
16662 if (opts === void 0) opts = {};
16663 this.type = "warning";
16664 this.text = text;
16665 if (opts.node && opts.node.source) {
16666 var range = opts.node.rangeBy(opts);
16667 this.line = range.start.line;
16668 this.column = range.start.column;
16669 this.endLine = range.end.line;
16670 this.endColumn = range.end.column;
16671 }
16672 for(var opt in opts)this[opt] = opts[opt];
16673 }
16674 var _proto = Warning2.prototype;
16675 _proto.toString = function toString() {
16676 if (this.node) {
16677 return this.node.error(this.text, {
16678 index: this.index,
16679 plugin: this.plugin,
16680 word: this.word
16681 }).message;
16682 }
16683 if (this.plugin) {
16684 return this.plugin + ": " + this.text;
16685 }
16686 return this.text;
16687 };
16688 return Warning2;
16689 }();
16690 var warning = Warning$2;
16691 Warning$2.default = Warning$2;
16692 var Warning$1 = warning;
16693 var Result$3 = /*#__PURE__*/ function() {
16694 function Result2(processor2, root2, opts) {
16695 this.processor = processor2;
16696 this.messages = [];
16697 this.root = root2;
16698 this.opts = opts;
16699 this.css = void 0;
16700 this.map = void 0;
16701 }
16702 var _proto = Result2.prototype;
16703 _proto.toString = function toString() {
16704 return this.css;
16705 };
16706 _proto.warn = function warn(text, opts) {
16707 if (opts === void 0) opts = {};
16708 if (!opts.plugin) {
16709 if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
16710 opts.plugin = this.lastPlugin.postcssPlugin;
16711 }
16712 }
16713 var warning2 = new Warning$1(text, opts);
16714 this.messages.push(warning2);
16715 return warning2;
16716 };
16717 _proto.warnings = function warnings() {
16718 return this.messages.filter(function(i2) {
16719 return i2.type === "warning";
16720 });
16721 };
16722 _create_class(Result2, [
16723 {
16724 key: "content",
16725 get: function get() {
16726 return this.css;
16727 }
16728 }
16729 ]);
16730 return Result2;
16731 }();
16732 var result = Result$3;
16733 Result$3.default = Result$3;
16734 var SINGLE_QUOTE = "'".charCodeAt(0);
16735 var DOUBLE_QUOTE = '"'.charCodeAt(0);
16736 var BACKSLASH = "\\".charCodeAt(0);
16737 var SLASH = "/".charCodeAt(0);
16738 var NEWLINE = "\n".charCodeAt(0);
16739 var SPACE = " ".charCodeAt(0);
16740 var FEED = "\f".charCodeAt(0);
16741 var TAB = " ".charCodeAt(0);
16742 var CR = "\r".charCodeAt(0);
16743 var OPEN_SQUARE = "[".charCodeAt(0);
16744 var CLOSE_SQUARE = "]".charCodeAt(0);
16745 var OPEN_PARENTHESES = "(".charCodeAt(0);
16746 var CLOSE_PARENTHESES = ")".charCodeAt(0);
16747 var OPEN_CURLY = "{".charCodeAt(0);
16748 var CLOSE_CURLY = "}".charCodeAt(0);
16749 var SEMICOLON = ";".charCodeAt(0);
16750 var ASTERISK = "*".charCodeAt(0);
16751 var COLON = ":".charCodeAt(0);
16752 var AT = "@".charCodeAt(0);
16753 var RE_AT_END = /[\t\n\f\r "#'()/;[\\\]{}]/g;
16754 var RE_WORD_END = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
16755 var RE_BAD_BRACKET = /.[\r\n"'(/\\]/;
16756 var RE_HEX_ESCAPE = /[\da-f]/i;
16757 var tokenize = function tokenizer2(input2, options) {
16758 if (options === void 0) options = {};
16759 var css = input2.css.valueOf();
16760 var ignore = options.ignoreErrors;
16761 var code, next, quote, content, escape;
16762 var escaped, escapePos, prev, n2, currentToken;
16763 var length = css.length;
16764 var pos = 0;
16765 var buffer = [];
16766 var returned = [];
16767 function position() {
16768 return pos;
16769 }
16770 function unclosed(what) {
16771 throw input2.error("Unclosed " + what, pos);
16772 }
16773 function endOfFile() {
16774 return returned.length === 0 && pos >= length;
16775 }
16776 function nextToken(opts) {
16777 if (returned.length) return returned.pop();
16778 if (pos >= length) return;
16779 var ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
16780 code = css.charCodeAt(pos);
16781 switch(code){
16782 case NEWLINE:
16783 case SPACE:
16784 case TAB:
16785 case CR:
16786 case FEED:
16787 {
16788 next = pos;
16789 do {
16790 next += 1;
16791 code = css.charCodeAt(next);
16792 }while (code === SPACE || code === NEWLINE || code === TAB || code === CR || code === FEED);
16793 currentToken = [
16794 "space",
16795 css.slice(pos, next)
16796 ];
16797 pos = next - 1;
16798 break;
16799 }
16800 case OPEN_SQUARE:
16801 case CLOSE_SQUARE:
16802 case OPEN_CURLY:
16803 case CLOSE_CURLY:
16804 case COLON:
16805 case SEMICOLON:
16806 case CLOSE_PARENTHESES:
16807 {
16808 var controlChar = String.fromCharCode(code);
16809 currentToken = [
16810 controlChar,
16811 controlChar,
16812 pos
16813 ];
16814 break;
16815 }
16816 case OPEN_PARENTHESES:
16817 {
16818 prev = buffer.length ? buffer.pop()[1] : "";
16819 n2 = css.charCodeAt(pos + 1);
16820 if (prev === "url" && n2 !== SINGLE_QUOTE && n2 !== DOUBLE_QUOTE && n2 !== SPACE && n2 !== NEWLINE && n2 !== TAB && n2 !== FEED && n2 !== CR) {
16821 next = pos;
16822 do {
16823 escaped = false;
16824 next = css.indexOf(")", next + 1);
16825 if (next === -1) {
16826 if (ignore || ignoreUnclosed) {
16827 next = pos;
16828 break;
16829 } else {
16830 unclosed("bracket");
16831 }
16832 }
16833 escapePos = next;
16834 while(css.charCodeAt(escapePos - 1) === BACKSLASH){
16835 escapePos -= 1;
16836 escaped = !escaped;
16837 }
16838 }while (escaped);
16839 currentToken = [
16840 "brackets",
16841 css.slice(pos, next + 1),
16842 pos,
16843 next
16844 ];
16845 pos = next;
16846 } else {
16847 next = css.indexOf(")", pos + 1);
16848 content = css.slice(pos, next + 1);
16849 if (next === -1 || RE_BAD_BRACKET.test(content)) {
16850 currentToken = [
16851 "(",
16852 "(",
16853 pos
16854 ];
16855 } else {
16856 currentToken = [
16857 "brackets",
16858 content,
16859 pos,
16860 next
16861 ];
16862 pos = next;
16863 }
16864 }
16865 break;
16866 }
16867 case SINGLE_QUOTE:
16868 case DOUBLE_QUOTE:
16869 {
16870 quote = code === SINGLE_QUOTE ? "'" : '"';
16871 next = pos;
16872 do {
16873 escaped = false;
16874 next = css.indexOf(quote, next + 1);
16875 if (next === -1) {
16876 if (ignore || ignoreUnclosed) {
16877 next = pos + 1;
16878 break;
16879 } else {
16880 unclosed("string");
16881 }
16882 }
16883 escapePos = next;
16884 while(css.charCodeAt(escapePos - 1) === BACKSLASH){
16885 escapePos -= 1;
16886 escaped = !escaped;
16887 }
16888 }while (escaped);
16889 currentToken = [
16890 "string",
16891 css.slice(pos, next + 1),
16892 pos,
16893 next
16894 ];
16895 pos = next;
16896 break;
16897 }
16898 case AT:
16899 {
16900 RE_AT_END.lastIndex = pos + 1;
16901 RE_AT_END.test(css);
16902 if (RE_AT_END.lastIndex === 0) {
16903 next = css.length - 1;
16904 } else {
16905 next = RE_AT_END.lastIndex - 2;
16906 }
16907 currentToken = [
16908 "at-word",
16909 css.slice(pos, next + 1),
16910 pos,
16911 next
16912 ];
16913 pos = next;
16914 break;
16915 }
16916 case BACKSLASH:
16917 {
16918 next = pos;
16919 escape = true;
16920 while(css.charCodeAt(next + 1) === BACKSLASH){
16921 next += 1;
16922 escape = !escape;
16923 }
16924 code = css.charCodeAt(next + 1);
16925 if (escape && code !== SLASH && code !== SPACE && code !== NEWLINE && code !== TAB && code !== CR && code !== FEED) {
16926 next += 1;
16927 if (RE_HEX_ESCAPE.test(css.charAt(next))) {
16928 while(RE_HEX_ESCAPE.test(css.charAt(next + 1))){
16929 next += 1;
16930 }
16931 if (css.charCodeAt(next + 1) === SPACE) {
16932 next += 1;
16933 }
16934 }
16935 }
16936 currentToken = [
16937 "word",
16938 css.slice(pos, next + 1),
16939 pos,
16940 next
16941 ];
16942 pos = next;
16943 break;
16944 }
16945 default:
16946 {
16947 if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
16948 next = css.indexOf("*/", pos + 2) + 1;
16949 if (next === 0) {
16950 if (ignore || ignoreUnclosed) {
16951 next = css.length;
16952 } else {
16953 unclosed("comment");
16954 }
16955 }
16956 currentToken = [
16957 "comment",
16958 css.slice(pos, next + 1),
16959 pos,
16960 next
16961 ];
16962 pos = next;
16963 } else {
16964 RE_WORD_END.lastIndex = pos + 1;
16965 RE_WORD_END.test(css);
16966 if (RE_WORD_END.lastIndex === 0) {
16967 next = css.length - 1;
16968 } else {
16969 next = RE_WORD_END.lastIndex - 2;
16970 }
16971 currentToken = [
16972 "word",
16973 css.slice(pos, next + 1),
16974 pos,
16975 next
16976 ];
16977 buffer.push(currentToken);
16978 pos = next;
16979 }
16980 break;
16981 }
16982 }
16983 pos++;
16984 return currentToken;
16985 }
16986 function back(token) {
16987 returned.push(token);
16988 }
16989 return {
16990 back: back,
16991 endOfFile: endOfFile,
16992 nextToken: nextToken,
16993 position: position
16994 };
16995 };
16996 var Container$5 = container;
16997 var AtRule$3 = /*#__PURE__*/ function(Container$5) {
16998 _inherits(AtRule2, Container$5);
16999 function AtRule2(defaults) {
17000 var _this;
17001 _this = Container$5.call(this, defaults) || this;
17002 _this.type = "atrule";
17003 return _this;
17004 }
17005 var _proto = AtRule2.prototype;
17006 _proto.append = function append() {
17007 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
17008 children[_key] = arguments[_key];
17009 }
17010 var _Container$5_prototype_append;
17011 if (!this.proxyOf.nodes) this.nodes = [];
17012 return (_Container$5_prototype_append = Container$5.prototype.append).call.apply(_Container$5_prototype_append, [].concat([
17013 this
17014 ], children));
17015 };
17016 _proto.prepend = function prepend() {
17017 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
17018 children[_key] = arguments[_key];
17019 }
17020 var _Container$5_prototype_prepend;
17021 if (!this.proxyOf.nodes) this.nodes = [];
17022 return (_Container$5_prototype_prepend = Container$5.prototype.prepend).call.apply(_Container$5_prototype_prepend, [].concat([
17023 this
17024 ], children));
17025 };
17026 return AtRule2;
17027 }(Container$5);
17028 var atRule = AtRule$3;
17029 AtRule$3.default = AtRule$3;
17030 Container$5.registerAtRule(AtRule$3);
17031 var Container$4 = container;
17032 var LazyResult$3, Processor$2;
17033 var Root$5 = /*#__PURE__*/ function(Container$4) {
17034 _inherits(Root2, Container$4);
17035 function Root2(defaults) {
17036 var _this;
17037 _this = Container$4.call(this, defaults) || this;
17038 _this.type = "root";
17039 if (!_this.nodes) _this.nodes = [];
17040 return _this;
17041 }
17042 var _proto = Root2.prototype;
17043 _proto.normalize = function normalize(child, sample, type) {
17044 var nodes = Container$4.prototype.normalize.call(this, child);
17045 if (sample) {
17046 if (type === "prepend") {
17047 if (this.nodes.length > 1) {
17048 sample.raws.before = this.nodes[1].raws.before;
17049 } else {
17050 delete sample.raws.before;
17051 }
17052 } else if (this.first !== sample) {
17053 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
17054 var node2 = _step.value;
17055 node2.raws.before = sample.raws.before;
17056 }
17057 }
17058 }
17059 return nodes;
17060 };
17061 _proto.removeChild = function removeChild(child, ignore) {
17062 var index2 = this.index(child);
17063 if (!ignore && index2 === 0 && this.nodes.length > 1) {
17064 this.nodes[1].raws.before = this.nodes[index2].raws.before;
17065 }
17066 return Container$4.prototype.removeChild.call(this, child);
17067 };
17068 _proto.toResult = function toResult(opts) {
17069 if (opts === void 0) opts = {};
17070 var lazy = new LazyResult$3(new Processor$2(), this, opts);
17071 return lazy.stringify();
17072 };
17073 return Root2;
17074 }(Container$4);
17075 Root$5.registerLazyResult = function(dependant) {
17076 LazyResult$3 = dependant;
17077 };
17078 Root$5.registerProcessor = function(dependant) {
17079 Processor$2 = dependant;
17080 };
17081 var root = Root$5;
17082 Root$5.default = Root$5;
17083 Container$4.registerRoot(Root$5);
17084 var list$2 = {
17085 comma: function comma(string) {
17086 return list$2.split(string, [
17087 ","
17088 ], true);
17089 },
17090 space: function space(string) {
17091 var spaces = [
17092 " ",
17093 "\n",
17094 " "
17095 ];
17096 return list$2.split(string, spaces);
17097 },
17098 split: function split(string, separators, last) {
17099 var array = [];
17100 var current = "";
17101 var split = false;
17102 var func = 0;
17103 var inQuote = false;
17104 var prevQuote = "";
17105 var escape = false;
17106 for(var _iterator = _create_for_of_iterator_helper_loose(string), _step; !(_step = _iterator()).done;){
17107 var letter = _step.value;
17108 if (escape) {
17109 escape = false;
17110 } else if (letter === "\\") {
17111 escape = true;
17112 } else if (inQuote) {
17113 if (letter === prevQuote) {
17114 inQuote = false;
17115 }
17116 } else if (letter === '"' || letter === "'") {
17117 inQuote = true;
17118 prevQuote = letter;
17119 } else if (letter === "(") {
17120 func += 1;
17121 } else if (letter === ")") {
17122 if (func > 0) func -= 1;
17123 } else if (func === 0) {
17124 if (separators.includes(letter)) split = true;
17125 }
17126 if (split) {
17127 if (current !== "") array.push(current.trim());
17128 current = "";
17129 split = false;
17130 } else {
17131 current += letter;
17132 }
17133 }
17134 if (last || current !== "") array.push(current.trim());
17135 return array;
17136 }
17137 };
17138 var list_1 = list$2;
17139 list$2.default = list$2;
17140 var Container$3 = container;
17141 var list$1 = list_1;
17142 var Rule$3 = /*#__PURE__*/ function(Container$3) {
17143 _inherits(Rule2, Container$3);
17144 function Rule2(defaults) {
17145 var _this;
17146 _this = Container$3.call(this, defaults) || this;
17147 _this.type = "rule";
17148 if (!_this.nodes) _this.nodes = [];
17149 return _this;
17150 }
17151 _create_class(Rule2, [
17152 {
17153 key: "selectors",
17154 get: function get() {
17155 return list$1.comma(this.selector);
17156 },
17157 set: function set(values) {
17158 var match = this.selector ? this.selector.match(/,\s*/) : null;
17159 var sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen");
17160 this.selector = values.join(sep2);
17161 }
17162 }
17163 ]);
17164 return Rule2;
17165 }(Container$3);
17166 var rule = Rule$3;
17167 Rule$3.default = Rule$3;
17168 Container$3.registerRule(Rule$3);
17169 var Declaration$2 = declaration;
17170 var tokenizer22 = tokenize;
17171 var Comment$2 = comment;
17172 var AtRule$2 = atRule;
17173 var Root$4 = root;
17174 var Rule$2 = rule;
17175 var SAFE_COMMENT_NEIGHBOR = {
17176 empty: true,
17177 space: true
17178 };
17179 function findLastWithPosition(tokens) {
17180 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
17181 var token = tokens[i2];
17182 var pos = token[3] || token[2];
17183 if (pos) return pos;
17184 }
17185 }
17186 var Parser$1 = /*#__PURE__*/ function() {
17187 function Parser2(input2) {
17188 this.input = input2;
17189 this.root = new Root$4();
17190 this.current = this.root;
17191 this.spaces = "";
17192 this.semicolon = false;
17193 this.createTokenizer();
17194 this.root.source = {
17195 input: input2,
17196 start: {
17197 column: 1,
17198 line: 1,
17199 offset: 0
17200 }
17201 };
17202 }
17203 var _proto = Parser2.prototype;
17204 _proto.atrule = function atrule(token) {
17205 var node2 = new AtRule$2();
17206 node2.name = token[1].slice(1);
17207 if (node2.name === "") {
17208 this.unnamedAtrule(node2, token);
17209 }
17210 this.init(node2, token[2]);
17211 var type;
17212 var prev;
17213 var shift;
17214 var last = false;
17215 var open = false;
17216 var params = [];
17217 var brackets = [];
17218 while(!this.tokenizer.endOfFile()){
17219 token = this.tokenizer.nextToken();
17220 type = token[0];
17221 if (type === "(" || type === "[") {
17222 brackets.push(type === "(" ? ")" : "]");
17223 } else if (type === "{" && brackets.length > 0) {
17224 brackets.push("}");
17225 } else if (type === brackets[brackets.length - 1]) {
17226 brackets.pop();
17227 }
17228 if (brackets.length === 0) {
17229 if (type === ";") {
17230 node2.source.end = this.getPosition(token[2]);
17231 node2.source.end.offset++;
17232 this.semicolon = true;
17233 break;
17234 } else if (type === "{") {
17235 open = true;
17236 break;
17237 } else if (type === "}") {
17238 if (params.length > 0) {
17239 shift = params.length - 1;
17240 prev = params[shift];
17241 while(prev && prev[0] === "space"){
17242 prev = params[--shift];
17243 }
17244 if (prev) {
17245 node2.source.end = this.getPosition(prev[3] || prev[2]);
17246 node2.source.end.offset++;
17247 }
17248 }
17249 this.end(token);
17250 break;
17251 } else {
17252 params.push(token);
17253 }
17254 } else {
17255 params.push(token);
17256 }
17257 if (this.tokenizer.endOfFile()) {
17258 last = true;
17259 break;
17260 }
17261 }
17262 node2.raws.between = this.spacesAndCommentsFromEnd(params);
17263 if (params.length) {
17264 node2.raws.afterName = this.spacesAndCommentsFromStart(params);
17265 this.raw(node2, "params", params);
17266 if (last) {
17267 token = params[params.length - 1];
17268 node2.source.end = this.getPosition(token[3] || token[2]);
17269 node2.source.end.offset++;
17270 this.spaces = node2.raws.between;
17271 node2.raws.between = "";
17272 }
17273 } else {
17274 node2.raws.afterName = "";
17275 node2.params = "";
17276 }
17277 if (open) {
17278 node2.nodes = [];
17279 this.current = node2;
17280 }
17281 };
17282 _proto.checkMissedSemicolon = function checkMissedSemicolon(tokens) {
17283 var colon = this.colon(tokens);
17284 if (colon === false) return;
17285 var founded = 0;
17286 var token;
17287 for(var j = colon - 1; j >= 0; j--){
17288 token = tokens[j];
17289 if (token[0] !== "space") {
17290 founded += 1;
17291 if (founded === 2) break;
17292 }
17293 }
17294 throw this.input.error("Missed semicolon", token[0] === "word" ? token[3] + 1 : token[2]);
17295 };
17296 _proto.colon = function colon(tokens) {
17297 var brackets = 0;
17298 var token, type, prev;
17299 for(var _iterator = _create_for_of_iterator_helper_loose(tokens.entries()), _step; !(_step = _iterator()).done;){
17300 var _step_value = _step.value, i2 = _step_value[0], element = _step_value[1];
17301 token = element;
17302 type = token[0];
17303 if (type === "(") {
17304 brackets += 1;
17305 }
17306 if (type === ")") {
17307 brackets -= 1;
17308 }
17309 if (brackets === 0 && type === ":") {
17310 if (!prev) {
17311 this.doubleColon(token);
17312 } else if (prev[0] === "word" && prev[1] === "progid") {
17313 continue;
17314 } else {
17315 return i2;
17316 }
17317 }
17318 prev = token;
17319 }
17320 return false;
17321 };
17322 _proto.comment = function comment(token) {
17323 var node2 = new Comment$2();
17324 this.init(node2, token[2]);
17325 node2.source.end = this.getPosition(token[3] || token[2]);
17326 node2.source.end.offset++;
17327 var text = token[1].slice(2, -2);
17328 if (/^\s*$/.test(text)) {
17329 node2.text = "";
17330 node2.raws.left = text;
17331 node2.raws.right = "";
17332 } else {
17333 var match = text.match(/^(\s*)([^]*\S)(\s*)$/);
17334 node2.text = match[2];
17335 node2.raws.left = match[1];
17336 node2.raws.right = match[3];
17337 }
17338 };
17339 _proto.createTokenizer = function createTokenizer() {
17340 this.tokenizer = tokenizer22(this.input);
17341 };
17342 _proto.decl = function decl(tokens, customProperty) {
17343 var node2 = new Declaration$2();
17344 this.init(node2, tokens[0][2]);
17345 var last = tokens[tokens.length - 1];
17346 if (last[0] === ";") {
17347 this.semicolon = true;
17348 tokens.pop();
17349 }
17350 node2.source.end = this.getPosition(last[3] || last[2] || findLastWithPosition(tokens));
17351 node2.source.end.offset++;
17352 while(tokens[0][0] !== "word"){
17353 if (tokens.length === 1) this.unknownWord(tokens);
17354 node2.raws.before += tokens.shift()[1];
17355 }
17356 node2.source.start = this.getPosition(tokens[0][2]);
17357 node2.prop = "";
17358 while(tokens.length){
17359 var type = tokens[0][0];
17360 if (type === ":" || type === "space" || type === "comment") {
17361 break;
17362 }
17363 node2.prop += tokens.shift()[1];
17364 }
17365 node2.raws.between = "";
17366 var token;
17367 while(tokens.length){
17368 token = tokens.shift();
17369 if (token[0] === ":") {
17370 node2.raws.between += token[1];
17371 break;
17372 } else {
17373 if (token[0] === "word" && /\w/.test(token[1])) {
17374 this.unknownWord([
17375 token
17376 ]);
17377 }
17378 node2.raws.between += token[1];
17379 }
17380 }
17381 if (node2.prop[0] === "_" || node2.prop[0] === "*") {
17382 node2.raws.before += node2.prop[0];
17383 node2.prop = node2.prop.slice(1);
17384 }
17385 var firstSpaces = [];
17386 var next;
17387 while(tokens.length){
17388 next = tokens[0][0];
17389 if (next !== "space" && next !== "comment") break;
17390 firstSpaces.push(tokens.shift());
17391 }
17392 this.precheckMissedSemicolon(tokens);
17393 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
17394 token = tokens[i2];
17395 if (token[1].toLowerCase() === "!important") {
17396 node2.important = true;
17397 var string = this.stringFrom(tokens, i2);
17398 string = this.spacesFromEnd(tokens) + string;
17399 if (string !== " !important") node2.raws.important = string;
17400 break;
17401 } else if (token[1].toLowerCase() === "important") {
17402 var cache = tokens.slice(0);
17403 var str = "";
17404 for(var j = i2; j > 0; j--){
17405 var type1 = cache[j][0];
17406 if (str.trim().indexOf("!") === 0 && type1 !== "space") {
17407 break;
17408 }
17409 str = cache.pop()[1] + str;
17410 }
17411 if (str.trim().indexOf("!") === 0) {
17412 node2.important = true;
17413 node2.raws.important = str;
17414 tokens = cache;
17415 }
17416 }
17417 if (token[0] !== "space" && token[0] !== "comment") {
17418 break;
17419 }
17420 }
17421 var hasWord = tokens.some(function(i2) {
17422 return i2[0] !== "space" && i2[0] !== "comment";
17423 });
17424 if (hasWord) {
17425 node2.raws.between += firstSpaces.map(function(i2) {
17426 return i2[1];
17427 }).join("");
17428 firstSpaces = [];
17429 }
17430 this.raw(node2, "value", firstSpaces.concat(tokens), customProperty);
17431 if (node2.value.includes(":") && !customProperty) {
17432 this.checkMissedSemicolon(tokens);
17433 }
17434 };
17435 _proto.doubleColon = function doubleColon(token) {
17436 throw this.input.error("Double colon", {
17437 offset: token[2]
17438 }, {
17439 offset: token[2] + token[1].length
17440 });
17441 };
17442 _proto.emptyRule = function emptyRule(token) {
17443 var node2 = new Rule$2();
17444 this.init(node2, token[2]);
17445 node2.selector = "";
17446 node2.raws.between = "";
17447 this.current = node2;
17448 };
17449 _proto.end = function end(token) {
17450 if (this.current.nodes && this.current.nodes.length) {
17451 this.current.raws.semicolon = this.semicolon;
17452 }
17453 this.semicolon = false;
17454 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
17455 this.spaces = "";
17456 if (this.current.parent) {
17457 this.current.source.end = this.getPosition(token[2]);
17458 this.current.source.end.offset++;
17459 this.current = this.current.parent;
17460 } else {
17461 this.unexpectedClose(token);
17462 }
17463 };
17464 _proto.endFile = function endFile() {
17465 if (this.current.parent) this.unclosedBlock();
17466 if (this.current.nodes && this.current.nodes.length) {
17467 this.current.raws.semicolon = this.semicolon;
17468 }
17469 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
17470 this.root.source.end = this.getPosition(this.tokenizer.position());
17471 };
17472 _proto.freeSemicolon = function freeSemicolon(token) {
17473 this.spaces += token[1];
17474 if (this.current.nodes) {
17475 var prev = this.current.nodes[this.current.nodes.length - 1];
17476 if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
17477 prev.raws.ownSemicolon = this.spaces;
17478 this.spaces = "";
17479 }
17480 }
17481 };
17482 // Helpers
17483 _proto.getPosition = function getPosition(offset) {
17484 var pos = this.input.fromOffset(offset);
17485 return {
17486 column: pos.col,
17487 line: pos.line,
17488 offset: offset
17489 };
17490 };
17491 _proto.init = function init(node2, offset) {
17492 this.current.push(node2);
17493 node2.source = {
17494 input: this.input,
17495 start: this.getPosition(offset)
17496 };
17497 node2.raws.before = this.spaces;
17498 this.spaces = "";
17499 if (node2.type !== "comment") this.semicolon = false;
17500 };
17501 _proto.other = function other(start) {
17502 var end = false;
17503 var type = null;
17504 var colon = false;
17505 var bracket = null;
17506 var brackets = [];
17507 var customProperty = start[1].startsWith("--");
17508 var tokens = [];
17509 var token = start;
17510 while(token){
17511 type = token[0];
17512 tokens.push(token);
17513 if (type === "(" || type === "[") {
17514 if (!bracket) bracket = token;
17515 brackets.push(type === "(" ? ")" : "]");
17516 } else if (customProperty && colon && type === "{") {
17517 if (!bracket) bracket = token;
17518 brackets.push("}");
17519 } else if (brackets.length === 0) {
17520 if (type === ";") {
17521 if (colon) {
17522 this.decl(tokens, customProperty);
17523 return;
17524 } else {
17525 break;
17526 }
17527 } else if (type === "{") {
17528 this.rule(tokens);
17529 return;
17530 } else if (type === "}") {
17531 this.tokenizer.back(tokens.pop());
17532 end = true;
17533 break;
17534 } else if (type === ":") {
17535 colon = true;
17536 }
17537 } else if (type === brackets[brackets.length - 1]) {
17538 brackets.pop();
17539 if (brackets.length === 0) bracket = null;
17540 }
17541 token = this.tokenizer.nextToken();
17542 }
17543 if (this.tokenizer.endOfFile()) end = true;
17544 if (brackets.length > 0) this.unclosedBracket(bracket);
17545 if (end && colon) {
17546 if (!customProperty) {
17547 while(tokens.length){
17548 token = tokens[tokens.length - 1][0];
17549 if (token !== "space" && token !== "comment") break;
17550 this.tokenizer.back(tokens.pop());
17551 }
17552 }
17553 this.decl(tokens, customProperty);
17554 } else {
17555 this.unknownWord(tokens);
17556 }
17557 };
17558 _proto.parse = function parse() {
17559 var token;
17560 while(!this.tokenizer.endOfFile()){
17561 token = this.tokenizer.nextToken();
17562 switch(token[0]){
17563 case "space":
17564 this.spaces += token[1];
17565 break;
17566 case ";":
17567 this.freeSemicolon(token);
17568 break;
17569 case "}":
17570 this.end(token);
17571 break;
17572 case "comment":
17573 this.comment(token);
17574 break;
17575 case "at-word":
17576 this.atrule(token);
17577 break;
17578 case "{":
17579 this.emptyRule(token);
17580 break;
17581 default:
17582 this.other(token);
17583 break;
17584 }
17585 }
17586 this.endFile();
17587 };
17588 _proto.precheckMissedSemicolon = function precheckMissedSemicolon() {};
17589 _proto.raw = function raw(node2, prop, tokens, customProperty) {
17590 var token, type;
17591 var length = tokens.length;
17592 var value = "";
17593 var clean = true;
17594 var next, prev;
17595 for(var i2 = 0; i2 < length; i2 += 1){
17596 token = tokens[i2];
17597 type = token[0];
17598 if (type === "space" && i2 === length - 1 && !customProperty) {
17599 clean = false;
17600 } else if (type === "comment") {
17601 prev = tokens[i2 - 1] ? tokens[i2 - 1][0] : "empty";
17602 next = tokens[i2 + 1] ? tokens[i2 + 1][0] : "empty";
17603 if (!SAFE_COMMENT_NEIGHBOR[prev] && !SAFE_COMMENT_NEIGHBOR[next]) {
17604 if (value.slice(-1) === ",") {
17605 clean = false;
17606 } else {
17607 value += token[1];
17608 }
17609 } else {
17610 clean = false;
17611 }
17612 } else {
17613 value += token[1];
17614 }
17615 }
17616 if (!clean) {
17617 var raw = tokens.reduce(function(all, i2) {
17618 return all + i2[1];
17619 }, "");
17620 node2.raws[prop] = {
17621 raw: raw,
17622 value: value
17623 };
17624 }
17625 node2[prop] = value;
17626 };
17627 _proto.rule = function rule(tokens) {
17628 tokens.pop();
17629 var node2 = new Rule$2();
17630 this.init(node2, tokens[0][2]);
17631 node2.raws.between = this.spacesAndCommentsFromEnd(tokens);
17632 this.raw(node2, "selector", tokens);
17633 this.current = node2;
17634 };
17635 _proto.spacesAndCommentsFromEnd = function spacesAndCommentsFromEnd(tokens) {
17636 var lastTokenType;
17637 var spaces = "";
17638 while(tokens.length){
17639 lastTokenType = tokens[tokens.length - 1][0];
17640 if (lastTokenType !== "space" && lastTokenType !== "comment") break;
17641 spaces = tokens.pop()[1] + spaces;
17642 }
17643 return spaces;
17644 };
17645 // Errors
17646 _proto.spacesAndCommentsFromStart = function spacesAndCommentsFromStart(tokens) {
17647 var next;
17648 var spaces = "";
17649 while(tokens.length){
17650 next = tokens[0][0];
17651 if (next !== "space" && next !== "comment") break;
17652 spaces += tokens.shift()[1];
17653 }
17654 return spaces;
17655 };
17656 _proto.spacesFromEnd = function spacesFromEnd(tokens) {
17657 var lastTokenType;
17658 var spaces = "";
17659 while(tokens.length){
17660 lastTokenType = tokens[tokens.length - 1][0];
17661 if (lastTokenType !== "space") break;
17662 spaces = tokens.pop()[1] + spaces;
17663 }
17664 return spaces;
17665 };
17666 _proto.stringFrom = function stringFrom(tokens, from) {
17667 var result2 = "";
17668 for(var i2 = from; i2 < tokens.length; i2++){
17669 result2 += tokens[i2][1];
17670 }
17671 tokens.splice(from, tokens.length - from);
17672 return result2;
17673 };
17674 _proto.unclosedBlock = function unclosedBlock() {
17675 var pos = this.current.source.start;
17676 throw this.input.error("Unclosed block", pos.line, pos.column);
17677 };
17678 _proto.unclosedBracket = function unclosedBracket(bracket) {
17679 throw this.input.error("Unclosed bracket", {
17680 offset: bracket[2]
17681 }, {
17682 offset: bracket[2] + 1
17683 });
17684 };
17685 _proto.unexpectedClose = function unexpectedClose(token) {
17686 throw this.input.error("Unexpected }", {
17687 offset: token[2]
17688 }, {
17689 offset: token[2] + 1
17690 });
17691 };
17692 _proto.unknownWord = function unknownWord(tokens) {
17693 throw this.input.error("Unknown word", {
17694 offset: tokens[0][2]
17695 }, {
17696 offset: tokens[0][2] + tokens[0][1].length
17697 });
17698 };
17699 _proto.unnamedAtrule = function unnamedAtrule(node2, token) {
17700 throw this.input.error("At-rule without name", {
17701 offset: token[2]
17702 }, {
17703 offset: token[2] + token[1].length
17704 });
17705 };
17706 return Parser2;
17707 }();
17708 var parser = Parser$1;
17709 var Container$2 = container;
17710 var Parser22 = parser;
17711 var Input$2 = input;
17712 function parse$3(css, opts) {
17713 var input2 = new Input$2(css, opts);
17714 var parser2 = new Parser22(input2);
17715 try {
17716 parser2.parse();
17717 } catch (e2) {
17718 if (true) {
17719 if (e2.name === "CssSyntaxError" && opts && opts.from) {
17720 if (/\.scss$/i.test(opts.from)) {
17721 e2.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser";
17722 } else if (/\.sass/i.test(opts.from)) {
17723 e2.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser";
17724 } else if (/\.less$/i.test(opts.from)) {
17725 e2.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser";
17726 }
17727 }
17728 }
17729 throw e2;
17730 }
17731 return parser2.root;
17732 }
17733 var parse_1 = parse$3;
17734 parse$3.default = parse$3;
17735 Container$2.registerParse(parse$3);
17736 var isClean = symbols.isClean, my = symbols.my;
17737 var MapGenerator$1 = mapGenerator;
17738 var stringify$2 = stringify_1;
17739 var Container$1 = container;
17740 var Document$2 = document$1$2;
17741 var warnOnce$1 = warnOnce$2;
17742 var Result$2 = result;
17743 var parse$2 = parse_1;
17744 var Root$3 = root;
17745 var TYPE_TO_CLASS_NAME = {
17746 atrule: "AtRule",
17747 comment: "Comment",
17748 decl: "Declaration",
17749 document: "Document",
17750 root: "Root",
17751 rule: "Rule"
17752 };
17753 var PLUGIN_PROPS = {
17754 AtRule: true,
17755 AtRuleExit: true,
17756 Comment: true,
17757 CommentExit: true,
17758 Declaration: true,
17759 DeclarationExit: true,
17760 Document: true,
17761 DocumentExit: true,
17762 Once: true,
17763 OnceExit: true,
17764 postcssPlugin: true,
17765 prepare: true,
17766 Root: true,
17767 RootExit: true,
17768 Rule: true,
17769 RuleExit: true
17770 };
17771 var NOT_VISITORS = {
17772 Once: true,
17773 postcssPlugin: true,
17774 prepare: true
17775 };
17776 var CHILDREN = 0;
17777 function isPromise(obj) {
17778 return (typeof obj === "undefined" ? "undefined" : _type_of(obj)) === "object" && typeof obj.then === "function";
17779 }
17780 function getEvents(node2) {
17781 var key = false;
17782 var type = TYPE_TO_CLASS_NAME[node2.type];
17783 if (node2.type === "decl") {
17784 key = node2.prop.toLowerCase();
17785 } else if (node2.type === "atrule") {
17786 key = node2.name.toLowerCase();
17787 }
17788 if (key && node2.append) {
17789 return [
17790 type,
17791 type + "-" + key,
17792 CHILDREN,
17793 type + "Exit",
17794 type + "Exit-" + key
17795 ];
17796 } else if (key) {
17797 return [
17798 type,
17799 type + "-" + key,
17800 type + "Exit",
17801 type + "Exit-" + key
17802 ];
17803 } else if (node2.append) {
17804 return [
17805 type,
17806 CHILDREN,
17807 type + "Exit"
17808 ];
17809 } else {
17810 return [
17811 type,
17812 type + "Exit"
17813 ];
17814 }
17815 }
17816 function toStack(node2) {
17817 var events;
17818 if (node2.type === "document") {
17819 events = [
17820 "Document",
17821 CHILDREN,
17822 "DocumentExit"
17823 ];
17824 } else if (node2.type === "root") {
17825 events = [
17826 "Root",
17827 CHILDREN,
17828 "RootExit"
17829 ];
17830 } else {
17831 events = getEvents(node2);
17832 }
17833 return {
17834 eventIndex: 0,
17835 events: events,
17836 iterator: 0,
17837 node: node2,
17838 visitorIndex: 0,
17839 visitors: []
17840 };
17841 }
17842 function cleanMarks(node2) {
17843 node2[isClean] = false;
17844 if (node2.nodes) node2.nodes.forEach(function(i2) {
17845 return cleanMarks(i2);
17846 });
17847 return node2;
17848 }
17849 var postcss$2 = {};
17850 var LazyResult$2 = /*#__PURE__*/ function() {
17851 function LazyResult2(processor2, css, opts) {
17852 var _this = this;
17853 this.stringified = false;
17854 this.processed = false;
17855 var root2;
17856 if ((typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && css !== null && (css.type === "root" || css.type === "document")) {
17857 root2 = cleanMarks(css);
17858 } else if (_instanceof(css, LazyResult2) || _instanceof(css, Result$2)) {
17859 root2 = cleanMarks(css.root);
17860 if (css.map) {
17861 if (typeof opts.map === "undefined") opts.map = {};
17862 if (!opts.map.inline) opts.map.inline = false;
17863 opts.map.prev = css.map;
17864 }
17865 } else {
17866 var parser2 = parse$2;
17867 if (opts.syntax) parser2 = opts.syntax.parse;
17868 if (opts.parser) parser2 = opts.parser;
17869 if (parser2.parse) parser2 = parser2.parse;
17870 try {
17871 root2 = parser2(css, opts);
17872 } catch (error) {
17873 this.processed = true;
17874 this.error = error;
17875 }
17876 if (root2 && !root2[my]) {
17877 Container$1.rebuild(root2);
17878 }
17879 }
17880 this.result = new Result$2(processor2, root2, opts);
17881 this.helpers = _extends({}, postcss$2, {
17882 postcss: postcss$2,
17883 result: this.result
17884 });
17885 this.plugins = this.processor.plugins.map(function(plugin22) {
17886 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.prepare) {
17887 return _extends({}, plugin22, plugin22.prepare(_this.result));
17888 } else {
17889 return plugin22;
17890 }
17891 });
17892 }
17893 var _proto = LazyResult2.prototype;
17894 _proto.async = function async() {
17895 if (this.error) return Promise.reject(this.error);
17896 if (this.processed) return Promise.resolve(this.result);
17897 if (!this.processing) {
17898 this.processing = this.runAsync();
17899 }
17900 return this.processing;
17901 };
17902 _proto.catch = function _catch(onRejected) {
17903 return this.async().catch(onRejected);
17904 };
17905 _proto.finally = function _finally(onFinally) {
17906 return this.async().then(onFinally, onFinally);
17907 };
17908 _proto.getAsyncError = function getAsyncError() {
17909 throw new Error("Use process(css).then(cb) to work with async plugins");
17910 };
17911 _proto.handleError = function handleError(error, node2) {
17912 var plugin22 = this.result.lastPlugin;
17913 try {
17914 if (node2) node2.addToError(error);
17915 this.error = error;
17916 if (error.name === "CssSyntaxError" && !error.plugin) {
17917 error.plugin = plugin22.postcssPlugin;
17918 error.setMessage();
17919 } else if (plugin22.postcssVersion) {
17920 if (true) {
17921 var pluginName = plugin22.postcssPlugin;
17922 var pluginVer = plugin22.postcssVersion;
17923 var runtimeVer = this.result.processor.version;
17924 var a2 = pluginVer.split(".");
17925 var b = runtimeVer.split(".");
17926 if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) {
17927 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.");
17928 }
17929 }
17930 }
17931 } catch (err) {
17932 if (console && console.error) console.error(err);
17933 }
17934 return error;
17935 };
17936 _proto.prepareVisitors = function prepareVisitors() {
17937 var _this = this;
17938 this.listeners = {};
17939 var add = function(plugin22, type, cb) {
17940 if (!_this.listeners[type]) _this.listeners[type] = [];
17941 _this.listeners[type].push([
17942 plugin22,
17943 cb
17944 ]);
17945 };
17946 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
17947 var plugin22 = _step.value;
17948 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object") {
17949 for(var event in plugin22){
17950 if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) {
17951 throw new Error("Unknown event " + event + " in " + plugin22.postcssPlugin + ". Try to update PostCSS (" + this.processor.version + " now).");
17952 }
17953 if (!NOT_VISITORS[event]) {
17954 if (_type_of(plugin22[event]) === "object") {
17955 for(var filter in plugin22[event]){
17956 if (filter === "*") {
17957 add(plugin22, event, plugin22[event][filter]);
17958 } else {
17959 add(plugin22, event + "-" + filter.toLowerCase(), plugin22[event][filter]);
17960 }
17961 }
17962 } else if (typeof plugin22[event] === "function") {
17963 add(plugin22, event, plugin22[event]);
17964 }
17965 }
17966 }
17967 }
17968 }
17969 this.hasListener = Object.keys(this.listeners).length > 0;
17970 };
17971 _proto.runAsync = function runAsync() {
17972 var _this = this;
17973 return _async_to_generator(function() {
17974 var i2, plugin22, promise, error, root2, stack, promise1, e2, node2, _loop, _iterator, _step;
17975 return _ts_generator(this, function(_state) {
17976 switch(_state.label){
17977 case 0:
17978 _this.plugin = 0;
17979 i2 = 0;
17980 _state.label = 1;
17981 case 1:
17982 if (!(i2 < _this.plugins.length)) return [
17983 3,
17984 6
17985 ];
17986 plugin22 = _this.plugins[i2];
17987 promise = _this.runOnRoot(plugin22);
17988 if (!isPromise(promise)) return [
17989 3,
17990 5
17991 ];
17992 _state.label = 2;
17993 case 2:
17994 _state.trys.push([
17995 2,
17996 4,
17997 ,
17998 5
17999 ]);
18000 return [
18001 4,
18002 promise
18003 ];
18004 case 3:
18005 _state.sent();
18006 return [
18007 3,
18008 5
18009 ];
18010 case 4:
18011 error = _state.sent();
18012 throw _this.handleError(error);
18013 case 5:
18014 i2++;
18015 return [
18016 3,
18017 1
18018 ];
18019 case 6:
18020 _this.prepareVisitors();
18021 if (!_this.hasListener) return [
18022 3,
18023 18
18024 ];
18025 root2 = _this.result.root;
18026 _state.label = 7;
18027 case 7:
18028 if (!!root2[isClean]) return [
18029 3,
18030 14
18031 ];
18032 root2[isClean] = true;
18033 stack = [
18034 toStack(root2)
18035 ];
18036 _state.label = 8;
18037 case 8:
18038 if (!(stack.length > 0)) return [
18039 3,
18040 13
18041 ];
18042 promise1 = _this.visitTick(stack);
18043 if (!isPromise(promise1)) return [
18044 3,
18045 12
18046 ];
18047 _state.label = 9;
18048 case 9:
18049 _state.trys.push([
18050 9,
18051 11,
18052 ,
18053 12
18054 ]);
18055 return [
18056 4,
18057 promise1
18058 ];
18059 case 10:
18060 _state.sent();
18061 return [
18062 3,
18063 12
18064 ];
18065 case 11:
18066 e2 = _state.sent();
18067 node2 = stack[stack.length - 1].node;
18068 throw _this.handleError(e2, node2);
18069 case 12:
18070 return [
18071 3,
18072 8
18073 ];
18074 case 13:
18075 return [
18076 3,
18077 7
18078 ];
18079 case 14:
18080 if (!_this.listeners.OnceExit) return [
18081 3,
18082 18
18083 ];
18084 _loop = function() {
18085 var _step_value, plugin22, visitor, roots, e2;
18086 return _ts_generator(this, function(_state) {
18087 switch(_state.label){
18088 case 0:
18089 _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
18090 _this.result.lastPlugin = plugin22;
18091 _state.label = 1;
18092 case 1:
18093 _state.trys.push([
18094 1,
18095 6,
18096 ,
18097 7
18098 ]);
18099 if (!(root2.type === "document")) return [
18100 3,
18101 3
18102 ];
18103 roots = root2.nodes.map(function(subRoot) {
18104 return visitor(subRoot, _this.helpers);
18105 });
18106 return [
18107 4,
18108 Promise.all(roots)
18109 ];
18110 case 2:
18111 _state.sent();
18112 return [
18113 3,
18114 5
18115 ];
18116 case 3:
18117 return [
18118 4,
18119 visitor(root2, _this.helpers)
18120 ];
18121 case 4:
18122 _state.sent();
18123 _state.label = 5;
18124 case 5:
18125 return [
18126 3,
18127 7
18128 ];
18129 case 6:
18130 e2 = _state.sent();
18131 throw _this.handleError(e2);
18132 case 7:
18133 return [
18134 2
18135 ];
18136 }
18137 });
18138 };
18139 _iterator = _create_for_of_iterator_helper_loose(_this.listeners.OnceExit);
18140 _state.label = 15;
18141 case 15:
18142 if (!!(_step = _iterator()).done) return [
18143 3,
18144 18
18145 ];
18146 return [
18147 5,
18148 _ts_values(_loop())
18149 ];
18150 case 16:
18151 _state.sent();
18152 _state.label = 17;
18153 case 17:
18154 return [
18155 3,
18156 15
18157 ];
18158 case 18:
18159 _this.processed = true;
18160 return [
18161 2,
18162 _this.stringify()
18163 ];
18164 }
18165 });
18166 })();
18167 };
18168 _proto.runOnRoot = function runOnRoot(plugin22) {
18169 var _this = this;
18170 this.result.lastPlugin = plugin22;
18171 try {
18172 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.Once) {
18173 if (this.result.root.type === "document") {
18174 var roots = this.result.root.nodes.map(function(root2) {
18175 return plugin22.Once(root2, _this.helpers);
18176 });
18177 if (isPromise(roots[0])) {
18178 return Promise.all(roots);
18179 }
18180 return roots;
18181 }
18182 return plugin22.Once(this.result.root, this.helpers);
18183 } else if (typeof plugin22 === "function") {
18184 return plugin22(this.result.root, this.result);
18185 }
18186 } catch (error) {
18187 throw this.handleError(error);
18188 }
18189 };
18190 _proto.stringify = function stringify() {
18191 if (this.error) throw this.error;
18192 if (this.stringified) return this.result;
18193 this.stringified = true;
18194 this.sync();
18195 var opts = this.result.opts;
18196 var str = stringify$2;
18197 if (opts.syntax) str = opts.syntax.stringify;
18198 if (opts.stringifier) str = opts.stringifier;
18199 if (str.stringify) str = str.stringify;
18200 var map = new MapGenerator$1(str, this.result.root, this.result.opts);
18201 var data = map.generate();
18202 this.result.css = data[0];
18203 this.result.map = data[1];
18204 return this.result;
18205 };
18206 _proto.sync = function sync() {
18207 if (this.error) throw this.error;
18208 if (this.processed) return this.result;
18209 this.processed = true;
18210 if (this.processing) {
18211 throw this.getAsyncError();
18212 }
18213 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
18214 var plugin22 = _step.value;
18215 var promise = this.runOnRoot(plugin22);
18216 if (isPromise(promise)) {
18217 throw this.getAsyncError();
18218 }
18219 }
18220 this.prepareVisitors();
18221 if (this.hasListener) {
18222 var root2 = this.result.root;
18223 while(!root2[isClean]){
18224 root2[isClean] = true;
18225 this.walkSync(root2);
18226 }
18227 if (this.listeners.OnceExit) {
18228 if (root2.type === "document") {
18229 for(var _iterator1 = _create_for_of_iterator_helper_loose(root2.nodes), _step1; !(_step1 = _iterator1()).done;){
18230 var subRoot = _step1.value;
18231 this.visitSync(this.listeners.OnceExit, subRoot);
18232 }
18233 } else {
18234 this.visitSync(this.listeners.OnceExit, root2);
18235 }
18236 }
18237 }
18238 return this.result;
18239 };
18240 _proto.then = function then(onFulfilled, onRejected) {
18241 if (true) {
18242 if (!("from" in this.opts)) {
18243 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.");
18244 }
18245 }
18246 return this.async().then(onFulfilled, onRejected);
18247 };
18248 _proto.toString = function toString() {
18249 return this.css;
18250 };
18251 _proto.visitSync = function visitSync(visitors, node2) {
18252 for(var _iterator = _create_for_of_iterator_helper_loose(visitors), _step; !(_step = _iterator()).done;){
18253 var _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
18254 this.result.lastPlugin = plugin22;
18255 var promise = void 0;
18256 try {
18257 promise = visitor(node2, this.helpers);
18258 } catch (e2) {
18259 throw this.handleError(e2, node2.proxyOf);
18260 }
18261 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
18262 return true;
18263 }
18264 if (isPromise(promise)) {
18265 throw this.getAsyncError();
18266 }
18267 }
18268 };
18269 _proto.visitTick = function visitTick(stack) {
18270 var visit2 = stack[stack.length - 1];
18271 var node2 = visit2.node, visitors = visit2.visitors;
18272 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
18273 stack.pop();
18274 return;
18275 }
18276 if (visitors.length > 0 && visit2.visitorIndex < visitors.length) {
18277 var _visitors_visit2_visitorIndex = visitors[visit2.visitorIndex], plugin22 = _visitors_visit2_visitorIndex[0], visitor = _visitors_visit2_visitorIndex[1];
18278 visit2.visitorIndex += 1;
18279 if (visit2.visitorIndex === visitors.length) {
18280 visit2.visitors = [];
18281 visit2.visitorIndex = 0;
18282 }
18283 this.result.lastPlugin = plugin22;
18284 try {
18285 return visitor(node2.toProxy(), this.helpers);
18286 } catch (e2) {
18287 throw this.handleError(e2, node2);
18288 }
18289 }
18290 if (visit2.iterator !== 0) {
18291 var iterator = visit2.iterator;
18292 var child;
18293 while(child = node2.nodes[node2.indexes[iterator]]){
18294 node2.indexes[iterator] += 1;
18295 if (!child[isClean]) {
18296 child[isClean] = true;
18297 stack.push(toStack(child));
18298 return;
18299 }
18300 }
18301 visit2.iterator = 0;
18302 delete node2.indexes[iterator];
18303 }
18304 var events = visit2.events;
18305 while(visit2.eventIndex < events.length){
18306 var event = events[visit2.eventIndex];
18307 visit2.eventIndex += 1;
18308 if (event === CHILDREN) {
18309 if (node2.nodes && node2.nodes.length) {
18310 node2[isClean] = true;
18311 visit2.iterator = node2.getIterator();
18312 }
18313 return;
18314 } else if (this.listeners[event]) {
18315 visit2.visitors = this.listeners[event];
18316 return;
18317 }
18318 }
18319 stack.pop();
18320 };
18321 _proto.walkSync = function walkSync(node2) {
18322 var _this = this;
18323 node2[isClean] = true;
18324 var events = getEvents(node2);
18325 for(var _iterator = _create_for_of_iterator_helper_loose(events), _step; !(_step = _iterator()).done;){
18326 var event = _step.value;
18327 if (event === CHILDREN) {
18328 if (node2.nodes) {
18329 node2.each(function(child) {
18330 if (!child[isClean]) _this.walkSync(child);
18331 });
18332 }
18333 } else {
18334 var visitors = this.listeners[event];
18335 if (visitors) {
18336 if (this.visitSync(visitors, node2.toProxy())) return;
18337 }
18338 }
18339 }
18340 };
18341 _proto.warnings = function warnings() {
18342 return this.sync().warnings();
18343 };
18344 _create_class(LazyResult2, [
18345 {
18346 key: "content",
18347 get: function get() {
18348 return this.stringify().content;
18349 }
18350 },
18351 {
18352 key: "css",
18353 get: function get() {
18354 return this.stringify().css;
18355 }
18356 },
18357 {
18358 key: "map",
18359 get: function get() {
18360 return this.stringify().map;
18361 }
18362 },
18363 {
18364 key: "messages",
18365 get: function get() {
18366 return this.sync().messages;
18367 }
18368 },
18369 {
18370 key: "opts",
18371 get: function get() {
18372 return this.result.opts;
18373 }
18374 },
18375 {
18376 key: "processor",
18377 get: function get() {
18378 return this.result.processor;
18379 }
18380 },
18381 {
18382 key: "root",
18383 get: function get() {
18384 return this.sync().root;
18385 }
18386 },
18387 {
18388 key: Symbol.toStringTag,
18389 get: function get() {
18390 return "LazyResult";
18391 }
18392 }
18393 ]);
18394 return LazyResult2;
18395 }();
18396 LazyResult$2.registerPostcss = function(dependant) {
18397 postcss$2 = dependant;
18398 };
18399 var lazyResult = LazyResult$2;
18400 LazyResult$2.default = LazyResult$2;
18401 Root$3.registerLazyResult(LazyResult$2);
18402 Document$2.registerLazyResult(LazyResult$2);
18403 var MapGenerator22 = mapGenerator;
18404 var stringify$1 = stringify_1;
18405 var warnOnce22 = warnOnce$2;
18406 var parse$1 = parse_1;
18407 var Result$1 = result;
18408 var NoWorkResult$1 = /*#__PURE__*/ function() {
18409 function NoWorkResult2(processor2, css, opts) {
18410 css = css.toString();
18411 this.stringified = false;
18412 this._processor = processor2;
18413 this._css = css;
18414 this._opts = opts;
18415 this._map = void 0;
18416 var root2;
18417 var str = stringify$1;
18418 this.result = new Result$1(this._processor, root2, this._opts);
18419 this.result.css = css;
18420 var self = this;
18421 Object.defineProperty(this.result, "root", {
18422 get: function get() {
18423 return self.root;
18424 }
18425 });
18426 var map = new MapGenerator22(str, root2, this._opts, css);
18427 if (map.isMap()) {
18428 var _map_generate = map.generate(), generatedCSS = _map_generate[0], generatedMap = _map_generate[1];
18429 if (generatedCSS) {
18430 this.result.css = generatedCSS;
18431 }
18432 if (generatedMap) {
18433 this.result.map = generatedMap;
18434 }
18435 } else {
18436 map.clearAnnotation();
18437 this.result.css = map.css;
18438 }
18439 }
18440 var _proto = NoWorkResult2.prototype;
18441 _proto.async = function async() {
18442 if (this.error) return Promise.reject(this.error);
18443 return Promise.resolve(this.result);
18444 };
18445 _proto.catch = function _catch(onRejected) {
18446 return this.async().catch(onRejected);
18447 };
18448 _proto.finally = function _finally(onFinally) {
18449 return this.async().then(onFinally, onFinally);
18450 };
18451 _proto.sync = function sync() {
18452 if (this.error) throw this.error;
18453 return this.result;
18454 };
18455 _proto.then = function then(onFulfilled, onRejected) {
18456 if (true) {
18457 if (!("from" in this._opts)) {
18458 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.");
18459 }
18460 }
18461 return this.async().then(onFulfilled, onRejected);
18462 };
18463 _proto.toString = function toString() {
18464 return this._css;
18465 };
18466 _proto.warnings = function warnings() {
18467 return [];
18468 };
18469 _create_class(NoWorkResult2, [
18470 {
18471 key: "content",
18472 get: function get() {
18473 return this.result.css;
18474 }
18475 },
18476 {
18477 key: "css",
18478 get: function get() {
18479 return this.result.css;
18480 }
18481 },
18482 {
18483 key: "map",
18484 get: function get() {
18485 return this.result.map;
18486 }
18487 },
18488 {
18489 key: "messages",
18490 get: function get() {
18491 return [];
18492 }
18493 },
18494 {
18495 key: "opts",
18496 get: function get() {
18497 return this.result.opts;
18498 }
18499 },
18500 {
18501 key: "processor",
18502 get: function get() {
18503 return this.result.processor;
18504 }
18505 },
18506 {
18507 key: "root",
18508 get: function get() {
18509 if (this._root) {
18510 return this._root;
18511 }
18512 var root2;
18513 var parser2 = parse$1;
18514 try {
18515 root2 = parser2(this._css, this._opts);
18516 } catch (error) {
18517 this.error = error;
18518 }
18519 if (this.error) {
18520 throw this.error;
18521 } else {
18522 this._root = root2;
18523 return root2;
18524 }
18525 }
18526 },
18527 {
18528 key: Symbol.toStringTag,
18529 get: function get() {
18530 return "NoWorkResult";
18531 }
18532 }
18533 ]);
18534 return NoWorkResult2;
18535 }();
18536 var noWorkResult = NoWorkResult$1;
18537 NoWorkResult$1.default = NoWorkResult$1;
18538 var NoWorkResult22 = noWorkResult;
18539 var LazyResult$1 = lazyResult;
18540 var Document$1 = document$1$2;
18541 var Root$2 = root;
18542 var Processor$1 = /*#__PURE__*/ function() {
18543 function Processor2(plugins) {
18544 if (plugins === void 0) plugins = [];
18545 this.version = "8.4.38";
18546 this.plugins = this.normalize(plugins);
18547 }
18548 var _proto = Processor2.prototype;
18549 _proto.normalize = function normalize(plugins) {
18550 var normalized = [];
18551 for(var _iterator = _create_for_of_iterator_helper_loose(plugins), _step; !(_step = _iterator()).done;){
18552 var i2 = _step.value;
18553 if (i2.postcss === true) {
18554 i2 = i2();
18555 } else if (i2.postcss) {
18556 i2 = i2.postcss;
18557 }
18558 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && Array.isArray(i2.plugins)) {
18559 normalized = normalized.concat(i2.plugins);
18560 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.postcssPlugin) {
18561 normalized.push(i2);
18562 } else if (typeof i2 === "function") {
18563 normalized.push(i2);
18564 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && (i2.parse || i2.stringify)) {
18565 if (true) {
18566 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.");
18567 }
18568 } else {
18569 throw new Error(i2 + " is not a PostCSS plugin");
18570 }
18571 }
18572 return normalized;
18573 };
18574 _proto.process = function process1(css, opts) {
18575 if (opts === void 0) opts = {};
18576 if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) {
18577 return new NoWorkResult22(this, css, opts);
18578 } else {
18579 return new LazyResult$1(this, css, opts);
18580 }
18581 };
18582 _proto.use = function use(plugin22) {
18583 this.plugins = this.plugins.concat(this.normalize([
18584 plugin22
18585 ]));
18586 return this;
18587 };
18588 return Processor2;
18589 }();
18590 var processor = Processor$1;
18591 Processor$1.default = Processor$1;
18592 Root$2.registerProcessor(Processor$1);
18593 Document$1.registerProcessor(Processor$1);
18594 var Declaration$1 = declaration;
18595 var PreviousMap22 = previousMap;
18596 var Comment$1 = comment;
18597 var AtRule$1 = atRule;
18598 var Input$1 = input;
18599 var Root$1 = root;
18600 var Rule$1 = rule;
18601 function fromJSON$1(json, inputs) {
18602 if (Array.isArray(json)) return json.map(function(n2) {
18603 return fromJSON$1(n2);
18604 });
18605 var ownInputs = json.inputs, defaults = _object_without_properties_loose(json, [
18606 "inputs"
18607 ]);
18608 if (ownInputs) {
18609 inputs = [];
18610 for(var _iterator = _create_for_of_iterator_helper_loose(ownInputs), _step; !(_step = _iterator()).done;){
18611 var input2 = _step.value;
18612 var inputHydrated = _extends({}, input2, {
18613 __proto__: Input$1.prototype
18614 });
18615 if (inputHydrated.map) {
18616 inputHydrated.map = _extends({}, inputHydrated.map, {
18617 __proto__: PreviousMap22.prototype
18618 });
18619 }
18620 inputs.push(inputHydrated);
18621 }
18622 }
18623 if (defaults.nodes) {
18624 defaults.nodes = json.nodes.map(function(n2) {
18625 return fromJSON$1(n2, inputs);
18626 });
18627 }
18628 if (defaults.source) {
18629 var _defaults_source = defaults.source, inputId = _defaults_source.inputId, source = _object_without_properties_loose(_defaults_source, [
18630 "inputId"
18631 ]);
18632 defaults.source = source;
18633 if (inputId != null) {
18634 defaults.source.input = inputs[inputId];
18635 }
18636 }
18637 if (defaults.type === "root") {
18638 return new Root$1(defaults);
18639 } else if (defaults.type === "decl") {
18640 return new Declaration$1(defaults);
18641 } else if (defaults.type === "rule") {
18642 return new Rule$1(defaults);
18643 } else if (defaults.type === "comment") {
18644 return new Comment$1(defaults);
18645 } else if (defaults.type === "atrule") {
18646 return new AtRule$1(defaults);
18647 } else {
18648 throw new Error("Unknown node type: " + json.type);
18649 }
18650 }
18651 var fromJSON_1 = fromJSON$1;
18652 fromJSON$1.default = fromJSON$1;
18653 var CssSyntaxError22 = cssSyntaxError;
18654 var Declaration22 = declaration;
18655 var LazyResult22 = lazyResult;
18656 var Container22 = container;
18657 var Processor22 = processor;
18658 var stringify = stringify_1;
18659 var fromJSON = fromJSON_1;
18660 var Document222 = document$1$2;
18661 var Warning22 = warning;
18662 var Comment22 = comment;
18663 var AtRule22 = atRule;
18664 var Result22 = result;
18665 var Input22 = input;
18666 var parse = parse_1;
18667 var list = list_1;
18668 var Rule22 = rule;
18669 var Root22 = root;
18670 var Node22 = node;
18671 function postcss() {
18672 for(var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++){
18673 plugins[_key] = arguments[_key];
18674 }
18675 if (plugins.length === 1 && Array.isArray(plugins[0])) {
18676 plugins = plugins[0];
18677 }
18678 return new Processor22(plugins);
18679 }
18680 postcss.plugin = function plugin2(name, initializer) {
18681 var warningPrinted = false;
18682 function creator() {
18683 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
18684 args[_key] = arguments[_key];
18685 }
18686 if (console && console.warn && !warningPrinted) {
18687 warningPrinted = true;
18688 console.warn(name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration");
18689 if (process.env.LANG && process.env.LANG.startsWith("cn")) {
18690 console.warn(name + ": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226");
18691 }
18692 }
18693 var transformer = initializer.apply(void 0, [].concat(args));
18694 transformer.postcssPlugin = name;
18695 transformer.postcssVersion = new Processor22().version;
18696 return transformer;
18697 }
18698 var cache;
18699 Object.defineProperty(creator, "postcss", {
18700 get: function get() {
18701 if (!cache) cache = creator();
18702 return cache;
18703 }
18704 });
18705 creator.process = function(css, processOpts, pluginOpts) {
18706 return postcss([
18707 creator(pluginOpts)
18708 ]).process(css, processOpts);
18709 };
18710 return creator;
18711 };
18712 postcss.stringify = stringify;
18713 postcss.parse = parse;
18714 postcss.fromJSON = fromJSON;
18715 postcss.list = list;
18716 postcss.comment = function(defaults) {
18717 return new Comment22(defaults);
18718 };
18719 postcss.atRule = function(defaults) {
18720 return new AtRule22(defaults);
18721 };
18722 postcss.decl = function(defaults) {
18723 return new Declaration22(defaults);
18724 };
18725 postcss.rule = function(defaults) {
18726 return new Rule22(defaults);
18727 };
18728 postcss.root = function(defaults) {
18729 return new Root22(defaults);
18730 };
18731 postcss.document = function(defaults) {
18732 return new Document222(defaults);
18733 };
18734 postcss.CssSyntaxError = CssSyntaxError22;
18735 postcss.Declaration = Declaration22;
18736 postcss.Container = Container22;
18737 postcss.Processor = Processor22;
18738 postcss.Document = Document222;
18739 postcss.Comment = Comment22;
18740 postcss.Warning = Warning22;
18741 postcss.AtRule = AtRule22;
18742 postcss.Result = Result22;
18743 postcss.Input = Input22;
18744 postcss.Rule = Rule22;
18745 postcss.Root = Root22;
18746 postcss.Node = Node22;
18747 LazyResult22.registerPostcss(postcss);
18748 var postcss_1 = postcss;
18749 postcss.default = postcss;
18750 var postcss$1 = /* @__PURE__ */ getDefaultExportFromCjs(postcss_1);
18751 postcss$1.stringify;
18752 postcss$1.fromJSON;
18753 postcss$1.plugin;
18754 postcss$1.parse;
18755 postcss$1.list;
18756 postcss$1.document;
18757 postcss$1.comment;
18758 postcss$1.atRule;
18759 postcss$1.rule;
18760 postcss$1.decl;
18761 postcss$1.root;
18762 postcss$1.CssSyntaxError;
18763 postcss$1.Declaration;
18764 postcss$1.Container;
18765 postcss$1.Processor;
18766 postcss$1.Document;
18767 postcss$1.Comment;
18768 postcss$1.Warning;
18769 postcss$1.AtRule;
18770 postcss$1.Result;
18771 postcss$1.Input;
18772 postcss$1.Rule;
18773 postcss$1.Root;
18774 postcss$1.Node;
18775 var BaseRRNode = /*#__PURE__*/ function() {
18776 function BaseRRNode() {
18777 for(var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++){
18778 _args[_key] = arguments[_key];
18779 }
18780 __publicField2(this, "parentElement", null);
18781 __publicField2(this, "parentNode", null);
18782 __publicField2(this, "ownerDocument");
18783 __publicField2(this, "firstChild", null);
18784 __publicField2(this, "lastChild", null);
18785 __publicField2(this, "previousSibling", null);
18786 __publicField2(this, "nextSibling", null);
18787 __publicField2(this, "ELEMENT_NODE", 1);
18788 __publicField2(this, "TEXT_NODE", 3);
18789 __publicField2(this, "nodeType");
18790 __publicField2(this, "nodeName");
18791 __publicField2(this, "RRNodeType");
18792 }
18793 var _proto = BaseRRNode.prototype;
18794 _proto.contains = function contains(node2) {
18795 if (!_instanceof(node2, BaseRRNode)) return false;
18796 else if (node2.ownerDocument !== this.ownerDocument) return false;
18797 else if (node2 === this) return true;
18798 while(node2.parentNode){
18799 if (node2.parentNode === this) return true;
18800 node2 = node2.parentNode;
18801 }
18802 return false;
18803 };
18804 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18805 _proto.appendChild = function appendChild(_newChild) {
18806 throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.");
18807 };
18808 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18809 _proto.insertBefore = function insertBefore(_newChild, _refChild) {
18810 throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.");
18811 };
18812 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18813 _proto.removeChild = function removeChild(_node) {
18814 throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.");
18815 };
18816 _proto.toString = function toString() {
18817 return "RRNode";
18818 };
18819 _create_class(BaseRRNode, [
18820 {
18821 key: "childNodes",
18822 get: function get() {
18823 var childNodes2 = [];
18824 var childIterator = this.firstChild;
18825 while(childIterator){
18826 childNodes2.push(childIterator);
18827 childIterator = childIterator.nextSibling;
18828 }
18829 return childNodes2;
18830 }
18831 }
18832 ]);
18833 return BaseRRNode;
18834 }();
18835 var testableAccessors = {
18836 Node: [
18837 "childNodes",
18838 "parentNode",
18839 "parentElement",
18840 "textContent"
18841 ],
18842 ShadowRoot: [
18843 "host",
18844 "styleSheets"
18845 ],
18846 Element: [
18847 "shadowRoot",
18848 "querySelector",
18849 "querySelectorAll"
18850 ],
18851 MutationObserver: []
18852 };
18853 var testableMethods = {
18854 Node: [
18855 "contains",
18856 "getRootNode"
18857 ],
18858 ShadowRoot: [
18859 "getSelection"
18860 ],
18861 Element: [],
18862 MutationObserver: [
18863 "constructor"
18864 ]
18865 };
18866 var untaintedBasePrototype = {};
18867 var isAngularZonePresent = function() {
18868 return !!globalThis.Zone;
18869 };
18870 function getUntaintedPrototype(key) {
18871 if (untaintedBasePrototype[key]) return untaintedBasePrototype[key];
18872 var defaultObj = globalThis[key];
18873 var defaultPrototype = defaultObj.prototype;
18874 var accessorNames = key in testableAccessors ? testableAccessors[key] : void 0;
18875 var isUntaintedAccessors = Boolean(accessorNames && // @ts-expect-error 2345
18876 accessorNames.every(function(accessor) {
18877 var _a2, _b;
18878 return Boolean((_b = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b.toString().includes("[native code]"));
18879 }));
18880 var methodNames = key in testableMethods ? testableMethods[key] : void 0;
18881 var isUntaintedMethods = Boolean(methodNames && methodNames.every(// @ts-expect-error 2345
18882 function(method) {
18883 var _a2;
18884 return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
18885 }));
18886 if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent()) {
18887 untaintedBasePrototype[key] = defaultObj.prototype;
18888 return defaultObj.prototype;
18889 }
18890 try {
18891 var iframeEl = document.createElement("iframe");
18892 document.body.appendChild(iframeEl);
18893 var win = iframeEl.contentWindow;
18894 if (!win) return defaultObj.prototype;
18895 var untaintedObject = win[key].prototype;
18896 document.body.removeChild(iframeEl);
18897 if (!untaintedObject) return defaultPrototype;
18898 return untaintedBasePrototype[key] = untaintedObject;
18899 } catch (e) {
18900 return defaultPrototype;
18901 }
18902 }
18903 var untaintedAccessorCache = {};
18904 function getUntaintedAccessor(key, instance, accessor) {
18905 var _a2;
18906 var cacheKey = key + "." + String(accessor);
18907 if (untaintedAccessorCache[cacheKey]) return untaintedAccessorCache[cacheKey].call(instance);
18908 var untaintedPrototype = getUntaintedPrototype(key);
18909 var untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(untaintedPrototype, accessor)) == null ? void 0 : _a2.get;
18910 if (!untaintedAccessor) return instance[accessor];
18911 untaintedAccessorCache[cacheKey] = untaintedAccessor;
18912 return untaintedAccessor.call(instance);
18913 }
18914 var untaintedMethodCache = {};
18915 function getUntaintedMethod(key, instance, method) {
18916 var cacheKey = key + "." + String(method);
18917 if (untaintedMethodCache[cacheKey]) return untaintedMethodCache[cacheKey].bind(instance);
18918 var untaintedPrototype = getUntaintedPrototype(key);
18919 var untaintedMethod = untaintedPrototype[method];
18920 if (typeof untaintedMethod !== "function") return instance[method];
18921 untaintedMethodCache[cacheKey] = untaintedMethod;
18922 return untaintedMethod.bind(instance);
18923 }
18924 function childNodes(n2) {
18925 return getUntaintedAccessor("Node", n2, "childNodes");
18926 }
18927 function parentNode(n2) {
18928 return getUntaintedAccessor("Node", n2, "parentNode");
18929 }
18930 function parentElement(n2) {
18931 return getUntaintedAccessor("Node", n2, "parentElement");
18932 }
18933 function textContent(n2) {
18934 return getUntaintedAccessor("Node", n2, "textContent");
18935 }
18936 function contains(n2, other) {
18937 return getUntaintedMethod("Node", n2, "contains")(other);
18938 }
18939 function getRootNode(n2) {
18940 return getUntaintedMethod("Node", n2, "getRootNode")();
18941 }
18942 function host(n2) {
18943 if (!n2 || !("host" in n2)) return null;
18944 return getUntaintedAccessor("ShadowRoot", n2, "host");
18945 }
18946 function styleSheets(n2) {
18947 return n2.styleSheets;
18948 }
18949 function shadowRoot(n2) {
18950 if (!n2 || !("shadowRoot" in n2)) return null;
18951 return getUntaintedAccessor("Element", n2, "shadowRoot");
18952 }
18953 function querySelector(n2, selectors) {
18954 return getUntaintedAccessor("Element", n2, "querySelector")(selectors);
18955 }
18956 function querySelectorAll(n2, selectors) {
18957 return getUntaintedAccessor("Element", n2, "querySelectorAll")(selectors);
18958 }
18959 function mutationObserverCtor() {
18960 return getUntaintedPrototype("MutationObserver").constructor;
18961 }
18962 function patch(source, name, replacement) {
18963 try {
18964 if (!(name in source)) {
18965 return function() {};
18966 }
18967 var original = source[name];
18968 var wrapped = replacement(original);
18969 if (typeof wrapped === "function") {
18970 wrapped.prototype = wrapped.prototype || {};
18971 Object.defineProperties(wrapped, {
18972 __rrweb_original__: {
18973 enumerable: false,
18974 value: original
18975 }
18976 });
18977 }
18978 source[name] = wrapped;
18979 return function() {
18980 source[name] = original;
18981 };
18982 } catch (e) {
18983 return function() {};
18984 }
18985 }
18986 var index = {
18987 childNodes: childNodes,
18988 parentNode: parentNode,
18989 parentElement: parentElement,
18990 textContent: textContent,
18991 contains: contains,
18992 getRootNode: getRootNode,
18993 host: host,
18994 styleSheets: styleSheets,
18995 shadowRoot: shadowRoot,
18996 querySelector: querySelector,
18997 querySelectorAll: querySelectorAll,
18998 mutationObserver: mutationObserverCtor,
18999 patch: patch
19000 };
19001 function on(type, fn, target) {
19002 if (target === void 0) target = document;
19003 var options = {
19004 capture: true,
19005 passive: true
19006 };
19007 target.addEventListener(type, fn, options);
19008 return function() {
19009 return target.removeEventListener(type, fn, options);
19010 };
19011 }
19012 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.";
19013 var _mirror = {
19014 map: {},
19015 getId: function getId() {
19016 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
19017 return -1;
19018 },
19019 getNode: function getNode() {
19020 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
19021 return null;
19022 },
19023 removeNodeFromMap: function removeNodeFromMap() {
19024 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
19025 },
19026 has: function has() {
19027 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
19028 return false;
19029 },
19030 reset: function reset() {
19031 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
19032 }
19033 };
19034 if (typeof window !== "undefined" && window.Proxy && window.Reflect) {
19035 _mirror = new Proxy(_mirror, {
19036 get: function get(target, prop, receiver) {
19037 if (prop === "map") {
19038 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
19039 }
19040 return Reflect.get(target, prop, receiver);
19041 }
19042 });
19043 }
19044 function throttle(func, wait, options) {
19045 if (options === void 0) options = {};
19046 var timeout = null;
19047 var previous = 0;
19048 return function() {
19049 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
19050 args[_key] = arguments[_key];
19051 }
19052 var now = Date.now();
19053 if (!previous && options.leading === false) {
19054 previous = now;
19055 }
19056 var remaining = wait - (now - previous);
19057 var context = this;
19058 if (remaining <= 0 || remaining > wait) {
19059 if (timeout) {
19060 clearTimeout(timeout);
19061 timeout = null;
19062 }
19063 previous = now;
19064 func.apply(context, args);
19065 } else if (!timeout && options.trailing !== false) {
19066 timeout = setTimeout(function() {
19067 previous = options.leading === false ? 0 : Date.now();
19068 timeout = null;
19069 func.apply(context, args);
19070 }, remaining);
19071 }
19072 };
19073 }
19074 function hookSetter(target, key, d, isRevoked, win) {
19075 if (win === void 0) win = window;
19076 var original = win.Object.getOwnPropertyDescriptor(target, key);
19077 win.Object.defineProperty(target, key, isRevoked ? d : {
19078 set: function set(value) {
19079 var _this = this;
19080 setTimeout(function() {
19081 d.set.call(_this, value);
19082 }, 0);
19083 if (original && original.set) {
19084 original.set.call(this, value);
19085 }
19086 }
19087 });
19088 return function() {
19089 return hookSetter(target, key, original || {}, true);
19090 };
19091 }
19092 var nowTimestamp = Date.now;
19093 if (!/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())) {
19094 nowTimestamp = function() {
19095 return /* @__PURE__ */ new Date().getTime();
19096 };
19097 }
19098 function getWindowScroll(win) {
19099 var _a2, _b, _c, _d;
19100 var doc = win.document;
19101 return {
19102 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,
19103 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
19104 };
19105 }
19106 function getWindowHeight() {
19107 return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body && document.body.clientHeight;
19108 }
19109 function getWindowWidth() {
19110 return window.innerWidth || document.documentElement && document.documentElement.clientWidth || document.body && document.body.clientWidth;
19111 }
19112 function closestElementOfNode(node2) {
19113 if (!node2) {
19114 return null;
19115 }
19116 var el = node2.nodeType === node2.ELEMENT_NODE ? node2 : index.parentElement(node2);
19117 return el;
19118 }
19119 function isBlocked(node2, blockClass, blockSelector, checkAncestors) {
19120 if (!node2) {
19121 return false;
19122 }
19123 var el = closestElementOfNode(node2);
19124 if (!el) {
19125 return false;
19126 }
19127 try {
19128 if (typeof blockClass === "string") {
19129 if (el.classList.contains(blockClass)) return true;
19130 if (checkAncestors && el.closest("." + blockClass) !== null) return true;
19131 } else {
19132 if (classMatchesRegex(el, blockClass, checkAncestors)) return true;
19133 }
19134 } catch (e2) {}
19135 if (blockSelector) {
19136 if (el.matches(blockSelector)) return true;
19137 if (checkAncestors && el.closest(blockSelector) !== null) return true;
19138 }
19139 return false;
19140 }
19141 function isSerialized(n2, mirror2) {
19142 return mirror2.getId(n2) !== -1;
19143 }
19144 function isIgnored(n2, mirror2, slimDOMOptions) {
19145 if (n2.tagName === "TITLE" && slimDOMOptions.headTitleMutations) {
19146 return true;
19147 }
19148 return mirror2.getId(n2) === IGNORED_NODE;
19149 }
19150 function isAncestorRemoved(target, mirror2) {
19151 if (isShadowRoot(target)) {
19152 return false;
19153 }
19154 var id = mirror2.getId(target);
19155 if (!mirror2.has(id)) {
19156 return true;
19157 }
19158 var parent = index.parentNode(target);
19159 if (parent && parent.nodeType === target.DOCUMENT_NODE) {
19160 return false;
19161 }
19162 if (!parent) {
19163 return true;
19164 }
19165 return isAncestorRemoved(parent, mirror2);
19166 }
19167 function legacy_isTouchEvent(event) {
19168 return Boolean(event.changedTouches);
19169 }
19170 function polyfill$1(win) {
19171 if (win === void 0) win = window;
19172 if ("NodeList" in win && !win.NodeList.prototype.forEach) {
19173 win.NodeList.prototype.forEach = Array.prototype.forEach;
19174 }
19175 if ("DOMTokenList" in win && !win.DOMTokenList.prototype.forEach) {
19176 win.DOMTokenList.prototype.forEach = Array.prototype.forEach;
19177 }
19178 }
19179 function isSerializedIframe(n2, mirror2) {
19180 return Boolean(n2.nodeName === "IFRAME" && mirror2.getMeta(n2));
19181 }
19182 function isSerializedStylesheet(n2, mirror2) {
19183 return Boolean(n2.nodeName === "LINK" && n2.nodeType === n2.ELEMENT_NODE && n2.getAttribute && n2.getAttribute("rel") === "stylesheet" && mirror2.getMeta(n2));
19184 }
19185 function hasShadowRoot(n2) {
19186 if (!n2) return false;
19187 if (_instanceof(n2, BaseRRNode) && "shadowRoot" in n2) {
19188 return Boolean(n2.shadowRoot);
19189 }
19190 return Boolean(index.shadowRoot(n2));
19191 }
19192 var StyleSheetMirror = /*#__PURE__*/ function() {
19193 function StyleSheetMirror() {
19194 __publicField(this, "id", 1);
19195 __publicField(this, "styleIDMap", /* @__PURE__ */ new WeakMap());
19196 __publicField(this, "idStyleMap", /* @__PURE__ */ new Map());
19197 }
19198 var _proto = StyleSheetMirror.prototype;
19199 _proto.getId = function getId(stylesheet) {
19200 var _this_styleIDMap_get;
19201 return (_this_styleIDMap_get = this.styleIDMap.get(stylesheet)) != null ? _this_styleIDMap_get : -1;
19202 };
19203 _proto.has = function has(stylesheet) {
19204 return this.styleIDMap.has(stylesheet);
19205 };
19206 /**
19207 * @returns If the stylesheet is in the mirror, returns the id of the stylesheet. If not, return the new assigned id.
19208 */ _proto.add = function add(stylesheet, id) {
19209 if (this.has(stylesheet)) return this.getId(stylesheet);
19210 var newId;
19211 if (id === void 0) {
19212 newId = this.id++;
19213 } else newId = id;
19214 this.styleIDMap.set(stylesheet, newId);
19215 this.idStyleMap.set(newId, stylesheet);
19216 return newId;
19217 };
19218 _proto.getStyle = function getStyle(id) {
19219 return this.idStyleMap.get(id) || null;
19220 };
19221 _proto.reset = function reset() {
19222 this.styleIDMap = /* @__PURE__ */ new WeakMap();
19223 this.idStyleMap = /* @__PURE__ */ new Map();
19224 this.id = 1;
19225 };
19226 _proto.generateId = function generateId() {
19227 return this.id++;
19228 };
19229 return StyleSheetMirror;
19230 }();
19231 function getShadowHost(n2) {
19232 var _a2;
19233 var shadowHost = null;
19234 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));
19235 return shadowHost;
19236 }
19237 function getRootShadowHost(n2) {
19238 var rootShadowHost = n2;
19239 var shadowHost;
19240 while(shadowHost = getShadowHost(rootShadowHost))rootShadowHost = shadowHost;
19241 return rootShadowHost;
19242 }
19243 function shadowHostInDom(n2) {
19244 var doc = n2.ownerDocument;
19245 if (!doc) return false;
19246 var shadowHost = getRootShadowHost(n2);
19247 return index.contains(doc, shadowHost);
19248 }
19249 function inDom(n2) {
19250 var doc = n2.ownerDocument;
19251 if (!doc) return false;
19252 return index.contains(doc, n2) || shadowHostInDom(n2);
19253 }
19254 var EventType = /* @__PURE__ */ function(EventType2) {
19255 EventType2[EventType2["DomContentLoaded"] = 0] = "DomContentLoaded";
19256 EventType2[EventType2["Load"] = 1] = "Load";
19257 EventType2[EventType2["FullSnapshot"] = 2] = "FullSnapshot";
19258 EventType2[EventType2["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
19259 EventType2[EventType2["Meta"] = 4] = "Meta";
19260 EventType2[EventType2["Custom"] = 5] = "Custom";
19261 EventType2[EventType2["Plugin"] = 6] = "Plugin";
19262 return EventType2;
19263 }(EventType || {});
19264 var IncrementalSource = /* @__PURE__ */ function(IncrementalSource2) {
19265 IncrementalSource2[IncrementalSource2["Mutation"] = 0] = "Mutation";
19266 IncrementalSource2[IncrementalSource2["MouseMove"] = 1] = "MouseMove";
19267 IncrementalSource2[IncrementalSource2["MouseInteraction"] = 2] = "MouseInteraction";
19268 IncrementalSource2[IncrementalSource2["Scroll"] = 3] = "Scroll";
19269 IncrementalSource2[IncrementalSource2["ViewportResize"] = 4] = "ViewportResize";
19270 IncrementalSource2[IncrementalSource2["Input"] = 5] = "Input";
19271 IncrementalSource2[IncrementalSource2["TouchMove"] = 6] = "TouchMove";
19272 IncrementalSource2[IncrementalSource2["MediaInteraction"] = 7] = "MediaInteraction";
19273 IncrementalSource2[IncrementalSource2["StyleSheetRule"] = 8] = "StyleSheetRule";
19274 IncrementalSource2[IncrementalSource2["CanvasMutation"] = 9] = "CanvasMutation";
19275 IncrementalSource2[IncrementalSource2["Font"] = 10] = "Font";
19276 IncrementalSource2[IncrementalSource2["Log"] = 11] = "Log";
19277 IncrementalSource2[IncrementalSource2["Drag"] = 12] = "Drag";
19278 IncrementalSource2[IncrementalSource2["StyleDeclaration"] = 13] = "StyleDeclaration";
19279 IncrementalSource2[IncrementalSource2["Selection"] = 14] = "Selection";
19280 IncrementalSource2[IncrementalSource2["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
19281 IncrementalSource2[IncrementalSource2["CustomElement"] = 16] = "CustomElement";
19282 return IncrementalSource2;
19283 }(IncrementalSource || {});
19284 var MouseInteractions = /* @__PURE__ */ function(MouseInteractions2) {
19285 MouseInteractions2[MouseInteractions2["MouseUp"] = 0] = "MouseUp";
19286 MouseInteractions2[MouseInteractions2["MouseDown"] = 1] = "MouseDown";
19287 MouseInteractions2[MouseInteractions2["Click"] = 2] = "Click";
19288 MouseInteractions2[MouseInteractions2["ContextMenu"] = 3] = "ContextMenu";
19289 MouseInteractions2[MouseInteractions2["DblClick"] = 4] = "DblClick";
19290 MouseInteractions2[MouseInteractions2["Focus"] = 5] = "Focus";
19291 MouseInteractions2[MouseInteractions2["Blur"] = 6] = "Blur";
19292 MouseInteractions2[MouseInteractions2["TouchStart"] = 7] = "TouchStart";
19293 MouseInteractions2[MouseInteractions2["TouchMove_Departed"] = 8] = "TouchMove_Departed";
19294 MouseInteractions2[MouseInteractions2["TouchEnd"] = 9] = "TouchEnd";
19295 MouseInteractions2[MouseInteractions2["TouchCancel"] = 10] = "TouchCancel";
19296 return MouseInteractions2;
19297 }(MouseInteractions || {});
19298 var PointerTypes = /* @__PURE__ */ function(PointerTypes2) {
19299 PointerTypes2[PointerTypes2["Mouse"] = 0] = "Mouse";
19300 PointerTypes2[PointerTypes2["Pen"] = 1] = "Pen";
19301 PointerTypes2[PointerTypes2["Touch"] = 2] = "Touch";
19302 return PointerTypes2;
19303 }(PointerTypes || {});
19304 var CanvasContext = /* @__PURE__ */ function(CanvasContext2) {
19305 CanvasContext2[CanvasContext2["2D"] = 0] = "2D";
19306 CanvasContext2[CanvasContext2["WebGL"] = 1] = "WebGL";
19307 CanvasContext2[CanvasContext2["WebGL2"] = 2] = "WebGL2";
19308 return CanvasContext2;
19309 }(CanvasContext || {});
19310 var MediaInteractions = /* @__PURE__ */ function(MediaInteractions2) {
19311 MediaInteractions2[MediaInteractions2["Play"] = 0] = "Play";
19312 MediaInteractions2[MediaInteractions2["Pause"] = 1] = "Pause";
19313 MediaInteractions2[MediaInteractions2["Seeked"] = 2] = "Seeked";
19314 MediaInteractions2[MediaInteractions2["VolumeChange"] = 3] = "VolumeChange";
19315 MediaInteractions2[MediaInteractions2["RateChange"] = 4] = "RateChange";
19316 return MediaInteractions2;
19317 }(MediaInteractions || {});
19318 var NodeType = /* @__PURE__ */ function(NodeType2) {
19319 NodeType2[NodeType2["Document"] = 0] = "Document";
19320 NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
19321 NodeType2[NodeType2["Element"] = 2] = "Element";
19322 NodeType2[NodeType2["Text"] = 3] = "Text";
19323 NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
19324 NodeType2[NodeType2["Comment"] = 5] = "Comment";
19325 return NodeType2;
19326 }(NodeType || {});
19327 function isNodeInLinkedList(n2) {
19328 return "__ln" in n2;
19329 }
19330 var DoubleLinkedList = /*#__PURE__*/ function() {
19331 function DoubleLinkedList() {
19332 __publicField(this, "length", 0);
19333 __publicField(this, "head", null);
19334 __publicField(this, "tail", null);
19335 }
19336 var _proto = DoubleLinkedList.prototype;
19337 _proto.get = function get(position) {
19338 if (position >= this.length) {
19339 throw new Error("Position outside of list range");
19340 }
19341 var current = this.head;
19342 for(var index2 = 0; index2 < position; index2++){
19343 current = (current == null ? void 0 : current.next) || null;
19344 }
19345 return current;
19346 };
19347 _proto.addNode = function addNode(n2) {
19348 var node2 = {
19349 value: n2,
19350 previous: null,
19351 next: null
19352 };
19353 n2.__ln = node2;
19354 if (n2.previousSibling && isNodeInLinkedList(n2.previousSibling)) {
19355 var current = n2.previousSibling.__ln.next;
19356 node2.next = current;
19357 node2.previous = n2.previousSibling.__ln;
19358 n2.previousSibling.__ln.next = node2;
19359 if (current) {
19360 current.previous = node2;
19361 }
19362 } else if (n2.nextSibling && isNodeInLinkedList(n2.nextSibling) && n2.nextSibling.__ln.previous) {
19363 var current1 = n2.nextSibling.__ln.previous;
19364 node2.previous = current1;
19365 node2.next = n2.nextSibling.__ln;
19366 n2.nextSibling.__ln.previous = node2;
19367 if (current1) {
19368 current1.next = node2;
19369 }
19370 } else {
19371 if (this.head) {
19372 this.head.previous = node2;
19373 }
19374 node2.next = this.head;
19375 this.head = node2;
19376 }
19377 if (node2.next === null) {
19378 this.tail = node2;
19379 }
19380 this.length++;
19381 };
19382 _proto.removeNode = function removeNode(n2) {
19383 var current = n2.__ln;
19384 if (!this.head) {
19385 return;
19386 }
19387 if (!current.previous) {
19388 this.head = current.next;
19389 if (this.head) {
19390 this.head.previous = null;
19391 } else {
19392 this.tail = null;
19393 }
19394 } else {
19395 current.previous.next = current.next;
19396 if (current.next) {
19397 current.next.previous = current.previous;
19398 } else {
19399 this.tail = current.previous;
19400 }
19401 }
19402 if (n2.__ln) {
19403 delete n2.__ln;
19404 }
19405 this.length--;
19406 };
19407 return DoubleLinkedList;
19408 }();
19409 var moveKey = function(id, parentId) {
19410 return id + "@" + parentId;
19411 };
19412 var MutationBuffer = /*#__PURE__*/ function() {
19413 function MutationBuffer() {
19414 var _this = this;
19415 __publicField(this, "frozen", false);
19416 __publicField(this, "locked", false);
19417 __publicField(this, "texts", []);
19418 __publicField(this, "attributes", []);
19419 __publicField(this, "attributeMap", /* @__PURE__ */ new WeakMap());
19420 __publicField(this, "removes", []);
19421 __publicField(this, "mapRemoves", []);
19422 __publicField(this, "movedMap", {});
19423 /**
19424 * the browser MutationObserver emits multiple mutations after
19425 * a delay for performance reasons, making tracing added nodes hard
19426 * in our `processMutations` callback function.
19427 * For example, if we append an element el_1 into body, and then append
19428 * another element el_2 into el_1, these two mutations may be passed to the
19429 * callback function together when the two operations were done.
19430 * Generally we need to trace child nodes of newly added nodes, but in this
19431 * case if we count el_2 as el_1's child node in the first mutation record,
19432 * then we will count el_2 again in the second mutation record which was
19433 * duplicated.
19434 * To avoid of duplicate counting added nodes, we use a Set to store
19435 * added nodes and its child nodes during iterate mutation records. Then
19436 * collect added nodes from the Set which have no duplicate copy. But
19437 * this also causes newly added nodes will not be serialized with id ASAP,
19438 * which means all the id related calculation should be lazy too.
19439 */ __publicField(this, "addedSet", /* @__PURE__ */ new Set());
19440 __publicField(this, "movedSet", /* @__PURE__ */ new Set());
19441 __publicField(this, "droppedSet", /* @__PURE__ */ new Set());
19442 __publicField(this, "removesSubTreeCache", /* @__PURE__ */ new Set());
19443 __publicField(this, "mutationCb");
19444 __publicField(this, "blockClass");
19445 __publicField(this, "blockSelector");
19446 __publicField(this, "maskTextClass");
19447 __publicField(this, "maskTextSelector");
19448 __publicField(this, "inlineStylesheet");
19449 __publicField(this, "maskInputOptions");
19450 __publicField(this, "maskTextFn");
19451 __publicField(this, "maskInputFn");
19452 __publicField(this, "keepIframeSrcFn");
19453 __publicField(this, "recordCanvas");
19454 __publicField(this, "inlineImages");
19455 __publicField(this, "slimDOMOptions");
19456 __publicField(this, "dataURLOptions");
19457 __publicField(this, "doc");
19458 __publicField(this, "mirror");
19459 __publicField(this, "iframeManager");
19460 __publicField(this, "stylesheetManager");
19461 __publicField(this, "shadowDomManager");
19462 __publicField(this, "canvasManager");
19463 __publicField(this, "processedNodeManager");
19464 __publicField(this, "unattachedDoc");
19465 __publicField(this, "processMutations", function(mutations) {
19466 mutations.forEach(_this.processMutation);
19467 _this.emit();
19468 });
19469 __publicField(this, "emit", function() {
19470 if (_this.frozen || _this.locked) {
19471 return;
19472 }
19473 var adds = [];
19474 var addedIds = /* @__PURE__ */ new Set();
19475 var addList = new DoubleLinkedList();
19476 var getNextId = function(n2) {
19477 var ns = n2;
19478 var nextId = IGNORED_NODE;
19479 while(nextId === IGNORED_NODE){
19480 ns = ns && ns.nextSibling;
19481 nextId = ns && _this.mirror.getId(ns);
19482 }
19483 return nextId;
19484 };
19485 var pushAdd = function(n2) {
19486 var parent = index.parentNode(n2);
19487 if (!parent || !inDom(n2)) {
19488 return;
19489 }
19490 var cssCaptured = false;
19491 if (n2.nodeType === Node.TEXT_NODE) {
19492 var parentTag = parent.tagName;
19493 if (parentTag === "TEXTAREA") {
19494 return;
19495 } else if (parentTag === "STYLE" && _this.addedSet.has(parent)) {
19496 cssCaptured = true;
19497 }
19498 }
19499 var parentId = isShadowRoot(parent) ? _this.mirror.getId(getShadowHost(n2)) : _this.mirror.getId(parent);
19500 var nextId = getNextId(n2);
19501 if (parentId === -1 || nextId === -1) {
19502 return addList.addNode(n2);
19503 }
19504 var sn = serializeNodeWithId(n2, {
19505 doc: _this.doc,
19506 mirror: _this.mirror,
19507 blockClass: _this.blockClass,
19508 blockSelector: _this.blockSelector,
19509 maskTextClass: _this.maskTextClass,
19510 maskTextSelector: _this.maskTextSelector,
19511 skipChild: true,
19512 newlyAddedElement: true,
19513 inlineStylesheet: _this.inlineStylesheet,
19514 maskInputOptions: _this.maskInputOptions,
19515 maskTextFn: _this.maskTextFn,
19516 maskInputFn: _this.maskInputFn,
19517 slimDOMOptions: _this.slimDOMOptions,
19518 dataURLOptions: _this.dataURLOptions,
19519 recordCanvas: _this.recordCanvas,
19520 inlineImages: _this.inlineImages,
19521 onSerialize: function(currentN) {
19522 if (isSerializedIframe(currentN, _this.mirror)) {
19523 _this.iframeManager.addIframe(currentN);
19524 }
19525 if (isSerializedStylesheet(currentN, _this.mirror)) {
19526 _this.stylesheetManager.trackLinkElement(currentN);
19527 }
19528 if (hasShadowRoot(n2)) {
19529 _this.shadowDomManager.addShadowRoot(index.shadowRoot(n2), _this.doc);
19530 }
19531 },
19532 onIframeLoad: function(iframe, childSn) {
19533 _this.iframeManager.attachIframe(iframe, childSn);
19534 _this.shadowDomManager.observeAttachShadow(iframe);
19535 },
19536 onStylesheetLoad: function(link, childSn) {
19537 _this.stylesheetManager.attachLinkElement(link, childSn);
19538 },
19539 cssCaptured: cssCaptured
19540 });
19541 if (sn) {
19542 adds.push({
19543 parentId: parentId,
19544 nextId: nextId,
19545 node: sn
19546 });
19547 addedIds.add(sn.id);
19548 }
19549 };
19550 while(_this.mapRemoves.length){
19551 _this.mirror.removeNodeFromMap(_this.mapRemoves.shift());
19552 }
19553 for(var _iterator = _create_for_of_iterator_helper_loose(_this.movedSet), _step; !(_step = _iterator()).done;){
19554 var n2 = _step.value;
19555 if (isParentRemoved(_this.removesSubTreeCache, n2, _this.mirror) && !_this.movedSet.has(index.parentNode(n2))) {
19556 continue;
19557 }
19558 pushAdd(n2);
19559 }
19560 for(var _iterator1 = _create_for_of_iterator_helper_loose(_this.addedSet), _step1; !(_step1 = _iterator1()).done;){
19561 var n21 = _step1.value;
19562 if (!isAncestorInSet(_this.droppedSet, n21) && !isParentRemoved(_this.removesSubTreeCache, n21, _this.mirror)) {
19563 pushAdd(n21);
19564 } else if (isAncestorInSet(_this.movedSet, n21)) {
19565 pushAdd(n21);
19566 } else {
19567 _this.droppedSet.add(n21);
19568 }
19569 }
19570 var candidate = null;
19571 while(addList.length){
19572 var node2 = null;
19573 if (candidate) {
19574 var parentId = _this.mirror.getId(index.parentNode(candidate.value));
19575 var nextId = getNextId(candidate.value);
19576 if (parentId !== -1 && nextId !== -1) {
19577 node2 = candidate;
19578 }
19579 }
19580 if (!node2) {
19581 var tailNode = addList.tail;
19582 while(tailNode){
19583 var _node = tailNode;
19584 tailNode = tailNode.previous;
19585 if (_node) {
19586 var parentId1 = _this.mirror.getId(index.parentNode(_node.value));
19587 var nextId1 = getNextId(_node.value);
19588 if (nextId1 === -1) continue;
19589 else if (parentId1 !== -1) {
19590 node2 = _node;
19591 break;
19592 } else {
19593 var unhandledNode = _node.value;
19594 var parent = index.parentNode(unhandledNode);
19595 if (parent && parent.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
19596 var shadowHost = index.host(parent);
19597 var parentId2 = _this.mirror.getId(shadowHost);
19598 if (parentId2 !== -1) {
19599 node2 = _node;
19600 break;
19601 }
19602 }
19603 }
19604 }
19605 }
19606 }
19607 if (!node2) {
19608 while(addList.head){
19609 addList.removeNode(addList.head.value);
19610 }
19611 break;
19612 }
19613 candidate = node2.previous;
19614 addList.removeNode(node2.value);
19615 pushAdd(node2.value);
19616 }
19617 var payload = {
19618 texts: _this.texts.map(function(text) {
19619 var n2 = text.node;
19620 var parent = index.parentNode(n2);
19621 if (parent && parent.tagName === "TEXTAREA") {
19622 _this.genTextAreaValueMutation(parent);
19623 }
19624 return {
19625 id: _this.mirror.getId(n2),
19626 value: text.value
19627 };
19628 }).filter(function(text) {
19629 return !addedIds.has(text.id);
19630 }).filter(function(text) {
19631 return _this.mirror.has(text.id);
19632 }),
19633 attributes: _this.attributes.map(function(attribute) {
19634 var attributes = attribute.attributes;
19635 if (typeof attributes.style === "string") {
19636 var diffAsStr = JSON.stringify(attribute.styleDiff);
19637 var unchangedAsStr = JSON.stringify(attribute._unchangedStyles);
19638 if (diffAsStr.length < attributes.style.length) {
19639 if ((diffAsStr + unchangedAsStr).split("var(").length === attributes.style.split("var(").length) {
19640 attributes.style = attribute.styleDiff;
19641 }
19642 }
19643 }
19644 return {
19645 id: _this.mirror.getId(attribute.node),
19646 attributes: attributes
19647 };
19648 }).filter(function(attribute) {
19649 return !addedIds.has(attribute.id);
19650 }).filter(function(attribute) {
19651 return _this.mirror.has(attribute.id);
19652 }),
19653 removes: _this.removes,
19654 adds: adds
19655 };
19656 if (!payload.texts.length && !payload.attributes.length && !payload.removes.length && !payload.adds.length) {
19657 return;
19658 }
19659 _this.texts = [];
19660 _this.attributes = [];
19661 _this.attributeMap = /* @__PURE__ */ new WeakMap();
19662 _this.removes = [];
19663 _this.addedSet = /* @__PURE__ */ new Set();
19664 _this.movedSet = /* @__PURE__ */ new Set();
19665 _this.droppedSet = /* @__PURE__ */ new Set();
19666 _this.removesSubTreeCache = /* @__PURE__ */ new Set();
19667 _this.movedMap = {};
19668 _this.mutationCb(payload);
19669 });
19670 __publicField(this, "genTextAreaValueMutation", function(textarea) {
19671 var item = _this.attributeMap.get(textarea);
19672 if (!item) {
19673 item = {
19674 node: textarea,
19675 attributes: {},
19676 styleDiff: {},
19677 _unchangedStyles: {}
19678 };
19679 _this.attributes.push(item);
19680 _this.attributeMap.set(textarea, item);
19681 }
19682 var value = Array.from(index.childNodes(textarea), function(cn) {
19683 return index.textContent(cn) || "";
19684 }).join("");
19685 item.attributes.value = maskInputValue({
19686 element: textarea,
19687 maskInputOptions: _this.maskInputOptions,
19688 tagName: textarea.tagName,
19689 type: getInputType(textarea),
19690 value: value,
19691 maskInputFn: _this.maskInputFn
19692 });
19693 });
19694 __publicField(this, "processMutation", function(m) {
19695 if (isIgnored(m.target, _this.mirror, _this.slimDOMOptions)) {
19696 return;
19697 }
19698 switch(m.type){
19699 case "characterData":
19700 {
19701 var value = index.textContent(m.target);
19702 if (!isBlocked(m.target, _this.blockClass, _this.blockSelector, false) && value !== m.oldValue) {
19703 _this.texts.push({
19704 value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector, true) && value ? _this.maskTextFn ? _this.maskTextFn(value, closestElementOfNode(m.target)) : value.replace(/[\S]/g, "*") : value,
19705 node: m.target
19706 });
19707 }
19708 break;
19709 }
19710 case "attributes":
19711 {
19712 var target = m.target;
19713 var attributeName = m.attributeName;
19714 var value1 = m.target.getAttribute(attributeName);
19715 if (attributeName === "value") {
19716 var type = getInputType(target);
19717 value1 = maskInputValue({
19718 element: target,
19719 maskInputOptions: _this.maskInputOptions,
19720 tagName: target.tagName,
19721 type: type,
19722 value: value1,
19723 maskInputFn: _this.maskInputFn
19724 });
19725 }
19726 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, false) || value1 === m.oldValue) {
19727 return;
19728 }
19729 var item = _this.attributeMap.get(m.target);
19730 if (target.tagName === "IFRAME" && attributeName === "src" && !_this.keepIframeSrcFn(value1)) {
19731 if (!target.contentDocument) {
19732 attributeName = "rr_src";
19733 } else {
19734 return;
19735 }
19736 }
19737 if (!item) {
19738 item = {
19739 node: m.target,
19740 attributes: {},
19741 styleDiff: {},
19742 _unchangedStyles: {}
19743 };
19744 _this.attributes.push(item);
19745 _this.attributeMap.set(m.target, item);
19746 }
19747 if (attributeName === "type" && target.tagName === "INPUT" && (m.oldValue || "").toLowerCase() === "password") {
19748 target.setAttribute("data-rr-is-password", "true");
19749 }
19750 if (!ignoreAttribute(target.tagName, attributeName)) {
19751 item.attributes[attributeName] = transformAttribute(_this.doc, toLowerCase(target.tagName), toLowerCase(attributeName), value1);
19752 if (attributeName === "style") {
19753 if (!_this.unattachedDoc) {
19754 try {
19755 _this.unattachedDoc = document.implementation.createHTMLDocument();
19756 } catch (e2) {
19757 _this.unattachedDoc = _this.doc;
19758 }
19759 }
19760 var old = _this.unattachedDoc.createElement("span");
19761 if (m.oldValue) {
19762 old.setAttribute("style", m.oldValue);
19763 }
19764 for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(target.style)), _step; !(_step = _iterator()).done;){
19765 var pname = _step.value;
19766 var newValue = target.style.getPropertyValue(pname);
19767 var newPriority = target.style.getPropertyPriority(pname);
19768 if (newValue !== old.style.getPropertyValue(pname) || newPriority !== old.style.getPropertyPriority(pname)) {
19769 if (newPriority === "") {
19770 item.styleDiff[pname] = newValue;
19771 } else {
19772 item.styleDiff[pname] = [
19773 newValue,
19774 newPriority
19775 ];
19776 }
19777 } else {
19778 item._unchangedStyles[pname] = [
19779 newValue,
19780 newPriority
19781 ];
19782 }
19783 }
19784 for(var _iterator1 = _create_for_of_iterator_helper_loose(Array.from(old.style)), _step1; !(_step1 = _iterator1()).done;){
19785 var pname1 = _step1.value;
19786 if (target.style.getPropertyValue(pname1) === "") {
19787 item.styleDiff[pname1] = false;
19788 }
19789 }
19790 } else if (attributeName === "open" && target.tagName === "DIALOG") {
19791 if (target.matches("dialog:modal")) {
19792 item.attributes["rr_open_mode"] = "modal";
19793 } else {
19794 item.attributes["rr_open_mode"] = "non-modal";
19795 }
19796 }
19797 }
19798 break;
19799 }
19800 case "childList":
19801 {
19802 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, true)) return;
19803 if (m.target.tagName === "TEXTAREA") {
19804 _this.genTextAreaValueMutation(m.target);
19805 return;
19806 }
19807 m.addedNodes.forEach(function(n2) {
19808 return _this.genAdds(n2, m.target);
19809 });
19810 m.removedNodes.forEach(function(n2) {
19811 var nodeId = _this.mirror.getId(n2);
19812 var parentId = isShadowRoot(m.target) ? _this.mirror.getId(index.host(m.target)) : _this.mirror.getId(m.target);
19813 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, false) || isIgnored(n2, _this.mirror, _this.slimDOMOptions) || !isSerialized(n2, _this.mirror)) {
19814 return;
19815 }
19816 if (_this.addedSet.has(n2)) {
19817 deepDelete(_this.addedSet, n2);
19818 _this.droppedSet.add(n2);
19819 } else if (_this.addedSet.has(m.target) && nodeId === -1) ;
19820 else if (isAncestorRemoved(m.target, _this.mirror)) ;
19821 else if (_this.movedSet.has(n2) && _this.movedMap[moveKey(nodeId, parentId)]) {
19822 deepDelete(_this.movedSet, n2);
19823 } else {
19824 _this.removes.push({
19825 parentId: parentId,
19826 id: nodeId,
19827 isShadow: isShadowRoot(m.target) && isNativeShadowDom(m.target) ? true : void 0
19828 });
19829 processRemoves(n2, _this.removesSubTreeCache);
19830 }
19831 _this.mapRemoves.push(n2);
19832 });
19833 break;
19834 }
19835 }
19836 });
19837 /**
19838 * Make sure you check if `n`'s parent is blocked before calling this function
19839 * */ __publicField(this, "genAdds", function(n2, target) {
19840 if (_this.processedNodeManager.inOtherBuffer(n2, _this)) return;
19841 if (_this.addedSet.has(n2) || _this.movedSet.has(n2)) return;
19842 if (_this.mirror.hasNode(n2)) {
19843 if (isIgnored(n2, _this.mirror, _this.slimDOMOptions)) {
19844 return;
19845 }
19846 _this.movedSet.add(n2);
19847 var targetId = null;
19848 if (target && _this.mirror.hasNode(target)) {
19849 targetId = _this.mirror.getId(target);
19850 }
19851 if (targetId && targetId !== -1) {
19852 _this.movedMap[moveKey(_this.mirror.getId(n2), targetId)] = true;
19853 }
19854 } else {
19855 _this.addedSet.add(n2);
19856 _this.droppedSet.delete(n2);
19857 }
19858 if (!isBlocked(n2, _this.blockClass, _this.blockSelector, false)) {
19859 index.childNodes(n2).forEach(function(childN) {
19860 return _this.genAdds(childN);
19861 });
19862 if (hasShadowRoot(n2)) {
19863 index.childNodes(index.shadowRoot(n2)).forEach(function(childN) {
19864 _this.processedNodeManager.add(childN, _this);
19865 _this.genAdds(childN, n2);
19866 });
19867 }
19868 }
19869 });
19870 }
19871 var _proto = MutationBuffer.prototype;
19872 _proto.init = function init(options) {
19873 var _this = this;
19874 [
19875 "mutationCb",
19876 "blockClass",
19877 "blockSelector",
19878 "maskTextClass",
19879 "maskTextSelector",
19880 "inlineStylesheet",
19881 "maskInputOptions",
19882 "maskTextFn",
19883 "maskInputFn",
19884 "keepIframeSrcFn",
19885 "recordCanvas",
19886 "inlineImages",
19887 "slimDOMOptions",
19888 "dataURLOptions",
19889 "doc",
19890 "mirror",
19891 "iframeManager",
19892 "stylesheetManager",
19893 "shadowDomManager",
19894 "canvasManager",
19895 "processedNodeManager"
19896 ].forEach(function(key) {
19897 _this[key] = options[key];
19898 });
19899 };
19900 _proto.freeze = function freeze() {
19901 this.frozen = true;
19902 this.canvasManager.freeze();
19903 };
19904 _proto.unfreeze = function unfreeze() {
19905 this.frozen = false;
19906 this.canvasManager.unfreeze();
19907 this.emit();
19908 };
19909 _proto.isFrozen = function isFrozen() {
19910 return this.frozen;
19911 };
19912 _proto.lock = function lock() {
19913 this.locked = true;
19914 this.canvasManager.lock();
19915 };
19916 _proto.unlock = function unlock() {
19917 this.locked = false;
19918 this.canvasManager.unlock();
19919 this.emit();
19920 };
19921 _proto.reset = function reset() {
19922 this.shadowDomManager.reset();
19923 this.canvasManager.reset();
19924 };
19925 return MutationBuffer;
19926 }();
19927 function deepDelete(addsSet, n2) {
19928 addsSet.delete(n2);
19929 index.childNodes(n2).forEach(function(childN) {
19930 return deepDelete(addsSet, childN);
19931 });
19932 }
19933 function processRemoves(n2, cache) {
19934 var queue = [
19935 n2
19936 ];
19937 while(queue.length){
19938 var next = queue.pop();
19939 if (cache.has(next)) continue;
19940 cache.add(next);
19941 index.childNodes(next).forEach(function(n22) {
19942 return queue.push(n22);
19943 });
19944 }
19945 return;
19946 }
19947 function isParentRemoved(removes, n2, mirror2) {
19948 if (removes.size === 0) return false;
19949 return _isParentRemoved(removes, n2);
19950 }
19951 function _isParentRemoved(removes, n2, _mirror2) {
19952 var node2 = index.parentNode(n2);
19953 if (!node2) return false;
19954 return removes.has(node2);
19955 }
19956 function isAncestorInSet(set, n2) {
19957 if (set.size === 0) return false;
19958 return _isAncestorInSet(set, n2);
19959 }
19960 function _isAncestorInSet(set, n2) {
19961 var parent = index.parentNode(n2);
19962 if (!parent) {
19963 return false;
19964 }
19965 if (set.has(parent)) {
19966 return true;
19967 }
19968 return _isAncestorInSet(set, parent);
19969 }
19970 var errorHandler;
19971 function registerErrorHandler(handler) {
19972 errorHandler = handler;
19973 }
19974 function unregisterErrorHandler() {
19975 errorHandler = void 0;
19976 }
19977 var callbackWrapper = function(cb) {
19978 if (!errorHandler) {
19979 return cb;
19980 }
19981 var rrwebWrapped = function() {
19982 for(var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++){
19983 rest[_key] = arguments[_key];
19984 }
19985 try {
19986 return cb.apply(void 0, [].concat(rest));
19987 } catch (error) {
19988 if (errorHandler && errorHandler(error) === true) {
19989 return;
19990 }
19991 throw error;
19992 }
19993 };
19994 return rrwebWrapped;
19995 };
19996 var mutationBuffers = [];
19997 function getEventTarget(event) {
19998 try {
19999 if ("composedPath" in event) {
20000 var path = event.composedPath();
20001 if (path.length) {
20002 return path[0];
20003 }
20004 } else if ("path" in event && event.path.length) {
20005 return event.path[0];
20006 }
20007 } catch (e) {}
20008 return event && event.target;
20009 }
20010 function initMutationObserver(options, rootEl) {
20011 var mutationBuffer = new MutationBuffer();
20012 mutationBuffers.push(mutationBuffer);
20013 mutationBuffer.init(options);
20014 var observer = new (mutationObserverCtor())(callbackWrapper(mutationBuffer.processMutations.bind(mutationBuffer)));
20015 observer.observe(rootEl, {
20016 attributes: true,
20017 attributeOldValue: true,
20018 characterData: true,
20019 characterDataOldValue: true,
20020 childList: true,
20021 subtree: true
20022 });
20023 return observer;
20024 }
20025 function initMoveObserver(param) {
20026 var mousemoveCb = param.mousemoveCb, sampling = param.sampling, doc = param.doc, mirror2 = param.mirror;
20027 if (sampling.mousemove === false) {
20028 return function() {};
20029 }
20030 var threshold = typeof sampling.mousemove === "number" ? sampling.mousemove : 50;
20031 var callbackThreshold = typeof sampling.mousemoveCallback === "number" ? sampling.mousemoveCallback : 500;
20032 var positions = [];
20033 var timeBaseline;
20034 var wrappedCb = throttle(callbackWrapper(function(source) {
20035 var totalOffset = Date.now() - timeBaseline;
20036 mousemoveCb(positions.map(function(p) {
20037 p.timeOffset -= totalOffset;
20038 return p;
20039 }), source);
20040 positions = [];
20041 timeBaseline = null;
20042 }), callbackThreshold);
20043 var updatePosition = callbackWrapper(throttle(callbackWrapper(function(evt) {
20044 var target = getEventTarget(evt);
20045 var _ref = legacy_isTouchEvent(evt) ? evt.changedTouches[0] : evt, clientX = _ref.clientX, clientY = _ref.clientY;
20046 if (!timeBaseline) {
20047 timeBaseline = nowTimestamp();
20048 }
20049 positions.push({
20050 x: clientX,
20051 y: clientY,
20052 id: mirror2.getId(target),
20053 timeOffset: nowTimestamp() - timeBaseline
20054 });
20055 wrappedCb(typeof DragEvent !== "undefined" && _instanceof(evt, DragEvent) ? IncrementalSource.Drag : _instanceof(evt, MouseEvent) ? IncrementalSource.MouseMove : IncrementalSource.TouchMove);
20056 }), threshold, {
20057 trailing: false
20058 }));
20059 var handlers = [
20060 on("mousemove", updatePosition, doc),
20061 on("touchmove", updatePosition, doc),
20062 on("drag", updatePosition, doc)
20063 ];
20064 return callbackWrapper(function() {
20065 handlers.forEach(function(h) {
20066 return h();
20067 });
20068 });
20069 }
20070 function initMouseInteractionObserver(param) {
20071 var mouseInteractionCb = param.mouseInteractionCb, doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, sampling = param.sampling;
20072 if (sampling.mouseInteraction === false) {
20073 return function() {};
20074 }
20075 var disableMap = sampling.mouseInteraction === true || sampling.mouseInteraction === void 0 ? {} : sampling.mouseInteraction;
20076 var handlers = [];
20077 var currentPointerType = null;
20078 var getHandler = function(eventKey) {
20079 return function(event) {
20080 var target = getEventTarget(event);
20081 if (isBlocked(target, blockClass, blockSelector, true)) {
20082 return;
20083 }
20084 var pointerType = null;
20085 var thisEventKey = eventKey;
20086 if ("pointerType" in event) {
20087 switch(event.pointerType){
20088 case "mouse":
20089 pointerType = PointerTypes.Mouse;
20090 break;
20091 case "touch":
20092 pointerType = PointerTypes.Touch;
20093 break;
20094 case "pen":
20095 pointerType = PointerTypes.Pen;
20096 break;
20097 }
20098 if (pointerType === PointerTypes.Touch) {
20099 if (MouseInteractions[eventKey] === MouseInteractions.MouseDown) {
20100 thisEventKey = "TouchStart";
20101 } else if (MouseInteractions[eventKey] === MouseInteractions.MouseUp) {
20102 thisEventKey = "TouchEnd";
20103 }
20104 } else if (pointerType === PointerTypes.Pen) ;
20105 } else if (legacy_isTouchEvent(event)) {
20106 pointerType = PointerTypes.Touch;
20107 }
20108 if (pointerType !== null) {
20109 currentPointerType = pointerType;
20110 if (thisEventKey.startsWith("Touch") && pointerType === PointerTypes.Touch || thisEventKey.startsWith("Mouse") && pointerType === PointerTypes.Mouse) {
20111 pointerType = null;
20112 }
20113 } else if (MouseInteractions[eventKey] === MouseInteractions.Click) {
20114 pointerType = currentPointerType;
20115 currentPointerType = null;
20116 }
20117 var e2 = legacy_isTouchEvent(event) ? event.changedTouches[0] : event;
20118 if (!e2) {
20119 return;
20120 }
20121 var id = mirror2.getId(target);
20122 var clientX = e2.clientX, clientY = e2.clientY;
20123 callbackWrapper(mouseInteractionCb)(_extends({
20124 type: MouseInteractions[thisEventKey],
20125 id: id,
20126 x: clientX,
20127 y: clientY
20128 }, pointerType !== null && {
20129 pointerType: pointerType
20130 }));
20131 };
20132 };
20133 Object.keys(MouseInteractions).filter(function(key) {
20134 return Number.isNaN(Number(key)) && !key.endsWith("_Departed") && disableMap[key] !== false;
20135 }).forEach(function(eventKey) {
20136 var eventName = toLowerCase(eventKey);
20137 var handler = getHandler(eventKey);
20138 if (window.PointerEvent) {
20139 switch(MouseInteractions[eventKey]){
20140 case MouseInteractions.MouseDown:
20141 case MouseInteractions.MouseUp:
20142 eventName = eventName.replace("mouse", "pointer");
20143 break;
20144 case MouseInteractions.TouchStart:
20145 case MouseInteractions.TouchEnd:
20146 return;
20147 }
20148 }
20149 handlers.push(on(eventName, handler, doc));
20150 });
20151 return callbackWrapper(function() {
20152 handlers.forEach(function(h) {
20153 return h();
20154 });
20155 });
20156 }
20157 function initScrollObserver(param) {
20158 var scrollCb = param.scrollCb, doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, sampling = param.sampling;
20159 var updatePosition = callbackWrapper(throttle(callbackWrapper(function(evt) {
20160 var target = getEventTarget(evt);
20161 if (!target || isBlocked(target, blockClass, blockSelector, true)) {
20162 return;
20163 }
20164 var id = mirror2.getId(target);
20165 if (target === doc && doc.defaultView) {
20166 var scrollLeftTop = getWindowScroll(doc.defaultView);
20167 scrollCb({
20168 id: id,
20169 x: scrollLeftTop.left,
20170 y: scrollLeftTop.top
20171 });
20172 } else {
20173 scrollCb({
20174 id: id,
20175 x: target.scrollLeft,
20176 y: target.scrollTop
20177 });
20178 }
20179 }), sampling.scroll || 100));
20180 return on("scroll", updatePosition, doc);
20181 }
20182 function initViewportResizeObserver(param, param1) {
20183 var viewportResizeCb = param.viewportResizeCb;
20184 var win = param1.win;
20185 var lastH = -1;
20186 var lastW = -1;
20187 var updateDimension = callbackWrapper(throttle(callbackWrapper(function() {
20188 var height = getWindowHeight();
20189 var width = getWindowWidth();
20190 if (lastH !== height || lastW !== width) {
20191 viewportResizeCb({
20192 width: Number(width),
20193 height: Number(height)
20194 });
20195 lastH = height;
20196 lastW = width;
20197 }
20198 }), 200));
20199 return on("resize", updateDimension, win);
20200 }
20201 var INPUT_TAGS = [
20202 "INPUT",
20203 "TEXTAREA",
20204 "SELECT"
20205 ];
20206 var lastInputValueMap = /* @__PURE__ */ new WeakMap();
20207 function initInputObserver(param) {
20208 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;
20209 function eventHandler(event) {
20210 var target = getEventTarget(event);
20211 var userTriggered = event.isTrusted;
20212 var tagName = target && target.tagName;
20213 if (target && tagName === "OPTION") {
20214 target = index.parentElement(target);
20215 }
20216 if (!target || !tagName || INPUT_TAGS.indexOf(tagName) < 0 || isBlocked(target, blockClass, blockSelector, true)) {
20217 return;
20218 }
20219 if (target.classList.contains(ignoreClass) || ignoreSelector && target.matches(ignoreSelector)) {
20220 return;
20221 }
20222 var text = target.value;
20223 var isChecked = false;
20224 var type = getInputType(target) || "";
20225 if (type === "radio" || type === "checkbox") {
20226 isChecked = target.checked;
20227 } else if (maskInputOptions[tagName.toLowerCase()] || maskInputOptions[type]) {
20228 text = maskInputValue({
20229 element: target,
20230 maskInputOptions: maskInputOptions,
20231 tagName: tagName,
20232 type: type,
20233 value: text,
20234 maskInputFn: maskInputFn
20235 });
20236 }
20237 cbWithDedup(target, userTriggeredOnInput ? {
20238 text: text,
20239 isChecked: isChecked,
20240 userTriggered: userTriggered
20241 } : {
20242 text: text,
20243 isChecked: isChecked
20244 });
20245 var name = target.name;
20246 if (type === "radio" && name && isChecked) {
20247 doc.querySelectorAll('input[type="radio"][name="' + name + '"]').forEach(function(el) {
20248 if (el !== target) {
20249 var text2 = el.value;
20250 cbWithDedup(el, userTriggeredOnInput ? {
20251 text: text2,
20252 isChecked: !isChecked,
20253 userTriggered: false
20254 } : {
20255 text: text2,
20256 isChecked: !isChecked
20257 });
20258 }
20259 });
20260 }
20261 }
20262 function cbWithDedup(target, v2) {
20263 var lastInputValue = lastInputValueMap.get(target);
20264 if (!lastInputValue || lastInputValue.text !== v2.text || lastInputValue.isChecked !== v2.isChecked) {
20265 lastInputValueMap.set(target, v2);
20266 var id = mirror2.getId(target);
20267 callbackWrapper(inputCb)(_extends({}, v2, {
20268 id: id
20269 }));
20270 }
20271 }
20272 var events = sampling.input === "last" ? [
20273 "change"
20274 ] : [
20275 "input",
20276 "change"
20277 ];
20278 var handlers = events.map(function(eventName) {
20279 return on(eventName, callbackWrapper(eventHandler), doc);
20280 });
20281 var currentWindow = doc.defaultView;
20282 if (!currentWindow) {
20283 return function() {
20284 handlers.forEach(function(h) {
20285 return h();
20286 });
20287 };
20288 }
20289 var propertyDescriptor = currentWindow.Object.getOwnPropertyDescriptor(currentWindow.HTMLInputElement.prototype, "value");
20290 var hookProperties = [
20291 [
20292 currentWindow.HTMLInputElement.prototype,
20293 "value"
20294 ],
20295 [
20296 currentWindow.HTMLInputElement.prototype,
20297 "checked"
20298 ],
20299 [
20300 currentWindow.HTMLSelectElement.prototype,
20301 "value"
20302 ],
20303 [
20304 currentWindow.HTMLTextAreaElement.prototype,
20305 "value"
20306 ],
20307 // Some UI library use selectedIndex to set select value
20308 [
20309 currentWindow.HTMLSelectElement.prototype,
20310 "selectedIndex"
20311 ],
20312 [
20313 currentWindow.HTMLOptionElement.prototype,
20314 "selected"
20315 ]
20316 ];
20317 if (propertyDescriptor && propertyDescriptor.set) {
20318 var _handlers;
20319 (_handlers = handlers).push.apply(_handlers, [].concat(hookProperties.map(function(p) {
20320 return hookSetter(p[0], p[1], {
20321 set: function set() {
20322 callbackWrapper(eventHandler)({
20323 target: this,
20324 isTrusted: false
20325 });
20326 }
20327 }, false, currentWindow);
20328 })));
20329 }
20330 return callbackWrapper(function() {
20331 handlers.forEach(function(h) {
20332 return h();
20333 });
20334 });
20335 }
20336 function getNestedCSSRulePositions(rule2) {
20337 var positions = [];
20338 function recurse(childRule, pos) {
20339 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)) {
20340 var rules2 = Array.from(childRule.parentRule.cssRules);
20341 var index2 = rules2.indexOf(childRule);
20342 pos.unshift(index2);
20343 } else if (childRule.parentStyleSheet) {
20344 var rules21 = Array.from(childRule.parentStyleSheet.cssRules);
20345 var index21 = rules21.indexOf(childRule);
20346 pos.unshift(index21);
20347 }
20348 return pos;
20349 }
20350 return recurse(rule2, positions);
20351 }
20352 function getIdAndStyleId(sheet, mirror2, styleMirror) {
20353 var id, styleId;
20354 if (!sheet) return {};
20355 if (sheet.ownerNode) id = mirror2.getId(sheet.ownerNode);
20356 else styleId = styleMirror.getId(sheet);
20357 return {
20358 styleId: styleId,
20359 id: id
20360 };
20361 }
20362 function initStyleSheetObserver(param, param1) {
20363 var styleSheetRuleCb = param.styleSheetRuleCb, mirror2 = param.mirror, stylesheetManager = param.stylesheetManager;
20364 var win = param1.win;
20365 if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) {
20366 return function() {};
20367 }
20368 var insertRule = win.CSSStyleSheet.prototype.insertRule;
20369 win.CSSStyleSheet.prototype.insertRule = new Proxy(insertRule, {
20370 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20371 var rule2 = argumentsList[0], index2 = argumentsList[1];
20372 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20373 if (id && id !== -1 || styleId && styleId !== -1) {
20374 styleSheetRuleCb({
20375 id: id,
20376 styleId: styleId,
20377 adds: [
20378 {
20379 rule: rule2,
20380 index: index2
20381 }
20382 ]
20383 });
20384 }
20385 return target.apply(thisArg, argumentsList);
20386 })
20387 });
20388 win.CSSStyleSheet.prototype.addRule = function(selector, styleBlock, index2) {
20389 if (index2 === void 0) index2 = this.cssRules.length;
20390 var rule2 = selector + " { " + styleBlock + " }";
20391 return win.CSSStyleSheet.prototype.insertRule.apply(this, [
20392 rule2,
20393 index2
20394 ]);
20395 };
20396 var deleteRule = win.CSSStyleSheet.prototype.deleteRule;
20397 win.CSSStyleSheet.prototype.deleteRule = new Proxy(deleteRule, {
20398 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20399 var index2 = argumentsList[0];
20400 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20401 if (id && id !== -1 || styleId && styleId !== -1) {
20402 styleSheetRuleCb({
20403 id: id,
20404 styleId: styleId,
20405 removes: [
20406 {
20407 index: index2
20408 }
20409 ]
20410 });
20411 }
20412 return target.apply(thisArg, argumentsList);
20413 })
20414 });
20415 win.CSSStyleSheet.prototype.removeRule = function(index2) {
20416 return win.CSSStyleSheet.prototype.deleteRule.apply(this, [
20417 index2
20418 ]);
20419 };
20420 var replace;
20421 if (win.CSSStyleSheet.prototype.replace) {
20422 replace = win.CSSStyleSheet.prototype.replace;
20423 win.CSSStyleSheet.prototype.replace = new Proxy(replace, {
20424 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20425 var text = argumentsList[0];
20426 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20427 if (id && id !== -1 || styleId && styleId !== -1) {
20428 styleSheetRuleCb({
20429 id: id,
20430 styleId: styleId,
20431 replace: text
20432 });
20433 }
20434 return target.apply(thisArg, argumentsList);
20435 })
20436 });
20437 }
20438 var replaceSync;
20439 if (win.CSSStyleSheet.prototype.replaceSync) {
20440 replaceSync = win.CSSStyleSheet.prototype.replaceSync;
20441 win.CSSStyleSheet.prototype.replaceSync = new Proxy(replaceSync, {
20442 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20443 var text = argumentsList[0];
20444 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20445 if (id && id !== -1 || styleId && styleId !== -1) {
20446 styleSheetRuleCb({
20447 id: id,
20448 styleId: styleId,
20449 replaceSync: text
20450 });
20451 }
20452 return target.apply(thisArg, argumentsList);
20453 })
20454 });
20455 }
20456 var supportedNestedCSSRuleTypes = {};
20457 if (canMonkeyPatchNestedCSSRule("CSSGroupingRule")) {
20458 supportedNestedCSSRuleTypes.CSSGroupingRule = win.CSSGroupingRule;
20459 } else {
20460 if (canMonkeyPatchNestedCSSRule("CSSMediaRule")) {
20461 supportedNestedCSSRuleTypes.CSSMediaRule = win.CSSMediaRule;
20462 }
20463 if (canMonkeyPatchNestedCSSRule("CSSConditionRule")) {
20464 supportedNestedCSSRuleTypes.CSSConditionRule = win.CSSConditionRule;
20465 }
20466 if (canMonkeyPatchNestedCSSRule("CSSSupportsRule")) {
20467 supportedNestedCSSRuleTypes.CSSSupportsRule = win.CSSSupportsRule;
20468 }
20469 }
20470 var unmodifiedFunctions = {};
20471 Object.entries(supportedNestedCSSRuleTypes).forEach(function(param) {
20472 var typeKey = param[0], type = param[1];
20473 unmodifiedFunctions[typeKey] = {
20474 // eslint-disable-next-line @typescript-eslint/unbound-method
20475 insertRule: type.prototype.insertRule,
20476 // eslint-disable-next-line @typescript-eslint/unbound-method
20477 deleteRule: type.prototype.deleteRule
20478 };
20479 type.prototype.insertRule = new Proxy(unmodifiedFunctions[typeKey].insertRule, {
20480 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20481 var rule2 = argumentsList[0], index2 = argumentsList[1];
20482 var _getIdAndStyleId = getIdAndStyleId(thisArg.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20483 if (id && id !== -1 || styleId && styleId !== -1) {
20484 styleSheetRuleCb({
20485 id: id,
20486 styleId: styleId,
20487 adds: [
20488 {
20489 rule: rule2,
20490 index: [].concat(getNestedCSSRulePositions(thisArg), [
20491 index2 || 0
20492 ])
20493 }
20494 ]
20495 });
20496 }
20497 return target.apply(thisArg, argumentsList);
20498 })
20499 });
20500 type.prototype.deleteRule = new Proxy(unmodifiedFunctions[typeKey].deleteRule, {
20501 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20502 var index2 = argumentsList[0];
20503 var _getIdAndStyleId = getIdAndStyleId(thisArg.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20504 if (id && id !== -1 || styleId && styleId !== -1) {
20505 styleSheetRuleCb({
20506 id: id,
20507 styleId: styleId,
20508 removes: [
20509 {
20510 index: [].concat(getNestedCSSRulePositions(thisArg), [
20511 index2
20512 ])
20513 }
20514 ]
20515 });
20516 }
20517 return target.apply(thisArg, argumentsList);
20518 })
20519 });
20520 });
20521 return callbackWrapper(function() {
20522 win.CSSStyleSheet.prototype.insertRule = insertRule;
20523 win.CSSStyleSheet.prototype.deleteRule = deleteRule;
20524 replace && (win.CSSStyleSheet.prototype.replace = replace);
20525 replaceSync && (win.CSSStyleSheet.prototype.replaceSync = replaceSync);
20526 Object.entries(supportedNestedCSSRuleTypes).forEach(function(param) {
20527 var typeKey = param[0], type = param[1];
20528 type.prototype.insertRule = unmodifiedFunctions[typeKey].insertRule;
20529 type.prototype.deleteRule = unmodifiedFunctions[typeKey].deleteRule;
20530 });
20531 });
20532 }
20533 function initAdoptedStyleSheetObserver(param, host2) {
20534 var mirror2 = param.mirror, stylesheetManager = param.stylesheetManager;
20535 var _a2, _b, _c;
20536 var hostId = null;
20537 if (host2.nodeName === "#document") hostId = mirror2.getId(host2);
20538 else hostId = mirror2.getId(index.host(host2));
20539 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;
20540 var originalPropertyDescriptor = (patchTarget == null ? void 0 : patchTarget.prototype) ? Object.getOwnPropertyDescriptor(patchTarget == null ? void 0 : patchTarget.prototype, "adoptedStyleSheets") : void 0;
20541 if (hostId === null || hostId === -1 || !patchTarget || !originalPropertyDescriptor) return function() {};
20542 Object.defineProperty(host2, "adoptedStyleSheets", {
20543 configurable: originalPropertyDescriptor.configurable,
20544 enumerable: originalPropertyDescriptor.enumerable,
20545 get: function get() {
20546 var _a3;
20547 return (_a3 = originalPropertyDescriptor.get) == null ? void 0 : _a3.call(this);
20548 },
20549 set: function set(sheets) {
20550 var _a3;
20551 var result2 = (_a3 = originalPropertyDescriptor.set) == null ? void 0 : _a3.call(this, sheets);
20552 if (hostId !== null && hostId !== -1) {
20553 try {
20554 stylesheetManager.adoptStyleSheets(sheets, hostId);
20555 } catch (e2) {}
20556 }
20557 return result2;
20558 }
20559 });
20560 return callbackWrapper(function() {
20561 Object.defineProperty(host2, "adoptedStyleSheets", {
20562 configurable: originalPropertyDescriptor.configurable,
20563 enumerable: originalPropertyDescriptor.enumerable,
20564 // eslint-disable-next-line @typescript-eslint/unbound-method
20565 get: originalPropertyDescriptor.get,
20566 // eslint-disable-next-line @typescript-eslint/unbound-method
20567 set: originalPropertyDescriptor.set
20568 });
20569 });
20570 }
20571 function initStyleDeclarationObserver(param, param1) {
20572 var styleDeclarationCb = param.styleDeclarationCb, mirror2 = param.mirror, ignoreCSSAttributes = param.ignoreCSSAttributes, stylesheetManager = param.stylesheetManager;
20573 var win = param1.win;
20574 var setProperty = win.CSSStyleDeclaration.prototype.setProperty;
20575 win.CSSStyleDeclaration.prototype.setProperty = new Proxy(setProperty, {
20576 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20577 var _a2;
20578 var property = argumentsList[0], value = argumentsList[1], priority = argumentsList[2];
20579 if (ignoreCSSAttributes.has(property)) {
20580 return setProperty.apply(thisArg, [
20581 property,
20582 value,
20583 priority
20584 ]);
20585 }
20586 var _getIdAndStyleId = getIdAndStyleId((_a2 = thisArg.parentRule) == null ? void 0 : _a2.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20587 if (id && id !== -1 || styleId && styleId !== -1) {
20588 styleDeclarationCb({
20589 id: id,
20590 styleId: styleId,
20591 set: {
20592 property: property,
20593 value: value,
20594 priority: priority
20595 },
20596 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
20597 index: getNestedCSSRulePositions(thisArg.parentRule)
20598 });
20599 }
20600 return target.apply(thisArg, argumentsList);
20601 })
20602 });
20603 var removeProperty = win.CSSStyleDeclaration.prototype.removeProperty;
20604 win.CSSStyleDeclaration.prototype.removeProperty = new Proxy(removeProperty, {
20605 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20606 var _a2;
20607 var property = argumentsList[0];
20608 if (ignoreCSSAttributes.has(property)) {
20609 return removeProperty.apply(thisArg, [
20610 property
20611 ]);
20612 }
20613 var _getIdAndStyleId = getIdAndStyleId((_a2 = thisArg.parentRule) == null ? void 0 : _a2.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20614 if (id && id !== -1 || styleId && styleId !== -1) {
20615 styleDeclarationCb({
20616 id: id,
20617 styleId: styleId,
20618 remove: {
20619 property: property
20620 },
20621 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
20622 index: getNestedCSSRulePositions(thisArg.parentRule)
20623 });
20624 }
20625 return target.apply(thisArg, argumentsList);
20626 })
20627 });
20628 return callbackWrapper(function() {
20629 win.CSSStyleDeclaration.prototype.setProperty = setProperty;
20630 win.CSSStyleDeclaration.prototype.removeProperty = removeProperty;
20631 });
20632 }
20633 function initMediaInteractionObserver(param) {
20634 var mediaInteractionCb = param.mediaInteractionCb, blockClass = param.blockClass, blockSelector = param.blockSelector, mirror2 = param.mirror, sampling = param.sampling, doc = param.doc;
20635 var handler = callbackWrapper(function(type) {
20636 return throttle(callbackWrapper(function(event) {
20637 var target = getEventTarget(event);
20638 if (!target || isBlocked(target, blockClass, blockSelector, true)) {
20639 return;
20640 }
20641 var currentTime = target.currentTime, volume = target.volume, muted = target.muted, playbackRate = target.playbackRate, loop = target.loop;
20642 mediaInteractionCb({
20643 type: type,
20644 id: mirror2.getId(target),
20645 currentTime: currentTime,
20646 volume: volume,
20647 muted: muted,
20648 playbackRate: playbackRate,
20649 loop: loop
20650 });
20651 }), sampling.media || 500);
20652 });
20653 var handlers = [
20654 on("play", handler(MediaInteractions.Play), doc),
20655 on("pause", handler(MediaInteractions.Pause), doc),
20656 on("seeked", handler(MediaInteractions.Seeked), doc),
20657 on("volumechange", handler(MediaInteractions.VolumeChange), doc),
20658 on("ratechange", handler(MediaInteractions.RateChange), doc)
20659 ];
20660 return callbackWrapper(function() {
20661 handlers.forEach(function(h) {
20662 return h();
20663 });
20664 });
20665 }
20666 function initFontObserver(param) {
20667 var fontCb = param.fontCb, doc = param.doc;
20668 var win = doc.defaultView;
20669 if (!win) {
20670 return function() {};
20671 }
20672 var handlers = [];
20673 var fontMap = /* @__PURE__ */ new WeakMap();
20674 var originalFontFace = win.FontFace;
20675 win.FontFace = function FontFace2(family, source, descriptors) {
20676 var fontFace = new originalFontFace(family, source, descriptors);
20677 fontMap.set(fontFace, {
20678 family: family,
20679 buffer: typeof source !== "string",
20680 descriptors: descriptors,
20681 fontSource: typeof source === "string" ? source : JSON.stringify(Array.from(new Uint8Array(source)))
20682 });
20683 return fontFace;
20684 };
20685 var restoreHandler = patch(doc.fonts, "add", function(original) {
20686 return function(fontFace) {
20687 setTimeout(callbackWrapper(function() {
20688 var p = fontMap.get(fontFace);
20689 if (p) {
20690 fontCb(p);
20691 fontMap.delete(fontFace);
20692 }
20693 }), 0);
20694 return original.apply(this, [
20695 fontFace
20696 ]);
20697 };
20698 });
20699 handlers.push(function() {
20700 win.FontFace = originalFontFace;
20701 });
20702 handlers.push(restoreHandler);
20703 return callbackWrapper(function() {
20704 handlers.forEach(function(h) {
20705 return h();
20706 });
20707 });
20708 }
20709 function initSelectionObserver(param) {
20710 var doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, selectionCb = param.selectionCb;
20711 var collapsed = true;
20712 var updateSelection = callbackWrapper(function() {
20713 var selection = doc.getSelection();
20714 if (!selection || collapsed && (selection == null ? void 0 : selection.isCollapsed)) return;
20715 collapsed = selection.isCollapsed || false;
20716 var ranges = [];
20717 var count = selection.rangeCount || 0;
20718 for(var i2 = 0; i2 < count; i2++){
20719 var range = selection.getRangeAt(i2);
20720 var startContainer = range.startContainer, startOffset = range.startOffset, endContainer = range.endContainer, endOffset = range.endOffset;
20721 var blocked = isBlocked(startContainer, blockClass, blockSelector, true) || isBlocked(endContainer, blockClass, blockSelector, true);
20722 if (blocked) continue;
20723 ranges.push({
20724 start: mirror2.getId(startContainer),
20725 startOffset: startOffset,
20726 end: mirror2.getId(endContainer),
20727 endOffset: endOffset
20728 });
20729 }
20730 selectionCb({
20731 ranges: ranges
20732 });
20733 });
20734 updateSelection();
20735 return on("selectionchange", updateSelection);
20736 }
20737 function initCustomElementObserver(param) {
20738 var doc = param.doc, customElementCb = param.customElementCb;
20739 var win = doc.defaultView;
20740 if (!win || !win.customElements) return function() {};
20741 var restoreHandler = patch(win.customElements, "define", function(original) {
20742 return function(name, constructor, options) {
20743 try {
20744 customElementCb({
20745 define: {
20746 name: name
20747 }
20748 });
20749 } catch (e2) {
20750 console.warn("Custom element callback failed for " + name);
20751 }
20752 return original.apply(this, [
20753 name,
20754 constructor,
20755 options
20756 ]);
20757 };
20758 });
20759 return restoreHandler;
20760 }
20761 function mergeHooks(o2, hooks) {
20762 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;
20763 o2.mutationCb = function() {
20764 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20765 p[_key] = arguments[_key];
20766 }
20767 if (hooks.mutation) {
20768 var _hooks;
20769 (_hooks = hooks).mutation.apply(_hooks, [].concat(p));
20770 }
20771 mutationCb.apply(void 0, [].concat(p));
20772 };
20773 o2.mousemoveCb = function() {
20774 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20775 p[_key] = arguments[_key];
20776 }
20777 if (hooks.mousemove) {
20778 var _hooks;
20779 (_hooks = hooks).mousemove.apply(_hooks, [].concat(p));
20780 }
20781 mousemoveCb.apply(void 0, [].concat(p));
20782 };
20783 o2.mouseInteractionCb = function() {
20784 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20785 p[_key] = arguments[_key];
20786 }
20787 if (hooks.mouseInteraction) {
20788 var _hooks;
20789 (_hooks = hooks).mouseInteraction.apply(_hooks, [].concat(p));
20790 }
20791 mouseInteractionCb.apply(void 0, [].concat(p));
20792 };
20793 o2.scrollCb = function() {
20794 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20795 p[_key] = arguments[_key];
20796 }
20797 if (hooks.scroll) {
20798 var _hooks;
20799 (_hooks = hooks).scroll.apply(_hooks, [].concat(p));
20800 }
20801 scrollCb.apply(void 0, [].concat(p));
20802 };
20803 o2.viewportResizeCb = function() {
20804 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20805 p[_key] = arguments[_key];
20806 }
20807 if (hooks.viewportResize) {
20808 var _hooks;
20809 (_hooks = hooks).viewportResize.apply(_hooks, [].concat(p));
20810 }
20811 viewportResizeCb.apply(void 0, [].concat(p));
20812 };
20813 o2.inputCb = function() {
20814 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20815 p[_key] = arguments[_key];
20816 }
20817 if (hooks.input) {
20818 var _hooks;
20819 (_hooks = hooks).input.apply(_hooks, [].concat(p));
20820 }
20821 inputCb.apply(void 0, [].concat(p));
20822 };
20823 o2.mediaInteractionCb = function() {
20824 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20825 p[_key] = arguments[_key];
20826 }
20827 if (hooks.mediaInteaction) {
20828 var _hooks;
20829 (_hooks = hooks).mediaInteaction.apply(_hooks, [].concat(p));
20830 }
20831 mediaInteractionCb.apply(void 0, [].concat(p));
20832 };
20833 o2.styleSheetRuleCb = function() {
20834 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20835 p[_key] = arguments[_key];
20836 }
20837 if (hooks.styleSheetRule) {
20838 var _hooks;
20839 (_hooks = hooks).styleSheetRule.apply(_hooks, [].concat(p));
20840 }
20841 styleSheetRuleCb.apply(void 0, [].concat(p));
20842 };
20843 o2.styleDeclarationCb = function() {
20844 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20845 p[_key] = arguments[_key];
20846 }
20847 if (hooks.styleDeclaration) {
20848 var _hooks;
20849 (_hooks = hooks).styleDeclaration.apply(_hooks, [].concat(p));
20850 }
20851 styleDeclarationCb.apply(void 0, [].concat(p));
20852 };
20853 o2.canvasMutationCb = function() {
20854 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20855 p[_key] = arguments[_key];
20856 }
20857 if (hooks.canvasMutation) {
20858 var _hooks;
20859 (_hooks = hooks).canvasMutation.apply(_hooks, [].concat(p));
20860 }
20861 canvasMutationCb.apply(void 0, [].concat(p));
20862 };
20863 o2.fontCb = function() {
20864 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20865 p[_key] = arguments[_key];
20866 }
20867 if (hooks.font) {
20868 var _hooks;
20869 (_hooks = hooks).font.apply(_hooks, [].concat(p));
20870 }
20871 fontCb.apply(void 0, [].concat(p));
20872 };
20873 o2.selectionCb = function() {
20874 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20875 p[_key] = arguments[_key];
20876 }
20877 if (hooks.selection) {
20878 var _hooks;
20879 (_hooks = hooks).selection.apply(_hooks, [].concat(p));
20880 }
20881 selectionCb.apply(void 0, [].concat(p));
20882 };
20883 o2.customElementCb = function() {
20884 for(var _len = arguments.length, c2 = new Array(_len), _key = 0; _key < _len; _key++){
20885 c2[_key] = arguments[_key];
20886 }
20887 if (hooks.customElement) {
20888 var _hooks;
20889 (_hooks = hooks).customElement.apply(_hooks, [].concat(c2));
20890 }
20891 customElementCb.apply(void 0, [].concat(c2));
20892 };
20893 }
20894 function initObservers(o2, hooks) {
20895 if (hooks === void 0) hooks = {};
20896 var currentWindow = o2.doc.defaultView;
20897 if (!currentWindow) {
20898 return function() {};
20899 }
20900 mergeHooks(o2, hooks);
20901 var mutationObserver;
20902 if (o2.recordDOM) {
20903 mutationObserver = initMutationObserver(o2, o2.doc);
20904 }
20905 var mousemoveHandler = initMoveObserver(o2);
20906 var mouseInteractionHandler = initMouseInteractionObserver(o2);
20907 var scrollHandler = initScrollObserver(o2);
20908 var viewportResizeHandler = initViewportResizeObserver(o2, {
20909 win: currentWindow
20910 });
20911 var inputHandler = initInputObserver(o2);
20912 var mediaInteractionHandler = initMediaInteractionObserver(o2);
20913 var styleSheetObserver = function() {};
20914 var adoptedStyleSheetObserver = function() {};
20915 var styleDeclarationObserver = function() {};
20916 var fontObserver = function() {};
20917 if (o2.recordDOM) {
20918 styleSheetObserver = initStyleSheetObserver(o2, {
20919 win: currentWindow
20920 });
20921 adoptedStyleSheetObserver = initAdoptedStyleSheetObserver(o2, o2.doc);
20922 styleDeclarationObserver = initStyleDeclarationObserver(o2, {
20923 win: currentWindow
20924 });
20925 if (o2.collectFonts) {
20926 fontObserver = initFontObserver(o2);
20927 }
20928 }
20929 var selectionObserver = initSelectionObserver(o2);
20930 var customElementObserver = initCustomElementObserver(o2);
20931 var pluginHandlers = [];
20932 for(var _iterator = _create_for_of_iterator_helper_loose(o2.plugins), _step; !(_step = _iterator()).done;){
20933 var plugin3 = _step.value;
20934 pluginHandlers.push(plugin3.observer(plugin3.callback, currentWindow, plugin3.options));
20935 }
20936 return callbackWrapper(function() {
20937 mutationBuffers.forEach(function(b) {
20938 return b.reset();
20939 });
20940 mutationObserver == null ? void 0 : mutationObserver.disconnect();
20941 mousemoveHandler();
20942 mouseInteractionHandler();
20943 scrollHandler();
20944 viewportResizeHandler();
20945 inputHandler();
20946 mediaInteractionHandler();
20947 styleSheetObserver();
20948 adoptedStyleSheetObserver();
20949 styleDeclarationObserver();
20950 fontObserver();
20951 selectionObserver();
20952 customElementObserver();
20953 pluginHandlers.forEach(function(h) {
20954 return h();
20955 });
20956 });
20957 }
20958 function hasNestedCSSRule(prop) {
20959 return typeof window[prop] !== "undefined";
20960 }
20961 function canMonkeyPatchNestedCSSRule(prop) {
20962 return Boolean(typeof window[prop] !== "undefined" && // Note: Generally, this check _shouldn't_ be necessary
20963 // However, in some scenarios (e.g. jsdom) this can sometimes fail, so we check for it here
20964 window[prop].prototype && "insertRule" in window[prop].prototype && "deleteRule" in window[prop].prototype);
20965 }
20966 var CrossOriginIframeMirror = /*#__PURE__*/ function() {
20967 function CrossOriginIframeMirror(generateIdFn) {
20968 __publicField(this, "iframeIdToRemoteIdMap", /* @__PURE__ */ new WeakMap());
20969 __publicField(this, "iframeRemoteIdToIdMap", /* @__PURE__ */ new WeakMap());
20970 this.generateIdFn = generateIdFn;
20971 }
20972 var _proto = CrossOriginIframeMirror.prototype;
20973 _proto.getId = function getId(iframe, remoteId, idToRemoteMap, remoteToIdMap) {
20974 var idToRemoteIdMap = idToRemoteMap || this.getIdToRemoteIdMap(iframe);
20975 var remoteIdToIdMap = remoteToIdMap || this.getRemoteIdToIdMap(iframe);
20976 var id = idToRemoteIdMap.get(remoteId);
20977 if (!id) {
20978 id = this.generateIdFn();
20979 idToRemoteIdMap.set(remoteId, id);
20980 remoteIdToIdMap.set(id, remoteId);
20981 }
20982 return id;
20983 };
20984 _proto.getIds = function getIds(iframe, remoteId) {
20985 var _this = this;
20986 var idToRemoteIdMap = this.getIdToRemoteIdMap(iframe);
20987 var remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);
20988 return remoteId.map(function(id) {
20989 return _this.getId(iframe, id, idToRemoteIdMap, remoteIdToIdMap);
20990 });
20991 };
20992 _proto.getRemoteId = function getRemoteId(iframe, id, map) {
20993 var remoteIdToIdMap = map || this.getRemoteIdToIdMap(iframe);
20994 if (typeof id !== "number") return id;
20995 var remoteId = remoteIdToIdMap.get(id);
20996 if (!remoteId) return -1;
20997 return remoteId;
20998 };
20999 _proto.getRemoteIds = function getRemoteIds(iframe, ids) {
21000 var _this = this;
21001 var remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);
21002 return ids.map(function(id) {
21003 return _this.getRemoteId(iframe, id, remoteIdToIdMap);
21004 });
21005 };
21006 _proto.reset = function reset(iframe) {
21007 if (!iframe) {
21008 this.iframeIdToRemoteIdMap = /* @__PURE__ */ new WeakMap();
21009 this.iframeRemoteIdToIdMap = /* @__PURE__ */ new WeakMap();
21010 return;
21011 }
21012 this.iframeIdToRemoteIdMap.delete(iframe);
21013 this.iframeRemoteIdToIdMap.delete(iframe);
21014 };
21015 _proto.getIdToRemoteIdMap = function getIdToRemoteIdMap(iframe) {
21016 var idToRemoteIdMap = this.iframeIdToRemoteIdMap.get(iframe);
21017 if (!idToRemoteIdMap) {
21018 idToRemoteIdMap = /* @__PURE__ */ new Map();
21019 this.iframeIdToRemoteIdMap.set(iframe, idToRemoteIdMap);
21020 }
21021 return idToRemoteIdMap;
21022 };
21023 _proto.getRemoteIdToIdMap = function getRemoteIdToIdMap(iframe) {
21024 var remoteIdToIdMap = this.iframeRemoteIdToIdMap.get(iframe);
21025 if (!remoteIdToIdMap) {
21026 remoteIdToIdMap = /* @__PURE__ */ new Map();
21027 this.iframeRemoteIdToIdMap.set(iframe, remoteIdToIdMap);
21028 }
21029 return remoteIdToIdMap;
21030 };
21031 return CrossOriginIframeMirror;
21032 }();
21033 var IframeManager = /*#__PURE__*/ function() {
21034 function IframeManager(options) {
21035 __publicField(this, "iframes", /* @__PURE__ */ new WeakMap());
21036 __publicField(this, "crossOriginIframeMap", /* @__PURE__ */ new WeakMap());
21037 __publicField(this, "crossOriginIframeMirror", new CrossOriginIframeMirror(genId));
21038 __publicField(this, "crossOriginIframeStyleMirror");
21039 __publicField(this, "crossOriginIframeRootIdMap", /* @__PURE__ */ new WeakMap());
21040 __publicField(this, "mirror");
21041 __publicField(this, "mutationCb");
21042 __publicField(this, "wrappedEmit");
21043 __publicField(this, "loadListener");
21044 __publicField(this, "stylesheetManager");
21045 __publicField(this, "recordCrossOriginIframes");
21046 this.mutationCb = options.mutationCb;
21047 this.wrappedEmit = options.wrappedEmit;
21048 this.stylesheetManager = options.stylesheetManager;
21049 this.recordCrossOriginIframes = options.recordCrossOriginIframes;
21050 this.crossOriginIframeStyleMirror = new CrossOriginIframeMirror(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror));
21051 this.mirror = options.mirror;
21052 if (this.recordCrossOriginIframes) {
21053 window.addEventListener("message", this.handleMessage.bind(this));
21054 }
21055 }
21056 var _proto = IframeManager.prototype;
21057 _proto.addIframe = function addIframe(iframeEl) {
21058 this.iframes.set(iframeEl, true);
21059 if (iframeEl.contentWindow) this.crossOriginIframeMap.set(iframeEl.contentWindow, iframeEl);
21060 };
21061 _proto.addLoadListener = function addLoadListener(cb) {
21062 this.loadListener = cb;
21063 };
21064 _proto.attachIframe = function attachIframe(iframeEl, childSn) {
21065 var _a2, _b;
21066 this.mutationCb({
21067 adds: [
21068 {
21069 parentId: this.mirror.getId(iframeEl),
21070 nextId: null,
21071 node: childSn
21072 }
21073 ],
21074 removes: [],
21075 texts: [],
21076 attributes: [],
21077 isAttachIframe: true
21078 });
21079 if (this.recordCrossOriginIframes) (_a2 = iframeEl.contentWindow) == null ? void 0 : _a2.addEventListener("message", this.handleMessage.bind(this));
21080 (_b = this.loadListener) == null ? void 0 : _b.call(this, iframeEl);
21081 if (iframeEl.contentDocument && iframeEl.contentDocument.adoptedStyleSheets && iframeEl.contentDocument.adoptedStyleSheets.length > 0) this.stylesheetManager.adoptStyleSheets(iframeEl.contentDocument.adoptedStyleSheets, this.mirror.getId(iframeEl.contentDocument));
21082 };
21083 _proto.handleMessage = function handleMessage(message) {
21084 var crossOriginMessageEvent = message;
21085 if (crossOriginMessageEvent.data.type !== "rrweb" || // To filter out the rrweb messages which are forwarded by some sites.
21086 crossOriginMessageEvent.origin !== crossOriginMessageEvent.data.origin) return;
21087 var iframeSourceWindow = message.source;
21088 if (!iframeSourceWindow) return;
21089 var iframeEl = this.crossOriginIframeMap.get(message.source);
21090 if (!iframeEl) return;
21091 var transformedEvent = this.transformCrossOriginEvent(iframeEl, crossOriginMessageEvent.data.event);
21092 if (transformedEvent) this.wrappedEmit(transformedEvent, crossOriginMessageEvent.data.isCheckout);
21093 };
21094 _proto.transformCrossOriginEvent = function transformCrossOriginEvent(iframeEl, e2) {
21095 var _this = this;
21096 var _a2;
21097 switch(e2.type){
21098 case EventType.FullSnapshot:
21099 {
21100 this.crossOriginIframeMirror.reset(iframeEl);
21101 this.crossOriginIframeStyleMirror.reset(iframeEl);
21102 this.replaceIdOnNode(e2.data.node, iframeEl);
21103 var rootId = e2.data.node.id;
21104 this.crossOriginIframeRootIdMap.set(iframeEl, rootId);
21105 this.patchRootIdOnNode(e2.data.node, rootId);
21106 return {
21107 timestamp: e2.timestamp,
21108 type: EventType.IncrementalSnapshot,
21109 data: {
21110 source: IncrementalSource.Mutation,
21111 adds: [
21112 {
21113 parentId: this.mirror.getId(iframeEl),
21114 nextId: null,
21115 node: e2.data.node
21116 }
21117 ],
21118 removes: [],
21119 texts: [],
21120 attributes: [],
21121 isAttachIframe: true
21122 }
21123 };
21124 }
21125 case EventType.Meta:
21126 case EventType.Load:
21127 case EventType.DomContentLoaded:
21128 {
21129 return false;
21130 }
21131 case EventType.Plugin:
21132 {
21133 return e2;
21134 }
21135 case EventType.Custom:
21136 {
21137 this.replaceIds(e2.data.payload, iframeEl, [
21138 "id",
21139 "parentId",
21140 "previousId",
21141 "nextId"
21142 ]);
21143 return e2;
21144 }
21145 case EventType.IncrementalSnapshot:
21146 {
21147 switch(e2.data.source){
21148 case IncrementalSource.Mutation:
21149 {
21150 e2.data.adds.forEach(function(n2) {
21151 _this.replaceIds(n2, iframeEl, [
21152 "parentId",
21153 "nextId",
21154 "previousId"
21155 ]);
21156 _this.replaceIdOnNode(n2.node, iframeEl);
21157 var rootId = _this.crossOriginIframeRootIdMap.get(iframeEl);
21158 rootId && _this.patchRootIdOnNode(n2.node, rootId);
21159 });
21160 e2.data.removes.forEach(function(n2) {
21161 _this.replaceIds(n2, iframeEl, [
21162 "parentId",
21163 "id"
21164 ]);
21165 });
21166 e2.data.attributes.forEach(function(n2) {
21167 _this.replaceIds(n2, iframeEl, [
21168 "id"
21169 ]);
21170 });
21171 e2.data.texts.forEach(function(n2) {
21172 _this.replaceIds(n2, iframeEl, [
21173 "id"
21174 ]);
21175 });
21176 return e2;
21177 }
21178 case IncrementalSource.Drag:
21179 case IncrementalSource.TouchMove:
21180 case IncrementalSource.MouseMove:
21181 {
21182 e2.data.positions.forEach(function(p) {
21183 _this.replaceIds(p, iframeEl, [
21184 "id"
21185 ]);
21186 });
21187 return e2;
21188 }
21189 case IncrementalSource.ViewportResize:
21190 {
21191 return false;
21192 }
21193 case IncrementalSource.MediaInteraction:
21194 case IncrementalSource.MouseInteraction:
21195 case IncrementalSource.Scroll:
21196 case IncrementalSource.CanvasMutation:
21197 case IncrementalSource.Input:
21198 {
21199 this.replaceIds(e2.data, iframeEl, [
21200 "id"
21201 ]);
21202 return e2;
21203 }
21204 case IncrementalSource.StyleSheetRule:
21205 case IncrementalSource.StyleDeclaration:
21206 {
21207 this.replaceIds(e2.data, iframeEl, [
21208 "id"
21209 ]);
21210 this.replaceStyleIds(e2.data, iframeEl, [
21211 "styleId"
21212 ]);
21213 return e2;
21214 }
21215 case IncrementalSource.Font:
21216 {
21217 return e2;
21218 }
21219 case IncrementalSource.Selection:
21220 {
21221 e2.data.ranges.forEach(function(range) {
21222 _this.replaceIds(range, iframeEl, [
21223 "start",
21224 "end"
21225 ]);
21226 });
21227 return e2;
21228 }
21229 case IncrementalSource.AdoptedStyleSheet:
21230 {
21231 this.replaceIds(e2.data, iframeEl, [
21232 "id"
21233 ]);
21234 this.replaceStyleIds(e2.data, iframeEl, [
21235 "styleIds"
21236 ]);
21237 (_a2 = e2.data.styles) == null ? void 0 : _a2.forEach(function(style) {
21238 _this.replaceStyleIds(style, iframeEl, [
21239 "styleId"
21240 ]);
21241 });
21242 return e2;
21243 }
21244 }
21245 }
21246 }
21247 return false;
21248 };
21249 _proto.replace = function replace(iframeMirror, obj, iframeEl, keys) {
21250 for(var _iterator = _create_for_of_iterator_helper_loose(keys), _step; !(_step = _iterator()).done;){
21251 var key = _step.value;
21252 if (!Array.isArray(obj[key]) && typeof obj[key] !== "number") continue;
21253 if (Array.isArray(obj[key])) {
21254 obj[key] = iframeMirror.getIds(iframeEl, obj[key]);
21255 } else {
21256 obj[key] = iframeMirror.getId(iframeEl, obj[key]);
21257 }
21258 }
21259 return obj;
21260 };
21261 _proto.replaceIds = function replaceIds(obj, iframeEl, keys) {
21262 return this.replace(this.crossOriginIframeMirror, obj, iframeEl, keys);
21263 };
21264 _proto.replaceStyleIds = function replaceStyleIds(obj, iframeEl, keys) {
21265 return this.replace(this.crossOriginIframeStyleMirror, obj, iframeEl, keys);
21266 };
21267 _proto.replaceIdOnNode = function replaceIdOnNode(node2, iframeEl) {
21268 var _this = this;
21269 this.replaceIds(node2, iframeEl, [
21270 "id",
21271 "rootId"
21272 ]);
21273 if ("childNodes" in node2) {
21274 node2.childNodes.forEach(function(child) {
21275 _this.replaceIdOnNode(child, iframeEl);
21276 });
21277 }
21278 };
21279 _proto.patchRootIdOnNode = function patchRootIdOnNode(node2, rootId) {
21280 var _this = this;
21281 if (node2.type !== NodeType.Document && !node2.rootId) node2.rootId = rootId;
21282 if ("childNodes" in node2) {
21283 node2.childNodes.forEach(function(child) {
21284 _this.patchRootIdOnNode(child, rootId);
21285 });
21286 }
21287 };
21288 return IframeManager;
21289 }();
21290 var ShadowDomManager = /*#__PURE__*/ function() {
21291 function ShadowDomManager(options) {
21292 __publicField(this, "shadowDoms", /* @__PURE__ */ new WeakSet());
21293 __publicField(this, "mutationCb");
21294 __publicField(this, "scrollCb");
21295 __publicField(this, "bypassOptions");
21296 __publicField(this, "mirror");
21297 __publicField(this, "restoreHandlers", []);
21298 this.mutationCb = options.mutationCb;
21299 this.scrollCb = options.scrollCb;
21300 this.bypassOptions = options.bypassOptions;
21301 this.mirror = options.mirror;
21302 this.init();
21303 }
21304 var _proto = ShadowDomManager.prototype;
21305 _proto.init = function init() {
21306 this.reset();
21307 this.patchAttachShadow(Element, document);
21308 };
21309 _proto.addShadowRoot = function addShadowRoot(shadowRoot2, doc) {
21310 var _this = this;
21311 if (!isNativeShadowDom(shadowRoot2)) return;
21312 if (this.shadowDoms.has(shadowRoot2)) return;
21313 this.shadowDoms.add(shadowRoot2);
21314 var observer = initMutationObserver(_extends({}, this.bypassOptions, {
21315 doc: doc,
21316 mutationCb: this.mutationCb,
21317 mirror: this.mirror,
21318 shadowDomManager: this
21319 }), shadowRoot2);
21320 this.restoreHandlers.push(function() {
21321 return observer.disconnect();
21322 });
21323 this.restoreHandlers.push(initScrollObserver(_extends({}, this.bypassOptions, {
21324 scrollCb: this.scrollCb,
21325 // https://gist.github.com/praveenpuglia/0832da687ed5a5d7a0907046c9ef1813
21326 // scroll is not allowed to pass the boundary, so we need to listen the shadow document
21327 doc: shadowRoot2,
21328 mirror: this.mirror
21329 })));
21330 setTimeout(function() {
21331 if (shadowRoot2.adoptedStyleSheets && shadowRoot2.adoptedStyleSheets.length > 0) _this.bypassOptions.stylesheetManager.adoptStyleSheets(shadowRoot2.adoptedStyleSheets, _this.mirror.getId(index.host(shadowRoot2)));
21332 _this.restoreHandlers.push(initAdoptedStyleSheetObserver({
21333 mirror: _this.mirror,
21334 stylesheetManager: _this.bypassOptions.stylesheetManager
21335 }, shadowRoot2));
21336 }, 0);
21337 };
21338 /**
21339 * Monkey patch 'attachShadow' of an IFrameElement to observe newly added shadow doms.
21340 */ _proto.observeAttachShadow = function observeAttachShadow(iframeElement) {
21341 if (!iframeElement.contentWindow || !iframeElement.contentDocument) return;
21342 this.patchAttachShadow(iframeElement.contentWindow.Element, iframeElement.contentDocument);
21343 };
21344 /**
21345 * Patch 'attachShadow' to observe newly added shadow doms.
21346 */ _proto.patchAttachShadow = function patchAttachShadow(element, doc) {
21347 var manager = this;
21348 this.restoreHandlers.push(patch(element.prototype, "attachShadow", function(original) {
21349 return function(option) {
21350 var sRoot = original.call(this, option);
21351 var shadowRootEl = index.shadowRoot(this);
21352 if (shadowRootEl && inDom(this)) manager.addShadowRoot(shadowRootEl, doc);
21353 return sRoot;
21354 };
21355 }));
21356 };
21357 _proto.reset = function reset() {
21358 this.restoreHandlers.forEach(function(handler) {
21359 try {
21360 handler();
21361 } catch (e2) {}
21362 });
21363 this.restoreHandlers = [];
21364 this.shadowDoms = /* @__PURE__ */ new WeakSet();
21365 };
21366 return ShadowDomManager;
21367 }();
21368 var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
21369 var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
21370 for(var i$1 = 0; i$1 < chars.length; i$1++){
21371 lookup[chars.charCodeAt(i$1)] = i$1;
21372 }
21373 var encode = function encode(arraybuffer) {
21374 var bytes = new Uint8Array(arraybuffer), i2, len = bytes.length, base64 = "";
21375 for(i2 = 0; i2 < len; i2 += 3){
21376 base64 += chars[bytes[i2] >> 2];
21377 base64 += chars[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4];
21378 base64 += chars[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6];
21379 base64 += chars[bytes[i2 + 2] & 63];
21380 }
21381 if (len % 3 === 2) {
21382 base64 = base64.substring(0, base64.length - 1) + "=";
21383 } else if (len % 3 === 1) {
21384 base64 = base64.substring(0, base64.length - 2) + "==";
21385 }
21386 return base64;
21387 };
21388 var canvasVarMap = /* @__PURE__ */ new Map();
21389 function variableListFor$1(ctx, ctor) {
21390 var contextMap = canvasVarMap.get(ctx);
21391 if (!contextMap) {
21392 contextMap = /* @__PURE__ */ new Map();
21393 canvasVarMap.set(ctx, contextMap);
21394 }
21395 if (!contextMap.has(ctor)) {
21396 contextMap.set(ctor, []);
21397 }
21398 return contextMap.get(ctor);
21399 }
21400 var saveWebGLVar = function(value, win, ctx) {
21401 if (!value || !(isInstanceOfWebGLObject(value, win) || (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object")) return;
21402 var name = value.constructor.name;
21403 var list2 = variableListFor$1(ctx, name);
21404 var index2 = list2.indexOf(value);
21405 if (index2 === -1) {
21406 index2 = list2.length;
21407 list2.push(value);
21408 }
21409 return index2;
21410 };
21411 function serializeArg(value, win, ctx) {
21412 if (_instanceof(value, Array)) {
21413 return value.map(function(arg) {
21414 return serializeArg(arg, win, ctx);
21415 });
21416 } else if (value === null) {
21417 return value;
21418 } 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)) {
21419 var name = value.constructor.name;
21420 return {
21421 rr_type: name,
21422 args: [
21423 Object.values(value)
21424 ]
21425 };
21426 } else if (// SharedArrayBuffer disabled on most browsers due to spectre.
21427 // More info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/SharedArrayBuffer
21428 // value instanceof SharedArrayBuffer ||
21429 _instanceof(value, ArrayBuffer)) {
21430 var name1 = value.constructor.name;
21431 var base64 = encode(value);
21432 return {
21433 rr_type: name1,
21434 base64: base64
21435 };
21436 } else if (_instanceof(value, DataView)) {
21437 var name2 = value.constructor.name;
21438 return {
21439 rr_type: name2,
21440 args: [
21441 serializeArg(value.buffer, win, ctx),
21442 value.byteOffset,
21443 value.byteLength
21444 ]
21445 };
21446 } else if (_instanceof(value, HTMLImageElement)) {
21447 var name3 = value.constructor.name;
21448 var src = value.src;
21449 return {
21450 rr_type: name3,
21451 src: src
21452 };
21453 } else if (_instanceof(value, HTMLCanvasElement)) {
21454 var name4 = "HTMLImageElement";
21455 var src1 = value.toDataURL();
21456 return {
21457 rr_type: name4,
21458 src: src1
21459 };
21460 } else if (_instanceof(value, ImageData)) {
21461 var name5 = value.constructor.name;
21462 return {
21463 rr_type: name5,
21464 args: [
21465 serializeArg(value.data, win, ctx),
21466 value.width,
21467 value.height
21468 ]
21469 };
21470 } else if (isInstanceOfWebGLObject(value, win) || (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object") {
21471 var name6 = value.constructor.name;
21472 var index2 = saveWebGLVar(value, win, ctx);
21473 return {
21474 rr_type: name6,
21475 index: index2
21476 };
21477 }
21478 return value;
21479 }
21480 var serializeArgs = function(args, win, ctx) {
21481 return args.map(function(arg) {
21482 return serializeArg(arg, win, ctx);
21483 });
21484 };
21485 var isInstanceOfWebGLObject = function(value, win) {
21486 var webGLConstructorNames = [
21487 "WebGLActiveInfo",
21488 "WebGLBuffer",
21489 "WebGLFramebuffer",
21490 "WebGLProgram",
21491 "WebGLRenderbuffer",
21492 "WebGLShader",
21493 "WebGLShaderPrecisionFormat",
21494 "WebGLTexture",
21495 "WebGLUniformLocation",
21496 "WebGLVertexArrayObject",
21497 // In old Chrome versions, value won't be an instanceof WebGLVertexArrayObject.
21498 "WebGLVertexArrayObjectOES"
21499 ];
21500 var supportedWebGLConstructorNames = webGLConstructorNames.filter(function(name) {
21501 return typeof win[name] === "function";
21502 });
21503 return Boolean(supportedWebGLConstructorNames.find(function(name) {
21504 return _instanceof(value, win[name]);
21505 }));
21506 };
21507 function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector) {
21508 var _loop = function() {
21509 var prop = _step.value;
21510 try {
21511 if (typeof win.CanvasRenderingContext2D.prototype[prop] !== "function") {
21512 return "continue";
21513 }
21514 var restoreHandler = patch(win.CanvasRenderingContext2D.prototype, prop, function(original) {
21515 return function() {
21516 var _this = this;
21517 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
21518 args[_key] = arguments[_key];
21519 }
21520 if (!isBlocked(this.canvas, blockClass, blockSelector, true)) {
21521 setTimeout(function() {
21522 var recordArgs = serializeArgs(args, win, _this);
21523 cb(_this.canvas, {
21524 type: CanvasContext["2D"],
21525 property: prop,
21526 args: recordArgs
21527 });
21528 }, 0);
21529 }
21530 return original.apply(this, args);
21531 };
21532 });
21533 handlers.push(restoreHandler);
21534 } catch (e) {
21535 var hookHandler = hookSetter(win.CanvasRenderingContext2D.prototype, prop, {
21536 set: function set(v2) {
21537 cb(this.canvas, {
21538 type: CanvasContext["2D"],
21539 property: prop,
21540 args: [
21541 v2
21542 ],
21543 setter: true
21544 });
21545 }
21546 });
21547 handlers.push(hookHandler);
21548 }
21549 };
21550 var handlers = [];
21551 var props2D = Object.getOwnPropertyNames(win.CanvasRenderingContext2D.prototype);
21552 for(var _iterator = _create_for_of_iterator_helper_loose(props2D), _step; !(_step = _iterator()).done;)_loop();
21553 return function() {
21554 handlers.forEach(function(h) {
21555 return h();
21556 });
21557 };
21558 }
21559 function getNormalizedContextName(contextType) {
21560 return contextType === "experimental-webgl" ? "webgl" : contextType;
21561 }
21562 function initCanvasContextObserver(win, blockClass, blockSelector, setPreserveDrawingBufferToTrue) {
21563 var handlers = [];
21564 try {
21565 var restoreHandler = patch(win.HTMLCanvasElement.prototype, "getContext", function(original) {
21566 return function(contextType) {
21567 for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
21568 args[_key - 1] = arguments[_key];
21569 }
21570 if (!isBlocked(this, blockClass, blockSelector, true)) {
21571 var ctxName = getNormalizedContextName(contextType);
21572 if (!("__context" in this)) this.__context = ctxName;
21573 if (setPreserveDrawingBufferToTrue && [
21574 "webgl",
21575 "webgl2"
21576 ].includes(ctxName)) {
21577 if (args[0] && _type_of(args[0]) === "object") {
21578 var contextAttributes = args[0];
21579 if (!contextAttributes.preserveDrawingBuffer) {
21580 contextAttributes.preserveDrawingBuffer = true;
21581 }
21582 } else {
21583 args.splice(0, 1, {
21584 preserveDrawingBuffer: true
21585 });
21586 }
21587 }
21588 }
21589 return original.apply(this, [].concat([
21590 contextType
21591 ], args));
21592 };
21593 });
21594 handlers.push(restoreHandler);
21595 } catch (e) {
21596 console.error("failed to patch HTMLCanvasElement.prototype.getContext");
21597 }
21598 return function() {
21599 handlers.forEach(function(h) {
21600 return h();
21601 });
21602 };
21603 }
21604 function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
21605 var _loop = function() {
21606 var prop = _step.value;
21607 if (//prop.startsWith('get') || // e.g. getProgramParameter, but too risky
21608 [
21609 "isContextLost",
21610 "canvas",
21611 "drawingBufferWidth",
21612 "drawingBufferHeight"
21613 ].includes(prop)) {
21614 return "continue";
21615 }
21616 try {
21617 if (typeof prototype[prop] !== "function") {
21618 return "continue";
21619 }
21620 var restoreHandler = patch(prototype, prop, function(original) {
21621 return function() {
21622 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
21623 args[_key] = arguments[_key];
21624 }
21625 var result2 = original.apply(this, args);
21626 saveWebGLVar(result2, win, this);
21627 if ("tagName" in this.canvas && !isBlocked(this.canvas, blockClass, blockSelector, true)) {
21628 var recordArgs = serializeArgs(args, win, this);
21629 var mutation = {
21630 type: type,
21631 property: prop,
21632 args: recordArgs
21633 };
21634 cb(this.canvas, mutation);
21635 }
21636 return result2;
21637 };
21638 });
21639 handlers.push(restoreHandler);
21640 } catch (e) {
21641 var hookHandler = hookSetter(prototype, prop, {
21642 set: function set(v2) {
21643 cb(this.canvas, {
21644 type: type,
21645 property: prop,
21646 args: [
21647 v2
21648 ],
21649 setter: true
21650 });
21651 }
21652 });
21653 handlers.push(hookHandler);
21654 }
21655 };
21656 var handlers = [];
21657 var props = Object.getOwnPropertyNames(prototype);
21658 for(var _iterator = _create_for_of_iterator_helper_loose(props), _step; !(_step = _iterator()).done;)_loop();
21659 return handlers;
21660 }
21661 function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
21662 var _handlers;
21663 var handlers = [];
21664 (_handlers = handlers).push.apply(_handlers, [].concat(patchGLPrototype(win.WebGLRenderingContext.prototype, CanvasContext.WebGL, cb, blockClass, blockSelector, win)));
21665 if (typeof win.WebGL2RenderingContext !== "undefined") {
21666 var _handlers1;
21667 (_handlers1 = handlers).push.apply(_handlers1, [].concat(patchGLPrototype(win.WebGL2RenderingContext.prototype, CanvasContext.WebGL2, cb, blockClass, blockSelector, win)));
21668 }
21669 return function() {
21670 handlers.forEach(function(h) {
21671 return h();
21672 });
21673 };
21674 }
21675 var encodedJs = "KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=";
21676 var decodeBase64 = function(base64) {
21677 return Uint8Array.from(atob(base64), function(c2) {
21678 return c2.charCodeAt(0);
21679 });
21680 };
21681 var blob = typeof window !== "undefined" && window.Blob && new Blob([
21682 decodeBase64(encodedJs)
21683 ], {
21684 type: "text/javascript;charset=utf-8"
21685 });
21686 function WorkerWrapper(options) {
21687 var objURL;
21688 try {
21689 objURL = blob && (window.URL || window.webkitURL).createObjectURL(blob);
21690 if (!objURL) throw "";
21691 var worker = new Worker(objURL, {
21692 name: options == null ? void 0 : options.name
21693 });
21694 worker.addEventListener("error", function() {
21695 (window.URL || window.webkitURL).revokeObjectURL(objURL);
21696 });
21697 return worker;
21698 } catch (e2) {
21699 return new Worker("data:text/javascript;base64," + encodedJs, {
21700 name: options == null ? void 0 : options.name
21701 });
21702 } finally{
21703 objURL && (window.URL || window.webkitURL).revokeObjectURL(objURL);
21704 }
21705 }
21706 var CanvasManager = /*#__PURE__*/ function() {
21707 function CanvasManager(options) {
21708 var _this = this;
21709 __publicField(this, "pendingCanvasMutations", /* @__PURE__ */ new Map());
21710 __publicField(this, "rafStamps", {
21711 latestId: 0,
21712 invokeId: null
21713 });
21714 __publicField(this, "mirror");
21715 __publicField(this, "mutationCb");
21716 __publicField(this, "resetObservers");
21717 __publicField(this, "frozen", false);
21718 __publicField(this, "locked", false);
21719 __publicField(this, "processMutation", function(target, mutation) {
21720 var newFrame = _this.rafStamps.invokeId && _this.rafStamps.latestId !== _this.rafStamps.invokeId;
21721 if (newFrame || !_this.rafStamps.invokeId) _this.rafStamps.invokeId = _this.rafStamps.latestId;
21722 if (!_this.pendingCanvasMutations.has(target)) {
21723 _this.pendingCanvasMutations.set(target, []);
21724 }
21725 _this.pendingCanvasMutations.get(target).push(mutation);
21726 });
21727 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;
21728 this.mutationCb = options.mutationCb;
21729 this.mirror = options.mirror;
21730 if (recordCanvas && sampling === "all") this.initCanvasMutationObserver(win, blockClass, blockSelector);
21731 if (recordCanvas && typeof sampling === "number") this.initCanvasFPSObserver(sampling, win, blockClass, blockSelector, {
21732 dataURLOptions: dataURLOptions
21733 });
21734 }
21735 var _proto = CanvasManager.prototype;
21736 _proto.reset = function reset() {
21737 this.pendingCanvasMutations.clear();
21738 this.resetObservers && this.resetObservers();
21739 };
21740 _proto.freeze = function freeze() {
21741 this.frozen = true;
21742 };
21743 _proto.unfreeze = function unfreeze() {
21744 this.frozen = false;
21745 };
21746 _proto.lock = function lock() {
21747 this.locked = true;
21748 };
21749 _proto.unlock = function unlock() {
21750 this.locked = false;
21751 };
21752 _proto.initCanvasFPSObserver = function initCanvasFPSObserver(fps, win, blockClass, blockSelector, options) {
21753 var _this = this;
21754 var canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, true);
21755 var snapshotInProgressMap = /* @__PURE__ */ new Map();
21756 var worker = new WorkerWrapper();
21757 worker.onmessage = function(e2) {
21758 var id = e2.data.id;
21759 snapshotInProgressMap.set(id, false);
21760 if (!("base64" in e2.data)) return;
21761 var _e2_data = e2.data, base64 = _e2_data.base64, type = _e2_data.type, width = _e2_data.width, height = _e2_data.height;
21762 _this.mutationCb({
21763 id: id,
21764 type: CanvasContext["2D"],
21765 commands: [
21766 {
21767 property: "clearRect",
21768 // wipe canvas
21769 args: [
21770 0,
21771 0,
21772 width,
21773 height
21774 ]
21775 },
21776 {
21777 property: "drawImage",
21778 // draws (semi-transparent) image
21779 args: [
21780 {
21781 rr_type: "ImageBitmap",
21782 args: [
21783 {
21784 rr_type: "Blob",
21785 data: [
21786 {
21787 rr_type: "ArrayBuffer",
21788 base64: base64
21789 }
21790 ],
21791 type: type
21792 }
21793 ]
21794 },
21795 0,
21796 0
21797 ]
21798 }
21799 ]
21800 });
21801 };
21802 var timeBetweenSnapshots = 1e3 / fps;
21803 var lastSnapshotTime = 0;
21804 var rafId;
21805 var getCanvas = function() {
21806 var matchedCanvas = [];
21807 win.document.querySelectorAll("canvas").forEach(function(canvas) {
21808 if (!isBlocked(canvas, blockClass, blockSelector, true)) {
21809 matchedCanvas.push(canvas);
21810 }
21811 });
21812 return matchedCanvas;
21813 };
21814 var takeCanvasSnapshots = function(timestamp) {
21815 if (lastSnapshotTime && timestamp - lastSnapshotTime < timeBetweenSnapshots) {
21816 rafId = requestAnimationFrame(takeCanvasSnapshots);
21817 return;
21818 }
21819 lastSnapshotTime = timestamp;
21820 var _this1 = _this;
21821 getCanvas().forEach(/*#__PURE__*/ _async_to_generator(function(canvas) {
21822 var _a2, id, context, bitmap;
21823 return _ts_generator(this, function(_state) {
21824 switch(_state.label){
21825 case 0:
21826 id = _this1.mirror.getId(canvas);
21827 if (snapshotInProgressMap.get(id)) return [
21828 2
21829 ];
21830 if (canvas.width === 0 || canvas.height === 0) return [
21831 2
21832 ];
21833 snapshotInProgressMap.set(id, true);
21834 if ([
21835 "webgl",
21836 "webgl2"
21837 ].includes(canvas.__context)) {
21838 context = canvas.getContext(canvas.__context);
21839 if (((_a2 = context == null ? void 0 : context.getContextAttributes()) == null ? void 0 : _a2.preserveDrawingBuffer) === false) {
21840 context.clear(context.COLOR_BUFFER_BIT);
21841 }
21842 }
21843 return [
21844 4,
21845 createImageBitmap(canvas)
21846 ];
21847 case 1:
21848 bitmap = _state.sent();
21849 worker.postMessage({
21850 id: id,
21851 bitmap: bitmap,
21852 width: canvas.width,
21853 height: canvas.height,
21854 dataURLOptions: options.dataURLOptions
21855 }, [
21856 bitmap
21857 ]);
21858 return [
21859 2
21860 ];
21861 }
21862 });
21863 }));
21864 rafId = requestAnimationFrame(takeCanvasSnapshots);
21865 };
21866 rafId = requestAnimationFrame(takeCanvasSnapshots);
21867 this.resetObservers = function() {
21868 canvasContextReset();
21869 cancelAnimationFrame(rafId);
21870 };
21871 };
21872 _proto.initCanvasMutationObserver = function initCanvasMutationObserver(win, blockClass, blockSelector) {
21873 this.startRAFTimestamping();
21874 this.startPendingCanvasMutationFlusher();
21875 var canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, false);
21876 var canvas2DReset = initCanvas2DMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector);
21877 var canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector);
21878 this.resetObservers = function() {
21879 canvasContextReset();
21880 canvas2DReset();
21881 canvasWebGL1and2Reset();
21882 };
21883 };
21884 _proto.startPendingCanvasMutationFlusher = function startPendingCanvasMutationFlusher() {
21885 var _this = this;
21886 requestAnimationFrame(function() {
21887 return _this.flushPendingCanvasMutations();
21888 });
21889 };
21890 _proto.startRAFTimestamping = function startRAFTimestamping() {
21891 var _this = this;
21892 var setLatestRAFTimestamp = function(timestamp) {
21893 _this.rafStamps.latestId = timestamp;
21894 requestAnimationFrame(setLatestRAFTimestamp);
21895 };
21896 requestAnimationFrame(setLatestRAFTimestamp);
21897 };
21898 _proto.flushPendingCanvasMutations = function flushPendingCanvasMutations() {
21899 var _this = this;
21900 this.pendingCanvasMutations.forEach(function(_values, canvas) {
21901 var id = _this.mirror.getId(canvas);
21902 _this.flushPendingCanvasMutationFor(canvas, id);
21903 });
21904 requestAnimationFrame(function() {
21905 return _this.flushPendingCanvasMutations();
21906 });
21907 };
21908 _proto.flushPendingCanvasMutationFor = function flushPendingCanvasMutationFor(canvas, id) {
21909 if (this.frozen || this.locked) {
21910 return;
21911 }
21912 var valuesWithType = this.pendingCanvasMutations.get(canvas);
21913 if (!valuesWithType || id === -1) return;
21914 var values = valuesWithType.map(function(value) {
21915 value.type; var rest = _object_without_properties_loose(value, [
21916 "type"
21917 ]);
21918 return rest;
21919 });
21920 var type = valuesWithType[0].type;
21921 this.mutationCb({
21922 id: id,
21923 type: type,
21924 commands: values
21925 });
21926 this.pendingCanvasMutations.delete(canvas);
21927 };
21928 return CanvasManager;
21929 }();
21930 var StylesheetManager = /*#__PURE__*/ function() {
21931 function StylesheetManager(options) {
21932 __publicField(this, "trackedLinkElements", /* @__PURE__ */ new WeakSet());
21933 __publicField(this, "mutationCb");
21934 __publicField(this, "adoptedStyleSheetCb");
21935 __publicField(this, "styleMirror", new StyleSheetMirror());
21936 this.mutationCb = options.mutationCb;
21937 this.adoptedStyleSheetCb = options.adoptedStyleSheetCb;
21938 }
21939 var _proto = StylesheetManager.prototype;
21940 _proto.attachLinkElement = function attachLinkElement(linkEl, childSn) {
21941 if ("_cssText" in childSn.attributes) this.mutationCb({
21942 adds: [],
21943 removes: [],
21944 texts: [],
21945 attributes: [
21946 {
21947 id: childSn.id,
21948 attributes: childSn.attributes
21949 }
21950 ]
21951 });
21952 this.trackLinkElement(linkEl);
21953 };
21954 _proto.trackLinkElement = function trackLinkElement(linkEl) {
21955 if (this.trackedLinkElements.has(linkEl)) return;
21956 this.trackedLinkElements.add(linkEl);
21957 this.trackStylesheetInLinkElement(linkEl);
21958 };
21959 _proto.adoptStyleSheets = function adoptStyleSheets(sheets, hostId) {
21960 var _this, _loop = function() {
21961 var sheet = _step.value;
21962 var styleId = void 0;
21963 if (!_this.styleMirror.has(sheet)) {
21964 styleId = _this.styleMirror.add(sheet);
21965 styles.push({
21966 styleId: styleId,
21967 rules: Array.from(sheet.rules || CSSRule, function(r2, index2) {
21968 return {
21969 rule: stringifyRule(r2, sheet.href),
21970 index: index2
21971 };
21972 })
21973 });
21974 } else styleId = _this.styleMirror.getId(sheet);
21975 adoptedStyleSheetData.styleIds.push(styleId);
21976 };
21977 if (sheets.length === 0) return;
21978 var adoptedStyleSheetData = {
21979 id: hostId,
21980 styleIds: []
21981 };
21982 var styles = [];
21983 for(var _iterator = _create_for_of_iterator_helper_loose(sheets), _step; !(_step = _iterator()).done;)_this = this, _loop();
21984 if (styles.length > 0) adoptedStyleSheetData.styles = styles;
21985 this.adoptedStyleSheetCb(adoptedStyleSheetData);
21986 };
21987 _proto.reset = function reset() {
21988 this.styleMirror.reset();
21989 this.trackedLinkElements = /* @__PURE__ */ new WeakSet();
21990 };
21991 // TODO: take snapshot on stylesheet reload by applying event listener
21992 _proto.trackStylesheetInLinkElement = function trackStylesheetInLinkElement(_linkEl) {};
21993 return StylesheetManager;
21994 }();
21995 var ProcessedNodeManager = /*#__PURE__*/ function() {
21996 function ProcessedNodeManager() {
21997 __publicField(this, "nodeMap", /* @__PURE__ */ new WeakMap());
21998 __publicField(this, "active", false);
21999 }
22000 var _proto = ProcessedNodeManager.prototype;
22001 _proto.inOtherBuffer = function inOtherBuffer(node2, thisBuffer) {
22002 var buffers = this.nodeMap.get(node2);
22003 return buffers && Array.from(buffers).some(function(buffer) {
22004 return buffer !== thisBuffer;
22005 });
22006 };
22007 _proto.add = function add(node2, buffer) {
22008 var _this = this;
22009 if (!this.active) {
22010 this.active = true;
22011 requestAnimationFrame(function() {
22012 _this.nodeMap = /* @__PURE__ */ new WeakMap();
22013 _this.active = false;
22014 });
22015 }
22016 this.nodeMap.set(node2, (this.nodeMap.get(node2) || /* @__PURE__ */ new Set()).add(buffer));
22017 };
22018 _proto.destroy = function destroy() {};
22019 return ProcessedNodeManager;
22020 }();
22021 var wrappedEmit;
22022 var takeFullSnapshot$1;
22023 var canvasManager;
22024 var recording = false;
22025 try {
22026 if (Array.from([
22027 1
22028 ], function(x2) {
22029 return x2 * 2;
22030 })[0] !== 2) {
22031 var cleanFrame = document.createElement("iframe");
22032 document.body.appendChild(cleanFrame);
22033 Array.from = ((_a = cleanFrame.contentWindow) == null ? void 0 : _a.Array.from) || Array.from;
22034 document.body.removeChild(cleanFrame);
22035 }
22036 } catch (err) {
22037 console.debug("Unable to override Array.from", err);
22038 }
22039 var mirror = createMirror$2();
22040 function record(options) {
22041 if (options === void 0) options = {};
22042 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() {
22043 return false;
22044 } : _options_keepIframeSrcFn, _options_ignoreCSSAttributes = options.ignoreCSSAttributes, ignoreCSSAttributes = _options_ignoreCSSAttributes === void 0 ? /* @__PURE__ */ new Set([]) : _options_ignoreCSSAttributes, errorHandler2 = options.errorHandler;
22045 registerErrorHandler(errorHandler2);
22046 var inEmittingFrame = recordCrossOriginIframes ? window.parent === window : true;
22047 var passEmitsToParent = false;
22048 if (!inEmittingFrame) {
22049 try {
22050 if (window.parent.document) {
22051 passEmitsToParent = false;
22052 }
22053 } catch (e2) {
22054 passEmitsToParent = true;
22055 }
22056 }
22057 if (inEmittingFrame && !emit) {
22058 throw new Error("emit function is required");
22059 }
22060 if (!inEmittingFrame && !passEmitsToParent) {
22061 return function() {};
22062 }
22063 if (mousemoveWait !== void 0 && sampling.mousemove === void 0) {
22064 sampling.mousemove = mousemoveWait;
22065 }
22066 mirror.reset();
22067 var maskInputOptions = maskAllInputs === true ? {
22068 color: true,
22069 date: true,
22070 "datetime-local": true,
22071 email: true,
22072 month: true,
22073 number: true,
22074 range: true,
22075 search: true,
22076 tel: true,
22077 text: true,
22078 time: true,
22079 url: true,
22080 week: true,
22081 textarea: true,
22082 select: true,
22083 password: true,
22084 hidden: true
22085 } : _maskInputOptions !== void 0 ? _maskInputOptions : {
22086 password: true
22087 };
22088 var slimDOMOptions = _slimDOMOptions === true || _slimDOMOptions === "all" ? {
22089 script: true,
22090 comment: true,
22091 headFavicon: true,
22092 headWhitespace: true,
22093 headMetaSocial: true,
22094 headMetaRobots: true,
22095 headMetaHttpEquiv: true,
22096 headMetaVerification: true,
22097 // the following are off for slimDOMOptions === true,
22098 // as they destroy some (hidden) info:
22099 headMetaAuthorship: _slimDOMOptions === "all",
22100 headMetaDescKeywords: _slimDOMOptions === "all",
22101 headTitleMutations: _slimDOMOptions === "all"
22102 } : _slimDOMOptions ? _slimDOMOptions : {};
22103 polyfill$1();
22104 var lastFullSnapshotEvent;
22105 var incrementalSnapshotCount = 0;
22106 var eventProcessor = function(e2) {
22107 for(var _iterator = _create_for_of_iterator_helper_loose(plugins || []), _step; !(_step = _iterator()).done;){
22108 var plugin3 = _step.value;
22109 if (plugin3.eventProcessor) {
22110 e2 = plugin3.eventProcessor(e2);
22111 }
22112 }
22113 if (packFn && // Disable packing events which will be emitted to parent frames.
22114 !passEmitsToParent) {
22115 e2 = packFn(e2);
22116 }
22117 return e2;
22118 };
22119 wrappedEmit = function(r2, isCheckout) {
22120 var _a2;
22121 var e2 = r2;
22122 e2.timestamp = nowTimestamp();
22123 if (((_a2 = mutationBuffers[0]) == null ? void 0 : _a2.isFrozen()) && e2.type !== EventType.FullSnapshot && !(e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.Mutation)) {
22124 mutationBuffers.forEach(function(buf) {
22125 return buf.unfreeze();
22126 });
22127 }
22128 if (inEmittingFrame) {
22129 emit == null ? void 0 : emit(eventProcessor(e2), isCheckout);
22130 } else if (passEmitsToParent) {
22131 var message = {
22132 type: "rrweb",
22133 event: eventProcessor(e2),
22134 origin: window.location.origin,
22135 isCheckout: isCheckout
22136 };
22137 window.parent.postMessage(message, "*");
22138 }
22139 if (e2.type === EventType.FullSnapshot) {
22140 lastFullSnapshotEvent = e2;
22141 incrementalSnapshotCount = 0;
22142 } else if (e2.type === EventType.IncrementalSnapshot) {
22143 if (e2.data.source === IncrementalSource.Mutation && e2.data.isAttachIframe) {
22144 return;
22145 }
22146 incrementalSnapshotCount++;
22147 var exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
22148 var exceedTime = checkoutEveryNms && e2.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
22149 if (exceedCount || exceedTime) {
22150 takeFullSnapshot$1(true);
22151 }
22152 }
22153 };
22154 var wrappedMutationEmit = function(m) {
22155 wrappedEmit({
22156 type: EventType.IncrementalSnapshot,
22157 data: _extends({
22158 source: IncrementalSource.Mutation
22159 }, m)
22160 });
22161 };
22162 var wrappedScrollEmit = function(p) {
22163 return wrappedEmit({
22164 type: EventType.IncrementalSnapshot,
22165 data: _extends({
22166 source: IncrementalSource.Scroll
22167 }, p)
22168 });
22169 };
22170 var wrappedCanvasMutationEmit = function(p) {
22171 return wrappedEmit({
22172 type: EventType.IncrementalSnapshot,
22173 data: _extends({
22174 source: IncrementalSource.CanvasMutation
22175 }, p)
22176 });
22177 };
22178 var wrappedAdoptedStyleSheetEmit = function(a2) {
22179 return wrappedEmit({
22180 type: EventType.IncrementalSnapshot,
22181 data: _extends({
22182 source: IncrementalSource.AdoptedStyleSheet
22183 }, a2)
22184 });
22185 };
22186 var stylesheetManager = new StylesheetManager({
22187 mutationCb: wrappedMutationEmit,
22188 adoptedStyleSheetCb: wrappedAdoptedStyleSheetEmit
22189 });
22190 var iframeManager = new IframeManager({
22191 mirror: mirror,
22192 mutationCb: wrappedMutationEmit,
22193 stylesheetManager: stylesheetManager,
22194 recordCrossOriginIframes: recordCrossOriginIframes,
22195 wrappedEmit: wrappedEmit
22196 });
22197 for(var _iterator = _create_for_of_iterator_helper_loose(plugins || []), _step; !(_step = _iterator()).done;){
22198 var plugin3 = _step.value;
22199 if (plugin3.getMirror) plugin3.getMirror({
22200 nodeMirror: mirror,
22201 crossOriginIframeMirror: iframeManager.crossOriginIframeMirror,
22202 crossOriginIframeStyleMirror: iframeManager.crossOriginIframeStyleMirror
22203 });
22204 }
22205 var processedNodeManager = new ProcessedNodeManager();
22206 canvasManager = new CanvasManager({
22207 recordCanvas: recordCanvas,
22208 mutationCb: wrappedCanvasMutationEmit,
22209 win: window,
22210 blockClass: blockClass,
22211 blockSelector: blockSelector,
22212 mirror: mirror,
22213 sampling: sampling.canvas,
22214 dataURLOptions: dataURLOptions
22215 });
22216 var shadowDomManager = new ShadowDomManager({
22217 mutationCb: wrappedMutationEmit,
22218 scrollCb: wrappedScrollEmit,
22219 bypassOptions: {
22220 blockClass: blockClass,
22221 blockSelector: blockSelector,
22222 maskTextClass: maskTextClass,
22223 maskTextSelector: maskTextSelector,
22224 inlineStylesheet: inlineStylesheet,
22225 maskInputOptions: maskInputOptions,
22226 dataURLOptions: dataURLOptions,
22227 maskTextFn: maskTextFn,
22228 maskInputFn: maskInputFn,
22229 recordCanvas: recordCanvas,
22230 inlineImages: inlineImages,
22231 sampling: sampling,
22232 slimDOMOptions: slimDOMOptions,
22233 iframeManager: iframeManager,
22234 stylesheetManager: stylesheetManager,
22235 canvasManager: canvasManager,
22236 keepIframeSrcFn: keepIframeSrcFn,
22237 processedNodeManager: processedNodeManager
22238 },
22239 mirror: mirror
22240 });
22241 takeFullSnapshot$1 = function(isCheckout) {
22242 if (isCheckout === void 0) isCheckout = false;
22243 if (!recordDOM) {
22244 return;
22245 }
22246 wrappedEmit({
22247 type: EventType.Meta,
22248 data: {
22249 href: window.location.href,
22250 width: getWindowWidth(),
22251 height: getWindowHeight()
22252 }
22253 }, isCheckout);
22254 stylesheetManager.reset();
22255 shadowDomManager.init();
22256 mutationBuffers.forEach(function(buf) {
22257 return buf.lock();
22258 });
22259 var node2 = snapshot(document, {
22260 mirror: mirror,
22261 blockClass: blockClass,
22262 blockSelector: blockSelector,
22263 maskTextClass: maskTextClass,
22264 maskTextSelector: maskTextSelector,
22265 inlineStylesheet: inlineStylesheet,
22266 maskAllInputs: maskInputOptions,
22267 maskTextFn: maskTextFn,
22268 maskInputFn: maskInputFn,
22269 slimDOM: slimDOMOptions,
22270 dataURLOptions: dataURLOptions,
22271 recordCanvas: recordCanvas,
22272 inlineImages: inlineImages,
22273 onSerialize: function(n2) {
22274 if (isSerializedIframe(n2, mirror)) {
22275 iframeManager.addIframe(n2);
22276 }
22277 if (isSerializedStylesheet(n2, mirror)) {
22278 stylesheetManager.trackLinkElement(n2);
22279 }
22280 if (hasShadowRoot(n2)) {
22281 shadowDomManager.addShadowRoot(index.shadowRoot(n2), document);
22282 }
22283 },
22284 onIframeLoad: function(iframe, childSn) {
22285 iframeManager.attachIframe(iframe, childSn);
22286 shadowDomManager.observeAttachShadow(iframe);
22287 },
22288 onStylesheetLoad: function(linkEl, childSn) {
22289 stylesheetManager.attachLinkElement(linkEl, childSn);
22290 },
22291 keepIframeSrcFn: keepIframeSrcFn
22292 });
22293 if (!node2) {
22294 return console.warn("Failed to snapshot the document");
22295 }
22296 wrappedEmit({
22297 type: EventType.FullSnapshot,
22298 data: {
22299 node: node2,
22300 initialOffset: getWindowScroll(window)
22301 }
22302 }, isCheckout);
22303 mutationBuffers.forEach(function(buf) {
22304 return buf.unlock();
22305 });
22306 if (document.adoptedStyleSheets && document.adoptedStyleSheets.length > 0) stylesheetManager.adoptStyleSheets(document.adoptedStyleSheets, mirror.getId(document));
22307 };
22308 try {
22309 var handlers = [];
22310 var observe = function(doc) {
22311 var _a2;
22312 return callbackWrapper(initObservers)({
22313 mutationCb: wrappedMutationEmit,
22314 mousemoveCb: function(positions, source) {
22315 return wrappedEmit({
22316 type: EventType.IncrementalSnapshot,
22317 data: {
22318 source: source,
22319 positions: positions
22320 }
22321 });
22322 },
22323 mouseInteractionCb: function(d) {
22324 return wrappedEmit({
22325 type: EventType.IncrementalSnapshot,
22326 data: _extends({
22327 source: IncrementalSource.MouseInteraction
22328 }, d)
22329 });
22330 },
22331 scrollCb: wrappedScrollEmit,
22332 viewportResizeCb: function(d) {
22333 return wrappedEmit({
22334 type: EventType.IncrementalSnapshot,
22335 data: _extends({
22336 source: IncrementalSource.ViewportResize
22337 }, d)
22338 });
22339 },
22340 inputCb: function(v2) {
22341 return wrappedEmit({
22342 type: EventType.IncrementalSnapshot,
22343 data: _extends({
22344 source: IncrementalSource.Input
22345 }, v2)
22346 });
22347 },
22348 mediaInteractionCb: function(p) {
22349 return wrappedEmit({
22350 type: EventType.IncrementalSnapshot,
22351 data: _extends({
22352 source: IncrementalSource.MediaInteraction
22353 }, p)
22354 });
22355 },
22356 styleSheetRuleCb: function(r2) {
22357 return wrappedEmit({
22358 type: EventType.IncrementalSnapshot,
22359 data: _extends({
22360 source: IncrementalSource.StyleSheetRule
22361 }, r2)
22362 });
22363 },
22364 styleDeclarationCb: function(r2) {
22365 return wrappedEmit({
22366 type: EventType.IncrementalSnapshot,
22367 data: _extends({
22368 source: IncrementalSource.StyleDeclaration
22369 }, r2)
22370 });
22371 },
22372 canvasMutationCb: wrappedCanvasMutationEmit,
22373 fontCb: function(p) {
22374 return wrappedEmit({
22375 type: EventType.IncrementalSnapshot,
22376 data: _extends({
22377 source: IncrementalSource.Font
22378 }, p)
22379 });
22380 },
22381 selectionCb: function(p) {
22382 wrappedEmit({
22383 type: EventType.IncrementalSnapshot,
22384 data: _extends({
22385 source: IncrementalSource.Selection
22386 }, p)
22387 });
22388 },
22389 customElementCb: function(c2) {
22390 wrappedEmit({
22391 type: EventType.IncrementalSnapshot,
22392 data: _extends({
22393 source: IncrementalSource.CustomElement
22394 }, c2)
22395 });
22396 },
22397 blockClass: blockClass,
22398 ignoreClass: ignoreClass,
22399 ignoreSelector: ignoreSelector,
22400 maskTextClass: maskTextClass,
22401 maskTextSelector: maskTextSelector,
22402 maskInputOptions: maskInputOptions,
22403 inlineStylesheet: inlineStylesheet,
22404 sampling: sampling,
22405 recordDOM: recordDOM,
22406 recordCanvas: recordCanvas,
22407 inlineImages: inlineImages,
22408 userTriggeredOnInput: userTriggeredOnInput,
22409 collectFonts: collectFonts,
22410 doc: doc,
22411 maskInputFn: maskInputFn,
22412 maskTextFn: maskTextFn,
22413 keepIframeSrcFn: keepIframeSrcFn,
22414 blockSelector: blockSelector,
22415 slimDOMOptions: slimDOMOptions,
22416 dataURLOptions: dataURLOptions,
22417 mirror: mirror,
22418 iframeManager: iframeManager,
22419 stylesheetManager: stylesheetManager,
22420 shadowDomManager: shadowDomManager,
22421 processedNodeManager: processedNodeManager,
22422 canvasManager: canvasManager,
22423 ignoreCSSAttributes: ignoreCSSAttributes,
22424 plugins: ((_a2 = plugins == null ? void 0 : plugins.filter(function(p) {
22425 return p.observer;
22426 })) == null ? void 0 : _a2.map(function(p) {
22427 return {
22428 observer: p.observer,
22429 options: p.options,
22430 callback: function(payload) {
22431 return wrappedEmit({
22432 type: EventType.Plugin,
22433 data: {
22434 plugin: p.name,
22435 payload: payload
22436 }
22437 });
22438 }
22439 };
22440 })) || []
22441 }, hooks);
22442 };
22443 iframeManager.addLoadListener(function(iframeEl) {
22444 try {
22445 handlers.push(observe(iframeEl.contentDocument));
22446 } catch (error) {
22447 console.warn(error);
22448 }
22449 });
22450 var init = function() {
22451 takeFullSnapshot$1();
22452 handlers.push(observe(document));
22453 recording = true;
22454 };
22455 if (document.readyState === "interactive" || document.readyState === "complete") {
22456 init();
22457 } else {
22458 handlers.push(on("DOMContentLoaded", function() {
22459 wrappedEmit({
22460 type: EventType.DomContentLoaded,
22461 data: {}
22462 });
22463 if (recordAfter === "DOMContentLoaded") init();
22464 }));
22465 handlers.push(on("load", function() {
22466 wrappedEmit({
22467 type: EventType.Load,
22468 data: {}
22469 });
22470 if (recordAfter === "load") init();
22471 }, window));
22472 }
22473 return function() {
22474 handlers.forEach(function(handler) {
22475 try {
22476 handler();
22477 } catch (error) {
22478 var msg = String(error).toLowerCase();
22479 if (!msg.includes("cross-origin")) {
22480 console.warn(error);
22481 }
22482 }
22483 });
22484 processedNodeManager.destroy();
22485 recording = false;
22486 unregisterErrorHandler();
22487 };
22488 } catch (error) {
22489 console.warn(error);
22490 }
22491 }
22492 record.addCustomEvent = function(tag, payload) {
22493 if (!recording) {
22494 throw new Error("please add custom event after start recording");
22495 }
22496 wrappedEmit({
22497 type: EventType.Custom,
22498 data: {
22499 tag: tag,
22500 payload: payload
22501 }
22502 });
22503 };
22504 record.freezePage = function() {
22505 mutationBuffers.forEach(function(buf) {
22506 return buf.freeze();
22507 });
22508 };
22509 record.takeFullSnapshot = function(isCheckout) {
22510 if (!recording) {
22511 throw new Error("please take full snapshot after start recording");
22512 }
22513 takeFullSnapshot$1(isCheckout);
22514 };
22515 record.mirror = mirror;
22516 var n;
22517 !function(t2) {
22518 t2[t2.NotStarted = 0] = "NotStarted", t2[t2.Running = 1] = "Running", t2[t2.Stopped = 2] = "Stopped";
22519 }(n || (n = {}));
22520 record.addCustomEvent;
22521 record.freezePage;
22522 record.takeFullSnapshot;
22523
22524 var setImmediate = win['setImmediate'];
22525 var builtInProp, cycle, schedulingQueue,
22526 ToString = Object.prototype.toString,
22527 timer = (typeof setImmediate !== 'undefined') ?
22528 function timer(fn) { return setImmediate(fn); } :
22529 setTimeout;
22530
22531 // dammit, IE8.
22532 try {
22533 Object.defineProperty({},'x',{});
22534 builtInProp = function builtInProp(obj,name,val,config) {
22535 return Object.defineProperty(obj,name,{
22536 value: val,
22537 writable: true,
22538 configurable: config !== false
22539 });
22540 };
22541 }
22542 catch (err) {
22543 builtInProp = function builtInProp(obj,name,val) {
22544 obj[name] = val;
22545 return obj;
22546 };
22547 }
22548
22549 // Note: using a queue instead of array for efficiency
22550 schedulingQueue = (function Queue() {
22551 var first, last, item;
22552
22553 function Item(fn,self) {
22554 this.fn = fn;
22555 this.self = self;
22556 this.next = void 0;
22557 }
22558
22559 return {
22560 add: function add(fn,self) {
22561 item = new Item(fn,self);
22562 if (last) {
22563 last.next = item;
22564 }
22565 else {
22566 first = item;
22567 }
22568 last = item;
22569 item = void 0;
22570 },
22571 drain: function drain() {
22572 var f = first;
22573 first = last = cycle = void 0;
22574
22575 while (f) {
22576 f.fn.call(f.self);
22577 f = f.next;
22578 }
22579 }
22580 };
22581 })();
22582
22583 function schedule(fn,self) {
22584 schedulingQueue.add(fn,self);
22585 if (!cycle) {
22586 cycle = timer(schedulingQueue.drain);
22587 }
22588 }
22589
22590 // promise duck typing
22591 function isThenable(o) {
22592 var _then, oType = typeof o;
22593
22594 if (o !== null && (oType === 'object' || oType === 'function')) {
22595 _then = o.then;
22596 }
22597 return typeof _then === 'function' ? _then : false;
22598 }
22599
22600 function notify() {
22601 for (var i=0; i<this.chain.length; i++) {
22602 notifyIsolated(
22603 this,
22604 (this.state === 1) ? this.chain[i].success : this.chain[i].failure,
22605 this.chain[i]
22606 );
22607 }
22608 this.chain.length = 0;
22609 }
22610
22611 // NOTE: This is a separate function to isolate
22612 // the `try..catch` so that other code can be
22613 // optimized better
22614 function notifyIsolated(self,cb,chain) {
22615 var ret, _then;
22616 try {
22617 if (cb === false) {
22618 chain.reject(self.msg);
22619 }
22620 else {
22621 if (cb === true) {
22622 ret = self.msg;
22623 }
22624 else {
22625 ret = cb.call(void 0,self.msg);
22626 }
22627
22628 if (ret === chain.promise) {
22629 chain.reject(TypeError('Promise-chain cycle'));
22630 }
22631 // eslint-disable-next-line no-cond-assign
22632 else if (_then = isThenable(ret)) {
22633 _then.call(ret,chain.resolve,chain.reject);
22634 }
22635 else {
22636 chain.resolve(ret);
22637 }
22638 }
22639 }
22640 catch (err) {
22641 chain.reject(err);
22642 }
22643 }
22644
22645 function resolve(msg) {
22646 var _then, self = this;
22647
22648 // already triggered?
22649 if (self.triggered) { return; }
22650
22651 self.triggered = true;
22652
22653 // unwrap
22654 if (self.def) {
22655 self = self.def;
22656 }
22657
22658 try {
22659 // eslint-disable-next-line no-cond-assign
22660 if (_then = isThenable(msg)) {
22661 schedule(function(){
22662 var defWrapper = new MakeDefWrapper(self);
22663 try {
22664 _then.call(msg,
22665 function $resolve$(){ resolve.apply(defWrapper,arguments); },
22666 function $reject$(){ reject.apply(defWrapper,arguments); }
22667 );
22668 }
22669 catch (err) {
22670 reject.call(defWrapper,err);
22671 }
22672 });
22673 }
22674 else {
22675 self.msg = msg;
22676 self.state = 1;
22677 if (self.chain.length > 0) {
22678 schedule(notify,self);
22679 }
22680 }
22681 }
22682 catch (err) {
22683 reject.call(new MakeDefWrapper(self),err);
22684 }
22685 }
22686
22687 function reject(msg) {
22688 var self = this;
22689
22690 // already triggered?
22691 if (self.triggered) { return; }
22692
22693 self.triggered = true;
22694
22695 // unwrap
22696 if (self.def) {
22697 self = self.def;
22698 }
22699
22700 self.msg = msg;
22701 self.state = 2;
22702 if (self.chain.length > 0) {
22703 schedule(notify,self);
22704 }
22705 }
22706
22707 function iteratePromises(Constructor,arr,resolver,rejecter) {
22708 for (var idx=0; idx<arr.length; idx++) {
22709 (function IIFE(idx){
22710 Constructor.resolve(arr[idx])
22711 .then(
22712 function $resolver$(msg){
22713 resolver(idx,msg);
22714 },
22715 rejecter
22716 );
22717 })(idx);
22718 }
22719 }
22720
22721 function MakeDefWrapper(self) {
22722 this.def = self;
22723 this.triggered = false;
22724 }
22725
22726 function MakeDef(self) {
22727 this.promise = self;
22728 this.state = 0;
22729 this.triggered = false;
22730 this.chain = [];
22731 this.msg = void 0;
22732 }
22733
22734 function NpoPromise(executor) {
22735 if (typeof executor !== 'function') {
22736 throw TypeError('Not a function');
22737 }
22738
22739 if (this['__NPO__'] !== 0) {
22740 throw TypeError('Not a promise');
22741 }
22742
22743 // instance shadowing the inherited "brand"
22744 // to signal an already "initialized" promise
22745 this['__NPO__'] = 1;
22746
22747 var def = new MakeDef(this);
22748
22749 this['then'] = function then(success,failure) {
22750 var o = {
22751 success: typeof success === 'function' ? success : true,
22752 failure: typeof failure === 'function' ? failure : false
22753 };
22754 // Note: `then(..)` itself can be borrowed to be used against
22755 // a different promise constructor for making the chained promise,
22756 // by substituting a different `this` binding.
22757 o.promise = new this.constructor(function extractChain(resolve,reject) {
22758 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22759 throw TypeError('Not a function');
22760 }
22761
22762 o.resolve = resolve;
22763 o.reject = reject;
22764 });
22765 def.chain.push(o);
22766
22767 if (def.state !== 0) {
22768 schedule(notify,def);
22769 }
22770
22771 return o.promise;
22772 };
22773 this['catch'] = function $catch$(failure) {
22774 return this.then(void 0,failure);
22775 };
22776
22777 try {
22778 executor.call(
22779 void 0,
22780 function publicResolve(msg){
22781 resolve.call(def,msg);
22782 },
22783 function publicReject(msg) {
22784 reject.call(def,msg);
22785 }
22786 );
22787 }
22788 catch (err) {
22789 reject.call(def,err);
22790 }
22791 }
22792
22793 var PromisePrototype = builtInProp({},'constructor',NpoPromise,
22794 /*configurable=*/false
22795 );
22796
22797 // Note: Android 4 cannot use `Object.defineProperty(..)` here
22798 NpoPromise.prototype = PromisePrototype;
22799
22800 // built-in "brand" to signal an "uninitialized" promise
22801 builtInProp(PromisePrototype,'__NPO__',0,
22802 /*configurable=*/false
22803 );
22804
22805 builtInProp(NpoPromise,'resolve',function Promise$resolve(msg) {
22806 var Constructor = this;
22807
22808 // spec mandated checks
22809 // note: best "isPromise" check that's practical for now
22810 if (msg && typeof msg === 'object' && msg['__NPO__'] === 1) {
22811 return msg;
22812 }
22813
22814 return new Constructor(function executor(resolve,reject){
22815 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22816 throw TypeError('Not a function');
22817 }
22818
22819 resolve(msg);
22820 });
22821 });
22822
22823 builtInProp(NpoPromise,'reject',function Promise$reject(msg) {
22824 return new this(function executor(resolve,reject){
22825 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22826 throw TypeError('Not a function');
22827 }
22828
22829 reject(msg);
22830 });
22831 });
22832
22833 builtInProp(NpoPromise,'all',function Promise$all(arr) {
22834 var Constructor = this;
22835
22836 // spec mandated checks
22837 if (ToString.call(arr) !== '[object Array]') {
22838 return Constructor.reject(TypeError('Not an array'));
22839 }
22840 if (arr.length === 0) {
22841 return Constructor.resolve([]);
22842 }
22843
22844 return new Constructor(function executor(resolve,reject){
22845 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22846 throw TypeError('Not a function');
22847 }
22848
22849 var len = arr.length, msgs = Array(len), count = 0;
22850
22851 iteratePromises(Constructor,arr,function resolver(idx,msg) {
22852 msgs[idx] = msg;
22853 if (++count === len) {
22854 resolve(msgs);
22855 }
22856 },reject);
22857 });
22858 });
22859
22860 builtInProp(NpoPromise,'race',function Promise$race(arr) {
22861 var Constructor = this;
22862
22863 // spec mandated checks
22864 if (ToString.call(arr) !== '[object Array]') {
22865 return Constructor.reject(TypeError('Not an array'));
22866 }
22867
22868 return new Constructor(function executor(resolve,reject){
22869 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22870 throw TypeError('Not a function');
22871 }
22872
22873 iteratePromises(Constructor,arr,function resolver(idx,msg){
22874 resolve(msg);
22875 },reject);
22876 });
22877 });
22878
22879 var PromisePolyfill;
22880 if (typeof Promise !== 'undefined' && Promise.toString().indexOf('[native code]') !== -1) {
22881 PromisePolyfill = Promise;
22882 } else {
22883 PromisePolyfill = NpoPromise;
22884 }
22885
22886 var Config = {
22887 DEBUG: false,
22888 LIB_VERSION: '2.71.1'
22889 };
22890
22891 /* eslint camelcase: "off", eqeqeq: "off" */
22892
22893 // Maximum allowed session recording length
22894 var MAX_RECORDING_MS = 24 * 60 * 60 * 1000; // 24 hours
22895 // Maximum allowed value for minimum session recording length
22896 var MAX_VALUE_FOR_MIN_RECORDING_MS = 8 * 1000; // 8 seconds
22897
22898 /*
22899 * Saved references to long variable names, so that closure compiler can
22900 * minimize file size.
22901 */
22902
22903 var ArrayProto = Array.prototype,
22904 FuncProto = Function.prototype,
22905 ObjProto = Object.prototype,
22906 slice = ArrayProto.slice,
22907 toString = ObjProto.toString,
22908 hasOwnProperty = ObjProto.hasOwnProperty,
22909 windowConsole = win.console,
22910 navigator = win.navigator,
22911 document$1 = win.document,
22912 windowOpera = win.opera,
22913 screen = win.screen,
22914 userAgent = navigator.userAgent;
22915
22916 var nativeBind = FuncProto.bind,
22917 nativeForEach = ArrayProto.forEach,
22918 nativeIndexOf = ArrayProto.indexOf,
22919 nativeMap = ArrayProto.map,
22920 nativeIsArray = Array.isArray,
22921 breaker = {};
22922
22923 var _ = {
22924 trim: function(str) {
22925 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
22926 return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
22927 }
22928 };
22929
22930 // Console override
22931 var console$1 = {
22932 /** @type {function(...*)} */
22933 log: function() {
22934 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22935 try {
22936 windowConsole.log.apply(windowConsole, arguments);
22937 } catch (err) {
22938 _.each(arguments, function(arg) {
22939 windowConsole.log(arg);
22940 });
22941 }
22942 }
22943 },
22944 /** @type {function(...*)} */
22945 warn: function() {
22946 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22947 var args = ['Mixpanel warning:'].concat(_.toArray(arguments));
22948 try {
22949 windowConsole.warn.apply(windowConsole, args);
22950 } catch (err) {
22951 _.each(args, function(arg) {
22952 windowConsole.warn(arg);
22953 });
22954 }
22955 }
22956 },
22957 /** @type {function(...*)} */
22958 error: function() {
22959 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22960 var args = ['Mixpanel error:'].concat(_.toArray(arguments));
22961 try {
22962 windowConsole.error.apply(windowConsole, args);
22963 } catch (err) {
22964 _.each(args, function(arg) {
22965 windowConsole.error(arg);
22966 });
22967 }
22968 }
22969 },
22970 /** @type {function(...*)} */
22971 critical: function() {
22972 if (!_.isUndefined(windowConsole) && windowConsole) {
22973 var args = ['Mixpanel error:'].concat(_.toArray(arguments));
22974 try {
22975 windowConsole.error.apply(windowConsole, args);
22976 } catch (err) {
22977 _.each(args, function(arg) {
22978 windowConsole.error(arg);
22979 });
22980 }
22981 }
22982 }
22983 };
22984
22985 var log_func_with_prefix = function(func, prefix) {
22986 return function() {
22987 arguments[0] = '[' + prefix + '] ' + arguments[0];
22988 return func.apply(console$1, arguments);
22989 };
22990 };
22991 var console_with_prefix = function(prefix) {
22992 return {
22993 log: log_func_with_prefix(console$1.log, prefix),
22994 error: log_func_with_prefix(console$1.error, prefix),
22995 critical: log_func_with_prefix(console$1.critical, prefix)
22996 };
22997 };
22998
22999
23000 var safewrap = function(f) {
23001 return function() {
23002 try {
23003 return f.apply(this, arguments);
23004 } catch (e) {
23005 console$1.critical('Implementation error. Please turn on debug and contact support@mixpanel.com.');
23006 if (Config.DEBUG){
23007 console$1.critical(e);
23008 }
23009 }
23010 };
23011 };
23012
23013 var safewrapClass = function(klass) {
23014 var proto = klass.prototype;
23015 for (var func in proto) {
23016 if (typeof(proto[func]) === 'function') {
23017 proto[func] = safewrap(proto[func]);
23018 }
23019 }
23020 };
23021
23022
23023 // UNDERSCORE
23024 // Embed part of the Underscore Library
23025 _.bind = function(func, context) {
23026 var args, bound;
23027 if (nativeBind && func.bind === nativeBind) {
23028 return nativeBind.apply(func, slice.call(arguments, 1));
23029 }
23030 if (!_.isFunction(func)) {
23031 throw new TypeError();
23032 }
23033 args = slice.call(arguments, 2);
23034 bound = function() {
23035 if (!(this instanceof bound)) {
23036 return func.apply(context, args.concat(slice.call(arguments)));
23037 }
23038 var ctor = {};
23039 ctor.prototype = func.prototype;
23040 var self = new ctor();
23041 ctor.prototype = null;
23042 var result = func.apply(self, args.concat(slice.call(arguments)));
23043 if (Object(result) === result) {
23044 return result;
23045 }
23046 return self;
23047 };
23048 return bound;
23049 };
23050
23051 /**
23052 * @param {*=} obj
23053 * @param {function(...*)=} iterator
23054 * @param {Object=} context
23055 */
23056 _.each = function(obj, iterator, context) {
23057 if (obj === null || obj === undefined) {
23058 return;
23059 }
23060 if (nativeForEach && obj.forEach === nativeForEach) {
23061 obj.forEach(iterator, context);
23062 } else if (obj.length === +obj.length) {
23063 for (var i = 0, l = obj.length; i < l; i++) {
23064 if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) {
23065 return;
23066 }
23067 }
23068 } else {
23069 for (var key in obj) {
23070 if (hasOwnProperty.call(obj, key)) {
23071 if (iterator.call(context, obj[key], key, obj) === breaker) {
23072 return;
23073 }
23074 }
23075 }
23076 }
23077 };
23078
23079 _.extend = function(obj) {
23080 _.each(slice.call(arguments, 1), function(source) {
23081 for (var prop in source) {
23082 if (source[prop] !== void 0) {
23083 obj[prop] = source[prop];
23084 }
23085 }
23086 });
23087 return obj;
23088 };
23089
23090 _.isArray = nativeIsArray || function(obj) {
23091 return toString.call(obj) === '[object Array]';
23092 };
23093
23094 // from a comment on http://dbj.org/dbj/?p=286
23095 // fails on only one very rare and deliberate custom object:
23096 // var bomb = { toString : undefined, valueOf: function(o) { return "function BOMBA!"; }};
23097 _.isFunction = function(f) {
23098 try {
23099 return /^\s*\bfunction\b/.test(f);
23100 } catch (x) {
23101 return false;
23102 }
23103 };
23104
23105 _.isArguments = function(obj) {
23106 return !!(obj && hasOwnProperty.call(obj, 'callee'));
23107 };
23108
23109 _.toArray = function(iterable) {
23110 if (!iterable) {
23111 return [];
23112 }
23113 if (iterable.toArray) {
23114 return iterable.toArray();
23115 }
23116 if (_.isArray(iterable)) {
23117 return slice.call(iterable);
23118 }
23119 if (_.isArguments(iterable)) {
23120 return slice.call(iterable);
23121 }
23122 return _.values(iterable);
23123 };
23124
23125 _.map = function(arr, callback, context) {
23126 if (nativeMap && arr.map === nativeMap) {
23127 return arr.map(callback, context);
23128 } else {
23129 var results = [];
23130 _.each(arr, function(item) {
23131 results.push(callback.call(context, item));
23132 });
23133 return results;
23134 }
23135 };
23136
23137 _.keys = function(obj) {
23138 var results = [];
23139 if (obj === null) {
23140 return results;
23141 }
23142 _.each(obj, function(value, key) {
23143 results[results.length] = key;
23144 });
23145 return results;
23146 };
23147
23148 _.values = function(obj) {
23149 var results = [];
23150 if (obj === null) {
23151 return results;
23152 }
23153 _.each(obj, function(value) {
23154 results[results.length] = value;
23155 });
23156 return results;
23157 };
23158
23159 _.include = function(obj, target) {
23160 var found = false;
23161 if (obj === null) {
23162 return found;
23163 }
23164 if (nativeIndexOf && obj.indexOf === nativeIndexOf) {
23165 return obj.indexOf(target) != -1;
23166 }
23167 _.each(obj, function(value) {
23168 if (found || (found = (value === target))) {
23169 return breaker;
23170 }
23171 });
23172 return found;
23173 };
23174
23175 _.includes = function(str, needle) {
23176 return str.indexOf(needle) !== -1;
23177 };
23178
23179 // Underscore Addons
23180 _.inherit = function(subclass, superclass) {
23181 subclass.prototype = new superclass();
23182 subclass.prototype.constructor = subclass;
23183 subclass.superclass = superclass.prototype;
23184 return subclass;
23185 };
23186
23187 _.isObject = function(obj) {
23188 return (obj === Object(obj) && !_.isArray(obj));
23189 };
23190
23191 _.isEmptyObject = function(obj) {
23192 if (_.isObject(obj)) {
23193 for (var key in obj) {
23194 if (hasOwnProperty.call(obj, key)) {
23195 return false;
23196 }
23197 }
23198 return true;
23199 }
23200 return false;
23201 };
23202
23203 _.isUndefined = function(obj) {
23204 return obj === void 0;
23205 };
23206
23207 _.isString = function(obj) {
23208 return toString.call(obj) == '[object String]';
23209 };
23210
23211 _.isDate = function(obj) {
23212 return toString.call(obj) == '[object Date]';
23213 };
23214
23215 _.isNumber = function(obj) {
23216 return toString.call(obj) == '[object Number]';
23217 };
23218
23219 _.isElement = function(obj) {
23220 return !!(obj && obj.nodeType === 1);
23221 };
23222
23223 _.encodeDates = function(obj) {
23224 _.each(obj, function(v, k) {
23225 if (_.isDate(v)) {
23226 obj[k] = _.formatDate(v);
23227 } else if (_.isObject(v)) {
23228 obj[k] = _.encodeDates(v); // recurse
23229 }
23230 });
23231 return obj;
23232 };
23233
23234 _.timestamp = function() {
23235 Date.now = Date.now || function() {
23236 return +new Date;
23237 };
23238 return Date.now();
23239 };
23240
23241 _.formatDate = function(d) {
23242 // YYYY-MM-DDTHH:MM:SS in UTC
23243 function pad(n) {
23244 return n < 10 ? '0' + n : n;
23245 }
23246 return d.getUTCFullYear() + '-' +
23247 pad(d.getUTCMonth() + 1) + '-' +
23248 pad(d.getUTCDate()) + 'T' +
23249 pad(d.getUTCHours()) + ':' +
23250 pad(d.getUTCMinutes()) + ':' +
23251 pad(d.getUTCSeconds());
23252 };
23253
23254 _.strip_empty_properties = function(p) {
23255 var ret = {};
23256 _.each(p, function(v, k) {
23257 if (_.isString(v) && v.length > 0) {
23258 ret[k] = v;
23259 }
23260 });
23261 return ret;
23262 };
23263
23264 /*
23265 * this function returns a copy of object after truncating it. If
23266 * passed an Array or Object it will iterate through obj and
23267 * truncate all the values recursively.
23268 */
23269 _.truncate = function(obj, length) {
23270 var ret;
23271
23272 if (typeof(obj) === 'string') {
23273 ret = obj.slice(0, length);
23274 } else if (_.isArray(obj)) {
23275 ret = [];
23276 _.each(obj, function(val) {
23277 ret.push(_.truncate(val, length));
23278 });
23279 } else if (_.isObject(obj)) {
23280 ret = {};
23281 _.each(obj, function(val, key) {
23282 ret[key] = _.truncate(val, length);
23283 });
23284 } else {
23285 ret = obj;
23286 }
23287
23288 return ret;
23289 };
23290
23291 _.JSONEncode = (function() {
23292 return function(mixed_val) {
23293 var value = mixed_val;
23294 var quote = function(string) {
23295 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
23296 var meta = { // table of character substitutions
23297 '\b': '\\b',
23298 '\t': '\\t',
23299 '\n': '\\n',
23300 '\f': '\\f',
23301 '\r': '\\r',
23302 '"': '\\"',
23303 '\\': '\\\\'
23304 };
23305
23306 escapable.lastIndex = 0;
23307 return escapable.test(string) ?
23308 '"' + string.replace(escapable, function(a) {
23309 var c = meta[a];
23310 return typeof c === 'string' ? c :
23311 '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
23312 }) + '"' :
23313 '"' + string + '"';
23314 };
23315
23316 var str = function(key, holder) {
23317 var gap = '';
23318 var indent = ' ';
23319 var i = 0; // The loop counter.
23320 var k = ''; // The member key.
23321 var v = ''; // The member value.
23322 var length = 0;
23323 var mind = gap;
23324 var partial = [];
23325 var value = holder[key];
23326
23327 // If the value has a toJSON method, call it to obtain a replacement value.
23328 if (value && typeof value === 'object' &&
23329 typeof value.toJSON === 'function') {
23330 value = value.toJSON(key);
23331 }
23332
23333 // What happens next depends on the value's type.
23334 switch (typeof value) {
23335 case 'string':
23336 return quote(value);
23337
23338 case 'number':
23339 // JSON numbers must be finite. Encode non-finite numbers as null.
23340 return isFinite(value) ? String(value) : 'null';
23341
23342 case 'boolean':
23343 case 'null':
23344 // If the value is a boolean or null, convert it to a string. Note:
23345 // typeof null does not produce 'null'. The case is included here in
23346 // the remote chance that this gets fixed someday.
23347
23348 return String(value);
23349
23350 case 'object':
23351 // If the type is 'object', we might be dealing with an object or an array or
23352 // null.
23353 // Due to a specification blunder in ECMAScript, typeof null is 'object',
23354 // so watch out for that case.
23355 if (!value) {
23356 return 'null';
23357 }
23358
23359 // Make an array to hold the partial results of stringifying this object value.
23360 gap += indent;
23361 partial = [];
23362
23363 // Is the value an array?
23364 if (toString.apply(value) === '[object Array]') {
23365 // The value is an array. Stringify every element. Use null as a placeholder
23366 // for non-JSON values.
23367
23368 length = value.length;
23369 for (i = 0; i < length; i += 1) {
23370 partial[i] = str(i, value) || 'null';
23371 }
23372
23373 // Join all of the elements together, separated with commas, and wrap them in
23374 // brackets.
23375 v = partial.length === 0 ? '[]' :
23376 gap ? '[\n' + gap +
23377 partial.join(',\n' + gap) + '\n' +
23378 mind + ']' :
23379 '[' + partial.join(',') + ']';
23380 gap = mind;
23381 return v;
23382 }
23383
23384 // Iterate through all of the keys in the object.
23385 for (k in value) {
23386 if (hasOwnProperty.call(value, k)) {
23387 v = str(k, value);
23388 if (v) {
23389 partial.push(quote(k) + (gap ? ': ' : ':') + v);
23390 }
23391 }
23392 }
23393
23394 // Join all of the member texts together, separated with commas,
23395 // and wrap them in braces.
23396 v = partial.length === 0 ? '{}' :
23397 gap ? '{' + partial.join(',') + '' +
23398 mind + '}' : '{' + partial.join(',') + '}';
23399 gap = mind;
23400 return v;
23401 }
23402 };
23403
23404 // Make a fake root object containing our value under the key of ''.
23405 // Return the result of stringifying the value.
23406 return str('', {
23407 '': value
23408 });
23409 };
23410 })();
23411
23412 /**
23413 * From https://github.com/douglascrockford/JSON-js/blob/master/json_parse.js
23414 * Slightly modified to throw a real Error rather than a POJO
23415 */
23416 _.JSONDecode = (function() {
23417 var at, // The index of the current character
23418 ch, // The current character
23419 escapee = {
23420 '"': '"',
23421 '\\': '\\',
23422 '/': '/',
23423 'b': '\b',
23424 'f': '\f',
23425 'n': '\n',
23426 'r': '\r',
23427 't': '\t'
23428 },
23429 text,
23430 error = function(m) {
23431 var e = new SyntaxError(m);
23432 e.at = at;
23433 e.text = text;
23434 throw e;
23435 },
23436 next = function(c) {
23437 // If a c parameter is provided, verify that it matches the current character.
23438 if (c && c !== ch) {
23439 error('Expected \'' + c + '\' instead of \'' + ch + '\'');
23440 }
23441 // Get the next character. When there are no more characters,
23442 // return the empty string.
23443 ch = text.charAt(at);
23444 at += 1;
23445 return ch;
23446 },
23447 number = function() {
23448 // Parse a number value.
23449 var number,
23450 string = '';
23451
23452 if (ch === '-') {
23453 string = '-';
23454 next('-');
23455 }
23456 while (ch >= '0' && ch <= '9') {
23457 string += ch;
23458 next();
23459 }
23460 if (ch === '.') {
23461 string += '.';
23462 while (next() && ch >= '0' && ch <= '9') {
23463 string += ch;
23464 }
23465 }
23466 if (ch === 'e' || ch === 'E') {
23467 string += ch;
23468 next();
23469 if (ch === '-' || ch === '+') {
23470 string += ch;
23471 next();
23472 }
23473 while (ch >= '0' && ch <= '9') {
23474 string += ch;
23475 next();
23476 }
23477 }
23478 number = +string;
23479 if (!isFinite(number)) {
23480 error('Bad number');
23481 } else {
23482 return number;
23483 }
23484 },
23485
23486 string = function() {
23487 // Parse a string value.
23488 var hex,
23489 i,
23490 string = '',
23491 uffff;
23492 // When parsing for string values, we must look for " and \ characters.
23493 if (ch === '"') {
23494 while (next()) {
23495 if (ch === '"') {
23496 next();
23497 return string;
23498 }
23499 if (ch === '\\') {
23500 next();
23501 if (ch === 'u') {
23502 uffff = 0;
23503 for (i = 0; i < 4; i += 1) {
23504 hex = parseInt(next(), 16);
23505 if (!isFinite(hex)) {
23506 break;
23507 }
23508 uffff = uffff * 16 + hex;
23509 }
23510 string += String.fromCharCode(uffff);
23511 } else if (typeof escapee[ch] === 'string') {
23512 string += escapee[ch];
23513 } else {
23514 break;
23515 }
23516 } else {
23517 string += ch;
23518 }
23519 }
23520 }
23521 error('Bad string');
23522 },
23523 white = function() {
23524 // Skip whitespace.
23525 while (ch && ch <= ' ') {
23526 next();
23527 }
23528 },
23529 word = function() {
23530 // true, false, or null.
23531 switch (ch) {
23532 case 't':
23533 next('t');
23534 next('r');
23535 next('u');
23536 next('e');
23537 return true;
23538 case 'f':
23539 next('f');
23540 next('a');
23541 next('l');
23542 next('s');
23543 next('e');
23544 return false;
23545 case 'n':
23546 next('n');
23547 next('u');
23548 next('l');
23549 next('l');
23550 return null;
23551 }
23552 error('Unexpected "' + ch + '"');
23553 },
23554 value, // Placeholder for the value function.
23555 array = function() {
23556 // Parse an array value.
23557 var array = [];
23558
23559 if (ch === '[') {
23560 next('[');
23561 white();
23562 if (ch === ']') {
23563 next(']');
23564 return array; // empty array
23565 }
23566 while (ch) {
23567 array.push(value());
23568 white();
23569 if (ch === ']') {
23570 next(']');
23571 return array;
23572 }
23573 next(',');
23574 white();
23575 }
23576 }
23577 error('Bad array');
23578 },
23579 object = function() {
23580 // Parse an object value.
23581 var key,
23582 object = {};
23583
23584 if (ch === '{') {
23585 next('{');
23586 white();
23587 if (ch === '}') {
23588 next('}');
23589 return object; // empty object
23590 }
23591 while (ch) {
23592 key = string();
23593 white();
23594 next(':');
23595 if (Object.hasOwnProperty.call(object, key)) {
23596 error('Duplicate key "' + key + '"');
23597 }
23598 object[key] = value();
23599 white();
23600 if (ch === '}') {
23601 next('}');
23602 return object;
23603 }
23604 next(',');
23605 white();
23606 }
23607 }
23608 error('Bad object');
23609 };
23610
23611 value = function() {
23612 // Parse a JSON value. It could be an object, an array, a string,
23613 // a number, or a word.
23614 white();
23615 switch (ch) {
23616 case '{':
23617 return object();
23618 case '[':
23619 return array();
23620 case '"':
23621 return string();
23622 case '-':
23623 return number();
23624 default:
23625 return ch >= '0' && ch <= '9' ? number() : word();
23626 }
23627 };
23628
23629 // Return the json_parse function. It will have access to all of the
23630 // above functions and variables.
23631 return function(source) {
23632 var result;
23633
23634 text = source;
23635 at = 0;
23636 ch = ' ';
23637 result = value();
23638 white();
23639 if (ch) {
23640 error('Syntax error');
23641 }
23642
23643 return result;
23644 };
23645 })();
23646
23647 _.base64Encode = function(data) {
23648 var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
23649 var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
23650 ac = 0,
23651 enc = '',
23652 tmp_arr = [];
23653
23654 if (!data) {
23655 return data;
23656 }
23657
23658 data = _.utf8Encode(data);
23659
23660 do { // pack three octets into four hexets
23661 o1 = data.charCodeAt(i++);
23662 o2 = data.charCodeAt(i++);
23663 o3 = data.charCodeAt(i++);
23664
23665 bits = o1 << 16 | o2 << 8 | o3;
23666
23667 h1 = bits >> 18 & 0x3f;
23668 h2 = bits >> 12 & 0x3f;
23669 h3 = bits >> 6 & 0x3f;
23670 h4 = bits & 0x3f;
23671
23672 // use hexets to index into b64, and append result to encoded string
23673 tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
23674 } while (i < data.length);
23675
23676 enc = tmp_arr.join('');
23677
23678 switch (data.length % 3) {
23679 case 1:
23680 enc = enc.slice(0, -2) + '==';
23681 break;
23682 case 2:
23683 enc = enc.slice(0, -1) + '=';
23684 break;
23685 }
23686
23687 return enc;
23688 };
23689
23690 _.utf8Encode = function(string) {
23691 string = (string + '').replace(/\r\n/g, '\n').replace(/\r/g, '\n');
23692
23693 var utftext = '',
23694 start,
23695 end;
23696 var stringl = 0,
23697 n;
23698
23699 start = end = 0;
23700 stringl = string.length;
23701
23702 for (n = 0; n < stringl; n++) {
23703 var c1 = string.charCodeAt(n);
23704 var enc = null;
23705
23706 if (c1 < 128) {
23707 end++;
23708 } else if ((c1 > 127) && (c1 < 2048)) {
23709 enc = String.fromCharCode((c1 >> 6) | 192, (c1 & 63) | 128);
23710 } else {
23711 enc = String.fromCharCode((c1 >> 12) | 224, ((c1 >> 6) & 63) | 128, (c1 & 63) | 128);
23712 }
23713 if (enc !== null) {
23714 if (end > start) {
23715 utftext += string.substring(start, end);
23716 }
23717 utftext += enc;
23718 start = end = n + 1;
23719 }
23720 }
23721
23722 if (end > start) {
23723 utftext += string.substring(start, string.length);
23724 }
23725
23726 return utftext;
23727 };
23728
23729 _.UUID = function() {
23730 try {
23731 // use native Crypto API when available
23732 return win['crypto']['randomUUID']();
23733 } catch (err) {
23734 // fall back to generating our own UUID
23735 // based on https://gist.github.com/scwood/3bff42cc005cc20ab7ec98f0d8e1d59d
23736 var uuid = new Array(36);
23737 for (var i = 0; i < 36; i++) {
23738 uuid[i] = Math.floor(Math.random() * 16);
23739 }
23740 uuid[14] = 4; // set bits 12-15 of time-high-and-version to 0100
23741 uuid[19] = uuid[19] &= -5; // set bit 6 of clock-seq-and-reserved to zero
23742 uuid[19] = uuid[19] |= (1 << 3); // set bit 7 of clock-seq-and-reserved to one
23743 uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
23744
23745 return _.map(uuid, function(x) {
23746 return x.toString(16);
23747 }).join('');
23748 }
23749 };
23750
23751 // _.isBlockedUA()
23752 // This is to block various web spiders from executing our JS and
23753 // sending false tracking data
23754 var BLOCKED_UA_STRS = [
23755 'ahrefsbot',
23756 'ahrefssiteaudit',
23757 'amazonbot',
23758 'baiduspider',
23759 'bingbot',
23760 'bingpreview',
23761 'chrome-lighthouse',
23762 'facebookexternal',
23763 'petalbot',
23764 'pinterest',
23765 'screaming frog',
23766 'yahoo! slurp',
23767 'yandex',
23768
23769 // a whole bunch of goog-specific crawlers
23770 // https://developers.google.com/search/docs/advanced/crawling/overview-google-crawlers
23771 'adsbot-google',
23772 'apis-google',
23773 'duplexweb-google',
23774 'feedfetcher-google',
23775 'google favicon',
23776 'google web preview',
23777 'google-read-aloud',
23778 'googlebot',
23779 'googleweblight',
23780 'mediapartners-google',
23781 'storebot-google'
23782 ];
23783 _.isBlockedUA = function(ua) {
23784 var i;
23785 ua = ua.toLowerCase();
23786 for (i = 0; i < BLOCKED_UA_STRS.length; i++) {
23787 if (ua.indexOf(BLOCKED_UA_STRS[i]) !== -1) {
23788 return true;
23789 }
23790 }
23791 return false;
23792 };
23793
23794 /**
23795 * @param {Object=} formdata
23796 * @param {string=} arg_separator
23797 */
23798 _.HTTPBuildQuery = function(formdata, arg_separator) {
23799 var use_val, use_key, tmp_arr = [];
23800
23801 if (_.isUndefined(arg_separator)) {
23802 arg_separator = '&';
23803 }
23804
23805 _.each(formdata, function(val, key) {
23806 use_val = encodeURIComponent(val.toString());
23807 use_key = encodeURIComponent(key);
23808 tmp_arr[tmp_arr.length] = use_key + '=' + use_val;
23809 });
23810
23811 return tmp_arr.join(arg_separator);
23812 };
23813
23814 _.getQueryParam = function(url, param) {
23815 // Expects a raw URL
23816
23817 param = param.replace(/[[]/g, '\\[').replace(/[\]]/g, '\\]');
23818 var regexS = '[\\?&]' + param + '=([^&#]*)',
23819 regex = new RegExp(regexS),
23820 results = regex.exec(url);
23821 if (results === null || (results && typeof(results[1]) !== 'string' && results[1].length)) {
23822 return '';
23823 } else {
23824 var result = results[1];
23825 try {
23826 result = decodeURIComponent(result);
23827 } catch(err) {
23828 console$1.error('Skipping decoding for malformed query param: ' + result);
23829 }
23830 return result.replace(/\+/g, ' ');
23831 }
23832 };
23833
23834
23835 // _.cookie
23836 // Methods partially borrowed from quirksmode.org/js/cookies.html
23837 _.cookie = {
23838 get: function(name) {
23839 var nameEQ = name + '=';
23840 var ca = document$1.cookie.split(';');
23841 for (var i = 0; i < ca.length; i++) {
23842 var c = ca[i];
23843 while (c.charAt(0) == ' ') {
23844 c = c.substring(1, c.length);
23845 }
23846 if (c.indexOf(nameEQ) === 0) {
23847 return decodeURIComponent(c.substring(nameEQ.length, c.length));
23848 }
23849 }
23850 return null;
23851 },
23852
23853 parse: function(name) {
23854 var cookie;
23855 try {
23856 cookie = _.JSONDecode(_.cookie.get(name)) || {};
23857 } catch (err) {
23858 // noop
23859 }
23860 return cookie;
23861 },
23862
23863 set_seconds: function(name, value, seconds, is_cross_subdomain, is_secure, is_cross_site, domain_override) {
23864 var cdomain = '',
23865 expires = '',
23866 secure = '';
23867
23868 if (domain_override) {
23869 cdomain = '; domain=' + domain_override;
23870 } else if (is_cross_subdomain) {
23871 var domain = extract_domain(document$1.location.hostname);
23872 cdomain = domain ? '; domain=.' + domain : '';
23873 }
23874
23875 if (seconds) {
23876 var date = new Date();
23877 date.setTime(date.getTime() + (seconds * 1000));
23878 expires = '; expires=' + date.toGMTString();
23879 }
23880
23881 if (is_cross_site) {
23882 is_secure = true;
23883 secure = '; SameSite=None';
23884 }
23885 if (is_secure) {
23886 secure += '; secure';
23887 }
23888
23889 document$1.cookie = name + '=' + encodeURIComponent(value) + expires + '; path=/' + cdomain + secure;
23890 },
23891
23892 set: function(name, value, days, is_cross_subdomain, is_secure, is_cross_site, domain_override) {
23893 var cdomain = '', expires = '', secure = '';
23894
23895 if (domain_override) {
23896 cdomain = '; domain=' + domain_override;
23897 } else if (is_cross_subdomain) {
23898 var domain = extract_domain(document$1.location.hostname);
23899 cdomain = domain ? '; domain=.' + domain : '';
23900 }
23901
23902 if (days) {
23903 var date = new Date();
23904 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
23905 expires = '; expires=' + date.toGMTString();
23906 }
23907
23908 if (is_cross_site) {
23909 is_secure = true;
23910 secure = '; SameSite=None';
23911 }
23912 if (is_secure) {
23913 secure += '; secure';
23914 }
23915
23916 var new_cookie_val = name + '=' + encodeURIComponent(value) + expires + '; path=/' + cdomain + secure;
23917 document$1.cookie = new_cookie_val;
23918 return new_cookie_val;
23919 },
23920
23921 remove: function(name, is_cross_subdomain, domain_override) {
23922 _.cookie.set(name, '', -1, is_cross_subdomain, false, false, domain_override);
23923 }
23924 };
23925
23926 var _testStorageSupported = function (storage) {
23927 var supported = true;
23928 try {
23929 var key = '__mplss_' + cheap_guid(8),
23930 val = 'xyz';
23931 storage.setItem(key, val);
23932 if (storage.getItem(key) !== val) {
23933 supported = false;
23934 }
23935 storage.removeItem(key);
23936 } catch (err) {
23937 supported = false;
23938 }
23939 return supported;
23940 };
23941
23942 var _localStorageSupported = null;
23943 var localStorageSupported = function(storage, forceCheck) {
23944 if (_localStorageSupported !== null && !forceCheck) {
23945 return _localStorageSupported;
23946 }
23947 return _localStorageSupported = _testStorageSupported(storage || win.localStorage);
23948 };
23949
23950 var _sessionStorageSupported = null;
23951 var sessionStorageSupported = function(storage, forceCheck) {
23952 if (_sessionStorageSupported !== null && !forceCheck) {
23953 return _sessionStorageSupported;
23954 }
23955 return _sessionStorageSupported = _testStorageSupported(storage || win.sessionStorage);
23956 };
23957
23958 function _storageWrapper(storage, name, is_supported_fn) {
23959 var log_error = function(msg) {
23960 console$1.error(name + ' error: ' + msg);
23961 };
23962
23963 return {
23964 is_supported: function(forceCheck) {
23965 var supported = is_supported_fn(storage, forceCheck);
23966 if (!supported) {
23967 console$1.error(name + ' unsupported');
23968 }
23969 return supported;
23970 },
23971 error: log_error,
23972 get: function(key) {
23973 try {
23974 return storage.getItem(key);
23975 } catch (err) {
23976 log_error(err);
23977 }
23978 return null;
23979 },
23980 parse: function(key) {
23981 try {
23982 return _.JSONDecode(storage.getItem(key)) || {};
23983 } catch (err) {
23984 // noop
23985 }
23986 return null;
23987 },
23988 set: function(key, value) {
23989 try {
23990 storage.setItem(key, value);
23991 } catch (err) {
23992 log_error(err);
23993 }
23994 },
23995 remove: function(key) {
23996 try {
23997 storage.removeItem(key);
23998 } catch (err) {
23999 log_error(err);
24000 }
24001 }
24002 };
24003 }
24004
24005 _.localStorage = _storageWrapper(win.localStorage, 'localStorage', localStorageSupported);
24006 _.sessionStorage = _storageWrapper(win.sessionStorage, 'sessionStorage', sessionStorageSupported);
24007
24008 _.register_event = (function() {
24009 // written by Dean Edwards, 2005
24010 // with input from Tino Zijdel - crisp@xs4all.nl
24011 // with input from Carl Sverre - mail@carlsverre.com
24012 // with input from Mixpanel
24013 // http://dean.edwards.name/weblog/2005/10/add-event/
24014 // https://gist.github.com/1930440
24015
24016 /**
24017 * @param {Object} element
24018 * @param {string} type
24019 * @param {function(...*)} handler
24020 * @param {boolean=} oldSchool
24021 * @param {boolean=} useCapture
24022 */
24023 var register_event = function(element, type, handler, oldSchool, useCapture) {
24024 if (!element) {
24025 console$1.error('No valid element provided to register_event');
24026 return;
24027 }
24028
24029 if (element.addEventListener && !oldSchool) {
24030 element.addEventListener(type, handler, !!useCapture);
24031 } else {
24032 var ontype = 'on' + type;
24033 var old_handler = element[ontype]; // can be undefined
24034 element[ontype] = makeHandler(element, handler, old_handler);
24035 }
24036 };
24037
24038 function makeHandler(element, new_handler, old_handlers) {
24039 var handler = function(event) {
24040 event = event || fixEvent(win.event);
24041
24042 // this basically happens in firefox whenever another script
24043 // overwrites the onload callback and doesn't pass the event
24044 // object to previously defined callbacks. All the browsers
24045 // that don't define window.event implement addEventListener
24046 // so the dom_loaded handler will still be fired as usual.
24047 if (!event) {
24048 return undefined;
24049 }
24050
24051 var ret = true;
24052 var old_result, new_result;
24053
24054 if (_.isFunction(old_handlers)) {
24055 old_result = old_handlers(event);
24056 }
24057 new_result = new_handler.call(element, event);
24058
24059 if ((false === old_result) || (false === new_result)) {
24060 ret = false;
24061 }
24062
24063 return ret;
24064 };
24065
24066 return handler;
24067 }
24068
24069 function fixEvent(event) {
24070 if (event) {
24071 event.preventDefault = fixEvent.preventDefault;
24072 event.stopPropagation = fixEvent.stopPropagation;
24073 }
24074 return event;
24075 }
24076 fixEvent.preventDefault = function() {
24077 this.returnValue = false;
24078 };
24079 fixEvent.stopPropagation = function() {
24080 this.cancelBubble = true;
24081 };
24082
24083 return register_event;
24084 })();
24085
24086
24087 var TOKEN_MATCH_REGEX = new RegExp('^(\\w*)\\[(\\w+)([=~\\|\\^\\$\\*]?)=?"?([^\\]"]*)"?\\]$');
24088
24089 _.dom_query = (function() {
24090 /* document.getElementsBySelector(selector)
24091 - returns an array of element objects from the current document
24092 matching the CSS selector. Selectors can contain element names,
24093 class names and ids and can be nested. For example:
24094
24095 elements = document.getElementsBySelector('div#main p a.external')
24096
24097 Will return an array of all 'a' elements with 'external' in their
24098 class attribute that are contained inside 'p' elements that are
24099 contained inside the 'div' element which has id="main"
24100
24101 New in version 0.4: Support for CSS2 and CSS3 attribute selectors:
24102 See http://www.w3.org/TR/css3-selectors/#attribute-selectors
24103
24104 Version 0.4 - Simon Willison, March 25th 2003
24105 -- Works in Phoenix 0.5, Mozilla 1.3, Opera 7, Internet Explorer 6, Internet Explorer 5 on Windows
24106 -- Opera 7 fails
24107
24108 Version 0.5 - Carl Sverre, Jan 7th 2013
24109 -- Now uses jQuery-esque `hasClass` for testing class name
24110 equality. This fixes a bug related to '-' characters being
24111 considered not part of a 'word' in regex.
24112 */
24113
24114 function getAllChildren(e) {
24115 // Returns all children of element. Workaround required for IE5/Windows. Ugh.
24116 return e.all ? e.all : e.getElementsByTagName('*');
24117 }
24118
24119 var bad_whitespace = /[\t\r\n]/g;
24120
24121 function hasClass(elem, selector) {
24122 var className = ' ' + selector + ' ';
24123 return ((' ' + elem.className + ' ').replace(bad_whitespace, ' ').indexOf(className) >= 0);
24124 }
24125
24126 function getElementsBySelector(selector) {
24127 // Attempt to fail gracefully in lesser browsers
24128 if (!document$1.getElementsByTagName) {
24129 return [];
24130 }
24131 // Split selector in to tokens
24132 var tokens = selector.split(' ');
24133 var token, bits, tagName, found, foundCount, i, j, k, elements, currentContextIndex;
24134 var currentContext = [document$1];
24135 for (i = 0; i < tokens.length; i++) {
24136 token = tokens[i].replace(/^\s+/, '').replace(/\s+$/, '');
24137 if (token.indexOf('#') > -1) {
24138 // Token is an ID selector
24139 bits = token.split('#');
24140 tagName = bits[0];
24141 var id = bits[1];
24142 var element = document$1.getElementById(id);
24143 if (!element || (tagName && element.nodeName.toLowerCase() != tagName)) {
24144 // element not found or tag with that ID not found, return false
24145 return [];
24146 }
24147 // Set currentContext to contain just this element
24148 currentContext = [element];
24149 continue; // Skip to next token
24150 }
24151 if (token.indexOf('.') > -1) {
24152 // Token contains a class selector
24153 bits = token.split('.');
24154 tagName = bits[0];
24155 var className = bits[1];
24156 if (!tagName) {
24157 tagName = '*';
24158 }
24159 // Get elements matching tag, filter them for class selector
24160 found = [];
24161 foundCount = 0;
24162 for (j = 0; j < currentContext.length; j++) {
24163 if (tagName == '*') {
24164 elements = getAllChildren(currentContext[j]);
24165 } else {
24166 elements = currentContext[j].getElementsByTagName(tagName);
24167 }
24168 for (k = 0; k < elements.length; k++) {
24169 found[foundCount++] = elements[k];
24170 }
24171 }
24172 currentContext = [];
24173 currentContextIndex = 0;
24174 for (j = 0; j < found.length; j++) {
24175 if (found[j].className &&
24176 _.isString(found[j].className) && // some SVG elements have classNames which are not strings
24177 hasClass(found[j], className)
24178 ) {
24179 currentContext[currentContextIndex++] = found[j];
24180 }
24181 }
24182 continue; // Skip to next token
24183 }
24184 // Code to deal with attribute selectors
24185 var token_match = token.match(TOKEN_MATCH_REGEX);
24186 if (token_match) {
24187 tagName = token_match[1];
24188 var attrName = token_match[2];
24189 var attrOperator = token_match[3];
24190 var attrValue = token_match[4];
24191 if (!tagName) {
24192 tagName = '*';
24193 }
24194 // Grab all of the tagName elements within current context
24195 found = [];
24196 foundCount = 0;
24197 for (j = 0; j < currentContext.length; j++) {
24198 if (tagName == '*') {
24199 elements = getAllChildren(currentContext[j]);
24200 } else {
24201 elements = currentContext[j].getElementsByTagName(tagName);
24202 }
24203 for (k = 0; k < elements.length; k++) {
24204 found[foundCount++] = elements[k];
24205 }
24206 }
24207 currentContext = [];
24208 currentContextIndex = 0;
24209 var checkFunction; // This function will be used to filter the elements
24210 switch (attrOperator) {
24211 case '=': // Equality
24212 checkFunction = function(e) {
24213 return (e.getAttribute(attrName) == attrValue);
24214 };
24215 break;
24216 case '~': // Match one of space seperated words
24217 checkFunction = function(e) {
24218 return (e.getAttribute(attrName).match(new RegExp('\\b' + attrValue + '\\b')));
24219 };
24220 break;
24221 case '|': // Match start with value followed by optional hyphen
24222 checkFunction = function(e) {
24223 return (e.getAttribute(attrName).match(new RegExp('^' + attrValue + '-?')));
24224 };
24225 break;
24226 case '^': // Match starts with value
24227 checkFunction = function(e) {
24228 return (e.getAttribute(attrName).indexOf(attrValue) === 0);
24229 };
24230 break;
24231 case '$': // Match ends with value - fails with "Warning" in Opera 7
24232 checkFunction = function(e) {
24233 return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length);
24234 };
24235 break;
24236 case '*': // Match ends with value
24237 checkFunction = function(e) {
24238 return (e.getAttribute(attrName).indexOf(attrValue) > -1);
24239 };
24240 break;
24241 default:
24242 // Just test for existence of attribute
24243 checkFunction = function(e) {
24244 return e.getAttribute(attrName);
24245 };
24246 }
24247 currentContext = [];
24248 currentContextIndex = 0;
24249 for (j = 0; j < found.length; j++) {
24250 if (checkFunction(found[j])) {
24251 currentContext[currentContextIndex++] = found[j];
24252 }
24253 }
24254 // alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue);
24255 continue; // Skip to next token
24256 }
24257 // If we get here, token is JUST an element (not a class or ID selector)
24258 tagName = token;
24259 found = [];
24260 foundCount = 0;
24261 for (j = 0; j < currentContext.length; j++) {
24262 elements = currentContext[j].getElementsByTagName(tagName);
24263 for (k = 0; k < elements.length; k++) {
24264 found[foundCount++] = elements[k];
24265 }
24266 }
24267 currentContext = found;
24268 }
24269 return currentContext;
24270 }
24271
24272 return function(query) {
24273 if (_.isElement(query)) {
24274 return [query];
24275 } else if (_.isObject(query) && !_.isUndefined(query.length)) {
24276 return query;
24277 } else {
24278 return getElementsBySelector.call(this, query);
24279 }
24280 };
24281 })();
24282
24283 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'];
24284 var CLICK_IDS = ['dclid', 'fbclid', 'gclid', 'ko_click_id', 'li_fat_id', 'msclkid', 'sccid', 'ttclid', 'twclid', 'wbraid'];
24285
24286 _.info = {
24287 campaignParams: function(default_value) {
24288 var kw = '',
24289 params = {};
24290 _.each(CAMPAIGN_KEYWORDS, function(kwkey) {
24291 kw = _.getQueryParam(document$1.URL, kwkey);
24292 if (kw.length) {
24293 params[kwkey] = kw;
24294 } else if (default_value !== undefined) {
24295 params[kwkey] = default_value;
24296 }
24297 });
24298
24299 return params;
24300 },
24301
24302 clickParams: function() {
24303 var id = '',
24304 params = {};
24305 _.each(CLICK_IDS, function(idkey) {
24306 id = _.getQueryParam(document$1.URL, idkey);
24307 if (id.length) {
24308 params[idkey] = id;
24309 }
24310 });
24311
24312 return params;
24313 },
24314
24315 marketingParams: function() {
24316 return _.extend(_.info.campaignParams(), _.info.clickParams());
24317 },
24318
24319 searchEngine: function(referrer) {
24320 if (referrer.search('https?://(.*)google.([^/?]*)') === 0) {
24321 return 'google';
24322 } else if (referrer.search('https?://(.*)bing.com') === 0) {
24323 return 'bing';
24324 } else if (referrer.search('https?://(.*)yahoo.com') === 0) {
24325 return 'yahoo';
24326 } else if (referrer.search('https?://(.*)duckduckgo.com') === 0) {
24327 return 'duckduckgo';
24328 } else {
24329 return null;
24330 }
24331 },
24332
24333 searchInfo: function(referrer) {
24334 var search = _.info.searchEngine(referrer),
24335 param = (search != 'yahoo') ? 'q' : 'p',
24336 ret = {};
24337
24338 if (search !== null) {
24339 ret['$search_engine'] = search;
24340
24341 var keyword = _.getQueryParam(referrer, param);
24342 if (keyword.length) {
24343 ret['mp_keyword'] = keyword;
24344 }
24345 }
24346
24347 return ret;
24348 },
24349
24350 /**
24351 * This function detects which browser is running this script.
24352 * The order of the checks are important since many user agents
24353 * include key words used in later checks.
24354 */
24355 browser: function(user_agent, vendor, opera) {
24356 vendor = vendor || ''; // vendor is undefined for at least IE9
24357 if (opera || _.includes(user_agent, ' OPR/')) {
24358 if (_.includes(user_agent, 'Mini')) {
24359 return 'Opera Mini';
24360 }
24361 return 'Opera';
24362 } else if (/(BlackBerry|PlayBook|BB10)/i.test(user_agent)) {
24363 return 'BlackBerry';
24364 } else if (_.includes(user_agent, 'IEMobile') || _.includes(user_agent, 'WPDesktop')) {
24365 return 'Internet Explorer Mobile';
24366 } else if (_.includes(user_agent, 'SamsungBrowser/')) {
24367 // https://developer.samsung.com/internet/user-agent-string-format
24368 return 'Samsung Internet';
24369 } else if (_.includes(user_agent, 'Edge') || _.includes(user_agent, 'Edg/')) {
24370 return 'Microsoft Edge';
24371 } else if (_.includes(user_agent, 'FBIOS')) {
24372 return 'Facebook Mobile';
24373 } else if (_.includes(user_agent, 'Whale/')) {
24374 // https://user-agents.net/browsers/whale-browser
24375 return 'Whale Browser';
24376 } else if (_.includes(user_agent, 'Chrome')) {
24377 return 'Chrome';
24378 } else if (_.includes(user_agent, 'CriOS')) {
24379 return 'Chrome iOS';
24380 } else if (_.includes(user_agent, 'UCWEB') || _.includes(user_agent, 'UCBrowser')) {
24381 return 'UC Browser';
24382 } else if (_.includes(user_agent, 'FxiOS')) {
24383 return 'Firefox iOS';
24384 } else if (_.includes(vendor, 'Apple')) {
24385 if (_.includes(user_agent, 'Mobile')) {
24386 return 'Mobile Safari';
24387 }
24388 return 'Safari';
24389 } else if (_.includes(user_agent, 'Android')) {
24390 return 'Android Mobile';
24391 } else if (_.includes(user_agent, 'Konqueror')) {
24392 return 'Konqueror';
24393 } else if (_.includes(user_agent, 'Firefox')) {
24394 return 'Firefox';
24395 } else if (_.includes(user_agent, 'MSIE') || _.includes(user_agent, 'Trident/')) {
24396 return 'Internet Explorer';
24397 } else if (_.includes(user_agent, 'Gecko')) {
24398 return 'Mozilla';
24399 } else {
24400 return '';
24401 }
24402 },
24403
24404 /**
24405 * This function detects which browser version is running this script,
24406 * parsing major and minor version (e.g., 42.1). User agent strings from:
24407 * http://www.useragentstring.com/pages/useragentstring.php
24408 */
24409 browserVersion: function(userAgent, vendor, opera) {
24410 var browser = _.info.browser(userAgent, vendor, opera);
24411 var versionRegexs = {
24412 'Internet Explorer Mobile': /rv:(\d+(\.\d+)?)/,
24413 'Microsoft Edge': /Edge?\/(\d+(\.\d+)?)/,
24414 'Chrome': /Chrome\/(\d+(\.\d+)?)/,
24415 'Chrome iOS': /CriOS\/(\d+(\.\d+)?)/,
24416 'UC Browser' : /(UCBrowser|UCWEB)\/(\d+(\.\d+)?)/,
24417 'Safari': /Version\/(\d+(\.\d+)?)/,
24418 'Mobile Safari': /Version\/(\d+(\.\d+)?)/,
24419 'Opera': /(Opera|OPR)\/(\d+(\.\d+)?)/,
24420 'Firefox': /Firefox\/(\d+(\.\d+)?)/,
24421 'Firefox iOS': /FxiOS\/(\d+(\.\d+)?)/,
24422 'Konqueror': /Konqueror:(\d+(\.\d+)?)/,
24423 'BlackBerry': /BlackBerry (\d+(\.\d+)?)/,
24424 'Android Mobile': /android\s(\d+(\.\d+)?)/,
24425 'Samsung Internet': /SamsungBrowser\/(\d+(\.\d+)?)/,
24426 'Internet Explorer': /(rv:|MSIE )(\d+(\.\d+)?)/,
24427 'Mozilla': /rv:(\d+(\.\d+)?)/,
24428 'Whale Browser': /Whale\/(\d+(\.\d+)?)/
24429 };
24430 var regex = versionRegexs[browser];
24431 if (regex === undefined) {
24432 return null;
24433 }
24434 var matches = userAgent.match(regex);
24435 if (!matches) {
24436 return null;
24437 }
24438 return parseFloat(matches[matches.length - 2]);
24439 },
24440
24441 os: function() {
24442 var a = userAgent;
24443 if (/Windows/i.test(a)) {
24444 if (/Phone/.test(a) || /WPDesktop/.test(a)) {
24445 return 'Windows Phone';
24446 }
24447 return 'Windows';
24448 } else if (/(iPhone|iPad|iPod)/.test(a)) {
24449 return 'iOS';
24450 } else if (/Android/.test(a)) {
24451 return 'Android';
24452 } else if (/(BlackBerry|PlayBook|BB10)/i.test(a)) {
24453 return 'BlackBerry';
24454 } else if (/Mac/i.test(a)) {
24455 return 'Mac OS X';
24456 } else if (/Linux/.test(a)) {
24457 return 'Linux';
24458 } else if (/CrOS/.test(a)) {
24459 return 'Chrome OS';
24460 } else {
24461 return '';
24462 }
24463 },
24464
24465 device: function(user_agent) {
24466 if (/Windows Phone/i.test(user_agent) || /WPDesktop/.test(user_agent)) {
24467 return 'Windows Phone';
24468 } else if (/iPad/.test(user_agent)) {
24469 return 'iPad';
24470 } else if (/iPod/.test(user_agent)) {
24471 return 'iPod Touch';
24472 } else if (/iPhone/.test(user_agent)) {
24473 return 'iPhone';
24474 } else if (/(BlackBerry|PlayBook|BB10)/i.test(user_agent)) {
24475 return 'BlackBerry';
24476 } else if (/Android/.test(user_agent)) {
24477 return 'Android';
24478 } else {
24479 return '';
24480 }
24481 },
24482
24483 referringDomain: function(referrer) {
24484 var split = referrer.split('/');
24485 if (split.length >= 3) {
24486 return split[2];
24487 }
24488 return '';
24489 },
24490
24491 currentUrl: function() {
24492 return win.location.href;
24493 },
24494
24495 properties: function(extra_props) {
24496 if (typeof extra_props !== 'object') {
24497 extra_props = {};
24498 }
24499 return _.extend(_.strip_empty_properties({
24500 '$os': _.info.os(),
24501 '$browser': _.info.browser(userAgent, navigator.vendor, windowOpera),
24502 '$referrer': document$1.referrer,
24503 '$referring_domain': _.info.referringDomain(document$1.referrer),
24504 '$device': _.info.device(userAgent)
24505 }), {
24506 '$current_url': _.info.currentUrl(),
24507 '$browser_version': _.info.browserVersion(userAgent, navigator.vendor, windowOpera),
24508 '$screen_height': screen.height,
24509 '$screen_width': screen.width,
24510 'mp_lib': 'web',
24511 '$lib_version': Config.LIB_VERSION,
24512 '$insert_id': cheap_guid(),
24513 'time': _.timestamp() / 1000 // epoch time in seconds
24514 }, _.strip_empty_properties(extra_props));
24515 },
24516
24517 people_properties: function() {
24518 return _.extend(_.strip_empty_properties({
24519 '$os': _.info.os(),
24520 '$browser': _.info.browser(userAgent, navigator.vendor, windowOpera)
24521 }), {
24522 '$browser_version': _.info.browserVersion(userAgent, navigator.vendor, windowOpera)
24523 });
24524 },
24525
24526 mpPageViewProperties: function() {
24527 return _.strip_empty_properties({
24528 'current_page_title': document$1.title,
24529 'current_domain': win.location.hostname,
24530 'current_url_path': win.location.pathname,
24531 'current_url_protocol': win.location.protocol,
24532 'current_url_search': win.location.search
24533 });
24534 }
24535 };
24536
24537 /**
24538 * Returns a throttled function that will only run at most every `waitMs` and returns a promise that resolves with the next invocation.
24539 * Throttled calls will build up a batch of args and invoke the callback with all args since the last invocation.
24540 */
24541 var batchedThrottle = function (fn, waitMs) {
24542 var timeoutPromise = null;
24543 var throttledItems = [];
24544 return function (item) {
24545 var self = this;
24546 throttledItems.push(item);
24547
24548 if (!timeoutPromise) {
24549 timeoutPromise = new PromisePolyfill(function (resolve) {
24550 setTimeout(function () {
24551 var returnValue = fn.apply(self, [throttledItems]);
24552 timeoutPromise = null;
24553 throttledItems = [];
24554 resolve(returnValue);
24555 }, waitMs);
24556 });
24557 }
24558 return timeoutPromise;
24559 };
24560 };
24561
24562 var cheap_guid = function(maxlen) {
24563 var guid = Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10);
24564 return maxlen ? guid.substring(0, maxlen) : guid;
24565 };
24566
24567 /**
24568 * Generates a W3C traceparent header for easy interop with distributed tracing systems i.e Open Telemetry
24569 * https://www.w3.org/TR/trace-context/#traceparent-header
24570 */
24571 var generateTraceparent = function() {
24572 var traceID = _.UUID().replace(/-/g, '');
24573 var parentID = _.UUID().replace(/-/g, '').substring(0, 16);
24574
24575 // Sampled trace
24576 var traceFlags = '01';
24577
24578 return '00-' + traceID + '-' + parentID + '-' + traceFlags;
24579 };
24580
24581 // naive way to extract domain name (example.com) from full hostname (my.sub.example.com)
24582 var SIMPLE_DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]*\.[a-z]+$/i;
24583 // this next one attempts to account for some ccSLDs, e.g. extracting oxford.ac.uk from www.oxford.ac.uk
24584 var DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i;
24585 /**
24586 * Attempts to extract main domain name from full hostname, using a few blunt heuristics. For
24587 * common TLDs like .com/.org that always have a simple SLD.TLD structure (example.com), we
24588 * simply extract the last two .-separated parts of the hostname (SIMPLE_DOMAIN_MATCH_REGEX).
24589 * For others, we attempt to account for short ccSLD+TLD combos (.ac.uk) with the legacy
24590 * DOMAIN_MATCH_REGEX (kept to maintain backwards compatibility with existing Mixpanel
24591 * integrations). The only _reliable_ way to extract domain from hostname is with an up-to-date
24592 * list like at https://publicsuffix.org/ so for cases that this helper fails at, the SDK
24593 * offers the 'cookie_domain' config option to set it explicitly.
24594 * @example
24595 * extract_domain('my.sub.example.com')
24596 * // 'example.com'
24597 */
24598 var extract_domain = function(hostname) {
24599 var domain_regex = DOMAIN_MATCH_REGEX;
24600 var parts = hostname.split('.');
24601 var tld = parts[parts.length - 1];
24602 if (tld.length > 4 || tld === 'com' || tld === 'org') {
24603 domain_regex = SIMPLE_DOMAIN_MATCH_REGEX;
24604 }
24605 var matches = hostname.match(domain_regex);
24606 return matches ? matches[0] : '';
24607 };
24608
24609 /**
24610 * Check whether we have network connection. default to true for browsers that don't support navigator.onLine (IE)
24611 * @returns {boolean}
24612 */
24613 var isOnline = function() {
24614 var onLine = win.navigator['onLine'];
24615 return _.isUndefined(onLine) || onLine;
24616 };
24617
24618 var NOOP_FUNC = function () {};
24619
24620 var JSONStringify = null, JSONParse = null;
24621 if (typeof JSON !== 'undefined') {
24622 JSONStringify = JSON.stringify;
24623 JSONParse = JSON.parse;
24624 }
24625 JSONStringify = JSONStringify || _.JSONEncode;
24626 JSONParse = JSONParse || _.JSONDecode;
24627
24628 // UNMINIFIED EXPORTS (for closure compiler)
24629 _['info'] = _.info;
24630 _['info']['browser'] = _.info.browser;
24631 _['info']['browserVersion'] = _.info.browserVersion;
24632 _['info']['device'] = _.info.device;
24633 _['info']['properties'] = _.info.properties;
24634 _['isBlockedUA'] = _.isBlockedUA;
24635 _['isEmptyObject'] = _.isEmptyObject;
24636 _['isObject'] = _.isObject;
24637 _['JSONDecode'] = _.JSONDecode;
24638 _['JSONEncode'] = _.JSONEncode;
24639 _['toArray'] = _.toArray;
24640 _['NPO'] = NpoPromise;
24641
24642 var MIXPANEL_DB_NAME = 'mixpanelBrowserDb';
24643
24644 var RECORDING_EVENTS_STORE_NAME = 'mixpanelRecordingEvents';
24645 var RECORDING_REGISTRY_STORE_NAME = 'mixpanelRecordingRegistry';
24646
24647 // note: increment the version number when adding new object stores
24648 var DB_VERSION = 1;
24649 var OBJECT_STORES = [RECORDING_EVENTS_STORE_NAME, RECORDING_REGISTRY_STORE_NAME];
24650
24651 /**
24652 * @type {import('./wrapper').StorageWrapper}
24653 */
24654 var IDBStorageWrapper = function (storeName) {
24655 /**
24656 * @type {Promise<IDBDatabase>|null}
24657 */
24658 this.dbPromise = null;
24659 this.storeName = storeName;
24660 };
24661
24662 IDBStorageWrapper.prototype._openDb = function () {
24663 return new PromisePolyfill(function (resolve, reject) {
24664 var openRequest = win.indexedDB.open(MIXPANEL_DB_NAME, DB_VERSION);
24665 openRequest['onerror'] = function () {
24666 reject(openRequest.error);
24667 };
24668
24669 openRequest['onsuccess'] = function () {
24670 resolve(openRequest.result);
24671 };
24672
24673 openRequest['onupgradeneeded'] = function (ev) {
24674 var db = ev.target.result;
24675
24676 OBJECT_STORES.forEach(function (storeName) {
24677 db.createObjectStore(storeName);
24678 });
24679 };
24680 });
24681 };
24682
24683 IDBStorageWrapper.prototype.init = function () {
24684 if (!win.indexedDB) {
24685 return PromisePolyfill.reject('indexedDB is not supported in this browser');
24686 }
24687
24688 if (!this.dbPromise) {
24689 this.dbPromise = this._openDb();
24690 }
24691
24692 return this.dbPromise
24693 .then(function (dbOrError) {
24694 if (dbOrError instanceof win['IDBDatabase']) {
24695 return PromisePolyfill.resolve();
24696 } else {
24697 return PromisePolyfill.reject(dbOrError);
24698 }
24699 });
24700 };
24701
24702 IDBStorageWrapper.prototype.isInitialized = function () {
24703 return !!this.dbPromise;
24704 };
24705
24706 /**
24707 * @param {IDBTransactionMode} mode
24708 * @param {function(IDBObjectStore): void} storeCb
24709 */
24710 IDBStorageWrapper.prototype.makeTransaction = function (mode, storeCb) {
24711 var storeName = this.storeName;
24712 var doTransaction = function (db) {
24713 return new PromisePolyfill(function (resolve, reject) {
24714 var transaction = db.transaction(storeName, mode);
24715 transaction.oncomplete = function () {
24716 resolve(transaction);
24717 };
24718 transaction.onabort = transaction.onerror = function () {
24719 reject(transaction.error);
24720 };
24721
24722 storeCb(transaction.objectStore(storeName));
24723 });
24724 };
24725
24726 return this.dbPromise
24727 .then(doTransaction)
24728 .catch(function (err) {
24729 if (err && err['name'] === 'InvalidStateError') {
24730 // try reopening the DB if the connection is closed
24731 this.dbPromise = this._openDb();
24732 return this.dbPromise.then(doTransaction);
24733 } else {
24734 return PromisePolyfill.reject(err);
24735 }
24736 }.bind(this));
24737 };
24738
24739 IDBStorageWrapper.prototype.setItem = function (key, value) {
24740 return this.makeTransaction('readwrite', function (objectStore) {
24741 objectStore.put(value, key);
24742 });
24743 };
24744
24745 IDBStorageWrapper.prototype.getItem = function (key) {
24746 var req;
24747 return this.makeTransaction('readonly', function (objectStore) {
24748 req = objectStore.get(key);
24749 }).then(function () {
24750 return req.result;
24751 });
24752 };
24753
24754 IDBStorageWrapper.prototype.removeItem = function (key) {
24755 return this.makeTransaction('readwrite', function (objectStore) {
24756 objectStore.delete(key);
24757 });
24758 };
24759
24760 IDBStorageWrapper.prototype.getAll = function () {
24761 var req;
24762 return this.makeTransaction('readonly', function (objectStore) {
24763 req = objectStore.getAll();
24764 }).then(function () {
24765 return req.result;
24766 });
24767 };
24768
24769 /**
24770 * GDPR utils
24771 *
24772 * The General Data Protection Regulation (GDPR) is a regulation in EU law on data protection
24773 * and privacy for all individuals within the European Union. It addresses the export of personal
24774 * data outside the EU. The GDPR aims primarily to give control back to citizens and residents
24775 * over their personal data and to simplify the regulatory environment for international business
24776 * by unifying the regulation within the EU.
24777 *
24778 * This set of utilities is intended to enable opt in/out functionality in the Mixpanel JS SDK.
24779 * These functions are used internally by the SDK and are not intended to be publicly exposed.
24780 */
24781
24782
24783 /**
24784 * A function used to track a Mixpanel event (e.g. MixpanelLib.track)
24785 * @callback trackFunction
24786 * @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
24787 * @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.
24788 * @param {Function} [callback] If provided, the callback function will be called after tracking the event.
24789 */
24790
24791 /** Public **/
24792
24793 var GDPR_DEFAULT_PERSISTENCE_PREFIX = '__mp_opt_in_out_';
24794
24795 /**
24796 * Opt the user in to data tracking and cookies/localstorage for the given token
24797 * @param {string} token - Mixpanel project tracking token
24798 * @param {Object} [options]
24799 * @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
24800 * @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
24801 * @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
24802 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24803 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24804 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24805 * @param {string} [options.cookieDomain] - custom cookie domain
24806 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24807 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24808 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24809 */
24810 function optIn(token, options) {
24811 _optInOut(true, token, options);
24812 }
24813
24814 /**
24815 * Opt the user out of data tracking and cookies/localstorage for the given token
24816 * @param {string} token - Mixpanel project tracking token
24817 * @param {Object} [options]
24818 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24819 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24820 * @param {Number} [options.cookieExpiration] - number of days until the opt-out cookie expires
24821 * @param {string} [options.cookieDomain] - custom cookie domain
24822 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24823 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-out cookie is set as cross-subdomain or not
24824 * @param {boolean} [options.secureCookie] - whether the opt-out cookie is set as secure or not
24825 */
24826 function optOut(token, options) {
24827 _optInOut(false, token, options);
24828 }
24829
24830 /**
24831 * Check whether the user has opted in to data tracking and cookies/localstorage for the given token
24832 * @param {string} token - Mixpanel project tracking token
24833 * @param {Object} [options]
24834 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24835 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24836 * @returns {boolean} whether the user has opted in to the given opt type
24837 */
24838 function hasOptedIn(token, options) {
24839 return _getStorageValue(token, options) === '1';
24840 }
24841
24842 /**
24843 * Check whether the user has opted out of data tracking and cookies/localstorage for the given token
24844 * @param {string} token - Mixpanel project tracking token
24845 * @param {Object} [options]
24846 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24847 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24848 * @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
24849 * @returns {boolean} whether the user has opted out of the given opt type
24850 */
24851 function hasOptedOut(token, options) {
24852 if (_hasDoNotTrackFlagOn(options)) {
24853 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"');
24854 return true;
24855 }
24856 var optedOut = _getStorageValue(token, options) === '0';
24857 if (optedOut) {
24858 console$1.warn('You are opted out of Mixpanel tracking. This will prevent the Mixpanel SDK from sending any data.');
24859 }
24860 return optedOut;
24861 }
24862
24863 /**
24864 * Wrap a MixpanelLib method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24865 * If the user has opted out, return early instead of executing the method.
24866 * If a callback argument was provided, execute it passing the 0 error code.
24867 * @param {function} method - wrapped method to be executed if the user has not opted out
24868 * @returns {*} the result of executing method OR undefined if the user has opted out
24869 */
24870 function addOptOutCheckMixpanelLib(method) {
24871 return _addOptOutCheck(method, function(name) {
24872 return this.get_config(name);
24873 });
24874 }
24875
24876 /**
24877 * Wrap a MixpanelPeople method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24878 * If the user has opted out, return early instead of executing the method.
24879 * If a callback argument was provided, execute it passing the 0 error code.
24880 * @param {function} method - wrapped method to be executed if the user has not opted out
24881 * @returns {*} the result of executing method OR undefined if the user has opted out
24882 */
24883 function addOptOutCheckMixpanelPeople(method) {
24884 return _addOptOutCheck(method, function(name) {
24885 return this._get_config(name);
24886 });
24887 }
24888
24889 /**
24890 * Wrap a MixpanelGroup method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24891 * If the user has opted out, return early instead of executing the method.
24892 * If a callback argument was provided, execute it passing the 0 error code.
24893 * @param {function} method - wrapped method to be executed if the user has not opted out
24894 * @returns {*} the result of executing method OR undefined if the user has opted out
24895 */
24896 function addOptOutCheckMixpanelGroup(method) {
24897 return _addOptOutCheck(method, function(name) {
24898 return this._get_config(name);
24899 });
24900 }
24901
24902 /**
24903 * Clear the user's opt in/out status of data tracking and cookies/localstorage for the given token
24904 * @param {string} token - Mixpanel project tracking token
24905 * @param {Object} [options]
24906 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24907 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24908 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24909 * @param {string} [options.cookieDomain] - custom cookie domain
24910 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24911 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24912 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24913 */
24914 function clearOptInOut(token, options) {
24915 options = options || {};
24916 _getStorage(options).remove(
24917 _getStorageKey(token, options), !!options.crossSubdomainCookie, options.cookieDomain
24918 );
24919 }
24920
24921 /** Private **/
24922
24923 /**
24924 * Get storage util
24925 * @param {Object} [options]
24926 * @param {string} [options.persistenceType]
24927 * @returns {object} either _.cookie or _.localstorage
24928 */
24929 function _getStorage(options) {
24930 options = options || {};
24931 return options.persistenceType === 'localStorage' ? _.localStorage : _.cookie;
24932 }
24933
24934 /**
24935 * Get the name of the cookie that is used for the given opt type (tracking, cookie, etc.)
24936 * @param {string} token - Mixpanel project tracking token
24937 * @param {Object} [options]
24938 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24939 * @returns {string} the name of the cookie for the given opt type
24940 */
24941 function _getStorageKey(token, options) {
24942 options = options || {};
24943 return (options.persistencePrefix || GDPR_DEFAULT_PERSISTENCE_PREFIX) + token;
24944 }
24945
24946 /**
24947 * Get the value of the cookie that is used for the given opt type (tracking, cookie, etc.)
24948 * @param {string} token - Mixpanel project tracking token
24949 * @param {Object} [options]
24950 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24951 * @returns {string} the value of the cookie for the given opt type
24952 */
24953 function _getStorageValue(token, options) {
24954 return _getStorage(options).get(_getStorageKey(token, options));
24955 }
24956
24957 /**
24958 * Check whether the user has set the DNT/doNotTrack setting to true in their browser
24959 * @param {Object} [options]
24960 * @param {string} [options.window] - alternate window object to check; used to force various DNT settings in browser tests
24961 * @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
24962 * @returns {boolean} whether the DNT setting is true
24963 */
24964 function _hasDoNotTrackFlagOn(options) {
24965 if (options && options.ignoreDnt) {
24966 return false;
24967 }
24968 var win$1 = (options && options.window) || win;
24969 var nav = win$1['navigator'] || {};
24970 var hasDntOn = false;
24971
24972 _.each([
24973 nav['doNotTrack'], // standard
24974 nav['msDoNotTrack'],
24975 win$1['doNotTrack']
24976 ], function(dntValue) {
24977 if (_.includes([true, 1, '1', 'yes'], dntValue)) {
24978 hasDntOn = true;
24979 }
24980 });
24981
24982 return hasDntOn;
24983 }
24984
24985 /**
24986 * Set cookie/localstorage for the user indicating that they are opted in or out for the given opt type
24987 * @param {boolean} optValue - whether to opt the user in or out for the given opt type
24988 * @param {string} token - Mixpanel project tracking token
24989 * @param {Object} [options]
24990 * @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
24991 * @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
24992 * @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
24993 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24994 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24995 * @param {string} [options.cookieDomain] - custom cookie domain
24996 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24997 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24998 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24999 */
25000 function _optInOut(optValue, token, options) {
25001 if (!_.isString(token) || !token.length) {
25002 console$1.error('gdpr.' + (optValue ? 'optIn' : 'optOut') + ' called with an invalid token');
25003 return;
25004 }
25005
25006 options = options || {};
25007
25008 _getStorage(options).set(
25009 _getStorageKey(token, options),
25010 optValue ? 1 : 0,
25011 _.isNumber(options.cookieExpiration) ? options.cookieExpiration : null,
25012 !!options.crossSubdomainCookie,
25013 !!options.secureCookie,
25014 !!options.crossSiteCookie,
25015 options.cookieDomain
25016 );
25017
25018 if (options.track && optValue) { // only track event if opting in (optValue=true)
25019 options.track(options.trackEventName || '$opt_in', options.trackProperties, {
25020 'send_immediately': true
25021 });
25022 }
25023 }
25024
25025 /**
25026 * Wrap a method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
25027 * If the user has opted out, return early instead of executing the method.
25028 * If a callback argument was provided, execute it passing the 0 error code.
25029 * @param {function} method - wrapped method to be executed if the user has not opted out
25030 * @param {function} getConfigValue - getter function for the Mixpanel API token and other options to be used with opt-out check
25031 * @returns {*} the result of executing method OR undefined if the user has opted out
25032 */
25033 function _addOptOutCheck(method, getConfigValue) {
25034 return function() {
25035 var optedOut = false;
25036
25037 try {
25038 var token = getConfigValue.call(this, 'token');
25039 var ignoreDnt = getConfigValue.call(this, 'ignore_dnt');
25040 var persistenceType = getConfigValue.call(this, 'opt_out_tracking_persistence_type');
25041 var persistencePrefix = getConfigValue.call(this, 'opt_out_tracking_cookie_prefix');
25042 var win = getConfigValue.call(this, 'window'); // used to override window during browser tests
25043
25044 if (token) { // if there was an issue getting the token, continue method execution as normal
25045 optedOut = hasOptedOut(token, {
25046 ignoreDnt: ignoreDnt,
25047 persistenceType: persistenceType,
25048 persistencePrefix: persistencePrefix,
25049 window: win
25050 });
25051 }
25052 } catch(err) {
25053 console$1.error('Unexpected error when checking tracking opt-out status: ' + err);
25054 }
25055
25056 if (!optedOut) {
25057 return method.apply(this, arguments);
25058 }
25059
25060 var callback = arguments[arguments.length - 1];
25061 if (typeof(callback) === 'function') {
25062 callback(0);
25063 }
25064
25065 return;
25066 };
25067 }
25068
25069 var logger$6 = console_with_prefix('lock');
25070
25071 /**
25072 * SharedLock: a mutex built on HTML5 localStorage, to ensure that only one browser
25073 * window/tab at a time will be able to access shared resources.
25074 *
25075 * Based on the Alur and Taubenfeld fast lock
25076 * (http://www.cs.rochester.edu/research/synchronization/pseudocode/fastlock.html)
25077 * with an added timeout to ensure there will be eventual progress in the event
25078 * that a window is closed in the middle of the callback.
25079 *
25080 * Implementation based on the original version by David Wolever (https://github.com/wolever)
25081 * at https://gist.github.com/wolever/5fd7573d1ef6166e8f8c4af286a69432.
25082 *
25083 * @example
25084 * const myLock = new SharedLock('some-key');
25085 * myLock.withLock(function() {
25086 * console.log('I hold the mutex!');
25087 * });
25088 *
25089 * @constructor
25090 */
25091 var SharedLock = function(key, options) {
25092 options = options || {};
25093
25094 this.storageKey = key;
25095 this.storage = options.storage || win.localStorage;
25096 this.pollIntervalMS = options.pollIntervalMS || 100;
25097 this.timeoutMS = options.timeoutMS || 2000;
25098
25099 // dependency-inject promise implementation for testing purposes
25100 this.promiseImpl = options.promiseImpl || PromisePolyfill;
25101 };
25102
25103 // pass in a specific pid to test contention scenarios; otherwise
25104 // it is chosen randomly for each acquisition attempt
25105 SharedLock.prototype.withLock = function(lockedCB, pid) {
25106 var Promise = this.promiseImpl;
25107 return new Promise(_.bind(function (resolve, reject) {
25108 var i = pid || (new Date().getTime() + '|' + Math.random());
25109 var startTime = new Date().getTime();
25110 var key = this.storageKey;
25111 var pollIntervalMS = this.pollIntervalMS;
25112 var timeoutMS = this.timeoutMS;
25113 var storage = this.storage;
25114
25115 var keyX = key + ':X';
25116 var keyY = key + ':Y';
25117 var keyZ = key + ':Z';
25118
25119 var delay = function(cb) {
25120 if (new Date().getTime() - startTime > timeoutMS) {
25121 logger$6.error('Timeout waiting for mutex on ' + key + '; clearing lock. [' + i + ']');
25122 storage.removeItem(keyZ);
25123 storage.removeItem(keyY);
25124 loop();
25125 return;
25126 }
25127 setTimeout(function() {
25128 try {
25129 cb();
25130 } catch(err) {
25131 reject(err);
25132 }
25133 }, pollIntervalMS * (Math.random() + 0.1));
25134 };
25135
25136 var waitFor = function(predicate, cb) {
25137 if (predicate()) {
25138 cb();
25139 } else {
25140 delay(function() {
25141 waitFor(predicate, cb);
25142 });
25143 }
25144 };
25145
25146 var getSetY = function() {
25147 var valY = storage.getItem(keyY);
25148 if (valY && valY !== i) { // if Y == i then this process already has the lock (useful for test cases)
25149 return false;
25150 } else {
25151 storage.setItem(keyY, i);
25152 if (storage.getItem(keyY) === i) {
25153 return true;
25154 } else {
25155 if (!localStorageSupported(storage, true)) {
25156 reject(new Error('localStorage support dropped while acquiring lock'));
25157 }
25158 return false;
25159 }
25160 }
25161 };
25162
25163 var loop = function() {
25164 storage.setItem(keyX, i);
25165
25166 waitFor(getSetY, function() {
25167 if (storage.getItem(keyX) === i) {
25168 criticalSection();
25169 return;
25170 }
25171
25172 delay(function() {
25173 if (storage.getItem(keyY) !== i) {
25174 loop();
25175 return;
25176 }
25177 waitFor(function() {
25178 return !storage.getItem(keyZ);
25179 }, criticalSection);
25180 });
25181 });
25182 };
25183
25184 var criticalSection = function() {
25185 storage.setItem(keyZ, '1');
25186 var removeLock = function () {
25187 storage.removeItem(keyZ);
25188 if (storage.getItem(keyY) === i) {
25189 storage.removeItem(keyY);
25190 }
25191 if (storage.getItem(keyX) === i) {
25192 storage.removeItem(keyX);
25193 }
25194 };
25195
25196 lockedCB()
25197 .then(function (ret) {
25198 removeLock();
25199 resolve(ret);
25200 })
25201 .catch(function (err) {
25202 removeLock();
25203 reject(err);
25204 });
25205 };
25206
25207 try {
25208 if (localStorageSupported(storage, true)) {
25209 loop();
25210 } else {
25211 throw new Error('localStorage support check failed');
25212 }
25213 } catch(err) {
25214 reject(err);
25215 }
25216 }, this));
25217 };
25218
25219 /**
25220 * @type {import('./wrapper').StorageWrapper}
25221 */
25222 var LocalStorageWrapper = function (storageOverride) {
25223 this.storage = storageOverride || win.localStorage;
25224 };
25225
25226 LocalStorageWrapper.prototype.init = function () {
25227 return PromisePolyfill.resolve();
25228 };
25229
25230 LocalStorageWrapper.prototype.isInitialized = function () {
25231 return true;
25232 };
25233
25234 LocalStorageWrapper.prototype.setItem = function (key, value) {
25235 return new PromisePolyfill(_.bind(function (resolve, reject) {
25236 try {
25237 this.storage.setItem(key, JSONStringify(value));
25238 } catch (e) {
25239 reject(e);
25240 }
25241 resolve();
25242 }, this));
25243 };
25244
25245 LocalStorageWrapper.prototype.getItem = function (key) {
25246 return new PromisePolyfill(_.bind(function (resolve, reject) {
25247 var item;
25248 try {
25249 item = JSONParse(this.storage.getItem(key));
25250 } catch (e) {
25251 reject(e);
25252 }
25253 resolve(item);
25254 }, this));
25255 };
25256
25257 LocalStorageWrapper.prototype.removeItem = function (key) {
25258 return new PromisePolyfill(_.bind(function (resolve, reject) {
25259 try {
25260 this.storage.removeItem(key);
25261 } catch (e) {
25262 reject(e);
25263 }
25264 resolve();
25265 }, this));
25266 };
25267
25268 var logger$5 = console_with_prefix('batch');
25269
25270 /**
25271 * RequestQueue: queue for batching API requests with localStorage backup for retries.
25272 * Maintains an in-memory queue which represents the source of truth for the current
25273 * page, but also writes all items out to a copy in the browser's localStorage, which
25274 * can be read on subsequent pageloads and retried. For batchability, all the request
25275 * items in the queue should be of the same type (events, people updates, group updates)
25276 * so they can be sent in a single request to the same API endpoint.
25277 *
25278 * LocalStorage keying and locking: In order for reloads and subsequent pageloads of
25279 * the same site to access the same persisted data, they must share the same localStorage
25280 * key (for instance based on project token and queue type). Therefore access to the
25281 * localStorage entry is guarded by an asynchronous mutex (SharedLock) to prevent
25282 * simultaneously open windows/tabs from overwriting each other's data (which would lead
25283 * to data loss in some situations).
25284 * @constructor
25285 */
25286 var RequestQueue = function (storageKey, options) {
25287 options = options || {};
25288 this.storageKey = storageKey;
25289 this.usePersistence = options.usePersistence;
25290 if (this.usePersistence) {
25291 this.queueStorage = options.queueStorage || new LocalStorageWrapper();
25292 this.lock = new SharedLock(storageKey, {
25293 storage: options.sharedLockStorage || win.localStorage,
25294 timeoutMS: options.sharedLockTimeoutMS,
25295 });
25296 }
25297 this.reportError = options.errorReporter || _.bind(logger$5.error, logger$5);
25298
25299 this.pid = options.pid || null; // pass pid to test out storage lock contention scenarios
25300
25301 this.memQueue = [];
25302 this.initialized = false;
25303
25304 if (options.enqueueThrottleMs) {
25305 this.enqueuePersisted = batchedThrottle(_.bind(this._enqueuePersisted, this), options.enqueueThrottleMs);
25306 } else {
25307 this.enqueuePersisted = _.bind(function (queueEntry) {
25308 return this._enqueuePersisted([queueEntry]);
25309 }, this);
25310 }
25311 };
25312
25313 RequestQueue.prototype.ensureInit = function () {
25314 if (this.initialized || !this.usePersistence) {
25315 return PromisePolyfill.resolve();
25316 }
25317
25318 return this.queueStorage
25319 .init()
25320 .then(_.bind(function () {
25321 this.initialized = true;
25322 }, this))
25323 .catch(_.bind(function (err) {
25324 this.reportError('Error initializing queue persistence. Disabling persistence', err);
25325 this.initialized = true;
25326 this.usePersistence = false;
25327 }, this));
25328 };
25329
25330 /**
25331 * Add one item to queues (memory and localStorage). The queued entry includes
25332 * the given item along with an auto-generated ID and a "flush-after" timestamp.
25333 * It is expected that the item will be sent over the network and dequeued
25334 * before the flush-after time; if this doesn't happen it is considered orphaned
25335 * (e.g., the original tab where it was enqueued got closed before it could be
25336 * sent) and the item can be sent by any tab that finds it in localStorage.
25337 *
25338 * The final callback param is called with a param indicating success or
25339 * failure of the enqueue operation; it is asynchronous because the localStorage
25340 * lock is asynchronous.
25341 */
25342 RequestQueue.prototype.enqueue = function (item, flushInterval) {
25343 var queueEntry = {
25344 'id': cheap_guid(),
25345 'flushAfter': new Date().getTime() + flushInterval * 2,
25346 'payload': item
25347 };
25348
25349 if (!this.usePersistence) {
25350 this.memQueue.push(queueEntry);
25351 return PromisePolyfill.resolve(true);
25352 } else {
25353 return this.enqueuePersisted(queueEntry);
25354 }
25355 };
25356
25357 RequestQueue.prototype._enqueuePersisted = function (queueEntries) {
25358 var enqueueItem = _.bind(function () {
25359 return this.ensureInit()
25360 .then(_.bind(function () {
25361 return this.readFromStorage();
25362 }, this))
25363 .then(_.bind(function (storedQueue) {
25364 return this.saveToStorage(storedQueue.concat(queueEntries));
25365 }, this))
25366 .then(_.bind(function (succeeded) {
25367 // only add to in-memory queue when storage succeeds
25368 if (succeeded) {
25369 this.memQueue = this.memQueue.concat(queueEntries);
25370 }
25371
25372 return succeeded;
25373 }, this))
25374 .catch(_.bind(function (err) {
25375 this.reportError('Error enqueueing items', err, queueEntries);
25376 return false;
25377 }, this));
25378 }, this);
25379
25380 return this.lock
25381 .withLock(enqueueItem, this.pid)
25382 .catch(_.bind(function (err) {
25383 this.reportError('Error acquiring storage lock', err);
25384 return false;
25385 }, this));
25386 };
25387
25388 /**
25389 * Read out the given number of queue entries. If this.memQueue
25390 * has fewer than batchSize items, then look for "orphaned" items
25391 * in the persisted queue (items where the 'flushAfter' time has
25392 * already passed).
25393 */
25394 RequestQueue.prototype.fillBatch = function (batchSize) {
25395 var batch = this.memQueue.slice(0, batchSize);
25396 if (this.usePersistence && batch.length < batchSize) {
25397 // don't need lock just to read events; localStorage is thread-safe
25398 // and the worst that could happen is a duplicate send of some
25399 // orphaned events, which will be deduplicated on the server side
25400 return this.ensureInit()
25401 .then(_.bind(function () {
25402 return this.readFromStorage();
25403 }, this))
25404 .then(_.bind(function (storedQueue) {
25405 if (storedQueue.length) {
25406 // item IDs already in batch; don't duplicate out of storage
25407 var idsInBatch = {}; // poor man's Set
25408 _.each(batch, function (item) {
25409 idsInBatch[item['id']] = true;
25410 });
25411
25412 for (var i = 0; i < storedQueue.length; i++) {
25413 var item = storedQueue[i];
25414 if (new Date().getTime() > item['flushAfter'] && !idsInBatch[item['id']]) {
25415 item.orphaned = true;
25416 batch.push(item);
25417 if (batch.length >= batchSize) {
25418 break;
25419 }
25420 }
25421 }
25422 }
25423
25424 return batch;
25425 }, this));
25426 } else {
25427 return PromisePolyfill.resolve(batch);
25428 }
25429 };
25430
25431 /**
25432 * Remove items with matching 'id' from array (immutably)
25433 * also remove any item without a valid id (e.g., malformed
25434 * storage entries).
25435 */
25436 var filterOutIDsAndInvalid = function (items, idSet) {
25437 var filteredItems = [];
25438 _.each(items, function (item) {
25439 if (item['id'] && !idSet[item['id']]) {
25440 filteredItems.push(item);
25441 }
25442 });
25443 return filteredItems;
25444 };
25445
25446 /**
25447 * Remove items with matching IDs from both in-memory queue
25448 * and persisted queue
25449 */
25450 RequestQueue.prototype.removeItemsByID = function (ids) {
25451 var idSet = {}; // poor man's Set
25452 _.each(ids, function (id) {
25453 idSet[id] = true;
25454 });
25455
25456 this.memQueue = filterOutIDsAndInvalid(this.memQueue, idSet);
25457 if (!this.usePersistence) {
25458 return PromisePolyfill.resolve(true);
25459 } else {
25460 var removeFromStorage = _.bind(function () {
25461 return this.ensureInit()
25462 .then(_.bind(function () {
25463 return this.readFromStorage();
25464 }, this))
25465 .then(_.bind(function (storedQueue) {
25466 storedQueue = filterOutIDsAndInvalid(storedQueue, idSet);
25467 return this.saveToStorage(storedQueue);
25468 }, this))
25469 .then(_.bind(function () {
25470 return this.readFromStorage();
25471 }, this))
25472 .then(_.bind(function (storedQueue) {
25473 // an extra check: did storage report success but somehow
25474 // the items are still there?
25475 for (var i = 0; i < storedQueue.length; i++) {
25476 var item = storedQueue[i];
25477 if (item['id'] && !!idSet[item['id']]) {
25478 throw new Error('Item not removed from storage');
25479 }
25480 }
25481 return true;
25482 }, this))
25483 .catch(_.bind(function (err) {
25484 this.reportError('Error removing items', err, ids);
25485 return false;
25486 }, this));
25487 }, this);
25488
25489 return this.lock
25490 .withLock(removeFromStorage, this.pid)
25491 .catch(_.bind(function (err) {
25492 this.reportError('Error acquiring storage lock', err);
25493 if (!localStorageSupported(this.lock.storage, true)) {
25494 // Looks like localStorage writes have stopped working sometime after
25495 // initialization (probably full), and so nobody can acquire locks
25496 // anymore. Consider it temporarily safe to remove items without the
25497 // lock, since nobody's writing successfully anyway.
25498 return removeFromStorage()
25499 .then(_.bind(function (success) {
25500 if (!success) {
25501 // OK, we couldn't even write out the smaller queue. Try clearing it
25502 // entirely.
25503 return this.queueStorage.removeItem(this.storageKey).then(function () {
25504 return success;
25505 });
25506 }
25507 return success;
25508 }, this))
25509 .catch(_.bind(function (err) {
25510 this.reportError('Error clearing queue', err);
25511 return false;
25512 }, this));
25513 } else {
25514 return false;
25515 }
25516 }, this));
25517 }
25518 };
25519
25520 // internal helper for RequestQueue.updatePayloads
25521 var updatePayloads = function (existingItems, itemsToUpdate) {
25522 var newItems = [];
25523 _.each(existingItems, function (item) {
25524 var id = item['id'];
25525 if (id in itemsToUpdate) {
25526 var newPayload = itemsToUpdate[id];
25527 if (newPayload !== null) {
25528 item['payload'] = newPayload;
25529 newItems.push(item);
25530 }
25531 } else {
25532 // no update
25533 newItems.push(item);
25534 }
25535 });
25536 return newItems;
25537 };
25538
25539 /**
25540 * Update payloads of given items in both in-memory queue and
25541 * persisted queue. Items set to null are removed from queues.
25542 */
25543 RequestQueue.prototype.updatePayloads = function (itemsToUpdate) {
25544 this.memQueue = updatePayloads(this.memQueue, itemsToUpdate);
25545 if (!this.usePersistence) {
25546 return PromisePolyfill.resolve(true);
25547 } else {
25548 return this.lock
25549 .withLock(_.bind(function lockAcquired() {
25550 return this.ensureInit()
25551 .then(_.bind(function () {
25552 return this.readFromStorage();
25553 }, this))
25554 .then(_.bind(function (storedQueue) {
25555 storedQueue = updatePayloads(storedQueue, itemsToUpdate);
25556 return this.saveToStorage(storedQueue);
25557 }, this))
25558 .catch(_.bind(function (err) {
25559 this.reportError('Error updating items', itemsToUpdate, err);
25560 return false;
25561 }, this));
25562 }, this), this.pid)
25563 .catch(_.bind(function (err) {
25564 this.reportError('Error acquiring storage lock', err);
25565 return false;
25566 }, this));
25567 }
25568 };
25569
25570 /**
25571 * Read and parse items array from localStorage entry, handling
25572 * malformed/missing data if necessary.
25573 */
25574 RequestQueue.prototype.readFromStorage = function () {
25575 return this.ensureInit()
25576 .then(_.bind(function () {
25577 return this.queueStorage.getItem(this.storageKey);
25578 }, this))
25579 .then(_.bind(function (storageEntry) {
25580 if (storageEntry) {
25581 if (!_.isArray(storageEntry)) {
25582 this.reportError('Invalid storage entry:', storageEntry);
25583 storageEntry = null;
25584 }
25585 }
25586 return storageEntry || [];
25587 }, this))
25588 .catch(_.bind(function (err) {
25589 this.reportError('Error retrieving queue', err);
25590 return [];
25591 }, this));
25592 };
25593
25594 /**
25595 * Serialize the given items array to localStorage.
25596 */
25597 RequestQueue.prototype.saveToStorage = function (queue) {
25598 return this.ensureInit()
25599 .then(_.bind(function () {
25600 return this.queueStorage.setItem(this.storageKey, queue);
25601 }, this))
25602 .then(function () {
25603 return true;
25604 })
25605 .catch(_.bind(function (err) {
25606 this.reportError('Error saving queue', err);
25607 return false;
25608 }, this));
25609 };
25610
25611 /**
25612 * Clear out queues (memory and localStorage).
25613 */
25614 RequestQueue.prototype.clear = function () {
25615 this.memQueue = [];
25616
25617 if (this.usePersistence) {
25618 return this.ensureInit()
25619 .then(_.bind(function () {
25620 return this.queueStorage.removeItem(this.storageKey);
25621 }, this));
25622 } else {
25623 return PromisePolyfill.resolve();
25624 }
25625 };
25626
25627 // maximum interval between request retries after exponential backoff
25628 var MAX_RETRY_INTERVAL_MS = 10 * 60 * 1000; // 10 minutes
25629
25630 var logger$4 = console_with_prefix('batch');
25631
25632 /**
25633 * RequestBatcher: manages the queueing, flushing, retry etc of requests of one
25634 * type (events, people, groups).
25635 * Uses RequestQueue to manage the backing store.
25636 * @constructor
25637 */
25638 var RequestBatcher = function(storageKey, options) {
25639 this.errorReporter = options.errorReporter;
25640 this.queue = new RequestQueue(storageKey, {
25641 errorReporter: _.bind(this.reportError, this),
25642 queueStorage: options.queueStorage,
25643 sharedLockStorage: options.sharedLockStorage,
25644 sharedLockTimeoutMS: options.sharedLockTimeoutMS,
25645 usePersistence: options.usePersistence,
25646 enqueueThrottleMs: options.enqueueThrottleMs
25647 });
25648
25649 this.libConfig = options.libConfig;
25650 this.sendRequest = options.sendRequestFunc;
25651 this.beforeSendHook = options.beforeSendHook;
25652 this.stopAllBatching = options.stopAllBatchingFunc;
25653
25654 // seed variable batch size + flush interval with configured values
25655 this.batchSize = this.libConfig['batch_size'];
25656 this.flushInterval = this.libConfig['batch_flush_interval_ms'];
25657
25658 this.stopped = !this.libConfig['batch_autostart'];
25659 this.consecutiveRemovalFailures = 0;
25660
25661 // extra client-side dedupe
25662 this.itemIdsSentSuccessfully = {};
25663
25664 // Make the flush occur at the interval specified by flushIntervalMs, default behavior will attempt consecutive flushes
25665 // as long as the queue is not empty. This is useful for high-frequency events like Session Replay where we might end up
25666 // in a request loop and get ratelimited by the server.
25667 this.flushOnlyOnInterval = options.flushOnlyOnInterval || false;
25668
25669 this._flushPromise = null;
25670 };
25671
25672 /**
25673 * Add one item to queue.
25674 */
25675 RequestBatcher.prototype.enqueue = function(item) {
25676 return this.queue.enqueue(item, this.flushInterval);
25677 };
25678
25679 /**
25680 * Start flushing batches at the configured time interval. Must call
25681 * this method upon SDK init in order to send anything over the network.
25682 */
25683 RequestBatcher.prototype.start = function() {
25684 this.stopped = false;
25685 this.consecutiveRemovalFailures = 0;
25686 return this.flush();
25687 };
25688
25689 /**
25690 * Stop flushing batches. Can be restarted by calling start().
25691 */
25692 RequestBatcher.prototype.stop = function() {
25693 this.stopped = true;
25694 if (this.timeoutID) {
25695 clearTimeout(this.timeoutID);
25696 this.timeoutID = null;
25697 }
25698 };
25699
25700 /**
25701 * Clear out queue.
25702 */
25703 RequestBatcher.prototype.clear = function() {
25704 return this.queue.clear();
25705 };
25706
25707 /**
25708 * Restore batch size configuration to whatever is set in the main SDK.
25709 */
25710 RequestBatcher.prototype.resetBatchSize = function() {
25711 this.batchSize = this.libConfig['batch_size'];
25712 };
25713
25714 /**
25715 * Restore flush interval time configuration to whatever is set in the main SDK.
25716 */
25717 RequestBatcher.prototype.resetFlush = function() {
25718 this.scheduleFlush(this.libConfig['batch_flush_interval_ms']);
25719 };
25720
25721 /**
25722 * Schedule the next flush in the given number of milliseconds.
25723 */
25724 RequestBatcher.prototype.scheduleFlush = function(flushMS) {
25725 this.flushInterval = flushMS;
25726 if (!this.stopped) { // don't schedule anymore if batching has been stopped
25727 this.timeoutID = setTimeout(_.bind(function() {
25728 if (!this.stopped) {
25729 this._flushPromise = this.flush();
25730 }
25731 }, this), this.flushInterval);
25732 }
25733 };
25734
25735 /**
25736 * Send a request using the sendRequest callback, but promisified.
25737 * TODO: sendRequest should be promisified in the first place.
25738 */
25739 RequestBatcher.prototype.sendRequestPromise = function(data, options) {
25740 return new PromisePolyfill(_.bind(function(resolve) {
25741 this.sendRequest(data, options, resolve);
25742 }, this));
25743 };
25744
25745
25746 /**
25747 * Flush one batch to network. Depending on success/failure modes, it will either
25748 * remove the batch from the queue or leave it in for retry, and schedule the next
25749 * flush. In cases of most network or API failures, it will back off exponentially
25750 * when retrying.
25751 * @param {Object} [options]
25752 * @param {boolean} [options.sendBeacon] - whether to send batch with
25753 * navigator.sendBeacon (only useful for sending batches before page unloads, as
25754 * sendBeacon offers no callbacks or status indications)
25755 */
25756 RequestBatcher.prototype.flush = function(options) {
25757 if (this.requestInProgress) {
25758 logger$4.log('Flush: Request already in progress');
25759 return PromisePolyfill.resolve();
25760 }
25761
25762 this.requestInProgress = true;
25763
25764 options = options || {};
25765 var timeoutMS = this.libConfig['batch_request_timeout_ms'];
25766 var startTime = new Date().getTime();
25767 var currentBatchSize = this.batchSize;
25768
25769 return this.queue.fillBatch(currentBatchSize)
25770 .then(_.bind(function(batch) {
25771
25772 // if there's more items in the queue than the batch size, attempt
25773 // to flush again after the current batch is done.
25774 var attemptSecondaryFlush = batch.length === currentBatchSize;
25775 var dataForRequest = [];
25776 var transformedItems = {};
25777 _.each(batch, function(item) {
25778 var payload = item['payload'];
25779 if (this.beforeSendHook && !item.orphaned) {
25780 payload = this.beforeSendHook(payload);
25781 }
25782 if (payload) {
25783 // mp_sent_by_lib_version prop captures which lib version actually
25784 // sends each event (regardless of which version originally queued
25785 // it for sending)
25786 if (payload['event'] && payload['properties']) {
25787 payload['properties'] = _.extend(
25788 {},
25789 payload['properties'],
25790 {'mp_sent_by_lib_version': Config.LIB_VERSION}
25791 );
25792 }
25793 var addPayload = true;
25794 var itemId = item['id'];
25795 if (itemId) {
25796 if ((this.itemIdsSentSuccessfully[itemId] || 0) > 5) {
25797 this.reportError('[dupe] item ID sent too many times, not sending', {
25798 item: item,
25799 batchSize: batch.length,
25800 timesSent: this.itemIdsSentSuccessfully[itemId]
25801 });
25802 addPayload = false;
25803 }
25804 } else {
25805 this.reportError('[dupe] found item with no ID', {item: item});
25806 }
25807
25808 if (addPayload) {
25809 dataForRequest.push(payload);
25810 }
25811 }
25812 transformedItems[item['id']] = payload;
25813 }, this);
25814
25815 if (dataForRequest.length < 1) {
25816 this.requestInProgress = false;
25817 this.resetFlush();
25818 return PromisePolyfill.resolve(); // nothing to do
25819 }
25820
25821 var removeItemsFromQueue = _.bind(function () {
25822 return this.queue
25823 .removeItemsByID(
25824 _.map(batch, function (item) {
25825 return item['id'];
25826 })
25827 )
25828 .then(_.bind(function (succeeded) {
25829 // client-side dedupe
25830 _.each(batch, _.bind(function(item) {
25831 var itemId = item['id'];
25832 if (itemId) {
25833 this.itemIdsSentSuccessfully[itemId] = this.itemIdsSentSuccessfully[itemId] || 0;
25834 this.itemIdsSentSuccessfully[itemId]++;
25835 if (this.itemIdsSentSuccessfully[itemId] > 5) {
25836 this.reportError('[dupe] item ID sent too many times', {
25837 item: item,
25838 batchSize: batch.length,
25839 timesSent: this.itemIdsSentSuccessfully[itemId]
25840 });
25841 }
25842 } else {
25843 this.reportError('[dupe] found item with no ID while removing', {item: item});
25844 }
25845 }, this));
25846
25847 if (succeeded) {
25848 this.consecutiveRemovalFailures = 0;
25849 if (this.flushOnlyOnInterval && !attemptSecondaryFlush) {
25850 this.resetFlush(); // schedule next batch with a delay
25851 return PromisePolyfill.resolve();
25852 } else {
25853 return this.flush(); // handle next batch if the queue isn't empty
25854 }
25855 } else {
25856 if (++this.consecutiveRemovalFailures > 5) {
25857 this.reportError('Too many queue failures; disabling batching system.');
25858 this.stopAllBatching();
25859 } else {
25860 this.resetFlush();
25861 }
25862 return PromisePolyfill.resolve();
25863 }
25864 }, this));
25865 }, this);
25866
25867 var batchSendCallback = _.bind(function(res) {
25868 this.requestInProgress = false;
25869
25870 try {
25871
25872 // handle API response in a try-catch to make sure we can reset the
25873 // flush operation if something goes wrong
25874
25875 if (options.unloading) {
25876 // update persisted data to include hook transformations
25877 return this.queue.updatePayloads(transformedItems);
25878 } else if (
25879 _.isObject(res) &&
25880 res.error === 'timeout' &&
25881 new Date().getTime() - startTime >= timeoutMS
25882 ) {
25883 this.reportError('Network timeout; retrying');
25884 return this.flush();
25885 } else if (
25886 _.isObject(res) &&
25887 (
25888 res.httpStatusCode >= 500
25889 || res.httpStatusCode === 429
25890 || (res.httpStatusCode <= 0 && !isOnline())
25891 || res.error === 'timeout'
25892 )
25893 ) {
25894 // network or API error, or 429 Too Many Requests, retry
25895 var retryMS = this.flushInterval * 2;
25896 if (res.retryAfter) {
25897 retryMS = (parseInt(res.retryAfter, 10) * 1000) || retryMS;
25898 }
25899 retryMS = Math.min(MAX_RETRY_INTERVAL_MS, retryMS);
25900 this.reportError('Error; retry in ' + retryMS + ' ms');
25901 this.scheduleFlush(retryMS);
25902 return PromisePolyfill.resolve();
25903 } else if (_.isObject(res) && res.httpStatusCode === 413) {
25904 // 413 Payload Too Large
25905 if (batch.length > 1) {
25906 var halvedBatchSize = Math.max(1, Math.floor(currentBatchSize / 2));
25907 this.batchSize = Math.min(this.batchSize, halvedBatchSize, batch.length - 1);
25908 this.reportError('413 response; reducing batch size to ' + this.batchSize);
25909 this.resetFlush();
25910 return PromisePolyfill.resolve();
25911 } else {
25912 this.reportError('Single-event request too large; dropping', batch);
25913 this.resetBatchSize();
25914 return removeItemsFromQueue();
25915 }
25916 } else {
25917 // successful network request+response; remove each item in batch from queue
25918 // (even if it was e.g. a 400, in which case retrying won't help)
25919 return removeItemsFromQueue();
25920 }
25921 } catch(err) {
25922 this.reportError('Error handling API response', err);
25923 this.resetFlush();
25924 }
25925 }, this);
25926 var requestOptions = {
25927 method: 'POST',
25928 verbose: true,
25929 ignore_json_errors: true, // eslint-disable-line camelcase
25930 timeout_ms: timeoutMS // eslint-disable-line camelcase
25931 };
25932 if (options.unloading) {
25933 requestOptions.transport = 'sendBeacon';
25934 }
25935 logger$4.log('MIXPANEL REQUEST:', dataForRequest);
25936 return this.sendRequestPromise(dataForRequest, requestOptions).then(batchSendCallback);
25937 }, this))
25938 .catch(_.bind(function(err) {
25939 this.reportError('Error flushing request queue', err);
25940 this.resetFlush();
25941 }, this));
25942 };
25943
25944 /**
25945 * Log error to global logger and optional user-defined logger.
25946 */
25947 RequestBatcher.prototype.reportError = function(msg, err) {
25948 logger$4.error.apply(logger$4.error, arguments);
25949 if (this.errorReporter) {
25950 try {
25951 if (!(err instanceof Error)) {
25952 err = new Error(msg);
25953 }
25954 this.errorReporter(msg, err);
25955 } catch(err) {
25956 logger$4.error(err);
25957 }
25958 }
25959 };
25960
25961 /**
25962 * @param {import('./session-recording').SerializedRecording} serializedRecording
25963 * @returns {boolean}
25964 */
25965 var isRecordingExpired = function(serializedRecording) {
25966 var now = Date.now();
25967 return !serializedRecording || now > serializedRecording['maxExpires'] || now > serializedRecording['idleExpires'];
25968 };
25969
25970 var RECORD_ENQUEUE_THROTTLE_MS = 250;
25971
25972 var logger$3 = console_with_prefix('recorder');
25973 var CompressionStream = win['CompressionStream'];
25974
25975 var RECORDER_BATCHER_LIB_CONFIG = {
25976 'batch_size': 1000,
25977 'batch_flush_interval_ms': 10 * 1000,
25978 'batch_request_timeout_ms': 90 * 1000,
25979 'batch_autostart': true
25980 };
25981
25982 var ACTIVE_SOURCES = new Set([
25983 IncrementalSource.MouseMove,
25984 IncrementalSource.MouseInteraction,
25985 IncrementalSource.Scroll,
25986 IncrementalSource.ViewportResize,
25987 IncrementalSource.Input,
25988 IncrementalSource.TouchMove,
25989 IncrementalSource.MediaInteraction,
25990 IncrementalSource.Drag,
25991 IncrementalSource.Selection,
25992 ]);
25993
25994 function isUserEvent(ev) {
25995 return ev.type === EventType.IncrementalSnapshot && ACTIVE_SOURCES.has(ev.data.source);
25996 }
25997
25998 /**
25999 * @typedef {Object} SerializedRecording
26000 * @property {number} idleExpires
26001 * @property {number} maxExpires
26002 * @property {number} replayStartTime
26003 * @property {number} seqNo
26004 * @property {string} batchStartUrl
26005 * @property {string} replayId
26006 * @property {string} tabId
26007 * @property {string} replayStartUrl
26008 */
26009
26010 /**
26011 * @typedef {Object} SessionRecordingOptions
26012 * @property {Object} [options.mixpanelInstance] - reference to the core MixpanelLib
26013 * @property {String} [options.replayId] - unique uuid for a single replay
26014 * @property {Function} [options.onIdleTimeout] - callback when a recording reaches idle timeout
26015 * @property {Function} [options.onMaxLengthReached] - callback when a recording reaches its maximum length
26016 * @property {Function} [options.rrwebRecord] - rrweb's `record` function
26017 * @property {Function} [options.onBatchSent] - callback when a batch of events is sent to the server
26018 * @property {Storage} [options.sharedLockStorage] - optional storage for shared lock, used for test dependency injection
26019 * optional properties for deserialization:
26020 * @property {number} idleExpires
26021 * @property {number} maxExpires
26022 * @property {number} replayStartTime
26023 * @property {number} seqNo
26024 * @property {string} batchStartUrl
26025 * @property {string} replayStartUrl
26026 */
26027
26028 /**
26029 * @typedef {Object} UserIdInfo
26030 * @property {string} distinct_id
26031 * @property {string} user_id
26032 * @property {string} device_id
26033 */
26034
26035
26036 /**
26037 * This class encapsulates a single session recording and its lifecycle.
26038 * @param {SessionRecordingOptions} options
26039 */
26040 var SessionRecording = function(options) {
26041 this._mixpanel = options.mixpanelInstance;
26042 this._onIdleTimeout = options.onIdleTimeout || NOOP_FUNC;
26043 this._onMaxLengthReached = options.onMaxLengthReached || NOOP_FUNC;
26044 this._onBatchSent = options.onBatchSent || NOOP_FUNC;
26045 this._rrwebRecord = options.rrwebRecord || null;
26046
26047 // internal rrweb stopRecording function
26048 this._stopRecording = null;
26049 this.replayId = options.replayId;
26050
26051 this.batchStartUrl = options.batchStartUrl || null;
26052 this.replayStartUrl = options.replayStartUrl || null;
26053 this.idleExpires = options.idleExpires || null;
26054 this.maxExpires = options.maxExpires || null;
26055 this.replayStartTime = options.replayStartTime || null;
26056 this.seqNo = options.seqNo || 0;
26057
26058 this.idleTimeoutId = null;
26059 this.maxTimeoutId = null;
26060
26061 this.recordMaxMs = MAX_RECORDING_MS;
26062 this.recordMinMs = 0;
26063
26064 // disable persistence if localStorage is not supported
26065 // request-queue will automatically disable persistence if indexedDB fails to initialize
26066 var usePersistence = localStorageSupported(options.sharedLockStorage, true) && !this.getConfig('disable_persistence');
26067
26068 // each replay has its own batcher key to avoid conflicts between rrweb events of different recordings
26069 this.batcherKey = '__mprec_' + this.getConfig('name') + '_' + this.getConfig('token') + '_' + this.replayId;
26070 this.queueStorage = new IDBStorageWrapper(RECORDING_EVENTS_STORE_NAME);
26071 this.batcher = new RequestBatcher(this.batcherKey, {
26072 errorReporter: this.reportError.bind(this),
26073 flushOnlyOnInterval: true,
26074 libConfig: RECORDER_BATCHER_LIB_CONFIG,
26075 sendRequestFunc: this.flushEventsWithOptOut.bind(this),
26076 queueStorage: this.queueStorage,
26077 sharedLockStorage: options.sharedLockStorage,
26078 usePersistence: usePersistence,
26079 stopAllBatchingFunc: this.stopRecording.bind(this),
26080
26081 // increased throttle and shared lock timeout because recording events are very high frequency.
26082 // this will minimize the amount of lock contention between enqueued events.
26083 // for session recordings there is a lock for each tab anyway, so there's no risk of deadlock between tabs.
26084 enqueueThrottleMs: RECORD_ENQUEUE_THROTTLE_MS,
26085 sharedLockTimeoutMS: 10 * 1000,
26086 });
26087 };
26088
26089 /**
26090 * @returns {UserIdInfo}
26091 */
26092 SessionRecording.prototype.getUserIdInfo = function () {
26093 if (this.finalFlushUserIdInfo) {
26094 return this.finalFlushUserIdInfo;
26095 }
26096
26097 var userIdInfo = {
26098 'distinct_id': String(this._mixpanel.get_distinct_id()),
26099 };
26100
26101 // send ID management props if they exist
26102 var deviceId = this._mixpanel.get_property('$device_id');
26103 if (deviceId) {
26104 userIdInfo['$device_id'] = deviceId;
26105 }
26106 var userId = this._mixpanel.get_property('$user_id');
26107 if (userId) {
26108 userIdInfo['$user_id'] = userId;
26109 }
26110 return userIdInfo;
26111 };
26112
26113 SessionRecording.prototype.unloadPersistedData = function () {
26114 this.batcher.stop();
26115 return this.batcher.flush()
26116 .then(function () {
26117 return this.queueStorage.removeItem(this.batcherKey);
26118 }.bind(this));
26119 };
26120
26121 SessionRecording.prototype.getConfig = function(configVar) {
26122 return this._mixpanel.get_config(configVar);
26123 };
26124
26125 // Alias for getConfig, used by the common addOptOutCheckMixpanelLib function which
26126 // reaches into this class instance and expects the snake case version of the function.
26127 // eslint-disable-next-line camelcase
26128 SessionRecording.prototype.get_config = function(configVar) {
26129 return this.getConfig(configVar);
26130 };
26131
26132 SessionRecording.prototype.startRecording = function (shouldStopBatcher) {
26133 if (this._rrwebRecord === null) {
26134 this.reportError('rrweb record function not provided. ');
26135 return;
26136 }
26137
26138 if (this._stopRecording !== null) {
26139 logger$3.log('Recording already in progress, skipping startRecording.');
26140 return;
26141 }
26142
26143 this.recordMaxMs = this.getConfig('record_max_ms');
26144 if (this.recordMaxMs > MAX_RECORDING_MS) {
26145 this.recordMaxMs = MAX_RECORDING_MS;
26146 logger$3.critical('record_max_ms cannot be greater than ' + MAX_RECORDING_MS + 'ms. Capping value.');
26147 }
26148
26149 if (!this.maxExpires) {
26150 this.maxExpires = new Date().getTime() + this.recordMaxMs;
26151 }
26152
26153 this.recordMinMs = this.getConfig('record_min_ms');
26154 if (this.recordMinMs > MAX_VALUE_FOR_MIN_RECORDING_MS) {
26155 this.recordMinMs = MAX_VALUE_FOR_MIN_RECORDING_MS;
26156 logger$3.critical('record_min_ms cannot be greater than ' + MAX_VALUE_FOR_MIN_RECORDING_MS + 'ms. Capping value.');
26157 }
26158
26159 if (!this.replayStartTime) {
26160 this.replayStartTime = new Date().getTime();
26161 this.batchStartUrl = _.info.currentUrl();
26162 this.replayStartUrl = _.info.currentUrl();
26163 }
26164
26165 if (shouldStopBatcher || this.recordMinMs > 0) {
26166 // the primary case for shouldStopBatcher is when we're starting recording after a reset
26167 // and don't want to send anything over the network until there's
26168 // actual user activity
26169 // this also applies if the minimum recording length has not been hit yet
26170 // so that we don't send data until we know the recording will be long enough
26171 this.batcher.stop();
26172 } else {
26173 this.batcher.start();
26174 }
26175
26176 var resetIdleTimeout = function () {
26177 clearTimeout(this.idleTimeoutId);
26178 var idleTimeoutMs = this.getConfig('record_idle_timeout_ms');
26179 this.idleTimeoutId = setTimeout(this._onIdleTimeout, idleTimeoutMs);
26180 this.idleExpires = new Date().getTime() + idleTimeoutMs;
26181 }.bind(this);
26182 resetIdleTimeout();
26183
26184 var blockSelector = this.getConfig('record_block_selector');
26185 if (blockSelector === '' || blockSelector === null) {
26186 blockSelector = undefined;
26187 }
26188
26189 try {
26190 this._stopRecording = this._rrwebRecord({
26191 'emit': function (ev) {
26192 if (this.idleExpires && this.idleExpires < ev.timestamp) {
26193 this._onIdleTimeout();
26194 return;
26195 }
26196 if (isUserEvent(ev)) {
26197 if (this.batcher.stopped && new Date().getTime() - this.replayStartTime >= this.recordMinMs) {
26198 // start flushing again after user activity
26199 this.batcher.start();
26200 }
26201 resetIdleTimeout();
26202 }
26203 // promise only used to await during tests
26204 this.__enqueuePromise = this.batcher.enqueue(ev);
26205 }.bind(this),
26206 'blockClass': this.getConfig('record_block_class'),
26207 'blockSelector': blockSelector,
26208 'collectFonts': this.getConfig('record_collect_fonts'),
26209 'dataURLOptions': { // canvas image options (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL)
26210 'type': 'image/webp',
26211 'quality': 0.6
26212 },
26213 'maskAllInputs': true,
26214 'maskTextClass': this.getConfig('record_mask_text_class'),
26215 'maskTextSelector': this.getConfig('record_mask_text_selector'),
26216 'recordCanvas': this.getConfig('record_canvas'),
26217 'sampling': {
26218 'canvas': 15
26219 }
26220 });
26221 } catch (err) {
26222 this.reportError('Unexpected error when starting rrweb recording.', err);
26223 }
26224
26225 if (typeof this._stopRecording !== 'function') {
26226 this.reportError('rrweb failed to start, skipping this recording.');
26227 this._stopRecording = null;
26228 this.stopRecording(); // stop batcher looping and any timeouts
26229 return;
26230 }
26231
26232 var maxTimeoutMs = this.maxExpires - new Date().getTime();
26233 this.maxTimeoutId = setTimeout(this._onMaxLengthReached.bind(this), maxTimeoutMs);
26234 };
26235
26236 SessionRecording.prototype.stopRecording = function (skipFlush) {
26237 // store the user ID info in case this is getting called in mixpanel.reset()
26238 this.finalFlushUserIdInfo = this.getUserIdInfo();
26239
26240 if (!this.isRrwebStopped()) {
26241 try {
26242 this._stopRecording();
26243 } catch (err) {
26244 this.reportError('Error with rrweb stopRecording', err);
26245 }
26246 this._stopRecording = null;
26247 }
26248
26249 var flushPromise;
26250 if (this.batcher.stopped) {
26251 // never got user activity to flush after reset, so just clear the batcher
26252 flushPromise = this.batcher.clear();
26253 } else if (!skipFlush) {
26254 // flush any remaining events from running batcher
26255 flushPromise = this.batcher.flush();
26256 }
26257 this.batcher.stop();
26258
26259 clearTimeout(this.idleTimeoutId);
26260 clearTimeout(this.maxTimeoutId);
26261 return flushPromise;
26262 };
26263
26264 SessionRecording.prototype.isRrwebStopped = function () {
26265 return this._stopRecording === null;
26266 };
26267
26268
26269 /**
26270 * Flushes the current batch of events to the server, but passes an opt-out callback to make sure
26271 * we stop recording and dump any queued events if the user has opted out.
26272 */
26273 SessionRecording.prototype.flushEventsWithOptOut = function (data, options, cb) {
26274 var onOptOut = function (code) {
26275 // addOptOutCheckMixpanelLib invokes this function with code=0 when the user has opted out
26276 if (code === 0) {
26277 this.stopRecording();
26278 cb({error: 'Tracking has been opted out, stopping recording.'});
26279 }
26280 }.bind(this);
26281
26282 this._flushEvents(data, options, cb, onOptOut);
26283 };
26284
26285 /**
26286 * @returns {SerializedRecording}
26287 */
26288 SessionRecording.prototype.serialize = function () {
26289 // don't break if mixpanel instance was destroyed at some point
26290 var tabId;
26291 try {
26292 tabId = this._mixpanel.get_tab_id();
26293 } catch (e) {
26294 this.reportError('Error getting tab ID for serialization ', e);
26295 tabId = null;
26296 }
26297
26298 return {
26299 'replayId': this.replayId,
26300 'seqNo': this.seqNo,
26301 'replayStartTime': this.replayStartTime,
26302 'batchStartUrl': this.batchStartUrl,
26303 'replayStartUrl': this.replayStartUrl,
26304 'idleExpires': this.idleExpires,
26305 'maxExpires': this.maxExpires,
26306 'tabId': tabId,
26307 };
26308 };
26309
26310
26311 /**
26312 * @static
26313 * @param {SerializedRecording} serializedRecording
26314 * @param {SessionRecordingOptions} options
26315 * @returns {SessionRecording}
26316 */
26317 SessionRecording.deserialize = function (serializedRecording, options) {
26318 var recording = new SessionRecording(_.extend({}, options, {
26319 replayId: serializedRecording['replayId'],
26320 batchStartUrl: serializedRecording['batchStartUrl'],
26321 replayStartUrl: serializedRecording['replayStartUrl'],
26322 idleExpires: serializedRecording['idleExpires'],
26323 maxExpires: serializedRecording['maxExpires'],
26324 replayStartTime: serializedRecording['replayStartTime'],
26325 seqNo: serializedRecording['seqNo'],
26326 sharedLockStorage: options.sharedLockStorage,
26327 }));
26328
26329 return recording;
26330 };
26331
26332 SessionRecording.prototype._sendRequest = function(currentReplayId, reqParams, reqBody, callback) {
26333 var onSuccess = function (response, responseBody) {
26334 // Update batch specific props only if the request was successful to guarantee ordering.
26335 // RequestBatcher will always flush the next batch after the previous one succeeds.
26336 // extra check to see if the replay ID has changed so that we don't increment the seqNo on the wrong replay
26337 if (response.status === 200 && this.replayId === currentReplayId) {
26338 this.seqNo++;
26339 this.batchStartUrl = _.info.currentUrl();
26340 }
26341
26342 this._onBatchSent();
26343 callback({
26344 status: 0,
26345 httpStatusCode: response.status,
26346 responseBody: responseBody,
26347 retryAfter: response.headers.get('Retry-After')
26348 });
26349 }.bind(this);
26350 var apiHost = (this._mixpanel.get_api_host && this._mixpanel.get_api_host('record')) || this.getConfig('api_host');
26351 win['fetch'](apiHost + '/' + this.getConfig('api_routes')['record'] + '?' + new URLSearchParams(reqParams), {
26352 'method': 'POST',
26353 'headers': {
26354 'Authorization': 'Basic ' + btoa(this.getConfig('token') + ':'),
26355 'Content-Type': 'application/octet-stream'
26356 },
26357 'body': reqBody,
26358 }).then(function (response) {
26359 response.json().then(function (responseBody) {
26360 onSuccess(response, responseBody);
26361 }).catch(function (error) {
26362 callback({error: error});
26363 });
26364 }).catch(function (error) {
26365 callback({error: error, httpStatusCode: 0});
26366 });
26367 };
26368
26369 SessionRecording.prototype._flushEvents = addOptOutCheckMixpanelLib(function (data, options, callback) {
26370 var numEvents = data.length;
26371
26372 if (numEvents > 0) {
26373 var replayId = this.replayId;
26374
26375 // each rrweb event has a timestamp - leverage those to get time properties
26376 var batchStartTime = Infinity;
26377 var batchEndTime = -Infinity;
26378 var hasFullSnapshot = false;
26379 for (var i = 0; i < numEvents; i++) {
26380 batchStartTime = Math.min(batchStartTime, data[i].timestamp);
26381 batchEndTime = Math.max(batchEndTime, data[i].timestamp);
26382 if (data[i].type === EventType.FullSnapshot) {
26383 hasFullSnapshot = true;
26384 }
26385 }
26386
26387 if (this.seqNo === 0) {
26388 if (!hasFullSnapshot) {
26389 callback({error: 'First batch does not contain a full snapshot. Aborting recording.'});
26390 this.stopRecording(true);
26391 return;
26392 }
26393 this.replayStartTime = batchStartTime;
26394 } else if (!this.replayStartTime) {
26395 this.reportError('Replay start time not set but seqNo is not 0. Using current batch start time as a fallback.');
26396 this.replayStartTime = batchStartTime;
26397 }
26398
26399 var replayLengthMs = batchEndTime - this.replayStartTime;
26400
26401 var reqParams = {
26402 '$current_url': this.batchStartUrl,
26403 '$lib_version': Config.LIB_VERSION,
26404 'batch_start_time': batchStartTime / 1000,
26405 'mp_lib': 'web',
26406 'replay_id': replayId,
26407 'replay_length_ms': replayLengthMs,
26408 'replay_start_time': this.replayStartTime / 1000,
26409 'replay_start_url': this.replayStartUrl,
26410 'seq': this.seqNo
26411 };
26412 var eventsJson = JSON.stringify(data);
26413 Object.assign(reqParams, this.getUserIdInfo());
26414
26415 if (CompressionStream) {
26416 var jsonStream = new Blob([eventsJson], {type: 'application/json'}).stream();
26417 var gzipStream = jsonStream.pipeThrough(new CompressionStream('gzip'));
26418 new Response(gzipStream)
26419 .blob()
26420 .then(function(compressedBlob) {
26421 reqParams['format'] = 'gzip';
26422 this._sendRequest(replayId, reqParams, compressedBlob, callback);
26423 }.bind(this));
26424 } else {
26425 reqParams['format'] = 'body';
26426 this._sendRequest(replayId, reqParams, eventsJson, callback);
26427 }
26428 }
26429 });
26430
26431
26432 SessionRecording.prototype.reportError = function(msg, err) {
26433 logger$3.error.apply(logger$3.error, arguments);
26434 try {
26435 if (!err && !(msg instanceof Error)) {
26436 msg = new Error(msg);
26437 }
26438 this.getConfig('error_reporter')(msg, err);
26439 } catch(err) {
26440 logger$3.error(err);
26441 }
26442 };
26443
26444 /**
26445 * Module for handling the storage and retrieval of recording metadata as well as any active recordings.
26446 * Makes sure that only one tab can be recording at a time.
26447 */
26448 var RecordingRegistry = function (options) {
26449 /** @type {IDBStorageWrapper} */
26450 this.idb = new IDBStorageWrapper(RECORDING_REGISTRY_STORE_NAME);
26451 this.errorReporter = options.errorReporter;
26452 this.mixpanelInstance = options.mixpanelInstance;
26453 this.sharedLockStorage = options.sharedLockStorage;
26454 };
26455
26456 RecordingRegistry.prototype.isPersistenceEnabled = function() {
26457 return !this.mixpanelInstance.get_config('disable_persistence');
26458 };
26459
26460 RecordingRegistry.prototype.handleError = function (err) {
26461 this.errorReporter('IndexedDB error: ', err);
26462 };
26463
26464 /**
26465 * @param {import('./session-recording').SerializedRecording} serializedRecording
26466 */
26467 RecordingRegistry.prototype.setActiveRecording = function (serializedRecording) {
26468 if (!this.isPersistenceEnabled()) {
26469 return PromisePolyfill.resolve();
26470 }
26471
26472 var tabId = serializedRecording['tabId'];
26473 if (!tabId) {
26474 console.warn('No tab ID is set, cannot persist recording metadata.');
26475 return PromisePolyfill.resolve();
26476 }
26477
26478 return this.idb.init()
26479 .then(function () {
26480 return this.idb.setItem(tabId, serializedRecording);
26481 }.bind(this))
26482 .catch(this.handleError.bind(this));
26483 };
26484
26485 /**
26486 * @returns {Promise<import('./session-recording').SerializedRecording>}
26487 */
26488 RecordingRegistry.prototype.getActiveRecording = function () {
26489 if (!this.isPersistenceEnabled()) {
26490 return PromisePolyfill.resolve(null);
26491 }
26492
26493 return this.idb.init()
26494 .then(function () {
26495 return this.idb.getItem(this.mixpanelInstance.get_tab_id());
26496 }.bind(this))
26497 .then(function (serializedRecording) {
26498 return isRecordingExpired(serializedRecording) ? null : serializedRecording;
26499 }.bind(this))
26500 .catch(this.handleError.bind(this));
26501 };
26502
26503 RecordingRegistry.prototype.clearActiveRecording = function () {
26504 if (this.isPersistenceEnabled()) {
26505 // mark recording as expired instead of deleting it in case the page unloads mid-flush and doesn't make it to ingestion.
26506 // this will ensure the next pageload will flush the remaining events, but not try to continue the recording.
26507 return this.markActiveRecordingExpired();
26508 } else {
26509 return this.deleteActiveRecording();
26510 }
26511 };
26512
26513 RecordingRegistry.prototype.markActiveRecordingExpired = function () {
26514 return this.getActiveRecording()
26515 .then(function (serializedRecording) {
26516 if (serializedRecording) {
26517 serializedRecording['maxExpires'] = 0;
26518 return this.setActiveRecording(serializedRecording);
26519 }
26520 }.bind(this))
26521 .catch(this.handleError.bind(this));
26522 };
26523
26524 RecordingRegistry.prototype.deleteActiveRecording = function () {
26525 // avoid initializing IDB if this registry instance hasn't already written a recording
26526 if (this.idb.isInitialized()) {
26527 return this.idb.removeItem(this.mixpanelInstance.get_tab_id())
26528 .catch(this.handleError.bind(this));
26529 } else {
26530 return PromisePolyfill.resolve();
26531 }
26532 };
26533
26534 /**
26535 * Flush any inactive recordings from the registry to minimize data loss.
26536 * The main idea here is that we can flush remaining rrweb events on the next page load if a tab is closed mid-batch.
26537 */
26538 RecordingRegistry.prototype.flushInactiveRecordings = function () {
26539 if (!this.isPersistenceEnabled()) {
26540 return PromisePolyfill.resolve([]);
26541 }
26542
26543 return this.idb.init()
26544 .then(function() {
26545 return this.idb.getAll();
26546 }.bind(this))
26547 .then(function (serializedRecordings) {
26548 // clean up any expired recordings from the registry, non-expired ones may be active in other tabs
26549 var unloadPromises = serializedRecordings
26550 .filter(function (serializedRecording) {
26551 return isRecordingExpired(serializedRecording);
26552 })
26553 .map(function (serializedRecording) {
26554 var sessionRecording = SessionRecording.deserialize(serializedRecording, {
26555 mixpanelInstance: this.mixpanelInstance,
26556 sharedLockStorage: this.sharedLockStorage
26557 });
26558 return sessionRecording.unloadPersistedData()
26559 .then(function () {
26560 // expired recording was successfully flushed, we can clean it up from the registry
26561 return this.idb.removeItem(serializedRecording['tabId']);
26562 }.bind(this))
26563 .catch(this.handleError.bind(this));
26564 }.bind(this));
26565
26566 return PromisePolyfill.all(unloadPromises);
26567 }.bind(this))
26568 .catch(this.handleError.bind(this));
26569 };
26570
26571 var logger$2 = console_with_prefix('recorder');
26572
26573 /**
26574 * Recorder API: bundles rrweb and and exposes methods to start and stop recordings.
26575 * @param {Object} [options.mixpanelInstance] - reference to the core MixpanelLib
26576 */
26577 var MixpanelRecorder = function(mixpanelInstance, rrwebRecord, sharedLockStorage) {
26578 this.mixpanelInstance = mixpanelInstance;
26579 this.rrwebRecord = rrwebRecord || record;
26580 this.sharedLockStorage = sharedLockStorage;
26581
26582 /**
26583 * @member {import('./registry').RecordingRegistry}
26584 */
26585 this.recordingRegistry = new RecordingRegistry({
26586 mixpanelInstance: this.mixpanelInstance,
26587 errorReporter: logger$2.error,
26588 sharedLockStorage: sharedLockStorage
26589 });
26590 this._flushInactivePromise = this.recordingRegistry.flushInactiveRecordings();
26591
26592 this.activeRecording = null;
26593 this.stopRecordingInProgress = false;
26594 };
26595
26596 MixpanelRecorder.prototype.startRecording = function(options) {
26597 options = options || {};
26598 if (this.activeRecording && !this.activeRecording.isRrwebStopped()) {
26599 logger$2.log('Recording already in progress, skipping startRecording.');
26600 return;
26601 }
26602
26603 var onIdleTimeout = function () {
26604 logger$2.log('Idle timeout reached, restarting recording.');
26605 this.resetRecording();
26606 }.bind(this);
26607
26608 var onMaxLengthReached = function () {
26609 logger$2.log('Max recording length reached, stopping recording.');
26610 this.resetRecording();
26611 }.bind(this);
26612
26613 var onBatchSent = function () {
26614 this.recordingRegistry.setActiveRecording(this.activeRecording.serialize());
26615 this['__flushPromise'] = this.activeRecording.batcher._flushPromise;
26616 }.bind(this);
26617
26618 /**
26619 * @type {import('./session-recording').SessionRecordingOptions}
26620 */
26621 var sessionRecordingOptions = {
26622 mixpanelInstance: this.mixpanelInstance,
26623 onBatchSent: onBatchSent,
26624 onIdleTimeout: onIdleTimeout,
26625 onMaxLengthReached: onMaxLengthReached,
26626 replayId: _.UUID(),
26627 rrwebRecord: this.rrwebRecord,
26628 sharedLockStorage: this.sharedLockStorage
26629 };
26630
26631 if (options.activeSerializedRecording) {
26632 this.activeRecording = SessionRecording.deserialize(options.activeSerializedRecording, sessionRecordingOptions);
26633 } else {
26634 this.activeRecording = new SessionRecording(sessionRecordingOptions);
26635 }
26636
26637 this.activeRecording.startRecording(options.shouldStopBatcher);
26638 return this.recordingRegistry.setActiveRecording(this.activeRecording.serialize());
26639 };
26640
26641 MixpanelRecorder.prototype.stopRecording = function() {
26642 // Prevents activeSerializedRecording from being reused when stopping the recording.
26643 this.stopRecordingInProgress = true;
26644 return this._stopCurrentRecording(false, true).then(function() {
26645 return this.recordingRegistry.clearActiveRecording();
26646 }.bind(this)).then(function() {
26647 this.stopRecordingInProgress = false;
26648 }.bind(this));
26649 };
26650
26651 MixpanelRecorder.prototype.pauseRecording = function() {
26652 return this._stopCurrentRecording(false);
26653 };
26654
26655 MixpanelRecorder.prototype._stopCurrentRecording = function(skipFlush, disableActiveRecording) {
26656 if (this.activeRecording) {
26657 var stopRecordingPromise = this.activeRecording.stopRecording(skipFlush);
26658 if (disableActiveRecording) {
26659 this.activeRecording = null;
26660 }
26661 return stopRecordingPromise;
26662 }
26663 return PromisePolyfill.resolve();
26664 };
26665
26666 MixpanelRecorder.prototype.resumeRecording = function (startNewIfInactive) {
26667 if (this.activeRecording && this.activeRecording.isRrwebStopped()) {
26668 this.activeRecording.startRecording(false);
26669 return PromisePolyfill.resolve(null);
26670 }
26671
26672 return this.recordingRegistry.getActiveRecording()
26673 .then(function (activeSerializedRecording) {
26674 if (activeSerializedRecording && !this.stopRecordingInProgress) {
26675 return this.startRecording({activeSerializedRecording: activeSerializedRecording});
26676 } else if (startNewIfInactive) {
26677 return this.startRecording({shouldStopBatcher: false});
26678 } else {
26679 logger$2.log('No resumable recording found.');
26680 return null;
26681 }
26682 }.bind(this));
26683 };
26684
26685
26686 MixpanelRecorder.prototype.resetRecording = function () {
26687 this.stopRecording();
26688 this.startRecording({shouldStopBatcher: true});
26689 };
26690
26691 MixpanelRecorder.prototype.getActiveReplayId = function () {
26692 if (this.activeRecording && !this.activeRecording.isRrwebStopped()) {
26693 return this.activeRecording.replayId;
26694 } else {
26695 return null;
26696 }
26697 };
26698
26699 // getter so that older mixpanel-core versions can still retrieve the replay ID
26700 // when pulling the latest recorder bundle from the CDN
26701 Object.defineProperty(MixpanelRecorder.prototype, 'replayId', {
26702 get: function () {
26703 return this.getActiveReplayId();
26704 }
26705 });
26706
26707 win['__mp_recorder'] = MixpanelRecorder;
26708
26709 // stateless utils
26710 // mostly from https://github.com/mixpanel/mixpanel-js/blob/989ada50f518edab47b9c4fd9535f9fbd5ec5fc0/src/autotrack-utils.js
26711
26712
26713 var EV_CHANGE = 'change';
26714 var EV_CLICK = 'click';
26715 var EV_HASHCHANGE = 'hashchange';
26716 var EV_INPUT = 'input';
26717 var EV_LOAD = 'load';
26718 var EV_MP_LOCATION_CHANGE = 'mp_locationchange';
26719 var EV_POPSTATE = 'popstate';
26720 // TODO scrollend isn't available in Safari: document or polyfill?
26721 var EV_SCROLLEND = 'scrollend';
26722 var EV_SCROLL = 'scroll';
26723 var EV_SELECT = 'select';
26724 var EV_SUBMIT = 'submit';
26725 var EV_TOGGLE = 'toggle';
26726 var EV_VISIBILITYCHANGE = 'visibilitychange';
26727
26728 var CLICK_EVENT_PROPS = [
26729 'clientX', 'clientY',
26730 'offsetX', 'offsetY',
26731 'pageX', 'pageY',
26732 'screenX', 'screenY',
26733 'x', 'y'
26734 ];
26735 var OPT_IN_CLASSES = ['mp-include'];
26736 var OPT_OUT_CLASSES = ['mp-no-track'];
26737 var SENSITIVE_DATA_CLASSES = OPT_OUT_CLASSES.concat(['mp-sensitive']);
26738 var TRACKED_ATTRS = [
26739 'aria-label', 'aria-labelledby', 'aria-describedby',
26740 'href', 'name', 'role', 'title', 'type'
26741 ];
26742
26743 var INTERACTIVE_ARIA_ROLES = {
26744 'button': true,
26745 'checkbox': true,
26746 'combobox': true,
26747 'grid': true,
26748 'link': true,
26749 'listbox': true,
26750 'menu': true,
26751 'menubar': true,
26752 'menuitem': true,
26753 'menuitemcheckbox': true,
26754 'menuitemradio': true,
26755 'navigation': true,
26756 'option': true,
26757 'radio': true,
26758 'radiogroup': true,
26759 'searchbox': true,
26760 'slider': true,
26761 'spinbutton': true,
26762 'switch': true,
26763 'tab': true,
26764 'tablist': true,
26765 'textbox': true,
26766 'tree': true,
26767 'treegrid': true,
26768 'treeitem': true
26769 };
26770
26771 var ALWAYS_NON_INTERACTIVE_TAGS = {
26772 // Document metadata
26773 'base': true,
26774 'head': true,
26775 'html': true,
26776 'link': true,
26777 'meta': true,
26778 'script': true,
26779 'style': true,
26780 'title': true,
26781 // Text formatting
26782 'br': true,
26783 'hr': true,
26784 'wbr': true,
26785 // Other
26786 'noscript': true,
26787 'picture': true,
26788 'source': true,
26789 'template': true,
26790 'track': true
26791 };
26792
26793 // Common container tags that need additional checks
26794 var TEXT_CONTAINER_TAGS = {
26795 'article': true,
26796 'div': true,
26797 'h1': true,
26798 'h2': true,
26799 'h3': true,
26800 'h4': true,
26801 'h5': true,
26802 'h6': true,
26803 'p': true,
26804 'section': true,
26805 'span': true
26806 };
26807
26808 var EVENT_HANDLER_ATTRIBUTES = [
26809 'onclick', 'onmousedown', 'onmouseup', 'onpointerdown', 'onpointerup', 'ontouchend', 'ontouchstart'
26810 ];
26811
26812 var MAX_DEPTH = 5;
26813
26814 var logger$1 = console_with_prefix('autocapture');
26815
26816
26817 function getClasses(el) {
26818 var classes = {};
26819 var classList = getClassName(el).split(' ');
26820 for (var i = 0; i < classList.length; i++) {
26821 var cls = classList[i];
26822 if (cls) {
26823 classes[cls] = true;
26824 }
26825 }
26826 return classes;
26827 }
26828
26829 /*
26830 * Get the className of an element, accounting for edge cases where element.className is an object
26831 * @param {Element} el - element to get the className of
26832 * @returns {string} the element's class
26833 */
26834 function getClassName(el) {
26835 switch(typeof el.className) {
26836 case 'string':
26837 return el.className;
26838 case 'object': // handle cases where className might be SVGAnimatedString or some other type
26839 return el.className.baseVal || el.getAttribute('class') || '';
26840 default: // future proof
26841 return '';
26842 }
26843 }
26844
26845 function getPreviousElementSibling(el) {
26846 if (el.previousElementSibling) {
26847 return el.previousElementSibling;
26848 } else {
26849 do {
26850 el = el.previousSibling;
26851 } while (el && !isElementNode(el));
26852 return el;
26853 }
26854 }
26855
26856 function getPropertiesFromElement(el, ev, blockAttrsSet, extraAttrs, allowElementCallback, allowSelectors) {
26857 var props = {
26858 '$classes': getClassName(el).split(' '),
26859 '$tag_name': el.tagName.toLowerCase()
26860 };
26861 var elId = el.id;
26862 if (elId) {
26863 props['$id'] = elId;
26864 }
26865
26866 if (shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors)) {
26867 _.each(TRACKED_ATTRS.concat(extraAttrs), function(attr) {
26868 if (el.hasAttribute(attr) && !blockAttrsSet[attr]) {
26869 var attrVal = el.getAttribute(attr);
26870 if (shouldTrackValue(attrVal)) {
26871 props['$attr-' + attr] = attrVal;
26872 }
26873 }
26874 });
26875 }
26876
26877 var nthChild = 1;
26878 var nthOfType = 1;
26879 var currentElem = el;
26880 while (currentElem = getPreviousElementSibling(currentElem)) { // eslint-disable-line no-cond-assign
26881 nthChild++;
26882 if (currentElem.tagName === el.tagName) {
26883 nthOfType++;
26884 }
26885 }
26886 props['$nth_child'] = nthChild;
26887 props['$nth_of_type'] = nthOfType;
26888
26889 return props;
26890 }
26891
26892 function getPropsForDOMEvent(ev, config) {
26893 var allowElementCallback = config.allowElementCallback;
26894 var allowSelectors = config.allowSelectors || [];
26895 var blockAttrs = config.blockAttrs || [];
26896 var blockElementCallback = config.blockElementCallback;
26897 var blockSelectors = config.blockSelectors || [];
26898 var captureTextContent = config.captureTextContent || false;
26899 var captureExtraAttrs = config.captureExtraAttrs || [];
26900 var capturedForHeatMap = config.capturedForHeatMap || false;
26901
26902 // convert array to set every time, as the config may have changed
26903 var blockAttrsSet = {};
26904 _.each(blockAttrs, function(attr) {
26905 blockAttrsSet[attr] = true;
26906 });
26907
26908 var props = null;
26909
26910 var target = typeof ev.target === 'undefined' ? ev.srcElement : ev.target;
26911 if (isTextNode(target)) { // defeat Safari bug (see: http://www.quirksmode.org/js/events_properties.html)
26912 target = target.parentNode;
26913 }
26914
26915 if (
26916 shouldTrackDomEvent(target, ev) &&
26917 isElementAllowed(target, ev, allowElementCallback, allowSelectors) &&
26918 !isElementBlocked(target, ev, blockElementCallback, blockSelectors)
26919 ) {
26920 var targetElementList = [target];
26921 var curEl = target;
26922 while (curEl.parentNode && !isTag(curEl, 'body')) {
26923 targetElementList.push(curEl.parentNode);
26924 curEl = curEl.parentNode;
26925 }
26926
26927 var elementsJson = [];
26928 var href, explicitNoTrack = false;
26929 _.each(targetElementList, function(el) {
26930 var shouldTrackDetails = shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors);
26931
26932 // if the element or a parent element is an anchor tag
26933 // include the href as a property
26934 if (!blockAttrsSet['href'] && el.tagName.toLowerCase() === 'a') {
26935 href = el.getAttribute('href');
26936 href = shouldTrackDetails && shouldTrackValue(href) && href;
26937 }
26938
26939 if (isElementBlocked(el, ev, blockElementCallback, blockSelectors)) {
26940 explicitNoTrack = true;
26941 }
26942
26943 elementsJson.push(getPropertiesFromElement(el, ev, blockAttrsSet, captureExtraAttrs, allowElementCallback, allowSelectors));
26944 }, this);
26945
26946 if (!explicitNoTrack) {
26947 var docElement = document$1['documentElement'];
26948 props = {
26949 '$event_type': ev.type,
26950 '$host': win.location.host,
26951 '$pathname': win.location.pathname,
26952 '$elements': elementsJson,
26953 '$el_attr__href': href,
26954 '$viewportHeight': Math.max(docElement['clientHeight'], win['innerHeight'] || 0),
26955 '$viewportWidth': Math.max(docElement['clientWidth'], win['innerWidth'] || 0),
26956 '$pageHeight': document$1['body']['offsetHeight'] || 0,
26957 '$pageWidth': document$1['body']['offsetWidth'] || 0,
26958 };
26959 _.each(captureExtraAttrs, function(attr) {
26960 if (!blockAttrsSet[attr] && target.hasAttribute(attr)) {
26961 var attrVal = target.getAttribute(attr);
26962 if (shouldTrackValue(attrVal)) {
26963 props['$el_attr__' + attr] = attrVal;
26964 }
26965 }
26966 });
26967
26968 if (captureTextContent) {
26969 elementText = getSafeText(target, ev, allowElementCallback, allowSelectors);
26970 if (elementText && elementText.length) {
26971 props['$el_text'] = elementText;
26972 }
26973 }
26974
26975 if (ev.type === EV_CLICK) {
26976 _.each(CLICK_EVENT_PROPS, function(prop) {
26977 if (prop in ev) {
26978 props['$' + prop] = ev[prop];
26979 }
26980 });
26981 if (capturedForHeatMap) {
26982 props['$captured_for_heatmap'] = true;
26983 }
26984 target = guessRealClickTarget(ev);
26985 }
26986 // prioritize text content from "real" click target if different from original target
26987 if (captureTextContent) {
26988 var elementText = getSafeText(target, ev, allowElementCallback, allowSelectors);
26989 if (elementText && elementText.length) {
26990 props['$el_text'] = elementText;
26991 }
26992 }
26993
26994 if (target) {
26995 // target may have been recalculated; check allowlists and blocklists again
26996 if (
26997 !isElementAllowed(target, ev, allowElementCallback, allowSelectors) ||
26998 isElementBlocked(target, ev, blockElementCallback, blockSelectors)
26999 ) {
27000 return null;
27001 }
27002
27003 var targetProps = getPropertiesFromElement(target, ev, blockAttrsSet, captureExtraAttrs, allowElementCallback, allowSelectors);
27004 props['$target'] = targetProps;
27005 // pull up more props onto main event props
27006 props['$el_classes'] = targetProps['$classes'];
27007 _.extend(props, _.strip_empty_properties({
27008 '$el_id': targetProps['$id'],
27009 '$el_tag_name': targetProps['$tag_name']
27010 }));
27011 }
27012 }
27013 }
27014
27015 return props;
27016 }
27017
27018
27019 /**
27020 * Get the direct text content of an element, protecting against sensitive data collection.
27021 * Concats textContent of each of the element's text node children; this avoids potential
27022 * collection of sensitive data that could happen if we used element.textContent and the
27023 * element had sensitive child elements, since element.textContent includes child content.
27024 * Scrubs values that look like they could be sensitive (i.e. cc or ssn number).
27025 * @param {Element} el - element to get the text of
27026 * @param {Array<string>} allowSelectors - CSS selectors for elements that should be included
27027 * @returns {string} the element's direct text content
27028 */
27029 function getSafeText(el, ev, allowElementCallback, allowSelectors) {
27030 var elText = '';
27031
27032 if (shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors) && el.childNodes && el.childNodes.length) {
27033 _.each(el.childNodes, function(child) {
27034 if (isTextNode(child) && child.textContent) {
27035 elText += _.trim(child.textContent)
27036 // scrub potentially sensitive values
27037 .split(/(\s+)/).filter(shouldTrackValue).join('')
27038 // normalize whitespace
27039 .replace(/[\r\n]/g, ' ').replace(/[ ]+/g, ' ')
27040 // truncate
27041 .substring(0, 255);
27042 }
27043 });
27044 }
27045
27046 return _.trim(elText);
27047 }
27048
27049 function guessRealClickTarget(ev) {
27050 var target = ev.target;
27051 var composedPath = ev['composedPath']();
27052 for (var i = 0; i < composedPath.length; i++) {
27053 var node = composedPath[i];
27054 if (
27055 isTag(node, 'a') ||
27056 isTag(node, 'button') ||
27057 isTag(node, 'input') ||
27058 isTag(node, 'select') ||
27059 (node.getAttribute && node.getAttribute('role') === 'button')
27060 ) {
27061 target = node;
27062 break;
27063 }
27064 if (node === target) {
27065 break;
27066 }
27067 }
27068 return target;
27069 }
27070
27071 function isElementAllowed(el, ev, allowElementCallback, allowSelectors) {
27072 if (allowElementCallback) {
27073 try {
27074 if (!allowElementCallback(el, ev)) {
27075 return false;
27076 }
27077 } catch (err) {
27078 logger$1.critical('Error while checking element in allowElementCallback', err);
27079 return false;
27080 }
27081 }
27082
27083 if (!allowSelectors.length) {
27084 // no allowlist; all elements are fair game
27085 return true;
27086 }
27087
27088 for (var i = 0; i < allowSelectors.length; i++) {
27089 var sel = allowSelectors[i];
27090 try {
27091 if (el['matches'](sel)) {
27092 return true;
27093 }
27094 } catch (err) {
27095 logger$1.critical('Error while checking selector: ' + sel, err);
27096 }
27097 }
27098 return false;
27099 }
27100
27101 function isElementBlocked(el, ev, blockElementCallback, blockSelectors) {
27102 var i;
27103
27104 if (blockElementCallback) {
27105 try {
27106 if (blockElementCallback(el, ev)) {
27107 return true;
27108 }
27109 } catch (err) {
27110 logger$1.critical('Error while checking element in blockElementCallback', err);
27111 return true;
27112 }
27113 }
27114
27115 if (blockSelectors && blockSelectors.length) {
27116 // programmatically prevent tracking of elements that match CSS selectors
27117 for (i = 0; i < blockSelectors.length; i++) {
27118 var sel = blockSelectors[i];
27119 try {
27120 if (el['matches'](sel)) {
27121 return true;
27122 }
27123 } catch (err) {
27124 logger$1.critical('Error while checking selector: ' + sel, err);
27125 }
27126 }
27127 }
27128
27129 // allow users to programmatically prevent tracking of elements by adding default classes such as 'mp-no-track'
27130 var classes = getClasses(el);
27131 for (i = 0; i < OPT_OUT_CLASSES.length; i++) {
27132 if (classes[OPT_OUT_CLASSES[i]]) {
27133 return true;
27134 }
27135 }
27136
27137 return false;
27138 }
27139
27140 /*
27141 * Check whether a DOM node has nodeType Node.ELEMENT_NODE
27142 * @param {Node} node - node to check
27143 * @returns {boolean} whether node is of the correct nodeType
27144 */
27145 function isElementNode(node) {
27146 return node && node.nodeType === 1; // Node.ELEMENT_NODE - use integer constant for browser portability
27147 }
27148
27149 /*
27150 * Check whether an element is of a given tag type.
27151 * Due to potential reference discrepancies (such as the webcomponents.js polyfill),
27152 * we want to match tagNames instead of specific references because something like
27153 * element === document.body won't always work because element might not be a native
27154 * element.
27155 * @param {Element} el - element to check
27156 * @param {string} tag - tag name (e.g., "div")
27157 * @returns {boolean} whether el is of the given tag type
27158 */
27159 function isTag(el, tag) {
27160 return el && el.tagName && el.tagName.toLowerCase() === tag.toLowerCase();
27161 }
27162
27163 /*
27164 * Check whether a DOM node is a TEXT_NODE
27165 * @param {Node} node - node to check
27166 * @returns {boolean} whether node is of type Node.TEXT_NODE
27167 */
27168 function isTextNode(node) {
27169 return node && node.nodeType === 3; // Node.TEXT_NODE - use integer constant for browser portability
27170 }
27171
27172 function minDOMApisSupported() {
27173 try {
27174 var testEl = document$1.createElement('div');
27175 return !!testEl['matches'];
27176 } catch (err) {
27177 return false;
27178 }
27179 }
27180
27181 function weakSetSupported() {
27182 return typeof WeakSet !== 'undefined';
27183 }
27184
27185 /*
27186 * Check whether a DOM event should be "tracked" or if it may contain sensitive data
27187 * using a variety of heuristics.
27188 * @param {Element} el - element to check
27189 * @param {Event} ev - event to check
27190 * @returns {boolean} whether the event should be tracked
27191 */
27192 function shouldTrackDomEvent(el, ev) {
27193 if (!el || isTag(el, 'html') || !isElementNode(el)) {
27194 return false;
27195 }
27196 var tag = el.tagName.toLowerCase();
27197 switch (tag) {
27198 case 'form':
27199 return ev.type === EV_SUBMIT;
27200 case 'input':
27201 if (['button', 'submit'].indexOf(el.getAttribute('type')) === -1) {
27202 return ev.type === EV_CHANGE;
27203 } else {
27204 return ev.type === EV_CLICK;
27205 }
27206 case 'select':
27207 case 'textarea':
27208 return ev.type === EV_CHANGE;
27209 default:
27210 return ev.type === EV_CLICK;
27211 }
27212 }
27213
27214 /*
27215 * Check whether a DOM element should be "tracked" or if it may contain sensitive data
27216 * using a variety of heuristics.
27217 * @param {Element} el - element to check
27218 * @param {Array<string>} allowSelectors - CSS selectors for elements that should be included
27219 * @returns {boolean} whether the element should be tracked
27220 */
27221 function shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors) {
27222 var i;
27223
27224 if (!isElementAllowed(el, ev, allowElementCallback, allowSelectors)) {
27225 return false;
27226 }
27227
27228 for (var curEl = el; curEl.parentNode && !isTag(curEl, 'body'); curEl = curEl.parentNode) {
27229 var classes = getClasses(curEl);
27230 for (i = 0; i < SENSITIVE_DATA_CLASSES.length; i++) {
27231 if (classes[SENSITIVE_DATA_CLASSES[i]]) {
27232 return false;
27233 }
27234 }
27235 }
27236
27237 var elClasses = getClasses(el);
27238 for (i = 0; i < OPT_IN_CLASSES.length; i++) {
27239 if (elClasses[OPT_IN_CLASSES[i]]) {
27240 return true;
27241 }
27242 }
27243
27244 // don't send data from inputs or similar elements since there will always be
27245 // a risk of clientside javascript placing sensitive data in attributes
27246 if (
27247 isTag(el, 'input') ||
27248 isTag(el, 'select') ||
27249 isTag(el, 'textarea') ||
27250 el.getAttribute('contenteditable') === 'true'
27251 ) {
27252 return false;
27253 }
27254
27255 // don't include hidden or password fields
27256 var type = el.type || '';
27257 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"]
27258 switch(type.toLowerCase()) {
27259 case 'hidden':
27260 return false;
27261 case 'password':
27262 return false;
27263 }
27264 }
27265
27266 // filter out data from fields that look like sensitive fields
27267 var name = el.name || el.id || '';
27268 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"]
27269 var sensitiveNameRegex = /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i;
27270 if (sensitiveNameRegex.test(name.replace(/[^a-zA-Z0-9]/g, ''))) {
27271 return false;
27272 }
27273 }
27274
27275 return true;
27276 }
27277
27278
27279 /*
27280 * Check whether a string value should be "tracked" or if it may contain sensitive data
27281 * using a variety of heuristics.
27282 * @param {string} value - string value to check
27283 * @returns {boolean} whether the element should be tracked
27284 */
27285 function shouldTrackValue(value) {
27286 if (value === null || _.isUndefined(value)) {
27287 return false;
27288 }
27289
27290 if (typeof value === 'string') {
27291 value = _.trim(value);
27292
27293 // check to see if input value looks like a credit card number
27294 // see: https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9781449327453/ch04s20.html
27295 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}))$/;
27296 if (ccRegex.test((value || '').replace(/[- ]/g, ''))) {
27297 return false;
27298 }
27299
27300 // check to see if input value looks like a social security number
27301 var ssnRegex = /(^\d{3}-?\d{2}-?\d{4}$)/;
27302 if (ssnRegex.test(value)) {
27303 return false;
27304 }
27305 }
27306
27307 return true;
27308 }
27309
27310 /**
27311 * Creates a cross-browser compatible scroll end function with appropriate event listener.
27312 * For browsers that support scrollend, returns the original function with scrollend event.
27313 * For browsers without scrollend support, returns a debounced function that triggers
27314 * 100ms after the last scroll event to simulate scrollend behavior.
27315 * @param {Function} originalFunction - The function to call when scrolling ends
27316 * @returns {Object} Object containing listener function and eventType string
27317 * @returns {Function} returns.listener - The wrapped function to use as event listener
27318 * @returns {string} returns.eventType - The event type to listen for ('scrollend' or 'scroll')
27319 */
27320 function getPolyfillScrollEndFunction(originalFunction) {
27321 var supportsScrollEnd = 'onscrollend' in win;
27322 var polyfillFunction = safewrap(originalFunction);
27323 var polyfillEvent = EV_SCROLLEND;
27324 if (!supportsScrollEnd) {
27325 // Polyfill for browsers without scrollend support: wait 100ms after the last scroll event
27326 // https://developer.chrome.com/blog/scrollend-a-new-javascript-event
27327 var scrollTimer = null;
27328 var scrollDelayMs = 100;
27329
27330 polyfillFunction = safewrap(function() {
27331 clearTimeout(scrollTimer);
27332 scrollTimer = setTimeout(originalFunction, scrollDelayMs);
27333 });
27334
27335 polyfillEvent = EV_SCROLL;
27336 }
27337
27338 return {
27339 listener: polyfillFunction,
27340 eventType: polyfillEvent
27341 };
27342 }
27343
27344 function hasInlineEventHandlers(element) {
27345 for (var i = 0; i < EVENT_HANDLER_ATTRIBUTES.length; i++) {
27346 if (element.hasAttribute(EVENT_HANDLER_ATTRIBUTES[i])) {
27347 return true;
27348 }
27349 }
27350 return false;
27351 }
27352
27353 function hasInteractiveAriaRole(element) {
27354 var role = element.getAttribute('role');
27355 if (!role) return false;
27356
27357 // Handle invalid markup where multiple roles might be specified
27358 // Only the first token is recognized per ARIA spec
27359 var primaryRole = role.trim().split(/\s+/)[0].toLowerCase();
27360
27361 return INTERACTIVE_ARIA_ROLES[primaryRole];
27362 }
27363
27364 function hasAnyInteractivityIndicators(element) {
27365 var tagName = element.tagName.toLowerCase();
27366
27367 // Check for interactive HTML elements
27368 if (tagName === 'button' ||
27369 tagName === 'input' ||
27370 tagName === 'select' ||
27371 tagName === 'textarea' ||
27372 tagName === 'details' ||
27373 tagName === 'dialog') {
27374 return true;
27375 }
27376
27377 if (element.isContentEditable) {
27378 return true;
27379 }
27380
27381 if (element.onclick || element.onmousedown || element.onmouseup || element.ontouchstart || element.ontouchend) {
27382 return true;
27383 }
27384
27385 if (hasInlineEventHandlers(element)) {
27386 return true;
27387 }
27388
27389 if (hasInteractiveAriaRole(element)) {
27390 return true;
27391 }
27392
27393 if (tagName === 'a' && element.hasAttribute('href')) {
27394 return true;
27395 }
27396
27397 if (element.hasAttribute('tabindex')) {
27398 return true;
27399 }
27400
27401 return false;
27402 }
27403
27404
27405 function isDefinitelyNonInteractive(element) {
27406 if (!element || !element.tagName) {
27407 return true;
27408 }
27409
27410 var tagName = element.tagName.toLowerCase();
27411
27412 // These tags are definitely non-interactive
27413 if (ALWAYS_NON_INTERACTIVE_TAGS[tagName]) {
27414 return true;
27415 }
27416
27417 // For all other elements, we can only be certain they're non-interactive if they lack ALL indicators of interactivity
27418 // Check for any signs of interactivity
27419 if (hasAnyInteractivityIndicators(element)) {
27420 return false;
27421 }
27422
27423 // Check parent chain for interactive context
27424 var parent = element.parentElement;
27425 var depth = 0;
27426
27427 while (parent && depth < MAX_DEPTH) {
27428 if (hasAnyInteractivityIndicators(parent)) {
27429 return false; // Element is inside an interactive parent
27430 }
27431
27432 if (parent.getRootNode && parent.getRootNode() !== document$1) {
27433 var root = parent.getRootNode();
27434 if (root.host && hasAnyInteractivityIndicators(root.host)) {
27435 return false; // Inside an interactive shadow host
27436 }
27437 }
27438
27439 parent = parent.parentElement;
27440 depth++;
27441 }
27442
27443 // Pure text containers without any interactive context
27444 if (TEXT_CONTAINER_TAGS[tagName]) {
27445 // These are non-interactive ONLY if they have no interactive indicators (already checked as part of hasAnyInteractivityIndicators)
27446 return true;
27447 }
27448
27449 // Default: we can't be certain it's non-interactive
27450 return false;
27451 }
27452
27453 /** @const */ var DEFAULT_RAGE_CLICK_THRESHOLD_PX = 30;
27454 /** @const */ var DEFAULT_RAGE_CLICK_TIMEOUT_MS = 1000;
27455 /** @const */ var DEFAULT_RAGE_CLICK_CLICK_COUNT = 4;
27456
27457 function RageClickTracker() {
27458 this.clicks = [];
27459 }
27460
27461 RageClickTracker.prototype.isRageClick = function(x, y, options) {
27462 options = options || {};
27463 var thresholdPx = options['threshold_px'] || DEFAULT_RAGE_CLICK_THRESHOLD_PX;
27464 var timeoutMs = options['timeout_ms'] || DEFAULT_RAGE_CLICK_TIMEOUT_MS;
27465 var clickCount = options['click_count'] || DEFAULT_RAGE_CLICK_CLICK_COUNT;
27466 var timestamp = Date.now();
27467
27468 var lastClick = this.clicks[this.clicks.length - 1];
27469 if (
27470 lastClick &&
27471 timestamp - lastClick.timestamp < timeoutMs &&
27472 Math.sqrt(Math.pow(x - lastClick.x, 2) + Math.pow(y - lastClick.y, 2)) < thresholdPx
27473 ) {
27474 this.clicks.push({ x: x, y: y, timestamp: timestamp });
27475 if (this.clicks.length >= clickCount) {
27476 this.clicks = [];
27477 return true;
27478 }
27479 } else {
27480 this.clicks = [{ x: x, y: y, timestamp: timestamp }];
27481 }
27482 return false;
27483 };
27484
27485 function ShadowDOMObserver(changeCallback, observerConfig) {
27486 this.changeCallback = changeCallback || function() {};
27487 this.observerConfig = observerConfig;
27488
27489 this.observedShadowRoots = null;
27490 this.shadowObservers = [];
27491 }
27492
27493 ShadowDOMObserver.prototype.getEventTarget = function(event) {
27494 if (!this.observedShadowRoots) {
27495 return;
27496 }
27497 var path = this.getComposedPath(event);
27498 if (path && path.length) {
27499 return path[0];
27500 }
27501
27502 return event['target'] || event['srcElement'];
27503 };
27504
27505
27506 ShadowDOMObserver.prototype.getComposedPath = function(event) {
27507 if ('composedPath' in event) {
27508 return event['composedPath']();
27509 }
27510
27511 return [];
27512 };
27513 ShadowDOMObserver.prototype.observeFromEvent = function(event) {
27514 if (!this.observedShadowRoots) {
27515 return;
27516 }
27517
27518 var path = this.getComposedPath(event);
27519
27520 // Check each element in path for shadow roots
27521 for (var i = 0; i < path.length; i++) {
27522 var element = path[i];
27523
27524 if (element && element.shadowRoot) {
27525 this.observeShadowRoot(element.shadowRoot);
27526 }
27527 }
27528 };
27529
27530
27531 ShadowDOMObserver.prototype.observeShadowRoot = function(shadowRoot) {
27532 if (!this.observedShadowRoots || this.observedShadowRoots.has(shadowRoot)) {
27533 return;
27534 }
27535
27536 var self = this;
27537
27538 try {
27539 this.observedShadowRoots.add(shadowRoot);
27540
27541 var observer = new window.MutationObserver(function() {
27542 self.changeCallback();
27543 });
27544
27545 observer.observe(shadowRoot, this.observerConfig);
27546 this.shadowObservers.push(observer);
27547 } catch (e) {
27548 logger$1.critical('Error while observing shadow root', e);
27549 }
27550 };
27551
27552
27553 ShadowDOMObserver.prototype.start = function() {
27554 if (this.observedShadowRoots) {
27555 return;
27556 }
27557
27558 if (!weakSetSupported()) {
27559 logger$1.critical('Shadow DOM observation unavailable: WeakSet not supported');
27560 return;
27561 }
27562
27563 this.observedShadowRoots = new WeakSet();
27564 };
27565
27566 ShadowDOMObserver.prototype.stop = function() {
27567 if (!this.observedShadowRoots) {
27568 return;
27569 }
27570
27571 for (var i = 0; i < this.shadowObservers.length; i++) {
27572 try {
27573 this.shadowObservers[i].disconnect();
27574 } catch (e) {
27575 logger$1.critical('Error while disconnecting shadow DOM observer', e);
27576 }
27577 }
27578 this.shadowObservers = [];
27579 this.observedShadowRoots = null;
27580 };
27581
27582 /** @const */ var DEFAULT_DEAD_CLICK_TIMEOUT_MS = 500;
27583 /** @const */ var INTERACTION_EVENTS = [EV_CHANGE, EV_INPUT, EV_SUBMIT, EV_SELECT, EV_TOGGLE];
27584 /** @const */ var LAYOUT_EVENTS = [EV_SCROLLEND];
27585 /** @const */ var NAVIGATION_EVENTS = [EV_HASHCHANGE];
27586 /** @const */ var MUTATION_OBSERVER_CONFIG = {
27587 characterData: true,
27588 childList: true,
27589 subtree: true,
27590 attributes: true,
27591 attributeFilter: ['style', 'class', 'hidden', 'checked', 'selected', 'value', 'display', 'visibility']
27592 };
27593
27594
27595 function DeadClickTracker(onDeadClickCallback) {
27596 this.eventListeners = [];
27597 this.mutationObserver = null;
27598 this.shadowDOMObserver = null;
27599
27600 this.isTracking = false;
27601 this.lastChangeEventTimestamp = 0;
27602 this.pendingClicks = [];
27603 this.onDeadClickCallback = onDeadClickCallback;
27604 this.processingActive = false;
27605 this.processingTimeout = null;
27606 }
27607
27608
27609 DeadClickTracker.prototype.addClick = function(event) {
27610 var element = this.shadowDOMObserver && this.shadowDOMObserver.getEventTarget(event);
27611
27612 if (!element) {
27613 element = event['target'] || event['srcElement'];
27614 }
27615
27616 if (!element || isDefinitelyNonInteractive(element)) {
27617 return false;
27618 }
27619
27620 if (this.shadowDOMObserver) {
27621 this.shadowDOMObserver.observeFromEvent(event);
27622 }
27623 this.pendingClicks.push({
27624 element: element,
27625 event: event,
27626 timestamp: Date.now()
27627 });
27628 return true;
27629 };
27630
27631 DeadClickTracker.prototype.trackClick = function(event, config) {
27632 if (!this.isTracking) {
27633 return false;
27634 }
27635
27636 var added = this.addClick(event);
27637 if (added) {
27638 this.triggerProcessing(config);
27639 }
27640 return added;
27641 };
27642
27643 DeadClickTracker.prototype.getDeadClicks = function(config) {
27644 if (this.pendingClicks.length === 0) {
27645 return [];
27646 }
27647
27648 var timeoutMs = config['timeout_ms'];
27649 var now = Date.now();
27650 var clicksToEvaluate = this.pendingClicks.slice(); // Copy array
27651 this.pendingClicks = []; // Clear original
27652
27653 var deadClicks = [];
27654
27655 for (var i = 0; i < clicksToEvaluate.length; i++) {
27656 var click = clicksToEvaluate[i];
27657
27658 if (now - click.timestamp >= timeoutMs) {
27659 // Click has exceeded timeout, check if it's dead by looking for changes after this specific click
27660 if (!this.hasChangesAfter(click.timestamp)) {
27661 deadClicks.push(click);
27662 }
27663 } else {
27664 // Still pending - add back
27665 this.pendingClicks.push(click);
27666 }
27667 }
27668
27669 return deadClicks;
27670 };
27671
27672 DeadClickTracker.prototype.hasChangesAfter = function(timestamp) {
27673 // 100ms tolerance for race condition between when we record the click and the change event
27674 return this.lastChangeEventTimestamp >= (timestamp - 100);
27675 };
27676
27677 DeadClickTracker.prototype.recordChangeEvent = function() {
27678 this.lastChangeEventTimestamp = Date.now();
27679 };
27680
27681 DeadClickTracker.prototype.triggerProcessing = function(config) {
27682 // Prevent multiple concurrent processing chains
27683 if (this.processingActive) {
27684 return;
27685 }
27686 this.processingActive = true;
27687 this.processRecursively(config);
27688 };
27689
27690 DeadClickTracker.prototype.processRecursively = function(config) {
27691 if (!this.isTracking || !this.onDeadClickCallback) {
27692 this.processingActive = false;
27693 return;
27694 }
27695
27696 var timeoutMs = config['timeout_ms'];
27697 var self = this;
27698
27699 this.processingTimeout = setTimeout(function() {
27700 if (!self.processingActive) {
27701 return;
27702 }
27703
27704 var deadClicks = self.getDeadClicks(config);
27705
27706 for (var i = 0; i < deadClicks.length; i++) {
27707 self.onDeadClickCallback(deadClicks[i].event);
27708 }
27709
27710 if (self.pendingClicks.length > 0) {
27711 self.processRecursively(config);
27712 } else {
27713 self.processingActive = false;
27714 }
27715 }, timeoutMs);
27716 };
27717
27718 DeadClickTracker.prototype.startTracking = function() {
27719 if (this.isTracking) {
27720 return;
27721 }
27722
27723 this.isTracking = true;
27724
27725 var self = this;
27726
27727 INTERACTION_EVENTS.forEach(function(event) {
27728 var handler = function() {
27729 self.recordChangeEvent();
27730 };
27731 document.addEventListener(event, handler, { capture: true, passive: true });
27732 self.eventListeners.push({ target: document, event: event, handler: handler, options: { capture: true, passive: true } });
27733 });
27734 NAVIGATION_EVENTS.forEach(function(event) {
27735 var handler = function() {
27736 self.recordChangeEvent();
27737 };
27738 window.addEventListener(event, handler);
27739 self.eventListeners.push({ target: window, event: event, handler: handler });
27740 });
27741 LAYOUT_EVENTS.forEach(function(event) {
27742 var handler = function() {
27743 self.recordChangeEvent();
27744 };
27745 window.addEventListener(event, handler, { passive: true });
27746 self.eventListeners.push({ target: window, event: event, handler: handler, options: { passive: true } });
27747 });
27748 var selectionHandler = function() {
27749 self.recordChangeEvent();
27750 };
27751 document.addEventListener('selectionchange', selectionHandler);
27752 self.eventListeners.push({ target: document, event: 'selectionchange', handler: selectionHandler });
27753
27754 // Set up MutationObserver
27755 if (window.MutationObserver) {
27756 try {
27757 this.mutationObserver = new window.MutationObserver(function() {
27758 self.recordChangeEvent();
27759 });
27760
27761 this.mutationObserver.observe(document.body || document.documentElement, MUTATION_OBSERVER_CONFIG);
27762 } catch (e) {
27763 logger$1.critical('Error while setting up mutation observer', e);
27764 }
27765 }
27766
27767 // Set up Shadow DOM observer
27768 if (window.customElements) {
27769 try {
27770 this.shadowDOMObserver = new ShadowDOMObserver(
27771 function() {
27772 self.recordChangeEvent();
27773 },
27774 MUTATION_OBSERVER_CONFIG
27775 );
27776 this.shadowDOMObserver.start();
27777 } catch (e) {
27778 logger$1.critical('Error while setting up shadow DOM observer', e);
27779 this.shadowDOMObserver = null;
27780 }
27781 }
27782 };
27783
27784 DeadClickTracker.prototype.stopTracking = function() {
27785 if (!this.isTracking) {
27786 return;
27787 }
27788
27789 this.isTracking = false;
27790 this.pendingClicks = [];
27791 this.lastChangeEventTimestamp = 0;
27792 this.processingActive = false;
27793
27794 if (this.processingTimeout) {
27795 clearTimeout(this.processingTimeout);
27796 this.processingTimeout = null;
27797 }
27798
27799 // Remove all event listeners
27800 for (var i = 0; i < this.eventListeners.length; i++) {
27801 var listener = this.eventListeners[i];
27802 try {
27803 listener.target.removeEventListener(listener.event, listener.handler, listener.options);
27804 } catch (e) {
27805 logger$1.critical('Error while removing event listener', e);
27806 }
27807 }
27808 this.eventListeners = [];
27809
27810 if (this.mutationObserver) {
27811 try {
27812 this.mutationObserver.disconnect();
27813 } catch (e) {
27814 logger$1.critical('Error while disconnecting mutation observer', e);
27815 }
27816 this.mutationObserver = null;
27817 }
27818
27819 if (this.shadowDOMObserver) {
27820 try {
27821 this.shadowDOMObserver.stop();
27822 } catch (e) {
27823 logger$1.critical('Error while stopping shadow DOM observer', e);
27824 }
27825 this.shadowDOMObserver = null;
27826 }
27827 };
27828
27829 var AUTOCAPTURE_CONFIG_KEY = 'autocapture';
27830 var LEGACY_PAGEVIEW_CONFIG_KEY = 'track_pageview';
27831
27832 var PAGEVIEW_OPTION_FULL_URL = 'full-url';
27833 var PAGEVIEW_OPTION_URL_WITH_PATH_AND_QUERY_STRING = 'url-with-path-and-query-string';
27834 var PAGEVIEW_OPTION_URL_WITH_PATH = 'url-with-path';
27835
27836 var CONFIG_ALLOW_ELEMENT_CALLBACK = 'allow_element_callback';
27837 var CONFIG_ALLOW_SELECTORS = 'allow_selectors';
27838 var CONFIG_ALLOW_URL_REGEXES = 'allow_url_regexes';
27839 var CONFIG_BLOCK_ATTRS = 'block_attrs';
27840 var CONFIG_BLOCK_ELEMENT_CALLBACK = 'block_element_callback';
27841 var CONFIG_BLOCK_SELECTORS = 'block_selectors';
27842 var CONFIG_BLOCK_URL_REGEXES = 'block_url_regexes';
27843 var CONFIG_CAPTURE_EXTRA_ATTRS = 'capture_extra_attrs';
27844 var CONFIG_CAPTURE_TEXT_CONTENT = 'capture_text_content';
27845 var CONFIG_SCROLL_CAPTURE_ALL = 'scroll_capture_all';
27846 var CONFIG_SCROLL_CHECKPOINTS = 'scroll_depth_percent_checkpoints';
27847 var CONFIG_TRACK_CLICK = 'click';
27848 var CONFIG_TRACK_DEAD_CLICK = 'dead_click';
27849 var CONFIG_TRACK_INPUT = 'input';
27850 var CONFIG_TRACK_PAGEVIEW = 'pageview';
27851 var CONFIG_TRACK_RAGE_CLICK = 'rage_click';
27852 var CONFIG_TRACK_SCROLL = 'scroll';
27853 var CONFIG_TRACK_PAGE_LEAVE = 'page_leave';
27854 var CONFIG_TRACK_SUBMIT = 'submit';
27855
27856 var CONFIG_DEFAULTS$1 = {};
27857 CONFIG_DEFAULTS$1[CONFIG_ALLOW_SELECTORS] = [];
27858 CONFIG_DEFAULTS$1[CONFIG_ALLOW_URL_REGEXES] = [];
27859 CONFIG_DEFAULTS$1[CONFIG_BLOCK_ATTRS] = [];
27860 CONFIG_DEFAULTS$1[CONFIG_BLOCK_ELEMENT_CALLBACK] = null;
27861 CONFIG_DEFAULTS$1[CONFIG_BLOCK_SELECTORS] = [];
27862 CONFIG_DEFAULTS$1[CONFIG_BLOCK_URL_REGEXES] = [];
27863 CONFIG_DEFAULTS$1[CONFIG_CAPTURE_EXTRA_ATTRS] = [];
27864 CONFIG_DEFAULTS$1[CONFIG_CAPTURE_TEXT_CONTENT] = false;
27865 CONFIG_DEFAULTS$1[CONFIG_SCROLL_CAPTURE_ALL] = false;
27866 CONFIG_DEFAULTS$1[CONFIG_SCROLL_CHECKPOINTS] = [25, 50, 75, 100];
27867 CONFIG_DEFAULTS$1[CONFIG_TRACK_CLICK] = true;
27868 CONFIG_DEFAULTS$1[CONFIG_TRACK_DEAD_CLICK] = true;
27869 CONFIG_DEFAULTS$1[CONFIG_TRACK_INPUT] = true;
27870 CONFIG_DEFAULTS$1[CONFIG_TRACK_PAGEVIEW] = PAGEVIEW_OPTION_FULL_URL;
27871 CONFIG_DEFAULTS$1[CONFIG_TRACK_RAGE_CLICK] = true;
27872 CONFIG_DEFAULTS$1[CONFIG_TRACK_SCROLL] = true;
27873 CONFIG_DEFAULTS$1[CONFIG_TRACK_PAGE_LEAVE] = false;
27874 CONFIG_DEFAULTS$1[CONFIG_TRACK_SUBMIT] = true;
27875
27876 var DEFAULT_PROPS = {
27877 '$mp_autocapture': true
27878 };
27879
27880 var MP_EV_CLICK = '$mp_click';
27881 var MP_EV_DEAD_CLICK = '$mp_dead_click';
27882 var MP_EV_INPUT = '$mp_input_change';
27883 var MP_EV_RAGE_CLICK = '$mp_rage_click';
27884 var MP_EV_SCROLL = '$mp_scroll';
27885 var MP_EV_SUBMIT = '$mp_submit';
27886 var MP_EV_PAGE_LEAVE = '$mp_page_leave';
27887
27888 /**
27889 * Autocapture: manages automatic event tracking
27890 * @constructor
27891 */
27892 var Autocapture = function(mp) {
27893 this.mp = mp;
27894 this.maxScrollViewDepth = 0;
27895 this.hasTrackedScrollSession = false;
27896 this.previousScrollHeight = 0;
27897 };
27898
27899 Autocapture.prototype.init = function() {
27900 if (!minDOMApisSupported()) {
27901 logger$1.critical('Autocapture unavailable: missing required DOM APIs');
27902 return;
27903 }
27904 this.initPageListeners();
27905 this.initPageviewTracking();
27906 this.initClickTracking();
27907 this.initDeadClickTracking();
27908 this.initInputTracking();
27909 this.initScrollTracking();
27910 this.initSubmitTracking();
27911 this.initRageClickTracking();
27912 this.initPageLeaveTracking();
27913 };
27914
27915 Autocapture.prototype.getFullConfig = function() {
27916 var autocaptureConfig = this.mp.get_config(AUTOCAPTURE_CONFIG_KEY);
27917 if (!autocaptureConfig) {
27918 // Autocapture is completely off
27919 return {};
27920 } else if (_.isObject(autocaptureConfig)) {
27921 return _.extend({}, CONFIG_DEFAULTS$1, autocaptureConfig);
27922 } else {
27923 // Autocapture config is non-object truthy value, return default
27924 return CONFIG_DEFAULTS$1;
27925 }
27926 };
27927
27928 Autocapture.prototype.getConfig = function(key) {
27929 return this.getFullConfig()[key];
27930 };
27931
27932 Autocapture.prototype.currentUrlBlocked = function() {
27933 var i;
27934 var currentUrl = _.info.currentUrl();
27935
27936 var allowUrlRegexes = this.getConfig(CONFIG_ALLOW_URL_REGEXES) || [];
27937 if (allowUrlRegexes.length) {
27938 // we're using an allowlist, only track if current URL matches
27939 var allowed = false;
27940 for (i = 0; i < allowUrlRegexes.length; i++) {
27941 var allowRegex = allowUrlRegexes[i];
27942 try {
27943 if (currentUrl.match(allowRegex)) {
27944 allowed = true;
27945 break;
27946 }
27947 } catch (err) {
27948 logger$1.critical('Error while checking block URL regex: ' + allowRegex, err);
27949 return true;
27950 }
27951 }
27952 if (!allowed) {
27953 // wasn't allowed by any regex
27954 return true;
27955 }
27956 }
27957
27958 var blockUrlRegexes = this.getConfig(CONFIG_BLOCK_URL_REGEXES) || [];
27959 if (!blockUrlRegexes || !blockUrlRegexes.length) {
27960 return false;
27961 }
27962
27963 for (i = 0; i < blockUrlRegexes.length; i++) {
27964 try {
27965 if (currentUrl.match(blockUrlRegexes[i])) {
27966 return true;
27967 }
27968 } catch (err) {
27969 logger$1.critical('Error while checking block URL regex: ' + blockUrlRegexes[i], err);
27970 return true;
27971 }
27972 }
27973 return false;
27974 };
27975
27976 Autocapture.prototype.pageviewTrackingConfig = function() {
27977 // supports both autocapture config and old track_pageview config
27978 if (this.mp.get_config(AUTOCAPTURE_CONFIG_KEY)) {
27979 return this.getConfig(CONFIG_TRACK_PAGEVIEW);
27980 } else {
27981 return this.mp.get_config(LEGACY_PAGEVIEW_CONFIG_KEY);
27982 }
27983 };
27984
27985 // helper for event handlers
27986 Autocapture.prototype.trackDomEvent = function(ev, mpEventName) {
27987 if (this.currentUrlBlocked()) {
27988 return;
27989 }
27990
27991 var isCapturedForHeatMap = this.mp.is_recording_heatmap_data() && (
27992 (mpEventName === MP_EV_CLICK && !this.getConfig(CONFIG_TRACK_CLICK)) ||
27993 (mpEventName === MP_EV_RAGE_CLICK && !this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK)) ||
27994 (mpEventName === MP_EV_DEAD_CLICK && !this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK))
27995 );
27996
27997 var props = getPropsForDOMEvent(ev, {
27998 allowElementCallback: this.getConfig(CONFIG_ALLOW_ELEMENT_CALLBACK),
27999 allowSelectors: this.getConfig(CONFIG_ALLOW_SELECTORS),
28000 blockAttrs: this.getConfig(CONFIG_BLOCK_ATTRS),
28001 blockElementCallback: this.getConfig(CONFIG_BLOCK_ELEMENT_CALLBACK),
28002 blockSelectors: this.getConfig(CONFIG_BLOCK_SELECTORS),
28003 captureExtraAttrs: this.getConfig(CONFIG_CAPTURE_EXTRA_ATTRS),
28004 captureTextContent: this.getConfig(CONFIG_CAPTURE_TEXT_CONTENT),
28005 capturedForHeatMap: isCapturedForHeatMap,
28006 });
28007 if (props) {
28008 _.extend(props, DEFAULT_PROPS);
28009 this.mp.track(mpEventName, props);
28010 }
28011 };
28012
28013 Autocapture.prototype.initPageListeners = function() {
28014 win.removeEventListener(EV_POPSTATE, this.listenerPopstate);
28015 win.removeEventListener(EV_HASHCHANGE, this.listenerHashchange);
28016
28017 if (!this.pageviewTrackingConfig() && !this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.get_config('record_heatmap_data')) {
28018 // These are all the configs that use these listeners
28019 return;
28020 }
28021
28022 this.listenerPopstate = function() {
28023 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
28024 };
28025 this.listenerHashchange = function() {
28026 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
28027 };
28028
28029 win.addEventListener(EV_POPSTATE, this.listenerPopstate);
28030 win.addEventListener(EV_HASHCHANGE, this.listenerHashchange);
28031 var nativePushState = win.history.pushState;
28032 if (typeof nativePushState === 'function') {
28033 win.history.pushState = function(state, unused, url) {
28034 nativePushState.call(win.history, state, unused, url);
28035 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
28036 };
28037 }
28038 var nativeReplaceState = win.history.replaceState;
28039 if (typeof nativeReplaceState === 'function') {
28040 win.history.replaceState = function(state, unused, url) {
28041 nativeReplaceState.call(win.history, state, unused, url);
28042 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
28043 };
28044 }
28045 };
28046
28047 Autocapture.prototype._getClickTrackingConfig = function(configKey) {
28048 var config = this.getConfig(configKey);
28049
28050 if (!config) {
28051 return null; // click tracking disabled
28052 }
28053
28054 if (config === true) {
28055 return {}; // use defaults
28056 }
28057
28058 if (typeof config === 'object') {
28059 return config; // use custom configuration
28060 }
28061
28062 return {}; // fallback to defaults for any other truthy value
28063 };
28064
28065 Autocapture.prototype._trackPageLeave = function(ev, currentUrl, currentScrollHeight) {
28066 if (this.hasTrackedScrollSession) {
28067 // User has navigated away already ending their impression.
28068 return;
28069 }
28070
28071 if (!this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.is_recording_heatmap_data()) {
28072 return;
28073 }
28074
28075 this.hasTrackedScrollSession = true;
28076 var viewportHeight = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
28077 var scrollPercentage = Math.round(Math.max(this.maxScrollViewDepth - viewportHeight, 0) / (currentScrollHeight - viewportHeight) * 100);
28078 var foldLinePercentage = Math.round((viewportHeight / currentScrollHeight) * 100);
28079 if (currentScrollHeight <= viewportHeight) {
28080 // If the content fits within the viewport, consider it fully scrolled
28081 scrollPercentage = 100;
28082 foldLinePercentage = 100;
28083 }
28084
28085 var props = _.extend({
28086 '$max_scroll_view_depth': this.maxScrollViewDepth,
28087 '$max_scroll_percentage': scrollPercentage,
28088 '$fold_line_percentage': foldLinePercentage,
28089 '$scroll_height': currentScrollHeight,
28090 '$event_type': ev.type,
28091 '$current_url': currentUrl || _.info.currentUrl(),
28092 '$viewportHeight': viewportHeight, // This is the fold line
28093 '$viewportWidth': Math.max(document$1.documentElement.clientWidth, win.innerWidth || 0),
28094 '$captured_for_heatmap': this.mp.is_recording_heatmap_data()
28095 }, DEFAULT_PROPS);
28096
28097 // Send with beacon transport to ensure event is sent before unload
28098 this.mp.track(MP_EV_PAGE_LEAVE, props, {transport: 'sendBeacon'});
28099 };
28100
28101 Autocapture.prototype._initScrollDepthTracking = function() {
28102 win.removeEventListener(EV_SCROLL, this.listenerScrollDepth);
28103 win.removeEventListener(EV_SCROLLEND, this.listenerScrollDepth);
28104
28105 if (!this.mp.get_config('record_heatmap_data')) {
28106 return;
28107 }
28108
28109 logger$1.log('Initializing scroll depth tracking');
28110
28111 this.maxScrollViewDepth = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
28112
28113 var updateScrollDepth = function() {
28114 if (this.currentUrlBlocked()) {
28115 return;
28116 }
28117 var scrollViewHeight = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0) + win.scrollY;
28118 if (scrollViewHeight > this.maxScrollViewDepth) {
28119 this.maxScrollViewDepth = scrollViewHeight;
28120 }
28121 this.previousScrollHeight = document$1.body.scrollHeight;
28122 }.bind(this);
28123
28124 var scrollEndPolyfill = getPolyfillScrollEndFunction(updateScrollDepth);
28125 this.listenerScrollDepth = scrollEndPolyfill.listener;
28126 win.addEventListener(scrollEndPolyfill.eventType, this.listenerScrollDepth);
28127 };
28128
28129 Autocapture.prototype.initClickTracking = function() {
28130 win.removeEventListener(EV_CLICK, this.listenerClick);
28131
28132 if (!this.getConfig(CONFIG_TRACK_CLICK) && !this.mp.get_config('record_heatmap_data')) {
28133 return;
28134 }
28135 logger$1.log('Initializing click tracking');
28136
28137 this.listenerClick = function(ev) {
28138 if (!this.getConfig(CONFIG_TRACK_CLICK) && !this.mp.is_recording_heatmap_data()) {
28139 return;
28140 }
28141 this.trackDomEvent(ev, MP_EV_CLICK);
28142 }.bind(this);
28143 win.addEventListener(EV_CLICK, this.listenerClick);
28144 };
28145
28146 Autocapture.prototype.initDeadClickTracking = function() {
28147 var deadClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK);
28148
28149 if (!deadClickConfig && !this.mp.get_config('record_heatmap_data')) {
28150 this.stopDeadClickTracking();
28151 return;
28152 }
28153
28154 logger$1.log('Initializing dead click tracking');
28155 if (!this._deadClickTracker) {
28156 this._deadClickTracker = new DeadClickTracker(function(deadClickEvent) {
28157 this.trackDomEvent(deadClickEvent, MP_EV_DEAD_CLICK);
28158 }.bind(this));
28159 this._deadClickTracker.startTracking();
28160 }
28161
28162 if (!this.listenerDeadClick) {
28163 this.listenerDeadClick = function(ev) {
28164 var currentDeadClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK);
28165 if (!currentDeadClickConfig && !this.mp.is_recording_heatmap_data()) {
28166 return;
28167 }
28168 if (this.currentUrlBlocked()) {
28169 return;
28170 }
28171 // Normalize config to ensure timeout_ms is always set
28172 var normalizedConfig = currentDeadClickConfig || {};
28173 if (!normalizedConfig['timeout_ms']) {
28174 normalizedConfig['timeout_ms'] = DEFAULT_DEAD_CLICK_TIMEOUT_MS;
28175 }
28176 this._deadClickTracker.trackClick(ev, normalizedConfig);
28177 }.bind(this);
28178 win.addEventListener(EV_CLICK, this.listenerDeadClick);
28179 }
28180 };
28181
28182 Autocapture.prototype.initInputTracking = function() {
28183 win.removeEventListener(EV_CHANGE, this.listenerChange);
28184
28185 if (!this.getConfig(CONFIG_TRACK_INPUT)) {
28186 return;
28187 }
28188 logger$1.log('Initializing input tracking');
28189
28190 this.listenerChange = function(ev) {
28191 if (!this.getConfig(CONFIG_TRACK_INPUT)) {
28192 return;
28193 }
28194 this.trackDomEvent(ev, MP_EV_INPUT);
28195 }.bind(this);
28196 win.addEventListener(EV_CHANGE, this.listenerChange);
28197 };
28198
28199 Autocapture.prototype.initPageviewTracking = function() {
28200 win.removeEventListener(EV_MP_LOCATION_CHANGE, this.listenerLocationchange);
28201
28202 if (!this.pageviewTrackingConfig()) {
28203 return;
28204 }
28205 logger$1.log('Initializing pageview tracking');
28206
28207 var previousTrackedUrl = '';
28208 var tracked = false;
28209 if (!this.currentUrlBlocked()) {
28210 tracked = this.mp.track_pageview(DEFAULT_PROPS);
28211 }
28212 if (tracked) {
28213 previousTrackedUrl = _.info.currentUrl();
28214 }
28215
28216 this.listenerLocationchange = safewrap(function() {
28217 if (this.currentUrlBlocked()) {
28218 return;
28219 }
28220
28221 var currentUrl = _.info.currentUrl();
28222 var shouldTrack = false;
28223 var didPathChange = currentUrl.split('#')[0].split('?')[0] !== previousTrackedUrl.split('#')[0].split('?')[0];
28224 var trackPageviewOption = this.pageviewTrackingConfig();
28225 if (trackPageviewOption === PAGEVIEW_OPTION_FULL_URL) {
28226 shouldTrack = currentUrl !== previousTrackedUrl;
28227 } else if (trackPageviewOption === PAGEVIEW_OPTION_URL_WITH_PATH_AND_QUERY_STRING) {
28228 shouldTrack = currentUrl.split('#')[0] !== previousTrackedUrl.split('#')[0];
28229 } else if (trackPageviewOption === PAGEVIEW_OPTION_URL_WITH_PATH) {
28230 shouldTrack = didPathChange;
28231 }
28232
28233 if (shouldTrack) {
28234 var tracked = this.mp.track_pageview(DEFAULT_PROPS);
28235 if (tracked) {
28236 previousTrackedUrl = currentUrl;
28237 }
28238 if (didPathChange) {
28239 this.lastScrollCheckpoint = 0;
28240 logger$1.log('Path change: re-initializing scroll depth checkpoints');
28241 }
28242 }
28243 }.bind(this));
28244 win.addEventListener(EV_MP_LOCATION_CHANGE, this.listenerLocationchange);
28245 };
28246
28247 Autocapture.prototype.initRageClickTracking = function() {
28248 win.removeEventListener(EV_CLICK, this.listenerRageClick);
28249
28250 var rageClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK);
28251 if (!rageClickConfig && !this.mp.get_config('record_heatmap_data')) {
28252 return;
28253 }
28254
28255 logger$1.log('Initializing rage click tracking');
28256 if (!this._rageClickTracker) {
28257 this._rageClickTracker = new RageClickTracker();
28258 }
28259
28260 this.listenerRageClick = function(ev) {
28261 var currentRageClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK);
28262 if (!currentRageClickConfig && !this.mp.is_recording_heatmap_data()) {
28263 return;
28264 }
28265
28266 if (this.currentUrlBlocked()) {
28267 return;
28268 }
28269
28270 if (this._rageClickTracker.isRageClick(ev['pageX'], ev['pageY'], currentRageClickConfig)) {
28271 this.trackDomEvent(ev, MP_EV_RAGE_CLICK);
28272 }
28273 }.bind(this);
28274 win.addEventListener(EV_CLICK, this.listenerRageClick);
28275 };
28276
28277 Autocapture.prototype.initScrollTracking = function() {
28278 win.removeEventListener(EV_SCROLLEND, this.listenerScroll);
28279 win.removeEventListener(EV_SCROLL, this.listenerScroll);
28280
28281
28282 if (!this.getConfig(CONFIG_TRACK_SCROLL)) {
28283 return;
28284 }
28285 logger$1.log('Initializing scroll tracking');
28286 this.lastScrollCheckpoint = 0;
28287
28288 var scrollTrackFunction = function() {
28289 if (!this.getConfig(CONFIG_TRACK_SCROLL)) {
28290 return;
28291 }
28292 if (this.currentUrlBlocked()) {
28293 return;
28294 }
28295
28296 var shouldTrack = this.getConfig(CONFIG_SCROLL_CAPTURE_ALL);
28297 var scrollCheckpoints = (this.getConfig(CONFIG_SCROLL_CHECKPOINTS) || [])
28298 .slice()
28299 .sort(function(a, b) { return a - b; });
28300
28301 var scrollTop = win.scrollY;
28302 var props = _.extend({'$scroll_top': scrollTop}, DEFAULT_PROPS);
28303 try {
28304 var scrollHeight = document$1.body.scrollHeight;
28305 var scrollPercentage = Math.round((scrollTop / (scrollHeight - win.innerHeight)) * 100);
28306 props['$scroll_height'] = scrollHeight;
28307 props['$scroll_percentage'] = scrollPercentage;
28308 if (scrollPercentage > this.lastScrollCheckpoint) {
28309 for (var i = 0; i < scrollCheckpoints.length; i++) {
28310 var checkpoint = scrollCheckpoints[i];
28311 if (
28312 scrollPercentage >= checkpoint &&
28313 this.lastScrollCheckpoint < checkpoint
28314 ) {
28315 props['$scroll_checkpoint'] = checkpoint;
28316 this.lastScrollCheckpoint = checkpoint;
28317 shouldTrack = true;
28318 }
28319 }
28320 }
28321 } catch (err) {
28322 logger$1.critical('Error while calculating scroll percentage', err);
28323 }
28324 if (shouldTrack) {
28325 this.mp.track(MP_EV_SCROLL, props);
28326 }
28327 }.bind(this);
28328
28329 var scrollEndPolyfill = getPolyfillScrollEndFunction(scrollTrackFunction);
28330 this.listenerScroll = scrollEndPolyfill.listener;
28331 win.addEventListener(scrollEndPolyfill.eventType, this.listenerScroll);
28332 };
28333
28334 Autocapture.prototype.initSubmitTracking = function() {
28335 win.removeEventListener(EV_SUBMIT, this.listenerSubmit);
28336
28337 if (!this.getConfig(CONFIG_TRACK_SUBMIT)) {
28338 return;
28339 }
28340 logger$1.log('Initializing submit tracking');
28341
28342 this.listenerSubmit = function(ev) {
28343 if (!this.getConfig(CONFIG_TRACK_SUBMIT)) {
28344 return;
28345 }
28346 this.trackDomEvent(ev, MP_EV_SUBMIT);
28347 }.bind(this);
28348 win.addEventListener(EV_SUBMIT, this.listenerSubmit);
28349 };
28350
28351 Autocapture.prototype.initPageLeaveTracking = function() {
28352 // Capture page_leave both when the user navigates away from the page (visibilitychange) as well
28353 // as when they navigate to a different page within the SPA (popstate/pushstate/hashchange).
28354 document$1.removeEventListener(EV_VISIBILITYCHANGE, this.listenerPageLeaveVisibilitychange);
28355 win.removeEventListener(EV_MP_LOCATION_CHANGE, this.listenerPageLeaveLocationchange);
28356 win.removeEventListener(EV_LOAD, this.listenerPageLoad);
28357
28358 if (!this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.get_config('record_heatmap_data')) {
28359 return;
28360 }
28361
28362 logger$1.log('Initializing page visibility tracking.');
28363 this._initScrollDepthTracking();
28364 var previousTrackedUrl = _.info.currentUrl();
28365
28366 // Initialize previousScrollHeight on `load` which handles async loading
28367 // https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event
28368 this.listenerPageLoad = function() {
28369 this.previousScrollHeight = document$1.body.scrollHeight;
28370 }.bind(this);
28371 win.addEventListener(EV_LOAD, this.listenerPageLoad);
28372
28373 // Track page navigation events similar to how initPageviewTracking does it
28374 this.listenerPageLeaveLocationchange = safewrap(function(ev) {
28375 if (this.currentUrlBlocked()) {
28376 return;
28377 }
28378
28379 var currentUrl = _.info.currentUrl();
28380 // Track all URL changes including query string or fragment changes as separate scroll sessions
28381 var shouldTrack = currentUrl !== previousTrackedUrl;
28382
28383 if (shouldTrack) {
28384 this._trackPageLeave(ev, previousTrackedUrl, this.previousScrollHeight);
28385 previousTrackedUrl = currentUrl;
28386 // Fragment navigation should call scroll(end) and trigger listener, don't add window.scrollY here.
28387 this.maxScrollViewDepth = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
28388 this.previousScrollHeight = document$1.body.scrollHeight;
28389 this.hasTrackedScrollSession = false;
28390 }
28391 }.bind(this));
28392 win.addEventListener(EV_MP_LOCATION_CHANGE, this.listenerPageLeaveLocationchange);
28393
28394 this.listenerPageLeaveVisibilitychange = function(ev) {
28395 if (document$1.hidden) {
28396 this._trackPageLeave(ev, previousTrackedUrl, this.previousScrollHeight);
28397 }
28398 }.bind(this);
28399 document$1.addEventListener(EV_VISIBILITYCHANGE, this.listenerPageLeaveVisibilitychange);
28400 };
28401
28402 Autocapture.prototype.stopDeadClickTracking = function() {
28403 if (this.listenerDeadClick) {
28404 win.removeEventListener(EV_CLICK, this.listenerDeadClick);
28405 this.listenerDeadClick = null;
28406 }
28407
28408 if (this._deadClickTracker) {
28409 this._deadClickTracker.stopTracking();
28410 this._deadClickTracker = null;
28411 }
28412 };
28413
28414 // TODO integrate error_reporter from mixpanel instance
28415 safewrapClass(Autocapture);
28416
28417 var logger = console_with_prefix('flags');
28418
28419 var FLAGS_CONFIG_KEY = 'flags';
28420
28421 var CONFIG_CONTEXT = 'context';
28422 var CONFIG_DEFAULTS = {};
28423 CONFIG_DEFAULTS[CONFIG_CONTEXT] = {};
28424
28425 /**
28426 * FeatureFlagManager: support for Mixpanel's feature flagging product
28427 * @constructor
28428 */
28429 var FeatureFlagManager = function(initOptions) {
28430 this.fetch = win['fetch'];
28431 this.getFullApiRoute = initOptions.getFullApiRoute;
28432 this.getMpConfig = initOptions.getConfigFunc;
28433 this.setMpConfig = initOptions.setConfigFunc;
28434 this.getMpProperty = initOptions.getPropertyFunc;
28435 this.track = initOptions.trackingFunc;
28436 };
28437
28438 FeatureFlagManager.prototype.init = function() {
28439 if (!this.minApisSupported()) {
28440 logger.critical('Feature Flags unavailable: missing minimum required APIs');
28441 return;
28442 }
28443
28444 this.flags = null;
28445 this.fetchFlags();
28446
28447 this.trackedFeatures = new Set();
28448 };
28449
28450 FeatureFlagManager.prototype.getFullConfig = function() {
28451 var ffConfig = this.getMpConfig(FLAGS_CONFIG_KEY);
28452 if (!ffConfig) {
28453 // flags are completely off
28454 return {};
28455 } else if (_.isObject(ffConfig)) {
28456 return _.extend({}, CONFIG_DEFAULTS, ffConfig);
28457 } else {
28458 // config is non-object truthy value, return default
28459 return CONFIG_DEFAULTS;
28460 }
28461 };
28462
28463 FeatureFlagManager.prototype.getConfig = function(key) {
28464 return this.getFullConfig()[key];
28465 };
28466
28467 FeatureFlagManager.prototype.isSystemEnabled = function() {
28468 return !!this.getMpConfig(FLAGS_CONFIG_KEY);
28469 };
28470
28471 FeatureFlagManager.prototype.updateContext = function(newContext, options) {
28472 if (!this.isSystemEnabled()) {
28473 logger.critical('Feature Flags not enabled, cannot update context');
28474 return Promise.resolve();
28475 }
28476
28477 var ffConfig = this.getMpConfig(FLAGS_CONFIG_KEY);
28478 if (!_.isObject(ffConfig)) {
28479 ffConfig = {};
28480 }
28481 var oldContext = (options && options['replace']) ? {} : this.getConfig(CONFIG_CONTEXT);
28482 ffConfig[CONFIG_CONTEXT] = _.extend({}, oldContext, newContext);
28483
28484 this.setMpConfig(FLAGS_CONFIG_KEY, ffConfig);
28485 return this.fetchFlags();
28486 };
28487
28488 FeatureFlagManager.prototype.areFlagsReady = function() {
28489 if (!this.isSystemEnabled()) {
28490 logger.error('Feature Flags not enabled');
28491 }
28492 return !!this.flags;
28493 };
28494
28495 FeatureFlagManager.prototype.fetchFlags = function() {
28496 if (!this.isSystemEnabled()) {
28497 return Promise.resolve();
28498 }
28499
28500 var distinctId = this.getMpProperty('distinct_id');
28501 var deviceId = this.getMpProperty('$device_id');
28502 var traceparent = generateTraceparent();
28503 logger.log('Fetching flags for distinct ID: ' + distinctId);
28504
28505 var context = _.extend({'distinct_id': distinctId, 'device_id': deviceId}, this.getConfig(CONFIG_CONTEXT));
28506 var searchParams = new URLSearchParams();
28507 searchParams.set('context', JSON.stringify(context));
28508 searchParams.set('token', this.getMpConfig('token'));
28509 searchParams.set('mp_lib', 'web');
28510 searchParams.set('$lib_version', Config.LIB_VERSION);
28511 var url = this.getFullApiRoute() + '?' + searchParams.toString();
28512
28513 this._fetchInProgressStartTime = Date.now();
28514 this.fetchPromise = this.fetch.call(win, url, {
28515 'method': 'GET',
28516 'headers': {
28517 'Authorization': 'Basic ' + btoa(this.getMpConfig('token') + ':'),
28518 'traceparent': traceparent
28519 }
28520 }).then(function(response) {
28521 this.markFetchComplete();
28522 return response.json().then(function(responseBody) {
28523 var responseFlags = responseBody['flags'];
28524 if (!responseFlags) {
28525 throw new Error('No flags in API response');
28526 }
28527 var flags = new Map();
28528 _.each(responseFlags, function(data, key) {
28529 flags.set(key, {
28530 'key': data['variant_key'],
28531 'value': data['variant_value'],
28532 'experiment_id': data['experiment_id'],
28533 'is_experiment_active': data['is_experiment_active'],
28534 'is_qa_tester': data['is_qa_tester']
28535 });
28536 });
28537 this.flags = flags;
28538 this._traceparent = traceparent;
28539 }.bind(this)).catch(function(error) {
28540 this.markFetchComplete();
28541 logger.error(error);
28542 }.bind(this));
28543 }.bind(this)).catch(function(error) {
28544 this.markFetchComplete();
28545 logger.error(error);
28546 }.bind(this));
28547
28548 return this.fetchPromise;
28549 };
28550
28551 FeatureFlagManager.prototype.markFetchComplete = function() {
28552 if (!this._fetchInProgressStartTime) {
28553 logger.error('Fetch in progress started time not set, cannot mark fetch complete');
28554 return;
28555 }
28556 this._fetchStartTime = this._fetchInProgressStartTime;
28557 this._fetchCompleteTime = Date.now();
28558 this._fetchLatency = this._fetchCompleteTime - this._fetchStartTime;
28559 this._fetchInProgressStartTime = null;
28560 };
28561
28562 FeatureFlagManager.prototype.getVariant = function(featureName, fallback) {
28563 if (!this.fetchPromise) {
28564 return new Promise(function(resolve) {
28565 logger.critical('Feature Flags not initialized');
28566 resolve(fallback);
28567 });
28568 }
28569
28570 return this.fetchPromise.then(function() {
28571 return this.getVariantSync(featureName, fallback);
28572 }.bind(this)).catch(function(error) {
28573 logger.error(error);
28574 return fallback;
28575 });
28576 };
28577
28578 FeatureFlagManager.prototype.getVariantSync = function(featureName, fallback) {
28579 if (!this.areFlagsReady()) {
28580 logger.log('Flags not loaded yet');
28581 return fallback;
28582 }
28583 var feature = this.flags.get(featureName);
28584 if (!feature) {
28585 logger.log('No flag found: "' + featureName + '"');
28586 return fallback;
28587 }
28588 this.trackFeatureCheck(featureName, feature);
28589 return feature;
28590 };
28591
28592 FeatureFlagManager.prototype.getVariantValue = function(featureName, fallbackValue) {
28593 return this.getVariant(featureName, {'value': fallbackValue}).then(function(feature) {
28594 return feature['value'];
28595 }).catch(function(error) {
28596 logger.error(error);
28597 return fallbackValue;
28598 });
28599 };
28600
28601 // TODO remove deprecated method
28602 FeatureFlagManager.prototype.getFeatureData = function(featureName, fallbackValue) {
28603 logger.critical('mixpanel.flags.get_feature_data() is deprecated and will be removed in a future release. Use mixpanel.flags.get_variant_value() instead.');
28604 return this.getVariantValue(featureName, fallbackValue);
28605 };
28606
28607 FeatureFlagManager.prototype.getVariantValueSync = function(featureName, fallbackValue) {
28608 return this.getVariantSync(featureName, {'value': fallbackValue})['value'];
28609 };
28610
28611 FeatureFlagManager.prototype.isEnabled = function(featureName, fallbackValue) {
28612 return this.getVariantValue(featureName).then(function() {
28613 return this.isEnabledSync(featureName, fallbackValue);
28614 }.bind(this)).catch(function(error) {
28615 logger.error(error);
28616 return fallbackValue;
28617 });
28618 };
28619
28620 FeatureFlagManager.prototype.isEnabledSync = function(featureName, fallbackValue) {
28621 fallbackValue = fallbackValue || false;
28622 var val = this.getVariantValueSync(featureName, fallbackValue);
28623 if (val !== true && val !== false) {
28624 logger.error('Feature flag "' + featureName + '" value: ' + val + ' is not a boolean; returning fallback value: ' + fallbackValue);
28625 val = fallbackValue;
28626 }
28627 return val;
28628 };
28629
28630 FeatureFlagManager.prototype.trackFeatureCheck = function(featureName, feature) {
28631 if (this.trackedFeatures.has(featureName)) {
28632 return;
28633 }
28634 this.trackedFeatures.add(featureName);
28635
28636 var trackingProperties = {
28637 'Experiment name': featureName,
28638 'Variant name': feature['key'],
28639 '$experiment_type': 'feature_flag',
28640 'Variant fetch start time': new Date(this._fetchStartTime).toISOString(),
28641 'Variant fetch complete time': new Date(this._fetchCompleteTime).toISOString(),
28642 'Variant fetch latency (ms)': this._fetchLatency,
28643 'Variant fetch traceparent': this._traceparent,
28644 };
28645
28646 if (feature['experiment_id'] !== 'undefined') {
28647 trackingProperties['$experiment_id'] = feature['experiment_id'];
28648 }
28649 if (feature['is_experiment_active'] !== 'undefined') {
28650 trackingProperties['$is_experiment_active'] = feature['is_experiment_active'];
28651 }
28652 if (feature['is_qa_tester'] !== 'undefined') {
28653 trackingProperties['$is_qa_tester'] = feature['is_qa_tester'];
28654 }
28655
28656 this.track('$experiment_started', trackingProperties);
28657 };
28658
28659 FeatureFlagManager.prototype.minApisSupported = function() {
28660 return !!this.fetch &&
28661 typeof Promise !== 'undefined' &&
28662 typeof Map !== 'undefined' &&
28663 typeof Set !== 'undefined';
28664 };
28665
28666 safewrapClass(FeatureFlagManager);
28667
28668 FeatureFlagManager.prototype['are_flags_ready'] = FeatureFlagManager.prototype.areFlagsReady;
28669 FeatureFlagManager.prototype['get_variant'] = FeatureFlagManager.prototype.getVariant;
28670 FeatureFlagManager.prototype['get_variant_sync'] = FeatureFlagManager.prototype.getVariantSync;
28671 FeatureFlagManager.prototype['get_variant_value'] = FeatureFlagManager.prototype.getVariantValue;
28672 FeatureFlagManager.prototype['get_variant_value_sync'] = FeatureFlagManager.prototype.getVariantValueSync;
28673 FeatureFlagManager.prototype['is_enabled'] = FeatureFlagManager.prototype.isEnabled;
28674 FeatureFlagManager.prototype['is_enabled_sync'] = FeatureFlagManager.prototype.isEnabledSync;
28675 FeatureFlagManager.prototype['update_context'] = FeatureFlagManager.prototype.updateContext;
28676
28677 // Deprecated method
28678 FeatureFlagManager.prototype['get_feature_data'] = FeatureFlagManager.prototype.getFeatureData;
28679
28680 /* eslint camelcase: "off" */
28681
28682
28683 /**
28684 * DomTracker Object
28685 * @constructor
28686 */
28687 var DomTracker = function() {};
28688
28689
28690 // interface
28691 DomTracker.prototype.create_properties = function() {};
28692 DomTracker.prototype.event_handler = function() {};
28693 DomTracker.prototype.after_track_handler = function() {};
28694
28695 DomTracker.prototype.init = function(mixpanel_instance) {
28696 this.mp = mixpanel_instance;
28697 return this;
28698 };
28699
28700 /**
28701 * @param {Object|string} query
28702 * @param {string} event_name
28703 * @param {Object=} properties
28704 * @param {function=} user_callback
28705 */
28706 DomTracker.prototype.track = function(query, event_name, properties, user_callback) {
28707 var that = this;
28708 var elements = _.dom_query(query);
28709
28710 if (elements.length === 0) {
28711 console$1.error('The DOM query (' + query + ') returned 0 elements');
28712 return;
28713 }
28714
28715 _.each(elements, function(element) {
28716 _.register_event(element, this.override_event, function(e) {
28717 var options = {};
28718 var props = that.create_properties(properties, this);
28719 var timeout = that.mp.get_config('track_links_timeout');
28720
28721 that.event_handler(e, this, options);
28722
28723 // in case the mixpanel servers don't get back to us in time
28724 window.setTimeout(that.track_callback(user_callback, props, options, true), timeout);
28725
28726 // fire the tracking event
28727 that.mp.track(event_name, props, that.track_callback(user_callback, props, options));
28728 });
28729 }, this);
28730
28731 return true;
28732 };
28733
28734 /**
28735 * @param {function} user_callback
28736 * @param {Object} props
28737 * @param {boolean=} timeout_occured
28738 */
28739 DomTracker.prototype.track_callback = function(user_callback, props, options, timeout_occured) {
28740 timeout_occured = timeout_occured || false;
28741 var that = this;
28742
28743 return function() {
28744 // options is referenced from both callbacks, so we can have
28745 // a 'lock' of sorts to ensure only one fires
28746 if (options.callback_fired) { return; }
28747 options.callback_fired = true;
28748
28749 if (user_callback && user_callback(timeout_occured, props) === false) {
28750 // user can prevent the default functionality by
28751 // returning false from their callback
28752 return;
28753 }
28754
28755 that.after_track_handler(props, options, timeout_occured);
28756 };
28757 };
28758
28759 DomTracker.prototype.create_properties = function(properties, element) {
28760 var props;
28761
28762 if (typeof(properties) === 'function') {
28763 props = properties(element);
28764 } else {
28765 props = _.extend({}, properties);
28766 }
28767
28768 return props;
28769 };
28770
28771 /**
28772 * LinkTracker Object
28773 * @constructor
28774 * @extends DomTracker
28775 */
28776 var LinkTracker = function() {
28777 this.override_event = 'click';
28778 };
28779 _.inherit(LinkTracker, DomTracker);
28780
28781 LinkTracker.prototype.create_properties = function(properties, element) {
28782 var props = LinkTracker.superclass.create_properties.apply(this, arguments);
28783
28784 if (element.href) { props['url'] = element.href; }
28785
28786 return props;
28787 };
28788
28789 LinkTracker.prototype.event_handler = function(evt, element, options) {
28790 options.new_tab = (
28791 evt.which === 2 ||
28792 evt.metaKey ||
28793 evt.ctrlKey ||
28794 element.target === '_blank'
28795 );
28796 options.href = element.href;
28797
28798 if (!options.new_tab) {
28799 evt.preventDefault();
28800 }
28801 };
28802
28803 LinkTracker.prototype.after_track_handler = function(props, options) {
28804 if (options.new_tab) { return; }
28805
28806 setTimeout(function() {
28807 window.location = options.href;
28808 }, 0);
28809 };
28810
28811 /**
28812 * FormTracker Object
28813 * @constructor
28814 * @extends DomTracker
28815 */
28816 var FormTracker = function() {
28817 this.override_event = 'submit';
28818 };
28819 _.inherit(FormTracker, DomTracker);
28820
28821 FormTracker.prototype.event_handler = function(evt, element, options) {
28822 options.element = element;
28823 evt.preventDefault();
28824 };
28825
28826 FormTracker.prototype.after_track_handler = function(props, options) {
28827 setTimeout(function() {
28828 options.element.submit();
28829 }, 0);
28830 };
28831
28832 /* eslint camelcase: "off" */
28833
28834
28835 /** @const */ var SET_ACTION = '$set';
28836 /** @const */ var SET_ONCE_ACTION = '$set_once';
28837 /** @const */ var UNSET_ACTION = '$unset';
28838 /** @const */ var ADD_ACTION = '$add';
28839 /** @const */ var APPEND_ACTION = '$append';
28840 /** @const */ var UNION_ACTION = '$union';
28841 /** @const */ var REMOVE_ACTION = '$remove';
28842 /** @const */ var DELETE_ACTION = '$delete';
28843
28844 // Common internal methods for mixpanel.people and mixpanel.group APIs.
28845 // These methods shouldn't involve network I/O.
28846 var apiActions = {
28847 set_action: function(prop, to) {
28848 var data = {};
28849 var $set = {};
28850 if (_.isObject(prop)) {
28851 _.each(prop, function(v, k) {
28852 if (!this._is_reserved_property(k)) {
28853 $set[k] = v;
28854 }
28855 }, this);
28856 } else {
28857 $set[prop] = to;
28858 }
28859
28860 data[SET_ACTION] = $set;
28861 return data;
28862 },
28863
28864 unset_action: function(prop) {
28865 var data = {};
28866 var $unset = [];
28867 if (!_.isArray(prop)) {
28868 prop = [prop];
28869 }
28870
28871 _.each(prop, function(k) {
28872 if (!this._is_reserved_property(k)) {
28873 $unset.push(k);
28874 }
28875 }, this);
28876
28877 data[UNSET_ACTION] = $unset;
28878 return data;
28879 },
28880
28881 set_once_action: function(prop, to) {
28882 var data = {};
28883 var $set_once = {};
28884 if (_.isObject(prop)) {
28885 _.each(prop, function(v, k) {
28886 if (!this._is_reserved_property(k)) {
28887 $set_once[k] = v;
28888 }
28889 }, this);
28890 } else {
28891 $set_once[prop] = to;
28892 }
28893 data[SET_ONCE_ACTION] = $set_once;
28894 return data;
28895 },
28896
28897 union_action: function(list_name, values) {
28898 var data = {};
28899 var $union = {};
28900 if (_.isObject(list_name)) {
28901 _.each(list_name, function(v, k) {
28902 if (!this._is_reserved_property(k)) {
28903 $union[k] = _.isArray(v) ? v : [v];
28904 }
28905 }, this);
28906 } else {
28907 $union[list_name] = _.isArray(values) ? values : [values];
28908 }
28909 data[UNION_ACTION] = $union;
28910 return data;
28911 },
28912
28913 append_action: function(list_name, value) {
28914 var data = {};
28915 var $append = {};
28916 if (_.isObject(list_name)) {
28917 _.each(list_name, function(v, k) {
28918 if (!this._is_reserved_property(k)) {
28919 $append[k] = v;
28920 }
28921 }, this);
28922 } else {
28923 $append[list_name] = value;
28924 }
28925 data[APPEND_ACTION] = $append;
28926 return data;
28927 },
28928
28929 remove_action: function(list_name, value) {
28930 var data = {};
28931 var $remove = {};
28932 if (_.isObject(list_name)) {
28933 _.each(list_name, function(v, k) {
28934 if (!this._is_reserved_property(k)) {
28935 $remove[k] = v;
28936 }
28937 }, this);
28938 } else {
28939 $remove[list_name] = value;
28940 }
28941 data[REMOVE_ACTION] = $remove;
28942 return data;
28943 },
28944
28945 delete_action: function() {
28946 var data = {};
28947 data[DELETE_ACTION] = '';
28948 return data;
28949 }
28950 };
28951
28952 /* eslint camelcase: "off" */
28953
28954 /**
28955 * Mixpanel Group Object
28956 * @constructor
28957 */
28958 var MixpanelGroup = function() {};
28959
28960 _.extend(MixpanelGroup.prototype, apiActions);
28961
28962 MixpanelGroup.prototype._init = function(mixpanel_instance, group_key, group_id) {
28963 this._mixpanel = mixpanel_instance;
28964 this._group_key = group_key;
28965 this._group_id = group_id;
28966 };
28967
28968 /**
28969 * Set properties on a group.
28970 *
28971 * ### Usage:
28972 *
28973 * mixpanel.get_group('company', 'mixpanel').set('Location', '405 Howard');
28974 *
28975 * // or set multiple properties at once
28976 * mixpanel.get_group('company', 'mixpanel').set({
28977 * 'Location': '405 Howard',
28978 * 'Founded' : 2009,
28979 * });
28980 * // properties can be strings, integers, dates, or lists
28981 *
28982 * @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.
28983 * @param {*} [to] A value to set on the given property name
28984 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28985 */
28986 MixpanelGroup.prototype.set = addOptOutCheckMixpanelGroup(function(prop, to, callback) {
28987 var data = this.set_action(prop, to);
28988 if (_.isObject(prop)) {
28989 callback = to;
28990 }
28991 return this._send_request(data, callback);
28992 });
28993
28994 /**
28995 * Set properties on a group, only if they do not yet exist.
28996 * This will not overwrite previous group property values, unlike
28997 * group.set().
28998 *
28999 * ### Usage:
29000 *
29001 * mixpanel.get_group('company', 'mixpanel').set_once('Location', '405 Howard');
29002 *
29003 * // or set multiple properties at once
29004 * mixpanel.get_group('company', 'mixpanel').set_once({
29005 * 'Location': '405 Howard',
29006 * 'Founded' : 2009,
29007 * });
29008 * // properties can be strings, integers, lists or dates
29009 *
29010 * @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.
29011 * @param {*} [to] A value to set on the given property name
29012 * @param {Function} [callback] If provided, the callback will be called after the tracking event
29013 */
29014 MixpanelGroup.prototype.set_once = addOptOutCheckMixpanelGroup(function(prop, to, callback) {
29015 var data = this.set_once_action(prop, to);
29016 if (_.isObject(prop)) {
29017 callback = to;
29018 }
29019 return this._send_request(data, callback);
29020 });
29021
29022 /**
29023 * Unset properties on a group permanently.
29024 *
29025 * ### Usage:
29026 *
29027 * mixpanel.get_group('company', 'mixpanel').unset('Founded');
29028 *
29029 * @param {String} prop The name of the property.
29030 * @param {Function} [callback] If provided, the callback will be called after the tracking event
29031 */
29032 MixpanelGroup.prototype.unset = addOptOutCheckMixpanelGroup(function(prop, callback) {
29033 var data = this.unset_action(prop);
29034 return this._send_request(data, callback);
29035 });
29036
29037 /**
29038 * Merge a given list with a list-valued group property, excluding duplicate values.
29039 *
29040 * ### Usage:
29041 *
29042 * // merge a value to a list, creating it if needed
29043 * mixpanel.get_group('company', 'mixpanel').union('Location', ['San Francisco', 'London']);
29044 *
29045 * @param {String} list_name Name of the property.
29046 * @param {Array} values Values to merge with the given property
29047 * @param {Function} [callback] If provided, the callback will be called after the tracking event
29048 */
29049 MixpanelGroup.prototype.union = addOptOutCheckMixpanelGroup(function(list_name, values, callback) {
29050 if (_.isObject(list_name)) {
29051 callback = values;
29052 }
29053 var data = this.union_action(list_name, values);
29054 return this._send_request(data, callback);
29055 });
29056
29057 /**
29058 * Permanently delete a group.
29059 *
29060 * ### Usage:
29061 *
29062 * mixpanel.get_group('company', 'mixpanel').delete();
29063 *
29064 * @param {Function} [callback] If provided, the callback will be called after the tracking event
29065 */
29066 MixpanelGroup.prototype['delete'] = addOptOutCheckMixpanelGroup(function(callback) {
29067 // bracket notation above prevents a minification error related to reserved words
29068 var data = this.delete_action();
29069 return this._send_request(data, callback);
29070 });
29071
29072 /**
29073 * Remove a property from a group. The value will be ignored if doesn't exist.
29074 *
29075 * ### Usage:
29076 *
29077 * mixpanel.get_group('company', 'mixpanel').remove('Location', 'London');
29078 *
29079 * @param {String} list_name Name of the property.
29080 * @param {Object} value Value to remove from the given group property
29081 * @param {Function} [callback] If provided, the callback will be called after the tracking event
29082 */
29083 MixpanelGroup.prototype.remove = addOptOutCheckMixpanelGroup(function(list_name, value, callback) {
29084 var data = this.remove_action(list_name, value);
29085 return this._send_request(data, callback);
29086 });
29087
29088 MixpanelGroup.prototype._send_request = function(data, callback) {
29089 data['$group_key'] = this._group_key;
29090 data['$group_id'] = this._group_id;
29091 data['$token'] = this._get_config('token');
29092
29093 var date_encoded_data = _.encodeDates(data);
29094 return this._mixpanel._track_or_batch({
29095 type: 'groups',
29096 data: date_encoded_data,
29097 endpoint: this._mixpanel.get_api_host('groups') + '/' + this._get_config('api_routes')['groups'],
29098 batcher: this._mixpanel.request_batchers.groups
29099 }, callback);
29100 };
29101
29102 MixpanelGroup.prototype._is_reserved_property = function(prop) {
29103 return prop === '$group_key' || prop === '$group_id';
29104 };
29105
29106 MixpanelGroup.prototype._get_config = function(conf) {
29107 return this._mixpanel.get_config(conf);
29108 };
29109
29110 MixpanelGroup.prototype.toString = function() {
29111 return this._mixpanel.toString() + '.group.' + this._group_key + '.' + this._group_id;
29112 };
29113
29114 // MixpanelGroup Exports
29115 MixpanelGroup.prototype['remove'] = MixpanelGroup.prototype.remove;
29116 MixpanelGroup.prototype['set'] = MixpanelGroup.prototype.set;
29117 MixpanelGroup.prototype['set_once'] = MixpanelGroup.prototype.set_once;
29118 MixpanelGroup.prototype['union'] = MixpanelGroup.prototype.union;
29119 MixpanelGroup.prototype['unset'] = MixpanelGroup.prototype.unset;
29120 MixpanelGroup.prototype['toString'] = MixpanelGroup.prototype.toString;
29121
29122 /* eslint camelcase: "off" */
29123
29124 /**
29125 * Mixpanel People Object
29126 * @constructor
29127 */
29128 var MixpanelPeople = function() {};
29129
29130 _.extend(MixpanelPeople.prototype, apiActions);
29131
29132 MixpanelPeople.prototype._init = function(mixpanel_instance) {
29133 this._mixpanel = mixpanel_instance;
29134 };
29135
29136 /*
29137 * Set properties on a user record.
29138 *
29139 * ### Usage:
29140 *
29141 * mixpanel.people.set('gender', 'm');
29142 *
29143 * // or set multiple properties at once
29144 * mixpanel.people.set({
29145 * 'Company': 'Acme',
29146 * 'Plan': 'Premium',
29147 * 'Upgrade date': new Date()
29148 * });
29149 * // properties can be strings, integers, dates, or lists
29150 *
29151 * @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.
29152 * @param {*} [to] A value to set on the given property name
29153 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29154 */
29155 MixpanelPeople.prototype.set = addOptOutCheckMixpanelPeople(function(prop, to, callback) {
29156 var data = this.set_action(prop, to);
29157 if (_.isObject(prop)) {
29158 callback = to;
29159 }
29160 // make sure that the referrer info has been updated and saved
29161 if (this._get_config('save_referrer')) {
29162 this._mixpanel['persistence'].update_referrer_info(document.referrer);
29163 }
29164
29165 // update $set object with default people properties
29166 data[SET_ACTION] = _.extend(
29167 {},
29168 _.info.people_properties(),
29169 data[SET_ACTION]
29170 );
29171 return this._send_request(data, callback);
29172 });
29173
29174 /*
29175 * Set properties on a user record, only if they do not yet exist.
29176 * This will not overwrite previous people property values, unlike
29177 * people.set().
29178 *
29179 * ### Usage:
29180 *
29181 * mixpanel.people.set_once('First Login Date', new Date());
29182 *
29183 * // or set multiple properties at once
29184 * mixpanel.people.set_once({
29185 * 'First Login Date': new Date(),
29186 * 'Starting Plan': 'Premium'
29187 * });
29188 *
29189 * // properties can be strings, integers or dates
29190 *
29191 * @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.
29192 * @param {*} [to] A value to set on the given property name
29193 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29194 */
29195 MixpanelPeople.prototype.set_once = addOptOutCheckMixpanelPeople(function(prop, to, callback) {
29196 var data = this.set_once_action(prop, to);
29197 if (_.isObject(prop)) {
29198 callback = to;
29199 }
29200 return this._send_request(data, callback);
29201 });
29202
29203 /*
29204 * Unset properties on a user record (permanently removes the properties and their values from a profile).
29205 *
29206 * ### Usage:
29207 *
29208 * mixpanel.people.unset('gender');
29209 *
29210 * // or unset multiple properties at once
29211 * mixpanel.people.unset(['gender', 'Company']);
29212 *
29213 * @param {Array|String} prop If a string, this is the name of the property. If an array, this is a list of property names.
29214 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29215 */
29216 MixpanelPeople.prototype.unset = addOptOutCheckMixpanelPeople(function(prop, callback) {
29217 var data = this.unset_action(prop);
29218 return this._send_request(data, callback);
29219 });
29220
29221 /*
29222 * Increment/decrement numeric people analytics properties.
29223 *
29224 * ### Usage:
29225 *
29226 * mixpanel.people.increment('page_views', 1);
29227 *
29228 * // or, for convenience, if you're just incrementing a counter by
29229 * // 1, you can simply do
29230 * mixpanel.people.increment('page_views');
29231 *
29232 * // to decrement a counter, pass a negative number
29233 * mixpanel.people.increment('credits_left', -1);
29234 *
29235 * // like mixpanel.people.set(), you can increment multiple
29236 * // properties at once:
29237 * mixpanel.people.increment({
29238 * counter1: 1,
29239 * counter2: 6
29240 * });
29241 *
29242 * @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.
29243 * @param {Number} [by] An amount to increment the given property
29244 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29245 */
29246 MixpanelPeople.prototype.increment = addOptOutCheckMixpanelPeople(function(prop, by, callback) {
29247 var data = {};
29248 var $add = {};
29249 if (_.isObject(prop)) {
29250 _.each(prop, function(v, k) {
29251 if (!this._is_reserved_property(k)) {
29252 if (isNaN(parseFloat(v))) {
29253 console$1.error('Invalid increment value passed to mixpanel.people.increment - must be a number');
29254 return;
29255 } else {
29256 $add[k] = v;
29257 }
29258 }
29259 }, this);
29260 callback = by;
29261 } else {
29262 // convenience: mixpanel.people.increment('property'); will
29263 // increment 'property' by 1
29264 if (_.isUndefined(by)) {
29265 by = 1;
29266 }
29267 $add[prop] = by;
29268 }
29269 data[ADD_ACTION] = $add;
29270
29271 return this._send_request(data, callback);
29272 });
29273
29274 /*
29275 * Append a value to a list-valued people analytics property.
29276 *
29277 * ### Usage:
29278 *
29279 * // append a value to a list, creating it if needed
29280 * mixpanel.people.append('pages_visited', 'homepage');
29281 *
29282 * // like mixpanel.people.set(), you can append multiple
29283 * // properties at once:
29284 * mixpanel.people.append({
29285 * list1: 'bob',
29286 * list2: 123
29287 * });
29288 *
29289 * @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.
29290 * @param {*} [value] value An item to append to the list
29291 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29292 */
29293 MixpanelPeople.prototype.append = addOptOutCheckMixpanelPeople(function(list_name, value, callback) {
29294 if (_.isObject(list_name)) {
29295 callback = value;
29296 }
29297 var data = this.append_action(list_name, value);
29298 return this._send_request(data, callback);
29299 });
29300
29301 /*
29302 * Remove a value from a list-valued people analytics property.
29303 *
29304 * ### Usage:
29305 *
29306 * mixpanel.people.remove('School', 'UCB');
29307 *
29308 * @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.
29309 * @param {*} [value] value Item to remove from the list
29310 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29311 */
29312 MixpanelPeople.prototype.remove = addOptOutCheckMixpanelPeople(function(list_name, value, callback) {
29313 if (_.isObject(list_name)) {
29314 callback = value;
29315 }
29316 var data = this.remove_action(list_name, value);
29317 return this._send_request(data, callback);
29318 });
29319
29320 /*
29321 * Merge a given list with a list-valued people analytics property,
29322 * excluding duplicate values.
29323 *
29324 * ### Usage:
29325 *
29326 * // merge a value to a list, creating it if needed
29327 * mixpanel.people.union('pages_visited', 'homepage');
29328 *
29329 * // like mixpanel.people.set(), you can append multiple
29330 * // properties at once:
29331 * mixpanel.people.union({
29332 * list1: 'bob',
29333 * list2: 123
29334 * });
29335 *
29336 * // like mixpanel.people.append(), you can append multiple
29337 * // values to the same list:
29338 * mixpanel.people.union({
29339 * list1: ['bob', 'billy']
29340 * });
29341 *
29342 * @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.
29343 * @param {*} [value] Value / values to merge with the given property
29344 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29345 */
29346 MixpanelPeople.prototype.union = addOptOutCheckMixpanelPeople(function(list_name, values, callback) {
29347 if (_.isObject(list_name)) {
29348 callback = values;
29349 }
29350 var data = this.union_action(list_name, values);
29351 return this._send_request(data, callback);
29352 });
29353
29354 /*
29355 * Record that you have charged the current user a certain amount
29356 * of money. Charges recorded with track_charge() will appear in the
29357 * Mixpanel revenue report.
29358 *
29359 * ### Usage:
29360 *
29361 * // charge a user $50
29362 * mixpanel.people.track_charge(50);
29363 *
29364 * // charge a user $30.50 on the 2nd of january
29365 * mixpanel.people.track_charge(30.50, {
29366 * '$time': new Date('jan 1 2012')
29367 * });
29368 *
29369 * @param {Number} amount The amount of money charged to the current user
29370 * @param {Object} [properties] An associative array of properties associated with the charge
29371 * @param {Function} [callback] If provided, the callback will be called when the server responds
29372 * @deprecated
29373 */
29374 MixpanelPeople.prototype.track_charge = addOptOutCheckMixpanelPeople(function() {
29375 console$1.error('mixpanel.people.track_charge() is deprecated and no longer has any effect.');
29376 });
29377
29378 /*
29379 * Permanently clear all revenue report transactions from the
29380 * current user's people analytics profile.
29381 *
29382 * ### Usage:
29383 *
29384 * mixpanel.people.clear_charges();
29385 *
29386 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29387 * @deprecated
29388 */
29389 MixpanelPeople.prototype.clear_charges = function(callback) {
29390 return this.set('$transactions', [], callback);
29391 };
29392
29393 /*
29394 * Permanently deletes the current people analytics profile from
29395 * Mixpanel (using the current distinct_id).
29396 *
29397 * ### Usage:
29398 *
29399 * // remove the all data you have stored about the current user
29400 * mixpanel.people.delete_user();
29401 *
29402 */
29403 MixpanelPeople.prototype.delete_user = function() {
29404 if (!this._identify_called()) {
29405 console$1.error('mixpanel.people.delete_user() requires you to call identify() first');
29406 return;
29407 }
29408 var data = {'$delete': this._mixpanel.get_distinct_id()};
29409 return this._send_request(data);
29410 };
29411
29412 MixpanelPeople.prototype.toString = function() {
29413 return this._mixpanel.toString() + '.people';
29414 };
29415
29416 MixpanelPeople.prototype._send_request = function(data, callback) {
29417 data['$token'] = this._get_config('token');
29418 data['$distinct_id'] = this._mixpanel.get_distinct_id();
29419 var device_id = this._mixpanel.get_property('$device_id');
29420 var user_id = this._mixpanel.get_property('$user_id');
29421 var had_persisted_distinct_id = this._mixpanel.get_property('$had_persisted_distinct_id');
29422 if (device_id) {
29423 data['$device_id'] = device_id;
29424 }
29425 if (user_id) {
29426 data['$user_id'] = user_id;
29427 }
29428 if (had_persisted_distinct_id) {
29429 data['$had_persisted_distinct_id'] = had_persisted_distinct_id;
29430 }
29431
29432 var date_encoded_data = _.encodeDates(data);
29433
29434 if (!this._identify_called()) {
29435 this._enqueue(data);
29436 if (!_.isUndefined(callback)) {
29437 if (this._get_config('verbose')) {
29438 callback({status: -1, error: null});
29439 } else {
29440 callback(-1);
29441 }
29442 }
29443 return _.truncate(date_encoded_data, 255);
29444 }
29445
29446 return this._mixpanel._track_or_batch({
29447 type: 'people',
29448 data: date_encoded_data,
29449 endpoint: this._mixpanel.get_api_host('people') + '/' + this._get_config('api_routes')['engage'],
29450 batcher: this._mixpanel.request_batchers.people
29451 }, callback);
29452 };
29453
29454 MixpanelPeople.prototype._get_config = function(conf_var) {
29455 return this._mixpanel.get_config(conf_var);
29456 };
29457
29458 MixpanelPeople.prototype._identify_called = function() {
29459 return this._mixpanel._flags.identify_called === true;
29460 };
29461
29462 // Queue up engage operations if identify hasn't been called yet.
29463 MixpanelPeople.prototype._enqueue = function(data) {
29464 if (SET_ACTION in data) {
29465 this._mixpanel['persistence']._add_to_people_queue(SET_ACTION, data);
29466 } else if (SET_ONCE_ACTION in data) {
29467 this._mixpanel['persistence']._add_to_people_queue(SET_ONCE_ACTION, data);
29468 } else if (UNSET_ACTION in data) {
29469 this._mixpanel['persistence']._add_to_people_queue(UNSET_ACTION, data);
29470 } else if (ADD_ACTION in data) {
29471 this._mixpanel['persistence']._add_to_people_queue(ADD_ACTION, data);
29472 } else if (APPEND_ACTION in data) {
29473 this._mixpanel['persistence']._add_to_people_queue(APPEND_ACTION, data);
29474 } else if (REMOVE_ACTION in data) {
29475 this._mixpanel['persistence']._add_to_people_queue(REMOVE_ACTION, data);
29476 } else if (UNION_ACTION in data) {
29477 this._mixpanel['persistence']._add_to_people_queue(UNION_ACTION, data);
29478 } else {
29479 console$1.error('Invalid call to _enqueue():', data);
29480 }
29481 };
29482
29483 MixpanelPeople.prototype._flush_one_queue = function(action, action_method, callback, queue_to_params_fn) {
29484 var _this = this;
29485 var queued_data = _.extend({}, this._mixpanel['persistence'].load_queue(action));
29486 var action_params = queued_data;
29487
29488 if (!_.isUndefined(queued_data) && _.isObject(queued_data) && !_.isEmptyObject(queued_data)) {
29489 _this._mixpanel['persistence']._pop_from_people_queue(action, queued_data);
29490 _this._mixpanel['persistence'].save();
29491 if (queue_to_params_fn) {
29492 action_params = queue_to_params_fn(queued_data);
29493 }
29494 action_method.call(_this, action_params, function(response, data) {
29495 // on bad response, we want to add it back to the queue
29496 if (response === 0) {
29497 _this._mixpanel['persistence']._add_to_people_queue(action, queued_data);
29498 }
29499 if (!_.isUndefined(callback)) {
29500 callback(response, data);
29501 }
29502 });
29503 }
29504 };
29505
29506 // Flush queued engage operations - order does not matter,
29507 // and there are network level race conditions anyway
29508 MixpanelPeople.prototype._flush = function(
29509 _set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback
29510 ) {
29511 var _this = this;
29512
29513 this._flush_one_queue(SET_ACTION, this.set, _set_callback);
29514 this._flush_one_queue(SET_ONCE_ACTION, this.set_once, _set_once_callback);
29515 this._flush_one_queue(UNSET_ACTION, this.unset, _unset_callback, function(queue) { return _.keys(queue); });
29516 this._flush_one_queue(ADD_ACTION, this.increment, _add_callback);
29517 this._flush_one_queue(UNION_ACTION, this.union, _union_callback);
29518
29519 // we have to fire off each $append individually since there is
29520 // no concat method server side
29521 var $append_queue = this._mixpanel['persistence'].load_queue(APPEND_ACTION);
29522 if (!_.isUndefined($append_queue) && _.isArray($append_queue) && $append_queue.length) {
29523 var $append_item;
29524 var append_callback = function(response, data) {
29525 if (response === 0) {
29526 _this._mixpanel['persistence']._add_to_people_queue(APPEND_ACTION, $append_item);
29527 }
29528 if (!_.isUndefined(_append_callback)) {
29529 _append_callback(response, data);
29530 }
29531 };
29532 for (var i = $append_queue.length - 1; i >= 0; i--) {
29533 $append_queue = this._mixpanel['persistence'].load_queue(APPEND_ACTION);
29534 $append_item = $append_queue.pop();
29535 _this._mixpanel['persistence'].save();
29536 if (!_.isEmptyObject($append_item)) {
29537 _this.append($append_item, append_callback);
29538 }
29539 }
29540 }
29541
29542 // same for $remove
29543 var $remove_queue = this._mixpanel['persistence'].load_queue(REMOVE_ACTION);
29544 if (!_.isUndefined($remove_queue) && _.isArray($remove_queue) && $remove_queue.length) {
29545 var $remove_item;
29546 var remove_callback = function(response, data) {
29547 if (response === 0) {
29548 _this._mixpanel['persistence']._add_to_people_queue(REMOVE_ACTION, $remove_item);
29549 }
29550 if (!_.isUndefined(_remove_callback)) {
29551 _remove_callback(response, data);
29552 }
29553 };
29554 for (var j = $remove_queue.length - 1; j >= 0; j--) {
29555 $remove_queue = this._mixpanel['persistence'].load_queue(REMOVE_ACTION);
29556 $remove_item = $remove_queue.pop();
29557 _this._mixpanel['persistence'].save();
29558 if (!_.isEmptyObject($remove_item)) {
29559 _this.remove($remove_item, remove_callback);
29560 }
29561 }
29562 }
29563 };
29564
29565 MixpanelPeople.prototype._is_reserved_property = function(prop) {
29566 return prop === '$distinct_id' || prop === '$token' || prop === '$device_id' || prop === '$user_id' || prop === '$had_persisted_distinct_id';
29567 };
29568
29569 // MixpanelPeople Exports
29570 MixpanelPeople.prototype['set'] = MixpanelPeople.prototype.set;
29571 MixpanelPeople.prototype['set_once'] = MixpanelPeople.prototype.set_once;
29572 MixpanelPeople.prototype['unset'] = MixpanelPeople.prototype.unset;
29573 MixpanelPeople.prototype['increment'] = MixpanelPeople.prototype.increment;
29574 MixpanelPeople.prototype['append'] = MixpanelPeople.prototype.append;
29575 MixpanelPeople.prototype['remove'] = MixpanelPeople.prototype.remove;
29576 MixpanelPeople.prototype['union'] = MixpanelPeople.prototype.union;
29577 MixpanelPeople.prototype['track_charge'] = MixpanelPeople.prototype.track_charge;
29578 MixpanelPeople.prototype['clear_charges'] = MixpanelPeople.prototype.clear_charges;
29579 MixpanelPeople.prototype['delete_user'] = MixpanelPeople.prototype.delete_user;
29580 MixpanelPeople.prototype['toString'] = MixpanelPeople.prototype.toString;
29581
29582 /* eslint camelcase: "off" */
29583
29584
29585 /*
29586 * Constants
29587 */
29588 /** @const */ var SET_QUEUE_KEY = '__mps';
29589 /** @const */ var SET_ONCE_QUEUE_KEY = '__mpso';
29590 /** @const */ var UNSET_QUEUE_KEY = '__mpus';
29591 /** @const */ var ADD_QUEUE_KEY = '__mpa';
29592 /** @const */ var APPEND_QUEUE_KEY = '__mpap';
29593 /** @const */ var REMOVE_QUEUE_KEY = '__mpr';
29594 /** @const */ var UNION_QUEUE_KEY = '__mpu';
29595 // This key is deprecated, but we want to check for it to see whether aliasing is allowed.
29596 /** @const */ var PEOPLE_DISTINCT_ID_KEY = '$people_distinct_id';
29597 /** @const */ var ALIAS_ID_KEY = '__alias';
29598 /** @const */ var EVENT_TIMERS_KEY = '__timers';
29599 /** @const */ var RESERVED_PROPERTIES = [
29600 SET_QUEUE_KEY,
29601 SET_ONCE_QUEUE_KEY,
29602 UNSET_QUEUE_KEY,
29603 ADD_QUEUE_KEY,
29604 APPEND_QUEUE_KEY,
29605 REMOVE_QUEUE_KEY,
29606 UNION_QUEUE_KEY,
29607 PEOPLE_DISTINCT_ID_KEY,
29608 ALIAS_ID_KEY,
29609 EVENT_TIMERS_KEY
29610 ];
29611
29612 /**
29613 * Mixpanel Persistence Object
29614 * @constructor
29615 */
29616 var MixpanelPersistence = function(config) {
29617 this['props'] = {};
29618 this.campaign_params_saved = false;
29619
29620 if (config['persistence_name']) {
29621 this.name = 'mp_' + config['persistence_name'];
29622 } else {
29623 this.name = 'mp_' + config['token'] + '_mixpanel';
29624 }
29625
29626 var storage_type = config['persistence'];
29627 if (storage_type !== 'cookie' && storage_type !== 'localStorage') {
29628 console$1.critical('Unknown persistence type ' + storage_type + '; falling back to cookie');
29629 storage_type = config['persistence'] = 'cookie';
29630 }
29631
29632 if (storage_type === 'localStorage' && _.localStorage.is_supported()) {
29633 this.storage = _.localStorage;
29634 } else {
29635 this.storage = _.cookie;
29636 }
29637
29638 this.load();
29639 this.update_config(config);
29640 this.upgrade();
29641 this.save();
29642 };
29643
29644 MixpanelPersistence.prototype.properties = function() {
29645 var p = {};
29646
29647 this.load();
29648
29649 // Filter out reserved properties
29650 _.each(this['props'], function(v, k) {
29651 if (!_.include(RESERVED_PROPERTIES, k)) {
29652 p[k] = v;
29653 }
29654 });
29655 return p;
29656 };
29657
29658 MixpanelPersistence.prototype.load = function() {
29659 if (this.disabled) { return; }
29660
29661 var entry = this.storage.parse(this.name);
29662
29663 if (entry) {
29664 this['props'] = _.extend({}, entry);
29665 }
29666 };
29667
29668 MixpanelPersistence.prototype.upgrade = function() {
29669 var old_cookie,
29670 old_localstorage;
29671
29672 // if transferring from cookie to localStorage or vice-versa, copy existing
29673 // super properties over to new storage mode
29674 if (this.storage === _.localStorage) {
29675 old_cookie = _.cookie.parse(this.name);
29676
29677 _.cookie.remove(this.name);
29678 _.cookie.remove(this.name, true);
29679
29680 if (old_cookie) {
29681 this.register_once(old_cookie);
29682 }
29683 } else if (this.storage === _.cookie) {
29684 old_localstorage = _.localStorage.parse(this.name);
29685
29686 _.localStorage.remove(this.name);
29687
29688 if (old_localstorage) {
29689 this.register_once(old_localstorage);
29690 }
29691 }
29692 };
29693
29694 MixpanelPersistence.prototype.save = function() {
29695 if (this.disabled) { return; }
29696
29697 this.storage.set(
29698 this.name,
29699 JSONStringify(this['props']),
29700 this.expire_days,
29701 this.cross_subdomain,
29702 this.secure,
29703 this.cross_site,
29704 this.cookie_domain
29705 );
29706 };
29707
29708 MixpanelPersistence.prototype.load_prop = function(key) {
29709 this.load();
29710 return this['props'][key];
29711 };
29712
29713 MixpanelPersistence.prototype.remove = function() {
29714 // remove both domain and subdomain cookies
29715 this.storage.remove(this.name, false, this.cookie_domain);
29716 this.storage.remove(this.name, true, this.cookie_domain);
29717 };
29718
29719 // removes the storage entry and deletes all loaded data
29720 // forced name for tests
29721 MixpanelPersistence.prototype.clear = function() {
29722 this.remove();
29723 this['props'] = {};
29724 };
29725
29726 /**
29727 * @param {Object} props
29728 * @param {*=} default_value
29729 * @param {number=} days
29730 */
29731 MixpanelPersistence.prototype.register_once = function(props, default_value, days) {
29732 if (_.isObject(props)) {
29733 if (typeof(default_value) === 'undefined') { default_value = 'None'; }
29734 this.expire_days = (typeof(days) === 'undefined') ? this.default_expiry : days;
29735
29736 this.load();
29737
29738 _.each(props, function(val, prop) {
29739 if (!this['props'].hasOwnProperty(prop) || this['props'][prop] === default_value) {
29740 this['props'][prop] = val;
29741 }
29742 }, this);
29743
29744 this.save();
29745
29746 return true;
29747 }
29748 return false;
29749 };
29750
29751 /**
29752 * @param {Object} props
29753 * @param {number=} days
29754 */
29755 MixpanelPersistence.prototype.register = function(props, days) {
29756 if (_.isObject(props)) {
29757 this.expire_days = (typeof(days) === 'undefined') ? this.default_expiry : days;
29758
29759 this.load();
29760 _.extend(this['props'], props);
29761 this.save();
29762
29763 return true;
29764 }
29765 return false;
29766 };
29767
29768 MixpanelPersistence.prototype.unregister = function(prop) {
29769 this.load();
29770 if (prop in this['props']) {
29771 delete this['props'][prop];
29772 this.save();
29773 }
29774 };
29775
29776 MixpanelPersistence.prototype.update_search_keyword = function(referrer) {
29777 this.register(_.info.searchInfo(referrer));
29778 };
29779
29780 // EXPORTED METHOD, we test this directly.
29781 MixpanelPersistence.prototype.update_referrer_info = function(referrer) {
29782 // If referrer doesn't exist, we want to note the fact that it was type-in traffic.
29783 this.register_once({
29784 '$initial_referrer': referrer || '$direct',
29785 '$initial_referring_domain': _.info.referringDomain(referrer) || '$direct'
29786 }, '');
29787 };
29788
29789 MixpanelPersistence.prototype.get_referrer_info = function() {
29790 return _.strip_empty_properties({
29791 '$initial_referrer': this['props']['$initial_referrer'],
29792 '$initial_referring_domain': this['props']['$initial_referring_domain']
29793 });
29794 };
29795
29796 MixpanelPersistence.prototype.update_config = function(config) {
29797 this.default_expiry = this.expire_days = config['cookie_expiration'];
29798 this.set_disabled(config['disable_persistence']);
29799 this.set_cookie_domain(config['cookie_domain']);
29800 this.set_cross_site(config['cross_site_cookie']);
29801 this.set_cross_subdomain(config['cross_subdomain_cookie']);
29802 this.set_secure(config['secure_cookie']);
29803 };
29804
29805 MixpanelPersistence.prototype.set_disabled = function(disabled) {
29806 this.disabled = disabled;
29807 if (this.disabled) {
29808 this.remove();
29809 } else {
29810 this.save();
29811 }
29812 };
29813
29814 MixpanelPersistence.prototype.set_cookie_domain = function(cookie_domain) {
29815 if (cookie_domain !== this.cookie_domain) {
29816 this.remove();
29817 this.cookie_domain = cookie_domain;
29818 this.save();
29819 }
29820 };
29821
29822 MixpanelPersistence.prototype.set_cross_site = function(cross_site) {
29823 if (cross_site !== this.cross_site) {
29824 this.cross_site = cross_site;
29825 this.remove();
29826 this.save();
29827 }
29828 };
29829
29830 MixpanelPersistence.prototype.set_cross_subdomain = function(cross_subdomain) {
29831 if (cross_subdomain !== this.cross_subdomain) {
29832 this.cross_subdomain = cross_subdomain;
29833 this.remove();
29834 this.save();
29835 }
29836 };
29837
29838 MixpanelPersistence.prototype.get_cross_subdomain = function() {
29839 return this.cross_subdomain;
29840 };
29841
29842 MixpanelPersistence.prototype.set_secure = function(secure) {
29843 if (secure !== this.secure) {
29844 this.secure = secure ? true : false;
29845 this.remove();
29846 this.save();
29847 }
29848 };
29849
29850 MixpanelPersistence.prototype._add_to_people_queue = function(queue, data) {
29851 var q_key = this._get_queue_key(queue),
29852 q_data = data[queue],
29853 set_q = this._get_or_create_queue(SET_ACTION),
29854 set_once_q = this._get_or_create_queue(SET_ONCE_ACTION),
29855 unset_q = this._get_or_create_queue(UNSET_ACTION),
29856 add_q = this._get_or_create_queue(ADD_ACTION),
29857 union_q = this._get_or_create_queue(UNION_ACTION),
29858 remove_q = this._get_or_create_queue(REMOVE_ACTION, []),
29859 append_q = this._get_or_create_queue(APPEND_ACTION, []);
29860
29861 if (q_key === SET_QUEUE_KEY) {
29862 // Update the set queue - we can override any existing values
29863 _.extend(set_q, q_data);
29864 // if there was a pending increment, override it
29865 // with the set.
29866 this._pop_from_people_queue(ADD_ACTION, q_data);
29867 // if there was a pending union, override it
29868 // with the set.
29869 this._pop_from_people_queue(UNION_ACTION, q_data);
29870 this._pop_from_people_queue(UNSET_ACTION, q_data);
29871 } else if (q_key === SET_ONCE_QUEUE_KEY) {
29872 // only queue the data if there is not already a set_once call for it.
29873 _.each(q_data, function(v, k) {
29874 if (!(k in set_once_q)) {
29875 set_once_q[k] = v;
29876 }
29877 });
29878 this._pop_from_people_queue(UNSET_ACTION, q_data);
29879 } else if (q_key === UNSET_QUEUE_KEY) {
29880 _.each(q_data, function(prop) {
29881
29882 // undo previously-queued actions on this key
29883 _.each([set_q, set_once_q, add_q, union_q], function(enqueued_obj) {
29884 if (prop in enqueued_obj) {
29885 delete enqueued_obj[prop];
29886 }
29887 });
29888 _.each(append_q, function(append_obj) {
29889 if (prop in append_obj) {
29890 delete append_obj[prop];
29891 }
29892 });
29893
29894 unset_q[prop] = true;
29895
29896 });
29897 } else if (q_key === ADD_QUEUE_KEY) {
29898 _.each(q_data, function(v, k) {
29899 // If it exists in the set queue, increment
29900 // the value
29901 if (k in set_q) {
29902 set_q[k] += v;
29903 } else {
29904 // If it doesn't exist, update the add
29905 // queue
29906 if (!(k in add_q)) {
29907 add_q[k] = 0;
29908 }
29909 add_q[k] += v;
29910 }
29911 }, this);
29912 this._pop_from_people_queue(UNSET_ACTION, q_data);
29913 } else if (q_key === UNION_QUEUE_KEY) {
29914 _.each(q_data, function(v, k) {
29915 if (_.isArray(v)) {
29916 if (!(k in union_q)) {
29917 union_q[k] = [];
29918 }
29919 // Prevent duplicate values
29920 _.each(v, function(item) {
29921 if (!_.include(union_q[k], item)) {
29922 union_q[k].push(item);
29923 }
29924 });
29925 }
29926 });
29927 this._pop_from_people_queue(UNSET_ACTION, q_data);
29928 } else if (q_key === REMOVE_QUEUE_KEY) {
29929 remove_q.push(q_data);
29930 this._pop_from_people_queue(APPEND_ACTION, q_data);
29931 } else if (q_key === APPEND_QUEUE_KEY) {
29932 append_q.push(q_data);
29933 this._pop_from_people_queue(UNSET_ACTION, q_data);
29934 }
29935
29936 console$1.log('MIXPANEL PEOPLE REQUEST (QUEUED, PENDING IDENTIFY):');
29937 console$1.log(data);
29938
29939 this.save();
29940 };
29941
29942 MixpanelPersistence.prototype._pop_from_people_queue = function(queue, data) {
29943 var q = this['props'][this._get_queue_key(queue)];
29944 if (!_.isUndefined(q)) {
29945 _.each(data, function(v, k) {
29946 if (queue === APPEND_ACTION || queue === REMOVE_ACTION) {
29947 // list actions: only remove if both k+v match
29948 // e.g. remove should not override append in a case like
29949 // append({foo: 'bar'}); remove({foo: 'qux'})
29950 _.each(q, function(queued_action) {
29951 if (queued_action[k] === v) {
29952 delete queued_action[k];
29953 }
29954 });
29955 } else {
29956 delete q[k];
29957 }
29958 }, this);
29959 }
29960 };
29961
29962 MixpanelPersistence.prototype.load_queue = function(queue) {
29963 return this.load_prop(this._get_queue_key(queue));
29964 };
29965
29966 MixpanelPersistence.prototype._get_queue_key = function(queue) {
29967 if (queue === SET_ACTION) {
29968 return SET_QUEUE_KEY;
29969 } else if (queue === SET_ONCE_ACTION) {
29970 return SET_ONCE_QUEUE_KEY;
29971 } else if (queue === UNSET_ACTION) {
29972 return UNSET_QUEUE_KEY;
29973 } else if (queue === ADD_ACTION) {
29974 return ADD_QUEUE_KEY;
29975 } else if (queue === APPEND_ACTION) {
29976 return APPEND_QUEUE_KEY;
29977 } else if (queue === REMOVE_ACTION) {
29978 return REMOVE_QUEUE_KEY;
29979 } else if (queue === UNION_ACTION) {
29980 return UNION_QUEUE_KEY;
29981 } else {
29982 console$1.error('Invalid queue:', queue);
29983 }
29984 };
29985
29986 MixpanelPersistence.prototype._get_or_create_queue = function(queue, default_val) {
29987 var key = this._get_queue_key(queue);
29988 default_val = _.isUndefined(default_val) ? {} : default_val;
29989 return this['props'][key] || (this['props'][key] = default_val);
29990 };
29991
29992 MixpanelPersistence.prototype.set_event_timer = function(event_name, timestamp) {
29993 var timers = this.load_prop(EVENT_TIMERS_KEY) || {};
29994 timers[event_name] = timestamp;
29995 this['props'][EVENT_TIMERS_KEY] = timers;
29996 this.save();
29997 };
29998
29999 MixpanelPersistence.prototype.remove_event_timer = function(event_name) {
30000 var timers = this.load_prop(EVENT_TIMERS_KEY) || {};
30001 var timestamp = timers[event_name];
30002 if (!_.isUndefined(timestamp)) {
30003 delete this['props'][EVENT_TIMERS_KEY][event_name];
30004 this.save();
30005 }
30006 return timestamp;
30007 };
30008
30009 /* eslint camelcase: "off" */
30010
30011 /*
30012 * Mixpanel JS Library
30013 *
30014 * Copyright 2012, Mixpanel, Inc. All Rights Reserved
30015 * http://mixpanel.com/
30016 *
30017 * Includes portions of Underscore.js
30018 * http://documentcloud.github.com/underscore/
30019 * (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.
30020 * Released under the MIT License.
30021 */
30022
30023 /*
30024 SIMPLE STYLE GUIDE:
30025
30026 this.x === public function
30027 this._x === internal - only use within this file
30028 this.__x === private - only use within the class
30029
30030 Globals should be all caps
30031 */
30032
30033 var init_type; // MODULE or SNIPPET loader
30034 // allow bundlers to specify how extra code (recorder bundle) should be loaded
30035 // eslint-disable-next-line no-unused-vars
30036 var load_extra_bundle = function(src, _onload) {
30037 throw new Error(src + ' not available in this build.');
30038 };
30039
30040 var mixpanel_master; // main mixpanel instance / object
30041 var INIT_MODULE = 0;
30042 var INIT_SNIPPET = 1;
30043
30044 var IDENTITY_FUNC = function(x) {return x;};
30045
30046 /** @const */ var PRIMARY_INSTANCE_NAME = 'mixpanel';
30047 /** @const */ var PAYLOAD_TYPE_BASE64 = 'base64';
30048 /** @const */ var PAYLOAD_TYPE_JSON = 'json';
30049 /** @const */ var DEVICE_ID_PREFIX = '$device:';
30050
30051
30052 /*
30053 * Dynamic... constants? Is that an oxymoron?
30054 */
30055 // http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/
30056 // https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#withCredentials
30057 var USE_XHR = (win.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest());
30058
30059 // IE<10 does not support cross-origin XHR's but script tags
30060 // with defer won't block window.onload; ENQUEUE_REQUESTS
30061 // should only be true for Opera<12
30062 var ENQUEUE_REQUESTS = !USE_XHR && (userAgent.indexOf('MSIE') === -1) && (userAgent.indexOf('Mozilla') === -1);
30063
30064 // save reference to navigator.sendBeacon so it can be minified
30065 var sendBeacon = null;
30066 if (navigator['sendBeacon']) {
30067 sendBeacon = function() {
30068 // late reference to navigator.sendBeacon to allow patching/spying
30069 return navigator['sendBeacon'].apply(navigator, arguments);
30070 };
30071 }
30072
30073 var DEFAULT_API_ROUTES = {
30074 'track': 'track/',
30075 'engage': 'engage/',
30076 'groups': 'groups/',
30077 'record': 'record/',
30078 'flags': 'flags/'
30079 };
30080
30081 /*
30082 * Module-level globals
30083 */
30084 var DEFAULT_CONFIG = {
30085 'api_host': 'https://api-js.mixpanel.com',
30086 'api_hosts': {},
30087 'api_routes': DEFAULT_API_ROUTES,
30088 'api_extra_query_params': {},
30089 'api_method': 'POST',
30090 'api_transport': 'XHR',
30091 'api_payload_format': PAYLOAD_TYPE_BASE64,
30092 'app_host': 'https://mixpanel.com',
30093 'autocapture': false,
30094 'cdn': 'https://cdn.mxpnl.com',
30095 'cross_site_cookie': false,
30096 'cross_subdomain_cookie': true,
30097 'error_reporter': NOOP_FUNC,
30098 'flags': false,
30099 'persistence': 'cookie',
30100 'persistence_name': '',
30101 'cookie_domain': '',
30102 'cookie_name': '',
30103 'loaded': NOOP_FUNC,
30104 'mp_loader': null,
30105 'track_marketing': true,
30106 'track_pageview': false,
30107 'skip_first_touch_marketing': false,
30108 'store_google': true,
30109 'stop_utm_persistence': false,
30110 'save_referrer': true,
30111 'test': false,
30112 'verbose': false,
30113 'img': false,
30114 'debug': false,
30115 'track_links_timeout': 300,
30116 'cookie_expiration': 365,
30117 'upgrade': false,
30118 'disable_persistence': false,
30119 'disable_cookie': false,
30120 'secure_cookie': false,
30121 'ip': true,
30122 'opt_out_tracking_by_default': false,
30123 'opt_out_persistence_by_default': false,
30124 'opt_out_tracking_persistence_type': 'localStorage',
30125 'opt_out_tracking_cookie_prefix': null,
30126 'property_blacklist': [],
30127 'xhr_headers': {}, // { header: value, header2: value }
30128 'ignore_dnt': false,
30129 'batch_requests': true,
30130 'batch_size': 50,
30131 'batch_flush_interval_ms': 5000,
30132 'batch_request_timeout_ms': 90000,
30133 'batch_autostart': true,
30134 'hooks': {},
30135 'record_block_class': new RegExp('^(mp-block|fs-exclude|amp-block|rr-block|ph-no-capture)$'),
30136 'record_block_selector': 'img, video, audio',
30137 'record_canvas': false,
30138 'record_collect_fonts': false,
30139 'record_heatmap_data': false,
30140 'record_idle_timeout_ms': 30 * 60 * 1000, // 30 minutes
30141 'record_mask_text_class': new RegExp('^(mp-mask|fs-mask|amp-mask|rr-mask|ph-mask)$'),
30142 'record_mask_text_selector': '*',
30143 'record_max_ms': MAX_RECORDING_MS,
30144 'record_min_ms': 0,
30145 'record_sessions_percent': 0,
30146 'recorder_src': 'https://cdn.mxpnl.com/libs/mixpanel-recorder.min.js'
30147 };
30148
30149 var DOM_LOADED = false;
30150
30151 /**
30152 * Mixpanel Library Object
30153 * @constructor
30154 */
30155 var MixpanelLib = function() {};
30156
30157
30158 /**
30159 * create_mplib(token:string, config:object, name:string)
30160 *
30161 * This function is used by the init method of MixpanelLib objects
30162 * as well as the main initializer at the end of the JSLib (that
30163 * initializes document.mixpanel as well as any additional instances
30164 * declared before this file has loaded).
30165 */
30166 var create_mplib = function(token, config, name) {
30167 var instance,
30168 target = (name === PRIMARY_INSTANCE_NAME) ? mixpanel_master : mixpanel_master[name];
30169
30170 if (target && init_type === INIT_MODULE) {
30171 instance = target;
30172 } else {
30173 if (target && !_.isArray(target)) {
30174 console$1.error('You have already initialized ' + name);
30175 return;
30176 }
30177 instance = new MixpanelLib();
30178 }
30179
30180 instance._cached_groups = {}; // cache groups in a pool
30181
30182 instance._init(token, config, name);
30183
30184 instance['people'] = new MixpanelPeople();
30185 instance['people']._init(instance);
30186
30187 if (!instance.get_config('skip_first_touch_marketing')) {
30188 // We need null UTM params in the object because
30189 // UTM parameters act as a tuple. If any UTM param
30190 // is present, then we set all UTM params including
30191 // empty ones together
30192 var utm_params = _.info.campaignParams(null);
30193 var initial_utm_params = {};
30194 var has_utm = false;
30195 _.each(utm_params, function(utm_value, utm_key) {
30196 initial_utm_params['initial_' + utm_key] = utm_value;
30197 if (utm_value) {
30198 has_utm = true;
30199 }
30200 });
30201 if (has_utm) {
30202 instance['people'].set_once(initial_utm_params);
30203 }
30204 }
30205
30206 // if any instance on the page has debug = true, we set the
30207 // global debug to be true
30208 Config.DEBUG = Config.DEBUG || instance.get_config('debug');
30209
30210 // if target is not defined, we called init after the lib already
30211 // loaded, so there won't be an array of things to execute
30212 if (!_.isUndefined(target) && _.isArray(target)) {
30213 // Crunch through the people queue first - we queue this data up &
30214 // flush on identify, so it's better to do all these operations first
30215 instance._execute_array.call(instance['people'], target['people']);
30216 instance._execute_array(target);
30217 }
30218
30219 return instance;
30220 };
30221
30222 // Initialization methods
30223
30224 /**
30225 * This function initializes a new instance of the Mixpanel tracking object.
30226 * All new instances are added to the main mixpanel object as sub properties (such as
30227 * mixpanel.library_name) and also returned by this function. To define a
30228 * second instance on the page, you would call:
30229 *
30230 * mixpanel.init('new token', { your: 'config' }, 'library_name');
30231 *
30232 * and use it like so:
30233 *
30234 * mixpanel.library_name.track(...);
30235 *
30236 * @param {String} token Your Mixpanel API token
30237 * @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>.
30238 * @param {String} [name] The name for the new mixpanel instance that you want created
30239 */
30240 MixpanelLib.prototype.init = function (token, config, name) {
30241 if (_.isUndefined(name)) {
30242 this.report_error('You must name your new library: init(token, config, name)');
30243 return;
30244 }
30245 if (name === PRIMARY_INSTANCE_NAME) {
30246 this.report_error('You must initialize the main mixpanel object right after you include the Mixpanel js snippet');
30247 return;
30248 }
30249
30250 var instance = create_mplib(token, config, name);
30251 mixpanel_master[name] = instance;
30252 instance._loaded();
30253
30254 return instance;
30255 };
30256
30257 // mixpanel._init(token:string, config:object, name:string)
30258 //
30259 // This function sets up the current instance of the mixpanel
30260 // library. The difference between this method and the init(...)
30261 // method is this one initializes the actual instance, whereas the
30262 // init(...) method sets up a new library and calls _init on it.
30263 //
30264 MixpanelLib.prototype._init = function(token, config, name) {
30265 config = config || {};
30266
30267 this['__loaded'] = true;
30268 this['config'] = {};
30269
30270 var variable_features = {};
30271
30272 // default to JSON payload for standard mixpanel.com API hosts
30273 if (!('api_payload_format' in config)) {
30274 var api_host = config['api_host'] || DEFAULT_CONFIG['api_host'];
30275 if (api_host.match(/\.mixpanel\.com/)) {
30276 variable_features['api_payload_format'] = PAYLOAD_TYPE_JSON;
30277 }
30278 }
30279
30280 this.set_config(_.extend({}, DEFAULT_CONFIG, variable_features, config, {
30281 'name': name,
30282 'token': token,
30283 'callback_fn': ((name === PRIMARY_INSTANCE_NAME) ? name : PRIMARY_INSTANCE_NAME + '.' + name) + '._jsc'
30284 }));
30285
30286 this['_jsc'] = NOOP_FUNC;
30287
30288 this.__dom_loaded_queue = [];
30289 this.__request_queue = [];
30290 this.__disabled_events = [];
30291 this._flags = {
30292 'disable_all_events': false,
30293 'identify_called': false
30294 };
30295
30296 // set up request queueing/batching
30297 this.request_batchers = {};
30298 this._batch_requests = this.get_config('batch_requests');
30299 if (this._batch_requests) {
30300 if (!_.localStorage.is_supported(true) || !USE_XHR) {
30301 this._batch_requests = false;
30302 console$1.log('Turning off Mixpanel request-queueing; needs XHR and localStorage support');
30303 _.each(this.get_batcher_configs(), function(batcher_config) {
30304 console$1.log('Clearing batch queue ' + batcher_config.queue_key);
30305 _.localStorage.remove(batcher_config.queue_key);
30306 });
30307 } else {
30308 this.init_batchers();
30309 if (sendBeacon && win.addEventListener) {
30310 // Before page closes or hides (user tabs away etc), attempt to flush any events
30311 // queued up via navigator.sendBeacon. Since sendBeacon doesn't report success/failure,
30312 // events will not be removed from the persistent store; if the site is loaded again,
30313 // the events will be flushed again on startup and deduplicated on the Mixpanel server
30314 // side.
30315 // There is no reliable way to capture only page close events, so we lean on the
30316 // visibilitychange and pagehide events as recommended at
30317 // https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event#usage_notes.
30318 // These events fire when the user clicks away from the current page/tab, so will occur
30319 // more frequently than page unload, but are the only mechanism currently for capturing
30320 // this scenario somewhat reliably.
30321 var flush_on_unload = _.bind(function() {
30322 if (!this.request_batchers.events.stopped) {
30323 this.request_batchers.events.flush({unloading: true});
30324 }
30325 }, this);
30326 win.addEventListener('pagehide', function(ev) {
30327 if (ev['persisted']) {
30328 flush_on_unload();
30329 }
30330 });
30331 win.addEventListener('visibilitychange', function() {
30332 if (document$1['visibilityState'] === 'hidden') {
30333 flush_on_unload();
30334 }
30335 });
30336 }
30337 }
30338 }
30339
30340 this['persistence'] = this['cookie'] = new MixpanelPersistence(this['config']);
30341 this.unpersisted_superprops = {};
30342 this._gdpr_init();
30343
30344 var uuid = _.UUID();
30345 if (!this.get_distinct_id()) {
30346 // There is no need to set the distinct id
30347 // or the device id if something was already stored
30348 // in the persitence
30349 this.register_once({
30350 'distinct_id': DEVICE_ID_PREFIX + uuid,
30351 '$device_id': uuid
30352 }, '');
30353 }
30354
30355 this.flags = new FeatureFlagManager({
30356 getFullApiRoute: _.bind(function() {
30357 return this.get_api_host('flags') + '/' + this.get_config('api_routes')['flags'];
30358 }, this),
30359 getConfigFunc: _.bind(this.get_config, this),
30360 setConfigFunc: _.bind(this.set_config, this),
30361 getPropertyFunc: _.bind(this.get_property, this),
30362 trackingFunc: _.bind(this.track, this)
30363 });
30364 this.flags.init();
30365 this['flags'] = this.flags;
30366
30367 this.autocapture = new Autocapture(this);
30368 this.autocapture.init();
30369
30370 this._init_tab_id();
30371 this._check_and_start_session_recording();
30372 };
30373
30374 /**
30375 * Assigns a unique UUID to this tab / window by leveraging sessionStorage.
30376 * This is primarily used for session recording, where data must be isolated to the current tab.
30377 */
30378 MixpanelLib.prototype._init_tab_id = function() {
30379 if (this.get_config('disable_persistence')) {
30380 console$1.log('Tab ID initialization skipped due to disable_persistence config');
30381 } else if (_.sessionStorage.is_supported()) {
30382 try {
30383 var key_suffix = this.get_config('name') + '_' + this.get_config('token');
30384 var tab_id_key = 'mp_tab_id_' + key_suffix;
30385
30386 // A flag is used to determine if sessionStorage is copied over and we need to generate a new tab ID.
30387 // This enforces a unique ID in the cases like duplicated tab, window.open(...)
30388 var should_generate_new_tab_id_key = 'mp_gen_new_tab_id_' + key_suffix;
30389 if (_.sessionStorage.get(should_generate_new_tab_id_key) || !_.sessionStorage.get(tab_id_key)) {
30390 _.sessionStorage.set(tab_id_key, '$tab-' + _.UUID());
30391 }
30392
30393 _.sessionStorage.set(should_generate_new_tab_id_key, '1');
30394 this.tab_id = _.sessionStorage.get(tab_id_key);
30395
30396 // 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,
30397 // but reliable in cases where the user remains in the tab e.g. a refresh or href navigation.
30398 // If the flag is absent, this indicates to the next SDK instance that we can reuse the stored tab_id.
30399 win.addEventListener('beforeunload', function () {
30400 _.sessionStorage.remove(should_generate_new_tab_id_key);
30401 });
30402 } catch(err) {
30403 this.report_error('Error initializing tab id', err);
30404 }
30405 } else {
30406 this.report_error('Session storage is not supported, cannot keep track of unique tab ID.');
30407 }
30408 };
30409
30410 MixpanelLib.prototype.get_tab_id = function () {
30411 return this.tab_id || null;
30412 };
30413
30414 MixpanelLib.prototype._should_load_recorder = function () {
30415 if (this.get_config('disable_persistence')) {
30416 console$1.log('Load recorder check skipped due to disable_persistence config');
30417 return Promise.resolve(false);
30418 }
30419
30420 var recording_registry_idb = new IDBStorageWrapper(RECORDING_REGISTRY_STORE_NAME);
30421 var tab_id = this.get_tab_id();
30422 return recording_registry_idb.init()
30423 .then(function () {
30424 return recording_registry_idb.getAll();
30425 })
30426 .then(function (recordings) {
30427 for (var i = 0; i < recordings.length; i++) {
30428 // if there are expired recordings in the registry, we should load the recorder to flush them
30429 // if there's a recording for this tab id, we should load the recorder to continue the recording
30430 if (isRecordingExpired(recordings[i]) || recordings[i]['tabId'] === tab_id) {
30431 return true;
30432 }
30433 }
30434 return false;
30435 })
30436 .catch(_.bind(function (err) {
30437 this.report_error('Error checking recording registry', err);
30438 }, this));
30439 };
30440
30441 MixpanelLib.prototype._check_and_start_session_recording = addOptOutCheckMixpanelLib(function(force_start) {
30442 if (!win['MutationObserver']) {
30443 console$1.critical('Browser does not support MutationObserver; skipping session recording');
30444 return;
30445 }
30446
30447 var loadRecorder = _.bind(function(startNewIfInactive) {
30448 var handleLoadedRecorder = _.bind(function() {
30449 this._recorder = this._recorder || new win['__mp_recorder'](this);
30450 this._recorder['resumeRecording'](startNewIfInactive);
30451 }, this);
30452
30453 if (_.isUndefined(win['__mp_recorder'])) {
30454 load_extra_bundle(this.get_config('recorder_src'), handleLoadedRecorder);
30455 } else {
30456 handleLoadedRecorder();
30457 }
30458 }, this);
30459
30460 /**
30461 * If the user is sampled or start_session_recording is called, we always load the recorder since it's guaranteed a recording should start.
30462 * 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.
30463 */
30464 var is_sampled = this.get_config('record_sessions_percent') > 0 && Math.random() * 100 <= this.get_config('record_sessions_percent');
30465 if (force_start || is_sampled) {
30466 loadRecorder(true);
30467 } else {
30468 this._should_load_recorder()
30469 .then(function (shouldLoad) {
30470 if (shouldLoad) {
30471 loadRecorder(false);
30472 }
30473 });
30474 }
30475 });
30476
30477 MixpanelLib.prototype.start_session_recording = function () {
30478 this._check_and_start_session_recording(true);
30479 };
30480
30481 MixpanelLib.prototype.stop_session_recording = function () {
30482 if (this._recorder) {
30483 return this._recorder['stopRecording']();
30484 }
30485 return Promise.resolve();
30486 };
30487
30488 MixpanelLib.prototype.pause_session_recording = function () {
30489 if (this._recorder) {
30490 return this._recorder['pauseRecording']();
30491 }
30492 return Promise.resolve();
30493 };
30494
30495 MixpanelLib.prototype.resume_session_recording = function () {
30496 if (this._recorder) {
30497 return this._recorder['resumeRecording']();
30498 }
30499 return Promise.resolve();
30500 };
30501
30502 MixpanelLib.prototype.is_recording_heatmap_data = function () {
30503 return this._get_session_replay_id() && this.get_config('record_heatmap_data');
30504 };
30505
30506 MixpanelLib.prototype.get_session_recording_properties = function () {
30507 var props = {};
30508 var replay_id = this._get_session_replay_id();
30509 if (replay_id) {
30510 props['$mp_replay_id'] = replay_id;
30511 }
30512 return props;
30513 };
30514
30515 MixpanelLib.prototype.get_session_replay_url = function () {
30516 var replay_url = null;
30517 var replay_id = this._get_session_replay_id();
30518 if (replay_id) {
30519 var query_params = _.HTTPBuildQuery({
30520 'replay_id': replay_id,
30521 'distinct_id': this.get_distinct_id(),
30522 'token': this.get_config('token')
30523 });
30524 replay_url = 'https://mixpanel.com/projects/replay-redirect?' + query_params;
30525 }
30526 return replay_url;
30527 };
30528
30529 MixpanelLib.prototype._get_session_replay_id = function () {
30530 var replay_id = null;
30531 if (this._recorder) {
30532 replay_id = this._recorder['replayId'];
30533 }
30534 return replay_id || null;
30535 };
30536
30537 // "private" public method to reach into the recorder in test cases
30538 MixpanelLib.prototype.__get_recorder = function () {
30539 return this._recorder;
30540 };
30541
30542 // Private methods
30543
30544 MixpanelLib.prototype._loaded = function() {
30545 this.get_config('loaded')(this);
30546 this._set_default_superprops();
30547 this['people'].set_once(this['persistence'].get_referrer_info());
30548
30549 // `store_google` is now deprecated and previously stored UTM parameters are cleared
30550 // from persistence by default.
30551 if (this.get_config('store_google') && this.get_config('stop_utm_persistence')) {
30552 var utm_params = _.info.campaignParams(null);
30553 _.each(utm_params, function(_utm_value, utm_key) {
30554 // We need to unregister persisted UTM parameters so old values
30555 // are not mixed with the new UTM parameters
30556 this.unregister(utm_key);
30557 }.bind(this));
30558 }
30559 };
30560
30561 // update persistence with info on referrer, UTM params, etc
30562 MixpanelLib.prototype._set_default_superprops = function() {
30563 this['persistence'].update_search_keyword(document$1.referrer);
30564 // Registering super properties for UTM persistence by 'store_google' is deprecated.
30565 if (this.get_config('store_google') && !this.get_config('stop_utm_persistence')) {
30566 this.register(_.info.campaignParams());
30567 }
30568 if (this.get_config('save_referrer')) {
30569 this['persistence'].update_referrer_info(document$1.referrer);
30570 }
30571 };
30572
30573 MixpanelLib.prototype._dom_loaded = function() {
30574 _.each(this.__dom_loaded_queue, function(item) {
30575 this._track_dom.apply(this, item);
30576 }, this);
30577
30578 if (!this.has_opted_out_tracking()) {
30579 _.each(this.__request_queue, function(item) {
30580 this._send_request.apply(this, item);
30581 }, this);
30582 }
30583
30584 delete this.__dom_loaded_queue;
30585 delete this.__request_queue;
30586 };
30587
30588 MixpanelLib.prototype._track_dom = function(DomClass, args) {
30589 if (this.get_config('img')) {
30590 this.report_error('You can\'t use DOM tracking functions with img = true.');
30591 return false;
30592 }
30593
30594 if (!DOM_LOADED) {
30595 this.__dom_loaded_queue.push([DomClass, args]);
30596 return false;
30597 }
30598
30599 var dt = new DomClass().init(this);
30600 return dt.track.apply(dt, args);
30601 };
30602
30603 /**
30604 * _prepare_callback() should be called by callers of _send_request for use
30605 * as the callback argument.
30606 *
30607 * If there is no callback, this returns null.
30608 * If we are going to make XHR/XDR requests, this returns a function.
30609 * If we are going to use script tags, this returns a string to use as the
30610 * callback GET param.
30611 */
30612 MixpanelLib.prototype._prepare_callback = function(callback, data) {
30613 if (_.isUndefined(callback)) {
30614 return null;
30615 }
30616
30617 if (USE_XHR) {
30618 var callback_function = function(response) {
30619 callback(response, data);
30620 };
30621 return callback_function;
30622 } else {
30623 // if the user gives us a callback, we store as a random
30624 // property on this instances jsc function and update our
30625 // callback string to reflect that.
30626 var jsc = this['_jsc'];
30627 var randomized_cb = '' + Math.floor(Math.random() * 100000000);
30628 var callback_string = this.get_config('callback_fn') + '[' + randomized_cb + ']';
30629 jsc[randomized_cb] = function(response) {
30630 delete jsc[randomized_cb];
30631 callback(response, data);
30632 };
30633 return callback_string;
30634 }
30635 };
30636
30637 MixpanelLib.prototype._send_request = function(url, data, options, callback) {
30638 var succeeded = true;
30639
30640 if (ENQUEUE_REQUESTS) {
30641 this.__request_queue.push(arguments);
30642 return succeeded;
30643 }
30644
30645 var DEFAULT_OPTIONS = {
30646 method: this.get_config('api_method'),
30647 transport: this.get_config('api_transport'),
30648 verbose: this.get_config('verbose')
30649 };
30650 var body_data = null;
30651
30652 if (!callback && (_.isFunction(options) || typeof options === 'string')) {
30653 callback = options;
30654 options = null;
30655 }
30656 options = _.extend(DEFAULT_OPTIONS, options || {});
30657 if (!USE_XHR) {
30658 options.method = 'GET';
30659 }
30660 var use_post = options.method === 'POST';
30661 var use_sendBeacon = sendBeacon && use_post && options.transport.toLowerCase() === 'sendbeacon';
30662
30663 // needed to correctly format responses
30664 var verbose_mode = options.verbose;
30665 if (data['verbose']) { verbose_mode = true; }
30666
30667 if (this.get_config('test')) { data['test'] = 1; }
30668 if (verbose_mode) { data['verbose'] = 1; }
30669 if (this.get_config('img')) { data['img'] = 1; }
30670 if (!USE_XHR) {
30671 if (callback) {
30672 data['callback'] = callback;
30673 } else if (verbose_mode || this.get_config('test')) {
30674 // Verbose output (from verbose mode, or an error in test mode) is a json blob,
30675 // which by itself is not valid javascript. Without a callback, this verbose output will
30676 // cause an error when returned via jsonp, so we force a no-op callback param.
30677 // See the ECMA script spec: http://www.ecma-international.org/ecma-262/5.1/#sec-12.4
30678 data['callback'] = '(function(){})';
30679 }
30680 }
30681
30682 data['ip'] = this.get_config('ip')?1:0;
30683 data['_'] = new Date().getTime().toString();
30684
30685 if (use_post) {
30686 body_data = 'data=' + encodeURIComponent(data['data']);
30687 delete data['data'];
30688 }
30689
30690 _.extend(data, this.get_config('api_extra_query_params'));
30691
30692 url += '?' + _.HTTPBuildQuery(data);
30693
30694 var lib = this;
30695 if ('img' in data) {
30696 var img = document$1.createElement('img');
30697 img.src = url;
30698 document$1.body.appendChild(img);
30699 } else if (use_sendBeacon) {
30700 try {
30701 succeeded = sendBeacon(url, body_data);
30702 } catch (e) {
30703 lib.report_error(e);
30704 succeeded = false;
30705 }
30706 try {
30707 if (callback) {
30708 callback(succeeded ? 1 : 0);
30709 }
30710 } catch (e) {
30711 lib.report_error(e);
30712 }
30713 } else if (USE_XHR) {
30714 try {
30715 var req = new XMLHttpRequest();
30716 req.open(options.method, url, true);
30717
30718 var headers = this.get_config('xhr_headers');
30719 if (use_post) {
30720 headers['Content-Type'] = 'application/x-www-form-urlencoded';
30721 }
30722 _.each(headers, function(headerValue, headerName) {
30723 req.setRequestHeader(headerName, headerValue);
30724 });
30725
30726 if (options.timeout_ms && typeof req.timeout !== 'undefined') {
30727 req.timeout = options.timeout_ms;
30728 var start_time = new Date().getTime();
30729 }
30730
30731 // send the mp_optout cookie
30732 // withCredentials cannot be modified until after calling .open on Android and Mobile Safari
30733 req.withCredentials = true;
30734 req.onreadystatechange = function () {
30735 if (req.readyState === 4) { // XMLHttpRequest.DONE == 4, except in safari 4
30736 if (req.status === 200) {
30737 if (callback) {
30738 if (verbose_mode) {
30739 var response;
30740 try {
30741 response = _.JSONDecode(req.responseText);
30742 } catch (e) {
30743 lib.report_error(e);
30744 if (options.ignore_json_errors) {
30745 response = req.responseText;
30746 } else {
30747 return;
30748 }
30749 }
30750 callback(response);
30751 } else {
30752 callback(Number(req.responseText));
30753 }
30754 }
30755 } else {
30756 var error;
30757 if (
30758 req.timeout &&
30759 !req.status &&
30760 new Date().getTime() - start_time >= req.timeout
30761 ) {
30762 error = 'timeout';
30763 } else {
30764 error = 'Bad HTTP status: ' + req.status + ' ' + req.statusText;
30765 }
30766 lib.report_error(error);
30767 if (callback) {
30768 if (verbose_mode) {
30769 var response_headers = req['responseHeaders'] || {};
30770 callback({status: 0, httpStatusCode: req['status'], error: error, retryAfter: response_headers['Retry-After']});
30771 } else {
30772 callback(0);
30773 }
30774 }
30775 }
30776 }
30777 };
30778 req.send(body_data);
30779 } catch (e) {
30780 lib.report_error(e);
30781 succeeded = false;
30782 }
30783 } else {
30784 var script = document$1.createElement('script');
30785 script.type = 'text/javascript';
30786 script.async = true;
30787 script.defer = true;
30788 script.src = url;
30789 var s = document$1.getElementsByTagName('script')[0];
30790 s.parentNode.insertBefore(script, s);
30791 }
30792
30793 return succeeded;
30794 };
30795
30796 /**
30797 * _execute_array() deals with processing any mixpanel function
30798 * calls that were called before the Mixpanel library were loaded
30799 * (and are thus stored in an array so they can be called later)
30800 *
30801 * Note: we fire off all the mixpanel function calls && user defined
30802 * functions BEFORE we fire off mixpanel tracking calls. This is so
30803 * identify/register/set_config calls can properly modify early
30804 * tracking calls.
30805 *
30806 * @param {Array} array
30807 */
30808 MixpanelLib.prototype._execute_array = function(array) {
30809 var fn_name, alias_calls = [], other_calls = [], tracking_calls = [];
30810 _.each(array, function(item) {
30811 if (item) {
30812 fn_name = item[0];
30813 if (_.isArray(fn_name)) {
30814 tracking_calls.push(item); // chained call e.g. mixpanel.get_group().set()
30815 } else if (typeof(item) === 'function') {
30816 item.call(this);
30817 } else if (_.isArray(item) && fn_name === 'alias') {
30818 alias_calls.push(item);
30819 } else if (_.isArray(item) && fn_name.indexOf('track') !== -1 && typeof(this[fn_name]) === 'function') {
30820 tracking_calls.push(item);
30821 } else {
30822 other_calls.push(item);
30823 }
30824 }
30825 }, this);
30826
30827 var execute = function(calls, context) {
30828 _.each(calls, function(item) {
30829 if (_.isArray(item[0])) {
30830 // chained call
30831 var caller = context;
30832 _.each(item, function(call) {
30833 caller = caller[call[0]].apply(caller, call.slice(1));
30834 });
30835 } else {
30836 this[item[0]].apply(this, item.slice(1));
30837 }
30838 }, context);
30839 };
30840
30841 execute(alias_calls, this);
30842 execute(other_calls, this);
30843 execute(tracking_calls, this);
30844 };
30845
30846 // request queueing utils
30847
30848 MixpanelLib.prototype.are_batchers_initialized = function() {
30849 return !!this.request_batchers.events;
30850 };
30851
30852 MixpanelLib.prototype.get_batcher_configs = function() {
30853 var queue_prefix = '__mpq_' + this.get_config('token');
30854 this._batcher_configs = this._batcher_configs || {
30855 events: {type: 'events', api_name: 'track', queue_key: queue_prefix + '_ev'},
30856 people: {type: 'people', api_name: 'engage', queue_key: queue_prefix + '_pp'},
30857 groups: {type: 'groups', api_name: 'groups', queue_key: queue_prefix + '_gr'}
30858 };
30859 return this._batcher_configs;
30860 };
30861
30862 MixpanelLib.prototype.init_batchers = function() {
30863 if (!this.are_batchers_initialized()) {
30864 var batcher_for = _.bind(function(attrs) {
30865 return new RequestBatcher(
30866 attrs.queue_key,
30867 {
30868 libConfig: this['config'],
30869 errorReporter: this.get_config('error_reporter'),
30870 sendRequestFunc: _.bind(function(data, options, cb) {
30871 var api_routes = this.get_config('api_routes');
30872 this._send_request(
30873 this.get_api_host(attrs.api_name) + '/' + api_routes[attrs.api_name],
30874 this._encode_data_for_request(data),
30875 options,
30876 this._prepare_callback(cb, data)
30877 );
30878 }, this),
30879 beforeSendHook: _.bind(function(item) {
30880 return this._run_hook('before_send_' + attrs.type, item);
30881 }, this),
30882 stopAllBatchingFunc: _.bind(this.stop_batch_senders, this),
30883 usePersistence: true,
30884 }
30885 );
30886 }, this);
30887 var batcher_configs = this.get_batcher_configs();
30888 this.request_batchers = {
30889 events: batcher_for(batcher_configs.events),
30890 people: batcher_for(batcher_configs.people),
30891 groups: batcher_for(batcher_configs.groups)
30892 };
30893 }
30894 if (this.get_config('batch_autostart')) {
30895 this.start_batch_senders();
30896 }
30897 };
30898
30899 MixpanelLib.prototype.start_batch_senders = function() {
30900 this._batchers_were_started = true;
30901 if (this.are_batchers_initialized()) {
30902 this._batch_requests = true;
30903 _.each(this.request_batchers, function(batcher) {
30904 batcher.start();
30905 });
30906 }
30907 };
30908
30909 MixpanelLib.prototype.stop_batch_senders = function() {
30910 this._batch_requests = false;
30911 _.each(this.request_batchers, function(batcher) {
30912 batcher.stop();
30913 batcher.clear();
30914 });
30915 };
30916
30917 /**
30918 * push() keeps the standard async-array-push
30919 * behavior around after the lib is loaded.
30920 * This is only useful for external integrations that
30921 * do not wish to rely on our convenience methods
30922 * (created in the snippet).
30923 *
30924 * ### Usage:
30925 * mixpanel.push(['register', { a: 'b' }]);
30926 *
30927 * @param {Array} item A [function_name, args...] array to be executed
30928 */
30929 MixpanelLib.prototype.push = function(item) {
30930 this._execute_array([item]);
30931 };
30932
30933 /**
30934 * Disable events on the Mixpanel object. If passed no arguments,
30935 * this function disables tracking of any event. If passed an
30936 * array of event names, those events will be disabled, but other
30937 * events will continue to be tracked.
30938 *
30939 * Note: this function does not stop other mixpanel functions from
30940 * firing, such as register() or people.set().
30941 *
30942 * @param {Array} [events] An array of event names to disable
30943 */
30944 MixpanelLib.prototype.disable = function(events) {
30945 if (typeof(events) === 'undefined') {
30946 this._flags.disable_all_events = true;
30947 } else {
30948 this.__disabled_events = this.__disabled_events.concat(events);
30949 }
30950 };
30951
30952 MixpanelLib.prototype._encode_data_for_request = function(data) {
30953 var encoded_data = JSONStringify(data);
30954 if (this.get_config('api_payload_format') === PAYLOAD_TYPE_BASE64) {
30955 encoded_data = _.base64Encode(encoded_data);
30956 }
30957 return {'data': encoded_data};
30958 };
30959
30960 // internal method for handling track vs batch-enqueue logic
30961 MixpanelLib.prototype._track_or_batch = function(options, callback) {
30962 var truncated_data = _.truncate(options.data, 255);
30963 var endpoint = options.endpoint;
30964 var batcher = options.batcher;
30965 var should_send_immediately = options.should_send_immediately;
30966 var send_request_options = options.send_request_options || {};
30967 callback = callback || NOOP_FUNC;
30968
30969 var request_enqueued_or_initiated = true;
30970 var send_request_immediately = _.bind(function() {
30971 if (!send_request_options.skip_hooks) {
30972 truncated_data = this._run_hook('before_send_' + options.type, truncated_data);
30973 }
30974 if (truncated_data) {
30975 console$1.log('MIXPANEL REQUEST:');
30976 console$1.log(truncated_data);
30977 return this._send_request(
30978 endpoint,
30979 this._encode_data_for_request(truncated_data),
30980 send_request_options,
30981 this._prepare_callback(callback, truncated_data)
30982 );
30983 } else {
30984 return null;
30985 }
30986 }, this);
30987
30988 if (this._batch_requests && !should_send_immediately) {
30989 batcher.enqueue(truncated_data).then(function(succeeded) {
30990 if (succeeded) {
30991 callback(1, truncated_data);
30992 } else {
30993 send_request_immediately();
30994 }
30995 });
30996 } else {
30997 request_enqueued_or_initiated = send_request_immediately();
30998 }
30999
31000 return request_enqueued_or_initiated && truncated_data;
31001 };
31002
31003 /**
31004 * Track an event. This is the most important and
31005 * frequently used Mixpanel function.
31006 *
31007 * ### Usage:
31008 *
31009 * // track an event named 'Registered'
31010 * mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
31011 *
31012 * // track an event using navigator.sendBeacon
31013 * mixpanel.track('Left page', {'duration_seconds': 35}, {transport: 'sendBeacon'});
31014 *
31015 * To track link clicks or form submissions, see track_links() or track_forms().
31016 *
31017 * @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
31018 * @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.
31019 * @param {Object} [options] Optional configuration for this track request.
31020 * @param {String} [options.transport] Transport method for network request ('xhr' or 'sendBeacon').
31021 * @param {Boolean} [options.send_immediately] Whether to bypass batching/queueing and send track request immediately.
31022 * @param {Function} [callback] If provided, the callback function will be called after tracking the event.
31023 * @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
31024 * with the tracking payload sent to the API server is returned; otherwise false.
31025 */
31026 MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, properties, options, callback) {
31027 if (!callback && typeof options === 'function') {
31028 callback = options;
31029 options = null;
31030 }
31031 options = options || {};
31032 var transport = options['transport']; // external API, don't minify 'transport' prop
31033 if (transport) {
31034 options.transport = transport; // 'transport' prop name can be minified internally
31035 }
31036 var should_send_immediately = options['send_immediately'];
31037 if (typeof callback !== 'function') {
31038 callback = NOOP_FUNC;
31039 }
31040
31041 if (_.isUndefined(event_name)) {
31042 this.report_error('No event name provided to mixpanel.track');
31043 return;
31044 }
31045
31046 if (this._event_is_disabled(event_name)) {
31047 callback(0);
31048 return;
31049 }
31050
31051 // set defaults
31052 properties = _.extend({}, properties);
31053 properties['token'] = this.get_config('token');
31054
31055 // set $duration if time_event was previously called for this event
31056 var start_timestamp = this['persistence'].remove_event_timer(event_name);
31057 if (!_.isUndefined(start_timestamp)) {
31058 var duration_in_ms = new Date().getTime() - start_timestamp;
31059 properties['$duration'] = parseFloat((duration_in_ms / 1000).toFixed(3));
31060 }
31061
31062 this._set_default_superprops();
31063
31064 var marketing_properties = this.get_config('track_marketing')
31065 ? _.info.marketingParams()
31066 : {};
31067
31068 // note: extend writes to the first object, so lets make sure we
31069 // don't write to the persistence properties object and info
31070 // properties object by passing in a new object
31071
31072 // update properties with pageview info and super-properties
31073 properties = _.extend(
31074 {},
31075 _.info.properties({'mp_loader': this.get_config('mp_loader')}),
31076 marketing_properties,
31077 this['persistence'].properties(),
31078 this.unpersisted_superprops,
31079 this.get_session_recording_properties(),
31080 properties
31081 );
31082
31083 var property_blacklist = this.get_config('property_blacklist');
31084 if (_.isArray(property_blacklist)) {
31085 _.each(property_blacklist, function(blacklisted_prop) {
31086 delete properties[blacklisted_prop];
31087 });
31088 } else {
31089 this.report_error('Invalid value for property_blacklist config: ' + property_blacklist);
31090 }
31091
31092 var data = {
31093 'event': event_name,
31094 'properties': properties
31095 };
31096 var ret = this._track_or_batch({
31097 type: 'events',
31098 data: data,
31099 endpoint: this.get_api_host('events') + '/' + this.get_config('api_routes')['track'],
31100 batcher: this.request_batchers.events,
31101 should_send_immediately: should_send_immediately,
31102 send_request_options: options
31103 }, callback);
31104
31105 return ret;
31106 });
31107
31108 /**
31109 * Register the current user into one/many groups.
31110 *
31111 * ### Usage:
31112 *
31113 * mixpanel.set_group('company', ['mixpanel', 'google']) // an array of IDs
31114 * mixpanel.set_group('company', 'mixpanel')
31115 * mixpanel.set_group('company', 128746312)
31116 *
31117 * @param {String} group_key Group key
31118 * @param {Array|String|Number} group_ids An array of group IDs, or a singular group ID
31119 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
31120 *
31121 */
31122 MixpanelLib.prototype.set_group = addOptOutCheckMixpanelLib(function(group_key, group_ids, callback) {
31123 if (!_.isArray(group_ids)) {
31124 group_ids = [group_ids];
31125 }
31126 var prop = {};
31127 prop[group_key] = group_ids;
31128 this.register(prop);
31129 return this['people'].set(group_key, group_ids, callback);
31130 });
31131
31132 /**
31133 * Add a new group for this user.
31134 *
31135 * ### Usage:
31136 *
31137 * mixpanel.add_group('company', 'mixpanel')
31138 *
31139 * @param {String} group_key Group key
31140 * @param {*} group_id A valid Mixpanel property type
31141 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
31142 */
31143 MixpanelLib.prototype.add_group = addOptOutCheckMixpanelLib(function(group_key, group_id, callback) {
31144 var old_values = this.get_property(group_key);
31145 var prop = {};
31146 if (old_values === undefined) {
31147 prop[group_key] = [group_id];
31148 this.register(prop);
31149 } else {
31150 if (old_values.indexOf(group_id) === -1) {
31151 old_values.push(group_id);
31152 prop[group_key] = old_values;
31153 this.register(prop);
31154 }
31155 }
31156 return this['people'].union(group_key, group_id, callback);
31157 });
31158
31159 /**
31160 * Remove a group from this user.
31161 *
31162 * ### Usage:
31163 *
31164 * mixpanel.remove_group('company', 'mixpanel')
31165 *
31166 * @param {String} group_key Group key
31167 * @param {*} group_id A valid Mixpanel property type
31168 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
31169 */
31170 MixpanelLib.prototype.remove_group = addOptOutCheckMixpanelLib(function(group_key, group_id, callback) {
31171 var old_value = this.get_property(group_key);
31172 // if the value doesn't exist, the persistent store is unchanged
31173 if (old_value !== undefined) {
31174 var idx = old_value.indexOf(group_id);
31175 if (idx > -1) {
31176 old_value.splice(idx, 1);
31177 this.register({group_key: old_value});
31178 }
31179 if (old_value.length === 0) {
31180 this.unregister(group_key);
31181 }
31182 }
31183 return this['people'].remove(group_key, group_id, callback);
31184 });
31185
31186 /**
31187 * Track an event with specific groups.
31188 *
31189 * ### Usage:
31190 *
31191 * mixpanel.track_with_groups('purchase', {'product': 'iphone'}, {'University': ['UCB', 'UCLA']})
31192 *
31193 * @param {String} event_name The name of the event (see `mixpanel.track()`)
31194 * @param {Object=} properties A set of properties to include with the event you're sending (see `mixpanel.track()`)
31195 * @param {Object=} groups An object mapping group name keys to one or more values
31196 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
31197 */
31198 MixpanelLib.prototype.track_with_groups = addOptOutCheckMixpanelLib(function(event_name, properties, groups, callback) {
31199 var tracking_props = _.extend({}, properties || {});
31200 _.each(groups, function(v, k) {
31201 if (v !== null && v !== undefined) {
31202 tracking_props[k] = v;
31203 }
31204 });
31205 return this.track(event_name, tracking_props, callback);
31206 });
31207
31208 MixpanelLib.prototype._create_map_key = function (group_key, group_id) {
31209 return group_key + '_' + JSON.stringify(group_id);
31210 };
31211
31212 MixpanelLib.prototype._remove_group_from_cache = function (group_key, group_id) {
31213 delete this._cached_groups[this._create_map_key(group_key, group_id)];
31214 };
31215
31216 /**
31217 * Look up reference to a Mixpanel group
31218 *
31219 * ### Usage:
31220 *
31221 * mixpanel.get_group(group_key, group_id)
31222 *
31223 * @param {String} group_key Group key
31224 * @param {Object} group_id A valid Mixpanel property type
31225 * @returns {Object} A MixpanelGroup identifier
31226 */
31227 MixpanelLib.prototype.get_group = function (group_key, group_id) {
31228 var map_key = this._create_map_key(group_key, group_id);
31229 var group = this._cached_groups[map_key];
31230 if (group === undefined || group._group_key !== group_key || group._group_id !== group_id) {
31231 group = new MixpanelGroup();
31232 group._init(this, group_key, group_id);
31233 this._cached_groups[map_key] = group;
31234 }
31235 return group;
31236 };
31237
31238 /**
31239 * Track a default Mixpanel page view event, which includes extra default event properties to
31240 * improve page view data.
31241 *
31242 * ### Usage:
31243 *
31244 * // track a default $mp_web_page_view event
31245 * mixpanel.track_pageview();
31246 *
31247 * // track a page view event with additional event properties
31248 * mixpanel.track_pageview({'ab_test_variant': 'card-layout-b'});
31249 *
31250 * // example approach to track page views on different page types as event properties
31251 * mixpanel.track_pageview({'page': 'pricing'});
31252 * mixpanel.track_pageview({'page': 'homepage'});
31253 *
31254 * // UNCOMMON: Tracking a page view event with a custom event_name option. NOT expected to be used for
31255 * // individual pages on the same site or product. Use cases for custom event_name may be page
31256 * // views on different products or internal applications that are considered completely separate
31257 * mixpanel.track_pageview({'page': 'customer-search'}, {'event_name': '[internal] Admin Page View'});
31258 *
31259 * ### Notes:
31260 *
31261 * The `config.track_pageview` option for <a href="#mixpanelinit">mixpanel.init()</a>
31262 * may be turned on for tracking page loads automatically.
31263 *
31264 * // track only page loads
31265 * mixpanel.init(PROJECT_TOKEN, {track_pageview: true});
31266 *
31267 * // track when the URL changes in any manner
31268 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'full-url'});
31269 *
31270 * // track when the URL changes, ignoring any changes in the hash part
31271 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'url-with-path-and-query-string'});
31272 *
31273 * // track when the path changes, ignoring any query parameter or hash changes
31274 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'url-with-path'});
31275 *
31276 * @param {Object} [properties] An optional set of additional properties to send with the page view event
31277 * @param {Object} [options] Page view tracking options
31278 * @param {String} [options.event_name] - Alternate name for the tracking event
31279 * @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
31280 * with the tracking payload sent to the API server is returned; otherwise false.
31281 */
31282 MixpanelLib.prototype.track_pageview = addOptOutCheckMixpanelLib(function(properties, options) {
31283 if (typeof properties !== 'object') {
31284 properties = {};
31285 }
31286 options = options || {};
31287 var event_name = options['event_name'] || '$mp_web_page_view';
31288
31289 var default_page_properties = _.extend(
31290 _.info.mpPageViewProperties(),
31291 _.info.campaignParams(),
31292 _.info.clickParams()
31293 );
31294
31295 var event_properties = _.extend(
31296 {},
31297 default_page_properties,
31298 properties
31299 );
31300
31301 return this.track(event_name, event_properties);
31302 });
31303
31304 /**
31305 * Track clicks on a set of document elements. Selector must be a
31306 * valid query. Elements must exist on the page at the time track_links is called.
31307 *
31308 * ### Usage:
31309 *
31310 * // track click for link id #nav
31311 * mixpanel.track_links('#nav', 'Clicked Nav Link');
31312 *
31313 * ### Notes:
31314 *
31315 * This function will wait up to 300 ms for the Mixpanel
31316 * servers to respond. If they have not responded by that time
31317 * it will head to the link without ensuring that your event
31318 * has been tracked. To configure this timeout please see the
31319 * set_config() documentation below.
31320 *
31321 * If you pass a function in as the properties argument, the
31322 * function will receive the DOMElement that triggered the
31323 * event as an argument. You are expected to return an object
31324 * from the function; any properties defined on this object
31325 * will be sent to mixpanel as event properties.
31326 *
31327 * @type {Function}
31328 * @param {Object|String} query A valid DOM query, element or jQuery-esque list
31329 * @param {String} event_name The name of the event to track
31330 * @param {Object|Function} [properties] A properties object or function that returns a dictionary of properties when passed a DOMElement
31331 */
31332 MixpanelLib.prototype.track_links = function() {
31333 return this._track_dom.call(this, LinkTracker, arguments);
31334 };
31335
31336 /**
31337 * Track form submissions. Selector must be a valid query.
31338 *
31339 * ### Usage:
31340 *
31341 * // track submission for form id 'register'
31342 * mixpanel.track_forms('#register', 'Created Account');
31343 *
31344 * ### Notes:
31345 *
31346 * This function will wait up to 300 ms for the mixpanel
31347 * servers to respond, if they have not responded by that time
31348 * it will head to the link without ensuring that your event
31349 * has been tracked. To configure this timeout please see the
31350 * set_config() documentation below.
31351 *
31352 * If you pass a function in as the properties argument, the
31353 * function will receive the DOMElement that triggered the
31354 * event as an argument. You are expected to return an object
31355 * from the function; any properties defined on this object
31356 * will be sent to mixpanel as event properties.
31357 *
31358 * @type {Function}
31359 * @param {Object|String} query A valid DOM query, element or jQuery-esque list
31360 * @param {String} event_name The name of the event to track
31361 * @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
31362 */
31363 MixpanelLib.prototype.track_forms = function() {
31364 return this._track_dom.call(this, FormTracker, arguments);
31365 };
31366
31367 /**
31368 * Time an event by including the time between this call and a
31369 * later 'track' call for the same event in the properties sent
31370 * with the event.
31371 *
31372 * ### Usage:
31373 *
31374 * // time an event named 'Registered'
31375 * mixpanel.time_event('Registered');
31376 * mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
31377 *
31378 * When called for a particular event name, the next track call for that event
31379 * name will include the elapsed time between the 'time_event' and 'track'
31380 * calls. This value is stored as seconds in the '$duration' property.
31381 *
31382 * @param {String} event_name The name of the event.
31383 */
31384 MixpanelLib.prototype.time_event = function(event_name) {
31385 if (_.isUndefined(event_name)) {
31386 this.report_error('No event name provided to mixpanel.time_event');
31387 return;
31388 }
31389
31390 if (this._event_is_disabled(event_name)) {
31391 return;
31392 }
31393
31394 this['persistence'].set_event_timer(event_name, new Date().getTime());
31395 };
31396
31397 var REGISTER_DEFAULTS = {
31398 'persistent': true
31399 };
31400 /**
31401 * Helper to parse options param for register methods, maintaining
31402 * legacy support for plain "days" param instead of options object
31403 * @param {Number|Object} [days_or_options] 'days' option (Number), or Options object for register methods
31404 * @returns {Object} options object
31405 */
31406 var options_for_register = function(days_or_options) {
31407 var options;
31408 if (_.isObject(days_or_options)) {
31409 options = days_or_options;
31410 } else if (!_.isUndefined(days_or_options)) {
31411 options = {'days': days_or_options};
31412 } else {
31413 options = {};
31414 }
31415 return _.extend({}, REGISTER_DEFAULTS, options);
31416 };
31417
31418 /**
31419 * Register a set of super properties, which are included with all
31420 * events. This will overwrite previous super property values.
31421 *
31422 * ### Usage:
31423 *
31424 * // register 'Gender' as a super property
31425 * mixpanel.register({'Gender': 'Female'});
31426 *
31427 * // register several super properties when a user signs up
31428 * mixpanel.register({
31429 * 'Email': 'jdoe@example.com',
31430 * 'Account Type': 'Free'
31431 * });
31432 *
31433 * // register only for the current pageload
31434 * mixpanel.register({'Name': 'Pat'}, {persistent: false});
31435 *
31436 * @param {Object} properties An associative array of properties to store about the user
31437 * @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)
31438 * @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)
31439 * @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
31440 */
31441 MixpanelLib.prototype.register = function(props, days_or_options) {
31442 var options = options_for_register(days_or_options);
31443 if (options['persistent']) {
31444 this['persistence'].register(props, options['days']);
31445 } else {
31446 _.extend(this.unpersisted_superprops, props);
31447 }
31448 };
31449
31450 /**
31451 * Register a set of super properties only once. This will not
31452 * overwrite previous super property values, unlike register().
31453 *
31454 * ### Usage:
31455 *
31456 * // register a super property for the first time only
31457 * mixpanel.register_once({
31458 * 'First Login Date': new Date().toISOString()
31459 * });
31460 *
31461 * // register once, only for the current pageload
31462 * mixpanel.register_once({
31463 * 'First interaction time': new Date().toISOString()
31464 * }, 'None', {persistent: false});
31465 *
31466 * ### Notes:
31467 *
31468 * If default_value is specified, current super properties
31469 * with that value will be overwritten.
31470 *
31471 * @param {Object} properties An associative array of properties to store about the user
31472 * @param {*} [default_value] Value to override if already set in super properties (ex: 'False') Default: 'None'
31473 * @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)
31474 * @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)
31475 * @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
31476 */
31477 MixpanelLib.prototype.register_once = function(props, default_value, days_or_options) {
31478 var options = options_for_register(days_or_options);
31479 if (options['persistent']) {
31480 this['persistence'].register_once(props, default_value, options['days']);
31481 } else {
31482 if (typeof(default_value) === 'undefined') {
31483 default_value = 'None';
31484 }
31485 _.each(props, function(val, prop) {
31486 if (!this.unpersisted_superprops.hasOwnProperty(prop) || this.unpersisted_superprops[prop] === default_value) {
31487 this.unpersisted_superprops[prop] = val;
31488 }
31489 }, this);
31490 }
31491 };
31492
31493 /**
31494 * Delete a super property stored with the current user.
31495 *
31496 * @param {String} property The name of the super property to remove
31497 * @param {Object} [options]
31498 * @param {boolean} [options.persistent=true] - whether to look in persistent storage (cookie/localStorage)
31499 */
31500 MixpanelLib.prototype.unregister = function(property, options) {
31501 options = options_for_register(options);
31502 if (options['persistent']) {
31503 this['persistence'].unregister(property);
31504 } else {
31505 delete this.unpersisted_superprops[property];
31506 }
31507 };
31508
31509 MixpanelLib.prototype._register_single = function(prop, value) {
31510 var props = {};
31511 props[prop] = value;
31512 this.register(props);
31513 };
31514
31515 /**
31516 * Identify a user with a unique ID to track user activity across
31517 * devices, tie a user to their events, and create a user profile.
31518 * If you never call this method, unique visitors are tracked using
31519 * a UUID generated the first time they visit the site.
31520 *
31521 * Call identify when you know the identity of the current user,
31522 * typically after login or signup. We recommend against using
31523 * identify for anonymous visitors to your site.
31524 *
31525 * ### Notes:
31526 * If your project has
31527 * <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a>
31528 * enabled, the identify method will connect pre- and
31529 * post-authentication events when appropriate.
31530 *
31531 * If your project does not have ID Merge enabled, identify will
31532 * change the user's local distinct_id to the unique ID you pass.
31533 * Events tracked prior to authentication will not be connected
31534 * to the same user identity. If ID Merge is disabled, alias can
31535 * be used to connect pre- and post-registration events.
31536 *
31537 * @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.
31538 */
31539 MixpanelLib.prototype.identify = function(
31540 new_distinct_id, _set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback
31541 ) {
31542 // Optional Parameters
31543 // _set_callback:function A callback to be run if and when the People set queue is flushed
31544 // _add_callback:function A callback to be run if and when the People add queue is flushed
31545 // _append_callback:function A callback to be run if and when the People append queue is flushed
31546 // _set_once_callback:function A callback to be run if and when the People set_once queue is flushed
31547 // _union_callback:function A callback to be run if and when the People union queue is flushed
31548 // _unset_callback:function A callback to be run if and when the People unset queue is flushed
31549
31550 var previous_distinct_id = this.get_distinct_id();
31551 if (new_distinct_id && previous_distinct_id !== new_distinct_id) {
31552 // we allow the following condition if previous distinct_id is same as new_distinct_id
31553 // so that you can force flush people updates for anonymous profiles.
31554 if (typeof new_distinct_id === 'string' && new_distinct_id.indexOf(DEVICE_ID_PREFIX) === 0) {
31555 this.report_error('distinct_id cannot have $device: prefix');
31556 return -1;
31557 }
31558 this.register({'$user_id': new_distinct_id});
31559 }
31560
31561 if (!this.get_property('$device_id')) {
31562 // The persisted distinct id might not actually be a device id at all
31563 // it might be a distinct id of the user from before
31564 var device_id = previous_distinct_id;
31565 this.register_once({
31566 '$had_persisted_distinct_id': true,
31567 '$device_id': device_id
31568 }, '');
31569 }
31570
31571 // identify only changes the distinct id if it doesn't match either the existing or the alias;
31572 // if it's new, blow away the alias as well.
31573 if (new_distinct_id !== previous_distinct_id && new_distinct_id !== this.get_property(ALIAS_ID_KEY)) {
31574 this.unregister(ALIAS_ID_KEY);
31575 this.register({'distinct_id': new_distinct_id});
31576 }
31577 this._flags.identify_called = true;
31578 // Flush any queued up people requests
31579 this['people']._flush(_set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback);
31580
31581 // send an $identify event any time the distinct_id is changing - logic on the server
31582 // will determine whether or not to do anything with it.
31583 if (new_distinct_id !== previous_distinct_id) {
31584 this.track('$identify', {
31585 'distinct_id': new_distinct_id,
31586 '$anon_distinct_id': previous_distinct_id
31587 }, {skip_hooks: true});
31588 }
31589
31590 // check feature flags again if distinct id has changed
31591 if (new_distinct_id !== previous_distinct_id) {
31592 this.flags.fetchFlags();
31593 }
31594 };
31595
31596 /**
31597 * Clears super properties and generates a new random distinct_id for this instance.
31598 * Useful for clearing data when a user logs out.
31599 */
31600 MixpanelLib.prototype.reset = function() {
31601 this.stop_session_recording();
31602 this['persistence'].clear();
31603 this._flags.identify_called = false;
31604 var uuid = _.UUID();
31605 this.register_once({
31606 'distinct_id': DEVICE_ID_PREFIX + uuid,
31607 '$device_id': uuid
31608 }, '');
31609 this._check_and_start_session_recording();
31610 };
31611
31612 /**
31613 * Returns the current distinct id of the user. This is either the id automatically
31614 * generated by the library or the id that has been passed by a call to identify().
31615 *
31616 * ### Notes:
31617 *
31618 * get_distinct_id() can only be called after the Mixpanel library has finished loading.
31619 * init() has a loaded function available to handle this automatically. For example:
31620 *
31621 * // set distinct_id after the mixpanel library has loaded
31622 * mixpanel.init('YOUR PROJECT TOKEN', {
31623 * loaded: function(mixpanel) {
31624 * distinct_id = mixpanel.get_distinct_id();
31625 * }
31626 * });
31627 */
31628 MixpanelLib.prototype.get_distinct_id = function() {
31629 return this.get_property('distinct_id');
31630 };
31631
31632 /**
31633 * The alias method creates an alias which Mixpanel will use to
31634 * remap one id to another. Multiple aliases can point to the
31635 * same identifier.
31636 *
31637 * The following is a valid use of alias:
31638 *
31639 * mixpanel.alias('new_id', 'existing_id');
31640 * // You can add multiple id aliases to the existing ID
31641 * mixpanel.alias('newer_id', 'existing_id');
31642 *
31643 * Aliases can also be chained - the following is a valid example:
31644 *
31645 * mixpanel.alias('new_id', 'existing_id');
31646 * // chain newer_id - new_id - existing_id
31647 * mixpanel.alias('newer_id', 'new_id');
31648 *
31649 * Aliases cannot point to multiple identifiers - the following
31650 * example will not work:
31651 *
31652 * mixpanel.alias('new_id', 'existing_id');
31653 * // this is invalid as 'new_id' already points to 'existing_id'
31654 * mixpanel.alias('new_id', 'newer_id');
31655 *
31656 * ### Notes:
31657 *
31658 * If your project does not have
31659 * <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a>
31660 * enabled, the best practice is to call alias once when a unique
31661 * ID is first created for a user (e.g., when a user first registers
31662 * for an account). Do not use alias multiple times for a single
31663 * user without ID Merge enabled.
31664 *
31665 * @param {String} alias A unique identifier that you want to use for this user in the future.
31666 * @param {String} [original] The current identifier being used for this user.
31667 */
31668 MixpanelLib.prototype.alias = function(alias, original) {
31669 // If the $people_distinct_id key exists in persistence, there has been a previous
31670 // mixpanel.people.identify() call made for this user. It is VERY BAD to make an alias with
31671 // this ID, as it will duplicate users.
31672 if (alias === this.get_property(PEOPLE_DISTINCT_ID_KEY)) {
31673 this.report_error('Attempting to create alias for existing People user - aborting.');
31674 return -2;
31675 }
31676
31677 var _this = this;
31678 if (_.isUndefined(original)) {
31679 original = this.get_distinct_id();
31680 }
31681 if (alias !== original) {
31682 this._register_single(ALIAS_ID_KEY, alias);
31683 return this.track('$create_alias', {
31684 'alias': alias,
31685 'distinct_id': original
31686 }, {
31687 skip_hooks: true
31688 }, function() {
31689 // Flush the people queue
31690 _this.identify(alias);
31691 });
31692 } else {
31693 this.report_error('alias matches current distinct_id - skipping api call.');
31694 this.identify(alias);
31695 return -1;
31696 }
31697 };
31698
31699 /**
31700 * Provide a string to recognize the user by. The string passed to
31701 * this method will appear in the Mixpanel Streams product rather
31702 * than an automatically generated name. Name tags do not have to
31703 * be unique.
31704 *
31705 * This value will only be included in Streams data.
31706 *
31707 * @param {String} name_tag A human readable name for the user
31708 * @deprecated
31709 */
31710 MixpanelLib.prototype.name_tag = function(name_tag) {
31711 this._register_single('mp_name_tag', name_tag);
31712 };
31713
31714 /**
31715 * Update the configuration of a mixpanel library instance.
31716 *
31717 * The default config is:
31718 *
31719 * {
31720 * // host for requests (customizable for e.g. a local proxy)
31721 * api_host: 'https://api-js.mixpanel.com',
31722 *
31723 * // endpoints for different types of requests
31724 * api_routes: {
31725 * track: 'track/',
31726 * engage: 'engage/',
31727 * groups: 'groups/',
31728 * }
31729 *
31730 * // HTTP method for tracking requests
31731 * api_method: 'POST'
31732 *
31733 * // transport for sending requests ('XHR' or 'sendBeacon')
31734 * // NB: sendBeacon should only be used for scenarios such as
31735 * // page unload where a "best-effort" attempt to send is
31736 * // acceptable; the sendBeacon API does not support callbacks
31737 * // or any way to know the result of the request. Mixpanel
31738 * // tracking via sendBeacon will not support any event-
31739 * // batching or retry mechanisms.
31740 * api_transport: 'XHR'
31741 *
31742 * // request-batching/queueing/retry
31743 * batch_requests: true,
31744 *
31745 * // maximum number of events/updates to send in a single
31746 * // network request
31747 * batch_size: 50,
31748 *
31749 * // milliseconds to wait between sending batch requests
31750 * batch_flush_interval_ms: 5000,
31751 *
31752 * // milliseconds to wait for network responses to batch requests
31753 * // before they are considered timed-out and retried
31754 * batch_request_timeout_ms: 90000,
31755 *
31756 * // override value for cookie domain, only useful for ensuring
31757 * // correct cross-subdomain cookies on unusual domains like
31758 * // subdomain.mainsite.avocat.fr; NB this cannot be used to
31759 * // set cookies on a different domain than the current origin
31760 * cookie_domain: ''
31761 *
31762 * // super properties cookie expiration (in days)
31763 * cookie_expiration: 365
31764 *
31765 * // if true, cookie will be set with SameSite=None; Secure
31766 * // this is only useful in special situations, like embedded
31767 * // 3rd-party iframes that set up a Mixpanel instance
31768 * cross_site_cookie: false
31769 *
31770 * // super properties span subdomains
31771 * cross_subdomain_cookie: true
31772 *
31773 * // debug mode
31774 * debug: false
31775 *
31776 * // if this is true, the mixpanel cookie or localStorage entry
31777 * // will be deleted, and no user persistence will take place
31778 * disable_persistence: false
31779 *
31780 * // if this is true, Mixpanel will automatically determine
31781 * // City, Region and Country data using the IP address of
31782 * //the client
31783 * ip: true
31784 *
31785 * // opt users out of tracking by this Mixpanel instance by default
31786 * opt_out_tracking_by_default: false
31787 *
31788 * // opt users out of browser data storage by this Mixpanel instance by default
31789 * opt_out_persistence_by_default: false
31790 *
31791 * // persistence mechanism used by opt-in/opt-out methods - cookie
31792 * // or localStorage - falls back to cookie if localStorage is unavailable
31793 * opt_out_tracking_persistence_type: 'localStorage'
31794 *
31795 * // customize the name of cookie/localStorage set by opt-in/opt-out methods
31796 * opt_out_tracking_cookie_prefix: null
31797 *
31798 * // type of persistent store for super properties (cookie/
31799 * // localStorage) if set to 'localStorage', any existing
31800 * // mixpanel cookie value with the same persistence_name
31801 * // will be transferred to localStorage and deleted
31802 * persistence: 'cookie'
31803 *
31804 * // name for super properties persistent store
31805 * persistence_name: ''
31806 *
31807 * // names of properties/superproperties which should never
31808 * // be sent with track() calls
31809 * property_blacklist: []
31810 *
31811 * // if this is true, mixpanel cookies will be marked as
31812 * // secure, meaning they will only be transmitted over https
31813 * secure_cookie: false
31814 *
31815 * // disables enriching user profiles with first touch marketing data
31816 * skip_first_touch_marketing: false
31817 *
31818 * // the amount of time track_links will
31819 * // wait for Mixpanel's servers to respond
31820 * track_links_timeout: 300
31821 *
31822 * // adds any UTM parameters and click IDs present on the page to any events fired
31823 * track_marketing: true
31824 *
31825 * // enables automatic page view tracking using default page view events through
31826 * // the track_pageview() method
31827 * track_pageview: false
31828 *
31829 * // if you set upgrade to be true, the library will check for
31830 * // a cookie from our old js library and import super
31831 * // properties from it, then the old cookie is deleted
31832 * // The upgrade config option only works in the initialization,
31833 * // so make sure you set it when you create the library.
31834 * upgrade: false
31835 *
31836 * // extra HTTP request headers to set for each API request, in
31837 * // the format {'Header-Name': value}
31838 * xhr_headers: {}
31839 *
31840 * // whether to ignore or respect the web browser's Do Not Track setting
31841 * ignore_dnt: false
31842 * }
31843 *
31844 *
31845 * @param {Object} config A dictionary of new configuration values to update
31846 */
31847 MixpanelLib.prototype.set_config = function(config) {
31848 if (_.isObject(config)) {
31849 _.extend(this['config'], config);
31850
31851 var new_batch_size = config['batch_size'];
31852 if (new_batch_size) {
31853 _.each(this.request_batchers, function(batcher) {
31854 batcher.resetBatchSize();
31855 });
31856 }
31857
31858 if (!this.get_config('persistence_name')) {
31859 this['config']['persistence_name'] = this['config']['cookie_name'];
31860 }
31861 if (!this.get_config('disable_persistence')) {
31862 this['config']['disable_persistence'] = this['config']['disable_cookie'];
31863 }
31864
31865 if (this['persistence']) {
31866 this['persistence'].update_config(this['config']);
31867 }
31868 Config.DEBUG = Config.DEBUG || this.get_config('debug');
31869
31870 if (('autocapture' in config || 'record_heatmap_data' in config) && this.autocapture) {
31871 this.autocapture.init();
31872 }
31873 }
31874 };
31875
31876 /**
31877 * returns the current config object for the library.
31878 */
31879 MixpanelLib.prototype.get_config = function(prop_name) {
31880 return this['config'][prop_name];
31881 };
31882
31883 /**
31884 * Fetch a hook function from config, with safe default, and run it
31885 * against the given arguments
31886 * @param {string} hook_name which hook to retrieve
31887 * @returns {any|null} return value of user-provided hook, or null if nothing was returned
31888 */
31889 MixpanelLib.prototype._run_hook = function(hook_name) {
31890 var ret = (this['config']['hooks'][hook_name] || IDENTITY_FUNC).apply(this, slice.call(arguments, 1));
31891 if (typeof ret === 'undefined') {
31892 this.report_error(hook_name + ' hook did not return a value');
31893 ret = null;
31894 }
31895 return ret;
31896 };
31897
31898 /**
31899 * Returns the value of the super property named property_name. If no such
31900 * property is set, get_property() will return the undefined value.
31901 *
31902 * ### Notes:
31903 *
31904 * get_property() can only be called after the Mixpanel library has finished loading.
31905 * init() has a loaded function available to handle this automatically. For example:
31906 *
31907 * // grab value for 'user_id' after the mixpanel library has loaded
31908 * mixpanel.init('YOUR PROJECT TOKEN', {
31909 * loaded: function(mixpanel) {
31910 * user_id = mixpanel.get_property('user_id');
31911 * }
31912 * });
31913 *
31914 * @param {String} property_name The name of the super property you want to retrieve
31915 */
31916 MixpanelLib.prototype.get_property = function(property_name) {
31917 return this['persistence'].load_prop([property_name]);
31918 };
31919
31920 /**
31921 * Get the API host for a specific endpoint type, falling back to the default api_host if not specified
31922 *
31923 * @param {String} endpoint_type The type of endpoint (e.g., "events", "people", "groups")
31924 * @returns {String} The API host to use for this endpoint
31925 */
31926 MixpanelLib.prototype.get_api_host = function(endpoint_type) {
31927 return this.get_config('api_hosts')[endpoint_type] || this.get_config('api_host');
31928 };
31929
31930 MixpanelLib.prototype.toString = function() {
31931 var name = this.get_config('name');
31932 if (name !== PRIMARY_INSTANCE_NAME) {
31933 name = PRIMARY_INSTANCE_NAME + '.' + name;
31934 }
31935 return name;
31936 };
31937
31938 MixpanelLib.prototype._event_is_disabled = function(event_name) {
31939 return _.isBlockedUA(userAgent) ||
31940 this._flags.disable_all_events ||
31941 _.include(this.__disabled_events, event_name);
31942 };
31943
31944 // perform some housekeeping around GDPR opt-in/out state
31945 MixpanelLib.prototype._gdpr_init = function() {
31946 var is_localStorage_requested = this.get_config('opt_out_tracking_persistence_type') === 'localStorage';
31947
31948 // try to convert opt-in/out cookies to localStorage if possible
31949 if (is_localStorage_requested && _.localStorage.is_supported()) {
31950 if (!this.has_opted_in_tracking() && this.has_opted_in_tracking({'persistence_type': 'cookie'})) {
31951 this.opt_in_tracking({'enable_persistence': false});
31952 }
31953 if (!this.has_opted_out_tracking() && this.has_opted_out_tracking({'persistence_type': 'cookie'})) {
31954 this.opt_out_tracking({'clear_persistence': false});
31955 }
31956 this.clear_opt_in_out_tracking({
31957 'persistence_type': 'cookie',
31958 'enable_persistence': false
31959 });
31960 }
31961
31962 // check whether the user has already opted out - if so, clear & disable persistence
31963 if (this.has_opted_out_tracking()) {
31964 this._gdpr_update_persistence({'clear_persistence': true});
31965
31966 // check whether we should opt out by default
31967 // note: we don't clear persistence here by default since opt-out default state is often
31968 // used as an initial state while GDPR information is being collected
31969 } else if (!this.has_opted_in_tracking() && (
31970 this.get_config('opt_out_tracking_by_default') || _.cookie.get('mp_optout')
31971 )) {
31972 _.cookie.remove('mp_optout');
31973 this.opt_out_tracking({
31974 'clear_persistence': this.get_config('opt_out_persistence_by_default')
31975 });
31976 }
31977 };
31978
31979 /**
31980 * Enable or disable persistence based on options
31981 * only enable/disable if persistence is not already in this state
31982 * @param {boolean} [options.clear_persistence] If true, will delete all data stored by the sdk in persistence and disable it
31983 * @param {boolean} [options.enable_persistence] If true, will re-enable sdk persistence
31984 */
31985 MixpanelLib.prototype._gdpr_update_persistence = function(options) {
31986 var disabled;
31987 if (options && options['clear_persistence']) {
31988 disabled = true;
31989 } else if (options && options['enable_persistence']) {
31990 disabled = false;
31991 } else {
31992 return;
31993 }
31994
31995 if (!this.get_config('disable_persistence') && this['persistence'].disabled !== disabled) {
31996 this['persistence'].set_disabled(disabled);
31997 }
31998
31999 if (disabled) {
32000 this.stop_batch_senders();
32001 this.stop_session_recording();
32002 } else {
32003 // only start batchers after opt-in if they have previously been started
32004 // in order to avoid unintentionally starting up batching for the first time
32005 if (this._batchers_were_started) {
32006 this.start_batch_senders();
32007 }
32008 }
32009 };
32010
32011 // call a base gdpr function after constructing the appropriate token and options args
32012 MixpanelLib.prototype._gdpr_call_func = function(func, options) {
32013 options = _.extend({
32014 'track': _.bind(this.track, this),
32015 'persistence_type': this.get_config('opt_out_tracking_persistence_type'),
32016 'cookie_prefix': this.get_config('opt_out_tracking_cookie_prefix'),
32017 'cookie_expiration': this.get_config('cookie_expiration'),
32018 'cross_site_cookie': this.get_config('cross_site_cookie'),
32019 'cross_subdomain_cookie': this.get_config('cross_subdomain_cookie'),
32020 'cookie_domain': this.get_config('cookie_domain'),
32021 'secure_cookie': this.get_config('secure_cookie'),
32022 'ignore_dnt': this.get_config('ignore_dnt')
32023 }, options);
32024
32025 // check if localStorage can be used for recording opt out status, fall back to cookie if not
32026 if (!_.localStorage.is_supported()) {
32027 options['persistence_type'] = 'cookie';
32028 }
32029
32030 return func(this.get_config('token'), {
32031 track: options['track'],
32032 trackEventName: options['track_event_name'],
32033 trackProperties: options['track_properties'],
32034 persistenceType: options['persistence_type'],
32035 persistencePrefix: options['cookie_prefix'],
32036 cookieDomain: options['cookie_domain'],
32037 cookieExpiration: options['cookie_expiration'],
32038 crossSiteCookie: options['cross_site_cookie'],
32039 crossSubdomainCookie: options['cross_subdomain_cookie'],
32040 secureCookie: options['secure_cookie'],
32041 ignoreDnt: options['ignore_dnt']
32042 });
32043 };
32044
32045 /**
32046 * Opt the user in to data tracking and cookies/localstorage for this Mixpanel instance
32047 *
32048 * ### Usage:
32049 *
32050 * // opt user in
32051 * mixpanel.opt_in_tracking();
32052 *
32053 * // opt user in with specific event name, properties, cookie configuration
32054 * mixpanel.opt_in_tracking({
32055 * track_event_name: 'User opted in',
32056 * track_event_properties: {
32057 * 'Email': 'jdoe@example.com'
32058 * },
32059 * cookie_expiration: 30,
32060 * secure_cookie: true
32061 * });
32062 *
32063 * @param {Object} [options] A dictionary of config options to override
32064 * @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)
32065 * @param {string} [options.track_event_name=$opt_in] Event name to be used for tracking the opt-in action
32066 * @param {Object} [options.track_properties] Set of properties to be tracked along with the opt-in action
32067 * @param {boolean} [options.enable_persistence=true] If true, will re-enable sdk persistence
32068 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32069 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32070 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
32071 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
32072 * @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)
32073 * @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)
32074 * @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)
32075 */
32076 MixpanelLib.prototype.opt_in_tracking = function(options) {
32077 options = _.extend({
32078 'enable_persistence': true
32079 }, options);
32080
32081 this._gdpr_call_func(optIn, options);
32082 this._gdpr_update_persistence(options);
32083 };
32084
32085 /**
32086 * Opt the user out of data tracking and cookies/localstorage for this Mixpanel instance
32087 *
32088 * ### Usage:
32089 *
32090 * // opt user out
32091 * mixpanel.opt_out_tracking();
32092 *
32093 * // opt user out with different cookie configuration from Mixpanel instance
32094 * mixpanel.opt_out_tracking({
32095 * cookie_expiration: 30,
32096 * secure_cookie: true
32097 * });
32098 *
32099 * @param {Object} [options] A dictionary of config options to override
32100 * @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
32101 * @param {boolean} [options.clear_persistence=true] If true, will delete all data stored by the sdk in persistence
32102 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32103 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32104 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
32105 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
32106 * @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)
32107 * @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)
32108 * @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)
32109 */
32110 MixpanelLib.prototype.opt_out_tracking = function(options) {
32111 options = _.extend({
32112 'clear_persistence': true,
32113 'delete_user': true
32114 }, options);
32115
32116 // delete user and clear charges since these methods may be disabled by opt-out
32117 if (options['delete_user'] && this['people'] && this['people']._identify_called()) {
32118 this['people'].delete_user();
32119 this['people'].clear_charges();
32120 }
32121
32122 this._gdpr_call_func(optOut, options);
32123 this._gdpr_update_persistence(options);
32124 };
32125
32126 /**
32127 * Check whether the user has opted in to data tracking and cookies/localstorage for this Mixpanel instance
32128 *
32129 * ### Usage:
32130 *
32131 * var has_opted_in = mixpanel.has_opted_in_tracking();
32132 * // use has_opted_in value
32133 *
32134 * @param {Object} [options] A dictionary of config options to override
32135 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32136 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32137 * @returns {boolean} current opt-in status
32138 */
32139 MixpanelLib.prototype.has_opted_in_tracking = function(options) {
32140 return this._gdpr_call_func(hasOptedIn, options);
32141 };
32142
32143 /**
32144 * Check whether the user has opted out of data tracking and cookies/localstorage for this Mixpanel instance
32145 *
32146 * ### Usage:
32147 *
32148 * var has_opted_out = mixpanel.has_opted_out_tracking();
32149 * // use has_opted_out value
32150 *
32151 * @param {Object} [options] A dictionary of config options to override
32152 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32153 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32154 * @returns {boolean} current opt-out status
32155 */
32156 MixpanelLib.prototype.has_opted_out_tracking = function(options) {
32157 return this._gdpr_call_func(hasOptedOut, options);
32158 };
32159
32160 /**
32161 * Clear the user's opt in/out status of data tracking and cookies/localstorage for this Mixpanel instance
32162 *
32163 * ### Usage:
32164 *
32165 * // clear user's opt-in/out status
32166 * mixpanel.clear_opt_in_out_tracking();
32167 *
32168 * // clear user's opt-in/out status with specific cookie configuration - should match
32169 * // configuration used when opt_in_tracking/opt_out_tracking methods were called.
32170 * mixpanel.clear_opt_in_out_tracking({
32171 * cookie_expiration: 30,
32172 * secure_cookie: true
32173 * });
32174 *
32175 * @param {Object} [options] A dictionary of config options to override
32176 * @param {boolean} [options.enable_persistence=true] If true, will re-enable sdk persistence
32177 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32178 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32179 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
32180 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
32181 * @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)
32182 * @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)
32183 * @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)
32184 */
32185 MixpanelLib.prototype.clear_opt_in_out_tracking = function(options) {
32186 options = _.extend({
32187 'enable_persistence': true
32188 }, options);
32189
32190 this._gdpr_call_func(clearOptInOut, options);
32191 this._gdpr_update_persistence(options);
32192 };
32193
32194 MixpanelLib.prototype.report_error = function(msg, err) {
32195 console$1.error.apply(console$1.error, arguments);
32196 try {
32197 if (!err && !(msg instanceof Error)) {
32198 msg = new Error(msg);
32199 }
32200 this.get_config('error_reporter')(msg, err);
32201 } catch(err) {
32202 console$1.error(err);
32203 }
32204 };
32205
32206 // EXPORTS (for closure compiler)
32207
32208 // MixpanelLib Exports
32209 MixpanelLib.prototype['init'] = MixpanelLib.prototype.init;
32210 MixpanelLib.prototype['reset'] = MixpanelLib.prototype.reset;
32211 MixpanelLib.prototype['disable'] = MixpanelLib.prototype.disable;
32212 MixpanelLib.prototype['time_event'] = MixpanelLib.prototype.time_event;
32213 MixpanelLib.prototype['track'] = MixpanelLib.prototype.track;
32214 MixpanelLib.prototype['track_links'] = MixpanelLib.prototype.track_links;
32215 MixpanelLib.prototype['track_forms'] = MixpanelLib.prototype.track_forms;
32216 MixpanelLib.prototype['track_pageview'] = MixpanelLib.prototype.track_pageview;
32217 MixpanelLib.prototype['register'] = MixpanelLib.prototype.register;
32218 MixpanelLib.prototype['register_once'] = MixpanelLib.prototype.register_once;
32219 MixpanelLib.prototype['unregister'] = MixpanelLib.prototype.unregister;
32220 MixpanelLib.prototype['identify'] = MixpanelLib.prototype.identify;
32221 MixpanelLib.prototype['alias'] = MixpanelLib.prototype.alias;
32222 MixpanelLib.prototype['name_tag'] = MixpanelLib.prototype.name_tag;
32223 MixpanelLib.prototype['set_config'] = MixpanelLib.prototype.set_config;
32224 MixpanelLib.prototype['get_config'] = MixpanelLib.prototype.get_config;
32225 MixpanelLib.prototype['get_api_host'] = MixpanelLib.prototype.get_api_host;
32226 MixpanelLib.prototype['get_property'] = MixpanelLib.prototype.get_property;
32227 MixpanelLib.prototype['get_distinct_id'] = MixpanelLib.prototype.get_distinct_id;
32228 MixpanelLib.prototype['toString'] = MixpanelLib.prototype.toString;
32229 MixpanelLib.prototype['opt_out_tracking'] = MixpanelLib.prototype.opt_out_tracking;
32230 MixpanelLib.prototype['opt_in_tracking'] = MixpanelLib.prototype.opt_in_tracking;
32231 MixpanelLib.prototype['has_opted_out_tracking'] = MixpanelLib.prototype.has_opted_out_tracking;
32232 MixpanelLib.prototype['has_opted_in_tracking'] = MixpanelLib.prototype.has_opted_in_tracking;
32233 MixpanelLib.prototype['clear_opt_in_out_tracking'] = MixpanelLib.prototype.clear_opt_in_out_tracking;
32234 MixpanelLib.prototype['get_group'] = MixpanelLib.prototype.get_group;
32235 MixpanelLib.prototype['set_group'] = MixpanelLib.prototype.set_group;
32236 MixpanelLib.prototype['add_group'] = MixpanelLib.prototype.add_group;
32237 MixpanelLib.prototype['remove_group'] = MixpanelLib.prototype.remove_group;
32238 MixpanelLib.prototype['track_with_groups'] = MixpanelLib.prototype.track_with_groups;
32239 MixpanelLib.prototype['start_batch_senders'] = MixpanelLib.prototype.start_batch_senders;
32240 MixpanelLib.prototype['stop_batch_senders'] = MixpanelLib.prototype.stop_batch_senders;
32241 MixpanelLib.prototype['start_session_recording'] = MixpanelLib.prototype.start_session_recording;
32242 MixpanelLib.prototype['stop_session_recording'] = MixpanelLib.prototype.stop_session_recording;
32243 MixpanelLib.prototype['pause_session_recording'] = MixpanelLib.prototype.pause_session_recording;
32244 MixpanelLib.prototype['resume_session_recording'] = MixpanelLib.prototype.resume_session_recording;
32245 MixpanelLib.prototype['get_session_recording_properties'] = MixpanelLib.prototype.get_session_recording_properties;
32246 MixpanelLib.prototype['get_session_replay_url'] = MixpanelLib.prototype.get_session_replay_url;
32247 MixpanelLib.prototype['get_tab_id'] = MixpanelLib.prototype.get_tab_id;
32248 MixpanelLib.prototype['DEFAULT_API_ROUTES'] = DEFAULT_API_ROUTES;
32249
32250 // Exports intended only for testing
32251 MixpanelLib.prototype['__get_recorder'] = MixpanelLib.prototype.__get_recorder;
32252
32253 // MixpanelPersistence Exports
32254 MixpanelPersistence.prototype['properties'] = MixpanelPersistence.prototype.properties;
32255 MixpanelPersistence.prototype['update_search_keyword'] = MixpanelPersistence.prototype.update_search_keyword;
32256 MixpanelPersistence.prototype['update_referrer_info'] = MixpanelPersistence.prototype.update_referrer_info;
32257 MixpanelPersistence.prototype['get_cross_subdomain'] = MixpanelPersistence.prototype.get_cross_subdomain;
32258 MixpanelPersistence.prototype['clear'] = MixpanelPersistence.prototype.clear;
32259
32260
32261 var instances = {};
32262 var extend_mp = function() {
32263 // add all the sub mixpanel instances
32264 _.each(instances, function(instance, name) {
32265 if (name !== PRIMARY_INSTANCE_NAME) { mixpanel_master[name] = instance; }
32266 });
32267
32268 // add private functions as _
32269 mixpanel_master['_'] = _;
32270 };
32271
32272 var override_mp_init_func = function() {
32273 // we override the snippets init function to handle the case where a
32274 // user initializes the mixpanel library after the script loads & runs
32275 mixpanel_master['init'] = function(token, config, name) {
32276 if (name) {
32277 // initialize a sub library
32278 if (!mixpanel_master[name]) {
32279 mixpanel_master[name] = instances[name] = create_mplib(token, config, name);
32280 mixpanel_master[name]._loaded();
32281 }
32282 return mixpanel_master[name];
32283 } else {
32284 var instance = mixpanel_master;
32285
32286 if (instances[PRIMARY_INSTANCE_NAME]) {
32287 // main mixpanel lib already initialized
32288 instance = instances[PRIMARY_INSTANCE_NAME];
32289 } else if (token) {
32290 // intialize the main mixpanel lib
32291 instance = create_mplib(token, config, PRIMARY_INSTANCE_NAME);
32292 instance._loaded();
32293 instances[PRIMARY_INSTANCE_NAME] = instance;
32294 }
32295
32296 mixpanel_master = instance;
32297 if (init_type === INIT_SNIPPET) {
32298 win[PRIMARY_INSTANCE_NAME] = mixpanel_master;
32299 }
32300 extend_mp();
32301 }
32302 };
32303 };
32304
32305 var add_dom_loaded_handler = function() {
32306 // Cross browser DOM Loaded support
32307 function dom_loaded_handler() {
32308 // function flag since we only want to execute this once
32309 if (dom_loaded_handler.done) { return; }
32310 dom_loaded_handler.done = true;
32311
32312 DOM_LOADED = true;
32313 ENQUEUE_REQUESTS = false;
32314
32315 _.each(instances, function(inst) {
32316 inst._dom_loaded();
32317 });
32318 }
32319
32320 function do_scroll_check() {
32321 try {
32322 document$1.documentElement.doScroll('left');
32323 } catch(e) {
32324 setTimeout(do_scroll_check, 1);
32325 return;
32326 }
32327
32328 dom_loaded_handler();
32329 }
32330
32331 if (document$1.addEventListener) {
32332 if (document$1.readyState === 'complete') {
32333 // safari 4 can fire the DOMContentLoaded event before loading all
32334 // external JS (including this file). you will see some copypasta
32335 // on the internet that checks for 'complete' and 'loaded', but
32336 // 'loaded' is an IE thing
32337 dom_loaded_handler();
32338 } else {
32339 document$1.addEventListener('DOMContentLoaded', dom_loaded_handler, false);
32340 }
32341 } else if (document$1.attachEvent) {
32342 // IE
32343 document$1.attachEvent('onreadystatechange', dom_loaded_handler);
32344
32345 // check to make sure we arn't in a frame
32346 var toplevel = false;
32347 try {
32348 toplevel = win.frameElement === null;
32349 } catch(e) {
32350 // noop
32351 }
32352
32353 if (document$1.documentElement.doScroll && toplevel) {
32354 do_scroll_check();
32355 }
32356 }
32357
32358 // fallback handler, always will work
32359 _.register_event(win, 'load', dom_loaded_handler, true);
32360 };
32361
32362 function init_as_module(bundle_loader) {
32363 load_extra_bundle = bundle_loader;
32364 init_type = INIT_MODULE;
32365 mixpanel_master = new MixpanelLib();
32366
32367 override_mp_init_func();
32368 mixpanel_master['init']();
32369 add_dom_loaded_handler();
32370
32371 return mixpanel_master;
32372 }
32373
32374 // For loading separate bundles asynchronously via script tag
32375 // so that we don't load them until they are needed at runtime.
32376
32377 // For builds that have everything in one bundle, no extra work.
32378 function loadNoop (_src, onload) {
32379 onload();
32380 }
32381
32382 /* eslint camelcase: "off" */
32383
32384 var mixpanel = init_as_module(loadNoop);
32385
32386
32387
32388
32389 /***/ }),
32390
32391 /***/ "../node_modules/redux-thunk/es/index.js":
32392 /*!***********************************************!*\
32393 !*** ../node_modules/redux-thunk/es/index.js ***!
32394 \***********************************************/
32395 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
32396
32397 "use strict";
32398 __webpack_require__.r(__webpack_exports__);
32399 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
32400 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
32401 /* harmony export */ });
32402 /** A function that accepts a potential "extra argument" value to be injected later,
32403 * and returns an instance of the thunk middleware that uses that value
32404 */
32405 function createThunkMiddleware(extraArgument) {
32406 // Standard Redux middleware definition pattern:
32407 // See: https://redux.js.org/tutorials/fundamentals/part-4-store#writing-custom-middleware
32408 var middleware = function middleware(_ref) {
32409 var dispatch = _ref.dispatch,
32410 getState = _ref.getState;
32411 return function (next) {
32412 return function (action) {
32413 // The thunk middleware looks for any functions that were passed to `store.dispatch`.
32414 // If this "action" is really a function, call it and return the result.
32415 if (typeof action === 'function') {
32416 // Inject the store's `dispatch` and `getState` methods, as well as any "extra arg"
32417 return action(dispatch, getState, extraArgument);
32418 } // Otherwise, pass the action down the middleware chain as usual
32419
32420
32421 return next(action);
32422 };
32423 };
32424 };
32425
32426 return middleware;
32427 }
32428
32429 var thunk = createThunkMiddleware(); // Attach the factory function so users can create a customized version
32430 // with whatever "extra arg" they want to inject into their thunks
32431
32432 thunk.withExtraArgument = createThunkMiddleware;
32433 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (thunk);
32434
32435 /***/ }),
32436
32437 /***/ "../node_modules/redux/es/redux.js":
32438 /*!*****************************************!*\
32439 !*** ../node_modules/redux/es/redux.js ***!
32440 \*****************************************/
32441 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
32442
32443 "use strict";
32444 __webpack_require__.r(__webpack_exports__);
32445 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
32446 /* harmony export */ __DO_NOT_USE__ActionTypes: () => (/* binding */ ActionTypes),
32447 /* harmony export */ applyMiddleware: () => (/* binding */ applyMiddleware),
32448 /* harmony export */ bindActionCreators: () => (/* binding */ bindActionCreators),
32449 /* harmony export */ combineReducers: () => (/* binding */ combineReducers),
32450 /* harmony export */ compose: () => (/* binding */ compose),
32451 /* harmony export */ createStore: () => (/* binding */ createStore),
32452 /* harmony export */ legacy_createStore: () => (/* binding */ legacy_createStore)
32453 /* harmony export */ });
32454 /* 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");
32455
32456
32457 /**
32458 * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
32459 *
32460 * Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
32461 * during build.
32462 * @param {number} code
32463 */
32464 function formatProdErrorMessage(code) {
32465 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. ';
32466 }
32467
32468 // Inlined version of the `symbol-observable` polyfill
32469 var $$observable = (function () {
32470 return typeof Symbol === 'function' && Symbol.observable || '@@observable';
32471 })();
32472
32473 /**
32474 * These are private action types reserved by Redux.
32475 * For any unknown actions, you must return the current state.
32476 * If the current state is undefined, you must return the initial state.
32477 * Do not reference these action types directly in your code.
32478 */
32479 var randomString = function randomString() {
32480 return Math.random().toString(36).substring(7).split('').join('.');
32481 };
32482
32483 var ActionTypes = {
32484 INIT: "@@redux/INIT" + randomString(),
32485 REPLACE: "@@redux/REPLACE" + randomString(),
32486 PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
32487 return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
32488 }
32489 };
32490
32491 /**
32492 * @param {any} obj The object to inspect.
32493 * @returns {boolean} True if the argument appears to be a plain object.
32494 */
32495 function isPlainObject(obj) {
32496 if (typeof obj !== 'object' || obj === null) return false;
32497 var proto = obj;
32498
32499 while (Object.getPrototypeOf(proto) !== null) {
32500 proto = Object.getPrototypeOf(proto);
32501 }
32502
32503 return Object.getPrototypeOf(obj) === proto;
32504 }
32505
32506 // Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
32507 function miniKindOf(val) {
32508 if (val === void 0) return 'undefined';
32509 if (val === null) return 'null';
32510 var type = typeof val;
32511
32512 switch (type) {
32513 case 'boolean':
32514 case 'string':
32515 case 'number':
32516 case 'symbol':
32517 case 'function':
32518 {
32519 return type;
32520 }
32521 }
32522
32523 if (Array.isArray(val)) return 'array';
32524 if (isDate(val)) return 'date';
32525 if (isError(val)) return 'error';
32526 var constructorName = ctorName(val);
32527
32528 switch (constructorName) {
32529 case 'Symbol':
32530 case 'Promise':
32531 case 'WeakMap':
32532 case 'WeakSet':
32533 case 'Map':
32534 case 'Set':
32535 return constructorName;
32536 } // other
32537
32538
32539 return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
32540 }
32541
32542 function ctorName(val) {
32543 return typeof val.constructor === 'function' ? val.constructor.name : null;
32544 }
32545
32546 function isError(val) {
32547 return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
32548 }
32549
32550 function isDate(val) {
32551 if (val instanceof Date) return true;
32552 return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function';
32553 }
32554
32555 function kindOf(val) {
32556 var typeOfVal = typeof val;
32557
32558 if (true) {
32559 typeOfVal = miniKindOf(val);
32560 }
32561
32562 return typeOfVal;
32563 }
32564
32565 /**
32566 * @deprecated
32567 *
32568 * **We recommend using the `configureStore` method
32569 * of the `@reduxjs/toolkit` package**, which replaces `createStore`.
32570 *
32571 * Redux Toolkit is our recommended approach for writing Redux logic today,
32572 * including store setup, reducers, data fetching, and more.
32573 *
32574 * **For more details, please read this Redux docs page:**
32575 * **https://redux.js.org/introduction/why-rtk-is-redux-today**
32576 *
32577 * `configureStore` from Redux Toolkit is an improved version of `createStore` that
32578 * simplifies setup and helps avoid common bugs.
32579 *
32580 * You should not be using the `redux` core package by itself today, except for learning purposes.
32581 * The `createStore` method from the core `redux` package will not be removed, but we encourage
32582 * all users to migrate to using Redux Toolkit for all Redux code.
32583 *
32584 * If you want to use `createStore` without this visual deprecation warning, use
32585 * the `legacy_createStore` import instead:
32586 *
32587 * `import { legacy_createStore as createStore} from 'redux'`
32588 *
32589 */
32590
32591 function createStore(reducer, preloadedState, enhancer) {
32592 var _ref2;
32593
32594 if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
32595 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.');
32596 }
32597
32598 if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
32599 enhancer = preloadedState;
32600 preloadedState = undefined;
32601 }
32602
32603 if (typeof enhancer !== 'undefined') {
32604 if (typeof enhancer !== 'function') {
32605 throw new Error( false ? 0 : "Expected the enhancer to be a function. Instead, received: '" + kindOf(enhancer) + "'");
32606 }
32607
32608 return enhancer(createStore)(reducer, preloadedState);
32609 }
32610
32611 if (typeof reducer !== 'function') {
32612 throw new Error( false ? 0 : "Expected the root reducer to be a function. Instead, received: '" + kindOf(reducer) + "'");
32613 }
32614
32615 var currentReducer = reducer;
32616 var currentState = preloadedState;
32617 var currentListeners = [];
32618 var nextListeners = currentListeners;
32619 var isDispatching = false;
32620 /**
32621 * This makes a shallow copy of currentListeners so we can use
32622 * nextListeners as a temporary list while dispatching.
32623 *
32624 * This prevents any bugs around consumers calling
32625 * subscribe/unsubscribe in the middle of a dispatch.
32626 */
32627
32628 function ensureCanMutateNextListeners() {
32629 if (nextListeners === currentListeners) {
32630 nextListeners = currentListeners.slice();
32631 }
32632 }
32633 /**
32634 * Reads the state tree managed by the store.
32635 *
32636 * @returns {any} The current state tree of your application.
32637 */
32638
32639
32640 function getState() {
32641 if (isDispatching) {
32642 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.');
32643 }
32644
32645 return currentState;
32646 }
32647 /**
32648 * Adds a change listener. It will be called any time an action is dispatched,
32649 * and some part of the state tree may potentially have changed. You may then
32650 * call `getState()` to read the current state tree inside the callback.
32651 *
32652 * You may call `dispatch()` from a change listener, with the following
32653 * caveats:
32654 *
32655 * 1. The subscriptions are snapshotted just before every `dispatch()` call.
32656 * If you subscribe or unsubscribe while the listeners are being invoked, this
32657 * will not have any effect on the `dispatch()` that is currently in progress.
32658 * However, the next `dispatch()` call, whether nested or not, will use a more
32659 * recent snapshot of the subscription list.
32660 *
32661 * 2. The listener should not expect to see all state changes, as the state
32662 * might have been updated multiple times during a nested `dispatch()` before
32663 * the listener is called. It is, however, guaranteed that all subscribers
32664 * registered before the `dispatch()` started will be called with the latest
32665 * state by the time it exits.
32666 *
32667 * @param {Function} listener A callback to be invoked on every dispatch.
32668 * @returns {Function} A function to remove this change listener.
32669 */
32670
32671
32672 function subscribe(listener) {
32673 if (typeof listener !== 'function') {
32674 throw new Error( false ? 0 : "Expected the listener to be a function. Instead, received: '" + kindOf(listener) + "'");
32675 }
32676
32677 if (isDispatching) {
32678 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.');
32679 }
32680
32681 var isSubscribed = true;
32682 ensureCanMutateNextListeners();
32683 nextListeners.push(listener);
32684 return function unsubscribe() {
32685 if (!isSubscribed) {
32686 return;
32687 }
32688
32689 if (isDispatching) {
32690 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.');
32691 }
32692
32693 isSubscribed = false;
32694 ensureCanMutateNextListeners();
32695 var index = nextListeners.indexOf(listener);
32696 nextListeners.splice(index, 1);
32697 currentListeners = null;
32698 };
32699 }
32700 /**
32701 * Dispatches an action. It is the only way to trigger a state change.
32702 *
32703 * The `reducer` function, used to create the store, will be called with the
32704 * current state tree and the given `action`. Its return value will
32705 * be considered the **next** state of the tree, and the change listeners
32706 * will be notified.
32707 *
32708 * The base implementation only supports plain object actions. If you want to
32709 * dispatch a Promise, an Observable, a thunk, or something else, you need to
32710 * wrap your store creating function into the corresponding middleware. For
32711 * example, see the documentation for the `redux-thunk` package. Even the
32712 * middleware will eventually dispatch plain object actions using this method.
32713 *
32714 * @param {Object} action A plain object representing “what changed”. It is
32715 * a good idea to keep actions serializable so you can record and replay user
32716 * sessions, or use the time travelling `redux-devtools`. An action must have
32717 * a `type` property which may not be `undefined`. It is a good idea to use
32718 * string constants for action types.
32719 *
32720 * @returns {Object} For convenience, the same action object you dispatched.
32721 *
32722 * Note that, if you use a custom middleware, it may wrap `dispatch()` to
32723 * return something else (for example, a Promise you can await).
32724 */
32725
32726
32727 function dispatch(action) {
32728 if (!isPlainObject(action)) {
32729 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.");
32730 }
32731
32732 if (typeof action.type === 'undefined') {
32733 throw new Error( false ? 0 : 'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');
32734 }
32735
32736 if (isDispatching) {
32737 throw new Error( false ? 0 : 'Reducers may not dispatch actions.');
32738 }
32739
32740 try {
32741 isDispatching = true;
32742 currentState = currentReducer(currentState, action);
32743 } finally {
32744 isDispatching = false;
32745 }
32746
32747 var listeners = currentListeners = nextListeners;
32748
32749 for (var i = 0; i < listeners.length; i++) {
32750 var listener = listeners[i];
32751 listener();
32752 }
32753
32754 return action;
32755 }
32756 /**
32757 * Replaces the reducer currently used by the store to calculate the state.
32758 *
32759 * You might need this if your app implements code splitting and you want to
32760 * load some of the reducers dynamically. You might also need this if you
32761 * implement a hot reloading mechanism for Redux.
32762 *
32763 * @param {Function} nextReducer The reducer for the store to use instead.
32764 * @returns {void}
32765 */
32766
32767
32768 function replaceReducer(nextReducer) {
32769 if (typeof nextReducer !== 'function') {
32770 throw new Error( false ? 0 : "Expected the nextReducer to be a function. Instead, received: '" + kindOf(nextReducer));
32771 }
32772
32773 currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
32774 // Any reducers that existed in both the new and old rootReducer
32775 // will receive the previous state. This effectively populates
32776 // the new state tree with any relevant data from the old one.
32777
32778 dispatch({
32779 type: ActionTypes.REPLACE
32780 });
32781 }
32782 /**
32783 * Interoperability point for observable/reactive libraries.
32784 * @returns {observable} A minimal observable of state changes.
32785 * For more information, see the observable proposal:
32786 * https://github.com/tc39/proposal-observable
32787 */
32788
32789
32790 function observable() {
32791 var _ref;
32792
32793 var outerSubscribe = subscribe;
32794 return _ref = {
32795 /**
32796 * The minimal observable subscription method.
32797 * @param {Object} observer Any object that can be used as an observer.
32798 * The observer object should have a `next` method.
32799 * @returns {subscription} An object with an `unsubscribe` method that can
32800 * be used to unsubscribe the observable from the store, and prevent further
32801 * emission of values from the observable.
32802 */
32803 subscribe: function subscribe(observer) {
32804 if (typeof observer !== 'object' || observer === null) {
32805 throw new Error( false ? 0 : "Expected the observer to be an object. Instead, received: '" + kindOf(observer) + "'");
32806 }
32807
32808 function observeState() {
32809 if (observer.next) {
32810 observer.next(getState());
32811 }
32812 }
32813
32814 observeState();
32815 var unsubscribe = outerSubscribe(observeState);
32816 return {
32817 unsubscribe: unsubscribe
32818 };
32819 }
32820 }, _ref[$$observable] = function () {
32821 return this;
32822 }, _ref;
32823 } // When a store is created, an "INIT" action is dispatched so that every
32824 // reducer returns their initial state. This effectively populates
32825 // the initial state tree.
32826
32827
32828 dispatch({
32829 type: ActionTypes.INIT
32830 });
32831 return _ref2 = {
32832 dispatch: dispatch,
32833 subscribe: subscribe,
32834 getState: getState,
32835 replaceReducer: replaceReducer
32836 }, _ref2[$$observable] = observable, _ref2;
32837 }
32838 /**
32839 * Creates a Redux store that holds the state tree.
32840 *
32841 * **We recommend using `configureStore` from the
32842 * `@reduxjs/toolkit` package**, which replaces `createStore`:
32843 * **https://redux.js.org/introduction/why-rtk-is-redux-today**
32844 *
32845 * The only way to change the data in the store is to call `dispatch()` on it.
32846 *
32847 * There should only be a single store in your app. To specify how different
32848 * parts of the state tree respond to actions, you may combine several reducers
32849 * into a single reducer function by using `combineReducers`.
32850 *
32851 * @param {Function} reducer A function that returns the next state tree, given
32852 * the current state tree and the action to handle.
32853 *
32854 * @param {any} [preloadedState] The initial state. You may optionally specify it
32855 * to hydrate the state from the server in universal apps, or to restore a
32856 * previously serialized user session.
32857 * If you use `combineReducers` to produce the root reducer function, this must be
32858 * an object with the same shape as `combineReducers` keys.
32859 *
32860 * @param {Function} [enhancer] The store enhancer. You may optionally specify it
32861 * to enhance the store with third-party capabilities such as middleware,
32862 * time travel, persistence, etc. The only store enhancer that ships with Redux
32863 * is `applyMiddleware()`.
32864 *
32865 * @returns {Store} A Redux store that lets you read the state, dispatch actions
32866 * and subscribe to changes.
32867 */
32868
32869 var legacy_createStore = createStore;
32870
32871 /**
32872 * Prints a warning in the console if it exists.
32873 *
32874 * @param {String} message The warning message.
32875 * @returns {void}
32876 */
32877 function warning(message) {
32878 /* eslint-disable no-console */
32879 if (typeof console !== 'undefined' && typeof console.error === 'function') {
32880 console.error(message);
32881 }
32882 /* eslint-enable no-console */
32883
32884
32885 try {
32886 // This error was thrown as a convenience so that if you enable
32887 // "break on all exceptions" in your console,
32888 // it would pause the execution at this line.
32889 throw new Error(message);
32890 } catch (e) {} // eslint-disable-line no-empty
32891
32892 }
32893
32894 function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
32895 var reducerKeys = Object.keys(reducers);
32896 var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
32897
32898 if (reducerKeys.length === 0) {
32899 return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
32900 }
32901
32902 if (!isPlainObject(inputState)) {
32903 return "The " + argumentName + " has unexpected type of \"" + kindOf(inputState) + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\"");
32904 }
32905
32906 var unexpectedKeys = Object.keys(inputState).filter(function (key) {
32907 return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
32908 });
32909 unexpectedKeys.forEach(function (key) {
32910 unexpectedKeyCache[key] = true;
32911 });
32912 if (action && action.type === ActionTypes.REPLACE) return;
32913
32914 if (unexpectedKeys.length > 0) {
32915 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.");
32916 }
32917 }
32918
32919 function assertReducerShape(reducers) {
32920 Object.keys(reducers).forEach(function (key) {
32921 var reducer = reducers[key];
32922 var initialState = reducer(undefined, {
32923 type: ActionTypes.INIT
32924 });
32925
32926 if (typeof initialState === 'undefined') {
32927 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.");
32928 }
32929
32930 if (typeof reducer(undefined, {
32931 type: ActionTypes.PROBE_UNKNOWN_ACTION()
32932 }) === 'undefined') {
32933 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.");
32934 }
32935 });
32936 }
32937 /**
32938 * Turns an object whose values are different reducer functions, into a single
32939 * reducer function. It will call every child reducer, and gather their results
32940 * into a single state object, whose keys correspond to the keys of the passed
32941 * reducer functions.
32942 *
32943 * @param {Object} reducers An object whose values correspond to different
32944 * reducer functions that need to be combined into one. One handy way to obtain
32945 * it is to use ES6 `import * as reducers` syntax. The reducers may never return
32946 * undefined for any action. Instead, they should return their initial state
32947 * if the state passed to them was undefined, and the current state for any
32948 * unrecognized action.
32949 *
32950 * @returns {Function} A reducer function that invokes every reducer inside the
32951 * passed object, and builds a state object with the same shape.
32952 */
32953
32954
32955 function combineReducers(reducers) {
32956 var reducerKeys = Object.keys(reducers);
32957 var finalReducers = {};
32958
32959 for (var i = 0; i < reducerKeys.length; i++) {
32960 var key = reducerKeys[i];
32961
32962 if (true) {
32963 if (typeof reducers[key] === 'undefined') {
32964 warning("No reducer provided for key \"" + key + "\"");
32965 }
32966 }
32967
32968 if (typeof reducers[key] === 'function') {
32969 finalReducers[key] = reducers[key];
32970 }
32971 }
32972
32973 var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
32974 // keys multiple times.
32975
32976 var unexpectedKeyCache;
32977
32978 if (true) {
32979 unexpectedKeyCache = {};
32980 }
32981
32982 var shapeAssertionError;
32983
32984 try {
32985 assertReducerShape(finalReducers);
32986 } catch (e) {
32987 shapeAssertionError = e;
32988 }
32989
32990 return function combination(state, action) {
32991 if (state === void 0) {
32992 state = {};
32993 }
32994
32995 if (shapeAssertionError) {
32996 throw shapeAssertionError;
32997 }
32998
32999 if (true) {
33000 var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
33001
33002 if (warningMessage) {
33003 warning(warningMessage);
33004 }
33005 }
33006
33007 var hasChanged = false;
33008 var nextState = {};
33009
33010 for (var _i = 0; _i < finalReducerKeys.length; _i++) {
33011 var _key = finalReducerKeys[_i];
33012 var reducer = finalReducers[_key];
33013 var previousStateForKey = state[_key];
33014 var nextStateForKey = reducer(previousStateForKey, action);
33015
33016 if (typeof nextStateForKey === 'undefined') {
33017 var actionType = action && action.type;
33018 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.");
33019 }
33020
33021 nextState[_key] = nextStateForKey;
33022 hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
33023 }
33024
33025 hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
33026 return hasChanged ? nextState : state;
33027 };
33028 }
33029
33030 function bindActionCreator(actionCreator, dispatch) {
33031 return function () {
33032 return dispatch(actionCreator.apply(this, arguments));
33033 };
33034 }
33035 /**
33036 * Turns an object whose values are action creators, into an object with the
33037 * same keys, but with every function wrapped into a `dispatch` call so they
33038 * may be invoked directly. This is just a convenience method, as you can call
33039 * `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
33040 *
33041 * For convenience, you can also pass an action creator as the first argument,
33042 * and get a dispatch wrapped function in return.
33043 *
33044 * @param {Function|Object} actionCreators An object whose values are action
33045 * creator functions. One handy way to obtain it is to use ES6 `import * as`
33046 * syntax. You may also pass a single function.
33047 *
33048 * @param {Function} dispatch The `dispatch` function available on your Redux
33049 * store.
33050 *
33051 * @returns {Function|Object} The object mimicking the original object, but with
33052 * every action creator wrapped into the `dispatch` call. If you passed a
33053 * function as `actionCreators`, the return value will also be a single
33054 * function.
33055 */
33056
33057
33058 function bindActionCreators(actionCreators, dispatch) {
33059 if (typeof actionCreators === 'function') {
33060 return bindActionCreator(actionCreators, dispatch);
33061 }
33062
33063 if (typeof actionCreators !== 'object' || actionCreators === null) {
33064 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\"?");
33065 }
33066
33067 var boundActionCreators = {};
33068
33069 for (var key in actionCreators) {
33070 var actionCreator = actionCreators[key];
33071
33072 if (typeof actionCreator === 'function') {
33073 boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
33074 }
33075 }
33076
33077 return boundActionCreators;
33078 }
33079
33080 /**
33081 * Composes single-argument functions from right to left. The rightmost
33082 * function can take multiple arguments as it provides the signature for
33083 * the resulting composite function.
33084 *
33085 * @param {...Function} funcs The functions to compose.
33086 * @returns {Function} A function obtained by composing the argument functions
33087 * from right to left. For example, compose(f, g, h) is identical to doing
33088 * (...args) => f(g(h(...args))).
33089 */
33090 function compose() {
33091 for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
33092 funcs[_key] = arguments[_key];
33093 }
33094
33095 if (funcs.length === 0) {
33096 return function (arg) {
33097 return arg;
33098 };
33099 }
33100
33101 if (funcs.length === 1) {
33102 return funcs[0];
33103 }
33104
33105 return funcs.reduce(function (a, b) {
33106 return function () {
33107 return a(b.apply(void 0, arguments));
33108 };
33109 });
33110 }
33111
33112 /**
33113 * Creates a store enhancer that applies middleware to the dispatch method
33114 * of the Redux store. This is handy for a variety of tasks, such as expressing
33115 * asynchronous actions in a concise manner, or logging every action payload.
33116 *
33117 * See `redux-thunk` package as an example of the Redux middleware.
33118 *
33119 * Because middleware is potentially asynchronous, this should be the first
33120 * store enhancer in the composition chain.
33121 *
33122 * Note that each middleware will be given the `dispatch` and `getState` functions
33123 * as named arguments.
33124 *
33125 * @param {...Function} middlewares The middleware chain to be applied.
33126 * @returns {Function} A store enhancer applying the middleware.
33127 */
33128
33129 function applyMiddleware() {
33130 for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
33131 middlewares[_key] = arguments[_key];
33132 }
33133
33134 return function (createStore) {
33135 return function () {
33136 var store = createStore.apply(void 0, arguments);
33137
33138 var _dispatch = function dispatch() {
33139 throw new Error( false ? 0 : 'Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.');
33140 };
33141
33142 var middlewareAPI = {
33143 getState: store.getState,
33144 dispatch: function dispatch() {
33145 return _dispatch.apply(void 0, arguments);
33146 }
33147 };
33148 var chain = middlewares.map(function (middleware) {
33149 return middleware(middlewareAPI);
33150 });
33151 _dispatch = compose.apply(void 0, chain)(store.dispatch);
33152 return (0,_babel_runtime_helpers_esm_objectSpread2__WEBPACK_IMPORTED_MODULE_0__["default"])((0,_babel_runtime_helpers_esm_objectSpread2__WEBPACK_IMPORTED_MODULE_0__["default"])({}, store), {}, {
33153 dispatch: _dispatch
33154 });
33155 };
33156 };
33157 }
33158
33159
33160
33161
33162 /***/ }),
33163
33164 /***/ "../node_modules/reselect/es/defaultMemoize.js":
33165 /*!*****************************************************!*\
33166 !*** ../node_modules/reselect/es/defaultMemoize.js ***!
33167 \*****************************************************/
33168 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
33169
33170 "use strict";
33171 __webpack_require__.r(__webpack_exports__);
33172 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
33173 /* harmony export */ createCacheKeyComparator: () => (/* binding */ createCacheKeyComparator),
33174 /* harmony export */ defaultEqualityCheck: () => (/* binding */ defaultEqualityCheck),
33175 /* harmony export */ defaultMemoize: () => (/* binding */ defaultMemoize)
33176 /* harmony export */ });
33177 // Cache implementation based on Erik Rasmussen's `lru-memoize`:
33178 // https://github.com/erikras/lru-memoize
33179 var NOT_FOUND = 'NOT_FOUND';
33180
33181 function createSingletonCache(equals) {
33182 var entry;
33183 return {
33184 get: function get(key) {
33185 if (entry && equals(entry.key, key)) {
33186 return entry.value;
33187 }
33188
33189 return NOT_FOUND;
33190 },
33191 put: function put(key, value) {
33192 entry = {
33193 key: key,
33194 value: value
33195 };
33196 },
33197 getEntries: function getEntries() {
33198 return entry ? [entry] : [];
33199 },
33200 clear: function clear() {
33201 entry = undefined;
33202 }
33203 };
33204 }
33205
33206 function createLruCache(maxSize, equals) {
33207 var entries = [];
33208
33209 function get(key) {
33210 var cacheIndex = entries.findIndex(function (entry) {
33211 return equals(key, entry.key);
33212 }); // We found a cached entry
33213
33214 if (cacheIndex > -1) {
33215 var entry = entries[cacheIndex]; // Cached entry not at top of cache, move it to the top
33216
33217 if (cacheIndex > 0) {
33218 entries.splice(cacheIndex, 1);
33219 entries.unshift(entry);
33220 }
33221
33222 return entry.value;
33223 } // No entry found in cache, return sentinel
33224
33225
33226 return NOT_FOUND;
33227 }
33228
33229 function put(key, value) {
33230 if (get(key) === NOT_FOUND) {
33231 // TODO Is unshift slow?
33232 entries.unshift({
33233 key: key,
33234 value: value
33235 });
33236
33237 if (entries.length > maxSize) {
33238 entries.pop();
33239 }
33240 }
33241 }
33242
33243 function getEntries() {
33244 return entries;
33245 }
33246
33247 function clear() {
33248 entries = [];
33249 }
33250
33251 return {
33252 get: get,
33253 put: put,
33254 getEntries: getEntries,
33255 clear: clear
33256 };
33257 }
33258
33259 var defaultEqualityCheck = function defaultEqualityCheck(a, b) {
33260 return a === b;
33261 };
33262 function createCacheKeyComparator(equalityCheck) {
33263 return function areArgumentsShallowlyEqual(prev, next) {
33264 if (prev === null || next === null || prev.length !== next.length) {
33265 return false;
33266 } // Do this in a for loop (and not a `forEach` or an `every`) so we can determine equality as fast as possible.
33267
33268
33269 var length = prev.length;
33270
33271 for (var i = 0; i < length; i++) {
33272 if (!equalityCheck(prev[i], next[i])) {
33273 return false;
33274 }
33275 }
33276
33277 return true;
33278 };
33279 }
33280 // defaultMemoize now supports a configurable cache size with LRU behavior,
33281 // and optional comparison of the result value with existing values
33282 function defaultMemoize(func, equalityCheckOrOptions) {
33283 var providedOptions = typeof equalityCheckOrOptions === 'object' ? equalityCheckOrOptions : {
33284 equalityCheck: equalityCheckOrOptions
33285 };
33286 var _providedOptions$equa = providedOptions.equalityCheck,
33287 equalityCheck = _providedOptions$equa === void 0 ? defaultEqualityCheck : _providedOptions$equa,
33288 _providedOptions$maxS = providedOptions.maxSize,
33289 maxSize = _providedOptions$maxS === void 0 ? 1 : _providedOptions$maxS,
33290 resultEqualityCheck = providedOptions.resultEqualityCheck;
33291 var comparator = createCacheKeyComparator(equalityCheck);
33292 var cache = maxSize === 1 ? createSingletonCache(comparator) : createLruCache(maxSize, comparator); // we reference arguments instead of spreading them for performance reasons
33293
33294 function memoized() {
33295 var value = cache.get(arguments);
33296
33297 if (value === NOT_FOUND) {
33298 // @ts-ignore
33299 value = func.apply(null, arguments);
33300
33301 if (resultEqualityCheck) {
33302 var entries = cache.getEntries();
33303 var matchingEntry = entries.find(function (entry) {
33304 return resultEqualityCheck(entry.value, value);
33305 });
33306
33307 if (matchingEntry) {
33308 value = matchingEntry.value;
33309 }
33310 }
33311
33312 cache.put(arguments, value);
33313 }
33314
33315 return value;
33316 }
33317
33318 memoized.clearCache = function () {
33319 return cache.clear();
33320 };
33321
33322 return memoized;
33323 }
33324
33325 /***/ }),
33326
33327 /***/ "../node_modules/reselect/es/index.js":
33328 /*!********************************************!*\
33329 !*** ../node_modules/reselect/es/index.js ***!
33330 \********************************************/
33331 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
33332
33333 "use strict";
33334 __webpack_require__.r(__webpack_exports__);
33335 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
33336 /* harmony export */ createSelector: () => (/* binding */ createSelector),
33337 /* harmony export */ createSelectorCreator: () => (/* binding */ createSelectorCreator),
33338 /* harmony export */ createStructuredSelector: () => (/* binding */ createStructuredSelector),
33339 /* harmony export */ defaultEqualityCheck: () => (/* reexport safe */ _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultEqualityCheck),
33340 /* harmony export */ defaultMemoize: () => (/* reexport safe */ _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultMemoize)
33341 /* harmony export */ });
33342 /* harmony import */ var _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultMemoize */ "../node_modules/reselect/es/defaultMemoize.js");
33343
33344
33345
33346 function getDependencies(funcs) {
33347 var dependencies = Array.isArray(funcs[0]) ? funcs[0] : funcs;
33348
33349 if (!dependencies.every(function (dep) {
33350 return typeof dep === 'function';
33351 })) {
33352 var dependencyTypes = dependencies.map(function (dep) {
33353 return typeof dep === 'function' ? "function " + (dep.name || 'unnamed') + "()" : typeof dep;
33354 }).join(', ');
33355 throw new Error("createSelector expects all input-selectors to be functions, but received the following types: [" + dependencyTypes + "]");
33356 }
33357
33358 return dependencies;
33359 }
33360
33361 function createSelectorCreator(memoize) {
33362 for (var _len = arguments.length, memoizeOptionsFromArgs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
33363 memoizeOptionsFromArgs[_key - 1] = arguments[_key];
33364 }
33365
33366 var createSelector = function createSelector() {
33367 for (var _len2 = arguments.length, funcs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
33368 funcs[_key2] = arguments[_key2];
33369 }
33370
33371 var _recomputations = 0;
33372
33373 var _lastResult; // Due to the intricacies of rest params, we can't do an optional arg after `...funcs`.
33374 // So, start by declaring the default value here.
33375 // (And yes, the words 'memoize' and 'options' appear too many times in this next sequence.)
33376
33377
33378 var directlyPassedOptions = {
33379 memoizeOptions: undefined
33380 }; // Normally, the result func or "output selector" is the last arg
33381
33382 var resultFunc = funcs.pop(); // If the result func is actually an _object_, assume it's our options object
33383
33384 if (typeof resultFunc === 'object') {
33385 directlyPassedOptions = resultFunc; // and pop the real result func off
33386
33387 resultFunc = funcs.pop();
33388 }
33389
33390 if (typeof resultFunc !== 'function') {
33391 throw new Error("createSelector expects an output function after the inputs, but received: [" + typeof resultFunc + "]");
33392 } // Determine which set of options we're using. Prefer options passed directly,
33393 // but fall back to options given to createSelectorCreator.
33394
33395
33396 var _directlyPassedOption = directlyPassedOptions,
33397 _directlyPassedOption2 = _directlyPassedOption.memoizeOptions,
33398 memoizeOptions = _directlyPassedOption2 === void 0 ? memoizeOptionsFromArgs : _directlyPassedOption2; // Simplifying assumption: it's unlikely that the first options arg of the provided memoizer
33399 // is an array. In most libs I've looked at, it's an equality function or options object.
33400 // Based on that, if `memoizeOptions` _is_ an array, we assume it's a full
33401 // user-provided array of options. Otherwise, it must be just the _first_ arg, and so
33402 // we wrap it in an array so we can apply it.
33403
33404 var finalMemoizeOptions = Array.isArray(memoizeOptions) ? memoizeOptions : [memoizeOptions];
33405 var dependencies = getDependencies(funcs);
33406 var memoizedResultFunc = memoize.apply(void 0, [function recomputationWrapper() {
33407 _recomputations++; // apply arguments instead of spreading for performance.
33408
33409 return resultFunc.apply(null, arguments);
33410 }].concat(finalMemoizeOptions)); // If a selector is called with the exact same arguments we don't need to traverse our dependencies again.
33411
33412 var selector = memoize(function dependenciesChecker() {
33413 var params = [];
33414 var length = dependencies.length;
33415
33416 for (var i = 0; i < length; i++) {
33417 // apply arguments instead of spreading and mutate a local list of params for performance.
33418 // @ts-ignore
33419 params.push(dependencies[i].apply(null, arguments));
33420 } // apply arguments instead of spreading for performance.
33421
33422
33423 _lastResult = memoizedResultFunc.apply(null, params);
33424 return _lastResult;
33425 });
33426 Object.assign(selector, {
33427 resultFunc: resultFunc,
33428 memoizedResultFunc: memoizedResultFunc,
33429 dependencies: dependencies,
33430 lastResult: function lastResult() {
33431 return _lastResult;
33432 },
33433 recomputations: function recomputations() {
33434 return _recomputations;
33435 },
33436 resetRecomputations: function resetRecomputations() {
33437 return _recomputations = 0;
33438 }
33439 });
33440 return selector;
33441 }; // @ts-ignore
33442
33443
33444 return createSelector;
33445 }
33446 var createSelector = /* #__PURE__ */createSelectorCreator(_defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultMemoize);
33447 // Manual definition of state and output arguments
33448 var createStructuredSelector = function createStructuredSelector(selectors, selectorCreator) {
33449 if (selectorCreator === void 0) {
33450 selectorCreator = createSelector;
33451 }
33452
33453 if (typeof selectors !== 'object') {
33454 throw new Error('createStructuredSelector expects first argument to be an object ' + ("where each property is a selector, instead received a " + typeof selectors));
33455 }
33456
33457 var objectKeys = Object.keys(selectors);
33458 var resultSelector = selectorCreator( // @ts-ignore
33459 objectKeys.map(function (key) {
33460 return selectors[key];
33461 }), function () {
33462 for (var _len3 = arguments.length, values = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
33463 values[_key3] = arguments[_key3];
33464 }
33465
33466 return values.reduce(function (composition, value, index) {
33467 composition[objectKeys[index]] = value;
33468 return composition;
33469 }, {});
33470 });
33471 return resultSelector;
33472 };
33473
33474 /***/ }),
33475
33476 /***/ "@wordpress/i18n":
33477 /*!**************************!*\
33478 !*** external "wp.i18n" ***!
33479 \**************************/
33480 /***/ ((module) => {
33481
33482 "use strict";
33483 module.exports = wp.i18n;
33484
33485 /***/ })
33486
33487 /******/ });
33488 /************************************************************************/
33489 /******/ // The module cache
33490 /******/ var __webpack_module_cache__ = {};
33491 /******/
33492 /******/ // The require function
33493 /******/ function __webpack_require__(moduleId) {
33494 /******/ // Check if module is in cache
33495 /******/ var cachedModule = __webpack_module_cache__[moduleId];
33496 /******/ if (cachedModule !== undefined) {
33497 /******/ return cachedModule.exports;
33498 /******/ }
33499 /******/ // Create a new module (and put it into the cache)
33500 /******/ var module = __webpack_module_cache__[moduleId] = {
33501 /******/ // no module.id needed
33502 /******/ // no module.loaded needed
33503 /******/ exports: {}
33504 /******/ };
33505 /******/
33506 /******/ // Execute the module function
33507 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
33508 /******/
33509 /******/ // Return the exports of the module
33510 /******/ return module.exports;
33511 /******/ }
33512 /******/
33513 /************************************************************************/
33514 /******/ /* webpack/runtime/define property getters */
33515 /******/ (() => {
33516 /******/ // define getter functions for harmony exports
33517 /******/ __webpack_require__.d = (exports, definition) => {
33518 /******/ for(var key in definition) {
33519 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
33520 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
33521 /******/ }
33522 /******/ }
33523 /******/ };
33524 /******/ })();
33525 /******/
33526 /******/ /* webpack/runtime/global */
33527 /******/ (() => {
33528 /******/ __webpack_require__.g = (function() {
33529 /******/ if (typeof globalThis === 'object') return globalThis;
33530 /******/ try {
33531 /******/ return this || new Function('return this')();
33532 /******/ } catch (e) {
33533 /******/ if (typeof window === 'object') return window;
33534 /******/ }
33535 /******/ })();
33536 /******/ })();
33537 /******/
33538 /******/ /* webpack/runtime/hasOwnProperty shorthand */
33539 /******/ (() => {
33540 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
33541 /******/ })();
33542 /******/
33543 /******/ /* webpack/runtime/make namespace object */
33544 /******/ (() => {
33545 /******/ // define __esModule on exports
33546 /******/ __webpack_require__.r = (exports) => {
33547 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
33548 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
33549 /******/ }
33550 /******/ Object.defineProperty(exports, '__esModule', { value: true });
33551 /******/ };
33552 /******/ })();
33553 /******/
33554 /************************************************************************/
33555 var __webpack_exports__ = {};
33556 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
33557 (() => {
33558 "use strict";
33559 /*!******************************************!*\
33560 !*** ../core/common/assets/js/common.js ***!
33561 \******************************************/
33562
33563
33564 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
33565 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
33566 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
33567 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
33568 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
33569 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
33570 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
33571 var _helpers = _interopRequireDefault(__webpack_require__(/*! ./utils/helpers */ "../core/common/assets/js/utils/helpers.js"));
33572 var _storage = _interopRequireDefault(__webpack_require__(/*! ./utils/storage */ "../core/common/assets/js/utils/storage.js"));
33573 var _debug = _interopRequireDefault(__webpack_require__(/*! ./utils/debug */ "../core/common/assets/js/utils/debug.js"));
33574 var _ajax = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/ajax/assets/js/ajax */ "../core/common/modules/ajax/assets/js/ajax.js"));
33575 var _finder = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/finder/assets/js/finder */ "../core/common/modules/finder/assets/js/finder.js"));
33576 var _connect = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/connect/assets/js/connect */ "../core/common/modules/connect/assets/js/connect.js"));
33577 var _component = _interopRequireDefault(__webpack_require__(/*! ./components/wordpress/component */ "../core/common/assets/js/components/wordpress/component.js"));
33578 var _component2 = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/event-tracker/assets/js/data/component */ "../core/common/modules/event-tracker/assets/js/data/component.js"));
33579 var _events = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/event-tracker/assets/js/events */ "../core/common/modules/event-tracker/assets/js/events.js"));
33580 var _module = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/events-manager/assets/js/module */ "../core/common/modules/events-manager/assets/js/module.js"));
33581 var _notifications = _interopRequireDefault(__webpack_require__(/*! elementor-utils/notifications */ "../assets/dev/js/utils/notifications.js"));
33582 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)); }
33583 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
33584 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; }
33585 var ElementorCommonApp = /*#__PURE__*/function (_elementorModules$Vie) {
33586 function ElementorCommonApp() {
33587 (0, _classCallCheck2.default)(this, ElementorCommonApp);
33588 return _callSuper(this, ElementorCommonApp, arguments);
33589 }
33590 (0, _inherits2.default)(ElementorCommonApp, _elementorModules$Vie);
33591 return (0, _createClass2.default)(ElementorCommonApp, [{
33592 key: "setMarionetteTemplateCompiler",
33593 value: function setMarionetteTemplateCompiler() {
33594 Marionette.TemplateCache.prototype.compileTemplate = function (rawTemplate, options) {
33595 options = {
33596 evaluate: /<#([\s\S]+?)#>/g,
33597 interpolate: /{{{([\s\S]+?)}}}/g,
33598 escape: /{{([^}]+?)}}(?!})/g
33599 };
33600 return _.template(rawTemplate, options);
33601 };
33602 }
33603 }, {
33604 key: "getDefaultElements",
33605 value: function getDefaultElements() {
33606 return {
33607 $window: jQuery(window),
33608 $document: jQuery(document),
33609 $body: jQuery(document.body)
33610 };
33611 }
33612 }, {
33613 key: "initComponents",
33614 value: function initComponents() {
33615 this.events = new _events.default();
33616 this.eventsManager = new _module.default();
33617 this.debug = new _debug.default();
33618 this.helpers = new _helpers.default();
33619 this.storage = new _storage.default();
33620 this.dialogsManager = new DialogsManager.Instance();
33621 this.notifications = new _notifications.default();
33622 this.api = window.$e;
33623 $e.components.register(new _component2.default());
33624 elementorCommon.elements.$window.on('elementor:init-components', function () {
33625 $e.components.register(new _component.default());
33626 });
33627 this.initModules();
33628 }
33629 }, {
33630 key: "initModules",
33631 value: function initModules() {
33632 var _this = this;
33633 var activeModules = this.config.activeModules;
33634 var modules = {
33635 ajax: _ajax.default,
33636 finder: _finder.default,
33637 connect: _connect.default
33638 };
33639 activeModules.forEach(function (name) {
33640 if (modules[name]) {
33641 _this[name] = new modules[name](_this.config[name]);
33642 }
33643 });
33644 }
33645 }, {
33646 key: "compileArrayTemplateArgs",
33647 value: function compileArrayTemplateArgs(template, templateArgs) {
33648 return template.replace(/%(?:(\d+)\$)?s/g, function (match, number) {
33649 if (!number) {
33650 number = 1;
33651 }
33652 number--;
33653 return undefined !== templateArgs[number] ? templateArgs[number] : match;
33654 });
33655 }
33656 }, {
33657 key: "compileObjectTemplateArgs",
33658 value: function compileObjectTemplateArgs(template, templateArgs) {
33659 return template.replace(/{{(?:([ \w]+))}}/g, function (match, name) {
33660 return templateArgs[name] ? templateArgs[name] : match;
33661 });
33662 }
33663 }, {
33664 key: "compileTemplate",
33665 value: function compileTemplate(template, templateArgs) {
33666 return jQuery.isPlainObject(templateArgs) ? this.compileObjectTemplateArgs(template, templateArgs) : this.compileArrayTemplateArgs(template, templateArgs);
33667 }
33668 }, {
33669 key: "translate",
33670 value: function translate(stringKey, context, templateArgs, i18nStack) {
33671 if (context) {
33672 i18nStack = this.config[context].i18n;
33673 }
33674 if (!i18nStack) {
33675 i18nStack = this.config.i18n;
33676 }
33677 var string = i18nStack[stringKey];
33678 if (undefined === string) {
33679 string = stringKey;
33680 }
33681 if (templateArgs) {
33682 string = this.compileTemplate(string, templateArgs);
33683 }
33684 return string;
33685 }
33686 }, {
33687 key: "onInit",
33688 value: function onInit() {
33689 _superPropGet(ElementorCommonApp, "onInit", this, 3)([]);
33690 this.config = elementorCommonConfig;
33691 this.setMarionetteTemplateCompiler();
33692 }
33693 }]);
33694 }(elementorModules.ViewModule);
33695 window.elementorCommon = new ElementorCommonApp();
33696 elementorCommon.initComponents();
33697 })();
33698
33699 /******/ })()
33700 ;
33701 //# sourceMappingURL=common.js.map