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

33,667 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 deferred = this.addRequest(request.action, {
1726 data: request.data,
1727 unique_id: request.unique_id,
1728 success: function success(data) {
1729 return _this3.cache[cacheKey] = data;
1730 }
1731 }, immediately).done(request.success);
1732 }
1733 return deferred;
1734 }
1735 }, {
1736 key: "cancelRequest",
1737 value: function cancelRequest(requestId) {
1738 var request = this.requests[requestId];
1739 if (!request) {
1740 return null;
1741 }
1742 if (request.options.deferred.jqXhr) {
1743 return request.options.deferred.jqXhr.abort('Request canceled');
1744 }
1745 if (request.options.deferred) {
1746 return request.options.deferred.reject('Request canceled');
1747 }
1748 }
1749 }, {
1750 key: "addRequest",
1751 value: function addRequest(action, options, immediately) {
1752 options = options || {};
1753 if (!options.unique_id) {
1754 options.unique_id = action;
1755 }
1756 options.deferred = jQuery.Deferred().done(options.success).fail(options.error).always(options.complete);
1757 var request = {
1758 action: action,
1759 options: options
1760 };
1761 if (immediately) {
1762 var requests = {};
1763 requests[options.unique_id] = request;
1764 options.deferred.jqXhr = this.sendBatch(requests);
1765 } else {
1766 this.requests[options.unique_id] = request;
1767 this.debounceSendBatch();
1768 }
1769 return options.deferred;
1770 }
1771 }, {
1772 key: "sendBatch",
1773 value: function sendBatch(requests) {
1774 var actions = {};
1775 if (!requests) {
1776 requests = this.requests;
1777
1778 // Empty for next batch.
1779 this.requests = {};
1780 }
1781 Object.entries(requests).forEach(function (_ref) {
1782 var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
1783 id = _ref2[0],
1784 request = _ref2[1];
1785 return actions[id] = {
1786 action: request.action,
1787 data: request.options.data
1788 };
1789 });
1790 return this.send('ajax', {
1791 data: {
1792 actions: JSON.stringify(actions)
1793 },
1794 success: function success(data) {
1795 Object.entries(data.responses).forEach(function (_ref3) {
1796 var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
1797 id = _ref4[0],
1798 response = _ref4[1];
1799 var options = requests[id].options;
1800 if (options) {
1801 if (response.success) {
1802 options.deferred.resolve(response.data);
1803 } else if (!response.success) {
1804 options.deferred.reject(response.data);
1805 }
1806 }
1807 });
1808 },
1809 error: function error(data) {
1810 return Object.values(requests).forEach(function (args) {
1811 if (args.options) {
1812 args.options.deferred.reject(data);
1813 }
1814 });
1815 }
1816 });
1817 }
1818 }, {
1819 key: "prepareSend",
1820 value: function prepareSend(action, options) {
1821 var _this4 = this;
1822 var settings = this.getSettings(),
1823 ajaxParams = elementorCommon.helpers.cloneObject(settings.ajaxParams);
1824 options = options || {};
1825 action = settings.actionPrefix + action;
1826 jQuery.extend(ajaxParams, options);
1827 var requestConstants = elementorCommon.helpers.cloneObject(this.requestConstants);
1828 requestConstants.action = action;
1829 var isFormData = ajaxParams.data instanceof FormData;
1830 Object.entries(requestConstants).forEach(function (_ref5) {
1831 var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
1832 key = _ref6[0],
1833 value = _ref6[1];
1834 if (isFormData) {
1835 ajaxParams.data.append(key, value);
1836 } else {
1837 ajaxParams.data[key] = value;
1838 }
1839 });
1840 var successCallback = ajaxParams.success,
1841 errorCallback = ajaxParams.error;
1842 if (successCallback || errorCallback) {
1843 ajaxParams.success = function (response) {
1844 if (response.success && successCallback) {
1845 successCallback(response.data);
1846 }
1847 if (!response.success && errorCallback) {
1848 errorCallback(response.data);
1849 }
1850 };
1851 if (errorCallback) {
1852 ajaxParams.error = function (data) {
1853 return errorCallback(data);
1854 };
1855 } else {
1856 ajaxParams.error = function (xmlHttpRequest) {
1857 if (xmlHttpRequest.readyState || 'abort' !== xmlHttpRequest.statusText) {
1858 _this4.trigger('request:unhandledError', xmlHttpRequest);
1859 }
1860 };
1861 }
1862 }
1863 return ajaxParams;
1864 }
1865 }, {
1866 key: "send",
1867 value: function send(action, options) {
1868 return jQuery.ajax(this.prepareSend(action, options));
1869 }
1870 }, {
1871 key: "addRequestCache",
1872 value: function addRequestCache(request, data) {
1873 var cacheKey = this.getCacheKey(request);
1874 this.cache[cacheKey] = data;
1875 }
1876 }, {
1877 key: "invalidateCache",
1878 value: function invalidateCache(request) {
1879 var cacheKey = this.getCacheKey(request);
1880 delete this.cache[cacheKey];
1881 }
1882 }]);
1883 }(elementorModules.Module);
1884
1885 /***/ }),
1886
1887 /***/ "../core/common/modules/connect/assets/js/connect.js":
1888 /*!***********************************************************!*\
1889 !*** ../core/common/modules/connect/assets/js/connect.js ***!
1890 \***********************************************************/
1891 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1892
1893 "use strict";
1894 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
1895
1896
1897 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1898 Object.defineProperty(exports, "__esModule", ({
1899 value: true
1900 }));
1901 exports["default"] = void 0;
1902 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1903 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1904 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1905 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1906 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
1907 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1908 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)); }
1909 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1910 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; }
1911 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Vie) {
1912 function _default() {
1913 (0, _classCallCheck2.default)(this, _default);
1914 return _callSuper(this, _default, arguments);
1915 }
1916 (0, _inherits2.default)(_default, _elementorModules$Vie);
1917 return (0, _createClass2.default)(_default, [{
1918 key: "addPopupPlugin",
1919 value: function addPopupPlugin() {
1920 var counter = 0;
1921 jQuery.fn.elementorConnect = function (options) {
1922 var _this = this;
1923 // Open the Connect Dialog in a popup window.
1924 if (options !== null && options !== void 0 && options.popup) {
1925 jQuery(this).on('click', function (event) {
1926 var _options$popup, _options$popup2;
1927 event.preventDefault();
1928 var width = ((_options$popup = options.popup) === null || _options$popup === void 0 ? void 0 : _options$popup.width) || 600,
1929 height = ((_options$popup2 = options.popup) === null || _options$popup2 === void 0 ? void 0 : _options$popup2.height) || 700;
1930 window.open(jQuery(_this).attr('href') + '&mode=popup', 'elementorConnect', "toolbar=no, menubar=no, width=".concat(width, ", height=").concat(height, ", top=200, left=0"));
1931 });
1932 delete options.popup;
1933 }
1934 var settings = jQuery.extend({
1935 // These are the defaults.
1936 success: function success() {
1937 return location.reload();
1938 },
1939 error: function error() {
1940 elementor.notifications.showToast({
1941 message: __('Unable to connect', 'elementor')
1942 });
1943 },
1944 parseUrl: function parseUrl(url) {
1945 return url;
1946 } // Allow to change the url, e.g: replace placeholders like '%%template_type%%' with actual value.
1947 }, options);
1948 this.each(function () {
1949 counter++;
1950 var $this = jQuery(this),
1951 callbackId = 'cb' + counter;
1952 $this.attr({
1953 target: '_blank',
1954 rel: 'opener',
1955 href: settings.parseUrl($this.attr('href') + '&mode=popup&callback_id=' + callbackId)
1956 });
1957 elementorCommon.elements.$window.on('elementor/connect/success/' + callbackId, settings.success).on('elementor/connect/error/' + callbackId, settings.error);
1958 });
1959 return this;
1960 };
1961 }
1962 }, {
1963 key: "getDefaultSettings",
1964 value: function getDefaultSettings() {
1965 return {
1966 selectors: {
1967 connectButton: '#elementor-template-library-connect__button'
1968 }
1969 };
1970 }
1971 }, {
1972 key: "getDefaultElements",
1973 value: function getDefaultElements() {
1974 return {
1975 $connectButton: jQuery(this.getSettings('selectors.connectButton'))
1976 };
1977 }
1978 }, {
1979 key: "applyPopup",
1980 value: function applyPopup() {
1981 this.elements.$connectButton.elementorConnect();
1982 }
1983 }, {
1984 key: "onInit",
1985 value: function onInit() {
1986 _superPropGet(_default, "onInit", this, 3)([]);
1987 this.addPopupPlugin();
1988 this.applyPopup();
1989 }
1990 }]);
1991 }(elementorModules.ViewModule);
1992
1993 /***/ }),
1994
1995 /***/ "../core/common/modules/event-tracker/assets/js/data/commands-data/index.js":
1996 /*!**********************************************************************************!*\
1997 !*** ../core/common/modules/event-tracker/assets/js/data/commands-data/index.js ***!
1998 \**********************************************************************************/
1999 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2000
2001 "use strict";
2002
2003
2004 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2005 Object.defineProperty(exports, "__esModule", ({
2006 value: true
2007 }));
2008 exports.Index = void 0;
2009 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2010 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2011 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2012 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2013 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2014 var _commandData = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-data */ "../modules/web-cli/assets/js/modules/command-data.js"));
2015 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)); }
2016 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2017 var Index = exports.Index = /*#__PURE__*/function (_CommandData) {
2018 function Index() {
2019 (0, _classCallCheck2.default)(this, Index);
2020 return _callSuper(this, Index, arguments);
2021 }
2022 (0, _inherits2.default)(Index, _CommandData);
2023 return (0, _createClass2.default)(Index, null, [{
2024 key: "getEndpointFormat",
2025 value: function getEndpointFormat() {
2026 return 'send-event';
2027 }
2028 }]);
2029 }(_commandData.default);
2030
2031 /***/ }),
2032
2033 /***/ "../core/common/modules/event-tracker/assets/js/data/component.js":
2034 /*!************************************************************************!*\
2035 !*** ../core/common/modules/event-tracker/assets/js/data/component.js ***!
2036 \************************************************************************/
2037 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2038
2039 "use strict";
2040
2041
2042 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2043 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
2044 Object.defineProperty(exports, "__esModule", ({
2045 value: true
2046 }));
2047 exports["default"] = void 0;
2048 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2049 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2050 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2051 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2052 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2053 var _componentBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/component-base */ "../modules/web-cli/assets/js/modules/component-base.js"));
2054 var commandsData = _interopRequireWildcard(__webpack_require__(/*! ./commands-data/ */ "../core/common/modules/event-tracker/assets/js/data/commands-data/index.js"));
2055 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); }
2056 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)); }
2057 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2058 var Component = exports["default"] = /*#__PURE__*/function (_ComponentBase) {
2059 function Component() {
2060 (0, _classCallCheck2.default)(this, Component);
2061 return _callSuper(this, Component, arguments);
2062 }
2063 (0, _inherits2.default)(Component, _ComponentBase);
2064 return (0, _createClass2.default)(Component, [{
2065 key: "getNamespace",
2066 value: function getNamespace() {
2067 return 'event-tracker';
2068 }
2069 }, {
2070 key: "defaultData",
2071 value: function defaultData() {
2072 return this.importCommands(commandsData);
2073 }
2074 }]);
2075 }(_componentBase.default);
2076
2077 /***/ }),
2078
2079 /***/ "../core/common/modules/event-tracker/assets/js/events.js":
2080 /*!****************************************************************!*\
2081 !*** ../core/common/modules/event-tracker/assets/js/events.js ***!
2082 \****************************************************************/
2083 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2084
2085 "use strict";
2086
2087
2088 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2089 Object.defineProperty(exports, "__esModule", ({
2090 value: true
2091 }));
2092 exports["default"] = void 0;
2093 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2094 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2095 var _time = _interopRequireDefault(__webpack_require__(/*! elementor-utils/time */ "../assets/dev/js/utils/time.js"));
2096 var Events = exports["default"] = /*#__PURE__*/function () {
2097 function Events() {
2098 (0, _classCallCheck2.default)(this, Events);
2099 }
2100 return (0, _createClass2.default)(Events, [{
2101 key: "dispatchEvent",
2102 value: function dispatchEvent(eventData) {
2103 if (!eventData) {
2104 return;
2105 }
2106 eventData.ts = (0, _time.default)();
2107
2108 // No need to wait for response, no need to block browser in any way.
2109 $e.data.create('event-tracker/index', {
2110 event_data: eventData
2111 });
2112 }
2113 }]);
2114 }();
2115
2116 /***/ }),
2117
2118 /***/ "../core/common/modules/events-manager/assets/js/events-config.js":
2119 /*!************************************************************************!*\
2120 !*** ../core/common/modules/events-manager/assets/js/events-config.js ***!
2121 \************************************************************************/
2122 /***/ ((__unused_webpack_module, exports) => {
2123
2124 "use strict";
2125
2126
2127 Object.defineProperty(exports, "__esModule", ({
2128 value: true
2129 }));
2130 exports["default"] = void 0;
2131 var eventsConfig = {
2132 appTypes: {
2133 editor: 'editor',
2134 wpAdmin: 'wpadmin'
2135 },
2136 targetTypes: {
2137 dropdownItem: 'dropdown_item',
2138 button: 'button',
2139 tab: 'tab',
2140 toggle: 'toggle',
2141 searchInput: 'search_input',
2142 searchResult: 'search_result',
2143 buttons: 'buttons',
2144 searchWidget: 'search_widget'
2145 },
2146 interactionResults: {
2147 actionSelected: 'action_selected',
2148 navigate: 'navigate',
2149 create: 'create',
2150 sessionEnd: 'session_end',
2151 tabChanged: 'tab_changed',
2152 assetInserted: 'asset_inserted',
2153 assetFavorite: 'asset_favorite',
2154 aiGenerate: 'ai_generate',
2155 resultsUpdated: 'results_updated',
2156 noResults: 'no_results',
2157 selected: 'selected',
2158 promotionViewed: 'promotion_viewed',
2159 upgradeNow: 'upgrade_now'
2160 },
2161 targetNames: {
2162 publishDropdown: {
2163 saveDraft: 'save_draft',
2164 saveAsTemplate: 'save_as_template',
2165 viewPage: 'view_page',
2166 copyAndShare: 'copy_and_share'
2167 },
2168 pageList: {
2169 addNewPage: 'add_new_page'
2170 }
2171 },
2172 triggers: {
2173 click: 'Click',
2174 rightClick: 'Right Click',
2175 doubleClick: 'Double Click',
2176 accordionClick: 'Accordion Click',
2177 toggleClick: 'Toggle Click',
2178 dropdownClick: 'Click Dropdown',
2179 editorLoaded: 'Editor Loaded',
2180 visible: 'Visible',
2181 pageLoaded: 'Page Loaded',
2182 typing: 'Typing',
2183 tabSelect: 'Tab Select',
2184 insert: 'Insert'
2185 },
2186 locations: {
2187 widgetPanel: 'Widget Panel',
2188 topBar: 'Top Bar',
2189 sidebar: 'Sidebar',
2190 elementorEditor: 'Elementor Editor',
2191 templatesLibrary: {
2192 library: 'Templates Library'
2193 },
2194 app: {
2195 import: 'Import Kit',
2196 export: 'Export Kit',
2197 kitLibrary: 'Kit Library',
2198 cloudKitLibrary: 'Cloud Kit Library'
2199 },
2200 variables: 'Variables Panel',
2201 variablesManager: 'Variables Manager',
2202 admin: 'WP admin',
2203 structurePanel: 'Structure Panel',
2204 canvas: 'Canvas',
2205 leftPanel: 'Left Panel',
2206 elementorLibrary: 'Elementor Library',
2207 components: {
2208 instanceEditingPanel: 'Instance Editing Panel'
2209 }
2210 },
2211 secondaryLocations: {
2212 layout: 'Layout Section',
2213 basic: 'Basic Section',
2214 'pro-elements': 'Pro Section',
2215 general: 'General Section',
2216 'theme-elements': 'Site Section',
2217 'theme-elements-single': 'Single Section',
2218 'woocommerce-elements': 'WooCommerce Section',
2219 wordpress: 'WordPress Section',
2220 categories: 'Widgets Tab',
2221 global: 'Globals Tab',
2222 'whats-new': 'What\'s New',
2223 'document-settings': 'Document Settings icon',
2224 'preview-page': 'Preview Page',
2225 'publish-button': 'Publish Button',
2226 'widget-panel': 'Widget Panel Icon',
2227 finder: 'Finder',
2228 help: 'Help',
2229 elementorLogoDropdown: 'top_bar_elementor_logo_dropdown',
2230 elementorLogo: 'Elementor Logo',
2231 eLogoMenu: 'E-logo Menu',
2232 notes: 'Notes',
2233 siteSettings: 'Site Settings',
2234 structure: 'Structure',
2235 documentNameDropdown: 'Document Name dropdown',
2236 responsiveControls: 'Responsive controls',
2237 launchpad: 'launchpad',
2238 checklistHeader: 'Checklist Header',
2239 checklistSteps: 'Checklist Steps',
2240 userPreferences: 'User Preferences',
2241 contextMenu: 'Context Menu',
2242 templateLibrary: {
2243 saveModal: 'Save to Modal',
2244 moveModal: 'Move to Modal',
2245 bulkMoveModal: 'Bulk Move to Modal',
2246 copyModal: 'Copy to Modal',
2247 bulkCopyModal: 'Bulk Copy to Modal',
2248 saveModalSelectFolder: 'Save to Modal - select folder',
2249 saveModalSelectConnect: 'Save to Modal - connect',
2250 saveModalSelectUpgrade: 'Save to Modal - upgrade',
2251 importModal: 'Import Modal',
2252 newFolderModal: 'New Folder Modal',
2253 deleteDialog: 'Delete Dialog',
2254 deleteFolderDialog: 'Delete Folder Dialog',
2255 renameDialog: 'Rename Dialog',
2256 createFolderDialog: 'Create Folder Dialog',
2257 applySettingsDialog: 'Apply Settings Dialog',
2258 cloudTab: 'Cloud Tab',
2259 siteTab: 'Site Tab',
2260 cloudTabFolder: 'Cloud Tab - Folder',
2261 cloudTabConnect: 'Cloud Tab - Connect',
2262 cloudTabUpgrade: 'Cloud Tab - Upgrade',
2263 morePopup: 'Context Menu',
2264 quotaBar: 'Quota Bar'
2265 },
2266 kitLibrary: {
2267 cloudKitLibrary: 'kits_cloud_library',
2268 cloudKitLibraryConnect: 'kits_cloud_library_connect',
2269 cloudKitLibraryUpgrade: 'kits_cloud_library_upgrade',
2270 kitExportCustomization: 'kit_export_customization',
2271 kitExport: 'kit_export',
2272 kitExportCustomizationEdit: 'kit_export_customization_edit',
2273 kitExportSummary: 'kit_export_summary',
2274 kitImportUploadBox: 'kit_import_upload_box',
2275 kitImportCustomization: 'kit_import_customization',
2276 kitImportSummary: 'kit_import_summary'
2277 },
2278 variablesPopover: 'Variables Popover',
2279 admin: {
2280 pluginToolsTab: 'plugin_tools_tab',
2281 pluginWebsiteTemplatesTab: 'plugin_website_templates_tab'
2282 },
2283 componentsTab: 'Components Tab',
2284 canvasElement: 'Canvas Element',
2285 publishDropdown: 'Publish Dropdown',
2286 pageListDropdown: 'Page List Dropdown',
2287 emptyBox: 'Empty Box',
2288 searchBar: 'Search Bar',
2289 finderResults: 'Finder Results',
2290 libraryTabs: 'Library Tabs',
2291 assetCard: 'Asset Card'
2292 },
2293 elements: {
2294 accordionSection: 'Accordion section',
2295 buttonIcon: 'Button Icon',
2296 mainCta: 'Main CTA',
2297 button: 'Button',
2298 link: 'Link',
2299 dropdown: 'Dropdown',
2300 toggle: 'Toggle',
2301 launchpadChecklist: 'Checklist popup'
2302 },
2303 names: {
2304 v1: {
2305 layout: 'v1_widgets_tab_layout_section',
2306 basic: 'v1_widgets_tab_basic_section',
2307 'pro-elements': 'v1_widgets_tab_pro_section',
2308 general: 'v1_widgets_tab_general_section',
2309 'theme-elements': 'v1_widgets_tab_site_section',
2310 'theme-elements-single': 'v1_widgets_tab_single_section',
2311 'woocommerce-elements': 'v1_widgets_tab_woocommerce_section',
2312 wordpress: 'v1_widgets_tab_wordpress_section',
2313 categories: 'v1_widgets_tab',
2314 global: 'v1_globals_tab'
2315 },
2316 topBar: {
2317 whatsNew: 'top_bar_whats_new',
2318 documentSettings: 'top_bar_document_settings_icon',
2319 previewPage: 'top_bar_preview_page',
2320 publishButton: 'top_bar_publish_button',
2321 widgetPanel: 'top_bar_widget_panel_icon',
2322 finder: 'top_bar_finder',
2323 help: 'top_bar_help',
2324 history: 'top_bar_elementor_logo_dropdown_history',
2325 userPreferences: 'top_bar_elementor_logo_dropdown_user_preferences',
2326 keyboardShortcuts: 'top_bar_elementor_logo_dropdown_keyboard_shortcuts',
2327 exitToWordpress: 'top_bar_elementor_logo_dropdown_exit_to_wordpress',
2328 themeBuilder: 'top_bar_elementor_logo_dropdown_theme_builder',
2329 notes: 'top_bar_notes',
2330 siteSettings: 'top_bar_site_setting',
2331 structure: 'top_bar_structure',
2332 documentNameDropdown: 'top_bar_document_name_dropdown',
2333 responsiveControls: 'top_bar_responsive_controls',
2334 launchpadOn: 'top_bar_checklist_icon_show',
2335 launchpadOff: 'top_bar_checklist_icon_hide',
2336 elementorLogoDropdown: 'open_e_menu',
2337 connectAccount: 'connect_account',
2338 accountConnected: 'account_connected'
2339 },
2340 // ChecklistSteps event names are generated dynamically, based on stepId and action type taken: title, action, done, undone, upgrade
2341 elementorEditor: {
2342 checklist: {
2343 checklistHeaderClose: 'checklist_header_close_icon',
2344 checklistFirstPopup: 'checklist popup triggered'
2345 },
2346 userPreferences: {
2347 checklistShow: 'checklist_userpreferences_toggle_show',
2348 checklistHide: 'checklist_userpreferences_toggle_hide'
2349 }
2350 },
2351 variables: {
2352 open: 'open_variables_popover',
2353 add: 'add_new_variable',
2354 connect: 'connect_variable',
2355 save: 'save_new_variable',
2356 openManager: 'open_variables_manager',
2357 saveChanges: 'save_variables_changes',
2358 delete: 'delete_variable'
2359 },
2360 components: {
2361 createClicked: 'component_create_clicked',
2362 createCancelled: 'component_creation_cancelled',
2363 created: 'component_created',
2364 instanceAdded: 'component_instance_added',
2365 edited: 'component_edited',
2366 propertiesPanelOpened: 'component_properties_panel_opened',
2367 propertiesGroupCreated: 'component_properties_group_created',
2368 propertyExposed: 'component_property_exposed',
2369 propertyRemoved: 'component_property_removed',
2370 detached: 'component_detached'
2371 },
2372 global_classes: {
2373 classApplied: 'class_applied',
2374 classRemoved: 'class_removed',
2375 classManagerFilterCleared: 'class_manager_filter_cleared',
2376 classDeleted: 'class_deleted',
2377 classPublishConflict: 'class_publish_conflict',
2378 classRenamed: 'class_renamed',
2379 classCreated: 'class_created',
2380 classManagerSearched: 'class_manager_searched',
2381 classManagerFiltersOpened: 'class_manager_filters_opened',
2382 classManagerOpened: 'class_manager_opened',
2383 classManagerReorder: 'class_manager_reorder',
2384 classManagerFilterUsed: 'class_manager_filter_used',
2385 classUsageLocate: 'class_usage_locate',
2386 classUsageHovered: 'class_usage_hovered',
2387 classStyled: 'class_styled',
2388 classStateClicked: 'class_state_clicked',
2389 classUsageClicked: 'class_usage_clicked',
2390 classDuplicate: 'class_duplicate'
2391 },
2392 editorOne: {
2393 topBarPublishDropdown: 'top_bar_publish_dropdown',
2394 topBarPageList: 'top_bar_page_list',
2395 siteSettingsSession: 'site_settings_session',
2396 eLibraryNav: 'e_library_nav',
2397 eLibraryInsert: 'e_library_insert',
2398 eLibraryFavorite: 'e_library_favorite',
2399 eLibraryGenerateAi: 'e_library_generate_ai',
2400 finderSearchInput: 'finder_search_input',
2401 finderResultSelect: 'finder_result_select',
2402 canvasEmptyBoxAction: 'canvas_empty_box_action',
2403 widgetPanelSearch: 'widget_panel_search'
2404 },
2405 interactions: {
2406 created: 'interactions_created'
2407 },
2408 promotions: {
2409 viewPromotion: 'view_promotion',
2410 upgradePromotionClick: 'upgrade_promotion_click'
2411 }
2412 }
2413 };
2414 var _default = exports["default"] = eventsConfig;
2415
2416 /***/ }),
2417
2418 /***/ "../core/common/modules/events-manager/assets/js/module.js":
2419 /*!*****************************************************************!*\
2420 !*** ../core/common/modules/events-manager/assets/js/module.js ***!
2421 \*****************************************************************/
2422 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2423
2424 "use strict";
2425
2426
2427 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2428 Object.defineProperty(exports, "__esModule", ({
2429 value: true
2430 }));
2431 exports["default"] = void 0;
2432 var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "../node_modules/@babel/runtime/regenerator/index.js"));
2433 var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "../node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
2434 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2435 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2436 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2437 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2438 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2439 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
2440 var _eventsConfig = _interopRequireDefault(__webpack_require__(/*! ./events-config */ "../core/common/modules/events-manager/assets/js/events-config.js"));
2441 var _mixpanelBrowser = _interopRequireDefault(__webpack_require__(/*! mixpanel-browser */ "../node_modules/mixpanel-browser/dist/mixpanel.module.js"));
2442 var _tiers = __webpack_require__(/*! elementor-utils/tiers */ "../assets/dev/js/utils/tiers.js");
2443 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; }
2444 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; }
2445 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)); }
2446 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2447 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
2448 function _default() {
2449 var _this;
2450 (0, _classCallCheck2.default)(this, _default);
2451 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2452 args[_key] = arguments[_key];
2453 }
2454 _this = _callSuper(this, _default, [].concat(args));
2455 (0, _defineProperty2.default)(_this, "trackingEnabled", false);
2456 return _this;
2457 }
2458 (0, _inherits2.default)(_default, _elementorModules$Mod);
2459 return (0, _createClass2.default)(_default, [{
2460 key: "onInit",
2461 value: function onInit() {
2462 var _this2 = this;
2463 this.config = _eventsConfig.default;
2464 if (!this.canSendEvents()) {
2465 return;
2466 }
2467 this.initializeMixpanel(function () {
2468 return _this2.enableTracking();
2469 });
2470 }
2471 }, {
2472 key: "initializeMixpanel",
2473 value: function initializeMixpanel(onLoaded) {
2474 var _elementorCommon$conf;
2475 _mixpanelBrowser.default.init((_elementorCommon$conf = elementorCommon.config.editor_events) === null || _elementorCommon$conf === void 0 ? void 0 : _elementorCommon$conf.token, {
2476 persistence: 'localStorage',
2477 autocapture: false,
2478 flags: true,
2479 api_hosts: {
2480 flags: 'https://api-eu.mixpanel.com'
2481 },
2482 loaded: onLoaded
2483 });
2484 }
2485 }, {
2486 key: "enableTracking",
2487 value: function enableTracking() {
2488 var _elementorCommon$conf2;
2489 if (!this.isMixpanelReady()) {
2490 return;
2491 }
2492 var userId = (_elementorCommon$conf2 = elementorCommon.config.library_connect) === null || _elementorCommon$conf2 === void 0 ? void 0 : _elementorCommon$conf2.user_id;
2493 if (userId) {
2494 var _elementorCommon$conf3;
2495 _mixpanelBrowser.default.identify(userId);
2496 _mixpanelBrowser.default.register({
2497 appType: 'Editor'
2498 });
2499 _mixpanelBrowser.default.people.set_once({
2500 $user_id: userId,
2501 $last_login: new Date().toISOString(),
2502 $plan_type: ((_elementorCommon$conf3 = elementorCommon.config.library_connect) === null || _elementorCommon$conf3 === void 0 ? void 0 : _elementorCommon$conf3.plan_type) || _tiers.TIERS.free
2503 });
2504 }
2505 this.trackingEnabled = true;
2506 }
2507 }, {
2508 key: "dispatchEvent",
2509 value: function dispatchEvent(name, data) {
2510 var _elementorCommon$conf4, _elementorCommon$conf5, _elementorCommon$conf6, _elementorCommon$conf7, _elementorCommon$conf8, _elementorCommon$conf9, _elementorCommon$conf0, _elementorCommon$conf1, _elementorCommon$conf10;
2511 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2512 if (!this.canSendEvents()) {
2513 return;
2514 }
2515 if (!this.trackingEnabled) {
2516 this.enableTracking();
2517 }
2518 var eventData = _objectSpread({
2519 user_id: ((_elementorCommon$conf4 = elementorCommon.config.library_connect) === null || _elementorCommon$conf4 === void 0 ? void 0 : _elementorCommon$conf4.user_id) || null,
2520 user_roles: ((_elementorCommon$conf5 = elementorCommon.config.library_connect) === null || _elementorCommon$conf5 === void 0 ? void 0 : _elementorCommon$conf5.user_roles) || [],
2521 subscription_id: ((_elementorCommon$conf6 = elementorCommon.config.editor_events) === null || _elementorCommon$conf6 === void 0 ? void 0 : _elementorCommon$conf6.subscription_id) || null,
2522 user_tier: ((_elementorCommon$conf7 = elementorCommon.config.library_connect) === null || _elementorCommon$conf7 === void 0 ? void 0 : _elementorCommon$conf7.current_access_tier) || null,
2523 url: (_elementorCommon$conf8 = elementorCommon.config.editor_events) === null || _elementorCommon$conf8 === void 0 ? void 0 : _elementorCommon$conf8.site_url,
2524 wp_version: (_elementorCommon$conf9 = elementorCommon.config.editor_events) === null || _elementorCommon$conf9 === void 0 ? void 0 : _elementorCommon$conf9.wp_version,
2525 client_id: (_elementorCommon$conf0 = elementorCommon.config.editor_events) === null || _elementorCommon$conf0 === void 0 ? void 0 : _elementorCommon$conf0.site_key,
2526 app_version: (_elementorCommon$conf1 = elementorCommon.config.editor_events) === null || _elementorCommon$conf1 === void 0 ? void 0 : _elementorCommon$conf1.elementor_version,
2527 site_language: (_elementorCommon$conf10 = elementorCommon.config.editor_events) === null || _elementorCommon$conf10 === void 0 ? void 0 : _elementorCommon$conf10.site_language
2528 }, data);
2529 _mixpanelBrowser.default.track(name, eventData, options);
2530 }
2531 }, {
2532 key: "featureFlagIsActive",
2533 value: function () {
2534 var _featureFlagIsActive = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(flagName) {
2535 var _mixpanel$flags;
2536 var isEnabled;
2537 return _regenerator.default.wrap(function (_context) {
2538 while (1) switch (_context.prev = _context.next) {
2539 case 0:
2540 if (!('function' !== typeof (_mixpanelBrowser.default === null || _mixpanelBrowser.default === void 0 || (_mixpanel$flags = _mixpanelBrowser.default.flags) === null || _mixpanel$flags === void 0 ? void 0 : _mixpanel$flags.is_enabled))) {
2541 _context.next = 1;
2542 break;
2543 }
2544 return _context.abrupt("return", false);
2545 case 1:
2546 _context.next = 2;
2547 return _mixpanelBrowser.default.flags.is_enabled(flagName, false);
2548 case 2:
2549 isEnabled = _context.sent;
2550 return _context.abrupt("return", true === isEnabled);
2551 case 3:
2552 case "end":
2553 return _context.stop();
2554 }
2555 }, _callee);
2556 }));
2557 function featureFlagIsActive(_x) {
2558 return _featureFlagIsActive.apply(this, arguments);
2559 }
2560 return featureFlagIsActive;
2561 }()
2562 }, {
2563 key: "getExperimentVariant",
2564 value: function () {
2565 var _getExperimentVariant = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2(experimentName) {
2566 var defaultValue,
2567 _elementorCommon$conf11,
2568 _elementorCommon$conf12,
2569 isAbTestingEnabled,
2570 variant,
2571 _args2 = arguments,
2572 _t;
2573 return _regenerator.default.wrap(function (_context2) {
2574 while (1) switch (_context2.prev = _context2.next) {
2575 case 0:
2576 defaultValue = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : 'control';
2577 _context2.prev = 1;
2578 if (this.canSendEvents()) {
2579 _context2.next = 2;
2580 break;
2581 }
2582 return _context2.abrupt("return", defaultValue);
2583 case 2:
2584 isAbTestingEnabled = (_elementorCommon$conf11 = (_elementorCommon$conf12 = elementorCommon.config.editor_events) === null || _elementorCommon$conf12 === void 0 ? void 0 : _elementorCommon$conf12.flags_enabled) !== null && _elementorCommon$conf11 !== void 0 ? _elementorCommon$conf11 : false;
2585 if (isAbTestingEnabled) {
2586 _context2.next = 3;
2587 break;
2588 }
2589 return _context2.abrupt("return", defaultValue);
2590 case 3:
2591 if (_mixpanelBrowser.default) {
2592 _context2.next = 4;
2593 break;
2594 }
2595 return _context2.abrupt("return", defaultValue);
2596 case 4:
2597 if (!this.trackingEnabled) {
2598 this.enableTracking();
2599 }
2600 if (_mixpanelBrowser.default.flags) {
2601 _context2.next = 5;
2602 break;
2603 }
2604 return _context2.abrupt("return", defaultValue);
2605 case 5:
2606 if (!('function' !== typeof _mixpanelBrowser.default.flags.get_variant_value)) {
2607 _context2.next = 6;
2608 break;
2609 }
2610 return _context2.abrupt("return", defaultValue);
2611 case 6:
2612 _context2.next = 7;
2613 return _mixpanelBrowser.default.flags.get_variant_value(experimentName, defaultValue);
2614 case 7:
2615 variant = _context2.sent;
2616 if (!(undefined === variant || null === variant)) {
2617 _context2.next = 8;
2618 break;
2619 }
2620 return _context2.abrupt("return", defaultValue);
2621 case 8:
2622 return _context2.abrupt("return", variant);
2623 case 9:
2624 _context2.prev = 9;
2625 _t = _context2["catch"](1);
2626 return _context2.abrupt("return", defaultValue);
2627 case 10:
2628 case "end":
2629 return _context2.stop();
2630 }
2631 }, _callee2, this, [[1, 9]]);
2632 }));
2633 function getExperimentVariant(_x2) {
2634 return _getExperimentVariant.apply(this, arguments);
2635 }
2636 return getExperimentVariant;
2637 }()
2638 }, {
2639 key: "startExperiment",
2640 value: function startExperiment(experimentName, experimentVariant) {
2641 if (!this.trackingEnabled) {
2642 return;
2643 }
2644 _mixpanelBrowser.default.track('$experiment_started', {
2645 'Experiment name': experimentName,
2646 'Variant name': experimentVariant
2647 });
2648 }
2649 }, {
2650 key: "isMixpanelReady",
2651 value: function isMixpanelReady() {
2652 if ('undefined' === typeof _mixpanelBrowser.default || !_mixpanelBrowser.default) {
2653 return false;
2654 }
2655 try {
2656 var distinctId = _mixpanelBrowser.default.get_distinct_id();
2657 return distinctId !== undefined && distinctId !== null;
2658 } catch (error) {
2659 return false;
2660 }
2661 }
2662 }, {
2663 key: "canSendEvents",
2664 value: function canSendEvents() {
2665 var _elementorCommon;
2666 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);
2667 }
2668 }, {
2669 key: "getMixpanelInstance",
2670 value: function getMixpanelInstance() {
2671 return this.isMixpanelReady() ? _mixpanelBrowser.default : undefined;
2672 }
2673 }]);
2674 }(elementorModules.Module);
2675
2676 /***/ }),
2677
2678 /***/ "../core/common/modules/finder/assets/js/commands/index.js":
2679 /*!*****************************************************************!*\
2680 !*** ../core/common/modules/finder/assets/js/commands/index.js ***!
2681 \*****************************************************************/
2682 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2683
2684 "use strict";
2685
2686
2687 Object.defineProperty(exports, "__esModule", ({
2688 value: true
2689 }));
2690 Object.defineProperty(exports, "NavigateDown", ({
2691 enumerable: true,
2692 get: function get() {
2693 return _navigateDown.NavigateDown;
2694 }
2695 }));
2696 Object.defineProperty(exports, "NavigateSelect", ({
2697 enumerable: true,
2698 get: function get() {
2699 return _navigateSelect.NavigateSelect;
2700 }
2701 }));
2702 Object.defineProperty(exports, "NavigateUp", ({
2703 enumerable: true,
2704 get: function get() {
2705 return _navigateUp.NavigateUp;
2706 }
2707 }));
2708 var _navigateDown = __webpack_require__(/*! ./navigate-down */ "../core/common/modules/finder/assets/js/commands/navigate-down.js");
2709 var _navigateSelect = __webpack_require__(/*! ./navigate-select */ "../core/common/modules/finder/assets/js/commands/navigate-select.js");
2710 var _navigateUp = __webpack_require__(/*! ./navigate-up */ "../core/common/modules/finder/assets/js/commands/navigate-up.js");
2711
2712 /***/ }),
2713
2714 /***/ "../core/common/modules/finder/assets/js/commands/navigate-down.js":
2715 /*!*************************************************************************!*\
2716 !*** ../core/common/modules/finder/assets/js/commands/navigate-down.js ***!
2717 \*************************************************************************/
2718 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2719
2720 "use strict";
2721
2722
2723 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2724 Object.defineProperty(exports, "__esModule", ({
2725 value: true
2726 }));
2727 exports["default"] = exports.NavigateDown = void 0;
2728 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2729 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2730 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2731 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2732 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2733 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2734 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)); }
2735 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2736 var NavigateDown = exports.NavigateDown = /*#__PURE__*/function (_CommandBase) {
2737 function NavigateDown() {
2738 (0, _classCallCheck2.default)(this, NavigateDown);
2739 return _callSuper(this, NavigateDown, arguments);
2740 }
2741 (0, _inherits2.default)(NavigateDown, _CommandBase);
2742 return (0, _createClass2.default)(NavigateDown, [{
2743 key: "apply",
2744 value: function apply() {
2745 this.component.getItemsView().activateNextItem();
2746 }
2747 }]);
2748 }(_commandBase.default);
2749 var _default = exports["default"] = NavigateDown;
2750
2751 /***/ }),
2752
2753 /***/ "../core/common/modules/finder/assets/js/commands/navigate-select.js":
2754 /*!***************************************************************************!*\
2755 !*** ../core/common/modules/finder/assets/js/commands/navigate-select.js ***!
2756 \***************************************************************************/
2757 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2758
2759 "use strict";
2760
2761
2762 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2763 Object.defineProperty(exports, "__esModule", ({
2764 value: true
2765 }));
2766 exports["default"] = exports.NavigateSelect = void 0;
2767 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2768 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2769 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2770 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2771 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2772 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2773 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)); }
2774 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2775 var NavigateSelect = exports.NavigateSelect = /*#__PURE__*/function (_CommandBase) {
2776 function NavigateSelect() {
2777 (0, _classCallCheck2.default)(this, NavigateSelect);
2778 return _callSuper(this, NavigateSelect, arguments);
2779 }
2780 (0, _inherits2.default)(NavigateSelect, _CommandBase);
2781 return (0, _createClass2.default)(NavigateSelect, [{
2782 key: "apply",
2783 value: function apply(args) {
2784 this.component.getItemsView().goToActiveItem(args);
2785 }
2786 }]);
2787 }(_commandBase.default);
2788 var _default = exports["default"] = NavigateSelect;
2789
2790 /***/ }),
2791
2792 /***/ "../core/common/modules/finder/assets/js/commands/navigate-up.js":
2793 /*!***********************************************************************!*\
2794 !*** ../core/common/modules/finder/assets/js/commands/navigate-up.js ***!
2795 \***********************************************************************/
2796 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2797
2798 "use strict";
2799
2800
2801 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2802 Object.defineProperty(exports, "__esModule", ({
2803 value: true
2804 }));
2805 exports["default"] = exports.NavigateUp = void 0;
2806 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2807 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2808 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2809 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2810 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2811 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2812 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)); }
2813 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2814 var NavigateUp = exports.NavigateUp = /*#__PURE__*/function (_CommandBase) {
2815 function NavigateUp() {
2816 (0, _classCallCheck2.default)(this, NavigateUp);
2817 return _callSuper(this, NavigateUp, arguments);
2818 }
2819 (0, _inherits2.default)(NavigateUp, _CommandBase);
2820 return (0, _createClass2.default)(NavigateUp, [{
2821 key: "apply",
2822 value: function apply() {
2823 this.component.getItemsView().activateNextItem(true);
2824 }
2825 }]);
2826 }(_commandBase.default);
2827 var _default = exports["default"] = NavigateUp;
2828
2829 /***/ }),
2830
2831 /***/ "../core/common/modules/finder/assets/js/component.js":
2832 /*!************************************************************!*\
2833 !*** ../core/common/modules/finder/assets/js/component.js ***!
2834 \************************************************************/
2835 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2836
2837 "use strict";
2838
2839
2840 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2841 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
2842 Object.defineProperty(exports, "__esModule", ({
2843 value: true
2844 }));
2845 exports["default"] = void 0;
2846 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
2847 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2848 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2849 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2850 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2851 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
2852 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2853 var _componentModalBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/component-modal-base */ "../modules/web-cli/assets/js/modules/component-modal-base.js"));
2854 var _layout = _interopRequireDefault(__webpack_require__(/*! ./modal/views/layout */ "../core/common/modules/finder/assets/js/modal/views/layout.js"));
2855 var commands = _interopRequireWildcard(__webpack_require__(/*! ./commands/ */ "../core/common/modules/finder/assets/js/commands/index.js"));
2856 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); }
2857 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; }
2858 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; }
2859 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)); }
2860 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2861 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; }
2862 var Component = exports["default"] = /*#__PURE__*/function (_ComponentModalBase) {
2863 function Component() {
2864 (0, _classCallCheck2.default)(this, Component);
2865 return _callSuper(this, Component, arguments);
2866 }
2867 (0, _inherits2.default)(Component, _ComponentModalBase);
2868 return (0, _createClass2.default)(Component, [{
2869 key: "getNamespace",
2870 value: function getNamespace() {
2871 return 'finder';
2872 }
2873 }, {
2874 key: "defaultShortcuts",
2875 value: function defaultShortcuts() {
2876 var _this = this;
2877 return {
2878 '': {
2879 keys: 'ctrl+e'
2880 },
2881 'navigate-down': {
2882 keys: 'down',
2883 scopes: [this.getNamespace()],
2884 dependency: function dependency() {
2885 return _this.getItemsView();
2886 }
2887 },
2888 'navigate-up': {
2889 keys: 'up',
2890 scopes: [this.getNamespace()],
2891 dependency: function dependency() {
2892 return _this.getItemsView();
2893 }
2894 },
2895 'navigate-select': {
2896 keys: 'enter',
2897 scopes: [this.getNamespace()],
2898 dependency: function dependency() {
2899 return _this.getItemsView().$activeItem;
2900 }
2901 }
2902 };
2903 }
2904 }, {
2905 key: "defaultCommands",
2906 value: function defaultCommands() {
2907 var modalCommands = _superPropGet(Component, "defaultCommands", this, 3)([]);
2908 return _objectSpread(_objectSpread({
2909 'navigate/down': function navigate_down() {
2910 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/down' )", '3.0.0', "$e.run( 'finder/navigate-down' )");
2911 $e.run('finder/navigate-down');
2912 },
2913 'navigate/up': function navigate_up() {
2914 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/up' )", '3.0.0', "$e.run( 'finder/navigate-up' )");
2915 $e.run('finder/navigate-up');
2916 },
2917 'navigate/select': function navigate_select(event) {
2918 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/select', event )", '3.0.0', "$e.run( 'finder/navigate-select', event )");
2919
2920 // TODO: Fix $e.shortcuts use args. ( args.event ).
2921 $e.run('finder/navigate-select', event);
2922 }
2923 }, modalCommands), this.importCommands(commands));
2924 }
2925 }, {
2926 key: "getModalLayout",
2927 value: function getModalLayout() {
2928 return _layout.default;
2929 }
2930 }, {
2931 key: "getItemsView",
2932 value: function getItemsView() {
2933 return this.layout.modalContent.currentView.content.currentView;
2934 }
2935 }]);
2936 }(_componentModalBase.default);
2937
2938 /***/ }),
2939
2940 /***/ "../core/common/modules/finder/assets/js/finder.js":
2941 /*!*********************************************************!*\
2942 !*** ../core/common/modules/finder/assets/js/finder.js ***!
2943 \*********************************************************/
2944 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2945
2946 "use strict";
2947
2948
2949 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2950 Object.defineProperty(exports, "__esModule", ({
2951 value: true
2952 }));
2953 exports["default"] = void 0;
2954 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2955 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2956 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2957 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2958 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2959 var _component = _interopRequireDefault(__webpack_require__(/*! ./component */ "../core/common/modules/finder/assets/js/component.js"));
2960 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)); }
2961 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2962 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
2963 function _default() {
2964 (0, _classCallCheck2.default)(this, _default);
2965 return _callSuper(this, _default, arguments);
2966 }
2967 (0, _inherits2.default)(_default, _elementorModules$Mod);
2968 return (0, _createClass2.default)(_default, [{
2969 key: "onInit",
2970 value: function onInit() {
2971 // TODO: Temp fix, do not load finder in theme-builder.
2972 // Better to pass into '$e' constructor the app owner. ( admin, editor, preview, iframe ).
2973 if (window.top !== window) {
2974 return;
2975 }
2976 this.channel = Backbone.Radio.channel('ELEMENTOR:finder');
2977 $e.components.register(new _component.default({
2978 manager: this
2979 }));
2980 }
2981 }]);
2982 }(elementorModules.Module);
2983
2984 /***/ }),
2985
2986 /***/ "../core/common/modules/finder/assets/js/modal/model/item.js":
2987 /*!*******************************************************************!*\
2988 !*** ../core/common/modules/finder/assets/js/modal/model/item.js ***!
2989 \*******************************************************************/
2990 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2991
2992 "use strict";
2993
2994
2995 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2996 Object.defineProperty(exports, "__esModule", ({
2997 value: true
2998 }));
2999 exports["default"] = void 0;
3000 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3001 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3002 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3003 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3004 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3005 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)); }
3006 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3007 var _default = exports["default"] = /*#__PURE__*/function (_Backbone$Model) {
3008 function _default() {
3009 (0, _classCallCheck2.default)(this, _default);
3010 return _callSuper(this, _default, arguments);
3011 }
3012 (0, _inherits2.default)(_default, _Backbone$Model);
3013 return (0, _createClass2.default)(_default, [{
3014 key: "defaults",
3015 value: function defaults() {
3016 return {
3017 description: '',
3018 icon: 'settings',
3019 url: '',
3020 keywords: [],
3021 actions: [],
3022 lock: null
3023 };
3024 }
3025 }]);
3026 }(Backbone.Model);
3027
3028 /***/ }),
3029
3030 /***/ "../core/common/modules/finder/assets/js/modal/views/categories.js":
3031 /*!*************************************************************************!*\
3032 !*** ../core/common/modules/finder/assets/js/modal/views/categories.js ***!
3033 \*************************************************************************/
3034 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3035
3036 "use strict";
3037
3038
3039 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3040 Object.defineProperty(exports, "__esModule", ({
3041 value: true
3042 }));
3043 exports["default"] = void 0;
3044 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3045 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3046 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3047 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3048 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3049 var _category = _interopRequireDefault(__webpack_require__(/*! ./category */ "../core/common/modules/finder/assets/js/modal/views/category.js"));
3050 var _dynamicCategory = _interopRequireDefault(__webpack_require__(/*! ./dynamic-category */ "../core/common/modules/finder/assets/js/modal/views/dynamic-category.js"));
3051 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)); }
3052 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3053 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$Composite) {
3054 function _default() {
3055 (0, _classCallCheck2.default)(this, _default);
3056 return _callSuper(this, _default, arguments);
3057 }
3058 (0, _inherits2.default)(_default, _Marionette$Composite);
3059 return (0, _createClass2.default)(_default, [{
3060 key: "id",
3061 value: function id() {
3062 return 'elementor-finder__results-container';
3063 }
3064 }, {
3065 key: "ui",
3066 value: function ui() {
3067 this.selectors = {
3068 noResults: '#elementor-finder__no-results',
3069 categoryItem: '.elementor-finder__results__item'
3070 };
3071 return this.selectors;
3072 }
3073 }, {
3074 key: "events",
3075 value: function events() {
3076 return {
3077 'mouseenter @ui.categoryItem': 'onCategoryItemMouseEnter'
3078 };
3079 }
3080 }, {
3081 key: "getTemplate",
3082 value: function getTemplate() {
3083 return '#tmpl-elementor-finder-results-container';
3084 }
3085 }, {
3086 key: "getChildView",
3087 value: function getChildView(childModel) {
3088 return childModel.get('dynamic') ? _dynamicCategory.default : _category.default;
3089 }
3090 }, {
3091 key: "initialize",
3092 value: function initialize() {
3093 this.$activeItem = null;
3094 this.childViewContainer = '#elementor-finder__results';
3095 this.collection = new Backbone.Collection(Object.values(elementorCommon.finder.getSettings('data')));
3096 }
3097 }, {
3098 key: "activateItem",
3099 value: function activateItem($item) {
3100 if (this.$activeItem) {
3101 this.$activeItem.removeClass('elementor-active');
3102 }
3103 $item.addClass('elementor-active');
3104 this.$activeItem = $item;
3105 }
3106 }, {
3107 key: "activateNextItem",
3108 value: function activateNextItem(reverse) {
3109 var $allItems = jQuery(this.selectors.categoryItem);
3110 var nextItemIndex = 0;
3111 if (this.$activeItem) {
3112 nextItemIndex = $allItems.index(this.$activeItem) + (reverse ? -1 : 1);
3113 if (nextItemIndex >= $allItems.length) {
3114 nextItemIndex = 0;
3115 } else if (nextItemIndex < 0) {
3116 nextItemIndex = $allItems.length - 1;
3117 }
3118 }
3119 var $nextItem = $allItems.eq(nextItemIndex);
3120 this.activateItem($nextItem);
3121 $nextItem[0].scrollIntoView({
3122 block: 'nearest'
3123 });
3124 }
3125 }, {
3126 key: "goToActiveItem",
3127 value: function goToActiveItem(event) {
3128 var $a = this.$activeItem.children('a'),
3129 isControlClicked = $e.shortcuts.isControlEvent(event);
3130 if (isControlClicked) {
3131 $a.attr('target', '_blank');
3132 }
3133 $a[0].click();
3134 if (isControlClicked) {
3135 $a.removeAttr('target');
3136 }
3137 }
3138 }, {
3139 key: "onCategoryItemMouseEnter",
3140 value: function onCategoryItemMouseEnter(event) {
3141 this.activateItem(jQuery(event.currentTarget));
3142 }
3143 }, {
3144 key: "onChildviewToggleVisibility",
3145 value: function onChildviewToggleVisibility() {
3146 var allCategoriesAreEmpty = this.children.every(function (child) {
3147 return !child.isVisible;
3148 });
3149 this.ui.noResults.toggle(allCategoriesAreEmpty);
3150 }
3151 }]);
3152 }(Marionette.CompositeView);
3153
3154 /***/ }),
3155
3156 /***/ "../core/common/modules/finder/assets/js/modal/views/category.js":
3157 /*!***********************************************************************!*\
3158 !*** ../core/common/modules/finder/assets/js/modal/views/category.js ***!
3159 \***********************************************************************/
3160 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3161
3162 "use strict";
3163
3164
3165 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3166 Object.defineProperty(exports, "__esModule", ({
3167 value: true
3168 }));
3169 exports["default"] = void 0;
3170 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3171 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3172 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3173 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3174 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3175 var _item = _interopRequireDefault(__webpack_require__(/*! ./item */ "../core/common/modules/finder/assets/js/modal/views/item.js"));
3176 var _item2 = _interopRequireDefault(__webpack_require__(/*! ../model/item */ "../core/common/modules/finder/assets/js/modal/model/item.js"));
3177 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)); }
3178 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3179 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$Composite) {
3180 function _default() {
3181 (0, _classCallCheck2.default)(this, _default);
3182 return _callSuper(this, _default, arguments);
3183 }
3184 (0, _inherits2.default)(_default, _Marionette$Composite);
3185 return (0, _createClass2.default)(_default, [{
3186 key: "className",
3187 value: function className() {
3188 return 'elementor-finder__results__category';
3189 }
3190 }, {
3191 key: "getTemplate",
3192 value: function getTemplate() {
3193 return '#tmpl-elementor-finder__results__category';
3194 }
3195 }, {
3196 key: "getChildView",
3197 value: function getChildView() {
3198 return _item.default;
3199 }
3200 }, {
3201 key: "initialize",
3202 value: function initialize() {
3203 this.childViewContainer = '.elementor-finder__results__category__items';
3204 this.isVisible = true;
3205 var items = this.model.get('items');
3206 if (items) {
3207 items = Object.values(items);
3208 }
3209 this.collection = new Backbone.Collection(items, {
3210 model: _item2.default
3211 });
3212 }
3213 }, {
3214 key: "filter",
3215 value: function filter(childModel) {
3216 var textFilter = this.getTextFilter();
3217 if (childModel.get('title').toLowerCase().indexOf(textFilter) >= 0) {
3218 return true;
3219 }
3220 return childModel.get('keywords').some(function (keyword) {
3221 return keyword.indexOf(textFilter) >= 0;
3222 });
3223 }
3224 }, {
3225 key: "getTextFilter",
3226 value: function getTextFilter() {
3227 return elementorCommon.finder.channel.request('filter:text').trim().toLowerCase();
3228 }
3229 }, {
3230 key: "toggleElement",
3231 value: function toggleElement() {
3232 var isCurrentlyVisible = !!this.children.length;
3233 if (isCurrentlyVisible !== this.isVisible) {
3234 this.isVisible = isCurrentlyVisible;
3235 this.$el.toggle(isCurrentlyVisible);
3236 this.triggerMethod('toggle:visibility');
3237 }
3238 }
3239 }, {
3240 key: "onRender",
3241 value: function onRender() {
3242 this.listenTo(elementorCommon.finder.channel, 'filter:change', this.onFilterChange.bind(this));
3243 }
3244 }, {
3245 key: "onFilterChange",
3246 value: function onFilterChange() {
3247 this._renderChildren();
3248 }
3249 }, {
3250 key: "onRenderCollection",
3251 value: function onRenderCollection() {
3252 this.toggleElement();
3253 }
3254 }]);
3255 }(Marionette.CompositeView);
3256
3257 /***/ }),
3258
3259 /***/ "../core/common/modules/finder/assets/js/modal/views/content.js":
3260 /*!**********************************************************************!*\
3261 !*** ../core/common/modules/finder/assets/js/modal/views/content.js ***!
3262 \**********************************************************************/
3263 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3264
3265 "use strict";
3266
3267
3268 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3269 Object.defineProperty(exports, "__esModule", ({
3270 value: true
3271 }));
3272 exports["default"] = void 0;
3273 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3274 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3275 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3276 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3277 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3278 var _categories = _interopRequireDefault(__webpack_require__(/*! ./categories */ "../core/common/modules/finder/assets/js/modal/views/categories.js"));
3279 var _editorOneEvents = __webpack_require__(/*! elementor-editor-utils/editor-one-events */ "../assets/dev/js/editor/utils/editor-one-events.js");
3280 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
3281 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3282 var FINDER_SEARCH_DEBOUNCE_MS = 300;
3283 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$LayoutVie) {
3284 function _default() {
3285 (0, _classCallCheck2.default)(this, _default);
3286 return _callSuper(this, _default, arguments);
3287 }
3288 (0, _inherits2.default)(_default, _Marionette$LayoutVie);
3289 return (0, _createClass2.default)(_default, [{
3290 key: "id",
3291 value: function id() {
3292 return 'elementor-finder';
3293 }
3294 }, {
3295 key: "getTemplate",
3296 value: function getTemplate() {
3297 return '#tmpl-elementor-finder';
3298 }
3299 }, {
3300 key: "ui",
3301 value: function ui() {
3302 return {
3303 searchInput: '#elementor-finder__search__input'
3304 };
3305 }
3306 }, {
3307 key: "events",
3308 value: function events() {
3309 return {
3310 'input @ui.searchInput': 'onSearchInputInput'
3311 };
3312 }
3313 }, {
3314 key: "regions",
3315 value: function regions() {
3316 return {
3317 content: '#elementor-finder__content'
3318 };
3319 }
3320 }, {
3321 key: "initialize",
3322 value: function initialize() {
3323 this.debouncedTrackSearch = (0, _editorOneEvents.createDebouncedFinderSearch)(FINDER_SEARCH_DEBOUNCE_MS);
3324 }
3325 }, {
3326 key: "showCategoriesView",
3327 value: function showCategoriesView() {
3328 this.content.show(new _categories.default());
3329 }
3330 }, {
3331 key: "getResultsCount",
3332 value: function getResultsCount() {
3333 if (!this.content.currentView) {
3334 return 0;
3335 }
3336 var $visibleItems = this.content.currentView.$el.find('.elementor-finder__results__item:visible');
3337 return $visibleItems.length;
3338 }
3339 }, {
3340 key: "onSearchInputInput",
3341 value: function onSearchInputInput() {
3342 var _this = this;
3343 var value = this.ui.searchInput.val();
3344 if (value) {
3345 elementorCommon.finder.channel.reply('filter:text', value).trigger('filter:change');
3346 if (!(this.content.currentView instanceof _categories.default)) {
3347 this.showCategoriesView();
3348 }
3349 setTimeout(function () {
3350 var resultsCount = _this.getResultsCount();
3351 _this.debouncedTrackSearch(resultsCount, value);
3352 }, 50);
3353 }
3354 this.content.currentView.$el.toggle(!!value);
3355 }
3356 }, {
3357 key: "onDestroy",
3358 value: function onDestroy() {
3359 var _this$debouncedTrackS;
3360 if ((_this$debouncedTrackS = this.debouncedTrackSearch) !== null && _this$debouncedTrackS !== void 0 && _this$debouncedTrackS.cancel) {
3361 this.debouncedTrackSearch.cancel();
3362 }
3363 }
3364 }]);
3365 }(Marionette.LayoutView);
3366
3367 /***/ }),
3368
3369 /***/ "../core/common/modules/finder/assets/js/modal/views/dynamic-category.js":
3370 /*!*******************************************************************************!*\
3371 !*** ../core/common/modules/finder/assets/js/modal/views/dynamic-category.js ***!
3372 \*******************************************************************************/
3373 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3374
3375 "use strict";
3376
3377
3378 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3379 Object.defineProperty(exports, "__esModule", ({
3380 value: true
3381 }));
3382 exports["default"] = void 0;
3383 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3384 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3385 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3386 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3387 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
3388 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3389 var _category = _interopRequireDefault(__webpack_require__(/*! ./category */ "../core/common/modules/finder/assets/js/modal/views/category.js"));
3390 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)); }
3391 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3392 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; }
3393 var _default = exports["default"] = /*#__PURE__*/function (_Category) {
3394 function _default() {
3395 (0, _classCallCheck2.default)(this, _default);
3396 return _callSuper(this, _default, arguments);
3397 }
3398 (0, _inherits2.default)(_default, _Category);
3399 return (0, _createClass2.default)(_default, [{
3400 key: "className",
3401 value: function className() {
3402 return _superPropGet(_default, "className", this, 3)([]) + ' elementor-finder__results__category--dynamic';
3403 }
3404 }, {
3405 key: "ui",
3406 value: function ui() {
3407 return {
3408 title: '.elementor-finder__results__category__title'
3409 };
3410 }
3411 }, {
3412 key: "fetchData",
3413 value: function fetchData() {
3414 var _this = this;
3415 this.ui.loadingIcon.show();
3416 elementorCommon.ajax.addRequest('finder_get_category_items', {
3417 data: {
3418 category: this.model.get('name'),
3419 filter: this.getTextFilter()
3420 },
3421 success: function success(data) {
3422 if (_this.isDestroyed) {
3423 return;
3424 }
3425 _this.collection.set(data);
3426 _this.toggleElement();
3427 _this.ui.loadingIcon.hide();
3428 }
3429 });
3430 }
3431 }, {
3432 key: "filter",
3433 value: function filter() {
3434 return true;
3435 }
3436 }, {
3437 key: "onFilterChange",
3438 value: function onFilterChange() {
3439 this.fetchData();
3440 }
3441 }, {
3442 key: "onRender",
3443 value: function onRender() {
3444 _superPropGet(_default, "onRender", this, 3)([]);
3445 this.ui.loadingIcon = jQuery('<i>', {
3446 class: 'eicon-loading eicon-animation-spin'
3447 });
3448 this.ui.title.after(this.ui.loadingIcon);
3449 this.fetchData();
3450 }
3451 }]);
3452 }(_category.default);
3453
3454 /***/ }),
3455
3456 /***/ "../core/common/modules/finder/assets/js/modal/views/item.js":
3457 /*!*******************************************************************!*\
3458 !*** ../core/common/modules/finder/assets/js/modal/views/item.js ***!
3459 \*******************************************************************/
3460 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3461
3462 "use strict";
3463 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
3464
3465
3466 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3467 Object.defineProperty(exports, "__esModule", ({
3468 value: true
3469 }));
3470 exports["default"] = void 0;
3471 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3472 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3473 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3474 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3475 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3476 var _editorOneEvents = __webpack_require__(/*! elementor-editor-utils/editor-one-events */ "../assets/dev/js/editor/utils/editor-one-events.js");
3477 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)); }
3478 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3479 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$ItemView) {
3480 function _default() {
3481 (0, _classCallCheck2.default)(this, _default);
3482 return _callSuper(this, _default, arguments);
3483 }
3484 (0, _inherits2.default)(_default, _Marionette$ItemView);
3485 return (0, _createClass2.default)(_default, [{
3486 key: "className",
3487 value: function className() {
3488 return 'elementor-finder__results__item';
3489 }
3490 }, {
3491 key: "getTemplate",
3492 value: function getTemplate() {
3493 return '#tmpl-elementor-finder__results__item';
3494 }
3495 }, {
3496 key: "events",
3497 value: function events() {
3498 this.$el[0].addEventListener('click', this.onClick.bind(this), true);
3499 }
3500 }, {
3501 key: "trackResultSelect",
3502 value: function trackResultSelect() {
3503 var title = this.model.get('title');
3504 _editorOneEvents.EditorOneEventManager.sendFinderResultSelect(title);
3505 }
3506 }, {
3507 key: "onClick",
3508 value: function onClick(e) {
3509 var _this = this;
3510 var lockOptions = this.model.get('lock');
3511 if (!(lockOptions !== null && lockOptions !== void 0 && lockOptions.is_locked)) {
3512 this.trackResultSelect();
3513 return;
3514 }
3515 e.preventDefault();
3516 e.stopImmediatePropagation();
3517 elementorCommon.dialogsManager.createWidget('confirm', {
3518 id: 'elementor-finder__lock-dialog',
3519 headerMessage: lockOptions.content.heading,
3520 message: lockOptions.content.description,
3521 position: {
3522 my: 'center center',
3523 at: 'center center'
3524 },
3525 strings: {
3526 confirm: lockOptions.button.text,
3527 cancel: __('Cancel', 'elementor')
3528 },
3529 onConfirm: function onConfirm() {
3530 _this.trackResultSelect();
3531 var link = _this.replaceLockLinkPlaceholders(lockOptions.button.url);
3532 window.open(link, '_blank');
3533 }
3534 }).show();
3535 }
3536 }, {
3537 key: "replaceLockLinkPlaceholders",
3538 value: function replaceLockLinkPlaceholders(link) {
3539 return link.replace(/%%utm_source%%/g, 'finder').replace(/%%utm_medium%%/g, 'wp-dash');
3540 }
3541 }]);
3542 }(Marionette.ItemView);
3543
3544 /***/ }),
3545
3546 /***/ "../core/common/modules/finder/assets/js/modal/views/layout.js":
3547 /*!*********************************************************************!*\
3548 !*** ../core/common/modules/finder/assets/js/modal/views/layout.js ***!
3549 \*********************************************************************/
3550 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3551
3552 "use strict";
3553 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
3554
3555
3556 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3557 Object.defineProperty(exports, "__esModule", ({
3558 value: true
3559 }));
3560 exports["default"] = void 0;
3561 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3562 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3563 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3564 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3565 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
3566 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3567 var _content = _interopRequireDefault(__webpack_require__(/*! ./content */ "../core/common/modules/finder/assets/js/modal/views/content.js"));
3568 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)); }
3569 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3570 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; }
3571 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$com) {
3572 function _default() {
3573 (0, _classCallCheck2.default)(this, _default);
3574 return _callSuper(this, _default, arguments);
3575 }
3576 (0, _inherits2.default)(_default, _elementorModules$com);
3577 return (0, _createClass2.default)(_default, [{
3578 key: "getModalOptions",
3579 value: function getModalOptions() {
3580 return {
3581 id: 'elementor-finder__modal',
3582 draggable: true,
3583 effects: {
3584 show: 'show',
3585 hide: 'hide'
3586 },
3587 position: {
3588 enable: false
3589 }
3590 };
3591 }
3592 }, {
3593 key: "getLogoOptions",
3594 value: function getLogoOptions() {
3595 return {
3596 title: __('Finder', 'elementor')
3597 };
3598 }
3599 }, {
3600 key: "initialize",
3601 value: function initialize() {
3602 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3603 args[_key] = arguments[_key];
3604 }
3605 _superPropGet(_default, "initialize", this, 3)(args);
3606 this.showLogo();
3607 this.showContentView();
3608 }
3609 }, {
3610 key: "showContentView",
3611 value: function showContentView() {
3612 this.modalContent.show(new _content.default());
3613 }
3614 }, {
3615 key: "showModal",
3616 value: function showModal() {
3617 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
3618 args[_key2] = arguments[_key2];
3619 }
3620 _superPropGet(_default, "showModal", this, 3)(args);
3621 this.modalContent.currentView.ui.searchInput.focus();
3622 }
3623 }]);
3624 }(elementorModules.common.views.modal.Layout);
3625
3626 /***/ }),
3627
3628 /***/ "../modules/web-cli/assets/js/core/data/errors/base-error.js":
3629 /*!*******************************************************************!*\
3630 !*** ../modules/web-cli/assets/js/core/data/errors/base-error.js ***!
3631 \*******************************************************************/
3632 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3633
3634 "use strict";
3635
3636
3637 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3638 Object.defineProperty(exports, "__esModule", ({
3639 value: true
3640 }));
3641 exports["default"] = void 0;
3642 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3643 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3644 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3645 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3646 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3647 var _wrapNativeSuper2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/wrapNativeSuper */ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js"));
3648 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
3649 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
3650 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../../../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
3651 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; }
3652 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; }
3653 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)); }
3654 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3655 var BaseError = exports["default"] = /*#__PURE__*/function (_Error) {
3656 /**
3657 * Error constructor.
3658 *
3659 * @param {string} message
3660 * @param {string} code
3661 * @param {*} data
3662 */
3663 function BaseError() {
3664 var _this;
3665 var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
3666 var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
3667 var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
3668 (0, _classCallCheck2.default)(this, BaseError);
3669 _this = _callSuper(this, BaseError, [message]);
3670 /**
3671 * The server error code.
3672 *
3673 * @type {string}
3674 */
3675 (0, _defineProperty2.default)(_this, "code", '');
3676 /**
3677 * Additional data about the current error.
3678 *
3679 * @type {*[]}
3680 */
3681 (0, _defineProperty2.default)(_this, "data", []);
3682 _this.code = code;
3683 _this.data = data;
3684 return _this;
3685 }
3686
3687 /**
3688 * Notify a message when the error occurs.
3689 */
3690 (0, _inherits2.default)(BaseError, _Error);
3691 return (0, _createClass2.default)(BaseError, [{
3692 key: "notify",
3693 value: function notify() {
3694 _console.default.error(_objectSpread({
3695 message: this.message
3696 }, this));
3697 }
3698 }], [{
3699 key: "create",
3700 value:
3701 /**
3702 * Static helper function to create the error.
3703 *
3704 * @param {string} message
3705 * @param {string} code
3706 * @param {*} data
3707 * @return {BaseError} error
3708 */
3709 function create(message) {
3710 var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
3711 var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
3712 return new this(message, code, data);
3713 }
3714
3715 /**
3716 * Returns the status code of the error.
3717 */
3718 }, {
3719 key: "getHTTPErrorCode",
3720 value: function getHTTPErrorCode() {
3721 (0, _forceMethodImplementation.default)();
3722 }
3723 }]);
3724 }(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
3725
3726 /***/ }),
3727
3728 /***/ "../modules/web-cli/assets/js/core/data/errors/default-error.js":
3729 /*!**********************************************************************!*\
3730 !*** ../modules/web-cli/assets/js/core/data/errors/default-error.js ***!
3731 \**********************************************************************/
3732 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3733
3734 "use strict";
3735
3736
3737 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3738 Object.defineProperty(exports, "__esModule", ({
3739 value: true
3740 }));
3741 exports["default"] = exports.DefaultError = void 0;
3742 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3743 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3744 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3745 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3746 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3747 var _baseError = _interopRequireDefault(__webpack_require__(/*! ./base-error */ "../modules/web-cli/assets/js/core/data/errors/base-error.js"));
3748 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)); }
3749 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3750 var DefaultError = exports.DefaultError = /*#__PURE__*/function (_BaseError) {
3751 function DefaultError() {
3752 (0, _classCallCheck2.default)(this, DefaultError);
3753 return _callSuper(this, DefaultError, arguments);
3754 }
3755 (0, _inherits2.default)(DefaultError, _BaseError);
3756 return (0, _createClass2.default)(DefaultError, null, [{
3757 key: "getHTTPErrorCode",
3758 value: function getHTTPErrorCode() {
3759 return 501;
3760 }
3761 }]);
3762 }(_baseError.default);
3763 var _default = exports["default"] = DefaultError;
3764
3765 /***/ }),
3766
3767 /***/ "../modules/web-cli/assets/js/core/data/errors/error-404.js":
3768 /*!******************************************************************!*\
3769 !*** ../modules/web-cli/assets/js/core/data/errors/error-404.js ***!
3770 \******************************************************************/
3771 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3772
3773 "use strict";
3774
3775
3776 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3777 Object.defineProperty(exports, "__esModule", ({
3778 value: true
3779 }));
3780 exports["default"] = exports.Error404 = void 0;
3781 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3782 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3783 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3784 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3785 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3786 var _baseError = _interopRequireDefault(__webpack_require__(/*! ./base-error */ "../modules/web-cli/assets/js/core/data/errors/base-error.js"));
3787 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
3788 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)); }
3789 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3790 var Error404 = exports.Error404 = /*#__PURE__*/function (_BaseError) {
3791 function Error404() {
3792 (0, _classCallCheck2.default)(this, Error404);
3793 return _callSuper(this, Error404, arguments);
3794 }
3795 (0, _inherits2.default)(Error404, _BaseError);
3796 return (0, _createClass2.default)(Error404, [{
3797 key: "notify",
3798 value: function notify() {
3799 _console.default.warn(this.message);
3800 }
3801 }], [{
3802 key: "getHTTPErrorCode",
3803 value: function getHTTPErrorCode() {
3804 return 404;
3805 }
3806 }]);
3807 }(_baseError.default);
3808 var _default = exports["default"] = Error404;
3809
3810 /***/ }),
3811
3812 /***/ "../modules/web-cli/assets/js/core/data/errors/index.js":
3813 /*!**************************************************************!*\
3814 !*** ../modules/web-cli/assets/js/core/data/errors/index.js ***!
3815 \**************************************************************/
3816 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3817
3818 "use strict";
3819
3820
3821 Object.defineProperty(exports, "__esModule", ({
3822 value: true
3823 }));
3824 Object.defineProperty(exports, "DefaultError", ({
3825 enumerable: true,
3826 get: function get() {
3827 return _defaultError.DefaultError;
3828 }
3829 }));
3830 Object.defineProperty(exports, "Error404", ({
3831 enumerable: true,
3832 get: function get() {
3833 return _error.Error404;
3834 }
3835 }));
3836 var _defaultError = __webpack_require__(/*! ./default-error */ "../modules/web-cli/assets/js/core/data/errors/default-error.js");
3837 var _error = __webpack_require__(/*! ./error-404 */ "../modules/web-cli/assets/js/core/data/errors/error-404.js");
3838
3839 /***/ }),
3840
3841 /***/ "../modules/web-cli/assets/js/modules/command-base.js":
3842 /*!************************************************************!*\
3843 !*** ../modules/web-cli/assets/js/modules/command-base.js ***!
3844 \************************************************************/
3845 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3846
3847 "use strict";
3848
3849
3850 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3851 Object.defineProperty(exports, "__esModule", ({
3852 value: true
3853 }));
3854 exports["default"] = void 0;
3855 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3856 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3857 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3858 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3859 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3860 var _commandInfra = _interopRequireDefault(__webpack_require__(/*! ./command-infra */ "../modules/web-cli/assets/js/modules/command-infra.js"));
3861 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
3862 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)); }
3863 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3864 /**
3865 * @name $e.modules.CommandBase
3866 */
3867 var CommandBase = exports["default"] = /*#__PURE__*/function (_CommandInfra) {
3868 function CommandBase() {
3869 (0, _classCallCheck2.default)(this, CommandBase);
3870 return _callSuper(this, CommandBase, arguments);
3871 }
3872 (0, _inherits2.default)(CommandBase, _CommandInfra);
3873 return (0, _createClass2.default)(CommandBase, [{
3874 key: "onBeforeRun",
3875 value: function onBeforeRun() {
3876 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3877 $e.hooks.runUIBefore(this.command, args);
3878 }
3879 }, {
3880 key: "onAfterRun",
3881 value: function onAfterRun() {
3882 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3883 var result = arguments.length > 1 ? arguments[1] : undefined;
3884 $e.hooks.runUIAfter(this.command, args, result);
3885 }
3886 }, {
3887 key: "onBeforeApply",
3888 value: function onBeforeApply() {
3889 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3890 $e.hooks.runDataDependency(this.command, args);
3891 }
3892 }, {
3893 key: "onAfterApply",
3894 value: function onAfterApply() {
3895 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3896 var result = arguments.length > 1 ? arguments[1] : undefined;
3897 return $e.hooks.runDataAfter(this.command, args, result);
3898 }
3899 }, {
3900 key: "onCatchApply",
3901 value: function onCatchApply(e) {
3902 this.runCatchHooks(e);
3903 }
3904
3905 /**
3906 * Run all the catch hooks.
3907 *
3908 * @param {Error} e
3909 */
3910 }, {
3911 key: "runCatchHooks",
3912 value: function runCatchHooks(e) {
3913 $e.hooks.runDataCatch(this.command, this.args, e);
3914 $e.hooks.runUICatch(this.command, this.args, e);
3915 }
3916
3917 /**
3918 * TODO - Remove - Backwards compatibility.
3919 *
3920 * Function requireContainer().
3921 *
3922 * Validate `arg.container` & `arg.containers`.
3923 *
3924 * @param {{}} args
3925 * @deprecated since 3.7.0, extend `$e.modules.editor.CommandContainerBase` or `$e.modules.editor.CommandContainerInternalBase` instead.
3926 *
3927 * @throws {Error}
3928 */
3929 }, {
3930 key: "requireContainer",
3931 value: function requireContainer() {
3932 var _this = this;
3933 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.args;
3934 _deprecation.default.deprecated('requireContainer()', '3.7.0', 'Extend `$e.modules.editor.CommandContainerBase` or `$e.modules.editor.CommandContainerInternalBase`');
3935 if (!args.container && !args.containers) {
3936 throw Error('container or containers are required.');
3937 }
3938 if (args.container && args.containers) {
3939 throw Error('container and containers cannot go together please select one of them.');
3940 }
3941 var containers = args.containers || [args.container];
3942 containers.forEach(function (container) {
3943 _this.requireArgumentInstance('container', elementorModules.editor.Container, {
3944 container: container
3945 });
3946 });
3947 }
3948 }], [{
3949 key: "getInstanceType",
3950 value: function getInstanceType() {
3951 return 'CommandBase';
3952 }
3953 }]);
3954 }(_commandInfra.default);
3955
3956 /***/ }),
3957
3958 /***/ "../modules/web-cli/assets/js/modules/command-callback-base.js":
3959 /*!*********************************************************************!*\
3960 !*** ../modules/web-cli/assets/js/modules/command-callback-base.js ***!
3961 \*********************************************************************/
3962 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3963
3964 "use strict";
3965
3966
3967 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3968 Object.defineProperty(exports, "__esModule", ({
3969 value: true
3970 }));
3971 exports["default"] = void 0;
3972 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3973 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3974 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3975 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3976 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3977 var _commandBase = _interopRequireDefault(__webpack_require__(/*! ./command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
3978 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)); }
3979 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3980 /**
3981 * To support pure callbacks in the API(commands.js), to ensure they have registered with the proper context.
3982 */
3983 var CommandCallbackBase = exports["default"] = /*#__PURE__*/function (_CommandBase) {
3984 function CommandCallbackBase() {
3985 (0, _classCallCheck2.default)(this, CommandCallbackBase);
3986 return _callSuper(this, CommandCallbackBase, arguments);
3987 }
3988 (0, _inherits2.default)(CommandCallbackBase, _CommandBase);
3989 return (0, _createClass2.default)(CommandCallbackBase, [{
3990 key: "apply",
3991 value: function apply() {
3992 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3993 return this.constructor.getCallback()(args);
3994 }
3995 }], [{
3996 key: "getInstanceType",
3997 value: function getInstanceType() {
3998 return 'CommandCallbackBase';
3999 }
4000
4001 /**
4002 * Get original callback of the command.
4003 *
4004 * Support pure callbacks ( Non command-base ).
4005 *
4006 * @return {()=>{}} Command Results.
4007 */
4008 }, {
4009 key: "getCallback",
4010 value: function getCallback() {
4011 return this.registerConfig.callback;
4012 }
4013 }]);
4014 }(_commandBase.default);
4015
4016 /***/ }),
4017
4018 /***/ "../modules/web-cli/assets/js/modules/command-data.js":
4019 /*!************************************************************!*\
4020 !*** ../modules/web-cli/assets/js/modules/command-data.js ***!
4021 \************************************************************/
4022 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4023
4024 "use strict";
4025
4026
4027 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4028 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
4029 Object.defineProperty(exports, "__esModule", ({
4030 value: true
4031 }));
4032 exports["default"] = void 0;
4033 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4034 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4035 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4036 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4037 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4038 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
4039 var _commandBase = _interopRequireDefault(__webpack_require__(/*! ./command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4040 var errors = _interopRequireWildcard(__webpack_require__(/*! ../core/data/errors/ */ "../modules/web-cli/assets/js/core/data/errors/index.js"));
4041 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); }
4042 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)); }
4043 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4044 /**
4045 * @name $e.modules.CommandData
4046 */
4047 /**
4048 * @typedef {('create'|'delete'|'get'|'update'|'options')} DataTypes
4049 */
4050 /**
4051 * @typedef {{}} RequestData
4052 */
4053 /**
4054 * @typedef {import('../core/data/errors/base-error')} BaseError
4055 */
4056 var CommandData = exports["default"] = /*#__PURE__*/function (_CommandBase) {
4057 function CommandData(args) {
4058 var _this$args$options;
4059 var _this;
4060 var commandsAPI = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : $e.data;
4061 (0, _classCallCheck2.default)(this, CommandData);
4062 _this = _callSuper(this, CommandData, [args, commandsAPI]);
4063 /**
4064 * Data returned from remote.
4065 *
4066 * @type {*}
4067 */
4068 (0, _defineProperty2.default)(_this, "data", void 0);
4069 /**
4070 * Fetch type.
4071 *
4072 * @type {DataTypes}
4073 */
4074 (0, _defineProperty2.default)(_this, "type", void 0);
4075 if ((_this$args$options = _this.args.options) !== null && _this$args$options !== void 0 && _this$args$options.type) {
4076 _this.type = _this.args.options.type;
4077 }
4078 return _this;
4079 }
4080
4081 /**
4082 * Function getEndpointFormat().
4083 *
4084 * @return {null|string} endpoint format
4085 */
4086 (0, _inherits2.default)(CommandData, _CommandBase);
4087 return (0, _createClass2.default)(CommandData, [{
4088 key: "getApplyMethods",
4089 value:
4090 /**
4091 * @param {DataTypes} type
4092 *
4093 * @return {boolean|{before: (function(*=): {}), after: (function({}, *=): {})}} apply methods
4094 */
4095 function getApplyMethods() {
4096 var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.type;
4097 var before, after;
4098 switch (type) {
4099 case 'create':
4100 before = this.applyBeforeCreate;
4101 after = this.applyAfterCreate;
4102 break;
4103 case 'delete':
4104 before = this.applyBeforeDelete;
4105 after = this.applyAfterDelete;
4106 break;
4107 case 'get':
4108 before = this.applyBeforeGet;
4109 after = this.applyAfterGet;
4110 break;
4111 case 'update':
4112 before = this.applyBeforeUpdate;
4113 after = this.applyAfterUpdate;
4114 break;
4115 case 'options':
4116 before = this.applyBeforeOptions;
4117 after = this.applyAfterOptions;
4118 break;
4119 default:
4120 return false;
4121 }
4122 return {
4123 before: before.bind(this),
4124 after: after.bind(this)
4125 };
4126 }
4127
4128 /**
4129 * Function getRequestData().
4130 *
4131 * @return {RequestData} request data
4132 */
4133 }, {
4134 key: "getRequestData",
4135 value: function getRequestData() {
4136 return {
4137 type: this.type,
4138 args: this.args,
4139 timestamp: new Date().getTime(),
4140 component: this.component,
4141 command: this.command,
4142 endpoint: $e.data.commandToEndpoint(this.command, JSON.parse(JSON.stringify(this.args)), this.constructor.getEndpointFormat())
4143 };
4144 }
4145 }, {
4146 key: "apply",
4147 value: function apply() {
4148 var _this2 = this;
4149 var applyMethods = this.getApplyMethods();
4150
4151 // Run 'before' method.
4152 this.args = applyMethods.before(this.args);
4153 var requestData = this.getRequestData();
4154 return $e.data.fetch(requestData).then(function (data) {
4155 _this2.data = data;
4156
4157 // Run 'after' method.
4158 _this2.data = applyMethods.after(data, _this2.args);
4159 _this2.data = {
4160 data: _this2.data
4161 };
4162
4163 // Append requestData.
4164 _this2.data = Object.assign({
4165 __requestData__: requestData
4166 }, _this2.data);
4167 return _this2.data;
4168 });
4169 }
4170
4171 /**
4172 * @param {*} [args={}]
4173 * @return {{}} filtered args
4174 */
4175 }, {
4176 key: "applyBeforeCreate",
4177 value: function applyBeforeCreate() {
4178 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4179 return args;
4180 }
4181
4182 /**
4183 * @param {{}} data
4184 * @param {*} [args={}]
4185 * @return {{}} filtered result
4186 */
4187 }, {
4188 key: "applyAfterCreate",
4189 value: function applyAfterCreate(data) {
4190 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4191 // eslint-disable-line no-unused-vars
4192 return data;
4193 }
4194
4195 /**
4196 * @param {*} [args={}]
4197 * @return {{}} filtered args
4198 */
4199 }, {
4200 key: "applyBeforeDelete",
4201 value: function applyBeforeDelete() {
4202 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4203 return args;
4204 }
4205
4206 /**
4207 * @param {{}} data
4208 * @param {*} [args={}]
4209 * @return {{}} filtered result
4210 */
4211 }, {
4212 key: "applyAfterDelete",
4213 value: function applyAfterDelete(data) {
4214 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4215 // eslint-disable-line no-unused-vars
4216 return data;
4217 }
4218
4219 /**
4220 * @param {*} [args={}]
4221 * @return {{}} filtered args
4222 */
4223 }, {
4224 key: "applyBeforeGet",
4225 value: function applyBeforeGet() {
4226 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4227 return args;
4228 }
4229
4230 /**
4231 * @param {{}} data
4232 * @param {*} [args={}]
4233 * @return {{}} filtered result
4234 */
4235 }, {
4236 key: "applyAfterGet",
4237 value: function applyAfterGet(data) {
4238 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4239 // eslint-disable-line no-unused-vars
4240 return data;
4241 }
4242
4243 /**
4244 * @param {*} [args={}]
4245 * @return {{}} filtered args
4246 */
4247 }, {
4248 key: "applyBeforeUpdate",
4249 value: function applyBeforeUpdate() {
4250 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4251 return args;
4252 }
4253
4254 /**
4255 * @param {{}} data
4256 * @param {*} [args={}]
4257 * @return {{}} filtered result
4258 */
4259 }, {
4260 key: "applyAfterUpdate",
4261 value: function applyAfterUpdate(data) {
4262 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4263 // eslint-disable-line no-unused-vars
4264 return data;
4265 }
4266
4267 /**
4268 * @param {*} [args={}]
4269 * @return {{}} filtered args
4270 */
4271 }, {
4272 key: "applyBeforeOptions",
4273 value: function applyBeforeOptions() {
4274 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4275 return args;
4276 }
4277
4278 /**
4279 * @param {{}} data
4280 * @param {*} [args={}]
4281 * @return {{}} filtered result
4282 */
4283 }, {
4284 key: "applyAfterOptions",
4285 value: function applyAfterOptions(data) {
4286 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4287 // eslint-disable-line no-unused-vars
4288 return data;
4289 }
4290
4291 /**
4292 * @param {BaseError} e
4293 */
4294 }, {
4295 key: "applyAfterCatch",
4296 value: function applyAfterCatch(e) {
4297 e.notify();
4298 }
4299 }, {
4300 key: "onCatchApply",
4301 value: function onCatchApply(e) {
4302 var _e;
4303 // TODO: If the errors that returns from the server is consistent remove the '?' from 'e'
4304 var httpErrorCode = ((_e = e) === null || _e === void 0 || (_e = _e.data) === null || _e === void 0 ? void 0 : _e.status) || 501;
4305 var dataError = Object.values(errors).find(function (error) {
4306 return error.getHTTPErrorCode() === httpErrorCode;
4307 });
4308 if (!dataError) {
4309 dataError = errors.DefaultError;
4310 }
4311 e = dataError.create(e.message, e.code, e.data || []);
4312 this.runCatchHooks(e);
4313 this.applyAfterCatch(e);
4314 }
4315 }], [{
4316 key: "getInstanceType",
4317 value: function getInstanceType() {
4318 return 'CommandData';
4319 }
4320 }, {
4321 key: "getEndpointFormat",
4322 value: function getEndpointFormat() {
4323 return null;
4324 }
4325 }]);
4326 }(_commandBase.default);
4327
4328 /***/ }),
4329
4330 /***/ "../modules/web-cli/assets/js/modules/command-infra.js":
4331 /*!*************************************************************!*\
4332 !*** ../modules/web-cli/assets/js/modules/command-infra.js ***!
4333 \*************************************************************/
4334 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4335
4336 "use strict";
4337
4338
4339 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4340 Object.defineProperty(exports, "__esModule", ({
4341 value: true
4342 }));
4343 exports["default"] = void 0;
4344 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4345 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4346 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4347 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4348 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4349 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
4350 var _argsObject = _interopRequireDefault(__webpack_require__(/*! elementor-assets-js/modules/imports/args-object */ "../assets/dev/js/modules/imports/args-object.js"));
4351 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
4352 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)); }
4353 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4354 /**
4355 * @typedef {import('../modules/component-base')} ComponentBase
4356 */
4357 var CommandInfra = exports["default"] = /*#__PURE__*/function (_ArgsObject) {
4358 /**
4359 * Function constructor().
4360 *
4361 * Create Commands Base.
4362 *
4363 * @param {{}} args
4364 */
4365 function CommandInfra() {
4366 var _this;
4367 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4368 (0, _classCallCheck2.default)(this, CommandInfra);
4369 _this = _callSuper(this, CommandInfra, [args]);
4370 if (!_this.constructor.registerConfig) {
4371 throw RangeError('Doing it wrong: Each command type should have `registerConfig`.');
4372 }
4373
4374 // Acknowledge self about which command it run.
4375 _this.command = _this.constructor.getCommand();
4376
4377 // Assign instance of current component.
4378 _this.component = _this.constructor.getComponent();
4379
4380 // Who ever need do something before without `super` the constructor can use `initialize` method.
4381 _this.initialize(args);
4382
4383 // Refresh args, maybe the changed via `initialize`.
4384 args = _this.args;
4385
4386 // Validate args before run.
4387 _this.validateArgs(args);
4388 return _this;
4389 }
4390
4391 /**
4392 * Function initialize().
4393 *
4394 * Initialize command, called after construction.
4395 *
4396 * @param {{}} args
4397 */
4398 (0, _inherits2.default)(CommandInfra, _ArgsObject);
4399 return (0, _createClass2.default)(CommandInfra, [{
4400 key: "currentCommand",
4401 get:
4402 /**
4403 * @deprecated since 3.7.0, use `this.command` instead.
4404 */
4405 function get() {
4406 _deprecation.default.deprecated('this.currentCommand', '3.7.0', 'this.command');
4407 return this.command;
4408 }
4409 }, {
4410 key: "initialize",
4411 value: function initialize() {
4412 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4413 } // eslint-disable-line no-unused-vars
4414
4415 /**
4416 * Function validateArgs().
4417 *
4418 * Validate command arguments.
4419 *
4420 * @param {{}} args
4421 */
4422 }, {
4423 key: "validateArgs",
4424 value: function validateArgs() {
4425 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4426 } // eslint-disable-line no-unused-vars
4427
4428 // eslint-disable-next-line jsdoc/require-returns-check
4429 /**
4430 * Function apply().
4431 *
4432 * Do the actual command.
4433 *
4434 * @param {{}} args
4435 *
4436 * @return {*} Command results.
4437 */
4438 }, {
4439 key: "apply",
4440 value: function apply() {
4441 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4442 // eslint-disable-line no-unused-vars
4443 elementorModules.ForceMethodImplementation();
4444 }
4445
4446 /**
4447 * Function run().
4448 *
4449 * Run command with history & hooks.
4450 *
4451 * @return {*} Command results.
4452 */
4453 }, {
4454 key: "run",
4455 value: function run() {
4456 return this.apply(this.args);
4457 }
4458
4459 /**
4460 * Function onBeforeRun.
4461 *
4462 * Called before run().
4463 *
4464 * @param {{}} args
4465 */
4466 }, {
4467 key: "onBeforeRun",
4468 value: function onBeforeRun() {
4469 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4470 } // eslint-disable-line no-unused-vars
4471
4472 /**
4473 * Function onAfterRun.
4474 *
4475 * Called after run().
4476 *
4477 * @param {{}} args
4478 * @param {*} result
4479 */
4480 }, {
4481 key: "onAfterRun",
4482 value: function onAfterRun() {
4483 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4484 var result = arguments.length > 1 ? arguments[1] : undefined;
4485 } // eslint-disable-line no-unused-vars
4486
4487 /**
4488 * Function onBeforeApply.
4489 *
4490 * Called before apply().
4491 *
4492 * @param {{}} args
4493 */
4494 }, {
4495 key: "onBeforeApply",
4496 value: function onBeforeApply() {
4497 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4498 } // eslint-disable-line no-unused-vars
4499
4500 /**
4501 * Function onAfterApply.
4502 *
4503 * Called after apply().
4504 *
4505 * @param {{}} args
4506 * @param {*} result
4507 */
4508 }, {
4509 key: "onAfterApply",
4510 value: function onAfterApply() {
4511 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4512 var result = arguments.length > 1 ? arguments[1] : undefined;
4513 } // eslint-disable-line no-unused-vars
4514
4515 /**
4516 * Function onCatchApply.
4517 *
4518 * Called after apply() failed.
4519 *
4520 * @param {Error} e
4521 */
4522 }, {
4523 key: "onCatchApply",
4524 value: function onCatchApply(e) {} // eslint-disable-line no-unused-vars
4525 }], [{
4526 key: "getInstanceType",
4527 value: function getInstanceType() {
4528 return 'CommandInfra';
4529 }
4530
4531 /**
4532 * Get info of command.
4533 *
4534 * @return {Object} Extra information about the command.
4535 */
4536 }, {
4537 key: "getInfo",
4538 value: function getInfo() {
4539 return {};
4540 }
4541
4542 /**
4543 * @return {string} Self command name.
4544 */
4545 }, {
4546 key: "getCommand",
4547 value: function getCommand() {
4548 return this.registerConfig.command;
4549 }
4550
4551 /**
4552 * @return {ComponentBase} Self component
4553 */
4554 }, {
4555 key: "getComponent",
4556 value: function getComponent() {
4557 return this.registerConfig.component;
4558 }
4559 }, {
4560 key: "setRegisterConfig",
4561 value: function setRegisterConfig(config) {
4562 this.registerConfig = Object.freeze(config);
4563 }
4564 }]);
4565 }(_argsObject.default);
4566 /**
4567 * @type {Object}
4568 */
4569 (0, _defineProperty2.default)(CommandInfra, "registerConfig", null);
4570
4571 /***/ }),
4572
4573 /***/ "../modules/web-cli/assets/js/modules/commands/close.js":
4574 /*!**************************************************************!*\
4575 !*** ../modules/web-cli/assets/js/modules/commands/close.js ***!
4576 \**************************************************************/
4577 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4578
4579 "use strict";
4580
4581
4582 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4583 Object.defineProperty(exports, "__esModule", ({
4584 value: true
4585 }));
4586 exports["default"] = exports.Close = void 0;
4587 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4588 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4589 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4590 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4591 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4592 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4593 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)); }
4594 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4595 var Close = exports.Close = /*#__PURE__*/function (_CommandBase) {
4596 function Close() {
4597 (0, _classCallCheck2.default)(this, Close);
4598 return _callSuper(this, Close, arguments);
4599 }
4600 (0, _inherits2.default)(Close, _CommandBase);
4601 return (0, _createClass2.default)(Close, [{
4602 key: "apply",
4603 value: function apply() {
4604 this.component.close();
4605 }
4606 }]);
4607 }(_commandBase.default);
4608 var _default = exports["default"] = Close;
4609
4610 /***/ }),
4611
4612 /***/ "../modules/web-cli/assets/js/modules/commands/index.js":
4613 /*!**************************************************************!*\
4614 !*** ../modules/web-cli/assets/js/modules/commands/index.js ***!
4615 \**************************************************************/
4616 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4617
4618 "use strict";
4619
4620
4621 Object.defineProperty(exports, "__esModule", ({
4622 value: true
4623 }));
4624 Object.defineProperty(exports, "Close", ({
4625 enumerable: true,
4626 get: function get() {
4627 return _close.Close;
4628 }
4629 }));
4630 Object.defineProperty(exports, "Open", ({
4631 enumerable: true,
4632 get: function get() {
4633 return _open.Open;
4634 }
4635 }));
4636 Object.defineProperty(exports, "Toggle", ({
4637 enumerable: true,
4638 get: function get() {
4639 return _toggle.Toggle;
4640 }
4641 }));
4642 var _close = __webpack_require__(/*! ./close */ "../modules/web-cli/assets/js/modules/commands/close.js");
4643 var _open = __webpack_require__(/*! ./open */ "../modules/web-cli/assets/js/modules/commands/open.js");
4644 var _toggle = __webpack_require__(/*! ./toggle */ "../modules/web-cli/assets/js/modules/commands/toggle.js");
4645
4646 /***/ }),
4647
4648 /***/ "../modules/web-cli/assets/js/modules/commands/open.js":
4649 /*!*************************************************************!*\
4650 !*** ../modules/web-cli/assets/js/modules/commands/open.js ***!
4651 \*************************************************************/
4652 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4653
4654 "use strict";
4655
4656
4657 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4658 Object.defineProperty(exports, "__esModule", ({
4659 value: true
4660 }));
4661 exports["default"] = exports.Open = void 0;
4662 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4663 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4664 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4665 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4666 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4667 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4668 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)); }
4669 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4670 var Open = exports.Open = /*#__PURE__*/function (_CommandBase) {
4671 function Open() {
4672 (0, _classCallCheck2.default)(this, Open);
4673 return _callSuper(this, Open, arguments);
4674 }
4675 (0, _inherits2.default)(Open, _CommandBase);
4676 return (0, _createClass2.default)(Open, [{
4677 key: "apply",
4678 value: function apply() {
4679 $e.route(this.component.getNamespace());
4680 }
4681 }]);
4682 }(_commandBase.default);
4683 var _default = exports["default"] = Open;
4684
4685 /***/ }),
4686
4687 /***/ "../modules/web-cli/assets/js/modules/commands/toggle.js":
4688 /*!***************************************************************!*\
4689 !*** ../modules/web-cli/assets/js/modules/commands/toggle.js ***!
4690 \***************************************************************/
4691 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4692
4693 "use strict";
4694
4695
4696 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4697 Object.defineProperty(exports, "__esModule", ({
4698 value: true
4699 }));
4700 exports["default"] = exports.Toggle = void 0;
4701 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4702 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4703 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4704 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4705 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4706 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4707 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)); }
4708 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4709 var Toggle = exports.Toggle = /*#__PURE__*/function (_CommandBase) {
4710 function Toggle() {
4711 (0, _classCallCheck2.default)(this, Toggle);
4712 return _callSuper(this, Toggle, arguments);
4713 }
4714 (0, _inherits2.default)(Toggle, _CommandBase);
4715 return (0, _createClass2.default)(Toggle, [{
4716 key: "apply",
4717 value: function apply() {
4718 if (this.component.isOpen) {
4719 this.component.close();
4720 } else {
4721 $e.route(this.component.getNamespace());
4722 }
4723 }
4724 }]);
4725 }(_commandBase.default);
4726 var _default = exports["default"] = Toggle;
4727
4728 /***/ }),
4729
4730 /***/ "../modules/web-cli/assets/js/modules/component-base.js":
4731 /*!**************************************************************!*\
4732 !*** ../modules/web-cli/assets/js/modules/component-base.js ***!
4733 \**************************************************************/
4734 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4735
4736 "use strict";
4737
4738
4739 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4740 Object.defineProperty(exports, "__esModule", ({
4741 value: true
4742 }));
4743 exports["default"] = void 0;
4744 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
4745 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
4746 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4747 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4748 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4749 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4750 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4751 var _commandCallbackBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-callback-base */ "../modules/web-cli/assets/js/modules/command-callback-base.js"));
4752 var _toolkit = __webpack_require__(/*! @reduxjs/toolkit */ "../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js");
4753 var _module = _interopRequireDefault(__webpack_require__(/*! elementor/assets/dev/js/modules/imports/module.js */ "../assets/dev/js/modules/imports/module.js"));
4754 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
4755 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
4756 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; }
4757 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; }
4758 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)); }
4759 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4760 /**
4761 * @typedef {import('./command-infra')} CommandInfra
4762 * @typedef {import('./hook-base')} HookBase
4763 * @typedef {import('../core/states/ui-state-base')} UiStateBase
4764 */
4765 var ComponentBase = exports["default"] = /*#__PURE__*/function (_Module) {
4766 function ComponentBase() {
4767 (0, _classCallCheck2.default)(this, ComponentBase);
4768 return _callSuper(this, ComponentBase, arguments);
4769 }
4770 (0, _inherits2.default)(ComponentBase, _Module);
4771 return (0, _createClass2.default)(ComponentBase, [{
4772 key: "__construct",
4773 value: function __construct() {
4774 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4775 if (args.manager) {
4776 this.manager = args.manager;
4777 }
4778 this.commands = this.defaultCommands();
4779 this.commandsInternal = this.defaultCommandsInternal();
4780 this.hooks = this.defaultHooks();
4781 this.routes = this.defaultRoutes();
4782 this.tabs = this.defaultTabs();
4783 this.shortcuts = this.defaultShortcuts();
4784 this.utils = this.defaultUtils();
4785 this.data = this.defaultData();
4786 this.uiStates = this.defaultUiStates();
4787 this.states = this.defaultStates();
4788 this.defaultRoute = '';
4789 this.currentTab = '';
4790 }
4791 }, {
4792 key: "registerAPI",
4793 value: function registerAPI() {
4794 var _this = this;
4795 Object.entries(this.getTabs()).forEach(function (tab) {
4796 return _this.registerTabRoute(tab[0]);
4797 });
4798 Object.entries(this.getRoutes()).forEach(function (_ref) {
4799 var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
4800 route = _ref2[0],
4801 callback = _ref2[1];
4802 return _this.registerRoute(route, callback);
4803 });
4804 Object.entries(this.getCommands()).forEach(function (_ref3) {
4805 var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
4806 command = _ref4[0],
4807 callback = _ref4[1];
4808 return _this.registerCommand(command, callback);
4809 });
4810 Object.entries(this.getCommandsInternal()).forEach(function (_ref5) {
4811 var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
4812 command = _ref6[0],
4813 callback = _ref6[1];
4814 return _this.registerCommandInternal(command, callback);
4815 });
4816 Object.values(this.getHooks()).forEach(function (instance) {
4817 return _this.registerHook(instance);
4818 });
4819 Object.entries(this.getData()).forEach(function (_ref7) {
4820 var _ref8 = (0, _slicedToArray2.default)(_ref7, 2),
4821 command = _ref8[0],
4822 callback = _ref8[1];
4823 return _this.registerData(command, callback);
4824 });
4825 Object.values(this.getUiStates()).forEach(function (instance) {
4826 return _this.registerUiState(instance);
4827 });
4828 Object.entries(this.getStates()).forEach(function (_ref9) {
4829 var _ref0 = (0, _slicedToArray2.default)(_ref9, 2),
4830 id = _ref0[0],
4831 state = _ref0[1];
4832 return _this.registerState(id, state);
4833 });
4834 }
4835
4836 // eslint-disable-next-line jsdoc/require-returns-check
4837 /**
4838 * @return {string} namespace
4839 */
4840 }, {
4841 key: "getNamespace",
4842 value: function getNamespace() {
4843 (0, _forceMethodImplementation.default)();
4844 }
4845
4846 /**
4847 * @deprecated since 3.7.0, use `getServiceName()` instead.
4848 */
4849 }, {
4850 key: "getRootContainer",
4851 value: function getRootContainer() {
4852 _deprecation.default.deprecated('getRootContainer()', '3.7.0', 'getServiceName()');
4853 return this.getServiceName();
4854 }
4855 }, {
4856 key: "getServiceName",
4857 value: function getServiceName() {
4858 return this.getNamespace().split('/')[0];
4859 }
4860 }, {
4861 key: "store",
4862 get: function get() {
4863 return $e.store.get(this.getNamespace());
4864 }
4865 }, {
4866 key: "defaultTabs",
4867 value: function defaultTabs() {
4868 return {};
4869 }
4870 }, {
4871 key: "defaultRoutes",
4872 value: function defaultRoutes() {
4873 return {};
4874 }
4875 }, {
4876 key: "defaultCommands",
4877 value: function defaultCommands() {
4878 return {};
4879 }
4880 }, {
4881 key: "defaultCommandsInternal",
4882 value: function defaultCommandsInternal() {
4883 return {};
4884 }
4885 }, {
4886 key: "defaultHooks",
4887 value: function defaultHooks() {
4888 return {};
4889 }
4890
4891 /**
4892 * Get the component's default UI states.
4893 *
4894 * @return {Object} default UI states
4895 */
4896 }, {
4897 key: "defaultUiStates",
4898 value: function defaultUiStates() {
4899 return {};
4900 }
4901
4902 /**
4903 * Get the component's Redux slice settings.
4904 *
4905 * @return {Object} Redux slice settings
4906 */
4907 }, {
4908 key: "defaultStates",
4909 value: function defaultStates() {
4910 return {};
4911 }
4912 }, {
4913 key: "defaultShortcuts",
4914 value: function defaultShortcuts() {
4915 return {};
4916 }
4917 }, {
4918 key: "defaultUtils",
4919 value: function defaultUtils() {
4920 return {};
4921 }
4922 }, {
4923 key: "defaultData",
4924 value: function defaultData() {
4925 return {};
4926 }
4927 }, {
4928 key: "getCommands",
4929 value: function getCommands() {
4930 return this.commands;
4931 }
4932 }, {
4933 key: "getCommandsInternal",
4934 value: function getCommandsInternal() {
4935 return this.commandsInternal;
4936 }
4937 }, {
4938 key: "getHooks",
4939 value: function getHooks() {
4940 return this.hooks;
4941 }
4942
4943 /**
4944 * Retrieve the component's UI states.
4945 *
4946 * @return {Object} UI states
4947 */
4948 }, {
4949 key: "getUiStates",
4950 value: function getUiStates() {
4951 return this.uiStates;
4952 }
4953
4954 /**
4955 * Retrieve the component's Redux Slice.
4956 *
4957 * @return {Object} Redux Slice
4958 */
4959 }, {
4960 key: "getStates",
4961 value: function getStates() {
4962 return this.states;
4963 }
4964 }, {
4965 key: "getRoutes",
4966 value: function getRoutes() {
4967 return this.routes;
4968 }
4969 }, {
4970 key: "getTabs",
4971 value: function getTabs() {
4972 return this.tabs;
4973 }
4974 }, {
4975 key: "getShortcuts",
4976 value: function getShortcuts() {
4977 return this.shortcuts;
4978 }
4979 }, {
4980 key: "getData",
4981 value: function getData() {
4982 return this.data;
4983 }
4984
4985 /**
4986 * @param {string} command
4987 * @param {(()=>{}|CommandInfra)} context
4988 * @param {'default'|'internal'|'data'} commandsType
4989 */
4990 }, {
4991 key: "registerCommand",
4992 value: function registerCommand(command, context) {
4993 var commandsType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'default';
4994 var commandsManager;
4995 switch (commandsType) {
4996 case 'default':
4997 commandsManager = $e.commands;
4998 break;
4999 case 'internal':
5000 commandsManager = $e.commandsInternal;
5001 break;
5002 case 'data':
5003 commandsManager = $e.data;
5004 break;
5005 default:
5006 throw new Error("Invalid commands type: '".concat(command, "'"));
5007 }
5008 var fullCommand = this.getNamespace() + '/' + command,
5009 instanceType = context.getInstanceType ? context.getInstanceType() : false,
5010 registerConfig = {
5011 command: fullCommand,
5012 component: this
5013 };
5014
5015 // Support pure callback.
5016 if (!instanceType) {
5017 if ($e.devTools) {
5018 $e.devTools.log.warn("Attach command-callback-base, on command: '".concat(fullCommand, "', context is unknown type."));
5019 }
5020 registerConfig.callback = context;
5021
5022 // Unique class.
5023 context = /*#__PURE__*/function (_CommandCallbackBase) {
5024 function context() {
5025 (0, _classCallCheck2.default)(this, context);
5026 return _callSuper(this, context, arguments);
5027 }
5028 (0, _inherits2.default)(context, _CommandCallbackBase);
5029 return (0, _createClass2.default)(context);
5030 }(_commandCallbackBase.default);
5031 }
5032 context.setRegisterConfig(registerConfig);
5033 commandsManager.register(this, command, context);
5034 }
5035
5036 /**
5037 * @param {HookBase} instance
5038 */
5039 }, {
5040 key: "registerHook",
5041 value: function registerHook(instance) {
5042 return instance.register();
5043 }
5044 }, {
5045 key: "registerCommandInternal",
5046 value: function registerCommandInternal(command, context) {
5047 this.registerCommand(command, context, 'internal');
5048 }
5049
5050 /**
5051 * Register a UI state.
5052 *
5053 * @param {UiStateBase} instance - UI state instance.
5054 *
5055 * @return {void}
5056 */
5057 }, {
5058 key: "registerUiState",
5059 value: function registerUiState(instance) {
5060 $e.uiStates.register(instance);
5061 }
5062
5063 /**
5064 * Register a Redux Slice.
5065 *
5066 * @param {string} id - State id.
5067 * @param {Object} stateConfig - The state config.
5068 *
5069 * @return {void}
5070 */
5071 }, {
5072 key: "registerState",
5073 value: function registerState(id, stateConfig) {
5074 id = this.getNamespace() + (id ? "/".concat(id) : '');
5075 var slice = (0, _toolkit.createSlice)(_objectSpread(_objectSpread({}, stateConfig), {}, {
5076 name: id
5077 }));
5078 $e.store.register(id, slice);
5079 }
5080 }, {
5081 key: "registerRoute",
5082 value: function registerRoute(route, callback) {
5083 $e.routes.register(this, route, callback);
5084 }
5085 }, {
5086 key: "registerData",
5087 value: function registerData(command, context) {
5088 this.registerCommand(command, context, 'data');
5089 }
5090 }, {
5091 key: "unregisterRoute",
5092 value: function unregisterRoute(route) {
5093 $e.routes.unregister(this, route);
5094 }
5095 }, {
5096 key: "registerTabRoute",
5097 value: function registerTabRoute(tab) {
5098 var _this2 = this;
5099 this.registerRoute(tab, function (args) {
5100 return _this2.activateTab(tab, args);
5101 });
5102 }
5103 }, {
5104 key: "dependency",
5105 value: function dependency() {
5106 return true;
5107 }
5108 }, {
5109 key: "open",
5110 value: function open() {
5111 return true;
5112 }
5113 }, {
5114 key: "close",
5115 value: function close() {
5116 if (!this.isOpen) {
5117 return false;
5118 }
5119 this.isOpen = false;
5120 this.inactivate();
5121 $e.routes.clearCurrent(this.getNamespace());
5122 $e.routes.clearHistory(this.getServiceName());
5123 return true;
5124 }
5125 }, {
5126 key: "activate",
5127 value: function activate() {
5128 $e.components.activate(this.getNamespace());
5129 }
5130 }, {
5131 key: "inactivate",
5132 value: function inactivate() {
5133 $e.components.inactivate(this.getNamespace());
5134 }
5135 }, {
5136 key: "isActive",
5137 value: function isActive() {
5138 return $e.components.isActive(this.getNamespace());
5139 }
5140 }, {
5141 key: "onRoute",
5142 value: function onRoute(route) {
5143 this.toggleRouteClass(route, true);
5144 this.toggleHistoryClass();
5145 this.activate();
5146 this.trigger('route/open', route);
5147 }
5148 }, {
5149 key: "onCloseRoute",
5150 value: function onCloseRoute(route) {
5151 this.toggleRouteClass(route, false);
5152 this.inactivate();
5153 this.trigger('route/close', route);
5154 }
5155 }, {
5156 key: "setDefaultRoute",
5157 value: function setDefaultRoute(route) {
5158 this.defaultRoute = this.getNamespace() + '/' + route;
5159 }
5160 }, {
5161 key: "getDefaultRoute",
5162 value: function getDefaultRoute() {
5163 return this.defaultRoute;
5164 }
5165 }, {
5166 key: "removeTab",
5167 value: function removeTab(tab) {
5168 delete this.tabs[tab];
5169 this.unregisterRoute(tab);
5170 }
5171 }, {
5172 key: "hasTab",
5173 value: function hasTab(tab) {
5174 return !!this.tabs[tab];
5175 }
5176 }, {
5177 key: "addTab",
5178 value: function addTab(tab, args, position) {
5179 var _this3 = this;
5180 this.tabs[tab] = args;
5181 // It can be 0.
5182 if ('undefined' !== typeof position) {
5183 var newTabs = {};
5184 var ids = Object.keys(this.tabs);
5185 // Remove new tab
5186 ids.pop();
5187
5188 // Add it to position.
5189 ids.splice(position, 0, tab);
5190 ids.forEach(function (id) {
5191 newTabs[id] = _this3.tabs[id];
5192 });
5193 this.tabs = newTabs;
5194 }
5195 this.registerTabRoute(tab);
5196 }
5197 }, {
5198 key: "getTabsWrapperSelector",
5199 value: function getTabsWrapperSelector() {
5200 return '';
5201 }
5202 }, {
5203 key: "getTabRoute",
5204 value: function getTabRoute(tab) {
5205 return this.getNamespace() + '/' + tab;
5206 }
5207 }, {
5208 key: "renderTab",
5209 value: function renderTab(tab) {} // eslint-disable-line
5210 }, {
5211 key: "activateTab",
5212 value: function activateTab(tab, args) {
5213 var _this4 = this;
5214 this.renderTab(tab, args);
5215 jQuery(this.getTabsWrapperSelector() + ' .elementor-component-tab').off('click').on('click', function (event) {
5216 $e.route(_this4.getTabRoute(event.currentTarget.dataset.tab), args);
5217 }).removeClass('elementor-active').filter('[data-tab="' + tab + '"]').addClass('elementor-active');
5218 }
5219 }, {
5220 key: "getActiveTabConfig",
5221 value: function getActiveTabConfig() {
5222 return this.tabs[this.currentTab] || {};
5223 }
5224 }, {
5225 key: "getBodyClass",
5226 value: function getBodyClass(route) {
5227 return 'e-route-' + route.replace(/\//g, '-');
5228 }
5229
5230 /**
5231 * If command includes uppercase character convert it to lowercase and add `-`.
5232 * e.g: `CopyAll` is converted to `copy-all`.
5233 *
5234 * @param {string} commandName
5235 */
5236 }, {
5237 key: "normalizeCommandName",
5238 value: function normalizeCommandName(commandName) {
5239 return commandName.replace(/[A-Z]/g, function (match, offset) {
5240 return (offset > 0 ? '-' : '') + match.toLowerCase();
5241 });
5242 }
5243
5244 /**
5245 * @param {{}} commandsFromImport
5246 * @return {{}} imported commands
5247 */
5248 }, {
5249 key: "importCommands",
5250 value: function importCommands(commandsFromImport) {
5251 var _this5 = this;
5252 var commands = {};
5253
5254 // Convert `Commands` to `ComponentBase` workable format.
5255 Object.entries(commandsFromImport).forEach(function (_ref1) {
5256 var _ref10 = (0, _slicedToArray2.default)(_ref1, 2),
5257 className = _ref10[0],
5258 Class = _ref10[1];
5259 var command = _this5.normalizeCommandName(className);
5260 commands[command] = Class;
5261 });
5262 return commands;
5263 }
5264 }, {
5265 key: "importHooks",
5266 value: function importHooks(hooksFromImport) {
5267 var hooks = {};
5268 for (var key in hooksFromImport) {
5269 var hook = new hooksFromImport[key]();
5270 hooks[hook.getId()] = hook;
5271 }
5272 return hooks;
5273 }
5274
5275 /**
5276 * Import & initialize the component's UI states.
5277 * Should be used inside `defaultUiState()`.
5278 *
5279 * @param {Object} statesFromImport - UI states from import.
5280 *
5281 * @return {Object} UI States
5282 */
5283 }, {
5284 key: "importUiStates",
5285 value: function importUiStates(statesFromImport) {
5286 var _this6 = this;
5287 var uiStates = {};
5288 Object.values(statesFromImport).forEach(function (className) {
5289 var uiState = new className(_this6);
5290 uiStates[uiState.getId()] = uiState;
5291 });
5292 return uiStates;
5293 }
5294
5295 /**
5296 * Set a UI state value.
5297 * TODO: Should we provide such function? Maybe the developer should implicitly pass the full state ID?
5298 *
5299 * @param {string} state - Non-prefixed state ID.
5300 * @param {*} value - New state value.
5301 *
5302 * @return {void}
5303 */
5304 }, {
5305 key: "setUiState",
5306 value: function setUiState(state, value) {
5307 $e.uiStates.set("".concat(this.getNamespace(), "/").concat(state), value);
5308 }
5309 }, {
5310 key: "toggleRouteClass",
5311 value: function toggleRouteClass(route, state) {
5312 document.body.classList.toggle(this.getBodyClass(route), state);
5313 }
5314 }, {
5315 key: "toggleHistoryClass",
5316 value: function toggleHistoryClass() {
5317 document.body.classList.toggle('e-routes-has-history', !!$e.routes.getHistory(this.getServiceName()).length);
5318 }
5319 }]);
5320 }(_module.default);
5321
5322 /***/ }),
5323
5324 /***/ "../modules/web-cli/assets/js/modules/component-modal-base.js":
5325 /*!********************************************************************!*\
5326 !*** ../modules/web-cli/assets/js/modules/component-modal-base.js ***!
5327 \********************************************************************/
5328 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5329
5330 "use strict";
5331
5332
5333 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5334 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
5335 Object.defineProperty(exports, "__esModule", ({
5336 value: true
5337 }));
5338 exports["default"] = void 0;
5339 var _readOnlyError2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/readOnlyError */ "../node_modules/@babel/runtime/helpers/readOnlyError.js"));
5340 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
5341 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
5342 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
5343 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
5344 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
5345 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
5346 var _componentBase = _interopRequireDefault(__webpack_require__(/*! ./component-base */ "../modules/web-cli/assets/js/modules/component-base.js"));
5347 var commands = _interopRequireWildcard(__webpack_require__(/*! ./commands/ */ "../modules/web-cli/assets/js/modules/commands/index.js"));
5348 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
5349 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); }
5350 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)); }
5351 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
5352 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; }
5353 var ComponentModalBase = exports["default"] = /*#__PURE__*/function (_ComponentBase) {
5354 function ComponentModalBase() {
5355 (0, _classCallCheck2.default)(this, ComponentModalBase);
5356 return _callSuper(this, ComponentModalBase, arguments);
5357 }
5358 (0, _inherits2.default)(ComponentModalBase, _ComponentBase);
5359 return (0, _createClass2.default)(ComponentModalBase, [{
5360 key: "registerAPI",
5361 value: function registerAPI() {
5362 var _this = this;
5363 _superPropGet(ComponentModalBase, "registerAPI", this, 3)([]);
5364 $e.shortcuts.register('esc', {
5365 scopes: [this.getNamespace()],
5366 callback: function callback() {
5367 return _this.close();
5368 }
5369 });
5370 }
5371 }, {
5372 key: "defaultCommands",
5373 value: function defaultCommands() {
5374 return this.importCommands(commands);
5375 }
5376 }, {
5377 key: "defaultRoutes",
5378 value: function defaultRoutes() {
5379 return {
5380 '': function _() {/* Nothing to do, it's already rendered. */}
5381 };
5382 }
5383 }, {
5384 key: "open",
5385 value: function open() {
5386 var _this2 = this;
5387 if (!this.layout) {
5388 var layout = this.getModalLayout();
5389 this.layout = new layout({
5390 component: this
5391 });
5392 this.layout.getModal().on('hide', function () {
5393 return _this2.close();
5394 });
5395 }
5396 this.layout.showModal();
5397 return true;
5398 }
5399 }, {
5400 key: "close",
5401 value: function close() {
5402 if (!_superPropGet(ComponentModalBase, "close", this, 3)([])) {
5403 return false;
5404 }
5405 var close = elementor.hooks.applyFilters('component/modal/close', this.layout.getModal().hide.bind(this.layout.getModal()), this);
5406 close();
5407 return true;
5408 }
5409 }, {
5410 key: "getModalLayout",
5411 value: function getModalLayout() {
5412 (0, _forceMethodImplementation.default)();
5413 }
5414 }]);
5415 }(_componentBase.default);
5416
5417 /***/ }),
5418
5419 /***/ "../modules/web-cli/assets/js/utils/console.js":
5420 /*!*****************************************************!*\
5421 !*** ../modules/web-cli/assets/js/utils/console.js ***!
5422 \*****************************************************/
5423 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5424
5425 "use strict";
5426
5427
5428 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5429 Object.defineProperty(exports, "__esModule", ({
5430 value: true
5431 }));
5432 exports["default"] = void 0;
5433 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
5434 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
5435 var Console = exports["default"] = /*#__PURE__*/function () {
5436 function Console() {
5437 (0, _classCallCheck2.default)(this, Console);
5438 }
5439 return (0, _createClass2.default)(Console, null, [{
5440 key: "error",
5441 value: function error(message) {
5442 // Show an error if devTools is available.
5443 if ($e.devTools) {
5444 $e.devTools.log.error(message);
5445 }
5446
5447 // If not a 'Hook-Break' then show error.
5448 if (!(message instanceof $e.modules.HookBreak)) {
5449 // eslint-disable-next-line no-console
5450 console.error(message);
5451 }
5452 }
5453 }, {
5454 key: "warn",
5455 value: function warn() {
5456 var _console;
5457 var style = "font-size: 12px; background-image: url(\"".concat(elementorWebCliConfig.urls.assets, "images/logo-icon.png\"); background-repeat: no-repeat; background-size: contain;");
5458 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5459 args[_key] = arguments[_key];
5460 }
5461 args.unshift('%c %c', style, '');
5462 (_console = console).warn.apply(_console, args); // eslint-disable-line no-console
5463 }
5464 }]);
5465 }();
5466
5467 /***/ }),
5468
5469 /***/ "../modules/web-cli/assets/js/utils/deprecation.js":
5470 /*!*********************************************************!*\
5471 !*** ../modules/web-cli/assets/js/utils/deprecation.js ***!
5472 \*********************************************************/
5473 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5474
5475 "use strict";
5476
5477
5478 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5479 Object.defineProperty(exports, "__esModule", ({
5480 value: true
5481 }));
5482 exports["default"] = void 0;
5483 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
5484 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
5485 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
5486 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
5487 // Copied from `modules/dev-tools/assets/js/deprecation.js`
5488 /**
5489 * @typedef {Object} Version
5490 * @property {number} major1 The first number
5491 * @property {number} major2 The second number
5492 * @property {number} minor The third number
5493 * @property {string} build The fourth number
5494 */
5495
5496 var softDeprecated = function softDeprecated(name, version, replacement) {
5497 if (elementorWebCliConfig.isDebug) {
5498 deprecatedMessage('soft', name, version, replacement);
5499 }
5500 };
5501 var hardDeprecated = function hardDeprecated(name, version, replacement) {
5502 deprecatedMessage('hard', name, version, replacement);
5503 };
5504 var deprecatedMessage = function deprecatedMessage(type, name, version, replacement) {
5505 var message = "`".concat(name, "` is ").concat(type, " deprecated since ").concat(version);
5506 if (replacement) {
5507 message += " - Use `".concat(replacement, "` instead");
5508 }
5509 _console.default.warn(message);
5510 };
5511 var Deprecation = exports["default"] = /*#__PURE__*/function () {
5512 function Deprecation() {
5513 (0, _classCallCheck2.default)(this, Deprecation);
5514 }
5515 return (0, _createClass2.default)(Deprecation, null, [{
5516 key: "deprecated",
5517 value: function deprecated(name, version, replacement) {
5518 if (this.isHardDeprecated(version)) {
5519 hardDeprecated(name, version, replacement);
5520 } else {
5521 softDeprecated(name, version, replacement);
5522 }
5523 }
5524
5525 /**
5526 * @param {string} version
5527 *
5528 * @return {Version}
5529 */
5530 }, {
5531 key: "parseVersion",
5532 value: function parseVersion(version) {
5533 var versionParts = version.split('.');
5534 if (versionParts.length < 3 || versionParts.length > 4) {
5535 throw new RangeError('Invalid Semantic Version string provided');
5536 }
5537 var _versionParts = (0, _slicedToArray2.default)(versionParts, 4),
5538 major1 = _versionParts[0],
5539 major2 = _versionParts[1],
5540 minor = _versionParts[2],
5541 _versionParts$ = _versionParts[3],
5542 build = _versionParts$ === void 0 ? '' : _versionParts$;
5543 return {
5544 major1: parseInt(major1),
5545 major2: parseInt(major2),
5546 minor: parseInt(minor),
5547 build: build
5548 };
5549 }
5550
5551 /**
5552 * Get total of major.
5553 *
5554 * 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,
5555 * versions with major2 more then 9 will be added to total.
5556 *
5557 * @param {Version} versionObj
5558 *
5559 * @return {number}
5560 */
5561 }, {
5562 key: "getTotalMajor",
5563 value: function getTotalMajor(versionObj) {
5564 var total = parseInt("".concat(versionObj.major1).concat(versionObj.major2, "0"));
5565 total = Number((total / 10).toFixed(0));
5566 if (versionObj.major2 > 9) {
5567 total = versionObj.major2 - 9;
5568 }
5569 return total;
5570 }
5571
5572 /**
5573 * @param {string} version1
5574 * @param {string} version2
5575 *
5576 * @return {number}
5577 */
5578 }, {
5579 key: "compareVersion",
5580 value: function compareVersion(version1, version2) {
5581 var _this = this;
5582 return [this.parseVersion(version1), this.parseVersion(version2)].map(function (versionObj) {
5583 return _this.getTotalMajor(versionObj);
5584 }).reduce(function (acc, major) {
5585 return acc - major;
5586 });
5587 }
5588
5589 /**
5590 * @param {string} version
5591 *
5592 * @return {boolean}
5593 */
5594 }, {
5595 key: "isSoftDeprecated",
5596 value: function isSoftDeprecated(version) {
5597 var total = this.compareVersion(version, elementorWebCliConfig.version);
5598 return total <= 4;
5599 }
5600
5601 /**
5602 * @param {string} version
5603 * @return {boolean}
5604 */
5605 }, {
5606 key: "isHardDeprecated",
5607 value: function isHardDeprecated(version) {
5608 var total = this.compareVersion(version, elementorWebCliConfig.version);
5609 return total < 0 || total >= 8;
5610 }
5611 }]);
5612 }();
5613
5614 /***/ }),
5615
5616 /***/ "../modules/web-cli/assets/js/utils/force-method-implementation.js":
5617 /*!*************************************************************************!*\
5618 !*** ../modules/web-cli/assets/js/utils/force-method-implementation.js ***!
5619 \*************************************************************************/
5620 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5621
5622 "use strict";
5623
5624
5625 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5626 Object.defineProperty(exports, "__esModule", ({
5627 value: true
5628 }));
5629 exports["default"] = exports.ForceMethodImplementation = void 0;
5630 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
5631 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
5632 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
5633 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
5634 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
5635 var _wrapNativeSuper2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/wrapNativeSuper */ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js"));
5636 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)); }
5637 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
5638 // TODO: Copied from `assets/dev/js/modules/imports/force-method-implementation.js`;
5639 var ForceMethodImplementation = exports.ForceMethodImplementation = /*#__PURE__*/function (_Error) {
5640 function ForceMethodImplementation() {
5641 var _this;
5642 var info = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5643 (0, _classCallCheck2.default)(this, ForceMethodImplementation);
5644 _this = _callSuper(this, ForceMethodImplementation, ["".concat(info.isStatic ? 'static ' : '').concat(info.fullName, "() should be implemented, please provide '").concat(info.functionName || info.fullName, "' functionality.")]);
5645 Error.captureStackTrace(_this, ForceMethodImplementation);
5646 return _this;
5647 }
5648 (0, _inherits2.default)(ForceMethodImplementation, _Error);
5649 return (0, _createClass2.default)(ForceMethodImplementation);
5650 }(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
5651 var _default = exports["default"] = function _default() {
5652 var stack = Error().stack,
5653 caller = stack.split('\n')[2].trim(),
5654 callerName = caller.startsWith('at new') ? 'constructor' : caller.split(' ')[1],
5655 info = {};
5656 info.functionName = callerName;
5657 info.fullName = callerName;
5658 if (info.functionName.includes('.')) {
5659 var parts = info.functionName.split('.');
5660 info.className = parts[0];
5661 info.functionName = parts[1];
5662 } else {
5663 info.isStatic = true;
5664 }
5665 throw new ForceMethodImplementation(info);
5666 };
5667
5668 /***/ }),
5669
5670 /***/ "../node_modules/@babel/runtime/helpers/OverloadYield.js":
5671 /*!***************************************************************!*\
5672 !*** ../node_modules/@babel/runtime/helpers/OverloadYield.js ***!
5673 \***************************************************************/
5674 /***/ ((module) => {
5675
5676 function _OverloadYield(e, d) {
5677 this.v = e, this.k = d;
5678 }
5679 module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
5680
5681 /***/ }),
5682
5683 /***/ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js":
5684 /*!******************************************************************!*\
5685 !*** ../node_modules/@babel/runtime/helpers/arrayLikeToArray.js ***!
5686 \******************************************************************/
5687 /***/ ((module) => {
5688
5689 function _arrayLikeToArray(r, a) {
5690 (null == a || a > r.length) && (a = r.length);
5691 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
5692 return n;
5693 }
5694 module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
5695
5696 /***/ }),
5697
5698 /***/ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js":
5699 /*!****************************************************************!*\
5700 !*** ../node_modules/@babel/runtime/helpers/arrayWithHoles.js ***!
5701 \****************************************************************/
5702 /***/ ((module) => {
5703
5704 function _arrayWithHoles(r) {
5705 if (Array.isArray(r)) return r;
5706 }
5707 module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
5708
5709 /***/ }),
5710
5711 /***/ "../node_modules/@babel/runtime/helpers/assertThisInitialized.js":
5712 /*!***********************************************************************!*\
5713 !*** ../node_modules/@babel/runtime/helpers/assertThisInitialized.js ***!
5714 \***********************************************************************/
5715 /***/ ((module) => {
5716
5717 function _assertThisInitialized(e) {
5718 if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
5719 return e;
5720 }
5721 module.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports["default"] = module.exports;
5722
5723 /***/ }),
5724
5725 /***/ "../node_modules/@babel/runtime/helpers/asyncToGenerator.js":
5726 /*!******************************************************************!*\
5727 !*** ../node_modules/@babel/runtime/helpers/asyncToGenerator.js ***!
5728 \******************************************************************/
5729 /***/ ((module) => {
5730
5731 function asyncGeneratorStep(n, t, e, r, o, a, c) {
5732 try {
5733 var i = n[a](c),
5734 u = i.value;
5735 } catch (n) {
5736 return void e(n);
5737 }
5738 i.done ? t(u) : Promise.resolve(u).then(r, o);
5739 }
5740 function _asyncToGenerator(n) {
5741 return function () {
5742 var t = this,
5743 e = arguments;
5744 return new Promise(function (r, o) {
5745 var a = n.apply(t, e);
5746 function _next(n) {
5747 asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
5748 }
5749 function _throw(n) {
5750 asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
5751 }
5752 _next(void 0);
5753 });
5754 };
5755 }
5756 module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
5757
5758 /***/ }),
5759
5760 /***/ "../node_modules/@babel/runtime/helpers/classCallCheck.js":
5761 /*!****************************************************************!*\
5762 !*** ../node_modules/@babel/runtime/helpers/classCallCheck.js ***!
5763 \****************************************************************/
5764 /***/ ((module) => {
5765
5766 function _classCallCheck(a, n) {
5767 if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
5768 }
5769 module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
5770
5771 /***/ }),
5772
5773 /***/ "../node_modules/@babel/runtime/helpers/construct.js":
5774 /*!***********************************************************!*\
5775 !*** ../node_modules/@babel/runtime/helpers/construct.js ***!
5776 \***********************************************************/
5777 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5778
5779 var isNativeReflectConstruct = __webpack_require__(/*! ./isNativeReflectConstruct.js */ "../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js");
5780 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
5781 function _construct(t, e, r) {
5782 if (isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
5783 var o = [null];
5784 o.push.apply(o, e);
5785 var p = new (t.bind.apply(t, o))();
5786 return r && setPrototypeOf(p, r.prototype), p;
5787 }
5788 module.exports = _construct, module.exports.__esModule = true, module.exports["default"] = module.exports;
5789
5790 /***/ }),
5791
5792 /***/ "../node_modules/@babel/runtime/helpers/createClass.js":
5793 /*!*************************************************************!*\
5794 !*** ../node_modules/@babel/runtime/helpers/createClass.js ***!
5795 \*************************************************************/
5796 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5797
5798 var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/toPropertyKey.js");
5799 function _defineProperties(e, r) {
5800 for (var t = 0; t < r.length; t++) {
5801 var o = r[t];
5802 o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey(o.key), o);
5803 }
5804 }
5805 function _createClass(e, r, t) {
5806 return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
5807 writable: !1
5808 }), e;
5809 }
5810 module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
5811
5812 /***/ }),
5813
5814 /***/ "../node_modules/@babel/runtime/helpers/defineProperty.js":
5815 /*!****************************************************************!*\
5816 !*** ../node_modules/@babel/runtime/helpers/defineProperty.js ***!
5817 \****************************************************************/
5818 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5819
5820 var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/toPropertyKey.js");
5821 function _defineProperty(e, r, t) {
5822 return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
5823 value: t,
5824 enumerable: !0,
5825 configurable: !0,
5826 writable: !0
5827 }) : e[r] = t, e;
5828 }
5829 module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
5830
5831 /***/ }),
5832
5833 /***/ "../node_modules/@babel/runtime/helpers/esm/defineProperty.js":
5834 /*!********************************************************************!*\
5835 !*** ../node_modules/@babel/runtime/helpers/esm/defineProperty.js ***!
5836 \********************************************************************/
5837 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5838
5839 "use strict";
5840 __webpack_require__.r(__webpack_exports__);
5841 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5842 /* harmony export */ "default": () => (/* binding */ _defineProperty)
5843 /* harmony export */ });
5844 /* harmony import */ var _toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js");
5845
5846 function _defineProperty(e, r, t) {
5847 return (r = (0,_toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__["default"])(r)) in e ? Object.defineProperty(e, r, {
5848 value: t,
5849 enumerable: !0,
5850 configurable: !0,
5851 writable: !0
5852 }) : e[r] = t, e;
5853 }
5854
5855
5856 /***/ }),
5857
5858 /***/ "../node_modules/@babel/runtime/helpers/esm/objectSpread2.js":
5859 /*!*******************************************************************!*\
5860 !*** ../node_modules/@babel/runtime/helpers/esm/objectSpread2.js ***!
5861 \*******************************************************************/
5862 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5863
5864 "use strict";
5865 __webpack_require__.r(__webpack_exports__);
5866 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5867 /* harmony export */ "default": () => (/* binding */ _objectSpread2)
5868 /* harmony export */ });
5869 /* harmony import */ var _defineProperty_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defineProperty.js */ "../node_modules/@babel/runtime/helpers/esm/defineProperty.js");
5870
5871 function ownKeys(e, r) {
5872 var t = Object.keys(e);
5873 if (Object.getOwnPropertySymbols) {
5874 var o = Object.getOwnPropertySymbols(e);
5875 r && (o = o.filter(function (r) {
5876 return Object.getOwnPropertyDescriptor(e, r).enumerable;
5877 })), t.push.apply(t, o);
5878 }
5879 return t;
5880 }
5881 function _objectSpread2(e) {
5882 for (var r = 1; r < arguments.length; r++) {
5883 var t = null != arguments[r] ? arguments[r] : {};
5884 r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
5885 (0,_defineProperty_js__WEBPACK_IMPORTED_MODULE_0__["default"])(e, r, t[r]);
5886 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
5887 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
5888 });
5889 }
5890 return e;
5891 }
5892
5893
5894 /***/ }),
5895
5896 /***/ "../node_modules/@babel/runtime/helpers/esm/toPrimitive.js":
5897 /*!*****************************************************************!*\
5898 !*** ../node_modules/@babel/runtime/helpers/esm/toPrimitive.js ***!
5899 \*****************************************************************/
5900 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5901
5902 "use strict";
5903 __webpack_require__.r(__webpack_exports__);
5904 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5905 /* harmony export */ "default": () => (/* binding */ toPrimitive)
5906 /* harmony export */ });
5907 /* harmony import */ var _typeof_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/esm/typeof.js");
5908
5909 function toPrimitive(t, r) {
5910 if ("object" != (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(t) || !t) return t;
5911 var e = t[Symbol.toPrimitive];
5912 if (void 0 !== e) {
5913 var i = e.call(t, r || "default");
5914 if ("object" != (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(i)) return i;
5915 throw new TypeError("@@toPrimitive must return a primitive value.");
5916 }
5917 return ("string" === r ? String : Number)(t);
5918 }
5919
5920
5921 /***/ }),
5922
5923 /***/ "../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js":
5924 /*!*******************************************************************!*\
5925 !*** ../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js ***!
5926 \*******************************************************************/
5927 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5928
5929 "use strict";
5930 __webpack_require__.r(__webpack_exports__);
5931 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5932 /* harmony export */ "default": () => (/* binding */ toPropertyKey)
5933 /* harmony export */ });
5934 /* harmony import */ var _typeof_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/esm/typeof.js");
5935 /* harmony import */ var _toPrimitive_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./toPrimitive.js */ "../node_modules/@babel/runtime/helpers/esm/toPrimitive.js");
5936
5937
5938 function toPropertyKey(t) {
5939 var i = (0,_toPrimitive_js__WEBPACK_IMPORTED_MODULE_1__["default"])(t, "string");
5940 return "symbol" == (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(i) ? i : i + "";
5941 }
5942
5943
5944 /***/ }),
5945
5946 /***/ "../node_modules/@babel/runtime/helpers/esm/typeof.js":
5947 /*!************************************************************!*\
5948 !*** ../node_modules/@babel/runtime/helpers/esm/typeof.js ***!
5949 \************************************************************/
5950 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5951
5952 "use strict";
5953 __webpack_require__.r(__webpack_exports__);
5954 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5955 /* harmony export */ "default": () => (/* binding */ _typeof)
5956 /* harmony export */ });
5957 function _typeof(o) {
5958 "@babel/helpers - typeof";
5959
5960 return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
5961 return typeof o;
5962 } : function (o) {
5963 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
5964 }, _typeof(o);
5965 }
5966
5967
5968 /***/ }),
5969
5970 /***/ "../node_modules/@babel/runtime/helpers/get.js":
5971 /*!*****************************************************!*\
5972 !*** ../node_modules/@babel/runtime/helpers/get.js ***!
5973 \*****************************************************/
5974 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5975
5976 var superPropBase = __webpack_require__(/*! ./superPropBase.js */ "../node_modules/@babel/runtime/helpers/superPropBase.js");
5977 function _get() {
5978 return module.exports = _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) {
5979 var p = superPropBase(e, t);
5980 if (p) {
5981 var n = Object.getOwnPropertyDescriptor(p, t);
5982 return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value;
5983 }
5984 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _get.apply(null, arguments);
5985 }
5986 module.exports = _get, module.exports.__esModule = true, module.exports["default"] = module.exports;
5987
5988 /***/ }),
5989
5990 /***/ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js":
5991 /*!****************************************************************!*\
5992 !*** ../node_modules/@babel/runtime/helpers/getPrototypeOf.js ***!
5993 \****************************************************************/
5994 /***/ ((module) => {
5995
5996 function _getPrototypeOf(t) {
5997 return module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
5998 return t.__proto__ || Object.getPrototypeOf(t);
5999 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _getPrototypeOf(t);
6000 }
6001 module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
6002
6003 /***/ }),
6004
6005 /***/ "../node_modules/@babel/runtime/helpers/inherits.js":
6006 /*!**********************************************************!*\
6007 !*** ../node_modules/@babel/runtime/helpers/inherits.js ***!
6008 \**********************************************************/
6009 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6010
6011 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
6012 function _inherits(t, e) {
6013 if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
6014 t.prototype = Object.create(e && e.prototype, {
6015 constructor: {
6016 value: t,
6017 writable: !0,
6018 configurable: !0
6019 }
6020 }), Object.defineProperty(t, "prototype", {
6021 writable: !1
6022 }), e && setPrototypeOf(t, e);
6023 }
6024 module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports;
6025
6026 /***/ }),
6027
6028 /***/ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js":
6029 /*!***********************************************************************!*\
6030 !*** ../node_modules/@babel/runtime/helpers/interopRequireDefault.js ***!
6031 \***********************************************************************/
6032 /***/ ((module) => {
6033
6034 function _interopRequireDefault(e) {
6035 return e && e.__esModule ? e : {
6036 "default": e
6037 };
6038 }
6039 module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
6040
6041 /***/ }),
6042
6043 /***/ "../node_modules/@babel/runtime/helpers/isNativeFunction.js":
6044 /*!******************************************************************!*\
6045 !*** ../node_modules/@babel/runtime/helpers/isNativeFunction.js ***!
6046 \******************************************************************/
6047 /***/ ((module) => {
6048
6049 function _isNativeFunction(t) {
6050 try {
6051 return -1 !== Function.toString.call(t).indexOf("[native code]");
6052 } catch (n) {
6053 return "function" == typeof t;
6054 }
6055 }
6056 module.exports = _isNativeFunction, module.exports.__esModule = true, module.exports["default"] = module.exports;
6057
6058 /***/ }),
6059
6060 /***/ "../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js":
6061 /*!**************************************************************************!*\
6062 !*** ../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js ***!
6063 \**************************************************************************/
6064 /***/ ((module) => {
6065
6066 function _isNativeReflectConstruct() {
6067 try {
6068 var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
6069 } catch (t) {}
6070 return (module.exports = _isNativeReflectConstruct = function _isNativeReflectConstruct() {
6071 return !!t;
6072 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
6073 }
6074 module.exports = _isNativeReflectConstruct, module.exports.__esModule = true, module.exports["default"] = module.exports;
6075
6076 /***/ }),
6077
6078 /***/ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js":
6079 /*!**********************************************************************!*\
6080 !*** ../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js ***!
6081 \**********************************************************************/
6082 /***/ ((module) => {
6083
6084 function _iterableToArrayLimit(r, l) {
6085 var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
6086 if (null != t) {
6087 var e,
6088 n,
6089 i,
6090 u,
6091 a = [],
6092 f = !0,
6093 o = !1;
6094 try {
6095 if (i = (t = t.call(r)).next, 0 === l) {
6096 if (Object(t) !== t) return;
6097 f = !1;
6098 } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
6099 } catch (r) {
6100 o = !0, n = r;
6101 } finally {
6102 try {
6103 if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
6104 } finally {
6105 if (o) throw n;
6106 }
6107 }
6108 return a;
6109 }
6110 }
6111 module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports;
6112
6113 /***/ }),
6114
6115 /***/ "../node_modules/@babel/runtime/helpers/nonIterableRest.js":
6116 /*!*****************************************************************!*\
6117 !*** ../node_modules/@babel/runtime/helpers/nonIterableRest.js ***!
6118 \*****************************************************************/
6119 /***/ ((module) => {
6120
6121 function _nonIterableRest() {
6122 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
6123 }
6124 module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports;
6125
6126 /***/ }),
6127
6128 /***/ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js":
6129 /*!***************************************************************************!*\
6130 !*** ../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js ***!
6131 \***************************************************************************/
6132 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6133
6134 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6135 var assertThisInitialized = __webpack_require__(/*! ./assertThisInitialized.js */ "../node_modules/@babel/runtime/helpers/assertThisInitialized.js");
6136 function _possibleConstructorReturn(t, e) {
6137 if (e && ("object" == _typeof(e) || "function" == typeof e)) return e;
6138 if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
6139 return assertThisInitialized(t);
6140 }
6141 module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
6142
6143 /***/ }),
6144
6145 /***/ "../node_modules/@babel/runtime/helpers/readOnlyError.js":
6146 /*!***************************************************************!*\
6147 !*** ../node_modules/@babel/runtime/helpers/readOnlyError.js ***!
6148 \***************************************************************/
6149 /***/ ((module) => {
6150
6151 function _readOnlyError(r) {
6152 throw new TypeError('"' + r + '" is read-only');
6153 }
6154 module.exports = _readOnlyError, module.exports.__esModule = true, module.exports["default"] = module.exports;
6155
6156 /***/ }),
6157
6158 /***/ "../node_modules/@babel/runtime/helpers/regenerator.js":
6159 /*!*************************************************************!*\
6160 !*** ../node_modules/@babel/runtime/helpers/regenerator.js ***!
6161 \*************************************************************/
6162 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6163
6164 var regeneratorDefine = __webpack_require__(/*! ./regeneratorDefine.js */ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js");
6165 function _regenerator() {
6166 /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
6167 var e,
6168 t,
6169 r = "function" == typeof Symbol ? Symbol : {},
6170 n = r.iterator || "@@iterator",
6171 o = r.toStringTag || "@@toStringTag";
6172 function i(r, n, o, i) {
6173 var c = n && n.prototype instanceof Generator ? n : Generator,
6174 u = Object.create(c.prototype);
6175 return regeneratorDefine(u, "_invoke", function (r, n, o) {
6176 var i,
6177 c,
6178 u,
6179 f = 0,
6180 p = o || [],
6181 y = !1,
6182 G = {
6183 p: 0,
6184 n: 0,
6185 v: e,
6186 a: d,
6187 f: d.bind(e, 4),
6188 d: function d(t, r) {
6189 return i = t, c = 0, u = e, G.n = r, a;
6190 }
6191 };
6192 function d(r, n) {
6193 for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
6194 var o,
6195 i = p[t],
6196 d = G.p,
6197 l = i[2];
6198 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));
6199 }
6200 if (o || r > 1) return a;
6201 throw y = !0, n;
6202 }
6203 return function (o, p, l) {
6204 if (f > 1) throw TypeError("Generator is already running");
6205 for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
6206 i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
6207 try {
6208 if (f = 2, i) {
6209 if (c || (o = "next"), t = i[o]) {
6210 if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
6211 if (!t.done) return t;
6212 u = t.value, c < 2 && (c = 0);
6213 } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
6214 i = e;
6215 } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
6216 } catch (t) {
6217 i = e, c = 1, u = t;
6218 } finally {
6219 f = 1;
6220 }
6221 }
6222 return {
6223 value: t,
6224 done: y
6225 };
6226 };
6227 }(r, o, i), !0), u;
6228 }
6229 var a = {};
6230 function Generator() {}
6231 function GeneratorFunction() {}
6232 function GeneratorFunctionPrototype() {}
6233 t = Object.getPrototypeOf;
6234 var c = [][n] ? t(t([][n]())) : (regeneratorDefine(t = {}, n, function () {
6235 return this;
6236 }), t),
6237 u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
6238 function f(e) {
6239 return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
6240 }
6241 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 () {
6242 return this;
6243 }), regeneratorDefine(u, "toString", function () {
6244 return "[object Generator]";
6245 }), (module.exports = _regenerator = function _regenerator() {
6246 return {
6247 w: i,
6248 m: f
6249 };
6250 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
6251 }
6252 module.exports = _regenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
6253
6254 /***/ }),
6255
6256 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsync.js":
6257 /*!******************************************************************!*\
6258 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsync.js ***!
6259 \******************************************************************/
6260 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6261
6262 var regeneratorAsyncGen = __webpack_require__(/*! ./regeneratorAsyncGen.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js");
6263 function _regeneratorAsync(n, e, r, t, o) {
6264 var a = regeneratorAsyncGen(n, e, r, t, o);
6265 return a.next().then(function (n) {
6266 return n.done ? n.value : a.next();
6267 });
6268 }
6269 module.exports = _regeneratorAsync, module.exports.__esModule = true, module.exports["default"] = module.exports;
6270
6271 /***/ }),
6272
6273 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js":
6274 /*!*********************************************************************!*\
6275 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js ***!
6276 \*********************************************************************/
6277 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6278
6279 var regenerator = __webpack_require__(/*! ./regenerator.js */ "../node_modules/@babel/runtime/helpers/regenerator.js");
6280 var regeneratorAsyncIterator = __webpack_require__(/*! ./regeneratorAsyncIterator.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js");
6281 function _regeneratorAsyncGen(r, e, t, o, n) {
6282 return new regeneratorAsyncIterator(regenerator().w(r, e, t, o), n || Promise);
6283 }
6284 module.exports = _regeneratorAsyncGen, module.exports.__esModule = true, module.exports["default"] = module.exports;
6285
6286 /***/ }),
6287
6288 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js":
6289 /*!**************************************************************************!*\
6290 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js ***!
6291 \**************************************************************************/
6292 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6293
6294 var OverloadYield = __webpack_require__(/*! ./OverloadYield.js */ "../node_modules/@babel/runtime/helpers/OverloadYield.js");
6295 var regeneratorDefine = __webpack_require__(/*! ./regeneratorDefine.js */ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js");
6296 function AsyncIterator(t, e) {
6297 function n(r, o, i, f) {
6298 try {
6299 var c = t[r](o),
6300 u = c.value;
6301 return u instanceof OverloadYield ? e.resolve(u.v).then(function (t) {
6302 n("next", t, i, f);
6303 }, function (t) {
6304 n("throw", t, i, f);
6305 }) : e.resolve(u).then(function (t) {
6306 c.value = t, i(c);
6307 }, function (t) {
6308 return n("throw", t, i, f);
6309 });
6310 } catch (t) {
6311 f(t);
6312 }
6313 }
6314 var r;
6315 this.next || (regeneratorDefine(AsyncIterator.prototype), regeneratorDefine(AsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () {
6316 return this;
6317 })), regeneratorDefine(this, "_invoke", function (t, o, i) {
6318 function f() {
6319 return new e(function (e, r) {
6320 n(t, i, e, r);
6321 });
6322 }
6323 return r = r ? r.then(f, f) : f();
6324 }, !0);
6325 }
6326 module.exports = AsyncIterator, module.exports.__esModule = true, module.exports["default"] = module.exports;
6327
6328 /***/ }),
6329
6330 /***/ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js":
6331 /*!*******************************************************************!*\
6332 !*** ../node_modules/@babel/runtime/helpers/regeneratorDefine.js ***!
6333 \*******************************************************************/
6334 /***/ ((module) => {
6335
6336 function _regeneratorDefine(e, r, n, t) {
6337 var i = Object.defineProperty;
6338 try {
6339 i({}, "", {});
6340 } catch (e) {
6341 i = 0;
6342 }
6343 module.exports = _regeneratorDefine = function regeneratorDefine(e, r, n, t) {
6344 function o(r, n) {
6345 _regeneratorDefine(e, r, function (e) {
6346 return this._invoke(r, n, e);
6347 });
6348 }
6349 r ? i ? i(e, r, {
6350 value: n,
6351 enumerable: !t,
6352 configurable: !t,
6353 writable: !t
6354 }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
6355 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _regeneratorDefine(e, r, n, t);
6356 }
6357 module.exports = _regeneratorDefine, module.exports.__esModule = true, module.exports["default"] = module.exports;
6358
6359 /***/ }),
6360
6361 /***/ "../node_modules/@babel/runtime/helpers/regeneratorKeys.js":
6362 /*!*****************************************************************!*\
6363 !*** ../node_modules/@babel/runtime/helpers/regeneratorKeys.js ***!
6364 \*****************************************************************/
6365 /***/ ((module) => {
6366
6367 function _regeneratorKeys(e) {
6368 var n = Object(e),
6369 r = [];
6370 for (var t in n) r.unshift(t);
6371 return function e() {
6372 for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e;
6373 return e.done = !0, e;
6374 };
6375 }
6376 module.exports = _regeneratorKeys, module.exports.__esModule = true, module.exports["default"] = module.exports;
6377
6378 /***/ }),
6379
6380 /***/ "../node_modules/@babel/runtime/helpers/regeneratorRuntime.js":
6381 /*!********************************************************************!*\
6382 !*** ../node_modules/@babel/runtime/helpers/regeneratorRuntime.js ***!
6383 \********************************************************************/
6384 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6385
6386 var OverloadYield = __webpack_require__(/*! ./OverloadYield.js */ "../node_modules/@babel/runtime/helpers/OverloadYield.js");
6387 var regenerator = __webpack_require__(/*! ./regenerator.js */ "../node_modules/@babel/runtime/helpers/regenerator.js");
6388 var regeneratorAsync = __webpack_require__(/*! ./regeneratorAsync.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsync.js");
6389 var regeneratorAsyncGen = __webpack_require__(/*! ./regeneratorAsyncGen.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js");
6390 var regeneratorAsyncIterator = __webpack_require__(/*! ./regeneratorAsyncIterator.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js");
6391 var regeneratorKeys = __webpack_require__(/*! ./regeneratorKeys.js */ "../node_modules/@babel/runtime/helpers/regeneratorKeys.js");
6392 var regeneratorValues = __webpack_require__(/*! ./regeneratorValues.js */ "../node_modules/@babel/runtime/helpers/regeneratorValues.js");
6393 function _regeneratorRuntime() {
6394 "use strict";
6395
6396 var r = regenerator(),
6397 e = r.m(_regeneratorRuntime),
6398 t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
6399 function n(r) {
6400 var e = "function" == typeof r && r.constructor;
6401 return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
6402 }
6403 var o = {
6404 "throw": 1,
6405 "return": 2,
6406 "break": 3,
6407 "continue": 3
6408 };
6409 function a(r) {
6410 var e, t;
6411 return function (n) {
6412 e || (e = {
6413 stop: function stop() {
6414 return t(n.a, 2);
6415 },
6416 "catch": function _catch() {
6417 return n.v;
6418 },
6419 abrupt: function abrupt(r, e) {
6420 return t(n.a, o[r], e);
6421 },
6422 delegateYield: function delegateYield(r, o, a) {
6423 return e.resultName = o, t(n.d, regeneratorValues(r), a);
6424 },
6425 finish: function finish(r) {
6426 return t(n.f, r);
6427 }
6428 }, t = function t(r, _t, o) {
6429 n.p = e.prev, n.n = e.next;
6430 try {
6431 return r(_t, o);
6432 } finally {
6433 e.next = n.n;
6434 }
6435 }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
6436 try {
6437 return r.call(this, e);
6438 } finally {
6439 n.p = e.prev, n.n = e.next;
6440 }
6441 };
6442 }
6443 return (module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
6444 return {
6445 wrap: function wrap(e, t, n, o) {
6446 return r.w(a(e), t, n, o && o.reverse());
6447 },
6448 isGeneratorFunction: n,
6449 mark: r.m,
6450 awrap: function awrap(r, e) {
6451 return new OverloadYield(r, e);
6452 },
6453 AsyncIterator: regeneratorAsyncIterator,
6454 async: function async(r, e, t, o, u) {
6455 return (n(e) ? regeneratorAsyncGen : regeneratorAsync)(a(r), e, t, o, u);
6456 },
6457 keys: regeneratorKeys,
6458 values: regeneratorValues
6459 };
6460 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
6461 }
6462 module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
6463
6464 /***/ }),
6465
6466 /***/ "../node_modules/@babel/runtime/helpers/regeneratorValues.js":
6467 /*!*******************************************************************!*\
6468 !*** ../node_modules/@babel/runtime/helpers/regeneratorValues.js ***!
6469 \*******************************************************************/
6470 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6471
6472 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6473 function _regeneratorValues(e) {
6474 if (null != e) {
6475 var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
6476 r = 0;
6477 if (t) return t.call(e);
6478 if ("function" == typeof e.next) return e;
6479 if (!isNaN(e.length)) return {
6480 next: function next() {
6481 return e && r >= e.length && (e = void 0), {
6482 value: e && e[r++],
6483 done: !e
6484 };
6485 }
6486 };
6487 }
6488 throw new TypeError(_typeof(e) + " is not iterable");
6489 }
6490 module.exports = _regeneratorValues, module.exports.__esModule = true, module.exports["default"] = module.exports;
6491
6492 /***/ }),
6493
6494 /***/ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js":
6495 /*!****************************************************************!*\
6496 !*** ../node_modules/@babel/runtime/helpers/setPrototypeOf.js ***!
6497 \****************************************************************/
6498 /***/ ((module) => {
6499
6500 function _setPrototypeOf(t, e) {
6501 return module.exports = _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
6502 return t.__proto__ = e, t;
6503 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _setPrototypeOf(t, e);
6504 }
6505 module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
6506
6507 /***/ }),
6508
6509 /***/ "../node_modules/@babel/runtime/helpers/slicedToArray.js":
6510 /*!***************************************************************!*\
6511 !*** ../node_modules/@babel/runtime/helpers/slicedToArray.js ***!
6512 \***************************************************************/
6513 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6514
6515 var arrayWithHoles = __webpack_require__(/*! ./arrayWithHoles.js */ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js");
6516 var iterableToArrayLimit = __webpack_require__(/*! ./iterableToArrayLimit.js */ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js");
6517 var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray.js */ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js");
6518 var nonIterableRest = __webpack_require__(/*! ./nonIterableRest.js */ "../node_modules/@babel/runtime/helpers/nonIterableRest.js");
6519 function _slicedToArray(r, e) {
6520 return arrayWithHoles(r) || iterableToArrayLimit(r, e) || unsupportedIterableToArray(r, e) || nonIterableRest();
6521 }
6522 module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
6523
6524 /***/ }),
6525
6526 /***/ "../node_modules/@babel/runtime/helpers/superPropBase.js":
6527 /*!***************************************************************!*\
6528 !*** ../node_modules/@babel/runtime/helpers/superPropBase.js ***!
6529 \***************************************************************/
6530 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6531
6532 var getPrototypeOf = __webpack_require__(/*! ./getPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js");
6533 function _superPropBase(t, o) {
6534 for (; !{}.hasOwnProperty.call(t, o) && null !== (t = getPrototypeOf(t)););
6535 return t;
6536 }
6537 module.exports = _superPropBase, module.exports.__esModule = true, module.exports["default"] = module.exports;
6538
6539 /***/ }),
6540
6541 /***/ "../node_modules/@babel/runtime/helpers/toPrimitive.js":
6542 /*!*************************************************************!*\
6543 !*** ../node_modules/@babel/runtime/helpers/toPrimitive.js ***!
6544 \*************************************************************/
6545 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6546
6547 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6548 function toPrimitive(t, r) {
6549 if ("object" != _typeof(t) || !t) return t;
6550 var e = t[Symbol.toPrimitive];
6551 if (void 0 !== e) {
6552 var i = e.call(t, r || "default");
6553 if ("object" != _typeof(i)) return i;
6554 throw new TypeError("@@toPrimitive must return a primitive value.");
6555 }
6556 return ("string" === r ? String : Number)(t);
6557 }
6558 module.exports = toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
6559
6560 /***/ }),
6561
6562 /***/ "../node_modules/@babel/runtime/helpers/toPropertyKey.js":
6563 /*!***************************************************************!*\
6564 !*** ../node_modules/@babel/runtime/helpers/toPropertyKey.js ***!
6565 \***************************************************************/
6566 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6567
6568 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6569 var toPrimitive = __webpack_require__(/*! ./toPrimitive.js */ "../node_modules/@babel/runtime/helpers/toPrimitive.js");
6570 function toPropertyKey(t) {
6571 var i = toPrimitive(t, "string");
6572 return "symbol" == _typeof(i) ? i : i + "";
6573 }
6574 module.exports = toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
6575
6576 /***/ }),
6577
6578 /***/ "../node_modules/@babel/runtime/helpers/typeof.js":
6579 /*!********************************************************!*\
6580 !*** ../node_modules/@babel/runtime/helpers/typeof.js ***!
6581 \********************************************************/
6582 /***/ ((module) => {
6583
6584 function _typeof(o) {
6585 "@babel/helpers - typeof";
6586
6587 return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
6588 return typeof o;
6589 } : function (o) {
6590 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
6591 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
6592 }
6593 module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
6594
6595 /***/ }),
6596
6597 /***/ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js":
6598 /*!****************************************************************************!*\
6599 !*** ../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js ***!
6600 \****************************************************************************/
6601 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6602
6603 var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray.js */ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js");
6604 function _unsupportedIterableToArray(r, a) {
6605 if (r) {
6606 if ("string" == typeof r) return arrayLikeToArray(r, a);
6607 var t = {}.toString.call(r).slice(8, -1);
6608 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;
6609 }
6610 }
6611 module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
6612
6613 /***/ }),
6614
6615 /***/ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js":
6616 /*!*****************************************************************!*\
6617 !*** ../node_modules/@babel/runtime/helpers/wrapNativeSuper.js ***!
6618 \*****************************************************************/
6619 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6620
6621 var getPrototypeOf = __webpack_require__(/*! ./getPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js");
6622 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
6623 var isNativeFunction = __webpack_require__(/*! ./isNativeFunction.js */ "../node_modules/@babel/runtime/helpers/isNativeFunction.js");
6624 var construct = __webpack_require__(/*! ./construct.js */ "../node_modules/@babel/runtime/helpers/construct.js");
6625 function _wrapNativeSuper(t) {
6626 var r = "function" == typeof Map ? new Map() : void 0;
6627 return module.exports = _wrapNativeSuper = function _wrapNativeSuper(t) {
6628 if (null === t || !isNativeFunction(t)) return t;
6629 if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
6630 if (void 0 !== r) {
6631 if (r.has(t)) return r.get(t);
6632 r.set(t, Wrapper);
6633 }
6634 function Wrapper() {
6635 return construct(t, arguments, getPrototypeOf(this).constructor);
6636 }
6637 return Wrapper.prototype = Object.create(t.prototype, {
6638 constructor: {
6639 value: Wrapper,
6640 enumerable: !1,
6641 writable: !0,
6642 configurable: !0
6643 }
6644 }), setPrototypeOf(Wrapper, t);
6645 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _wrapNativeSuper(t);
6646 }
6647 module.exports = _wrapNativeSuper, module.exports.__esModule = true, module.exports["default"] = module.exports;
6648
6649 /***/ }),
6650
6651 /***/ "../node_modules/@babel/runtime/regenerator/index.js":
6652 /*!***********************************************************!*\
6653 !*** ../node_modules/@babel/runtime/regenerator/index.js ***!
6654 \***********************************************************/
6655 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6656
6657 // TODO(Babel 8): Remove this file.
6658
6659 var runtime = __webpack_require__(/*! ../helpers/regeneratorRuntime */ "../node_modules/@babel/runtime/helpers/regeneratorRuntime.js")();
6660 module.exports = runtime;
6661
6662 // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
6663 try {
6664 regeneratorRuntime = runtime;
6665 } catch (accidentalStrictMode) {
6666 if (typeof globalThis === "object") {
6667 globalThis.regeneratorRuntime = runtime;
6668 } else {
6669 Function("r", "regeneratorRuntime = r")(runtime);
6670 }
6671 }
6672
6673
6674 /***/ }),
6675
6676 /***/ "../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js":
6677 /*!******************************************************************!*\
6678 !*** ../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js ***!
6679 \******************************************************************/
6680 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
6681
6682 "use strict";
6683 __webpack_require__.r(__webpack_exports__);
6684 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
6685 /* harmony export */ EnhancerArray: () => (/* binding */ EnhancerArray),
6686 /* harmony export */ MiddlewareArray: () => (/* binding */ MiddlewareArray),
6687 /* harmony export */ SHOULD_AUTOBATCH: () => (/* binding */ SHOULD_AUTOBATCH),
6688 /* harmony export */ TaskAbortError: () => (/* binding */ TaskAbortError),
6689 /* harmony export */ __DO_NOT_USE__ActionTypes: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.__DO_NOT_USE__ActionTypes),
6690 /* harmony export */ addListener: () => (/* binding */ addListener),
6691 /* harmony export */ applyMiddleware: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.applyMiddleware),
6692 /* harmony export */ autoBatchEnhancer: () => (/* binding */ autoBatchEnhancer),
6693 /* harmony export */ bindActionCreators: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.bindActionCreators),
6694 /* harmony export */ clearAllListeners: () => (/* binding */ clearAllListeners),
6695 /* harmony export */ combineReducers: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.combineReducers),
6696 /* harmony export */ compose: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.compose),
6697 /* harmony export */ configureStore: () => (/* binding */ configureStore),
6698 /* harmony export */ createAction: () => (/* binding */ createAction),
6699 /* harmony export */ createActionCreatorInvariantMiddleware: () => (/* binding */ createActionCreatorInvariantMiddleware),
6700 /* harmony export */ createAsyncThunk: () => (/* binding */ createAsyncThunk),
6701 /* harmony export */ createDraftSafeSelector: () => (/* binding */ createDraftSafeSelector),
6702 /* harmony export */ createEntityAdapter: () => (/* binding */ createEntityAdapter),
6703 /* harmony export */ createImmutableStateInvariantMiddleware: () => (/* binding */ createImmutableStateInvariantMiddleware),
6704 /* harmony export */ createListenerMiddleware: () => (/* binding */ createListenerMiddleware),
6705 /* harmony export */ createNextState: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__["default"]),
6706 /* harmony export */ createReducer: () => (/* binding */ createReducer),
6707 /* harmony export */ createSelector: () => (/* reexport safe */ reselect__WEBPACK_IMPORTED_MODULE_2__.createSelector),
6708 /* harmony export */ createSerializableStateInvariantMiddleware: () => (/* binding */ createSerializableStateInvariantMiddleware),
6709 /* harmony export */ createSlice: () => (/* binding */ createSlice),
6710 /* harmony export */ createStore: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.createStore),
6711 /* harmony export */ current: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.current),
6712 /* harmony export */ findNonSerializableValue: () => (/* binding */ findNonSerializableValue),
6713 /* harmony export */ freeze: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.freeze),
6714 /* harmony export */ getDefaultMiddleware: () => (/* binding */ getDefaultMiddleware),
6715 /* harmony export */ getType: () => (/* binding */ getType),
6716 /* harmony export */ isAction: () => (/* binding */ isAction),
6717 /* harmony export */ isActionCreator: () => (/* binding */ isActionCreator),
6718 /* harmony export */ isAllOf: () => (/* binding */ isAllOf),
6719 /* harmony export */ isAnyOf: () => (/* binding */ isAnyOf),
6720 /* harmony export */ isAsyncThunkAction: () => (/* binding */ isAsyncThunkAction),
6721 /* harmony export */ isDraft: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.isDraft),
6722 /* harmony export */ isFluxStandardAction: () => (/* binding */ isFSA),
6723 /* harmony export */ isFulfilled: () => (/* binding */ isFulfilled),
6724 /* harmony export */ isImmutableDefault: () => (/* binding */ isImmutableDefault),
6725 /* harmony export */ isPending: () => (/* binding */ isPending),
6726 /* harmony export */ isPlain: () => (/* binding */ isPlain),
6727 /* harmony export */ isPlainObject: () => (/* binding */ isPlainObject),
6728 /* harmony export */ isRejected: () => (/* binding */ isRejected),
6729 /* harmony export */ isRejectedWithValue: () => (/* binding */ isRejectedWithValue),
6730 /* harmony export */ legacy_createStore: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.legacy_createStore),
6731 /* harmony export */ miniSerializeError: () => (/* binding */ miniSerializeError),
6732 /* harmony export */ nanoid: () => (/* binding */ nanoid),
6733 /* harmony export */ original: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.original),
6734 /* harmony export */ prepareAutoBatched: () => (/* binding */ prepareAutoBatched),
6735 /* harmony export */ removeListener: () => (/* binding */ removeListener),
6736 /* harmony export */ unwrapResult: () => (/* binding */ unwrapResult)
6737 /* harmony export */ });
6738 /* harmony import */ var immer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! immer */ "../node_modules/immer/dist/immer.esm.mjs");
6739 /* harmony import */ var redux__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! redux */ "../node_modules/redux/es/redux.js");
6740 /* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! reselect */ "../node_modules/reselect/es/index.js");
6741 /* harmony import */ var redux_thunk__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! redux-thunk */ "../node_modules/redux-thunk/es/index.js");
6742 var __extends = (undefined && undefined.__extends) || (function () {
6743 var extendStatics = function (d, b) {
6744 extendStatics = Object.setPrototypeOf ||
6745 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6746 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6747 return extendStatics(d, b);
6748 };
6749 return function (d, b) {
6750 if (typeof b !== "function" && b !== null)
6751 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
6752 extendStatics(d, b);
6753 function __() { this.constructor = d; }
6754 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6755 };
6756 })();
6757 var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
6758 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
6759 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
6760 function verb(n) { return function (v) { return step([n, v]); }; }
6761 function step(op) {
6762 if (f) throw new TypeError("Generator is already executing.");
6763 while (_) try {
6764 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;
6765 if (y = 0, t) op = [op[0] & 2, t.value];
6766 switch (op[0]) {
6767 case 0: case 1: t = op; break;
6768 case 4: _.label++; return { value: op[1], done: false };
6769 case 5: _.label++; y = op[1]; op = [0]; continue;
6770 case 7: op = _.ops.pop(); _.trys.pop(); continue;
6771 default:
6772 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
6773 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
6774 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
6775 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
6776 if (t[2]) _.ops.pop();
6777 _.trys.pop(); continue;
6778 }
6779 op = body.call(thisArg, _);
6780 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
6781 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
6782 }
6783 };
6784 var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
6785 for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
6786 to[j] = from[i];
6787 return to;
6788 };
6789 var __defProp = Object.defineProperty;
6790 var __defProps = Object.defineProperties;
6791 var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6792 var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6793 var __hasOwnProp = Object.prototype.hasOwnProperty;
6794 var __propIsEnum = Object.prototype.propertyIsEnumerable;
6795 var __defNormalProp = function (obj, key, value) { return key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value }) : obj[key] = value; };
6796 var __spreadValues = function (a, b) {
6797 for (var prop in b || (b = {}))
6798 if (__hasOwnProp.call(b, prop))
6799 __defNormalProp(a, prop, b[prop]);
6800 if (__getOwnPropSymbols)
6801 for (var _i = 0, _c = __getOwnPropSymbols(b); _i < _c.length; _i++) {
6802 var prop = _c[_i];
6803 if (__propIsEnum.call(b, prop))
6804 __defNormalProp(a, prop, b[prop]);
6805 }
6806 return a;
6807 };
6808 var __spreadProps = function (a, b) { return __defProps(a, __getOwnPropDescs(b)); };
6809 var __async = function (__this, __arguments, generator) {
6810 return new Promise(function (resolve, reject) {
6811 var fulfilled = function (value) {
6812 try {
6813 step(generator.next(value));
6814 }
6815 catch (e) {
6816 reject(e);
6817 }
6818 };
6819 var rejected = function (value) {
6820 try {
6821 step(generator.throw(value));
6822 }
6823 catch (e) {
6824 reject(e);
6825 }
6826 };
6827 var step = function (x) { return x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); };
6828 step((generator = generator.apply(__this, __arguments)).next());
6829 });
6830 };
6831 // src/index.ts
6832
6833
6834
6835
6836 // src/createDraftSafeSelector.ts
6837
6838
6839 var createDraftSafeSelector = function () {
6840 var args = [];
6841 for (var _i = 0; _i < arguments.length; _i++) {
6842 args[_i] = arguments[_i];
6843 }
6844 var selector = reselect__WEBPACK_IMPORTED_MODULE_2__.createSelector.apply(void 0, args);
6845 var wrappedSelector = function (value) {
6846 var rest = [];
6847 for (var _i = 1; _i < arguments.length; _i++) {
6848 rest[_i - 1] = arguments[_i];
6849 }
6850 return selector.apply(void 0, __spreadArray([(0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(value) ? (0,immer__WEBPACK_IMPORTED_MODULE_0__.current)(value) : value], rest));
6851 };
6852 return wrappedSelector;
6853 };
6854 // src/configureStore.ts
6855
6856 // src/devtoolsExtension.ts
6857
6858 var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function () {
6859 if (arguments.length === 0)
6860 return void 0;
6861 if (typeof arguments[0] === "object")
6862 return redux__WEBPACK_IMPORTED_MODULE_1__.compose;
6863 return redux__WEBPACK_IMPORTED_MODULE_1__.compose.apply(null, arguments);
6864 };
6865 var devToolsEnhancer = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__ : function () {
6866 return function (noop2) {
6867 return noop2;
6868 };
6869 };
6870 // src/isPlainObject.ts
6871 function isPlainObject(value) {
6872 if (typeof value !== "object" || value === null)
6873 return false;
6874 var proto = Object.getPrototypeOf(value);
6875 if (proto === null)
6876 return true;
6877 var baseProto = proto;
6878 while (Object.getPrototypeOf(baseProto) !== null) {
6879 baseProto = Object.getPrototypeOf(baseProto);
6880 }
6881 return proto === baseProto;
6882 }
6883 // src/getDefaultMiddleware.ts
6884
6885 // src/tsHelpers.ts
6886 var hasMatchFunction = function (v) {
6887 return v && typeof v.match === "function";
6888 };
6889 // src/createAction.ts
6890 function createAction(type, prepareAction) {
6891 function actionCreator() {
6892 var args = [];
6893 for (var _i = 0; _i < arguments.length; _i++) {
6894 args[_i] = arguments[_i];
6895 }
6896 if (prepareAction) {
6897 var prepared = prepareAction.apply(void 0, args);
6898 if (!prepared) {
6899 throw new Error("prepareAction did not return an object");
6900 }
6901 return __spreadValues(__spreadValues({
6902 type: type,
6903 payload: prepared.payload
6904 }, "meta" in prepared && { meta: prepared.meta }), "error" in prepared && { error: prepared.error });
6905 }
6906 return { type: type, payload: args[0] };
6907 }
6908 actionCreator.toString = function () { return "" + type; };
6909 actionCreator.type = type;
6910 actionCreator.match = function (action) { return action.type === type; };
6911 return actionCreator;
6912 }
6913 function isAction(action) {
6914 return isPlainObject(action) && "type" in action;
6915 }
6916 function isActionCreator(action) {
6917 return typeof action === "function" && "type" in action && hasMatchFunction(action);
6918 }
6919 function isFSA(action) {
6920 return isAction(action) && typeof action.type === "string" && Object.keys(action).every(isValidKey);
6921 }
6922 function isValidKey(key) {
6923 return ["type", "payload", "error", "meta"].indexOf(key) > -1;
6924 }
6925 function getType(actionCreator) {
6926 return "" + actionCreator;
6927 }
6928 // src/actionCreatorInvariantMiddleware.ts
6929 function getMessage(type) {
6930 var splitType = type ? ("" + type).split("/") : [];
6931 var actionName = splitType[splitType.length - 1] || "actionCreator";
6932 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.";
6933 }
6934 function createActionCreatorInvariantMiddleware(options) {
6935 if (options === void 0) { options = {}; }
6936 if (false) // removed by dead control flow
6937 {}
6938 var _c = options.isActionCreator, isActionCreator2 = _c === void 0 ? isActionCreator : _c;
6939 return function () { return function (next) { return function (action) {
6940 if (isActionCreator2(action)) {
6941 console.warn(getMessage(action.type));
6942 }
6943 return next(action);
6944 }; }; };
6945 }
6946 // src/utils.ts
6947
6948 function getTimeMeasureUtils(maxDelay, fnName) {
6949 var elapsed = 0;
6950 return {
6951 measureTime: function (fn) {
6952 var started = Date.now();
6953 try {
6954 return fn();
6955 }
6956 finally {
6957 var finished = Date.now();
6958 elapsed += finished - started;
6959 }
6960 },
6961 warnIfExceeded: function () {
6962 if (elapsed > maxDelay) {
6963 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.");
6964 }
6965 }
6966 };
6967 }
6968 var MiddlewareArray = /** @class */ (function (_super) {
6969 __extends(MiddlewareArray, _super);
6970 function MiddlewareArray() {
6971 var args = [];
6972 for (var _i = 0; _i < arguments.length; _i++) {
6973 args[_i] = arguments[_i];
6974 }
6975 var _this = _super.apply(this, args) || this;
6976 Object.setPrototypeOf(_this, MiddlewareArray.prototype);
6977 return _this;
6978 }
6979 Object.defineProperty(MiddlewareArray, Symbol.species, {
6980 get: function () {
6981 return MiddlewareArray;
6982 },
6983 enumerable: false,
6984 configurable: true
6985 });
6986 MiddlewareArray.prototype.concat = function () {
6987 var arr = [];
6988 for (var _i = 0; _i < arguments.length; _i++) {
6989 arr[_i] = arguments[_i];
6990 }
6991 return _super.prototype.concat.apply(this, arr);
6992 };
6993 MiddlewareArray.prototype.prepend = function () {
6994 var arr = [];
6995 for (var _i = 0; _i < arguments.length; _i++) {
6996 arr[_i] = arguments[_i];
6997 }
6998 if (arr.length === 1 && Array.isArray(arr[0])) {
6999 return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr[0].concat(this))))();
7000 }
7001 return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr.concat(this))))();
7002 };
7003 return MiddlewareArray;
7004 }(Array));
7005 var EnhancerArray = /** @class */ (function (_super) {
7006 __extends(EnhancerArray, _super);
7007 function EnhancerArray() {
7008 var args = [];
7009 for (var _i = 0; _i < arguments.length; _i++) {
7010 args[_i] = arguments[_i];
7011 }
7012 var _this = _super.apply(this, args) || this;
7013 Object.setPrototypeOf(_this, EnhancerArray.prototype);
7014 return _this;
7015 }
7016 Object.defineProperty(EnhancerArray, Symbol.species, {
7017 get: function () {
7018 return EnhancerArray;
7019 },
7020 enumerable: false,
7021 configurable: true
7022 });
7023 EnhancerArray.prototype.concat = function () {
7024 var arr = [];
7025 for (var _i = 0; _i < arguments.length; _i++) {
7026 arr[_i] = arguments[_i];
7027 }
7028 return _super.prototype.concat.apply(this, arr);
7029 };
7030 EnhancerArray.prototype.prepend = function () {
7031 var arr = [];
7032 for (var _i = 0; _i < arguments.length; _i++) {
7033 arr[_i] = arguments[_i];
7034 }
7035 if (arr.length === 1 && Array.isArray(arr[0])) {
7036 return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr[0].concat(this))))();
7037 }
7038 return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr.concat(this))))();
7039 };
7040 return EnhancerArray;
7041 }(Array));
7042 function freezeDraftable(val) {
7043 return (0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraftable)(val) ? (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(val, function () {
7044 }) : val;
7045 }
7046 // src/immutableStateInvariantMiddleware.ts
7047 var isProduction = "development" === "production";
7048 var prefix = "Invariant failed";
7049 function invariant(condition, message) {
7050 if (condition) {
7051 return;
7052 }
7053 if (isProduction) {
7054 throw new Error(prefix);
7055 }
7056 throw new Error(prefix + ": " + (message || ""));
7057 }
7058 function stringify(obj, serializer, indent, decycler) {
7059 return JSON.stringify(obj, getSerialize(serializer, decycler), indent);
7060 }
7061 function getSerialize(serializer, decycler) {
7062 var stack = [], keys = [];
7063 if (!decycler)
7064 decycler = function (_, value) {
7065 if (stack[0] === value)
7066 return "[Circular ~]";
7067 return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
7068 };
7069 return function (key, value) {
7070 if (stack.length > 0) {
7071 var thisPos = stack.indexOf(this);
7072 ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
7073 ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
7074 if (~stack.indexOf(value))
7075 value = decycler.call(this, key, value);
7076 }
7077 else
7078 stack.push(value);
7079 return serializer == null ? value : serializer.call(this, key, value);
7080 };
7081 }
7082 function isImmutableDefault(value) {
7083 return typeof value !== "object" || value == null || Object.isFrozen(value);
7084 }
7085 function trackForMutations(isImmutable, ignorePaths, obj) {
7086 var trackedProperties = trackProperties(isImmutable, ignorePaths, obj);
7087 return {
7088 detectMutations: function () {
7089 return detectMutations(isImmutable, ignorePaths, trackedProperties, obj);
7090 }
7091 };
7092 }
7093 function trackProperties(isImmutable, ignorePaths, obj, path, checkedObjects) {
7094 if (ignorePaths === void 0) { ignorePaths = []; }
7095 if (path === void 0) { path = ""; }
7096 if (checkedObjects === void 0) { checkedObjects = new Set(); }
7097 var tracked = { value: obj };
7098 if (!isImmutable(obj) && !checkedObjects.has(obj)) {
7099 checkedObjects.add(obj);
7100 tracked.children = {};
7101 for (var key in obj) {
7102 var childPath = path ? path + "." + key : key;
7103 if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
7104 continue;
7105 }
7106 tracked.children[key] = trackProperties(isImmutable, ignorePaths, obj[key], childPath);
7107 }
7108 }
7109 return tracked;
7110 }
7111 function detectMutations(isImmutable, ignoredPaths, trackedProperty, obj, sameParentRef, path) {
7112 if (ignoredPaths === void 0) { ignoredPaths = []; }
7113 if (sameParentRef === void 0) { sameParentRef = false; }
7114 if (path === void 0) { path = ""; }
7115 var prevObj = trackedProperty ? trackedProperty.value : void 0;
7116 var sameRef = prevObj === obj;
7117 if (sameParentRef && !sameRef && !Number.isNaN(obj)) {
7118 return { wasMutated: true, path: path };
7119 }
7120 if (isImmutable(prevObj) || isImmutable(obj)) {
7121 return { wasMutated: false };
7122 }
7123 var keysToDetect = {};
7124 for (var key in trackedProperty.children) {
7125 keysToDetect[key] = true;
7126 }
7127 for (var key in obj) {
7128 keysToDetect[key] = true;
7129 }
7130 var hasIgnoredPaths = ignoredPaths.length > 0;
7131 var _loop_1 = function (key) {
7132 var nestedPath = path ? path + "." + key : key;
7133 if (hasIgnoredPaths) {
7134 var hasMatches = ignoredPaths.some(function (ignored) {
7135 if (ignored instanceof RegExp) {
7136 return ignored.test(nestedPath);
7137 }
7138 return nestedPath === ignored;
7139 });
7140 if (hasMatches) {
7141 return "continue";
7142 }
7143 }
7144 var result = detectMutations(isImmutable, ignoredPaths, trackedProperty.children[key], obj[key], sameRef, nestedPath);
7145 if (result.wasMutated) {
7146 return { value: result };
7147 }
7148 };
7149 for (var key in keysToDetect) {
7150 var state_1 = _loop_1(key);
7151 if (typeof state_1 === "object")
7152 return state_1.value;
7153 }
7154 return { wasMutated: false };
7155 }
7156 function createImmutableStateInvariantMiddleware(options) {
7157 if (options === void 0) { options = {}; }
7158 if (false) // removed by dead control flow
7159 {}
7160 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;
7161 ignoredPaths = ignoredPaths || ignore;
7162 var track = trackForMutations.bind(null, isImmutable, ignoredPaths);
7163 return function (_c) {
7164 var getState = _c.getState;
7165 var state = getState();
7166 var tracker = track(state);
7167 var result;
7168 return function (next) { return function (action) {
7169 var measureUtils = getTimeMeasureUtils(warnAfter, "ImmutableStateInvariantMiddleware");
7170 measureUtils.measureTime(function () {
7171 state = getState();
7172 result = tracker.detectMutations();
7173 tracker = track(state);
7174 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)");
7175 });
7176 var dispatchedAction = next(action);
7177 measureUtils.measureTime(function () {
7178 state = getState();
7179 result = tracker.detectMutations();
7180 tracker = track(state);
7181 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)");
7182 });
7183 measureUtils.warnIfExceeded();
7184 return dispatchedAction;
7185 }; };
7186 };
7187 }
7188 // src/serializableStateInvariantMiddleware.ts
7189 function isPlain(val) {
7190 var type = typeof val;
7191 return val == null || type === "string" || type === "boolean" || type === "number" || Array.isArray(val) || isPlainObject(val);
7192 }
7193 function findNonSerializableValue(value, path, isSerializable, getEntries, ignoredPaths, cache) {
7194 if (path === void 0) { path = ""; }
7195 if (isSerializable === void 0) { isSerializable = isPlain; }
7196 if (ignoredPaths === void 0) { ignoredPaths = []; }
7197 var foundNestedSerializable;
7198 if (!isSerializable(value)) {
7199 return {
7200 keyPath: path || "<root>",
7201 value: value
7202 };
7203 }
7204 if (typeof value !== "object" || value === null) {
7205 return false;
7206 }
7207 if (cache == null ? void 0 : cache.has(value))
7208 return false;
7209 var entries = getEntries != null ? getEntries(value) : Object.entries(value);
7210 var hasIgnoredPaths = ignoredPaths.length > 0;
7211 var _loop_2 = function (key, nestedValue) {
7212 var nestedPath = path ? path + "." + key : key;
7213 if (hasIgnoredPaths) {
7214 var hasMatches = ignoredPaths.some(function (ignored) {
7215 if (ignored instanceof RegExp) {
7216 return ignored.test(nestedPath);
7217 }
7218 return nestedPath === ignored;
7219 });
7220 if (hasMatches) {
7221 return "continue";
7222 }
7223 }
7224 if (!isSerializable(nestedValue)) {
7225 return { value: {
7226 keyPath: nestedPath,
7227 value: nestedValue
7228 } };
7229 }
7230 if (typeof nestedValue === "object") {
7231 foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths, cache);
7232 if (foundNestedSerializable) {
7233 return { value: foundNestedSerializable };
7234 }
7235 }
7236 };
7237 for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
7238 var _c = entries_1[_i], key = _c[0], nestedValue = _c[1];
7239 var state_2 = _loop_2(key, nestedValue);
7240 if (typeof state_2 === "object")
7241 return state_2.value;
7242 }
7243 if (cache && isNestedFrozen(value))
7244 cache.add(value);
7245 return false;
7246 }
7247 function isNestedFrozen(value) {
7248 if (!Object.isFrozen(value))
7249 return false;
7250 for (var _i = 0, _c = Object.values(value); _i < _c.length; _i++) {
7251 var nestedValue = _c[_i];
7252 if (typeof nestedValue !== "object" || nestedValue === null)
7253 continue;
7254 if (!isNestedFrozen(nestedValue))
7255 return false;
7256 }
7257 return true;
7258 }
7259 function createSerializableStateInvariantMiddleware(options) {
7260 if (options === void 0) { options = {}; }
7261 if (false) // removed by dead control flow
7262 {}
7263 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;
7264 var cache = !disableCache && WeakSet ? new WeakSet() : void 0;
7265 return function (storeAPI) { return function (next) { return function (action) {
7266 var result = next(action);
7267 var measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware");
7268 if (!ignoreActions && !(ignoredActions.length && ignoredActions.indexOf(action.type) !== -1)) {
7269 measureUtils.measureTime(function () {
7270 var foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths, cache);
7271 if (foundActionNonSerializableValue) {
7272 var keyPath = foundActionNonSerializableValue.keyPath, value = foundActionNonSerializableValue.value;
7273 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)");
7274 }
7275 });
7276 }
7277 if (!ignoreState) {
7278 measureUtils.measureTime(function () {
7279 var state = storeAPI.getState();
7280 var foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths, cache);
7281 if (foundStateNonSerializableValue) {
7282 var keyPath = foundStateNonSerializableValue.keyPath, value = foundStateNonSerializableValue.value;
7283 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)");
7284 }
7285 });
7286 measureUtils.warnIfExceeded();
7287 }
7288 return result;
7289 }; }; };
7290 }
7291 // src/getDefaultMiddleware.ts
7292 function isBoolean(x) {
7293 return typeof x === "boolean";
7294 }
7295 function curryGetDefaultMiddleware() {
7296 return function curriedGetDefaultMiddleware(options) {
7297 return getDefaultMiddleware(options);
7298 };
7299 }
7300 function getDefaultMiddleware(options) {
7301 if (options === void 0) { options = {}; }
7302 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;
7303 var middlewareArray = new MiddlewareArray();
7304 if (thunk) {
7305 if (isBoolean(thunk)) {
7306 middlewareArray.push(redux_thunk__WEBPACK_IMPORTED_MODULE_3__["default"]);
7307 }
7308 else {
7309 middlewareArray.push(redux_thunk__WEBPACK_IMPORTED_MODULE_3__["default"].withExtraArgument(thunk.extraArgument));
7310 }
7311 }
7312 if (true) {
7313 if (immutableCheck) {
7314 var immutableOptions = {};
7315 if (!isBoolean(immutableCheck)) {
7316 immutableOptions = immutableCheck;
7317 }
7318 middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));
7319 }
7320 if (serializableCheck) {
7321 var serializableOptions = {};
7322 if (!isBoolean(serializableCheck)) {
7323 serializableOptions = serializableCheck;
7324 }
7325 middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions));
7326 }
7327 if (actionCreatorCheck) {
7328 var actionCreatorOptions = {};
7329 if (!isBoolean(actionCreatorCheck)) {
7330 actionCreatorOptions = actionCreatorCheck;
7331 }
7332 middlewareArray.unshift(createActionCreatorInvariantMiddleware(actionCreatorOptions));
7333 }
7334 }
7335 return middlewareArray;
7336 }
7337 // src/configureStore.ts
7338 var IS_PRODUCTION = "development" === "production";
7339 function configureStore(options) {
7340 var curriedGetDefaultMiddleware = curryGetDefaultMiddleware();
7341 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;
7342 var rootReducer;
7343 if (typeof reducer === "function") {
7344 rootReducer = reducer;
7345 }
7346 else if (isPlainObject(reducer)) {
7347 rootReducer = (0,redux__WEBPACK_IMPORTED_MODULE_1__.combineReducers)(reducer);
7348 }
7349 else {
7350 throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');
7351 }
7352 var finalMiddleware = middleware;
7353 if (typeof finalMiddleware === "function") {
7354 finalMiddleware = finalMiddleware(curriedGetDefaultMiddleware);
7355 if (!IS_PRODUCTION && !Array.isArray(finalMiddleware)) {
7356 throw new Error("when using a middleware builder function, an array of middleware must be returned");
7357 }
7358 }
7359 if (!IS_PRODUCTION && finalMiddleware.some(function (item) { return typeof item !== "function"; })) {
7360 throw new Error("each middleware provided to configureStore must be a function");
7361 }
7362 var middlewareEnhancer = redux__WEBPACK_IMPORTED_MODULE_1__.applyMiddleware.apply(void 0, finalMiddleware);
7363 var finalCompose = redux__WEBPACK_IMPORTED_MODULE_1__.compose;
7364 if (devTools) {
7365 finalCompose = composeWithDevTools(__spreadValues({
7366 trace: !IS_PRODUCTION
7367 }, typeof devTools === "object" && devTools));
7368 }
7369 var defaultEnhancers = new EnhancerArray(middlewareEnhancer);
7370 var storeEnhancers = defaultEnhancers;
7371 if (Array.isArray(enhancers)) {
7372 storeEnhancers = __spreadArray([middlewareEnhancer], enhancers);
7373 }
7374 else if (typeof enhancers === "function") {
7375 storeEnhancers = enhancers(defaultEnhancers);
7376 }
7377 var composedEnhancer = finalCompose.apply(void 0, storeEnhancers);
7378 return (0,redux__WEBPACK_IMPORTED_MODULE_1__.createStore)(rootReducer, preloadedState, composedEnhancer);
7379 }
7380 // src/createReducer.ts
7381
7382 // src/mapBuilders.ts
7383 function executeReducerBuilderCallback(builderCallback) {
7384 var actionsMap = {};
7385 var actionMatchers = [];
7386 var defaultCaseReducer;
7387 var builder = {
7388 addCase: function (typeOrActionCreator, reducer) {
7389 if (true) {
7390 if (actionMatchers.length > 0) {
7391 throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");
7392 }
7393 if (defaultCaseReducer) {
7394 throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");
7395 }
7396 }
7397 var type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
7398 if (!type) {
7399 throw new Error("`builder.addCase` cannot be called with an empty action type");
7400 }
7401 if (type in actionsMap) {
7402 throw new Error("`builder.addCase` cannot be called with two reducers for the same action type");
7403 }
7404 actionsMap[type] = reducer;
7405 return builder;
7406 },
7407 addMatcher: function (matcher, reducer) {
7408 if (true) {
7409 if (defaultCaseReducer) {
7410 throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");
7411 }
7412 }
7413 actionMatchers.push({ matcher: matcher, reducer: reducer });
7414 return builder;
7415 },
7416 addDefaultCase: function (reducer) {
7417 if (true) {
7418 if (defaultCaseReducer) {
7419 throw new Error("`builder.addDefaultCase` can only be called once");
7420 }
7421 }
7422 defaultCaseReducer = reducer;
7423 return builder;
7424 }
7425 };
7426 builderCallback(builder);
7427 return [actionsMap, actionMatchers, defaultCaseReducer];
7428 }
7429 // src/createReducer.ts
7430 function isStateFunction(x) {
7431 return typeof x === "function";
7432 }
7433 var hasWarnedAboutObjectNotation = false;
7434 function createReducer(initialState, mapOrBuilderCallback, actionMatchers, defaultCaseReducer) {
7435 if (actionMatchers === void 0) { actionMatchers = []; }
7436 if (true) {
7437 if (typeof mapOrBuilderCallback === "object") {
7438 if (!hasWarnedAboutObjectNotation) {
7439 hasWarnedAboutObjectNotation = true;
7440 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");
7441 }
7442 }
7443 }
7444 var _c = typeof mapOrBuilderCallback === "function" ? executeReducerBuilderCallback(mapOrBuilderCallback) : [mapOrBuilderCallback, actionMatchers, defaultCaseReducer], actionsMap = _c[0], finalActionMatchers = _c[1], finalDefaultCaseReducer = _c[2];
7445 var getInitialState;
7446 if (isStateFunction(initialState)) {
7447 getInitialState = function () { return freezeDraftable(initialState()); };
7448 }
7449 else {
7450 var frozenInitialState_1 = freezeDraftable(initialState);
7451 getInitialState = function () { return frozenInitialState_1; };
7452 }
7453 function reducer(state, action) {
7454 if (state === void 0) { state = getInitialState(); }
7455 var caseReducers = __spreadArray([
7456 actionsMap[action.type]
7457 ], finalActionMatchers.filter(function (_c) {
7458 var matcher = _c.matcher;
7459 return matcher(action);
7460 }).map(function (_c) {
7461 var reducer2 = _c.reducer;
7462 return reducer2;
7463 }));
7464 if (caseReducers.filter(function (cr) { return !!cr; }).length === 0) {
7465 caseReducers = [finalDefaultCaseReducer];
7466 }
7467 return caseReducers.reduce(function (previousState, caseReducer) {
7468 if (caseReducer) {
7469 if ((0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(previousState)) {
7470 var draft = previousState;
7471 var result = caseReducer(draft, action);
7472 if (result === void 0) {
7473 return previousState;
7474 }
7475 return result;
7476 }
7477 else if (!(0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraftable)(previousState)) {
7478 var result = caseReducer(previousState, action);
7479 if (result === void 0) {
7480 if (previousState === null) {
7481 return previousState;
7482 }
7483 throw Error("A case reducer on a non-draftable value must not return undefined");
7484 }
7485 return result;
7486 }
7487 else {
7488 return (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(previousState, function (draft) {
7489 return caseReducer(draft, action);
7490 });
7491 }
7492 }
7493 return previousState;
7494 }, state);
7495 }
7496 reducer.getInitialState = getInitialState;
7497 return reducer;
7498 }
7499 // src/createSlice.ts
7500 var hasWarnedAboutObjectNotation2 = false;
7501 function getType2(slice, actionKey) {
7502 return slice + "/" + actionKey;
7503 }
7504 function createSlice(options) {
7505 var name = options.name;
7506 if (!name) {
7507 throw new Error("`name` is a required option for createSlice");
7508 }
7509 if (typeof process !== "undefined" && "development" === "development") {
7510 if (options.initialState === void 0) {
7511 console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");
7512 }
7513 }
7514 var initialState = typeof options.initialState == "function" ? options.initialState : freezeDraftable(options.initialState);
7515 var reducers = options.reducers || {};
7516 var reducerNames = Object.keys(reducers);
7517 var sliceCaseReducersByName = {};
7518 var sliceCaseReducersByType = {};
7519 var actionCreators = {};
7520 reducerNames.forEach(function (reducerName) {
7521 var maybeReducerWithPrepare = reducers[reducerName];
7522 var type = getType2(name, reducerName);
7523 var caseReducer;
7524 var prepareCallback;
7525 if ("reducer" in maybeReducerWithPrepare) {
7526 caseReducer = maybeReducerWithPrepare.reducer;
7527 prepareCallback = maybeReducerWithPrepare.prepare;
7528 }
7529 else {
7530 caseReducer = maybeReducerWithPrepare;
7531 }
7532 sliceCaseReducersByName[reducerName] = caseReducer;
7533 sliceCaseReducersByType[type] = caseReducer;
7534 actionCreators[reducerName] = prepareCallback ? createAction(type, prepareCallback) : createAction(type);
7535 });
7536 function buildReducer() {
7537 if (true) {
7538 if (typeof options.extraReducers === "object") {
7539 if (!hasWarnedAboutObjectNotation2) {
7540 hasWarnedAboutObjectNotation2 = true;
7541 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");
7542 }
7543 }
7544 }
7545 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;
7546 var finalCaseReducers = __spreadValues(__spreadValues({}, extraReducers), sliceCaseReducersByType);
7547 return createReducer(initialState, function (builder) {
7548 for (var key in finalCaseReducers) {
7549 builder.addCase(key, finalCaseReducers[key]);
7550 }
7551 for (var _i = 0, actionMatchers_1 = actionMatchers; _i < actionMatchers_1.length; _i++) {
7552 var m = actionMatchers_1[_i];
7553 builder.addMatcher(m.matcher, m.reducer);
7554 }
7555 if (defaultCaseReducer) {
7556 builder.addDefaultCase(defaultCaseReducer);
7557 }
7558 });
7559 }
7560 var _reducer;
7561 return {
7562 name: name,
7563 reducer: function (state, action) {
7564 if (!_reducer)
7565 _reducer = buildReducer();
7566 return _reducer(state, action);
7567 },
7568 actions: actionCreators,
7569 caseReducers: sliceCaseReducersByName,
7570 getInitialState: function () {
7571 if (!_reducer)
7572 _reducer = buildReducer();
7573 return _reducer.getInitialState();
7574 }
7575 };
7576 }
7577 // src/entities/entity_state.ts
7578 function getInitialEntityState() {
7579 return {
7580 ids: [],
7581 entities: {}
7582 };
7583 }
7584 function createInitialStateFactory() {
7585 function getInitialState(additionalState) {
7586 if (additionalState === void 0) { additionalState = {}; }
7587 return Object.assign(getInitialEntityState(), additionalState);
7588 }
7589 return { getInitialState: getInitialState };
7590 }
7591 // src/entities/state_selectors.ts
7592 function createSelectorsFactory() {
7593 function getSelectors(selectState) {
7594 var selectIds = function (state) { return state.ids; };
7595 var selectEntities = function (state) { return state.entities; };
7596 var selectAll = createDraftSafeSelector(selectIds, selectEntities, function (ids, entities) { return ids.map(function (id) { return entities[id]; }); });
7597 var selectId = function (_, id) { return id; };
7598 var selectById = function (entities, id) { return entities[id]; };
7599 var selectTotal = createDraftSafeSelector(selectIds, function (ids) { return ids.length; });
7600 if (!selectState) {
7601 return {
7602 selectIds: selectIds,
7603 selectEntities: selectEntities,
7604 selectAll: selectAll,
7605 selectTotal: selectTotal,
7606 selectById: createDraftSafeSelector(selectEntities, selectId, selectById)
7607 };
7608 }
7609 var selectGlobalizedEntities = createDraftSafeSelector(selectState, selectEntities);
7610 return {
7611 selectIds: createDraftSafeSelector(selectState, selectIds),
7612 selectEntities: selectGlobalizedEntities,
7613 selectAll: createDraftSafeSelector(selectState, selectAll),
7614 selectTotal: createDraftSafeSelector(selectState, selectTotal),
7615 selectById: createDraftSafeSelector(selectGlobalizedEntities, selectId, selectById)
7616 };
7617 }
7618 return { getSelectors: getSelectors };
7619 }
7620 // src/entities/state_adapter.ts
7621
7622 function createSingleArgumentStateOperator(mutator) {
7623 var operator = createStateOperator(function (_, state) { return mutator(state); });
7624 return function operation(state) {
7625 return operator(state, void 0);
7626 };
7627 }
7628 function createStateOperator(mutator) {
7629 return function operation(state, arg) {
7630 function isPayloadActionArgument(arg2) {
7631 return isFSA(arg2);
7632 }
7633 var runMutator = function (draft) {
7634 if (isPayloadActionArgument(arg)) {
7635 mutator(arg.payload, draft);
7636 }
7637 else {
7638 mutator(arg, draft);
7639 }
7640 };
7641 if ((0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(state)) {
7642 runMutator(state);
7643 return state;
7644 }
7645 else {
7646 return (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(state, runMutator);
7647 }
7648 };
7649 }
7650 // src/entities/utils.ts
7651 function selectIdValue(entity, selectId) {
7652 var key = selectId(entity);
7653 if ( true && key === void 0) {
7654 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());
7655 }
7656 return key;
7657 }
7658 function ensureEntitiesArray(entities) {
7659 if (!Array.isArray(entities)) {
7660 entities = Object.values(entities);
7661 }
7662 return entities;
7663 }
7664 function splitAddedUpdatedEntities(newEntities, selectId, state) {
7665 newEntities = ensureEntitiesArray(newEntities);
7666 var added = [];
7667 var updated = [];
7668 for (var _i = 0, newEntities_1 = newEntities; _i < newEntities_1.length; _i++) {
7669 var entity = newEntities_1[_i];
7670 var id = selectIdValue(entity, selectId);
7671 if (id in state.entities) {
7672 updated.push({ id: id, changes: entity });
7673 }
7674 else {
7675 added.push(entity);
7676 }
7677 }
7678 return [added, updated];
7679 }
7680 // src/entities/unsorted_state_adapter.ts
7681 function createUnsortedStateAdapter(selectId) {
7682 function addOneMutably(entity, state) {
7683 var key = selectIdValue(entity, selectId);
7684 if (key in state.entities) {
7685 return;
7686 }
7687 state.ids.push(key);
7688 state.entities[key] = entity;
7689 }
7690 function addManyMutably(newEntities, state) {
7691 newEntities = ensureEntitiesArray(newEntities);
7692 for (var _i = 0, newEntities_2 = newEntities; _i < newEntities_2.length; _i++) {
7693 var entity = newEntities_2[_i];
7694 addOneMutably(entity, state);
7695 }
7696 }
7697 function setOneMutably(entity, state) {
7698 var key = selectIdValue(entity, selectId);
7699 if (!(key in state.entities)) {
7700 state.ids.push(key);
7701 }
7702 state.entities[key] = entity;
7703 }
7704 function setManyMutably(newEntities, state) {
7705 newEntities = ensureEntitiesArray(newEntities);
7706 for (var _i = 0, newEntities_3 = newEntities; _i < newEntities_3.length; _i++) {
7707 var entity = newEntities_3[_i];
7708 setOneMutably(entity, state);
7709 }
7710 }
7711 function setAllMutably(newEntities, state) {
7712 newEntities = ensureEntitiesArray(newEntities);
7713 state.ids = [];
7714 state.entities = {};
7715 addManyMutably(newEntities, state);
7716 }
7717 function removeOneMutably(key, state) {
7718 return removeManyMutably([key], state);
7719 }
7720 function removeManyMutably(keys, state) {
7721 var didMutate = false;
7722 keys.forEach(function (key) {
7723 if (key in state.entities) {
7724 delete state.entities[key];
7725 didMutate = true;
7726 }
7727 });
7728 if (didMutate) {
7729 state.ids = state.ids.filter(function (id) { return id in state.entities; });
7730 }
7731 }
7732 function removeAllMutably(state) {
7733 Object.assign(state, {
7734 ids: [],
7735 entities: {}
7736 });
7737 }
7738 function takeNewKey(keys, update, state) {
7739 var original2 = state.entities[update.id];
7740 var updated = Object.assign({}, original2, update.changes);
7741 var newKey = selectIdValue(updated, selectId);
7742 var hasNewKey = newKey !== update.id;
7743 if (hasNewKey) {
7744 keys[update.id] = newKey;
7745 delete state.entities[update.id];
7746 }
7747 state.entities[newKey] = updated;
7748 return hasNewKey;
7749 }
7750 function updateOneMutably(update, state) {
7751 return updateManyMutably([update], state);
7752 }
7753 function updateManyMutably(updates, state) {
7754 var newKeys = {};
7755 var updatesPerEntity = {};
7756 updates.forEach(function (update) {
7757 if (update.id in state.entities) {
7758 updatesPerEntity[update.id] = {
7759 id: update.id,
7760 changes: __spreadValues(__spreadValues({}, updatesPerEntity[update.id] ? updatesPerEntity[update.id].changes : null), update.changes)
7761 };
7762 }
7763 });
7764 updates = Object.values(updatesPerEntity);
7765 var didMutateEntities = updates.length > 0;
7766 if (didMutateEntities) {
7767 var didMutateIds = updates.filter(function (update) { return takeNewKey(newKeys, update, state); }).length > 0;
7768 if (didMutateIds) {
7769 state.ids = Object.keys(state.entities);
7770 }
7771 }
7772 }
7773 function upsertOneMutably(entity, state) {
7774 return upsertManyMutably([entity], state);
7775 }
7776 function upsertManyMutably(newEntities, state) {
7777 var _c = splitAddedUpdatedEntities(newEntities, selectId, state), added = _c[0], updated = _c[1];
7778 updateManyMutably(updated, state);
7779 addManyMutably(added, state);
7780 }
7781 return {
7782 removeAll: createSingleArgumentStateOperator(removeAllMutably),
7783 addOne: createStateOperator(addOneMutably),
7784 addMany: createStateOperator(addManyMutably),
7785 setOne: createStateOperator(setOneMutably),
7786 setMany: createStateOperator(setManyMutably),
7787 setAll: createStateOperator(setAllMutably),
7788 updateOne: createStateOperator(updateOneMutably),
7789 updateMany: createStateOperator(updateManyMutably),
7790 upsertOne: createStateOperator(upsertOneMutably),
7791 upsertMany: createStateOperator(upsertManyMutably),
7792 removeOne: createStateOperator(removeOneMutably),
7793 removeMany: createStateOperator(removeManyMutably)
7794 };
7795 }
7796 // src/entities/sorted_state_adapter.ts
7797 function createSortedStateAdapter(selectId, sort) {
7798 var _c = createUnsortedStateAdapter(selectId), removeOne = _c.removeOne, removeMany = _c.removeMany, removeAll = _c.removeAll;
7799 function addOneMutably(entity, state) {
7800 return addManyMutably([entity], state);
7801 }
7802 function addManyMutably(newEntities, state) {
7803 newEntities = ensureEntitiesArray(newEntities);
7804 var models = newEntities.filter(function (model) { return !(selectIdValue(model, selectId) in state.entities); });
7805 if (models.length !== 0) {
7806 merge(models, state);
7807 }
7808 }
7809 function setOneMutably(entity, state) {
7810 return setManyMutably([entity], state);
7811 }
7812 function setManyMutably(newEntities, state) {
7813 newEntities = ensureEntitiesArray(newEntities);
7814 if (newEntities.length !== 0) {
7815 merge(newEntities, state);
7816 }
7817 }
7818 function setAllMutably(newEntities, state) {
7819 newEntities = ensureEntitiesArray(newEntities);
7820 state.entities = {};
7821 state.ids = [];
7822 addManyMutably(newEntities, state);
7823 }
7824 function updateOneMutably(update, state) {
7825 return updateManyMutably([update], state);
7826 }
7827 function updateManyMutably(updates, state) {
7828 var appliedUpdates = false;
7829 for (var _i = 0, updates_1 = updates; _i < updates_1.length; _i++) {
7830 var update = updates_1[_i];
7831 var entity = state.entities[update.id];
7832 if (!entity) {
7833 continue;
7834 }
7835 appliedUpdates = true;
7836 Object.assign(entity, update.changes);
7837 var newId = selectId(entity);
7838 if (update.id !== newId) {
7839 delete state.entities[update.id];
7840 state.entities[newId] = entity;
7841 }
7842 }
7843 if (appliedUpdates) {
7844 resortEntities(state);
7845 }
7846 }
7847 function upsertOneMutably(entity, state) {
7848 return upsertManyMutably([entity], state);
7849 }
7850 function upsertManyMutably(newEntities, state) {
7851 var _c = splitAddedUpdatedEntities(newEntities, selectId, state), added = _c[0], updated = _c[1];
7852 updateManyMutably(updated, state);
7853 addManyMutably(added, state);
7854 }
7855 function areArraysEqual(a, b) {
7856 if (a.length !== b.length) {
7857 return false;
7858 }
7859 for (var i = 0; i < a.length && i < b.length; i++) {
7860 if (a[i] === b[i]) {
7861 continue;
7862 }
7863 return false;
7864 }
7865 return true;
7866 }
7867 function merge(models, state) {
7868 models.forEach(function (model) {
7869 state.entities[selectId(model)] = model;
7870 });
7871 resortEntities(state);
7872 }
7873 function resortEntities(state) {
7874 var allEntities = Object.values(state.entities);
7875 allEntities.sort(sort);
7876 var newSortedIds = allEntities.map(selectId);
7877 var ids = state.ids;
7878 if (!areArraysEqual(ids, newSortedIds)) {
7879 state.ids = newSortedIds;
7880 }
7881 }
7882 return {
7883 removeOne: removeOne,
7884 removeMany: removeMany,
7885 removeAll: removeAll,
7886 addOne: createStateOperator(addOneMutably),
7887 updateOne: createStateOperator(updateOneMutably),
7888 upsertOne: createStateOperator(upsertOneMutably),
7889 setOne: createStateOperator(setOneMutably),
7890 setMany: createStateOperator(setManyMutably),
7891 setAll: createStateOperator(setAllMutably),
7892 addMany: createStateOperator(addManyMutably),
7893 updateMany: createStateOperator(updateManyMutably),
7894 upsertMany: createStateOperator(upsertManyMutably)
7895 };
7896 }
7897 // src/entities/create_adapter.ts
7898 function createEntityAdapter(options) {
7899 if (options === void 0) { options = {}; }
7900 var _c = __spreadValues({
7901 sortComparer: false,
7902 selectId: function (instance) { return instance.id; }
7903 }, options), selectId = _c.selectId, sortComparer = _c.sortComparer;
7904 var stateFactory = createInitialStateFactory();
7905 var selectorsFactory = createSelectorsFactory();
7906 var stateAdapter = sortComparer ? createSortedStateAdapter(selectId, sortComparer) : createUnsortedStateAdapter(selectId);
7907 return __spreadValues(__spreadValues(__spreadValues({
7908 selectId: selectId,
7909 sortComparer: sortComparer
7910 }, stateFactory), selectorsFactory), stateAdapter);
7911 }
7912 // src/nanoid.ts
7913 var urlAlphabet = "ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";
7914 var nanoid = function (size) {
7915 if (size === void 0) { size = 21; }
7916 var id = "";
7917 var i = size;
7918 while (i--) {
7919 id += urlAlphabet[Math.random() * 64 | 0];
7920 }
7921 return id;
7922 };
7923 // src/createAsyncThunk.ts
7924 var commonProperties = [
7925 "name",
7926 "message",
7927 "stack",
7928 "code"
7929 ];
7930 var RejectWithValue = /** @class */ (function () {
7931 function RejectWithValue(payload, meta) {
7932 this.payload = payload;
7933 this.meta = meta;
7934 }
7935 return RejectWithValue;
7936 }());
7937 var FulfillWithMeta = /** @class */ (function () {
7938 function FulfillWithMeta(payload, meta) {
7939 this.payload = payload;
7940 this.meta = meta;
7941 }
7942 return FulfillWithMeta;
7943 }());
7944 var miniSerializeError = function (value) {
7945 if (typeof value === "object" && value !== null) {
7946 var simpleError = {};
7947 for (var _i = 0, commonProperties_1 = commonProperties; _i < commonProperties_1.length; _i++) {
7948 var property = commonProperties_1[_i];
7949 if (typeof value[property] === "string") {
7950 simpleError[property] = value[property];
7951 }
7952 }
7953 return simpleError;
7954 }
7955 return { message: String(value) };
7956 };
7957 var createAsyncThunk = (function () {
7958 function createAsyncThunk2(typePrefix, payloadCreator, options) {
7959 var fulfilled = createAction(typePrefix + "/fulfilled", function (payload, requestId, arg, meta) { return ({
7960 payload: payload,
7961 meta: __spreadProps(__spreadValues({}, meta || {}), {
7962 arg: arg,
7963 requestId: requestId,
7964 requestStatus: "fulfilled"
7965 })
7966 }); });
7967 var pending = createAction(typePrefix + "/pending", function (requestId, arg, meta) { return ({
7968 payload: void 0,
7969 meta: __spreadProps(__spreadValues({}, meta || {}), {
7970 arg: arg,
7971 requestId: requestId,
7972 requestStatus: "pending"
7973 })
7974 }); });
7975 var rejected = createAction(typePrefix + "/rejected", function (error, requestId, arg, payload, meta) { return ({
7976 payload: payload,
7977 error: (options && options.serializeError || miniSerializeError)(error || "Rejected"),
7978 meta: __spreadProps(__spreadValues({}, meta || {}), {
7979 arg: arg,
7980 requestId: requestId,
7981 rejectedWithValue: !!payload,
7982 requestStatus: "rejected",
7983 aborted: (error == null ? void 0 : error.name) === "AbortError",
7984 condition: (error == null ? void 0 : error.name) === "ConditionError"
7985 })
7986 }); });
7987 var displayedWarning = false;
7988 var AC = typeof AbortController !== "undefined" ? AbortController : /** @class */ (function () {
7989 function class_1() {
7990 this.signal = {
7991 aborted: false,
7992 addEventListener: function () {
7993 },
7994 dispatchEvent: function () {
7995 return false;
7996 },
7997 onabort: function () {
7998 },
7999 removeEventListener: function () {
8000 },
8001 reason: void 0,
8002 throwIfAborted: function () {
8003 }
8004 };
8005 }
8006 class_1.prototype.abort = function () {
8007 if (true) {
8008 if (!displayedWarning) {
8009 displayedWarning = true;
8010 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'.");
8011 }
8012 }
8013 };
8014 return class_1;
8015 }());
8016 function actionCreator(arg) {
8017 return function (dispatch, getState, extra) {
8018 var requestId = (options == null ? void 0 : options.idGenerator) ? options.idGenerator(arg) : nanoid();
8019 var abortController = new AC();
8020 var abortReason;
8021 var started = false;
8022 function abort(reason) {
8023 abortReason = reason;
8024 abortController.abort();
8025 }
8026 var promise2 = function () {
8027 return __async(this, null, function () {
8028 var _a, _b, finalAction, conditionResult, abortedPromise, err_1, skipDispatch;
8029 return __generator(this, function (_c) {
8030 switch (_c.label) {
8031 case 0:
8032 _c.trys.push([0, 4, , 5]);
8033 conditionResult = (_a = options == null ? void 0 : options.condition) == null ? void 0 : _a.call(options, arg, { getState: getState, extra: extra });
8034 if (!isThenable(conditionResult)) return [3 /*break*/, 2];
8035 return [4 /*yield*/, conditionResult];
8036 case 1:
8037 conditionResult = _c.sent();
8038 _c.label = 2;
8039 case 2:
8040 if (conditionResult === false || abortController.signal.aborted) {
8041 throw {
8042 name: "ConditionError",
8043 message: "Aborted due to condition callback returning false."
8044 };
8045 }
8046 started = true;
8047 abortedPromise = new Promise(function (_, reject) { return abortController.signal.addEventListener("abort", function () { return reject({
8048 name: "AbortError",
8049 message: abortReason || "Aborted"
8050 }); }); });
8051 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 })));
8052 return [4 /*yield*/, Promise.race([
8053 abortedPromise,
8054 Promise.resolve(payloadCreator(arg, {
8055 dispatch: dispatch,
8056 getState: getState,
8057 extra: extra,
8058 requestId: requestId,
8059 signal: abortController.signal,
8060 abort: abort,
8061 rejectWithValue: function (value, meta) {
8062 return new RejectWithValue(value, meta);
8063 },
8064 fulfillWithValue: function (value, meta) {
8065 return new FulfillWithMeta(value, meta);
8066 }
8067 })).then(function (result) {
8068 if (result instanceof RejectWithValue) {
8069 throw result;
8070 }
8071 if (result instanceof FulfillWithMeta) {
8072 return fulfilled(result.payload, requestId, arg, result.meta);
8073 }
8074 return fulfilled(result, requestId, arg);
8075 })
8076 ])];
8077 case 3:
8078 finalAction = _c.sent();
8079 return [3 /*break*/, 5];
8080 case 4:
8081 err_1 = _c.sent();
8082 finalAction = err_1 instanceof RejectWithValue ? rejected(null, requestId, arg, err_1.payload, err_1.meta) : rejected(err_1, requestId, arg);
8083 return [3 /*break*/, 5];
8084 case 5:
8085 skipDispatch = options && !options.dispatchConditionRejection && rejected.match(finalAction) && finalAction.meta.condition;
8086 if (!skipDispatch) {
8087 dispatch(finalAction);
8088 }
8089 return [2 /*return*/, finalAction];
8090 }
8091 });
8092 });
8093 }();
8094 return Object.assign(promise2, {
8095 abort: abort,
8096 requestId: requestId,
8097 arg: arg,
8098 unwrap: function () {
8099 return promise2.then(unwrapResult);
8100 }
8101 });
8102 };
8103 }
8104 return Object.assign(actionCreator, {
8105 pending: pending,
8106 rejected: rejected,
8107 fulfilled: fulfilled,
8108 typePrefix: typePrefix
8109 });
8110 }
8111 createAsyncThunk2.withTypes = function () { return createAsyncThunk2; };
8112 return createAsyncThunk2;
8113 })();
8114 function unwrapResult(action) {
8115 if (action.meta && action.meta.rejectedWithValue) {
8116 throw action.payload;
8117 }
8118 if (action.error) {
8119 throw action.error;
8120 }
8121 return action.payload;
8122 }
8123 function isThenable(value) {
8124 return value !== null && typeof value === "object" && typeof value.then === "function";
8125 }
8126 // src/matchers.ts
8127 var matches = function (matcher, action) {
8128 if (hasMatchFunction(matcher)) {
8129 return matcher.match(action);
8130 }
8131 else {
8132 return matcher(action);
8133 }
8134 };
8135 function isAnyOf() {
8136 var matchers = [];
8137 for (var _i = 0; _i < arguments.length; _i++) {
8138 matchers[_i] = arguments[_i];
8139 }
8140 return function (action) {
8141 return matchers.some(function (matcher) { return matches(matcher, action); });
8142 };
8143 }
8144 function isAllOf() {
8145 var matchers = [];
8146 for (var _i = 0; _i < arguments.length; _i++) {
8147 matchers[_i] = arguments[_i];
8148 }
8149 return function (action) {
8150 return matchers.every(function (matcher) { return matches(matcher, action); });
8151 };
8152 }
8153 function hasExpectedRequestMetadata(action, validStatus) {
8154 if (!action || !action.meta)
8155 return false;
8156 var hasValidRequestId = typeof action.meta.requestId === "string";
8157 var hasValidRequestStatus = validStatus.indexOf(action.meta.requestStatus) > -1;
8158 return hasValidRequestId && hasValidRequestStatus;
8159 }
8160 function isAsyncThunkArray(a) {
8161 return typeof a[0] === "function" && "pending" in a[0] && "fulfilled" in a[0] && "rejected" in a[0];
8162 }
8163 function isPending() {
8164 var asyncThunks = [];
8165 for (var _i = 0; _i < arguments.length; _i++) {
8166 asyncThunks[_i] = arguments[_i];
8167 }
8168 if (asyncThunks.length === 0) {
8169 return function (action) { return hasExpectedRequestMetadata(action, ["pending"]); };
8170 }
8171 if (!isAsyncThunkArray(asyncThunks)) {
8172 return isPending()(asyncThunks[0]);
8173 }
8174 return function (action) {
8175 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.pending; });
8176 var combinedMatcher = isAnyOf.apply(void 0, matchers);
8177 return combinedMatcher(action);
8178 };
8179 }
8180 function isRejected() {
8181 var asyncThunks = [];
8182 for (var _i = 0; _i < arguments.length; _i++) {
8183 asyncThunks[_i] = arguments[_i];
8184 }
8185 if (asyncThunks.length === 0) {
8186 return function (action) { return hasExpectedRequestMetadata(action, ["rejected"]); };
8187 }
8188 if (!isAsyncThunkArray(asyncThunks)) {
8189 return isRejected()(asyncThunks[0]);
8190 }
8191 return function (action) {
8192 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.rejected; });
8193 var combinedMatcher = isAnyOf.apply(void 0, matchers);
8194 return combinedMatcher(action);
8195 };
8196 }
8197 function isRejectedWithValue() {
8198 var asyncThunks = [];
8199 for (var _i = 0; _i < arguments.length; _i++) {
8200 asyncThunks[_i] = arguments[_i];
8201 }
8202 var hasFlag = function (action) {
8203 return action && action.meta && action.meta.rejectedWithValue;
8204 };
8205 if (asyncThunks.length === 0) {
8206 return function (action) {
8207 var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
8208 return combinedMatcher(action);
8209 };
8210 }
8211 if (!isAsyncThunkArray(asyncThunks)) {
8212 return isRejectedWithValue()(asyncThunks[0]);
8213 }
8214 return function (action) {
8215 var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
8216 return combinedMatcher(action);
8217 };
8218 }
8219 function isFulfilled() {
8220 var asyncThunks = [];
8221 for (var _i = 0; _i < arguments.length; _i++) {
8222 asyncThunks[_i] = arguments[_i];
8223 }
8224 if (asyncThunks.length === 0) {
8225 return function (action) { return hasExpectedRequestMetadata(action, ["fulfilled"]); };
8226 }
8227 if (!isAsyncThunkArray(asyncThunks)) {
8228 return isFulfilled()(asyncThunks[0]);
8229 }
8230 return function (action) {
8231 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.fulfilled; });
8232 var combinedMatcher = isAnyOf.apply(void 0, matchers);
8233 return combinedMatcher(action);
8234 };
8235 }
8236 function isAsyncThunkAction() {
8237 var asyncThunks = [];
8238 for (var _i = 0; _i < arguments.length; _i++) {
8239 asyncThunks[_i] = arguments[_i];
8240 }
8241 if (asyncThunks.length === 0) {
8242 return function (action) { return hasExpectedRequestMetadata(action, ["pending", "fulfilled", "rejected"]); };
8243 }
8244 if (!isAsyncThunkArray(asyncThunks)) {
8245 return isAsyncThunkAction()(asyncThunks[0]);
8246 }
8247 return function (action) {
8248 var matchers = [];
8249 for (var _i = 0, asyncThunks_1 = asyncThunks; _i < asyncThunks_1.length; _i++) {
8250 var asyncThunk = asyncThunks_1[_i];
8251 matchers.push(asyncThunk.pending, asyncThunk.rejected, asyncThunk.fulfilled);
8252 }
8253 var combinedMatcher = isAnyOf.apply(void 0, matchers);
8254 return combinedMatcher(action);
8255 };
8256 }
8257 // src/listenerMiddleware/utils.ts
8258 var assertFunction = function (func, expected) {
8259 if (typeof func !== "function") {
8260 throw new TypeError(expected + " is not a function");
8261 }
8262 };
8263 var noop = function () {
8264 };
8265 var catchRejection = function (promise2, onError) {
8266 if (onError === void 0) { onError = noop; }
8267 promise2.catch(onError);
8268 return promise2;
8269 };
8270 var addAbortSignalListener = function (abortSignal, callback) {
8271 abortSignal.addEventListener("abort", callback, { once: true });
8272 return function () { return abortSignal.removeEventListener("abort", callback); };
8273 };
8274 var abortControllerWithReason = function (abortController, reason) {
8275 var signal = abortController.signal;
8276 if (signal.aborted) {
8277 return;
8278 }
8279 if (!("reason" in signal)) {
8280 Object.defineProperty(signal, "reason", {
8281 enumerable: true,
8282 value: reason,
8283 configurable: true,
8284 writable: true
8285 });
8286 }
8287 ;
8288 abortController.abort(reason);
8289 };
8290 // src/listenerMiddleware/exceptions.ts
8291 var task = "task";
8292 var listener = "listener";
8293 var completed = "completed";
8294 var cancelled = "cancelled";
8295 var taskCancelled = "task-" + cancelled;
8296 var taskCompleted = "task-" + completed;
8297 var listenerCancelled = listener + "-" + cancelled;
8298 var listenerCompleted = listener + "-" + completed;
8299 var TaskAbortError = /** @class */ (function () {
8300 function TaskAbortError(code) {
8301 this.code = code;
8302 this.name = "TaskAbortError";
8303 this.message = task + " " + cancelled + " (reason: " + code + ")";
8304 }
8305 return TaskAbortError;
8306 }());
8307 // src/listenerMiddleware/task.ts
8308 var validateActive = function (signal) {
8309 if (signal.aborted) {
8310 throw new TaskAbortError(signal.reason);
8311 }
8312 };
8313 function raceWithSignal(signal, promise2) {
8314 var cleanup = noop;
8315 return new Promise(function (resolve, reject) {
8316 var notifyRejection = function () { return reject(new TaskAbortError(signal.reason)); };
8317 if (signal.aborted) {
8318 notifyRejection();
8319 return;
8320 }
8321 cleanup = addAbortSignalListener(signal, notifyRejection);
8322 promise2.finally(function () { return cleanup(); }).then(resolve, reject);
8323 }).finally(function () {
8324 cleanup = noop;
8325 });
8326 }
8327 var runTask = function (task2, cleanUp) { return __async(void 0, null, function () {
8328 var value, error_1;
8329 return __generator(this, function (_c) {
8330 switch (_c.label) {
8331 case 0:
8332 _c.trys.push([0, 3, 4, 5]);
8333 return [4 /*yield*/, Promise.resolve()];
8334 case 1:
8335 _c.sent();
8336 return [4 /*yield*/, task2()];
8337 case 2:
8338 value = _c.sent();
8339 return [2 /*return*/, {
8340 status: "ok",
8341 value: value
8342 }];
8343 case 3:
8344 error_1 = _c.sent();
8345 return [2 /*return*/, {
8346 status: error_1 instanceof TaskAbortError ? "cancelled" : "rejected",
8347 error: error_1
8348 }];
8349 case 4:
8350 cleanUp == null ? void 0 : cleanUp();
8351 return [7 /*endfinally*/];
8352 case 5: return [2 /*return*/];
8353 }
8354 });
8355 }); };
8356 var createPause = function (signal) {
8357 return function (promise2) {
8358 return catchRejection(raceWithSignal(signal, promise2).then(function (output) {
8359 validateActive(signal);
8360 return output;
8361 }));
8362 };
8363 };
8364 var createDelay = function (signal) {
8365 var pause = createPause(signal);
8366 return function (timeoutMs) {
8367 return pause(new Promise(function (resolve) { return setTimeout(resolve, timeoutMs); }));
8368 };
8369 };
8370 // src/listenerMiddleware/index.ts
8371 var assign = Object.assign;
8372 var INTERNAL_NIL_TOKEN = {};
8373 var alm = "listenerMiddleware";
8374 var createFork = function (parentAbortSignal, parentBlockingPromises) {
8375 var linkControllers = function (controller) { return addAbortSignalListener(parentAbortSignal, function () { return abortControllerWithReason(controller, parentAbortSignal.reason); }); };
8376 return function (taskExecutor, opts) {
8377 assertFunction(taskExecutor, "taskExecutor");
8378 var childAbortController = new AbortController();
8379 linkControllers(childAbortController);
8380 var result = runTask(function () { return __async(void 0, null, function () {
8381 var result2;
8382 return __generator(this, function (_c) {
8383 switch (_c.label) {
8384 case 0:
8385 validateActive(parentAbortSignal);
8386 validateActive(childAbortController.signal);
8387 return [4 /*yield*/, taskExecutor({
8388 pause: createPause(childAbortController.signal),
8389 delay: createDelay(childAbortController.signal),
8390 signal: childAbortController.signal
8391 })];
8392 case 1:
8393 result2 = _c.sent();
8394 validateActive(childAbortController.signal);
8395 return [2 /*return*/, result2];
8396 }
8397 });
8398 }); }, function () { return abortControllerWithReason(childAbortController, taskCompleted); });
8399 if (opts == null ? void 0 : opts.autoJoin) {
8400 parentBlockingPromises.push(result);
8401 }
8402 return {
8403 result: createPause(parentAbortSignal)(result),
8404 cancel: function () {
8405 abortControllerWithReason(childAbortController, taskCancelled);
8406 }
8407 };
8408 };
8409 };
8410 var createTakePattern = function (startListening, signal) {
8411 var take = function (predicate, timeout) { return __async(void 0, null, function () {
8412 var unsubscribe, tuplePromise, promises, output;
8413 return __generator(this, function (_c) {
8414 switch (_c.label) {
8415 case 0:
8416 validateActive(signal);
8417 unsubscribe = function () {
8418 };
8419 tuplePromise = new Promise(function (resolve, reject) {
8420 var stopListening = startListening({
8421 predicate: predicate,
8422 effect: function (action, listenerApi) {
8423 listenerApi.unsubscribe();
8424 resolve([
8425 action,
8426 listenerApi.getState(),
8427 listenerApi.getOriginalState()
8428 ]);
8429 }
8430 });
8431 unsubscribe = function () {
8432 stopListening();
8433 reject();
8434 };
8435 });
8436 promises = [
8437 tuplePromise
8438 ];
8439 if (timeout != null) {
8440 promises.push(new Promise(function (resolve) { return setTimeout(resolve, timeout, null); }));
8441 }
8442 _c.label = 1;
8443 case 1:
8444 _c.trys.push([1, , 3, 4]);
8445 return [4 /*yield*/, raceWithSignal(signal, Promise.race(promises))];
8446 case 2:
8447 output = _c.sent();
8448 validateActive(signal);
8449 return [2 /*return*/, output];
8450 case 3:
8451 unsubscribe();
8452 return [7 /*endfinally*/];
8453 case 4: return [2 /*return*/];
8454 }
8455 });
8456 }); };
8457 return function (predicate, timeout) { return catchRejection(take(predicate, timeout)); };
8458 };
8459 var getListenerEntryPropsFrom = function (options) {
8460 var type = options.type, actionCreator = options.actionCreator, matcher = options.matcher, predicate = options.predicate, effect = options.effect;
8461 if (type) {
8462 predicate = createAction(type).match;
8463 }
8464 else if (actionCreator) {
8465 type = actionCreator.type;
8466 predicate = actionCreator.match;
8467 }
8468 else if (matcher) {
8469 predicate = matcher;
8470 }
8471 else if (predicate) {
8472 }
8473 else {
8474 throw new Error("Creating or removing a listener requires one of the known fields for matching an action");
8475 }
8476 assertFunction(effect, "options.listener");
8477 return { predicate: predicate, type: type, effect: effect };
8478 };
8479 var createListenerEntry = function (options) {
8480 var _c = getListenerEntryPropsFrom(options), type = _c.type, predicate = _c.predicate, effect = _c.effect;
8481 var id = nanoid();
8482 var entry = {
8483 id: id,
8484 effect: effect,
8485 type: type,
8486 predicate: predicate,
8487 pending: new Set(),
8488 unsubscribe: function () {
8489 throw new Error("Unsubscribe not initialized");
8490 }
8491 };
8492 return entry;
8493 };
8494 var cancelActiveListeners = function (entry) {
8495 entry.pending.forEach(function (controller) {
8496 abortControllerWithReason(controller, listenerCancelled);
8497 });
8498 };
8499 var createClearListenerMiddleware = function (listenerMap) {
8500 return function () {
8501 listenerMap.forEach(cancelActiveListeners);
8502 listenerMap.clear();
8503 };
8504 };
8505 var safelyNotifyError = function (errorHandler, errorToNotify, errorInfo) {
8506 try {
8507 errorHandler(errorToNotify, errorInfo);
8508 }
8509 catch (errorHandlerError) {
8510 setTimeout(function () {
8511 throw errorHandlerError;
8512 }, 0);
8513 }
8514 };
8515 var addListener = createAction(alm + "/add");
8516 var clearAllListeners = createAction(alm + "/removeAll");
8517 var removeListener = createAction(alm + "/remove");
8518 var defaultErrorHandler = function () {
8519 var args = [];
8520 for (var _i = 0; _i < arguments.length; _i++) {
8521 args[_i] = arguments[_i];
8522 }
8523 console.error.apply(console, __spreadArray([alm + "/error"], args));
8524 };
8525 function createListenerMiddleware(middlewareOptions) {
8526 var _this = this;
8527 if (middlewareOptions === void 0) { middlewareOptions = {}; }
8528 var listenerMap = new Map();
8529 var extra = middlewareOptions.extra, _c = middlewareOptions.onError, onError = _c === void 0 ? defaultErrorHandler : _c;
8530 assertFunction(onError, "onError");
8531 var insertEntry = function (entry) {
8532 entry.unsubscribe = function () { return listenerMap.delete(entry.id); };
8533 listenerMap.set(entry.id, entry);
8534 return function (cancelOptions) {
8535 entry.unsubscribe();
8536 if (cancelOptions == null ? void 0 : cancelOptions.cancelActive) {
8537 cancelActiveListeners(entry);
8538 }
8539 };
8540 };
8541 var findListenerEntry = function (comparator) {
8542 for (var _i = 0, _c = Array.from(listenerMap.values()); _i < _c.length; _i++) {
8543 var entry = _c[_i];
8544 if (comparator(entry)) {
8545 return entry;
8546 }
8547 }
8548 return void 0;
8549 };
8550 var startListening = function (options) {
8551 var entry = findListenerEntry(function (existingEntry) { return existingEntry.effect === options.effect; });
8552 if (!entry) {
8553 entry = createListenerEntry(options);
8554 }
8555 return insertEntry(entry);
8556 };
8557 var stopListening = function (options) {
8558 var _c = getListenerEntryPropsFrom(options), type = _c.type, effect = _c.effect, predicate = _c.predicate;
8559 var entry = findListenerEntry(function (entry2) {
8560 var matchPredicateOrType = typeof type === "string" ? entry2.type === type : entry2.predicate === predicate;
8561 return matchPredicateOrType && entry2.effect === effect;
8562 });
8563 if (entry) {
8564 entry.unsubscribe();
8565 if (options.cancelActive) {
8566 cancelActiveListeners(entry);
8567 }
8568 }
8569 return !!entry;
8570 };
8571 var notifyListener = function (entry, action, api, getOriginalState) { return __async(_this, null, function () {
8572 var internalTaskController, take, autoJoinPromises, listenerError_1;
8573 return __generator(this, function (_c) {
8574 switch (_c.label) {
8575 case 0:
8576 internalTaskController = new AbortController();
8577 take = createTakePattern(startListening, internalTaskController.signal);
8578 autoJoinPromises = [];
8579 _c.label = 1;
8580 case 1:
8581 _c.trys.push([1, 3, 4, 6]);
8582 entry.pending.add(internalTaskController);
8583 return [4 /*yield*/, Promise.resolve(entry.effect(action, assign({}, api, {
8584 getOriginalState: getOriginalState,
8585 condition: function (predicate, timeout) { return take(predicate, timeout).then(Boolean); },
8586 take: take,
8587 delay: createDelay(internalTaskController.signal),
8588 pause: createPause(internalTaskController.signal),
8589 extra: extra,
8590 signal: internalTaskController.signal,
8591 fork: createFork(internalTaskController.signal, autoJoinPromises),
8592 unsubscribe: entry.unsubscribe,
8593 subscribe: function () {
8594 listenerMap.set(entry.id, entry);
8595 },
8596 cancelActiveListeners: function () {
8597 entry.pending.forEach(function (controller, _, set) {
8598 if (controller !== internalTaskController) {
8599 abortControllerWithReason(controller, listenerCancelled);
8600 set.delete(controller);
8601 }
8602 });
8603 }
8604 })))];
8605 case 2:
8606 _c.sent();
8607 return [3 /*break*/, 6];
8608 case 3:
8609 listenerError_1 = _c.sent();
8610 if (!(listenerError_1 instanceof TaskAbortError)) {
8611 safelyNotifyError(onError, listenerError_1, {
8612 raisedBy: "effect"
8613 });
8614 }
8615 return [3 /*break*/, 6];
8616 case 4: return [4 /*yield*/, Promise.allSettled(autoJoinPromises)];
8617 case 5:
8618 _c.sent();
8619 abortControllerWithReason(internalTaskController, listenerCompleted);
8620 entry.pending.delete(internalTaskController);
8621 return [7 /*endfinally*/];
8622 case 6: return [2 /*return*/];
8623 }
8624 });
8625 }); };
8626 var clearListenerMiddleware = createClearListenerMiddleware(listenerMap);
8627 var middleware = function (api) { return function (next) { return function (action) {
8628 if (!isAction(action)) {
8629 return next(action);
8630 }
8631 if (addListener.match(action)) {
8632 return startListening(action.payload);
8633 }
8634 if (clearAllListeners.match(action)) {
8635 clearListenerMiddleware();
8636 return;
8637 }
8638 if (removeListener.match(action)) {
8639 return stopListening(action.payload);
8640 }
8641 var originalState = api.getState();
8642 var getOriginalState = function () {
8643 if (originalState === INTERNAL_NIL_TOKEN) {
8644 throw new Error(alm + ": getOriginalState can only be called synchronously");
8645 }
8646 return originalState;
8647 };
8648 var result;
8649 try {
8650 result = next(action);
8651 if (listenerMap.size > 0) {
8652 var currentState = api.getState();
8653 var listenerEntries = Array.from(listenerMap.values());
8654 for (var _i = 0, listenerEntries_1 = listenerEntries; _i < listenerEntries_1.length; _i++) {
8655 var entry = listenerEntries_1[_i];
8656 var runListener = false;
8657 try {
8658 runListener = entry.predicate(action, currentState, originalState);
8659 }
8660 catch (predicateError) {
8661 runListener = false;
8662 safelyNotifyError(onError, predicateError, {
8663 raisedBy: "predicate"
8664 });
8665 }
8666 if (!runListener) {
8667 continue;
8668 }
8669 notifyListener(entry, action, api, getOriginalState);
8670 }
8671 }
8672 }
8673 finally {
8674 originalState = INTERNAL_NIL_TOKEN;
8675 }
8676 return result;
8677 }; }; };
8678 return {
8679 middleware: middleware,
8680 startListening: startListening,
8681 stopListening: stopListening,
8682 clearListeners: clearListenerMiddleware
8683 };
8684 }
8685 // src/autoBatchEnhancer.ts
8686 var SHOULD_AUTOBATCH = "RTK_autoBatch";
8687 var prepareAutoBatched = function () { return function (payload) {
8688 var _c;
8689 return ({
8690 payload: payload,
8691 meta: (_c = {}, _c[SHOULD_AUTOBATCH] = true, _c)
8692 });
8693 }; };
8694 var promise;
8695 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 () {
8696 throw err;
8697 }, 0); }); };
8698 var createQueueWithTimer = function (timeout) {
8699 return function (notify) {
8700 setTimeout(notify, timeout);
8701 };
8702 };
8703 var rAF = typeof window !== "undefined" && window.requestAnimationFrame ? window.requestAnimationFrame : createQueueWithTimer(10);
8704 var autoBatchEnhancer = function (options) {
8705 if (options === void 0) { options = { type: "raf" }; }
8706 return function (next) { return function () {
8707 var args = [];
8708 for (var _i = 0; _i < arguments.length; _i++) {
8709 args[_i] = arguments[_i];
8710 }
8711 var store = next.apply(void 0, args);
8712 var notifying = true;
8713 var shouldNotifyAtEndOfTick = false;
8714 var notificationQueued = false;
8715 var listeners = new Set();
8716 var queueCallback = options.type === "tick" ? queueMicrotaskShim : options.type === "raf" ? rAF : options.type === "callback" ? options.queueNotification : createQueueWithTimer(options.timeout);
8717 var notifyListeners = function () {
8718 notificationQueued = false;
8719 if (shouldNotifyAtEndOfTick) {
8720 shouldNotifyAtEndOfTick = false;
8721 listeners.forEach(function (l) { return l(); });
8722 }
8723 };
8724 return Object.assign({}, store, {
8725 subscribe: function (listener2) {
8726 var wrappedListener = function () { return notifying && listener2(); };
8727 var unsubscribe = store.subscribe(wrappedListener);
8728 listeners.add(listener2);
8729 return function () {
8730 unsubscribe();
8731 listeners.delete(listener2);
8732 };
8733 },
8734 dispatch: function (action) {
8735 var _a;
8736 try {
8737 notifying = !((_a = action == null ? void 0 : action.meta) == null ? void 0 : _a[SHOULD_AUTOBATCH]);
8738 shouldNotifyAtEndOfTick = !notifying;
8739 if (shouldNotifyAtEndOfTick) {
8740 if (!notificationQueued) {
8741 notificationQueued = true;
8742 queueCallback(notifyListeners);
8743 }
8744 }
8745 return store.dispatch(action);
8746 }
8747 finally {
8748 notifying = true;
8749 }
8750 }
8751 });
8752 }; };
8753 };
8754 // src/index.ts
8755 (0,immer__WEBPACK_IMPORTED_MODULE_0__.enableES5)();
8756
8757 //# sourceMappingURL=redux-toolkit.esm.js.map
8758
8759 /***/ }),
8760
8761 /***/ "../node_modules/immer/dist/immer.esm.mjs":
8762 /*!************************************************!*\
8763 !*** ../node_modules/immer/dist/immer.esm.mjs ***!
8764 \************************************************/
8765 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
8766
8767 "use strict";
8768 __webpack_require__.r(__webpack_exports__);
8769 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8770 /* harmony export */ Immer: () => (/* binding */ un),
8771 /* harmony export */ applyPatches: () => (/* binding */ pn),
8772 /* harmony export */ castDraft: () => (/* binding */ K),
8773 /* harmony export */ castImmutable: () => (/* binding */ $),
8774 /* harmony export */ createDraft: () => (/* binding */ ln),
8775 /* harmony export */ current: () => (/* binding */ R),
8776 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
8777 /* harmony export */ enableAllPlugins: () => (/* binding */ J),
8778 /* harmony export */ enableES5: () => (/* binding */ F),
8779 /* harmony export */ enableMapSet: () => (/* binding */ C),
8780 /* harmony export */ enablePatches: () => (/* binding */ T),
8781 /* harmony export */ finishDraft: () => (/* binding */ dn),
8782 /* harmony export */ freeze: () => (/* binding */ d),
8783 /* harmony export */ immerable: () => (/* binding */ L),
8784 /* harmony export */ isDraft: () => (/* binding */ r),
8785 /* harmony export */ isDraftable: () => (/* binding */ t),
8786 /* harmony export */ nothing: () => (/* binding */ H),
8787 /* harmony export */ original: () => (/* binding */ e),
8788 /* harmony export */ produce: () => (/* binding */ fn),
8789 /* harmony export */ produceWithPatches: () => (/* binding */ cn),
8790 /* harmony export */ setAutoFreeze: () => (/* binding */ sn),
8791 /* harmony export */ setUseProxies: () => (/* binding */ vn)
8792 /* harmony export */ });
8793 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
8794 }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);
8795 //# sourceMappingURL=immer.esm.js.map
8796
8797
8798 /***/ }),
8799
8800 /***/ "../node_modules/mixpanel-browser/dist/mixpanel.module.js":
8801 /*!****************************************************************!*\
8802 !*** ../node_modules/mixpanel-browser/dist/mixpanel.module.js ***!
8803 \****************************************************************/
8804 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8805
8806 "use strict";
8807 __webpack_require__.r(__webpack_exports__);
8808 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8809 /* harmony export */ "default": () => (/* binding */ mixpanel)
8810 /* harmony export */ });
8811 // since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
8812 var win;
8813 if (typeof(window) === 'undefined') {
8814 var loc = {
8815 hostname: ''
8816 };
8817 win = {
8818 crypto: {randomUUID: function() {throw Error('unsupported');}},
8819 navigator: { userAgent: '', onLine: true },
8820 document: {
8821 createElement: function() { return {}; },
8822 location: loc,
8823 referrer: ''
8824 },
8825 screen: { width: 0, height: 0 },
8826 location: loc,
8827 addEventListener: function() {},
8828 removeEventListener: function() {}
8829 };
8830 } else {
8831 win = window;
8832 }
8833
8834 function _array_like_to_array(arr, len) {
8835 if (len == null || len > arr.length) len = arr.length;
8836 for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
8837 return arr2;
8838 }
8839 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
8840 try {
8841 var info = gen[key](arg);
8842 var value = info.value;
8843 } catch (error) {
8844 reject(error);
8845 return;
8846 }
8847 if (info.done) {
8848 resolve(value);
8849 } else {
8850 Promise.resolve(value).then(_next, _throw);
8851 }
8852 }
8853 function _async_to_generator(fn) {
8854 return function() {
8855 var self = this, args = arguments;
8856 return new Promise(function(resolve, reject) {
8857 var gen = fn.apply(self, args);
8858 function _next(value) {
8859 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
8860 }
8861 function _throw(err) {
8862 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
8863 }
8864 _next(undefined);
8865 });
8866 };
8867 }
8868 function _construct(Parent, args, Class) {
8869 if (_is_native_reflect_construct()) {
8870 _construct = Reflect.construct;
8871 } else {
8872 _construct = function construct(Parent, args, Class) {
8873 var a = [
8874 null
8875 ];
8876 a.push.apply(a, args);
8877 var Constructor = Function.bind.apply(Parent, a);
8878 var instance = new Constructor();
8879 if (Class) _set_prototype_of(instance, Class.prototype);
8880 return instance;
8881 };
8882 }
8883 return _construct.apply(null, arguments);
8884 }
8885 function _defineProperties(target, props) {
8886 for(var i = 0; i < props.length; i++){
8887 var descriptor = props[i];
8888 descriptor.enumerable = descriptor.enumerable || false;
8889 descriptor.configurable = true;
8890 if ("value" in descriptor) descriptor.writable = true;
8891 Object.defineProperty(target, descriptor.key, descriptor);
8892 }
8893 }
8894 function _create_class(Constructor, protoProps, staticProps) {
8895 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
8896 return Constructor;
8897 }
8898 function _extends() {
8899 _extends = Object.assign || function(target) {
8900 for(var i = 1; i < arguments.length; i++){
8901 var source = arguments[i];
8902 for(var key in source){
8903 if (Object.prototype.hasOwnProperty.call(source, key)) {
8904 target[key] = source[key];
8905 }
8906 }
8907 }
8908 return target;
8909 };
8910 return _extends.apply(this, arguments);
8911 }
8912 function _get_prototype_of(o) {
8913 _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
8914 return o.__proto__ || Object.getPrototypeOf(o);
8915 };
8916 return _get_prototype_of(o);
8917 }
8918 function _inherits(subClass, superClass) {
8919 if (typeof superClass !== "function" && superClass !== null) {
8920 throw new TypeError("Super expression must either be null or a function");
8921 }
8922 subClass.prototype = Object.create(superClass && superClass.prototype, {
8923 constructor: {
8924 value: subClass,
8925 writable: true,
8926 configurable: true
8927 }
8928 });
8929 if (superClass) _set_prototype_of(subClass, superClass);
8930 }
8931 function _instanceof(left, right) {
8932 if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
8933 return !!right[Symbol.hasInstance](left);
8934 } else {
8935 return left instanceof right;
8936 }
8937 }
8938 function _is_native_function(fn) {
8939 return Function.toString.call(fn).indexOf("[native code]") !== -1;
8940 }
8941 function _object_without_properties_loose(source, excluded) {
8942 if (source == null) return {};
8943 var target = {};
8944 var sourceKeys = Object.keys(source);
8945 var key, i;
8946 for(i = 0; i < sourceKeys.length; i++){
8947 key = sourceKeys[i];
8948 if (excluded.indexOf(key) >= 0) continue;
8949 target[key] = source[key];
8950 }
8951 return target;
8952 }
8953 function _set_prototype_of(o, p) {
8954 _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
8955 o.__proto__ = p;
8956 return o;
8957 };
8958 return _set_prototype_of(o, p);
8959 }
8960 function _type_of(obj) {
8961 "@swc/helpers - typeof";
8962 return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
8963 }
8964 function _unsupported_iterable_to_array(o, minLen) {
8965 if (!o) return;
8966 if (typeof o === "string") return _array_like_to_array(o, minLen);
8967 var n = Object.prototype.toString.call(o).slice(8, -1);
8968 if (n === "Object" && o.constructor) n = o.constructor.name;
8969 if (n === "Map" || n === "Set") return Array.from(n);
8970 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
8971 }
8972 function _wrap_native_super(Class) {
8973 var _cache = typeof Map === "function" ? new Map() : undefined;
8974 _wrap_native_super = function wrapNativeSuper(Class) {
8975 if (Class === null || !_is_native_function(Class)) return Class;
8976 if (typeof Class !== "function") {
8977 throw new TypeError("Super expression must either be null or a function");
8978 }
8979 if (typeof _cache !== "undefined") {
8980 if (_cache.has(Class)) return _cache.get(Class);
8981 _cache.set(Class, Wrapper);
8982 }
8983 function Wrapper() {
8984 return _construct(Class, arguments, _get_prototype_of(this).constructor);
8985 }
8986 Wrapper.prototype = Object.create(Class.prototype, {
8987 constructor: {
8988 value: Wrapper,
8989 enumerable: false,
8990 writable: true,
8991 configurable: true
8992 }
8993 });
8994 return _set_prototype_of(Wrapper, Class);
8995 };
8996 return _wrap_native_super(Class);
8997 }
8998 function _is_native_reflect_construct() {
8999 try {
9000 var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
9001 } catch (_) {}
9002 return (_is_native_reflect_construct = function() {
9003 return !!result;
9004 })();
9005 }
9006 function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
9007 var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
9008 if (it) return (it = it.call(o)).next.bind(it);
9009 if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike) {
9010 if (it) o = it;
9011 var i = 0;
9012 return function() {
9013 if (i >= o.length) {
9014 return {
9015 done: true
9016 };
9017 }
9018 return {
9019 done: false,
9020 value: o[i++]
9021 };
9022 };
9023 }
9024 throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
9025 }
9026 function _ts_generator(thisArg, body) {
9027 var f, y, t, g, _ = {
9028 label: 0,
9029 sent: function() {
9030 if (t[0] & 1) throw t[1];
9031 return t[1];
9032 },
9033 trys: [],
9034 ops: []
9035 };
9036 return g = {
9037 next: verb(0),
9038 "throw": verb(1),
9039 "return": verb(2)
9040 }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
9041 return this;
9042 }), g;
9043 function verb(n) {
9044 return function(v) {
9045 return step([
9046 n,
9047 v
9048 ]);
9049 };
9050 }
9051 function step(op) {
9052 if (f) throw new TypeError("Generator is already executing.");
9053 while(_)try {
9054 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;
9055 if (y = 0, t) op = [
9056 op[0] & 2,
9057 t.value
9058 ];
9059 switch(op[0]){
9060 case 0:
9061 case 1:
9062 t = op;
9063 break;
9064 case 4:
9065 _.label++;
9066 return {
9067 value: op[1],
9068 done: false
9069 };
9070 case 5:
9071 _.label++;
9072 y = op[1];
9073 op = [
9074 0
9075 ];
9076 continue;
9077 case 7:
9078 op = _.ops.pop();
9079 _.trys.pop();
9080 continue;
9081 default:
9082 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
9083 _ = 0;
9084 continue;
9085 }
9086 if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
9087 _.label = op[1];
9088 break;
9089 }
9090 if (op[0] === 6 && _.label < t[1]) {
9091 _.label = t[1];
9092 t = op;
9093 break;
9094 }
9095 if (t && _.label < t[2]) {
9096 _.label = t[2];
9097 _.ops.push(op);
9098 break;
9099 }
9100 if (t[2]) _.ops.pop();
9101 _.trys.pop();
9102 continue;
9103 }
9104 op = body.call(thisArg, _);
9105 } catch (e) {
9106 op = [
9107 6,
9108 e
9109 ];
9110 y = 0;
9111 } finally{
9112 f = t = 0;
9113 }
9114 if (op[0] & 5) throw op[1];
9115 return {
9116 value: op[0] ? op[1] : void 0,
9117 done: true
9118 };
9119 }
9120 }
9121 function _ts_values(o) {
9122 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
9123 if (m) return m.call(o);
9124 if (o && typeof o.length === "number") return {
9125 next: function() {
9126 if (o && i >= o.length) o = void 0;
9127 return {
9128 value: o && o[i++],
9129 done: !o
9130 };
9131 }
9132 };
9133 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
9134 }
9135 var __defProp = Object.defineProperty;
9136 var __defNormalProp = function(obj, key, value) {
9137 return key in obj ? __defProp(obj, key, {
9138 enumerable: true,
9139 configurable: true,
9140 writable: true,
9141 value: value
9142 }) : obj[key] = value;
9143 };
9144 var __publicField = function(obj, key, value) {
9145 return __defNormalProp(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
9146 };
9147 var _a;
9148 var __defProp$1 = Object.defineProperty;
9149 var __defNormalProp$1 = function(obj, key, value) {
9150 return key in obj ? __defProp$1(obj, key, {
9151 enumerable: true,
9152 configurable: true,
9153 writable: true,
9154 value: value
9155 }) : obj[key] = value;
9156 };
9157 var __publicField$1 = function(obj, key, value) {
9158 return __defNormalProp$1(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
9159 };
9160 var NodeType$3 = /* @__PURE__ */ function(NodeType2) {
9161 NodeType2[NodeType2["Document"] = 0] = "Document";
9162 NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
9163 NodeType2[NodeType2["Element"] = 2] = "Element";
9164 NodeType2[NodeType2["Text"] = 3] = "Text";
9165 NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
9166 NodeType2[NodeType2["Comment"] = 5] = "Comment";
9167 return NodeType2;
9168 }(NodeType$3 || {});
9169 var testableAccessors$1 = {
9170 Node: [
9171 "childNodes",
9172 "parentNode",
9173 "parentElement",
9174 "textContent"
9175 ],
9176 ShadowRoot: [
9177 "host",
9178 "styleSheets"
9179 ],
9180 Element: [
9181 "shadowRoot",
9182 "querySelector",
9183 "querySelectorAll"
9184 ],
9185 MutationObserver: []
9186 };
9187 var testableMethods$1 = {
9188 Node: [
9189 "contains",
9190 "getRootNode"
9191 ],
9192 ShadowRoot: [
9193 "getSelection"
9194 ],
9195 Element: [],
9196 MutationObserver: [
9197 "constructor"
9198 ]
9199 };
9200 var untaintedBasePrototype$1 = {};
9201 var isAngularZonePresent$1 = function() {
9202 return !!globalThis.Zone;
9203 };
9204 function getUntaintedPrototype$1(key) {
9205 if (untaintedBasePrototype$1[key]) return untaintedBasePrototype$1[key];
9206 var defaultObj = globalThis[key];
9207 var defaultPrototype = defaultObj.prototype;
9208 var accessorNames = key in testableAccessors$1 ? testableAccessors$1[key] : void 0;
9209 var isUntaintedAccessors = Boolean(accessorNames && // @ts-expect-error 2345
9210 accessorNames.every(function(accessor) {
9211 var _a2, _b;
9212 return Boolean((_b = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b.toString().includes("[native code]"));
9213 }));
9214 var methodNames = key in testableMethods$1 ? testableMethods$1[key] : void 0;
9215 var isUntaintedMethods = Boolean(methodNames && methodNames.every(// @ts-expect-error 2345
9216 function(method) {
9217 var _a2;
9218 return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
9219 }));
9220 if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent$1()) {
9221 untaintedBasePrototype$1[key] = defaultObj.prototype;
9222 return defaultObj.prototype;
9223 }
9224 try {
9225 var iframeEl = document.createElement("iframe");
9226 document.body.appendChild(iframeEl);
9227 var win = iframeEl.contentWindow;
9228 if (!win) return defaultObj.prototype;
9229 var untaintedObject = win[key].prototype;
9230 document.body.removeChild(iframeEl);
9231 if (!untaintedObject) return defaultPrototype;
9232 return untaintedBasePrototype$1[key] = untaintedObject;
9233 } catch (e) {
9234 return defaultPrototype;
9235 }
9236 }
9237 var untaintedAccessorCache$1 = {};
9238 function getUntaintedAccessor$1(key, instance, accessor) {
9239 var _a2;
9240 var cacheKey = key + "." + String(accessor);
9241 if (untaintedAccessorCache$1[cacheKey]) return untaintedAccessorCache$1[cacheKey].call(instance);
9242 var untaintedPrototype = getUntaintedPrototype$1(key);
9243 var untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(untaintedPrototype, accessor)) == null ? void 0 : _a2.get;
9244 if (!untaintedAccessor) return instance[accessor];
9245 untaintedAccessorCache$1[cacheKey] = untaintedAccessor;
9246 return untaintedAccessor.call(instance);
9247 }
9248 var untaintedMethodCache$1 = {};
9249 function getUntaintedMethod$1(key, instance, method) {
9250 var cacheKey = key + "." + String(method);
9251 if (untaintedMethodCache$1[cacheKey]) return untaintedMethodCache$1[cacheKey].bind(instance);
9252 var untaintedPrototype = getUntaintedPrototype$1(key);
9253 var untaintedMethod = untaintedPrototype[method];
9254 if (typeof untaintedMethod !== "function") return instance[method];
9255 untaintedMethodCache$1[cacheKey] = untaintedMethod;
9256 return untaintedMethod.bind(instance);
9257 }
9258 function childNodes$1(n2) {
9259 return getUntaintedAccessor$1("Node", n2, "childNodes");
9260 }
9261 function parentNode$1(n2) {
9262 return getUntaintedAccessor$1("Node", n2, "parentNode");
9263 }
9264 function parentElement$1(n2) {
9265 return getUntaintedAccessor$1("Node", n2, "parentElement");
9266 }
9267 function textContent$1(n2) {
9268 return getUntaintedAccessor$1("Node", n2, "textContent");
9269 }
9270 function contains$1(n2, other) {
9271 return getUntaintedMethod$1("Node", n2, "contains")(other);
9272 }
9273 function getRootNode$1(n2) {
9274 return getUntaintedMethod$1("Node", n2, "getRootNode")();
9275 }
9276 function host$1(n2) {
9277 if (!n2 || !("host" in n2)) return null;
9278 return getUntaintedAccessor$1("ShadowRoot", n2, "host");
9279 }
9280 function styleSheets$1(n2) {
9281 return n2.styleSheets;
9282 }
9283 function shadowRoot$1(n2) {
9284 if (!n2 || !("shadowRoot" in n2)) return null;
9285 return getUntaintedAccessor$1("Element", n2, "shadowRoot");
9286 }
9287 function querySelector$1(n2, selectors) {
9288 return getUntaintedAccessor$1("Element", n2, "querySelector")(selectors);
9289 }
9290 function querySelectorAll$1(n2, selectors) {
9291 return getUntaintedAccessor$1("Element", n2, "querySelectorAll")(selectors);
9292 }
9293 function mutationObserverCtor$1() {
9294 return getUntaintedPrototype$1("MutationObserver").constructor;
9295 }
9296 function patch$1(source, name, replacement) {
9297 try {
9298 if (!(name in source)) {
9299 return function() {};
9300 }
9301 var original = source[name];
9302 var wrapped = replacement(original);
9303 if (typeof wrapped === "function") {
9304 wrapped.prototype = wrapped.prototype || {};
9305 Object.defineProperties(wrapped, {
9306 __rrweb_original__: {
9307 enumerable: false,
9308 value: original
9309 }
9310 });
9311 }
9312 source[name] = wrapped;
9313 return function() {
9314 source[name] = original;
9315 };
9316 } catch (e) {
9317 return function() {};
9318 }
9319 }
9320 var index$1 = {
9321 childNodes: childNodes$1,
9322 parentNode: parentNode$1,
9323 parentElement: parentElement$1,
9324 textContent: textContent$1,
9325 contains: contains$1,
9326 getRootNode: getRootNode$1,
9327 host: host$1,
9328 styleSheets: styleSheets$1,
9329 shadowRoot: shadowRoot$1,
9330 querySelector: querySelector$1,
9331 querySelectorAll: querySelectorAll$1,
9332 mutationObserver: mutationObserverCtor$1,
9333 patch: patch$1
9334 };
9335 function isElement(n2) {
9336 return n2.nodeType === n2.ELEMENT_NODE;
9337 }
9338 function isShadowRoot(n2) {
9339 var hostEl = // anchor and textarea elements also have a `host` property
9340 // but only shadow roots have a `mode` property
9341 n2 && "host" in n2 && "mode" in n2 && index$1.host(n2) || null;
9342 return Boolean(hostEl && "shadowRoot" in hostEl && index$1.shadowRoot(hostEl) === n2);
9343 }
9344 function isNativeShadowDom(shadowRoot2) {
9345 return Object.prototype.toString.call(shadowRoot2) === "[object ShadowRoot]";
9346 }
9347 function fixBrowserCompatibilityIssuesInCSS(cssText) {
9348 if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
9349 cssText = cssText.replace(/\sbackground-clip:\s*text;/g, " -webkit-background-clip: text; background-clip: text;");
9350 }
9351 return cssText;
9352 }
9353 function escapeImportStatement(rule2) {
9354 var cssText = rule2.cssText;
9355 if (cssText.split('"').length < 3) return cssText;
9356 var statement = [
9357 "@import",
9358 "url(" + JSON.stringify(rule2.href) + ")"
9359 ];
9360 if (rule2.layerName === "") {
9361 statement.push("layer");
9362 } else if (rule2.layerName) {
9363 statement.push("layer(" + rule2.layerName + ")");
9364 }
9365 if (rule2.supportsText) {
9366 statement.push("supports(" + rule2.supportsText + ")");
9367 }
9368 if (rule2.media.length) {
9369 statement.push(rule2.media.mediaText);
9370 }
9371 return statement.join(" ") + ";";
9372 }
9373 function stringifyStylesheet(s2) {
9374 try {
9375 var rules2 = s2.rules || s2.cssRules;
9376 if (!rules2) {
9377 return null;
9378 }
9379 var sheetHref = s2.href;
9380 if (!sheetHref && s2.ownerNode && s2.ownerNode.ownerDocument) {
9381 sheetHref = s2.ownerNode.ownerDocument.location.href;
9382 }
9383 var stringifiedRules = Array.from(rules2, function(rule2) {
9384 return stringifyRule(rule2, sheetHref);
9385 }).join("");
9386 return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
9387 } catch (error) {
9388 return null;
9389 }
9390 }
9391 function stringifyRule(rule2, sheetHref) {
9392 if (isCSSImportRule(rule2)) {
9393 var importStringified;
9394 try {
9395 importStringified = // we can access the imported stylesheet rules directly
9396 stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
9397 escapeImportStatement(rule2);
9398 } catch (error) {
9399 importStringified = rule2.cssText;
9400 }
9401 if (rule2.styleSheet.href) {
9402 return absolutifyURLs(importStringified, rule2.styleSheet.href);
9403 }
9404 return importStringified;
9405 } else {
9406 var ruleStringified = rule2.cssText;
9407 if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
9408 ruleStringified = fixSafariColons(ruleStringified);
9409 }
9410 if (sheetHref) {
9411 return absolutifyURLs(ruleStringified, sheetHref);
9412 }
9413 return ruleStringified;
9414 }
9415 }
9416 function fixSafariColons(cssStringified) {
9417 var regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
9418 return cssStringified.replace(regex, "$1\\$2");
9419 }
9420 function isCSSImportRule(rule2) {
9421 return "styleSheet" in rule2;
9422 }
9423 function isCSSStyleRule(rule2) {
9424 return "selectorText" in rule2;
9425 }
9426 var Mirror = /*#__PURE__*/ function() {
9427 function Mirror() {
9428 __publicField$1(this, "idNodeMap", /* @__PURE__ */ new Map());
9429 __publicField$1(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap());
9430 }
9431 var _proto = Mirror.prototype;
9432 _proto.getId = function getId(n2) {
9433 var _a2;
9434 if (!n2) return -1;
9435 var id = (_a2 = this.getMeta(n2)) == null ? void 0 : _a2.id;
9436 return id != null ? id : -1;
9437 };
9438 _proto.getNode = function getNode(id) {
9439 return this.idNodeMap.get(id) || null;
9440 };
9441 _proto.getIds = function getIds() {
9442 return Array.from(this.idNodeMap.keys());
9443 };
9444 _proto.getMeta = function getMeta(n2) {
9445 return this.nodeMetaMap.get(n2) || null;
9446 };
9447 // removes the node from idNodeMap
9448 // doesn't remove the node from nodeMetaMap
9449 _proto.removeNodeFromMap = function removeNodeFromMap(n2) {
9450 var _this = this;
9451 var id = this.getId(n2);
9452 this.idNodeMap.delete(id);
9453 if (n2.childNodes) {
9454 n2.childNodes.forEach(function(childNode) {
9455 return _this.removeNodeFromMap(childNode);
9456 });
9457 }
9458 };
9459 _proto.has = function has(id) {
9460 return this.idNodeMap.has(id);
9461 };
9462 _proto.hasNode = function hasNode(node2) {
9463 return this.nodeMetaMap.has(node2);
9464 };
9465 _proto.add = function add(n2, meta) {
9466 var id = meta.id;
9467 this.idNodeMap.set(id, n2);
9468 this.nodeMetaMap.set(n2, meta);
9469 };
9470 _proto.replace = function replace(id, n2) {
9471 var oldNode = this.getNode(id);
9472 if (oldNode) {
9473 var meta = this.nodeMetaMap.get(oldNode);
9474 if (meta) this.nodeMetaMap.set(n2, meta);
9475 }
9476 this.idNodeMap.set(id, n2);
9477 };
9478 _proto.reset = function reset() {
9479 this.idNodeMap = /* @__PURE__ */ new Map();
9480 this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
9481 };
9482 return Mirror;
9483 }();
9484 function createMirror$2() {
9485 return new Mirror();
9486 }
9487 function maskInputValue(param) {
9488 var element = param.element, maskInputOptions = param.maskInputOptions, tagName = param.tagName, type = param.type, value = param.value, maskInputFn = param.maskInputFn;
9489 var text = value || "";
9490 var actualType = type && toLowerCase(type);
9491 if (maskInputOptions[tagName.toLowerCase()] || actualType && maskInputOptions[actualType]) {
9492 if (maskInputFn) {
9493 text = maskInputFn(text, element);
9494 } else {
9495 text = "*".repeat(text.length);
9496 }
9497 }
9498 return text;
9499 }
9500 function toLowerCase(str) {
9501 return str.toLowerCase();
9502 }
9503 var ORIGINAL_ATTRIBUTE_NAME = "__rrweb_original__";
9504 function is2DCanvasBlank(canvas) {
9505 var ctx = canvas.getContext("2d");
9506 if (!ctx) return true;
9507 var chunkSize = 50;
9508 for(var x2 = 0; x2 < canvas.width; x2 += chunkSize){
9509 for(var y = 0; y < canvas.height; y += chunkSize){
9510 var getImageData = ctx.getImageData;
9511 var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData ? getImageData[ORIGINAL_ATTRIBUTE_NAME] : getImageData;
9512 var pixelBuffer = new Uint32Array(// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
9513 originalGetImageData.call(ctx, x2, y, Math.min(chunkSize, canvas.width - x2), Math.min(chunkSize, canvas.height - y)).data.buffer);
9514 if (pixelBuffer.some(function(pixel) {
9515 return pixel !== 0;
9516 })) return false;
9517 }
9518 }
9519 return true;
9520 }
9521 function getInputType(element) {
9522 var type = element.type;
9523 return element.hasAttribute("data-rr-is-password") ? "password" : type ? // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
9524 toLowerCase(type) : null;
9525 }
9526 function extractFileExtension(path, baseURL) {
9527 var url;
9528 try {
9529 url = new URL(path, baseURL != null ? baseURL : window.location.href);
9530 } catch (err) {
9531 return null;
9532 }
9533 var regex = /\.([0-9a-z]+)(?:$)/i;
9534 var match = url.pathname.match(regex);
9535 var _ref;
9536 return (_ref = match == null ? void 0 : match[1]) != null ? _ref : null;
9537 }
9538 function extractOrigin(url) {
9539 var origin = "";
9540 if (url.indexOf("//") > -1) {
9541 origin = url.split("/").slice(0, 3).join("/");
9542 } else {
9543 origin = url.split("/")[0];
9544 }
9545 origin = origin.split("?")[0];
9546 return origin;
9547 }
9548 var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
9549 var URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
9550 var URL_WWW_MATCH = /^www\..*/i;
9551 var DATA_URI = /^(data:)([^,]*),(.*)/i;
9552 function absolutifyURLs(cssText, href) {
9553 return (cssText || "").replace(URL_IN_CSS_REF, function(origin, quote1, path1, quote2, path2, path3) {
9554 var filePath = path1 || path2 || path3;
9555 var maybeQuote = quote1 || quote2 || "";
9556 if (!filePath) {
9557 return origin;
9558 }
9559 if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {
9560 return "url(" + maybeQuote + filePath + maybeQuote + ")";
9561 }
9562 if (DATA_URI.test(filePath)) {
9563 return "url(" + maybeQuote + filePath + maybeQuote + ")";
9564 }
9565 if (filePath[0] === "/") {
9566 return "url(" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + ")";
9567 }
9568 var stack = href.split("/");
9569 var parts = filePath.split("/");
9570 stack.pop();
9571 for(var _iterator = _create_for_of_iterator_helper_loose(parts), _step; !(_step = _iterator()).done;){
9572 var part = _step.value;
9573 if (part === ".") {
9574 continue;
9575 } else if (part === "..") {
9576 stack.pop();
9577 } else {
9578 stack.push(part);
9579 }
9580 }
9581 return "url(" + maybeQuote + stack.join("/") + maybeQuote + ")";
9582 });
9583 }
9584 function normalizeCssString(cssText, _testNoPxNorm) {
9585 if (_testNoPxNorm === void 0) _testNoPxNorm = false;
9586 if (_testNoPxNorm) {
9587 return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "");
9588 } else {
9589 return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "").replace(/0px/g, "0");
9590 }
9591 }
9592 function splitCssText(cssText, style, _testNoPxNorm) {
9593 if (_testNoPxNorm === void 0) _testNoPxNorm = false;
9594 var childNodes2 = Array.from(style.childNodes);
9595 var splits = [];
9596 var iterCount = 0;
9597 if (childNodes2.length > 1 && cssText && typeof cssText === "string") {
9598 var cssTextNorm = normalizeCssString(cssText, _testNoPxNorm);
9599 var normFactor = cssTextNorm.length / cssText.length;
9600 for(var i2 = 1; i2 < childNodes2.length; i2++){
9601 if (childNodes2[i2].textContent && typeof childNodes2[i2].textContent === "string") {
9602 var textContentNorm = normalizeCssString(childNodes2[i2].textContent, _testNoPxNorm);
9603 var jLimit = 100;
9604 var j = 3;
9605 for(; j < textContentNorm.length; j++){
9606 if (// keep consuming css identifiers (to get a decent chunk more quickly)
9607 textContentNorm[j].match(/[a-zA-Z0-9]/) || // substring needs to be unique to this section
9608 textContentNorm.indexOf(textContentNorm.substring(0, j), 1) !== -1) {
9609 continue;
9610 }
9611 break;
9612 }
9613 for(; j < textContentNorm.length; j++){
9614 var startSubstring = textContentNorm.substring(0, j);
9615 var cssNormSplits = cssTextNorm.split(startSubstring);
9616 var splitNorm = -1;
9617 if (cssNormSplits.length === 2) {
9618 splitNorm = cssNormSplits[0].length;
9619 } else if (cssNormSplits.length > 2 && cssNormSplits[0] === "" && childNodes2[i2 - 1].textContent !== "") {
9620 splitNorm = cssTextNorm.indexOf(startSubstring, 1);
9621 } else if (cssNormSplits.length === 1) {
9622 startSubstring = startSubstring.substring(0, startSubstring.length - 1);
9623 cssNormSplits = cssTextNorm.split(startSubstring);
9624 if (cssNormSplits.length <= 1) {
9625 splits.push(cssText);
9626 return splits;
9627 }
9628 j = jLimit + 1;
9629 } else if (j === textContentNorm.length - 1) {
9630 splitNorm = cssTextNorm.indexOf(startSubstring);
9631 }
9632 if (cssNormSplits.length >= 2 && j > jLimit) {
9633 var prevTextContent = childNodes2[i2 - 1].textContent;
9634 if (prevTextContent && typeof prevTextContent === "string") {
9635 var prevMinLength = normalizeCssString(prevTextContent).length;
9636 splitNorm = cssTextNorm.indexOf(startSubstring, prevMinLength);
9637 }
9638 if (splitNorm === -1) {
9639 splitNorm = cssNormSplits[0].length;
9640 }
9641 }
9642 if (splitNorm !== -1) {
9643 var k = Math.floor(splitNorm / normFactor);
9644 for(; k > 0 && k < cssText.length;){
9645 iterCount += 1;
9646 if (iterCount > 50 * childNodes2.length) {
9647 splits.push(cssText);
9648 return splits;
9649 }
9650 var normPart = normalizeCssString(cssText.substring(0, k), _testNoPxNorm);
9651 if (normPart.length === splitNorm) {
9652 splits.push(cssText.substring(0, k));
9653 cssText = cssText.substring(k);
9654 cssTextNorm = cssTextNorm.substring(splitNorm);
9655 break;
9656 } else if (normPart.length < splitNorm) {
9657 k += Math.max(1, Math.floor((splitNorm - normPart.length) / normFactor));
9658 } else {
9659 k -= Math.max(1, Math.floor((normPart.length - splitNorm) * normFactor));
9660 }
9661 }
9662 break;
9663 }
9664 }
9665 }
9666 }
9667 }
9668 splits.push(cssText);
9669 return splits;
9670 }
9671 function markCssSplits(cssText, style) {
9672 return splitCssText(cssText, style).join("/* rr_split */");
9673 }
9674 var _id = 1;
9675 var tagNameRegex = new RegExp("[^a-z0-9-_:]");
9676 var IGNORED_NODE = -2;
9677 function genId() {
9678 return _id++;
9679 }
9680 function getValidTagName$1(element) {
9681 if (_instanceof(element, HTMLFormElement)) {
9682 return "form";
9683 }
9684 var processedTagName = toLowerCase(element.tagName);
9685 if (tagNameRegex.test(processedTagName)) {
9686 return "div";
9687 }
9688 return processedTagName;
9689 }
9690 var canvasService;
9691 var canvasCtx;
9692 var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
9693 var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
9694 function getAbsoluteSrcsetString(doc, attributeValue) {
9695 if (attributeValue.trim() === "") {
9696 return attributeValue;
9697 }
9698 var pos = 0;
9699 function collectCharacters(regEx) {
9700 var chars2;
9701 var match = regEx.exec(attributeValue.substring(pos));
9702 if (match) {
9703 chars2 = match[0];
9704 pos += chars2.length;
9705 return chars2;
9706 }
9707 return "";
9708 }
9709 var output = [];
9710 while(true){
9711 collectCharacters(SRCSET_COMMAS_OR_SPACES);
9712 if (pos >= attributeValue.length) {
9713 break;
9714 }
9715 var url = collectCharacters(SRCSET_NOT_SPACES);
9716 if (url.slice(-1) === ",") {
9717 url = absoluteToDoc(doc, url.substring(0, url.length - 1));
9718 output.push(url);
9719 } else {
9720 var descriptorsStr = "";
9721 url = absoluteToDoc(doc, url);
9722 var inParens = false;
9723 while(true){
9724 var c2 = attributeValue.charAt(pos);
9725 if (c2 === "") {
9726 output.push((url + descriptorsStr).trim());
9727 break;
9728 } else if (!inParens) {
9729 if (c2 === ",") {
9730 pos += 1;
9731 output.push((url + descriptorsStr).trim());
9732 break;
9733 } else if (c2 === "(") {
9734 inParens = true;
9735 }
9736 } else {
9737 if (c2 === ")") {
9738 inParens = false;
9739 }
9740 }
9741 descriptorsStr += c2;
9742 pos += 1;
9743 }
9744 }
9745 }
9746 return output.join(", ");
9747 }
9748 var cachedDocument = /* @__PURE__ */ new WeakMap();
9749 function absoluteToDoc(doc, attributeValue) {
9750 if (!attributeValue || attributeValue.trim() === "") {
9751 return attributeValue;
9752 }
9753 return getHref(doc, attributeValue);
9754 }
9755 function isSVGElement(el) {
9756 return Boolean(el.tagName === "svg" || el.ownerSVGElement);
9757 }
9758 function getHref(doc, customHref) {
9759 var a2 = cachedDocument.get(doc);
9760 if (!a2) {
9761 a2 = doc.createElement("a");
9762 cachedDocument.set(doc, a2);
9763 }
9764 if (!customHref) {
9765 customHref = "";
9766 } else if (customHref.startsWith("blob:") || customHref.startsWith("data:")) {
9767 return customHref;
9768 }
9769 a2.setAttribute("href", customHref);
9770 return a2.href;
9771 }
9772 function transformAttribute(doc, tagName, name, value) {
9773 if (!value) {
9774 return value;
9775 }
9776 if (name === "src" || name === "href" && !(tagName === "use" && value[0] === "#")) {
9777 return absoluteToDoc(doc, value);
9778 } else if (name === "xlink:href" && value[0] !== "#") {
9779 return absoluteToDoc(doc, value);
9780 } else if (name === "background" && (tagName === "table" || tagName === "td" || tagName === "th")) {
9781 return absoluteToDoc(doc, value);
9782 } else if (name === "srcset") {
9783 return getAbsoluteSrcsetString(doc, value);
9784 } else if (name === "style") {
9785 return absolutifyURLs(value, getHref(doc));
9786 } else if (tagName === "object" && name === "data") {
9787 return absoluteToDoc(doc, value);
9788 }
9789 return value;
9790 }
9791 function ignoreAttribute(tagName, name, _value) {
9792 return (tagName === "video" || tagName === "audio") && name === "autoplay";
9793 }
9794 function _isBlockedElement(element, blockClass, blockSelector) {
9795 try {
9796 if (typeof blockClass === "string") {
9797 if (element.classList.contains(blockClass)) {
9798 return true;
9799 }
9800 } else {
9801 for(var eIndex = element.classList.length; eIndex--;){
9802 var className = element.classList[eIndex];
9803 if (blockClass.test(className)) {
9804 return true;
9805 }
9806 }
9807 }
9808 if (blockSelector) {
9809 return element.matches(blockSelector);
9810 }
9811 } catch (e2) {}
9812 return false;
9813 }
9814 function classMatchesRegex(node2, regex, checkAncestors) {
9815 if (!node2) return false;
9816 if (node2.nodeType !== node2.ELEMENT_NODE) {
9817 if (!checkAncestors) return false;
9818 return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
9819 }
9820 for(var eIndex = node2.classList.length; eIndex--;){
9821 var className = node2.classList[eIndex];
9822 if (regex.test(className)) {
9823 return true;
9824 }
9825 }
9826 if (!checkAncestors) return false;
9827 return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
9828 }
9829 function needMaskingText(node2, maskTextClass, maskTextSelector, checkAncestors) {
9830 var el;
9831 if (isElement(node2)) {
9832 el = node2;
9833 if (!index$1.childNodes(el).length) {
9834 return false;
9835 }
9836 } else if (index$1.parentElement(node2) === null) {
9837 return false;
9838 } else {
9839 el = index$1.parentElement(node2);
9840 }
9841 try {
9842 if (typeof maskTextClass === "string") {
9843 if (checkAncestors) {
9844 if (el.closest("." + maskTextClass)) return true;
9845 } else {
9846 if (el.classList.contains(maskTextClass)) return true;
9847 }
9848 } else {
9849 if (classMatchesRegex(el, maskTextClass, checkAncestors)) return true;
9850 }
9851 if (maskTextSelector) {
9852 if (checkAncestors) {
9853 if (el.closest(maskTextSelector)) return true;
9854 } else {
9855 if (el.matches(maskTextSelector)) return true;
9856 }
9857 }
9858 } catch (e2) {}
9859 return false;
9860 }
9861 function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
9862 var win = iframeEl.contentWindow;
9863 if (!win) {
9864 return;
9865 }
9866 var fired = false;
9867 var readyState;
9868 try {
9869 readyState = win.document.readyState;
9870 } catch (error) {
9871 return;
9872 }
9873 if (readyState !== "complete") {
9874 var timer = setTimeout(function() {
9875 if (!fired) {
9876 listener();
9877 fired = true;
9878 }
9879 }, iframeLoadTimeout);
9880 iframeEl.addEventListener("load", function() {
9881 clearTimeout(timer);
9882 fired = true;
9883 listener();
9884 });
9885 return;
9886 }
9887 var blankUrl = "about:blank";
9888 if (win.location.href !== blankUrl || iframeEl.src === blankUrl || iframeEl.src === "") {
9889 setTimeout(listener, 0);
9890 return iframeEl.addEventListener("load", listener);
9891 }
9892 iframeEl.addEventListener("load", listener);
9893 }
9894 function onceStylesheetLoaded(link, listener, styleSheetLoadTimeout) {
9895 var fired = false;
9896 var styleSheetLoaded;
9897 try {
9898 styleSheetLoaded = link.sheet;
9899 } catch (error) {
9900 return;
9901 }
9902 if (styleSheetLoaded) return;
9903 var timer = setTimeout(function() {
9904 if (!fired) {
9905 listener();
9906 fired = true;
9907 }
9908 }, styleSheetLoadTimeout);
9909 link.addEventListener("load", function() {
9910 clearTimeout(timer);
9911 fired = true;
9912 listener();
9913 });
9914 }
9915 function serializeNode(n2, options) {
9916 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;
9917 var rootId = getRootId(doc, mirror2);
9918 switch(n2.nodeType){
9919 case n2.DOCUMENT_NODE:
9920 if (n2.compatMode !== "CSS1Compat") {
9921 return {
9922 type: NodeType$3.Document,
9923 childNodes: [],
9924 compatMode: n2.compatMode
9925 };
9926 } else {
9927 return {
9928 type: NodeType$3.Document,
9929 childNodes: []
9930 };
9931 }
9932 case n2.DOCUMENT_TYPE_NODE:
9933 return {
9934 type: NodeType$3.DocumentType,
9935 name: n2.name,
9936 publicId: n2.publicId,
9937 systemId: n2.systemId,
9938 rootId: rootId
9939 };
9940 case n2.ELEMENT_NODE:
9941 return serializeElementNode(n2, {
9942 doc: doc,
9943 blockClass: blockClass,
9944 blockSelector: blockSelector,
9945 inlineStylesheet: inlineStylesheet,
9946 maskInputOptions: maskInputOptions,
9947 maskInputFn: maskInputFn,
9948 dataURLOptions: dataURLOptions,
9949 inlineImages: inlineImages,
9950 recordCanvas: recordCanvas,
9951 keepIframeSrcFn: keepIframeSrcFn,
9952 newlyAddedElement: newlyAddedElement,
9953 rootId: rootId
9954 });
9955 case n2.TEXT_NODE:
9956 return serializeTextNode(n2, {
9957 doc: doc,
9958 needsMask: needsMask,
9959 maskTextFn: maskTextFn,
9960 rootId: rootId,
9961 cssCaptured: cssCaptured
9962 });
9963 case n2.CDATA_SECTION_NODE:
9964 return {
9965 type: NodeType$3.CDATA,
9966 textContent: "",
9967 rootId: rootId
9968 };
9969 case n2.COMMENT_NODE:
9970 return {
9971 type: NodeType$3.Comment,
9972 textContent: index$1.textContent(n2) || "",
9973 rootId: rootId
9974 };
9975 default:
9976 return false;
9977 }
9978 }
9979 function getRootId(doc, mirror2) {
9980 if (!mirror2.hasNode(doc)) return void 0;
9981 var docId = mirror2.getId(doc);
9982 return docId === 1 ? void 0 : docId;
9983 }
9984 function serializeTextNode(n2, options) {
9985 var needsMask = options.needsMask, maskTextFn = options.maskTextFn, rootId = options.rootId, cssCaptured = options.cssCaptured;
9986 var parent = index$1.parentNode(n2);
9987 var parentTagName = parent && parent.tagName;
9988 var textContent2 = "";
9989 var isStyle = parentTagName === "STYLE" ? true : void 0;
9990 var isScript = parentTagName === "SCRIPT" ? true : void 0;
9991 if (isScript) {
9992 textContent2 = "SCRIPT_PLACEHOLDER";
9993 } else if (!cssCaptured) {
9994 textContent2 = index$1.textContent(n2);
9995 if (isStyle && textContent2) {
9996 textContent2 = absolutifyURLs(textContent2, getHref(options.doc));
9997 }
9998 }
9999 if (!isStyle && !isScript && textContent2 && needsMask) {
10000 textContent2 = maskTextFn ? maskTextFn(textContent2, index$1.parentElement(n2)) : textContent2.replace(/[\S]/g, "*");
10001 }
10002 return {
10003 type: NodeType$3.Text,
10004 textContent: textContent2 || "",
10005 rootId: rootId
10006 };
10007 }
10008 function serializeElementNode(n2, options) {
10009 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;
10010 var needBlock = _isBlockedElement(n2, blockClass, blockSelector);
10011 var tagName = getValidTagName$1(n2);
10012 var attributes = {};
10013 var len = n2.attributes.length;
10014 for(var i2 = 0; i2 < len; i2++){
10015 var attr = n2.attributes[i2];
10016 if (!ignoreAttribute(tagName, attr.name, attr.value)) {
10017 attributes[attr.name] = transformAttribute(doc, tagName, toLowerCase(attr.name), attr.value);
10018 }
10019 }
10020 if (tagName === "link" && inlineStylesheet) {
10021 var stylesheet = Array.from(doc.styleSheets).find(function(s2) {
10022 return s2.href === n2.href;
10023 });
10024 var cssText = null;
10025 if (stylesheet) {
10026 cssText = stringifyStylesheet(stylesheet);
10027 }
10028 if (cssText) {
10029 delete attributes.rel;
10030 delete attributes.href;
10031 attributes._cssText = cssText;
10032 }
10033 }
10034 if (tagName === "style" && n2.sheet) {
10035 var cssText1 = stringifyStylesheet(n2.sheet);
10036 if (cssText1) {
10037 if (n2.childNodes.length > 1) {
10038 cssText1 = markCssSplits(cssText1, n2);
10039 }
10040 attributes._cssText = cssText1;
10041 }
10042 }
10043 if (tagName === "input" || tagName === "textarea" || tagName === "select") {
10044 var value = n2.value;
10045 var checked = n2.checked;
10046 if (attributes.type !== "radio" && attributes.type !== "checkbox" && attributes.type !== "submit" && attributes.type !== "button" && value) {
10047 attributes.value = maskInputValue({
10048 element: n2,
10049 type: getInputType(n2),
10050 tagName: tagName,
10051 value: value,
10052 maskInputOptions: maskInputOptions,
10053 maskInputFn: maskInputFn
10054 });
10055 } else if (checked) {
10056 attributes.checked = checked;
10057 }
10058 }
10059 if (tagName === "option") {
10060 if (n2.selected && !maskInputOptions["select"]) {
10061 attributes.selected = true;
10062 } else {
10063 delete attributes.selected;
10064 }
10065 }
10066 if (tagName === "dialog" && n2.open) {
10067 attributes.rr_open_mode = n2.matches("dialog:modal") ? "modal" : "non-modal";
10068 }
10069 if (tagName === "canvas" && recordCanvas) {
10070 if (n2.__context === "2d") {
10071 if (!is2DCanvasBlank(n2)) {
10072 attributes.rr_dataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
10073 }
10074 } else if (!("__context" in n2)) {
10075 var canvasDataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
10076 var blankCanvas = doc.createElement("canvas");
10077 blankCanvas.width = n2.width;
10078 blankCanvas.height = n2.height;
10079 var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);
10080 if (canvasDataURL !== blankCanvasDataURL) {
10081 attributes.rr_dataURL = canvasDataURL;
10082 }
10083 }
10084 }
10085 if (tagName === "img" && inlineImages) {
10086 if (!canvasService) {
10087 canvasService = doc.createElement("canvas");
10088 canvasCtx = canvasService.getContext("2d");
10089 }
10090 var image = n2;
10091 var imageSrc = image.currentSrc || image.getAttribute("src") || "<unknown-src>";
10092 var priorCrossOrigin = image.crossOrigin;
10093 var recordInlineImage = function() {
10094 image.removeEventListener("load", recordInlineImage);
10095 try {
10096 canvasService.width = image.naturalWidth;
10097 canvasService.height = image.naturalHeight;
10098 canvasCtx.drawImage(image, 0, 0);
10099 attributes.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);
10100 } catch (err) {
10101 if (image.crossOrigin !== "anonymous") {
10102 image.crossOrigin = "anonymous";
10103 if (image.complete && image.naturalWidth !== 0) recordInlineImage();
10104 else image.addEventListener("load", recordInlineImage);
10105 return;
10106 } else {
10107 console.warn("Cannot inline img src=" + imageSrc + "! Error: " + err);
10108 }
10109 }
10110 if (image.crossOrigin === "anonymous") {
10111 priorCrossOrigin ? attributes.crossOrigin = priorCrossOrigin : image.removeAttribute("crossorigin");
10112 }
10113 };
10114 if (image.complete && image.naturalWidth !== 0) recordInlineImage();
10115 else image.addEventListener("load", recordInlineImage);
10116 }
10117 if (tagName === "audio" || tagName === "video") {
10118 var mediaAttributes = attributes;
10119 mediaAttributes.rr_mediaState = n2.paused ? "paused" : "played";
10120 mediaAttributes.rr_mediaCurrentTime = n2.currentTime;
10121 mediaAttributes.rr_mediaPlaybackRate = n2.playbackRate;
10122 mediaAttributes.rr_mediaMuted = n2.muted;
10123 mediaAttributes.rr_mediaLoop = n2.loop;
10124 mediaAttributes.rr_mediaVolume = n2.volume;
10125 }
10126 if (!newlyAddedElement) {
10127 if (n2.scrollLeft) {
10128 attributes.rr_scrollLeft = n2.scrollLeft;
10129 }
10130 if (n2.scrollTop) {
10131 attributes.rr_scrollTop = n2.scrollTop;
10132 }
10133 }
10134 if (needBlock) {
10135 var _n2_getBoundingClientRect = n2.getBoundingClientRect(), width = _n2_getBoundingClientRect.width, height = _n2_getBoundingClientRect.height;
10136 attributes = {
10137 class: attributes.class,
10138 rr_width: "" + width + "px",
10139 rr_height: "" + height + "px"
10140 };
10141 }
10142 if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
10143 if (!n2.contentDocument) {
10144 attributes.rr_src = attributes.src;
10145 }
10146 delete attributes.src;
10147 }
10148 var isCustomElement;
10149 try {
10150 if (customElements.get(tagName)) isCustomElement = true;
10151 } catch (e2) {}
10152 return {
10153 type: NodeType$3.Element,
10154 tagName: tagName,
10155 attributes: attributes,
10156 childNodes: [],
10157 isSVG: isSVGElement(n2) || void 0,
10158 needBlock: needBlock,
10159 rootId: rootId,
10160 isCustom: isCustomElement
10161 };
10162 }
10163 function lowerIfExists(maybeAttr) {
10164 if (maybeAttr === void 0 || maybeAttr === null) {
10165 return "";
10166 } else {
10167 return maybeAttr.toLowerCase();
10168 }
10169 }
10170 function slimDOMExcluded(sn, slimDOMOptions) {
10171 if (slimDOMOptions.comment && sn.type === NodeType$3.Comment) {
10172 return true;
10173 } else if (sn.type === NodeType$3.Element) {
10174 if (slimDOMOptions.script && // script tag
10175 (sn.tagName === "script" || // (module)preload link
10176 sn.tagName === "link" && (sn.attributes.rel === "preload" && sn.attributes.as === "script" || sn.attributes.rel === "modulepreload") || // prefetch link
10177 sn.tagName === "link" && sn.attributes.rel === "prefetch" && typeof sn.attributes.href === "string" && extractFileExtension(sn.attributes.href) === "js")) {
10178 return true;
10179 } 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"))) {
10180 return true;
10181 } else if (sn.tagName === "meta") {
10182 if (slimDOMOptions.headMetaDescKeywords && lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
10183 return true;
10184 } else if (slimDOMOptions.headMetaSocial && (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || // og = opengraph (facebook)
10185 lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || lowerIfExists(sn.attributes.name) === "pinterest")) {
10186 return true;
10187 } else if (slimDOMOptions.headMetaRobots && (lowerIfExists(sn.attributes.name) === "robots" || lowerIfExists(sn.attributes.name) === "googlebot" || lowerIfExists(sn.attributes.name) === "bingbot")) {
10188 return true;
10189 } else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== void 0) {
10190 return true;
10191 } 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:/))) {
10192 return true;
10193 } 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")) {
10194 return true;
10195 }
10196 }
10197 }
10198 return false;
10199 }
10200 function serializeNodeWithId(n2, options) {
10201 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() {
10202 return false;
10203 } : _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;
10204 var needsMask = options.needsMask;
10205 var _options_preserveWhiteSpace = options.preserveWhiteSpace, preserveWhiteSpace = _options_preserveWhiteSpace === void 0 ? true : _options_preserveWhiteSpace;
10206 if (!needsMask) {
10207 var checkAncestors = needsMask === void 0;
10208 needsMask = needMaskingText(n2, maskTextClass, maskTextSelector, checkAncestors);
10209 }
10210 var _serializedNode = serializeNode(n2, {
10211 doc: doc,
10212 mirror: mirror2,
10213 blockClass: blockClass,
10214 blockSelector: blockSelector,
10215 needsMask: needsMask,
10216 inlineStylesheet: inlineStylesheet,
10217 maskInputOptions: maskInputOptions,
10218 maskTextFn: maskTextFn,
10219 maskInputFn: maskInputFn,
10220 dataURLOptions: dataURLOptions,
10221 inlineImages: inlineImages,
10222 recordCanvas: recordCanvas,
10223 keepIframeSrcFn: keepIframeSrcFn,
10224 newlyAddedElement: newlyAddedElement,
10225 cssCaptured: cssCaptured
10226 });
10227 if (!_serializedNode) {
10228 console.warn(n2, "not serialized");
10229 return null;
10230 }
10231 var id;
10232 if (mirror2.hasNode(n2)) {
10233 id = mirror2.getId(n2);
10234 } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType$3.Text && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
10235 id = IGNORED_NODE;
10236 } else {
10237 id = genId();
10238 }
10239 var serializedNode = Object.assign(_serializedNode, {
10240 id: id
10241 });
10242 mirror2.add(n2, serializedNode);
10243 if (id === IGNORED_NODE) {
10244 return null;
10245 }
10246 if (onSerialize) {
10247 onSerialize(n2);
10248 }
10249 var recordChild = !skipChild;
10250 if (serializedNode.type === NodeType$3.Element) {
10251 recordChild = recordChild && !serializedNode.needBlock;
10252 delete serializedNode.needBlock;
10253 var shadowRootEl = index$1.shadowRoot(n2);
10254 if (shadowRootEl && isNativeShadowDom(shadowRootEl)) serializedNode.isShadowHost = true;
10255 }
10256 if ((serializedNode.type === NodeType$3.Document || serializedNode.type === NodeType$3.Element) && recordChild) {
10257 if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType$3.Element && serializedNode.tagName === "head") {
10258 preserveWhiteSpace = false;
10259 }
10260 var bypassOptions = {
10261 doc: doc,
10262 mirror: mirror2,
10263 blockClass: blockClass,
10264 blockSelector: blockSelector,
10265 needsMask: needsMask,
10266 maskTextClass: maskTextClass,
10267 maskTextSelector: maskTextSelector,
10268 skipChild: skipChild,
10269 inlineStylesheet: inlineStylesheet,
10270 maskInputOptions: maskInputOptions,
10271 maskTextFn: maskTextFn,
10272 maskInputFn: maskInputFn,
10273 slimDOMOptions: slimDOMOptions,
10274 dataURLOptions: dataURLOptions,
10275 inlineImages: inlineImages,
10276 recordCanvas: recordCanvas,
10277 preserveWhiteSpace: preserveWhiteSpace,
10278 onSerialize: onSerialize,
10279 onIframeLoad: onIframeLoad,
10280 iframeLoadTimeout: iframeLoadTimeout,
10281 onStylesheetLoad: onStylesheetLoad,
10282 stylesheetLoadTimeout: stylesheetLoadTimeout,
10283 keepIframeSrcFn: keepIframeSrcFn,
10284 cssCaptured: false
10285 };
10286 if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
10287 else {
10288 if (serializedNode.type === NodeType$3.Element && serializedNode.attributes._cssText !== void 0 && typeof serializedNode.attributes._cssText === "string") {
10289 bypassOptions.cssCaptured = true;
10290 }
10291 for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(index$1.childNodes(n2))), _step; !(_step = _iterator()).done;){
10292 var childN = _step.value;
10293 var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
10294 if (serializedChildNode) {
10295 serializedNode.childNodes.push(serializedChildNode);
10296 }
10297 }
10298 }
10299 var shadowRootEl1 = null;
10300 if (isElement(n2) && (shadowRootEl1 = index$1.shadowRoot(n2))) {
10301 for(var _iterator1 = _create_for_of_iterator_helper_loose(Array.from(index$1.childNodes(shadowRootEl1))), _step1; !(_step1 = _iterator1()).done;){
10302 var childN1 = _step1.value;
10303 var serializedChildNode1 = serializeNodeWithId(childN1, bypassOptions);
10304 if (serializedChildNode1) {
10305 isNativeShadowDom(shadowRootEl1) && (serializedChildNode1.isShadow = true);
10306 serializedNode.childNodes.push(serializedChildNode1);
10307 }
10308 }
10309 }
10310 }
10311 var parent = index$1.parentNode(n2);
10312 if (parent && isShadowRoot(parent) && isNativeShadowDom(parent)) {
10313 serializedNode.isShadow = true;
10314 }
10315 if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "iframe") {
10316 onceIframeLoaded(n2, function() {
10317 var iframeDoc = n2.contentDocument;
10318 if (iframeDoc && onIframeLoad) {
10319 var serializedIframeNode = serializeNodeWithId(iframeDoc, {
10320 doc: iframeDoc,
10321 mirror: mirror2,
10322 blockClass: blockClass,
10323 blockSelector: blockSelector,
10324 needsMask: needsMask,
10325 maskTextClass: maskTextClass,
10326 maskTextSelector: maskTextSelector,
10327 skipChild: false,
10328 inlineStylesheet: inlineStylesheet,
10329 maskInputOptions: maskInputOptions,
10330 maskTextFn: maskTextFn,
10331 maskInputFn: maskInputFn,
10332 slimDOMOptions: slimDOMOptions,
10333 dataURLOptions: dataURLOptions,
10334 inlineImages: inlineImages,
10335 recordCanvas: recordCanvas,
10336 preserveWhiteSpace: preserveWhiteSpace,
10337 onSerialize: onSerialize,
10338 onIframeLoad: onIframeLoad,
10339 iframeLoadTimeout: iframeLoadTimeout,
10340 onStylesheetLoad: onStylesheetLoad,
10341 stylesheetLoadTimeout: stylesheetLoadTimeout,
10342 keepIframeSrcFn: keepIframeSrcFn
10343 });
10344 if (serializedIframeNode) {
10345 onIframeLoad(n2, serializedIframeNode);
10346 }
10347 }
10348 }, iframeLoadTimeout);
10349 }
10350 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")) {
10351 onceStylesheetLoaded(n2, function() {
10352 if (onStylesheetLoad) {
10353 var serializedLinkNode = serializeNodeWithId(n2, {
10354 doc: doc,
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 (serializedLinkNode) {
10379 onStylesheetLoad(n2, serializedLinkNode);
10380 }
10381 }
10382 }, stylesheetLoadTimeout);
10383 }
10384 return serializedNode;
10385 }
10386 function snapshot(n2, options) {
10387 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() {
10388 return false;
10389 } : _ref_keepIframeSrcFn;
10390 var maskInputOptions = maskAllInputs === true ? {
10391 color: true,
10392 date: true,
10393 "datetime-local": true,
10394 email: true,
10395 month: true,
10396 number: true,
10397 range: true,
10398 search: true,
10399 tel: true,
10400 text: true,
10401 time: true,
10402 url: true,
10403 week: true,
10404 textarea: true,
10405 select: true,
10406 password: true,
10407 hidden: true
10408 } : maskAllInputs === false ? {
10409 password: true
10410 } : maskAllInputs;
10411 var slimDOMOptions = slimDOM === true || slimDOM === "all" ? // if true: set of sensible options that should not throw away any information
10412 {
10413 script: true,
10414 comment: true,
10415 headFavicon: true,
10416 headWhitespace: true,
10417 headMetaDescKeywords: slimDOM === "all",
10418 // destructive
10419 headMetaSocial: true,
10420 headMetaRobots: true,
10421 headMetaHttpEquiv: true,
10422 headMetaAuthorship: true,
10423 headMetaVerification: true
10424 } : slimDOM === false ? {} : slimDOM;
10425 return serializeNodeWithId(n2, {
10426 doc: n2,
10427 mirror: mirror2,
10428 blockClass: blockClass,
10429 blockSelector: blockSelector,
10430 maskTextClass: maskTextClass,
10431 maskTextSelector: maskTextSelector,
10432 skipChild: false,
10433 inlineStylesheet: inlineStylesheet,
10434 maskInputOptions: maskInputOptions,
10435 maskTextFn: maskTextFn,
10436 maskInputFn: maskInputFn,
10437 slimDOMOptions: slimDOMOptions,
10438 dataURLOptions: dataURLOptions,
10439 inlineImages: inlineImages,
10440 recordCanvas: recordCanvas,
10441 preserveWhiteSpace: preserveWhiteSpace,
10442 onSerialize: onSerialize,
10443 onIframeLoad: onIframeLoad,
10444 iframeLoadTimeout: iframeLoadTimeout,
10445 onStylesheetLoad: onStylesheetLoad,
10446 stylesheetLoadTimeout: stylesheetLoadTimeout,
10447 keepIframeSrcFn: keepIframeSrcFn,
10448 newlyAddedElement: false
10449 });
10450 }
10451 function getDefaultExportFromCjs$1(x2) {
10452 return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
10453 }
10454 function getAugmentedNamespace$1(n2) {
10455 if (n2.__esModule) return n2;
10456 var f2 = n2.default;
10457 if (typeof f2 == "function") {
10458 var a2 = function a22() {
10459 if (_instanceof(this, a22)) {
10460 return Reflect.construct(f2, arguments, this.constructor);
10461 }
10462 return f2.apply(this, arguments);
10463 };
10464 a2.prototype = f2.prototype;
10465 } else a2 = {};
10466 Object.defineProperty(a2, "__esModule", {
10467 value: true
10468 });
10469 Object.keys(n2).forEach(function(k) {
10470 var d = Object.getOwnPropertyDescriptor(n2, k);
10471 Object.defineProperty(a2, k, d.get ? d : {
10472 enumerable: true,
10473 get: function get() {
10474 return n2[k];
10475 }
10476 });
10477 });
10478 return a2;
10479 }
10480 var picocolors_browser$1 = {
10481 exports: {}
10482 };
10483 var x$1 = String;
10484 var create$1 = function create$1() {
10485 return {
10486 isColorSupported: false,
10487 reset: x$1,
10488 bold: x$1,
10489 dim: x$1,
10490 italic: x$1,
10491 underline: x$1,
10492 inverse: x$1,
10493 hidden: x$1,
10494 strikethrough: x$1,
10495 black: x$1,
10496 red: x$1,
10497 green: x$1,
10498 yellow: x$1,
10499 blue: x$1,
10500 magenta: x$1,
10501 cyan: x$1,
10502 white: x$1,
10503 gray: x$1,
10504 bgBlack: x$1,
10505 bgRed: x$1,
10506 bgGreen: x$1,
10507 bgYellow: x$1,
10508 bgBlue: x$1,
10509 bgMagenta: x$1,
10510 bgCyan: x$1,
10511 bgWhite: x$1
10512 };
10513 };
10514 picocolors_browser$1.exports = create$1();
10515 picocolors_browser$1.exports.createColors = create$1;
10516 var picocolors_browserExports$1 = picocolors_browser$1.exports;
10517 var __viteBrowserExternal$2 = {};
10518 var __viteBrowserExternal$1$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10519 __proto__: null,
10520 default: __viteBrowserExternal$2
10521 }, Symbol.toStringTag, {
10522 value: "Module"
10523 }));
10524 var require$$2$1 = /* @__PURE__ */ getAugmentedNamespace$1(__viteBrowserExternal$1$1);
10525 var pico$1 = picocolors_browserExports$1;
10526 var terminalHighlight$1$1 = require$$2$1;
10527 var CssSyntaxError$3$1 = /*#__PURE__*/ function(Error1) {
10528 _inherits(CssSyntaxError, Error1);
10529 function CssSyntaxError(message, line, column, source, file, plugin22) {
10530 var _this;
10531 _this = Error1.call(this, message) || this;
10532 _this.name = "CssSyntaxError";
10533 _this.reason = message;
10534 if (file) {
10535 _this.file = file;
10536 }
10537 if (source) {
10538 _this.source = source;
10539 }
10540 if (plugin22) {
10541 _this.plugin = plugin22;
10542 }
10543 if (typeof line !== "undefined" && typeof column !== "undefined") {
10544 if (typeof line === "number") {
10545 _this.line = line;
10546 _this.column = column;
10547 } else {
10548 _this.line = line.line;
10549 _this.column = line.column;
10550 _this.endLine = column.line;
10551 _this.endColumn = column.column;
10552 }
10553 }
10554 _this.setMessage();
10555 if (Error.captureStackTrace) {
10556 Error.captureStackTrace(_this, CssSyntaxError);
10557 }
10558 return _this;
10559 }
10560 var _proto = CssSyntaxError.prototype;
10561 _proto.setMessage = function setMessage() {
10562 this.message = this.plugin ? this.plugin + ": " : "";
10563 this.message += this.file ? this.file : "<css input>";
10564 if (typeof this.line !== "undefined") {
10565 this.message += ":" + this.line + ":" + this.column;
10566 }
10567 this.message += ": " + this.reason;
10568 };
10569 _proto.showSourceCode = function showSourceCode(color) {
10570 var _this = this;
10571 if (!this.source) return "";
10572 var css = this.source;
10573 if (color == null) color = pico$1.isColorSupported;
10574 if (terminalHighlight$1$1) {
10575 if (color) css = terminalHighlight$1$1(css);
10576 }
10577 var lines = css.split(/\r?\n/);
10578 var start = Math.max(this.line - 3, 0);
10579 var end = Math.min(this.line + 2, lines.length);
10580 var maxWidth = String(end).length;
10581 var mark, aside;
10582 if (color) {
10583 var _pico$1_createColors = pico$1.createColors(true), bold = _pico$1_createColors.bold, gray = _pico$1_createColors.gray, red = _pico$1_createColors.red;
10584 mark = function(text) {
10585 return bold(red(text));
10586 };
10587 aside = function(text) {
10588 return gray(text);
10589 };
10590 } else {
10591 mark = aside = function(str) {
10592 return str;
10593 };
10594 }
10595 return lines.slice(start, end).map(function(line, index2) {
10596 var number = start + 1 + index2;
10597 var gutter = " " + (" " + number).slice(-maxWidth) + " | ";
10598 if (number === _this.line) {
10599 var spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, _this.column - 1).replace(/[^\t]/g, " ");
10600 return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^");
10601 }
10602 return " " + aside(gutter) + line;
10603 }).join("\n");
10604 };
10605 _proto.toString = function toString() {
10606 var code = this.showSourceCode();
10607 if (code) {
10608 code = "\n\n" + code + "\n";
10609 }
10610 return this.name + ": " + this.message + code;
10611 };
10612 return CssSyntaxError;
10613 }(_wrap_native_super(Error));
10614 var cssSyntaxError$1 = CssSyntaxError$3$1;
10615 CssSyntaxError$3$1.default = CssSyntaxError$3$1;
10616 var symbols$1 = {};
10617 symbols$1.isClean = Symbol("isClean");
10618 symbols$1.my = Symbol("my");
10619 var DEFAULT_RAW$1 = {
10620 after: "\n",
10621 beforeClose: "\n",
10622 beforeComment: "\n",
10623 beforeDecl: "\n",
10624 beforeOpen: " ",
10625 beforeRule: "\n",
10626 colon: ": ",
10627 commentLeft: " ",
10628 commentRight: " ",
10629 emptyBody: "",
10630 indent: " ",
10631 semicolon: false
10632 };
10633 function capitalize$1(str) {
10634 return str[0].toUpperCase() + str.slice(1);
10635 }
10636 var Stringifier$2$1 = /*#__PURE__*/ function() {
10637 function Stringifier(builder) {
10638 this.builder = builder;
10639 }
10640 var _proto = Stringifier.prototype;
10641 _proto.atrule = function atrule(node2, semicolon) {
10642 var name = "@" + node2.name;
10643 var params = node2.params ? this.rawValue(node2, "params") : "";
10644 if (typeof node2.raws.afterName !== "undefined") {
10645 name += node2.raws.afterName;
10646 } else if (params) {
10647 name += " ";
10648 }
10649 if (node2.nodes) {
10650 this.block(node2, name + params);
10651 } else {
10652 var end = (node2.raws.between || "") + (semicolon ? ";" : "");
10653 this.builder(name + params + end, node2);
10654 }
10655 };
10656 _proto.beforeAfter = function beforeAfter(node2, detect) {
10657 var value;
10658 if (node2.type === "decl") {
10659 value = this.raw(node2, null, "beforeDecl");
10660 } else if (node2.type === "comment") {
10661 value = this.raw(node2, null, "beforeComment");
10662 } else if (detect === "before") {
10663 value = this.raw(node2, null, "beforeRule");
10664 } else {
10665 value = this.raw(node2, null, "beforeClose");
10666 }
10667 var buf = node2.parent;
10668 var depth = 0;
10669 while(buf && buf.type !== "root"){
10670 depth += 1;
10671 buf = buf.parent;
10672 }
10673 if (value.includes("\n")) {
10674 var indent = this.raw(node2, null, "indent");
10675 if (indent.length) {
10676 for(var step = 0; step < depth; step++)value += indent;
10677 }
10678 }
10679 return value;
10680 };
10681 _proto.block = function block(node2, start) {
10682 var between = this.raw(node2, "between", "beforeOpen");
10683 this.builder(start + between + "{", node2, "start");
10684 var after;
10685 if (node2.nodes && node2.nodes.length) {
10686 this.body(node2);
10687 after = this.raw(node2, "after");
10688 } else {
10689 after = this.raw(node2, "after", "emptyBody");
10690 }
10691 if (after) this.builder(after);
10692 this.builder("}", node2, "end");
10693 };
10694 _proto.body = function body(node2) {
10695 var last = node2.nodes.length - 1;
10696 while(last > 0){
10697 if (node2.nodes[last].type !== "comment") break;
10698 last -= 1;
10699 }
10700 var semicolon = this.raw(node2, "semicolon");
10701 for(var i2 = 0; i2 < node2.nodes.length; i2++){
10702 var child = node2.nodes[i2];
10703 var before = this.raw(child, "before");
10704 if (before) this.builder(before);
10705 this.stringify(child, last !== i2 || semicolon);
10706 }
10707 };
10708 _proto.comment = function comment(node2) {
10709 var left = this.raw(node2, "left", "commentLeft");
10710 var right = this.raw(node2, "right", "commentRight");
10711 this.builder("/*" + left + node2.text + right + "*/", node2);
10712 };
10713 _proto.decl = function decl(node2, semicolon) {
10714 var between = this.raw(node2, "between", "colon");
10715 var string = node2.prop + between + this.rawValue(node2, "value");
10716 if (node2.important) {
10717 string += node2.raws.important || " !important";
10718 }
10719 if (semicolon) string += ";";
10720 this.builder(string, node2);
10721 };
10722 _proto.document = function document1(node2) {
10723 this.body(node2);
10724 };
10725 _proto.raw = function raw(node2, own, detect) {
10726 var value;
10727 if (!detect) detect = own;
10728 if (own) {
10729 value = node2.raws[own];
10730 if (typeof value !== "undefined") return value;
10731 }
10732 var parent = node2.parent;
10733 if (detect === "before") {
10734 if (!parent || parent.type === "root" && parent.first === node2) {
10735 return "";
10736 }
10737 if (parent && parent.type === "document") {
10738 return "";
10739 }
10740 }
10741 if (!parent) return DEFAULT_RAW$1[detect];
10742 var root2 = node2.root();
10743 if (!root2.rawCache) root2.rawCache = {};
10744 if (typeof root2.rawCache[detect] !== "undefined") {
10745 return root2.rawCache[detect];
10746 }
10747 if (detect === "before" || detect === "after") {
10748 return this.beforeAfter(node2, detect);
10749 } else {
10750 var method = "raw" + capitalize$1(detect);
10751 if (this[method]) {
10752 value = this[method](root2, node2);
10753 } else {
10754 root2.walk(function(i2) {
10755 value = i2.raws[own];
10756 if (typeof value !== "undefined") return false;
10757 });
10758 }
10759 }
10760 if (typeof value === "undefined") value = DEFAULT_RAW$1[detect];
10761 root2.rawCache[detect] = value;
10762 return value;
10763 };
10764 _proto.rawBeforeClose = function rawBeforeClose(root2) {
10765 var value;
10766 root2.walk(function(i2) {
10767 if (i2.nodes && i2.nodes.length > 0) {
10768 if (typeof i2.raws.after !== "undefined") {
10769 value = i2.raws.after;
10770 if (value.includes("\n")) {
10771 value = value.replace(/[^\n]+$/, "");
10772 }
10773 return false;
10774 }
10775 }
10776 });
10777 if (value) value = value.replace(/\S/g, "");
10778 return value;
10779 };
10780 _proto.rawBeforeComment = function rawBeforeComment(root2, node2) {
10781 var value;
10782 root2.walkComments(function(i2) {
10783 if (typeof i2.raws.before !== "undefined") {
10784 value = i2.raws.before;
10785 if (value.includes("\n")) {
10786 value = value.replace(/[^\n]+$/, "");
10787 }
10788 return false;
10789 }
10790 });
10791 if (typeof value === "undefined") {
10792 value = this.raw(node2, null, "beforeDecl");
10793 } else if (value) {
10794 value = value.replace(/\S/g, "");
10795 }
10796 return value;
10797 };
10798 _proto.rawBeforeDecl = function rawBeforeDecl(root2, node2) {
10799 var value;
10800 root2.walkDecls(function(i2) {
10801 if (typeof i2.raws.before !== "undefined") {
10802 value = i2.raws.before;
10803 if (value.includes("\n")) {
10804 value = value.replace(/[^\n]+$/, "");
10805 }
10806 return false;
10807 }
10808 });
10809 if (typeof value === "undefined") {
10810 value = this.raw(node2, null, "beforeRule");
10811 } else if (value) {
10812 value = value.replace(/\S/g, "");
10813 }
10814 return value;
10815 };
10816 _proto.rawBeforeOpen = function rawBeforeOpen(root2) {
10817 var value;
10818 root2.walk(function(i2) {
10819 if (i2.type !== "decl") {
10820 value = i2.raws.between;
10821 if (typeof value !== "undefined") return false;
10822 }
10823 });
10824 return value;
10825 };
10826 _proto.rawBeforeRule = function rawBeforeRule(root2) {
10827 var value;
10828 root2.walk(function(i2) {
10829 if (i2.nodes && (i2.parent !== root2 || root2.first !== i2)) {
10830 if (typeof i2.raws.before !== "undefined") {
10831 value = i2.raws.before;
10832 if (value.includes("\n")) {
10833 value = value.replace(/[^\n]+$/, "");
10834 }
10835 return false;
10836 }
10837 }
10838 });
10839 if (value) value = value.replace(/\S/g, "");
10840 return value;
10841 };
10842 _proto.rawColon = function rawColon(root2) {
10843 var value;
10844 root2.walkDecls(function(i2) {
10845 if (typeof i2.raws.between !== "undefined") {
10846 value = i2.raws.between.replace(/[^\s:]/g, "");
10847 return false;
10848 }
10849 });
10850 return value;
10851 };
10852 _proto.rawEmptyBody = function rawEmptyBody(root2) {
10853 var value;
10854 root2.walk(function(i2) {
10855 if (i2.nodes && i2.nodes.length === 0) {
10856 value = i2.raws.after;
10857 if (typeof value !== "undefined") return false;
10858 }
10859 });
10860 return value;
10861 };
10862 _proto.rawIndent = function rawIndent(root2) {
10863 if (root2.raws.indent) return root2.raws.indent;
10864 var value;
10865 root2.walk(function(i2) {
10866 var p = i2.parent;
10867 if (p && p !== root2 && p.parent && p.parent === root2) {
10868 if (typeof i2.raws.before !== "undefined") {
10869 var parts = i2.raws.before.split("\n");
10870 value = parts[parts.length - 1];
10871 value = value.replace(/\S/g, "");
10872 return false;
10873 }
10874 }
10875 });
10876 return value;
10877 };
10878 _proto.rawSemicolon = function rawSemicolon(root2) {
10879 var value;
10880 root2.walk(function(i2) {
10881 if (i2.nodes && i2.nodes.length && i2.last.type === "decl") {
10882 value = i2.raws.semicolon;
10883 if (typeof value !== "undefined") return false;
10884 }
10885 });
10886 return value;
10887 };
10888 _proto.rawValue = function rawValue(node2, prop) {
10889 var value = node2[prop];
10890 var raw = node2.raws[prop];
10891 if (raw && raw.value === value) {
10892 return raw.raw;
10893 }
10894 return value;
10895 };
10896 _proto.root = function root(node2) {
10897 this.body(node2);
10898 if (node2.raws.after) this.builder(node2.raws.after);
10899 };
10900 _proto.rule = function rule(node2) {
10901 this.block(node2, this.rawValue(node2, "selector"));
10902 if (node2.raws.ownSemicolon) {
10903 this.builder(node2.raws.ownSemicolon, node2, "end");
10904 }
10905 };
10906 _proto.stringify = function stringify(node2, semicolon) {
10907 if (!this[node2.type]) {
10908 throw new Error("Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier.");
10909 }
10910 this[node2.type](node2, semicolon);
10911 };
10912 return Stringifier;
10913 }();
10914 var stringifier$1 = Stringifier$2$1;
10915 Stringifier$2$1.default = Stringifier$2$1;
10916 var Stringifier$1$1 = stringifier$1;
10917 function stringify$4$1(node2, builder) {
10918 var str = new Stringifier$1$1(builder);
10919 str.stringify(node2);
10920 }
10921 var stringify_1$1 = stringify$4$1;
10922 stringify$4$1.default = stringify$4$1;
10923 var isClean$2$1 = symbols$1.isClean, my$2$1 = symbols$1.my;
10924 var CssSyntaxError$2$1 = cssSyntaxError$1;
10925 var Stringifier2$1 = stringifier$1;
10926 var stringify$3$1 = stringify_1$1;
10927 function cloneNode$1(obj, parent) {
10928 var cloned = new obj.constructor();
10929 for(var i2 in obj){
10930 if (!Object.prototype.hasOwnProperty.call(obj, i2)) {
10931 continue;
10932 }
10933 if (i2 === "proxyCache") continue;
10934 var value = obj[i2];
10935 var type = typeof value === "undefined" ? "undefined" : _type_of(value);
10936 if (i2 === "parent" && type === "object") {
10937 if (parent) cloned[i2] = parent;
10938 } else if (i2 === "source") {
10939 cloned[i2] = value;
10940 } else if (Array.isArray(value)) {
10941 cloned[i2] = value.map(function(j) {
10942 return cloneNode$1(j, cloned);
10943 });
10944 } else {
10945 if (type === "object" && value !== null) value = cloneNode$1(value);
10946 cloned[i2] = value;
10947 }
10948 }
10949 return cloned;
10950 }
10951 var Node$4$1 = /*#__PURE__*/ function() {
10952 function Node2(defaults) {
10953 if (defaults === void 0) defaults = {};
10954 this.raws = {};
10955 this[isClean$2$1] = false;
10956 this[my$2$1] = true;
10957 for(var name in defaults){
10958 if (name === "nodes") {
10959 this.nodes = [];
10960 for(var _iterator = _create_for_of_iterator_helper_loose(defaults[name]), _step; !(_step = _iterator()).done;){
10961 var node2 = _step.value;
10962 if (typeof node2.clone === "function") {
10963 this.append(node2.clone());
10964 } else {
10965 this.append(node2);
10966 }
10967 }
10968 } else {
10969 this[name] = defaults[name];
10970 }
10971 }
10972 }
10973 var _proto = Node2.prototype;
10974 _proto.addToError = function addToError(error) {
10975 error.postcssNode = this;
10976 if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
10977 var s2 = this.source;
10978 error.stack = error.stack.replace(/\n\s{4}at /, "$&" + s2.input.from + ":" + s2.start.line + ":" + s2.start.column + "$&");
10979 }
10980 return error;
10981 };
10982 _proto.after = function after(add) {
10983 this.parent.insertAfter(this, add);
10984 return this;
10985 };
10986 _proto.assign = function assign(overrides) {
10987 if (overrides === void 0) overrides = {};
10988 for(var name in overrides){
10989 this[name] = overrides[name];
10990 }
10991 return this;
10992 };
10993 _proto.before = function before(add) {
10994 this.parent.insertBefore(this, add);
10995 return this;
10996 };
10997 _proto.cleanRaws = function cleanRaws(keepBetween) {
10998 delete this.raws.before;
10999 delete this.raws.after;
11000 if (!keepBetween) delete this.raws.between;
11001 };
11002 _proto.clone = function clone(overrides) {
11003 if (overrides === void 0) overrides = {};
11004 var cloned = cloneNode$1(this);
11005 for(var name in overrides){
11006 cloned[name] = overrides[name];
11007 }
11008 return cloned;
11009 };
11010 _proto.cloneAfter = function cloneAfter(overrides) {
11011 if (overrides === void 0) overrides = {};
11012 var cloned = this.clone(overrides);
11013 this.parent.insertAfter(this, cloned);
11014 return cloned;
11015 };
11016 _proto.cloneBefore = function cloneBefore(overrides) {
11017 if (overrides === void 0) overrides = {};
11018 var cloned = this.clone(overrides);
11019 this.parent.insertBefore(this, cloned);
11020 return cloned;
11021 };
11022 _proto.error = function error(message, opts) {
11023 if (opts === void 0) opts = {};
11024 if (this.source) {
11025 var _this_rangeBy = this.rangeBy(opts), end = _this_rangeBy.end, start = _this_rangeBy.start;
11026 return this.source.input.error(message, {
11027 column: start.column,
11028 line: start.line
11029 }, {
11030 column: end.column,
11031 line: end.line
11032 }, opts);
11033 }
11034 return new CssSyntaxError$2$1(message);
11035 };
11036 _proto.getProxyProcessor = function getProxyProcessor() {
11037 return {
11038 get: function get(node2, prop) {
11039 if (prop === "proxyOf") {
11040 return node2;
11041 } else if (prop === "root") {
11042 return function() {
11043 return node2.root().toProxy();
11044 };
11045 } else {
11046 return node2[prop];
11047 }
11048 },
11049 set: function set(node2, prop, value) {
11050 if (node2[prop] === value) return true;
11051 node2[prop] = value;
11052 if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ prop === "text") {
11053 node2.markDirty();
11054 }
11055 return true;
11056 }
11057 };
11058 };
11059 _proto.markDirty = function markDirty() {
11060 if (this[isClean$2$1]) {
11061 this[isClean$2$1] = false;
11062 var next = this;
11063 while(next = next.parent){
11064 next[isClean$2$1] = false;
11065 }
11066 }
11067 };
11068 _proto.next = function next() {
11069 if (!this.parent) return void 0;
11070 var index2 = this.parent.index(this);
11071 return this.parent.nodes[index2 + 1];
11072 };
11073 _proto.positionBy = function positionBy(opts, stringRepresentation) {
11074 var pos = this.source.start;
11075 if (opts.index) {
11076 pos = this.positionInside(opts.index, stringRepresentation);
11077 } else if (opts.word) {
11078 stringRepresentation = this.toString();
11079 var index2 = stringRepresentation.indexOf(opts.word);
11080 if (index2 !== -1) pos = this.positionInside(index2, stringRepresentation);
11081 }
11082 return pos;
11083 };
11084 _proto.positionInside = function positionInside(index2, stringRepresentation) {
11085 var string = stringRepresentation || this.toString();
11086 var column = this.source.start.column;
11087 var line = this.source.start.line;
11088 for(var i2 = 0; i2 < index2; i2++){
11089 if (string[i2] === "\n") {
11090 column = 1;
11091 line += 1;
11092 } else {
11093 column += 1;
11094 }
11095 }
11096 return {
11097 column: column,
11098 line: line
11099 };
11100 };
11101 _proto.prev = function prev() {
11102 if (!this.parent) return void 0;
11103 var index2 = this.parent.index(this);
11104 return this.parent.nodes[index2 - 1];
11105 };
11106 _proto.rangeBy = function rangeBy(opts) {
11107 var start = {
11108 column: this.source.start.column,
11109 line: this.source.start.line
11110 };
11111 var end = this.source.end ? {
11112 column: this.source.end.column + 1,
11113 line: this.source.end.line
11114 } : {
11115 column: start.column + 1,
11116 line: start.line
11117 };
11118 if (opts.word) {
11119 var stringRepresentation = this.toString();
11120 var index2 = stringRepresentation.indexOf(opts.word);
11121 if (index2 !== -1) {
11122 start = this.positionInside(index2, stringRepresentation);
11123 end = this.positionInside(index2 + opts.word.length, stringRepresentation);
11124 }
11125 } else {
11126 if (opts.start) {
11127 start = {
11128 column: opts.start.column,
11129 line: opts.start.line
11130 };
11131 } else if (opts.index) {
11132 start = this.positionInside(opts.index);
11133 }
11134 if (opts.end) {
11135 end = {
11136 column: opts.end.column,
11137 line: opts.end.line
11138 };
11139 } else if (typeof opts.endIndex === "number") {
11140 end = this.positionInside(opts.endIndex);
11141 } else if (opts.index) {
11142 end = this.positionInside(opts.index + 1);
11143 }
11144 }
11145 if (end.line < start.line || end.line === start.line && end.column <= start.column) {
11146 end = {
11147 column: start.column + 1,
11148 line: start.line
11149 };
11150 }
11151 return {
11152 end: end,
11153 start: start
11154 };
11155 };
11156 _proto.raw = function raw(prop, defaultType) {
11157 var str = new Stringifier2$1();
11158 return str.raw(this, prop, defaultType);
11159 };
11160 _proto.remove = function remove() {
11161 if (this.parent) {
11162 this.parent.removeChild(this);
11163 }
11164 this.parent = void 0;
11165 return this;
11166 };
11167 _proto.replaceWith = function replaceWith() {
11168 for(var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++){
11169 nodes[_key] = arguments[_key];
11170 }
11171 if (this.parent) {
11172 var bookmark = this;
11173 var foundSelf = false;
11174 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
11175 var node2 = _step.value;
11176 if (node2 === this) {
11177 foundSelf = true;
11178 } else if (foundSelf) {
11179 this.parent.insertAfter(bookmark, node2);
11180 bookmark = node2;
11181 } else {
11182 this.parent.insertBefore(bookmark, node2);
11183 }
11184 }
11185 if (!foundSelf) {
11186 this.remove();
11187 }
11188 }
11189 return this;
11190 };
11191 _proto.root = function root() {
11192 var result2 = this;
11193 while(result2.parent && result2.parent.type !== "document"){
11194 result2 = result2.parent;
11195 }
11196 return result2;
11197 };
11198 _proto.toJSON = function toJSON(_, inputs) {
11199 var fixed = {};
11200 var emitInputs = inputs == null;
11201 inputs = inputs || /* @__PURE__ */ new Map();
11202 var inputsNextIndex = 0;
11203 for(var name in this){
11204 if (!Object.prototype.hasOwnProperty.call(this, name)) {
11205 continue;
11206 }
11207 if (name === "parent" || name === "proxyCache") continue;
11208 var value = this[name];
11209 if (Array.isArray(value)) {
11210 fixed[name] = value.map(function(i2) {
11211 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.toJSON) {
11212 return i2.toJSON(null, inputs);
11213 } else {
11214 return i2;
11215 }
11216 });
11217 } else if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value.toJSON) {
11218 fixed[name] = value.toJSON(null, inputs);
11219 } else if (name === "source") {
11220 var inputId = inputs.get(value.input);
11221 if (inputId == null) {
11222 inputId = inputsNextIndex;
11223 inputs.set(value.input, inputsNextIndex);
11224 inputsNextIndex++;
11225 }
11226 fixed[name] = {
11227 end: value.end,
11228 inputId: inputId,
11229 start: value.start
11230 };
11231 } else {
11232 fixed[name] = value;
11233 }
11234 }
11235 if (emitInputs) {
11236 fixed.inputs = [].concat(inputs.keys()).map(function(input2) {
11237 return input2.toJSON();
11238 });
11239 }
11240 return fixed;
11241 };
11242 _proto.toProxy = function toProxy() {
11243 if (!this.proxyCache) {
11244 this.proxyCache = new Proxy(this, this.getProxyProcessor());
11245 }
11246 return this.proxyCache;
11247 };
11248 _proto.toString = function toString(stringifier2) {
11249 if (stringifier2 === void 0) stringifier2 = stringify$3$1;
11250 if (stringifier2.stringify) stringifier2 = stringifier2.stringify;
11251 var result2 = "";
11252 stringifier2(this, function(i2) {
11253 result2 += i2;
11254 });
11255 return result2;
11256 };
11257 _proto.warn = function warn(result2, text, opts) {
11258 var data = {
11259 node: this
11260 };
11261 for(var i2 in opts)data[i2] = opts[i2];
11262 return result2.warn(text, data);
11263 };
11264 _create_class(Node2, [
11265 {
11266 key: "proxyOf",
11267 get: function get() {
11268 return this;
11269 }
11270 }
11271 ]);
11272 return Node2;
11273 }();
11274 var node$1 = Node$4$1;
11275 Node$4$1.default = Node$4$1;
11276 var Node$3$1 = node$1;
11277 var Declaration$4$1 = /*#__PURE__*/ function(Node$3$1) {
11278 _inherits(Declaration, Node$3$1);
11279 function Declaration(defaults) {
11280 var _this;
11281 if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
11282 defaults = _extends({}, defaults, {
11283 value: String(defaults.value)
11284 });
11285 }
11286 _this = Node$3$1.call(this, defaults) || this;
11287 _this.type = "decl";
11288 return _this;
11289 }
11290 _create_class(Declaration, [
11291 {
11292 key: "variable",
11293 get: function get() {
11294 return this.prop.startsWith("--") || this.prop[0] === "$";
11295 }
11296 }
11297 ]);
11298 return Declaration;
11299 }(Node$3$1);
11300 var declaration$1 = Declaration$4$1;
11301 Declaration$4$1.default = Declaration$4$1;
11302 var urlAlphabet$1 = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
11303 var nanoid$1$1 = function(size) {
11304 if (size === void 0) size = 21;
11305 var id = "";
11306 var i2 = size;
11307 while(i2--){
11308 id += urlAlphabet$1[Math.random() * 64 | 0];
11309 }
11310 return id;
11311 };
11312 var nonSecure$1 = {
11313 nanoid: nanoid$1$1};
11314 var SourceMapConsumer$2$1 = require$$2$1.SourceMapConsumer, SourceMapGenerator$2$1 = require$$2$1.SourceMapGenerator;
11315 var existsSync$1 = require$$2$1.existsSync, readFileSync$1 = require$$2$1.readFileSync;
11316 var dirname$1$1 = require$$2$1.dirname, join$1 = require$$2$1.join;
11317 function fromBase64$1(str) {
11318 if (Buffer) {
11319 return Buffer.from(str, "base64").toString();
11320 } else {
11321 return window.atob(str);
11322 }
11323 }
11324 var PreviousMap$2$1 = /*#__PURE__*/ function() {
11325 function PreviousMap(css, opts) {
11326 if (opts.map === false) return;
11327 this.loadAnnotation(css);
11328 this.inline = this.startWith(this.annotation, "data:");
11329 var prev = opts.map ? opts.map.prev : void 0;
11330 var text = this.loadMap(opts.from, prev);
11331 if (!this.mapFile && opts.from) {
11332 this.mapFile = opts.from;
11333 }
11334 if (this.mapFile) this.root = dirname$1$1(this.mapFile);
11335 if (text) this.text = text;
11336 }
11337 var _proto = PreviousMap.prototype;
11338 _proto.consumer = function consumer() {
11339 if (!this.consumerCache) {
11340 this.consumerCache = new SourceMapConsumer$2$1(this.text);
11341 }
11342 return this.consumerCache;
11343 };
11344 _proto.decodeInline = function decodeInline(text) {
11345 var baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
11346 var baseUri = /^data:application\/json;base64,/;
11347 var charsetUri = /^data:application\/json;charset=utf-?8,/;
11348 var uri = /^data:application\/json,/;
11349 if (charsetUri.test(text) || uri.test(text)) {
11350 return decodeURIComponent(text.substr(RegExp.lastMatch.length));
11351 }
11352 if (baseCharsetUri.test(text) || baseUri.test(text)) {
11353 return fromBase64$1(text.substr(RegExp.lastMatch.length));
11354 }
11355 var encoding = text.match(/data:application\/json;([^,]+),/)[1];
11356 throw new Error("Unsupported source map encoding " + encoding);
11357 };
11358 _proto.getAnnotationURL = function getAnnotationURL(sourceMapString) {
11359 return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
11360 };
11361 _proto.isMap = function isMap(map) {
11362 if ((typeof map === "undefined" ? "undefined" : _type_of(map)) !== "object") return false;
11363 return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
11364 };
11365 _proto.loadAnnotation = function loadAnnotation(css) {
11366 var comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
11367 if (!comments) return;
11368 var start = css.lastIndexOf(comments.pop());
11369 var end = css.indexOf("*/", start);
11370 if (start > -1 && end > -1) {
11371 this.annotation = this.getAnnotationURL(css.substring(start, end));
11372 }
11373 };
11374 _proto.loadFile = function loadFile(path) {
11375 this.root = dirname$1$1(path);
11376 if (existsSync$1(path)) {
11377 this.mapFile = path;
11378 return readFileSync$1(path, "utf-8").toString().trim();
11379 }
11380 };
11381 _proto.loadMap = function loadMap(file, prev) {
11382 if (prev === false) return false;
11383 if (prev) {
11384 if (typeof prev === "string") {
11385 return prev;
11386 } else if (typeof prev === "function") {
11387 var prevPath = prev(file);
11388 if (prevPath) {
11389 var map = this.loadFile(prevPath);
11390 if (!map) {
11391 throw new Error("Unable to load previous source map: " + prevPath.toString());
11392 }
11393 return map;
11394 }
11395 } else if (_instanceof(prev, SourceMapConsumer$2$1)) {
11396 return SourceMapGenerator$2$1.fromSourceMap(prev).toString();
11397 } else if (_instanceof(prev, SourceMapGenerator$2$1)) {
11398 return prev.toString();
11399 } else if (this.isMap(prev)) {
11400 return JSON.stringify(prev);
11401 } else {
11402 throw new Error("Unsupported previous source map format: " + prev.toString());
11403 }
11404 } else if (this.inline) {
11405 return this.decodeInline(this.annotation);
11406 } else if (this.annotation) {
11407 var map1 = this.annotation;
11408 if (file) map1 = join$1(dirname$1$1(file), map1);
11409 return this.loadFile(map1);
11410 }
11411 };
11412 _proto.startWith = function startWith(string, start) {
11413 if (!string) return false;
11414 return string.substr(0, start.length) === start;
11415 };
11416 _proto.withContent = function withContent() {
11417 return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
11418 };
11419 return PreviousMap;
11420 }();
11421 var previousMap$1 = PreviousMap$2$1;
11422 PreviousMap$2$1.default = PreviousMap$2$1;
11423 var SourceMapConsumer$1$1 = require$$2$1.SourceMapConsumer, SourceMapGenerator$1$1 = require$$2$1.SourceMapGenerator;
11424 var fileURLToPath$1 = require$$2$1.fileURLToPath, pathToFileURL$1$1 = require$$2$1.pathToFileURL;
11425 var isAbsolute$1 = require$$2$1.isAbsolute, resolve$1$1 = require$$2$1.resolve;
11426 var nanoid$2 = nonSecure$1.nanoid;
11427 var terminalHighlight$2 = require$$2$1;
11428 var CssSyntaxError$1$1 = cssSyntaxError$1;
11429 var PreviousMap$1$1 = previousMap$1;
11430 var fromOffsetCache$1 = Symbol("fromOffsetCache");
11431 var sourceMapAvailable$1$1 = Boolean(SourceMapConsumer$1$1 && SourceMapGenerator$1$1);
11432 var pathAvailable$1$1 = Boolean(resolve$1$1 && isAbsolute$1);
11433 var Input$4$1 = /*#__PURE__*/ function() {
11434 function Input(css, opts) {
11435 if (opts === void 0) opts = {};
11436 if (css === null || typeof css === "undefined" || (typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && !css.toString) {
11437 throw new Error("PostCSS received " + css + " instead of CSS string");
11438 }
11439 this.css = css.toString();
11440 if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
11441 this.hasBOM = true;
11442 this.css = this.css.slice(1);
11443 } else {
11444 this.hasBOM = false;
11445 }
11446 if (opts.from) {
11447 if (!pathAvailable$1$1 || /^\w+:\/\//.test(opts.from) || isAbsolute$1(opts.from)) {
11448 this.file = opts.from;
11449 } else {
11450 this.file = resolve$1$1(opts.from);
11451 }
11452 }
11453 if (pathAvailable$1$1 && sourceMapAvailable$1$1) {
11454 var map = new PreviousMap$1$1(this.css, opts);
11455 if (map.text) {
11456 this.map = map;
11457 var file = map.consumer().file;
11458 if (!this.file && file) this.file = this.mapResolve(file);
11459 }
11460 }
11461 if (!this.file) {
11462 this.id = "<input css " + nanoid$2(6) + ">";
11463 }
11464 if (this.map) this.map.file = this.from;
11465 }
11466 var _proto = Input.prototype;
11467 _proto.error = function error(message, line, column, opts) {
11468 if (opts === void 0) opts = {};
11469 var result2, endLine, endColumn;
11470 if (line && (typeof line === "undefined" ? "undefined" : _type_of(line)) === "object") {
11471 var start = line;
11472 var end = column;
11473 if (typeof start.offset === "number") {
11474 var pos = this.fromOffset(start.offset);
11475 line = pos.line;
11476 column = pos.col;
11477 } else {
11478 line = start.line;
11479 column = start.column;
11480 }
11481 if (typeof end.offset === "number") {
11482 var pos1 = this.fromOffset(end.offset);
11483 endLine = pos1.line;
11484 endColumn = pos1.col;
11485 } else {
11486 endLine = end.line;
11487 endColumn = end.column;
11488 }
11489 } else if (!column) {
11490 var pos2 = this.fromOffset(line);
11491 line = pos2.line;
11492 column = pos2.col;
11493 }
11494 var origin = this.origin(line, column, endLine, endColumn);
11495 if (origin) {
11496 result2 = new CssSyntaxError$1$1(message, origin.endLine === void 0 ? origin.line : {
11497 column: origin.column,
11498 line: origin.line
11499 }, origin.endLine === void 0 ? origin.column : {
11500 column: origin.endColumn,
11501 line: origin.endLine
11502 }, origin.source, origin.file, opts.plugin);
11503 } else {
11504 result2 = new CssSyntaxError$1$1(message, endLine === void 0 ? line : {
11505 column: column,
11506 line: line
11507 }, endLine === void 0 ? column : {
11508 column: endColumn,
11509 line: endLine
11510 }, this.css, this.file, opts.plugin);
11511 }
11512 result2.input = {
11513 column: column,
11514 endColumn: endColumn,
11515 endLine: endLine,
11516 line: line,
11517 source: this.css
11518 };
11519 if (this.file) {
11520 if (pathToFileURL$1$1) {
11521 result2.input.url = pathToFileURL$1$1(this.file).toString();
11522 }
11523 result2.input.file = this.file;
11524 }
11525 return result2;
11526 };
11527 _proto.fromOffset = function fromOffset(offset) {
11528 var lastLine, lineToIndex;
11529 if (!this[fromOffsetCache$1]) {
11530 var lines = this.css.split("\n");
11531 lineToIndex = new Array(lines.length);
11532 var prevIndex = 0;
11533 for(var i2 = 0, l2 = lines.length; i2 < l2; i2++){
11534 lineToIndex[i2] = prevIndex;
11535 prevIndex += lines[i2].length + 1;
11536 }
11537 this[fromOffsetCache$1] = lineToIndex;
11538 } else {
11539 lineToIndex = this[fromOffsetCache$1];
11540 }
11541 lastLine = lineToIndex[lineToIndex.length - 1];
11542 var min = 0;
11543 if (offset >= lastLine) {
11544 min = lineToIndex.length - 1;
11545 } else {
11546 var max = lineToIndex.length - 2;
11547 var mid;
11548 while(min < max){
11549 mid = min + (max - min >> 1);
11550 if (offset < lineToIndex[mid]) {
11551 max = mid - 1;
11552 } else if (offset >= lineToIndex[mid + 1]) {
11553 min = mid + 1;
11554 } else {
11555 min = mid;
11556 break;
11557 }
11558 }
11559 }
11560 return {
11561 col: offset - lineToIndex[min] + 1,
11562 line: min + 1
11563 };
11564 };
11565 _proto.mapResolve = function mapResolve(file) {
11566 if (/^\w+:\/\//.test(file)) {
11567 return file;
11568 }
11569 return resolve$1$1(this.map.consumer().sourceRoot || this.map.root || ".", file);
11570 };
11571 _proto.origin = function origin(line, column, endLine, endColumn) {
11572 if (!this.map) return false;
11573 var consumer = this.map.consumer();
11574 var from = consumer.originalPositionFor({
11575 column: column,
11576 line: line
11577 });
11578 if (!from.source) return false;
11579 var to;
11580 if (typeof endLine === "number") {
11581 to = consumer.originalPositionFor({
11582 column: endColumn,
11583 line: endLine
11584 });
11585 }
11586 var fromUrl;
11587 if (isAbsolute$1(from.source)) {
11588 fromUrl = pathToFileURL$1$1(from.source);
11589 } else {
11590 fromUrl = new URL(from.source, this.map.consumer().sourceRoot || pathToFileURL$1$1(this.map.mapFile));
11591 }
11592 var result2 = {
11593 column: from.column,
11594 endColumn: to && to.column,
11595 endLine: to && to.line,
11596 line: from.line,
11597 url: fromUrl.toString()
11598 };
11599 if (fromUrl.protocol === "file:") {
11600 if (fileURLToPath$1) {
11601 result2.file = fileURLToPath$1(fromUrl);
11602 } else {
11603 throw new Error("file: protocol is not available in this PostCSS build");
11604 }
11605 }
11606 var source = consumer.sourceContentFor(from.source);
11607 if (source) result2.source = source;
11608 return result2;
11609 };
11610 _proto.toJSON = function toJSON() {
11611 var json = {};
11612 for(var _i = 0, _iter = [
11613 "hasBOM",
11614 "css",
11615 "file",
11616 "id"
11617 ]; _i < _iter.length; _i++){
11618 var name = _iter[_i];
11619 if (this[name] != null) {
11620 json[name] = this[name];
11621 }
11622 }
11623 if (this.map) {
11624 json.map = _extends({}, this.map);
11625 if (json.map.consumerCache) {
11626 json.map.consumerCache = void 0;
11627 }
11628 }
11629 return json;
11630 };
11631 _create_class(Input, [
11632 {
11633 key: "from",
11634 get: function get() {
11635 return this.file || this.id;
11636 }
11637 }
11638 ]);
11639 return Input;
11640 }();
11641 var input$1 = Input$4$1;
11642 Input$4$1.default = Input$4$1;
11643 if (terminalHighlight$2 && terminalHighlight$2.registerInput) {
11644 terminalHighlight$2.registerInput(Input$4$1);
11645 }
11646 var SourceMapConsumer$3 = require$$2$1.SourceMapConsumer, SourceMapGenerator$3 = require$$2$1.SourceMapGenerator;
11647 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;
11648 var pathToFileURL$2 = require$$2$1.pathToFileURL;
11649 var Input$3$1 = input$1;
11650 var sourceMapAvailable$2 = Boolean(SourceMapConsumer$3 && SourceMapGenerator$3);
11651 var pathAvailable$2 = Boolean(dirname$2 && resolve$2 && relative$1 && sep$1);
11652 var MapGenerator$2$1 = /*#__PURE__*/ function() {
11653 function MapGenerator(stringify2, root2, opts, cssString) {
11654 this.stringify = stringify2;
11655 this.mapOpts = opts.map || {};
11656 this.root = root2;
11657 this.opts = opts;
11658 this.css = cssString;
11659 this.originalCSS = cssString;
11660 this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
11661 this.memoizedFileURLs = /* @__PURE__ */ new Map();
11662 this.memoizedPaths = /* @__PURE__ */ new Map();
11663 this.memoizedURLs = /* @__PURE__ */ new Map();
11664 }
11665 var _proto = MapGenerator.prototype;
11666 _proto.addAnnotation = function addAnnotation() {
11667 var content;
11668 if (this.isInline()) {
11669 content = "data:application/json;base64," + this.toBase64(this.map.toString());
11670 } else if (typeof this.mapOpts.annotation === "string") {
11671 content = this.mapOpts.annotation;
11672 } else if (typeof this.mapOpts.annotation === "function") {
11673 content = this.mapOpts.annotation(this.opts.to, this.root);
11674 } else {
11675 content = this.outputFile() + ".map";
11676 }
11677 var eol = "\n";
11678 if (this.css.includes("\r\n")) eol = "\r\n";
11679 this.css += eol + "/*# sourceMappingURL=" + content + " */";
11680 };
11681 _proto.applyPrevMaps = function applyPrevMaps() {
11682 for(var _iterator = _create_for_of_iterator_helper_loose(this.previous()), _step; !(_step = _iterator()).done;){
11683 var prev = _step.value;
11684 var from = this.toUrl(this.path(prev.file));
11685 var root2 = prev.root || dirname$2(prev.file);
11686 var map = void 0;
11687 if (this.mapOpts.sourcesContent === false) {
11688 map = new SourceMapConsumer$3(prev.text);
11689 if (map.sourcesContent) {
11690 map.sourcesContent = null;
11691 }
11692 } else {
11693 map = prev.consumer();
11694 }
11695 this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
11696 }
11697 };
11698 _proto.clearAnnotation = function clearAnnotation() {
11699 if (this.mapOpts.annotation === false) return;
11700 if (this.root) {
11701 var node2;
11702 for(var i2 = this.root.nodes.length - 1; i2 >= 0; i2--){
11703 node2 = this.root.nodes[i2];
11704 if (node2.type !== "comment") continue;
11705 if (node2.text.indexOf("# sourceMappingURL=") === 0) {
11706 this.root.removeChild(i2);
11707 }
11708 }
11709 } else if (this.css) {
11710 this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, "");
11711 }
11712 };
11713 _proto.generate = function generate() {
11714 this.clearAnnotation();
11715 if (pathAvailable$2 && sourceMapAvailable$2 && this.isMap()) {
11716 return this.generateMap();
11717 } else {
11718 var result2 = "";
11719 this.stringify(this.root, function(i2) {
11720 result2 += i2;
11721 });
11722 return [
11723 result2
11724 ];
11725 }
11726 };
11727 _proto.generateMap = function generateMap() {
11728 if (this.root) {
11729 this.generateString();
11730 } else if (this.previous().length === 1) {
11731 var prev = this.previous()[0].consumer();
11732 prev.file = this.outputFile();
11733 this.map = SourceMapGenerator$3.fromSourceMap(prev, {
11734 ignoreInvalidMapping: true
11735 });
11736 } else {
11737 this.map = new SourceMapGenerator$3({
11738 file: this.outputFile(),
11739 ignoreInvalidMapping: true
11740 });
11741 this.map.addMapping({
11742 generated: {
11743 column: 0,
11744 line: 1
11745 },
11746 original: {
11747 column: 0,
11748 line: 1
11749 },
11750 source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
11751 });
11752 }
11753 if (this.isSourcesContent()) this.setSourcesContent();
11754 if (this.root && this.previous().length > 0) this.applyPrevMaps();
11755 if (this.isAnnotation()) this.addAnnotation();
11756 if (this.isInline()) {
11757 return [
11758 this.css
11759 ];
11760 } else {
11761 return [
11762 this.css,
11763 this.map
11764 ];
11765 }
11766 };
11767 _proto.generateString = function generateString() {
11768 var _this = this;
11769 this.css = "";
11770 this.map = new SourceMapGenerator$3({
11771 file: this.outputFile(),
11772 ignoreInvalidMapping: true
11773 });
11774 var line = 1;
11775 var column = 1;
11776 var noSource = "<no source>";
11777 var mapping = {
11778 generated: {
11779 column: 0,
11780 line: 0
11781 },
11782 original: {
11783 column: 0,
11784 line: 0
11785 },
11786 source: ""
11787 };
11788 var lines, last;
11789 this.stringify(this.root, function(str, node2, type) {
11790 _this.css += str;
11791 if (node2 && type !== "end") {
11792 mapping.generated.line = line;
11793 mapping.generated.column = column - 1;
11794 if (node2.source && node2.source.start) {
11795 mapping.source = _this.sourcePath(node2);
11796 mapping.original.line = node2.source.start.line;
11797 mapping.original.column = node2.source.start.column - 1;
11798 _this.map.addMapping(mapping);
11799 } else {
11800 mapping.source = noSource;
11801 mapping.original.line = 1;
11802 mapping.original.column = 0;
11803 _this.map.addMapping(mapping);
11804 }
11805 }
11806 lines = str.match(/\n/g);
11807 if (lines) {
11808 line += lines.length;
11809 last = str.lastIndexOf("\n");
11810 column = str.length - last;
11811 } else {
11812 column += str.length;
11813 }
11814 if (node2 && type !== "start") {
11815 var p = node2.parent || {
11816 raws: {}
11817 };
11818 var childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
11819 if (!childless || node2 !== p.last || p.raws.semicolon) {
11820 if (node2.source && node2.source.end) {
11821 mapping.source = _this.sourcePath(node2);
11822 mapping.original.line = node2.source.end.line;
11823 mapping.original.column = node2.source.end.column - 1;
11824 mapping.generated.line = line;
11825 mapping.generated.column = column - 2;
11826 _this.map.addMapping(mapping);
11827 } else {
11828 mapping.source = noSource;
11829 mapping.original.line = 1;
11830 mapping.original.column = 0;
11831 mapping.generated.line = line;
11832 mapping.generated.column = column - 1;
11833 _this.map.addMapping(mapping);
11834 }
11835 }
11836 }
11837 });
11838 };
11839 _proto.isAnnotation = function isAnnotation() {
11840 if (this.isInline()) {
11841 return true;
11842 }
11843 if (typeof this.mapOpts.annotation !== "undefined") {
11844 return this.mapOpts.annotation;
11845 }
11846 if (this.previous().length) {
11847 return this.previous().some(function(i2) {
11848 return i2.annotation;
11849 });
11850 }
11851 return true;
11852 };
11853 _proto.isInline = function isInline() {
11854 if (typeof this.mapOpts.inline !== "undefined") {
11855 return this.mapOpts.inline;
11856 }
11857 var annotation = this.mapOpts.annotation;
11858 if (typeof annotation !== "undefined" && annotation !== true) {
11859 return false;
11860 }
11861 if (this.previous().length) {
11862 return this.previous().some(function(i2) {
11863 return i2.inline;
11864 });
11865 }
11866 return true;
11867 };
11868 _proto.isMap = function isMap() {
11869 if (typeof this.opts.map !== "undefined") {
11870 return !!this.opts.map;
11871 }
11872 return this.previous().length > 0;
11873 };
11874 _proto.isSourcesContent = function isSourcesContent() {
11875 if (typeof this.mapOpts.sourcesContent !== "undefined") {
11876 return this.mapOpts.sourcesContent;
11877 }
11878 if (this.previous().length) {
11879 return this.previous().some(function(i2) {
11880 return i2.withContent();
11881 });
11882 }
11883 return true;
11884 };
11885 _proto.outputFile = function outputFile() {
11886 if (this.opts.to) {
11887 return this.path(this.opts.to);
11888 } else if (this.opts.from) {
11889 return this.path(this.opts.from);
11890 } else {
11891 return "to.css";
11892 }
11893 };
11894 _proto.path = function path(file) {
11895 if (this.mapOpts.absolute) return file;
11896 if (file.charCodeAt(0) === 60) return file;
11897 if (/^\w+:\/\//.test(file)) return file;
11898 var cached = this.memoizedPaths.get(file);
11899 if (cached) return cached;
11900 var from = this.opts.to ? dirname$2(this.opts.to) : ".";
11901 if (typeof this.mapOpts.annotation === "string") {
11902 from = dirname$2(resolve$2(from, this.mapOpts.annotation));
11903 }
11904 var path = relative$1(from, file);
11905 this.memoizedPaths.set(file, path);
11906 return path;
11907 };
11908 _proto.previous = function previous() {
11909 var _this = this;
11910 if (!this.previousMaps) {
11911 this.previousMaps = [];
11912 if (this.root) {
11913 this.root.walk(function(node2) {
11914 if (node2.source && node2.source.input.map) {
11915 var map = node2.source.input.map;
11916 if (!_this.previousMaps.includes(map)) {
11917 _this.previousMaps.push(map);
11918 }
11919 }
11920 });
11921 } else {
11922 var input2 = new Input$3$1(this.originalCSS, this.opts);
11923 if (input2.map) this.previousMaps.push(input2.map);
11924 }
11925 }
11926 return this.previousMaps;
11927 };
11928 _proto.setSourcesContent = function setSourcesContent() {
11929 var _this = this;
11930 var already = {};
11931 if (this.root) {
11932 this.root.walk(function(node2) {
11933 if (node2.source) {
11934 var from = node2.source.input.from;
11935 if (from && !already[from]) {
11936 already[from] = true;
11937 var fromUrl = _this.usesFileUrls ? _this.toFileUrl(from) : _this.toUrl(_this.path(from));
11938 _this.map.setSourceContent(fromUrl, node2.source.input.css);
11939 }
11940 }
11941 });
11942 } else if (this.css) {
11943 var from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
11944 this.map.setSourceContent(from, this.css);
11945 }
11946 };
11947 _proto.sourcePath = function sourcePath(node2) {
11948 if (this.mapOpts.from) {
11949 return this.toUrl(this.mapOpts.from);
11950 } else if (this.usesFileUrls) {
11951 return this.toFileUrl(node2.source.input.from);
11952 } else {
11953 return this.toUrl(this.path(node2.source.input.from));
11954 }
11955 };
11956 _proto.toBase64 = function toBase64(str) {
11957 if (Buffer) {
11958 return Buffer.from(str).toString("base64");
11959 } else {
11960 return window.btoa(unescape(encodeURIComponent(str)));
11961 }
11962 };
11963 _proto.toFileUrl = function toFileUrl(path) {
11964 var cached = this.memoizedFileURLs.get(path);
11965 if (cached) return cached;
11966 if (pathToFileURL$2) {
11967 var fileURL = pathToFileURL$2(path).toString();
11968 this.memoizedFileURLs.set(path, fileURL);
11969 return fileURL;
11970 } else {
11971 throw new Error("`map.absolute` option is not available in this PostCSS build");
11972 }
11973 };
11974 _proto.toUrl = function toUrl(path) {
11975 var cached = this.memoizedURLs.get(path);
11976 if (cached) return cached;
11977 if (sep$1 === "\\") {
11978 path = path.replace(/\\/g, "/");
11979 }
11980 var url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
11981 this.memoizedURLs.set(path, url);
11982 return url;
11983 };
11984 return MapGenerator;
11985 }();
11986 var mapGenerator$1 = MapGenerator$2$1;
11987 var Node$2$1 = node$1;
11988 var Comment$4$1 = /*#__PURE__*/ function(Node$2$1) {
11989 _inherits(Comment, Node$2$1);
11990 function Comment(defaults) {
11991 var _this;
11992 _this = Node$2$1.call(this, defaults) || this;
11993 _this.type = "comment";
11994 return _this;
11995 }
11996 return Comment;
11997 }(Node$2$1);
11998 var comment$1 = Comment$4$1;
11999 Comment$4$1.default = Comment$4$1;
12000 var isClean$1$1 = symbols$1.isClean, my$1$1 = symbols$1.my;
12001 var Declaration$3$1 = declaration$1;
12002 var Comment$3$1 = comment$1;
12003 var Node$1$1 = node$1;
12004 var parse$4$1, Rule$4$1, AtRule$4$1, Root$6$1;
12005 function cleanSource$1(nodes) {
12006 return nodes.map(function(i2) {
12007 if (i2.nodes) i2.nodes = cleanSource$1(i2.nodes);
12008 delete i2.source;
12009 return i2;
12010 });
12011 }
12012 function markDirtyUp$1(node2) {
12013 node2[isClean$1$1] = false;
12014 if (node2.proxyOf.nodes) {
12015 for(var _iterator = _create_for_of_iterator_helper_loose(node2.proxyOf.nodes), _step; !(_step = _iterator()).done;){
12016 var i2 = _step.value;
12017 markDirtyUp$1(i2);
12018 }
12019 }
12020 }
12021 var Container$7$1 = /*#__PURE__*/ function(Node$1$1) {
12022 _inherits(Container, Node$1$1);
12023 function Container() {
12024 return Node$1$1.apply(this, arguments) || this;
12025 }
12026 var _proto = Container.prototype;
12027 _proto.append = function append() {
12028 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12029 children[_key] = arguments[_key];
12030 }
12031 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
12032 var child = _step.value;
12033 var nodes = this.normalize(child, this.last);
12034 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
12035 var node2 = _step1.value;
12036 this.proxyOf.nodes.push(node2);
12037 }
12038 }
12039 this.markDirty();
12040 return this;
12041 };
12042 _proto.cleanRaws = function cleanRaws(keepBetween) {
12043 Node$1$1.prototype.cleanRaws.call(this, keepBetween);
12044 if (this.nodes) {
12045 for(var _iterator = _create_for_of_iterator_helper_loose(this.nodes), _step; !(_step = _iterator()).done;){
12046 var node2 = _step.value;
12047 node2.cleanRaws(keepBetween);
12048 }
12049 }
12050 };
12051 _proto.each = function each(callback) {
12052 if (!this.proxyOf.nodes) return void 0;
12053 var iterator = this.getIterator();
12054 var index2, result2;
12055 while(this.indexes[iterator] < this.proxyOf.nodes.length){
12056 index2 = this.indexes[iterator];
12057 result2 = callback(this.proxyOf.nodes[index2], index2);
12058 if (result2 === false) break;
12059 this.indexes[iterator] += 1;
12060 }
12061 delete this.indexes[iterator];
12062 return result2;
12063 };
12064 _proto.every = function every(condition) {
12065 return this.nodes.every(condition);
12066 };
12067 _proto.getIterator = function getIterator() {
12068 if (!this.lastEach) this.lastEach = 0;
12069 if (!this.indexes) this.indexes = {};
12070 this.lastEach += 1;
12071 var iterator = this.lastEach;
12072 this.indexes[iterator] = 0;
12073 return iterator;
12074 };
12075 _proto.getProxyProcessor = function getProxyProcessor() {
12076 return {
12077 get: function get(node2, prop) {
12078 if (prop === "proxyOf") {
12079 return node2;
12080 } else if (!node2[prop]) {
12081 return node2[prop];
12082 } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
12083 return function() {
12084 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
12085 args[_key] = arguments[_key];
12086 }
12087 var _node2;
12088 return (_node2 = node2)[prop].apply(_node2, [].concat(args.map(function(i2) {
12089 if (typeof i2 === "function") {
12090 return function(child, index2) {
12091 return i2(child.toProxy(), index2);
12092 };
12093 } else {
12094 return i2;
12095 }
12096 })));
12097 };
12098 } else if (prop === "every" || prop === "some") {
12099 return function(cb) {
12100 return node2[prop](function(child) {
12101 for(var _len = arguments.length, other = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
12102 other[_key - 1] = arguments[_key];
12103 }
12104 return cb.apply(void 0, [].concat([
12105 child.toProxy()
12106 ], other));
12107 });
12108 };
12109 } else if (prop === "root") {
12110 return function() {
12111 return node2.root().toProxy();
12112 };
12113 } else if (prop === "nodes") {
12114 return node2.nodes.map(function(i2) {
12115 return i2.toProxy();
12116 });
12117 } else if (prop === "first" || prop === "last") {
12118 return node2[prop].toProxy();
12119 } else {
12120 return node2[prop];
12121 }
12122 },
12123 set: function set(node2, prop, value) {
12124 if (node2[prop] === value) return true;
12125 node2[prop] = value;
12126 if (prop === "name" || prop === "params" || prop === "selector") {
12127 node2.markDirty();
12128 }
12129 return true;
12130 }
12131 };
12132 };
12133 _proto.index = function index(child) {
12134 if (typeof child === "number") return child;
12135 if (child.proxyOf) child = child.proxyOf;
12136 return this.proxyOf.nodes.indexOf(child);
12137 };
12138 _proto.insertAfter = function insertAfter(exist, add) {
12139 var existIndex = this.index(exist);
12140 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
12141 existIndex = this.index(exist);
12142 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12143 var node2 = _step.value;
12144 this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
12145 }
12146 var index2;
12147 for(var id in this.indexes){
12148 index2 = this.indexes[id];
12149 if (existIndex < index2) {
12150 this.indexes[id] = index2 + nodes.length;
12151 }
12152 }
12153 this.markDirty();
12154 return this;
12155 };
12156 _proto.insertBefore = function insertBefore(exist, add) {
12157 var existIndex = this.index(exist);
12158 var type = existIndex === 0 ? "prepend" : false;
12159 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
12160 existIndex = this.index(exist);
12161 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12162 var node2 = _step.value;
12163 this.proxyOf.nodes.splice(existIndex, 0, node2);
12164 }
12165 var index2;
12166 for(var id in this.indexes){
12167 index2 = this.indexes[id];
12168 if (existIndex <= index2) {
12169 this.indexes[id] = index2 + nodes.length;
12170 }
12171 }
12172 this.markDirty();
12173 return this;
12174 };
12175 _proto.normalize = function normalize(nodes, sample) {
12176 var _this = this;
12177 if (typeof nodes === "string") {
12178 nodes = cleanSource$1(parse$4$1(nodes).nodes);
12179 } else if (typeof nodes === "undefined") {
12180 nodes = [];
12181 } else if (Array.isArray(nodes)) {
12182 nodes = nodes.slice(0);
12183 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12184 var i2 = _step.value;
12185 if (i2.parent) i2.parent.removeChild(i2, "ignore");
12186 }
12187 } else if (nodes.type === "root" && this.type !== "document") {
12188 nodes = nodes.nodes.slice(0);
12189 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
12190 var i21 = _step1.value;
12191 if (i21.parent) i21.parent.removeChild(i21, "ignore");
12192 }
12193 } else if (nodes.type) {
12194 nodes = [
12195 nodes
12196 ];
12197 } else if (nodes.prop) {
12198 if (typeof nodes.value === "undefined") {
12199 throw new Error("Value field is missed in node creation");
12200 } else if (typeof nodes.value !== "string") {
12201 nodes.value = String(nodes.value);
12202 }
12203 nodes = [
12204 new Declaration$3$1(nodes)
12205 ];
12206 } else if (nodes.selector) {
12207 nodes = [
12208 new Rule$4$1(nodes)
12209 ];
12210 } else if (nodes.name) {
12211 nodes = [
12212 new AtRule$4$1(nodes)
12213 ];
12214 } else if (nodes.text) {
12215 nodes = [
12216 new Comment$3$1(nodes)
12217 ];
12218 } else {
12219 throw new Error("Unknown node type in node creation");
12220 }
12221 var processed = nodes.map(function(i2) {
12222 if (!i2[my$1$1]) Container.rebuild(i2);
12223 i2 = i2.proxyOf;
12224 if (i2.parent) i2.parent.removeChild(i2);
12225 if (i2[isClean$1$1]) markDirtyUp$1(i2);
12226 if (typeof i2.raws.before === "undefined") {
12227 if (sample && typeof sample.raws.before !== "undefined") {
12228 i2.raws.before = sample.raws.before.replace(/\S/g, "");
12229 }
12230 }
12231 i2.parent = _this.proxyOf;
12232 return i2;
12233 });
12234 return processed;
12235 };
12236 _proto.prepend = function prepend() {
12237 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12238 children[_key] = arguments[_key];
12239 }
12240 children = children.reverse();
12241 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
12242 var child = _step.value;
12243 var nodes = this.normalize(child, this.first, "prepend").reverse();
12244 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
12245 var node2 = _step1.value;
12246 this.proxyOf.nodes.unshift(node2);
12247 }
12248 for(var id in this.indexes){
12249 this.indexes[id] = this.indexes[id] + nodes.length;
12250 }
12251 }
12252 this.markDirty();
12253 return this;
12254 };
12255 _proto.push = function push(child) {
12256 child.parent = this;
12257 this.proxyOf.nodes.push(child);
12258 return this;
12259 };
12260 _proto.removeAll = function removeAll() {
12261 for(var _iterator = _create_for_of_iterator_helper_loose(this.proxyOf.nodes), _step; !(_step = _iterator()).done;){
12262 var node2 = _step.value;
12263 node2.parent = void 0;
12264 }
12265 this.proxyOf.nodes = [];
12266 this.markDirty();
12267 return this;
12268 };
12269 _proto.removeChild = function removeChild(child) {
12270 child = this.index(child);
12271 this.proxyOf.nodes[child].parent = void 0;
12272 this.proxyOf.nodes.splice(child, 1);
12273 var index2;
12274 for(var id in this.indexes){
12275 index2 = this.indexes[id];
12276 if (index2 >= child) {
12277 this.indexes[id] = index2 - 1;
12278 }
12279 }
12280 this.markDirty();
12281 return this;
12282 };
12283 _proto.replaceValues = function replaceValues(pattern, opts, callback) {
12284 if (!callback) {
12285 callback = opts;
12286 opts = {};
12287 }
12288 this.walkDecls(function(decl) {
12289 if (opts.props && !opts.props.includes(decl.prop)) return;
12290 if (opts.fast && !decl.value.includes(opts.fast)) return;
12291 decl.value = decl.value.replace(pattern, callback);
12292 });
12293 this.markDirty();
12294 return this;
12295 };
12296 _proto.some = function some(condition) {
12297 return this.nodes.some(condition);
12298 };
12299 _proto.walk = function walk(callback) {
12300 return this.each(function(child, i2) {
12301 var result2;
12302 try {
12303 result2 = callback(child, i2);
12304 } catch (e2) {
12305 throw child.addToError(e2);
12306 }
12307 if (result2 !== false && child.walk) {
12308 result2 = child.walk(callback);
12309 }
12310 return result2;
12311 });
12312 };
12313 _proto.walkAtRules = function walkAtRules(name, callback) {
12314 if (!callback) {
12315 callback = name;
12316 return this.walk(function(child, i2) {
12317 if (child.type === "atrule") {
12318 return callback(child, i2);
12319 }
12320 });
12321 }
12322 if (_instanceof(name, RegExp)) {
12323 return this.walk(function(child, i2) {
12324 if (child.type === "atrule" && name.test(child.name)) {
12325 return callback(child, i2);
12326 }
12327 });
12328 }
12329 return this.walk(function(child, i2) {
12330 if (child.type === "atrule" && child.name === name) {
12331 return callback(child, i2);
12332 }
12333 });
12334 };
12335 _proto.walkComments = function walkComments(callback) {
12336 return this.walk(function(child, i2) {
12337 if (child.type === "comment") {
12338 return callback(child, i2);
12339 }
12340 });
12341 };
12342 _proto.walkDecls = function walkDecls(prop, callback) {
12343 if (!callback) {
12344 callback = prop;
12345 return this.walk(function(child, i2) {
12346 if (child.type === "decl") {
12347 return callback(child, i2);
12348 }
12349 });
12350 }
12351 if (_instanceof(prop, RegExp)) {
12352 return this.walk(function(child, i2) {
12353 if (child.type === "decl" && prop.test(child.prop)) {
12354 return callback(child, i2);
12355 }
12356 });
12357 }
12358 return this.walk(function(child, i2) {
12359 if (child.type === "decl" && child.prop === prop) {
12360 return callback(child, i2);
12361 }
12362 });
12363 };
12364 _proto.walkRules = function walkRules(selector, callback) {
12365 if (!callback) {
12366 callback = selector;
12367 return this.walk(function(child, i2) {
12368 if (child.type === "rule") {
12369 return callback(child, i2);
12370 }
12371 });
12372 }
12373 if (_instanceof(selector, RegExp)) {
12374 return this.walk(function(child, i2) {
12375 if (child.type === "rule" && selector.test(child.selector)) {
12376 return callback(child, i2);
12377 }
12378 });
12379 }
12380 return this.walk(function(child, i2) {
12381 if (child.type === "rule" && child.selector === selector) {
12382 return callback(child, i2);
12383 }
12384 });
12385 };
12386 _create_class(Container, [
12387 {
12388 key: "first",
12389 get: function get() {
12390 if (!this.proxyOf.nodes) return void 0;
12391 return this.proxyOf.nodes[0];
12392 }
12393 },
12394 {
12395 key: "last",
12396 get: function get() {
12397 if (!this.proxyOf.nodes) return void 0;
12398 return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
12399 }
12400 }
12401 ]);
12402 return Container;
12403 }(Node$1$1);
12404 Container$7$1.registerParse = function(dependant) {
12405 parse$4$1 = dependant;
12406 };
12407 Container$7$1.registerRule = function(dependant) {
12408 Rule$4$1 = dependant;
12409 };
12410 Container$7$1.registerAtRule = function(dependant) {
12411 AtRule$4$1 = dependant;
12412 };
12413 Container$7$1.registerRoot = function(dependant) {
12414 Root$6$1 = dependant;
12415 };
12416 var container$1 = Container$7$1;
12417 Container$7$1.default = Container$7$1;
12418 Container$7$1.rebuild = function(node2) {
12419 if (node2.type === "atrule") {
12420 Object.setPrototypeOf(node2, AtRule$4$1.prototype);
12421 } else if (node2.type === "rule") {
12422 Object.setPrototypeOf(node2, Rule$4$1.prototype);
12423 } else if (node2.type === "decl") {
12424 Object.setPrototypeOf(node2, Declaration$3$1.prototype);
12425 } else if (node2.type === "comment") {
12426 Object.setPrototypeOf(node2, Comment$3$1.prototype);
12427 } else if (node2.type === "root") {
12428 Object.setPrototypeOf(node2, Root$6$1.prototype);
12429 }
12430 node2[my$1$1] = true;
12431 if (node2.nodes) {
12432 node2.nodes.forEach(function(child) {
12433 Container$7$1.rebuild(child);
12434 });
12435 }
12436 };
12437 var Container$6$1 = container$1;
12438 var LazyResult$4$1, Processor$3$1;
12439 var Document$3$1 = /*#__PURE__*/ function(Container$6$1) {
12440 _inherits(Document2, Container$6$1);
12441 function Document2(defaults) {
12442 var _this;
12443 _this = Container$6$1.call(this, _extends({
12444 type: "document"
12445 }, defaults)) || this;
12446 if (!_this.nodes) {
12447 _this.nodes = [];
12448 }
12449 return _this;
12450 }
12451 var _proto = Document2.prototype;
12452 _proto.toResult = function toResult(opts) {
12453 if (opts === void 0) opts = {};
12454 var lazy = new LazyResult$4$1(new Processor$3$1(), this, opts);
12455 return lazy.stringify();
12456 };
12457 return Document2;
12458 }(Container$6$1);
12459 Document$3$1.registerLazyResult = function(dependant) {
12460 LazyResult$4$1 = dependant;
12461 };
12462 Document$3$1.registerProcessor = function(dependant) {
12463 Processor$3$1 = dependant;
12464 };
12465 var document$1$1 = Document$3$1;
12466 Document$3$1.default = Document$3$1;
12467 var printed$1 = {};
12468 var warnOnce$2$1 = function warnOnce(message) {
12469 if (printed$1[message]) return;
12470 printed$1[message] = true;
12471 if (typeof console !== "undefined" && console.warn) {
12472 console.warn(message);
12473 }
12474 };
12475 var Warning$2$1 = /*#__PURE__*/ function() {
12476 function Warning(text, opts) {
12477 if (opts === void 0) opts = {};
12478 this.type = "warning";
12479 this.text = text;
12480 if (opts.node && opts.node.source) {
12481 var range = opts.node.rangeBy(opts);
12482 this.line = range.start.line;
12483 this.column = range.start.column;
12484 this.endLine = range.end.line;
12485 this.endColumn = range.end.column;
12486 }
12487 for(var opt in opts)this[opt] = opts[opt];
12488 }
12489 var _proto = Warning.prototype;
12490 _proto.toString = function toString() {
12491 if (this.node) {
12492 return this.node.error(this.text, {
12493 index: this.index,
12494 plugin: this.plugin,
12495 word: this.word
12496 }).message;
12497 }
12498 if (this.plugin) {
12499 return this.plugin + ": " + this.text;
12500 }
12501 return this.text;
12502 };
12503 return Warning;
12504 }();
12505 var warning$1 = Warning$2$1;
12506 Warning$2$1.default = Warning$2$1;
12507 var Warning$1$1 = warning$1;
12508 var Result$3$1 = /*#__PURE__*/ function() {
12509 function Result(processor2, root2, opts) {
12510 this.processor = processor2;
12511 this.messages = [];
12512 this.root = root2;
12513 this.opts = opts;
12514 this.css = void 0;
12515 this.map = void 0;
12516 }
12517 var _proto = Result.prototype;
12518 _proto.toString = function toString() {
12519 return this.css;
12520 };
12521 _proto.warn = function warn(text, opts) {
12522 if (opts === void 0) opts = {};
12523 if (!opts.plugin) {
12524 if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
12525 opts.plugin = this.lastPlugin.postcssPlugin;
12526 }
12527 }
12528 var warning2 = new Warning$1$1(text, opts);
12529 this.messages.push(warning2);
12530 return warning2;
12531 };
12532 _proto.warnings = function warnings() {
12533 return this.messages.filter(function(i2) {
12534 return i2.type === "warning";
12535 });
12536 };
12537 _create_class(Result, [
12538 {
12539 key: "content",
12540 get: function get() {
12541 return this.css;
12542 }
12543 }
12544 ]);
12545 return Result;
12546 }();
12547 var result$1 = Result$3$1;
12548 Result$3$1.default = Result$3$1;
12549 var SINGLE_QUOTE$1 = "'".charCodeAt(0);
12550 var DOUBLE_QUOTE$1 = '"'.charCodeAt(0);
12551 var BACKSLASH$1 = "\\".charCodeAt(0);
12552 var SLASH$1 = "/".charCodeAt(0);
12553 var NEWLINE$1 = "\n".charCodeAt(0);
12554 var SPACE$1 = " ".charCodeAt(0);
12555 var FEED$1 = "\f".charCodeAt(0);
12556 var TAB$1 = " ".charCodeAt(0);
12557 var CR$1 = "\r".charCodeAt(0);
12558 var OPEN_SQUARE$1 = "[".charCodeAt(0);
12559 var CLOSE_SQUARE$1 = "]".charCodeAt(0);
12560 var OPEN_PARENTHESES$1 = "(".charCodeAt(0);
12561 var CLOSE_PARENTHESES$1 = ")".charCodeAt(0);
12562 var OPEN_CURLY$1 = "{".charCodeAt(0);
12563 var CLOSE_CURLY$1 = "}".charCodeAt(0);
12564 var SEMICOLON$1 = ";".charCodeAt(0);
12565 var ASTERISK$1 = "*".charCodeAt(0);
12566 var COLON$1 = ":".charCodeAt(0);
12567 var AT$1 = "@".charCodeAt(0);
12568 var RE_AT_END$1 = /[\t\n\f\r "#'()/;[\\\]{}]/g;
12569 var RE_WORD_END$1 = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
12570 var RE_BAD_BRACKET$1 = /.[\r\n"'(/\\]/;
12571 var RE_HEX_ESCAPE$1 = /[\da-f]/i;
12572 var tokenize$1 = function tokenizer(input2, options) {
12573 if (options === void 0) options = {};
12574 var css = input2.css.valueOf();
12575 var ignore = options.ignoreErrors;
12576 var code, next, quote, content, escape;
12577 var escaped, escapePos, prev, n2, currentToken;
12578 var length = css.length;
12579 var pos = 0;
12580 var buffer = [];
12581 var returned = [];
12582 function position() {
12583 return pos;
12584 }
12585 function unclosed(what) {
12586 throw input2.error("Unclosed " + what, pos);
12587 }
12588 function endOfFile() {
12589 return returned.length === 0 && pos >= length;
12590 }
12591 function nextToken(opts) {
12592 if (returned.length) return returned.pop();
12593 if (pos >= length) return;
12594 var ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
12595 code = css.charCodeAt(pos);
12596 switch(code){
12597 case NEWLINE$1:
12598 case SPACE$1:
12599 case TAB$1:
12600 case CR$1:
12601 case FEED$1:
12602 {
12603 next = pos;
12604 do {
12605 next += 1;
12606 code = css.charCodeAt(next);
12607 }while (code === SPACE$1 || code === NEWLINE$1 || code === TAB$1 || code === CR$1 || code === FEED$1);
12608 currentToken = [
12609 "space",
12610 css.slice(pos, next)
12611 ];
12612 pos = next - 1;
12613 break;
12614 }
12615 case OPEN_SQUARE$1:
12616 case CLOSE_SQUARE$1:
12617 case OPEN_CURLY$1:
12618 case CLOSE_CURLY$1:
12619 case COLON$1:
12620 case SEMICOLON$1:
12621 case CLOSE_PARENTHESES$1:
12622 {
12623 var controlChar = String.fromCharCode(code);
12624 currentToken = [
12625 controlChar,
12626 controlChar,
12627 pos
12628 ];
12629 break;
12630 }
12631 case OPEN_PARENTHESES$1:
12632 {
12633 prev = buffer.length ? buffer.pop()[1] : "";
12634 n2 = css.charCodeAt(pos + 1);
12635 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) {
12636 next = pos;
12637 do {
12638 escaped = false;
12639 next = css.indexOf(")", next + 1);
12640 if (next === -1) {
12641 if (ignore || ignoreUnclosed) {
12642 next = pos;
12643 break;
12644 } else {
12645 unclosed("bracket");
12646 }
12647 }
12648 escapePos = next;
12649 while(css.charCodeAt(escapePos - 1) === BACKSLASH$1){
12650 escapePos -= 1;
12651 escaped = !escaped;
12652 }
12653 }while (escaped);
12654 currentToken = [
12655 "brackets",
12656 css.slice(pos, next + 1),
12657 pos,
12658 next
12659 ];
12660 pos = next;
12661 } else {
12662 next = css.indexOf(")", pos + 1);
12663 content = css.slice(pos, next + 1);
12664 if (next === -1 || RE_BAD_BRACKET$1.test(content)) {
12665 currentToken = [
12666 "(",
12667 "(",
12668 pos
12669 ];
12670 } else {
12671 currentToken = [
12672 "brackets",
12673 content,
12674 pos,
12675 next
12676 ];
12677 pos = next;
12678 }
12679 }
12680 break;
12681 }
12682 case SINGLE_QUOTE$1:
12683 case DOUBLE_QUOTE$1:
12684 {
12685 quote = code === SINGLE_QUOTE$1 ? "'" : '"';
12686 next = pos;
12687 do {
12688 escaped = false;
12689 next = css.indexOf(quote, next + 1);
12690 if (next === -1) {
12691 if (ignore || ignoreUnclosed) {
12692 next = pos + 1;
12693 break;
12694 } else {
12695 unclosed("string");
12696 }
12697 }
12698 escapePos = next;
12699 while(css.charCodeAt(escapePos - 1) === BACKSLASH$1){
12700 escapePos -= 1;
12701 escaped = !escaped;
12702 }
12703 }while (escaped);
12704 currentToken = [
12705 "string",
12706 css.slice(pos, next + 1),
12707 pos,
12708 next
12709 ];
12710 pos = next;
12711 break;
12712 }
12713 case AT$1:
12714 {
12715 RE_AT_END$1.lastIndex = pos + 1;
12716 RE_AT_END$1.test(css);
12717 if (RE_AT_END$1.lastIndex === 0) {
12718 next = css.length - 1;
12719 } else {
12720 next = RE_AT_END$1.lastIndex - 2;
12721 }
12722 currentToken = [
12723 "at-word",
12724 css.slice(pos, next + 1),
12725 pos,
12726 next
12727 ];
12728 pos = next;
12729 break;
12730 }
12731 case BACKSLASH$1:
12732 {
12733 next = pos;
12734 escape = true;
12735 while(css.charCodeAt(next + 1) === BACKSLASH$1){
12736 next += 1;
12737 escape = !escape;
12738 }
12739 code = css.charCodeAt(next + 1);
12740 if (escape && code !== SLASH$1 && code !== SPACE$1 && code !== NEWLINE$1 && code !== TAB$1 && code !== CR$1 && code !== FEED$1) {
12741 next += 1;
12742 if (RE_HEX_ESCAPE$1.test(css.charAt(next))) {
12743 while(RE_HEX_ESCAPE$1.test(css.charAt(next + 1))){
12744 next += 1;
12745 }
12746 if (css.charCodeAt(next + 1) === SPACE$1) {
12747 next += 1;
12748 }
12749 }
12750 }
12751 currentToken = [
12752 "word",
12753 css.slice(pos, next + 1),
12754 pos,
12755 next
12756 ];
12757 pos = next;
12758 break;
12759 }
12760 default:
12761 {
12762 if (code === SLASH$1 && css.charCodeAt(pos + 1) === ASTERISK$1) {
12763 next = css.indexOf("*/", pos + 2) + 1;
12764 if (next === 0) {
12765 if (ignore || ignoreUnclosed) {
12766 next = css.length;
12767 } else {
12768 unclosed("comment");
12769 }
12770 }
12771 currentToken = [
12772 "comment",
12773 css.slice(pos, next + 1),
12774 pos,
12775 next
12776 ];
12777 pos = next;
12778 } else {
12779 RE_WORD_END$1.lastIndex = pos + 1;
12780 RE_WORD_END$1.test(css);
12781 if (RE_WORD_END$1.lastIndex === 0) {
12782 next = css.length - 1;
12783 } else {
12784 next = RE_WORD_END$1.lastIndex - 2;
12785 }
12786 currentToken = [
12787 "word",
12788 css.slice(pos, next + 1),
12789 pos,
12790 next
12791 ];
12792 buffer.push(currentToken);
12793 pos = next;
12794 }
12795 break;
12796 }
12797 }
12798 pos++;
12799 return currentToken;
12800 }
12801 function back(token) {
12802 returned.push(token);
12803 }
12804 return {
12805 back: back,
12806 endOfFile: endOfFile,
12807 nextToken: nextToken,
12808 position: position
12809 };
12810 };
12811 var Container$5$1 = container$1;
12812 var AtRule$3$1 = /*#__PURE__*/ function(Container$5$1) {
12813 _inherits(AtRule, Container$5$1);
12814 function AtRule(defaults) {
12815 var _this;
12816 _this = Container$5$1.call(this, defaults) || this;
12817 _this.type = "atrule";
12818 return _this;
12819 }
12820 var _proto = AtRule.prototype;
12821 _proto.append = function append() {
12822 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12823 children[_key] = arguments[_key];
12824 }
12825 var _Container$5$1_prototype_append;
12826 if (!this.proxyOf.nodes) this.nodes = [];
12827 return (_Container$5$1_prototype_append = Container$5$1.prototype.append).call.apply(_Container$5$1_prototype_append, [].concat([
12828 this
12829 ], children));
12830 };
12831 _proto.prepend = function prepend() {
12832 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12833 children[_key] = arguments[_key];
12834 }
12835 var _Container$5$1_prototype_prepend;
12836 if (!this.proxyOf.nodes) this.nodes = [];
12837 return (_Container$5$1_prototype_prepend = Container$5$1.prototype.prepend).call.apply(_Container$5$1_prototype_prepend, [].concat([
12838 this
12839 ], children));
12840 };
12841 return AtRule;
12842 }(Container$5$1);
12843 var atRule$1 = AtRule$3$1;
12844 AtRule$3$1.default = AtRule$3$1;
12845 Container$5$1.registerAtRule(AtRule$3$1);
12846 var Container$4$1 = container$1;
12847 var LazyResult$3$1, Processor$2$1;
12848 var Root$5$1 = /*#__PURE__*/ function(Container$4$1) {
12849 _inherits(Root, Container$4$1);
12850 function Root(defaults) {
12851 var _this;
12852 _this = Container$4$1.call(this, defaults) || this;
12853 _this.type = "root";
12854 if (!_this.nodes) _this.nodes = [];
12855 return _this;
12856 }
12857 var _proto = Root.prototype;
12858 _proto.normalize = function normalize(child, sample, type) {
12859 var nodes = Container$4$1.prototype.normalize.call(this, child);
12860 if (sample) {
12861 if (type === "prepend") {
12862 if (this.nodes.length > 1) {
12863 sample.raws.before = this.nodes[1].raws.before;
12864 } else {
12865 delete sample.raws.before;
12866 }
12867 } else if (this.first !== sample) {
12868 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12869 var node2 = _step.value;
12870 node2.raws.before = sample.raws.before;
12871 }
12872 }
12873 }
12874 return nodes;
12875 };
12876 _proto.removeChild = function removeChild(child, ignore) {
12877 var index2 = this.index(child);
12878 if (!ignore && index2 === 0 && this.nodes.length > 1) {
12879 this.nodes[1].raws.before = this.nodes[index2].raws.before;
12880 }
12881 return Container$4$1.prototype.removeChild.call(this, child);
12882 };
12883 _proto.toResult = function toResult(opts) {
12884 if (opts === void 0) opts = {};
12885 var lazy = new LazyResult$3$1(new Processor$2$1(), this, opts);
12886 return lazy.stringify();
12887 };
12888 return Root;
12889 }(Container$4$1);
12890 Root$5$1.registerLazyResult = function(dependant) {
12891 LazyResult$3$1 = dependant;
12892 };
12893 Root$5$1.registerProcessor = function(dependant) {
12894 Processor$2$1 = dependant;
12895 };
12896 var root$1 = Root$5$1;
12897 Root$5$1.default = Root$5$1;
12898 Container$4$1.registerRoot(Root$5$1);
12899 var list$2$1 = {
12900 comma: function comma(string) {
12901 return list$2$1.split(string, [
12902 ","
12903 ], true);
12904 },
12905 space: function space(string) {
12906 var spaces = [
12907 " ",
12908 "\n",
12909 " "
12910 ];
12911 return list$2$1.split(string, spaces);
12912 },
12913 split: function split(string, separators, last) {
12914 var array = [];
12915 var current = "";
12916 var split = false;
12917 var func = 0;
12918 var inQuote = false;
12919 var prevQuote = "";
12920 var escape = false;
12921 for(var _iterator = _create_for_of_iterator_helper_loose(string), _step; !(_step = _iterator()).done;){
12922 var letter = _step.value;
12923 if (escape) {
12924 escape = false;
12925 } else if (letter === "\\") {
12926 escape = true;
12927 } else if (inQuote) {
12928 if (letter === prevQuote) {
12929 inQuote = false;
12930 }
12931 } else if (letter === '"' || letter === "'") {
12932 inQuote = true;
12933 prevQuote = letter;
12934 } else if (letter === "(") {
12935 func += 1;
12936 } else if (letter === ")") {
12937 if (func > 0) func -= 1;
12938 } else if (func === 0) {
12939 if (separators.includes(letter)) split = true;
12940 }
12941 if (split) {
12942 if (current !== "") array.push(current.trim());
12943 current = "";
12944 split = false;
12945 } else {
12946 current += letter;
12947 }
12948 }
12949 if (last || current !== "") array.push(current.trim());
12950 return array;
12951 }
12952 };
12953 var list_1$1 = list$2$1;
12954 list$2$1.default = list$2$1;
12955 var Container$3$1 = container$1;
12956 var list$1$1 = list_1$1;
12957 var Rule$3$1 = /*#__PURE__*/ function(Container$3$1) {
12958 _inherits(Rule, Container$3$1);
12959 function Rule(defaults) {
12960 var _this;
12961 _this = Container$3$1.call(this, defaults) || this;
12962 _this.type = "rule";
12963 if (!_this.nodes) _this.nodes = [];
12964 return _this;
12965 }
12966 _create_class(Rule, [
12967 {
12968 key: "selectors",
12969 get: function get() {
12970 return list$1$1.comma(this.selector);
12971 },
12972 set: function set(values) {
12973 var match = this.selector ? this.selector.match(/,\s*/) : null;
12974 var sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen");
12975 this.selector = values.join(sep2);
12976 }
12977 }
12978 ]);
12979 return Rule;
12980 }(Container$3$1);
12981 var rule$1 = Rule$3$1;
12982 Rule$3$1.default = Rule$3$1;
12983 Container$3$1.registerRule(Rule$3$1);
12984 var Declaration$2$1 = declaration$1;
12985 var tokenizer2$1 = tokenize$1;
12986 var Comment$2$1 = comment$1;
12987 var AtRule$2$1 = atRule$1;
12988 var Root$4$1 = root$1;
12989 var Rule$2$1 = rule$1;
12990 var SAFE_COMMENT_NEIGHBOR$1 = {
12991 empty: true,
12992 space: true
12993 };
12994 function findLastWithPosition$1(tokens) {
12995 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
12996 var token = tokens[i2];
12997 var pos = token[3] || token[2];
12998 if (pos) return pos;
12999 }
13000 }
13001 var Parser$1$1 = /*#__PURE__*/ function() {
13002 function Parser(input2) {
13003 this.input = input2;
13004 this.root = new Root$4$1();
13005 this.current = this.root;
13006 this.spaces = "";
13007 this.semicolon = false;
13008 this.createTokenizer();
13009 this.root.source = {
13010 input: input2,
13011 start: {
13012 column: 1,
13013 line: 1,
13014 offset: 0
13015 }
13016 };
13017 }
13018 var _proto = Parser.prototype;
13019 _proto.atrule = function atrule(token) {
13020 var node2 = new AtRule$2$1();
13021 node2.name = token[1].slice(1);
13022 if (node2.name === "") {
13023 this.unnamedAtrule(node2, token);
13024 }
13025 this.init(node2, token[2]);
13026 var type;
13027 var prev;
13028 var shift;
13029 var last = false;
13030 var open = false;
13031 var params = [];
13032 var brackets = [];
13033 while(!this.tokenizer.endOfFile()){
13034 token = this.tokenizer.nextToken();
13035 type = token[0];
13036 if (type === "(" || type === "[") {
13037 brackets.push(type === "(" ? ")" : "]");
13038 } else if (type === "{" && brackets.length > 0) {
13039 brackets.push("}");
13040 } else if (type === brackets[brackets.length - 1]) {
13041 brackets.pop();
13042 }
13043 if (brackets.length === 0) {
13044 if (type === ";") {
13045 node2.source.end = this.getPosition(token[2]);
13046 node2.source.end.offset++;
13047 this.semicolon = true;
13048 break;
13049 } else if (type === "{") {
13050 open = true;
13051 break;
13052 } else if (type === "}") {
13053 if (params.length > 0) {
13054 shift = params.length - 1;
13055 prev = params[shift];
13056 while(prev && prev[0] === "space"){
13057 prev = params[--shift];
13058 }
13059 if (prev) {
13060 node2.source.end = this.getPosition(prev[3] || prev[2]);
13061 node2.source.end.offset++;
13062 }
13063 }
13064 this.end(token);
13065 break;
13066 } else {
13067 params.push(token);
13068 }
13069 } else {
13070 params.push(token);
13071 }
13072 if (this.tokenizer.endOfFile()) {
13073 last = true;
13074 break;
13075 }
13076 }
13077 node2.raws.between = this.spacesAndCommentsFromEnd(params);
13078 if (params.length) {
13079 node2.raws.afterName = this.spacesAndCommentsFromStart(params);
13080 this.raw(node2, "params", params);
13081 if (last) {
13082 token = params[params.length - 1];
13083 node2.source.end = this.getPosition(token[3] || token[2]);
13084 node2.source.end.offset++;
13085 this.spaces = node2.raws.between;
13086 node2.raws.between = "";
13087 }
13088 } else {
13089 node2.raws.afterName = "";
13090 node2.params = "";
13091 }
13092 if (open) {
13093 node2.nodes = [];
13094 this.current = node2;
13095 }
13096 };
13097 _proto.checkMissedSemicolon = function checkMissedSemicolon(tokens) {
13098 var colon = this.colon(tokens);
13099 if (colon === false) return;
13100 var founded = 0;
13101 var token;
13102 for(var j = colon - 1; j >= 0; j--){
13103 token = tokens[j];
13104 if (token[0] !== "space") {
13105 founded += 1;
13106 if (founded === 2) break;
13107 }
13108 }
13109 throw this.input.error("Missed semicolon", token[0] === "word" ? token[3] + 1 : token[2]);
13110 };
13111 _proto.colon = function colon(tokens) {
13112 var brackets = 0;
13113 var token, type, prev;
13114 for(var _iterator = _create_for_of_iterator_helper_loose(tokens.entries()), _step; !(_step = _iterator()).done;){
13115 var _step_value = _step.value, i2 = _step_value[0], element = _step_value[1];
13116 token = element;
13117 type = token[0];
13118 if (type === "(") {
13119 brackets += 1;
13120 }
13121 if (type === ")") {
13122 brackets -= 1;
13123 }
13124 if (brackets === 0 && type === ":") {
13125 if (!prev) {
13126 this.doubleColon(token);
13127 } else if (prev[0] === "word" && prev[1] === "progid") {
13128 continue;
13129 } else {
13130 return i2;
13131 }
13132 }
13133 prev = token;
13134 }
13135 return false;
13136 };
13137 _proto.comment = function comment(token) {
13138 var node2 = new Comment$2$1();
13139 this.init(node2, token[2]);
13140 node2.source.end = this.getPosition(token[3] || token[2]);
13141 node2.source.end.offset++;
13142 var text = token[1].slice(2, -2);
13143 if (/^\s*$/.test(text)) {
13144 node2.text = "";
13145 node2.raws.left = text;
13146 node2.raws.right = "";
13147 } else {
13148 var match = text.match(/^(\s*)([^]*\S)(\s*)$/);
13149 node2.text = match[2];
13150 node2.raws.left = match[1];
13151 node2.raws.right = match[3];
13152 }
13153 };
13154 _proto.createTokenizer = function createTokenizer() {
13155 this.tokenizer = tokenizer2$1(this.input);
13156 };
13157 _proto.decl = function decl(tokens, customProperty) {
13158 var node2 = new Declaration$2$1();
13159 this.init(node2, tokens[0][2]);
13160 var last = tokens[tokens.length - 1];
13161 if (last[0] === ";") {
13162 this.semicolon = true;
13163 tokens.pop();
13164 }
13165 node2.source.end = this.getPosition(last[3] || last[2] || findLastWithPosition$1(tokens));
13166 node2.source.end.offset++;
13167 while(tokens[0][0] !== "word"){
13168 if (tokens.length === 1) this.unknownWord(tokens);
13169 node2.raws.before += tokens.shift()[1];
13170 }
13171 node2.source.start = this.getPosition(tokens[0][2]);
13172 node2.prop = "";
13173 while(tokens.length){
13174 var type = tokens[0][0];
13175 if (type === ":" || type === "space" || type === "comment") {
13176 break;
13177 }
13178 node2.prop += tokens.shift()[1];
13179 }
13180 node2.raws.between = "";
13181 var token;
13182 while(tokens.length){
13183 token = tokens.shift();
13184 if (token[0] === ":") {
13185 node2.raws.between += token[1];
13186 break;
13187 } else {
13188 if (token[0] === "word" && /\w/.test(token[1])) {
13189 this.unknownWord([
13190 token
13191 ]);
13192 }
13193 node2.raws.between += token[1];
13194 }
13195 }
13196 if (node2.prop[0] === "_" || node2.prop[0] === "*") {
13197 node2.raws.before += node2.prop[0];
13198 node2.prop = node2.prop.slice(1);
13199 }
13200 var firstSpaces = [];
13201 var next;
13202 while(tokens.length){
13203 next = tokens[0][0];
13204 if (next !== "space" && next !== "comment") break;
13205 firstSpaces.push(tokens.shift());
13206 }
13207 this.precheckMissedSemicolon(tokens);
13208 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
13209 token = tokens[i2];
13210 if (token[1].toLowerCase() === "!important") {
13211 node2.important = true;
13212 var string = this.stringFrom(tokens, i2);
13213 string = this.spacesFromEnd(tokens) + string;
13214 if (string !== " !important") node2.raws.important = string;
13215 break;
13216 } else if (token[1].toLowerCase() === "important") {
13217 var cache = tokens.slice(0);
13218 var str = "";
13219 for(var j = i2; j > 0; j--){
13220 var type1 = cache[j][0];
13221 if (str.trim().indexOf("!") === 0 && type1 !== "space") {
13222 break;
13223 }
13224 str = cache.pop()[1] + str;
13225 }
13226 if (str.trim().indexOf("!") === 0) {
13227 node2.important = true;
13228 node2.raws.important = str;
13229 tokens = cache;
13230 }
13231 }
13232 if (token[0] !== "space" && token[0] !== "comment") {
13233 break;
13234 }
13235 }
13236 var hasWord = tokens.some(function(i2) {
13237 return i2[0] !== "space" && i2[0] !== "comment";
13238 });
13239 if (hasWord) {
13240 node2.raws.between += firstSpaces.map(function(i2) {
13241 return i2[1];
13242 }).join("");
13243 firstSpaces = [];
13244 }
13245 this.raw(node2, "value", firstSpaces.concat(tokens), customProperty);
13246 if (node2.value.includes(":") && !customProperty) {
13247 this.checkMissedSemicolon(tokens);
13248 }
13249 };
13250 _proto.doubleColon = function doubleColon(token) {
13251 throw this.input.error("Double colon", {
13252 offset: token[2]
13253 }, {
13254 offset: token[2] + token[1].length
13255 });
13256 };
13257 _proto.emptyRule = function emptyRule(token) {
13258 var node2 = new Rule$2$1();
13259 this.init(node2, token[2]);
13260 node2.selector = "";
13261 node2.raws.between = "";
13262 this.current = node2;
13263 };
13264 _proto.end = function end(token) {
13265 if (this.current.nodes && this.current.nodes.length) {
13266 this.current.raws.semicolon = this.semicolon;
13267 }
13268 this.semicolon = false;
13269 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
13270 this.spaces = "";
13271 if (this.current.parent) {
13272 this.current.source.end = this.getPosition(token[2]);
13273 this.current.source.end.offset++;
13274 this.current = this.current.parent;
13275 } else {
13276 this.unexpectedClose(token);
13277 }
13278 };
13279 _proto.endFile = function endFile() {
13280 if (this.current.parent) this.unclosedBlock();
13281 if (this.current.nodes && this.current.nodes.length) {
13282 this.current.raws.semicolon = this.semicolon;
13283 }
13284 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
13285 this.root.source.end = this.getPosition(this.tokenizer.position());
13286 };
13287 _proto.freeSemicolon = function freeSemicolon(token) {
13288 this.spaces += token[1];
13289 if (this.current.nodes) {
13290 var prev = this.current.nodes[this.current.nodes.length - 1];
13291 if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
13292 prev.raws.ownSemicolon = this.spaces;
13293 this.spaces = "";
13294 }
13295 }
13296 };
13297 // Helpers
13298 _proto.getPosition = function getPosition(offset) {
13299 var pos = this.input.fromOffset(offset);
13300 return {
13301 column: pos.col,
13302 line: pos.line,
13303 offset: offset
13304 };
13305 };
13306 _proto.init = function init(node2, offset) {
13307 this.current.push(node2);
13308 node2.source = {
13309 input: this.input,
13310 start: this.getPosition(offset)
13311 };
13312 node2.raws.before = this.spaces;
13313 this.spaces = "";
13314 if (node2.type !== "comment") this.semicolon = false;
13315 };
13316 _proto.other = function other(start) {
13317 var end = false;
13318 var type = null;
13319 var colon = false;
13320 var bracket = null;
13321 var brackets = [];
13322 var customProperty = start[1].startsWith("--");
13323 var tokens = [];
13324 var token = start;
13325 while(token){
13326 type = token[0];
13327 tokens.push(token);
13328 if (type === "(" || type === "[") {
13329 if (!bracket) bracket = token;
13330 brackets.push(type === "(" ? ")" : "]");
13331 } else if (customProperty && colon && type === "{") {
13332 if (!bracket) bracket = token;
13333 brackets.push("}");
13334 } else if (brackets.length === 0) {
13335 if (type === ";") {
13336 if (colon) {
13337 this.decl(tokens, customProperty);
13338 return;
13339 } else {
13340 break;
13341 }
13342 } else if (type === "{") {
13343 this.rule(tokens);
13344 return;
13345 } else if (type === "}") {
13346 this.tokenizer.back(tokens.pop());
13347 end = true;
13348 break;
13349 } else if (type === ":") {
13350 colon = true;
13351 }
13352 } else if (type === brackets[brackets.length - 1]) {
13353 brackets.pop();
13354 if (brackets.length === 0) bracket = null;
13355 }
13356 token = this.tokenizer.nextToken();
13357 }
13358 if (this.tokenizer.endOfFile()) end = true;
13359 if (brackets.length > 0) this.unclosedBracket(bracket);
13360 if (end && colon) {
13361 if (!customProperty) {
13362 while(tokens.length){
13363 token = tokens[tokens.length - 1][0];
13364 if (token !== "space" && token !== "comment") break;
13365 this.tokenizer.back(tokens.pop());
13366 }
13367 }
13368 this.decl(tokens, customProperty);
13369 } else {
13370 this.unknownWord(tokens);
13371 }
13372 };
13373 _proto.parse = function parse() {
13374 var token;
13375 while(!this.tokenizer.endOfFile()){
13376 token = this.tokenizer.nextToken();
13377 switch(token[0]){
13378 case "space":
13379 this.spaces += token[1];
13380 break;
13381 case ";":
13382 this.freeSemicolon(token);
13383 break;
13384 case "}":
13385 this.end(token);
13386 break;
13387 case "comment":
13388 this.comment(token);
13389 break;
13390 case "at-word":
13391 this.atrule(token);
13392 break;
13393 case "{":
13394 this.emptyRule(token);
13395 break;
13396 default:
13397 this.other(token);
13398 break;
13399 }
13400 }
13401 this.endFile();
13402 };
13403 _proto.precheckMissedSemicolon = function precheckMissedSemicolon() {};
13404 _proto.raw = function raw(node2, prop, tokens, customProperty) {
13405 var token, type;
13406 var length = tokens.length;
13407 var value = "";
13408 var clean = true;
13409 var next, prev;
13410 for(var i2 = 0; i2 < length; i2 += 1){
13411 token = tokens[i2];
13412 type = token[0];
13413 if (type === "space" && i2 === length - 1 && !customProperty) {
13414 clean = false;
13415 } else if (type === "comment") {
13416 prev = tokens[i2 - 1] ? tokens[i2 - 1][0] : "empty";
13417 next = tokens[i2 + 1] ? tokens[i2 + 1][0] : "empty";
13418 if (!SAFE_COMMENT_NEIGHBOR$1[prev] && !SAFE_COMMENT_NEIGHBOR$1[next]) {
13419 if (value.slice(-1) === ",") {
13420 clean = false;
13421 } else {
13422 value += token[1];
13423 }
13424 } else {
13425 clean = false;
13426 }
13427 } else {
13428 value += token[1];
13429 }
13430 }
13431 if (!clean) {
13432 var raw = tokens.reduce(function(all, i2) {
13433 return all + i2[1];
13434 }, "");
13435 node2.raws[prop] = {
13436 raw: raw,
13437 value: value
13438 };
13439 }
13440 node2[prop] = value;
13441 };
13442 _proto.rule = function rule(tokens) {
13443 tokens.pop();
13444 var node2 = new Rule$2$1();
13445 this.init(node2, tokens[0][2]);
13446 node2.raws.between = this.spacesAndCommentsFromEnd(tokens);
13447 this.raw(node2, "selector", tokens);
13448 this.current = node2;
13449 };
13450 _proto.spacesAndCommentsFromEnd = function spacesAndCommentsFromEnd(tokens) {
13451 var lastTokenType;
13452 var spaces = "";
13453 while(tokens.length){
13454 lastTokenType = tokens[tokens.length - 1][0];
13455 if (lastTokenType !== "space" && lastTokenType !== "comment") break;
13456 spaces = tokens.pop()[1] + spaces;
13457 }
13458 return spaces;
13459 };
13460 // Errors
13461 _proto.spacesAndCommentsFromStart = function spacesAndCommentsFromStart(tokens) {
13462 var next;
13463 var spaces = "";
13464 while(tokens.length){
13465 next = tokens[0][0];
13466 if (next !== "space" && next !== "comment") break;
13467 spaces += tokens.shift()[1];
13468 }
13469 return spaces;
13470 };
13471 _proto.spacesFromEnd = function spacesFromEnd(tokens) {
13472 var lastTokenType;
13473 var spaces = "";
13474 while(tokens.length){
13475 lastTokenType = tokens[tokens.length - 1][0];
13476 if (lastTokenType !== "space") break;
13477 spaces = tokens.pop()[1] + spaces;
13478 }
13479 return spaces;
13480 };
13481 _proto.stringFrom = function stringFrom(tokens, from) {
13482 var result2 = "";
13483 for(var i2 = from; i2 < tokens.length; i2++){
13484 result2 += tokens[i2][1];
13485 }
13486 tokens.splice(from, tokens.length - from);
13487 return result2;
13488 };
13489 _proto.unclosedBlock = function unclosedBlock() {
13490 var pos = this.current.source.start;
13491 throw this.input.error("Unclosed block", pos.line, pos.column);
13492 };
13493 _proto.unclosedBracket = function unclosedBracket(bracket) {
13494 throw this.input.error("Unclosed bracket", {
13495 offset: bracket[2]
13496 }, {
13497 offset: bracket[2] + 1
13498 });
13499 };
13500 _proto.unexpectedClose = function unexpectedClose(token) {
13501 throw this.input.error("Unexpected }", {
13502 offset: token[2]
13503 }, {
13504 offset: token[2] + 1
13505 });
13506 };
13507 _proto.unknownWord = function unknownWord(tokens) {
13508 throw this.input.error("Unknown word", {
13509 offset: tokens[0][2]
13510 }, {
13511 offset: tokens[0][2] + tokens[0][1].length
13512 });
13513 };
13514 _proto.unnamedAtrule = function unnamedAtrule(node2, token) {
13515 throw this.input.error("At-rule without name", {
13516 offset: token[2]
13517 }, {
13518 offset: token[2] + token[1].length
13519 });
13520 };
13521 return Parser;
13522 }();
13523 var parser$1 = Parser$1$1;
13524 var Container$2$1 = container$1;
13525 var Parser2$1 = parser$1;
13526 var Input$2$1 = input$1;
13527 function parse$3$1(css, opts) {
13528 var input2 = new Input$2$1(css, opts);
13529 var parser2 = new Parser2$1(input2);
13530 try {
13531 parser2.parse();
13532 } catch (e2) {
13533 if (true) {
13534 if (e2.name === "CssSyntaxError" && opts && opts.from) {
13535 if (/\.scss$/i.test(opts.from)) {
13536 e2.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser";
13537 } else if (/\.sass/i.test(opts.from)) {
13538 e2.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser";
13539 } else if (/\.less$/i.test(opts.from)) {
13540 e2.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser";
13541 }
13542 }
13543 }
13544 throw e2;
13545 }
13546 return parser2.root;
13547 }
13548 var parse_1$1 = parse$3$1;
13549 parse$3$1.default = parse$3$1;
13550 Container$2$1.registerParse(parse$3$1);
13551 var isClean$3 = symbols$1.isClean, my$3 = symbols$1.my;
13552 var MapGenerator$1$1 = mapGenerator$1;
13553 var stringify$2$1 = stringify_1$1;
13554 var Container$1$1 = container$1;
13555 var Document$2$1 = document$1$1;
13556 var warnOnce$1$1 = warnOnce$2$1;
13557 var Result$2$1 = result$1;
13558 var parse$2$1 = parse_1$1;
13559 var Root$3$1 = root$1;
13560 var TYPE_TO_CLASS_NAME$1 = {
13561 atrule: "AtRule",
13562 comment: "Comment",
13563 decl: "Declaration",
13564 document: "Document",
13565 root: "Root",
13566 rule: "Rule"
13567 };
13568 var PLUGIN_PROPS$1 = {
13569 AtRule: true,
13570 AtRuleExit: true,
13571 Comment: true,
13572 CommentExit: true,
13573 Declaration: true,
13574 DeclarationExit: true,
13575 Document: true,
13576 DocumentExit: true,
13577 Once: true,
13578 OnceExit: true,
13579 postcssPlugin: true,
13580 prepare: true,
13581 Root: true,
13582 RootExit: true,
13583 Rule: true,
13584 RuleExit: true
13585 };
13586 var NOT_VISITORS$1 = {
13587 Once: true,
13588 postcssPlugin: true,
13589 prepare: true
13590 };
13591 var CHILDREN$1 = 0;
13592 function isPromise$1(obj) {
13593 return (typeof obj === "undefined" ? "undefined" : _type_of(obj)) === "object" && typeof obj.then === "function";
13594 }
13595 function getEvents$1(node2) {
13596 var key = false;
13597 var type = TYPE_TO_CLASS_NAME$1[node2.type];
13598 if (node2.type === "decl") {
13599 key = node2.prop.toLowerCase();
13600 } else if (node2.type === "atrule") {
13601 key = node2.name.toLowerCase();
13602 }
13603 if (key && node2.append) {
13604 return [
13605 type,
13606 type + "-" + key,
13607 CHILDREN$1,
13608 type + "Exit",
13609 type + "Exit-" + key
13610 ];
13611 } else if (key) {
13612 return [
13613 type,
13614 type + "-" + key,
13615 type + "Exit",
13616 type + "Exit-" + key
13617 ];
13618 } else if (node2.append) {
13619 return [
13620 type,
13621 CHILDREN$1,
13622 type + "Exit"
13623 ];
13624 } else {
13625 return [
13626 type,
13627 type + "Exit"
13628 ];
13629 }
13630 }
13631 function toStack$1(node2) {
13632 var events;
13633 if (node2.type === "document") {
13634 events = [
13635 "Document",
13636 CHILDREN$1,
13637 "DocumentExit"
13638 ];
13639 } else if (node2.type === "root") {
13640 events = [
13641 "Root",
13642 CHILDREN$1,
13643 "RootExit"
13644 ];
13645 } else {
13646 events = getEvents$1(node2);
13647 }
13648 return {
13649 eventIndex: 0,
13650 events: events,
13651 iterator: 0,
13652 node: node2,
13653 visitorIndex: 0,
13654 visitors: []
13655 };
13656 }
13657 function cleanMarks$1(node2) {
13658 node2[isClean$3] = false;
13659 if (node2.nodes) node2.nodes.forEach(function(i2) {
13660 return cleanMarks$1(i2);
13661 });
13662 return node2;
13663 }
13664 var postcss$2$1 = {};
13665 var LazyResult$2$1 = /*#__PURE__*/ function() {
13666 function LazyResult(processor2, css, opts) {
13667 var _this = this;
13668 this.stringified = false;
13669 this.processed = false;
13670 var root2;
13671 if ((typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && css !== null && (css.type === "root" || css.type === "document")) {
13672 root2 = cleanMarks$1(css);
13673 } else if (_instanceof(css, LazyResult) || _instanceof(css, Result$2$1)) {
13674 root2 = cleanMarks$1(css.root);
13675 if (css.map) {
13676 if (typeof opts.map === "undefined") opts.map = {};
13677 if (!opts.map.inline) opts.map.inline = false;
13678 opts.map.prev = css.map;
13679 }
13680 } else {
13681 var parser2 = parse$2$1;
13682 if (opts.syntax) parser2 = opts.syntax.parse;
13683 if (opts.parser) parser2 = opts.parser;
13684 if (parser2.parse) parser2 = parser2.parse;
13685 try {
13686 root2 = parser2(css, opts);
13687 } catch (error) {
13688 this.processed = true;
13689 this.error = error;
13690 }
13691 if (root2 && !root2[my$3]) {
13692 Container$1$1.rebuild(root2);
13693 }
13694 }
13695 this.result = new Result$2$1(processor2, root2, opts);
13696 this.helpers = _extends({}, postcss$2$1, {
13697 postcss: postcss$2$1,
13698 result: this.result
13699 });
13700 this.plugins = this.processor.plugins.map(function(plugin22) {
13701 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.prepare) {
13702 return _extends({}, plugin22, plugin22.prepare(_this.result));
13703 } else {
13704 return plugin22;
13705 }
13706 });
13707 }
13708 var _proto = LazyResult.prototype;
13709 _proto.async = function async() {
13710 if (this.error) return Promise.reject(this.error);
13711 if (this.processed) return Promise.resolve(this.result);
13712 if (!this.processing) {
13713 this.processing = this.runAsync();
13714 }
13715 return this.processing;
13716 };
13717 _proto.catch = function _catch(onRejected) {
13718 return this.async().catch(onRejected);
13719 };
13720 _proto.finally = function _finally(onFinally) {
13721 return this.async().then(onFinally, onFinally);
13722 };
13723 _proto.getAsyncError = function getAsyncError() {
13724 throw new Error("Use process(css).then(cb) to work with async plugins");
13725 };
13726 _proto.handleError = function handleError(error, node2) {
13727 var plugin22 = this.result.lastPlugin;
13728 try {
13729 if (node2) node2.addToError(error);
13730 this.error = error;
13731 if (error.name === "CssSyntaxError" && !error.plugin) {
13732 error.plugin = plugin22.postcssPlugin;
13733 error.setMessage();
13734 } else if (plugin22.postcssVersion) {
13735 if (true) {
13736 var pluginName = plugin22.postcssPlugin;
13737 var pluginVer = plugin22.postcssVersion;
13738 var runtimeVer = this.result.processor.version;
13739 var a2 = pluginVer.split(".");
13740 var b = runtimeVer.split(".");
13741 if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) {
13742 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.");
13743 }
13744 }
13745 }
13746 } catch (err) {
13747 if (console && console.error) console.error(err);
13748 }
13749 return error;
13750 };
13751 _proto.prepareVisitors = function prepareVisitors() {
13752 var _this = this;
13753 this.listeners = {};
13754 var add = function(plugin22, type, cb) {
13755 if (!_this.listeners[type]) _this.listeners[type] = [];
13756 _this.listeners[type].push([
13757 plugin22,
13758 cb
13759 ]);
13760 };
13761 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
13762 var plugin22 = _step.value;
13763 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object") {
13764 for(var event in plugin22){
13765 if (!PLUGIN_PROPS$1[event] && /^[A-Z]/.test(event)) {
13766 throw new Error("Unknown event " + event + " in " + plugin22.postcssPlugin + ". Try to update PostCSS (" + this.processor.version + " now).");
13767 }
13768 if (!NOT_VISITORS$1[event]) {
13769 if (_type_of(plugin22[event]) === "object") {
13770 for(var filter in plugin22[event]){
13771 if (filter === "*") {
13772 add(plugin22, event, plugin22[event][filter]);
13773 } else {
13774 add(plugin22, event + "-" + filter.toLowerCase(), plugin22[event][filter]);
13775 }
13776 }
13777 } else if (typeof plugin22[event] === "function") {
13778 add(plugin22, event, plugin22[event]);
13779 }
13780 }
13781 }
13782 }
13783 }
13784 this.hasListener = Object.keys(this.listeners).length > 0;
13785 };
13786 _proto.runAsync = function runAsync() {
13787 var _this = this;
13788 return _async_to_generator(function() {
13789 var i2, plugin22, promise, error, root2, stack, promise1, e2, node2, _loop, _iterator, _step;
13790 return _ts_generator(this, function(_state) {
13791 switch(_state.label){
13792 case 0:
13793 _this.plugin = 0;
13794 i2 = 0;
13795 _state.label = 1;
13796 case 1:
13797 if (!(i2 < _this.plugins.length)) return [
13798 3,
13799 6
13800 ];
13801 plugin22 = _this.plugins[i2];
13802 promise = _this.runOnRoot(plugin22);
13803 if (!isPromise$1(promise)) return [
13804 3,
13805 5
13806 ];
13807 _state.label = 2;
13808 case 2:
13809 _state.trys.push([
13810 2,
13811 4,
13812 ,
13813 5
13814 ]);
13815 return [
13816 4,
13817 promise
13818 ];
13819 case 3:
13820 _state.sent();
13821 return [
13822 3,
13823 5
13824 ];
13825 case 4:
13826 error = _state.sent();
13827 throw _this.handleError(error);
13828 case 5:
13829 i2++;
13830 return [
13831 3,
13832 1
13833 ];
13834 case 6:
13835 _this.prepareVisitors();
13836 if (!_this.hasListener) return [
13837 3,
13838 18
13839 ];
13840 root2 = _this.result.root;
13841 _state.label = 7;
13842 case 7:
13843 if (!!root2[isClean$3]) return [
13844 3,
13845 14
13846 ];
13847 root2[isClean$3] = true;
13848 stack = [
13849 toStack$1(root2)
13850 ];
13851 _state.label = 8;
13852 case 8:
13853 if (!(stack.length > 0)) return [
13854 3,
13855 13
13856 ];
13857 promise1 = _this.visitTick(stack);
13858 if (!isPromise$1(promise1)) return [
13859 3,
13860 12
13861 ];
13862 _state.label = 9;
13863 case 9:
13864 _state.trys.push([
13865 9,
13866 11,
13867 ,
13868 12
13869 ]);
13870 return [
13871 4,
13872 promise1
13873 ];
13874 case 10:
13875 _state.sent();
13876 return [
13877 3,
13878 12
13879 ];
13880 case 11:
13881 e2 = _state.sent();
13882 node2 = stack[stack.length - 1].node;
13883 throw _this.handleError(e2, node2);
13884 case 12:
13885 return [
13886 3,
13887 8
13888 ];
13889 case 13:
13890 return [
13891 3,
13892 7
13893 ];
13894 case 14:
13895 if (!_this.listeners.OnceExit) return [
13896 3,
13897 18
13898 ];
13899 _loop = function() {
13900 var _step_value, plugin22, visitor, roots, e2;
13901 return _ts_generator(this, function(_state) {
13902 switch(_state.label){
13903 case 0:
13904 _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
13905 _this.result.lastPlugin = plugin22;
13906 _state.label = 1;
13907 case 1:
13908 _state.trys.push([
13909 1,
13910 6,
13911 ,
13912 7
13913 ]);
13914 if (!(root2.type === "document")) return [
13915 3,
13916 3
13917 ];
13918 roots = root2.nodes.map(function(subRoot) {
13919 return visitor(subRoot, _this.helpers);
13920 });
13921 return [
13922 4,
13923 Promise.all(roots)
13924 ];
13925 case 2:
13926 _state.sent();
13927 return [
13928 3,
13929 5
13930 ];
13931 case 3:
13932 return [
13933 4,
13934 visitor(root2, _this.helpers)
13935 ];
13936 case 4:
13937 _state.sent();
13938 _state.label = 5;
13939 case 5:
13940 return [
13941 3,
13942 7
13943 ];
13944 case 6:
13945 e2 = _state.sent();
13946 throw _this.handleError(e2);
13947 case 7:
13948 return [
13949 2
13950 ];
13951 }
13952 });
13953 };
13954 _iterator = _create_for_of_iterator_helper_loose(_this.listeners.OnceExit);
13955 _state.label = 15;
13956 case 15:
13957 if (!!(_step = _iterator()).done) return [
13958 3,
13959 18
13960 ];
13961 return [
13962 5,
13963 _ts_values(_loop())
13964 ];
13965 case 16:
13966 _state.sent();
13967 _state.label = 17;
13968 case 17:
13969 return [
13970 3,
13971 15
13972 ];
13973 case 18:
13974 _this.processed = true;
13975 return [
13976 2,
13977 _this.stringify()
13978 ];
13979 }
13980 });
13981 })();
13982 };
13983 _proto.runOnRoot = function runOnRoot(plugin22) {
13984 var _this = this;
13985 this.result.lastPlugin = plugin22;
13986 try {
13987 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.Once) {
13988 if (this.result.root.type === "document") {
13989 var roots = this.result.root.nodes.map(function(root2) {
13990 return plugin22.Once(root2, _this.helpers);
13991 });
13992 if (isPromise$1(roots[0])) {
13993 return Promise.all(roots);
13994 }
13995 return roots;
13996 }
13997 return plugin22.Once(this.result.root, this.helpers);
13998 } else if (typeof plugin22 === "function") {
13999 return plugin22(this.result.root, this.result);
14000 }
14001 } catch (error) {
14002 throw this.handleError(error);
14003 }
14004 };
14005 _proto.stringify = function stringify() {
14006 if (this.error) throw this.error;
14007 if (this.stringified) return this.result;
14008 this.stringified = true;
14009 this.sync();
14010 var opts = this.result.opts;
14011 var str = stringify$2$1;
14012 if (opts.syntax) str = opts.syntax.stringify;
14013 if (opts.stringifier) str = opts.stringifier;
14014 if (str.stringify) str = str.stringify;
14015 var map = new MapGenerator$1$1(str, this.result.root, this.result.opts);
14016 var data = map.generate();
14017 this.result.css = data[0];
14018 this.result.map = data[1];
14019 return this.result;
14020 };
14021 _proto.sync = function sync() {
14022 if (this.error) throw this.error;
14023 if (this.processed) return this.result;
14024 this.processed = true;
14025 if (this.processing) {
14026 throw this.getAsyncError();
14027 }
14028 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
14029 var plugin22 = _step.value;
14030 var promise = this.runOnRoot(plugin22);
14031 if (isPromise$1(promise)) {
14032 throw this.getAsyncError();
14033 }
14034 }
14035 this.prepareVisitors();
14036 if (this.hasListener) {
14037 var root2 = this.result.root;
14038 while(!root2[isClean$3]){
14039 root2[isClean$3] = true;
14040 this.walkSync(root2);
14041 }
14042 if (this.listeners.OnceExit) {
14043 if (root2.type === "document") {
14044 for(var _iterator1 = _create_for_of_iterator_helper_loose(root2.nodes), _step1; !(_step1 = _iterator1()).done;){
14045 var subRoot = _step1.value;
14046 this.visitSync(this.listeners.OnceExit, subRoot);
14047 }
14048 } else {
14049 this.visitSync(this.listeners.OnceExit, root2);
14050 }
14051 }
14052 }
14053 return this.result;
14054 };
14055 _proto.then = function then(onFulfilled, onRejected) {
14056 if (true) {
14057 if (!("from" in this.opts)) {
14058 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.");
14059 }
14060 }
14061 return this.async().then(onFulfilled, onRejected);
14062 };
14063 _proto.toString = function toString() {
14064 return this.css;
14065 };
14066 _proto.visitSync = function visitSync(visitors, node2) {
14067 for(var _iterator = _create_for_of_iterator_helper_loose(visitors), _step; !(_step = _iterator()).done;){
14068 var _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
14069 this.result.lastPlugin = plugin22;
14070 var promise = void 0;
14071 try {
14072 promise = visitor(node2, this.helpers);
14073 } catch (e2) {
14074 throw this.handleError(e2, node2.proxyOf);
14075 }
14076 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
14077 return true;
14078 }
14079 if (isPromise$1(promise)) {
14080 throw this.getAsyncError();
14081 }
14082 }
14083 };
14084 _proto.visitTick = function visitTick(stack) {
14085 var visit2 = stack[stack.length - 1];
14086 var node2 = visit2.node, visitors = visit2.visitors;
14087 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
14088 stack.pop();
14089 return;
14090 }
14091 if (visitors.length > 0 && visit2.visitorIndex < visitors.length) {
14092 var _visitors_visit2_visitorIndex = visitors[visit2.visitorIndex], plugin22 = _visitors_visit2_visitorIndex[0], visitor = _visitors_visit2_visitorIndex[1];
14093 visit2.visitorIndex += 1;
14094 if (visit2.visitorIndex === visitors.length) {
14095 visit2.visitors = [];
14096 visit2.visitorIndex = 0;
14097 }
14098 this.result.lastPlugin = plugin22;
14099 try {
14100 return visitor(node2.toProxy(), this.helpers);
14101 } catch (e2) {
14102 throw this.handleError(e2, node2);
14103 }
14104 }
14105 if (visit2.iterator !== 0) {
14106 var iterator = visit2.iterator;
14107 var child;
14108 while(child = node2.nodes[node2.indexes[iterator]]){
14109 node2.indexes[iterator] += 1;
14110 if (!child[isClean$3]) {
14111 child[isClean$3] = true;
14112 stack.push(toStack$1(child));
14113 return;
14114 }
14115 }
14116 visit2.iterator = 0;
14117 delete node2.indexes[iterator];
14118 }
14119 var events = visit2.events;
14120 while(visit2.eventIndex < events.length){
14121 var event = events[visit2.eventIndex];
14122 visit2.eventIndex += 1;
14123 if (event === CHILDREN$1) {
14124 if (node2.nodes && node2.nodes.length) {
14125 node2[isClean$3] = true;
14126 visit2.iterator = node2.getIterator();
14127 }
14128 return;
14129 } else if (this.listeners[event]) {
14130 visit2.visitors = this.listeners[event];
14131 return;
14132 }
14133 }
14134 stack.pop();
14135 };
14136 _proto.walkSync = function walkSync(node2) {
14137 var _this = this;
14138 node2[isClean$3] = true;
14139 var events = getEvents$1(node2);
14140 for(var _iterator = _create_for_of_iterator_helper_loose(events), _step; !(_step = _iterator()).done;){
14141 var event = _step.value;
14142 if (event === CHILDREN$1) {
14143 if (node2.nodes) {
14144 node2.each(function(child) {
14145 if (!child[isClean$3]) _this.walkSync(child);
14146 });
14147 }
14148 } else {
14149 var visitors = this.listeners[event];
14150 if (visitors) {
14151 if (this.visitSync(visitors, node2.toProxy())) return;
14152 }
14153 }
14154 }
14155 };
14156 _proto.warnings = function warnings() {
14157 return this.sync().warnings();
14158 };
14159 _create_class(LazyResult, [
14160 {
14161 key: "content",
14162 get: function get() {
14163 return this.stringify().content;
14164 }
14165 },
14166 {
14167 key: "css",
14168 get: function get() {
14169 return this.stringify().css;
14170 }
14171 },
14172 {
14173 key: "map",
14174 get: function get() {
14175 return this.stringify().map;
14176 }
14177 },
14178 {
14179 key: "messages",
14180 get: function get() {
14181 return this.sync().messages;
14182 }
14183 },
14184 {
14185 key: "opts",
14186 get: function get() {
14187 return this.result.opts;
14188 }
14189 },
14190 {
14191 key: "processor",
14192 get: function get() {
14193 return this.result.processor;
14194 }
14195 },
14196 {
14197 key: "root",
14198 get: function get() {
14199 return this.sync().root;
14200 }
14201 },
14202 {
14203 key: Symbol.toStringTag,
14204 get: function get() {
14205 return "LazyResult";
14206 }
14207 }
14208 ]);
14209 return LazyResult;
14210 }();
14211 LazyResult$2$1.registerPostcss = function(dependant) {
14212 postcss$2$1 = dependant;
14213 };
14214 var lazyResult$1 = LazyResult$2$1;
14215 LazyResult$2$1.default = LazyResult$2$1;
14216 Root$3$1.registerLazyResult(LazyResult$2$1);
14217 Document$2$1.registerLazyResult(LazyResult$2$1);
14218 var MapGenerator2$1 = mapGenerator$1;
14219 var stringify$1$1 = stringify_1$1;
14220 var warnOnce2$1 = warnOnce$2$1;
14221 var parse$1$1 = parse_1$1;
14222 var Result$1$1 = result$1;
14223 var NoWorkResult$1$1 = /*#__PURE__*/ function() {
14224 function NoWorkResult(processor2, css, opts) {
14225 css = css.toString();
14226 this.stringified = false;
14227 this._processor = processor2;
14228 this._css = css;
14229 this._opts = opts;
14230 this._map = void 0;
14231 var root2;
14232 var str = stringify$1$1;
14233 this.result = new Result$1$1(this._processor, root2, this._opts);
14234 this.result.css = css;
14235 var self = this;
14236 Object.defineProperty(this.result, "root", {
14237 get: function get() {
14238 return self.root;
14239 }
14240 });
14241 var map = new MapGenerator2$1(str, root2, this._opts, css);
14242 if (map.isMap()) {
14243 var _map_generate = map.generate(), generatedCSS = _map_generate[0], generatedMap = _map_generate[1];
14244 if (generatedCSS) {
14245 this.result.css = generatedCSS;
14246 }
14247 if (generatedMap) {
14248 this.result.map = generatedMap;
14249 }
14250 } else {
14251 map.clearAnnotation();
14252 this.result.css = map.css;
14253 }
14254 }
14255 var _proto = NoWorkResult.prototype;
14256 _proto.async = function async() {
14257 if (this.error) return Promise.reject(this.error);
14258 return Promise.resolve(this.result);
14259 };
14260 _proto.catch = function _catch(onRejected) {
14261 return this.async().catch(onRejected);
14262 };
14263 _proto.finally = function _finally(onFinally) {
14264 return this.async().then(onFinally, onFinally);
14265 };
14266 _proto.sync = function sync() {
14267 if (this.error) throw this.error;
14268 return this.result;
14269 };
14270 _proto.then = function then(onFulfilled, onRejected) {
14271 if (true) {
14272 if (!("from" in this._opts)) {
14273 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.");
14274 }
14275 }
14276 return this.async().then(onFulfilled, onRejected);
14277 };
14278 _proto.toString = function toString() {
14279 return this._css;
14280 };
14281 _proto.warnings = function warnings() {
14282 return [];
14283 };
14284 _create_class(NoWorkResult, [
14285 {
14286 key: "content",
14287 get: function get() {
14288 return this.result.css;
14289 }
14290 },
14291 {
14292 key: "css",
14293 get: function get() {
14294 return this.result.css;
14295 }
14296 },
14297 {
14298 key: "map",
14299 get: function get() {
14300 return this.result.map;
14301 }
14302 },
14303 {
14304 key: "messages",
14305 get: function get() {
14306 return [];
14307 }
14308 },
14309 {
14310 key: "opts",
14311 get: function get() {
14312 return this.result.opts;
14313 }
14314 },
14315 {
14316 key: "processor",
14317 get: function get() {
14318 return this.result.processor;
14319 }
14320 },
14321 {
14322 key: "root",
14323 get: function get() {
14324 if (this._root) {
14325 return this._root;
14326 }
14327 var root2;
14328 var parser2 = parse$1$1;
14329 try {
14330 root2 = parser2(this._css, this._opts);
14331 } catch (error) {
14332 this.error = error;
14333 }
14334 if (this.error) {
14335 throw this.error;
14336 } else {
14337 this._root = root2;
14338 return root2;
14339 }
14340 }
14341 },
14342 {
14343 key: Symbol.toStringTag,
14344 get: function get() {
14345 return "NoWorkResult";
14346 }
14347 }
14348 ]);
14349 return NoWorkResult;
14350 }();
14351 var noWorkResult$1 = NoWorkResult$1$1;
14352 NoWorkResult$1$1.default = NoWorkResult$1$1;
14353 var NoWorkResult2$1 = noWorkResult$1;
14354 var LazyResult$1$1 = lazyResult$1;
14355 var Document$1$1 = document$1$1;
14356 var Root$2$1 = root$1;
14357 var Processor$1$1 = /*#__PURE__*/ function() {
14358 function Processor(plugins) {
14359 if (plugins === void 0) plugins = [];
14360 this.version = "8.4.38";
14361 this.plugins = this.normalize(plugins);
14362 }
14363 var _proto = Processor.prototype;
14364 _proto.normalize = function normalize(plugins) {
14365 var normalized = [];
14366 for(var _iterator = _create_for_of_iterator_helper_loose(plugins), _step; !(_step = _iterator()).done;){
14367 var i2 = _step.value;
14368 if (i2.postcss === true) {
14369 i2 = i2();
14370 } else if (i2.postcss) {
14371 i2 = i2.postcss;
14372 }
14373 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && Array.isArray(i2.plugins)) {
14374 normalized = normalized.concat(i2.plugins);
14375 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.postcssPlugin) {
14376 normalized.push(i2);
14377 } else if (typeof i2 === "function") {
14378 normalized.push(i2);
14379 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && (i2.parse || i2.stringify)) {
14380 if (true) {
14381 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.");
14382 }
14383 } else {
14384 throw new Error(i2 + " is not a PostCSS plugin");
14385 }
14386 }
14387 return normalized;
14388 };
14389 _proto.process = function process1(css, opts) {
14390 if (opts === void 0) opts = {};
14391 if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) {
14392 return new NoWorkResult2$1(this, css, opts);
14393 } else {
14394 return new LazyResult$1$1(this, css, opts);
14395 }
14396 };
14397 _proto.use = function use(plugin22) {
14398 this.plugins = this.plugins.concat(this.normalize([
14399 plugin22
14400 ]));
14401 return this;
14402 };
14403 return Processor;
14404 }();
14405 var processor$1 = Processor$1$1;
14406 Processor$1$1.default = Processor$1$1;
14407 Root$2$1.registerProcessor(Processor$1$1);
14408 Document$1$1.registerProcessor(Processor$1$1);
14409 var Declaration$1$1 = declaration$1;
14410 var PreviousMap2$1 = previousMap$1;
14411 var Comment$1$1 = comment$1;
14412 var AtRule$1$1 = atRule$1;
14413 var Input$1$1 = input$1;
14414 var Root$1$1 = root$1;
14415 var Rule$1$1 = rule$1;
14416 function fromJSON$1$1(json, inputs) {
14417 if (Array.isArray(json)) return json.map(function(n2) {
14418 return fromJSON$1$1(n2);
14419 });
14420 var ownInputs = json.inputs, defaults = _object_without_properties_loose(json, [
14421 "inputs"
14422 ]);
14423 if (ownInputs) {
14424 inputs = [];
14425 for(var _iterator = _create_for_of_iterator_helper_loose(ownInputs), _step; !(_step = _iterator()).done;){
14426 var input2 = _step.value;
14427 var inputHydrated = _extends({}, input2, {
14428 __proto__: Input$1$1.prototype
14429 });
14430 if (inputHydrated.map) {
14431 inputHydrated.map = _extends({}, inputHydrated.map, {
14432 __proto__: PreviousMap2$1.prototype
14433 });
14434 }
14435 inputs.push(inputHydrated);
14436 }
14437 }
14438 if (defaults.nodes) {
14439 defaults.nodes = json.nodes.map(function(n2) {
14440 return fromJSON$1$1(n2, inputs);
14441 });
14442 }
14443 if (defaults.source) {
14444 var _defaults_source = defaults.source, inputId = _defaults_source.inputId, source = _object_without_properties_loose(_defaults_source, [
14445 "inputId"
14446 ]);
14447 defaults.source = source;
14448 if (inputId != null) {
14449 defaults.source.input = inputs[inputId];
14450 }
14451 }
14452 if (defaults.type === "root") {
14453 return new Root$1$1(defaults);
14454 } else if (defaults.type === "decl") {
14455 return new Declaration$1$1(defaults);
14456 } else if (defaults.type === "rule") {
14457 return new Rule$1$1(defaults);
14458 } else if (defaults.type === "comment") {
14459 return new Comment$1$1(defaults);
14460 } else if (defaults.type === "atrule") {
14461 return new AtRule$1$1(defaults);
14462 } else {
14463 throw new Error("Unknown node type: " + json.type);
14464 }
14465 }
14466 var fromJSON_1$1 = fromJSON$1$1;
14467 fromJSON$1$1.default = fromJSON$1$1;
14468 var CssSyntaxError2$1 = cssSyntaxError$1;
14469 var Declaration2$1 = declaration$1;
14470 var LazyResult2$1 = lazyResult$1;
14471 var Container2$1 = container$1;
14472 var Processor2$1 = processor$1;
14473 var stringify$5 = stringify_1$1;
14474 var fromJSON$2 = fromJSON_1$1;
14475 var Document22 = document$1$1;
14476 var Warning2$1 = warning$1;
14477 var Comment2$1 = comment$1;
14478 var AtRule2$1 = atRule$1;
14479 var Result2$1 = result$1;
14480 var Input2$1 = input$1;
14481 var parse$5 = parse_1$1;
14482 var list$3 = list_1$1;
14483 var Rule2$1 = rule$1;
14484 var Root2$1 = root$1;
14485 var Node2$1 = node$1;
14486 function postcss$3() {
14487 for(var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++){
14488 plugins[_key] = arguments[_key];
14489 }
14490 if (plugins.length === 1 && Array.isArray(plugins[0])) {
14491 plugins = plugins[0];
14492 }
14493 return new Processor2$1(plugins);
14494 }
14495 postcss$3.plugin = function plugin(name, initializer) {
14496 var warningPrinted = false;
14497 function creator() {
14498 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
14499 args[_key] = arguments[_key];
14500 }
14501 if (console && console.warn && !warningPrinted) {
14502 warningPrinted = true;
14503 console.warn(name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration");
14504 if (process.env.LANG && process.env.LANG.startsWith("cn")) {
14505 console.warn(name + ": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226");
14506 }
14507 }
14508 var transformer = initializer.apply(void 0, [].concat(args));
14509 transformer.postcssPlugin = name;
14510 transformer.postcssVersion = new Processor2$1().version;
14511 return transformer;
14512 }
14513 var cache;
14514 Object.defineProperty(creator, "postcss", {
14515 get: function get() {
14516 if (!cache) cache = creator();
14517 return cache;
14518 }
14519 });
14520 creator.process = function(css, processOpts, pluginOpts) {
14521 return postcss$3([
14522 creator(pluginOpts)
14523 ]).process(css, processOpts);
14524 };
14525 return creator;
14526 };
14527 postcss$3.stringify = stringify$5;
14528 postcss$3.parse = parse$5;
14529 postcss$3.fromJSON = fromJSON$2;
14530 postcss$3.list = list$3;
14531 postcss$3.comment = function(defaults) {
14532 return new Comment2$1(defaults);
14533 };
14534 postcss$3.atRule = function(defaults) {
14535 return new AtRule2$1(defaults);
14536 };
14537 postcss$3.decl = function(defaults) {
14538 return new Declaration2$1(defaults);
14539 };
14540 postcss$3.rule = function(defaults) {
14541 return new Rule2$1(defaults);
14542 };
14543 postcss$3.root = function(defaults) {
14544 return new Root2$1(defaults);
14545 };
14546 postcss$3.document = function(defaults) {
14547 return new Document22(defaults);
14548 };
14549 postcss$3.CssSyntaxError = CssSyntaxError2$1;
14550 postcss$3.Declaration = Declaration2$1;
14551 postcss$3.Container = Container2$1;
14552 postcss$3.Processor = Processor2$1;
14553 postcss$3.Document = Document22;
14554 postcss$3.Comment = Comment2$1;
14555 postcss$3.Warning = Warning2$1;
14556 postcss$3.AtRule = AtRule2$1;
14557 postcss$3.Result = Result2$1;
14558 postcss$3.Input = Input2$1;
14559 postcss$3.Rule = Rule2$1;
14560 postcss$3.Root = Root2$1;
14561 postcss$3.Node = Node2$1;
14562 LazyResult2$1.registerPostcss(postcss$3);
14563 var postcss_1$1 = postcss$3;
14564 postcss$3.default = postcss$3;
14565 var postcss$1$1 = /* @__PURE__ */ getDefaultExportFromCjs$1(postcss_1$1);
14566 postcss$1$1.stringify;
14567 postcss$1$1.fromJSON;
14568 postcss$1$1.plugin;
14569 postcss$1$1.parse;
14570 postcss$1$1.list;
14571 postcss$1$1.document;
14572 postcss$1$1.comment;
14573 postcss$1$1.atRule;
14574 postcss$1$1.rule;
14575 postcss$1$1.decl;
14576 postcss$1$1.root;
14577 postcss$1$1.CssSyntaxError;
14578 postcss$1$1.Declaration;
14579 postcss$1$1.Container;
14580 postcss$1$1.Processor;
14581 postcss$1$1.Document;
14582 postcss$1$1.Comment;
14583 postcss$1$1.Warning;
14584 postcss$1$1.AtRule;
14585 postcss$1$1.Result;
14586 postcss$1$1.Input;
14587 postcss$1$1.Rule;
14588 postcss$1$1.Root;
14589 postcss$1$1.Node;
14590 var __defProp2 = Object.defineProperty;
14591 var __defNormalProp2 = function(obj, key, value) {
14592 return key in obj ? __defProp2(obj, key, {
14593 enumerable: true,
14594 configurable: true,
14595 writable: true,
14596 value: value
14597 }) : obj[key] = value;
14598 };
14599 var __publicField2 = function(obj, key, value) {
14600 return __defNormalProp2(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
14601 };
14602 function getDefaultExportFromCjs(x2) {
14603 return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
14604 }
14605 function getAugmentedNamespace(n2) {
14606 if (n2.__esModule) return n2;
14607 var f2 = n2.default;
14608 if (typeof f2 == "function") {
14609 var a2 = function a22() {
14610 if (_instanceof(this, a22)) {
14611 return Reflect.construct(f2, arguments, this.constructor);
14612 }
14613 return f2.apply(this, arguments);
14614 };
14615 a2.prototype = f2.prototype;
14616 } else a2 = {};
14617 Object.defineProperty(a2, "__esModule", {
14618 value: true
14619 });
14620 Object.keys(n2).forEach(function(k) {
14621 var d = Object.getOwnPropertyDescriptor(n2, k);
14622 Object.defineProperty(a2, k, d.get ? d : {
14623 enumerable: true,
14624 get: function get() {
14625 return n2[k];
14626 }
14627 });
14628 });
14629 return a2;
14630 }
14631 var picocolors_browser = {
14632 exports: {}
14633 };
14634 var x = String;
14635 var create = function create() {
14636 return {
14637 isColorSupported: false,
14638 reset: x,
14639 bold: x,
14640 dim: x,
14641 italic: x,
14642 underline: x,
14643 inverse: x,
14644 hidden: x,
14645 strikethrough: x,
14646 black: x,
14647 red: x,
14648 green: x,
14649 yellow: x,
14650 blue: x,
14651 magenta: x,
14652 cyan: x,
14653 white: x,
14654 gray: x,
14655 bgBlack: x,
14656 bgRed: x,
14657 bgGreen: x,
14658 bgYellow: x,
14659 bgBlue: x,
14660 bgMagenta: x,
14661 bgCyan: x,
14662 bgWhite: x
14663 };
14664 };
14665 picocolors_browser.exports = create();
14666 picocolors_browser.exports.createColors = create;
14667 var picocolors_browserExports = picocolors_browser.exports;
14668 var __viteBrowserExternal = {};
14669 var __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
14670 __proto__: null,
14671 default: __viteBrowserExternal
14672 }, Symbol.toStringTag, {
14673 value: "Module"
14674 }));
14675 var require$$2 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1);
14676 var pico = picocolors_browserExports;
14677 var terminalHighlight$1 = require$$2;
14678 var CssSyntaxError$3 = /*#__PURE__*/ function(Error1) {
14679 _inherits(CssSyntaxError2, Error1);
14680 function CssSyntaxError2(message, line, column, source, file, plugin22) {
14681 var _this;
14682 _this = Error1.call(this, message) || this;
14683 _this.name = "CssSyntaxError";
14684 _this.reason = message;
14685 if (file) {
14686 _this.file = file;
14687 }
14688 if (source) {
14689 _this.source = source;
14690 }
14691 if (plugin22) {
14692 _this.plugin = plugin22;
14693 }
14694 if (typeof line !== "undefined" && typeof column !== "undefined") {
14695 if (typeof line === "number") {
14696 _this.line = line;
14697 _this.column = column;
14698 } else {
14699 _this.line = line.line;
14700 _this.column = line.column;
14701 _this.endLine = column.line;
14702 _this.endColumn = column.column;
14703 }
14704 }
14705 _this.setMessage();
14706 if (Error.captureStackTrace) {
14707 Error.captureStackTrace(_this, CssSyntaxError2);
14708 }
14709 return _this;
14710 }
14711 var _proto = CssSyntaxError2.prototype;
14712 _proto.setMessage = function setMessage() {
14713 this.message = this.plugin ? this.plugin + ": " : "";
14714 this.message += this.file ? this.file : "<css input>";
14715 if (typeof this.line !== "undefined") {
14716 this.message += ":" + this.line + ":" + this.column;
14717 }
14718 this.message += ": " + this.reason;
14719 };
14720 _proto.showSourceCode = function showSourceCode(color) {
14721 var _this = this;
14722 if (!this.source) return "";
14723 var css = this.source;
14724 if (color == null) color = pico.isColorSupported;
14725 if (terminalHighlight$1) {
14726 if (color) css = terminalHighlight$1(css);
14727 }
14728 var lines = css.split(/\r?\n/);
14729 var start = Math.max(this.line - 3, 0);
14730 var end = Math.min(this.line + 2, lines.length);
14731 var maxWidth = String(end).length;
14732 var mark, aside;
14733 if (color) {
14734 var _pico_createColors = pico.createColors(true), bold = _pico_createColors.bold, gray = _pico_createColors.gray, red = _pico_createColors.red;
14735 mark = function(text) {
14736 return bold(red(text));
14737 };
14738 aside = function(text) {
14739 return gray(text);
14740 };
14741 } else {
14742 mark = aside = function(str) {
14743 return str;
14744 };
14745 }
14746 return lines.slice(start, end).map(function(line, index2) {
14747 var number = start + 1 + index2;
14748 var gutter = " " + (" " + number).slice(-maxWidth) + " | ";
14749 if (number === _this.line) {
14750 var spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, _this.column - 1).replace(/[^\t]/g, " ");
14751 return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^");
14752 }
14753 return " " + aside(gutter) + line;
14754 }).join("\n");
14755 };
14756 _proto.toString = function toString() {
14757 var code = this.showSourceCode();
14758 if (code) {
14759 code = "\n\n" + code + "\n";
14760 }
14761 return this.name + ": " + this.message + code;
14762 };
14763 return CssSyntaxError2;
14764 }(_wrap_native_super(Error));
14765 var cssSyntaxError = CssSyntaxError$3;
14766 CssSyntaxError$3.default = CssSyntaxError$3;
14767 var symbols = {};
14768 symbols.isClean = Symbol("isClean");
14769 symbols.my = Symbol("my");
14770 var DEFAULT_RAW = {
14771 after: "\n",
14772 beforeClose: "\n",
14773 beforeComment: "\n",
14774 beforeDecl: "\n",
14775 beforeOpen: " ",
14776 beforeRule: "\n",
14777 colon: ": ",
14778 commentLeft: " ",
14779 commentRight: " ",
14780 emptyBody: "",
14781 indent: " ",
14782 semicolon: false
14783 };
14784 function capitalize(str) {
14785 return str[0].toUpperCase() + str.slice(1);
14786 }
14787 var Stringifier$2 = /*#__PURE__*/ function() {
14788 function Stringifier2(builder) {
14789 this.builder = builder;
14790 }
14791 var _proto = Stringifier2.prototype;
14792 _proto.atrule = function atrule(node2, semicolon) {
14793 var name = "@" + node2.name;
14794 var params = node2.params ? this.rawValue(node2, "params") : "";
14795 if (typeof node2.raws.afterName !== "undefined") {
14796 name += node2.raws.afterName;
14797 } else if (params) {
14798 name += " ";
14799 }
14800 if (node2.nodes) {
14801 this.block(node2, name + params);
14802 } else {
14803 var end = (node2.raws.between || "") + (semicolon ? ";" : "");
14804 this.builder(name + params + end, node2);
14805 }
14806 };
14807 _proto.beforeAfter = function beforeAfter(node2, detect) {
14808 var value;
14809 if (node2.type === "decl") {
14810 value = this.raw(node2, null, "beforeDecl");
14811 } else if (node2.type === "comment") {
14812 value = this.raw(node2, null, "beforeComment");
14813 } else if (detect === "before") {
14814 value = this.raw(node2, null, "beforeRule");
14815 } else {
14816 value = this.raw(node2, null, "beforeClose");
14817 }
14818 var buf = node2.parent;
14819 var depth = 0;
14820 while(buf && buf.type !== "root"){
14821 depth += 1;
14822 buf = buf.parent;
14823 }
14824 if (value.includes("\n")) {
14825 var indent = this.raw(node2, null, "indent");
14826 if (indent.length) {
14827 for(var step = 0; step < depth; step++)value += indent;
14828 }
14829 }
14830 return value;
14831 };
14832 _proto.block = function block(node2, start) {
14833 var between = this.raw(node2, "between", "beforeOpen");
14834 this.builder(start + between + "{", node2, "start");
14835 var after;
14836 if (node2.nodes && node2.nodes.length) {
14837 this.body(node2);
14838 after = this.raw(node2, "after");
14839 } else {
14840 after = this.raw(node2, "after", "emptyBody");
14841 }
14842 if (after) this.builder(after);
14843 this.builder("}", node2, "end");
14844 };
14845 _proto.body = function body(node2) {
14846 var last = node2.nodes.length - 1;
14847 while(last > 0){
14848 if (node2.nodes[last].type !== "comment") break;
14849 last -= 1;
14850 }
14851 var semicolon = this.raw(node2, "semicolon");
14852 for(var i2 = 0; i2 < node2.nodes.length; i2++){
14853 var child = node2.nodes[i2];
14854 var before = this.raw(child, "before");
14855 if (before) this.builder(before);
14856 this.stringify(child, last !== i2 || semicolon);
14857 }
14858 };
14859 _proto.comment = function comment(node2) {
14860 var left = this.raw(node2, "left", "commentLeft");
14861 var right = this.raw(node2, "right", "commentRight");
14862 this.builder("/*" + left + node2.text + right + "*/", node2);
14863 };
14864 _proto.decl = function decl(node2, semicolon) {
14865 var between = this.raw(node2, "between", "colon");
14866 var string = node2.prop + between + this.rawValue(node2, "value");
14867 if (node2.important) {
14868 string += node2.raws.important || " !important";
14869 }
14870 if (semicolon) string += ";";
14871 this.builder(string, node2);
14872 };
14873 _proto.document = function document1(node2) {
14874 this.body(node2);
14875 };
14876 _proto.raw = function raw(node2, own, detect) {
14877 var value;
14878 if (!detect) detect = own;
14879 if (own) {
14880 value = node2.raws[own];
14881 if (typeof value !== "undefined") return value;
14882 }
14883 var parent = node2.parent;
14884 if (detect === "before") {
14885 if (!parent || parent.type === "root" && parent.first === node2) {
14886 return "";
14887 }
14888 if (parent && parent.type === "document") {
14889 return "";
14890 }
14891 }
14892 if (!parent) return DEFAULT_RAW[detect];
14893 var root2 = node2.root();
14894 if (!root2.rawCache) root2.rawCache = {};
14895 if (typeof root2.rawCache[detect] !== "undefined") {
14896 return root2.rawCache[detect];
14897 }
14898 if (detect === "before" || detect === "after") {
14899 return this.beforeAfter(node2, detect);
14900 } else {
14901 var method = "raw" + capitalize(detect);
14902 if (this[method]) {
14903 value = this[method](root2, node2);
14904 } else {
14905 root2.walk(function(i2) {
14906 value = i2.raws[own];
14907 if (typeof value !== "undefined") return false;
14908 });
14909 }
14910 }
14911 if (typeof value === "undefined") value = DEFAULT_RAW[detect];
14912 root2.rawCache[detect] = value;
14913 return value;
14914 };
14915 _proto.rawBeforeClose = function rawBeforeClose(root2) {
14916 var value;
14917 root2.walk(function(i2) {
14918 if (i2.nodes && i2.nodes.length > 0) {
14919 if (typeof i2.raws.after !== "undefined") {
14920 value = i2.raws.after;
14921 if (value.includes("\n")) {
14922 value = value.replace(/[^\n]+$/, "");
14923 }
14924 return false;
14925 }
14926 }
14927 });
14928 if (value) value = value.replace(/\S/g, "");
14929 return value;
14930 };
14931 _proto.rawBeforeComment = function rawBeforeComment(root2, node2) {
14932 var value;
14933 root2.walkComments(function(i2) {
14934 if (typeof i2.raws.before !== "undefined") {
14935 value = i2.raws.before;
14936 if (value.includes("\n")) {
14937 value = value.replace(/[^\n]+$/, "");
14938 }
14939 return false;
14940 }
14941 });
14942 if (typeof value === "undefined") {
14943 value = this.raw(node2, null, "beforeDecl");
14944 } else if (value) {
14945 value = value.replace(/\S/g, "");
14946 }
14947 return value;
14948 };
14949 _proto.rawBeforeDecl = function rawBeforeDecl(root2, node2) {
14950 var value;
14951 root2.walkDecls(function(i2) {
14952 if (typeof i2.raws.before !== "undefined") {
14953 value = i2.raws.before;
14954 if (value.includes("\n")) {
14955 value = value.replace(/[^\n]+$/, "");
14956 }
14957 return false;
14958 }
14959 });
14960 if (typeof value === "undefined") {
14961 value = this.raw(node2, null, "beforeRule");
14962 } else if (value) {
14963 value = value.replace(/\S/g, "");
14964 }
14965 return value;
14966 };
14967 _proto.rawBeforeOpen = function rawBeforeOpen(root2) {
14968 var value;
14969 root2.walk(function(i2) {
14970 if (i2.type !== "decl") {
14971 value = i2.raws.between;
14972 if (typeof value !== "undefined") return false;
14973 }
14974 });
14975 return value;
14976 };
14977 _proto.rawBeforeRule = function rawBeforeRule(root2) {
14978 var value;
14979 root2.walk(function(i2) {
14980 if (i2.nodes && (i2.parent !== root2 || root2.first !== i2)) {
14981 if (typeof i2.raws.before !== "undefined") {
14982 value = i2.raws.before;
14983 if (value.includes("\n")) {
14984 value = value.replace(/[^\n]+$/, "");
14985 }
14986 return false;
14987 }
14988 }
14989 });
14990 if (value) value = value.replace(/\S/g, "");
14991 return value;
14992 };
14993 _proto.rawColon = function rawColon(root2) {
14994 var value;
14995 root2.walkDecls(function(i2) {
14996 if (typeof i2.raws.between !== "undefined") {
14997 value = i2.raws.between.replace(/[^\s:]/g, "");
14998 return false;
14999 }
15000 });
15001 return value;
15002 };
15003 _proto.rawEmptyBody = function rawEmptyBody(root2) {
15004 var value;
15005 root2.walk(function(i2) {
15006 if (i2.nodes && i2.nodes.length === 0) {
15007 value = i2.raws.after;
15008 if (typeof value !== "undefined") return false;
15009 }
15010 });
15011 return value;
15012 };
15013 _proto.rawIndent = function rawIndent(root2) {
15014 if (root2.raws.indent) return root2.raws.indent;
15015 var value;
15016 root2.walk(function(i2) {
15017 var p = i2.parent;
15018 if (p && p !== root2 && p.parent && p.parent === root2) {
15019 if (typeof i2.raws.before !== "undefined") {
15020 var parts = i2.raws.before.split("\n");
15021 value = parts[parts.length - 1];
15022 value = value.replace(/\S/g, "");
15023 return false;
15024 }
15025 }
15026 });
15027 return value;
15028 };
15029 _proto.rawSemicolon = function rawSemicolon(root2) {
15030 var value;
15031 root2.walk(function(i2) {
15032 if (i2.nodes && i2.nodes.length && i2.last.type === "decl") {
15033 value = i2.raws.semicolon;
15034 if (typeof value !== "undefined") return false;
15035 }
15036 });
15037 return value;
15038 };
15039 _proto.rawValue = function rawValue(node2, prop) {
15040 var value = node2[prop];
15041 var raw = node2.raws[prop];
15042 if (raw && raw.value === value) {
15043 return raw.raw;
15044 }
15045 return value;
15046 };
15047 _proto.root = function root(node2) {
15048 this.body(node2);
15049 if (node2.raws.after) this.builder(node2.raws.after);
15050 };
15051 _proto.rule = function rule(node2) {
15052 this.block(node2, this.rawValue(node2, "selector"));
15053 if (node2.raws.ownSemicolon) {
15054 this.builder(node2.raws.ownSemicolon, node2, "end");
15055 }
15056 };
15057 _proto.stringify = function stringify(node2, semicolon) {
15058 if (!this[node2.type]) {
15059 throw new Error("Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier.");
15060 }
15061 this[node2.type](node2, semicolon);
15062 };
15063 return Stringifier2;
15064 }();
15065 var stringifier = Stringifier$2;
15066 Stringifier$2.default = Stringifier$2;
15067 var Stringifier$1 = stringifier;
15068 function stringify$4(node2, builder) {
15069 var str = new Stringifier$1(builder);
15070 str.stringify(node2);
15071 }
15072 var stringify_1 = stringify$4;
15073 stringify$4.default = stringify$4;
15074 var isClean$2 = symbols.isClean, my$2 = symbols.my;
15075 var CssSyntaxError$2 = cssSyntaxError;
15076 var Stringifier22 = stringifier;
15077 var stringify$3 = stringify_1;
15078 function cloneNode(obj, parent) {
15079 var cloned = new obj.constructor();
15080 for(var i2 in obj){
15081 if (!Object.prototype.hasOwnProperty.call(obj, i2)) {
15082 continue;
15083 }
15084 if (i2 === "proxyCache") continue;
15085 var value = obj[i2];
15086 var type = typeof value === "undefined" ? "undefined" : _type_of(value);
15087 if (i2 === "parent" && type === "object") {
15088 if (parent) cloned[i2] = parent;
15089 } else if (i2 === "source") {
15090 cloned[i2] = value;
15091 } else if (Array.isArray(value)) {
15092 cloned[i2] = value.map(function(j) {
15093 return cloneNode(j, cloned);
15094 });
15095 } else {
15096 if (type === "object" && value !== null) value = cloneNode(value);
15097 cloned[i2] = value;
15098 }
15099 }
15100 return cloned;
15101 }
15102 var Node$4 = /*#__PURE__*/ function() {
15103 function Node3(defaults) {
15104 if (defaults === void 0) defaults = {};
15105 this.raws = {};
15106 this[isClean$2] = false;
15107 this[my$2] = true;
15108 for(var name in defaults){
15109 if (name === "nodes") {
15110 this.nodes = [];
15111 for(var _iterator = _create_for_of_iterator_helper_loose(defaults[name]), _step; !(_step = _iterator()).done;){
15112 var node2 = _step.value;
15113 if (typeof node2.clone === "function") {
15114 this.append(node2.clone());
15115 } else {
15116 this.append(node2);
15117 }
15118 }
15119 } else {
15120 this[name] = defaults[name];
15121 }
15122 }
15123 }
15124 var _proto = Node3.prototype;
15125 _proto.addToError = function addToError(error) {
15126 error.postcssNode = this;
15127 if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
15128 var s2 = this.source;
15129 error.stack = error.stack.replace(/\n\s{4}at /, "$&" + s2.input.from + ":" + s2.start.line + ":" + s2.start.column + "$&");
15130 }
15131 return error;
15132 };
15133 _proto.after = function after(add) {
15134 this.parent.insertAfter(this, add);
15135 return this;
15136 };
15137 _proto.assign = function assign(overrides) {
15138 if (overrides === void 0) overrides = {};
15139 for(var name in overrides){
15140 this[name] = overrides[name];
15141 }
15142 return this;
15143 };
15144 _proto.before = function before(add) {
15145 this.parent.insertBefore(this, add);
15146 return this;
15147 };
15148 _proto.cleanRaws = function cleanRaws(keepBetween) {
15149 delete this.raws.before;
15150 delete this.raws.after;
15151 if (!keepBetween) delete this.raws.between;
15152 };
15153 _proto.clone = function clone(overrides) {
15154 if (overrides === void 0) overrides = {};
15155 var cloned = cloneNode(this);
15156 for(var name in overrides){
15157 cloned[name] = overrides[name];
15158 }
15159 return cloned;
15160 };
15161 _proto.cloneAfter = function cloneAfter(overrides) {
15162 if (overrides === void 0) overrides = {};
15163 var cloned = this.clone(overrides);
15164 this.parent.insertAfter(this, cloned);
15165 return cloned;
15166 };
15167 _proto.cloneBefore = function cloneBefore(overrides) {
15168 if (overrides === void 0) overrides = {};
15169 var cloned = this.clone(overrides);
15170 this.parent.insertBefore(this, cloned);
15171 return cloned;
15172 };
15173 _proto.error = function error(message, opts) {
15174 if (opts === void 0) opts = {};
15175 if (this.source) {
15176 var _this_rangeBy = this.rangeBy(opts), end = _this_rangeBy.end, start = _this_rangeBy.start;
15177 return this.source.input.error(message, {
15178 column: start.column,
15179 line: start.line
15180 }, {
15181 column: end.column,
15182 line: end.line
15183 }, opts);
15184 }
15185 return new CssSyntaxError$2(message);
15186 };
15187 _proto.getProxyProcessor = function getProxyProcessor() {
15188 return {
15189 get: function get(node2, prop) {
15190 if (prop === "proxyOf") {
15191 return node2;
15192 } else if (prop === "root") {
15193 return function() {
15194 return node2.root().toProxy();
15195 };
15196 } else {
15197 return node2[prop];
15198 }
15199 },
15200 set: function set(node2, prop, value) {
15201 if (node2[prop] === value) return true;
15202 node2[prop] = value;
15203 if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ prop === "text") {
15204 node2.markDirty();
15205 }
15206 return true;
15207 }
15208 };
15209 };
15210 _proto.markDirty = function markDirty() {
15211 if (this[isClean$2]) {
15212 this[isClean$2] = false;
15213 var next = this;
15214 while(next = next.parent){
15215 next[isClean$2] = false;
15216 }
15217 }
15218 };
15219 _proto.next = function next() {
15220 if (!this.parent) return void 0;
15221 var index2 = this.parent.index(this);
15222 return this.parent.nodes[index2 + 1];
15223 };
15224 _proto.positionBy = function positionBy(opts, stringRepresentation) {
15225 var pos = this.source.start;
15226 if (opts.index) {
15227 pos = this.positionInside(opts.index, stringRepresentation);
15228 } else if (opts.word) {
15229 stringRepresentation = this.toString();
15230 var index2 = stringRepresentation.indexOf(opts.word);
15231 if (index2 !== -1) pos = this.positionInside(index2, stringRepresentation);
15232 }
15233 return pos;
15234 };
15235 _proto.positionInside = function positionInside(index2, stringRepresentation) {
15236 var string = stringRepresentation || this.toString();
15237 var column = this.source.start.column;
15238 var line = this.source.start.line;
15239 for(var i2 = 0; i2 < index2; i2++){
15240 if (string[i2] === "\n") {
15241 column = 1;
15242 line += 1;
15243 } else {
15244 column += 1;
15245 }
15246 }
15247 return {
15248 column: column,
15249 line: line
15250 };
15251 };
15252 _proto.prev = function prev() {
15253 if (!this.parent) return void 0;
15254 var index2 = this.parent.index(this);
15255 return this.parent.nodes[index2 - 1];
15256 };
15257 _proto.rangeBy = function rangeBy(opts) {
15258 var start = {
15259 column: this.source.start.column,
15260 line: this.source.start.line
15261 };
15262 var end = this.source.end ? {
15263 column: this.source.end.column + 1,
15264 line: this.source.end.line
15265 } : {
15266 column: start.column + 1,
15267 line: start.line
15268 };
15269 if (opts.word) {
15270 var stringRepresentation = this.toString();
15271 var index2 = stringRepresentation.indexOf(opts.word);
15272 if (index2 !== -1) {
15273 start = this.positionInside(index2, stringRepresentation);
15274 end = this.positionInside(index2 + opts.word.length, stringRepresentation);
15275 }
15276 } else {
15277 if (opts.start) {
15278 start = {
15279 column: opts.start.column,
15280 line: opts.start.line
15281 };
15282 } else if (opts.index) {
15283 start = this.positionInside(opts.index);
15284 }
15285 if (opts.end) {
15286 end = {
15287 column: opts.end.column,
15288 line: opts.end.line
15289 };
15290 } else if (typeof opts.endIndex === "number") {
15291 end = this.positionInside(opts.endIndex);
15292 } else if (opts.index) {
15293 end = this.positionInside(opts.index + 1);
15294 }
15295 }
15296 if (end.line < start.line || end.line === start.line && end.column <= start.column) {
15297 end = {
15298 column: start.column + 1,
15299 line: start.line
15300 };
15301 }
15302 return {
15303 end: end,
15304 start: start
15305 };
15306 };
15307 _proto.raw = function raw(prop, defaultType) {
15308 var str = new Stringifier22();
15309 return str.raw(this, prop, defaultType);
15310 };
15311 _proto.remove = function remove() {
15312 if (this.parent) {
15313 this.parent.removeChild(this);
15314 }
15315 this.parent = void 0;
15316 return this;
15317 };
15318 _proto.replaceWith = function replaceWith() {
15319 for(var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++){
15320 nodes[_key] = arguments[_key];
15321 }
15322 if (this.parent) {
15323 var bookmark = this;
15324 var foundSelf = false;
15325 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
15326 var node2 = _step.value;
15327 if (node2 === this) {
15328 foundSelf = true;
15329 } else if (foundSelf) {
15330 this.parent.insertAfter(bookmark, node2);
15331 bookmark = node2;
15332 } else {
15333 this.parent.insertBefore(bookmark, node2);
15334 }
15335 }
15336 if (!foundSelf) {
15337 this.remove();
15338 }
15339 }
15340 return this;
15341 };
15342 _proto.root = function root() {
15343 var result2 = this;
15344 while(result2.parent && result2.parent.type !== "document"){
15345 result2 = result2.parent;
15346 }
15347 return result2;
15348 };
15349 _proto.toJSON = function toJSON(_, inputs) {
15350 var fixed = {};
15351 var emitInputs = inputs == null;
15352 inputs = inputs || /* @__PURE__ */ new Map();
15353 var inputsNextIndex = 0;
15354 for(var name in this){
15355 if (!Object.prototype.hasOwnProperty.call(this, name)) {
15356 continue;
15357 }
15358 if (name === "parent" || name === "proxyCache") continue;
15359 var value = this[name];
15360 if (Array.isArray(value)) {
15361 fixed[name] = value.map(function(i2) {
15362 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.toJSON) {
15363 return i2.toJSON(null, inputs);
15364 } else {
15365 return i2;
15366 }
15367 });
15368 } else if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value.toJSON) {
15369 fixed[name] = value.toJSON(null, inputs);
15370 } else if (name === "source") {
15371 var inputId = inputs.get(value.input);
15372 if (inputId == null) {
15373 inputId = inputsNextIndex;
15374 inputs.set(value.input, inputsNextIndex);
15375 inputsNextIndex++;
15376 }
15377 fixed[name] = {
15378 end: value.end,
15379 inputId: inputId,
15380 start: value.start
15381 };
15382 } else {
15383 fixed[name] = value;
15384 }
15385 }
15386 if (emitInputs) {
15387 fixed.inputs = [].concat(inputs.keys()).map(function(input2) {
15388 return input2.toJSON();
15389 });
15390 }
15391 return fixed;
15392 };
15393 _proto.toProxy = function toProxy() {
15394 if (!this.proxyCache) {
15395 this.proxyCache = new Proxy(this, this.getProxyProcessor());
15396 }
15397 return this.proxyCache;
15398 };
15399 _proto.toString = function toString(stringifier2) {
15400 if (stringifier2 === void 0) stringifier2 = stringify$3;
15401 if (stringifier2.stringify) stringifier2 = stringifier2.stringify;
15402 var result2 = "";
15403 stringifier2(this, function(i2) {
15404 result2 += i2;
15405 });
15406 return result2;
15407 };
15408 _proto.warn = function warn(result2, text, opts) {
15409 var data = {
15410 node: this
15411 };
15412 for(var i2 in opts)data[i2] = opts[i2];
15413 return result2.warn(text, data);
15414 };
15415 _create_class(Node3, [
15416 {
15417 key: "proxyOf",
15418 get: function get() {
15419 return this;
15420 }
15421 }
15422 ]);
15423 return Node3;
15424 }();
15425 var node = Node$4;
15426 Node$4.default = Node$4;
15427 var Node$3 = node;
15428 var Declaration$4 = /*#__PURE__*/ function(Node$3) {
15429 _inherits(Declaration2, Node$3);
15430 function Declaration2(defaults) {
15431 var _this;
15432 if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
15433 defaults = _extends({}, defaults, {
15434 value: String(defaults.value)
15435 });
15436 }
15437 _this = Node$3.call(this, defaults) || this;
15438 _this.type = "decl";
15439 return _this;
15440 }
15441 _create_class(Declaration2, [
15442 {
15443 key: "variable",
15444 get: function get() {
15445 return this.prop.startsWith("--") || this.prop[0] === "$";
15446 }
15447 }
15448 ]);
15449 return Declaration2;
15450 }(Node$3);
15451 var declaration = Declaration$4;
15452 Declaration$4.default = Declaration$4;
15453 var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
15454 var nanoid$1 = function(size) {
15455 if (size === void 0) size = 21;
15456 var id = "";
15457 var i2 = size;
15458 while(i2--){
15459 id += urlAlphabet[Math.random() * 64 | 0];
15460 }
15461 return id;
15462 };
15463 var nonSecure = {
15464 nanoid: nanoid$1};
15465 var SourceMapConsumer$2 = require$$2.SourceMapConsumer, SourceMapGenerator$2 = require$$2.SourceMapGenerator;
15466 var existsSync = require$$2.existsSync, readFileSync = require$$2.readFileSync;
15467 var dirname$1 = require$$2.dirname, join = require$$2.join;
15468 function fromBase64(str) {
15469 if (Buffer) {
15470 return Buffer.from(str, "base64").toString();
15471 } else {
15472 return window.atob(str);
15473 }
15474 }
15475 var PreviousMap$2 = /*#__PURE__*/ function() {
15476 function PreviousMap2(css, opts) {
15477 if (opts.map === false) return;
15478 this.loadAnnotation(css);
15479 this.inline = this.startWith(this.annotation, "data:");
15480 var prev = opts.map ? opts.map.prev : void 0;
15481 var text = this.loadMap(opts.from, prev);
15482 if (!this.mapFile && opts.from) {
15483 this.mapFile = opts.from;
15484 }
15485 if (this.mapFile) this.root = dirname$1(this.mapFile);
15486 if (text) this.text = text;
15487 }
15488 var _proto = PreviousMap2.prototype;
15489 _proto.consumer = function consumer() {
15490 if (!this.consumerCache) {
15491 this.consumerCache = new SourceMapConsumer$2(this.text);
15492 }
15493 return this.consumerCache;
15494 };
15495 _proto.decodeInline = function decodeInline(text) {
15496 var baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
15497 var baseUri = /^data:application\/json;base64,/;
15498 var charsetUri = /^data:application\/json;charset=utf-?8,/;
15499 var uri = /^data:application\/json,/;
15500 if (charsetUri.test(text) || uri.test(text)) {
15501 return decodeURIComponent(text.substr(RegExp.lastMatch.length));
15502 }
15503 if (baseCharsetUri.test(text) || baseUri.test(text)) {
15504 return fromBase64(text.substr(RegExp.lastMatch.length));
15505 }
15506 var encoding = text.match(/data:application\/json;([^,]+),/)[1];
15507 throw new Error("Unsupported source map encoding " + encoding);
15508 };
15509 _proto.getAnnotationURL = function getAnnotationURL(sourceMapString) {
15510 return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
15511 };
15512 _proto.isMap = function isMap(map) {
15513 if ((typeof map === "undefined" ? "undefined" : _type_of(map)) !== "object") return false;
15514 return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
15515 };
15516 _proto.loadAnnotation = function loadAnnotation(css) {
15517 var comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
15518 if (!comments) return;
15519 var start = css.lastIndexOf(comments.pop());
15520 var end = css.indexOf("*/", start);
15521 if (start > -1 && end > -1) {
15522 this.annotation = this.getAnnotationURL(css.substring(start, end));
15523 }
15524 };
15525 _proto.loadFile = function loadFile(path) {
15526 this.root = dirname$1(path);
15527 if (existsSync(path)) {
15528 this.mapFile = path;
15529 return readFileSync(path, "utf-8").toString().trim();
15530 }
15531 };
15532 _proto.loadMap = function loadMap(file, prev) {
15533 if (prev === false) return false;
15534 if (prev) {
15535 if (typeof prev === "string") {
15536 return prev;
15537 } else if (typeof prev === "function") {
15538 var prevPath = prev(file);
15539 if (prevPath) {
15540 var map = this.loadFile(prevPath);
15541 if (!map) {
15542 throw new Error("Unable to load previous source map: " + prevPath.toString());
15543 }
15544 return map;
15545 }
15546 } else if (_instanceof(prev, SourceMapConsumer$2)) {
15547 return SourceMapGenerator$2.fromSourceMap(prev).toString();
15548 } else if (_instanceof(prev, SourceMapGenerator$2)) {
15549 return prev.toString();
15550 } else if (this.isMap(prev)) {
15551 return JSON.stringify(prev);
15552 } else {
15553 throw new Error("Unsupported previous source map format: " + prev.toString());
15554 }
15555 } else if (this.inline) {
15556 return this.decodeInline(this.annotation);
15557 } else if (this.annotation) {
15558 var map1 = this.annotation;
15559 if (file) map1 = join(dirname$1(file), map1);
15560 return this.loadFile(map1);
15561 }
15562 };
15563 _proto.startWith = function startWith(string, start) {
15564 if (!string) return false;
15565 return string.substr(0, start.length) === start;
15566 };
15567 _proto.withContent = function withContent() {
15568 return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
15569 };
15570 return PreviousMap2;
15571 }();
15572 var previousMap = PreviousMap$2;
15573 PreviousMap$2.default = PreviousMap$2;
15574 var SourceMapConsumer$1 = require$$2.SourceMapConsumer, SourceMapGenerator$1 = require$$2.SourceMapGenerator;
15575 var fileURLToPath = require$$2.fileURLToPath, pathToFileURL$1 = require$$2.pathToFileURL;
15576 var isAbsolute = require$$2.isAbsolute, resolve$1 = require$$2.resolve;
15577 var nanoid = nonSecure.nanoid;
15578 var terminalHighlight = require$$2;
15579 var CssSyntaxError$1 = cssSyntaxError;
15580 var PreviousMap$1 = previousMap;
15581 var fromOffsetCache = Symbol("fromOffsetCache");
15582 var sourceMapAvailable$1 = Boolean(SourceMapConsumer$1 && SourceMapGenerator$1);
15583 var pathAvailable$1 = Boolean(resolve$1 && isAbsolute);
15584 var Input$4 = /*#__PURE__*/ function() {
15585 function Input2(css, opts) {
15586 if (opts === void 0) opts = {};
15587 if (css === null || typeof css === "undefined" || (typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && !css.toString) {
15588 throw new Error("PostCSS received " + css + " instead of CSS string");
15589 }
15590 this.css = css.toString();
15591 if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
15592 this.hasBOM = true;
15593 this.css = this.css.slice(1);
15594 } else {
15595 this.hasBOM = false;
15596 }
15597 if (opts.from) {
15598 if (!pathAvailable$1 || /^\w+:\/\//.test(opts.from) || isAbsolute(opts.from)) {
15599 this.file = opts.from;
15600 } else {
15601 this.file = resolve$1(opts.from);
15602 }
15603 }
15604 if (pathAvailable$1 && sourceMapAvailable$1) {
15605 var map = new PreviousMap$1(this.css, opts);
15606 if (map.text) {
15607 this.map = map;
15608 var file = map.consumer().file;
15609 if (!this.file && file) this.file = this.mapResolve(file);
15610 }
15611 }
15612 if (!this.file) {
15613 this.id = "<input css " + nanoid(6) + ">";
15614 }
15615 if (this.map) this.map.file = this.from;
15616 }
15617 var _proto = Input2.prototype;
15618 _proto.error = function error(message, line, column, opts) {
15619 if (opts === void 0) opts = {};
15620 var result2, endLine, endColumn;
15621 if (line && (typeof line === "undefined" ? "undefined" : _type_of(line)) === "object") {
15622 var start = line;
15623 var end = column;
15624 if (typeof start.offset === "number") {
15625 var pos = this.fromOffset(start.offset);
15626 line = pos.line;
15627 column = pos.col;
15628 } else {
15629 line = start.line;
15630 column = start.column;
15631 }
15632 if (typeof end.offset === "number") {
15633 var pos1 = this.fromOffset(end.offset);
15634 endLine = pos1.line;
15635 endColumn = pos1.col;
15636 } else {
15637 endLine = end.line;
15638 endColumn = end.column;
15639 }
15640 } else if (!column) {
15641 var pos2 = this.fromOffset(line);
15642 line = pos2.line;
15643 column = pos2.col;
15644 }
15645 var origin = this.origin(line, column, endLine, endColumn);
15646 if (origin) {
15647 result2 = new CssSyntaxError$1(message, origin.endLine === void 0 ? origin.line : {
15648 column: origin.column,
15649 line: origin.line
15650 }, origin.endLine === void 0 ? origin.column : {
15651 column: origin.endColumn,
15652 line: origin.endLine
15653 }, origin.source, origin.file, opts.plugin);
15654 } else {
15655 result2 = new CssSyntaxError$1(message, endLine === void 0 ? line : {
15656 column: column,
15657 line: line
15658 }, endLine === void 0 ? column : {
15659 column: endColumn,
15660 line: endLine
15661 }, this.css, this.file, opts.plugin);
15662 }
15663 result2.input = {
15664 column: column,
15665 endColumn: endColumn,
15666 endLine: endLine,
15667 line: line,
15668 source: this.css
15669 };
15670 if (this.file) {
15671 if (pathToFileURL$1) {
15672 result2.input.url = pathToFileURL$1(this.file).toString();
15673 }
15674 result2.input.file = this.file;
15675 }
15676 return result2;
15677 };
15678 _proto.fromOffset = function fromOffset(offset) {
15679 var lastLine, lineToIndex;
15680 if (!this[fromOffsetCache]) {
15681 var lines = this.css.split("\n");
15682 lineToIndex = new Array(lines.length);
15683 var prevIndex = 0;
15684 for(var i2 = 0, l2 = lines.length; i2 < l2; i2++){
15685 lineToIndex[i2] = prevIndex;
15686 prevIndex += lines[i2].length + 1;
15687 }
15688 this[fromOffsetCache] = lineToIndex;
15689 } else {
15690 lineToIndex = this[fromOffsetCache];
15691 }
15692 lastLine = lineToIndex[lineToIndex.length - 1];
15693 var min = 0;
15694 if (offset >= lastLine) {
15695 min = lineToIndex.length - 1;
15696 } else {
15697 var max = lineToIndex.length - 2;
15698 var mid;
15699 while(min < max){
15700 mid = min + (max - min >> 1);
15701 if (offset < lineToIndex[mid]) {
15702 max = mid - 1;
15703 } else if (offset >= lineToIndex[mid + 1]) {
15704 min = mid + 1;
15705 } else {
15706 min = mid;
15707 break;
15708 }
15709 }
15710 }
15711 return {
15712 col: offset - lineToIndex[min] + 1,
15713 line: min + 1
15714 };
15715 };
15716 _proto.mapResolve = function mapResolve(file) {
15717 if (/^\w+:\/\//.test(file)) {
15718 return file;
15719 }
15720 return resolve$1(this.map.consumer().sourceRoot || this.map.root || ".", file);
15721 };
15722 _proto.origin = function origin(line, column, endLine, endColumn) {
15723 if (!this.map) return false;
15724 var consumer = this.map.consumer();
15725 var from = consumer.originalPositionFor({
15726 column: column,
15727 line: line
15728 });
15729 if (!from.source) return false;
15730 var to;
15731 if (typeof endLine === "number") {
15732 to = consumer.originalPositionFor({
15733 column: endColumn,
15734 line: endLine
15735 });
15736 }
15737 var fromUrl;
15738 if (isAbsolute(from.source)) {
15739 fromUrl = pathToFileURL$1(from.source);
15740 } else {
15741 fromUrl = new URL(from.source, this.map.consumer().sourceRoot || pathToFileURL$1(this.map.mapFile));
15742 }
15743 var result2 = {
15744 column: from.column,
15745 endColumn: to && to.column,
15746 endLine: to && to.line,
15747 line: from.line,
15748 url: fromUrl.toString()
15749 };
15750 if (fromUrl.protocol === "file:") {
15751 if (fileURLToPath) {
15752 result2.file = fileURLToPath(fromUrl);
15753 } else {
15754 throw new Error("file: protocol is not available in this PostCSS build");
15755 }
15756 }
15757 var source = consumer.sourceContentFor(from.source);
15758 if (source) result2.source = source;
15759 return result2;
15760 };
15761 _proto.toJSON = function toJSON() {
15762 var json = {};
15763 for(var _i = 0, _iter = [
15764 "hasBOM",
15765 "css",
15766 "file",
15767 "id"
15768 ]; _i < _iter.length; _i++){
15769 var name = _iter[_i];
15770 if (this[name] != null) {
15771 json[name] = this[name];
15772 }
15773 }
15774 if (this.map) {
15775 json.map = _extends({}, this.map);
15776 if (json.map.consumerCache) {
15777 json.map.consumerCache = void 0;
15778 }
15779 }
15780 return json;
15781 };
15782 _create_class(Input2, [
15783 {
15784 key: "from",
15785 get: function get() {
15786 return this.file || this.id;
15787 }
15788 }
15789 ]);
15790 return Input2;
15791 }();
15792 var input = Input$4;
15793 Input$4.default = Input$4;
15794 if (terminalHighlight && terminalHighlight.registerInput) {
15795 terminalHighlight.registerInput(Input$4);
15796 }
15797 var SourceMapConsumer = require$$2.SourceMapConsumer, SourceMapGenerator = require$$2.SourceMapGenerator;
15798 var dirname = require$$2.dirname, relative = require$$2.relative, resolve$3 = require$$2.resolve, sep = require$$2.sep;
15799 var pathToFileURL = require$$2.pathToFileURL;
15800 var Input$3 = input;
15801 var sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
15802 var pathAvailable = Boolean(dirname && resolve$3 && relative && sep);
15803 var MapGenerator$2 = /*#__PURE__*/ function() {
15804 function MapGenerator2(stringify2, root2, opts, cssString) {
15805 this.stringify = stringify2;
15806 this.mapOpts = opts.map || {};
15807 this.root = root2;
15808 this.opts = opts;
15809 this.css = cssString;
15810 this.originalCSS = cssString;
15811 this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
15812 this.memoizedFileURLs = /* @__PURE__ */ new Map();
15813 this.memoizedPaths = /* @__PURE__ */ new Map();
15814 this.memoizedURLs = /* @__PURE__ */ new Map();
15815 }
15816 var _proto = MapGenerator2.prototype;
15817 _proto.addAnnotation = function addAnnotation() {
15818 var content;
15819 if (this.isInline()) {
15820 content = "data:application/json;base64," + this.toBase64(this.map.toString());
15821 } else if (typeof this.mapOpts.annotation === "string") {
15822 content = this.mapOpts.annotation;
15823 } else if (typeof this.mapOpts.annotation === "function") {
15824 content = this.mapOpts.annotation(this.opts.to, this.root);
15825 } else {
15826 content = this.outputFile() + ".map";
15827 }
15828 var eol = "\n";
15829 if (this.css.includes("\r\n")) eol = "\r\n";
15830 this.css += eol + "/*# sourceMappingURL=" + content + " */";
15831 };
15832 _proto.applyPrevMaps = function applyPrevMaps() {
15833 for(var _iterator = _create_for_of_iterator_helper_loose(this.previous()), _step; !(_step = _iterator()).done;){
15834 var prev = _step.value;
15835 var from = this.toUrl(this.path(prev.file));
15836 var root2 = prev.root || dirname(prev.file);
15837 var map = void 0;
15838 if (this.mapOpts.sourcesContent === false) {
15839 map = new SourceMapConsumer(prev.text);
15840 if (map.sourcesContent) {
15841 map.sourcesContent = null;
15842 }
15843 } else {
15844 map = prev.consumer();
15845 }
15846 this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
15847 }
15848 };
15849 _proto.clearAnnotation = function clearAnnotation() {
15850 if (this.mapOpts.annotation === false) return;
15851 if (this.root) {
15852 var node2;
15853 for(var i2 = this.root.nodes.length - 1; i2 >= 0; i2--){
15854 node2 = this.root.nodes[i2];
15855 if (node2.type !== "comment") continue;
15856 if (node2.text.indexOf("# sourceMappingURL=") === 0) {
15857 this.root.removeChild(i2);
15858 }
15859 }
15860 } else if (this.css) {
15861 this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, "");
15862 }
15863 };
15864 _proto.generate = function generate() {
15865 this.clearAnnotation();
15866 if (pathAvailable && sourceMapAvailable && this.isMap()) {
15867 return this.generateMap();
15868 } else {
15869 var result2 = "";
15870 this.stringify(this.root, function(i2) {
15871 result2 += i2;
15872 });
15873 return [
15874 result2
15875 ];
15876 }
15877 };
15878 _proto.generateMap = function generateMap() {
15879 if (this.root) {
15880 this.generateString();
15881 } else if (this.previous().length === 1) {
15882 var prev = this.previous()[0].consumer();
15883 prev.file = this.outputFile();
15884 this.map = SourceMapGenerator.fromSourceMap(prev, {
15885 ignoreInvalidMapping: true
15886 });
15887 } else {
15888 this.map = new SourceMapGenerator({
15889 file: this.outputFile(),
15890 ignoreInvalidMapping: true
15891 });
15892 this.map.addMapping({
15893 generated: {
15894 column: 0,
15895 line: 1
15896 },
15897 original: {
15898 column: 0,
15899 line: 1
15900 },
15901 source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
15902 });
15903 }
15904 if (this.isSourcesContent()) this.setSourcesContent();
15905 if (this.root && this.previous().length > 0) this.applyPrevMaps();
15906 if (this.isAnnotation()) this.addAnnotation();
15907 if (this.isInline()) {
15908 return [
15909 this.css
15910 ];
15911 } else {
15912 return [
15913 this.css,
15914 this.map
15915 ];
15916 }
15917 };
15918 _proto.generateString = function generateString() {
15919 var _this = this;
15920 this.css = "";
15921 this.map = new SourceMapGenerator({
15922 file: this.outputFile(),
15923 ignoreInvalidMapping: true
15924 });
15925 var line = 1;
15926 var column = 1;
15927 var noSource = "<no source>";
15928 var mapping = {
15929 generated: {
15930 column: 0,
15931 line: 0
15932 },
15933 original: {
15934 column: 0,
15935 line: 0
15936 },
15937 source: ""
15938 };
15939 var lines, last;
15940 this.stringify(this.root, function(str, node2, type) {
15941 _this.css += str;
15942 if (node2 && type !== "end") {
15943 mapping.generated.line = line;
15944 mapping.generated.column = column - 1;
15945 if (node2.source && node2.source.start) {
15946 mapping.source = _this.sourcePath(node2);
15947 mapping.original.line = node2.source.start.line;
15948 mapping.original.column = node2.source.start.column - 1;
15949 _this.map.addMapping(mapping);
15950 } else {
15951 mapping.source = noSource;
15952 mapping.original.line = 1;
15953 mapping.original.column = 0;
15954 _this.map.addMapping(mapping);
15955 }
15956 }
15957 lines = str.match(/\n/g);
15958 if (lines) {
15959 line += lines.length;
15960 last = str.lastIndexOf("\n");
15961 column = str.length - last;
15962 } else {
15963 column += str.length;
15964 }
15965 if (node2 && type !== "start") {
15966 var p = node2.parent || {
15967 raws: {}
15968 };
15969 var childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
15970 if (!childless || node2 !== p.last || p.raws.semicolon) {
15971 if (node2.source && node2.source.end) {
15972 mapping.source = _this.sourcePath(node2);
15973 mapping.original.line = node2.source.end.line;
15974 mapping.original.column = node2.source.end.column - 1;
15975 mapping.generated.line = line;
15976 mapping.generated.column = column - 2;
15977 _this.map.addMapping(mapping);
15978 } else {
15979 mapping.source = noSource;
15980 mapping.original.line = 1;
15981 mapping.original.column = 0;
15982 mapping.generated.line = line;
15983 mapping.generated.column = column - 1;
15984 _this.map.addMapping(mapping);
15985 }
15986 }
15987 }
15988 });
15989 };
15990 _proto.isAnnotation = function isAnnotation() {
15991 if (this.isInline()) {
15992 return true;
15993 }
15994 if (typeof this.mapOpts.annotation !== "undefined") {
15995 return this.mapOpts.annotation;
15996 }
15997 if (this.previous().length) {
15998 return this.previous().some(function(i2) {
15999 return i2.annotation;
16000 });
16001 }
16002 return true;
16003 };
16004 _proto.isInline = function isInline() {
16005 if (typeof this.mapOpts.inline !== "undefined") {
16006 return this.mapOpts.inline;
16007 }
16008 var annotation = this.mapOpts.annotation;
16009 if (typeof annotation !== "undefined" && annotation !== true) {
16010 return false;
16011 }
16012 if (this.previous().length) {
16013 return this.previous().some(function(i2) {
16014 return i2.inline;
16015 });
16016 }
16017 return true;
16018 };
16019 _proto.isMap = function isMap() {
16020 if (typeof this.opts.map !== "undefined") {
16021 return !!this.opts.map;
16022 }
16023 return this.previous().length > 0;
16024 };
16025 _proto.isSourcesContent = function isSourcesContent() {
16026 if (typeof this.mapOpts.sourcesContent !== "undefined") {
16027 return this.mapOpts.sourcesContent;
16028 }
16029 if (this.previous().length) {
16030 return this.previous().some(function(i2) {
16031 return i2.withContent();
16032 });
16033 }
16034 return true;
16035 };
16036 _proto.outputFile = function outputFile() {
16037 if (this.opts.to) {
16038 return this.path(this.opts.to);
16039 } else if (this.opts.from) {
16040 return this.path(this.opts.from);
16041 } else {
16042 return "to.css";
16043 }
16044 };
16045 _proto.path = function path(file) {
16046 if (this.mapOpts.absolute) return file;
16047 if (file.charCodeAt(0) === 60) return file;
16048 if (/^\w+:\/\//.test(file)) return file;
16049 var cached = this.memoizedPaths.get(file);
16050 if (cached) return cached;
16051 var from = this.opts.to ? dirname(this.opts.to) : ".";
16052 if (typeof this.mapOpts.annotation === "string") {
16053 from = dirname(resolve$3(from, this.mapOpts.annotation));
16054 }
16055 var path = relative(from, file);
16056 this.memoizedPaths.set(file, path);
16057 return path;
16058 };
16059 _proto.previous = function previous() {
16060 var _this = this;
16061 if (!this.previousMaps) {
16062 this.previousMaps = [];
16063 if (this.root) {
16064 this.root.walk(function(node2) {
16065 if (node2.source && node2.source.input.map) {
16066 var map = node2.source.input.map;
16067 if (!_this.previousMaps.includes(map)) {
16068 _this.previousMaps.push(map);
16069 }
16070 }
16071 });
16072 } else {
16073 var input2 = new Input$3(this.originalCSS, this.opts);
16074 if (input2.map) this.previousMaps.push(input2.map);
16075 }
16076 }
16077 return this.previousMaps;
16078 };
16079 _proto.setSourcesContent = function setSourcesContent() {
16080 var _this = this;
16081 var already = {};
16082 if (this.root) {
16083 this.root.walk(function(node2) {
16084 if (node2.source) {
16085 var from = node2.source.input.from;
16086 if (from && !already[from]) {
16087 already[from] = true;
16088 var fromUrl = _this.usesFileUrls ? _this.toFileUrl(from) : _this.toUrl(_this.path(from));
16089 _this.map.setSourceContent(fromUrl, node2.source.input.css);
16090 }
16091 }
16092 });
16093 } else if (this.css) {
16094 var from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
16095 this.map.setSourceContent(from, this.css);
16096 }
16097 };
16098 _proto.sourcePath = function sourcePath(node2) {
16099 if (this.mapOpts.from) {
16100 return this.toUrl(this.mapOpts.from);
16101 } else if (this.usesFileUrls) {
16102 return this.toFileUrl(node2.source.input.from);
16103 } else {
16104 return this.toUrl(this.path(node2.source.input.from));
16105 }
16106 };
16107 _proto.toBase64 = function toBase64(str) {
16108 if (Buffer) {
16109 return Buffer.from(str).toString("base64");
16110 } else {
16111 return window.btoa(unescape(encodeURIComponent(str)));
16112 }
16113 };
16114 _proto.toFileUrl = function toFileUrl(path) {
16115 var cached = this.memoizedFileURLs.get(path);
16116 if (cached) return cached;
16117 if (pathToFileURL) {
16118 var fileURL = pathToFileURL(path).toString();
16119 this.memoizedFileURLs.set(path, fileURL);
16120 return fileURL;
16121 } else {
16122 throw new Error("`map.absolute` option is not available in this PostCSS build");
16123 }
16124 };
16125 _proto.toUrl = function toUrl(path) {
16126 var cached = this.memoizedURLs.get(path);
16127 if (cached) return cached;
16128 if (sep === "\\") {
16129 path = path.replace(/\\/g, "/");
16130 }
16131 var url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
16132 this.memoizedURLs.set(path, url);
16133 return url;
16134 };
16135 return MapGenerator2;
16136 }();
16137 var mapGenerator = MapGenerator$2;
16138 var Node$2 = node;
16139 var Comment$4 = /*#__PURE__*/ function(Node$2) {
16140 _inherits(Comment2, Node$2);
16141 function Comment2(defaults) {
16142 var _this;
16143 _this = Node$2.call(this, defaults) || this;
16144 _this.type = "comment";
16145 return _this;
16146 }
16147 return Comment2;
16148 }(Node$2);
16149 var comment = Comment$4;
16150 Comment$4.default = Comment$4;
16151 var isClean$1 = symbols.isClean, my$1 = symbols.my;
16152 var Declaration$3 = declaration;
16153 var Comment$3 = comment;
16154 var Node$1 = node;
16155 var parse$4, Rule$4, AtRule$4, Root$6;
16156 function cleanSource(nodes) {
16157 return nodes.map(function(i2) {
16158 if (i2.nodes) i2.nodes = cleanSource(i2.nodes);
16159 delete i2.source;
16160 return i2;
16161 });
16162 }
16163 function markDirtyUp(node2) {
16164 node2[isClean$1] = false;
16165 if (node2.proxyOf.nodes) {
16166 for(var _iterator = _create_for_of_iterator_helper_loose(node2.proxyOf.nodes), _step; !(_step = _iterator()).done;){
16167 var i2 = _step.value;
16168 markDirtyUp(i2);
16169 }
16170 }
16171 }
16172 var Container$7 = /*#__PURE__*/ function(Node$1) {
16173 _inherits(Container2, Node$1);
16174 function Container2() {
16175 return Node$1.apply(this, arguments) || this;
16176 }
16177 var _proto = Container2.prototype;
16178 _proto.append = function append() {
16179 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16180 children[_key] = arguments[_key];
16181 }
16182 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
16183 var child = _step.value;
16184 var nodes = this.normalize(child, this.last);
16185 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
16186 var node2 = _step1.value;
16187 this.proxyOf.nodes.push(node2);
16188 }
16189 }
16190 this.markDirty();
16191 return this;
16192 };
16193 _proto.cleanRaws = function cleanRaws(keepBetween) {
16194 Node$1.prototype.cleanRaws.call(this, keepBetween);
16195 if (this.nodes) {
16196 for(var _iterator = _create_for_of_iterator_helper_loose(this.nodes), _step; !(_step = _iterator()).done;){
16197 var node2 = _step.value;
16198 node2.cleanRaws(keepBetween);
16199 }
16200 }
16201 };
16202 _proto.each = function each(callback) {
16203 if (!this.proxyOf.nodes) return void 0;
16204 var iterator = this.getIterator();
16205 var index2, result2;
16206 while(this.indexes[iterator] < this.proxyOf.nodes.length){
16207 index2 = this.indexes[iterator];
16208 result2 = callback(this.proxyOf.nodes[index2], index2);
16209 if (result2 === false) break;
16210 this.indexes[iterator] += 1;
16211 }
16212 delete this.indexes[iterator];
16213 return result2;
16214 };
16215 _proto.every = function every(condition) {
16216 return this.nodes.every(condition);
16217 };
16218 _proto.getIterator = function getIterator() {
16219 if (!this.lastEach) this.lastEach = 0;
16220 if (!this.indexes) this.indexes = {};
16221 this.lastEach += 1;
16222 var iterator = this.lastEach;
16223 this.indexes[iterator] = 0;
16224 return iterator;
16225 };
16226 _proto.getProxyProcessor = function getProxyProcessor() {
16227 return {
16228 get: function get(node2, prop) {
16229 if (prop === "proxyOf") {
16230 return node2;
16231 } else if (!node2[prop]) {
16232 return node2[prop];
16233 } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
16234 return function() {
16235 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
16236 args[_key] = arguments[_key];
16237 }
16238 var _node2;
16239 return (_node2 = node2)[prop].apply(_node2, [].concat(args.map(function(i2) {
16240 if (typeof i2 === "function") {
16241 return function(child, index2) {
16242 return i2(child.toProxy(), index2);
16243 };
16244 } else {
16245 return i2;
16246 }
16247 })));
16248 };
16249 } else if (prop === "every" || prop === "some") {
16250 return function(cb) {
16251 return node2[prop](function(child) {
16252 for(var _len = arguments.length, other = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
16253 other[_key - 1] = arguments[_key];
16254 }
16255 return cb.apply(void 0, [].concat([
16256 child.toProxy()
16257 ], other));
16258 });
16259 };
16260 } else if (prop === "root") {
16261 return function() {
16262 return node2.root().toProxy();
16263 };
16264 } else if (prop === "nodes") {
16265 return node2.nodes.map(function(i2) {
16266 return i2.toProxy();
16267 });
16268 } else if (prop === "first" || prop === "last") {
16269 return node2[prop].toProxy();
16270 } else {
16271 return node2[prop];
16272 }
16273 },
16274 set: function set(node2, prop, value) {
16275 if (node2[prop] === value) return true;
16276 node2[prop] = value;
16277 if (prop === "name" || prop === "params" || prop === "selector") {
16278 node2.markDirty();
16279 }
16280 return true;
16281 }
16282 };
16283 };
16284 _proto.index = function index(child) {
16285 if (typeof child === "number") return child;
16286 if (child.proxyOf) child = child.proxyOf;
16287 return this.proxyOf.nodes.indexOf(child);
16288 };
16289 _proto.insertAfter = function insertAfter(exist, add) {
16290 var existIndex = this.index(exist);
16291 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
16292 existIndex = this.index(exist);
16293 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
16294 var node2 = _step.value;
16295 this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
16296 }
16297 var index2;
16298 for(var id in this.indexes){
16299 index2 = this.indexes[id];
16300 if (existIndex < index2) {
16301 this.indexes[id] = index2 + nodes.length;
16302 }
16303 }
16304 this.markDirty();
16305 return this;
16306 };
16307 _proto.insertBefore = function insertBefore(exist, add) {
16308 var existIndex = this.index(exist);
16309 var type = existIndex === 0 ? "prepend" : false;
16310 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
16311 existIndex = this.index(exist);
16312 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
16313 var node2 = _step.value;
16314 this.proxyOf.nodes.splice(existIndex, 0, node2);
16315 }
16316 var index2;
16317 for(var id in this.indexes){
16318 index2 = this.indexes[id];
16319 if (existIndex <= index2) {
16320 this.indexes[id] = index2 + nodes.length;
16321 }
16322 }
16323 this.markDirty();
16324 return this;
16325 };
16326 _proto.normalize = function normalize(nodes, sample) {
16327 var _this = this;
16328 if (typeof nodes === "string") {
16329 nodes = cleanSource(parse$4(nodes).nodes);
16330 } else if (typeof nodes === "undefined") {
16331 nodes = [];
16332 } else if (Array.isArray(nodes)) {
16333 nodes = nodes.slice(0);
16334 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
16335 var i2 = _step.value;
16336 if (i2.parent) i2.parent.removeChild(i2, "ignore");
16337 }
16338 } else if (nodes.type === "root" && this.type !== "document") {
16339 nodes = nodes.nodes.slice(0);
16340 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
16341 var i21 = _step1.value;
16342 if (i21.parent) i21.parent.removeChild(i21, "ignore");
16343 }
16344 } else if (nodes.type) {
16345 nodes = [
16346 nodes
16347 ];
16348 } else if (nodes.prop) {
16349 if (typeof nodes.value === "undefined") {
16350 throw new Error("Value field is missed in node creation");
16351 } else if (typeof nodes.value !== "string") {
16352 nodes.value = String(nodes.value);
16353 }
16354 nodes = [
16355 new Declaration$3(nodes)
16356 ];
16357 } else if (nodes.selector) {
16358 nodes = [
16359 new Rule$4(nodes)
16360 ];
16361 } else if (nodes.name) {
16362 nodes = [
16363 new AtRule$4(nodes)
16364 ];
16365 } else if (nodes.text) {
16366 nodes = [
16367 new Comment$3(nodes)
16368 ];
16369 } else {
16370 throw new Error("Unknown node type in node creation");
16371 }
16372 var processed = nodes.map(function(i2) {
16373 if (!i2[my$1]) Container2.rebuild(i2);
16374 i2 = i2.proxyOf;
16375 if (i2.parent) i2.parent.removeChild(i2);
16376 if (i2[isClean$1]) markDirtyUp(i2);
16377 if (typeof i2.raws.before === "undefined") {
16378 if (sample && typeof sample.raws.before !== "undefined") {
16379 i2.raws.before = sample.raws.before.replace(/\S/g, "");
16380 }
16381 }
16382 i2.parent = _this.proxyOf;
16383 return i2;
16384 });
16385 return processed;
16386 };
16387 _proto.prepend = function prepend() {
16388 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16389 children[_key] = arguments[_key];
16390 }
16391 children = children.reverse();
16392 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
16393 var child = _step.value;
16394 var nodes = this.normalize(child, this.first, "prepend").reverse();
16395 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
16396 var node2 = _step1.value;
16397 this.proxyOf.nodes.unshift(node2);
16398 }
16399 for(var id in this.indexes){
16400 this.indexes[id] = this.indexes[id] + nodes.length;
16401 }
16402 }
16403 this.markDirty();
16404 return this;
16405 };
16406 _proto.push = function push(child) {
16407 child.parent = this;
16408 this.proxyOf.nodes.push(child);
16409 return this;
16410 };
16411 _proto.removeAll = function removeAll() {
16412 for(var _iterator = _create_for_of_iterator_helper_loose(this.proxyOf.nodes), _step; !(_step = _iterator()).done;){
16413 var node2 = _step.value;
16414 node2.parent = void 0;
16415 }
16416 this.proxyOf.nodes = [];
16417 this.markDirty();
16418 return this;
16419 };
16420 _proto.removeChild = function removeChild(child) {
16421 child = this.index(child);
16422 this.proxyOf.nodes[child].parent = void 0;
16423 this.proxyOf.nodes.splice(child, 1);
16424 var index2;
16425 for(var id in this.indexes){
16426 index2 = this.indexes[id];
16427 if (index2 >= child) {
16428 this.indexes[id] = index2 - 1;
16429 }
16430 }
16431 this.markDirty();
16432 return this;
16433 };
16434 _proto.replaceValues = function replaceValues(pattern, opts, callback) {
16435 if (!callback) {
16436 callback = opts;
16437 opts = {};
16438 }
16439 this.walkDecls(function(decl) {
16440 if (opts.props && !opts.props.includes(decl.prop)) return;
16441 if (opts.fast && !decl.value.includes(opts.fast)) return;
16442 decl.value = decl.value.replace(pattern, callback);
16443 });
16444 this.markDirty();
16445 return this;
16446 };
16447 _proto.some = function some(condition) {
16448 return this.nodes.some(condition);
16449 };
16450 _proto.walk = function walk(callback) {
16451 return this.each(function(child, i2) {
16452 var result2;
16453 try {
16454 result2 = callback(child, i2);
16455 } catch (e2) {
16456 throw child.addToError(e2);
16457 }
16458 if (result2 !== false && child.walk) {
16459 result2 = child.walk(callback);
16460 }
16461 return result2;
16462 });
16463 };
16464 _proto.walkAtRules = function walkAtRules(name, callback) {
16465 if (!callback) {
16466 callback = name;
16467 return this.walk(function(child, i2) {
16468 if (child.type === "atrule") {
16469 return callback(child, i2);
16470 }
16471 });
16472 }
16473 if (_instanceof(name, RegExp)) {
16474 return this.walk(function(child, i2) {
16475 if (child.type === "atrule" && name.test(child.name)) {
16476 return callback(child, i2);
16477 }
16478 });
16479 }
16480 return this.walk(function(child, i2) {
16481 if (child.type === "atrule" && child.name === name) {
16482 return callback(child, i2);
16483 }
16484 });
16485 };
16486 _proto.walkComments = function walkComments(callback) {
16487 return this.walk(function(child, i2) {
16488 if (child.type === "comment") {
16489 return callback(child, i2);
16490 }
16491 });
16492 };
16493 _proto.walkDecls = function walkDecls(prop, callback) {
16494 if (!callback) {
16495 callback = prop;
16496 return this.walk(function(child, i2) {
16497 if (child.type === "decl") {
16498 return callback(child, i2);
16499 }
16500 });
16501 }
16502 if (_instanceof(prop, RegExp)) {
16503 return this.walk(function(child, i2) {
16504 if (child.type === "decl" && prop.test(child.prop)) {
16505 return callback(child, i2);
16506 }
16507 });
16508 }
16509 return this.walk(function(child, i2) {
16510 if (child.type === "decl" && child.prop === prop) {
16511 return callback(child, i2);
16512 }
16513 });
16514 };
16515 _proto.walkRules = function walkRules(selector, callback) {
16516 if (!callback) {
16517 callback = selector;
16518 return this.walk(function(child, i2) {
16519 if (child.type === "rule") {
16520 return callback(child, i2);
16521 }
16522 });
16523 }
16524 if (_instanceof(selector, RegExp)) {
16525 return this.walk(function(child, i2) {
16526 if (child.type === "rule" && selector.test(child.selector)) {
16527 return callback(child, i2);
16528 }
16529 });
16530 }
16531 return this.walk(function(child, i2) {
16532 if (child.type === "rule" && child.selector === selector) {
16533 return callback(child, i2);
16534 }
16535 });
16536 };
16537 _create_class(Container2, [
16538 {
16539 key: "first",
16540 get: function get() {
16541 if (!this.proxyOf.nodes) return void 0;
16542 return this.proxyOf.nodes[0];
16543 }
16544 },
16545 {
16546 key: "last",
16547 get: function get() {
16548 if (!this.proxyOf.nodes) return void 0;
16549 return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
16550 }
16551 }
16552 ]);
16553 return Container2;
16554 }(Node$1);
16555 Container$7.registerParse = function(dependant) {
16556 parse$4 = dependant;
16557 };
16558 Container$7.registerRule = function(dependant) {
16559 Rule$4 = dependant;
16560 };
16561 Container$7.registerAtRule = function(dependant) {
16562 AtRule$4 = dependant;
16563 };
16564 Container$7.registerRoot = function(dependant) {
16565 Root$6 = dependant;
16566 };
16567 var container = Container$7;
16568 Container$7.default = Container$7;
16569 Container$7.rebuild = function(node2) {
16570 if (node2.type === "atrule") {
16571 Object.setPrototypeOf(node2, AtRule$4.prototype);
16572 } else if (node2.type === "rule") {
16573 Object.setPrototypeOf(node2, Rule$4.prototype);
16574 } else if (node2.type === "decl") {
16575 Object.setPrototypeOf(node2, Declaration$3.prototype);
16576 } else if (node2.type === "comment") {
16577 Object.setPrototypeOf(node2, Comment$3.prototype);
16578 } else if (node2.type === "root") {
16579 Object.setPrototypeOf(node2, Root$6.prototype);
16580 }
16581 node2[my$1] = true;
16582 if (node2.nodes) {
16583 node2.nodes.forEach(function(child) {
16584 Container$7.rebuild(child);
16585 });
16586 }
16587 };
16588 var Container$6 = container;
16589 var LazyResult$4, Processor$3;
16590 var Document$3 = /*#__PURE__*/ function(Container$6) {
16591 _inherits(Document23, Container$6);
16592 function Document23(defaults) {
16593 var _this;
16594 _this = Container$6.call(this, _extends({
16595 type: "document"
16596 }, defaults)) || this;
16597 if (!_this.nodes) {
16598 _this.nodes = [];
16599 }
16600 return _this;
16601 }
16602 var _proto = Document23.prototype;
16603 _proto.toResult = function toResult(opts) {
16604 if (opts === void 0) opts = {};
16605 var lazy = new LazyResult$4(new Processor$3(), this, opts);
16606 return lazy.stringify();
16607 };
16608 return Document23;
16609 }(Container$6);
16610 Document$3.registerLazyResult = function(dependant) {
16611 LazyResult$4 = dependant;
16612 };
16613 Document$3.registerProcessor = function(dependant) {
16614 Processor$3 = dependant;
16615 };
16616 var document$1$2 = Document$3;
16617 Document$3.default = Document$3;
16618 var printed = {};
16619 var warnOnce$2 = function warnOnce2(message) {
16620 if (printed[message]) return;
16621 printed[message] = true;
16622 if (typeof console !== "undefined" && console.warn) {
16623 console.warn(message);
16624 }
16625 };
16626 var Warning$2 = /*#__PURE__*/ function() {
16627 function Warning2(text, opts) {
16628 if (opts === void 0) opts = {};
16629 this.type = "warning";
16630 this.text = text;
16631 if (opts.node && opts.node.source) {
16632 var range = opts.node.rangeBy(opts);
16633 this.line = range.start.line;
16634 this.column = range.start.column;
16635 this.endLine = range.end.line;
16636 this.endColumn = range.end.column;
16637 }
16638 for(var opt in opts)this[opt] = opts[opt];
16639 }
16640 var _proto = Warning2.prototype;
16641 _proto.toString = function toString() {
16642 if (this.node) {
16643 return this.node.error(this.text, {
16644 index: this.index,
16645 plugin: this.plugin,
16646 word: this.word
16647 }).message;
16648 }
16649 if (this.plugin) {
16650 return this.plugin + ": " + this.text;
16651 }
16652 return this.text;
16653 };
16654 return Warning2;
16655 }();
16656 var warning = Warning$2;
16657 Warning$2.default = Warning$2;
16658 var Warning$1 = warning;
16659 var Result$3 = /*#__PURE__*/ function() {
16660 function Result2(processor2, root2, opts) {
16661 this.processor = processor2;
16662 this.messages = [];
16663 this.root = root2;
16664 this.opts = opts;
16665 this.css = void 0;
16666 this.map = void 0;
16667 }
16668 var _proto = Result2.prototype;
16669 _proto.toString = function toString() {
16670 return this.css;
16671 };
16672 _proto.warn = function warn(text, opts) {
16673 if (opts === void 0) opts = {};
16674 if (!opts.plugin) {
16675 if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
16676 opts.plugin = this.lastPlugin.postcssPlugin;
16677 }
16678 }
16679 var warning2 = new Warning$1(text, opts);
16680 this.messages.push(warning2);
16681 return warning2;
16682 };
16683 _proto.warnings = function warnings() {
16684 return this.messages.filter(function(i2) {
16685 return i2.type === "warning";
16686 });
16687 };
16688 _create_class(Result2, [
16689 {
16690 key: "content",
16691 get: function get() {
16692 return this.css;
16693 }
16694 }
16695 ]);
16696 return Result2;
16697 }();
16698 var result = Result$3;
16699 Result$3.default = Result$3;
16700 var SINGLE_QUOTE = "'".charCodeAt(0);
16701 var DOUBLE_QUOTE = '"'.charCodeAt(0);
16702 var BACKSLASH = "\\".charCodeAt(0);
16703 var SLASH = "/".charCodeAt(0);
16704 var NEWLINE = "\n".charCodeAt(0);
16705 var SPACE = " ".charCodeAt(0);
16706 var FEED = "\f".charCodeAt(0);
16707 var TAB = " ".charCodeAt(0);
16708 var CR = "\r".charCodeAt(0);
16709 var OPEN_SQUARE = "[".charCodeAt(0);
16710 var CLOSE_SQUARE = "]".charCodeAt(0);
16711 var OPEN_PARENTHESES = "(".charCodeAt(0);
16712 var CLOSE_PARENTHESES = ")".charCodeAt(0);
16713 var OPEN_CURLY = "{".charCodeAt(0);
16714 var CLOSE_CURLY = "}".charCodeAt(0);
16715 var SEMICOLON = ";".charCodeAt(0);
16716 var ASTERISK = "*".charCodeAt(0);
16717 var COLON = ":".charCodeAt(0);
16718 var AT = "@".charCodeAt(0);
16719 var RE_AT_END = /[\t\n\f\r "#'()/;[\\\]{}]/g;
16720 var RE_WORD_END = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
16721 var RE_BAD_BRACKET = /.[\r\n"'(/\\]/;
16722 var RE_HEX_ESCAPE = /[\da-f]/i;
16723 var tokenize = function tokenizer2(input2, options) {
16724 if (options === void 0) options = {};
16725 var css = input2.css.valueOf();
16726 var ignore = options.ignoreErrors;
16727 var code, next, quote, content, escape;
16728 var escaped, escapePos, prev, n2, currentToken;
16729 var length = css.length;
16730 var pos = 0;
16731 var buffer = [];
16732 var returned = [];
16733 function position() {
16734 return pos;
16735 }
16736 function unclosed(what) {
16737 throw input2.error("Unclosed " + what, pos);
16738 }
16739 function endOfFile() {
16740 return returned.length === 0 && pos >= length;
16741 }
16742 function nextToken(opts) {
16743 if (returned.length) return returned.pop();
16744 if (pos >= length) return;
16745 var ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
16746 code = css.charCodeAt(pos);
16747 switch(code){
16748 case NEWLINE:
16749 case SPACE:
16750 case TAB:
16751 case CR:
16752 case FEED:
16753 {
16754 next = pos;
16755 do {
16756 next += 1;
16757 code = css.charCodeAt(next);
16758 }while (code === SPACE || code === NEWLINE || code === TAB || code === CR || code === FEED);
16759 currentToken = [
16760 "space",
16761 css.slice(pos, next)
16762 ];
16763 pos = next - 1;
16764 break;
16765 }
16766 case OPEN_SQUARE:
16767 case CLOSE_SQUARE:
16768 case OPEN_CURLY:
16769 case CLOSE_CURLY:
16770 case COLON:
16771 case SEMICOLON:
16772 case CLOSE_PARENTHESES:
16773 {
16774 var controlChar = String.fromCharCode(code);
16775 currentToken = [
16776 controlChar,
16777 controlChar,
16778 pos
16779 ];
16780 break;
16781 }
16782 case OPEN_PARENTHESES:
16783 {
16784 prev = buffer.length ? buffer.pop()[1] : "";
16785 n2 = css.charCodeAt(pos + 1);
16786 if (prev === "url" && n2 !== SINGLE_QUOTE && n2 !== DOUBLE_QUOTE && n2 !== SPACE && n2 !== NEWLINE && n2 !== TAB && n2 !== FEED && n2 !== CR) {
16787 next = pos;
16788 do {
16789 escaped = false;
16790 next = css.indexOf(")", next + 1);
16791 if (next === -1) {
16792 if (ignore || ignoreUnclosed) {
16793 next = pos;
16794 break;
16795 } else {
16796 unclosed("bracket");
16797 }
16798 }
16799 escapePos = next;
16800 while(css.charCodeAt(escapePos - 1) === BACKSLASH){
16801 escapePos -= 1;
16802 escaped = !escaped;
16803 }
16804 }while (escaped);
16805 currentToken = [
16806 "brackets",
16807 css.slice(pos, next + 1),
16808 pos,
16809 next
16810 ];
16811 pos = next;
16812 } else {
16813 next = css.indexOf(")", pos + 1);
16814 content = css.slice(pos, next + 1);
16815 if (next === -1 || RE_BAD_BRACKET.test(content)) {
16816 currentToken = [
16817 "(",
16818 "(",
16819 pos
16820 ];
16821 } else {
16822 currentToken = [
16823 "brackets",
16824 content,
16825 pos,
16826 next
16827 ];
16828 pos = next;
16829 }
16830 }
16831 break;
16832 }
16833 case SINGLE_QUOTE:
16834 case DOUBLE_QUOTE:
16835 {
16836 quote = code === SINGLE_QUOTE ? "'" : '"';
16837 next = pos;
16838 do {
16839 escaped = false;
16840 next = css.indexOf(quote, next + 1);
16841 if (next === -1) {
16842 if (ignore || ignoreUnclosed) {
16843 next = pos + 1;
16844 break;
16845 } else {
16846 unclosed("string");
16847 }
16848 }
16849 escapePos = next;
16850 while(css.charCodeAt(escapePos - 1) === BACKSLASH){
16851 escapePos -= 1;
16852 escaped = !escaped;
16853 }
16854 }while (escaped);
16855 currentToken = [
16856 "string",
16857 css.slice(pos, next + 1),
16858 pos,
16859 next
16860 ];
16861 pos = next;
16862 break;
16863 }
16864 case AT:
16865 {
16866 RE_AT_END.lastIndex = pos + 1;
16867 RE_AT_END.test(css);
16868 if (RE_AT_END.lastIndex === 0) {
16869 next = css.length - 1;
16870 } else {
16871 next = RE_AT_END.lastIndex - 2;
16872 }
16873 currentToken = [
16874 "at-word",
16875 css.slice(pos, next + 1),
16876 pos,
16877 next
16878 ];
16879 pos = next;
16880 break;
16881 }
16882 case BACKSLASH:
16883 {
16884 next = pos;
16885 escape = true;
16886 while(css.charCodeAt(next + 1) === BACKSLASH){
16887 next += 1;
16888 escape = !escape;
16889 }
16890 code = css.charCodeAt(next + 1);
16891 if (escape && code !== SLASH && code !== SPACE && code !== NEWLINE && code !== TAB && code !== CR && code !== FEED) {
16892 next += 1;
16893 if (RE_HEX_ESCAPE.test(css.charAt(next))) {
16894 while(RE_HEX_ESCAPE.test(css.charAt(next + 1))){
16895 next += 1;
16896 }
16897 if (css.charCodeAt(next + 1) === SPACE) {
16898 next += 1;
16899 }
16900 }
16901 }
16902 currentToken = [
16903 "word",
16904 css.slice(pos, next + 1),
16905 pos,
16906 next
16907 ];
16908 pos = next;
16909 break;
16910 }
16911 default:
16912 {
16913 if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
16914 next = css.indexOf("*/", pos + 2) + 1;
16915 if (next === 0) {
16916 if (ignore || ignoreUnclosed) {
16917 next = css.length;
16918 } else {
16919 unclosed("comment");
16920 }
16921 }
16922 currentToken = [
16923 "comment",
16924 css.slice(pos, next + 1),
16925 pos,
16926 next
16927 ];
16928 pos = next;
16929 } else {
16930 RE_WORD_END.lastIndex = pos + 1;
16931 RE_WORD_END.test(css);
16932 if (RE_WORD_END.lastIndex === 0) {
16933 next = css.length - 1;
16934 } else {
16935 next = RE_WORD_END.lastIndex - 2;
16936 }
16937 currentToken = [
16938 "word",
16939 css.slice(pos, next + 1),
16940 pos,
16941 next
16942 ];
16943 buffer.push(currentToken);
16944 pos = next;
16945 }
16946 break;
16947 }
16948 }
16949 pos++;
16950 return currentToken;
16951 }
16952 function back(token) {
16953 returned.push(token);
16954 }
16955 return {
16956 back: back,
16957 endOfFile: endOfFile,
16958 nextToken: nextToken,
16959 position: position
16960 };
16961 };
16962 var Container$5 = container;
16963 var AtRule$3 = /*#__PURE__*/ function(Container$5) {
16964 _inherits(AtRule2, Container$5);
16965 function AtRule2(defaults) {
16966 var _this;
16967 _this = Container$5.call(this, defaults) || this;
16968 _this.type = "atrule";
16969 return _this;
16970 }
16971 var _proto = AtRule2.prototype;
16972 _proto.append = function append() {
16973 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16974 children[_key] = arguments[_key];
16975 }
16976 var _Container$5_prototype_append;
16977 if (!this.proxyOf.nodes) this.nodes = [];
16978 return (_Container$5_prototype_append = Container$5.prototype.append).call.apply(_Container$5_prototype_append, [].concat([
16979 this
16980 ], children));
16981 };
16982 _proto.prepend = function prepend() {
16983 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16984 children[_key] = arguments[_key];
16985 }
16986 var _Container$5_prototype_prepend;
16987 if (!this.proxyOf.nodes) this.nodes = [];
16988 return (_Container$5_prototype_prepend = Container$5.prototype.prepend).call.apply(_Container$5_prototype_prepend, [].concat([
16989 this
16990 ], children));
16991 };
16992 return AtRule2;
16993 }(Container$5);
16994 var atRule = AtRule$3;
16995 AtRule$3.default = AtRule$3;
16996 Container$5.registerAtRule(AtRule$3);
16997 var Container$4 = container;
16998 var LazyResult$3, Processor$2;
16999 var Root$5 = /*#__PURE__*/ function(Container$4) {
17000 _inherits(Root2, Container$4);
17001 function Root2(defaults) {
17002 var _this;
17003 _this = Container$4.call(this, defaults) || this;
17004 _this.type = "root";
17005 if (!_this.nodes) _this.nodes = [];
17006 return _this;
17007 }
17008 var _proto = Root2.prototype;
17009 _proto.normalize = function normalize(child, sample, type) {
17010 var nodes = Container$4.prototype.normalize.call(this, child);
17011 if (sample) {
17012 if (type === "prepend") {
17013 if (this.nodes.length > 1) {
17014 sample.raws.before = this.nodes[1].raws.before;
17015 } else {
17016 delete sample.raws.before;
17017 }
17018 } else if (this.first !== sample) {
17019 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
17020 var node2 = _step.value;
17021 node2.raws.before = sample.raws.before;
17022 }
17023 }
17024 }
17025 return nodes;
17026 };
17027 _proto.removeChild = function removeChild(child, ignore) {
17028 var index2 = this.index(child);
17029 if (!ignore && index2 === 0 && this.nodes.length > 1) {
17030 this.nodes[1].raws.before = this.nodes[index2].raws.before;
17031 }
17032 return Container$4.prototype.removeChild.call(this, child);
17033 };
17034 _proto.toResult = function toResult(opts) {
17035 if (opts === void 0) opts = {};
17036 var lazy = new LazyResult$3(new Processor$2(), this, opts);
17037 return lazy.stringify();
17038 };
17039 return Root2;
17040 }(Container$4);
17041 Root$5.registerLazyResult = function(dependant) {
17042 LazyResult$3 = dependant;
17043 };
17044 Root$5.registerProcessor = function(dependant) {
17045 Processor$2 = dependant;
17046 };
17047 var root = Root$5;
17048 Root$5.default = Root$5;
17049 Container$4.registerRoot(Root$5);
17050 var list$2 = {
17051 comma: function comma(string) {
17052 return list$2.split(string, [
17053 ","
17054 ], true);
17055 },
17056 space: function space(string) {
17057 var spaces = [
17058 " ",
17059 "\n",
17060 " "
17061 ];
17062 return list$2.split(string, spaces);
17063 },
17064 split: function split(string, separators, last) {
17065 var array = [];
17066 var current = "";
17067 var split = false;
17068 var func = 0;
17069 var inQuote = false;
17070 var prevQuote = "";
17071 var escape = false;
17072 for(var _iterator = _create_for_of_iterator_helper_loose(string), _step; !(_step = _iterator()).done;){
17073 var letter = _step.value;
17074 if (escape) {
17075 escape = false;
17076 } else if (letter === "\\") {
17077 escape = true;
17078 } else if (inQuote) {
17079 if (letter === prevQuote) {
17080 inQuote = false;
17081 }
17082 } else if (letter === '"' || letter === "'") {
17083 inQuote = true;
17084 prevQuote = letter;
17085 } else if (letter === "(") {
17086 func += 1;
17087 } else if (letter === ")") {
17088 if (func > 0) func -= 1;
17089 } else if (func === 0) {
17090 if (separators.includes(letter)) split = true;
17091 }
17092 if (split) {
17093 if (current !== "") array.push(current.trim());
17094 current = "";
17095 split = false;
17096 } else {
17097 current += letter;
17098 }
17099 }
17100 if (last || current !== "") array.push(current.trim());
17101 return array;
17102 }
17103 };
17104 var list_1 = list$2;
17105 list$2.default = list$2;
17106 var Container$3 = container;
17107 var list$1 = list_1;
17108 var Rule$3 = /*#__PURE__*/ function(Container$3) {
17109 _inherits(Rule2, Container$3);
17110 function Rule2(defaults) {
17111 var _this;
17112 _this = Container$3.call(this, defaults) || this;
17113 _this.type = "rule";
17114 if (!_this.nodes) _this.nodes = [];
17115 return _this;
17116 }
17117 _create_class(Rule2, [
17118 {
17119 key: "selectors",
17120 get: function get() {
17121 return list$1.comma(this.selector);
17122 },
17123 set: function set(values) {
17124 var match = this.selector ? this.selector.match(/,\s*/) : null;
17125 var sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen");
17126 this.selector = values.join(sep2);
17127 }
17128 }
17129 ]);
17130 return Rule2;
17131 }(Container$3);
17132 var rule = Rule$3;
17133 Rule$3.default = Rule$3;
17134 Container$3.registerRule(Rule$3);
17135 var Declaration$2 = declaration;
17136 var tokenizer22 = tokenize;
17137 var Comment$2 = comment;
17138 var AtRule$2 = atRule;
17139 var Root$4 = root;
17140 var Rule$2 = rule;
17141 var SAFE_COMMENT_NEIGHBOR = {
17142 empty: true,
17143 space: true
17144 };
17145 function findLastWithPosition(tokens) {
17146 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
17147 var token = tokens[i2];
17148 var pos = token[3] || token[2];
17149 if (pos) return pos;
17150 }
17151 }
17152 var Parser$1 = /*#__PURE__*/ function() {
17153 function Parser2(input2) {
17154 this.input = input2;
17155 this.root = new Root$4();
17156 this.current = this.root;
17157 this.spaces = "";
17158 this.semicolon = false;
17159 this.createTokenizer();
17160 this.root.source = {
17161 input: input2,
17162 start: {
17163 column: 1,
17164 line: 1,
17165 offset: 0
17166 }
17167 };
17168 }
17169 var _proto = Parser2.prototype;
17170 _proto.atrule = function atrule(token) {
17171 var node2 = new AtRule$2();
17172 node2.name = token[1].slice(1);
17173 if (node2.name === "") {
17174 this.unnamedAtrule(node2, token);
17175 }
17176 this.init(node2, token[2]);
17177 var type;
17178 var prev;
17179 var shift;
17180 var last = false;
17181 var open = false;
17182 var params = [];
17183 var brackets = [];
17184 while(!this.tokenizer.endOfFile()){
17185 token = this.tokenizer.nextToken();
17186 type = token[0];
17187 if (type === "(" || type === "[") {
17188 brackets.push(type === "(" ? ")" : "]");
17189 } else if (type === "{" && brackets.length > 0) {
17190 brackets.push("}");
17191 } else if (type === brackets[brackets.length - 1]) {
17192 brackets.pop();
17193 }
17194 if (brackets.length === 0) {
17195 if (type === ";") {
17196 node2.source.end = this.getPosition(token[2]);
17197 node2.source.end.offset++;
17198 this.semicolon = true;
17199 break;
17200 } else if (type === "{") {
17201 open = true;
17202 break;
17203 } else if (type === "}") {
17204 if (params.length > 0) {
17205 shift = params.length - 1;
17206 prev = params[shift];
17207 while(prev && prev[0] === "space"){
17208 prev = params[--shift];
17209 }
17210 if (prev) {
17211 node2.source.end = this.getPosition(prev[3] || prev[2]);
17212 node2.source.end.offset++;
17213 }
17214 }
17215 this.end(token);
17216 break;
17217 } else {
17218 params.push(token);
17219 }
17220 } else {
17221 params.push(token);
17222 }
17223 if (this.tokenizer.endOfFile()) {
17224 last = true;
17225 break;
17226 }
17227 }
17228 node2.raws.between = this.spacesAndCommentsFromEnd(params);
17229 if (params.length) {
17230 node2.raws.afterName = this.spacesAndCommentsFromStart(params);
17231 this.raw(node2, "params", params);
17232 if (last) {
17233 token = params[params.length - 1];
17234 node2.source.end = this.getPosition(token[3] || token[2]);
17235 node2.source.end.offset++;
17236 this.spaces = node2.raws.between;
17237 node2.raws.between = "";
17238 }
17239 } else {
17240 node2.raws.afterName = "";
17241 node2.params = "";
17242 }
17243 if (open) {
17244 node2.nodes = [];
17245 this.current = node2;
17246 }
17247 };
17248 _proto.checkMissedSemicolon = function checkMissedSemicolon(tokens) {
17249 var colon = this.colon(tokens);
17250 if (colon === false) return;
17251 var founded = 0;
17252 var token;
17253 for(var j = colon - 1; j >= 0; j--){
17254 token = tokens[j];
17255 if (token[0] !== "space") {
17256 founded += 1;
17257 if (founded === 2) break;
17258 }
17259 }
17260 throw this.input.error("Missed semicolon", token[0] === "word" ? token[3] + 1 : token[2]);
17261 };
17262 _proto.colon = function colon(tokens) {
17263 var brackets = 0;
17264 var token, type, prev;
17265 for(var _iterator = _create_for_of_iterator_helper_loose(tokens.entries()), _step; !(_step = _iterator()).done;){
17266 var _step_value = _step.value, i2 = _step_value[0], element = _step_value[1];
17267 token = element;
17268 type = token[0];
17269 if (type === "(") {
17270 brackets += 1;
17271 }
17272 if (type === ")") {
17273 brackets -= 1;
17274 }
17275 if (brackets === 0 && type === ":") {
17276 if (!prev) {
17277 this.doubleColon(token);
17278 } else if (prev[0] === "word" && prev[1] === "progid") {
17279 continue;
17280 } else {
17281 return i2;
17282 }
17283 }
17284 prev = token;
17285 }
17286 return false;
17287 };
17288 _proto.comment = function comment(token) {
17289 var node2 = new Comment$2();
17290 this.init(node2, token[2]);
17291 node2.source.end = this.getPosition(token[3] || token[2]);
17292 node2.source.end.offset++;
17293 var text = token[1].slice(2, -2);
17294 if (/^\s*$/.test(text)) {
17295 node2.text = "";
17296 node2.raws.left = text;
17297 node2.raws.right = "";
17298 } else {
17299 var match = text.match(/^(\s*)([^]*\S)(\s*)$/);
17300 node2.text = match[2];
17301 node2.raws.left = match[1];
17302 node2.raws.right = match[3];
17303 }
17304 };
17305 _proto.createTokenizer = function createTokenizer() {
17306 this.tokenizer = tokenizer22(this.input);
17307 };
17308 _proto.decl = function decl(tokens, customProperty) {
17309 var node2 = new Declaration$2();
17310 this.init(node2, tokens[0][2]);
17311 var last = tokens[tokens.length - 1];
17312 if (last[0] === ";") {
17313 this.semicolon = true;
17314 tokens.pop();
17315 }
17316 node2.source.end = this.getPosition(last[3] || last[2] || findLastWithPosition(tokens));
17317 node2.source.end.offset++;
17318 while(tokens[0][0] !== "word"){
17319 if (tokens.length === 1) this.unknownWord(tokens);
17320 node2.raws.before += tokens.shift()[1];
17321 }
17322 node2.source.start = this.getPosition(tokens[0][2]);
17323 node2.prop = "";
17324 while(tokens.length){
17325 var type = tokens[0][0];
17326 if (type === ":" || type === "space" || type === "comment") {
17327 break;
17328 }
17329 node2.prop += tokens.shift()[1];
17330 }
17331 node2.raws.between = "";
17332 var token;
17333 while(tokens.length){
17334 token = tokens.shift();
17335 if (token[0] === ":") {
17336 node2.raws.between += token[1];
17337 break;
17338 } else {
17339 if (token[0] === "word" && /\w/.test(token[1])) {
17340 this.unknownWord([
17341 token
17342 ]);
17343 }
17344 node2.raws.between += token[1];
17345 }
17346 }
17347 if (node2.prop[0] === "_" || node2.prop[0] === "*") {
17348 node2.raws.before += node2.prop[0];
17349 node2.prop = node2.prop.slice(1);
17350 }
17351 var firstSpaces = [];
17352 var next;
17353 while(tokens.length){
17354 next = tokens[0][0];
17355 if (next !== "space" && next !== "comment") break;
17356 firstSpaces.push(tokens.shift());
17357 }
17358 this.precheckMissedSemicolon(tokens);
17359 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
17360 token = tokens[i2];
17361 if (token[1].toLowerCase() === "!important") {
17362 node2.important = true;
17363 var string = this.stringFrom(tokens, i2);
17364 string = this.spacesFromEnd(tokens) + string;
17365 if (string !== " !important") node2.raws.important = string;
17366 break;
17367 } else if (token[1].toLowerCase() === "important") {
17368 var cache = tokens.slice(0);
17369 var str = "";
17370 for(var j = i2; j > 0; j--){
17371 var type1 = cache[j][0];
17372 if (str.trim().indexOf("!") === 0 && type1 !== "space") {
17373 break;
17374 }
17375 str = cache.pop()[1] + str;
17376 }
17377 if (str.trim().indexOf("!") === 0) {
17378 node2.important = true;
17379 node2.raws.important = str;
17380 tokens = cache;
17381 }
17382 }
17383 if (token[0] !== "space" && token[0] !== "comment") {
17384 break;
17385 }
17386 }
17387 var hasWord = tokens.some(function(i2) {
17388 return i2[0] !== "space" && i2[0] !== "comment";
17389 });
17390 if (hasWord) {
17391 node2.raws.between += firstSpaces.map(function(i2) {
17392 return i2[1];
17393 }).join("");
17394 firstSpaces = [];
17395 }
17396 this.raw(node2, "value", firstSpaces.concat(tokens), customProperty);
17397 if (node2.value.includes(":") && !customProperty) {
17398 this.checkMissedSemicolon(tokens);
17399 }
17400 };
17401 _proto.doubleColon = function doubleColon(token) {
17402 throw this.input.error("Double colon", {
17403 offset: token[2]
17404 }, {
17405 offset: token[2] + token[1].length
17406 });
17407 };
17408 _proto.emptyRule = function emptyRule(token) {
17409 var node2 = new Rule$2();
17410 this.init(node2, token[2]);
17411 node2.selector = "";
17412 node2.raws.between = "";
17413 this.current = node2;
17414 };
17415 _proto.end = function end(token) {
17416 if (this.current.nodes && this.current.nodes.length) {
17417 this.current.raws.semicolon = this.semicolon;
17418 }
17419 this.semicolon = false;
17420 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
17421 this.spaces = "";
17422 if (this.current.parent) {
17423 this.current.source.end = this.getPosition(token[2]);
17424 this.current.source.end.offset++;
17425 this.current = this.current.parent;
17426 } else {
17427 this.unexpectedClose(token);
17428 }
17429 };
17430 _proto.endFile = function endFile() {
17431 if (this.current.parent) this.unclosedBlock();
17432 if (this.current.nodes && this.current.nodes.length) {
17433 this.current.raws.semicolon = this.semicolon;
17434 }
17435 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
17436 this.root.source.end = this.getPosition(this.tokenizer.position());
17437 };
17438 _proto.freeSemicolon = function freeSemicolon(token) {
17439 this.spaces += token[1];
17440 if (this.current.nodes) {
17441 var prev = this.current.nodes[this.current.nodes.length - 1];
17442 if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
17443 prev.raws.ownSemicolon = this.spaces;
17444 this.spaces = "";
17445 }
17446 }
17447 };
17448 // Helpers
17449 _proto.getPosition = function getPosition(offset) {
17450 var pos = this.input.fromOffset(offset);
17451 return {
17452 column: pos.col,
17453 line: pos.line,
17454 offset: offset
17455 };
17456 };
17457 _proto.init = function init(node2, offset) {
17458 this.current.push(node2);
17459 node2.source = {
17460 input: this.input,
17461 start: this.getPosition(offset)
17462 };
17463 node2.raws.before = this.spaces;
17464 this.spaces = "";
17465 if (node2.type !== "comment") this.semicolon = false;
17466 };
17467 _proto.other = function other(start) {
17468 var end = false;
17469 var type = null;
17470 var colon = false;
17471 var bracket = null;
17472 var brackets = [];
17473 var customProperty = start[1].startsWith("--");
17474 var tokens = [];
17475 var token = start;
17476 while(token){
17477 type = token[0];
17478 tokens.push(token);
17479 if (type === "(" || type === "[") {
17480 if (!bracket) bracket = token;
17481 brackets.push(type === "(" ? ")" : "]");
17482 } else if (customProperty && colon && type === "{") {
17483 if (!bracket) bracket = token;
17484 brackets.push("}");
17485 } else if (brackets.length === 0) {
17486 if (type === ";") {
17487 if (colon) {
17488 this.decl(tokens, customProperty);
17489 return;
17490 } else {
17491 break;
17492 }
17493 } else if (type === "{") {
17494 this.rule(tokens);
17495 return;
17496 } else if (type === "}") {
17497 this.tokenizer.back(tokens.pop());
17498 end = true;
17499 break;
17500 } else if (type === ":") {
17501 colon = true;
17502 }
17503 } else if (type === brackets[brackets.length - 1]) {
17504 brackets.pop();
17505 if (brackets.length === 0) bracket = null;
17506 }
17507 token = this.tokenizer.nextToken();
17508 }
17509 if (this.tokenizer.endOfFile()) end = true;
17510 if (brackets.length > 0) this.unclosedBracket(bracket);
17511 if (end && colon) {
17512 if (!customProperty) {
17513 while(tokens.length){
17514 token = tokens[tokens.length - 1][0];
17515 if (token !== "space" && token !== "comment") break;
17516 this.tokenizer.back(tokens.pop());
17517 }
17518 }
17519 this.decl(tokens, customProperty);
17520 } else {
17521 this.unknownWord(tokens);
17522 }
17523 };
17524 _proto.parse = function parse() {
17525 var token;
17526 while(!this.tokenizer.endOfFile()){
17527 token = this.tokenizer.nextToken();
17528 switch(token[0]){
17529 case "space":
17530 this.spaces += token[1];
17531 break;
17532 case ";":
17533 this.freeSemicolon(token);
17534 break;
17535 case "}":
17536 this.end(token);
17537 break;
17538 case "comment":
17539 this.comment(token);
17540 break;
17541 case "at-word":
17542 this.atrule(token);
17543 break;
17544 case "{":
17545 this.emptyRule(token);
17546 break;
17547 default:
17548 this.other(token);
17549 break;
17550 }
17551 }
17552 this.endFile();
17553 };
17554 _proto.precheckMissedSemicolon = function precheckMissedSemicolon() {};
17555 _proto.raw = function raw(node2, prop, tokens, customProperty) {
17556 var token, type;
17557 var length = tokens.length;
17558 var value = "";
17559 var clean = true;
17560 var next, prev;
17561 for(var i2 = 0; i2 < length; i2 += 1){
17562 token = tokens[i2];
17563 type = token[0];
17564 if (type === "space" && i2 === length - 1 && !customProperty) {
17565 clean = false;
17566 } else if (type === "comment") {
17567 prev = tokens[i2 - 1] ? tokens[i2 - 1][0] : "empty";
17568 next = tokens[i2 + 1] ? tokens[i2 + 1][0] : "empty";
17569 if (!SAFE_COMMENT_NEIGHBOR[prev] && !SAFE_COMMENT_NEIGHBOR[next]) {
17570 if (value.slice(-1) === ",") {
17571 clean = false;
17572 } else {
17573 value += token[1];
17574 }
17575 } else {
17576 clean = false;
17577 }
17578 } else {
17579 value += token[1];
17580 }
17581 }
17582 if (!clean) {
17583 var raw = tokens.reduce(function(all, i2) {
17584 return all + i2[1];
17585 }, "");
17586 node2.raws[prop] = {
17587 raw: raw,
17588 value: value
17589 };
17590 }
17591 node2[prop] = value;
17592 };
17593 _proto.rule = function rule(tokens) {
17594 tokens.pop();
17595 var node2 = new Rule$2();
17596 this.init(node2, tokens[0][2]);
17597 node2.raws.between = this.spacesAndCommentsFromEnd(tokens);
17598 this.raw(node2, "selector", tokens);
17599 this.current = node2;
17600 };
17601 _proto.spacesAndCommentsFromEnd = function spacesAndCommentsFromEnd(tokens) {
17602 var lastTokenType;
17603 var spaces = "";
17604 while(tokens.length){
17605 lastTokenType = tokens[tokens.length - 1][0];
17606 if (lastTokenType !== "space" && lastTokenType !== "comment") break;
17607 spaces = tokens.pop()[1] + spaces;
17608 }
17609 return spaces;
17610 };
17611 // Errors
17612 _proto.spacesAndCommentsFromStart = function spacesAndCommentsFromStart(tokens) {
17613 var next;
17614 var spaces = "";
17615 while(tokens.length){
17616 next = tokens[0][0];
17617 if (next !== "space" && next !== "comment") break;
17618 spaces += tokens.shift()[1];
17619 }
17620 return spaces;
17621 };
17622 _proto.spacesFromEnd = function spacesFromEnd(tokens) {
17623 var lastTokenType;
17624 var spaces = "";
17625 while(tokens.length){
17626 lastTokenType = tokens[tokens.length - 1][0];
17627 if (lastTokenType !== "space") break;
17628 spaces = tokens.pop()[1] + spaces;
17629 }
17630 return spaces;
17631 };
17632 _proto.stringFrom = function stringFrom(tokens, from) {
17633 var result2 = "";
17634 for(var i2 = from; i2 < tokens.length; i2++){
17635 result2 += tokens[i2][1];
17636 }
17637 tokens.splice(from, tokens.length - from);
17638 return result2;
17639 };
17640 _proto.unclosedBlock = function unclosedBlock() {
17641 var pos = this.current.source.start;
17642 throw this.input.error("Unclosed block", pos.line, pos.column);
17643 };
17644 _proto.unclosedBracket = function unclosedBracket(bracket) {
17645 throw this.input.error("Unclosed bracket", {
17646 offset: bracket[2]
17647 }, {
17648 offset: bracket[2] + 1
17649 });
17650 };
17651 _proto.unexpectedClose = function unexpectedClose(token) {
17652 throw this.input.error("Unexpected }", {
17653 offset: token[2]
17654 }, {
17655 offset: token[2] + 1
17656 });
17657 };
17658 _proto.unknownWord = function unknownWord(tokens) {
17659 throw this.input.error("Unknown word", {
17660 offset: tokens[0][2]
17661 }, {
17662 offset: tokens[0][2] + tokens[0][1].length
17663 });
17664 };
17665 _proto.unnamedAtrule = function unnamedAtrule(node2, token) {
17666 throw this.input.error("At-rule without name", {
17667 offset: token[2]
17668 }, {
17669 offset: token[2] + token[1].length
17670 });
17671 };
17672 return Parser2;
17673 }();
17674 var parser = Parser$1;
17675 var Container$2 = container;
17676 var Parser22 = parser;
17677 var Input$2 = input;
17678 function parse$3(css, opts) {
17679 var input2 = new Input$2(css, opts);
17680 var parser2 = new Parser22(input2);
17681 try {
17682 parser2.parse();
17683 } catch (e2) {
17684 if (true) {
17685 if (e2.name === "CssSyntaxError" && opts && opts.from) {
17686 if (/\.scss$/i.test(opts.from)) {
17687 e2.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser";
17688 } else if (/\.sass/i.test(opts.from)) {
17689 e2.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser";
17690 } else if (/\.less$/i.test(opts.from)) {
17691 e2.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser";
17692 }
17693 }
17694 }
17695 throw e2;
17696 }
17697 return parser2.root;
17698 }
17699 var parse_1 = parse$3;
17700 parse$3.default = parse$3;
17701 Container$2.registerParse(parse$3);
17702 var isClean = symbols.isClean, my = symbols.my;
17703 var MapGenerator$1 = mapGenerator;
17704 var stringify$2 = stringify_1;
17705 var Container$1 = container;
17706 var Document$2 = document$1$2;
17707 var warnOnce$1 = warnOnce$2;
17708 var Result$2 = result;
17709 var parse$2 = parse_1;
17710 var Root$3 = root;
17711 var TYPE_TO_CLASS_NAME = {
17712 atrule: "AtRule",
17713 comment: "Comment",
17714 decl: "Declaration",
17715 document: "Document",
17716 root: "Root",
17717 rule: "Rule"
17718 };
17719 var PLUGIN_PROPS = {
17720 AtRule: true,
17721 AtRuleExit: true,
17722 Comment: true,
17723 CommentExit: true,
17724 Declaration: true,
17725 DeclarationExit: true,
17726 Document: true,
17727 DocumentExit: true,
17728 Once: true,
17729 OnceExit: true,
17730 postcssPlugin: true,
17731 prepare: true,
17732 Root: true,
17733 RootExit: true,
17734 Rule: true,
17735 RuleExit: true
17736 };
17737 var NOT_VISITORS = {
17738 Once: true,
17739 postcssPlugin: true,
17740 prepare: true
17741 };
17742 var CHILDREN = 0;
17743 function isPromise(obj) {
17744 return (typeof obj === "undefined" ? "undefined" : _type_of(obj)) === "object" && typeof obj.then === "function";
17745 }
17746 function getEvents(node2) {
17747 var key = false;
17748 var type = TYPE_TO_CLASS_NAME[node2.type];
17749 if (node2.type === "decl") {
17750 key = node2.prop.toLowerCase();
17751 } else if (node2.type === "atrule") {
17752 key = node2.name.toLowerCase();
17753 }
17754 if (key && node2.append) {
17755 return [
17756 type,
17757 type + "-" + key,
17758 CHILDREN,
17759 type + "Exit",
17760 type + "Exit-" + key
17761 ];
17762 } else if (key) {
17763 return [
17764 type,
17765 type + "-" + key,
17766 type + "Exit",
17767 type + "Exit-" + key
17768 ];
17769 } else if (node2.append) {
17770 return [
17771 type,
17772 CHILDREN,
17773 type + "Exit"
17774 ];
17775 } else {
17776 return [
17777 type,
17778 type + "Exit"
17779 ];
17780 }
17781 }
17782 function toStack(node2) {
17783 var events;
17784 if (node2.type === "document") {
17785 events = [
17786 "Document",
17787 CHILDREN,
17788 "DocumentExit"
17789 ];
17790 } else if (node2.type === "root") {
17791 events = [
17792 "Root",
17793 CHILDREN,
17794 "RootExit"
17795 ];
17796 } else {
17797 events = getEvents(node2);
17798 }
17799 return {
17800 eventIndex: 0,
17801 events: events,
17802 iterator: 0,
17803 node: node2,
17804 visitorIndex: 0,
17805 visitors: []
17806 };
17807 }
17808 function cleanMarks(node2) {
17809 node2[isClean] = false;
17810 if (node2.nodes) node2.nodes.forEach(function(i2) {
17811 return cleanMarks(i2);
17812 });
17813 return node2;
17814 }
17815 var postcss$2 = {};
17816 var LazyResult$2 = /*#__PURE__*/ function() {
17817 function LazyResult2(processor2, css, opts) {
17818 var _this = this;
17819 this.stringified = false;
17820 this.processed = false;
17821 var root2;
17822 if ((typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && css !== null && (css.type === "root" || css.type === "document")) {
17823 root2 = cleanMarks(css);
17824 } else if (_instanceof(css, LazyResult2) || _instanceof(css, Result$2)) {
17825 root2 = cleanMarks(css.root);
17826 if (css.map) {
17827 if (typeof opts.map === "undefined") opts.map = {};
17828 if (!opts.map.inline) opts.map.inline = false;
17829 opts.map.prev = css.map;
17830 }
17831 } else {
17832 var parser2 = parse$2;
17833 if (opts.syntax) parser2 = opts.syntax.parse;
17834 if (opts.parser) parser2 = opts.parser;
17835 if (parser2.parse) parser2 = parser2.parse;
17836 try {
17837 root2 = parser2(css, opts);
17838 } catch (error) {
17839 this.processed = true;
17840 this.error = error;
17841 }
17842 if (root2 && !root2[my]) {
17843 Container$1.rebuild(root2);
17844 }
17845 }
17846 this.result = new Result$2(processor2, root2, opts);
17847 this.helpers = _extends({}, postcss$2, {
17848 postcss: postcss$2,
17849 result: this.result
17850 });
17851 this.plugins = this.processor.plugins.map(function(plugin22) {
17852 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.prepare) {
17853 return _extends({}, plugin22, plugin22.prepare(_this.result));
17854 } else {
17855 return plugin22;
17856 }
17857 });
17858 }
17859 var _proto = LazyResult2.prototype;
17860 _proto.async = function async() {
17861 if (this.error) return Promise.reject(this.error);
17862 if (this.processed) return Promise.resolve(this.result);
17863 if (!this.processing) {
17864 this.processing = this.runAsync();
17865 }
17866 return this.processing;
17867 };
17868 _proto.catch = function _catch(onRejected) {
17869 return this.async().catch(onRejected);
17870 };
17871 _proto.finally = function _finally(onFinally) {
17872 return this.async().then(onFinally, onFinally);
17873 };
17874 _proto.getAsyncError = function getAsyncError() {
17875 throw new Error("Use process(css).then(cb) to work with async plugins");
17876 };
17877 _proto.handleError = function handleError(error, node2) {
17878 var plugin22 = this.result.lastPlugin;
17879 try {
17880 if (node2) node2.addToError(error);
17881 this.error = error;
17882 if (error.name === "CssSyntaxError" && !error.plugin) {
17883 error.plugin = plugin22.postcssPlugin;
17884 error.setMessage();
17885 } else if (plugin22.postcssVersion) {
17886 if (true) {
17887 var pluginName = plugin22.postcssPlugin;
17888 var pluginVer = plugin22.postcssVersion;
17889 var runtimeVer = this.result.processor.version;
17890 var a2 = pluginVer.split(".");
17891 var b = runtimeVer.split(".");
17892 if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) {
17893 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.");
17894 }
17895 }
17896 }
17897 } catch (err) {
17898 if (console && console.error) console.error(err);
17899 }
17900 return error;
17901 };
17902 _proto.prepareVisitors = function prepareVisitors() {
17903 var _this = this;
17904 this.listeners = {};
17905 var add = function(plugin22, type, cb) {
17906 if (!_this.listeners[type]) _this.listeners[type] = [];
17907 _this.listeners[type].push([
17908 plugin22,
17909 cb
17910 ]);
17911 };
17912 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
17913 var plugin22 = _step.value;
17914 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object") {
17915 for(var event in plugin22){
17916 if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) {
17917 throw new Error("Unknown event " + event + " in " + plugin22.postcssPlugin + ". Try to update PostCSS (" + this.processor.version + " now).");
17918 }
17919 if (!NOT_VISITORS[event]) {
17920 if (_type_of(plugin22[event]) === "object") {
17921 for(var filter in plugin22[event]){
17922 if (filter === "*") {
17923 add(plugin22, event, plugin22[event][filter]);
17924 } else {
17925 add(plugin22, event + "-" + filter.toLowerCase(), plugin22[event][filter]);
17926 }
17927 }
17928 } else if (typeof plugin22[event] === "function") {
17929 add(plugin22, event, plugin22[event]);
17930 }
17931 }
17932 }
17933 }
17934 }
17935 this.hasListener = Object.keys(this.listeners).length > 0;
17936 };
17937 _proto.runAsync = function runAsync() {
17938 var _this = this;
17939 return _async_to_generator(function() {
17940 var i2, plugin22, promise, error, root2, stack, promise1, e2, node2, _loop, _iterator, _step;
17941 return _ts_generator(this, function(_state) {
17942 switch(_state.label){
17943 case 0:
17944 _this.plugin = 0;
17945 i2 = 0;
17946 _state.label = 1;
17947 case 1:
17948 if (!(i2 < _this.plugins.length)) return [
17949 3,
17950 6
17951 ];
17952 plugin22 = _this.plugins[i2];
17953 promise = _this.runOnRoot(plugin22);
17954 if (!isPromise(promise)) return [
17955 3,
17956 5
17957 ];
17958 _state.label = 2;
17959 case 2:
17960 _state.trys.push([
17961 2,
17962 4,
17963 ,
17964 5
17965 ]);
17966 return [
17967 4,
17968 promise
17969 ];
17970 case 3:
17971 _state.sent();
17972 return [
17973 3,
17974 5
17975 ];
17976 case 4:
17977 error = _state.sent();
17978 throw _this.handleError(error);
17979 case 5:
17980 i2++;
17981 return [
17982 3,
17983 1
17984 ];
17985 case 6:
17986 _this.prepareVisitors();
17987 if (!_this.hasListener) return [
17988 3,
17989 18
17990 ];
17991 root2 = _this.result.root;
17992 _state.label = 7;
17993 case 7:
17994 if (!!root2[isClean]) return [
17995 3,
17996 14
17997 ];
17998 root2[isClean] = true;
17999 stack = [
18000 toStack(root2)
18001 ];
18002 _state.label = 8;
18003 case 8:
18004 if (!(stack.length > 0)) return [
18005 3,
18006 13
18007 ];
18008 promise1 = _this.visitTick(stack);
18009 if (!isPromise(promise1)) return [
18010 3,
18011 12
18012 ];
18013 _state.label = 9;
18014 case 9:
18015 _state.trys.push([
18016 9,
18017 11,
18018 ,
18019 12
18020 ]);
18021 return [
18022 4,
18023 promise1
18024 ];
18025 case 10:
18026 _state.sent();
18027 return [
18028 3,
18029 12
18030 ];
18031 case 11:
18032 e2 = _state.sent();
18033 node2 = stack[stack.length - 1].node;
18034 throw _this.handleError(e2, node2);
18035 case 12:
18036 return [
18037 3,
18038 8
18039 ];
18040 case 13:
18041 return [
18042 3,
18043 7
18044 ];
18045 case 14:
18046 if (!_this.listeners.OnceExit) return [
18047 3,
18048 18
18049 ];
18050 _loop = function() {
18051 var _step_value, plugin22, visitor, roots, e2;
18052 return _ts_generator(this, function(_state) {
18053 switch(_state.label){
18054 case 0:
18055 _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
18056 _this.result.lastPlugin = plugin22;
18057 _state.label = 1;
18058 case 1:
18059 _state.trys.push([
18060 1,
18061 6,
18062 ,
18063 7
18064 ]);
18065 if (!(root2.type === "document")) return [
18066 3,
18067 3
18068 ];
18069 roots = root2.nodes.map(function(subRoot) {
18070 return visitor(subRoot, _this.helpers);
18071 });
18072 return [
18073 4,
18074 Promise.all(roots)
18075 ];
18076 case 2:
18077 _state.sent();
18078 return [
18079 3,
18080 5
18081 ];
18082 case 3:
18083 return [
18084 4,
18085 visitor(root2, _this.helpers)
18086 ];
18087 case 4:
18088 _state.sent();
18089 _state.label = 5;
18090 case 5:
18091 return [
18092 3,
18093 7
18094 ];
18095 case 6:
18096 e2 = _state.sent();
18097 throw _this.handleError(e2);
18098 case 7:
18099 return [
18100 2
18101 ];
18102 }
18103 });
18104 };
18105 _iterator = _create_for_of_iterator_helper_loose(_this.listeners.OnceExit);
18106 _state.label = 15;
18107 case 15:
18108 if (!!(_step = _iterator()).done) return [
18109 3,
18110 18
18111 ];
18112 return [
18113 5,
18114 _ts_values(_loop())
18115 ];
18116 case 16:
18117 _state.sent();
18118 _state.label = 17;
18119 case 17:
18120 return [
18121 3,
18122 15
18123 ];
18124 case 18:
18125 _this.processed = true;
18126 return [
18127 2,
18128 _this.stringify()
18129 ];
18130 }
18131 });
18132 })();
18133 };
18134 _proto.runOnRoot = function runOnRoot(plugin22) {
18135 var _this = this;
18136 this.result.lastPlugin = plugin22;
18137 try {
18138 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.Once) {
18139 if (this.result.root.type === "document") {
18140 var roots = this.result.root.nodes.map(function(root2) {
18141 return plugin22.Once(root2, _this.helpers);
18142 });
18143 if (isPromise(roots[0])) {
18144 return Promise.all(roots);
18145 }
18146 return roots;
18147 }
18148 return plugin22.Once(this.result.root, this.helpers);
18149 } else if (typeof plugin22 === "function") {
18150 return plugin22(this.result.root, this.result);
18151 }
18152 } catch (error) {
18153 throw this.handleError(error);
18154 }
18155 };
18156 _proto.stringify = function stringify() {
18157 if (this.error) throw this.error;
18158 if (this.stringified) return this.result;
18159 this.stringified = true;
18160 this.sync();
18161 var opts = this.result.opts;
18162 var str = stringify$2;
18163 if (opts.syntax) str = opts.syntax.stringify;
18164 if (opts.stringifier) str = opts.stringifier;
18165 if (str.stringify) str = str.stringify;
18166 var map = new MapGenerator$1(str, this.result.root, this.result.opts);
18167 var data = map.generate();
18168 this.result.css = data[0];
18169 this.result.map = data[1];
18170 return this.result;
18171 };
18172 _proto.sync = function sync() {
18173 if (this.error) throw this.error;
18174 if (this.processed) return this.result;
18175 this.processed = true;
18176 if (this.processing) {
18177 throw this.getAsyncError();
18178 }
18179 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
18180 var plugin22 = _step.value;
18181 var promise = this.runOnRoot(plugin22);
18182 if (isPromise(promise)) {
18183 throw this.getAsyncError();
18184 }
18185 }
18186 this.prepareVisitors();
18187 if (this.hasListener) {
18188 var root2 = this.result.root;
18189 while(!root2[isClean]){
18190 root2[isClean] = true;
18191 this.walkSync(root2);
18192 }
18193 if (this.listeners.OnceExit) {
18194 if (root2.type === "document") {
18195 for(var _iterator1 = _create_for_of_iterator_helper_loose(root2.nodes), _step1; !(_step1 = _iterator1()).done;){
18196 var subRoot = _step1.value;
18197 this.visitSync(this.listeners.OnceExit, subRoot);
18198 }
18199 } else {
18200 this.visitSync(this.listeners.OnceExit, root2);
18201 }
18202 }
18203 }
18204 return this.result;
18205 };
18206 _proto.then = function then(onFulfilled, onRejected) {
18207 if (true) {
18208 if (!("from" in this.opts)) {
18209 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.");
18210 }
18211 }
18212 return this.async().then(onFulfilled, onRejected);
18213 };
18214 _proto.toString = function toString() {
18215 return this.css;
18216 };
18217 _proto.visitSync = function visitSync(visitors, node2) {
18218 for(var _iterator = _create_for_of_iterator_helper_loose(visitors), _step; !(_step = _iterator()).done;){
18219 var _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
18220 this.result.lastPlugin = plugin22;
18221 var promise = void 0;
18222 try {
18223 promise = visitor(node2, this.helpers);
18224 } catch (e2) {
18225 throw this.handleError(e2, node2.proxyOf);
18226 }
18227 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
18228 return true;
18229 }
18230 if (isPromise(promise)) {
18231 throw this.getAsyncError();
18232 }
18233 }
18234 };
18235 _proto.visitTick = function visitTick(stack) {
18236 var visit2 = stack[stack.length - 1];
18237 var node2 = visit2.node, visitors = visit2.visitors;
18238 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
18239 stack.pop();
18240 return;
18241 }
18242 if (visitors.length > 0 && visit2.visitorIndex < visitors.length) {
18243 var _visitors_visit2_visitorIndex = visitors[visit2.visitorIndex], plugin22 = _visitors_visit2_visitorIndex[0], visitor = _visitors_visit2_visitorIndex[1];
18244 visit2.visitorIndex += 1;
18245 if (visit2.visitorIndex === visitors.length) {
18246 visit2.visitors = [];
18247 visit2.visitorIndex = 0;
18248 }
18249 this.result.lastPlugin = plugin22;
18250 try {
18251 return visitor(node2.toProxy(), this.helpers);
18252 } catch (e2) {
18253 throw this.handleError(e2, node2);
18254 }
18255 }
18256 if (visit2.iterator !== 0) {
18257 var iterator = visit2.iterator;
18258 var child;
18259 while(child = node2.nodes[node2.indexes[iterator]]){
18260 node2.indexes[iterator] += 1;
18261 if (!child[isClean]) {
18262 child[isClean] = true;
18263 stack.push(toStack(child));
18264 return;
18265 }
18266 }
18267 visit2.iterator = 0;
18268 delete node2.indexes[iterator];
18269 }
18270 var events = visit2.events;
18271 while(visit2.eventIndex < events.length){
18272 var event = events[visit2.eventIndex];
18273 visit2.eventIndex += 1;
18274 if (event === CHILDREN) {
18275 if (node2.nodes && node2.nodes.length) {
18276 node2[isClean] = true;
18277 visit2.iterator = node2.getIterator();
18278 }
18279 return;
18280 } else if (this.listeners[event]) {
18281 visit2.visitors = this.listeners[event];
18282 return;
18283 }
18284 }
18285 stack.pop();
18286 };
18287 _proto.walkSync = function walkSync(node2) {
18288 var _this = this;
18289 node2[isClean] = true;
18290 var events = getEvents(node2);
18291 for(var _iterator = _create_for_of_iterator_helper_loose(events), _step; !(_step = _iterator()).done;){
18292 var event = _step.value;
18293 if (event === CHILDREN) {
18294 if (node2.nodes) {
18295 node2.each(function(child) {
18296 if (!child[isClean]) _this.walkSync(child);
18297 });
18298 }
18299 } else {
18300 var visitors = this.listeners[event];
18301 if (visitors) {
18302 if (this.visitSync(visitors, node2.toProxy())) return;
18303 }
18304 }
18305 }
18306 };
18307 _proto.warnings = function warnings() {
18308 return this.sync().warnings();
18309 };
18310 _create_class(LazyResult2, [
18311 {
18312 key: "content",
18313 get: function get() {
18314 return this.stringify().content;
18315 }
18316 },
18317 {
18318 key: "css",
18319 get: function get() {
18320 return this.stringify().css;
18321 }
18322 },
18323 {
18324 key: "map",
18325 get: function get() {
18326 return this.stringify().map;
18327 }
18328 },
18329 {
18330 key: "messages",
18331 get: function get() {
18332 return this.sync().messages;
18333 }
18334 },
18335 {
18336 key: "opts",
18337 get: function get() {
18338 return this.result.opts;
18339 }
18340 },
18341 {
18342 key: "processor",
18343 get: function get() {
18344 return this.result.processor;
18345 }
18346 },
18347 {
18348 key: "root",
18349 get: function get() {
18350 return this.sync().root;
18351 }
18352 },
18353 {
18354 key: Symbol.toStringTag,
18355 get: function get() {
18356 return "LazyResult";
18357 }
18358 }
18359 ]);
18360 return LazyResult2;
18361 }();
18362 LazyResult$2.registerPostcss = function(dependant) {
18363 postcss$2 = dependant;
18364 };
18365 var lazyResult = LazyResult$2;
18366 LazyResult$2.default = LazyResult$2;
18367 Root$3.registerLazyResult(LazyResult$2);
18368 Document$2.registerLazyResult(LazyResult$2);
18369 var MapGenerator22 = mapGenerator;
18370 var stringify$1 = stringify_1;
18371 var warnOnce22 = warnOnce$2;
18372 var parse$1 = parse_1;
18373 var Result$1 = result;
18374 var NoWorkResult$1 = /*#__PURE__*/ function() {
18375 function NoWorkResult2(processor2, css, opts) {
18376 css = css.toString();
18377 this.stringified = false;
18378 this._processor = processor2;
18379 this._css = css;
18380 this._opts = opts;
18381 this._map = void 0;
18382 var root2;
18383 var str = stringify$1;
18384 this.result = new Result$1(this._processor, root2, this._opts);
18385 this.result.css = css;
18386 var self = this;
18387 Object.defineProperty(this.result, "root", {
18388 get: function get() {
18389 return self.root;
18390 }
18391 });
18392 var map = new MapGenerator22(str, root2, this._opts, css);
18393 if (map.isMap()) {
18394 var _map_generate = map.generate(), generatedCSS = _map_generate[0], generatedMap = _map_generate[1];
18395 if (generatedCSS) {
18396 this.result.css = generatedCSS;
18397 }
18398 if (generatedMap) {
18399 this.result.map = generatedMap;
18400 }
18401 } else {
18402 map.clearAnnotation();
18403 this.result.css = map.css;
18404 }
18405 }
18406 var _proto = NoWorkResult2.prototype;
18407 _proto.async = function async() {
18408 if (this.error) return Promise.reject(this.error);
18409 return Promise.resolve(this.result);
18410 };
18411 _proto.catch = function _catch(onRejected) {
18412 return this.async().catch(onRejected);
18413 };
18414 _proto.finally = function _finally(onFinally) {
18415 return this.async().then(onFinally, onFinally);
18416 };
18417 _proto.sync = function sync() {
18418 if (this.error) throw this.error;
18419 return this.result;
18420 };
18421 _proto.then = function then(onFulfilled, onRejected) {
18422 if (true) {
18423 if (!("from" in this._opts)) {
18424 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.");
18425 }
18426 }
18427 return this.async().then(onFulfilled, onRejected);
18428 };
18429 _proto.toString = function toString() {
18430 return this._css;
18431 };
18432 _proto.warnings = function warnings() {
18433 return [];
18434 };
18435 _create_class(NoWorkResult2, [
18436 {
18437 key: "content",
18438 get: function get() {
18439 return this.result.css;
18440 }
18441 },
18442 {
18443 key: "css",
18444 get: function get() {
18445 return this.result.css;
18446 }
18447 },
18448 {
18449 key: "map",
18450 get: function get() {
18451 return this.result.map;
18452 }
18453 },
18454 {
18455 key: "messages",
18456 get: function get() {
18457 return [];
18458 }
18459 },
18460 {
18461 key: "opts",
18462 get: function get() {
18463 return this.result.opts;
18464 }
18465 },
18466 {
18467 key: "processor",
18468 get: function get() {
18469 return this.result.processor;
18470 }
18471 },
18472 {
18473 key: "root",
18474 get: function get() {
18475 if (this._root) {
18476 return this._root;
18477 }
18478 var root2;
18479 var parser2 = parse$1;
18480 try {
18481 root2 = parser2(this._css, this._opts);
18482 } catch (error) {
18483 this.error = error;
18484 }
18485 if (this.error) {
18486 throw this.error;
18487 } else {
18488 this._root = root2;
18489 return root2;
18490 }
18491 }
18492 },
18493 {
18494 key: Symbol.toStringTag,
18495 get: function get() {
18496 return "NoWorkResult";
18497 }
18498 }
18499 ]);
18500 return NoWorkResult2;
18501 }();
18502 var noWorkResult = NoWorkResult$1;
18503 NoWorkResult$1.default = NoWorkResult$1;
18504 var NoWorkResult22 = noWorkResult;
18505 var LazyResult$1 = lazyResult;
18506 var Document$1 = document$1$2;
18507 var Root$2 = root;
18508 var Processor$1 = /*#__PURE__*/ function() {
18509 function Processor2(plugins) {
18510 if (plugins === void 0) plugins = [];
18511 this.version = "8.4.38";
18512 this.plugins = this.normalize(plugins);
18513 }
18514 var _proto = Processor2.prototype;
18515 _proto.normalize = function normalize(plugins) {
18516 var normalized = [];
18517 for(var _iterator = _create_for_of_iterator_helper_loose(plugins), _step; !(_step = _iterator()).done;){
18518 var i2 = _step.value;
18519 if (i2.postcss === true) {
18520 i2 = i2();
18521 } else if (i2.postcss) {
18522 i2 = i2.postcss;
18523 }
18524 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && Array.isArray(i2.plugins)) {
18525 normalized = normalized.concat(i2.plugins);
18526 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.postcssPlugin) {
18527 normalized.push(i2);
18528 } else if (typeof i2 === "function") {
18529 normalized.push(i2);
18530 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && (i2.parse || i2.stringify)) {
18531 if (true) {
18532 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.");
18533 }
18534 } else {
18535 throw new Error(i2 + " is not a PostCSS plugin");
18536 }
18537 }
18538 return normalized;
18539 };
18540 _proto.process = function process1(css, opts) {
18541 if (opts === void 0) opts = {};
18542 if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) {
18543 return new NoWorkResult22(this, css, opts);
18544 } else {
18545 return new LazyResult$1(this, css, opts);
18546 }
18547 };
18548 _proto.use = function use(plugin22) {
18549 this.plugins = this.plugins.concat(this.normalize([
18550 plugin22
18551 ]));
18552 return this;
18553 };
18554 return Processor2;
18555 }();
18556 var processor = Processor$1;
18557 Processor$1.default = Processor$1;
18558 Root$2.registerProcessor(Processor$1);
18559 Document$1.registerProcessor(Processor$1);
18560 var Declaration$1 = declaration;
18561 var PreviousMap22 = previousMap;
18562 var Comment$1 = comment;
18563 var AtRule$1 = atRule;
18564 var Input$1 = input;
18565 var Root$1 = root;
18566 var Rule$1 = rule;
18567 function fromJSON$1(json, inputs) {
18568 if (Array.isArray(json)) return json.map(function(n2) {
18569 return fromJSON$1(n2);
18570 });
18571 var ownInputs = json.inputs, defaults = _object_without_properties_loose(json, [
18572 "inputs"
18573 ]);
18574 if (ownInputs) {
18575 inputs = [];
18576 for(var _iterator = _create_for_of_iterator_helper_loose(ownInputs), _step; !(_step = _iterator()).done;){
18577 var input2 = _step.value;
18578 var inputHydrated = _extends({}, input2, {
18579 __proto__: Input$1.prototype
18580 });
18581 if (inputHydrated.map) {
18582 inputHydrated.map = _extends({}, inputHydrated.map, {
18583 __proto__: PreviousMap22.prototype
18584 });
18585 }
18586 inputs.push(inputHydrated);
18587 }
18588 }
18589 if (defaults.nodes) {
18590 defaults.nodes = json.nodes.map(function(n2) {
18591 return fromJSON$1(n2, inputs);
18592 });
18593 }
18594 if (defaults.source) {
18595 var _defaults_source = defaults.source, inputId = _defaults_source.inputId, source = _object_without_properties_loose(_defaults_source, [
18596 "inputId"
18597 ]);
18598 defaults.source = source;
18599 if (inputId != null) {
18600 defaults.source.input = inputs[inputId];
18601 }
18602 }
18603 if (defaults.type === "root") {
18604 return new Root$1(defaults);
18605 } else if (defaults.type === "decl") {
18606 return new Declaration$1(defaults);
18607 } else if (defaults.type === "rule") {
18608 return new Rule$1(defaults);
18609 } else if (defaults.type === "comment") {
18610 return new Comment$1(defaults);
18611 } else if (defaults.type === "atrule") {
18612 return new AtRule$1(defaults);
18613 } else {
18614 throw new Error("Unknown node type: " + json.type);
18615 }
18616 }
18617 var fromJSON_1 = fromJSON$1;
18618 fromJSON$1.default = fromJSON$1;
18619 var CssSyntaxError22 = cssSyntaxError;
18620 var Declaration22 = declaration;
18621 var LazyResult22 = lazyResult;
18622 var Container22 = container;
18623 var Processor22 = processor;
18624 var stringify = stringify_1;
18625 var fromJSON = fromJSON_1;
18626 var Document222 = document$1$2;
18627 var Warning22 = warning;
18628 var Comment22 = comment;
18629 var AtRule22 = atRule;
18630 var Result22 = result;
18631 var Input22 = input;
18632 var parse = parse_1;
18633 var list = list_1;
18634 var Rule22 = rule;
18635 var Root22 = root;
18636 var Node22 = node;
18637 function postcss() {
18638 for(var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++){
18639 plugins[_key] = arguments[_key];
18640 }
18641 if (plugins.length === 1 && Array.isArray(plugins[0])) {
18642 plugins = plugins[0];
18643 }
18644 return new Processor22(plugins);
18645 }
18646 postcss.plugin = function plugin2(name, initializer) {
18647 var warningPrinted = false;
18648 function creator() {
18649 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
18650 args[_key] = arguments[_key];
18651 }
18652 if (console && console.warn && !warningPrinted) {
18653 warningPrinted = true;
18654 console.warn(name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration");
18655 if (process.env.LANG && process.env.LANG.startsWith("cn")) {
18656 console.warn(name + ": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226");
18657 }
18658 }
18659 var transformer = initializer.apply(void 0, [].concat(args));
18660 transformer.postcssPlugin = name;
18661 transformer.postcssVersion = new Processor22().version;
18662 return transformer;
18663 }
18664 var cache;
18665 Object.defineProperty(creator, "postcss", {
18666 get: function get() {
18667 if (!cache) cache = creator();
18668 return cache;
18669 }
18670 });
18671 creator.process = function(css, processOpts, pluginOpts) {
18672 return postcss([
18673 creator(pluginOpts)
18674 ]).process(css, processOpts);
18675 };
18676 return creator;
18677 };
18678 postcss.stringify = stringify;
18679 postcss.parse = parse;
18680 postcss.fromJSON = fromJSON;
18681 postcss.list = list;
18682 postcss.comment = function(defaults) {
18683 return new Comment22(defaults);
18684 };
18685 postcss.atRule = function(defaults) {
18686 return new AtRule22(defaults);
18687 };
18688 postcss.decl = function(defaults) {
18689 return new Declaration22(defaults);
18690 };
18691 postcss.rule = function(defaults) {
18692 return new Rule22(defaults);
18693 };
18694 postcss.root = function(defaults) {
18695 return new Root22(defaults);
18696 };
18697 postcss.document = function(defaults) {
18698 return new Document222(defaults);
18699 };
18700 postcss.CssSyntaxError = CssSyntaxError22;
18701 postcss.Declaration = Declaration22;
18702 postcss.Container = Container22;
18703 postcss.Processor = Processor22;
18704 postcss.Document = Document222;
18705 postcss.Comment = Comment22;
18706 postcss.Warning = Warning22;
18707 postcss.AtRule = AtRule22;
18708 postcss.Result = Result22;
18709 postcss.Input = Input22;
18710 postcss.Rule = Rule22;
18711 postcss.Root = Root22;
18712 postcss.Node = Node22;
18713 LazyResult22.registerPostcss(postcss);
18714 var postcss_1 = postcss;
18715 postcss.default = postcss;
18716 var postcss$1 = /* @__PURE__ */ getDefaultExportFromCjs(postcss_1);
18717 postcss$1.stringify;
18718 postcss$1.fromJSON;
18719 postcss$1.plugin;
18720 postcss$1.parse;
18721 postcss$1.list;
18722 postcss$1.document;
18723 postcss$1.comment;
18724 postcss$1.atRule;
18725 postcss$1.rule;
18726 postcss$1.decl;
18727 postcss$1.root;
18728 postcss$1.CssSyntaxError;
18729 postcss$1.Declaration;
18730 postcss$1.Container;
18731 postcss$1.Processor;
18732 postcss$1.Document;
18733 postcss$1.Comment;
18734 postcss$1.Warning;
18735 postcss$1.AtRule;
18736 postcss$1.Result;
18737 postcss$1.Input;
18738 postcss$1.Rule;
18739 postcss$1.Root;
18740 postcss$1.Node;
18741 var BaseRRNode = /*#__PURE__*/ function() {
18742 function BaseRRNode() {
18743 for(var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++){
18744 _args[_key] = arguments[_key];
18745 }
18746 __publicField2(this, "parentElement", null);
18747 __publicField2(this, "parentNode", null);
18748 __publicField2(this, "ownerDocument");
18749 __publicField2(this, "firstChild", null);
18750 __publicField2(this, "lastChild", null);
18751 __publicField2(this, "previousSibling", null);
18752 __publicField2(this, "nextSibling", null);
18753 __publicField2(this, "ELEMENT_NODE", 1);
18754 __publicField2(this, "TEXT_NODE", 3);
18755 __publicField2(this, "nodeType");
18756 __publicField2(this, "nodeName");
18757 __publicField2(this, "RRNodeType");
18758 }
18759 var _proto = BaseRRNode.prototype;
18760 _proto.contains = function contains(node2) {
18761 if (!_instanceof(node2, BaseRRNode)) return false;
18762 else if (node2.ownerDocument !== this.ownerDocument) return false;
18763 else if (node2 === this) return true;
18764 while(node2.parentNode){
18765 if (node2.parentNode === this) return true;
18766 node2 = node2.parentNode;
18767 }
18768 return false;
18769 };
18770 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18771 _proto.appendChild = function appendChild(_newChild) {
18772 throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.");
18773 };
18774 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18775 _proto.insertBefore = function insertBefore(_newChild, _refChild) {
18776 throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.");
18777 };
18778 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18779 _proto.removeChild = function removeChild(_node) {
18780 throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.");
18781 };
18782 _proto.toString = function toString() {
18783 return "RRNode";
18784 };
18785 _create_class(BaseRRNode, [
18786 {
18787 key: "childNodes",
18788 get: function get() {
18789 var childNodes2 = [];
18790 var childIterator = this.firstChild;
18791 while(childIterator){
18792 childNodes2.push(childIterator);
18793 childIterator = childIterator.nextSibling;
18794 }
18795 return childNodes2;
18796 }
18797 }
18798 ]);
18799 return BaseRRNode;
18800 }();
18801 var testableAccessors = {
18802 Node: [
18803 "childNodes",
18804 "parentNode",
18805 "parentElement",
18806 "textContent"
18807 ],
18808 ShadowRoot: [
18809 "host",
18810 "styleSheets"
18811 ],
18812 Element: [
18813 "shadowRoot",
18814 "querySelector",
18815 "querySelectorAll"
18816 ],
18817 MutationObserver: []
18818 };
18819 var testableMethods = {
18820 Node: [
18821 "contains",
18822 "getRootNode"
18823 ],
18824 ShadowRoot: [
18825 "getSelection"
18826 ],
18827 Element: [],
18828 MutationObserver: [
18829 "constructor"
18830 ]
18831 };
18832 var untaintedBasePrototype = {};
18833 var isAngularZonePresent = function() {
18834 return !!globalThis.Zone;
18835 };
18836 function getUntaintedPrototype(key) {
18837 if (untaintedBasePrototype[key]) return untaintedBasePrototype[key];
18838 var defaultObj = globalThis[key];
18839 var defaultPrototype = defaultObj.prototype;
18840 var accessorNames = key in testableAccessors ? testableAccessors[key] : void 0;
18841 var isUntaintedAccessors = Boolean(accessorNames && // @ts-expect-error 2345
18842 accessorNames.every(function(accessor) {
18843 var _a2, _b;
18844 return Boolean((_b = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b.toString().includes("[native code]"));
18845 }));
18846 var methodNames = key in testableMethods ? testableMethods[key] : void 0;
18847 var isUntaintedMethods = Boolean(methodNames && methodNames.every(// @ts-expect-error 2345
18848 function(method) {
18849 var _a2;
18850 return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
18851 }));
18852 if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent()) {
18853 untaintedBasePrototype[key] = defaultObj.prototype;
18854 return defaultObj.prototype;
18855 }
18856 try {
18857 var iframeEl = document.createElement("iframe");
18858 document.body.appendChild(iframeEl);
18859 var win = iframeEl.contentWindow;
18860 if (!win) return defaultObj.prototype;
18861 var untaintedObject = win[key].prototype;
18862 document.body.removeChild(iframeEl);
18863 if (!untaintedObject) return defaultPrototype;
18864 return untaintedBasePrototype[key] = untaintedObject;
18865 } catch (e) {
18866 return defaultPrototype;
18867 }
18868 }
18869 var untaintedAccessorCache = {};
18870 function getUntaintedAccessor(key, instance, accessor) {
18871 var _a2;
18872 var cacheKey = key + "." + String(accessor);
18873 if (untaintedAccessorCache[cacheKey]) return untaintedAccessorCache[cacheKey].call(instance);
18874 var untaintedPrototype = getUntaintedPrototype(key);
18875 var untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(untaintedPrototype, accessor)) == null ? void 0 : _a2.get;
18876 if (!untaintedAccessor) return instance[accessor];
18877 untaintedAccessorCache[cacheKey] = untaintedAccessor;
18878 return untaintedAccessor.call(instance);
18879 }
18880 var untaintedMethodCache = {};
18881 function getUntaintedMethod(key, instance, method) {
18882 var cacheKey = key + "." + String(method);
18883 if (untaintedMethodCache[cacheKey]) return untaintedMethodCache[cacheKey].bind(instance);
18884 var untaintedPrototype = getUntaintedPrototype(key);
18885 var untaintedMethod = untaintedPrototype[method];
18886 if (typeof untaintedMethod !== "function") return instance[method];
18887 untaintedMethodCache[cacheKey] = untaintedMethod;
18888 return untaintedMethod.bind(instance);
18889 }
18890 function childNodes(n2) {
18891 return getUntaintedAccessor("Node", n2, "childNodes");
18892 }
18893 function parentNode(n2) {
18894 return getUntaintedAccessor("Node", n2, "parentNode");
18895 }
18896 function parentElement(n2) {
18897 return getUntaintedAccessor("Node", n2, "parentElement");
18898 }
18899 function textContent(n2) {
18900 return getUntaintedAccessor("Node", n2, "textContent");
18901 }
18902 function contains(n2, other) {
18903 return getUntaintedMethod("Node", n2, "contains")(other);
18904 }
18905 function getRootNode(n2) {
18906 return getUntaintedMethod("Node", n2, "getRootNode")();
18907 }
18908 function host(n2) {
18909 if (!n2 || !("host" in n2)) return null;
18910 return getUntaintedAccessor("ShadowRoot", n2, "host");
18911 }
18912 function styleSheets(n2) {
18913 return n2.styleSheets;
18914 }
18915 function shadowRoot(n2) {
18916 if (!n2 || !("shadowRoot" in n2)) return null;
18917 return getUntaintedAccessor("Element", n2, "shadowRoot");
18918 }
18919 function querySelector(n2, selectors) {
18920 return getUntaintedAccessor("Element", n2, "querySelector")(selectors);
18921 }
18922 function querySelectorAll(n2, selectors) {
18923 return getUntaintedAccessor("Element", n2, "querySelectorAll")(selectors);
18924 }
18925 function mutationObserverCtor() {
18926 return getUntaintedPrototype("MutationObserver").constructor;
18927 }
18928 function patch(source, name, replacement) {
18929 try {
18930 if (!(name in source)) {
18931 return function() {};
18932 }
18933 var original = source[name];
18934 var wrapped = replacement(original);
18935 if (typeof wrapped === "function") {
18936 wrapped.prototype = wrapped.prototype || {};
18937 Object.defineProperties(wrapped, {
18938 __rrweb_original__: {
18939 enumerable: false,
18940 value: original
18941 }
18942 });
18943 }
18944 source[name] = wrapped;
18945 return function() {
18946 source[name] = original;
18947 };
18948 } catch (e) {
18949 return function() {};
18950 }
18951 }
18952 var index = {
18953 childNodes: childNodes,
18954 parentNode: parentNode,
18955 parentElement: parentElement,
18956 textContent: textContent,
18957 contains: contains,
18958 getRootNode: getRootNode,
18959 host: host,
18960 styleSheets: styleSheets,
18961 shadowRoot: shadowRoot,
18962 querySelector: querySelector,
18963 querySelectorAll: querySelectorAll,
18964 mutationObserver: mutationObserverCtor,
18965 patch: patch
18966 };
18967 function on(type, fn, target) {
18968 if (target === void 0) target = document;
18969 var options = {
18970 capture: true,
18971 passive: true
18972 };
18973 target.addEventListener(type, fn, options);
18974 return function() {
18975 return target.removeEventListener(type, fn, options);
18976 };
18977 }
18978 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.";
18979 var _mirror = {
18980 map: {},
18981 getId: function getId() {
18982 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18983 return -1;
18984 },
18985 getNode: function getNode() {
18986 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18987 return null;
18988 },
18989 removeNodeFromMap: function removeNodeFromMap() {
18990 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18991 },
18992 has: function has() {
18993 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18994 return false;
18995 },
18996 reset: function reset() {
18997 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18998 }
18999 };
19000 if (typeof window !== "undefined" && window.Proxy && window.Reflect) {
19001 _mirror = new Proxy(_mirror, {
19002 get: function get(target, prop, receiver) {
19003 if (prop === "map") {
19004 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
19005 }
19006 return Reflect.get(target, prop, receiver);
19007 }
19008 });
19009 }
19010 function throttle(func, wait, options) {
19011 if (options === void 0) options = {};
19012 var timeout = null;
19013 var previous = 0;
19014 return function() {
19015 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
19016 args[_key] = arguments[_key];
19017 }
19018 var now = Date.now();
19019 if (!previous && options.leading === false) {
19020 previous = now;
19021 }
19022 var remaining = wait - (now - previous);
19023 var context = this;
19024 if (remaining <= 0 || remaining > wait) {
19025 if (timeout) {
19026 clearTimeout(timeout);
19027 timeout = null;
19028 }
19029 previous = now;
19030 func.apply(context, args);
19031 } else if (!timeout && options.trailing !== false) {
19032 timeout = setTimeout(function() {
19033 previous = options.leading === false ? 0 : Date.now();
19034 timeout = null;
19035 func.apply(context, args);
19036 }, remaining);
19037 }
19038 };
19039 }
19040 function hookSetter(target, key, d, isRevoked, win) {
19041 if (win === void 0) win = window;
19042 var original = win.Object.getOwnPropertyDescriptor(target, key);
19043 win.Object.defineProperty(target, key, isRevoked ? d : {
19044 set: function set(value) {
19045 var _this = this;
19046 setTimeout(function() {
19047 d.set.call(_this, value);
19048 }, 0);
19049 if (original && original.set) {
19050 original.set.call(this, value);
19051 }
19052 }
19053 });
19054 return function() {
19055 return hookSetter(target, key, original || {}, true);
19056 };
19057 }
19058 var nowTimestamp = Date.now;
19059 if (!/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())) {
19060 nowTimestamp = function() {
19061 return /* @__PURE__ */ new Date().getTime();
19062 };
19063 }
19064 function getWindowScroll(win) {
19065 var _a2, _b, _c, _d;
19066 var doc = win.document;
19067 return {
19068 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,
19069 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
19070 };
19071 }
19072 function getWindowHeight() {
19073 return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body && document.body.clientHeight;
19074 }
19075 function getWindowWidth() {
19076 return window.innerWidth || document.documentElement && document.documentElement.clientWidth || document.body && document.body.clientWidth;
19077 }
19078 function closestElementOfNode(node2) {
19079 if (!node2) {
19080 return null;
19081 }
19082 var el = node2.nodeType === node2.ELEMENT_NODE ? node2 : index.parentElement(node2);
19083 return el;
19084 }
19085 function isBlocked(node2, blockClass, blockSelector, checkAncestors) {
19086 if (!node2) {
19087 return false;
19088 }
19089 var el = closestElementOfNode(node2);
19090 if (!el) {
19091 return false;
19092 }
19093 try {
19094 if (typeof blockClass === "string") {
19095 if (el.classList.contains(blockClass)) return true;
19096 if (checkAncestors && el.closest("." + blockClass) !== null) return true;
19097 } else {
19098 if (classMatchesRegex(el, blockClass, checkAncestors)) return true;
19099 }
19100 } catch (e2) {}
19101 if (blockSelector) {
19102 if (el.matches(blockSelector)) return true;
19103 if (checkAncestors && el.closest(blockSelector) !== null) return true;
19104 }
19105 return false;
19106 }
19107 function isSerialized(n2, mirror2) {
19108 return mirror2.getId(n2) !== -1;
19109 }
19110 function isIgnored(n2, mirror2, slimDOMOptions) {
19111 if (n2.tagName === "TITLE" && slimDOMOptions.headTitleMutations) {
19112 return true;
19113 }
19114 return mirror2.getId(n2) === IGNORED_NODE;
19115 }
19116 function isAncestorRemoved(target, mirror2) {
19117 if (isShadowRoot(target)) {
19118 return false;
19119 }
19120 var id = mirror2.getId(target);
19121 if (!mirror2.has(id)) {
19122 return true;
19123 }
19124 var parent = index.parentNode(target);
19125 if (parent && parent.nodeType === target.DOCUMENT_NODE) {
19126 return false;
19127 }
19128 if (!parent) {
19129 return true;
19130 }
19131 return isAncestorRemoved(parent, mirror2);
19132 }
19133 function legacy_isTouchEvent(event) {
19134 return Boolean(event.changedTouches);
19135 }
19136 function polyfill$1(win) {
19137 if (win === void 0) win = window;
19138 if ("NodeList" in win && !win.NodeList.prototype.forEach) {
19139 win.NodeList.prototype.forEach = Array.prototype.forEach;
19140 }
19141 if ("DOMTokenList" in win && !win.DOMTokenList.prototype.forEach) {
19142 win.DOMTokenList.prototype.forEach = Array.prototype.forEach;
19143 }
19144 }
19145 function isSerializedIframe(n2, mirror2) {
19146 return Boolean(n2.nodeName === "IFRAME" && mirror2.getMeta(n2));
19147 }
19148 function isSerializedStylesheet(n2, mirror2) {
19149 return Boolean(n2.nodeName === "LINK" && n2.nodeType === n2.ELEMENT_NODE && n2.getAttribute && n2.getAttribute("rel") === "stylesheet" && mirror2.getMeta(n2));
19150 }
19151 function hasShadowRoot(n2) {
19152 if (!n2) return false;
19153 if (_instanceof(n2, BaseRRNode) && "shadowRoot" in n2) {
19154 return Boolean(n2.shadowRoot);
19155 }
19156 return Boolean(index.shadowRoot(n2));
19157 }
19158 var StyleSheetMirror = /*#__PURE__*/ function() {
19159 function StyleSheetMirror() {
19160 __publicField(this, "id", 1);
19161 __publicField(this, "styleIDMap", /* @__PURE__ */ new WeakMap());
19162 __publicField(this, "idStyleMap", /* @__PURE__ */ new Map());
19163 }
19164 var _proto = StyleSheetMirror.prototype;
19165 _proto.getId = function getId(stylesheet) {
19166 var _this_styleIDMap_get;
19167 return (_this_styleIDMap_get = this.styleIDMap.get(stylesheet)) != null ? _this_styleIDMap_get : -1;
19168 };
19169 _proto.has = function has(stylesheet) {
19170 return this.styleIDMap.has(stylesheet);
19171 };
19172 /**
19173 * @returns If the stylesheet is in the mirror, returns the id of the stylesheet. If not, return the new assigned id.
19174 */ _proto.add = function add(stylesheet, id) {
19175 if (this.has(stylesheet)) return this.getId(stylesheet);
19176 var newId;
19177 if (id === void 0) {
19178 newId = this.id++;
19179 } else newId = id;
19180 this.styleIDMap.set(stylesheet, newId);
19181 this.idStyleMap.set(newId, stylesheet);
19182 return newId;
19183 };
19184 _proto.getStyle = function getStyle(id) {
19185 return this.idStyleMap.get(id) || null;
19186 };
19187 _proto.reset = function reset() {
19188 this.styleIDMap = /* @__PURE__ */ new WeakMap();
19189 this.idStyleMap = /* @__PURE__ */ new Map();
19190 this.id = 1;
19191 };
19192 _proto.generateId = function generateId() {
19193 return this.id++;
19194 };
19195 return StyleSheetMirror;
19196 }();
19197 function getShadowHost(n2) {
19198 var _a2;
19199 var shadowHost = null;
19200 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));
19201 return shadowHost;
19202 }
19203 function getRootShadowHost(n2) {
19204 var rootShadowHost = n2;
19205 var shadowHost;
19206 while(shadowHost = getShadowHost(rootShadowHost))rootShadowHost = shadowHost;
19207 return rootShadowHost;
19208 }
19209 function shadowHostInDom(n2) {
19210 var doc = n2.ownerDocument;
19211 if (!doc) return false;
19212 var shadowHost = getRootShadowHost(n2);
19213 return index.contains(doc, shadowHost);
19214 }
19215 function inDom(n2) {
19216 var doc = n2.ownerDocument;
19217 if (!doc) return false;
19218 return index.contains(doc, n2) || shadowHostInDom(n2);
19219 }
19220 var EventType = /* @__PURE__ */ function(EventType2) {
19221 EventType2[EventType2["DomContentLoaded"] = 0] = "DomContentLoaded";
19222 EventType2[EventType2["Load"] = 1] = "Load";
19223 EventType2[EventType2["FullSnapshot"] = 2] = "FullSnapshot";
19224 EventType2[EventType2["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
19225 EventType2[EventType2["Meta"] = 4] = "Meta";
19226 EventType2[EventType2["Custom"] = 5] = "Custom";
19227 EventType2[EventType2["Plugin"] = 6] = "Plugin";
19228 return EventType2;
19229 }(EventType || {});
19230 var IncrementalSource = /* @__PURE__ */ function(IncrementalSource2) {
19231 IncrementalSource2[IncrementalSource2["Mutation"] = 0] = "Mutation";
19232 IncrementalSource2[IncrementalSource2["MouseMove"] = 1] = "MouseMove";
19233 IncrementalSource2[IncrementalSource2["MouseInteraction"] = 2] = "MouseInteraction";
19234 IncrementalSource2[IncrementalSource2["Scroll"] = 3] = "Scroll";
19235 IncrementalSource2[IncrementalSource2["ViewportResize"] = 4] = "ViewportResize";
19236 IncrementalSource2[IncrementalSource2["Input"] = 5] = "Input";
19237 IncrementalSource2[IncrementalSource2["TouchMove"] = 6] = "TouchMove";
19238 IncrementalSource2[IncrementalSource2["MediaInteraction"] = 7] = "MediaInteraction";
19239 IncrementalSource2[IncrementalSource2["StyleSheetRule"] = 8] = "StyleSheetRule";
19240 IncrementalSource2[IncrementalSource2["CanvasMutation"] = 9] = "CanvasMutation";
19241 IncrementalSource2[IncrementalSource2["Font"] = 10] = "Font";
19242 IncrementalSource2[IncrementalSource2["Log"] = 11] = "Log";
19243 IncrementalSource2[IncrementalSource2["Drag"] = 12] = "Drag";
19244 IncrementalSource2[IncrementalSource2["StyleDeclaration"] = 13] = "StyleDeclaration";
19245 IncrementalSource2[IncrementalSource2["Selection"] = 14] = "Selection";
19246 IncrementalSource2[IncrementalSource2["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
19247 IncrementalSource2[IncrementalSource2["CustomElement"] = 16] = "CustomElement";
19248 return IncrementalSource2;
19249 }(IncrementalSource || {});
19250 var MouseInteractions = /* @__PURE__ */ function(MouseInteractions2) {
19251 MouseInteractions2[MouseInteractions2["MouseUp"] = 0] = "MouseUp";
19252 MouseInteractions2[MouseInteractions2["MouseDown"] = 1] = "MouseDown";
19253 MouseInteractions2[MouseInteractions2["Click"] = 2] = "Click";
19254 MouseInteractions2[MouseInteractions2["ContextMenu"] = 3] = "ContextMenu";
19255 MouseInteractions2[MouseInteractions2["DblClick"] = 4] = "DblClick";
19256 MouseInteractions2[MouseInteractions2["Focus"] = 5] = "Focus";
19257 MouseInteractions2[MouseInteractions2["Blur"] = 6] = "Blur";
19258 MouseInteractions2[MouseInteractions2["TouchStart"] = 7] = "TouchStart";
19259 MouseInteractions2[MouseInteractions2["TouchMove_Departed"] = 8] = "TouchMove_Departed";
19260 MouseInteractions2[MouseInteractions2["TouchEnd"] = 9] = "TouchEnd";
19261 MouseInteractions2[MouseInteractions2["TouchCancel"] = 10] = "TouchCancel";
19262 return MouseInteractions2;
19263 }(MouseInteractions || {});
19264 var PointerTypes = /* @__PURE__ */ function(PointerTypes2) {
19265 PointerTypes2[PointerTypes2["Mouse"] = 0] = "Mouse";
19266 PointerTypes2[PointerTypes2["Pen"] = 1] = "Pen";
19267 PointerTypes2[PointerTypes2["Touch"] = 2] = "Touch";
19268 return PointerTypes2;
19269 }(PointerTypes || {});
19270 var CanvasContext = /* @__PURE__ */ function(CanvasContext2) {
19271 CanvasContext2[CanvasContext2["2D"] = 0] = "2D";
19272 CanvasContext2[CanvasContext2["WebGL"] = 1] = "WebGL";
19273 CanvasContext2[CanvasContext2["WebGL2"] = 2] = "WebGL2";
19274 return CanvasContext2;
19275 }(CanvasContext || {});
19276 var MediaInteractions = /* @__PURE__ */ function(MediaInteractions2) {
19277 MediaInteractions2[MediaInteractions2["Play"] = 0] = "Play";
19278 MediaInteractions2[MediaInteractions2["Pause"] = 1] = "Pause";
19279 MediaInteractions2[MediaInteractions2["Seeked"] = 2] = "Seeked";
19280 MediaInteractions2[MediaInteractions2["VolumeChange"] = 3] = "VolumeChange";
19281 MediaInteractions2[MediaInteractions2["RateChange"] = 4] = "RateChange";
19282 return MediaInteractions2;
19283 }(MediaInteractions || {});
19284 var NodeType = /* @__PURE__ */ function(NodeType2) {
19285 NodeType2[NodeType2["Document"] = 0] = "Document";
19286 NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
19287 NodeType2[NodeType2["Element"] = 2] = "Element";
19288 NodeType2[NodeType2["Text"] = 3] = "Text";
19289 NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
19290 NodeType2[NodeType2["Comment"] = 5] = "Comment";
19291 return NodeType2;
19292 }(NodeType || {});
19293 function isNodeInLinkedList(n2) {
19294 return "__ln" in n2;
19295 }
19296 var DoubleLinkedList = /*#__PURE__*/ function() {
19297 function DoubleLinkedList() {
19298 __publicField(this, "length", 0);
19299 __publicField(this, "head", null);
19300 __publicField(this, "tail", null);
19301 }
19302 var _proto = DoubleLinkedList.prototype;
19303 _proto.get = function get(position) {
19304 if (position >= this.length) {
19305 throw new Error("Position outside of list range");
19306 }
19307 var current = this.head;
19308 for(var index2 = 0; index2 < position; index2++){
19309 current = (current == null ? void 0 : current.next) || null;
19310 }
19311 return current;
19312 };
19313 _proto.addNode = function addNode(n2) {
19314 var node2 = {
19315 value: n2,
19316 previous: null,
19317 next: null
19318 };
19319 n2.__ln = node2;
19320 if (n2.previousSibling && isNodeInLinkedList(n2.previousSibling)) {
19321 var current = n2.previousSibling.__ln.next;
19322 node2.next = current;
19323 node2.previous = n2.previousSibling.__ln;
19324 n2.previousSibling.__ln.next = node2;
19325 if (current) {
19326 current.previous = node2;
19327 }
19328 } else if (n2.nextSibling && isNodeInLinkedList(n2.nextSibling) && n2.nextSibling.__ln.previous) {
19329 var current1 = n2.nextSibling.__ln.previous;
19330 node2.previous = current1;
19331 node2.next = n2.nextSibling.__ln;
19332 n2.nextSibling.__ln.previous = node2;
19333 if (current1) {
19334 current1.next = node2;
19335 }
19336 } else {
19337 if (this.head) {
19338 this.head.previous = node2;
19339 }
19340 node2.next = this.head;
19341 this.head = node2;
19342 }
19343 if (node2.next === null) {
19344 this.tail = node2;
19345 }
19346 this.length++;
19347 };
19348 _proto.removeNode = function removeNode(n2) {
19349 var current = n2.__ln;
19350 if (!this.head) {
19351 return;
19352 }
19353 if (!current.previous) {
19354 this.head = current.next;
19355 if (this.head) {
19356 this.head.previous = null;
19357 } else {
19358 this.tail = null;
19359 }
19360 } else {
19361 current.previous.next = current.next;
19362 if (current.next) {
19363 current.next.previous = current.previous;
19364 } else {
19365 this.tail = current.previous;
19366 }
19367 }
19368 if (n2.__ln) {
19369 delete n2.__ln;
19370 }
19371 this.length--;
19372 };
19373 return DoubleLinkedList;
19374 }();
19375 var moveKey = function(id, parentId) {
19376 return id + "@" + parentId;
19377 };
19378 var MutationBuffer = /*#__PURE__*/ function() {
19379 function MutationBuffer() {
19380 var _this = this;
19381 __publicField(this, "frozen", false);
19382 __publicField(this, "locked", false);
19383 __publicField(this, "texts", []);
19384 __publicField(this, "attributes", []);
19385 __publicField(this, "attributeMap", /* @__PURE__ */ new WeakMap());
19386 __publicField(this, "removes", []);
19387 __publicField(this, "mapRemoves", []);
19388 __publicField(this, "movedMap", {});
19389 /**
19390 * the browser MutationObserver emits multiple mutations after
19391 * a delay for performance reasons, making tracing added nodes hard
19392 * in our `processMutations` callback function.
19393 * For example, if we append an element el_1 into body, and then append
19394 * another element el_2 into el_1, these two mutations may be passed to the
19395 * callback function together when the two operations were done.
19396 * Generally we need to trace child nodes of newly added nodes, but in this
19397 * case if we count el_2 as el_1's child node in the first mutation record,
19398 * then we will count el_2 again in the second mutation record which was
19399 * duplicated.
19400 * To avoid of duplicate counting added nodes, we use a Set to store
19401 * added nodes and its child nodes during iterate mutation records. Then
19402 * collect added nodes from the Set which have no duplicate copy. But
19403 * this also causes newly added nodes will not be serialized with id ASAP,
19404 * which means all the id related calculation should be lazy too.
19405 */ __publicField(this, "addedSet", /* @__PURE__ */ new Set());
19406 __publicField(this, "movedSet", /* @__PURE__ */ new Set());
19407 __publicField(this, "droppedSet", /* @__PURE__ */ new Set());
19408 __publicField(this, "removesSubTreeCache", /* @__PURE__ */ new Set());
19409 __publicField(this, "mutationCb");
19410 __publicField(this, "blockClass");
19411 __publicField(this, "blockSelector");
19412 __publicField(this, "maskTextClass");
19413 __publicField(this, "maskTextSelector");
19414 __publicField(this, "inlineStylesheet");
19415 __publicField(this, "maskInputOptions");
19416 __publicField(this, "maskTextFn");
19417 __publicField(this, "maskInputFn");
19418 __publicField(this, "keepIframeSrcFn");
19419 __publicField(this, "recordCanvas");
19420 __publicField(this, "inlineImages");
19421 __publicField(this, "slimDOMOptions");
19422 __publicField(this, "dataURLOptions");
19423 __publicField(this, "doc");
19424 __publicField(this, "mirror");
19425 __publicField(this, "iframeManager");
19426 __publicField(this, "stylesheetManager");
19427 __publicField(this, "shadowDomManager");
19428 __publicField(this, "canvasManager");
19429 __publicField(this, "processedNodeManager");
19430 __publicField(this, "unattachedDoc");
19431 __publicField(this, "processMutations", function(mutations) {
19432 mutations.forEach(_this.processMutation);
19433 _this.emit();
19434 });
19435 __publicField(this, "emit", function() {
19436 if (_this.frozen || _this.locked) {
19437 return;
19438 }
19439 var adds = [];
19440 var addedIds = /* @__PURE__ */ new Set();
19441 var addList = new DoubleLinkedList();
19442 var getNextId = function(n2) {
19443 var ns = n2;
19444 var nextId = IGNORED_NODE;
19445 while(nextId === IGNORED_NODE){
19446 ns = ns && ns.nextSibling;
19447 nextId = ns && _this.mirror.getId(ns);
19448 }
19449 return nextId;
19450 };
19451 var pushAdd = function(n2) {
19452 var parent = index.parentNode(n2);
19453 if (!parent || !inDom(n2)) {
19454 return;
19455 }
19456 var cssCaptured = false;
19457 if (n2.nodeType === Node.TEXT_NODE) {
19458 var parentTag = parent.tagName;
19459 if (parentTag === "TEXTAREA") {
19460 return;
19461 } else if (parentTag === "STYLE" && _this.addedSet.has(parent)) {
19462 cssCaptured = true;
19463 }
19464 }
19465 var parentId = isShadowRoot(parent) ? _this.mirror.getId(getShadowHost(n2)) : _this.mirror.getId(parent);
19466 var nextId = getNextId(n2);
19467 if (parentId === -1 || nextId === -1) {
19468 return addList.addNode(n2);
19469 }
19470 var sn = serializeNodeWithId(n2, {
19471 doc: _this.doc,
19472 mirror: _this.mirror,
19473 blockClass: _this.blockClass,
19474 blockSelector: _this.blockSelector,
19475 maskTextClass: _this.maskTextClass,
19476 maskTextSelector: _this.maskTextSelector,
19477 skipChild: true,
19478 newlyAddedElement: true,
19479 inlineStylesheet: _this.inlineStylesheet,
19480 maskInputOptions: _this.maskInputOptions,
19481 maskTextFn: _this.maskTextFn,
19482 maskInputFn: _this.maskInputFn,
19483 slimDOMOptions: _this.slimDOMOptions,
19484 dataURLOptions: _this.dataURLOptions,
19485 recordCanvas: _this.recordCanvas,
19486 inlineImages: _this.inlineImages,
19487 onSerialize: function(currentN) {
19488 if (isSerializedIframe(currentN, _this.mirror)) {
19489 _this.iframeManager.addIframe(currentN);
19490 }
19491 if (isSerializedStylesheet(currentN, _this.mirror)) {
19492 _this.stylesheetManager.trackLinkElement(currentN);
19493 }
19494 if (hasShadowRoot(n2)) {
19495 _this.shadowDomManager.addShadowRoot(index.shadowRoot(n2), _this.doc);
19496 }
19497 },
19498 onIframeLoad: function(iframe, childSn) {
19499 _this.iframeManager.attachIframe(iframe, childSn);
19500 _this.shadowDomManager.observeAttachShadow(iframe);
19501 },
19502 onStylesheetLoad: function(link, childSn) {
19503 _this.stylesheetManager.attachLinkElement(link, childSn);
19504 },
19505 cssCaptured: cssCaptured
19506 });
19507 if (sn) {
19508 adds.push({
19509 parentId: parentId,
19510 nextId: nextId,
19511 node: sn
19512 });
19513 addedIds.add(sn.id);
19514 }
19515 };
19516 while(_this.mapRemoves.length){
19517 _this.mirror.removeNodeFromMap(_this.mapRemoves.shift());
19518 }
19519 for(var _iterator = _create_for_of_iterator_helper_loose(_this.movedSet), _step; !(_step = _iterator()).done;){
19520 var n2 = _step.value;
19521 if (isParentRemoved(_this.removesSubTreeCache, n2, _this.mirror) && !_this.movedSet.has(index.parentNode(n2))) {
19522 continue;
19523 }
19524 pushAdd(n2);
19525 }
19526 for(var _iterator1 = _create_for_of_iterator_helper_loose(_this.addedSet), _step1; !(_step1 = _iterator1()).done;){
19527 var n21 = _step1.value;
19528 if (!isAncestorInSet(_this.droppedSet, n21) && !isParentRemoved(_this.removesSubTreeCache, n21, _this.mirror)) {
19529 pushAdd(n21);
19530 } else if (isAncestorInSet(_this.movedSet, n21)) {
19531 pushAdd(n21);
19532 } else {
19533 _this.droppedSet.add(n21);
19534 }
19535 }
19536 var candidate = null;
19537 while(addList.length){
19538 var node2 = null;
19539 if (candidate) {
19540 var parentId = _this.mirror.getId(index.parentNode(candidate.value));
19541 var nextId = getNextId(candidate.value);
19542 if (parentId !== -1 && nextId !== -1) {
19543 node2 = candidate;
19544 }
19545 }
19546 if (!node2) {
19547 var tailNode = addList.tail;
19548 while(tailNode){
19549 var _node = tailNode;
19550 tailNode = tailNode.previous;
19551 if (_node) {
19552 var parentId1 = _this.mirror.getId(index.parentNode(_node.value));
19553 var nextId1 = getNextId(_node.value);
19554 if (nextId1 === -1) continue;
19555 else if (parentId1 !== -1) {
19556 node2 = _node;
19557 break;
19558 } else {
19559 var unhandledNode = _node.value;
19560 var parent = index.parentNode(unhandledNode);
19561 if (parent && parent.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
19562 var shadowHost = index.host(parent);
19563 var parentId2 = _this.mirror.getId(shadowHost);
19564 if (parentId2 !== -1) {
19565 node2 = _node;
19566 break;
19567 }
19568 }
19569 }
19570 }
19571 }
19572 }
19573 if (!node2) {
19574 while(addList.head){
19575 addList.removeNode(addList.head.value);
19576 }
19577 break;
19578 }
19579 candidate = node2.previous;
19580 addList.removeNode(node2.value);
19581 pushAdd(node2.value);
19582 }
19583 var payload = {
19584 texts: _this.texts.map(function(text) {
19585 var n2 = text.node;
19586 var parent = index.parentNode(n2);
19587 if (parent && parent.tagName === "TEXTAREA") {
19588 _this.genTextAreaValueMutation(parent);
19589 }
19590 return {
19591 id: _this.mirror.getId(n2),
19592 value: text.value
19593 };
19594 }).filter(function(text) {
19595 return !addedIds.has(text.id);
19596 }).filter(function(text) {
19597 return _this.mirror.has(text.id);
19598 }),
19599 attributes: _this.attributes.map(function(attribute) {
19600 var attributes = attribute.attributes;
19601 if (typeof attributes.style === "string") {
19602 var diffAsStr = JSON.stringify(attribute.styleDiff);
19603 var unchangedAsStr = JSON.stringify(attribute._unchangedStyles);
19604 if (diffAsStr.length < attributes.style.length) {
19605 if ((diffAsStr + unchangedAsStr).split("var(").length === attributes.style.split("var(").length) {
19606 attributes.style = attribute.styleDiff;
19607 }
19608 }
19609 }
19610 return {
19611 id: _this.mirror.getId(attribute.node),
19612 attributes: attributes
19613 };
19614 }).filter(function(attribute) {
19615 return !addedIds.has(attribute.id);
19616 }).filter(function(attribute) {
19617 return _this.mirror.has(attribute.id);
19618 }),
19619 removes: _this.removes,
19620 adds: adds
19621 };
19622 if (!payload.texts.length && !payload.attributes.length && !payload.removes.length && !payload.adds.length) {
19623 return;
19624 }
19625 _this.texts = [];
19626 _this.attributes = [];
19627 _this.attributeMap = /* @__PURE__ */ new WeakMap();
19628 _this.removes = [];
19629 _this.addedSet = /* @__PURE__ */ new Set();
19630 _this.movedSet = /* @__PURE__ */ new Set();
19631 _this.droppedSet = /* @__PURE__ */ new Set();
19632 _this.removesSubTreeCache = /* @__PURE__ */ new Set();
19633 _this.movedMap = {};
19634 _this.mutationCb(payload);
19635 });
19636 __publicField(this, "genTextAreaValueMutation", function(textarea) {
19637 var item = _this.attributeMap.get(textarea);
19638 if (!item) {
19639 item = {
19640 node: textarea,
19641 attributes: {},
19642 styleDiff: {},
19643 _unchangedStyles: {}
19644 };
19645 _this.attributes.push(item);
19646 _this.attributeMap.set(textarea, item);
19647 }
19648 var value = Array.from(index.childNodes(textarea), function(cn) {
19649 return index.textContent(cn) || "";
19650 }).join("");
19651 item.attributes.value = maskInputValue({
19652 element: textarea,
19653 maskInputOptions: _this.maskInputOptions,
19654 tagName: textarea.tagName,
19655 type: getInputType(textarea),
19656 value: value,
19657 maskInputFn: _this.maskInputFn
19658 });
19659 });
19660 __publicField(this, "processMutation", function(m) {
19661 if (isIgnored(m.target, _this.mirror, _this.slimDOMOptions)) {
19662 return;
19663 }
19664 switch(m.type){
19665 case "characterData":
19666 {
19667 var value = index.textContent(m.target);
19668 if (!isBlocked(m.target, _this.blockClass, _this.blockSelector, false) && value !== m.oldValue) {
19669 _this.texts.push({
19670 value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector, true) && value ? _this.maskTextFn ? _this.maskTextFn(value, closestElementOfNode(m.target)) : value.replace(/[\S]/g, "*") : value,
19671 node: m.target
19672 });
19673 }
19674 break;
19675 }
19676 case "attributes":
19677 {
19678 var target = m.target;
19679 var attributeName = m.attributeName;
19680 var value1 = m.target.getAttribute(attributeName);
19681 if (attributeName === "value") {
19682 var type = getInputType(target);
19683 value1 = maskInputValue({
19684 element: target,
19685 maskInputOptions: _this.maskInputOptions,
19686 tagName: target.tagName,
19687 type: type,
19688 value: value1,
19689 maskInputFn: _this.maskInputFn
19690 });
19691 }
19692 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, false) || value1 === m.oldValue) {
19693 return;
19694 }
19695 var item = _this.attributeMap.get(m.target);
19696 if (target.tagName === "IFRAME" && attributeName === "src" && !_this.keepIframeSrcFn(value1)) {
19697 if (!target.contentDocument) {
19698 attributeName = "rr_src";
19699 } else {
19700 return;
19701 }
19702 }
19703 if (!item) {
19704 item = {
19705 node: m.target,
19706 attributes: {},
19707 styleDiff: {},
19708 _unchangedStyles: {}
19709 };
19710 _this.attributes.push(item);
19711 _this.attributeMap.set(m.target, item);
19712 }
19713 if (attributeName === "type" && target.tagName === "INPUT" && (m.oldValue || "").toLowerCase() === "password") {
19714 target.setAttribute("data-rr-is-password", "true");
19715 }
19716 if (!ignoreAttribute(target.tagName, attributeName)) {
19717 item.attributes[attributeName] = transformAttribute(_this.doc, toLowerCase(target.tagName), toLowerCase(attributeName), value1);
19718 if (attributeName === "style") {
19719 if (!_this.unattachedDoc) {
19720 try {
19721 _this.unattachedDoc = document.implementation.createHTMLDocument();
19722 } catch (e2) {
19723 _this.unattachedDoc = _this.doc;
19724 }
19725 }
19726 var old = _this.unattachedDoc.createElement("span");
19727 if (m.oldValue) {
19728 old.setAttribute("style", m.oldValue);
19729 }
19730 for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(target.style)), _step; !(_step = _iterator()).done;){
19731 var pname = _step.value;
19732 var newValue = target.style.getPropertyValue(pname);
19733 var newPriority = target.style.getPropertyPriority(pname);
19734 if (newValue !== old.style.getPropertyValue(pname) || newPriority !== old.style.getPropertyPriority(pname)) {
19735 if (newPriority === "") {
19736 item.styleDiff[pname] = newValue;
19737 } else {
19738 item.styleDiff[pname] = [
19739 newValue,
19740 newPriority
19741 ];
19742 }
19743 } else {
19744 item._unchangedStyles[pname] = [
19745 newValue,
19746 newPriority
19747 ];
19748 }
19749 }
19750 for(var _iterator1 = _create_for_of_iterator_helper_loose(Array.from(old.style)), _step1; !(_step1 = _iterator1()).done;){
19751 var pname1 = _step1.value;
19752 if (target.style.getPropertyValue(pname1) === "") {
19753 item.styleDiff[pname1] = false;
19754 }
19755 }
19756 } else if (attributeName === "open" && target.tagName === "DIALOG") {
19757 if (target.matches("dialog:modal")) {
19758 item.attributes["rr_open_mode"] = "modal";
19759 } else {
19760 item.attributes["rr_open_mode"] = "non-modal";
19761 }
19762 }
19763 }
19764 break;
19765 }
19766 case "childList":
19767 {
19768 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, true)) return;
19769 if (m.target.tagName === "TEXTAREA") {
19770 _this.genTextAreaValueMutation(m.target);
19771 return;
19772 }
19773 m.addedNodes.forEach(function(n2) {
19774 return _this.genAdds(n2, m.target);
19775 });
19776 m.removedNodes.forEach(function(n2) {
19777 var nodeId = _this.mirror.getId(n2);
19778 var parentId = isShadowRoot(m.target) ? _this.mirror.getId(index.host(m.target)) : _this.mirror.getId(m.target);
19779 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, false) || isIgnored(n2, _this.mirror, _this.slimDOMOptions) || !isSerialized(n2, _this.mirror)) {
19780 return;
19781 }
19782 if (_this.addedSet.has(n2)) {
19783 deepDelete(_this.addedSet, n2);
19784 _this.droppedSet.add(n2);
19785 } else if (_this.addedSet.has(m.target) && nodeId === -1) ;
19786 else if (isAncestorRemoved(m.target, _this.mirror)) ;
19787 else if (_this.movedSet.has(n2) && _this.movedMap[moveKey(nodeId, parentId)]) {
19788 deepDelete(_this.movedSet, n2);
19789 } else {
19790 _this.removes.push({
19791 parentId: parentId,
19792 id: nodeId,
19793 isShadow: isShadowRoot(m.target) && isNativeShadowDom(m.target) ? true : void 0
19794 });
19795 processRemoves(n2, _this.removesSubTreeCache);
19796 }
19797 _this.mapRemoves.push(n2);
19798 });
19799 break;
19800 }
19801 }
19802 });
19803 /**
19804 * Make sure you check if `n`'s parent is blocked before calling this function
19805 * */ __publicField(this, "genAdds", function(n2, target) {
19806 if (_this.processedNodeManager.inOtherBuffer(n2, _this)) return;
19807 if (_this.addedSet.has(n2) || _this.movedSet.has(n2)) return;
19808 if (_this.mirror.hasNode(n2)) {
19809 if (isIgnored(n2, _this.mirror, _this.slimDOMOptions)) {
19810 return;
19811 }
19812 _this.movedSet.add(n2);
19813 var targetId = null;
19814 if (target && _this.mirror.hasNode(target)) {
19815 targetId = _this.mirror.getId(target);
19816 }
19817 if (targetId && targetId !== -1) {
19818 _this.movedMap[moveKey(_this.mirror.getId(n2), targetId)] = true;
19819 }
19820 } else {
19821 _this.addedSet.add(n2);
19822 _this.droppedSet.delete(n2);
19823 }
19824 if (!isBlocked(n2, _this.blockClass, _this.blockSelector, false)) {
19825 index.childNodes(n2).forEach(function(childN) {
19826 return _this.genAdds(childN);
19827 });
19828 if (hasShadowRoot(n2)) {
19829 index.childNodes(index.shadowRoot(n2)).forEach(function(childN) {
19830 _this.processedNodeManager.add(childN, _this);
19831 _this.genAdds(childN, n2);
19832 });
19833 }
19834 }
19835 });
19836 }
19837 var _proto = MutationBuffer.prototype;
19838 _proto.init = function init(options) {
19839 var _this = this;
19840 [
19841 "mutationCb",
19842 "blockClass",
19843 "blockSelector",
19844 "maskTextClass",
19845 "maskTextSelector",
19846 "inlineStylesheet",
19847 "maskInputOptions",
19848 "maskTextFn",
19849 "maskInputFn",
19850 "keepIframeSrcFn",
19851 "recordCanvas",
19852 "inlineImages",
19853 "slimDOMOptions",
19854 "dataURLOptions",
19855 "doc",
19856 "mirror",
19857 "iframeManager",
19858 "stylesheetManager",
19859 "shadowDomManager",
19860 "canvasManager",
19861 "processedNodeManager"
19862 ].forEach(function(key) {
19863 _this[key] = options[key];
19864 });
19865 };
19866 _proto.freeze = function freeze() {
19867 this.frozen = true;
19868 this.canvasManager.freeze();
19869 };
19870 _proto.unfreeze = function unfreeze() {
19871 this.frozen = false;
19872 this.canvasManager.unfreeze();
19873 this.emit();
19874 };
19875 _proto.isFrozen = function isFrozen() {
19876 return this.frozen;
19877 };
19878 _proto.lock = function lock() {
19879 this.locked = true;
19880 this.canvasManager.lock();
19881 };
19882 _proto.unlock = function unlock() {
19883 this.locked = false;
19884 this.canvasManager.unlock();
19885 this.emit();
19886 };
19887 _proto.reset = function reset() {
19888 this.shadowDomManager.reset();
19889 this.canvasManager.reset();
19890 };
19891 return MutationBuffer;
19892 }();
19893 function deepDelete(addsSet, n2) {
19894 addsSet.delete(n2);
19895 index.childNodes(n2).forEach(function(childN) {
19896 return deepDelete(addsSet, childN);
19897 });
19898 }
19899 function processRemoves(n2, cache) {
19900 var queue = [
19901 n2
19902 ];
19903 while(queue.length){
19904 var next = queue.pop();
19905 if (cache.has(next)) continue;
19906 cache.add(next);
19907 index.childNodes(next).forEach(function(n22) {
19908 return queue.push(n22);
19909 });
19910 }
19911 return;
19912 }
19913 function isParentRemoved(removes, n2, mirror2) {
19914 if (removes.size === 0) return false;
19915 return _isParentRemoved(removes, n2);
19916 }
19917 function _isParentRemoved(removes, n2, _mirror2) {
19918 var node2 = index.parentNode(n2);
19919 if (!node2) return false;
19920 return removes.has(node2);
19921 }
19922 function isAncestorInSet(set, n2) {
19923 if (set.size === 0) return false;
19924 return _isAncestorInSet(set, n2);
19925 }
19926 function _isAncestorInSet(set, n2) {
19927 var parent = index.parentNode(n2);
19928 if (!parent) {
19929 return false;
19930 }
19931 if (set.has(parent)) {
19932 return true;
19933 }
19934 return _isAncestorInSet(set, parent);
19935 }
19936 var errorHandler;
19937 function registerErrorHandler(handler) {
19938 errorHandler = handler;
19939 }
19940 function unregisterErrorHandler() {
19941 errorHandler = void 0;
19942 }
19943 var callbackWrapper = function(cb) {
19944 if (!errorHandler) {
19945 return cb;
19946 }
19947 var rrwebWrapped = function() {
19948 for(var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++){
19949 rest[_key] = arguments[_key];
19950 }
19951 try {
19952 return cb.apply(void 0, [].concat(rest));
19953 } catch (error) {
19954 if (errorHandler && errorHandler(error) === true) {
19955 return;
19956 }
19957 throw error;
19958 }
19959 };
19960 return rrwebWrapped;
19961 };
19962 var mutationBuffers = [];
19963 function getEventTarget(event) {
19964 try {
19965 if ("composedPath" in event) {
19966 var path = event.composedPath();
19967 if (path.length) {
19968 return path[0];
19969 }
19970 } else if ("path" in event && event.path.length) {
19971 return event.path[0];
19972 }
19973 } catch (e) {}
19974 return event && event.target;
19975 }
19976 function initMutationObserver(options, rootEl) {
19977 var mutationBuffer = new MutationBuffer();
19978 mutationBuffers.push(mutationBuffer);
19979 mutationBuffer.init(options);
19980 var observer = new (mutationObserverCtor())(callbackWrapper(mutationBuffer.processMutations.bind(mutationBuffer)));
19981 observer.observe(rootEl, {
19982 attributes: true,
19983 attributeOldValue: true,
19984 characterData: true,
19985 characterDataOldValue: true,
19986 childList: true,
19987 subtree: true
19988 });
19989 return observer;
19990 }
19991 function initMoveObserver(param) {
19992 var mousemoveCb = param.mousemoveCb, sampling = param.sampling, doc = param.doc, mirror2 = param.mirror;
19993 if (sampling.mousemove === false) {
19994 return function() {};
19995 }
19996 var threshold = typeof sampling.mousemove === "number" ? sampling.mousemove : 50;
19997 var callbackThreshold = typeof sampling.mousemoveCallback === "number" ? sampling.mousemoveCallback : 500;
19998 var positions = [];
19999 var timeBaseline;
20000 var wrappedCb = throttle(callbackWrapper(function(source) {
20001 var totalOffset = Date.now() - timeBaseline;
20002 mousemoveCb(positions.map(function(p) {
20003 p.timeOffset -= totalOffset;
20004 return p;
20005 }), source);
20006 positions = [];
20007 timeBaseline = null;
20008 }), callbackThreshold);
20009 var updatePosition = callbackWrapper(throttle(callbackWrapper(function(evt) {
20010 var target = getEventTarget(evt);
20011 var _ref = legacy_isTouchEvent(evt) ? evt.changedTouches[0] : evt, clientX = _ref.clientX, clientY = _ref.clientY;
20012 if (!timeBaseline) {
20013 timeBaseline = nowTimestamp();
20014 }
20015 positions.push({
20016 x: clientX,
20017 y: clientY,
20018 id: mirror2.getId(target),
20019 timeOffset: nowTimestamp() - timeBaseline
20020 });
20021 wrappedCb(typeof DragEvent !== "undefined" && _instanceof(evt, DragEvent) ? IncrementalSource.Drag : _instanceof(evt, MouseEvent) ? IncrementalSource.MouseMove : IncrementalSource.TouchMove);
20022 }), threshold, {
20023 trailing: false
20024 }));
20025 var handlers = [
20026 on("mousemove", updatePosition, doc),
20027 on("touchmove", updatePosition, doc),
20028 on("drag", updatePosition, doc)
20029 ];
20030 return callbackWrapper(function() {
20031 handlers.forEach(function(h) {
20032 return h();
20033 });
20034 });
20035 }
20036 function initMouseInteractionObserver(param) {
20037 var mouseInteractionCb = param.mouseInteractionCb, doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, sampling = param.sampling;
20038 if (sampling.mouseInteraction === false) {
20039 return function() {};
20040 }
20041 var disableMap = sampling.mouseInteraction === true || sampling.mouseInteraction === void 0 ? {} : sampling.mouseInteraction;
20042 var handlers = [];
20043 var currentPointerType = null;
20044 var getHandler = function(eventKey) {
20045 return function(event) {
20046 var target = getEventTarget(event);
20047 if (isBlocked(target, blockClass, blockSelector, true)) {
20048 return;
20049 }
20050 var pointerType = null;
20051 var thisEventKey = eventKey;
20052 if ("pointerType" in event) {
20053 switch(event.pointerType){
20054 case "mouse":
20055 pointerType = PointerTypes.Mouse;
20056 break;
20057 case "touch":
20058 pointerType = PointerTypes.Touch;
20059 break;
20060 case "pen":
20061 pointerType = PointerTypes.Pen;
20062 break;
20063 }
20064 if (pointerType === PointerTypes.Touch) {
20065 if (MouseInteractions[eventKey] === MouseInteractions.MouseDown) {
20066 thisEventKey = "TouchStart";
20067 } else if (MouseInteractions[eventKey] === MouseInteractions.MouseUp) {
20068 thisEventKey = "TouchEnd";
20069 }
20070 } else if (pointerType === PointerTypes.Pen) ;
20071 } else if (legacy_isTouchEvent(event)) {
20072 pointerType = PointerTypes.Touch;
20073 }
20074 if (pointerType !== null) {
20075 currentPointerType = pointerType;
20076 if (thisEventKey.startsWith("Touch") && pointerType === PointerTypes.Touch || thisEventKey.startsWith("Mouse") && pointerType === PointerTypes.Mouse) {
20077 pointerType = null;
20078 }
20079 } else if (MouseInteractions[eventKey] === MouseInteractions.Click) {
20080 pointerType = currentPointerType;
20081 currentPointerType = null;
20082 }
20083 var e2 = legacy_isTouchEvent(event) ? event.changedTouches[0] : event;
20084 if (!e2) {
20085 return;
20086 }
20087 var id = mirror2.getId(target);
20088 var clientX = e2.clientX, clientY = e2.clientY;
20089 callbackWrapper(mouseInteractionCb)(_extends({
20090 type: MouseInteractions[thisEventKey],
20091 id: id,
20092 x: clientX,
20093 y: clientY
20094 }, pointerType !== null && {
20095 pointerType: pointerType
20096 }));
20097 };
20098 };
20099 Object.keys(MouseInteractions).filter(function(key) {
20100 return Number.isNaN(Number(key)) && !key.endsWith("_Departed") && disableMap[key] !== false;
20101 }).forEach(function(eventKey) {
20102 var eventName = toLowerCase(eventKey);
20103 var handler = getHandler(eventKey);
20104 if (window.PointerEvent) {
20105 switch(MouseInteractions[eventKey]){
20106 case MouseInteractions.MouseDown:
20107 case MouseInteractions.MouseUp:
20108 eventName = eventName.replace("mouse", "pointer");
20109 break;
20110 case MouseInteractions.TouchStart:
20111 case MouseInteractions.TouchEnd:
20112 return;
20113 }
20114 }
20115 handlers.push(on(eventName, handler, doc));
20116 });
20117 return callbackWrapper(function() {
20118 handlers.forEach(function(h) {
20119 return h();
20120 });
20121 });
20122 }
20123 function initScrollObserver(param) {
20124 var scrollCb = param.scrollCb, doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, sampling = param.sampling;
20125 var updatePosition = callbackWrapper(throttle(callbackWrapper(function(evt) {
20126 var target = getEventTarget(evt);
20127 if (!target || isBlocked(target, blockClass, blockSelector, true)) {
20128 return;
20129 }
20130 var id = mirror2.getId(target);
20131 if (target === doc && doc.defaultView) {
20132 var scrollLeftTop = getWindowScroll(doc.defaultView);
20133 scrollCb({
20134 id: id,
20135 x: scrollLeftTop.left,
20136 y: scrollLeftTop.top
20137 });
20138 } else {
20139 scrollCb({
20140 id: id,
20141 x: target.scrollLeft,
20142 y: target.scrollTop
20143 });
20144 }
20145 }), sampling.scroll || 100));
20146 return on("scroll", updatePosition, doc);
20147 }
20148 function initViewportResizeObserver(param, param1) {
20149 var viewportResizeCb = param.viewportResizeCb;
20150 var win = param1.win;
20151 var lastH = -1;
20152 var lastW = -1;
20153 var updateDimension = callbackWrapper(throttle(callbackWrapper(function() {
20154 var height = getWindowHeight();
20155 var width = getWindowWidth();
20156 if (lastH !== height || lastW !== width) {
20157 viewportResizeCb({
20158 width: Number(width),
20159 height: Number(height)
20160 });
20161 lastH = height;
20162 lastW = width;
20163 }
20164 }), 200));
20165 return on("resize", updateDimension, win);
20166 }
20167 var INPUT_TAGS = [
20168 "INPUT",
20169 "TEXTAREA",
20170 "SELECT"
20171 ];
20172 var lastInputValueMap = /* @__PURE__ */ new WeakMap();
20173 function initInputObserver(param) {
20174 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;
20175 function eventHandler(event) {
20176 var target = getEventTarget(event);
20177 var userTriggered = event.isTrusted;
20178 var tagName = target && target.tagName;
20179 if (target && tagName === "OPTION") {
20180 target = index.parentElement(target);
20181 }
20182 if (!target || !tagName || INPUT_TAGS.indexOf(tagName) < 0 || isBlocked(target, blockClass, blockSelector, true)) {
20183 return;
20184 }
20185 if (target.classList.contains(ignoreClass) || ignoreSelector && target.matches(ignoreSelector)) {
20186 return;
20187 }
20188 var text = target.value;
20189 var isChecked = false;
20190 var type = getInputType(target) || "";
20191 if (type === "radio" || type === "checkbox") {
20192 isChecked = target.checked;
20193 } else if (maskInputOptions[tagName.toLowerCase()] || maskInputOptions[type]) {
20194 text = maskInputValue({
20195 element: target,
20196 maskInputOptions: maskInputOptions,
20197 tagName: tagName,
20198 type: type,
20199 value: text,
20200 maskInputFn: maskInputFn
20201 });
20202 }
20203 cbWithDedup(target, userTriggeredOnInput ? {
20204 text: text,
20205 isChecked: isChecked,
20206 userTriggered: userTriggered
20207 } : {
20208 text: text,
20209 isChecked: isChecked
20210 });
20211 var name = target.name;
20212 if (type === "radio" && name && isChecked) {
20213 doc.querySelectorAll('input[type="radio"][name="' + name + '"]').forEach(function(el) {
20214 if (el !== target) {
20215 var text2 = el.value;
20216 cbWithDedup(el, userTriggeredOnInput ? {
20217 text: text2,
20218 isChecked: !isChecked,
20219 userTriggered: false
20220 } : {
20221 text: text2,
20222 isChecked: !isChecked
20223 });
20224 }
20225 });
20226 }
20227 }
20228 function cbWithDedup(target, v2) {
20229 var lastInputValue = lastInputValueMap.get(target);
20230 if (!lastInputValue || lastInputValue.text !== v2.text || lastInputValue.isChecked !== v2.isChecked) {
20231 lastInputValueMap.set(target, v2);
20232 var id = mirror2.getId(target);
20233 callbackWrapper(inputCb)(_extends({}, v2, {
20234 id: id
20235 }));
20236 }
20237 }
20238 var events = sampling.input === "last" ? [
20239 "change"
20240 ] : [
20241 "input",
20242 "change"
20243 ];
20244 var handlers = events.map(function(eventName) {
20245 return on(eventName, callbackWrapper(eventHandler), doc);
20246 });
20247 var currentWindow = doc.defaultView;
20248 if (!currentWindow) {
20249 return function() {
20250 handlers.forEach(function(h) {
20251 return h();
20252 });
20253 };
20254 }
20255 var propertyDescriptor = currentWindow.Object.getOwnPropertyDescriptor(currentWindow.HTMLInputElement.prototype, "value");
20256 var hookProperties = [
20257 [
20258 currentWindow.HTMLInputElement.prototype,
20259 "value"
20260 ],
20261 [
20262 currentWindow.HTMLInputElement.prototype,
20263 "checked"
20264 ],
20265 [
20266 currentWindow.HTMLSelectElement.prototype,
20267 "value"
20268 ],
20269 [
20270 currentWindow.HTMLTextAreaElement.prototype,
20271 "value"
20272 ],
20273 // Some UI library use selectedIndex to set select value
20274 [
20275 currentWindow.HTMLSelectElement.prototype,
20276 "selectedIndex"
20277 ],
20278 [
20279 currentWindow.HTMLOptionElement.prototype,
20280 "selected"
20281 ]
20282 ];
20283 if (propertyDescriptor && propertyDescriptor.set) {
20284 var _handlers;
20285 (_handlers = handlers).push.apply(_handlers, [].concat(hookProperties.map(function(p) {
20286 return hookSetter(p[0], p[1], {
20287 set: function set() {
20288 callbackWrapper(eventHandler)({
20289 target: this,
20290 isTrusted: false
20291 });
20292 }
20293 }, false, currentWindow);
20294 })));
20295 }
20296 return callbackWrapper(function() {
20297 handlers.forEach(function(h) {
20298 return h();
20299 });
20300 });
20301 }
20302 function getNestedCSSRulePositions(rule2) {
20303 var positions = [];
20304 function recurse(childRule, pos) {
20305 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)) {
20306 var rules2 = Array.from(childRule.parentRule.cssRules);
20307 var index2 = rules2.indexOf(childRule);
20308 pos.unshift(index2);
20309 } else if (childRule.parentStyleSheet) {
20310 var rules21 = Array.from(childRule.parentStyleSheet.cssRules);
20311 var index21 = rules21.indexOf(childRule);
20312 pos.unshift(index21);
20313 }
20314 return pos;
20315 }
20316 return recurse(rule2, positions);
20317 }
20318 function getIdAndStyleId(sheet, mirror2, styleMirror) {
20319 var id, styleId;
20320 if (!sheet) return {};
20321 if (sheet.ownerNode) id = mirror2.getId(sheet.ownerNode);
20322 else styleId = styleMirror.getId(sheet);
20323 return {
20324 styleId: styleId,
20325 id: id
20326 };
20327 }
20328 function initStyleSheetObserver(param, param1) {
20329 var styleSheetRuleCb = param.styleSheetRuleCb, mirror2 = param.mirror, stylesheetManager = param.stylesheetManager;
20330 var win = param1.win;
20331 if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) {
20332 return function() {};
20333 }
20334 var insertRule = win.CSSStyleSheet.prototype.insertRule;
20335 win.CSSStyleSheet.prototype.insertRule = new Proxy(insertRule, {
20336 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20337 var rule2 = argumentsList[0], index2 = argumentsList[1];
20338 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20339 if (id && id !== -1 || styleId && styleId !== -1) {
20340 styleSheetRuleCb({
20341 id: id,
20342 styleId: styleId,
20343 adds: [
20344 {
20345 rule: rule2,
20346 index: index2
20347 }
20348 ]
20349 });
20350 }
20351 return target.apply(thisArg, argumentsList);
20352 })
20353 });
20354 win.CSSStyleSheet.prototype.addRule = function(selector, styleBlock, index2) {
20355 if (index2 === void 0) index2 = this.cssRules.length;
20356 var rule2 = selector + " { " + styleBlock + " }";
20357 return win.CSSStyleSheet.prototype.insertRule.apply(this, [
20358 rule2,
20359 index2
20360 ]);
20361 };
20362 var deleteRule = win.CSSStyleSheet.prototype.deleteRule;
20363 win.CSSStyleSheet.prototype.deleteRule = new Proxy(deleteRule, {
20364 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20365 var index2 = argumentsList[0];
20366 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20367 if (id && id !== -1 || styleId && styleId !== -1) {
20368 styleSheetRuleCb({
20369 id: id,
20370 styleId: styleId,
20371 removes: [
20372 {
20373 index: index2
20374 }
20375 ]
20376 });
20377 }
20378 return target.apply(thisArg, argumentsList);
20379 })
20380 });
20381 win.CSSStyleSheet.prototype.removeRule = function(index2) {
20382 return win.CSSStyleSheet.prototype.deleteRule.apply(this, [
20383 index2
20384 ]);
20385 };
20386 var replace;
20387 if (win.CSSStyleSheet.prototype.replace) {
20388 replace = win.CSSStyleSheet.prototype.replace;
20389 win.CSSStyleSheet.prototype.replace = new Proxy(replace, {
20390 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20391 var text = argumentsList[0];
20392 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20393 if (id && id !== -1 || styleId && styleId !== -1) {
20394 styleSheetRuleCb({
20395 id: id,
20396 styleId: styleId,
20397 replace: text
20398 });
20399 }
20400 return target.apply(thisArg, argumentsList);
20401 })
20402 });
20403 }
20404 var replaceSync;
20405 if (win.CSSStyleSheet.prototype.replaceSync) {
20406 replaceSync = win.CSSStyleSheet.prototype.replaceSync;
20407 win.CSSStyleSheet.prototype.replaceSync = new Proxy(replaceSync, {
20408 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20409 var text = argumentsList[0];
20410 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20411 if (id && id !== -1 || styleId && styleId !== -1) {
20412 styleSheetRuleCb({
20413 id: id,
20414 styleId: styleId,
20415 replaceSync: text
20416 });
20417 }
20418 return target.apply(thisArg, argumentsList);
20419 })
20420 });
20421 }
20422 var supportedNestedCSSRuleTypes = {};
20423 if (canMonkeyPatchNestedCSSRule("CSSGroupingRule")) {
20424 supportedNestedCSSRuleTypes.CSSGroupingRule = win.CSSGroupingRule;
20425 } else {
20426 if (canMonkeyPatchNestedCSSRule("CSSMediaRule")) {
20427 supportedNestedCSSRuleTypes.CSSMediaRule = win.CSSMediaRule;
20428 }
20429 if (canMonkeyPatchNestedCSSRule("CSSConditionRule")) {
20430 supportedNestedCSSRuleTypes.CSSConditionRule = win.CSSConditionRule;
20431 }
20432 if (canMonkeyPatchNestedCSSRule("CSSSupportsRule")) {
20433 supportedNestedCSSRuleTypes.CSSSupportsRule = win.CSSSupportsRule;
20434 }
20435 }
20436 var unmodifiedFunctions = {};
20437 Object.entries(supportedNestedCSSRuleTypes).forEach(function(param) {
20438 var typeKey = param[0], type = param[1];
20439 unmodifiedFunctions[typeKey] = {
20440 // eslint-disable-next-line @typescript-eslint/unbound-method
20441 insertRule: type.prototype.insertRule,
20442 // eslint-disable-next-line @typescript-eslint/unbound-method
20443 deleteRule: type.prototype.deleteRule
20444 };
20445 type.prototype.insertRule = new Proxy(unmodifiedFunctions[typeKey].insertRule, {
20446 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20447 var rule2 = argumentsList[0], index2 = argumentsList[1];
20448 var _getIdAndStyleId = getIdAndStyleId(thisArg.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20449 if (id && id !== -1 || styleId && styleId !== -1) {
20450 styleSheetRuleCb({
20451 id: id,
20452 styleId: styleId,
20453 adds: [
20454 {
20455 rule: rule2,
20456 index: [].concat(getNestedCSSRulePositions(thisArg), [
20457 index2 || 0
20458 ])
20459 }
20460 ]
20461 });
20462 }
20463 return target.apply(thisArg, argumentsList);
20464 })
20465 });
20466 type.prototype.deleteRule = new Proxy(unmodifiedFunctions[typeKey].deleteRule, {
20467 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20468 var index2 = argumentsList[0];
20469 var _getIdAndStyleId = getIdAndStyleId(thisArg.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20470 if (id && id !== -1 || styleId && styleId !== -1) {
20471 styleSheetRuleCb({
20472 id: id,
20473 styleId: styleId,
20474 removes: [
20475 {
20476 index: [].concat(getNestedCSSRulePositions(thisArg), [
20477 index2
20478 ])
20479 }
20480 ]
20481 });
20482 }
20483 return target.apply(thisArg, argumentsList);
20484 })
20485 });
20486 });
20487 return callbackWrapper(function() {
20488 win.CSSStyleSheet.prototype.insertRule = insertRule;
20489 win.CSSStyleSheet.prototype.deleteRule = deleteRule;
20490 replace && (win.CSSStyleSheet.prototype.replace = replace);
20491 replaceSync && (win.CSSStyleSheet.prototype.replaceSync = replaceSync);
20492 Object.entries(supportedNestedCSSRuleTypes).forEach(function(param) {
20493 var typeKey = param[0], type = param[1];
20494 type.prototype.insertRule = unmodifiedFunctions[typeKey].insertRule;
20495 type.prototype.deleteRule = unmodifiedFunctions[typeKey].deleteRule;
20496 });
20497 });
20498 }
20499 function initAdoptedStyleSheetObserver(param, host2) {
20500 var mirror2 = param.mirror, stylesheetManager = param.stylesheetManager;
20501 var _a2, _b, _c;
20502 var hostId = null;
20503 if (host2.nodeName === "#document") hostId = mirror2.getId(host2);
20504 else hostId = mirror2.getId(index.host(host2));
20505 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;
20506 var originalPropertyDescriptor = (patchTarget == null ? void 0 : patchTarget.prototype) ? Object.getOwnPropertyDescriptor(patchTarget == null ? void 0 : patchTarget.prototype, "adoptedStyleSheets") : void 0;
20507 if (hostId === null || hostId === -1 || !patchTarget || !originalPropertyDescriptor) return function() {};
20508 Object.defineProperty(host2, "adoptedStyleSheets", {
20509 configurable: originalPropertyDescriptor.configurable,
20510 enumerable: originalPropertyDescriptor.enumerable,
20511 get: function get() {
20512 var _a3;
20513 return (_a3 = originalPropertyDescriptor.get) == null ? void 0 : _a3.call(this);
20514 },
20515 set: function set(sheets) {
20516 var _a3;
20517 var result2 = (_a3 = originalPropertyDescriptor.set) == null ? void 0 : _a3.call(this, sheets);
20518 if (hostId !== null && hostId !== -1) {
20519 try {
20520 stylesheetManager.adoptStyleSheets(sheets, hostId);
20521 } catch (e2) {}
20522 }
20523 return result2;
20524 }
20525 });
20526 return callbackWrapper(function() {
20527 Object.defineProperty(host2, "adoptedStyleSheets", {
20528 configurable: originalPropertyDescriptor.configurable,
20529 enumerable: originalPropertyDescriptor.enumerable,
20530 // eslint-disable-next-line @typescript-eslint/unbound-method
20531 get: originalPropertyDescriptor.get,
20532 // eslint-disable-next-line @typescript-eslint/unbound-method
20533 set: originalPropertyDescriptor.set
20534 });
20535 });
20536 }
20537 function initStyleDeclarationObserver(param, param1) {
20538 var styleDeclarationCb = param.styleDeclarationCb, mirror2 = param.mirror, ignoreCSSAttributes = param.ignoreCSSAttributes, stylesheetManager = param.stylesheetManager;
20539 var win = param1.win;
20540 var setProperty = win.CSSStyleDeclaration.prototype.setProperty;
20541 win.CSSStyleDeclaration.prototype.setProperty = new Proxy(setProperty, {
20542 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20543 var _a2;
20544 var property = argumentsList[0], value = argumentsList[1], priority = argumentsList[2];
20545 if (ignoreCSSAttributes.has(property)) {
20546 return setProperty.apply(thisArg, [
20547 property,
20548 value,
20549 priority
20550 ]);
20551 }
20552 var _getIdAndStyleId = getIdAndStyleId((_a2 = thisArg.parentRule) == null ? void 0 : _a2.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20553 if (id && id !== -1 || styleId && styleId !== -1) {
20554 styleDeclarationCb({
20555 id: id,
20556 styleId: styleId,
20557 set: {
20558 property: property,
20559 value: value,
20560 priority: priority
20561 },
20562 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
20563 index: getNestedCSSRulePositions(thisArg.parentRule)
20564 });
20565 }
20566 return target.apply(thisArg, argumentsList);
20567 })
20568 });
20569 var removeProperty = win.CSSStyleDeclaration.prototype.removeProperty;
20570 win.CSSStyleDeclaration.prototype.removeProperty = new Proxy(removeProperty, {
20571 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20572 var _a2;
20573 var property = argumentsList[0];
20574 if (ignoreCSSAttributes.has(property)) {
20575 return removeProperty.apply(thisArg, [
20576 property
20577 ]);
20578 }
20579 var _getIdAndStyleId = getIdAndStyleId((_a2 = thisArg.parentRule) == null ? void 0 : _a2.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20580 if (id && id !== -1 || styleId && styleId !== -1) {
20581 styleDeclarationCb({
20582 id: id,
20583 styleId: styleId,
20584 remove: {
20585 property: property
20586 },
20587 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
20588 index: getNestedCSSRulePositions(thisArg.parentRule)
20589 });
20590 }
20591 return target.apply(thisArg, argumentsList);
20592 })
20593 });
20594 return callbackWrapper(function() {
20595 win.CSSStyleDeclaration.prototype.setProperty = setProperty;
20596 win.CSSStyleDeclaration.prototype.removeProperty = removeProperty;
20597 });
20598 }
20599 function initMediaInteractionObserver(param) {
20600 var mediaInteractionCb = param.mediaInteractionCb, blockClass = param.blockClass, blockSelector = param.blockSelector, mirror2 = param.mirror, sampling = param.sampling, doc = param.doc;
20601 var handler = callbackWrapper(function(type) {
20602 return throttle(callbackWrapper(function(event) {
20603 var target = getEventTarget(event);
20604 if (!target || isBlocked(target, blockClass, blockSelector, true)) {
20605 return;
20606 }
20607 var currentTime = target.currentTime, volume = target.volume, muted = target.muted, playbackRate = target.playbackRate, loop = target.loop;
20608 mediaInteractionCb({
20609 type: type,
20610 id: mirror2.getId(target),
20611 currentTime: currentTime,
20612 volume: volume,
20613 muted: muted,
20614 playbackRate: playbackRate,
20615 loop: loop
20616 });
20617 }), sampling.media || 500);
20618 });
20619 var handlers = [
20620 on("play", handler(MediaInteractions.Play), doc),
20621 on("pause", handler(MediaInteractions.Pause), doc),
20622 on("seeked", handler(MediaInteractions.Seeked), doc),
20623 on("volumechange", handler(MediaInteractions.VolumeChange), doc),
20624 on("ratechange", handler(MediaInteractions.RateChange), doc)
20625 ];
20626 return callbackWrapper(function() {
20627 handlers.forEach(function(h) {
20628 return h();
20629 });
20630 });
20631 }
20632 function initFontObserver(param) {
20633 var fontCb = param.fontCb, doc = param.doc;
20634 var win = doc.defaultView;
20635 if (!win) {
20636 return function() {};
20637 }
20638 var handlers = [];
20639 var fontMap = /* @__PURE__ */ new WeakMap();
20640 var originalFontFace = win.FontFace;
20641 win.FontFace = function FontFace2(family, source, descriptors) {
20642 var fontFace = new originalFontFace(family, source, descriptors);
20643 fontMap.set(fontFace, {
20644 family: family,
20645 buffer: typeof source !== "string",
20646 descriptors: descriptors,
20647 fontSource: typeof source === "string" ? source : JSON.stringify(Array.from(new Uint8Array(source)))
20648 });
20649 return fontFace;
20650 };
20651 var restoreHandler = patch(doc.fonts, "add", function(original) {
20652 return function(fontFace) {
20653 setTimeout(callbackWrapper(function() {
20654 var p = fontMap.get(fontFace);
20655 if (p) {
20656 fontCb(p);
20657 fontMap.delete(fontFace);
20658 }
20659 }), 0);
20660 return original.apply(this, [
20661 fontFace
20662 ]);
20663 };
20664 });
20665 handlers.push(function() {
20666 win.FontFace = originalFontFace;
20667 });
20668 handlers.push(restoreHandler);
20669 return callbackWrapper(function() {
20670 handlers.forEach(function(h) {
20671 return h();
20672 });
20673 });
20674 }
20675 function initSelectionObserver(param) {
20676 var doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, selectionCb = param.selectionCb;
20677 var collapsed = true;
20678 var updateSelection = callbackWrapper(function() {
20679 var selection = doc.getSelection();
20680 if (!selection || collapsed && (selection == null ? void 0 : selection.isCollapsed)) return;
20681 collapsed = selection.isCollapsed || false;
20682 var ranges = [];
20683 var count = selection.rangeCount || 0;
20684 for(var i2 = 0; i2 < count; i2++){
20685 var range = selection.getRangeAt(i2);
20686 var startContainer = range.startContainer, startOffset = range.startOffset, endContainer = range.endContainer, endOffset = range.endOffset;
20687 var blocked = isBlocked(startContainer, blockClass, blockSelector, true) || isBlocked(endContainer, blockClass, blockSelector, true);
20688 if (blocked) continue;
20689 ranges.push({
20690 start: mirror2.getId(startContainer),
20691 startOffset: startOffset,
20692 end: mirror2.getId(endContainer),
20693 endOffset: endOffset
20694 });
20695 }
20696 selectionCb({
20697 ranges: ranges
20698 });
20699 });
20700 updateSelection();
20701 return on("selectionchange", updateSelection);
20702 }
20703 function initCustomElementObserver(param) {
20704 var doc = param.doc, customElementCb = param.customElementCb;
20705 var win = doc.defaultView;
20706 if (!win || !win.customElements) return function() {};
20707 var restoreHandler = patch(win.customElements, "define", function(original) {
20708 return function(name, constructor, options) {
20709 try {
20710 customElementCb({
20711 define: {
20712 name: name
20713 }
20714 });
20715 } catch (e2) {
20716 console.warn("Custom element callback failed for " + name);
20717 }
20718 return original.apply(this, [
20719 name,
20720 constructor,
20721 options
20722 ]);
20723 };
20724 });
20725 return restoreHandler;
20726 }
20727 function mergeHooks(o2, hooks) {
20728 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;
20729 o2.mutationCb = function() {
20730 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20731 p[_key] = arguments[_key];
20732 }
20733 if (hooks.mutation) {
20734 var _hooks;
20735 (_hooks = hooks).mutation.apply(_hooks, [].concat(p));
20736 }
20737 mutationCb.apply(void 0, [].concat(p));
20738 };
20739 o2.mousemoveCb = function() {
20740 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20741 p[_key] = arguments[_key];
20742 }
20743 if (hooks.mousemove) {
20744 var _hooks;
20745 (_hooks = hooks).mousemove.apply(_hooks, [].concat(p));
20746 }
20747 mousemoveCb.apply(void 0, [].concat(p));
20748 };
20749 o2.mouseInteractionCb = function() {
20750 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20751 p[_key] = arguments[_key];
20752 }
20753 if (hooks.mouseInteraction) {
20754 var _hooks;
20755 (_hooks = hooks).mouseInteraction.apply(_hooks, [].concat(p));
20756 }
20757 mouseInteractionCb.apply(void 0, [].concat(p));
20758 };
20759 o2.scrollCb = function() {
20760 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20761 p[_key] = arguments[_key];
20762 }
20763 if (hooks.scroll) {
20764 var _hooks;
20765 (_hooks = hooks).scroll.apply(_hooks, [].concat(p));
20766 }
20767 scrollCb.apply(void 0, [].concat(p));
20768 };
20769 o2.viewportResizeCb = function() {
20770 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20771 p[_key] = arguments[_key];
20772 }
20773 if (hooks.viewportResize) {
20774 var _hooks;
20775 (_hooks = hooks).viewportResize.apply(_hooks, [].concat(p));
20776 }
20777 viewportResizeCb.apply(void 0, [].concat(p));
20778 };
20779 o2.inputCb = function() {
20780 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20781 p[_key] = arguments[_key];
20782 }
20783 if (hooks.input) {
20784 var _hooks;
20785 (_hooks = hooks).input.apply(_hooks, [].concat(p));
20786 }
20787 inputCb.apply(void 0, [].concat(p));
20788 };
20789 o2.mediaInteractionCb = function() {
20790 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20791 p[_key] = arguments[_key];
20792 }
20793 if (hooks.mediaInteaction) {
20794 var _hooks;
20795 (_hooks = hooks).mediaInteaction.apply(_hooks, [].concat(p));
20796 }
20797 mediaInteractionCb.apply(void 0, [].concat(p));
20798 };
20799 o2.styleSheetRuleCb = function() {
20800 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20801 p[_key] = arguments[_key];
20802 }
20803 if (hooks.styleSheetRule) {
20804 var _hooks;
20805 (_hooks = hooks).styleSheetRule.apply(_hooks, [].concat(p));
20806 }
20807 styleSheetRuleCb.apply(void 0, [].concat(p));
20808 };
20809 o2.styleDeclarationCb = function() {
20810 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20811 p[_key] = arguments[_key];
20812 }
20813 if (hooks.styleDeclaration) {
20814 var _hooks;
20815 (_hooks = hooks).styleDeclaration.apply(_hooks, [].concat(p));
20816 }
20817 styleDeclarationCb.apply(void 0, [].concat(p));
20818 };
20819 o2.canvasMutationCb = function() {
20820 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20821 p[_key] = arguments[_key];
20822 }
20823 if (hooks.canvasMutation) {
20824 var _hooks;
20825 (_hooks = hooks).canvasMutation.apply(_hooks, [].concat(p));
20826 }
20827 canvasMutationCb.apply(void 0, [].concat(p));
20828 };
20829 o2.fontCb = function() {
20830 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20831 p[_key] = arguments[_key];
20832 }
20833 if (hooks.font) {
20834 var _hooks;
20835 (_hooks = hooks).font.apply(_hooks, [].concat(p));
20836 }
20837 fontCb.apply(void 0, [].concat(p));
20838 };
20839 o2.selectionCb = function() {
20840 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20841 p[_key] = arguments[_key];
20842 }
20843 if (hooks.selection) {
20844 var _hooks;
20845 (_hooks = hooks).selection.apply(_hooks, [].concat(p));
20846 }
20847 selectionCb.apply(void 0, [].concat(p));
20848 };
20849 o2.customElementCb = function() {
20850 for(var _len = arguments.length, c2 = new Array(_len), _key = 0; _key < _len; _key++){
20851 c2[_key] = arguments[_key];
20852 }
20853 if (hooks.customElement) {
20854 var _hooks;
20855 (_hooks = hooks).customElement.apply(_hooks, [].concat(c2));
20856 }
20857 customElementCb.apply(void 0, [].concat(c2));
20858 };
20859 }
20860 function initObservers(o2, hooks) {
20861 if (hooks === void 0) hooks = {};
20862 var currentWindow = o2.doc.defaultView;
20863 if (!currentWindow) {
20864 return function() {};
20865 }
20866 mergeHooks(o2, hooks);
20867 var mutationObserver;
20868 if (o2.recordDOM) {
20869 mutationObserver = initMutationObserver(o2, o2.doc);
20870 }
20871 var mousemoveHandler = initMoveObserver(o2);
20872 var mouseInteractionHandler = initMouseInteractionObserver(o2);
20873 var scrollHandler = initScrollObserver(o2);
20874 var viewportResizeHandler = initViewportResizeObserver(o2, {
20875 win: currentWindow
20876 });
20877 var inputHandler = initInputObserver(o2);
20878 var mediaInteractionHandler = initMediaInteractionObserver(o2);
20879 var styleSheetObserver = function() {};
20880 var adoptedStyleSheetObserver = function() {};
20881 var styleDeclarationObserver = function() {};
20882 var fontObserver = function() {};
20883 if (o2.recordDOM) {
20884 styleSheetObserver = initStyleSheetObserver(o2, {
20885 win: currentWindow
20886 });
20887 adoptedStyleSheetObserver = initAdoptedStyleSheetObserver(o2, o2.doc);
20888 styleDeclarationObserver = initStyleDeclarationObserver(o2, {
20889 win: currentWindow
20890 });
20891 if (o2.collectFonts) {
20892 fontObserver = initFontObserver(o2);
20893 }
20894 }
20895 var selectionObserver = initSelectionObserver(o2);
20896 var customElementObserver = initCustomElementObserver(o2);
20897 var pluginHandlers = [];
20898 for(var _iterator = _create_for_of_iterator_helper_loose(o2.plugins), _step; !(_step = _iterator()).done;){
20899 var plugin3 = _step.value;
20900 pluginHandlers.push(plugin3.observer(plugin3.callback, currentWindow, plugin3.options));
20901 }
20902 return callbackWrapper(function() {
20903 mutationBuffers.forEach(function(b) {
20904 return b.reset();
20905 });
20906 mutationObserver == null ? void 0 : mutationObserver.disconnect();
20907 mousemoveHandler();
20908 mouseInteractionHandler();
20909 scrollHandler();
20910 viewportResizeHandler();
20911 inputHandler();
20912 mediaInteractionHandler();
20913 styleSheetObserver();
20914 adoptedStyleSheetObserver();
20915 styleDeclarationObserver();
20916 fontObserver();
20917 selectionObserver();
20918 customElementObserver();
20919 pluginHandlers.forEach(function(h) {
20920 return h();
20921 });
20922 });
20923 }
20924 function hasNestedCSSRule(prop) {
20925 return typeof window[prop] !== "undefined";
20926 }
20927 function canMonkeyPatchNestedCSSRule(prop) {
20928 return Boolean(typeof window[prop] !== "undefined" && // Note: Generally, this check _shouldn't_ be necessary
20929 // However, in some scenarios (e.g. jsdom) this can sometimes fail, so we check for it here
20930 window[prop].prototype && "insertRule" in window[prop].prototype && "deleteRule" in window[prop].prototype);
20931 }
20932 var CrossOriginIframeMirror = /*#__PURE__*/ function() {
20933 function CrossOriginIframeMirror(generateIdFn) {
20934 __publicField(this, "iframeIdToRemoteIdMap", /* @__PURE__ */ new WeakMap());
20935 __publicField(this, "iframeRemoteIdToIdMap", /* @__PURE__ */ new WeakMap());
20936 this.generateIdFn = generateIdFn;
20937 }
20938 var _proto = CrossOriginIframeMirror.prototype;
20939 _proto.getId = function getId(iframe, remoteId, idToRemoteMap, remoteToIdMap) {
20940 var idToRemoteIdMap = idToRemoteMap || this.getIdToRemoteIdMap(iframe);
20941 var remoteIdToIdMap = remoteToIdMap || this.getRemoteIdToIdMap(iframe);
20942 var id = idToRemoteIdMap.get(remoteId);
20943 if (!id) {
20944 id = this.generateIdFn();
20945 idToRemoteIdMap.set(remoteId, id);
20946 remoteIdToIdMap.set(id, remoteId);
20947 }
20948 return id;
20949 };
20950 _proto.getIds = function getIds(iframe, remoteId) {
20951 var _this = this;
20952 var idToRemoteIdMap = this.getIdToRemoteIdMap(iframe);
20953 var remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);
20954 return remoteId.map(function(id) {
20955 return _this.getId(iframe, id, idToRemoteIdMap, remoteIdToIdMap);
20956 });
20957 };
20958 _proto.getRemoteId = function getRemoteId(iframe, id, map) {
20959 var remoteIdToIdMap = map || this.getRemoteIdToIdMap(iframe);
20960 if (typeof id !== "number") return id;
20961 var remoteId = remoteIdToIdMap.get(id);
20962 if (!remoteId) return -1;
20963 return remoteId;
20964 };
20965 _proto.getRemoteIds = function getRemoteIds(iframe, ids) {
20966 var _this = this;
20967 var remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);
20968 return ids.map(function(id) {
20969 return _this.getRemoteId(iframe, id, remoteIdToIdMap);
20970 });
20971 };
20972 _proto.reset = function reset(iframe) {
20973 if (!iframe) {
20974 this.iframeIdToRemoteIdMap = /* @__PURE__ */ new WeakMap();
20975 this.iframeRemoteIdToIdMap = /* @__PURE__ */ new WeakMap();
20976 return;
20977 }
20978 this.iframeIdToRemoteIdMap.delete(iframe);
20979 this.iframeRemoteIdToIdMap.delete(iframe);
20980 };
20981 _proto.getIdToRemoteIdMap = function getIdToRemoteIdMap(iframe) {
20982 var idToRemoteIdMap = this.iframeIdToRemoteIdMap.get(iframe);
20983 if (!idToRemoteIdMap) {
20984 idToRemoteIdMap = /* @__PURE__ */ new Map();
20985 this.iframeIdToRemoteIdMap.set(iframe, idToRemoteIdMap);
20986 }
20987 return idToRemoteIdMap;
20988 };
20989 _proto.getRemoteIdToIdMap = function getRemoteIdToIdMap(iframe) {
20990 var remoteIdToIdMap = this.iframeRemoteIdToIdMap.get(iframe);
20991 if (!remoteIdToIdMap) {
20992 remoteIdToIdMap = /* @__PURE__ */ new Map();
20993 this.iframeRemoteIdToIdMap.set(iframe, remoteIdToIdMap);
20994 }
20995 return remoteIdToIdMap;
20996 };
20997 return CrossOriginIframeMirror;
20998 }();
20999 var IframeManager = /*#__PURE__*/ function() {
21000 function IframeManager(options) {
21001 __publicField(this, "iframes", /* @__PURE__ */ new WeakMap());
21002 __publicField(this, "crossOriginIframeMap", /* @__PURE__ */ new WeakMap());
21003 __publicField(this, "crossOriginIframeMirror", new CrossOriginIframeMirror(genId));
21004 __publicField(this, "crossOriginIframeStyleMirror");
21005 __publicField(this, "crossOriginIframeRootIdMap", /* @__PURE__ */ new WeakMap());
21006 __publicField(this, "mirror");
21007 __publicField(this, "mutationCb");
21008 __publicField(this, "wrappedEmit");
21009 __publicField(this, "loadListener");
21010 __publicField(this, "stylesheetManager");
21011 __publicField(this, "recordCrossOriginIframes");
21012 this.mutationCb = options.mutationCb;
21013 this.wrappedEmit = options.wrappedEmit;
21014 this.stylesheetManager = options.stylesheetManager;
21015 this.recordCrossOriginIframes = options.recordCrossOriginIframes;
21016 this.crossOriginIframeStyleMirror = new CrossOriginIframeMirror(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror));
21017 this.mirror = options.mirror;
21018 if (this.recordCrossOriginIframes) {
21019 window.addEventListener("message", this.handleMessage.bind(this));
21020 }
21021 }
21022 var _proto = IframeManager.prototype;
21023 _proto.addIframe = function addIframe(iframeEl) {
21024 this.iframes.set(iframeEl, true);
21025 if (iframeEl.contentWindow) this.crossOriginIframeMap.set(iframeEl.contentWindow, iframeEl);
21026 };
21027 _proto.addLoadListener = function addLoadListener(cb) {
21028 this.loadListener = cb;
21029 };
21030 _proto.attachIframe = function attachIframe(iframeEl, childSn) {
21031 var _a2, _b;
21032 this.mutationCb({
21033 adds: [
21034 {
21035 parentId: this.mirror.getId(iframeEl),
21036 nextId: null,
21037 node: childSn
21038 }
21039 ],
21040 removes: [],
21041 texts: [],
21042 attributes: [],
21043 isAttachIframe: true
21044 });
21045 if (this.recordCrossOriginIframes) (_a2 = iframeEl.contentWindow) == null ? void 0 : _a2.addEventListener("message", this.handleMessage.bind(this));
21046 (_b = this.loadListener) == null ? void 0 : _b.call(this, iframeEl);
21047 if (iframeEl.contentDocument && iframeEl.contentDocument.adoptedStyleSheets && iframeEl.contentDocument.adoptedStyleSheets.length > 0) this.stylesheetManager.adoptStyleSheets(iframeEl.contentDocument.adoptedStyleSheets, this.mirror.getId(iframeEl.contentDocument));
21048 };
21049 _proto.handleMessage = function handleMessage(message) {
21050 var crossOriginMessageEvent = message;
21051 if (crossOriginMessageEvent.data.type !== "rrweb" || // To filter out the rrweb messages which are forwarded by some sites.
21052 crossOriginMessageEvent.origin !== crossOriginMessageEvent.data.origin) return;
21053 var iframeSourceWindow = message.source;
21054 if (!iframeSourceWindow) return;
21055 var iframeEl = this.crossOriginIframeMap.get(message.source);
21056 if (!iframeEl) return;
21057 var transformedEvent = this.transformCrossOriginEvent(iframeEl, crossOriginMessageEvent.data.event);
21058 if (transformedEvent) this.wrappedEmit(transformedEvent, crossOriginMessageEvent.data.isCheckout);
21059 };
21060 _proto.transformCrossOriginEvent = function transformCrossOriginEvent(iframeEl, e2) {
21061 var _this = this;
21062 var _a2;
21063 switch(e2.type){
21064 case EventType.FullSnapshot:
21065 {
21066 this.crossOriginIframeMirror.reset(iframeEl);
21067 this.crossOriginIframeStyleMirror.reset(iframeEl);
21068 this.replaceIdOnNode(e2.data.node, iframeEl);
21069 var rootId = e2.data.node.id;
21070 this.crossOriginIframeRootIdMap.set(iframeEl, rootId);
21071 this.patchRootIdOnNode(e2.data.node, rootId);
21072 return {
21073 timestamp: e2.timestamp,
21074 type: EventType.IncrementalSnapshot,
21075 data: {
21076 source: IncrementalSource.Mutation,
21077 adds: [
21078 {
21079 parentId: this.mirror.getId(iframeEl),
21080 nextId: null,
21081 node: e2.data.node
21082 }
21083 ],
21084 removes: [],
21085 texts: [],
21086 attributes: [],
21087 isAttachIframe: true
21088 }
21089 };
21090 }
21091 case EventType.Meta:
21092 case EventType.Load:
21093 case EventType.DomContentLoaded:
21094 {
21095 return false;
21096 }
21097 case EventType.Plugin:
21098 {
21099 return e2;
21100 }
21101 case EventType.Custom:
21102 {
21103 this.replaceIds(e2.data.payload, iframeEl, [
21104 "id",
21105 "parentId",
21106 "previousId",
21107 "nextId"
21108 ]);
21109 return e2;
21110 }
21111 case EventType.IncrementalSnapshot:
21112 {
21113 switch(e2.data.source){
21114 case IncrementalSource.Mutation:
21115 {
21116 e2.data.adds.forEach(function(n2) {
21117 _this.replaceIds(n2, iframeEl, [
21118 "parentId",
21119 "nextId",
21120 "previousId"
21121 ]);
21122 _this.replaceIdOnNode(n2.node, iframeEl);
21123 var rootId = _this.crossOriginIframeRootIdMap.get(iframeEl);
21124 rootId && _this.patchRootIdOnNode(n2.node, rootId);
21125 });
21126 e2.data.removes.forEach(function(n2) {
21127 _this.replaceIds(n2, iframeEl, [
21128 "parentId",
21129 "id"
21130 ]);
21131 });
21132 e2.data.attributes.forEach(function(n2) {
21133 _this.replaceIds(n2, iframeEl, [
21134 "id"
21135 ]);
21136 });
21137 e2.data.texts.forEach(function(n2) {
21138 _this.replaceIds(n2, iframeEl, [
21139 "id"
21140 ]);
21141 });
21142 return e2;
21143 }
21144 case IncrementalSource.Drag:
21145 case IncrementalSource.TouchMove:
21146 case IncrementalSource.MouseMove:
21147 {
21148 e2.data.positions.forEach(function(p) {
21149 _this.replaceIds(p, iframeEl, [
21150 "id"
21151 ]);
21152 });
21153 return e2;
21154 }
21155 case IncrementalSource.ViewportResize:
21156 {
21157 return false;
21158 }
21159 case IncrementalSource.MediaInteraction:
21160 case IncrementalSource.MouseInteraction:
21161 case IncrementalSource.Scroll:
21162 case IncrementalSource.CanvasMutation:
21163 case IncrementalSource.Input:
21164 {
21165 this.replaceIds(e2.data, iframeEl, [
21166 "id"
21167 ]);
21168 return e2;
21169 }
21170 case IncrementalSource.StyleSheetRule:
21171 case IncrementalSource.StyleDeclaration:
21172 {
21173 this.replaceIds(e2.data, iframeEl, [
21174 "id"
21175 ]);
21176 this.replaceStyleIds(e2.data, iframeEl, [
21177 "styleId"
21178 ]);
21179 return e2;
21180 }
21181 case IncrementalSource.Font:
21182 {
21183 return e2;
21184 }
21185 case IncrementalSource.Selection:
21186 {
21187 e2.data.ranges.forEach(function(range) {
21188 _this.replaceIds(range, iframeEl, [
21189 "start",
21190 "end"
21191 ]);
21192 });
21193 return e2;
21194 }
21195 case IncrementalSource.AdoptedStyleSheet:
21196 {
21197 this.replaceIds(e2.data, iframeEl, [
21198 "id"
21199 ]);
21200 this.replaceStyleIds(e2.data, iframeEl, [
21201 "styleIds"
21202 ]);
21203 (_a2 = e2.data.styles) == null ? void 0 : _a2.forEach(function(style) {
21204 _this.replaceStyleIds(style, iframeEl, [
21205 "styleId"
21206 ]);
21207 });
21208 return e2;
21209 }
21210 }
21211 }
21212 }
21213 return false;
21214 };
21215 _proto.replace = function replace(iframeMirror, obj, iframeEl, keys) {
21216 for(var _iterator = _create_for_of_iterator_helper_loose(keys), _step; !(_step = _iterator()).done;){
21217 var key = _step.value;
21218 if (!Array.isArray(obj[key]) && typeof obj[key] !== "number") continue;
21219 if (Array.isArray(obj[key])) {
21220 obj[key] = iframeMirror.getIds(iframeEl, obj[key]);
21221 } else {
21222 obj[key] = iframeMirror.getId(iframeEl, obj[key]);
21223 }
21224 }
21225 return obj;
21226 };
21227 _proto.replaceIds = function replaceIds(obj, iframeEl, keys) {
21228 return this.replace(this.crossOriginIframeMirror, obj, iframeEl, keys);
21229 };
21230 _proto.replaceStyleIds = function replaceStyleIds(obj, iframeEl, keys) {
21231 return this.replace(this.crossOriginIframeStyleMirror, obj, iframeEl, keys);
21232 };
21233 _proto.replaceIdOnNode = function replaceIdOnNode(node2, iframeEl) {
21234 var _this = this;
21235 this.replaceIds(node2, iframeEl, [
21236 "id",
21237 "rootId"
21238 ]);
21239 if ("childNodes" in node2) {
21240 node2.childNodes.forEach(function(child) {
21241 _this.replaceIdOnNode(child, iframeEl);
21242 });
21243 }
21244 };
21245 _proto.patchRootIdOnNode = function patchRootIdOnNode(node2, rootId) {
21246 var _this = this;
21247 if (node2.type !== NodeType.Document && !node2.rootId) node2.rootId = rootId;
21248 if ("childNodes" in node2) {
21249 node2.childNodes.forEach(function(child) {
21250 _this.patchRootIdOnNode(child, rootId);
21251 });
21252 }
21253 };
21254 return IframeManager;
21255 }();
21256 var ShadowDomManager = /*#__PURE__*/ function() {
21257 function ShadowDomManager(options) {
21258 __publicField(this, "shadowDoms", /* @__PURE__ */ new WeakSet());
21259 __publicField(this, "mutationCb");
21260 __publicField(this, "scrollCb");
21261 __publicField(this, "bypassOptions");
21262 __publicField(this, "mirror");
21263 __publicField(this, "restoreHandlers", []);
21264 this.mutationCb = options.mutationCb;
21265 this.scrollCb = options.scrollCb;
21266 this.bypassOptions = options.bypassOptions;
21267 this.mirror = options.mirror;
21268 this.init();
21269 }
21270 var _proto = ShadowDomManager.prototype;
21271 _proto.init = function init() {
21272 this.reset();
21273 this.patchAttachShadow(Element, document);
21274 };
21275 _proto.addShadowRoot = function addShadowRoot(shadowRoot2, doc) {
21276 var _this = this;
21277 if (!isNativeShadowDom(shadowRoot2)) return;
21278 if (this.shadowDoms.has(shadowRoot2)) return;
21279 this.shadowDoms.add(shadowRoot2);
21280 var observer = initMutationObserver(_extends({}, this.bypassOptions, {
21281 doc: doc,
21282 mutationCb: this.mutationCb,
21283 mirror: this.mirror,
21284 shadowDomManager: this
21285 }), shadowRoot2);
21286 this.restoreHandlers.push(function() {
21287 return observer.disconnect();
21288 });
21289 this.restoreHandlers.push(initScrollObserver(_extends({}, this.bypassOptions, {
21290 scrollCb: this.scrollCb,
21291 // https://gist.github.com/praveenpuglia/0832da687ed5a5d7a0907046c9ef1813
21292 // scroll is not allowed to pass the boundary, so we need to listen the shadow document
21293 doc: shadowRoot2,
21294 mirror: this.mirror
21295 })));
21296 setTimeout(function() {
21297 if (shadowRoot2.adoptedStyleSheets && shadowRoot2.adoptedStyleSheets.length > 0) _this.bypassOptions.stylesheetManager.adoptStyleSheets(shadowRoot2.adoptedStyleSheets, _this.mirror.getId(index.host(shadowRoot2)));
21298 _this.restoreHandlers.push(initAdoptedStyleSheetObserver({
21299 mirror: _this.mirror,
21300 stylesheetManager: _this.bypassOptions.stylesheetManager
21301 }, shadowRoot2));
21302 }, 0);
21303 };
21304 /**
21305 * Monkey patch 'attachShadow' of an IFrameElement to observe newly added shadow doms.
21306 */ _proto.observeAttachShadow = function observeAttachShadow(iframeElement) {
21307 if (!iframeElement.contentWindow || !iframeElement.contentDocument) return;
21308 this.patchAttachShadow(iframeElement.contentWindow.Element, iframeElement.contentDocument);
21309 };
21310 /**
21311 * Patch 'attachShadow' to observe newly added shadow doms.
21312 */ _proto.patchAttachShadow = function patchAttachShadow(element, doc) {
21313 var manager = this;
21314 this.restoreHandlers.push(patch(element.prototype, "attachShadow", function(original) {
21315 return function(option) {
21316 var sRoot = original.call(this, option);
21317 var shadowRootEl = index.shadowRoot(this);
21318 if (shadowRootEl && inDom(this)) manager.addShadowRoot(shadowRootEl, doc);
21319 return sRoot;
21320 };
21321 }));
21322 };
21323 _proto.reset = function reset() {
21324 this.restoreHandlers.forEach(function(handler) {
21325 try {
21326 handler();
21327 } catch (e2) {}
21328 });
21329 this.restoreHandlers = [];
21330 this.shadowDoms = /* @__PURE__ */ new WeakSet();
21331 };
21332 return ShadowDomManager;
21333 }();
21334 var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
21335 var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
21336 for(var i$1 = 0; i$1 < chars.length; i$1++){
21337 lookup[chars.charCodeAt(i$1)] = i$1;
21338 }
21339 var encode = function encode(arraybuffer) {
21340 var bytes = new Uint8Array(arraybuffer), i2, len = bytes.length, base64 = "";
21341 for(i2 = 0; i2 < len; i2 += 3){
21342 base64 += chars[bytes[i2] >> 2];
21343 base64 += chars[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4];
21344 base64 += chars[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6];
21345 base64 += chars[bytes[i2 + 2] & 63];
21346 }
21347 if (len % 3 === 2) {
21348 base64 = base64.substring(0, base64.length - 1) + "=";
21349 } else if (len % 3 === 1) {
21350 base64 = base64.substring(0, base64.length - 2) + "==";
21351 }
21352 return base64;
21353 };
21354 var canvasVarMap = /* @__PURE__ */ new Map();
21355 function variableListFor$1(ctx, ctor) {
21356 var contextMap = canvasVarMap.get(ctx);
21357 if (!contextMap) {
21358 contextMap = /* @__PURE__ */ new Map();
21359 canvasVarMap.set(ctx, contextMap);
21360 }
21361 if (!contextMap.has(ctor)) {
21362 contextMap.set(ctor, []);
21363 }
21364 return contextMap.get(ctor);
21365 }
21366 var saveWebGLVar = function(value, win, ctx) {
21367 if (!value || !(isInstanceOfWebGLObject(value, win) || (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object")) return;
21368 var name = value.constructor.name;
21369 var list2 = variableListFor$1(ctx, name);
21370 var index2 = list2.indexOf(value);
21371 if (index2 === -1) {
21372 index2 = list2.length;
21373 list2.push(value);
21374 }
21375 return index2;
21376 };
21377 function serializeArg(value, win, ctx) {
21378 if (_instanceof(value, Array)) {
21379 return value.map(function(arg) {
21380 return serializeArg(arg, win, ctx);
21381 });
21382 } else if (value === null) {
21383 return value;
21384 } 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)) {
21385 var name = value.constructor.name;
21386 return {
21387 rr_type: name,
21388 args: [
21389 Object.values(value)
21390 ]
21391 };
21392 } else if (// SharedArrayBuffer disabled on most browsers due to spectre.
21393 // More info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/SharedArrayBuffer
21394 // value instanceof SharedArrayBuffer ||
21395 _instanceof(value, ArrayBuffer)) {
21396 var name1 = value.constructor.name;
21397 var base64 = encode(value);
21398 return {
21399 rr_type: name1,
21400 base64: base64
21401 };
21402 } else if (_instanceof(value, DataView)) {
21403 var name2 = value.constructor.name;
21404 return {
21405 rr_type: name2,
21406 args: [
21407 serializeArg(value.buffer, win, ctx),
21408 value.byteOffset,
21409 value.byteLength
21410 ]
21411 };
21412 } else if (_instanceof(value, HTMLImageElement)) {
21413 var name3 = value.constructor.name;
21414 var src = value.src;
21415 return {
21416 rr_type: name3,
21417 src: src
21418 };
21419 } else if (_instanceof(value, HTMLCanvasElement)) {
21420 var name4 = "HTMLImageElement";
21421 var src1 = value.toDataURL();
21422 return {
21423 rr_type: name4,
21424 src: src1
21425 };
21426 } else if (_instanceof(value, ImageData)) {
21427 var name5 = value.constructor.name;
21428 return {
21429 rr_type: name5,
21430 args: [
21431 serializeArg(value.data, win, ctx),
21432 value.width,
21433 value.height
21434 ]
21435 };
21436 } else if (isInstanceOfWebGLObject(value, win) || (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object") {
21437 var name6 = value.constructor.name;
21438 var index2 = saveWebGLVar(value, win, ctx);
21439 return {
21440 rr_type: name6,
21441 index: index2
21442 };
21443 }
21444 return value;
21445 }
21446 var serializeArgs = function(args, win, ctx) {
21447 return args.map(function(arg) {
21448 return serializeArg(arg, win, ctx);
21449 });
21450 };
21451 var isInstanceOfWebGLObject = function(value, win) {
21452 var webGLConstructorNames = [
21453 "WebGLActiveInfo",
21454 "WebGLBuffer",
21455 "WebGLFramebuffer",
21456 "WebGLProgram",
21457 "WebGLRenderbuffer",
21458 "WebGLShader",
21459 "WebGLShaderPrecisionFormat",
21460 "WebGLTexture",
21461 "WebGLUniformLocation",
21462 "WebGLVertexArrayObject",
21463 // In old Chrome versions, value won't be an instanceof WebGLVertexArrayObject.
21464 "WebGLVertexArrayObjectOES"
21465 ];
21466 var supportedWebGLConstructorNames = webGLConstructorNames.filter(function(name) {
21467 return typeof win[name] === "function";
21468 });
21469 return Boolean(supportedWebGLConstructorNames.find(function(name) {
21470 return _instanceof(value, win[name]);
21471 }));
21472 };
21473 function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector) {
21474 var _loop = function() {
21475 var prop = _step.value;
21476 try {
21477 if (typeof win.CanvasRenderingContext2D.prototype[prop] !== "function") {
21478 return "continue";
21479 }
21480 var restoreHandler = patch(win.CanvasRenderingContext2D.prototype, prop, function(original) {
21481 return function() {
21482 var _this = this;
21483 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
21484 args[_key] = arguments[_key];
21485 }
21486 if (!isBlocked(this.canvas, blockClass, blockSelector, true)) {
21487 setTimeout(function() {
21488 var recordArgs = serializeArgs(args, win, _this);
21489 cb(_this.canvas, {
21490 type: CanvasContext["2D"],
21491 property: prop,
21492 args: recordArgs
21493 });
21494 }, 0);
21495 }
21496 return original.apply(this, args);
21497 };
21498 });
21499 handlers.push(restoreHandler);
21500 } catch (e) {
21501 var hookHandler = hookSetter(win.CanvasRenderingContext2D.prototype, prop, {
21502 set: function set(v2) {
21503 cb(this.canvas, {
21504 type: CanvasContext["2D"],
21505 property: prop,
21506 args: [
21507 v2
21508 ],
21509 setter: true
21510 });
21511 }
21512 });
21513 handlers.push(hookHandler);
21514 }
21515 };
21516 var handlers = [];
21517 var props2D = Object.getOwnPropertyNames(win.CanvasRenderingContext2D.prototype);
21518 for(var _iterator = _create_for_of_iterator_helper_loose(props2D), _step; !(_step = _iterator()).done;)_loop();
21519 return function() {
21520 handlers.forEach(function(h) {
21521 return h();
21522 });
21523 };
21524 }
21525 function getNormalizedContextName(contextType) {
21526 return contextType === "experimental-webgl" ? "webgl" : contextType;
21527 }
21528 function initCanvasContextObserver(win, blockClass, blockSelector, setPreserveDrawingBufferToTrue) {
21529 var handlers = [];
21530 try {
21531 var restoreHandler = patch(win.HTMLCanvasElement.prototype, "getContext", function(original) {
21532 return function(contextType) {
21533 for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
21534 args[_key - 1] = arguments[_key];
21535 }
21536 if (!isBlocked(this, blockClass, blockSelector, true)) {
21537 var ctxName = getNormalizedContextName(contextType);
21538 if (!("__context" in this)) this.__context = ctxName;
21539 if (setPreserveDrawingBufferToTrue && [
21540 "webgl",
21541 "webgl2"
21542 ].includes(ctxName)) {
21543 if (args[0] && _type_of(args[0]) === "object") {
21544 var contextAttributes = args[0];
21545 if (!contextAttributes.preserveDrawingBuffer) {
21546 contextAttributes.preserveDrawingBuffer = true;
21547 }
21548 } else {
21549 args.splice(0, 1, {
21550 preserveDrawingBuffer: true
21551 });
21552 }
21553 }
21554 }
21555 return original.apply(this, [].concat([
21556 contextType
21557 ], args));
21558 };
21559 });
21560 handlers.push(restoreHandler);
21561 } catch (e) {
21562 console.error("failed to patch HTMLCanvasElement.prototype.getContext");
21563 }
21564 return function() {
21565 handlers.forEach(function(h) {
21566 return h();
21567 });
21568 };
21569 }
21570 function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
21571 var _loop = function() {
21572 var prop = _step.value;
21573 if (//prop.startsWith('get') || // e.g. getProgramParameter, but too risky
21574 [
21575 "isContextLost",
21576 "canvas",
21577 "drawingBufferWidth",
21578 "drawingBufferHeight"
21579 ].includes(prop)) {
21580 return "continue";
21581 }
21582 try {
21583 if (typeof prototype[prop] !== "function") {
21584 return "continue";
21585 }
21586 var restoreHandler = patch(prototype, prop, function(original) {
21587 return function() {
21588 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
21589 args[_key] = arguments[_key];
21590 }
21591 var result2 = original.apply(this, args);
21592 saveWebGLVar(result2, win, this);
21593 if ("tagName" in this.canvas && !isBlocked(this.canvas, blockClass, blockSelector, true)) {
21594 var recordArgs = serializeArgs(args, win, this);
21595 var mutation = {
21596 type: type,
21597 property: prop,
21598 args: recordArgs
21599 };
21600 cb(this.canvas, mutation);
21601 }
21602 return result2;
21603 };
21604 });
21605 handlers.push(restoreHandler);
21606 } catch (e) {
21607 var hookHandler = hookSetter(prototype, prop, {
21608 set: function set(v2) {
21609 cb(this.canvas, {
21610 type: type,
21611 property: prop,
21612 args: [
21613 v2
21614 ],
21615 setter: true
21616 });
21617 }
21618 });
21619 handlers.push(hookHandler);
21620 }
21621 };
21622 var handlers = [];
21623 var props = Object.getOwnPropertyNames(prototype);
21624 for(var _iterator = _create_for_of_iterator_helper_loose(props), _step; !(_step = _iterator()).done;)_loop();
21625 return handlers;
21626 }
21627 function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
21628 var _handlers;
21629 var handlers = [];
21630 (_handlers = handlers).push.apply(_handlers, [].concat(patchGLPrototype(win.WebGLRenderingContext.prototype, CanvasContext.WebGL, cb, blockClass, blockSelector, win)));
21631 if (typeof win.WebGL2RenderingContext !== "undefined") {
21632 var _handlers1;
21633 (_handlers1 = handlers).push.apply(_handlers1, [].concat(patchGLPrototype(win.WebGL2RenderingContext.prototype, CanvasContext.WebGL2, cb, blockClass, blockSelector, win)));
21634 }
21635 return function() {
21636 handlers.forEach(function(h) {
21637 return h();
21638 });
21639 };
21640 }
21641 var encodedJs = "KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=";
21642 var decodeBase64 = function(base64) {
21643 return Uint8Array.from(atob(base64), function(c2) {
21644 return c2.charCodeAt(0);
21645 });
21646 };
21647 var blob = typeof window !== "undefined" && window.Blob && new Blob([
21648 decodeBase64(encodedJs)
21649 ], {
21650 type: "text/javascript;charset=utf-8"
21651 });
21652 function WorkerWrapper(options) {
21653 var objURL;
21654 try {
21655 objURL = blob && (window.URL || window.webkitURL).createObjectURL(blob);
21656 if (!objURL) throw "";
21657 var worker = new Worker(objURL, {
21658 name: options == null ? void 0 : options.name
21659 });
21660 worker.addEventListener("error", function() {
21661 (window.URL || window.webkitURL).revokeObjectURL(objURL);
21662 });
21663 return worker;
21664 } catch (e2) {
21665 return new Worker("data:text/javascript;base64," + encodedJs, {
21666 name: options == null ? void 0 : options.name
21667 });
21668 } finally{
21669 objURL && (window.URL || window.webkitURL).revokeObjectURL(objURL);
21670 }
21671 }
21672 var CanvasManager = /*#__PURE__*/ function() {
21673 function CanvasManager(options) {
21674 var _this = this;
21675 __publicField(this, "pendingCanvasMutations", /* @__PURE__ */ new Map());
21676 __publicField(this, "rafStamps", {
21677 latestId: 0,
21678 invokeId: null
21679 });
21680 __publicField(this, "mirror");
21681 __publicField(this, "mutationCb");
21682 __publicField(this, "resetObservers");
21683 __publicField(this, "frozen", false);
21684 __publicField(this, "locked", false);
21685 __publicField(this, "processMutation", function(target, mutation) {
21686 var newFrame = _this.rafStamps.invokeId && _this.rafStamps.latestId !== _this.rafStamps.invokeId;
21687 if (newFrame || !_this.rafStamps.invokeId) _this.rafStamps.invokeId = _this.rafStamps.latestId;
21688 if (!_this.pendingCanvasMutations.has(target)) {
21689 _this.pendingCanvasMutations.set(target, []);
21690 }
21691 _this.pendingCanvasMutations.get(target).push(mutation);
21692 });
21693 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;
21694 this.mutationCb = options.mutationCb;
21695 this.mirror = options.mirror;
21696 if (recordCanvas && sampling === "all") this.initCanvasMutationObserver(win, blockClass, blockSelector);
21697 if (recordCanvas && typeof sampling === "number") this.initCanvasFPSObserver(sampling, win, blockClass, blockSelector, {
21698 dataURLOptions: dataURLOptions
21699 });
21700 }
21701 var _proto = CanvasManager.prototype;
21702 _proto.reset = function reset() {
21703 this.pendingCanvasMutations.clear();
21704 this.resetObservers && this.resetObservers();
21705 };
21706 _proto.freeze = function freeze() {
21707 this.frozen = true;
21708 };
21709 _proto.unfreeze = function unfreeze() {
21710 this.frozen = false;
21711 };
21712 _proto.lock = function lock() {
21713 this.locked = true;
21714 };
21715 _proto.unlock = function unlock() {
21716 this.locked = false;
21717 };
21718 _proto.initCanvasFPSObserver = function initCanvasFPSObserver(fps, win, blockClass, blockSelector, options) {
21719 var _this = this;
21720 var canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, true);
21721 var snapshotInProgressMap = /* @__PURE__ */ new Map();
21722 var worker = new WorkerWrapper();
21723 worker.onmessage = function(e2) {
21724 var id = e2.data.id;
21725 snapshotInProgressMap.set(id, false);
21726 if (!("base64" in e2.data)) return;
21727 var _e2_data = e2.data, base64 = _e2_data.base64, type = _e2_data.type, width = _e2_data.width, height = _e2_data.height;
21728 _this.mutationCb({
21729 id: id,
21730 type: CanvasContext["2D"],
21731 commands: [
21732 {
21733 property: "clearRect",
21734 // wipe canvas
21735 args: [
21736 0,
21737 0,
21738 width,
21739 height
21740 ]
21741 },
21742 {
21743 property: "drawImage",
21744 // draws (semi-transparent) image
21745 args: [
21746 {
21747 rr_type: "ImageBitmap",
21748 args: [
21749 {
21750 rr_type: "Blob",
21751 data: [
21752 {
21753 rr_type: "ArrayBuffer",
21754 base64: base64
21755 }
21756 ],
21757 type: type
21758 }
21759 ]
21760 },
21761 0,
21762 0
21763 ]
21764 }
21765 ]
21766 });
21767 };
21768 var timeBetweenSnapshots = 1e3 / fps;
21769 var lastSnapshotTime = 0;
21770 var rafId;
21771 var getCanvas = function() {
21772 var matchedCanvas = [];
21773 win.document.querySelectorAll("canvas").forEach(function(canvas) {
21774 if (!isBlocked(canvas, blockClass, blockSelector, true)) {
21775 matchedCanvas.push(canvas);
21776 }
21777 });
21778 return matchedCanvas;
21779 };
21780 var takeCanvasSnapshots = function(timestamp) {
21781 if (lastSnapshotTime && timestamp - lastSnapshotTime < timeBetweenSnapshots) {
21782 rafId = requestAnimationFrame(takeCanvasSnapshots);
21783 return;
21784 }
21785 lastSnapshotTime = timestamp;
21786 var _this1 = _this;
21787 getCanvas().forEach(/*#__PURE__*/ _async_to_generator(function(canvas) {
21788 var _a2, id, context, bitmap;
21789 return _ts_generator(this, function(_state) {
21790 switch(_state.label){
21791 case 0:
21792 id = _this1.mirror.getId(canvas);
21793 if (snapshotInProgressMap.get(id)) return [
21794 2
21795 ];
21796 if (canvas.width === 0 || canvas.height === 0) return [
21797 2
21798 ];
21799 snapshotInProgressMap.set(id, true);
21800 if ([
21801 "webgl",
21802 "webgl2"
21803 ].includes(canvas.__context)) {
21804 context = canvas.getContext(canvas.__context);
21805 if (((_a2 = context == null ? void 0 : context.getContextAttributes()) == null ? void 0 : _a2.preserveDrawingBuffer) === false) {
21806 context.clear(context.COLOR_BUFFER_BIT);
21807 }
21808 }
21809 return [
21810 4,
21811 createImageBitmap(canvas)
21812 ];
21813 case 1:
21814 bitmap = _state.sent();
21815 worker.postMessage({
21816 id: id,
21817 bitmap: bitmap,
21818 width: canvas.width,
21819 height: canvas.height,
21820 dataURLOptions: options.dataURLOptions
21821 }, [
21822 bitmap
21823 ]);
21824 return [
21825 2
21826 ];
21827 }
21828 });
21829 }));
21830 rafId = requestAnimationFrame(takeCanvasSnapshots);
21831 };
21832 rafId = requestAnimationFrame(takeCanvasSnapshots);
21833 this.resetObservers = function() {
21834 canvasContextReset();
21835 cancelAnimationFrame(rafId);
21836 };
21837 };
21838 _proto.initCanvasMutationObserver = function initCanvasMutationObserver(win, blockClass, blockSelector) {
21839 this.startRAFTimestamping();
21840 this.startPendingCanvasMutationFlusher();
21841 var canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, false);
21842 var canvas2DReset = initCanvas2DMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector);
21843 var canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector);
21844 this.resetObservers = function() {
21845 canvasContextReset();
21846 canvas2DReset();
21847 canvasWebGL1and2Reset();
21848 };
21849 };
21850 _proto.startPendingCanvasMutationFlusher = function startPendingCanvasMutationFlusher() {
21851 var _this = this;
21852 requestAnimationFrame(function() {
21853 return _this.flushPendingCanvasMutations();
21854 });
21855 };
21856 _proto.startRAFTimestamping = function startRAFTimestamping() {
21857 var _this = this;
21858 var setLatestRAFTimestamp = function(timestamp) {
21859 _this.rafStamps.latestId = timestamp;
21860 requestAnimationFrame(setLatestRAFTimestamp);
21861 };
21862 requestAnimationFrame(setLatestRAFTimestamp);
21863 };
21864 _proto.flushPendingCanvasMutations = function flushPendingCanvasMutations() {
21865 var _this = this;
21866 this.pendingCanvasMutations.forEach(function(_values, canvas) {
21867 var id = _this.mirror.getId(canvas);
21868 _this.flushPendingCanvasMutationFor(canvas, id);
21869 });
21870 requestAnimationFrame(function() {
21871 return _this.flushPendingCanvasMutations();
21872 });
21873 };
21874 _proto.flushPendingCanvasMutationFor = function flushPendingCanvasMutationFor(canvas, id) {
21875 if (this.frozen || this.locked) {
21876 return;
21877 }
21878 var valuesWithType = this.pendingCanvasMutations.get(canvas);
21879 if (!valuesWithType || id === -1) return;
21880 var values = valuesWithType.map(function(value) {
21881 value.type; var rest = _object_without_properties_loose(value, [
21882 "type"
21883 ]);
21884 return rest;
21885 });
21886 var type = valuesWithType[0].type;
21887 this.mutationCb({
21888 id: id,
21889 type: type,
21890 commands: values
21891 });
21892 this.pendingCanvasMutations.delete(canvas);
21893 };
21894 return CanvasManager;
21895 }();
21896 var StylesheetManager = /*#__PURE__*/ function() {
21897 function StylesheetManager(options) {
21898 __publicField(this, "trackedLinkElements", /* @__PURE__ */ new WeakSet());
21899 __publicField(this, "mutationCb");
21900 __publicField(this, "adoptedStyleSheetCb");
21901 __publicField(this, "styleMirror", new StyleSheetMirror());
21902 this.mutationCb = options.mutationCb;
21903 this.adoptedStyleSheetCb = options.adoptedStyleSheetCb;
21904 }
21905 var _proto = StylesheetManager.prototype;
21906 _proto.attachLinkElement = function attachLinkElement(linkEl, childSn) {
21907 if ("_cssText" in childSn.attributes) this.mutationCb({
21908 adds: [],
21909 removes: [],
21910 texts: [],
21911 attributes: [
21912 {
21913 id: childSn.id,
21914 attributes: childSn.attributes
21915 }
21916 ]
21917 });
21918 this.trackLinkElement(linkEl);
21919 };
21920 _proto.trackLinkElement = function trackLinkElement(linkEl) {
21921 if (this.trackedLinkElements.has(linkEl)) return;
21922 this.trackedLinkElements.add(linkEl);
21923 this.trackStylesheetInLinkElement(linkEl);
21924 };
21925 _proto.adoptStyleSheets = function adoptStyleSheets(sheets, hostId) {
21926 var _this, _loop = function() {
21927 var sheet = _step.value;
21928 var styleId = void 0;
21929 if (!_this.styleMirror.has(sheet)) {
21930 styleId = _this.styleMirror.add(sheet);
21931 styles.push({
21932 styleId: styleId,
21933 rules: Array.from(sheet.rules || CSSRule, function(r2, index2) {
21934 return {
21935 rule: stringifyRule(r2, sheet.href),
21936 index: index2
21937 };
21938 })
21939 });
21940 } else styleId = _this.styleMirror.getId(sheet);
21941 adoptedStyleSheetData.styleIds.push(styleId);
21942 };
21943 if (sheets.length === 0) return;
21944 var adoptedStyleSheetData = {
21945 id: hostId,
21946 styleIds: []
21947 };
21948 var styles = [];
21949 for(var _iterator = _create_for_of_iterator_helper_loose(sheets), _step; !(_step = _iterator()).done;)_this = this, _loop();
21950 if (styles.length > 0) adoptedStyleSheetData.styles = styles;
21951 this.adoptedStyleSheetCb(adoptedStyleSheetData);
21952 };
21953 _proto.reset = function reset() {
21954 this.styleMirror.reset();
21955 this.trackedLinkElements = /* @__PURE__ */ new WeakSet();
21956 };
21957 // TODO: take snapshot on stylesheet reload by applying event listener
21958 _proto.trackStylesheetInLinkElement = function trackStylesheetInLinkElement(_linkEl) {};
21959 return StylesheetManager;
21960 }();
21961 var ProcessedNodeManager = /*#__PURE__*/ function() {
21962 function ProcessedNodeManager() {
21963 __publicField(this, "nodeMap", /* @__PURE__ */ new WeakMap());
21964 __publicField(this, "active", false);
21965 }
21966 var _proto = ProcessedNodeManager.prototype;
21967 _proto.inOtherBuffer = function inOtherBuffer(node2, thisBuffer) {
21968 var buffers = this.nodeMap.get(node2);
21969 return buffers && Array.from(buffers).some(function(buffer) {
21970 return buffer !== thisBuffer;
21971 });
21972 };
21973 _proto.add = function add(node2, buffer) {
21974 var _this = this;
21975 if (!this.active) {
21976 this.active = true;
21977 requestAnimationFrame(function() {
21978 _this.nodeMap = /* @__PURE__ */ new WeakMap();
21979 _this.active = false;
21980 });
21981 }
21982 this.nodeMap.set(node2, (this.nodeMap.get(node2) || /* @__PURE__ */ new Set()).add(buffer));
21983 };
21984 _proto.destroy = function destroy() {};
21985 return ProcessedNodeManager;
21986 }();
21987 var wrappedEmit;
21988 var takeFullSnapshot$1;
21989 var canvasManager;
21990 var recording = false;
21991 try {
21992 if (Array.from([
21993 1
21994 ], function(x2) {
21995 return x2 * 2;
21996 })[0] !== 2) {
21997 var cleanFrame = document.createElement("iframe");
21998 document.body.appendChild(cleanFrame);
21999 Array.from = ((_a = cleanFrame.contentWindow) == null ? void 0 : _a.Array.from) || Array.from;
22000 document.body.removeChild(cleanFrame);
22001 }
22002 } catch (err) {
22003 console.debug("Unable to override Array.from", err);
22004 }
22005 var mirror = createMirror$2();
22006 function record(options) {
22007 if (options === void 0) options = {};
22008 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() {
22009 return false;
22010 } : _options_keepIframeSrcFn, _options_ignoreCSSAttributes = options.ignoreCSSAttributes, ignoreCSSAttributes = _options_ignoreCSSAttributes === void 0 ? /* @__PURE__ */ new Set([]) : _options_ignoreCSSAttributes, errorHandler2 = options.errorHandler;
22011 registerErrorHandler(errorHandler2);
22012 var inEmittingFrame = recordCrossOriginIframes ? window.parent === window : true;
22013 var passEmitsToParent = false;
22014 if (!inEmittingFrame) {
22015 try {
22016 if (window.parent.document) {
22017 passEmitsToParent = false;
22018 }
22019 } catch (e2) {
22020 passEmitsToParent = true;
22021 }
22022 }
22023 if (inEmittingFrame && !emit) {
22024 throw new Error("emit function is required");
22025 }
22026 if (!inEmittingFrame && !passEmitsToParent) {
22027 return function() {};
22028 }
22029 if (mousemoveWait !== void 0 && sampling.mousemove === void 0) {
22030 sampling.mousemove = mousemoveWait;
22031 }
22032 mirror.reset();
22033 var maskInputOptions = maskAllInputs === true ? {
22034 color: true,
22035 date: true,
22036 "datetime-local": true,
22037 email: true,
22038 month: true,
22039 number: true,
22040 range: true,
22041 search: true,
22042 tel: true,
22043 text: true,
22044 time: true,
22045 url: true,
22046 week: true,
22047 textarea: true,
22048 select: true,
22049 password: true,
22050 hidden: true
22051 } : _maskInputOptions !== void 0 ? _maskInputOptions : {
22052 password: true
22053 };
22054 var slimDOMOptions = _slimDOMOptions === true || _slimDOMOptions === "all" ? {
22055 script: true,
22056 comment: true,
22057 headFavicon: true,
22058 headWhitespace: true,
22059 headMetaSocial: true,
22060 headMetaRobots: true,
22061 headMetaHttpEquiv: true,
22062 headMetaVerification: true,
22063 // the following are off for slimDOMOptions === true,
22064 // as they destroy some (hidden) info:
22065 headMetaAuthorship: _slimDOMOptions === "all",
22066 headMetaDescKeywords: _slimDOMOptions === "all",
22067 headTitleMutations: _slimDOMOptions === "all"
22068 } : _slimDOMOptions ? _slimDOMOptions : {};
22069 polyfill$1();
22070 var lastFullSnapshotEvent;
22071 var incrementalSnapshotCount = 0;
22072 var eventProcessor = function(e2) {
22073 for(var _iterator = _create_for_of_iterator_helper_loose(plugins || []), _step; !(_step = _iterator()).done;){
22074 var plugin3 = _step.value;
22075 if (plugin3.eventProcessor) {
22076 e2 = plugin3.eventProcessor(e2);
22077 }
22078 }
22079 if (packFn && // Disable packing events which will be emitted to parent frames.
22080 !passEmitsToParent) {
22081 e2 = packFn(e2);
22082 }
22083 return e2;
22084 };
22085 wrappedEmit = function(r2, isCheckout) {
22086 var _a2;
22087 var e2 = r2;
22088 e2.timestamp = nowTimestamp();
22089 if (((_a2 = mutationBuffers[0]) == null ? void 0 : _a2.isFrozen()) && e2.type !== EventType.FullSnapshot && !(e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.Mutation)) {
22090 mutationBuffers.forEach(function(buf) {
22091 return buf.unfreeze();
22092 });
22093 }
22094 if (inEmittingFrame) {
22095 emit == null ? void 0 : emit(eventProcessor(e2), isCheckout);
22096 } else if (passEmitsToParent) {
22097 var message = {
22098 type: "rrweb",
22099 event: eventProcessor(e2),
22100 origin: window.location.origin,
22101 isCheckout: isCheckout
22102 };
22103 window.parent.postMessage(message, "*");
22104 }
22105 if (e2.type === EventType.FullSnapshot) {
22106 lastFullSnapshotEvent = e2;
22107 incrementalSnapshotCount = 0;
22108 } else if (e2.type === EventType.IncrementalSnapshot) {
22109 if (e2.data.source === IncrementalSource.Mutation && e2.data.isAttachIframe) {
22110 return;
22111 }
22112 incrementalSnapshotCount++;
22113 var exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
22114 var exceedTime = checkoutEveryNms && e2.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
22115 if (exceedCount || exceedTime) {
22116 takeFullSnapshot$1(true);
22117 }
22118 }
22119 };
22120 var wrappedMutationEmit = function(m) {
22121 wrappedEmit({
22122 type: EventType.IncrementalSnapshot,
22123 data: _extends({
22124 source: IncrementalSource.Mutation
22125 }, m)
22126 });
22127 };
22128 var wrappedScrollEmit = function(p) {
22129 return wrappedEmit({
22130 type: EventType.IncrementalSnapshot,
22131 data: _extends({
22132 source: IncrementalSource.Scroll
22133 }, p)
22134 });
22135 };
22136 var wrappedCanvasMutationEmit = function(p) {
22137 return wrappedEmit({
22138 type: EventType.IncrementalSnapshot,
22139 data: _extends({
22140 source: IncrementalSource.CanvasMutation
22141 }, p)
22142 });
22143 };
22144 var wrappedAdoptedStyleSheetEmit = function(a2) {
22145 return wrappedEmit({
22146 type: EventType.IncrementalSnapshot,
22147 data: _extends({
22148 source: IncrementalSource.AdoptedStyleSheet
22149 }, a2)
22150 });
22151 };
22152 var stylesheetManager = new StylesheetManager({
22153 mutationCb: wrappedMutationEmit,
22154 adoptedStyleSheetCb: wrappedAdoptedStyleSheetEmit
22155 });
22156 var iframeManager = new IframeManager({
22157 mirror: mirror,
22158 mutationCb: wrappedMutationEmit,
22159 stylesheetManager: stylesheetManager,
22160 recordCrossOriginIframes: recordCrossOriginIframes,
22161 wrappedEmit: wrappedEmit
22162 });
22163 for(var _iterator = _create_for_of_iterator_helper_loose(plugins || []), _step; !(_step = _iterator()).done;){
22164 var plugin3 = _step.value;
22165 if (plugin3.getMirror) plugin3.getMirror({
22166 nodeMirror: mirror,
22167 crossOriginIframeMirror: iframeManager.crossOriginIframeMirror,
22168 crossOriginIframeStyleMirror: iframeManager.crossOriginIframeStyleMirror
22169 });
22170 }
22171 var processedNodeManager = new ProcessedNodeManager();
22172 canvasManager = new CanvasManager({
22173 recordCanvas: recordCanvas,
22174 mutationCb: wrappedCanvasMutationEmit,
22175 win: window,
22176 blockClass: blockClass,
22177 blockSelector: blockSelector,
22178 mirror: mirror,
22179 sampling: sampling.canvas,
22180 dataURLOptions: dataURLOptions
22181 });
22182 var shadowDomManager = new ShadowDomManager({
22183 mutationCb: wrappedMutationEmit,
22184 scrollCb: wrappedScrollEmit,
22185 bypassOptions: {
22186 blockClass: blockClass,
22187 blockSelector: blockSelector,
22188 maskTextClass: maskTextClass,
22189 maskTextSelector: maskTextSelector,
22190 inlineStylesheet: inlineStylesheet,
22191 maskInputOptions: maskInputOptions,
22192 dataURLOptions: dataURLOptions,
22193 maskTextFn: maskTextFn,
22194 maskInputFn: maskInputFn,
22195 recordCanvas: recordCanvas,
22196 inlineImages: inlineImages,
22197 sampling: sampling,
22198 slimDOMOptions: slimDOMOptions,
22199 iframeManager: iframeManager,
22200 stylesheetManager: stylesheetManager,
22201 canvasManager: canvasManager,
22202 keepIframeSrcFn: keepIframeSrcFn,
22203 processedNodeManager: processedNodeManager
22204 },
22205 mirror: mirror
22206 });
22207 takeFullSnapshot$1 = function(isCheckout) {
22208 if (isCheckout === void 0) isCheckout = false;
22209 if (!recordDOM) {
22210 return;
22211 }
22212 wrappedEmit({
22213 type: EventType.Meta,
22214 data: {
22215 href: window.location.href,
22216 width: getWindowWidth(),
22217 height: getWindowHeight()
22218 }
22219 }, isCheckout);
22220 stylesheetManager.reset();
22221 shadowDomManager.init();
22222 mutationBuffers.forEach(function(buf) {
22223 return buf.lock();
22224 });
22225 var node2 = snapshot(document, {
22226 mirror: mirror,
22227 blockClass: blockClass,
22228 blockSelector: blockSelector,
22229 maskTextClass: maskTextClass,
22230 maskTextSelector: maskTextSelector,
22231 inlineStylesheet: inlineStylesheet,
22232 maskAllInputs: maskInputOptions,
22233 maskTextFn: maskTextFn,
22234 maskInputFn: maskInputFn,
22235 slimDOM: slimDOMOptions,
22236 dataURLOptions: dataURLOptions,
22237 recordCanvas: recordCanvas,
22238 inlineImages: inlineImages,
22239 onSerialize: function(n2) {
22240 if (isSerializedIframe(n2, mirror)) {
22241 iframeManager.addIframe(n2);
22242 }
22243 if (isSerializedStylesheet(n2, mirror)) {
22244 stylesheetManager.trackLinkElement(n2);
22245 }
22246 if (hasShadowRoot(n2)) {
22247 shadowDomManager.addShadowRoot(index.shadowRoot(n2), document);
22248 }
22249 },
22250 onIframeLoad: function(iframe, childSn) {
22251 iframeManager.attachIframe(iframe, childSn);
22252 shadowDomManager.observeAttachShadow(iframe);
22253 },
22254 onStylesheetLoad: function(linkEl, childSn) {
22255 stylesheetManager.attachLinkElement(linkEl, childSn);
22256 },
22257 keepIframeSrcFn: keepIframeSrcFn
22258 });
22259 if (!node2) {
22260 return console.warn("Failed to snapshot the document");
22261 }
22262 wrappedEmit({
22263 type: EventType.FullSnapshot,
22264 data: {
22265 node: node2,
22266 initialOffset: getWindowScroll(window)
22267 }
22268 }, isCheckout);
22269 mutationBuffers.forEach(function(buf) {
22270 return buf.unlock();
22271 });
22272 if (document.adoptedStyleSheets && document.adoptedStyleSheets.length > 0) stylesheetManager.adoptStyleSheets(document.adoptedStyleSheets, mirror.getId(document));
22273 };
22274 try {
22275 var handlers = [];
22276 var observe = function(doc) {
22277 var _a2;
22278 return callbackWrapper(initObservers)({
22279 mutationCb: wrappedMutationEmit,
22280 mousemoveCb: function(positions, source) {
22281 return wrappedEmit({
22282 type: EventType.IncrementalSnapshot,
22283 data: {
22284 source: source,
22285 positions: positions
22286 }
22287 });
22288 },
22289 mouseInteractionCb: function(d) {
22290 return wrappedEmit({
22291 type: EventType.IncrementalSnapshot,
22292 data: _extends({
22293 source: IncrementalSource.MouseInteraction
22294 }, d)
22295 });
22296 },
22297 scrollCb: wrappedScrollEmit,
22298 viewportResizeCb: function(d) {
22299 return wrappedEmit({
22300 type: EventType.IncrementalSnapshot,
22301 data: _extends({
22302 source: IncrementalSource.ViewportResize
22303 }, d)
22304 });
22305 },
22306 inputCb: function(v2) {
22307 return wrappedEmit({
22308 type: EventType.IncrementalSnapshot,
22309 data: _extends({
22310 source: IncrementalSource.Input
22311 }, v2)
22312 });
22313 },
22314 mediaInteractionCb: function(p) {
22315 return wrappedEmit({
22316 type: EventType.IncrementalSnapshot,
22317 data: _extends({
22318 source: IncrementalSource.MediaInteraction
22319 }, p)
22320 });
22321 },
22322 styleSheetRuleCb: function(r2) {
22323 return wrappedEmit({
22324 type: EventType.IncrementalSnapshot,
22325 data: _extends({
22326 source: IncrementalSource.StyleSheetRule
22327 }, r2)
22328 });
22329 },
22330 styleDeclarationCb: function(r2) {
22331 return wrappedEmit({
22332 type: EventType.IncrementalSnapshot,
22333 data: _extends({
22334 source: IncrementalSource.StyleDeclaration
22335 }, r2)
22336 });
22337 },
22338 canvasMutationCb: wrappedCanvasMutationEmit,
22339 fontCb: function(p) {
22340 return wrappedEmit({
22341 type: EventType.IncrementalSnapshot,
22342 data: _extends({
22343 source: IncrementalSource.Font
22344 }, p)
22345 });
22346 },
22347 selectionCb: function(p) {
22348 wrappedEmit({
22349 type: EventType.IncrementalSnapshot,
22350 data: _extends({
22351 source: IncrementalSource.Selection
22352 }, p)
22353 });
22354 },
22355 customElementCb: function(c2) {
22356 wrappedEmit({
22357 type: EventType.IncrementalSnapshot,
22358 data: _extends({
22359 source: IncrementalSource.CustomElement
22360 }, c2)
22361 });
22362 },
22363 blockClass: blockClass,
22364 ignoreClass: ignoreClass,
22365 ignoreSelector: ignoreSelector,
22366 maskTextClass: maskTextClass,
22367 maskTextSelector: maskTextSelector,
22368 maskInputOptions: maskInputOptions,
22369 inlineStylesheet: inlineStylesheet,
22370 sampling: sampling,
22371 recordDOM: recordDOM,
22372 recordCanvas: recordCanvas,
22373 inlineImages: inlineImages,
22374 userTriggeredOnInput: userTriggeredOnInput,
22375 collectFonts: collectFonts,
22376 doc: doc,
22377 maskInputFn: maskInputFn,
22378 maskTextFn: maskTextFn,
22379 keepIframeSrcFn: keepIframeSrcFn,
22380 blockSelector: blockSelector,
22381 slimDOMOptions: slimDOMOptions,
22382 dataURLOptions: dataURLOptions,
22383 mirror: mirror,
22384 iframeManager: iframeManager,
22385 stylesheetManager: stylesheetManager,
22386 shadowDomManager: shadowDomManager,
22387 processedNodeManager: processedNodeManager,
22388 canvasManager: canvasManager,
22389 ignoreCSSAttributes: ignoreCSSAttributes,
22390 plugins: ((_a2 = plugins == null ? void 0 : plugins.filter(function(p) {
22391 return p.observer;
22392 })) == null ? void 0 : _a2.map(function(p) {
22393 return {
22394 observer: p.observer,
22395 options: p.options,
22396 callback: function(payload) {
22397 return wrappedEmit({
22398 type: EventType.Plugin,
22399 data: {
22400 plugin: p.name,
22401 payload: payload
22402 }
22403 });
22404 }
22405 };
22406 })) || []
22407 }, hooks);
22408 };
22409 iframeManager.addLoadListener(function(iframeEl) {
22410 try {
22411 handlers.push(observe(iframeEl.contentDocument));
22412 } catch (error) {
22413 console.warn(error);
22414 }
22415 });
22416 var init = function() {
22417 takeFullSnapshot$1();
22418 handlers.push(observe(document));
22419 recording = true;
22420 };
22421 if (document.readyState === "interactive" || document.readyState === "complete") {
22422 init();
22423 } else {
22424 handlers.push(on("DOMContentLoaded", function() {
22425 wrappedEmit({
22426 type: EventType.DomContentLoaded,
22427 data: {}
22428 });
22429 if (recordAfter === "DOMContentLoaded") init();
22430 }));
22431 handlers.push(on("load", function() {
22432 wrappedEmit({
22433 type: EventType.Load,
22434 data: {}
22435 });
22436 if (recordAfter === "load") init();
22437 }, window));
22438 }
22439 return function() {
22440 handlers.forEach(function(handler) {
22441 try {
22442 handler();
22443 } catch (error) {
22444 var msg = String(error).toLowerCase();
22445 if (!msg.includes("cross-origin")) {
22446 console.warn(error);
22447 }
22448 }
22449 });
22450 processedNodeManager.destroy();
22451 recording = false;
22452 unregisterErrorHandler();
22453 };
22454 } catch (error) {
22455 console.warn(error);
22456 }
22457 }
22458 record.addCustomEvent = function(tag, payload) {
22459 if (!recording) {
22460 throw new Error("please add custom event after start recording");
22461 }
22462 wrappedEmit({
22463 type: EventType.Custom,
22464 data: {
22465 tag: tag,
22466 payload: payload
22467 }
22468 });
22469 };
22470 record.freezePage = function() {
22471 mutationBuffers.forEach(function(buf) {
22472 return buf.freeze();
22473 });
22474 };
22475 record.takeFullSnapshot = function(isCheckout) {
22476 if (!recording) {
22477 throw new Error("please take full snapshot after start recording");
22478 }
22479 takeFullSnapshot$1(isCheckout);
22480 };
22481 record.mirror = mirror;
22482 var n;
22483 !function(t2) {
22484 t2[t2.NotStarted = 0] = "NotStarted", t2[t2.Running = 1] = "Running", t2[t2.Stopped = 2] = "Stopped";
22485 }(n || (n = {}));
22486 record.addCustomEvent;
22487 record.freezePage;
22488 record.takeFullSnapshot;
22489
22490 var setImmediate = win['setImmediate'];
22491 var builtInProp, cycle, schedulingQueue,
22492 ToString = Object.prototype.toString,
22493 timer = (typeof setImmediate !== 'undefined') ?
22494 function timer(fn) { return setImmediate(fn); } :
22495 setTimeout;
22496
22497 // dammit, IE8.
22498 try {
22499 Object.defineProperty({},'x',{});
22500 builtInProp = function builtInProp(obj,name,val,config) {
22501 return Object.defineProperty(obj,name,{
22502 value: val,
22503 writable: true,
22504 configurable: config !== false
22505 });
22506 };
22507 }
22508 catch (err) {
22509 builtInProp = function builtInProp(obj,name,val) {
22510 obj[name] = val;
22511 return obj;
22512 };
22513 }
22514
22515 // Note: using a queue instead of array for efficiency
22516 schedulingQueue = (function Queue() {
22517 var first, last, item;
22518
22519 function Item(fn,self) {
22520 this.fn = fn;
22521 this.self = self;
22522 this.next = void 0;
22523 }
22524
22525 return {
22526 add: function add(fn,self) {
22527 item = new Item(fn,self);
22528 if (last) {
22529 last.next = item;
22530 }
22531 else {
22532 first = item;
22533 }
22534 last = item;
22535 item = void 0;
22536 },
22537 drain: function drain() {
22538 var f = first;
22539 first = last = cycle = void 0;
22540
22541 while (f) {
22542 f.fn.call(f.self);
22543 f = f.next;
22544 }
22545 }
22546 };
22547 })();
22548
22549 function schedule(fn,self) {
22550 schedulingQueue.add(fn,self);
22551 if (!cycle) {
22552 cycle = timer(schedulingQueue.drain);
22553 }
22554 }
22555
22556 // promise duck typing
22557 function isThenable(o) {
22558 var _then, oType = typeof o;
22559
22560 if (o !== null && (oType === 'object' || oType === 'function')) {
22561 _then = o.then;
22562 }
22563 return typeof _then === 'function' ? _then : false;
22564 }
22565
22566 function notify() {
22567 for (var i=0; i<this.chain.length; i++) {
22568 notifyIsolated(
22569 this,
22570 (this.state === 1) ? this.chain[i].success : this.chain[i].failure,
22571 this.chain[i]
22572 );
22573 }
22574 this.chain.length = 0;
22575 }
22576
22577 // NOTE: This is a separate function to isolate
22578 // the `try..catch` so that other code can be
22579 // optimized better
22580 function notifyIsolated(self,cb,chain) {
22581 var ret, _then;
22582 try {
22583 if (cb === false) {
22584 chain.reject(self.msg);
22585 }
22586 else {
22587 if (cb === true) {
22588 ret = self.msg;
22589 }
22590 else {
22591 ret = cb.call(void 0,self.msg);
22592 }
22593
22594 if (ret === chain.promise) {
22595 chain.reject(TypeError('Promise-chain cycle'));
22596 }
22597 // eslint-disable-next-line no-cond-assign
22598 else if (_then = isThenable(ret)) {
22599 _then.call(ret,chain.resolve,chain.reject);
22600 }
22601 else {
22602 chain.resolve(ret);
22603 }
22604 }
22605 }
22606 catch (err) {
22607 chain.reject(err);
22608 }
22609 }
22610
22611 function resolve(msg) {
22612 var _then, self = this;
22613
22614 // already triggered?
22615 if (self.triggered) { return; }
22616
22617 self.triggered = true;
22618
22619 // unwrap
22620 if (self.def) {
22621 self = self.def;
22622 }
22623
22624 try {
22625 // eslint-disable-next-line no-cond-assign
22626 if (_then = isThenable(msg)) {
22627 schedule(function(){
22628 var defWrapper = new MakeDefWrapper(self);
22629 try {
22630 _then.call(msg,
22631 function $resolve$(){ resolve.apply(defWrapper,arguments); },
22632 function $reject$(){ reject.apply(defWrapper,arguments); }
22633 );
22634 }
22635 catch (err) {
22636 reject.call(defWrapper,err);
22637 }
22638 });
22639 }
22640 else {
22641 self.msg = msg;
22642 self.state = 1;
22643 if (self.chain.length > 0) {
22644 schedule(notify,self);
22645 }
22646 }
22647 }
22648 catch (err) {
22649 reject.call(new MakeDefWrapper(self),err);
22650 }
22651 }
22652
22653 function reject(msg) {
22654 var self = this;
22655
22656 // already triggered?
22657 if (self.triggered) { return; }
22658
22659 self.triggered = true;
22660
22661 // unwrap
22662 if (self.def) {
22663 self = self.def;
22664 }
22665
22666 self.msg = msg;
22667 self.state = 2;
22668 if (self.chain.length > 0) {
22669 schedule(notify,self);
22670 }
22671 }
22672
22673 function iteratePromises(Constructor,arr,resolver,rejecter) {
22674 for (var idx=0; idx<arr.length; idx++) {
22675 (function IIFE(idx){
22676 Constructor.resolve(arr[idx])
22677 .then(
22678 function $resolver$(msg){
22679 resolver(idx,msg);
22680 },
22681 rejecter
22682 );
22683 })(idx);
22684 }
22685 }
22686
22687 function MakeDefWrapper(self) {
22688 this.def = self;
22689 this.triggered = false;
22690 }
22691
22692 function MakeDef(self) {
22693 this.promise = self;
22694 this.state = 0;
22695 this.triggered = false;
22696 this.chain = [];
22697 this.msg = void 0;
22698 }
22699
22700 function NpoPromise(executor) {
22701 if (typeof executor !== 'function') {
22702 throw TypeError('Not a function');
22703 }
22704
22705 if (this['__NPO__'] !== 0) {
22706 throw TypeError('Not a promise');
22707 }
22708
22709 // instance shadowing the inherited "brand"
22710 // to signal an already "initialized" promise
22711 this['__NPO__'] = 1;
22712
22713 var def = new MakeDef(this);
22714
22715 this['then'] = function then(success,failure) {
22716 var o = {
22717 success: typeof success === 'function' ? success : true,
22718 failure: typeof failure === 'function' ? failure : false
22719 };
22720 // Note: `then(..)` itself can be borrowed to be used against
22721 // a different promise constructor for making the chained promise,
22722 // by substituting a different `this` binding.
22723 o.promise = new this.constructor(function extractChain(resolve,reject) {
22724 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22725 throw TypeError('Not a function');
22726 }
22727
22728 o.resolve = resolve;
22729 o.reject = reject;
22730 });
22731 def.chain.push(o);
22732
22733 if (def.state !== 0) {
22734 schedule(notify,def);
22735 }
22736
22737 return o.promise;
22738 };
22739 this['catch'] = function $catch$(failure) {
22740 return this.then(void 0,failure);
22741 };
22742
22743 try {
22744 executor.call(
22745 void 0,
22746 function publicResolve(msg){
22747 resolve.call(def,msg);
22748 },
22749 function publicReject(msg) {
22750 reject.call(def,msg);
22751 }
22752 );
22753 }
22754 catch (err) {
22755 reject.call(def,err);
22756 }
22757 }
22758
22759 var PromisePrototype = builtInProp({},'constructor',NpoPromise,
22760 /*configurable=*/false
22761 );
22762
22763 // Note: Android 4 cannot use `Object.defineProperty(..)` here
22764 NpoPromise.prototype = PromisePrototype;
22765
22766 // built-in "brand" to signal an "uninitialized" promise
22767 builtInProp(PromisePrototype,'__NPO__',0,
22768 /*configurable=*/false
22769 );
22770
22771 builtInProp(NpoPromise,'resolve',function Promise$resolve(msg) {
22772 var Constructor = this;
22773
22774 // spec mandated checks
22775 // note: best "isPromise" check that's practical for now
22776 if (msg && typeof msg === 'object' && msg['__NPO__'] === 1) {
22777 return msg;
22778 }
22779
22780 return new Constructor(function executor(resolve,reject){
22781 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22782 throw TypeError('Not a function');
22783 }
22784
22785 resolve(msg);
22786 });
22787 });
22788
22789 builtInProp(NpoPromise,'reject',function Promise$reject(msg) {
22790 return new this(function executor(resolve,reject){
22791 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22792 throw TypeError('Not a function');
22793 }
22794
22795 reject(msg);
22796 });
22797 });
22798
22799 builtInProp(NpoPromise,'all',function Promise$all(arr) {
22800 var Constructor = this;
22801
22802 // spec mandated checks
22803 if (ToString.call(arr) !== '[object Array]') {
22804 return Constructor.reject(TypeError('Not an array'));
22805 }
22806 if (arr.length === 0) {
22807 return Constructor.resolve([]);
22808 }
22809
22810 return new Constructor(function executor(resolve,reject){
22811 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22812 throw TypeError('Not a function');
22813 }
22814
22815 var len = arr.length, msgs = Array(len), count = 0;
22816
22817 iteratePromises(Constructor,arr,function resolver(idx,msg) {
22818 msgs[idx] = msg;
22819 if (++count === len) {
22820 resolve(msgs);
22821 }
22822 },reject);
22823 });
22824 });
22825
22826 builtInProp(NpoPromise,'race',function Promise$race(arr) {
22827 var Constructor = this;
22828
22829 // spec mandated checks
22830 if (ToString.call(arr) !== '[object Array]') {
22831 return Constructor.reject(TypeError('Not an array'));
22832 }
22833
22834 return new Constructor(function executor(resolve,reject){
22835 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22836 throw TypeError('Not a function');
22837 }
22838
22839 iteratePromises(Constructor,arr,function resolver(idx,msg){
22840 resolve(msg);
22841 },reject);
22842 });
22843 });
22844
22845 var PromisePolyfill;
22846 if (typeof Promise !== 'undefined' && Promise.toString().indexOf('[native code]') !== -1) {
22847 PromisePolyfill = Promise;
22848 } else {
22849 PromisePolyfill = NpoPromise;
22850 }
22851
22852 var Config = {
22853 DEBUG: false,
22854 LIB_VERSION: '2.71.1'
22855 };
22856
22857 /* eslint camelcase: "off", eqeqeq: "off" */
22858
22859 // Maximum allowed session recording length
22860 var MAX_RECORDING_MS = 24 * 60 * 60 * 1000; // 24 hours
22861 // Maximum allowed value for minimum session recording length
22862 var MAX_VALUE_FOR_MIN_RECORDING_MS = 8 * 1000; // 8 seconds
22863
22864 /*
22865 * Saved references to long variable names, so that closure compiler can
22866 * minimize file size.
22867 */
22868
22869 var ArrayProto = Array.prototype,
22870 FuncProto = Function.prototype,
22871 ObjProto = Object.prototype,
22872 slice = ArrayProto.slice,
22873 toString = ObjProto.toString,
22874 hasOwnProperty = ObjProto.hasOwnProperty,
22875 windowConsole = win.console,
22876 navigator = win.navigator,
22877 document$1 = win.document,
22878 windowOpera = win.opera,
22879 screen = win.screen,
22880 userAgent = navigator.userAgent;
22881
22882 var nativeBind = FuncProto.bind,
22883 nativeForEach = ArrayProto.forEach,
22884 nativeIndexOf = ArrayProto.indexOf,
22885 nativeMap = ArrayProto.map,
22886 nativeIsArray = Array.isArray,
22887 breaker = {};
22888
22889 var _ = {
22890 trim: function(str) {
22891 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
22892 return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
22893 }
22894 };
22895
22896 // Console override
22897 var console$1 = {
22898 /** @type {function(...*)} */
22899 log: function() {
22900 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22901 try {
22902 windowConsole.log.apply(windowConsole, arguments);
22903 } catch (err) {
22904 _.each(arguments, function(arg) {
22905 windowConsole.log(arg);
22906 });
22907 }
22908 }
22909 },
22910 /** @type {function(...*)} */
22911 warn: function() {
22912 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22913 var args = ['Mixpanel warning:'].concat(_.toArray(arguments));
22914 try {
22915 windowConsole.warn.apply(windowConsole, args);
22916 } catch (err) {
22917 _.each(args, function(arg) {
22918 windowConsole.warn(arg);
22919 });
22920 }
22921 }
22922 },
22923 /** @type {function(...*)} */
22924 error: function() {
22925 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22926 var args = ['Mixpanel error:'].concat(_.toArray(arguments));
22927 try {
22928 windowConsole.error.apply(windowConsole, args);
22929 } catch (err) {
22930 _.each(args, function(arg) {
22931 windowConsole.error(arg);
22932 });
22933 }
22934 }
22935 },
22936 /** @type {function(...*)} */
22937 critical: function() {
22938 if (!_.isUndefined(windowConsole) && windowConsole) {
22939 var args = ['Mixpanel error:'].concat(_.toArray(arguments));
22940 try {
22941 windowConsole.error.apply(windowConsole, args);
22942 } catch (err) {
22943 _.each(args, function(arg) {
22944 windowConsole.error(arg);
22945 });
22946 }
22947 }
22948 }
22949 };
22950
22951 var log_func_with_prefix = function(func, prefix) {
22952 return function() {
22953 arguments[0] = '[' + prefix + '] ' + arguments[0];
22954 return func.apply(console$1, arguments);
22955 };
22956 };
22957 var console_with_prefix = function(prefix) {
22958 return {
22959 log: log_func_with_prefix(console$1.log, prefix),
22960 error: log_func_with_prefix(console$1.error, prefix),
22961 critical: log_func_with_prefix(console$1.critical, prefix)
22962 };
22963 };
22964
22965
22966 var safewrap = function(f) {
22967 return function() {
22968 try {
22969 return f.apply(this, arguments);
22970 } catch (e) {
22971 console$1.critical('Implementation error. Please turn on debug and contact support@mixpanel.com.');
22972 if (Config.DEBUG){
22973 console$1.critical(e);
22974 }
22975 }
22976 };
22977 };
22978
22979 var safewrapClass = function(klass) {
22980 var proto = klass.prototype;
22981 for (var func in proto) {
22982 if (typeof(proto[func]) === 'function') {
22983 proto[func] = safewrap(proto[func]);
22984 }
22985 }
22986 };
22987
22988
22989 // UNDERSCORE
22990 // Embed part of the Underscore Library
22991 _.bind = function(func, context) {
22992 var args, bound;
22993 if (nativeBind && func.bind === nativeBind) {
22994 return nativeBind.apply(func, slice.call(arguments, 1));
22995 }
22996 if (!_.isFunction(func)) {
22997 throw new TypeError();
22998 }
22999 args = slice.call(arguments, 2);
23000 bound = function() {
23001 if (!(this instanceof bound)) {
23002 return func.apply(context, args.concat(slice.call(arguments)));
23003 }
23004 var ctor = {};
23005 ctor.prototype = func.prototype;
23006 var self = new ctor();
23007 ctor.prototype = null;
23008 var result = func.apply(self, args.concat(slice.call(arguments)));
23009 if (Object(result) === result) {
23010 return result;
23011 }
23012 return self;
23013 };
23014 return bound;
23015 };
23016
23017 /**
23018 * @param {*=} obj
23019 * @param {function(...*)=} iterator
23020 * @param {Object=} context
23021 */
23022 _.each = function(obj, iterator, context) {
23023 if (obj === null || obj === undefined) {
23024 return;
23025 }
23026 if (nativeForEach && obj.forEach === nativeForEach) {
23027 obj.forEach(iterator, context);
23028 } else if (obj.length === +obj.length) {
23029 for (var i = 0, l = obj.length; i < l; i++) {
23030 if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) {
23031 return;
23032 }
23033 }
23034 } else {
23035 for (var key in obj) {
23036 if (hasOwnProperty.call(obj, key)) {
23037 if (iterator.call(context, obj[key], key, obj) === breaker) {
23038 return;
23039 }
23040 }
23041 }
23042 }
23043 };
23044
23045 _.extend = function(obj) {
23046 _.each(slice.call(arguments, 1), function(source) {
23047 for (var prop in source) {
23048 if (source[prop] !== void 0) {
23049 obj[prop] = source[prop];
23050 }
23051 }
23052 });
23053 return obj;
23054 };
23055
23056 _.isArray = nativeIsArray || function(obj) {
23057 return toString.call(obj) === '[object Array]';
23058 };
23059
23060 // from a comment on http://dbj.org/dbj/?p=286
23061 // fails on only one very rare and deliberate custom object:
23062 // var bomb = { toString : undefined, valueOf: function(o) { return "function BOMBA!"; }};
23063 _.isFunction = function(f) {
23064 try {
23065 return /^\s*\bfunction\b/.test(f);
23066 } catch (x) {
23067 return false;
23068 }
23069 };
23070
23071 _.isArguments = function(obj) {
23072 return !!(obj && hasOwnProperty.call(obj, 'callee'));
23073 };
23074
23075 _.toArray = function(iterable) {
23076 if (!iterable) {
23077 return [];
23078 }
23079 if (iterable.toArray) {
23080 return iterable.toArray();
23081 }
23082 if (_.isArray(iterable)) {
23083 return slice.call(iterable);
23084 }
23085 if (_.isArguments(iterable)) {
23086 return slice.call(iterable);
23087 }
23088 return _.values(iterable);
23089 };
23090
23091 _.map = function(arr, callback, context) {
23092 if (nativeMap && arr.map === nativeMap) {
23093 return arr.map(callback, context);
23094 } else {
23095 var results = [];
23096 _.each(arr, function(item) {
23097 results.push(callback.call(context, item));
23098 });
23099 return results;
23100 }
23101 };
23102
23103 _.keys = function(obj) {
23104 var results = [];
23105 if (obj === null) {
23106 return results;
23107 }
23108 _.each(obj, function(value, key) {
23109 results[results.length] = key;
23110 });
23111 return results;
23112 };
23113
23114 _.values = function(obj) {
23115 var results = [];
23116 if (obj === null) {
23117 return results;
23118 }
23119 _.each(obj, function(value) {
23120 results[results.length] = value;
23121 });
23122 return results;
23123 };
23124
23125 _.include = function(obj, target) {
23126 var found = false;
23127 if (obj === null) {
23128 return found;
23129 }
23130 if (nativeIndexOf && obj.indexOf === nativeIndexOf) {
23131 return obj.indexOf(target) != -1;
23132 }
23133 _.each(obj, function(value) {
23134 if (found || (found = (value === target))) {
23135 return breaker;
23136 }
23137 });
23138 return found;
23139 };
23140
23141 _.includes = function(str, needle) {
23142 return str.indexOf(needle) !== -1;
23143 };
23144
23145 // Underscore Addons
23146 _.inherit = function(subclass, superclass) {
23147 subclass.prototype = new superclass();
23148 subclass.prototype.constructor = subclass;
23149 subclass.superclass = superclass.prototype;
23150 return subclass;
23151 };
23152
23153 _.isObject = function(obj) {
23154 return (obj === Object(obj) && !_.isArray(obj));
23155 };
23156
23157 _.isEmptyObject = function(obj) {
23158 if (_.isObject(obj)) {
23159 for (var key in obj) {
23160 if (hasOwnProperty.call(obj, key)) {
23161 return false;
23162 }
23163 }
23164 return true;
23165 }
23166 return false;
23167 };
23168
23169 _.isUndefined = function(obj) {
23170 return obj === void 0;
23171 };
23172
23173 _.isString = function(obj) {
23174 return toString.call(obj) == '[object String]';
23175 };
23176
23177 _.isDate = function(obj) {
23178 return toString.call(obj) == '[object Date]';
23179 };
23180
23181 _.isNumber = function(obj) {
23182 return toString.call(obj) == '[object Number]';
23183 };
23184
23185 _.isElement = function(obj) {
23186 return !!(obj && obj.nodeType === 1);
23187 };
23188
23189 _.encodeDates = function(obj) {
23190 _.each(obj, function(v, k) {
23191 if (_.isDate(v)) {
23192 obj[k] = _.formatDate(v);
23193 } else if (_.isObject(v)) {
23194 obj[k] = _.encodeDates(v); // recurse
23195 }
23196 });
23197 return obj;
23198 };
23199
23200 _.timestamp = function() {
23201 Date.now = Date.now || function() {
23202 return +new Date;
23203 };
23204 return Date.now();
23205 };
23206
23207 _.formatDate = function(d) {
23208 // YYYY-MM-DDTHH:MM:SS in UTC
23209 function pad(n) {
23210 return n < 10 ? '0' + n : n;
23211 }
23212 return d.getUTCFullYear() + '-' +
23213 pad(d.getUTCMonth() + 1) + '-' +
23214 pad(d.getUTCDate()) + 'T' +
23215 pad(d.getUTCHours()) + ':' +
23216 pad(d.getUTCMinutes()) + ':' +
23217 pad(d.getUTCSeconds());
23218 };
23219
23220 _.strip_empty_properties = function(p) {
23221 var ret = {};
23222 _.each(p, function(v, k) {
23223 if (_.isString(v) && v.length > 0) {
23224 ret[k] = v;
23225 }
23226 });
23227 return ret;
23228 };
23229
23230 /*
23231 * this function returns a copy of object after truncating it. If
23232 * passed an Array or Object it will iterate through obj and
23233 * truncate all the values recursively.
23234 */
23235 _.truncate = function(obj, length) {
23236 var ret;
23237
23238 if (typeof(obj) === 'string') {
23239 ret = obj.slice(0, length);
23240 } else if (_.isArray(obj)) {
23241 ret = [];
23242 _.each(obj, function(val) {
23243 ret.push(_.truncate(val, length));
23244 });
23245 } else if (_.isObject(obj)) {
23246 ret = {};
23247 _.each(obj, function(val, key) {
23248 ret[key] = _.truncate(val, length);
23249 });
23250 } else {
23251 ret = obj;
23252 }
23253
23254 return ret;
23255 };
23256
23257 _.JSONEncode = (function() {
23258 return function(mixed_val) {
23259 var value = mixed_val;
23260 var quote = function(string) {
23261 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
23262 var meta = { // table of character substitutions
23263 '\b': '\\b',
23264 '\t': '\\t',
23265 '\n': '\\n',
23266 '\f': '\\f',
23267 '\r': '\\r',
23268 '"': '\\"',
23269 '\\': '\\\\'
23270 };
23271
23272 escapable.lastIndex = 0;
23273 return escapable.test(string) ?
23274 '"' + string.replace(escapable, function(a) {
23275 var c = meta[a];
23276 return typeof c === 'string' ? c :
23277 '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
23278 }) + '"' :
23279 '"' + string + '"';
23280 };
23281
23282 var str = function(key, holder) {
23283 var gap = '';
23284 var indent = ' ';
23285 var i = 0; // The loop counter.
23286 var k = ''; // The member key.
23287 var v = ''; // The member value.
23288 var length = 0;
23289 var mind = gap;
23290 var partial = [];
23291 var value = holder[key];
23292
23293 // If the value has a toJSON method, call it to obtain a replacement value.
23294 if (value && typeof value === 'object' &&
23295 typeof value.toJSON === 'function') {
23296 value = value.toJSON(key);
23297 }
23298
23299 // What happens next depends on the value's type.
23300 switch (typeof value) {
23301 case 'string':
23302 return quote(value);
23303
23304 case 'number':
23305 // JSON numbers must be finite. Encode non-finite numbers as null.
23306 return isFinite(value) ? String(value) : 'null';
23307
23308 case 'boolean':
23309 case 'null':
23310 // If the value is a boolean or null, convert it to a string. Note:
23311 // typeof null does not produce 'null'. The case is included here in
23312 // the remote chance that this gets fixed someday.
23313
23314 return String(value);
23315
23316 case 'object':
23317 // If the type is 'object', we might be dealing with an object or an array or
23318 // null.
23319 // Due to a specification blunder in ECMAScript, typeof null is 'object',
23320 // so watch out for that case.
23321 if (!value) {
23322 return 'null';
23323 }
23324
23325 // Make an array to hold the partial results of stringifying this object value.
23326 gap += indent;
23327 partial = [];
23328
23329 // Is the value an array?
23330 if (toString.apply(value) === '[object Array]') {
23331 // The value is an array. Stringify every element. Use null as a placeholder
23332 // for non-JSON values.
23333
23334 length = value.length;
23335 for (i = 0; i < length; i += 1) {
23336 partial[i] = str(i, value) || 'null';
23337 }
23338
23339 // Join all of the elements together, separated with commas, and wrap them in
23340 // brackets.
23341 v = partial.length === 0 ? '[]' :
23342 gap ? '[\n' + gap +
23343 partial.join(',\n' + gap) + '\n' +
23344 mind + ']' :
23345 '[' + partial.join(',') + ']';
23346 gap = mind;
23347 return v;
23348 }
23349
23350 // Iterate through all of the keys in the object.
23351 for (k in value) {
23352 if (hasOwnProperty.call(value, k)) {
23353 v = str(k, value);
23354 if (v) {
23355 partial.push(quote(k) + (gap ? ': ' : ':') + v);
23356 }
23357 }
23358 }
23359
23360 // Join all of the member texts together, separated with commas,
23361 // and wrap them in braces.
23362 v = partial.length === 0 ? '{}' :
23363 gap ? '{' + partial.join(',') + '' +
23364 mind + '}' : '{' + partial.join(',') + '}';
23365 gap = mind;
23366 return v;
23367 }
23368 };
23369
23370 // Make a fake root object containing our value under the key of ''.
23371 // Return the result of stringifying the value.
23372 return str('', {
23373 '': value
23374 });
23375 };
23376 })();
23377
23378 /**
23379 * From https://github.com/douglascrockford/JSON-js/blob/master/json_parse.js
23380 * Slightly modified to throw a real Error rather than a POJO
23381 */
23382 _.JSONDecode = (function() {
23383 var at, // The index of the current character
23384 ch, // The current character
23385 escapee = {
23386 '"': '"',
23387 '\\': '\\',
23388 '/': '/',
23389 'b': '\b',
23390 'f': '\f',
23391 'n': '\n',
23392 'r': '\r',
23393 't': '\t'
23394 },
23395 text,
23396 error = function(m) {
23397 var e = new SyntaxError(m);
23398 e.at = at;
23399 e.text = text;
23400 throw e;
23401 },
23402 next = function(c) {
23403 // If a c parameter is provided, verify that it matches the current character.
23404 if (c && c !== ch) {
23405 error('Expected \'' + c + '\' instead of \'' + ch + '\'');
23406 }
23407 // Get the next character. When there are no more characters,
23408 // return the empty string.
23409 ch = text.charAt(at);
23410 at += 1;
23411 return ch;
23412 },
23413 number = function() {
23414 // Parse a number value.
23415 var number,
23416 string = '';
23417
23418 if (ch === '-') {
23419 string = '-';
23420 next('-');
23421 }
23422 while (ch >= '0' && ch <= '9') {
23423 string += ch;
23424 next();
23425 }
23426 if (ch === '.') {
23427 string += '.';
23428 while (next() && ch >= '0' && ch <= '9') {
23429 string += ch;
23430 }
23431 }
23432 if (ch === 'e' || ch === 'E') {
23433 string += ch;
23434 next();
23435 if (ch === '-' || ch === '+') {
23436 string += ch;
23437 next();
23438 }
23439 while (ch >= '0' && ch <= '9') {
23440 string += ch;
23441 next();
23442 }
23443 }
23444 number = +string;
23445 if (!isFinite(number)) {
23446 error('Bad number');
23447 } else {
23448 return number;
23449 }
23450 },
23451
23452 string = function() {
23453 // Parse a string value.
23454 var hex,
23455 i,
23456 string = '',
23457 uffff;
23458 // When parsing for string values, we must look for " and \ characters.
23459 if (ch === '"') {
23460 while (next()) {
23461 if (ch === '"') {
23462 next();
23463 return string;
23464 }
23465 if (ch === '\\') {
23466 next();
23467 if (ch === 'u') {
23468 uffff = 0;
23469 for (i = 0; i < 4; i += 1) {
23470 hex = parseInt(next(), 16);
23471 if (!isFinite(hex)) {
23472 break;
23473 }
23474 uffff = uffff * 16 + hex;
23475 }
23476 string += String.fromCharCode(uffff);
23477 } else if (typeof escapee[ch] === 'string') {
23478 string += escapee[ch];
23479 } else {
23480 break;
23481 }
23482 } else {
23483 string += ch;
23484 }
23485 }
23486 }
23487 error('Bad string');
23488 },
23489 white = function() {
23490 // Skip whitespace.
23491 while (ch && ch <= ' ') {
23492 next();
23493 }
23494 },
23495 word = function() {
23496 // true, false, or null.
23497 switch (ch) {
23498 case 't':
23499 next('t');
23500 next('r');
23501 next('u');
23502 next('e');
23503 return true;
23504 case 'f':
23505 next('f');
23506 next('a');
23507 next('l');
23508 next('s');
23509 next('e');
23510 return false;
23511 case 'n':
23512 next('n');
23513 next('u');
23514 next('l');
23515 next('l');
23516 return null;
23517 }
23518 error('Unexpected "' + ch + '"');
23519 },
23520 value, // Placeholder for the value function.
23521 array = function() {
23522 // Parse an array value.
23523 var array = [];
23524
23525 if (ch === '[') {
23526 next('[');
23527 white();
23528 if (ch === ']') {
23529 next(']');
23530 return array; // empty array
23531 }
23532 while (ch) {
23533 array.push(value());
23534 white();
23535 if (ch === ']') {
23536 next(']');
23537 return array;
23538 }
23539 next(',');
23540 white();
23541 }
23542 }
23543 error('Bad array');
23544 },
23545 object = function() {
23546 // Parse an object value.
23547 var key,
23548 object = {};
23549
23550 if (ch === '{') {
23551 next('{');
23552 white();
23553 if (ch === '}') {
23554 next('}');
23555 return object; // empty object
23556 }
23557 while (ch) {
23558 key = string();
23559 white();
23560 next(':');
23561 if (Object.hasOwnProperty.call(object, key)) {
23562 error('Duplicate key "' + key + '"');
23563 }
23564 object[key] = value();
23565 white();
23566 if (ch === '}') {
23567 next('}');
23568 return object;
23569 }
23570 next(',');
23571 white();
23572 }
23573 }
23574 error('Bad object');
23575 };
23576
23577 value = function() {
23578 // Parse a JSON value. It could be an object, an array, a string,
23579 // a number, or a word.
23580 white();
23581 switch (ch) {
23582 case '{':
23583 return object();
23584 case '[':
23585 return array();
23586 case '"':
23587 return string();
23588 case '-':
23589 return number();
23590 default:
23591 return ch >= '0' && ch <= '9' ? number() : word();
23592 }
23593 };
23594
23595 // Return the json_parse function. It will have access to all of the
23596 // above functions and variables.
23597 return function(source) {
23598 var result;
23599
23600 text = source;
23601 at = 0;
23602 ch = ' ';
23603 result = value();
23604 white();
23605 if (ch) {
23606 error('Syntax error');
23607 }
23608
23609 return result;
23610 };
23611 })();
23612
23613 _.base64Encode = function(data) {
23614 var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
23615 var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
23616 ac = 0,
23617 enc = '',
23618 tmp_arr = [];
23619
23620 if (!data) {
23621 return data;
23622 }
23623
23624 data = _.utf8Encode(data);
23625
23626 do { // pack three octets into four hexets
23627 o1 = data.charCodeAt(i++);
23628 o2 = data.charCodeAt(i++);
23629 o3 = data.charCodeAt(i++);
23630
23631 bits = o1 << 16 | o2 << 8 | o3;
23632
23633 h1 = bits >> 18 & 0x3f;
23634 h2 = bits >> 12 & 0x3f;
23635 h3 = bits >> 6 & 0x3f;
23636 h4 = bits & 0x3f;
23637
23638 // use hexets to index into b64, and append result to encoded string
23639 tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
23640 } while (i < data.length);
23641
23642 enc = tmp_arr.join('');
23643
23644 switch (data.length % 3) {
23645 case 1:
23646 enc = enc.slice(0, -2) + '==';
23647 break;
23648 case 2:
23649 enc = enc.slice(0, -1) + '=';
23650 break;
23651 }
23652
23653 return enc;
23654 };
23655
23656 _.utf8Encode = function(string) {
23657 string = (string + '').replace(/\r\n/g, '\n').replace(/\r/g, '\n');
23658
23659 var utftext = '',
23660 start,
23661 end;
23662 var stringl = 0,
23663 n;
23664
23665 start = end = 0;
23666 stringl = string.length;
23667
23668 for (n = 0; n < stringl; n++) {
23669 var c1 = string.charCodeAt(n);
23670 var enc = null;
23671
23672 if (c1 < 128) {
23673 end++;
23674 } else if ((c1 > 127) && (c1 < 2048)) {
23675 enc = String.fromCharCode((c1 >> 6) | 192, (c1 & 63) | 128);
23676 } else {
23677 enc = String.fromCharCode((c1 >> 12) | 224, ((c1 >> 6) & 63) | 128, (c1 & 63) | 128);
23678 }
23679 if (enc !== null) {
23680 if (end > start) {
23681 utftext += string.substring(start, end);
23682 }
23683 utftext += enc;
23684 start = end = n + 1;
23685 }
23686 }
23687
23688 if (end > start) {
23689 utftext += string.substring(start, string.length);
23690 }
23691
23692 return utftext;
23693 };
23694
23695 _.UUID = function() {
23696 try {
23697 // use native Crypto API when available
23698 return win['crypto']['randomUUID']();
23699 } catch (err) {
23700 // fall back to generating our own UUID
23701 // based on https://gist.github.com/scwood/3bff42cc005cc20ab7ec98f0d8e1d59d
23702 var uuid = new Array(36);
23703 for (var i = 0; i < 36; i++) {
23704 uuid[i] = Math.floor(Math.random() * 16);
23705 }
23706 uuid[14] = 4; // set bits 12-15 of time-high-and-version to 0100
23707 uuid[19] = uuid[19] &= -5; // set bit 6 of clock-seq-and-reserved to zero
23708 uuid[19] = uuid[19] |= (1 << 3); // set bit 7 of clock-seq-and-reserved to one
23709 uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
23710
23711 return _.map(uuid, function(x) {
23712 return x.toString(16);
23713 }).join('');
23714 }
23715 };
23716
23717 // _.isBlockedUA()
23718 // This is to block various web spiders from executing our JS and
23719 // sending false tracking data
23720 var BLOCKED_UA_STRS = [
23721 'ahrefsbot',
23722 'ahrefssiteaudit',
23723 'amazonbot',
23724 'baiduspider',
23725 'bingbot',
23726 'bingpreview',
23727 'chrome-lighthouse',
23728 'facebookexternal',
23729 'petalbot',
23730 'pinterest',
23731 'screaming frog',
23732 'yahoo! slurp',
23733 'yandex',
23734
23735 // a whole bunch of goog-specific crawlers
23736 // https://developers.google.com/search/docs/advanced/crawling/overview-google-crawlers
23737 'adsbot-google',
23738 'apis-google',
23739 'duplexweb-google',
23740 'feedfetcher-google',
23741 'google favicon',
23742 'google web preview',
23743 'google-read-aloud',
23744 'googlebot',
23745 'googleweblight',
23746 'mediapartners-google',
23747 'storebot-google'
23748 ];
23749 _.isBlockedUA = function(ua) {
23750 var i;
23751 ua = ua.toLowerCase();
23752 for (i = 0; i < BLOCKED_UA_STRS.length; i++) {
23753 if (ua.indexOf(BLOCKED_UA_STRS[i]) !== -1) {
23754 return true;
23755 }
23756 }
23757 return false;
23758 };
23759
23760 /**
23761 * @param {Object=} formdata
23762 * @param {string=} arg_separator
23763 */
23764 _.HTTPBuildQuery = function(formdata, arg_separator) {
23765 var use_val, use_key, tmp_arr = [];
23766
23767 if (_.isUndefined(arg_separator)) {
23768 arg_separator = '&';
23769 }
23770
23771 _.each(formdata, function(val, key) {
23772 use_val = encodeURIComponent(val.toString());
23773 use_key = encodeURIComponent(key);
23774 tmp_arr[tmp_arr.length] = use_key + '=' + use_val;
23775 });
23776
23777 return tmp_arr.join(arg_separator);
23778 };
23779
23780 _.getQueryParam = function(url, param) {
23781 // Expects a raw URL
23782
23783 param = param.replace(/[[]/g, '\\[').replace(/[\]]/g, '\\]');
23784 var regexS = '[\\?&]' + param + '=([^&#]*)',
23785 regex = new RegExp(regexS),
23786 results = regex.exec(url);
23787 if (results === null || (results && typeof(results[1]) !== 'string' && results[1].length)) {
23788 return '';
23789 } else {
23790 var result = results[1];
23791 try {
23792 result = decodeURIComponent(result);
23793 } catch(err) {
23794 console$1.error('Skipping decoding for malformed query param: ' + result);
23795 }
23796 return result.replace(/\+/g, ' ');
23797 }
23798 };
23799
23800
23801 // _.cookie
23802 // Methods partially borrowed from quirksmode.org/js/cookies.html
23803 _.cookie = {
23804 get: function(name) {
23805 var nameEQ = name + '=';
23806 var ca = document$1.cookie.split(';');
23807 for (var i = 0; i < ca.length; i++) {
23808 var c = ca[i];
23809 while (c.charAt(0) == ' ') {
23810 c = c.substring(1, c.length);
23811 }
23812 if (c.indexOf(nameEQ) === 0) {
23813 return decodeURIComponent(c.substring(nameEQ.length, c.length));
23814 }
23815 }
23816 return null;
23817 },
23818
23819 parse: function(name) {
23820 var cookie;
23821 try {
23822 cookie = _.JSONDecode(_.cookie.get(name)) || {};
23823 } catch (err) {
23824 // noop
23825 }
23826 return cookie;
23827 },
23828
23829 set_seconds: function(name, value, seconds, is_cross_subdomain, is_secure, is_cross_site, domain_override) {
23830 var cdomain = '',
23831 expires = '',
23832 secure = '';
23833
23834 if (domain_override) {
23835 cdomain = '; domain=' + domain_override;
23836 } else if (is_cross_subdomain) {
23837 var domain = extract_domain(document$1.location.hostname);
23838 cdomain = domain ? '; domain=.' + domain : '';
23839 }
23840
23841 if (seconds) {
23842 var date = new Date();
23843 date.setTime(date.getTime() + (seconds * 1000));
23844 expires = '; expires=' + date.toGMTString();
23845 }
23846
23847 if (is_cross_site) {
23848 is_secure = true;
23849 secure = '; SameSite=None';
23850 }
23851 if (is_secure) {
23852 secure += '; secure';
23853 }
23854
23855 document$1.cookie = name + '=' + encodeURIComponent(value) + expires + '; path=/' + cdomain + secure;
23856 },
23857
23858 set: function(name, value, days, is_cross_subdomain, is_secure, is_cross_site, domain_override) {
23859 var cdomain = '', expires = '', secure = '';
23860
23861 if (domain_override) {
23862 cdomain = '; domain=' + domain_override;
23863 } else if (is_cross_subdomain) {
23864 var domain = extract_domain(document$1.location.hostname);
23865 cdomain = domain ? '; domain=.' + domain : '';
23866 }
23867
23868 if (days) {
23869 var date = new Date();
23870 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
23871 expires = '; expires=' + date.toGMTString();
23872 }
23873
23874 if (is_cross_site) {
23875 is_secure = true;
23876 secure = '; SameSite=None';
23877 }
23878 if (is_secure) {
23879 secure += '; secure';
23880 }
23881
23882 var new_cookie_val = name + '=' + encodeURIComponent(value) + expires + '; path=/' + cdomain + secure;
23883 document$1.cookie = new_cookie_val;
23884 return new_cookie_val;
23885 },
23886
23887 remove: function(name, is_cross_subdomain, domain_override) {
23888 _.cookie.set(name, '', -1, is_cross_subdomain, false, false, domain_override);
23889 }
23890 };
23891
23892 var _testStorageSupported = function (storage) {
23893 var supported = true;
23894 try {
23895 var key = '__mplss_' + cheap_guid(8),
23896 val = 'xyz';
23897 storage.setItem(key, val);
23898 if (storage.getItem(key) !== val) {
23899 supported = false;
23900 }
23901 storage.removeItem(key);
23902 } catch (err) {
23903 supported = false;
23904 }
23905 return supported;
23906 };
23907
23908 var _localStorageSupported = null;
23909 var localStorageSupported = function(storage, forceCheck) {
23910 if (_localStorageSupported !== null && !forceCheck) {
23911 return _localStorageSupported;
23912 }
23913 return _localStorageSupported = _testStorageSupported(storage || win.localStorage);
23914 };
23915
23916 var _sessionStorageSupported = null;
23917 var sessionStorageSupported = function(storage, forceCheck) {
23918 if (_sessionStorageSupported !== null && !forceCheck) {
23919 return _sessionStorageSupported;
23920 }
23921 return _sessionStorageSupported = _testStorageSupported(storage || win.sessionStorage);
23922 };
23923
23924 function _storageWrapper(storage, name, is_supported_fn) {
23925 var log_error = function(msg) {
23926 console$1.error(name + ' error: ' + msg);
23927 };
23928
23929 return {
23930 is_supported: function(forceCheck) {
23931 var supported = is_supported_fn(storage, forceCheck);
23932 if (!supported) {
23933 console$1.error(name + ' unsupported');
23934 }
23935 return supported;
23936 },
23937 error: log_error,
23938 get: function(key) {
23939 try {
23940 return storage.getItem(key);
23941 } catch (err) {
23942 log_error(err);
23943 }
23944 return null;
23945 },
23946 parse: function(key) {
23947 try {
23948 return _.JSONDecode(storage.getItem(key)) || {};
23949 } catch (err) {
23950 // noop
23951 }
23952 return null;
23953 },
23954 set: function(key, value) {
23955 try {
23956 storage.setItem(key, value);
23957 } catch (err) {
23958 log_error(err);
23959 }
23960 },
23961 remove: function(key) {
23962 try {
23963 storage.removeItem(key);
23964 } catch (err) {
23965 log_error(err);
23966 }
23967 }
23968 };
23969 }
23970
23971 _.localStorage = _storageWrapper(win.localStorage, 'localStorage', localStorageSupported);
23972 _.sessionStorage = _storageWrapper(win.sessionStorage, 'sessionStorage', sessionStorageSupported);
23973
23974 _.register_event = (function() {
23975 // written by Dean Edwards, 2005
23976 // with input from Tino Zijdel - crisp@xs4all.nl
23977 // with input from Carl Sverre - mail@carlsverre.com
23978 // with input from Mixpanel
23979 // http://dean.edwards.name/weblog/2005/10/add-event/
23980 // https://gist.github.com/1930440
23981
23982 /**
23983 * @param {Object} element
23984 * @param {string} type
23985 * @param {function(...*)} handler
23986 * @param {boolean=} oldSchool
23987 * @param {boolean=} useCapture
23988 */
23989 var register_event = function(element, type, handler, oldSchool, useCapture) {
23990 if (!element) {
23991 console$1.error('No valid element provided to register_event');
23992 return;
23993 }
23994
23995 if (element.addEventListener && !oldSchool) {
23996 element.addEventListener(type, handler, !!useCapture);
23997 } else {
23998 var ontype = 'on' + type;
23999 var old_handler = element[ontype]; // can be undefined
24000 element[ontype] = makeHandler(element, handler, old_handler);
24001 }
24002 };
24003
24004 function makeHandler(element, new_handler, old_handlers) {
24005 var handler = function(event) {
24006 event = event || fixEvent(win.event);
24007
24008 // this basically happens in firefox whenever another script
24009 // overwrites the onload callback and doesn't pass the event
24010 // object to previously defined callbacks. All the browsers
24011 // that don't define window.event implement addEventListener
24012 // so the dom_loaded handler will still be fired as usual.
24013 if (!event) {
24014 return undefined;
24015 }
24016
24017 var ret = true;
24018 var old_result, new_result;
24019
24020 if (_.isFunction(old_handlers)) {
24021 old_result = old_handlers(event);
24022 }
24023 new_result = new_handler.call(element, event);
24024
24025 if ((false === old_result) || (false === new_result)) {
24026 ret = false;
24027 }
24028
24029 return ret;
24030 };
24031
24032 return handler;
24033 }
24034
24035 function fixEvent(event) {
24036 if (event) {
24037 event.preventDefault = fixEvent.preventDefault;
24038 event.stopPropagation = fixEvent.stopPropagation;
24039 }
24040 return event;
24041 }
24042 fixEvent.preventDefault = function() {
24043 this.returnValue = false;
24044 };
24045 fixEvent.stopPropagation = function() {
24046 this.cancelBubble = true;
24047 };
24048
24049 return register_event;
24050 })();
24051
24052
24053 var TOKEN_MATCH_REGEX = new RegExp('^(\\w*)\\[(\\w+)([=~\\|\\^\\$\\*]?)=?"?([^\\]"]*)"?\\]$');
24054
24055 _.dom_query = (function() {
24056 /* document.getElementsBySelector(selector)
24057 - returns an array of element objects from the current document
24058 matching the CSS selector. Selectors can contain element names,
24059 class names and ids and can be nested. For example:
24060
24061 elements = document.getElementsBySelector('div#main p a.external')
24062
24063 Will return an array of all 'a' elements with 'external' in their
24064 class attribute that are contained inside 'p' elements that are
24065 contained inside the 'div' element which has id="main"
24066
24067 New in version 0.4: Support for CSS2 and CSS3 attribute selectors:
24068 See http://www.w3.org/TR/css3-selectors/#attribute-selectors
24069
24070 Version 0.4 - Simon Willison, March 25th 2003
24071 -- Works in Phoenix 0.5, Mozilla 1.3, Opera 7, Internet Explorer 6, Internet Explorer 5 on Windows
24072 -- Opera 7 fails
24073
24074 Version 0.5 - Carl Sverre, Jan 7th 2013
24075 -- Now uses jQuery-esque `hasClass` for testing class name
24076 equality. This fixes a bug related to '-' characters being
24077 considered not part of a 'word' in regex.
24078 */
24079
24080 function getAllChildren(e) {
24081 // Returns all children of element. Workaround required for IE5/Windows. Ugh.
24082 return e.all ? e.all : e.getElementsByTagName('*');
24083 }
24084
24085 var bad_whitespace = /[\t\r\n]/g;
24086
24087 function hasClass(elem, selector) {
24088 var className = ' ' + selector + ' ';
24089 return ((' ' + elem.className + ' ').replace(bad_whitespace, ' ').indexOf(className) >= 0);
24090 }
24091
24092 function getElementsBySelector(selector) {
24093 // Attempt to fail gracefully in lesser browsers
24094 if (!document$1.getElementsByTagName) {
24095 return [];
24096 }
24097 // Split selector in to tokens
24098 var tokens = selector.split(' ');
24099 var token, bits, tagName, found, foundCount, i, j, k, elements, currentContextIndex;
24100 var currentContext = [document$1];
24101 for (i = 0; i < tokens.length; i++) {
24102 token = tokens[i].replace(/^\s+/, '').replace(/\s+$/, '');
24103 if (token.indexOf('#') > -1) {
24104 // Token is an ID selector
24105 bits = token.split('#');
24106 tagName = bits[0];
24107 var id = bits[1];
24108 var element = document$1.getElementById(id);
24109 if (!element || (tagName && element.nodeName.toLowerCase() != tagName)) {
24110 // element not found or tag with that ID not found, return false
24111 return [];
24112 }
24113 // Set currentContext to contain just this element
24114 currentContext = [element];
24115 continue; // Skip to next token
24116 }
24117 if (token.indexOf('.') > -1) {
24118 // Token contains a class selector
24119 bits = token.split('.');
24120 tagName = bits[0];
24121 var className = bits[1];
24122 if (!tagName) {
24123 tagName = '*';
24124 }
24125 // Get elements matching tag, filter them for class selector
24126 found = [];
24127 foundCount = 0;
24128 for (j = 0; j < currentContext.length; j++) {
24129 if (tagName == '*') {
24130 elements = getAllChildren(currentContext[j]);
24131 } else {
24132 elements = currentContext[j].getElementsByTagName(tagName);
24133 }
24134 for (k = 0; k < elements.length; k++) {
24135 found[foundCount++] = elements[k];
24136 }
24137 }
24138 currentContext = [];
24139 currentContextIndex = 0;
24140 for (j = 0; j < found.length; j++) {
24141 if (found[j].className &&
24142 _.isString(found[j].className) && // some SVG elements have classNames which are not strings
24143 hasClass(found[j], className)
24144 ) {
24145 currentContext[currentContextIndex++] = found[j];
24146 }
24147 }
24148 continue; // Skip to next token
24149 }
24150 // Code to deal with attribute selectors
24151 var token_match = token.match(TOKEN_MATCH_REGEX);
24152 if (token_match) {
24153 tagName = token_match[1];
24154 var attrName = token_match[2];
24155 var attrOperator = token_match[3];
24156 var attrValue = token_match[4];
24157 if (!tagName) {
24158 tagName = '*';
24159 }
24160 // Grab all of the tagName elements within current context
24161 found = [];
24162 foundCount = 0;
24163 for (j = 0; j < currentContext.length; j++) {
24164 if (tagName == '*') {
24165 elements = getAllChildren(currentContext[j]);
24166 } else {
24167 elements = currentContext[j].getElementsByTagName(tagName);
24168 }
24169 for (k = 0; k < elements.length; k++) {
24170 found[foundCount++] = elements[k];
24171 }
24172 }
24173 currentContext = [];
24174 currentContextIndex = 0;
24175 var checkFunction; // This function will be used to filter the elements
24176 switch (attrOperator) {
24177 case '=': // Equality
24178 checkFunction = function(e) {
24179 return (e.getAttribute(attrName) == attrValue);
24180 };
24181 break;
24182 case '~': // Match one of space seperated words
24183 checkFunction = function(e) {
24184 return (e.getAttribute(attrName).match(new RegExp('\\b' + attrValue + '\\b')));
24185 };
24186 break;
24187 case '|': // Match start with value followed by optional hyphen
24188 checkFunction = function(e) {
24189 return (e.getAttribute(attrName).match(new RegExp('^' + attrValue + '-?')));
24190 };
24191 break;
24192 case '^': // Match starts with value
24193 checkFunction = function(e) {
24194 return (e.getAttribute(attrName).indexOf(attrValue) === 0);
24195 };
24196 break;
24197 case '$': // Match ends with value - fails with "Warning" in Opera 7
24198 checkFunction = function(e) {
24199 return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length);
24200 };
24201 break;
24202 case '*': // Match ends with value
24203 checkFunction = function(e) {
24204 return (e.getAttribute(attrName).indexOf(attrValue) > -1);
24205 };
24206 break;
24207 default:
24208 // Just test for existence of attribute
24209 checkFunction = function(e) {
24210 return e.getAttribute(attrName);
24211 };
24212 }
24213 currentContext = [];
24214 currentContextIndex = 0;
24215 for (j = 0; j < found.length; j++) {
24216 if (checkFunction(found[j])) {
24217 currentContext[currentContextIndex++] = found[j];
24218 }
24219 }
24220 // alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue);
24221 continue; // Skip to next token
24222 }
24223 // If we get here, token is JUST an element (not a class or ID selector)
24224 tagName = token;
24225 found = [];
24226 foundCount = 0;
24227 for (j = 0; j < currentContext.length; j++) {
24228 elements = currentContext[j].getElementsByTagName(tagName);
24229 for (k = 0; k < elements.length; k++) {
24230 found[foundCount++] = elements[k];
24231 }
24232 }
24233 currentContext = found;
24234 }
24235 return currentContext;
24236 }
24237
24238 return function(query) {
24239 if (_.isElement(query)) {
24240 return [query];
24241 } else if (_.isObject(query) && !_.isUndefined(query.length)) {
24242 return query;
24243 } else {
24244 return getElementsBySelector.call(this, query);
24245 }
24246 };
24247 })();
24248
24249 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'];
24250 var CLICK_IDS = ['dclid', 'fbclid', 'gclid', 'ko_click_id', 'li_fat_id', 'msclkid', 'sccid', 'ttclid', 'twclid', 'wbraid'];
24251
24252 _.info = {
24253 campaignParams: function(default_value) {
24254 var kw = '',
24255 params = {};
24256 _.each(CAMPAIGN_KEYWORDS, function(kwkey) {
24257 kw = _.getQueryParam(document$1.URL, kwkey);
24258 if (kw.length) {
24259 params[kwkey] = kw;
24260 } else if (default_value !== undefined) {
24261 params[kwkey] = default_value;
24262 }
24263 });
24264
24265 return params;
24266 },
24267
24268 clickParams: function() {
24269 var id = '',
24270 params = {};
24271 _.each(CLICK_IDS, function(idkey) {
24272 id = _.getQueryParam(document$1.URL, idkey);
24273 if (id.length) {
24274 params[idkey] = id;
24275 }
24276 });
24277
24278 return params;
24279 },
24280
24281 marketingParams: function() {
24282 return _.extend(_.info.campaignParams(), _.info.clickParams());
24283 },
24284
24285 searchEngine: function(referrer) {
24286 if (referrer.search('https?://(.*)google.([^/?]*)') === 0) {
24287 return 'google';
24288 } else if (referrer.search('https?://(.*)bing.com') === 0) {
24289 return 'bing';
24290 } else if (referrer.search('https?://(.*)yahoo.com') === 0) {
24291 return 'yahoo';
24292 } else if (referrer.search('https?://(.*)duckduckgo.com') === 0) {
24293 return 'duckduckgo';
24294 } else {
24295 return null;
24296 }
24297 },
24298
24299 searchInfo: function(referrer) {
24300 var search = _.info.searchEngine(referrer),
24301 param = (search != 'yahoo') ? 'q' : 'p',
24302 ret = {};
24303
24304 if (search !== null) {
24305 ret['$search_engine'] = search;
24306
24307 var keyword = _.getQueryParam(referrer, param);
24308 if (keyword.length) {
24309 ret['mp_keyword'] = keyword;
24310 }
24311 }
24312
24313 return ret;
24314 },
24315
24316 /**
24317 * This function detects which browser is running this script.
24318 * The order of the checks are important since many user agents
24319 * include key words used in later checks.
24320 */
24321 browser: function(user_agent, vendor, opera) {
24322 vendor = vendor || ''; // vendor is undefined for at least IE9
24323 if (opera || _.includes(user_agent, ' OPR/')) {
24324 if (_.includes(user_agent, 'Mini')) {
24325 return 'Opera Mini';
24326 }
24327 return 'Opera';
24328 } else if (/(BlackBerry|PlayBook|BB10)/i.test(user_agent)) {
24329 return 'BlackBerry';
24330 } else if (_.includes(user_agent, 'IEMobile') || _.includes(user_agent, 'WPDesktop')) {
24331 return 'Internet Explorer Mobile';
24332 } else if (_.includes(user_agent, 'SamsungBrowser/')) {
24333 // https://developer.samsung.com/internet/user-agent-string-format
24334 return 'Samsung Internet';
24335 } else if (_.includes(user_agent, 'Edge') || _.includes(user_agent, 'Edg/')) {
24336 return 'Microsoft Edge';
24337 } else if (_.includes(user_agent, 'FBIOS')) {
24338 return 'Facebook Mobile';
24339 } else if (_.includes(user_agent, 'Whale/')) {
24340 // https://user-agents.net/browsers/whale-browser
24341 return 'Whale Browser';
24342 } else if (_.includes(user_agent, 'Chrome')) {
24343 return 'Chrome';
24344 } else if (_.includes(user_agent, 'CriOS')) {
24345 return 'Chrome iOS';
24346 } else if (_.includes(user_agent, 'UCWEB') || _.includes(user_agent, 'UCBrowser')) {
24347 return 'UC Browser';
24348 } else if (_.includes(user_agent, 'FxiOS')) {
24349 return 'Firefox iOS';
24350 } else if (_.includes(vendor, 'Apple')) {
24351 if (_.includes(user_agent, 'Mobile')) {
24352 return 'Mobile Safari';
24353 }
24354 return 'Safari';
24355 } else if (_.includes(user_agent, 'Android')) {
24356 return 'Android Mobile';
24357 } else if (_.includes(user_agent, 'Konqueror')) {
24358 return 'Konqueror';
24359 } else if (_.includes(user_agent, 'Firefox')) {
24360 return 'Firefox';
24361 } else if (_.includes(user_agent, 'MSIE') || _.includes(user_agent, 'Trident/')) {
24362 return 'Internet Explorer';
24363 } else if (_.includes(user_agent, 'Gecko')) {
24364 return 'Mozilla';
24365 } else {
24366 return '';
24367 }
24368 },
24369
24370 /**
24371 * This function detects which browser version is running this script,
24372 * parsing major and minor version (e.g., 42.1). User agent strings from:
24373 * http://www.useragentstring.com/pages/useragentstring.php
24374 */
24375 browserVersion: function(userAgent, vendor, opera) {
24376 var browser = _.info.browser(userAgent, vendor, opera);
24377 var versionRegexs = {
24378 'Internet Explorer Mobile': /rv:(\d+(\.\d+)?)/,
24379 'Microsoft Edge': /Edge?\/(\d+(\.\d+)?)/,
24380 'Chrome': /Chrome\/(\d+(\.\d+)?)/,
24381 'Chrome iOS': /CriOS\/(\d+(\.\d+)?)/,
24382 'UC Browser' : /(UCBrowser|UCWEB)\/(\d+(\.\d+)?)/,
24383 'Safari': /Version\/(\d+(\.\d+)?)/,
24384 'Mobile Safari': /Version\/(\d+(\.\d+)?)/,
24385 'Opera': /(Opera|OPR)\/(\d+(\.\d+)?)/,
24386 'Firefox': /Firefox\/(\d+(\.\d+)?)/,
24387 'Firefox iOS': /FxiOS\/(\d+(\.\d+)?)/,
24388 'Konqueror': /Konqueror:(\d+(\.\d+)?)/,
24389 'BlackBerry': /BlackBerry (\d+(\.\d+)?)/,
24390 'Android Mobile': /android\s(\d+(\.\d+)?)/,
24391 'Samsung Internet': /SamsungBrowser\/(\d+(\.\d+)?)/,
24392 'Internet Explorer': /(rv:|MSIE )(\d+(\.\d+)?)/,
24393 'Mozilla': /rv:(\d+(\.\d+)?)/,
24394 'Whale Browser': /Whale\/(\d+(\.\d+)?)/
24395 };
24396 var regex = versionRegexs[browser];
24397 if (regex === undefined) {
24398 return null;
24399 }
24400 var matches = userAgent.match(regex);
24401 if (!matches) {
24402 return null;
24403 }
24404 return parseFloat(matches[matches.length - 2]);
24405 },
24406
24407 os: function() {
24408 var a = userAgent;
24409 if (/Windows/i.test(a)) {
24410 if (/Phone/.test(a) || /WPDesktop/.test(a)) {
24411 return 'Windows Phone';
24412 }
24413 return 'Windows';
24414 } else if (/(iPhone|iPad|iPod)/.test(a)) {
24415 return 'iOS';
24416 } else if (/Android/.test(a)) {
24417 return 'Android';
24418 } else if (/(BlackBerry|PlayBook|BB10)/i.test(a)) {
24419 return 'BlackBerry';
24420 } else if (/Mac/i.test(a)) {
24421 return 'Mac OS X';
24422 } else if (/Linux/.test(a)) {
24423 return 'Linux';
24424 } else if (/CrOS/.test(a)) {
24425 return 'Chrome OS';
24426 } else {
24427 return '';
24428 }
24429 },
24430
24431 device: function(user_agent) {
24432 if (/Windows Phone/i.test(user_agent) || /WPDesktop/.test(user_agent)) {
24433 return 'Windows Phone';
24434 } else if (/iPad/.test(user_agent)) {
24435 return 'iPad';
24436 } else if (/iPod/.test(user_agent)) {
24437 return 'iPod Touch';
24438 } else if (/iPhone/.test(user_agent)) {
24439 return 'iPhone';
24440 } else if (/(BlackBerry|PlayBook|BB10)/i.test(user_agent)) {
24441 return 'BlackBerry';
24442 } else if (/Android/.test(user_agent)) {
24443 return 'Android';
24444 } else {
24445 return '';
24446 }
24447 },
24448
24449 referringDomain: function(referrer) {
24450 var split = referrer.split('/');
24451 if (split.length >= 3) {
24452 return split[2];
24453 }
24454 return '';
24455 },
24456
24457 currentUrl: function() {
24458 return win.location.href;
24459 },
24460
24461 properties: function(extra_props) {
24462 if (typeof extra_props !== 'object') {
24463 extra_props = {};
24464 }
24465 return _.extend(_.strip_empty_properties({
24466 '$os': _.info.os(),
24467 '$browser': _.info.browser(userAgent, navigator.vendor, windowOpera),
24468 '$referrer': document$1.referrer,
24469 '$referring_domain': _.info.referringDomain(document$1.referrer),
24470 '$device': _.info.device(userAgent)
24471 }), {
24472 '$current_url': _.info.currentUrl(),
24473 '$browser_version': _.info.browserVersion(userAgent, navigator.vendor, windowOpera),
24474 '$screen_height': screen.height,
24475 '$screen_width': screen.width,
24476 'mp_lib': 'web',
24477 '$lib_version': Config.LIB_VERSION,
24478 '$insert_id': cheap_guid(),
24479 'time': _.timestamp() / 1000 // epoch time in seconds
24480 }, _.strip_empty_properties(extra_props));
24481 },
24482
24483 people_properties: function() {
24484 return _.extend(_.strip_empty_properties({
24485 '$os': _.info.os(),
24486 '$browser': _.info.browser(userAgent, navigator.vendor, windowOpera)
24487 }), {
24488 '$browser_version': _.info.browserVersion(userAgent, navigator.vendor, windowOpera)
24489 });
24490 },
24491
24492 mpPageViewProperties: function() {
24493 return _.strip_empty_properties({
24494 'current_page_title': document$1.title,
24495 'current_domain': win.location.hostname,
24496 'current_url_path': win.location.pathname,
24497 'current_url_protocol': win.location.protocol,
24498 'current_url_search': win.location.search
24499 });
24500 }
24501 };
24502
24503 /**
24504 * Returns a throttled function that will only run at most every `waitMs` and returns a promise that resolves with the next invocation.
24505 * Throttled calls will build up a batch of args and invoke the callback with all args since the last invocation.
24506 */
24507 var batchedThrottle = function (fn, waitMs) {
24508 var timeoutPromise = null;
24509 var throttledItems = [];
24510 return function (item) {
24511 var self = this;
24512 throttledItems.push(item);
24513
24514 if (!timeoutPromise) {
24515 timeoutPromise = new PromisePolyfill(function (resolve) {
24516 setTimeout(function () {
24517 var returnValue = fn.apply(self, [throttledItems]);
24518 timeoutPromise = null;
24519 throttledItems = [];
24520 resolve(returnValue);
24521 }, waitMs);
24522 });
24523 }
24524 return timeoutPromise;
24525 };
24526 };
24527
24528 var cheap_guid = function(maxlen) {
24529 var guid = Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10);
24530 return maxlen ? guid.substring(0, maxlen) : guid;
24531 };
24532
24533 /**
24534 * Generates a W3C traceparent header for easy interop with distributed tracing systems i.e Open Telemetry
24535 * https://www.w3.org/TR/trace-context/#traceparent-header
24536 */
24537 var generateTraceparent = function() {
24538 var traceID = _.UUID().replace(/-/g, '');
24539 var parentID = _.UUID().replace(/-/g, '').substring(0, 16);
24540
24541 // Sampled trace
24542 var traceFlags = '01';
24543
24544 return '00-' + traceID + '-' + parentID + '-' + traceFlags;
24545 };
24546
24547 // naive way to extract domain name (example.com) from full hostname (my.sub.example.com)
24548 var SIMPLE_DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]*\.[a-z]+$/i;
24549 // this next one attempts to account for some ccSLDs, e.g. extracting oxford.ac.uk from www.oxford.ac.uk
24550 var DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i;
24551 /**
24552 * Attempts to extract main domain name from full hostname, using a few blunt heuristics. For
24553 * common TLDs like .com/.org that always have a simple SLD.TLD structure (example.com), we
24554 * simply extract the last two .-separated parts of the hostname (SIMPLE_DOMAIN_MATCH_REGEX).
24555 * For others, we attempt to account for short ccSLD+TLD combos (.ac.uk) with the legacy
24556 * DOMAIN_MATCH_REGEX (kept to maintain backwards compatibility with existing Mixpanel
24557 * integrations). The only _reliable_ way to extract domain from hostname is with an up-to-date
24558 * list like at https://publicsuffix.org/ so for cases that this helper fails at, the SDK
24559 * offers the 'cookie_domain' config option to set it explicitly.
24560 * @example
24561 * extract_domain('my.sub.example.com')
24562 * // 'example.com'
24563 */
24564 var extract_domain = function(hostname) {
24565 var domain_regex = DOMAIN_MATCH_REGEX;
24566 var parts = hostname.split('.');
24567 var tld = parts[parts.length - 1];
24568 if (tld.length > 4 || tld === 'com' || tld === 'org') {
24569 domain_regex = SIMPLE_DOMAIN_MATCH_REGEX;
24570 }
24571 var matches = hostname.match(domain_regex);
24572 return matches ? matches[0] : '';
24573 };
24574
24575 /**
24576 * Check whether we have network connection. default to true for browsers that don't support navigator.onLine (IE)
24577 * @returns {boolean}
24578 */
24579 var isOnline = function() {
24580 var onLine = win.navigator['onLine'];
24581 return _.isUndefined(onLine) || onLine;
24582 };
24583
24584 var NOOP_FUNC = function () {};
24585
24586 var JSONStringify = null, JSONParse = null;
24587 if (typeof JSON !== 'undefined') {
24588 JSONStringify = JSON.stringify;
24589 JSONParse = JSON.parse;
24590 }
24591 JSONStringify = JSONStringify || _.JSONEncode;
24592 JSONParse = JSONParse || _.JSONDecode;
24593
24594 // UNMINIFIED EXPORTS (for closure compiler)
24595 _['info'] = _.info;
24596 _['info']['browser'] = _.info.browser;
24597 _['info']['browserVersion'] = _.info.browserVersion;
24598 _['info']['device'] = _.info.device;
24599 _['info']['properties'] = _.info.properties;
24600 _['isBlockedUA'] = _.isBlockedUA;
24601 _['isEmptyObject'] = _.isEmptyObject;
24602 _['isObject'] = _.isObject;
24603 _['JSONDecode'] = _.JSONDecode;
24604 _['JSONEncode'] = _.JSONEncode;
24605 _['toArray'] = _.toArray;
24606 _['NPO'] = NpoPromise;
24607
24608 var MIXPANEL_DB_NAME = 'mixpanelBrowserDb';
24609
24610 var RECORDING_EVENTS_STORE_NAME = 'mixpanelRecordingEvents';
24611 var RECORDING_REGISTRY_STORE_NAME = 'mixpanelRecordingRegistry';
24612
24613 // note: increment the version number when adding new object stores
24614 var DB_VERSION = 1;
24615 var OBJECT_STORES = [RECORDING_EVENTS_STORE_NAME, RECORDING_REGISTRY_STORE_NAME];
24616
24617 /**
24618 * @type {import('./wrapper').StorageWrapper}
24619 */
24620 var IDBStorageWrapper = function (storeName) {
24621 /**
24622 * @type {Promise<IDBDatabase>|null}
24623 */
24624 this.dbPromise = null;
24625 this.storeName = storeName;
24626 };
24627
24628 IDBStorageWrapper.prototype._openDb = function () {
24629 return new PromisePolyfill(function (resolve, reject) {
24630 var openRequest = win.indexedDB.open(MIXPANEL_DB_NAME, DB_VERSION);
24631 openRequest['onerror'] = function () {
24632 reject(openRequest.error);
24633 };
24634
24635 openRequest['onsuccess'] = function () {
24636 resolve(openRequest.result);
24637 };
24638
24639 openRequest['onupgradeneeded'] = function (ev) {
24640 var db = ev.target.result;
24641
24642 OBJECT_STORES.forEach(function (storeName) {
24643 db.createObjectStore(storeName);
24644 });
24645 };
24646 });
24647 };
24648
24649 IDBStorageWrapper.prototype.init = function () {
24650 if (!win.indexedDB) {
24651 return PromisePolyfill.reject('indexedDB is not supported in this browser');
24652 }
24653
24654 if (!this.dbPromise) {
24655 this.dbPromise = this._openDb();
24656 }
24657
24658 return this.dbPromise
24659 .then(function (dbOrError) {
24660 if (dbOrError instanceof win['IDBDatabase']) {
24661 return PromisePolyfill.resolve();
24662 } else {
24663 return PromisePolyfill.reject(dbOrError);
24664 }
24665 });
24666 };
24667
24668 IDBStorageWrapper.prototype.isInitialized = function () {
24669 return !!this.dbPromise;
24670 };
24671
24672 /**
24673 * @param {IDBTransactionMode} mode
24674 * @param {function(IDBObjectStore): void} storeCb
24675 */
24676 IDBStorageWrapper.prototype.makeTransaction = function (mode, storeCb) {
24677 var storeName = this.storeName;
24678 var doTransaction = function (db) {
24679 return new PromisePolyfill(function (resolve, reject) {
24680 var transaction = db.transaction(storeName, mode);
24681 transaction.oncomplete = function () {
24682 resolve(transaction);
24683 };
24684 transaction.onabort = transaction.onerror = function () {
24685 reject(transaction.error);
24686 };
24687
24688 storeCb(transaction.objectStore(storeName));
24689 });
24690 };
24691
24692 return this.dbPromise
24693 .then(doTransaction)
24694 .catch(function (err) {
24695 if (err && err['name'] === 'InvalidStateError') {
24696 // try reopening the DB if the connection is closed
24697 this.dbPromise = this._openDb();
24698 return this.dbPromise.then(doTransaction);
24699 } else {
24700 return PromisePolyfill.reject(err);
24701 }
24702 }.bind(this));
24703 };
24704
24705 IDBStorageWrapper.prototype.setItem = function (key, value) {
24706 return this.makeTransaction('readwrite', function (objectStore) {
24707 objectStore.put(value, key);
24708 });
24709 };
24710
24711 IDBStorageWrapper.prototype.getItem = function (key) {
24712 var req;
24713 return this.makeTransaction('readonly', function (objectStore) {
24714 req = objectStore.get(key);
24715 }).then(function () {
24716 return req.result;
24717 });
24718 };
24719
24720 IDBStorageWrapper.prototype.removeItem = function (key) {
24721 return this.makeTransaction('readwrite', function (objectStore) {
24722 objectStore.delete(key);
24723 });
24724 };
24725
24726 IDBStorageWrapper.prototype.getAll = function () {
24727 var req;
24728 return this.makeTransaction('readonly', function (objectStore) {
24729 req = objectStore.getAll();
24730 }).then(function () {
24731 return req.result;
24732 });
24733 };
24734
24735 /**
24736 * GDPR utils
24737 *
24738 * The General Data Protection Regulation (GDPR) is a regulation in EU law on data protection
24739 * and privacy for all individuals within the European Union. It addresses the export of personal
24740 * data outside the EU. The GDPR aims primarily to give control back to citizens and residents
24741 * over their personal data and to simplify the regulatory environment for international business
24742 * by unifying the regulation within the EU.
24743 *
24744 * This set of utilities is intended to enable opt in/out functionality in the Mixpanel JS SDK.
24745 * These functions are used internally by the SDK and are not intended to be publicly exposed.
24746 */
24747
24748
24749 /**
24750 * A function used to track a Mixpanel event (e.g. MixpanelLib.track)
24751 * @callback trackFunction
24752 * @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
24753 * @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.
24754 * @param {Function} [callback] If provided, the callback function will be called after tracking the event.
24755 */
24756
24757 /** Public **/
24758
24759 var GDPR_DEFAULT_PERSISTENCE_PREFIX = '__mp_opt_in_out_';
24760
24761 /**
24762 * Opt the user in to data tracking and cookies/localstorage for the given token
24763 * @param {string} token - Mixpanel project tracking token
24764 * @param {Object} [options]
24765 * @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
24766 * @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
24767 * @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
24768 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24769 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24770 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24771 * @param {string} [options.cookieDomain] - custom cookie domain
24772 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24773 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24774 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24775 */
24776 function optIn(token, options) {
24777 _optInOut(true, token, options);
24778 }
24779
24780 /**
24781 * Opt the user out of data tracking and cookies/localstorage for the given token
24782 * @param {string} token - Mixpanel project tracking token
24783 * @param {Object} [options]
24784 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24785 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24786 * @param {Number} [options.cookieExpiration] - number of days until the opt-out cookie expires
24787 * @param {string} [options.cookieDomain] - custom cookie domain
24788 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24789 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-out cookie is set as cross-subdomain or not
24790 * @param {boolean} [options.secureCookie] - whether the opt-out cookie is set as secure or not
24791 */
24792 function optOut(token, options) {
24793 _optInOut(false, token, options);
24794 }
24795
24796 /**
24797 * Check whether the user has opted in to data tracking and cookies/localstorage for the given token
24798 * @param {string} token - Mixpanel project tracking token
24799 * @param {Object} [options]
24800 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24801 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24802 * @returns {boolean} whether the user has opted in to the given opt type
24803 */
24804 function hasOptedIn(token, options) {
24805 return _getStorageValue(token, options) === '1';
24806 }
24807
24808 /**
24809 * Check whether the user has opted out of data tracking and cookies/localstorage for the given token
24810 * @param {string} token - Mixpanel project tracking token
24811 * @param {Object} [options]
24812 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24813 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24814 * @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
24815 * @returns {boolean} whether the user has opted out of the given opt type
24816 */
24817 function hasOptedOut(token, options) {
24818 if (_hasDoNotTrackFlagOn(options)) {
24819 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"');
24820 return true;
24821 }
24822 var optedOut = _getStorageValue(token, options) === '0';
24823 if (optedOut) {
24824 console$1.warn('You are opted out of Mixpanel tracking. This will prevent the Mixpanel SDK from sending any data.');
24825 }
24826 return optedOut;
24827 }
24828
24829 /**
24830 * Wrap a MixpanelLib method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24831 * If the user has opted out, return early instead of executing the method.
24832 * If a callback argument was provided, execute it passing the 0 error code.
24833 * @param {function} method - wrapped method to be executed if the user has not opted out
24834 * @returns {*} the result of executing method OR undefined if the user has opted out
24835 */
24836 function addOptOutCheckMixpanelLib(method) {
24837 return _addOptOutCheck(method, function(name) {
24838 return this.get_config(name);
24839 });
24840 }
24841
24842 /**
24843 * Wrap a MixpanelPeople method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24844 * If the user has opted out, return early instead of executing the method.
24845 * If a callback argument was provided, execute it passing the 0 error code.
24846 * @param {function} method - wrapped method to be executed if the user has not opted out
24847 * @returns {*} the result of executing method OR undefined if the user has opted out
24848 */
24849 function addOptOutCheckMixpanelPeople(method) {
24850 return _addOptOutCheck(method, function(name) {
24851 return this._get_config(name);
24852 });
24853 }
24854
24855 /**
24856 * Wrap a MixpanelGroup method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24857 * If the user has opted out, return early instead of executing the method.
24858 * If a callback argument was provided, execute it passing the 0 error code.
24859 * @param {function} method - wrapped method to be executed if the user has not opted out
24860 * @returns {*} the result of executing method OR undefined if the user has opted out
24861 */
24862 function addOptOutCheckMixpanelGroup(method) {
24863 return _addOptOutCheck(method, function(name) {
24864 return this._get_config(name);
24865 });
24866 }
24867
24868 /**
24869 * Clear the user's opt in/out status of data tracking and cookies/localstorage for the given token
24870 * @param {string} token - Mixpanel project tracking token
24871 * @param {Object} [options]
24872 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24873 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24874 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24875 * @param {string} [options.cookieDomain] - custom cookie domain
24876 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24877 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24878 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24879 */
24880 function clearOptInOut(token, options) {
24881 options = options || {};
24882 _getStorage(options).remove(
24883 _getStorageKey(token, options), !!options.crossSubdomainCookie, options.cookieDomain
24884 );
24885 }
24886
24887 /** Private **/
24888
24889 /**
24890 * Get storage util
24891 * @param {Object} [options]
24892 * @param {string} [options.persistenceType]
24893 * @returns {object} either _.cookie or _.localstorage
24894 */
24895 function _getStorage(options) {
24896 options = options || {};
24897 return options.persistenceType === 'localStorage' ? _.localStorage : _.cookie;
24898 }
24899
24900 /**
24901 * Get the name of the cookie that is used for the given opt type (tracking, cookie, etc.)
24902 * @param {string} token - Mixpanel project tracking token
24903 * @param {Object} [options]
24904 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24905 * @returns {string} the name of the cookie for the given opt type
24906 */
24907 function _getStorageKey(token, options) {
24908 options = options || {};
24909 return (options.persistencePrefix || GDPR_DEFAULT_PERSISTENCE_PREFIX) + token;
24910 }
24911
24912 /**
24913 * Get the value of the cookie that is used for the given opt type (tracking, cookie, etc.)
24914 * @param {string} token - Mixpanel project tracking token
24915 * @param {Object} [options]
24916 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24917 * @returns {string} the value of the cookie for the given opt type
24918 */
24919 function _getStorageValue(token, options) {
24920 return _getStorage(options).get(_getStorageKey(token, options));
24921 }
24922
24923 /**
24924 * Check whether the user has set the DNT/doNotTrack setting to true in their browser
24925 * @param {Object} [options]
24926 * @param {string} [options.window] - alternate window object to check; used to force various DNT settings in browser tests
24927 * @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
24928 * @returns {boolean} whether the DNT setting is true
24929 */
24930 function _hasDoNotTrackFlagOn(options) {
24931 if (options && options.ignoreDnt) {
24932 return false;
24933 }
24934 var win$1 = (options && options.window) || win;
24935 var nav = win$1['navigator'] || {};
24936 var hasDntOn = false;
24937
24938 _.each([
24939 nav['doNotTrack'], // standard
24940 nav['msDoNotTrack'],
24941 win$1['doNotTrack']
24942 ], function(dntValue) {
24943 if (_.includes([true, 1, '1', 'yes'], dntValue)) {
24944 hasDntOn = true;
24945 }
24946 });
24947
24948 return hasDntOn;
24949 }
24950
24951 /**
24952 * Set cookie/localstorage for the user indicating that they are opted in or out for the given opt type
24953 * @param {boolean} optValue - whether to opt the user in or out for the given opt type
24954 * @param {string} token - Mixpanel project tracking token
24955 * @param {Object} [options]
24956 * @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
24957 * @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
24958 * @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
24959 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24960 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24961 * @param {string} [options.cookieDomain] - custom cookie domain
24962 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24963 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24964 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24965 */
24966 function _optInOut(optValue, token, options) {
24967 if (!_.isString(token) || !token.length) {
24968 console$1.error('gdpr.' + (optValue ? 'optIn' : 'optOut') + ' called with an invalid token');
24969 return;
24970 }
24971
24972 options = options || {};
24973
24974 _getStorage(options).set(
24975 _getStorageKey(token, options),
24976 optValue ? 1 : 0,
24977 _.isNumber(options.cookieExpiration) ? options.cookieExpiration : null,
24978 !!options.crossSubdomainCookie,
24979 !!options.secureCookie,
24980 !!options.crossSiteCookie,
24981 options.cookieDomain
24982 );
24983
24984 if (options.track && optValue) { // only track event if opting in (optValue=true)
24985 options.track(options.trackEventName || '$opt_in', options.trackProperties, {
24986 'send_immediately': true
24987 });
24988 }
24989 }
24990
24991 /**
24992 * Wrap a method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24993 * If the user has opted out, return early instead of executing the method.
24994 * If a callback argument was provided, execute it passing the 0 error code.
24995 * @param {function} method - wrapped method to be executed if the user has not opted out
24996 * @param {function} getConfigValue - getter function for the Mixpanel API token and other options to be used with opt-out check
24997 * @returns {*} the result of executing method OR undefined if the user has opted out
24998 */
24999 function _addOptOutCheck(method, getConfigValue) {
25000 return function() {
25001 var optedOut = false;
25002
25003 try {
25004 var token = getConfigValue.call(this, 'token');
25005 var ignoreDnt = getConfigValue.call(this, 'ignore_dnt');
25006 var persistenceType = getConfigValue.call(this, 'opt_out_tracking_persistence_type');
25007 var persistencePrefix = getConfigValue.call(this, 'opt_out_tracking_cookie_prefix');
25008 var win = getConfigValue.call(this, 'window'); // used to override window during browser tests
25009
25010 if (token) { // if there was an issue getting the token, continue method execution as normal
25011 optedOut = hasOptedOut(token, {
25012 ignoreDnt: ignoreDnt,
25013 persistenceType: persistenceType,
25014 persistencePrefix: persistencePrefix,
25015 window: win
25016 });
25017 }
25018 } catch(err) {
25019 console$1.error('Unexpected error when checking tracking opt-out status: ' + err);
25020 }
25021
25022 if (!optedOut) {
25023 return method.apply(this, arguments);
25024 }
25025
25026 var callback = arguments[arguments.length - 1];
25027 if (typeof(callback) === 'function') {
25028 callback(0);
25029 }
25030
25031 return;
25032 };
25033 }
25034
25035 var logger$6 = console_with_prefix('lock');
25036
25037 /**
25038 * SharedLock: a mutex built on HTML5 localStorage, to ensure that only one browser
25039 * window/tab at a time will be able to access shared resources.
25040 *
25041 * Based on the Alur and Taubenfeld fast lock
25042 * (http://www.cs.rochester.edu/research/synchronization/pseudocode/fastlock.html)
25043 * with an added timeout to ensure there will be eventual progress in the event
25044 * that a window is closed in the middle of the callback.
25045 *
25046 * Implementation based on the original version by David Wolever (https://github.com/wolever)
25047 * at https://gist.github.com/wolever/5fd7573d1ef6166e8f8c4af286a69432.
25048 *
25049 * @example
25050 * const myLock = new SharedLock('some-key');
25051 * myLock.withLock(function() {
25052 * console.log('I hold the mutex!');
25053 * });
25054 *
25055 * @constructor
25056 */
25057 var SharedLock = function(key, options) {
25058 options = options || {};
25059
25060 this.storageKey = key;
25061 this.storage = options.storage || win.localStorage;
25062 this.pollIntervalMS = options.pollIntervalMS || 100;
25063 this.timeoutMS = options.timeoutMS || 2000;
25064
25065 // dependency-inject promise implementation for testing purposes
25066 this.promiseImpl = options.promiseImpl || PromisePolyfill;
25067 };
25068
25069 // pass in a specific pid to test contention scenarios; otherwise
25070 // it is chosen randomly for each acquisition attempt
25071 SharedLock.prototype.withLock = function(lockedCB, pid) {
25072 var Promise = this.promiseImpl;
25073 return new Promise(_.bind(function (resolve, reject) {
25074 var i = pid || (new Date().getTime() + '|' + Math.random());
25075 var startTime = new Date().getTime();
25076 var key = this.storageKey;
25077 var pollIntervalMS = this.pollIntervalMS;
25078 var timeoutMS = this.timeoutMS;
25079 var storage = this.storage;
25080
25081 var keyX = key + ':X';
25082 var keyY = key + ':Y';
25083 var keyZ = key + ':Z';
25084
25085 var delay = function(cb) {
25086 if (new Date().getTime() - startTime > timeoutMS) {
25087 logger$6.error('Timeout waiting for mutex on ' + key + '; clearing lock. [' + i + ']');
25088 storage.removeItem(keyZ);
25089 storage.removeItem(keyY);
25090 loop();
25091 return;
25092 }
25093 setTimeout(function() {
25094 try {
25095 cb();
25096 } catch(err) {
25097 reject(err);
25098 }
25099 }, pollIntervalMS * (Math.random() + 0.1));
25100 };
25101
25102 var waitFor = function(predicate, cb) {
25103 if (predicate()) {
25104 cb();
25105 } else {
25106 delay(function() {
25107 waitFor(predicate, cb);
25108 });
25109 }
25110 };
25111
25112 var getSetY = function() {
25113 var valY = storage.getItem(keyY);
25114 if (valY && valY !== i) { // if Y == i then this process already has the lock (useful for test cases)
25115 return false;
25116 } else {
25117 storage.setItem(keyY, i);
25118 if (storage.getItem(keyY) === i) {
25119 return true;
25120 } else {
25121 if (!localStorageSupported(storage, true)) {
25122 reject(new Error('localStorage support dropped while acquiring lock'));
25123 }
25124 return false;
25125 }
25126 }
25127 };
25128
25129 var loop = function() {
25130 storage.setItem(keyX, i);
25131
25132 waitFor(getSetY, function() {
25133 if (storage.getItem(keyX) === i) {
25134 criticalSection();
25135 return;
25136 }
25137
25138 delay(function() {
25139 if (storage.getItem(keyY) !== i) {
25140 loop();
25141 return;
25142 }
25143 waitFor(function() {
25144 return !storage.getItem(keyZ);
25145 }, criticalSection);
25146 });
25147 });
25148 };
25149
25150 var criticalSection = function() {
25151 storage.setItem(keyZ, '1');
25152 var removeLock = function () {
25153 storage.removeItem(keyZ);
25154 if (storage.getItem(keyY) === i) {
25155 storage.removeItem(keyY);
25156 }
25157 if (storage.getItem(keyX) === i) {
25158 storage.removeItem(keyX);
25159 }
25160 };
25161
25162 lockedCB()
25163 .then(function (ret) {
25164 removeLock();
25165 resolve(ret);
25166 })
25167 .catch(function (err) {
25168 removeLock();
25169 reject(err);
25170 });
25171 };
25172
25173 try {
25174 if (localStorageSupported(storage, true)) {
25175 loop();
25176 } else {
25177 throw new Error('localStorage support check failed');
25178 }
25179 } catch(err) {
25180 reject(err);
25181 }
25182 }, this));
25183 };
25184
25185 /**
25186 * @type {import('./wrapper').StorageWrapper}
25187 */
25188 var LocalStorageWrapper = function (storageOverride) {
25189 this.storage = storageOverride || win.localStorage;
25190 };
25191
25192 LocalStorageWrapper.prototype.init = function () {
25193 return PromisePolyfill.resolve();
25194 };
25195
25196 LocalStorageWrapper.prototype.isInitialized = function () {
25197 return true;
25198 };
25199
25200 LocalStorageWrapper.prototype.setItem = function (key, value) {
25201 return new PromisePolyfill(_.bind(function (resolve, reject) {
25202 try {
25203 this.storage.setItem(key, JSONStringify(value));
25204 } catch (e) {
25205 reject(e);
25206 }
25207 resolve();
25208 }, this));
25209 };
25210
25211 LocalStorageWrapper.prototype.getItem = function (key) {
25212 return new PromisePolyfill(_.bind(function (resolve, reject) {
25213 var item;
25214 try {
25215 item = JSONParse(this.storage.getItem(key));
25216 } catch (e) {
25217 reject(e);
25218 }
25219 resolve(item);
25220 }, this));
25221 };
25222
25223 LocalStorageWrapper.prototype.removeItem = function (key) {
25224 return new PromisePolyfill(_.bind(function (resolve, reject) {
25225 try {
25226 this.storage.removeItem(key);
25227 } catch (e) {
25228 reject(e);
25229 }
25230 resolve();
25231 }, this));
25232 };
25233
25234 var logger$5 = console_with_prefix('batch');
25235
25236 /**
25237 * RequestQueue: queue for batching API requests with localStorage backup for retries.
25238 * Maintains an in-memory queue which represents the source of truth for the current
25239 * page, but also writes all items out to a copy in the browser's localStorage, which
25240 * can be read on subsequent pageloads and retried. For batchability, all the request
25241 * items in the queue should be of the same type (events, people updates, group updates)
25242 * so they can be sent in a single request to the same API endpoint.
25243 *
25244 * LocalStorage keying and locking: In order for reloads and subsequent pageloads of
25245 * the same site to access the same persisted data, they must share the same localStorage
25246 * key (for instance based on project token and queue type). Therefore access to the
25247 * localStorage entry is guarded by an asynchronous mutex (SharedLock) to prevent
25248 * simultaneously open windows/tabs from overwriting each other's data (which would lead
25249 * to data loss in some situations).
25250 * @constructor
25251 */
25252 var RequestQueue = function (storageKey, options) {
25253 options = options || {};
25254 this.storageKey = storageKey;
25255 this.usePersistence = options.usePersistence;
25256 if (this.usePersistence) {
25257 this.queueStorage = options.queueStorage || new LocalStorageWrapper();
25258 this.lock = new SharedLock(storageKey, {
25259 storage: options.sharedLockStorage || win.localStorage,
25260 timeoutMS: options.sharedLockTimeoutMS,
25261 });
25262 }
25263 this.reportError = options.errorReporter || _.bind(logger$5.error, logger$5);
25264
25265 this.pid = options.pid || null; // pass pid to test out storage lock contention scenarios
25266
25267 this.memQueue = [];
25268 this.initialized = false;
25269
25270 if (options.enqueueThrottleMs) {
25271 this.enqueuePersisted = batchedThrottle(_.bind(this._enqueuePersisted, this), options.enqueueThrottleMs);
25272 } else {
25273 this.enqueuePersisted = _.bind(function (queueEntry) {
25274 return this._enqueuePersisted([queueEntry]);
25275 }, this);
25276 }
25277 };
25278
25279 RequestQueue.prototype.ensureInit = function () {
25280 if (this.initialized || !this.usePersistence) {
25281 return PromisePolyfill.resolve();
25282 }
25283
25284 return this.queueStorage
25285 .init()
25286 .then(_.bind(function () {
25287 this.initialized = true;
25288 }, this))
25289 .catch(_.bind(function (err) {
25290 this.reportError('Error initializing queue persistence. Disabling persistence', err);
25291 this.initialized = true;
25292 this.usePersistence = false;
25293 }, this));
25294 };
25295
25296 /**
25297 * Add one item to queues (memory and localStorage). The queued entry includes
25298 * the given item along with an auto-generated ID and a "flush-after" timestamp.
25299 * It is expected that the item will be sent over the network and dequeued
25300 * before the flush-after time; if this doesn't happen it is considered orphaned
25301 * (e.g., the original tab where it was enqueued got closed before it could be
25302 * sent) and the item can be sent by any tab that finds it in localStorage.
25303 *
25304 * The final callback param is called with a param indicating success or
25305 * failure of the enqueue operation; it is asynchronous because the localStorage
25306 * lock is asynchronous.
25307 */
25308 RequestQueue.prototype.enqueue = function (item, flushInterval) {
25309 var queueEntry = {
25310 'id': cheap_guid(),
25311 'flushAfter': new Date().getTime() + flushInterval * 2,
25312 'payload': item
25313 };
25314
25315 if (!this.usePersistence) {
25316 this.memQueue.push(queueEntry);
25317 return PromisePolyfill.resolve(true);
25318 } else {
25319 return this.enqueuePersisted(queueEntry);
25320 }
25321 };
25322
25323 RequestQueue.prototype._enqueuePersisted = function (queueEntries) {
25324 var enqueueItem = _.bind(function () {
25325 return this.ensureInit()
25326 .then(_.bind(function () {
25327 return this.readFromStorage();
25328 }, this))
25329 .then(_.bind(function (storedQueue) {
25330 return this.saveToStorage(storedQueue.concat(queueEntries));
25331 }, this))
25332 .then(_.bind(function (succeeded) {
25333 // only add to in-memory queue when storage succeeds
25334 if (succeeded) {
25335 this.memQueue = this.memQueue.concat(queueEntries);
25336 }
25337
25338 return succeeded;
25339 }, this))
25340 .catch(_.bind(function (err) {
25341 this.reportError('Error enqueueing items', err, queueEntries);
25342 return false;
25343 }, this));
25344 }, this);
25345
25346 return this.lock
25347 .withLock(enqueueItem, this.pid)
25348 .catch(_.bind(function (err) {
25349 this.reportError('Error acquiring storage lock', err);
25350 return false;
25351 }, this));
25352 };
25353
25354 /**
25355 * Read out the given number of queue entries. If this.memQueue
25356 * has fewer than batchSize items, then look for "orphaned" items
25357 * in the persisted queue (items where the 'flushAfter' time has
25358 * already passed).
25359 */
25360 RequestQueue.prototype.fillBatch = function (batchSize) {
25361 var batch = this.memQueue.slice(0, batchSize);
25362 if (this.usePersistence && batch.length < batchSize) {
25363 // don't need lock just to read events; localStorage is thread-safe
25364 // and the worst that could happen is a duplicate send of some
25365 // orphaned events, which will be deduplicated on the server side
25366 return this.ensureInit()
25367 .then(_.bind(function () {
25368 return this.readFromStorage();
25369 }, this))
25370 .then(_.bind(function (storedQueue) {
25371 if (storedQueue.length) {
25372 // item IDs already in batch; don't duplicate out of storage
25373 var idsInBatch = {}; // poor man's Set
25374 _.each(batch, function (item) {
25375 idsInBatch[item['id']] = true;
25376 });
25377
25378 for (var i = 0; i < storedQueue.length; i++) {
25379 var item = storedQueue[i];
25380 if (new Date().getTime() > item['flushAfter'] && !idsInBatch[item['id']]) {
25381 item.orphaned = true;
25382 batch.push(item);
25383 if (batch.length >= batchSize) {
25384 break;
25385 }
25386 }
25387 }
25388 }
25389
25390 return batch;
25391 }, this));
25392 } else {
25393 return PromisePolyfill.resolve(batch);
25394 }
25395 };
25396
25397 /**
25398 * Remove items with matching 'id' from array (immutably)
25399 * also remove any item without a valid id (e.g., malformed
25400 * storage entries).
25401 */
25402 var filterOutIDsAndInvalid = function (items, idSet) {
25403 var filteredItems = [];
25404 _.each(items, function (item) {
25405 if (item['id'] && !idSet[item['id']]) {
25406 filteredItems.push(item);
25407 }
25408 });
25409 return filteredItems;
25410 };
25411
25412 /**
25413 * Remove items with matching IDs from both in-memory queue
25414 * and persisted queue
25415 */
25416 RequestQueue.prototype.removeItemsByID = function (ids) {
25417 var idSet = {}; // poor man's Set
25418 _.each(ids, function (id) {
25419 idSet[id] = true;
25420 });
25421
25422 this.memQueue = filterOutIDsAndInvalid(this.memQueue, idSet);
25423 if (!this.usePersistence) {
25424 return PromisePolyfill.resolve(true);
25425 } else {
25426 var removeFromStorage = _.bind(function () {
25427 return this.ensureInit()
25428 .then(_.bind(function () {
25429 return this.readFromStorage();
25430 }, this))
25431 .then(_.bind(function (storedQueue) {
25432 storedQueue = filterOutIDsAndInvalid(storedQueue, idSet);
25433 return this.saveToStorage(storedQueue);
25434 }, this))
25435 .then(_.bind(function () {
25436 return this.readFromStorage();
25437 }, this))
25438 .then(_.bind(function (storedQueue) {
25439 // an extra check: did storage report success but somehow
25440 // the items are still there?
25441 for (var i = 0; i < storedQueue.length; i++) {
25442 var item = storedQueue[i];
25443 if (item['id'] && !!idSet[item['id']]) {
25444 throw new Error('Item not removed from storage');
25445 }
25446 }
25447 return true;
25448 }, this))
25449 .catch(_.bind(function (err) {
25450 this.reportError('Error removing items', err, ids);
25451 return false;
25452 }, this));
25453 }, this);
25454
25455 return this.lock
25456 .withLock(removeFromStorage, this.pid)
25457 .catch(_.bind(function (err) {
25458 this.reportError('Error acquiring storage lock', err);
25459 if (!localStorageSupported(this.lock.storage, true)) {
25460 // Looks like localStorage writes have stopped working sometime after
25461 // initialization (probably full), and so nobody can acquire locks
25462 // anymore. Consider it temporarily safe to remove items without the
25463 // lock, since nobody's writing successfully anyway.
25464 return removeFromStorage()
25465 .then(_.bind(function (success) {
25466 if (!success) {
25467 // OK, we couldn't even write out the smaller queue. Try clearing it
25468 // entirely.
25469 return this.queueStorage.removeItem(this.storageKey).then(function () {
25470 return success;
25471 });
25472 }
25473 return success;
25474 }, this))
25475 .catch(_.bind(function (err) {
25476 this.reportError('Error clearing queue', err);
25477 return false;
25478 }, this));
25479 } else {
25480 return false;
25481 }
25482 }, this));
25483 }
25484 };
25485
25486 // internal helper for RequestQueue.updatePayloads
25487 var updatePayloads = function (existingItems, itemsToUpdate) {
25488 var newItems = [];
25489 _.each(existingItems, function (item) {
25490 var id = item['id'];
25491 if (id in itemsToUpdate) {
25492 var newPayload = itemsToUpdate[id];
25493 if (newPayload !== null) {
25494 item['payload'] = newPayload;
25495 newItems.push(item);
25496 }
25497 } else {
25498 // no update
25499 newItems.push(item);
25500 }
25501 });
25502 return newItems;
25503 };
25504
25505 /**
25506 * Update payloads of given items in both in-memory queue and
25507 * persisted queue. Items set to null are removed from queues.
25508 */
25509 RequestQueue.prototype.updatePayloads = function (itemsToUpdate) {
25510 this.memQueue = updatePayloads(this.memQueue, itemsToUpdate);
25511 if (!this.usePersistence) {
25512 return PromisePolyfill.resolve(true);
25513 } else {
25514 return this.lock
25515 .withLock(_.bind(function lockAcquired() {
25516 return this.ensureInit()
25517 .then(_.bind(function () {
25518 return this.readFromStorage();
25519 }, this))
25520 .then(_.bind(function (storedQueue) {
25521 storedQueue = updatePayloads(storedQueue, itemsToUpdate);
25522 return this.saveToStorage(storedQueue);
25523 }, this))
25524 .catch(_.bind(function (err) {
25525 this.reportError('Error updating items', itemsToUpdate, err);
25526 return false;
25527 }, this));
25528 }, this), this.pid)
25529 .catch(_.bind(function (err) {
25530 this.reportError('Error acquiring storage lock', err);
25531 return false;
25532 }, this));
25533 }
25534 };
25535
25536 /**
25537 * Read and parse items array from localStorage entry, handling
25538 * malformed/missing data if necessary.
25539 */
25540 RequestQueue.prototype.readFromStorage = function () {
25541 return this.ensureInit()
25542 .then(_.bind(function () {
25543 return this.queueStorage.getItem(this.storageKey);
25544 }, this))
25545 .then(_.bind(function (storageEntry) {
25546 if (storageEntry) {
25547 if (!_.isArray(storageEntry)) {
25548 this.reportError('Invalid storage entry:', storageEntry);
25549 storageEntry = null;
25550 }
25551 }
25552 return storageEntry || [];
25553 }, this))
25554 .catch(_.bind(function (err) {
25555 this.reportError('Error retrieving queue', err);
25556 return [];
25557 }, this));
25558 };
25559
25560 /**
25561 * Serialize the given items array to localStorage.
25562 */
25563 RequestQueue.prototype.saveToStorage = function (queue) {
25564 return this.ensureInit()
25565 .then(_.bind(function () {
25566 return this.queueStorage.setItem(this.storageKey, queue);
25567 }, this))
25568 .then(function () {
25569 return true;
25570 })
25571 .catch(_.bind(function (err) {
25572 this.reportError('Error saving queue', err);
25573 return false;
25574 }, this));
25575 };
25576
25577 /**
25578 * Clear out queues (memory and localStorage).
25579 */
25580 RequestQueue.prototype.clear = function () {
25581 this.memQueue = [];
25582
25583 if (this.usePersistence) {
25584 return this.ensureInit()
25585 .then(_.bind(function () {
25586 return this.queueStorage.removeItem(this.storageKey);
25587 }, this));
25588 } else {
25589 return PromisePolyfill.resolve();
25590 }
25591 };
25592
25593 // maximum interval between request retries after exponential backoff
25594 var MAX_RETRY_INTERVAL_MS = 10 * 60 * 1000; // 10 minutes
25595
25596 var logger$4 = console_with_prefix('batch');
25597
25598 /**
25599 * RequestBatcher: manages the queueing, flushing, retry etc of requests of one
25600 * type (events, people, groups).
25601 * Uses RequestQueue to manage the backing store.
25602 * @constructor
25603 */
25604 var RequestBatcher = function(storageKey, options) {
25605 this.errorReporter = options.errorReporter;
25606 this.queue = new RequestQueue(storageKey, {
25607 errorReporter: _.bind(this.reportError, this),
25608 queueStorage: options.queueStorage,
25609 sharedLockStorage: options.sharedLockStorage,
25610 sharedLockTimeoutMS: options.sharedLockTimeoutMS,
25611 usePersistence: options.usePersistence,
25612 enqueueThrottleMs: options.enqueueThrottleMs
25613 });
25614
25615 this.libConfig = options.libConfig;
25616 this.sendRequest = options.sendRequestFunc;
25617 this.beforeSendHook = options.beforeSendHook;
25618 this.stopAllBatching = options.stopAllBatchingFunc;
25619
25620 // seed variable batch size + flush interval with configured values
25621 this.batchSize = this.libConfig['batch_size'];
25622 this.flushInterval = this.libConfig['batch_flush_interval_ms'];
25623
25624 this.stopped = !this.libConfig['batch_autostart'];
25625 this.consecutiveRemovalFailures = 0;
25626
25627 // extra client-side dedupe
25628 this.itemIdsSentSuccessfully = {};
25629
25630 // Make the flush occur at the interval specified by flushIntervalMs, default behavior will attempt consecutive flushes
25631 // as long as the queue is not empty. This is useful for high-frequency events like Session Replay where we might end up
25632 // in a request loop and get ratelimited by the server.
25633 this.flushOnlyOnInterval = options.flushOnlyOnInterval || false;
25634
25635 this._flushPromise = null;
25636 };
25637
25638 /**
25639 * Add one item to queue.
25640 */
25641 RequestBatcher.prototype.enqueue = function(item) {
25642 return this.queue.enqueue(item, this.flushInterval);
25643 };
25644
25645 /**
25646 * Start flushing batches at the configured time interval. Must call
25647 * this method upon SDK init in order to send anything over the network.
25648 */
25649 RequestBatcher.prototype.start = function() {
25650 this.stopped = false;
25651 this.consecutiveRemovalFailures = 0;
25652 return this.flush();
25653 };
25654
25655 /**
25656 * Stop flushing batches. Can be restarted by calling start().
25657 */
25658 RequestBatcher.prototype.stop = function() {
25659 this.stopped = true;
25660 if (this.timeoutID) {
25661 clearTimeout(this.timeoutID);
25662 this.timeoutID = null;
25663 }
25664 };
25665
25666 /**
25667 * Clear out queue.
25668 */
25669 RequestBatcher.prototype.clear = function() {
25670 return this.queue.clear();
25671 };
25672
25673 /**
25674 * Restore batch size configuration to whatever is set in the main SDK.
25675 */
25676 RequestBatcher.prototype.resetBatchSize = function() {
25677 this.batchSize = this.libConfig['batch_size'];
25678 };
25679
25680 /**
25681 * Restore flush interval time configuration to whatever is set in the main SDK.
25682 */
25683 RequestBatcher.prototype.resetFlush = function() {
25684 this.scheduleFlush(this.libConfig['batch_flush_interval_ms']);
25685 };
25686
25687 /**
25688 * Schedule the next flush in the given number of milliseconds.
25689 */
25690 RequestBatcher.prototype.scheduleFlush = function(flushMS) {
25691 this.flushInterval = flushMS;
25692 if (!this.stopped) { // don't schedule anymore if batching has been stopped
25693 this.timeoutID = setTimeout(_.bind(function() {
25694 if (!this.stopped) {
25695 this._flushPromise = this.flush();
25696 }
25697 }, this), this.flushInterval);
25698 }
25699 };
25700
25701 /**
25702 * Send a request using the sendRequest callback, but promisified.
25703 * TODO: sendRequest should be promisified in the first place.
25704 */
25705 RequestBatcher.prototype.sendRequestPromise = function(data, options) {
25706 return new PromisePolyfill(_.bind(function(resolve) {
25707 this.sendRequest(data, options, resolve);
25708 }, this));
25709 };
25710
25711
25712 /**
25713 * Flush one batch to network. Depending on success/failure modes, it will either
25714 * remove the batch from the queue or leave it in for retry, and schedule the next
25715 * flush. In cases of most network or API failures, it will back off exponentially
25716 * when retrying.
25717 * @param {Object} [options]
25718 * @param {boolean} [options.sendBeacon] - whether to send batch with
25719 * navigator.sendBeacon (only useful for sending batches before page unloads, as
25720 * sendBeacon offers no callbacks or status indications)
25721 */
25722 RequestBatcher.prototype.flush = function(options) {
25723 if (this.requestInProgress) {
25724 logger$4.log('Flush: Request already in progress');
25725 return PromisePolyfill.resolve();
25726 }
25727
25728 this.requestInProgress = true;
25729
25730 options = options || {};
25731 var timeoutMS = this.libConfig['batch_request_timeout_ms'];
25732 var startTime = new Date().getTime();
25733 var currentBatchSize = this.batchSize;
25734
25735 return this.queue.fillBatch(currentBatchSize)
25736 .then(_.bind(function(batch) {
25737
25738 // if there's more items in the queue than the batch size, attempt
25739 // to flush again after the current batch is done.
25740 var attemptSecondaryFlush = batch.length === currentBatchSize;
25741 var dataForRequest = [];
25742 var transformedItems = {};
25743 _.each(batch, function(item) {
25744 var payload = item['payload'];
25745 if (this.beforeSendHook && !item.orphaned) {
25746 payload = this.beforeSendHook(payload);
25747 }
25748 if (payload) {
25749 // mp_sent_by_lib_version prop captures which lib version actually
25750 // sends each event (regardless of which version originally queued
25751 // it for sending)
25752 if (payload['event'] && payload['properties']) {
25753 payload['properties'] = _.extend(
25754 {},
25755 payload['properties'],
25756 {'mp_sent_by_lib_version': Config.LIB_VERSION}
25757 );
25758 }
25759 var addPayload = true;
25760 var itemId = item['id'];
25761 if (itemId) {
25762 if ((this.itemIdsSentSuccessfully[itemId] || 0) > 5) {
25763 this.reportError('[dupe] item ID sent too many times, not sending', {
25764 item: item,
25765 batchSize: batch.length,
25766 timesSent: this.itemIdsSentSuccessfully[itemId]
25767 });
25768 addPayload = false;
25769 }
25770 } else {
25771 this.reportError('[dupe] found item with no ID', {item: item});
25772 }
25773
25774 if (addPayload) {
25775 dataForRequest.push(payload);
25776 }
25777 }
25778 transformedItems[item['id']] = payload;
25779 }, this);
25780
25781 if (dataForRequest.length < 1) {
25782 this.requestInProgress = false;
25783 this.resetFlush();
25784 return PromisePolyfill.resolve(); // nothing to do
25785 }
25786
25787 var removeItemsFromQueue = _.bind(function () {
25788 return this.queue
25789 .removeItemsByID(
25790 _.map(batch, function (item) {
25791 return item['id'];
25792 })
25793 )
25794 .then(_.bind(function (succeeded) {
25795 // client-side dedupe
25796 _.each(batch, _.bind(function(item) {
25797 var itemId = item['id'];
25798 if (itemId) {
25799 this.itemIdsSentSuccessfully[itemId] = this.itemIdsSentSuccessfully[itemId] || 0;
25800 this.itemIdsSentSuccessfully[itemId]++;
25801 if (this.itemIdsSentSuccessfully[itemId] > 5) {
25802 this.reportError('[dupe] item ID sent too many times', {
25803 item: item,
25804 batchSize: batch.length,
25805 timesSent: this.itemIdsSentSuccessfully[itemId]
25806 });
25807 }
25808 } else {
25809 this.reportError('[dupe] found item with no ID while removing', {item: item});
25810 }
25811 }, this));
25812
25813 if (succeeded) {
25814 this.consecutiveRemovalFailures = 0;
25815 if (this.flushOnlyOnInterval && !attemptSecondaryFlush) {
25816 this.resetFlush(); // schedule next batch with a delay
25817 return PromisePolyfill.resolve();
25818 } else {
25819 return this.flush(); // handle next batch if the queue isn't empty
25820 }
25821 } else {
25822 if (++this.consecutiveRemovalFailures > 5) {
25823 this.reportError('Too many queue failures; disabling batching system.');
25824 this.stopAllBatching();
25825 } else {
25826 this.resetFlush();
25827 }
25828 return PromisePolyfill.resolve();
25829 }
25830 }, this));
25831 }, this);
25832
25833 var batchSendCallback = _.bind(function(res) {
25834 this.requestInProgress = false;
25835
25836 try {
25837
25838 // handle API response in a try-catch to make sure we can reset the
25839 // flush operation if something goes wrong
25840
25841 if (options.unloading) {
25842 // update persisted data to include hook transformations
25843 return this.queue.updatePayloads(transformedItems);
25844 } else if (
25845 _.isObject(res) &&
25846 res.error === 'timeout' &&
25847 new Date().getTime() - startTime >= timeoutMS
25848 ) {
25849 this.reportError('Network timeout; retrying');
25850 return this.flush();
25851 } else if (
25852 _.isObject(res) &&
25853 (
25854 res.httpStatusCode >= 500
25855 || res.httpStatusCode === 429
25856 || (res.httpStatusCode <= 0 && !isOnline())
25857 || res.error === 'timeout'
25858 )
25859 ) {
25860 // network or API error, or 429 Too Many Requests, retry
25861 var retryMS = this.flushInterval * 2;
25862 if (res.retryAfter) {
25863 retryMS = (parseInt(res.retryAfter, 10) * 1000) || retryMS;
25864 }
25865 retryMS = Math.min(MAX_RETRY_INTERVAL_MS, retryMS);
25866 this.reportError('Error; retry in ' + retryMS + ' ms');
25867 this.scheduleFlush(retryMS);
25868 return PromisePolyfill.resolve();
25869 } else if (_.isObject(res) && res.httpStatusCode === 413) {
25870 // 413 Payload Too Large
25871 if (batch.length > 1) {
25872 var halvedBatchSize = Math.max(1, Math.floor(currentBatchSize / 2));
25873 this.batchSize = Math.min(this.batchSize, halvedBatchSize, batch.length - 1);
25874 this.reportError('413 response; reducing batch size to ' + this.batchSize);
25875 this.resetFlush();
25876 return PromisePolyfill.resolve();
25877 } else {
25878 this.reportError('Single-event request too large; dropping', batch);
25879 this.resetBatchSize();
25880 return removeItemsFromQueue();
25881 }
25882 } else {
25883 // successful network request+response; remove each item in batch from queue
25884 // (even if it was e.g. a 400, in which case retrying won't help)
25885 return removeItemsFromQueue();
25886 }
25887 } catch(err) {
25888 this.reportError('Error handling API response', err);
25889 this.resetFlush();
25890 }
25891 }, this);
25892 var requestOptions = {
25893 method: 'POST',
25894 verbose: true,
25895 ignore_json_errors: true, // eslint-disable-line camelcase
25896 timeout_ms: timeoutMS // eslint-disable-line camelcase
25897 };
25898 if (options.unloading) {
25899 requestOptions.transport = 'sendBeacon';
25900 }
25901 logger$4.log('MIXPANEL REQUEST:', dataForRequest);
25902 return this.sendRequestPromise(dataForRequest, requestOptions).then(batchSendCallback);
25903 }, this))
25904 .catch(_.bind(function(err) {
25905 this.reportError('Error flushing request queue', err);
25906 this.resetFlush();
25907 }, this));
25908 };
25909
25910 /**
25911 * Log error to global logger and optional user-defined logger.
25912 */
25913 RequestBatcher.prototype.reportError = function(msg, err) {
25914 logger$4.error.apply(logger$4.error, arguments);
25915 if (this.errorReporter) {
25916 try {
25917 if (!(err instanceof Error)) {
25918 err = new Error(msg);
25919 }
25920 this.errorReporter(msg, err);
25921 } catch(err) {
25922 logger$4.error(err);
25923 }
25924 }
25925 };
25926
25927 /**
25928 * @param {import('./session-recording').SerializedRecording} serializedRecording
25929 * @returns {boolean}
25930 */
25931 var isRecordingExpired = function(serializedRecording) {
25932 var now = Date.now();
25933 return !serializedRecording || now > serializedRecording['maxExpires'] || now > serializedRecording['idleExpires'];
25934 };
25935
25936 var RECORD_ENQUEUE_THROTTLE_MS = 250;
25937
25938 var logger$3 = console_with_prefix('recorder');
25939 var CompressionStream = win['CompressionStream'];
25940
25941 var RECORDER_BATCHER_LIB_CONFIG = {
25942 'batch_size': 1000,
25943 'batch_flush_interval_ms': 10 * 1000,
25944 'batch_request_timeout_ms': 90 * 1000,
25945 'batch_autostart': true
25946 };
25947
25948 var ACTIVE_SOURCES = new Set([
25949 IncrementalSource.MouseMove,
25950 IncrementalSource.MouseInteraction,
25951 IncrementalSource.Scroll,
25952 IncrementalSource.ViewportResize,
25953 IncrementalSource.Input,
25954 IncrementalSource.TouchMove,
25955 IncrementalSource.MediaInteraction,
25956 IncrementalSource.Drag,
25957 IncrementalSource.Selection,
25958 ]);
25959
25960 function isUserEvent(ev) {
25961 return ev.type === EventType.IncrementalSnapshot && ACTIVE_SOURCES.has(ev.data.source);
25962 }
25963
25964 /**
25965 * @typedef {Object} SerializedRecording
25966 * @property {number} idleExpires
25967 * @property {number} maxExpires
25968 * @property {number} replayStartTime
25969 * @property {number} seqNo
25970 * @property {string} batchStartUrl
25971 * @property {string} replayId
25972 * @property {string} tabId
25973 * @property {string} replayStartUrl
25974 */
25975
25976 /**
25977 * @typedef {Object} SessionRecordingOptions
25978 * @property {Object} [options.mixpanelInstance] - reference to the core MixpanelLib
25979 * @property {String} [options.replayId] - unique uuid for a single replay
25980 * @property {Function} [options.onIdleTimeout] - callback when a recording reaches idle timeout
25981 * @property {Function} [options.onMaxLengthReached] - callback when a recording reaches its maximum length
25982 * @property {Function} [options.rrwebRecord] - rrweb's `record` function
25983 * @property {Function} [options.onBatchSent] - callback when a batch of events is sent to the server
25984 * @property {Storage} [options.sharedLockStorage] - optional storage for shared lock, used for test dependency injection
25985 * optional properties for deserialization:
25986 * @property {number} idleExpires
25987 * @property {number} maxExpires
25988 * @property {number} replayStartTime
25989 * @property {number} seqNo
25990 * @property {string} batchStartUrl
25991 * @property {string} replayStartUrl
25992 */
25993
25994 /**
25995 * @typedef {Object} UserIdInfo
25996 * @property {string} distinct_id
25997 * @property {string} user_id
25998 * @property {string} device_id
25999 */
26000
26001
26002 /**
26003 * This class encapsulates a single session recording and its lifecycle.
26004 * @param {SessionRecordingOptions} options
26005 */
26006 var SessionRecording = function(options) {
26007 this._mixpanel = options.mixpanelInstance;
26008 this._onIdleTimeout = options.onIdleTimeout || NOOP_FUNC;
26009 this._onMaxLengthReached = options.onMaxLengthReached || NOOP_FUNC;
26010 this._onBatchSent = options.onBatchSent || NOOP_FUNC;
26011 this._rrwebRecord = options.rrwebRecord || null;
26012
26013 // internal rrweb stopRecording function
26014 this._stopRecording = null;
26015 this.replayId = options.replayId;
26016
26017 this.batchStartUrl = options.batchStartUrl || null;
26018 this.replayStartUrl = options.replayStartUrl || null;
26019 this.idleExpires = options.idleExpires || null;
26020 this.maxExpires = options.maxExpires || null;
26021 this.replayStartTime = options.replayStartTime || null;
26022 this.seqNo = options.seqNo || 0;
26023
26024 this.idleTimeoutId = null;
26025 this.maxTimeoutId = null;
26026
26027 this.recordMaxMs = MAX_RECORDING_MS;
26028 this.recordMinMs = 0;
26029
26030 // disable persistence if localStorage is not supported
26031 // request-queue will automatically disable persistence if indexedDB fails to initialize
26032 var usePersistence = localStorageSupported(options.sharedLockStorage, true) && !this.getConfig('disable_persistence');
26033
26034 // each replay has its own batcher key to avoid conflicts between rrweb events of different recordings
26035 this.batcherKey = '__mprec_' + this.getConfig('name') + '_' + this.getConfig('token') + '_' + this.replayId;
26036 this.queueStorage = new IDBStorageWrapper(RECORDING_EVENTS_STORE_NAME);
26037 this.batcher = new RequestBatcher(this.batcherKey, {
26038 errorReporter: this.reportError.bind(this),
26039 flushOnlyOnInterval: true,
26040 libConfig: RECORDER_BATCHER_LIB_CONFIG,
26041 sendRequestFunc: this.flushEventsWithOptOut.bind(this),
26042 queueStorage: this.queueStorage,
26043 sharedLockStorage: options.sharedLockStorage,
26044 usePersistence: usePersistence,
26045 stopAllBatchingFunc: this.stopRecording.bind(this),
26046
26047 // increased throttle and shared lock timeout because recording events are very high frequency.
26048 // this will minimize the amount of lock contention between enqueued events.
26049 // for session recordings there is a lock for each tab anyway, so there's no risk of deadlock between tabs.
26050 enqueueThrottleMs: RECORD_ENQUEUE_THROTTLE_MS,
26051 sharedLockTimeoutMS: 10 * 1000,
26052 });
26053 };
26054
26055 /**
26056 * @returns {UserIdInfo}
26057 */
26058 SessionRecording.prototype.getUserIdInfo = function () {
26059 if (this.finalFlushUserIdInfo) {
26060 return this.finalFlushUserIdInfo;
26061 }
26062
26063 var userIdInfo = {
26064 'distinct_id': String(this._mixpanel.get_distinct_id()),
26065 };
26066
26067 // send ID management props if they exist
26068 var deviceId = this._mixpanel.get_property('$device_id');
26069 if (deviceId) {
26070 userIdInfo['$device_id'] = deviceId;
26071 }
26072 var userId = this._mixpanel.get_property('$user_id');
26073 if (userId) {
26074 userIdInfo['$user_id'] = userId;
26075 }
26076 return userIdInfo;
26077 };
26078
26079 SessionRecording.prototype.unloadPersistedData = function () {
26080 this.batcher.stop();
26081 return this.batcher.flush()
26082 .then(function () {
26083 return this.queueStorage.removeItem(this.batcherKey);
26084 }.bind(this));
26085 };
26086
26087 SessionRecording.prototype.getConfig = function(configVar) {
26088 return this._mixpanel.get_config(configVar);
26089 };
26090
26091 // Alias for getConfig, used by the common addOptOutCheckMixpanelLib function which
26092 // reaches into this class instance and expects the snake case version of the function.
26093 // eslint-disable-next-line camelcase
26094 SessionRecording.prototype.get_config = function(configVar) {
26095 return this.getConfig(configVar);
26096 };
26097
26098 SessionRecording.prototype.startRecording = function (shouldStopBatcher) {
26099 if (this._rrwebRecord === null) {
26100 this.reportError('rrweb record function not provided. ');
26101 return;
26102 }
26103
26104 if (this._stopRecording !== null) {
26105 logger$3.log('Recording already in progress, skipping startRecording.');
26106 return;
26107 }
26108
26109 this.recordMaxMs = this.getConfig('record_max_ms');
26110 if (this.recordMaxMs > MAX_RECORDING_MS) {
26111 this.recordMaxMs = MAX_RECORDING_MS;
26112 logger$3.critical('record_max_ms cannot be greater than ' + MAX_RECORDING_MS + 'ms. Capping value.');
26113 }
26114
26115 if (!this.maxExpires) {
26116 this.maxExpires = new Date().getTime() + this.recordMaxMs;
26117 }
26118
26119 this.recordMinMs = this.getConfig('record_min_ms');
26120 if (this.recordMinMs > MAX_VALUE_FOR_MIN_RECORDING_MS) {
26121 this.recordMinMs = MAX_VALUE_FOR_MIN_RECORDING_MS;
26122 logger$3.critical('record_min_ms cannot be greater than ' + MAX_VALUE_FOR_MIN_RECORDING_MS + 'ms. Capping value.');
26123 }
26124
26125 if (!this.replayStartTime) {
26126 this.replayStartTime = new Date().getTime();
26127 this.batchStartUrl = _.info.currentUrl();
26128 this.replayStartUrl = _.info.currentUrl();
26129 }
26130
26131 if (shouldStopBatcher || this.recordMinMs > 0) {
26132 // the primary case for shouldStopBatcher is when we're starting recording after a reset
26133 // and don't want to send anything over the network until there's
26134 // actual user activity
26135 // this also applies if the minimum recording length has not been hit yet
26136 // so that we don't send data until we know the recording will be long enough
26137 this.batcher.stop();
26138 } else {
26139 this.batcher.start();
26140 }
26141
26142 var resetIdleTimeout = function () {
26143 clearTimeout(this.idleTimeoutId);
26144 var idleTimeoutMs = this.getConfig('record_idle_timeout_ms');
26145 this.idleTimeoutId = setTimeout(this._onIdleTimeout, idleTimeoutMs);
26146 this.idleExpires = new Date().getTime() + idleTimeoutMs;
26147 }.bind(this);
26148 resetIdleTimeout();
26149
26150 var blockSelector = this.getConfig('record_block_selector');
26151 if (blockSelector === '' || blockSelector === null) {
26152 blockSelector = undefined;
26153 }
26154
26155 try {
26156 this._stopRecording = this._rrwebRecord({
26157 'emit': function (ev) {
26158 if (this.idleExpires && this.idleExpires < ev.timestamp) {
26159 this._onIdleTimeout();
26160 return;
26161 }
26162 if (isUserEvent(ev)) {
26163 if (this.batcher.stopped && new Date().getTime() - this.replayStartTime >= this.recordMinMs) {
26164 // start flushing again after user activity
26165 this.batcher.start();
26166 }
26167 resetIdleTimeout();
26168 }
26169 // promise only used to await during tests
26170 this.__enqueuePromise = this.batcher.enqueue(ev);
26171 }.bind(this),
26172 'blockClass': this.getConfig('record_block_class'),
26173 'blockSelector': blockSelector,
26174 'collectFonts': this.getConfig('record_collect_fonts'),
26175 'dataURLOptions': { // canvas image options (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL)
26176 'type': 'image/webp',
26177 'quality': 0.6
26178 },
26179 'maskAllInputs': true,
26180 'maskTextClass': this.getConfig('record_mask_text_class'),
26181 'maskTextSelector': this.getConfig('record_mask_text_selector'),
26182 'recordCanvas': this.getConfig('record_canvas'),
26183 'sampling': {
26184 'canvas': 15
26185 }
26186 });
26187 } catch (err) {
26188 this.reportError('Unexpected error when starting rrweb recording.', err);
26189 }
26190
26191 if (typeof this._stopRecording !== 'function') {
26192 this.reportError('rrweb failed to start, skipping this recording.');
26193 this._stopRecording = null;
26194 this.stopRecording(); // stop batcher looping and any timeouts
26195 return;
26196 }
26197
26198 var maxTimeoutMs = this.maxExpires - new Date().getTime();
26199 this.maxTimeoutId = setTimeout(this._onMaxLengthReached.bind(this), maxTimeoutMs);
26200 };
26201
26202 SessionRecording.prototype.stopRecording = function (skipFlush) {
26203 // store the user ID info in case this is getting called in mixpanel.reset()
26204 this.finalFlushUserIdInfo = this.getUserIdInfo();
26205
26206 if (!this.isRrwebStopped()) {
26207 try {
26208 this._stopRecording();
26209 } catch (err) {
26210 this.reportError('Error with rrweb stopRecording', err);
26211 }
26212 this._stopRecording = null;
26213 }
26214
26215 var flushPromise;
26216 if (this.batcher.stopped) {
26217 // never got user activity to flush after reset, so just clear the batcher
26218 flushPromise = this.batcher.clear();
26219 } else if (!skipFlush) {
26220 // flush any remaining events from running batcher
26221 flushPromise = this.batcher.flush();
26222 }
26223 this.batcher.stop();
26224
26225 clearTimeout(this.idleTimeoutId);
26226 clearTimeout(this.maxTimeoutId);
26227 return flushPromise;
26228 };
26229
26230 SessionRecording.prototype.isRrwebStopped = function () {
26231 return this._stopRecording === null;
26232 };
26233
26234
26235 /**
26236 * Flushes the current batch of events to the server, but passes an opt-out callback to make sure
26237 * we stop recording and dump any queued events if the user has opted out.
26238 */
26239 SessionRecording.prototype.flushEventsWithOptOut = function (data, options, cb) {
26240 var onOptOut = function (code) {
26241 // addOptOutCheckMixpanelLib invokes this function with code=0 when the user has opted out
26242 if (code === 0) {
26243 this.stopRecording();
26244 cb({error: 'Tracking has been opted out, stopping recording.'});
26245 }
26246 }.bind(this);
26247
26248 this._flushEvents(data, options, cb, onOptOut);
26249 };
26250
26251 /**
26252 * @returns {SerializedRecording}
26253 */
26254 SessionRecording.prototype.serialize = function () {
26255 // don't break if mixpanel instance was destroyed at some point
26256 var tabId;
26257 try {
26258 tabId = this._mixpanel.get_tab_id();
26259 } catch (e) {
26260 this.reportError('Error getting tab ID for serialization ', e);
26261 tabId = null;
26262 }
26263
26264 return {
26265 'replayId': this.replayId,
26266 'seqNo': this.seqNo,
26267 'replayStartTime': this.replayStartTime,
26268 'batchStartUrl': this.batchStartUrl,
26269 'replayStartUrl': this.replayStartUrl,
26270 'idleExpires': this.idleExpires,
26271 'maxExpires': this.maxExpires,
26272 'tabId': tabId,
26273 };
26274 };
26275
26276
26277 /**
26278 * @static
26279 * @param {SerializedRecording} serializedRecording
26280 * @param {SessionRecordingOptions} options
26281 * @returns {SessionRecording}
26282 */
26283 SessionRecording.deserialize = function (serializedRecording, options) {
26284 var recording = new SessionRecording(_.extend({}, options, {
26285 replayId: serializedRecording['replayId'],
26286 batchStartUrl: serializedRecording['batchStartUrl'],
26287 replayStartUrl: serializedRecording['replayStartUrl'],
26288 idleExpires: serializedRecording['idleExpires'],
26289 maxExpires: serializedRecording['maxExpires'],
26290 replayStartTime: serializedRecording['replayStartTime'],
26291 seqNo: serializedRecording['seqNo'],
26292 sharedLockStorage: options.sharedLockStorage,
26293 }));
26294
26295 return recording;
26296 };
26297
26298 SessionRecording.prototype._sendRequest = function(currentReplayId, reqParams, reqBody, callback) {
26299 var onSuccess = function (response, responseBody) {
26300 // Update batch specific props only if the request was successful to guarantee ordering.
26301 // RequestBatcher will always flush the next batch after the previous one succeeds.
26302 // extra check to see if the replay ID has changed so that we don't increment the seqNo on the wrong replay
26303 if (response.status === 200 && this.replayId === currentReplayId) {
26304 this.seqNo++;
26305 this.batchStartUrl = _.info.currentUrl();
26306 }
26307
26308 this._onBatchSent();
26309 callback({
26310 status: 0,
26311 httpStatusCode: response.status,
26312 responseBody: responseBody,
26313 retryAfter: response.headers.get('Retry-After')
26314 });
26315 }.bind(this);
26316 var apiHost = (this._mixpanel.get_api_host && this._mixpanel.get_api_host('record')) || this.getConfig('api_host');
26317 win['fetch'](apiHost + '/' + this.getConfig('api_routes')['record'] + '?' + new URLSearchParams(reqParams), {
26318 'method': 'POST',
26319 'headers': {
26320 'Authorization': 'Basic ' + btoa(this.getConfig('token') + ':'),
26321 'Content-Type': 'application/octet-stream'
26322 },
26323 'body': reqBody,
26324 }).then(function (response) {
26325 response.json().then(function (responseBody) {
26326 onSuccess(response, responseBody);
26327 }).catch(function (error) {
26328 callback({error: error});
26329 });
26330 }).catch(function (error) {
26331 callback({error: error, httpStatusCode: 0});
26332 });
26333 };
26334
26335 SessionRecording.prototype._flushEvents = addOptOutCheckMixpanelLib(function (data, options, callback) {
26336 var numEvents = data.length;
26337
26338 if (numEvents > 0) {
26339 var replayId = this.replayId;
26340
26341 // each rrweb event has a timestamp - leverage those to get time properties
26342 var batchStartTime = Infinity;
26343 var batchEndTime = -Infinity;
26344 var hasFullSnapshot = false;
26345 for (var i = 0; i < numEvents; i++) {
26346 batchStartTime = Math.min(batchStartTime, data[i].timestamp);
26347 batchEndTime = Math.max(batchEndTime, data[i].timestamp);
26348 if (data[i].type === EventType.FullSnapshot) {
26349 hasFullSnapshot = true;
26350 }
26351 }
26352
26353 if (this.seqNo === 0) {
26354 if (!hasFullSnapshot) {
26355 callback({error: 'First batch does not contain a full snapshot. Aborting recording.'});
26356 this.stopRecording(true);
26357 return;
26358 }
26359 this.replayStartTime = batchStartTime;
26360 } else if (!this.replayStartTime) {
26361 this.reportError('Replay start time not set but seqNo is not 0. Using current batch start time as a fallback.');
26362 this.replayStartTime = batchStartTime;
26363 }
26364
26365 var replayLengthMs = batchEndTime - this.replayStartTime;
26366
26367 var reqParams = {
26368 '$current_url': this.batchStartUrl,
26369 '$lib_version': Config.LIB_VERSION,
26370 'batch_start_time': batchStartTime / 1000,
26371 'mp_lib': 'web',
26372 'replay_id': replayId,
26373 'replay_length_ms': replayLengthMs,
26374 'replay_start_time': this.replayStartTime / 1000,
26375 'replay_start_url': this.replayStartUrl,
26376 'seq': this.seqNo
26377 };
26378 var eventsJson = JSON.stringify(data);
26379 Object.assign(reqParams, this.getUserIdInfo());
26380
26381 if (CompressionStream) {
26382 var jsonStream = new Blob([eventsJson], {type: 'application/json'}).stream();
26383 var gzipStream = jsonStream.pipeThrough(new CompressionStream('gzip'));
26384 new Response(gzipStream)
26385 .blob()
26386 .then(function(compressedBlob) {
26387 reqParams['format'] = 'gzip';
26388 this._sendRequest(replayId, reqParams, compressedBlob, callback);
26389 }.bind(this));
26390 } else {
26391 reqParams['format'] = 'body';
26392 this._sendRequest(replayId, reqParams, eventsJson, callback);
26393 }
26394 }
26395 });
26396
26397
26398 SessionRecording.prototype.reportError = function(msg, err) {
26399 logger$3.error.apply(logger$3.error, arguments);
26400 try {
26401 if (!err && !(msg instanceof Error)) {
26402 msg = new Error(msg);
26403 }
26404 this.getConfig('error_reporter')(msg, err);
26405 } catch(err) {
26406 logger$3.error(err);
26407 }
26408 };
26409
26410 /**
26411 * Module for handling the storage and retrieval of recording metadata as well as any active recordings.
26412 * Makes sure that only one tab can be recording at a time.
26413 */
26414 var RecordingRegistry = function (options) {
26415 /** @type {IDBStorageWrapper} */
26416 this.idb = new IDBStorageWrapper(RECORDING_REGISTRY_STORE_NAME);
26417 this.errorReporter = options.errorReporter;
26418 this.mixpanelInstance = options.mixpanelInstance;
26419 this.sharedLockStorage = options.sharedLockStorage;
26420 };
26421
26422 RecordingRegistry.prototype.isPersistenceEnabled = function() {
26423 return !this.mixpanelInstance.get_config('disable_persistence');
26424 };
26425
26426 RecordingRegistry.prototype.handleError = function (err) {
26427 this.errorReporter('IndexedDB error: ', err);
26428 };
26429
26430 /**
26431 * @param {import('./session-recording').SerializedRecording} serializedRecording
26432 */
26433 RecordingRegistry.prototype.setActiveRecording = function (serializedRecording) {
26434 if (!this.isPersistenceEnabled()) {
26435 return PromisePolyfill.resolve();
26436 }
26437
26438 var tabId = serializedRecording['tabId'];
26439 if (!tabId) {
26440 console.warn('No tab ID is set, cannot persist recording metadata.');
26441 return PromisePolyfill.resolve();
26442 }
26443
26444 return this.idb.init()
26445 .then(function () {
26446 return this.idb.setItem(tabId, serializedRecording);
26447 }.bind(this))
26448 .catch(this.handleError.bind(this));
26449 };
26450
26451 /**
26452 * @returns {Promise<import('./session-recording').SerializedRecording>}
26453 */
26454 RecordingRegistry.prototype.getActiveRecording = function () {
26455 if (!this.isPersistenceEnabled()) {
26456 return PromisePolyfill.resolve(null);
26457 }
26458
26459 return this.idb.init()
26460 .then(function () {
26461 return this.idb.getItem(this.mixpanelInstance.get_tab_id());
26462 }.bind(this))
26463 .then(function (serializedRecording) {
26464 return isRecordingExpired(serializedRecording) ? null : serializedRecording;
26465 }.bind(this))
26466 .catch(this.handleError.bind(this));
26467 };
26468
26469 RecordingRegistry.prototype.clearActiveRecording = function () {
26470 if (this.isPersistenceEnabled()) {
26471 // mark recording as expired instead of deleting it in case the page unloads mid-flush and doesn't make it to ingestion.
26472 // this will ensure the next pageload will flush the remaining events, but not try to continue the recording.
26473 return this.markActiveRecordingExpired();
26474 } else {
26475 return this.deleteActiveRecording();
26476 }
26477 };
26478
26479 RecordingRegistry.prototype.markActiveRecordingExpired = function () {
26480 return this.getActiveRecording()
26481 .then(function (serializedRecording) {
26482 if (serializedRecording) {
26483 serializedRecording['maxExpires'] = 0;
26484 return this.setActiveRecording(serializedRecording);
26485 }
26486 }.bind(this))
26487 .catch(this.handleError.bind(this));
26488 };
26489
26490 RecordingRegistry.prototype.deleteActiveRecording = function () {
26491 // avoid initializing IDB if this registry instance hasn't already written a recording
26492 if (this.idb.isInitialized()) {
26493 return this.idb.removeItem(this.mixpanelInstance.get_tab_id())
26494 .catch(this.handleError.bind(this));
26495 } else {
26496 return PromisePolyfill.resolve();
26497 }
26498 };
26499
26500 /**
26501 * Flush any inactive recordings from the registry to minimize data loss.
26502 * The main idea here is that we can flush remaining rrweb events on the next page load if a tab is closed mid-batch.
26503 */
26504 RecordingRegistry.prototype.flushInactiveRecordings = function () {
26505 if (!this.isPersistenceEnabled()) {
26506 return PromisePolyfill.resolve([]);
26507 }
26508
26509 return this.idb.init()
26510 .then(function() {
26511 return this.idb.getAll();
26512 }.bind(this))
26513 .then(function (serializedRecordings) {
26514 // clean up any expired recordings from the registry, non-expired ones may be active in other tabs
26515 var unloadPromises = serializedRecordings
26516 .filter(function (serializedRecording) {
26517 return isRecordingExpired(serializedRecording);
26518 })
26519 .map(function (serializedRecording) {
26520 var sessionRecording = SessionRecording.deserialize(serializedRecording, {
26521 mixpanelInstance: this.mixpanelInstance,
26522 sharedLockStorage: this.sharedLockStorage
26523 });
26524 return sessionRecording.unloadPersistedData()
26525 .then(function () {
26526 // expired recording was successfully flushed, we can clean it up from the registry
26527 return this.idb.removeItem(serializedRecording['tabId']);
26528 }.bind(this))
26529 .catch(this.handleError.bind(this));
26530 }.bind(this));
26531
26532 return PromisePolyfill.all(unloadPromises);
26533 }.bind(this))
26534 .catch(this.handleError.bind(this));
26535 };
26536
26537 var logger$2 = console_with_prefix('recorder');
26538
26539 /**
26540 * Recorder API: bundles rrweb and and exposes methods to start and stop recordings.
26541 * @param {Object} [options.mixpanelInstance] - reference to the core MixpanelLib
26542 */
26543 var MixpanelRecorder = function(mixpanelInstance, rrwebRecord, sharedLockStorage) {
26544 this.mixpanelInstance = mixpanelInstance;
26545 this.rrwebRecord = rrwebRecord || record;
26546 this.sharedLockStorage = sharedLockStorage;
26547
26548 /**
26549 * @member {import('./registry').RecordingRegistry}
26550 */
26551 this.recordingRegistry = new RecordingRegistry({
26552 mixpanelInstance: this.mixpanelInstance,
26553 errorReporter: logger$2.error,
26554 sharedLockStorage: sharedLockStorage
26555 });
26556 this._flushInactivePromise = this.recordingRegistry.flushInactiveRecordings();
26557
26558 this.activeRecording = null;
26559 this.stopRecordingInProgress = false;
26560 };
26561
26562 MixpanelRecorder.prototype.startRecording = function(options) {
26563 options = options || {};
26564 if (this.activeRecording && !this.activeRecording.isRrwebStopped()) {
26565 logger$2.log('Recording already in progress, skipping startRecording.');
26566 return;
26567 }
26568
26569 var onIdleTimeout = function () {
26570 logger$2.log('Idle timeout reached, restarting recording.');
26571 this.resetRecording();
26572 }.bind(this);
26573
26574 var onMaxLengthReached = function () {
26575 logger$2.log('Max recording length reached, stopping recording.');
26576 this.resetRecording();
26577 }.bind(this);
26578
26579 var onBatchSent = function () {
26580 this.recordingRegistry.setActiveRecording(this.activeRecording.serialize());
26581 this['__flushPromise'] = this.activeRecording.batcher._flushPromise;
26582 }.bind(this);
26583
26584 /**
26585 * @type {import('./session-recording').SessionRecordingOptions}
26586 */
26587 var sessionRecordingOptions = {
26588 mixpanelInstance: this.mixpanelInstance,
26589 onBatchSent: onBatchSent,
26590 onIdleTimeout: onIdleTimeout,
26591 onMaxLengthReached: onMaxLengthReached,
26592 replayId: _.UUID(),
26593 rrwebRecord: this.rrwebRecord,
26594 sharedLockStorage: this.sharedLockStorage
26595 };
26596
26597 if (options.activeSerializedRecording) {
26598 this.activeRecording = SessionRecording.deserialize(options.activeSerializedRecording, sessionRecordingOptions);
26599 } else {
26600 this.activeRecording = new SessionRecording(sessionRecordingOptions);
26601 }
26602
26603 this.activeRecording.startRecording(options.shouldStopBatcher);
26604 return this.recordingRegistry.setActiveRecording(this.activeRecording.serialize());
26605 };
26606
26607 MixpanelRecorder.prototype.stopRecording = function() {
26608 // Prevents activeSerializedRecording from being reused when stopping the recording.
26609 this.stopRecordingInProgress = true;
26610 return this._stopCurrentRecording(false, true).then(function() {
26611 return this.recordingRegistry.clearActiveRecording();
26612 }.bind(this)).then(function() {
26613 this.stopRecordingInProgress = false;
26614 }.bind(this));
26615 };
26616
26617 MixpanelRecorder.prototype.pauseRecording = function() {
26618 return this._stopCurrentRecording(false);
26619 };
26620
26621 MixpanelRecorder.prototype._stopCurrentRecording = function(skipFlush, disableActiveRecording) {
26622 if (this.activeRecording) {
26623 var stopRecordingPromise = this.activeRecording.stopRecording(skipFlush);
26624 if (disableActiveRecording) {
26625 this.activeRecording = null;
26626 }
26627 return stopRecordingPromise;
26628 }
26629 return PromisePolyfill.resolve();
26630 };
26631
26632 MixpanelRecorder.prototype.resumeRecording = function (startNewIfInactive) {
26633 if (this.activeRecording && this.activeRecording.isRrwebStopped()) {
26634 this.activeRecording.startRecording(false);
26635 return PromisePolyfill.resolve(null);
26636 }
26637
26638 return this.recordingRegistry.getActiveRecording()
26639 .then(function (activeSerializedRecording) {
26640 if (activeSerializedRecording && !this.stopRecordingInProgress) {
26641 return this.startRecording({activeSerializedRecording: activeSerializedRecording});
26642 } else if (startNewIfInactive) {
26643 return this.startRecording({shouldStopBatcher: false});
26644 } else {
26645 logger$2.log('No resumable recording found.');
26646 return null;
26647 }
26648 }.bind(this));
26649 };
26650
26651
26652 MixpanelRecorder.prototype.resetRecording = function () {
26653 this.stopRecording();
26654 this.startRecording({shouldStopBatcher: true});
26655 };
26656
26657 MixpanelRecorder.prototype.getActiveReplayId = function () {
26658 if (this.activeRecording && !this.activeRecording.isRrwebStopped()) {
26659 return this.activeRecording.replayId;
26660 } else {
26661 return null;
26662 }
26663 };
26664
26665 // getter so that older mixpanel-core versions can still retrieve the replay ID
26666 // when pulling the latest recorder bundle from the CDN
26667 Object.defineProperty(MixpanelRecorder.prototype, 'replayId', {
26668 get: function () {
26669 return this.getActiveReplayId();
26670 }
26671 });
26672
26673 win['__mp_recorder'] = MixpanelRecorder;
26674
26675 // stateless utils
26676 // mostly from https://github.com/mixpanel/mixpanel-js/blob/989ada50f518edab47b9c4fd9535f9fbd5ec5fc0/src/autotrack-utils.js
26677
26678
26679 var EV_CHANGE = 'change';
26680 var EV_CLICK = 'click';
26681 var EV_HASHCHANGE = 'hashchange';
26682 var EV_INPUT = 'input';
26683 var EV_LOAD = 'load';
26684 var EV_MP_LOCATION_CHANGE = 'mp_locationchange';
26685 var EV_POPSTATE = 'popstate';
26686 // TODO scrollend isn't available in Safari: document or polyfill?
26687 var EV_SCROLLEND = 'scrollend';
26688 var EV_SCROLL = 'scroll';
26689 var EV_SELECT = 'select';
26690 var EV_SUBMIT = 'submit';
26691 var EV_TOGGLE = 'toggle';
26692 var EV_VISIBILITYCHANGE = 'visibilitychange';
26693
26694 var CLICK_EVENT_PROPS = [
26695 'clientX', 'clientY',
26696 'offsetX', 'offsetY',
26697 'pageX', 'pageY',
26698 'screenX', 'screenY',
26699 'x', 'y'
26700 ];
26701 var OPT_IN_CLASSES = ['mp-include'];
26702 var OPT_OUT_CLASSES = ['mp-no-track'];
26703 var SENSITIVE_DATA_CLASSES = OPT_OUT_CLASSES.concat(['mp-sensitive']);
26704 var TRACKED_ATTRS = [
26705 'aria-label', 'aria-labelledby', 'aria-describedby',
26706 'href', 'name', 'role', 'title', 'type'
26707 ];
26708
26709 var INTERACTIVE_ARIA_ROLES = {
26710 'button': true,
26711 'checkbox': true,
26712 'combobox': true,
26713 'grid': true,
26714 'link': true,
26715 'listbox': true,
26716 'menu': true,
26717 'menubar': true,
26718 'menuitem': true,
26719 'menuitemcheckbox': true,
26720 'menuitemradio': true,
26721 'navigation': true,
26722 'option': true,
26723 'radio': true,
26724 'radiogroup': true,
26725 'searchbox': true,
26726 'slider': true,
26727 'spinbutton': true,
26728 'switch': true,
26729 'tab': true,
26730 'tablist': true,
26731 'textbox': true,
26732 'tree': true,
26733 'treegrid': true,
26734 'treeitem': true
26735 };
26736
26737 var ALWAYS_NON_INTERACTIVE_TAGS = {
26738 // Document metadata
26739 'base': true,
26740 'head': true,
26741 'html': true,
26742 'link': true,
26743 'meta': true,
26744 'script': true,
26745 'style': true,
26746 'title': true,
26747 // Text formatting
26748 'br': true,
26749 'hr': true,
26750 'wbr': true,
26751 // Other
26752 'noscript': true,
26753 'picture': true,
26754 'source': true,
26755 'template': true,
26756 'track': true
26757 };
26758
26759 // Common container tags that need additional checks
26760 var TEXT_CONTAINER_TAGS = {
26761 'article': true,
26762 'div': true,
26763 'h1': true,
26764 'h2': true,
26765 'h3': true,
26766 'h4': true,
26767 'h5': true,
26768 'h6': true,
26769 'p': true,
26770 'section': true,
26771 'span': true
26772 };
26773
26774 var EVENT_HANDLER_ATTRIBUTES = [
26775 'onclick', 'onmousedown', 'onmouseup', 'onpointerdown', 'onpointerup', 'ontouchend', 'ontouchstart'
26776 ];
26777
26778 var MAX_DEPTH = 5;
26779
26780 var logger$1 = console_with_prefix('autocapture');
26781
26782
26783 function getClasses(el) {
26784 var classes = {};
26785 var classList = getClassName(el).split(' ');
26786 for (var i = 0; i < classList.length; i++) {
26787 var cls = classList[i];
26788 if (cls) {
26789 classes[cls] = true;
26790 }
26791 }
26792 return classes;
26793 }
26794
26795 /*
26796 * Get the className of an element, accounting for edge cases where element.className is an object
26797 * @param {Element} el - element to get the className of
26798 * @returns {string} the element's class
26799 */
26800 function getClassName(el) {
26801 switch(typeof el.className) {
26802 case 'string':
26803 return el.className;
26804 case 'object': // handle cases where className might be SVGAnimatedString or some other type
26805 return el.className.baseVal || el.getAttribute('class') || '';
26806 default: // future proof
26807 return '';
26808 }
26809 }
26810
26811 function getPreviousElementSibling(el) {
26812 if (el.previousElementSibling) {
26813 return el.previousElementSibling;
26814 } else {
26815 do {
26816 el = el.previousSibling;
26817 } while (el && !isElementNode(el));
26818 return el;
26819 }
26820 }
26821
26822 function getPropertiesFromElement(el, ev, blockAttrsSet, extraAttrs, allowElementCallback, allowSelectors) {
26823 var props = {
26824 '$classes': getClassName(el).split(' '),
26825 '$tag_name': el.tagName.toLowerCase()
26826 };
26827 var elId = el.id;
26828 if (elId) {
26829 props['$id'] = elId;
26830 }
26831
26832 if (shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors)) {
26833 _.each(TRACKED_ATTRS.concat(extraAttrs), function(attr) {
26834 if (el.hasAttribute(attr) && !blockAttrsSet[attr]) {
26835 var attrVal = el.getAttribute(attr);
26836 if (shouldTrackValue(attrVal)) {
26837 props['$attr-' + attr] = attrVal;
26838 }
26839 }
26840 });
26841 }
26842
26843 var nthChild = 1;
26844 var nthOfType = 1;
26845 var currentElem = el;
26846 while (currentElem = getPreviousElementSibling(currentElem)) { // eslint-disable-line no-cond-assign
26847 nthChild++;
26848 if (currentElem.tagName === el.tagName) {
26849 nthOfType++;
26850 }
26851 }
26852 props['$nth_child'] = nthChild;
26853 props['$nth_of_type'] = nthOfType;
26854
26855 return props;
26856 }
26857
26858 function getPropsForDOMEvent(ev, config) {
26859 var allowElementCallback = config.allowElementCallback;
26860 var allowSelectors = config.allowSelectors || [];
26861 var blockAttrs = config.blockAttrs || [];
26862 var blockElementCallback = config.blockElementCallback;
26863 var blockSelectors = config.blockSelectors || [];
26864 var captureTextContent = config.captureTextContent || false;
26865 var captureExtraAttrs = config.captureExtraAttrs || [];
26866 var capturedForHeatMap = config.capturedForHeatMap || false;
26867
26868 // convert array to set every time, as the config may have changed
26869 var blockAttrsSet = {};
26870 _.each(blockAttrs, function(attr) {
26871 blockAttrsSet[attr] = true;
26872 });
26873
26874 var props = null;
26875
26876 var target = typeof ev.target === 'undefined' ? ev.srcElement : ev.target;
26877 if (isTextNode(target)) { // defeat Safari bug (see: http://www.quirksmode.org/js/events_properties.html)
26878 target = target.parentNode;
26879 }
26880
26881 if (
26882 shouldTrackDomEvent(target, ev) &&
26883 isElementAllowed(target, ev, allowElementCallback, allowSelectors) &&
26884 !isElementBlocked(target, ev, blockElementCallback, blockSelectors)
26885 ) {
26886 var targetElementList = [target];
26887 var curEl = target;
26888 while (curEl.parentNode && !isTag(curEl, 'body')) {
26889 targetElementList.push(curEl.parentNode);
26890 curEl = curEl.parentNode;
26891 }
26892
26893 var elementsJson = [];
26894 var href, explicitNoTrack = false;
26895 _.each(targetElementList, function(el) {
26896 var shouldTrackDetails = shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors);
26897
26898 // if the element or a parent element is an anchor tag
26899 // include the href as a property
26900 if (!blockAttrsSet['href'] && el.tagName.toLowerCase() === 'a') {
26901 href = el.getAttribute('href');
26902 href = shouldTrackDetails && shouldTrackValue(href) && href;
26903 }
26904
26905 if (isElementBlocked(el, ev, blockElementCallback, blockSelectors)) {
26906 explicitNoTrack = true;
26907 }
26908
26909 elementsJson.push(getPropertiesFromElement(el, ev, blockAttrsSet, captureExtraAttrs, allowElementCallback, allowSelectors));
26910 }, this);
26911
26912 if (!explicitNoTrack) {
26913 var docElement = document$1['documentElement'];
26914 props = {
26915 '$event_type': ev.type,
26916 '$host': win.location.host,
26917 '$pathname': win.location.pathname,
26918 '$elements': elementsJson,
26919 '$el_attr__href': href,
26920 '$viewportHeight': Math.max(docElement['clientHeight'], win['innerHeight'] || 0),
26921 '$viewportWidth': Math.max(docElement['clientWidth'], win['innerWidth'] || 0),
26922 '$pageHeight': document$1['body']['offsetHeight'] || 0,
26923 '$pageWidth': document$1['body']['offsetWidth'] || 0,
26924 };
26925 _.each(captureExtraAttrs, function(attr) {
26926 if (!blockAttrsSet[attr] && target.hasAttribute(attr)) {
26927 var attrVal = target.getAttribute(attr);
26928 if (shouldTrackValue(attrVal)) {
26929 props['$el_attr__' + attr] = attrVal;
26930 }
26931 }
26932 });
26933
26934 if (captureTextContent) {
26935 elementText = getSafeText(target, ev, allowElementCallback, allowSelectors);
26936 if (elementText && elementText.length) {
26937 props['$el_text'] = elementText;
26938 }
26939 }
26940
26941 if (ev.type === EV_CLICK) {
26942 _.each(CLICK_EVENT_PROPS, function(prop) {
26943 if (prop in ev) {
26944 props['$' + prop] = ev[prop];
26945 }
26946 });
26947 if (capturedForHeatMap) {
26948 props['$captured_for_heatmap'] = true;
26949 }
26950 target = guessRealClickTarget(ev);
26951 }
26952 // prioritize text content from "real" click target if different from original target
26953 if (captureTextContent) {
26954 var elementText = getSafeText(target, ev, allowElementCallback, allowSelectors);
26955 if (elementText && elementText.length) {
26956 props['$el_text'] = elementText;
26957 }
26958 }
26959
26960 if (target) {
26961 // target may have been recalculated; check allowlists and blocklists again
26962 if (
26963 !isElementAllowed(target, ev, allowElementCallback, allowSelectors) ||
26964 isElementBlocked(target, ev, blockElementCallback, blockSelectors)
26965 ) {
26966 return null;
26967 }
26968
26969 var targetProps = getPropertiesFromElement(target, ev, blockAttrsSet, captureExtraAttrs, allowElementCallback, allowSelectors);
26970 props['$target'] = targetProps;
26971 // pull up more props onto main event props
26972 props['$el_classes'] = targetProps['$classes'];
26973 _.extend(props, _.strip_empty_properties({
26974 '$el_id': targetProps['$id'],
26975 '$el_tag_name': targetProps['$tag_name']
26976 }));
26977 }
26978 }
26979 }
26980
26981 return props;
26982 }
26983
26984
26985 /**
26986 * Get the direct text content of an element, protecting against sensitive data collection.
26987 * Concats textContent of each of the element's text node children; this avoids potential
26988 * collection of sensitive data that could happen if we used element.textContent and the
26989 * element had sensitive child elements, since element.textContent includes child content.
26990 * Scrubs values that look like they could be sensitive (i.e. cc or ssn number).
26991 * @param {Element} el - element to get the text of
26992 * @param {Array<string>} allowSelectors - CSS selectors for elements that should be included
26993 * @returns {string} the element's direct text content
26994 */
26995 function getSafeText(el, ev, allowElementCallback, allowSelectors) {
26996 var elText = '';
26997
26998 if (shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors) && el.childNodes && el.childNodes.length) {
26999 _.each(el.childNodes, function(child) {
27000 if (isTextNode(child) && child.textContent) {
27001 elText += _.trim(child.textContent)
27002 // scrub potentially sensitive values
27003 .split(/(\s+)/).filter(shouldTrackValue).join('')
27004 // normalize whitespace
27005 .replace(/[\r\n]/g, ' ').replace(/[ ]+/g, ' ')
27006 // truncate
27007 .substring(0, 255);
27008 }
27009 });
27010 }
27011
27012 return _.trim(elText);
27013 }
27014
27015 function guessRealClickTarget(ev) {
27016 var target = ev.target;
27017 var composedPath = ev['composedPath']();
27018 for (var i = 0; i < composedPath.length; i++) {
27019 var node = composedPath[i];
27020 if (
27021 isTag(node, 'a') ||
27022 isTag(node, 'button') ||
27023 isTag(node, 'input') ||
27024 isTag(node, 'select') ||
27025 (node.getAttribute && node.getAttribute('role') === 'button')
27026 ) {
27027 target = node;
27028 break;
27029 }
27030 if (node === target) {
27031 break;
27032 }
27033 }
27034 return target;
27035 }
27036
27037 function isElementAllowed(el, ev, allowElementCallback, allowSelectors) {
27038 if (allowElementCallback) {
27039 try {
27040 if (!allowElementCallback(el, ev)) {
27041 return false;
27042 }
27043 } catch (err) {
27044 logger$1.critical('Error while checking element in allowElementCallback', err);
27045 return false;
27046 }
27047 }
27048
27049 if (!allowSelectors.length) {
27050 // no allowlist; all elements are fair game
27051 return true;
27052 }
27053
27054 for (var i = 0; i < allowSelectors.length; i++) {
27055 var sel = allowSelectors[i];
27056 try {
27057 if (el['matches'](sel)) {
27058 return true;
27059 }
27060 } catch (err) {
27061 logger$1.critical('Error while checking selector: ' + sel, err);
27062 }
27063 }
27064 return false;
27065 }
27066
27067 function isElementBlocked(el, ev, blockElementCallback, blockSelectors) {
27068 var i;
27069
27070 if (blockElementCallback) {
27071 try {
27072 if (blockElementCallback(el, ev)) {
27073 return true;
27074 }
27075 } catch (err) {
27076 logger$1.critical('Error while checking element in blockElementCallback', err);
27077 return true;
27078 }
27079 }
27080
27081 if (blockSelectors && blockSelectors.length) {
27082 // programmatically prevent tracking of elements that match CSS selectors
27083 for (i = 0; i < blockSelectors.length; i++) {
27084 var sel = blockSelectors[i];
27085 try {
27086 if (el['matches'](sel)) {
27087 return true;
27088 }
27089 } catch (err) {
27090 logger$1.critical('Error while checking selector: ' + sel, err);
27091 }
27092 }
27093 }
27094
27095 // allow users to programmatically prevent tracking of elements by adding default classes such as 'mp-no-track'
27096 var classes = getClasses(el);
27097 for (i = 0; i < OPT_OUT_CLASSES.length; i++) {
27098 if (classes[OPT_OUT_CLASSES[i]]) {
27099 return true;
27100 }
27101 }
27102
27103 return false;
27104 }
27105
27106 /*
27107 * Check whether a DOM node has nodeType Node.ELEMENT_NODE
27108 * @param {Node} node - node to check
27109 * @returns {boolean} whether node is of the correct nodeType
27110 */
27111 function isElementNode(node) {
27112 return node && node.nodeType === 1; // Node.ELEMENT_NODE - use integer constant for browser portability
27113 }
27114
27115 /*
27116 * Check whether an element is of a given tag type.
27117 * Due to potential reference discrepancies (such as the webcomponents.js polyfill),
27118 * we want to match tagNames instead of specific references because something like
27119 * element === document.body won't always work because element might not be a native
27120 * element.
27121 * @param {Element} el - element to check
27122 * @param {string} tag - tag name (e.g., "div")
27123 * @returns {boolean} whether el is of the given tag type
27124 */
27125 function isTag(el, tag) {
27126 return el && el.tagName && el.tagName.toLowerCase() === tag.toLowerCase();
27127 }
27128
27129 /*
27130 * Check whether a DOM node is a TEXT_NODE
27131 * @param {Node} node - node to check
27132 * @returns {boolean} whether node is of type Node.TEXT_NODE
27133 */
27134 function isTextNode(node) {
27135 return node && node.nodeType === 3; // Node.TEXT_NODE - use integer constant for browser portability
27136 }
27137
27138 function minDOMApisSupported() {
27139 try {
27140 var testEl = document$1.createElement('div');
27141 return !!testEl['matches'];
27142 } catch (err) {
27143 return false;
27144 }
27145 }
27146
27147 function weakSetSupported() {
27148 return typeof WeakSet !== 'undefined';
27149 }
27150
27151 /*
27152 * Check whether a DOM event should be "tracked" or if it may contain sensitive data
27153 * using a variety of heuristics.
27154 * @param {Element} el - element to check
27155 * @param {Event} ev - event to check
27156 * @returns {boolean} whether the event should be tracked
27157 */
27158 function shouldTrackDomEvent(el, ev) {
27159 if (!el || isTag(el, 'html') || !isElementNode(el)) {
27160 return false;
27161 }
27162 var tag = el.tagName.toLowerCase();
27163 switch (tag) {
27164 case 'form':
27165 return ev.type === EV_SUBMIT;
27166 case 'input':
27167 if (['button', 'submit'].indexOf(el.getAttribute('type')) === -1) {
27168 return ev.type === EV_CHANGE;
27169 } else {
27170 return ev.type === EV_CLICK;
27171 }
27172 case 'select':
27173 case 'textarea':
27174 return ev.type === EV_CHANGE;
27175 default:
27176 return ev.type === EV_CLICK;
27177 }
27178 }
27179
27180 /*
27181 * Check whether a DOM element should be "tracked" or if it may contain sensitive data
27182 * using a variety of heuristics.
27183 * @param {Element} el - element to check
27184 * @param {Array<string>} allowSelectors - CSS selectors for elements that should be included
27185 * @returns {boolean} whether the element should be tracked
27186 */
27187 function shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors) {
27188 var i;
27189
27190 if (!isElementAllowed(el, ev, allowElementCallback, allowSelectors)) {
27191 return false;
27192 }
27193
27194 for (var curEl = el; curEl.parentNode && !isTag(curEl, 'body'); curEl = curEl.parentNode) {
27195 var classes = getClasses(curEl);
27196 for (i = 0; i < SENSITIVE_DATA_CLASSES.length; i++) {
27197 if (classes[SENSITIVE_DATA_CLASSES[i]]) {
27198 return false;
27199 }
27200 }
27201 }
27202
27203 var elClasses = getClasses(el);
27204 for (i = 0; i < OPT_IN_CLASSES.length; i++) {
27205 if (elClasses[OPT_IN_CLASSES[i]]) {
27206 return true;
27207 }
27208 }
27209
27210 // don't send data from inputs or similar elements since there will always be
27211 // a risk of clientside javascript placing sensitive data in attributes
27212 if (
27213 isTag(el, 'input') ||
27214 isTag(el, 'select') ||
27215 isTag(el, 'textarea') ||
27216 el.getAttribute('contenteditable') === 'true'
27217 ) {
27218 return false;
27219 }
27220
27221 // don't include hidden or password fields
27222 var type = el.type || '';
27223 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"]
27224 switch(type.toLowerCase()) {
27225 case 'hidden':
27226 return false;
27227 case 'password':
27228 return false;
27229 }
27230 }
27231
27232 // filter out data from fields that look like sensitive fields
27233 var name = el.name || el.id || '';
27234 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"]
27235 var sensitiveNameRegex = /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i;
27236 if (sensitiveNameRegex.test(name.replace(/[^a-zA-Z0-9]/g, ''))) {
27237 return false;
27238 }
27239 }
27240
27241 return true;
27242 }
27243
27244
27245 /*
27246 * Check whether a string value should be "tracked" or if it may contain sensitive data
27247 * using a variety of heuristics.
27248 * @param {string} value - string value to check
27249 * @returns {boolean} whether the element should be tracked
27250 */
27251 function shouldTrackValue(value) {
27252 if (value === null || _.isUndefined(value)) {
27253 return false;
27254 }
27255
27256 if (typeof value === 'string') {
27257 value = _.trim(value);
27258
27259 // check to see if input value looks like a credit card number
27260 // see: https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9781449327453/ch04s20.html
27261 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}))$/;
27262 if (ccRegex.test((value || '').replace(/[- ]/g, ''))) {
27263 return false;
27264 }
27265
27266 // check to see if input value looks like a social security number
27267 var ssnRegex = /(^\d{3}-?\d{2}-?\d{4}$)/;
27268 if (ssnRegex.test(value)) {
27269 return false;
27270 }
27271 }
27272
27273 return true;
27274 }
27275
27276 /**
27277 * Creates a cross-browser compatible scroll end function with appropriate event listener.
27278 * For browsers that support scrollend, returns the original function with scrollend event.
27279 * For browsers without scrollend support, returns a debounced function that triggers
27280 * 100ms after the last scroll event to simulate scrollend behavior.
27281 * @param {Function} originalFunction - The function to call when scrolling ends
27282 * @returns {Object} Object containing listener function and eventType string
27283 * @returns {Function} returns.listener - The wrapped function to use as event listener
27284 * @returns {string} returns.eventType - The event type to listen for ('scrollend' or 'scroll')
27285 */
27286 function getPolyfillScrollEndFunction(originalFunction) {
27287 var supportsScrollEnd = 'onscrollend' in win;
27288 var polyfillFunction = safewrap(originalFunction);
27289 var polyfillEvent = EV_SCROLLEND;
27290 if (!supportsScrollEnd) {
27291 // Polyfill for browsers without scrollend support: wait 100ms after the last scroll event
27292 // https://developer.chrome.com/blog/scrollend-a-new-javascript-event
27293 var scrollTimer = null;
27294 var scrollDelayMs = 100;
27295
27296 polyfillFunction = safewrap(function() {
27297 clearTimeout(scrollTimer);
27298 scrollTimer = setTimeout(originalFunction, scrollDelayMs);
27299 });
27300
27301 polyfillEvent = EV_SCROLL;
27302 }
27303
27304 return {
27305 listener: polyfillFunction,
27306 eventType: polyfillEvent
27307 };
27308 }
27309
27310 function hasInlineEventHandlers(element) {
27311 for (var i = 0; i < EVENT_HANDLER_ATTRIBUTES.length; i++) {
27312 if (element.hasAttribute(EVENT_HANDLER_ATTRIBUTES[i])) {
27313 return true;
27314 }
27315 }
27316 return false;
27317 }
27318
27319 function hasInteractiveAriaRole(element) {
27320 var role = element.getAttribute('role');
27321 if (!role) return false;
27322
27323 // Handle invalid markup where multiple roles might be specified
27324 // Only the first token is recognized per ARIA spec
27325 var primaryRole = role.trim().split(/\s+/)[0].toLowerCase();
27326
27327 return INTERACTIVE_ARIA_ROLES[primaryRole];
27328 }
27329
27330 function hasAnyInteractivityIndicators(element) {
27331 var tagName = element.tagName.toLowerCase();
27332
27333 // Check for interactive HTML elements
27334 if (tagName === 'button' ||
27335 tagName === 'input' ||
27336 tagName === 'select' ||
27337 tagName === 'textarea' ||
27338 tagName === 'details' ||
27339 tagName === 'dialog') {
27340 return true;
27341 }
27342
27343 if (element.isContentEditable) {
27344 return true;
27345 }
27346
27347 if (element.onclick || element.onmousedown || element.onmouseup || element.ontouchstart || element.ontouchend) {
27348 return true;
27349 }
27350
27351 if (hasInlineEventHandlers(element)) {
27352 return true;
27353 }
27354
27355 if (hasInteractiveAriaRole(element)) {
27356 return true;
27357 }
27358
27359 if (tagName === 'a' && element.hasAttribute('href')) {
27360 return true;
27361 }
27362
27363 if (element.hasAttribute('tabindex')) {
27364 return true;
27365 }
27366
27367 return false;
27368 }
27369
27370
27371 function isDefinitelyNonInteractive(element) {
27372 if (!element || !element.tagName) {
27373 return true;
27374 }
27375
27376 var tagName = element.tagName.toLowerCase();
27377
27378 // These tags are definitely non-interactive
27379 if (ALWAYS_NON_INTERACTIVE_TAGS[tagName]) {
27380 return true;
27381 }
27382
27383 // For all other elements, we can only be certain they're non-interactive if they lack ALL indicators of interactivity
27384 // Check for any signs of interactivity
27385 if (hasAnyInteractivityIndicators(element)) {
27386 return false;
27387 }
27388
27389 // Check parent chain for interactive context
27390 var parent = element.parentElement;
27391 var depth = 0;
27392
27393 while (parent && depth < MAX_DEPTH) {
27394 if (hasAnyInteractivityIndicators(parent)) {
27395 return false; // Element is inside an interactive parent
27396 }
27397
27398 if (parent.getRootNode && parent.getRootNode() !== document$1) {
27399 var root = parent.getRootNode();
27400 if (root.host && hasAnyInteractivityIndicators(root.host)) {
27401 return false; // Inside an interactive shadow host
27402 }
27403 }
27404
27405 parent = parent.parentElement;
27406 depth++;
27407 }
27408
27409 // Pure text containers without any interactive context
27410 if (TEXT_CONTAINER_TAGS[tagName]) {
27411 // These are non-interactive ONLY if they have no interactive indicators (already checked as part of hasAnyInteractivityIndicators)
27412 return true;
27413 }
27414
27415 // Default: we can't be certain it's non-interactive
27416 return false;
27417 }
27418
27419 /** @const */ var DEFAULT_RAGE_CLICK_THRESHOLD_PX = 30;
27420 /** @const */ var DEFAULT_RAGE_CLICK_TIMEOUT_MS = 1000;
27421 /** @const */ var DEFAULT_RAGE_CLICK_CLICK_COUNT = 4;
27422
27423 function RageClickTracker() {
27424 this.clicks = [];
27425 }
27426
27427 RageClickTracker.prototype.isRageClick = function(x, y, options) {
27428 options = options || {};
27429 var thresholdPx = options['threshold_px'] || DEFAULT_RAGE_CLICK_THRESHOLD_PX;
27430 var timeoutMs = options['timeout_ms'] || DEFAULT_RAGE_CLICK_TIMEOUT_MS;
27431 var clickCount = options['click_count'] || DEFAULT_RAGE_CLICK_CLICK_COUNT;
27432 var timestamp = Date.now();
27433
27434 var lastClick = this.clicks[this.clicks.length - 1];
27435 if (
27436 lastClick &&
27437 timestamp - lastClick.timestamp < timeoutMs &&
27438 Math.sqrt(Math.pow(x - lastClick.x, 2) + Math.pow(y - lastClick.y, 2)) < thresholdPx
27439 ) {
27440 this.clicks.push({ x: x, y: y, timestamp: timestamp });
27441 if (this.clicks.length >= clickCount) {
27442 this.clicks = [];
27443 return true;
27444 }
27445 } else {
27446 this.clicks = [{ x: x, y: y, timestamp: timestamp }];
27447 }
27448 return false;
27449 };
27450
27451 function ShadowDOMObserver(changeCallback, observerConfig) {
27452 this.changeCallback = changeCallback || function() {};
27453 this.observerConfig = observerConfig;
27454
27455 this.observedShadowRoots = null;
27456 this.shadowObservers = [];
27457 }
27458
27459 ShadowDOMObserver.prototype.getEventTarget = function(event) {
27460 if (!this.observedShadowRoots) {
27461 return;
27462 }
27463 var path = this.getComposedPath(event);
27464 if (path && path.length) {
27465 return path[0];
27466 }
27467
27468 return event['target'] || event['srcElement'];
27469 };
27470
27471
27472 ShadowDOMObserver.prototype.getComposedPath = function(event) {
27473 if ('composedPath' in event) {
27474 return event['composedPath']();
27475 }
27476
27477 return [];
27478 };
27479 ShadowDOMObserver.prototype.observeFromEvent = function(event) {
27480 if (!this.observedShadowRoots) {
27481 return;
27482 }
27483
27484 var path = this.getComposedPath(event);
27485
27486 // Check each element in path for shadow roots
27487 for (var i = 0; i < path.length; i++) {
27488 var element = path[i];
27489
27490 if (element && element.shadowRoot) {
27491 this.observeShadowRoot(element.shadowRoot);
27492 }
27493 }
27494 };
27495
27496
27497 ShadowDOMObserver.prototype.observeShadowRoot = function(shadowRoot) {
27498 if (!this.observedShadowRoots || this.observedShadowRoots.has(shadowRoot)) {
27499 return;
27500 }
27501
27502 var self = this;
27503
27504 try {
27505 this.observedShadowRoots.add(shadowRoot);
27506
27507 var observer = new window.MutationObserver(function() {
27508 self.changeCallback();
27509 });
27510
27511 observer.observe(shadowRoot, this.observerConfig);
27512 this.shadowObservers.push(observer);
27513 } catch (e) {
27514 logger$1.critical('Error while observing shadow root', e);
27515 }
27516 };
27517
27518
27519 ShadowDOMObserver.prototype.start = function() {
27520 if (this.observedShadowRoots) {
27521 return;
27522 }
27523
27524 if (!weakSetSupported()) {
27525 logger$1.critical('Shadow DOM observation unavailable: WeakSet not supported');
27526 return;
27527 }
27528
27529 this.observedShadowRoots = new WeakSet();
27530 };
27531
27532 ShadowDOMObserver.prototype.stop = function() {
27533 if (!this.observedShadowRoots) {
27534 return;
27535 }
27536
27537 for (var i = 0; i < this.shadowObservers.length; i++) {
27538 try {
27539 this.shadowObservers[i].disconnect();
27540 } catch (e) {
27541 logger$1.critical('Error while disconnecting shadow DOM observer', e);
27542 }
27543 }
27544 this.shadowObservers = [];
27545 this.observedShadowRoots = null;
27546 };
27547
27548 /** @const */ var DEFAULT_DEAD_CLICK_TIMEOUT_MS = 500;
27549 /** @const */ var INTERACTION_EVENTS = [EV_CHANGE, EV_INPUT, EV_SUBMIT, EV_SELECT, EV_TOGGLE];
27550 /** @const */ var LAYOUT_EVENTS = [EV_SCROLLEND];
27551 /** @const */ var NAVIGATION_EVENTS = [EV_HASHCHANGE];
27552 /** @const */ var MUTATION_OBSERVER_CONFIG = {
27553 characterData: true,
27554 childList: true,
27555 subtree: true,
27556 attributes: true,
27557 attributeFilter: ['style', 'class', 'hidden', 'checked', 'selected', 'value', 'display', 'visibility']
27558 };
27559
27560
27561 function DeadClickTracker(onDeadClickCallback) {
27562 this.eventListeners = [];
27563 this.mutationObserver = null;
27564 this.shadowDOMObserver = null;
27565
27566 this.isTracking = false;
27567 this.lastChangeEventTimestamp = 0;
27568 this.pendingClicks = [];
27569 this.onDeadClickCallback = onDeadClickCallback;
27570 this.processingActive = false;
27571 this.processingTimeout = null;
27572 }
27573
27574
27575 DeadClickTracker.prototype.addClick = function(event) {
27576 var element = this.shadowDOMObserver && this.shadowDOMObserver.getEventTarget(event);
27577
27578 if (!element) {
27579 element = event['target'] || event['srcElement'];
27580 }
27581
27582 if (!element || isDefinitelyNonInteractive(element)) {
27583 return false;
27584 }
27585
27586 if (this.shadowDOMObserver) {
27587 this.shadowDOMObserver.observeFromEvent(event);
27588 }
27589 this.pendingClicks.push({
27590 element: element,
27591 event: event,
27592 timestamp: Date.now()
27593 });
27594 return true;
27595 };
27596
27597 DeadClickTracker.prototype.trackClick = function(event, config) {
27598 if (!this.isTracking) {
27599 return false;
27600 }
27601
27602 var added = this.addClick(event);
27603 if (added) {
27604 this.triggerProcessing(config);
27605 }
27606 return added;
27607 };
27608
27609 DeadClickTracker.prototype.getDeadClicks = function(config) {
27610 if (this.pendingClicks.length === 0) {
27611 return [];
27612 }
27613
27614 var timeoutMs = config['timeout_ms'];
27615 var now = Date.now();
27616 var clicksToEvaluate = this.pendingClicks.slice(); // Copy array
27617 this.pendingClicks = []; // Clear original
27618
27619 var deadClicks = [];
27620
27621 for (var i = 0; i < clicksToEvaluate.length; i++) {
27622 var click = clicksToEvaluate[i];
27623
27624 if (now - click.timestamp >= timeoutMs) {
27625 // Click has exceeded timeout, check if it's dead by looking for changes after this specific click
27626 if (!this.hasChangesAfter(click.timestamp)) {
27627 deadClicks.push(click);
27628 }
27629 } else {
27630 // Still pending - add back
27631 this.pendingClicks.push(click);
27632 }
27633 }
27634
27635 return deadClicks;
27636 };
27637
27638 DeadClickTracker.prototype.hasChangesAfter = function(timestamp) {
27639 // 100ms tolerance for race condition between when we record the click and the change event
27640 return this.lastChangeEventTimestamp >= (timestamp - 100);
27641 };
27642
27643 DeadClickTracker.prototype.recordChangeEvent = function() {
27644 this.lastChangeEventTimestamp = Date.now();
27645 };
27646
27647 DeadClickTracker.prototype.triggerProcessing = function(config) {
27648 // Prevent multiple concurrent processing chains
27649 if (this.processingActive) {
27650 return;
27651 }
27652 this.processingActive = true;
27653 this.processRecursively(config);
27654 };
27655
27656 DeadClickTracker.prototype.processRecursively = function(config) {
27657 if (!this.isTracking || !this.onDeadClickCallback) {
27658 this.processingActive = false;
27659 return;
27660 }
27661
27662 var timeoutMs = config['timeout_ms'];
27663 var self = this;
27664
27665 this.processingTimeout = setTimeout(function() {
27666 if (!self.processingActive) {
27667 return;
27668 }
27669
27670 var deadClicks = self.getDeadClicks(config);
27671
27672 for (var i = 0; i < deadClicks.length; i++) {
27673 self.onDeadClickCallback(deadClicks[i].event);
27674 }
27675
27676 if (self.pendingClicks.length > 0) {
27677 self.processRecursively(config);
27678 } else {
27679 self.processingActive = false;
27680 }
27681 }, timeoutMs);
27682 };
27683
27684 DeadClickTracker.prototype.startTracking = function() {
27685 if (this.isTracking) {
27686 return;
27687 }
27688
27689 this.isTracking = true;
27690
27691 var self = this;
27692
27693 INTERACTION_EVENTS.forEach(function(event) {
27694 var handler = function() {
27695 self.recordChangeEvent();
27696 };
27697 document.addEventListener(event, handler, { capture: true, passive: true });
27698 self.eventListeners.push({ target: document, event: event, handler: handler, options: { capture: true, passive: true } });
27699 });
27700 NAVIGATION_EVENTS.forEach(function(event) {
27701 var handler = function() {
27702 self.recordChangeEvent();
27703 };
27704 window.addEventListener(event, handler);
27705 self.eventListeners.push({ target: window, event: event, handler: handler });
27706 });
27707 LAYOUT_EVENTS.forEach(function(event) {
27708 var handler = function() {
27709 self.recordChangeEvent();
27710 };
27711 window.addEventListener(event, handler, { passive: true });
27712 self.eventListeners.push({ target: window, event: event, handler: handler, options: { passive: true } });
27713 });
27714 var selectionHandler = function() {
27715 self.recordChangeEvent();
27716 };
27717 document.addEventListener('selectionchange', selectionHandler);
27718 self.eventListeners.push({ target: document, event: 'selectionchange', handler: selectionHandler });
27719
27720 // Set up MutationObserver
27721 if (window.MutationObserver) {
27722 try {
27723 this.mutationObserver = new window.MutationObserver(function() {
27724 self.recordChangeEvent();
27725 });
27726
27727 this.mutationObserver.observe(document.body || document.documentElement, MUTATION_OBSERVER_CONFIG);
27728 } catch (e) {
27729 logger$1.critical('Error while setting up mutation observer', e);
27730 }
27731 }
27732
27733 // Set up Shadow DOM observer
27734 if (window.customElements) {
27735 try {
27736 this.shadowDOMObserver = new ShadowDOMObserver(
27737 function() {
27738 self.recordChangeEvent();
27739 },
27740 MUTATION_OBSERVER_CONFIG
27741 );
27742 this.shadowDOMObserver.start();
27743 } catch (e) {
27744 logger$1.critical('Error while setting up shadow DOM observer', e);
27745 this.shadowDOMObserver = null;
27746 }
27747 }
27748 };
27749
27750 DeadClickTracker.prototype.stopTracking = function() {
27751 if (!this.isTracking) {
27752 return;
27753 }
27754
27755 this.isTracking = false;
27756 this.pendingClicks = [];
27757 this.lastChangeEventTimestamp = 0;
27758 this.processingActive = false;
27759
27760 if (this.processingTimeout) {
27761 clearTimeout(this.processingTimeout);
27762 this.processingTimeout = null;
27763 }
27764
27765 // Remove all event listeners
27766 for (var i = 0; i < this.eventListeners.length; i++) {
27767 var listener = this.eventListeners[i];
27768 try {
27769 listener.target.removeEventListener(listener.event, listener.handler, listener.options);
27770 } catch (e) {
27771 logger$1.critical('Error while removing event listener', e);
27772 }
27773 }
27774 this.eventListeners = [];
27775
27776 if (this.mutationObserver) {
27777 try {
27778 this.mutationObserver.disconnect();
27779 } catch (e) {
27780 logger$1.critical('Error while disconnecting mutation observer', e);
27781 }
27782 this.mutationObserver = null;
27783 }
27784
27785 if (this.shadowDOMObserver) {
27786 try {
27787 this.shadowDOMObserver.stop();
27788 } catch (e) {
27789 logger$1.critical('Error while stopping shadow DOM observer', e);
27790 }
27791 this.shadowDOMObserver = null;
27792 }
27793 };
27794
27795 var AUTOCAPTURE_CONFIG_KEY = 'autocapture';
27796 var LEGACY_PAGEVIEW_CONFIG_KEY = 'track_pageview';
27797
27798 var PAGEVIEW_OPTION_FULL_URL = 'full-url';
27799 var PAGEVIEW_OPTION_URL_WITH_PATH_AND_QUERY_STRING = 'url-with-path-and-query-string';
27800 var PAGEVIEW_OPTION_URL_WITH_PATH = 'url-with-path';
27801
27802 var CONFIG_ALLOW_ELEMENT_CALLBACK = 'allow_element_callback';
27803 var CONFIG_ALLOW_SELECTORS = 'allow_selectors';
27804 var CONFIG_ALLOW_URL_REGEXES = 'allow_url_regexes';
27805 var CONFIG_BLOCK_ATTRS = 'block_attrs';
27806 var CONFIG_BLOCK_ELEMENT_CALLBACK = 'block_element_callback';
27807 var CONFIG_BLOCK_SELECTORS = 'block_selectors';
27808 var CONFIG_BLOCK_URL_REGEXES = 'block_url_regexes';
27809 var CONFIG_CAPTURE_EXTRA_ATTRS = 'capture_extra_attrs';
27810 var CONFIG_CAPTURE_TEXT_CONTENT = 'capture_text_content';
27811 var CONFIG_SCROLL_CAPTURE_ALL = 'scroll_capture_all';
27812 var CONFIG_SCROLL_CHECKPOINTS = 'scroll_depth_percent_checkpoints';
27813 var CONFIG_TRACK_CLICK = 'click';
27814 var CONFIG_TRACK_DEAD_CLICK = 'dead_click';
27815 var CONFIG_TRACK_INPUT = 'input';
27816 var CONFIG_TRACK_PAGEVIEW = 'pageview';
27817 var CONFIG_TRACK_RAGE_CLICK = 'rage_click';
27818 var CONFIG_TRACK_SCROLL = 'scroll';
27819 var CONFIG_TRACK_PAGE_LEAVE = 'page_leave';
27820 var CONFIG_TRACK_SUBMIT = 'submit';
27821
27822 var CONFIG_DEFAULTS$1 = {};
27823 CONFIG_DEFAULTS$1[CONFIG_ALLOW_SELECTORS] = [];
27824 CONFIG_DEFAULTS$1[CONFIG_ALLOW_URL_REGEXES] = [];
27825 CONFIG_DEFAULTS$1[CONFIG_BLOCK_ATTRS] = [];
27826 CONFIG_DEFAULTS$1[CONFIG_BLOCK_ELEMENT_CALLBACK] = null;
27827 CONFIG_DEFAULTS$1[CONFIG_BLOCK_SELECTORS] = [];
27828 CONFIG_DEFAULTS$1[CONFIG_BLOCK_URL_REGEXES] = [];
27829 CONFIG_DEFAULTS$1[CONFIG_CAPTURE_EXTRA_ATTRS] = [];
27830 CONFIG_DEFAULTS$1[CONFIG_CAPTURE_TEXT_CONTENT] = false;
27831 CONFIG_DEFAULTS$1[CONFIG_SCROLL_CAPTURE_ALL] = false;
27832 CONFIG_DEFAULTS$1[CONFIG_SCROLL_CHECKPOINTS] = [25, 50, 75, 100];
27833 CONFIG_DEFAULTS$1[CONFIG_TRACK_CLICK] = true;
27834 CONFIG_DEFAULTS$1[CONFIG_TRACK_DEAD_CLICK] = true;
27835 CONFIG_DEFAULTS$1[CONFIG_TRACK_INPUT] = true;
27836 CONFIG_DEFAULTS$1[CONFIG_TRACK_PAGEVIEW] = PAGEVIEW_OPTION_FULL_URL;
27837 CONFIG_DEFAULTS$1[CONFIG_TRACK_RAGE_CLICK] = true;
27838 CONFIG_DEFAULTS$1[CONFIG_TRACK_SCROLL] = true;
27839 CONFIG_DEFAULTS$1[CONFIG_TRACK_PAGE_LEAVE] = false;
27840 CONFIG_DEFAULTS$1[CONFIG_TRACK_SUBMIT] = true;
27841
27842 var DEFAULT_PROPS = {
27843 '$mp_autocapture': true
27844 };
27845
27846 var MP_EV_CLICK = '$mp_click';
27847 var MP_EV_DEAD_CLICK = '$mp_dead_click';
27848 var MP_EV_INPUT = '$mp_input_change';
27849 var MP_EV_RAGE_CLICK = '$mp_rage_click';
27850 var MP_EV_SCROLL = '$mp_scroll';
27851 var MP_EV_SUBMIT = '$mp_submit';
27852 var MP_EV_PAGE_LEAVE = '$mp_page_leave';
27853
27854 /**
27855 * Autocapture: manages automatic event tracking
27856 * @constructor
27857 */
27858 var Autocapture = function(mp) {
27859 this.mp = mp;
27860 this.maxScrollViewDepth = 0;
27861 this.hasTrackedScrollSession = false;
27862 this.previousScrollHeight = 0;
27863 };
27864
27865 Autocapture.prototype.init = function() {
27866 if (!minDOMApisSupported()) {
27867 logger$1.critical('Autocapture unavailable: missing required DOM APIs');
27868 return;
27869 }
27870 this.initPageListeners();
27871 this.initPageviewTracking();
27872 this.initClickTracking();
27873 this.initDeadClickTracking();
27874 this.initInputTracking();
27875 this.initScrollTracking();
27876 this.initSubmitTracking();
27877 this.initRageClickTracking();
27878 this.initPageLeaveTracking();
27879 };
27880
27881 Autocapture.prototype.getFullConfig = function() {
27882 var autocaptureConfig = this.mp.get_config(AUTOCAPTURE_CONFIG_KEY);
27883 if (!autocaptureConfig) {
27884 // Autocapture is completely off
27885 return {};
27886 } else if (_.isObject(autocaptureConfig)) {
27887 return _.extend({}, CONFIG_DEFAULTS$1, autocaptureConfig);
27888 } else {
27889 // Autocapture config is non-object truthy value, return default
27890 return CONFIG_DEFAULTS$1;
27891 }
27892 };
27893
27894 Autocapture.prototype.getConfig = function(key) {
27895 return this.getFullConfig()[key];
27896 };
27897
27898 Autocapture.prototype.currentUrlBlocked = function() {
27899 var i;
27900 var currentUrl = _.info.currentUrl();
27901
27902 var allowUrlRegexes = this.getConfig(CONFIG_ALLOW_URL_REGEXES) || [];
27903 if (allowUrlRegexes.length) {
27904 // we're using an allowlist, only track if current URL matches
27905 var allowed = false;
27906 for (i = 0; i < allowUrlRegexes.length; i++) {
27907 var allowRegex = allowUrlRegexes[i];
27908 try {
27909 if (currentUrl.match(allowRegex)) {
27910 allowed = true;
27911 break;
27912 }
27913 } catch (err) {
27914 logger$1.critical('Error while checking block URL regex: ' + allowRegex, err);
27915 return true;
27916 }
27917 }
27918 if (!allowed) {
27919 // wasn't allowed by any regex
27920 return true;
27921 }
27922 }
27923
27924 var blockUrlRegexes = this.getConfig(CONFIG_BLOCK_URL_REGEXES) || [];
27925 if (!blockUrlRegexes || !blockUrlRegexes.length) {
27926 return false;
27927 }
27928
27929 for (i = 0; i < blockUrlRegexes.length; i++) {
27930 try {
27931 if (currentUrl.match(blockUrlRegexes[i])) {
27932 return true;
27933 }
27934 } catch (err) {
27935 logger$1.critical('Error while checking block URL regex: ' + blockUrlRegexes[i], err);
27936 return true;
27937 }
27938 }
27939 return false;
27940 };
27941
27942 Autocapture.prototype.pageviewTrackingConfig = function() {
27943 // supports both autocapture config and old track_pageview config
27944 if (this.mp.get_config(AUTOCAPTURE_CONFIG_KEY)) {
27945 return this.getConfig(CONFIG_TRACK_PAGEVIEW);
27946 } else {
27947 return this.mp.get_config(LEGACY_PAGEVIEW_CONFIG_KEY);
27948 }
27949 };
27950
27951 // helper for event handlers
27952 Autocapture.prototype.trackDomEvent = function(ev, mpEventName) {
27953 if (this.currentUrlBlocked()) {
27954 return;
27955 }
27956
27957 var isCapturedForHeatMap = this.mp.is_recording_heatmap_data() && (
27958 (mpEventName === MP_EV_CLICK && !this.getConfig(CONFIG_TRACK_CLICK)) ||
27959 (mpEventName === MP_EV_RAGE_CLICK && !this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK)) ||
27960 (mpEventName === MP_EV_DEAD_CLICK && !this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK))
27961 );
27962
27963 var props = getPropsForDOMEvent(ev, {
27964 allowElementCallback: this.getConfig(CONFIG_ALLOW_ELEMENT_CALLBACK),
27965 allowSelectors: this.getConfig(CONFIG_ALLOW_SELECTORS),
27966 blockAttrs: this.getConfig(CONFIG_BLOCK_ATTRS),
27967 blockElementCallback: this.getConfig(CONFIG_BLOCK_ELEMENT_CALLBACK),
27968 blockSelectors: this.getConfig(CONFIG_BLOCK_SELECTORS),
27969 captureExtraAttrs: this.getConfig(CONFIG_CAPTURE_EXTRA_ATTRS),
27970 captureTextContent: this.getConfig(CONFIG_CAPTURE_TEXT_CONTENT),
27971 capturedForHeatMap: isCapturedForHeatMap,
27972 });
27973 if (props) {
27974 _.extend(props, DEFAULT_PROPS);
27975 this.mp.track(mpEventName, props);
27976 }
27977 };
27978
27979 Autocapture.prototype.initPageListeners = function() {
27980 win.removeEventListener(EV_POPSTATE, this.listenerPopstate);
27981 win.removeEventListener(EV_HASHCHANGE, this.listenerHashchange);
27982
27983 if (!this.pageviewTrackingConfig() && !this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.get_config('record_heatmap_data')) {
27984 // These are all the configs that use these listeners
27985 return;
27986 }
27987
27988 this.listenerPopstate = function() {
27989 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
27990 };
27991 this.listenerHashchange = function() {
27992 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
27993 };
27994
27995 win.addEventListener(EV_POPSTATE, this.listenerPopstate);
27996 win.addEventListener(EV_HASHCHANGE, this.listenerHashchange);
27997 var nativePushState = win.history.pushState;
27998 if (typeof nativePushState === 'function') {
27999 win.history.pushState = function(state, unused, url) {
28000 nativePushState.call(win.history, state, unused, url);
28001 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
28002 };
28003 }
28004 var nativeReplaceState = win.history.replaceState;
28005 if (typeof nativeReplaceState === 'function') {
28006 win.history.replaceState = function(state, unused, url) {
28007 nativeReplaceState.call(win.history, state, unused, url);
28008 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
28009 };
28010 }
28011 };
28012
28013 Autocapture.prototype._getClickTrackingConfig = function(configKey) {
28014 var config = this.getConfig(configKey);
28015
28016 if (!config) {
28017 return null; // click tracking disabled
28018 }
28019
28020 if (config === true) {
28021 return {}; // use defaults
28022 }
28023
28024 if (typeof config === 'object') {
28025 return config; // use custom configuration
28026 }
28027
28028 return {}; // fallback to defaults for any other truthy value
28029 };
28030
28031 Autocapture.prototype._trackPageLeave = function(ev, currentUrl, currentScrollHeight) {
28032 if (this.hasTrackedScrollSession) {
28033 // User has navigated away already ending their impression.
28034 return;
28035 }
28036
28037 if (!this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.is_recording_heatmap_data()) {
28038 return;
28039 }
28040
28041 this.hasTrackedScrollSession = true;
28042 var viewportHeight = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
28043 var scrollPercentage = Math.round(Math.max(this.maxScrollViewDepth - viewportHeight, 0) / (currentScrollHeight - viewportHeight) * 100);
28044 var foldLinePercentage = Math.round((viewportHeight / currentScrollHeight) * 100);
28045 if (currentScrollHeight <= viewportHeight) {
28046 // If the content fits within the viewport, consider it fully scrolled
28047 scrollPercentage = 100;
28048 foldLinePercentage = 100;
28049 }
28050
28051 var props = _.extend({
28052 '$max_scroll_view_depth': this.maxScrollViewDepth,
28053 '$max_scroll_percentage': scrollPercentage,
28054 '$fold_line_percentage': foldLinePercentage,
28055 '$scroll_height': currentScrollHeight,
28056 '$event_type': ev.type,
28057 '$current_url': currentUrl || _.info.currentUrl(),
28058 '$viewportHeight': viewportHeight, // This is the fold line
28059 '$viewportWidth': Math.max(document$1.documentElement.clientWidth, win.innerWidth || 0),
28060 '$captured_for_heatmap': this.mp.is_recording_heatmap_data()
28061 }, DEFAULT_PROPS);
28062
28063 // Send with beacon transport to ensure event is sent before unload
28064 this.mp.track(MP_EV_PAGE_LEAVE, props, {transport: 'sendBeacon'});
28065 };
28066
28067 Autocapture.prototype._initScrollDepthTracking = function() {
28068 win.removeEventListener(EV_SCROLL, this.listenerScrollDepth);
28069 win.removeEventListener(EV_SCROLLEND, this.listenerScrollDepth);
28070
28071 if (!this.mp.get_config('record_heatmap_data')) {
28072 return;
28073 }
28074
28075 logger$1.log('Initializing scroll depth tracking');
28076
28077 this.maxScrollViewDepth = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
28078
28079 var updateScrollDepth = function() {
28080 if (this.currentUrlBlocked()) {
28081 return;
28082 }
28083 var scrollViewHeight = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0) + win.scrollY;
28084 if (scrollViewHeight > this.maxScrollViewDepth) {
28085 this.maxScrollViewDepth = scrollViewHeight;
28086 }
28087 this.previousScrollHeight = document$1.body.scrollHeight;
28088 }.bind(this);
28089
28090 var scrollEndPolyfill = getPolyfillScrollEndFunction(updateScrollDepth);
28091 this.listenerScrollDepth = scrollEndPolyfill.listener;
28092 win.addEventListener(scrollEndPolyfill.eventType, this.listenerScrollDepth);
28093 };
28094
28095 Autocapture.prototype.initClickTracking = function() {
28096 win.removeEventListener(EV_CLICK, this.listenerClick);
28097
28098 if (!this.getConfig(CONFIG_TRACK_CLICK) && !this.mp.get_config('record_heatmap_data')) {
28099 return;
28100 }
28101 logger$1.log('Initializing click tracking');
28102
28103 this.listenerClick = function(ev) {
28104 if (!this.getConfig(CONFIG_TRACK_CLICK) && !this.mp.is_recording_heatmap_data()) {
28105 return;
28106 }
28107 this.trackDomEvent(ev, MP_EV_CLICK);
28108 }.bind(this);
28109 win.addEventListener(EV_CLICK, this.listenerClick);
28110 };
28111
28112 Autocapture.prototype.initDeadClickTracking = function() {
28113 var deadClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK);
28114
28115 if (!deadClickConfig && !this.mp.get_config('record_heatmap_data')) {
28116 this.stopDeadClickTracking();
28117 return;
28118 }
28119
28120 logger$1.log('Initializing dead click tracking');
28121 if (!this._deadClickTracker) {
28122 this._deadClickTracker = new DeadClickTracker(function(deadClickEvent) {
28123 this.trackDomEvent(deadClickEvent, MP_EV_DEAD_CLICK);
28124 }.bind(this));
28125 this._deadClickTracker.startTracking();
28126 }
28127
28128 if (!this.listenerDeadClick) {
28129 this.listenerDeadClick = function(ev) {
28130 var currentDeadClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK);
28131 if (!currentDeadClickConfig && !this.mp.is_recording_heatmap_data()) {
28132 return;
28133 }
28134 if (this.currentUrlBlocked()) {
28135 return;
28136 }
28137 // Normalize config to ensure timeout_ms is always set
28138 var normalizedConfig = currentDeadClickConfig || {};
28139 if (!normalizedConfig['timeout_ms']) {
28140 normalizedConfig['timeout_ms'] = DEFAULT_DEAD_CLICK_TIMEOUT_MS;
28141 }
28142 this._deadClickTracker.trackClick(ev, normalizedConfig);
28143 }.bind(this);
28144 win.addEventListener(EV_CLICK, this.listenerDeadClick);
28145 }
28146 };
28147
28148 Autocapture.prototype.initInputTracking = function() {
28149 win.removeEventListener(EV_CHANGE, this.listenerChange);
28150
28151 if (!this.getConfig(CONFIG_TRACK_INPUT)) {
28152 return;
28153 }
28154 logger$1.log('Initializing input tracking');
28155
28156 this.listenerChange = function(ev) {
28157 if (!this.getConfig(CONFIG_TRACK_INPUT)) {
28158 return;
28159 }
28160 this.trackDomEvent(ev, MP_EV_INPUT);
28161 }.bind(this);
28162 win.addEventListener(EV_CHANGE, this.listenerChange);
28163 };
28164
28165 Autocapture.prototype.initPageviewTracking = function() {
28166 win.removeEventListener(EV_MP_LOCATION_CHANGE, this.listenerLocationchange);
28167
28168 if (!this.pageviewTrackingConfig()) {
28169 return;
28170 }
28171 logger$1.log('Initializing pageview tracking');
28172
28173 var previousTrackedUrl = '';
28174 var tracked = false;
28175 if (!this.currentUrlBlocked()) {
28176 tracked = this.mp.track_pageview(DEFAULT_PROPS);
28177 }
28178 if (tracked) {
28179 previousTrackedUrl = _.info.currentUrl();
28180 }
28181
28182 this.listenerLocationchange = safewrap(function() {
28183 if (this.currentUrlBlocked()) {
28184 return;
28185 }
28186
28187 var currentUrl = _.info.currentUrl();
28188 var shouldTrack = false;
28189 var didPathChange = currentUrl.split('#')[0].split('?')[0] !== previousTrackedUrl.split('#')[0].split('?')[0];
28190 var trackPageviewOption = this.pageviewTrackingConfig();
28191 if (trackPageviewOption === PAGEVIEW_OPTION_FULL_URL) {
28192 shouldTrack = currentUrl !== previousTrackedUrl;
28193 } else if (trackPageviewOption === PAGEVIEW_OPTION_URL_WITH_PATH_AND_QUERY_STRING) {
28194 shouldTrack = currentUrl.split('#')[0] !== previousTrackedUrl.split('#')[0];
28195 } else if (trackPageviewOption === PAGEVIEW_OPTION_URL_WITH_PATH) {
28196 shouldTrack = didPathChange;
28197 }
28198
28199 if (shouldTrack) {
28200 var tracked = this.mp.track_pageview(DEFAULT_PROPS);
28201 if (tracked) {
28202 previousTrackedUrl = currentUrl;
28203 }
28204 if (didPathChange) {
28205 this.lastScrollCheckpoint = 0;
28206 logger$1.log('Path change: re-initializing scroll depth checkpoints');
28207 }
28208 }
28209 }.bind(this));
28210 win.addEventListener(EV_MP_LOCATION_CHANGE, this.listenerLocationchange);
28211 };
28212
28213 Autocapture.prototype.initRageClickTracking = function() {
28214 win.removeEventListener(EV_CLICK, this.listenerRageClick);
28215
28216 var rageClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK);
28217 if (!rageClickConfig && !this.mp.get_config('record_heatmap_data')) {
28218 return;
28219 }
28220
28221 logger$1.log('Initializing rage click tracking');
28222 if (!this._rageClickTracker) {
28223 this._rageClickTracker = new RageClickTracker();
28224 }
28225
28226 this.listenerRageClick = function(ev) {
28227 var currentRageClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK);
28228 if (!currentRageClickConfig && !this.mp.is_recording_heatmap_data()) {
28229 return;
28230 }
28231
28232 if (this.currentUrlBlocked()) {
28233 return;
28234 }
28235
28236 if (this._rageClickTracker.isRageClick(ev['pageX'], ev['pageY'], currentRageClickConfig)) {
28237 this.trackDomEvent(ev, MP_EV_RAGE_CLICK);
28238 }
28239 }.bind(this);
28240 win.addEventListener(EV_CLICK, this.listenerRageClick);
28241 };
28242
28243 Autocapture.prototype.initScrollTracking = function() {
28244 win.removeEventListener(EV_SCROLLEND, this.listenerScroll);
28245 win.removeEventListener(EV_SCROLL, this.listenerScroll);
28246
28247
28248 if (!this.getConfig(CONFIG_TRACK_SCROLL)) {
28249 return;
28250 }
28251 logger$1.log('Initializing scroll tracking');
28252 this.lastScrollCheckpoint = 0;
28253
28254 var scrollTrackFunction = function() {
28255 if (!this.getConfig(CONFIG_TRACK_SCROLL)) {
28256 return;
28257 }
28258 if (this.currentUrlBlocked()) {
28259 return;
28260 }
28261
28262 var shouldTrack = this.getConfig(CONFIG_SCROLL_CAPTURE_ALL);
28263 var scrollCheckpoints = (this.getConfig(CONFIG_SCROLL_CHECKPOINTS) || [])
28264 .slice()
28265 .sort(function(a, b) { return a - b; });
28266
28267 var scrollTop = win.scrollY;
28268 var props = _.extend({'$scroll_top': scrollTop}, DEFAULT_PROPS);
28269 try {
28270 var scrollHeight = document$1.body.scrollHeight;
28271 var scrollPercentage = Math.round((scrollTop / (scrollHeight - win.innerHeight)) * 100);
28272 props['$scroll_height'] = scrollHeight;
28273 props['$scroll_percentage'] = scrollPercentage;
28274 if (scrollPercentage > this.lastScrollCheckpoint) {
28275 for (var i = 0; i < scrollCheckpoints.length; i++) {
28276 var checkpoint = scrollCheckpoints[i];
28277 if (
28278 scrollPercentage >= checkpoint &&
28279 this.lastScrollCheckpoint < checkpoint
28280 ) {
28281 props['$scroll_checkpoint'] = checkpoint;
28282 this.lastScrollCheckpoint = checkpoint;
28283 shouldTrack = true;
28284 }
28285 }
28286 }
28287 } catch (err) {
28288 logger$1.critical('Error while calculating scroll percentage', err);
28289 }
28290 if (shouldTrack) {
28291 this.mp.track(MP_EV_SCROLL, props);
28292 }
28293 }.bind(this);
28294
28295 var scrollEndPolyfill = getPolyfillScrollEndFunction(scrollTrackFunction);
28296 this.listenerScroll = scrollEndPolyfill.listener;
28297 win.addEventListener(scrollEndPolyfill.eventType, this.listenerScroll);
28298 };
28299
28300 Autocapture.prototype.initSubmitTracking = function() {
28301 win.removeEventListener(EV_SUBMIT, this.listenerSubmit);
28302
28303 if (!this.getConfig(CONFIG_TRACK_SUBMIT)) {
28304 return;
28305 }
28306 logger$1.log('Initializing submit tracking');
28307
28308 this.listenerSubmit = function(ev) {
28309 if (!this.getConfig(CONFIG_TRACK_SUBMIT)) {
28310 return;
28311 }
28312 this.trackDomEvent(ev, MP_EV_SUBMIT);
28313 }.bind(this);
28314 win.addEventListener(EV_SUBMIT, this.listenerSubmit);
28315 };
28316
28317 Autocapture.prototype.initPageLeaveTracking = function() {
28318 // Capture page_leave both when the user navigates away from the page (visibilitychange) as well
28319 // as when they navigate to a different page within the SPA (popstate/pushstate/hashchange).
28320 document$1.removeEventListener(EV_VISIBILITYCHANGE, this.listenerPageLeaveVisibilitychange);
28321 win.removeEventListener(EV_MP_LOCATION_CHANGE, this.listenerPageLeaveLocationchange);
28322 win.removeEventListener(EV_LOAD, this.listenerPageLoad);
28323
28324 if (!this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.get_config('record_heatmap_data')) {
28325 return;
28326 }
28327
28328 logger$1.log('Initializing page visibility tracking.');
28329 this._initScrollDepthTracking();
28330 var previousTrackedUrl = _.info.currentUrl();
28331
28332 // Initialize previousScrollHeight on `load` which handles async loading
28333 // https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event
28334 this.listenerPageLoad = function() {
28335 this.previousScrollHeight = document$1.body.scrollHeight;
28336 }.bind(this);
28337 win.addEventListener(EV_LOAD, this.listenerPageLoad);
28338
28339 // Track page navigation events similar to how initPageviewTracking does it
28340 this.listenerPageLeaveLocationchange = safewrap(function(ev) {
28341 if (this.currentUrlBlocked()) {
28342 return;
28343 }
28344
28345 var currentUrl = _.info.currentUrl();
28346 // Track all URL changes including query string or fragment changes as separate scroll sessions
28347 var shouldTrack = currentUrl !== previousTrackedUrl;
28348
28349 if (shouldTrack) {
28350 this._trackPageLeave(ev, previousTrackedUrl, this.previousScrollHeight);
28351 previousTrackedUrl = currentUrl;
28352 // Fragment navigation should call scroll(end) and trigger listener, don't add window.scrollY here.
28353 this.maxScrollViewDepth = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
28354 this.previousScrollHeight = document$1.body.scrollHeight;
28355 this.hasTrackedScrollSession = false;
28356 }
28357 }.bind(this));
28358 win.addEventListener(EV_MP_LOCATION_CHANGE, this.listenerPageLeaveLocationchange);
28359
28360 this.listenerPageLeaveVisibilitychange = function(ev) {
28361 if (document$1.hidden) {
28362 this._trackPageLeave(ev, previousTrackedUrl, this.previousScrollHeight);
28363 }
28364 }.bind(this);
28365 document$1.addEventListener(EV_VISIBILITYCHANGE, this.listenerPageLeaveVisibilitychange);
28366 };
28367
28368 Autocapture.prototype.stopDeadClickTracking = function() {
28369 if (this.listenerDeadClick) {
28370 win.removeEventListener(EV_CLICK, this.listenerDeadClick);
28371 this.listenerDeadClick = null;
28372 }
28373
28374 if (this._deadClickTracker) {
28375 this._deadClickTracker.stopTracking();
28376 this._deadClickTracker = null;
28377 }
28378 };
28379
28380 // TODO integrate error_reporter from mixpanel instance
28381 safewrapClass(Autocapture);
28382
28383 var logger = console_with_prefix('flags');
28384
28385 var FLAGS_CONFIG_KEY = 'flags';
28386
28387 var CONFIG_CONTEXT = 'context';
28388 var CONFIG_DEFAULTS = {};
28389 CONFIG_DEFAULTS[CONFIG_CONTEXT] = {};
28390
28391 /**
28392 * FeatureFlagManager: support for Mixpanel's feature flagging product
28393 * @constructor
28394 */
28395 var FeatureFlagManager = function(initOptions) {
28396 this.fetch = win['fetch'];
28397 this.getFullApiRoute = initOptions.getFullApiRoute;
28398 this.getMpConfig = initOptions.getConfigFunc;
28399 this.setMpConfig = initOptions.setConfigFunc;
28400 this.getMpProperty = initOptions.getPropertyFunc;
28401 this.track = initOptions.trackingFunc;
28402 };
28403
28404 FeatureFlagManager.prototype.init = function() {
28405 if (!this.minApisSupported()) {
28406 logger.critical('Feature Flags unavailable: missing minimum required APIs');
28407 return;
28408 }
28409
28410 this.flags = null;
28411 this.fetchFlags();
28412
28413 this.trackedFeatures = new Set();
28414 };
28415
28416 FeatureFlagManager.prototype.getFullConfig = function() {
28417 var ffConfig = this.getMpConfig(FLAGS_CONFIG_KEY);
28418 if (!ffConfig) {
28419 // flags are completely off
28420 return {};
28421 } else if (_.isObject(ffConfig)) {
28422 return _.extend({}, CONFIG_DEFAULTS, ffConfig);
28423 } else {
28424 // config is non-object truthy value, return default
28425 return CONFIG_DEFAULTS;
28426 }
28427 };
28428
28429 FeatureFlagManager.prototype.getConfig = function(key) {
28430 return this.getFullConfig()[key];
28431 };
28432
28433 FeatureFlagManager.prototype.isSystemEnabled = function() {
28434 return !!this.getMpConfig(FLAGS_CONFIG_KEY);
28435 };
28436
28437 FeatureFlagManager.prototype.updateContext = function(newContext, options) {
28438 if (!this.isSystemEnabled()) {
28439 logger.critical('Feature Flags not enabled, cannot update context');
28440 return Promise.resolve();
28441 }
28442
28443 var ffConfig = this.getMpConfig(FLAGS_CONFIG_KEY);
28444 if (!_.isObject(ffConfig)) {
28445 ffConfig = {};
28446 }
28447 var oldContext = (options && options['replace']) ? {} : this.getConfig(CONFIG_CONTEXT);
28448 ffConfig[CONFIG_CONTEXT] = _.extend({}, oldContext, newContext);
28449
28450 this.setMpConfig(FLAGS_CONFIG_KEY, ffConfig);
28451 return this.fetchFlags();
28452 };
28453
28454 FeatureFlagManager.prototype.areFlagsReady = function() {
28455 if (!this.isSystemEnabled()) {
28456 logger.error('Feature Flags not enabled');
28457 }
28458 return !!this.flags;
28459 };
28460
28461 FeatureFlagManager.prototype.fetchFlags = function() {
28462 if (!this.isSystemEnabled()) {
28463 return Promise.resolve();
28464 }
28465
28466 var distinctId = this.getMpProperty('distinct_id');
28467 var deviceId = this.getMpProperty('$device_id');
28468 var traceparent = generateTraceparent();
28469 logger.log('Fetching flags for distinct ID: ' + distinctId);
28470
28471 var context = _.extend({'distinct_id': distinctId, 'device_id': deviceId}, this.getConfig(CONFIG_CONTEXT));
28472 var searchParams = new URLSearchParams();
28473 searchParams.set('context', JSON.stringify(context));
28474 searchParams.set('token', this.getMpConfig('token'));
28475 searchParams.set('mp_lib', 'web');
28476 searchParams.set('$lib_version', Config.LIB_VERSION);
28477 var url = this.getFullApiRoute() + '?' + searchParams.toString();
28478
28479 this._fetchInProgressStartTime = Date.now();
28480 this.fetchPromise = this.fetch.call(win, url, {
28481 'method': 'GET',
28482 'headers': {
28483 'Authorization': 'Basic ' + btoa(this.getMpConfig('token') + ':'),
28484 'traceparent': traceparent
28485 }
28486 }).then(function(response) {
28487 this.markFetchComplete();
28488 return response.json().then(function(responseBody) {
28489 var responseFlags = responseBody['flags'];
28490 if (!responseFlags) {
28491 throw new Error('No flags in API response');
28492 }
28493 var flags = new Map();
28494 _.each(responseFlags, function(data, key) {
28495 flags.set(key, {
28496 'key': data['variant_key'],
28497 'value': data['variant_value'],
28498 'experiment_id': data['experiment_id'],
28499 'is_experiment_active': data['is_experiment_active'],
28500 'is_qa_tester': data['is_qa_tester']
28501 });
28502 });
28503 this.flags = flags;
28504 this._traceparent = traceparent;
28505 }.bind(this)).catch(function(error) {
28506 this.markFetchComplete();
28507 logger.error(error);
28508 }.bind(this));
28509 }.bind(this)).catch(function(error) {
28510 this.markFetchComplete();
28511 logger.error(error);
28512 }.bind(this));
28513
28514 return this.fetchPromise;
28515 };
28516
28517 FeatureFlagManager.prototype.markFetchComplete = function() {
28518 if (!this._fetchInProgressStartTime) {
28519 logger.error('Fetch in progress started time not set, cannot mark fetch complete');
28520 return;
28521 }
28522 this._fetchStartTime = this._fetchInProgressStartTime;
28523 this._fetchCompleteTime = Date.now();
28524 this._fetchLatency = this._fetchCompleteTime - this._fetchStartTime;
28525 this._fetchInProgressStartTime = null;
28526 };
28527
28528 FeatureFlagManager.prototype.getVariant = function(featureName, fallback) {
28529 if (!this.fetchPromise) {
28530 return new Promise(function(resolve) {
28531 logger.critical('Feature Flags not initialized');
28532 resolve(fallback);
28533 });
28534 }
28535
28536 return this.fetchPromise.then(function() {
28537 return this.getVariantSync(featureName, fallback);
28538 }.bind(this)).catch(function(error) {
28539 logger.error(error);
28540 return fallback;
28541 });
28542 };
28543
28544 FeatureFlagManager.prototype.getVariantSync = function(featureName, fallback) {
28545 if (!this.areFlagsReady()) {
28546 logger.log('Flags not loaded yet');
28547 return fallback;
28548 }
28549 var feature = this.flags.get(featureName);
28550 if (!feature) {
28551 logger.log('No flag found: "' + featureName + '"');
28552 return fallback;
28553 }
28554 this.trackFeatureCheck(featureName, feature);
28555 return feature;
28556 };
28557
28558 FeatureFlagManager.prototype.getVariantValue = function(featureName, fallbackValue) {
28559 return this.getVariant(featureName, {'value': fallbackValue}).then(function(feature) {
28560 return feature['value'];
28561 }).catch(function(error) {
28562 logger.error(error);
28563 return fallbackValue;
28564 });
28565 };
28566
28567 // TODO remove deprecated method
28568 FeatureFlagManager.prototype.getFeatureData = function(featureName, fallbackValue) {
28569 logger.critical('mixpanel.flags.get_feature_data() is deprecated and will be removed in a future release. Use mixpanel.flags.get_variant_value() instead.');
28570 return this.getVariantValue(featureName, fallbackValue);
28571 };
28572
28573 FeatureFlagManager.prototype.getVariantValueSync = function(featureName, fallbackValue) {
28574 return this.getVariantSync(featureName, {'value': fallbackValue})['value'];
28575 };
28576
28577 FeatureFlagManager.prototype.isEnabled = function(featureName, fallbackValue) {
28578 return this.getVariantValue(featureName).then(function() {
28579 return this.isEnabledSync(featureName, fallbackValue);
28580 }.bind(this)).catch(function(error) {
28581 logger.error(error);
28582 return fallbackValue;
28583 });
28584 };
28585
28586 FeatureFlagManager.prototype.isEnabledSync = function(featureName, fallbackValue) {
28587 fallbackValue = fallbackValue || false;
28588 var val = this.getVariantValueSync(featureName, fallbackValue);
28589 if (val !== true && val !== false) {
28590 logger.error('Feature flag "' + featureName + '" value: ' + val + ' is not a boolean; returning fallback value: ' + fallbackValue);
28591 val = fallbackValue;
28592 }
28593 return val;
28594 };
28595
28596 FeatureFlagManager.prototype.trackFeatureCheck = function(featureName, feature) {
28597 if (this.trackedFeatures.has(featureName)) {
28598 return;
28599 }
28600 this.trackedFeatures.add(featureName);
28601
28602 var trackingProperties = {
28603 'Experiment name': featureName,
28604 'Variant name': feature['key'],
28605 '$experiment_type': 'feature_flag',
28606 'Variant fetch start time': new Date(this._fetchStartTime).toISOString(),
28607 'Variant fetch complete time': new Date(this._fetchCompleteTime).toISOString(),
28608 'Variant fetch latency (ms)': this._fetchLatency,
28609 'Variant fetch traceparent': this._traceparent,
28610 };
28611
28612 if (feature['experiment_id'] !== 'undefined') {
28613 trackingProperties['$experiment_id'] = feature['experiment_id'];
28614 }
28615 if (feature['is_experiment_active'] !== 'undefined') {
28616 trackingProperties['$is_experiment_active'] = feature['is_experiment_active'];
28617 }
28618 if (feature['is_qa_tester'] !== 'undefined') {
28619 trackingProperties['$is_qa_tester'] = feature['is_qa_tester'];
28620 }
28621
28622 this.track('$experiment_started', trackingProperties);
28623 };
28624
28625 FeatureFlagManager.prototype.minApisSupported = function() {
28626 return !!this.fetch &&
28627 typeof Promise !== 'undefined' &&
28628 typeof Map !== 'undefined' &&
28629 typeof Set !== 'undefined';
28630 };
28631
28632 safewrapClass(FeatureFlagManager);
28633
28634 FeatureFlagManager.prototype['are_flags_ready'] = FeatureFlagManager.prototype.areFlagsReady;
28635 FeatureFlagManager.prototype['get_variant'] = FeatureFlagManager.prototype.getVariant;
28636 FeatureFlagManager.prototype['get_variant_sync'] = FeatureFlagManager.prototype.getVariantSync;
28637 FeatureFlagManager.prototype['get_variant_value'] = FeatureFlagManager.prototype.getVariantValue;
28638 FeatureFlagManager.prototype['get_variant_value_sync'] = FeatureFlagManager.prototype.getVariantValueSync;
28639 FeatureFlagManager.prototype['is_enabled'] = FeatureFlagManager.prototype.isEnabled;
28640 FeatureFlagManager.prototype['is_enabled_sync'] = FeatureFlagManager.prototype.isEnabledSync;
28641 FeatureFlagManager.prototype['update_context'] = FeatureFlagManager.prototype.updateContext;
28642
28643 // Deprecated method
28644 FeatureFlagManager.prototype['get_feature_data'] = FeatureFlagManager.prototype.getFeatureData;
28645
28646 /* eslint camelcase: "off" */
28647
28648
28649 /**
28650 * DomTracker Object
28651 * @constructor
28652 */
28653 var DomTracker = function() {};
28654
28655
28656 // interface
28657 DomTracker.prototype.create_properties = function() {};
28658 DomTracker.prototype.event_handler = function() {};
28659 DomTracker.prototype.after_track_handler = function() {};
28660
28661 DomTracker.prototype.init = function(mixpanel_instance) {
28662 this.mp = mixpanel_instance;
28663 return this;
28664 };
28665
28666 /**
28667 * @param {Object|string} query
28668 * @param {string} event_name
28669 * @param {Object=} properties
28670 * @param {function=} user_callback
28671 */
28672 DomTracker.prototype.track = function(query, event_name, properties, user_callback) {
28673 var that = this;
28674 var elements = _.dom_query(query);
28675
28676 if (elements.length === 0) {
28677 console$1.error('The DOM query (' + query + ') returned 0 elements');
28678 return;
28679 }
28680
28681 _.each(elements, function(element) {
28682 _.register_event(element, this.override_event, function(e) {
28683 var options = {};
28684 var props = that.create_properties(properties, this);
28685 var timeout = that.mp.get_config('track_links_timeout');
28686
28687 that.event_handler(e, this, options);
28688
28689 // in case the mixpanel servers don't get back to us in time
28690 window.setTimeout(that.track_callback(user_callback, props, options, true), timeout);
28691
28692 // fire the tracking event
28693 that.mp.track(event_name, props, that.track_callback(user_callback, props, options));
28694 });
28695 }, this);
28696
28697 return true;
28698 };
28699
28700 /**
28701 * @param {function} user_callback
28702 * @param {Object} props
28703 * @param {boolean=} timeout_occured
28704 */
28705 DomTracker.prototype.track_callback = function(user_callback, props, options, timeout_occured) {
28706 timeout_occured = timeout_occured || false;
28707 var that = this;
28708
28709 return function() {
28710 // options is referenced from both callbacks, so we can have
28711 // a 'lock' of sorts to ensure only one fires
28712 if (options.callback_fired) { return; }
28713 options.callback_fired = true;
28714
28715 if (user_callback && user_callback(timeout_occured, props) === false) {
28716 // user can prevent the default functionality by
28717 // returning false from their callback
28718 return;
28719 }
28720
28721 that.after_track_handler(props, options, timeout_occured);
28722 };
28723 };
28724
28725 DomTracker.prototype.create_properties = function(properties, element) {
28726 var props;
28727
28728 if (typeof(properties) === 'function') {
28729 props = properties(element);
28730 } else {
28731 props = _.extend({}, properties);
28732 }
28733
28734 return props;
28735 };
28736
28737 /**
28738 * LinkTracker Object
28739 * @constructor
28740 * @extends DomTracker
28741 */
28742 var LinkTracker = function() {
28743 this.override_event = 'click';
28744 };
28745 _.inherit(LinkTracker, DomTracker);
28746
28747 LinkTracker.prototype.create_properties = function(properties, element) {
28748 var props = LinkTracker.superclass.create_properties.apply(this, arguments);
28749
28750 if (element.href) { props['url'] = element.href; }
28751
28752 return props;
28753 };
28754
28755 LinkTracker.prototype.event_handler = function(evt, element, options) {
28756 options.new_tab = (
28757 evt.which === 2 ||
28758 evt.metaKey ||
28759 evt.ctrlKey ||
28760 element.target === '_blank'
28761 );
28762 options.href = element.href;
28763
28764 if (!options.new_tab) {
28765 evt.preventDefault();
28766 }
28767 };
28768
28769 LinkTracker.prototype.after_track_handler = function(props, options) {
28770 if (options.new_tab) { return; }
28771
28772 setTimeout(function() {
28773 window.location = options.href;
28774 }, 0);
28775 };
28776
28777 /**
28778 * FormTracker Object
28779 * @constructor
28780 * @extends DomTracker
28781 */
28782 var FormTracker = function() {
28783 this.override_event = 'submit';
28784 };
28785 _.inherit(FormTracker, DomTracker);
28786
28787 FormTracker.prototype.event_handler = function(evt, element, options) {
28788 options.element = element;
28789 evt.preventDefault();
28790 };
28791
28792 FormTracker.prototype.after_track_handler = function(props, options) {
28793 setTimeout(function() {
28794 options.element.submit();
28795 }, 0);
28796 };
28797
28798 /* eslint camelcase: "off" */
28799
28800
28801 /** @const */ var SET_ACTION = '$set';
28802 /** @const */ var SET_ONCE_ACTION = '$set_once';
28803 /** @const */ var UNSET_ACTION = '$unset';
28804 /** @const */ var ADD_ACTION = '$add';
28805 /** @const */ var APPEND_ACTION = '$append';
28806 /** @const */ var UNION_ACTION = '$union';
28807 /** @const */ var REMOVE_ACTION = '$remove';
28808 /** @const */ var DELETE_ACTION = '$delete';
28809
28810 // Common internal methods for mixpanel.people and mixpanel.group APIs.
28811 // These methods shouldn't involve network I/O.
28812 var apiActions = {
28813 set_action: function(prop, to) {
28814 var data = {};
28815 var $set = {};
28816 if (_.isObject(prop)) {
28817 _.each(prop, function(v, k) {
28818 if (!this._is_reserved_property(k)) {
28819 $set[k] = v;
28820 }
28821 }, this);
28822 } else {
28823 $set[prop] = to;
28824 }
28825
28826 data[SET_ACTION] = $set;
28827 return data;
28828 },
28829
28830 unset_action: function(prop) {
28831 var data = {};
28832 var $unset = [];
28833 if (!_.isArray(prop)) {
28834 prop = [prop];
28835 }
28836
28837 _.each(prop, function(k) {
28838 if (!this._is_reserved_property(k)) {
28839 $unset.push(k);
28840 }
28841 }, this);
28842
28843 data[UNSET_ACTION] = $unset;
28844 return data;
28845 },
28846
28847 set_once_action: function(prop, to) {
28848 var data = {};
28849 var $set_once = {};
28850 if (_.isObject(prop)) {
28851 _.each(prop, function(v, k) {
28852 if (!this._is_reserved_property(k)) {
28853 $set_once[k] = v;
28854 }
28855 }, this);
28856 } else {
28857 $set_once[prop] = to;
28858 }
28859 data[SET_ONCE_ACTION] = $set_once;
28860 return data;
28861 },
28862
28863 union_action: function(list_name, values) {
28864 var data = {};
28865 var $union = {};
28866 if (_.isObject(list_name)) {
28867 _.each(list_name, function(v, k) {
28868 if (!this._is_reserved_property(k)) {
28869 $union[k] = _.isArray(v) ? v : [v];
28870 }
28871 }, this);
28872 } else {
28873 $union[list_name] = _.isArray(values) ? values : [values];
28874 }
28875 data[UNION_ACTION] = $union;
28876 return data;
28877 },
28878
28879 append_action: function(list_name, value) {
28880 var data = {};
28881 var $append = {};
28882 if (_.isObject(list_name)) {
28883 _.each(list_name, function(v, k) {
28884 if (!this._is_reserved_property(k)) {
28885 $append[k] = v;
28886 }
28887 }, this);
28888 } else {
28889 $append[list_name] = value;
28890 }
28891 data[APPEND_ACTION] = $append;
28892 return data;
28893 },
28894
28895 remove_action: function(list_name, value) {
28896 var data = {};
28897 var $remove = {};
28898 if (_.isObject(list_name)) {
28899 _.each(list_name, function(v, k) {
28900 if (!this._is_reserved_property(k)) {
28901 $remove[k] = v;
28902 }
28903 }, this);
28904 } else {
28905 $remove[list_name] = value;
28906 }
28907 data[REMOVE_ACTION] = $remove;
28908 return data;
28909 },
28910
28911 delete_action: function() {
28912 var data = {};
28913 data[DELETE_ACTION] = '';
28914 return data;
28915 }
28916 };
28917
28918 /* eslint camelcase: "off" */
28919
28920 /**
28921 * Mixpanel Group Object
28922 * @constructor
28923 */
28924 var MixpanelGroup = function() {};
28925
28926 _.extend(MixpanelGroup.prototype, apiActions);
28927
28928 MixpanelGroup.prototype._init = function(mixpanel_instance, group_key, group_id) {
28929 this._mixpanel = mixpanel_instance;
28930 this._group_key = group_key;
28931 this._group_id = group_id;
28932 };
28933
28934 /**
28935 * Set properties on a group.
28936 *
28937 * ### Usage:
28938 *
28939 * mixpanel.get_group('company', 'mixpanel').set('Location', '405 Howard');
28940 *
28941 * // or set multiple properties at once
28942 * mixpanel.get_group('company', 'mixpanel').set({
28943 * 'Location': '405 Howard',
28944 * 'Founded' : 2009,
28945 * });
28946 * // properties can be strings, integers, dates, or lists
28947 *
28948 * @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.
28949 * @param {*} [to] A value to set on the given property name
28950 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28951 */
28952 MixpanelGroup.prototype.set = addOptOutCheckMixpanelGroup(function(prop, to, callback) {
28953 var data = this.set_action(prop, to);
28954 if (_.isObject(prop)) {
28955 callback = to;
28956 }
28957 return this._send_request(data, callback);
28958 });
28959
28960 /**
28961 * Set properties on a group, only if they do not yet exist.
28962 * This will not overwrite previous group property values, unlike
28963 * group.set().
28964 *
28965 * ### Usage:
28966 *
28967 * mixpanel.get_group('company', 'mixpanel').set_once('Location', '405 Howard');
28968 *
28969 * // or set multiple properties at once
28970 * mixpanel.get_group('company', 'mixpanel').set_once({
28971 * 'Location': '405 Howard',
28972 * 'Founded' : 2009,
28973 * });
28974 * // properties can be strings, integers, lists or dates
28975 *
28976 * @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.
28977 * @param {*} [to] A value to set on the given property name
28978 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28979 */
28980 MixpanelGroup.prototype.set_once = addOptOutCheckMixpanelGroup(function(prop, to, callback) {
28981 var data = this.set_once_action(prop, to);
28982 if (_.isObject(prop)) {
28983 callback = to;
28984 }
28985 return this._send_request(data, callback);
28986 });
28987
28988 /**
28989 * Unset properties on a group permanently.
28990 *
28991 * ### Usage:
28992 *
28993 * mixpanel.get_group('company', 'mixpanel').unset('Founded');
28994 *
28995 * @param {String} prop The name of the property.
28996 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28997 */
28998 MixpanelGroup.prototype.unset = addOptOutCheckMixpanelGroup(function(prop, callback) {
28999 var data = this.unset_action(prop);
29000 return this._send_request(data, callback);
29001 });
29002
29003 /**
29004 * Merge a given list with a list-valued group property, excluding duplicate values.
29005 *
29006 * ### Usage:
29007 *
29008 * // merge a value to a list, creating it if needed
29009 * mixpanel.get_group('company', 'mixpanel').union('Location', ['San Francisco', 'London']);
29010 *
29011 * @param {String} list_name Name of the property.
29012 * @param {Array} values Values to merge with the given property
29013 * @param {Function} [callback] If provided, the callback will be called after the tracking event
29014 */
29015 MixpanelGroup.prototype.union = addOptOutCheckMixpanelGroup(function(list_name, values, callback) {
29016 if (_.isObject(list_name)) {
29017 callback = values;
29018 }
29019 var data = this.union_action(list_name, values);
29020 return this._send_request(data, callback);
29021 });
29022
29023 /**
29024 * Permanently delete a group.
29025 *
29026 * ### Usage:
29027 *
29028 * mixpanel.get_group('company', 'mixpanel').delete();
29029 *
29030 * @param {Function} [callback] If provided, the callback will be called after the tracking event
29031 */
29032 MixpanelGroup.prototype['delete'] = addOptOutCheckMixpanelGroup(function(callback) {
29033 // bracket notation above prevents a minification error related to reserved words
29034 var data = this.delete_action();
29035 return this._send_request(data, callback);
29036 });
29037
29038 /**
29039 * Remove a property from a group. The value will be ignored if doesn't exist.
29040 *
29041 * ### Usage:
29042 *
29043 * mixpanel.get_group('company', 'mixpanel').remove('Location', 'London');
29044 *
29045 * @param {String} list_name Name of the property.
29046 * @param {Object} value Value to remove from the given group property
29047 * @param {Function} [callback] If provided, the callback will be called after the tracking event
29048 */
29049 MixpanelGroup.prototype.remove = addOptOutCheckMixpanelGroup(function(list_name, value, callback) {
29050 var data = this.remove_action(list_name, value);
29051 return this._send_request(data, callback);
29052 });
29053
29054 MixpanelGroup.prototype._send_request = function(data, callback) {
29055 data['$group_key'] = this._group_key;
29056 data['$group_id'] = this._group_id;
29057 data['$token'] = this._get_config('token');
29058
29059 var date_encoded_data = _.encodeDates(data);
29060 return this._mixpanel._track_or_batch({
29061 type: 'groups',
29062 data: date_encoded_data,
29063 endpoint: this._mixpanel.get_api_host('groups') + '/' + this._get_config('api_routes')['groups'],
29064 batcher: this._mixpanel.request_batchers.groups
29065 }, callback);
29066 };
29067
29068 MixpanelGroup.prototype._is_reserved_property = function(prop) {
29069 return prop === '$group_key' || prop === '$group_id';
29070 };
29071
29072 MixpanelGroup.prototype._get_config = function(conf) {
29073 return this._mixpanel.get_config(conf);
29074 };
29075
29076 MixpanelGroup.prototype.toString = function() {
29077 return this._mixpanel.toString() + '.group.' + this._group_key + '.' + this._group_id;
29078 };
29079
29080 // MixpanelGroup Exports
29081 MixpanelGroup.prototype['remove'] = MixpanelGroup.prototype.remove;
29082 MixpanelGroup.prototype['set'] = MixpanelGroup.prototype.set;
29083 MixpanelGroup.prototype['set_once'] = MixpanelGroup.prototype.set_once;
29084 MixpanelGroup.prototype['union'] = MixpanelGroup.prototype.union;
29085 MixpanelGroup.prototype['unset'] = MixpanelGroup.prototype.unset;
29086 MixpanelGroup.prototype['toString'] = MixpanelGroup.prototype.toString;
29087
29088 /* eslint camelcase: "off" */
29089
29090 /**
29091 * Mixpanel People Object
29092 * @constructor
29093 */
29094 var MixpanelPeople = function() {};
29095
29096 _.extend(MixpanelPeople.prototype, apiActions);
29097
29098 MixpanelPeople.prototype._init = function(mixpanel_instance) {
29099 this._mixpanel = mixpanel_instance;
29100 };
29101
29102 /*
29103 * Set properties on a user record.
29104 *
29105 * ### Usage:
29106 *
29107 * mixpanel.people.set('gender', 'm');
29108 *
29109 * // or set multiple properties at once
29110 * mixpanel.people.set({
29111 * 'Company': 'Acme',
29112 * 'Plan': 'Premium',
29113 * 'Upgrade date': new Date()
29114 * });
29115 * // properties can be strings, integers, dates, or lists
29116 *
29117 * @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.
29118 * @param {*} [to] A value to set on the given property name
29119 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29120 */
29121 MixpanelPeople.prototype.set = addOptOutCheckMixpanelPeople(function(prop, to, callback) {
29122 var data = this.set_action(prop, to);
29123 if (_.isObject(prop)) {
29124 callback = to;
29125 }
29126 // make sure that the referrer info has been updated and saved
29127 if (this._get_config('save_referrer')) {
29128 this._mixpanel['persistence'].update_referrer_info(document.referrer);
29129 }
29130
29131 // update $set object with default people properties
29132 data[SET_ACTION] = _.extend(
29133 {},
29134 _.info.people_properties(),
29135 data[SET_ACTION]
29136 );
29137 return this._send_request(data, callback);
29138 });
29139
29140 /*
29141 * Set properties on a user record, only if they do not yet exist.
29142 * This will not overwrite previous people property values, unlike
29143 * people.set().
29144 *
29145 * ### Usage:
29146 *
29147 * mixpanel.people.set_once('First Login Date', new Date());
29148 *
29149 * // or set multiple properties at once
29150 * mixpanel.people.set_once({
29151 * 'First Login Date': new Date(),
29152 * 'Starting Plan': 'Premium'
29153 * });
29154 *
29155 * // properties can be strings, integers or dates
29156 *
29157 * @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.
29158 * @param {*} [to] A value to set on the given property name
29159 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29160 */
29161 MixpanelPeople.prototype.set_once = addOptOutCheckMixpanelPeople(function(prop, to, callback) {
29162 var data = this.set_once_action(prop, to);
29163 if (_.isObject(prop)) {
29164 callback = to;
29165 }
29166 return this._send_request(data, callback);
29167 });
29168
29169 /*
29170 * Unset properties on a user record (permanently removes the properties and their values from a profile).
29171 *
29172 * ### Usage:
29173 *
29174 * mixpanel.people.unset('gender');
29175 *
29176 * // or unset multiple properties at once
29177 * mixpanel.people.unset(['gender', 'Company']);
29178 *
29179 * @param {Array|String} prop If a string, this is the name of the property. If an array, this is a list of property names.
29180 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29181 */
29182 MixpanelPeople.prototype.unset = addOptOutCheckMixpanelPeople(function(prop, callback) {
29183 var data = this.unset_action(prop);
29184 return this._send_request(data, callback);
29185 });
29186
29187 /*
29188 * Increment/decrement numeric people analytics properties.
29189 *
29190 * ### Usage:
29191 *
29192 * mixpanel.people.increment('page_views', 1);
29193 *
29194 * // or, for convenience, if you're just incrementing a counter by
29195 * // 1, you can simply do
29196 * mixpanel.people.increment('page_views');
29197 *
29198 * // to decrement a counter, pass a negative number
29199 * mixpanel.people.increment('credits_left', -1);
29200 *
29201 * // like mixpanel.people.set(), you can increment multiple
29202 * // properties at once:
29203 * mixpanel.people.increment({
29204 * counter1: 1,
29205 * counter2: 6
29206 * });
29207 *
29208 * @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.
29209 * @param {Number} [by] An amount to increment the given property
29210 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29211 */
29212 MixpanelPeople.prototype.increment = addOptOutCheckMixpanelPeople(function(prop, by, callback) {
29213 var data = {};
29214 var $add = {};
29215 if (_.isObject(prop)) {
29216 _.each(prop, function(v, k) {
29217 if (!this._is_reserved_property(k)) {
29218 if (isNaN(parseFloat(v))) {
29219 console$1.error('Invalid increment value passed to mixpanel.people.increment - must be a number');
29220 return;
29221 } else {
29222 $add[k] = v;
29223 }
29224 }
29225 }, this);
29226 callback = by;
29227 } else {
29228 // convenience: mixpanel.people.increment('property'); will
29229 // increment 'property' by 1
29230 if (_.isUndefined(by)) {
29231 by = 1;
29232 }
29233 $add[prop] = by;
29234 }
29235 data[ADD_ACTION] = $add;
29236
29237 return this._send_request(data, callback);
29238 });
29239
29240 /*
29241 * Append a value to a list-valued people analytics property.
29242 *
29243 * ### Usage:
29244 *
29245 * // append a value to a list, creating it if needed
29246 * mixpanel.people.append('pages_visited', 'homepage');
29247 *
29248 * // like mixpanel.people.set(), you can append multiple
29249 * // properties at once:
29250 * mixpanel.people.append({
29251 * list1: 'bob',
29252 * list2: 123
29253 * });
29254 *
29255 * @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.
29256 * @param {*} [value] value An item to append to the list
29257 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29258 */
29259 MixpanelPeople.prototype.append = addOptOutCheckMixpanelPeople(function(list_name, value, callback) {
29260 if (_.isObject(list_name)) {
29261 callback = value;
29262 }
29263 var data = this.append_action(list_name, value);
29264 return this._send_request(data, callback);
29265 });
29266
29267 /*
29268 * Remove a value from a list-valued people analytics property.
29269 *
29270 * ### Usage:
29271 *
29272 * mixpanel.people.remove('School', 'UCB');
29273 *
29274 * @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.
29275 * @param {*} [value] value Item to remove from the list
29276 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29277 */
29278 MixpanelPeople.prototype.remove = addOptOutCheckMixpanelPeople(function(list_name, value, callback) {
29279 if (_.isObject(list_name)) {
29280 callback = value;
29281 }
29282 var data = this.remove_action(list_name, value);
29283 return this._send_request(data, callback);
29284 });
29285
29286 /*
29287 * Merge a given list with a list-valued people analytics property,
29288 * excluding duplicate values.
29289 *
29290 * ### Usage:
29291 *
29292 * // merge a value to a list, creating it if needed
29293 * mixpanel.people.union('pages_visited', 'homepage');
29294 *
29295 * // like mixpanel.people.set(), you can append multiple
29296 * // properties at once:
29297 * mixpanel.people.union({
29298 * list1: 'bob',
29299 * list2: 123
29300 * });
29301 *
29302 * // like mixpanel.people.append(), you can append multiple
29303 * // values to the same list:
29304 * mixpanel.people.union({
29305 * list1: ['bob', 'billy']
29306 * });
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 / values to merge with the given property
29310 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29311 */
29312 MixpanelPeople.prototype.union = addOptOutCheckMixpanelPeople(function(list_name, values, callback) {
29313 if (_.isObject(list_name)) {
29314 callback = values;
29315 }
29316 var data = this.union_action(list_name, values);
29317 return this._send_request(data, callback);
29318 });
29319
29320 /*
29321 * Record that you have charged the current user a certain amount
29322 * of money. Charges recorded with track_charge() will appear in the
29323 * Mixpanel revenue report.
29324 *
29325 * ### Usage:
29326 *
29327 * // charge a user $50
29328 * mixpanel.people.track_charge(50);
29329 *
29330 * // charge a user $30.50 on the 2nd of january
29331 * mixpanel.people.track_charge(30.50, {
29332 * '$time': new Date('jan 1 2012')
29333 * });
29334 *
29335 * @param {Number} amount The amount of money charged to the current user
29336 * @param {Object} [properties] An associative array of properties associated with the charge
29337 * @param {Function} [callback] If provided, the callback will be called when the server responds
29338 * @deprecated
29339 */
29340 MixpanelPeople.prototype.track_charge = addOptOutCheckMixpanelPeople(function() {
29341 console$1.error('mixpanel.people.track_charge() is deprecated and no longer has any effect.');
29342 });
29343
29344 /*
29345 * Permanently clear all revenue report transactions from the
29346 * current user's people analytics profile.
29347 *
29348 * ### Usage:
29349 *
29350 * mixpanel.people.clear_charges();
29351 *
29352 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29353 * @deprecated
29354 */
29355 MixpanelPeople.prototype.clear_charges = function(callback) {
29356 return this.set('$transactions', [], callback);
29357 };
29358
29359 /*
29360 * Permanently deletes the current people analytics profile from
29361 * Mixpanel (using the current distinct_id).
29362 *
29363 * ### Usage:
29364 *
29365 * // remove the all data you have stored about the current user
29366 * mixpanel.people.delete_user();
29367 *
29368 */
29369 MixpanelPeople.prototype.delete_user = function() {
29370 if (!this._identify_called()) {
29371 console$1.error('mixpanel.people.delete_user() requires you to call identify() first');
29372 return;
29373 }
29374 var data = {'$delete': this._mixpanel.get_distinct_id()};
29375 return this._send_request(data);
29376 };
29377
29378 MixpanelPeople.prototype.toString = function() {
29379 return this._mixpanel.toString() + '.people';
29380 };
29381
29382 MixpanelPeople.prototype._send_request = function(data, callback) {
29383 data['$token'] = this._get_config('token');
29384 data['$distinct_id'] = this._mixpanel.get_distinct_id();
29385 var device_id = this._mixpanel.get_property('$device_id');
29386 var user_id = this._mixpanel.get_property('$user_id');
29387 var had_persisted_distinct_id = this._mixpanel.get_property('$had_persisted_distinct_id');
29388 if (device_id) {
29389 data['$device_id'] = device_id;
29390 }
29391 if (user_id) {
29392 data['$user_id'] = user_id;
29393 }
29394 if (had_persisted_distinct_id) {
29395 data['$had_persisted_distinct_id'] = had_persisted_distinct_id;
29396 }
29397
29398 var date_encoded_data = _.encodeDates(data);
29399
29400 if (!this._identify_called()) {
29401 this._enqueue(data);
29402 if (!_.isUndefined(callback)) {
29403 if (this._get_config('verbose')) {
29404 callback({status: -1, error: null});
29405 } else {
29406 callback(-1);
29407 }
29408 }
29409 return _.truncate(date_encoded_data, 255);
29410 }
29411
29412 return this._mixpanel._track_or_batch({
29413 type: 'people',
29414 data: date_encoded_data,
29415 endpoint: this._mixpanel.get_api_host('people') + '/' + this._get_config('api_routes')['engage'],
29416 batcher: this._mixpanel.request_batchers.people
29417 }, callback);
29418 };
29419
29420 MixpanelPeople.prototype._get_config = function(conf_var) {
29421 return this._mixpanel.get_config(conf_var);
29422 };
29423
29424 MixpanelPeople.prototype._identify_called = function() {
29425 return this._mixpanel._flags.identify_called === true;
29426 };
29427
29428 // Queue up engage operations if identify hasn't been called yet.
29429 MixpanelPeople.prototype._enqueue = function(data) {
29430 if (SET_ACTION in data) {
29431 this._mixpanel['persistence']._add_to_people_queue(SET_ACTION, data);
29432 } else if (SET_ONCE_ACTION in data) {
29433 this._mixpanel['persistence']._add_to_people_queue(SET_ONCE_ACTION, data);
29434 } else if (UNSET_ACTION in data) {
29435 this._mixpanel['persistence']._add_to_people_queue(UNSET_ACTION, data);
29436 } else if (ADD_ACTION in data) {
29437 this._mixpanel['persistence']._add_to_people_queue(ADD_ACTION, data);
29438 } else if (APPEND_ACTION in data) {
29439 this._mixpanel['persistence']._add_to_people_queue(APPEND_ACTION, data);
29440 } else if (REMOVE_ACTION in data) {
29441 this._mixpanel['persistence']._add_to_people_queue(REMOVE_ACTION, data);
29442 } else if (UNION_ACTION in data) {
29443 this._mixpanel['persistence']._add_to_people_queue(UNION_ACTION, data);
29444 } else {
29445 console$1.error('Invalid call to _enqueue():', data);
29446 }
29447 };
29448
29449 MixpanelPeople.prototype._flush_one_queue = function(action, action_method, callback, queue_to_params_fn) {
29450 var _this = this;
29451 var queued_data = _.extend({}, this._mixpanel['persistence'].load_queue(action));
29452 var action_params = queued_data;
29453
29454 if (!_.isUndefined(queued_data) && _.isObject(queued_data) && !_.isEmptyObject(queued_data)) {
29455 _this._mixpanel['persistence']._pop_from_people_queue(action, queued_data);
29456 _this._mixpanel['persistence'].save();
29457 if (queue_to_params_fn) {
29458 action_params = queue_to_params_fn(queued_data);
29459 }
29460 action_method.call(_this, action_params, function(response, data) {
29461 // on bad response, we want to add it back to the queue
29462 if (response === 0) {
29463 _this._mixpanel['persistence']._add_to_people_queue(action, queued_data);
29464 }
29465 if (!_.isUndefined(callback)) {
29466 callback(response, data);
29467 }
29468 });
29469 }
29470 };
29471
29472 // Flush queued engage operations - order does not matter,
29473 // and there are network level race conditions anyway
29474 MixpanelPeople.prototype._flush = function(
29475 _set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback
29476 ) {
29477 var _this = this;
29478
29479 this._flush_one_queue(SET_ACTION, this.set, _set_callback);
29480 this._flush_one_queue(SET_ONCE_ACTION, this.set_once, _set_once_callback);
29481 this._flush_one_queue(UNSET_ACTION, this.unset, _unset_callback, function(queue) { return _.keys(queue); });
29482 this._flush_one_queue(ADD_ACTION, this.increment, _add_callback);
29483 this._flush_one_queue(UNION_ACTION, this.union, _union_callback);
29484
29485 // we have to fire off each $append individually since there is
29486 // no concat method server side
29487 var $append_queue = this._mixpanel['persistence'].load_queue(APPEND_ACTION);
29488 if (!_.isUndefined($append_queue) && _.isArray($append_queue) && $append_queue.length) {
29489 var $append_item;
29490 var append_callback = function(response, data) {
29491 if (response === 0) {
29492 _this._mixpanel['persistence']._add_to_people_queue(APPEND_ACTION, $append_item);
29493 }
29494 if (!_.isUndefined(_append_callback)) {
29495 _append_callback(response, data);
29496 }
29497 };
29498 for (var i = $append_queue.length - 1; i >= 0; i--) {
29499 $append_queue = this._mixpanel['persistence'].load_queue(APPEND_ACTION);
29500 $append_item = $append_queue.pop();
29501 _this._mixpanel['persistence'].save();
29502 if (!_.isEmptyObject($append_item)) {
29503 _this.append($append_item, append_callback);
29504 }
29505 }
29506 }
29507
29508 // same for $remove
29509 var $remove_queue = this._mixpanel['persistence'].load_queue(REMOVE_ACTION);
29510 if (!_.isUndefined($remove_queue) && _.isArray($remove_queue) && $remove_queue.length) {
29511 var $remove_item;
29512 var remove_callback = function(response, data) {
29513 if (response === 0) {
29514 _this._mixpanel['persistence']._add_to_people_queue(REMOVE_ACTION, $remove_item);
29515 }
29516 if (!_.isUndefined(_remove_callback)) {
29517 _remove_callback(response, data);
29518 }
29519 };
29520 for (var j = $remove_queue.length - 1; j >= 0; j--) {
29521 $remove_queue = this._mixpanel['persistence'].load_queue(REMOVE_ACTION);
29522 $remove_item = $remove_queue.pop();
29523 _this._mixpanel['persistence'].save();
29524 if (!_.isEmptyObject($remove_item)) {
29525 _this.remove($remove_item, remove_callback);
29526 }
29527 }
29528 }
29529 };
29530
29531 MixpanelPeople.prototype._is_reserved_property = function(prop) {
29532 return prop === '$distinct_id' || prop === '$token' || prop === '$device_id' || prop === '$user_id' || prop === '$had_persisted_distinct_id';
29533 };
29534
29535 // MixpanelPeople Exports
29536 MixpanelPeople.prototype['set'] = MixpanelPeople.prototype.set;
29537 MixpanelPeople.prototype['set_once'] = MixpanelPeople.prototype.set_once;
29538 MixpanelPeople.prototype['unset'] = MixpanelPeople.prototype.unset;
29539 MixpanelPeople.prototype['increment'] = MixpanelPeople.prototype.increment;
29540 MixpanelPeople.prototype['append'] = MixpanelPeople.prototype.append;
29541 MixpanelPeople.prototype['remove'] = MixpanelPeople.prototype.remove;
29542 MixpanelPeople.prototype['union'] = MixpanelPeople.prototype.union;
29543 MixpanelPeople.prototype['track_charge'] = MixpanelPeople.prototype.track_charge;
29544 MixpanelPeople.prototype['clear_charges'] = MixpanelPeople.prototype.clear_charges;
29545 MixpanelPeople.prototype['delete_user'] = MixpanelPeople.prototype.delete_user;
29546 MixpanelPeople.prototype['toString'] = MixpanelPeople.prototype.toString;
29547
29548 /* eslint camelcase: "off" */
29549
29550
29551 /*
29552 * Constants
29553 */
29554 /** @const */ var SET_QUEUE_KEY = '__mps';
29555 /** @const */ var SET_ONCE_QUEUE_KEY = '__mpso';
29556 /** @const */ var UNSET_QUEUE_KEY = '__mpus';
29557 /** @const */ var ADD_QUEUE_KEY = '__mpa';
29558 /** @const */ var APPEND_QUEUE_KEY = '__mpap';
29559 /** @const */ var REMOVE_QUEUE_KEY = '__mpr';
29560 /** @const */ var UNION_QUEUE_KEY = '__mpu';
29561 // This key is deprecated, but we want to check for it to see whether aliasing is allowed.
29562 /** @const */ var PEOPLE_DISTINCT_ID_KEY = '$people_distinct_id';
29563 /** @const */ var ALIAS_ID_KEY = '__alias';
29564 /** @const */ var EVENT_TIMERS_KEY = '__timers';
29565 /** @const */ var RESERVED_PROPERTIES = [
29566 SET_QUEUE_KEY,
29567 SET_ONCE_QUEUE_KEY,
29568 UNSET_QUEUE_KEY,
29569 ADD_QUEUE_KEY,
29570 APPEND_QUEUE_KEY,
29571 REMOVE_QUEUE_KEY,
29572 UNION_QUEUE_KEY,
29573 PEOPLE_DISTINCT_ID_KEY,
29574 ALIAS_ID_KEY,
29575 EVENT_TIMERS_KEY
29576 ];
29577
29578 /**
29579 * Mixpanel Persistence Object
29580 * @constructor
29581 */
29582 var MixpanelPersistence = function(config) {
29583 this['props'] = {};
29584 this.campaign_params_saved = false;
29585
29586 if (config['persistence_name']) {
29587 this.name = 'mp_' + config['persistence_name'];
29588 } else {
29589 this.name = 'mp_' + config['token'] + '_mixpanel';
29590 }
29591
29592 var storage_type = config['persistence'];
29593 if (storage_type !== 'cookie' && storage_type !== 'localStorage') {
29594 console$1.critical('Unknown persistence type ' + storage_type + '; falling back to cookie');
29595 storage_type = config['persistence'] = 'cookie';
29596 }
29597
29598 if (storage_type === 'localStorage' && _.localStorage.is_supported()) {
29599 this.storage = _.localStorage;
29600 } else {
29601 this.storage = _.cookie;
29602 }
29603
29604 this.load();
29605 this.update_config(config);
29606 this.upgrade();
29607 this.save();
29608 };
29609
29610 MixpanelPersistence.prototype.properties = function() {
29611 var p = {};
29612
29613 this.load();
29614
29615 // Filter out reserved properties
29616 _.each(this['props'], function(v, k) {
29617 if (!_.include(RESERVED_PROPERTIES, k)) {
29618 p[k] = v;
29619 }
29620 });
29621 return p;
29622 };
29623
29624 MixpanelPersistence.prototype.load = function() {
29625 if (this.disabled) { return; }
29626
29627 var entry = this.storage.parse(this.name);
29628
29629 if (entry) {
29630 this['props'] = _.extend({}, entry);
29631 }
29632 };
29633
29634 MixpanelPersistence.prototype.upgrade = function() {
29635 var old_cookie,
29636 old_localstorage;
29637
29638 // if transferring from cookie to localStorage or vice-versa, copy existing
29639 // super properties over to new storage mode
29640 if (this.storage === _.localStorage) {
29641 old_cookie = _.cookie.parse(this.name);
29642
29643 _.cookie.remove(this.name);
29644 _.cookie.remove(this.name, true);
29645
29646 if (old_cookie) {
29647 this.register_once(old_cookie);
29648 }
29649 } else if (this.storage === _.cookie) {
29650 old_localstorage = _.localStorage.parse(this.name);
29651
29652 _.localStorage.remove(this.name);
29653
29654 if (old_localstorage) {
29655 this.register_once(old_localstorage);
29656 }
29657 }
29658 };
29659
29660 MixpanelPersistence.prototype.save = function() {
29661 if (this.disabled) { return; }
29662
29663 this.storage.set(
29664 this.name,
29665 JSONStringify(this['props']),
29666 this.expire_days,
29667 this.cross_subdomain,
29668 this.secure,
29669 this.cross_site,
29670 this.cookie_domain
29671 );
29672 };
29673
29674 MixpanelPersistence.prototype.load_prop = function(key) {
29675 this.load();
29676 return this['props'][key];
29677 };
29678
29679 MixpanelPersistence.prototype.remove = function() {
29680 // remove both domain and subdomain cookies
29681 this.storage.remove(this.name, false, this.cookie_domain);
29682 this.storage.remove(this.name, true, this.cookie_domain);
29683 };
29684
29685 // removes the storage entry and deletes all loaded data
29686 // forced name for tests
29687 MixpanelPersistence.prototype.clear = function() {
29688 this.remove();
29689 this['props'] = {};
29690 };
29691
29692 /**
29693 * @param {Object} props
29694 * @param {*=} default_value
29695 * @param {number=} days
29696 */
29697 MixpanelPersistence.prototype.register_once = function(props, default_value, days) {
29698 if (_.isObject(props)) {
29699 if (typeof(default_value) === 'undefined') { default_value = 'None'; }
29700 this.expire_days = (typeof(days) === 'undefined') ? this.default_expiry : days;
29701
29702 this.load();
29703
29704 _.each(props, function(val, prop) {
29705 if (!this['props'].hasOwnProperty(prop) || this['props'][prop] === default_value) {
29706 this['props'][prop] = val;
29707 }
29708 }, this);
29709
29710 this.save();
29711
29712 return true;
29713 }
29714 return false;
29715 };
29716
29717 /**
29718 * @param {Object} props
29719 * @param {number=} days
29720 */
29721 MixpanelPersistence.prototype.register = function(props, days) {
29722 if (_.isObject(props)) {
29723 this.expire_days = (typeof(days) === 'undefined') ? this.default_expiry : days;
29724
29725 this.load();
29726 _.extend(this['props'], props);
29727 this.save();
29728
29729 return true;
29730 }
29731 return false;
29732 };
29733
29734 MixpanelPersistence.prototype.unregister = function(prop) {
29735 this.load();
29736 if (prop in this['props']) {
29737 delete this['props'][prop];
29738 this.save();
29739 }
29740 };
29741
29742 MixpanelPersistence.prototype.update_search_keyword = function(referrer) {
29743 this.register(_.info.searchInfo(referrer));
29744 };
29745
29746 // EXPORTED METHOD, we test this directly.
29747 MixpanelPersistence.prototype.update_referrer_info = function(referrer) {
29748 // If referrer doesn't exist, we want to note the fact that it was type-in traffic.
29749 this.register_once({
29750 '$initial_referrer': referrer || '$direct',
29751 '$initial_referring_domain': _.info.referringDomain(referrer) || '$direct'
29752 }, '');
29753 };
29754
29755 MixpanelPersistence.prototype.get_referrer_info = function() {
29756 return _.strip_empty_properties({
29757 '$initial_referrer': this['props']['$initial_referrer'],
29758 '$initial_referring_domain': this['props']['$initial_referring_domain']
29759 });
29760 };
29761
29762 MixpanelPersistence.prototype.update_config = function(config) {
29763 this.default_expiry = this.expire_days = config['cookie_expiration'];
29764 this.set_disabled(config['disable_persistence']);
29765 this.set_cookie_domain(config['cookie_domain']);
29766 this.set_cross_site(config['cross_site_cookie']);
29767 this.set_cross_subdomain(config['cross_subdomain_cookie']);
29768 this.set_secure(config['secure_cookie']);
29769 };
29770
29771 MixpanelPersistence.prototype.set_disabled = function(disabled) {
29772 this.disabled = disabled;
29773 if (this.disabled) {
29774 this.remove();
29775 } else {
29776 this.save();
29777 }
29778 };
29779
29780 MixpanelPersistence.prototype.set_cookie_domain = function(cookie_domain) {
29781 if (cookie_domain !== this.cookie_domain) {
29782 this.remove();
29783 this.cookie_domain = cookie_domain;
29784 this.save();
29785 }
29786 };
29787
29788 MixpanelPersistence.prototype.set_cross_site = function(cross_site) {
29789 if (cross_site !== this.cross_site) {
29790 this.cross_site = cross_site;
29791 this.remove();
29792 this.save();
29793 }
29794 };
29795
29796 MixpanelPersistence.prototype.set_cross_subdomain = function(cross_subdomain) {
29797 if (cross_subdomain !== this.cross_subdomain) {
29798 this.cross_subdomain = cross_subdomain;
29799 this.remove();
29800 this.save();
29801 }
29802 };
29803
29804 MixpanelPersistence.prototype.get_cross_subdomain = function() {
29805 return this.cross_subdomain;
29806 };
29807
29808 MixpanelPersistence.prototype.set_secure = function(secure) {
29809 if (secure !== this.secure) {
29810 this.secure = secure ? true : false;
29811 this.remove();
29812 this.save();
29813 }
29814 };
29815
29816 MixpanelPersistence.prototype._add_to_people_queue = function(queue, data) {
29817 var q_key = this._get_queue_key(queue),
29818 q_data = data[queue],
29819 set_q = this._get_or_create_queue(SET_ACTION),
29820 set_once_q = this._get_or_create_queue(SET_ONCE_ACTION),
29821 unset_q = this._get_or_create_queue(UNSET_ACTION),
29822 add_q = this._get_or_create_queue(ADD_ACTION),
29823 union_q = this._get_or_create_queue(UNION_ACTION),
29824 remove_q = this._get_or_create_queue(REMOVE_ACTION, []),
29825 append_q = this._get_or_create_queue(APPEND_ACTION, []);
29826
29827 if (q_key === SET_QUEUE_KEY) {
29828 // Update the set queue - we can override any existing values
29829 _.extend(set_q, q_data);
29830 // if there was a pending increment, override it
29831 // with the set.
29832 this._pop_from_people_queue(ADD_ACTION, q_data);
29833 // if there was a pending union, override it
29834 // with the set.
29835 this._pop_from_people_queue(UNION_ACTION, q_data);
29836 this._pop_from_people_queue(UNSET_ACTION, q_data);
29837 } else if (q_key === SET_ONCE_QUEUE_KEY) {
29838 // only queue the data if there is not already a set_once call for it.
29839 _.each(q_data, function(v, k) {
29840 if (!(k in set_once_q)) {
29841 set_once_q[k] = v;
29842 }
29843 });
29844 this._pop_from_people_queue(UNSET_ACTION, q_data);
29845 } else if (q_key === UNSET_QUEUE_KEY) {
29846 _.each(q_data, function(prop) {
29847
29848 // undo previously-queued actions on this key
29849 _.each([set_q, set_once_q, add_q, union_q], function(enqueued_obj) {
29850 if (prop in enqueued_obj) {
29851 delete enqueued_obj[prop];
29852 }
29853 });
29854 _.each(append_q, function(append_obj) {
29855 if (prop in append_obj) {
29856 delete append_obj[prop];
29857 }
29858 });
29859
29860 unset_q[prop] = true;
29861
29862 });
29863 } else if (q_key === ADD_QUEUE_KEY) {
29864 _.each(q_data, function(v, k) {
29865 // If it exists in the set queue, increment
29866 // the value
29867 if (k in set_q) {
29868 set_q[k] += v;
29869 } else {
29870 // If it doesn't exist, update the add
29871 // queue
29872 if (!(k in add_q)) {
29873 add_q[k] = 0;
29874 }
29875 add_q[k] += v;
29876 }
29877 }, this);
29878 this._pop_from_people_queue(UNSET_ACTION, q_data);
29879 } else if (q_key === UNION_QUEUE_KEY) {
29880 _.each(q_data, function(v, k) {
29881 if (_.isArray(v)) {
29882 if (!(k in union_q)) {
29883 union_q[k] = [];
29884 }
29885 // Prevent duplicate values
29886 _.each(v, function(item) {
29887 if (!_.include(union_q[k], item)) {
29888 union_q[k].push(item);
29889 }
29890 });
29891 }
29892 });
29893 this._pop_from_people_queue(UNSET_ACTION, q_data);
29894 } else if (q_key === REMOVE_QUEUE_KEY) {
29895 remove_q.push(q_data);
29896 this._pop_from_people_queue(APPEND_ACTION, q_data);
29897 } else if (q_key === APPEND_QUEUE_KEY) {
29898 append_q.push(q_data);
29899 this._pop_from_people_queue(UNSET_ACTION, q_data);
29900 }
29901
29902 console$1.log('MIXPANEL PEOPLE REQUEST (QUEUED, PENDING IDENTIFY):');
29903 console$1.log(data);
29904
29905 this.save();
29906 };
29907
29908 MixpanelPersistence.prototype._pop_from_people_queue = function(queue, data) {
29909 var q = this['props'][this._get_queue_key(queue)];
29910 if (!_.isUndefined(q)) {
29911 _.each(data, function(v, k) {
29912 if (queue === APPEND_ACTION || queue === REMOVE_ACTION) {
29913 // list actions: only remove if both k+v match
29914 // e.g. remove should not override append in a case like
29915 // append({foo: 'bar'}); remove({foo: 'qux'})
29916 _.each(q, function(queued_action) {
29917 if (queued_action[k] === v) {
29918 delete queued_action[k];
29919 }
29920 });
29921 } else {
29922 delete q[k];
29923 }
29924 }, this);
29925 }
29926 };
29927
29928 MixpanelPersistence.prototype.load_queue = function(queue) {
29929 return this.load_prop(this._get_queue_key(queue));
29930 };
29931
29932 MixpanelPersistence.prototype._get_queue_key = function(queue) {
29933 if (queue === SET_ACTION) {
29934 return SET_QUEUE_KEY;
29935 } else if (queue === SET_ONCE_ACTION) {
29936 return SET_ONCE_QUEUE_KEY;
29937 } else if (queue === UNSET_ACTION) {
29938 return UNSET_QUEUE_KEY;
29939 } else if (queue === ADD_ACTION) {
29940 return ADD_QUEUE_KEY;
29941 } else if (queue === APPEND_ACTION) {
29942 return APPEND_QUEUE_KEY;
29943 } else if (queue === REMOVE_ACTION) {
29944 return REMOVE_QUEUE_KEY;
29945 } else if (queue === UNION_ACTION) {
29946 return UNION_QUEUE_KEY;
29947 } else {
29948 console$1.error('Invalid queue:', queue);
29949 }
29950 };
29951
29952 MixpanelPersistence.prototype._get_or_create_queue = function(queue, default_val) {
29953 var key = this._get_queue_key(queue);
29954 default_val = _.isUndefined(default_val) ? {} : default_val;
29955 return this['props'][key] || (this['props'][key] = default_val);
29956 };
29957
29958 MixpanelPersistence.prototype.set_event_timer = function(event_name, timestamp) {
29959 var timers = this.load_prop(EVENT_TIMERS_KEY) || {};
29960 timers[event_name] = timestamp;
29961 this['props'][EVENT_TIMERS_KEY] = timers;
29962 this.save();
29963 };
29964
29965 MixpanelPersistence.prototype.remove_event_timer = function(event_name) {
29966 var timers = this.load_prop(EVENT_TIMERS_KEY) || {};
29967 var timestamp = timers[event_name];
29968 if (!_.isUndefined(timestamp)) {
29969 delete this['props'][EVENT_TIMERS_KEY][event_name];
29970 this.save();
29971 }
29972 return timestamp;
29973 };
29974
29975 /* eslint camelcase: "off" */
29976
29977 /*
29978 * Mixpanel JS Library
29979 *
29980 * Copyright 2012, Mixpanel, Inc. All Rights Reserved
29981 * http://mixpanel.com/
29982 *
29983 * Includes portions of Underscore.js
29984 * http://documentcloud.github.com/underscore/
29985 * (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.
29986 * Released under the MIT License.
29987 */
29988
29989 /*
29990 SIMPLE STYLE GUIDE:
29991
29992 this.x === public function
29993 this._x === internal - only use within this file
29994 this.__x === private - only use within the class
29995
29996 Globals should be all caps
29997 */
29998
29999 var init_type; // MODULE or SNIPPET loader
30000 // allow bundlers to specify how extra code (recorder bundle) should be loaded
30001 // eslint-disable-next-line no-unused-vars
30002 var load_extra_bundle = function(src, _onload) {
30003 throw new Error(src + ' not available in this build.');
30004 };
30005
30006 var mixpanel_master; // main mixpanel instance / object
30007 var INIT_MODULE = 0;
30008 var INIT_SNIPPET = 1;
30009
30010 var IDENTITY_FUNC = function(x) {return x;};
30011
30012 /** @const */ var PRIMARY_INSTANCE_NAME = 'mixpanel';
30013 /** @const */ var PAYLOAD_TYPE_BASE64 = 'base64';
30014 /** @const */ var PAYLOAD_TYPE_JSON = 'json';
30015 /** @const */ var DEVICE_ID_PREFIX = '$device:';
30016
30017
30018 /*
30019 * Dynamic... constants? Is that an oxymoron?
30020 */
30021 // http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/
30022 // https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#withCredentials
30023 var USE_XHR = (win.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest());
30024
30025 // IE<10 does not support cross-origin XHR's but script tags
30026 // with defer won't block window.onload; ENQUEUE_REQUESTS
30027 // should only be true for Opera<12
30028 var ENQUEUE_REQUESTS = !USE_XHR && (userAgent.indexOf('MSIE') === -1) && (userAgent.indexOf('Mozilla') === -1);
30029
30030 // save reference to navigator.sendBeacon so it can be minified
30031 var sendBeacon = null;
30032 if (navigator['sendBeacon']) {
30033 sendBeacon = function() {
30034 // late reference to navigator.sendBeacon to allow patching/spying
30035 return navigator['sendBeacon'].apply(navigator, arguments);
30036 };
30037 }
30038
30039 var DEFAULT_API_ROUTES = {
30040 'track': 'track/',
30041 'engage': 'engage/',
30042 'groups': 'groups/',
30043 'record': 'record/',
30044 'flags': 'flags/'
30045 };
30046
30047 /*
30048 * Module-level globals
30049 */
30050 var DEFAULT_CONFIG = {
30051 'api_host': 'https://api-js.mixpanel.com',
30052 'api_hosts': {},
30053 'api_routes': DEFAULT_API_ROUTES,
30054 'api_extra_query_params': {},
30055 'api_method': 'POST',
30056 'api_transport': 'XHR',
30057 'api_payload_format': PAYLOAD_TYPE_BASE64,
30058 'app_host': 'https://mixpanel.com',
30059 'autocapture': false,
30060 'cdn': 'https://cdn.mxpnl.com',
30061 'cross_site_cookie': false,
30062 'cross_subdomain_cookie': true,
30063 'error_reporter': NOOP_FUNC,
30064 'flags': false,
30065 'persistence': 'cookie',
30066 'persistence_name': '',
30067 'cookie_domain': '',
30068 'cookie_name': '',
30069 'loaded': NOOP_FUNC,
30070 'mp_loader': null,
30071 'track_marketing': true,
30072 'track_pageview': false,
30073 'skip_first_touch_marketing': false,
30074 'store_google': true,
30075 'stop_utm_persistence': false,
30076 'save_referrer': true,
30077 'test': false,
30078 'verbose': false,
30079 'img': false,
30080 'debug': false,
30081 'track_links_timeout': 300,
30082 'cookie_expiration': 365,
30083 'upgrade': false,
30084 'disable_persistence': false,
30085 'disable_cookie': false,
30086 'secure_cookie': false,
30087 'ip': true,
30088 'opt_out_tracking_by_default': false,
30089 'opt_out_persistence_by_default': false,
30090 'opt_out_tracking_persistence_type': 'localStorage',
30091 'opt_out_tracking_cookie_prefix': null,
30092 'property_blacklist': [],
30093 'xhr_headers': {}, // { header: value, header2: value }
30094 'ignore_dnt': false,
30095 'batch_requests': true,
30096 'batch_size': 50,
30097 'batch_flush_interval_ms': 5000,
30098 'batch_request_timeout_ms': 90000,
30099 'batch_autostart': true,
30100 'hooks': {},
30101 'record_block_class': new RegExp('^(mp-block|fs-exclude|amp-block|rr-block|ph-no-capture)$'),
30102 'record_block_selector': 'img, video, audio',
30103 'record_canvas': false,
30104 'record_collect_fonts': false,
30105 'record_heatmap_data': false,
30106 'record_idle_timeout_ms': 30 * 60 * 1000, // 30 minutes
30107 'record_mask_text_class': new RegExp('^(mp-mask|fs-mask|amp-mask|rr-mask|ph-mask)$'),
30108 'record_mask_text_selector': '*',
30109 'record_max_ms': MAX_RECORDING_MS,
30110 'record_min_ms': 0,
30111 'record_sessions_percent': 0,
30112 'recorder_src': 'https://cdn.mxpnl.com/libs/mixpanel-recorder.min.js'
30113 };
30114
30115 var DOM_LOADED = false;
30116
30117 /**
30118 * Mixpanel Library Object
30119 * @constructor
30120 */
30121 var MixpanelLib = function() {};
30122
30123
30124 /**
30125 * create_mplib(token:string, config:object, name:string)
30126 *
30127 * This function is used by the init method of MixpanelLib objects
30128 * as well as the main initializer at the end of the JSLib (that
30129 * initializes document.mixpanel as well as any additional instances
30130 * declared before this file has loaded).
30131 */
30132 var create_mplib = function(token, config, name) {
30133 var instance,
30134 target = (name === PRIMARY_INSTANCE_NAME) ? mixpanel_master : mixpanel_master[name];
30135
30136 if (target && init_type === INIT_MODULE) {
30137 instance = target;
30138 } else {
30139 if (target && !_.isArray(target)) {
30140 console$1.error('You have already initialized ' + name);
30141 return;
30142 }
30143 instance = new MixpanelLib();
30144 }
30145
30146 instance._cached_groups = {}; // cache groups in a pool
30147
30148 instance._init(token, config, name);
30149
30150 instance['people'] = new MixpanelPeople();
30151 instance['people']._init(instance);
30152
30153 if (!instance.get_config('skip_first_touch_marketing')) {
30154 // We need null UTM params in the object because
30155 // UTM parameters act as a tuple. If any UTM param
30156 // is present, then we set all UTM params including
30157 // empty ones together
30158 var utm_params = _.info.campaignParams(null);
30159 var initial_utm_params = {};
30160 var has_utm = false;
30161 _.each(utm_params, function(utm_value, utm_key) {
30162 initial_utm_params['initial_' + utm_key] = utm_value;
30163 if (utm_value) {
30164 has_utm = true;
30165 }
30166 });
30167 if (has_utm) {
30168 instance['people'].set_once(initial_utm_params);
30169 }
30170 }
30171
30172 // if any instance on the page has debug = true, we set the
30173 // global debug to be true
30174 Config.DEBUG = Config.DEBUG || instance.get_config('debug');
30175
30176 // if target is not defined, we called init after the lib already
30177 // loaded, so there won't be an array of things to execute
30178 if (!_.isUndefined(target) && _.isArray(target)) {
30179 // Crunch through the people queue first - we queue this data up &
30180 // flush on identify, so it's better to do all these operations first
30181 instance._execute_array.call(instance['people'], target['people']);
30182 instance._execute_array(target);
30183 }
30184
30185 return instance;
30186 };
30187
30188 // Initialization methods
30189
30190 /**
30191 * This function initializes a new instance of the Mixpanel tracking object.
30192 * All new instances are added to the main mixpanel object as sub properties (such as
30193 * mixpanel.library_name) and also returned by this function. To define a
30194 * second instance on the page, you would call:
30195 *
30196 * mixpanel.init('new token', { your: 'config' }, 'library_name');
30197 *
30198 * and use it like so:
30199 *
30200 * mixpanel.library_name.track(...);
30201 *
30202 * @param {String} token Your Mixpanel API token
30203 * @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>.
30204 * @param {String} [name] The name for the new mixpanel instance that you want created
30205 */
30206 MixpanelLib.prototype.init = function (token, config, name) {
30207 if (_.isUndefined(name)) {
30208 this.report_error('You must name your new library: init(token, config, name)');
30209 return;
30210 }
30211 if (name === PRIMARY_INSTANCE_NAME) {
30212 this.report_error('You must initialize the main mixpanel object right after you include the Mixpanel js snippet');
30213 return;
30214 }
30215
30216 var instance = create_mplib(token, config, name);
30217 mixpanel_master[name] = instance;
30218 instance._loaded();
30219
30220 return instance;
30221 };
30222
30223 // mixpanel._init(token:string, config:object, name:string)
30224 //
30225 // This function sets up the current instance of the mixpanel
30226 // library. The difference between this method and the init(...)
30227 // method is this one initializes the actual instance, whereas the
30228 // init(...) method sets up a new library and calls _init on it.
30229 //
30230 MixpanelLib.prototype._init = function(token, config, name) {
30231 config = config || {};
30232
30233 this['__loaded'] = true;
30234 this['config'] = {};
30235
30236 var variable_features = {};
30237
30238 // default to JSON payload for standard mixpanel.com API hosts
30239 if (!('api_payload_format' in config)) {
30240 var api_host = config['api_host'] || DEFAULT_CONFIG['api_host'];
30241 if (api_host.match(/\.mixpanel\.com/)) {
30242 variable_features['api_payload_format'] = PAYLOAD_TYPE_JSON;
30243 }
30244 }
30245
30246 this.set_config(_.extend({}, DEFAULT_CONFIG, variable_features, config, {
30247 'name': name,
30248 'token': token,
30249 'callback_fn': ((name === PRIMARY_INSTANCE_NAME) ? name : PRIMARY_INSTANCE_NAME + '.' + name) + '._jsc'
30250 }));
30251
30252 this['_jsc'] = NOOP_FUNC;
30253
30254 this.__dom_loaded_queue = [];
30255 this.__request_queue = [];
30256 this.__disabled_events = [];
30257 this._flags = {
30258 'disable_all_events': false,
30259 'identify_called': false
30260 };
30261
30262 // set up request queueing/batching
30263 this.request_batchers = {};
30264 this._batch_requests = this.get_config('batch_requests');
30265 if (this._batch_requests) {
30266 if (!_.localStorage.is_supported(true) || !USE_XHR) {
30267 this._batch_requests = false;
30268 console$1.log('Turning off Mixpanel request-queueing; needs XHR and localStorage support');
30269 _.each(this.get_batcher_configs(), function(batcher_config) {
30270 console$1.log('Clearing batch queue ' + batcher_config.queue_key);
30271 _.localStorage.remove(batcher_config.queue_key);
30272 });
30273 } else {
30274 this.init_batchers();
30275 if (sendBeacon && win.addEventListener) {
30276 // Before page closes or hides (user tabs away etc), attempt to flush any events
30277 // queued up via navigator.sendBeacon. Since sendBeacon doesn't report success/failure,
30278 // events will not be removed from the persistent store; if the site is loaded again,
30279 // the events will be flushed again on startup and deduplicated on the Mixpanel server
30280 // side.
30281 // There is no reliable way to capture only page close events, so we lean on the
30282 // visibilitychange and pagehide events as recommended at
30283 // https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event#usage_notes.
30284 // These events fire when the user clicks away from the current page/tab, so will occur
30285 // more frequently than page unload, but are the only mechanism currently for capturing
30286 // this scenario somewhat reliably.
30287 var flush_on_unload = _.bind(function() {
30288 if (!this.request_batchers.events.stopped) {
30289 this.request_batchers.events.flush({unloading: true});
30290 }
30291 }, this);
30292 win.addEventListener('pagehide', function(ev) {
30293 if (ev['persisted']) {
30294 flush_on_unload();
30295 }
30296 });
30297 win.addEventListener('visibilitychange', function() {
30298 if (document$1['visibilityState'] === 'hidden') {
30299 flush_on_unload();
30300 }
30301 });
30302 }
30303 }
30304 }
30305
30306 this['persistence'] = this['cookie'] = new MixpanelPersistence(this['config']);
30307 this.unpersisted_superprops = {};
30308 this._gdpr_init();
30309
30310 var uuid = _.UUID();
30311 if (!this.get_distinct_id()) {
30312 // There is no need to set the distinct id
30313 // or the device id if something was already stored
30314 // in the persitence
30315 this.register_once({
30316 'distinct_id': DEVICE_ID_PREFIX + uuid,
30317 '$device_id': uuid
30318 }, '');
30319 }
30320
30321 this.flags = new FeatureFlagManager({
30322 getFullApiRoute: _.bind(function() {
30323 return this.get_api_host('flags') + '/' + this.get_config('api_routes')['flags'];
30324 }, this),
30325 getConfigFunc: _.bind(this.get_config, this),
30326 setConfigFunc: _.bind(this.set_config, this),
30327 getPropertyFunc: _.bind(this.get_property, this),
30328 trackingFunc: _.bind(this.track, this)
30329 });
30330 this.flags.init();
30331 this['flags'] = this.flags;
30332
30333 this.autocapture = new Autocapture(this);
30334 this.autocapture.init();
30335
30336 this._init_tab_id();
30337 this._check_and_start_session_recording();
30338 };
30339
30340 /**
30341 * Assigns a unique UUID to this tab / window by leveraging sessionStorage.
30342 * This is primarily used for session recording, where data must be isolated to the current tab.
30343 */
30344 MixpanelLib.prototype._init_tab_id = function() {
30345 if (this.get_config('disable_persistence')) {
30346 console$1.log('Tab ID initialization skipped due to disable_persistence config');
30347 } else if (_.sessionStorage.is_supported()) {
30348 try {
30349 var key_suffix = this.get_config('name') + '_' + this.get_config('token');
30350 var tab_id_key = 'mp_tab_id_' + key_suffix;
30351
30352 // A flag is used to determine if sessionStorage is copied over and we need to generate a new tab ID.
30353 // This enforces a unique ID in the cases like duplicated tab, window.open(...)
30354 var should_generate_new_tab_id_key = 'mp_gen_new_tab_id_' + key_suffix;
30355 if (_.sessionStorage.get(should_generate_new_tab_id_key) || !_.sessionStorage.get(tab_id_key)) {
30356 _.sessionStorage.set(tab_id_key, '$tab-' + _.UUID());
30357 }
30358
30359 _.sessionStorage.set(should_generate_new_tab_id_key, '1');
30360 this.tab_id = _.sessionStorage.get(tab_id_key);
30361
30362 // 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,
30363 // but reliable in cases where the user remains in the tab e.g. a refresh or href navigation.
30364 // If the flag is absent, this indicates to the next SDK instance that we can reuse the stored tab_id.
30365 win.addEventListener('beforeunload', function () {
30366 _.sessionStorage.remove(should_generate_new_tab_id_key);
30367 });
30368 } catch(err) {
30369 this.report_error('Error initializing tab id', err);
30370 }
30371 } else {
30372 this.report_error('Session storage is not supported, cannot keep track of unique tab ID.');
30373 }
30374 };
30375
30376 MixpanelLib.prototype.get_tab_id = function () {
30377 return this.tab_id || null;
30378 };
30379
30380 MixpanelLib.prototype._should_load_recorder = function () {
30381 if (this.get_config('disable_persistence')) {
30382 console$1.log('Load recorder check skipped due to disable_persistence config');
30383 return Promise.resolve(false);
30384 }
30385
30386 var recording_registry_idb = new IDBStorageWrapper(RECORDING_REGISTRY_STORE_NAME);
30387 var tab_id = this.get_tab_id();
30388 return recording_registry_idb.init()
30389 .then(function () {
30390 return recording_registry_idb.getAll();
30391 })
30392 .then(function (recordings) {
30393 for (var i = 0; i < recordings.length; i++) {
30394 // if there are expired recordings in the registry, we should load the recorder to flush them
30395 // if there's a recording for this tab id, we should load the recorder to continue the recording
30396 if (isRecordingExpired(recordings[i]) || recordings[i]['tabId'] === tab_id) {
30397 return true;
30398 }
30399 }
30400 return false;
30401 })
30402 .catch(_.bind(function (err) {
30403 this.report_error('Error checking recording registry', err);
30404 }, this));
30405 };
30406
30407 MixpanelLib.prototype._check_and_start_session_recording = addOptOutCheckMixpanelLib(function(force_start) {
30408 if (!win['MutationObserver']) {
30409 console$1.critical('Browser does not support MutationObserver; skipping session recording');
30410 return;
30411 }
30412
30413 var loadRecorder = _.bind(function(startNewIfInactive) {
30414 var handleLoadedRecorder = _.bind(function() {
30415 this._recorder = this._recorder || new win['__mp_recorder'](this);
30416 this._recorder['resumeRecording'](startNewIfInactive);
30417 }, this);
30418
30419 if (_.isUndefined(win['__mp_recorder'])) {
30420 load_extra_bundle(this.get_config('recorder_src'), handleLoadedRecorder);
30421 } else {
30422 handleLoadedRecorder();
30423 }
30424 }, this);
30425
30426 /**
30427 * If the user is sampled or start_session_recording is called, we always load the recorder since it's guaranteed a recording should start.
30428 * 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.
30429 */
30430 var is_sampled = this.get_config('record_sessions_percent') > 0 && Math.random() * 100 <= this.get_config('record_sessions_percent');
30431 if (force_start || is_sampled) {
30432 loadRecorder(true);
30433 } else {
30434 this._should_load_recorder()
30435 .then(function (shouldLoad) {
30436 if (shouldLoad) {
30437 loadRecorder(false);
30438 }
30439 });
30440 }
30441 });
30442
30443 MixpanelLib.prototype.start_session_recording = function () {
30444 this._check_and_start_session_recording(true);
30445 };
30446
30447 MixpanelLib.prototype.stop_session_recording = function () {
30448 if (this._recorder) {
30449 return this._recorder['stopRecording']();
30450 }
30451 return Promise.resolve();
30452 };
30453
30454 MixpanelLib.prototype.pause_session_recording = function () {
30455 if (this._recorder) {
30456 return this._recorder['pauseRecording']();
30457 }
30458 return Promise.resolve();
30459 };
30460
30461 MixpanelLib.prototype.resume_session_recording = function () {
30462 if (this._recorder) {
30463 return this._recorder['resumeRecording']();
30464 }
30465 return Promise.resolve();
30466 };
30467
30468 MixpanelLib.prototype.is_recording_heatmap_data = function () {
30469 return this._get_session_replay_id() && this.get_config('record_heatmap_data');
30470 };
30471
30472 MixpanelLib.prototype.get_session_recording_properties = function () {
30473 var props = {};
30474 var replay_id = this._get_session_replay_id();
30475 if (replay_id) {
30476 props['$mp_replay_id'] = replay_id;
30477 }
30478 return props;
30479 };
30480
30481 MixpanelLib.prototype.get_session_replay_url = function () {
30482 var replay_url = null;
30483 var replay_id = this._get_session_replay_id();
30484 if (replay_id) {
30485 var query_params = _.HTTPBuildQuery({
30486 'replay_id': replay_id,
30487 'distinct_id': this.get_distinct_id(),
30488 'token': this.get_config('token')
30489 });
30490 replay_url = 'https://mixpanel.com/projects/replay-redirect?' + query_params;
30491 }
30492 return replay_url;
30493 };
30494
30495 MixpanelLib.prototype._get_session_replay_id = function () {
30496 var replay_id = null;
30497 if (this._recorder) {
30498 replay_id = this._recorder['replayId'];
30499 }
30500 return replay_id || null;
30501 };
30502
30503 // "private" public method to reach into the recorder in test cases
30504 MixpanelLib.prototype.__get_recorder = function () {
30505 return this._recorder;
30506 };
30507
30508 // Private methods
30509
30510 MixpanelLib.prototype._loaded = function() {
30511 this.get_config('loaded')(this);
30512 this._set_default_superprops();
30513 this['people'].set_once(this['persistence'].get_referrer_info());
30514
30515 // `store_google` is now deprecated and previously stored UTM parameters are cleared
30516 // from persistence by default.
30517 if (this.get_config('store_google') && this.get_config('stop_utm_persistence')) {
30518 var utm_params = _.info.campaignParams(null);
30519 _.each(utm_params, function(_utm_value, utm_key) {
30520 // We need to unregister persisted UTM parameters so old values
30521 // are not mixed with the new UTM parameters
30522 this.unregister(utm_key);
30523 }.bind(this));
30524 }
30525 };
30526
30527 // update persistence with info on referrer, UTM params, etc
30528 MixpanelLib.prototype._set_default_superprops = function() {
30529 this['persistence'].update_search_keyword(document$1.referrer);
30530 // Registering super properties for UTM persistence by 'store_google' is deprecated.
30531 if (this.get_config('store_google') && !this.get_config('stop_utm_persistence')) {
30532 this.register(_.info.campaignParams());
30533 }
30534 if (this.get_config('save_referrer')) {
30535 this['persistence'].update_referrer_info(document$1.referrer);
30536 }
30537 };
30538
30539 MixpanelLib.prototype._dom_loaded = function() {
30540 _.each(this.__dom_loaded_queue, function(item) {
30541 this._track_dom.apply(this, item);
30542 }, this);
30543
30544 if (!this.has_opted_out_tracking()) {
30545 _.each(this.__request_queue, function(item) {
30546 this._send_request.apply(this, item);
30547 }, this);
30548 }
30549
30550 delete this.__dom_loaded_queue;
30551 delete this.__request_queue;
30552 };
30553
30554 MixpanelLib.prototype._track_dom = function(DomClass, args) {
30555 if (this.get_config('img')) {
30556 this.report_error('You can\'t use DOM tracking functions with img = true.');
30557 return false;
30558 }
30559
30560 if (!DOM_LOADED) {
30561 this.__dom_loaded_queue.push([DomClass, args]);
30562 return false;
30563 }
30564
30565 var dt = new DomClass().init(this);
30566 return dt.track.apply(dt, args);
30567 };
30568
30569 /**
30570 * _prepare_callback() should be called by callers of _send_request for use
30571 * as the callback argument.
30572 *
30573 * If there is no callback, this returns null.
30574 * If we are going to make XHR/XDR requests, this returns a function.
30575 * If we are going to use script tags, this returns a string to use as the
30576 * callback GET param.
30577 */
30578 MixpanelLib.prototype._prepare_callback = function(callback, data) {
30579 if (_.isUndefined(callback)) {
30580 return null;
30581 }
30582
30583 if (USE_XHR) {
30584 var callback_function = function(response) {
30585 callback(response, data);
30586 };
30587 return callback_function;
30588 } else {
30589 // if the user gives us a callback, we store as a random
30590 // property on this instances jsc function and update our
30591 // callback string to reflect that.
30592 var jsc = this['_jsc'];
30593 var randomized_cb = '' + Math.floor(Math.random() * 100000000);
30594 var callback_string = this.get_config('callback_fn') + '[' + randomized_cb + ']';
30595 jsc[randomized_cb] = function(response) {
30596 delete jsc[randomized_cb];
30597 callback(response, data);
30598 };
30599 return callback_string;
30600 }
30601 };
30602
30603 MixpanelLib.prototype._send_request = function(url, data, options, callback) {
30604 var succeeded = true;
30605
30606 if (ENQUEUE_REQUESTS) {
30607 this.__request_queue.push(arguments);
30608 return succeeded;
30609 }
30610
30611 var DEFAULT_OPTIONS = {
30612 method: this.get_config('api_method'),
30613 transport: this.get_config('api_transport'),
30614 verbose: this.get_config('verbose')
30615 };
30616 var body_data = null;
30617
30618 if (!callback && (_.isFunction(options) || typeof options === 'string')) {
30619 callback = options;
30620 options = null;
30621 }
30622 options = _.extend(DEFAULT_OPTIONS, options || {});
30623 if (!USE_XHR) {
30624 options.method = 'GET';
30625 }
30626 var use_post = options.method === 'POST';
30627 var use_sendBeacon = sendBeacon && use_post && options.transport.toLowerCase() === 'sendbeacon';
30628
30629 // needed to correctly format responses
30630 var verbose_mode = options.verbose;
30631 if (data['verbose']) { verbose_mode = true; }
30632
30633 if (this.get_config('test')) { data['test'] = 1; }
30634 if (verbose_mode) { data['verbose'] = 1; }
30635 if (this.get_config('img')) { data['img'] = 1; }
30636 if (!USE_XHR) {
30637 if (callback) {
30638 data['callback'] = callback;
30639 } else if (verbose_mode || this.get_config('test')) {
30640 // Verbose output (from verbose mode, or an error in test mode) is a json blob,
30641 // which by itself is not valid javascript. Without a callback, this verbose output will
30642 // cause an error when returned via jsonp, so we force a no-op callback param.
30643 // See the ECMA script spec: http://www.ecma-international.org/ecma-262/5.1/#sec-12.4
30644 data['callback'] = '(function(){})';
30645 }
30646 }
30647
30648 data['ip'] = this.get_config('ip')?1:0;
30649 data['_'] = new Date().getTime().toString();
30650
30651 if (use_post) {
30652 body_data = 'data=' + encodeURIComponent(data['data']);
30653 delete data['data'];
30654 }
30655
30656 _.extend(data, this.get_config('api_extra_query_params'));
30657
30658 url += '?' + _.HTTPBuildQuery(data);
30659
30660 var lib = this;
30661 if ('img' in data) {
30662 var img = document$1.createElement('img');
30663 img.src = url;
30664 document$1.body.appendChild(img);
30665 } else if (use_sendBeacon) {
30666 try {
30667 succeeded = sendBeacon(url, body_data);
30668 } catch (e) {
30669 lib.report_error(e);
30670 succeeded = false;
30671 }
30672 try {
30673 if (callback) {
30674 callback(succeeded ? 1 : 0);
30675 }
30676 } catch (e) {
30677 lib.report_error(e);
30678 }
30679 } else if (USE_XHR) {
30680 try {
30681 var req = new XMLHttpRequest();
30682 req.open(options.method, url, true);
30683
30684 var headers = this.get_config('xhr_headers');
30685 if (use_post) {
30686 headers['Content-Type'] = 'application/x-www-form-urlencoded';
30687 }
30688 _.each(headers, function(headerValue, headerName) {
30689 req.setRequestHeader(headerName, headerValue);
30690 });
30691
30692 if (options.timeout_ms && typeof req.timeout !== 'undefined') {
30693 req.timeout = options.timeout_ms;
30694 var start_time = new Date().getTime();
30695 }
30696
30697 // send the mp_optout cookie
30698 // withCredentials cannot be modified until after calling .open on Android and Mobile Safari
30699 req.withCredentials = true;
30700 req.onreadystatechange = function () {
30701 if (req.readyState === 4) { // XMLHttpRequest.DONE == 4, except in safari 4
30702 if (req.status === 200) {
30703 if (callback) {
30704 if (verbose_mode) {
30705 var response;
30706 try {
30707 response = _.JSONDecode(req.responseText);
30708 } catch (e) {
30709 lib.report_error(e);
30710 if (options.ignore_json_errors) {
30711 response = req.responseText;
30712 } else {
30713 return;
30714 }
30715 }
30716 callback(response);
30717 } else {
30718 callback(Number(req.responseText));
30719 }
30720 }
30721 } else {
30722 var error;
30723 if (
30724 req.timeout &&
30725 !req.status &&
30726 new Date().getTime() - start_time >= req.timeout
30727 ) {
30728 error = 'timeout';
30729 } else {
30730 error = 'Bad HTTP status: ' + req.status + ' ' + req.statusText;
30731 }
30732 lib.report_error(error);
30733 if (callback) {
30734 if (verbose_mode) {
30735 var response_headers = req['responseHeaders'] || {};
30736 callback({status: 0, httpStatusCode: req['status'], error: error, retryAfter: response_headers['Retry-After']});
30737 } else {
30738 callback(0);
30739 }
30740 }
30741 }
30742 }
30743 };
30744 req.send(body_data);
30745 } catch (e) {
30746 lib.report_error(e);
30747 succeeded = false;
30748 }
30749 } else {
30750 var script = document$1.createElement('script');
30751 script.type = 'text/javascript';
30752 script.async = true;
30753 script.defer = true;
30754 script.src = url;
30755 var s = document$1.getElementsByTagName('script')[0];
30756 s.parentNode.insertBefore(script, s);
30757 }
30758
30759 return succeeded;
30760 };
30761
30762 /**
30763 * _execute_array() deals with processing any mixpanel function
30764 * calls that were called before the Mixpanel library were loaded
30765 * (and are thus stored in an array so they can be called later)
30766 *
30767 * Note: we fire off all the mixpanel function calls && user defined
30768 * functions BEFORE we fire off mixpanel tracking calls. This is so
30769 * identify/register/set_config calls can properly modify early
30770 * tracking calls.
30771 *
30772 * @param {Array} array
30773 */
30774 MixpanelLib.prototype._execute_array = function(array) {
30775 var fn_name, alias_calls = [], other_calls = [], tracking_calls = [];
30776 _.each(array, function(item) {
30777 if (item) {
30778 fn_name = item[0];
30779 if (_.isArray(fn_name)) {
30780 tracking_calls.push(item); // chained call e.g. mixpanel.get_group().set()
30781 } else if (typeof(item) === 'function') {
30782 item.call(this);
30783 } else if (_.isArray(item) && fn_name === 'alias') {
30784 alias_calls.push(item);
30785 } else if (_.isArray(item) && fn_name.indexOf('track') !== -1 && typeof(this[fn_name]) === 'function') {
30786 tracking_calls.push(item);
30787 } else {
30788 other_calls.push(item);
30789 }
30790 }
30791 }, this);
30792
30793 var execute = function(calls, context) {
30794 _.each(calls, function(item) {
30795 if (_.isArray(item[0])) {
30796 // chained call
30797 var caller = context;
30798 _.each(item, function(call) {
30799 caller = caller[call[0]].apply(caller, call.slice(1));
30800 });
30801 } else {
30802 this[item[0]].apply(this, item.slice(1));
30803 }
30804 }, context);
30805 };
30806
30807 execute(alias_calls, this);
30808 execute(other_calls, this);
30809 execute(tracking_calls, this);
30810 };
30811
30812 // request queueing utils
30813
30814 MixpanelLib.prototype.are_batchers_initialized = function() {
30815 return !!this.request_batchers.events;
30816 };
30817
30818 MixpanelLib.prototype.get_batcher_configs = function() {
30819 var queue_prefix = '__mpq_' + this.get_config('token');
30820 this._batcher_configs = this._batcher_configs || {
30821 events: {type: 'events', api_name: 'track', queue_key: queue_prefix + '_ev'},
30822 people: {type: 'people', api_name: 'engage', queue_key: queue_prefix + '_pp'},
30823 groups: {type: 'groups', api_name: 'groups', queue_key: queue_prefix + '_gr'}
30824 };
30825 return this._batcher_configs;
30826 };
30827
30828 MixpanelLib.prototype.init_batchers = function() {
30829 if (!this.are_batchers_initialized()) {
30830 var batcher_for = _.bind(function(attrs) {
30831 return new RequestBatcher(
30832 attrs.queue_key,
30833 {
30834 libConfig: this['config'],
30835 errorReporter: this.get_config('error_reporter'),
30836 sendRequestFunc: _.bind(function(data, options, cb) {
30837 var api_routes = this.get_config('api_routes');
30838 this._send_request(
30839 this.get_api_host(attrs.api_name) + '/' + api_routes[attrs.api_name],
30840 this._encode_data_for_request(data),
30841 options,
30842 this._prepare_callback(cb, data)
30843 );
30844 }, this),
30845 beforeSendHook: _.bind(function(item) {
30846 return this._run_hook('before_send_' + attrs.type, item);
30847 }, this),
30848 stopAllBatchingFunc: _.bind(this.stop_batch_senders, this),
30849 usePersistence: true,
30850 }
30851 );
30852 }, this);
30853 var batcher_configs = this.get_batcher_configs();
30854 this.request_batchers = {
30855 events: batcher_for(batcher_configs.events),
30856 people: batcher_for(batcher_configs.people),
30857 groups: batcher_for(batcher_configs.groups)
30858 };
30859 }
30860 if (this.get_config('batch_autostart')) {
30861 this.start_batch_senders();
30862 }
30863 };
30864
30865 MixpanelLib.prototype.start_batch_senders = function() {
30866 this._batchers_were_started = true;
30867 if (this.are_batchers_initialized()) {
30868 this._batch_requests = true;
30869 _.each(this.request_batchers, function(batcher) {
30870 batcher.start();
30871 });
30872 }
30873 };
30874
30875 MixpanelLib.prototype.stop_batch_senders = function() {
30876 this._batch_requests = false;
30877 _.each(this.request_batchers, function(batcher) {
30878 batcher.stop();
30879 batcher.clear();
30880 });
30881 };
30882
30883 /**
30884 * push() keeps the standard async-array-push
30885 * behavior around after the lib is loaded.
30886 * This is only useful for external integrations that
30887 * do not wish to rely on our convenience methods
30888 * (created in the snippet).
30889 *
30890 * ### Usage:
30891 * mixpanel.push(['register', { a: 'b' }]);
30892 *
30893 * @param {Array} item A [function_name, args...] array to be executed
30894 */
30895 MixpanelLib.prototype.push = function(item) {
30896 this._execute_array([item]);
30897 };
30898
30899 /**
30900 * Disable events on the Mixpanel object. If passed no arguments,
30901 * this function disables tracking of any event. If passed an
30902 * array of event names, those events will be disabled, but other
30903 * events will continue to be tracked.
30904 *
30905 * Note: this function does not stop other mixpanel functions from
30906 * firing, such as register() or people.set().
30907 *
30908 * @param {Array} [events] An array of event names to disable
30909 */
30910 MixpanelLib.prototype.disable = function(events) {
30911 if (typeof(events) === 'undefined') {
30912 this._flags.disable_all_events = true;
30913 } else {
30914 this.__disabled_events = this.__disabled_events.concat(events);
30915 }
30916 };
30917
30918 MixpanelLib.prototype._encode_data_for_request = function(data) {
30919 var encoded_data = JSONStringify(data);
30920 if (this.get_config('api_payload_format') === PAYLOAD_TYPE_BASE64) {
30921 encoded_data = _.base64Encode(encoded_data);
30922 }
30923 return {'data': encoded_data};
30924 };
30925
30926 // internal method for handling track vs batch-enqueue logic
30927 MixpanelLib.prototype._track_or_batch = function(options, callback) {
30928 var truncated_data = _.truncate(options.data, 255);
30929 var endpoint = options.endpoint;
30930 var batcher = options.batcher;
30931 var should_send_immediately = options.should_send_immediately;
30932 var send_request_options = options.send_request_options || {};
30933 callback = callback || NOOP_FUNC;
30934
30935 var request_enqueued_or_initiated = true;
30936 var send_request_immediately = _.bind(function() {
30937 if (!send_request_options.skip_hooks) {
30938 truncated_data = this._run_hook('before_send_' + options.type, truncated_data);
30939 }
30940 if (truncated_data) {
30941 console$1.log('MIXPANEL REQUEST:');
30942 console$1.log(truncated_data);
30943 return this._send_request(
30944 endpoint,
30945 this._encode_data_for_request(truncated_data),
30946 send_request_options,
30947 this._prepare_callback(callback, truncated_data)
30948 );
30949 } else {
30950 return null;
30951 }
30952 }, this);
30953
30954 if (this._batch_requests && !should_send_immediately) {
30955 batcher.enqueue(truncated_data).then(function(succeeded) {
30956 if (succeeded) {
30957 callback(1, truncated_data);
30958 } else {
30959 send_request_immediately();
30960 }
30961 });
30962 } else {
30963 request_enqueued_or_initiated = send_request_immediately();
30964 }
30965
30966 return request_enqueued_or_initiated && truncated_data;
30967 };
30968
30969 /**
30970 * Track an event. This is the most important and
30971 * frequently used Mixpanel function.
30972 *
30973 * ### Usage:
30974 *
30975 * // track an event named 'Registered'
30976 * mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
30977 *
30978 * // track an event using navigator.sendBeacon
30979 * mixpanel.track('Left page', {'duration_seconds': 35}, {transport: 'sendBeacon'});
30980 *
30981 * To track link clicks or form submissions, see track_links() or track_forms().
30982 *
30983 * @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
30984 * @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.
30985 * @param {Object} [options] Optional configuration for this track request.
30986 * @param {String} [options.transport] Transport method for network request ('xhr' or 'sendBeacon').
30987 * @param {Boolean} [options.send_immediately] Whether to bypass batching/queueing and send track request immediately.
30988 * @param {Function} [callback] If provided, the callback function will be called after tracking the event.
30989 * @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
30990 * with the tracking payload sent to the API server is returned; otherwise false.
30991 */
30992 MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, properties, options, callback) {
30993 if (!callback && typeof options === 'function') {
30994 callback = options;
30995 options = null;
30996 }
30997 options = options || {};
30998 var transport = options['transport']; // external API, don't minify 'transport' prop
30999 if (transport) {
31000 options.transport = transport; // 'transport' prop name can be minified internally
31001 }
31002 var should_send_immediately = options['send_immediately'];
31003 if (typeof callback !== 'function') {
31004 callback = NOOP_FUNC;
31005 }
31006
31007 if (_.isUndefined(event_name)) {
31008 this.report_error('No event name provided to mixpanel.track');
31009 return;
31010 }
31011
31012 if (this._event_is_disabled(event_name)) {
31013 callback(0);
31014 return;
31015 }
31016
31017 // set defaults
31018 properties = _.extend({}, properties);
31019 properties['token'] = this.get_config('token');
31020
31021 // set $duration if time_event was previously called for this event
31022 var start_timestamp = this['persistence'].remove_event_timer(event_name);
31023 if (!_.isUndefined(start_timestamp)) {
31024 var duration_in_ms = new Date().getTime() - start_timestamp;
31025 properties['$duration'] = parseFloat((duration_in_ms / 1000).toFixed(3));
31026 }
31027
31028 this._set_default_superprops();
31029
31030 var marketing_properties = this.get_config('track_marketing')
31031 ? _.info.marketingParams()
31032 : {};
31033
31034 // note: extend writes to the first object, so lets make sure we
31035 // don't write to the persistence properties object and info
31036 // properties object by passing in a new object
31037
31038 // update properties with pageview info and super-properties
31039 properties = _.extend(
31040 {},
31041 _.info.properties({'mp_loader': this.get_config('mp_loader')}),
31042 marketing_properties,
31043 this['persistence'].properties(),
31044 this.unpersisted_superprops,
31045 this.get_session_recording_properties(),
31046 properties
31047 );
31048
31049 var property_blacklist = this.get_config('property_blacklist');
31050 if (_.isArray(property_blacklist)) {
31051 _.each(property_blacklist, function(blacklisted_prop) {
31052 delete properties[blacklisted_prop];
31053 });
31054 } else {
31055 this.report_error('Invalid value for property_blacklist config: ' + property_blacklist);
31056 }
31057
31058 var data = {
31059 'event': event_name,
31060 'properties': properties
31061 };
31062 var ret = this._track_or_batch({
31063 type: 'events',
31064 data: data,
31065 endpoint: this.get_api_host('events') + '/' + this.get_config('api_routes')['track'],
31066 batcher: this.request_batchers.events,
31067 should_send_immediately: should_send_immediately,
31068 send_request_options: options
31069 }, callback);
31070
31071 return ret;
31072 });
31073
31074 /**
31075 * Register the current user into one/many groups.
31076 *
31077 * ### Usage:
31078 *
31079 * mixpanel.set_group('company', ['mixpanel', 'google']) // an array of IDs
31080 * mixpanel.set_group('company', 'mixpanel')
31081 * mixpanel.set_group('company', 128746312)
31082 *
31083 * @param {String} group_key Group key
31084 * @param {Array|String|Number} group_ids An array of group IDs, or a singular group ID
31085 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
31086 *
31087 */
31088 MixpanelLib.prototype.set_group = addOptOutCheckMixpanelLib(function(group_key, group_ids, callback) {
31089 if (!_.isArray(group_ids)) {
31090 group_ids = [group_ids];
31091 }
31092 var prop = {};
31093 prop[group_key] = group_ids;
31094 this.register(prop);
31095 return this['people'].set(group_key, group_ids, callback);
31096 });
31097
31098 /**
31099 * Add a new group for this user.
31100 *
31101 * ### Usage:
31102 *
31103 * mixpanel.add_group('company', 'mixpanel')
31104 *
31105 * @param {String} group_key Group key
31106 * @param {*} group_id A valid Mixpanel property type
31107 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
31108 */
31109 MixpanelLib.prototype.add_group = addOptOutCheckMixpanelLib(function(group_key, group_id, callback) {
31110 var old_values = this.get_property(group_key);
31111 var prop = {};
31112 if (old_values === undefined) {
31113 prop[group_key] = [group_id];
31114 this.register(prop);
31115 } else {
31116 if (old_values.indexOf(group_id) === -1) {
31117 old_values.push(group_id);
31118 prop[group_key] = old_values;
31119 this.register(prop);
31120 }
31121 }
31122 return this['people'].union(group_key, group_id, callback);
31123 });
31124
31125 /**
31126 * Remove a group from this user.
31127 *
31128 * ### Usage:
31129 *
31130 * mixpanel.remove_group('company', 'mixpanel')
31131 *
31132 * @param {String} group_key Group key
31133 * @param {*} group_id A valid Mixpanel property type
31134 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
31135 */
31136 MixpanelLib.prototype.remove_group = addOptOutCheckMixpanelLib(function(group_key, group_id, callback) {
31137 var old_value = this.get_property(group_key);
31138 // if the value doesn't exist, the persistent store is unchanged
31139 if (old_value !== undefined) {
31140 var idx = old_value.indexOf(group_id);
31141 if (idx > -1) {
31142 old_value.splice(idx, 1);
31143 this.register({group_key: old_value});
31144 }
31145 if (old_value.length === 0) {
31146 this.unregister(group_key);
31147 }
31148 }
31149 return this['people'].remove(group_key, group_id, callback);
31150 });
31151
31152 /**
31153 * Track an event with specific groups.
31154 *
31155 * ### Usage:
31156 *
31157 * mixpanel.track_with_groups('purchase', {'product': 'iphone'}, {'University': ['UCB', 'UCLA']})
31158 *
31159 * @param {String} event_name The name of the event (see `mixpanel.track()`)
31160 * @param {Object=} properties A set of properties to include with the event you're sending (see `mixpanel.track()`)
31161 * @param {Object=} groups An object mapping group name keys to one or more values
31162 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
31163 */
31164 MixpanelLib.prototype.track_with_groups = addOptOutCheckMixpanelLib(function(event_name, properties, groups, callback) {
31165 var tracking_props = _.extend({}, properties || {});
31166 _.each(groups, function(v, k) {
31167 if (v !== null && v !== undefined) {
31168 tracking_props[k] = v;
31169 }
31170 });
31171 return this.track(event_name, tracking_props, callback);
31172 });
31173
31174 MixpanelLib.prototype._create_map_key = function (group_key, group_id) {
31175 return group_key + '_' + JSON.stringify(group_id);
31176 };
31177
31178 MixpanelLib.prototype._remove_group_from_cache = function (group_key, group_id) {
31179 delete this._cached_groups[this._create_map_key(group_key, group_id)];
31180 };
31181
31182 /**
31183 * Look up reference to a Mixpanel group
31184 *
31185 * ### Usage:
31186 *
31187 * mixpanel.get_group(group_key, group_id)
31188 *
31189 * @param {String} group_key Group key
31190 * @param {Object} group_id A valid Mixpanel property type
31191 * @returns {Object} A MixpanelGroup identifier
31192 */
31193 MixpanelLib.prototype.get_group = function (group_key, group_id) {
31194 var map_key = this._create_map_key(group_key, group_id);
31195 var group = this._cached_groups[map_key];
31196 if (group === undefined || group._group_key !== group_key || group._group_id !== group_id) {
31197 group = new MixpanelGroup();
31198 group._init(this, group_key, group_id);
31199 this._cached_groups[map_key] = group;
31200 }
31201 return group;
31202 };
31203
31204 /**
31205 * Track a default Mixpanel page view event, which includes extra default event properties to
31206 * improve page view data.
31207 *
31208 * ### Usage:
31209 *
31210 * // track a default $mp_web_page_view event
31211 * mixpanel.track_pageview();
31212 *
31213 * // track a page view event with additional event properties
31214 * mixpanel.track_pageview({'ab_test_variant': 'card-layout-b'});
31215 *
31216 * // example approach to track page views on different page types as event properties
31217 * mixpanel.track_pageview({'page': 'pricing'});
31218 * mixpanel.track_pageview({'page': 'homepage'});
31219 *
31220 * // UNCOMMON: Tracking a page view event with a custom event_name option. NOT expected to be used for
31221 * // individual pages on the same site or product. Use cases for custom event_name may be page
31222 * // views on different products or internal applications that are considered completely separate
31223 * mixpanel.track_pageview({'page': 'customer-search'}, {'event_name': '[internal] Admin Page View'});
31224 *
31225 * ### Notes:
31226 *
31227 * The `config.track_pageview` option for <a href="#mixpanelinit">mixpanel.init()</a>
31228 * may be turned on for tracking page loads automatically.
31229 *
31230 * // track only page loads
31231 * mixpanel.init(PROJECT_TOKEN, {track_pageview: true});
31232 *
31233 * // track when the URL changes in any manner
31234 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'full-url'});
31235 *
31236 * // track when the URL changes, ignoring any changes in the hash part
31237 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'url-with-path-and-query-string'});
31238 *
31239 * // track when the path changes, ignoring any query parameter or hash changes
31240 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'url-with-path'});
31241 *
31242 * @param {Object} [properties] An optional set of additional properties to send with the page view event
31243 * @param {Object} [options] Page view tracking options
31244 * @param {String} [options.event_name] - Alternate name for the tracking event
31245 * @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
31246 * with the tracking payload sent to the API server is returned; otherwise false.
31247 */
31248 MixpanelLib.prototype.track_pageview = addOptOutCheckMixpanelLib(function(properties, options) {
31249 if (typeof properties !== 'object') {
31250 properties = {};
31251 }
31252 options = options || {};
31253 var event_name = options['event_name'] || '$mp_web_page_view';
31254
31255 var default_page_properties = _.extend(
31256 _.info.mpPageViewProperties(),
31257 _.info.campaignParams(),
31258 _.info.clickParams()
31259 );
31260
31261 var event_properties = _.extend(
31262 {},
31263 default_page_properties,
31264 properties
31265 );
31266
31267 return this.track(event_name, event_properties);
31268 });
31269
31270 /**
31271 * Track clicks on a set of document elements. Selector must be a
31272 * valid query. Elements must exist on the page at the time track_links is called.
31273 *
31274 * ### Usage:
31275 *
31276 * // track click for link id #nav
31277 * mixpanel.track_links('#nav', 'Clicked Nav Link');
31278 *
31279 * ### Notes:
31280 *
31281 * This function will wait up to 300 ms for the Mixpanel
31282 * servers to respond. If they have not responded by that time
31283 * it will head to the link without ensuring that your event
31284 * has been tracked. To configure this timeout please see the
31285 * set_config() documentation below.
31286 *
31287 * If you pass a function in as the properties argument, the
31288 * function will receive the DOMElement that triggered the
31289 * event as an argument. You are expected to return an object
31290 * from the function; any properties defined on this object
31291 * will be sent to mixpanel as event properties.
31292 *
31293 * @type {Function}
31294 * @param {Object|String} query A valid DOM query, element or jQuery-esque list
31295 * @param {String} event_name The name of the event to track
31296 * @param {Object|Function} [properties] A properties object or function that returns a dictionary of properties when passed a DOMElement
31297 */
31298 MixpanelLib.prototype.track_links = function() {
31299 return this._track_dom.call(this, LinkTracker, arguments);
31300 };
31301
31302 /**
31303 * Track form submissions. Selector must be a valid query.
31304 *
31305 * ### Usage:
31306 *
31307 * // track submission for form id 'register'
31308 * mixpanel.track_forms('#register', 'Created Account');
31309 *
31310 * ### Notes:
31311 *
31312 * This function will wait up to 300 ms for the mixpanel
31313 * servers to respond, if they have not responded by that time
31314 * it will head to the link without ensuring that your event
31315 * has been tracked. To configure this timeout please see the
31316 * set_config() documentation below.
31317 *
31318 * If you pass a function in as the properties argument, the
31319 * function will receive the DOMElement that triggered the
31320 * event as an argument. You are expected to return an object
31321 * from the function; any properties defined on this object
31322 * will be sent to mixpanel as event properties.
31323 *
31324 * @type {Function}
31325 * @param {Object|String} query A valid DOM query, element or jQuery-esque list
31326 * @param {String} event_name The name of the event to track
31327 * @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
31328 */
31329 MixpanelLib.prototype.track_forms = function() {
31330 return this._track_dom.call(this, FormTracker, arguments);
31331 };
31332
31333 /**
31334 * Time an event by including the time between this call and a
31335 * later 'track' call for the same event in the properties sent
31336 * with the event.
31337 *
31338 * ### Usage:
31339 *
31340 * // time an event named 'Registered'
31341 * mixpanel.time_event('Registered');
31342 * mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
31343 *
31344 * When called for a particular event name, the next track call for that event
31345 * name will include the elapsed time between the 'time_event' and 'track'
31346 * calls. This value is stored as seconds in the '$duration' property.
31347 *
31348 * @param {String} event_name The name of the event.
31349 */
31350 MixpanelLib.prototype.time_event = function(event_name) {
31351 if (_.isUndefined(event_name)) {
31352 this.report_error('No event name provided to mixpanel.time_event');
31353 return;
31354 }
31355
31356 if (this._event_is_disabled(event_name)) {
31357 return;
31358 }
31359
31360 this['persistence'].set_event_timer(event_name, new Date().getTime());
31361 };
31362
31363 var REGISTER_DEFAULTS = {
31364 'persistent': true
31365 };
31366 /**
31367 * Helper to parse options param for register methods, maintaining
31368 * legacy support for plain "days" param instead of options object
31369 * @param {Number|Object} [days_or_options] 'days' option (Number), or Options object for register methods
31370 * @returns {Object} options object
31371 */
31372 var options_for_register = function(days_or_options) {
31373 var options;
31374 if (_.isObject(days_or_options)) {
31375 options = days_or_options;
31376 } else if (!_.isUndefined(days_or_options)) {
31377 options = {'days': days_or_options};
31378 } else {
31379 options = {};
31380 }
31381 return _.extend({}, REGISTER_DEFAULTS, options);
31382 };
31383
31384 /**
31385 * Register a set of super properties, which are included with all
31386 * events. This will overwrite previous super property values.
31387 *
31388 * ### Usage:
31389 *
31390 * // register 'Gender' as a super property
31391 * mixpanel.register({'Gender': 'Female'});
31392 *
31393 * // register several super properties when a user signs up
31394 * mixpanel.register({
31395 * 'Email': 'jdoe@example.com',
31396 * 'Account Type': 'Free'
31397 * });
31398 *
31399 * // register only for the current pageload
31400 * mixpanel.register({'Name': 'Pat'}, {persistent: false});
31401 *
31402 * @param {Object} properties An associative array of properties to store about the user
31403 * @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)
31404 * @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)
31405 * @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
31406 */
31407 MixpanelLib.prototype.register = function(props, days_or_options) {
31408 var options = options_for_register(days_or_options);
31409 if (options['persistent']) {
31410 this['persistence'].register(props, options['days']);
31411 } else {
31412 _.extend(this.unpersisted_superprops, props);
31413 }
31414 };
31415
31416 /**
31417 * Register a set of super properties only once. This will not
31418 * overwrite previous super property values, unlike register().
31419 *
31420 * ### Usage:
31421 *
31422 * // register a super property for the first time only
31423 * mixpanel.register_once({
31424 * 'First Login Date': new Date().toISOString()
31425 * });
31426 *
31427 * // register once, only for the current pageload
31428 * mixpanel.register_once({
31429 * 'First interaction time': new Date().toISOString()
31430 * }, 'None', {persistent: false});
31431 *
31432 * ### Notes:
31433 *
31434 * If default_value is specified, current super properties
31435 * with that value will be overwritten.
31436 *
31437 * @param {Object} properties An associative array of properties to store about the user
31438 * @param {*} [default_value] Value to override if already set in super properties (ex: 'False') Default: 'None'
31439 * @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)
31440 * @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)
31441 * @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
31442 */
31443 MixpanelLib.prototype.register_once = function(props, default_value, days_or_options) {
31444 var options = options_for_register(days_or_options);
31445 if (options['persistent']) {
31446 this['persistence'].register_once(props, default_value, options['days']);
31447 } else {
31448 if (typeof(default_value) === 'undefined') {
31449 default_value = 'None';
31450 }
31451 _.each(props, function(val, prop) {
31452 if (!this.unpersisted_superprops.hasOwnProperty(prop) || this.unpersisted_superprops[prop] === default_value) {
31453 this.unpersisted_superprops[prop] = val;
31454 }
31455 }, this);
31456 }
31457 };
31458
31459 /**
31460 * Delete a super property stored with the current user.
31461 *
31462 * @param {String} property The name of the super property to remove
31463 * @param {Object} [options]
31464 * @param {boolean} [options.persistent=true] - whether to look in persistent storage (cookie/localStorage)
31465 */
31466 MixpanelLib.prototype.unregister = function(property, options) {
31467 options = options_for_register(options);
31468 if (options['persistent']) {
31469 this['persistence'].unregister(property);
31470 } else {
31471 delete this.unpersisted_superprops[property];
31472 }
31473 };
31474
31475 MixpanelLib.prototype._register_single = function(prop, value) {
31476 var props = {};
31477 props[prop] = value;
31478 this.register(props);
31479 };
31480
31481 /**
31482 * Identify a user with a unique ID to track user activity across
31483 * devices, tie a user to their events, and create a user profile.
31484 * If you never call this method, unique visitors are tracked using
31485 * a UUID generated the first time they visit the site.
31486 *
31487 * Call identify when you know the identity of the current user,
31488 * typically after login or signup. We recommend against using
31489 * identify for anonymous visitors to your site.
31490 *
31491 * ### Notes:
31492 * If your project has
31493 * <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a>
31494 * enabled, the identify method will connect pre- and
31495 * post-authentication events when appropriate.
31496 *
31497 * If your project does not have ID Merge enabled, identify will
31498 * change the user's local distinct_id to the unique ID you pass.
31499 * Events tracked prior to authentication will not be connected
31500 * to the same user identity. If ID Merge is disabled, alias can
31501 * be used to connect pre- and post-registration events.
31502 *
31503 * @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.
31504 */
31505 MixpanelLib.prototype.identify = function(
31506 new_distinct_id, _set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback
31507 ) {
31508 // Optional Parameters
31509 // _set_callback:function A callback to be run if and when the People set queue is flushed
31510 // _add_callback:function A callback to be run if and when the People add queue is flushed
31511 // _append_callback:function A callback to be run if and when the People append queue is flushed
31512 // _set_once_callback:function A callback to be run if and when the People set_once queue is flushed
31513 // _union_callback:function A callback to be run if and when the People union queue is flushed
31514 // _unset_callback:function A callback to be run if and when the People unset queue is flushed
31515
31516 var previous_distinct_id = this.get_distinct_id();
31517 if (new_distinct_id && previous_distinct_id !== new_distinct_id) {
31518 // we allow the following condition if previous distinct_id is same as new_distinct_id
31519 // so that you can force flush people updates for anonymous profiles.
31520 if (typeof new_distinct_id === 'string' && new_distinct_id.indexOf(DEVICE_ID_PREFIX) === 0) {
31521 this.report_error('distinct_id cannot have $device: prefix');
31522 return -1;
31523 }
31524 this.register({'$user_id': new_distinct_id});
31525 }
31526
31527 if (!this.get_property('$device_id')) {
31528 // The persisted distinct id might not actually be a device id at all
31529 // it might be a distinct id of the user from before
31530 var device_id = previous_distinct_id;
31531 this.register_once({
31532 '$had_persisted_distinct_id': true,
31533 '$device_id': device_id
31534 }, '');
31535 }
31536
31537 // identify only changes the distinct id if it doesn't match either the existing or the alias;
31538 // if it's new, blow away the alias as well.
31539 if (new_distinct_id !== previous_distinct_id && new_distinct_id !== this.get_property(ALIAS_ID_KEY)) {
31540 this.unregister(ALIAS_ID_KEY);
31541 this.register({'distinct_id': new_distinct_id});
31542 }
31543 this._flags.identify_called = true;
31544 // Flush any queued up people requests
31545 this['people']._flush(_set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback);
31546
31547 // send an $identify event any time the distinct_id is changing - logic on the server
31548 // will determine whether or not to do anything with it.
31549 if (new_distinct_id !== previous_distinct_id) {
31550 this.track('$identify', {
31551 'distinct_id': new_distinct_id,
31552 '$anon_distinct_id': previous_distinct_id
31553 }, {skip_hooks: true});
31554 }
31555
31556 // check feature flags again if distinct id has changed
31557 if (new_distinct_id !== previous_distinct_id) {
31558 this.flags.fetchFlags();
31559 }
31560 };
31561
31562 /**
31563 * Clears super properties and generates a new random distinct_id for this instance.
31564 * Useful for clearing data when a user logs out.
31565 */
31566 MixpanelLib.prototype.reset = function() {
31567 this.stop_session_recording();
31568 this['persistence'].clear();
31569 this._flags.identify_called = false;
31570 var uuid = _.UUID();
31571 this.register_once({
31572 'distinct_id': DEVICE_ID_PREFIX + uuid,
31573 '$device_id': uuid
31574 }, '');
31575 this._check_and_start_session_recording();
31576 };
31577
31578 /**
31579 * Returns the current distinct id of the user. This is either the id automatically
31580 * generated by the library or the id that has been passed by a call to identify().
31581 *
31582 * ### Notes:
31583 *
31584 * get_distinct_id() can only be called after the Mixpanel library has finished loading.
31585 * init() has a loaded function available to handle this automatically. For example:
31586 *
31587 * // set distinct_id after the mixpanel library has loaded
31588 * mixpanel.init('YOUR PROJECT TOKEN', {
31589 * loaded: function(mixpanel) {
31590 * distinct_id = mixpanel.get_distinct_id();
31591 * }
31592 * });
31593 */
31594 MixpanelLib.prototype.get_distinct_id = function() {
31595 return this.get_property('distinct_id');
31596 };
31597
31598 /**
31599 * The alias method creates an alias which Mixpanel will use to
31600 * remap one id to another. Multiple aliases can point to the
31601 * same identifier.
31602 *
31603 * The following is a valid use of alias:
31604 *
31605 * mixpanel.alias('new_id', 'existing_id');
31606 * // You can add multiple id aliases to the existing ID
31607 * mixpanel.alias('newer_id', 'existing_id');
31608 *
31609 * Aliases can also be chained - the following is a valid example:
31610 *
31611 * mixpanel.alias('new_id', 'existing_id');
31612 * // chain newer_id - new_id - existing_id
31613 * mixpanel.alias('newer_id', 'new_id');
31614 *
31615 * Aliases cannot point to multiple identifiers - the following
31616 * example will not work:
31617 *
31618 * mixpanel.alias('new_id', 'existing_id');
31619 * // this is invalid as 'new_id' already points to 'existing_id'
31620 * mixpanel.alias('new_id', 'newer_id');
31621 *
31622 * ### Notes:
31623 *
31624 * If your project does not have
31625 * <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a>
31626 * enabled, the best practice is to call alias once when a unique
31627 * ID is first created for a user (e.g., when a user first registers
31628 * for an account). Do not use alias multiple times for a single
31629 * user without ID Merge enabled.
31630 *
31631 * @param {String} alias A unique identifier that you want to use for this user in the future.
31632 * @param {String} [original] The current identifier being used for this user.
31633 */
31634 MixpanelLib.prototype.alias = function(alias, original) {
31635 // If the $people_distinct_id key exists in persistence, there has been a previous
31636 // mixpanel.people.identify() call made for this user. It is VERY BAD to make an alias with
31637 // this ID, as it will duplicate users.
31638 if (alias === this.get_property(PEOPLE_DISTINCT_ID_KEY)) {
31639 this.report_error('Attempting to create alias for existing People user - aborting.');
31640 return -2;
31641 }
31642
31643 var _this = this;
31644 if (_.isUndefined(original)) {
31645 original = this.get_distinct_id();
31646 }
31647 if (alias !== original) {
31648 this._register_single(ALIAS_ID_KEY, alias);
31649 return this.track('$create_alias', {
31650 'alias': alias,
31651 'distinct_id': original
31652 }, {
31653 skip_hooks: true
31654 }, function() {
31655 // Flush the people queue
31656 _this.identify(alias);
31657 });
31658 } else {
31659 this.report_error('alias matches current distinct_id - skipping api call.');
31660 this.identify(alias);
31661 return -1;
31662 }
31663 };
31664
31665 /**
31666 * Provide a string to recognize the user by. The string passed to
31667 * this method will appear in the Mixpanel Streams product rather
31668 * than an automatically generated name. Name tags do not have to
31669 * be unique.
31670 *
31671 * This value will only be included in Streams data.
31672 *
31673 * @param {String} name_tag A human readable name for the user
31674 * @deprecated
31675 */
31676 MixpanelLib.prototype.name_tag = function(name_tag) {
31677 this._register_single('mp_name_tag', name_tag);
31678 };
31679
31680 /**
31681 * Update the configuration of a mixpanel library instance.
31682 *
31683 * The default config is:
31684 *
31685 * {
31686 * // host for requests (customizable for e.g. a local proxy)
31687 * api_host: 'https://api-js.mixpanel.com',
31688 *
31689 * // endpoints for different types of requests
31690 * api_routes: {
31691 * track: 'track/',
31692 * engage: 'engage/',
31693 * groups: 'groups/',
31694 * }
31695 *
31696 * // HTTP method for tracking requests
31697 * api_method: 'POST'
31698 *
31699 * // transport for sending requests ('XHR' or 'sendBeacon')
31700 * // NB: sendBeacon should only be used for scenarios such as
31701 * // page unload where a "best-effort" attempt to send is
31702 * // acceptable; the sendBeacon API does not support callbacks
31703 * // or any way to know the result of the request. Mixpanel
31704 * // tracking via sendBeacon will not support any event-
31705 * // batching or retry mechanisms.
31706 * api_transport: 'XHR'
31707 *
31708 * // request-batching/queueing/retry
31709 * batch_requests: true,
31710 *
31711 * // maximum number of events/updates to send in a single
31712 * // network request
31713 * batch_size: 50,
31714 *
31715 * // milliseconds to wait between sending batch requests
31716 * batch_flush_interval_ms: 5000,
31717 *
31718 * // milliseconds to wait for network responses to batch requests
31719 * // before they are considered timed-out and retried
31720 * batch_request_timeout_ms: 90000,
31721 *
31722 * // override value for cookie domain, only useful for ensuring
31723 * // correct cross-subdomain cookies on unusual domains like
31724 * // subdomain.mainsite.avocat.fr; NB this cannot be used to
31725 * // set cookies on a different domain than the current origin
31726 * cookie_domain: ''
31727 *
31728 * // super properties cookie expiration (in days)
31729 * cookie_expiration: 365
31730 *
31731 * // if true, cookie will be set with SameSite=None; Secure
31732 * // this is only useful in special situations, like embedded
31733 * // 3rd-party iframes that set up a Mixpanel instance
31734 * cross_site_cookie: false
31735 *
31736 * // super properties span subdomains
31737 * cross_subdomain_cookie: true
31738 *
31739 * // debug mode
31740 * debug: false
31741 *
31742 * // if this is true, the mixpanel cookie or localStorage entry
31743 * // will be deleted, and no user persistence will take place
31744 * disable_persistence: false
31745 *
31746 * // if this is true, Mixpanel will automatically determine
31747 * // City, Region and Country data using the IP address of
31748 * //the client
31749 * ip: true
31750 *
31751 * // opt users out of tracking by this Mixpanel instance by default
31752 * opt_out_tracking_by_default: false
31753 *
31754 * // opt users out of browser data storage by this Mixpanel instance by default
31755 * opt_out_persistence_by_default: false
31756 *
31757 * // persistence mechanism used by opt-in/opt-out methods - cookie
31758 * // or localStorage - falls back to cookie if localStorage is unavailable
31759 * opt_out_tracking_persistence_type: 'localStorage'
31760 *
31761 * // customize the name of cookie/localStorage set by opt-in/opt-out methods
31762 * opt_out_tracking_cookie_prefix: null
31763 *
31764 * // type of persistent store for super properties (cookie/
31765 * // localStorage) if set to 'localStorage', any existing
31766 * // mixpanel cookie value with the same persistence_name
31767 * // will be transferred to localStorage and deleted
31768 * persistence: 'cookie'
31769 *
31770 * // name for super properties persistent store
31771 * persistence_name: ''
31772 *
31773 * // names of properties/superproperties which should never
31774 * // be sent with track() calls
31775 * property_blacklist: []
31776 *
31777 * // if this is true, mixpanel cookies will be marked as
31778 * // secure, meaning they will only be transmitted over https
31779 * secure_cookie: false
31780 *
31781 * // disables enriching user profiles with first touch marketing data
31782 * skip_first_touch_marketing: false
31783 *
31784 * // the amount of time track_links will
31785 * // wait for Mixpanel's servers to respond
31786 * track_links_timeout: 300
31787 *
31788 * // adds any UTM parameters and click IDs present on the page to any events fired
31789 * track_marketing: true
31790 *
31791 * // enables automatic page view tracking using default page view events through
31792 * // the track_pageview() method
31793 * track_pageview: false
31794 *
31795 * // if you set upgrade to be true, the library will check for
31796 * // a cookie from our old js library and import super
31797 * // properties from it, then the old cookie is deleted
31798 * // The upgrade config option only works in the initialization,
31799 * // so make sure you set it when you create the library.
31800 * upgrade: false
31801 *
31802 * // extra HTTP request headers to set for each API request, in
31803 * // the format {'Header-Name': value}
31804 * xhr_headers: {}
31805 *
31806 * // whether to ignore or respect the web browser's Do Not Track setting
31807 * ignore_dnt: false
31808 * }
31809 *
31810 *
31811 * @param {Object} config A dictionary of new configuration values to update
31812 */
31813 MixpanelLib.prototype.set_config = function(config) {
31814 if (_.isObject(config)) {
31815 _.extend(this['config'], config);
31816
31817 var new_batch_size = config['batch_size'];
31818 if (new_batch_size) {
31819 _.each(this.request_batchers, function(batcher) {
31820 batcher.resetBatchSize();
31821 });
31822 }
31823
31824 if (!this.get_config('persistence_name')) {
31825 this['config']['persistence_name'] = this['config']['cookie_name'];
31826 }
31827 if (!this.get_config('disable_persistence')) {
31828 this['config']['disable_persistence'] = this['config']['disable_cookie'];
31829 }
31830
31831 if (this['persistence']) {
31832 this['persistence'].update_config(this['config']);
31833 }
31834 Config.DEBUG = Config.DEBUG || this.get_config('debug');
31835
31836 if (('autocapture' in config || 'record_heatmap_data' in config) && this.autocapture) {
31837 this.autocapture.init();
31838 }
31839 }
31840 };
31841
31842 /**
31843 * returns the current config object for the library.
31844 */
31845 MixpanelLib.prototype.get_config = function(prop_name) {
31846 return this['config'][prop_name];
31847 };
31848
31849 /**
31850 * Fetch a hook function from config, with safe default, and run it
31851 * against the given arguments
31852 * @param {string} hook_name which hook to retrieve
31853 * @returns {any|null} return value of user-provided hook, or null if nothing was returned
31854 */
31855 MixpanelLib.prototype._run_hook = function(hook_name) {
31856 var ret = (this['config']['hooks'][hook_name] || IDENTITY_FUNC).apply(this, slice.call(arguments, 1));
31857 if (typeof ret === 'undefined') {
31858 this.report_error(hook_name + ' hook did not return a value');
31859 ret = null;
31860 }
31861 return ret;
31862 };
31863
31864 /**
31865 * Returns the value of the super property named property_name. If no such
31866 * property is set, get_property() will return the undefined value.
31867 *
31868 * ### Notes:
31869 *
31870 * get_property() can only be called after the Mixpanel library has finished loading.
31871 * init() has a loaded function available to handle this automatically. For example:
31872 *
31873 * // grab value for 'user_id' after the mixpanel library has loaded
31874 * mixpanel.init('YOUR PROJECT TOKEN', {
31875 * loaded: function(mixpanel) {
31876 * user_id = mixpanel.get_property('user_id');
31877 * }
31878 * });
31879 *
31880 * @param {String} property_name The name of the super property you want to retrieve
31881 */
31882 MixpanelLib.prototype.get_property = function(property_name) {
31883 return this['persistence'].load_prop([property_name]);
31884 };
31885
31886 /**
31887 * Get the API host for a specific endpoint type, falling back to the default api_host if not specified
31888 *
31889 * @param {String} endpoint_type The type of endpoint (e.g., "events", "people", "groups")
31890 * @returns {String} The API host to use for this endpoint
31891 */
31892 MixpanelLib.prototype.get_api_host = function(endpoint_type) {
31893 return this.get_config('api_hosts')[endpoint_type] || this.get_config('api_host');
31894 };
31895
31896 MixpanelLib.prototype.toString = function() {
31897 var name = this.get_config('name');
31898 if (name !== PRIMARY_INSTANCE_NAME) {
31899 name = PRIMARY_INSTANCE_NAME + '.' + name;
31900 }
31901 return name;
31902 };
31903
31904 MixpanelLib.prototype._event_is_disabled = function(event_name) {
31905 return _.isBlockedUA(userAgent) ||
31906 this._flags.disable_all_events ||
31907 _.include(this.__disabled_events, event_name);
31908 };
31909
31910 // perform some housekeeping around GDPR opt-in/out state
31911 MixpanelLib.prototype._gdpr_init = function() {
31912 var is_localStorage_requested = this.get_config('opt_out_tracking_persistence_type') === 'localStorage';
31913
31914 // try to convert opt-in/out cookies to localStorage if possible
31915 if (is_localStorage_requested && _.localStorage.is_supported()) {
31916 if (!this.has_opted_in_tracking() && this.has_opted_in_tracking({'persistence_type': 'cookie'})) {
31917 this.opt_in_tracking({'enable_persistence': false});
31918 }
31919 if (!this.has_opted_out_tracking() && this.has_opted_out_tracking({'persistence_type': 'cookie'})) {
31920 this.opt_out_tracking({'clear_persistence': false});
31921 }
31922 this.clear_opt_in_out_tracking({
31923 'persistence_type': 'cookie',
31924 'enable_persistence': false
31925 });
31926 }
31927
31928 // check whether the user has already opted out - if so, clear & disable persistence
31929 if (this.has_opted_out_tracking()) {
31930 this._gdpr_update_persistence({'clear_persistence': true});
31931
31932 // check whether we should opt out by default
31933 // note: we don't clear persistence here by default since opt-out default state is often
31934 // used as an initial state while GDPR information is being collected
31935 } else if (!this.has_opted_in_tracking() && (
31936 this.get_config('opt_out_tracking_by_default') || _.cookie.get('mp_optout')
31937 )) {
31938 _.cookie.remove('mp_optout');
31939 this.opt_out_tracking({
31940 'clear_persistence': this.get_config('opt_out_persistence_by_default')
31941 });
31942 }
31943 };
31944
31945 /**
31946 * Enable or disable persistence based on options
31947 * only enable/disable if persistence is not already in this state
31948 * @param {boolean} [options.clear_persistence] If true, will delete all data stored by the sdk in persistence and disable it
31949 * @param {boolean} [options.enable_persistence] If true, will re-enable sdk persistence
31950 */
31951 MixpanelLib.prototype._gdpr_update_persistence = function(options) {
31952 var disabled;
31953 if (options && options['clear_persistence']) {
31954 disabled = true;
31955 } else if (options && options['enable_persistence']) {
31956 disabled = false;
31957 } else {
31958 return;
31959 }
31960
31961 if (!this.get_config('disable_persistence') && this['persistence'].disabled !== disabled) {
31962 this['persistence'].set_disabled(disabled);
31963 }
31964
31965 if (disabled) {
31966 this.stop_batch_senders();
31967 this.stop_session_recording();
31968 } else {
31969 // only start batchers after opt-in if they have previously been started
31970 // in order to avoid unintentionally starting up batching for the first time
31971 if (this._batchers_were_started) {
31972 this.start_batch_senders();
31973 }
31974 }
31975 };
31976
31977 // call a base gdpr function after constructing the appropriate token and options args
31978 MixpanelLib.prototype._gdpr_call_func = function(func, options) {
31979 options = _.extend({
31980 'track': _.bind(this.track, this),
31981 'persistence_type': this.get_config('opt_out_tracking_persistence_type'),
31982 'cookie_prefix': this.get_config('opt_out_tracking_cookie_prefix'),
31983 'cookie_expiration': this.get_config('cookie_expiration'),
31984 'cross_site_cookie': this.get_config('cross_site_cookie'),
31985 'cross_subdomain_cookie': this.get_config('cross_subdomain_cookie'),
31986 'cookie_domain': this.get_config('cookie_domain'),
31987 'secure_cookie': this.get_config('secure_cookie'),
31988 'ignore_dnt': this.get_config('ignore_dnt')
31989 }, options);
31990
31991 // check if localStorage can be used for recording opt out status, fall back to cookie if not
31992 if (!_.localStorage.is_supported()) {
31993 options['persistence_type'] = 'cookie';
31994 }
31995
31996 return func(this.get_config('token'), {
31997 track: options['track'],
31998 trackEventName: options['track_event_name'],
31999 trackProperties: options['track_properties'],
32000 persistenceType: options['persistence_type'],
32001 persistencePrefix: options['cookie_prefix'],
32002 cookieDomain: options['cookie_domain'],
32003 cookieExpiration: options['cookie_expiration'],
32004 crossSiteCookie: options['cross_site_cookie'],
32005 crossSubdomainCookie: options['cross_subdomain_cookie'],
32006 secureCookie: options['secure_cookie'],
32007 ignoreDnt: options['ignore_dnt']
32008 });
32009 };
32010
32011 /**
32012 * Opt the user in to data tracking and cookies/localstorage for this Mixpanel instance
32013 *
32014 * ### Usage:
32015 *
32016 * // opt user in
32017 * mixpanel.opt_in_tracking();
32018 *
32019 * // opt user in with specific event name, properties, cookie configuration
32020 * mixpanel.opt_in_tracking({
32021 * track_event_name: 'User opted in',
32022 * track_event_properties: {
32023 * 'Email': 'jdoe@example.com'
32024 * },
32025 * cookie_expiration: 30,
32026 * secure_cookie: true
32027 * });
32028 *
32029 * @param {Object} [options] A dictionary of config options to override
32030 * @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)
32031 * @param {string} [options.track_event_name=$opt_in] Event name to be used for tracking the opt-in action
32032 * @param {Object} [options.track_properties] Set of properties to be tracked along with the opt-in action
32033 * @param {boolean} [options.enable_persistence=true] If true, will re-enable sdk persistence
32034 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32035 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32036 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
32037 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
32038 * @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)
32039 * @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)
32040 * @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)
32041 */
32042 MixpanelLib.prototype.opt_in_tracking = function(options) {
32043 options = _.extend({
32044 'enable_persistence': true
32045 }, options);
32046
32047 this._gdpr_call_func(optIn, options);
32048 this._gdpr_update_persistence(options);
32049 };
32050
32051 /**
32052 * Opt the user out of data tracking and cookies/localstorage for this Mixpanel instance
32053 *
32054 * ### Usage:
32055 *
32056 * // opt user out
32057 * mixpanel.opt_out_tracking();
32058 *
32059 * // opt user out with different cookie configuration from Mixpanel instance
32060 * mixpanel.opt_out_tracking({
32061 * cookie_expiration: 30,
32062 * secure_cookie: true
32063 * });
32064 *
32065 * @param {Object} [options] A dictionary of config options to override
32066 * @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
32067 * @param {boolean} [options.clear_persistence=true] If true, will delete all data stored by the sdk in 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_out_tracking = function(options) {
32077 options = _.extend({
32078 'clear_persistence': true,
32079 'delete_user': true
32080 }, options);
32081
32082 // delete user and clear charges since these methods may be disabled by opt-out
32083 if (options['delete_user'] && this['people'] && this['people']._identify_called()) {
32084 this['people'].delete_user();
32085 this['people'].clear_charges();
32086 }
32087
32088 this._gdpr_call_func(optOut, options);
32089 this._gdpr_update_persistence(options);
32090 };
32091
32092 /**
32093 * Check whether the user has opted in to data tracking and cookies/localstorage for this Mixpanel instance
32094 *
32095 * ### Usage:
32096 *
32097 * var has_opted_in = mixpanel.has_opted_in_tracking();
32098 * // use has_opted_in value
32099 *
32100 * @param {Object} [options] A dictionary of config options to override
32101 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32102 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32103 * @returns {boolean} current opt-in status
32104 */
32105 MixpanelLib.prototype.has_opted_in_tracking = function(options) {
32106 return this._gdpr_call_func(hasOptedIn, options);
32107 };
32108
32109 /**
32110 * Check whether the user has opted out of data tracking and cookies/localstorage for this Mixpanel instance
32111 *
32112 * ### Usage:
32113 *
32114 * var has_opted_out = mixpanel.has_opted_out_tracking();
32115 * // use has_opted_out value
32116 *
32117 * @param {Object} [options] A dictionary of config options to override
32118 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32119 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32120 * @returns {boolean} current opt-out status
32121 */
32122 MixpanelLib.prototype.has_opted_out_tracking = function(options) {
32123 return this._gdpr_call_func(hasOptedOut, options);
32124 };
32125
32126 /**
32127 * Clear the user's opt in/out status of data tracking and cookies/localstorage for this Mixpanel instance
32128 *
32129 * ### Usage:
32130 *
32131 * // clear user's opt-in/out status
32132 * mixpanel.clear_opt_in_out_tracking();
32133 *
32134 * // clear user's opt-in/out status with specific cookie configuration - should match
32135 * // configuration used when opt_in_tracking/opt_out_tracking methods were called.
32136 * mixpanel.clear_opt_in_out_tracking({
32137 * cookie_expiration: 30,
32138 * secure_cookie: true
32139 * });
32140 *
32141 * @param {Object} [options] A dictionary of config options to override
32142 * @param {boolean} [options.enable_persistence=true] If true, will re-enable sdk persistence
32143 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32144 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32145 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
32146 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
32147 * @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)
32148 * @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)
32149 * @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)
32150 */
32151 MixpanelLib.prototype.clear_opt_in_out_tracking = function(options) {
32152 options = _.extend({
32153 'enable_persistence': true
32154 }, options);
32155
32156 this._gdpr_call_func(clearOptInOut, options);
32157 this._gdpr_update_persistence(options);
32158 };
32159
32160 MixpanelLib.prototype.report_error = function(msg, err) {
32161 console$1.error.apply(console$1.error, arguments);
32162 try {
32163 if (!err && !(msg instanceof Error)) {
32164 msg = new Error(msg);
32165 }
32166 this.get_config('error_reporter')(msg, err);
32167 } catch(err) {
32168 console$1.error(err);
32169 }
32170 };
32171
32172 // EXPORTS (for closure compiler)
32173
32174 // MixpanelLib Exports
32175 MixpanelLib.prototype['init'] = MixpanelLib.prototype.init;
32176 MixpanelLib.prototype['reset'] = MixpanelLib.prototype.reset;
32177 MixpanelLib.prototype['disable'] = MixpanelLib.prototype.disable;
32178 MixpanelLib.prototype['time_event'] = MixpanelLib.prototype.time_event;
32179 MixpanelLib.prototype['track'] = MixpanelLib.prototype.track;
32180 MixpanelLib.prototype['track_links'] = MixpanelLib.prototype.track_links;
32181 MixpanelLib.prototype['track_forms'] = MixpanelLib.prototype.track_forms;
32182 MixpanelLib.prototype['track_pageview'] = MixpanelLib.prototype.track_pageview;
32183 MixpanelLib.prototype['register'] = MixpanelLib.prototype.register;
32184 MixpanelLib.prototype['register_once'] = MixpanelLib.prototype.register_once;
32185 MixpanelLib.prototype['unregister'] = MixpanelLib.prototype.unregister;
32186 MixpanelLib.prototype['identify'] = MixpanelLib.prototype.identify;
32187 MixpanelLib.prototype['alias'] = MixpanelLib.prototype.alias;
32188 MixpanelLib.prototype['name_tag'] = MixpanelLib.prototype.name_tag;
32189 MixpanelLib.prototype['set_config'] = MixpanelLib.prototype.set_config;
32190 MixpanelLib.prototype['get_config'] = MixpanelLib.prototype.get_config;
32191 MixpanelLib.prototype['get_api_host'] = MixpanelLib.prototype.get_api_host;
32192 MixpanelLib.prototype['get_property'] = MixpanelLib.prototype.get_property;
32193 MixpanelLib.prototype['get_distinct_id'] = MixpanelLib.prototype.get_distinct_id;
32194 MixpanelLib.prototype['toString'] = MixpanelLib.prototype.toString;
32195 MixpanelLib.prototype['opt_out_tracking'] = MixpanelLib.prototype.opt_out_tracking;
32196 MixpanelLib.prototype['opt_in_tracking'] = MixpanelLib.prototype.opt_in_tracking;
32197 MixpanelLib.prototype['has_opted_out_tracking'] = MixpanelLib.prototype.has_opted_out_tracking;
32198 MixpanelLib.prototype['has_opted_in_tracking'] = MixpanelLib.prototype.has_opted_in_tracking;
32199 MixpanelLib.prototype['clear_opt_in_out_tracking'] = MixpanelLib.prototype.clear_opt_in_out_tracking;
32200 MixpanelLib.prototype['get_group'] = MixpanelLib.prototype.get_group;
32201 MixpanelLib.prototype['set_group'] = MixpanelLib.prototype.set_group;
32202 MixpanelLib.prototype['add_group'] = MixpanelLib.prototype.add_group;
32203 MixpanelLib.prototype['remove_group'] = MixpanelLib.prototype.remove_group;
32204 MixpanelLib.prototype['track_with_groups'] = MixpanelLib.prototype.track_with_groups;
32205 MixpanelLib.prototype['start_batch_senders'] = MixpanelLib.prototype.start_batch_senders;
32206 MixpanelLib.prototype['stop_batch_senders'] = MixpanelLib.prototype.stop_batch_senders;
32207 MixpanelLib.prototype['start_session_recording'] = MixpanelLib.prototype.start_session_recording;
32208 MixpanelLib.prototype['stop_session_recording'] = MixpanelLib.prototype.stop_session_recording;
32209 MixpanelLib.prototype['pause_session_recording'] = MixpanelLib.prototype.pause_session_recording;
32210 MixpanelLib.prototype['resume_session_recording'] = MixpanelLib.prototype.resume_session_recording;
32211 MixpanelLib.prototype['get_session_recording_properties'] = MixpanelLib.prototype.get_session_recording_properties;
32212 MixpanelLib.prototype['get_session_replay_url'] = MixpanelLib.prototype.get_session_replay_url;
32213 MixpanelLib.prototype['get_tab_id'] = MixpanelLib.prototype.get_tab_id;
32214 MixpanelLib.prototype['DEFAULT_API_ROUTES'] = DEFAULT_API_ROUTES;
32215
32216 // Exports intended only for testing
32217 MixpanelLib.prototype['__get_recorder'] = MixpanelLib.prototype.__get_recorder;
32218
32219 // MixpanelPersistence Exports
32220 MixpanelPersistence.prototype['properties'] = MixpanelPersistence.prototype.properties;
32221 MixpanelPersistence.prototype['update_search_keyword'] = MixpanelPersistence.prototype.update_search_keyword;
32222 MixpanelPersistence.prototype['update_referrer_info'] = MixpanelPersistence.prototype.update_referrer_info;
32223 MixpanelPersistence.prototype['get_cross_subdomain'] = MixpanelPersistence.prototype.get_cross_subdomain;
32224 MixpanelPersistence.prototype['clear'] = MixpanelPersistence.prototype.clear;
32225
32226
32227 var instances = {};
32228 var extend_mp = function() {
32229 // add all the sub mixpanel instances
32230 _.each(instances, function(instance, name) {
32231 if (name !== PRIMARY_INSTANCE_NAME) { mixpanel_master[name] = instance; }
32232 });
32233
32234 // add private functions as _
32235 mixpanel_master['_'] = _;
32236 };
32237
32238 var override_mp_init_func = function() {
32239 // we override the snippets init function to handle the case where a
32240 // user initializes the mixpanel library after the script loads & runs
32241 mixpanel_master['init'] = function(token, config, name) {
32242 if (name) {
32243 // initialize a sub library
32244 if (!mixpanel_master[name]) {
32245 mixpanel_master[name] = instances[name] = create_mplib(token, config, name);
32246 mixpanel_master[name]._loaded();
32247 }
32248 return mixpanel_master[name];
32249 } else {
32250 var instance = mixpanel_master;
32251
32252 if (instances[PRIMARY_INSTANCE_NAME]) {
32253 // main mixpanel lib already initialized
32254 instance = instances[PRIMARY_INSTANCE_NAME];
32255 } else if (token) {
32256 // intialize the main mixpanel lib
32257 instance = create_mplib(token, config, PRIMARY_INSTANCE_NAME);
32258 instance._loaded();
32259 instances[PRIMARY_INSTANCE_NAME] = instance;
32260 }
32261
32262 mixpanel_master = instance;
32263 if (init_type === INIT_SNIPPET) {
32264 win[PRIMARY_INSTANCE_NAME] = mixpanel_master;
32265 }
32266 extend_mp();
32267 }
32268 };
32269 };
32270
32271 var add_dom_loaded_handler = function() {
32272 // Cross browser DOM Loaded support
32273 function dom_loaded_handler() {
32274 // function flag since we only want to execute this once
32275 if (dom_loaded_handler.done) { return; }
32276 dom_loaded_handler.done = true;
32277
32278 DOM_LOADED = true;
32279 ENQUEUE_REQUESTS = false;
32280
32281 _.each(instances, function(inst) {
32282 inst._dom_loaded();
32283 });
32284 }
32285
32286 function do_scroll_check() {
32287 try {
32288 document$1.documentElement.doScroll('left');
32289 } catch(e) {
32290 setTimeout(do_scroll_check, 1);
32291 return;
32292 }
32293
32294 dom_loaded_handler();
32295 }
32296
32297 if (document$1.addEventListener) {
32298 if (document$1.readyState === 'complete') {
32299 // safari 4 can fire the DOMContentLoaded event before loading all
32300 // external JS (including this file). you will see some copypasta
32301 // on the internet that checks for 'complete' and 'loaded', but
32302 // 'loaded' is an IE thing
32303 dom_loaded_handler();
32304 } else {
32305 document$1.addEventListener('DOMContentLoaded', dom_loaded_handler, false);
32306 }
32307 } else if (document$1.attachEvent) {
32308 // IE
32309 document$1.attachEvent('onreadystatechange', dom_loaded_handler);
32310
32311 // check to make sure we arn't in a frame
32312 var toplevel = false;
32313 try {
32314 toplevel = win.frameElement === null;
32315 } catch(e) {
32316 // noop
32317 }
32318
32319 if (document$1.documentElement.doScroll && toplevel) {
32320 do_scroll_check();
32321 }
32322 }
32323
32324 // fallback handler, always will work
32325 _.register_event(win, 'load', dom_loaded_handler, true);
32326 };
32327
32328 function init_as_module(bundle_loader) {
32329 load_extra_bundle = bundle_loader;
32330 init_type = INIT_MODULE;
32331 mixpanel_master = new MixpanelLib();
32332
32333 override_mp_init_func();
32334 mixpanel_master['init']();
32335 add_dom_loaded_handler();
32336
32337 return mixpanel_master;
32338 }
32339
32340 // For loading separate bundles asynchronously via script tag
32341 // so that we don't load them until they are needed at runtime.
32342
32343 // For builds that have everything in one bundle, no extra work.
32344 function loadNoop (_src, onload) {
32345 onload();
32346 }
32347
32348 /* eslint camelcase: "off" */
32349
32350 var mixpanel = init_as_module(loadNoop);
32351
32352
32353
32354
32355 /***/ }),
32356
32357 /***/ "../node_modules/redux-thunk/es/index.js":
32358 /*!***********************************************!*\
32359 !*** ../node_modules/redux-thunk/es/index.js ***!
32360 \***********************************************/
32361 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
32362
32363 "use strict";
32364 __webpack_require__.r(__webpack_exports__);
32365 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
32366 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
32367 /* harmony export */ });
32368 /** A function that accepts a potential "extra argument" value to be injected later,
32369 * and returns an instance of the thunk middleware that uses that value
32370 */
32371 function createThunkMiddleware(extraArgument) {
32372 // Standard Redux middleware definition pattern:
32373 // See: https://redux.js.org/tutorials/fundamentals/part-4-store#writing-custom-middleware
32374 var middleware = function middleware(_ref) {
32375 var dispatch = _ref.dispatch,
32376 getState = _ref.getState;
32377 return function (next) {
32378 return function (action) {
32379 // The thunk middleware looks for any functions that were passed to `store.dispatch`.
32380 // If this "action" is really a function, call it and return the result.
32381 if (typeof action === 'function') {
32382 // Inject the store's `dispatch` and `getState` methods, as well as any "extra arg"
32383 return action(dispatch, getState, extraArgument);
32384 } // Otherwise, pass the action down the middleware chain as usual
32385
32386
32387 return next(action);
32388 };
32389 };
32390 };
32391
32392 return middleware;
32393 }
32394
32395 var thunk = createThunkMiddleware(); // Attach the factory function so users can create a customized version
32396 // with whatever "extra arg" they want to inject into their thunks
32397
32398 thunk.withExtraArgument = createThunkMiddleware;
32399 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (thunk);
32400
32401 /***/ }),
32402
32403 /***/ "../node_modules/redux/es/redux.js":
32404 /*!*****************************************!*\
32405 !*** ../node_modules/redux/es/redux.js ***!
32406 \*****************************************/
32407 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
32408
32409 "use strict";
32410 __webpack_require__.r(__webpack_exports__);
32411 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
32412 /* harmony export */ __DO_NOT_USE__ActionTypes: () => (/* binding */ ActionTypes),
32413 /* harmony export */ applyMiddleware: () => (/* binding */ applyMiddleware),
32414 /* harmony export */ bindActionCreators: () => (/* binding */ bindActionCreators),
32415 /* harmony export */ combineReducers: () => (/* binding */ combineReducers),
32416 /* harmony export */ compose: () => (/* binding */ compose),
32417 /* harmony export */ createStore: () => (/* binding */ createStore),
32418 /* harmony export */ legacy_createStore: () => (/* binding */ legacy_createStore)
32419 /* harmony export */ });
32420 /* 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");
32421
32422
32423 /**
32424 * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
32425 *
32426 * Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
32427 * during build.
32428 * @param {number} code
32429 */
32430 function formatProdErrorMessage(code) {
32431 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. ';
32432 }
32433
32434 // Inlined version of the `symbol-observable` polyfill
32435 var $$observable = (function () {
32436 return typeof Symbol === 'function' && Symbol.observable || '@@observable';
32437 })();
32438
32439 /**
32440 * These are private action types reserved by Redux.
32441 * For any unknown actions, you must return the current state.
32442 * If the current state is undefined, you must return the initial state.
32443 * Do not reference these action types directly in your code.
32444 */
32445 var randomString = function randomString() {
32446 return Math.random().toString(36).substring(7).split('').join('.');
32447 };
32448
32449 var ActionTypes = {
32450 INIT: "@@redux/INIT" + randomString(),
32451 REPLACE: "@@redux/REPLACE" + randomString(),
32452 PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
32453 return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
32454 }
32455 };
32456
32457 /**
32458 * @param {any} obj The object to inspect.
32459 * @returns {boolean} True if the argument appears to be a plain object.
32460 */
32461 function isPlainObject(obj) {
32462 if (typeof obj !== 'object' || obj === null) return false;
32463 var proto = obj;
32464
32465 while (Object.getPrototypeOf(proto) !== null) {
32466 proto = Object.getPrototypeOf(proto);
32467 }
32468
32469 return Object.getPrototypeOf(obj) === proto;
32470 }
32471
32472 // Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
32473 function miniKindOf(val) {
32474 if (val === void 0) return 'undefined';
32475 if (val === null) return 'null';
32476 var type = typeof val;
32477
32478 switch (type) {
32479 case 'boolean':
32480 case 'string':
32481 case 'number':
32482 case 'symbol':
32483 case 'function':
32484 {
32485 return type;
32486 }
32487 }
32488
32489 if (Array.isArray(val)) return 'array';
32490 if (isDate(val)) return 'date';
32491 if (isError(val)) return 'error';
32492 var constructorName = ctorName(val);
32493
32494 switch (constructorName) {
32495 case 'Symbol':
32496 case 'Promise':
32497 case 'WeakMap':
32498 case 'WeakSet':
32499 case 'Map':
32500 case 'Set':
32501 return constructorName;
32502 } // other
32503
32504
32505 return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
32506 }
32507
32508 function ctorName(val) {
32509 return typeof val.constructor === 'function' ? val.constructor.name : null;
32510 }
32511
32512 function isError(val) {
32513 return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
32514 }
32515
32516 function isDate(val) {
32517 if (val instanceof Date) return true;
32518 return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function';
32519 }
32520
32521 function kindOf(val) {
32522 var typeOfVal = typeof val;
32523
32524 if (true) {
32525 typeOfVal = miniKindOf(val);
32526 }
32527
32528 return typeOfVal;
32529 }
32530
32531 /**
32532 * @deprecated
32533 *
32534 * **We recommend using the `configureStore` method
32535 * of the `@reduxjs/toolkit` package**, which replaces `createStore`.
32536 *
32537 * Redux Toolkit is our recommended approach for writing Redux logic today,
32538 * including store setup, reducers, data fetching, and more.
32539 *
32540 * **For more details, please read this Redux docs page:**
32541 * **https://redux.js.org/introduction/why-rtk-is-redux-today**
32542 *
32543 * `configureStore` from Redux Toolkit is an improved version of `createStore` that
32544 * simplifies setup and helps avoid common bugs.
32545 *
32546 * You should not be using the `redux` core package by itself today, except for learning purposes.
32547 * The `createStore` method from the core `redux` package will not be removed, but we encourage
32548 * all users to migrate to using Redux Toolkit for all Redux code.
32549 *
32550 * If you want to use `createStore` without this visual deprecation warning, use
32551 * the `legacy_createStore` import instead:
32552 *
32553 * `import { legacy_createStore as createStore} from 'redux'`
32554 *
32555 */
32556
32557 function createStore(reducer, preloadedState, enhancer) {
32558 var _ref2;
32559
32560 if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
32561 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.');
32562 }
32563
32564 if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
32565 enhancer = preloadedState;
32566 preloadedState = undefined;
32567 }
32568
32569 if (typeof enhancer !== 'undefined') {
32570 if (typeof enhancer !== 'function') {
32571 throw new Error( false ? 0 : "Expected the enhancer to be a function. Instead, received: '" + kindOf(enhancer) + "'");
32572 }
32573
32574 return enhancer(createStore)(reducer, preloadedState);
32575 }
32576
32577 if (typeof reducer !== 'function') {
32578 throw new Error( false ? 0 : "Expected the root reducer to be a function. Instead, received: '" + kindOf(reducer) + "'");
32579 }
32580
32581 var currentReducer = reducer;
32582 var currentState = preloadedState;
32583 var currentListeners = [];
32584 var nextListeners = currentListeners;
32585 var isDispatching = false;
32586 /**
32587 * This makes a shallow copy of currentListeners so we can use
32588 * nextListeners as a temporary list while dispatching.
32589 *
32590 * This prevents any bugs around consumers calling
32591 * subscribe/unsubscribe in the middle of a dispatch.
32592 */
32593
32594 function ensureCanMutateNextListeners() {
32595 if (nextListeners === currentListeners) {
32596 nextListeners = currentListeners.slice();
32597 }
32598 }
32599 /**
32600 * Reads the state tree managed by the store.
32601 *
32602 * @returns {any} The current state tree of your application.
32603 */
32604
32605
32606 function getState() {
32607 if (isDispatching) {
32608 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.');
32609 }
32610
32611 return currentState;
32612 }
32613 /**
32614 * Adds a change listener. It will be called any time an action is dispatched,
32615 * and some part of the state tree may potentially have changed. You may then
32616 * call `getState()` to read the current state tree inside the callback.
32617 *
32618 * You may call `dispatch()` from a change listener, with the following
32619 * caveats:
32620 *
32621 * 1. The subscriptions are snapshotted just before every `dispatch()` call.
32622 * If you subscribe or unsubscribe while the listeners are being invoked, this
32623 * will not have any effect on the `dispatch()` that is currently in progress.
32624 * However, the next `dispatch()` call, whether nested or not, will use a more
32625 * recent snapshot of the subscription list.
32626 *
32627 * 2. The listener should not expect to see all state changes, as the state
32628 * might have been updated multiple times during a nested `dispatch()` before
32629 * the listener is called. It is, however, guaranteed that all subscribers
32630 * registered before the `dispatch()` started will be called with the latest
32631 * state by the time it exits.
32632 *
32633 * @param {Function} listener A callback to be invoked on every dispatch.
32634 * @returns {Function} A function to remove this change listener.
32635 */
32636
32637
32638 function subscribe(listener) {
32639 if (typeof listener !== 'function') {
32640 throw new Error( false ? 0 : "Expected the listener to be a function. Instead, received: '" + kindOf(listener) + "'");
32641 }
32642
32643 if (isDispatching) {
32644 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.');
32645 }
32646
32647 var isSubscribed = true;
32648 ensureCanMutateNextListeners();
32649 nextListeners.push(listener);
32650 return function unsubscribe() {
32651 if (!isSubscribed) {
32652 return;
32653 }
32654
32655 if (isDispatching) {
32656 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.');
32657 }
32658
32659 isSubscribed = false;
32660 ensureCanMutateNextListeners();
32661 var index = nextListeners.indexOf(listener);
32662 nextListeners.splice(index, 1);
32663 currentListeners = null;
32664 };
32665 }
32666 /**
32667 * Dispatches an action. It is the only way to trigger a state change.
32668 *
32669 * The `reducer` function, used to create the store, will be called with the
32670 * current state tree and the given `action`. Its return value will
32671 * be considered the **next** state of the tree, and the change listeners
32672 * will be notified.
32673 *
32674 * The base implementation only supports plain object actions. If you want to
32675 * dispatch a Promise, an Observable, a thunk, or something else, you need to
32676 * wrap your store creating function into the corresponding middleware. For
32677 * example, see the documentation for the `redux-thunk` package. Even the
32678 * middleware will eventually dispatch plain object actions using this method.
32679 *
32680 * @param {Object} action A plain object representing “what changed”. It is
32681 * a good idea to keep actions serializable so you can record and replay user
32682 * sessions, or use the time travelling `redux-devtools`. An action must have
32683 * a `type` property which may not be `undefined`. It is a good idea to use
32684 * string constants for action types.
32685 *
32686 * @returns {Object} For convenience, the same action object you dispatched.
32687 *
32688 * Note that, if you use a custom middleware, it may wrap `dispatch()` to
32689 * return something else (for example, a Promise you can await).
32690 */
32691
32692
32693 function dispatch(action) {
32694 if (!isPlainObject(action)) {
32695 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.");
32696 }
32697
32698 if (typeof action.type === 'undefined') {
32699 throw new Error( false ? 0 : 'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');
32700 }
32701
32702 if (isDispatching) {
32703 throw new Error( false ? 0 : 'Reducers may not dispatch actions.');
32704 }
32705
32706 try {
32707 isDispatching = true;
32708 currentState = currentReducer(currentState, action);
32709 } finally {
32710 isDispatching = false;
32711 }
32712
32713 var listeners = currentListeners = nextListeners;
32714
32715 for (var i = 0; i < listeners.length; i++) {
32716 var listener = listeners[i];
32717 listener();
32718 }
32719
32720 return action;
32721 }
32722 /**
32723 * Replaces the reducer currently used by the store to calculate the state.
32724 *
32725 * You might need this if your app implements code splitting and you want to
32726 * load some of the reducers dynamically. You might also need this if you
32727 * implement a hot reloading mechanism for Redux.
32728 *
32729 * @param {Function} nextReducer The reducer for the store to use instead.
32730 * @returns {void}
32731 */
32732
32733
32734 function replaceReducer(nextReducer) {
32735 if (typeof nextReducer !== 'function') {
32736 throw new Error( false ? 0 : "Expected the nextReducer to be a function. Instead, received: '" + kindOf(nextReducer));
32737 }
32738
32739 currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
32740 // Any reducers that existed in both the new and old rootReducer
32741 // will receive the previous state. This effectively populates
32742 // the new state tree with any relevant data from the old one.
32743
32744 dispatch({
32745 type: ActionTypes.REPLACE
32746 });
32747 }
32748 /**
32749 * Interoperability point for observable/reactive libraries.
32750 * @returns {observable} A minimal observable of state changes.
32751 * For more information, see the observable proposal:
32752 * https://github.com/tc39/proposal-observable
32753 */
32754
32755
32756 function observable() {
32757 var _ref;
32758
32759 var outerSubscribe = subscribe;
32760 return _ref = {
32761 /**
32762 * The minimal observable subscription method.
32763 * @param {Object} observer Any object that can be used as an observer.
32764 * The observer object should have a `next` method.
32765 * @returns {subscription} An object with an `unsubscribe` method that can
32766 * be used to unsubscribe the observable from the store, and prevent further
32767 * emission of values from the observable.
32768 */
32769 subscribe: function subscribe(observer) {
32770 if (typeof observer !== 'object' || observer === null) {
32771 throw new Error( false ? 0 : "Expected the observer to be an object. Instead, received: '" + kindOf(observer) + "'");
32772 }
32773
32774 function observeState() {
32775 if (observer.next) {
32776 observer.next(getState());
32777 }
32778 }
32779
32780 observeState();
32781 var unsubscribe = outerSubscribe(observeState);
32782 return {
32783 unsubscribe: unsubscribe
32784 };
32785 }
32786 }, _ref[$$observable] = function () {
32787 return this;
32788 }, _ref;
32789 } // When a store is created, an "INIT" action is dispatched so that every
32790 // reducer returns their initial state. This effectively populates
32791 // the initial state tree.
32792
32793
32794 dispatch({
32795 type: ActionTypes.INIT
32796 });
32797 return _ref2 = {
32798 dispatch: dispatch,
32799 subscribe: subscribe,
32800 getState: getState,
32801 replaceReducer: replaceReducer
32802 }, _ref2[$$observable] = observable, _ref2;
32803 }
32804 /**
32805 * Creates a Redux store that holds the state tree.
32806 *
32807 * **We recommend using `configureStore` from the
32808 * `@reduxjs/toolkit` package**, which replaces `createStore`:
32809 * **https://redux.js.org/introduction/why-rtk-is-redux-today**
32810 *
32811 * The only way to change the data in the store is to call `dispatch()` on it.
32812 *
32813 * There should only be a single store in your app. To specify how different
32814 * parts of the state tree respond to actions, you may combine several reducers
32815 * into a single reducer function by using `combineReducers`.
32816 *
32817 * @param {Function} reducer A function that returns the next state tree, given
32818 * the current state tree and the action to handle.
32819 *
32820 * @param {any} [preloadedState] The initial state. You may optionally specify it
32821 * to hydrate the state from the server in universal apps, or to restore a
32822 * previously serialized user session.
32823 * If you use `combineReducers` to produce the root reducer function, this must be
32824 * an object with the same shape as `combineReducers` keys.
32825 *
32826 * @param {Function} [enhancer] The store enhancer. You may optionally specify it
32827 * to enhance the store with third-party capabilities such as middleware,
32828 * time travel, persistence, etc. The only store enhancer that ships with Redux
32829 * is `applyMiddleware()`.
32830 *
32831 * @returns {Store} A Redux store that lets you read the state, dispatch actions
32832 * and subscribe to changes.
32833 */
32834
32835 var legacy_createStore = createStore;
32836
32837 /**
32838 * Prints a warning in the console if it exists.
32839 *
32840 * @param {String} message The warning message.
32841 * @returns {void}
32842 */
32843 function warning(message) {
32844 /* eslint-disable no-console */
32845 if (typeof console !== 'undefined' && typeof console.error === 'function') {
32846 console.error(message);
32847 }
32848 /* eslint-enable no-console */
32849
32850
32851 try {
32852 // This error was thrown as a convenience so that if you enable
32853 // "break on all exceptions" in your console,
32854 // it would pause the execution at this line.
32855 throw new Error(message);
32856 } catch (e) {} // eslint-disable-line no-empty
32857
32858 }
32859
32860 function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
32861 var reducerKeys = Object.keys(reducers);
32862 var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
32863
32864 if (reducerKeys.length === 0) {
32865 return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
32866 }
32867
32868 if (!isPlainObject(inputState)) {
32869 return "The " + argumentName + " has unexpected type of \"" + kindOf(inputState) + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\"");
32870 }
32871
32872 var unexpectedKeys = Object.keys(inputState).filter(function (key) {
32873 return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
32874 });
32875 unexpectedKeys.forEach(function (key) {
32876 unexpectedKeyCache[key] = true;
32877 });
32878 if (action && action.type === ActionTypes.REPLACE) return;
32879
32880 if (unexpectedKeys.length > 0) {
32881 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.");
32882 }
32883 }
32884
32885 function assertReducerShape(reducers) {
32886 Object.keys(reducers).forEach(function (key) {
32887 var reducer = reducers[key];
32888 var initialState = reducer(undefined, {
32889 type: ActionTypes.INIT
32890 });
32891
32892 if (typeof initialState === 'undefined') {
32893 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.");
32894 }
32895
32896 if (typeof reducer(undefined, {
32897 type: ActionTypes.PROBE_UNKNOWN_ACTION()
32898 }) === 'undefined') {
32899 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.");
32900 }
32901 });
32902 }
32903 /**
32904 * Turns an object whose values are different reducer functions, into a single
32905 * reducer function. It will call every child reducer, and gather their results
32906 * into a single state object, whose keys correspond to the keys of the passed
32907 * reducer functions.
32908 *
32909 * @param {Object} reducers An object whose values correspond to different
32910 * reducer functions that need to be combined into one. One handy way to obtain
32911 * it is to use ES6 `import * as reducers` syntax. The reducers may never return
32912 * undefined for any action. Instead, they should return their initial state
32913 * if the state passed to them was undefined, and the current state for any
32914 * unrecognized action.
32915 *
32916 * @returns {Function} A reducer function that invokes every reducer inside the
32917 * passed object, and builds a state object with the same shape.
32918 */
32919
32920
32921 function combineReducers(reducers) {
32922 var reducerKeys = Object.keys(reducers);
32923 var finalReducers = {};
32924
32925 for (var i = 0; i < reducerKeys.length; i++) {
32926 var key = reducerKeys[i];
32927
32928 if (true) {
32929 if (typeof reducers[key] === 'undefined') {
32930 warning("No reducer provided for key \"" + key + "\"");
32931 }
32932 }
32933
32934 if (typeof reducers[key] === 'function') {
32935 finalReducers[key] = reducers[key];
32936 }
32937 }
32938
32939 var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
32940 // keys multiple times.
32941
32942 var unexpectedKeyCache;
32943
32944 if (true) {
32945 unexpectedKeyCache = {};
32946 }
32947
32948 var shapeAssertionError;
32949
32950 try {
32951 assertReducerShape(finalReducers);
32952 } catch (e) {
32953 shapeAssertionError = e;
32954 }
32955
32956 return function combination(state, action) {
32957 if (state === void 0) {
32958 state = {};
32959 }
32960
32961 if (shapeAssertionError) {
32962 throw shapeAssertionError;
32963 }
32964
32965 if (true) {
32966 var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
32967
32968 if (warningMessage) {
32969 warning(warningMessage);
32970 }
32971 }
32972
32973 var hasChanged = false;
32974 var nextState = {};
32975
32976 for (var _i = 0; _i < finalReducerKeys.length; _i++) {
32977 var _key = finalReducerKeys[_i];
32978 var reducer = finalReducers[_key];
32979 var previousStateForKey = state[_key];
32980 var nextStateForKey = reducer(previousStateForKey, action);
32981
32982 if (typeof nextStateForKey === 'undefined') {
32983 var actionType = action && action.type;
32984 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.");
32985 }
32986
32987 nextState[_key] = nextStateForKey;
32988 hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
32989 }
32990
32991 hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
32992 return hasChanged ? nextState : state;
32993 };
32994 }
32995
32996 function bindActionCreator(actionCreator, dispatch) {
32997 return function () {
32998 return dispatch(actionCreator.apply(this, arguments));
32999 };
33000 }
33001 /**
33002 * Turns an object whose values are action creators, into an object with the
33003 * same keys, but with every function wrapped into a `dispatch` call so they
33004 * may be invoked directly. This is just a convenience method, as you can call
33005 * `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
33006 *
33007 * For convenience, you can also pass an action creator as the first argument,
33008 * and get a dispatch wrapped function in return.
33009 *
33010 * @param {Function|Object} actionCreators An object whose values are action
33011 * creator functions. One handy way to obtain it is to use ES6 `import * as`
33012 * syntax. You may also pass a single function.
33013 *
33014 * @param {Function} dispatch The `dispatch` function available on your Redux
33015 * store.
33016 *
33017 * @returns {Function|Object} The object mimicking the original object, but with
33018 * every action creator wrapped into the `dispatch` call. If you passed a
33019 * function as `actionCreators`, the return value will also be a single
33020 * function.
33021 */
33022
33023
33024 function bindActionCreators(actionCreators, dispatch) {
33025 if (typeof actionCreators === 'function') {
33026 return bindActionCreator(actionCreators, dispatch);
33027 }
33028
33029 if (typeof actionCreators !== 'object' || actionCreators === null) {
33030 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\"?");
33031 }
33032
33033 var boundActionCreators = {};
33034
33035 for (var key in actionCreators) {
33036 var actionCreator = actionCreators[key];
33037
33038 if (typeof actionCreator === 'function') {
33039 boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
33040 }
33041 }
33042
33043 return boundActionCreators;
33044 }
33045
33046 /**
33047 * Composes single-argument functions from right to left. The rightmost
33048 * function can take multiple arguments as it provides the signature for
33049 * the resulting composite function.
33050 *
33051 * @param {...Function} funcs The functions to compose.
33052 * @returns {Function} A function obtained by composing the argument functions
33053 * from right to left. For example, compose(f, g, h) is identical to doing
33054 * (...args) => f(g(h(...args))).
33055 */
33056 function compose() {
33057 for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
33058 funcs[_key] = arguments[_key];
33059 }
33060
33061 if (funcs.length === 0) {
33062 return function (arg) {
33063 return arg;
33064 };
33065 }
33066
33067 if (funcs.length === 1) {
33068 return funcs[0];
33069 }
33070
33071 return funcs.reduce(function (a, b) {
33072 return function () {
33073 return a(b.apply(void 0, arguments));
33074 };
33075 });
33076 }
33077
33078 /**
33079 * Creates a store enhancer that applies middleware to the dispatch method
33080 * of the Redux store. This is handy for a variety of tasks, such as expressing
33081 * asynchronous actions in a concise manner, or logging every action payload.
33082 *
33083 * See `redux-thunk` package as an example of the Redux middleware.
33084 *
33085 * Because middleware is potentially asynchronous, this should be the first
33086 * store enhancer in the composition chain.
33087 *
33088 * Note that each middleware will be given the `dispatch` and `getState` functions
33089 * as named arguments.
33090 *
33091 * @param {...Function} middlewares The middleware chain to be applied.
33092 * @returns {Function} A store enhancer applying the middleware.
33093 */
33094
33095 function applyMiddleware() {
33096 for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
33097 middlewares[_key] = arguments[_key];
33098 }
33099
33100 return function (createStore) {
33101 return function () {
33102 var store = createStore.apply(void 0, arguments);
33103
33104 var _dispatch = function dispatch() {
33105 throw new Error( false ? 0 : 'Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.');
33106 };
33107
33108 var middlewareAPI = {
33109 getState: store.getState,
33110 dispatch: function dispatch() {
33111 return _dispatch.apply(void 0, arguments);
33112 }
33113 };
33114 var chain = middlewares.map(function (middleware) {
33115 return middleware(middlewareAPI);
33116 });
33117 _dispatch = compose.apply(void 0, chain)(store.dispatch);
33118 return (0,_babel_runtime_helpers_esm_objectSpread2__WEBPACK_IMPORTED_MODULE_0__["default"])((0,_babel_runtime_helpers_esm_objectSpread2__WEBPACK_IMPORTED_MODULE_0__["default"])({}, store), {}, {
33119 dispatch: _dispatch
33120 });
33121 };
33122 };
33123 }
33124
33125
33126
33127
33128 /***/ }),
33129
33130 /***/ "../node_modules/reselect/es/defaultMemoize.js":
33131 /*!*****************************************************!*\
33132 !*** ../node_modules/reselect/es/defaultMemoize.js ***!
33133 \*****************************************************/
33134 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
33135
33136 "use strict";
33137 __webpack_require__.r(__webpack_exports__);
33138 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
33139 /* harmony export */ createCacheKeyComparator: () => (/* binding */ createCacheKeyComparator),
33140 /* harmony export */ defaultEqualityCheck: () => (/* binding */ defaultEqualityCheck),
33141 /* harmony export */ defaultMemoize: () => (/* binding */ defaultMemoize)
33142 /* harmony export */ });
33143 // Cache implementation based on Erik Rasmussen's `lru-memoize`:
33144 // https://github.com/erikras/lru-memoize
33145 var NOT_FOUND = 'NOT_FOUND';
33146
33147 function createSingletonCache(equals) {
33148 var entry;
33149 return {
33150 get: function get(key) {
33151 if (entry && equals(entry.key, key)) {
33152 return entry.value;
33153 }
33154
33155 return NOT_FOUND;
33156 },
33157 put: function put(key, value) {
33158 entry = {
33159 key: key,
33160 value: value
33161 };
33162 },
33163 getEntries: function getEntries() {
33164 return entry ? [entry] : [];
33165 },
33166 clear: function clear() {
33167 entry = undefined;
33168 }
33169 };
33170 }
33171
33172 function createLruCache(maxSize, equals) {
33173 var entries = [];
33174
33175 function get(key) {
33176 var cacheIndex = entries.findIndex(function (entry) {
33177 return equals(key, entry.key);
33178 }); // We found a cached entry
33179
33180 if (cacheIndex > -1) {
33181 var entry = entries[cacheIndex]; // Cached entry not at top of cache, move it to the top
33182
33183 if (cacheIndex > 0) {
33184 entries.splice(cacheIndex, 1);
33185 entries.unshift(entry);
33186 }
33187
33188 return entry.value;
33189 } // No entry found in cache, return sentinel
33190
33191
33192 return NOT_FOUND;
33193 }
33194
33195 function put(key, value) {
33196 if (get(key) === NOT_FOUND) {
33197 // TODO Is unshift slow?
33198 entries.unshift({
33199 key: key,
33200 value: value
33201 });
33202
33203 if (entries.length > maxSize) {
33204 entries.pop();
33205 }
33206 }
33207 }
33208
33209 function getEntries() {
33210 return entries;
33211 }
33212
33213 function clear() {
33214 entries = [];
33215 }
33216
33217 return {
33218 get: get,
33219 put: put,
33220 getEntries: getEntries,
33221 clear: clear
33222 };
33223 }
33224
33225 var defaultEqualityCheck = function defaultEqualityCheck(a, b) {
33226 return a === b;
33227 };
33228 function createCacheKeyComparator(equalityCheck) {
33229 return function areArgumentsShallowlyEqual(prev, next) {
33230 if (prev === null || next === null || prev.length !== next.length) {
33231 return false;
33232 } // Do this in a for loop (and not a `forEach` or an `every`) so we can determine equality as fast as possible.
33233
33234
33235 var length = prev.length;
33236
33237 for (var i = 0; i < length; i++) {
33238 if (!equalityCheck(prev[i], next[i])) {
33239 return false;
33240 }
33241 }
33242
33243 return true;
33244 };
33245 }
33246 // defaultMemoize now supports a configurable cache size with LRU behavior,
33247 // and optional comparison of the result value with existing values
33248 function defaultMemoize(func, equalityCheckOrOptions) {
33249 var providedOptions = typeof equalityCheckOrOptions === 'object' ? equalityCheckOrOptions : {
33250 equalityCheck: equalityCheckOrOptions
33251 };
33252 var _providedOptions$equa = providedOptions.equalityCheck,
33253 equalityCheck = _providedOptions$equa === void 0 ? defaultEqualityCheck : _providedOptions$equa,
33254 _providedOptions$maxS = providedOptions.maxSize,
33255 maxSize = _providedOptions$maxS === void 0 ? 1 : _providedOptions$maxS,
33256 resultEqualityCheck = providedOptions.resultEqualityCheck;
33257 var comparator = createCacheKeyComparator(equalityCheck);
33258 var cache = maxSize === 1 ? createSingletonCache(comparator) : createLruCache(maxSize, comparator); // we reference arguments instead of spreading them for performance reasons
33259
33260 function memoized() {
33261 var value = cache.get(arguments);
33262
33263 if (value === NOT_FOUND) {
33264 // @ts-ignore
33265 value = func.apply(null, arguments);
33266
33267 if (resultEqualityCheck) {
33268 var entries = cache.getEntries();
33269 var matchingEntry = entries.find(function (entry) {
33270 return resultEqualityCheck(entry.value, value);
33271 });
33272
33273 if (matchingEntry) {
33274 value = matchingEntry.value;
33275 }
33276 }
33277
33278 cache.put(arguments, value);
33279 }
33280
33281 return value;
33282 }
33283
33284 memoized.clearCache = function () {
33285 return cache.clear();
33286 };
33287
33288 return memoized;
33289 }
33290
33291 /***/ }),
33292
33293 /***/ "../node_modules/reselect/es/index.js":
33294 /*!********************************************!*\
33295 !*** ../node_modules/reselect/es/index.js ***!
33296 \********************************************/
33297 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
33298
33299 "use strict";
33300 __webpack_require__.r(__webpack_exports__);
33301 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
33302 /* harmony export */ createSelector: () => (/* binding */ createSelector),
33303 /* harmony export */ createSelectorCreator: () => (/* binding */ createSelectorCreator),
33304 /* harmony export */ createStructuredSelector: () => (/* binding */ createStructuredSelector),
33305 /* harmony export */ defaultEqualityCheck: () => (/* reexport safe */ _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultEqualityCheck),
33306 /* harmony export */ defaultMemoize: () => (/* reexport safe */ _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultMemoize)
33307 /* harmony export */ });
33308 /* harmony import */ var _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultMemoize */ "../node_modules/reselect/es/defaultMemoize.js");
33309
33310
33311
33312 function getDependencies(funcs) {
33313 var dependencies = Array.isArray(funcs[0]) ? funcs[0] : funcs;
33314
33315 if (!dependencies.every(function (dep) {
33316 return typeof dep === 'function';
33317 })) {
33318 var dependencyTypes = dependencies.map(function (dep) {
33319 return typeof dep === 'function' ? "function " + (dep.name || 'unnamed') + "()" : typeof dep;
33320 }).join(', ');
33321 throw new Error("createSelector expects all input-selectors to be functions, but received the following types: [" + dependencyTypes + "]");
33322 }
33323
33324 return dependencies;
33325 }
33326
33327 function createSelectorCreator(memoize) {
33328 for (var _len = arguments.length, memoizeOptionsFromArgs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
33329 memoizeOptionsFromArgs[_key - 1] = arguments[_key];
33330 }
33331
33332 var createSelector = function createSelector() {
33333 for (var _len2 = arguments.length, funcs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
33334 funcs[_key2] = arguments[_key2];
33335 }
33336
33337 var _recomputations = 0;
33338
33339 var _lastResult; // Due to the intricacies of rest params, we can't do an optional arg after `...funcs`.
33340 // So, start by declaring the default value here.
33341 // (And yes, the words 'memoize' and 'options' appear too many times in this next sequence.)
33342
33343
33344 var directlyPassedOptions = {
33345 memoizeOptions: undefined
33346 }; // Normally, the result func or "output selector" is the last arg
33347
33348 var resultFunc = funcs.pop(); // If the result func is actually an _object_, assume it's our options object
33349
33350 if (typeof resultFunc === 'object') {
33351 directlyPassedOptions = resultFunc; // and pop the real result func off
33352
33353 resultFunc = funcs.pop();
33354 }
33355
33356 if (typeof resultFunc !== 'function') {
33357 throw new Error("createSelector expects an output function after the inputs, but received: [" + typeof resultFunc + "]");
33358 } // Determine which set of options we're using. Prefer options passed directly,
33359 // but fall back to options given to createSelectorCreator.
33360
33361
33362 var _directlyPassedOption = directlyPassedOptions,
33363 _directlyPassedOption2 = _directlyPassedOption.memoizeOptions,
33364 memoizeOptions = _directlyPassedOption2 === void 0 ? memoizeOptionsFromArgs : _directlyPassedOption2; // Simplifying assumption: it's unlikely that the first options arg of the provided memoizer
33365 // is an array. In most libs I've looked at, it's an equality function or options object.
33366 // Based on that, if `memoizeOptions` _is_ an array, we assume it's a full
33367 // user-provided array of options. Otherwise, it must be just the _first_ arg, and so
33368 // we wrap it in an array so we can apply it.
33369
33370 var finalMemoizeOptions = Array.isArray(memoizeOptions) ? memoizeOptions : [memoizeOptions];
33371 var dependencies = getDependencies(funcs);
33372 var memoizedResultFunc = memoize.apply(void 0, [function recomputationWrapper() {
33373 _recomputations++; // apply arguments instead of spreading for performance.
33374
33375 return resultFunc.apply(null, arguments);
33376 }].concat(finalMemoizeOptions)); // If a selector is called with the exact same arguments we don't need to traverse our dependencies again.
33377
33378 var selector = memoize(function dependenciesChecker() {
33379 var params = [];
33380 var length = dependencies.length;
33381
33382 for (var i = 0; i < length; i++) {
33383 // apply arguments instead of spreading and mutate a local list of params for performance.
33384 // @ts-ignore
33385 params.push(dependencies[i].apply(null, arguments));
33386 } // apply arguments instead of spreading for performance.
33387
33388
33389 _lastResult = memoizedResultFunc.apply(null, params);
33390 return _lastResult;
33391 });
33392 Object.assign(selector, {
33393 resultFunc: resultFunc,
33394 memoizedResultFunc: memoizedResultFunc,
33395 dependencies: dependencies,
33396 lastResult: function lastResult() {
33397 return _lastResult;
33398 },
33399 recomputations: function recomputations() {
33400 return _recomputations;
33401 },
33402 resetRecomputations: function resetRecomputations() {
33403 return _recomputations = 0;
33404 }
33405 });
33406 return selector;
33407 }; // @ts-ignore
33408
33409
33410 return createSelector;
33411 }
33412 var createSelector = /* #__PURE__ */createSelectorCreator(_defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultMemoize);
33413 // Manual definition of state and output arguments
33414 var createStructuredSelector = function createStructuredSelector(selectors, selectorCreator) {
33415 if (selectorCreator === void 0) {
33416 selectorCreator = createSelector;
33417 }
33418
33419 if (typeof selectors !== 'object') {
33420 throw new Error('createStructuredSelector expects first argument to be an object ' + ("where each property is a selector, instead received a " + typeof selectors));
33421 }
33422
33423 var objectKeys = Object.keys(selectors);
33424 var resultSelector = selectorCreator( // @ts-ignore
33425 objectKeys.map(function (key) {
33426 return selectors[key];
33427 }), function () {
33428 for (var _len3 = arguments.length, values = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
33429 values[_key3] = arguments[_key3];
33430 }
33431
33432 return values.reduce(function (composition, value, index) {
33433 composition[objectKeys[index]] = value;
33434 return composition;
33435 }, {});
33436 });
33437 return resultSelector;
33438 };
33439
33440 /***/ }),
33441
33442 /***/ "@wordpress/i18n":
33443 /*!**************************!*\
33444 !*** external "wp.i18n" ***!
33445 \**************************/
33446 /***/ ((module) => {
33447
33448 "use strict";
33449 module.exports = wp.i18n;
33450
33451 /***/ })
33452
33453 /******/ });
33454 /************************************************************************/
33455 /******/ // The module cache
33456 /******/ var __webpack_module_cache__ = {};
33457 /******/
33458 /******/ // The require function
33459 /******/ function __webpack_require__(moduleId) {
33460 /******/ // Check if module is in cache
33461 /******/ var cachedModule = __webpack_module_cache__[moduleId];
33462 /******/ if (cachedModule !== undefined) {
33463 /******/ return cachedModule.exports;
33464 /******/ }
33465 /******/ // Create a new module (and put it into the cache)
33466 /******/ var module = __webpack_module_cache__[moduleId] = {
33467 /******/ // no module.id needed
33468 /******/ // no module.loaded needed
33469 /******/ exports: {}
33470 /******/ };
33471 /******/
33472 /******/ // Execute the module function
33473 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
33474 /******/
33475 /******/ // Return the exports of the module
33476 /******/ return module.exports;
33477 /******/ }
33478 /******/
33479 /************************************************************************/
33480 /******/ /* webpack/runtime/define property getters */
33481 /******/ (() => {
33482 /******/ // define getter functions for harmony exports
33483 /******/ __webpack_require__.d = (exports, definition) => {
33484 /******/ for(var key in definition) {
33485 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
33486 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
33487 /******/ }
33488 /******/ }
33489 /******/ };
33490 /******/ })();
33491 /******/
33492 /******/ /* webpack/runtime/global */
33493 /******/ (() => {
33494 /******/ __webpack_require__.g = (function() {
33495 /******/ if (typeof globalThis === 'object') return globalThis;
33496 /******/ try {
33497 /******/ return this || new Function('return this')();
33498 /******/ } catch (e) {
33499 /******/ if (typeof window === 'object') return window;
33500 /******/ }
33501 /******/ })();
33502 /******/ })();
33503 /******/
33504 /******/ /* webpack/runtime/hasOwnProperty shorthand */
33505 /******/ (() => {
33506 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
33507 /******/ })();
33508 /******/
33509 /******/ /* webpack/runtime/make namespace object */
33510 /******/ (() => {
33511 /******/ // define __esModule on exports
33512 /******/ __webpack_require__.r = (exports) => {
33513 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
33514 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
33515 /******/ }
33516 /******/ Object.defineProperty(exports, '__esModule', { value: true });
33517 /******/ };
33518 /******/ })();
33519 /******/
33520 /************************************************************************/
33521 var __webpack_exports__ = {};
33522 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
33523 (() => {
33524 "use strict";
33525 /*!******************************************!*\
33526 !*** ../core/common/assets/js/common.js ***!
33527 \******************************************/
33528
33529
33530 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
33531 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
33532 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
33533 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
33534 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
33535 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
33536 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
33537 var _helpers = _interopRequireDefault(__webpack_require__(/*! ./utils/helpers */ "../core/common/assets/js/utils/helpers.js"));
33538 var _storage = _interopRequireDefault(__webpack_require__(/*! ./utils/storage */ "../core/common/assets/js/utils/storage.js"));
33539 var _debug = _interopRequireDefault(__webpack_require__(/*! ./utils/debug */ "../core/common/assets/js/utils/debug.js"));
33540 var _ajax = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/ajax/assets/js/ajax */ "../core/common/modules/ajax/assets/js/ajax.js"));
33541 var _finder = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/finder/assets/js/finder */ "../core/common/modules/finder/assets/js/finder.js"));
33542 var _connect = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/connect/assets/js/connect */ "../core/common/modules/connect/assets/js/connect.js"));
33543 var _component = _interopRequireDefault(__webpack_require__(/*! ./components/wordpress/component */ "../core/common/assets/js/components/wordpress/component.js"));
33544 var _component2 = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/event-tracker/assets/js/data/component */ "../core/common/modules/event-tracker/assets/js/data/component.js"));
33545 var _events = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/event-tracker/assets/js/events */ "../core/common/modules/event-tracker/assets/js/events.js"));
33546 var _module = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/events-manager/assets/js/module */ "../core/common/modules/events-manager/assets/js/module.js"));
33547 var _notifications = _interopRequireDefault(__webpack_require__(/*! elementor-utils/notifications */ "../assets/dev/js/utils/notifications.js"));
33548 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)); }
33549 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
33550 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; }
33551 var ElementorCommonApp = /*#__PURE__*/function (_elementorModules$Vie) {
33552 function ElementorCommonApp() {
33553 (0, _classCallCheck2.default)(this, ElementorCommonApp);
33554 return _callSuper(this, ElementorCommonApp, arguments);
33555 }
33556 (0, _inherits2.default)(ElementorCommonApp, _elementorModules$Vie);
33557 return (0, _createClass2.default)(ElementorCommonApp, [{
33558 key: "setMarionetteTemplateCompiler",
33559 value: function setMarionetteTemplateCompiler() {
33560 Marionette.TemplateCache.prototype.compileTemplate = function (rawTemplate, options) {
33561 options = {
33562 evaluate: /<#([\s\S]+?)#>/g,
33563 interpolate: /{{{([\s\S]+?)}}}/g,
33564 escape: /{{([^}]+?)}}(?!})/g
33565 };
33566 return _.template(rawTemplate, options);
33567 };
33568 }
33569 }, {
33570 key: "getDefaultElements",
33571 value: function getDefaultElements() {
33572 return {
33573 $window: jQuery(window),
33574 $document: jQuery(document),
33575 $body: jQuery(document.body)
33576 };
33577 }
33578 }, {
33579 key: "initComponents",
33580 value: function initComponents() {
33581 this.events = new _events.default();
33582 this.eventsManager = new _module.default();
33583 this.debug = new _debug.default();
33584 this.helpers = new _helpers.default();
33585 this.storage = new _storage.default();
33586 this.dialogsManager = new DialogsManager.Instance();
33587 this.notifications = new _notifications.default();
33588 this.api = window.$e;
33589 $e.components.register(new _component2.default());
33590 elementorCommon.elements.$window.on('elementor:init-components', function () {
33591 $e.components.register(new _component.default());
33592 });
33593 this.initModules();
33594 }
33595 }, {
33596 key: "initModules",
33597 value: function initModules() {
33598 var _this = this;
33599 var activeModules = this.config.activeModules;
33600 var modules = {
33601 ajax: _ajax.default,
33602 finder: _finder.default,
33603 connect: _connect.default
33604 };
33605 activeModules.forEach(function (name) {
33606 if (modules[name]) {
33607 _this[name] = new modules[name](_this.config[name]);
33608 }
33609 });
33610 }
33611 }, {
33612 key: "compileArrayTemplateArgs",
33613 value: function compileArrayTemplateArgs(template, templateArgs) {
33614 return template.replace(/%(?:(\d+)\$)?s/g, function (match, number) {
33615 if (!number) {
33616 number = 1;
33617 }
33618 number--;
33619 return undefined !== templateArgs[number] ? templateArgs[number] : match;
33620 });
33621 }
33622 }, {
33623 key: "compileObjectTemplateArgs",
33624 value: function compileObjectTemplateArgs(template, templateArgs) {
33625 return template.replace(/{{(?:([ \w]+))}}/g, function (match, name) {
33626 return templateArgs[name] ? templateArgs[name] : match;
33627 });
33628 }
33629 }, {
33630 key: "compileTemplate",
33631 value: function compileTemplate(template, templateArgs) {
33632 return jQuery.isPlainObject(templateArgs) ? this.compileObjectTemplateArgs(template, templateArgs) : this.compileArrayTemplateArgs(template, templateArgs);
33633 }
33634 }, {
33635 key: "translate",
33636 value: function translate(stringKey, context, templateArgs, i18nStack) {
33637 if (context) {
33638 i18nStack = this.config[context].i18n;
33639 }
33640 if (!i18nStack) {
33641 i18nStack = this.config.i18n;
33642 }
33643 var string = i18nStack[stringKey];
33644 if (undefined === string) {
33645 string = stringKey;
33646 }
33647 if (templateArgs) {
33648 string = this.compileTemplate(string, templateArgs);
33649 }
33650 return string;
33651 }
33652 }, {
33653 key: "onInit",
33654 value: function onInit() {
33655 _superPropGet(ElementorCommonApp, "onInit", this, 3)([]);
33656 this.config = elementorCommonConfig;
33657 this.setMarionetteTemplateCompiler();
33658 }
33659 }]);
33660 }(elementorModules.ViewModule);
33661 window.elementorCommon = new ElementorCommonApp();
33662 elementorCommon.initComponents();
33663 })();
33664
33665 /******/ })()
33666 ;
33667 //# sourceMappingURL=common.js.map