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

33,671 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 variableSyncToV3: 'variable_sync_to_v3'
2360 },
2361 components: {
2362 createClicked: 'component_create_clicked',
2363 createCancelled: 'component_creation_cancelled',
2364 created: 'component_created',
2365 instanceAdded: 'component_instance_added',
2366 edited: 'component_edited',
2367 propertiesPanelOpened: 'component_properties_panel_opened',
2368 propertiesGroupCreated: 'component_properties_group_created',
2369 propertyExposed: 'component_property_exposed',
2370 propertyRemoved: 'component_property_removed',
2371 detached: 'component_detached'
2372 },
2373 global_classes: {
2374 classApplied: 'class_applied',
2375 classRemoved: 'class_removed',
2376 classManagerFilterCleared: 'class_manager_filter_cleared',
2377 classDeleted: 'class_deleted',
2378 classPublishConflict: 'class_publish_conflict',
2379 classRenamed: 'class_renamed',
2380 classCreated: 'class_created',
2381 classManagerSearched: 'class_manager_searched',
2382 classManagerFiltersOpened: 'class_manager_filters_opened',
2383 classManagerOpened: 'class_manager_opened',
2384 classManagerReorder: 'class_manager_reorder',
2385 classManagerFilterUsed: 'class_manager_filter_used',
2386 classUsageLocate: 'class_usage_locate',
2387 classUsageHovered: 'class_usage_hovered',
2388 classStyled: 'class_styled',
2389 classStateClicked: 'class_state_clicked',
2390 classUsageClicked: 'class_usage_clicked',
2391 classDuplicate: 'class_duplicate',
2392 classSyncToV3PopupShown: 'class_sync_to_v3_popup_shown',
2393 classSyncToV3: 'class_sync_to_v3',
2394 classSyncToV3PopupClick: 'class_sync_to_v3_popup_click'
2395 },
2396 editorOne: {
2397 topBarPublishDropdown: 'top_bar_publish_dropdown',
2398 topBarPageList: 'top_bar_page_list',
2399 siteSettingsSession: 'site_settings_session',
2400 eLibraryNav: 'e_library_nav',
2401 eLibraryInsert: 'e_library_insert',
2402 eLibraryFavorite: 'e_library_favorite',
2403 eLibraryGenerateAi: 'e_library_generate_ai',
2404 finderSearchInput: 'finder_search_input',
2405 finderResultSelect: 'finder_result_select',
2406 canvasEmptyBoxAction: 'canvas_empty_box_action',
2407 widgetPanelSearch: 'widget_panel_search'
2408 },
2409 interactions: {
2410 created: 'interactions_created'
2411 },
2412 promotions: {
2413 viewPromotion: 'view_promotion',
2414 upgradePromotionClick: 'upgrade_promotion_click'
2415 }
2416 }
2417 };
2418 var _default = exports["default"] = eventsConfig;
2419
2420 /***/ }),
2421
2422 /***/ "../core/common/modules/events-manager/assets/js/module.js":
2423 /*!*****************************************************************!*\
2424 !*** ../core/common/modules/events-manager/assets/js/module.js ***!
2425 \*****************************************************************/
2426 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2427
2428 "use strict";
2429
2430
2431 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2432 Object.defineProperty(exports, "__esModule", ({
2433 value: true
2434 }));
2435 exports["default"] = void 0;
2436 var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "../node_modules/@babel/runtime/regenerator/index.js"));
2437 var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "../node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
2438 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2439 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2440 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2441 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2442 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2443 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
2444 var _eventsConfig = _interopRequireDefault(__webpack_require__(/*! ./events-config */ "../core/common/modules/events-manager/assets/js/events-config.js"));
2445 var _mixpanelBrowser = _interopRequireDefault(__webpack_require__(/*! mixpanel-browser */ "../node_modules/mixpanel-browser/dist/mixpanel.module.js"));
2446 var _tiers = __webpack_require__(/*! elementor-utils/tiers */ "../assets/dev/js/utils/tiers.js");
2447 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; }
2448 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; }
2449 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)); }
2450 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2451 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
2452 function _default() {
2453 var _this;
2454 (0, _classCallCheck2.default)(this, _default);
2455 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2456 args[_key] = arguments[_key];
2457 }
2458 _this = _callSuper(this, _default, [].concat(args));
2459 (0, _defineProperty2.default)(_this, "trackingEnabled", false);
2460 return _this;
2461 }
2462 (0, _inherits2.default)(_default, _elementorModules$Mod);
2463 return (0, _createClass2.default)(_default, [{
2464 key: "onInit",
2465 value: function onInit() {
2466 var _this2 = this;
2467 this.config = _eventsConfig.default;
2468 if (!this.canSendEvents()) {
2469 return;
2470 }
2471 this.initializeMixpanel(function () {
2472 return _this2.enableTracking();
2473 });
2474 }
2475 }, {
2476 key: "initializeMixpanel",
2477 value: function initializeMixpanel(onLoaded) {
2478 var _elementorCommon$conf;
2479 _mixpanelBrowser.default.init((_elementorCommon$conf = elementorCommon.config.editor_events) === null || _elementorCommon$conf === void 0 ? void 0 : _elementorCommon$conf.token, {
2480 persistence: 'localStorage',
2481 autocapture: false,
2482 flags: true,
2483 api_hosts: {
2484 flags: 'https://api-eu.mixpanel.com'
2485 },
2486 loaded: onLoaded
2487 });
2488 }
2489 }, {
2490 key: "enableTracking",
2491 value: function enableTracking() {
2492 var _elementorCommon$conf2;
2493 if (!this.isMixpanelReady()) {
2494 return;
2495 }
2496 var userId = (_elementorCommon$conf2 = elementorCommon.config.library_connect) === null || _elementorCommon$conf2 === void 0 ? void 0 : _elementorCommon$conf2.user_id;
2497 if (userId) {
2498 var _elementorCommon$conf3;
2499 _mixpanelBrowser.default.identify(userId);
2500 _mixpanelBrowser.default.register({
2501 appType: 'Editor'
2502 });
2503 _mixpanelBrowser.default.people.set_once({
2504 $user_id: userId,
2505 $last_login: new Date().toISOString(),
2506 $plan_type: ((_elementorCommon$conf3 = elementorCommon.config.library_connect) === null || _elementorCommon$conf3 === void 0 ? void 0 : _elementorCommon$conf3.plan_type) || _tiers.TIERS.free
2507 });
2508 }
2509 this.trackingEnabled = true;
2510 }
2511 }, {
2512 key: "dispatchEvent",
2513 value: function dispatchEvent(name, data) {
2514 var _elementorCommon$conf4, _elementorCommon$conf5, _elementorCommon$conf6, _elementorCommon$conf7, _elementorCommon$conf8, _elementorCommon$conf9, _elementorCommon$conf0, _elementorCommon$conf1, _elementorCommon$conf10;
2515 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2516 if (!this.canSendEvents()) {
2517 return;
2518 }
2519 if (!this.trackingEnabled) {
2520 this.enableTracking();
2521 }
2522 var eventData = _objectSpread({
2523 user_id: ((_elementorCommon$conf4 = elementorCommon.config.library_connect) === null || _elementorCommon$conf4 === void 0 ? void 0 : _elementorCommon$conf4.user_id) || null,
2524 user_roles: ((_elementorCommon$conf5 = elementorCommon.config.library_connect) === null || _elementorCommon$conf5 === void 0 ? void 0 : _elementorCommon$conf5.user_roles) || [],
2525 subscription_id: ((_elementorCommon$conf6 = elementorCommon.config.editor_events) === null || _elementorCommon$conf6 === void 0 ? void 0 : _elementorCommon$conf6.subscription_id) || null,
2526 user_tier: ((_elementorCommon$conf7 = elementorCommon.config.library_connect) === null || _elementorCommon$conf7 === void 0 ? void 0 : _elementorCommon$conf7.current_access_tier) || null,
2527 url: (_elementorCommon$conf8 = elementorCommon.config.editor_events) === null || _elementorCommon$conf8 === void 0 ? void 0 : _elementorCommon$conf8.site_url,
2528 wp_version: (_elementorCommon$conf9 = elementorCommon.config.editor_events) === null || _elementorCommon$conf9 === void 0 ? void 0 : _elementorCommon$conf9.wp_version,
2529 client_id: (_elementorCommon$conf0 = elementorCommon.config.editor_events) === null || _elementorCommon$conf0 === void 0 ? void 0 : _elementorCommon$conf0.site_key,
2530 app_version: (_elementorCommon$conf1 = elementorCommon.config.editor_events) === null || _elementorCommon$conf1 === void 0 ? void 0 : _elementorCommon$conf1.elementor_version,
2531 site_language: (_elementorCommon$conf10 = elementorCommon.config.editor_events) === null || _elementorCommon$conf10 === void 0 ? void 0 : _elementorCommon$conf10.site_language
2532 }, data);
2533 _mixpanelBrowser.default.track(name, eventData, options);
2534 }
2535 }, {
2536 key: "featureFlagIsActive",
2537 value: function () {
2538 var _featureFlagIsActive = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(flagName) {
2539 var _mixpanel$flags;
2540 var isEnabled;
2541 return _regenerator.default.wrap(function (_context) {
2542 while (1) switch (_context.prev = _context.next) {
2543 case 0:
2544 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))) {
2545 _context.next = 1;
2546 break;
2547 }
2548 return _context.abrupt("return", false);
2549 case 1:
2550 _context.next = 2;
2551 return _mixpanelBrowser.default.flags.is_enabled(flagName, false);
2552 case 2:
2553 isEnabled = _context.sent;
2554 return _context.abrupt("return", true === isEnabled);
2555 case 3:
2556 case "end":
2557 return _context.stop();
2558 }
2559 }, _callee);
2560 }));
2561 function featureFlagIsActive(_x) {
2562 return _featureFlagIsActive.apply(this, arguments);
2563 }
2564 return featureFlagIsActive;
2565 }()
2566 }, {
2567 key: "getExperimentVariant",
2568 value: function () {
2569 var _getExperimentVariant = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2(experimentName) {
2570 var defaultValue,
2571 _elementorCommon$conf11,
2572 _elementorCommon$conf12,
2573 isAbTestingEnabled,
2574 variant,
2575 _args2 = arguments,
2576 _t;
2577 return _regenerator.default.wrap(function (_context2) {
2578 while (1) switch (_context2.prev = _context2.next) {
2579 case 0:
2580 defaultValue = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : 'control';
2581 _context2.prev = 1;
2582 if (this.canSendEvents()) {
2583 _context2.next = 2;
2584 break;
2585 }
2586 return _context2.abrupt("return", defaultValue);
2587 case 2:
2588 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;
2589 if (isAbTestingEnabled) {
2590 _context2.next = 3;
2591 break;
2592 }
2593 return _context2.abrupt("return", defaultValue);
2594 case 3:
2595 if (_mixpanelBrowser.default) {
2596 _context2.next = 4;
2597 break;
2598 }
2599 return _context2.abrupt("return", defaultValue);
2600 case 4:
2601 if (!this.trackingEnabled) {
2602 this.enableTracking();
2603 }
2604 if (_mixpanelBrowser.default.flags) {
2605 _context2.next = 5;
2606 break;
2607 }
2608 return _context2.abrupt("return", defaultValue);
2609 case 5:
2610 if (!('function' !== typeof _mixpanelBrowser.default.flags.get_variant_value)) {
2611 _context2.next = 6;
2612 break;
2613 }
2614 return _context2.abrupt("return", defaultValue);
2615 case 6:
2616 _context2.next = 7;
2617 return _mixpanelBrowser.default.flags.get_variant_value(experimentName, defaultValue);
2618 case 7:
2619 variant = _context2.sent;
2620 if (!(undefined === variant || null === variant)) {
2621 _context2.next = 8;
2622 break;
2623 }
2624 return _context2.abrupt("return", defaultValue);
2625 case 8:
2626 return _context2.abrupt("return", variant);
2627 case 9:
2628 _context2.prev = 9;
2629 _t = _context2["catch"](1);
2630 return _context2.abrupt("return", defaultValue);
2631 case 10:
2632 case "end":
2633 return _context2.stop();
2634 }
2635 }, _callee2, this, [[1, 9]]);
2636 }));
2637 function getExperimentVariant(_x2) {
2638 return _getExperimentVariant.apply(this, arguments);
2639 }
2640 return getExperimentVariant;
2641 }()
2642 }, {
2643 key: "startExperiment",
2644 value: function startExperiment(experimentName, experimentVariant) {
2645 if (!this.trackingEnabled) {
2646 return;
2647 }
2648 _mixpanelBrowser.default.track('$experiment_started', {
2649 'Experiment name': experimentName,
2650 'Variant name': experimentVariant
2651 });
2652 }
2653 }, {
2654 key: "isMixpanelReady",
2655 value: function isMixpanelReady() {
2656 if ('undefined' === typeof _mixpanelBrowser.default || !_mixpanelBrowser.default) {
2657 return false;
2658 }
2659 try {
2660 var distinctId = _mixpanelBrowser.default.get_distinct_id();
2661 return distinctId !== undefined && distinctId !== null;
2662 } catch (error) {
2663 return false;
2664 }
2665 }
2666 }, {
2667 key: "canSendEvents",
2668 value: function canSendEvents() {
2669 var _elementorCommon;
2670 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);
2671 }
2672 }, {
2673 key: "getMixpanelInstance",
2674 value: function getMixpanelInstance() {
2675 return this.isMixpanelReady() ? _mixpanelBrowser.default : undefined;
2676 }
2677 }]);
2678 }(elementorModules.Module);
2679
2680 /***/ }),
2681
2682 /***/ "../core/common/modules/finder/assets/js/commands/index.js":
2683 /*!*****************************************************************!*\
2684 !*** ../core/common/modules/finder/assets/js/commands/index.js ***!
2685 \*****************************************************************/
2686 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2687
2688 "use strict";
2689
2690
2691 Object.defineProperty(exports, "__esModule", ({
2692 value: true
2693 }));
2694 Object.defineProperty(exports, "NavigateDown", ({
2695 enumerable: true,
2696 get: function get() {
2697 return _navigateDown.NavigateDown;
2698 }
2699 }));
2700 Object.defineProperty(exports, "NavigateSelect", ({
2701 enumerable: true,
2702 get: function get() {
2703 return _navigateSelect.NavigateSelect;
2704 }
2705 }));
2706 Object.defineProperty(exports, "NavigateUp", ({
2707 enumerable: true,
2708 get: function get() {
2709 return _navigateUp.NavigateUp;
2710 }
2711 }));
2712 var _navigateDown = __webpack_require__(/*! ./navigate-down */ "../core/common/modules/finder/assets/js/commands/navigate-down.js");
2713 var _navigateSelect = __webpack_require__(/*! ./navigate-select */ "../core/common/modules/finder/assets/js/commands/navigate-select.js");
2714 var _navigateUp = __webpack_require__(/*! ./navigate-up */ "../core/common/modules/finder/assets/js/commands/navigate-up.js");
2715
2716 /***/ }),
2717
2718 /***/ "../core/common/modules/finder/assets/js/commands/navigate-down.js":
2719 /*!*************************************************************************!*\
2720 !*** ../core/common/modules/finder/assets/js/commands/navigate-down.js ***!
2721 \*************************************************************************/
2722 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2723
2724 "use strict";
2725
2726
2727 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2728 Object.defineProperty(exports, "__esModule", ({
2729 value: true
2730 }));
2731 exports["default"] = exports.NavigateDown = void 0;
2732 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2733 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2734 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2735 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2736 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2737 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2738 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)); }
2739 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2740 var NavigateDown = exports.NavigateDown = /*#__PURE__*/function (_CommandBase) {
2741 function NavigateDown() {
2742 (0, _classCallCheck2.default)(this, NavigateDown);
2743 return _callSuper(this, NavigateDown, arguments);
2744 }
2745 (0, _inherits2.default)(NavigateDown, _CommandBase);
2746 return (0, _createClass2.default)(NavigateDown, [{
2747 key: "apply",
2748 value: function apply() {
2749 this.component.getItemsView().activateNextItem();
2750 }
2751 }]);
2752 }(_commandBase.default);
2753 var _default = exports["default"] = NavigateDown;
2754
2755 /***/ }),
2756
2757 /***/ "../core/common/modules/finder/assets/js/commands/navigate-select.js":
2758 /*!***************************************************************************!*\
2759 !*** ../core/common/modules/finder/assets/js/commands/navigate-select.js ***!
2760 \***************************************************************************/
2761 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2762
2763 "use strict";
2764
2765
2766 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2767 Object.defineProperty(exports, "__esModule", ({
2768 value: true
2769 }));
2770 exports["default"] = exports.NavigateSelect = void 0;
2771 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2772 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2773 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2774 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2775 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2776 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2777 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)); }
2778 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2779 var NavigateSelect = exports.NavigateSelect = /*#__PURE__*/function (_CommandBase) {
2780 function NavigateSelect() {
2781 (0, _classCallCheck2.default)(this, NavigateSelect);
2782 return _callSuper(this, NavigateSelect, arguments);
2783 }
2784 (0, _inherits2.default)(NavigateSelect, _CommandBase);
2785 return (0, _createClass2.default)(NavigateSelect, [{
2786 key: "apply",
2787 value: function apply(args) {
2788 this.component.getItemsView().goToActiveItem(args);
2789 }
2790 }]);
2791 }(_commandBase.default);
2792 var _default = exports["default"] = NavigateSelect;
2793
2794 /***/ }),
2795
2796 /***/ "../core/common/modules/finder/assets/js/commands/navigate-up.js":
2797 /*!***********************************************************************!*\
2798 !*** ../core/common/modules/finder/assets/js/commands/navigate-up.js ***!
2799 \***********************************************************************/
2800 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2801
2802 "use strict";
2803
2804
2805 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2806 Object.defineProperty(exports, "__esModule", ({
2807 value: true
2808 }));
2809 exports["default"] = exports.NavigateUp = void 0;
2810 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2811 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2812 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2813 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2814 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2815 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2816 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)); }
2817 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2818 var NavigateUp = exports.NavigateUp = /*#__PURE__*/function (_CommandBase) {
2819 function NavigateUp() {
2820 (0, _classCallCheck2.default)(this, NavigateUp);
2821 return _callSuper(this, NavigateUp, arguments);
2822 }
2823 (0, _inherits2.default)(NavigateUp, _CommandBase);
2824 return (0, _createClass2.default)(NavigateUp, [{
2825 key: "apply",
2826 value: function apply() {
2827 this.component.getItemsView().activateNextItem(true);
2828 }
2829 }]);
2830 }(_commandBase.default);
2831 var _default = exports["default"] = NavigateUp;
2832
2833 /***/ }),
2834
2835 /***/ "../core/common/modules/finder/assets/js/component.js":
2836 /*!************************************************************!*\
2837 !*** ../core/common/modules/finder/assets/js/component.js ***!
2838 \************************************************************/
2839 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2840
2841 "use strict";
2842
2843
2844 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2845 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
2846 Object.defineProperty(exports, "__esModule", ({
2847 value: true
2848 }));
2849 exports["default"] = void 0;
2850 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
2851 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2852 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2853 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2854 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2855 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
2856 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2857 var _componentModalBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/component-modal-base */ "../modules/web-cli/assets/js/modules/component-modal-base.js"));
2858 var _layout = _interopRequireDefault(__webpack_require__(/*! ./modal/views/layout */ "../core/common/modules/finder/assets/js/modal/views/layout.js"));
2859 var commands = _interopRequireWildcard(__webpack_require__(/*! ./commands/ */ "../core/common/modules/finder/assets/js/commands/index.js"));
2860 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); }
2861 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; }
2862 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; }
2863 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)); }
2864 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2865 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; }
2866 var Component = exports["default"] = /*#__PURE__*/function (_ComponentModalBase) {
2867 function Component() {
2868 (0, _classCallCheck2.default)(this, Component);
2869 return _callSuper(this, Component, arguments);
2870 }
2871 (0, _inherits2.default)(Component, _ComponentModalBase);
2872 return (0, _createClass2.default)(Component, [{
2873 key: "getNamespace",
2874 value: function getNamespace() {
2875 return 'finder';
2876 }
2877 }, {
2878 key: "defaultShortcuts",
2879 value: function defaultShortcuts() {
2880 var _this = this;
2881 return {
2882 '': {
2883 keys: 'ctrl+e'
2884 },
2885 'navigate-down': {
2886 keys: 'down',
2887 scopes: [this.getNamespace()],
2888 dependency: function dependency() {
2889 return _this.getItemsView();
2890 }
2891 },
2892 'navigate-up': {
2893 keys: 'up',
2894 scopes: [this.getNamespace()],
2895 dependency: function dependency() {
2896 return _this.getItemsView();
2897 }
2898 },
2899 'navigate-select': {
2900 keys: 'enter',
2901 scopes: [this.getNamespace()],
2902 dependency: function dependency() {
2903 return _this.getItemsView().$activeItem;
2904 }
2905 }
2906 };
2907 }
2908 }, {
2909 key: "defaultCommands",
2910 value: function defaultCommands() {
2911 var modalCommands = _superPropGet(Component, "defaultCommands", this, 3)([]);
2912 return _objectSpread(_objectSpread({
2913 'navigate/down': function navigate_down() {
2914 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/down' )", '3.0.0', "$e.run( 'finder/navigate-down' )");
2915 $e.run('finder/navigate-down');
2916 },
2917 'navigate/up': function navigate_up() {
2918 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/up' )", '3.0.0', "$e.run( 'finder/navigate-up' )");
2919 $e.run('finder/navigate-up');
2920 },
2921 'navigate/select': function navigate_select(event) {
2922 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/select', event )", '3.0.0', "$e.run( 'finder/navigate-select', event )");
2923
2924 // TODO: Fix $e.shortcuts use args. ( args.event ).
2925 $e.run('finder/navigate-select', event);
2926 }
2927 }, modalCommands), this.importCommands(commands));
2928 }
2929 }, {
2930 key: "getModalLayout",
2931 value: function getModalLayout() {
2932 return _layout.default;
2933 }
2934 }, {
2935 key: "getItemsView",
2936 value: function getItemsView() {
2937 return this.layout.modalContent.currentView.content.currentView;
2938 }
2939 }]);
2940 }(_componentModalBase.default);
2941
2942 /***/ }),
2943
2944 /***/ "../core/common/modules/finder/assets/js/finder.js":
2945 /*!*********************************************************!*\
2946 !*** ../core/common/modules/finder/assets/js/finder.js ***!
2947 \*********************************************************/
2948 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2949
2950 "use strict";
2951
2952
2953 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2954 Object.defineProperty(exports, "__esModule", ({
2955 value: true
2956 }));
2957 exports["default"] = void 0;
2958 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2959 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2960 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2961 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2962 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2963 var _component = _interopRequireDefault(__webpack_require__(/*! ./component */ "../core/common/modules/finder/assets/js/component.js"));
2964 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)); }
2965 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2966 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
2967 function _default() {
2968 (0, _classCallCheck2.default)(this, _default);
2969 return _callSuper(this, _default, arguments);
2970 }
2971 (0, _inherits2.default)(_default, _elementorModules$Mod);
2972 return (0, _createClass2.default)(_default, [{
2973 key: "onInit",
2974 value: function onInit() {
2975 // TODO: Temp fix, do not load finder in theme-builder.
2976 // Better to pass into '$e' constructor the app owner. ( admin, editor, preview, iframe ).
2977 if (window.top !== window) {
2978 return;
2979 }
2980 this.channel = Backbone.Radio.channel('ELEMENTOR:finder');
2981 $e.components.register(new _component.default({
2982 manager: this
2983 }));
2984 }
2985 }]);
2986 }(elementorModules.Module);
2987
2988 /***/ }),
2989
2990 /***/ "../core/common/modules/finder/assets/js/modal/model/item.js":
2991 /*!*******************************************************************!*\
2992 !*** ../core/common/modules/finder/assets/js/modal/model/item.js ***!
2993 \*******************************************************************/
2994 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2995
2996 "use strict";
2997
2998
2999 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3000 Object.defineProperty(exports, "__esModule", ({
3001 value: true
3002 }));
3003 exports["default"] = void 0;
3004 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3005 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3006 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3007 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3008 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3009 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)); }
3010 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3011 var _default = exports["default"] = /*#__PURE__*/function (_Backbone$Model) {
3012 function _default() {
3013 (0, _classCallCheck2.default)(this, _default);
3014 return _callSuper(this, _default, arguments);
3015 }
3016 (0, _inherits2.default)(_default, _Backbone$Model);
3017 return (0, _createClass2.default)(_default, [{
3018 key: "defaults",
3019 value: function defaults() {
3020 return {
3021 description: '',
3022 icon: 'settings',
3023 url: '',
3024 keywords: [],
3025 actions: [],
3026 lock: null
3027 };
3028 }
3029 }]);
3030 }(Backbone.Model);
3031
3032 /***/ }),
3033
3034 /***/ "../core/common/modules/finder/assets/js/modal/views/categories.js":
3035 /*!*************************************************************************!*\
3036 !*** ../core/common/modules/finder/assets/js/modal/views/categories.js ***!
3037 \*************************************************************************/
3038 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3039
3040 "use strict";
3041
3042
3043 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3044 Object.defineProperty(exports, "__esModule", ({
3045 value: true
3046 }));
3047 exports["default"] = void 0;
3048 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3049 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3050 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3051 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3052 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3053 var _category = _interopRequireDefault(__webpack_require__(/*! ./category */ "../core/common/modules/finder/assets/js/modal/views/category.js"));
3054 var _dynamicCategory = _interopRequireDefault(__webpack_require__(/*! ./dynamic-category */ "../core/common/modules/finder/assets/js/modal/views/dynamic-category.js"));
3055 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)); }
3056 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3057 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$Composite) {
3058 function _default() {
3059 (0, _classCallCheck2.default)(this, _default);
3060 return _callSuper(this, _default, arguments);
3061 }
3062 (0, _inherits2.default)(_default, _Marionette$Composite);
3063 return (0, _createClass2.default)(_default, [{
3064 key: "id",
3065 value: function id() {
3066 return 'elementor-finder__results-container';
3067 }
3068 }, {
3069 key: "ui",
3070 value: function ui() {
3071 this.selectors = {
3072 noResults: '#elementor-finder__no-results',
3073 categoryItem: '.elementor-finder__results__item'
3074 };
3075 return this.selectors;
3076 }
3077 }, {
3078 key: "events",
3079 value: function events() {
3080 return {
3081 'mouseenter @ui.categoryItem': 'onCategoryItemMouseEnter'
3082 };
3083 }
3084 }, {
3085 key: "getTemplate",
3086 value: function getTemplate() {
3087 return '#tmpl-elementor-finder-results-container';
3088 }
3089 }, {
3090 key: "getChildView",
3091 value: function getChildView(childModel) {
3092 return childModel.get('dynamic') ? _dynamicCategory.default : _category.default;
3093 }
3094 }, {
3095 key: "initialize",
3096 value: function initialize() {
3097 this.$activeItem = null;
3098 this.childViewContainer = '#elementor-finder__results';
3099 this.collection = new Backbone.Collection(Object.values(elementorCommon.finder.getSettings('data')));
3100 }
3101 }, {
3102 key: "activateItem",
3103 value: function activateItem($item) {
3104 if (this.$activeItem) {
3105 this.$activeItem.removeClass('elementor-active');
3106 }
3107 $item.addClass('elementor-active');
3108 this.$activeItem = $item;
3109 }
3110 }, {
3111 key: "activateNextItem",
3112 value: function activateNextItem(reverse) {
3113 var $allItems = jQuery(this.selectors.categoryItem);
3114 var nextItemIndex = 0;
3115 if (this.$activeItem) {
3116 nextItemIndex = $allItems.index(this.$activeItem) + (reverse ? -1 : 1);
3117 if (nextItemIndex >= $allItems.length) {
3118 nextItemIndex = 0;
3119 } else if (nextItemIndex < 0) {
3120 nextItemIndex = $allItems.length - 1;
3121 }
3122 }
3123 var $nextItem = $allItems.eq(nextItemIndex);
3124 this.activateItem($nextItem);
3125 $nextItem[0].scrollIntoView({
3126 block: 'nearest'
3127 });
3128 }
3129 }, {
3130 key: "goToActiveItem",
3131 value: function goToActiveItem(event) {
3132 var $a = this.$activeItem.children('a'),
3133 isControlClicked = $e.shortcuts.isControlEvent(event);
3134 if (isControlClicked) {
3135 $a.attr('target', '_blank');
3136 }
3137 $a[0].click();
3138 if (isControlClicked) {
3139 $a.removeAttr('target');
3140 }
3141 }
3142 }, {
3143 key: "onCategoryItemMouseEnter",
3144 value: function onCategoryItemMouseEnter(event) {
3145 this.activateItem(jQuery(event.currentTarget));
3146 }
3147 }, {
3148 key: "onChildviewToggleVisibility",
3149 value: function onChildviewToggleVisibility() {
3150 var allCategoriesAreEmpty = this.children.every(function (child) {
3151 return !child.isVisible;
3152 });
3153 this.ui.noResults.toggle(allCategoriesAreEmpty);
3154 }
3155 }]);
3156 }(Marionette.CompositeView);
3157
3158 /***/ }),
3159
3160 /***/ "../core/common/modules/finder/assets/js/modal/views/category.js":
3161 /*!***********************************************************************!*\
3162 !*** ../core/common/modules/finder/assets/js/modal/views/category.js ***!
3163 \***********************************************************************/
3164 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3165
3166 "use strict";
3167
3168
3169 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3170 Object.defineProperty(exports, "__esModule", ({
3171 value: true
3172 }));
3173 exports["default"] = void 0;
3174 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3175 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3176 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3177 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3178 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3179 var _item = _interopRequireDefault(__webpack_require__(/*! ./item */ "../core/common/modules/finder/assets/js/modal/views/item.js"));
3180 var _item2 = _interopRequireDefault(__webpack_require__(/*! ../model/item */ "../core/common/modules/finder/assets/js/modal/model/item.js"));
3181 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)); }
3182 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3183 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$Composite) {
3184 function _default() {
3185 (0, _classCallCheck2.default)(this, _default);
3186 return _callSuper(this, _default, arguments);
3187 }
3188 (0, _inherits2.default)(_default, _Marionette$Composite);
3189 return (0, _createClass2.default)(_default, [{
3190 key: "className",
3191 value: function className() {
3192 return 'elementor-finder__results__category';
3193 }
3194 }, {
3195 key: "getTemplate",
3196 value: function getTemplate() {
3197 return '#tmpl-elementor-finder__results__category';
3198 }
3199 }, {
3200 key: "getChildView",
3201 value: function getChildView() {
3202 return _item.default;
3203 }
3204 }, {
3205 key: "initialize",
3206 value: function initialize() {
3207 this.childViewContainer = '.elementor-finder__results__category__items';
3208 this.isVisible = true;
3209 var items = this.model.get('items');
3210 if (items) {
3211 items = Object.values(items);
3212 }
3213 this.collection = new Backbone.Collection(items, {
3214 model: _item2.default
3215 });
3216 }
3217 }, {
3218 key: "filter",
3219 value: function filter(childModel) {
3220 var textFilter = this.getTextFilter();
3221 if (childModel.get('title').toLowerCase().indexOf(textFilter) >= 0) {
3222 return true;
3223 }
3224 return childModel.get('keywords').some(function (keyword) {
3225 return keyword.indexOf(textFilter) >= 0;
3226 });
3227 }
3228 }, {
3229 key: "getTextFilter",
3230 value: function getTextFilter() {
3231 return elementorCommon.finder.channel.request('filter:text').trim().toLowerCase();
3232 }
3233 }, {
3234 key: "toggleElement",
3235 value: function toggleElement() {
3236 var isCurrentlyVisible = !!this.children.length;
3237 if (isCurrentlyVisible !== this.isVisible) {
3238 this.isVisible = isCurrentlyVisible;
3239 this.$el.toggle(isCurrentlyVisible);
3240 this.triggerMethod('toggle:visibility');
3241 }
3242 }
3243 }, {
3244 key: "onRender",
3245 value: function onRender() {
3246 this.listenTo(elementorCommon.finder.channel, 'filter:change', this.onFilterChange.bind(this));
3247 }
3248 }, {
3249 key: "onFilterChange",
3250 value: function onFilterChange() {
3251 this._renderChildren();
3252 }
3253 }, {
3254 key: "onRenderCollection",
3255 value: function onRenderCollection() {
3256 this.toggleElement();
3257 }
3258 }]);
3259 }(Marionette.CompositeView);
3260
3261 /***/ }),
3262
3263 /***/ "../core/common/modules/finder/assets/js/modal/views/content.js":
3264 /*!**********************************************************************!*\
3265 !*** ../core/common/modules/finder/assets/js/modal/views/content.js ***!
3266 \**********************************************************************/
3267 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3268
3269 "use strict";
3270
3271
3272 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3273 Object.defineProperty(exports, "__esModule", ({
3274 value: true
3275 }));
3276 exports["default"] = void 0;
3277 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3278 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3279 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3280 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3281 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3282 var _categories = _interopRequireDefault(__webpack_require__(/*! ./categories */ "../core/common/modules/finder/assets/js/modal/views/categories.js"));
3283 var _editorOneEvents = __webpack_require__(/*! elementor-editor-utils/editor-one-events */ "../assets/dev/js/editor/utils/editor-one-events.js");
3284 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)); }
3285 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3286 var FINDER_SEARCH_DEBOUNCE_MS = 300;
3287 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$LayoutVie) {
3288 function _default() {
3289 (0, _classCallCheck2.default)(this, _default);
3290 return _callSuper(this, _default, arguments);
3291 }
3292 (0, _inherits2.default)(_default, _Marionette$LayoutVie);
3293 return (0, _createClass2.default)(_default, [{
3294 key: "id",
3295 value: function id() {
3296 return 'elementor-finder';
3297 }
3298 }, {
3299 key: "getTemplate",
3300 value: function getTemplate() {
3301 return '#tmpl-elementor-finder';
3302 }
3303 }, {
3304 key: "ui",
3305 value: function ui() {
3306 return {
3307 searchInput: '#elementor-finder__search__input'
3308 };
3309 }
3310 }, {
3311 key: "events",
3312 value: function events() {
3313 return {
3314 'input @ui.searchInput': 'onSearchInputInput'
3315 };
3316 }
3317 }, {
3318 key: "regions",
3319 value: function regions() {
3320 return {
3321 content: '#elementor-finder__content'
3322 };
3323 }
3324 }, {
3325 key: "initialize",
3326 value: function initialize() {
3327 this.debouncedTrackSearch = (0, _editorOneEvents.createDebouncedFinderSearch)(FINDER_SEARCH_DEBOUNCE_MS);
3328 }
3329 }, {
3330 key: "showCategoriesView",
3331 value: function showCategoriesView() {
3332 this.content.show(new _categories.default());
3333 }
3334 }, {
3335 key: "getResultsCount",
3336 value: function getResultsCount() {
3337 if (!this.content.currentView) {
3338 return 0;
3339 }
3340 var $visibleItems = this.content.currentView.$el.find('.elementor-finder__results__item:visible');
3341 return $visibleItems.length;
3342 }
3343 }, {
3344 key: "onSearchInputInput",
3345 value: function onSearchInputInput() {
3346 var _this = this;
3347 var value = this.ui.searchInput.val();
3348 if (value) {
3349 elementorCommon.finder.channel.reply('filter:text', value).trigger('filter:change');
3350 if (!(this.content.currentView instanceof _categories.default)) {
3351 this.showCategoriesView();
3352 }
3353 setTimeout(function () {
3354 var resultsCount = _this.getResultsCount();
3355 _this.debouncedTrackSearch(resultsCount, value);
3356 }, 50);
3357 }
3358 this.content.currentView.$el.toggle(!!value);
3359 }
3360 }, {
3361 key: "onDestroy",
3362 value: function onDestroy() {
3363 var _this$debouncedTrackS;
3364 if ((_this$debouncedTrackS = this.debouncedTrackSearch) !== null && _this$debouncedTrackS !== void 0 && _this$debouncedTrackS.cancel) {
3365 this.debouncedTrackSearch.cancel();
3366 }
3367 }
3368 }]);
3369 }(Marionette.LayoutView);
3370
3371 /***/ }),
3372
3373 /***/ "../core/common/modules/finder/assets/js/modal/views/dynamic-category.js":
3374 /*!*******************************************************************************!*\
3375 !*** ../core/common/modules/finder/assets/js/modal/views/dynamic-category.js ***!
3376 \*******************************************************************************/
3377 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3378
3379 "use strict";
3380
3381
3382 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3383 Object.defineProperty(exports, "__esModule", ({
3384 value: true
3385 }));
3386 exports["default"] = void 0;
3387 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3388 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3389 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3390 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3391 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
3392 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3393 var _category = _interopRequireDefault(__webpack_require__(/*! ./category */ "../core/common/modules/finder/assets/js/modal/views/category.js"));
3394 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)); }
3395 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3396 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; }
3397 var _default = exports["default"] = /*#__PURE__*/function (_Category) {
3398 function _default() {
3399 (0, _classCallCheck2.default)(this, _default);
3400 return _callSuper(this, _default, arguments);
3401 }
3402 (0, _inherits2.default)(_default, _Category);
3403 return (0, _createClass2.default)(_default, [{
3404 key: "className",
3405 value: function className() {
3406 return _superPropGet(_default, "className", this, 3)([]) + ' elementor-finder__results__category--dynamic';
3407 }
3408 }, {
3409 key: "ui",
3410 value: function ui() {
3411 return {
3412 title: '.elementor-finder__results__category__title'
3413 };
3414 }
3415 }, {
3416 key: "fetchData",
3417 value: function fetchData() {
3418 var _this = this;
3419 this.ui.loadingIcon.show();
3420 elementorCommon.ajax.addRequest('finder_get_category_items', {
3421 data: {
3422 category: this.model.get('name'),
3423 filter: this.getTextFilter()
3424 },
3425 success: function success(data) {
3426 if (_this.isDestroyed) {
3427 return;
3428 }
3429 _this.collection.set(data);
3430 _this.toggleElement();
3431 _this.ui.loadingIcon.hide();
3432 }
3433 });
3434 }
3435 }, {
3436 key: "filter",
3437 value: function filter() {
3438 return true;
3439 }
3440 }, {
3441 key: "onFilterChange",
3442 value: function onFilterChange() {
3443 this.fetchData();
3444 }
3445 }, {
3446 key: "onRender",
3447 value: function onRender() {
3448 _superPropGet(_default, "onRender", this, 3)([]);
3449 this.ui.loadingIcon = jQuery('<i>', {
3450 class: 'eicon-loading eicon-animation-spin'
3451 });
3452 this.ui.title.after(this.ui.loadingIcon);
3453 this.fetchData();
3454 }
3455 }]);
3456 }(_category.default);
3457
3458 /***/ }),
3459
3460 /***/ "../core/common/modules/finder/assets/js/modal/views/item.js":
3461 /*!*******************************************************************!*\
3462 !*** ../core/common/modules/finder/assets/js/modal/views/item.js ***!
3463 \*******************************************************************/
3464 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3465
3466 "use strict";
3467 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
3468
3469
3470 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3471 Object.defineProperty(exports, "__esModule", ({
3472 value: true
3473 }));
3474 exports["default"] = void 0;
3475 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3476 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3477 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3478 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3479 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3480 var _editorOneEvents = __webpack_require__(/*! elementor-editor-utils/editor-one-events */ "../assets/dev/js/editor/utils/editor-one-events.js");
3481 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)); }
3482 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3483 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$ItemView) {
3484 function _default() {
3485 (0, _classCallCheck2.default)(this, _default);
3486 return _callSuper(this, _default, arguments);
3487 }
3488 (0, _inherits2.default)(_default, _Marionette$ItemView);
3489 return (0, _createClass2.default)(_default, [{
3490 key: "className",
3491 value: function className() {
3492 return 'elementor-finder__results__item';
3493 }
3494 }, {
3495 key: "getTemplate",
3496 value: function getTemplate() {
3497 return '#tmpl-elementor-finder__results__item';
3498 }
3499 }, {
3500 key: "events",
3501 value: function events() {
3502 this.$el[0].addEventListener('click', this.onClick.bind(this), true);
3503 }
3504 }, {
3505 key: "trackResultSelect",
3506 value: function trackResultSelect() {
3507 var title = this.model.get('title');
3508 _editorOneEvents.EditorOneEventManager.sendFinderResultSelect(title);
3509 }
3510 }, {
3511 key: "onClick",
3512 value: function onClick(e) {
3513 var _this = this;
3514 var lockOptions = this.model.get('lock');
3515 if (!(lockOptions !== null && lockOptions !== void 0 && lockOptions.is_locked)) {
3516 this.trackResultSelect();
3517 return;
3518 }
3519 e.preventDefault();
3520 e.stopImmediatePropagation();
3521 elementorCommon.dialogsManager.createWidget('confirm', {
3522 id: 'elementor-finder__lock-dialog',
3523 headerMessage: lockOptions.content.heading,
3524 message: lockOptions.content.description,
3525 position: {
3526 my: 'center center',
3527 at: 'center center'
3528 },
3529 strings: {
3530 confirm: lockOptions.button.text,
3531 cancel: __('Cancel', 'elementor')
3532 },
3533 onConfirm: function onConfirm() {
3534 _this.trackResultSelect();
3535 var link = _this.replaceLockLinkPlaceholders(lockOptions.button.url);
3536 window.open(link, '_blank');
3537 }
3538 }).show();
3539 }
3540 }, {
3541 key: "replaceLockLinkPlaceholders",
3542 value: function replaceLockLinkPlaceholders(link) {
3543 return link.replace(/%%utm_source%%/g, 'finder').replace(/%%utm_medium%%/g, 'wp-dash');
3544 }
3545 }]);
3546 }(Marionette.ItemView);
3547
3548 /***/ }),
3549
3550 /***/ "../core/common/modules/finder/assets/js/modal/views/layout.js":
3551 /*!*********************************************************************!*\
3552 !*** ../core/common/modules/finder/assets/js/modal/views/layout.js ***!
3553 \*********************************************************************/
3554 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3555
3556 "use strict";
3557 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
3558
3559
3560 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3561 Object.defineProperty(exports, "__esModule", ({
3562 value: true
3563 }));
3564 exports["default"] = void 0;
3565 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3566 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3567 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3568 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3569 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
3570 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3571 var _content = _interopRequireDefault(__webpack_require__(/*! ./content */ "../core/common/modules/finder/assets/js/modal/views/content.js"));
3572 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)); }
3573 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3574 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; }
3575 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$com) {
3576 function _default() {
3577 (0, _classCallCheck2.default)(this, _default);
3578 return _callSuper(this, _default, arguments);
3579 }
3580 (0, _inherits2.default)(_default, _elementorModules$com);
3581 return (0, _createClass2.default)(_default, [{
3582 key: "getModalOptions",
3583 value: function getModalOptions() {
3584 return {
3585 id: 'elementor-finder__modal',
3586 draggable: true,
3587 effects: {
3588 show: 'show',
3589 hide: 'hide'
3590 },
3591 position: {
3592 enable: false
3593 }
3594 };
3595 }
3596 }, {
3597 key: "getLogoOptions",
3598 value: function getLogoOptions() {
3599 return {
3600 title: __('Finder', 'elementor')
3601 };
3602 }
3603 }, {
3604 key: "initialize",
3605 value: function initialize() {
3606 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3607 args[_key] = arguments[_key];
3608 }
3609 _superPropGet(_default, "initialize", this, 3)(args);
3610 this.showLogo();
3611 this.showContentView();
3612 }
3613 }, {
3614 key: "showContentView",
3615 value: function showContentView() {
3616 this.modalContent.show(new _content.default());
3617 }
3618 }, {
3619 key: "showModal",
3620 value: function showModal() {
3621 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
3622 args[_key2] = arguments[_key2];
3623 }
3624 _superPropGet(_default, "showModal", this, 3)(args);
3625 this.modalContent.currentView.ui.searchInput.focus();
3626 }
3627 }]);
3628 }(elementorModules.common.views.modal.Layout);
3629
3630 /***/ }),
3631
3632 /***/ "../modules/web-cli/assets/js/core/data/errors/base-error.js":
3633 /*!*******************************************************************!*\
3634 !*** ../modules/web-cli/assets/js/core/data/errors/base-error.js ***!
3635 \*******************************************************************/
3636 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3637
3638 "use strict";
3639
3640
3641 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3642 Object.defineProperty(exports, "__esModule", ({
3643 value: true
3644 }));
3645 exports["default"] = void 0;
3646 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3647 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3648 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3649 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3650 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3651 var _wrapNativeSuper2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/wrapNativeSuper */ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js"));
3652 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
3653 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
3654 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../../../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
3655 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; }
3656 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; }
3657 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)); }
3658 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3659 var BaseError = exports["default"] = /*#__PURE__*/function (_Error) {
3660 /**
3661 * Error constructor.
3662 *
3663 * @param {string} message
3664 * @param {string} code
3665 * @param {*} data
3666 */
3667 function BaseError() {
3668 var _this;
3669 var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
3670 var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
3671 var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
3672 (0, _classCallCheck2.default)(this, BaseError);
3673 _this = _callSuper(this, BaseError, [message]);
3674 /**
3675 * The server error code.
3676 *
3677 * @type {string}
3678 */
3679 (0, _defineProperty2.default)(_this, "code", '');
3680 /**
3681 * Additional data about the current error.
3682 *
3683 * @type {*[]}
3684 */
3685 (0, _defineProperty2.default)(_this, "data", []);
3686 _this.code = code;
3687 _this.data = data;
3688 return _this;
3689 }
3690
3691 /**
3692 * Notify a message when the error occurs.
3693 */
3694 (0, _inherits2.default)(BaseError, _Error);
3695 return (0, _createClass2.default)(BaseError, [{
3696 key: "notify",
3697 value: function notify() {
3698 _console.default.error(_objectSpread({
3699 message: this.message
3700 }, this));
3701 }
3702 }], [{
3703 key: "create",
3704 value:
3705 /**
3706 * Static helper function to create the error.
3707 *
3708 * @param {string} message
3709 * @param {string} code
3710 * @param {*} data
3711 * @return {BaseError} error
3712 */
3713 function create(message) {
3714 var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
3715 var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
3716 return new this(message, code, data);
3717 }
3718
3719 /**
3720 * Returns the status code of the error.
3721 */
3722 }, {
3723 key: "getHTTPErrorCode",
3724 value: function getHTTPErrorCode() {
3725 (0, _forceMethodImplementation.default)();
3726 }
3727 }]);
3728 }(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
3729
3730 /***/ }),
3731
3732 /***/ "../modules/web-cli/assets/js/core/data/errors/default-error.js":
3733 /*!**********************************************************************!*\
3734 !*** ../modules/web-cli/assets/js/core/data/errors/default-error.js ***!
3735 \**********************************************************************/
3736 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3737
3738 "use strict";
3739
3740
3741 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3742 Object.defineProperty(exports, "__esModule", ({
3743 value: true
3744 }));
3745 exports["default"] = exports.DefaultError = void 0;
3746 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3747 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3748 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3749 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3750 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3751 var _baseError = _interopRequireDefault(__webpack_require__(/*! ./base-error */ "../modules/web-cli/assets/js/core/data/errors/base-error.js"));
3752 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)); }
3753 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3754 var DefaultError = exports.DefaultError = /*#__PURE__*/function (_BaseError) {
3755 function DefaultError() {
3756 (0, _classCallCheck2.default)(this, DefaultError);
3757 return _callSuper(this, DefaultError, arguments);
3758 }
3759 (0, _inherits2.default)(DefaultError, _BaseError);
3760 return (0, _createClass2.default)(DefaultError, null, [{
3761 key: "getHTTPErrorCode",
3762 value: function getHTTPErrorCode() {
3763 return 501;
3764 }
3765 }]);
3766 }(_baseError.default);
3767 var _default = exports["default"] = DefaultError;
3768
3769 /***/ }),
3770
3771 /***/ "../modules/web-cli/assets/js/core/data/errors/error-404.js":
3772 /*!******************************************************************!*\
3773 !*** ../modules/web-cli/assets/js/core/data/errors/error-404.js ***!
3774 \******************************************************************/
3775 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3776
3777 "use strict";
3778
3779
3780 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3781 Object.defineProperty(exports, "__esModule", ({
3782 value: true
3783 }));
3784 exports["default"] = exports.Error404 = void 0;
3785 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3786 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3787 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3788 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3789 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3790 var _baseError = _interopRequireDefault(__webpack_require__(/*! ./base-error */ "../modules/web-cli/assets/js/core/data/errors/base-error.js"));
3791 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
3792 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)); }
3793 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3794 var Error404 = exports.Error404 = /*#__PURE__*/function (_BaseError) {
3795 function Error404() {
3796 (0, _classCallCheck2.default)(this, Error404);
3797 return _callSuper(this, Error404, arguments);
3798 }
3799 (0, _inherits2.default)(Error404, _BaseError);
3800 return (0, _createClass2.default)(Error404, [{
3801 key: "notify",
3802 value: function notify() {
3803 _console.default.warn(this.message);
3804 }
3805 }], [{
3806 key: "getHTTPErrorCode",
3807 value: function getHTTPErrorCode() {
3808 return 404;
3809 }
3810 }]);
3811 }(_baseError.default);
3812 var _default = exports["default"] = Error404;
3813
3814 /***/ }),
3815
3816 /***/ "../modules/web-cli/assets/js/core/data/errors/index.js":
3817 /*!**************************************************************!*\
3818 !*** ../modules/web-cli/assets/js/core/data/errors/index.js ***!
3819 \**************************************************************/
3820 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3821
3822 "use strict";
3823
3824
3825 Object.defineProperty(exports, "__esModule", ({
3826 value: true
3827 }));
3828 Object.defineProperty(exports, "DefaultError", ({
3829 enumerable: true,
3830 get: function get() {
3831 return _defaultError.DefaultError;
3832 }
3833 }));
3834 Object.defineProperty(exports, "Error404", ({
3835 enumerable: true,
3836 get: function get() {
3837 return _error.Error404;
3838 }
3839 }));
3840 var _defaultError = __webpack_require__(/*! ./default-error */ "../modules/web-cli/assets/js/core/data/errors/default-error.js");
3841 var _error = __webpack_require__(/*! ./error-404 */ "../modules/web-cli/assets/js/core/data/errors/error-404.js");
3842
3843 /***/ }),
3844
3845 /***/ "../modules/web-cli/assets/js/modules/command-base.js":
3846 /*!************************************************************!*\
3847 !*** ../modules/web-cli/assets/js/modules/command-base.js ***!
3848 \************************************************************/
3849 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3850
3851 "use strict";
3852
3853
3854 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3855 Object.defineProperty(exports, "__esModule", ({
3856 value: true
3857 }));
3858 exports["default"] = void 0;
3859 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3860 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3861 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3862 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3863 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3864 var _commandInfra = _interopRequireDefault(__webpack_require__(/*! ./command-infra */ "../modules/web-cli/assets/js/modules/command-infra.js"));
3865 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
3866 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)); }
3867 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3868 /**
3869 * @name $e.modules.CommandBase
3870 */
3871 var CommandBase = exports["default"] = /*#__PURE__*/function (_CommandInfra) {
3872 function CommandBase() {
3873 (0, _classCallCheck2.default)(this, CommandBase);
3874 return _callSuper(this, CommandBase, arguments);
3875 }
3876 (0, _inherits2.default)(CommandBase, _CommandInfra);
3877 return (0, _createClass2.default)(CommandBase, [{
3878 key: "onBeforeRun",
3879 value: function onBeforeRun() {
3880 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3881 $e.hooks.runUIBefore(this.command, args);
3882 }
3883 }, {
3884 key: "onAfterRun",
3885 value: function onAfterRun() {
3886 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3887 var result = arguments.length > 1 ? arguments[1] : undefined;
3888 $e.hooks.runUIAfter(this.command, args, result);
3889 }
3890 }, {
3891 key: "onBeforeApply",
3892 value: function onBeforeApply() {
3893 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3894 $e.hooks.runDataDependency(this.command, args);
3895 }
3896 }, {
3897 key: "onAfterApply",
3898 value: function onAfterApply() {
3899 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3900 var result = arguments.length > 1 ? arguments[1] : undefined;
3901 return $e.hooks.runDataAfter(this.command, args, result);
3902 }
3903 }, {
3904 key: "onCatchApply",
3905 value: function onCatchApply(e) {
3906 this.runCatchHooks(e);
3907 }
3908
3909 /**
3910 * Run all the catch hooks.
3911 *
3912 * @param {Error} e
3913 */
3914 }, {
3915 key: "runCatchHooks",
3916 value: function runCatchHooks(e) {
3917 $e.hooks.runDataCatch(this.command, this.args, e);
3918 $e.hooks.runUICatch(this.command, this.args, e);
3919 }
3920
3921 /**
3922 * TODO - Remove - Backwards compatibility.
3923 *
3924 * Function requireContainer().
3925 *
3926 * Validate `arg.container` & `arg.containers`.
3927 *
3928 * @param {{}} args
3929 * @deprecated since 3.7.0, extend `$e.modules.editor.CommandContainerBase` or `$e.modules.editor.CommandContainerInternalBase` instead.
3930 *
3931 * @throws {Error}
3932 */
3933 }, {
3934 key: "requireContainer",
3935 value: function requireContainer() {
3936 var _this = this;
3937 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.args;
3938 _deprecation.default.deprecated('requireContainer()', '3.7.0', 'Extend `$e.modules.editor.CommandContainerBase` or `$e.modules.editor.CommandContainerInternalBase`');
3939 if (!args.container && !args.containers) {
3940 throw Error('container or containers are required.');
3941 }
3942 if (args.container && args.containers) {
3943 throw Error('container and containers cannot go together please select one of them.');
3944 }
3945 var containers = args.containers || [args.container];
3946 containers.forEach(function (container) {
3947 _this.requireArgumentInstance('container', elementorModules.editor.Container, {
3948 container: container
3949 });
3950 });
3951 }
3952 }], [{
3953 key: "getInstanceType",
3954 value: function getInstanceType() {
3955 return 'CommandBase';
3956 }
3957 }]);
3958 }(_commandInfra.default);
3959
3960 /***/ }),
3961
3962 /***/ "../modules/web-cli/assets/js/modules/command-callback-base.js":
3963 /*!*********************************************************************!*\
3964 !*** ../modules/web-cli/assets/js/modules/command-callback-base.js ***!
3965 \*********************************************************************/
3966 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3967
3968 "use strict";
3969
3970
3971 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3972 Object.defineProperty(exports, "__esModule", ({
3973 value: true
3974 }));
3975 exports["default"] = void 0;
3976 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3977 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3978 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3979 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3980 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3981 var _commandBase = _interopRequireDefault(__webpack_require__(/*! ./command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
3982 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)); }
3983 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3984 /**
3985 * To support pure callbacks in the API(commands.js), to ensure they have registered with the proper context.
3986 */
3987 var CommandCallbackBase = exports["default"] = /*#__PURE__*/function (_CommandBase) {
3988 function CommandCallbackBase() {
3989 (0, _classCallCheck2.default)(this, CommandCallbackBase);
3990 return _callSuper(this, CommandCallbackBase, arguments);
3991 }
3992 (0, _inherits2.default)(CommandCallbackBase, _CommandBase);
3993 return (0, _createClass2.default)(CommandCallbackBase, [{
3994 key: "apply",
3995 value: function apply() {
3996 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3997 return this.constructor.getCallback()(args);
3998 }
3999 }], [{
4000 key: "getInstanceType",
4001 value: function getInstanceType() {
4002 return 'CommandCallbackBase';
4003 }
4004
4005 /**
4006 * Get original callback of the command.
4007 *
4008 * Support pure callbacks ( Non command-base ).
4009 *
4010 * @return {()=>{}} Command Results.
4011 */
4012 }, {
4013 key: "getCallback",
4014 value: function getCallback() {
4015 return this.registerConfig.callback;
4016 }
4017 }]);
4018 }(_commandBase.default);
4019
4020 /***/ }),
4021
4022 /***/ "../modules/web-cli/assets/js/modules/command-data.js":
4023 /*!************************************************************!*\
4024 !*** ../modules/web-cli/assets/js/modules/command-data.js ***!
4025 \************************************************************/
4026 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4027
4028 "use strict";
4029
4030
4031 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4032 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
4033 Object.defineProperty(exports, "__esModule", ({
4034 value: true
4035 }));
4036 exports["default"] = void 0;
4037 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4038 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4039 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4040 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4041 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4042 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
4043 var _commandBase = _interopRequireDefault(__webpack_require__(/*! ./command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4044 var errors = _interopRequireWildcard(__webpack_require__(/*! ../core/data/errors/ */ "../modules/web-cli/assets/js/core/data/errors/index.js"));
4045 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); }
4046 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)); }
4047 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4048 /**
4049 * @name $e.modules.CommandData
4050 */
4051 /**
4052 * @typedef {('create'|'delete'|'get'|'update'|'options')} DataTypes
4053 */
4054 /**
4055 * @typedef {{}} RequestData
4056 */
4057 /**
4058 * @typedef {import('../core/data/errors/base-error')} BaseError
4059 */
4060 var CommandData = exports["default"] = /*#__PURE__*/function (_CommandBase) {
4061 function CommandData(args) {
4062 var _this$args$options;
4063 var _this;
4064 var commandsAPI = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : $e.data;
4065 (0, _classCallCheck2.default)(this, CommandData);
4066 _this = _callSuper(this, CommandData, [args, commandsAPI]);
4067 /**
4068 * Data returned from remote.
4069 *
4070 * @type {*}
4071 */
4072 (0, _defineProperty2.default)(_this, "data", void 0);
4073 /**
4074 * Fetch type.
4075 *
4076 * @type {DataTypes}
4077 */
4078 (0, _defineProperty2.default)(_this, "type", void 0);
4079 if ((_this$args$options = _this.args.options) !== null && _this$args$options !== void 0 && _this$args$options.type) {
4080 _this.type = _this.args.options.type;
4081 }
4082 return _this;
4083 }
4084
4085 /**
4086 * Function getEndpointFormat().
4087 *
4088 * @return {null|string} endpoint format
4089 */
4090 (0, _inherits2.default)(CommandData, _CommandBase);
4091 return (0, _createClass2.default)(CommandData, [{
4092 key: "getApplyMethods",
4093 value:
4094 /**
4095 * @param {DataTypes} type
4096 *
4097 * @return {boolean|{before: (function(*=): {}), after: (function({}, *=): {})}} apply methods
4098 */
4099 function getApplyMethods() {
4100 var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.type;
4101 var before, after;
4102 switch (type) {
4103 case 'create':
4104 before = this.applyBeforeCreate;
4105 after = this.applyAfterCreate;
4106 break;
4107 case 'delete':
4108 before = this.applyBeforeDelete;
4109 after = this.applyAfterDelete;
4110 break;
4111 case 'get':
4112 before = this.applyBeforeGet;
4113 after = this.applyAfterGet;
4114 break;
4115 case 'update':
4116 before = this.applyBeforeUpdate;
4117 after = this.applyAfterUpdate;
4118 break;
4119 case 'options':
4120 before = this.applyBeforeOptions;
4121 after = this.applyAfterOptions;
4122 break;
4123 default:
4124 return false;
4125 }
4126 return {
4127 before: before.bind(this),
4128 after: after.bind(this)
4129 };
4130 }
4131
4132 /**
4133 * Function getRequestData().
4134 *
4135 * @return {RequestData} request data
4136 */
4137 }, {
4138 key: "getRequestData",
4139 value: function getRequestData() {
4140 return {
4141 type: this.type,
4142 args: this.args,
4143 timestamp: new Date().getTime(),
4144 component: this.component,
4145 command: this.command,
4146 endpoint: $e.data.commandToEndpoint(this.command, JSON.parse(JSON.stringify(this.args)), this.constructor.getEndpointFormat())
4147 };
4148 }
4149 }, {
4150 key: "apply",
4151 value: function apply() {
4152 var _this2 = this;
4153 var applyMethods = this.getApplyMethods();
4154
4155 // Run 'before' method.
4156 this.args = applyMethods.before(this.args);
4157 var requestData = this.getRequestData();
4158 return $e.data.fetch(requestData).then(function (data) {
4159 _this2.data = data;
4160
4161 // Run 'after' method.
4162 _this2.data = applyMethods.after(data, _this2.args);
4163 _this2.data = {
4164 data: _this2.data
4165 };
4166
4167 // Append requestData.
4168 _this2.data = Object.assign({
4169 __requestData__: requestData
4170 }, _this2.data);
4171 return _this2.data;
4172 });
4173 }
4174
4175 /**
4176 * @param {*} [args={}]
4177 * @return {{}} filtered args
4178 */
4179 }, {
4180 key: "applyBeforeCreate",
4181 value: function applyBeforeCreate() {
4182 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4183 return args;
4184 }
4185
4186 /**
4187 * @param {{}} data
4188 * @param {*} [args={}]
4189 * @return {{}} filtered result
4190 */
4191 }, {
4192 key: "applyAfterCreate",
4193 value: function applyAfterCreate(data) {
4194 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4195 // eslint-disable-line no-unused-vars
4196 return data;
4197 }
4198
4199 /**
4200 * @param {*} [args={}]
4201 * @return {{}} filtered args
4202 */
4203 }, {
4204 key: "applyBeforeDelete",
4205 value: function applyBeforeDelete() {
4206 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4207 return args;
4208 }
4209
4210 /**
4211 * @param {{}} data
4212 * @param {*} [args={}]
4213 * @return {{}} filtered result
4214 */
4215 }, {
4216 key: "applyAfterDelete",
4217 value: function applyAfterDelete(data) {
4218 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4219 // eslint-disable-line no-unused-vars
4220 return data;
4221 }
4222
4223 /**
4224 * @param {*} [args={}]
4225 * @return {{}} filtered args
4226 */
4227 }, {
4228 key: "applyBeforeGet",
4229 value: function applyBeforeGet() {
4230 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4231 return args;
4232 }
4233
4234 /**
4235 * @param {{}} data
4236 * @param {*} [args={}]
4237 * @return {{}} filtered result
4238 */
4239 }, {
4240 key: "applyAfterGet",
4241 value: function applyAfterGet(data) {
4242 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4243 // eslint-disable-line no-unused-vars
4244 return data;
4245 }
4246
4247 /**
4248 * @param {*} [args={}]
4249 * @return {{}} filtered args
4250 */
4251 }, {
4252 key: "applyBeforeUpdate",
4253 value: function applyBeforeUpdate() {
4254 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4255 return args;
4256 }
4257
4258 /**
4259 * @param {{}} data
4260 * @param {*} [args={}]
4261 * @return {{}} filtered result
4262 */
4263 }, {
4264 key: "applyAfterUpdate",
4265 value: function applyAfterUpdate(data) {
4266 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4267 // eslint-disable-line no-unused-vars
4268 return data;
4269 }
4270
4271 /**
4272 * @param {*} [args={}]
4273 * @return {{}} filtered args
4274 */
4275 }, {
4276 key: "applyBeforeOptions",
4277 value: function applyBeforeOptions() {
4278 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4279 return args;
4280 }
4281
4282 /**
4283 * @param {{}} data
4284 * @param {*} [args={}]
4285 * @return {{}} filtered result
4286 */
4287 }, {
4288 key: "applyAfterOptions",
4289 value: function applyAfterOptions(data) {
4290 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4291 // eslint-disable-line no-unused-vars
4292 return data;
4293 }
4294
4295 /**
4296 * @param {BaseError} e
4297 */
4298 }, {
4299 key: "applyAfterCatch",
4300 value: function applyAfterCatch(e) {
4301 e.notify();
4302 }
4303 }, {
4304 key: "onCatchApply",
4305 value: function onCatchApply(e) {
4306 var _e;
4307 // TODO: If the errors that returns from the server is consistent remove the '?' from 'e'
4308 var httpErrorCode = ((_e = e) === null || _e === void 0 || (_e = _e.data) === null || _e === void 0 ? void 0 : _e.status) || 501;
4309 var dataError = Object.values(errors).find(function (error) {
4310 return error.getHTTPErrorCode() === httpErrorCode;
4311 });
4312 if (!dataError) {
4313 dataError = errors.DefaultError;
4314 }
4315 e = dataError.create(e.message, e.code, e.data || []);
4316 this.runCatchHooks(e);
4317 this.applyAfterCatch(e);
4318 }
4319 }], [{
4320 key: "getInstanceType",
4321 value: function getInstanceType() {
4322 return 'CommandData';
4323 }
4324 }, {
4325 key: "getEndpointFormat",
4326 value: function getEndpointFormat() {
4327 return null;
4328 }
4329 }]);
4330 }(_commandBase.default);
4331
4332 /***/ }),
4333
4334 /***/ "../modules/web-cli/assets/js/modules/command-infra.js":
4335 /*!*************************************************************!*\
4336 !*** ../modules/web-cli/assets/js/modules/command-infra.js ***!
4337 \*************************************************************/
4338 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4339
4340 "use strict";
4341
4342
4343 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4344 Object.defineProperty(exports, "__esModule", ({
4345 value: true
4346 }));
4347 exports["default"] = void 0;
4348 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4349 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4350 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4351 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4352 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4353 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
4354 var _argsObject = _interopRequireDefault(__webpack_require__(/*! elementor-assets-js/modules/imports/args-object */ "../assets/dev/js/modules/imports/args-object.js"));
4355 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
4356 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)); }
4357 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4358 /**
4359 * @typedef {import('../modules/component-base')} ComponentBase
4360 */
4361 var CommandInfra = exports["default"] = /*#__PURE__*/function (_ArgsObject) {
4362 /**
4363 * Function constructor().
4364 *
4365 * Create Commands Base.
4366 *
4367 * @param {{}} args
4368 */
4369 function CommandInfra() {
4370 var _this;
4371 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4372 (0, _classCallCheck2.default)(this, CommandInfra);
4373 _this = _callSuper(this, CommandInfra, [args]);
4374 if (!_this.constructor.registerConfig) {
4375 throw RangeError('Doing it wrong: Each command type should have `registerConfig`.');
4376 }
4377
4378 // Acknowledge self about which command it run.
4379 _this.command = _this.constructor.getCommand();
4380
4381 // Assign instance of current component.
4382 _this.component = _this.constructor.getComponent();
4383
4384 // Who ever need do something before without `super` the constructor can use `initialize` method.
4385 _this.initialize(args);
4386
4387 // Refresh args, maybe the changed via `initialize`.
4388 args = _this.args;
4389
4390 // Validate args before run.
4391 _this.validateArgs(args);
4392 return _this;
4393 }
4394
4395 /**
4396 * Function initialize().
4397 *
4398 * Initialize command, called after construction.
4399 *
4400 * @param {{}} args
4401 */
4402 (0, _inherits2.default)(CommandInfra, _ArgsObject);
4403 return (0, _createClass2.default)(CommandInfra, [{
4404 key: "currentCommand",
4405 get:
4406 /**
4407 * @deprecated since 3.7.0, use `this.command` instead.
4408 */
4409 function get() {
4410 _deprecation.default.deprecated('this.currentCommand', '3.7.0', 'this.command');
4411 return this.command;
4412 }
4413 }, {
4414 key: "initialize",
4415 value: function initialize() {
4416 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4417 } // eslint-disable-line no-unused-vars
4418
4419 /**
4420 * Function validateArgs().
4421 *
4422 * Validate command arguments.
4423 *
4424 * @param {{}} args
4425 */
4426 }, {
4427 key: "validateArgs",
4428 value: function validateArgs() {
4429 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4430 } // eslint-disable-line no-unused-vars
4431
4432 // eslint-disable-next-line jsdoc/require-returns-check
4433 /**
4434 * Function apply().
4435 *
4436 * Do the actual command.
4437 *
4438 * @param {{}} args
4439 *
4440 * @return {*} Command results.
4441 */
4442 }, {
4443 key: "apply",
4444 value: function apply() {
4445 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4446 // eslint-disable-line no-unused-vars
4447 elementorModules.ForceMethodImplementation();
4448 }
4449
4450 /**
4451 * Function run().
4452 *
4453 * Run command with history & hooks.
4454 *
4455 * @return {*} Command results.
4456 */
4457 }, {
4458 key: "run",
4459 value: function run() {
4460 return this.apply(this.args);
4461 }
4462
4463 /**
4464 * Function onBeforeRun.
4465 *
4466 * Called before run().
4467 *
4468 * @param {{}} args
4469 */
4470 }, {
4471 key: "onBeforeRun",
4472 value: function onBeforeRun() {
4473 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4474 } // eslint-disable-line no-unused-vars
4475
4476 /**
4477 * Function onAfterRun.
4478 *
4479 * Called after run().
4480 *
4481 * @param {{}} args
4482 * @param {*} result
4483 */
4484 }, {
4485 key: "onAfterRun",
4486 value: function onAfterRun() {
4487 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4488 var result = arguments.length > 1 ? arguments[1] : undefined;
4489 } // eslint-disable-line no-unused-vars
4490
4491 /**
4492 * Function onBeforeApply.
4493 *
4494 * Called before apply().
4495 *
4496 * @param {{}} args
4497 */
4498 }, {
4499 key: "onBeforeApply",
4500 value: function onBeforeApply() {
4501 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4502 } // eslint-disable-line no-unused-vars
4503
4504 /**
4505 * Function onAfterApply.
4506 *
4507 * Called after apply().
4508 *
4509 * @param {{}} args
4510 * @param {*} result
4511 */
4512 }, {
4513 key: "onAfterApply",
4514 value: function onAfterApply() {
4515 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4516 var result = arguments.length > 1 ? arguments[1] : undefined;
4517 } // eslint-disable-line no-unused-vars
4518
4519 /**
4520 * Function onCatchApply.
4521 *
4522 * Called after apply() failed.
4523 *
4524 * @param {Error} e
4525 */
4526 }, {
4527 key: "onCatchApply",
4528 value: function onCatchApply(e) {} // eslint-disable-line no-unused-vars
4529 }], [{
4530 key: "getInstanceType",
4531 value: function getInstanceType() {
4532 return 'CommandInfra';
4533 }
4534
4535 /**
4536 * Get info of command.
4537 *
4538 * @return {Object} Extra information about the command.
4539 */
4540 }, {
4541 key: "getInfo",
4542 value: function getInfo() {
4543 return {};
4544 }
4545
4546 /**
4547 * @return {string} Self command name.
4548 */
4549 }, {
4550 key: "getCommand",
4551 value: function getCommand() {
4552 return this.registerConfig.command;
4553 }
4554
4555 /**
4556 * @return {ComponentBase} Self component
4557 */
4558 }, {
4559 key: "getComponent",
4560 value: function getComponent() {
4561 return this.registerConfig.component;
4562 }
4563 }, {
4564 key: "setRegisterConfig",
4565 value: function setRegisterConfig(config) {
4566 this.registerConfig = Object.freeze(config);
4567 }
4568 }]);
4569 }(_argsObject.default);
4570 /**
4571 * @type {Object}
4572 */
4573 (0, _defineProperty2.default)(CommandInfra, "registerConfig", null);
4574
4575 /***/ }),
4576
4577 /***/ "../modules/web-cli/assets/js/modules/commands/close.js":
4578 /*!**************************************************************!*\
4579 !*** ../modules/web-cli/assets/js/modules/commands/close.js ***!
4580 \**************************************************************/
4581 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4582
4583 "use strict";
4584
4585
4586 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4587 Object.defineProperty(exports, "__esModule", ({
4588 value: true
4589 }));
4590 exports["default"] = exports.Close = void 0;
4591 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4592 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4593 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4594 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4595 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4596 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4597 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)); }
4598 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4599 var Close = exports.Close = /*#__PURE__*/function (_CommandBase) {
4600 function Close() {
4601 (0, _classCallCheck2.default)(this, Close);
4602 return _callSuper(this, Close, arguments);
4603 }
4604 (0, _inherits2.default)(Close, _CommandBase);
4605 return (0, _createClass2.default)(Close, [{
4606 key: "apply",
4607 value: function apply() {
4608 this.component.close();
4609 }
4610 }]);
4611 }(_commandBase.default);
4612 var _default = exports["default"] = Close;
4613
4614 /***/ }),
4615
4616 /***/ "../modules/web-cli/assets/js/modules/commands/index.js":
4617 /*!**************************************************************!*\
4618 !*** ../modules/web-cli/assets/js/modules/commands/index.js ***!
4619 \**************************************************************/
4620 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4621
4622 "use strict";
4623
4624
4625 Object.defineProperty(exports, "__esModule", ({
4626 value: true
4627 }));
4628 Object.defineProperty(exports, "Close", ({
4629 enumerable: true,
4630 get: function get() {
4631 return _close.Close;
4632 }
4633 }));
4634 Object.defineProperty(exports, "Open", ({
4635 enumerable: true,
4636 get: function get() {
4637 return _open.Open;
4638 }
4639 }));
4640 Object.defineProperty(exports, "Toggle", ({
4641 enumerable: true,
4642 get: function get() {
4643 return _toggle.Toggle;
4644 }
4645 }));
4646 var _close = __webpack_require__(/*! ./close */ "../modules/web-cli/assets/js/modules/commands/close.js");
4647 var _open = __webpack_require__(/*! ./open */ "../modules/web-cli/assets/js/modules/commands/open.js");
4648 var _toggle = __webpack_require__(/*! ./toggle */ "../modules/web-cli/assets/js/modules/commands/toggle.js");
4649
4650 /***/ }),
4651
4652 /***/ "../modules/web-cli/assets/js/modules/commands/open.js":
4653 /*!*************************************************************!*\
4654 !*** ../modules/web-cli/assets/js/modules/commands/open.js ***!
4655 \*************************************************************/
4656 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4657
4658 "use strict";
4659
4660
4661 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4662 Object.defineProperty(exports, "__esModule", ({
4663 value: true
4664 }));
4665 exports["default"] = exports.Open = void 0;
4666 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4667 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4668 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4669 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4670 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4671 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4672 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)); }
4673 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4674 var Open = exports.Open = /*#__PURE__*/function (_CommandBase) {
4675 function Open() {
4676 (0, _classCallCheck2.default)(this, Open);
4677 return _callSuper(this, Open, arguments);
4678 }
4679 (0, _inherits2.default)(Open, _CommandBase);
4680 return (0, _createClass2.default)(Open, [{
4681 key: "apply",
4682 value: function apply() {
4683 $e.route(this.component.getNamespace());
4684 }
4685 }]);
4686 }(_commandBase.default);
4687 var _default = exports["default"] = Open;
4688
4689 /***/ }),
4690
4691 /***/ "../modules/web-cli/assets/js/modules/commands/toggle.js":
4692 /*!***************************************************************!*\
4693 !*** ../modules/web-cli/assets/js/modules/commands/toggle.js ***!
4694 \***************************************************************/
4695 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4696
4697 "use strict";
4698
4699
4700 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4701 Object.defineProperty(exports, "__esModule", ({
4702 value: true
4703 }));
4704 exports["default"] = exports.Toggle = void 0;
4705 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4706 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4707 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4708 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4709 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4710 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4711 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)); }
4712 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4713 var Toggle = exports.Toggle = /*#__PURE__*/function (_CommandBase) {
4714 function Toggle() {
4715 (0, _classCallCheck2.default)(this, Toggle);
4716 return _callSuper(this, Toggle, arguments);
4717 }
4718 (0, _inherits2.default)(Toggle, _CommandBase);
4719 return (0, _createClass2.default)(Toggle, [{
4720 key: "apply",
4721 value: function apply() {
4722 if (this.component.isOpen) {
4723 this.component.close();
4724 } else {
4725 $e.route(this.component.getNamespace());
4726 }
4727 }
4728 }]);
4729 }(_commandBase.default);
4730 var _default = exports["default"] = Toggle;
4731
4732 /***/ }),
4733
4734 /***/ "../modules/web-cli/assets/js/modules/component-base.js":
4735 /*!**************************************************************!*\
4736 !*** ../modules/web-cli/assets/js/modules/component-base.js ***!
4737 \**************************************************************/
4738 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4739
4740 "use strict";
4741
4742
4743 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4744 Object.defineProperty(exports, "__esModule", ({
4745 value: true
4746 }));
4747 exports["default"] = void 0;
4748 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
4749 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
4750 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4751 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4752 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4753 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4754 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4755 var _commandCallbackBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-callback-base */ "../modules/web-cli/assets/js/modules/command-callback-base.js"));
4756 var _toolkit = __webpack_require__(/*! @reduxjs/toolkit */ "../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js");
4757 var _module = _interopRequireDefault(__webpack_require__(/*! elementor/assets/dev/js/modules/imports/module.js */ "../assets/dev/js/modules/imports/module.js"));
4758 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
4759 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
4760 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; }
4761 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; }
4762 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)); }
4763 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4764 /**
4765 * @typedef {import('./command-infra')} CommandInfra
4766 * @typedef {import('./hook-base')} HookBase
4767 * @typedef {import('../core/states/ui-state-base')} UiStateBase
4768 */
4769 var ComponentBase = exports["default"] = /*#__PURE__*/function (_Module) {
4770 function ComponentBase() {
4771 (0, _classCallCheck2.default)(this, ComponentBase);
4772 return _callSuper(this, ComponentBase, arguments);
4773 }
4774 (0, _inherits2.default)(ComponentBase, _Module);
4775 return (0, _createClass2.default)(ComponentBase, [{
4776 key: "__construct",
4777 value: function __construct() {
4778 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4779 if (args.manager) {
4780 this.manager = args.manager;
4781 }
4782 this.commands = this.defaultCommands();
4783 this.commandsInternal = this.defaultCommandsInternal();
4784 this.hooks = this.defaultHooks();
4785 this.routes = this.defaultRoutes();
4786 this.tabs = this.defaultTabs();
4787 this.shortcuts = this.defaultShortcuts();
4788 this.utils = this.defaultUtils();
4789 this.data = this.defaultData();
4790 this.uiStates = this.defaultUiStates();
4791 this.states = this.defaultStates();
4792 this.defaultRoute = '';
4793 this.currentTab = '';
4794 }
4795 }, {
4796 key: "registerAPI",
4797 value: function registerAPI() {
4798 var _this = this;
4799 Object.entries(this.getTabs()).forEach(function (tab) {
4800 return _this.registerTabRoute(tab[0]);
4801 });
4802 Object.entries(this.getRoutes()).forEach(function (_ref) {
4803 var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
4804 route = _ref2[0],
4805 callback = _ref2[1];
4806 return _this.registerRoute(route, callback);
4807 });
4808 Object.entries(this.getCommands()).forEach(function (_ref3) {
4809 var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
4810 command = _ref4[0],
4811 callback = _ref4[1];
4812 return _this.registerCommand(command, callback);
4813 });
4814 Object.entries(this.getCommandsInternal()).forEach(function (_ref5) {
4815 var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
4816 command = _ref6[0],
4817 callback = _ref6[1];
4818 return _this.registerCommandInternal(command, callback);
4819 });
4820 Object.values(this.getHooks()).forEach(function (instance) {
4821 return _this.registerHook(instance);
4822 });
4823 Object.entries(this.getData()).forEach(function (_ref7) {
4824 var _ref8 = (0, _slicedToArray2.default)(_ref7, 2),
4825 command = _ref8[0],
4826 callback = _ref8[1];
4827 return _this.registerData(command, callback);
4828 });
4829 Object.values(this.getUiStates()).forEach(function (instance) {
4830 return _this.registerUiState(instance);
4831 });
4832 Object.entries(this.getStates()).forEach(function (_ref9) {
4833 var _ref0 = (0, _slicedToArray2.default)(_ref9, 2),
4834 id = _ref0[0],
4835 state = _ref0[1];
4836 return _this.registerState(id, state);
4837 });
4838 }
4839
4840 // eslint-disable-next-line jsdoc/require-returns-check
4841 /**
4842 * @return {string} namespace
4843 */
4844 }, {
4845 key: "getNamespace",
4846 value: function getNamespace() {
4847 (0, _forceMethodImplementation.default)();
4848 }
4849
4850 /**
4851 * @deprecated since 3.7.0, use `getServiceName()` instead.
4852 */
4853 }, {
4854 key: "getRootContainer",
4855 value: function getRootContainer() {
4856 _deprecation.default.deprecated('getRootContainer()', '3.7.0', 'getServiceName()');
4857 return this.getServiceName();
4858 }
4859 }, {
4860 key: "getServiceName",
4861 value: function getServiceName() {
4862 return this.getNamespace().split('/')[0];
4863 }
4864 }, {
4865 key: "store",
4866 get: function get() {
4867 return $e.store.get(this.getNamespace());
4868 }
4869 }, {
4870 key: "defaultTabs",
4871 value: function defaultTabs() {
4872 return {};
4873 }
4874 }, {
4875 key: "defaultRoutes",
4876 value: function defaultRoutes() {
4877 return {};
4878 }
4879 }, {
4880 key: "defaultCommands",
4881 value: function defaultCommands() {
4882 return {};
4883 }
4884 }, {
4885 key: "defaultCommandsInternal",
4886 value: function defaultCommandsInternal() {
4887 return {};
4888 }
4889 }, {
4890 key: "defaultHooks",
4891 value: function defaultHooks() {
4892 return {};
4893 }
4894
4895 /**
4896 * Get the component's default UI states.
4897 *
4898 * @return {Object} default UI states
4899 */
4900 }, {
4901 key: "defaultUiStates",
4902 value: function defaultUiStates() {
4903 return {};
4904 }
4905
4906 /**
4907 * Get the component's Redux slice settings.
4908 *
4909 * @return {Object} Redux slice settings
4910 */
4911 }, {
4912 key: "defaultStates",
4913 value: function defaultStates() {
4914 return {};
4915 }
4916 }, {
4917 key: "defaultShortcuts",
4918 value: function defaultShortcuts() {
4919 return {};
4920 }
4921 }, {
4922 key: "defaultUtils",
4923 value: function defaultUtils() {
4924 return {};
4925 }
4926 }, {
4927 key: "defaultData",
4928 value: function defaultData() {
4929 return {};
4930 }
4931 }, {
4932 key: "getCommands",
4933 value: function getCommands() {
4934 return this.commands;
4935 }
4936 }, {
4937 key: "getCommandsInternal",
4938 value: function getCommandsInternal() {
4939 return this.commandsInternal;
4940 }
4941 }, {
4942 key: "getHooks",
4943 value: function getHooks() {
4944 return this.hooks;
4945 }
4946
4947 /**
4948 * Retrieve the component's UI states.
4949 *
4950 * @return {Object} UI states
4951 */
4952 }, {
4953 key: "getUiStates",
4954 value: function getUiStates() {
4955 return this.uiStates;
4956 }
4957
4958 /**
4959 * Retrieve the component's Redux Slice.
4960 *
4961 * @return {Object} Redux Slice
4962 */
4963 }, {
4964 key: "getStates",
4965 value: function getStates() {
4966 return this.states;
4967 }
4968 }, {
4969 key: "getRoutes",
4970 value: function getRoutes() {
4971 return this.routes;
4972 }
4973 }, {
4974 key: "getTabs",
4975 value: function getTabs() {
4976 return this.tabs;
4977 }
4978 }, {
4979 key: "getShortcuts",
4980 value: function getShortcuts() {
4981 return this.shortcuts;
4982 }
4983 }, {
4984 key: "getData",
4985 value: function getData() {
4986 return this.data;
4987 }
4988
4989 /**
4990 * @param {string} command
4991 * @param {(()=>{}|CommandInfra)} context
4992 * @param {'default'|'internal'|'data'} commandsType
4993 */
4994 }, {
4995 key: "registerCommand",
4996 value: function registerCommand(command, context) {
4997 var commandsType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'default';
4998 var commandsManager;
4999 switch (commandsType) {
5000 case 'default':
5001 commandsManager = $e.commands;
5002 break;
5003 case 'internal':
5004 commandsManager = $e.commandsInternal;
5005 break;
5006 case 'data':
5007 commandsManager = $e.data;
5008 break;
5009 default:
5010 throw new Error("Invalid commands type: '".concat(command, "'"));
5011 }
5012 var fullCommand = this.getNamespace() + '/' + command,
5013 instanceType = context.getInstanceType ? context.getInstanceType() : false,
5014 registerConfig = {
5015 command: fullCommand,
5016 component: this
5017 };
5018
5019 // Support pure callback.
5020 if (!instanceType) {
5021 if ($e.devTools) {
5022 $e.devTools.log.warn("Attach command-callback-base, on command: '".concat(fullCommand, "', context is unknown type."));
5023 }
5024 registerConfig.callback = context;
5025
5026 // Unique class.
5027 context = /*#__PURE__*/function (_CommandCallbackBase) {
5028 function context() {
5029 (0, _classCallCheck2.default)(this, context);
5030 return _callSuper(this, context, arguments);
5031 }
5032 (0, _inherits2.default)(context, _CommandCallbackBase);
5033 return (0, _createClass2.default)(context);
5034 }(_commandCallbackBase.default);
5035 }
5036 context.setRegisterConfig(registerConfig);
5037 commandsManager.register(this, command, context);
5038 }
5039
5040 /**
5041 * @param {HookBase} instance
5042 */
5043 }, {
5044 key: "registerHook",
5045 value: function registerHook(instance) {
5046 return instance.register();
5047 }
5048 }, {
5049 key: "registerCommandInternal",
5050 value: function registerCommandInternal(command, context) {
5051 this.registerCommand(command, context, 'internal');
5052 }
5053
5054 /**
5055 * Register a UI state.
5056 *
5057 * @param {UiStateBase} instance - UI state instance.
5058 *
5059 * @return {void}
5060 */
5061 }, {
5062 key: "registerUiState",
5063 value: function registerUiState(instance) {
5064 $e.uiStates.register(instance);
5065 }
5066
5067 /**
5068 * Register a Redux Slice.
5069 *
5070 * @param {string} id - State id.
5071 * @param {Object} stateConfig - The state config.
5072 *
5073 * @return {void}
5074 */
5075 }, {
5076 key: "registerState",
5077 value: function registerState(id, stateConfig) {
5078 id = this.getNamespace() + (id ? "/".concat(id) : '');
5079 var slice = (0, _toolkit.createSlice)(_objectSpread(_objectSpread({}, stateConfig), {}, {
5080 name: id
5081 }));
5082 $e.store.register(id, slice);
5083 }
5084 }, {
5085 key: "registerRoute",
5086 value: function registerRoute(route, callback) {
5087 $e.routes.register(this, route, callback);
5088 }
5089 }, {
5090 key: "registerData",
5091 value: function registerData(command, context) {
5092 this.registerCommand(command, context, 'data');
5093 }
5094 }, {
5095 key: "unregisterRoute",
5096 value: function unregisterRoute(route) {
5097 $e.routes.unregister(this, route);
5098 }
5099 }, {
5100 key: "registerTabRoute",
5101 value: function registerTabRoute(tab) {
5102 var _this2 = this;
5103 this.registerRoute(tab, function (args) {
5104 return _this2.activateTab(tab, args);
5105 });
5106 }
5107 }, {
5108 key: "dependency",
5109 value: function dependency() {
5110 return true;
5111 }
5112 }, {
5113 key: "open",
5114 value: function open() {
5115 return true;
5116 }
5117 }, {
5118 key: "close",
5119 value: function close() {
5120 if (!this.isOpen) {
5121 return false;
5122 }
5123 this.isOpen = false;
5124 this.inactivate();
5125 $e.routes.clearCurrent(this.getNamespace());
5126 $e.routes.clearHistory(this.getServiceName());
5127 return true;
5128 }
5129 }, {
5130 key: "activate",
5131 value: function activate() {
5132 $e.components.activate(this.getNamespace());
5133 }
5134 }, {
5135 key: "inactivate",
5136 value: function inactivate() {
5137 $e.components.inactivate(this.getNamespace());
5138 }
5139 }, {
5140 key: "isActive",
5141 value: function isActive() {
5142 return $e.components.isActive(this.getNamespace());
5143 }
5144 }, {
5145 key: "onRoute",
5146 value: function onRoute(route) {
5147 this.toggleRouteClass(route, true);
5148 this.toggleHistoryClass();
5149 this.activate();
5150 this.trigger('route/open', route);
5151 }
5152 }, {
5153 key: "onCloseRoute",
5154 value: function onCloseRoute(route) {
5155 this.toggleRouteClass(route, false);
5156 this.inactivate();
5157 this.trigger('route/close', route);
5158 }
5159 }, {
5160 key: "setDefaultRoute",
5161 value: function setDefaultRoute(route) {
5162 this.defaultRoute = this.getNamespace() + '/' + route;
5163 }
5164 }, {
5165 key: "getDefaultRoute",
5166 value: function getDefaultRoute() {
5167 return this.defaultRoute;
5168 }
5169 }, {
5170 key: "removeTab",
5171 value: function removeTab(tab) {
5172 delete this.tabs[tab];
5173 this.unregisterRoute(tab);
5174 }
5175 }, {
5176 key: "hasTab",
5177 value: function hasTab(tab) {
5178 return !!this.tabs[tab];
5179 }
5180 }, {
5181 key: "addTab",
5182 value: function addTab(tab, args, position) {
5183 var _this3 = this;
5184 this.tabs[tab] = args;
5185 // It can be 0.
5186 if ('undefined' !== typeof position) {
5187 var newTabs = {};
5188 var ids = Object.keys(this.tabs);
5189 // Remove new tab
5190 ids.pop();
5191
5192 // Add it to position.
5193 ids.splice(position, 0, tab);
5194 ids.forEach(function (id) {
5195 newTabs[id] = _this3.tabs[id];
5196 });
5197 this.tabs = newTabs;
5198 }
5199 this.registerTabRoute(tab);
5200 }
5201 }, {
5202 key: "getTabsWrapperSelector",
5203 value: function getTabsWrapperSelector() {
5204 return '';
5205 }
5206 }, {
5207 key: "getTabRoute",
5208 value: function getTabRoute(tab) {
5209 return this.getNamespace() + '/' + tab;
5210 }
5211 }, {
5212 key: "renderTab",
5213 value: function renderTab(tab) {} // eslint-disable-line
5214 }, {
5215 key: "activateTab",
5216 value: function activateTab(tab, args) {
5217 var _this4 = this;
5218 this.renderTab(tab, args);
5219 jQuery(this.getTabsWrapperSelector() + ' .elementor-component-tab').off('click').on('click', function (event) {
5220 $e.route(_this4.getTabRoute(event.currentTarget.dataset.tab), args);
5221 }).removeClass('elementor-active').filter('[data-tab="' + tab + '"]').addClass('elementor-active');
5222 }
5223 }, {
5224 key: "getActiveTabConfig",
5225 value: function getActiveTabConfig() {
5226 return this.tabs[this.currentTab] || {};
5227 }
5228 }, {
5229 key: "getBodyClass",
5230 value: function getBodyClass(route) {
5231 return 'e-route-' + route.replace(/\//g, '-');
5232 }
5233
5234 /**
5235 * If command includes uppercase character convert it to lowercase and add `-`.
5236 * e.g: `CopyAll` is converted to `copy-all`.
5237 *
5238 * @param {string} commandName
5239 */
5240 }, {
5241 key: "normalizeCommandName",
5242 value: function normalizeCommandName(commandName) {
5243 return commandName.replace(/[A-Z]/g, function (match, offset) {
5244 return (offset > 0 ? '-' : '') + match.toLowerCase();
5245 });
5246 }
5247
5248 /**
5249 * @param {{}} commandsFromImport
5250 * @return {{}} imported commands
5251 */
5252 }, {
5253 key: "importCommands",
5254 value: function importCommands(commandsFromImport) {
5255 var _this5 = this;
5256 var commands = {};
5257
5258 // Convert `Commands` to `ComponentBase` workable format.
5259 Object.entries(commandsFromImport).forEach(function (_ref1) {
5260 var _ref10 = (0, _slicedToArray2.default)(_ref1, 2),
5261 className = _ref10[0],
5262 Class = _ref10[1];
5263 var command = _this5.normalizeCommandName(className);
5264 commands[command] = Class;
5265 });
5266 return commands;
5267 }
5268 }, {
5269 key: "importHooks",
5270 value: function importHooks(hooksFromImport) {
5271 var hooks = {};
5272 for (var key in hooksFromImport) {
5273 var hook = new hooksFromImport[key]();
5274 hooks[hook.getId()] = hook;
5275 }
5276 return hooks;
5277 }
5278
5279 /**
5280 * Import & initialize the component's UI states.
5281 * Should be used inside `defaultUiState()`.
5282 *
5283 * @param {Object} statesFromImport - UI states from import.
5284 *
5285 * @return {Object} UI States
5286 */
5287 }, {
5288 key: "importUiStates",
5289 value: function importUiStates(statesFromImport) {
5290 var _this6 = this;
5291 var uiStates = {};
5292 Object.values(statesFromImport).forEach(function (className) {
5293 var uiState = new className(_this6);
5294 uiStates[uiState.getId()] = uiState;
5295 });
5296 return uiStates;
5297 }
5298
5299 /**
5300 * Set a UI state value.
5301 * TODO: Should we provide such function? Maybe the developer should implicitly pass the full state ID?
5302 *
5303 * @param {string} state - Non-prefixed state ID.
5304 * @param {*} value - New state value.
5305 *
5306 * @return {void}
5307 */
5308 }, {
5309 key: "setUiState",
5310 value: function setUiState(state, value) {
5311 $e.uiStates.set("".concat(this.getNamespace(), "/").concat(state), value);
5312 }
5313 }, {
5314 key: "toggleRouteClass",
5315 value: function toggleRouteClass(route, state) {
5316 document.body.classList.toggle(this.getBodyClass(route), state);
5317 }
5318 }, {
5319 key: "toggleHistoryClass",
5320 value: function toggleHistoryClass() {
5321 document.body.classList.toggle('e-routes-has-history', !!$e.routes.getHistory(this.getServiceName()).length);
5322 }
5323 }]);
5324 }(_module.default);
5325
5326 /***/ }),
5327
5328 /***/ "../modules/web-cli/assets/js/modules/component-modal-base.js":
5329 /*!********************************************************************!*\
5330 !*** ../modules/web-cli/assets/js/modules/component-modal-base.js ***!
5331 \********************************************************************/
5332 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5333
5334 "use strict";
5335
5336
5337 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5338 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
5339 Object.defineProperty(exports, "__esModule", ({
5340 value: true
5341 }));
5342 exports["default"] = void 0;
5343 var _readOnlyError2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/readOnlyError */ "../node_modules/@babel/runtime/helpers/readOnlyError.js"));
5344 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
5345 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
5346 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
5347 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
5348 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
5349 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
5350 var _componentBase = _interopRequireDefault(__webpack_require__(/*! ./component-base */ "../modules/web-cli/assets/js/modules/component-base.js"));
5351 var commands = _interopRequireWildcard(__webpack_require__(/*! ./commands/ */ "../modules/web-cli/assets/js/modules/commands/index.js"));
5352 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
5353 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); }
5354 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)); }
5355 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
5356 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; }
5357 var ComponentModalBase = exports["default"] = /*#__PURE__*/function (_ComponentBase) {
5358 function ComponentModalBase() {
5359 (0, _classCallCheck2.default)(this, ComponentModalBase);
5360 return _callSuper(this, ComponentModalBase, arguments);
5361 }
5362 (0, _inherits2.default)(ComponentModalBase, _ComponentBase);
5363 return (0, _createClass2.default)(ComponentModalBase, [{
5364 key: "registerAPI",
5365 value: function registerAPI() {
5366 var _this = this;
5367 _superPropGet(ComponentModalBase, "registerAPI", this, 3)([]);
5368 $e.shortcuts.register('esc', {
5369 scopes: [this.getNamespace()],
5370 callback: function callback() {
5371 return _this.close();
5372 }
5373 });
5374 }
5375 }, {
5376 key: "defaultCommands",
5377 value: function defaultCommands() {
5378 return this.importCommands(commands);
5379 }
5380 }, {
5381 key: "defaultRoutes",
5382 value: function defaultRoutes() {
5383 return {
5384 '': function _() {/* Nothing to do, it's already rendered. */}
5385 };
5386 }
5387 }, {
5388 key: "open",
5389 value: function open() {
5390 var _this2 = this;
5391 if (!this.layout) {
5392 var layout = this.getModalLayout();
5393 this.layout = new layout({
5394 component: this
5395 });
5396 this.layout.getModal().on('hide', function () {
5397 return _this2.close();
5398 });
5399 }
5400 this.layout.showModal();
5401 return true;
5402 }
5403 }, {
5404 key: "close",
5405 value: function close() {
5406 if (!_superPropGet(ComponentModalBase, "close", this, 3)([])) {
5407 return false;
5408 }
5409 var close = elementor.hooks.applyFilters('component/modal/close', this.layout.getModal().hide.bind(this.layout.getModal()), this);
5410 close();
5411 return true;
5412 }
5413 }, {
5414 key: "getModalLayout",
5415 value: function getModalLayout() {
5416 (0, _forceMethodImplementation.default)();
5417 }
5418 }]);
5419 }(_componentBase.default);
5420
5421 /***/ }),
5422
5423 /***/ "../modules/web-cli/assets/js/utils/console.js":
5424 /*!*****************************************************!*\
5425 !*** ../modules/web-cli/assets/js/utils/console.js ***!
5426 \*****************************************************/
5427 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5428
5429 "use strict";
5430
5431
5432 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5433 Object.defineProperty(exports, "__esModule", ({
5434 value: true
5435 }));
5436 exports["default"] = void 0;
5437 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
5438 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
5439 var Console = exports["default"] = /*#__PURE__*/function () {
5440 function Console() {
5441 (0, _classCallCheck2.default)(this, Console);
5442 }
5443 return (0, _createClass2.default)(Console, null, [{
5444 key: "error",
5445 value: function error(message) {
5446 // Show an error if devTools is available.
5447 if ($e.devTools) {
5448 $e.devTools.log.error(message);
5449 }
5450
5451 // If not a 'Hook-Break' then show error.
5452 if (!(message instanceof $e.modules.HookBreak)) {
5453 // eslint-disable-next-line no-console
5454 console.error(message);
5455 }
5456 }
5457 }, {
5458 key: "warn",
5459 value: function warn() {
5460 var _console;
5461 var style = "font-size: 12px; background-image: url(\"".concat(elementorWebCliConfig.urls.assets, "images/logo-icon.png\"); background-repeat: no-repeat; background-size: contain;");
5462 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5463 args[_key] = arguments[_key];
5464 }
5465 args.unshift('%c %c', style, '');
5466 (_console = console).warn.apply(_console, args); // eslint-disable-line no-console
5467 }
5468 }]);
5469 }();
5470
5471 /***/ }),
5472
5473 /***/ "../modules/web-cli/assets/js/utils/deprecation.js":
5474 /*!*********************************************************!*\
5475 !*** ../modules/web-cli/assets/js/utils/deprecation.js ***!
5476 \*********************************************************/
5477 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5478
5479 "use strict";
5480
5481
5482 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5483 Object.defineProperty(exports, "__esModule", ({
5484 value: true
5485 }));
5486 exports["default"] = void 0;
5487 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
5488 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
5489 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
5490 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
5491 // Copied from `modules/dev-tools/assets/js/deprecation.js`
5492 /**
5493 * @typedef {Object} Version
5494 * @property {number} major1 The first number
5495 * @property {number} major2 The second number
5496 * @property {number} minor The third number
5497 * @property {string} build The fourth number
5498 */
5499
5500 var softDeprecated = function softDeprecated(name, version, replacement) {
5501 if (elementorWebCliConfig.isDebug) {
5502 deprecatedMessage('soft', name, version, replacement);
5503 }
5504 };
5505 var hardDeprecated = function hardDeprecated(name, version, replacement) {
5506 deprecatedMessage('hard', name, version, replacement);
5507 };
5508 var deprecatedMessage = function deprecatedMessage(type, name, version, replacement) {
5509 var message = "`".concat(name, "` is ").concat(type, " deprecated since ").concat(version);
5510 if (replacement) {
5511 message += " - Use `".concat(replacement, "` instead");
5512 }
5513 _console.default.warn(message);
5514 };
5515 var Deprecation = exports["default"] = /*#__PURE__*/function () {
5516 function Deprecation() {
5517 (0, _classCallCheck2.default)(this, Deprecation);
5518 }
5519 return (0, _createClass2.default)(Deprecation, null, [{
5520 key: "deprecated",
5521 value: function deprecated(name, version, replacement) {
5522 if (this.isHardDeprecated(version)) {
5523 hardDeprecated(name, version, replacement);
5524 } else {
5525 softDeprecated(name, version, replacement);
5526 }
5527 }
5528
5529 /**
5530 * @param {string} version
5531 *
5532 * @return {Version}
5533 */
5534 }, {
5535 key: "parseVersion",
5536 value: function parseVersion(version) {
5537 var versionParts = version.split('.');
5538 if (versionParts.length < 3 || versionParts.length > 4) {
5539 throw new RangeError('Invalid Semantic Version string provided');
5540 }
5541 var _versionParts = (0, _slicedToArray2.default)(versionParts, 4),
5542 major1 = _versionParts[0],
5543 major2 = _versionParts[1],
5544 minor = _versionParts[2],
5545 _versionParts$ = _versionParts[3],
5546 build = _versionParts$ === void 0 ? '' : _versionParts$;
5547 return {
5548 major1: parseInt(major1),
5549 major2: parseInt(major2),
5550 minor: parseInt(minor),
5551 build: build
5552 };
5553 }
5554
5555 /**
5556 * Get total of major.
5557 *
5558 * 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,
5559 * versions with major2 more then 9 will be added to total.
5560 *
5561 * @param {Version} versionObj
5562 *
5563 * @return {number}
5564 */
5565 }, {
5566 key: "getTotalMajor",
5567 value: function getTotalMajor(versionObj) {
5568 var total = parseInt("".concat(versionObj.major1).concat(versionObj.major2, "0"));
5569 total = Number((total / 10).toFixed(0));
5570 if (versionObj.major2 > 9) {
5571 total = versionObj.major2 - 9;
5572 }
5573 return total;
5574 }
5575
5576 /**
5577 * @param {string} version1
5578 * @param {string} version2
5579 *
5580 * @return {number}
5581 */
5582 }, {
5583 key: "compareVersion",
5584 value: function compareVersion(version1, version2) {
5585 var _this = this;
5586 return [this.parseVersion(version1), this.parseVersion(version2)].map(function (versionObj) {
5587 return _this.getTotalMajor(versionObj);
5588 }).reduce(function (acc, major) {
5589 return acc - major;
5590 });
5591 }
5592
5593 /**
5594 * @param {string} version
5595 *
5596 * @return {boolean}
5597 */
5598 }, {
5599 key: "isSoftDeprecated",
5600 value: function isSoftDeprecated(version) {
5601 var total = this.compareVersion(version, elementorWebCliConfig.version);
5602 return total <= 4;
5603 }
5604
5605 /**
5606 * @param {string} version
5607 * @return {boolean}
5608 */
5609 }, {
5610 key: "isHardDeprecated",
5611 value: function isHardDeprecated(version) {
5612 var total = this.compareVersion(version, elementorWebCliConfig.version);
5613 return total < 0 || total >= 8;
5614 }
5615 }]);
5616 }();
5617
5618 /***/ }),
5619
5620 /***/ "../modules/web-cli/assets/js/utils/force-method-implementation.js":
5621 /*!*************************************************************************!*\
5622 !*** ../modules/web-cli/assets/js/utils/force-method-implementation.js ***!
5623 \*************************************************************************/
5624 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5625
5626 "use strict";
5627
5628
5629 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5630 Object.defineProperty(exports, "__esModule", ({
5631 value: true
5632 }));
5633 exports["default"] = exports.ForceMethodImplementation = void 0;
5634 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
5635 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
5636 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
5637 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
5638 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
5639 var _wrapNativeSuper2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/wrapNativeSuper */ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js"));
5640 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)); }
5641 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
5642 // TODO: Copied from `assets/dev/js/modules/imports/force-method-implementation.js`;
5643 var ForceMethodImplementation = exports.ForceMethodImplementation = /*#__PURE__*/function (_Error) {
5644 function ForceMethodImplementation() {
5645 var _this;
5646 var info = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5647 (0, _classCallCheck2.default)(this, ForceMethodImplementation);
5648 _this = _callSuper(this, ForceMethodImplementation, ["".concat(info.isStatic ? 'static ' : '').concat(info.fullName, "() should be implemented, please provide '").concat(info.functionName || info.fullName, "' functionality.")]);
5649 Error.captureStackTrace(_this, ForceMethodImplementation);
5650 return _this;
5651 }
5652 (0, _inherits2.default)(ForceMethodImplementation, _Error);
5653 return (0, _createClass2.default)(ForceMethodImplementation);
5654 }(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
5655 var _default = exports["default"] = function _default() {
5656 var stack = Error().stack,
5657 caller = stack.split('\n')[2].trim(),
5658 callerName = caller.startsWith('at new') ? 'constructor' : caller.split(' ')[1],
5659 info = {};
5660 info.functionName = callerName;
5661 info.fullName = callerName;
5662 if (info.functionName.includes('.')) {
5663 var parts = info.functionName.split('.');
5664 info.className = parts[0];
5665 info.functionName = parts[1];
5666 } else {
5667 info.isStatic = true;
5668 }
5669 throw new ForceMethodImplementation(info);
5670 };
5671
5672 /***/ }),
5673
5674 /***/ "../node_modules/@babel/runtime/helpers/OverloadYield.js":
5675 /*!***************************************************************!*\
5676 !*** ../node_modules/@babel/runtime/helpers/OverloadYield.js ***!
5677 \***************************************************************/
5678 /***/ ((module) => {
5679
5680 function _OverloadYield(e, d) {
5681 this.v = e, this.k = d;
5682 }
5683 module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
5684
5685 /***/ }),
5686
5687 /***/ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js":
5688 /*!******************************************************************!*\
5689 !*** ../node_modules/@babel/runtime/helpers/arrayLikeToArray.js ***!
5690 \******************************************************************/
5691 /***/ ((module) => {
5692
5693 function _arrayLikeToArray(r, a) {
5694 (null == a || a > r.length) && (a = r.length);
5695 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
5696 return n;
5697 }
5698 module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
5699
5700 /***/ }),
5701
5702 /***/ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js":
5703 /*!****************************************************************!*\
5704 !*** ../node_modules/@babel/runtime/helpers/arrayWithHoles.js ***!
5705 \****************************************************************/
5706 /***/ ((module) => {
5707
5708 function _arrayWithHoles(r) {
5709 if (Array.isArray(r)) return r;
5710 }
5711 module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
5712
5713 /***/ }),
5714
5715 /***/ "../node_modules/@babel/runtime/helpers/assertThisInitialized.js":
5716 /*!***********************************************************************!*\
5717 !*** ../node_modules/@babel/runtime/helpers/assertThisInitialized.js ***!
5718 \***********************************************************************/
5719 /***/ ((module) => {
5720
5721 function _assertThisInitialized(e) {
5722 if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
5723 return e;
5724 }
5725 module.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports["default"] = module.exports;
5726
5727 /***/ }),
5728
5729 /***/ "../node_modules/@babel/runtime/helpers/asyncToGenerator.js":
5730 /*!******************************************************************!*\
5731 !*** ../node_modules/@babel/runtime/helpers/asyncToGenerator.js ***!
5732 \******************************************************************/
5733 /***/ ((module) => {
5734
5735 function asyncGeneratorStep(n, t, e, r, o, a, c) {
5736 try {
5737 var i = n[a](c),
5738 u = i.value;
5739 } catch (n) {
5740 return void e(n);
5741 }
5742 i.done ? t(u) : Promise.resolve(u).then(r, o);
5743 }
5744 function _asyncToGenerator(n) {
5745 return function () {
5746 var t = this,
5747 e = arguments;
5748 return new Promise(function (r, o) {
5749 var a = n.apply(t, e);
5750 function _next(n) {
5751 asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
5752 }
5753 function _throw(n) {
5754 asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
5755 }
5756 _next(void 0);
5757 });
5758 };
5759 }
5760 module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
5761
5762 /***/ }),
5763
5764 /***/ "../node_modules/@babel/runtime/helpers/classCallCheck.js":
5765 /*!****************************************************************!*\
5766 !*** ../node_modules/@babel/runtime/helpers/classCallCheck.js ***!
5767 \****************************************************************/
5768 /***/ ((module) => {
5769
5770 function _classCallCheck(a, n) {
5771 if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
5772 }
5773 module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
5774
5775 /***/ }),
5776
5777 /***/ "../node_modules/@babel/runtime/helpers/construct.js":
5778 /*!***********************************************************!*\
5779 !*** ../node_modules/@babel/runtime/helpers/construct.js ***!
5780 \***********************************************************/
5781 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5782
5783 var isNativeReflectConstruct = __webpack_require__(/*! ./isNativeReflectConstruct.js */ "../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js");
5784 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
5785 function _construct(t, e, r) {
5786 if (isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
5787 var o = [null];
5788 o.push.apply(o, e);
5789 var p = new (t.bind.apply(t, o))();
5790 return r && setPrototypeOf(p, r.prototype), p;
5791 }
5792 module.exports = _construct, module.exports.__esModule = true, module.exports["default"] = module.exports;
5793
5794 /***/ }),
5795
5796 /***/ "../node_modules/@babel/runtime/helpers/createClass.js":
5797 /*!*************************************************************!*\
5798 !*** ../node_modules/@babel/runtime/helpers/createClass.js ***!
5799 \*************************************************************/
5800 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5801
5802 var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/toPropertyKey.js");
5803 function _defineProperties(e, r) {
5804 for (var t = 0; t < r.length; t++) {
5805 var o = r[t];
5806 o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey(o.key), o);
5807 }
5808 }
5809 function _createClass(e, r, t) {
5810 return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
5811 writable: !1
5812 }), e;
5813 }
5814 module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
5815
5816 /***/ }),
5817
5818 /***/ "../node_modules/@babel/runtime/helpers/defineProperty.js":
5819 /*!****************************************************************!*\
5820 !*** ../node_modules/@babel/runtime/helpers/defineProperty.js ***!
5821 \****************************************************************/
5822 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5823
5824 var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/toPropertyKey.js");
5825 function _defineProperty(e, r, t) {
5826 return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
5827 value: t,
5828 enumerable: !0,
5829 configurable: !0,
5830 writable: !0
5831 }) : e[r] = t, e;
5832 }
5833 module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
5834
5835 /***/ }),
5836
5837 /***/ "../node_modules/@babel/runtime/helpers/esm/defineProperty.js":
5838 /*!********************************************************************!*\
5839 !*** ../node_modules/@babel/runtime/helpers/esm/defineProperty.js ***!
5840 \********************************************************************/
5841 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5842
5843 "use strict";
5844 __webpack_require__.r(__webpack_exports__);
5845 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5846 /* harmony export */ "default": () => (/* binding */ _defineProperty)
5847 /* harmony export */ });
5848 /* harmony import */ var _toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js");
5849
5850 function _defineProperty(e, r, t) {
5851 return (r = (0,_toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__["default"])(r)) in e ? Object.defineProperty(e, r, {
5852 value: t,
5853 enumerable: !0,
5854 configurable: !0,
5855 writable: !0
5856 }) : e[r] = t, e;
5857 }
5858
5859
5860 /***/ }),
5861
5862 /***/ "../node_modules/@babel/runtime/helpers/esm/objectSpread2.js":
5863 /*!*******************************************************************!*\
5864 !*** ../node_modules/@babel/runtime/helpers/esm/objectSpread2.js ***!
5865 \*******************************************************************/
5866 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5867
5868 "use strict";
5869 __webpack_require__.r(__webpack_exports__);
5870 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5871 /* harmony export */ "default": () => (/* binding */ _objectSpread2)
5872 /* harmony export */ });
5873 /* harmony import */ var _defineProperty_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defineProperty.js */ "../node_modules/@babel/runtime/helpers/esm/defineProperty.js");
5874
5875 function ownKeys(e, r) {
5876 var t = Object.keys(e);
5877 if (Object.getOwnPropertySymbols) {
5878 var o = Object.getOwnPropertySymbols(e);
5879 r && (o = o.filter(function (r) {
5880 return Object.getOwnPropertyDescriptor(e, r).enumerable;
5881 })), t.push.apply(t, o);
5882 }
5883 return t;
5884 }
5885 function _objectSpread2(e) {
5886 for (var r = 1; r < arguments.length; r++) {
5887 var t = null != arguments[r] ? arguments[r] : {};
5888 r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
5889 (0,_defineProperty_js__WEBPACK_IMPORTED_MODULE_0__["default"])(e, r, t[r]);
5890 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
5891 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
5892 });
5893 }
5894 return e;
5895 }
5896
5897
5898 /***/ }),
5899
5900 /***/ "../node_modules/@babel/runtime/helpers/esm/toPrimitive.js":
5901 /*!*****************************************************************!*\
5902 !*** ../node_modules/@babel/runtime/helpers/esm/toPrimitive.js ***!
5903 \*****************************************************************/
5904 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5905
5906 "use strict";
5907 __webpack_require__.r(__webpack_exports__);
5908 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5909 /* harmony export */ "default": () => (/* binding */ toPrimitive)
5910 /* harmony export */ });
5911 /* harmony import */ var _typeof_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/esm/typeof.js");
5912
5913 function toPrimitive(t, r) {
5914 if ("object" != (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(t) || !t) return t;
5915 var e = t[Symbol.toPrimitive];
5916 if (void 0 !== e) {
5917 var i = e.call(t, r || "default");
5918 if ("object" != (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(i)) return i;
5919 throw new TypeError("@@toPrimitive must return a primitive value.");
5920 }
5921 return ("string" === r ? String : Number)(t);
5922 }
5923
5924
5925 /***/ }),
5926
5927 /***/ "../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js":
5928 /*!*******************************************************************!*\
5929 !*** ../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js ***!
5930 \*******************************************************************/
5931 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5932
5933 "use strict";
5934 __webpack_require__.r(__webpack_exports__);
5935 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5936 /* harmony export */ "default": () => (/* binding */ toPropertyKey)
5937 /* harmony export */ });
5938 /* harmony import */ var _typeof_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/esm/typeof.js");
5939 /* harmony import */ var _toPrimitive_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./toPrimitive.js */ "../node_modules/@babel/runtime/helpers/esm/toPrimitive.js");
5940
5941
5942 function toPropertyKey(t) {
5943 var i = (0,_toPrimitive_js__WEBPACK_IMPORTED_MODULE_1__["default"])(t, "string");
5944 return "symbol" == (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(i) ? i : i + "";
5945 }
5946
5947
5948 /***/ }),
5949
5950 /***/ "../node_modules/@babel/runtime/helpers/esm/typeof.js":
5951 /*!************************************************************!*\
5952 !*** ../node_modules/@babel/runtime/helpers/esm/typeof.js ***!
5953 \************************************************************/
5954 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5955
5956 "use strict";
5957 __webpack_require__.r(__webpack_exports__);
5958 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5959 /* harmony export */ "default": () => (/* binding */ _typeof)
5960 /* harmony export */ });
5961 function _typeof(o) {
5962 "@babel/helpers - typeof";
5963
5964 return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
5965 return typeof o;
5966 } : function (o) {
5967 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
5968 }, _typeof(o);
5969 }
5970
5971
5972 /***/ }),
5973
5974 /***/ "../node_modules/@babel/runtime/helpers/get.js":
5975 /*!*****************************************************!*\
5976 !*** ../node_modules/@babel/runtime/helpers/get.js ***!
5977 \*****************************************************/
5978 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5979
5980 var superPropBase = __webpack_require__(/*! ./superPropBase.js */ "../node_modules/@babel/runtime/helpers/superPropBase.js");
5981 function _get() {
5982 return module.exports = _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) {
5983 var p = superPropBase(e, t);
5984 if (p) {
5985 var n = Object.getOwnPropertyDescriptor(p, t);
5986 return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value;
5987 }
5988 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _get.apply(null, arguments);
5989 }
5990 module.exports = _get, module.exports.__esModule = true, module.exports["default"] = module.exports;
5991
5992 /***/ }),
5993
5994 /***/ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js":
5995 /*!****************************************************************!*\
5996 !*** ../node_modules/@babel/runtime/helpers/getPrototypeOf.js ***!
5997 \****************************************************************/
5998 /***/ ((module) => {
5999
6000 function _getPrototypeOf(t) {
6001 return module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
6002 return t.__proto__ || Object.getPrototypeOf(t);
6003 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _getPrototypeOf(t);
6004 }
6005 module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
6006
6007 /***/ }),
6008
6009 /***/ "../node_modules/@babel/runtime/helpers/inherits.js":
6010 /*!**********************************************************!*\
6011 !*** ../node_modules/@babel/runtime/helpers/inherits.js ***!
6012 \**********************************************************/
6013 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6014
6015 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
6016 function _inherits(t, e) {
6017 if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
6018 t.prototype = Object.create(e && e.prototype, {
6019 constructor: {
6020 value: t,
6021 writable: !0,
6022 configurable: !0
6023 }
6024 }), Object.defineProperty(t, "prototype", {
6025 writable: !1
6026 }), e && setPrototypeOf(t, e);
6027 }
6028 module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports;
6029
6030 /***/ }),
6031
6032 /***/ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js":
6033 /*!***********************************************************************!*\
6034 !*** ../node_modules/@babel/runtime/helpers/interopRequireDefault.js ***!
6035 \***********************************************************************/
6036 /***/ ((module) => {
6037
6038 function _interopRequireDefault(e) {
6039 return e && e.__esModule ? e : {
6040 "default": e
6041 };
6042 }
6043 module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
6044
6045 /***/ }),
6046
6047 /***/ "../node_modules/@babel/runtime/helpers/isNativeFunction.js":
6048 /*!******************************************************************!*\
6049 !*** ../node_modules/@babel/runtime/helpers/isNativeFunction.js ***!
6050 \******************************************************************/
6051 /***/ ((module) => {
6052
6053 function _isNativeFunction(t) {
6054 try {
6055 return -1 !== Function.toString.call(t).indexOf("[native code]");
6056 } catch (n) {
6057 return "function" == typeof t;
6058 }
6059 }
6060 module.exports = _isNativeFunction, module.exports.__esModule = true, module.exports["default"] = module.exports;
6061
6062 /***/ }),
6063
6064 /***/ "../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js":
6065 /*!**************************************************************************!*\
6066 !*** ../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js ***!
6067 \**************************************************************************/
6068 /***/ ((module) => {
6069
6070 function _isNativeReflectConstruct() {
6071 try {
6072 var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
6073 } catch (t) {}
6074 return (module.exports = _isNativeReflectConstruct = function _isNativeReflectConstruct() {
6075 return !!t;
6076 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
6077 }
6078 module.exports = _isNativeReflectConstruct, module.exports.__esModule = true, module.exports["default"] = module.exports;
6079
6080 /***/ }),
6081
6082 /***/ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js":
6083 /*!**********************************************************************!*\
6084 !*** ../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js ***!
6085 \**********************************************************************/
6086 /***/ ((module) => {
6087
6088 function _iterableToArrayLimit(r, l) {
6089 var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
6090 if (null != t) {
6091 var e,
6092 n,
6093 i,
6094 u,
6095 a = [],
6096 f = !0,
6097 o = !1;
6098 try {
6099 if (i = (t = t.call(r)).next, 0 === l) {
6100 if (Object(t) !== t) return;
6101 f = !1;
6102 } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
6103 } catch (r) {
6104 o = !0, n = r;
6105 } finally {
6106 try {
6107 if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
6108 } finally {
6109 if (o) throw n;
6110 }
6111 }
6112 return a;
6113 }
6114 }
6115 module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports;
6116
6117 /***/ }),
6118
6119 /***/ "../node_modules/@babel/runtime/helpers/nonIterableRest.js":
6120 /*!*****************************************************************!*\
6121 !*** ../node_modules/@babel/runtime/helpers/nonIterableRest.js ***!
6122 \*****************************************************************/
6123 /***/ ((module) => {
6124
6125 function _nonIterableRest() {
6126 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
6127 }
6128 module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports;
6129
6130 /***/ }),
6131
6132 /***/ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js":
6133 /*!***************************************************************************!*\
6134 !*** ../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js ***!
6135 \***************************************************************************/
6136 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6137
6138 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6139 var assertThisInitialized = __webpack_require__(/*! ./assertThisInitialized.js */ "../node_modules/@babel/runtime/helpers/assertThisInitialized.js");
6140 function _possibleConstructorReturn(t, e) {
6141 if (e && ("object" == _typeof(e) || "function" == typeof e)) return e;
6142 if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
6143 return assertThisInitialized(t);
6144 }
6145 module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
6146
6147 /***/ }),
6148
6149 /***/ "../node_modules/@babel/runtime/helpers/readOnlyError.js":
6150 /*!***************************************************************!*\
6151 !*** ../node_modules/@babel/runtime/helpers/readOnlyError.js ***!
6152 \***************************************************************/
6153 /***/ ((module) => {
6154
6155 function _readOnlyError(r) {
6156 throw new TypeError('"' + r + '" is read-only');
6157 }
6158 module.exports = _readOnlyError, module.exports.__esModule = true, module.exports["default"] = module.exports;
6159
6160 /***/ }),
6161
6162 /***/ "../node_modules/@babel/runtime/helpers/regenerator.js":
6163 /*!*************************************************************!*\
6164 !*** ../node_modules/@babel/runtime/helpers/regenerator.js ***!
6165 \*************************************************************/
6166 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6167
6168 var regeneratorDefine = __webpack_require__(/*! ./regeneratorDefine.js */ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js");
6169 function _regenerator() {
6170 /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
6171 var e,
6172 t,
6173 r = "function" == typeof Symbol ? Symbol : {},
6174 n = r.iterator || "@@iterator",
6175 o = r.toStringTag || "@@toStringTag";
6176 function i(r, n, o, i) {
6177 var c = n && n.prototype instanceof Generator ? n : Generator,
6178 u = Object.create(c.prototype);
6179 return regeneratorDefine(u, "_invoke", function (r, n, o) {
6180 var i,
6181 c,
6182 u,
6183 f = 0,
6184 p = o || [],
6185 y = !1,
6186 G = {
6187 p: 0,
6188 n: 0,
6189 v: e,
6190 a: d,
6191 f: d.bind(e, 4),
6192 d: function d(t, r) {
6193 return i = t, c = 0, u = e, G.n = r, a;
6194 }
6195 };
6196 function d(r, n) {
6197 for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
6198 var o,
6199 i = p[t],
6200 d = G.p,
6201 l = i[2];
6202 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));
6203 }
6204 if (o || r > 1) return a;
6205 throw y = !0, n;
6206 }
6207 return function (o, p, l) {
6208 if (f > 1) throw TypeError("Generator is already running");
6209 for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
6210 i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
6211 try {
6212 if (f = 2, i) {
6213 if (c || (o = "next"), t = i[o]) {
6214 if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
6215 if (!t.done) return t;
6216 u = t.value, c < 2 && (c = 0);
6217 } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
6218 i = e;
6219 } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
6220 } catch (t) {
6221 i = e, c = 1, u = t;
6222 } finally {
6223 f = 1;
6224 }
6225 }
6226 return {
6227 value: t,
6228 done: y
6229 };
6230 };
6231 }(r, o, i), !0), u;
6232 }
6233 var a = {};
6234 function Generator() {}
6235 function GeneratorFunction() {}
6236 function GeneratorFunctionPrototype() {}
6237 t = Object.getPrototypeOf;
6238 var c = [][n] ? t(t([][n]())) : (regeneratorDefine(t = {}, n, function () {
6239 return this;
6240 }), t),
6241 u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
6242 function f(e) {
6243 return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
6244 }
6245 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 () {
6246 return this;
6247 }), regeneratorDefine(u, "toString", function () {
6248 return "[object Generator]";
6249 }), (module.exports = _regenerator = function _regenerator() {
6250 return {
6251 w: i,
6252 m: f
6253 };
6254 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
6255 }
6256 module.exports = _regenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
6257
6258 /***/ }),
6259
6260 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsync.js":
6261 /*!******************************************************************!*\
6262 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsync.js ***!
6263 \******************************************************************/
6264 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6265
6266 var regeneratorAsyncGen = __webpack_require__(/*! ./regeneratorAsyncGen.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js");
6267 function _regeneratorAsync(n, e, r, t, o) {
6268 var a = regeneratorAsyncGen(n, e, r, t, o);
6269 return a.next().then(function (n) {
6270 return n.done ? n.value : a.next();
6271 });
6272 }
6273 module.exports = _regeneratorAsync, module.exports.__esModule = true, module.exports["default"] = module.exports;
6274
6275 /***/ }),
6276
6277 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js":
6278 /*!*********************************************************************!*\
6279 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js ***!
6280 \*********************************************************************/
6281 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6282
6283 var regenerator = __webpack_require__(/*! ./regenerator.js */ "../node_modules/@babel/runtime/helpers/regenerator.js");
6284 var regeneratorAsyncIterator = __webpack_require__(/*! ./regeneratorAsyncIterator.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js");
6285 function _regeneratorAsyncGen(r, e, t, o, n) {
6286 return new regeneratorAsyncIterator(regenerator().w(r, e, t, o), n || Promise);
6287 }
6288 module.exports = _regeneratorAsyncGen, module.exports.__esModule = true, module.exports["default"] = module.exports;
6289
6290 /***/ }),
6291
6292 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js":
6293 /*!**************************************************************************!*\
6294 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js ***!
6295 \**************************************************************************/
6296 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6297
6298 var OverloadYield = __webpack_require__(/*! ./OverloadYield.js */ "../node_modules/@babel/runtime/helpers/OverloadYield.js");
6299 var regeneratorDefine = __webpack_require__(/*! ./regeneratorDefine.js */ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js");
6300 function AsyncIterator(t, e) {
6301 function n(r, o, i, f) {
6302 try {
6303 var c = t[r](o),
6304 u = c.value;
6305 return u instanceof OverloadYield ? e.resolve(u.v).then(function (t) {
6306 n("next", t, i, f);
6307 }, function (t) {
6308 n("throw", t, i, f);
6309 }) : e.resolve(u).then(function (t) {
6310 c.value = t, i(c);
6311 }, function (t) {
6312 return n("throw", t, i, f);
6313 });
6314 } catch (t) {
6315 f(t);
6316 }
6317 }
6318 var r;
6319 this.next || (regeneratorDefine(AsyncIterator.prototype), regeneratorDefine(AsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () {
6320 return this;
6321 })), regeneratorDefine(this, "_invoke", function (t, o, i) {
6322 function f() {
6323 return new e(function (e, r) {
6324 n(t, i, e, r);
6325 });
6326 }
6327 return r = r ? r.then(f, f) : f();
6328 }, !0);
6329 }
6330 module.exports = AsyncIterator, module.exports.__esModule = true, module.exports["default"] = module.exports;
6331
6332 /***/ }),
6333
6334 /***/ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js":
6335 /*!*******************************************************************!*\
6336 !*** ../node_modules/@babel/runtime/helpers/regeneratorDefine.js ***!
6337 \*******************************************************************/
6338 /***/ ((module) => {
6339
6340 function _regeneratorDefine(e, r, n, t) {
6341 var i = Object.defineProperty;
6342 try {
6343 i({}, "", {});
6344 } catch (e) {
6345 i = 0;
6346 }
6347 module.exports = _regeneratorDefine = function regeneratorDefine(e, r, n, t) {
6348 function o(r, n) {
6349 _regeneratorDefine(e, r, function (e) {
6350 return this._invoke(r, n, e);
6351 });
6352 }
6353 r ? i ? i(e, r, {
6354 value: n,
6355 enumerable: !t,
6356 configurable: !t,
6357 writable: !t
6358 }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
6359 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _regeneratorDefine(e, r, n, t);
6360 }
6361 module.exports = _regeneratorDefine, module.exports.__esModule = true, module.exports["default"] = module.exports;
6362
6363 /***/ }),
6364
6365 /***/ "../node_modules/@babel/runtime/helpers/regeneratorKeys.js":
6366 /*!*****************************************************************!*\
6367 !*** ../node_modules/@babel/runtime/helpers/regeneratorKeys.js ***!
6368 \*****************************************************************/
6369 /***/ ((module) => {
6370
6371 function _regeneratorKeys(e) {
6372 var n = Object(e),
6373 r = [];
6374 for (var t in n) r.unshift(t);
6375 return function e() {
6376 for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e;
6377 return e.done = !0, e;
6378 };
6379 }
6380 module.exports = _regeneratorKeys, module.exports.__esModule = true, module.exports["default"] = module.exports;
6381
6382 /***/ }),
6383
6384 /***/ "../node_modules/@babel/runtime/helpers/regeneratorRuntime.js":
6385 /*!********************************************************************!*\
6386 !*** ../node_modules/@babel/runtime/helpers/regeneratorRuntime.js ***!
6387 \********************************************************************/
6388 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6389
6390 var OverloadYield = __webpack_require__(/*! ./OverloadYield.js */ "../node_modules/@babel/runtime/helpers/OverloadYield.js");
6391 var regenerator = __webpack_require__(/*! ./regenerator.js */ "../node_modules/@babel/runtime/helpers/regenerator.js");
6392 var regeneratorAsync = __webpack_require__(/*! ./regeneratorAsync.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsync.js");
6393 var regeneratorAsyncGen = __webpack_require__(/*! ./regeneratorAsyncGen.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js");
6394 var regeneratorAsyncIterator = __webpack_require__(/*! ./regeneratorAsyncIterator.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js");
6395 var regeneratorKeys = __webpack_require__(/*! ./regeneratorKeys.js */ "../node_modules/@babel/runtime/helpers/regeneratorKeys.js");
6396 var regeneratorValues = __webpack_require__(/*! ./regeneratorValues.js */ "../node_modules/@babel/runtime/helpers/regeneratorValues.js");
6397 function _regeneratorRuntime() {
6398 "use strict";
6399
6400 var r = regenerator(),
6401 e = r.m(_regeneratorRuntime),
6402 t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
6403 function n(r) {
6404 var e = "function" == typeof r && r.constructor;
6405 return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
6406 }
6407 var o = {
6408 "throw": 1,
6409 "return": 2,
6410 "break": 3,
6411 "continue": 3
6412 };
6413 function a(r) {
6414 var e, t;
6415 return function (n) {
6416 e || (e = {
6417 stop: function stop() {
6418 return t(n.a, 2);
6419 },
6420 "catch": function _catch() {
6421 return n.v;
6422 },
6423 abrupt: function abrupt(r, e) {
6424 return t(n.a, o[r], e);
6425 },
6426 delegateYield: function delegateYield(r, o, a) {
6427 return e.resultName = o, t(n.d, regeneratorValues(r), a);
6428 },
6429 finish: function finish(r) {
6430 return t(n.f, r);
6431 }
6432 }, t = function t(r, _t, o) {
6433 n.p = e.prev, n.n = e.next;
6434 try {
6435 return r(_t, o);
6436 } finally {
6437 e.next = n.n;
6438 }
6439 }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
6440 try {
6441 return r.call(this, e);
6442 } finally {
6443 n.p = e.prev, n.n = e.next;
6444 }
6445 };
6446 }
6447 return (module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
6448 return {
6449 wrap: function wrap(e, t, n, o) {
6450 return r.w(a(e), t, n, o && o.reverse());
6451 },
6452 isGeneratorFunction: n,
6453 mark: r.m,
6454 awrap: function awrap(r, e) {
6455 return new OverloadYield(r, e);
6456 },
6457 AsyncIterator: regeneratorAsyncIterator,
6458 async: function async(r, e, t, o, u) {
6459 return (n(e) ? regeneratorAsyncGen : regeneratorAsync)(a(r), e, t, o, u);
6460 },
6461 keys: regeneratorKeys,
6462 values: regeneratorValues
6463 };
6464 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
6465 }
6466 module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
6467
6468 /***/ }),
6469
6470 /***/ "../node_modules/@babel/runtime/helpers/regeneratorValues.js":
6471 /*!*******************************************************************!*\
6472 !*** ../node_modules/@babel/runtime/helpers/regeneratorValues.js ***!
6473 \*******************************************************************/
6474 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6475
6476 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6477 function _regeneratorValues(e) {
6478 if (null != e) {
6479 var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
6480 r = 0;
6481 if (t) return t.call(e);
6482 if ("function" == typeof e.next) return e;
6483 if (!isNaN(e.length)) return {
6484 next: function next() {
6485 return e && r >= e.length && (e = void 0), {
6486 value: e && e[r++],
6487 done: !e
6488 };
6489 }
6490 };
6491 }
6492 throw new TypeError(_typeof(e) + " is not iterable");
6493 }
6494 module.exports = _regeneratorValues, module.exports.__esModule = true, module.exports["default"] = module.exports;
6495
6496 /***/ }),
6497
6498 /***/ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js":
6499 /*!****************************************************************!*\
6500 !*** ../node_modules/@babel/runtime/helpers/setPrototypeOf.js ***!
6501 \****************************************************************/
6502 /***/ ((module) => {
6503
6504 function _setPrototypeOf(t, e) {
6505 return module.exports = _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
6506 return t.__proto__ = e, t;
6507 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _setPrototypeOf(t, e);
6508 }
6509 module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
6510
6511 /***/ }),
6512
6513 /***/ "../node_modules/@babel/runtime/helpers/slicedToArray.js":
6514 /*!***************************************************************!*\
6515 !*** ../node_modules/@babel/runtime/helpers/slicedToArray.js ***!
6516 \***************************************************************/
6517 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6518
6519 var arrayWithHoles = __webpack_require__(/*! ./arrayWithHoles.js */ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js");
6520 var iterableToArrayLimit = __webpack_require__(/*! ./iterableToArrayLimit.js */ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js");
6521 var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray.js */ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js");
6522 var nonIterableRest = __webpack_require__(/*! ./nonIterableRest.js */ "../node_modules/@babel/runtime/helpers/nonIterableRest.js");
6523 function _slicedToArray(r, e) {
6524 return arrayWithHoles(r) || iterableToArrayLimit(r, e) || unsupportedIterableToArray(r, e) || nonIterableRest();
6525 }
6526 module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
6527
6528 /***/ }),
6529
6530 /***/ "../node_modules/@babel/runtime/helpers/superPropBase.js":
6531 /*!***************************************************************!*\
6532 !*** ../node_modules/@babel/runtime/helpers/superPropBase.js ***!
6533 \***************************************************************/
6534 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6535
6536 var getPrototypeOf = __webpack_require__(/*! ./getPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js");
6537 function _superPropBase(t, o) {
6538 for (; !{}.hasOwnProperty.call(t, o) && null !== (t = getPrototypeOf(t)););
6539 return t;
6540 }
6541 module.exports = _superPropBase, module.exports.__esModule = true, module.exports["default"] = module.exports;
6542
6543 /***/ }),
6544
6545 /***/ "../node_modules/@babel/runtime/helpers/toPrimitive.js":
6546 /*!*************************************************************!*\
6547 !*** ../node_modules/@babel/runtime/helpers/toPrimitive.js ***!
6548 \*************************************************************/
6549 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6550
6551 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6552 function toPrimitive(t, r) {
6553 if ("object" != _typeof(t) || !t) return t;
6554 var e = t[Symbol.toPrimitive];
6555 if (void 0 !== e) {
6556 var i = e.call(t, r || "default");
6557 if ("object" != _typeof(i)) return i;
6558 throw new TypeError("@@toPrimitive must return a primitive value.");
6559 }
6560 return ("string" === r ? String : Number)(t);
6561 }
6562 module.exports = toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
6563
6564 /***/ }),
6565
6566 /***/ "../node_modules/@babel/runtime/helpers/toPropertyKey.js":
6567 /*!***************************************************************!*\
6568 !*** ../node_modules/@babel/runtime/helpers/toPropertyKey.js ***!
6569 \***************************************************************/
6570 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6571
6572 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6573 var toPrimitive = __webpack_require__(/*! ./toPrimitive.js */ "../node_modules/@babel/runtime/helpers/toPrimitive.js");
6574 function toPropertyKey(t) {
6575 var i = toPrimitive(t, "string");
6576 return "symbol" == _typeof(i) ? i : i + "";
6577 }
6578 module.exports = toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
6579
6580 /***/ }),
6581
6582 /***/ "../node_modules/@babel/runtime/helpers/typeof.js":
6583 /*!********************************************************!*\
6584 !*** ../node_modules/@babel/runtime/helpers/typeof.js ***!
6585 \********************************************************/
6586 /***/ ((module) => {
6587
6588 function _typeof(o) {
6589 "@babel/helpers - typeof";
6590
6591 return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
6592 return typeof o;
6593 } : function (o) {
6594 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
6595 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
6596 }
6597 module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
6598
6599 /***/ }),
6600
6601 /***/ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js":
6602 /*!****************************************************************************!*\
6603 !*** ../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js ***!
6604 \****************************************************************************/
6605 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6606
6607 var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray.js */ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js");
6608 function _unsupportedIterableToArray(r, a) {
6609 if (r) {
6610 if ("string" == typeof r) return arrayLikeToArray(r, a);
6611 var t = {}.toString.call(r).slice(8, -1);
6612 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;
6613 }
6614 }
6615 module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
6616
6617 /***/ }),
6618
6619 /***/ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js":
6620 /*!*****************************************************************!*\
6621 !*** ../node_modules/@babel/runtime/helpers/wrapNativeSuper.js ***!
6622 \*****************************************************************/
6623 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6624
6625 var getPrototypeOf = __webpack_require__(/*! ./getPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js");
6626 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
6627 var isNativeFunction = __webpack_require__(/*! ./isNativeFunction.js */ "../node_modules/@babel/runtime/helpers/isNativeFunction.js");
6628 var construct = __webpack_require__(/*! ./construct.js */ "../node_modules/@babel/runtime/helpers/construct.js");
6629 function _wrapNativeSuper(t) {
6630 var r = "function" == typeof Map ? new Map() : void 0;
6631 return module.exports = _wrapNativeSuper = function _wrapNativeSuper(t) {
6632 if (null === t || !isNativeFunction(t)) return t;
6633 if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
6634 if (void 0 !== r) {
6635 if (r.has(t)) return r.get(t);
6636 r.set(t, Wrapper);
6637 }
6638 function Wrapper() {
6639 return construct(t, arguments, getPrototypeOf(this).constructor);
6640 }
6641 return Wrapper.prototype = Object.create(t.prototype, {
6642 constructor: {
6643 value: Wrapper,
6644 enumerable: !1,
6645 writable: !0,
6646 configurable: !0
6647 }
6648 }), setPrototypeOf(Wrapper, t);
6649 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _wrapNativeSuper(t);
6650 }
6651 module.exports = _wrapNativeSuper, module.exports.__esModule = true, module.exports["default"] = module.exports;
6652
6653 /***/ }),
6654
6655 /***/ "../node_modules/@babel/runtime/regenerator/index.js":
6656 /*!***********************************************************!*\
6657 !*** ../node_modules/@babel/runtime/regenerator/index.js ***!
6658 \***********************************************************/
6659 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6660
6661 // TODO(Babel 8): Remove this file.
6662
6663 var runtime = __webpack_require__(/*! ../helpers/regeneratorRuntime */ "../node_modules/@babel/runtime/helpers/regeneratorRuntime.js")();
6664 module.exports = runtime;
6665
6666 // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
6667 try {
6668 regeneratorRuntime = runtime;
6669 } catch (accidentalStrictMode) {
6670 if (typeof globalThis === "object") {
6671 globalThis.regeneratorRuntime = runtime;
6672 } else {
6673 Function("r", "regeneratorRuntime = r")(runtime);
6674 }
6675 }
6676
6677
6678 /***/ }),
6679
6680 /***/ "../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js":
6681 /*!******************************************************************!*\
6682 !*** ../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js ***!
6683 \******************************************************************/
6684 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
6685
6686 "use strict";
6687 __webpack_require__.r(__webpack_exports__);
6688 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
6689 /* harmony export */ EnhancerArray: () => (/* binding */ EnhancerArray),
6690 /* harmony export */ MiddlewareArray: () => (/* binding */ MiddlewareArray),
6691 /* harmony export */ SHOULD_AUTOBATCH: () => (/* binding */ SHOULD_AUTOBATCH),
6692 /* harmony export */ TaskAbortError: () => (/* binding */ TaskAbortError),
6693 /* harmony export */ __DO_NOT_USE__ActionTypes: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.__DO_NOT_USE__ActionTypes),
6694 /* harmony export */ addListener: () => (/* binding */ addListener),
6695 /* harmony export */ applyMiddleware: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.applyMiddleware),
6696 /* harmony export */ autoBatchEnhancer: () => (/* binding */ autoBatchEnhancer),
6697 /* harmony export */ bindActionCreators: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.bindActionCreators),
6698 /* harmony export */ clearAllListeners: () => (/* binding */ clearAllListeners),
6699 /* harmony export */ combineReducers: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.combineReducers),
6700 /* harmony export */ compose: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.compose),
6701 /* harmony export */ configureStore: () => (/* binding */ configureStore),
6702 /* harmony export */ createAction: () => (/* binding */ createAction),
6703 /* harmony export */ createActionCreatorInvariantMiddleware: () => (/* binding */ createActionCreatorInvariantMiddleware),
6704 /* harmony export */ createAsyncThunk: () => (/* binding */ createAsyncThunk),
6705 /* harmony export */ createDraftSafeSelector: () => (/* binding */ createDraftSafeSelector),
6706 /* harmony export */ createEntityAdapter: () => (/* binding */ createEntityAdapter),
6707 /* harmony export */ createImmutableStateInvariantMiddleware: () => (/* binding */ createImmutableStateInvariantMiddleware),
6708 /* harmony export */ createListenerMiddleware: () => (/* binding */ createListenerMiddleware),
6709 /* harmony export */ createNextState: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__["default"]),
6710 /* harmony export */ createReducer: () => (/* binding */ createReducer),
6711 /* harmony export */ createSelector: () => (/* reexport safe */ reselect__WEBPACK_IMPORTED_MODULE_2__.createSelector),
6712 /* harmony export */ createSerializableStateInvariantMiddleware: () => (/* binding */ createSerializableStateInvariantMiddleware),
6713 /* harmony export */ createSlice: () => (/* binding */ createSlice),
6714 /* harmony export */ createStore: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.createStore),
6715 /* harmony export */ current: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.current),
6716 /* harmony export */ findNonSerializableValue: () => (/* binding */ findNonSerializableValue),
6717 /* harmony export */ freeze: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.freeze),
6718 /* harmony export */ getDefaultMiddleware: () => (/* binding */ getDefaultMiddleware),
6719 /* harmony export */ getType: () => (/* binding */ getType),
6720 /* harmony export */ isAction: () => (/* binding */ isAction),
6721 /* harmony export */ isActionCreator: () => (/* binding */ isActionCreator),
6722 /* harmony export */ isAllOf: () => (/* binding */ isAllOf),
6723 /* harmony export */ isAnyOf: () => (/* binding */ isAnyOf),
6724 /* harmony export */ isAsyncThunkAction: () => (/* binding */ isAsyncThunkAction),
6725 /* harmony export */ isDraft: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.isDraft),
6726 /* harmony export */ isFluxStandardAction: () => (/* binding */ isFSA),
6727 /* harmony export */ isFulfilled: () => (/* binding */ isFulfilled),
6728 /* harmony export */ isImmutableDefault: () => (/* binding */ isImmutableDefault),
6729 /* harmony export */ isPending: () => (/* binding */ isPending),
6730 /* harmony export */ isPlain: () => (/* binding */ isPlain),
6731 /* harmony export */ isPlainObject: () => (/* binding */ isPlainObject),
6732 /* harmony export */ isRejected: () => (/* binding */ isRejected),
6733 /* harmony export */ isRejectedWithValue: () => (/* binding */ isRejectedWithValue),
6734 /* harmony export */ legacy_createStore: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.legacy_createStore),
6735 /* harmony export */ miniSerializeError: () => (/* binding */ miniSerializeError),
6736 /* harmony export */ nanoid: () => (/* binding */ nanoid),
6737 /* harmony export */ original: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.original),
6738 /* harmony export */ prepareAutoBatched: () => (/* binding */ prepareAutoBatched),
6739 /* harmony export */ removeListener: () => (/* binding */ removeListener),
6740 /* harmony export */ unwrapResult: () => (/* binding */ unwrapResult)
6741 /* harmony export */ });
6742 /* harmony import */ var immer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! immer */ "../node_modules/immer/dist/immer.esm.mjs");
6743 /* harmony import */ var redux__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! redux */ "../node_modules/redux/es/redux.js");
6744 /* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! reselect */ "../node_modules/reselect/es/index.js");
6745 /* harmony import */ var redux_thunk__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! redux-thunk */ "../node_modules/redux-thunk/es/index.js");
6746 var __extends = (undefined && undefined.__extends) || (function () {
6747 var extendStatics = function (d, b) {
6748 extendStatics = Object.setPrototypeOf ||
6749 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6750 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6751 return extendStatics(d, b);
6752 };
6753 return function (d, b) {
6754 if (typeof b !== "function" && b !== null)
6755 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
6756 extendStatics(d, b);
6757 function __() { this.constructor = d; }
6758 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6759 };
6760 })();
6761 var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
6762 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
6763 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
6764 function verb(n) { return function (v) { return step([n, v]); }; }
6765 function step(op) {
6766 if (f) throw new TypeError("Generator is already executing.");
6767 while (_) try {
6768 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;
6769 if (y = 0, t) op = [op[0] & 2, t.value];
6770 switch (op[0]) {
6771 case 0: case 1: t = op; break;
6772 case 4: _.label++; return { value: op[1], done: false };
6773 case 5: _.label++; y = op[1]; op = [0]; continue;
6774 case 7: op = _.ops.pop(); _.trys.pop(); continue;
6775 default:
6776 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
6777 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
6778 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
6779 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
6780 if (t[2]) _.ops.pop();
6781 _.trys.pop(); continue;
6782 }
6783 op = body.call(thisArg, _);
6784 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
6785 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
6786 }
6787 };
6788 var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
6789 for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
6790 to[j] = from[i];
6791 return to;
6792 };
6793 var __defProp = Object.defineProperty;
6794 var __defProps = Object.defineProperties;
6795 var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6796 var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6797 var __hasOwnProp = Object.prototype.hasOwnProperty;
6798 var __propIsEnum = Object.prototype.propertyIsEnumerable;
6799 var __defNormalProp = function (obj, key, value) { return key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value }) : obj[key] = value; };
6800 var __spreadValues = function (a, b) {
6801 for (var prop in b || (b = {}))
6802 if (__hasOwnProp.call(b, prop))
6803 __defNormalProp(a, prop, b[prop]);
6804 if (__getOwnPropSymbols)
6805 for (var _i = 0, _c = __getOwnPropSymbols(b); _i < _c.length; _i++) {
6806 var prop = _c[_i];
6807 if (__propIsEnum.call(b, prop))
6808 __defNormalProp(a, prop, b[prop]);
6809 }
6810 return a;
6811 };
6812 var __spreadProps = function (a, b) { return __defProps(a, __getOwnPropDescs(b)); };
6813 var __async = function (__this, __arguments, generator) {
6814 return new Promise(function (resolve, reject) {
6815 var fulfilled = function (value) {
6816 try {
6817 step(generator.next(value));
6818 }
6819 catch (e) {
6820 reject(e);
6821 }
6822 };
6823 var rejected = function (value) {
6824 try {
6825 step(generator.throw(value));
6826 }
6827 catch (e) {
6828 reject(e);
6829 }
6830 };
6831 var step = function (x) { return x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); };
6832 step((generator = generator.apply(__this, __arguments)).next());
6833 });
6834 };
6835 // src/index.ts
6836
6837
6838
6839
6840 // src/createDraftSafeSelector.ts
6841
6842
6843 var createDraftSafeSelector = function () {
6844 var args = [];
6845 for (var _i = 0; _i < arguments.length; _i++) {
6846 args[_i] = arguments[_i];
6847 }
6848 var selector = reselect__WEBPACK_IMPORTED_MODULE_2__.createSelector.apply(void 0, args);
6849 var wrappedSelector = function (value) {
6850 var rest = [];
6851 for (var _i = 1; _i < arguments.length; _i++) {
6852 rest[_i - 1] = arguments[_i];
6853 }
6854 return selector.apply(void 0, __spreadArray([(0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(value) ? (0,immer__WEBPACK_IMPORTED_MODULE_0__.current)(value) : value], rest));
6855 };
6856 return wrappedSelector;
6857 };
6858 // src/configureStore.ts
6859
6860 // src/devtoolsExtension.ts
6861
6862 var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function () {
6863 if (arguments.length === 0)
6864 return void 0;
6865 if (typeof arguments[0] === "object")
6866 return redux__WEBPACK_IMPORTED_MODULE_1__.compose;
6867 return redux__WEBPACK_IMPORTED_MODULE_1__.compose.apply(null, arguments);
6868 };
6869 var devToolsEnhancer = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__ : function () {
6870 return function (noop2) {
6871 return noop2;
6872 };
6873 };
6874 // src/isPlainObject.ts
6875 function isPlainObject(value) {
6876 if (typeof value !== "object" || value === null)
6877 return false;
6878 var proto = Object.getPrototypeOf(value);
6879 if (proto === null)
6880 return true;
6881 var baseProto = proto;
6882 while (Object.getPrototypeOf(baseProto) !== null) {
6883 baseProto = Object.getPrototypeOf(baseProto);
6884 }
6885 return proto === baseProto;
6886 }
6887 // src/getDefaultMiddleware.ts
6888
6889 // src/tsHelpers.ts
6890 var hasMatchFunction = function (v) {
6891 return v && typeof v.match === "function";
6892 };
6893 // src/createAction.ts
6894 function createAction(type, prepareAction) {
6895 function actionCreator() {
6896 var args = [];
6897 for (var _i = 0; _i < arguments.length; _i++) {
6898 args[_i] = arguments[_i];
6899 }
6900 if (prepareAction) {
6901 var prepared = prepareAction.apply(void 0, args);
6902 if (!prepared) {
6903 throw new Error("prepareAction did not return an object");
6904 }
6905 return __spreadValues(__spreadValues({
6906 type: type,
6907 payload: prepared.payload
6908 }, "meta" in prepared && { meta: prepared.meta }), "error" in prepared && { error: prepared.error });
6909 }
6910 return { type: type, payload: args[0] };
6911 }
6912 actionCreator.toString = function () { return "" + type; };
6913 actionCreator.type = type;
6914 actionCreator.match = function (action) { return action.type === type; };
6915 return actionCreator;
6916 }
6917 function isAction(action) {
6918 return isPlainObject(action) && "type" in action;
6919 }
6920 function isActionCreator(action) {
6921 return typeof action === "function" && "type" in action && hasMatchFunction(action);
6922 }
6923 function isFSA(action) {
6924 return isAction(action) && typeof action.type === "string" && Object.keys(action).every(isValidKey);
6925 }
6926 function isValidKey(key) {
6927 return ["type", "payload", "error", "meta"].indexOf(key) > -1;
6928 }
6929 function getType(actionCreator) {
6930 return "" + actionCreator;
6931 }
6932 // src/actionCreatorInvariantMiddleware.ts
6933 function getMessage(type) {
6934 var splitType = type ? ("" + type).split("/") : [];
6935 var actionName = splitType[splitType.length - 1] || "actionCreator";
6936 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.";
6937 }
6938 function createActionCreatorInvariantMiddleware(options) {
6939 if (options === void 0) { options = {}; }
6940 if (false) // removed by dead control flow
6941 {}
6942 var _c = options.isActionCreator, isActionCreator2 = _c === void 0 ? isActionCreator : _c;
6943 return function () { return function (next) { return function (action) {
6944 if (isActionCreator2(action)) {
6945 console.warn(getMessage(action.type));
6946 }
6947 return next(action);
6948 }; }; };
6949 }
6950 // src/utils.ts
6951
6952 function getTimeMeasureUtils(maxDelay, fnName) {
6953 var elapsed = 0;
6954 return {
6955 measureTime: function (fn) {
6956 var started = Date.now();
6957 try {
6958 return fn();
6959 }
6960 finally {
6961 var finished = Date.now();
6962 elapsed += finished - started;
6963 }
6964 },
6965 warnIfExceeded: function () {
6966 if (elapsed > maxDelay) {
6967 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.");
6968 }
6969 }
6970 };
6971 }
6972 var MiddlewareArray = /** @class */ (function (_super) {
6973 __extends(MiddlewareArray, _super);
6974 function MiddlewareArray() {
6975 var args = [];
6976 for (var _i = 0; _i < arguments.length; _i++) {
6977 args[_i] = arguments[_i];
6978 }
6979 var _this = _super.apply(this, args) || this;
6980 Object.setPrototypeOf(_this, MiddlewareArray.prototype);
6981 return _this;
6982 }
6983 Object.defineProperty(MiddlewareArray, Symbol.species, {
6984 get: function () {
6985 return MiddlewareArray;
6986 },
6987 enumerable: false,
6988 configurable: true
6989 });
6990 MiddlewareArray.prototype.concat = function () {
6991 var arr = [];
6992 for (var _i = 0; _i < arguments.length; _i++) {
6993 arr[_i] = arguments[_i];
6994 }
6995 return _super.prototype.concat.apply(this, arr);
6996 };
6997 MiddlewareArray.prototype.prepend = function () {
6998 var arr = [];
6999 for (var _i = 0; _i < arguments.length; _i++) {
7000 arr[_i] = arguments[_i];
7001 }
7002 if (arr.length === 1 && Array.isArray(arr[0])) {
7003 return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr[0].concat(this))))();
7004 }
7005 return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr.concat(this))))();
7006 };
7007 return MiddlewareArray;
7008 }(Array));
7009 var EnhancerArray = /** @class */ (function (_super) {
7010 __extends(EnhancerArray, _super);
7011 function EnhancerArray() {
7012 var args = [];
7013 for (var _i = 0; _i < arguments.length; _i++) {
7014 args[_i] = arguments[_i];
7015 }
7016 var _this = _super.apply(this, args) || this;
7017 Object.setPrototypeOf(_this, EnhancerArray.prototype);
7018 return _this;
7019 }
7020 Object.defineProperty(EnhancerArray, Symbol.species, {
7021 get: function () {
7022 return EnhancerArray;
7023 },
7024 enumerable: false,
7025 configurable: true
7026 });
7027 EnhancerArray.prototype.concat = function () {
7028 var arr = [];
7029 for (var _i = 0; _i < arguments.length; _i++) {
7030 arr[_i] = arguments[_i];
7031 }
7032 return _super.prototype.concat.apply(this, arr);
7033 };
7034 EnhancerArray.prototype.prepend = function () {
7035 var arr = [];
7036 for (var _i = 0; _i < arguments.length; _i++) {
7037 arr[_i] = arguments[_i];
7038 }
7039 if (arr.length === 1 && Array.isArray(arr[0])) {
7040 return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr[0].concat(this))))();
7041 }
7042 return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr.concat(this))))();
7043 };
7044 return EnhancerArray;
7045 }(Array));
7046 function freezeDraftable(val) {
7047 return (0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraftable)(val) ? (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(val, function () {
7048 }) : val;
7049 }
7050 // src/immutableStateInvariantMiddleware.ts
7051 var isProduction = "development" === "production";
7052 var prefix = "Invariant failed";
7053 function invariant(condition, message) {
7054 if (condition) {
7055 return;
7056 }
7057 if (isProduction) {
7058 throw new Error(prefix);
7059 }
7060 throw new Error(prefix + ": " + (message || ""));
7061 }
7062 function stringify(obj, serializer, indent, decycler) {
7063 return JSON.stringify(obj, getSerialize(serializer, decycler), indent);
7064 }
7065 function getSerialize(serializer, decycler) {
7066 var stack = [], keys = [];
7067 if (!decycler)
7068 decycler = function (_, value) {
7069 if (stack[0] === value)
7070 return "[Circular ~]";
7071 return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
7072 };
7073 return function (key, value) {
7074 if (stack.length > 0) {
7075 var thisPos = stack.indexOf(this);
7076 ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
7077 ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
7078 if (~stack.indexOf(value))
7079 value = decycler.call(this, key, value);
7080 }
7081 else
7082 stack.push(value);
7083 return serializer == null ? value : serializer.call(this, key, value);
7084 };
7085 }
7086 function isImmutableDefault(value) {
7087 return typeof value !== "object" || value == null || Object.isFrozen(value);
7088 }
7089 function trackForMutations(isImmutable, ignorePaths, obj) {
7090 var trackedProperties = trackProperties(isImmutable, ignorePaths, obj);
7091 return {
7092 detectMutations: function () {
7093 return detectMutations(isImmutable, ignorePaths, trackedProperties, obj);
7094 }
7095 };
7096 }
7097 function trackProperties(isImmutable, ignorePaths, obj, path, checkedObjects) {
7098 if (ignorePaths === void 0) { ignorePaths = []; }
7099 if (path === void 0) { path = ""; }
7100 if (checkedObjects === void 0) { checkedObjects = new Set(); }
7101 var tracked = { value: obj };
7102 if (!isImmutable(obj) && !checkedObjects.has(obj)) {
7103 checkedObjects.add(obj);
7104 tracked.children = {};
7105 for (var key in obj) {
7106 var childPath = path ? path + "." + key : key;
7107 if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
7108 continue;
7109 }
7110 tracked.children[key] = trackProperties(isImmutable, ignorePaths, obj[key], childPath);
7111 }
7112 }
7113 return tracked;
7114 }
7115 function detectMutations(isImmutable, ignoredPaths, trackedProperty, obj, sameParentRef, path) {
7116 if (ignoredPaths === void 0) { ignoredPaths = []; }
7117 if (sameParentRef === void 0) { sameParentRef = false; }
7118 if (path === void 0) { path = ""; }
7119 var prevObj = trackedProperty ? trackedProperty.value : void 0;
7120 var sameRef = prevObj === obj;
7121 if (sameParentRef && !sameRef && !Number.isNaN(obj)) {
7122 return { wasMutated: true, path: path };
7123 }
7124 if (isImmutable(prevObj) || isImmutable(obj)) {
7125 return { wasMutated: false };
7126 }
7127 var keysToDetect = {};
7128 for (var key in trackedProperty.children) {
7129 keysToDetect[key] = true;
7130 }
7131 for (var key in obj) {
7132 keysToDetect[key] = true;
7133 }
7134 var hasIgnoredPaths = ignoredPaths.length > 0;
7135 var _loop_1 = function (key) {
7136 var nestedPath = path ? path + "." + key : key;
7137 if (hasIgnoredPaths) {
7138 var hasMatches = ignoredPaths.some(function (ignored) {
7139 if (ignored instanceof RegExp) {
7140 return ignored.test(nestedPath);
7141 }
7142 return nestedPath === ignored;
7143 });
7144 if (hasMatches) {
7145 return "continue";
7146 }
7147 }
7148 var result = detectMutations(isImmutable, ignoredPaths, trackedProperty.children[key], obj[key], sameRef, nestedPath);
7149 if (result.wasMutated) {
7150 return { value: result };
7151 }
7152 };
7153 for (var key in keysToDetect) {
7154 var state_1 = _loop_1(key);
7155 if (typeof state_1 === "object")
7156 return state_1.value;
7157 }
7158 return { wasMutated: false };
7159 }
7160 function createImmutableStateInvariantMiddleware(options) {
7161 if (options === void 0) { options = {}; }
7162 if (false) // removed by dead control flow
7163 {}
7164 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;
7165 ignoredPaths = ignoredPaths || ignore;
7166 var track = trackForMutations.bind(null, isImmutable, ignoredPaths);
7167 return function (_c) {
7168 var getState = _c.getState;
7169 var state = getState();
7170 var tracker = track(state);
7171 var result;
7172 return function (next) { return function (action) {
7173 var measureUtils = getTimeMeasureUtils(warnAfter, "ImmutableStateInvariantMiddleware");
7174 measureUtils.measureTime(function () {
7175 state = getState();
7176 result = tracker.detectMutations();
7177 tracker = track(state);
7178 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)");
7179 });
7180 var dispatchedAction = next(action);
7181 measureUtils.measureTime(function () {
7182 state = getState();
7183 result = tracker.detectMutations();
7184 tracker = track(state);
7185 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)");
7186 });
7187 measureUtils.warnIfExceeded();
7188 return dispatchedAction;
7189 }; };
7190 };
7191 }
7192 // src/serializableStateInvariantMiddleware.ts
7193 function isPlain(val) {
7194 var type = typeof val;
7195 return val == null || type === "string" || type === "boolean" || type === "number" || Array.isArray(val) || isPlainObject(val);
7196 }
7197 function findNonSerializableValue(value, path, isSerializable, getEntries, ignoredPaths, cache) {
7198 if (path === void 0) { path = ""; }
7199 if (isSerializable === void 0) { isSerializable = isPlain; }
7200 if (ignoredPaths === void 0) { ignoredPaths = []; }
7201 var foundNestedSerializable;
7202 if (!isSerializable(value)) {
7203 return {
7204 keyPath: path || "<root>",
7205 value: value
7206 };
7207 }
7208 if (typeof value !== "object" || value === null) {
7209 return false;
7210 }
7211 if (cache == null ? void 0 : cache.has(value))
7212 return false;
7213 var entries = getEntries != null ? getEntries(value) : Object.entries(value);
7214 var hasIgnoredPaths = ignoredPaths.length > 0;
7215 var _loop_2 = function (key, nestedValue) {
7216 var nestedPath = path ? path + "." + key : key;
7217 if (hasIgnoredPaths) {
7218 var hasMatches = ignoredPaths.some(function (ignored) {
7219 if (ignored instanceof RegExp) {
7220 return ignored.test(nestedPath);
7221 }
7222 return nestedPath === ignored;
7223 });
7224 if (hasMatches) {
7225 return "continue";
7226 }
7227 }
7228 if (!isSerializable(nestedValue)) {
7229 return { value: {
7230 keyPath: nestedPath,
7231 value: nestedValue
7232 } };
7233 }
7234 if (typeof nestedValue === "object") {
7235 foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths, cache);
7236 if (foundNestedSerializable) {
7237 return { value: foundNestedSerializable };
7238 }
7239 }
7240 };
7241 for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
7242 var _c = entries_1[_i], key = _c[0], nestedValue = _c[1];
7243 var state_2 = _loop_2(key, nestedValue);
7244 if (typeof state_2 === "object")
7245 return state_2.value;
7246 }
7247 if (cache && isNestedFrozen(value))
7248 cache.add(value);
7249 return false;
7250 }
7251 function isNestedFrozen(value) {
7252 if (!Object.isFrozen(value))
7253 return false;
7254 for (var _i = 0, _c = Object.values(value); _i < _c.length; _i++) {
7255 var nestedValue = _c[_i];
7256 if (typeof nestedValue !== "object" || nestedValue === null)
7257 continue;
7258 if (!isNestedFrozen(nestedValue))
7259 return false;
7260 }
7261 return true;
7262 }
7263 function createSerializableStateInvariantMiddleware(options) {
7264 if (options === void 0) { options = {}; }
7265 if (false) // removed by dead control flow
7266 {}
7267 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;
7268 var cache = !disableCache && WeakSet ? new WeakSet() : void 0;
7269 return function (storeAPI) { return function (next) { return function (action) {
7270 var result = next(action);
7271 var measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware");
7272 if (!ignoreActions && !(ignoredActions.length && ignoredActions.indexOf(action.type) !== -1)) {
7273 measureUtils.measureTime(function () {
7274 var foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths, cache);
7275 if (foundActionNonSerializableValue) {
7276 var keyPath = foundActionNonSerializableValue.keyPath, value = foundActionNonSerializableValue.value;
7277 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)");
7278 }
7279 });
7280 }
7281 if (!ignoreState) {
7282 measureUtils.measureTime(function () {
7283 var state = storeAPI.getState();
7284 var foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths, cache);
7285 if (foundStateNonSerializableValue) {
7286 var keyPath = foundStateNonSerializableValue.keyPath, value = foundStateNonSerializableValue.value;
7287 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)");
7288 }
7289 });
7290 measureUtils.warnIfExceeded();
7291 }
7292 return result;
7293 }; }; };
7294 }
7295 // src/getDefaultMiddleware.ts
7296 function isBoolean(x) {
7297 return typeof x === "boolean";
7298 }
7299 function curryGetDefaultMiddleware() {
7300 return function curriedGetDefaultMiddleware(options) {
7301 return getDefaultMiddleware(options);
7302 };
7303 }
7304 function getDefaultMiddleware(options) {
7305 if (options === void 0) { options = {}; }
7306 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;
7307 var middlewareArray = new MiddlewareArray();
7308 if (thunk) {
7309 if (isBoolean(thunk)) {
7310 middlewareArray.push(redux_thunk__WEBPACK_IMPORTED_MODULE_3__["default"]);
7311 }
7312 else {
7313 middlewareArray.push(redux_thunk__WEBPACK_IMPORTED_MODULE_3__["default"].withExtraArgument(thunk.extraArgument));
7314 }
7315 }
7316 if (true) {
7317 if (immutableCheck) {
7318 var immutableOptions = {};
7319 if (!isBoolean(immutableCheck)) {
7320 immutableOptions = immutableCheck;
7321 }
7322 middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));
7323 }
7324 if (serializableCheck) {
7325 var serializableOptions = {};
7326 if (!isBoolean(serializableCheck)) {
7327 serializableOptions = serializableCheck;
7328 }
7329 middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions));
7330 }
7331 if (actionCreatorCheck) {
7332 var actionCreatorOptions = {};
7333 if (!isBoolean(actionCreatorCheck)) {
7334 actionCreatorOptions = actionCreatorCheck;
7335 }
7336 middlewareArray.unshift(createActionCreatorInvariantMiddleware(actionCreatorOptions));
7337 }
7338 }
7339 return middlewareArray;
7340 }
7341 // src/configureStore.ts
7342 var IS_PRODUCTION = "development" === "production";
7343 function configureStore(options) {
7344 var curriedGetDefaultMiddleware = curryGetDefaultMiddleware();
7345 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;
7346 var rootReducer;
7347 if (typeof reducer === "function") {
7348 rootReducer = reducer;
7349 }
7350 else if (isPlainObject(reducer)) {
7351 rootReducer = (0,redux__WEBPACK_IMPORTED_MODULE_1__.combineReducers)(reducer);
7352 }
7353 else {
7354 throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');
7355 }
7356 var finalMiddleware = middleware;
7357 if (typeof finalMiddleware === "function") {
7358 finalMiddleware = finalMiddleware(curriedGetDefaultMiddleware);
7359 if (!IS_PRODUCTION && !Array.isArray(finalMiddleware)) {
7360 throw new Error("when using a middleware builder function, an array of middleware must be returned");
7361 }
7362 }
7363 if (!IS_PRODUCTION && finalMiddleware.some(function (item) { return typeof item !== "function"; })) {
7364 throw new Error("each middleware provided to configureStore must be a function");
7365 }
7366 var middlewareEnhancer = redux__WEBPACK_IMPORTED_MODULE_1__.applyMiddleware.apply(void 0, finalMiddleware);
7367 var finalCompose = redux__WEBPACK_IMPORTED_MODULE_1__.compose;
7368 if (devTools) {
7369 finalCompose = composeWithDevTools(__spreadValues({
7370 trace: !IS_PRODUCTION
7371 }, typeof devTools === "object" && devTools));
7372 }
7373 var defaultEnhancers = new EnhancerArray(middlewareEnhancer);
7374 var storeEnhancers = defaultEnhancers;
7375 if (Array.isArray(enhancers)) {
7376 storeEnhancers = __spreadArray([middlewareEnhancer], enhancers);
7377 }
7378 else if (typeof enhancers === "function") {
7379 storeEnhancers = enhancers(defaultEnhancers);
7380 }
7381 var composedEnhancer = finalCompose.apply(void 0, storeEnhancers);
7382 return (0,redux__WEBPACK_IMPORTED_MODULE_1__.createStore)(rootReducer, preloadedState, composedEnhancer);
7383 }
7384 // src/createReducer.ts
7385
7386 // src/mapBuilders.ts
7387 function executeReducerBuilderCallback(builderCallback) {
7388 var actionsMap = {};
7389 var actionMatchers = [];
7390 var defaultCaseReducer;
7391 var builder = {
7392 addCase: function (typeOrActionCreator, reducer) {
7393 if (true) {
7394 if (actionMatchers.length > 0) {
7395 throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");
7396 }
7397 if (defaultCaseReducer) {
7398 throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");
7399 }
7400 }
7401 var type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
7402 if (!type) {
7403 throw new Error("`builder.addCase` cannot be called with an empty action type");
7404 }
7405 if (type in actionsMap) {
7406 throw new Error("`builder.addCase` cannot be called with two reducers for the same action type");
7407 }
7408 actionsMap[type] = reducer;
7409 return builder;
7410 },
7411 addMatcher: function (matcher, reducer) {
7412 if (true) {
7413 if (defaultCaseReducer) {
7414 throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");
7415 }
7416 }
7417 actionMatchers.push({ matcher: matcher, reducer: reducer });
7418 return builder;
7419 },
7420 addDefaultCase: function (reducer) {
7421 if (true) {
7422 if (defaultCaseReducer) {
7423 throw new Error("`builder.addDefaultCase` can only be called once");
7424 }
7425 }
7426 defaultCaseReducer = reducer;
7427 return builder;
7428 }
7429 };
7430 builderCallback(builder);
7431 return [actionsMap, actionMatchers, defaultCaseReducer];
7432 }
7433 // src/createReducer.ts
7434 function isStateFunction(x) {
7435 return typeof x === "function";
7436 }
7437 var hasWarnedAboutObjectNotation = false;
7438 function createReducer(initialState, mapOrBuilderCallback, actionMatchers, defaultCaseReducer) {
7439 if (actionMatchers === void 0) { actionMatchers = []; }
7440 if (true) {
7441 if (typeof mapOrBuilderCallback === "object") {
7442 if (!hasWarnedAboutObjectNotation) {
7443 hasWarnedAboutObjectNotation = true;
7444 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");
7445 }
7446 }
7447 }
7448 var _c = typeof mapOrBuilderCallback === "function" ? executeReducerBuilderCallback(mapOrBuilderCallback) : [mapOrBuilderCallback, actionMatchers, defaultCaseReducer], actionsMap = _c[0], finalActionMatchers = _c[1], finalDefaultCaseReducer = _c[2];
7449 var getInitialState;
7450 if (isStateFunction(initialState)) {
7451 getInitialState = function () { return freezeDraftable(initialState()); };
7452 }
7453 else {
7454 var frozenInitialState_1 = freezeDraftable(initialState);
7455 getInitialState = function () { return frozenInitialState_1; };
7456 }
7457 function reducer(state, action) {
7458 if (state === void 0) { state = getInitialState(); }
7459 var caseReducers = __spreadArray([
7460 actionsMap[action.type]
7461 ], finalActionMatchers.filter(function (_c) {
7462 var matcher = _c.matcher;
7463 return matcher(action);
7464 }).map(function (_c) {
7465 var reducer2 = _c.reducer;
7466 return reducer2;
7467 }));
7468 if (caseReducers.filter(function (cr) { return !!cr; }).length === 0) {
7469 caseReducers = [finalDefaultCaseReducer];
7470 }
7471 return caseReducers.reduce(function (previousState, caseReducer) {
7472 if (caseReducer) {
7473 if ((0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(previousState)) {
7474 var draft = previousState;
7475 var result = caseReducer(draft, action);
7476 if (result === void 0) {
7477 return previousState;
7478 }
7479 return result;
7480 }
7481 else if (!(0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraftable)(previousState)) {
7482 var result = caseReducer(previousState, action);
7483 if (result === void 0) {
7484 if (previousState === null) {
7485 return previousState;
7486 }
7487 throw Error("A case reducer on a non-draftable value must not return undefined");
7488 }
7489 return result;
7490 }
7491 else {
7492 return (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(previousState, function (draft) {
7493 return caseReducer(draft, action);
7494 });
7495 }
7496 }
7497 return previousState;
7498 }, state);
7499 }
7500 reducer.getInitialState = getInitialState;
7501 return reducer;
7502 }
7503 // src/createSlice.ts
7504 var hasWarnedAboutObjectNotation2 = false;
7505 function getType2(slice, actionKey) {
7506 return slice + "/" + actionKey;
7507 }
7508 function createSlice(options) {
7509 var name = options.name;
7510 if (!name) {
7511 throw new Error("`name` is a required option for createSlice");
7512 }
7513 if (typeof process !== "undefined" && "development" === "development") {
7514 if (options.initialState === void 0) {
7515 console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");
7516 }
7517 }
7518 var initialState = typeof options.initialState == "function" ? options.initialState : freezeDraftable(options.initialState);
7519 var reducers = options.reducers || {};
7520 var reducerNames = Object.keys(reducers);
7521 var sliceCaseReducersByName = {};
7522 var sliceCaseReducersByType = {};
7523 var actionCreators = {};
7524 reducerNames.forEach(function (reducerName) {
7525 var maybeReducerWithPrepare = reducers[reducerName];
7526 var type = getType2(name, reducerName);
7527 var caseReducer;
7528 var prepareCallback;
7529 if ("reducer" in maybeReducerWithPrepare) {
7530 caseReducer = maybeReducerWithPrepare.reducer;
7531 prepareCallback = maybeReducerWithPrepare.prepare;
7532 }
7533 else {
7534 caseReducer = maybeReducerWithPrepare;
7535 }
7536 sliceCaseReducersByName[reducerName] = caseReducer;
7537 sliceCaseReducersByType[type] = caseReducer;
7538 actionCreators[reducerName] = prepareCallback ? createAction(type, prepareCallback) : createAction(type);
7539 });
7540 function buildReducer() {
7541 if (true) {
7542 if (typeof options.extraReducers === "object") {
7543 if (!hasWarnedAboutObjectNotation2) {
7544 hasWarnedAboutObjectNotation2 = true;
7545 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");
7546 }
7547 }
7548 }
7549 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;
7550 var finalCaseReducers = __spreadValues(__spreadValues({}, extraReducers), sliceCaseReducersByType);
7551 return createReducer(initialState, function (builder) {
7552 for (var key in finalCaseReducers) {
7553 builder.addCase(key, finalCaseReducers[key]);
7554 }
7555 for (var _i = 0, actionMatchers_1 = actionMatchers; _i < actionMatchers_1.length; _i++) {
7556 var m = actionMatchers_1[_i];
7557 builder.addMatcher(m.matcher, m.reducer);
7558 }
7559 if (defaultCaseReducer) {
7560 builder.addDefaultCase(defaultCaseReducer);
7561 }
7562 });
7563 }
7564 var _reducer;
7565 return {
7566 name: name,
7567 reducer: function (state, action) {
7568 if (!_reducer)
7569 _reducer = buildReducer();
7570 return _reducer(state, action);
7571 },
7572 actions: actionCreators,
7573 caseReducers: sliceCaseReducersByName,
7574 getInitialState: function () {
7575 if (!_reducer)
7576 _reducer = buildReducer();
7577 return _reducer.getInitialState();
7578 }
7579 };
7580 }
7581 // src/entities/entity_state.ts
7582 function getInitialEntityState() {
7583 return {
7584 ids: [],
7585 entities: {}
7586 };
7587 }
7588 function createInitialStateFactory() {
7589 function getInitialState(additionalState) {
7590 if (additionalState === void 0) { additionalState = {}; }
7591 return Object.assign(getInitialEntityState(), additionalState);
7592 }
7593 return { getInitialState: getInitialState };
7594 }
7595 // src/entities/state_selectors.ts
7596 function createSelectorsFactory() {
7597 function getSelectors(selectState) {
7598 var selectIds = function (state) { return state.ids; };
7599 var selectEntities = function (state) { return state.entities; };
7600 var selectAll = createDraftSafeSelector(selectIds, selectEntities, function (ids, entities) { return ids.map(function (id) { return entities[id]; }); });
7601 var selectId = function (_, id) { return id; };
7602 var selectById = function (entities, id) { return entities[id]; };
7603 var selectTotal = createDraftSafeSelector(selectIds, function (ids) { return ids.length; });
7604 if (!selectState) {
7605 return {
7606 selectIds: selectIds,
7607 selectEntities: selectEntities,
7608 selectAll: selectAll,
7609 selectTotal: selectTotal,
7610 selectById: createDraftSafeSelector(selectEntities, selectId, selectById)
7611 };
7612 }
7613 var selectGlobalizedEntities = createDraftSafeSelector(selectState, selectEntities);
7614 return {
7615 selectIds: createDraftSafeSelector(selectState, selectIds),
7616 selectEntities: selectGlobalizedEntities,
7617 selectAll: createDraftSafeSelector(selectState, selectAll),
7618 selectTotal: createDraftSafeSelector(selectState, selectTotal),
7619 selectById: createDraftSafeSelector(selectGlobalizedEntities, selectId, selectById)
7620 };
7621 }
7622 return { getSelectors: getSelectors };
7623 }
7624 // src/entities/state_adapter.ts
7625
7626 function createSingleArgumentStateOperator(mutator) {
7627 var operator = createStateOperator(function (_, state) { return mutator(state); });
7628 return function operation(state) {
7629 return operator(state, void 0);
7630 };
7631 }
7632 function createStateOperator(mutator) {
7633 return function operation(state, arg) {
7634 function isPayloadActionArgument(arg2) {
7635 return isFSA(arg2);
7636 }
7637 var runMutator = function (draft) {
7638 if (isPayloadActionArgument(arg)) {
7639 mutator(arg.payload, draft);
7640 }
7641 else {
7642 mutator(arg, draft);
7643 }
7644 };
7645 if ((0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(state)) {
7646 runMutator(state);
7647 return state;
7648 }
7649 else {
7650 return (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(state, runMutator);
7651 }
7652 };
7653 }
7654 // src/entities/utils.ts
7655 function selectIdValue(entity, selectId) {
7656 var key = selectId(entity);
7657 if ( true && key === void 0) {
7658 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());
7659 }
7660 return key;
7661 }
7662 function ensureEntitiesArray(entities) {
7663 if (!Array.isArray(entities)) {
7664 entities = Object.values(entities);
7665 }
7666 return entities;
7667 }
7668 function splitAddedUpdatedEntities(newEntities, selectId, state) {
7669 newEntities = ensureEntitiesArray(newEntities);
7670 var added = [];
7671 var updated = [];
7672 for (var _i = 0, newEntities_1 = newEntities; _i < newEntities_1.length; _i++) {
7673 var entity = newEntities_1[_i];
7674 var id = selectIdValue(entity, selectId);
7675 if (id in state.entities) {
7676 updated.push({ id: id, changes: entity });
7677 }
7678 else {
7679 added.push(entity);
7680 }
7681 }
7682 return [added, updated];
7683 }
7684 // src/entities/unsorted_state_adapter.ts
7685 function createUnsortedStateAdapter(selectId) {
7686 function addOneMutably(entity, state) {
7687 var key = selectIdValue(entity, selectId);
7688 if (key in state.entities) {
7689 return;
7690 }
7691 state.ids.push(key);
7692 state.entities[key] = entity;
7693 }
7694 function addManyMutably(newEntities, state) {
7695 newEntities = ensureEntitiesArray(newEntities);
7696 for (var _i = 0, newEntities_2 = newEntities; _i < newEntities_2.length; _i++) {
7697 var entity = newEntities_2[_i];
7698 addOneMutably(entity, state);
7699 }
7700 }
7701 function setOneMutably(entity, state) {
7702 var key = selectIdValue(entity, selectId);
7703 if (!(key in state.entities)) {
7704 state.ids.push(key);
7705 }
7706 state.entities[key] = entity;
7707 }
7708 function setManyMutably(newEntities, state) {
7709 newEntities = ensureEntitiesArray(newEntities);
7710 for (var _i = 0, newEntities_3 = newEntities; _i < newEntities_3.length; _i++) {
7711 var entity = newEntities_3[_i];
7712 setOneMutably(entity, state);
7713 }
7714 }
7715 function setAllMutably(newEntities, state) {
7716 newEntities = ensureEntitiesArray(newEntities);
7717 state.ids = [];
7718 state.entities = {};
7719 addManyMutably(newEntities, state);
7720 }
7721 function removeOneMutably(key, state) {
7722 return removeManyMutably([key], state);
7723 }
7724 function removeManyMutably(keys, state) {
7725 var didMutate = false;
7726 keys.forEach(function (key) {
7727 if (key in state.entities) {
7728 delete state.entities[key];
7729 didMutate = true;
7730 }
7731 });
7732 if (didMutate) {
7733 state.ids = state.ids.filter(function (id) { return id in state.entities; });
7734 }
7735 }
7736 function removeAllMutably(state) {
7737 Object.assign(state, {
7738 ids: [],
7739 entities: {}
7740 });
7741 }
7742 function takeNewKey(keys, update, state) {
7743 var original2 = state.entities[update.id];
7744 var updated = Object.assign({}, original2, update.changes);
7745 var newKey = selectIdValue(updated, selectId);
7746 var hasNewKey = newKey !== update.id;
7747 if (hasNewKey) {
7748 keys[update.id] = newKey;
7749 delete state.entities[update.id];
7750 }
7751 state.entities[newKey] = updated;
7752 return hasNewKey;
7753 }
7754 function updateOneMutably(update, state) {
7755 return updateManyMutably([update], state);
7756 }
7757 function updateManyMutably(updates, state) {
7758 var newKeys = {};
7759 var updatesPerEntity = {};
7760 updates.forEach(function (update) {
7761 if (update.id in state.entities) {
7762 updatesPerEntity[update.id] = {
7763 id: update.id,
7764 changes: __spreadValues(__spreadValues({}, updatesPerEntity[update.id] ? updatesPerEntity[update.id].changes : null), update.changes)
7765 };
7766 }
7767 });
7768 updates = Object.values(updatesPerEntity);
7769 var didMutateEntities = updates.length > 0;
7770 if (didMutateEntities) {
7771 var didMutateIds = updates.filter(function (update) { return takeNewKey(newKeys, update, state); }).length > 0;
7772 if (didMutateIds) {
7773 state.ids = Object.keys(state.entities);
7774 }
7775 }
7776 }
7777 function upsertOneMutably(entity, state) {
7778 return upsertManyMutably([entity], state);
7779 }
7780 function upsertManyMutably(newEntities, state) {
7781 var _c = splitAddedUpdatedEntities(newEntities, selectId, state), added = _c[0], updated = _c[1];
7782 updateManyMutably(updated, state);
7783 addManyMutably(added, state);
7784 }
7785 return {
7786 removeAll: createSingleArgumentStateOperator(removeAllMutably),
7787 addOne: createStateOperator(addOneMutably),
7788 addMany: createStateOperator(addManyMutably),
7789 setOne: createStateOperator(setOneMutably),
7790 setMany: createStateOperator(setManyMutably),
7791 setAll: createStateOperator(setAllMutably),
7792 updateOne: createStateOperator(updateOneMutably),
7793 updateMany: createStateOperator(updateManyMutably),
7794 upsertOne: createStateOperator(upsertOneMutably),
7795 upsertMany: createStateOperator(upsertManyMutably),
7796 removeOne: createStateOperator(removeOneMutably),
7797 removeMany: createStateOperator(removeManyMutably)
7798 };
7799 }
7800 // src/entities/sorted_state_adapter.ts
7801 function createSortedStateAdapter(selectId, sort) {
7802 var _c = createUnsortedStateAdapter(selectId), removeOne = _c.removeOne, removeMany = _c.removeMany, removeAll = _c.removeAll;
7803 function addOneMutably(entity, state) {
7804 return addManyMutably([entity], state);
7805 }
7806 function addManyMutably(newEntities, state) {
7807 newEntities = ensureEntitiesArray(newEntities);
7808 var models = newEntities.filter(function (model) { return !(selectIdValue(model, selectId) in state.entities); });
7809 if (models.length !== 0) {
7810 merge(models, state);
7811 }
7812 }
7813 function setOneMutably(entity, state) {
7814 return setManyMutably([entity], state);
7815 }
7816 function setManyMutably(newEntities, state) {
7817 newEntities = ensureEntitiesArray(newEntities);
7818 if (newEntities.length !== 0) {
7819 merge(newEntities, state);
7820 }
7821 }
7822 function setAllMutably(newEntities, state) {
7823 newEntities = ensureEntitiesArray(newEntities);
7824 state.entities = {};
7825 state.ids = [];
7826 addManyMutably(newEntities, state);
7827 }
7828 function updateOneMutably(update, state) {
7829 return updateManyMutably([update], state);
7830 }
7831 function updateManyMutably(updates, state) {
7832 var appliedUpdates = false;
7833 for (var _i = 0, updates_1 = updates; _i < updates_1.length; _i++) {
7834 var update = updates_1[_i];
7835 var entity = state.entities[update.id];
7836 if (!entity) {
7837 continue;
7838 }
7839 appliedUpdates = true;
7840 Object.assign(entity, update.changes);
7841 var newId = selectId(entity);
7842 if (update.id !== newId) {
7843 delete state.entities[update.id];
7844 state.entities[newId] = entity;
7845 }
7846 }
7847 if (appliedUpdates) {
7848 resortEntities(state);
7849 }
7850 }
7851 function upsertOneMutably(entity, state) {
7852 return upsertManyMutably([entity], state);
7853 }
7854 function upsertManyMutably(newEntities, state) {
7855 var _c = splitAddedUpdatedEntities(newEntities, selectId, state), added = _c[0], updated = _c[1];
7856 updateManyMutably(updated, state);
7857 addManyMutably(added, state);
7858 }
7859 function areArraysEqual(a, b) {
7860 if (a.length !== b.length) {
7861 return false;
7862 }
7863 for (var i = 0; i < a.length && i < b.length; i++) {
7864 if (a[i] === b[i]) {
7865 continue;
7866 }
7867 return false;
7868 }
7869 return true;
7870 }
7871 function merge(models, state) {
7872 models.forEach(function (model) {
7873 state.entities[selectId(model)] = model;
7874 });
7875 resortEntities(state);
7876 }
7877 function resortEntities(state) {
7878 var allEntities = Object.values(state.entities);
7879 allEntities.sort(sort);
7880 var newSortedIds = allEntities.map(selectId);
7881 var ids = state.ids;
7882 if (!areArraysEqual(ids, newSortedIds)) {
7883 state.ids = newSortedIds;
7884 }
7885 }
7886 return {
7887 removeOne: removeOne,
7888 removeMany: removeMany,
7889 removeAll: removeAll,
7890 addOne: createStateOperator(addOneMutably),
7891 updateOne: createStateOperator(updateOneMutably),
7892 upsertOne: createStateOperator(upsertOneMutably),
7893 setOne: createStateOperator(setOneMutably),
7894 setMany: createStateOperator(setManyMutably),
7895 setAll: createStateOperator(setAllMutably),
7896 addMany: createStateOperator(addManyMutably),
7897 updateMany: createStateOperator(updateManyMutably),
7898 upsertMany: createStateOperator(upsertManyMutably)
7899 };
7900 }
7901 // src/entities/create_adapter.ts
7902 function createEntityAdapter(options) {
7903 if (options === void 0) { options = {}; }
7904 var _c = __spreadValues({
7905 sortComparer: false,
7906 selectId: function (instance) { return instance.id; }
7907 }, options), selectId = _c.selectId, sortComparer = _c.sortComparer;
7908 var stateFactory = createInitialStateFactory();
7909 var selectorsFactory = createSelectorsFactory();
7910 var stateAdapter = sortComparer ? createSortedStateAdapter(selectId, sortComparer) : createUnsortedStateAdapter(selectId);
7911 return __spreadValues(__spreadValues(__spreadValues({
7912 selectId: selectId,
7913 sortComparer: sortComparer
7914 }, stateFactory), selectorsFactory), stateAdapter);
7915 }
7916 // src/nanoid.ts
7917 var urlAlphabet = "ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";
7918 var nanoid = function (size) {
7919 if (size === void 0) { size = 21; }
7920 var id = "";
7921 var i = size;
7922 while (i--) {
7923 id += urlAlphabet[Math.random() * 64 | 0];
7924 }
7925 return id;
7926 };
7927 // src/createAsyncThunk.ts
7928 var commonProperties = [
7929 "name",
7930 "message",
7931 "stack",
7932 "code"
7933 ];
7934 var RejectWithValue = /** @class */ (function () {
7935 function RejectWithValue(payload, meta) {
7936 this.payload = payload;
7937 this.meta = meta;
7938 }
7939 return RejectWithValue;
7940 }());
7941 var FulfillWithMeta = /** @class */ (function () {
7942 function FulfillWithMeta(payload, meta) {
7943 this.payload = payload;
7944 this.meta = meta;
7945 }
7946 return FulfillWithMeta;
7947 }());
7948 var miniSerializeError = function (value) {
7949 if (typeof value === "object" && value !== null) {
7950 var simpleError = {};
7951 for (var _i = 0, commonProperties_1 = commonProperties; _i < commonProperties_1.length; _i++) {
7952 var property = commonProperties_1[_i];
7953 if (typeof value[property] === "string") {
7954 simpleError[property] = value[property];
7955 }
7956 }
7957 return simpleError;
7958 }
7959 return { message: String(value) };
7960 };
7961 var createAsyncThunk = (function () {
7962 function createAsyncThunk2(typePrefix, payloadCreator, options) {
7963 var fulfilled = createAction(typePrefix + "/fulfilled", function (payload, requestId, arg, meta) { return ({
7964 payload: payload,
7965 meta: __spreadProps(__spreadValues({}, meta || {}), {
7966 arg: arg,
7967 requestId: requestId,
7968 requestStatus: "fulfilled"
7969 })
7970 }); });
7971 var pending = createAction(typePrefix + "/pending", function (requestId, arg, meta) { return ({
7972 payload: void 0,
7973 meta: __spreadProps(__spreadValues({}, meta || {}), {
7974 arg: arg,
7975 requestId: requestId,
7976 requestStatus: "pending"
7977 })
7978 }); });
7979 var rejected = createAction(typePrefix + "/rejected", function (error, requestId, arg, payload, meta) { return ({
7980 payload: payload,
7981 error: (options && options.serializeError || miniSerializeError)(error || "Rejected"),
7982 meta: __spreadProps(__spreadValues({}, meta || {}), {
7983 arg: arg,
7984 requestId: requestId,
7985 rejectedWithValue: !!payload,
7986 requestStatus: "rejected",
7987 aborted: (error == null ? void 0 : error.name) === "AbortError",
7988 condition: (error == null ? void 0 : error.name) === "ConditionError"
7989 })
7990 }); });
7991 var displayedWarning = false;
7992 var AC = typeof AbortController !== "undefined" ? AbortController : /** @class */ (function () {
7993 function class_1() {
7994 this.signal = {
7995 aborted: false,
7996 addEventListener: function () {
7997 },
7998 dispatchEvent: function () {
7999 return false;
8000 },
8001 onabort: function () {
8002 },
8003 removeEventListener: function () {
8004 },
8005 reason: void 0,
8006 throwIfAborted: function () {
8007 }
8008 };
8009 }
8010 class_1.prototype.abort = function () {
8011 if (true) {
8012 if (!displayedWarning) {
8013 displayedWarning = true;
8014 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'.");
8015 }
8016 }
8017 };
8018 return class_1;
8019 }());
8020 function actionCreator(arg) {
8021 return function (dispatch, getState, extra) {
8022 var requestId = (options == null ? void 0 : options.idGenerator) ? options.idGenerator(arg) : nanoid();
8023 var abortController = new AC();
8024 var abortReason;
8025 var started = false;
8026 function abort(reason) {
8027 abortReason = reason;
8028 abortController.abort();
8029 }
8030 var promise2 = function () {
8031 return __async(this, null, function () {
8032 var _a, _b, finalAction, conditionResult, abortedPromise, err_1, skipDispatch;
8033 return __generator(this, function (_c) {
8034 switch (_c.label) {
8035 case 0:
8036 _c.trys.push([0, 4, , 5]);
8037 conditionResult = (_a = options == null ? void 0 : options.condition) == null ? void 0 : _a.call(options, arg, { getState: getState, extra: extra });
8038 if (!isThenable(conditionResult)) return [3 /*break*/, 2];
8039 return [4 /*yield*/, conditionResult];
8040 case 1:
8041 conditionResult = _c.sent();
8042 _c.label = 2;
8043 case 2:
8044 if (conditionResult === false || abortController.signal.aborted) {
8045 throw {
8046 name: "ConditionError",
8047 message: "Aborted due to condition callback returning false."
8048 };
8049 }
8050 started = true;
8051 abortedPromise = new Promise(function (_, reject) { return abortController.signal.addEventListener("abort", function () { return reject({
8052 name: "AbortError",
8053 message: abortReason || "Aborted"
8054 }); }); });
8055 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 })));
8056 return [4 /*yield*/, Promise.race([
8057 abortedPromise,
8058 Promise.resolve(payloadCreator(arg, {
8059 dispatch: dispatch,
8060 getState: getState,
8061 extra: extra,
8062 requestId: requestId,
8063 signal: abortController.signal,
8064 abort: abort,
8065 rejectWithValue: function (value, meta) {
8066 return new RejectWithValue(value, meta);
8067 },
8068 fulfillWithValue: function (value, meta) {
8069 return new FulfillWithMeta(value, meta);
8070 }
8071 })).then(function (result) {
8072 if (result instanceof RejectWithValue) {
8073 throw result;
8074 }
8075 if (result instanceof FulfillWithMeta) {
8076 return fulfilled(result.payload, requestId, arg, result.meta);
8077 }
8078 return fulfilled(result, requestId, arg);
8079 })
8080 ])];
8081 case 3:
8082 finalAction = _c.sent();
8083 return [3 /*break*/, 5];
8084 case 4:
8085 err_1 = _c.sent();
8086 finalAction = err_1 instanceof RejectWithValue ? rejected(null, requestId, arg, err_1.payload, err_1.meta) : rejected(err_1, requestId, arg);
8087 return [3 /*break*/, 5];
8088 case 5:
8089 skipDispatch = options && !options.dispatchConditionRejection && rejected.match(finalAction) && finalAction.meta.condition;
8090 if (!skipDispatch) {
8091 dispatch(finalAction);
8092 }
8093 return [2 /*return*/, finalAction];
8094 }
8095 });
8096 });
8097 }();
8098 return Object.assign(promise2, {
8099 abort: abort,
8100 requestId: requestId,
8101 arg: arg,
8102 unwrap: function () {
8103 return promise2.then(unwrapResult);
8104 }
8105 });
8106 };
8107 }
8108 return Object.assign(actionCreator, {
8109 pending: pending,
8110 rejected: rejected,
8111 fulfilled: fulfilled,
8112 typePrefix: typePrefix
8113 });
8114 }
8115 createAsyncThunk2.withTypes = function () { return createAsyncThunk2; };
8116 return createAsyncThunk2;
8117 })();
8118 function unwrapResult(action) {
8119 if (action.meta && action.meta.rejectedWithValue) {
8120 throw action.payload;
8121 }
8122 if (action.error) {
8123 throw action.error;
8124 }
8125 return action.payload;
8126 }
8127 function isThenable(value) {
8128 return value !== null && typeof value === "object" && typeof value.then === "function";
8129 }
8130 // src/matchers.ts
8131 var matches = function (matcher, action) {
8132 if (hasMatchFunction(matcher)) {
8133 return matcher.match(action);
8134 }
8135 else {
8136 return matcher(action);
8137 }
8138 };
8139 function isAnyOf() {
8140 var matchers = [];
8141 for (var _i = 0; _i < arguments.length; _i++) {
8142 matchers[_i] = arguments[_i];
8143 }
8144 return function (action) {
8145 return matchers.some(function (matcher) { return matches(matcher, action); });
8146 };
8147 }
8148 function isAllOf() {
8149 var matchers = [];
8150 for (var _i = 0; _i < arguments.length; _i++) {
8151 matchers[_i] = arguments[_i];
8152 }
8153 return function (action) {
8154 return matchers.every(function (matcher) { return matches(matcher, action); });
8155 };
8156 }
8157 function hasExpectedRequestMetadata(action, validStatus) {
8158 if (!action || !action.meta)
8159 return false;
8160 var hasValidRequestId = typeof action.meta.requestId === "string";
8161 var hasValidRequestStatus = validStatus.indexOf(action.meta.requestStatus) > -1;
8162 return hasValidRequestId && hasValidRequestStatus;
8163 }
8164 function isAsyncThunkArray(a) {
8165 return typeof a[0] === "function" && "pending" in a[0] && "fulfilled" in a[0] && "rejected" in a[0];
8166 }
8167 function isPending() {
8168 var asyncThunks = [];
8169 for (var _i = 0; _i < arguments.length; _i++) {
8170 asyncThunks[_i] = arguments[_i];
8171 }
8172 if (asyncThunks.length === 0) {
8173 return function (action) { return hasExpectedRequestMetadata(action, ["pending"]); };
8174 }
8175 if (!isAsyncThunkArray(asyncThunks)) {
8176 return isPending()(asyncThunks[0]);
8177 }
8178 return function (action) {
8179 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.pending; });
8180 var combinedMatcher = isAnyOf.apply(void 0, matchers);
8181 return combinedMatcher(action);
8182 };
8183 }
8184 function isRejected() {
8185 var asyncThunks = [];
8186 for (var _i = 0; _i < arguments.length; _i++) {
8187 asyncThunks[_i] = arguments[_i];
8188 }
8189 if (asyncThunks.length === 0) {
8190 return function (action) { return hasExpectedRequestMetadata(action, ["rejected"]); };
8191 }
8192 if (!isAsyncThunkArray(asyncThunks)) {
8193 return isRejected()(asyncThunks[0]);
8194 }
8195 return function (action) {
8196 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.rejected; });
8197 var combinedMatcher = isAnyOf.apply(void 0, matchers);
8198 return combinedMatcher(action);
8199 };
8200 }
8201 function isRejectedWithValue() {
8202 var asyncThunks = [];
8203 for (var _i = 0; _i < arguments.length; _i++) {
8204 asyncThunks[_i] = arguments[_i];
8205 }
8206 var hasFlag = function (action) {
8207 return action && action.meta && action.meta.rejectedWithValue;
8208 };
8209 if (asyncThunks.length === 0) {
8210 return function (action) {
8211 var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
8212 return combinedMatcher(action);
8213 };
8214 }
8215 if (!isAsyncThunkArray(asyncThunks)) {
8216 return isRejectedWithValue()(asyncThunks[0]);
8217 }
8218 return function (action) {
8219 var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
8220 return combinedMatcher(action);
8221 };
8222 }
8223 function isFulfilled() {
8224 var asyncThunks = [];
8225 for (var _i = 0; _i < arguments.length; _i++) {
8226 asyncThunks[_i] = arguments[_i];
8227 }
8228 if (asyncThunks.length === 0) {
8229 return function (action) { return hasExpectedRequestMetadata(action, ["fulfilled"]); };
8230 }
8231 if (!isAsyncThunkArray(asyncThunks)) {
8232 return isFulfilled()(asyncThunks[0]);
8233 }
8234 return function (action) {
8235 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.fulfilled; });
8236 var combinedMatcher = isAnyOf.apply(void 0, matchers);
8237 return combinedMatcher(action);
8238 };
8239 }
8240 function isAsyncThunkAction() {
8241 var asyncThunks = [];
8242 for (var _i = 0; _i < arguments.length; _i++) {
8243 asyncThunks[_i] = arguments[_i];
8244 }
8245 if (asyncThunks.length === 0) {
8246 return function (action) { return hasExpectedRequestMetadata(action, ["pending", "fulfilled", "rejected"]); };
8247 }
8248 if (!isAsyncThunkArray(asyncThunks)) {
8249 return isAsyncThunkAction()(asyncThunks[0]);
8250 }
8251 return function (action) {
8252 var matchers = [];
8253 for (var _i = 0, asyncThunks_1 = asyncThunks; _i < asyncThunks_1.length; _i++) {
8254 var asyncThunk = asyncThunks_1[_i];
8255 matchers.push(asyncThunk.pending, asyncThunk.rejected, asyncThunk.fulfilled);
8256 }
8257 var combinedMatcher = isAnyOf.apply(void 0, matchers);
8258 return combinedMatcher(action);
8259 };
8260 }
8261 // src/listenerMiddleware/utils.ts
8262 var assertFunction = function (func, expected) {
8263 if (typeof func !== "function") {
8264 throw new TypeError(expected + " is not a function");
8265 }
8266 };
8267 var noop = function () {
8268 };
8269 var catchRejection = function (promise2, onError) {
8270 if (onError === void 0) { onError = noop; }
8271 promise2.catch(onError);
8272 return promise2;
8273 };
8274 var addAbortSignalListener = function (abortSignal, callback) {
8275 abortSignal.addEventListener("abort", callback, { once: true });
8276 return function () { return abortSignal.removeEventListener("abort", callback); };
8277 };
8278 var abortControllerWithReason = function (abortController, reason) {
8279 var signal = abortController.signal;
8280 if (signal.aborted) {
8281 return;
8282 }
8283 if (!("reason" in signal)) {
8284 Object.defineProperty(signal, "reason", {
8285 enumerable: true,
8286 value: reason,
8287 configurable: true,
8288 writable: true
8289 });
8290 }
8291 ;
8292 abortController.abort(reason);
8293 };
8294 // src/listenerMiddleware/exceptions.ts
8295 var task = "task";
8296 var listener = "listener";
8297 var completed = "completed";
8298 var cancelled = "cancelled";
8299 var taskCancelled = "task-" + cancelled;
8300 var taskCompleted = "task-" + completed;
8301 var listenerCancelled = listener + "-" + cancelled;
8302 var listenerCompleted = listener + "-" + completed;
8303 var TaskAbortError = /** @class */ (function () {
8304 function TaskAbortError(code) {
8305 this.code = code;
8306 this.name = "TaskAbortError";
8307 this.message = task + " " + cancelled + " (reason: " + code + ")";
8308 }
8309 return TaskAbortError;
8310 }());
8311 // src/listenerMiddleware/task.ts
8312 var validateActive = function (signal) {
8313 if (signal.aborted) {
8314 throw new TaskAbortError(signal.reason);
8315 }
8316 };
8317 function raceWithSignal(signal, promise2) {
8318 var cleanup = noop;
8319 return new Promise(function (resolve, reject) {
8320 var notifyRejection = function () { return reject(new TaskAbortError(signal.reason)); };
8321 if (signal.aborted) {
8322 notifyRejection();
8323 return;
8324 }
8325 cleanup = addAbortSignalListener(signal, notifyRejection);
8326 promise2.finally(function () { return cleanup(); }).then(resolve, reject);
8327 }).finally(function () {
8328 cleanup = noop;
8329 });
8330 }
8331 var runTask = function (task2, cleanUp) { return __async(void 0, null, function () {
8332 var value, error_1;
8333 return __generator(this, function (_c) {
8334 switch (_c.label) {
8335 case 0:
8336 _c.trys.push([0, 3, 4, 5]);
8337 return [4 /*yield*/, Promise.resolve()];
8338 case 1:
8339 _c.sent();
8340 return [4 /*yield*/, task2()];
8341 case 2:
8342 value = _c.sent();
8343 return [2 /*return*/, {
8344 status: "ok",
8345 value: value
8346 }];
8347 case 3:
8348 error_1 = _c.sent();
8349 return [2 /*return*/, {
8350 status: error_1 instanceof TaskAbortError ? "cancelled" : "rejected",
8351 error: error_1
8352 }];
8353 case 4:
8354 cleanUp == null ? void 0 : cleanUp();
8355 return [7 /*endfinally*/];
8356 case 5: return [2 /*return*/];
8357 }
8358 });
8359 }); };
8360 var createPause = function (signal) {
8361 return function (promise2) {
8362 return catchRejection(raceWithSignal(signal, promise2).then(function (output) {
8363 validateActive(signal);
8364 return output;
8365 }));
8366 };
8367 };
8368 var createDelay = function (signal) {
8369 var pause = createPause(signal);
8370 return function (timeoutMs) {
8371 return pause(new Promise(function (resolve) { return setTimeout(resolve, timeoutMs); }));
8372 };
8373 };
8374 // src/listenerMiddleware/index.ts
8375 var assign = Object.assign;
8376 var INTERNAL_NIL_TOKEN = {};
8377 var alm = "listenerMiddleware";
8378 var createFork = function (parentAbortSignal, parentBlockingPromises) {
8379 var linkControllers = function (controller) { return addAbortSignalListener(parentAbortSignal, function () { return abortControllerWithReason(controller, parentAbortSignal.reason); }); };
8380 return function (taskExecutor, opts) {
8381 assertFunction(taskExecutor, "taskExecutor");
8382 var childAbortController = new AbortController();
8383 linkControllers(childAbortController);
8384 var result = runTask(function () { return __async(void 0, null, function () {
8385 var result2;
8386 return __generator(this, function (_c) {
8387 switch (_c.label) {
8388 case 0:
8389 validateActive(parentAbortSignal);
8390 validateActive(childAbortController.signal);
8391 return [4 /*yield*/, taskExecutor({
8392 pause: createPause(childAbortController.signal),
8393 delay: createDelay(childAbortController.signal),
8394 signal: childAbortController.signal
8395 })];
8396 case 1:
8397 result2 = _c.sent();
8398 validateActive(childAbortController.signal);
8399 return [2 /*return*/, result2];
8400 }
8401 });
8402 }); }, function () { return abortControllerWithReason(childAbortController, taskCompleted); });
8403 if (opts == null ? void 0 : opts.autoJoin) {
8404 parentBlockingPromises.push(result);
8405 }
8406 return {
8407 result: createPause(parentAbortSignal)(result),
8408 cancel: function () {
8409 abortControllerWithReason(childAbortController, taskCancelled);
8410 }
8411 };
8412 };
8413 };
8414 var createTakePattern = function (startListening, signal) {
8415 var take = function (predicate, timeout) { return __async(void 0, null, function () {
8416 var unsubscribe, tuplePromise, promises, output;
8417 return __generator(this, function (_c) {
8418 switch (_c.label) {
8419 case 0:
8420 validateActive(signal);
8421 unsubscribe = function () {
8422 };
8423 tuplePromise = new Promise(function (resolve, reject) {
8424 var stopListening = startListening({
8425 predicate: predicate,
8426 effect: function (action, listenerApi) {
8427 listenerApi.unsubscribe();
8428 resolve([
8429 action,
8430 listenerApi.getState(),
8431 listenerApi.getOriginalState()
8432 ]);
8433 }
8434 });
8435 unsubscribe = function () {
8436 stopListening();
8437 reject();
8438 };
8439 });
8440 promises = [
8441 tuplePromise
8442 ];
8443 if (timeout != null) {
8444 promises.push(new Promise(function (resolve) { return setTimeout(resolve, timeout, null); }));
8445 }
8446 _c.label = 1;
8447 case 1:
8448 _c.trys.push([1, , 3, 4]);
8449 return [4 /*yield*/, raceWithSignal(signal, Promise.race(promises))];
8450 case 2:
8451 output = _c.sent();
8452 validateActive(signal);
8453 return [2 /*return*/, output];
8454 case 3:
8455 unsubscribe();
8456 return [7 /*endfinally*/];
8457 case 4: return [2 /*return*/];
8458 }
8459 });
8460 }); };
8461 return function (predicate, timeout) { return catchRejection(take(predicate, timeout)); };
8462 };
8463 var getListenerEntryPropsFrom = function (options) {
8464 var type = options.type, actionCreator = options.actionCreator, matcher = options.matcher, predicate = options.predicate, effect = options.effect;
8465 if (type) {
8466 predicate = createAction(type).match;
8467 }
8468 else if (actionCreator) {
8469 type = actionCreator.type;
8470 predicate = actionCreator.match;
8471 }
8472 else if (matcher) {
8473 predicate = matcher;
8474 }
8475 else if (predicate) {
8476 }
8477 else {
8478 throw new Error("Creating or removing a listener requires one of the known fields for matching an action");
8479 }
8480 assertFunction(effect, "options.listener");
8481 return { predicate: predicate, type: type, effect: effect };
8482 };
8483 var createListenerEntry = function (options) {
8484 var _c = getListenerEntryPropsFrom(options), type = _c.type, predicate = _c.predicate, effect = _c.effect;
8485 var id = nanoid();
8486 var entry = {
8487 id: id,
8488 effect: effect,
8489 type: type,
8490 predicate: predicate,
8491 pending: new Set(),
8492 unsubscribe: function () {
8493 throw new Error("Unsubscribe not initialized");
8494 }
8495 };
8496 return entry;
8497 };
8498 var cancelActiveListeners = function (entry) {
8499 entry.pending.forEach(function (controller) {
8500 abortControllerWithReason(controller, listenerCancelled);
8501 });
8502 };
8503 var createClearListenerMiddleware = function (listenerMap) {
8504 return function () {
8505 listenerMap.forEach(cancelActiveListeners);
8506 listenerMap.clear();
8507 };
8508 };
8509 var safelyNotifyError = function (errorHandler, errorToNotify, errorInfo) {
8510 try {
8511 errorHandler(errorToNotify, errorInfo);
8512 }
8513 catch (errorHandlerError) {
8514 setTimeout(function () {
8515 throw errorHandlerError;
8516 }, 0);
8517 }
8518 };
8519 var addListener = createAction(alm + "/add");
8520 var clearAllListeners = createAction(alm + "/removeAll");
8521 var removeListener = createAction(alm + "/remove");
8522 var defaultErrorHandler = function () {
8523 var args = [];
8524 for (var _i = 0; _i < arguments.length; _i++) {
8525 args[_i] = arguments[_i];
8526 }
8527 console.error.apply(console, __spreadArray([alm + "/error"], args));
8528 };
8529 function createListenerMiddleware(middlewareOptions) {
8530 var _this = this;
8531 if (middlewareOptions === void 0) { middlewareOptions = {}; }
8532 var listenerMap = new Map();
8533 var extra = middlewareOptions.extra, _c = middlewareOptions.onError, onError = _c === void 0 ? defaultErrorHandler : _c;
8534 assertFunction(onError, "onError");
8535 var insertEntry = function (entry) {
8536 entry.unsubscribe = function () { return listenerMap.delete(entry.id); };
8537 listenerMap.set(entry.id, entry);
8538 return function (cancelOptions) {
8539 entry.unsubscribe();
8540 if (cancelOptions == null ? void 0 : cancelOptions.cancelActive) {
8541 cancelActiveListeners(entry);
8542 }
8543 };
8544 };
8545 var findListenerEntry = function (comparator) {
8546 for (var _i = 0, _c = Array.from(listenerMap.values()); _i < _c.length; _i++) {
8547 var entry = _c[_i];
8548 if (comparator(entry)) {
8549 return entry;
8550 }
8551 }
8552 return void 0;
8553 };
8554 var startListening = function (options) {
8555 var entry = findListenerEntry(function (existingEntry) { return existingEntry.effect === options.effect; });
8556 if (!entry) {
8557 entry = createListenerEntry(options);
8558 }
8559 return insertEntry(entry);
8560 };
8561 var stopListening = function (options) {
8562 var _c = getListenerEntryPropsFrom(options), type = _c.type, effect = _c.effect, predicate = _c.predicate;
8563 var entry = findListenerEntry(function (entry2) {
8564 var matchPredicateOrType = typeof type === "string" ? entry2.type === type : entry2.predicate === predicate;
8565 return matchPredicateOrType && entry2.effect === effect;
8566 });
8567 if (entry) {
8568 entry.unsubscribe();
8569 if (options.cancelActive) {
8570 cancelActiveListeners(entry);
8571 }
8572 }
8573 return !!entry;
8574 };
8575 var notifyListener = function (entry, action, api, getOriginalState) { return __async(_this, null, function () {
8576 var internalTaskController, take, autoJoinPromises, listenerError_1;
8577 return __generator(this, function (_c) {
8578 switch (_c.label) {
8579 case 0:
8580 internalTaskController = new AbortController();
8581 take = createTakePattern(startListening, internalTaskController.signal);
8582 autoJoinPromises = [];
8583 _c.label = 1;
8584 case 1:
8585 _c.trys.push([1, 3, 4, 6]);
8586 entry.pending.add(internalTaskController);
8587 return [4 /*yield*/, Promise.resolve(entry.effect(action, assign({}, api, {
8588 getOriginalState: getOriginalState,
8589 condition: function (predicate, timeout) { return take(predicate, timeout).then(Boolean); },
8590 take: take,
8591 delay: createDelay(internalTaskController.signal),
8592 pause: createPause(internalTaskController.signal),
8593 extra: extra,
8594 signal: internalTaskController.signal,
8595 fork: createFork(internalTaskController.signal, autoJoinPromises),
8596 unsubscribe: entry.unsubscribe,
8597 subscribe: function () {
8598 listenerMap.set(entry.id, entry);
8599 },
8600 cancelActiveListeners: function () {
8601 entry.pending.forEach(function (controller, _, set) {
8602 if (controller !== internalTaskController) {
8603 abortControllerWithReason(controller, listenerCancelled);
8604 set.delete(controller);
8605 }
8606 });
8607 }
8608 })))];
8609 case 2:
8610 _c.sent();
8611 return [3 /*break*/, 6];
8612 case 3:
8613 listenerError_1 = _c.sent();
8614 if (!(listenerError_1 instanceof TaskAbortError)) {
8615 safelyNotifyError(onError, listenerError_1, {
8616 raisedBy: "effect"
8617 });
8618 }
8619 return [3 /*break*/, 6];
8620 case 4: return [4 /*yield*/, Promise.allSettled(autoJoinPromises)];
8621 case 5:
8622 _c.sent();
8623 abortControllerWithReason(internalTaskController, listenerCompleted);
8624 entry.pending.delete(internalTaskController);
8625 return [7 /*endfinally*/];
8626 case 6: return [2 /*return*/];
8627 }
8628 });
8629 }); };
8630 var clearListenerMiddleware = createClearListenerMiddleware(listenerMap);
8631 var middleware = function (api) { return function (next) { return function (action) {
8632 if (!isAction(action)) {
8633 return next(action);
8634 }
8635 if (addListener.match(action)) {
8636 return startListening(action.payload);
8637 }
8638 if (clearAllListeners.match(action)) {
8639 clearListenerMiddleware();
8640 return;
8641 }
8642 if (removeListener.match(action)) {
8643 return stopListening(action.payload);
8644 }
8645 var originalState = api.getState();
8646 var getOriginalState = function () {
8647 if (originalState === INTERNAL_NIL_TOKEN) {
8648 throw new Error(alm + ": getOriginalState can only be called synchronously");
8649 }
8650 return originalState;
8651 };
8652 var result;
8653 try {
8654 result = next(action);
8655 if (listenerMap.size > 0) {
8656 var currentState = api.getState();
8657 var listenerEntries = Array.from(listenerMap.values());
8658 for (var _i = 0, listenerEntries_1 = listenerEntries; _i < listenerEntries_1.length; _i++) {
8659 var entry = listenerEntries_1[_i];
8660 var runListener = false;
8661 try {
8662 runListener = entry.predicate(action, currentState, originalState);
8663 }
8664 catch (predicateError) {
8665 runListener = false;
8666 safelyNotifyError(onError, predicateError, {
8667 raisedBy: "predicate"
8668 });
8669 }
8670 if (!runListener) {
8671 continue;
8672 }
8673 notifyListener(entry, action, api, getOriginalState);
8674 }
8675 }
8676 }
8677 finally {
8678 originalState = INTERNAL_NIL_TOKEN;
8679 }
8680 return result;
8681 }; }; };
8682 return {
8683 middleware: middleware,
8684 startListening: startListening,
8685 stopListening: stopListening,
8686 clearListeners: clearListenerMiddleware
8687 };
8688 }
8689 // src/autoBatchEnhancer.ts
8690 var SHOULD_AUTOBATCH = "RTK_autoBatch";
8691 var prepareAutoBatched = function () { return function (payload) {
8692 var _c;
8693 return ({
8694 payload: payload,
8695 meta: (_c = {}, _c[SHOULD_AUTOBATCH] = true, _c)
8696 });
8697 }; };
8698 var promise;
8699 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 () {
8700 throw err;
8701 }, 0); }); };
8702 var createQueueWithTimer = function (timeout) {
8703 return function (notify) {
8704 setTimeout(notify, timeout);
8705 };
8706 };
8707 var rAF = typeof window !== "undefined" && window.requestAnimationFrame ? window.requestAnimationFrame : createQueueWithTimer(10);
8708 var autoBatchEnhancer = function (options) {
8709 if (options === void 0) { options = { type: "raf" }; }
8710 return function (next) { return function () {
8711 var args = [];
8712 for (var _i = 0; _i < arguments.length; _i++) {
8713 args[_i] = arguments[_i];
8714 }
8715 var store = next.apply(void 0, args);
8716 var notifying = true;
8717 var shouldNotifyAtEndOfTick = false;
8718 var notificationQueued = false;
8719 var listeners = new Set();
8720 var queueCallback = options.type === "tick" ? queueMicrotaskShim : options.type === "raf" ? rAF : options.type === "callback" ? options.queueNotification : createQueueWithTimer(options.timeout);
8721 var notifyListeners = function () {
8722 notificationQueued = false;
8723 if (shouldNotifyAtEndOfTick) {
8724 shouldNotifyAtEndOfTick = false;
8725 listeners.forEach(function (l) { return l(); });
8726 }
8727 };
8728 return Object.assign({}, store, {
8729 subscribe: function (listener2) {
8730 var wrappedListener = function () { return notifying && listener2(); };
8731 var unsubscribe = store.subscribe(wrappedListener);
8732 listeners.add(listener2);
8733 return function () {
8734 unsubscribe();
8735 listeners.delete(listener2);
8736 };
8737 },
8738 dispatch: function (action) {
8739 var _a;
8740 try {
8741 notifying = !((_a = action == null ? void 0 : action.meta) == null ? void 0 : _a[SHOULD_AUTOBATCH]);
8742 shouldNotifyAtEndOfTick = !notifying;
8743 if (shouldNotifyAtEndOfTick) {
8744 if (!notificationQueued) {
8745 notificationQueued = true;
8746 queueCallback(notifyListeners);
8747 }
8748 }
8749 return store.dispatch(action);
8750 }
8751 finally {
8752 notifying = true;
8753 }
8754 }
8755 });
8756 }; };
8757 };
8758 // src/index.ts
8759 (0,immer__WEBPACK_IMPORTED_MODULE_0__.enableES5)();
8760
8761 //# sourceMappingURL=redux-toolkit.esm.js.map
8762
8763 /***/ }),
8764
8765 /***/ "../node_modules/immer/dist/immer.esm.mjs":
8766 /*!************************************************!*\
8767 !*** ../node_modules/immer/dist/immer.esm.mjs ***!
8768 \************************************************/
8769 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
8770
8771 "use strict";
8772 __webpack_require__.r(__webpack_exports__);
8773 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8774 /* harmony export */ Immer: () => (/* binding */ un),
8775 /* harmony export */ applyPatches: () => (/* binding */ pn),
8776 /* harmony export */ castDraft: () => (/* binding */ K),
8777 /* harmony export */ castImmutable: () => (/* binding */ $),
8778 /* harmony export */ createDraft: () => (/* binding */ ln),
8779 /* harmony export */ current: () => (/* binding */ R),
8780 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
8781 /* harmony export */ enableAllPlugins: () => (/* binding */ J),
8782 /* harmony export */ enableES5: () => (/* binding */ F),
8783 /* harmony export */ enableMapSet: () => (/* binding */ C),
8784 /* harmony export */ enablePatches: () => (/* binding */ T),
8785 /* harmony export */ finishDraft: () => (/* binding */ dn),
8786 /* harmony export */ freeze: () => (/* binding */ d),
8787 /* harmony export */ immerable: () => (/* binding */ L),
8788 /* harmony export */ isDraft: () => (/* binding */ r),
8789 /* harmony export */ isDraftable: () => (/* binding */ t),
8790 /* harmony export */ nothing: () => (/* binding */ H),
8791 /* harmony export */ original: () => (/* binding */ e),
8792 /* harmony export */ produce: () => (/* binding */ fn),
8793 /* harmony export */ produceWithPatches: () => (/* binding */ cn),
8794 /* harmony export */ setAutoFreeze: () => (/* binding */ sn),
8795 /* harmony export */ setUseProxies: () => (/* binding */ vn)
8796 /* harmony export */ });
8797 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
8798 }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);
8799 //# sourceMappingURL=immer.esm.js.map
8800
8801
8802 /***/ }),
8803
8804 /***/ "../node_modules/mixpanel-browser/dist/mixpanel.module.js":
8805 /*!****************************************************************!*\
8806 !*** ../node_modules/mixpanel-browser/dist/mixpanel.module.js ***!
8807 \****************************************************************/
8808 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8809
8810 "use strict";
8811 __webpack_require__.r(__webpack_exports__);
8812 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8813 /* harmony export */ "default": () => (/* binding */ mixpanel)
8814 /* harmony export */ });
8815 // since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
8816 var win;
8817 if (typeof(window) === 'undefined') {
8818 var loc = {
8819 hostname: ''
8820 };
8821 win = {
8822 crypto: {randomUUID: function() {throw Error('unsupported');}},
8823 navigator: { userAgent: '', onLine: true },
8824 document: {
8825 createElement: function() { return {}; },
8826 location: loc,
8827 referrer: ''
8828 },
8829 screen: { width: 0, height: 0 },
8830 location: loc,
8831 addEventListener: function() {},
8832 removeEventListener: function() {}
8833 };
8834 } else {
8835 win = window;
8836 }
8837
8838 function _array_like_to_array(arr, len) {
8839 if (len == null || len > arr.length) len = arr.length;
8840 for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
8841 return arr2;
8842 }
8843 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
8844 try {
8845 var info = gen[key](arg);
8846 var value = info.value;
8847 } catch (error) {
8848 reject(error);
8849 return;
8850 }
8851 if (info.done) {
8852 resolve(value);
8853 } else {
8854 Promise.resolve(value).then(_next, _throw);
8855 }
8856 }
8857 function _async_to_generator(fn) {
8858 return function() {
8859 var self = this, args = arguments;
8860 return new Promise(function(resolve, reject) {
8861 var gen = fn.apply(self, args);
8862 function _next(value) {
8863 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
8864 }
8865 function _throw(err) {
8866 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
8867 }
8868 _next(undefined);
8869 });
8870 };
8871 }
8872 function _construct(Parent, args, Class) {
8873 if (_is_native_reflect_construct()) {
8874 _construct = Reflect.construct;
8875 } else {
8876 _construct = function construct(Parent, args, Class) {
8877 var a = [
8878 null
8879 ];
8880 a.push.apply(a, args);
8881 var Constructor = Function.bind.apply(Parent, a);
8882 var instance = new Constructor();
8883 if (Class) _set_prototype_of(instance, Class.prototype);
8884 return instance;
8885 };
8886 }
8887 return _construct.apply(null, arguments);
8888 }
8889 function _defineProperties(target, props) {
8890 for(var i = 0; i < props.length; i++){
8891 var descriptor = props[i];
8892 descriptor.enumerable = descriptor.enumerable || false;
8893 descriptor.configurable = true;
8894 if ("value" in descriptor) descriptor.writable = true;
8895 Object.defineProperty(target, descriptor.key, descriptor);
8896 }
8897 }
8898 function _create_class(Constructor, protoProps, staticProps) {
8899 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
8900 return Constructor;
8901 }
8902 function _extends() {
8903 _extends = Object.assign || function(target) {
8904 for(var i = 1; i < arguments.length; i++){
8905 var source = arguments[i];
8906 for(var key in source){
8907 if (Object.prototype.hasOwnProperty.call(source, key)) {
8908 target[key] = source[key];
8909 }
8910 }
8911 }
8912 return target;
8913 };
8914 return _extends.apply(this, arguments);
8915 }
8916 function _get_prototype_of(o) {
8917 _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
8918 return o.__proto__ || Object.getPrototypeOf(o);
8919 };
8920 return _get_prototype_of(o);
8921 }
8922 function _inherits(subClass, superClass) {
8923 if (typeof superClass !== "function" && superClass !== null) {
8924 throw new TypeError("Super expression must either be null or a function");
8925 }
8926 subClass.prototype = Object.create(superClass && superClass.prototype, {
8927 constructor: {
8928 value: subClass,
8929 writable: true,
8930 configurable: true
8931 }
8932 });
8933 if (superClass) _set_prototype_of(subClass, superClass);
8934 }
8935 function _instanceof(left, right) {
8936 if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
8937 return !!right[Symbol.hasInstance](left);
8938 } else {
8939 return left instanceof right;
8940 }
8941 }
8942 function _is_native_function(fn) {
8943 return Function.toString.call(fn).indexOf("[native code]") !== -1;
8944 }
8945 function _object_without_properties_loose(source, excluded) {
8946 if (source == null) return {};
8947 var target = {};
8948 var sourceKeys = Object.keys(source);
8949 var key, i;
8950 for(i = 0; i < sourceKeys.length; i++){
8951 key = sourceKeys[i];
8952 if (excluded.indexOf(key) >= 0) continue;
8953 target[key] = source[key];
8954 }
8955 return target;
8956 }
8957 function _set_prototype_of(o, p) {
8958 _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
8959 o.__proto__ = p;
8960 return o;
8961 };
8962 return _set_prototype_of(o, p);
8963 }
8964 function _type_of(obj) {
8965 "@swc/helpers - typeof";
8966 return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
8967 }
8968 function _unsupported_iterable_to_array(o, minLen) {
8969 if (!o) return;
8970 if (typeof o === "string") return _array_like_to_array(o, minLen);
8971 var n = Object.prototype.toString.call(o).slice(8, -1);
8972 if (n === "Object" && o.constructor) n = o.constructor.name;
8973 if (n === "Map" || n === "Set") return Array.from(n);
8974 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
8975 }
8976 function _wrap_native_super(Class) {
8977 var _cache = typeof Map === "function" ? new Map() : undefined;
8978 _wrap_native_super = function wrapNativeSuper(Class) {
8979 if (Class === null || !_is_native_function(Class)) return Class;
8980 if (typeof Class !== "function") {
8981 throw new TypeError("Super expression must either be null or a function");
8982 }
8983 if (typeof _cache !== "undefined") {
8984 if (_cache.has(Class)) return _cache.get(Class);
8985 _cache.set(Class, Wrapper);
8986 }
8987 function Wrapper() {
8988 return _construct(Class, arguments, _get_prototype_of(this).constructor);
8989 }
8990 Wrapper.prototype = Object.create(Class.prototype, {
8991 constructor: {
8992 value: Wrapper,
8993 enumerable: false,
8994 writable: true,
8995 configurable: true
8996 }
8997 });
8998 return _set_prototype_of(Wrapper, Class);
8999 };
9000 return _wrap_native_super(Class);
9001 }
9002 function _is_native_reflect_construct() {
9003 try {
9004 var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
9005 } catch (_) {}
9006 return (_is_native_reflect_construct = function() {
9007 return !!result;
9008 })();
9009 }
9010 function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
9011 var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
9012 if (it) return (it = it.call(o)).next.bind(it);
9013 if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike) {
9014 if (it) o = it;
9015 var i = 0;
9016 return function() {
9017 if (i >= o.length) {
9018 return {
9019 done: true
9020 };
9021 }
9022 return {
9023 done: false,
9024 value: o[i++]
9025 };
9026 };
9027 }
9028 throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
9029 }
9030 function _ts_generator(thisArg, body) {
9031 var f, y, t, g, _ = {
9032 label: 0,
9033 sent: function() {
9034 if (t[0] & 1) throw t[1];
9035 return t[1];
9036 },
9037 trys: [],
9038 ops: []
9039 };
9040 return g = {
9041 next: verb(0),
9042 "throw": verb(1),
9043 "return": verb(2)
9044 }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
9045 return this;
9046 }), g;
9047 function verb(n) {
9048 return function(v) {
9049 return step([
9050 n,
9051 v
9052 ]);
9053 };
9054 }
9055 function step(op) {
9056 if (f) throw new TypeError("Generator is already executing.");
9057 while(_)try {
9058 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;
9059 if (y = 0, t) op = [
9060 op[0] & 2,
9061 t.value
9062 ];
9063 switch(op[0]){
9064 case 0:
9065 case 1:
9066 t = op;
9067 break;
9068 case 4:
9069 _.label++;
9070 return {
9071 value: op[1],
9072 done: false
9073 };
9074 case 5:
9075 _.label++;
9076 y = op[1];
9077 op = [
9078 0
9079 ];
9080 continue;
9081 case 7:
9082 op = _.ops.pop();
9083 _.trys.pop();
9084 continue;
9085 default:
9086 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
9087 _ = 0;
9088 continue;
9089 }
9090 if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
9091 _.label = op[1];
9092 break;
9093 }
9094 if (op[0] === 6 && _.label < t[1]) {
9095 _.label = t[1];
9096 t = op;
9097 break;
9098 }
9099 if (t && _.label < t[2]) {
9100 _.label = t[2];
9101 _.ops.push(op);
9102 break;
9103 }
9104 if (t[2]) _.ops.pop();
9105 _.trys.pop();
9106 continue;
9107 }
9108 op = body.call(thisArg, _);
9109 } catch (e) {
9110 op = [
9111 6,
9112 e
9113 ];
9114 y = 0;
9115 } finally{
9116 f = t = 0;
9117 }
9118 if (op[0] & 5) throw op[1];
9119 return {
9120 value: op[0] ? op[1] : void 0,
9121 done: true
9122 };
9123 }
9124 }
9125 function _ts_values(o) {
9126 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
9127 if (m) return m.call(o);
9128 if (o && typeof o.length === "number") return {
9129 next: function() {
9130 if (o && i >= o.length) o = void 0;
9131 return {
9132 value: o && o[i++],
9133 done: !o
9134 };
9135 }
9136 };
9137 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
9138 }
9139 var __defProp = Object.defineProperty;
9140 var __defNormalProp = function(obj, key, value) {
9141 return key in obj ? __defProp(obj, key, {
9142 enumerable: true,
9143 configurable: true,
9144 writable: true,
9145 value: value
9146 }) : obj[key] = value;
9147 };
9148 var __publicField = function(obj, key, value) {
9149 return __defNormalProp(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
9150 };
9151 var _a;
9152 var __defProp$1 = Object.defineProperty;
9153 var __defNormalProp$1 = function(obj, key, value) {
9154 return key in obj ? __defProp$1(obj, key, {
9155 enumerable: true,
9156 configurable: true,
9157 writable: true,
9158 value: value
9159 }) : obj[key] = value;
9160 };
9161 var __publicField$1 = function(obj, key, value) {
9162 return __defNormalProp$1(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
9163 };
9164 var NodeType$3 = /* @__PURE__ */ function(NodeType2) {
9165 NodeType2[NodeType2["Document"] = 0] = "Document";
9166 NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
9167 NodeType2[NodeType2["Element"] = 2] = "Element";
9168 NodeType2[NodeType2["Text"] = 3] = "Text";
9169 NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
9170 NodeType2[NodeType2["Comment"] = 5] = "Comment";
9171 return NodeType2;
9172 }(NodeType$3 || {});
9173 var testableAccessors$1 = {
9174 Node: [
9175 "childNodes",
9176 "parentNode",
9177 "parentElement",
9178 "textContent"
9179 ],
9180 ShadowRoot: [
9181 "host",
9182 "styleSheets"
9183 ],
9184 Element: [
9185 "shadowRoot",
9186 "querySelector",
9187 "querySelectorAll"
9188 ],
9189 MutationObserver: []
9190 };
9191 var testableMethods$1 = {
9192 Node: [
9193 "contains",
9194 "getRootNode"
9195 ],
9196 ShadowRoot: [
9197 "getSelection"
9198 ],
9199 Element: [],
9200 MutationObserver: [
9201 "constructor"
9202 ]
9203 };
9204 var untaintedBasePrototype$1 = {};
9205 var isAngularZonePresent$1 = function() {
9206 return !!globalThis.Zone;
9207 };
9208 function getUntaintedPrototype$1(key) {
9209 if (untaintedBasePrototype$1[key]) return untaintedBasePrototype$1[key];
9210 var defaultObj = globalThis[key];
9211 var defaultPrototype = defaultObj.prototype;
9212 var accessorNames = key in testableAccessors$1 ? testableAccessors$1[key] : void 0;
9213 var isUntaintedAccessors = Boolean(accessorNames && // @ts-expect-error 2345
9214 accessorNames.every(function(accessor) {
9215 var _a2, _b;
9216 return Boolean((_b = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b.toString().includes("[native code]"));
9217 }));
9218 var methodNames = key in testableMethods$1 ? testableMethods$1[key] : void 0;
9219 var isUntaintedMethods = Boolean(methodNames && methodNames.every(// @ts-expect-error 2345
9220 function(method) {
9221 var _a2;
9222 return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
9223 }));
9224 if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent$1()) {
9225 untaintedBasePrototype$1[key] = defaultObj.prototype;
9226 return defaultObj.prototype;
9227 }
9228 try {
9229 var iframeEl = document.createElement("iframe");
9230 document.body.appendChild(iframeEl);
9231 var win = iframeEl.contentWindow;
9232 if (!win) return defaultObj.prototype;
9233 var untaintedObject = win[key].prototype;
9234 document.body.removeChild(iframeEl);
9235 if (!untaintedObject) return defaultPrototype;
9236 return untaintedBasePrototype$1[key] = untaintedObject;
9237 } catch (e) {
9238 return defaultPrototype;
9239 }
9240 }
9241 var untaintedAccessorCache$1 = {};
9242 function getUntaintedAccessor$1(key, instance, accessor) {
9243 var _a2;
9244 var cacheKey = key + "." + String(accessor);
9245 if (untaintedAccessorCache$1[cacheKey]) return untaintedAccessorCache$1[cacheKey].call(instance);
9246 var untaintedPrototype = getUntaintedPrototype$1(key);
9247 var untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(untaintedPrototype, accessor)) == null ? void 0 : _a2.get;
9248 if (!untaintedAccessor) return instance[accessor];
9249 untaintedAccessorCache$1[cacheKey] = untaintedAccessor;
9250 return untaintedAccessor.call(instance);
9251 }
9252 var untaintedMethodCache$1 = {};
9253 function getUntaintedMethod$1(key, instance, method) {
9254 var cacheKey = key + "." + String(method);
9255 if (untaintedMethodCache$1[cacheKey]) return untaintedMethodCache$1[cacheKey].bind(instance);
9256 var untaintedPrototype = getUntaintedPrototype$1(key);
9257 var untaintedMethod = untaintedPrototype[method];
9258 if (typeof untaintedMethod !== "function") return instance[method];
9259 untaintedMethodCache$1[cacheKey] = untaintedMethod;
9260 return untaintedMethod.bind(instance);
9261 }
9262 function childNodes$1(n2) {
9263 return getUntaintedAccessor$1("Node", n2, "childNodes");
9264 }
9265 function parentNode$1(n2) {
9266 return getUntaintedAccessor$1("Node", n2, "parentNode");
9267 }
9268 function parentElement$1(n2) {
9269 return getUntaintedAccessor$1("Node", n2, "parentElement");
9270 }
9271 function textContent$1(n2) {
9272 return getUntaintedAccessor$1("Node", n2, "textContent");
9273 }
9274 function contains$1(n2, other) {
9275 return getUntaintedMethod$1("Node", n2, "contains")(other);
9276 }
9277 function getRootNode$1(n2) {
9278 return getUntaintedMethod$1("Node", n2, "getRootNode")();
9279 }
9280 function host$1(n2) {
9281 if (!n2 || !("host" in n2)) return null;
9282 return getUntaintedAccessor$1("ShadowRoot", n2, "host");
9283 }
9284 function styleSheets$1(n2) {
9285 return n2.styleSheets;
9286 }
9287 function shadowRoot$1(n2) {
9288 if (!n2 || !("shadowRoot" in n2)) return null;
9289 return getUntaintedAccessor$1("Element", n2, "shadowRoot");
9290 }
9291 function querySelector$1(n2, selectors) {
9292 return getUntaintedAccessor$1("Element", n2, "querySelector")(selectors);
9293 }
9294 function querySelectorAll$1(n2, selectors) {
9295 return getUntaintedAccessor$1("Element", n2, "querySelectorAll")(selectors);
9296 }
9297 function mutationObserverCtor$1() {
9298 return getUntaintedPrototype$1("MutationObserver").constructor;
9299 }
9300 function patch$1(source, name, replacement) {
9301 try {
9302 if (!(name in source)) {
9303 return function() {};
9304 }
9305 var original = source[name];
9306 var wrapped = replacement(original);
9307 if (typeof wrapped === "function") {
9308 wrapped.prototype = wrapped.prototype || {};
9309 Object.defineProperties(wrapped, {
9310 __rrweb_original__: {
9311 enumerable: false,
9312 value: original
9313 }
9314 });
9315 }
9316 source[name] = wrapped;
9317 return function() {
9318 source[name] = original;
9319 };
9320 } catch (e) {
9321 return function() {};
9322 }
9323 }
9324 var index$1 = {
9325 childNodes: childNodes$1,
9326 parentNode: parentNode$1,
9327 parentElement: parentElement$1,
9328 textContent: textContent$1,
9329 contains: contains$1,
9330 getRootNode: getRootNode$1,
9331 host: host$1,
9332 styleSheets: styleSheets$1,
9333 shadowRoot: shadowRoot$1,
9334 querySelector: querySelector$1,
9335 querySelectorAll: querySelectorAll$1,
9336 mutationObserver: mutationObserverCtor$1,
9337 patch: patch$1
9338 };
9339 function isElement(n2) {
9340 return n2.nodeType === n2.ELEMENT_NODE;
9341 }
9342 function isShadowRoot(n2) {
9343 var hostEl = // anchor and textarea elements also have a `host` property
9344 // but only shadow roots have a `mode` property
9345 n2 && "host" in n2 && "mode" in n2 && index$1.host(n2) || null;
9346 return Boolean(hostEl && "shadowRoot" in hostEl && index$1.shadowRoot(hostEl) === n2);
9347 }
9348 function isNativeShadowDom(shadowRoot2) {
9349 return Object.prototype.toString.call(shadowRoot2) === "[object ShadowRoot]";
9350 }
9351 function fixBrowserCompatibilityIssuesInCSS(cssText) {
9352 if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
9353 cssText = cssText.replace(/\sbackground-clip:\s*text;/g, " -webkit-background-clip: text; background-clip: text;");
9354 }
9355 return cssText;
9356 }
9357 function escapeImportStatement(rule2) {
9358 var cssText = rule2.cssText;
9359 if (cssText.split('"').length < 3) return cssText;
9360 var statement = [
9361 "@import",
9362 "url(" + JSON.stringify(rule2.href) + ")"
9363 ];
9364 if (rule2.layerName === "") {
9365 statement.push("layer");
9366 } else if (rule2.layerName) {
9367 statement.push("layer(" + rule2.layerName + ")");
9368 }
9369 if (rule2.supportsText) {
9370 statement.push("supports(" + rule2.supportsText + ")");
9371 }
9372 if (rule2.media.length) {
9373 statement.push(rule2.media.mediaText);
9374 }
9375 return statement.join(" ") + ";";
9376 }
9377 function stringifyStylesheet(s2) {
9378 try {
9379 var rules2 = s2.rules || s2.cssRules;
9380 if (!rules2) {
9381 return null;
9382 }
9383 var sheetHref = s2.href;
9384 if (!sheetHref && s2.ownerNode && s2.ownerNode.ownerDocument) {
9385 sheetHref = s2.ownerNode.ownerDocument.location.href;
9386 }
9387 var stringifiedRules = Array.from(rules2, function(rule2) {
9388 return stringifyRule(rule2, sheetHref);
9389 }).join("");
9390 return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
9391 } catch (error) {
9392 return null;
9393 }
9394 }
9395 function stringifyRule(rule2, sheetHref) {
9396 if (isCSSImportRule(rule2)) {
9397 var importStringified;
9398 try {
9399 importStringified = // we can access the imported stylesheet rules directly
9400 stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
9401 escapeImportStatement(rule2);
9402 } catch (error) {
9403 importStringified = rule2.cssText;
9404 }
9405 if (rule2.styleSheet.href) {
9406 return absolutifyURLs(importStringified, rule2.styleSheet.href);
9407 }
9408 return importStringified;
9409 } else {
9410 var ruleStringified = rule2.cssText;
9411 if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
9412 ruleStringified = fixSafariColons(ruleStringified);
9413 }
9414 if (sheetHref) {
9415 return absolutifyURLs(ruleStringified, sheetHref);
9416 }
9417 return ruleStringified;
9418 }
9419 }
9420 function fixSafariColons(cssStringified) {
9421 var regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
9422 return cssStringified.replace(regex, "$1\\$2");
9423 }
9424 function isCSSImportRule(rule2) {
9425 return "styleSheet" in rule2;
9426 }
9427 function isCSSStyleRule(rule2) {
9428 return "selectorText" in rule2;
9429 }
9430 var Mirror = /*#__PURE__*/ function() {
9431 function Mirror() {
9432 __publicField$1(this, "idNodeMap", /* @__PURE__ */ new Map());
9433 __publicField$1(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap());
9434 }
9435 var _proto = Mirror.prototype;
9436 _proto.getId = function getId(n2) {
9437 var _a2;
9438 if (!n2) return -1;
9439 var id = (_a2 = this.getMeta(n2)) == null ? void 0 : _a2.id;
9440 return id != null ? id : -1;
9441 };
9442 _proto.getNode = function getNode(id) {
9443 return this.idNodeMap.get(id) || null;
9444 };
9445 _proto.getIds = function getIds() {
9446 return Array.from(this.idNodeMap.keys());
9447 };
9448 _proto.getMeta = function getMeta(n2) {
9449 return this.nodeMetaMap.get(n2) || null;
9450 };
9451 // removes the node from idNodeMap
9452 // doesn't remove the node from nodeMetaMap
9453 _proto.removeNodeFromMap = function removeNodeFromMap(n2) {
9454 var _this = this;
9455 var id = this.getId(n2);
9456 this.idNodeMap.delete(id);
9457 if (n2.childNodes) {
9458 n2.childNodes.forEach(function(childNode) {
9459 return _this.removeNodeFromMap(childNode);
9460 });
9461 }
9462 };
9463 _proto.has = function has(id) {
9464 return this.idNodeMap.has(id);
9465 };
9466 _proto.hasNode = function hasNode(node2) {
9467 return this.nodeMetaMap.has(node2);
9468 };
9469 _proto.add = function add(n2, meta) {
9470 var id = meta.id;
9471 this.idNodeMap.set(id, n2);
9472 this.nodeMetaMap.set(n2, meta);
9473 };
9474 _proto.replace = function replace(id, n2) {
9475 var oldNode = this.getNode(id);
9476 if (oldNode) {
9477 var meta = this.nodeMetaMap.get(oldNode);
9478 if (meta) this.nodeMetaMap.set(n2, meta);
9479 }
9480 this.idNodeMap.set(id, n2);
9481 };
9482 _proto.reset = function reset() {
9483 this.idNodeMap = /* @__PURE__ */ new Map();
9484 this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
9485 };
9486 return Mirror;
9487 }();
9488 function createMirror$2() {
9489 return new Mirror();
9490 }
9491 function maskInputValue(param) {
9492 var element = param.element, maskInputOptions = param.maskInputOptions, tagName = param.tagName, type = param.type, value = param.value, maskInputFn = param.maskInputFn;
9493 var text = value || "";
9494 var actualType = type && toLowerCase(type);
9495 if (maskInputOptions[tagName.toLowerCase()] || actualType && maskInputOptions[actualType]) {
9496 if (maskInputFn) {
9497 text = maskInputFn(text, element);
9498 } else {
9499 text = "*".repeat(text.length);
9500 }
9501 }
9502 return text;
9503 }
9504 function toLowerCase(str) {
9505 return str.toLowerCase();
9506 }
9507 var ORIGINAL_ATTRIBUTE_NAME = "__rrweb_original__";
9508 function is2DCanvasBlank(canvas) {
9509 var ctx = canvas.getContext("2d");
9510 if (!ctx) return true;
9511 var chunkSize = 50;
9512 for(var x2 = 0; x2 < canvas.width; x2 += chunkSize){
9513 for(var y = 0; y < canvas.height; y += chunkSize){
9514 var getImageData = ctx.getImageData;
9515 var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData ? getImageData[ORIGINAL_ATTRIBUTE_NAME] : getImageData;
9516 var pixelBuffer = new Uint32Array(// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
9517 originalGetImageData.call(ctx, x2, y, Math.min(chunkSize, canvas.width - x2), Math.min(chunkSize, canvas.height - y)).data.buffer);
9518 if (pixelBuffer.some(function(pixel) {
9519 return pixel !== 0;
9520 })) return false;
9521 }
9522 }
9523 return true;
9524 }
9525 function getInputType(element) {
9526 var type = element.type;
9527 return element.hasAttribute("data-rr-is-password") ? "password" : type ? // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
9528 toLowerCase(type) : null;
9529 }
9530 function extractFileExtension(path, baseURL) {
9531 var url;
9532 try {
9533 url = new URL(path, baseURL != null ? baseURL : window.location.href);
9534 } catch (err) {
9535 return null;
9536 }
9537 var regex = /\.([0-9a-z]+)(?:$)/i;
9538 var match = url.pathname.match(regex);
9539 var _ref;
9540 return (_ref = match == null ? void 0 : match[1]) != null ? _ref : null;
9541 }
9542 function extractOrigin(url) {
9543 var origin = "";
9544 if (url.indexOf("//") > -1) {
9545 origin = url.split("/").slice(0, 3).join("/");
9546 } else {
9547 origin = url.split("/")[0];
9548 }
9549 origin = origin.split("?")[0];
9550 return origin;
9551 }
9552 var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
9553 var URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
9554 var URL_WWW_MATCH = /^www\..*/i;
9555 var DATA_URI = /^(data:)([^,]*),(.*)/i;
9556 function absolutifyURLs(cssText, href) {
9557 return (cssText || "").replace(URL_IN_CSS_REF, function(origin, quote1, path1, quote2, path2, path3) {
9558 var filePath = path1 || path2 || path3;
9559 var maybeQuote = quote1 || quote2 || "";
9560 if (!filePath) {
9561 return origin;
9562 }
9563 if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {
9564 return "url(" + maybeQuote + filePath + maybeQuote + ")";
9565 }
9566 if (DATA_URI.test(filePath)) {
9567 return "url(" + maybeQuote + filePath + maybeQuote + ")";
9568 }
9569 if (filePath[0] === "/") {
9570 return "url(" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + ")";
9571 }
9572 var stack = href.split("/");
9573 var parts = filePath.split("/");
9574 stack.pop();
9575 for(var _iterator = _create_for_of_iterator_helper_loose(parts), _step; !(_step = _iterator()).done;){
9576 var part = _step.value;
9577 if (part === ".") {
9578 continue;
9579 } else if (part === "..") {
9580 stack.pop();
9581 } else {
9582 stack.push(part);
9583 }
9584 }
9585 return "url(" + maybeQuote + stack.join("/") + maybeQuote + ")";
9586 });
9587 }
9588 function normalizeCssString(cssText, _testNoPxNorm) {
9589 if (_testNoPxNorm === void 0) _testNoPxNorm = false;
9590 if (_testNoPxNorm) {
9591 return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "");
9592 } else {
9593 return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "").replace(/0px/g, "0");
9594 }
9595 }
9596 function splitCssText(cssText, style, _testNoPxNorm) {
9597 if (_testNoPxNorm === void 0) _testNoPxNorm = false;
9598 var childNodes2 = Array.from(style.childNodes);
9599 var splits = [];
9600 var iterCount = 0;
9601 if (childNodes2.length > 1 && cssText && typeof cssText === "string") {
9602 var cssTextNorm = normalizeCssString(cssText, _testNoPxNorm);
9603 var normFactor = cssTextNorm.length / cssText.length;
9604 for(var i2 = 1; i2 < childNodes2.length; i2++){
9605 if (childNodes2[i2].textContent && typeof childNodes2[i2].textContent === "string") {
9606 var textContentNorm = normalizeCssString(childNodes2[i2].textContent, _testNoPxNorm);
9607 var jLimit = 100;
9608 var j = 3;
9609 for(; j < textContentNorm.length; j++){
9610 if (// keep consuming css identifiers (to get a decent chunk more quickly)
9611 textContentNorm[j].match(/[a-zA-Z0-9]/) || // substring needs to be unique to this section
9612 textContentNorm.indexOf(textContentNorm.substring(0, j), 1) !== -1) {
9613 continue;
9614 }
9615 break;
9616 }
9617 for(; j < textContentNorm.length; j++){
9618 var startSubstring = textContentNorm.substring(0, j);
9619 var cssNormSplits = cssTextNorm.split(startSubstring);
9620 var splitNorm = -1;
9621 if (cssNormSplits.length === 2) {
9622 splitNorm = cssNormSplits[0].length;
9623 } else if (cssNormSplits.length > 2 && cssNormSplits[0] === "" && childNodes2[i2 - 1].textContent !== "") {
9624 splitNorm = cssTextNorm.indexOf(startSubstring, 1);
9625 } else if (cssNormSplits.length === 1) {
9626 startSubstring = startSubstring.substring(0, startSubstring.length - 1);
9627 cssNormSplits = cssTextNorm.split(startSubstring);
9628 if (cssNormSplits.length <= 1) {
9629 splits.push(cssText);
9630 return splits;
9631 }
9632 j = jLimit + 1;
9633 } else if (j === textContentNorm.length - 1) {
9634 splitNorm = cssTextNorm.indexOf(startSubstring);
9635 }
9636 if (cssNormSplits.length >= 2 && j > jLimit) {
9637 var prevTextContent = childNodes2[i2 - 1].textContent;
9638 if (prevTextContent && typeof prevTextContent === "string") {
9639 var prevMinLength = normalizeCssString(prevTextContent).length;
9640 splitNorm = cssTextNorm.indexOf(startSubstring, prevMinLength);
9641 }
9642 if (splitNorm === -1) {
9643 splitNorm = cssNormSplits[0].length;
9644 }
9645 }
9646 if (splitNorm !== -1) {
9647 var k = Math.floor(splitNorm / normFactor);
9648 for(; k > 0 && k < cssText.length;){
9649 iterCount += 1;
9650 if (iterCount > 50 * childNodes2.length) {
9651 splits.push(cssText);
9652 return splits;
9653 }
9654 var normPart = normalizeCssString(cssText.substring(0, k), _testNoPxNorm);
9655 if (normPart.length === splitNorm) {
9656 splits.push(cssText.substring(0, k));
9657 cssText = cssText.substring(k);
9658 cssTextNorm = cssTextNorm.substring(splitNorm);
9659 break;
9660 } else if (normPart.length < splitNorm) {
9661 k += Math.max(1, Math.floor((splitNorm - normPart.length) / normFactor));
9662 } else {
9663 k -= Math.max(1, Math.floor((normPart.length - splitNorm) * normFactor));
9664 }
9665 }
9666 break;
9667 }
9668 }
9669 }
9670 }
9671 }
9672 splits.push(cssText);
9673 return splits;
9674 }
9675 function markCssSplits(cssText, style) {
9676 return splitCssText(cssText, style).join("/* rr_split */");
9677 }
9678 var _id = 1;
9679 var tagNameRegex = new RegExp("[^a-z0-9-_:]");
9680 var IGNORED_NODE = -2;
9681 function genId() {
9682 return _id++;
9683 }
9684 function getValidTagName$1(element) {
9685 if (_instanceof(element, HTMLFormElement)) {
9686 return "form";
9687 }
9688 var processedTagName = toLowerCase(element.tagName);
9689 if (tagNameRegex.test(processedTagName)) {
9690 return "div";
9691 }
9692 return processedTagName;
9693 }
9694 var canvasService;
9695 var canvasCtx;
9696 var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
9697 var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
9698 function getAbsoluteSrcsetString(doc, attributeValue) {
9699 if (attributeValue.trim() === "") {
9700 return attributeValue;
9701 }
9702 var pos = 0;
9703 function collectCharacters(regEx) {
9704 var chars2;
9705 var match = regEx.exec(attributeValue.substring(pos));
9706 if (match) {
9707 chars2 = match[0];
9708 pos += chars2.length;
9709 return chars2;
9710 }
9711 return "";
9712 }
9713 var output = [];
9714 while(true){
9715 collectCharacters(SRCSET_COMMAS_OR_SPACES);
9716 if (pos >= attributeValue.length) {
9717 break;
9718 }
9719 var url = collectCharacters(SRCSET_NOT_SPACES);
9720 if (url.slice(-1) === ",") {
9721 url = absoluteToDoc(doc, url.substring(0, url.length - 1));
9722 output.push(url);
9723 } else {
9724 var descriptorsStr = "";
9725 url = absoluteToDoc(doc, url);
9726 var inParens = false;
9727 while(true){
9728 var c2 = attributeValue.charAt(pos);
9729 if (c2 === "") {
9730 output.push((url + descriptorsStr).trim());
9731 break;
9732 } else if (!inParens) {
9733 if (c2 === ",") {
9734 pos += 1;
9735 output.push((url + descriptorsStr).trim());
9736 break;
9737 } else if (c2 === "(") {
9738 inParens = true;
9739 }
9740 } else {
9741 if (c2 === ")") {
9742 inParens = false;
9743 }
9744 }
9745 descriptorsStr += c2;
9746 pos += 1;
9747 }
9748 }
9749 }
9750 return output.join(", ");
9751 }
9752 var cachedDocument = /* @__PURE__ */ new WeakMap();
9753 function absoluteToDoc(doc, attributeValue) {
9754 if (!attributeValue || attributeValue.trim() === "") {
9755 return attributeValue;
9756 }
9757 return getHref(doc, attributeValue);
9758 }
9759 function isSVGElement(el) {
9760 return Boolean(el.tagName === "svg" || el.ownerSVGElement);
9761 }
9762 function getHref(doc, customHref) {
9763 var a2 = cachedDocument.get(doc);
9764 if (!a2) {
9765 a2 = doc.createElement("a");
9766 cachedDocument.set(doc, a2);
9767 }
9768 if (!customHref) {
9769 customHref = "";
9770 } else if (customHref.startsWith("blob:") || customHref.startsWith("data:")) {
9771 return customHref;
9772 }
9773 a2.setAttribute("href", customHref);
9774 return a2.href;
9775 }
9776 function transformAttribute(doc, tagName, name, value) {
9777 if (!value) {
9778 return value;
9779 }
9780 if (name === "src" || name === "href" && !(tagName === "use" && value[0] === "#")) {
9781 return absoluteToDoc(doc, value);
9782 } else if (name === "xlink:href" && value[0] !== "#") {
9783 return absoluteToDoc(doc, value);
9784 } else if (name === "background" && (tagName === "table" || tagName === "td" || tagName === "th")) {
9785 return absoluteToDoc(doc, value);
9786 } else if (name === "srcset") {
9787 return getAbsoluteSrcsetString(doc, value);
9788 } else if (name === "style") {
9789 return absolutifyURLs(value, getHref(doc));
9790 } else if (tagName === "object" && name === "data") {
9791 return absoluteToDoc(doc, value);
9792 }
9793 return value;
9794 }
9795 function ignoreAttribute(tagName, name, _value) {
9796 return (tagName === "video" || tagName === "audio") && name === "autoplay";
9797 }
9798 function _isBlockedElement(element, blockClass, blockSelector) {
9799 try {
9800 if (typeof blockClass === "string") {
9801 if (element.classList.contains(blockClass)) {
9802 return true;
9803 }
9804 } else {
9805 for(var eIndex = element.classList.length; eIndex--;){
9806 var className = element.classList[eIndex];
9807 if (blockClass.test(className)) {
9808 return true;
9809 }
9810 }
9811 }
9812 if (blockSelector) {
9813 return element.matches(blockSelector);
9814 }
9815 } catch (e2) {}
9816 return false;
9817 }
9818 function classMatchesRegex(node2, regex, checkAncestors) {
9819 if (!node2) return false;
9820 if (node2.nodeType !== node2.ELEMENT_NODE) {
9821 if (!checkAncestors) return false;
9822 return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
9823 }
9824 for(var eIndex = node2.classList.length; eIndex--;){
9825 var className = node2.classList[eIndex];
9826 if (regex.test(className)) {
9827 return true;
9828 }
9829 }
9830 if (!checkAncestors) return false;
9831 return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
9832 }
9833 function needMaskingText(node2, maskTextClass, maskTextSelector, checkAncestors) {
9834 var el;
9835 if (isElement(node2)) {
9836 el = node2;
9837 if (!index$1.childNodes(el).length) {
9838 return false;
9839 }
9840 } else if (index$1.parentElement(node2) === null) {
9841 return false;
9842 } else {
9843 el = index$1.parentElement(node2);
9844 }
9845 try {
9846 if (typeof maskTextClass === "string") {
9847 if (checkAncestors) {
9848 if (el.closest("." + maskTextClass)) return true;
9849 } else {
9850 if (el.classList.contains(maskTextClass)) return true;
9851 }
9852 } else {
9853 if (classMatchesRegex(el, maskTextClass, checkAncestors)) return true;
9854 }
9855 if (maskTextSelector) {
9856 if (checkAncestors) {
9857 if (el.closest(maskTextSelector)) return true;
9858 } else {
9859 if (el.matches(maskTextSelector)) return true;
9860 }
9861 }
9862 } catch (e2) {}
9863 return false;
9864 }
9865 function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
9866 var win = iframeEl.contentWindow;
9867 if (!win) {
9868 return;
9869 }
9870 var fired = false;
9871 var readyState;
9872 try {
9873 readyState = win.document.readyState;
9874 } catch (error) {
9875 return;
9876 }
9877 if (readyState !== "complete") {
9878 var timer = setTimeout(function() {
9879 if (!fired) {
9880 listener();
9881 fired = true;
9882 }
9883 }, iframeLoadTimeout);
9884 iframeEl.addEventListener("load", function() {
9885 clearTimeout(timer);
9886 fired = true;
9887 listener();
9888 });
9889 return;
9890 }
9891 var blankUrl = "about:blank";
9892 if (win.location.href !== blankUrl || iframeEl.src === blankUrl || iframeEl.src === "") {
9893 setTimeout(listener, 0);
9894 return iframeEl.addEventListener("load", listener);
9895 }
9896 iframeEl.addEventListener("load", listener);
9897 }
9898 function onceStylesheetLoaded(link, listener, styleSheetLoadTimeout) {
9899 var fired = false;
9900 var styleSheetLoaded;
9901 try {
9902 styleSheetLoaded = link.sheet;
9903 } catch (error) {
9904 return;
9905 }
9906 if (styleSheetLoaded) return;
9907 var timer = setTimeout(function() {
9908 if (!fired) {
9909 listener();
9910 fired = true;
9911 }
9912 }, styleSheetLoadTimeout);
9913 link.addEventListener("load", function() {
9914 clearTimeout(timer);
9915 fired = true;
9916 listener();
9917 });
9918 }
9919 function serializeNode(n2, options) {
9920 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;
9921 var rootId = getRootId(doc, mirror2);
9922 switch(n2.nodeType){
9923 case n2.DOCUMENT_NODE:
9924 if (n2.compatMode !== "CSS1Compat") {
9925 return {
9926 type: NodeType$3.Document,
9927 childNodes: [],
9928 compatMode: n2.compatMode
9929 };
9930 } else {
9931 return {
9932 type: NodeType$3.Document,
9933 childNodes: []
9934 };
9935 }
9936 case n2.DOCUMENT_TYPE_NODE:
9937 return {
9938 type: NodeType$3.DocumentType,
9939 name: n2.name,
9940 publicId: n2.publicId,
9941 systemId: n2.systemId,
9942 rootId: rootId
9943 };
9944 case n2.ELEMENT_NODE:
9945 return serializeElementNode(n2, {
9946 doc: doc,
9947 blockClass: blockClass,
9948 blockSelector: blockSelector,
9949 inlineStylesheet: inlineStylesheet,
9950 maskInputOptions: maskInputOptions,
9951 maskInputFn: maskInputFn,
9952 dataURLOptions: dataURLOptions,
9953 inlineImages: inlineImages,
9954 recordCanvas: recordCanvas,
9955 keepIframeSrcFn: keepIframeSrcFn,
9956 newlyAddedElement: newlyAddedElement,
9957 rootId: rootId
9958 });
9959 case n2.TEXT_NODE:
9960 return serializeTextNode(n2, {
9961 doc: doc,
9962 needsMask: needsMask,
9963 maskTextFn: maskTextFn,
9964 rootId: rootId,
9965 cssCaptured: cssCaptured
9966 });
9967 case n2.CDATA_SECTION_NODE:
9968 return {
9969 type: NodeType$3.CDATA,
9970 textContent: "",
9971 rootId: rootId
9972 };
9973 case n2.COMMENT_NODE:
9974 return {
9975 type: NodeType$3.Comment,
9976 textContent: index$1.textContent(n2) || "",
9977 rootId: rootId
9978 };
9979 default:
9980 return false;
9981 }
9982 }
9983 function getRootId(doc, mirror2) {
9984 if (!mirror2.hasNode(doc)) return void 0;
9985 var docId = mirror2.getId(doc);
9986 return docId === 1 ? void 0 : docId;
9987 }
9988 function serializeTextNode(n2, options) {
9989 var needsMask = options.needsMask, maskTextFn = options.maskTextFn, rootId = options.rootId, cssCaptured = options.cssCaptured;
9990 var parent = index$1.parentNode(n2);
9991 var parentTagName = parent && parent.tagName;
9992 var textContent2 = "";
9993 var isStyle = parentTagName === "STYLE" ? true : void 0;
9994 var isScript = parentTagName === "SCRIPT" ? true : void 0;
9995 if (isScript) {
9996 textContent2 = "SCRIPT_PLACEHOLDER";
9997 } else if (!cssCaptured) {
9998 textContent2 = index$1.textContent(n2);
9999 if (isStyle && textContent2) {
10000 textContent2 = absolutifyURLs(textContent2, getHref(options.doc));
10001 }
10002 }
10003 if (!isStyle && !isScript && textContent2 && needsMask) {
10004 textContent2 = maskTextFn ? maskTextFn(textContent2, index$1.parentElement(n2)) : textContent2.replace(/[\S]/g, "*");
10005 }
10006 return {
10007 type: NodeType$3.Text,
10008 textContent: textContent2 || "",
10009 rootId: rootId
10010 };
10011 }
10012 function serializeElementNode(n2, options) {
10013 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;
10014 var needBlock = _isBlockedElement(n2, blockClass, blockSelector);
10015 var tagName = getValidTagName$1(n2);
10016 var attributes = {};
10017 var len = n2.attributes.length;
10018 for(var i2 = 0; i2 < len; i2++){
10019 var attr = n2.attributes[i2];
10020 if (!ignoreAttribute(tagName, attr.name, attr.value)) {
10021 attributes[attr.name] = transformAttribute(doc, tagName, toLowerCase(attr.name), attr.value);
10022 }
10023 }
10024 if (tagName === "link" && inlineStylesheet) {
10025 var stylesheet = Array.from(doc.styleSheets).find(function(s2) {
10026 return s2.href === n2.href;
10027 });
10028 var cssText = null;
10029 if (stylesheet) {
10030 cssText = stringifyStylesheet(stylesheet);
10031 }
10032 if (cssText) {
10033 delete attributes.rel;
10034 delete attributes.href;
10035 attributes._cssText = cssText;
10036 }
10037 }
10038 if (tagName === "style" && n2.sheet) {
10039 var cssText1 = stringifyStylesheet(n2.sheet);
10040 if (cssText1) {
10041 if (n2.childNodes.length > 1) {
10042 cssText1 = markCssSplits(cssText1, n2);
10043 }
10044 attributes._cssText = cssText1;
10045 }
10046 }
10047 if (tagName === "input" || tagName === "textarea" || tagName === "select") {
10048 var value = n2.value;
10049 var checked = n2.checked;
10050 if (attributes.type !== "radio" && attributes.type !== "checkbox" && attributes.type !== "submit" && attributes.type !== "button" && value) {
10051 attributes.value = maskInputValue({
10052 element: n2,
10053 type: getInputType(n2),
10054 tagName: tagName,
10055 value: value,
10056 maskInputOptions: maskInputOptions,
10057 maskInputFn: maskInputFn
10058 });
10059 } else if (checked) {
10060 attributes.checked = checked;
10061 }
10062 }
10063 if (tagName === "option") {
10064 if (n2.selected && !maskInputOptions["select"]) {
10065 attributes.selected = true;
10066 } else {
10067 delete attributes.selected;
10068 }
10069 }
10070 if (tagName === "dialog" && n2.open) {
10071 attributes.rr_open_mode = n2.matches("dialog:modal") ? "modal" : "non-modal";
10072 }
10073 if (tagName === "canvas" && recordCanvas) {
10074 if (n2.__context === "2d") {
10075 if (!is2DCanvasBlank(n2)) {
10076 attributes.rr_dataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
10077 }
10078 } else if (!("__context" in n2)) {
10079 var canvasDataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
10080 var blankCanvas = doc.createElement("canvas");
10081 blankCanvas.width = n2.width;
10082 blankCanvas.height = n2.height;
10083 var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);
10084 if (canvasDataURL !== blankCanvasDataURL) {
10085 attributes.rr_dataURL = canvasDataURL;
10086 }
10087 }
10088 }
10089 if (tagName === "img" && inlineImages) {
10090 if (!canvasService) {
10091 canvasService = doc.createElement("canvas");
10092 canvasCtx = canvasService.getContext("2d");
10093 }
10094 var image = n2;
10095 var imageSrc = image.currentSrc || image.getAttribute("src") || "<unknown-src>";
10096 var priorCrossOrigin = image.crossOrigin;
10097 var recordInlineImage = function() {
10098 image.removeEventListener("load", recordInlineImage);
10099 try {
10100 canvasService.width = image.naturalWidth;
10101 canvasService.height = image.naturalHeight;
10102 canvasCtx.drawImage(image, 0, 0);
10103 attributes.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);
10104 } catch (err) {
10105 if (image.crossOrigin !== "anonymous") {
10106 image.crossOrigin = "anonymous";
10107 if (image.complete && image.naturalWidth !== 0) recordInlineImage();
10108 else image.addEventListener("load", recordInlineImage);
10109 return;
10110 } else {
10111 console.warn("Cannot inline img src=" + imageSrc + "! Error: " + err);
10112 }
10113 }
10114 if (image.crossOrigin === "anonymous") {
10115 priorCrossOrigin ? attributes.crossOrigin = priorCrossOrigin : image.removeAttribute("crossorigin");
10116 }
10117 };
10118 if (image.complete && image.naturalWidth !== 0) recordInlineImage();
10119 else image.addEventListener("load", recordInlineImage);
10120 }
10121 if (tagName === "audio" || tagName === "video") {
10122 var mediaAttributes = attributes;
10123 mediaAttributes.rr_mediaState = n2.paused ? "paused" : "played";
10124 mediaAttributes.rr_mediaCurrentTime = n2.currentTime;
10125 mediaAttributes.rr_mediaPlaybackRate = n2.playbackRate;
10126 mediaAttributes.rr_mediaMuted = n2.muted;
10127 mediaAttributes.rr_mediaLoop = n2.loop;
10128 mediaAttributes.rr_mediaVolume = n2.volume;
10129 }
10130 if (!newlyAddedElement) {
10131 if (n2.scrollLeft) {
10132 attributes.rr_scrollLeft = n2.scrollLeft;
10133 }
10134 if (n2.scrollTop) {
10135 attributes.rr_scrollTop = n2.scrollTop;
10136 }
10137 }
10138 if (needBlock) {
10139 var _n2_getBoundingClientRect = n2.getBoundingClientRect(), width = _n2_getBoundingClientRect.width, height = _n2_getBoundingClientRect.height;
10140 attributes = {
10141 class: attributes.class,
10142 rr_width: "" + width + "px",
10143 rr_height: "" + height + "px"
10144 };
10145 }
10146 if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
10147 if (!n2.contentDocument) {
10148 attributes.rr_src = attributes.src;
10149 }
10150 delete attributes.src;
10151 }
10152 var isCustomElement;
10153 try {
10154 if (customElements.get(tagName)) isCustomElement = true;
10155 } catch (e2) {}
10156 return {
10157 type: NodeType$3.Element,
10158 tagName: tagName,
10159 attributes: attributes,
10160 childNodes: [],
10161 isSVG: isSVGElement(n2) || void 0,
10162 needBlock: needBlock,
10163 rootId: rootId,
10164 isCustom: isCustomElement
10165 };
10166 }
10167 function lowerIfExists(maybeAttr) {
10168 if (maybeAttr === void 0 || maybeAttr === null) {
10169 return "";
10170 } else {
10171 return maybeAttr.toLowerCase();
10172 }
10173 }
10174 function slimDOMExcluded(sn, slimDOMOptions) {
10175 if (slimDOMOptions.comment && sn.type === NodeType$3.Comment) {
10176 return true;
10177 } else if (sn.type === NodeType$3.Element) {
10178 if (slimDOMOptions.script && // script tag
10179 (sn.tagName === "script" || // (module)preload link
10180 sn.tagName === "link" && (sn.attributes.rel === "preload" && sn.attributes.as === "script" || sn.attributes.rel === "modulepreload") || // prefetch link
10181 sn.tagName === "link" && sn.attributes.rel === "prefetch" && typeof sn.attributes.href === "string" && extractFileExtension(sn.attributes.href) === "js")) {
10182 return true;
10183 } 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"))) {
10184 return true;
10185 } else if (sn.tagName === "meta") {
10186 if (slimDOMOptions.headMetaDescKeywords && lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
10187 return true;
10188 } else if (slimDOMOptions.headMetaSocial && (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || // og = opengraph (facebook)
10189 lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || lowerIfExists(sn.attributes.name) === "pinterest")) {
10190 return true;
10191 } else if (slimDOMOptions.headMetaRobots && (lowerIfExists(sn.attributes.name) === "robots" || lowerIfExists(sn.attributes.name) === "googlebot" || lowerIfExists(sn.attributes.name) === "bingbot")) {
10192 return true;
10193 } else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== void 0) {
10194 return true;
10195 } 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:/))) {
10196 return true;
10197 } 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")) {
10198 return true;
10199 }
10200 }
10201 }
10202 return false;
10203 }
10204 function serializeNodeWithId(n2, options) {
10205 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() {
10206 return false;
10207 } : _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;
10208 var needsMask = options.needsMask;
10209 var _options_preserveWhiteSpace = options.preserveWhiteSpace, preserveWhiteSpace = _options_preserveWhiteSpace === void 0 ? true : _options_preserveWhiteSpace;
10210 if (!needsMask) {
10211 var checkAncestors = needsMask === void 0;
10212 needsMask = needMaskingText(n2, maskTextClass, maskTextSelector, checkAncestors);
10213 }
10214 var _serializedNode = serializeNode(n2, {
10215 doc: doc,
10216 mirror: mirror2,
10217 blockClass: blockClass,
10218 blockSelector: blockSelector,
10219 needsMask: needsMask,
10220 inlineStylesheet: inlineStylesheet,
10221 maskInputOptions: maskInputOptions,
10222 maskTextFn: maskTextFn,
10223 maskInputFn: maskInputFn,
10224 dataURLOptions: dataURLOptions,
10225 inlineImages: inlineImages,
10226 recordCanvas: recordCanvas,
10227 keepIframeSrcFn: keepIframeSrcFn,
10228 newlyAddedElement: newlyAddedElement,
10229 cssCaptured: cssCaptured
10230 });
10231 if (!_serializedNode) {
10232 console.warn(n2, "not serialized");
10233 return null;
10234 }
10235 var id;
10236 if (mirror2.hasNode(n2)) {
10237 id = mirror2.getId(n2);
10238 } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType$3.Text && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
10239 id = IGNORED_NODE;
10240 } else {
10241 id = genId();
10242 }
10243 var serializedNode = Object.assign(_serializedNode, {
10244 id: id
10245 });
10246 mirror2.add(n2, serializedNode);
10247 if (id === IGNORED_NODE) {
10248 return null;
10249 }
10250 if (onSerialize) {
10251 onSerialize(n2);
10252 }
10253 var recordChild = !skipChild;
10254 if (serializedNode.type === NodeType$3.Element) {
10255 recordChild = recordChild && !serializedNode.needBlock;
10256 delete serializedNode.needBlock;
10257 var shadowRootEl = index$1.shadowRoot(n2);
10258 if (shadowRootEl && isNativeShadowDom(shadowRootEl)) serializedNode.isShadowHost = true;
10259 }
10260 if ((serializedNode.type === NodeType$3.Document || serializedNode.type === NodeType$3.Element) && recordChild) {
10261 if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType$3.Element && serializedNode.tagName === "head") {
10262 preserveWhiteSpace = false;
10263 }
10264 var bypassOptions = {
10265 doc: doc,
10266 mirror: mirror2,
10267 blockClass: blockClass,
10268 blockSelector: blockSelector,
10269 needsMask: needsMask,
10270 maskTextClass: maskTextClass,
10271 maskTextSelector: maskTextSelector,
10272 skipChild: skipChild,
10273 inlineStylesheet: inlineStylesheet,
10274 maskInputOptions: maskInputOptions,
10275 maskTextFn: maskTextFn,
10276 maskInputFn: maskInputFn,
10277 slimDOMOptions: slimDOMOptions,
10278 dataURLOptions: dataURLOptions,
10279 inlineImages: inlineImages,
10280 recordCanvas: recordCanvas,
10281 preserveWhiteSpace: preserveWhiteSpace,
10282 onSerialize: onSerialize,
10283 onIframeLoad: onIframeLoad,
10284 iframeLoadTimeout: iframeLoadTimeout,
10285 onStylesheetLoad: onStylesheetLoad,
10286 stylesheetLoadTimeout: stylesheetLoadTimeout,
10287 keepIframeSrcFn: keepIframeSrcFn,
10288 cssCaptured: false
10289 };
10290 if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
10291 else {
10292 if (serializedNode.type === NodeType$3.Element && serializedNode.attributes._cssText !== void 0 && typeof serializedNode.attributes._cssText === "string") {
10293 bypassOptions.cssCaptured = true;
10294 }
10295 for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(index$1.childNodes(n2))), _step; !(_step = _iterator()).done;){
10296 var childN = _step.value;
10297 var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
10298 if (serializedChildNode) {
10299 serializedNode.childNodes.push(serializedChildNode);
10300 }
10301 }
10302 }
10303 var shadowRootEl1 = null;
10304 if (isElement(n2) && (shadowRootEl1 = index$1.shadowRoot(n2))) {
10305 for(var _iterator1 = _create_for_of_iterator_helper_loose(Array.from(index$1.childNodes(shadowRootEl1))), _step1; !(_step1 = _iterator1()).done;){
10306 var childN1 = _step1.value;
10307 var serializedChildNode1 = serializeNodeWithId(childN1, bypassOptions);
10308 if (serializedChildNode1) {
10309 isNativeShadowDom(shadowRootEl1) && (serializedChildNode1.isShadow = true);
10310 serializedNode.childNodes.push(serializedChildNode1);
10311 }
10312 }
10313 }
10314 }
10315 var parent = index$1.parentNode(n2);
10316 if (parent && isShadowRoot(parent) && isNativeShadowDom(parent)) {
10317 serializedNode.isShadow = true;
10318 }
10319 if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "iframe") {
10320 onceIframeLoaded(n2, function() {
10321 var iframeDoc = n2.contentDocument;
10322 if (iframeDoc && onIframeLoad) {
10323 var serializedIframeNode = serializeNodeWithId(iframeDoc, {
10324 doc: iframeDoc,
10325 mirror: mirror2,
10326 blockClass: blockClass,
10327 blockSelector: blockSelector,
10328 needsMask: needsMask,
10329 maskTextClass: maskTextClass,
10330 maskTextSelector: maskTextSelector,
10331 skipChild: false,
10332 inlineStylesheet: inlineStylesheet,
10333 maskInputOptions: maskInputOptions,
10334 maskTextFn: maskTextFn,
10335 maskInputFn: maskInputFn,
10336 slimDOMOptions: slimDOMOptions,
10337 dataURLOptions: dataURLOptions,
10338 inlineImages: inlineImages,
10339 recordCanvas: recordCanvas,
10340 preserveWhiteSpace: preserveWhiteSpace,
10341 onSerialize: onSerialize,
10342 onIframeLoad: onIframeLoad,
10343 iframeLoadTimeout: iframeLoadTimeout,
10344 onStylesheetLoad: onStylesheetLoad,
10345 stylesheetLoadTimeout: stylesheetLoadTimeout,
10346 keepIframeSrcFn: keepIframeSrcFn
10347 });
10348 if (serializedIframeNode) {
10349 onIframeLoad(n2, serializedIframeNode);
10350 }
10351 }
10352 }, iframeLoadTimeout);
10353 }
10354 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")) {
10355 onceStylesheetLoaded(n2, function() {
10356 if (onStylesheetLoad) {
10357 var serializedLinkNode = serializeNodeWithId(n2, {
10358 doc: doc,
10359 mirror: mirror2,
10360 blockClass: blockClass,
10361 blockSelector: blockSelector,
10362 needsMask: needsMask,
10363 maskTextClass: maskTextClass,
10364 maskTextSelector: maskTextSelector,
10365 skipChild: false,
10366 inlineStylesheet: inlineStylesheet,
10367 maskInputOptions: maskInputOptions,
10368 maskTextFn: maskTextFn,
10369 maskInputFn: maskInputFn,
10370 slimDOMOptions: slimDOMOptions,
10371 dataURLOptions: dataURLOptions,
10372 inlineImages: inlineImages,
10373 recordCanvas: recordCanvas,
10374 preserveWhiteSpace: preserveWhiteSpace,
10375 onSerialize: onSerialize,
10376 onIframeLoad: onIframeLoad,
10377 iframeLoadTimeout: iframeLoadTimeout,
10378 onStylesheetLoad: onStylesheetLoad,
10379 stylesheetLoadTimeout: stylesheetLoadTimeout,
10380 keepIframeSrcFn: keepIframeSrcFn
10381 });
10382 if (serializedLinkNode) {
10383 onStylesheetLoad(n2, serializedLinkNode);
10384 }
10385 }
10386 }, stylesheetLoadTimeout);
10387 }
10388 return serializedNode;
10389 }
10390 function snapshot(n2, options) {
10391 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() {
10392 return false;
10393 } : _ref_keepIframeSrcFn;
10394 var maskInputOptions = maskAllInputs === true ? {
10395 color: true,
10396 date: true,
10397 "datetime-local": true,
10398 email: true,
10399 month: true,
10400 number: true,
10401 range: true,
10402 search: true,
10403 tel: true,
10404 text: true,
10405 time: true,
10406 url: true,
10407 week: true,
10408 textarea: true,
10409 select: true,
10410 password: true,
10411 hidden: true
10412 } : maskAllInputs === false ? {
10413 password: true
10414 } : maskAllInputs;
10415 var slimDOMOptions = slimDOM === true || slimDOM === "all" ? // if true: set of sensible options that should not throw away any information
10416 {
10417 script: true,
10418 comment: true,
10419 headFavicon: true,
10420 headWhitespace: true,
10421 headMetaDescKeywords: slimDOM === "all",
10422 // destructive
10423 headMetaSocial: true,
10424 headMetaRobots: true,
10425 headMetaHttpEquiv: true,
10426 headMetaAuthorship: true,
10427 headMetaVerification: true
10428 } : slimDOM === false ? {} : slimDOM;
10429 return serializeNodeWithId(n2, {
10430 doc: n2,
10431 mirror: mirror2,
10432 blockClass: blockClass,
10433 blockSelector: blockSelector,
10434 maskTextClass: maskTextClass,
10435 maskTextSelector: maskTextSelector,
10436 skipChild: false,
10437 inlineStylesheet: inlineStylesheet,
10438 maskInputOptions: maskInputOptions,
10439 maskTextFn: maskTextFn,
10440 maskInputFn: maskInputFn,
10441 slimDOMOptions: slimDOMOptions,
10442 dataURLOptions: dataURLOptions,
10443 inlineImages: inlineImages,
10444 recordCanvas: recordCanvas,
10445 preserveWhiteSpace: preserveWhiteSpace,
10446 onSerialize: onSerialize,
10447 onIframeLoad: onIframeLoad,
10448 iframeLoadTimeout: iframeLoadTimeout,
10449 onStylesheetLoad: onStylesheetLoad,
10450 stylesheetLoadTimeout: stylesheetLoadTimeout,
10451 keepIframeSrcFn: keepIframeSrcFn,
10452 newlyAddedElement: false
10453 });
10454 }
10455 function getDefaultExportFromCjs$1(x2) {
10456 return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
10457 }
10458 function getAugmentedNamespace$1(n2) {
10459 if (n2.__esModule) return n2;
10460 var f2 = n2.default;
10461 if (typeof f2 == "function") {
10462 var a2 = function a22() {
10463 if (_instanceof(this, a22)) {
10464 return Reflect.construct(f2, arguments, this.constructor);
10465 }
10466 return f2.apply(this, arguments);
10467 };
10468 a2.prototype = f2.prototype;
10469 } else a2 = {};
10470 Object.defineProperty(a2, "__esModule", {
10471 value: true
10472 });
10473 Object.keys(n2).forEach(function(k) {
10474 var d = Object.getOwnPropertyDescriptor(n2, k);
10475 Object.defineProperty(a2, k, d.get ? d : {
10476 enumerable: true,
10477 get: function get() {
10478 return n2[k];
10479 }
10480 });
10481 });
10482 return a2;
10483 }
10484 var picocolors_browser$1 = {
10485 exports: {}
10486 };
10487 var x$1 = String;
10488 var create$1 = function create$1() {
10489 return {
10490 isColorSupported: false,
10491 reset: x$1,
10492 bold: x$1,
10493 dim: x$1,
10494 italic: x$1,
10495 underline: x$1,
10496 inverse: x$1,
10497 hidden: x$1,
10498 strikethrough: x$1,
10499 black: x$1,
10500 red: x$1,
10501 green: x$1,
10502 yellow: x$1,
10503 blue: x$1,
10504 magenta: x$1,
10505 cyan: x$1,
10506 white: x$1,
10507 gray: x$1,
10508 bgBlack: x$1,
10509 bgRed: x$1,
10510 bgGreen: x$1,
10511 bgYellow: x$1,
10512 bgBlue: x$1,
10513 bgMagenta: x$1,
10514 bgCyan: x$1,
10515 bgWhite: x$1
10516 };
10517 };
10518 picocolors_browser$1.exports = create$1();
10519 picocolors_browser$1.exports.createColors = create$1;
10520 var picocolors_browserExports$1 = picocolors_browser$1.exports;
10521 var __viteBrowserExternal$2 = {};
10522 var __viteBrowserExternal$1$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10523 __proto__: null,
10524 default: __viteBrowserExternal$2
10525 }, Symbol.toStringTag, {
10526 value: "Module"
10527 }));
10528 var require$$2$1 = /* @__PURE__ */ getAugmentedNamespace$1(__viteBrowserExternal$1$1);
10529 var pico$1 = picocolors_browserExports$1;
10530 var terminalHighlight$1$1 = require$$2$1;
10531 var CssSyntaxError$3$1 = /*#__PURE__*/ function(Error1) {
10532 _inherits(CssSyntaxError, Error1);
10533 function CssSyntaxError(message, line, column, source, file, plugin22) {
10534 var _this;
10535 _this = Error1.call(this, message) || this;
10536 _this.name = "CssSyntaxError";
10537 _this.reason = message;
10538 if (file) {
10539 _this.file = file;
10540 }
10541 if (source) {
10542 _this.source = source;
10543 }
10544 if (plugin22) {
10545 _this.plugin = plugin22;
10546 }
10547 if (typeof line !== "undefined" && typeof column !== "undefined") {
10548 if (typeof line === "number") {
10549 _this.line = line;
10550 _this.column = column;
10551 } else {
10552 _this.line = line.line;
10553 _this.column = line.column;
10554 _this.endLine = column.line;
10555 _this.endColumn = column.column;
10556 }
10557 }
10558 _this.setMessage();
10559 if (Error.captureStackTrace) {
10560 Error.captureStackTrace(_this, CssSyntaxError);
10561 }
10562 return _this;
10563 }
10564 var _proto = CssSyntaxError.prototype;
10565 _proto.setMessage = function setMessage() {
10566 this.message = this.plugin ? this.plugin + ": " : "";
10567 this.message += this.file ? this.file : "<css input>";
10568 if (typeof this.line !== "undefined") {
10569 this.message += ":" + this.line + ":" + this.column;
10570 }
10571 this.message += ": " + this.reason;
10572 };
10573 _proto.showSourceCode = function showSourceCode(color) {
10574 var _this = this;
10575 if (!this.source) return "";
10576 var css = this.source;
10577 if (color == null) color = pico$1.isColorSupported;
10578 if (terminalHighlight$1$1) {
10579 if (color) css = terminalHighlight$1$1(css);
10580 }
10581 var lines = css.split(/\r?\n/);
10582 var start = Math.max(this.line - 3, 0);
10583 var end = Math.min(this.line + 2, lines.length);
10584 var maxWidth = String(end).length;
10585 var mark, aside;
10586 if (color) {
10587 var _pico$1_createColors = pico$1.createColors(true), bold = _pico$1_createColors.bold, gray = _pico$1_createColors.gray, red = _pico$1_createColors.red;
10588 mark = function(text) {
10589 return bold(red(text));
10590 };
10591 aside = function(text) {
10592 return gray(text);
10593 };
10594 } else {
10595 mark = aside = function(str) {
10596 return str;
10597 };
10598 }
10599 return lines.slice(start, end).map(function(line, index2) {
10600 var number = start + 1 + index2;
10601 var gutter = " " + (" " + number).slice(-maxWidth) + " | ";
10602 if (number === _this.line) {
10603 var spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, _this.column - 1).replace(/[^\t]/g, " ");
10604 return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^");
10605 }
10606 return " " + aside(gutter) + line;
10607 }).join("\n");
10608 };
10609 _proto.toString = function toString() {
10610 var code = this.showSourceCode();
10611 if (code) {
10612 code = "\n\n" + code + "\n";
10613 }
10614 return this.name + ": " + this.message + code;
10615 };
10616 return CssSyntaxError;
10617 }(_wrap_native_super(Error));
10618 var cssSyntaxError$1 = CssSyntaxError$3$1;
10619 CssSyntaxError$3$1.default = CssSyntaxError$3$1;
10620 var symbols$1 = {};
10621 symbols$1.isClean = Symbol("isClean");
10622 symbols$1.my = Symbol("my");
10623 var DEFAULT_RAW$1 = {
10624 after: "\n",
10625 beforeClose: "\n",
10626 beforeComment: "\n",
10627 beforeDecl: "\n",
10628 beforeOpen: " ",
10629 beforeRule: "\n",
10630 colon: ": ",
10631 commentLeft: " ",
10632 commentRight: " ",
10633 emptyBody: "",
10634 indent: " ",
10635 semicolon: false
10636 };
10637 function capitalize$1(str) {
10638 return str[0].toUpperCase() + str.slice(1);
10639 }
10640 var Stringifier$2$1 = /*#__PURE__*/ function() {
10641 function Stringifier(builder) {
10642 this.builder = builder;
10643 }
10644 var _proto = Stringifier.prototype;
10645 _proto.atrule = function atrule(node2, semicolon) {
10646 var name = "@" + node2.name;
10647 var params = node2.params ? this.rawValue(node2, "params") : "";
10648 if (typeof node2.raws.afterName !== "undefined") {
10649 name += node2.raws.afterName;
10650 } else if (params) {
10651 name += " ";
10652 }
10653 if (node2.nodes) {
10654 this.block(node2, name + params);
10655 } else {
10656 var end = (node2.raws.between || "") + (semicolon ? ";" : "");
10657 this.builder(name + params + end, node2);
10658 }
10659 };
10660 _proto.beforeAfter = function beforeAfter(node2, detect) {
10661 var value;
10662 if (node2.type === "decl") {
10663 value = this.raw(node2, null, "beforeDecl");
10664 } else if (node2.type === "comment") {
10665 value = this.raw(node2, null, "beforeComment");
10666 } else if (detect === "before") {
10667 value = this.raw(node2, null, "beforeRule");
10668 } else {
10669 value = this.raw(node2, null, "beforeClose");
10670 }
10671 var buf = node2.parent;
10672 var depth = 0;
10673 while(buf && buf.type !== "root"){
10674 depth += 1;
10675 buf = buf.parent;
10676 }
10677 if (value.includes("\n")) {
10678 var indent = this.raw(node2, null, "indent");
10679 if (indent.length) {
10680 for(var step = 0; step < depth; step++)value += indent;
10681 }
10682 }
10683 return value;
10684 };
10685 _proto.block = function block(node2, start) {
10686 var between = this.raw(node2, "between", "beforeOpen");
10687 this.builder(start + between + "{", node2, "start");
10688 var after;
10689 if (node2.nodes && node2.nodes.length) {
10690 this.body(node2);
10691 after = this.raw(node2, "after");
10692 } else {
10693 after = this.raw(node2, "after", "emptyBody");
10694 }
10695 if (after) this.builder(after);
10696 this.builder("}", node2, "end");
10697 };
10698 _proto.body = function body(node2) {
10699 var last = node2.nodes.length - 1;
10700 while(last > 0){
10701 if (node2.nodes[last].type !== "comment") break;
10702 last -= 1;
10703 }
10704 var semicolon = this.raw(node2, "semicolon");
10705 for(var i2 = 0; i2 < node2.nodes.length; i2++){
10706 var child = node2.nodes[i2];
10707 var before = this.raw(child, "before");
10708 if (before) this.builder(before);
10709 this.stringify(child, last !== i2 || semicolon);
10710 }
10711 };
10712 _proto.comment = function comment(node2) {
10713 var left = this.raw(node2, "left", "commentLeft");
10714 var right = this.raw(node2, "right", "commentRight");
10715 this.builder("/*" + left + node2.text + right + "*/", node2);
10716 };
10717 _proto.decl = function decl(node2, semicolon) {
10718 var between = this.raw(node2, "between", "colon");
10719 var string = node2.prop + between + this.rawValue(node2, "value");
10720 if (node2.important) {
10721 string += node2.raws.important || " !important";
10722 }
10723 if (semicolon) string += ";";
10724 this.builder(string, node2);
10725 };
10726 _proto.document = function document1(node2) {
10727 this.body(node2);
10728 };
10729 _proto.raw = function raw(node2, own, detect) {
10730 var value;
10731 if (!detect) detect = own;
10732 if (own) {
10733 value = node2.raws[own];
10734 if (typeof value !== "undefined") return value;
10735 }
10736 var parent = node2.parent;
10737 if (detect === "before") {
10738 if (!parent || parent.type === "root" && parent.first === node2) {
10739 return "";
10740 }
10741 if (parent && parent.type === "document") {
10742 return "";
10743 }
10744 }
10745 if (!parent) return DEFAULT_RAW$1[detect];
10746 var root2 = node2.root();
10747 if (!root2.rawCache) root2.rawCache = {};
10748 if (typeof root2.rawCache[detect] !== "undefined") {
10749 return root2.rawCache[detect];
10750 }
10751 if (detect === "before" || detect === "after") {
10752 return this.beforeAfter(node2, detect);
10753 } else {
10754 var method = "raw" + capitalize$1(detect);
10755 if (this[method]) {
10756 value = this[method](root2, node2);
10757 } else {
10758 root2.walk(function(i2) {
10759 value = i2.raws[own];
10760 if (typeof value !== "undefined") return false;
10761 });
10762 }
10763 }
10764 if (typeof value === "undefined") value = DEFAULT_RAW$1[detect];
10765 root2.rawCache[detect] = value;
10766 return value;
10767 };
10768 _proto.rawBeforeClose = function rawBeforeClose(root2) {
10769 var value;
10770 root2.walk(function(i2) {
10771 if (i2.nodes && i2.nodes.length > 0) {
10772 if (typeof i2.raws.after !== "undefined") {
10773 value = i2.raws.after;
10774 if (value.includes("\n")) {
10775 value = value.replace(/[^\n]+$/, "");
10776 }
10777 return false;
10778 }
10779 }
10780 });
10781 if (value) value = value.replace(/\S/g, "");
10782 return value;
10783 };
10784 _proto.rawBeforeComment = function rawBeforeComment(root2, node2) {
10785 var value;
10786 root2.walkComments(function(i2) {
10787 if (typeof i2.raws.before !== "undefined") {
10788 value = i2.raws.before;
10789 if (value.includes("\n")) {
10790 value = value.replace(/[^\n]+$/, "");
10791 }
10792 return false;
10793 }
10794 });
10795 if (typeof value === "undefined") {
10796 value = this.raw(node2, null, "beforeDecl");
10797 } else if (value) {
10798 value = value.replace(/\S/g, "");
10799 }
10800 return value;
10801 };
10802 _proto.rawBeforeDecl = function rawBeforeDecl(root2, node2) {
10803 var value;
10804 root2.walkDecls(function(i2) {
10805 if (typeof i2.raws.before !== "undefined") {
10806 value = i2.raws.before;
10807 if (value.includes("\n")) {
10808 value = value.replace(/[^\n]+$/, "");
10809 }
10810 return false;
10811 }
10812 });
10813 if (typeof value === "undefined") {
10814 value = this.raw(node2, null, "beforeRule");
10815 } else if (value) {
10816 value = value.replace(/\S/g, "");
10817 }
10818 return value;
10819 };
10820 _proto.rawBeforeOpen = function rawBeforeOpen(root2) {
10821 var value;
10822 root2.walk(function(i2) {
10823 if (i2.type !== "decl") {
10824 value = i2.raws.between;
10825 if (typeof value !== "undefined") return false;
10826 }
10827 });
10828 return value;
10829 };
10830 _proto.rawBeforeRule = function rawBeforeRule(root2) {
10831 var value;
10832 root2.walk(function(i2) {
10833 if (i2.nodes && (i2.parent !== root2 || root2.first !== i2)) {
10834 if (typeof i2.raws.before !== "undefined") {
10835 value = i2.raws.before;
10836 if (value.includes("\n")) {
10837 value = value.replace(/[^\n]+$/, "");
10838 }
10839 return false;
10840 }
10841 }
10842 });
10843 if (value) value = value.replace(/\S/g, "");
10844 return value;
10845 };
10846 _proto.rawColon = function rawColon(root2) {
10847 var value;
10848 root2.walkDecls(function(i2) {
10849 if (typeof i2.raws.between !== "undefined") {
10850 value = i2.raws.between.replace(/[^\s:]/g, "");
10851 return false;
10852 }
10853 });
10854 return value;
10855 };
10856 _proto.rawEmptyBody = function rawEmptyBody(root2) {
10857 var value;
10858 root2.walk(function(i2) {
10859 if (i2.nodes && i2.nodes.length === 0) {
10860 value = i2.raws.after;
10861 if (typeof value !== "undefined") return false;
10862 }
10863 });
10864 return value;
10865 };
10866 _proto.rawIndent = function rawIndent(root2) {
10867 if (root2.raws.indent) return root2.raws.indent;
10868 var value;
10869 root2.walk(function(i2) {
10870 var p = i2.parent;
10871 if (p && p !== root2 && p.parent && p.parent === root2) {
10872 if (typeof i2.raws.before !== "undefined") {
10873 var parts = i2.raws.before.split("\n");
10874 value = parts[parts.length - 1];
10875 value = value.replace(/\S/g, "");
10876 return false;
10877 }
10878 }
10879 });
10880 return value;
10881 };
10882 _proto.rawSemicolon = function rawSemicolon(root2) {
10883 var value;
10884 root2.walk(function(i2) {
10885 if (i2.nodes && i2.nodes.length && i2.last.type === "decl") {
10886 value = i2.raws.semicolon;
10887 if (typeof value !== "undefined") return false;
10888 }
10889 });
10890 return value;
10891 };
10892 _proto.rawValue = function rawValue(node2, prop) {
10893 var value = node2[prop];
10894 var raw = node2.raws[prop];
10895 if (raw && raw.value === value) {
10896 return raw.raw;
10897 }
10898 return value;
10899 };
10900 _proto.root = function root(node2) {
10901 this.body(node2);
10902 if (node2.raws.after) this.builder(node2.raws.after);
10903 };
10904 _proto.rule = function rule(node2) {
10905 this.block(node2, this.rawValue(node2, "selector"));
10906 if (node2.raws.ownSemicolon) {
10907 this.builder(node2.raws.ownSemicolon, node2, "end");
10908 }
10909 };
10910 _proto.stringify = function stringify(node2, semicolon) {
10911 if (!this[node2.type]) {
10912 throw new Error("Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier.");
10913 }
10914 this[node2.type](node2, semicolon);
10915 };
10916 return Stringifier;
10917 }();
10918 var stringifier$1 = Stringifier$2$1;
10919 Stringifier$2$1.default = Stringifier$2$1;
10920 var Stringifier$1$1 = stringifier$1;
10921 function stringify$4$1(node2, builder) {
10922 var str = new Stringifier$1$1(builder);
10923 str.stringify(node2);
10924 }
10925 var stringify_1$1 = stringify$4$1;
10926 stringify$4$1.default = stringify$4$1;
10927 var isClean$2$1 = symbols$1.isClean, my$2$1 = symbols$1.my;
10928 var CssSyntaxError$2$1 = cssSyntaxError$1;
10929 var Stringifier2$1 = stringifier$1;
10930 var stringify$3$1 = stringify_1$1;
10931 function cloneNode$1(obj, parent) {
10932 var cloned = new obj.constructor();
10933 for(var i2 in obj){
10934 if (!Object.prototype.hasOwnProperty.call(obj, i2)) {
10935 continue;
10936 }
10937 if (i2 === "proxyCache") continue;
10938 var value = obj[i2];
10939 var type = typeof value === "undefined" ? "undefined" : _type_of(value);
10940 if (i2 === "parent" && type === "object") {
10941 if (parent) cloned[i2] = parent;
10942 } else if (i2 === "source") {
10943 cloned[i2] = value;
10944 } else if (Array.isArray(value)) {
10945 cloned[i2] = value.map(function(j) {
10946 return cloneNode$1(j, cloned);
10947 });
10948 } else {
10949 if (type === "object" && value !== null) value = cloneNode$1(value);
10950 cloned[i2] = value;
10951 }
10952 }
10953 return cloned;
10954 }
10955 var Node$4$1 = /*#__PURE__*/ function() {
10956 function Node2(defaults) {
10957 if (defaults === void 0) defaults = {};
10958 this.raws = {};
10959 this[isClean$2$1] = false;
10960 this[my$2$1] = true;
10961 for(var name in defaults){
10962 if (name === "nodes") {
10963 this.nodes = [];
10964 for(var _iterator = _create_for_of_iterator_helper_loose(defaults[name]), _step; !(_step = _iterator()).done;){
10965 var node2 = _step.value;
10966 if (typeof node2.clone === "function") {
10967 this.append(node2.clone());
10968 } else {
10969 this.append(node2);
10970 }
10971 }
10972 } else {
10973 this[name] = defaults[name];
10974 }
10975 }
10976 }
10977 var _proto = Node2.prototype;
10978 _proto.addToError = function addToError(error) {
10979 error.postcssNode = this;
10980 if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
10981 var s2 = this.source;
10982 error.stack = error.stack.replace(/\n\s{4}at /, "$&" + s2.input.from + ":" + s2.start.line + ":" + s2.start.column + "$&");
10983 }
10984 return error;
10985 };
10986 _proto.after = function after(add) {
10987 this.parent.insertAfter(this, add);
10988 return this;
10989 };
10990 _proto.assign = function assign(overrides) {
10991 if (overrides === void 0) overrides = {};
10992 for(var name in overrides){
10993 this[name] = overrides[name];
10994 }
10995 return this;
10996 };
10997 _proto.before = function before(add) {
10998 this.parent.insertBefore(this, add);
10999 return this;
11000 };
11001 _proto.cleanRaws = function cleanRaws(keepBetween) {
11002 delete this.raws.before;
11003 delete this.raws.after;
11004 if (!keepBetween) delete this.raws.between;
11005 };
11006 _proto.clone = function clone(overrides) {
11007 if (overrides === void 0) overrides = {};
11008 var cloned = cloneNode$1(this);
11009 for(var name in overrides){
11010 cloned[name] = overrides[name];
11011 }
11012 return cloned;
11013 };
11014 _proto.cloneAfter = function cloneAfter(overrides) {
11015 if (overrides === void 0) overrides = {};
11016 var cloned = this.clone(overrides);
11017 this.parent.insertAfter(this, cloned);
11018 return cloned;
11019 };
11020 _proto.cloneBefore = function cloneBefore(overrides) {
11021 if (overrides === void 0) overrides = {};
11022 var cloned = this.clone(overrides);
11023 this.parent.insertBefore(this, cloned);
11024 return cloned;
11025 };
11026 _proto.error = function error(message, opts) {
11027 if (opts === void 0) opts = {};
11028 if (this.source) {
11029 var _this_rangeBy = this.rangeBy(opts), end = _this_rangeBy.end, start = _this_rangeBy.start;
11030 return this.source.input.error(message, {
11031 column: start.column,
11032 line: start.line
11033 }, {
11034 column: end.column,
11035 line: end.line
11036 }, opts);
11037 }
11038 return new CssSyntaxError$2$1(message);
11039 };
11040 _proto.getProxyProcessor = function getProxyProcessor() {
11041 return {
11042 get: function get(node2, prop) {
11043 if (prop === "proxyOf") {
11044 return node2;
11045 } else if (prop === "root") {
11046 return function() {
11047 return node2.root().toProxy();
11048 };
11049 } else {
11050 return node2[prop];
11051 }
11052 },
11053 set: function set(node2, prop, value) {
11054 if (node2[prop] === value) return true;
11055 node2[prop] = value;
11056 if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ prop === "text") {
11057 node2.markDirty();
11058 }
11059 return true;
11060 }
11061 };
11062 };
11063 _proto.markDirty = function markDirty() {
11064 if (this[isClean$2$1]) {
11065 this[isClean$2$1] = false;
11066 var next = this;
11067 while(next = next.parent){
11068 next[isClean$2$1] = false;
11069 }
11070 }
11071 };
11072 _proto.next = function next() {
11073 if (!this.parent) return void 0;
11074 var index2 = this.parent.index(this);
11075 return this.parent.nodes[index2 + 1];
11076 };
11077 _proto.positionBy = function positionBy(opts, stringRepresentation) {
11078 var pos = this.source.start;
11079 if (opts.index) {
11080 pos = this.positionInside(opts.index, stringRepresentation);
11081 } else if (opts.word) {
11082 stringRepresentation = this.toString();
11083 var index2 = stringRepresentation.indexOf(opts.word);
11084 if (index2 !== -1) pos = this.positionInside(index2, stringRepresentation);
11085 }
11086 return pos;
11087 };
11088 _proto.positionInside = function positionInside(index2, stringRepresentation) {
11089 var string = stringRepresentation || this.toString();
11090 var column = this.source.start.column;
11091 var line = this.source.start.line;
11092 for(var i2 = 0; i2 < index2; i2++){
11093 if (string[i2] === "\n") {
11094 column = 1;
11095 line += 1;
11096 } else {
11097 column += 1;
11098 }
11099 }
11100 return {
11101 column: column,
11102 line: line
11103 };
11104 };
11105 _proto.prev = function prev() {
11106 if (!this.parent) return void 0;
11107 var index2 = this.parent.index(this);
11108 return this.parent.nodes[index2 - 1];
11109 };
11110 _proto.rangeBy = function rangeBy(opts) {
11111 var start = {
11112 column: this.source.start.column,
11113 line: this.source.start.line
11114 };
11115 var end = this.source.end ? {
11116 column: this.source.end.column + 1,
11117 line: this.source.end.line
11118 } : {
11119 column: start.column + 1,
11120 line: start.line
11121 };
11122 if (opts.word) {
11123 var stringRepresentation = this.toString();
11124 var index2 = stringRepresentation.indexOf(opts.word);
11125 if (index2 !== -1) {
11126 start = this.positionInside(index2, stringRepresentation);
11127 end = this.positionInside(index2 + opts.word.length, stringRepresentation);
11128 }
11129 } else {
11130 if (opts.start) {
11131 start = {
11132 column: opts.start.column,
11133 line: opts.start.line
11134 };
11135 } else if (opts.index) {
11136 start = this.positionInside(opts.index);
11137 }
11138 if (opts.end) {
11139 end = {
11140 column: opts.end.column,
11141 line: opts.end.line
11142 };
11143 } else if (typeof opts.endIndex === "number") {
11144 end = this.positionInside(opts.endIndex);
11145 } else if (opts.index) {
11146 end = this.positionInside(opts.index + 1);
11147 }
11148 }
11149 if (end.line < start.line || end.line === start.line && end.column <= start.column) {
11150 end = {
11151 column: start.column + 1,
11152 line: start.line
11153 };
11154 }
11155 return {
11156 end: end,
11157 start: start
11158 };
11159 };
11160 _proto.raw = function raw(prop, defaultType) {
11161 var str = new Stringifier2$1();
11162 return str.raw(this, prop, defaultType);
11163 };
11164 _proto.remove = function remove() {
11165 if (this.parent) {
11166 this.parent.removeChild(this);
11167 }
11168 this.parent = void 0;
11169 return this;
11170 };
11171 _proto.replaceWith = function replaceWith() {
11172 for(var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++){
11173 nodes[_key] = arguments[_key];
11174 }
11175 if (this.parent) {
11176 var bookmark = this;
11177 var foundSelf = false;
11178 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
11179 var node2 = _step.value;
11180 if (node2 === this) {
11181 foundSelf = true;
11182 } else if (foundSelf) {
11183 this.parent.insertAfter(bookmark, node2);
11184 bookmark = node2;
11185 } else {
11186 this.parent.insertBefore(bookmark, node2);
11187 }
11188 }
11189 if (!foundSelf) {
11190 this.remove();
11191 }
11192 }
11193 return this;
11194 };
11195 _proto.root = function root() {
11196 var result2 = this;
11197 while(result2.parent && result2.parent.type !== "document"){
11198 result2 = result2.parent;
11199 }
11200 return result2;
11201 };
11202 _proto.toJSON = function toJSON(_, inputs) {
11203 var fixed = {};
11204 var emitInputs = inputs == null;
11205 inputs = inputs || /* @__PURE__ */ new Map();
11206 var inputsNextIndex = 0;
11207 for(var name in this){
11208 if (!Object.prototype.hasOwnProperty.call(this, name)) {
11209 continue;
11210 }
11211 if (name === "parent" || name === "proxyCache") continue;
11212 var value = this[name];
11213 if (Array.isArray(value)) {
11214 fixed[name] = value.map(function(i2) {
11215 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.toJSON) {
11216 return i2.toJSON(null, inputs);
11217 } else {
11218 return i2;
11219 }
11220 });
11221 } else if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value.toJSON) {
11222 fixed[name] = value.toJSON(null, inputs);
11223 } else if (name === "source") {
11224 var inputId = inputs.get(value.input);
11225 if (inputId == null) {
11226 inputId = inputsNextIndex;
11227 inputs.set(value.input, inputsNextIndex);
11228 inputsNextIndex++;
11229 }
11230 fixed[name] = {
11231 end: value.end,
11232 inputId: inputId,
11233 start: value.start
11234 };
11235 } else {
11236 fixed[name] = value;
11237 }
11238 }
11239 if (emitInputs) {
11240 fixed.inputs = [].concat(inputs.keys()).map(function(input2) {
11241 return input2.toJSON();
11242 });
11243 }
11244 return fixed;
11245 };
11246 _proto.toProxy = function toProxy() {
11247 if (!this.proxyCache) {
11248 this.proxyCache = new Proxy(this, this.getProxyProcessor());
11249 }
11250 return this.proxyCache;
11251 };
11252 _proto.toString = function toString(stringifier2) {
11253 if (stringifier2 === void 0) stringifier2 = stringify$3$1;
11254 if (stringifier2.stringify) stringifier2 = stringifier2.stringify;
11255 var result2 = "";
11256 stringifier2(this, function(i2) {
11257 result2 += i2;
11258 });
11259 return result2;
11260 };
11261 _proto.warn = function warn(result2, text, opts) {
11262 var data = {
11263 node: this
11264 };
11265 for(var i2 in opts)data[i2] = opts[i2];
11266 return result2.warn(text, data);
11267 };
11268 _create_class(Node2, [
11269 {
11270 key: "proxyOf",
11271 get: function get() {
11272 return this;
11273 }
11274 }
11275 ]);
11276 return Node2;
11277 }();
11278 var node$1 = Node$4$1;
11279 Node$4$1.default = Node$4$1;
11280 var Node$3$1 = node$1;
11281 var Declaration$4$1 = /*#__PURE__*/ function(Node$3$1) {
11282 _inherits(Declaration, Node$3$1);
11283 function Declaration(defaults) {
11284 var _this;
11285 if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
11286 defaults = _extends({}, defaults, {
11287 value: String(defaults.value)
11288 });
11289 }
11290 _this = Node$3$1.call(this, defaults) || this;
11291 _this.type = "decl";
11292 return _this;
11293 }
11294 _create_class(Declaration, [
11295 {
11296 key: "variable",
11297 get: function get() {
11298 return this.prop.startsWith("--") || this.prop[0] === "$";
11299 }
11300 }
11301 ]);
11302 return Declaration;
11303 }(Node$3$1);
11304 var declaration$1 = Declaration$4$1;
11305 Declaration$4$1.default = Declaration$4$1;
11306 var urlAlphabet$1 = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
11307 var nanoid$1$1 = function(size) {
11308 if (size === void 0) size = 21;
11309 var id = "";
11310 var i2 = size;
11311 while(i2--){
11312 id += urlAlphabet$1[Math.random() * 64 | 0];
11313 }
11314 return id;
11315 };
11316 var nonSecure$1 = {
11317 nanoid: nanoid$1$1};
11318 var SourceMapConsumer$2$1 = require$$2$1.SourceMapConsumer, SourceMapGenerator$2$1 = require$$2$1.SourceMapGenerator;
11319 var existsSync$1 = require$$2$1.existsSync, readFileSync$1 = require$$2$1.readFileSync;
11320 var dirname$1$1 = require$$2$1.dirname, join$1 = require$$2$1.join;
11321 function fromBase64$1(str) {
11322 if (Buffer) {
11323 return Buffer.from(str, "base64").toString();
11324 } else {
11325 return window.atob(str);
11326 }
11327 }
11328 var PreviousMap$2$1 = /*#__PURE__*/ function() {
11329 function PreviousMap(css, opts) {
11330 if (opts.map === false) return;
11331 this.loadAnnotation(css);
11332 this.inline = this.startWith(this.annotation, "data:");
11333 var prev = opts.map ? opts.map.prev : void 0;
11334 var text = this.loadMap(opts.from, prev);
11335 if (!this.mapFile && opts.from) {
11336 this.mapFile = opts.from;
11337 }
11338 if (this.mapFile) this.root = dirname$1$1(this.mapFile);
11339 if (text) this.text = text;
11340 }
11341 var _proto = PreviousMap.prototype;
11342 _proto.consumer = function consumer() {
11343 if (!this.consumerCache) {
11344 this.consumerCache = new SourceMapConsumer$2$1(this.text);
11345 }
11346 return this.consumerCache;
11347 };
11348 _proto.decodeInline = function decodeInline(text) {
11349 var baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
11350 var baseUri = /^data:application\/json;base64,/;
11351 var charsetUri = /^data:application\/json;charset=utf-?8,/;
11352 var uri = /^data:application\/json,/;
11353 if (charsetUri.test(text) || uri.test(text)) {
11354 return decodeURIComponent(text.substr(RegExp.lastMatch.length));
11355 }
11356 if (baseCharsetUri.test(text) || baseUri.test(text)) {
11357 return fromBase64$1(text.substr(RegExp.lastMatch.length));
11358 }
11359 var encoding = text.match(/data:application\/json;([^,]+),/)[1];
11360 throw new Error("Unsupported source map encoding " + encoding);
11361 };
11362 _proto.getAnnotationURL = function getAnnotationURL(sourceMapString) {
11363 return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
11364 };
11365 _proto.isMap = function isMap(map) {
11366 if ((typeof map === "undefined" ? "undefined" : _type_of(map)) !== "object") return false;
11367 return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
11368 };
11369 _proto.loadAnnotation = function loadAnnotation(css) {
11370 var comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
11371 if (!comments) return;
11372 var start = css.lastIndexOf(comments.pop());
11373 var end = css.indexOf("*/", start);
11374 if (start > -1 && end > -1) {
11375 this.annotation = this.getAnnotationURL(css.substring(start, end));
11376 }
11377 };
11378 _proto.loadFile = function loadFile(path) {
11379 this.root = dirname$1$1(path);
11380 if (existsSync$1(path)) {
11381 this.mapFile = path;
11382 return readFileSync$1(path, "utf-8").toString().trim();
11383 }
11384 };
11385 _proto.loadMap = function loadMap(file, prev) {
11386 if (prev === false) return false;
11387 if (prev) {
11388 if (typeof prev === "string") {
11389 return prev;
11390 } else if (typeof prev === "function") {
11391 var prevPath = prev(file);
11392 if (prevPath) {
11393 var map = this.loadFile(prevPath);
11394 if (!map) {
11395 throw new Error("Unable to load previous source map: " + prevPath.toString());
11396 }
11397 return map;
11398 }
11399 } else if (_instanceof(prev, SourceMapConsumer$2$1)) {
11400 return SourceMapGenerator$2$1.fromSourceMap(prev).toString();
11401 } else if (_instanceof(prev, SourceMapGenerator$2$1)) {
11402 return prev.toString();
11403 } else if (this.isMap(prev)) {
11404 return JSON.stringify(prev);
11405 } else {
11406 throw new Error("Unsupported previous source map format: " + prev.toString());
11407 }
11408 } else if (this.inline) {
11409 return this.decodeInline(this.annotation);
11410 } else if (this.annotation) {
11411 var map1 = this.annotation;
11412 if (file) map1 = join$1(dirname$1$1(file), map1);
11413 return this.loadFile(map1);
11414 }
11415 };
11416 _proto.startWith = function startWith(string, start) {
11417 if (!string) return false;
11418 return string.substr(0, start.length) === start;
11419 };
11420 _proto.withContent = function withContent() {
11421 return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
11422 };
11423 return PreviousMap;
11424 }();
11425 var previousMap$1 = PreviousMap$2$1;
11426 PreviousMap$2$1.default = PreviousMap$2$1;
11427 var SourceMapConsumer$1$1 = require$$2$1.SourceMapConsumer, SourceMapGenerator$1$1 = require$$2$1.SourceMapGenerator;
11428 var fileURLToPath$1 = require$$2$1.fileURLToPath, pathToFileURL$1$1 = require$$2$1.pathToFileURL;
11429 var isAbsolute$1 = require$$2$1.isAbsolute, resolve$1$1 = require$$2$1.resolve;
11430 var nanoid$2 = nonSecure$1.nanoid;
11431 var terminalHighlight$2 = require$$2$1;
11432 var CssSyntaxError$1$1 = cssSyntaxError$1;
11433 var PreviousMap$1$1 = previousMap$1;
11434 var fromOffsetCache$1 = Symbol("fromOffsetCache");
11435 var sourceMapAvailable$1$1 = Boolean(SourceMapConsumer$1$1 && SourceMapGenerator$1$1);
11436 var pathAvailable$1$1 = Boolean(resolve$1$1 && isAbsolute$1);
11437 var Input$4$1 = /*#__PURE__*/ function() {
11438 function Input(css, opts) {
11439 if (opts === void 0) opts = {};
11440 if (css === null || typeof css === "undefined" || (typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && !css.toString) {
11441 throw new Error("PostCSS received " + css + " instead of CSS string");
11442 }
11443 this.css = css.toString();
11444 if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
11445 this.hasBOM = true;
11446 this.css = this.css.slice(1);
11447 } else {
11448 this.hasBOM = false;
11449 }
11450 if (opts.from) {
11451 if (!pathAvailable$1$1 || /^\w+:\/\//.test(opts.from) || isAbsolute$1(opts.from)) {
11452 this.file = opts.from;
11453 } else {
11454 this.file = resolve$1$1(opts.from);
11455 }
11456 }
11457 if (pathAvailable$1$1 && sourceMapAvailable$1$1) {
11458 var map = new PreviousMap$1$1(this.css, opts);
11459 if (map.text) {
11460 this.map = map;
11461 var file = map.consumer().file;
11462 if (!this.file && file) this.file = this.mapResolve(file);
11463 }
11464 }
11465 if (!this.file) {
11466 this.id = "<input css " + nanoid$2(6) + ">";
11467 }
11468 if (this.map) this.map.file = this.from;
11469 }
11470 var _proto = Input.prototype;
11471 _proto.error = function error(message, line, column, opts) {
11472 if (opts === void 0) opts = {};
11473 var result2, endLine, endColumn;
11474 if (line && (typeof line === "undefined" ? "undefined" : _type_of(line)) === "object") {
11475 var start = line;
11476 var end = column;
11477 if (typeof start.offset === "number") {
11478 var pos = this.fromOffset(start.offset);
11479 line = pos.line;
11480 column = pos.col;
11481 } else {
11482 line = start.line;
11483 column = start.column;
11484 }
11485 if (typeof end.offset === "number") {
11486 var pos1 = this.fromOffset(end.offset);
11487 endLine = pos1.line;
11488 endColumn = pos1.col;
11489 } else {
11490 endLine = end.line;
11491 endColumn = end.column;
11492 }
11493 } else if (!column) {
11494 var pos2 = this.fromOffset(line);
11495 line = pos2.line;
11496 column = pos2.col;
11497 }
11498 var origin = this.origin(line, column, endLine, endColumn);
11499 if (origin) {
11500 result2 = new CssSyntaxError$1$1(message, origin.endLine === void 0 ? origin.line : {
11501 column: origin.column,
11502 line: origin.line
11503 }, origin.endLine === void 0 ? origin.column : {
11504 column: origin.endColumn,
11505 line: origin.endLine
11506 }, origin.source, origin.file, opts.plugin);
11507 } else {
11508 result2 = new CssSyntaxError$1$1(message, endLine === void 0 ? line : {
11509 column: column,
11510 line: line
11511 }, endLine === void 0 ? column : {
11512 column: endColumn,
11513 line: endLine
11514 }, this.css, this.file, opts.plugin);
11515 }
11516 result2.input = {
11517 column: column,
11518 endColumn: endColumn,
11519 endLine: endLine,
11520 line: line,
11521 source: this.css
11522 };
11523 if (this.file) {
11524 if (pathToFileURL$1$1) {
11525 result2.input.url = pathToFileURL$1$1(this.file).toString();
11526 }
11527 result2.input.file = this.file;
11528 }
11529 return result2;
11530 };
11531 _proto.fromOffset = function fromOffset(offset) {
11532 var lastLine, lineToIndex;
11533 if (!this[fromOffsetCache$1]) {
11534 var lines = this.css.split("\n");
11535 lineToIndex = new Array(lines.length);
11536 var prevIndex = 0;
11537 for(var i2 = 0, l2 = lines.length; i2 < l2; i2++){
11538 lineToIndex[i2] = prevIndex;
11539 prevIndex += lines[i2].length + 1;
11540 }
11541 this[fromOffsetCache$1] = lineToIndex;
11542 } else {
11543 lineToIndex = this[fromOffsetCache$1];
11544 }
11545 lastLine = lineToIndex[lineToIndex.length - 1];
11546 var min = 0;
11547 if (offset >= lastLine) {
11548 min = lineToIndex.length - 1;
11549 } else {
11550 var max = lineToIndex.length - 2;
11551 var mid;
11552 while(min < max){
11553 mid = min + (max - min >> 1);
11554 if (offset < lineToIndex[mid]) {
11555 max = mid - 1;
11556 } else if (offset >= lineToIndex[mid + 1]) {
11557 min = mid + 1;
11558 } else {
11559 min = mid;
11560 break;
11561 }
11562 }
11563 }
11564 return {
11565 col: offset - lineToIndex[min] + 1,
11566 line: min + 1
11567 };
11568 };
11569 _proto.mapResolve = function mapResolve(file) {
11570 if (/^\w+:\/\//.test(file)) {
11571 return file;
11572 }
11573 return resolve$1$1(this.map.consumer().sourceRoot || this.map.root || ".", file);
11574 };
11575 _proto.origin = function origin(line, column, endLine, endColumn) {
11576 if (!this.map) return false;
11577 var consumer = this.map.consumer();
11578 var from = consumer.originalPositionFor({
11579 column: column,
11580 line: line
11581 });
11582 if (!from.source) return false;
11583 var to;
11584 if (typeof endLine === "number") {
11585 to = consumer.originalPositionFor({
11586 column: endColumn,
11587 line: endLine
11588 });
11589 }
11590 var fromUrl;
11591 if (isAbsolute$1(from.source)) {
11592 fromUrl = pathToFileURL$1$1(from.source);
11593 } else {
11594 fromUrl = new URL(from.source, this.map.consumer().sourceRoot || pathToFileURL$1$1(this.map.mapFile));
11595 }
11596 var result2 = {
11597 column: from.column,
11598 endColumn: to && to.column,
11599 endLine: to && to.line,
11600 line: from.line,
11601 url: fromUrl.toString()
11602 };
11603 if (fromUrl.protocol === "file:") {
11604 if (fileURLToPath$1) {
11605 result2.file = fileURLToPath$1(fromUrl);
11606 } else {
11607 throw new Error("file: protocol is not available in this PostCSS build");
11608 }
11609 }
11610 var source = consumer.sourceContentFor(from.source);
11611 if (source) result2.source = source;
11612 return result2;
11613 };
11614 _proto.toJSON = function toJSON() {
11615 var json = {};
11616 for(var _i = 0, _iter = [
11617 "hasBOM",
11618 "css",
11619 "file",
11620 "id"
11621 ]; _i < _iter.length; _i++){
11622 var name = _iter[_i];
11623 if (this[name] != null) {
11624 json[name] = this[name];
11625 }
11626 }
11627 if (this.map) {
11628 json.map = _extends({}, this.map);
11629 if (json.map.consumerCache) {
11630 json.map.consumerCache = void 0;
11631 }
11632 }
11633 return json;
11634 };
11635 _create_class(Input, [
11636 {
11637 key: "from",
11638 get: function get() {
11639 return this.file || this.id;
11640 }
11641 }
11642 ]);
11643 return Input;
11644 }();
11645 var input$1 = Input$4$1;
11646 Input$4$1.default = Input$4$1;
11647 if (terminalHighlight$2 && terminalHighlight$2.registerInput) {
11648 terminalHighlight$2.registerInput(Input$4$1);
11649 }
11650 var SourceMapConsumer$3 = require$$2$1.SourceMapConsumer, SourceMapGenerator$3 = require$$2$1.SourceMapGenerator;
11651 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;
11652 var pathToFileURL$2 = require$$2$1.pathToFileURL;
11653 var Input$3$1 = input$1;
11654 var sourceMapAvailable$2 = Boolean(SourceMapConsumer$3 && SourceMapGenerator$3);
11655 var pathAvailable$2 = Boolean(dirname$2 && resolve$2 && relative$1 && sep$1);
11656 var MapGenerator$2$1 = /*#__PURE__*/ function() {
11657 function MapGenerator(stringify2, root2, opts, cssString) {
11658 this.stringify = stringify2;
11659 this.mapOpts = opts.map || {};
11660 this.root = root2;
11661 this.opts = opts;
11662 this.css = cssString;
11663 this.originalCSS = cssString;
11664 this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
11665 this.memoizedFileURLs = /* @__PURE__ */ new Map();
11666 this.memoizedPaths = /* @__PURE__ */ new Map();
11667 this.memoizedURLs = /* @__PURE__ */ new Map();
11668 }
11669 var _proto = MapGenerator.prototype;
11670 _proto.addAnnotation = function addAnnotation() {
11671 var content;
11672 if (this.isInline()) {
11673 content = "data:application/json;base64," + this.toBase64(this.map.toString());
11674 } else if (typeof this.mapOpts.annotation === "string") {
11675 content = this.mapOpts.annotation;
11676 } else if (typeof this.mapOpts.annotation === "function") {
11677 content = this.mapOpts.annotation(this.opts.to, this.root);
11678 } else {
11679 content = this.outputFile() + ".map";
11680 }
11681 var eol = "\n";
11682 if (this.css.includes("\r\n")) eol = "\r\n";
11683 this.css += eol + "/*# sourceMappingURL=" + content + " */";
11684 };
11685 _proto.applyPrevMaps = function applyPrevMaps() {
11686 for(var _iterator = _create_for_of_iterator_helper_loose(this.previous()), _step; !(_step = _iterator()).done;){
11687 var prev = _step.value;
11688 var from = this.toUrl(this.path(prev.file));
11689 var root2 = prev.root || dirname$2(prev.file);
11690 var map = void 0;
11691 if (this.mapOpts.sourcesContent === false) {
11692 map = new SourceMapConsumer$3(prev.text);
11693 if (map.sourcesContent) {
11694 map.sourcesContent = null;
11695 }
11696 } else {
11697 map = prev.consumer();
11698 }
11699 this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
11700 }
11701 };
11702 _proto.clearAnnotation = function clearAnnotation() {
11703 if (this.mapOpts.annotation === false) return;
11704 if (this.root) {
11705 var node2;
11706 for(var i2 = this.root.nodes.length - 1; i2 >= 0; i2--){
11707 node2 = this.root.nodes[i2];
11708 if (node2.type !== "comment") continue;
11709 if (node2.text.indexOf("# sourceMappingURL=") === 0) {
11710 this.root.removeChild(i2);
11711 }
11712 }
11713 } else if (this.css) {
11714 this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, "");
11715 }
11716 };
11717 _proto.generate = function generate() {
11718 this.clearAnnotation();
11719 if (pathAvailable$2 && sourceMapAvailable$2 && this.isMap()) {
11720 return this.generateMap();
11721 } else {
11722 var result2 = "";
11723 this.stringify(this.root, function(i2) {
11724 result2 += i2;
11725 });
11726 return [
11727 result2
11728 ];
11729 }
11730 };
11731 _proto.generateMap = function generateMap() {
11732 if (this.root) {
11733 this.generateString();
11734 } else if (this.previous().length === 1) {
11735 var prev = this.previous()[0].consumer();
11736 prev.file = this.outputFile();
11737 this.map = SourceMapGenerator$3.fromSourceMap(prev, {
11738 ignoreInvalidMapping: true
11739 });
11740 } else {
11741 this.map = new SourceMapGenerator$3({
11742 file: this.outputFile(),
11743 ignoreInvalidMapping: true
11744 });
11745 this.map.addMapping({
11746 generated: {
11747 column: 0,
11748 line: 1
11749 },
11750 original: {
11751 column: 0,
11752 line: 1
11753 },
11754 source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
11755 });
11756 }
11757 if (this.isSourcesContent()) this.setSourcesContent();
11758 if (this.root && this.previous().length > 0) this.applyPrevMaps();
11759 if (this.isAnnotation()) this.addAnnotation();
11760 if (this.isInline()) {
11761 return [
11762 this.css
11763 ];
11764 } else {
11765 return [
11766 this.css,
11767 this.map
11768 ];
11769 }
11770 };
11771 _proto.generateString = function generateString() {
11772 var _this = this;
11773 this.css = "";
11774 this.map = new SourceMapGenerator$3({
11775 file: this.outputFile(),
11776 ignoreInvalidMapping: true
11777 });
11778 var line = 1;
11779 var column = 1;
11780 var noSource = "<no source>";
11781 var mapping = {
11782 generated: {
11783 column: 0,
11784 line: 0
11785 },
11786 original: {
11787 column: 0,
11788 line: 0
11789 },
11790 source: ""
11791 };
11792 var lines, last;
11793 this.stringify(this.root, function(str, node2, type) {
11794 _this.css += str;
11795 if (node2 && type !== "end") {
11796 mapping.generated.line = line;
11797 mapping.generated.column = column - 1;
11798 if (node2.source && node2.source.start) {
11799 mapping.source = _this.sourcePath(node2);
11800 mapping.original.line = node2.source.start.line;
11801 mapping.original.column = node2.source.start.column - 1;
11802 _this.map.addMapping(mapping);
11803 } else {
11804 mapping.source = noSource;
11805 mapping.original.line = 1;
11806 mapping.original.column = 0;
11807 _this.map.addMapping(mapping);
11808 }
11809 }
11810 lines = str.match(/\n/g);
11811 if (lines) {
11812 line += lines.length;
11813 last = str.lastIndexOf("\n");
11814 column = str.length - last;
11815 } else {
11816 column += str.length;
11817 }
11818 if (node2 && type !== "start") {
11819 var p = node2.parent || {
11820 raws: {}
11821 };
11822 var childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
11823 if (!childless || node2 !== p.last || p.raws.semicolon) {
11824 if (node2.source && node2.source.end) {
11825 mapping.source = _this.sourcePath(node2);
11826 mapping.original.line = node2.source.end.line;
11827 mapping.original.column = node2.source.end.column - 1;
11828 mapping.generated.line = line;
11829 mapping.generated.column = column - 2;
11830 _this.map.addMapping(mapping);
11831 } else {
11832 mapping.source = noSource;
11833 mapping.original.line = 1;
11834 mapping.original.column = 0;
11835 mapping.generated.line = line;
11836 mapping.generated.column = column - 1;
11837 _this.map.addMapping(mapping);
11838 }
11839 }
11840 }
11841 });
11842 };
11843 _proto.isAnnotation = function isAnnotation() {
11844 if (this.isInline()) {
11845 return true;
11846 }
11847 if (typeof this.mapOpts.annotation !== "undefined") {
11848 return this.mapOpts.annotation;
11849 }
11850 if (this.previous().length) {
11851 return this.previous().some(function(i2) {
11852 return i2.annotation;
11853 });
11854 }
11855 return true;
11856 };
11857 _proto.isInline = function isInline() {
11858 if (typeof this.mapOpts.inline !== "undefined") {
11859 return this.mapOpts.inline;
11860 }
11861 var annotation = this.mapOpts.annotation;
11862 if (typeof annotation !== "undefined" && annotation !== true) {
11863 return false;
11864 }
11865 if (this.previous().length) {
11866 return this.previous().some(function(i2) {
11867 return i2.inline;
11868 });
11869 }
11870 return true;
11871 };
11872 _proto.isMap = function isMap() {
11873 if (typeof this.opts.map !== "undefined") {
11874 return !!this.opts.map;
11875 }
11876 return this.previous().length > 0;
11877 };
11878 _proto.isSourcesContent = function isSourcesContent() {
11879 if (typeof this.mapOpts.sourcesContent !== "undefined") {
11880 return this.mapOpts.sourcesContent;
11881 }
11882 if (this.previous().length) {
11883 return this.previous().some(function(i2) {
11884 return i2.withContent();
11885 });
11886 }
11887 return true;
11888 };
11889 _proto.outputFile = function outputFile() {
11890 if (this.opts.to) {
11891 return this.path(this.opts.to);
11892 } else if (this.opts.from) {
11893 return this.path(this.opts.from);
11894 } else {
11895 return "to.css";
11896 }
11897 };
11898 _proto.path = function path(file) {
11899 if (this.mapOpts.absolute) return file;
11900 if (file.charCodeAt(0) === 60) return file;
11901 if (/^\w+:\/\//.test(file)) return file;
11902 var cached = this.memoizedPaths.get(file);
11903 if (cached) return cached;
11904 var from = this.opts.to ? dirname$2(this.opts.to) : ".";
11905 if (typeof this.mapOpts.annotation === "string") {
11906 from = dirname$2(resolve$2(from, this.mapOpts.annotation));
11907 }
11908 var path = relative$1(from, file);
11909 this.memoizedPaths.set(file, path);
11910 return path;
11911 };
11912 _proto.previous = function previous() {
11913 var _this = this;
11914 if (!this.previousMaps) {
11915 this.previousMaps = [];
11916 if (this.root) {
11917 this.root.walk(function(node2) {
11918 if (node2.source && node2.source.input.map) {
11919 var map = node2.source.input.map;
11920 if (!_this.previousMaps.includes(map)) {
11921 _this.previousMaps.push(map);
11922 }
11923 }
11924 });
11925 } else {
11926 var input2 = new Input$3$1(this.originalCSS, this.opts);
11927 if (input2.map) this.previousMaps.push(input2.map);
11928 }
11929 }
11930 return this.previousMaps;
11931 };
11932 _proto.setSourcesContent = function setSourcesContent() {
11933 var _this = this;
11934 var already = {};
11935 if (this.root) {
11936 this.root.walk(function(node2) {
11937 if (node2.source) {
11938 var from = node2.source.input.from;
11939 if (from && !already[from]) {
11940 already[from] = true;
11941 var fromUrl = _this.usesFileUrls ? _this.toFileUrl(from) : _this.toUrl(_this.path(from));
11942 _this.map.setSourceContent(fromUrl, node2.source.input.css);
11943 }
11944 }
11945 });
11946 } else if (this.css) {
11947 var from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
11948 this.map.setSourceContent(from, this.css);
11949 }
11950 };
11951 _proto.sourcePath = function sourcePath(node2) {
11952 if (this.mapOpts.from) {
11953 return this.toUrl(this.mapOpts.from);
11954 } else if (this.usesFileUrls) {
11955 return this.toFileUrl(node2.source.input.from);
11956 } else {
11957 return this.toUrl(this.path(node2.source.input.from));
11958 }
11959 };
11960 _proto.toBase64 = function toBase64(str) {
11961 if (Buffer) {
11962 return Buffer.from(str).toString("base64");
11963 } else {
11964 return window.btoa(unescape(encodeURIComponent(str)));
11965 }
11966 };
11967 _proto.toFileUrl = function toFileUrl(path) {
11968 var cached = this.memoizedFileURLs.get(path);
11969 if (cached) return cached;
11970 if (pathToFileURL$2) {
11971 var fileURL = pathToFileURL$2(path).toString();
11972 this.memoizedFileURLs.set(path, fileURL);
11973 return fileURL;
11974 } else {
11975 throw new Error("`map.absolute` option is not available in this PostCSS build");
11976 }
11977 };
11978 _proto.toUrl = function toUrl(path) {
11979 var cached = this.memoizedURLs.get(path);
11980 if (cached) return cached;
11981 if (sep$1 === "\\") {
11982 path = path.replace(/\\/g, "/");
11983 }
11984 var url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
11985 this.memoizedURLs.set(path, url);
11986 return url;
11987 };
11988 return MapGenerator;
11989 }();
11990 var mapGenerator$1 = MapGenerator$2$1;
11991 var Node$2$1 = node$1;
11992 var Comment$4$1 = /*#__PURE__*/ function(Node$2$1) {
11993 _inherits(Comment, Node$2$1);
11994 function Comment(defaults) {
11995 var _this;
11996 _this = Node$2$1.call(this, defaults) || this;
11997 _this.type = "comment";
11998 return _this;
11999 }
12000 return Comment;
12001 }(Node$2$1);
12002 var comment$1 = Comment$4$1;
12003 Comment$4$1.default = Comment$4$1;
12004 var isClean$1$1 = symbols$1.isClean, my$1$1 = symbols$1.my;
12005 var Declaration$3$1 = declaration$1;
12006 var Comment$3$1 = comment$1;
12007 var Node$1$1 = node$1;
12008 var parse$4$1, Rule$4$1, AtRule$4$1, Root$6$1;
12009 function cleanSource$1(nodes) {
12010 return nodes.map(function(i2) {
12011 if (i2.nodes) i2.nodes = cleanSource$1(i2.nodes);
12012 delete i2.source;
12013 return i2;
12014 });
12015 }
12016 function markDirtyUp$1(node2) {
12017 node2[isClean$1$1] = false;
12018 if (node2.proxyOf.nodes) {
12019 for(var _iterator = _create_for_of_iterator_helper_loose(node2.proxyOf.nodes), _step; !(_step = _iterator()).done;){
12020 var i2 = _step.value;
12021 markDirtyUp$1(i2);
12022 }
12023 }
12024 }
12025 var Container$7$1 = /*#__PURE__*/ function(Node$1$1) {
12026 _inherits(Container, Node$1$1);
12027 function Container() {
12028 return Node$1$1.apply(this, arguments) || this;
12029 }
12030 var _proto = Container.prototype;
12031 _proto.append = function append() {
12032 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12033 children[_key] = arguments[_key];
12034 }
12035 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
12036 var child = _step.value;
12037 var nodes = this.normalize(child, this.last);
12038 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
12039 var node2 = _step1.value;
12040 this.proxyOf.nodes.push(node2);
12041 }
12042 }
12043 this.markDirty();
12044 return this;
12045 };
12046 _proto.cleanRaws = function cleanRaws(keepBetween) {
12047 Node$1$1.prototype.cleanRaws.call(this, keepBetween);
12048 if (this.nodes) {
12049 for(var _iterator = _create_for_of_iterator_helper_loose(this.nodes), _step; !(_step = _iterator()).done;){
12050 var node2 = _step.value;
12051 node2.cleanRaws(keepBetween);
12052 }
12053 }
12054 };
12055 _proto.each = function each(callback) {
12056 if (!this.proxyOf.nodes) return void 0;
12057 var iterator = this.getIterator();
12058 var index2, result2;
12059 while(this.indexes[iterator] < this.proxyOf.nodes.length){
12060 index2 = this.indexes[iterator];
12061 result2 = callback(this.proxyOf.nodes[index2], index2);
12062 if (result2 === false) break;
12063 this.indexes[iterator] += 1;
12064 }
12065 delete this.indexes[iterator];
12066 return result2;
12067 };
12068 _proto.every = function every(condition) {
12069 return this.nodes.every(condition);
12070 };
12071 _proto.getIterator = function getIterator() {
12072 if (!this.lastEach) this.lastEach = 0;
12073 if (!this.indexes) this.indexes = {};
12074 this.lastEach += 1;
12075 var iterator = this.lastEach;
12076 this.indexes[iterator] = 0;
12077 return iterator;
12078 };
12079 _proto.getProxyProcessor = function getProxyProcessor() {
12080 return {
12081 get: function get(node2, prop) {
12082 if (prop === "proxyOf") {
12083 return node2;
12084 } else if (!node2[prop]) {
12085 return node2[prop];
12086 } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
12087 return function() {
12088 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
12089 args[_key] = arguments[_key];
12090 }
12091 var _node2;
12092 return (_node2 = node2)[prop].apply(_node2, [].concat(args.map(function(i2) {
12093 if (typeof i2 === "function") {
12094 return function(child, index2) {
12095 return i2(child.toProxy(), index2);
12096 };
12097 } else {
12098 return i2;
12099 }
12100 })));
12101 };
12102 } else if (prop === "every" || prop === "some") {
12103 return function(cb) {
12104 return node2[prop](function(child) {
12105 for(var _len = arguments.length, other = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
12106 other[_key - 1] = arguments[_key];
12107 }
12108 return cb.apply(void 0, [].concat([
12109 child.toProxy()
12110 ], other));
12111 });
12112 };
12113 } else if (prop === "root") {
12114 return function() {
12115 return node2.root().toProxy();
12116 };
12117 } else if (prop === "nodes") {
12118 return node2.nodes.map(function(i2) {
12119 return i2.toProxy();
12120 });
12121 } else if (prop === "first" || prop === "last") {
12122 return node2[prop].toProxy();
12123 } else {
12124 return node2[prop];
12125 }
12126 },
12127 set: function set(node2, prop, value) {
12128 if (node2[prop] === value) return true;
12129 node2[prop] = value;
12130 if (prop === "name" || prop === "params" || prop === "selector") {
12131 node2.markDirty();
12132 }
12133 return true;
12134 }
12135 };
12136 };
12137 _proto.index = function index(child) {
12138 if (typeof child === "number") return child;
12139 if (child.proxyOf) child = child.proxyOf;
12140 return this.proxyOf.nodes.indexOf(child);
12141 };
12142 _proto.insertAfter = function insertAfter(exist, add) {
12143 var existIndex = this.index(exist);
12144 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
12145 existIndex = this.index(exist);
12146 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12147 var node2 = _step.value;
12148 this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
12149 }
12150 var index2;
12151 for(var id in this.indexes){
12152 index2 = this.indexes[id];
12153 if (existIndex < index2) {
12154 this.indexes[id] = index2 + nodes.length;
12155 }
12156 }
12157 this.markDirty();
12158 return this;
12159 };
12160 _proto.insertBefore = function insertBefore(exist, add) {
12161 var existIndex = this.index(exist);
12162 var type = existIndex === 0 ? "prepend" : false;
12163 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
12164 existIndex = this.index(exist);
12165 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12166 var node2 = _step.value;
12167 this.proxyOf.nodes.splice(existIndex, 0, node2);
12168 }
12169 var index2;
12170 for(var id in this.indexes){
12171 index2 = this.indexes[id];
12172 if (existIndex <= index2) {
12173 this.indexes[id] = index2 + nodes.length;
12174 }
12175 }
12176 this.markDirty();
12177 return this;
12178 };
12179 _proto.normalize = function normalize(nodes, sample) {
12180 var _this = this;
12181 if (typeof nodes === "string") {
12182 nodes = cleanSource$1(parse$4$1(nodes).nodes);
12183 } else if (typeof nodes === "undefined") {
12184 nodes = [];
12185 } else if (Array.isArray(nodes)) {
12186 nodes = nodes.slice(0);
12187 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12188 var i2 = _step.value;
12189 if (i2.parent) i2.parent.removeChild(i2, "ignore");
12190 }
12191 } else if (nodes.type === "root" && this.type !== "document") {
12192 nodes = nodes.nodes.slice(0);
12193 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
12194 var i21 = _step1.value;
12195 if (i21.parent) i21.parent.removeChild(i21, "ignore");
12196 }
12197 } else if (nodes.type) {
12198 nodes = [
12199 nodes
12200 ];
12201 } else if (nodes.prop) {
12202 if (typeof nodes.value === "undefined") {
12203 throw new Error("Value field is missed in node creation");
12204 } else if (typeof nodes.value !== "string") {
12205 nodes.value = String(nodes.value);
12206 }
12207 nodes = [
12208 new Declaration$3$1(nodes)
12209 ];
12210 } else if (nodes.selector) {
12211 nodes = [
12212 new Rule$4$1(nodes)
12213 ];
12214 } else if (nodes.name) {
12215 nodes = [
12216 new AtRule$4$1(nodes)
12217 ];
12218 } else if (nodes.text) {
12219 nodes = [
12220 new Comment$3$1(nodes)
12221 ];
12222 } else {
12223 throw new Error("Unknown node type in node creation");
12224 }
12225 var processed = nodes.map(function(i2) {
12226 if (!i2[my$1$1]) Container.rebuild(i2);
12227 i2 = i2.proxyOf;
12228 if (i2.parent) i2.parent.removeChild(i2);
12229 if (i2[isClean$1$1]) markDirtyUp$1(i2);
12230 if (typeof i2.raws.before === "undefined") {
12231 if (sample && typeof sample.raws.before !== "undefined") {
12232 i2.raws.before = sample.raws.before.replace(/\S/g, "");
12233 }
12234 }
12235 i2.parent = _this.proxyOf;
12236 return i2;
12237 });
12238 return processed;
12239 };
12240 _proto.prepend = function prepend() {
12241 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12242 children[_key] = arguments[_key];
12243 }
12244 children = children.reverse();
12245 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
12246 var child = _step.value;
12247 var nodes = this.normalize(child, this.first, "prepend").reverse();
12248 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
12249 var node2 = _step1.value;
12250 this.proxyOf.nodes.unshift(node2);
12251 }
12252 for(var id in this.indexes){
12253 this.indexes[id] = this.indexes[id] + nodes.length;
12254 }
12255 }
12256 this.markDirty();
12257 return this;
12258 };
12259 _proto.push = function push(child) {
12260 child.parent = this;
12261 this.proxyOf.nodes.push(child);
12262 return this;
12263 };
12264 _proto.removeAll = function removeAll() {
12265 for(var _iterator = _create_for_of_iterator_helper_loose(this.proxyOf.nodes), _step; !(_step = _iterator()).done;){
12266 var node2 = _step.value;
12267 node2.parent = void 0;
12268 }
12269 this.proxyOf.nodes = [];
12270 this.markDirty();
12271 return this;
12272 };
12273 _proto.removeChild = function removeChild(child) {
12274 child = this.index(child);
12275 this.proxyOf.nodes[child].parent = void 0;
12276 this.proxyOf.nodes.splice(child, 1);
12277 var index2;
12278 for(var id in this.indexes){
12279 index2 = this.indexes[id];
12280 if (index2 >= child) {
12281 this.indexes[id] = index2 - 1;
12282 }
12283 }
12284 this.markDirty();
12285 return this;
12286 };
12287 _proto.replaceValues = function replaceValues(pattern, opts, callback) {
12288 if (!callback) {
12289 callback = opts;
12290 opts = {};
12291 }
12292 this.walkDecls(function(decl) {
12293 if (opts.props && !opts.props.includes(decl.prop)) return;
12294 if (opts.fast && !decl.value.includes(opts.fast)) return;
12295 decl.value = decl.value.replace(pattern, callback);
12296 });
12297 this.markDirty();
12298 return this;
12299 };
12300 _proto.some = function some(condition) {
12301 return this.nodes.some(condition);
12302 };
12303 _proto.walk = function walk(callback) {
12304 return this.each(function(child, i2) {
12305 var result2;
12306 try {
12307 result2 = callback(child, i2);
12308 } catch (e2) {
12309 throw child.addToError(e2);
12310 }
12311 if (result2 !== false && child.walk) {
12312 result2 = child.walk(callback);
12313 }
12314 return result2;
12315 });
12316 };
12317 _proto.walkAtRules = function walkAtRules(name, callback) {
12318 if (!callback) {
12319 callback = name;
12320 return this.walk(function(child, i2) {
12321 if (child.type === "atrule") {
12322 return callback(child, i2);
12323 }
12324 });
12325 }
12326 if (_instanceof(name, RegExp)) {
12327 return this.walk(function(child, i2) {
12328 if (child.type === "atrule" && name.test(child.name)) {
12329 return callback(child, i2);
12330 }
12331 });
12332 }
12333 return this.walk(function(child, i2) {
12334 if (child.type === "atrule" && child.name === name) {
12335 return callback(child, i2);
12336 }
12337 });
12338 };
12339 _proto.walkComments = function walkComments(callback) {
12340 return this.walk(function(child, i2) {
12341 if (child.type === "comment") {
12342 return callback(child, i2);
12343 }
12344 });
12345 };
12346 _proto.walkDecls = function walkDecls(prop, callback) {
12347 if (!callback) {
12348 callback = prop;
12349 return this.walk(function(child, i2) {
12350 if (child.type === "decl") {
12351 return callback(child, i2);
12352 }
12353 });
12354 }
12355 if (_instanceof(prop, RegExp)) {
12356 return this.walk(function(child, i2) {
12357 if (child.type === "decl" && prop.test(child.prop)) {
12358 return callback(child, i2);
12359 }
12360 });
12361 }
12362 return this.walk(function(child, i2) {
12363 if (child.type === "decl" && child.prop === prop) {
12364 return callback(child, i2);
12365 }
12366 });
12367 };
12368 _proto.walkRules = function walkRules(selector, callback) {
12369 if (!callback) {
12370 callback = selector;
12371 return this.walk(function(child, i2) {
12372 if (child.type === "rule") {
12373 return callback(child, i2);
12374 }
12375 });
12376 }
12377 if (_instanceof(selector, RegExp)) {
12378 return this.walk(function(child, i2) {
12379 if (child.type === "rule" && selector.test(child.selector)) {
12380 return callback(child, i2);
12381 }
12382 });
12383 }
12384 return this.walk(function(child, i2) {
12385 if (child.type === "rule" && child.selector === selector) {
12386 return callback(child, i2);
12387 }
12388 });
12389 };
12390 _create_class(Container, [
12391 {
12392 key: "first",
12393 get: function get() {
12394 if (!this.proxyOf.nodes) return void 0;
12395 return this.proxyOf.nodes[0];
12396 }
12397 },
12398 {
12399 key: "last",
12400 get: function get() {
12401 if (!this.proxyOf.nodes) return void 0;
12402 return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
12403 }
12404 }
12405 ]);
12406 return Container;
12407 }(Node$1$1);
12408 Container$7$1.registerParse = function(dependant) {
12409 parse$4$1 = dependant;
12410 };
12411 Container$7$1.registerRule = function(dependant) {
12412 Rule$4$1 = dependant;
12413 };
12414 Container$7$1.registerAtRule = function(dependant) {
12415 AtRule$4$1 = dependant;
12416 };
12417 Container$7$1.registerRoot = function(dependant) {
12418 Root$6$1 = dependant;
12419 };
12420 var container$1 = Container$7$1;
12421 Container$7$1.default = Container$7$1;
12422 Container$7$1.rebuild = function(node2) {
12423 if (node2.type === "atrule") {
12424 Object.setPrototypeOf(node2, AtRule$4$1.prototype);
12425 } else if (node2.type === "rule") {
12426 Object.setPrototypeOf(node2, Rule$4$1.prototype);
12427 } else if (node2.type === "decl") {
12428 Object.setPrototypeOf(node2, Declaration$3$1.prototype);
12429 } else if (node2.type === "comment") {
12430 Object.setPrototypeOf(node2, Comment$3$1.prototype);
12431 } else if (node2.type === "root") {
12432 Object.setPrototypeOf(node2, Root$6$1.prototype);
12433 }
12434 node2[my$1$1] = true;
12435 if (node2.nodes) {
12436 node2.nodes.forEach(function(child) {
12437 Container$7$1.rebuild(child);
12438 });
12439 }
12440 };
12441 var Container$6$1 = container$1;
12442 var LazyResult$4$1, Processor$3$1;
12443 var Document$3$1 = /*#__PURE__*/ function(Container$6$1) {
12444 _inherits(Document2, Container$6$1);
12445 function Document2(defaults) {
12446 var _this;
12447 _this = Container$6$1.call(this, _extends({
12448 type: "document"
12449 }, defaults)) || this;
12450 if (!_this.nodes) {
12451 _this.nodes = [];
12452 }
12453 return _this;
12454 }
12455 var _proto = Document2.prototype;
12456 _proto.toResult = function toResult(opts) {
12457 if (opts === void 0) opts = {};
12458 var lazy = new LazyResult$4$1(new Processor$3$1(), this, opts);
12459 return lazy.stringify();
12460 };
12461 return Document2;
12462 }(Container$6$1);
12463 Document$3$1.registerLazyResult = function(dependant) {
12464 LazyResult$4$1 = dependant;
12465 };
12466 Document$3$1.registerProcessor = function(dependant) {
12467 Processor$3$1 = dependant;
12468 };
12469 var document$1$1 = Document$3$1;
12470 Document$3$1.default = Document$3$1;
12471 var printed$1 = {};
12472 var warnOnce$2$1 = function warnOnce(message) {
12473 if (printed$1[message]) return;
12474 printed$1[message] = true;
12475 if (typeof console !== "undefined" && console.warn) {
12476 console.warn(message);
12477 }
12478 };
12479 var Warning$2$1 = /*#__PURE__*/ function() {
12480 function Warning(text, opts) {
12481 if (opts === void 0) opts = {};
12482 this.type = "warning";
12483 this.text = text;
12484 if (opts.node && opts.node.source) {
12485 var range = opts.node.rangeBy(opts);
12486 this.line = range.start.line;
12487 this.column = range.start.column;
12488 this.endLine = range.end.line;
12489 this.endColumn = range.end.column;
12490 }
12491 for(var opt in opts)this[opt] = opts[opt];
12492 }
12493 var _proto = Warning.prototype;
12494 _proto.toString = function toString() {
12495 if (this.node) {
12496 return this.node.error(this.text, {
12497 index: this.index,
12498 plugin: this.plugin,
12499 word: this.word
12500 }).message;
12501 }
12502 if (this.plugin) {
12503 return this.plugin + ": " + this.text;
12504 }
12505 return this.text;
12506 };
12507 return Warning;
12508 }();
12509 var warning$1 = Warning$2$1;
12510 Warning$2$1.default = Warning$2$1;
12511 var Warning$1$1 = warning$1;
12512 var Result$3$1 = /*#__PURE__*/ function() {
12513 function Result(processor2, root2, opts) {
12514 this.processor = processor2;
12515 this.messages = [];
12516 this.root = root2;
12517 this.opts = opts;
12518 this.css = void 0;
12519 this.map = void 0;
12520 }
12521 var _proto = Result.prototype;
12522 _proto.toString = function toString() {
12523 return this.css;
12524 };
12525 _proto.warn = function warn(text, opts) {
12526 if (opts === void 0) opts = {};
12527 if (!opts.plugin) {
12528 if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
12529 opts.plugin = this.lastPlugin.postcssPlugin;
12530 }
12531 }
12532 var warning2 = new Warning$1$1(text, opts);
12533 this.messages.push(warning2);
12534 return warning2;
12535 };
12536 _proto.warnings = function warnings() {
12537 return this.messages.filter(function(i2) {
12538 return i2.type === "warning";
12539 });
12540 };
12541 _create_class(Result, [
12542 {
12543 key: "content",
12544 get: function get() {
12545 return this.css;
12546 }
12547 }
12548 ]);
12549 return Result;
12550 }();
12551 var result$1 = Result$3$1;
12552 Result$3$1.default = Result$3$1;
12553 var SINGLE_QUOTE$1 = "'".charCodeAt(0);
12554 var DOUBLE_QUOTE$1 = '"'.charCodeAt(0);
12555 var BACKSLASH$1 = "\\".charCodeAt(0);
12556 var SLASH$1 = "/".charCodeAt(0);
12557 var NEWLINE$1 = "\n".charCodeAt(0);
12558 var SPACE$1 = " ".charCodeAt(0);
12559 var FEED$1 = "\f".charCodeAt(0);
12560 var TAB$1 = " ".charCodeAt(0);
12561 var CR$1 = "\r".charCodeAt(0);
12562 var OPEN_SQUARE$1 = "[".charCodeAt(0);
12563 var CLOSE_SQUARE$1 = "]".charCodeAt(0);
12564 var OPEN_PARENTHESES$1 = "(".charCodeAt(0);
12565 var CLOSE_PARENTHESES$1 = ")".charCodeAt(0);
12566 var OPEN_CURLY$1 = "{".charCodeAt(0);
12567 var CLOSE_CURLY$1 = "}".charCodeAt(0);
12568 var SEMICOLON$1 = ";".charCodeAt(0);
12569 var ASTERISK$1 = "*".charCodeAt(0);
12570 var COLON$1 = ":".charCodeAt(0);
12571 var AT$1 = "@".charCodeAt(0);
12572 var RE_AT_END$1 = /[\t\n\f\r "#'()/;[\\\]{}]/g;
12573 var RE_WORD_END$1 = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
12574 var RE_BAD_BRACKET$1 = /.[\r\n"'(/\\]/;
12575 var RE_HEX_ESCAPE$1 = /[\da-f]/i;
12576 var tokenize$1 = function tokenizer(input2, options) {
12577 if (options === void 0) options = {};
12578 var css = input2.css.valueOf();
12579 var ignore = options.ignoreErrors;
12580 var code, next, quote, content, escape;
12581 var escaped, escapePos, prev, n2, currentToken;
12582 var length = css.length;
12583 var pos = 0;
12584 var buffer = [];
12585 var returned = [];
12586 function position() {
12587 return pos;
12588 }
12589 function unclosed(what) {
12590 throw input2.error("Unclosed " + what, pos);
12591 }
12592 function endOfFile() {
12593 return returned.length === 0 && pos >= length;
12594 }
12595 function nextToken(opts) {
12596 if (returned.length) return returned.pop();
12597 if (pos >= length) return;
12598 var ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
12599 code = css.charCodeAt(pos);
12600 switch(code){
12601 case NEWLINE$1:
12602 case SPACE$1:
12603 case TAB$1:
12604 case CR$1:
12605 case FEED$1:
12606 {
12607 next = pos;
12608 do {
12609 next += 1;
12610 code = css.charCodeAt(next);
12611 }while (code === SPACE$1 || code === NEWLINE$1 || code === TAB$1 || code === CR$1 || code === FEED$1);
12612 currentToken = [
12613 "space",
12614 css.slice(pos, next)
12615 ];
12616 pos = next - 1;
12617 break;
12618 }
12619 case OPEN_SQUARE$1:
12620 case CLOSE_SQUARE$1:
12621 case OPEN_CURLY$1:
12622 case CLOSE_CURLY$1:
12623 case COLON$1:
12624 case SEMICOLON$1:
12625 case CLOSE_PARENTHESES$1:
12626 {
12627 var controlChar = String.fromCharCode(code);
12628 currentToken = [
12629 controlChar,
12630 controlChar,
12631 pos
12632 ];
12633 break;
12634 }
12635 case OPEN_PARENTHESES$1:
12636 {
12637 prev = buffer.length ? buffer.pop()[1] : "";
12638 n2 = css.charCodeAt(pos + 1);
12639 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) {
12640 next = pos;
12641 do {
12642 escaped = false;
12643 next = css.indexOf(")", next + 1);
12644 if (next === -1) {
12645 if (ignore || ignoreUnclosed) {
12646 next = pos;
12647 break;
12648 } else {
12649 unclosed("bracket");
12650 }
12651 }
12652 escapePos = next;
12653 while(css.charCodeAt(escapePos - 1) === BACKSLASH$1){
12654 escapePos -= 1;
12655 escaped = !escaped;
12656 }
12657 }while (escaped);
12658 currentToken = [
12659 "brackets",
12660 css.slice(pos, next + 1),
12661 pos,
12662 next
12663 ];
12664 pos = next;
12665 } else {
12666 next = css.indexOf(")", pos + 1);
12667 content = css.slice(pos, next + 1);
12668 if (next === -1 || RE_BAD_BRACKET$1.test(content)) {
12669 currentToken = [
12670 "(",
12671 "(",
12672 pos
12673 ];
12674 } else {
12675 currentToken = [
12676 "brackets",
12677 content,
12678 pos,
12679 next
12680 ];
12681 pos = next;
12682 }
12683 }
12684 break;
12685 }
12686 case SINGLE_QUOTE$1:
12687 case DOUBLE_QUOTE$1:
12688 {
12689 quote = code === SINGLE_QUOTE$1 ? "'" : '"';
12690 next = pos;
12691 do {
12692 escaped = false;
12693 next = css.indexOf(quote, next + 1);
12694 if (next === -1) {
12695 if (ignore || ignoreUnclosed) {
12696 next = pos + 1;
12697 break;
12698 } else {
12699 unclosed("string");
12700 }
12701 }
12702 escapePos = next;
12703 while(css.charCodeAt(escapePos - 1) === BACKSLASH$1){
12704 escapePos -= 1;
12705 escaped = !escaped;
12706 }
12707 }while (escaped);
12708 currentToken = [
12709 "string",
12710 css.slice(pos, next + 1),
12711 pos,
12712 next
12713 ];
12714 pos = next;
12715 break;
12716 }
12717 case AT$1:
12718 {
12719 RE_AT_END$1.lastIndex = pos + 1;
12720 RE_AT_END$1.test(css);
12721 if (RE_AT_END$1.lastIndex === 0) {
12722 next = css.length - 1;
12723 } else {
12724 next = RE_AT_END$1.lastIndex - 2;
12725 }
12726 currentToken = [
12727 "at-word",
12728 css.slice(pos, next + 1),
12729 pos,
12730 next
12731 ];
12732 pos = next;
12733 break;
12734 }
12735 case BACKSLASH$1:
12736 {
12737 next = pos;
12738 escape = true;
12739 while(css.charCodeAt(next + 1) === BACKSLASH$1){
12740 next += 1;
12741 escape = !escape;
12742 }
12743 code = css.charCodeAt(next + 1);
12744 if (escape && code !== SLASH$1 && code !== SPACE$1 && code !== NEWLINE$1 && code !== TAB$1 && code !== CR$1 && code !== FEED$1) {
12745 next += 1;
12746 if (RE_HEX_ESCAPE$1.test(css.charAt(next))) {
12747 while(RE_HEX_ESCAPE$1.test(css.charAt(next + 1))){
12748 next += 1;
12749 }
12750 if (css.charCodeAt(next + 1) === SPACE$1) {
12751 next += 1;
12752 }
12753 }
12754 }
12755 currentToken = [
12756 "word",
12757 css.slice(pos, next + 1),
12758 pos,
12759 next
12760 ];
12761 pos = next;
12762 break;
12763 }
12764 default:
12765 {
12766 if (code === SLASH$1 && css.charCodeAt(pos + 1) === ASTERISK$1) {
12767 next = css.indexOf("*/", pos + 2) + 1;
12768 if (next === 0) {
12769 if (ignore || ignoreUnclosed) {
12770 next = css.length;
12771 } else {
12772 unclosed("comment");
12773 }
12774 }
12775 currentToken = [
12776 "comment",
12777 css.slice(pos, next + 1),
12778 pos,
12779 next
12780 ];
12781 pos = next;
12782 } else {
12783 RE_WORD_END$1.lastIndex = pos + 1;
12784 RE_WORD_END$1.test(css);
12785 if (RE_WORD_END$1.lastIndex === 0) {
12786 next = css.length - 1;
12787 } else {
12788 next = RE_WORD_END$1.lastIndex - 2;
12789 }
12790 currentToken = [
12791 "word",
12792 css.slice(pos, next + 1),
12793 pos,
12794 next
12795 ];
12796 buffer.push(currentToken);
12797 pos = next;
12798 }
12799 break;
12800 }
12801 }
12802 pos++;
12803 return currentToken;
12804 }
12805 function back(token) {
12806 returned.push(token);
12807 }
12808 return {
12809 back: back,
12810 endOfFile: endOfFile,
12811 nextToken: nextToken,
12812 position: position
12813 };
12814 };
12815 var Container$5$1 = container$1;
12816 var AtRule$3$1 = /*#__PURE__*/ function(Container$5$1) {
12817 _inherits(AtRule, Container$5$1);
12818 function AtRule(defaults) {
12819 var _this;
12820 _this = Container$5$1.call(this, defaults) || this;
12821 _this.type = "atrule";
12822 return _this;
12823 }
12824 var _proto = AtRule.prototype;
12825 _proto.append = function append() {
12826 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12827 children[_key] = arguments[_key];
12828 }
12829 var _Container$5$1_prototype_append;
12830 if (!this.proxyOf.nodes) this.nodes = [];
12831 return (_Container$5$1_prototype_append = Container$5$1.prototype.append).call.apply(_Container$5$1_prototype_append, [].concat([
12832 this
12833 ], children));
12834 };
12835 _proto.prepend = function prepend() {
12836 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12837 children[_key] = arguments[_key];
12838 }
12839 var _Container$5$1_prototype_prepend;
12840 if (!this.proxyOf.nodes) this.nodes = [];
12841 return (_Container$5$1_prototype_prepend = Container$5$1.prototype.prepend).call.apply(_Container$5$1_prototype_prepend, [].concat([
12842 this
12843 ], children));
12844 };
12845 return AtRule;
12846 }(Container$5$1);
12847 var atRule$1 = AtRule$3$1;
12848 AtRule$3$1.default = AtRule$3$1;
12849 Container$5$1.registerAtRule(AtRule$3$1);
12850 var Container$4$1 = container$1;
12851 var LazyResult$3$1, Processor$2$1;
12852 var Root$5$1 = /*#__PURE__*/ function(Container$4$1) {
12853 _inherits(Root, Container$4$1);
12854 function Root(defaults) {
12855 var _this;
12856 _this = Container$4$1.call(this, defaults) || this;
12857 _this.type = "root";
12858 if (!_this.nodes) _this.nodes = [];
12859 return _this;
12860 }
12861 var _proto = Root.prototype;
12862 _proto.normalize = function normalize(child, sample, type) {
12863 var nodes = Container$4$1.prototype.normalize.call(this, child);
12864 if (sample) {
12865 if (type === "prepend") {
12866 if (this.nodes.length > 1) {
12867 sample.raws.before = this.nodes[1].raws.before;
12868 } else {
12869 delete sample.raws.before;
12870 }
12871 } else if (this.first !== sample) {
12872 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12873 var node2 = _step.value;
12874 node2.raws.before = sample.raws.before;
12875 }
12876 }
12877 }
12878 return nodes;
12879 };
12880 _proto.removeChild = function removeChild(child, ignore) {
12881 var index2 = this.index(child);
12882 if (!ignore && index2 === 0 && this.nodes.length > 1) {
12883 this.nodes[1].raws.before = this.nodes[index2].raws.before;
12884 }
12885 return Container$4$1.prototype.removeChild.call(this, child);
12886 };
12887 _proto.toResult = function toResult(opts) {
12888 if (opts === void 0) opts = {};
12889 var lazy = new LazyResult$3$1(new Processor$2$1(), this, opts);
12890 return lazy.stringify();
12891 };
12892 return Root;
12893 }(Container$4$1);
12894 Root$5$1.registerLazyResult = function(dependant) {
12895 LazyResult$3$1 = dependant;
12896 };
12897 Root$5$1.registerProcessor = function(dependant) {
12898 Processor$2$1 = dependant;
12899 };
12900 var root$1 = Root$5$1;
12901 Root$5$1.default = Root$5$1;
12902 Container$4$1.registerRoot(Root$5$1);
12903 var list$2$1 = {
12904 comma: function comma(string) {
12905 return list$2$1.split(string, [
12906 ","
12907 ], true);
12908 },
12909 space: function space(string) {
12910 var spaces = [
12911 " ",
12912 "\n",
12913 " "
12914 ];
12915 return list$2$1.split(string, spaces);
12916 },
12917 split: function split(string, separators, last) {
12918 var array = [];
12919 var current = "";
12920 var split = false;
12921 var func = 0;
12922 var inQuote = false;
12923 var prevQuote = "";
12924 var escape = false;
12925 for(var _iterator = _create_for_of_iterator_helper_loose(string), _step; !(_step = _iterator()).done;){
12926 var letter = _step.value;
12927 if (escape) {
12928 escape = false;
12929 } else if (letter === "\\") {
12930 escape = true;
12931 } else if (inQuote) {
12932 if (letter === prevQuote) {
12933 inQuote = false;
12934 }
12935 } else if (letter === '"' || letter === "'") {
12936 inQuote = true;
12937 prevQuote = letter;
12938 } else if (letter === "(") {
12939 func += 1;
12940 } else if (letter === ")") {
12941 if (func > 0) func -= 1;
12942 } else if (func === 0) {
12943 if (separators.includes(letter)) split = true;
12944 }
12945 if (split) {
12946 if (current !== "") array.push(current.trim());
12947 current = "";
12948 split = false;
12949 } else {
12950 current += letter;
12951 }
12952 }
12953 if (last || current !== "") array.push(current.trim());
12954 return array;
12955 }
12956 };
12957 var list_1$1 = list$2$1;
12958 list$2$1.default = list$2$1;
12959 var Container$3$1 = container$1;
12960 var list$1$1 = list_1$1;
12961 var Rule$3$1 = /*#__PURE__*/ function(Container$3$1) {
12962 _inherits(Rule, Container$3$1);
12963 function Rule(defaults) {
12964 var _this;
12965 _this = Container$3$1.call(this, defaults) || this;
12966 _this.type = "rule";
12967 if (!_this.nodes) _this.nodes = [];
12968 return _this;
12969 }
12970 _create_class(Rule, [
12971 {
12972 key: "selectors",
12973 get: function get() {
12974 return list$1$1.comma(this.selector);
12975 },
12976 set: function set(values) {
12977 var match = this.selector ? this.selector.match(/,\s*/) : null;
12978 var sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen");
12979 this.selector = values.join(sep2);
12980 }
12981 }
12982 ]);
12983 return Rule;
12984 }(Container$3$1);
12985 var rule$1 = Rule$3$1;
12986 Rule$3$1.default = Rule$3$1;
12987 Container$3$1.registerRule(Rule$3$1);
12988 var Declaration$2$1 = declaration$1;
12989 var tokenizer2$1 = tokenize$1;
12990 var Comment$2$1 = comment$1;
12991 var AtRule$2$1 = atRule$1;
12992 var Root$4$1 = root$1;
12993 var Rule$2$1 = rule$1;
12994 var SAFE_COMMENT_NEIGHBOR$1 = {
12995 empty: true,
12996 space: true
12997 };
12998 function findLastWithPosition$1(tokens) {
12999 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
13000 var token = tokens[i2];
13001 var pos = token[3] || token[2];
13002 if (pos) return pos;
13003 }
13004 }
13005 var Parser$1$1 = /*#__PURE__*/ function() {
13006 function Parser(input2) {
13007 this.input = input2;
13008 this.root = new Root$4$1();
13009 this.current = this.root;
13010 this.spaces = "";
13011 this.semicolon = false;
13012 this.createTokenizer();
13013 this.root.source = {
13014 input: input2,
13015 start: {
13016 column: 1,
13017 line: 1,
13018 offset: 0
13019 }
13020 };
13021 }
13022 var _proto = Parser.prototype;
13023 _proto.atrule = function atrule(token) {
13024 var node2 = new AtRule$2$1();
13025 node2.name = token[1].slice(1);
13026 if (node2.name === "") {
13027 this.unnamedAtrule(node2, token);
13028 }
13029 this.init(node2, token[2]);
13030 var type;
13031 var prev;
13032 var shift;
13033 var last = false;
13034 var open = false;
13035 var params = [];
13036 var brackets = [];
13037 while(!this.tokenizer.endOfFile()){
13038 token = this.tokenizer.nextToken();
13039 type = token[0];
13040 if (type === "(" || type === "[") {
13041 brackets.push(type === "(" ? ")" : "]");
13042 } else if (type === "{" && brackets.length > 0) {
13043 brackets.push("}");
13044 } else if (type === brackets[brackets.length - 1]) {
13045 brackets.pop();
13046 }
13047 if (brackets.length === 0) {
13048 if (type === ";") {
13049 node2.source.end = this.getPosition(token[2]);
13050 node2.source.end.offset++;
13051 this.semicolon = true;
13052 break;
13053 } else if (type === "{") {
13054 open = true;
13055 break;
13056 } else if (type === "}") {
13057 if (params.length > 0) {
13058 shift = params.length - 1;
13059 prev = params[shift];
13060 while(prev && prev[0] === "space"){
13061 prev = params[--shift];
13062 }
13063 if (prev) {
13064 node2.source.end = this.getPosition(prev[3] || prev[2]);
13065 node2.source.end.offset++;
13066 }
13067 }
13068 this.end(token);
13069 break;
13070 } else {
13071 params.push(token);
13072 }
13073 } else {
13074 params.push(token);
13075 }
13076 if (this.tokenizer.endOfFile()) {
13077 last = true;
13078 break;
13079 }
13080 }
13081 node2.raws.between = this.spacesAndCommentsFromEnd(params);
13082 if (params.length) {
13083 node2.raws.afterName = this.spacesAndCommentsFromStart(params);
13084 this.raw(node2, "params", params);
13085 if (last) {
13086 token = params[params.length - 1];
13087 node2.source.end = this.getPosition(token[3] || token[2]);
13088 node2.source.end.offset++;
13089 this.spaces = node2.raws.between;
13090 node2.raws.between = "";
13091 }
13092 } else {
13093 node2.raws.afterName = "";
13094 node2.params = "";
13095 }
13096 if (open) {
13097 node2.nodes = [];
13098 this.current = node2;
13099 }
13100 };
13101 _proto.checkMissedSemicolon = function checkMissedSemicolon(tokens) {
13102 var colon = this.colon(tokens);
13103 if (colon === false) return;
13104 var founded = 0;
13105 var token;
13106 for(var j = colon - 1; j >= 0; j--){
13107 token = tokens[j];
13108 if (token[0] !== "space") {
13109 founded += 1;
13110 if (founded === 2) break;
13111 }
13112 }
13113 throw this.input.error("Missed semicolon", token[0] === "word" ? token[3] + 1 : token[2]);
13114 };
13115 _proto.colon = function colon(tokens) {
13116 var brackets = 0;
13117 var token, type, prev;
13118 for(var _iterator = _create_for_of_iterator_helper_loose(tokens.entries()), _step; !(_step = _iterator()).done;){
13119 var _step_value = _step.value, i2 = _step_value[0], element = _step_value[1];
13120 token = element;
13121 type = token[0];
13122 if (type === "(") {
13123 brackets += 1;
13124 }
13125 if (type === ")") {
13126 brackets -= 1;
13127 }
13128 if (brackets === 0 && type === ":") {
13129 if (!prev) {
13130 this.doubleColon(token);
13131 } else if (prev[0] === "word" && prev[1] === "progid") {
13132 continue;
13133 } else {
13134 return i2;
13135 }
13136 }
13137 prev = token;
13138 }
13139 return false;
13140 };
13141 _proto.comment = function comment(token) {
13142 var node2 = new Comment$2$1();
13143 this.init(node2, token[2]);
13144 node2.source.end = this.getPosition(token[3] || token[2]);
13145 node2.source.end.offset++;
13146 var text = token[1].slice(2, -2);
13147 if (/^\s*$/.test(text)) {
13148 node2.text = "";
13149 node2.raws.left = text;
13150 node2.raws.right = "";
13151 } else {
13152 var match = text.match(/^(\s*)([^]*\S)(\s*)$/);
13153 node2.text = match[2];
13154 node2.raws.left = match[1];
13155 node2.raws.right = match[3];
13156 }
13157 };
13158 _proto.createTokenizer = function createTokenizer() {
13159 this.tokenizer = tokenizer2$1(this.input);
13160 };
13161 _proto.decl = function decl(tokens, customProperty) {
13162 var node2 = new Declaration$2$1();
13163 this.init(node2, tokens[0][2]);
13164 var last = tokens[tokens.length - 1];
13165 if (last[0] === ";") {
13166 this.semicolon = true;
13167 tokens.pop();
13168 }
13169 node2.source.end = this.getPosition(last[3] || last[2] || findLastWithPosition$1(tokens));
13170 node2.source.end.offset++;
13171 while(tokens[0][0] !== "word"){
13172 if (tokens.length === 1) this.unknownWord(tokens);
13173 node2.raws.before += tokens.shift()[1];
13174 }
13175 node2.source.start = this.getPosition(tokens[0][2]);
13176 node2.prop = "";
13177 while(tokens.length){
13178 var type = tokens[0][0];
13179 if (type === ":" || type === "space" || type === "comment") {
13180 break;
13181 }
13182 node2.prop += tokens.shift()[1];
13183 }
13184 node2.raws.between = "";
13185 var token;
13186 while(tokens.length){
13187 token = tokens.shift();
13188 if (token[0] === ":") {
13189 node2.raws.between += token[1];
13190 break;
13191 } else {
13192 if (token[0] === "word" && /\w/.test(token[1])) {
13193 this.unknownWord([
13194 token
13195 ]);
13196 }
13197 node2.raws.between += token[1];
13198 }
13199 }
13200 if (node2.prop[0] === "_" || node2.prop[0] === "*") {
13201 node2.raws.before += node2.prop[0];
13202 node2.prop = node2.prop.slice(1);
13203 }
13204 var firstSpaces = [];
13205 var next;
13206 while(tokens.length){
13207 next = tokens[0][0];
13208 if (next !== "space" && next !== "comment") break;
13209 firstSpaces.push(tokens.shift());
13210 }
13211 this.precheckMissedSemicolon(tokens);
13212 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
13213 token = tokens[i2];
13214 if (token[1].toLowerCase() === "!important") {
13215 node2.important = true;
13216 var string = this.stringFrom(tokens, i2);
13217 string = this.spacesFromEnd(tokens) + string;
13218 if (string !== " !important") node2.raws.important = string;
13219 break;
13220 } else if (token[1].toLowerCase() === "important") {
13221 var cache = tokens.slice(0);
13222 var str = "";
13223 for(var j = i2; j > 0; j--){
13224 var type1 = cache[j][0];
13225 if (str.trim().indexOf("!") === 0 && type1 !== "space") {
13226 break;
13227 }
13228 str = cache.pop()[1] + str;
13229 }
13230 if (str.trim().indexOf("!") === 0) {
13231 node2.important = true;
13232 node2.raws.important = str;
13233 tokens = cache;
13234 }
13235 }
13236 if (token[0] !== "space" && token[0] !== "comment") {
13237 break;
13238 }
13239 }
13240 var hasWord = tokens.some(function(i2) {
13241 return i2[0] !== "space" && i2[0] !== "comment";
13242 });
13243 if (hasWord) {
13244 node2.raws.between += firstSpaces.map(function(i2) {
13245 return i2[1];
13246 }).join("");
13247 firstSpaces = [];
13248 }
13249 this.raw(node2, "value", firstSpaces.concat(tokens), customProperty);
13250 if (node2.value.includes(":") && !customProperty) {
13251 this.checkMissedSemicolon(tokens);
13252 }
13253 };
13254 _proto.doubleColon = function doubleColon(token) {
13255 throw this.input.error("Double colon", {
13256 offset: token[2]
13257 }, {
13258 offset: token[2] + token[1].length
13259 });
13260 };
13261 _proto.emptyRule = function emptyRule(token) {
13262 var node2 = new Rule$2$1();
13263 this.init(node2, token[2]);
13264 node2.selector = "";
13265 node2.raws.between = "";
13266 this.current = node2;
13267 };
13268 _proto.end = function end(token) {
13269 if (this.current.nodes && this.current.nodes.length) {
13270 this.current.raws.semicolon = this.semicolon;
13271 }
13272 this.semicolon = false;
13273 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
13274 this.spaces = "";
13275 if (this.current.parent) {
13276 this.current.source.end = this.getPosition(token[2]);
13277 this.current.source.end.offset++;
13278 this.current = this.current.parent;
13279 } else {
13280 this.unexpectedClose(token);
13281 }
13282 };
13283 _proto.endFile = function endFile() {
13284 if (this.current.parent) this.unclosedBlock();
13285 if (this.current.nodes && this.current.nodes.length) {
13286 this.current.raws.semicolon = this.semicolon;
13287 }
13288 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
13289 this.root.source.end = this.getPosition(this.tokenizer.position());
13290 };
13291 _proto.freeSemicolon = function freeSemicolon(token) {
13292 this.spaces += token[1];
13293 if (this.current.nodes) {
13294 var prev = this.current.nodes[this.current.nodes.length - 1];
13295 if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
13296 prev.raws.ownSemicolon = this.spaces;
13297 this.spaces = "";
13298 }
13299 }
13300 };
13301 // Helpers
13302 _proto.getPosition = function getPosition(offset) {
13303 var pos = this.input.fromOffset(offset);
13304 return {
13305 column: pos.col,
13306 line: pos.line,
13307 offset: offset
13308 };
13309 };
13310 _proto.init = function init(node2, offset) {
13311 this.current.push(node2);
13312 node2.source = {
13313 input: this.input,
13314 start: this.getPosition(offset)
13315 };
13316 node2.raws.before = this.spaces;
13317 this.spaces = "";
13318 if (node2.type !== "comment") this.semicolon = false;
13319 };
13320 _proto.other = function other(start) {
13321 var end = false;
13322 var type = null;
13323 var colon = false;
13324 var bracket = null;
13325 var brackets = [];
13326 var customProperty = start[1].startsWith("--");
13327 var tokens = [];
13328 var token = start;
13329 while(token){
13330 type = token[0];
13331 tokens.push(token);
13332 if (type === "(" || type === "[") {
13333 if (!bracket) bracket = token;
13334 brackets.push(type === "(" ? ")" : "]");
13335 } else if (customProperty && colon && type === "{") {
13336 if (!bracket) bracket = token;
13337 brackets.push("}");
13338 } else if (brackets.length === 0) {
13339 if (type === ";") {
13340 if (colon) {
13341 this.decl(tokens, customProperty);
13342 return;
13343 } else {
13344 break;
13345 }
13346 } else if (type === "{") {
13347 this.rule(tokens);
13348 return;
13349 } else if (type === "}") {
13350 this.tokenizer.back(tokens.pop());
13351 end = true;
13352 break;
13353 } else if (type === ":") {
13354 colon = true;
13355 }
13356 } else if (type === brackets[brackets.length - 1]) {
13357 brackets.pop();
13358 if (brackets.length === 0) bracket = null;
13359 }
13360 token = this.tokenizer.nextToken();
13361 }
13362 if (this.tokenizer.endOfFile()) end = true;
13363 if (brackets.length > 0) this.unclosedBracket(bracket);
13364 if (end && colon) {
13365 if (!customProperty) {
13366 while(tokens.length){
13367 token = tokens[tokens.length - 1][0];
13368 if (token !== "space" && token !== "comment") break;
13369 this.tokenizer.back(tokens.pop());
13370 }
13371 }
13372 this.decl(tokens, customProperty);
13373 } else {
13374 this.unknownWord(tokens);
13375 }
13376 };
13377 _proto.parse = function parse() {
13378 var token;
13379 while(!this.tokenizer.endOfFile()){
13380 token = this.tokenizer.nextToken();
13381 switch(token[0]){
13382 case "space":
13383 this.spaces += token[1];
13384 break;
13385 case ";":
13386 this.freeSemicolon(token);
13387 break;
13388 case "}":
13389 this.end(token);
13390 break;
13391 case "comment":
13392 this.comment(token);
13393 break;
13394 case "at-word":
13395 this.atrule(token);
13396 break;
13397 case "{":
13398 this.emptyRule(token);
13399 break;
13400 default:
13401 this.other(token);
13402 break;
13403 }
13404 }
13405 this.endFile();
13406 };
13407 _proto.precheckMissedSemicolon = function precheckMissedSemicolon() {};
13408 _proto.raw = function raw(node2, prop, tokens, customProperty) {
13409 var token, type;
13410 var length = tokens.length;
13411 var value = "";
13412 var clean = true;
13413 var next, prev;
13414 for(var i2 = 0; i2 < length; i2 += 1){
13415 token = tokens[i2];
13416 type = token[0];
13417 if (type === "space" && i2 === length - 1 && !customProperty) {
13418 clean = false;
13419 } else if (type === "comment") {
13420 prev = tokens[i2 - 1] ? tokens[i2 - 1][0] : "empty";
13421 next = tokens[i2 + 1] ? tokens[i2 + 1][0] : "empty";
13422 if (!SAFE_COMMENT_NEIGHBOR$1[prev] && !SAFE_COMMENT_NEIGHBOR$1[next]) {
13423 if (value.slice(-1) === ",") {
13424 clean = false;
13425 } else {
13426 value += token[1];
13427 }
13428 } else {
13429 clean = false;
13430 }
13431 } else {
13432 value += token[1];
13433 }
13434 }
13435 if (!clean) {
13436 var raw = tokens.reduce(function(all, i2) {
13437 return all + i2[1];
13438 }, "");
13439 node2.raws[prop] = {
13440 raw: raw,
13441 value: value
13442 };
13443 }
13444 node2[prop] = value;
13445 };
13446 _proto.rule = function rule(tokens) {
13447 tokens.pop();
13448 var node2 = new Rule$2$1();
13449 this.init(node2, tokens[0][2]);
13450 node2.raws.between = this.spacesAndCommentsFromEnd(tokens);
13451 this.raw(node2, "selector", tokens);
13452 this.current = node2;
13453 };
13454 _proto.spacesAndCommentsFromEnd = function spacesAndCommentsFromEnd(tokens) {
13455 var lastTokenType;
13456 var spaces = "";
13457 while(tokens.length){
13458 lastTokenType = tokens[tokens.length - 1][0];
13459 if (lastTokenType !== "space" && lastTokenType !== "comment") break;
13460 spaces = tokens.pop()[1] + spaces;
13461 }
13462 return spaces;
13463 };
13464 // Errors
13465 _proto.spacesAndCommentsFromStart = function spacesAndCommentsFromStart(tokens) {
13466 var next;
13467 var spaces = "";
13468 while(tokens.length){
13469 next = tokens[0][0];
13470 if (next !== "space" && next !== "comment") break;
13471 spaces += tokens.shift()[1];
13472 }
13473 return spaces;
13474 };
13475 _proto.spacesFromEnd = function spacesFromEnd(tokens) {
13476 var lastTokenType;
13477 var spaces = "";
13478 while(tokens.length){
13479 lastTokenType = tokens[tokens.length - 1][0];
13480 if (lastTokenType !== "space") break;
13481 spaces = tokens.pop()[1] + spaces;
13482 }
13483 return spaces;
13484 };
13485 _proto.stringFrom = function stringFrom(tokens, from) {
13486 var result2 = "";
13487 for(var i2 = from; i2 < tokens.length; i2++){
13488 result2 += tokens[i2][1];
13489 }
13490 tokens.splice(from, tokens.length - from);
13491 return result2;
13492 };
13493 _proto.unclosedBlock = function unclosedBlock() {
13494 var pos = this.current.source.start;
13495 throw this.input.error("Unclosed block", pos.line, pos.column);
13496 };
13497 _proto.unclosedBracket = function unclosedBracket(bracket) {
13498 throw this.input.error("Unclosed bracket", {
13499 offset: bracket[2]
13500 }, {
13501 offset: bracket[2] + 1
13502 });
13503 };
13504 _proto.unexpectedClose = function unexpectedClose(token) {
13505 throw this.input.error("Unexpected }", {
13506 offset: token[2]
13507 }, {
13508 offset: token[2] + 1
13509 });
13510 };
13511 _proto.unknownWord = function unknownWord(tokens) {
13512 throw this.input.error("Unknown word", {
13513 offset: tokens[0][2]
13514 }, {
13515 offset: tokens[0][2] + tokens[0][1].length
13516 });
13517 };
13518 _proto.unnamedAtrule = function unnamedAtrule(node2, token) {
13519 throw this.input.error("At-rule without name", {
13520 offset: token[2]
13521 }, {
13522 offset: token[2] + token[1].length
13523 });
13524 };
13525 return Parser;
13526 }();
13527 var parser$1 = Parser$1$1;
13528 var Container$2$1 = container$1;
13529 var Parser2$1 = parser$1;
13530 var Input$2$1 = input$1;
13531 function parse$3$1(css, opts) {
13532 var input2 = new Input$2$1(css, opts);
13533 var parser2 = new Parser2$1(input2);
13534 try {
13535 parser2.parse();
13536 } catch (e2) {
13537 if (true) {
13538 if (e2.name === "CssSyntaxError" && opts && opts.from) {
13539 if (/\.scss$/i.test(opts.from)) {
13540 e2.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser";
13541 } else if (/\.sass/i.test(opts.from)) {
13542 e2.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser";
13543 } else if (/\.less$/i.test(opts.from)) {
13544 e2.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser";
13545 }
13546 }
13547 }
13548 throw e2;
13549 }
13550 return parser2.root;
13551 }
13552 var parse_1$1 = parse$3$1;
13553 parse$3$1.default = parse$3$1;
13554 Container$2$1.registerParse(parse$3$1);
13555 var isClean$3 = symbols$1.isClean, my$3 = symbols$1.my;
13556 var MapGenerator$1$1 = mapGenerator$1;
13557 var stringify$2$1 = stringify_1$1;
13558 var Container$1$1 = container$1;
13559 var Document$2$1 = document$1$1;
13560 var warnOnce$1$1 = warnOnce$2$1;
13561 var Result$2$1 = result$1;
13562 var parse$2$1 = parse_1$1;
13563 var Root$3$1 = root$1;
13564 var TYPE_TO_CLASS_NAME$1 = {
13565 atrule: "AtRule",
13566 comment: "Comment",
13567 decl: "Declaration",
13568 document: "Document",
13569 root: "Root",
13570 rule: "Rule"
13571 };
13572 var PLUGIN_PROPS$1 = {
13573 AtRule: true,
13574 AtRuleExit: true,
13575 Comment: true,
13576 CommentExit: true,
13577 Declaration: true,
13578 DeclarationExit: true,
13579 Document: true,
13580 DocumentExit: true,
13581 Once: true,
13582 OnceExit: true,
13583 postcssPlugin: true,
13584 prepare: true,
13585 Root: true,
13586 RootExit: true,
13587 Rule: true,
13588 RuleExit: true
13589 };
13590 var NOT_VISITORS$1 = {
13591 Once: true,
13592 postcssPlugin: true,
13593 prepare: true
13594 };
13595 var CHILDREN$1 = 0;
13596 function isPromise$1(obj) {
13597 return (typeof obj === "undefined" ? "undefined" : _type_of(obj)) === "object" && typeof obj.then === "function";
13598 }
13599 function getEvents$1(node2) {
13600 var key = false;
13601 var type = TYPE_TO_CLASS_NAME$1[node2.type];
13602 if (node2.type === "decl") {
13603 key = node2.prop.toLowerCase();
13604 } else if (node2.type === "atrule") {
13605 key = node2.name.toLowerCase();
13606 }
13607 if (key && node2.append) {
13608 return [
13609 type,
13610 type + "-" + key,
13611 CHILDREN$1,
13612 type + "Exit",
13613 type + "Exit-" + key
13614 ];
13615 } else if (key) {
13616 return [
13617 type,
13618 type + "-" + key,
13619 type + "Exit",
13620 type + "Exit-" + key
13621 ];
13622 } else if (node2.append) {
13623 return [
13624 type,
13625 CHILDREN$1,
13626 type + "Exit"
13627 ];
13628 } else {
13629 return [
13630 type,
13631 type + "Exit"
13632 ];
13633 }
13634 }
13635 function toStack$1(node2) {
13636 var events;
13637 if (node2.type === "document") {
13638 events = [
13639 "Document",
13640 CHILDREN$1,
13641 "DocumentExit"
13642 ];
13643 } else if (node2.type === "root") {
13644 events = [
13645 "Root",
13646 CHILDREN$1,
13647 "RootExit"
13648 ];
13649 } else {
13650 events = getEvents$1(node2);
13651 }
13652 return {
13653 eventIndex: 0,
13654 events: events,
13655 iterator: 0,
13656 node: node2,
13657 visitorIndex: 0,
13658 visitors: []
13659 };
13660 }
13661 function cleanMarks$1(node2) {
13662 node2[isClean$3] = false;
13663 if (node2.nodes) node2.nodes.forEach(function(i2) {
13664 return cleanMarks$1(i2);
13665 });
13666 return node2;
13667 }
13668 var postcss$2$1 = {};
13669 var LazyResult$2$1 = /*#__PURE__*/ function() {
13670 function LazyResult(processor2, css, opts) {
13671 var _this = this;
13672 this.stringified = false;
13673 this.processed = false;
13674 var root2;
13675 if ((typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && css !== null && (css.type === "root" || css.type === "document")) {
13676 root2 = cleanMarks$1(css);
13677 } else if (_instanceof(css, LazyResult) || _instanceof(css, Result$2$1)) {
13678 root2 = cleanMarks$1(css.root);
13679 if (css.map) {
13680 if (typeof opts.map === "undefined") opts.map = {};
13681 if (!opts.map.inline) opts.map.inline = false;
13682 opts.map.prev = css.map;
13683 }
13684 } else {
13685 var parser2 = parse$2$1;
13686 if (opts.syntax) parser2 = opts.syntax.parse;
13687 if (opts.parser) parser2 = opts.parser;
13688 if (parser2.parse) parser2 = parser2.parse;
13689 try {
13690 root2 = parser2(css, opts);
13691 } catch (error) {
13692 this.processed = true;
13693 this.error = error;
13694 }
13695 if (root2 && !root2[my$3]) {
13696 Container$1$1.rebuild(root2);
13697 }
13698 }
13699 this.result = new Result$2$1(processor2, root2, opts);
13700 this.helpers = _extends({}, postcss$2$1, {
13701 postcss: postcss$2$1,
13702 result: this.result
13703 });
13704 this.plugins = this.processor.plugins.map(function(plugin22) {
13705 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.prepare) {
13706 return _extends({}, plugin22, plugin22.prepare(_this.result));
13707 } else {
13708 return plugin22;
13709 }
13710 });
13711 }
13712 var _proto = LazyResult.prototype;
13713 _proto.async = function async() {
13714 if (this.error) return Promise.reject(this.error);
13715 if (this.processed) return Promise.resolve(this.result);
13716 if (!this.processing) {
13717 this.processing = this.runAsync();
13718 }
13719 return this.processing;
13720 };
13721 _proto.catch = function _catch(onRejected) {
13722 return this.async().catch(onRejected);
13723 };
13724 _proto.finally = function _finally(onFinally) {
13725 return this.async().then(onFinally, onFinally);
13726 };
13727 _proto.getAsyncError = function getAsyncError() {
13728 throw new Error("Use process(css).then(cb) to work with async plugins");
13729 };
13730 _proto.handleError = function handleError(error, node2) {
13731 var plugin22 = this.result.lastPlugin;
13732 try {
13733 if (node2) node2.addToError(error);
13734 this.error = error;
13735 if (error.name === "CssSyntaxError" && !error.plugin) {
13736 error.plugin = plugin22.postcssPlugin;
13737 error.setMessage();
13738 } else if (plugin22.postcssVersion) {
13739 if (true) {
13740 var pluginName = plugin22.postcssPlugin;
13741 var pluginVer = plugin22.postcssVersion;
13742 var runtimeVer = this.result.processor.version;
13743 var a2 = pluginVer.split(".");
13744 var b = runtimeVer.split(".");
13745 if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) {
13746 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.");
13747 }
13748 }
13749 }
13750 } catch (err) {
13751 if (console && console.error) console.error(err);
13752 }
13753 return error;
13754 };
13755 _proto.prepareVisitors = function prepareVisitors() {
13756 var _this = this;
13757 this.listeners = {};
13758 var add = function(plugin22, type, cb) {
13759 if (!_this.listeners[type]) _this.listeners[type] = [];
13760 _this.listeners[type].push([
13761 plugin22,
13762 cb
13763 ]);
13764 };
13765 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
13766 var plugin22 = _step.value;
13767 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object") {
13768 for(var event in plugin22){
13769 if (!PLUGIN_PROPS$1[event] && /^[A-Z]/.test(event)) {
13770 throw new Error("Unknown event " + event + " in " + plugin22.postcssPlugin + ". Try to update PostCSS (" + this.processor.version + " now).");
13771 }
13772 if (!NOT_VISITORS$1[event]) {
13773 if (_type_of(plugin22[event]) === "object") {
13774 for(var filter in plugin22[event]){
13775 if (filter === "*") {
13776 add(plugin22, event, plugin22[event][filter]);
13777 } else {
13778 add(plugin22, event + "-" + filter.toLowerCase(), plugin22[event][filter]);
13779 }
13780 }
13781 } else if (typeof plugin22[event] === "function") {
13782 add(plugin22, event, plugin22[event]);
13783 }
13784 }
13785 }
13786 }
13787 }
13788 this.hasListener = Object.keys(this.listeners).length > 0;
13789 };
13790 _proto.runAsync = function runAsync() {
13791 var _this = this;
13792 return _async_to_generator(function() {
13793 var i2, plugin22, promise, error, root2, stack, promise1, e2, node2, _loop, _iterator, _step;
13794 return _ts_generator(this, function(_state) {
13795 switch(_state.label){
13796 case 0:
13797 _this.plugin = 0;
13798 i2 = 0;
13799 _state.label = 1;
13800 case 1:
13801 if (!(i2 < _this.plugins.length)) return [
13802 3,
13803 6
13804 ];
13805 plugin22 = _this.plugins[i2];
13806 promise = _this.runOnRoot(plugin22);
13807 if (!isPromise$1(promise)) return [
13808 3,
13809 5
13810 ];
13811 _state.label = 2;
13812 case 2:
13813 _state.trys.push([
13814 2,
13815 4,
13816 ,
13817 5
13818 ]);
13819 return [
13820 4,
13821 promise
13822 ];
13823 case 3:
13824 _state.sent();
13825 return [
13826 3,
13827 5
13828 ];
13829 case 4:
13830 error = _state.sent();
13831 throw _this.handleError(error);
13832 case 5:
13833 i2++;
13834 return [
13835 3,
13836 1
13837 ];
13838 case 6:
13839 _this.prepareVisitors();
13840 if (!_this.hasListener) return [
13841 3,
13842 18
13843 ];
13844 root2 = _this.result.root;
13845 _state.label = 7;
13846 case 7:
13847 if (!!root2[isClean$3]) return [
13848 3,
13849 14
13850 ];
13851 root2[isClean$3] = true;
13852 stack = [
13853 toStack$1(root2)
13854 ];
13855 _state.label = 8;
13856 case 8:
13857 if (!(stack.length > 0)) return [
13858 3,
13859 13
13860 ];
13861 promise1 = _this.visitTick(stack);
13862 if (!isPromise$1(promise1)) return [
13863 3,
13864 12
13865 ];
13866 _state.label = 9;
13867 case 9:
13868 _state.trys.push([
13869 9,
13870 11,
13871 ,
13872 12
13873 ]);
13874 return [
13875 4,
13876 promise1
13877 ];
13878 case 10:
13879 _state.sent();
13880 return [
13881 3,
13882 12
13883 ];
13884 case 11:
13885 e2 = _state.sent();
13886 node2 = stack[stack.length - 1].node;
13887 throw _this.handleError(e2, node2);
13888 case 12:
13889 return [
13890 3,
13891 8
13892 ];
13893 case 13:
13894 return [
13895 3,
13896 7
13897 ];
13898 case 14:
13899 if (!_this.listeners.OnceExit) return [
13900 3,
13901 18
13902 ];
13903 _loop = function() {
13904 var _step_value, plugin22, visitor, roots, e2;
13905 return _ts_generator(this, function(_state) {
13906 switch(_state.label){
13907 case 0:
13908 _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
13909 _this.result.lastPlugin = plugin22;
13910 _state.label = 1;
13911 case 1:
13912 _state.trys.push([
13913 1,
13914 6,
13915 ,
13916 7
13917 ]);
13918 if (!(root2.type === "document")) return [
13919 3,
13920 3
13921 ];
13922 roots = root2.nodes.map(function(subRoot) {
13923 return visitor(subRoot, _this.helpers);
13924 });
13925 return [
13926 4,
13927 Promise.all(roots)
13928 ];
13929 case 2:
13930 _state.sent();
13931 return [
13932 3,
13933 5
13934 ];
13935 case 3:
13936 return [
13937 4,
13938 visitor(root2, _this.helpers)
13939 ];
13940 case 4:
13941 _state.sent();
13942 _state.label = 5;
13943 case 5:
13944 return [
13945 3,
13946 7
13947 ];
13948 case 6:
13949 e2 = _state.sent();
13950 throw _this.handleError(e2);
13951 case 7:
13952 return [
13953 2
13954 ];
13955 }
13956 });
13957 };
13958 _iterator = _create_for_of_iterator_helper_loose(_this.listeners.OnceExit);
13959 _state.label = 15;
13960 case 15:
13961 if (!!(_step = _iterator()).done) return [
13962 3,
13963 18
13964 ];
13965 return [
13966 5,
13967 _ts_values(_loop())
13968 ];
13969 case 16:
13970 _state.sent();
13971 _state.label = 17;
13972 case 17:
13973 return [
13974 3,
13975 15
13976 ];
13977 case 18:
13978 _this.processed = true;
13979 return [
13980 2,
13981 _this.stringify()
13982 ];
13983 }
13984 });
13985 })();
13986 };
13987 _proto.runOnRoot = function runOnRoot(plugin22) {
13988 var _this = this;
13989 this.result.lastPlugin = plugin22;
13990 try {
13991 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.Once) {
13992 if (this.result.root.type === "document") {
13993 var roots = this.result.root.nodes.map(function(root2) {
13994 return plugin22.Once(root2, _this.helpers);
13995 });
13996 if (isPromise$1(roots[0])) {
13997 return Promise.all(roots);
13998 }
13999 return roots;
14000 }
14001 return plugin22.Once(this.result.root, this.helpers);
14002 } else if (typeof plugin22 === "function") {
14003 return plugin22(this.result.root, this.result);
14004 }
14005 } catch (error) {
14006 throw this.handleError(error);
14007 }
14008 };
14009 _proto.stringify = function stringify() {
14010 if (this.error) throw this.error;
14011 if (this.stringified) return this.result;
14012 this.stringified = true;
14013 this.sync();
14014 var opts = this.result.opts;
14015 var str = stringify$2$1;
14016 if (opts.syntax) str = opts.syntax.stringify;
14017 if (opts.stringifier) str = opts.stringifier;
14018 if (str.stringify) str = str.stringify;
14019 var map = new MapGenerator$1$1(str, this.result.root, this.result.opts);
14020 var data = map.generate();
14021 this.result.css = data[0];
14022 this.result.map = data[1];
14023 return this.result;
14024 };
14025 _proto.sync = function sync() {
14026 if (this.error) throw this.error;
14027 if (this.processed) return this.result;
14028 this.processed = true;
14029 if (this.processing) {
14030 throw this.getAsyncError();
14031 }
14032 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
14033 var plugin22 = _step.value;
14034 var promise = this.runOnRoot(plugin22);
14035 if (isPromise$1(promise)) {
14036 throw this.getAsyncError();
14037 }
14038 }
14039 this.prepareVisitors();
14040 if (this.hasListener) {
14041 var root2 = this.result.root;
14042 while(!root2[isClean$3]){
14043 root2[isClean$3] = true;
14044 this.walkSync(root2);
14045 }
14046 if (this.listeners.OnceExit) {
14047 if (root2.type === "document") {
14048 for(var _iterator1 = _create_for_of_iterator_helper_loose(root2.nodes), _step1; !(_step1 = _iterator1()).done;){
14049 var subRoot = _step1.value;
14050 this.visitSync(this.listeners.OnceExit, subRoot);
14051 }
14052 } else {
14053 this.visitSync(this.listeners.OnceExit, root2);
14054 }
14055 }
14056 }
14057 return this.result;
14058 };
14059 _proto.then = function then(onFulfilled, onRejected) {
14060 if (true) {
14061 if (!("from" in this.opts)) {
14062 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.");
14063 }
14064 }
14065 return this.async().then(onFulfilled, onRejected);
14066 };
14067 _proto.toString = function toString() {
14068 return this.css;
14069 };
14070 _proto.visitSync = function visitSync(visitors, node2) {
14071 for(var _iterator = _create_for_of_iterator_helper_loose(visitors), _step; !(_step = _iterator()).done;){
14072 var _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
14073 this.result.lastPlugin = plugin22;
14074 var promise = void 0;
14075 try {
14076 promise = visitor(node2, this.helpers);
14077 } catch (e2) {
14078 throw this.handleError(e2, node2.proxyOf);
14079 }
14080 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
14081 return true;
14082 }
14083 if (isPromise$1(promise)) {
14084 throw this.getAsyncError();
14085 }
14086 }
14087 };
14088 _proto.visitTick = function visitTick(stack) {
14089 var visit2 = stack[stack.length - 1];
14090 var node2 = visit2.node, visitors = visit2.visitors;
14091 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
14092 stack.pop();
14093 return;
14094 }
14095 if (visitors.length > 0 && visit2.visitorIndex < visitors.length) {
14096 var _visitors_visit2_visitorIndex = visitors[visit2.visitorIndex], plugin22 = _visitors_visit2_visitorIndex[0], visitor = _visitors_visit2_visitorIndex[1];
14097 visit2.visitorIndex += 1;
14098 if (visit2.visitorIndex === visitors.length) {
14099 visit2.visitors = [];
14100 visit2.visitorIndex = 0;
14101 }
14102 this.result.lastPlugin = plugin22;
14103 try {
14104 return visitor(node2.toProxy(), this.helpers);
14105 } catch (e2) {
14106 throw this.handleError(e2, node2);
14107 }
14108 }
14109 if (visit2.iterator !== 0) {
14110 var iterator = visit2.iterator;
14111 var child;
14112 while(child = node2.nodes[node2.indexes[iterator]]){
14113 node2.indexes[iterator] += 1;
14114 if (!child[isClean$3]) {
14115 child[isClean$3] = true;
14116 stack.push(toStack$1(child));
14117 return;
14118 }
14119 }
14120 visit2.iterator = 0;
14121 delete node2.indexes[iterator];
14122 }
14123 var events = visit2.events;
14124 while(visit2.eventIndex < events.length){
14125 var event = events[visit2.eventIndex];
14126 visit2.eventIndex += 1;
14127 if (event === CHILDREN$1) {
14128 if (node2.nodes && node2.nodes.length) {
14129 node2[isClean$3] = true;
14130 visit2.iterator = node2.getIterator();
14131 }
14132 return;
14133 } else if (this.listeners[event]) {
14134 visit2.visitors = this.listeners[event];
14135 return;
14136 }
14137 }
14138 stack.pop();
14139 };
14140 _proto.walkSync = function walkSync(node2) {
14141 var _this = this;
14142 node2[isClean$3] = true;
14143 var events = getEvents$1(node2);
14144 for(var _iterator = _create_for_of_iterator_helper_loose(events), _step; !(_step = _iterator()).done;){
14145 var event = _step.value;
14146 if (event === CHILDREN$1) {
14147 if (node2.nodes) {
14148 node2.each(function(child) {
14149 if (!child[isClean$3]) _this.walkSync(child);
14150 });
14151 }
14152 } else {
14153 var visitors = this.listeners[event];
14154 if (visitors) {
14155 if (this.visitSync(visitors, node2.toProxy())) return;
14156 }
14157 }
14158 }
14159 };
14160 _proto.warnings = function warnings() {
14161 return this.sync().warnings();
14162 };
14163 _create_class(LazyResult, [
14164 {
14165 key: "content",
14166 get: function get() {
14167 return this.stringify().content;
14168 }
14169 },
14170 {
14171 key: "css",
14172 get: function get() {
14173 return this.stringify().css;
14174 }
14175 },
14176 {
14177 key: "map",
14178 get: function get() {
14179 return this.stringify().map;
14180 }
14181 },
14182 {
14183 key: "messages",
14184 get: function get() {
14185 return this.sync().messages;
14186 }
14187 },
14188 {
14189 key: "opts",
14190 get: function get() {
14191 return this.result.opts;
14192 }
14193 },
14194 {
14195 key: "processor",
14196 get: function get() {
14197 return this.result.processor;
14198 }
14199 },
14200 {
14201 key: "root",
14202 get: function get() {
14203 return this.sync().root;
14204 }
14205 },
14206 {
14207 key: Symbol.toStringTag,
14208 get: function get() {
14209 return "LazyResult";
14210 }
14211 }
14212 ]);
14213 return LazyResult;
14214 }();
14215 LazyResult$2$1.registerPostcss = function(dependant) {
14216 postcss$2$1 = dependant;
14217 };
14218 var lazyResult$1 = LazyResult$2$1;
14219 LazyResult$2$1.default = LazyResult$2$1;
14220 Root$3$1.registerLazyResult(LazyResult$2$1);
14221 Document$2$1.registerLazyResult(LazyResult$2$1);
14222 var MapGenerator2$1 = mapGenerator$1;
14223 var stringify$1$1 = stringify_1$1;
14224 var warnOnce2$1 = warnOnce$2$1;
14225 var parse$1$1 = parse_1$1;
14226 var Result$1$1 = result$1;
14227 var NoWorkResult$1$1 = /*#__PURE__*/ function() {
14228 function NoWorkResult(processor2, css, opts) {
14229 css = css.toString();
14230 this.stringified = false;
14231 this._processor = processor2;
14232 this._css = css;
14233 this._opts = opts;
14234 this._map = void 0;
14235 var root2;
14236 var str = stringify$1$1;
14237 this.result = new Result$1$1(this._processor, root2, this._opts);
14238 this.result.css = css;
14239 var self = this;
14240 Object.defineProperty(this.result, "root", {
14241 get: function get() {
14242 return self.root;
14243 }
14244 });
14245 var map = new MapGenerator2$1(str, root2, this._opts, css);
14246 if (map.isMap()) {
14247 var _map_generate = map.generate(), generatedCSS = _map_generate[0], generatedMap = _map_generate[1];
14248 if (generatedCSS) {
14249 this.result.css = generatedCSS;
14250 }
14251 if (generatedMap) {
14252 this.result.map = generatedMap;
14253 }
14254 } else {
14255 map.clearAnnotation();
14256 this.result.css = map.css;
14257 }
14258 }
14259 var _proto = NoWorkResult.prototype;
14260 _proto.async = function async() {
14261 if (this.error) return Promise.reject(this.error);
14262 return Promise.resolve(this.result);
14263 };
14264 _proto.catch = function _catch(onRejected) {
14265 return this.async().catch(onRejected);
14266 };
14267 _proto.finally = function _finally(onFinally) {
14268 return this.async().then(onFinally, onFinally);
14269 };
14270 _proto.sync = function sync() {
14271 if (this.error) throw this.error;
14272 return this.result;
14273 };
14274 _proto.then = function then(onFulfilled, onRejected) {
14275 if (true) {
14276 if (!("from" in this._opts)) {
14277 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.");
14278 }
14279 }
14280 return this.async().then(onFulfilled, onRejected);
14281 };
14282 _proto.toString = function toString() {
14283 return this._css;
14284 };
14285 _proto.warnings = function warnings() {
14286 return [];
14287 };
14288 _create_class(NoWorkResult, [
14289 {
14290 key: "content",
14291 get: function get() {
14292 return this.result.css;
14293 }
14294 },
14295 {
14296 key: "css",
14297 get: function get() {
14298 return this.result.css;
14299 }
14300 },
14301 {
14302 key: "map",
14303 get: function get() {
14304 return this.result.map;
14305 }
14306 },
14307 {
14308 key: "messages",
14309 get: function get() {
14310 return [];
14311 }
14312 },
14313 {
14314 key: "opts",
14315 get: function get() {
14316 return this.result.opts;
14317 }
14318 },
14319 {
14320 key: "processor",
14321 get: function get() {
14322 return this.result.processor;
14323 }
14324 },
14325 {
14326 key: "root",
14327 get: function get() {
14328 if (this._root) {
14329 return this._root;
14330 }
14331 var root2;
14332 var parser2 = parse$1$1;
14333 try {
14334 root2 = parser2(this._css, this._opts);
14335 } catch (error) {
14336 this.error = error;
14337 }
14338 if (this.error) {
14339 throw this.error;
14340 } else {
14341 this._root = root2;
14342 return root2;
14343 }
14344 }
14345 },
14346 {
14347 key: Symbol.toStringTag,
14348 get: function get() {
14349 return "NoWorkResult";
14350 }
14351 }
14352 ]);
14353 return NoWorkResult;
14354 }();
14355 var noWorkResult$1 = NoWorkResult$1$1;
14356 NoWorkResult$1$1.default = NoWorkResult$1$1;
14357 var NoWorkResult2$1 = noWorkResult$1;
14358 var LazyResult$1$1 = lazyResult$1;
14359 var Document$1$1 = document$1$1;
14360 var Root$2$1 = root$1;
14361 var Processor$1$1 = /*#__PURE__*/ function() {
14362 function Processor(plugins) {
14363 if (plugins === void 0) plugins = [];
14364 this.version = "8.4.38";
14365 this.plugins = this.normalize(plugins);
14366 }
14367 var _proto = Processor.prototype;
14368 _proto.normalize = function normalize(plugins) {
14369 var normalized = [];
14370 for(var _iterator = _create_for_of_iterator_helper_loose(plugins), _step; !(_step = _iterator()).done;){
14371 var i2 = _step.value;
14372 if (i2.postcss === true) {
14373 i2 = i2();
14374 } else if (i2.postcss) {
14375 i2 = i2.postcss;
14376 }
14377 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && Array.isArray(i2.plugins)) {
14378 normalized = normalized.concat(i2.plugins);
14379 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.postcssPlugin) {
14380 normalized.push(i2);
14381 } else if (typeof i2 === "function") {
14382 normalized.push(i2);
14383 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && (i2.parse || i2.stringify)) {
14384 if (true) {
14385 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.");
14386 }
14387 } else {
14388 throw new Error(i2 + " is not a PostCSS plugin");
14389 }
14390 }
14391 return normalized;
14392 };
14393 _proto.process = function process1(css, opts) {
14394 if (opts === void 0) opts = {};
14395 if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) {
14396 return new NoWorkResult2$1(this, css, opts);
14397 } else {
14398 return new LazyResult$1$1(this, css, opts);
14399 }
14400 };
14401 _proto.use = function use(plugin22) {
14402 this.plugins = this.plugins.concat(this.normalize([
14403 plugin22
14404 ]));
14405 return this;
14406 };
14407 return Processor;
14408 }();
14409 var processor$1 = Processor$1$1;
14410 Processor$1$1.default = Processor$1$1;
14411 Root$2$1.registerProcessor(Processor$1$1);
14412 Document$1$1.registerProcessor(Processor$1$1);
14413 var Declaration$1$1 = declaration$1;
14414 var PreviousMap2$1 = previousMap$1;
14415 var Comment$1$1 = comment$1;
14416 var AtRule$1$1 = atRule$1;
14417 var Input$1$1 = input$1;
14418 var Root$1$1 = root$1;
14419 var Rule$1$1 = rule$1;
14420 function fromJSON$1$1(json, inputs) {
14421 if (Array.isArray(json)) return json.map(function(n2) {
14422 return fromJSON$1$1(n2);
14423 });
14424 var ownInputs = json.inputs, defaults = _object_without_properties_loose(json, [
14425 "inputs"
14426 ]);
14427 if (ownInputs) {
14428 inputs = [];
14429 for(var _iterator = _create_for_of_iterator_helper_loose(ownInputs), _step; !(_step = _iterator()).done;){
14430 var input2 = _step.value;
14431 var inputHydrated = _extends({}, input2, {
14432 __proto__: Input$1$1.prototype
14433 });
14434 if (inputHydrated.map) {
14435 inputHydrated.map = _extends({}, inputHydrated.map, {
14436 __proto__: PreviousMap2$1.prototype
14437 });
14438 }
14439 inputs.push(inputHydrated);
14440 }
14441 }
14442 if (defaults.nodes) {
14443 defaults.nodes = json.nodes.map(function(n2) {
14444 return fromJSON$1$1(n2, inputs);
14445 });
14446 }
14447 if (defaults.source) {
14448 var _defaults_source = defaults.source, inputId = _defaults_source.inputId, source = _object_without_properties_loose(_defaults_source, [
14449 "inputId"
14450 ]);
14451 defaults.source = source;
14452 if (inputId != null) {
14453 defaults.source.input = inputs[inputId];
14454 }
14455 }
14456 if (defaults.type === "root") {
14457 return new Root$1$1(defaults);
14458 } else if (defaults.type === "decl") {
14459 return new Declaration$1$1(defaults);
14460 } else if (defaults.type === "rule") {
14461 return new Rule$1$1(defaults);
14462 } else if (defaults.type === "comment") {
14463 return new Comment$1$1(defaults);
14464 } else if (defaults.type === "atrule") {
14465 return new AtRule$1$1(defaults);
14466 } else {
14467 throw new Error("Unknown node type: " + json.type);
14468 }
14469 }
14470 var fromJSON_1$1 = fromJSON$1$1;
14471 fromJSON$1$1.default = fromJSON$1$1;
14472 var CssSyntaxError2$1 = cssSyntaxError$1;
14473 var Declaration2$1 = declaration$1;
14474 var LazyResult2$1 = lazyResult$1;
14475 var Container2$1 = container$1;
14476 var Processor2$1 = processor$1;
14477 var stringify$5 = stringify_1$1;
14478 var fromJSON$2 = fromJSON_1$1;
14479 var Document22 = document$1$1;
14480 var Warning2$1 = warning$1;
14481 var Comment2$1 = comment$1;
14482 var AtRule2$1 = atRule$1;
14483 var Result2$1 = result$1;
14484 var Input2$1 = input$1;
14485 var parse$5 = parse_1$1;
14486 var list$3 = list_1$1;
14487 var Rule2$1 = rule$1;
14488 var Root2$1 = root$1;
14489 var Node2$1 = node$1;
14490 function postcss$3() {
14491 for(var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++){
14492 plugins[_key] = arguments[_key];
14493 }
14494 if (plugins.length === 1 && Array.isArray(plugins[0])) {
14495 plugins = plugins[0];
14496 }
14497 return new Processor2$1(plugins);
14498 }
14499 postcss$3.plugin = function plugin(name, initializer) {
14500 var warningPrinted = false;
14501 function creator() {
14502 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
14503 args[_key] = arguments[_key];
14504 }
14505 if (console && console.warn && !warningPrinted) {
14506 warningPrinted = true;
14507 console.warn(name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration");
14508 if (process.env.LANG && process.env.LANG.startsWith("cn")) {
14509 console.warn(name + ": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226");
14510 }
14511 }
14512 var transformer = initializer.apply(void 0, [].concat(args));
14513 transformer.postcssPlugin = name;
14514 transformer.postcssVersion = new Processor2$1().version;
14515 return transformer;
14516 }
14517 var cache;
14518 Object.defineProperty(creator, "postcss", {
14519 get: function get() {
14520 if (!cache) cache = creator();
14521 return cache;
14522 }
14523 });
14524 creator.process = function(css, processOpts, pluginOpts) {
14525 return postcss$3([
14526 creator(pluginOpts)
14527 ]).process(css, processOpts);
14528 };
14529 return creator;
14530 };
14531 postcss$3.stringify = stringify$5;
14532 postcss$3.parse = parse$5;
14533 postcss$3.fromJSON = fromJSON$2;
14534 postcss$3.list = list$3;
14535 postcss$3.comment = function(defaults) {
14536 return new Comment2$1(defaults);
14537 };
14538 postcss$3.atRule = function(defaults) {
14539 return new AtRule2$1(defaults);
14540 };
14541 postcss$3.decl = function(defaults) {
14542 return new Declaration2$1(defaults);
14543 };
14544 postcss$3.rule = function(defaults) {
14545 return new Rule2$1(defaults);
14546 };
14547 postcss$3.root = function(defaults) {
14548 return new Root2$1(defaults);
14549 };
14550 postcss$3.document = function(defaults) {
14551 return new Document22(defaults);
14552 };
14553 postcss$3.CssSyntaxError = CssSyntaxError2$1;
14554 postcss$3.Declaration = Declaration2$1;
14555 postcss$3.Container = Container2$1;
14556 postcss$3.Processor = Processor2$1;
14557 postcss$3.Document = Document22;
14558 postcss$3.Comment = Comment2$1;
14559 postcss$3.Warning = Warning2$1;
14560 postcss$3.AtRule = AtRule2$1;
14561 postcss$3.Result = Result2$1;
14562 postcss$3.Input = Input2$1;
14563 postcss$3.Rule = Rule2$1;
14564 postcss$3.Root = Root2$1;
14565 postcss$3.Node = Node2$1;
14566 LazyResult2$1.registerPostcss(postcss$3);
14567 var postcss_1$1 = postcss$3;
14568 postcss$3.default = postcss$3;
14569 var postcss$1$1 = /* @__PURE__ */ getDefaultExportFromCjs$1(postcss_1$1);
14570 postcss$1$1.stringify;
14571 postcss$1$1.fromJSON;
14572 postcss$1$1.plugin;
14573 postcss$1$1.parse;
14574 postcss$1$1.list;
14575 postcss$1$1.document;
14576 postcss$1$1.comment;
14577 postcss$1$1.atRule;
14578 postcss$1$1.rule;
14579 postcss$1$1.decl;
14580 postcss$1$1.root;
14581 postcss$1$1.CssSyntaxError;
14582 postcss$1$1.Declaration;
14583 postcss$1$1.Container;
14584 postcss$1$1.Processor;
14585 postcss$1$1.Document;
14586 postcss$1$1.Comment;
14587 postcss$1$1.Warning;
14588 postcss$1$1.AtRule;
14589 postcss$1$1.Result;
14590 postcss$1$1.Input;
14591 postcss$1$1.Rule;
14592 postcss$1$1.Root;
14593 postcss$1$1.Node;
14594 var __defProp2 = Object.defineProperty;
14595 var __defNormalProp2 = function(obj, key, value) {
14596 return key in obj ? __defProp2(obj, key, {
14597 enumerable: true,
14598 configurable: true,
14599 writable: true,
14600 value: value
14601 }) : obj[key] = value;
14602 };
14603 var __publicField2 = function(obj, key, value) {
14604 return __defNormalProp2(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
14605 };
14606 function getDefaultExportFromCjs(x2) {
14607 return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
14608 }
14609 function getAugmentedNamespace(n2) {
14610 if (n2.__esModule) return n2;
14611 var f2 = n2.default;
14612 if (typeof f2 == "function") {
14613 var a2 = function a22() {
14614 if (_instanceof(this, a22)) {
14615 return Reflect.construct(f2, arguments, this.constructor);
14616 }
14617 return f2.apply(this, arguments);
14618 };
14619 a2.prototype = f2.prototype;
14620 } else a2 = {};
14621 Object.defineProperty(a2, "__esModule", {
14622 value: true
14623 });
14624 Object.keys(n2).forEach(function(k) {
14625 var d = Object.getOwnPropertyDescriptor(n2, k);
14626 Object.defineProperty(a2, k, d.get ? d : {
14627 enumerable: true,
14628 get: function get() {
14629 return n2[k];
14630 }
14631 });
14632 });
14633 return a2;
14634 }
14635 var picocolors_browser = {
14636 exports: {}
14637 };
14638 var x = String;
14639 var create = function create() {
14640 return {
14641 isColorSupported: false,
14642 reset: x,
14643 bold: x,
14644 dim: x,
14645 italic: x,
14646 underline: x,
14647 inverse: x,
14648 hidden: x,
14649 strikethrough: x,
14650 black: x,
14651 red: x,
14652 green: x,
14653 yellow: x,
14654 blue: x,
14655 magenta: x,
14656 cyan: x,
14657 white: x,
14658 gray: x,
14659 bgBlack: x,
14660 bgRed: x,
14661 bgGreen: x,
14662 bgYellow: x,
14663 bgBlue: x,
14664 bgMagenta: x,
14665 bgCyan: x,
14666 bgWhite: x
14667 };
14668 };
14669 picocolors_browser.exports = create();
14670 picocolors_browser.exports.createColors = create;
14671 var picocolors_browserExports = picocolors_browser.exports;
14672 var __viteBrowserExternal = {};
14673 var __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
14674 __proto__: null,
14675 default: __viteBrowserExternal
14676 }, Symbol.toStringTag, {
14677 value: "Module"
14678 }));
14679 var require$$2 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1);
14680 var pico = picocolors_browserExports;
14681 var terminalHighlight$1 = require$$2;
14682 var CssSyntaxError$3 = /*#__PURE__*/ function(Error1) {
14683 _inherits(CssSyntaxError2, Error1);
14684 function CssSyntaxError2(message, line, column, source, file, plugin22) {
14685 var _this;
14686 _this = Error1.call(this, message) || this;
14687 _this.name = "CssSyntaxError";
14688 _this.reason = message;
14689 if (file) {
14690 _this.file = file;
14691 }
14692 if (source) {
14693 _this.source = source;
14694 }
14695 if (plugin22) {
14696 _this.plugin = plugin22;
14697 }
14698 if (typeof line !== "undefined" && typeof column !== "undefined") {
14699 if (typeof line === "number") {
14700 _this.line = line;
14701 _this.column = column;
14702 } else {
14703 _this.line = line.line;
14704 _this.column = line.column;
14705 _this.endLine = column.line;
14706 _this.endColumn = column.column;
14707 }
14708 }
14709 _this.setMessage();
14710 if (Error.captureStackTrace) {
14711 Error.captureStackTrace(_this, CssSyntaxError2);
14712 }
14713 return _this;
14714 }
14715 var _proto = CssSyntaxError2.prototype;
14716 _proto.setMessage = function setMessage() {
14717 this.message = this.plugin ? this.plugin + ": " : "";
14718 this.message += this.file ? this.file : "<css input>";
14719 if (typeof this.line !== "undefined") {
14720 this.message += ":" + this.line + ":" + this.column;
14721 }
14722 this.message += ": " + this.reason;
14723 };
14724 _proto.showSourceCode = function showSourceCode(color) {
14725 var _this = this;
14726 if (!this.source) return "";
14727 var css = this.source;
14728 if (color == null) color = pico.isColorSupported;
14729 if (terminalHighlight$1) {
14730 if (color) css = terminalHighlight$1(css);
14731 }
14732 var lines = css.split(/\r?\n/);
14733 var start = Math.max(this.line - 3, 0);
14734 var end = Math.min(this.line + 2, lines.length);
14735 var maxWidth = String(end).length;
14736 var mark, aside;
14737 if (color) {
14738 var _pico_createColors = pico.createColors(true), bold = _pico_createColors.bold, gray = _pico_createColors.gray, red = _pico_createColors.red;
14739 mark = function(text) {
14740 return bold(red(text));
14741 };
14742 aside = function(text) {
14743 return gray(text);
14744 };
14745 } else {
14746 mark = aside = function(str) {
14747 return str;
14748 };
14749 }
14750 return lines.slice(start, end).map(function(line, index2) {
14751 var number = start + 1 + index2;
14752 var gutter = " " + (" " + number).slice(-maxWidth) + " | ";
14753 if (number === _this.line) {
14754 var spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, _this.column - 1).replace(/[^\t]/g, " ");
14755 return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^");
14756 }
14757 return " " + aside(gutter) + line;
14758 }).join("\n");
14759 };
14760 _proto.toString = function toString() {
14761 var code = this.showSourceCode();
14762 if (code) {
14763 code = "\n\n" + code + "\n";
14764 }
14765 return this.name + ": " + this.message + code;
14766 };
14767 return CssSyntaxError2;
14768 }(_wrap_native_super(Error));
14769 var cssSyntaxError = CssSyntaxError$3;
14770 CssSyntaxError$3.default = CssSyntaxError$3;
14771 var symbols = {};
14772 symbols.isClean = Symbol("isClean");
14773 symbols.my = Symbol("my");
14774 var DEFAULT_RAW = {
14775 after: "\n",
14776 beforeClose: "\n",
14777 beforeComment: "\n",
14778 beforeDecl: "\n",
14779 beforeOpen: " ",
14780 beforeRule: "\n",
14781 colon: ": ",
14782 commentLeft: " ",
14783 commentRight: " ",
14784 emptyBody: "",
14785 indent: " ",
14786 semicolon: false
14787 };
14788 function capitalize(str) {
14789 return str[0].toUpperCase() + str.slice(1);
14790 }
14791 var Stringifier$2 = /*#__PURE__*/ function() {
14792 function Stringifier2(builder) {
14793 this.builder = builder;
14794 }
14795 var _proto = Stringifier2.prototype;
14796 _proto.atrule = function atrule(node2, semicolon) {
14797 var name = "@" + node2.name;
14798 var params = node2.params ? this.rawValue(node2, "params") : "";
14799 if (typeof node2.raws.afterName !== "undefined") {
14800 name += node2.raws.afterName;
14801 } else if (params) {
14802 name += " ";
14803 }
14804 if (node2.nodes) {
14805 this.block(node2, name + params);
14806 } else {
14807 var end = (node2.raws.between || "") + (semicolon ? ";" : "");
14808 this.builder(name + params + end, node2);
14809 }
14810 };
14811 _proto.beforeAfter = function beforeAfter(node2, detect) {
14812 var value;
14813 if (node2.type === "decl") {
14814 value = this.raw(node2, null, "beforeDecl");
14815 } else if (node2.type === "comment") {
14816 value = this.raw(node2, null, "beforeComment");
14817 } else if (detect === "before") {
14818 value = this.raw(node2, null, "beforeRule");
14819 } else {
14820 value = this.raw(node2, null, "beforeClose");
14821 }
14822 var buf = node2.parent;
14823 var depth = 0;
14824 while(buf && buf.type !== "root"){
14825 depth += 1;
14826 buf = buf.parent;
14827 }
14828 if (value.includes("\n")) {
14829 var indent = this.raw(node2, null, "indent");
14830 if (indent.length) {
14831 for(var step = 0; step < depth; step++)value += indent;
14832 }
14833 }
14834 return value;
14835 };
14836 _proto.block = function block(node2, start) {
14837 var between = this.raw(node2, "between", "beforeOpen");
14838 this.builder(start + between + "{", node2, "start");
14839 var after;
14840 if (node2.nodes && node2.nodes.length) {
14841 this.body(node2);
14842 after = this.raw(node2, "after");
14843 } else {
14844 after = this.raw(node2, "after", "emptyBody");
14845 }
14846 if (after) this.builder(after);
14847 this.builder("}", node2, "end");
14848 };
14849 _proto.body = function body(node2) {
14850 var last = node2.nodes.length - 1;
14851 while(last > 0){
14852 if (node2.nodes[last].type !== "comment") break;
14853 last -= 1;
14854 }
14855 var semicolon = this.raw(node2, "semicolon");
14856 for(var i2 = 0; i2 < node2.nodes.length; i2++){
14857 var child = node2.nodes[i2];
14858 var before = this.raw(child, "before");
14859 if (before) this.builder(before);
14860 this.stringify(child, last !== i2 || semicolon);
14861 }
14862 };
14863 _proto.comment = function comment(node2) {
14864 var left = this.raw(node2, "left", "commentLeft");
14865 var right = this.raw(node2, "right", "commentRight");
14866 this.builder("/*" + left + node2.text + right + "*/", node2);
14867 };
14868 _proto.decl = function decl(node2, semicolon) {
14869 var between = this.raw(node2, "between", "colon");
14870 var string = node2.prop + between + this.rawValue(node2, "value");
14871 if (node2.important) {
14872 string += node2.raws.important || " !important";
14873 }
14874 if (semicolon) string += ";";
14875 this.builder(string, node2);
14876 };
14877 _proto.document = function document1(node2) {
14878 this.body(node2);
14879 };
14880 _proto.raw = function raw(node2, own, detect) {
14881 var value;
14882 if (!detect) detect = own;
14883 if (own) {
14884 value = node2.raws[own];
14885 if (typeof value !== "undefined") return value;
14886 }
14887 var parent = node2.parent;
14888 if (detect === "before") {
14889 if (!parent || parent.type === "root" && parent.first === node2) {
14890 return "";
14891 }
14892 if (parent && parent.type === "document") {
14893 return "";
14894 }
14895 }
14896 if (!parent) return DEFAULT_RAW[detect];
14897 var root2 = node2.root();
14898 if (!root2.rawCache) root2.rawCache = {};
14899 if (typeof root2.rawCache[detect] !== "undefined") {
14900 return root2.rawCache[detect];
14901 }
14902 if (detect === "before" || detect === "after") {
14903 return this.beforeAfter(node2, detect);
14904 } else {
14905 var method = "raw" + capitalize(detect);
14906 if (this[method]) {
14907 value = this[method](root2, node2);
14908 } else {
14909 root2.walk(function(i2) {
14910 value = i2.raws[own];
14911 if (typeof value !== "undefined") return false;
14912 });
14913 }
14914 }
14915 if (typeof value === "undefined") value = DEFAULT_RAW[detect];
14916 root2.rawCache[detect] = value;
14917 return value;
14918 };
14919 _proto.rawBeforeClose = function rawBeforeClose(root2) {
14920 var value;
14921 root2.walk(function(i2) {
14922 if (i2.nodes && i2.nodes.length > 0) {
14923 if (typeof i2.raws.after !== "undefined") {
14924 value = i2.raws.after;
14925 if (value.includes("\n")) {
14926 value = value.replace(/[^\n]+$/, "");
14927 }
14928 return false;
14929 }
14930 }
14931 });
14932 if (value) value = value.replace(/\S/g, "");
14933 return value;
14934 };
14935 _proto.rawBeforeComment = function rawBeforeComment(root2, node2) {
14936 var value;
14937 root2.walkComments(function(i2) {
14938 if (typeof i2.raws.before !== "undefined") {
14939 value = i2.raws.before;
14940 if (value.includes("\n")) {
14941 value = value.replace(/[^\n]+$/, "");
14942 }
14943 return false;
14944 }
14945 });
14946 if (typeof value === "undefined") {
14947 value = this.raw(node2, null, "beforeDecl");
14948 } else if (value) {
14949 value = value.replace(/\S/g, "");
14950 }
14951 return value;
14952 };
14953 _proto.rawBeforeDecl = function rawBeforeDecl(root2, node2) {
14954 var value;
14955 root2.walkDecls(function(i2) {
14956 if (typeof i2.raws.before !== "undefined") {
14957 value = i2.raws.before;
14958 if (value.includes("\n")) {
14959 value = value.replace(/[^\n]+$/, "");
14960 }
14961 return false;
14962 }
14963 });
14964 if (typeof value === "undefined") {
14965 value = this.raw(node2, null, "beforeRule");
14966 } else if (value) {
14967 value = value.replace(/\S/g, "");
14968 }
14969 return value;
14970 };
14971 _proto.rawBeforeOpen = function rawBeforeOpen(root2) {
14972 var value;
14973 root2.walk(function(i2) {
14974 if (i2.type !== "decl") {
14975 value = i2.raws.between;
14976 if (typeof value !== "undefined") return false;
14977 }
14978 });
14979 return value;
14980 };
14981 _proto.rawBeforeRule = function rawBeforeRule(root2) {
14982 var value;
14983 root2.walk(function(i2) {
14984 if (i2.nodes && (i2.parent !== root2 || root2.first !== i2)) {
14985 if (typeof i2.raws.before !== "undefined") {
14986 value = i2.raws.before;
14987 if (value.includes("\n")) {
14988 value = value.replace(/[^\n]+$/, "");
14989 }
14990 return false;
14991 }
14992 }
14993 });
14994 if (value) value = value.replace(/\S/g, "");
14995 return value;
14996 };
14997 _proto.rawColon = function rawColon(root2) {
14998 var value;
14999 root2.walkDecls(function(i2) {
15000 if (typeof i2.raws.between !== "undefined") {
15001 value = i2.raws.between.replace(/[^\s:]/g, "");
15002 return false;
15003 }
15004 });
15005 return value;
15006 };
15007 _proto.rawEmptyBody = function rawEmptyBody(root2) {
15008 var value;
15009 root2.walk(function(i2) {
15010 if (i2.nodes && i2.nodes.length === 0) {
15011 value = i2.raws.after;
15012 if (typeof value !== "undefined") return false;
15013 }
15014 });
15015 return value;
15016 };
15017 _proto.rawIndent = function rawIndent(root2) {
15018 if (root2.raws.indent) return root2.raws.indent;
15019 var value;
15020 root2.walk(function(i2) {
15021 var p = i2.parent;
15022 if (p && p !== root2 && p.parent && p.parent === root2) {
15023 if (typeof i2.raws.before !== "undefined") {
15024 var parts = i2.raws.before.split("\n");
15025 value = parts[parts.length - 1];
15026 value = value.replace(/\S/g, "");
15027 return false;
15028 }
15029 }
15030 });
15031 return value;
15032 };
15033 _proto.rawSemicolon = function rawSemicolon(root2) {
15034 var value;
15035 root2.walk(function(i2) {
15036 if (i2.nodes && i2.nodes.length && i2.last.type === "decl") {
15037 value = i2.raws.semicolon;
15038 if (typeof value !== "undefined") return false;
15039 }
15040 });
15041 return value;
15042 };
15043 _proto.rawValue = function rawValue(node2, prop) {
15044 var value = node2[prop];
15045 var raw = node2.raws[prop];
15046 if (raw && raw.value === value) {
15047 return raw.raw;
15048 }
15049 return value;
15050 };
15051 _proto.root = function root(node2) {
15052 this.body(node2);
15053 if (node2.raws.after) this.builder(node2.raws.after);
15054 };
15055 _proto.rule = function rule(node2) {
15056 this.block(node2, this.rawValue(node2, "selector"));
15057 if (node2.raws.ownSemicolon) {
15058 this.builder(node2.raws.ownSemicolon, node2, "end");
15059 }
15060 };
15061 _proto.stringify = function stringify(node2, semicolon) {
15062 if (!this[node2.type]) {
15063 throw new Error("Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier.");
15064 }
15065 this[node2.type](node2, semicolon);
15066 };
15067 return Stringifier2;
15068 }();
15069 var stringifier = Stringifier$2;
15070 Stringifier$2.default = Stringifier$2;
15071 var Stringifier$1 = stringifier;
15072 function stringify$4(node2, builder) {
15073 var str = new Stringifier$1(builder);
15074 str.stringify(node2);
15075 }
15076 var stringify_1 = stringify$4;
15077 stringify$4.default = stringify$4;
15078 var isClean$2 = symbols.isClean, my$2 = symbols.my;
15079 var CssSyntaxError$2 = cssSyntaxError;
15080 var Stringifier22 = stringifier;
15081 var stringify$3 = stringify_1;
15082 function cloneNode(obj, parent) {
15083 var cloned = new obj.constructor();
15084 for(var i2 in obj){
15085 if (!Object.prototype.hasOwnProperty.call(obj, i2)) {
15086 continue;
15087 }
15088 if (i2 === "proxyCache") continue;
15089 var value = obj[i2];
15090 var type = typeof value === "undefined" ? "undefined" : _type_of(value);
15091 if (i2 === "parent" && type === "object") {
15092 if (parent) cloned[i2] = parent;
15093 } else if (i2 === "source") {
15094 cloned[i2] = value;
15095 } else if (Array.isArray(value)) {
15096 cloned[i2] = value.map(function(j) {
15097 return cloneNode(j, cloned);
15098 });
15099 } else {
15100 if (type === "object" && value !== null) value = cloneNode(value);
15101 cloned[i2] = value;
15102 }
15103 }
15104 return cloned;
15105 }
15106 var Node$4 = /*#__PURE__*/ function() {
15107 function Node3(defaults) {
15108 if (defaults === void 0) defaults = {};
15109 this.raws = {};
15110 this[isClean$2] = false;
15111 this[my$2] = true;
15112 for(var name in defaults){
15113 if (name === "nodes") {
15114 this.nodes = [];
15115 for(var _iterator = _create_for_of_iterator_helper_loose(defaults[name]), _step; !(_step = _iterator()).done;){
15116 var node2 = _step.value;
15117 if (typeof node2.clone === "function") {
15118 this.append(node2.clone());
15119 } else {
15120 this.append(node2);
15121 }
15122 }
15123 } else {
15124 this[name] = defaults[name];
15125 }
15126 }
15127 }
15128 var _proto = Node3.prototype;
15129 _proto.addToError = function addToError(error) {
15130 error.postcssNode = this;
15131 if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
15132 var s2 = this.source;
15133 error.stack = error.stack.replace(/\n\s{4}at /, "$&" + s2.input.from + ":" + s2.start.line + ":" + s2.start.column + "$&");
15134 }
15135 return error;
15136 };
15137 _proto.after = function after(add) {
15138 this.parent.insertAfter(this, add);
15139 return this;
15140 };
15141 _proto.assign = function assign(overrides) {
15142 if (overrides === void 0) overrides = {};
15143 for(var name in overrides){
15144 this[name] = overrides[name];
15145 }
15146 return this;
15147 };
15148 _proto.before = function before(add) {
15149 this.parent.insertBefore(this, add);
15150 return this;
15151 };
15152 _proto.cleanRaws = function cleanRaws(keepBetween) {
15153 delete this.raws.before;
15154 delete this.raws.after;
15155 if (!keepBetween) delete this.raws.between;
15156 };
15157 _proto.clone = function clone(overrides) {
15158 if (overrides === void 0) overrides = {};
15159 var cloned = cloneNode(this);
15160 for(var name in overrides){
15161 cloned[name] = overrides[name];
15162 }
15163 return cloned;
15164 };
15165 _proto.cloneAfter = function cloneAfter(overrides) {
15166 if (overrides === void 0) overrides = {};
15167 var cloned = this.clone(overrides);
15168 this.parent.insertAfter(this, cloned);
15169 return cloned;
15170 };
15171 _proto.cloneBefore = function cloneBefore(overrides) {
15172 if (overrides === void 0) overrides = {};
15173 var cloned = this.clone(overrides);
15174 this.parent.insertBefore(this, cloned);
15175 return cloned;
15176 };
15177 _proto.error = function error(message, opts) {
15178 if (opts === void 0) opts = {};
15179 if (this.source) {
15180 var _this_rangeBy = this.rangeBy(opts), end = _this_rangeBy.end, start = _this_rangeBy.start;
15181 return this.source.input.error(message, {
15182 column: start.column,
15183 line: start.line
15184 }, {
15185 column: end.column,
15186 line: end.line
15187 }, opts);
15188 }
15189 return new CssSyntaxError$2(message);
15190 };
15191 _proto.getProxyProcessor = function getProxyProcessor() {
15192 return {
15193 get: function get(node2, prop) {
15194 if (prop === "proxyOf") {
15195 return node2;
15196 } else if (prop === "root") {
15197 return function() {
15198 return node2.root().toProxy();
15199 };
15200 } else {
15201 return node2[prop];
15202 }
15203 },
15204 set: function set(node2, prop, value) {
15205 if (node2[prop] === value) return true;
15206 node2[prop] = value;
15207 if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ prop === "text") {
15208 node2.markDirty();
15209 }
15210 return true;
15211 }
15212 };
15213 };
15214 _proto.markDirty = function markDirty() {
15215 if (this[isClean$2]) {
15216 this[isClean$2] = false;
15217 var next = this;
15218 while(next = next.parent){
15219 next[isClean$2] = false;
15220 }
15221 }
15222 };
15223 _proto.next = function next() {
15224 if (!this.parent) return void 0;
15225 var index2 = this.parent.index(this);
15226 return this.parent.nodes[index2 + 1];
15227 };
15228 _proto.positionBy = function positionBy(opts, stringRepresentation) {
15229 var pos = this.source.start;
15230 if (opts.index) {
15231 pos = this.positionInside(opts.index, stringRepresentation);
15232 } else if (opts.word) {
15233 stringRepresentation = this.toString();
15234 var index2 = stringRepresentation.indexOf(opts.word);
15235 if (index2 !== -1) pos = this.positionInside(index2, stringRepresentation);
15236 }
15237 return pos;
15238 };
15239 _proto.positionInside = function positionInside(index2, stringRepresentation) {
15240 var string = stringRepresentation || this.toString();
15241 var column = this.source.start.column;
15242 var line = this.source.start.line;
15243 for(var i2 = 0; i2 < index2; i2++){
15244 if (string[i2] === "\n") {
15245 column = 1;
15246 line += 1;
15247 } else {
15248 column += 1;
15249 }
15250 }
15251 return {
15252 column: column,
15253 line: line
15254 };
15255 };
15256 _proto.prev = function prev() {
15257 if (!this.parent) return void 0;
15258 var index2 = this.parent.index(this);
15259 return this.parent.nodes[index2 - 1];
15260 };
15261 _proto.rangeBy = function rangeBy(opts) {
15262 var start = {
15263 column: this.source.start.column,
15264 line: this.source.start.line
15265 };
15266 var end = this.source.end ? {
15267 column: this.source.end.column + 1,
15268 line: this.source.end.line
15269 } : {
15270 column: start.column + 1,
15271 line: start.line
15272 };
15273 if (opts.word) {
15274 var stringRepresentation = this.toString();
15275 var index2 = stringRepresentation.indexOf(opts.word);
15276 if (index2 !== -1) {
15277 start = this.positionInside(index2, stringRepresentation);
15278 end = this.positionInside(index2 + opts.word.length, stringRepresentation);
15279 }
15280 } else {
15281 if (opts.start) {
15282 start = {
15283 column: opts.start.column,
15284 line: opts.start.line
15285 };
15286 } else if (opts.index) {
15287 start = this.positionInside(opts.index);
15288 }
15289 if (opts.end) {
15290 end = {
15291 column: opts.end.column,
15292 line: opts.end.line
15293 };
15294 } else if (typeof opts.endIndex === "number") {
15295 end = this.positionInside(opts.endIndex);
15296 } else if (opts.index) {
15297 end = this.positionInside(opts.index + 1);
15298 }
15299 }
15300 if (end.line < start.line || end.line === start.line && end.column <= start.column) {
15301 end = {
15302 column: start.column + 1,
15303 line: start.line
15304 };
15305 }
15306 return {
15307 end: end,
15308 start: start
15309 };
15310 };
15311 _proto.raw = function raw(prop, defaultType) {
15312 var str = new Stringifier22();
15313 return str.raw(this, prop, defaultType);
15314 };
15315 _proto.remove = function remove() {
15316 if (this.parent) {
15317 this.parent.removeChild(this);
15318 }
15319 this.parent = void 0;
15320 return this;
15321 };
15322 _proto.replaceWith = function replaceWith() {
15323 for(var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++){
15324 nodes[_key] = arguments[_key];
15325 }
15326 if (this.parent) {
15327 var bookmark = this;
15328 var foundSelf = false;
15329 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
15330 var node2 = _step.value;
15331 if (node2 === this) {
15332 foundSelf = true;
15333 } else if (foundSelf) {
15334 this.parent.insertAfter(bookmark, node2);
15335 bookmark = node2;
15336 } else {
15337 this.parent.insertBefore(bookmark, node2);
15338 }
15339 }
15340 if (!foundSelf) {
15341 this.remove();
15342 }
15343 }
15344 return this;
15345 };
15346 _proto.root = function root() {
15347 var result2 = this;
15348 while(result2.parent && result2.parent.type !== "document"){
15349 result2 = result2.parent;
15350 }
15351 return result2;
15352 };
15353 _proto.toJSON = function toJSON(_, inputs) {
15354 var fixed = {};
15355 var emitInputs = inputs == null;
15356 inputs = inputs || /* @__PURE__ */ new Map();
15357 var inputsNextIndex = 0;
15358 for(var name in this){
15359 if (!Object.prototype.hasOwnProperty.call(this, name)) {
15360 continue;
15361 }
15362 if (name === "parent" || name === "proxyCache") continue;
15363 var value = this[name];
15364 if (Array.isArray(value)) {
15365 fixed[name] = value.map(function(i2) {
15366 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.toJSON) {
15367 return i2.toJSON(null, inputs);
15368 } else {
15369 return i2;
15370 }
15371 });
15372 } else if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value.toJSON) {
15373 fixed[name] = value.toJSON(null, inputs);
15374 } else if (name === "source") {
15375 var inputId = inputs.get(value.input);
15376 if (inputId == null) {
15377 inputId = inputsNextIndex;
15378 inputs.set(value.input, inputsNextIndex);
15379 inputsNextIndex++;
15380 }
15381 fixed[name] = {
15382 end: value.end,
15383 inputId: inputId,
15384 start: value.start
15385 };
15386 } else {
15387 fixed[name] = value;
15388 }
15389 }
15390 if (emitInputs) {
15391 fixed.inputs = [].concat(inputs.keys()).map(function(input2) {
15392 return input2.toJSON();
15393 });
15394 }
15395 return fixed;
15396 };
15397 _proto.toProxy = function toProxy() {
15398 if (!this.proxyCache) {
15399 this.proxyCache = new Proxy(this, this.getProxyProcessor());
15400 }
15401 return this.proxyCache;
15402 };
15403 _proto.toString = function toString(stringifier2) {
15404 if (stringifier2 === void 0) stringifier2 = stringify$3;
15405 if (stringifier2.stringify) stringifier2 = stringifier2.stringify;
15406 var result2 = "";
15407 stringifier2(this, function(i2) {
15408 result2 += i2;
15409 });
15410 return result2;
15411 };
15412 _proto.warn = function warn(result2, text, opts) {
15413 var data = {
15414 node: this
15415 };
15416 for(var i2 in opts)data[i2] = opts[i2];
15417 return result2.warn(text, data);
15418 };
15419 _create_class(Node3, [
15420 {
15421 key: "proxyOf",
15422 get: function get() {
15423 return this;
15424 }
15425 }
15426 ]);
15427 return Node3;
15428 }();
15429 var node = Node$4;
15430 Node$4.default = Node$4;
15431 var Node$3 = node;
15432 var Declaration$4 = /*#__PURE__*/ function(Node$3) {
15433 _inherits(Declaration2, Node$3);
15434 function Declaration2(defaults) {
15435 var _this;
15436 if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
15437 defaults = _extends({}, defaults, {
15438 value: String(defaults.value)
15439 });
15440 }
15441 _this = Node$3.call(this, defaults) || this;
15442 _this.type = "decl";
15443 return _this;
15444 }
15445 _create_class(Declaration2, [
15446 {
15447 key: "variable",
15448 get: function get() {
15449 return this.prop.startsWith("--") || this.prop[0] === "$";
15450 }
15451 }
15452 ]);
15453 return Declaration2;
15454 }(Node$3);
15455 var declaration = Declaration$4;
15456 Declaration$4.default = Declaration$4;
15457 var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
15458 var nanoid$1 = function(size) {
15459 if (size === void 0) size = 21;
15460 var id = "";
15461 var i2 = size;
15462 while(i2--){
15463 id += urlAlphabet[Math.random() * 64 | 0];
15464 }
15465 return id;
15466 };
15467 var nonSecure = {
15468 nanoid: nanoid$1};
15469 var SourceMapConsumer$2 = require$$2.SourceMapConsumer, SourceMapGenerator$2 = require$$2.SourceMapGenerator;
15470 var existsSync = require$$2.existsSync, readFileSync = require$$2.readFileSync;
15471 var dirname$1 = require$$2.dirname, join = require$$2.join;
15472 function fromBase64(str) {
15473 if (Buffer) {
15474 return Buffer.from(str, "base64").toString();
15475 } else {
15476 return window.atob(str);
15477 }
15478 }
15479 var PreviousMap$2 = /*#__PURE__*/ function() {
15480 function PreviousMap2(css, opts) {
15481 if (opts.map === false) return;
15482 this.loadAnnotation(css);
15483 this.inline = this.startWith(this.annotation, "data:");
15484 var prev = opts.map ? opts.map.prev : void 0;
15485 var text = this.loadMap(opts.from, prev);
15486 if (!this.mapFile && opts.from) {
15487 this.mapFile = opts.from;
15488 }
15489 if (this.mapFile) this.root = dirname$1(this.mapFile);
15490 if (text) this.text = text;
15491 }
15492 var _proto = PreviousMap2.prototype;
15493 _proto.consumer = function consumer() {
15494 if (!this.consumerCache) {
15495 this.consumerCache = new SourceMapConsumer$2(this.text);
15496 }
15497 return this.consumerCache;
15498 };
15499 _proto.decodeInline = function decodeInline(text) {
15500 var baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
15501 var baseUri = /^data:application\/json;base64,/;
15502 var charsetUri = /^data:application\/json;charset=utf-?8,/;
15503 var uri = /^data:application\/json,/;
15504 if (charsetUri.test(text) || uri.test(text)) {
15505 return decodeURIComponent(text.substr(RegExp.lastMatch.length));
15506 }
15507 if (baseCharsetUri.test(text) || baseUri.test(text)) {
15508 return fromBase64(text.substr(RegExp.lastMatch.length));
15509 }
15510 var encoding = text.match(/data:application\/json;([^,]+),/)[1];
15511 throw new Error("Unsupported source map encoding " + encoding);
15512 };
15513 _proto.getAnnotationURL = function getAnnotationURL(sourceMapString) {
15514 return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
15515 };
15516 _proto.isMap = function isMap(map) {
15517 if ((typeof map === "undefined" ? "undefined" : _type_of(map)) !== "object") return false;
15518 return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
15519 };
15520 _proto.loadAnnotation = function loadAnnotation(css) {
15521 var comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
15522 if (!comments) return;
15523 var start = css.lastIndexOf(comments.pop());
15524 var end = css.indexOf("*/", start);
15525 if (start > -1 && end > -1) {
15526 this.annotation = this.getAnnotationURL(css.substring(start, end));
15527 }
15528 };
15529 _proto.loadFile = function loadFile(path) {
15530 this.root = dirname$1(path);
15531 if (existsSync(path)) {
15532 this.mapFile = path;
15533 return readFileSync(path, "utf-8").toString().trim();
15534 }
15535 };
15536 _proto.loadMap = function loadMap(file, prev) {
15537 if (prev === false) return false;
15538 if (prev) {
15539 if (typeof prev === "string") {
15540 return prev;
15541 } else if (typeof prev === "function") {
15542 var prevPath = prev(file);
15543 if (prevPath) {
15544 var map = this.loadFile(prevPath);
15545 if (!map) {
15546 throw new Error("Unable to load previous source map: " + prevPath.toString());
15547 }
15548 return map;
15549 }
15550 } else if (_instanceof(prev, SourceMapConsumer$2)) {
15551 return SourceMapGenerator$2.fromSourceMap(prev).toString();
15552 } else if (_instanceof(prev, SourceMapGenerator$2)) {
15553 return prev.toString();
15554 } else if (this.isMap(prev)) {
15555 return JSON.stringify(prev);
15556 } else {
15557 throw new Error("Unsupported previous source map format: " + prev.toString());
15558 }
15559 } else if (this.inline) {
15560 return this.decodeInline(this.annotation);
15561 } else if (this.annotation) {
15562 var map1 = this.annotation;
15563 if (file) map1 = join(dirname$1(file), map1);
15564 return this.loadFile(map1);
15565 }
15566 };
15567 _proto.startWith = function startWith(string, start) {
15568 if (!string) return false;
15569 return string.substr(0, start.length) === start;
15570 };
15571 _proto.withContent = function withContent() {
15572 return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
15573 };
15574 return PreviousMap2;
15575 }();
15576 var previousMap = PreviousMap$2;
15577 PreviousMap$2.default = PreviousMap$2;
15578 var SourceMapConsumer$1 = require$$2.SourceMapConsumer, SourceMapGenerator$1 = require$$2.SourceMapGenerator;
15579 var fileURLToPath = require$$2.fileURLToPath, pathToFileURL$1 = require$$2.pathToFileURL;
15580 var isAbsolute = require$$2.isAbsolute, resolve$1 = require$$2.resolve;
15581 var nanoid = nonSecure.nanoid;
15582 var terminalHighlight = require$$2;
15583 var CssSyntaxError$1 = cssSyntaxError;
15584 var PreviousMap$1 = previousMap;
15585 var fromOffsetCache = Symbol("fromOffsetCache");
15586 var sourceMapAvailable$1 = Boolean(SourceMapConsumer$1 && SourceMapGenerator$1);
15587 var pathAvailable$1 = Boolean(resolve$1 && isAbsolute);
15588 var Input$4 = /*#__PURE__*/ function() {
15589 function Input2(css, opts) {
15590 if (opts === void 0) opts = {};
15591 if (css === null || typeof css === "undefined" || (typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && !css.toString) {
15592 throw new Error("PostCSS received " + css + " instead of CSS string");
15593 }
15594 this.css = css.toString();
15595 if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
15596 this.hasBOM = true;
15597 this.css = this.css.slice(1);
15598 } else {
15599 this.hasBOM = false;
15600 }
15601 if (opts.from) {
15602 if (!pathAvailable$1 || /^\w+:\/\//.test(opts.from) || isAbsolute(opts.from)) {
15603 this.file = opts.from;
15604 } else {
15605 this.file = resolve$1(opts.from);
15606 }
15607 }
15608 if (pathAvailable$1 && sourceMapAvailable$1) {
15609 var map = new PreviousMap$1(this.css, opts);
15610 if (map.text) {
15611 this.map = map;
15612 var file = map.consumer().file;
15613 if (!this.file && file) this.file = this.mapResolve(file);
15614 }
15615 }
15616 if (!this.file) {
15617 this.id = "<input css " + nanoid(6) + ">";
15618 }
15619 if (this.map) this.map.file = this.from;
15620 }
15621 var _proto = Input2.prototype;
15622 _proto.error = function error(message, line, column, opts) {
15623 if (opts === void 0) opts = {};
15624 var result2, endLine, endColumn;
15625 if (line && (typeof line === "undefined" ? "undefined" : _type_of(line)) === "object") {
15626 var start = line;
15627 var end = column;
15628 if (typeof start.offset === "number") {
15629 var pos = this.fromOffset(start.offset);
15630 line = pos.line;
15631 column = pos.col;
15632 } else {
15633 line = start.line;
15634 column = start.column;
15635 }
15636 if (typeof end.offset === "number") {
15637 var pos1 = this.fromOffset(end.offset);
15638 endLine = pos1.line;
15639 endColumn = pos1.col;
15640 } else {
15641 endLine = end.line;
15642 endColumn = end.column;
15643 }
15644 } else if (!column) {
15645 var pos2 = this.fromOffset(line);
15646 line = pos2.line;
15647 column = pos2.col;
15648 }
15649 var origin = this.origin(line, column, endLine, endColumn);
15650 if (origin) {
15651 result2 = new CssSyntaxError$1(message, origin.endLine === void 0 ? origin.line : {
15652 column: origin.column,
15653 line: origin.line
15654 }, origin.endLine === void 0 ? origin.column : {
15655 column: origin.endColumn,
15656 line: origin.endLine
15657 }, origin.source, origin.file, opts.plugin);
15658 } else {
15659 result2 = new CssSyntaxError$1(message, endLine === void 0 ? line : {
15660 column: column,
15661 line: line
15662 }, endLine === void 0 ? column : {
15663 column: endColumn,
15664 line: endLine
15665 }, this.css, this.file, opts.plugin);
15666 }
15667 result2.input = {
15668 column: column,
15669 endColumn: endColumn,
15670 endLine: endLine,
15671 line: line,
15672 source: this.css
15673 };
15674 if (this.file) {
15675 if (pathToFileURL$1) {
15676 result2.input.url = pathToFileURL$1(this.file).toString();
15677 }
15678 result2.input.file = this.file;
15679 }
15680 return result2;
15681 };
15682 _proto.fromOffset = function fromOffset(offset) {
15683 var lastLine, lineToIndex;
15684 if (!this[fromOffsetCache]) {
15685 var lines = this.css.split("\n");
15686 lineToIndex = new Array(lines.length);
15687 var prevIndex = 0;
15688 for(var i2 = 0, l2 = lines.length; i2 < l2; i2++){
15689 lineToIndex[i2] = prevIndex;
15690 prevIndex += lines[i2].length + 1;
15691 }
15692 this[fromOffsetCache] = lineToIndex;
15693 } else {
15694 lineToIndex = this[fromOffsetCache];
15695 }
15696 lastLine = lineToIndex[lineToIndex.length - 1];
15697 var min = 0;
15698 if (offset >= lastLine) {
15699 min = lineToIndex.length - 1;
15700 } else {
15701 var max = lineToIndex.length - 2;
15702 var mid;
15703 while(min < max){
15704 mid = min + (max - min >> 1);
15705 if (offset < lineToIndex[mid]) {
15706 max = mid - 1;
15707 } else if (offset >= lineToIndex[mid + 1]) {
15708 min = mid + 1;
15709 } else {
15710 min = mid;
15711 break;
15712 }
15713 }
15714 }
15715 return {
15716 col: offset - lineToIndex[min] + 1,
15717 line: min + 1
15718 };
15719 };
15720 _proto.mapResolve = function mapResolve(file) {
15721 if (/^\w+:\/\//.test(file)) {
15722 return file;
15723 }
15724 return resolve$1(this.map.consumer().sourceRoot || this.map.root || ".", file);
15725 };
15726 _proto.origin = function origin(line, column, endLine, endColumn) {
15727 if (!this.map) return false;
15728 var consumer = this.map.consumer();
15729 var from = consumer.originalPositionFor({
15730 column: column,
15731 line: line
15732 });
15733 if (!from.source) return false;
15734 var to;
15735 if (typeof endLine === "number") {
15736 to = consumer.originalPositionFor({
15737 column: endColumn,
15738 line: endLine
15739 });
15740 }
15741 var fromUrl;
15742 if (isAbsolute(from.source)) {
15743 fromUrl = pathToFileURL$1(from.source);
15744 } else {
15745 fromUrl = new URL(from.source, this.map.consumer().sourceRoot || pathToFileURL$1(this.map.mapFile));
15746 }
15747 var result2 = {
15748 column: from.column,
15749 endColumn: to && to.column,
15750 endLine: to && to.line,
15751 line: from.line,
15752 url: fromUrl.toString()
15753 };
15754 if (fromUrl.protocol === "file:") {
15755 if (fileURLToPath) {
15756 result2.file = fileURLToPath(fromUrl);
15757 } else {
15758 throw new Error("file: protocol is not available in this PostCSS build");
15759 }
15760 }
15761 var source = consumer.sourceContentFor(from.source);
15762 if (source) result2.source = source;
15763 return result2;
15764 };
15765 _proto.toJSON = function toJSON() {
15766 var json = {};
15767 for(var _i = 0, _iter = [
15768 "hasBOM",
15769 "css",
15770 "file",
15771 "id"
15772 ]; _i < _iter.length; _i++){
15773 var name = _iter[_i];
15774 if (this[name] != null) {
15775 json[name] = this[name];
15776 }
15777 }
15778 if (this.map) {
15779 json.map = _extends({}, this.map);
15780 if (json.map.consumerCache) {
15781 json.map.consumerCache = void 0;
15782 }
15783 }
15784 return json;
15785 };
15786 _create_class(Input2, [
15787 {
15788 key: "from",
15789 get: function get() {
15790 return this.file || this.id;
15791 }
15792 }
15793 ]);
15794 return Input2;
15795 }();
15796 var input = Input$4;
15797 Input$4.default = Input$4;
15798 if (terminalHighlight && terminalHighlight.registerInput) {
15799 terminalHighlight.registerInput(Input$4);
15800 }
15801 var SourceMapConsumer = require$$2.SourceMapConsumer, SourceMapGenerator = require$$2.SourceMapGenerator;
15802 var dirname = require$$2.dirname, relative = require$$2.relative, resolve$3 = require$$2.resolve, sep = require$$2.sep;
15803 var pathToFileURL = require$$2.pathToFileURL;
15804 var Input$3 = input;
15805 var sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
15806 var pathAvailable = Boolean(dirname && resolve$3 && relative && sep);
15807 var MapGenerator$2 = /*#__PURE__*/ function() {
15808 function MapGenerator2(stringify2, root2, opts, cssString) {
15809 this.stringify = stringify2;
15810 this.mapOpts = opts.map || {};
15811 this.root = root2;
15812 this.opts = opts;
15813 this.css = cssString;
15814 this.originalCSS = cssString;
15815 this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
15816 this.memoizedFileURLs = /* @__PURE__ */ new Map();
15817 this.memoizedPaths = /* @__PURE__ */ new Map();
15818 this.memoizedURLs = /* @__PURE__ */ new Map();
15819 }
15820 var _proto = MapGenerator2.prototype;
15821 _proto.addAnnotation = function addAnnotation() {
15822 var content;
15823 if (this.isInline()) {
15824 content = "data:application/json;base64," + this.toBase64(this.map.toString());
15825 } else if (typeof this.mapOpts.annotation === "string") {
15826 content = this.mapOpts.annotation;
15827 } else if (typeof this.mapOpts.annotation === "function") {
15828 content = this.mapOpts.annotation(this.opts.to, this.root);
15829 } else {
15830 content = this.outputFile() + ".map";
15831 }
15832 var eol = "\n";
15833 if (this.css.includes("\r\n")) eol = "\r\n";
15834 this.css += eol + "/*# sourceMappingURL=" + content + " */";
15835 };
15836 _proto.applyPrevMaps = function applyPrevMaps() {
15837 for(var _iterator = _create_for_of_iterator_helper_loose(this.previous()), _step; !(_step = _iterator()).done;){
15838 var prev = _step.value;
15839 var from = this.toUrl(this.path(prev.file));
15840 var root2 = prev.root || dirname(prev.file);
15841 var map = void 0;
15842 if (this.mapOpts.sourcesContent === false) {
15843 map = new SourceMapConsumer(prev.text);
15844 if (map.sourcesContent) {
15845 map.sourcesContent = null;
15846 }
15847 } else {
15848 map = prev.consumer();
15849 }
15850 this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
15851 }
15852 };
15853 _proto.clearAnnotation = function clearAnnotation() {
15854 if (this.mapOpts.annotation === false) return;
15855 if (this.root) {
15856 var node2;
15857 for(var i2 = this.root.nodes.length - 1; i2 >= 0; i2--){
15858 node2 = this.root.nodes[i2];
15859 if (node2.type !== "comment") continue;
15860 if (node2.text.indexOf("# sourceMappingURL=") === 0) {
15861 this.root.removeChild(i2);
15862 }
15863 }
15864 } else if (this.css) {
15865 this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, "");
15866 }
15867 };
15868 _proto.generate = function generate() {
15869 this.clearAnnotation();
15870 if (pathAvailable && sourceMapAvailable && this.isMap()) {
15871 return this.generateMap();
15872 } else {
15873 var result2 = "";
15874 this.stringify(this.root, function(i2) {
15875 result2 += i2;
15876 });
15877 return [
15878 result2
15879 ];
15880 }
15881 };
15882 _proto.generateMap = function generateMap() {
15883 if (this.root) {
15884 this.generateString();
15885 } else if (this.previous().length === 1) {
15886 var prev = this.previous()[0].consumer();
15887 prev.file = this.outputFile();
15888 this.map = SourceMapGenerator.fromSourceMap(prev, {
15889 ignoreInvalidMapping: true
15890 });
15891 } else {
15892 this.map = new SourceMapGenerator({
15893 file: this.outputFile(),
15894 ignoreInvalidMapping: true
15895 });
15896 this.map.addMapping({
15897 generated: {
15898 column: 0,
15899 line: 1
15900 },
15901 original: {
15902 column: 0,
15903 line: 1
15904 },
15905 source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
15906 });
15907 }
15908 if (this.isSourcesContent()) this.setSourcesContent();
15909 if (this.root && this.previous().length > 0) this.applyPrevMaps();
15910 if (this.isAnnotation()) this.addAnnotation();
15911 if (this.isInline()) {
15912 return [
15913 this.css
15914 ];
15915 } else {
15916 return [
15917 this.css,
15918 this.map
15919 ];
15920 }
15921 };
15922 _proto.generateString = function generateString() {
15923 var _this = this;
15924 this.css = "";
15925 this.map = new SourceMapGenerator({
15926 file: this.outputFile(),
15927 ignoreInvalidMapping: true
15928 });
15929 var line = 1;
15930 var column = 1;
15931 var noSource = "<no source>";
15932 var mapping = {
15933 generated: {
15934 column: 0,
15935 line: 0
15936 },
15937 original: {
15938 column: 0,
15939 line: 0
15940 },
15941 source: ""
15942 };
15943 var lines, last;
15944 this.stringify(this.root, function(str, node2, type) {
15945 _this.css += str;
15946 if (node2 && type !== "end") {
15947 mapping.generated.line = line;
15948 mapping.generated.column = column - 1;
15949 if (node2.source && node2.source.start) {
15950 mapping.source = _this.sourcePath(node2);
15951 mapping.original.line = node2.source.start.line;
15952 mapping.original.column = node2.source.start.column - 1;
15953 _this.map.addMapping(mapping);
15954 } else {
15955 mapping.source = noSource;
15956 mapping.original.line = 1;
15957 mapping.original.column = 0;
15958 _this.map.addMapping(mapping);
15959 }
15960 }
15961 lines = str.match(/\n/g);
15962 if (lines) {
15963 line += lines.length;
15964 last = str.lastIndexOf("\n");
15965 column = str.length - last;
15966 } else {
15967 column += str.length;
15968 }
15969 if (node2 && type !== "start") {
15970 var p = node2.parent || {
15971 raws: {}
15972 };
15973 var childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
15974 if (!childless || node2 !== p.last || p.raws.semicolon) {
15975 if (node2.source && node2.source.end) {
15976 mapping.source = _this.sourcePath(node2);
15977 mapping.original.line = node2.source.end.line;
15978 mapping.original.column = node2.source.end.column - 1;
15979 mapping.generated.line = line;
15980 mapping.generated.column = column - 2;
15981 _this.map.addMapping(mapping);
15982 } else {
15983 mapping.source = noSource;
15984 mapping.original.line = 1;
15985 mapping.original.column = 0;
15986 mapping.generated.line = line;
15987 mapping.generated.column = column - 1;
15988 _this.map.addMapping(mapping);
15989 }
15990 }
15991 }
15992 });
15993 };
15994 _proto.isAnnotation = function isAnnotation() {
15995 if (this.isInline()) {
15996 return true;
15997 }
15998 if (typeof this.mapOpts.annotation !== "undefined") {
15999 return this.mapOpts.annotation;
16000 }
16001 if (this.previous().length) {
16002 return this.previous().some(function(i2) {
16003 return i2.annotation;
16004 });
16005 }
16006 return true;
16007 };
16008 _proto.isInline = function isInline() {
16009 if (typeof this.mapOpts.inline !== "undefined") {
16010 return this.mapOpts.inline;
16011 }
16012 var annotation = this.mapOpts.annotation;
16013 if (typeof annotation !== "undefined" && annotation !== true) {
16014 return false;
16015 }
16016 if (this.previous().length) {
16017 return this.previous().some(function(i2) {
16018 return i2.inline;
16019 });
16020 }
16021 return true;
16022 };
16023 _proto.isMap = function isMap() {
16024 if (typeof this.opts.map !== "undefined") {
16025 return !!this.opts.map;
16026 }
16027 return this.previous().length > 0;
16028 };
16029 _proto.isSourcesContent = function isSourcesContent() {
16030 if (typeof this.mapOpts.sourcesContent !== "undefined") {
16031 return this.mapOpts.sourcesContent;
16032 }
16033 if (this.previous().length) {
16034 return this.previous().some(function(i2) {
16035 return i2.withContent();
16036 });
16037 }
16038 return true;
16039 };
16040 _proto.outputFile = function outputFile() {
16041 if (this.opts.to) {
16042 return this.path(this.opts.to);
16043 } else if (this.opts.from) {
16044 return this.path(this.opts.from);
16045 } else {
16046 return "to.css";
16047 }
16048 };
16049 _proto.path = function path(file) {
16050 if (this.mapOpts.absolute) return file;
16051 if (file.charCodeAt(0) === 60) return file;
16052 if (/^\w+:\/\//.test(file)) return file;
16053 var cached = this.memoizedPaths.get(file);
16054 if (cached) return cached;
16055 var from = this.opts.to ? dirname(this.opts.to) : ".";
16056 if (typeof this.mapOpts.annotation === "string") {
16057 from = dirname(resolve$3(from, this.mapOpts.annotation));
16058 }
16059 var path = relative(from, file);
16060 this.memoizedPaths.set(file, path);
16061 return path;
16062 };
16063 _proto.previous = function previous() {
16064 var _this = this;
16065 if (!this.previousMaps) {
16066 this.previousMaps = [];
16067 if (this.root) {
16068 this.root.walk(function(node2) {
16069 if (node2.source && node2.source.input.map) {
16070 var map = node2.source.input.map;
16071 if (!_this.previousMaps.includes(map)) {
16072 _this.previousMaps.push(map);
16073 }
16074 }
16075 });
16076 } else {
16077 var input2 = new Input$3(this.originalCSS, this.opts);
16078 if (input2.map) this.previousMaps.push(input2.map);
16079 }
16080 }
16081 return this.previousMaps;
16082 };
16083 _proto.setSourcesContent = function setSourcesContent() {
16084 var _this = this;
16085 var already = {};
16086 if (this.root) {
16087 this.root.walk(function(node2) {
16088 if (node2.source) {
16089 var from = node2.source.input.from;
16090 if (from && !already[from]) {
16091 already[from] = true;
16092 var fromUrl = _this.usesFileUrls ? _this.toFileUrl(from) : _this.toUrl(_this.path(from));
16093 _this.map.setSourceContent(fromUrl, node2.source.input.css);
16094 }
16095 }
16096 });
16097 } else if (this.css) {
16098 var from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
16099 this.map.setSourceContent(from, this.css);
16100 }
16101 };
16102 _proto.sourcePath = function sourcePath(node2) {
16103 if (this.mapOpts.from) {
16104 return this.toUrl(this.mapOpts.from);
16105 } else if (this.usesFileUrls) {
16106 return this.toFileUrl(node2.source.input.from);
16107 } else {
16108 return this.toUrl(this.path(node2.source.input.from));
16109 }
16110 };
16111 _proto.toBase64 = function toBase64(str) {
16112 if (Buffer) {
16113 return Buffer.from(str).toString("base64");
16114 } else {
16115 return window.btoa(unescape(encodeURIComponent(str)));
16116 }
16117 };
16118 _proto.toFileUrl = function toFileUrl(path) {
16119 var cached = this.memoizedFileURLs.get(path);
16120 if (cached) return cached;
16121 if (pathToFileURL) {
16122 var fileURL = pathToFileURL(path).toString();
16123 this.memoizedFileURLs.set(path, fileURL);
16124 return fileURL;
16125 } else {
16126 throw new Error("`map.absolute` option is not available in this PostCSS build");
16127 }
16128 };
16129 _proto.toUrl = function toUrl(path) {
16130 var cached = this.memoizedURLs.get(path);
16131 if (cached) return cached;
16132 if (sep === "\\") {
16133 path = path.replace(/\\/g, "/");
16134 }
16135 var url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
16136 this.memoizedURLs.set(path, url);
16137 return url;
16138 };
16139 return MapGenerator2;
16140 }();
16141 var mapGenerator = MapGenerator$2;
16142 var Node$2 = node;
16143 var Comment$4 = /*#__PURE__*/ function(Node$2) {
16144 _inherits(Comment2, Node$2);
16145 function Comment2(defaults) {
16146 var _this;
16147 _this = Node$2.call(this, defaults) || this;
16148 _this.type = "comment";
16149 return _this;
16150 }
16151 return Comment2;
16152 }(Node$2);
16153 var comment = Comment$4;
16154 Comment$4.default = Comment$4;
16155 var isClean$1 = symbols.isClean, my$1 = symbols.my;
16156 var Declaration$3 = declaration;
16157 var Comment$3 = comment;
16158 var Node$1 = node;
16159 var parse$4, Rule$4, AtRule$4, Root$6;
16160 function cleanSource(nodes) {
16161 return nodes.map(function(i2) {
16162 if (i2.nodes) i2.nodes = cleanSource(i2.nodes);
16163 delete i2.source;
16164 return i2;
16165 });
16166 }
16167 function markDirtyUp(node2) {
16168 node2[isClean$1] = false;
16169 if (node2.proxyOf.nodes) {
16170 for(var _iterator = _create_for_of_iterator_helper_loose(node2.proxyOf.nodes), _step; !(_step = _iterator()).done;){
16171 var i2 = _step.value;
16172 markDirtyUp(i2);
16173 }
16174 }
16175 }
16176 var Container$7 = /*#__PURE__*/ function(Node$1) {
16177 _inherits(Container2, Node$1);
16178 function Container2() {
16179 return Node$1.apply(this, arguments) || this;
16180 }
16181 var _proto = Container2.prototype;
16182 _proto.append = function append() {
16183 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16184 children[_key] = arguments[_key];
16185 }
16186 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
16187 var child = _step.value;
16188 var nodes = this.normalize(child, this.last);
16189 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
16190 var node2 = _step1.value;
16191 this.proxyOf.nodes.push(node2);
16192 }
16193 }
16194 this.markDirty();
16195 return this;
16196 };
16197 _proto.cleanRaws = function cleanRaws(keepBetween) {
16198 Node$1.prototype.cleanRaws.call(this, keepBetween);
16199 if (this.nodes) {
16200 for(var _iterator = _create_for_of_iterator_helper_loose(this.nodes), _step; !(_step = _iterator()).done;){
16201 var node2 = _step.value;
16202 node2.cleanRaws(keepBetween);
16203 }
16204 }
16205 };
16206 _proto.each = function each(callback) {
16207 if (!this.proxyOf.nodes) return void 0;
16208 var iterator = this.getIterator();
16209 var index2, result2;
16210 while(this.indexes[iterator] < this.proxyOf.nodes.length){
16211 index2 = this.indexes[iterator];
16212 result2 = callback(this.proxyOf.nodes[index2], index2);
16213 if (result2 === false) break;
16214 this.indexes[iterator] += 1;
16215 }
16216 delete this.indexes[iterator];
16217 return result2;
16218 };
16219 _proto.every = function every(condition) {
16220 return this.nodes.every(condition);
16221 };
16222 _proto.getIterator = function getIterator() {
16223 if (!this.lastEach) this.lastEach = 0;
16224 if (!this.indexes) this.indexes = {};
16225 this.lastEach += 1;
16226 var iterator = this.lastEach;
16227 this.indexes[iterator] = 0;
16228 return iterator;
16229 };
16230 _proto.getProxyProcessor = function getProxyProcessor() {
16231 return {
16232 get: function get(node2, prop) {
16233 if (prop === "proxyOf") {
16234 return node2;
16235 } else if (!node2[prop]) {
16236 return node2[prop];
16237 } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
16238 return function() {
16239 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
16240 args[_key] = arguments[_key];
16241 }
16242 var _node2;
16243 return (_node2 = node2)[prop].apply(_node2, [].concat(args.map(function(i2) {
16244 if (typeof i2 === "function") {
16245 return function(child, index2) {
16246 return i2(child.toProxy(), index2);
16247 };
16248 } else {
16249 return i2;
16250 }
16251 })));
16252 };
16253 } else if (prop === "every" || prop === "some") {
16254 return function(cb) {
16255 return node2[prop](function(child) {
16256 for(var _len = arguments.length, other = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
16257 other[_key - 1] = arguments[_key];
16258 }
16259 return cb.apply(void 0, [].concat([
16260 child.toProxy()
16261 ], other));
16262 });
16263 };
16264 } else if (prop === "root") {
16265 return function() {
16266 return node2.root().toProxy();
16267 };
16268 } else if (prop === "nodes") {
16269 return node2.nodes.map(function(i2) {
16270 return i2.toProxy();
16271 });
16272 } else if (prop === "first" || prop === "last") {
16273 return node2[prop].toProxy();
16274 } else {
16275 return node2[prop];
16276 }
16277 },
16278 set: function set(node2, prop, value) {
16279 if (node2[prop] === value) return true;
16280 node2[prop] = value;
16281 if (prop === "name" || prop === "params" || prop === "selector") {
16282 node2.markDirty();
16283 }
16284 return true;
16285 }
16286 };
16287 };
16288 _proto.index = function index(child) {
16289 if (typeof child === "number") return child;
16290 if (child.proxyOf) child = child.proxyOf;
16291 return this.proxyOf.nodes.indexOf(child);
16292 };
16293 _proto.insertAfter = function insertAfter(exist, add) {
16294 var existIndex = this.index(exist);
16295 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
16296 existIndex = this.index(exist);
16297 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
16298 var node2 = _step.value;
16299 this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
16300 }
16301 var index2;
16302 for(var id in this.indexes){
16303 index2 = this.indexes[id];
16304 if (existIndex < index2) {
16305 this.indexes[id] = index2 + nodes.length;
16306 }
16307 }
16308 this.markDirty();
16309 return this;
16310 };
16311 _proto.insertBefore = function insertBefore(exist, add) {
16312 var existIndex = this.index(exist);
16313 var type = existIndex === 0 ? "prepend" : false;
16314 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
16315 existIndex = this.index(exist);
16316 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
16317 var node2 = _step.value;
16318 this.proxyOf.nodes.splice(existIndex, 0, node2);
16319 }
16320 var index2;
16321 for(var id in this.indexes){
16322 index2 = this.indexes[id];
16323 if (existIndex <= index2) {
16324 this.indexes[id] = index2 + nodes.length;
16325 }
16326 }
16327 this.markDirty();
16328 return this;
16329 };
16330 _proto.normalize = function normalize(nodes, sample) {
16331 var _this = this;
16332 if (typeof nodes === "string") {
16333 nodes = cleanSource(parse$4(nodes).nodes);
16334 } else if (typeof nodes === "undefined") {
16335 nodes = [];
16336 } else if (Array.isArray(nodes)) {
16337 nodes = nodes.slice(0);
16338 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
16339 var i2 = _step.value;
16340 if (i2.parent) i2.parent.removeChild(i2, "ignore");
16341 }
16342 } else if (nodes.type === "root" && this.type !== "document") {
16343 nodes = nodes.nodes.slice(0);
16344 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
16345 var i21 = _step1.value;
16346 if (i21.parent) i21.parent.removeChild(i21, "ignore");
16347 }
16348 } else if (nodes.type) {
16349 nodes = [
16350 nodes
16351 ];
16352 } else if (nodes.prop) {
16353 if (typeof nodes.value === "undefined") {
16354 throw new Error("Value field is missed in node creation");
16355 } else if (typeof nodes.value !== "string") {
16356 nodes.value = String(nodes.value);
16357 }
16358 nodes = [
16359 new Declaration$3(nodes)
16360 ];
16361 } else if (nodes.selector) {
16362 nodes = [
16363 new Rule$4(nodes)
16364 ];
16365 } else if (nodes.name) {
16366 nodes = [
16367 new AtRule$4(nodes)
16368 ];
16369 } else if (nodes.text) {
16370 nodes = [
16371 new Comment$3(nodes)
16372 ];
16373 } else {
16374 throw new Error("Unknown node type in node creation");
16375 }
16376 var processed = nodes.map(function(i2) {
16377 if (!i2[my$1]) Container2.rebuild(i2);
16378 i2 = i2.proxyOf;
16379 if (i2.parent) i2.parent.removeChild(i2);
16380 if (i2[isClean$1]) markDirtyUp(i2);
16381 if (typeof i2.raws.before === "undefined") {
16382 if (sample && typeof sample.raws.before !== "undefined") {
16383 i2.raws.before = sample.raws.before.replace(/\S/g, "");
16384 }
16385 }
16386 i2.parent = _this.proxyOf;
16387 return i2;
16388 });
16389 return processed;
16390 };
16391 _proto.prepend = function prepend() {
16392 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16393 children[_key] = arguments[_key];
16394 }
16395 children = children.reverse();
16396 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
16397 var child = _step.value;
16398 var nodes = this.normalize(child, this.first, "prepend").reverse();
16399 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
16400 var node2 = _step1.value;
16401 this.proxyOf.nodes.unshift(node2);
16402 }
16403 for(var id in this.indexes){
16404 this.indexes[id] = this.indexes[id] + nodes.length;
16405 }
16406 }
16407 this.markDirty();
16408 return this;
16409 };
16410 _proto.push = function push(child) {
16411 child.parent = this;
16412 this.proxyOf.nodes.push(child);
16413 return this;
16414 };
16415 _proto.removeAll = function removeAll() {
16416 for(var _iterator = _create_for_of_iterator_helper_loose(this.proxyOf.nodes), _step; !(_step = _iterator()).done;){
16417 var node2 = _step.value;
16418 node2.parent = void 0;
16419 }
16420 this.proxyOf.nodes = [];
16421 this.markDirty();
16422 return this;
16423 };
16424 _proto.removeChild = function removeChild(child) {
16425 child = this.index(child);
16426 this.proxyOf.nodes[child].parent = void 0;
16427 this.proxyOf.nodes.splice(child, 1);
16428 var index2;
16429 for(var id in this.indexes){
16430 index2 = this.indexes[id];
16431 if (index2 >= child) {
16432 this.indexes[id] = index2 - 1;
16433 }
16434 }
16435 this.markDirty();
16436 return this;
16437 };
16438 _proto.replaceValues = function replaceValues(pattern, opts, callback) {
16439 if (!callback) {
16440 callback = opts;
16441 opts = {};
16442 }
16443 this.walkDecls(function(decl) {
16444 if (opts.props && !opts.props.includes(decl.prop)) return;
16445 if (opts.fast && !decl.value.includes(opts.fast)) return;
16446 decl.value = decl.value.replace(pattern, callback);
16447 });
16448 this.markDirty();
16449 return this;
16450 };
16451 _proto.some = function some(condition) {
16452 return this.nodes.some(condition);
16453 };
16454 _proto.walk = function walk(callback) {
16455 return this.each(function(child, i2) {
16456 var result2;
16457 try {
16458 result2 = callback(child, i2);
16459 } catch (e2) {
16460 throw child.addToError(e2);
16461 }
16462 if (result2 !== false && child.walk) {
16463 result2 = child.walk(callback);
16464 }
16465 return result2;
16466 });
16467 };
16468 _proto.walkAtRules = function walkAtRules(name, callback) {
16469 if (!callback) {
16470 callback = name;
16471 return this.walk(function(child, i2) {
16472 if (child.type === "atrule") {
16473 return callback(child, i2);
16474 }
16475 });
16476 }
16477 if (_instanceof(name, RegExp)) {
16478 return this.walk(function(child, i2) {
16479 if (child.type === "atrule" && name.test(child.name)) {
16480 return callback(child, i2);
16481 }
16482 });
16483 }
16484 return this.walk(function(child, i2) {
16485 if (child.type === "atrule" && child.name === name) {
16486 return callback(child, i2);
16487 }
16488 });
16489 };
16490 _proto.walkComments = function walkComments(callback) {
16491 return this.walk(function(child, i2) {
16492 if (child.type === "comment") {
16493 return callback(child, i2);
16494 }
16495 });
16496 };
16497 _proto.walkDecls = function walkDecls(prop, callback) {
16498 if (!callback) {
16499 callback = prop;
16500 return this.walk(function(child, i2) {
16501 if (child.type === "decl") {
16502 return callback(child, i2);
16503 }
16504 });
16505 }
16506 if (_instanceof(prop, RegExp)) {
16507 return this.walk(function(child, i2) {
16508 if (child.type === "decl" && prop.test(child.prop)) {
16509 return callback(child, i2);
16510 }
16511 });
16512 }
16513 return this.walk(function(child, i2) {
16514 if (child.type === "decl" && child.prop === prop) {
16515 return callback(child, i2);
16516 }
16517 });
16518 };
16519 _proto.walkRules = function walkRules(selector, callback) {
16520 if (!callback) {
16521 callback = selector;
16522 return this.walk(function(child, i2) {
16523 if (child.type === "rule") {
16524 return callback(child, i2);
16525 }
16526 });
16527 }
16528 if (_instanceof(selector, RegExp)) {
16529 return this.walk(function(child, i2) {
16530 if (child.type === "rule" && selector.test(child.selector)) {
16531 return callback(child, i2);
16532 }
16533 });
16534 }
16535 return this.walk(function(child, i2) {
16536 if (child.type === "rule" && child.selector === selector) {
16537 return callback(child, i2);
16538 }
16539 });
16540 };
16541 _create_class(Container2, [
16542 {
16543 key: "first",
16544 get: function get() {
16545 if (!this.proxyOf.nodes) return void 0;
16546 return this.proxyOf.nodes[0];
16547 }
16548 },
16549 {
16550 key: "last",
16551 get: function get() {
16552 if (!this.proxyOf.nodes) return void 0;
16553 return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
16554 }
16555 }
16556 ]);
16557 return Container2;
16558 }(Node$1);
16559 Container$7.registerParse = function(dependant) {
16560 parse$4 = dependant;
16561 };
16562 Container$7.registerRule = function(dependant) {
16563 Rule$4 = dependant;
16564 };
16565 Container$7.registerAtRule = function(dependant) {
16566 AtRule$4 = dependant;
16567 };
16568 Container$7.registerRoot = function(dependant) {
16569 Root$6 = dependant;
16570 };
16571 var container = Container$7;
16572 Container$7.default = Container$7;
16573 Container$7.rebuild = function(node2) {
16574 if (node2.type === "atrule") {
16575 Object.setPrototypeOf(node2, AtRule$4.prototype);
16576 } else if (node2.type === "rule") {
16577 Object.setPrototypeOf(node2, Rule$4.prototype);
16578 } else if (node2.type === "decl") {
16579 Object.setPrototypeOf(node2, Declaration$3.prototype);
16580 } else if (node2.type === "comment") {
16581 Object.setPrototypeOf(node2, Comment$3.prototype);
16582 } else if (node2.type === "root") {
16583 Object.setPrototypeOf(node2, Root$6.prototype);
16584 }
16585 node2[my$1] = true;
16586 if (node2.nodes) {
16587 node2.nodes.forEach(function(child) {
16588 Container$7.rebuild(child);
16589 });
16590 }
16591 };
16592 var Container$6 = container;
16593 var LazyResult$4, Processor$3;
16594 var Document$3 = /*#__PURE__*/ function(Container$6) {
16595 _inherits(Document23, Container$6);
16596 function Document23(defaults) {
16597 var _this;
16598 _this = Container$6.call(this, _extends({
16599 type: "document"
16600 }, defaults)) || this;
16601 if (!_this.nodes) {
16602 _this.nodes = [];
16603 }
16604 return _this;
16605 }
16606 var _proto = Document23.prototype;
16607 _proto.toResult = function toResult(opts) {
16608 if (opts === void 0) opts = {};
16609 var lazy = new LazyResult$4(new Processor$3(), this, opts);
16610 return lazy.stringify();
16611 };
16612 return Document23;
16613 }(Container$6);
16614 Document$3.registerLazyResult = function(dependant) {
16615 LazyResult$4 = dependant;
16616 };
16617 Document$3.registerProcessor = function(dependant) {
16618 Processor$3 = dependant;
16619 };
16620 var document$1$2 = Document$3;
16621 Document$3.default = Document$3;
16622 var printed = {};
16623 var warnOnce$2 = function warnOnce2(message) {
16624 if (printed[message]) return;
16625 printed[message] = true;
16626 if (typeof console !== "undefined" && console.warn) {
16627 console.warn(message);
16628 }
16629 };
16630 var Warning$2 = /*#__PURE__*/ function() {
16631 function Warning2(text, opts) {
16632 if (opts === void 0) opts = {};
16633 this.type = "warning";
16634 this.text = text;
16635 if (opts.node && opts.node.source) {
16636 var range = opts.node.rangeBy(opts);
16637 this.line = range.start.line;
16638 this.column = range.start.column;
16639 this.endLine = range.end.line;
16640 this.endColumn = range.end.column;
16641 }
16642 for(var opt in opts)this[opt] = opts[opt];
16643 }
16644 var _proto = Warning2.prototype;
16645 _proto.toString = function toString() {
16646 if (this.node) {
16647 return this.node.error(this.text, {
16648 index: this.index,
16649 plugin: this.plugin,
16650 word: this.word
16651 }).message;
16652 }
16653 if (this.plugin) {
16654 return this.plugin + ": " + this.text;
16655 }
16656 return this.text;
16657 };
16658 return Warning2;
16659 }();
16660 var warning = Warning$2;
16661 Warning$2.default = Warning$2;
16662 var Warning$1 = warning;
16663 var Result$3 = /*#__PURE__*/ function() {
16664 function Result2(processor2, root2, opts) {
16665 this.processor = processor2;
16666 this.messages = [];
16667 this.root = root2;
16668 this.opts = opts;
16669 this.css = void 0;
16670 this.map = void 0;
16671 }
16672 var _proto = Result2.prototype;
16673 _proto.toString = function toString() {
16674 return this.css;
16675 };
16676 _proto.warn = function warn(text, opts) {
16677 if (opts === void 0) opts = {};
16678 if (!opts.plugin) {
16679 if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
16680 opts.plugin = this.lastPlugin.postcssPlugin;
16681 }
16682 }
16683 var warning2 = new Warning$1(text, opts);
16684 this.messages.push(warning2);
16685 return warning2;
16686 };
16687 _proto.warnings = function warnings() {
16688 return this.messages.filter(function(i2) {
16689 return i2.type === "warning";
16690 });
16691 };
16692 _create_class(Result2, [
16693 {
16694 key: "content",
16695 get: function get() {
16696 return this.css;
16697 }
16698 }
16699 ]);
16700 return Result2;
16701 }();
16702 var result = Result$3;
16703 Result$3.default = Result$3;
16704 var SINGLE_QUOTE = "'".charCodeAt(0);
16705 var DOUBLE_QUOTE = '"'.charCodeAt(0);
16706 var BACKSLASH = "\\".charCodeAt(0);
16707 var SLASH = "/".charCodeAt(0);
16708 var NEWLINE = "\n".charCodeAt(0);
16709 var SPACE = " ".charCodeAt(0);
16710 var FEED = "\f".charCodeAt(0);
16711 var TAB = " ".charCodeAt(0);
16712 var CR = "\r".charCodeAt(0);
16713 var OPEN_SQUARE = "[".charCodeAt(0);
16714 var CLOSE_SQUARE = "]".charCodeAt(0);
16715 var OPEN_PARENTHESES = "(".charCodeAt(0);
16716 var CLOSE_PARENTHESES = ")".charCodeAt(0);
16717 var OPEN_CURLY = "{".charCodeAt(0);
16718 var CLOSE_CURLY = "}".charCodeAt(0);
16719 var SEMICOLON = ";".charCodeAt(0);
16720 var ASTERISK = "*".charCodeAt(0);
16721 var COLON = ":".charCodeAt(0);
16722 var AT = "@".charCodeAt(0);
16723 var RE_AT_END = /[\t\n\f\r "#'()/;[\\\]{}]/g;
16724 var RE_WORD_END = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
16725 var RE_BAD_BRACKET = /.[\r\n"'(/\\]/;
16726 var RE_HEX_ESCAPE = /[\da-f]/i;
16727 var tokenize = function tokenizer2(input2, options) {
16728 if (options === void 0) options = {};
16729 var css = input2.css.valueOf();
16730 var ignore = options.ignoreErrors;
16731 var code, next, quote, content, escape;
16732 var escaped, escapePos, prev, n2, currentToken;
16733 var length = css.length;
16734 var pos = 0;
16735 var buffer = [];
16736 var returned = [];
16737 function position() {
16738 return pos;
16739 }
16740 function unclosed(what) {
16741 throw input2.error("Unclosed " + what, pos);
16742 }
16743 function endOfFile() {
16744 return returned.length === 0 && pos >= length;
16745 }
16746 function nextToken(opts) {
16747 if (returned.length) return returned.pop();
16748 if (pos >= length) return;
16749 var ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
16750 code = css.charCodeAt(pos);
16751 switch(code){
16752 case NEWLINE:
16753 case SPACE:
16754 case TAB:
16755 case CR:
16756 case FEED:
16757 {
16758 next = pos;
16759 do {
16760 next += 1;
16761 code = css.charCodeAt(next);
16762 }while (code === SPACE || code === NEWLINE || code === TAB || code === CR || code === FEED);
16763 currentToken = [
16764 "space",
16765 css.slice(pos, next)
16766 ];
16767 pos = next - 1;
16768 break;
16769 }
16770 case OPEN_SQUARE:
16771 case CLOSE_SQUARE:
16772 case OPEN_CURLY:
16773 case CLOSE_CURLY:
16774 case COLON:
16775 case SEMICOLON:
16776 case CLOSE_PARENTHESES:
16777 {
16778 var controlChar = String.fromCharCode(code);
16779 currentToken = [
16780 controlChar,
16781 controlChar,
16782 pos
16783 ];
16784 break;
16785 }
16786 case OPEN_PARENTHESES:
16787 {
16788 prev = buffer.length ? buffer.pop()[1] : "";
16789 n2 = css.charCodeAt(pos + 1);
16790 if (prev === "url" && n2 !== SINGLE_QUOTE && n2 !== DOUBLE_QUOTE && n2 !== SPACE && n2 !== NEWLINE && n2 !== TAB && n2 !== FEED && n2 !== CR) {
16791 next = pos;
16792 do {
16793 escaped = false;
16794 next = css.indexOf(")", next + 1);
16795 if (next === -1) {
16796 if (ignore || ignoreUnclosed) {
16797 next = pos;
16798 break;
16799 } else {
16800 unclosed("bracket");
16801 }
16802 }
16803 escapePos = next;
16804 while(css.charCodeAt(escapePos - 1) === BACKSLASH){
16805 escapePos -= 1;
16806 escaped = !escaped;
16807 }
16808 }while (escaped);
16809 currentToken = [
16810 "brackets",
16811 css.slice(pos, next + 1),
16812 pos,
16813 next
16814 ];
16815 pos = next;
16816 } else {
16817 next = css.indexOf(")", pos + 1);
16818 content = css.slice(pos, next + 1);
16819 if (next === -1 || RE_BAD_BRACKET.test(content)) {
16820 currentToken = [
16821 "(",
16822 "(",
16823 pos
16824 ];
16825 } else {
16826 currentToken = [
16827 "brackets",
16828 content,
16829 pos,
16830 next
16831 ];
16832 pos = next;
16833 }
16834 }
16835 break;
16836 }
16837 case SINGLE_QUOTE:
16838 case DOUBLE_QUOTE:
16839 {
16840 quote = code === SINGLE_QUOTE ? "'" : '"';
16841 next = pos;
16842 do {
16843 escaped = false;
16844 next = css.indexOf(quote, next + 1);
16845 if (next === -1) {
16846 if (ignore || ignoreUnclosed) {
16847 next = pos + 1;
16848 break;
16849 } else {
16850 unclosed("string");
16851 }
16852 }
16853 escapePos = next;
16854 while(css.charCodeAt(escapePos - 1) === BACKSLASH){
16855 escapePos -= 1;
16856 escaped = !escaped;
16857 }
16858 }while (escaped);
16859 currentToken = [
16860 "string",
16861 css.slice(pos, next + 1),
16862 pos,
16863 next
16864 ];
16865 pos = next;
16866 break;
16867 }
16868 case AT:
16869 {
16870 RE_AT_END.lastIndex = pos + 1;
16871 RE_AT_END.test(css);
16872 if (RE_AT_END.lastIndex === 0) {
16873 next = css.length - 1;
16874 } else {
16875 next = RE_AT_END.lastIndex - 2;
16876 }
16877 currentToken = [
16878 "at-word",
16879 css.slice(pos, next + 1),
16880 pos,
16881 next
16882 ];
16883 pos = next;
16884 break;
16885 }
16886 case BACKSLASH:
16887 {
16888 next = pos;
16889 escape = true;
16890 while(css.charCodeAt(next + 1) === BACKSLASH){
16891 next += 1;
16892 escape = !escape;
16893 }
16894 code = css.charCodeAt(next + 1);
16895 if (escape && code !== SLASH && code !== SPACE && code !== NEWLINE && code !== TAB && code !== CR && code !== FEED) {
16896 next += 1;
16897 if (RE_HEX_ESCAPE.test(css.charAt(next))) {
16898 while(RE_HEX_ESCAPE.test(css.charAt(next + 1))){
16899 next += 1;
16900 }
16901 if (css.charCodeAt(next + 1) === SPACE) {
16902 next += 1;
16903 }
16904 }
16905 }
16906 currentToken = [
16907 "word",
16908 css.slice(pos, next + 1),
16909 pos,
16910 next
16911 ];
16912 pos = next;
16913 break;
16914 }
16915 default:
16916 {
16917 if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
16918 next = css.indexOf("*/", pos + 2) + 1;
16919 if (next === 0) {
16920 if (ignore || ignoreUnclosed) {
16921 next = css.length;
16922 } else {
16923 unclosed("comment");
16924 }
16925 }
16926 currentToken = [
16927 "comment",
16928 css.slice(pos, next + 1),
16929 pos,
16930 next
16931 ];
16932 pos = next;
16933 } else {
16934 RE_WORD_END.lastIndex = pos + 1;
16935 RE_WORD_END.test(css);
16936 if (RE_WORD_END.lastIndex === 0) {
16937 next = css.length - 1;
16938 } else {
16939 next = RE_WORD_END.lastIndex - 2;
16940 }
16941 currentToken = [
16942 "word",
16943 css.slice(pos, next + 1),
16944 pos,
16945 next
16946 ];
16947 buffer.push(currentToken);
16948 pos = next;
16949 }
16950 break;
16951 }
16952 }
16953 pos++;
16954 return currentToken;
16955 }
16956 function back(token) {
16957 returned.push(token);
16958 }
16959 return {
16960 back: back,
16961 endOfFile: endOfFile,
16962 nextToken: nextToken,
16963 position: position
16964 };
16965 };
16966 var Container$5 = container;
16967 var AtRule$3 = /*#__PURE__*/ function(Container$5) {
16968 _inherits(AtRule2, Container$5);
16969 function AtRule2(defaults) {
16970 var _this;
16971 _this = Container$5.call(this, defaults) || this;
16972 _this.type = "atrule";
16973 return _this;
16974 }
16975 var _proto = AtRule2.prototype;
16976 _proto.append = function append() {
16977 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16978 children[_key] = arguments[_key];
16979 }
16980 var _Container$5_prototype_append;
16981 if (!this.proxyOf.nodes) this.nodes = [];
16982 return (_Container$5_prototype_append = Container$5.prototype.append).call.apply(_Container$5_prototype_append, [].concat([
16983 this
16984 ], children));
16985 };
16986 _proto.prepend = function prepend() {
16987 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16988 children[_key] = arguments[_key];
16989 }
16990 var _Container$5_prototype_prepend;
16991 if (!this.proxyOf.nodes) this.nodes = [];
16992 return (_Container$5_prototype_prepend = Container$5.prototype.prepend).call.apply(_Container$5_prototype_prepend, [].concat([
16993 this
16994 ], children));
16995 };
16996 return AtRule2;
16997 }(Container$5);
16998 var atRule = AtRule$3;
16999 AtRule$3.default = AtRule$3;
17000 Container$5.registerAtRule(AtRule$3);
17001 var Container$4 = container;
17002 var LazyResult$3, Processor$2;
17003 var Root$5 = /*#__PURE__*/ function(Container$4) {
17004 _inherits(Root2, Container$4);
17005 function Root2(defaults) {
17006 var _this;
17007 _this = Container$4.call(this, defaults) || this;
17008 _this.type = "root";
17009 if (!_this.nodes) _this.nodes = [];
17010 return _this;
17011 }
17012 var _proto = Root2.prototype;
17013 _proto.normalize = function normalize(child, sample, type) {
17014 var nodes = Container$4.prototype.normalize.call(this, child);
17015 if (sample) {
17016 if (type === "prepend") {
17017 if (this.nodes.length > 1) {
17018 sample.raws.before = this.nodes[1].raws.before;
17019 } else {
17020 delete sample.raws.before;
17021 }
17022 } else if (this.first !== sample) {
17023 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
17024 var node2 = _step.value;
17025 node2.raws.before = sample.raws.before;
17026 }
17027 }
17028 }
17029 return nodes;
17030 };
17031 _proto.removeChild = function removeChild(child, ignore) {
17032 var index2 = this.index(child);
17033 if (!ignore && index2 === 0 && this.nodes.length > 1) {
17034 this.nodes[1].raws.before = this.nodes[index2].raws.before;
17035 }
17036 return Container$4.prototype.removeChild.call(this, child);
17037 };
17038 _proto.toResult = function toResult(opts) {
17039 if (opts === void 0) opts = {};
17040 var lazy = new LazyResult$3(new Processor$2(), this, opts);
17041 return lazy.stringify();
17042 };
17043 return Root2;
17044 }(Container$4);
17045 Root$5.registerLazyResult = function(dependant) {
17046 LazyResult$3 = dependant;
17047 };
17048 Root$5.registerProcessor = function(dependant) {
17049 Processor$2 = dependant;
17050 };
17051 var root = Root$5;
17052 Root$5.default = Root$5;
17053 Container$4.registerRoot(Root$5);
17054 var list$2 = {
17055 comma: function comma(string) {
17056 return list$2.split(string, [
17057 ","
17058 ], true);
17059 },
17060 space: function space(string) {
17061 var spaces = [
17062 " ",
17063 "\n",
17064 " "
17065 ];
17066 return list$2.split(string, spaces);
17067 },
17068 split: function split(string, separators, last) {
17069 var array = [];
17070 var current = "";
17071 var split = false;
17072 var func = 0;
17073 var inQuote = false;
17074 var prevQuote = "";
17075 var escape = false;
17076 for(var _iterator = _create_for_of_iterator_helper_loose(string), _step; !(_step = _iterator()).done;){
17077 var letter = _step.value;
17078 if (escape) {
17079 escape = false;
17080 } else if (letter === "\\") {
17081 escape = true;
17082 } else if (inQuote) {
17083 if (letter === prevQuote) {
17084 inQuote = false;
17085 }
17086 } else if (letter === '"' || letter === "'") {
17087 inQuote = true;
17088 prevQuote = letter;
17089 } else if (letter === "(") {
17090 func += 1;
17091 } else if (letter === ")") {
17092 if (func > 0) func -= 1;
17093 } else if (func === 0) {
17094 if (separators.includes(letter)) split = true;
17095 }
17096 if (split) {
17097 if (current !== "") array.push(current.trim());
17098 current = "";
17099 split = false;
17100 } else {
17101 current += letter;
17102 }
17103 }
17104 if (last || current !== "") array.push(current.trim());
17105 return array;
17106 }
17107 };
17108 var list_1 = list$2;
17109 list$2.default = list$2;
17110 var Container$3 = container;
17111 var list$1 = list_1;
17112 var Rule$3 = /*#__PURE__*/ function(Container$3) {
17113 _inherits(Rule2, Container$3);
17114 function Rule2(defaults) {
17115 var _this;
17116 _this = Container$3.call(this, defaults) || this;
17117 _this.type = "rule";
17118 if (!_this.nodes) _this.nodes = [];
17119 return _this;
17120 }
17121 _create_class(Rule2, [
17122 {
17123 key: "selectors",
17124 get: function get() {
17125 return list$1.comma(this.selector);
17126 },
17127 set: function set(values) {
17128 var match = this.selector ? this.selector.match(/,\s*/) : null;
17129 var sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen");
17130 this.selector = values.join(sep2);
17131 }
17132 }
17133 ]);
17134 return Rule2;
17135 }(Container$3);
17136 var rule = Rule$3;
17137 Rule$3.default = Rule$3;
17138 Container$3.registerRule(Rule$3);
17139 var Declaration$2 = declaration;
17140 var tokenizer22 = tokenize;
17141 var Comment$2 = comment;
17142 var AtRule$2 = atRule;
17143 var Root$4 = root;
17144 var Rule$2 = rule;
17145 var SAFE_COMMENT_NEIGHBOR = {
17146 empty: true,
17147 space: true
17148 };
17149 function findLastWithPosition(tokens) {
17150 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
17151 var token = tokens[i2];
17152 var pos = token[3] || token[2];
17153 if (pos) return pos;
17154 }
17155 }
17156 var Parser$1 = /*#__PURE__*/ function() {
17157 function Parser2(input2) {
17158 this.input = input2;
17159 this.root = new Root$4();
17160 this.current = this.root;
17161 this.spaces = "";
17162 this.semicolon = false;
17163 this.createTokenizer();
17164 this.root.source = {
17165 input: input2,
17166 start: {
17167 column: 1,
17168 line: 1,
17169 offset: 0
17170 }
17171 };
17172 }
17173 var _proto = Parser2.prototype;
17174 _proto.atrule = function atrule(token) {
17175 var node2 = new AtRule$2();
17176 node2.name = token[1].slice(1);
17177 if (node2.name === "") {
17178 this.unnamedAtrule(node2, token);
17179 }
17180 this.init(node2, token[2]);
17181 var type;
17182 var prev;
17183 var shift;
17184 var last = false;
17185 var open = false;
17186 var params = [];
17187 var brackets = [];
17188 while(!this.tokenizer.endOfFile()){
17189 token = this.tokenizer.nextToken();
17190 type = token[0];
17191 if (type === "(" || type === "[") {
17192 brackets.push(type === "(" ? ")" : "]");
17193 } else if (type === "{" && brackets.length > 0) {
17194 brackets.push("}");
17195 } else if (type === brackets[brackets.length - 1]) {
17196 brackets.pop();
17197 }
17198 if (brackets.length === 0) {
17199 if (type === ";") {
17200 node2.source.end = this.getPosition(token[2]);
17201 node2.source.end.offset++;
17202 this.semicolon = true;
17203 break;
17204 } else if (type === "{") {
17205 open = true;
17206 break;
17207 } else if (type === "}") {
17208 if (params.length > 0) {
17209 shift = params.length - 1;
17210 prev = params[shift];
17211 while(prev && prev[0] === "space"){
17212 prev = params[--shift];
17213 }
17214 if (prev) {
17215 node2.source.end = this.getPosition(prev[3] || prev[2]);
17216 node2.source.end.offset++;
17217 }
17218 }
17219 this.end(token);
17220 break;
17221 } else {
17222 params.push(token);
17223 }
17224 } else {
17225 params.push(token);
17226 }
17227 if (this.tokenizer.endOfFile()) {
17228 last = true;
17229 break;
17230 }
17231 }
17232 node2.raws.between = this.spacesAndCommentsFromEnd(params);
17233 if (params.length) {
17234 node2.raws.afterName = this.spacesAndCommentsFromStart(params);
17235 this.raw(node2, "params", params);
17236 if (last) {
17237 token = params[params.length - 1];
17238 node2.source.end = this.getPosition(token[3] || token[2]);
17239 node2.source.end.offset++;
17240 this.spaces = node2.raws.between;
17241 node2.raws.between = "";
17242 }
17243 } else {
17244 node2.raws.afterName = "";
17245 node2.params = "";
17246 }
17247 if (open) {
17248 node2.nodes = [];
17249 this.current = node2;
17250 }
17251 };
17252 _proto.checkMissedSemicolon = function checkMissedSemicolon(tokens) {
17253 var colon = this.colon(tokens);
17254 if (colon === false) return;
17255 var founded = 0;
17256 var token;
17257 for(var j = colon - 1; j >= 0; j--){
17258 token = tokens[j];
17259 if (token[0] !== "space") {
17260 founded += 1;
17261 if (founded === 2) break;
17262 }
17263 }
17264 throw this.input.error("Missed semicolon", token[0] === "word" ? token[3] + 1 : token[2]);
17265 };
17266 _proto.colon = function colon(tokens) {
17267 var brackets = 0;
17268 var token, type, prev;
17269 for(var _iterator = _create_for_of_iterator_helper_loose(tokens.entries()), _step; !(_step = _iterator()).done;){
17270 var _step_value = _step.value, i2 = _step_value[0], element = _step_value[1];
17271 token = element;
17272 type = token[0];
17273 if (type === "(") {
17274 brackets += 1;
17275 }
17276 if (type === ")") {
17277 brackets -= 1;
17278 }
17279 if (brackets === 0 && type === ":") {
17280 if (!prev) {
17281 this.doubleColon(token);
17282 } else if (prev[0] === "word" && prev[1] === "progid") {
17283 continue;
17284 } else {
17285 return i2;
17286 }
17287 }
17288 prev = token;
17289 }
17290 return false;
17291 };
17292 _proto.comment = function comment(token) {
17293 var node2 = new Comment$2();
17294 this.init(node2, token[2]);
17295 node2.source.end = this.getPosition(token[3] || token[2]);
17296 node2.source.end.offset++;
17297 var text = token[1].slice(2, -2);
17298 if (/^\s*$/.test(text)) {
17299 node2.text = "";
17300 node2.raws.left = text;
17301 node2.raws.right = "";
17302 } else {
17303 var match = text.match(/^(\s*)([^]*\S)(\s*)$/);
17304 node2.text = match[2];
17305 node2.raws.left = match[1];
17306 node2.raws.right = match[3];
17307 }
17308 };
17309 _proto.createTokenizer = function createTokenizer() {
17310 this.tokenizer = tokenizer22(this.input);
17311 };
17312 _proto.decl = function decl(tokens, customProperty) {
17313 var node2 = new Declaration$2();
17314 this.init(node2, tokens[0][2]);
17315 var last = tokens[tokens.length - 1];
17316 if (last[0] === ";") {
17317 this.semicolon = true;
17318 tokens.pop();
17319 }
17320 node2.source.end = this.getPosition(last[3] || last[2] || findLastWithPosition(tokens));
17321 node2.source.end.offset++;
17322 while(tokens[0][0] !== "word"){
17323 if (tokens.length === 1) this.unknownWord(tokens);
17324 node2.raws.before += tokens.shift()[1];
17325 }
17326 node2.source.start = this.getPosition(tokens[0][2]);
17327 node2.prop = "";
17328 while(tokens.length){
17329 var type = tokens[0][0];
17330 if (type === ":" || type === "space" || type === "comment") {
17331 break;
17332 }
17333 node2.prop += tokens.shift()[1];
17334 }
17335 node2.raws.between = "";
17336 var token;
17337 while(tokens.length){
17338 token = tokens.shift();
17339 if (token[0] === ":") {
17340 node2.raws.between += token[1];
17341 break;
17342 } else {
17343 if (token[0] === "word" && /\w/.test(token[1])) {
17344 this.unknownWord([
17345 token
17346 ]);
17347 }
17348 node2.raws.between += token[1];
17349 }
17350 }
17351 if (node2.prop[0] === "_" || node2.prop[0] === "*") {
17352 node2.raws.before += node2.prop[0];
17353 node2.prop = node2.prop.slice(1);
17354 }
17355 var firstSpaces = [];
17356 var next;
17357 while(tokens.length){
17358 next = tokens[0][0];
17359 if (next !== "space" && next !== "comment") break;
17360 firstSpaces.push(tokens.shift());
17361 }
17362 this.precheckMissedSemicolon(tokens);
17363 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
17364 token = tokens[i2];
17365 if (token[1].toLowerCase() === "!important") {
17366 node2.important = true;
17367 var string = this.stringFrom(tokens, i2);
17368 string = this.spacesFromEnd(tokens) + string;
17369 if (string !== " !important") node2.raws.important = string;
17370 break;
17371 } else if (token[1].toLowerCase() === "important") {
17372 var cache = tokens.slice(0);
17373 var str = "";
17374 for(var j = i2; j > 0; j--){
17375 var type1 = cache[j][0];
17376 if (str.trim().indexOf("!") === 0 && type1 !== "space") {
17377 break;
17378 }
17379 str = cache.pop()[1] + str;
17380 }
17381 if (str.trim().indexOf("!") === 0) {
17382 node2.important = true;
17383 node2.raws.important = str;
17384 tokens = cache;
17385 }
17386 }
17387 if (token[0] !== "space" && token[0] !== "comment") {
17388 break;
17389 }
17390 }
17391 var hasWord = tokens.some(function(i2) {
17392 return i2[0] !== "space" && i2[0] !== "comment";
17393 });
17394 if (hasWord) {
17395 node2.raws.between += firstSpaces.map(function(i2) {
17396 return i2[1];
17397 }).join("");
17398 firstSpaces = [];
17399 }
17400 this.raw(node2, "value", firstSpaces.concat(tokens), customProperty);
17401 if (node2.value.includes(":") && !customProperty) {
17402 this.checkMissedSemicolon(tokens);
17403 }
17404 };
17405 _proto.doubleColon = function doubleColon(token) {
17406 throw this.input.error("Double colon", {
17407 offset: token[2]
17408 }, {
17409 offset: token[2] + token[1].length
17410 });
17411 };
17412 _proto.emptyRule = function emptyRule(token) {
17413 var node2 = new Rule$2();
17414 this.init(node2, token[2]);
17415 node2.selector = "";
17416 node2.raws.between = "";
17417 this.current = node2;
17418 };
17419 _proto.end = function end(token) {
17420 if (this.current.nodes && this.current.nodes.length) {
17421 this.current.raws.semicolon = this.semicolon;
17422 }
17423 this.semicolon = false;
17424 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
17425 this.spaces = "";
17426 if (this.current.parent) {
17427 this.current.source.end = this.getPosition(token[2]);
17428 this.current.source.end.offset++;
17429 this.current = this.current.parent;
17430 } else {
17431 this.unexpectedClose(token);
17432 }
17433 };
17434 _proto.endFile = function endFile() {
17435 if (this.current.parent) this.unclosedBlock();
17436 if (this.current.nodes && this.current.nodes.length) {
17437 this.current.raws.semicolon = this.semicolon;
17438 }
17439 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
17440 this.root.source.end = this.getPosition(this.tokenizer.position());
17441 };
17442 _proto.freeSemicolon = function freeSemicolon(token) {
17443 this.spaces += token[1];
17444 if (this.current.nodes) {
17445 var prev = this.current.nodes[this.current.nodes.length - 1];
17446 if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
17447 prev.raws.ownSemicolon = this.spaces;
17448 this.spaces = "";
17449 }
17450 }
17451 };
17452 // Helpers
17453 _proto.getPosition = function getPosition(offset) {
17454 var pos = this.input.fromOffset(offset);
17455 return {
17456 column: pos.col,
17457 line: pos.line,
17458 offset: offset
17459 };
17460 };
17461 _proto.init = function init(node2, offset) {
17462 this.current.push(node2);
17463 node2.source = {
17464 input: this.input,
17465 start: this.getPosition(offset)
17466 };
17467 node2.raws.before = this.spaces;
17468 this.spaces = "";
17469 if (node2.type !== "comment") this.semicolon = false;
17470 };
17471 _proto.other = function other(start) {
17472 var end = false;
17473 var type = null;
17474 var colon = false;
17475 var bracket = null;
17476 var brackets = [];
17477 var customProperty = start[1].startsWith("--");
17478 var tokens = [];
17479 var token = start;
17480 while(token){
17481 type = token[0];
17482 tokens.push(token);
17483 if (type === "(" || type === "[") {
17484 if (!bracket) bracket = token;
17485 brackets.push(type === "(" ? ")" : "]");
17486 } else if (customProperty && colon && type === "{") {
17487 if (!bracket) bracket = token;
17488 brackets.push("}");
17489 } else if (brackets.length === 0) {
17490 if (type === ";") {
17491 if (colon) {
17492 this.decl(tokens, customProperty);
17493 return;
17494 } else {
17495 break;
17496 }
17497 } else if (type === "{") {
17498 this.rule(tokens);
17499 return;
17500 } else if (type === "}") {
17501 this.tokenizer.back(tokens.pop());
17502 end = true;
17503 break;
17504 } else if (type === ":") {
17505 colon = true;
17506 }
17507 } else if (type === brackets[brackets.length - 1]) {
17508 brackets.pop();
17509 if (brackets.length === 0) bracket = null;
17510 }
17511 token = this.tokenizer.nextToken();
17512 }
17513 if (this.tokenizer.endOfFile()) end = true;
17514 if (brackets.length > 0) this.unclosedBracket(bracket);
17515 if (end && colon) {
17516 if (!customProperty) {
17517 while(tokens.length){
17518 token = tokens[tokens.length - 1][0];
17519 if (token !== "space" && token !== "comment") break;
17520 this.tokenizer.back(tokens.pop());
17521 }
17522 }
17523 this.decl(tokens, customProperty);
17524 } else {
17525 this.unknownWord(tokens);
17526 }
17527 };
17528 _proto.parse = function parse() {
17529 var token;
17530 while(!this.tokenizer.endOfFile()){
17531 token = this.tokenizer.nextToken();
17532 switch(token[0]){
17533 case "space":
17534 this.spaces += token[1];
17535 break;
17536 case ";":
17537 this.freeSemicolon(token);
17538 break;
17539 case "}":
17540 this.end(token);
17541 break;
17542 case "comment":
17543 this.comment(token);
17544 break;
17545 case "at-word":
17546 this.atrule(token);
17547 break;
17548 case "{":
17549 this.emptyRule(token);
17550 break;
17551 default:
17552 this.other(token);
17553 break;
17554 }
17555 }
17556 this.endFile();
17557 };
17558 _proto.precheckMissedSemicolon = function precheckMissedSemicolon() {};
17559 _proto.raw = function raw(node2, prop, tokens, customProperty) {
17560 var token, type;
17561 var length = tokens.length;
17562 var value = "";
17563 var clean = true;
17564 var next, prev;
17565 for(var i2 = 0; i2 < length; i2 += 1){
17566 token = tokens[i2];
17567 type = token[0];
17568 if (type === "space" && i2 === length - 1 && !customProperty) {
17569 clean = false;
17570 } else if (type === "comment") {
17571 prev = tokens[i2 - 1] ? tokens[i2 - 1][0] : "empty";
17572 next = tokens[i2 + 1] ? tokens[i2 + 1][0] : "empty";
17573 if (!SAFE_COMMENT_NEIGHBOR[prev] && !SAFE_COMMENT_NEIGHBOR[next]) {
17574 if (value.slice(-1) === ",") {
17575 clean = false;
17576 } else {
17577 value += token[1];
17578 }
17579 } else {
17580 clean = false;
17581 }
17582 } else {
17583 value += token[1];
17584 }
17585 }
17586 if (!clean) {
17587 var raw = tokens.reduce(function(all, i2) {
17588 return all + i2[1];
17589 }, "");
17590 node2.raws[prop] = {
17591 raw: raw,
17592 value: value
17593 };
17594 }
17595 node2[prop] = value;
17596 };
17597 _proto.rule = function rule(tokens) {
17598 tokens.pop();
17599 var node2 = new Rule$2();
17600 this.init(node2, tokens[0][2]);
17601 node2.raws.between = this.spacesAndCommentsFromEnd(tokens);
17602 this.raw(node2, "selector", tokens);
17603 this.current = node2;
17604 };
17605 _proto.spacesAndCommentsFromEnd = function spacesAndCommentsFromEnd(tokens) {
17606 var lastTokenType;
17607 var spaces = "";
17608 while(tokens.length){
17609 lastTokenType = tokens[tokens.length - 1][0];
17610 if (lastTokenType !== "space" && lastTokenType !== "comment") break;
17611 spaces = tokens.pop()[1] + spaces;
17612 }
17613 return spaces;
17614 };
17615 // Errors
17616 _proto.spacesAndCommentsFromStart = function spacesAndCommentsFromStart(tokens) {
17617 var next;
17618 var spaces = "";
17619 while(tokens.length){
17620 next = tokens[0][0];
17621 if (next !== "space" && next !== "comment") break;
17622 spaces += tokens.shift()[1];
17623 }
17624 return spaces;
17625 };
17626 _proto.spacesFromEnd = function spacesFromEnd(tokens) {
17627 var lastTokenType;
17628 var spaces = "";
17629 while(tokens.length){
17630 lastTokenType = tokens[tokens.length - 1][0];
17631 if (lastTokenType !== "space") break;
17632 spaces = tokens.pop()[1] + spaces;
17633 }
17634 return spaces;
17635 };
17636 _proto.stringFrom = function stringFrom(tokens, from) {
17637 var result2 = "";
17638 for(var i2 = from; i2 < tokens.length; i2++){
17639 result2 += tokens[i2][1];
17640 }
17641 tokens.splice(from, tokens.length - from);
17642 return result2;
17643 };
17644 _proto.unclosedBlock = function unclosedBlock() {
17645 var pos = this.current.source.start;
17646 throw this.input.error("Unclosed block", pos.line, pos.column);
17647 };
17648 _proto.unclosedBracket = function unclosedBracket(bracket) {
17649 throw this.input.error("Unclosed bracket", {
17650 offset: bracket[2]
17651 }, {
17652 offset: bracket[2] + 1
17653 });
17654 };
17655 _proto.unexpectedClose = function unexpectedClose(token) {
17656 throw this.input.error("Unexpected }", {
17657 offset: token[2]
17658 }, {
17659 offset: token[2] + 1
17660 });
17661 };
17662 _proto.unknownWord = function unknownWord(tokens) {
17663 throw this.input.error("Unknown word", {
17664 offset: tokens[0][2]
17665 }, {
17666 offset: tokens[0][2] + tokens[0][1].length
17667 });
17668 };
17669 _proto.unnamedAtrule = function unnamedAtrule(node2, token) {
17670 throw this.input.error("At-rule without name", {
17671 offset: token[2]
17672 }, {
17673 offset: token[2] + token[1].length
17674 });
17675 };
17676 return Parser2;
17677 }();
17678 var parser = Parser$1;
17679 var Container$2 = container;
17680 var Parser22 = parser;
17681 var Input$2 = input;
17682 function parse$3(css, opts) {
17683 var input2 = new Input$2(css, opts);
17684 var parser2 = new Parser22(input2);
17685 try {
17686 parser2.parse();
17687 } catch (e2) {
17688 if (true) {
17689 if (e2.name === "CssSyntaxError" && opts && opts.from) {
17690 if (/\.scss$/i.test(opts.from)) {
17691 e2.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser";
17692 } else if (/\.sass/i.test(opts.from)) {
17693 e2.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser";
17694 } else if (/\.less$/i.test(opts.from)) {
17695 e2.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser";
17696 }
17697 }
17698 }
17699 throw e2;
17700 }
17701 return parser2.root;
17702 }
17703 var parse_1 = parse$3;
17704 parse$3.default = parse$3;
17705 Container$2.registerParse(parse$3);
17706 var isClean = symbols.isClean, my = symbols.my;
17707 var MapGenerator$1 = mapGenerator;
17708 var stringify$2 = stringify_1;
17709 var Container$1 = container;
17710 var Document$2 = document$1$2;
17711 var warnOnce$1 = warnOnce$2;
17712 var Result$2 = result;
17713 var parse$2 = parse_1;
17714 var Root$3 = root;
17715 var TYPE_TO_CLASS_NAME = {
17716 atrule: "AtRule",
17717 comment: "Comment",
17718 decl: "Declaration",
17719 document: "Document",
17720 root: "Root",
17721 rule: "Rule"
17722 };
17723 var PLUGIN_PROPS = {
17724 AtRule: true,
17725 AtRuleExit: true,
17726 Comment: true,
17727 CommentExit: true,
17728 Declaration: true,
17729 DeclarationExit: true,
17730 Document: true,
17731 DocumentExit: true,
17732 Once: true,
17733 OnceExit: true,
17734 postcssPlugin: true,
17735 prepare: true,
17736 Root: true,
17737 RootExit: true,
17738 Rule: true,
17739 RuleExit: true
17740 };
17741 var NOT_VISITORS = {
17742 Once: true,
17743 postcssPlugin: true,
17744 prepare: true
17745 };
17746 var CHILDREN = 0;
17747 function isPromise(obj) {
17748 return (typeof obj === "undefined" ? "undefined" : _type_of(obj)) === "object" && typeof obj.then === "function";
17749 }
17750 function getEvents(node2) {
17751 var key = false;
17752 var type = TYPE_TO_CLASS_NAME[node2.type];
17753 if (node2.type === "decl") {
17754 key = node2.prop.toLowerCase();
17755 } else if (node2.type === "atrule") {
17756 key = node2.name.toLowerCase();
17757 }
17758 if (key && node2.append) {
17759 return [
17760 type,
17761 type + "-" + key,
17762 CHILDREN,
17763 type + "Exit",
17764 type + "Exit-" + key
17765 ];
17766 } else if (key) {
17767 return [
17768 type,
17769 type + "-" + key,
17770 type + "Exit",
17771 type + "Exit-" + key
17772 ];
17773 } else if (node2.append) {
17774 return [
17775 type,
17776 CHILDREN,
17777 type + "Exit"
17778 ];
17779 } else {
17780 return [
17781 type,
17782 type + "Exit"
17783 ];
17784 }
17785 }
17786 function toStack(node2) {
17787 var events;
17788 if (node2.type === "document") {
17789 events = [
17790 "Document",
17791 CHILDREN,
17792 "DocumentExit"
17793 ];
17794 } else if (node2.type === "root") {
17795 events = [
17796 "Root",
17797 CHILDREN,
17798 "RootExit"
17799 ];
17800 } else {
17801 events = getEvents(node2);
17802 }
17803 return {
17804 eventIndex: 0,
17805 events: events,
17806 iterator: 0,
17807 node: node2,
17808 visitorIndex: 0,
17809 visitors: []
17810 };
17811 }
17812 function cleanMarks(node2) {
17813 node2[isClean] = false;
17814 if (node2.nodes) node2.nodes.forEach(function(i2) {
17815 return cleanMarks(i2);
17816 });
17817 return node2;
17818 }
17819 var postcss$2 = {};
17820 var LazyResult$2 = /*#__PURE__*/ function() {
17821 function LazyResult2(processor2, css, opts) {
17822 var _this = this;
17823 this.stringified = false;
17824 this.processed = false;
17825 var root2;
17826 if ((typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && css !== null && (css.type === "root" || css.type === "document")) {
17827 root2 = cleanMarks(css);
17828 } else if (_instanceof(css, LazyResult2) || _instanceof(css, Result$2)) {
17829 root2 = cleanMarks(css.root);
17830 if (css.map) {
17831 if (typeof opts.map === "undefined") opts.map = {};
17832 if (!opts.map.inline) opts.map.inline = false;
17833 opts.map.prev = css.map;
17834 }
17835 } else {
17836 var parser2 = parse$2;
17837 if (opts.syntax) parser2 = opts.syntax.parse;
17838 if (opts.parser) parser2 = opts.parser;
17839 if (parser2.parse) parser2 = parser2.parse;
17840 try {
17841 root2 = parser2(css, opts);
17842 } catch (error) {
17843 this.processed = true;
17844 this.error = error;
17845 }
17846 if (root2 && !root2[my]) {
17847 Container$1.rebuild(root2);
17848 }
17849 }
17850 this.result = new Result$2(processor2, root2, opts);
17851 this.helpers = _extends({}, postcss$2, {
17852 postcss: postcss$2,
17853 result: this.result
17854 });
17855 this.plugins = this.processor.plugins.map(function(plugin22) {
17856 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.prepare) {
17857 return _extends({}, plugin22, plugin22.prepare(_this.result));
17858 } else {
17859 return plugin22;
17860 }
17861 });
17862 }
17863 var _proto = LazyResult2.prototype;
17864 _proto.async = function async() {
17865 if (this.error) return Promise.reject(this.error);
17866 if (this.processed) return Promise.resolve(this.result);
17867 if (!this.processing) {
17868 this.processing = this.runAsync();
17869 }
17870 return this.processing;
17871 };
17872 _proto.catch = function _catch(onRejected) {
17873 return this.async().catch(onRejected);
17874 };
17875 _proto.finally = function _finally(onFinally) {
17876 return this.async().then(onFinally, onFinally);
17877 };
17878 _proto.getAsyncError = function getAsyncError() {
17879 throw new Error("Use process(css).then(cb) to work with async plugins");
17880 };
17881 _proto.handleError = function handleError(error, node2) {
17882 var plugin22 = this.result.lastPlugin;
17883 try {
17884 if (node2) node2.addToError(error);
17885 this.error = error;
17886 if (error.name === "CssSyntaxError" && !error.plugin) {
17887 error.plugin = plugin22.postcssPlugin;
17888 error.setMessage();
17889 } else if (plugin22.postcssVersion) {
17890 if (true) {
17891 var pluginName = plugin22.postcssPlugin;
17892 var pluginVer = plugin22.postcssVersion;
17893 var runtimeVer = this.result.processor.version;
17894 var a2 = pluginVer.split(".");
17895 var b = runtimeVer.split(".");
17896 if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) {
17897 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.");
17898 }
17899 }
17900 }
17901 } catch (err) {
17902 if (console && console.error) console.error(err);
17903 }
17904 return error;
17905 };
17906 _proto.prepareVisitors = function prepareVisitors() {
17907 var _this = this;
17908 this.listeners = {};
17909 var add = function(plugin22, type, cb) {
17910 if (!_this.listeners[type]) _this.listeners[type] = [];
17911 _this.listeners[type].push([
17912 plugin22,
17913 cb
17914 ]);
17915 };
17916 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
17917 var plugin22 = _step.value;
17918 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object") {
17919 for(var event in plugin22){
17920 if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) {
17921 throw new Error("Unknown event " + event + " in " + plugin22.postcssPlugin + ". Try to update PostCSS (" + this.processor.version + " now).");
17922 }
17923 if (!NOT_VISITORS[event]) {
17924 if (_type_of(plugin22[event]) === "object") {
17925 for(var filter in plugin22[event]){
17926 if (filter === "*") {
17927 add(plugin22, event, plugin22[event][filter]);
17928 } else {
17929 add(plugin22, event + "-" + filter.toLowerCase(), plugin22[event][filter]);
17930 }
17931 }
17932 } else if (typeof plugin22[event] === "function") {
17933 add(plugin22, event, plugin22[event]);
17934 }
17935 }
17936 }
17937 }
17938 }
17939 this.hasListener = Object.keys(this.listeners).length > 0;
17940 };
17941 _proto.runAsync = function runAsync() {
17942 var _this = this;
17943 return _async_to_generator(function() {
17944 var i2, plugin22, promise, error, root2, stack, promise1, e2, node2, _loop, _iterator, _step;
17945 return _ts_generator(this, function(_state) {
17946 switch(_state.label){
17947 case 0:
17948 _this.plugin = 0;
17949 i2 = 0;
17950 _state.label = 1;
17951 case 1:
17952 if (!(i2 < _this.plugins.length)) return [
17953 3,
17954 6
17955 ];
17956 plugin22 = _this.plugins[i2];
17957 promise = _this.runOnRoot(plugin22);
17958 if (!isPromise(promise)) return [
17959 3,
17960 5
17961 ];
17962 _state.label = 2;
17963 case 2:
17964 _state.trys.push([
17965 2,
17966 4,
17967 ,
17968 5
17969 ]);
17970 return [
17971 4,
17972 promise
17973 ];
17974 case 3:
17975 _state.sent();
17976 return [
17977 3,
17978 5
17979 ];
17980 case 4:
17981 error = _state.sent();
17982 throw _this.handleError(error);
17983 case 5:
17984 i2++;
17985 return [
17986 3,
17987 1
17988 ];
17989 case 6:
17990 _this.prepareVisitors();
17991 if (!_this.hasListener) return [
17992 3,
17993 18
17994 ];
17995 root2 = _this.result.root;
17996 _state.label = 7;
17997 case 7:
17998 if (!!root2[isClean]) return [
17999 3,
18000 14
18001 ];
18002 root2[isClean] = true;
18003 stack = [
18004 toStack(root2)
18005 ];
18006 _state.label = 8;
18007 case 8:
18008 if (!(stack.length > 0)) return [
18009 3,
18010 13
18011 ];
18012 promise1 = _this.visitTick(stack);
18013 if (!isPromise(promise1)) return [
18014 3,
18015 12
18016 ];
18017 _state.label = 9;
18018 case 9:
18019 _state.trys.push([
18020 9,
18021 11,
18022 ,
18023 12
18024 ]);
18025 return [
18026 4,
18027 promise1
18028 ];
18029 case 10:
18030 _state.sent();
18031 return [
18032 3,
18033 12
18034 ];
18035 case 11:
18036 e2 = _state.sent();
18037 node2 = stack[stack.length - 1].node;
18038 throw _this.handleError(e2, node2);
18039 case 12:
18040 return [
18041 3,
18042 8
18043 ];
18044 case 13:
18045 return [
18046 3,
18047 7
18048 ];
18049 case 14:
18050 if (!_this.listeners.OnceExit) return [
18051 3,
18052 18
18053 ];
18054 _loop = function() {
18055 var _step_value, plugin22, visitor, roots, e2;
18056 return _ts_generator(this, function(_state) {
18057 switch(_state.label){
18058 case 0:
18059 _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
18060 _this.result.lastPlugin = plugin22;
18061 _state.label = 1;
18062 case 1:
18063 _state.trys.push([
18064 1,
18065 6,
18066 ,
18067 7
18068 ]);
18069 if (!(root2.type === "document")) return [
18070 3,
18071 3
18072 ];
18073 roots = root2.nodes.map(function(subRoot) {
18074 return visitor(subRoot, _this.helpers);
18075 });
18076 return [
18077 4,
18078 Promise.all(roots)
18079 ];
18080 case 2:
18081 _state.sent();
18082 return [
18083 3,
18084 5
18085 ];
18086 case 3:
18087 return [
18088 4,
18089 visitor(root2, _this.helpers)
18090 ];
18091 case 4:
18092 _state.sent();
18093 _state.label = 5;
18094 case 5:
18095 return [
18096 3,
18097 7
18098 ];
18099 case 6:
18100 e2 = _state.sent();
18101 throw _this.handleError(e2);
18102 case 7:
18103 return [
18104 2
18105 ];
18106 }
18107 });
18108 };
18109 _iterator = _create_for_of_iterator_helper_loose(_this.listeners.OnceExit);
18110 _state.label = 15;
18111 case 15:
18112 if (!!(_step = _iterator()).done) return [
18113 3,
18114 18
18115 ];
18116 return [
18117 5,
18118 _ts_values(_loop())
18119 ];
18120 case 16:
18121 _state.sent();
18122 _state.label = 17;
18123 case 17:
18124 return [
18125 3,
18126 15
18127 ];
18128 case 18:
18129 _this.processed = true;
18130 return [
18131 2,
18132 _this.stringify()
18133 ];
18134 }
18135 });
18136 })();
18137 };
18138 _proto.runOnRoot = function runOnRoot(plugin22) {
18139 var _this = this;
18140 this.result.lastPlugin = plugin22;
18141 try {
18142 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.Once) {
18143 if (this.result.root.type === "document") {
18144 var roots = this.result.root.nodes.map(function(root2) {
18145 return plugin22.Once(root2, _this.helpers);
18146 });
18147 if (isPromise(roots[0])) {
18148 return Promise.all(roots);
18149 }
18150 return roots;
18151 }
18152 return plugin22.Once(this.result.root, this.helpers);
18153 } else if (typeof plugin22 === "function") {
18154 return plugin22(this.result.root, this.result);
18155 }
18156 } catch (error) {
18157 throw this.handleError(error);
18158 }
18159 };
18160 _proto.stringify = function stringify() {
18161 if (this.error) throw this.error;
18162 if (this.stringified) return this.result;
18163 this.stringified = true;
18164 this.sync();
18165 var opts = this.result.opts;
18166 var str = stringify$2;
18167 if (opts.syntax) str = opts.syntax.stringify;
18168 if (opts.stringifier) str = opts.stringifier;
18169 if (str.stringify) str = str.stringify;
18170 var map = new MapGenerator$1(str, this.result.root, this.result.opts);
18171 var data = map.generate();
18172 this.result.css = data[0];
18173 this.result.map = data[1];
18174 return this.result;
18175 };
18176 _proto.sync = function sync() {
18177 if (this.error) throw this.error;
18178 if (this.processed) return this.result;
18179 this.processed = true;
18180 if (this.processing) {
18181 throw this.getAsyncError();
18182 }
18183 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
18184 var plugin22 = _step.value;
18185 var promise = this.runOnRoot(plugin22);
18186 if (isPromise(promise)) {
18187 throw this.getAsyncError();
18188 }
18189 }
18190 this.prepareVisitors();
18191 if (this.hasListener) {
18192 var root2 = this.result.root;
18193 while(!root2[isClean]){
18194 root2[isClean] = true;
18195 this.walkSync(root2);
18196 }
18197 if (this.listeners.OnceExit) {
18198 if (root2.type === "document") {
18199 for(var _iterator1 = _create_for_of_iterator_helper_loose(root2.nodes), _step1; !(_step1 = _iterator1()).done;){
18200 var subRoot = _step1.value;
18201 this.visitSync(this.listeners.OnceExit, subRoot);
18202 }
18203 } else {
18204 this.visitSync(this.listeners.OnceExit, root2);
18205 }
18206 }
18207 }
18208 return this.result;
18209 };
18210 _proto.then = function then(onFulfilled, onRejected) {
18211 if (true) {
18212 if (!("from" in this.opts)) {
18213 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.");
18214 }
18215 }
18216 return this.async().then(onFulfilled, onRejected);
18217 };
18218 _proto.toString = function toString() {
18219 return this.css;
18220 };
18221 _proto.visitSync = function visitSync(visitors, node2) {
18222 for(var _iterator = _create_for_of_iterator_helper_loose(visitors), _step; !(_step = _iterator()).done;){
18223 var _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
18224 this.result.lastPlugin = plugin22;
18225 var promise = void 0;
18226 try {
18227 promise = visitor(node2, this.helpers);
18228 } catch (e2) {
18229 throw this.handleError(e2, node2.proxyOf);
18230 }
18231 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
18232 return true;
18233 }
18234 if (isPromise(promise)) {
18235 throw this.getAsyncError();
18236 }
18237 }
18238 };
18239 _proto.visitTick = function visitTick(stack) {
18240 var visit2 = stack[stack.length - 1];
18241 var node2 = visit2.node, visitors = visit2.visitors;
18242 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
18243 stack.pop();
18244 return;
18245 }
18246 if (visitors.length > 0 && visit2.visitorIndex < visitors.length) {
18247 var _visitors_visit2_visitorIndex = visitors[visit2.visitorIndex], plugin22 = _visitors_visit2_visitorIndex[0], visitor = _visitors_visit2_visitorIndex[1];
18248 visit2.visitorIndex += 1;
18249 if (visit2.visitorIndex === visitors.length) {
18250 visit2.visitors = [];
18251 visit2.visitorIndex = 0;
18252 }
18253 this.result.lastPlugin = plugin22;
18254 try {
18255 return visitor(node2.toProxy(), this.helpers);
18256 } catch (e2) {
18257 throw this.handleError(e2, node2);
18258 }
18259 }
18260 if (visit2.iterator !== 0) {
18261 var iterator = visit2.iterator;
18262 var child;
18263 while(child = node2.nodes[node2.indexes[iterator]]){
18264 node2.indexes[iterator] += 1;
18265 if (!child[isClean]) {
18266 child[isClean] = true;
18267 stack.push(toStack(child));
18268 return;
18269 }
18270 }
18271 visit2.iterator = 0;
18272 delete node2.indexes[iterator];
18273 }
18274 var events = visit2.events;
18275 while(visit2.eventIndex < events.length){
18276 var event = events[visit2.eventIndex];
18277 visit2.eventIndex += 1;
18278 if (event === CHILDREN) {
18279 if (node2.nodes && node2.nodes.length) {
18280 node2[isClean] = true;
18281 visit2.iterator = node2.getIterator();
18282 }
18283 return;
18284 } else if (this.listeners[event]) {
18285 visit2.visitors = this.listeners[event];
18286 return;
18287 }
18288 }
18289 stack.pop();
18290 };
18291 _proto.walkSync = function walkSync(node2) {
18292 var _this = this;
18293 node2[isClean] = true;
18294 var events = getEvents(node2);
18295 for(var _iterator = _create_for_of_iterator_helper_loose(events), _step; !(_step = _iterator()).done;){
18296 var event = _step.value;
18297 if (event === CHILDREN) {
18298 if (node2.nodes) {
18299 node2.each(function(child) {
18300 if (!child[isClean]) _this.walkSync(child);
18301 });
18302 }
18303 } else {
18304 var visitors = this.listeners[event];
18305 if (visitors) {
18306 if (this.visitSync(visitors, node2.toProxy())) return;
18307 }
18308 }
18309 }
18310 };
18311 _proto.warnings = function warnings() {
18312 return this.sync().warnings();
18313 };
18314 _create_class(LazyResult2, [
18315 {
18316 key: "content",
18317 get: function get() {
18318 return this.stringify().content;
18319 }
18320 },
18321 {
18322 key: "css",
18323 get: function get() {
18324 return this.stringify().css;
18325 }
18326 },
18327 {
18328 key: "map",
18329 get: function get() {
18330 return this.stringify().map;
18331 }
18332 },
18333 {
18334 key: "messages",
18335 get: function get() {
18336 return this.sync().messages;
18337 }
18338 },
18339 {
18340 key: "opts",
18341 get: function get() {
18342 return this.result.opts;
18343 }
18344 },
18345 {
18346 key: "processor",
18347 get: function get() {
18348 return this.result.processor;
18349 }
18350 },
18351 {
18352 key: "root",
18353 get: function get() {
18354 return this.sync().root;
18355 }
18356 },
18357 {
18358 key: Symbol.toStringTag,
18359 get: function get() {
18360 return "LazyResult";
18361 }
18362 }
18363 ]);
18364 return LazyResult2;
18365 }();
18366 LazyResult$2.registerPostcss = function(dependant) {
18367 postcss$2 = dependant;
18368 };
18369 var lazyResult = LazyResult$2;
18370 LazyResult$2.default = LazyResult$2;
18371 Root$3.registerLazyResult(LazyResult$2);
18372 Document$2.registerLazyResult(LazyResult$2);
18373 var MapGenerator22 = mapGenerator;
18374 var stringify$1 = stringify_1;
18375 var warnOnce22 = warnOnce$2;
18376 var parse$1 = parse_1;
18377 var Result$1 = result;
18378 var NoWorkResult$1 = /*#__PURE__*/ function() {
18379 function NoWorkResult2(processor2, css, opts) {
18380 css = css.toString();
18381 this.stringified = false;
18382 this._processor = processor2;
18383 this._css = css;
18384 this._opts = opts;
18385 this._map = void 0;
18386 var root2;
18387 var str = stringify$1;
18388 this.result = new Result$1(this._processor, root2, this._opts);
18389 this.result.css = css;
18390 var self = this;
18391 Object.defineProperty(this.result, "root", {
18392 get: function get() {
18393 return self.root;
18394 }
18395 });
18396 var map = new MapGenerator22(str, root2, this._opts, css);
18397 if (map.isMap()) {
18398 var _map_generate = map.generate(), generatedCSS = _map_generate[0], generatedMap = _map_generate[1];
18399 if (generatedCSS) {
18400 this.result.css = generatedCSS;
18401 }
18402 if (generatedMap) {
18403 this.result.map = generatedMap;
18404 }
18405 } else {
18406 map.clearAnnotation();
18407 this.result.css = map.css;
18408 }
18409 }
18410 var _proto = NoWorkResult2.prototype;
18411 _proto.async = function async() {
18412 if (this.error) return Promise.reject(this.error);
18413 return Promise.resolve(this.result);
18414 };
18415 _proto.catch = function _catch(onRejected) {
18416 return this.async().catch(onRejected);
18417 };
18418 _proto.finally = function _finally(onFinally) {
18419 return this.async().then(onFinally, onFinally);
18420 };
18421 _proto.sync = function sync() {
18422 if (this.error) throw this.error;
18423 return this.result;
18424 };
18425 _proto.then = function then(onFulfilled, onRejected) {
18426 if (true) {
18427 if (!("from" in this._opts)) {
18428 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.");
18429 }
18430 }
18431 return this.async().then(onFulfilled, onRejected);
18432 };
18433 _proto.toString = function toString() {
18434 return this._css;
18435 };
18436 _proto.warnings = function warnings() {
18437 return [];
18438 };
18439 _create_class(NoWorkResult2, [
18440 {
18441 key: "content",
18442 get: function get() {
18443 return this.result.css;
18444 }
18445 },
18446 {
18447 key: "css",
18448 get: function get() {
18449 return this.result.css;
18450 }
18451 },
18452 {
18453 key: "map",
18454 get: function get() {
18455 return this.result.map;
18456 }
18457 },
18458 {
18459 key: "messages",
18460 get: function get() {
18461 return [];
18462 }
18463 },
18464 {
18465 key: "opts",
18466 get: function get() {
18467 return this.result.opts;
18468 }
18469 },
18470 {
18471 key: "processor",
18472 get: function get() {
18473 return this.result.processor;
18474 }
18475 },
18476 {
18477 key: "root",
18478 get: function get() {
18479 if (this._root) {
18480 return this._root;
18481 }
18482 var root2;
18483 var parser2 = parse$1;
18484 try {
18485 root2 = parser2(this._css, this._opts);
18486 } catch (error) {
18487 this.error = error;
18488 }
18489 if (this.error) {
18490 throw this.error;
18491 } else {
18492 this._root = root2;
18493 return root2;
18494 }
18495 }
18496 },
18497 {
18498 key: Symbol.toStringTag,
18499 get: function get() {
18500 return "NoWorkResult";
18501 }
18502 }
18503 ]);
18504 return NoWorkResult2;
18505 }();
18506 var noWorkResult = NoWorkResult$1;
18507 NoWorkResult$1.default = NoWorkResult$1;
18508 var NoWorkResult22 = noWorkResult;
18509 var LazyResult$1 = lazyResult;
18510 var Document$1 = document$1$2;
18511 var Root$2 = root;
18512 var Processor$1 = /*#__PURE__*/ function() {
18513 function Processor2(plugins) {
18514 if (plugins === void 0) plugins = [];
18515 this.version = "8.4.38";
18516 this.plugins = this.normalize(plugins);
18517 }
18518 var _proto = Processor2.prototype;
18519 _proto.normalize = function normalize(plugins) {
18520 var normalized = [];
18521 for(var _iterator = _create_for_of_iterator_helper_loose(plugins), _step; !(_step = _iterator()).done;){
18522 var i2 = _step.value;
18523 if (i2.postcss === true) {
18524 i2 = i2();
18525 } else if (i2.postcss) {
18526 i2 = i2.postcss;
18527 }
18528 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && Array.isArray(i2.plugins)) {
18529 normalized = normalized.concat(i2.plugins);
18530 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.postcssPlugin) {
18531 normalized.push(i2);
18532 } else if (typeof i2 === "function") {
18533 normalized.push(i2);
18534 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && (i2.parse || i2.stringify)) {
18535 if (true) {
18536 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.");
18537 }
18538 } else {
18539 throw new Error(i2 + " is not a PostCSS plugin");
18540 }
18541 }
18542 return normalized;
18543 };
18544 _proto.process = function process1(css, opts) {
18545 if (opts === void 0) opts = {};
18546 if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) {
18547 return new NoWorkResult22(this, css, opts);
18548 } else {
18549 return new LazyResult$1(this, css, opts);
18550 }
18551 };
18552 _proto.use = function use(plugin22) {
18553 this.plugins = this.plugins.concat(this.normalize([
18554 plugin22
18555 ]));
18556 return this;
18557 };
18558 return Processor2;
18559 }();
18560 var processor = Processor$1;
18561 Processor$1.default = Processor$1;
18562 Root$2.registerProcessor(Processor$1);
18563 Document$1.registerProcessor(Processor$1);
18564 var Declaration$1 = declaration;
18565 var PreviousMap22 = previousMap;
18566 var Comment$1 = comment;
18567 var AtRule$1 = atRule;
18568 var Input$1 = input;
18569 var Root$1 = root;
18570 var Rule$1 = rule;
18571 function fromJSON$1(json, inputs) {
18572 if (Array.isArray(json)) return json.map(function(n2) {
18573 return fromJSON$1(n2);
18574 });
18575 var ownInputs = json.inputs, defaults = _object_without_properties_loose(json, [
18576 "inputs"
18577 ]);
18578 if (ownInputs) {
18579 inputs = [];
18580 for(var _iterator = _create_for_of_iterator_helper_loose(ownInputs), _step; !(_step = _iterator()).done;){
18581 var input2 = _step.value;
18582 var inputHydrated = _extends({}, input2, {
18583 __proto__: Input$1.prototype
18584 });
18585 if (inputHydrated.map) {
18586 inputHydrated.map = _extends({}, inputHydrated.map, {
18587 __proto__: PreviousMap22.prototype
18588 });
18589 }
18590 inputs.push(inputHydrated);
18591 }
18592 }
18593 if (defaults.nodes) {
18594 defaults.nodes = json.nodes.map(function(n2) {
18595 return fromJSON$1(n2, inputs);
18596 });
18597 }
18598 if (defaults.source) {
18599 var _defaults_source = defaults.source, inputId = _defaults_source.inputId, source = _object_without_properties_loose(_defaults_source, [
18600 "inputId"
18601 ]);
18602 defaults.source = source;
18603 if (inputId != null) {
18604 defaults.source.input = inputs[inputId];
18605 }
18606 }
18607 if (defaults.type === "root") {
18608 return new Root$1(defaults);
18609 } else if (defaults.type === "decl") {
18610 return new Declaration$1(defaults);
18611 } else if (defaults.type === "rule") {
18612 return new Rule$1(defaults);
18613 } else if (defaults.type === "comment") {
18614 return new Comment$1(defaults);
18615 } else if (defaults.type === "atrule") {
18616 return new AtRule$1(defaults);
18617 } else {
18618 throw new Error("Unknown node type: " + json.type);
18619 }
18620 }
18621 var fromJSON_1 = fromJSON$1;
18622 fromJSON$1.default = fromJSON$1;
18623 var CssSyntaxError22 = cssSyntaxError;
18624 var Declaration22 = declaration;
18625 var LazyResult22 = lazyResult;
18626 var Container22 = container;
18627 var Processor22 = processor;
18628 var stringify = stringify_1;
18629 var fromJSON = fromJSON_1;
18630 var Document222 = document$1$2;
18631 var Warning22 = warning;
18632 var Comment22 = comment;
18633 var AtRule22 = atRule;
18634 var Result22 = result;
18635 var Input22 = input;
18636 var parse = parse_1;
18637 var list = list_1;
18638 var Rule22 = rule;
18639 var Root22 = root;
18640 var Node22 = node;
18641 function postcss() {
18642 for(var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++){
18643 plugins[_key] = arguments[_key];
18644 }
18645 if (plugins.length === 1 && Array.isArray(plugins[0])) {
18646 plugins = plugins[0];
18647 }
18648 return new Processor22(plugins);
18649 }
18650 postcss.plugin = function plugin2(name, initializer) {
18651 var warningPrinted = false;
18652 function creator() {
18653 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
18654 args[_key] = arguments[_key];
18655 }
18656 if (console && console.warn && !warningPrinted) {
18657 warningPrinted = true;
18658 console.warn(name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration");
18659 if (process.env.LANG && process.env.LANG.startsWith("cn")) {
18660 console.warn(name + ": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226");
18661 }
18662 }
18663 var transformer = initializer.apply(void 0, [].concat(args));
18664 transformer.postcssPlugin = name;
18665 transformer.postcssVersion = new Processor22().version;
18666 return transformer;
18667 }
18668 var cache;
18669 Object.defineProperty(creator, "postcss", {
18670 get: function get() {
18671 if (!cache) cache = creator();
18672 return cache;
18673 }
18674 });
18675 creator.process = function(css, processOpts, pluginOpts) {
18676 return postcss([
18677 creator(pluginOpts)
18678 ]).process(css, processOpts);
18679 };
18680 return creator;
18681 };
18682 postcss.stringify = stringify;
18683 postcss.parse = parse;
18684 postcss.fromJSON = fromJSON;
18685 postcss.list = list;
18686 postcss.comment = function(defaults) {
18687 return new Comment22(defaults);
18688 };
18689 postcss.atRule = function(defaults) {
18690 return new AtRule22(defaults);
18691 };
18692 postcss.decl = function(defaults) {
18693 return new Declaration22(defaults);
18694 };
18695 postcss.rule = function(defaults) {
18696 return new Rule22(defaults);
18697 };
18698 postcss.root = function(defaults) {
18699 return new Root22(defaults);
18700 };
18701 postcss.document = function(defaults) {
18702 return new Document222(defaults);
18703 };
18704 postcss.CssSyntaxError = CssSyntaxError22;
18705 postcss.Declaration = Declaration22;
18706 postcss.Container = Container22;
18707 postcss.Processor = Processor22;
18708 postcss.Document = Document222;
18709 postcss.Comment = Comment22;
18710 postcss.Warning = Warning22;
18711 postcss.AtRule = AtRule22;
18712 postcss.Result = Result22;
18713 postcss.Input = Input22;
18714 postcss.Rule = Rule22;
18715 postcss.Root = Root22;
18716 postcss.Node = Node22;
18717 LazyResult22.registerPostcss(postcss);
18718 var postcss_1 = postcss;
18719 postcss.default = postcss;
18720 var postcss$1 = /* @__PURE__ */ getDefaultExportFromCjs(postcss_1);
18721 postcss$1.stringify;
18722 postcss$1.fromJSON;
18723 postcss$1.plugin;
18724 postcss$1.parse;
18725 postcss$1.list;
18726 postcss$1.document;
18727 postcss$1.comment;
18728 postcss$1.atRule;
18729 postcss$1.rule;
18730 postcss$1.decl;
18731 postcss$1.root;
18732 postcss$1.CssSyntaxError;
18733 postcss$1.Declaration;
18734 postcss$1.Container;
18735 postcss$1.Processor;
18736 postcss$1.Document;
18737 postcss$1.Comment;
18738 postcss$1.Warning;
18739 postcss$1.AtRule;
18740 postcss$1.Result;
18741 postcss$1.Input;
18742 postcss$1.Rule;
18743 postcss$1.Root;
18744 postcss$1.Node;
18745 var BaseRRNode = /*#__PURE__*/ function() {
18746 function BaseRRNode() {
18747 for(var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++){
18748 _args[_key] = arguments[_key];
18749 }
18750 __publicField2(this, "parentElement", null);
18751 __publicField2(this, "parentNode", null);
18752 __publicField2(this, "ownerDocument");
18753 __publicField2(this, "firstChild", null);
18754 __publicField2(this, "lastChild", null);
18755 __publicField2(this, "previousSibling", null);
18756 __publicField2(this, "nextSibling", null);
18757 __publicField2(this, "ELEMENT_NODE", 1);
18758 __publicField2(this, "TEXT_NODE", 3);
18759 __publicField2(this, "nodeType");
18760 __publicField2(this, "nodeName");
18761 __publicField2(this, "RRNodeType");
18762 }
18763 var _proto = BaseRRNode.prototype;
18764 _proto.contains = function contains(node2) {
18765 if (!_instanceof(node2, BaseRRNode)) return false;
18766 else if (node2.ownerDocument !== this.ownerDocument) return false;
18767 else if (node2 === this) return true;
18768 while(node2.parentNode){
18769 if (node2.parentNode === this) return true;
18770 node2 = node2.parentNode;
18771 }
18772 return false;
18773 };
18774 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18775 _proto.appendChild = function appendChild(_newChild) {
18776 throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.");
18777 };
18778 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18779 _proto.insertBefore = function insertBefore(_newChild, _refChild) {
18780 throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.");
18781 };
18782 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18783 _proto.removeChild = function removeChild(_node) {
18784 throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.");
18785 };
18786 _proto.toString = function toString() {
18787 return "RRNode";
18788 };
18789 _create_class(BaseRRNode, [
18790 {
18791 key: "childNodes",
18792 get: function get() {
18793 var childNodes2 = [];
18794 var childIterator = this.firstChild;
18795 while(childIterator){
18796 childNodes2.push(childIterator);
18797 childIterator = childIterator.nextSibling;
18798 }
18799 return childNodes2;
18800 }
18801 }
18802 ]);
18803 return BaseRRNode;
18804 }();
18805 var testableAccessors = {
18806 Node: [
18807 "childNodes",
18808 "parentNode",
18809 "parentElement",
18810 "textContent"
18811 ],
18812 ShadowRoot: [
18813 "host",
18814 "styleSheets"
18815 ],
18816 Element: [
18817 "shadowRoot",
18818 "querySelector",
18819 "querySelectorAll"
18820 ],
18821 MutationObserver: []
18822 };
18823 var testableMethods = {
18824 Node: [
18825 "contains",
18826 "getRootNode"
18827 ],
18828 ShadowRoot: [
18829 "getSelection"
18830 ],
18831 Element: [],
18832 MutationObserver: [
18833 "constructor"
18834 ]
18835 };
18836 var untaintedBasePrototype = {};
18837 var isAngularZonePresent = function() {
18838 return !!globalThis.Zone;
18839 };
18840 function getUntaintedPrototype(key) {
18841 if (untaintedBasePrototype[key]) return untaintedBasePrototype[key];
18842 var defaultObj = globalThis[key];
18843 var defaultPrototype = defaultObj.prototype;
18844 var accessorNames = key in testableAccessors ? testableAccessors[key] : void 0;
18845 var isUntaintedAccessors = Boolean(accessorNames && // @ts-expect-error 2345
18846 accessorNames.every(function(accessor) {
18847 var _a2, _b;
18848 return Boolean((_b = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b.toString().includes("[native code]"));
18849 }));
18850 var methodNames = key in testableMethods ? testableMethods[key] : void 0;
18851 var isUntaintedMethods = Boolean(methodNames && methodNames.every(// @ts-expect-error 2345
18852 function(method) {
18853 var _a2;
18854 return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
18855 }));
18856 if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent()) {
18857 untaintedBasePrototype[key] = defaultObj.prototype;
18858 return defaultObj.prototype;
18859 }
18860 try {
18861 var iframeEl = document.createElement("iframe");
18862 document.body.appendChild(iframeEl);
18863 var win = iframeEl.contentWindow;
18864 if (!win) return defaultObj.prototype;
18865 var untaintedObject = win[key].prototype;
18866 document.body.removeChild(iframeEl);
18867 if (!untaintedObject) return defaultPrototype;
18868 return untaintedBasePrototype[key] = untaintedObject;
18869 } catch (e) {
18870 return defaultPrototype;
18871 }
18872 }
18873 var untaintedAccessorCache = {};
18874 function getUntaintedAccessor(key, instance, accessor) {
18875 var _a2;
18876 var cacheKey = key + "." + String(accessor);
18877 if (untaintedAccessorCache[cacheKey]) return untaintedAccessorCache[cacheKey].call(instance);
18878 var untaintedPrototype = getUntaintedPrototype(key);
18879 var untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(untaintedPrototype, accessor)) == null ? void 0 : _a2.get;
18880 if (!untaintedAccessor) return instance[accessor];
18881 untaintedAccessorCache[cacheKey] = untaintedAccessor;
18882 return untaintedAccessor.call(instance);
18883 }
18884 var untaintedMethodCache = {};
18885 function getUntaintedMethod(key, instance, method) {
18886 var cacheKey = key + "." + String(method);
18887 if (untaintedMethodCache[cacheKey]) return untaintedMethodCache[cacheKey].bind(instance);
18888 var untaintedPrototype = getUntaintedPrototype(key);
18889 var untaintedMethod = untaintedPrototype[method];
18890 if (typeof untaintedMethod !== "function") return instance[method];
18891 untaintedMethodCache[cacheKey] = untaintedMethod;
18892 return untaintedMethod.bind(instance);
18893 }
18894 function childNodes(n2) {
18895 return getUntaintedAccessor("Node", n2, "childNodes");
18896 }
18897 function parentNode(n2) {
18898 return getUntaintedAccessor("Node", n2, "parentNode");
18899 }
18900 function parentElement(n2) {
18901 return getUntaintedAccessor("Node", n2, "parentElement");
18902 }
18903 function textContent(n2) {
18904 return getUntaintedAccessor("Node", n2, "textContent");
18905 }
18906 function contains(n2, other) {
18907 return getUntaintedMethod("Node", n2, "contains")(other);
18908 }
18909 function getRootNode(n2) {
18910 return getUntaintedMethod("Node", n2, "getRootNode")();
18911 }
18912 function host(n2) {
18913 if (!n2 || !("host" in n2)) return null;
18914 return getUntaintedAccessor("ShadowRoot", n2, "host");
18915 }
18916 function styleSheets(n2) {
18917 return n2.styleSheets;
18918 }
18919 function shadowRoot(n2) {
18920 if (!n2 || !("shadowRoot" in n2)) return null;
18921 return getUntaintedAccessor("Element", n2, "shadowRoot");
18922 }
18923 function querySelector(n2, selectors) {
18924 return getUntaintedAccessor("Element", n2, "querySelector")(selectors);
18925 }
18926 function querySelectorAll(n2, selectors) {
18927 return getUntaintedAccessor("Element", n2, "querySelectorAll")(selectors);
18928 }
18929 function mutationObserverCtor() {
18930 return getUntaintedPrototype("MutationObserver").constructor;
18931 }
18932 function patch(source, name, replacement) {
18933 try {
18934 if (!(name in source)) {
18935 return function() {};
18936 }
18937 var original = source[name];
18938 var wrapped = replacement(original);
18939 if (typeof wrapped === "function") {
18940 wrapped.prototype = wrapped.prototype || {};
18941 Object.defineProperties(wrapped, {
18942 __rrweb_original__: {
18943 enumerable: false,
18944 value: original
18945 }
18946 });
18947 }
18948 source[name] = wrapped;
18949 return function() {
18950 source[name] = original;
18951 };
18952 } catch (e) {
18953 return function() {};
18954 }
18955 }
18956 var index = {
18957 childNodes: childNodes,
18958 parentNode: parentNode,
18959 parentElement: parentElement,
18960 textContent: textContent,
18961 contains: contains,
18962 getRootNode: getRootNode,
18963 host: host,
18964 styleSheets: styleSheets,
18965 shadowRoot: shadowRoot,
18966 querySelector: querySelector,
18967 querySelectorAll: querySelectorAll,
18968 mutationObserver: mutationObserverCtor,
18969 patch: patch
18970 };
18971 function on(type, fn, target) {
18972 if (target === void 0) target = document;
18973 var options = {
18974 capture: true,
18975 passive: true
18976 };
18977 target.addEventListener(type, fn, options);
18978 return function() {
18979 return target.removeEventListener(type, fn, options);
18980 };
18981 }
18982 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.";
18983 var _mirror = {
18984 map: {},
18985 getId: function getId() {
18986 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18987 return -1;
18988 },
18989 getNode: function getNode() {
18990 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18991 return null;
18992 },
18993 removeNodeFromMap: function removeNodeFromMap() {
18994 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18995 },
18996 has: function has() {
18997 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18998 return false;
18999 },
19000 reset: function reset() {
19001 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
19002 }
19003 };
19004 if (typeof window !== "undefined" && window.Proxy && window.Reflect) {
19005 _mirror = new Proxy(_mirror, {
19006 get: function get(target, prop, receiver) {
19007 if (prop === "map") {
19008 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
19009 }
19010 return Reflect.get(target, prop, receiver);
19011 }
19012 });
19013 }
19014 function throttle(func, wait, options) {
19015 if (options === void 0) options = {};
19016 var timeout = null;
19017 var previous = 0;
19018 return function() {
19019 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
19020 args[_key] = arguments[_key];
19021 }
19022 var now = Date.now();
19023 if (!previous && options.leading === false) {
19024 previous = now;
19025 }
19026 var remaining = wait - (now - previous);
19027 var context = this;
19028 if (remaining <= 0 || remaining > wait) {
19029 if (timeout) {
19030 clearTimeout(timeout);
19031 timeout = null;
19032 }
19033 previous = now;
19034 func.apply(context, args);
19035 } else if (!timeout && options.trailing !== false) {
19036 timeout = setTimeout(function() {
19037 previous = options.leading === false ? 0 : Date.now();
19038 timeout = null;
19039 func.apply(context, args);
19040 }, remaining);
19041 }
19042 };
19043 }
19044 function hookSetter(target, key, d, isRevoked, win) {
19045 if (win === void 0) win = window;
19046 var original = win.Object.getOwnPropertyDescriptor(target, key);
19047 win.Object.defineProperty(target, key, isRevoked ? d : {
19048 set: function set(value) {
19049 var _this = this;
19050 setTimeout(function() {
19051 d.set.call(_this, value);
19052 }, 0);
19053 if (original && original.set) {
19054 original.set.call(this, value);
19055 }
19056 }
19057 });
19058 return function() {
19059 return hookSetter(target, key, original || {}, true);
19060 };
19061 }
19062 var nowTimestamp = Date.now;
19063 if (!/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())) {
19064 nowTimestamp = function() {
19065 return /* @__PURE__ */ new Date().getTime();
19066 };
19067 }
19068 function getWindowScroll(win) {
19069 var _a2, _b, _c, _d;
19070 var doc = win.document;
19071 return {
19072 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,
19073 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
19074 };
19075 }
19076 function getWindowHeight() {
19077 return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body && document.body.clientHeight;
19078 }
19079 function getWindowWidth() {
19080 return window.innerWidth || document.documentElement && document.documentElement.clientWidth || document.body && document.body.clientWidth;
19081 }
19082 function closestElementOfNode(node2) {
19083 if (!node2) {
19084 return null;
19085 }
19086 var el = node2.nodeType === node2.ELEMENT_NODE ? node2 : index.parentElement(node2);
19087 return el;
19088 }
19089 function isBlocked(node2, blockClass, blockSelector, checkAncestors) {
19090 if (!node2) {
19091 return false;
19092 }
19093 var el = closestElementOfNode(node2);
19094 if (!el) {
19095 return false;
19096 }
19097 try {
19098 if (typeof blockClass === "string") {
19099 if (el.classList.contains(blockClass)) return true;
19100 if (checkAncestors && el.closest("." + blockClass) !== null) return true;
19101 } else {
19102 if (classMatchesRegex(el, blockClass, checkAncestors)) return true;
19103 }
19104 } catch (e2) {}
19105 if (blockSelector) {
19106 if (el.matches(blockSelector)) return true;
19107 if (checkAncestors && el.closest(blockSelector) !== null) return true;
19108 }
19109 return false;
19110 }
19111 function isSerialized(n2, mirror2) {
19112 return mirror2.getId(n2) !== -1;
19113 }
19114 function isIgnored(n2, mirror2, slimDOMOptions) {
19115 if (n2.tagName === "TITLE" && slimDOMOptions.headTitleMutations) {
19116 return true;
19117 }
19118 return mirror2.getId(n2) === IGNORED_NODE;
19119 }
19120 function isAncestorRemoved(target, mirror2) {
19121 if (isShadowRoot(target)) {
19122 return false;
19123 }
19124 var id = mirror2.getId(target);
19125 if (!mirror2.has(id)) {
19126 return true;
19127 }
19128 var parent = index.parentNode(target);
19129 if (parent && parent.nodeType === target.DOCUMENT_NODE) {
19130 return false;
19131 }
19132 if (!parent) {
19133 return true;
19134 }
19135 return isAncestorRemoved(parent, mirror2);
19136 }
19137 function legacy_isTouchEvent(event) {
19138 return Boolean(event.changedTouches);
19139 }
19140 function polyfill$1(win) {
19141 if (win === void 0) win = window;
19142 if ("NodeList" in win && !win.NodeList.prototype.forEach) {
19143 win.NodeList.prototype.forEach = Array.prototype.forEach;
19144 }
19145 if ("DOMTokenList" in win && !win.DOMTokenList.prototype.forEach) {
19146 win.DOMTokenList.prototype.forEach = Array.prototype.forEach;
19147 }
19148 }
19149 function isSerializedIframe(n2, mirror2) {
19150 return Boolean(n2.nodeName === "IFRAME" && mirror2.getMeta(n2));
19151 }
19152 function isSerializedStylesheet(n2, mirror2) {
19153 return Boolean(n2.nodeName === "LINK" && n2.nodeType === n2.ELEMENT_NODE && n2.getAttribute && n2.getAttribute("rel") === "stylesheet" && mirror2.getMeta(n2));
19154 }
19155 function hasShadowRoot(n2) {
19156 if (!n2) return false;
19157 if (_instanceof(n2, BaseRRNode) && "shadowRoot" in n2) {
19158 return Boolean(n2.shadowRoot);
19159 }
19160 return Boolean(index.shadowRoot(n2));
19161 }
19162 var StyleSheetMirror = /*#__PURE__*/ function() {
19163 function StyleSheetMirror() {
19164 __publicField(this, "id", 1);
19165 __publicField(this, "styleIDMap", /* @__PURE__ */ new WeakMap());
19166 __publicField(this, "idStyleMap", /* @__PURE__ */ new Map());
19167 }
19168 var _proto = StyleSheetMirror.prototype;
19169 _proto.getId = function getId(stylesheet) {
19170 var _this_styleIDMap_get;
19171 return (_this_styleIDMap_get = this.styleIDMap.get(stylesheet)) != null ? _this_styleIDMap_get : -1;
19172 };
19173 _proto.has = function has(stylesheet) {
19174 return this.styleIDMap.has(stylesheet);
19175 };
19176 /**
19177 * @returns If the stylesheet is in the mirror, returns the id of the stylesheet. If not, return the new assigned id.
19178 */ _proto.add = function add(stylesheet, id) {
19179 if (this.has(stylesheet)) return this.getId(stylesheet);
19180 var newId;
19181 if (id === void 0) {
19182 newId = this.id++;
19183 } else newId = id;
19184 this.styleIDMap.set(stylesheet, newId);
19185 this.idStyleMap.set(newId, stylesheet);
19186 return newId;
19187 };
19188 _proto.getStyle = function getStyle(id) {
19189 return this.idStyleMap.get(id) || null;
19190 };
19191 _proto.reset = function reset() {
19192 this.styleIDMap = /* @__PURE__ */ new WeakMap();
19193 this.idStyleMap = /* @__PURE__ */ new Map();
19194 this.id = 1;
19195 };
19196 _proto.generateId = function generateId() {
19197 return this.id++;
19198 };
19199 return StyleSheetMirror;
19200 }();
19201 function getShadowHost(n2) {
19202 var _a2;
19203 var shadowHost = null;
19204 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));
19205 return shadowHost;
19206 }
19207 function getRootShadowHost(n2) {
19208 var rootShadowHost = n2;
19209 var shadowHost;
19210 while(shadowHost = getShadowHost(rootShadowHost))rootShadowHost = shadowHost;
19211 return rootShadowHost;
19212 }
19213 function shadowHostInDom(n2) {
19214 var doc = n2.ownerDocument;
19215 if (!doc) return false;
19216 var shadowHost = getRootShadowHost(n2);
19217 return index.contains(doc, shadowHost);
19218 }
19219 function inDom(n2) {
19220 var doc = n2.ownerDocument;
19221 if (!doc) return false;
19222 return index.contains(doc, n2) || shadowHostInDom(n2);
19223 }
19224 var EventType = /* @__PURE__ */ function(EventType2) {
19225 EventType2[EventType2["DomContentLoaded"] = 0] = "DomContentLoaded";
19226 EventType2[EventType2["Load"] = 1] = "Load";
19227 EventType2[EventType2["FullSnapshot"] = 2] = "FullSnapshot";
19228 EventType2[EventType2["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
19229 EventType2[EventType2["Meta"] = 4] = "Meta";
19230 EventType2[EventType2["Custom"] = 5] = "Custom";
19231 EventType2[EventType2["Plugin"] = 6] = "Plugin";
19232 return EventType2;
19233 }(EventType || {});
19234 var IncrementalSource = /* @__PURE__ */ function(IncrementalSource2) {
19235 IncrementalSource2[IncrementalSource2["Mutation"] = 0] = "Mutation";
19236 IncrementalSource2[IncrementalSource2["MouseMove"] = 1] = "MouseMove";
19237 IncrementalSource2[IncrementalSource2["MouseInteraction"] = 2] = "MouseInteraction";
19238 IncrementalSource2[IncrementalSource2["Scroll"] = 3] = "Scroll";
19239 IncrementalSource2[IncrementalSource2["ViewportResize"] = 4] = "ViewportResize";
19240 IncrementalSource2[IncrementalSource2["Input"] = 5] = "Input";
19241 IncrementalSource2[IncrementalSource2["TouchMove"] = 6] = "TouchMove";
19242 IncrementalSource2[IncrementalSource2["MediaInteraction"] = 7] = "MediaInteraction";
19243 IncrementalSource2[IncrementalSource2["StyleSheetRule"] = 8] = "StyleSheetRule";
19244 IncrementalSource2[IncrementalSource2["CanvasMutation"] = 9] = "CanvasMutation";
19245 IncrementalSource2[IncrementalSource2["Font"] = 10] = "Font";
19246 IncrementalSource2[IncrementalSource2["Log"] = 11] = "Log";
19247 IncrementalSource2[IncrementalSource2["Drag"] = 12] = "Drag";
19248 IncrementalSource2[IncrementalSource2["StyleDeclaration"] = 13] = "StyleDeclaration";
19249 IncrementalSource2[IncrementalSource2["Selection"] = 14] = "Selection";
19250 IncrementalSource2[IncrementalSource2["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
19251 IncrementalSource2[IncrementalSource2["CustomElement"] = 16] = "CustomElement";
19252 return IncrementalSource2;
19253 }(IncrementalSource || {});
19254 var MouseInteractions = /* @__PURE__ */ function(MouseInteractions2) {
19255 MouseInteractions2[MouseInteractions2["MouseUp"] = 0] = "MouseUp";
19256 MouseInteractions2[MouseInteractions2["MouseDown"] = 1] = "MouseDown";
19257 MouseInteractions2[MouseInteractions2["Click"] = 2] = "Click";
19258 MouseInteractions2[MouseInteractions2["ContextMenu"] = 3] = "ContextMenu";
19259 MouseInteractions2[MouseInteractions2["DblClick"] = 4] = "DblClick";
19260 MouseInteractions2[MouseInteractions2["Focus"] = 5] = "Focus";
19261 MouseInteractions2[MouseInteractions2["Blur"] = 6] = "Blur";
19262 MouseInteractions2[MouseInteractions2["TouchStart"] = 7] = "TouchStart";
19263 MouseInteractions2[MouseInteractions2["TouchMove_Departed"] = 8] = "TouchMove_Departed";
19264 MouseInteractions2[MouseInteractions2["TouchEnd"] = 9] = "TouchEnd";
19265 MouseInteractions2[MouseInteractions2["TouchCancel"] = 10] = "TouchCancel";
19266 return MouseInteractions2;
19267 }(MouseInteractions || {});
19268 var PointerTypes = /* @__PURE__ */ function(PointerTypes2) {
19269 PointerTypes2[PointerTypes2["Mouse"] = 0] = "Mouse";
19270 PointerTypes2[PointerTypes2["Pen"] = 1] = "Pen";
19271 PointerTypes2[PointerTypes2["Touch"] = 2] = "Touch";
19272 return PointerTypes2;
19273 }(PointerTypes || {});
19274 var CanvasContext = /* @__PURE__ */ function(CanvasContext2) {
19275 CanvasContext2[CanvasContext2["2D"] = 0] = "2D";
19276 CanvasContext2[CanvasContext2["WebGL"] = 1] = "WebGL";
19277 CanvasContext2[CanvasContext2["WebGL2"] = 2] = "WebGL2";
19278 return CanvasContext2;
19279 }(CanvasContext || {});
19280 var MediaInteractions = /* @__PURE__ */ function(MediaInteractions2) {
19281 MediaInteractions2[MediaInteractions2["Play"] = 0] = "Play";
19282 MediaInteractions2[MediaInteractions2["Pause"] = 1] = "Pause";
19283 MediaInteractions2[MediaInteractions2["Seeked"] = 2] = "Seeked";
19284 MediaInteractions2[MediaInteractions2["VolumeChange"] = 3] = "VolumeChange";
19285 MediaInteractions2[MediaInteractions2["RateChange"] = 4] = "RateChange";
19286 return MediaInteractions2;
19287 }(MediaInteractions || {});
19288 var NodeType = /* @__PURE__ */ function(NodeType2) {
19289 NodeType2[NodeType2["Document"] = 0] = "Document";
19290 NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
19291 NodeType2[NodeType2["Element"] = 2] = "Element";
19292 NodeType2[NodeType2["Text"] = 3] = "Text";
19293 NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
19294 NodeType2[NodeType2["Comment"] = 5] = "Comment";
19295 return NodeType2;
19296 }(NodeType || {});
19297 function isNodeInLinkedList(n2) {
19298 return "__ln" in n2;
19299 }
19300 var DoubleLinkedList = /*#__PURE__*/ function() {
19301 function DoubleLinkedList() {
19302 __publicField(this, "length", 0);
19303 __publicField(this, "head", null);
19304 __publicField(this, "tail", null);
19305 }
19306 var _proto = DoubleLinkedList.prototype;
19307 _proto.get = function get(position) {
19308 if (position >= this.length) {
19309 throw new Error("Position outside of list range");
19310 }
19311 var current = this.head;
19312 for(var index2 = 0; index2 < position; index2++){
19313 current = (current == null ? void 0 : current.next) || null;
19314 }
19315 return current;
19316 };
19317 _proto.addNode = function addNode(n2) {
19318 var node2 = {
19319 value: n2,
19320 previous: null,
19321 next: null
19322 };
19323 n2.__ln = node2;
19324 if (n2.previousSibling && isNodeInLinkedList(n2.previousSibling)) {
19325 var current = n2.previousSibling.__ln.next;
19326 node2.next = current;
19327 node2.previous = n2.previousSibling.__ln;
19328 n2.previousSibling.__ln.next = node2;
19329 if (current) {
19330 current.previous = node2;
19331 }
19332 } else if (n2.nextSibling && isNodeInLinkedList(n2.nextSibling) && n2.nextSibling.__ln.previous) {
19333 var current1 = n2.nextSibling.__ln.previous;
19334 node2.previous = current1;
19335 node2.next = n2.nextSibling.__ln;
19336 n2.nextSibling.__ln.previous = node2;
19337 if (current1) {
19338 current1.next = node2;
19339 }
19340 } else {
19341 if (this.head) {
19342 this.head.previous = node2;
19343 }
19344 node2.next = this.head;
19345 this.head = node2;
19346 }
19347 if (node2.next === null) {
19348 this.tail = node2;
19349 }
19350 this.length++;
19351 };
19352 _proto.removeNode = function removeNode(n2) {
19353 var current = n2.__ln;
19354 if (!this.head) {
19355 return;
19356 }
19357 if (!current.previous) {
19358 this.head = current.next;
19359 if (this.head) {
19360 this.head.previous = null;
19361 } else {
19362 this.tail = null;
19363 }
19364 } else {
19365 current.previous.next = current.next;
19366 if (current.next) {
19367 current.next.previous = current.previous;
19368 } else {
19369 this.tail = current.previous;
19370 }
19371 }
19372 if (n2.__ln) {
19373 delete n2.__ln;
19374 }
19375 this.length--;
19376 };
19377 return DoubleLinkedList;
19378 }();
19379 var moveKey = function(id, parentId) {
19380 return id + "@" + parentId;
19381 };
19382 var MutationBuffer = /*#__PURE__*/ function() {
19383 function MutationBuffer() {
19384 var _this = this;
19385 __publicField(this, "frozen", false);
19386 __publicField(this, "locked", false);
19387 __publicField(this, "texts", []);
19388 __publicField(this, "attributes", []);
19389 __publicField(this, "attributeMap", /* @__PURE__ */ new WeakMap());
19390 __publicField(this, "removes", []);
19391 __publicField(this, "mapRemoves", []);
19392 __publicField(this, "movedMap", {});
19393 /**
19394 * the browser MutationObserver emits multiple mutations after
19395 * a delay for performance reasons, making tracing added nodes hard
19396 * in our `processMutations` callback function.
19397 * For example, if we append an element el_1 into body, and then append
19398 * another element el_2 into el_1, these two mutations may be passed to the
19399 * callback function together when the two operations were done.
19400 * Generally we need to trace child nodes of newly added nodes, but in this
19401 * case if we count el_2 as el_1's child node in the first mutation record,
19402 * then we will count el_2 again in the second mutation record which was
19403 * duplicated.
19404 * To avoid of duplicate counting added nodes, we use a Set to store
19405 * added nodes and its child nodes during iterate mutation records. Then
19406 * collect added nodes from the Set which have no duplicate copy. But
19407 * this also causes newly added nodes will not be serialized with id ASAP,
19408 * which means all the id related calculation should be lazy too.
19409 */ __publicField(this, "addedSet", /* @__PURE__ */ new Set());
19410 __publicField(this, "movedSet", /* @__PURE__ */ new Set());
19411 __publicField(this, "droppedSet", /* @__PURE__ */ new Set());
19412 __publicField(this, "removesSubTreeCache", /* @__PURE__ */ new Set());
19413 __publicField(this, "mutationCb");
19414 __publicField(this, "blockClass");
19415 __publicField(this, "blockSelector");
19416 __publicField(this, "maskTextClass");
19417 __publicField(this, "maskTextSelector");
19418 __publicField(this, "inlineStylesheet");
19419 __publicField(this, "maskInputOptions");
19420 __publicField(this, "maskTextFn");
19421 __publicField(this, "maskInputFn");
19422 __publicField(this, "keepIframeSrcFn");
19423 __publicField(this, "recordCanvas");
19424 __publicField(this, "inlineImages");
19425 __publicField(this, "slimDOMOptions");
19426 __publicField(this, "dataURLOptions");
19427 __publicField(this, "doc");
19428 __publicField(this, "mirror");
19429 __publicField(this, "iframeManager");
19430 __publicField(this, "stylesheetManager");
19431 __publicField(this, "shadowDomManager");
19432 __publicField(this, "canvasManager");
19433 __publicField(this, "processedNodeManager");
19434 __publicField(this, "unattachedDoc");
19435 __publicField(this, "processMutations", function(mutations) {
19436 mutations.forEach(_this.processMutation);
19437 _this.emit();
19438 });
19439 __publicField(this, "emit", function() {
19440 if (_this.frozen || _this.locked) {
19441 return;
19442 }
19443 var adds = [];
19444 var addedIds = /* @__PURE__ */ new Set();
19445 var addList = new DoubleLinkedList();
19446 var getNextId = function(n2) {
19447 var ns = n2;
19448 var nextId = IGNORED_NODE;
19449 while(nextId === IGNORED_NODE){
19450 ns = ns && ns.nextSibling;
19451 nextId = ns && _this.mirror.getId(ns);
19452 }
19453 return nextId;
19454 };
19455 var pushAdd = function(n2) {
19456 var parent = index.parentNode(n2);
19457 if (!parent || !inDom(n2)) {
19458 return;
19459 }
19460 var cssCaptured = false;
19461 if (n2.nodeType === Node.TEXT_NODE) {
19462 var parentTag = parent.tagName;
19463 if (parentTag === "TEXTAREA") {
19464 return;
19465 } else if (parentTag === "STYLE" && _this.addedSet.has(parent)) {
19466 cssCaptured = true;
19467 }
19468 }
19469 var parentId = isShadowRoot(parent) ? _this.mirror.getId(getShadowHost(n2)) : _this.mirror.getId(parent);
19470 var nextId = getNextId(n2);
19471 if (parentId === -1 || nextId === -1) {
19472 return addList.addNode(n2);
19473 }
19474 var sn = serializeNodeWithId(n2, {
19475 doc: _this.doc,
19476 mirror: _this.mirror,
19477 blockClass: _this.blockClass,
19478 blockSelector: _this.blockSelector,
19479 maskTextClass: _this.maskTextClass,
19480 maskTextSelector: _this.maskTextSelector,
19481 skipChild: true,
19482 newlyAddedElement: true,
19483 inlineStylesheet: _this.inlineStylesheet,
19484 maskInputOptions: _this.maskInputOptions,
19485 maskTextFn: _this.maskTextFn,
19486 maskInputFn: _this.maskInputFn,
19487 slimDOMOptions: _this.slimDOMOptions,
19488 dataURLOptions: _this.dataURLOptions,
19489 recordCanvas: _this.recordCanvas,
19490 inlineImages: _this.inlineImages,
19491 onSerialize: function(currentN) {
19492 if (isSerializedIframe(currentN, _this.mirror)) {
19493 _this.iframeManager.addIframe(currentN);
19494 }
19495 if (isSerializedStylesheet(currentN, _this.mirror)) {
19496 _this.stylesheetManager.trackLinkElement(currentN);
19497 }
19498 if (hasShadowRoot(n2)) {
19499 _this.shadowDomManager.addShadowRoot(index.shadowRoot(n2), _this.doc);
19500 }
19501 },
19502 onIframeLoad: function(iframe, childSn) {
19503 _this.iframeManager.attachIframe(iframe, childSn);
19504 _this.shadowDomManager.observeAttachShadow(iframe);
19505 },
19506 onStylesheetLoad: function(link, childSn) {
19507 _this.stylesheetManager.attachLinkElement(link, childSn);
19508 },
19509 cssCaptured: cssCaptured
19510 });
19511 if (sn) {
19512 adds.push({
19513 parentId: parentId,
19514 nextId: nextId,
19515 node: sn
19516 });
19517 addedIds.add(sn.id);
19518 }
19519 };
19520 while(_this.mapRemoves.length){
19521 _this.mirror.removeNodeFromMap(_this.mapRemoves.shift());
19522 }
19523 for(var _iterator = _create_for_of_iterator_helper_loose(_this.movedSet), _step; !(_step = _iterator()).done;){
19524 var n2 = _step.value;
19525 if (isParentRemoved(_this.removesSubTreeCache, n2, _this.mirror) && !_this.movedSet.has(index.parentNode(n2))) {
19526 continue;
19527 }
19528 pushAdd(n2);
19529 }
19530 for(var _iterator1 = _create_for_of_iterator_helper_loose(_this.addedSet), _step1; !(_step1 = _iterator1()).done;){
19531 var n21 = _step1.value;
19532 if (!isAncestorInSet(_this.droppedSet, n21) && !isParentRemoved(_this.removesSubTreeCache, n21, _this.mirror)) {
19533 pushAdd(n21);
19534 } else if (isAncestorInSet(_this.movedSet, n21)) {
19535 pushAdd(n21);
19536 } else {
19537 _this.droppedSet.add(n21);
19538 }
19539 }
19540 var candidate = null;
19541 while(addList.length){
19542 var node2 = null;
19543 if (candidate) {
19544 var parentId = _this.mirror.getId(index.parentNode(candidate.value));
19545 var nextId = getNextId(candidate.value);
19546 if (parentId !== -1 && nextId !== -1) {
19547 node2 = candidate;
19548 }
19549 }
19550 if (!node2) {
19551 var tailNode = addList.tail;
19552 while(tailNode){
19553 var _node = tailNode;
19554 tailNode = tailNode.previous;
19555 if (_node) {
19556 var parentId1 = _this.mirror.getId(index.parentNode(_node.value));
19557 var nextId1 = getNextId(_node.value);
19558 if (nextId1 === -1) continue;
19559 else if (parentId1 !== -1) {
19560 node2 = _node;
19561 break;
19562 } else {
19563 var unhandledNode = _node.value;
19564 var parent = index.parentNode(unhandledNode);
19565 if (parent && parent.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
19566 var shadowHost = index.host(parent);
19567 var parentId2 = _this.mirror.getId(shadowHost);
19568 if (parentId2 !== -1) {
19569 node2 = _node;
19570 break;
19571 }
19572 }
19573 }
19574 }
19575 }
19576 }
19577 if (!node2) {
19578 while(addList.head){
19579 addList.removeNode(addList.head.value);
19580 }
19581 break;
19582 }
19583 candidate = node2.previous;
19584 addList.removeNode(node2.value);
19585 pushAdd(node2.value);
19586 }
19587 var payload = {
19588 texts: _this.texts.map(function(text) {
19589 var n2 = text.node;
19590 var parent = index.parentNode(n2);
19591 if (parent && parent.tagName === "TEXTAREA") {
19592 _this.genTextAreaValueMutation(parent);
19593 }
19594 return {
19595 id: _this.mirror.getId(n2),
19596 value: text.value
19597 };
19598 }).filter(function(text) {
19599 return !addedIds.has(text.id);
19600 }).filter(function(text) {
19601 return _this.mirror.has(text.id);
19602 }),
19603 attributes: _this.attributes.map(function(attribute) {
19604 var attributes = attribute.attributes;
19605 if (typeof attributes.style === "string") {
19606 var diffAsStr = JSON.stringify(attribute.styleDiff);
19607 var unchangedAsStr = JSON.stringify(attribute._unchangedStyles);
19608 if (diffAsStr.length < attributes.style.length) {
19609 if ((diffAsStr + unchangedAsStr).split("var(").length === attributes.style.split("var(").length) {
19610 attributes.style = attribute.styleDiff;
19611 }
19612 }
19613 }
19614 return {
19615 id: _this.mirror.getId(attribute.node),
19616 attributes: attributes
19617 };
19618 }).filter(function(attribute) {
19619 return !addedIds.has(attribute.id);
19620 }).filter(function(attribute) {
19621 return _this.mirror.has(attribute.id);
19622 }),
19623 removes: _this.removes,
19624 adds: adds
19625 };
19626 if (!payload.texts.length && !payload.attributes.length && !payload.removes.length && !payload.adds.length) {
19627 return;
19628 }
19629 _this.texts = [];
19630 _this.attributes = [];
19631 _this.attributeMap = /* @__PURE__ */ new WeakMap();
19632 _this.removes = [];
19633 _this.addedSet = /* @__PURE__ */ new Set();
19634 _this.movedSet = /* @__PURE__ */ new Set();
19635 _this.droppedSet = /* @__PURE__ */ new Set();
19636 _this.removesSubTreeCache = /* @__PURE__ */ new Set();
19637 _this.movedMap = {};
19638 _this.mutationCb(payload);
19639 });
19640 __publicField(this, "genTextAreaValueMutation", function(textarea) {
19641 var item = _this.attributeMap.get(textarea);
19642 if (!item) {
19643 item = {
19644 node: textarea,
19645 attributes: {},
19646 styleDiff: {},
19647 _unchangedStyles: {}
19648 };
19649 _this.attributes.push(item);
19650 _this.attributeMap.set(textarea, item);
19651 }
19652 var value = Array.from(index.childNodes(textarea), function(cn) {
19653 return index.textContent(cn) || "";
19654 }).join("");
19655 item.attributes.value = maskInputValue({
19656 element: textarea,
19657 maskInputOptions: _this.maskInputOptions,
19658 tagName: textarea.tagName,
19659 type: getInputType(textarea),
19660 value: value,
19661 maskInputFn: _this.maskInputFn
19662 });
19663 });
19664 __publicField(this, "processMutation", function(m) {
19665 if (isIgnored(m.target, _this.mirror, _this.slimDOMOptions)) {
19666 return;
19667 }
19668 switch(m.type){
19669 case "characterData":
19670 {
19671 var value = index.textContent(m.target);
19672 if (!isBlocked(m.target, _this.blockClass, _this.blockSelector, false) && value !== m.oldValue) {
19673 _this.texts.push({
19674 value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector, true) && value ? _this.maskTextFn ? _this.maskTextFn(value, closestElementOfNode(m.target)) : value.replace(/[\S]/g, "*") : value,
19675 node: m.target
19676 });
19677 }
19678 break;
19679 }
19680 case "attributes":
19681 {
19682 var target = m.target;
19683 var attributeName = m.attributeName;
19684 var value1 = m.target.getAttribute(attributeName);
19685 if (attributeName === "value") {
19686 var type = getInputType(target);
19687 value1 = maskInputValue({
19688 element: target,
19689 maskInputOptions: _this.maskInputOptions,
19690 tagName: target.tagName,
19691 type: type,
19692 value: value1,
19693 maskInputFn: _this.maskInputFn
19694 });
19695 }
19696 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, false) || value1 === m.oldValue) {
19697 return;
19698 }
19699 var item = _this.attributeMap.get(m.target);
19700 if (target.tagName === "IFRAME" && attributeName === "src" && !_this.keepIframeSrcFn(value1)) {
19701 if (!target.contentDocument) {
19702 attributeName = "rr_src";
19703 } else {
19704 return;
19705 }
19706 }
19707 if (!item) {
19708 item = {
19709 node: m.target,
19710 attributes: {},
19711 styleDiff: {},
19712 _unchangedStyles: {}
19713 };
19714 _this.attributes.push(item);
19715 _this.attributeMap.set(m.target, item);
19716 }
19717 if (attributeName === "type" && target.tagName === "INPUT" && (m.oldValue || "").toLowerCase() === "password") {
19718 target.setAttribute("data-rr-is-password", "true");
19719 }
19720 if (!ignoreAttribute(target.tagName, attributeName)) {
19721 item.attributes[attributeName] = transformAttribute(_this.doc, toLowerCase(target.tagName), toLowerCase(attributeName), value1);
19722 if (attributeName === "style") {
19723 if (!_this.unattachedDoc) {
19724 try {
19725 _this.unattachedDoc = document.implementation.createHTMLDocument();
19726 } catch (e2) {
19727 _this.unattachedDoc = _this.doc;
19728 }
19729 }
19730 var old = _this.unattachedDoc.createElement("span");
19731 if (m.oldValue) {
19732 old.setAttribute("style", m.oldValue);
19733 }
19734 for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(target.style)), _step; !(_step = _iterator()).done;){
19735 var pname = _step.value;
19736 var newValue = target.style.getPropertyValue(pname);
19737 var newPriority = target.style.getPropertyPriority(pname);
19738 if (newValue !== old.style.getPropertyValue(pname) || newPriority !== old.style.getPropertyPriority(pname)) {
19739 if (newPriority === "") {
19740 item.styleDiff[pname] = newValue;
19741 } else {
19742 item.styleDiff[pname] = [
19743 newValue,
19744 newPriority
19745 ];
19746 }
19747 } else {
19748 item._unchangedStyles[pname] = [
19749 newValue,
19750 newPriority
19751 ];
19752 }
19753 }
19754 for(var _iterator1 = _create_for_of_iterator_helper_loose(Array.from(old.style)), _step1; !(_step1 = _iterator1()).done;){
19755 var pname1 = _step1.value;
19756 if (target.style.getPropertyValue(pname1) === "") {
19757 item.styleDiff[pname1] = false;
19758 }
19759 }
19760 } else if (attributeName === "open" && target.tagName === "DIALOG") {
19761 if (target.matches("dialog:modal")) {
19762 item.attributes["rr_open_mode"] = "modal";
19763 } else {
19764 item.attributes["rr_open_mode"] = "non-modal";
19765 }
19766 }
19767 }
19768 break;
19769 }
19770 case "childList":
19771 {
19772 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, true)) return;
19773 if (m.target.tagName === "TEXTAREA") {
19774 _this.genTextAreaValueMutation(m.target);
19775 return;
19776 }
19777 m.addedNodes.forEach(function(n2) {
19778 return _this.genAdds(n2, m.target);
19779 });
19780 m.removedNodes.forEach(function(n2) {
19781 var nodeId = _this.mirror.getId(n2);
19782 var parentId = isShadowRoot(m.target) ? _this.mirror.getId(index.host(m.target)) : _this.mirror.getId(m.target);
19783 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, false) || isIgnored(n2, _this.mirror, _this.slimDOMOptions) || !isSerialized(n2, _this.mirror)) {
19784 return;
19785 }
19786 if (_this.addedSet.has(n2)) {
19787 deepDelete(_this.addedSet, n2);
19788 _this.droppedSet.add(n2);
19789 } else if (_this.addedSet.has(m.target) && nodeId === -1) ;
19790 else if (isAncestorRemoved(m.target, _this.mirror)) ;
19791 else if (_this.movedSet.has(n2) && _this.movedMap[moveKey(nodeId, parentId)]) {
19792 deepDelete(_this.movedSet, n2);
19793 } else {
19794 _this.removes.push({
19795 parentId: parentId,
19796 id: nodeId,
19797 isShadow: isShadowRoot(m.target) && isNativeShadowDom(m.target) ? true : void 0
19798 });
19799 processRemoves(n2, _this.removesSubTreeCache);
19800 }
19801 _this.mapRemoves.push(n2);
19802 });
19803 break;
19804 }
19805 }
19806 });
19807 /**
19808 * Make sure you check if `n`'s parent is blocked before calling this function
19809 * */ __publicField(this, "genAdds", function(n2, target) {
19810 if (_this.processedNodeManager.inOtherBuffer(n2, _this)) return;
19811 if (_this.addedSet.has(n2) || _this.movedSet.has(n2)) return;
19812 if (_this.mirror.hasNode(n2)) {
19813 if (isIgnored(n2, _this.mirror, _this.slimDOMOptions)) {
19814 return;
19815 }
19816 _this.movedSet.add(n2);
19817 var targetId = null;
19818 if (target && _this.mirror.hasNode(target)) {
19819 targetId = _this.mirror.getId(target);
19820 }
19821 if (targetId && targetId !== -1) {
19822 _this.movedMap[moveKey(_this.mirror.getId(n2), targetId)] = true;
19823 }
19824 } else {
19825 _this.addedSet.add(n2);
19826 _this.droppedSet.delete(n2);
19827 }
19828 if (!isBlocked(n2, _this.blockClass, _this.blockSelector, false)) {
19829 index.childNodes(n2).forEach(function(childN) {
19830 return _this.genAdds(childN);
19831 });
19832 if (hasShadowRoot(n2)) {
19833 index.childNodes(index.shadowRoot(n2)).forEach(function(childN) {
19834 _this.processedNodeManager.add(childN, _this);
19835 _this.genAdds(childN, n2);
19836 });
19837 }
19838 }
19839 });
19840 }
19841 var _proto = MutationBuffer.prototype;
19842 _proto.init = function init(options) {
19843 var _this = this;
19844 [
19845 "mutationCb",
19846 "blockClass",
19847 "blockSelector",
19848 "maskTextClass",
19849 "maskTextSelector",
19850 "inlineStylesheet",
19851 "maskInputOptions",
19852 "maskTextFn",
19853 "maskInputFn",
19854 "keepIframeSrcFn",
19855 "recordCanvas",
19856 "inlineImages",
19857 "slimDOMOptions",
19858 "dataURLOptions",
19859 "doc",
19860 "mirror",
19861 "iframeManager",
19862 "stylesheetManager",
19863 "shadowDomManager",
19864 "canvasManager",
19865 "processedNodeManager"
19866 ].forEach(function(key) {
19867 _this[key] = options[key];
19868 });
19869 };
19870 _proto.freeze = function freeze() {
19871 this.frozen = true;
19872 this.canvasManager.freeze();
19873 };
19874 _proto.unfreeze = function unfreeze() {
19875 this.frozen = false;
19876 this.canvasManager.unfreeze();
19877 this.emit();
19878 };
19879 _proto.isFrozen = function isFrozen() {
19880 return this.frozen;
19881 };
19882 _proto.lock = function lock() {
19883 this.locked = true;
19884 this.canvasManager.lock();
19885 };
19886 _proto.unlock = function unlock() {
19887 this.locked = false;
19888 this.canvasManager.unlock();
19889 this.emit();
19890 };
19891 _proto.reset = function reset() {
19892 this.shadowDomManager.reset();
19893 this.canvasManager.reset();
19894 };
19895 return MutationBuffer;
19896 }();
19897 function deepDelete(addsSet, n2) {
19898 addsSet.delete(n2);
19899 index.childNodes(n2).forEach(function(childN) {
19900 return deepDelete(addsSet, childN);
19901 });
19902 }
19903 function processRemoves(n2, cache) {
19904 var queue = [
19905 n2
19906 ];
19907 while(queue.length){
19908 var next = queue.pop();
19909 if (cache.has(next)) continue;
19910 cache.add(next);
19911 index.childNodes(next).forEach(function(n22) {
19912 return queue.push(n22);
19913 });
19914 }
19915 return;
19916 }
19917 function isParentRemoved(removes, n2, mirror2) {
19918 if (removes.size === 0) return false;
19919 return _isParentRemoved(removes, n2);
19920 }
19921 function _isParentRemoved(removes, n2, _mirror2) {
19922 var node2 = index.parentNode(n2);
19923 if (!node2) return false;
19924 return removes.has(node2);
19925 }
19926 function isAncestorInSet(set, n2) {
19927 if (set.size === 0) return false;
19928 return _isAncestorInSet(set, n2);
19929 }
19930 function _isAncestorInSet(set, n2) {
19931 var parent = index.parentNode(n2);
19932 if (!parent) {
19933 return false;
19934 }
19935 if (set.has(parent)) {
19936 return true;
19937 }
19938 return _isAncestorInSet(set, parent);
19939 }
19940 var errorHandler;
19941 function registerErrorHandler(handler) {
19942 errorHandler = handler;
19943 }
19944 function unregisterErrorHandler() {
19945 errorHandler = void 0;
19946 }
19947 var callbackWrapper = function(cb) {
19948 if (!errorHandler) {
19949 return cb;
19950 }
19951 var rrwebWrapped = function() {
19952 for(var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++){
19953 rest[_key] = arguments[_key];
19954 }
19955 try {
19956 return cb.apply(void 0, [].concat(rest));
19957 } catch (error) {
19958 if (errorHandler && errorHandler(error) === true) {
19959 return;
19960 }
19961 throw error;
19962 }
19963 };
19964 return rrwebWrapped;
19965 };
19966 var mutationBuffers = [];
19967 function getEventTarget(event) {
19968 try {
19969 if ("composedPath" in event) {
19970 var path = event.composedPath();
19971 if (path.length) {
19972 return path[0];
19973 }
19974 } else if ("path" in event && event.path.length) {
19975 return event.path[0];
19976 }
19977 } catch (e) {}
19978 return event && event.target;
19979 }
19980 function initMutationObserver(options, rootEl) {
19981 var mutationBuffer = new MutationBuffer();
19982 mutationBuffers.push(mutationBuffer);
19983 mutationBuffer.init(options);
19984 var observer = new (mutationObserverCtor())(callbackWrapper(mutationBuffer.processMutations.bind(mutationBuffer)));
19985 observer.observe(rootEl, {
19986 attributes: true,
19987 attributeOldValue: true,
19988 characterData: true,
19989 characterDataOldValue: true,
19990 childList: true,
19991 subtree: true
19992 });
19993 return observer;
19994 }
19995 function initMoveObserver(param) {
19996 var mousemoveCb = param.mousemoveCb, sampling = param.sampling, doc = param.doc, mirror2 = param.mirror;
19997 if (sampling.mousemove === false) {
19998 return function() {};
19999 }
20000 var threshold = typeof sampling.mousemove === "number" ? sampling.mousemove : 50;
20001 var callbackThreshold = typeof sampling.mousemoveCallback === "number" ? sampling.mousemoveCallback : 500;
20002 var positions = [];
20003 var timeBaseline;
20004 var wrappedCb = throttle(callbackWrapper(function(source) {
20005 var totalOffset = Date.now() - timeBaseline;
20006 mousemoveCb(positions.map(function(p) {
20007 p.timeOffset -= totalOffset;
20008 return p;
20009 }), source);
20010 positions = [];
20011 timeBaseline = null;
20012 }), callbackThreshold);
20013 var updatePosition = callbackWrapper(throttle(callbackWrapper(function(evt) {
20014 var target = getEventTarget(evt);
20015 var _ref = legacy_isTouchEvent(evt) ? evt.changedTouches[0] : evt, clientX = _ref.clientX, clientY = _ref.clientY;
20016 if (!timeBaseline) {
20017 timeBaseline = nowTimestamp();
20018 }
20019 positions.push({
20020 x: clientX,
20021 y: clientY,
20022 id: mirror2.getId(target),
20023 timeOffset: nowTimestamp() - timeBaseline
20024 });
20025 wrappedCb(typeof DragEvent !== "undefined" && _instanceof(evt, DragEvent) ? IncrementalSource.Drag : _instanceof(evt, MouseEvent) ? IncrementalSource.MouseMove : IncrementalSource.TouchMove);
20026 }), threshold, {
20027 trailing: false
20028 }));
20029 var handlers = [
20030 on("mousemove", updatePosition, doc),
20031 on("touchmove", updatePosition, doc),
20032 on("drag", updatePosition, doc)
20033 ];
20034 return callbackWrapper(function() {
20035 handlers.forEach(function(h) {
20036 return h();
20037 });
20038 });
20039 }
20040 function initMouseInteractionObserver(param) {
20041 var mouseInteractionCb = param.mouseInteractionCb, doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, sampling = param.sampling;
20042 if (sampling.mouseInteraction === false) {
20043 return function() {};
20044 }
20045 var disableMap = sampling.mouseInteraction === true || sampling.mouseInteraction === void 0 ? {} : sampling.mouseInteraction;
20046 var handlers = [];
20047 var currentPointerType = null;
20048 var getHandler = function(eventKey) {
20049 return function(event) {
20050 var target = getEventTarget(event);
20051 if (isBlocked(target, blockClass, blockSelector, true)) {
20052 return;
20053 }
20054 var pointerType = null;
20055 var thisEventKey = eventKey;
20056 if ("pointerType" in event) {
20057 switch(event.pointerType){
20058 case "mouse":
20059 pointerType = PointerTypes.Mouse;
20060 break;
20061 case "touch":
20062 pointerType = PointerTypes.Touch;
20063 break;
20064 case "pen":
20065 pointerType = PointerTypes.Pen;
20066 break;
20067 }
20068 if (pointerType === PointerTypes.Touch) {
20069 if (MouseInteractions[eventKey] === MouseInteractions.MouseDown) {
20070 thisEventKey = "TouchStart";
20071 } else if (MouseInteractions[eventKey] === MouseInteractions.MouseUp) {
20072 thisEventKey = "TouchEnd";
20073 }
20074 } else if (pointerType === PointerTypes.Pen) ;
20075 } else if (legacy_isTouchEvent(event)) {
20076 pointerType = PointerTypes.Touch;
20077 }
20078 if (pointerType !== null) {
20079 currentPointerType = pointerType;
20080 if (thisEventKey.startsWith("Touch") && pointerType === PointerTypes.Touch || thisEventKey.startsWith("Mouse") && pointerType === PointerTypes.Mouse) {
20081 pointerType = null;
20082 }
20083 } else if (MouseInteractions[eventKey] === MouseInteractions.Click) {
20084 pointerType = currentPointerType;
20085 currentPointerType = null;
20086 }
20087 var e2 = legacy_isTouchEvent(event) ? event.changedTouches[0] : event;
20088 if (!e2) {
20089 return;
20090 }
20091 var id = mirror2.getId(target);
20092 var clientX = e2.clientX, clientY = e2.clientY;
20093 callbackWrapper(mouseInteractionCb)(_extends({
20094 type: MouseInteractions[thisEventKey],
20095 id: id,
20096 x: clientX,
20097 y: clientY
20098 }, pointerType !== null && {
20099 pointerType: pointerType
20100 }));
20101 };
20102 };
20103 Object.keys(MouseInteractions).filter(function(key) {
20104 return Number.isNaN(Number(key)) && !key.endsWith("_Departed") && disableMap[key] !== false;
20105 }).forEach(function(eventKey) {
20106 var eventName = toLowerCase(eventKey);
20107 var handler = getHandler(eventKey);
20108 if (window.PointerEvent) {
20109 switch(MouseInteractions[eventKey]){
20110 case MouseInteractions.MouseDown:
20111 case MouseInteractions.MouseUp:
20112 eventName = eventName.replace("mouse", "pointer");
20113 break;
20114 case MouseInteractions.TouchStart:
20115 case MouseInteractions.TouchEnd:
20116 return;
20117 }
20118 }
20119 handlers.push(on(eventName, handler, doc));
20120 });
20121 return callbackWrapper(function() {
20122 handlers.forEach(function(h) {
20123 return h();
20124 });
20125 });
20126 }
20127 function initScrollObserver(param) {
20128 var scrollCb = param.scrollCb, doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, sampling = param.sampling;
20129 var updatePosition = callbackWrapper(throttle(callbackWrapper(function(evt) {
20130 var target = getEventTarget(evt);
20131 if (!target || isBlocked(target, blockClass, blockSelector, true)) {
20132 return;
20133 }
20134 var id = mirror2.getId(target);
20135 if (target === doc && doc.defaultView) {
20136 var scrollLeftTop = getWindowScroll(doc.defaultView);
20137 scrollCb({
20138 id: id,
20139 x: scrollLeftTop.left,
20140 y: scrollLeftTop.top
20141 });
20142 } else {
20143 scrollCb({
20144 id: id,
20145 x: target.scrollLeft,
20146 y: target.scrollTop
20147 });
20148 }
20149 }), sampling.scroll || 100));
20150 return on("scroll", updatePosition, doc);
20151 }
20152 function initViewportResizeObserver(param, param1) {
20153 var viewportResizeCb = param.viewportResizeCb;
20154 var win = param1.win;
20155 var lastH = -1;
20156 var lastW = -1;
20157 var updateDimension = callbackWrapper(throttle(callbackWrapper(function() {
20158 var height = getWindowHeight();
20159 var width = getWindowWidth();
20160 if (lastH !== height || lastW !== width) {
20161 viewportResizeCb({
20162 width: Number(width),
20163 height: Number(height)
20164 });
20165 lastH = height;
20166 lastW = width;
20167 }
20168 }), 200));
20169 return on("resize", updateDimension, win);
20170 }
20171 var INPUT_TAGS = [
20172 "INPUT",
20173 "TEXTAREA",
20174 "SELECT"
20175 ];
20176 var lastInputValueMap = /* @__PURE__ */ new WeakMap();
20177 function initInputObserver(param) {
20178 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;
20179 function eventHandler(event) {
20180 var target = getEventTarget(event);
20181 var userTriggered = event.isTrusted;
20182 var tagName = target && target.tagName;
20183 if (target && tagName === "OPTION") {
20184 target = index.parentElement(target);
20185 }
20186 if (!target || !tagName || INPUT_TAGS.indexOf(tagName) < 0 || isBlocked(target, blockClass, blockSelector, true)) {
20187 return;
20188 }
20189 if (target.classList.contains(ignoreClass) || ignoreSelector && target.matches(ignoreSelector)) {
20190 return;
20191 }
20192 var text = target.value;
20193 var isChecked = false;
20194 var type = getInputType(target) || "";
20195 if (type === "radio" || type === "checkbox") {
20196 isChecked = target.checked;
20197 } else if (maskInputOptions[tagName.toLowerCase()] || maskInputOptions[type]) {
20198 text = maskInputValue({
20199 element: target,
20200 maskInputOptions: maskInputOptions,
20201 tagName: tagName,
20202 type: type,
20203 value: text,
20204 maskInputFn: maskInputFn
20205 });
20206 }
20207 cbWithDedup(target, userTriggeredOnInput ? {
20208 text: text,
20209 isChecked: isChecked,
20210 userTriggered: userTriggered
20211 } : {
20212 text: text,
20213 isChecked: isChecked
20214 });
20215 var name = target.name;
20216 if (type === "radio" && name && isChecked) {
20217 doc.querySelectorAll('input[type="radio"][name="' + name + '"]').forEach(function(el) {
20218 if (el !== target) {
20219 var text2 = el.value;
20220 cbWithDedup(el, userTriggeredOnInput ? {
20221 text: text2,
20222 isChecked: !isChecked,
20223 userTriggered: false
20224 } : {
20225 text: text2,
20226 isChecked: !isChecked
20227 });
20228 }
20229 });
20230 }
20231 }
20232 function cbWithDedup(target, v2) {
20233 var lastInputValue = lastInputValueMap.get(target);
20234 if (!lastInputValue || lastInputValue.text !== v2.text || lastInputValue.isChecked !== v2.isChecked) {
20235 lastInputValueMap.set(target, v2);
20236 var id = mirror2.getId(target);
20237 callbackWrapper(inputCb)(_extends({}, v2, {
20238 id: id
20239 }));
20240 }
20241 }
20242 var events = sampling.input === "last" ? [
20243 "change"
20244 ] : [
20245 "input",
20246 "change"
20247 ];
20248 var handlers = events.map(function(eventName) {
20249 return on(eventName, callbackWrapper(eventHandler), doc);
20250 });
20251 var currentWindow = doc.defaultView;
20252 if (!currentWindow) {
20253 return function() {
20254 handlers.forEach(function(h) {
20255 return h();
20256 });
20257 };
20258 }
20259 var propertyDescriptor = currentWindow.Object.getOwnPropertyDescriptor(currentWindow.HTMLInputElement.prototype, "value");
20260 var hookProperties = [
20261 [
20262 currentWindow.HTMLInputElement.prototype,
20263 "value"
20264 ],
20265 [
20266 currentWindow.HTMLInputElement.prototype,
20267 "checked"
20268 ],
20269 [
20270 currentWindow.HTMLSelectElement.prototype,
20271 "value"
20272 ],
20273 [
20274 currentWindow.HTMLTextAreaElement.prototype,
20275 "value"
20276 ],
20277 // Some UI library use selectedIndex to set select value
20278 [
20279 currentWindow.HTMLSelectElement.prototype,
20280 "selectedIndex"
20281 ],
20282 [
20283 currentWindow.HTMLOptionElement.prototype,
20284 "selected"
20285 ]
20286 ];
20287 if (propertyDescriptor && propertyDescriptor.set) {
20288 var _handlers;
20289 (_handlers = handlers).push.apply(_handlers, [].concat(hookProperties.map(function(p) {
20290 return hookSetter(p[0], p[1], {
20291 set: function set() {
20292 callbackWrapper(eventHandler)({
20293 target: this,
20294 isTrusted: false
20295 });
20296 }
20297 }, false, currentWindow);
20298 })));
20299 }
20300 return callbackWrapper(function() {
20301 handlers.forEach(function(h) {
20302 return h();
20303 });
20304 });
20305 }
20306 function getNestedCSSRulePositions(rule2) {
20307 var positions = [];
20308 function recurse(childRule, pos) {
20309 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)) {
20310 var rules2 = Array.from(childRule.parentRule.cssRules);
20311 var index2 = rules2.indexOf(childRule);
20312 pos.unshift(index2);
20313 } else if (childRule.parentStyleSheet) {
20314 var rules21 = Array.from(childRule.parentStyleSheet.cssRules);
20315 var index21 = rules21.indexOf(childRule);
20316 pos.unshift(index21);
20317 }
20318 return pos;
20319 }
20320 return recurse(rule2, positions);
20321 }
20322 function getIdAndStyleId(sheet, mirror2, styleMirror) {
20323 var id, styleId;
20324 if (!sheet) return {};
20325 if (sheet.ownerNode) id = mirror2.getId(sheet.ownerNode);
20326 else styleId = styleMirror.getId(sheet);
20327 return {
20328 styleId: styleId,
20329 id: id
20330 };
20331 }
20332 function initStyleSheetObserver(param, param1) {
20333 var styleSheetRuleCb = param.styleSheetRuleCb, mirror2 = param.mirror, stylesheetManager = param.stylesheetManager;
20334 var win = param1.win;
20335 if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) {
20336 return function() {};
20337 }
20338 var insertRule = win.CSSStyleSheet.prototype.insertRule;
20339 win.CSSStyleSheet.prototype.insertRule = new Proxy(insertRule, {
20340 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20341 var rule2 = argumentsList[0], index2 = argumentsList[1];
20342 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20343 if (id && id !== -1 || styleId && styleId !== -1) {
20344 styleSheetRuleCb({
20345 id: id,
20346 styleId: styleId,
20347 adds: [
20348 {
20349 rule: rule2,
20350 index: index2
20351 }
20352 ]
20353 });
20354 }
20355 return target.apply(thisArg, argumentsList);
20356 })
20357 });
20358 win.CSSStyleSheet.prototype.addRule = function(selector, styleBlock, index2) {
20359 if (index2 === void 0) index2 = this.cssRules.length;
20360 var rule2 = selector + " { " + styleBlock + " }";
20361 return win.CSSStyleSheet.prototype.insertRule.apply(this, [
20362 rule2,
20363 index2
20364 ]);
20365 };
20366 var deleteRule = win.CSSStyleSheet.prototype.deleteRule;
20367 win.CSSStyleSheet.prototype.deleteRule = new Proxy(deleteRule, {
20368 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20369 var index2 = argumentsList[0];
20370 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20371 if (id && id !== -1 || styleId && styleId !== -1) {
20372 styleSheetRuleCb({
20373 id: id,
20374 styleId: styleId,
20375 removes: [
20376 {
20377 index: index2
20378 }
20379 ]
20380 });
20381 }
20382 return target.apply(thisArg, argumentsList);
20383 })
20384 });
20385 win.CSSStyleSheet.prototype.removeRule = function(index2) {
20386 return win.CSSStyleSheet.prototype.deleteRule.apply(this, [
20387 index2
20388 ]);
20389 };
20390 var replace;
20391 if (win.CSSStyleSheet.prototype.replace) {
20392 replace = win.CSSStyleSheet.prototype.replace;
20393 win.CSSStyleSheet.prototype.replace = new Proxy(replace, {
20394 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20395 var text = argumentsList[0];
20396 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20397 if (id && id !== -1 || styleId && styleId !== -1) {
20398 styleSheetRuleCb({
20399 id: id,
20400 styleId: styleId,
20401 replace: text
20402 });
20403 }
20404 return target.apply(thisArg, argumentsList);
20405 })
20406 });
20407 }
20408 var replaceSync;
20409 if (win.CSSStyleSheet.prototype.replaceSync) {
20410 replaceSync = win.CSSStyleSheet.prototype.replaceSync;
20411 win.CSSStyleSheet.prototype.replaceSync = new Proxy(replaceSync, {
20412 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20413 var text = argumentsList[0];
20414 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20415 if (id && id !== -1 || styleId && styleId !== -1) {
20416 styleSheetRuleCb({
20417 id: id,
20418 styleId: styleId,
20419 replaceSync: text
20420 });
20421 }
20422 return target.apply(thisArg, argumentsList);
20423 })
20424 });
20425 }
20426 var supportedNestedCSSRuleTypes = {};
20427 if (canMonkeyPatchNestedCSSRule("CSSGroupingRule")) {
20428 supportedNestedCSSRuleTypes.CSSGroupingRule = win.CSSGroupingRule;
20429 } else {
20430 if (canMonkeyPatchNestedCSSRule("CSSMediaRule")) {
20431 supportedNestedCSSRuleTypes.CSSMediaRule = win.CSSMediaRule;
20432 }
20433 if (canMonkeyPatchNestedCSSRule("CSSConditionRule")) {
20434 supportedNestedCSSRuleTypes.CSSConditionRule = win.CSSConditionRule;
20435 }
20436 if (canMonkeyPatchNestedCSSRule("CSSSupportsRule")) {
20437 supportedNestedCSSRuleTypes.CSSSupportsRule = win.CSSSupportsRule;
20438 }
20439 }
20440 var unmodifiedFunctions = {};
20441 Object.entries(supportedNestedCSSRuleTypes).forEach(function(param) {
20442 var typeKey = param[0], type = param[1];
20443 unmodifiedFunctions[typeKey] = {
20444 // eslint-disable-next-line @typescript-eslint/unbound-method
20445 insertRule: type.prototype.insertRule,
20446 // eslint-disable-next-line @typescript-eslint/unbound-method
20447 deleteRule: type.prototype.deleteRule
20448 };
20449 type.prototype.insertRule = new Proxy(unmodifiedFunctions[typeKey].insertRule, {
20450 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20451 var rule2 = argumentsList[0], index2 = argumentsList[1];
20452 var _getIdAndStyleId = getIdAndStyleId(thisArg.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20453 if (id && id !== -1 || styleId && styleId !== -1) {
20454 styleSheetRuleCb({
20455 id: id,
20456 styleId: styleId,
20457 adds: [
20458 {
20459 rule: rule2,
20460 index: [].concat(getNestedCSSRulePositions(thisArg), [
20461 index2 || 0
20462 ])
20463 }
20464 ]
20465 });
20466 }
20467 return target.apply(thisArg, argumentsList);
20468 })
20469 });
20470 type.prototype.deleteRule = new Proxy(unmodifiedFunctions[typeKey].deleteRule, {
20471 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20472 var index2 = argumentsList[0];
20473 var _getIdAndStyleId = getIdAndStyleId(thisArg.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20474 if (id && id !== -1 || styleId && styleId !== -1) {
20475 styleSheetRuleCb({
20476 id: id,
20477 styleId: styleId,
20478 removes: [
20479 {
20480 index: [].concat(getNestedCSSRulePositions(thisArg), [
20481 index2
20482 ])
20483 }
20484 ]
20485 });
20486 }
20487 return target.apply(thisArg, argumentsList);
20488 })
20489 });
20490 });
20491 return callbackWrapper(function() {
20492 win.CSSStyleSheet.prototype.insertRule = insertRule;
20493 win.CSSStyleSheet.prototype.deleteRule = deleteRule;
20494 replace && (win.CSSStyleSheet.prototype.replace = replace);
20495 replaceSync && (win.CSSStyleSheet.prototype.replaceSync = replaceSync);
20496 Object.entries(supportedNestedCSSRuleTypes).forEach(function(param) {
20497 var typeKey = param[0], type = param[1];
20498 type.prototype.insertRule = unmodifiedFunctions[typeKey].insertRule;
20499 type.prototype.deleteRule = unmodifiedFunctions[typeKey].deleteRule;
20500 });
20501 });
20502 }
20503 function initAdoptedStyleSheetObserver(param, host2) {
20504 var mirror2 = param.mirror, stylesheetManager = param.stylesheetManager;
20505 var _a2, _b, _c;
20506 var hostId = null;
20507 if (host2.nodeName === "#document") hostId = mirror2.getId(host2);
20508 else hostId = mirror2.getId(index.host(host2));
20509 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;
20510 var originalPropertyDescriptor = (patchTarget == null ? void 0 : patchTarget.prototype) ? Object.getOwnPropertyDescriptor(patchTarget == null ? void 0 : patchTarget.prototype, "adoptedStyleSheets") : void 0;
20511 if (hostId === null || hostId === -1 || !patchTarget || !originalPropertyDescriptor) return function() {};
20512 Object.defineProperty(host2, "adoptedStyleSheets", {
20513 configurable: originalPropertyDescriptor.configurable,
20514 enumerable: originalPropertyDescriptor.enumerable,
20515 get: function get() {
20516 var _a3;
20517 return (_a3 = originalPropertyDescriptor.get) == null ? void 0 : _a3.call(this);
20518 },
20519 set: function set(sheets) {
20520 var _a3;
20521 var result2 = (_a3 = originalPropertyDescriptor.set) == null ? void 0 : _a3.call(this, sheets);
20522 if (hostId !== null && hostId !== -1) {
20523 try {
20524 stylesheetManager.adoptStyleSheets(sheets, hostId);
20525 } catch (e2) {}
20526 }
20527 return result2;
20528 }
20529 });
20530 return callbackWrapper(function() {
20531 Object.defineProperty(host2, "adoptedStyleSheets", {
20532 configurable: originalPropertyDescriptor.configurable,
20533 enumerable: originalPropertyDescriptor.enumerable,
20534 // eslint-disable-next-line @typescript-eslint/unbound-method
20535 get: originalPropertyDescriptor.get,
20536 // eslint-disable-next-line @typescript-eslint/unbound-method
20537 set: originalPropertyDescriptor.set
20538 });
20539 });
20540 }
20541 function initStyleDeclarationObserver(param, param1) {
20542 var styleDeclarationCb = param.styleDeclarationCb, mirror2 = param.mirror, ignoreCSSAttributes = param.ignoreCSSAttributes, stylesheetManager = param.stylesheetManager;
20543 var win = param1.win;
20544 var setProperty = win.CSSStyleDeclaration.prototype.setProperty;
20545 win.CSSStyleDeclaration.prototype.setProperty = new Proxy(setProperty, {
20546 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20547 var _a2;
20548 var property = argumentsList[0], value = argumentsList[1], priority = argumentsList[2];
20549 if (ignoreCSSAttributes.has(property)) {
20550 return setProperty.apply(thisArg, [
20551 property,
20552 value,
20553 priority
20554 ]);
20555 }
20556 var _getIdAndStyleId = getIdAndStyleId((_a2 = thisArg.parentRule) == null ? void 0 : _a2.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20557 if (id && id !== -1 || styleId && styleId !== -1) {
20558 styleDeclarationCb({
20559 id: id,
20560 styleId: styleId,
20561 set: {
20562 property: property,
20563 value: value,
20564 priority: priority
20565 },
20566 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
20567 index: getNestedCSSRulePositions(thisArg.parentRule)
20568 });
20569 }
20570 return target.apply(thisArg, argumentsList);
20571 })
20572 });
20573 var removeProperty = win.CSSStyleDeclaration.prototype.removeProperty;
20574 win.CSSStyleDeclaration.prototype.removeProperty = new Proxy(removeProperty, {
20575 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20576 var _a2;
20577 var property = argumentsList[0];
20578 if (ignoreCSSAttributes.has(property)) {
20579 return removeProperty.apply(thisArg, [
20580 property
20581 ]);
20582 }
20583 var _getIdAndStyleId = getIdAndStyleId((_a2 = thisArg.parentRule) == null ? void 0 : _a2.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20584 if (id && id !== -1 || styleId && styleId !== -1) {
20585 styleDeclarationCb({
20586 id: id,
20587 styleId: styleId,
20588 remove: {
20589 property: property
20590 },
20591 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
20592 index: getNestedCSSRulePositions(thisArg.parentRule)
20593 });
20594 }
20595 return target.apply(thisArg, argumentsList);
20596 })
20597 });
20598 return callbackWrapper(function() {
20599 win.CSSStyleDeclaration.prototype.setProperty = setProperty;
20600 win.CSSStyleDeclaration.prototype.removeProperty = removeProperty;
20601 });
20602 }
20603 function initMediaInteractionObserver(param) {
20604 var mediaInteractionCb = param.mediaInteractionCb, blockClass = param.blockClass, blockSelector = param.blockSelector, mirror2 = param.mirror, sampling = param.sampling, doc = param.doc;
20605 var handler = callbackWrapper(function(type) {
20606 return throttle(callbackWrapper(function(event) {
20607 var target = getEventTarget(event);
20608 if (!target || isBlocked(target, blockClass, blockSelector, true)) {
20609 return;
20610 }
20611 var currentTime = target.currentTime, volume = target.volume, muted = target.muted, playbackRate = target.playbackRate, loop = target.loop;
20612 mediaInteractionCb({
20613 type: type,
20614 id: mirror2.getId(target),
20615 currentTime: currentTime,
20616 volume: volume,
20617 muted: muted,
20618 playbackRate: playbackRate,
20619 loop: loop
20620 });
20621 }), sampling.media || 500);
20622 });
20623 var handlers = [
20624 on("play", handler(MediaInteractions.Play), doc),
20625 on("pause", handler(MediaInteractions.Pause), doc),
20626 on("seeked", handler(MediaInteractions.Seeked), doc),
20627 on("volumechange", handler(MediaInteractions.VolumeChange), doc),
20628 on("ratechange", handler(MediaInteractions.RateChange), doc)
20629 ];
20630 return callbackWrapper(function() {
20631 handlers.forEach(function(h) {
20632 return h();
20633 });
20634 });
20635 }
20636 function initFontObserver(param) {
20637 var fontCb = param.fontCb, doc = param.doc;
20638 var win = doc.defaultView;
20639 if (!win) {
20640 return function() {};
20641 }
20642 var handlers = [];
20643 var fontMap = /* @__PURE__ */ new WeakMap();
20644 var originalFontFace = win.FontFace;
20645 win.FontFace = function FontFace2(family, source, descriptors) {
20646 var fontFace = new originalFontFace(family, source, descriptors);
20647 fontMap.set(fontFace, {
20648 family: family,
20649 buffer: typeof source !== "string",
20650 descriptors: descriptors,
20651 fontSource: typeof source === "string" ? source : JSON.stringify(Array.from(new Uint8Array(source)))
20652 });
20653 return fontFace;
20654 };
20655 var restoreHandler = patch(doc.fonts, "add", function(original) {
20656 return function(fontFace) {
20657 setTimeout(callbackWrapper(function() {
20658 var p = fontMap.get(fontFace);
20659 if (p) {
20660 fontCb(p);
20661 fontMap.delete(fontFace);
20662 }
20663 }), 0);
20664 return original.apply(this, [
20665 fontFace
20666 ]);
20667 };
20668 });
20669 handlers.push(function() {
20670 win.FontFace = originalFontFace;
20671 });
20672 handlers.push(restoreHandler);
20673 return callbackWrapper(function() {
20674 handlers.forEach(function(h) {
20675 return h();
20676 });
20677 });
20678 }
20679 function initSelectionObserver(param) {
20680 var doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, selectionCb = param.selectionCb;
20681 var collapsed = true;
20682 var updateSelection = callbackWrapper(function() {
20683 var selection = doc.getSelection();
20684 if (!selection || collapsed && (selection == null ? void 0 : selection.isCollapsed)) return;
20685 collapsed = selection.isCollapsed || false;
20686 var ranges = [];
20687 var count = selection.rangeCount || 0;
20688 for(var i2 = 0; i2 < count; i2++){
20689 var range = selection.getRangeAt(i2);
20690 var startContainer = range.startContainer, startOffset = range.startOffset, endContainer = range.endContainer, endOffset = range.endOffset;
20691 var blocked = isBlocked(startContainer, blockClass, blockSelector, true) || isBlocked(endContainer, blockClass, blockSelector, true);
20692 if (blocked) continue;
20693 ranges.push({
20694 start: mirror2.getId(startContainer),
20695 startOffset: startOffset,
20696 end: mirror2.getId(endContainer),
20697 endOffset: endOffset
20698 });
20699 }
20700 selectionCb({
20701 ranges: ranges
20702 });
20703 });
20704 updateSelection();
20705 return on("selectionchange", updateSelection);
20706 }
20707 function initCustomElementObserver(param) {
20708 var doc = param.doc, customElementCb = param.customElementCb;
20709 var win = doc.defaultView;
20710 if (!win || !win.customElements) return function() {};
20711 var restoreHandler = patch(win.customElements, "define", function(original) {
20712 return function(name, constructor, options) {
20713 try {
20714 customElementCb({
20715 define: {
20716 name: name
20717 }
20718 });
20719 } catch (e2) {
20720 console.warn("Custom element callback failed for " + name);
20721 }
20722 return original.apply(this, [
20723 name,
20724 constructor,
20725 options
20726 ]);
20727 };
20728 });
20729 return restoreHandler;
20730 }
20731 function mergeHooks(o2, hooks) {
20732 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;
20733 o2.mutationCb = function() {
20734 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20735 p[_key] = arguments[_key];
20736 }
20737 if (hooks.mutation) {
20738 var _hooks;
20739 (_hooks = hooks).mutation.apply(_hooks, [].concat(p));
20740 }
20741 mutationCb.apply(void 0, [].concat(p));
20742 };
20743 o2.mousemoveCb = function() {
20744 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20745 p[_key] = arguments[_key];
20746 }
20747 if (hooks.mousemove) {
20748 var _hooks;
20749 (_hooks = hooks).mousemove.apply(_hooks, [].concat(p));
20750 }
20751 mousemoveCb.apply(void 0, [].concat(p));
20752 };
20753 o2.mouseInteractionCb = function() {
20754 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20755 p[_key] = arguments[_key];
20756 }
20757 if (hooks.mouseInteraction) {
20758 var _hooks;
20759 (_hooks = hooks).mouseInteraction.apply(_hooks, [].concat(p));
20760 }
20761 mouseInteractionCb.apply(void 0, [].concat(p));
20762 };
20763 o2.scrollCb = function() {
20764 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20765 p[_key] = arguments[_key];
20766 }
20767 if (hooks.scroll) {
20768 var _hooks;
20769 (_hooks = hooks).scroll.apply(_hooks, [].concat(p));
20770 }
20771 scrollCb.apply(void 0, [].concat(p));
20772 };
20773 o2.viewportResizeCb = function() {
20774 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20775 p[_key] = arguments[_key];
20776 }
20777 if (hooks.viewportResize) {
20778 var _hooks;
20779 (_hooks = hooks).viewportResize.apply(_hooks, [].concat(p));
20780 }
20781 viewportResizeCb.apply(void 0, [].concat(p));
20782 };
20783 o2.inputCb = function() {
20784 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20785 p[_key] = arguments[_key];
20786 }
20787 if (hooks.input) {
20788 var _hooks;
20789 (_hooks = hooks).input.apply(_hooks, [].concat(p));
20790 }
20791 inputCb.apply(void 0, [].concat(p));
20792 };
20793 o2.mediaInteractionCb = function() {
20794 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20795 p[_key] = arguments[_key];
20796 }
20797 if (hooks.mediaInteaction) {
20798 var _hooks;
20799 (_hooks = hooks).mediaInteaction.apply(_hooks, [].concat(p));
20800 }
20801 mediaInteractionCb.apply(void 0, [].concat(p));
20802 };
20803 o2.styleSheetRuleCb = function() {
20804 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20805 p[_key] = arguments[_key];
20806 }
20807 if (hooks.styleSheetRule) {
20808 var _hooks;
20809 (_hooks = hooks).styleSheetRule.apply(_hooks, [].concat(p));
20810 }
20811 styleSheetRuleCb.apply(void 0, [].concat(p));
20812 };
20813 o2.styleDeclarationCb = function() {
20814 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20815 p[_key] = arguments[_key];
20816 }
20817 if (hooks.styleDeclaration) {
20818 var _hooks;
20819 (_hooks = hooks).styleDeclaration.apply(_hooks, [].concat(p));
20820 }
20821 styleDeclarationCb.apply(void 0, [].concat(p));
20822 };
20823 o2.canvasMutationCb = function() {
20824 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20825 p[_key] = arguments[_key];
20826 }
20827 if (hooks.canvasMutation) {
20828 var _hooks;
20829 (_hooks = hooks).canvasMutation.apply(_hooks, [].concat(p));
20830 }
20831 canvasMutationCb.apply(void 0, [].concat(p));
20832 };
20833 o2.fontCb = function() {
20834 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20835 p[_key] = arguments[_key];
20836 }
20837 if (hooks.font) {
20838 var _hooks;
20839 (_hooks = hooks).font.apply(_hooks, [].concat(p));
20840 }
20841 fontCb.apply(void 0, [].concat(p));
20842 };
20843 o2.selectionCb = function() {
20844 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20845 p[_key] = arguments[_key];
20846 }
20847 if (hooks.selection) {
20848 var _hooks;
20849 (_hooks = hooks).selection.apply(_hooks, [].concat(p));
20850 }
20851 selectionCb.apply(void 0, [].concat(p));
20852 };
20853 o2.customElementCb = function() {
20854 for(var _len = arguments.length, c2 = new Array(_len), _key = 0; _key < _len; _key++){
20855 c2[_key] = arguments[_key];
20856 }
20857 if (hooks.customElement) {
20858 var _hooks;
20859 (_hooks = hooks).customElement.apply(_hooks, [].concat(c2));
20860 }
20861 customElementCb.apply(void 0, [].concat(c2));
20862 };
20863 }
20864 function initObservers(o2, hooks) {
20865 if (hooks === void 0) hooks = {};
20866 var currentWindow = o2.doc.defaultView;
20867 if (!currentWindow) {
20868 return function() {};
20869 }
20870 mergeHooks(o2, hooks);
20871 var mutationObserver;
20872 if (o2.recordDOM) {
20873 mutationObserver = initMutationObserver(o2, o2.doc);
20874 }
20875 var mousemoveHandler = initMoveObserver(o2);
20876 var mouseInteractionHandler = initMouseInteractionObserver(o2);
20877 var scrollHandler = initScrollObserver(o2);
20878 var viewportResizeHandler = initViewportResizeObserver(o2, {
20879 win: currentWindow
20880 });
20881 var inputHandler = initInputObserver(o2);
20882 var mediaInteractionHandler = initMediaInteractionObserver(o2);
20883 var styleSheetObserver = function() {};
20884 var adoptedStyleSheetObserver = function() {};
20885 var styleDeclarationObserver = function() {};
20886 var fontObserver = function() {};
20887 if (o2.recordDOM) {
20888 styleSheetObserver = initStyleSheetObserver(o2, {
20889 win: currentWindow
20890 });
20891 adoptedStyleSheetObserver = initAdoptedStyleSheetObserver(o2, o2.doc);
20892 styleDeclarationObserver = initStyleDeclarationObserver(o2, {
20893 win: currentWindow
20894 });
20895 if (o2.collectFonts) {
20896 fontObserver = initFontObserver(o2);
20897 }
20898 }
20899 var selectionObserver = initSelectionObserver(o2);
20900 var customElementObserver = initCustomElementObserver(o2);
20901 var pluginHandlers = [];
20902 for(var _iterator = _create_for_of_iterator_helper_loose(o2.plugins), _step; !(_step = _iterator()).done;){
20903 var plugin3 = _step.value;
20904 pluginHandlers.push(plugin3.observer(plugin3.callback, currentWindow, plugin3.options));
20905 }
20906 return callbackWrapper(function() {
20907 mutationBuffers.forEach(function(b) {
20908 return b.reset();
20909 });
20910 mutationObserver == null ? void 0 : mutationObserver.disconnect();
20911 mousemoveHandler();
20912 mouseInteractionHandler();
20913 scrollHandler();
20914 viewportResizeHandler();
20915 inputHandler();
20916 mediaInteractionHandler();
20917 styleSheetObserver();
20918 adoptedStyleSheetObserver();
20919 styleDeclarationObserver();
20920 fontObserver();
20921 selectionObserver();
20922 customElementObserver();
20923 pluginHandlers.forEach(function(h) {
20924 return h();
20925 });
20926 });
20927 }
20928 function hasNestedCSSRule(prop) {
20929 return typeof window[prop] !== "undefined";
20930 }
20931 function canMonkeyPatchNestedCSSRule(prop) {
20932 return Boolean(typeof window[prop] !== "undefined" && // Note: Generally, this check _shouldn't_ be necessary
20933 // However, in some scenarios (e.g. jsdom) this can sometimes fail, so we check for it here
20934 window[prop].prototype && "insertRule" in window[prop].prototype && "deleteRule" in window[prop].prototype);
20935 }
20936 var CrossOriginIframeMirror = /*#__PURE__*/ function() {
20937 function CrossOriginIframeMirror(generateIdFn) {
20938 __publicField(this, "iframeIdToRemoteIdMap", /* @__PURE__ */ new WeakMap());
20939 __publicField(this, "iframeRemoteIdToIdMap", /* @__PURE__ */ new WeakMap());
20940 this.generateIdFn = generateIdFn;
20941 }
20942 var _proto = CrossOriginIframeMirror.prototype;
20943 _proto.getId = function getId(iframe, remoteId, idToRemoteMap, remoteToIdMap) {
20944 var idToRemoteIdMap = idToRemoteMap || this.getIdToRemoteIdMap(iframe);
20945 var remoteIdToIdMap = remoteToIdMap || this.getRemoteIdToIdMap(iframe);
20946 var id = idToRemoteIdMap.get(remoteId);
20947 if (!id) {
20948 id = this.generateIdFn();
20949 idToRemoteIdMap.set(remoteId, id);
20950 remoteIdToIdMap.set(id, remoteId);
20951 }
20952 return id;
20953 };
20954 _proto.getIds = function getIds(iframe, remoteId) {
20955 var _this = this;
20956 var idToRemoteIdMap = this.getIdToRemoteIdMap(iframe);
20957 var remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);
20958 return remoteId.map(function(id) {
20959 return _this.getId(iframe, id, idToRemoteIdMap, remoteIdToIdMap);
20960 });
20961 };
20962 _proto.getRemoteId = function getRemoteId(iframe, id, map) {
20963 var remoteIdToIdMap = map || this.getRemoteIdToIdMap(iframe);
20964 if (typeof id !== "number") return id;
20965 var remoteId = remoteIdToIdMap.get(id);
20966 if (!remoteId) return -1;
20967 return remoteId;
20968 };
20969 _proto.getRemoteIds = function getRemoteIds(iframe, ids) {
20970 var _this = this;
20971 var remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);
20972 return ids.map(function(id) {
20973 return _this.getRemoteId(iframe, id, remoteIdToIdMap);
20974 });
20975 };
20976 _proto.reset = function reset(iframe) {
20977 if (!iframe) {
20978 this.iframeIdToRemoteIdMap = /* @__PURE__ */ new WeakMap();
20979 this.iframeRemoteIdToIdMap = /* @__PURE__ */ new WeakMap();
20980 return;
20981 }
20982 this.iframeIdToRemoteIdMap.delete(iframe);
20983 this.iframeRemoteIdToIdMap.delete(iframe);
20984 };
20985 _proto.getIdToRemoteIdMap = function getIdToRemoteIdMap(iframe) {
20986 var idToRemoteIdMap = this.iframeIdToRemoteIdMap.get(iframe);
20987 if (!idToRemoteIdMap) {
20988 idToRemoteIdMap = /* @__PURE__ */ new Map();
20989 this.iframeIdToRemoteIdMap.set(iframe, idToRemoteIdMap);
20990 }
20991 return idToRemoteIdMap;
20992 };
20993 _proto.getRemoteIdToIdMap = function getRemoteIdToIdMap(iframe) {
20994 var remoteIdToIdMap = this.iframeRemoteIdToIdMap.get(iframe);
20995 if (!remoteIdToIdMap) {
20996 remoteIdToIdMap = /* @__PURE__ */ new Map();
20997 this.iframeRemoteIdToIdMap.set(iframe, remoteIdToIdMap);
20998 }
20999 return remoteIdToIdMap;
21000 };
21001 return CrossOriginIframeMirror;
21002 }();
21003 var IframeManager = /*#__PURE__*/ function() {
21004 function IframeManager(options) {
21005 __publicField(this, "iframes", /* @__PURE__ */ new WeakMap());
21006 __publicField(this, "crossOriginIframeMap", /* @__PURE__ */ new WeakMap());
21007 __publicField(this, "crossOriginIframeMirror", new CrossOriginIframeMirror(genId));
21008 __publicField(this, "crossOriginIframeStyleMirror");
21009 __publicField(this, "crossOriginIframeRootIdMap", /* @__PURE__ */ new WeakMap());
21010 __publicField(this, "mirror");
21011 __publicField(this, "mutationCb");
21012 __publicField(this, "wrappedEmit");
21013 __publicField(this, "loadListener");
21014 __publicField(this, "stylesheetManager");
21015 __publicField(this, "recordCrossOriginIframes");
21016 this.mutationCb = options.mutationCb;
21017 this.wrappedEmit = options.wrappedEmit;
21018 this.stylesheetManager = options.stylesheetManager;
21019 this.recordCrossOriginIframes = options.recordCrossOriginIframes;
21020 this.crossOriginIframeStyleMirror = new CrossOriginIframeMirror(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror));
21021 this.mirror = options.mirror;
21022 if (this.recordCrossOriginIframes) {
21023 window.addEventListener("message", this.handleMessage.bind(this));
21024 }
21025 }
21026 var _proto = IframeManager.prototype;
21027 _proto.addIframe = function addIframe(iframeEl) {
21028 this.iframes.set(iframeEl, true);
21029 if (iframeEl.contentWindow) this.crossOriginIframeMap.set(iframeEl.contentWindow, iframeEl);
21030 };
21031 _proto.addLoadListener = function addLoadListener(cb) {
21032 this.loadListener = cb;
21033 };
21034 _proto.attachIframe = function attachIframe(iframeEl, childSn) {
21035 var _a2, _b;
21036 this.mutationCb({
21037 adds: [
21038 {
21039 parentId: this.mirror.getId(iframeEl),
21040 nextId: null,
21041 node: childSn
21042 }
21043 ],
21044 removes: [],
21045 texts: [],
21046 attributes: [],
21047 isAttachIframe: true
21048 });
21049 if (this.recordCrossOriginIframes) (_a2 = iframeEl.contentWindow) == null ? void 0 : _a2.addEventListener("message", this.handleMessage.bind(this));
21050 (_b = this.loadListener) == null ? void 0 : _b.call(this, iframeEl);
21051 if (iframeEl.contentDocument && iframeEl.contentDocument.adoptedStyleSheets && iframeEl.contentDocument.adoptedStyleSheets.length > 0) this.stylesheetManager.adoptStyleSheets(iframeEl.contentDocument.adoptedStyleSheets, this.mirror.getId(iframeEl.contentDocument));
21052 };
21053 _proto.handleMessage = function handleMessage(message) {
21054 var crossOriginMessageEvent = message;
21055 if (crossOriginMessageEvent.data.type !== "rrweb" || // To filter out the rrweb messages which are forwarded by some sites.
21056 crossOriginMessageEvent.origin !== crossOriginMessageEvent.data.origin) return;
21057 var iframeSourceWindow = message.source;
21058 if (!iframeSourceWindow) return;
21059 var iframeEl = this.crossOriginIframeMap.get(message.source);
21060 if (!iframeEl) return;
21061 var transformedEvent = this.transformCrossOriginEvent(iframeEl, crossOriginMessageEvent.data.event);
21062 if (transformedEvent) this.wrappedEmit(transformedEvent, crossOriginMessageEvent.data.isCheckout);
21063 };
21064 _proto.transformCrossOriginEvent = function transformCrossOriginEvent(iframeEl, e2) {
21065 var _this = this;
21066 var _a2;
21067 switch(e2.type){
21068 case EventType.FullSnapshot:
21069 {
21070 this.crossOriginIframeMirror.reset(iframeEl);
21071 this.crossOriginIframeStyleMirror.reset(iframeEl);
21072 this.replaceIdOnNode(e2.data.node, iframeEl);
21073 var rootId = e2.data.node.id;
21074 this.crossOriginIframeRootIdMap.set(iframeEl, rootId);
21075 this.patchRootIdOnNode(e2.data.node, rootId);
21076 return {
21077 timestamp: e2.timestamp,
21078 type: EventType.IncrementalSnapshot,
21079 data: {
21080 source: IncrementalSource.Mutation,
21081 adds: [
21082 {
21083 parentId: this.mirror.getId(iframeEl),
21084 nextId: null,
21085 node: e2.data.node
21086 }
21087 ],
21088 removes: [],
21089 texts: [],
21090 attributes: [],
21091 isAttachIframe: true
21092 }
21093 };
21094 }
21095 case EventType.Meta:
21096 case EventType.Load:
21097 case EventType.DomContentLoaded:
21098 {
21099 return false;
21100 }
21101 case EventType.Plugin:
21102 {
21103 return e2;
21104 }
21105 case EventType.Custom:
21106 {
21107 this.replaceIds(e2.data.payload, iframeEl, [
21108 "id",
21109 "parentId",
21110 "previousId",
21111 "nextId"
21112 ]);
21113 return e2;
21114 }
21115 case EventType.IncrementalSnapshot:
21116 {
21117 switch(e2.data.source){
21118 case IncrementalSource.Mutation:
21119 {
21120 e2.data.adds.forEach(function(n2) {
21121 _this.replaceIds(n2, iframeEl, [
21122 "parentId",
21123 "nextId",
21124 "previousId"
21125 ]);
21126 _this.replaceIdOnNode(n2.node, iframeEl);
21127 var rootId = _this.crossOriginIframeRootIdMap.get(iframeEl);
21128 rootId && _this.patchRootIdOnNode(n2.node, rootId);
21129 });
21130 e2.data.removes.forEach(function(n2) {
21131 _this.replaceIds(n2, iframeEl, [
21132 "parentId",
21133 "id"
21134 ]);
21135 });
21136 e2.data.attributes.forEach(function(n2) {
21137 _this.replaceIds(n2, iframeEl, [
21138 "id"
21139 ]);
21140 });
21141 e2.data.texts.forEach(function(n2) {
21142 _this.replaceIds(n2, iframeEl, [
21143 "id"
21144 ]);
21145 });
21146 return e2;
21147 }
21148 case IncrementalSource.Drag:
21149 case IncrementalSource.TouchMove:
21150 case IncrementalSource.MouseMove:
21151 {
21152 e2.data.positions.forEach(function(p) {
21153 _this.replaceIds(p, iframeEl, [
21154 "id"
21155 ]);
21156 });
21157 return e2;
21158 }
21159 case IncrementalSource.ViewportResize:
21160 {
21161 return false;
21162 }
21163 case IncrementalSource.MediaInteraction:
21164 case IncrementalSource.MouseInteraction:
21165 case IncrementalSource.Scroll:
21166 case IncrementalSource.CanvasMutation:
21167 case IncrementalSource.Input:
21168 {
21169 this.replaceIds(e2.data, iframeEl, [
21170 "id"
21171 ]);
21172 return e2;
21173 }
21174 case IncrementalSource.StyleSheetRule:
21175 case IncrementalSource.StyleDeclaration:
21176 {
21177 this.replaceIds(e2.data, iframeEl, [
21178 "id"
21179 ]);
21180 this.replaceStyleIds(e2.data, iframeEl, [
21181 "styleId"
21182 ]);
21183 return e2;
21184 }
21185 case IncrementalSource.Font:
21186 {
21187 return e2;
21188 }
21189 case IncrementalSource.Selection:
21190 {
21191 e2.data.ranges.forEach(function(range) {
21192 _this.replaceIds(range, iframeEl, [
21193 "start",
21194 "end"
21195 ]);
21196 });
21197 return e2;
21198 }
21199 case IncrementalSource.AdoptedStyleSheet:
21200 {
21201 this.replaceIds(e2.data, iframeEl, [
21202 "id"
21203 ]);
21204 this.replaceStyleIds(e2.data, iframeEl, [
21205 "styleIds"
21206 ]);
21207 (_a2 = e2.data.styles) == null ? void 0 : _a2.forEach(function(style) {
21208 _this.replaceStyleIds(style, iframeEl, [
21209 "styleId"
21210 ]);
21211 });
21212 return e2;
21213 }
21214 }
21215 }
21216 }
21217 return false;
21218 };
21219 _proto.replace = function replace(iframeMirror, obj, iframeEl, keys) {
21220 for(var _iterator = _create_for_of_iterator_helper_loose(keys), _step; !(_step = _iterator()).done;){
21221 var key = _step.value;
21222 if (!Array.isArray(obj[key]) && typeof obj[key] !== "number") continue;
21223 if (Array.isArray(obj[key])) {
21224 obj[key] = iframeMirror.getIds(iframeEl, obj[key]);
21225 } else {
21226 obj[key] = iframeMirror.getId(iframeEl, obj[key]);
21227 }
21228 }
21229 return obj;
21230 };
21231 _proto.replaceIds = function replaceIds(obj, iframeEl, keys) {
21232 return this.replace(this.crossOriginIframeMirror, obj, iframeEl, keys);
21233 };
21234 _proto.replaceStyleIds = function replaceStyleIds(obj, iframeEl, keys) {
21235 return this.replace(this.crossOriginIframeStyleMirror, obj, iframeEl, keys);
21236 };
21237 _proto.replaceIdOnNode = function replaceIdOnNode(node2, iframeEl) {
21238 var _this = this;
21239 this.replaceIds(node2, iframeEl, [
21240 "id",
21241 "rootId"
21242 ]);
21243 if ("childNodes" in node2) {
21244 node2.childNodes.forEach(function(child) {
21245 _this.replaceIdOnNode(child, iframeEl);
21246 });
21247 }
21248 };
21249 _proto.patchRootIdOnNode = function patchRootIdOnNode(node2, rootId) {
21250 var _this = this;
21251 if (node2.type !== NodeType.Document && !node2.rootId) node2.rootId = rootId;
21252 if ("childNodes" in node2) {
21253 node2.childNodes.forEach(function(child) {
21254 _this.patchRootIdOnNode(child, rootId);
21255 });
21256 }
21257 };
21258 return IframeManager;
21259 }();
21260 var ShadowDomManager = /*#__PURE__*/ function() {
21261 function ShadowDomManager(options) {
21262 __publicField(this, "shadowDoms", /* @__PURE__ */ new WeakSet());
21263 __publicField(this, "mutationCb");
21264 __publicField(this, "scrollCb");
21265 __publicField(this, "bypassOptions");
21266 __publicField(this, "mirror");
21267 __publicField(this, "restoreHandlers", []);
21268 this.mutationCb = options.mutationCb;
21269 this.scrollCb = options.scrollCb;
21270 this.bypassOptions = options.bypassOptions;
21271 this.mirror = options.mirror;
21272 this.init();
21273 }
21274 var _proto = ShadowDomManager.prototype;
21275 _proto.init = function init() {
21276 this.reset();
21277 this.patchAttachShadow(Element, document);
21278 };
21279 _proto.addShadowRoot = function addShadowRoot(shadowRoot2, doc) {
21280 var _this = this;
21281 if (!isNativeShadowDom(shadowRoot2)) return;
21282 if (this.shadowDoms.has(shadowRoot2)) return;
21283 this.shadowDoms.add(shadowRoot2);
21284 var observer = initMutationObserver(_extends({}, this.bypassOptions, {
21285 doc: doc,
21286 mutationCb: this.mutationCb,
21287 mirror: this.mirror,
21288 shadowDomManager: this
21289 }), shadowRoot2);
21290 this.restoreHandlers.push(function() {
21291 return observer.disconnect();
21292 });
21293 this.restoreHandlers.push(initScrollObserver(_extends({}, this.bypassOptions, {
21294 scrollCb: this.scrollCb,
21295 // https://gist.github.com/praveenpuglia/0832da687ed5a5d7a0907046c9ef1813
21296 // scroll is not allowed to pass the boundary, so we need to listen the shadow document
21297 doc: shadowRoot2,
21298 mirror: this.mirror
21299 })));
21300 setTimeout(function() {
21301 if (shadowRoot2.adoptedStyleSheets && shadowRoot2.adoptedStyleSheets.length > 0) _this.bypassOptions.stylesheetManager.adoptStyleSheets(shadowRoot2.adoptedStyleSheets, _this.mirror.getId(index.host(shadowRoot2)));
21302 _this.restoreHandlers.push(initAdoptedStyleSheetObserver({
21303 mirror: _this.mirror,
21304 stylesheetManager: _this.bypassOptions.stylesheetManager
21305 }, shadowRoot2));
21306 }, 0);
21307 };
21308 /**
21309 * Monkey patch 'attachShadow' of an IFrameElement to observe newly added shadow doms.
21310 */ _proto.observeAttachShadow = function observeAttachShadow(iframeElement) {
21311 if (!iframeElement.contentWindow || !iframeElement.contentDocument) return;
21312 this.patchAttachShadow(iframeElement.contentWindow.Element, iframeElement.contentDocument);
21313 };
21314 /**
21315 * Patch 'attachShadow' to observe newly added shadow doms.
21316 */ _proto.patchAttachShadow = function patchAttachShadow(element, doc) {
21317 var manager = this;
21318 this.restoreHandlers.push(patch(element.prototype, "attachShadow", function(original) {
21319 return function(option) {
21320 var sRoot = original.call(this, option);
21321 var shadowRootEl = index.shadowRoot(this);
21322 if (shadowRootEl && inDom(this)) manager.addShadowRoot(shadowRootEl, doc);
21323 return sRoot;
21324 };
21325 }));
21326 };
21327 _proto.reset = function reset() {
21328 this.restoreHandlers.forEach(function(handler) {
21329 try {
21330 handler();
21331 } catch (e2) {}
21332 });
21333 this.restoreHandlers = [];
21334 this.shadowDoms = /* @__PURE__ */ new WeakSet();
21335 };
21336 return ShadowDomManager;
21337 }();
21338 var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
21339 var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
21340 for(var i$1 = 0; i$1 < chars.length; i$1++){
21341 lookup[chars.charCodeAt(i$1)] = i$1;
21342 }
21343 var encode = function encode(arraybuffer) {
21344 var bytes = new Uint8Array(arraybuffer), i2, len = bytes.length, base64 = "";
21345 for(i2 = 0; i2 < len; i2 += 3){
21346 base64 += chars[bytes[i2] >> 2];
21347 base64 += chars[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4];
21348 base64 += chars[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6];
21349 base64 += chars[bytes[i2 + 2] & 63];
21350 }
21351 if (len % 3 === 2) {
21352 base64 = base64.substring(0, base64.length - 1) + "=";
21353 } else if (len % 3 === 1) {
21354 base64 = base64.substring(0, base64.length - 2) + "==";
21355 }
21356 return base64;
21357 };
21358 var canvasVarMap = /* @__PURE__ */ new Map();
21359 function variableListFor$1(ctx, ctor) {
21360 var contextMap = canvasVarMap.get(ctx);
21361 if (!contextMap) {
21362 contextMap = /* @__PURE__ */ new Map();
21363 canvasVarMap.set(ctx, contextMap);
21364 }
21365 if (!contextMap.has(ctor)) {
21366 contextMap.set(ctor, []);
21367 }
21368 return contextMap.get(ctor);
21369 }
21370 var saveWebGLVar = function(value, win, ctx) {
21371 if (!value || !(isInstanceOfWebGLObject(value, win) || (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object")) return;
21372 var name = value.constructor.name;
21373 var list2 = variableListFor$1(ctx, name);
21374 var index2 = list2.indexOf(value);
21375 if (index2 === -1) {
21376 index2 = list2.length;
21377 list2.push(value);
21378 }
21379 return index2;
21380 };
21381 function serializeArg(value, win, ctx) {
21382 if (_instanceof(value, Array)) {
21383 return value.map(function(arg) {
21384 return serializeArg(arg, win, ctx);
21385 });
21386 } else if (value === null) {
21387 return value;
21388 } 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)) {
21389 var name = value.constructor.name;
21390 return {
21391 rr_type: name,
21392 args: [
21393 Object.values(value)
21394 ]
21395 };
21396 } else if (// SharedArrayBuffer disabled on most browsers due to spectre.
21397 // More info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/SharedArrayBuffer
21398 // value instanceof SharedArrayBuffer ||
21399 _instanceof(value, ArrayBuffer)) {
21400 var name1 = value.constructor.name;
21401 var base64 = encode(value);
21402 return {
21403 rr_type: name1,
21404 base64: base64
21405 };
21406 } else if (_instanceof(value, DataView)) {
21407 var name2 = value.constructor.name;
21408 return {
21409 rr_type: name2,
21410 args: [
21411 serializeArg(value.buffer, win, ctx),
21412 value.byteOffset,
21413 value.byteLength
21414 ]
21415 };
21416 } else if (_instanceof(value, HTMLImageElement)) {
21417 var name3 = value.constructor.name;
21418 var src = value.src;
21419 return {
21420 rr_type: name3,
21421 src: src
21422 };
21423 } else if (_instanceof(value, HTMLCanvasElement)) {
21424 var name4 = "HTMLImageElement";
21425 var src1 = value.toDataURL();
21426 return {
21427 rr_type: name4,
21428 src: src1
21429 };
21430 } else if (_instanceof(value, ImageData)) {
21431 var name5 = value.constructor.name;
21432 return {
21433 rr_type: name5,
21434 args: [
21435 serializeArg(value.data, win, ctx),
21436 value.width,
21437 value.height
21438 ]
21439 };
21440 } else if (isInstanceOfWebGLObject(value, win) || (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object") {
21441 var name6 = value.constructor.name;
21442 var index2 = saveWebGLVar(value, win, ctx);
21443 return {
21444 rr_type: name6,
21445 index: index2
21446 };
21447 }
21448 return value;
21449 }
21450 var serializeArgs = function(args, win, ctx) {
21451 return args.map(function(arg) {
21452 return serializeArg(arg, win, ctx);
21453 });
21454 };
21455 var isInstanceOfWebGLObject = function(value, win) {
21456 var webGLConstructorNames = [
21457 "WebGLActiveInfo",
21458 "WebGLBuffer",
21459 "WebGLFramebuffer",
21460 "WebGLProgram",
21461 "WebGLRenderbuffer",
21462 "WebGLShader",
21463 "WebGLShaderPrecisionFormat",
21464 "WebGLTexture",
21465 "WebGLUniformLocation",
21466 "WebGLVertexArrayObject",
21467 // In old Chrome versions, value won't be an instanceof WebGLVertexArrayObject.
21468 "WebGLVertexArrayObjectOES"
21469 ];
21470 var supportedWebGLConstructorNames = webGLConstructorNames.filter(function(name) {
21471 return typeof win[name] === "function";
21472 });
21473 return Boolean(supportedWebGLConstructorNames.find(function(name) {
21474 return _instanceof(value, win[name]);
21475 }));
21476 };
21477 function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector) {
21478 var _loop = function() {
21479 var prop = _step.value;
21480 try {
21481 if (typeof win.CanvasRenderingContext2D.prototype[prop] !== "function") {
21482 return "continue";
21483 }
21484 var restoreHandler = patch(win.CanvasRenderingContext2D.prototype, prop, function(original) {
21485 return function() {
21486 var _this = this;
21487 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
21488 args[_key] = arguments[_key];
21489 }
21490 if (!isBlocked(this.canvas, blockClass, blockSelector, true)) {
21491 setTimeout(function() {
21492 var recordArgs = serializeArgs(args, win, _this);
21493 cb(_this.canvas, {
21494 type: CanvasContext["2D"],
21495 property: prop,
21496 args: recordArgs
21497 });
21498 }, 0);
21499 }
21500 return original.apply(this, args);
21501 };
21502 });
21503 handlers.push(restoreHandler);
21504 } catch (e) {
21505 var hookHandler = hookSetter(win.CanvasRenderingContext2D.prototype, prop, {
21506 set: function set(v2) {
21507 cb(this.canvas, {
21508 type: CanvasContext["2D"],
21509 property: prop,
21510 args: [
21511 v2
21512 ],
21513 setter: true
21514 });
21515 }
21516 });
21517 handlers.push(hookHandler);
21518 }
21519 };
21520 var handlers = [];
21521 var props2D = Object.getOwnPropertyNames(win.CanvasRenderingContext2D.prototype);
21522 for(var _iterator = _create_for_of_iterator_helper_loose(props2D), _step; !(_step = _iterator()).done;)_loop();
21523 return function() {
21524 handlers.forEach(function(h) {
21525 return h();
21526 });
21527 };
21528 }
21529 function getNormalizedContextName(contextType) {
21530 return contextType === "experimental-webgl" ? "webgl" : contextType;
21531 }
21532 function initCanvasContextObserver(win, blockClass, blockSelector, setPreserveDrawingBufferToTrue) {
21533 var handlers = [];
21534 try {
21535 var restoreHandler = patch(win.HTMLCanvasElement.prototype, "getContext", function(original) {
21536 return function(contextType) {
21537 for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
21538 args[_key - 1] = arguments[_key];
21539 }
21540 if (!isBlocked(this, blockClass, blockSelector, true)) {
21541 var ctxName = getNormalizedContextName(contextType);
21542 if (!("__context" in this)) this.__context = ctxName;
21543 if (setPreserveDrawingBufferToTrue && [
21544 "webgl",
21545 "webgl2"
21546 ].includes(ctxName)) {
21547 if (args[0] && _type_of(args[0]) === "object") {
21548 var contextAttributes = args[0];
21549 if (!contextAttributes.preserveDrawingBuffer) {
21550 contextAttributes.preserveDrawingBuffer = true;
21551 }
21552 } else {
21553 args.splice(0, 1, {
21554 preserveDrawingBuffer: true
21555 });
21556 }
21557 }
21558 }
21559 return original.apply(this, [].concat([
21560 contextType
21561 ], args));
21562 };
21563 });
21564 handlers.push(restoreHandler);
21565 } catch (e) {
21566 console.error("failed to patch HTMLCanvasElement.prototype.getContext");
21567 }
21568 return function() {
21569 handlers.forEach(function(h) {
21570 return h();
21571 });
21572 };
21573 }
21574 function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
21575 var _loop = function() {
21576 var prop = _step.value;
21577 if (//prop.startsWith('get') || // e.g. getProgramParameter, but too risky
21578 [
21579 "isContextLost",
21580 "canvas",
21581 "drawingBufferWidth",
21582 "drawingBufferHeight"
21583 ].includes(prop)) {
21584 return "continue";
21585 }
21586 try {
21587 if (typeof prototype[prop] !== "function") {
21588 return "continue";
21589 }
21590 var restoreHandler = patch(prototype, prop, function(original) {
21591 return function() {
21592 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
21593 args[_key] = arguments[_key];
21594 }
21595 var result2 = original.apply(this, args);
21596 saveWebGLVar(result2, win, this);
21597 if ("tagName" in this.canvas && !isBlocked(this.canvas, blockClass, blockSelector, true)) {
21598 var recordArgs = serializeArgs(args, win, this);
21599 var mutation = {
21600 type: type,
21601 property: prop,
21602 args: recordArgs
21603 };
21604 cb(this.canvas, mutation);
21605 }
21606 return result2;
21607 };
21608 });
21609 handlers.push(restoreHandler);
21610 } catch (e) {
21611 var hookHandler = hookSetter(prototype, prop, {
21612 set: function set(v2) {
21613 cb(this.canvas, {
21614 type: type,
21615 property: prop,
21616 args: [
21617 v2
21618 ],
21619 setter: true
21620 });
21621 }
21622 });
21623 handlers.push(hookHandler);
21624 }
21625 };
21626 var handlers = [];
21627 var props = Object.getOwnPropertyNames(prototype);
21628 for(var _iterator = _create_for_of_iterator_helper_loose(props), _step; !(_step = _iterator()).done;)_loop();
21629 return handlers;
21630 }
21631 function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
21632 var _handlers;
21633 var handlers = [];
21634 (_handlers = handlers).push.apply(_handlers, [].concat(patchGLPrototype(win.WebGLRenderingContext.prototype, CanvasContext.WebGL, cb, blockClass, blockSelector, win)));
21635 if (typeof win.WebGL2RenderingContext !== "undefined") {
21636 var _handlers1;
21637 (_handlers1 = handlers).push.apply(_handlers1, [].concat(patchGLPrototype(win.WebGL2RenderingContext.prototype, CanvasContext.WebGL2, cb, blockClass, blockSelector, win)));
21638 }
21639 return function() {
21640 handlers.forEach(function(h) {
21641 return h();
21642 });
21643 };
21644 }
21645 var encodedJs = "KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=";
21646 var decodeBase64 = function(base64) {
21647 return Uint8Array.from(atob(base64), function(c2) {
21648 return c2.charCodeAt(0);
21649 });
21650 };
21651 var blob = typeof window !== "undefined" && window.Blob && new Blob([
21652 decodeBase64(encodedJs)
21653 ], {
21654 type: "text/javascript;charset=utf-8"
21655 });
21656 function WorkerWrapper(options) {
21657 var objURL;
21658 try {
21659 objURL = blob && (window.URL || window.webkitURL).createObjectURL(blob);
21660 if (!objURL) throw "";
21661 var worker = new Worker(objURL, {
21662 name: options == null ? void 0 : options.name
21663 });
21664 worker.addEventListener("error", function() {
21665 (window.URL || window.webkitURL).revokeObjectURL(objURL);
21666 });
21667 return worker;
21668 } catch (e2) {
21669 return new Worker("data:text/javascript;base64," + encodedJs, {
21670 name: options == null ? void 0 : options.name
21671 });
21672 } finally{
21673 objURL && (window.URL || window.webkitURL).revokeObjectURL(objURL);
21674 }
21675 }
21676 var CanvasManager = /*#__PURE__*/ function() {
21677 function CanvasManager(options) {
21678 var _this = this;
21679 __publicField(this, "pendingCanvasMutations", /* @__PURE__ */ new Map());
21680 __publicField(this, "rafStamps", {
21681 latestId: 0,
21682 invokeId: null
21683 });
21684 __publicField(this, "mirror");
21685 __publicField(this, "mutationCb");
21686 __publicField(this, "resetObservers");
21687 __publicField(this, "frozen", false);
21688 __publicField(this, "locked", false);
21689 __publicField(this, "processMutation", function(target, mutation) {
21690 var newFrame = _this.rafStamps.invokeId && _this.rafStamps.latestId !== _this.rafStamps.invokeId;
21691 if (newFrame || !_this.rafStamps.invokeId) _this.rafStamps.invokeId = _this.rafStamps.latestId;
21692 if (!_this.pendingCanvasMutations.has(target)) {
21693 _this.pendingCanvasMutations.set(target, []);
21694 }
21695 _this.pendingCanvasMutations.get(target).push(mutation);
21696 });
21697 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;
21698 this.mutationCb = options.mutationCb;
21699 this.mirror = options.mirror;
21700 if (recordCanvas && sampling === "all") this.initCanvasMutationObserver(win, blockClass, blockSelector);
21701 if (recordCanvas && typeof sampling === "number") this.initCanvasFPSObserver(sampling, win, blockClass, blockSelector, {
21702 dataURLOptions: dataURLOptions
21703 });
21704 }
21705 var _proto = CanvasManager.prototype;
21706 _proto.reset = function reset() {
21707 this.pendingCanvasMutations.clear();
21708 this.resetObservers && this.resetObservers();
21709 };
21710 _proto.freeze = function freeze() {
21711 this.frozen = true;
21712 };
21713 _proto.unfreeze = function unfreeze() {
21714 this.frozen = false;
21715 };
21716 _proto.lock = function lock() {
21717 this.locked = true;
21718 };
21719 _proto.unlock = function unlock() {
21720 this.locked = false;
21721 };
21722 _proto.initCanvasFPSObserver = function initCanvasFPSObserver(fps, win, blockClass, blockSelector, options) {
21723 var _this = this;
21724 var canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, true);
21725 var snapshotInProgressMap = /* @__PURE__ */ new Map();
21726 var worker = new WorkerWrapper();
21727 worker.onmessage = function(e2) {
21728 var id = e2.data.id;
21729 snapshotInProgressMap.set(id, false);
21730 if (!("base64" in e2.data)) return;
21731 var _e2_data = e2.data, base64 = _e2_data.base64, type = _e2_data.type, width = _e2_data.width, height = _e2_data.height;
21732 _this.mutationCb({
21733 id: id,
21734 type: CanvasContext["2D"],
21735 commands: [
21736 {
21737 property: "clearRect",
21738 // wipe canvas
21739 args: [
21740 0,
21741 0,
21742 width,
21743 height
21744 ]
21745 },
21746 {
21747 property: "drawImage",
21748 // draws (semi-transparent) image
21749 args: [
21750 {
21751 rr_type: "ImageBitmap",
21752 args: [
21753 {
21754 rr_type: "Blob",
21755 data: [
21756 {
21757 rr_type: "ArrayBuffer",
21758 base64: base64
21759 }
21760 ],
21761 type: type
21762 }
21763 ]
21764 },
21765 0,
21766 0
21767 ]
21768 }
21769 ]
21770 });
21771 };
21772 var timeBetweenSnapshots = 1e3 / fps;
21773 var lastSnapshotTime = 0;
21774 var rafId;
21775 var getCanvas = function() {
21776 var matchedCanvas = [];
21777 win.document.querySelectorAll("canvas").forEach(function(canvas) {
21778 if (!isBlocked(canvas, blockClass, blockSelector, true)) {
21779 matchedCanvas.push(canvas);
21780 }
21781 });
21782 return matchedCanvas;
21783 };
21784 var takeCanvasSnapshots = function(timestamp) {
21785 if (lastSnapshotTime && timestamp - lastSnapshotTime < timeBetweenSnapshots) {
21786 rafId = requestAnimationFrame(takeCanvasSnapshots);
21787 return;
21788 }
21789 lastSnapshotTime = timestamp;
21790 var _this1 = _this;
21791 getCanvas().forEach(/*#__PURE__*/ _async_to_generator(function(canvas) {
21792 var _a2, id, context, bitmap;
21793 return _ts_generator(this, function(_state) {
21794 switch(_state.label){
21795 case 0:
21796 id = _this1.mirror.getId(canvas);
21797 if (snapshotInProgressMap.get(id)) return [
21798 2
21799 ];
21800 if (canvas.width === 0 || canvas.height === 0) return [
21801 2
21802 ];
21803 snapshotInProgressMap.set(id, true);
21804 if ([
21805 "webgl",
21806 "webgl2"
21807 ].includes(canvas.__context)) {
21808 context = canvas.getContext(canvas.__context);
21809 if (((_a2 = context == null ? void 0 : context.getContextAttributes()) == null ? void 0 : _a2.preserveDrawingBuffer) === false) {
21810 context.clear(context.COLOR_BUFFER_BIT);
21811 }
21812 }
21813 return [
21814 4,
21815 createImageBitmap(canvas)
21816 ];
21817 case 1:
21818 bitmap = _state.sent();
21819 worker.postMessage({
21820 id: id,
21821 bitmap: bitmap,
21822 width: canvas.width,
21823 height: canvas.height,
21824 dataURLOptions: options.dataURLOptions
21825 }, [
21826 bitmap
21827 ]);
21828 return [
21829 2
21830 ];
21831 }
21832 });
21833 }));
21834 rafId = requestAnimationFrame(takeCanvasSnapshots);
21835 };
21836 rafId = requestAnimationFrame(takeCanvasSnapshots);
21837 this.resetObservers = function() {
21838 canvasContextReset();
21839 cancelAnimationFrame(rafId);
21840 };
21841 };
21842 _proto.initCanvasMutationObserver = function initCanvasMutationObserver(win, blockClass, blockSelector) {
21843 this.startRAFTimestamping();
21844 this.startPendingCanvasMutationFlusher();
21845 var canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, false);
21846 var canvas2DReset = initCanvas2DMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector);
21847 var canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector);
21848 this.resetObservers = function() {
21849 canvasContextReset();
21850 canvas2DReset();
21851 canvasWebGL1and2Reset();
21852 };
21853 };
21854 _proto.startPendingCanvasMutationFlusher = function startPendingCanvasMutationFlusher() {
21855 var _this = this;
21856 requestAnimationFrame(function() {
21857 return _this.flushPendingCanvasMutations();
21858 });
21859 };
21860 _proto.startRAFTimestamping = function startRAFTimestamping() {
21861 var _this = this;
21862 var setLatestRAFTimestamp = function(timestamp) {
21863 _this.rafStamps.latestId = timestamp;
21864 requestAnimationFrame(setLatestRAFTimestamp);
21865 };
21866 requestAnimationFrame(setLatestRAFTimestamp);
21867 };
21868 _proto.flushPendingCanvasMutations = function flushPendingCanvasMutations() {
21869 var _this = this;
21870 this.pendingCanvasMutations.forEach(function(_values, canvas) {
21871 var id = _this.mirror.getId(canvas);
21872 _this.flushPendingCanvasMutationFor(canvas, id);
21873 });
21874 requestAnimationFrame(function() {
21875 return _this.flushPendingCanvasMutations();
21876 });
21877 };
21878 _proto.flushPendingCanvasMutationFor = function flushPendingCanvasMutationFor(canvas, id) {
21879 if (this.frozen || this.locked) {
21880 return;
21881 }
21882 var valuesWithType = this.pendingCanvasMutations.get(canvas);
21883 if (!valuesWithType || id === -1) return;
21884 var values = valuesWithType.map(function(value) {
21885 value.type; var rest = _object_without_properties_loose(value, [
21886 "type"
21887 ]);
21888 return rest;
21889 });
21890 var type = valuesWithType[0].type;
21891 this.mutationCb({
21892 id: id,
21893 type: type,
21894 commands: values
21895 });
21896 this.pendingCanvasMutations.delete(canvas);
21897 };
21898 return CanvasManager;
21899 }();
21900 var StylesheetManager = /*#__PURE__*/ function() {
21901 function StylesheetManager(options) {
21902 __publicField(this, "trackedLinkElements", /* @__PURE__ */ new WeakSet());
21903 __publicField(this, "mutationCb");
21904 __publicField(this, "adoptedStyleSheetCb");
21905 __publicField(this, "styleMirror", new StyleSheetMirror());
21906 this.mutationCb = options.mutationCb;
21907 this.adoptedStyleSheetCb = options.adoptedStyleSheetCb;
21908 }
21909 var _proto = StylesheetManager.prototype;
21910 _proto.attachLinkElement = function attachLinkElement(linkEl, childSn) {
21911 if ("_cssText" in childSn.attributes) this.mutationCb({
21912 adds: [],
21913 removes: [],
21914 texts: [],
21915 attributes: [
21916 {
21917 id: childSn.id,
21918 attributes: childSn.attributes
21919 }
21920 ]
21921 });
21922 this.trackLinkElement(linkEl);
21923 };
21924 _proto.trackLinkElement = function trackLinkElement(linkEl) {
21925 if (this.trackedLinkElements.has(linkEl)) return;
21926 this.trackedLinkElements.add(linkEl);
21927 this.trackStylesheetInLinkElement(linkEl);
21928 };
21929 _proto.adoptStyleSheets = function adoptStyleSheets(sheets, hostId) {
21930 var _this, _loop = function() {
21931 var sheet = _step.value;
21932 var styleId = void 0;
21933 if (!_this.styleMirror.has(sheet)) {
21934 styleId = _this.styleMirror.add(sheet);
21935 styles.push({
21936 styleId: styleId,
21937 rules: Array.from(sheet.rules || CSSRule, function(r2, index2) {
21938 return {
21939 rule: stringifyRule(r2, sheet.href),
21940 index: index2
21941 };
21942 })
21943 });
21944 } else styleId = _this.styleMirror.getId(sheet);
21945 adoptedStyleSheetData.styleIds.push(styleId);
21946 };
21947 if (sheets.length === 0) return;
21948 var adoptedStyleSheetData = {
21949 id: hostId,
21950 styleIds: []
21951 };
21952 var styles = [];
21953 for(var _iterator = _create_for_of_iterator_helper_loose(sheets), _step; !(_step = _iterator()).done;)_this = this, _loop();
21954 if (styles.length > 0) adoptedStyleSheetData.styles = styles;
21955 this.adoptedStyleSheetCb(adoptedStyleSheetData);
21956 };
21957 _proto.reset = function reset() {
21958 this.styleMirror.reset();
21959 this.trackedLinkElements = /* @__PURE__ */ new WeakSet();
21960 };
21961 // TODO: take snapshot on stylesheet reload by applying event listener
21962 _proto.trackStylesheetInLinkElement = function trackStylesheetInLinkElement(_linkEl) {};
21963 return StylesheetManager;
21964 }();
21965 var ProcessedNodeManager = /*#__PURE__*/ function() {
21966 function ProcessedNodeManager() {
21967 __publicField(this, "nodeMap", /* @__PURE__ */ new WeakMap());
21968 __publicField(this, "active", false);
21969 }
21970 var _proto = ProcessedNodeManager.prototype;
21971 _proto.inOtherBuffer = function inOtherBuffer(node2, thisBuffer) {
21972 var buffers = this.nodeMap.get(node2);
21973 return buffers && Array.from(buffers).some(function(buffer) {
21974 return buffer !== thisBuffer;
21975 });
21976 };
21977 _proto.add = function add(node2, buffer) {
21978 var _this = this;
21979 if (!this.active) {
21980 this.active = true;
21981 requestAnimationFrame(function() {
21982 _this.nodeMap = /* @__PURE__ */ new WeakMap();
21983 _this.active = false;
21984 });
21985 }
21986 this.nodeMap.set(node2, (this.nodeMap.get(node2) || /* @__PURE__ */ new Set()).add(buffer));
21987 };
21988 _proto.destroy = function destroy() {};
21989 return ProcessedNodeManager;
21990 }();
21991 var wrappedEmit;
21992 var takeFullSnapshot$1;
21993 var canvasManager;
21994 var recording = false;
21995 try {
21996 if (Array.from([
21997 1
21998 ], function(x2) {
21999 return x2 * 2;
22000 })[0] !== 2) {
22001 var cleanFrame = document.createElement("iframe");
22002 document.body.appendChild(cleanFrame);
22003 Array.from = ((_a = cleanFrame.contentWindow) == null ? void 0 : _a.Array.from) || Array.from;
22004 document.body.removeChild(cleanFrame);
22005 }
22006 } catch (err) {
22007 console.debug("Unable to override Array.from", err);
22008 }
22009 var mirror = createMirror$2();
22010 function record(options) {
22011 if (options === void 0) options = {};
22012 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() {
22013 return false;
22014 } : _options_keepIframeSrcFn, _options_ignoreCSSAttributes = options.ignoreCSSAttributes, ignoreCSSAttributes = _options_ignoreCSSAttributes === void 0 ? /* @__PURE__ */ new Set([]) : _options_ignoreCSSAttributes, errorHandler2 = options.errorHandler;
22015 registerErrorHandler(errorHandler2);
22016 var inEmittingFrame = recordCrossOriginIframes ? window.parent === window : true;
22017 var passEmitsToParent = false;
22018 if (!inEmittingFrame) {
22019 try {
22020 if (window.parent.document) {
22021 passEmitsToParent = false;
22022 }
22023 } catch (e2) {
22024 passEmitsToParent = true;
22025 }
22026 }
22027 if (inEmittingFrame && !emit) {
22028 throw new Error("emit function is required");
22029 }
22030 if (!inEmittingFrame && !passEmitsToParent) {
22031 return function() {};
22032 }
22033 if (mousemoveWait !== void 0 && sampling.mousemove === void 0) {
22034 sampling.mousemove = mousemoveWait;
22035 }
22036 mirror.reset();
22037 var maskInputOptions = maskAllInputs === true ? {
22038 color: true,
22039 date: true,
22040 "datetime-local": true,
22041 email: true,
22042 month: true,
22043 number: true,
22044 range: true,
22045 search: true,
22046 tel: true,
22047 text: true,
22048 time: true,
22049 url: true,
22050 week: true,
22051 textarea: true,
22052 select: true,
22053 password: true,
22054 hidden: true
22055 } : _maskInputOptions !== void 0 ? _maskInputOptions : {
22056 password: true
22057 };
22058 var slimDOMOptions = _slimDOMOptions === true || _slimDOMOptions === "all" ? {
22059 script: true,
22060 comment: true,
22061 headFavicon: true,
22062 headWhitespace: true,
22063 headMetaSocial: true,
22064 headMetaRobots: true,
22065 headMetaHttpEquiv: true,
22066 headMetaVerification: true,
22067 // the following are off for slimDOMOptions === true,
22068 // as they destroy some (hidden) info:
22069 headMetaAuthorship: _slimDOMOptions === "all",
22070 headMetaDescKeywords: _slimDOMOptions === "all",
22071 headTitleMutations: _slimDOMOptions === "all"
22072 } : _slimDOMOptions ? _slimDOMOptions : {};
22073 polyfill$1();
22074 var lastFullSnapshotEvent;
22075 var incrementalSnapshotCount = 0;
22076 var eventProcessor = function(e2) {
22077 for(var _iterator = _create_for_of_iterator_helper_loose(plugins || []), _step; !(_step = _iterator()).done;){
22078 var plugin3 = _step.value;
22079 if (plugin3.eventProcessor) {
22080 e2 = plugin3.eventProcessor(e2);
22081 }
22082 }
22083 if (packFn && // Disable packing events which will be emitted to parent frames.
22084 !passEmitsToParent) {
22085 e2 = packFn(e2);
22086 }
22087 return e2;
22088 };
22089 wrappedEmit = function(r2, isCheckout) {
22090 var _a2;
22091 var e2 = r2;
22092 e2.timestamp = nowTimestamp();
22093 if (((_a2 = mutationBuffers[0]) == null ? void 0 : _a2.isFrozen()) && e2.type !== EventType.FullSnapshot && !(e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.Mutation)) {
22094 mutationBuffers.forEach(function(buf) {
22095 return buf.unfreeze();
22096 });
22097 }
22098 if (inEmittingFrame) {
22099 emit == null ? void 0 : emit(eventProcessor(e2), isCheckout);
22100 } else if (passEmitsToParent) {
22101 var message = {
22102 type: "rrweb",
22103 event: eventProcessor(e2),
22104 origin: window.location.origin,
22105 isCheckout: isCheckout
22106 };
22107 window.parent.postMessage(message, "*");
22108 }
22109 if (e2.type === EventType.FullSnapshot) {
22110 lastFullSnapshotEvent = e2;
22111 incrementalSnapshotCount = 0;
22112 } else if (e2.type === EventType.IncrementalSnapshot) {
22113 if (e2.data.source === IncrementalSource.Mutation && e2.data.isAttachIframe) {
22114 return;
22115 }
22116 incrementalSnapshotCount++;
22117 var exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
22118 var exceedTime = checkoutEveryNms && e2.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
22119 if (exceedCount || exceedTime) {
22120 takeFullSnapshot$1(true);
22121 }
22122 }
22123 };
22124 var wrappedMutationEmit = function(m) {
22125 wrappedEmit({
22126 type: EventType.IncrementalSnapshot,
22127 data: _extends({
22128 source: IncrementalSource.Mutation
22129 }, m)
22130 });
22131 };
22132 var wrappedScrollEmit = function(p) {
22133 return wrappedEmit({
22134 type: EventType.IncrementalSnapshot,
22135 data: _extends({
22136 source: IncrementalSource.Scroll
22137 }, p)
22138 });
22139 };
22140 var wrappedCanvasMutationEmit = function(p) {
22141 return wrappedEmit({
22142 type: EventType.IncrementalSnapshot,
22143 data: _extends({
22144 source: IncrementalSource.CanvasMutation
22145 }, p)
22146 });
22147 };
22148 var wrappedAdoptedStyleSheetEmit = function(a2) {
22149 return wrappedEmit({
22150 type: EventType.IncrementalSnapshot,
22151 data: _extends({
22152 source: IncrementalSource.AdoptedStyleSheet
22153 }, a2)
22154 });
22155 };
22156 var stylesheetManager = new StylesheetManager({
22157 mutationCb: wrappedMutationEmit,
22158 adoptedStyleSheetCb: wrappedAdoptedStyleSheetEmit
22159 });
22160 var iframeManager = new IframeManager({
22161 mirror: mirror,
22162 mutationCb: wrappedMutationEmit,
22163 stylesheetManager: stylesheetManager,
22164 recordCrossOriginIframes: recordCrossOriginIframes,
22165 wrappedEmit: wrappedEmit
22166 });
22167 for(var _iterator = _create_for_of_iterator_helper_loose(plugins || []), _step; !(_step = _iterator()).done;){
22168 var plugin3 = _step.value;
22169 if (plugin3.getMirror) plugin3.getMirror({
22170 nodeMirror: mirror,
22171 crossOriginIframeMirror: iframeManager.crossOriginIframeMirror,
22172 crossOriginIframeStyleMirror: iframeManager.crossOriginIframeStyleMirror
22173 });
22174 }
22175 var processedNodeManager = new ProcessedNodeManager();
22176 canvasManager = new CanvasManager({
22177 recordCanvas: recordCanvas,
22178 mutationCb: wrappedCanvasMutationEmit,
22179 win: window,
22180 blockClass: blockClass,
22181 blockSelector: blockSelector,
22182 mirror: mirror,
22183 sampling: sampling.canvas,
22184 dataURLOptions: dataURLOptions
22185 });
22186 var shadowDomManager = new ShadowDomManager({
22187 mutationCb: wrappedMutationEmit,
22188 scrollCb: wrappedScrollEmit,
22189 bypassOptions: {
22190 blockClass: blockClass,
22191 blockSelector: blockSelector,
22192 maskTextClass: maskTextClass,
22193 maskTextSelector: maskTextSelector,
22194 inlineStylesheet: inlineStylesheet,
22195 maskInputOptions: maskInputOptions,
22196 dataURLOptions: dataURLOptions,
22197 maskTextFn: maskTextFn,
22198 maskInputFn: maskInputFn,
22199 recordCanvas: recordCanvas,
22200 inlineImages: inlineImages,
22201 sampling: sampling,
22202 slimDOMOptions: slimDOMOptions,
22203 iframeManager: iframeManager,
22204 stylesheetManager: stylesheetManager,
22205 canvasManager: canvasManager,
22206 keepIframeSrcFn: keepIframeSrcFn,
22207 processedNodeManager: processedNodeManager
22208 },
22209 mirror: mirror
22210 });
22211 takeFullSnapshot$1 = function(isCheckout) {
22212 if (isCheckout === void 0) isCheckout = false;
22213 if (!recordDOM) {
22214 return;
22215 }
22216 wrappedEmit({
22217 type: EventType.Meta,
22218 data: {
22219 href: window.location.href,
22220 width: getWindowWidth(),
22221 height: getWindowHeight()
22222 }
22223 }, isCheckout);
22224 stylesheetManager.reset();
22225 shadowDomManager.init();
22226 mutationBuffers.forEach(function(buf) {
22227 return buf.lock();
22228 });
22229 var node2 = snapshot(document, {
22230 mirror: mirror,
22231 blockClass: blockClass,
22232 blockSelector: blockSelector,
22233 maskTextClass: maskTextClass,
22234 maskTextSelector: maskTextSelector,
22235 inlineStylesheet: inlineStylesheet,
22236 maskAllInputs: maskInputOptions,
22237 maskTextFn: maskTextFn,
22238 maskInputFn: maskInputFn,
22239 slimDOM: slimDOMOptions,
22240 dataURLOptions: dataURLOptions,
22241 recordCanvas: recordCanvas,
22242 inlineImages: inlineImages,
22243 onSerialize: function(n2) {
22244 if (isSerializedIframe(n2, mirror)) {
22245 iframeManager.addIframe(n2);
22246 }
22247 if (isSerializedStylesheet(n2, mirror)) {
22248 stylesheetManager.trackLinkElement(n2);
22249 }
22250 if (hasShadowRoot(n2)) {
22251 shadowDomManager.addShadowRoot(index.shadowRoot(n2), document);
22252 }
22253 },
22254 onIframeLoad: function(iframe, childSn) {
22255 iframeManager.attachIframe(iframe, childSn);
22256 shadowDomManager.observeAttachShadow(iframe);
22257 },
22258 onStylesheetLoad: function(linkEl, childSn) {
22259 stylesheetManager.attachLinkElement(linkEl, childSn);
22260 },
22261 keepIframeSrcFn: keepIframeSrcFn
22262 });
22263 if (!node2) {
22264 return console.warn("Failed to snapshot the document");
22265 }
22266 wrappedEmit({
22267 type: EventType.FullSnapshot,
22268 data: {
22269 node: node2,
22270 initialOffset: getWindowScroll(window)
22271 }
22272 }, isCheckout);
22273 mutationBuffers.forEach(function(buf) {
22274 return buf.unlock();
22275 });
22276 if (document.adoptedStyleSheets && document.adoptedStyleSheets.length > 0) stylesheetManager.adoptStyleSheets(document.adoptedStyleSheets, mirror.getId(document));
22277 };
22278 try {
22279 var handlers = [];
22280 var observe = function(doc) {
22281 var _a2;
22282 return callbackWrapper(initObservers)({
22283 mutationCb: wrappedMutationEmit,
22284 mousemoveCb: function(positions, source) {
22285 return wrappedEmit({
22286 type: EventType.IncrementalSnapshot,
22287 data: {
22288 source: source,
22289 positions: positions
22290 }
22291 });
22292 },
22293 mouseInteractionCb: function(d) {
22294 return wrappedEmit({
22295 type: EventType.IncrementalSnapshot,
22296 data: _extends({
22297 source: IncrementalSource.MouseInteraction
22298 }, d)
22299 });
22300 },
22301 scrollCb: wrappedScrollEmit,
22302 viewportResizeCb: function(d) {
22303 return wrappedEmit({
22304 type: EventType.IncrementalSnapshot,
22305 data: _extends({
22306 source: IncrementalSource.ViewportResize
22307 }, d)
22308 });
22309 },
22310 inputCb: function(v2) {
22311 return wrappedEmit({
22312 type: EventType.IncrementalSnapshot,
22313 data: _extends({
22314 source: IncrementalSource.Input
22315 }, v2)
22316 });
22317 },
22318 mediaInteractionCb: function(p) {
22319 return wrappedEmit({
22320 type: EventType.IncrementalSnapshot,
22321 data: _extends({
22322 source: IncrementalSource.MediaInteraction
22323 }, p)
22324 });
22325 },
22326 styleSheetRuleCb: function(r2) {
22327 return wrappedEmit({
22328 type: EventType.IncrementalSnapshot,
22329 data: _extends({
22330 source: IncrementalSource.StyleSheetRule
22331 }, r2)
22332 });
22333 },
22334 styleDeclarationCb: function(r2) {
22335 return wrappedEmit({
22336 type: EventType.IncrementalSnapshot,
22337 data: _extends({
22338 source: IncrementalSource.StyleDeclaration
22339 }, r2)
22340 });
22341 },
22342 canvasMutationCb: wrappedCanvasMutationEmit,
22343 fontCb: function(p) {
22344 return wrappedEmit({
22345 type: EventType.IncrementalSnapshot,
22346 data: _extends({
22347 source: IncrementalSource.Font
22348 }, p)
22349 });
22350 },
22351 selectionCb: function(p) {
22352 wrappedEmit({
22353 type: EventType.IncrementalSnapshot,
22354 data: _extends({
22355 source: IncrementalSource.Selection
22356 }, p)
22357 });
22358 },
22359 customElementCb: function(c2) {
22360 wrappedEmit({
22361 type: EventType.IncrementalSnapshot,
22362 data: _extends({
22363 source: IncrementalSource.CustomElement
22364 }, c2)
22365 });
22366 },
22367 blockClass: blockClass,
22368 ignoreClass: ignoreClass,
22369 ignoreSelector: ignoreSelector,
22370 maskTextClass: maskTextClass,
22371 maskTextSelector: maskTextSelector,
22372 maskInputOptions: maskInputOptions,
22373 inlineStylesheet: inlineStylesheet,
22374 sampling: sampling,
22375 recordDOM: recordDOM,
22376 recordCanvas: recordCanvas,
22377 inlineImages: inlineImages,
22378 userTriggeredOnInput: userTriggeredOnInput,
22379 collectFonts: collectFonts,
22380 doc: doc,
22381 maskInputFn: maskInputFn,
22382 maskTextFn: maskTextFn,
22383 keepIframeSrcFn: keepIframeSrcFn,
22384 blockSelector: blockSelector,
22385 slimDOMOptions: slimDOMOptions,
22386 dataURLOptions: dataURLOptions,
22387 mirror: mirror,
22388 iframeManager: iframeManager,
22389 stylesheetManager: stylesheetManager,
22390 shadowDomManager: shadowDomManager,
22391 processedNodeManager: processedNodeManager,
22392 canvasManager: canvasManager,
22393 ignoreCSSAttributes: ignoreCSSAttributes,
22394 plugins: ((_a2 = plugins == null ? void 0 : plugins.filter(function(p) {
22395 return p.observer;
22396 })) == null ? void 0 : _a2.map(function(p) {
22397 return {
22398 observer: p.observer,
22399 options: p.options,
22400 callback: function(payload) {
22401 return wrappedEmit({
22402 type: EventType.Plugin,
22403 data: {
22404 plugin: p.name,
22405 payload: payload
22406 }
22407 });
22408 }
22409 };
22410 })) || []
22411 }, hooks);
22412 };
22413 iframeManager.addLoadListener(function(iframeEl) {
22414 try {
22415 handlers.push(observe(iframeEl.contentDocument));
22416 } catch (error) {
22417 console.warn(error);
22418 }
22419 });
22420 var init = function() {
22421 takeFullSnapshot$1();
22422 handlers.push(observe(document));
22423 recording = true;
22424 };
22425 if (document.readyState === "interactive" || document.readyState === "complete") {
22426 init();
22427 } else {
22428 handlers.push(on("DOMContentLoaded", function() {
22429 wrappedEmit({
22430 type: EventType.DomContentLoaded,
22431 data: {}
22432 });
22433 if (recordAfter === "DOMContentLoaded") init();
22434 }));
22435 handlers.push(on("load", function() {
22436 wrappedEmit({
22437 type: EventType.Load,
22438 data: {}
22439 });
22440 if (recordAfter === "load") init();
22441 }, window));
22442 }
22443 return function() {
22444 handlers.forEach(function(handler) {
22445 try {
22446 handler();
22447 } catch (error) {
22448 var msg = String(error).toLowerCase();
22449 if (!msg.includes("cross-origin")) {
22450 console.warn(error);
22451 }
22452 }
22453 });
22454 processedNodeManager.destroy();
22455 recording = false;
22456 unregisterErrorHandler();
22457 };
22458 } catch (error) {
22459 console.warn(error);
22460 }
22461 }
22462 record.addCustomEvent = function(tag, payload) {
22463 if (!recording) {
22464 throw new Error("please add custom event after start recording");
22465 }
22466 wrappedEmit({
22467 type: EventType.Custom,
22468 data: {
22469 tag: tag,
22470 payload: payload
22471 }
22472 });
22473 };
22474 record.freezePage = function() {
22475 mutationBuffers.forEach(function(buf) {
22476 return buf.freeze();
22477 });
22478 };
22479 record.takeFullSnapshot = function(isCheckout) {
22480 if (!recording) {
22481 throw new Error("please take full snapshot after start recording");
22482 }
22483 takeFullSnapshot$1(isCheckout);
22484 };
22485 record.mirror = mirror;
22486 var n;
22487 !function(t2) {
22488 t2[t2.NotStarted = 0] = "NotStarted", t2[t2.Running = 1] = "Running", t2[t2.Stopped = 2] = "Stopped";
22489 }(n || (n = {}));
22490 record.addCustomEvent;
22491 record.freezePage;
22492 record.takeFullSnapshot;
22493
22494 var setImmediate = win['setImmediate'];
22495 var builtInProp, cycle, schedulingQueue,
22496 ToString = Object.prototype.toString,
22497 timer = (typeof setImmediate !== 'undefined') ?
22498 function timer(fn) { return setImmediate(fn); } :
22499 setTimeout;
22500
22501 // dammit, IE8.
22502 try {
22503 Object.defineProperty({},'x',{});
22504 builtInProp = function builtInProp(obj,name,val,config) {
22505 return Object.defineProperty(obj,name,{
22506 value: val,
22507 writable: true,
22508 configurable: config !== false
22509 });
22510 };
22511 }
22512 catch (err) {
22513 builtInProp = function builtInProp(obj,name,val) {
22514 obj[name] = val;
22515 return obj;
22516 };
22517 }
22518
22519 // Note: using a queue instead of array for efficiency
22520 schedulingQueue = (function Queue() {
22521 var first, last, item;
22522
22523 function Item(fn,self) {
22524 this.fn = fn;
22525 this.self = self;
22526 this.next = void 0;
22527 }
22528
22529 return {
22530 add: function add(fn,self) {
22531 item = new Item(fn,self);
22532 if (last) {
22533 last.next = item;
22534 }
22535 else {
22536 first = item;
22537 }
22538 last = item;
22539 item = void 0;
22540 },
22541 drain: function drain() {
22542 var f = first;
22543 first = last = cycle = void 0;
22544
22545 while (f) {
22546 f.fn.call(f.self);
22547 f = f.next;
22548 }
22549 }
22550 };
22551 })();
22552
22553 function schedule(fn,self) {
22554 schedulingQueue.add(fn,self);
22555 if (!cycle) {
22556 cycle = timer(schedulingQueue.drain);
22557 }
22558 }
22559
22560 // promise duck typing
22561 function isThenable(o) {
22562 var _then, oType = typeof o;
22563
22564 if (o !== null && (oType === 'object' || oType === 'function')) {
22565 _then = o.then;
22566 }
22567 return typeof _then === 'function' ? _then : false;
22568 }
22569
22570 function notify() {
22571 for (var i=0; i<this.chain.length; i++) {
22572 notifyIsolated(
22573 this,
22574 (this.state === 1) ? this.chain[i].success : this.chain[i].failure,
22575 this.chain[i]
22576 );
22577 }
22578 this.chain.length = 0;
22579 }
22580
22581 // NOTE: This is a separate function to isolate
22582 // the `try..catch` so that other code can be
22583 // optimized better
22584 function notifyIsolated(self,cb,chain) {
22585 var ret, _then;
22586 try {
22587 if (cb === false) {
22588 chain.reject(self.msg);
22589 }
22590 else {
22591 if (cb === true) {
22592 ret = self.msg;
22593 }
22594 else {
22595 ret = cb.call(void 0,self.msg);
22596 }
22597
22598 if (ret === chain.promise) {
22599 chain.reject(TypeError('Promise-chain cycle'));
22600 }
22601 // eslint-disable-next-line no-cond-assign
22602 else if (_then = isThenable(ret)) {
22603 _then.call(ret,chain.resolve,chain.reject);
22604 }
22605 else {
22606 chain.resolve(ret);
22607 }
22608 }
22609 }
22610 catch (err) {
22611 chain.reject(err);
22612 }
22613 }
22614
22615 function resolve(msg) {
22616 var _then, self = this;
22617
22618 // already triggered?
22619 if (self.triggered) { return; }
22620
22621 self.triggered = true;
22622
22623 // unwrap
22624 if (self.def) {
22625 self = self.def;
22626 }
22627
22628 try {
22629 // eslint-disable-next-line no-cond-assign
22630 if (_then = isThenable(msg)) {
22631 schedule(function(){
22632 var defWrapper = new MakeDefWrapper(self);
22633 try {
22634 _then.call(msg,
22635 function $resolve$(){ resolve.apply(defWrapper,arguments); },
22636 function $reject$(){ reject.apply(defWrapper,arguments); }
22637 );
22638 }
22639 catch (err) {
22640 reject.call(defWrapper,err);
22641 }
22642 });
22643 }
22644 else {
22645 self.msg = msg;
22646 self.state = 1;
22647 if (self.chain.length > 0) {
22648 schedule(notify,self);
22649 }
22650 }
22651 }
22652 catch (err) {
22653 reject.call(new MakeDefWrapper(self),err);
22654 }
22655 }
22656
22657 function reject(msg) {
22658 var self = this;
22659
22660 // already triggered?
22661 if (self.triggered) { return; }
22662
22663 self.triggered = true;
22664
22665 // unwrap
22666 if (self.def) {
22667 self = self.def;
22668 }
22669
22670 self.msg = msg;
22671 self.state = 2;
22672 if (self.chain.length > 0) {
22673 schedule(notify,self);
22674 }
22675 }
22676
22677 function iteratePromises(Constructor,arr,resolver,rejecter) {
22678 for (var idx=0; idx<arr.length; idx++) {
22679 (function IIFE(idx){
22680 Constructor.resolve(arr[idx])
22681 .then(
22682 function $resolver$(msg){
22683 resolver(idx,msg);
22684 },
22685 rejecter
22686 );
22687 })(idx);
22688 }
22689 }
22690
22691 function MakeDefWrapper(self) {
22692 this.def = self;
22693 this.triggered = false;
22694 }
22695
22696 function MakeDef(self) {
22697 this.promise = self;
22698 this.state = 0;
22699 this.triggered = false;
22700 this.chain = [];
22701 this.msg = void 0;
22702 }
22703
22704 function NpoPromise(executor) {
22705 if (typeof executor !== 'function') {
22706 throw TypeError('Not a function');
22707 }
22708
22709 if (this['__NPO__'] !== 0) {
22710 throw TypeError('Not a promise');
22711 }
22712
22713 // instance shadowing the inherited "brand"
22714 // to signal an already "initialized" promise
22715 this['__NPO__'] = 1;
22716
22717 var def = new MakeDef(this);
22718
22719 this['then'] = function then(success,failure) {
22720 var o = {
22721 success: typeof success === 'function' ? success : true,
22722 failure: typeof failure === 'function' ? failure : false
22723 };
22724 // Note: `then(..)` itself can be borrowed to be used against
22725 // a different promise constructor for making the chained promise,
22726 // by substituting a different `this` binding.
22727 o.promise = new this.constructor(function extractChain(resolve,reject) {
22728 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22729 throw TypeError('Not a function');
22730 }
22731
22732 o.resolve = resolve;
22733 o.reject = reject;
22734 });
22735 def.chain.push(o);
22736
22737 if (def.state !== 0) {
22738 schedule(notify,def);
22739 }
22740
22741 return o.promise;
22742 };
22743 this['catch'] = function $catch$(failure) {
22744 return this.then(void 0,failure);
22745 };
22746
22747 try {
22748 executor.call(
22749 void 0,
22750 function publicResolve(msg){
22751 resolve.call(def,msg);
22752 },
22753 function publicReject(msg) {
22754 reject.call(def,msg);
22755 }
22756 );
22757 }
22758 catch (err) {
22759 reject.call(def,err);
22760 }
22761 }
22762
22763 var PromisePrototype = builtInProp({},'constructor',NpoPromise,
22764 /*configurable=*/false
22765 );
22766
22767 // Note: Android 4 cannot use `Object.defineProperty(..)` here
22768 NpoPromise.prototype = PromisePrototype;
22769
22770 // built-in "brand" to signal an "uninitialized" promise
22771 builtInProp(PromisePrototype,'__NPO__',0,
22772 /*configurable=*/false
22773 );
22774
22775 builtInProp(NpoPromise,'resolve',function Promise$resolve(msg) {
22776 var Constructor = this;
22777
22778 // spec mandated checks
22779 // note: best "isPromise" check that's practical for now
22780 if (msg && typeof msg === 'object' && msg['__NPO__'] === 1) {
22781 return msg;
22782 }
22783
22784 return new Constructor(function executor(resolve,reject){
22785 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22786 throw TypeError('Not a function');
22787 }
22788
22789 resolve(msg);
22790 });
22791 });
22792
22793 builtInProp(NpoPromise,'reject',function Promise$reject(msg) {
22794 return new this(function executor(resolve,reject){
22795 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22796 throw TypeError('Not a function');
22797 }
22798
22799 reject(msg);
22800 });
22801 });
22802
22803 builtInProp(NpoPromise,'all',function Promise$all(arr) {
22804 var Constructor = this;
22805
22806 // spec mandated checks
22807 if (ToString.call(arr) !== '[object Array]') {
22808 return Constructor.reject(TypeError('Not an array'));
22809 }
22810 if (arr.length === 0) {
22811 return Constructor.resolve([]);
22812 }
22813
22814 return new Constructor(function executor(resolve,reject){
22815 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22816 throw TypeError('Not a function');
22817 }
22818
22819 var len = arr.length, msgs = Array(len), count = 0;
22820
22821 iteratePromises(Constructor,arr,function resolver(idx,msg) {
22822 msgs[idx] = msg;
22823 if (++count === len) {
22824 resolve(msgs);
22825 }
22826 },reject);
22827 });
22828 });
22829
22830 builtInProp(NpoPromise,'race',function Promise$race(arr) {
22831 var Constructor = this;
22832
22833 // spec mandated checks
22834 if (ToString.call(arr) !== '[object Array]') {
22835 return Constructor.reject(TypeError('Not an array'));
22836 }
22837
22838 return new Constructor(function executor(resolve,reject){
22839 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22840 throw TypeError('Not a function');
22841 }
22842
22843 iteratePromises(Constructor,arr,function resolver(idx,msg){
22844 resolve(msg);
22845 },reject);
22846 });
22847 });
22848
22849 var PromisePolyfill;
22850 if (typeof Promise !== 'undefined' && Promise.toString().indexOf('[native code]') !== -1) {
22851 PromisePolyfill = Promise;
22852 } else {
22853 PromisePolyfill = NpoPromise;
22854 }
22855
22856 var Config = {
22857 DEBUG: false,
22858 LIB_VERSION: '2.71.1'
22859 };
22860
22861 /* eslint camelcase: "off", eqeqeq: "off" */
22862
22863 // Maximum allowed session recording length
22864 var MAX_RECORDING_MS = 24 * 60 * 60 * 1000; // 24 hours
22865 // Maximum allowed value for minimum session recording length
22866 var MAX_VALUE_FOR_MIN_RECORDING_MS = 8 * 1000; // 8 seconds
22867
22868 /*
22869 * Saved references to long variable names, so that closure compiler can
22870 * minimize file size.
22871 */
22872
22873 var ArrayProto = Array.prototype,
22874 FuncProto = Function.prototype,
22875 ObjProto = Object.prototype,
22876 slice = ArrayProto.slice,
22877 toString = ObjProto.toString,
22878 hasOwnProperty = ObjProto.hasOwnProperty,
22879 windowConsole = win.console,
22880 navigator = win.navigator,
22881 document$1 = win.document,
22882 windowOpera = win.opera,
22883 screen = win.screen,
22884 userAgent = navigator.userAgent;
22885
22886 var nativeBind = FuncProto.bind,
22887 nativeForEach = ArrayProto.forEach,
22888 nativeIndexOf = ArrayProto.indexOf,
22889 nativeMap = ArrayProto.map,
22890 nativeIsArray = Array.isArray,
22891 breaker = {};
22892
22893 var _ = {
22894 trim: function(str) {
22895 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
22896 return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
22897 }
22898 };
22899
22900 // Console override
22901 var console$1 = {
22902 /** @type {function(...*)} */
22903 log: function() {
22904 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22905 try {
22906 windowConsole.log.apply(windowConsole, arguments);
22907 } catch (err) {
22908 _.each(arguments, function(arg) {
22909 windowConsole.log(arg);
22910 });
22911 }
22912 }
22913 },
22914 /** @type {function(...*)} */
22915 warn: function() {
22916 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22917 var args = ['Mixpanel warning:'].concat(_.toArray(arguments));
22918 try {
22919 windowConsole.warn.apply(windowConsole, args);
22920 } catch (err) {
22921 _.each(args, function(arg) {
22922 windowConsole.warn(arg);
22923 });
22924 }
22925 }
22926 },
22927 /** @type {function(...*)} */
22928 error: function() {
22929 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22930 var args = ['Mixpanel error:'].concat(_.toArray(arguments));
22931 try {
22932 windowConsole.error.apply(windowConsole, args);
22933 } catch (err) {
22934 _.each(args, function(arg) {
22935 windowConsole.error(arg);
22936 });
22937 }
22938 }
22939 },
22940 /** @type {function(...*)} */
22941 critical: function() {
22942 if (!_.isUndefined(windowConsole) && windowConsole) {
22943 var args = ['Mixpanel error:'].concat(_.toArray(arguments));
22944 try {
22945 windowConsole.error.apply(windowConsole, args);
22946 } catch (err) {
22947 _.each(args, function(arg) {
22948 windowConsole.error(arg);
22949 });
22950 }
22951 }
22952 }
22953 };
22954
22955 var log_func_with_prefix = function(func, prefix) {
22956 return function() {
22957 arguments[0] = '[' + prefix + '] ' + arguments[0];
22958 return func.apply(console$1, arguments);
22959 };
22960 };
22961 var console_with_prefix = function(prefix) {
22962 return {
22963 log: log_func_with_prefix(console$1.log, prefix),
22964 error: log_func_with_prefix(console$1.error, prefix),
22965 critical: log_func_with_prefix(console$1.critical, prefix)
22966 };
22967 };
22968
22969
22970 var safewrap = function(f) {
22971 return function() {
22972 try {
22973 return f.apply(this, arguments);
22974 } catch (e) {
22975 console$1.critical('Implementation error. Please turn on debug and contact support@mixpanel.com.');
22976 if (Config.DEBUG){
22977 console$1.critical(e);
22978 }
22979 }
22980 };
22981 };
22982
22983 var safewrapClass = function(klass) {
22984 var proto = klass.prototype;
22985 for (var func in proto) {
22986 if (typeof(proto[func]) === 'function') {
22987 proto[func] = safewrap(proto[func]);
22988 }
22989 }
22990 };
22991
22992
22993 // UNDERSCORE
22994 // Embed part of the Underscore Library
22995 _.bind = function(func, context) {
22996 var args, bound;
22997 if (nativeBind && func.bind === nativeBind) {
22998 return nativeBind.apply(func, slice.call(arguments, 1));
22999 }
23000 if (!_.isFunction(func)) {
23001 throw new TypeError();
23002 }
23003 args = slice.call(arguments, 2);
23004 bound = function() {
23005 if (!(this instanceof bound)) {
23006 return func.apply(context, args.concat(slice.call(arguments)));
23007 }
23008 var ctor = {};
23009 ctor.prototype = func.prototype;
23010 var self = new ctor();
23011 ctor.prototype = null;
23012 var result = func.apply(self, args.concat(slice.call(arguments)));
23013 if (Object(result) === result) {
23014 return result;
23015 }
23016 return self;
23017 };
23018 return bound;
23019 };
23020
23021 /**
23022 * @param {*=} obj
23023 * @param {function(...*)=} iterator
23024 * @param {Object=} context
23025 */
23026 _.each = function(obj, iterator, context) {
23027 if (obj === null || obj === undefined) {
23028 return;
23029 }
23030 if (nativeForEach && obj.forEach === nativeForEach) {
23031 obj.forEach(iterator, context);
23032 } else if (obj.length === +obj.length) {
23033 for (var i = 0, l = obj.length; i < l; i++) {
23034 if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) {
23035 return;
23036 }
23037 }
23038 } else {
23039 for (var key in obj) {
23040 if (hasOwnProperty.call(obj, key)) {
23041 if (iterator.call(context, obj[key], key, obj) === breaker) {
23042 return;
23043 }
23044 }
23045 }
23046 }
23047 };
23048
23049 _.extend = function(obj) {
23050 _.each(slice.call(arguments, 1), function(source) {
23051 for (var prop in source) {
23052 if (source[prop] !== void 0) {
23053 obj[prop] = source[prop];
23054 }
23055 }
23056 });
23057 return obj;
23058 };
23059
23060 _.isArray = nativeIsArray || function(obj) {
23061 return toString.call(obj) === '[object Array]';
23062 };
23063
23064 // from a comment on http://dbj.org/dbj/?p=286
23065 // fails on only one very rare and deliberate custom object:
23066 // var bomb = { toString : undefined, valueOf: function(o) { return "function BOMBA!"; }};
23067 _.isFunction = function(f) {
23068 try {
23069 return /^\s*\bfunction\b/.test(f);
23070 } catch (x) {
23071 return false;
23072 }
23073 };
23074
23075 _.isArguments = function(obj) {
23076 return !!(obj && hasOwnProperty.call(obj, 'callee'));
23077 };
23078
23079 _.toArray = function(iterable) {
23080 if (!iterable) {
23081 return [];
23082 }
23083 if (iterable.toArray) {
23084 return iterable.toArray();
23085 }
23086 if (_.isArray(iterable)) {
23087 return slice.call(iterable);
23088 }
23089 if (_.isArguments(iterable)) {
23090 return slice.call(iterable);
23091 }
23092 return _.values(iterable);
23093 };
23094
23095 _.map = function(arr, callback, context) {
23096 if (nativeMap && arr.map === nativeMap) {
23097 return arr.map(callback, context);
23098 } else {
23099 var results = [];
23100 _.each(arr, function(item) {
23101 results.push(callback.call(context, item));
23102 });
23103 return results;
23104 }
23105 };
23106
23107 _.keys = function(obj) {
23108 var results = [];
23109 if (obj === null) {
23110 return results;
23111 }
23112 _.each(obj, function(value, key) {
23113 results[results.length] = key;
23114 });
23115 return results;
23116 };
23117
23118 _.values = function(obj) {
23119 var results = [];
23120 if (obj === null) {
23121 return results;
23122 }
23123 _.each(obj, function(value) {
23124 results[results.length] = value;
23125 });
23126 return results;
23127 };
23128
23129 _.include = function(obj, target) {
23130 var found = false;
23131 if (obj === null) {
23132 return found;
23133 }
23134 if (nativeIndexOf && obj.indexOf === nativeIndexOf) {
23135 return obj.indexOf(target) != -1;
23136 }
23137 _.each(obj, function(value) {
23138 if (found || (found = (value === target))) {
23139 return breaker;
23140 }
23141 });
23142 return found;
23143 };
23144
23145 _.includes = function(str, needle) {
23146 return str.indexOf(needle) !== -1;
23147 };
23148
23149 // Underscore Addons
23150 _.inherit = function(subclass, superclass) {
23151 subclass.prototype = new superclass();
23152 subclass.prototype.constructor = subclass;
23153 subclass.superclass = superclass.prototype;
23154 return subclass;
23155 };
23156
23157 _.isObject = function(obj) {
23158 return (obj === Object(obj) && !_.isArray(obj));
23159 };
23160
23161 _.isEmptyObject = function(obj) {
23162 if (_.isObject(obj)) {
23163 for (var key in obj) {
23164 if (hasOwnProperty.call(obj, key)) {
23165 return false;
23166 }
23167 }
23168 return true;
23169 }
23170 return false;
23171 };
23172
23173 _.isUndefined = function(obj) {
23174 return obj === void 0;
23175 };
23176
23177 _.isString = function(obj) {
23178 return toString.call(obj) == '[object String]';
23179 };
23180
23181 _.isDate = function(obj) {
23182 return toString.call(obj) == '[object Date]';
23183 };
23184
23185 _.isNumber = function(obj) {
23186 return toString.call(obj) == '[object Number]';
23187 };
23188
23189 _.isElement = function(obj) {
23190 return !!(obj && obj.nodeType === 1);
23191 };
23192
23193 _.encodeDates = function(obj) {
23194 _.each(obj, function(v, k) {
23195 if (_.isDate(v)) {
23196 obj[k] = _.formatDate(v);
23197 } else if (_.isObject(v)) {
23198 obj[k] = _.encodeDates(v); // recurse
23199 }
23200 });
23201 return obj;
23202 };
23203
23204 _.timestamp = function() {
23205 Date.now = Date.now || function() {
23206 return +new Date;
23207 };
23208 return Date.now();
23209 };
23210
23211 _.formatDate = function(d) {
23212 // YYYY-MM-DDTHH:MM:SS in UTC
23213 function pad(n) {
23214 return n < 10 ? '0' + n : n;
23215 }
23216 return d.getUTCFullYear() + '-' +
23217 pad(d.getUTCMonth() + 1) + '-' +
23218 pad(d.getUTCDate()) + 'T' +
23219 pad(d.getUTCHours()) + ':' +
23220 pad(d.getUTCMinutes()) + ':' +
23221 pad(d.getUTCSeconds());
23222 };
23223
23224 _.strip_empty_properties = function(p) {
23225 var ret = {};
23226 _.each(p, function(v, k) {
23227 if (_.isString(v) && v.length > 0) {
23228 ret[k] = v;
23229 }
23230 });
23231 return ret;
23232 };
23233
23234 /*
23235 * this function returns a copy of object after truncating it. If
23236 * passed an Array or Object it will iterate through obj and
23237 * truncate all the values recursively.
23238 */
23239 _.truncate = function(obj, length) {
23240 var ret;
23241
23242 if (typeof(obj) === 'string') {
23243 ret = obj.slice(0, length);
23244 } else if (_.isArray(obj)) {
23245 ret = [];
23246 _.each(obj, function(val) {
23247 ret.push(_.truncate(val, length));
23248 });
23249 } else if (_.isObject(obj)) {
23250 ret = {};
23251 _.each(obj, function(val, key) {
23252 ret[key] = _.truncate(val, length);
23253 });
23254 } else {
23255 ret = obj;
23256 }
23257
23258 return ret;
23259 };
23260
23261 _.JSONEncode = (function() {
23262 return function(mixed_val) {
23263 var value = mixed_val;
23264 var quote = function(string) {
23265 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
23266 var meta = { // table of character substitutions
23267 '\b': '\\b',
23268 '\t': '\\t',
23269 '\n': '\\n',
23270 '\f': '\\f',
23271 '\r': '\\r',
23272 '"': '\\"',
23273 '\\': '\\\\'
23274 };
23275
23276 escapable.lastIndex = 0;
23277 return escapable.test(string) ?
23278 '"' + string.replace(escapable, function(a) {
23279 var c = meta[a];
23280 return typeof c === 'string' ? c :
23281 '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
23282 }) + '"' :
23283 '"' + string + '"';
23284 };
23285
23286 var str = function(key, holder) {
23287 var gap = '';
23288 var indent = ' ';
23289 var i = 0; // The loop counter.
23290 var k = ''; // The member key.
23291 var v = ''; // The member value.
23292 var length = 0;
23293 var mind = gap;
23294 var partial = [];
23295 var value = holder[key];
23296
23297 // If the value has a toJSON method, call it to obtain a replacement value.
23298 if (value && typeof value === 'object' &&
23299 typeof value.toJSON === 'function') {
23300 value = value.toJSON(key);
23301 }
23302
23303 // What happens next depends on the value's type.
23304 switch (typeof value) {
23305 case 'string':
23306 return quote(value);
23307
23308 case 'number':
23309 // JSON numbers must be finite. Encode non-finite numbers as null.
23310 return isFinite(value) ? String(value) : 'null';
23311
23312 case 'boolean':
23313 case 'null':
23314 // If the value is a boolean or null, convert it to a string. Note:
23315 // typeof null does not produce 'null'. The case is included here in
23316 // the remote chance that this gets fixed someday.
23317
23318 return String(value);
23319
23320 case 'object':
23321 // If the type is 'object', we might be dealing with an object or an array or
23322 // null.
23323 // Due to a specification blunder in ECMAScript, typeof null is 'object',
23324 // so watch out for that case.
23325 if (!value) {
23326 return 'null';
23327 }
23328
23329 // Make an array to hold the partial results of stringifying this object value.
23330 gap += indent;
23331 partial = [];
23332
23333 // Is the value an array?
23334 if (toString.apply(value) === '[object Array]') {
23335 // The value is an array. Stringify every element. Use null as a placeholder
23336 // for non-JSON values.
23337
23338 length = value.length;
23339 for (i = 0; i < length; i += 1) {
23340 partial[i] = str(i, value) || 'null';
23341 }
23342
23343 // Join all of the elements together, separated with commas, and wrap them in
23344 // brackets.
23345 v = partial.length === 0 ? '[]' :
23346 gap ? '[\n' + gap +
23347 partial.join(',\n' + gap) + '\n' +
23348 mind + ']' :
23349 '[' + partial.join(',') + ']';
23350 gap = mind;
23351 return v;
23352 }
23353
23354 // Iterate through all of the keys in the object.
23355 for (k in value) {
23356 if (hasOwnProperty.call(value, k)) {
23357 v = str(k, value);
23358 if (v) {
23359 partial.push(quote(k) + (gap ? ': ' : ':') + v);
23360 }
23361 }
23362 }
23363
23364 // Join all of the member texts together, separated with commas,
23365 // and wrap them in braces.
23366 v = partial.length === 0 ? '{}' :
23367 gap ? '{' + partial.join(',') + '' +
23368 mind + '}' : '{' + partial.join(',') + '}';
23369 gap = mind;
23370 return v;
23371 }
23372 };
23373
23374 // Make a fake root object containing our value under the key of ''.
23375 // Return the result of stringifying the value.
23376 return str('', {
23377 '': value
23378 });
23379 };
23380 })();
23381
23382 /**
23383 * From https://github.com/douglascrockford/JSON-js/blob/master/json_parse.js
23384 * Slightly modified to throw a real Error rather than a POJO
23385 */
23386 _.JSONDecode = (function() {
23387 var at, // The index of the current character
23388 ch, // The current character
23389 escapee = {
23390 '"': '"',
23391 '\\': '\\',
23392 '/': '/',
23393 'b': '\b',
23394 'f': '\f',
23395 'n': '\n',
23396 'r': '\r',
23397 't': '\t'
23398 },
23399 text,
23400 error = function(m) {
23401 var e = new SyntaxError(m);
23402 e.at = at;
23403 e.text = text;
23404 throw e;
23405 },
23406 next = function(c) {
23407 // If a c parameter is provided, verify that it matches the current character.
23408 if (c && c !== ch) {
23409 error('Expected \'' + c + '\' instead of \'' + ch + '\'');
23410 }
23411 // Get the next character. When there are no more characters,
23412 // return the empty string.
23413 ch = text.charAt(at);
23414 at += 1;
23415 return ch;
23416 },
23417 number = function() {
23418 // Parse a number value.
23419 var number,
23420 string = '';
23421
23422 if (ch === '-') {
23423 string = '-';
23424 next('-');
23425 }
23426 while (ch >= '0' && ch <= '9') {
23427 string += ch;
23428 next();
23429 }
23430 if (ch === '.') {
23431 string += '.';
23432 while (next() && ch >= '0' && ch <= '9') {
23433 string += ch;
23434 }
23435 }
23436 if (ch === 'e' || ch === 'E') {
23437 string += ch;
23438 next();
23439 if (ch === '-' || ch === '+') {
23440 string += ch;
23441 next();
23442 }
23443 while (ch >= '0' && ch <= '9') {
23444 string += ch;
23445 next();
23446 }
23447 }
23448 number = +string;
23449 if (!isFinite(number)) {
23450 error('Bad number');
23451 } else {
23452 return number;
23453 }
23454 },
23455
23456 string = function() {
23457 // Parse a string value.
23458 var hex,
23459 i,
23460 string = '',
23461 uffff;
23462 // When parsing for string values, we must look for " and \ characters.
23463 if (ch === '"') {
23464 while (next()) {
23465 if (ch === '"') {
23466 next();
23467 return string;
23468 }
23469 if (ch === '\\') {
23470 next();
23471 if (ch === 'u') {
23472 uffff = 0;
23473 for (i = 0; i < 4; i += 1) {
23474 hex = parseInt(next(), 16);
23475 if (!isFinite(hex)) {
23476 break;
23477 }
23478 uffff = uffff * 16 + hex;
23479 }
23480 string += String.fromCharCode(uffff);
23481 } else if (typeof escapee[ch] === 'string') {
23482 string += escapee[ch];
23483 } else {
23484 break;
23485 }
23486 } else {
23487 string += ch;
23488 }
23489 }
23490 }
23491 error('Bad string');
23492 },
23493 white = function() {
23494 // Skip whitespace.
23495 while (ch && ch <= ' ') {
23496 next();
23497 }
23498 },
23499 word = function() {
23500 // true, false, or null.
23501 switch (ch) {
23502 case 't':
23503 next('t');
23504 next('r');
23505 next('u');
23506 next('e');
23507 return true;
23508 case 'f':
23509 next('f');
23510 next('a');
23511 next('l');
23512 next('s');
23513 next('e');
23514 return false;
23515 case 'n':
23516 next('n');
23517 next('u');
23518 next('l');
23519 next('l');
23520 return null;
23521 }
23522 error('Unexpected "' + ch + '"');
23523 },
23524 value, // Placeholder for the value function.
23525 array = function() {
23526 // Parse an array value.
23527 var array = [];
23528
23529 if (ch === '[') {
23530 next('[');
23531 white();
23532 if (ch === ']') {
23533 next(']');
23534 return array; // empty array
23535 }
23536 while (ch) {
23537 array.push(value());
23538 white();
23539 if (ch === ']') {
23540 next(']');
23541 return array;
23542 }
23543 next(',');
23544 white();
23545 }
23546 }
23547 error('Bad array');
23548 },
23549 object = function() {
23550 // Parse an object value.
23551 var key,
23552 object = {};
23553
23554 if (ch === '{') {
23555 next('{');
23556 white();
23557 if (ch === '}') {
23558 next('}');
23559 return object; // empty object
23560 }
23561 while (ch) {
23562 key = string();
23563 white();
23564 next(':');
23565 if (Object.hasOwnProperty.call(object, key)) {
23566 error('Duplicate key "' + key + '"');
23567 }
23568 object[key] = value();
23569 white();
23570 if (ch === '}') {
23571 next('}');
23572 return object;
23573 }
23574 next(',');
23575 white();
23576 }
23577 }
23578 error('Bad object');
23579 };
23580
23581 value = function() {
23582 // Parse a JSON value. It could be an object, an array, a string,
23583 // a number, or a word.
23584 white();
23585 switch (ch) {
23586 case '{':
23587 return object();
23588 case '[':
23589 return array();
23590 case '"':
23591 return string();
23592 case '-':
23593 return number();
23594 default:
23595 return ch >= '0' && ch <= '9' ? number() : word();
23596 }
23597 };
23598
23599 // Return the json_parse function. It will have access to all of the
23600 // above functions and variables.
23601 return function(source) {
23602 var result;
23603
23604 text = source;
23605 at = 0;
23606 ch = ' ';
23607 result = value();
23608 white();
23609 if (ch) {
23610 error('Syntax error');
23611 }
23612
23613 return result;
23614 };
23615 })();
23616
23617 _.base64Encode = function(data) {
23618 var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
23619 var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
23620 ac = 0,
23621 enc = '',
23622 tmp_arr = [];
23623
23624 if (!data) {
23625 return data;
23626 }
23627
23628 data = _.utf8Encode(data);
23629
23630 do { // pack three octets into four hexets
23631 o1 = data.charCodeAt(i++);
23632 o2 = data.charCodeAt(i++);
23633 o3 = data.charCodeAt(i++);
23634
23635 bits = o1 << 16 | o2 << 8 | o3;
23636
23637 h1 = bits >> 18 & 0x3f;
23638 h2 = bits >> 12 & 0x3f;
23639 h3 = bits >> 6 & 0x3f;
23640 h4 = bits & 0x3f;
23641
23642 // use hexets to index into b64, and append result to encoded string
23643 tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
23644 } while (i < data.length);
23645
23646 enc = tmp_arr.join('');
23647
23648 switch (data.length % 3) {
23649 case 1:
23650 enc = enc.slice(0, -2) + '==';
23651 break;
23652 case 2:
23653 enc = enc.slice(0, -1) + '=';
23654 break;
23655 }
23656
23657 return enc;
23658 };
23659
23660 _.utf8Encode = function(string) {
23661 string = (string + '').replace(/\r\n/g, '\n').replace(/\r/g, '\n');
23662
23663 var utftext = '',
23664 start,
23665 end;
23666 var stringl = 0,
23667 n;
23668
23669 start = end = 0;
23670 stringl = string.length;
23671
23672 for (n = 0; n < stringl; n++) {
23673 var c1 = string.charCodeAt(n);
23674 var enc = null;
23675
23676 if (c1 < 128) {
23677 end++;
23678 } else if ((c1 > 127) && (c1 < 2048)) {
23679 enc = String.fromCharCode((c1 >> 6) | 192, (c1 & 63) | 128);
23680 } else {
23681 enc = String.fromCharCode((c1 >> 12) | 224, ((c1 >> 6) & 63) | 128, (c1 & 63) | 128);
23682 }
23683 if (enc !== null) {
23684 if (end > start) {
23685 utftext += string.substring(start, end);
23686 }
23687 utftext += enc;
23688 start = end = n + 1;
23689 }
23690 }
23691
23692 if (end > start) {
23693 utftext += string.substring(start, string.length);
23694 }
23695
23696 return utftext;
23697 };
23698
23699 _.UUID = function() {
23700 try {
23701 // use native Crypto API when available
23702 return win['crypto']['randomUUID']();
23703 } catch (err) {
23704 // fall back to generating our own UUID
23705 // based on https://gist.github.com/scwood/3bff42cc005cc20ab7ec98f0d8e1d59d
23706 var uuid = new Array(36);
23707 for (var i = 0; i < 36; i++) {
23708 uuid[i] = Math.floor(Math.random() * 16);
23709 }
23710 uuid[14] = 4; // set bits 12-15 of time-high-and-version to 0100
23711 uuid[19] = uuid[19] &= -5; // set bit 6 of clock-seq-and-reserved to zero
23712 uuid[19] = uuid[19] |= (1 << 3); // set bit 7 of clock-seq-and-reserved to one
23713 uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
23714
23715 return _.map(uuid, function(x) {
23716 return x.toString(16);
23717 }).join('');
23718 }
23719 };
23720
23721 // _.isBlockedUA()
23722 // This is to block various web spiders from executing our JS and
23723 // sending false tracking data
23724 var BLOCKED_UA_STRS = [
23725 'ahrefsbot',
23726 'ahrefssiteaudit',
23727 'amazonbot',
23728 'baiduspider',
23729 'bingbot',
23730 'bingpreview',
23731 'chrome-lighthouse',
23732 'facebookexternal',
23733 'petalbot',
23734 'pinterest',
23735 'screaming frog',
23736 'yahoo! slurp',
23737 'yandex',
23738
23739 // a whole bunch of goog-specific crawlers
23740 // https://developers.google.com/search/docs/advanced/crawling/overview-google-crawlers
23741 'adsbot-google',
23742 'apis-google',
23743 'duplexweb-google',
23744 'feedfetcher-google',
23745 'google favicon',
23746 'google web preview',
23747 'google-read-aloud',
23748 'googlebot',
23749 'googleweblight',
23750 'mediapartners-google',
23751 'storebot-google'
23752 ];
23753 _.isBlockedUA = function(ua) {
23754 var i;
23755 ua = ua.toLowerCase();
23756 for (i = 0; i < BLOCKED_UA_STRS.length; i++) {
23757 if (ua.indexOf(BLOCKED_UA_STRS[i]) !== -1) {
23758 return true;
23759 }
23760 }
23761 return false;
23762 };
23763
23764 /**
23765 * @param {Object=} formdata
23766 * @param {string=} arg_separator
23767 */
23768 _.HTTPBuildQuery = function(formdata, arg_separator) {
23769 var use_val, use_key, tmp_arr = [];
23770
23771 if (_.isUndefined(arg_separator)) {
23772 arg_separator = '&';
23773 }
23774
23775 _.each(formdata, function(val, key) {
23776 use_val = encodeURIComponent(val.toString());
23777 use_key = encodeURIComponent(key);
23778 tmp_arr[tmp_arr.length] = use_key + '=' + use_val;
23779 });
23780
23781 return tmp_arr.join(arg_separator);
23782 };
23783
23784 _.getQueryParam = function(url, param) {
23785 // Expects a raw URL
23786
23787 param = param.replace(/[[]/g, '\\[').replace(/[\]]/g, '\\]');
23788 var regexS = '[\\?&]' + param + '=([^&#]*)',
23789 regex = new RegExp(regexS),
23790 results = regex.exec(url);
23791 if (results === null || (results && typeof(results[1]) !== 'string' && results[1].length)) {
23792 return '';
23793 } else {
23794 var result = results[1];
23795 try {
23796 result = decodeURIComponent(result);
23797 } catch(err) {
23798 console$1.error('Skipping decoding for malformed query param: ' + result);
23799 }
23800 return result.replace(/\+/g, ' ');
23801 }
23802 };
23803
23804
23805 // _.cookie
23806 // Methods partially borrowed from quirksmode.org/js/cookies.html
23807 _.cookie = {
23808 get: function(name) {
23809 var nameEQ = name + '=';
23810 var ca = document$1.cookie.split(';');
23811 for (var i = 0; i < ca.length; i++) {
23812 var c = ca[i];
23813 while (c.charAt(0) == ' ') {
23814 c = c.substring(1, c.length);
23815 }
23816 if (c.indexOf(nameEQ) === 0) {
23817 return decodeURIComponent(c.substring(nameEQ.length, c.length));
23818 }
23819 }
23820 return null;
23821 },
23822
23823 parse: function(name) {
23824 var cookie;
23825 try {
23826 cookie = _.JSONDecode(_.cookie.get(name)) || {};
23827 } catch (err) {
23828 // noop
23829 }
23830 return cookie;
23831 },
23832
23833 set_seconds: function(name, value, seconds, is_cross_subdomain, is_secure, is_cross_site, domain_override) {
23834 var cdomain = '',
23835 expires = '',
23836 secure = '';
23837
23838 if (domain_override) {
23839 cdomain = '; domain=' + domain_override;
23840 } else if (is_cross_subdomain) {
23841 var domain = extract_domain(document$1.location.hostname);
23842 cdomain = domain ? '; domain=.' + domain : '';
23843 }
23844
23845 if (seconds) {
23846 var date = new Date();
23847 date.setTime(date.getTime() + (seconds * 1000));
23848 expires = '; expires=' + date.toGMTString();
23849 }
23850
23851 if (is_cross_site) {
23852 is_secure = true;
23853 secure = '; SameSite=None';
23854 }
23855 if (is_secure) {
23856 secure += '; secure';
23857 }
23858
23859 document$1.cookie = name + '=' + encodeURIComponent(value) + expires + '; path=/' + cdomain + secure;
23860 },
23861
23862 set: function(name, value, days, is_cross_subdomain, is_secure, is_cross_site, domain_override) {
23863 var cdomain = '', expires = '', secure = '';
23864
23865 if (domain_override) {
23866 cdomain = '; domain=' + domain_override;
23867 } else if (is_cross_subdomain) {
23868 var domain = extract_domain(document$1.location.hostname);
23869 cdomain = domain ? '; domain=.' + domain : '';
23870 }
23871
23872 if (days) {
23873 var date = new Date();
23874 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
23875 expires = '; expires=' + date.toGMTString();
23876 }
23877
23878 if (is_cross_site) {
23879 is_secure = true;
23880 secure = '; SameSite=None';
23881 }
23882 if (is_secure) {
23883 secure += '; secure';
23884 }
23885
23886 var new_cookie_val = name + '=' + encodeURIComponent(value) + expires + '; path=/' + cdomain + secure;
23887 document$1.cookie = new_cookie_val;
23888 return new_cookie_val;
23889 },
23890
23891 remove: function(name, is_cross_subdomain, domain_override) {
23892 _.cookie.set(name, '', -1, is_cross_subdomain, false, false, domain_override);
23893 }
23894 };
23895
23896 var _testStorageSupported = function (storage) {
23897 var supported = true;
23898 try {
23899 var key = '__mplss_' + cheap_guid(8),
23900 val = 'xyz';
23901 storage.setItem(key, val);
23902 if (storage.getItem(key) !== val) {
23903 supported = false;
23904 }
23905 storage.removeItem(key);
23906 } catch (err) {
23907 supported = false;
23908 }
23909 return supported;
23910 };
23911
23912 var _localStorageSupported = null;
23913 var localStorageSupported = function(storage, forceCheck) {
23914 if (_localStorageSupported !== null && !forceCheck) {
23915 return _localStorageSupported;
23916 }
23917 return _localStorageSupported = _testStorageSupported(storage || win.localStorage);
23918 };
23919
23920 var _sessionStorageSupported = null;
23921 var sessionStorageSupported = function(storage, forceCheck) {
23922 if (_sessionStorageSupported !== null && !forceCheck) {
23923 return _sessionStorageSupported;
23924 }
23925 return _sessionStorageSupported = _testStorageSupported(storage || win.sessionStorage);
23926 };
23927
23928 function _storageWrapper(storage, name, is_supported_fn) {
23929 var log_error = function(msg) {
23930 console$1.error(name + ' error: ' + msg);
23931 };
23932
23933 return {
23934 is_supported: function(forceCheck) {
23935 var supported = is_supported_fn(storage, forceCheck);
23936 if (!supported) {
23937 console$1.error(name + ' unsupported');
23938 }
23939 return supported;
23940 },
23941 error: log_error,
23942 get: function(key) {
23943 try {
23944 return storage.getItem(key);
23945 } catch (err) {
23946 log_error(err);
23947 }
23948 return null;
23949 },
23950 parse: function(key) {
23951 try {
23952 return _.JSONDecode(storage.getItem(key)) || {};
23953 } catch (err) {
23954 // noop
23955 }
23956 return null;
23957 },
23958 set: function(key, value) {
23959 try {
23960 storage.setItem(key, value);
23961 } catch (err) {
23962 log_error(err);
23963 }
23964 },
23965 remove: function(key) {
23966 try {
23967 storage.removeItem(key);
23968 } catch (err) {
23969 log_error(err);
23970 }
23971 }
23972 };
23973 }
23974
23975 _.localStorage = _storageWrapper(win.localStorage, 'localStorage', localStorageSupported);
23976 _.sessionStorage = _storageWrapper(win.sessionStorage, 'sessionStorage', sessionStorageSupported);
23977
23978 _.register_event = (function() {
23979 // written by Dean Edwards, 2005
23980 // with input from Tino Zijdel - crisp@xs4all.nl
23981 // with input from Carl Sverre - mail@carlsverre.com
23982 // with input from Mixpanel
23983 // http://dean.edwards.name/weblog/2005/10/add-event/
23984 // https://gist.github.com/1930440
23985
23986 /**
23987 * @param {Object} element
23988 * @param {string} type
23989 * @param {function(...*)} handler
23990 * @param {boolean=} oldSchool
23991 * @param {boolean=} useCapture
23992 */
23993 var register_event = function(element, type, handler, oldSchool, useCapture) {
23994 if (!element) {
23995 console$1.error('No valid element provided to register_event');
23996 return;
23997 }
23998
23999 if (element.addEventListener && !oldSchool) {
24000 element.addEventListener(type, handler, !!useCapture);
24001 } else {
24002 var ontype = 'on' + type;
24003 var old_handler = element[ontype]; // can be undefined
24004 element[ontype] = makeHandler(element, handler, old_handler);
24005 }
24006 };
24007
24008 function makeHandler(element, new_handler, old_handlers) {
24009 var handler = function(event) {
24010 event = event || fixEvent(win.event);
24011
24012 // this basically happens in firefox whenever another script
24013 // overwrites the onload callback and doesn't pass the event
24014 // object to previously defined callbacks. All the browsers
24015 // that don't define window.event implement addEventListener
24016 // so the dom_loaded handler will still be fired as usual.
24017 if (!event) {
24018 return undefined;
24019 }
24020
24021 var ret = true;
24022 var old_result, new_result;
24023
24024 if (_.isFunction(old_handlers)) {
24025 old_result = old_handlers(event);
24026 }
24027 new_result = new_handler.call(element, event);
24028
24029 if ((false === old_result) || (false === new_result)) {
24030 ret = false;
24031 }
24032
24033 return ret;
24034 };
24035
24036 return handler;
24037 }
24038
24039 function fixEvent(event) {
24040 if (event) {
24041 event.preventDefault = fixEvent.preventDefault;
24042 event.stopPropagation = fixEvent.stopPropagation;
24043 }
24044 return event;
24045 }
24046 fixEvent.preventDefault = function() {
24047 this.returnValue = false;
24048 };
24049 fixEvent.stopPropagation = function() {
24050 this.cancelBubble = true;
24051 };
24052
24053 return register_event;
24054 })();
24055
24056
24057 var TOKEN_MATCH_REGEX = new RegExp('^(\\w*)\\[(\\w+)([=~\\|\\^\\$\\*]?)=?"?([^\\]"]*)"?\\]$');
24058
24059 _.dom_query = (function() {
24060 /* document.getElementsBySelector(selector)
24061 - returns an array of element objects from the current document
24062 matching the CSS selector. Selectors can contain element names,
24063 class names and ids and can be nested. For example:
24064
24065 elements = document.getElementsBySelector('div#main p a.external')
24066
24067 Will return an array of all 'a' elements with 'external' in their
24068 class attribute that are contained inside 'p' elements that are
24069 contained inside the 'div' element which has id="main"
24070
24071 New in version 0.4: Support for CSS2 and CSS3 attribute selectors:
24072 See http://www.w3.org/TR/css3-selectors/#attribute-selectors
24073
24074 Version 0.4 - Simon Willison, March 25th 2003
24075 -- Works in Phoenix 0.5, Mozilla 1.3, Opera 7, Internet Explorer 6, Internet Explorer 5 on Windows
24076 -- Opera 7 fails
24077
24078 Version 0.5 - Carl Sverre, Jan 7th 2013
24079 -- Now uses jQuery-esque `hasClass` for testing class name
24080 equality. This fixes a bug related to '-' characters being
24081 considered not part of a 'word' in regex.
24082 */
24083
24084 function getAllChildren(e) {
24085 // Returns all children of element. Workaround required for IE5/Windows. Ugh.
24086 return e.all ? e.all : e.getElementsByTagName('*');
24087 }
24088
24089 var bad_whitespace = /[\t\r\n]/g;
24090
24091 function hasClass(elem, selector) {
24092 var className = ' ' + selector + ' ';
24093 return ((' ' + elem.className + ' ').replace(bad_whitespace, ' ').indexOf(className) >= 0);
24094 }
24095
24096 function getElementsBySelector(selector) {
24097 // Attempt to fail gracefully in lesser browsers
24098 if (!document$1.getElementsByTagName) {
24099 return [];
24100 }
24101 // Split selector in to tokens
24102 var tokens = selector.split(' ');
24103 var token, bits, tagName, found, foundCount, i, j, k, elements, currentContextIndex;
24104 var currentContext = [document$1];
24105 for (i = 0; i < tokens.length; i++) {
24106 token = tokens[i].replace(/^\s+/, '').replace(/\s+$/, '');
24107 if (token.indexOf('#') > -1) {
24108 // Token is an ID selector
24109 bits = token.split('#');
24110 tagName = bits[0];
24111 var id = bits[1];
24112 var element = document$1.getElementById(id);
24113 if (!element || (tagName && element.nodeName.toLowerCase() != tagName)) {
24114 // element not found or tag with that ID not found, return false
24115 return [];
24116 }
24117 // Set currentContext to contain just this element
24118 currentContext = [element];
24119 continue; // Skip to next token
24120 }
24121 if (token.indexOf('.') > -1) {
24122 // Token contains a class selector
24123 bits = token.split('.');
24124 tagName = bits[0];
24125 var className = bits[1];
24126 if (!tagName) {
24127 tagName = '*';
24128 }
24129 // Get elements matching tag, filter them for class selector
24130 found = [];
24131 foundCount = 0;
24132 for (j = 0; j < currentContext.length; j++) {
24133 if (tagName == '*') {
24134 elements = getAllChildren(currentContext[j]);
24135 } else {
24136 elements = currentContext[j].getElementsByTagName(tagName);
24137 }
24138 for (k = 0; k < elements.length; k++) {
24139 found[foundCount++] = elements[k];
24140 }
24141 }
24142 currentContext = [];
24143 currentContextIndex = 0;
24144 for (j = 0; j < found.length; j++) {
24145 if (found[j].className &&
24146 _.isString(found[j].className) && // some SVG elements have classNames which are not strings
24147 hasClass(found[j], className)
24148 ) {
24149 currentContext[currentContextIndex++] = found[j];
24150 }
24151 }
24152 continue; // Skip to next token
24153 }
24154 // Code to deal with attribute selectors
24155 var token_match = token.match(TOKEN_MATCH_REGEX);
24156 if (token_match) {
24157 tagName = token_match[1];
24158 var attrName = token_match[2];
24159 var attrOperator = token_match[3];
24160 var attrValue = token_match[4];
24161 if (!tagName) {
24162 tagName = '*';
24163 }
24164 // Grab all of the tagName elements within current context
24165 found = [];
24166 foundCount = 0;
24167 for (j = 0; j < currentContext.length; j++) {
24168 if (tagName == '*') {
24169 elements = getAllChildren(currentContext[j]);
24170 } else {
24171 elements = currentContext[j].getElementsByTagName(tagName);
24172 }
24173 for (k = 0; k < elements.length; k++) {
24174 found[foundCount++] = elements[k];
24175 }
24176 }
24177 currentContext = [];
24178 currentContextIndex = 0;
24179 var checkFunction; // This function will be used to filter the elements
24180 switch (attrOperator) {
24181 case '=': // Equality
24182 checkFunction = function(e) {
24183 return (e.getAttribute(attrName) == attrValue);
24184 };
24185 break;
24186 case '~': // Match one of space seperated words
24187 checkFunction = function(e) {
24188 return (e.getAttribute(attrName).match(new RegExp('\\b' + attrValue + '\\b')));
24189 };
24190 break;
24191 case '|': // Match start with value followed by optional hyphen
24192 checkFunction = function(e) {
24193 return (e.getAttribute(attrName).match(new RegExp('^' + attrValue + '-?')));
24194 };
24195 break;
24196 case '^': // Match starts with value
24197 checkFunction = function(e) {
24198 return (e.getAttribute(attrName).indexOf(attrValue) === 0);
24199 };
24200 break;
24201 case '$': // Match ends with value - fails with "Warning" in Opera 7
24202 checkFunction = function(e) {
24203 return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length);
24204 };
24205 break;
24206 case '*': // Match ends with value
24207 checkFunction = function(e) {
24208 return (e.getAttribute(attrName).indexOf(attrValue) > -1);
24209 };
24210 break;
24211 default:
24212 // Just test for existence of attribute
24213 checkFunction = function(e) {
24214 return e.getAttribute(attrName);
24215 };
24216 }
24217 currentContext = [];
24218 currentContextIndex = 0;
24219 for (j = 0; j < found.length; j++) {
24220 if (checkFunction(found[j])) {
24221 currentContext[currentContextIndex++] = found[j];
24222 }
24223 }
24224 // alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue);
24225 continue; // Skip to next token
24226 }
24227 // If we get here, token is JUST an element (not a class or ID selector)
24228 tagName = token;
24229 found = [];
24230 foundCount = 0;
24231 for (j = 0; j < currentContext.length; j++) {
24232 elements = currentContext[j].getElementsByTagName(tagName);
24233 for (k = 0; k < elements.length; k++) {
24234 found[foundCount++] = elements[k];
24235 }
24236 }
24237 currentContext = found;
24238 }
24239 return currentContext;
24240 }
24241
24242 return function(query) {
24243 if (_.isElement(query)) {
24244 return [query];
24245 } else if (_.isObject(query) && !_.isUndefined(query.length)) {
24246 return query;
24247 } else {
24248 return getElementsBySelector.call(this, query);
24249 }
24250 };
24251 })();
24252
24253 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'];
24254 var CLICK_IDS = ['dclid', 'fbclid', 'gclid', 'ko_click_id', 'li_fat_id', 'msclkid', 'sccid', 'ttclid', 'twclid', 'wbraid'];
24255
24256 _.info = {
24257 campaignParams: function(default_value) {
24258 var kw = '',
24259 params = {};
24260 _.each(CAMPAIGN_KEYWORDS, function(kwkey) {
24261 kw = _.getQueryParam(document$1.URL, kwkey);
24262 if (kw.length) {
24263 params[kwkey] = kw;
24264 } else if (default_value !== undefined) {
24265 params[kwkey] = default_value;
24266 }
24267 });
24268
24269 return params;
24270 },
24271
24272 clickParams: function() {
24273 var id = '',
24274 params = {};
24275 _.each(CLICK_IDS, function(idkey) {
24276 id = _.getQueryParam(document$1.URL, idkey);
24277 if (id.length) {
24278 params[idkey] = id;
24279 }
24280 });
24281
24282 return params;
24283 },
24284
24285 marketingParams: function() {
24286 return _.extend(_.info.campaignParams(), _.info.clickParams());
24287 },
24288
24289 searchEngine: function(referrer) {
24290 if (referrer.search('https?://(.*)google.([^/?]*)') === 0) {
24291 return 'google';
24292 } else if (referrer.search('https?://(.*)bing.com') === 0) {
24293 return 'bing';
24294 } else if (referrer.search('https?://(.*)yahoo.com') === 0) {
24295 return 'yahoo';
24296 } else if (referrer.search('https?://(.*)duckduckgo.com') === 0) {
24297 return 'duckduckgo';
24298 } else {
24299 return null;
24300 }
24301 },
24302
24303 searchInfo: function(referrer) {
24304 var search = _.info.searchEngine(referrer),
24305 param = (search != 'yahoo') ? 'q' : 'p',
24306 ret = {};
24307
24308 if (search !== null) {
24309 ret['$search_engine'] = search;
24310
24311 var keyword = _.getQueryParam(referrer, param);
24312 if (keyword.length) {
24313 ret['mp_keyword'] = keyword;
24314 }
24315 }
24316
24317 return ret;
24318 },
24319
24320 /**
24321 * This function detects which browser is running this script.
24322 * The order of the checks are important since many user agents
24323 * include key words used in later checks.
24324 */
24325 browser: function(user_agent, vendor, opera) {
24326 vendor = vendor || ''; // vendor is undefined for at least IE9
24327 if (opera || _.includes(user_agent, ' OPR/')) {
24328 if (_.includes(user_agent, 'Mini')) {
24329 return 'Opera Mini';
24330 }
24331 return 'Opera';
24332 } else if (/(BlackBerry|PlayBook|BB10)/i.test(user_agent)) {
24333 return 'BlackBerry';
24334 } else if (_.includes(user_agent, 'IEMobile') || _.includes(user_agent, 'WPDesktop')) {
24335 return 'Internet Explorer Mobile';
24336 } else if (_.includes(user_agent, 'SamsungBrowser/')) {
24337 // https://developer.samsung.com/internet/user-agent-string-format
24338 return 'Samsung Internet';
24339 } else if (_.includes(user_agent, 'Edge') || _.includes(user_agent, 'Edg/')) {
24340 return 'Microsoft Edge';
24341 } else if (_.includes(user_agent, 'FBIOS')) {
24342 return 'Facebook Mobile';
24343 } else if (_.includes(user_agent, 'Whale/')) {
24344 // https://user-agents.net/browsers/whale-browser
24345 return 'Whale Browser';
24346 } else if (_.includes(user_agent, 'Chrome')) {
24347 return 'Chrome';
24348 } else if (_.includes(user_agent, 'CriOS')) {
24349 return 'Chrome iOS';
24350 } else if (_.includes(user_agent, 'UCWEB') || _.includes(user_agent, 'UCBrowser')) {
24351 return 'UC Browser';
24352 } else if (_.includes(user_agent, 'FxiOS')) {
24353 return 'Firefox iOS';
24354 } else if (_.includes(vendor, 'Apple')) {
24355 if (_.includes(user_agent, 'Mobile')) {
24356 return 'Mobile Safari';
24357 }
24358 return 'Safari';
24359 } else if (_.includes(user_agent, 'Android')) {
24360 return 'Android Mobile';
24361 } else if (_.includes(user_agent, 'Konqueror')) {
24362 return 'Konqueror';
24363 } else if (_.includes(user_agent, 'Firefox')) {
24364 return 'Firefox';
24365 } else if (_.includes(user_agent, 'MSIE') || _.includes(user_agent, 'Trident/')) {
24366 return 'Internet Explorer';
24367 } else if (_.includes(user_agent, 'Gecko')) {
24368 return 'Mozilla';
24369 } else {
24370 return '';
24371 }
24372 },
24373
24374 /**
24375 * This function detects which browser version is running this script,
24376 * parsing major and minor version (e.g., 42.1). User agent strings from:
24377 * http://www.useragentstring.com/pages/useragentstring.php
24378 */
24379 browserVersion: function(userAgent, vendor, opera) {
24380 var browser = _.info.browser(userAgent, vendor, opera);
24381 var versionRegexs = {
24382 'Internet Explorer Mobile': /rv:(\d+(\.\d+)?)/,
24383 'Microsoft Edge': /Edge?\/(\d+(\.\d+)?)/,
24384 'Chrome': /Chrome\/(\d+(\.\d+)?)/,
24385 'Chrome iOS': /CriOS\/(\d+(\.\d+)?)/,
24386 'UC Browser' : /(UCBrowser|UCWEB)\/(\d+(\.\d+)?)/,
24387 'Safari': /Version\/(\d+(\.\d+)?)/,
24388 'Mobile Safari': /Version\/(\d+(\.\d+)?)/,
24389 'Opera': /(Opera|OPR)\/(\d+(\.\d+)?)/,
24390 'Firefox': /Firefox\/(\d+(\.\d+)?)/,
24391 'Firefox iOS': /FxiOS\/(\d+(\.\d+)?)/,
24392 'Konqueror': /Konqueror:(\d+(\.\d+)?)/,
24393 'BlackBerry': /BlackBerry (\d+(\.\d+)?)/,
24394 'Android Mobile': /android\s(\d+(\.\d+)?)/,
24395 'Samsung Internet': /SamsungBrowser\/(\d+(\.\d+)?)/,
24396 'Internet Explorer': /(rv:|MSIE )(\d+(\.\d+)?)/,
24397 'Mozilla': /rv:(\d+(\.\d+)?)/,
24398 'Whale Browser': /Whale\/(\d+(\.\d+)?)/
24399 };
24400 var regex = versionRegexs[browser];
24401 if (regex === undefined) {
24402 return null;
24403 }
24404 var matches = userAgent.match(regex);
24405 if (!matches) {
24406 return null;
24407 }
24408 return parseFloat(matches[matches.length - 2]);
24409 },
24410
24411 os: function() {
24412 var a = userAgent;
24413 if (/Windows/i.test(a)) {
24414 if (/Phone/.test(a) || /WPDesktop/.test(a)) {
24415 return 'Windows Phone';
24416 }
24417 return 'Windows';
24418 } else if (/(iPhone|iPad|iPod)/.test(a)) {
24419 return 'iOS';
24420 } else if (/Android/.test(a)) {
24421 return 'Android';
24422 } else if (/(BlackBerry|PlayBook|BB10)/i.test(a)) {
24423 return 'BlackBerry';
24424 } else if (/Mac/i.test(a)) {
24425 return 'Mac OS X';
24426 } else if (/Linux/.test(a)) {
24427 return 'Linux';
24428 } else if (/CrOS/.test(a)) {
24429 return 'Chrome OS';
24430 } else {
24431 return '';
24432 }
24433 },
24434
24435 device: function(user_agent) {
24436 if (/Windows Phone/i.test(user_agent) || /WPDesktop/.test(user_agent)) {
24437 return 'Windows Phone';
24438 } else if (/iPad/.test(user_agent)) {
24439 return 'iPad';
24440 } else if (/iPod/.test(user_agent)) {
24441 return 'iPod Touch';
24442 } else if (/iPhone/.test(user_agent)) {
24443 return 'iPhone';
24444 } else if (/(BlackBerry|PlayBook|BB10)/i.test(user_agent)) {
24445 return 'BlackBerry';
24446 } else if (/Android/.test(user_agent)) {
24447 return 'Android';
24448 } else {
24449 return '';
24450 }
24451 },
24452
24453 referringDomain: function(referrer) {
24454 var split = referrer.split('/');
24455 if (split.length >= 3) {
24456 return split[2];
24457 }
24458 return '';
24459 },
24460
24461 currentUrl: function() {
24462 return win.location.href;
24463 },
24464
24465 properties: function(extra_props) {
24466 if (typeof extra_props !== 'object') {
24467 extra_props = {};
24468 }
24469 return _.extend(_.strip_empty_properties({
24470 '$os': _.info.os(),
24471 '$browser': _.info.browser(userAgent, navigator.vendor, windowOpera),
24472 '$referrer': document$1.referrer,
24473 '$referring_domain': _.info.referringDomain(document$1.referrer),
24474 '$device': _.info.device(userAgent)
24475 }), {
24476 '$current_url': _.info.currentUrl(),
24477 '$browser_version': _.info.browserVersion(userAgent, navigator.vendor, windowOpera),
24478 '$screen_height': screen.height,
24479 '$screen_width': screen.width,
24480 'mp_lib': 'web',
24481 '$lib_version': Config.LIB_VERSION,
24482 '$insert_id': cheap_guid(),
24483 'time': _.timestamp() / 1000 // epoch time in seconds
24484 }, _.strip_empty_properties(extra_props));
24485 },
24486
24487 people_properties: function() {
24488 return _.extend(_.strip_empty_properties({
24489 '$os': _.info.os(),
24490 '$browser': _.info.browser(userAgent, navigator.vendor, windowOpera)
24491 }), {
24492 '$browser_version': _.info.browserVersion(userAgent, navigator.vendor, windowOpera)
24493 });
24494 },
24495
24496 mpPageViewProperties: function() {
24497 return _.strip_empty_properties({
24498 'current_page_title': document$1.title,
24499 'current_domain': win.location.hostname,
24500 'current_url_path': win.location.pathname,
24501 'current_url_protocol': win.location.protocol,
24502 'current_url_search': win.location.search
24503 });
24504 }
24505 };
24506
24507 /**
24508 * Returns a throttled function that will only run at most every `waitMs` and returns a promise that resolves with the next invocation.
24509 * Throttled calls will build up a batch of args and invoke the callback with all args since the last invocation.
24510 */
24511 var batchedThrottle = function (fn, waitMs) {
24512 var timeoutPromise = null;
24513 var throttledItems = [];
24514 return function (item) {
24515 var self = this;
24516 throttledItems.push(item);
24517
24518 if (!timeoutPromise) {
24519 timeoutPromise = new PromisePolyfill(function (resolve) {
24520 setTimeout(function () {
24521 var returnValue = fn.apply(self, [throttledItems]);
24522 timeoutPromise = null;
24523 throttledItems = [];
24524 resolve(returnValue);
24525 }, waitMs);
24526 });
24527 }
24528 return timeoutPromise;
24529 };
24530 };
24531
24532 var cheap_guid = function(maxlen) {
24533 var guid = Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10);
24534 return maxlen ? guid.substring(0, maxlen) : guid;
24535 };
24536
24537 /**
24538 * Generates a W3C traceparent header for easy interop with distributed tracing systems i.e Open Telemetry
24539 * https://www.w3.org/TR/trace-context/#traceparent-header
24540 */
24541 var generateTraceparent = function() {
24542 var traceID = _.UUID().replace(/-/g, '');
24543 var parentID = _.UUID().replace(/-/g, '').substring(0, 16);
24544
24545 // Sampled trace
24546 var traceFlags = '01';
24547
24548 return '00-' + traceID + '-' + parentID + '-' + traceFlags;
24549 };
24550
24551 // naive way to extract domain name (example.com) from full hostname (my.sub.example.com)
24552 var SIMPLE_DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]*\.[a-z]+$/i;
24553 // this next one attempts to account for some ccSLDs, e.g. extracting oxford.ac.uk from www.oxford.ac.uk
24554 var DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i;
24555 /**
24556 * Attempts to extract main domain name from full hostname, using a few blunt heuristics. For
24557 * common TLDs like .com/.org that always have a simple SLD.TLD structure (example.com), we
24558 * simply extract the last two .-separated parts of the hostname (SIMPLE_DOMAIN_MATCH_REGEX).
24559 * For others, we attempt to account for short ccSLD+TLD combos (.ac.uk) with the legacy
24560 * DOMAIN_MATCH_REGEX (kept to maintain backwards compatibility with existing Mixpanel
24561 * integrations). The only _reliable_ way to extract domain from hostname is with an up-to-date
24562 * list like at https://publicsuffix.org/ so for cases that this helper fails at, the SDK
24563 * offers the 'cookie_domain' config option to set it explicitly.
24564 * @example
24565 * extract_domain('my.sub.example.com')
24566 * // 'example.com'
24567 */
24568 var extract_domain = function(hostname) {
24569 var domain_regex = DOMAIN_MATCH_REGEX;
24570 var parts = hostname.split('.');
24571 var tld = parts[parts.length - 1];
24572 if (tld.length > 4 || tld === 'com' || tld === 'org') {
24573 domain_regex = SIMPLE_DOMAIN_MATCH_REGEX;
24574 }
24575 var matches = hostname.match(domain_regex);
24576 return matches ? matches[0] : '';
24577 };
24578
24579 /**
24580 * Check whether we have network connection. default to true for browsers that don't support navigator.onLine (IE)
24581 * @returns {boolean}
24582 */
24583 var isOnline = function() {
24584 var onLine = win.navigator['onLine'];
24585 return _.isUndefined(onLine) || onLine;
24586 };
24587
24588 var NOOP_FUNC = function () {};
24589
24590 var JSONStringify = null, JSONParse = null;
24591 if (typeof JSON !== 'undefined') {
24592 JSONStringify = JSON.stringify;
24593 JSONParse = JSON.parse;
24594 }
24595 JSONStringify = JSONStringify || _.JSONEncode;
24596 JSONParse = JSONParse || _.JSONDecode;
24597
24598 // UNMINIFIED EXPORTS (for closure compiler)
24599 _['info'] = _.info;
24600 _['info']['browser'] = _.info.browser;
24601 _['info']['browserVersion'] = _.info.browserVersion;
24602 _['info']['device'] = _.info.device;
24603 _['info']['properties'] = _.info.properties;
24604 _['isBlockedUA'] = _.isBlockedUA;
24605 _['isEmptyObject'] = _.isEmptyObject;
24606 _['isObject'] = _.isObject;
24607 _['JSONDecode'] = _.JSONDecode;
24608 _['JSONEncode'] = _.JSONEncode;
24609 _['toArray'] = _.toArray;
24610 _['NPO'] = NpoPromise;
24611
24612 var MIXPANEL_DB_NAME = 'mixpanelBrowserDb';
24613
24614 var RECORDING_EVENTS_STORE_NAME = 'mixpanelRecordingEvents';
24615 var RECORDING_REGISTRY_STORE_NAME = 'mixpanelRecordingRegistry';
24616
24617 // note: increment the version number when adding new object stores
24618 var DB_VERSION = 1;
24619 var OBJECT_STORES = [RECORDING_EVENTS_STORE_NAME, RECORDING_REGISTRY_STORE_NAME];
24620
24621 /**
24622 * @type {import('./wrapper').StorageWrapper}
24623 */
24624 var IDBStorageWrapper = function (storeName) {
24625 /**
24626 * @type {Promise<IDBDatabase>|null}
24627 */
24628 this.dbPromise = null;
24629 this.storeName = storeName;
24630 };
24631
24632 IDBStorageWrapper.prototype._openDb = function () {
24633 return new PromisePolyfill(function (resolve, reject) {
24634 var openRequest = win.indexedDB.open(MIXPANEL_DB_NAME, DB_VERSION);
24635 openRequest['onerror'] = function () {
24636 reject(openRequest.error);
24637 };
24638
24639 openRequest['onsuccess'] = function () {
24640 resolve(openRequest.result);
24641 };
24642
24643 openRequest['onupgradeneeded'] = function (ev) {
24644 var db = ev.target.result;
24645
24646 OBJECT_STORES.forEach(function (storeName) {
24647 db.createObjectStore(storeName);
24648 });
24649 };
24650 });
24651 };
24652
24653 IDBStorageWrapper.prototype.init = function () {
24654 if (!win.indexedDB) {
24655 return PromisePolyfill.reject('indexedDB is not supported in this browser');
24656 }
24657
24658 if (!this.dbPromise) {
24659 this.dbPromise = this._openDb();
24660 }
24661
24662 return this.dbPromise
24663 .then(function (dbOrError) {
24664 if (dbOrError instanceof win['IDBDatabase']) {
24665 return PromisePolyfill.resolve();
24666 } else {
24667 return PromisePolyfill.reject(dbOrError);
24668 }
24669 });
24670 };
24671
24672 IDBStorageWrapper.prototype.isInitialized = function () {
24673 return !!this.dbPromise;
24674 };
24675
24676 /**
24677 * @param {IDBTransactionMode} mode
24678 * @param {function(IDBObjectStore): void} storeCb
24679 */
24680 IDBStorageWrapper.prototype.makeTransaction = function (mode, storeCb) {
24681 var storeName = this.storeName;
24682 var doTransaction = function (db) {
24683 return new PromisePolyfill(function (resolve, reject) {
24684 var transaction = db.transaction(storeName, mode);
24685 transaction.oncomplete = function () {
24686 resolve(transaction);
24687 };
24688 transaction.onabort = transaction.onerror = function () {
24689 reject(transaction.error);
24690 };
24691
24692 storeCb(transaction.objectStore(storeName));
24693 });
24694 };
24695
24696 return this.dbPromise
24697 .then(doTransaction)
24698 .catch(function (err) {
24699 if (err && err['name'] === 'InvalidStateError') {
24700 // try reopening the DB if the connection is closed
24701 this.dbPromise = this._openDb();
24702 return this.dbPromise.then(doTransaction);
24703 } else {
24704 return PromisePolyfill.reject(err);
24705 }
24706 }.bind(this));
24707 };
24708
24709 IDBStorageWrapper.prototype.setItem = function (key, value) {
24710 return this.makeTransaction('readwrite', function (objectStore) {
24711 objectStore.put(value, key);
24712 });
24713 };
24714
24715 IDBStorageWrapper.prototype.getItem = function (key) {
24716 var req;
24717 return this.makeTransaction('readonly', function (objectStore) {
24718 req = objectStore.get(key);
24719 }).then(function () {
24720 return req.result;
24721 });
24722 };
24723
24724 IDBStorageWrapper.prototype.removeItem = function (key) {
24725 return this.makeTransaction('readwrite', function (objectStore) {
24726 objectStore.delete(key);
24727 });
24728 };
24729
24730 IDBStorageWrapper.prototype.getAll = function () {
24731 var req;
24732 return this.makeTransaction('readonly', function (objectStore) {
24733 req = objectStore.getAll();
24734 }).then(function () {
24735 return req.result;
24736 });
24737 };
24738
24739 /**
24740 * GDPR utils
24741 *
24742 * The General Data Protection Regulation (GDPR) is a regulation in EU law on data protection
24743 * and privacy for all individuals within the European Union. It addresses the export of personal
24744 * data outside the EU. The GDPR aims primarily to give control back to citizens and residents
24745 * over their personal data and to simplify the regulatory environment for international business
24746 * by unifying the regulation within the EU.
24747 *
24748 * This set of utilities is intended to enable opt in/out functionality in the Mixpanel JS SDK.
24749 * These functions are used internally by the SDK and are not intended to be publicly exposed.
24750 */
24751
24752
24753 /**
24754 * A function used to track a Mixpanel event (e.g. MixpanelLib.track)
24755 * @callback trackFunction
24756 * @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
24757 * @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.
24758 * @param {Function} [callback] If provided, the callback function will be called after tracking the event.
24759 */
24760
24761 /** Public **/
24762
24763 var GDPR_DEFAULT_PERSISTENCE_PREFIX = '__mp_opt_in_out_';
24764
24765 /**
24766 * Opt the user in to data tracking and cookies/localstorage for the given token
24767 * @param {string} token - Mixpanel project tracking token
24768 * @param {Object} [options]
24769 * @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
24770 * @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
24771 * @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
24772 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24773 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24774 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24775 * @param {string} [options.cookieDomain] - custom cookie domain
24776 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24777 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24778 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24779 */
24780 function optIn(token, options) {
24781 _optInOut(true, token, options);
24782 }
24783
24784 /**
24785 * Opt the user out of data tracking and cookies/localstorage for the given token
24786 * @param {string} token - Mixpanel project tracking token
24787 * @param {Object} [options]
24788 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24789 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24790 * @param {Number} [options.cookieExpiration] - number of days until the opt-out cookie expires
24791 * @param {string} [options.cookieDomain] - custom cookie domain
24792 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24793 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-out cookie is set as cross-subdomain or not
24794 * @param {boolean} [options.secureCookie] - whether the opt-out cookie is set as secure or not
24795 */
24796 function optOut(token, options) {
24797 _optInOut(false, token, options);
24798 }
24799
24800 /**
24801 * Check whether the user has opted in to data tracking and cookies/localstorage for the given token
24802 * @param {string} token - Mixpanel project tracking token
24803 * @param {Object} [options]
24804 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24805 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24806 * @returns {boolean} whether the user has opted in to the given opt type
24807 */
24808 function hasOptedIn(token, options) {
24809 return _getStorageValue(token, options) === '1';
24810 }
24811
24812 /**
24813 * Check whether the user has opted out of data tracking and cookies/localstorage for the given token
24814 * @param {string} token - Mixpanel project tracking token
24815 * @param {Object} [options]
24816 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24817 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24818 * @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
24819 * @returns {boolean} whether the user has opted out of the given opt type
24820 */
24821 function hasOptedOut(token, options) {
24822 if (_hasDoNotTrackFlagOn(options)) {
24823 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"');
24824 return true;
24825 }
24826 var optedOut = _getStorageValue(token, options) === '0';
24827 if (optedOut) {
24828 console$1.warn('You are opted out of Mixpanel tracking. This will prevent the Mixpanel SDK from sending any data.');
24829 }
24830 return optedOut;
24831 }
24832
24833 /**
24834 * Wrap a MixpanelLib method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24835 * If the user has opted out, return early instead of executing the method.
24836 * If a callback argument was provided, execute it passing the 0 error code.
24837 * @param {function} method - wrapped method to be executed if the user has not opted out
24838 * @returns {*} the result of executing method OR undefined if the user has opted out
24839 */
24840 function addOptOutCheckMixpanelLib(method) {
24841 return _addOptOutCheck(method, function(name) {
24842 return this.get_config(name);
24843 });
24844 }
24845
24846 /**
24847 * Wrap a MixpanelPeople method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24848 * If the user has opted out, return early instead of executing the method.
24849 * If a callback argument was provided, execute it passing the 0 error code.
24850 * @param {function} method - wrapped method to be executed if the user has not opted out
24851 * @returns {*} the result of executing method OR undefined if the user has opted out
24852 */
24853 function addOptOutCheckMixpanelPeople(method) {
24854 return _addOptOutCheck(method, function(name) {
24855 return this._get_config(name);
24856 });
24857 }
24858
24859 /**
24860 * Wrap a MixpanelGroup method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24861 * If the user has opted out, return early instead of executing the method.
24862 * If a callback argument was provided, execute it passing the 0 error code.
24863 * @param {function} method - wrapped method to be executed if the user has not opted out
24864 * @returns {*} the result of executing method OR undefined if the user has opted out
24865 */
24866 function addOptOutCheckMixpanelGroup(method) {
24867 return _addOptOutCheck(method, function(name) {
24868 return this._get_config(name);
24869 });
24870 }
24871
24872 /**
24873 * Clear the user's opt in/out status of data tracking and cookies/localstorage for the given token
24874 * @param {string} token - Mixpanel project tracking token
24875 * @param {Object} [options]
24876 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24877 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24878 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24879 * @param {string} [options.cookieDomain] - custom cookie domain
24880 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24881 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24882 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24883 */
24884 function clearOptInOut(token, options) {
24885 options = options || {};
24886 _getStorage(options).remove(
24887 _getStorageKey(token, options), !!options.crossSubdomainCookie, options.cookieDomain
24888 );
24889 }
24890
24891 /** Private **/
24892
24893 /**
24894 * Get storage util
24895 * @param {Object} [options]
24896 * @param {string} [options.persistenceType]
24897 * @returns {object} either _.cookie or _.localstorage
24898 */
24899 function _getStorage(options) {
24900 options = options || {};
24901 return options.persistenceType === 'localStorage' ? _.localStorage : _.cookie;
24902 }
24903
24904 /**
24905 * Get the name of the cookie that is used for the given opt type (tracking, cookie, etc.)
24906 * @param {string} token - Mixpanel project tracking token
24907 * @param {Object} [options]
24908 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24909 * @returns {string} the name of the cookie for the given opt type
24910 */
24911 function _getStorageKey(token, options) {
24912 options = options || {};
24913 return (options.persistencePrefix || GDPR_DEFAULT_PERSISTENCE_PREFIX) + token;
24914 }
24915
24916 /**
24917 * Get the value of the cookie that is used for the given opt type (tracking, cookie, etc.)
24918 * @param {string} token - Mixpanel project tracking token
24919 * @param {Object} [options]
24920 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24921 * @returns {string} the value of the cookie for the given opt type
24922 */
24923 function _getStorageValue(token, options) {
24924 return _getStorage(options).get(_getStorageKey(token, options));
24925 }
24926
24927 /**
24928 * Check whether the user has set the DNT/doNotTrack setting to true in their browser
24929 * @param {Object} [options]
24930 * @param {string} [options.window] - alternate window object to check; used to force various DNT settings in browser tests
24931 * @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
24932 * @returns {boolean} whether the DNT setting is true
24933 */
24934 function _hasDoNotTrackFlagOn(options) {
24935 if (options && options.ignoreDnt) {
24936 return false;
24937 }
24938 var win$1 = (options && options.window) || win;
24939 var nav = win$1['navigator'] || {};
24940 var hasDntOn = false;
24941
24942 _.each([
24943 nav['doNotTrack'], // standard
24944 nav['msDoNotTrack'],
24945 win$1['doNotTrack']
24946 ], function(dntValue) {
24947 if (_.includes([true, 1, '1', 'yes'], dntValue)) {
24948 hasDntOn = true;
24949 }
24950 });
24951
24952 return hasDntOn;
24953 }
24954
24955 /**
24956 * Set cookie/localstorage for the user indicating that they are opted in or out for the given opt type
24957 * @param {boolean} optValue - whether to opt the user in or out for the given opt type
24958 * @param {string} token - Mixpanel project tracking token
24959 * @param {Object} [options]
24960 * @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
24961 * @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
24962 * @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
24963 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24964 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24965 * @param {string} [options.cookieDomain] - custom cookie domain
24966 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24967 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24968 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24969 */
24970 function _optInOut(optValue, token, options) {
24971 if (!_.isString(token) || !token.length) {
24972 console$1.error('gdpr.' + (optValue ? 'optIn' : 'optOut') + ' called with an invalid token');
24973 return;
24974 }
24975
24976 options = options || {};
24977
24978 _getStorage(options).set(
24979 _getStorageKey(token, options),
24980 optValue ? 1 : 0,
24981 _.isNumber(options.cookieExpiration) ? options.cookieExpiration : null,
24982 !!options.crossSubdomainCookie,
24983 !!options.secureCookie,
24984 !!options.crossSiteCookie,
24985 options.cookieDomain
24986 );
24987
24988 if (options.track && optValue) { // only track event if opting in (optValue=true)
24989 options.track(options.trackEventName || '$opt_in', options.trackProperties, {
24990 'send_immediately': true
24991 });
24992 }
24993 }
24994
24995 /**
24996 * Wrap a method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24997 * If the user has opted out, return early instead of executing the method.
24998 * If a callback argument was provided, execute it passing the 0 error code.
24999 * @param {function} method - wrapped method to be executed if the user has not opted out
25000 * @param {function} getConfigValue - getter function for the Mixpanel API token and other options to be used with opt-out check
25001 * @returns {*} the result of executing method OR undefined if the user has opted out
25002 */
25003 function _addOptOutCheck(method, getConfigValue) {
25004 return function() {
25005 var optedOut = false;
25006
25007 try {
25008 var token = getConfigValue.call(this, 'token');
25009 var ignoreDnt = getConfigValue.call(this, 'ignore_dnt');
25010 var persistenceType = getConfigValue.call(this, 'opt_out_tracking_persistence_type');
25011 var persistencePrefix = getConfigValue.call(this, 'opt_out_tracking_cookie_prefix');
25012 var win = getConfigValue.call(this, 'window'); // used to override window during browser tests
25013
25014 if (token) { // if there was an issue getting the token, continue method execution as normal
25015 optedOut = hasOptedOut(token, {
25016 ignoreDnt: ignoreDnt,
25017 persistenceType: persistenceType,
25018 persistencePrefix: persistencePrefix,
25019 window: win
25020 });
25021 }
25022 } catch(err) {
25023 console$1.error('Unexpected error when checking tracking opt-out status: ' + err);
25024 }
25025
25026 if (!optedOut) {
25027 return method.apply(this, arguments);
25028 }
25029
25030 var callback = arguments[arguments.length - 1];
25031 if (typeof(callback) === 'function') {
25032 callback(0);
25033 }
25034
25035 return;
25036 };
25037 }
25038
25039 var logger$6 = console_with_prefix('lock');
25040
25041 /**
25042 * SharedLock: a mutex built on HTML5 localStorage, to ensure that only one browser
25043 * window/tab at a time will be able to access shared resources.
25044 *
25045 * Based on the Alur and Taubenfeld fast lock
25046 * (http://www.cs.rochester.edu/research/synchronization/pseudocode/fastlock.html)
25047 * with an added timeout to ensure there will be eventual progress in the event
25048 * that a window is closed in the middle of the callback.
25049 *
25050 * Implementation based on the original version by David Wolever (https://github.com/wolever)
25051 * at https://gist.github.com/wolever/5fd7573d1ef6166e8f8c4af286a69432.
25052 *
25053 * @example
25054 * const myLock = new SharedLock('some-key');
25055 * myLock.withLock(function() {
25056 * console.log('I hold the mutex!');
25057 * });
25058 *
25059 * @constructor
25060 */
25061 var SharedLock = function(key, options) {
25062 options = options || {};
25063
25064 this.storageKey = key;
25065 this.storage = options.storage || win.localStorage;
25066 this.pollIntervalMS = options.pollIntervalMS || 100;
25067 this.timeoutMS = options.timeoutMS || 2000;
25068
25069 // dependency-inject promise implementation for testing purposes
25070 this.promiseImpl = options.promiseImpl || PromisePolyfill;
25071 };
25072
25073 // pass in a specific pid to test contention scenarios; otherwise
25074 // it is chosen randomly for each acquisition attempt
25075 SharedLock.prototype.withLock = function(lockedCB, pid) {
25076 var Promise = this.promiseImpl;
25077 return new Promise(_.bind(function (resolve, reject) {
25078 var i = pid || (new Date().getTime() + '|' + Math.random());
25079 var startTime = new Date().getTime();
25080 var key = this.storageKey;
25081 var pollIntervalMS = this.pollIntervalMS;
25082 var timeoutMS = this.timeoutMS;
25083 var storage = this.storage;
25084
25085 var keyX = key + ':X';
25086 var keyY = key + ':Y';
25087 var keyZ = key + ':Z';
25088
25089 var delay = function(cb) {
25090 if (new Date().getTime() - startTime > timeoutMS) {
25091 logger$6.error('Timeout waiting for mutex on ' + key + '; clearing lock. [' + i + ']');
25092 storage.removeItem(keyZ);
25093 storage.removeItem(keyY);
25094 loop();
25095 return;
25096 }
25097 setTimeout(function() {
25098 try {
25099 cb();
25100 } catch(err) {
25101 reject(err);
25102 }
25103 }, pollIntervalMS * (Math.random() + 0.1));
25104 };
25105
25106 var waitFor = function(predicate, cb) {
25107 if (predicate()) {
25108 cb();
25109 } else {
25110 delay(function() {
25111 waitFor(predicate, cb);
25112 });
25113 }
25114 };
25115
25116 var getSetY = function() {
25117 var valY = storage.getItem(keyY);
25118 if (valY && valY !== i) { // if Y == i then this process already has the lock (useful for test cases)
25119 return false;
25120 } else {
25121 storage.setItem(keyY, i);
25122 if (storage.getItem(keyY) === i) {
25123 return true;
25124 } else {
25125 if (!localStorageSupported(storage, true)) {
25126 reject(new Error('localStorage support dropped while acquiring lock'));
25127 }
25128 return false;
25129 }
25130 }
25131 };
25132
25133 var loop = function() {
25134 storage.setItem(keyX, i);
25135
25136 waitFor(getSetY, function() {
25137 if (storage.getItem(keyX) === i) {
25138 criticalSection();
25139 return;
25140 }
25141
25142 delay(function() {
25143 if (storage.getItem(keyY) !== i) {
25144 loop();
25145 return;
25146 }
25147 waitFor(function() {
25148 return !storage.getItem(keyZ);
25149 }, criticalSection);
25150 });
25151 });
25152 };
25153
25154 var criticalSection = function() {
25155 storage.setItem(keyZ, '1');
25156 var removeLock = function () {
25157 storage.removeItem(keyZ);
25158 if (storage.getItem(keyY) === i) {
25159 storage.removeItem(keyY);
25160 }
25161 if (storage.getItem(keyX) === i) {
25162 storage.removeItem(keyX);
25163 }
25164 };
25165
25166 lockedCB()
25167 .then(function (ret) {
25168 removeLock();
25169 resolve(ret);
25170 })
25171 .catch(function (err) {
25172 removeLock();
25173 reject(err);
25174 });
25175 };
25176
25177 try {
25178 if (localStorageSupported(storage, true)) {
25179 loop();
25180 } else {
25181 throw new Error('localStorage support check failed');
25182 }
25183 } catch(err) {
25184 reject(err);
25185 }
25186 }, this));
25187 };
25188
25189 /**
25190 * @type {import('./wrapper').StorageWrapper}
25191 */
25192 var LocalStorageWrapper = function (storageOverride) {
25193 this.storage = storageOverride || win.localStorage;
25194 };
25195
25196 LocalStorageWrapper.prototype.init = function () {
25197 return PromisePolyfill.resolve();
25198 };
25199
25200 LocalStorageWrapper.prototype.isInitialized = function () {
25201 return true;
25202 };
25203
25204 LocalStorageWrapper.prototype.setItem = function (key, value) {
25205 return new PromisePolyfill(_.bind(function (resolve, reject) {
25206 try {
25207 this.storage.setItem(key, JSONStringify(value));
25208 } catch (e) {
25209 reject(e);
25210 }
25211 resolve();
25212 }, this));
25213 };
25214
25215 LocalStorageWrapper.prototype.getItem = function (key) {
25216 return new PromisePolyfill(_.bind(function (resolve, reject) {
25217 var item;
25218 try {
25219 item = JSONParse(this.storage.getItem(key));
25220 } catch (e) {
25221 reject(e);
25222 }
25223 resolve(item);
25224 }, this));
25225 };
25226
25227 LocalStorageWrapper.prototype.removeItem = function (key) {
25228 return new PromisePolyfill(_.bind(function (resolve, reject) {
25229 try {
25230 this.storage.removeItem(key);
25231 } catch (e) {
25232 reject(e);
25233 }
25234 resolve();
25235 }, this));
25236 };
25237
25238 var logger$5 = console_with_prefix('batch');
25239
25240 /**
25241 * RequestQueue: queue for batching API requests with localStorage backup for retries.
25242 * Maintains an in-memory queue which represents the source of truth for the current
25243 * page, but also writes all items out to a copy in the browser's localStorage, which
25244 * can be read on subsequent pageloads and retried. For batchability, all the request
25245 * items in the queue should be of the same type (events, people updates, group updates)
25246 * so they can be sent in a single request to the same API endpoint.
25247 *
25248 * LocalStorage keying and locking: In order for reloads and subsequent pageloads of
25249 * the same site to access the same persisted data, they must share the same localStorage
25250 * key (for instance based on project token and queue type). Therefore access to the
25251 * localStorage entry is guarded by an asynchronous mutex (SharedLock) to prevent
25252 * simultaneously open windows/tabs from overwriting each other's data (which would lead
25253 * to data loss in some situations).
25254 * @constructor
25255 */
25256 var RequestQueue = function (storageKey, options) {
25257 options = options || {};
25258 this.storageKey = storageKey;
25259 this.usePersistence = options.usePersistence;
25260 if (this.usePersistence) {
25261 this.queueStorage = options.queueStorage || new LocalStorageWrapper();
25262 this.lock = new SharedLock(storageKey, {
25263 storage: options.sharedLockStorage || win.localStorage,
25264 timeoutMS: options.sharedLockTimeoutMS,
25265 });
25266 }
25267 this.reportError = options.errorReporter || _.bind(logger$5.error, logger$5);
25268
25269 this.pid = options.pid || null; // pass pid to test out storage lock contention scenarios
25270
25271 this.memQueue = [];
25272 this.initialized = false;
25273
25274 if (options.enqueueThrottleMs) {
25275 this.enqueuePersisted = batchedThrottle(_.bind(this._enqueuePersisted, this), options.enqueueThrottleMs);
25276 } else {
25277 this.enqueuePersisted = _.bind(function (queueEntry) {
25278 return this._enqueuePersisted([queueEntry]);
25279 }, this);
25280 }
25281 };
25282
25283 RequestQueue.prototype.ensureInit = function () {
25284 if (this.initialized || !this.usePersistence) {
25285 return PromisePolyfill.resolve();
25286 }
25287
25288 return this.queueStorage
25289 .init()
25290 .then(_.bind(function () {
25291 this.initialized = true;
25292 }, this))
25293 .catch(_.bind(function (err) {
25294 this.reportError('Error initializing queue persistence. Disabling persistence', err);
25295 this.initialized = true;
25296 this.usePersistence = false;
25297 }, this));
25298 };
25299
25300 /**
25301 * Add one item to queues (memory and localStorage). The queued entry includes
25302 * the given item along with an auto-generated ID and a "flush-after" timestamp.
25303 * It is expected that the item will be sent over the network and dequeued
25304 * before the flush-after time; if this doesn't happen it is considered orphaned
25305 * (e.g., the original tab where it was enqueued got closed before it could be
25306 * sent) and the item can be sent by any tab that finds it in localStorage.
25307 *
25308 * The final callback param is called with a param indicating success or
25309 * failure of the enqueue operation; it is asynchronous because the localStorage
25310 * lock is asynchronous.
25311 */
25312 RequestQueue.prototype.enqueue = function (item, flushInterval) {
25313 var queueEntry = {
25314 'id': cheap_guid(),
25315 'flushAfter': new Date().getTime() + flushInterval * 2,
25316 'payload': item
25317 };
25318
25319 if (!this.usePersistence) {
25320 this.memQueue.push(queueEntry);
25321 return PromisePolyfill.resolve(true);
25322 } else {
25323 return this.enqueuePersisted(queueEntry);
25324 }
25325 };
25326
25327 RequestQueue.prototype._enqueuePersisted = function (queueEntries) {
25328 var enqueueItem = _.bind(function () {
25329 return this.ensureInit()
25330 .then(_.bind(function () {
25331 return this.readFromStorage();
25332 }, this))
25333 .then(_.bind(function (storedQueue) {
25334 return this.saveToStorage(storedQueue.concat(queueEntries));
25335 }, this))
25336 .then(_.bind(function (succeeded) {
25337 // only add to in-memory queue when storage succeeds
25338 if (succeeded) {
25339 this.memQueue = this.memQueue.concat(queueEntries);
25340 }
25341
25342 return succeeded;
25343 }, this))
25344 .catch(_.bind(function (err) {
25345 this.reportError('Error enqueueing items', err, queueEntries);
25346 return false;
25347 }, this));
25348 }, this);
25349
25350 return this.lock
25351 .withLock(enqueueItem, this.pid)
25352 .catch(_.bind(function (err) {
25353 this.reportError('Error acquiring storage lock', err);
25354 return false;
25355 }, this));
25356 };
25357
25358 /**
25359 * Read out the given number of queue entries. If this.memQueue
25360 * has fewer than batchSize items, then look for "orphaned" items
25361 * in the persisted queue (items where the 'flushAfter' time has
25362 * already passed).
25363 */
25364 RequestQueue.prototype.fillBatch = function (batchSize) {
25365 var batch = this.memQueue.slice(0, batchSize);
25366 if (this.usePersistence && batch.length < batchSize) {
25367 // don't need lock just to read events; localStorage is thread-safe
25368 // and the worst that could happen is a duplicate send of some
25369 // orphaned events, which will be deduplicated on the server side
25370 return this.ensureInit()
25371 .then(_.bind(function () {
25372 return this.readFromStorage();
25373 }, this))
25374 .then(_.bind(function (storedQueue) {
25375 if (storedQueue.length) {
25376 // item IDs already in batch; don't duplicate out of storage
25377 var idsInBatch = {}; // poor man's Set
25378 _.each(batch, function (item) {
25379 idsInBatch[item['id']] = true;
25380 });
25381
25382 for (var i = 0; i < storedQueue.length; i++) {
25383 var item = storedQueue[i];
25384 if (new Date().getTime() > item['flushAfter'] && !idsInBatch[item['id']]) {
25385 item.orphaned = true;
25386 batch.push(item);
25387 if (batch.length >= batchSize) {
25388 break;
25389 }
25390 }
25391 }
25392 }
25393
25394 return batch;
25395 }, this));
25396 } else {
25397 return PromisePolyfill.resolve(batch);
25398 }
25399 };
25400
25401 /**
25402 * Remove items with matching 'id' from array (immutably)
25403 * also remove any item without a valid id (e.g., malformed
25404 * storage entries).
25405 */
25406 var filterOutIDsAndInvalid = function (items, idSet) {
25407 var filteredItems = [];
25408 _.each(items, function (item) {
25409 if (item['id'] && !idSet[item['id']]) {
25410 filteredItems.push(item);
25411 }
25412 });
25413 return filteredItems;
25414 };
25415
25416 /**
25417 * Remove items with matching IDs from both in-memory queue
25418 * and persisted queue
25419 */
25420 RequestQueue.prototype.removeItemsByID = function (ids) {
25421 var idSet = {}; // poor man's Set
25422 _.each(ids, function (id) {
25423 idSet[id] = true;
25424 });
25425
25426 this.memQueue = filterOutIDsAndInvalid(this.memQueue, idSet);
25427 if (!this.usePersistence) {
25428 return PromisePolyfill.resolve(true);
25429 } else {
25430 var removeFromStorage = _.bind(function () {
25431 return this.ensureInit()
25432 .then(_.bind(function () {
25433 return this.readFromStorage();
25434 }, this))
25435 .then(_.bind(function (storedQueue) {
25436 storedQueue = filterOutIDsAndInvalid(storedQueue, idSet);
25437 return this.saveToStorage(storedQueue);
25438 }, this))
25439 .then(_.bind(function () {
25440 return this.readFromStorage();
25441 }, this))
25442 .then(_.bind(function (storedQueue) {
25443 // an extra check: did storage report success but somehow
25444 // the items are still there?
25445 for (var i = 0; i < storedQueue.length; i++) {
25446 var item = storedQueue[i];
25447 if (item['id'] && !!idSet[item['id']]) {
25448 throw new Error('Item not removed from storage');
25449 }
25450 }
25451 return true;
25452 }, this))
25453 .catch(_.bind(function (err) {
25454 this.reportError('Error removing items', err, ids);
25455 return false;
25456 }, this));
25457 }, this);
25458
25459 return this.lock
25460 .withLock(removeFromStorage, this.pid)
25461 .catch(_.bind(function (err) {
25462 this.reportError('Error acquiring storage lock', err);
25463 if (!localStorageSupported(this.lock.storage, true)) {
25464 // Looks like localStorage writes have stopped working sometime after
25465 // initialization (probably full), and so nobody can acquire locks
25466 // anymore. Consider it temporarily safe to remove items without the
25467 // lock, since nobody's writing successfully anyway.
25468 return removeFromStorage()
25469 .then(_.bind(function (success) {
25470 if (!success) {
25471 // OK, we couldn't even write out the smaller queue. Try clearing it
25472 // entirely.
25473 return this.queueStorage.removeItem(this.storageKey).then(function () {
25474 return success;
25475 });
25476 }
25477 return success;
25478 }, this))
25479 .catch(_.bind(function (err) {
25480 this.reportError('Error clearing queue', err);
25481 return false;
25482 }, this));
25483 } else {
25484 return false;
25485 }
25486 }, this));
25487 }
25488 };
25489
25490 // internal helper for RequestQueue.updatePayloads
25491 var updatePayloads = function (existingItems, itemsToUpdate) {
25492 var newItems = [];
25493 _.each(existingItems, function (item) {
25494 var id = item['id'];
25495 if (id in itemsToUpdate) {
25496 var newPayload = itemsToUpdate[id];
25497 if (newPayload !== null) {
25498 item['payload'] = newPayload;
25499 newItems.push(item);
25500 }
25501 } else {
25502 // no update
25503 newItems.push(item);
25504 }
25505 });
25506 return newItems;
25507 };
25508
25509 /**
25510 * Update payloads of given items in both in-memory queue and
25511 * persisted queue. Items set to null are removed from queues.
25512 */
25513 RequestQueue.prototype.updatePayloads = function (itemsToUpdate) {
25514 this.memQueue = updatePayloads(this.memQueue, itemsToUpdate);
25515 if (!this.usePersistence) {
25516 return PromisePolyfill.resolve(true);
25517 } else {
25518 return this.lock
25519 .withLock(_.bind(function lockAcquired() {
25520 return this.ensureInit()
25521 .then(_.bind(function () {
25522 return this.readFromStorage();
25523 }, this))
25524 .then(_.bind(function (storedQueue) {
25525 storedQueue = updatePayloads(storedQueue, itemsToUpdate);
25526 return this.saveToStorage(storedQueue);
25527 }, this))
25528 .catch(_.bind(function (err) {
25529 this.reportError('Error updating items', itemsToUpdate, err);
25530 return false;
25531 }, this));
25532 }, this), this.pid)
25533 .catch(_.bind(function (err) {
25534 this.reportError('Error acquiring storage lock', err);
25535 return false;
25536 }, this));
25537 }
25538 };
25539
25540 /**
25541 * Read and parse items array from localStorage entry, handling
25542 * malformed/missing data if necessary.
25543 */
25544 RequestQueue.prototype.readFromStorage = function () {
25545 return this.ensureInit()
25546 .then(_.bind(function () {
25547 return this.queueStorage.getItem(this.storageKey);
25548 }, this))
25549 .then(_.bind(function (storageEntry) {
25550 if (storageEntry) {
25551 if (!_.isArray(storageEntry)) {
25552 this.reportError('Invalid storage entry:', storageEntry);
25553 storageEntry = null;
25554 }
25555 }
25556 return storageEntry || [];
25557 }, this))
25558 .catch(_.bind(function (err) {
25559 this.reportError('Error retrieving queue', err);
25560 return [];
25561 }, this));
25562 };
25563
25564 /**
25565 * Serialize the given items array to localStorage.
25566 */
25567 RequestQueue.prototype.saveToStorage = function (queue) {
25568 return this.ensureInit()
25569 .then(_.bind(function () {
25570 return this.queueStorage.setItem(this.storageKey, queue);
25571 }, this))
25572 .then(function () {
25573 return true;
25574 })
25575 .catch(_.bind(function (err) {
25576 this.reportError('Error saving queue', err);
25577 return false;
25578 }, this));
25579 };
25580
25581 /**
25582 * Clear out queues (memory and localStorage).
25583 */
25584 RequestQueue.prototype.clear = function () {
25585 this.memQueue = [];
25586
25587 if (this.usePersistence) {
25588 return this.ensureInit()
25589 .then(_.bind(function () {
25590 return this.queueStorage.removeItem(this.storageKey);
25591 }, this));
25592 } else {
25593 return PromisePolyfill.resolve();
25594 }
25595 };
25596
25597 // maximum interval between request retries after exponential backoff
25598 var MAX_RETRY_INTERVAL_MS = 10 * 60 * 1000; // 10 minutes
25599
25600 var logger$4 = console_with_prefix('batch');
25601
25602 /**
25603 * RequestBatcher: manages the queueing, flushing, retry etc of requests of one
25604 * type (events, people, groups).
25605 * Uses RequestQueue to manage the backing store.
25606 * @constructor
25607 */
25608 var RequestBatcher = function(storageKey, options) {
25609 this.errorReporter = options.errorReporter;
25610 this.queue = new RequestQueue(storageKey, {
25611 errorReporter: _.bind(this.reportError, this),
25612 queueStorage: options.queueStorage,
25613 sharedLockStorage: options.sharedLockStorage,
25614 sharedLockTimeoutMS: options.sharedLockTimeoutMS,
25615 usePersistence: options.usePersistence,
25616 enqueueThrottleMs: options.enqueueThrottleMs
25617 });
25618
25619 this.libConfig = options.libConfig;
25620 this.sendRequest = options.sendRequestFunc;
25621 this.beforeSendHook = options.beforeSendHook;
25622 this.stopAllBatching = options.stopAllBatchingFunc;
25623
25624 // seed variable batch size + flush interval with configured values
25625 this.batchSize = this.libConfig['batch_size'];
25626 this.flushInterval = this.libConfig['batch_flush_interval_ms'];
25627
25628 this.stopped = !this.libConfig['batch_autostart'];
25629 this.consecutiveRemovalFailures = 0;
25630
25631 // extra client-side dedupe
25632 this.itemIdsSentSuccessfully = {};
25633
25634 // Make the flush occur at the interval specified by flushIntervalMs, default behavior will attempt consecutive flushes
25635 // as long as the queue is not empty. This is useful for high-frequency events like Session Replay where we might end up
25636 // in a request loop and get ratelimited by the server.
25637 this.flushOnlyOnInterval = options.flushOnlyOnInterval || false;
25638
25639 this._flushPromise = null;
25640 };
25641
25642 /**
25643 * Add one item to queue.
25644 */
25645 RequestBatcher.prototype.enqueue = function(item) {
25646 return this.queue.enqueue(item, this.flushInterval);
25647 };
25648
25649 /**
25650 * Start flushing batches at the configured time interval. Must call
25651 * this method upon SDK init in order to send anything over the network.
25652 */
25653 RequestBatcher.prototype.start = function() {
25654 this.stopped = false;
25655 this.consecutiveRemovalFailures = 0;
25656 return this.flush();
25657 };
25658
25659 /**
25660 * Stop flushing batches. Can be restarted by calling start().
25661 */
25662 RequestBatcher.prototype.stop = function() {
25663 this.stopped = true;
25664 if (this.timeoutID) {
25665 clearTimeout(this.timeoutID);
25666 this.timeoutID = null;
25667 }
25668 };
25669
25670 /**
25671 * Clear out queue.
25672 */
25673 RequestBatcher.prototype.clear = function() {
25674 return this.queue.clear();
25675 };
25676
25677 /**
25678 * Restore batch size configuration to whatever is set in the main SDK.
25679 */
25680 RequestBatcher.prototype.resetBatchSize = function() {
25681 this.batchSize = this.libConfig['batch_size'];
25682 };
25683
25684 /**
25685 * Restore flush interval time configuration to whatever is set in the main SDK.
25686 */
25687 RequestBatcher.prototype.resetFlush = function() {
25688 this.scheduleFlush(this.libConfig['batch_flush_interval_ms']);
25689 };
25690
25691 /**
25692 * Schedule the next flush in the given number of milliseconds.
25693 */
25694 RequestBatcher.prototype.scheduleFlush = function(flushMS) {
25695 this.flushInterval = flushMS;
25696 if (!this.stopped) { // don't schedule anymore if batching has been stopped
25697 this.timeoutID = setTimeout(_.bind(function() {
25698 if (!this.stopped) {
25699 this._flushPromise = this.flush();
25700 }
25701 }, this), this.flushInterval);
25702 }
25703 };
25704
25705 /**
25706 * Send a request using the sendRequest callback, but promisified.
25707 * TODO: sendRequest should be promisified in the first place.
25708 */
25709 RequestBatcher.prototype.sendRequestPromise = function(data, options) {
25710 return new PromisePolyfill(_.bind(function(resolve) {
25711 this.sendRequest(data, options, resolve);
25712 }, this));
25713 };
25714
25715
25716 /**
25717 * Flush one batch to network. Depending on success/failure modes, it will either
25718 * remove the batch from the queue or leave it in for retry, and schedule the next
25719 * flush. In cases of most network or API failures, it will back off exponentially
25720 * when retrying.
25721 * @param {Object} [options]
25722 * @param {boolean} [options.sendBeacon] - whether to send batch with
25723 * navigator.sendBeacon (only useful for sending batches before page unloads, as
25724 * sendBeacon offers no callbacks or status indications)
25725 */
25726 RequestBatcher.prototype.flush = function(options) {
25727 if (this.requestInProgress) {
25728 logger$4.log('Flush: Request already in progress');
25729 return PromisePolyfill.resolve();
25730 }
25731
25732 this.requestInProgress = true;
25733
25734 options = options || {};
25735 var timeoutMS = this.libConfig['batch_request_timeout_ms'];
25736 var startTime = new Date().getTime();
25737 var currentBatchSize = this.batchSize;
25738
25739 return this.queue.fillBatch(currentBatchSize)
25740 .then(_.bind(function(batch) {
25741
25742 // if there's more items in the queue than the batch size, attempt
25743 // to flush again after the current batch is done.
25744 var attemptSecondaryFlush = batch.length === currentBatchSize;
25745 var dataForRequest = [];
25746 var transformedItems = {};
25747 _.each(batch, function(item) {
25748 var payload = item['payload'];
25749 if (this.beforeSendHook && !item.orphaned) {
25750 payload = this.beforeSendHook(payload);
25751 }
25752 if (payload) {
25753 // mp_sent_by_lib_version prop captures which lib version actually
25754 // sends each event (regardless of which version originally queued
25755 // it for sending)
25756 if (payload['event'] && payload['properties']) {
25757 payload['properties'] = _.extend(
25758 {},
25759 payload['properties'],
25760 {'mp_sent_by_lib_version': Config.LIB_VERSION}
25761 );
25762 }
25763 var addPayload = true;
25764 var itemId = item['id'];
25765 if (itemId) {
25766 if ((this.itemIdsSentSuccessfully[itemId] || 0) > 5) {
25767 this.reportError('[dupe] item ID sent too many times, not sending', {
25768 item: item,
25769 batchSize: batch.length,
25770 timesSent: this.itemIdsSentSuccessfully[itemId]
25771 });
25772 addPayload = false;
25773 }
25774 } else {
25775 this.reportError('[dupe] found item with no ID', {item: item});
25776 }
25777
25778 if (addPayload) {
25779 dataForRequest.push(payload);
25780 }
25781 }
25782 transformedItems[item['id']] = payload;
25783 }, this);
25784
25785 if (dataForRequest.length < 1) {
25786 this.requestInProgress = false;
25787 this.resetFlush();
25788 return PromisePolyfill.resolve(); // nothing to do
25789 }
25790
25791 var removeItemsFromQueue = _.bind(function () {
25792 return this.queue
25793 .removeItemsByID(
25794 _.map(batch, function (item) {
25795 return item['id'];
25796 })
25797 )
25798 .then(_.bind(function (succeeded) {
25799 // client-side dedupe
25800 _.each(batch, _.bind(function(item) {
25801 var itemId = item['id'];
25802 if (itemId) {
25803 this.itemIdsSentSuccessfully[itemId] = this.itemIdsSentSuccessfully[itemId] || 0;
25804 this.itemIdsSentSuccessfully[itemId]++;
25805 if (this.itemIdsSentSuccessfully[itemId] > 5) {
25806 this.reportError('[dupe] item ID sent too many times', {
25807 item: item,
25808 batchSize: batch.length,
25809 timesSent: this.itemIdsSentSuccessfully[itemId]
25810 });
25811 }
25812 } else {
25813 this.reportError('[dupe] found item with no ID while removing', {item: item});
25814 }
25815 }, this));
25816
25817 if (succeeded) {
25818 this.consecutiveRemovalFailures = 0;
25819 if (this.flushOnlyOnInterval && !attemptSecondaryFlush) {
25820 this.resetFlush(); // schedule next batch with a delay
25821 return PromisePolyfill.resolve();
25822 } else {
25823 return this.flush(); // handle next batch if the queue isn't empty
25824 }
25825 } else {
25826 if (++this.consecutiveRemovalFailures > 5) {
25827 this.reportError('Too many queue failures; disabling batching system.');
25828 this.stopAllBatching();
25829 } else {
25830 this.resetFlush();
25831 }
25832 return PromisePolyfill.resolve();
25833 }
25834 }, this));
25835 }, this);
25836
25837 var batchSendCallback = _.bind(function(res) {
25838 this.requestInProgress = false;
25839
25840 try {
25841
25842 // handle API response in a try-catch to make sure we can reset the
25843 // flush operation if something goes wrong
25844
25845 if (options.unloading) {
25846 // update persisted data to include hook transformations
25847 return this.queue.updatePayloads(transformedItems);
25848 } else if (
25849 _.isObject(res) &&
25850 res.error === 'timeout' &&
25851 new Date().getTime() - startTime >= timeoutMS
25852 ) {
25853 this.reportError('Network timeout; retrying');
25854 return this.flush();
25855 } else if (
25856 _.isObject(res) &&
25857 (
25858 res.httpStatusCode >= 500
25859 || res.httpStatusCode === 429
25860 || (res.httpStatusCode <= 0 && !isOnline())
25861 || res.error === 'timeout'
25862 )
25863 ) {
25864 // network or API error, or 429 Too Many Requests, retry
25865 var retryMS = this.flushInterval * 2;
25866 if (res.retryAfter) {
25867 retryMS = (parseInt(res.retryAfter, 10) * 1000) || retryMS;
25868 }
25869 retryMS = Math.min(MAX_RETRY_INTERVAL_MS, retryMS);
25870 this.reportError('Error; retry in ' + retryMS + ' ms');
25871 this.scheduleFlush(retryMS);
25872 return PromisePolyfill.resolve();
25873 } else if (_.isObject(res) && res.httpStatusCode === 413) {
25874 // 413 Payload Too Large
25875 if (batch.length > 1) {
25876 var halvedBatchSize = Math.max(1, Math.floor(currentBatchSize / 2));
25877 this.batchSize = Math.min(this.batchSize, halvedBatchSize, batch.length - 1);
25878 this.reportError('413 response; reducing batch size to ' + this.batchSize);
25879 this.resetFlush();
25880 return PromisePolyfill.resolve();
25881 } else {
25882 this.reportError('Single-event request too large; dropping', batch);
25883 this.resetBatchSize();
25884 return removeItemsFromQueue();
25885 }
25886 } else {
25887 // successful network request+response; remove each item in batch from queue
25888 // (even if it was e.g. a 400, in which case retrying won't help)
25889 return removeItemsFromQueue();
25890 }
25891 } catch(err) {
25892 this.reportError('Error handling API response', err);
25893 this.resetFlush();
25894 }
25895 }, this);
25896 var requestOptions = {
25897 method: 'POST',
25898 verbose: true,
25899 ignore_json_errors: true, // eslint-disable-line camelcase
25900 timeout_ms: timeoutMS // eslint-disable-line camelcase
25901 };
25902 if (options.unloading) {
25903 requestOptions.transport = 'sendBeacon';
25904 }
25905 logger$4.log('MIXPANEL REQUEST:', dataForRequest);
25906 return this.sendRequestPromise(dataForRequest, requestOptions).then(batchSendCallback);
25907 }, this))
25908 .catch(_.bind(function(err) {
25909 this.reportError('Error flushing request queue', err);
25910 this.resetFlush();
25911 }, this));
25912 };
25913
25914 /**
25915 * Log error to global logger and optional user-defined logger.
25916 */
25917 RequestBatcher.prototype.reportError = function(msg, err) {
25918 logger$4.error.apply(logger$4.error, arguments);
25919 if (this.errorReporter) {
25920 try {
25921 if (!(err instanceof Error)) {
25922 err = new Error(msg);
25923 }
25924 this.errorReporter(msg, err);
25925 } catch(err) {
25926 logger$4.error(err);
25927 }
25928 }
25929 };
25930
25931 /**
25932 * @param {import('./session-recording').SerializedRecording} serializedRecording
25933 * @returns {boolean}
25934 */
25935 var isRecordingExpired = function(serializedRecording) {
25936 var now = Date.now();
25937 return !serializedRecording || now > serializedRecording['maxExpires'] || now > serializedRecording['idleExpires'];
25938 };
25939
25940 var RECORD_ENQUEUE_THROTTLE_MS = 250;
25941
25942 var logger$3 = console_with_prefix('recorder');
25943 var CompressionStream = win['CompressionStream'];
25944
25945 var RECORDER_BATCHER_LIB_CONFIG = {
25946 'batch_size': 1000,
25947 'batch_flush_interval_ms': 10 * 1000,
25948 'batch_request_timeout_ms': 90 * 1000,
25949 'batch_autostart': true
25950 };
25951
25952 var ACTIVE_SOURCES = new Set([
25953 IncrementalSource.MouseMove,
25954 IncrementalSource.MouseInteraction,
25955 IncrementalSource.Scroll,
25956 IncrementalSource.ViewportResize,
25957 IncrementalSource.Input,
25958 IncrementalSource.TouchMove,
25959 IncrementalSource.MediaInteraction,
25960 IncrementalSource.Drag,
25961 IncrementalSource.Selection,
25962 ]);
25963
25964 function isUserEvent(ev) {
25965 return ev.type === EventType.IncrementalSnapshot && ACTIVE_SOURCES.has(ev.data.source);
25966 }
25967
25968 /**
25969 * @typedef {Object} SerializedRecording
25970 * @property {number} idleExpires
25971 * @property {number} maxExpires
25972 * @property {number} replayStartTime
25973 * @property {number} seqNo
25974 * @property {string} batchStartUrl
25975 * @property {string} replayId
25976 * @property {string} tabId
25977 * @property {string} replayStartUrl
25978 */
25979
25980 /**
25981 * @typedef {Object} SessionRecordingOptions
25982 * @property {Object} [options.mixpanelInstance] - reference to the core MixpanelLib
25983 * @property {String} [options.replayId] - unique uuid for a single replay
25984 * @property {Function} [options.onIdleTimeout] - callback when a recording reaches idle timeout
25985 * @property {Function} [options.onMaxLengthReached] - callback when a recording reaches its maximum length
25986 * @property {Function} [options.rrwebRecord] - rrweb's `record` function
25987 * @property {Function} [options.onBatchSent] - callback when a batch of events is sent to the server
25988 * @property {Storage} [options.sharedLockStorage] - optional storage for shared lock, used for test dependency injection
25989 * optional properties for deserialization:
25990 * @property {number} idleExpires
25991 * @property {number} maxExpires
25992 * @property {number} replayStartTime
25993 * @property {number} seqNo
25994 * @property {string} batchStartUrl
25995 * @property {string} replayStartUrl
25996 */
25997
25998 /**
25999 * @typedef {Object} UserIdInfo
26000 * @property {string} distinct_id
26001 * @property {string} user_id
26002 * @property {string} device_id
26003 */
26004
26005
26006 /**
26007 * This class encapsulates a single session recording and its lifecycle.
26008 * @param {SessionRecordingOptions} options
26009 */
26010 var SessionRecording = function(options) {
26011 this._mixpanel = options.mixpanelInstance;
26012 this._onIdleTimeout = options.onIdleTimeout || NOOP_FUNC;
26013 this._onMaxLengthReached = options.onMaxLengthReached || NOOP_FUNC;
26014 this._onBatchSent = options.onBatchSent || NOOP_FUNC;
26015 this._rrwebRecord = options.rrwebRecord || null;
26016
26017 // internal rrweb stopRecording function
26018 this._stopRecording = null;
26019 this.replayId = options.replayId;
26020
26021 this.batchStartUrl = options.batchStartUrl || null;
26022 this.replayStartUrl = options.replayStartUrl || null;
26023 this.idleExpires = options.idleExpires || null;
26024 this.maxExpires = options.maxExpires || null;
26025 this.replayStartTime = options.replayStartTime || null;
26026 this.seqNo = options.seqNo || 0;
26027
26028 this.idleTimeoutId = null;
26029 this.maxTimeoutId = null;
26030
26031 this.recordMaxMs = MAX_RECORDING_MS;
26032 this.recordMinMs = 0;
26033
26034 // disable persistence if localStorage is not supported
26035 // request-queue will automatically disable persistence if indexedDB fails to initialize
26036 var usePersistence = localStorageSupported(options.sharedLockStorage, true) && !this.getConfig('disable_persistence');
26037
26038 // each replay has its own batcher key to avoid conflicts between rrweb events of different recordings
26039 this.batcherKey = '__mprec_' + this.getConfig('name') + '_' + this.getConfig('token') + '_' + this.replayId;
26040 this.queueStorage = new IDBStorageWrapper(RECORDING_EVENTS_STORE_NAME);
26041 this.batcher = new RequestBatcher(this.batcherKey, {
26042 errorReporter: this.reportError.bind(this),
26043 flushOnlyOnInterval: true,
26044 libConfig: RECORDER_BATCHER_LIB_CONFIG,
26045 sendRequestFunc: this.flushEventsWithOptOut.bind(this),
26046 queueStorage: this.queueStorage,
26047 sharedLockStorage: options.sharedLockStorage,
26048 usePersistence: usePersistence,
26049 stopAllBatchingFunc: this.stopRecording.bind(this),
26050
26051 // increased throttle and shared lock timeout because recording events are very high frequency.
26052 // this will minimize the amount of lock contention between enqueued events.
26053 // for session recordings there is a lock for each tab anyway, so there's no risk of deadlock between tabs.
26054 enqueueThrottleMs: RECORD_ENQUEUE_THROTTLE_MS,
26055 sharedLockTimeoutMS: 10 * 1000,
26056 });
26057 };
26058
26059 /**
26060 * @returns {UserIdInfo}
26061 */
26062 SessionRecording.prototype.getUserIdInfo = function () {
26063 if (this.finalFlushUserIdInfo) {
26064 return this.finalFlushUserIdInfo;
26065 }
26066
26067 var userIdInfo = {
26068 'distinct_id': String(this._mixpanel.get_distinct_id()),
26069 };
26070
26071 // send ID management props if they exist
26072 var deviceId = this._mixpanel.get_property('$device_id');
26073 if (deviceId) {
26074 userIdInfo['$device_id'] = deviceId;
26075 }
26076 var userId = this._mixpanel.get_property('$user_id');
26077 if (userId) {
26078 userIdInfo['$user_id'] = userId;
26079 }
26080 return userIdInfo;
26081 };
26082
26083 SessionRecording.prototype.unloadPersistedData = function () {
26084 this.batcher.stop();
26085 return this.batcher.flush()
26086 .then(function () {
26087 return this.queueStorage.removeItem(this.batcherKey);
26088 }.bind(this));
26089 };
26090
26091 SessionRecording.prototype.getConfig = function(configVar) {
26092 return this._mixpanel.get_config(configVar);
26093 };
26094
26095 // Alias for getConfig, used by the common addOptOutCheckMixpanelLib function which
26096 // reaches into this class instance and expects the snake case version of the function.
26097 // eslint-disable-next-line camelcase
26098 SessionRecording.prototype.get_config = function(configVar) {
26099 return this.getConfig(configVar);
26100 };
26101
26102 SessionRecording.prototype.startRecording = function (shouldStopBatcher) {
26103 if (this._rrwebRecord === null) {
26104 this.reportError('rrweb record function not provided. ');
26105 return;
26106 }
26107
26108 if (this._stopRecording !== null) {
26109 logger$3.log('Recording already in progress, skipping startRecording.');
26110 return;
26111 }
26112
26113 this.recordMaxMs = this.getConfig('record_max_ms');
26114 if (this.recordMaxMs > MAX_RECORDING_MS) {
26115 this.recordMaxMs = MAX_RECORDING_MS;
26116 logger$3.critical('record_max_ms cannot be greater than ' + MAX_RECORDING_MS + 'ms. Capping value.');
26117 }
26118
26119 if (!this.maxExpires) {
26120 this.maxExpires = new Date().getTime() + this.recordMaxMs;
26121 }
26122
26123 this.recordMinMs = this.getConfig('record_min_ms');
26124 if (this.recordMinMs > MAX_VALUE_FOR_MIN_RECORDING_MS) {
26125 this.recordMinMs = MAX_VALUE_FOR_MIN_RECORDING_MS;
26126 logger$3.critical('record_min_ms cannot be greater than ' + MAX_VALUE_FOR_MIN_RECORDING_MS + 'ms. Capping value.');
26127 }
26128
26129 if (!this.replayStartTime) {
26130 this.replayStartTime = new Date().getTime();
26131 this.batchStartUrl = _.info.currentUrl();
26132 this.replayStartUrl = _.info.currentUrl();
26133 }
26134
26135 if (shouldStopBatcher || this.recordMinMs > 0) {
26136 // the primary case for shouldStopBatcher is when we're starting recording after a reset
26137 // and don't want to send anything over the network until there's
26138 // actual user activity
26139 // this also applies if the minimum recording length has not been hit yet
26140 // so that we don't send data until we know the recording will be long enough
26141 this.batcher.stop();
26142 } else {
26143 this.batcher.start();
26144 }
26145
26146 var resetIdleTimeout = function () {
26147 clearTimeout(this.idleTimeoutId);
26148 var idleTimeoutMs = this.getConfig('record_idle_timeout_ms');
26149 this.idleTimeoutId = setTimeout(this._onIdleTimeout, idleTimeoutMs);
26150 this.idleExpires = new Date().getTime() + idleTimeoutMs;
26151 }.bind(this);
26152 resetIdleTimeout();
26153
26154 var blockSelector = this.getConfig('record_block_selector');
26155 if (blockSelector === '' || blockSelector === null) {
26156 blockSelector = undefined;
26157 }
26158
26159 try {
26160 this._stopRecording = this._rrwebRecord({
26161 'emit': function (ev) {
26162 if (this.idleExpires && this.idleExpires < ev.timestamp) {
26163 this._onIdleTimeout();
26164 return;
26165 }
26166 if (isUserEvent(ev)) {
26167 if (this.batcher.stopped && new Date().getTime() - this.replayStartTime >= this.recordMinMs) {
26168 // start flushing again after user activity
26169 this.batcher.start();
26170 }
26171 resetIdleTimeout();
26172 }
26173 // promise only used to await during tests
26174 this.__enqueuePromise = this.batcher.enqueue(ev);
26175 }.bind(this),
26176 'blockClass': this.getConfig('record_block_class'),
26177 'blockSelector': blockSelector,
26178 'collectFonts': this.getConfig('record_collect_fonts'),
26179 'dataURLOptions': { // canvas image options (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL)
26180 'type': 'image/webp',
26181 'quality': 0.6
26182 },
26183 'maskAllInputs': true,
26184 'maskTextClass': this.getConfig('record_mask_text_class'),
26185 'maskTextSelector': this.getConfig('record_mask_text_selector'),
26186 'recordCanvas': this.getConfig('record_canvas'),
26187 'sampling': {
26188 'canvas': 15
26189 }
26190 });
26191 } catch (err) {
26192 this.reportError('Unexpected error when starting rrweb recording.', err);
26193 }
26194
26195 if (typeof this._stopRecording !== 'function') {
26196 this.reportError('rrweb failed to start, skipping this recording.');
26197 this._stopRecording = null;
26198 this.stopRecording(); // stop batcher looping and any timeouts
26199 return;
26200 }
26201
26202 var maxTimeoutMs = this.maxExpires - new Date().getTime();
26203 this.maxTimeoutId = setTimeout(this._onMaxLengthReached.bind(this), maxTimeoutMs);
26204 };
26205
26206 SessionRecording.prototype.stopRecording = function (skipFlush) {
26207 // store the user ID info in case this is getting called in mixpanel.reset()
26208 this.finalFlushUserIdInfo = this.getUserIdInfo();
26209
26210 if (!this.isRrwebStopped()) {
26211 try {
26212 this._stopRecording();
26213 } catch (err) {
26214 this.reportError('Error with rrweb stopRecording', err);
26215 }
26216 this._stopRecording = null;
26217 }
26218
26219 var flushPromise;
26220 if (this.batcher.stopped) {
26221 // never got user activity to flush after reset, so just clear the batcher
26222 flushPromise = this.batcher.clear();
26223 } else if (!skipFlush) {
26224 // flush any remaining events from running batcher
26225 flushPromise = this.batcher.flush();
26226 }
26227 this.batcher.stop();
26228
26229 clearTimeout(this.idleTimeoutId);
26230 clearTimeout(this.maxTimeoutId);
26231 return flushPromise;
26232 };
26233
26234 SessionRecording.prototype.isRrwebStopped = function () {
26235 return this._stopRecording === null;
26236 };
26237
26238
26239 /**
26240 * Flushes the current batch of events to the server, but passes an opt-out callback to make sure
26241 * we stop recording and dump any queued events if the user has opted out.
26242 */
26243 SessionRecording.prototype.flushEventsWithOptOut = function (data, options, cb) {
26244 var onOptOut = function (code) {
26245 // addOptOutCheckMixpanelLib invokes this function with code=0 when the user has opted out
26246 if (code === 0) {
26247 this.stopRecording();
26248 cb({error: 'Tracking has been opted out, stopping recording.'});
26249 }
26250 }.bind(this);
26251
26252 this._flushEvents(data, options, cb, onOptOut);
26253 };
26254
26255 /**
26256 * @returns {SerializedRecording}
26257 */
26258 SessionRecording.prototype.serialize = function () {
26259 // don't break if mixpanel instance was destroyed at some point
26260 var tabId;
26261 try {
26262 tabId = this._mixpanel.get_tab_id();
26263 } catch (e) {
26264 this.reportError('Error getting tab ID for serialization ', e);
26265 tabId = null;
26266 }
26267
26268 return {
26269 'replayId': this.replayId,
26270 'seqNo': this.seqNo,
26271 'replayStartTime': this.replayStartTime,
26272 'batchStartUrl': this.batchStartUrl,
26273 'replayStartUrl': this.replayStartUrl,
26274 'idleExpires': this.idleExpires,
26275 'maxExpires': this.maxExpires,
26276 'tabId': tabId,
26277 };
26278 };
26279
26280
26281 /**
26282 * @static
26283 * @param {SerializedRecording} serializedRecording
26284 * @param {SessionRecordingOptions} options
26285 * @returns {SessionRecording}
26286 */
26287 SessionRecording.deserialize = function (serializedRecording, options) {
26288 var recording = new SessionRecording(_.extend({}, options, {
26289 replayId: serializedRecording['replayId'],
26290 batchStartUrl: serializedRecording['batchStartUrl'],
26291 replayStartUrl: serializedRecording['replayStartUrl'],
26292 idleExpires: serializedRecording['idleExpires'],
26293 maxExpires: serializedRecording['maxExpires'],
26294 replayStartTime: serializedRecording['replayStartTime'],
26295 seqNo: serializedRecording['seqNo'],
26296 sharedLockStorage: options.sharedLockStorage,
26297 }));
26298
26299 return recording;
26300 };
26301
26302 SessionRecording.prototype._sendRequest = function(currentReplayId, reqParams, reqBody, callback) {
26303 var onSuccess = function (response, responseBody) {
26304 // Update batch specific props only if the request was successful to guarantee ordering.
26305 // RequestBatcher will always flush the next batch after the previous one succeeds.
26306 // extra check to see if the replay ID has changed so that we don't increment the seqNo on the wrong replay
26307 if (response.status === 200 && this.replayId === currentReplayId) {
26308 this.seqNo++;
26309 this.batchStartUrl = _.info.currentUrl();
26310 }
26311
26312 this._onBatchSent();
26313 callback({
26314 status: 0,
26315 httpStatusCode: response.status,
26316 responseBody: responseBody,
26317 retryAfter: response.headers.get('Retry-After')
26318 });
26319 }.bind(this);
26320 var apiHost = (this._mixpanel.get_api_host && this._mixpanel.get_api_host('record')) || this.getConfig('api_host');
26321 win['fetch'](apiHost + '/' + this.getConfig('api_routes')['record'] + '?' + new URLSearchParams(reqParams), {
26322 'method': 'POST',
26323 'headers': {
26324 'Authorization': 'Basic ' + btoa(this.getConfig('token') + ':'),
26325 'Content-Type': 'application/octet-stream'
26326 },
26327 'body': reqBody,
26328 }).then(function (response) {
26329 response.json().then(function (responseBody) {
26330 onSuccess(response, responseBody);
26331 }).catch(function (error) {
26332 callback({error: error});
26333 });
26334 }).catch(function (error) {
26335 callback({error: error, httpStatusCode: 0});
26336 });
26337 };
26338
26339 SessionRecording.prototype._flushEvents = addOptOutCheckMixpanelLib(function (data, options, callback) {
26340 var numEvents = data.length;
26341
26342 if (numEvents > 0) {
26343 var replayId = this.replayId;
26344
26345 // each rrweb event has a timestamp - leverage those to get time properties
26346 var batchStartTime = Infinity;
26347 var batchEndTime = -Infinity;
26348 var hasFullSnapshot = false;
26349 for (var i = 0; i < numEvents; i++) {
26350 batchStartTime = Math.min(batchStartTime, data[i].timestamp);
26351 batchEndTime = Math.max(batchEndTime, data[i].timestamp);
26352 if (data[i].type === EventType.FullSnapshot) {
26353 hasFullSnapshot = true;
26354 }
26355 }
26356
26357 if (this.seqNo === 0) {
26358 if (!hasFullSnapshot) {
26359 callback({error: 'First batch does not contain a full snapshot. Aborting recording.'});
26360 this.stopRecording(true);
26361 return;
26362 }
26363 this.replayStartTime = batchStartTime;
26364 } else if (!this.replayStartTime) {
26365 this.reportError('Replay start time not set but seqNo is not 0. Using current batch start time as a fallback.');
26366 this.replayStartTime = batchStartTime;
26367 }
26368
26369 var replayLengthMs = batchEndTime - this.replayStartTime;
26370
26371 var reqParams = {
26372 '$current_url': this.batchStartUrl,
26373 '$lib_version': Config.LIB_VERSION,
26374 'batch_start_time': batchStartTime / 1000,
26375 'mp_lib': 'web',
26376 'replay_id': replayId,
26377 'replay_length_ms': replayLengthMs,
26378 'replay_start_time': this.replayStartTime / 1000,
26379 'replay_start_url': this.replayStartUrl,
26380 'seq': this.seqNo
26381 };
26382 var eventsJson = JSON.stringify(data);
26383 Object.assign(reqParams, this.getUserIdInfo());
26384
26385 if (CompressionStream) {
26386 var jsonStream = new Blob([eventsJson], {type: 'application/json'}).stream();
26387 var gzipStream = jsonStream.pipeThrough(new CompressionStream('gzip'));
26388 new Response(gzipStream)
26389 .blob()
26390 .then(function(compressedBlob) {
26391 reqParams['format'] = 'gzip';
26392 this._sendRequest(replayId, reqParams, compressedBlob, callback);
26393 }.bind(this));
26394 } else {
26395 reqParams['format'] = 'body';
26396 this._sendRequest(replayId, reqParams, eventsJson, callback);
26397 }
26398 }
26399 });
26400
26401
26402 SessionRecording.prototype.reportError = function(msg, err) {
26403 logger$3.error.apply(logger$3.error, arguments);
26404 try {
26405 if (!err && !(msg instanceof Error)) {
26406 msg = new Error(msg);
26407 }
26408 this.getConfig('error_reporter')(msg, err);
26409 } catch(err) {
26410 logger$3.error(err);
26411 }
26412 };
26413
26414 /**
26415 * Module for handling the storage and retrieval of recording metadata as well as any active recordings.
26416 * Makes sure that only one tab can be recording at a time.
26417 */
26418 var RecordingRegistry = function (options) {
26419 /** @type {IDBStorageWrapper} */
26420 this.idb = new IDBStorageWrapper(RECORDING_REGISTRY_STORE_NAME);
26421 this.errorReporter = options.errorReporter;
26422 this.mixpanelInstance = options.mixpanelInstance;
26423 this.sharedLockStorage = options.sharedLockStorage;
26424 };
26425
26426 RecordingRegistry.prototype.isPersistenceEnabled = function() {
26427 return !this.mixpanelInstance.get_config('disable_persistence');
26428 };
26429
26430 RecordingRegistry.prototype.handleError = function (err) {
26431 this.errorReporter('IndexedDB error: ', err);
26432 };
26433
26434 /**
26435 * @param {import('./session-recording').SerializedRecording} serializedRecording
26436 */
26437 RecordingRegistry.prototype.setActiveRecording = function (serializedRecording) {
26438 if (!this.isPersistenceEnabled()) {
26439 return PromisePolyfill.resolve();
26440 }
26441
26442 var tabId = serializedRecording['tabId'];
26443 if (!tabId) {
26444 console.warn('No tab ID is set, cannot persist recording metadata.');
26445 return PromisePolyfill.resolve();
26446 }
26447
26448 return this.idb.init()
26449 .then(function () {
26450 return this.idb.setItem(tabId, serializedRecording);
26451 }.bind(this))
26452 .catch(this.handleError.bind(this));
26453 };
26454
26455 /**
26456 * @returns {Promise<import('./session-recording').SerializedRecording>}
26457 */
26458 RecordingRegistry.prototype.getActiveRecording = function () {
26459 if (!this.isPersistenceEnabled()) {
26460 return PromisePolyfill.resolve(null);
26461 }
26462
26463 return this.idb.init()
26464 .then(function () {
26465 return this.idb.getItem(this.mixpanelInstance.get_tab_id());
26466 }.bind(this))
26467 .then(function (serializedRecording) {
26468 return isRecordingExpired(serializedRecording) ? null : serializedRecording;
26469 }.bind(this))
26470 .catch(this.handleError.bind(this));
26471 };
26472
26473 RecordingRegistry.prototype.clearActiveRecording = function () {
26474 if (this.isPersistenceEnabled()) {
26475 // mark recording as expired instead of deleting it in case the page unloads mid-flush and doesn't make it to ingestion.
26476 // this will ensure the next pageload will flush the remaining events, but not try to continue the recording.
26477 return this.markActiveRecordingExpired();
26478 } else {
26479 return this.deleteActiveRecording();
26480 }
26481 };
26482
26483 RecordingRegistry.prototype.markActiveRecordingExpired = function () {
26484 return this.getActiveRecording()
26485 .then(function (serializedRecording) {
26486 if (serializedRecording) {
26487 serializedRecording['maxExpires'] = 0;
26488 return this.setActiveRecording(serializedRecording);
26489 }
26490 }.bind(this))
26491 .catch(this.handleError.bind(this));
26492 };
26493
26494 RecordingRegistry.prototype.deleteActiveRecording = function () {
26495 // avoid initializing IDB if this registry instance hasn't already written a recording
26496 if (this.idb.isInitialized()) {
26497 return this.idb.removeItem(this.mixpanelInstance.get_tab_id())
26498 .catch(this.handleError.bind(this));
26499 } else {
26500 return PromisePolyfill.resolve();
26501 }
26502 };
26503
26504 /**
26505 * Flush any inactive recordings from the registry to minimize data loss.
26506 * The main idea here is that we can flush remaining rrweb events on the next page load if a tab is closed mid-batch.
26507 */
26508 RecordingRegistry.prototype.flushInactiveRecordings = function () {
26509 if (!this.isPersistenceEnabled()) {
26510 return PromisePolyfill.resolve([]);
26511 }
26512
26513 return this.idb.init()
26514 .then(function() {
26515 return this.idb.getAll();
26516 }.bind(this))
26517 .then(function (serializedRecordings) {
26518 // clean up any expired recordings from the registry, non-expired ones may be active in other tabs
26519 var unloadPromises = serializedRecordings
26520 .filter(function (serializedRecording) {
26521 return isRecordingExpired(serializedRecording);
26522 })
26523 .map(function (serializedRecording) {
26524 var sessionRecording = SessionRecording.deserialize(serializedRecording, {
26525 mixpanelInstance: this.mixpanelInstance,
26526 sharedLockStorage: this.sharedLockStorage
26527 });
26528 return sessionRecording.unloadPersistedData()
26529 .then(function () {
26530 // expired recording was successfully flushed, we can clean it up from the registry
26531 return this.idb.removeItem(serializedRecording['tabId']);
26532 }.bind(this))
26533 .catch(this.handleError.bind(this));
26534 }.bind(this));
26535
26536 return PromisePolyfill.all(unloadPromises);
26537 }.bind(this))
26538 .catch(this.handleError.bind(this));
26539 };
26540
26541 var logger$2 = console_with_prefix('recorder');
26542
26543 /**
26544 * Recorder API: bundles rrweb and and exposes methods to start and stop recordings.
26545 * @param {Object} [options.mixpanelInstance] - reference to the core MixpanelLib
26546 */
26547 var MixpanelRecorder = function(mixpanelInstance, rrwebRecord, sharedLockStorage) {
26548 this.mixpanelInstance = mixpanelInstance;
26549 this.rrwebRecord = rrwebRecord || record;
26550 this.sharedLockStorage = sharedLockStorage;
26551
26552 /**
26553 * @member {import('./registry').RecordingRegistry}
26554 */
26555 this.recordingRegistry = new RecordingRegistry({
26556 mixpanelInstance: this.mixpanelInstance,
26557 errorReporter: logger$2.error,
26558 sharedLockStorage: sharedLockStorage
26559 });
26560 this._flushInactivePromise = this.recordingRegistry.flushInactiveRecordings();
26561
26562 this.activeRecording = null;
26563 this.stopRecordingInProgress = false;
26564 };
26565
26566 MixpanelRecorder.prototype.startRecording = function(options) {
26567 options = options || {};
26568 if (this.activeRecording && !this.activeRecording.isRrwebStopped()) {
26569 logger$2.log('Recording already in progress, skipping startRecording.');
26570 return;
26571 }
26572
26573 var onIdleTimeout = function () {
26574 logger$2.log('Idle timeout reached, restarting recording.');
26575 this.resetRecording();
26576 }.bind(this);
26577
26578 var onMaxLengthReached = function () {
26579 logger$2.log('Max recording length reached, stopping recording.');
26580 this.resetRecording();
26581 }.bind(this);
26582
26583 var onBatchSent = function () {
26584 this.recordingRegistry.setActiveRecording(this.activeRecording.serialize());
26585 this['__flushPromise'] = this.activeRecording.batcher._flushPromise;
26586 }.bind(this);
26587
26588 /**
26589 * @type {import('./session-recording').SessionRecordingOptions}
26590 */
26591 var sessionRecordingOptions = {
26592 mixpanelInstance: this.mixpanelInstance,
26593 onBatchSent: onBatchSent,
26594 onIdleTimeout: onIdleTimeout,
26595 onMaxLengthReached: onMaxLengthReached,
26596 replayId: _.UUID(),
26597 rrwebRecord: this.rrwebRecord,
26598 sharedLockStorage: this.sharedLockStorage
26599 };
26600
26601 if (options.activeSerializedRecording) {
26602 this.activeRecording = SessionRecording.deserialize(options.activeSerializedRecording, sessionRecordingOptions);
26603 } else {
26604 this.activeRecording = new SessionRecording(sessionRecordingOptions);
26605 }
26606
26607 this.activeRecording.startRecording(options.shouldStopBatcher);
26608 return this.recordingRegistry.setActiveRecording(this.activeRecording.serialize());
26609 };
26610
26611 MixpanelRecorder.prototype.stopRecording = function() {
26612 // Prevents activeSerializedRecording from being reused when stopping the recording.
26613 this.stopRecordingInProgress = true;
26614 return this._stopCurrentRecording(false, true).then(function() {
26615 return this.recordingRegistry.clearActiveRecording();
26616 }.bind(this)).then(function() {
26617 this.stopRecordingInProgress = false;
26618 }.bind(this));
26619 };
26620
26621 MixpanelRecorder.prototype.pauseRecording = function() {
26622 return this._stopCurrentRecording(false);
26623 };
26624
26625 MixpanelRecorder.prototype._stopCurrentRecording = function(skipFlush, disableActiveRecording) {
26626 if (this.activeRecording) {
26627 var stopRecordingPromise = this.activeRecording.stopRecording(skipFlush);
26628 if (disableActiveRecording) {
26629 this.activeRecording = null;
26630 }
26631 return stopRecordingPromise;
26632 }
26633 return PromisePolyfill.resolve();
26634 };
26635
26636 MixpanelRecorder.prototype.resumeRecording = function (startNewIfInactive) {
26637 if (this.activeRecording && this.activeRecording.isRrwebStopped()) {
26638 this.activeRecording.startRecording(false);
26639 return PromisePolyfill.resolve(null);
26640 }
26641
26642 return this.recordingRegistry.getActiveRecording()
26643 .then(function (activeSerializedRecording) {
26644 if (activeSerializedRecording && !this.stopRecordingInProgress) {
26645 return this.startRecording({activeSerializedRecording: activeSerializedRecording});
26646 } else if (startNewIfInactive) {
26647 return this.startRecording({shouldStopBatcher: false});
26648 } else {
26649 logger$2.log('No resumable recording found.');
26650 return null;
26651 }
26652 }.bind(this));
26653 };
26654
26655
26656 MixpanelRecorder.prototype.resetRecording = function () {
26657 this.stopRecording();
26658 this.startRecording({shouldStopBatcher: true});
26659 };
26660
26661 MixpanelRecorder.prototype.getActiveReplayId = function () {
26662 if (this.activeRecording && !this.activeRecording.isRrwebStopped()) {
26663 return this.activeRecording.replayId;
26664 } else {
26665 return null;
26666 }
26667 };
26668
26669 // getter so that older mixpanel-core versions can still retrieve the replay ID
26670 // when pulling the latest recorder bundle from the CDN
26671 Object.defineProperty(MixpanelRecorder.prototype, 'replayId', {
26672 get: function () {
26673 return this.getActiveReplayId();
26674 }
26675 });
26676
26677 win['__mp_recorder'] = MixpanelRecorder;
26678
26679 // stateless utils
26680 // mostly from https://github.com/mixpanel/mixpanel-js/blob/989ada50f518edab47b9c4fd9535f9fbd5ec5fc0/src/autotrack-utils.js
26681
26682
26683 var EV_CHANGE = 'change';
26684 var EV_CLICK = 'click';
26685 var EV_HASHCHANGE = 'hashchange';
26686 var EV_INPUT = 'input';
26687 var EV_LOAD = 'load';
26688 var EV_MP_LOCATION_CHANGE = 'mp_locationchange';
26689 var EV_POPSTATE = 'popstate';
26690 // TODO scrollend isn't available in Safari: document or polyfill?
26691 var EV_SCROLLEND = 'scrollend';
26692 var EV_SCROLL = 'scroll';
26693 var EV_SELECT = 'select';
26694 var EV_SUBMIT = 'submit';
26695 var EV_TOGGLE = 'toggle';
26696 var EV_VISIBILITYCHANGE = 'visibilitychange';
26697
26698 var CLICK_EVENT_PROPS = [
26699 'clientX', 'clientY',
26700 'offsetX', 'offsetY',
26701 'pageX', 'pageY',
26702 'screenX', 'screenY',
26703 'x', 'y'
26704 ];
26705 var OPT_IN_CLASSES = ['mp-include'];
26706 var OPT_OUT_CLASSES = ['mp-no-track'];
26707 var SENSITIVE_DATA_CLASSES = OPT_OUT_CLASSES.concat(['mp-sensitive']);
26708 var TRACKED_ATTRS = [
26709 'aria-label', 'aria-labelledby', 'aria-describedby',
26710 'href', 'name', 'role', 'title', 'type'
26711 ];
26712
26713 var INTERACTIVE_ARIA_ROLES = {
26714 'button': true,
26715 'checkbox': true,
26716 'combobox': true,
26717 'grid': true,
26718 'link': true,
26719 'listbox': true,
26720 'menu': true,
26721 'menubar': true,
26722 'menuitem': true,
26723 'menuitemcheckbox': true,
26724 'menuitemradio': true,
26725 'navigation': true,
26726 'option': true,
26727 'radio': true,
26728 'radiogroup': true,
26729 'searchbox': true,
26730 'slider': true,
26731 'spinbutton': true,
26732 'switch': true,
26733 'tab': true,
26734 'tablist': true,
26735 'textbox': true,
26736 'tree': true,
26737 'treegrid': true,
26738 'treeitem': true
26739 };
26740
26741 var ALWAYS_NON_INTERACTIVE_TAGS = {
26742 // Document metadata
26743 'base': true,
26744 'head': true,
26745 'html': true,
26746 'link': true,
26747 'meta': true,
26748 'script': true,
26749 'style': true,
26750 'title': true,
26751 // Text formatting
26752 'br': true,
26753 'hr': true,
26754 'wbr': true,
26755 // Other
26756 'noscript': true,
26757 'picture': true,
26758 'source': true,
26759 'template': true,
26760 'track': true
26761 };
26762
26763 // Common container tags that need additional checks
26764 var TEXT_CONTAINER_TAGS = {
26765 'article': true,
26766 'div': true,
26767 'h1': true,
26768 'h2': true,
26769 'h3': true,
26770 'h4': true,
26771 'h5': true,
26772 'h6': true,
26773 'p': true,
26774 'section': true,
26775 'span': true
26776 };
26777
26778 var EVENT_HANDLER_ATTRIBUTES = [
26779 'onclick', 'onmousedown', 'onmouseup', 'onpointerdown', 'onpointerup', 'ontouchend', 'ontouchstart'
26780 ];
26781
26782 var MAX_DEPTH = 5;
26783
26784 var logger$1 = console_with_prefix('autocapture');
26785
26786
26787 function getClasses(el) {
26788 var classes = {};
26789 var classList = getClassName(el).split(' ');
26790 for (var i = 0; i < classList.length; i++) {
26791 var cls = classList[i];
26792 if (cls) {
26793 classes[cls] = true;
26794 }
26795 }
26796 return classes;
26797 }
26798
26799 /*
26800 * Get the className of an element, accounting for edge cases where element.className is an object
26801 * @param {Element} el - element to get the className of
26802 * @returns {string} the element's class
26803 */
26804 function getClassName(el) {
26805 switch(typeof el.className) {
26806 case 'string':
26807 return el.className;
26808 case 'object': // handle cases where className might be SVGAnimatedString or some other type
26809 return el.className.baseVal || el.getAttribute('class') || '';
26810 default: // future proof
26811 return '';
26812 }
26813 }
26814
26815 function getPreviousElementSibling(el) {
26816 if (el.previousElementSibling) {
26817 return el.previousElementSibling;
26818 } else {
26819 do {
26820 el = el.previousSibling;
26821 } while (el && !isElementNode(el));
26822 return el;
26823 }
26824 }
26825
26826 function getPropertiesFromElement(el, ev, blockAttrsSet, extraAttrs, allowElementCallback, allowSelectors) {
26827 var props = {
26828 '$classes': getClassName(el).split(' '),
26829 '$tag_name': el.tagName.toLowerCase()
26830 };
26831 var elId = el.id;
26832 if (elId) {
26833 props['$id'] = elId;
26834 }
26835
26836 if (shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors)) {
26837 _.each(TRACKED_ATTRS.concat(extraAttrs), function(attr) {
26838 if (el.hasAttribute(attr) && !blockAttrsSet[attr]) {
26839 var attrVal = el.getAttribute(attr);
26840 if (shouldTrackValue(attrVal)) {
26841 props['$attr-' + attr] = attrVal;
26842 }
26843 }
26844 });
26845 }
26846
26847 var nthChild = 1;
26848 var nthOfType = 1;
26849 var currentElem = el;
26850 while (currentElem = getPreviousElementSibling(currentElem)) { // eslint-disable-line no-cond-assign
26851 nthChild++;
26852 if (currentElem.tagName === el.tagName) {
26853 nthOfType++;
26854 }
26855 }
26856 props['$nth_child'] = nthChild;
26857 props['$nth_of_type'] = nthOfType;
26858
26859 return props;
26860 }
26861
26862 function getPropsForDOMEvent(ev, config) {
26863 var allowElementCallback = config.allowElementCallback;
26864 var allowSelectors = config.allowSelectors || [];
26865 var blockAttrs = config.blockAttrs || [];
26866 var blockElementCallback = config.blockElementCallback;
26867 var blockSelectors = config.blockSelectors || [];
26868 var captureTextContent = config.captureTextContent || false;
26869 var captureExtraAttrs = config.captureExtraAttrs || [];
26870 var capturedForHeatMap = config.capturedForHeatMap || false;
26871
26872 // convert array to set every time, as the config may have changed
26873 var blockAttrsSet = {};
26874 _.each(blockAttrs, function(attr) {
26875 blockAttrsSet[attr] = true;
26876 });
26877
26878 var props = null;
26879
26880 var target = typeof ev.target === 'undefined' ? ev.srcElement : ev.target;
26881 if (isTextNode(target)) { // defeat Safari bug (see: http://www.quirksmode.org/js/events_properties.html)
26882 target = target.parentNode;
26883 }
26884
26885 if (
26886 shouldTrackDomEvent(target, ev) &&
26887 isElementAllowed(target, ev, allowElementCallback, allowSelectors) &&
26888 !isElementBlocked(target, ev, blockElementCallback, blockSelectors)
26889 ) {
26890 var targetElementList = [target];
26891 var curEl = target;
26892 while (curEl.parentNode && !isTag(curEl, 'body')) {
26893 targetElementList.push(curEl.parentNode);
26894 curEl = curEl.parentNode;
26895 }
26896
26897 var elementsJson = [];
26898 var href, explicitNoTrack = false;
26899 _.each(targetElementList, function(el) {
26900 var shouldTrackDetails = shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors);
26901
26902 // if the element or a parent element is an anchor tag
26903 // include the href as a property
26904 if (!blockAttrsSet['href'] && el.tagName.toLowerCase() === 'a') {
26905 href = el.getAttribute('href');
26906 href = shouldTrackDetails && shouldTrackValue(href) && href;
26907 }
26908
26909 if (isElementBlocked(el, ev, blockElementCallback, blockSelectors)) {
26910 explicitNoTrack = true;
26911 }
26912
26913 elementsJson.push(getPropertiesFromElement(el, ev, blockAttrsSet, captureExtraAttrs, allowElementCallback, allowSelectors));
26914 }, this);
26915
26916 if (!explicitNoTrack) {
26917 var docElement = document$1['documentElement'];
26918 props = {
26919 '$event_type': ev.type,
26920 '$host': win.location.host,
26921 '$pathname': win.location.pathname,
26922 '$elements': elementsJson,
26923 '$el_attr__href': href,
26924 '$viewportHeight': Math.max(docElement['clientHeight'], win['innerHeight'] || 0),
26925 '$viewportWidth': Math.max(docElement['clientWidth'], win['innerWidth'] || 0),
26926 '$pageHeight': document$1['body']['offsetHeight'] || 0,
26927 '$pageWidth': document$1['body']['offsetWidth'] || 0,
26928 };
26929 _.each(captureExtraAttrs, function(attr) {
26930 if (!blockAttrsSet[attr] && target.hasAttribute(attr)) {
26931 var attrVal = target.getAttribute(attr);
26932 if (shouldTrackValue(attrVal)) {
26933 props['$el_attr__' + attr] = attrVal;
26934 }
26935 }
26936 });
26937
26938 if (captureTextContent) {
26939 elementText = getSafeText(target, ev, allowElementCallback, allowSelectors);
26940 if (elementText && elementText.length) {
26941 props['$el_text'] = elementText;
26942 }
26943 }
26944
26945 if (ev.type === EV_CLICK) {
26946 _.each(CLICK_EVENT_PROPS, function(prop) {
26947 if (prop in ev) {
26948 props['$' + prop] = ev[prop];
26949 }
26950 });
26951 if (capturedForHeatMap) {
26952 props['$captured_for_heatmap'] = true;
26953 }
26954 target = guessRealClickTarget(ev);
26955 }
26956 // prioritize text content from "real" click target if different from original target
26957 if (captureTextContent) {
26958 var elementText = getSafeText(target, ev, allowElementCallback, allowSelectors);
26959 if (elementText && elementText.length) {
26960 props['$el_text'] = elementText;
26961 }
26962 }
26963
26964 if (target) {
26965 // target may have been recalculated; check allowlists and blocklists again
26966 if (
26967 !isElementAllowed(target, ev, allowElementCallback, allowSelectors) ||
26968 isElementBlocked(target, ev, blockElementCallback, blockSelectors)
26969 ) {
26970 return null;
26971 }
26972
26973 var targetProps = getPropertiesFromElement(target, ev, blockAttrsSet, captureExtraAttrs, allowElementCallback, allowSelectors);
26974 props['$target'] = targetProps;
26975 // pull up more props onto main event props
26976 props['$el_classes'] = targetProps['$classes'];
26977 _.extend(props, _.strip_empty_properties({
26978 '$el_id': targetProps['$id'],
26979 '$el_tag_name': targetProps['$tag_name']
26980 }));
26981 }
26982 }
26983 }
26984
26985 return props;
26986 }
26987
26988
26989 /**
26990 * Get the direct text content of an element, protecting against sensitive data collection.
26991 * Concats textContent of each of the element's text node children; this avoids potential
26992 * collection of sensitive data that could happen if we used element.textContent and the
26993 * element had sensitive child elements, since element.textContent includes child content.
26994 * Scrubs values that look like they could be sensitive (i.e. cc or ssn number).
26995 * @param {Element} el - element to get the text of
26996 * @param {Array<string>} allowSelectors - CSS selectors for elements that should be included
26997 * @returns {string} the element's direct text content
26998 */
26999 function getSafeText(el, ev, allowElementCallback, allowSelectors) {
27000 var elText = '';
27001
27002 if (shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors) && el.childNodes && el.childNodes.length) {
27003 _.each(el.childNodes, function(child) {
27004 if (isTextNode(child) && child.textContent) {
27005 elText += _.trim(child.textContent)
27006 // scrub potentially sensitive values
27007 .split(/(\s+)/).filter(shouldTrackValue).join('')
27008 // normalize whitespace
27009 .replace(/[\r\n]/g, ' ').replace(/[ ]+/g, ' ')
27010 // truncate
27011 .substring(0, 255);
27012 }
27013 });
27014 }
27015
27016 return _.trim(elText);
27017 }
27018
27019 function guessRealClickTarget(ev) {
27020 var target = ev.target;
27021 var composedPath = ev['composedPath']();
27022 for (var i = 0; i < composedPath.length; i++) {
27023 var node = composedPath[i];
27024 if (
27025 isTag(node, 'a') ||
27026 isTag(node, 'button') ||
27027 isTag(node, 'input') ||
27028 isTag(node, 'select') ||
27029 (node.getAttribute && node.getAttribute('role') === 'button')
27030 ) {
27031 target = node;
27032 break;
27033 }
27034 if (node === target) {
27035 break;
27036 }
27037 }
27038 return target;
27039 }
27040
27041 function isElementAllowed(el, ev, allowElementCallback, allowSelectors) {
27042 if (allowElementCallback) {
27043 try {
27044 if (!allowElementCallback(el, ev)) {
27045 return false;
27046 }
27047 } catch (err) {
27048 logger$1.critical('Error while checking element in allowElementCallback', err);
27049 return false;
27050 }
27051 }
27052
27053 if (!allowSelectors.length) {
27054 // no allowlist; all elements are fair game
27055 return true;
27056 }
27057
27058 for (var i = 0; i < allowSelectors.length; i++) {
27059 var sel = allowSelectors[i];
27060 try {
27061 if (el['matches'](sel)) {
27062 return true;
27063 }
27064 } catch (err) {
27065 logger$1.critical('Error while checking selector: ' + sel, err);
27066 }
27067 }
27068 return false;
27069 }
27070
27071 function isElementBlocked(el, ev, blockElementCallback, blockSelectors) {
27072 var i;
27073
27074 if (blockElementCallback) {
27075 try {
27076 if (blockElementCallback(el, ev)) {
27077 return true;
27078 }
27079 } catch (err) {
27080 logger$1.critical('Error while checking element in blockElementCallback', err);
27081 return true;
27082 }
27083 }
27084
27085 if (blockSelectors && blockSelectors.length) {
27086 // programmatically prevent tracking of elements that match CSS selectors
27087 for (i = 0; i < blockSelectors.length; i++) {
27088 var sel = blockSelectors[i];
27089 try {
27090 if (el['matches'](sel)) {
27091 return true;
27092 }
27093 } catch (err) {
27094 logger$1.critical('Error while checking selector: ' + sel, err);
27095 }
27096 }
27097 }
27098
27099 // allow users to programmatically prevent tracking of elements by adding default classes such as 'mp-no-track'
27100 var classes = getClasses(el);
27101 for (i = 0; i < OPT_OUT_CLASSES.length; i++) {
27102 if (classes[OPT_OUT_CLASSES[i]]) {
27103 return true;
27104 }
27105 }
27106
27107 return false;
27108 }
27109
27110 /*
27111 * Check whether a DOM node has nodeType Node.ELEMENT_NODE
27112 * @param {Node} node - node to check
27113 * @returns {boolean} whether node is of the correct nodeType
27114 */
27115 function isElementNode(node) {
27116 return node && node.nodeType === 1; // Node.ELEMENT_NODE - use integer constant for browser portability
27117 }
27118
27119 /*
27120 * Check whether an element is of a given tag type.
27121 * Due to potential reference discrepancies (such as the webcomponents.js polyfill),
27122 * we want to match tagNames instead of specific references because something like
27123 * element === document.body won't always work because element might not be a native
27124 * element.
27125 * @param {Element} el - element to check
27126 * @param {string} tag - tag name (e.g., "div")
27127 * @returns {boolean} whether el is of the given tag type
27128 */
27129 function isTag(el, tag) {
27130 return el && el.tagName && el.tagName.toLowerCase() === tag.toLowerCase();
27131 }
27132
27133 /*
27134 * Check whether a DOM node is a TEXT_NODE
27135 * @param {Node} node - node to check
27136 * @returns {boolean} whether node is of type Node.TEXT_NODE
27137 */
27138 function isTextNode(node) {
27139 return node && node.nodeType === 3; // Node.TEXT_NODE - use integer constant for browser portability
27140 }
27141
27142 function minDOMApisSupported() {
27143 try {
27144 var testEl = document$1.createElement('div');
27145 return !!testEl['matches'];
27146 } catch (err) {
27147 return false;
27148 }
27149 }
27150
27151 function weakSetSupported() {
27152 return typeof WeakSet !== 'undefined';
27153 }
27154
27155 /*
27156 * Check whether a DOM event should be "tracked" or if it may contain sensitive data
27157 * using a variety of heuristics.
27158 * @param {Element} el - element to check
27159 * @param {Event} ev - event to check
27160 * @returns {boolean} whether the event should be tracked
27161 */
27162 function shouldTrackDomEvent(el, ev) {
27163 if (!el || isTag(el, 'html') || !isElementNode(el)) {
27164 return false;
27165 }
27166 var tag = el.tagName.toLowerCase();
27167 switch (tag) {
27168 case 'form':
27169 return ev.type === EV_SUBMIT;
27170 case 'input':
27171 if (['button', 'submit'].indexOf(el.getAttribute('type')) === -1) {
27172 return ev.type === EV_CHANGE;
27173 } else {
27174 return ev.type === EV_CLICK;
27175 }
27176 case 'select':
27177 case 'textarea':
27178 return ev.type === EV_CHANGE;
27179 default:
27180 return ev.type === EV_CLICK;
27181 }
27182 }
27183
27184 /*
27185 * Check whether a DOM element should be "tracked" or if it may contain sensitive data
27186 * using a variety of heuristics.
27187 * @param {Element} el - element to check
27188 * @param {Array<string>} allowSelectors - CSS selectors for elements that should be included
27189 * @returns {boolean} whether the element should be tracked
27190 */
27191 function shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors) {
27192 var i;
27193
27194 if (!isElementAllowed(el, ev, allowElementCallback, allowSelectors)) {
27195 return false;
27196 }
27197
27198 for (var curEl = el; curEl.parentNode && !isTag(curEl, 'body'); curEl = curEl.parentNode) {
27199 var classes = getClasses(curEl);
27200 for (i = 0; i < SENSITIVE_DATA_CLASSES.length; i++) {
27201 if (classes[SENSITIVE_DATA_CLASSES[i]]) {
27202 return false;
27203 }
27204 }
27205 }
27206
27207 var elClasses = getClasses(el);
27208 for (i = 0; i < OPT_IN_CLASSES.length; i++) {
27209 if (elClasses[OPT_IN_CLASSES[i]]) {
27210 return true;
27211 }
27212 }
27213
27214 // don't send data from inputs or similar elements since there will always be
27215 // a risk of clientside javascript placing sensitive data in attributes
27216 if (
27217 isTag(el, 'input') ||
27218 isTag(el, 'select') ||
27219 isTag(el, 'textarea') ||
27220 el.getAttribute('contenteditable') === 'true'
27221 ) {
27222 return false;
27223 }
27224
27225 // don't include hidden or password fields
27226 var type = el.type || '';
27227 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"]
27228 switch(type.toLowerCase()) {
27229 case 'hidden':
27230 return false;
27231 case 'password':
27232 return false;
27233 }
27234 }
27235
27236 // filter out data from fields that look like sensitive fields
27237 var name = el.name || el.id || '';
27238 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"]
27239 var sensitiveNameRegex = /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i;
27240 if (sensitiveNameRegex.test(name.replace(/[^a-zA-Z0-9]/g, ''))) {
27241 return false;
27242 }
27243 }
27244
27245 return true;
27246 }
27247
27248
27249 /*
27250 * Check whether a string value should be "tracked" or if it may contain sensitive data
27251 * using a variety of heuristics.
27252 * @param {string} value - string value to check
27253 * @returns {boolean} whether the element should be tracked
27254 */
27255 function shouldTrackValue(value) {
27256 if (value === null || _.isUndefined(value)) {
27257 return false;
27258 }
27259
27260 if (typeof value === 'string') {
27261 value = _.trim(value);
27262
27263 // check to see if input value looks like a credit card number
27264 // see: https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9781449327453/ch04s20.html
27265 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}))$/;
27266 if (ccRegex.test((value || '').replace(/[- ]/g, ''))) {
27267 return false;
27268 }
27269
27270 // check to see if input value looks like a social security number
27271 var ssnRegex = /(^\d{3}-?\d{2}-?\d{4}$)/;
27272 if (ssnRegex.test(value)) {
27273 return false;
27274 }
27275 }
27276
27277 return true;
27278 }
27279
27280 /**
27281 * Creates a cross-browser compatible scroll end function with appropriate event listener.
27282 * For browsers that support scrollend, returns the original function with scrollend event.
27283 * For browsers without scrollend support, returns a debounced function that triggers
27284 * 100ms after the last scroll event to simulate scrollend behavior.
27285 * @param {Function} originalFunction - The function to call when scrolling ends
27286 * @returns {Object} Object containing listener function and eventType string
27287 * @returns {Function} returns.listener - The wrapped function to use as event listener
27288 * @returns {string} returns.eventType - The event type to listen for ('scrollend' or 'scroll')
27289 */
27290 function getPolyfillScrollEndFunction(originalFunction) {
27291 var supportsScrollEnd = 'onscrollend' in win;
27292 var polyfillFunction = safewrap(originalFunction);
27293 var polyfillEvent = EV_SCROLLEND;
27294 if (!supportsScrollEnd) {
27295 // Polyfill for browsers without scrollend support: wait 100ms after the last scroll event
27296 // https://developer.chrome.com/blog/scrollend-a-new-javascript-event
27297 var scrollTimer = null;
27298 var scrollDelayMs = 100;
27299
27300 polyfillFunction = safewrap(function() {
27301 clearTimeout(scrollTimer);
27302 scrollTimer = setTimeout(originalFunction, scrollDelayMs);
27303 });
27304
27305 polyfillEvent = EV_SCROLL;
27306 }
27307
27308 return {
27309 listener: polyfillFunction,
27310 eventType: polyfillEvent
27311 };
27312 }
27313
27314 function hasInlineEventHandlers(element) {
27315 for (var i = 0; i < EVENT_HANDLER_ATTRIBUTES.length; i++) {
27316 if (element.hasAttribute(EVENT_HANDLER_ATTRIBUTES[i])) {
27317 return true;
27318 }
27319 }
27320 return false;
27321 }
27322
27323 function hasInteractiveAriaRole(element) {
27324 var role = element.getAttribute('role');
27325 if (!role) return false;
27326
27327 // Handle invalid markup where multiple roles might be specified
27328 // Only the first token is recognized per ARIA spec
27329 var primaryRole = role.trim().split(/\s+/)[0].toLowerCase();
27330
27331 return INTERACTIVE_ARIA_ROLES[primaryRole];
27332 }
27333
27334 function hasAnyInteractivityIndicators(element) {
27335 var tagName = element.tagName.toLowerCase();
27336
27337 // Check for interactive HTML elements
27338 if (tagName === 'button' ||
27339 tagName === 'input' ||
27340 tagName === 'select' ||
27341 tagName === 'textarea' ||
27342 tagName === 'details' ||
27343 tagName === 'dialog') {
27344 return true;
27345 }
27346
27347 if (element.isContentEditable) {
27348 return true;
27349 }
27350
27351 if (element.onclick || element.onmousedown || element.onmouseup || element.ontouchstart || element.ontouchend) {
27352 return true;
27353 }
27354
27355 if (hasInlineEventHandlers(element)) {
27356 return true;
27357 }
27358
27359 if (hasInteractiveAriaRole(element)) {
27360 return true;
27361 }
27362
27363 if (tagName === 'a' && element.hasAttribute('href')) {
27364 return true;
27365 }
27366
27367 if (element.hasAttribute('tabindex')) {
27368 return true;
27369 }
27370
27371 return false;
27372 }
27373
27374
27375 function isDefinitelyNonInteractive(element) {
27376 if (!element || !element.tagName) {
27377 return true;
27378 }
27379
27380 var tagName = element.tagName.toLowerCase();
27381
27382 // These tags are definitely non-interactive
27383 if (ALWAYS_NON_INTERACTIVE_TAGS[tagName]) {
27384 return true;
27385 }
27386
27387 // For all other elements, we can only be certain they're non-interactive if they lack ALL indicators of interactivity
27388 // Check for any signs of interactivity
27389 if (hasAnyInteractivityIndicators(element)) {
27390 return false;
27391 }
27392
27393 // Check parent chain for interactive context
27394 var parent = element.parentElement;
27395 var depth = 0;
27396
27397 while (parent && depth < MAX_DEPTH) {
27398 if (hasAnyInteractivityIndicators(parent)) {
27399 return false; // Element is inside an interactive parent
27400 }
27401
27402 if (parent.getRootNode && parent.getRootNode() !== document$1) {
27403 var root = parent.getRootNode();
27404 if (root.host && hasAnyInteractivityIndicators(root.host)) {
27405 return false; // Inside an interactive shadow host
27406 }
27407 }
27408
27409 parent = parent.parentElement;
27410 depth++;
27411 }
27412
27413 // Pure text containers without any interactive context
27414 if (TEXT_CONTAINER_TAGS[tagName]) {
27415 // These are non-interactive ONLY if they have no interactive indicators (already checked as part of hasAnyInteractivityIndicators)
27416 return true;
27417 }
27418
27419 // Default: we can't be certain it's non-interactive
27420 return false;
27421 }
27422
27423 /** @const */ var DEFAULT_RAGE_CLICK_THRESHOLD_PX = 30;
27424 /** @const */ var DEFAULT_RAGE_CLICK_TIMEOUT_MS = 1000;
27425 /** @const */ var DEFAULT_RAGE_CLICK_CLICK_COUNT = 4;
27426
27427 function RageClickTracker() {
27428 this.clicks = [];
27429 }
27430
27431 RageClickTracker.prototype.isRageClick = function(x, y, options) {
27432 options = options || {};
27433 var thresholdPx = options['threshold_px'] || DEFAULT_RAGE_CLICK_THRESHOLD_PX;
27434 var timeoutMs = options['timeout_ms'] || DEFAULT_RAGE_CLICK_TIMEOUT_MS;
27435 var clickCount = options['click_count'] || DEFAULT_RAGE_CLICK_CLICK_COUNT;
27436 var timestamp = Date.now();
27437
27438 var lastClick = this.clicks[this.clicks.length - 1];
27439 if (
27440 lastClick &&
27441 timestamp - lastClick.timestamp < timeoutMs &&
27442 Math.sqrt(Math.pow(x - lastClick.x, 2) + Math.pow(y - lastClick.y, 2)) < thresholdPx
27443 ) {
27444 this.clicks.push({ x: x, y: y, timestamp: timestamp });
27445 if (this.clicks.length >= clickCount) {
27446 this.clicks = [];
27447 return true;
27448 }
27449 } else {
27450 this.clicks = [{ x: x, y: y, timestamp: timestamp }];
27451 }
27452 return false;
27453 };
27454
27455 function ShadowDOMObserver(changeCallback, observerConfig) {
27456 this.changeCallback = changeCallback || function() {};
27457 this.observerConfig = observerConfig;
27458
27459 this.observedShadowRoots = null;
27460 this.shadowObservers = [];
27461 }
27462
27463 ShadowDOMObserver.prototype.getEventTarget = function(event) {
27464 if (!this.observedShadowRoots) {
27465 return;
27466 }
27467 var path = this.getComposedPath(event);
27468 if (path && path.length) {
27469 return path[0];
27470 }
27471
27472 return event['target'] || event['srcElement'];
27473 };
27474
27475
27476 ShadowDOMObserver.prototype.getComposedPath = function(event) {
27477 if ('composedPath' in event) {
27478 return event['composedPath']();
27479 }
27480
27481 return [];
27482 };
27483 ShadowDOMObserver.prototype.observeFromEvent = function(event) {
27484 if (!this.observedShadowRoots) {
27485 return;
27486 }
27487
27488 var path = this.getComposedPath(event);
27489
27490 // Check each element in path for shadow roots
27491 for (var i = 0; i < path.length; i++) {
27492 var element = path[i];
27493
27494 if (element && element.shadowRoot) {
27495 this.observeShadowRoot(element.shadowRoot);
27496 }
27497 }
27498 };
27499
27500
27501 ShadowDOMObserver.prototype.observeShadowRoot = function(shadowRoot) {
27502 if (!this.observedShadowRoots || this.observedShadowRoots.has(shadowRoot)) {
27503 return;
27504 }
27505
27506 var self = this;
27507
27508 try {
27509 this.observedShadowRoots.add(shadowRoot);
27510
27511 var observer = new window.MutationObserver(function() {
27512 self.changeCallback();
27513 });
27514
27515 observer.observe(shadowRoot, this.observerConfig);
27516 this.shadowObservers.push(observer);
27517 } catch (e) {
27518 logger$1.critical('Error while observing shadow root', e);
27519 }
27520 };
27521
27522
27523 ShadowDOMObserver.prototype.start = function() {
27524 if (this.observedShadowRoots) {
27525 return;
27526 }
27527
27528 if (!weakSetSupported()) {
27529 logger$1.critical('Shadow DOM observation unavailable: WeakSet not supported');
27530 return;
27531 }
27532
27533 this.observedShadowRoots = new WeakSet();
27534 };
27535
27536 ShadowDOMObserver.prototype.stop = function() {
27537 if (!this.observedShadowRoots) {
27538 return;
27539 }
27540
27541 for (var i = 0; i < this.shadowObservers.length; i++) {
27542 try {
27543 this.shadowObservers[i].disconnect();
27544 } catch (e) {
27545 logger$1.critical('Error while disconnecting shadow DOM observer', e);
27546 }
27547 }
27548 this.shadowObservers = [];
27549 this.observedShadowRoots = null;
27550 };
27551
27552 /** @const */ var DEFAULT_DEAD_CLICK_TIMEOUT_MS = 500;
27553 /** @const */ var INTERACTION_EVENTS = [EV_CHANGE, EV_INPUT, EV_SUBMIT, EV_SELECT, EV_TOGGLE];
27554 /** @const */ var LAYOUT_EVENTS = [EV_SCROLLEND];
27555 /** @const */ var NAVIGATION_EVENTS = [EV_HASHCHANGE];
27556 /** @const */ var MUTATION_OBSERVER_CONFIG = {
27557 characterData: true,
27558 childList: true,
27559 subtree: true,
27560 attributes: true,
27561 attributeFilter: ['style', 'class', 'hidden', 'checked', 'selected', 'value', 'display', 'visibility']
27562 };
27563
27564
27565 function DeadClickTracker(onDeadClickCallback) {
27566 this.eventListeners = [];
27567 this.mutationObserver = null;
27568 this.shadowDOMObserver = null;
27569
27570 this.isTracking = false;
27571 this.lastChangeEventTimestamp = 0;
27572 this.pendingClicks = [];
27573 this.onDeadClickCallback = onDeadClickCallback;
27574 this.processingActive = false;
27575 this.processingTimeout = null;
27576 }
27577
27578
27579 DeadClickTracker.prototype.addClick = function(event) {
27580 var element = this.shadowDOMObserver && this.shadowDOMObserver.getEventTarget(event);
27581
27582 if (!element) {
27583 element = event['target'] || event['srcElement'];
27584 }
27585
27586 if (!element || isDefinitelyNonInteractive(element)) {
27587 return false;
27588 }
27589
27590 if (this.shadowDOMObserver) {
27591 this.shadowDOMObserver.observeFromEvent(event);
27592 }
27593 this.pendingClicks.push({
27594 element: element,
27595 event: event,
27596 timestamp: Date.now()
27597 });
27598 return true;
27599 };
27600
27601 DeadClickTracker.prototype.trackClick = function(event, config) {
27602 if (!this.isTracking) {
27603 return false;
27604 }
27605
27606 var added = this.addClick(event);
27607 if (added) {
27608 this.triggerProcessing(config);
27609 }
27610 return added;
27611 };
27612
27613 DeadClickTracker.prototype.getDeadClicks = function(config) {
27614 if (this.pendingClicks.length === 0) {
27615 return [];
27616 }
27617
27618 var timeoutMs = config['timeout_ms'];
27619 var now = Date.now();
27620 var clicksToEvaluate = this.pendingClicks.slice(); // Copy array
27621 this.pendingClicks = []; // Clear original
27622
27623 var deadClicks = [];
27624
27625 for (var i = 0; i < clicksToEvaluate.length; i++) {
27626 var click = clicksToEvaluate[i];
27627
27628 if (now - click.timestamp >= timeoutMs) {
27629 // Click has exceeded timeout, check if it's dead by looking for changes after this specific click
27630 if (!this.hasChangesAfter(click.timestamp)) {
27631 deadClicks.push(click);
27632 }
27633 } else {
27634 // Still pending - add back
27635 this.pendingClicks.push(click);
27636 }
27637 }
27638
27639 return deadClicks;
27640 };
27641
27642 DeadClickTracker.prototype.hasChangesAfter = function(timestamp) {
27643 // 100ms tolerance for race condition between when we record the click and the change event
27644 return this.lastChangeEventTimestamp >= (timestamp - 100);
27645 };
27646
27647 DeadClickTracker.prototype.recordChangeEvent = function() {
27648 this.lastChangeEventTimestamp = Date.now();
27649 };
27650
27651 DeadClickTracker.prototype.triggerProcessing = function(config) {
27652 // Prevent multiple concurrent processing chains
27653 if (this.processingActive) {
27654 return;
27655 }
27656 this.processingActive = true;
27657 this.processRecursively(config);
27658 };
27659
27660 DeadClickTracker.prototype.processRecursively = function(config) {
27661 if (!this.isTracking || !this.onDeadClickCallback) {
27662 this.processingActive = false;
27663 return;
27664 }
27665
27666 var timeoutMs = config['timeout_ms'];
27667 var self = this;
27668
27669 this.processingTimeout = setTimeout(function() {
27670 if (!self.processingActive) {
27671 return;
27672 }
27673
27674 var deadClicks = self.getDeadClicks(config);
27675
27676 for (var i = 0; i < deadClicks.length; i++) {
27677 self.onDeadClickCallback(deadClicks[i].event);
27678 }
27679
27680 if (self.pendingClicks.length > 0) {
27681 self.processRecursively(config);
27682 } else {
27683 self.processingActive = false;
27684 }
27685 }, timeoutMs);
27686 };
27687
27688 DeadClickTracker.prototype.startTracking = function() {
27689 if (this.isTracking) {
27690 return;
27691 }
27692
27693 this.isTracking = true;
27694
27695 var self = this;
27696
27697 INTERACTION_EVENTS.forEach(function(event) {
27698 var handler = function() {
27699 self.recordChangeEvent();
27700 };
27701 document.addEventListener(event, handler, { capture: true, passive: true });
27702 self.eventListeners.push({ target: document, event: event, handler: handler, options: { capture: true, passive: true } });
27703 });
27704 NAVIGATION_EVENTS.forEach(function(event) {
27705 var handler = function() {
27706 self.recordChangeEvent();
27707 };
27708 window.addEventListener(event, handler);
27709 self.eventListeners.push({ target: window, event: event, handler: handler });
27710 });
27711 LAYOUT_EVENTS.forEach(function(event) {
27712 var handler = function() {
27713 self.recordChangeEvent();
27714 };
27715 window.addEventListener(event, handler, { passive: true });
27716 self.eventListeners.push({ target: window, event: event, handler: handler, options: { passive: true } });
27717 });
27718 var selectionHandler = function() {
27719 self.recordChangeEvent();
27720 };
27721 document.addEventListener('selectionchange', selectionHandler);
27722 self.eventListeners.push({ target: document, event: 'selectionchange', handler: selectionHandler });
27723
27724 // Set up MutationObserver
27725 if (window.MutationObserver) {
27726 try {
27727 this.mutationObserver = new window.MutationObserver(function() {
27728 self.recordChangeEvent();
27729 });
27730
27731 this.mutationObserver.observe(document.body || document.documentElement, MUTATION_OBSERVER_CONFIG);
27732 } catch (e) {
27733 logger$1.critical('Error while setting up mutation observer', e);
27734 }
27735 }
27736
27737 // Set up Shadow DOM observer
27738 if (window.customElements) {
27739 try {
27740 this.shadowDOMObserver = new ShadowDOMObserver(
27741 function() {
27742 self.recordChangeEvent();
27743 },
27744 MUTATION_OBSERVER_CONFIG
27745 );
27746 this.shadowDOMObserver.start();
27747 } catch (e) {
27748 logger$1.critical('Error while setting up shadow DOM observer', e);
27749 this.shadowDOMObserver = null;
27750 }
27751 }
27752 };
27753
27754 DeadClickTracker.prototype.stopTracking = function() {
27755 if (!this.isTracking) {
27756 return;
27757 }
27758
27759 this.isTracking = false;
27760 this.pendingClicks = [];
27761 this.lastChangeEventTimestamp = 0;
27762 this.processingActive = false;
27763
27764 if (this.processingTimeout) {
27765 clearTimeout(this.processingTimeout);
27766 this.processingTimeout = null;
27767 }
27768
27769 // Remove all event listeners
27770 for (var i = 0; i < this.eventListeners.length; i++) {
27771 var listener = this.eventListeners[i];
27772 try {
27773 listener.target.removeEventListener(listener.event, listener.handler, listener.options);
27774 } catch (e) {
27775 logger$1.critical('Error while removing event listener', e);
27776 }
27777 }
27778 this.eventListeners = [];
27779
27780 if (this.mutationObserver) {
27781 try {
27782 this.mutationObserver.disconnect();
27783 } catch (e) {
27784 logger$1.critical('Error while disconnecting mutation observer', e);
27785 }
27786 this.mutationObserver = null;
27787 }
27788
27789 if (this.shadowDOMObserver) {
27790 try {
27791 this.shadowDOMObserver.stop();
27792 } catch (e) {
27793 logger$1.critical('Error while stopping shadow DOM observer', e);
27794 }
27795 this.shadowDOMObserver = null;
27796 }
27797 };
27798
27799 var AUTOCAPTURE_CONFIG_KEY = 'autocapture';
27800 var LEGACY_PAGEVIEW_CONFIG_KEY = 'track_pageview';
27801
27802 var PAGEVIEW_OPTION_FULL_URL = 'full-url';
27803 var PAGEVIEW_OPTION_URL_WITH_PATH_AND_QUERY_STRING = 'url-with-path-and-query-string';
27804 var PAGEVIEW_OPTION_URL_WITH_PATH = 'url-with-path';
27805
27806 var CONFIG_ALLOW_ELEMENT_CALLBACK = 'allow_element_callback';
27807 var CONFIG_ALLOW_SELECTORS = 'allow_selectors';
27808 var CONFIG_ALLOW_URL_REGEXES = 'allow_url_regexes';
27809 var CONFIG_BLOCK_ATTRS = 'block_attrs';
27810 var CONFIG_BLOCK_ELEMENT_CALLBACK = 'block_element_callback';
27811 var CONFIG_BLOCK_SELECTORS = 'block_selectors';
27812 var CONFIG_BLOCK_URL_REGEXES = 'block_url_regexes';
27813 var CONFIG_CAPTURE_EXTRA_ATTRS = 'capture_extra_attrs';
27814 var CONFIG_CAPTURE_TEXT_CONTENT = 'capture_text_content';
27815 var CONFIG_SCROLL_CAPTURE_ALL = 'scroll_capture_all';
27816 var CONFIG_SCROLL_CHECKPOINTS = 'scroll_depth_percent_checkpoints';
27817 var CONFIG_TRACK_CLICK = 'click';
27818 var CONFIG_TRACK_DEAD_CLICK = 'dead_click';
27819 var CONFIG_TRACK_INPUT = 'input';
27820 var CONFIG_TRACK_PAGEVIEW = 'pageview';
27821 var CONFIG_TRACK_RAGE_CLICK = 'rage_click';
27822 var CONFIG_TRACK_SCROLL = 'scroll';
27823 var CONFIG_TRACK_PAGE_LEAVE = 'page_leave';
27824 var CONFIG_TRACK_SUBMIT = 'submit';
27825
27826 var CONFIG_DEFAULTS$1 = {};
27827 CONFIG_DEFAULTS$1[CONFIG_ALLOW_SELECTORS] = [];
27828 CONFIG_DEFAULTS$1[CONFIG_ALLOW_URL_REGEXES] = [];
27829 CONFIG_DEFAULTS$1[CONFIG_BLOCK_ATTRS] = [];
27830 CONFIG_DEFAULTS$1[CONFIG_BLOCK_ELEMENT_CALLBACK] = null;
27831 CONFIG_DEFAULTS$1[CONFIG_BLOCK_SELECTORS] = [];
27832 CONFIG_DEFAULTS$1[CONFIG_BLOCK_URL_REGEXES] = [];
27833 CONFIG_DEFAULTS$1[CONFIG_CAPTURE_EXTRA_ATTRS] = [];
27834 CONFIG_DEFAULTS$1[CONFIG_CAPTURE_TEXT_CONTENT] = false;
27835 CONFIG_DEFAULTS$1[CONFIG_SCROLL_CAPTURE_ALL] = false;
27836 CONFIG_DEFAULTS$1[CONFIG_SCROLL_CHECKPOINTS] = [25, 50, 75, 100];
27837 CONFIG_DEFAULTS$1[CONFIG_TRACK_CLICK] = true;
27838 CONFIG_DEFAULTS$1[CONFIG_TRACK_DEAD_CLICK] = true;
27839 CONFIG_DEFAULTS$1[CONFIG_TRACK_INPUT] = true;
27840 CONFIG_DEFAULTS$1[CONFIG_TRACK_PAGEVIEW] = PAGEVIEW_OPTION_FULL_URL;
27841 CONFIG_DEFAULTS$1[CONFIG_TRACK_RAGE_CLICK] = true;
27842 CONFIG_DEFAULTS$1[CONFIG_TRACK_SCROLL] = true;
27843 CONFIG_DEFAULTS$1[CONFIG_TRACK_PAGE_LEAVE] = false;
27844 CONFIG_DEFAULTS$1[CONFIG_TRACK_SUBMIT] = true;
27845
27846 var DEFAULT_PROPS = {
27847 '$mp_autocapture': true
27848 };
27849
27850 var MP_EV_CLICK = '$mp_click';
27851 var MP_EV_DEAD_CLICK = '$mp_dead_click';
27852 var MP_EV_INPUT = '$mp_input_change';
27853 var MP_EV_RAGE_CLICK = '$mp_rage_click';
27854 var MP_EV_SCROLL = '$mp_scroll';
27855 var MP_EV_SUBMIT = '$mp_submit';
27856 var MP_EV_PAGE_LEAVE = '$mp_page_leave';
27857
27858 /**
27859 * Autocapture: manages automatic event tracking
27860 * @constructor
27861 */
27862 var Autocapture = function(mp) {
27863 this.mp = mp;
27864 this.maxScrollViewDepth = 0;
27865 this.hasTrackedScrollSession = false;
27866 this.previousScrollHeight = 0;
27867 };
27868
27869 Autocapture.prototype.init = function() {
27870 if (!minDOMApisSupported()) {
27871 logger$1.critical('Autocapture unavailable: missing required DOM APIs');
27872 return;
27873 }
27874 this.initPageListeners();
27875 this.initPageviewTracking();
27876 this.initClickTracking();
27877 this.initDeadClickTracking();
27878 this.initInputTracking();
27879 this.initScrollTracking();
27880 this.initSubmitTracking();
27881 this.initRageClickTracking();
27882 this.initPageLeaveTracking();
27883 };
27884
27885 Autocapture.prototype.getFullConfig = function() {
27886 var autocaptureConfig = this.mp.get_config(AUTOCAPTURE_CONFIG_KEY);
27887 if (!autocaptureConfig) {
27888 // Autocapture is completely off
27889 return {};
27890 } else if (_.isObject(autocaptureConfig)) {
27891 return _.extend({}, CONFIG_DEFAULTS$1, autocaptureConfig);
27892 } else {
27893 // Autocapture config is non-object truthy value, return default
27894 return CONFIG_DEFAULTS$1;
27895 }
27896 };
27897
27898 Autocapture.prototype.getConfig = function(key) {
27899 return this.getFullConfig()[key];
27900 };
27901
27902 Autocapture.prototype.currentUrlBlocked = function() {
27903 var i;
27904 var currentUrl = _.info.currentUrl();
27905
27906 var allowUrlRegexes = this.getConfig(CONFIG_ALLOW_URL_REGEXES) || [];
27907 if (allowUrlRegexes.length) {
27908 // we're using an allowlist, only track if current URL matches
27909 var allowed = false;
27910 for (i = 0; i < allowUrlRegexes.length; i++) {
27911 var allowRegex = allowUrlRegexes[i];
27912 try {
27913 if (currentUrl.match(allowRegex)) {
27914 allowed = true;
27915 break;
27916 }
27917 } catch (err) {
27918 logger$1.critical('Error while checking block URL regex: ' + allowRegex, err);
27919 return true;
27920 }
27921 }
27922 if (!allowed) {
27923 // wasn't allowed by any regex
27924 return true;
27925 }
27926 }
27927
27928 var blockUrlRegexes = this.getConfig(CONFIG_BLOCK_URL_REGEXES) || [];
27929 if (!blockUrlRegexes || !blockUrlRegexes.length) {
27930 return false;
27931 }
27932
27933 for (i = 0; i < blockUrlRegexes.length; i++) {
27934 try {
27935 if (currentUrl.match(blockUrlRegexes[i])) {
27936 return true;
27937 }
27938 } catch (err) {
27939 logger$1.critical('Error while checking block URL regex: ' + blockUrlRegexes[i], err);
27940 return true;
27941 }
27942 }
27943 return false;
27944 };
27945
27946 Autocapture.prototype.pageviewTrackingConfig = function() {
27947 // supports both autocapture config and old track_pageview config
27948 if (this.mp.get_config(AUTOCAPTURE_CONFIG_KEY)) {
27949 return this.getConfig(CONFIG_TRACK_PAGEVIEW);
27950 } else {
27951 return this.mp.get_config(LEGACY_PAGEVIEW_CONFIG_KEY);
27952 }
27953 };
27954
27955 // helper for event handlers
27956 Autocapture.prototype.trackDomEvent = function(ev, mpEventName) {
27957 if (this.currentUrlBlocked()) {
27958 return;
27959 }
27960
27961 var isCapturedForHeatMap = this.mp.is_recording_heatmap_data() && (
27962 (mpEventName === MP_EV_CLICK && !this.getConfig(CONFIG_TRACK_CLICK)) ||
27963 (mpEventName === MP_EV_RAGE_CLICK && !this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK)) ||
27964 (mpEventName === MP_EV_DEAD_CLICK && !this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK))
27965 );
27966
27967 var props = getPropsForDOMEvent(ev, {
27968 allowElementCallback: this.getConfig(CONFIG_ALLOW_ELEMENT_CALLBACK),
27969 allowSelectors: this.getConfig(CONFIG_ALLOW_SELECTORS),
27970 blockAttrs: this.getConfig(CONFIG_BLOCK_ATTRS),
27971 blockElementCallback: this.getConfig(CONFIG_BLOCK_ELEMENT_CALLBACK),
27972 blockSelectors: this.getConfig(CONFIG_BLOCK_SELECTORS),
27973 captureExtraAttrs: this.getConfig(CONFIG_CAPTURE_EXTRA_ATTRS),
27974 captureTextContent: this.getConfig(CONFIG_CAPTURE_TEXT_CONTENT),
27975 capturedForHeatMap: isCapturedForHeatMap,
27976 });
27977 if (props) {
27978 _.extend(props, DEFAULT_PROPS);
27979 this.mp.track(mpEventName, props);
27980 }
27981 };
27982
27983 Autocapture.prototype.initPageListeners = function() {
27984 win.removeEventListener(EV_POPSTATE, this.listenerPopstate);
27985 win.removeEventListener(EV_HASHCHANGE, this.listenerHashchange);
27986
27987 if (!this.pageviewTrackingConfig() && !this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.get_config('record_heatmap_data')) {
27988 // These are all the configs that use these listeners
27989 return;
27990 }
27991
27992 this.listenerPopstate = function() {
27993 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
27994 };
27995 this.listenerHashchange = function() {
27996 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
27997 };
27998
27999 win.addEventListener(EV_POPSTATE, this.listenerPopstate);
28000 win.addEventListener(EV_HASHCHANGE, this.listenerHashchange);
28001 var nativePushState = win.history.pushState;
28002 if (typeof nativePushState === 'function') {
28003 win.history.pushState = function(state, unused, url) {
28004 nativePushState.call(win.history, state, unused, url);
28005 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
28006 };
28007 }
28008 var nativeReplaceState = win.history.replaceState;
28009 if (typeof nativeReplaceState === 'function') {
28010 win.history.replaceState = function(state, unused, url) {
28011 nativeReplaceState.call(win.history, state, unused, url);
28012 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
28013 };
28014 }
28015 };
28016
28017 Autocapture.prototype._getClickTrackingConfig = function(configKey) {
28018 var config = this.getConfig(configKey);
28019
28020 if (!config) {
28021 return null; // click tracking disabled
28022 }
28023
28024 if (config === true) {
28025 return {}; // use defaults
28026 }
28027
28028 if (typeof config === 'object') {
28029 return config; // use custom configuration
28030 }
28031
28032 return {}; // fallback to defaults for any other truthy value
28033 };
28034
28035 Autocapture.prototype._trackPageLeave = function(ev, currentUrl, currentScrollHeight) {
28036 if (this.hasTrackedScrollSession) {
28037 // User has navigated away already ending their impression.
28038 return;
28039 }
28040
28041 if (!this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.is_recording_heatmap_data()) {
28042 return;
28043 }
28044
28045 this.hasTrackedScrollSession = true;
28046 var viewportHeight = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
28047 var scrollPercentage = Math.round(Math.max(this.maxScrollViewDepth - viewportHeight, 0) / (currentScrollHeight - viewportHeight) * 100);
28048 var foldLinePercentage = Math.round((viewportHeight / currentScrollHeight) * 100);
28049 if (currentScrollHeight <= viewportHeight) {
28050 // If the content fits within the viewport, consider it fully scrolled
28051 scrollPercentage = 100;
28052 foldLinePercentage = 100;
28053 }
28054
28055 var props = _.extend({
28056 '$max_scroll_view_depth': this.maxScrollViewDepth,
28057 '$max_scroll_percentage': scrollPercentage,
28058 '$fold_line_percentage': foldLinePercentage,
28059 '$scroll_height': currentScrollHeight,
28060 '$event_type': ev.type,
28061 '$current_url': currentUrl || _.info.currentUrl(),
28062 '$viewportHeight': viewportHeight, // This is the fold line
28063 '$viewportWidth': Math.max(document$1.documentElement.clientWidth, win.innerWidth || 0),
28064 '$captured_for_heatmap': this.mp.is_recording_heatmap_data()
28065 }, DEFAULT_PROPS);
28066
28067 // Send with beacon transport to ensure event is sent before unload
28068 this.mp.track(MP_EV_PAGE_LEAVE, props, {transport: 'sendBeacon'});
28069 };
28070
28071 Autocapture.prototype._initScrollDepthTracking = function() {
28072 win.removeEventListener(EV_SCROLL, this.listenerScrollDepth);
28073 win.removeEventListener(EV_SCROLLEND, this.listenerScrollDepth);
28074
28075 if (!this.mp.get_config('record_heatmap_data')) {
28076 return;
28077 }
28078
28079 logger$1.log('Initializing scroll depth tracking');
28080
28081 this.maxScrollViewDepth = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
28082
28083 var updateScrollDepth = function() {
28084 if (this.currentUrlBlocked()) {
28085 return;
28086 }
28087 var scrollViewHeight = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0) + win.scrollY;
28088 if (scrollViewHeight > this.maxScrollViewDepth) {
28089 this.maxScrollViewDepth = scrollViewHeight;
28090 }
28091 this.previousScrollHeight = document$1.body.scrollHeight;
28092 }.bind(this);
28093
28094 var scrollEndPolyfill = getPolyfillScrollEndFunction(updateScrollDepth);
28095 this.listenerScrollDepth = scrollEndPolyfill.listener;
28096 win.addEventListener(scrollEndPolyfill.eventType, this.listenerScrollDepth);
28097 };
28098
28099 Autocapture.prototype.initClickTracking = function() {
28100 win.removeEventListener(EV_CLICK, this.listenerClick);
28101
28102 if (!this.getConfig(CONFIG_TRACK_CLICK) && !this.mp.get_config('record_heatmap_data')) {
28103 return;
28104 }
28105 logger$1.log('Initializing click tracking');
28106
28107 this.listenerClick = function(ev) {
28108 if (!this.getConfig(CONFIG_TRACK_CLICK) && !this.mp.is_recording_heatmap_data()) {
28109 return;
28110 }
28111 this.trackDomEvent(ev, MP_EV_CLICK);
28112 }.bind(this);
28113 win.addEventListener(EV_CLICK, this.listenerClick);
28114 };
28115
28116 Autocapture.prototype.initDeadClickTracking = function() {
28117 var deadClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK);
28118
28119 if (!deadClickConfig && !this.mp.get_config('record_heatmap_data')) {
28120 this.stopDeadClickTracking();
28121 return;
28122 }
28123
28124 logger$1.log('Initializing dead click tracking');
28125 if (!this._deadClickTracker) {
28126 this._deadClickTracker = new DeadClickTracker(function(deadClickEvent) {
28127 this.trackDomEvent(deadClickEvent, MP_EV_DEAD_CLICK);
28128 }.bind(this));
28129 this._deadClickTracker.startTracking();
28130 }
28131
28132 if (!this.listenerDeadClick) {
28133 this.listenerDeadClick = function(ev) {
28134 var currentDeadClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK);
28135 if (!currentDeadClickConfig && !this.mp.is_recording_heatmap_data()) {
28136 return;
28137 }
28138 if (this.currentUrlBlocked()) {
28139 return;
28140 }
28141 // Normalize config to ensure timeout_ms is always set
28142 var normalizedConfig = currentDeadClickConfig || {};
28143 if (!normalizedConfig['timeout_ms']) {
28144 normalizedConfig['timeout_ms'] = DEFAULT_DEAD_CLICK_TIMEOUT_MS;
28145 }
28146 this._deadClickTracker.trackClick(ev, normalizedConfig);
28147 }.bind(this);
28148 win.addEventListener(EV_CLICK, this.listenerDeadClick);
28149 }
28150 };
28151
28152 Autocapture.prototype.initInputTracking = function() {
28153 win.removeEventListener(EV_CHANGE, this.listenerChange);
28154
28155 if (!this.getConfig(CONFIG_TRACK_INPUT)) {
28156 return;
28157 }
28158 logger$1.log('Initializing input tracking');
28159
28160 this.listenerChange = function(ev) {
28161 if (!this.getConfig(CONFIG_TRACK_INPUT)) {
28162 return;
28163 }
28164 this.trackDomEvent(ev, MP_EV_INPUT);
28165 }.bind(this);
28166 win.addEventListener(EV_CHANGE, this.listenerChange);
28167 };
28168
28169 Autocapture.prototype.initPageviewTracking = function() {
28170 win.removeEventListener(EV_MP_LOCATION_CHANGE, this.listenerLocationchange);
28171
28172 if (!this.pageviewTrackingConfig()) {
28173 return;
28174 }
28175 logger$1.log('Initializing pageview tracking');
28176
28177 var previousTrackedUrl = '';
28178 var tracked = false;
28179 if (!this.currentUrlBlocked()) {
28180 tracked = this.mp.track_pageview(DEFAULT_PROPS);
28181 }
28182 if (tracked) {
28183 previousTrackedUrl = _.info.currentUrl();
28184 }
28185
28186 this.listenerLocationchange = safewrap(function() {
28187 if (this.currentUrlBlocked()) {
28188 return;
28189 }
28190
28191 var currentUrl = _.info.currentUrl();
28192 var shouldTrack = false;
28193 var didPathChange = currentUrl.split('#')[0].split('?')[0] !== previousTrackedUrl.split('#')[0].split('?')[0];
28194 var trackPageviewOption = this.pageviewTrackingConfig();
28195 if (trackPageviewOption === PAGEVIEW_OPTION_FULL_URL) {
28196 shouldTrack = currentUrl !== previousTrackedUrl;
28197 } else if (trackPageviewOption === PAGEVIEW_OPTION_URL_WITH_PATH_AND_QUERY_STRING) {
28198 shouldTrack = currentUrl.split('#')[0] !== previousTrackedUrl.split('#')[0];
28199 } else if (trackPageviewOption === PAGEVIEW_OPTION_URL_WITH_PATH) {
28200 shouldTrack = didPathChange;
28201 }
28202
28203 if (shouldTrack) {
28204 var tracked = this.mp.track_pageview(DEFAULT_PROPS);
28205 if (tracked) {
28206 previousTrackedUrl = currentUrl;
28207 }
28208 if (didPathChange) {
28209 this.lastScrollCheckpoint = 0;
28210 logger$1.log('Path change: re-initializing scroll depth checkpoints');
28211 }
28212 }
28213 }.bind(this));
28214 win.addEventListener(EV_MP_LOCATION_CHANGE, this.listenerLocationchange);
28215 };
28216
28217 Autocapture.prototype.initRageClickTracking = function() {
28218 win.removeEventListener(EV_CLICK, this.listenerRageClick);
28219
28220 var rageClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK);
28221 if (!rageClickConfig && !this.mp.get_config('record_heatmap_data')) {
28222 return;
28223 }
28224
28225 logger$1.log('Initializing rage click tracking');
28226 if (!this._rageClickTracker) {
28227 this._rageClickTracker = new RageClickTracker();
28228 }
28229
28230 this.listenerRageClick = function(ev) {
28231 var currentRageClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK);
28232 if (!currentRageClickConfig && !this.mp.is_recording_heatmap_data()) {
28233 return;
28234 }
28235
28236 if (this.currentUrlBlocked()) {
28237 return;
28238 }
28239
28240 if (this._rageClickTracker.isRageClick(ev['pageX'], ev['pageY'], currentRageClickConfig)) {
28241 this.trackDomEvent(ev, MP_EV_RAGE_CLICK);
28242 }
28243 }.bind(this);
28244 win.addEventListener(EV_CLICK, this.listenerRageClick);
28245 };
28246
28247 Autocapture.prototype.initScrollTracking = function() {
28248 win.removeEventListener(EV_SCROLLEND, this.listenerScroll);
28249 win.removeEventListener(EV_SCROLL, this.listenerScroll);
28250
28251
28252 if (!this.getConfig(CONFIG_TRACK_SCROLL)) {
28253 return;
28254 }
28255 logger$1.log('Initializing scroll tracking');
28256 this.lastScrollCheckpoint = 0;
28257
28258 var scrollTrackFunction = function() {
28259 if (!this.getConfig(CONFIG_TRACK_SCROLL)) {
28260 return;
28261 }
28262 if (this.currentUrlBlocked()) {
28263 return;
28264 }
28265
28266 var shouldTrack = this.getConfig(CONFIG_SCROLL_CAPTURE_ALL);
28267 var scrollCheckpoints = (this.getConfig(CONFIG_SCROLL_CHECKPOINTS) || [])
28268 .slice()
28269 .sort(function(a, b) { return a - b; });
28270
28271 var scrollTop = win.scrollY;
28272 var props = _.extend({'$scroll_top': scrollTop}, DEFAULT_PROPS);
28273 try {
28274 var scrollHeight = document$1.body.scrollHeight;
28275 var scrollPercentage = Math.round((scrollTop / (scrollHeight - win.innerHeight)) * 100);
28276 props['$scroll_height'] = scrollHeight;
28277 props['$scroll_percentage'] = scrollPercentage;
28278 if (scrollPercentage > this.lastScrollCheckpoint) {
28279 for (var i = 0; i < scrollCheckpoints.length; i++) {
28280 var checkpoint = scrollCheckpoints[i];
28281 if (
28282 scrollPercentage >= checkpoint &&
28283 this.lastScrollCheckpoint < checkpoint
28284 ) {
28285 props['$scroll_checkpoint'] = checkpoint;
28286 this.lastScrollCheckpoint = checkpoint;
28287 shouldTrack = true;
28288 }
28289 }
28290 }
28291 } catch (err) {
28292 logger$1.critical('Error while calculating scroll percentage', err);
28293 }
28294 if (shouldTrack) {
28295 this.mp.track(MP_EV_SCROLL, props);
28296 }
28297 }.bind(this);
28298
28299 var scrollEndPolyfill = getPolyfillScrollEndFunction(scrollTrackFunction);
28300 this.listenerScroll = scrollEndPolyfill.listener;
28301 win.addEventListener(scrollEndPolyfill.eventType, this.listenerScroll);
28302 };
28303
28304 Autocapture.prototype.initSubmitTracking = function() {
28305 win.removeEventListener(EV_SUBMIT, this.listenerSubmit);
28306
28307 if (!this.getConfig(CONFIG_TRACK_SUBMIT)) {
28308 return;
28309 }
28310 logger$1.log('Initializing submit tracking');
28311
28312 this.listenerSubmit = function(ev) {
28313 if (!this.getConfig(CONFIG_TRACK_SUBMIT)) {
28314 return;
28315 }
28316 this.trackDomEvent(ev, MP_EV_SUBMIT);
28317 }.bind(this);
28318 win.addEventListener(EV_SUBMIT, this.listenerSubmit);
28319 };
28320
28321 Autocapture.prototype.initPageLeaveTracking = function() {
28322 // Capture page_leave both when the user navigates away from the page (visibilitychange) as well
28323 // as when they navigate to a different page within the SPA (popstate/pushstate/hashchange).
28324 document$1.removeEventListener(EV_VISIBILITYCHANGE, this.listenerPageLeaveVisibilitychange);
28325 win.removeEventListener(EV_MP_LOCATION_CHANGE, this.listenerPageLeaveLocationchange);
28326 win.removeEventListener(EV_LOAD, this.listenerPageLoad);
28327
28328 if (!this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.get_config('record_heatmap_data')) {
28329 return;
28330 }
28331
28332 logger$1.log('Initializing page visibility tracking.');
28333 this._initScrollDepthTracking();
28334 var previousTrackedUrl = _.info.currentUrl();
28335
28336 // Initialize previousScrollHeight on `load` which handles async loading
28337 // https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event
28338 this.listenerPageLoad = function() {
28339 this.previousScrollHeight = document$1.body.scrollHeight;
28340 }.bind(this);
28341 win.addEventListener(EV_LOAD, this.listenerPageLoad);
28342
28343 // Track page navigation events similar to how initPageviewTracking does it
28344 this.listenerPageLeaveLocationchange = safewrap(function(ev) {
28345 if (this.currentUrlBlocked()) {
28346 return;
28347 }
28348
28349 var currentUrl = _.info.currentUrl();
28350 // Track all URL changes including query string or fragment changes as separate scroll sessions
28351 var shouldTrack = currentUrl !== previousTrackedUrl;
28352
28353 if (shouldTrack) {
28354 this._trackPageLeave(ev, previousTrackedUrl, this.previousScrollHeight);
28355 previousTrackedUrl = currentUrl;
28356 // Fragment navigation should call scroll(end) and trigger listener, don't add window.scrollY here.
28357 this.maxScrollViewDepth = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
28358 this.previousScrollHeight = document$1.body.scrollHeight;
28359 this.hasTrackedScrollSession = false;
28360 }
28361 }.bind(this));
28362 win.addEventListener(EV_MP_LOCATION_CHANGE, this.listenerPageLeaveLocationchange);
28363
28364 this.listenerPageLeaveVisibilitychange = function(ev) {
28365 if (document$1.hidden) {
28366 this._trackPageLeave(ev, previousTrackedUrl, this.previousScrollHeight);
28367 }
28368 }.bind(this);
28369 document$1.addEventListener(EV_VISIBILITYCHANGE, this.listenerPageLeaveVisibilitychange);
28370 };
28371
28372 Autocapture.prototype.stopDeadClickTracking = function() {
28373 if (this.listenerDeadClick) {
28374 win.removeEventListener(EV_CLICK, this.listenerDeadClick);
28375 this.listenerDeadClick = null;
28376 }
28377
28378 if (this._deadClickTracker) {
28379 this._deadClickTracker.stopTracking();
28380 this._deadClickTracker = null;
28381 }
28382 };
28383
28384 // TODO integrate error_reporter from mixpanel instance
28385 safewrapClass(Autocapture);
28386
28387 var logger = console_with_prefix('flags');
28388
28389 var FLAGS_CONFIG_KEY = 'flags';
28390
28391 var CONFIG_CONTEXT = 'context';
28392 var CONFIG_DEFAULTS = {};
28393 CONFIG_DEFAULTS[CONFIG_CONTEXT] = {};
28394
28395 /**
28396 * FeatureFlagManager: support for Mixpanel's feature flagging product
28397 * @constructor
28398 */
28399 var FeatureFlagManager = function(initOptions) {
28400 this.fetch = win['fetch'];
28401 this.getFullApiRoute = initOptions.getFullApiRoute;
28402 this.getMpConfig = initOptions.getConfigFunc;
28403 this.setMpConfig = initOptions.setConfigFunc;
28404 this.getMpProperty = initOptions.getPropertyFunc;
28405 this.track = initOptions.trackingFunc;
28406 };
28407
28408 FeatureFlagManager.prototype.init = function() {
28409 if (!this.minApisSupported()) {
28410 logger.critical('Feature Flags unavailable: missing minimum required APIs');
28411 return;
28412 }
28413
28414 this.flags = null;
28415 this.fetchFlags();
28416
28417 this.trackedFeatures = new Set();
28418 };
28419
28420 FeatureFlagManager.prototype.getFullConfig = function() {
28421 var ffConfig = this.getMpConfig(FLAGS_CONFIG_KEY);
28422 if (!ffConfig) {
28423 // flags are completely off
28424 return {};
28425 } else if (_.isObject(ffConfig)) {
28426 return _.extend({}, CONFIG_DEFAULTS, ffConfig);
28427 } else {
28428 // config is non-object truthy value, return default
28429 return CONFIG_DEFAULTS;
28430 }
28431 };
28432
28433 FeatureFlagManager.prototype.getConfig = function(key) {
28434 return this.getFullConfig()[key];
28435 };
28436
28437 FeatureFlagManager.prototype.isSystemEnabled = function() {
28438 return !!this.getMpConfig(FLAGS_CONFIG_KEY);
28439 };
28440
28441 FeatureFlagManager.prototype.updateContext = function(newContext, options) {
28442 if (!this.isSystemEnabled()) {
28443 logger.critical('Feature Flags not enabled, cannot update context');
28444 return Promise.resolve();
28445 }
28446
28447 var ffConfig = this.getMpConfig(FLAGS_CONFIG_KEY);
28448 if (!_.isObject(ffConfig)) {
28449 ffConfig = {};
28450 }
28451 var oldContext = (options && options['replace']) ? {} : this.getConfig(CONFIG_CONTEXT);
28452 ffConfig[CONFIG_CONTEXT] = _.extend({}, oldContext, newContext);
28453
28454 this.setMpConfig(FLAGS_CONFIG_KEY, ffConfig);
28455 return this.fetchFlags();
28456 };
28457
28458 FeatureFlagManager.prototype.areFlagsReady = function() {
28459 if (!this.isSystemEnabled()) {
28460 logger.error('Feature Flags not enabled');
28461 }
28462 return !!this.flags;
28463 };
28464
28465 FeatureFlagManager.prototype.fetchFlags = function() {
28466 if (!this.isSystemEnabled()) {
28467 return Promise.resolve();
28468 }
28469
28470 var distinctId = this.getMpProperty('distinct_id');
28471 var deviceId = this.getMpProperty('$device_id');
28472 var traceparent = generateTraceparent();
28473 logger.log('Fetching flags for distinct ID: ' + distinctId);
28474
28475 var context = _.extend({'distinct_id': distinctId, 'device_id': deviceId}, this.getConfig(CONFIG_CONTEXT));
28476 var searchParams = new URLSearchParams();
28477 searchParams.set('context', JSON.stringify(context));
28478 searchParams.set('token', this.getMpConfig('token'));
28479 searchParams.set('mp_lib', 'web');
28480 searchParams.set('$lib_version', Config.LIB_VERSION);
28481 var url = this.getFullApiRoute() + '?' + searchParams.toString();
28482
28483 this._fetchInProgressStartTime = Date.now();
28484 this.fetchPromise = this.fetch.call(win, url, {
28485 'method': 'GET',
28486 'headers': {
28487 'Authorization': 'Basic ' + btoa(this.getMpConfig('token') + ':'),
28488 'traceparent': traceparent
28489 }
28490 }).then(function(response) {
28491 this.markFetchComplete();
28492 return response.json().then(function(responseBody) {
28493 var responseFlags = responseBody['flags'];
28494 if (!responseFlags) {
28495 throw new Error('No flags in API response');
28496 }
28497 var flags = new Map();
28498 _.each(responseFlags, function(data, key) {
28499 flags.set(key, {
28500 'key': data['variant_key'],
28501 'value': data['variant_value'],
28502 'experiment_id': data['experiment_id'],
28503 'is_experiment_active': data['is_experiment_active'],
28504 'is_qa_tester': data['is_qa_tester']
28505 });
28506 });
28507 this.flags = flags;
28508 this._traceparent = traceparent;
28509 }.bind(this)).catch(function(error) {
28510 this.markFetchComplete();
28511 logger.error(error);
28512 }.bind(this));
28513 }.bind(this)).catch(function(error) {
28514 this.markFetchComplete();
28515 logger.error(error);
28516 }.bind(this));
28517
28518 return this.fetchPromise;
28519 };
28520
28521 FeatureFlagManager.prototype.markFetchComplete = function() {
28522 if (!this._fetchInProgressStartTime) {
28523 logger.error('Fetch in progress started time not set, cannot mark fetch complete');
28524 return;
28525 }
28526 this._fetchStartTime = this._fetchInProgressStartTime;
28527 this._fetchCompleteTime = Date.now();
28528 this._fetchLatency = this._fetchCompleteTime - this._fetchStartTime;
28529 this._fetchInProgressStartTime = null;
28530 };
28531
28532 FeatureFlagManager.prototype.getVariant = function(featureName, fallback) {
28533 if (!this.fetchPromise) {
28534 return new Promise(function(resolve) {
28535 logger.critical('Feature Flags not initialized');
28536 resolve(fallback);
28537 });
28538 }
28539
28540 return this.fetchPromise.then(function() {
28541 return this.getVariantSync(featureName, fallback);
28542 }.bind(this)).catch(function(error) {
28543 logger.error(error);
28544 return fallback;
28545 });
28546 };
28547
28548 FeatureFlagManager.prototype.getVariantSync = function(featureName, fallback) {
28549 if (!this.areFlagsReady()) {
28550 logger.log('Flags not loaded yet');
28551 return fallback;
28552 }
28553 var feature = this.flags.get(featureName);
28554 if (!feature) {
28555 logger.log('No flag found: "' + featureName + '"');
28556 return fallback;
28557 }
28558 this.trackFeatureCheck(featureName, feature);
28559 return feature;
28560 };
28561
28562 FeatureFlagManager.prototype.getVariantValue = function(featureName, fallbackValue) {
28563 return this.getVariant(featureName, {'value': fallbackValue}).then(function(feature) {
28564 return feature['value'];
28565 }).catch(function(error) {
28566 logger.error(error);
28567 return fallbackValue;
28568 });
28569 };
28570
28571 // TODO remove deprecated method
28572 FeatureFlagManager.prototype.getFeatureData = function(featureName, fallbackValue) {
28573 logger.critical('mixpanel.flags.get_feature_data() is deprecated and will be removed in a future release. Use mixpanel.flags.get_variant_value() instead.');
28574 return this.getVariantValue(featureName, fallbackValue);
28575 };
28576
28577 FeatureFlagManager.prototype.getVariantValueSync = function(featureName, fallbackValue) {
28578 return this.getVariantSync(featureName, {'value': fallbackValue})['value'];
28579 };
28580
28581 FeatureFlagManager.prototype.isEnabled = function(featureName, fallbackValue) {
28582 return this.getVariantValue(featureName).then(function() {
28583 return this.isEnabledSync(featureName, fallbackValue);
28584 }.bind(this)).catch(function(error) {
28585 logger.error(error);
28586 return fallbackValue;
28587 });
28588 };
28589
28590 FeatureFlagManager.prototype.isEnabledSync = function(featureName, fallbackValue) {
28591 fallbackValue = fallbackValue || false;
28592 var val = this.getVariantValueSync(featureName, fallbackValue);
28593 if (val !== true && val !== false) {
28594 logger.error('Feature flag "' + featureName + '" value: ' + val + ' is not a boolean; returning fallback value: ' + fallbackValue);
28595 val = fallbackValue;
28596 }
28597 return val;
28598 };
28599
28600 FeatureFlagManager.prototype.trackFeatureCheck = function(featureName, feature) {
28601 if (this.trackedFeatures.has(featureName)) {
28602 return;
28603 }
28604 this.trackedFeatures.add(featureName);
28605
28606 var trackingProperties = {
28607 'Experiment name': featureName,
28608 'Variant name': feature['key'],
28609 '$experiment_type': 'feature_flag',
28610 'Variant fetch start time': new Date(this._fetchStartTime).toISOString(),
28611 'Variant fetch complete time': new Date(this._fetchCompleteTime).toISOString(),
28612 'Variant fetch latency (ms)': this._fetchLatency,
28613 'Variant fetch traceparent': this._traceparent,
28614 };
28615
28616 if (feature['experiment_id'] !== 'undefined') {
28617 trackingProperties['$experiment_id'] = feature['experiment_id'];
28618 }
28619 if (feature['is_experiment_active'] !== 'undefined') {
28620 trackingProperties['$is_experiment_active'] = feature['is_experiment_active'];
28621 }
28622 if (feature['is_qa_tester'] !== 'undefined') {
28623 trackingProperties['$is_qa_tester'] = feature['is_qa_tester'];
28624 }
28625
28626 this.track('$experiment_started', trackingProperties);
28627 };
28628
28629 FeatureFlagManager.prototype.minApisSupported = function() {
28630 return !!this.fetch &&
28631 typeof Promise !== 'undefined' &&
28632 typeof Map !== 'undefined' &&
28633 typeof Set !== 'undefined';
28634 };
28635
28636 safewrapClass(FeatureFlagManager);
28637
28638 FeatureFlagManager.prototype['are_flags_ready'] = FeatureFlagManager.prototype.areFlagsReady;
28639 FeatureFlagManager.prototype['get_variant'] = FeatureFlagManager.prototype.getVariant;
28640 FeatureFlagManager.prototype['get_variant_sync'] = FeatureFlagManager.prototype.getVariantSync;
28641 FeatureFlagManager.prototype['get_variant_value'] = FeatureFlagManager.prototype.getVariantValue;
28642 FeatureFlagManager.prototype['get_variant_value_sync'] = FeatureFlagManager.prototype.getVariantValueSync;
28643 FeatureFlagManager.prototype['is_enabled'] = FeatureFlagManager.prototype.isEnabled;
28644 FeatureFlagManager.prototype['is_enabled_sync'] = FeatureFlagManager.prototype.isEnabledSync;
28645 FeatureFlagManager.prototype['update_context'] = FeatureFlagManager.prototype.updateContext;
28646
28647 // Deprecated method
28648 FeatureFlagManager.prototype['get_feature_data'] = FeatureFlagManager.prototype.getFeatureData;
28649
28650 /* eslint camelcase: "off" */
28651
28652
28653 /**
28654 * DomTracker Object
28655 * @constructor
28656 */
28657 var DomTracker = function() {};
28658
28659
28660 // interface
28661 DomTracker.prototype.create_properties = function() {};
28662 DomTracker.prototype.event_handler = function() {};
28663 DomTracker.prototype.after_track_handler = function() {};
28664
28665 DomTracker.prototype.init = function(mixpanel_instance) {
28666 this.mp = mixpanel_instance;
28667 return this;
28668 };
28669
28670 /**
28671 * @param {Object|string} query
28672 * @param {string} event_name
28673 * @param {Object=} properties
28674 * @param {function=} user_callback
28675 */
28676 DomTracker.prototype.track = function(query, event_name, properties, user_callback) {
28677 var that = this;
28678 var elements = _.dom_query(query);
28679
28680 if (elements.length === 0) {
28681 console$1.error('The DOM query (' + query + ') returned 0 elements');
28682 return;
28683 }
28684
28685 _.each(elements, function(element) {
28686 _.register_event(element, this.override_event, function(e) {
28687 var options = {};
28688 var props = that.create_properties(properties, this);
28689 var timeout = that.mp.get_config('track_links_timeout');
28690
28691 that.event_handler(e, this, options);
28692
28693 // in case the mixpanel servers don't get back to us in time
28694 window.setTimeout(that.track_callback(user_callback, props, options, true), timeout);
28695
28696 // fire the tracking event
28697 that.mp.track(event_name, props, that.track_callback(user_callback, props, options));
28698 });
28699 }, this);
28700
28701 return true;
28702 };
28703
28704 /**
28705 * @param {function} user_callback
28706 * @param {Object} props
28707 * @param {boolean=} timeout_occured
28708 */
28709 DomTracker.prototype.track_callback = function(user_callback, props, options, timeout_occured) {
28710 timeout_occured = timeout_occured || false;
28711 var that = this;
28712
28713 return function() {
28714 // options is referenced from both callbacks, so we can have
28715 // a 'lock' of sorts to ensure only one fires
28716 if (options.callback_fired) { return; }
28717 options.callback_fired = true;
28718
28719 if (user_callback && user_callback(timeout_occured, props) === false) {
28720 // user can prevent the default functionality by
28721 // returning false from their callback
28722 return;
28723 }
28724
28725 that.after_track_handler(props, options, timeout_occured);
28726 };
28727 };
28728
28729 DomTracker.prototype.create_properties = function(properties, element) {
28730 var props;
28731
28732 if (typeof(properties) === 'function') {
28733 props = properties(element);
28734 } else {
28735 props = _.extend({}, properties);
28736 }
28737
28738 return props;
28739 };
28740
28741 /**
28742 * LinkTracker Object
28743 * @constructor
28744 * @extends DomTracker
28745 */
28746 var LinkTracker = function() {
28747 this.override_event = 'click';
28748 };
28749 _.inherit(LinkTracker, DomTracker);
28750
28751 LinkTracker.prototype.create_properties = function(properties, element) {
28752 var props = LinkTracker.superclass.create_properties.apply(this, arguments);
28753
28754 if (element.href) { props['url'] = element.href; }
28755
28756 return props;
28757 };
28758
28759 LinkTracker.prototype.event_handler = function(evt, element, options) {
28760 options.new_tab = (
28761 evt.which === 2 ||
28762 evt.metaKey ||
28763 evt.ctrlKey ||
28764 element.target === '_blank'
28765 );
28766 options.href = element.href;
28767
28768 if (!options.new_tab) {
28769 evt.preventDefault();
28770 }
28771 };
28772
28773 LinkTracker.prototype.after_track_handler = function(props, options) {
28774 if (options.new_tab) { return; }
28775
28776 setTimeout(function() {
28777 window.location = options.href;
28778 }, 0);
28779 };
28780
28781 /**
28782 * FormTracker Object
28783 * @constructor
28784 * @extends DomTracker
28785 */
28786 var FormTracker = function() {
28787 this.override_event = 'submit';
28788 };
28789 _.inherit(FormTracker, DomTracker);
28790
28791 FormTracker.prototype.event_handler = function(evt, element, options) {
28792 options.element = element;
28793 evt.preventDefault();
28794 };
28795
28796 FormTracker.prototype.after_track_handler = function(props, options) {
28797 setTimeout(function() {
28798 options.element.submit();
28799 }, 0);
28800 };
28801
28802 /* eslint camelcase: "off" */
28803
28804
28805 /** @const */ var SET_ACTION = '$set';
28806 /** @const */ var SET_ONCE_ACTION = '$set_once';
28807 /** @const */ var UNSET_ACTION = '$unset';
28808 /** @const */ var ADD_ACTION = '$add';
28809 /** @const */ var APPEND_ACTION = '$append';
28810 /** @const */ var UNION_ACTION = '$union';
28811 /** @const */ var REMOVE_ACTION = '$remove';
28812 /** @const */ var DELETE_ACTION = '$delete';
28813
28814 // Common internal methods for mixpanel.people and mixpanel.group APIs.
28815 // These methods shouldn't involve network I/O.
28816 var apiActions = {
28817 set_action: function(prop, to) {
28818 var data = {};
28819 var $set = {};
28820 if (_.isObject(prop)) {
28821 _.each(prop, function(v, k) {
28822 if (!this._is_reserved_property(k)) {
28823 $set[k] = v;
28824 }
28825 }, this);
28826 } else {
28827 $set[prop] = to;
28828 }
28829
28830 data[SET_ACTION] = $set;
28831 return data;
28832 },
28833
28834 unset_action: function(prop) {
28835 var data = {};
28836 var $unset = [];
28837 if (!_.isArray(prop)) {
28838 prop = [prop];
28839 }
28840
28841 _.each(prop, function(k) {
28842 if (!this._is_reserved_property(k)) {
28843 $unset.push(k);
28844 }
28845 }, this);
28846
28847 data[UNSET_ACTION] = $unset;
28848 return data;
28849 },
28850
28851 set_once_action: function(prop, to) {
28852 var data = {};
28853 var $set_once = {};
28854 if (_.isObject(prop)) {
28855 _.each(prop, function(v, k) {
28856 if (!this._is_reserved_property(k)) {
28857 $set_once[k] = v;
28858 }
28859 }, this);
28860 } else {
28861 $set_once[prop] = to;
28862 }
28863 data[SET_ONCE_ACTION] = $set_once;
28864 return data;
28865 },
28866
28867 union_action: function(list_name, values) {
28868 var data = {};
28869 var $union = {};
28870 if (_.isObject(list_name)) {
28871 _.each(list_name, function(v, k) {
28872 if (!this._is_reserved_property(k)) {
28873 $union[k] = _.isArray(v) ? v : [v];
28874 }
28875 }, this);
28876 } else {
28877 $union[list_name] = _.isArray(values) ? values : [values];
28878 }
28879 data[UNION_ACTION] = $union;
28880 return data;
28881 },
28882
28883 append_action: function(list_name, value) {
28884 var data = {};
28885 var $append = {};
28886 if (_.isObject(list_name)) {
28887 _.each(list_name, function(v, k) {
28888 if (!this._is_reserved_property(k)) {
28889 $append[k] = v;
28890 }
28891 }, this);
28892 } else {
28893 $append[list_name] = value;
28894 }
28895 data[APPEND_ACTION] = $append;
28896 return data;
28897 },
28898
28899 remove_action: function(list_name, value) {
28900 var data = {};
28901 var $remove = {};
28902 if (_.isObject(list_name)) {
28903 _.each(list_name, function(v, k) {
28904 if (!this._is_reserved_property(k)) {
28905 $remove[k] = v;
28906 }
28907 }, this);
28908 } else {
28909 $remove[list_name] = value;
28910 }
28911 data[REMOVE_ACTION] = $remove;
28912 return data;
28913 },
28914
28915 delete_action: function() {
28916 var data = {};
28917 data[DELETE_ACTION] = '';
28918 return data;
28919 }
28920 };
28921
28922 /* eslint camelcase: "off" */
28923
28924 /**
28925 * Mixpanel Group Object
28926 * @constructor
28927 */
28928 var MixpanelGroup = function() {};
28929
28930 _.extend(MixpanelGroup.prototype, apiActions);
28931
28932 MixpanelGroup.prototype._init = function(mixpanel_instance, group_key, group_id) {
28933 this._mixpanel = mixpanel_instance;
28934 this._group_key = group_key;
28935 this._group_id = group_id;
28936 };
28937
28938 /**
28939 * Set properties on a group.
28940 *
28941 * ### Usage:
28942 *
28943 * mixpanel.get_group('company', 'mixpanel').set('Location', '405 Howard');
28944 *
28945 * // or set multiple properties at once
28946 * mixpanel.get_group('company', 'mixpanel').set({
28947 * 'Location': '405 Howard',
28948 * 'Founded' : 2009,
28949 * });
28950 * // properties can be strings, integers, dates, or lists
28951 *
28952 * @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.
28953 * @param {*} [to] A value to set on the given property name
28954 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28955 */
28956 MixpanelGroup.prototype.set = addOptOutCheckMixpanelGroup(function(prop, to, callback) {
28957 var data = this.set_action(prop, to);
28958 if (_.isObject(prop)) {
28959 callback = to;
28960 }
28961 return this._send_request(data, callback);
28962 });
28963
28964 /**
28965 * Set properties on a group, only if they do not yet exist.
28966 * This will not overwrite previous group property values, unlike
28967 * group.set().
28968 *
28969 * ### Usage:
28970 *
28971 * mixpanel.get_group('company', 'mixpanel').set_once('Location', '405 Howard');
28972 *
28973 * // or set multiple properties at once
28974 * mixpanel.get_group('company', 'mixpanel').set_once({
28975 * 'Location': '405 Howard',
28976 * 'Founded' : 2009,
28977 * });
28978 * // properties can be strings, integers, lists or dates
28979 *
28980 * @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.
28981 * @param {*} [to] A value to set on the given property name
28982 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28983 */
28984 MixpanelGroup.prototype.set_once = addOptOutCheckMixpanelGroup(function(prop, to, callback) {
28985 var data = this.set_once_action(prop, to);
28986 if (_.isObject(prop)) {
28987 callback = to;
28988 }
28989 return this._send_request(data, callback);
28990 });
28991
28992 /**
28993 * Unset properties on a group permanently.
28994 *
28995 * ### Usage:
28996 *
28997 * mixpanel.get_group('company', 'mixpanel').unset('Founded');
28998 *
28999 * @param {String} prop The name of the property.
29000 * @param {Function} [callback] If provided, the callback will be called after the tracking event
29001 */
29002 MixpanelGroup.prototype.unset = addOptOutCheckMixpanelGroup(function(prop, callback) {
29003 var data = this.unset_action(prop);
29004 return this._send_request(data, callback);
29005 });
29006
29007 /**
29008 * Merge a given list with a list-valued group property, excluding duplicate values.
29009 *
29010 * ### Usage:
29011 *
29012 * // merge a value to a list, creating it if needed
29013 * mixpanel.get_group('company', 'mixpanel').union('Location', ['San Francisco', 'London']);
29014 *
29015 * @param {String} list_name Name of the property.
29016 * @param {Array} values Values to merge with the given property
29017 * @param {Function} [callback] If provided, the callback will be called after the tracking event
29018 */
29019 MixpanelGroup.prototype.union = addOptOutCheckMixpanelGroup(function(list_name, values, callback) {
29020 if (_.isObject(list_name)) {
29021 callback = values;
29022 }
29023 var data = this.union_action(list_name, values);
29024 return this._send_request(data, callback);
29025 });
29026
29027 /**
29028 * Permanently delete a group.
29029 *
29030 * ### Usage:
29031 *
29032 * mixpanel.get_group('company', 'mixpanel').delete();
29033 *
29034 * @param {Function} [callback] If provided, the callback will be called after the tracking event
29035 */
29036 MixpanelGroup.prototype['delete'] = addOptOutCheckMixpanelGroup(function(callback) {
29037 // bracket notation above prevents a minification error related to reserved words
29038 var data = this.delete_action();
29039 return this._send_request(data, callback);
29040 });
29041
29042 /**
29043 * Remove a property from a group. The value will be ignored if doesn't exist.
29044 *
29045 * ### Usage:
29046 *
29047 * mixpanel.get_group('company', 'mixpanel').remove('Location', 'London');
29048 *
29049 * @param {String} list_name Name of the property.
29050 * @param {Object} value Value to remove from the given group property
29051 * @param {Function} [callback] If provided, the callback will be called after the tracking event
29052 */
29053 MixpanelGroup.prototype.remove = addOptOutCheckMixpanelGroup(function(list_name, value, callback) {
29054 var data = this.remove_action(list_name, value);
29055 return this._send_request(data, callback);
29056 });
29057
29058 MixpanelGroup.prototype._send_request = function(data, callback) {
29059 data['$group_key'] = this._group_key;
29060 data['$group_id'] = this._group_id;
29061 data['$token'] = this._get_config('token');
29062
29063 var date_encoded_data = _.encodeDates(data);
29064 return this._mixpanel._track_or_batch({
29065 type: 'groups',
29066 data: date_encoded_data,
29067 endpoint: this._mixpanel.get_api_host('groups') + '/' + this._get_config('api_routes')['groups'],
29068 batcher: this._mixpanel.request_batchers.groups
29069 }, callback);
29070 };
29071
29072 MixpanelGroup.prototype._is_reserved_property = function(prop) {
29073 return prop === '$group_key' || prop === '$group_id';
29074 };
29075
29076 MixpanelGroup.prototype._get_config = function(conf) {
29077 return this._mixpanel.get_config(conf);
29078 };
29079
29080 MixpanelGroup.prototype.toString = function() {
29081 return this._mixpanel.toString() + '.group.' + this._group_key + '.' + this._group_id;
29082 };
29083
29084 // MixpanelGroup Exports
29085 MixpanelGroup.prototype['remove'] = MixpanelGroup.prototype.remove;
29086 MixpanelGroup.prototype['set'] = MixpanelGroup.prototype.set;
29087 MixpanelGroup.prototype['set_once'] = MixpanelGroup.prototype.set_once;
29088 MixpanelGroup.prototype['union'] = MixpanelGroup.prototype.union;
29089 MixpanelGroup.prototype['unset'] = MixpanelGroup.prototype.unset;
29090 MixpanelGroup.prototype['toString'] = MixpanelGroup.prototype.toString;
29091
29092 /* eslint camelcase: "off" */
29093
29094 /**
29095 * Mixpanel People Object
29096 * @constructor
29097 */
29098 var MixpanelPeople = function() {};
29099
29100 _.extend(MixpanelPeople.prototype, apiActions);
29101
29102 MixpanelPeople.prototype._init = function(mixpanel_instance) {
29103 this._mixpanel = mixpanel_instance;
29104 };
29105
29106 /*
29107 * Set properties on a user record.
29108 *
29109 * ### Usage:
29110 *
29111 * mixpanel.people.set('gender', 'm');
29112 *
29113 * // or set multiple properties at once
29114 * mixpanel.people.set({
29115 * 'Company': 'Acme',
29116 * 'Plan': 'Premium',
29117 * 'Upgrade date': new Date()
29118 * });
29119 * // properties can be strings, integers, dates, or lists
29120 *
29121 * @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.
29122 * @param {*} [to] A value to set on the given property name
29123 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29124 */
29125 MixpanelPeople.prototype.set = addOptOutCheckMixpanelPeople(function(prop, to, callback) {
29126 var data = this.set_action(prop, to);
29127 if (_.isObject(prop)) {
29128 callback = to;
29129 }
29130 // make sure that the referrer info has been updated and saved
29131 if (this._get_config('save_referrer')) {
29132 this._mixpanel['persistence'].update_referrer_info(document.referrer);
29133 }
29134
29135 // update $set object with default people properties
29136 data[SET_ACTION] = _.extend(
29137 {},
29138 _.info.people_properties(),
29139 data[SET_ACTION]
29140 );
29141 return this._send_request(data, callback);
29142 });
29143
29144 /*
29145 * Set properties on a user record, only if they do not yet exist.
29146 * This will not overwrite previous people property values, unlike
29147 * people.set().
29148 *
29149 * ### Usage:
29150 *
29151 * mixpanel.people.set_once('First Login Date', new Date());
29152 *
29153 * // or set multiple properties at once
29154 * mixpanel.people.set_once({
29155 * 'First Login Date': new Date(),
29156 * 'Starting Plan': 'Premium'
29157 * });
29158 *
29159 * // properties can be strings, integers or dates
29160 *
29161 * @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.
29162 * @param {*} [to] A value to set on the given property name
29163 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29164 */
29165 MixpanelPeople.prototype.set_once = addOptOutCheckMixpanelPeople(function(prop, to, callback) {
29166 var data = this.set_once_action(prop, to);
29167 if (_.isObject(prop)) {
29168 callback = to;
29169 }
29170 return this._send_request(data, callback);
29171 });
29172
29173 /*
29174 * Unset properties on a user record (permanently removes the properties and their values from a profile).
29175 *
29176 * ### Usage:
29177 *
29178 * mixpanel.people.unset('gender');
29179 *
29180 * // or unset multiple properties at once
29181 * mixpanel.people.unset(['gender', 'Company']);
29182 *
29183 * @param {Array|String} prop If a string, this is the name of the property. If an array, this is a list of property names.
29184 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29185 */
29186 MixpanelPeople.prototype.unset = addOptOutCheckMixpanelPeople(function(prop, callback) {
29187 var data = this.unset_action(prop);
29188 return this._send_request(data, callback);
29189 });
29190
29191 /*
29192 * Increment/decrement numeric people analytics properties.
29193 *
29194 * ### Usage:
29195 *
29196 * mixpanel.people.increment('page_views', 1);
29197 *
29198 * // or, for convenience, if you're just incrementing a counter by
29199 * // 1, you can simply do
29200 * mixpanel.people.increment('page_views');
29201 *
29202 * // to decrement a counter, pass a negative number
29203 * mixpanel.people.increment('credits_left', -1);
29204 *
29205 * // like mixpanel.people.set(), you can increment multiple
29206 * // properties at once:
29207 * mixpanel.people.increment({
29208 * counter1: 1,
29209 * counter2: 6
29210 * });
29211 *
29212 * @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.
29213 * @param {Number} [by] An amount to increment the given property
29214 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29215 */
29216 MixpanelPeople.prototype.increment = addOptOutCheckMixpanelPeople(function(prop, by, callback) {
29217 var data = {};
29218 var $add = {};
29219 if (_.isObject(prop)) {
29220 _.each(prop, function(v, k) {
29221 if (!this._is_reserved_property(k)) {
29222 if (isNaN(parseFloat(v))) {
29223 console$1.error('Invalid increment value passed to mixpanel.people.increment - must be a number');
29224 return;
29225 } else {
29226 $add[k] = v;
29227 }
29228 }
29229 }, this);
29230 callback = by;
29231 } else {
29232 // convenience: mixpanel.people.increment('property'); will
29233 // increment 'property' by 1
29234 if (_.isUndefined(by)) {
29235 by = 1;
29236 }
29237 $add[prop] = by;
29238 }
29239 data[ADD_ACTION] = $add;
29240
29241 return this._send_request(data, callback);
29242 });
29243
29244 /*
29245 * Append a value to a list-valued people analytics property.
29246 *
29247 * ### Usage:
29248 *
29249 * // append a value to a list, creating it if needed
29250 * mixpanel.people.append('pages_visited', 'homepage');
29251 *
29252 * // like mixpanel.people.set(), you can append multiple
29253 * // properties at once:
29254 * mixpanel.people.append({
29255 * list1: 'bob',
29256 * list2: 123
29257 * });
29258 *
29259 * @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.
29260 * @param {*} [value] value An item to append to the list
29261 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29262 */
29263 MixpanelPeople.prototype.append = addOptOutCheckMixpanelPeople(function(list_name, value, callback) {
29264 if (_.isObject(list_name)) {
29265 callback = value;
29266 }
29267 var data = this.append_action(list_name, value);
29268 return this._send_request(data, callback);
29269 });
29270
29271 /*
29272 * Remove a value from a list-valued people analytics property.
29273 *
29274 * ### Usage:
29275 *
29276 * mixpanel.people.remove('School', 'UCB');
29277 *
29278 * @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.
29279 * @param {*} [value] value Item to remove from the list
29280 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29281 */
29282 MixpanelPeople.prototype.remove = addOptOutCheckMixpanelPeople(function(list_name, value, callback) {
29283 if (_.isObject(list_name)) {
29284 callback = value;
29285 }
29286 var data = this.remove_action(list_name, value);
29287 return this._send_request(data, callback);
29288 });
29289
29290 /*
29291 * Merge a given list with a list-valued people analytics property,
29292 * excluding duplicate values.
29293 *
29294 * ### Usage:
29295 *
29296 * // merge a value to a list, creating it if needed
29297 * mixpanel.people.union('pages_visited', 'homepage');
29298 *
29299 * // like mixpanel.people.set(), you can append multiple
29300 * // properties at once:
29301 * mixpanel.people.union({
29302 * list1: 'bob',
29303 * list2: 123
29304 * });
29305 *
29306 * // like mixpanel.people.append(), you can append multiple
29307 * // values to the same list:
29308 * mixpanel.people.union({
29309 * list1: ['bob', 'billy']
29310 * });
29311 *
29312 * @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.
29313 * @param {*} [value] Value / values to merge with the given property
29314 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29315 */
29316 MixpanelPeople.prototype.union = addOptOutCheckMixpanelPeople(function(list_name, values, callback) {
29317 if (_.isObject(list_name)) {
29318 callback = values;
29319 }
29320 var data = this.union_action(list_name, values);
29321 return this._send_request(data, callback);
29322 });
29323
29324 /*
29325 * Record that you have charged the current user a certain amount
29326 * of money. Charges recorded with track_charge() will appear in the
29327 * Mixpanel revenue report.
29328 *
29329 * ### Usage:
29330 *
29331 * // charge a user $50
29332 * mixpanel.people.track_charge(50);
29333 *
29334 * // charge a user $30.50 on the 2nd of january
29335 * mixpanel.people.track_charge(30.50, {
29336 * '$time': new Date('jan 1 2012')
29337 * });
29338 *
29339 * @param {Number} amount The amount of money charged to the current user
29340 * @param {Object} [properties] An associative array of properties associated with the charge
29341 * @param {Function} [callback] If provided, the callback will be called when the server responds
29342 * @deprecated
29343 */
29344 MixpanelPeople.prototype.track_charge = addOptOutCheckMixpanelPeople(function() {
29345 console$1.error('mixpanel.people.track_charge() is deprecated and no longer has any effect.');
29346 });
29347
29348 /*
29349 * Permanently clear all revenue report transactions from the
29350 * current user's people analytics profile.
29351 *
29352 * ### Usage:
29353 *
29354 * mixpanel.people.clear_charges();
29355 *
29356 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29357 * @deprecated
29358 */
29359 MixpanelPeople.prototype.clear_charges = function(callback) {
29360 return this.set('$transactions', [], callback);
29361 };
29362
29363 /*
29364 * Permanently deletes the current people analytics profile from
29365 * Mixpanel (using the current distinct_id).
29366 *
29367 * ### Usage:
29368 *
29369 * // remove the all data you have stored about the current user
29370 * mixpanel.people.delete_user();
29371 *
29372 */
29373 MixpanelPeople.prototype.delete_user = function() {
29374 if (!this._identify_called()) {
29375 console$1.error('mixpanel.people.delete_user() requires you to call identify() first');
29376 return;
29377 }
29378 var data = {'$delete': this._mixpanel.get_distinct_id()};
29379 return this._send_request(data);
29380 };
29381
29382 MixpanelPeople.prototype.toString = function() {
29383 return this._mixpanel.toString() + '.people';
29384 };
29385
29386 MixpanelPeople.prototype._send_request = function(data, callback) {
29387 data['$token'] = this._get_config('token');
29388 data['$distinct_id'] = this._mixpanel.get_distinct_id();
29389 var device_id = this._mixpanel.get_property('$device_id');
29390 var user_id = this._mixpanel.get_property('$user_id');
29391 var had_persisted_distinct_id = this._mixpanel.get_property('$had_persisted_distinct_id');
29392 if (device_id) {
29393 data['$device_id'] = device_id;
29394 }
29395 if (user_id) {
29396 data['$user_id'] = user_id;
29397 }
29398 if (had_persisted_distinct_id) {
29399 data['$had_persisted_distinct_id'] = had_persisted_distinct_id;
29400 }
29401
29402 var date_encoded_data = _.encodeDates(data);
29403
29404 if (!this._identify_called()) {
29405 this._enqueue(data);
29406 if (!_.isUndefined(callback)) {
29407 if (this._get_config('verbose')) {
29408 callback({status: -1, error: null});
29409 } else {
29410 callback(-1);
29411 }
29412 }
29413 return _.truncate(date_encoded_data, 255);
29414 }
29415
29416 return this._mixpanel._track_or_batch({
29417 type: 'people',
29418 data: date_encoded_data,
29419 endpoint: this._mixpanel.get_api_host('people') + '/' + this._get_config('api_routes')['engage'],
29420 batcher: this._mixpanel.request_batchers.people
29421 }, callback);
29422 };
29423
29424 MixpanelPeople.prototype._get_config = function(conf_var) {
29425 return this._mixpanel.get_config(conf_var);
29426 };
29427
29428 MixpanelPeople.prototype._identify_called = function() {
29429 return this._mixpanel._flags.identify_called === true;
29430 };
29431
29432 // Queue up engage operations if identify hasn't been called yet.
29433 MixpanelPeople.prototype._enqueue = function(data) {
29434 if (SET_ACTION in data) {
29435 this._mixpanel['persistence']._add_to_people_queue(SET_ACTION, data);
29436 } else if (SET_ONCE_ACTION in data) {
29437 this._mixpanel['persistence']._add_to_people_queue(SET_ONCE_ACTION, data);
29438 } else if (UNSET_ACTION in data) {
29439 this._mixpanel['persistence']._add_to_people_queue(UNSET_ACTION, data);
29440 } else if (ADD_ACTION in data) {
29441 this._mixpanel['persistence']._add_to_people_queue(ADD_ACTION, data);
29442 } else if (APPEND_ACTION in data) {
29443 this._mixpanel['persistence']._add_to_people_queue(APPEND_ACTION, data);
29444 } else if (REMOVE_ACTION in data) {
29445 this._mixpanel['persistence']._add_to_people_queue(REMOVE_ACTION, data);
29446 } else if (UNION_ACTION in data) {
29447 this._mixpanel['persistence']._add_to_people_queue(UNION_ACTION, data);
29448 } else {
29449 console$1.error('Invalid call to _enqueue():', data);
29450 }
29451 };
29452
29453 MixpanelPeople.prototype._flush_one_queue = function(action, action_method, callback, queue_to_params_fn) {
29454 var _this = this;
29455 var queued_data = _.extend({}, this._mixpanel['persistence'].load_queue(action));
29456 var action_params = queued_data;
29457
29458 if (!_.isUndefined(queued_data) && _.isObject(queued_data) && !_.isEmptyObject(queued_data)) {
29459 _this._mixpanel['persistence']._pop_from_people_queue(action, queued_data);
29460 _this._mixpanel['persistence'].save();
29461 if (queue_to_params_fn) {
29462 action_params = queue_to_params_fn(queued_data);
29463 }
29464 action_method.call(_this, action_params, function(response, data) {
29465 // on bad response, we want to add it back to the queue
29466 if (response === 0) {
29467 _this._mixpanel['persistence']._add_to_people_queue(action, queued_data);
29468 }
29469 if (!_.isUndefined(callback)) {
29470 callback(response, data);
29471 }
29472 });
29473 }
29474 };
29475
29476 // Flush queued engage operations - order does not matter,
29477 // and there are network level race conditions anyway
29478 MixpanelPeople.prototype._flush = function(
29479 _set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback
29480 ) {
29481 var _this = this;
29482
29483 this._flush_one_queue(SET_ACTION, this.set, _set_callback);
29484 this._flush_one_queue(SET_ONCE_ACTION, this.set_once, _set_once_callback);
29485 this._flush_one_queue(UNSET_ACTION, this.unset, _unset_callback, function(queue) { return _.keys(queue); });
29486 this._flush_one_queue(ADD_ACTION, this.increment, _add_callback);
29487 this._flush_one_queue(UNION_ACTION, this.union, _union_callback);
29488
29489 // we have to fire off each $append individually since there is
29490 // no concat method server side
29491 var $append_queue = this._mixpanel['persistence'].load_queue(APPEND_ACTION);
29492 if (!_.isUndefined($append_queue) && _.isArray($append_queue) && $append_queue.length) {
29493 var $append_item;
29494 var append_callback = function(response, data) {
29495 if (response === 0) {
29496 _this._mixpanel['persistence']._add_to_people_queue(APPEND_ACTION, $append_item);
29497 }
29498 if (!_.isUndefined(_append_callback)) {
29499 _append_callback(response, data);
29500 }
29501 };
29502 for (var i = $append_queue.length - 1; i >= 0; i--) {
29503 $append_queue = this._mixpanel['persistence'].load_queue(APPEND_ACTION);
29504 $append_item = $append_queue.pop();
29505 _this._mixpanel['persistence'].save();
29506 if (!_.isEmptyObject($append_item)) {
29507 _this.append($append_item, append_callback);
29508 }
29509 }
29510 }
29511
29512 // same for $remove
29513 var $remove_queue = this._mixpanel['persistence'].load_queue(REMOVE_ACTION);
29514 if (!_.isUndefined($remove_queue) && _.isArray($remove_queue) && $remove_queue.length) {
29515 var $remove_item;
29516 var remove_callback = function(response, data) {
29517 if (response === 0) {
29518 _this._mixpanel['persistence']._add_to_people_queue(REMOVE_ACTION, $remove_item);
29519 }
29520 if (!_.isUndefined(_remove_callback)) {
29521 _remove_callback(response, data);
29522 }
29523 };
29524 for (var j = $remove_queue.length - 1; j >= 0; j--) {
29525 $remove_queue = this._mixpanel['persistence'].load_queue(REMOVE_ACTION);
29526 $remove_item = $remove_queue.pop();
29527 _this._mixpanel['persistence'].save();
29528 if (!_.isEmptyObject($remove_item)) {
29529 _this.remove($remove_item, remove_callback);
29530 }
29531 }
29532 }
29533 };
29534
29535 MixpanelPeople.prototype._is_reserved_property = function(prop) {
29536 return prop === '$distinct_id' || prop === '$token' || prop === '$device_id' || prop === '$user_id' || prop === '$had_persisted_distinct_id';
29537 };
29538
29539 // MixpanelPeople Exports
29540 MixpanelPeople.prototype['set'] = MixpanelPeople.prototype.set;
29541 MixpanelPeople.prototype['set_once'] = MixpanelPeople.prototype.set_once;
29542 MixpanelPeople.prototype['unset'] = MixpanelPeople.prototype.unset;
29543 MixpanelPeople.prototype['increment'] = MixpanelPeople.prototype.increment;
29544 MixpanelPeople.prototype['append'] = MixpanelPeople.prototype.append;
29545 MixpanelPeople.prototype['remove'] = MixpanelPeople.prototype.remove;
29546 MixpanelPeople.prototype['union'] = MixpanelPeople.prototype.union;
29547 MixpanelPeople.prototype['track_charge'] = MixpanelPeople.prototype.track_charge;
29548 MixpanelPeople.prototype['clear_charges'] = MixpanelPeople.prototype.clear_charges;
29549 MixpanelPeople.prototype['delete_user'] = MixpanelPeople.prototype.delete_user;
29550 MixpanelPeople.prototype['toString'] = MixpanelPeople.prototype.toString;
29551
29552 /* eslint camelcase: "off" */
29553
29554
29555 /*
29556 * Constants
29557 */
29558 /** @const */ var SET_QUEUE_KEY = '__mps';
29559 /** @const */ var SET_ONCE_QUEUE_KEY = '__mpso';
29560 /** @const */ var UNSET_QUEUE_KEY = '__mpus';
29561 /** @const */ var ADD_QUEUE_KEY = '__mpa';
29562 /** @const */ var APPEND_QUEUE_KEY = '__mpap';
29563 /** @const */ var REMOVE_QUEUE_KEY = '__mpr';
29564 /** @const */ var UNION_QUEUE_KEY = '__mpu';
29565 // This key is deprecated, but we want to check for it to see whether aliasing is allowed.
29566 /** @const */ var PEOPLE_DISTINCT_ID_KEY = '$people_distinct_id';
29567 /** @const */ var ALIAS_ID_KEY = '__alias';
29568 /** @const */ var EVENT_TIMERS_KEY = '__timers';
29569 /** @const */ var RESERVED_PROPERTIES = [
29570 SET_QUEUE_KEY,
29571 SET_ONCE_QUEUE_KEY,
29572 UNSET_QUEUE_KEY,
29573 ADD_QUEUE_KEY,
29574 APPEND_QUEUE_KEY,
29575 REMOVE_QUEUE_KEY,
29576 UNION_QUEUE_KEY,
29577 PEOPLE_DISTINCT_ID_KEY,
29578 ALIAS_ID_KEY,
29579 EVENT_TIMERS_KEY
29580 ];
29581
29582 /**
29583 * Mixpanel Persistence Object
29584 * @constructor
29585 */
29586 var MixpanelPersistence = function(config) {
29587 this['props'] = {};
29588 this.campaign_params_saved = false;
29589
29590 if (config['persistence_name']) {
29591 this.name = 'mp_' + config['persistence_name'];
29592 } else {
29593 this.name = 'mp_' + config['token'] + '_mixpanel';
29594 }
29595
29596 var storage_type = config['persistence'];
29597 if (storage_type !== 'cookie' && storage_type !== 'localStorage') {
29598 console$1.critical('Unknown persistence type ' + storage_type + '; falling back to cookie');
29599 storage_type = config['persistence'] = 'cookie';
29600 }
29601
29602 if (storage_type === 'localStorage' && _.localStorage.is_supported()) {
29603 this.storage = _.localStorage;
29604 } else {
29605 this.storage = _.cookie;
29606 }
29607
29608 this.load();
29609 this.update_config(config);
29610 this.upgrade();
29611 this.save();
29612 };
29613
29614 MixpanelPersistence.prototype.properties = function() {
29615 var p = {};
29616
29617 this.load();
29618
29619 // Filter out reserved properties
29620 _.each(this['props'], function(v, k) {
29621 if (!_.include(RESERVED_PROPERTIES, k)) {
29622 p[k] = v;
29623 }
29624 });
29625 return p;
29626 };
29627
29628 MixpanelPersistence.prototype.load = function() {
29629 if (this.disabled) { return; }
29630
29631 var entry = this.storage.parse(this.name);
29632
29633 if (entry) {
29634 this['props'] = _.extend({}, entry);
29635 }
29636 };
29637
29638 MixpanelPersistence.prototype.upgrade = function() {
29639 var old_cookie,
29640 old_localstorage;
29641
29642 // if transferring from cookie to localStorage or vice-versa, copy existing
29643 // super properties over to new storage mode
29644 if (this.storage === _.localStorage) {
29645 old_cookie = _.cookie.parse(this.name);
29646
29647 _.cookie.remove(this.name);
29648 _.cookie.remove(this.name, true);
29649
29650 if (old_cookie) {
29651 this.register_once(old_cookie);
29652 }
29653 } else if (this.storage === _.cookie) {
29654 old_localstorage = _.localStorage.parse(this.name);
29655
29656 _.localStorage.remove(this.name);
29657
29658 if (old_localstorage) {
29659 this.register_once(old_localstorage);
29660 }
29661 }
29662 };
29663
29664 MixpanelPersistence.prototype.save = function() {
29665 if (this.disabled) { return; }
29666
29667 this.storage.set(
29668 this.name,
29669 JSONStringify(this['props']),
29670 this.expire_days,
29671 this.cross_subdomain,
29672 this.secure,
29673 this.cross_site,
29674 this.cookie_domain
29675 );
29676 };
29677
29678 MixpanelPersistence.prototype.load_prop = function(key) {
29679 this.load();
29680 return this['props'][key];
29681 };
29682
29683 MixpanelPersistence.prototype.remove = function() {
29684 // remove both domain and subdomain cookies
29685 this.storage.remove(this.name, false, this.cookie_domain);
29686 this.storage.remove(this.name, true, this.cookie_domain);
29687 };
29688
29689 // removes the storage entry and deletes all loaded data
29690 // forced name for tests
29691 MixpanelPersistence.prototype.clear = function() {
29692 this.remove();
29693 this['props'] = {};
29694 };
29695
29696 /**
29697 * @param {Object} props
29698 * @param {*=} default_value
29699 * @param {number=} days
29700 */
29701 MixpanelPersistence.prototype.register_once = function(props, default_value, days) {
29702 if (_.isObject(props)) {
29703 if (typeof(default_value) === 'undefined') { default_value = 'None'; }
29704 this.expire_days = (typeof(days) === 'undefined') ? this.default_expiry : days;
29705
29706 this.load();
29707
29708 _.each(props, function(val, prop) {
29709 if (!this['props'].hasOwnProperty(prop) || this['props'][prop] === default_value) {
29710 this['props'][prop] = val;
29711 }
29712 }, this);
29713
29714 this.save();
29715
29716 return true;
29717 }
29718 return false;
29719 };
29720
29721 /**
29722 * @param {Object} props
29723 * @param {number=} days
29724 */
29725 MixpanelPersistence.prototype.register = function(props, days) {
29726 if (_.isObject(props)) {
29727 this.expire_days = (typeof(days) === 'undefined') ? this.default_expiry : days;
29728
29729 this.load();
29730 _.extend(this['props'], props);
29731 this.save();
29732
29733 return true;
29734 }
29735 return false;
29736 };
29737
29738 MixpanelPersistence.prototype.unregister = function(prop) {
29739 this.load();
29740 if (prop in this['props']) {
29741 delete this['props'][prop];
29742 this.save();
29743 }
29744 };
29745
29746 MixpanelPersistence.prototype.update_search_keyword = function(referrer) {
29747 this.register(_.info.searchInfo(referrer));
29748 };
29749
29750 // EXPORTED METHOD, we test this directly.
29751 MixpanelPersistence.prototype.update_referrer_info = function(referrer) {
29752 // If referrer doesn't exist, we want to note the fact that it was type-in traffic.
29753 this.register_once({
29754 '$initial_referrer': referrer || '$direct',
29755 '$initial_referring_domain': _.info.referringDomain(referrer) || '$direct'
29756 }, '');
29757 };
29758
29759 MixpanelPersistence.prototype.get_referrer_info = function() {
29760 return _.strip_empty_properties({
29761 '$initial_referrer': this['props']['$initial_referrer'],
29762 '$initial_referring_domain': this['props']['$initial_referring_domain']
29763 });
29764 };
29765
29766 MixpanelPersistence.prototype.update_config = function(config) {
29767 this.default_expiry = this.expire_days = config['cookie_expiration'];
29768 this.set_disabled(config['disable_persistence']);
29769 this.set_cookie_domain(config['cookie_domain']);
29770 this.set_cross_site(config['cross_site_cookie']);
29771 this.set_cross_subdomain(config['cross_subdomain_cookie']);
29772 this.set_secure(config['secure_cookie']);
29773 };
29774
29775 MixpanelPersistence.prototype.set_disabled = function(disabled) {
29776 this.disabled = disabled;
29777 if (this.disabled) {
29778 this.remove();
29779 } else {
29780 this.save();
29781 }
29782 };
29783
29784 MixpanelPersistence.prototype.set_cookie_domain = function(cookie_domain) {
29785 if (cookie_domain !== this.cookie_domain) {
29786 this.remove();
29787 this.cookie_domain = cookie_domain;
29788 this.save();
29789 }
29790 };
29791
29792 MixpanelPersistence.prototype.set_cross_site = function(cross_site) {
29793 if (cross_site !== this.cross_site) {
29794 this.cross_site = cross_site;
29795 this.remove();
29796 this.save();
29797 }
29798 };
29799
29800 MixpanelPersistence.prototype.set_cross_subdomain = function(cross_subdomain) {
29801 if (cross_subdomain !== this.cross_subdomain) {
29802 this.cross_subdomain = cross_subdomain;
29803 this.remove();
29804 this.save();
29805 }
29806 };
29807
29808 MixpanelPersistence.prototype.get_cross_subdomain = function() {
29809 return this.cross_subdomain;
29810 };
29811
29812 MixpanelPersistence.prototype.set_secure = function(secure) {
29813 if (secure !== this.secure) {
29814 this.secure = secure ? true : false;
29815 this.remove();
29816 this.save();
29817 }
29818 };
29819
29820 MixpanelPersistence.prototype._add_to_people_queue = function(queue, data) {
29821 var q_key = this._get_queue_key(queue),
29822 q_data = data[queue],
29823 set_q = this._get_or_create_queue(SET_ACTION),
29824 set_once_q = this._get_or_create_queue(SET_ONCE_ACTION),
29825 unset_q = this._get_or_create_queue(UNSET_ACTION),
29826 add_q = this._get_or_create_queue(ADD_ACTION),
29827 union_q = this._get_or_create_queue(UNION_ACTION),
29828 remove_q = this._get_or_create_queue(REMOVE_ACTION, []),
29829 append_q = this._get_or_create_queue(APPEND_ACTION, []);
29830
29831 if (q_key === SET_QUEUE_KEY) {
29832 // Update the set queue - we can override any existing values
29833 _.extend(set_q, q_data);
29834 // if there was a pending increment, override it
29835 // with the set.
29836 this._pop_from_people_queue(ADD_ACTION, q_data);
29837 // if there was a pending union, override it
29838 // with the set.
29839 this._pop_from_people_queue(UNION_ACTION, q_data);
29840 this._pop_from_people_queue(UNSET_ACTION, q_data);
29841 } else if (q_key === SET_ONCE_QUEUE_KEY) {
29842 // only queue the data if there is not already a set_once call for it.
29843 _.each(q_data, function(v, k) {
29844 if (!(k in set_once_q)) {
29845 set_once_q[k] = v;
29846 }
29847 });
29848 this._pop_from_people_queue(UNSET_ACTION, q_data);
29849 } else if (q_key === UNSET_QUEUE_KEY) {
29850 _.each(q_data, function(prop) {
29851
29852 // undo previously-queued actions on this key
29853 _.each([set_q, set_once_q, add_q, union_q], function(enqueued_obj) {
29854 if (prop in enqueued_obj) {
29855 delete enqueued_obj[prop];
29856 }
29857 });
29858 _.each(append_q, function(append_obj) {
29859 if (prop in append_obj) {
29860 delete append_obj[prop];
29861 }
29862 });
29863
29864 unset_q[prop] = true;
29865
29866 });
29867 } else if (q_key === ADD_QUEUE_KEY) {
29868 _.each(q_data, function(v, k) {
29869 // If it exists in the set queue, increment
29870 // the value
29871 if (k in set_q) {
29872 set_q[k] += v;
29873 } else {
29874 // If it doesn't exist, update the add
29875 // queue
29876 if (!(k in add_q)) {
29877 add_q[k] = 0;
29878 }
29879 add_q[k] += v;
29880 }
29881 }, this);
29882 this._pop_from_people_queue(UNSET_ACTION, q_data);
29883 } else if (q_key === UNION_QUEUE_KEY) {
29884 _.each(q_data, function(v, k) {
29885 if (_.isArray(v)) {
29886 if (!(k in union_q)) {
29887 union_q[k] = [];
29888 }
29889 // Prevent duplicate values
29890 _.each(v, function(item) {
29891 if (!_.include(union_q[k], item)) {
29892 union_q[k].push(item);
29893 }
29894 });
29895 }
29896 });
29897 this._pop_from_people_queue(UNSET_ACTION, q_data);
29898 } else if (q_key === REMOVE_QUEUE_KEY) {
29899 remove_q.push(q_data);
29900 this._pop_from_people_queue(APPEND_ACTION, q_data);
29901 } else if (q_key === APPEND_QUEUE_KEY) {
29902 append_q.push(q_data);
29903 this._pop_from_people_queue(UNSET_ACTION, q_data);
29904 }
29905
29906 console$1.log('MIXPANEL PEOPLE REQUEST (QUEUED, PENDING IDENTIFY):');
29907 console$1.log(data);
29908
29909 this.save();
29910 };
29911
29912 MixpanelPersistence.prototype._pop_from_people_queue = function(queue, data) {
29913 var q = this['props'][this._get_queue_key(queue)];
29914 if (!_.isUndefined(q)) {
29915 _.each(data, function(v, k) {
29916 if (queue === APPEND_ACTION || queue === REMOVE_ACTION) {
29917 // list actions: only remove if both k+v match
29918 // e.g. remove should not override append in a case like
29919 // append({foo: 'bar'}); remove({foo: 'qux'})
29920 _.each(q, function(queued_action) {
29921 if (queued_action[k] === v) {
29922 delete queued_action[k];
29923 }
29924 });
29925 } else {
29926 delete q[k];
29927 }
29928 }, this);
29929 }
29930 };
29931
29932 MixpanelPersistence.prototype.load_queue = function(queue) {
29933 return this.load_prop(this._get_queue_key(queue));
29934 };
29935
29936 MixpanelPersistence.prototype._get_queue_key = function(queue) {
29937 if (queue === SET_ACTION) {
29938 return SET_QUEUE_KEY;
29939 } else if (queue === SET_ONCE_ACTION) {
29940 return SET_ONCE_QUEUE_KEY;
29941 } else if (queue === UNSET_ACTION) {
29942 return UNSET_QUEUE_KEY;
29943 } else if (queue === ADD_ACTION) {
29944 return ADD_QUEUE_KEY;
29945 } else if (queue === APPEND_ACTION) {
29946 return APPEND_QUEUE_KEY;
29947 } else if (queue === REMOVE_ACTION) {
29948 return REMOVE_QUEUE_KEY;
29949 } else if (queue === UNION_ACTION) {
29950 return UNION_QUEUE_KEY;
29951 } else {
29952 console$1.error('Invalid queue:', queue);
29953 }
29954 };
29955
29956 MixpanelPersistence.prototype._get_or_create_queue = function(queue, default_val) {
29957 var key = this._get_queue_key(queue);
29958 default_val = _.isUndefined(default_val) ? {} : default_val;
29959 return this['props'][key] || (this['props'][key] = default_val);
29960 };
29961
29962 MixpanelPersistence.prototype.set_event_timer = function(event_name, timestamp) {
29963 var timers = this.load_prop(EVENT_TIMERS_KEY) || {};
29964 timers[event_name] = timestamp;
29965 this['props'][EVENT_TIMERS_KEY] = timers;
29966 this.save();
29967 };
29968
29969 MixpanelPersistence.prototype.remove_event_timer = function(event_name) {
29970 var timers = this.load_prop(EVENT_TIMERS_KEY) || {};
29971 var timestamp = timers[event_name];
29972 if (!_.isUndefined(timestamp)) {
29973 delete this['props'][EVENT_TIMERS_KEY][event_name];
29974 this.save();
29975 }
29976 return timestamp;
29977 };
29978
29979 /* eslint camelcase: "off" */
29980
29981 /*
29982 * Mixpanel JS Library
29983 *
29984 * Copyright 2012, Mixpanel, Inc. All Rights Reserved
29985 * http://mixpanel.com/
29986 *
29987 * Includes portions of Underscore.js
29988 * http://documentcloud.github.com/underscore/
29989 * (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.
29990 * Released under the MIT License.
29991 */
29992
29993 /*
29994 SIMPLE STYLE GUIDE:
29995
29996 this.x === public function
29997 this._x === internal - only use within this file
29998 this.__x === private - only use within the class
29999
30000 Globals should be all caps
30001 */
30002
30003 var init_type; // MODULE or SNIPPET loader
30004 // allow bundlers to specify how extra code (recorder bundle) should be loaded
30005 // eslint-disable-next-line no-unused-vars
30006 var load_extra_bundle = function(src, _onload) {
30007 throw new Error(src + ' not available in this build.');
30008 };
30009
30010 var mixpanel_master; // main mixpanel instance / object
30011 var INIT_MODULE = 0;
30012 var INIT_SNIPPET = 1;
30013
30014 var IDENTITY_FUNC = function(x) {return x;};
30015
30016 /** @const */ var PRIMARY_INSTANCE_NAME = 'mixpanel';
30017 /** @const */ var PAYLOAD_TYPE_BASE64 = 'base64';
30018 /** @const */ var PAYLOAD_TYPE_JSON = 'json';
30019 /** @const */ var DEVICE_ID_PREFIX = '$device:';
30020
30021
30022 /*
30023 * Dynamic... constants? Is that an oxymoron?
30024 */
30025 // http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/
30026 // https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#withCredentials
30027 var USE_XHR = (win.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest());
30028
30029 // IE<10 does not support cross-origin XHR's but script tags
30030 // with defer won't block window.onload; ENQUEUE_REQUESTS
30031 // should only be true for Opera<12
30032 var ENQUEUE_REQUESTS = !USE_XHR && (userAgent.indexOf('MSIE') === -1) && (userAgent.indexOf('Mozilla') === -1);
30033
30034 // save reference to navigator.sendBeacon so it can be minified
30035 var sendBeacon = null;
30036 if (navigator['sendBeacon']) {
30037 sendBeacon = function() {
30038 // late reference to navigator.sendBeacon to allow patching/spying
30039 return navigator['sendBeacon'].apply(navigator, arguments);
30040 };
30041 }
30042
30043 var DEFAULT_API_ROUTES = {
30044 'track': 'track/',
30045 'engage': 'engage/',
30046 'groups': 'groups/',
30047 'record': 'record/',
30048 'flags': 'flags/'
30049 };
30050
30051 /*
30052 * Module-level globals
30053 */
30054 var DEFAULT_CONFIG = {
30055 'api_host': 'https://api-js.mixpanel.com',
30056 'api_hosts': {},
30057 'api_routes': DEFAULT_API_ROUTES,
30058 'api_extra_query_params': {},
30059 'api_method': 'POST',
30060 'api_transport': 'XHR',
30061 'api_payload_format': PAYLOAD_TYPE_BASE64,
30062 'app_host': 'https://mixpanel.com',
30063 'autocapture': false,
30064 'cdn': 'https://cdn.mxpnl.com',
30065 'cross_site_cookie': false,
30066 'cross_subdomain_cookie': true,
30067 'error_reporter': NOOP_FUNC,
30068 'flags': false,
30069 'persistence': 'cookie',
30070 'persistence_name': '',
30071 'cookie_domain': '',
30072 'cookie_name': '',
30073 'loaded': NOOP_FUNC,
30074 'mp_loader': null,
30075 'track_marketing': true,
30076 'track_pageview': false,
30077 'skip_first_touch_marketing': false,
30078 'store_google': true,
30079 'stop_utm_persistence': false,
30080 'save_referrer': true,
30081 'test': false,
30082 'verbose': false,
30083 'img': false,
30084 'debug': false,
30085 'track_links_timeout': 300,
30086 'cookie_expiration': 365,
30087 'upgrade': false,
30088 'disable_persistence': false,
30089 'disable_cookie': false,
30090 'secure_cookie': false,
30091 'ip': true,
30092 'opt_out_tracking_by_default': false,
30093 'opt_out_persistence_by_default': false,
30094 'opt_out_tracking_persistence_type': 'localStorage',
30095 'opt_out_tracking_cookie_prefix': null,
30096 'property_blacklist': [],
30097 'xhr_headers': {}, // { header: value, header2: value }
30098 'ignore_dnt': false,
30099 'batch_requests': true,
30100 'batch_size': 50,
30101 'batch_flush_interval_ms': 5000,
30102 'batch_request_timeout_ms': 90000,
30103 'batch_autostart': true,
30104 'hooks': {},
30105 'record_block_class': new RegExp('^(mp-block|fs-exclude|amp-block|rr-block|ph-no-capture)$'),
30106 'record_block_selector': 'img, video, audio',
30107 'record_canvas': false,
30108 'record_collect_fonts': false,
30109 'record_heatmap_data': false,
30110 'record_idle_timeout_ms': 30 * 60 * 1000, // 30 minutes
30111 'record_mask_text_class': new RegExp('^(mp-mask|fs-mask|amp-mask|rr-mask|ph-mask)$'),
30112 'record_mask_text_selector': '*',
30113 'record_max_ms': MAX_RECORDING_MS,
30114 'record_min_ms': 0,
30115 'record_sessions_percent': 0,
30116 'recorder_src': 'https://cdn.mxpnl.com/libs/mixpanel-recorder.min.js'
30117 };
30118
30119 var DOM_LOADED = false;
30120
30121 /**
30122 * Mixpanel Library Object
30123 * @constructor
30124 */
30125 var MixpanelLib = function() {};
30126
30127
30128 /**
30129 * create_mplib(token:string, config:object, name:string)
30130 *
30131 * This function is used by the init method of MixpanelLib objects
30132 * as well as the main initializer at the end of the JSLib (that
30133 * initializes document.mixpanel as well as any additional instances
30134 * declared before this file has loaded).
30135 */
30136 var create_mplib = function(token, config, name) {
30137 var instance,
30138 target = (name === PRIMARY_INSTANCE_NAME) ? mixpanel_master : mixpanel_master[name];
30139
30140 if (target && init_type === INIT_MODULE) {
30141 instance = target;
30142 } else {
30143 if (target && !_.isArray(target)) {
30144 console$1.error('You have already initialized ' + name);
30145 return;
30146 }
30147 instance = new MixpanelLib();
30148 }
30149
30150 instance._cached_groups = {}; // cache groups in a pool
30151
30152 instance._init(token, config, name);
30153
30154 instance['people'] = new MixpanelPeople();
30155 instance['people']._init(instance);
30156
30157 if (!instance.get_config('skip_first_touch_marketing')) {
30158 // We need null UTM params in the object because
30159 // UTM parameters act as a tuple. If any UTM param
30160 // is present, then we set all UTM params including
30161 // empty ones together
30162 var utm_params = _.info.campaignParams(null);
30163 var initial_utm_params = {};
30164 var has_utm = false;
30165 _.each(utm_params, function(utm_value, utm_key) {
30166 initial_utm_params['initial_' + utm_key] = utm_value;
30167 if (utm_value) {
30168 has_utm = true;
30169 }
30170 });
30171 if (has_utm) {
30172 instance['people'].set_once(initial_utm_params);
30173 }
30174 }
30175
30176 // if any instance on the page has debug = true, we set the
30177 // global debug to be true
30178 Config.DEBUG = Config.DEBUG || instance.get_config('debug');
30179
30180 // if target is not defined, we called init after the lib already
30181 // loaded, so there won't be an array of things to execute
30182 if (!_.isUndefined(target) && _.isArray(target)) {
30183 // Crunch through the people queue first - we queue this data up &
30184 // flush on identify, so it's better to do all these operations first
30185 instance._execute_array.call(instance['people'], target['people']);
30186 instance._execute_array(target);
30187 }
30188
30189 return instance;
30190 };
30191
30192 // Initialization methods
30193
30194 /**
30195 * This function initializes a new instance of the Mixpanel tracking object.
30196 * All new instances are added to the main mixpanel object as sub properties (such as
30197 * mixpanel.library_name) and also returned by this function. To define a
30198 * second instance on the page, you would call:
30199 *
30200 * mixpanel.init('new token', { your: 'config' }, 'library_name');
30201 *
30202 * and use it like so:
30203 *
30204 * mixpanel.library_name.track(...);
30205 *
30206 * @param {String} token Your Mixpanel API token
30207 * @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>.
30208 * @param {String} [name] The name for the new mixpanel instance that you want created
30209 */
30210 MixpanelLib.prototype.init = function (token, config, name) {
30211 if (_.isUndefined(name)) {
30212 this.report_error('You must name your new library: init(token, config, name)');
30213 return;
30214 }
30215 if (name === PRIMARY_INSTANCE_NAME) {
30216 this.report_error('You must initialize the main mixpanel object right after you include the Mixpanel js snippet');
30217 return;
30218 }
30219
30220 var instance = create_mplib(token, config, name);
30221 mixpanel_master[name] = instance;
30222 instance._loaded();
30223
30224 return instance;
30225 };
30226
30227 // mixpanel._init(token:string, config:object, name:string)
30228 //
30229 // This function sets up the current instance of the mixpanel
30230 // library. The difference between this method and the init(...)
30231 // method is this one initializes the actual instance, whereas the
30232 // init(...) method sets up a new library and calls _init on it.
30233 //
30234 MixpanelLib.prototype._init = function(token, config, name) {
30235 config = config || {};
30236
30237 this['__loaded'] = true;
30238 this['config'] = {};
30239
30240 var variable_features = {};
30241
30242 // default to JSON payload for standard mixpanel.com API hosts
30243 if (!('api_payload_format' in config)) {
30244 var api_host = config['api_host'] || DEFAULT_CONFIG['api_host'];
30245 if (api_host.match(/\.mixpanel\.com/)) {
30246 variable_features['api_payload_format'] = PAYLOAD_TYPE_JSON;
30247 }
30248 }
30249
30250 this.set_config(_.extend({}, DEFAULT_CONFIG, variable_features, config, {
30251 'name': name,
30252 'token': token,
30253 'callback_fn': ((name === PRIMARY_INSTANCE_NAME) ? name : PRIMARY_INSTANCE_NAME + '.' + name) + '._jsc'
30254 }));
30255
30256 this['_jsc'] = NOOP_FUNC;
30257
30258 this.__dom_loaded_queue = [];
30259 this.__request_queue = [];
30260 this.__disabled_events = [];
30261 this._flags = {
30262 'disable_all_events': false,
30263 'identify_called': false
30264 };
30265
30266 // set up request queueing/batching
30267 this.request_batchers = {};
30268 this._batch_requests = this.get_config('batch_requests');
30269 if (this._batch_requests) {
30270 if (!_.localStorage.is_supported(true) || !USE_XHR) {
30271 this._batch_requests = false;
30272 console$1.log('Turning off Mixpanel request-queueing; needs XHR and localStorage support');
30273 _.each(this.get_batcher_configs(), function(batcher_config) {
30274 console$1.log('Clearing batch queue ' + batcher_config.queue_key);
30275 _.localStorage.remove(batcher_config.queue_key);
30276 });
30277 } else {
30278 this.init_batchers();
30279 if (sendBeacon && win.addEventListener) {
30280 // Before page closes or hides (user tabs away etc), attempt to flush any events
30281 // queued up via navigator.sendBeacon. Since sendBeacon doesn't report success/failure,
30282 // events will not be removed from the persistent store; if the site is loaded again,
30283 // the events will be flushed again on startup and deduplicated on the Mixpanel server
30284 // side.
30285 // There is no reliable way to capture only page close events, so we lean on the
30286 // visibilitychange and pagehide events as recommended at
30287 // https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event#usage_notes.
30288 // These events fire when the user clicks away from the current page/tab, so will occur
30289 // more frequently than page unload, but are the only mechanism currently for capturing
30290 // this scenario somewhat reliably.
30291 var flush_on_unload = _.bind(function() {
30292 if (!this.request_batchers.events.stopped) {
30293 this.request_batchers.events.flush({unloading: true});
30294 }
30295 }, this);
30296 win.addEventListener('pagehide', function(ev) {
30297 if (ev['persisted']) {
30298 flush_on_unload();
30299 }
30300 });
30301 win.addEventListener('visibilitychange', function() {
30302 if (document$1['visibilityState'] === 'hidden') {
30303 flush_on_unload();
30304 }
30305 });
30306 }
30307 }
30308 }
30309
30310 this['persistence'] = this['cookie'] = new MixpanelPersistence(this['config']);
30311 this.unpersisted_superprops = {};
30312 this._gdpr_init();
30313
30314 var uuid = _.UUID();
30315 if (!this.get_distinct_id()) {
30316 // There is no need to set the distinct id
30317 // or the device id if something was already stored
30318 // in the persitence
30319 this.register_once({
30320 'distinct_id': DEVICE_ID_PREFIX + uuid,
30321 '$device_id': uuid
30322 }, '');
30323 }
30324
30325 this.flags = new FeatureFlagManager({
30326 getFullApiRoute: _.bind(function() {
30327 return this.get_api_host('flags') + '/' + this.get_config('api_routes')['flags'];
30328 }, this),
30329 getConfigFunc: _.bind(this.get_config, this),
30330 setConfigFunc: _.bind(this.set_config, this),
30331 getPropertyFunc: _.bind(this.get_property, this),
30332 trackingFunc: _.bind(this.track, this)
30333 });
30334 this.flags.init();
30335 this['flags'] = this.flags;
30336
30337 this.autocapture = new Autocapture(this);
30338 this.autocapture.init();
30339
30340 this._init_tab_id();
30341 this._check_and_start_session_recording();
30342 };
30343
30344 /**
30345 * Assigns a unique UUID to this tab / window by leveraging sessionStorage.
30346 * This is primarily used for session recording, where data must be isolated to the current tab.
30347 */
30348 MixpanelLib.prototype._init_tab_id = function() {
30349 if (this.get_config('disable_persistence')) {
30350 console$1.log('Tab ID initialization skipped due to disable_persistence config');
30351 } else if (_.sessionStorage.is_supported()) {
30352 try {
30353 var key_suffix = this.get_config('name') + '_' + this.get_config('token');
30354 var tab_id_key = 'mp_tab_id_' + key_suffix;
30355
30356 // A flag is used to determine if sessionStorage is copied over and we need to generate a new tab ID.
30357 // This enforces a unique ID in the cases like duplicated tab, window.open(...)
30358 var should_generate_new_tab_id_key = 'mp_gen_new_tab_id_' + key_suffix;
30359 if (_.sessionStorage.get(should_generate_new_tab_id_key) || !_.sessionStorage.get(tab_id_key)) {
30360 _.sessionStorage.set(tab_id_key, '$tab-' + _.UUID());
30361 }
30362
30363 _.sessionStorage.set(should_generate_new_tab_id_key, '1');
30364 this.tab_id = _.sessionStorage.get(tab_id_key);
30365
30366 // 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,
30367 // but reliable in cases where the user remains in the tab e.g. a refresh or href navigation.
30368 // If the flag is absent, this indicates to the next SDK instance that we can reuse the stored tab_id.
30369 win.addEventListener('beforeunload', function () {
30370 _.sessionStorage.remove(should_generate_new_tab_id_key);
30371 });
30372 } catch(err) {
30373 this.report_error('Error initializing tab id', err);
30374 }
30375 } else {
30376 this.report_error('Session storage is not supported, cannot keep track of unique tab ID.');
30377 }
30378 };
30379
30380 MixpanelLib.prototype.get_tab_id = function () {
30381 return this.tab_id || null;
30382 };
30383
30384 MixpanelLib.prototype._should_load_recorder = function () {
30385 if (this.get_config('disable_persistence')) {
30386 console$1.log('Load recorder check skipped due to disable_persistence config');
30387 return Promise.resolve(false);
30388 }
30389
30390 var recording_registry_idb = new IDBStorageWrapper(RECORDING_REGISTRY_STORE_NAME);
30391 var tab_id = this.get_tab_id();
30392 return recording_registry_idb.init()
30393 .then(function () {
30394 return recording_registry_idb.getAll();
30395 })
30396 .then(function (recordings) {
30397 for (var i = 0; i < recordings.length; i++) {
30398 // if there are expired recordings in the registry, we should load the recorder to flush them
30399 // if there's a recording for this tab id, we should load the recorder to continue the recording
30400 if (isRecordingExpired(recordings[i]) || recordings[i]['tabId'] === tab_id) {
30401 return true;
30402 }
30403 }
30404 return false;
30405 })
30406 .catch(_.bind(function (err) {
30407 this.report_error('Error checking recording registry', err);
30408 }, this));
30409 };
30410
30411 MixpanelLib.prototype._check_and_start_session_recording = addOptOutCheckMixpanelLib(function(force_start) {
30412 if (!win['MutationObserver']) {
30413 console$1.critical('Browser does not support MutationObserver; skipping session recording');
30414 return;
30415 }
30416
30417 var loadRecorder = _.bind(function(startNewIfInactive) {
30418 var handleLoadedRecorder = _.bind(function() {
30419 this._recorder = this._recorder || new win['__mp_recorder'](this);
30420 this._recorder['resumeRecording'](startNewIfInactive);
30421 }, this);
30422
30423 if (_.isUndefined(win['__mp_recorder'])) {
30424 load_extra_bundle(this.get_config('recorder_src'), handleLoadedRecorder);
30425 } else {
30426 handleLoadedRecorder();
30427 }
30428 }, this);
30429
30430 /**
30431 * If the user is sampled or start_session_recording is called, we always load the recorder since it's guaranteed a recording should start.
30432 * 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.
30433 */
30434 var is_sampled = this.get_config('record_sessions_percent') > 0 && Math.random() * 100 <= this.get_config('record_sessions_percent');
30435 if (force_start || is_sampled) {
30436 loadRecorder(true);
30437 } else {
30438 this._should_load_recorder()
30439 .then(function (shouldLoad) {
30440 if (shouldLoad) {
30441 loadRecorder(false);
30442 }
30443 });
30444 }
30445 });
30446
30447 MixpanelLib.prototype.start_session_recording = function () {
30448 this._check_and_start_session_recording(true);
30449 };
30450
30451 MixpanelLib.prototype.stop_session_recording = function () {
30452 if (this._recorder) {
30453 return this._recorder['stopRecording']();
30454 }
30455 return Promise.resolve();
30456 };
30457
30458 MixpanelLib.prototype.pause_session_recording = function () {
30459 if (this._recorder) {
30460 return this._recorder['pauseRecording']();
30461 }
30462 return Promise.resolve();
30463 };
30464
30465 MixpanelLib.prototype.resume_session_recording = function () {
30466 if (this._recorder) {
30467 return this._recorder['resumeRecording']();
30468 }
30469 return Promise.resolve();
30470 };
30471
30472 MixpanelLib.prototype.is_recording_heatmap_data = function () {
30473 return this._get_session_replay_id() && this.get_config('record_heatmap_data');
30474 };
30475
30476 MixpanelLib.prototype.get_session_recording_properties = function () {
30477 var props = {};
30478 var replay_id = this._get_session_replay_id();
30479 if (replay_id) {
30480 props['$mp_replay_id'] = replay_id;
30481 }
30482 return props;
30483 };
30484
30485 MixpanelLib.prototype.get_session_replay_url = function () {
30486 var replay_url = null;
30487 var replay_id = this._get_session_replay_id();
30488 if (replay_id) {
30489 var query_params = _.HTTPBuildQuery({
30490 'replay_id': replay_id,
30491 'distinct_id': this.get_distinct_id(),
30492 'token': this.get_config('token')
30493 });
30494 replay_url = 'https://mixpanel.com/projects/replay-redirect?' + query_params;
30495 }
30496 return replay_url;
30497 };
30498
30499 MixpanelLib.prototype._get_session_replay_id = function () {
30500 var replay_id = null;
30501 if (this._recorder) {
30502 replay_id = this._recorder['replayId'];
30503 }
30504 return replay_id || null;
30505 };
30506
30507 // "private" public method to reach into the recorder in test cases
30508 MixpanelLib.prototype.__get_recorder = function () {
30509 return this._recorder;
30510 };
30511
30512 // Private methods
30513
30514 MixpanelLib.prototype._loaded = function() {
30515 this.get_config('loaded')(this);
30516 this._set_default_superprops();
30517 this['people'].set_once(this['persistence'].get_referrer_info());
30518
30519 // `store_google` is now deprecated and previously stored UTM parameters are cleared
30520 // from persistence by default.
30521 if (this.get_config('store_google') && this.get_config('stop_utm_persistence')) {
30522 var utm_params = _.info.campaignParams(null);
30523 _.each(utm_params, function(_utm_value, utm_key) {
30524 // We need to unregister persisted UTM parameters so old values
30525 // are not mixed with the new UTM parameters
30526 this.unregister(utm_key);
30527 }.bind(this));
30528 }
30529 };
30530
30531 // update persistence with info on referrer, UTM params, etc
30532 MixpanelLib.prototype._set_default_superprops = function() {
30533 this['persistence'].update_search_keyword(document$1.referrer);
30534 // Registering super properties for UTM persistence by 'store_google' is deprecated.
30535 if (this.get_config('store_google') && !this.get_config('stop_utm_persistence')) {
30536 this.register(_.info.campaignParams());
30537 }
30538 if (this.get_config('save_referrer')) {
30539 this['persistence'].update_referrer_info(document$1.referrer);
30540 }
30541 };
30542
30543 MixpanelLib.prototype._dom_loaded = function() {
30544 _.each(this.__dom_loaded_queue, function(item) {
30545 this._track_dom.apply(this, item);
30546 }, this);
30547
30548 if (!this.has_opted_out_tracking()) {
30549 _.each(this.__request_queue, function(item) {
30550 this._send_request.apply(this, item);
30551 }, this);
30552 }
30553
30554 delete this.__dom_loaded_queue;
30555 delete this.__request_queue;
30556 };
30557
30558 MixpanelLib.prototype._track_dom = function(DomClass, args) {
30559 if (this.get_config('img')) {
30560 this.report_error('You can\'t use DOM tracking functions with img = true.');
30561 return false;
30562 }
30563
30564 if (!DOM_LOADED) {
30565 this.__dom_loaded_queue.push([DomClass, args]);
30566 return false;
30567 }
30568
30569 var dt = new DomClass().init(this);
30570 return dt.track.apply(dt, args);
30571 };
30572
30573 /**
30574 * _prepare_callback() should be called by callers of _send_request for use
30575 * as the callback argument.
30576 *
30577 * If there is no callback, this returns null.
30578 * If we are going to make XHR/XDR requests, this returns a function.
30579 * If we are going to use script tags, this returns a string to use as the
30580 * callback GET param.
30581 */
30582 MixpanelLib.prototype._prepare_callback = function(callback, data) {
30583 if (_.isUndefined(callback)) {
30584 return null;
30585 }
30586
30587 if (USE_XHR) {
30588 var callback_function = function(response) {
30589 callback(response, data);
30590 };
30591 return callback_function;
30592 } else {
30593 // if the user gives us a callback, we store as a random
30594 // property on this instances jsc function and update our
30595 // callback string to reflect that.
30596 var jsc = this['_jsc'];
30597 var randomized_cb = '' + Math.floor(Math.random() * 100000000);
30598 var callback_string = this.get_config('callback_fn') + '[' + randomized_cb + ']';
30599 jsc[randomized_cb] = function(response) {
30600 delete jsc[randomized_cb];
30601 callback(response, data);
30602 };
30603 return callback_string;
30604 }
30605 };
30606
30607 MixpanelLib.prototype._send_request = function(url, data, options, callback) {
30608 var succeeded = true;
30609
30610 if (ENQUEUE_REQUESTS) {
30611 this.__request_queue.push(arguments);
30612 return succeeded;
30613 }
30614
30615 var DEFAULT_OPTIONS = {
30616 method: this.get_config('api_method'),
30617 transport: this.get_config('api_transport'),
30618 verbose: this.get_config('verbose')
30619 };
30620 var body_data = null;
30621
30622 if (!callback && (_.isFunction(options) || typeof options === 'string')) {
30623 callback = options;
30624 options = null;
30625 }
30626 options = _.extend(DEFAULT_OPTIONS, options || {});
30627 if (!USE_XHR) {
30628 options.method = 'GET';
30629 }
30630 var use_post = options.method === 'POST';
30631 var use_sendBeacon = sendBeacon && use_post && options.transport.toLowerCase() === 'sendbeacon';
30632
30633 // needed to correctly format responses
30634 var verbose_mode = options.verbose;
30635 if (data['verbose']) { verbose_mode = true; }
30636
30637 if (this.get_config('test')) { data['test'] = 1; }
30638 if (verbose_mode) { data['verbose'] = 1; }
30639 if (this.get_config('img')) { data['img'] = 1; }
30640 if (!USE_XHR) {
30641 if (callback) {
30642 data['callback'] = callback;
30643 } else if (verbose_mode || this.get_config('test')) {
30644 // Verbose output (from verbose mode, or an error in test mode) is a json blob,
30645 // which by itself is not valid javascript. Without a callback, this verbose output will
30646 // cause an error when returned via jsonp, so we force a no-op callback param.
30647 // See the ECMA script spec: http://www.ecma-international.org/ecma-262/5.1/#sec-12.4
30648 data['callback'] = '(function(){})';
30649 }
30650 }
30651
30652 data['ip'] = this.get_config('ip')?1:0;
30653 data['_'] = new Date().getTime().toString();
30654
30655 if (use_post) {
30656 body_data = 'data=' + encodeURIComponent(data['data']);
30657 delete data['data'];
30658 }
30659
30660 _.extend(data, this.get_config('api_extra_query_params'));
30661
30662 url += '?' + _.HTTPBuildQuery(data);
30663
30664 var lib = this;
30665 if ('img' in data) {
30666 var img = document$1.createElement('img');
30667 img.src = url;
30668 document$1.body.appendChild(img);
30669 } else if (use_sendBeacon) {
30670 try {
30671 succeeded = sendBeacon(url, body_data);
30672 } catch (e) {
30673 lib.report_error(e);
30674 succeeded = false;
30675 }
30676 try {
30677 if (callback) {
30678 callback(succeeded ? 1 : 0);
30679 }
30680 } catch (e) {
30681 lib.report_error(e);
30682 }
30683 } else if (USE_XHR) {
30684 try {
30685 var req = new XMLHttpRequest();
30686 req.open(options.method, url, true);
30687
30688 var headers = this.get_config('xhr_headers');
30689 if (use_post) {
30690 headers['Content-Type'] = 'application/x-www-form-urlencoded';
30691 }
30692 _.each(headers, function(headerValue, headerName) {
30693 req.setRequestHeader(headerName, headerValue);
30694 });
30695
30696 if (options.timeout_ms && typeof req.timeout !== 'undefined') {
30697 req.timeout = options.timeout_ms;
30698 var start_time = new Date().getTime();
30699 }
30700
30701 // send the mp_optout cookie
30702 // withCredentials cannot be modified until after calling .open on Android and Mobile Safari
30703 req.withCredentials = true;
30704 req.onreadystatechange = function () {
30705 if (req.readyState === 4) { // XMLHttpRequest.DONE == 4, except in safari 4
30706 if (req.status === 200) {
30707 if (callback) {
30708 if (verbose_mode) {
30709 var response;
30710 try {
30711 response = _.JSONDecode(req.responseText);
30712 } catch (e) {
30713 lib.report_error(e);
30714 if (options.ignore_json_errors) {
30715 response = req.responseText;
30716 } else {
30717 return;
30718 }
30719 }
30720 callback(response);
30721 } else {
30722 callback(Number(req.responseText));
30723 }
30724 }
30725 } else {
30726 var error;
30727 if (
30728 req.timeout &&
30729 !req.status &&
30730 new Date().getTime() - start_time >= req.timeout
30731 ) {
30732 error = 'timeout';
30733 } else {
30734 error = 'Bad HTTP status: ' + req.status + ' ' + req.statusText;
30735 }
30736 lib.report_error(error);
30737 if (callback) {
30738 if (verbose_mode) {
30739 var response_headers = req['responseHeaders'] || {};
30740 callback({status: 0, httpStatusCode: req['status'], error: error, retryAfter: response_headers['Retry-After']});
30741 } else {
30742 callback(0);
30743 }
30744 }
30745 }
30746 }
30747 };
30748 req.send(body_data);
30749 } catch (e) {
30750 lib.report_error(e);
30751 succeeded = false;
30752 }
30753 } else {
30754 var script = document$1.createElement('script');
30755 script.type = 'text/javascript';
30756 script.async = true;
30757 script.defer = true;
30758 script.src = url;
30759 var s = document$1.getElementsByTagName('script')[0];
30760 s.parentNode.insertBefore(script, s);
30761 }
30762
30763 return succeeded;
30764 };
30765
30766 /**
30767 * _execute_array() deals with processing any mixpanel function
30768 * calls that were called before the Mixpanel library were loaded
30769 * (and are thus stored in an array so they can be called later)
30770 *
30771 * Note: we fire off all the mixpanel function calls && user defined
30772 * functions BEFORE we fire off mixpanel tracking calls. This is so
30773 * identify/register/set_config calls can properly modify early
30774 * tracking calls.
30775 *
30776 * @param {Array} array
30777 */
30778 MixpanelLib.prototype._execute_array = function(array) {
30779 var fn_name, alias_calls = [], other_calls = [], tracking_calls = [];
30780 _.each(array, function(item) {
30781 if (item) {
30782 fn_name = item[0];
30783 if (_.isArray(fn_name)) {
30784 tracking_calls.push(item); // chained call e.g. mixpanel.get_group().set()
30785 } else if (typeof(item) === 'function') {
30786 item.call(this);
30787 } else if (_.isArray(item) && fn_name === 'alias') {
30788 alias_calls.push(item);
30789 } else if (_.isArray(item) && fn_name.indexOf('track') !== -1 && typeof(this[fn_name]) === 'function') {
30790 tracking_calls.push(item);
30791 } else {
30792 other_calls.push(item);
30793 }
30794 }
30795 }, this);
30796
30797 var execute = function(calls, context) {
30798 _.each(calls, function(item) {
30799 if (_.isArray(item[0])) {
30800 // chained call
30801 var caller = context;
30802 _.each(item, function(call) {
30803 caller = caller[call[0]].apply(caller, call.slice(1));
30804 });
30805 } else {
30806 this[item[0]].apply(this, item.slice(1));
30807 }
30808 }, context);
30809 };
30810
30811 execute(alias_calls, this);
30812 execute(other_calls, this);
30813 execute(tracking_calls, this);
30814 };
30815
30816 // request queueing utils
30817
30818 MixpanelLib.prototype.are_batchers_initialized = function() {
30819 return !!this.request_batchers.events;
30820 };
30821
30822 MixpanelLib.prototype.get_batcher_configs = function() {
30823 var queue_prefix = '__mpq_' + this.get_config('token');
30824 this._batcher_configs = this._batcher_configs || {
30825 events: {type: 'events', api_name: 'track', queue_key: queue_prefix + '_ev'},
30826 people: {type: 'people', api_name: 'engage', queue_key: queue_prefix + '_pp'},
30827 groups: {type: 'groups', api_name: 'groups', queue_key: queue_prefix + '_gr'}
30828 };
30829 return this._batcher_configs;
30830 };
30831
30832 MixpanelLib.prototype.init_batchers = function() {
30833 if (!this.are_batchers_initialized()) {
30834 var batcher_for = _.bind(function(attrs) {
30835 return new RequestBatcher(
30836 attrs.queue_key,
30837 {
30838 libConfig: this['config'],
30839 errorReporter: this.get_config('error_reporter'),
30840 sendRequestFunc: _.bind(function(data, options, cb) {
30841 var api_routes = this.get_config('api_routes');
30842 this._send_request(
30843 this.get_api_host(attrs.api_name) + '/' + api_routes[attrs.api_name],
30844 this._encode_data_for_request(data),
30845 options,
30846 this._prepare_callback(cb, data)
30847 );
30848 }, this),
30849 beforeSendHook: _.bind(function(item) {
30850 return this._run_hook('before_send_' + attrs.type, item);
30851 }, this),
30852 stopAllBatchingFunc: _.bind(this.stop_batch_senders, this),
30853 usePersistence: true,
30854 }
30855 );
30856 }, this);
30857 var batcher_configs = this.get_batcher_configs();
30858 this.request_batchers = {
30859 events: batcher_for(batcher_configs.events),
30860 people: batcher_for(batcher_configs.people),
30861 groups: batcher_for(batcher_configs.groups)
30862 };
30863 }
30864 if (this.get_config('batch_autostart')) {
30865 this.start_batch_senders();
30866 }
30867 };
30868
30869 MixpanelLib.prototype.start_batch_senders = function() {
30870 this._batchers_were_started = true;
30871 if (this.are_batchers_initialized()) {
30872 this._batch_requests = true;
30873 _.each(this.request_batchers, function(batcher) {
30874 batcher.start();
30875 });
30876 }
30877 };
30878
30879 MixpanelLib.prototype.stop_batch_senders = function() {
30880 this._batch_requests = false;
30881 _.each(this.request_batchers, function(batcher) {
30882 batcher.stop();
30883 batcher.clear();
30884 });
30885 };
30886
30887 /**
30888 * push() keeps the standard async-array-push
30889 * behavior around after the lib is loaded.
30890 * This is only useful for external integrations that
30891 * do not wish to rely on our convenience methods
30892 * (created in the snippet).
30893 *
30894 * ### Usage:
30895 * mixpanel.push(['register', { a: 'b' }]);
30896 *
30897 * @param {Array} item A [function_name, args...] array to be executed
30898 */
30899 MixpanelLib.prototype.push = function(item) {
30900 this._execute_array([item]);
30901 };
30902
30903 /**
30904 * Disable events on the Mixpanel object. If passed no arguments,
30905 * this function disables tracking of any event. If passed an
30906 * array of event names, those events will be disabled, but other
30907 * events will continue to be tracked.
30908 *
30909 * Note: this function does not stop other mixpanel functions from
30910 * firing, such as register() or people.set().
30911 *
30912 * @param {Array} [events] An array of event names to disable
30913 */
30914 MixpanelLib.prototype.disable = function(events) {
30915 if (typeof(events) === 'undefined') {
30916 this._flags.disable_all_events = true;
30917 } else {
30918 this.__disabled_events = this.__disabled_events.concat(events);
30919 }
30920 };
30921
30922 MixpanelLib.prototype._encode_data_for_request = function(data) {
30923 var encoded_data = JSONStringify(data);
30924 if (this.get_config('api_payload_format') === PAYLOAD_TYPE_BASE64) {
30925 encoded_data = _.base64Encode(encoded_data);
30926 }
30927 return {'data': encoded_data};
30928 };
30929
30930 // internal method for handling track vs batch-enqueue logic
30931 MixpanelLib.prototype._track_or_batch = function(options, callback) {
30932 var truncated_data = _.truncate(options.data, 255);
30933 var endpoint = options.endpoint;
30934 var batcher = options.batcher;
30935 var should_send_immediately = options.should_send_immediately;
30936 var send_request_options = options.send_request_options || {};
30937 callback = callback || NOOP_FUNC;
30938
30939 var request_enqueued_or_initiated = true;
30940 var send_request_immediately = _.bind(function() {
30941 if (!send_request_options.skip_hooks) {
30942 truncated_data = this._run_hook('before_send_' + options.type, truncated_data);
30943 }
30944 if (truncated_data) {
30945 console$1.log('MIXPANEL REQUEST:');
30946 console$1.log(truncated_data);
30947 return this._send_request(
30948 endpoint,
30949 this._encode_data_for_request(truncated_data),
30950 send_request_options,
30951 this._prepare_callback(callback, truncated_data)
30952 );
30953 } else {
30954 return null;
30955 }
30956 }, this);
30957
30958 if (this._batch_requests && !should_send_immediately) {
30959 batcher.enqueue(truncated_data).then(function(succeeded) {
30960 if (succeeded) {
30961 callback(1, truncated_data);
30962 } else {
30963 send_request_immediately();
30964 }
30965 });
30966 } else {
30967 request_enqueued_or_initiated = send_request_immediately();
30968 }
30969
30970 return request_enqueued_or_initiated && truncated_data;
30971 };
30972
30973 /**
30974 * Track an event. This is the most important and
30975 * frequently used Mixpanel function.
30976 *
30977 * ### Usage:
30978 *
30979 * // track an event named 'Registered'
30980 * mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
30981 *
30982 * // track an event using navigator.sendBeacon
30983 * mixpanel.track('Left page', {'duration_seconds': 35}, {transport: 'sendBeacon'});
30984 *
30985 * To track link clicks or form submissions, see track_links() or track_forms().
30986 *
30987 * @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
30988 * @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.
30989 * @param {Object} [options] Optional configuration for this track request.
30990 * @param {String} [options.transport] Transport method for network request ('xhr' or 'sendBeacon').
30991 * @param {Boolean} [options.send_immediately] Whether to bypass batching/queueing and send track request immediately.
30992 * @param {Function} [callback] If provided, the callback function will be called after tracking the event.
30993 * @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
30994 * with the tracking payload sent to the API server is returned; otherwise false.
30995 */
30996 MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, properties, options, callback) {
30997 if (!callback && typeof options === 'function') {
30998 callback = options;
30999 options = null;
31000 }
31001 options = options || {};
31002 var transport = options['transport']; // external API, don't minify 'transport' prop
31003 if (transport) {
31004 options.transport = transport; // 'transport' prop name can be minified internally
31005 }
31006 var should_send_immediately = options['send_immediately'];
31007 if (typeof callback !== 'function') {
31008 callback = NOOP_FUNC;
31009 }
31010
31011 if (_.isUndefined(event_name)) {
31012 this.report_error('No event name provided to mixpanel.track');
31013 return;
31014 }
31015
31016 if (this._event_is_disabled(event_name)) {
31017 callback(0);
31018 return;
31019 }
31020
31021 // set defaults
31022 properties = _.extend({}, properties);
31023 properties['token'] = this.get_config('token');
31024
31025 // set $duration if time_event was previously called for this event
31026 var start_timestamp = this['persistence'].remove_event_timer(event_name);
31027 if (!_.isUndefined(start_timestamp)) {
31028 var duration_in_ms = new Date().getTime() - start_timestamp;
31029 properties['$duration'] = parseFloat((duration_in_ms / 1000).toFixed(3));
31030 }
31031
31032 this._set_default_superprops();
31033
31034 var marketing_properties = this.get_config('track_marketing')
31035 ? _.info.marketingParams()
31036 : {};
31037
31038 // note: extend writes to the first object, so lets make sure we
31039 // don't write to the persistence properties object and info
31040 // properties object by passing in a new object
31041
31042 // update properties with pageview info and super-properties
31043 properties = _.extend(
31044 {},
31045 _.info.properties({'mp_loader': this.get_config('mp_loader')}),
31046 marketing_properties,
31047 this['persistence'].properties(),
31048 this.unpersisted_superprops,
31049 this.get_session_recording_properties(),
31050 properties
31051 );
31052
31053 var property_blacklist = this.get_config('property_blacklist');
31054 if (_.isArray(property_blacklist)) {
31055 _.each(property_blacklist, function(blacklisted_prop) {
31056 delete properties[blacklisted_prop];
31057 });
31058 } else {
31059 this.report_error('Invalid value for property_blacklist config: ' + property_blacklist);
31060 }
31061
31062 var data = {
31063 'event': event_name,
31064 'properties': properties
31065 };
31066 var ret = this._track_or_batch({
31067 type: 'events',
31068 data: data,
31069 endpoint: this.get_api_host('events') + '/' + this.get_config('api_routes')['track'],
31070 batcher: this.request_batchers.events,
31071 should_send_immediately: should_send_immediately,
31072 send_request_options: options
31073 }, callback);
31074
31075 return ret;
31076 });
31077
31078 /**
31079 * Register the current user into one/many groups.
31080 *
31081 * ### Usage:
31082 *
31083 * mixpanel.set_group('company', ['mixpanel', 'google']) // an array of IDs
31084 * mixpanel.set_group('company', 'mixpanel')
31085 * mixpanel.set_group('company', 128746312)
31086 *
31087 * @param {String} group_key Group key
31088 * @param {Array|String|Number} group_ids An array of group IDs, or a singular group ID
31089 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
31090 *
31091 */
31092 MixpanelLib.prototype.set_group = addOptOutCheckMixpanelLib(function(group_key, group_ids, callback) {
31093 if (!_.isArray(group_ids)) {
31094 group_ids = [group_ids];
31095 }
31096 var prop = {};
31097 prop[group_key] = group_ids;
31098 this.register(prop);
31099 return this['people'].set(group_key, group_ids, callback);
31100 });
31101
31102 /**
31103 * Add a new group for this user.
31104 *
31105 * ### Usage:
31106 *
31107 * mixpanel.add_group('company', 'mixpanel')
31108 *
31109 * @param {String} group_key Group key
31110 * @param {*} group_id A valid Mixpanel property type
31111 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
31112 */
31113 MixpanelLib.prototype.add_group = addOptOutCheckMixpanelLib(function(group_key, group_id, callback) {
31114 var old_values = this.get_property(group_key);
31115 var prop = {};
31116 if (old_values === undefined) {
31117 prop[group_key] = [group_id];
31118 this.register(prop);
31119 } else {
31120 if (old_values.indexOf(group_id) === -1) {
31121 old_values.push(group_id);
31122 prop[group_key] = old_values;
31123 this.register(prop);
31124 }
31125 }
31126 return this['people'].union(group_key, group_id, callback);
31127 });
31128
31129 /**
31130 * Remove a group from this user.
31131 *
31132 * ### Usage:
31133 *
31134 * mixpanel.remove_group('company', 'mixpanel')
31135 *
31136 * @param {String} group_key Group key
31137 * @param {*} group_id A valid Mixpanel property type
31138 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
31139 */
31140 MixpanelLib.prototype.remove_group = addOptOutCheckMixpanelLib(function(group_key, group_id, callback) {
31141 var old_value = this.get_property(group_key);
31142 // if the value doesn't exist, the persistent store is unchanged
31143 if (old_value !== undefined) {
31144 var idx = old_value.indexOf(group_id);
31145 if (idx > -1) {
31146 old_value.splice(idx, 1);
31147 this.register({group_key: old_value});
31148 }
31149 if (old_value.length === 0) {
31150 this.unregister(group_key);
31151 }
31152 }
31153 return this['people'].remove(group_key, group_id, callback);
31154 });
31155
31156 /**
31157 * Track an event with specific groups.
31158 *
31159 * ### Usage:
31160 *
31161 * mixpanel.track_with_groups('purchase', {'product': 'iphone'}, {'University': ['UCB', 'UCLA']})
31162 *
31163 * @param {String} event_name The name of the event (see `mixpanel.track()`)
31164 * @param {Object=} properties A set of properties to include with the event you're sending (see `mixpanel.track()`)
31165 * @param {Object=} groups An object mapping group name keys to one or more values
31166 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
31167 */
31168 MixpanelLib.prototype.track_with_groups = addOptOutCheckMixpanelLib(function(event_name, properties, groups, callback) {
31169 var tracking_props = _.extend({}, properties || {});
31170 _.each(groups, function(v, k) {
31171 if (v !== null && v !== undefined) {
31172 tracking_props[k] = v;
31173 }
31174 });
31175 return this.track(event_name, tracking_props, callback);
31176 });
31177
31178 MixpanelLib.prototype._create_map_key = function (group_key, group_id) {
31179 return group_key + '_' + JSON.stringify(group_id);
31180 };
31181
31182 MixpanelLib.prototype._remove_group_from_cache = function (group_key, group_id) {
31183 delete this._cached_groups[this._create_map_key(group_key, group_id)];
31184 };
31185
31186 /**
31187 * Look up reference to a Mixpanel group
31188 *
31189 * ### Usage:
31190 *
31191 * mixpanel.get_group(group_key, group_id)
31192 *
31193 * @param {String} group_key Group key
31194 * @param {Object} group_id A valid Mixpanel property type
31195 * @returns {Object} A MixpanelGroup identifier
31196 */
31197 MixpanelLib.prototype.get_group = function (group_key, group_id) {
31198 var map_key = this._create_map_key(group_key, group_id);
31199 var group = this._cached_groups[map_key];
31200 if (group === undefined || group._group_key !== group_key || group._group_id !== group_id) {
31201 group = new MixpanelGroup();
31202 group._init(this, group_key, group_id);
31203 this._cached_groups[map_key] = group;
31204 }
31205 return group;
31206 };
31207
31208 /**
31209 * Track a default Mixpanel page view event, which includes extra default event properties to
31210 * improve page view data.
31211 *
31212 * ### Usage:
31213 *
31214 * // track a default $mp_web_page_view event
31215 * mixpanel.track_pageview();
31216 *
31217 * // track a page view event with additional event properties
31218 * mixpanel.track_pageview({'ab_test_variant': 'card-layout-b'});
31219 *
31220 * // example approach to track page views on different page types as event properties
31221 * mixpanel.track_pageview({'page': 'pricing'});
31222 * mixpanel.track_pageview({'page': 'homepage'});
31223 *
31224 * // UNCOMMON: Tracking a page view event with a custom event_name option. NOT expected to be used for
31225 * // individual pages on the same site or product. Use cases for custom event_name may be page
31226 * // views on different products or internal applications that are considered completely separate
31227 * mixpanel.track_pageview({'page': 'customer-search'}, {'event_name': '[internal] Admin Page View'});
31228 *
31229 * ### Notes:
31230 *
31231 * The `config.track_pageview` option for <a href="#mixpanelinit">mixpanel.init()</a>
31232 * may be turned on for tracking page loads automatically.
31233 *
31234 * // track only page loads
31235 * mixpanel.init(PROJECT_TOKEN, {track_pageview: true});
31236 *
31237 * // track when the URL changes in any manner
31238 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'full-url'});
31239 *
31240 * // track when the URL changes, ignoring any changes in the hash part
31241 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'url-with-path-and-query-string'});
31242 *
31243 * // track when the path changes, ignoring any query parameter or hash changes
31244 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'url-with-path'});
31245 *
31246 * @param {Object} [properties] An optional set of additional properties to send with the page view event
31247 * @param {Object} [options] Page view tracking options
31248 * @param {String} [options.event_name] - Alternate name for the tracking event
31249 * @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
31250 * with the tracking payload sent to the API server is returned; otherwise false.
31251 */
31252 MixpanelLib.prototype.track_pageview = addOptOutCheckMixpanelLib(function(properties, options) {
31253 if (typeof properties !== 'object') {
31254 properties = {};
31255 }
31256 options = options || {};
31257 var event_name = options['event_name'] || '$mp_web_page_view';
31258
31259 var default_page_properties = _.extend(
31260 _.info.mpPageViewProperties(),
31261 _.info.campaignParams(),
31262 _.info.clickParams()
31263 );
31264
31265 var event_properties = _.extend(
31266 {},
31267 default_page_properties,
31268 properties
31269 );
31270
31271 return this.track(event_name, event_properties);
31272 });
31273
31274 /**
31275 * Track clicks on a set of document elements. Selector must be a
31276 * valid query. Elements must exist on the page at the time track_links is called.
31277 *
31278 * ### Usage:
31279 *
31280 * // track click for link id #nav
31281 * mixpanel.track_links('#nav', 'Clicked Nav Link');
31282 *
31283 * ### Notes:
31284 *
31285 * This function will wait up to 300 ms for the Mixpanel
31286 * servers to respond. If they have not responded by that time
31287 * it will head to the link without ensuring that your event
31288 * has been tracked. To configure this timeout please see the
31289 * set_config() documentation below.
31290 *
31291 * If you pass a function in as the properties argument, the
31292 * function will receive the DOMElement that triggered the
31293 * event as an argument. You are expected to return an object
31294 * from the function; any properties defined on this object
31295 * will be sent to mixpanel as event properties.
31296 *
31297 * @type {Function}
31298 * @param {Object|String} query A valid DOM query, element or jQuery-esque list
31299 * @param {String} event_name The name of the event to track
31300 * @param {Object|Function} [properties] A properties object or function that returns a dictionary of properties when passed a DOMElement
31301 */
31302 MixpanelLib.prototype.track_links = function() {
31303 return this._track_dom.call(this, LinkTracker, arguments);
31304 };
31305
31306 /**
31307 * Track form submissions. Selector must be a valid query.
31308 *
31309 * ### Usage:
31310 *
31311 * // track submission for form id 'register'
31312 * mixpanel.track_forms('#register', 'Created Account');
31313 *
31314 * ### Notes:
31315 *
31316 * This function will wait up to 300 ms for the mixpanel
31317 * servers to respond, if they have not responded by that time
31318 * it will head to the link without ensuring that your event
31319 * has been tracked. To configure this timeout please see the
31320 * set_config() documentation below.
31321 *
31322 * If you pass a function in as the properties argument, the
31323 * function will receive the DOMElement that triggered the
31324 * event as an argument. You are expected to return an object
31325 * from the function; any properties defined on this object
31326 * will be sent to mixpanel as event properties.
31327 *
31328 * @type {Function}
31329 * @param {Object|String} query A valid DOM query, element or jQuery-esque list
31330 * @param {String} event_name The name of the event to track
31331 * @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
31332 */
31333 MixpanelLib.prototype.track_forms = function() {
31334 return this._track_dom.call(this, FormTracker, arguments);
31335 };
31336
31337 /**
31338 * Time an event by including the time between this call and a
31339 * later 'track' call for the same event in the properties sent
31340 * with the event.
31341 *
31342 * ### Usage:
31343 *
31344 * // time an event named 'Registered'
31345 * mixpanel.time_event('Registered');
31346 * mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
31347 *
31348 * When called for a particular event name, the next track call for that event
31349 * name will include the elapsed time between the 'time_event' and 'track'
31350 * calls. This value is stored as seconds in the '$duration' property.
31351 *
31352 * @param {String} event_name The name of the event.
31353 */
31354 MixpanelLib.prototype.time_event = function(event_name) {
31355 if (_.isUndefined(event_name)) {
31356 this.report_error('No event name provided to mixpanel.time_event');
31357 return;
31358 }
31359
31360 if (this._event_is_disabled(event_name)) {
31361 return;
31362 }
31363
31364 this['persistence'].set_event_timer(event_name, new Date().getTime());
31365 };
31366
31367 var REGISTER_DEFAULTS = {
31368 'persistent': true
31369 };
31370 /**
31371 * Helper to parse options param for register methods, maintaining
31372 * legacy support for plain "days" param instead of options object
31373 * @param {Number|Object} [days_or_options] 'days' option (Number), or Options object for register methods
31374 * @returns {Object} options object
31375 */
31376 var options_for_register = function(days_or_options) {
31377 var options;
31378 if (_.isObject(days_or_options)) {
31379 options = days_or_options;
31380 } else if (!_.isUndefined(days_or_options)) {
31381 options = {'days': days_or_options};
31382 } else {
31383 options = {};
31384 }
31385 return _.extend({}, REGISTER_DEFAULTS, options);
31386 };
31387
31388 /**
31389 * Register a set of super properties, which are included with all
31390 * events. This will overwrite previous super property values.
31391 *
31392 * ### Usage:
31393 *
31394 * // register 'Gender' as a super property
31395 * mixpanel.register({'Gender': 'Female'});
31396 *
31397 * // register several super properties when a user signs up
31398 * mixpanel.register({
31399 * 'Email': 'jdoe@example.com',
31400 * 'Account Type': 'Free'
31401 * });
31402 *
31403 * // register only for the current pageload
31404 * mixpanel.register({'Name': 'Pat'}, {persistent: false});
31405 *
31406 * @param {Object} properties An associative array of properties to store about the user
31407 * @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)
31408 * @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)
31409 * @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
31410 */
31411 MixpanelLib.prototype.register = function(props, days_or_options) {
31412 var options = options_for_register(days_or_options);
31413 if (options['persistent']) {
31414 this['persistence'].register(props, options['days']);
31415 } else {
31416 _.extend(this.unpersisted_superprops, props);
31417 }
31418 };
31419
31420 /**
31421 * Register a set of super properties only once. This will not
31422 * overwrite previous super property values, unlike register().
31423 *
31424 * ### Usage:
31425 *
31426 * // register a super property for the first time only
31427 * mixpanel.register_once({
31428 * 'First Login Date': new Date().toISOString()
31429 * });
31430 *
31431 * // register once, only for the current pageload
31432 * mixpanel.register_once({
31433 * 'First interaction time': new Date().toISOString()
31434 * }, 'None', {persistent: false});
31435 *
31436 * ### Notes:
31437 *
31438 * If default_value is specified, current super properties
31439 * with that value will be overwritten.
31440 *
31441 * @param {Object} properties An associative array of properties to store about the user
31442 * @param {*} [default_value] Value to override if already set in super properties (ex: 'False') Default: 'None'
31443 * @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)
31444 * @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)
31445 * @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
31446 */
31447 MixpanelLib.prototype.register_once = function(props, default_value, days_or_options) {
31448 var options = options_for_register(days_or_options);
31449 if (options['persistent']) {
31450 this['persistence'].register_once(props, default_value, options['days']);
31451 } else {
31452 if (typeof(default_value) === 'undefined') {
31453 default_value = 'None';
31454 }
31455 _.each(props, function(val, prop) {
31456 if (!this.unpersisted_superprops.hasOwnProperty(prop) || this.unpersisted_superprops[prop] === default_value) {
31457 this.unpersisted_superprops[prop] = val;
31458 }
31459 }, this);
31460 }
31461 };
31462
31463 /**
31464 * Delete a super property stored with the current user.
31465 *
31466 * @param {String} property The name of the super property to remove
31467 * @param {Object} [options]
31468 * @param {boolean} [options.persistent=true] - whether to look in persistent storage (cookie/localStorage)
31469 */
31470 MixpanelLib.prototype.unregister = function(property, options) {
31471 options = options_for_register(options);
31472 if (options['persistent']) {
31473 this['persistence'].unregister(property);
31474 } else {
31475 delete this.unpersisted_superprops[property];
31476 }
31477 };
31478
31479 MixpanelLib.prototype._register_single = function(prop, value) {
31480 var props = {};
31481 props[prop] = value;
31482 this.register(props);
31483 };
31484
31485 /**
31486 * Identify a user with a unique ID to track user activity across
31487 * devices, tie a user to their events, and create a user profile.
31488 * If you never call this method, unique visitors are tracked using
31489 * a UUID generated the first time they visit the site.
31490 *
31491 * Call identify when you know the identity of the current user,
31492 * typically after login or signup. We recommend against using
31493 * identify for anonymous visitors to your site.
31494 *
31495 * ### Notes:
31496 * If your project has
31497 * <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a>
31498 * enabled, the identify method will connect pre- and
31499 * post-authentication events when appropriate.
31500 *
31501 * If your project does not have ID Merge enabled, identify will
31502 * change the user's local distinct_id to the unique ID you pass.
31503 * Events tracked prior to authentication will not be connected
31504 * to the same user identity. If ID Merge is disabled, alias can
31505 * be used to connect pre- and post-registration events.
31506 *
31507 * @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.
31508 */
31509 MixpanelLib.prototype.identify = function(
31510 new_distinct_id, _set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback
31511 ) {
31512 // Optional Parameters
31513 // _set_callback:function A callback to be run if and when the People set queue is flushed
31514 // _add_callback:function A callback to be run if and when the People add queue is flushed
31515 // _append_callback:function A callback to be run if and when the People append queue is flushed
31516 // _set_once_callback:function A callback to be run if and when the People set_once queue is flushed
31517 // _union_callback:function A callback to be run if and when the People union queue is flushed
31518 // _unset_callback:function A callback to be run if and when the People unset queue is flushed
31519
31520 var previous_distinct_id = this.get_distinct_id();
31521 if (new_distinct_id && previous_distinct_id !== new_distinct_id) {
31522 // we allow the following condition if previous distinct_id is same as new_distinct_id
31523 // so that you can force flush people updates for anonymous profiles.
31524 if (typeof new_distinct_id === 'string' && new_distinct_id.indexOf(DEVICE_ID_PREFIX) === 0) {
31525 this.report_error('distinct_id cannot have $device: prefix');
31526 return -1;
31527 }
31528 this.register({'$user_id': new_distinct_id});
31529 }
31530
31531 if (!this.get_property('$device_id')) {
31532 // The persisted distinct id might not actually be a device id at all
31533 // it might be a distinct id of the user from before
31534 var device_id = previous_distinct_id;
31535 this.register_once({
31536 '$had_persisted_distinct_id': true,
31537 '$device_id': device_id
31538 }, '');
31539 }
31540
31541 // identify only changes the distinct id if it doesn't match either the existing or the alias;
31542 // if it's new, blow away the alias as well.
31543 if (new_distinct_id !== previous_distinct_id && new_distinct_id !== this.get_property(ALIAS_ID_KEY)) {
31544 this.unregister(ALIAS_ID_KEY);
31545 this.register({'distinct_id': new_distinct_id});
31546 }
31547 this._flags.identify_called = true;
31548 // Flush any queued up people requests
31549 this['people']._flush(_set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback);
31550
31551 // send an $identify event any time the distinct_id is changing - logic on the server
31552 // will determine whether or not to do anything with it.
31553 if (new_distinct_id !== previous_distinct_id) {
31554 this.track('$identify', {
31555 'distinct_id': new_distinct_id,
31556 '$anon_distinct_id': previous_distinct_id
31557 }, {skip_hooks: true});
31558 }
31559
31560 // check feature flags again if distinct id has changed
31561 if (new_distinct_id !== previous_distinct_id) {
31562 this.flags.fetchFlags();
31563 }
31564 };
31565
31566 /**
31567 * Clears super properties and generates a new random distinct_id for this instance.
31568 * Useful for clearing data when a user logs out.
31569 */
31570 MixpanelLib.prototype.reset = function() {
31571 this.stop_session_recording();
31572 this['persistence'].clear();
31573 this._flags.identify_called = false;
31574 var uuid = _.UUID();
31575 this.register_once({
31576 'distinct_id': DEVICE_ID_PREFIX + uuid,
31577 '$device_id': uuid
31578 }, '');
31579 this._check_and_start_session_recording();
31580 };
31581
31582 /**
31583 * Returns the current distinct id of the user. This is either the id automatically
31584 * generated by the library or the id that has been passed by a call to identify().
31585 *
31586 * ### Notes:
31587 *
31588 * get_distinct_id() can only be called after the Mixpanel library has finished loading.
31589 * init() has a loaded function available to handle this automatically. For example:
31590 *
31591 * // set distinct_id after the mixpanel library has loaded
31592 * mixpanel.init('YOUR PROJECT TOKEN', {
31593 * loaded: function(mixpanel) {
31594 * distinct_id = mixpanel.get_distinct_id();
31595 * }
31596 * });
31597 */
31598 MixpanelLib.prototype.get_distinct_id = function() {
31599 return this.get_property('distinct_id');
31600 };
31601
31602 /**
31603 * The alias method creates an alias which Mixpanel will use to
31604 * remap one id to another. Multiple aliases can point to the
31605 * same identifier.
31606 *
31607 * The following is a valid use of alias:
31608 *
31609 * mixpanel.alias('new_id', 'existing_id');
31610 * // You can add multiple id aliases to the existing ID
31611 * mixpanel.alias('newer_id', 'existing_id');
31612 *
31613 * Aliases can also be chained - the following is a valid example:
31614 *
31615 * mixpanel.alias('new_id', 'existing_id');
31616 * // chain newer_id - new_id - existing_id
31617 * mixpanel.alias('newer_id', 'new_id');
31618 *
31619 * Aliases cannot point to multiple identifiers - the following
31620 * example will not work:
31621 *
31622 * mixpanel.alias('new_id', 'existing_id');
31623 * // this is invalid as 'new_id' already points to 'existing_id'
31624 * mixpanel.alias('new_id', 'newer_id');
31625 *
31626 * ### Notes:
31627 *
31628 * If your project does not have
31629 * <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a>
31630 * enabled, the best practice is to call alias once when a unique
31631 * ID is first created for a user (e.g., when a user first registers
31632 * for an account). Do not use alias multiple times for a single
31633 * user without ID Merge enabled.
31634 *
31635 * @param {String} alias A unique identifier that you want to use for this user in the future.
31636 * @param {String} [original] The current identifier being used for this user.
31637 */
31638 MixpanelLib.prototype.alias = function(alias, original) {
31639 // If the $people_distinct_id key exists in persistence, there has been a previous
31640 // mixpanel.people.identify() call made for this user. It is VERY BAD to make an alias with
31641 // this ID, as it will duplicate users.
31642 if (alias === this.get_property(PEOPLE_DISTINCT_ID_KEY)) {
31643 this.report_error('Attempting to create alias for existing People user - aborting.');
31644 return -2;
31645 }
31646
31647 var _this = this;
31648 if (_.isUndefined(original)) {
31649 original = this.get_distinct_id();
31650 }
31651 if (alias !== original) {
31652 this._register_single(ALIAS_ID_KEY, alias);
31653 return this.track('$create_alias', {
31654 'alias': alias,
31655 'distinct_id': original
31656 }, {
31657 skip_hooks: true
31658 }, function() {
31659 // Flush the people queue
31660 _this.identify(alias);
31661 });
31662 } else {
31663 this.report_error('alias matches current distinct_id - skipping api call.');
31664 this.identify(alias);
31665 return -1;
31666 }
31667 };
31668
31669 /**
31670 * Provide a string to recognize the user by. The string passed to
31671 * this method will appear in the Mixpanel Streams product rather
31672 * than an automatically generated name. Name tags do not have to
31673 * be unique.
31674 *
31675 * This value will only be included in Streams data.
31676 *
31677 * @param {String} name_tag A human readable name for the user
31678 * @deprecated
31679 */
31680 MixpanelLib.prototype.name_tag = function(name_tag) {
31681 this._register_single('mp_name_tag', name_tag);
31682 };
31683
31684 /**
31685 * Update the configuration of a mixpanel library instance.
31686 *
31687 * The default config is:
31688 *
31689 * {
31690 * // host for requests (customizable for e.g. a local proxy)
31691 * api_host: 'https://api-js.mixpanel.com',
31692 *
31693 * // endpoints for different types of requests
31694 * api_routes: {
31695 * track: 'track/',
31696 * engage: 'engage/',
31697 * groups: 'groups/',
31698 * }
31699 *
31700 * // HTTP method for tracking requests
31701 * api_method: 'POST'
31702 *
31703 * // transport for sending requests ('XHR' or 'sendBeacon')
31704 * // NB: sendBeacon should only be used for scenarios such as
31705 * // page unload where a "best-effort" attempt to send is
31706 * // acceptable; the sendBeacon API does not support callbacks
31707 * // or any way to know the result of the request. Mixpanel
31708 * // tracking via sendBeacon will not support any event-
31709 * // batching or retry mechanisms.
31710 * api_transport: 'XHR'
31711 *
31712 * // request-batching/queueing/retry
31713 * batch_requests: true,
31714 *
31715 * // maximum number of events/updates to send in a single
31716 * // network request
31717 * batch_size: 50,
31718 *
31719 * // milliseconds to wait between sending batch requests
31720 * batch_flush_interval_ms: 5000,
31721 *
31722 * // milliseconds to wait for network responses to batch requests
31723 * // before they are considered timed-out and retried
31724 * batch_request_timeout_ms: 90000,
31725 *
31726 * // override value for cookie domain, only useful for ensuring
31727 * // correct cross-subdomain cookies on unusual domains like
31728 * // subdomain.mainsite.avocat.fr; NB this cannot be used to
31729 * // set cookies on a different domain than the current origin
31730 * cookie_domain: ''
31731 *
31732 * // super properties cookie expiration (in days)
31733 * cookie_expiration: 365
31734 *
31735 * // if true, cookie will be set with SameSite=None; Secure
31736 * // this is only useful in special situations, like embedded
31737 * // 3rd-party iframes that set up a Mixpanel instance
31738 * cross_site_cookie: false
31739 *
31740 * // super properties span subdomains
31741 * cross_subdomain_cookie: true
31742 *
31743 * // debug mode
31744 * debug: false
31745 *
31746 * // if this is true, the mixpanel cookie or localStorage entry
31747 * // will be deleted, and no user persistence will take place
31748 * disable_persistence: false
31749 *
31750 * // if this is true, Mixpanel will automatically determine
31751 * // City, Region and Country data using the IP address of
31752 * //the client
31753 * ip: true
31754 *
31755 * // opt users out of tracking by this Mixpanel instance by default
31756 * opt_out_tracking_by_default: false
31757 *
31758 * // opt users out of browser data storage by this Mixpanel instance by default
31759 * opt_out_persistence_by_default: false
31760 *
31761 * // persistence mechanism used by opt-in/opt-out methods - cookie
31762 * // or localStorage - falls back to cookie if localStorage is unavailable
31763 * opt_out_tracking_persistence_type: 'localStorage'
31764 *
31765 * // customize the name of cookie/localStorage set by opt-in/opt-out methods
31766 * opt_out_tracking_cookie_prefix: null
31767 *
31768 * // type of persistent store for super properties (cookie/
31769 * // localStorage) if set to 'localStorage', any existing
31770 * // mixpanel cookie value with the same persistence_name
31771 * // will be transferred to localStorage and deleted
31772 * persistence: 'cookie'
31773 *
31774 * // name for super properties persistent store
31775 * persistence_name: ''
31776 *
31777 * // names of properties/superproperties which should never
31778 * // be sent with track() calls
31779 * property_blacklist: []
31780 *
31781 * // if this is true, mixpanel cookies will be marked as
31782 * // secure, meaning they will only be transmitted over https
31783 * secure_cookie: false
31784 *
31785 * // disables enriching user profiles with first touch marketing data
31786 * skip_first_touch_marketing: false
31787 *
31788 * // the amount of time track_links will
31789 * // wait for Mixpanel's servers to respond
31790 * track_links_timeout: 300
31791 *
31792 * // adds any UTM parameters and click IDs present on the page to any events fired
31793 * track_marketing: true
31794 *
31795 * // enables automatic page view tracking using default page view events through
31796 * // the track_pageview() method
31797 * track_pageview: false
31798 *
31799 * // if you set upgrade to be true, the library will check for
31800 * // a cookie from our old js library and import super
31801 * // properties from it, then the old cookie is deleted
31802 * // The upgrade config option only works in the initialization,
31803 * // so make sure you set it when you create the library.
31804 * upgrade: false
31805 *
31806 * // extra HTTP request headers to set for each API request, in
31807 * // the format {'Header-Name': value}
31808 * xhr_headers: {}
31809 *
31810 * // whether to ignore or respect the web browser's Do Not Track setting
31811 * ignore_dnt: false
31812 * }
31813 *
31814 *
31815 * @param {Object} config A dictionary of new configuration values to update
31816 */
31817 MixpanelLib.prototype.set_config = function(config) {
31818 if (_.isObject(config)) {
31819 _.extend(this['config'], config);
31820
31821 var new_batch_size = config['batch_size'];
31822 if (new_batch_size) {
31823 _.each(this.request_batchers, function(batcher) {
31824 batcher.resetBatchSize();
31825 });
31826 }
31827
31828 if (!this.get_config('persistence_name')) {
31829 this['config']['persistence_name'] = this['config']['cookie_name'];
31830 }
31831 if (!this.get_config('disable_persistence')) {
31832 this['config']['disable_persistence'] = this['config']['disable_cookie'];
31833 }
31834
31835 if (this['persistence']) {
31836 this['persistence'].update_config(this['config']);
31837 }
31838 Config.DEBUG = Config.DEBUG || this.get_config('debug');
31839
31840 if (('autocapture' in config || 'record_heatmap_data' in config) && this.autocapture) {
31841 this.autocapture.init();
31842 }
31843 }
31844 };
31845
31846 /**
31847 * returns the current config object for the library.
31848 */
31849 MixpanelLib.prototype.get_config = function(prop_name) {
31850 return this['config'][prop_name];
31851 };
31852
31853 /**
31854 * Fetch a hook function from config, with safe default, and run it
31855 * against the given arguments
31856 * @param {string} hook_name which hook to retrieve
31857 * @returns {any|null} return value of user-provided hook, or null if nothing was returned
31858 */
31859 MixpanelLib.prototype._run_hook = function(hook_name) {
31860 var ret = (this['config']['hooks'][hook_name] || IDENTITY_FUNC).apply(this, slice.call(arguments, 1));
31861 if (typeof ret === 'undefined') {
31862 this.report_error(hook_name + ' hook did not return a value');
31863 ret = null;
31864 }
31865 return ret;
31866 };
31867
31868 /**
31869 * Returns the value of the super property named property_name. If no such
31870 * property is set, get_property() will return the undefined value.
31871 *
31872 * ### Notes:
31873 *
31874 * get_property() can only be called after the Mixpanel library has finished loading.
31875 * init() has a loaded function available to handle this automatically. For example:
31876 *
31877 * // grab value for 'user_id' after the mixpanel library has loaded
31878 * mixpanel.init('YOUR PROJECT TOKEN', {
31879 * loaded: function(mixpanel) {
31880 * user_id = mixpanel.get_property('user_id');
31881 * }
31882 * });
31883 *
31884 * @param {String} property_name The name of the super property you want to retrieve
31885 */
31886 MixpanelLib.prototype.get_property = function(property_name) {
31887 return this['persistence'].load_prop([property_name]);
31888 };
31889
31890 /**
31891 * Get the API host for a specific endpoint type, falling back to the default api_host if not specified
31892 *
31893 * @param {String} endpoint_type The type of endpoint (e.g., "events", "people", "groups")
31894 * @returns {String} The API host to use for this endpoint
31895 */
31896 MixpanelLib.prototype.get_api_host = function(endpoint_type) {
31897 return this.get_config('api_hosts')[endpoint_type] || this.get_config('api_host');
31898 };
31899
31900 MixpanelLib.prototype.toString = function() {
31901 var name = this.get_config('name');
31902 if (name !== PRIMARY_INSTANCE_NAME) {
31903 name = PRIMARY_INSTANCE_NAME + '.' + name;
31904 }
31905 return name;
31906 };
31907
31908 MixpanelLib.prototype._event_is_disabled = function(event_name) {
31909 return _.isBlockedUA(userAgent) ||
31910 this._flags.disable_all_events ||
31911 _.include(this.__disabled_events, event_name);
31912 };
31913
31914 // perform some housekeeping around GDPR opt-in/out state
31915 MixpanelLib.prototype._gdpr_init = function() {
31916 var is_localStorage_requested = this.get_config('opt_out_tracking_persistence_type') === 'localStorage';
31917
31918 // try to convert opt-in/out cookies to localStorage if possible
31919 if (is_localStorage_requested && _.localStorage.is_supported()) {
31920 if (!this.has_opted_in_tracking() && this.has_opted_in_tracking({'persistence_type': 'cookie'})) {
31921 this.opt_in_tracking({'enable_persistence': false});
31922 }
31923 if (!this.has_opted_out_tracking() && this.has_opted_out_tracking({'persistence_type': 'cookie'})) {
31924 this.opt_out_tracking({'clear_persistence': false});
31925 }
31926 this.clear_opt_in_out_tracking({
31927 'persistence_type': 'cookie',
31928 'enable_persistence': false
31929 });
31930 }
31931
31932 // check whether the user has already opted out - if so, clear & disable persistence
31933 if (this.has_opted_out_tracking()) {
31934 this._gdpr_update_persistence({'clear_persistence': true});
31935
31936 // check whether we should opt out by default
31937 // note: we don't clear persistence here by default since opt-out default state is often
31938 // used as an initial state while GDPR information is being collected
31939 } else if (!this.has_opted_in_tracking() && (
31940 this.get_config('opt_out_tracking_by_default') || _.cookie.get('mp_optout')
31941 )) {
31942 _.cookie.remove('mp_optout');
31943 this.opt_out_tracking({
31944 'clear_persistence': this.get_config('opt_out_persistence_by_default')
31945 });
31946 }
31947 };
31948
31949 /**
31950 * Enable or disable persistence based on options
31951 * only enable/disable if persistence is not already in this state
31952 * @param {boolean} [options.clear_persistence] If true, will delete all data stored by the sdk in persistence and disable it
31953 * @param {boolean} [options.enable_persistence] If true, will re-enable sdk persistence
31954 */
31955 MixpanelLib.prototype._gdpr_update_persistence = function(options) {
31956 var disabled;
31957 if (options && options['clear_persistence']) {
31958 disabled = true;
31959 } else if (options && options['enable_persistence']) {
31960 disabled = false;
31961 } else {
31962 return;
31963 }
31964
31965 if (!this.get_config('disable_persistence') && this['persistence'].disabled !== disabled) {
31966 this['persistence'].set_disabled(disabled);
31967 }
31968
31969 if (disabled) {
31970 this.stop_batch_senders();
31971 this.stop_session_recording();
31972 } else {
31973 // only start batchers after opt-in if they have previously been started
31974 // in order to avoid unintentionally starting up batching for the first time
31975 if (this._batchers_were_started) {
31976 this.start_batch_senders();
31977 }
31978 }
31979 };
31980
31981 // call a base gdpr function after constructing the appropriate token and options args
31982 MixpanelLib.prototype._gdpr_call_func = function(func, options) {
31983 options = _.extend({
31984 'track': _.bind(this.track, this),
31985 'persistence_type': this.get_config('opt_out_tracking_persistence_type'),
31986 'cookie_prefix': this.get_config('opt_out_tracking_cookie_prefix'),
31987 'cookie_expiration': this.get_config('cookie_expiration'),
31988 'cross_site_cookie': this.get_config('cross_site_cookie'),
31989 'cross_subdomain_cookie': this.get_config('cross_subdomain_cookie'),
31990 'cookie_domain': this.get_config('cookie_domain'),
31991 'secure_cookie': this.get_config('secure_cookie'),
31992 'ignore_dnt': this.get_config('ignore_dnt')
31993 }, options);
31994
31995 // check if localStorage can be used for recording opt out status, fall back to cookie if not
31996 if (!_.localStorage.is_supported()) {
31997 options['persistence_type'] = 'cookie';
31998 }
31999
32000 return func(this.get_config('token'), {
32001 track: options['track'],
32002 trackEventName: options['track_event_name'],
32003 trackProperties: options['track_properties'],
32004 persistenceType: options['persistence_type'],
32005 persistencePrefix: options['cookie_prefix'],
32006 cookieDomain: options['cookie_domain'],
32007 cookieExpiration: options['cookie_expiration'],
32008 crossSiteCookie: options['cross_site_cookie'],
32009 crossSubdomainCookie: options['cross_subdomain_cookie'],
32010 secureCookie: options['secure_cookie'],
32011 ignoreDnt: options['ignore_dnt']
32012 });
32013 };
32014
32015 /**
32016 * Opt the user in to data tracking and cookies/localstorage for this Mixpanel instance
32017 *
32018 * ### Usage:
32019 *
32020 * // opt user in
32021 * mixpanel.opt_in_tracking();
32022 *
32023 * // opt user in with specific event name, properties, cookie configuration
32024 * mixpanel.opt_in_tracking({
32025 * track_event_name: 'User opted in',
32026 * track_event_properties: {
32027 * 'Email': 'jdoe@example.com'
32028 * },
32029 * cookie_expiration: 30,
32030 * secure_cookie: true
32031 * });
32032 *
32033 * @param {Object} [options] A dictionary of config options to override
32034 * @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)
32035 * @param {string} [options.track_event_name=$opt_in] Event name to be used for tracking the opt-in action
32036 * @param {Object} [options.track_properties] Set of properties to be tracked along with the opt-in action
32037 * @param {boolean} [options.enable_persistence=true] If true, will re-enable sdk persistence
32038 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32039 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32040 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
32041 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
32042 * @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)
32043 * @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)
32044 * @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)
32045 */
32046 MixpanelLib.prototype.opt_in_tracking = function(options) {
32047 options = _.extend({
32048 'enable_persistence': true
32049 }, options);
32050
32051 this._gdpr_call_func(optIn, options);
32052 this._gdpr_update_persistence(options);
32053 };
32054
32055 /**
32056 * Opt the user out of data tracking and cookies/localstorage for this Mixpanel instance
32057 *
32058 * ### Usage:
32059 *
32060 * // opt user out
32061 * mixpanel.opt_out_tracking();
32062 *
32063 * // opt user out with different cookie configuration from Mixpanel instance
32064 * mixpanel.opt_out_tracking({
32065 * cookie_expiration: 30,
32066 * secure_cookie: true
32067 * });
32068 *
32069 * @param {Object} [options] A dictionary of config options to override
32070 * @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
32071 * @param {boolean} [options.clear_persistence=true] If true, will delete all data stored by the sdk in persistence
32072 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32073 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32074 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
32075 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
32076 * @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)
32077 * @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)
32078 * @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)
32079 */
32080 MixpanelLib.prototype.opt_out_tracking = function(options) {
32081 options = _.extend({
32082 'clear_persistence': true,
32083 'delete_user': true
32084 }, options);
32085
32086 // delete user and clear charges since these methods may be disabled by opt-out
32087 if (options['delete_user'] && this['people'] && this['people']._identify_called()) {
32088 this['people'].delete_user();
32089 this['people'].clear_charges();
32090 }
32091
32092 this._gdpr_call_func(optOut, options);
32093 this._gdpr_update_persistence(options);
32094 };
32095
32096 /**
32097 * Check whether the user has opted in to data tracking and cookies/localstorage for this Mixpanel instance
32098 *
32099 * ### Usage:
32100 *
32101 * var has_opted_in = mixpanel.has_opted_in_tracking();
32102 * // use has_opted_in value
32103 *
32104 * @param {Object} [options] A dictionary of config options to override
32105 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32106 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32107 * @returns {boolean} current opt-in status
32108 */
32109 MixpanelLib.prototype.has_opted_in_tracking = function(options) {
32110 return this._gdpr_call_func(hasOptedIn, options);
32111 };
32112
32113 /**
32114 * Check whether the user has opted out of data tracking and cookies/localstorage for this Mixpanel instance
32115 *
32116 * ### Usage:
32117 *
32118 * var has_opted_out = mixpanel.has_opted_out_tracking();
32119 * // use has_opted_out value
32120 *
32121 * @param {Object} [options] A dictionary of config options to override
32122 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32123 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32124 * @returns {boolean} current opt-out status
32125 */
32126 MixpanelLib.prototype.has_opted_out_tracking = function(options) {
32127 return this._gdpr_call_func(hasOptedOut, options);
32128 };
32129
32130 /**
32131 * Clear the user's opt in/out status of data tracking and cookies/localstorage for this Mixpanel instance
32132 *
32133 * ### Usage:
32134 *
32135 * // clear user's opt-in/out status
32136 * mixpanel.clear_opt_in_out_tracking();
32137 *
32138 * // clear user's opt-in/out status with specific cookie configuration - should match
32139 * // configuration used when opt_in_tracking/opt_out_tracking methods were called.
32140 * mixpanel.clear_opt_in_out_tracking({
32141 * cookie_expiration: 30,
32142 * secure_cookie: true
32143 * });
32144 *
32145 * @param {Object} [options] A dictionary of config options to override
32146 * @param {boolean} [options.enable_persistence=true] If true, will re-enable sdk persistence
32147 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32148 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32149 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
32150 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
32151 * @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)
32152 * @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)
32153 * @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)
32154 */
32155 MixpanelLib.prototype.clear_opt_in_out_tracking = function(options) {
32156 options = _.extend({
32157 'enable_persistence': true
32158 }, options);
32159
32160 this._gdpr_call_func(clearOptInOut, options);
32161 this._gdpr_update_persistence(options);
32162 };
32163
32164 MixpanelLib.prototype.report_error = function(msg, err) {
32165 console$1.error.apply(console$1.error, arguments);
32166 try {
32167 if (!err && !(msg instanceof Error)) {
32168 msg = new Error(msg);
32169 }
32170 this.get_config('error_reporter')(msg, err);
32171 } catch(err) {
32172 console$1.error(err);
32173 }
32174 };
32175
32176 // EXPORTS (for closure compiler)
32177
32178 // MixpanelLib Exports
32179 MixpanelLib.prototype['init'] = MixpanelLib.prototype.init;
32180 MixpanelLib.prototype['reset'] = MixpanelLib.prototype.reset;
32181 MixpanelLib.prototype['disable'] = MixpanelLib.prototype.disable;
32182 MixpanelLib.prototype['time_event'] = MixpanelLib.prototype.time_event;
32183 MixpanelLib.prototype['track'] = MixpanelLib.prototype.track;
32184 MixpanelLib.prototype['track_links'] = MixpanelLib.prototype.track_links;
32185 MixpanelLib.prototype['track_forms'] = MixpanelLib.prototype.track_forms;
32186 MixpanelLib.prototype['track_pageview'] = MixpanelLib.prototype.track_pageview;
32187 MixpanelLib.prototype['register'] = MixpanelLib.prototype.register;
32188 MixpanelLib.prototype['register_once'] = MixpanelLib.prototype.register_once;
32189 MixpanelLib.prototype['unregister'] = MixpanelLib.prototype.unregister;
32190 MixpanelLib.prototype['identify'] = MixpanelLib.prototype.identify;
32191 MixpanelLib.prototype['alias'] = MixpanelLib.prototype.alias;
32192 MixpanelLib.prototype['name_tag'] = MixpanelLib.prototype.name_tag;
32193 MixpanelLib.prototype['set_config'] = MixpanelLib.prototype.set_config;
32194 MixpanelLib.prototype['get_config'] = MixpanelLib.prototype.get_config;
32195 MixpanelLib.prototype['get_api_host'] = MixpanelLib.prototype.get_api_host;
32196 MixpanelLib.prototype['get_property'] = MixpanelLib.prototype.get_property;
32197 MixpanelLib.prototype['get_distinct_id'] = MixpanelLib.prototype.get_distinct_id;
32198 MixpanelLib.prototype['toString'] = MixpanelLib.prototype.toString;
32199 MixpanelLib.prototype['opt_out_tracking'] = MixpanelLib.prototype.opt_out_tracking;
32200 MixpanelLib.prototype['opt_in_tracking'] = MixpanelLib.prototype.opt_in_tracking;
32201 MixpanelLib.prototype['has_opted_out_tracking'] = MixpanelLib.prototype.has_opted_out_tracking;
32202 MixpanelLib.prototype['has_opted_in_tracking'] = MixpanelLib.prototype.has_opted_in_tracking;
32203 MixpanelLib.prototype['clear_opt_in_out_tracking'] = MixpanelLib.prototype.clear_opt_in_out_tracking;
32204 MixpanelLib.prototype['get_group'] = MixpanelLib.prototype.get_group;
32205 MixpanelLib.prototype['set_group'] = MixpanelLib.prototype.set_group;
32206 MixpanelLib.prototype['add_group'] = MixpanelLib.prototype.add_group;
32207 MixpanelLib.prototype['remove_group'] = MixpanelLib.prototype.remove_group;
32208 MixpanelLib.prototype['track_with_groups'] = MixpanelLib.prototype.track_with_groups;
32209 MixpanelLib.prototype['start_batch_senders'] = MixpanelLib.prototype.start_batch_senders;
32210 MixpanelLib.prototype['stop_batch_senders'] = MixpanelLib.prototype.stop_batch_senders;
32211 MixpanelLib.prototype['start_session_recording'] = MixpanelLib.prototype.start_session_recording;
32212 MixpanelLib.prototype['stop_session_recording'] = MixpanelLib.prototype.stop_session_recording;
32213 MixpanelLib.prototype['pause_session_recording'] = MixpanelLib.prototype.pause_session_recording;
32214 MixpanelLib.prototype['resume_session_recording'] = MixpanelLib.prototype.resume_session_recording;
32215 MixpanelLib.prototype['get_session_recording_properties'] = MixpanelLib.prototype.get_session_recording_properties;
32216 MixpanelLib.prototype['get_session_replay_url'] = MixpanelLib.prototype.get_session_replay_url;
32217 MixpanelLib.prototype['get_tab_id'] = MixpanelLib.prototype.get_tab_id;
32218 MixpanelLib.prototype['DEFAULT_API_ROUTES'] = DEFAULT_API_ROUTES;
32219
32220 // Exports intended only for testing
32221 MixpanelLib.prototype['__get_recorder'] = MixpanelLib.prototype.__get_recorder;
32222
32223 // MixpanelPersistence Exports
32224 MixpanelPersistence.prototype['properties'] = MixpanelPersistence.prototype.properties;
32225 MixpanelPersistence.prototype['update_search_keyword'] = MixpanelPersistence.prototype.update_search_keyword;
32226 MixpanelPersistence.prototype['update_referrer_info'] = MixpanelPersistence.prototype.update_referrer_info;
32227 MixpanelPersistence.prototype['get_cross_subdomain'] = MixpanelPersistence.prototype.get_cross_subdomain;
32228 MixpanelPersistence.prototype['clear'] = MixpanelPersistence.prototype.clear;
32229
32230
32231 var instances = {};
32232 var extend_mp = function() {
32233 // add all the sub mixpanel instances
32234 _.each(instances, function(instance, name) {
32235 if (name !== PRIMARY_INSTANCE_NAME) { mixpanel_master[name] = instance; }
32236 });
32237
32238 // add private functions as _
32239 mixpanel_master['_'] = _;
32240 };
32241
32242 var override_mp_init_func = function() {
32243 // we override the snippets init function to handle the case where a
32244 // user initializes the mixpanel library after the script loads & runs
32245 mixpanel_master['init'] = function(token, config, name) {
32246 if (name) {
32247 // initialize a sub library
32248 if (!mixpanel_master[name]) {
32249 mixpanel_master[name] = instances[name] = create_mplib(token, config, name);
32250 mixpanel_master[name]._loaded();
32251 }
32252 return mixpanel_master[name];
32253 } else {
32254 var instance = mixpanel_master;
32255
32256 if (instances[PRIMARY_INSTANCE_NAME]) {
32257 // main mixpanel lib already initialized
32258 instance = instances[PRIMARY_INSTANCE_NAME];
32259 } else if (token) {
32260 // intialize the main mixpanel lib
32261 instance = create_mplib(token, config, PRIMARY_INSTANCE_NAME);
32262 instance._loaded();
32263 instances[PRIMARY_INSTANCE_NAME] = instance;
32264 }
32265
32266 mixpanel_master = instance;
32267 if (init_type === INIT_SNIPPET) {
32268 win[PRIMARY_INSTANCE_NAME] = mixpanel_master;
32269 }
32270 extend_mp();
32271 }
32272 };
32273 };
32274
32275 var add_dom_loaded_handler = function() {
32276 // Cross browser DOM Loaded support
32277 function dom_loaded_handler() {
32278 // function flag since we only want to execute this once
32279 if (dom_loaded_handler.done) { return; }
32280 dom_loaded_handler.done = true;
32281
32282 DOM_LOADED = true;
32283 ENQUEUE_REQUESTS = false;
32284
32285 _.each(instances, function(inst) {
32286 inst._dom_loaded();
32287 });
32288 }
32289
32290 function do_scroll_check() {
32291 try {
32292 document$1.documentElement.doScroll('left');
32293 } catch(e) {
32294 setTimeout(do_scroll_check, 1);
32295 return;
32296 }
32297
32298 dom_loaded_handler();
32299 }
32300
32301 if (document$1.addEventListener) {
32302 if (document$1.readyState === 'complete') {
32303 // safari 4 can fire the DOMContentLoaded event before loading all
32304 // external JS (including this file). you will see some copypasta
32305 // on the internet that checks for 'complete' and 'loaded', but
32306 // 'loaded' is an IE thing
32307 dom_loaded_handler();
32308 } else {
32309 document$1.addEventListener('DOMContentLoaded', dom_loaded_handler, false);
32310 }
32311 } else if (document$1.attachEvent) {
32312 // IE
32313 document$1.attachEvent('onreadystatechange', dom_loaded_handler);
32314
32315 // check to make sure we arn't in a frame
32316 var toplevel = false;
32317 try {
32318 toplevel = win.frameElement === null;
32319 } catch(e) {
32320 // noop
32321 }
32322
32323 if (document$1.documentElement.doScroll && toplevel) {
32324 do_scroll_check();
32325 }
32326 }
32327
32328 // fallback handler, always will work
32329 _.register_event(win, 'load', dom_loaded_handler, true);
32330 };
32331
32332 function init_as_module(bundle_loader) {
32333 load_extra_bundle = bundle_loader;
32334 init_type = INIT_MODULE;
32335 mixpanel_master = new MixpanelLib();
32336
32337 override_mp_init_func();
32338 mixpanel_master['init']();
32339 add_dom_loaded_handler();
32340
32341 return mixpanel_master;
32342 }
32343
32344 // For loading separate bundles asynchronously via script tag
32345 // so that we don't load them until they are needed at runtime.
32346
32347 // For builds that have everything in one bundle, no extra work.
32348 function loadNoop (_src, onload) {
32349 onload();
32350 }
32351
32352 /* eslint camelcase: "off" */
32353
32354 var mixpanel = init_as_module(loadNoop);
32355
32356
32357
32358
32359 /***/ }),
32360
32361 /***/ "../node_modules/redux-thunk/es/index.js":
32362 /*!***********************************************!*\
32363 !*** ../node_modules/redux-thunk/es/index.js ***!
32364 \***********************************************/
32365 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
32366
32367 "use strict";
32368 __webpack_require__.r(__webpack_exports__);
32369 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
32370 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
32371 /* harmony export */ });
32372 /** A function that accepts a potential "extra argument" value to be injected later,
32373 * and returns an instance of the thunk middleware that uses that value
32374 */
32375 function createThunkMiddleware(extraArgument) {
32376 // Standard Redux middleware definition pattern:
32377 // See: https://redux.js.org/tutorials/fundamentals/part-4-store#writing-custom-middleware
32378 var middleware = function middleware(_ref) {
32379 var dispatch = _ref.dispatch,
32380 getState = _ref.getState;
32381 return function (next) {
32382 return function (action) {
32383 // The thunk middleware looks for any functions that were passed to `store.dispatch`.
32384 // If this "action" is really a function, call it and return the result.
32385 if (typeof action === 'function') {
32386 // Inject the store's `dispatch` and `getState` methods, as well as any "extra arg"
32387 return action(dispatch, getState, extraArgument);
32388 } // Otherwise, pass the action down the middleware chain as usual
32389
32390
32391 return next(action);
32392 };
32393 };
32394 };
32395
32396 return middleware;
32397 }
32398
32399 var thunk = createThunkMiddleware(); // Attach the factory function so users can create a customized version
32400 // with whatever "extra arg" they want to inject into their thunks
32401
32402 thunk.withExtraArgument = createThunkMiddleware;
32403 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (thunk);
32404
32405 /***/ }),
32406
32407 /***/ "../node_modules/redux/es/redux.js":
32408 /*!*****************************************!*\
32409 !*** ../node_modules/redux/es/redux.js ***!
32410 \*****************************************/
32411 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
32412
32413 "use strict";
32414 __webpack_require__.r(__webpack_exports__);
32415 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
32416 /* harmony export */ __DO_NOT_USE__ActionTypes: () => (/* binding */ ActionTypes),
32417 /* harmony export */ applyMiddleware: () => (/* binding */ applyMiddleware),
32418 /* harmony export */ bindActionCreators: () => (/* binding */ bindActionCreators),
32419 /* harmony export */ combineReducers: () => (/* binding */ combineReducers),
32420 /* harmony export */ compose: () => (/* binding */ compose),
32421 /* harmony export */ createStore: () => (/* binding */ createStore),
32422 /* harmony export */ legacy_createStore: () => (/* binding */ legacy_createStore)
32423 /* harmony export */ });
32424 /* 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");
32425
32426
32427 /**
32428 * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
32429 *
32430 * Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
32431 * during build.
32432 * @param {number} code
32433 */
32434 function formatProdErrorMessage(code) {
32435 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. ';
32436 }
32437
32438 // Inlined version of the `symbol-observable` polyfill
32439 var $$observable = (function () {
32440 return typeof Symbol === 'function' && Symbol.observable || '@@observable';
32441 })();
32442
32443 /**
32444 * These are private action types reserved by Redux.
32445 * For any unknown actions, you must return the current state.
32446 * If the current state is undefined, you must return the initial state.
32447 * Do not reference these action types directly in your code.
32448 */
32449 var randomString = function randomString() {
32450 return Math.random().toString(36).substring(7).split('').join('.');
32451 };
32452
32453 var ActionTypes = {
32454 INIT: "@@redux/INIT" + randomString(),
32455 REPLACE: "@@redux/REPLACE" + randomString(),
32456 PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
32457 return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
32458 }
32459 };
32460
32461 /**
32462 * @param {any} obj The object to inspect.
32463 * @returns {boolean} True if the argument appears to be a plain object.
32464 */
32465 function isPlainObject(obj) {
32466 if (typeof obj !== 'object' || obj === null) return false;
32467 var proto = obj;
32468
32469 while (Object.getPrototypeOf(proto) !== null) {
32470 proto = Object.getPrototypeOf(proto);
32471 }
32472
32473 return Object.getPrototypeOf(obj) === proto;
32474 }
32475
32476 // Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
32477 function miniKindOf(val) {
32478 if (val === void 0) return 'undefined';
32479 if (val === null) return 'null';
32480 var type = typeof val;
32481
32482 switch (type) {
32483 case 'boolean':
32484 case 'string':
32485 case 'number':
32486 case 'symbol':
32487 case 'function':
32488 {
32489 return type;
32490 }
32491 }
32492
32493 if (Array.isArray(val)) return 'array';
32494 if (isDate(val)) return 'date';
32495 if (isError(val)) return 'error';
32496 var constructorName = ctorName(val);
32497
32498 switch (constructorName) {
32499 case 'Symbol':
32500 case 'Promise':
32501 case 'WeakMap':
32502 case 'WeakSet':
32503 case 'Map':
32504 case 'Set':
32505 return constructorName;
32506 } // other
32507
32508
32509 return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
32510 }
32511
32512 function ctorName(val) {
32513 return typeof val.constructor === 'function' ? val.constructor.name : null;
32514 }
32515
32516 function isError(val) {
32517 return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
32518 }
32519
32520 function isDate(val) {
32521 if (val instanceof Date) return true;
32522 return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function';
32523 }
32524
32525 function kindOf(val) {
32526 var typeOfVal = typeof val;
32527
32528 if (true) {
32529 typeOfVal = miniKindOf(val);
32530 }
32531
32532 return typeOfVal;
32533 }
32534
32535 /**
32536 * @deprecated
32537 *
32538 * **We recommend using the `configureStore` method
32539 * of the `@reduxjs/toolkit` package**, which replaces `createStore`.
32540 *
32541 * Redux Toolkit is our recommended approach for writing Redux logic today,
32542 * including store setup, reducers, data fetching, and more.
32543 *
32544 * **For more details, please read this Redux docs page:**
32545 * **https://redux.js.org/introduction/why-rtk-is-redux-today**
32546 *
32547 * `configureStore` from Redux Toolkit is an improved version of `createStore` that
32548 * simplifies setup and helps avoid common bugs.
32549 *
32550 * You should not be using the `redux` core package by itself today, except for learning purposes.
32551 * The `createStore` method from the core `redux` package will not be removed, but we encourage
32552 * all users to migrate to using Redux Toolkit for all Redux code.
32553 *
32554 * If you want to use `createStore` without this visual deprecation warning, use
32555 * the `legacy_createStore` import instead:
32556 *
32557 * `import { legacy_createStore as createStore} from 'redux'`
32558 *
32559 */
32560
32561 function createStore(reducer, preloadedState, enhancer) {
32562 var _ref2;
32563
32564 if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
32565 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.');
32566 }
32567
32568 if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
32569 enhancer = preloadedState;
32570 preloadedState = undefined;
32571 }
32572
32573 if (typeof enhancer !== 'undefined') {
32574 if (typeof enhancer !== 'function') {
32575 throw new Error( false ? 0 : "Expected the enhancer to be a function. Instead, received: '" + kindOf(enhancer) + "'");
32576 }
32577
32578 return enhancer(createStore)(reducer, preloadedState);
32579 }
32580
32581 if (typeof reducer !== 'function') {
32582 throw new Error( false ? 0 : "Expected the root reducer to be a function. Instead, received: '" + kindOf(reducer) + "'");
32583 }
32584
32585 var currentReducer = reducer;
32586 var currentState = preloadedState;
32587 var currentListeners = [];
32588 var nextListeners = currentListeners;
32589 var isDispatching = false;
32590 /**
32591 * This makes a shallow copy of currentListeners so we can use
32592 * nextListeners as a temporary list while dispatching.
32593 *
32594 * This prevents any bugs around consumers calling
32595 * subscribe/unsubscribe in the middle of a dispatch.
32596 */
32597
32598 function ensureCanMutateNextListeners() {
32599 if (nextListeners === currentListeners) {
32600 nextListeners = currentListeners.slice();
32601 }
32602 }
32603 /**
32604 * Reads the state tree managed by the store.
32605 *
32606 * @returns {any} The current state tree of your application.
32607 */
32608
32609
32610 function getState() {
32611 if (isDispatching) {
32612 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.');
32613 }
32614
32615 return currentState;
32616 }
32617 /**
32618 * Adds a change listener. It will be called any time an action is dispatched,
32619 * and some part of the state tree may potentially have changed. You may then
32620 * call `getState()` to read the current state tree inside the callback.
32621 *
32622 * You may call `dispatch()` from a change listener, with the following
32623 * caveats:
32624 *
32625 * 1. The subscriptions are snapshotted just before every `dispatch()` call.
32626 * If you subscribe or unsubscribe while the listeners are being invoked, this
32627 * will not have any effect on the `dispatch()` that is currently in progress.
32628 * However, the next `dispatch()` call, whether nested or not, will use a more
32629 * recent snapshot of the subscription list.
32630 *
32631 * 2. The listener should not expect to see all state changes, as the state
32632 * might have been updated multiple times during a nested `dispatch()` before
32633 * the listener is called. It is, however, guaranteed that all subscribers
32634 * registered before the `dispatch()` started will be called with the latest
32635 * state by the time it exits.
32636 *
32637 * @param {Function} listener A callback to be invoked on every dispatch.
32638 * @returns {Function} A function to remove this change listener.
32639 */
32640
32641
32642 function subscribe(listener) {
32643 if (typeof listener !== 'function') {
32644 throw new Error( false ? 0 : "Expected the listener to be a function. Instead, received: '" + kindOf(listener) + "'");
32645 }
32646
32647 if (isDispatching) {
32648 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.');
32649 }
32650
32651 var isSubscribed = true;
32652 ensureCanMutateNextListeners();
32653 nextListeners.push(listener);
32654 return function unsubscribe() {
32655 if (!isSubscribed) {
32656 return;
32657 }
32658
32659 if (isDispatching) {
32660 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.');
32661 }
32662
32663 isSubscribed = false;
32664 ensureCanMutateNextListeners();
32665 var index = nextListeners.indexOf(listener);
32666 nextListeners.splice(index, 1);
32667 currentListeners = null;
32668 };
32669 }
32670 /**
32671 * Dispatches an action. It is the only way to trigger a state change.
32672 *
32673 * The `reducer` function, used to create the store, will be called with the
32674 * current state tree and the given `action`. Its return value will
32675 * be considered the **next** state of the tree, and the change listeners
32676 * will be notified.
32677 *
32678 * The base implementation only supports plain object actions. If you want to
32679 * dispatch a Promise, an Observable, a thunk, or something else, you need to
32680 * wrap your store creating function into the corresponding middleware. For
32681 * example, see the documentation for the `redux-thunk` package. Even the
32682 * middleware will eventually dispatch plain object actions using this method.
32683 *
32684 * @param {Object} action A plain object representing “what changed”. It is
32685 * a good idea to keep actions serializable so you can record and replay user
32686 * sessions, or use the time travelling `redux-devtools`. An action must have
32687 * a `type` property which may not be `undefined`. It is a good idea to use
32688 * string constants for action types.
32689 *
32690 * @returns {Object} For convenience, the same action object you dispatched.
32691 *
32692 * Note that, if you use a custom middleware, it may wrap `dispatch()` to
32693 * return something else (for example, a Promise you can await).
32694 */
32695
32696
32697 function dispatch(action) {
32698 if (!isPlainObject(action)) {
32699 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.");
32700 }
32701
32702 if (typeof action.type === 'undefined') {
32703 throw new Error( false ? 0 : 'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');
32704 }
32705
32706 if (isDispatching) {
32707 throw new Error( false ? 0 : 'Reducers may not dispatch actions.');
32708 }
32709
32710 try {
32711 isDispatching = true;
32712 currentState = currentReducer(currentState, action);
32713 } finally {
32714 isDispatching = false;
32715 }
32716
32717 var listeners = currentListeners = nextListeners;
32718
32719 for (var i = 0; i < listeners.length; i++) {
32720 var listener = listeners[i];
32721 listener();
32722 }
32723
32724 return action;
32725 }
32726 /**
32727 * Replaces the reducer currently used by the store to calculate the state.
32728 *
32729 * You might need this if your app implements code splitting and you want to
32730 * load some of the reducers dynamically. You might also need this if you
32731 * implement a hot reloading mechanism for Redux.
32732 *
32733 * @param {Function} nextReducer The reducer for the store to use instead.
32734 * @returns {void}
32735 */
32736
32737
32738 function replaceReducer(nextReducer) {
32739 if (typeof nextReducer !== 'function') {
32740 throw new Error( false ? 0 : "Expected the nextReducer to be a function. Instead, received: '" + kindOf(nextReducer));
32741 }
32742
32743 currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
32744 // Any reducers that existed in both the new and old rootReducer
32745 // will receive the previous state. This effectively populates
32746 // the new state tree with any relevant data from the old one.
32747
32748 dispatch({
32749 type: ActionTypes.REPLACE
32750 });
32751 }
32752 /**
32753 * Interoperability point for observable/reactive libraries.
32754 * @returns {observable} A minimal observable of state changes.
32755 * For more information, see the observable proposal:
32756 * https://github.com/tc39/proposal-observable
32757 */
32758
32759
32760 function observable() {
32761 var _ref;
32762
32763 var outerSubscribe = subscribe;
32764 return _ref = {
32765 /**
32766 * The minimal observable subscription method.
32767 * @param {Object} observer Any object that can be used as an observer.
32768 * The observer object should have a `next` method.
32769 * @returns {subscription} An object with an `unsubscribe` method that can
32770 * be used to unsubscribe the observable from the store, and prevent further
32771 * emission of values from the observable.
32772 */
32773 subscribe: function subscribe(observer) {
32774 if (typeof observer !== 'object' || observer === null) {
32775 throw new Error( false ? 0 : "Expected the observer to be an object. Instead, received: '" + kindOf(observer) + "'");
32776 }
32777
32778 function observeState() {
32779 if (observer.next) {
32780 observer.next(getState());
32781 }
32782 }
32783
32784 observeState();
32785 var unsubscribe = outerSubscribe(observeState);
32786 return {
32787 unsubscribe: unsubscribe
32788 };
32789 }
32790 }, _ref[$$observable] = function () {
32791 return this;
32792 }, _ref;
32793 } // When a store is created, an "INIT" action is dispatched so that every
32794 // reducer returns their initial state. This effectively populates
32795 // the initial state tree.
32796
32797
32798 dispatch({
32799 type: ActionTypes.INIT
32800 });
32801 return _ref2 = {
32802 dispatch: dispatch,
32803 subscribe: subscribe,
32804 getState: getState,
32805 replaceReducer: replaceReducer
32806 }, _ref2[$$observable] = observable, _ref2;
32807 }
32808 /**
32809 * Creates a Redux store that holds the state tree.
32810 *
32811 * **We recommend using `configureStore` from the
32812 * `@reduxjs/toolkit` package**, which replaces `createStore`:
32813 * **https://redux.js.org/introduction/why-rtk-is-redux-today**
32814 *
32815 * The only way to change the data in the store is to call `dispatch()` on it.
32816 *
32817 * There should only be a single store in your app. To specify how different
32818 * parts of the state tree respond to actions, you may combine several reducers
32819 * into a single reducer function by using `combineReducers`.
32820 *
32821 * @param {Function} reducer A function that returns the next state tree, given
32822 * the current state tree and the action to handle.
32823 *
32824 * @param {any} [preloadedState] The initial state. You may optionally specify it
32825 * to hydrate the state from the server in universal apps, or to restore a
32826 * previously serialized user session.
32827 * If you use `combineReducers` to produce the root reducer function, this must be
32828 * an object with the same shape as `combineReducers` keys.
32829 *
32830 * @param {Function} [enhancer] The store enhancer. You may optionally specify it
32831 * to enhance the store with third-party capabilities such as middleware,
32832 * time travel, persistence, etc. The only store enhancer that ships with Redux
32833 * is `applyMiddleware()`.
32834 *
32835 * @returns {Store} A Redux store that lets you read the state, dispatch actions
32836 * and subscribe to changes.
32837 */
32838
32839 var legacy_createStore = createStore;
32840
32841 /**
32842 * Prints a warning in the console if it exists.
32843 *
32844 * @param {String} message The warning message.
32845 * @returns {void}
32846 */
32847 function warning(message) {
32848 /* eslint-disable no-console */
32849 if (typeof console !== 'undefined' && typeof console.error === 'function') {
32850 console.error(message);
32851 }
32852 /* eslint-enable no-console */
32853
32854
32855 try {
32856 // This error was thrown as a convenience so that if you enable
32857 // "break on all exceptions" in your console,
32858 // it would pause the execution at this line.
32859 throw new Error(message);
32860 } catch (e) {} // eslint-disable-line no-empty
32861
32862 }
32863
32864 function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
32865 var reducerKeys = Object.keys(reducers);
32866 var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
32867
32868 if (reducerKeys.length === 0) {
32869 return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
32870 }
32871
32872 if (!isPlainObject(inputState)) {
32873 return "The " + argumentName + " has unexpected type of \"" + kindOf(inputState) + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\"");
32874 }
32875
32876 var unexpectedKeys = Object.keys(inputState).filter(function (key) {
32877 return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
32878 });
32879 unexpectedKeys.forEach(function (key) {
32880 unexpectedKeyCache[key] = true;
32881 });
32882 if (action && action.type === ActionTypes.REPLACE) return;
32883
32884 if (unexpectedKeys.length > 0) {
32885 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.");
32886 }
32887 }
32888
32889 function assertReducerShape(reducers) {
32890 Object.keys(reducers).forEach(function (key) {
32891 var reducer = reducers[key];
32892 var initialState = reducer(undefined, {
32893 type: ActionTypes.INIT
32894 });
32895
32896 if (typeof initialState === 'undefined') {
32897 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.");
32898 }
32899
32900 if (typeof reducer(undefined, {
32901 type: ActionTypes.PROBE_UNKNOWN_ACTION()
32902 }) === 'undefined') {
32903 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.");
32904 }
32905 });
32906 }
32907 /**
32908 * Turns an object whose values are different reducer functions, into a single
32909 * reducer function. It will call every child reducer, and gather their results
32910 * into a single state object, whose keys correspond to the keys of the passed
32911 * reducer functions.
32912 *
32913 * @param {Object} reducers An object whose values correspond to different
32914 * reducer functions that need to be combined into one. One handy way to obtain
32915 * it is to use ES6 `import * as reducers` syntax. The reducers may never return
32916 * undefined for any action. Instead, they should return their initial state
32917 * if the state passed to them was undefined, and the current state for any
32918 * unrecognized action.
32919 *
32920 * @returns {Function} A reducer function that invokes every reducer inside the
32921 * passed object, and builds a state object with the same shape.
32922 */
32923
32924
32925 function combineReducers(reducers) {
32926 var reducerKeys = Object.keys(reducers);
32927 var finalReducers = {};
32928
32929 for (var i = 0; i < reducerKeys.length; i++) {
32930 var key = reducerKeys[i];
32931
32932 if (true) {
32933 if (typeof reducers[key] === 'undefined') {
32934 warning("No reducer provided for key \"" + key + "\"");
32935 }
32936 }
32937
32938 if (typeof reducers[key] === 'function') {
32939 finalReducers[key] = reducers[key];
32940 }
32941 }
32942
32943 var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
32944 // keys multiple times.
32945
32946 var unexpectedKeyCache;
32947
32948 if (true) {
32949 unexpectedKeyCache = {};
32950 }
32951
32952 var shapeAssertionError;
32953
32954 try {
32955 assertReducerShape(finalReducers);
32956 } catch (e) {
32957 shapeAssertionError = e;
32958 }
32959
32960 return function combination(state, action) {
32961 if (state === void 0) {
32962 state = {};
32963 }
32964
32965 if (shapeAssertionError) {
32966 throw shapeAssertionError;
32967 }
32968
32969 if (true) {
32970 var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
32971
32972 if (warningMessage) {
32973 warning(warningMessage);
32974 }
32975 }
32976
32977 var hasChanged = false;
32978 var nextState = {};
32979
32980 for (var _i = 0; _i < finalReducerKeys.length; _i++) {
32981 var _key = finalReducerKeys[_i];
32982 var reducer = finalReducers[_key];
32983 var previousStateForKey = state[_key];
32984 var nextStateForKey = reducer(previousStateForKey, action);
32985
32986 if (typeof nextStateForKey === 'undefined') {
32987 var actionType = action && action.type;
32988 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.");
32989 }
32990
32991 nextState[_key] = nextStateForKey;
32992 hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
32993 }
32994
32995 hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
32996 return hasChanged ? nextState : state;
32997 };
32998 }
32999
33000 function bindActionCreator(actionCreator, dispatch) {
33001 return function () {
33002 return dispatch(actionCreator.apply(this, arguments));
33003 };
33004 }
33005 /**
33006 * Turns an object whose values are action creators, into an object with the
33007 * same keys, but with every function wrapped into a `dispatch` call so they
33008 * may be invoked directly. This is just a convenience method, as you can call
33009 * `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
33010 *
33011 * For convenience, you can also pass an action creator as the first argument,
33012 * and get a dispatch wrapped function in return.
33013 *
33014 * @param {Function|Object} actionCreators An object whose values are action
33015 * creator functions. One handy way to obtain it is to use ES6 `import * as`
33016 * syntax. You may also pass a single function.
33017 *
33018 * @param {Function} dispatch The `dispatch` function available on your Redux
33019 * store.
33020 *
33021 * @returns {Function|Object} The object mimicking the original object, but with
33022 * every action creator wrapped into the `dispatch` call. If you passed a
33023 * function as `actionCreators`, the return value will also be a single
33024 * function.
33025 */
33026
33027
33028 function bindActionCreators(actionCreators, dispatch) {
33029 if (typeof actionCreators === 'function') {
33030 return bindActionCreator(actionCreators, dispatch);
33031 }
33032
33033 if (typeof actionCreators !== 'object' || actionCreators === null) {
33034 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\"?");
33035 }
33036
33037 var boundActionCreators = {};
33038
33039 for (var key in actionCreators) {
33040 var actionCreator = actionCreators[key];
33041
33042 if (typeof actionCreator === 'function') {
33043 boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
33044 }
33045 }
33046
33047 return boundActionCreators;
33048 }
33049
33050 /**
33051 * Composes single-argument functions from right to left. The rightmost
33052 * function can take multiple arguments as it provides the signature for
33053 * the resulting composite function.
33054 *
33055 * @param {...Function} funcs The functions to compose.
33056 * @returns {Function} A function obtained by composing the argument functions
33057 * from right to left. For example, compose(f, g, h) is identical to doing
33058 * (...args) => f(g(h(...args))).
33059 */
33060 function compose() {
33061 for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
33062 funcs[_key] = arguments[_key];
33063 }
33064
33065 if (funcs.length === 0) {
33066 return function (arg) {
33067 return arg;
33068 };
33069 }
33070
33071 if (funcs.length === 1) {
33072 return funcs[0];
33073 }
33074
33075 return funcs.reduce(function (a, b) {
33076 return function () {
33077 return a(b.apply(void 0, arguments));
33078 };
33079 });
33080 }
33081
33082 /**
33083 * Creates a store enhancer that applies middleware to the dispatch method
33084 * of the Redux store. This is handy for a variety of tasks, such as expressing
33085 * asynchronous actions in a concise manner, or logging every action payload.
33086 *
33087 * See `redux-thunk` package as an example of the Redux middleware.
33088 *
33089 * Because middleware is potentially asynchronous, this should be the first
33090 * store enhancer in the composition chain.
33091 *
33092 * Note that each middleware will be given the `dispatch` and `getState` functions
33093 * as named arguments.
33094 *
33095 * @param {...Function} middlewares The middleware chain to be applied.
33096 * @returns {Function} A store enhancer applying the middleware.
33097 */
33098
33099 function applyMiddleware() {
33100 for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
33101 middlewares[_key] = arguments[_key];
33102 }
33103
33104 return function (createStore) {
33105 return function () {
33106 var store = createStore.apply(void 0, arguments);
33107
33108 var _dispatch = function dispatch() {
33109 throw new Error( false ? 0 : 'Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.');
33110 };
33111
33112 var middlewareAPI = {
33113 getState: store.getState,
33114 dispatch: function dispatch() {
33115 return _dispatch.apply(void 0, arguments);
33116 }
33117 };
33118 var chain = middlewares.map(function (middleware) {
33119 return middleware(middlewareAPI);
33120 });
33121 _dispatch = compose.apply(void 0, chain)(store.dispatch);
33122 return (0,_babel_runtime_helpers_esm_objectSpread2__WEBPACK_IMPORTED_MODULE_0__["default"])((0,_babel_runtime_helpers_esm_objectSpread2__WEBPACK_IMPORTED_MODULE_0__["default"])({}, store), {}, {
33123 dispatch: _dispatch
33124 });
33125 };
33126 };
33127 }
33128
33129
33130
33131
33132 /***/ }),
33133
33134 /***/ "../node_modules/reselect/es/defaultMemoize.js":
33135 /*!*****************************************************!*\
33136 !*** ../node_modules/reselect/es/defaultMemoize.js ***!
33137 \*****************************************************/
33138 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
33139
33140 "use strict";
33141 __webpack_require__.r(__webpack_exports__);
33142 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
33143 /* harmony export */ createCacheKeyComparator: () => (/* binding */ createCacheKeyComparator),
33144 /* harmony export */ defaultEqualityCheck: () => (/* binding */ defaultEqualityCheck),
33145 /* harmony export */ defaultMemoize: () => (/* binding */ defaultMemoize)
33146 /* harmony export */ });
33147 // Cache implementation based on Erik Rasmussen's `lru-memoize`:
33148 // https://github.com/erikras/lru-memoize
33149 var NOT_FOUND = 'NOT_FOUND';
33150
33151 function createSingletonCache(equals) {
33152 var entry;
33153 return {
33154 get: function get(key) {
33155 if (entry && equals(entry.key, key)) {
33156 return entry.value;
33157 }
33158
33159 return NOT_FOUND;
33160 },
33161 put: function put(key, value) {
33162 entry = {
33163 key: key,
33164 value: value
33165 };
33166 },
33167 getEntries: function getEntries() {
33168 return entry ? [entry] : [];
33169 },
33170 clear: function clear() {
33171 entry = undefined;
33172 }
33173 };
33174 }
33175
33176 function createLruCache(maxSize, equals) {
33177 var entries = [];
33178
33179 function get(key) {
33180 var cacheIndex = entries.findIndex(function (entry) {
33181 return equals(key, entry.key);
33182 }); // We found a cached entry
33183
33184 if (cacheIndex > -1) {
33185 var entry = entries[cacheIndex]; // Cached entry not at top of cache, move it to the top
33186
33187 if (cacheIndex > 0) {
33188 entries.splice(cacheIndex, 1);
33189 entries.unshift(entry);
33190 }
33191
33192 return entry.value;
33193 } // No entry found in cache, return sentinel
33194
33195
33196 return NOT_FOUND;
33197 }
33198
33199 function put(key, value) {
33200 if (get(key) === NOT_FOUND) {
33201 // TODO Is unshift slow?
33202 entries.unshift({
33203 key: key,
33204 value: value
33205 });
33206
33207 if (entries.length > maxSize) {
33208 entries.pop();
33209 }
33210 }
33211 }
33212
33213 function getEntries() {
33214 return entries;
33215 }
33216
33217 function clear() {
33218 entries = [];
33219 }
33220
33221 return {
33222 get: get,
33223 put: put,
33224 getEntries: getEntries,
33225 clear: clear
33226 };
33227 }
33228
33229 var defaultEqualityCheck = function defaultEqualityCheck(a, b) {
33230 return a === b;
33231 };
33232 function createCacheKeyComparator(equalityCheck) {
33233 return function areArgumentsShallowlyEqual(prev, next) {
33234 if (prev === null || next === null || prev.length !== next.length) {
33235 return false;
33236 } // Do this in a for loop (and not a `forEach` or an `every`) so we can determine equality as fast as possible.
33237
33238
33239 var length = prev.length;
33240
33241 for (var i = 0; i < length; i++) {
33242 if (!equalityCheck(prev[i], next[i])) {
33243 return false;
33244 }
33245 }
33246
33247 return true;
33248 };
33249 }
33250 // defaultMemoize now supports a configurable cache size with LRU behavior,
33251 // and optional comparison of the result value with existing values
33252 function defaultMemoize(func, equalityCheckOrOptions) {
33253 var providedOptions = typeof equalityCheckOrOptions === 'object' ? equalityCheckOrOptions : {
33254 equalityCheck: equalityCheckOrOptions
33255 };
33256 var _providedOptions$equa = providedOptions.equalityCheck,
33257 equalityCheck = _providedOptions$equa === void 0 ? defaultEqualityCheck : _providedOptions$equa,
33258 _providedOptions$maxS = providedOptions.maxSize,
33259 maxSize = _providedOptions$maxS === void 0 ? 1 : _providedOptions$maxS,
33260 resultEqualityCheck = providedOptions.resultEqualityCheck;
33261 var comparator = createCacheKeyComparator(equalityCheck);
33262 var cache = maxSize === 1 ? createSingletonCache(comparator) : createLruCache(maxSize, comparator); // we reference arguments instead of spreading them for performance reasons
33263
33264 function memoized() {
33265 var value = cache.get(arguments);
33266
33267 if (value === NOT_FOUND) {
33268 // @ts-ignore
33269 value = func.apply(null, arguments);
33270
33271 if (resultEqualityCheck) {
33272 var entries = cache.getEntries();
33273 var matchingEntry = entries.find(function (entry) {
33274 return resultEqualityCheck(entry.value, value);
33275 });
33276
33277 if (matchingEntry) {
33278 value = matchingEntry.value;
33279 }
33280 }
33281
33282 cache.put(arguments, value);
33283 }
33284
33285 return value;
33286 }
33287
33288 memoized.clearCache = function () {
33289 return cache.clear();
33290 };
33291
33292 return memoized;
33293 }
33294
33295 /***/ }),
33296
33297 /***/ "../node_modules/reselect/es/index.js":
33298 /*!********************************************!*\
33299 !*** ../node_modules/reselect/es/index.js ***!
33300 \********************************************/
33301 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
33302
33303 "use strict";
33304 __webpack_require__.r(__webpack_exports__);
33305 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
33306 /* harmony export */ createSelector: () => (/* binding */ createSelector),
33307 /* harmony export */ createSelectorCreator: () => (/* binding */ createSelectorCreator),
33308 /* harmony export */ createStructuredSelector: () => (/* binding */ createStructuredSelector),
33309 /* harmony export */ defaultEqualityCheck: () => (/* reexport safe */ _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultEqualityCheck),
33310 /* harmony export */ defaultMemoize: () => (/* reexport safe */ _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultMemoize)
33311 /* harmony export */ });
33312 /* harmony import */ var _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultMemoize */ "../node_modules/reselect/es/defaultMemoize.js");
33313
33314
33315
33316 function getDependencies(funcs) {
33317 var dependencies = Array.isArray(funcs[0]) ? funcs[0] : funcs;
33318
33319 if (!dependencies.every(function (dep) {
33320 return typeof dep === 'function';
33321 })) {
33322 var dependencyTypes = dependencies.map(function (dep) {
33323 return typeof dep === 'function' ? "function " + (dep.name || 'unnamed') + "()" : typeof dep;
33324 }).join(', ');
33325 throw new Error("createSelector expects all input-selectors to be functions, but received the following types: [" + dependencyTypes + "]");
33326 }
33327
33328 return dependencies;
33329 }
33330
33331 function createSelectorCreator(memoize) {
33332 for (var _len = arguments.length, memoizeOptionsFromArgs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
33333 memoizeOptionsFromArgs[_key - 1] = arguments[_key];
33334 }
33335
33336 var createSelector = function createSelector() {
33337 for (var _len2 = arguments.length, funcs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
33338 funcs[_key2] = arguments[_key2];
33339 }
33340
33341 var _recomputations = 0;
33342
33343 var _lastResult; // Due to the intricacies of rest params, we can't do an optional arg after `...funcs`.
33344 // So, start by declaring the default value here.
33345 // (And yes, the words 'memoize' and 'options' appear too many times in this next sequence.)
33346
33347
33348 var directlyPassedOptions = {
33349 memoizeOptions: undefined
33350 }; // Normally, the result func or "output selector" is the last arg
33351
33352 var resultFunc = funcs.pop(); // If the result func is actually an _object_, assume it's our options object
33353
33354 if (typeof resultFunc === 'object') {
33355 directlyPassedOptions = resultFunc; // and pop the real result func off
33356
33357 resultFunc = funcs.pop();
33358 }
33359
33360 if (typeof resultFunc !== 'function') {
33361 throw new Error("createSelector expects an output function after the inputs, but received: [" + typeof resultFunc + "]");
33362 } // Determine which set of options we're using. Prefer options passed directly,
33363 // but fall back to options given to createSelectorCreator.
33364
33365
33366 var _directlyPassedOption = directlyPassedOptions,
33367 _directlyPassedOption2 = _directlyPassedOption.memoizeOptions,
33368 memoizeOptions = _directlyPassedOption2 === void 0 ? memoizeOptionsFromArgs : _directlyPassedOption2; // Simplifying assumption: it's unlikely that the first options arg of the provided memoizer
33369 // is an array. In most libs I've looked at, it's an equality function or options object.
33370 // Based on that, if `memoizeOptions` _is_ an array, we assume it's a full
33371 // user-provided array of options. Otherwise, it must be just the _first_ arg, and so
33372 // we wrap it in an array so we can apply it.
33373
33374 var finalMemoizeOptions = Array.isArray(memoizeOptions) ? memoizeOptions : [memoizeOptions];
33375 var dependencies = getDependencies(funcs);
33376 var memoizedResultFunc = memoize.apply(void 0, [function recomputationWrapper() {
33377 _recomputations++; // apply arguments instead of spreading for performance.
33378
33379 return resultFunc.apply(null, arguments);
33380 }].concat(finalMemoizeOptions)); // If a selector is called with the exact same arguments we don't need to traverse our dependencies again.
33381
33382 var selector = memoize(function dependenciesChecker() {
33383 var params = [];
33384 var length = dependencies.length;
33385
33386 for (var i = 0; i < length; i++) {
33387 // apply arguments instead of spreading and mutate a local list of params for performance.
33388 // @ts-ignore
33389 params.push(dependencies[i].apply(null, arguments));
33390 } // apply arguments instead of spreading for performance.
33391
33392
33393 _lastResult = memoizedResultFunc.apply(null, params);
33394 return _lastResult;
33395 });
33396 Object.assign(selector, {
33397 resultFunc: resultFunc,
33398 memoizedResultFunc: memoizedResultFunc,
33399 dependencies: dependencies,
33400 lastResult: function lastResult() {
33401 return _lastResult;
33402 },
33403 recomputations: function recomputations() {
33404 return _recomputations;
33405 },
33406 resetRecomputations: function resetRecomputations() {
33407 return _recomputations = 0;
33408 }
33409 });
33410 return selector;
33411 }; // @ts-ignore
33412
33413
33414 return createSelector;
33415 }
33416 var createSelector = /* #__PURE__ */createSelectorCreator(_defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultMemoize);
33417 // Manual definition of state and output arguments
33418 var createStructuredSelector = function createStructuredSelector(selectors, selectorCreator) {
33419 if (selectorCreator === void 0) {
33420 selectorCreator = createSelector;
33421 }
33422
33423 if (typeof selectors !== 'object') {
33424 throw new Error('createStructuredSelector expects first argument to be an object ' + ("where each property is a selector, instead received a " + typeof selectors));
33425 }
33426
33427 var objectKeys = Object.keys(selectors);
33428 var resultSelector = selectorCreator( // @ts-ignore
33429 objectKeys.map(function (key) {
33430 return selectors[key];
33431 }), function () {
33432 for (var _len3 = arguments.length, values = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
33433 values[_key3] = arguments[_key3];
33434 }
33435
33436 return values.reduce(function (composition, value, index) {
33437 composition[objectKeys[index]] = value;
33438 return composition;
33439 }, {});
33440 });
33441 return resultSelector;
33442 };
33443
33444 /***/ }),
33445
33446 /***/ "@wordpress/i18n":
33447 /*!**************************!*\
33448 !*** external "wp.i18n" ***!
33449 \**************************/
33450 /***/ ((module) => {
33451
33452 "use strict";
33453 module.exports = wp.i18n;
33454
33455 /***/ })
33456
33457 /******/ });
33458 /************************************************************************/
33459 /******/ // The module cache
33460 /******/ var __webpack_module_cache__ = {};
33461 /******/
33462 /******/ // The require function
33463 /******/ function __webpack_require__(moduleId) {
33464 /******/ // Check if module is in cache
33465 /******/ var cachedModule = __webpack_module_cache__[moduleId];
33466 /******/ if (cachedModule !== undefined) {
33467 /******/ return cachedModule.exports;
33468 /******/ }
33469 /******/ // Create a new module (and put it into the cache)
33470 /******/ var module = __webpack_module_cache__[moduleId] = {
33471 /******/ // no module.id needed
33472 /******/ // no module.loaded needed
33473 /******/ exports: {}
33474 /******/ };
33475 /******/
33476 /******/ // Execute the module function
33477 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
33478 /******/
33479 /******/ // Return the exports of the module
33480 /******/ return module.exports;
33481 /******/ }
33482 /******/
33483 /************************************************************************/
33484 /******/ /* webpack/runtime/define property getters */
33485 /******/ (() => {
33486 /******/ // define getter functions for harmony exports
33487 /******/ __webpack_require__.d = (exports, definition) => {
33488 /******/ for(var key in definition) {
33489 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
33490 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
33491 /******/ }
33492 /******/ }
33493 /******/ };
33494 /******/ })();
33495 /******/
33496 /******/ /* webpack/runtime/global */
33497 /******/ (() => {
33498 /******/ __webpack_require__.g = (function() {
33499 /******/ if (typeof globalThis === 'object') return globalThis;
33500 /******/ try {
33501 /******/ return this || new Function('return this')();
33502 /******/ } catch (e) {
33503 /******/ if (typeof window === 'object') return window;
33504 /******/ }
33505 /******/ })();
33506 /******/ })();
33507 /******/
33508 /******/ /* webpack/runtime/hasOwnProperty shorthand */
33509 /******/ (() => {
33510 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
33511 /******/ })();
33512 /******/
33513 /******/ /* webpack/runtime/make namespace object */
33514 /******/ (() => {
33515 /******/ // define __esModule on exports
33516 /******/ __webpack_require__.r = (exports) => {
33517 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
33518 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
33519 /******/ }
33520 /******/ Object.defineProperty(exports, '__esModule', { value: true });
33521 /******/ };
33522 /******/ })();
33523 /******/
33524 /************************************************************************/
33525 var __webpack_exports__ = {};
33526 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
33527 (() => {
33528 "use strict";
33529 /*!******************************************!*\
33530 !*** ../core/common/assets/js/common.js ***!
33531 \******************************************/
33532
33533
33534 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
33535 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
33536 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
33537 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
33538 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
33539 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
33540 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
33541 var _helpers = _interopRequireDefault(__webpack_require__(/*! ./utils/helpers */ "../core/common/assets/js/utils/helpers.js"));
33542 var _storage = _interopRequireDefault(__webpack_require__(/*! ./utils/storage */ "../core/common/assets/js/utils/storage.js"));
33543 var _debug = _interopRequireDefault(__webpack_require__(/*! ./utils/debug */ "../core/common/assets/js/utils/debug.js"));
33544 var _ajax = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/ajax/assets/js/ajax */ "../core/common/modules/ajax/assets/js/ajax.js"));
33545 var _finder = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/finder/assets/js/finder */ "../core/common/modules/finder/assets/js/finder.js"));
33546 var _connect = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/connect/assets/js/connect */ "../core/common/modules/connect/assets/js/connect.js"));
33547 var _component = _interopRequireDefault(__webpack_require__(/*! ./components/wordpress/component */ "../core/common/assets/js/components/wordpress/component.js"));
33548 var _component2 = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/event-tracker/assets/js/data/component */ "../core/common/modules/event-tracker/assets/js/data/component.js"));
33549 var _events = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/event-tracker/assets/js/events */ "../core/common/modules/event-tracker/assets/js/events.js"));
33550 var _module = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/events-manager/assets/js/module */ "../core/common/modules/events-manager/assets/js/module.js"));
33551 var _notifications = _interopRequireDefault(__webpack_require__(/*! elementor-utils/notifications */ "../assets/dev/js/utils/notifications.js"));
33552 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)); }
33553 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
33554 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; }
33555 var ElementorCommonApp = /*#__PURE__*/function (_elementorModules$Vie) {
33556 function ElementorCommonApp() {
33557 (0, _classCallCheck2.default)(this, ElementorCommonApp);
33558 return _callSuper(this, ElementorCommonApp, arguments);
33559 }
33560 (0, _inherits2.default)(ElementorCommonApp, _elementorModules$Vie);
33561 return (0, _createClass2.default)(ElementorCommonApp, [{
33562 key: "setMarionetteTemplateCompiler",
33563 value: function setMarionetteTemplateCompiler() {
33564 Marionette.TemplateCache.prototype.compileTemplate = function (rawTemplate, options) {
33565 options = {
33566 evaluate: /<#([\s\S]+?)#>/g,
33567 interpolate: /{{{([\s\S]+?)}}}/g,
33568 escape: /{{([^}]+?)}}(?!})/g
33569 };
33570 return _.template(rawTemplate, options);
33571 };
33572 }
33573 }, {
33574 key: "getDefaultElements",
33575 value: function getDefaultElements() {
33576 return {
33577 $window: jQuery(window),
33578 $document: jQuery(document),
33579 $body: jQuery(document.body)
33580 };
33581 }
33582 }, {
33583 key: "initComponents",
33584 value: function initComponents() {
33585 this.events = new _events.default();
33586 this.eventsManager = new _module.default();
33587 this.debug = new _debug.default();
33588 this.helpers = new _helpers.default();
33589 this.storage = new _storage.default();
33590 this.dialogsManager = new DialogsManager.Instance();
33591 this.notifications = new _notifications.default();
33592 this.api = window.$e;
33593 $e.components.register(new _component2.default());
33594 elementorCommon.elements.$window.on('elementor:init-components', function () {
33595 $e.components.register(new _component.default());
33596 });
33597 this.initModules();
33598 }
33599 }, {
33600 key: "initModules",
33601 value: function initModules() {
33602 var _this = this;
33603 var activeModules = this.config.activeModules;
33604 var modules = {
33605 ajax: _ajax.default,
33606 finder: _finder.default,
33607 connect: _connect.default
33608 };
33609 activeModules.forEach(function (name) {
33610 if (modules[name]) {
33611 _this[name] = new modules[name](_this.config[name]);
33612 }
33613 });
33614 }
33615 }, {
33616 key: "compileArrayTemplateArgs",
33617 value: function compileArrayTemplateArgs(template, templateArgs) {
33618 return template.replace(/%(?:(\d+)\$)?s/g, function (match, number) {
33619 if (!number) {
33620 number = 1;
33621 }
33622 number--;
33623 return undefined !== templateArgs[number] ? templateArgs[number] : match;
33624 });
33625 }
33626 }, {
33627 key: "compileObjectTemplateArgs",
33628 value: function compileObjectTemplateArgs(template, templateArgs) {
33629 return template.replace(/{{(?:([ \w]+))}}/g, function (match, name) {
33630 return templateArgs[name] ? templateArgs[name] : match;
33631 });
33632 }
33633 }, {
33634 key: "compileTemplate",
33635 value: function compileTemplate(template, templateArgs) {
33636 return jQuery.isPlainObject(templateArgs) ? this.compileObjectTemplateArgs(template, templateArgs) : this.compileArrayTemplateArgs(template, templateArgs);
33637 }
33638 }, {
33639 key: "translate",
33640 value: function translate(stringKey, context, templateArgs, i18nStack) {
33641 if (context) {
33642 i18nStack = this.config[context].i18n;
33643 }
33644 if (!i18nStack) {
33645 i18nStack = this.config.i18n;
33646 }
33647 var string = i18nStack[stringKey];
33648 if (undefined === string) {
33649 string = stringKey;
33650 }
33651 if (templateArgs) {
33652 string = this.compileTemplate(string, templateArgs);
33653 }
33654 return string;
33655 }
33656 }, {
33657 key: "onInit",
33658 value: function onInit() {
33659 _superPropGet(ElementorCommonApp, "onInit", this, 3)([]);
33660 this.config = elementorCommonConfig;
33661 this.setMarionetteTemplateCompiler();
33662 }
33663 }]);
33664 }(elementorModules.ViewModule);
33665 window.elementorCommon = new ElementorCommonApp();
33666 elementorCommon.initComponents();
33667 })();
33668
33669 /******/ })()
33670 ;
33671 //# sourceMappingURL=common.js.map