@salla.sa/twilight-components 2.12.1 → 2.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/cjs/app-globals-9ad08b7a.js +4215 -0
  2. package/dist/cjs/app-globals-9ad08b7a.js.map +1 -0
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/salla-add-product-button_40.cjs.entry.js +3 -3
  5. package/dist/cjs/salla-add-product-button_40.cjs.entry.js.map +1 -1
  6. package/dist/cjs/twilight.cjs.js +1 -1
  7. package/dist/collection/components/salla-gifting/salla-gifting.js +3 -3
  8. package/dist/collection/components/salla-gifting/salla-gifting.js.map +1 -1
  9. package/dist/components/_commonjsHelpers.js +1 -1
  10. package/dist/components/index.js +3 -3362
  11. package/dist/components/index.js.map +1 -1
  12. package/dist/components/salla-file-upload2.js +1 -1
  13. package/dist/components/salla-gifting.js +3 -3
  14. package/dist/components/salla-gifting.js.map +1 -1
  15. package/dist/components/salla-tel-input2.js +1 -1
  16. package/dist/esm/{_commonjsHelpers-1415ffd3.js → _commonjsHelpers-9adcfb67.js} +2 -2
  17. package/dist/esm/_commonjsHelpers-9adcfb67.js.map +1 -0
  18. package/dist/esm/app-globals-d0d32791.js +4213 -0
  19. package/dist/esm/app-globals-d0d32791.js.map +1 -0
  20. package/dist/esm/loader.js +2 -2
  21. package/dist/esm/salla-add-product-button_40.entry.js +4 -4
  22. package/dist/esm/salla-add-product-button_40.entry.js.map +1 -1
  23. package/dist/esm/twilight.js +2 -2
  24. package/dist/esm-es5/{_commonjsHelpers-1415ffd3.js → _commonjsHelpers-9adcfb67.js} +2 -2
  25. package/dist/esm-es5/app-globals-d0d32791.js +25 -0
  26. package/dist/esm-es5/app-globals-d0d32791.js.map +1 -0
  27. package/dist/esm-es5/loader.js +1 -1
  28. package/dist/esm-es5/salla-add-product-button_40.entry.js +2 -2
  29. package/dist/esm-es5/salla-add-product-button_40.entry.js.map +1 -1
  30. package/dist/esm-es5/twilight.js +1 -1
  31. package/dist/twilight/{p-af908ac9.entry.js → p-0e716419.entry.js} +3 -3
  32. package/dist/twilight/{p-af908ac9.entry.js.map → p-0e716419.entry.js.map} +1 -1
  33. package/dist/twilight/{p-23ba159f.system.js → p-671591bd.system.js} +2 -2
  34. package/dist/twilight/{p-9beb6b7b.system.js → p-a292baff.system.js} +2 -2
  35. package/dist/twilight/p-aa8e58b9.js +25 -0
  36. package/dist/twilight/p-aa8e58b9.js.map +1 -0
  37. package/dist/twilight/p-bd2b7381.system.js +25 -0
  38. package/dist/twilight/p-bd2b7381.system.js.map +1 -0
  39. package/dist/twilight/{p-5b865984.system.entry.js → p-ee9a8735.system.entry.js} +3 -3
  40. package/dist/twilight/{p-5b865984.system.entry.js.map → p-ee9a8735.system.entry.js.map} +1 -1
  41. package/dist/twilight/{p-f84bae34.js → p-eed6da4c.js} +2 -2
  42. package/dist/twilight/twilight.esm.js +1 -1
  43. package/dist/twilight/twilight.js +1 -1
  44. package/package.json +3 -3
  45. package/dist/cjs/app-globals-6dd47580.js +0 -7574
  46. package/dist/cjs/app-globals-6dd47580.js.map +0 -1
  47. package/dist/esm/_commonjsHelpers-1415ffd3.js.map +0 -1
  48. package/dist/esm/app-globals-21b11ff1.js +0 -7572
  49. package/dist/esm/app-globals-21b11ff1.js.map +0 -1
  50. package/dist/esm-es5/app-globals-21b11ff1.js +0 -25
  51. package/dist/esm-es5/app-globals-21b11ff1.js.map +0 -1
  52. package/dist/twilight/p-3e30b764.system.js +0 -25
  53. package/dist/twilight/p-3e30b764.system.js.map +0 -1
  54. package/dist/twilight/p-fc2dbb78.js +0 -25
  55. package/dist/twilight/p-fc2dbb78.js.map +0 -1
  56. /package/dist/esm-es5/{_commonjsHelpers-1415ffd3.js.map → _commonjsHelpers-9adcfb67.js.map} +0 -0
  57. /package/dist/twilight/{p-23ba159f.system.js.map → p-671591bd.system.js.map} +0 -0
  58. /package/dist/twilight/{p-9beb6b7b.system.js.map → p-a292baff.system.js.map} +0 -0
  59. /package/dist/twilight/{p-f84bae34.js.map → p-eed6da4c.js.map} +0 -0
@@ -0,0 +1,4215 @@
1
+ /*!
2
+ * Crafted with ❤ by Salla
3
+ */
4
+ 'use strict';
5
+
6
+ const _commonjsHelpers = require('./_commonjsHelpers-691dd63b.js');
7
+
8
+ var evEmitter = _commonjsHelpers.createCommonjsModule(function (module) {
9
+ /**
10
+ * EvEmitter v2.1.1
11
+ * Lil' event emitter
12
+ * MIT License
13
+ */
14
+
15
+ ( function( global, factory ) {
16
+ // universal module definition
17
+ if ( module.exports ) {
18
+ // CommonJS - Browserify, Webpack
19
+ module.exports = factory();
20
+ } else {
21
+ // Browser globals
22
+ global.EvEmitter = factory();
23
+ }
24
+
25
+ }( typeof window != 'undefined' ? window : _commonjsHelpers.commonjsGlobal, function() {
26
+
27
+ function EvEmitter() {}
28
+
29
+ let proto = EvEmitter.prototype;
30
+
31
+ proto.on = function( eventName, listener ) {
32
+ if ( !eventName || !listener ) return this;
33
+
34
+ // set events hash
35
+ let events = this._events = this._events || {};
36
+ // set listeners array
37
+ let listeners = events[ eventName ] = events[ eventName ] || [];
38
+ // only add once
39
+ if ( !listeners.includes( listener ) ) {
40
+ listeners.push( listener );
41
+ }
42
+
43
+ return this;
44
+ };
45
+
46
+ proto.once = function( eventName, listener ) {
47
+ if ( !eventName || !listener ) return this;
48
+
49
+ // add event
50
+ this.on( eventName, listener );
51
+ // set once flag
52
+ // set onceEvents hash
53
+ let onceEvents = this._onceEvents = this._onceEvents || {};
54
+ // set onceListeners object
55
+ let onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || {};
56
+ // set flag
57
+ onceListeners[ listener ] = true;
58
+
59
+ return this;
60
+ };
61
+
62
+ proto.off = function( eventName, listener ) {
63
+ let listeners = this._events && this._events[ eventName ];
64
+ if ( !listeners || !listeners.length ) return this;
65
+
66
+ let index = listeners.indexOf( listener );
67
+ if ( index != -1 ) {
68
+ listeners.splice( index, 1 );
69
+ }
70
+
71
+ return this;
72
+ };
73
+
74
+ proto.emitEvent = function( eventName, args ) {
75
+ let listeners = this._events && this._events[ eventName ];
76
+ if ( !listeners || !listeners.length ) return this;
77
+
78
+ // copy over to avoid interference if .off() in listener
79
+ listeners = listeners.slice( 0 );
80
+ args = args || [];
81
+ // once stuff
82
+ let onceListeners = this._onceEvents && this._onceEvents[ eventName ];
83
+
84
+ for ( let listener of listeners ) {
85
+ let isOnce = onceListeners && onceListeners[ listener ];
86
+ if ( isOnce ) {
87
+ // remove listener
88
+ // remove before trigger to prevent recursion
89
+ this.off( eventName, listener );
90
+ // unset once flag
91
+ delete onceListeners[ listener ];
92
+ }
93
+ // trigger listener
94
+ listener.apply( this, args );
95
+ }
96
+
97
+ return this;
98
+ };
99
+
100
+ proto.allOff = function() {
101
+ delete this._events;
102
+ delete this._onceEvents;
103
+ return this;
104
+ };
105
+
106
+ return EvEmitter;
107
+
108
+ } ) );
109
+ });
110
+
111
+ var utils$1 = _commonjsHelpers.createCommonjsModule(function (module) {
112
+ /**
113
+ * Fizzy UI utils v3.0.0
114
+ * MIT license
115
+ */
116
+
117
+ ( function( global, factory ) {
118
+ // universal module definition
119
+ if ( module.exports ) {
120
+ // CommonJS
121
+ module.exports = factory( global );
122
+ } else {
123
+ // browser global
124
+ global.fizzyUIUtils = factory( global );
125
+ }
126
+
127
+ }( _commonjsHelpers.commonjsGlobal, function factory( global ) {
128
+
129
+ let utils = {};
130
+
131
+ // ----- extend ----- //
132
+
133
+ // extends objects
134
+ utils.extend = function( a, b ) {
135
+ return Object.assign( a, b );
136
+ };
137
+
138
+ // ----- modulo ----- //
139
+
140
+ utils.modulo = function( num, div ) {
141
+ return ( ( num % div ) + div ) % div;
142
+ };
143
+
144
+ // ----- makeArray ----- //
145
+
146
+ // turn element or nodeList into an array
147
+ utils.makeArray = function( obj ) {
148
+ // use object if already an array
149
+ if ( Array.isArray( obj ) ) return obj;
150
+
151
+ // return empty array if undefined or null. #6
152
+ if ( obj === null || obj === undefined ) return [];
153
+
154
+ let isArrayLike = typeof obj == 'object' && typeof obj.length == 'number';
155
+ // convert nodeList to array
156
+ if ( isArrayLike ) return [ ...obj ];
157
+
158
+ // array of single index
159
+ return [ obj ];
160
+ };
161
+
162
+ // ----- removeFrom ----- //
163
+
164
+ utils.removeFrom = function( ary, obj ) {
165
+ let index = ary.indexOf( obj );
166
+ if ( index != -1 ) {
167
+ ary.splice( index, 1 );
168
+ }
169
+ };
170
+
171
+ // ----- getParent ----- //
172
+
173
+ utils.getParent = function( elem, selector ) {
174
+ while ( elem.parentNode && elem != document.body ) {
175
+ elem = elem.parentNode;
176
+ if ( elem.matches( selector ) ) return elem;
177
+ }
178
+ };
179
+
180
+ // ----- getQueryElement ----- //
181
+
182
+ // use element as selector string
183
+ utils.getQueryElement = function( elem ) {
184
+ if ( typeof elem == 'string' ) {
185
+ return document.querySelector( elem );
186
+ }
187
+ return elem;
188
+ };
189
+
190
+ // ----- handleEvent ----- //
191
+
192
+ // enable .ontype to trigger from .addEventListener( elem, 'type' )
193
+ utils.handleEvent = function( event ) {
194
+ let method = 'on' + event.type;
195
+ if ( this[ method ] ) {
196
+ this[ method ]( event );
197
+ }
198
+ };
199
+
200
+ // ----- filterFindElements ----- //
201
+
202
+ utils.filterFindElements = function( elems, selector ) {
203
+ // make array of elems
204
+ elems = utils.makeArray( elems );
205
+
206
+ return elems
207
+ // check that elem is an actual element
208
+ .filter( ( elem ) => elem instanceof HTMLElement )
209
+ .reduce( ( ffElems, elem ) => {
210
+ // add elem if no selector
211
+ if ( !selector ) {
212
+ ffElems.push( elem );
213
+ return ffElems;
214
+ }
215
+ // filter & find items if we have a selector
216
+ // filter
217
+ if ( elem.matches( selector ) ) {
218
+ ffElems.push( elem );
219
+ }
220
+ // find children
221
+ let childElems = elem.querySelectorAll( selector );
222
+ // concat childElems to filterFound array
223
+ ffElems = ffElems.concat( ...childElems );
224
+ return ffElems;
225
+ }, [] );
226
+ };
227
+
228
+ // ----- debounceMethod ----- //
229
+
230
+ utils.debounceMethod = function( _class, methodName, threshold ) {
231
+ threshold = threshold || 100;
232
+ // original method
233
+ let method = _class.prototype[ methodName ];
234
+ let timeoutName = methodName + 'Timeout';
235
+
236
+ _class.prototype[ methodName ] = function() {
237
+ clearTimeout( this[ timeoutName ] );
238
+
239
+ let args = arguments;
240
+ this[ timeoutName ] = setTimeout( () => {
241
+ method.apply( this, args );
242
+ delete this[ timeoutName ];
243
+ }, threshold );
244
+ };
245
+ };
246
+
247
+ // ----- docReady ----- //
248
+
249
+ utils.docReady = function( onDocReady ) {
250
+ let readyState = document.readyState;
251
+ if ( readyState == 'complete' || readyState == 'interactive' ) {
252
+ // do async to allow for other scripts to run. metafizzy/flickity#441
253
+ setTimeout( onDocReady );
254
+ } else {
255
+ document.addEventListener( 'DOMContentLoaded', onDocReady );
256
+ }
257
+ };
258
+
259
+ // ----- htmlInit ----- //
260
+
261
+ // http://bit.ly/3oYLusc
262
+ utils.toDashed = function( str ) {
263
+ return str.replace( /(.)([A-Z])/g, function( match, $1, $2 ) {
264
+ return $1 + '-' + $2;
265
+ } ).toLowerCase();
266
+ };
267
+
268
+ let console = global.console;
269
+
270
+ // allow user to initialize classes via [data-namespace] or .js-namespace class
271
+ // htmlInit( Widget, 'widgetName' )
272
+ // options are parsed from data-namespace-options
273
+ utils.htmlInit = function( WidgetClass, namespace ) {
274
+ utils.docReady( function() {
275
+ let dashedNamespace = utils.toDashed( namespace );
276
+ let dataAttr = 'data-' + dashedNamespace;
277
+ let dataAttrElems = document.querySelectorAll( `[${dataAttr}]` );
278
+ let jQuery = global.jQuery;
279
+
280
+ [ ...dataAttrElems ].forEach( ( elem ) => {
281
+ let attr = elem.getAttribute( dataAttr );
282
+ let options;
283
+ try {
284
+ options = attr && JSON.parse( attr );
285
+ } catch ( error ) {
286
+ // log error, do not initialize
287
+ if ( console ) {
288
+ console.error( `Error parsing ${dataAttr} on ${elem.className}: ${error}` );
289
+ }
290
+ return;
291
+ }
292
+ // initialize
293
+ let instance = new WidgetClass( elem, options );
294
+ // make available via $().data('namespace')
295
+ if ( jQuery ) {
296
+ jQuery.data( elem, namespace, instance );
297
+ }
298
+ } );
299
+
300
+ } );
301
+ };
302
+
303
+ // ----- ----- //
304
+
305
+ return utils;
306
+
307
+ } ) );
308
+ });
309
+
310
+ var core = _commonjsHelpers.createCommonjsModule(function (module) {
311
+ // core
312
+ ( function( window, factory ) {
313
+ // universal module definition
314
+ if ( module.exports ) {
315
+ // CommonJS
316
+ module.exports = factory(
317
+ window,
318
+ evEmitter,
319
+ utils$1,
320
+ );
321
+ } else {
322
+ // browser global
323
+ window.InfiniteScroll = factory(
324
+ window,
325
+ window.EvEmitter,
326
+ window.fizzyUIUtils,
327
+ );
328
+ }
329
+
330
+ }( window, function factory( window, EvEmitter, utils ) {
331
+
332
+ let jQuery = window.jQuery;
333
+ // internal store of all InfiniteScroll intances
334
+ let instances = {};
335
+
336
+ function InfiniteScroll( element, options ) {
337
+ let queryElem = utils.getQueryElement( element );
338
+
339
+ if ( !queryElem ) {
340
+ console.error( 'Bad element for InfiniteScroll: ' + ( queryElem || element ) );
341
+ return;
342
+ }
343
+ element = queryElem;
344
+ // do not initialize twice on same element
345
+ if ( element.infiniteScrollGUID ) {
346
+ let instance = instances[ element.infiniteScrollGUID ];
347
+ instance.option( options );
348
+ return instance;
349
+ }
350
+
351
+ this.element = element;
352
+ // options
353
+ this.options = { ...InfiniteScroll.defaults };
354
+ this.option( options );
355
+ // add jQuery
356
+ if ( jQuery ) {
357
+ this.$element = jQuery( this.element );
358
+ }
359
+
360
+ this.create();
361
+ }
362
+
363
+ // defaults
364
+ InfiniteScroll.defaults = {
365
+ // path: null,
366
+ // hideNav: null,
367
+ // debug: false,
368
+ };
369
+
370
+ // create & destroy methods
371
+ InfiniteScroll.create = {};
372
+ InfiniteScroll.destroy = {};
373
+
374
+ let proto = InfiniteScroll.prototype;
375
+ // inherit EvEmitter
376
+ Object.assign( proto, EvEmitter.prototype );
377
+
378
+ // -------------------------- -------------------------- //
379
+
380
+ // globally unique identifiers
381
+ let GUID = 0;
382
+
383
+ proto.create = function() {
384
+ // create core
385
+ // add id for InfiniteScroll.data
386
+ let id = this.guid = ++GUID;
387
+ this.element.infiniteScrollGUID = id; // expando
388
+ instances[ id ] = this; // associate via id
389
+ // properties
390
+ this.pageIndex = 1; // default to first page
391
+ this.loadCount = 0;
392
+ this.updateGetPath();
393
+ // bail if getPath not set, or returns falsey #776
394
+ let hasPath = this.getPath && this.getPath();
395
+ if ( !hasPath ) {
396
+ console.error('Disabling InfiniteScroll');
397
+ return;
398
+ }
399
+ this.updateGetAbsolutePath();
400
+ this.log( 'initialized', [ this.element.className ] );
401
+ this.callOnInit();
402
+ // create features
403
+ for ( let method in InfiniteScroll.create ) {
404
+ InfiniteScroll.create[ method ].call( this );
405
+ }
406
+ };
407
+
408
+ proto.option = function( opts ) {
409
+ Object.assign( this.options, opts );
410
+ };
411
+
412
+ // call onInit option, used for binding events on init
413
+ proto.callOnInit = function() {
414
+ let onInit = this.options.onInit;
415
+ if ( onInit ) {
416
+ onInit.call( this, this );
417
+ }
418
+ };
419
+
420
+ // ----- events ----- //
421
+
422
+ proto.dispatchEvent = function( type, event, args ) {
423
+ this.log( type, args );
424
+ let emitArgs = event ? [ event ].concat( args ) : args;
425
+ this.emitEvent( type, emitArgs );
426
+ // trigger jQuery event
427
+ if ( !jQuery || !this.$element ) {
428
+ return;
429
+ }
430
+ // namespace jQuery event
431
+ type += '.infiniteScroll';
432
+ let $event = type;
433
+ if ( event ) {
434
+ // create jQuery event
435
+ /* eslint-disable-next-line new-cap */
436
+ let jQEvent = jQuery.Event( event );
437
+ jQEvent.type = type;
438
+ $event = jQEvent;
439
+ }
440
+ this.$element.trigger( $event, args );
441
+ };
442
+
443
+ let loggers = {
444
+ initialized: ( className ) => `on ${className}`,
445
+ request: ( path ) => `URL: ${path}`,
446
+ load: ( response, path ) => `${response.title || ''}. URL: ${path}`,
447
+ error: ( error, path ) => `${error}. URL: ${path}`,
448
+ append: ( response, path, items ) => `${items.length} items. URL: ${path}`,
449
+ last: ( response, path ) => `URL: ${path}`,
450
+ history: ( title, path ) => `URL: ${path}`,
451
+ pageIndex: function( index, origin ) {
452
+ return `current page determined to be: ${index} from ${origin}`;
453
+ },
454
+ };
455
+
456
+ // log events
457
+ proto.log = function( type, args ) {
458
+ if ( !this.options.debug ) return;
459
+
460
+ let message = `[InfiniteScroll] ${type}`;
461
+ let logger = loggers[ type ];
462
+ if ( logger ) message += '. ' + logger.apply( this, args );
463
+ console.log( message );
464
+ };
465
+
466
+ // -------------------------- methods used amoung features -------------------------- //
467
+
468
+ proto.updateMeasurements = function() {
469
+ this.windowHeight = window.innerHeight;
470
+ let rect = this.element.getBoundingClientRect();
471
+ this.top = rect.top + window.scrollY;
472
+ };
473
+
474
+ proto.updateScroller = function() {
475
+ let elementScroll = this.options.elementScroll;
476
+ if ( !elementScroll ) {
477
+ // default, use window
478
+ this.scroller = window;
479
+ return;
480
+ }
481
+ // if true, set to element, otherwise use option
482
+ this.scroller = elementScroll === true ? this.element :
483
+ utils.getQueryElement( elementScroll );
484
+ if ( !this.scroller ) {
485
+ throw new Error(`Unable to find elementScroll: ${elementScroll}`);
486
+ }
487
+ };
488
+
489
+ // -------------------------- page path -------------------------- //
490
+
491
+ proto.updateGetPath = function() {
492
+ let optPath = this.options.path;
493
+ if ( !optPath ) {
494
+ console.error(`InfiniteScroll path option required. Set as: ${optPath}`);
495
+ return;
496
+ }
497
+ // function
498
+ let type = typeof optPath;
499
+ if ( type == 'function' ) {
500
+ this.getPath = optPath;
501
+ return;
502
+ }
503
+ // template string: '/pages/{{#}}.html'
504
+ let templateMatch = type == 'string' && optPath.match('{{#}}');
505
+ if ( templateMatch ) {
506
+ this.updateGetPathTemplate( optPath );
507
+ return;
508
+ }
509
+ // selector: '.next-page-selector'
510
+ this.updateGetPathSelector( optPath );
511
+ };
512
+
513
+ proto.updateGetPathTemplate = function( optPath ) {
514
+ // set getPath with template string
515
+ this.getPath = () => {
516
+ let nextIndex = this.pageIndex + 1;
517
+ return optPath.replace( '{{#}}', nextIndex );
518
+ };
519
+ // get pageIndex from location
520
+ // convert path option into regex to look for pattern in location
521
+ // escape query (?) in url, allows for parsing GET parameters
522
+ let regexString = optPath
523
+ .replace( /(\\\?|\?)/, '\\?' )
524
+ .replace( '{{#}}', '(\\d\\d?\\d?)' );
525
+ let templateRe = new RegExp( regexString );
526
+ let match = location.href.match( templateRe );
527
+
528
+ if ( match ) {
529
+ this.pageIndex = parseInt( match[1], 10 );
530
+ this.log( 'pageIndex', [ this.pageIndex, 'template string' ] );
531
+ }
532
+ };
533
+
534
+ let pathRegexes = [
535
+ // WordPress & Tumblr - example.com/page/2
536
+ // Jekyll - example.com/page2
537
+ /^(.*?\/?page\/?)(\d\d?\d?)(.*?$)/,
538
+ // Drupal - example.com/?page=1
539
+ /^(.*?\/?\?page=)(\d\d?\d?)(.*?$)/,
540
+ // catch all, last occurence of a number
541
+ /(.*?)(\d\d?\d?)(?!.*\d)(.*?$)/,
542
+ ];
543
+
544
+ // try matching href to pathRegexes patterns
545
+ let getPathParts = InfiniteScroll.getPathParts = function( href ) {
546
+ if ( !href ) return;
547
+ for ( let regex of pathRegexes ) {
548
+ let match = href.match( regex );
549
+ if ( match ) {
550
+ let [ , begin, index, end ] = match;
551
+ return { begin, index, end };
552
+ }
553
+ }
554
+ };
555
+
556
+ proto.updateGetPathSelector = function( optPath ) {
557
+ // parse href of link: '.next-page-link'
558
+ let hrefElem = document.querySelector( optPath );
559
+ if ( !hrefElem ) {
560
+ console.error(`Bad InfiniteScroll path option. Next link not found: ${optPath}`);
561
+ return;
562
+ }
563
+
564
+ let href = hrefElem.getAttribute('href');
565
+ let pathParts = getPathParts( href );
566
+ if ( !pathParts ) {
567
+ console.error(`InfiniteScroll unable to parse next link href: ${href}`);
568
+ return;
569
+ }
570
+
571
+ let { begin, index, end } = pathParts;
572
+ this.isPathSelector = true; // flag for checkLastPage()
573
+ this.getPath = () => begin + ( this.pageIndex + 1 ) + end;
574
+ // get pageIndex from href
575
+ this.pageIndex = parseInt( index, 10 ) - 1;
576
+ this.log( 'pageIndex', [ this.pageIndex, 'next link' ] );
577
+ };
578
+
579
+ proto.updateGetAbsolutePath = function() {
580
+ let path = this.getPath();
581
+ // path doesn't start with http or /
582
+ let isAbsolute = path.match( /^http/ ) || path.match( /^\// );
583
+ if ( isAbsolute ) {
584
+ this.getAbsolutePath = this.getPath;
585
+ return;
586
+ }
587
+
588
+ let { pathname } = location;
589
+ // query parameter #829. example.com/?pg=2
590
+ let isQuery = path.match( /^\?/ );
591
+ // /foo/bar/index.html => /foo/bar
592
+ let directory = pathname.substring( 0, pathname.lastIndexOf('/') );
593
+ let pathStart = isQuery ? pathname : directory + '/';
594
+
595
+ this.getAbsolutePath = () => pathStart + this.getPath();
596
+ };
597
+
598
+ // -------------------------- nav -------------------------- //
599
+
600
+ // hide navigation
601
+ InfiniteScroll.create.hideNav = function() {
602
+ let nav = utils.getQueryElement( this.options.hideNav );
603
+ if ( !nav ) return;
604
+
605
+ nav.style.display = 'none';
606
+ this.nav = nav;
607
+ };
608
+
609
+ InfiniteScroll.destroy.hideNav = function() {
610
+ if ( this.nav ) this.nav.style.display = '';
611
+ };
612
+
613
+ // -------------------------- destroy -------------------------- //
614
+
615
+ proto.destroy = function() {
616
+ this.allOff(); // remove all event listeners
617
+ // call destroy methods
618
+ for ( let method in InfiniteScroll.destroy ) {
619
+ InfiniteScroll.destroy[ method ].call( this );
620
+ }
621
+
622
+ delete this.element.infiniteScrollGUID;
623
+ delete instances[ this.guid ];
624
+ // remove jQuery data. #807
625
+ if ( jQuery && this.$element ) {
626
+ jQuery.removeData( this.element, 'infiniteScroll' );
627
+ }
628
+ };
629
+
630
+ // -------------------------- utilities -------------------------- //
631
+
632
+ // https://remysharp.com/2010/07/21/throttling-function-calls
633
+ InfiniteScroll.throttle = function( fn, threshold ) {
634
+ threshold = threshold || 200;
635
+ let last, timeout;
636
+
637
+ return function() {
638
+ let now = +new Date();
639
+ let args = arguments;
640
+ let trigger = () => {
641
+ last = now;
642
+ fn.apply( this, args );
643
+ };
644
+ if ( last && now < last + threshold ) {
645
+ // hold on to it
646
+ clearTimeout( timeout );
647
+ timeout = setTimeout( trigger, threshold );
648
+ } else {
649
+ trigger();
650
+ }
651
+ };
652
+ };
653
+
654
+ InfiniteScroll.data = function( elem ) {
655
+ elem = utils.getQueryElement( elem );
656
+ let id = elem && elem.infiniteScrollGUID;
657
+ return id && instances[ id ];
658
+ };
659
+
660
+ // set internal jQuery, for Webpack + jQuery v3
661
+ InfiniteScroll.setJQuery = function( jqry ) {
662
+ jQuery = jqry;
663
+ };
664
+
665
+ // -------------------------- setup -------------------------- //
666
+
667
+ utils.htmlInit( InfiniteScroll, 'infinite-scroll' );
668
+
669
+ // add noop _init method for jQuery Bridget. #768
670
+ proto._init = function() {};
671
+
672
+ let { jQueryBridget } = window;
673
+ if ( jQuery && jQueryBridget ) {
674
+ jQueryBridget( 'infiniteScroll', InfiniteScroll, jQuery );
675
+ }
676
+
677
+ // -------------------------- -------------------------- //
678
+
679
+ return InfiniteScroll;
680
+
681
+ } ) );
682
+ });
683
+
684
+ var pageLoad = _commonjsHelpers.createCommonjsModule(function (module) {
685
+ // page-load
686
+ ( function( window, factory ) {
687
+ // universal module definition
688
+ if ( module.exports ) {
689
+ // CommonJS
690
+ module.exports = factory(
691
+ window,
692
+ core,
693
+ );
694
+ } else {
695
+ // browser global
696
+ factory(
697
+ window,
698
+ window.InfiniteScroll,
699
+ );
700
+ }
701
+
702
+ }( window, function factory( window, InfiniteScroll ) {
703
+
704
+ let proto = InfiniteScroll.prototype;
705
+
706
+ Object.assign( InfiniteScroll.defaults, {
707
+ // append: false,
708
+ loadOnScroll: true,
709
+ checkLastPage: true,
710
+ responseBody: 'text',
711
+ domParseResponse: true,
712
+ // prefill: false,
713
+ // outlayer: null,
714
+ } );
715
+
716
+ InfiniteScroll.create.pageLoad = function() {
717
+ this.canLoad = true;
718
+ this.on( 'scrollThreshold', this.onScrollThresholdLoad );
719
+ this.on( 'load', this.checkLastPage );
720
+ if ( this.options.outlayer ) {
721
+ this.on( 'append', this.onAppendOutlayer );
722
+ }
723
+ };
724
+
725
+ proto.onScrollThresholdLoad = function() {
726
+ if ( this.options.loadOnScroll ) this.loadNextPage();
727
+ };
728
+
729
+ let domParser = new DOMParser();
730
+
731
+ proto.loadNextPage = function() {
732
+ if ( this.isLoading || !this.canLoad ) return;
733
+
734
+ let { responseBody, domParseResponse, fetchOptions } = this.options;
735
+ let path = this.getAbsolutePath();
736
+ this.isLoading = true;
737
+ if ( typeof fetchOptions == 'function' ) fetchOptions = fetchOptions();
738
+
739
+ let fetchPromise = fetch( path, fetchOptions )
740
+ .then( ( response ) => {
741
+ if ( !response.ok ) {
742
+ let error = new Error( response.statusText );
743
+ this.onPageError( error, path, response );
744
+ return { response };
745
+ }
746
+
747
+ return response[ responseBody ]().then( ( body ) => {
748
+ let canDomParse = responseBody == 'text' && domParseResponse;
749
+ if ( canDomParse ) {
750
+ body = domParser.parseFromString( body, 'text/html' );
751
+ }
752
+ if ( response.status == 204 ) {
753
+ this.lastPageReached( body, path );
754
+ return { body, response };
755
+ } else {
756
+ return this.onPageLoad( body, path, response );
757
+ }
758
+ } );
759
+ } )
760
+ .catch( ( error ) => {
761
+ this.onPageError( error, path );
762
+ } );
763
+
764
+ this.dispatchEvent( 'request', null, [ path, fetchPromise ] );
765
+
766
+ return fetchPromise;
767
+ };
768
+
769
+ proto.onPageLoad = function( body, path, response ) {
770
+ // done loading if not appending
771
+ if ( !this.options.append ) {
772
+ this.isLoading = false;
773
+ }
774
+ this.pageIndex++;
775
+ this.loadCount++;
776
+ this.dispatchEvent( 'load', null, [ body, path, response ] );
777
+ return this.appendNextPage( body, path, response );
778
+ };
779
+
780
+ proto.appendNextPage = function( body, path, response ) {
781
+ let { append, responseBody, domParseResponse } = this.options;
782
+ // do not append json
783
+ let isDocument = responseBody == 'text' && domParseResponse;
784
+ if ( !isDocument || !append ) return { body, response };
785
+
786
+ let items = body.querySelectorAll( append );
787
+ let promiseValue = { body, response, items };
788
+ // last page hit if no items. #840
789
+ if ( !items || !items.length ) {
790
+ this.lastPageReached( body, path );
791
+ return promiseValue;
792
+ }
793
+
794
+ let fragment = getItemsFragment( items );
795
+ let appendReady = () => {
796
+ this.appendItems( items, fragment );
797
+ this.isLoading = false;
798
+ this.dispatchEvent( 'append', null, [ body, path, items, response ] );
799
+ return promiseValue;
800
+ };
801
+
802
+ // TODO add hook for option to trigger appendReady
803
+ if ( this.options.outlayer ) {
804
+ return this.appendOutlayerItems( fragment, appendReady );
805
+ } else {
806
+ return appendReady();
807
+ }
808
+ };
809
+
810
+ proto.appendItems = function( items, fragment ) {
811
+ if ( !items || !items.length ) return;
812
+
813
+ // get fragment if not provided
814
+ fragment = fragment || getItemsFragment( items );
815
+ refreshScripts( fragment );
816
+ this.element.appendChild( fragment );
817
+ };
818
+
819
+ function getItemsFragment( items ) {
820
+ // add items to fragment
821
+ let fragment = document.createDocumentFragment();
822
+ if ( items ) fragment.append( ...items );
823
+ return fragment;
824
+ }
825
+
826
+ // replace <script>s with copies so they load
827
+ // <script>s added by InfiniteScroll will not load
828
+ // similar to https://stackoverflow.com/questions/610995
829
+ function refreshScripts( fragment ) {
830
+ let scripts = fragment.querySelectorAll('script');
831
+ for ( let script of scripts ) {
832
+ let freshScript = document.createElement('script');
833
+ // copy attributes
834
+ let attrs = script.attributes;
835
+ for ( let attr of attrs ) {
836
+ freshScript.setAttribute( attr.name, attr.value );
837
+ }
838
+ // copy inner script code. #718, #782
839
+ freshScript.innerHTML = script.innerHTML;
840
+ script.parentNode.replaceChild( freshScript, script );
841
+ }
842
+ }
843
+
844
+ // ----- outlayer ----- //
845
+
846
+ proto.appendOutlayerItems = function( fragment, appendReady ) {
847
+ let imagesLoaded = InfiniteScroll.imagesLoaded || window.imagesLoaded;
848
+ if ( !imagesLoaded ) {
849
+ console.error('[InfiniteScroll] imagesLoaded required for outlayer option');
850
+ this.isLoading = false;
851
+ return;
852
+ }
853
+ // append once images loaded
854
+ return new Promise( function( resolve ) {
855
+ imagesLoaded( fragment, function() {
856
+ let bodyResponse = appendReady();
857
+ resolve( bodyResponse );
858
+ } );
859
+ } );
860
+ };
861
+
862
+ proto.onAppendOutlayer = function( response, path, items ) {
863
+ this.options.outlayer.appended( items );
864
+ };
865
+
866
+ // ----- checkLastPage ----- //
867
+
868
+ // check response for next element
869
+ proto.checkLastPage = function( body, path ) {
870
+ let { checkLastPage, path: pathOpt } = this.options;
871
+ if ( !checkLastPage ) return;
872
+
873
+ // if path is function, check if next path is truthy
874
+ if ( typeof pathOpt == 'function' ) {
875
+ let nextPath = this.getPath();
876
+ if ( !nextPath ) {
877
+ this.lastPageReached( body, path );
878
+ return;
879
+ }
880
+ }
881
+ // get selector from checkLastPage or path option
882
+ let selector;
883
+ if ( typeof checkLastPage == 'string' ) {
884
+ selector = checkLastPage;
885
+ } else if ( this.isPathSelector ) {
886
+ // path option is selector string
887
+ selector = pathOpt;
888
+ }
889
+ // check last page for selector
890
+ // bail if no selector or not document response
891
+ if ( !selector || !body.querySelector ) return;
892
+
893
+ // check if response has selector
894
+ let nextElem = body.querySelector( selector );
895
+ if ( !nextElem ) this.lastPageReached( body, path );
896
+ };
897
+
898
+ proto.lastPageReached = function( body, path ) {
899
+ this.canLoad = false;
900
+ this.dispatchEvent( 'last', null, [ body, path ] );
901
+ };
902
+
903
+ // ----- error ----- //
904
+
905
+ proto.onPageError = function( error, path, response ) {
906
+ this.isLoading = false;
907
+ this.canLoad = false;
908
+ this.dispatchEvent( 'error', null, [ error, path, response ] );
909
+ return error;
910
+ };
911
+
912
+ // -------------------------- prefill -------------------------- //
913
+
914
+ InfiniteScroll.create.prefill = function() {
915
+ if ( !this.options.prefill ) return;
916
+
917
+ let append = this.options.append;
918
+ if ( !append ) {
919
+ console.error(`append option required for prefill. Set as :${append}`);
920
+ return;
921
+ }
922
+ this.updateMeasurements();
923
+ this.updateScroller();
924
+ this.isPrefilling = true;
925
+ this.on( 'append', this.prefill );
926
+ this.once( 'error', this.stopPrefill );
927
+ this.once( 'last', this.stopPrefill );
928
+ this.prefill();
929
+ };
930
+
931
+ proto.prefill = function() {
932
+ let distance = this.getPrefillDistance();
933
+ this.isPrefilling = distance >= 0;
934
+ if ( this.isPrefilling ) {
935
+ this.log('prefill');
936
+ this.loadNextPage();
937
+ } else {
938
+ this.stopPrefill();
939
+ }
940
+ };
941
+
942
+ proto.getPrefillDistance = function() {
943
+ // element scroll
944
+ if ( this.options.elementScroll ) {
945
+ return this.scroller.clientHeight - this.scroller.scrollHeight;
946
+ }
947
+ // window
948
+ return this.windowHeight - this.element.clientHeight;
949
+ };
950
+
951
+ proto.stopPrefill = function() {
952
+ this.log('stopPrefill');
953
+ this.off( 'append', this.prefill );
954
+ };
955
+
956
+ // -------------------------- -------------------------- //
957
+
958
+ return InfiniteScroll;
959
+
960
+ } ) );
961
+ });
962
+
963
+ var scrollWatch = _commonjsHelpers.createCommonjsModule(function (module) {
964
+ // scroll-watch
965
+ ( function( window, factory ) {
966
+ // universal module definition
967
+ if ( module.exports ) {
968
+ // CommonJS
969
+ module.exports = factory(
970
+ window,
971
+ core,
972
+ utils$1,
973
+ );
974
+ } else {
975
+ // browser global
976
+ factory(
977
+ window,
978
+ window.InfiniteScroll,
979
+ window.fizzyUIUtils,
980
+ );
981
+ }
982
+
983
+ }( window, function factory( window, InfiniteScroll, utils ) {
984
+
985
+ let proto = InfiniteScroll.prototype;
986
+
987
+ // default options
988
+ Object.assign( InfiniteScroll.defaults, {
989
+ scrollThreshold: 400,
990
+ // elementScroll: null,
991
+ } );
992
+
993
+ InfiniteScroll.create.scrollWatch = function() {
994
+ // events
995
+ this.pageScrollHandler = this.onPageScroll.bind( this );
996
+ this.resizeHandler = this.onResize.bind( this );
997
+
998
+ let scrollThreshold = this.options.scrollThreshold;
999
+ let isEnable = scrollThreshold || scrollThreshold === 0;
1000
+ if ( isEnable ) this.enableScrollWatch();
1001
+ };
1002
+
1003
+ InfiniteScroll.destroy.scrollWatch = function() {
1004
+ this.disableScrollWatch();
1005
+ };
1006
+
1007
+ proto.enableScrollWatch = function() {
1008
+ if ( this.isScrollWatching ) return;
1009
+
1010
+ this.isScrollWatching = true;
1011
+ this.updateMeasurements();
1012
+ this.updateScroller();
1013
+ // TODO disable after error?
1014
+ this.on( 'last', this.disableScrollWatch );
1015
+ this.bindScrollWatchEvents( true );
1016
+ };
1017
+
1018
+ proto.disableScrollWatch = function() {
1019
+ if ( !this.isScrollWatching ) return;
1020
+
1021
+ this.bindScrollWatchEvents( false );
1022
+ delete this.isScrollWatching;
1023
+ };
1024
+
1025
+ proto.bindScrollWatchEvents = function( isBind ) {
1026
+ let addRemove = isBind ? 'addEventListener' : 'removeEventListener';
1027
+ this.scroller[ addRemove ]( 'scroll', this.pageScrollHandler );
1028
+ window[ addRemove ]( 'resize', this.resizeHandler );
1029
+ };
1030
+
1031
+ proto.onPageScroll = InfiniteScroll.throttle( function() {
1032
+ let distance = this.getBottomDistance();
1033
+ if ( distance <= this.options.scrollThreshold ) {
1034
+ this.dispatchEvent('scrollThreshold');
1035
+ }
1036
+ } );
1037
+
1038
+ proto.getBottomDistance = function() {
1039
+ let bottom, scrollY;
1040
+ if ( this.options.elementScroll ) {
1041
+ bottom = this.scroller.scrollHeight;
1042
+ scrollY = this.scroller.scrollTop + this.scroller.clientHeight;
1043
+ } else {
1044
+ bottom = this.top + this.element.clientHeight;
1045
+ scrollY = window.scrollY + this.windowHeight;
1046
+ }
1047
+ return bottom - scrollY;
1048
+ };
1049
+
1050
+ proto.onResize = function() {
1051
+ this.updateMeasurements();
1052
+ };
1053
+
1054
+ utils.debounceMethod( InfiniteScroll, 'onResize', 150 );
1055
+
1056
+ // -------------------------- -------------------------- //
1057
+
1058
+ return InfiniteScroll;
1059
+
1060
+ } ) );
1061
+ });
1062
+
1063
+ var history_1 = _commonjsHelpers.createCommonjsModule(function (module) {
1064
+ // history
1065
+ ( function( window, factory ) {
1066
+ // universal module definition
1067
+ if ( module.exports ) {
1068
+ // CommonJS
1069
+ module.exports = factory(
1070
+ window,
1071
+ core,
1072
+ utils$1,
1073
+ );
1074
+ } else {
1075
+ // browser global
1076
+ factory(
1077
+ window,
1078
+ window.InfiniteScroll,
1079
+ window.fizzyUIUtils,
1080
+ );
1081
+ }
1082
+
1083
+ }( window, function factory( window, InfiniteScroll, utils ) {
1084
+
1085
+ let proto = InfiniteScroll.prototype;
1086
+
1087
+ Object.assign( InfiniteScroll.defaults, {
1088
+ history: 'replace',
1089
+ // historyTitle: false,
1090
+ } );
1091
+
1092
+ let link = document.createElement('a');
1093
+
1094
+ // ----- create/destroy ----- //
1095
+
1096
+ InfiniteScroll.create.history = function() {
1097
+ if ( !this.options.history ) return;
1098
+
1099
+ // check for same origin
1100
+ link.href = this.getAbsolutePath();
1101
+ // MS Edge does not have origin on link
1102
+ // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/12236493/
1103
+ let linkOrigin = link.origin || link.protocol + '//' + link.host;
1104
+ let isSameOrigin = linkOrigin == location.origin;
1105
+ if ( !isSameOrigin ) {
1106
+ console.error( '[InfiniteScroll] cannot set history with different origin: ' +
1107
+ `${link.origin} on ${location.origin} . History behavior disabled.` );
1108
+ return;
1109
+ }
1110
+
1111
+ // two ways to handle changing history
1112
+ if ( this.options.append ) {
1113
+ this.createHistoryAppend();
1114
+ } else {
1115
+ this.createHistoryPageLoad();
1116
+ }
1117
+ };
1118
+
1119
+ proto.createHistoryAppend = function() {
1120
+ this.updateMeasurements();
1121
+ this.updateScroller();
1122
+ // array of scroll positions of appended pages
1123
+ this.scrollPages = [
1124
+ // first page
1125
+ {
1126
+ top: 0,
1127
+ path: location.href,
1128
+ title: document.title,
1129
+ },
1130
+ ];
1131
+ this.scrollPage = this.scrollPages[0];
1132
+ // events
1133
+ this.scrollHistoryHandler = this.onScrollHistory.bind( this );
1134
+ this.unloadHandler = this.onUnload.bind( this );
1135
+ this.scroller.addEventListener( 'scroll', this.scrollHistoryHandler );
1136
+ this.on( 'append', this.onAppendHistory );
1137
+ this.bindHistoryAppendEvents( true );
1138
+ };
1139
+
1140
+ proto.bindHistoryAppendEvents = function( isBind ) {
1141
+ let addRemove = isBind ? 'addEventListener' : 'removeEventListener';
1142
+ this.scroller[ addRemove ]( 'scroll', this.scrollHistoryHandler );
1143
+ window[ addRemove ]( 'unload', this.unloadHandler );
1144
+ };
1145
+
1146
+ proto.createHistoryPageLoad = function() {
1147
+ this.on( 'load', this.onPageLoadHistory );
1148
+ };
1149
+
1150
+ InfiniteScroll.destroy.history =
1151
+ proto.destroyHistory = function() {
1152
+ let isHistoryAppend = this.options.history && this.options.append;
1153
+ if ( isHistoryAppend ) {
1154
+ this.bindHistoryAppendEvents( false );
1155
+ }
1156
+ };
1157
+
1158
+ // ----- append history ----- //
1159
+
1160
+ proto.onAppendHistory = function( response, path, items ) {
1161
+ // do not proceed if no items. #779
1162
+ if ( !items || !items.length ) return;
1163
+
1164
+ let firstItem = items[0];
1165
+ let elemScrollY = this.getElementScrollY( firstItem );
1166
+ // resolve path
1167
+ link.href = path;
1168
+ // add page data to hash
1169
+ this.scrollPages.push({
1170
+ top: elemScrollY,
1171
+ path: link.href,
1172
+ title: response.title,
1173
+ });
1174
+ };
1175
+
1176
+ proto.getElementScrollY = function( elem ) {
1177
+ if ( this.options.elementScroll ) {
1178
+ return elem.offsetTop - this.top;
1179
+ } else {
1180
+ let rect = elem.getBoundingClientRect();
1181
+ return rect.top + window.scrollY;
1182
+ }
1183
+ };
1184
+
1185
+ proto.onScrollHistory = function() {
1186
+ // cycle through positions, find biggest without going over
1187
+ let scrollPage = this.getClosestScrollPage();
1188
+ // set history if changed
1189
+ if ( scrollPage != this.scrollPage ) {
1190
+ this.scrollPage = scrollPage;
1191
+ this.setHistory( scrollPage.title, scrollPage.path );
1192
+ }
1193
+ };
1194
+
1195
+ utils.debounceMethod( InfiniteScroll, 'onScrollHistory', 150 );
1196
+
1197
+ proto.getClosestScrollPage = function() {
1198
+ let scrollViewY;
1199
+ if ( this.options.elementScroll ) {
1200
+ scrollViewY = this.scroller.scrollTop + this.scroller.clientHeight / 2;
1201
+ } else {
1202
+ scrollViewY = window.scrollY + this.windowHeight / 2;
1203
+ }
1204
+
1205
+ let scrollPage;
1206
+ for ( let page of this.scrollPages ) {
1207
+ if ( page.top >= scrollViewY ) break;
1208
+
1209
+ scrollPage = page;
1210
+ }
1211
+ return scrollPage;
1212
+ };
1213
+
1214
+ proto.setHistory = function( title, path ) {
1215
+ let optHistory = this.options.history;
1216
+ let historyMethod = optHistory && history[ optHistory + 'State' ];
1217
+ if ( !historyMethod ) return;
1218
+
1219
+ history[ optHistory + 'State' ]( null, title, path );
1220
+ if ( this.options.historyTitle ) document.title = title;
1221
+ this.dispatchEvent( 'history', null, [ title, path ] );
1222
+ };
1223
+
1224
+ // scroll to top to prevent initial scroll-reset after page refresh
1225
+ // https://stackoverflow.com/a/18633915/182183
1226
+ proto.onUnload = function() {
1227
+ if ( this.scrollPage.top === 0 ) return;
1228
+
1229
+ // calculate where scroll position would be on refresh
1230
+ let scrollY = window.scrollY - this.scrollPage.top + this.top;
1231
+ // disable scroll event before setting scroll #679
1232
+ this.destroyHistory();
1233
+ scrollTo( 0, scrollY );
1234
+ };
1235
+
1236
+ // ----- load history ----- //
1237
+
1238
+ // update URL
1239
+ proto.onPageLoadHistory = function( response, path ) {
1240
+ this.setHistory( response.title, path );
1241
+ };
1242
+
1243
+ // -------------------------- -------------------------- //
1244
+
1245
+ return InfiniteScroll;
1246
+
1247
+ } ) );
1248
+ });
1249
+
1250
+ var button = _commonjsHelpers.createCommonjsModule(function (module) {
1251
+ // button
1252
+ ( function( window, factory ) {
1253
+ // universal module definition
1254
+ if ( module.exports ) {
1255
+ // CommonJS
1256
+ module.exports = factory(
1257
+ window,
1258
+ core,
1259
+ utils$1,
1260
+ );
1261
+ } else {
1262
+ // browser global
1263
+ factory(
1264
+ window,
1265
+ window.InfiniteScroll,
1266
+ window.fizzyUIUtils,
1267
+ );
1268
+ }
1269
+
1270
+ }( window, function factory( window, InfiniteScroll, utils ) {
1271
+
1272
+ // -------------------------- InfiniteScrollButton -------------------------- //
1273
+
1274
+ class InfiniteScrollButton {
1275
+ constructor( element, infScroll ) {
1276
+ this.element = element;
1277
+ this.infScroll = infScroll;
1278
+ // events
1279
+ this.clickHandler = this.onClick.bind( this );
1280
+ this.element.addEventListener( 'click', this.clickHandler );
1281
+ infScroll.on( 'request', this.disable.bind( this ) );
1282
+ infScroll.on( 'load', this.enable.bind( this ) );
1283
+ infScroll.on( 'error', this.hide.bind( this ) );
1284
+ infScroll.on( 'last', this.hide.bind( this ) );
1285
+ }
1286
+
1287
+ onClick( event ) {
1288
+ event.preventDefault();
1289
+ this.infScroll.loadNextPage();
1290
+ }
1291
+
1292
+ enable() {
1293
+ this.element.removeAttribute('disabled');
1294
+ }
1295
+
1296
+ disable() {
1297
+ this.element.disabled = 'disabled';
1298
+ }
1299
+
1300
+ hide() {
1301
+ this.element.style.display = 'none';
1302
+ }
1303
+
1304
+ destroy() {
1305
+ this.element.removeEventListener( 'click', this.clickHandler );
1306
+ }
1307
+
1308
+ }
1309
+
1310
+ // -------------------------- InfiniteScroll methods -------------------------- //
1311
+
1312
+ // InfiniteScroll.defaults.button = null;
1313
+
1314
+ InfiniteScroll.create.button = function() {
1315
+ let buttonElem = utils.getQueryElement( this.options.button );
1316
+ if ( buttonElem ) {
1317
+ this.button = new InfiniteScrollButton( buttonElem, this );
1318
+ }
1319
+ };
1320
+
1321
+ InfiniteScroll.destroy.button = function() {
1322
+ if ( this.button ) this.button.destroy();
1323
+ };
1324
+
1325
+ // -------------------------- -------------------------- //
1326
+
1327
+ InfiniteScroll.Button = InfiniteScrollButton;
1328
+
1329
+ return InfiniteScroll;
1330
+
1331
+ } ) );
1332
+ });
1333
+
1334
+ var status = _commonjsHelpers.createCommonjsModule(function (module) {
1335
+ // status
1336
+ ( function( window, factory ) {
1337
+ // universal module definition
1338
+ if ( module.exports ) {
1339
+ // CommonJS
1340
+ module.exports = factory(
1341
+ window,
1342
+ core,
1343
+ utils$1,
1344
+ );
1345
+ } else {
1346
+ // browser global
1347
+ factory(
1348
+ window,
1349
+ window.InfiniteScroll,
1350
+ window.fizzyUIUtils,
1351
+ );
1352
+ }
1353
+
1354
+ }( window, function factory( window, InfiniteScroll, utils ) {
1355
+
1356
+ let proto = InfiniteScroll.prototype;
1357
+
1358
+ // InfiniteScroll.defaults.status = null;
1359
+
1360
+ InfiniteScroll.create.status = function() {
1361
+ let statusElem = utils.getQueryElement( this.options.status );
1362
+ if ( !statusElem ) return;
1363
+
1364
+ // elements
1365
+ this.statusElement = statusElem;
1366
+ this.statusEventElements = {
1367
+ request: statusElem.querySelector('.infinite-scroll-request'),
1368
+ error: statusElem.querySelector('.infinite-scroll-error'),
1369
+ last: statusElem.querySelector('.infinite-scroll-last'),
1370
+ };
1371
+ // events
1372
+ this.on( 'request', this.showRequestStatus );
1373
+ this.on( 'error', this.showErrorStatus );
1374
+ this.on( 'last', this.showLastStatus );
1375
+ this.bindHideStatus('on');
1376
+ };
1377
+
1378
+ proto.bindHideStatus = function( bindMethod ) {
1379
+ let hideEvent = this.options.append ? 'append' : 'load';
1380
+ this[ bindMethod ]( hideEvent, this.hideAllStatus );
1381
+ };
1382
+
1383
+ proto.showRequestStatus = function() {
1384
+ this.showStatus('request');
1385
+ };
1386
+
1387
+ proto.showErrorStatus = function() {
1388
+ this.showStatus('error');
1389
+ };
1390
+
1391
+ proto.showLastStatus = function() {
1392
+ this.showStatus('last');
1393
+ // prevent last then append event race condition from showing last status #706
1394
+ this.bindHideStatus('off');
1395
+ };
1396
+
1397
+ proto.showStatus = function( eventName ) {
1398
+ show( this.statusElement );
1399
+ this.hideStatusEventElements();
1400
+ let eventElem = this.statusEventElements[ eventName ];
1401
+ show( eventElem );
1402
+ };
1403
+
1404
+ proto.hideAllStatus = function() {
1405
+ hide( this.statusElement );
1406
+ this.hideStatusEventElements();
1407
+ };
1408
+
1409
+ proto.hideStatusEventElements = function() {
1410
+ for ( let type in this.statusEventElements ) {
1411
+ let eventElem = this.statusEventElements[ type ];
1412
+ hide( eventElem );
1413
+ }
1414
+ };
1415
+
1416
+ // -------------------------- -------------------------- //
1417
+
1418
+ function hide( elem ) {
1419
+ setDisplay( elem, 'none' );
1420
+ }
1421
+
1422
+ function show( elem ) {
1423
+ setDisplay( elem, 'block' );
1424
+ }
1425
+
1426
+ function setDisplay( elem, value ) {
1427
+ if ( elem ) {
1428
+ elem.style.display = value;
1429
+ }
1430
+ }
1431
+
1432
+ // -------------------------- -------------------------- //
1433
+
1434
+ return InfiniteScroll;
1435
+
1436
+ } ) );
1437
+ });
1438
+
1439
+ var js = _commonjsHelpers.createCommonjsModule(function (module) {
1440
+ /*!
1441
+ * Infinite Scroll v4.0.1
1442
+ * Automatically add next page
1443
+ *
1444
+ * Licensed GPLv3 for open source use
1445
+ * or Infinite Scroll Commercial License for commercial use
1446
+ *
1447
+ * https://infinite-scroll.com
1448
+ * Copyright 2018-2020 Metafizzy
1449
+ */
1450
+
1451
+ ( function( window, factory ) {
1452
+ // universal module definition
1453
+ if ( module.exports ) {
1454
+ // CommonJS
1455
+ module.exports = factory(
1456
+ core,
1457
+ pageLoad,
1458
+ scrollWatch,
1459
+ history_1,
1460
+ button,
1461
+ status,
1462
+ );
1463
+ }
1464
+
1465
+ } )( window, function factory( InfiniteScroll ) {
1466
+ return InfiniteScroll;
1467
+ } );
1468
+ });
1469
+
1470
+ var lang = _commonjsHelpers.createCommonjsModule(function (module, exports) {
1471
+ /*!
1472
+ * Lang.js for Laravel localization in JavaScript.
1473
+ *
1474
+ * @version 1.1.12
1475
+ * @license MIT https://github.com/rmariuzzo/Lang.js/blob/master/LICENSE
1476
+ * @site https://github.com/rmariuzzo/Lang.js
1477
+ * @author Rubens Mariuzzo <rubens@mariuzzo.com>
1478
+ */
1479
+
1480
+ (function(root, factory) {
1481
+
1482
+ {
1483
+ // NodeJS support.
1484
+ module.exports = factory();
1485
+ }
1486
+
1487
+ }(_commonjsHelpers.commonjsGlobal, function() {
1488
+
1489
+ function inferLocale() {
1490
+ if (typeof document !== 'undefined' && document.documentElement) {
1491
+ return document.documentElement.lang;
1492
+ }
1493
+ }
1494
+ function convertNumber(str) {
1495
+ if (str === '-Inf') {
1496
+ return -Infinity;
1497
+ } else if (str === '+Inf' || str === 'Inf' || str === '*') {
1498
+ return Infinity;
1499
+ }
1500
+ return parseInt(str, 10);
1501
+ }
1502
+
1503
+ // Derived from: https://github.com/symfony/translation/blob/460390765eb7bb9338a4a323b8a4e815a47541ba/Interval.php
1504
+ var intervalRegexp = /^({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])$/;
1505
+ var anyIntervalRegexp = /({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])/;
1506
+
1507
+ // Default options //
1508
+
1509
+ var defaults = {
1510
+ locale: 'en'/** The default locale if not set. */
1511
+ };
1512
+
1513
+ // Constructor //
1514
+
1515
+ var Lang = function(options) {
1516
+ options = options || {};
1517
+ this.locale = options.locale || inferLocale() || defaults.locale;
1518
+ this.fallback = options.fallback;
1519
+ this.messages = options.messages;
1520
+ };
1521
+
1522
+ // Methods //
1523
+
1524
+ /**
1525
+ * Set messages source.
1526
+ *
1527
+ * @param messages {object} The messages source.
1528
+ *
1529
+ * @return void
1530
+ */
1531
+ Lang.prototype.setMessages = function(messages) {
1532
+ this.messages = messages;
1533
+ };
1534
+
1535
+ /**
1536
+ * Get the current locale.
1537
+ *
1538
+ * @return {string} The current locale.
1539
+ */
1540
+ Lang.prototype.getLocale = function() {
1541
+ return this.locale || this.fallback;
1542
+ };
1543
+
1544
+ /**
1545
+ * Set the current locale.
1546
+ *
1547
+ * @param locale {string} The locale to set.
1548
+ *
1549
+ * @return void
1550
+ */
1551
+ Lang.prototype.setLocale = function(locale) {
1552
+ this.locale = locale;
1553
+ };
1554
+
1555
+ /**
1556
+ * Get the fallback locale being used.
1557
+ *
1558
+ * @return void
1559
+ */
1560
+ Lang.prototype.getFallback = function() {
1561
+ return this.fallback;
1562
+ };
1563
+
1564
+ /**
1565
+ * Set the fallback locale being used.
1566
+ *
1567
+ * @param fallback {string} The fallback locale.
1568
+ *
1569
+ * @return void
1570
+ */
1571
+ Lang.prototype.setFallback = function(fallback) {
1572
+ this.fallback = fallback;
1573
+ };
1574
+
1575
+ /**
1576
+ * This method act as an alias to get() method.
1577
+ *
1578
+ * @param key {string} The key of the message.
1579
+ * @param locale {string} The locale of the message
1580
+ *
1581
+ * @return {boolean} true if the given key is defined on the messages source, otherwise false.
1582
+ */
1583
+ Lang.prototype.has = function(key, locale) {
1584
+ if (typeof key !== 'string' || !this.messages) {
1585
+ return false;
1586
+ }
1587
+
1588
+ return this._getMessage(key, locale) !== null;
1589
+ };
1590
+
1591
+ /**
1592
+ * Get a translation message.
1593
+ *
1594
+ * @param key {string} The key of the message.
1595
+ * @param replacements {object} The replacements to be done in the message.
1596
+ * @param locale {string} The locale to use, if not passed use the default locale.
1597
+ *
1598
+ * @return {string} The translation message, if not found the given key.
1599
+ */
1600
+ Lang.prototype.get = function(key, replacements, locale) {
1601
+ if (!this.has(key, locale)) {
1602
+ return key;
1603
+ }
1604
+
1605
+ var message = this._getMessage(key, locale);
1606
+ if (message === null) {
1607
+ return key;
1608
+ }
1609
+
1610
+ if (replacements) {
1611
+ message = this._applyReplacements(message, replacements);
1612
+ }
1613
+
1614
+ return message;
1615
+ };
1616
+
1617
+ /**
1618
+ * This method act as an alias to get() method.
1619
+ *
1620
+ * @param key {string} The key of the message.
1621
+ * @param replacements {object} The replacements to be done in the message.
1622
+ *
1623
+ * @return {string} The translation message, if not found the given key.
1624
+ */
1625
+ Lang.prototype.trans = function(key, replacements) {
1626
+ return this.get(key, replacements);
1627
+ };
1628
+
1629
+ /**
1630
+ * Gets the plural or singular form of the message specified based on an integer value.
1631
+ *
1632
+ * @param key {string} The key of the message.
1633
+ * @param count {number} The number of elements.
1634
+ * @param replacements {object} The replacements to be done in the message.
1635
+ * @param locale {string} The locale to use, if not passed use the default locale.
1636
+ *
1637
+ * @return {string} The translation message according to an integer value.
1638
+ */
1639
+ Lang.prototype.choice = function(key, number, replacements, locale) {
1640
+ // Set default values for parameters replace and locale
1641
+ replacements = typeof replacements !== 'undefined'
1642
+ ? replacements
1643
+ : {};
1644
+
1645
+ // The count must be replaced if found in the message
1646
+ replacements.count = number;
1647
+
1648
+ // Message to get the plural or singular
1649
+ var message = this.get(key, replacements, locale);
1650
+
1651
+ // Check if message is not null or undefined
1652
+ if (message === null || message === undefined) {
1653
+ return message;
1654
+ }
1655
+
1656
+ // Separate the plural from the singular, if any
1657
+ var messageParts = message.split('|');
1658
+
1659
+ // Get the explicit rules, If any
1660
+ var explicitRules = [];
1661
+
1662
+ for (var i = 0; i < messageParts.length; i++) {
1663
+ messageParts[i] = messageParts[i].trim();
1664
+
1665
+ if (anyIntervalRegexp.test(messageParts[i])) {
1666
+ var messageSpaceSplit = messageParts[i].split(/\s/);
1667
+ explicitRules.push(messageSpaceSplit.shift());
1668
+ messageParts[i] = messageSpaceSplit.join(' ');
1669
+ }
1670
+ }
1671
+
1672
+ // Check if there's only one message
1673
+ if (messageParts.length === 1) {
1674
+ // Nothing to do here
1675
+ return message;
1676
+ }
1677
+
1678
+ // Check the explicit rules
1679
+ for (var j = 0; j < explicitRules.length; j++) {
1680
+ if (this._testInterval(number, explicitRules[j])) {
1681
+ return messageParts[j];
1682
+ }
1683
+ }
1684
+
1685
+ locale = locale || this._getLocale(key);
1686
+ var pluralForm = this._getPluralForm(number, locale);
1687
+
1688
+ return messageParts[pluralForm];
1689
+ };
1690
+
1691
+ /**
1692
+ * This method act as an alias to choice() method.
1693
+ *
1694
+ * @param key {string} The key of the message.
1695
+ * @param count {number} The number of elements.
1696
+ * @param replacements {object} The replacements to be done in the message.
1697
+ *
1698
+ * @return {string} The translation message according to an integer value.
1699
+ */
1700
+ Lang.prototype.transChoice = function(key, count, replacements) {
1701
+ return this.choice(key, count, replacements);
1702
+ };
1703
+
1704
+ /**
1705
+ * Parse a message key into components.
1706
+ *
1707
+ * @param key {string} The message key to parse.
1708
+ * @param key {string} The message locale to parse
1709
+ * @return {object} A key object with source and entries properties.
1710
+ */
1711
+ Lang.prototype._parseKey = function(key, locale) {
1712
+ if (typeof key !== 'string' || typeof locale !== 'string') {
1713
+ return null;
1714
+ }
1715
+
1716
+ var segments = key.split('.');
1717
+ var source = segments[0].replace(/\//g, '.');
1718
+
1719
+ return {
1720
+ source: locale + '.' + source,
1721
+ sourceFallback: this.getFallback() + '.' + source,
1722
+ entries: segments.slice(1)
1723
+ };
1724
+ };
1725
+
1726
+ /**
1727
+ * Returns a translation message. Use `Lang.get()` method instead, this methods assumes the key exists.
1728
+ *
1729
+ * @param key {string} The key of the message.
1730
+ * @param locale {string} The locale of the message
1731
+ *
1732
+ * @return {string} The translation message for the given key.
1733
+ */
1734
+ Lang.prototype._getMessage = function(key, locale) {
1735
+ locale = locale || this.getLocale();
1736
+
1737
+ key = this._parseKey(key, locale);
1738
+
1739
+ // Ensure message source exists.
1740
+ if (this.messages[key.source] === undefined && this.messages[key.sourceFallback] === undefined) {
1741
+ return null;
1742
+ }
1743
+
1744
+ // Get message from default locale.
1745
+ var message = this.messages[key.source];
1746
+ var entries = key.entries.slice();
1747
+ var subKey = entries.join('.');
1748
+ message = message !== undefined ? this._getValueInKey(message, subKey) : undefined;
1749
+
1750
+
1751
+ // Get message from fallback locale.
1752
+ if (typeof message !== 'string' && this.messages[key.sourceFallback]) {
1753
+ message = this.messages[key.sourceFallback];
1754
+ entries = key.entries.slice();
1755
+ subKey = '';
1756
+ while (entries.length && message !== undefined) {
1757
+ var subKey = !subKey ? entries.shift() : subKey.concat('.', entries.shift());
1758
+ if (message[subKey]) {
1759
+ message = message[subKey];
1760
+ subKey = '';
1761
+ }
1762
+ }
1763
+ }
1764
+
1765
+ if (typeof message !== 'string') {
1766
+ return null;
1767
+ }
1768
+
1769
+ return message;
1770
+ };
1771
+
1772
+ Lang.prototype._getValueInKey = function(obj, str) {
1773
+ // If the full key exists just return the value
1774
+ if (typeof obj[str] === 'string') {
1775
+ return obj[str]
1776
+ }
1777
+
1778
+ str = str.replace(/\[(\w+)\]/g, '.$1'); // convert indexes to properties
1779
+ str = str.replace(/^\./, ''); // strip a leading dot
1780
+
1781
+ var parts = str.split('.');
1782
+
1783
+ for (var i = 0, n = parts.length; i < n; ++i) {
1784
+ var currentKey = parts.slice(0, i + 1).join('.');
1785
+ var restOfTheKey = parts.slice(i + 1, parts.length).join('.');
1786
+
1787
+ if (obj[currentKey]) {
1788
+ return this._getValueInKey(obj[currentKey], restOfTheKey)
1789
+ }
1790
+ }
1791
+
1792
+ return obj;
1793
+ };
1794
+
1795
+ /**
1796
+ * Return the locale to be used between default and fallback.
1797
+ * @param {String} key
1798
+ * @return {String}
1799
+ */
1800
+ Lang.prototype._getLocale = function(key) {
1801
+ key = this._parseKey(key, this.locale);
1802
+ if (this.messages[key.source]) {
1803
+ return this.locale;
1804
+ }
1805
+ if (this.messages[key.sourceFallback]) {
1806
+ return this.fallback;
1807
+ }
1808
+ return null;
1809
+ };
1810
+
1811
+ /**
1812
+ * Find a message in a translation tree using both dotted keys and regular ones
1813
+ *
1814
+ * @param pathSegments {array} An array of path segments such as ['family', 'father']
1815
+ * @param tree {object} The translation tree
1816
+ */
1817
+ Lang.prototype._findMessageInTree = function(pathSegments, tree) {
1818
+ while (pathSegments.length && tree !== undefined) {
1819
+ var dottedKey = pathSegments.join('.');
1820
+ if (tree[dottedKey]) {
1821
+ tree = tree[dottedKey];
1822
+ break;
1823
+ }
1824
+
1825
+ tree = tree[pathSegments.shift()];
1826
+ }
1827
+
1828
+ return tree;
1829
+ };
1830
+
1831
+ /**
1832
+ * Sort replacement keys by length in descending order.
1833
+ *
1834
+ * @param a {string} Replacement key
1835
+ * @param b {string} Sibling replacement key
1836
+ * @return {number}
1837
+ * @private
1838
+ */
1839
+ Lang.prototype._sortReplacementKeys = function(a, b) {
1840
+ return b.length - a.length;
1841
+ };
1842
+
1843
+ /**
1844
+ * Apply replacements to a string message containing placeholders.
1845
+ *
1846
+ * @param message {string} The text message.
1847
+ * @param replacements {object} The replacements to be done in the message.
1848
+ *
1849
+ * @return {string} The string message with replacements applied.
1850
+ */
1851
+ Lang.prototype._applyReplacements = function(message, replacements) {
1852
+ var keys = Object.keys(replacements).sort(this._sortReplacementKeys);
1853
+
1854
+ keys.forEach(function(replace) {
1855
+ message = message.replace(new RegExp(':' + replace, 'gi'), function (match) {
1856
+ var value = replacements[replace];
1857
+
1858
+ // Capitalize all characters.
1859
+ var allCaps = match === match.toUpperCase();
1860
+ if (allCaps) {
1861
+ return value.toUpperCase();
1862
+ }
1863
+
1864
+ // Capitalize first letter.
1865
+ var firstCap = match === match.replace(/\w/i, function(letter) {
1866
+ return letter.toUpperCase();
1867
+ });
1868
+ if (firstCap) {
1869
+ return value.charAt(0).toUpperCase() + value.slice(1);
1870
+ }
1871
+
1872
+ return value;
1873
+ });
1874
+ });
1875
+ return message;
1876
+ };
1877
+
1878
+ /**
1879
+ * Checks if the given `count` is within the interval defined by the {string} `interval`
1880
+ *
1881
+ * @param count {int} The amount of items.
1882
+ * @param interval {string} The interval to be compared with the count.
1883
+ * @return {boolean} Returns true if count is within interval; false otherwise.
1884
+ */
1885
+ Lang.prototype._testInterval = function(count, interval) {
1886
+ /**
1887
+ * From the Symfony\Component\Translation\Interval Docs
1888
+ *
1889
+ * Tests if a given number belongs to a given math interval.
1890
+ *
1891
+ * An interval can represent a finite set of numbers:
1892
+ *
1893
+ * {1,2,3,4}
1894
+ *
1895
+ * An interval can represent numbers between two numbers:
1896
+ *
1897
+ * [1, +Inf]
1898
+ * ]-1,2[
1899
+ *
1900
+ * The left delimiter can be [ (inclusive) or ] (exclusive).
1901
+ * The right delimiter can be [ (exclusive) or ] (inclusive).
1902
+ * Beside numbers, you can use -Inf and +Inf for the infinite.
1903
+ */
1904
+
1905
+ if (typeof interval !== 'string') {
1906
+ throw 'Invalid interval: should be a string.';
1907
+ }
1908
+
1909
+ interval = interval.trim();
1910
+
1911
+ var matches = interval.match(intervalRegexp);
1912
+ if (!matches) {
1913
+ throw 'Invalid interval: ' + interval;
1914
+ }
1915
+
1916
+ if (matches[2]) {
1917
+ var items = matches[2].split(',');
1918
+ for (var i = 0; i < items.length; i++) {
1919
+ if (parseInt(items[i], 10) === count) {
1920
+ return true;
1921
+ }
1922
+ }
1923
+ } else {
1924
+ // Remove falsy values.
1925
+ matches = matches.filter(function(match) {
1926
+ return !!match;
1927
+ });
1928
+
1929
+ var leftDelimiter = matches[1];
1930
+ var leftNumber = convertNumber(matches[2]);
1931
+ if (leftNumber === Infinity) {
1932
+ leftNumber = -Infinity;
1933
+ }
1934
+ var rightNumber = convertNumber(matches[3]);
1935
+ var rightDelimiter = matches[4];
1936
+
1937
+ return (leftDelimiter === '[' ? count >= leftNumber : count > leftNumber)
1938
+ && (rightDelimiter === ']' ? count <= rightNumber : count < rightNumber);
1939
+ }
1940
+
1941
+ return false;
1942
+ };
1943
+
1944
+ /**
1945
+ * Returns the plural position to use for the given locale and number.
1946
+ *
1947
+ * The plural rules are derived from code of the Zend Framework (2010-09-25),
1948
+ * which is subject to the new BSD license (http://framework.zend.com/license/new-bsd).
1949
+ * Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
1950
+ *
1951
+ * @param {Number} count
1952
+ * @param {String} locale
1953
+ * @return {Number}
1954
+ */
1955
+ Lang.prototype._getPluralForm = function(count, locale) {
1956
+ switch (locale) {
1957
+ case 'az':
1958
+ case 'bo':
1959
+ case 'dz':
1960
+ case 'id':
1961
+ case 'ja':
1962
+ case 'jv':
1963
+ case 'ka':
1964
+ case 'km':
1965
+ case 'kn':
1966
+ case 'ko':
1967
+ case 'ms':
1968
+ case 'th':
1969
+ case 'tr':
1970
+ case 'vi':
1971
+ case 'zh':
1972
+ return 0;
1973
+
1974
+ case 'af':
1975
+ case 'bn':
1976
+ case 'bg':
1977
+ case 'ca':
1978
+ case 'da':
1979
+ case 'de':
1980
+ case 'el':
1981
+ case 'en':
1982
+ case 'eo':
1983
+ case 'es':
1984
+ case 'et':
1985
+ case 'eu':
1986
+ case 'fa':
1987
+ case 'fi':
1988
+ case 'fo':
1989
+ case 'fur':
1990
+ case 'fy':
1991
+ case 'gl':
1992
+ case 'gu':
1993
+ case 'ha':
1994
+ case 'he':
1995
+ case 'hu':
1996
+ case 'is':
1997
+ case 'it':
1998
+ case 'ku':
1999
+ case 'lb':
2000
+ case 'ml':
2001
+ case 'mn':
2002
+ case 'mr':
2003
+ case 'nah':
2004
+ case 'nb':
2005
+ case 'ne':
2006
+ case 'nl':
2007
+ case 'nn':
2008
+ case 'no':
2009
+ case 'om':
2010
+ case 'or':
2011
+ case 'pa':
2012
+ case 'pap':
2013
+ case 'ps':
2014
+ case 'pt':
2015
+ case 'so':
2016
+ case 'sq':
2017
+ case 'sv':
2018
+ case 'sw':
2019
+ case 'ta':
2020
+ case 'te':
2021
+ case 'tk':
2022
+ case 'ur':
2023
+ case 'zu':
2024
+ return (count == 1)
2025
+ ? 0
2026
+ : 1;
2027
+
2028
+ case 'am':
2029
+ case 'bh':
2030
+ case 'fil':
2031
+ case 'fr':
2032
+ case 'gun':
2033
+ case 'hi':
2034
+ case 'hy':
2035
+ case 'ln':
2036
+ case 'mg':
2037
+ case 'nso':
2038
+ case 'xbr':
2039
+ case 'ti':
2040
+ case 'wa':
2041
+ return ((count === 0) || (count === 1))
2042
+ ? 0
2043
+ : 1;
2044
+
2045
+ case 'be':
2046
+ case 'bs':
2047
+ case 'hr':
2048
+ case 'ru':
2049
+ case 'sr':
2050
+ case 'uk':
2051
+ return ((count % 10 == 1) && (count % 100 != 11))
2052
+ ? 0
2053
+ : (((count % 10 >= 2) && (count % 10 <= 4) && ((count % 100 < 10) || (count % 100 >= 20)))
2054
+ ? 1
2055
+ : 2);
2056
+
2057
+ case 'cs':
2058
+ case 'sk':
2059
+ return (count == 1)
2060
+ ? 0
2061
+ : (((count >= 2) && (count <= 4))
2062
+ ? 1
2063
+ : 2);
2064
+
2065
+ case 'ga':
2066
+ return (count == 1)
2067
+ ? 0
2068
+ : ((count == 2)
2069
+ ? 1
2070
+ : 2);
2071
+
2072
+ case 'lt':
2073
+ return ((count % 10 == 1) && (count % 100 != 11))
2074
+ ? 0
2075
+ : (((count % 10 >= 2) && ((count % 100 < 10) || (count % 100 >= 20)))
2076
+ ? 1
2077
+ : 2);
2078
+
2079
+ case 'sl':
2080
+ return (count % 100 == 1)
2081
+ ? 0
2082
+ : ((count % 100 == 2)
2083
+ ? 1
2084
+ : (((count % 100 == 3) || (count % 100 == 4))
2085
+ ? 2
2086
+ : 3));
2087
+
2088
+ case 'mk':
2089
+ return (count % 10 == 1)
2090
+ ? 0
2091
+ : 1;
2092
+
2093
+ case 'mt':
2094
+ return (count == 1)
2095
+ ? 0
2096
+ : (((count === 0) || ((count % 100 > 1) && (count % 100 < 11)))
2097
+ ? 1
2098
+ : (((count % 100 > 10) && (count % 100 < 20))
2099
+ ? 2
2100
+ : 3));
2101
+
2102
+ case 'lv':
2103
+ return (count === 0)
2104
+ ? 0
2105
+ : (((count % 10 == 1) && (count % 100 != 11))
2106
+ ? 1
2107
+ : 2);
2108
+
2109
+ case 'pl':
2110
+ return (count == 1)
2111
+ ? 0
2112
+ : (((count % 10 >= 2) && (count % 10 <= 4) && ((count % 100 < 12) || (count % 100 > 14)))
2113
+ ? 1
2114
+ : 2);
2115
+
2116
+ case 'cy':
2117
+ return (count == 1)
2118
+ ? 0
2119
+ : ((count == 2)
2120
+ ? 1
2121
+ : (((count == 8) || (count == 11))
2122
+ ? 2
2123
+ : 3));
2124
+
2125
+ case 'ro':
2126
+ return (count == 1)
2127
+ ? 0
2128
+ : (((count === 0) || ((count % 100 > 0) && (count % 100 < 20)))
2129
+ ? 1
2130
+ : 2);
2131
+
2132
+ case 'ar':
2133
+ return (count === 0)
2134
+ ? 0
2135
+ : ((count == 1)
2136
+ ? 1
2137
+ : ((count == 2)
2138
+ ? 2
2139
+ : (((count % 100 >= 3) && (count % 100 <= 10))
2140
+ ? 3
2141
+ : (((count % 100 >= 11) && (count % 100 <= 99))
2142
+ ? 4
2143
+ : 5))));
2144
+
2145
+ default:
2146
+ return 0;
2147
+ }
2148
+ };
2149
+
2150
+ return Lang;
2151
+
2152
+ }));
2153
+ });
2154
+
2155
+ var bind = function bind(fn, thisArg) {
2156
+ return function wrap() {
2157
+ var args = new Array(arguments.length);
2158
+ for (var i = 0; i < args.length; i++) {
2159
+ args[i] = arguments[i];
2160
+ }
2161
+ return fn.apply(thisArg, args);
2162
+ };
2163
+ };
2164
+
2165
+ // utils is a library of generic helper functions non-specific to axios
2166
+
2167
+ var toString = Object.prototype.toString;
2168
+
2169
+ // eslint-disable-next-line func-names
2170
+ var kindOf = (function(cache) {
2171
+ // eslint-disable-next-line func-names
2172
+ return function(thing) {
2173
+ var str = toString.call(thing);
2174
+ return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
2175
+ };
2176
+ })(Object.create(null));
2177
+
2178
+ function kindOfTest(type) {
2179
+ type = type.toLowerCase();
2180
+ return function isKindOf(thing) {
2181
+ return kindOf(thing) === type;
2182
+ };
2183
+ }
2184
+
2185
+ /**
2186
+ * Determine if a value is an Array
2187
+ *
2188
+ * @param {Object} val The value to test
2189
+ * @returns {boolean} True if value is an Array, otherwise false
2190
+ */
2191
+ function isArray(val) {
2192
+ return Array.isArray(val);
2193
+ }
2194
+
2195
+ /**
2196
+ * Determine if a value is undefined
2197
+ *
2198
+ * @param {Object} val The value to test
2199
+ * @returns {boolean} True if the value is undefined, otherwise false
2200
+ */
2201
+ function isUndefined(val) {
2202
+ return typeof val === 'undefined';
2203
+ }
2204
+
2205
+ /**
2206
+ * Determine if a value is a Buffer
2207
+ *
2208
+ * @param {Object} val The value to test
2209
+ * @returns {boolean} True if value is a Buffer, otherwise false
2210
+ */
2211
+ function isBuffer(val) {
2212
+ return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
2213
+ && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
2214
+ }
2215
+
2216
+ /**
2217
+ * Determine if a value is an ArrayBuffer
2218
+ *
2219
+ * @function
2220
+ * @param {Object} val The value to test
2221
+ * @returns {boolean} True if value is an ArrayBuffer, otherwise false
2222
+ */
2223
+ var isArrayBuffer = kindOfTest('ArrayBuffer');
2224
+
2225
+
2226
+ /**
2227
+ * Determine if a value is a view on an ArrayBuffer
2228
+ *
2229
+ * @param {Object} val The value to test
2230
+ * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
2231
+ */
2232
+ function isArrayBufferView(val) {
2233
+ var result;
2234
+ if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
2235
+ result = ArrayBuffer.isView(val);
2236
+ } else {
2237
+ result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
2238
+ }
2239
+ return result;
2240
+ }
2241
+
2242
+ /**
2243
+ * Determine if a value is a String
2244
+ *
2245
+ * @param {Object} val The value to test
2246
+ * @returns {boolean} True if value is a String, otherwise false
2247
+ */
2248
+ function isString(val) {
2249
+ return typeof val === 'string';
2250
+ }
2251
+
2252
+ /**
2253
+ * Determine if a value is a Number
2254
+ *
2255
+ * @param {Object} val The value to test
2256
+ * @returns {boolean} True if value is a Number, otherwise false
2257
+ */
2258
+ function isNumber(val) {
2259
+ return typeof val === 'number';
2260
+ }
2261
+
2262
+ /**
2263
+ * Determine if a value is an Object
2264
+ *
2265
+ * @param {Object} val The value to test
2266
+ * @returns {boolean} True if value is an Object, otherwise false
2267
+ */
2268
+ function isObject(val) {
2269
+ return val !== null && typeof val === 'object';
2270
+ }
2271
+
2272
+ /**
2273
+ * Determine if a value is a plain Object
2274
+ *
2275
+ * @param {Object} val The value to test
2276
+ * @return {boolean} True if value is a plain Object, otherwise false
2277
+ */
2278
+ function isPlainObject(val) {
2279
+ if (kindOf(val) !== 'object') {
2280
+ return false;
2281
+ }
2282
+
2283
+ var prototype = Object.getPrototypeOf(val);
2284
+ return prototype === null || prototype === Object.prototype;
2285
+ }
2286
+
2287
+ /**
2288
+ * Determine if a value is a Date
2289
+ *
2290
+ * @function
2291
+ * @param {Object} val The value to test
2292
+ * @returns {boolean} True if value is a Date, otherwise false
2293
+ */
2294
+ var isDate = kindOfTest('Date');
2295
+
2296
+ /**
2297
+ * Determine if a value is a File
2298
+ *
2299
+ * @function
2300
+ * @param {Object} val The value to test
2301
+ * @returns {boolean} True if value is a File, otherwise false
2302
+ */
2303
+ var isFile = kindOfTest('File');
2304
+
2305
+ /**
2306
+ * Determine if a value is a Blob
2307
+ *
2308
+ * @function
2309
+ * @param {Object} val The value to test
2310
+ * @returns {boolean} True if value is a Blob, otherwise false
2311
+ */
2312
+ var isBlob = kindOfTest('Blob');
2313
+
2314
+ /**
2315
+ * Determine if a value is a FileList
2316
+ *
2317
+ * @function
2318
+ * @param {Object} val The value to test
2319
+ * @returns {boolean} True if value is a File, otherwise false
2320
+ */
2321
+ var isFileList = kindOfTest('FileList');
2322
+
2323
+ /**
2324
+ * Determine if a value is a Function
2325
+ *
2326
+ * @param {Object} val The value to test
2327
+ * @returns {boolean} True if value is a Function, otherwise false
2328
+ */
2329
+ function isFunction(val) {
2330
+ return toString.call(val) === '[object Function]';
2331
+ }
2332
+
2333
+ /**
2334
+ * Determine if a value is a Stream
2335
+ *
2336
+ * @param {Object} val The value to test
2337
+ * @returns {boolean} True if value is a Stream, otherwise false
2338
+ */
2339
+ function isStream(val) {
2340
+ return isObject(val) && isFunction(val.pipe);
2341
+ }
2342
+
2343
+ /**
2344
+ * Determine if a value is a FormData
2345
+ *
2346
+ * @param {Object} thing The value to test
2347
+ * @returns {boolean} True if value is an FormData, otherwise false
2348
+ */
2349
+ function isFormData(thing) {
2350
+ var pattern = '[object FormData]';
2351
+ return thing && (
2352
+ (typeof FormData === 'function' && thing instanceof FormData) ||
2353
+ toString.call(thing) === pattern ||
2354
+ (isFunction(thing.toString) && thing.toString() === pattern)
2355
+ );
2356
+ }
2357
+
2358
+ /**
2359
+ * Determine if a value is a URLSearchParams object
2360
+ * @function
2361
+ * @param {Object} val The value to test
2362
+ * @returns {boolean} True if value is a URLSearchParams object, otherwise false
2363
+ */
2364
+ var isURLSearchParams = kindOfTest('URLSearchParams');
2365
+
2366
+ /**
2367
+ * Trim excess whitespace off the beginning and end of a string
2368
+ *
2369
+ * @param {String} str The String to trim
2370
+ * @returns {String} The String freed of excess whitespace
2371
+ */
2372
+ function trim(str) {
2373
+ return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
2374
+ }
2375
+
2376
+ /**
2377
+ * Determine if we're running in a standard browser environment
2378
+ *
2379
+ * This allows axios to run in a web worker, and react-native.
2380
+ * Both environments support XMLHttpRequest, but not fully standard globals.
2381
+ *
2382
+ * web workers:
2383
+ * typeof window -> undefined
2384
+ * typeof document -> undefined
2385
+ *
2386
+ * react-native:
2387
+ * navigator.product -> 'ReactNative'
2388
+ * nativescript
2389
+ * navigator.product -> 'NativeScript' or 'NS'
2390
+ */
2391
+ function isStandardBrowserEnv() {
2392
+ if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
2393
+ navigator.product === 'NativeScript' ||
2394
+ navigator.product === 'NS')) {
2395
+ return false;
2396
+ }
2397
+ return (
2398
+ typeof window !== 'undefined' &&
2399
+ typeof document !== 'undefined'
2400
+ );
2401
+ }
2402
+
2403
+ /**
2404
+ * Iterate over an Array or an Object invoking a function for each item.
2405
+ *
2406
+ * If `obj` is an Array callback will be called passing
2407
+ * the value, index, and complete array for each item.
2408
+ *
2409
+ * If 'obj' is an Object callback will be called passing
2410
+ * the value, key, and complete object for each property.
2411
+ *
2412
+ * @param {Object|Array} obj The object to iterate
2413
+ * @param {Function} fn The callback to invoke for each item
2414
+ */
2415
+ function forEach(obj, fn) {
2416
+ // Don't bother if no value provided
2417
+ if (obj === null || typeof obj === 'undefined') {
2418
+ return;
2419
+ }
2420
+
2421
+ // Force an array if not already something iterable
2422
+ if (typeof obj !== 'object') {
2423
+ /*eslint no-param-reassign:0*/
2424
+ obj = [obj];
2425
+ }
2426
+
2427
+ if (isArray(obj)) {
2428
+ // Iterate over array values
2429
+ for (var i = 0, l = obj.length; i < l; i++) {
2430
+ fn.call(null, obj[i], i, obj);
2431
+ }
2432
+ } else {
2433
+ // Iterate over object keys
2434
+ for (var key in obj) {
2435
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
2436
+ fn.call(null, obj[key], key, obj);
2437
+ }
2438
+ }
2439
+ }
2440
+ }
2441
+
2442
+ /**
2443
+ * Accepts varargs expecting each argument to be an object, then
2444
+ * immutably merges the properties of each object and returns result.
2445
+ *
2446
+ * When multiple objects contain the same key the later object in
2447
+ * the arguments list will take precedence.
2448
+ *
2449
+ * Example:
2450
+ *
2451
+ * ```js
2452
+ * var result = merge({foo: 123}, {foo: 456});
2453
+ * console.log(result.foo); // outputs 456
2454
+ * ```
2455
+ *
2456
+ * @param {Object} obj1 Object to merge
2457
+ * @returns {Object} Result of all merge properties
2458
+ */
2459
+ function merge(/* obj1, obj2, obj3, ... */) {
2460
+ var result = {};
2461
+ function assignValue(val, key) {
2462
+ if (isPlainObject(result[key]) && isPlainObject(val)) {
2463
+ result[key] = merge(result[key], val);
2464
+ } else if (isPlainObject(val)) {
2465
+ result[key] = merge({}, val);
2466
+ } else if (isArray(val)) {
2467
+ result[key] = val.slice();
2468
+ } else {
2469
+ result[key] = val;
2470
+ }
2471
+ }
2472
+
2473
+ for (var i = 0, l = arguments.length; i < l; i++) {
2474
+ forEach(arguments[i], assignValue);
2475
+ }
2476
+ return result;
2477
+ }
2478
+
2479
+ /**
2480
+ * Extends object a by mutably adding to it the properties of object b.
2481
+ *
2482
+ * @param {Object} a The object to be extended
2483
+ * @param {Object} b The object to copy properties from
2484
+ * @param {Object} thisArg The object to bind function to
2485
+ * @return {Object} The resulting value of object a
2486
+ */
2487
+ function extend(a, b, thisArg) {
2488
+ forEach(b, function assignValue(val, key) {
2489
+ if (thisArg && typeof val === 'function') {
2490
+ a[key] = bind(val, thisArg);
2491
+ } else {
2492
+ a[key] = val;
2493
+ }
2494
+ });
2495
+ return a;
2496
+ }
2497
+
2498
+ /**
2499
+ * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
2500
+ *
2501
+ * @param {string} content with BOM
2502
+ * @return {string} content value without BOM
2503
+ */
2504
+ function stripBOM(content) {
2505
+ if (content.charCodeAt(0) === 0xFEFF) {
2506
+ content = content.slice(1);
2507
+ }
2508
+ return content;
2509
+ }
2510
+
2511
+ /**
2512
+ * Inherit the prototype methods from one constructor into another
2513
+ * @param {function} constructor
2514
+ * @param {function} superConstructor
2515
+ * @param {object} [props]
2516
+ * @param {object} [descriptors]
2517
+ */
2518
+
2519
+ function inherits(constructor, superConstructor, props, descriptors) {
2520
+ constructor.prototype = Object.create(superConstructor.prototype, descriptors);
2521
+ constructor.prototype.constructor = constructor;
2522
+ props && Object.assign(constructor.prototype, props);
2523
+ }
2524
+
2525
+ /**
2526
+ * Resolve object with deep prototype chain to a flat object
2527
+ * @param {Object} sourceObj source object
2528
+ * @param {Object} [destObj]
2529
+ * @param {Function} [filter]
2530
+ * @returns {Object}
2531
+ */
2532
+
2533
+ function toFlatObject(sourceObj, destObj, filter) {
2534
+ var props;
2535
+ var i;
2536
+ var prop;
2537
+ var merged = {};
2538
+
2539
+ destObj = destObj || {};
2540
+
2541
+ do {
2542
+ props = Object.getOwnPropertyNames(sourceObj);
2543
+ i = props.length;
2544
+ while (i-- > 0) {
2545
+ prop = props[i];
2546
+ if (!merged[prop]) {
2547
+ destObj[prop] = sourceObj[prop];
2548
+ merged[prop] = true;
2549
+ }
2550
+ }
2551
+ sourceObj = Object.getPrototypeOf(sourceObj);
2552
+ } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
2553
+
2554
+ return destObj;
2555
+ }
2556
+
2557
+ /*
2558
+ * determines whether a string ends with the characters of a specified string
2559
+ * @param {String} str
2560
+ * @param {String} searchString
2561
+ * @param {Number} [position= 0]
2562
+ * @returns {boolean}
2563
+ */
2564
+ function endsWith(str, searchString, position) {
2565
+ str = String(str);
2566
+ if (position === undefined || position > str.length) {
2567
+ position = str.length;
2568
+ }
2569
+ position -= searchString.length;
2570
+ var lastIndex = str.indexOf(searchString, position);
2571
+ return lastIndex !== -1 && lastIndex === position;
2572
+ }
2573
+
2574
+
2575
+ /**
2576
+ * Returns new array from array like object
2577
+ * @param {*} [thing]
2578
+ * @returns {Array}
2579
+ */
2580
+ function toArray(thing) {
2581
+ if (!thing) return null;
2582
+ var i = thing.length;
2583
+ if (isUndefined(i)) return null;
2584
+ var arr = new Array(i);
2585
+ while (i-- > 0) {
2586
+ arr[i] = thing[i];
2587
+ }
2588
+ return arr;
2589
+ }
2590
+
2591
+ // eslint-disable-next-line func-names
2592
+ var isTypedArray = (function(TypedArray) {
2593
+ // eslint-disable-next-line func-names
2594
+ return function(thing) {
2595
+ return TypedArray && thing instanceof TypedArray;
2596
+ };
2597
+ })(typeof Uint8Array !== 'undefined' && Object.getPrototypeOf(Uint8Array));
2598
+
2599
+ var utils = {
2600
+ isArray: isArray,
2601
+ isArrayBuffer: isArrayBuffer,
2602
+ isBuffer: isBuffer,
2603
+ isFormData: isFormData,
2604
+ isArrayBufferView: isArrayBufferView,
2605
+ isString: isString,
2606
+ isNumber: isNumber,
2607
+ isObject: isObject,
2608
+ isPlainObject: isPlainObject,
2609
+ isUndefined: isUndefined,
2610
+ isDate: isDate,
2611
+ isFile: isFile,
2612
+ isBlob: isBlob,
2613
+ isFunction: isFunction,
2614
+ isStream: isStream,
2615
+ isURLSearchParams: isURLSearchParams,
2616
+ isStandardBrowserEnv: isStandardBrowserEnv,
2617
+ forEach: forEach,
2618
+ merge: merge,
2619
+ extend: extend,
2620
+ trim: trim,
2621
+ stripBOM: stripBOM,
2622
+ inherits: inherits,
2623
+ toFlatObject: toFlatObject,
2624
+ kindOf: kindOf,
2625
+ kindOfTest: kindOfTest,
2626
+ endsWith: endsWith,
2627
+ toArray: toArray,
2628
+ isTypedArray: isTypedArray,
2629
+ isFileList: isFileList
2630
+ };
2631
+
2632
+ function encode(val) {
2633
+ return encodeURIComponent(val).
2634
+ replace(/%3A/gi, ':').
2635
+ replace(/%24/g, '$').
2636
+ replace(/%2C/gi, ',').
2637
+ replace(/%20/g, '+').
2638
+ replace(/%5B/gi, '[').
2639
+ replace(/%5D/gi, ']');
2640
+ }
2641
+
2642
+ /**
2643
+ * Build a URL by appending params to the end
2644
+ *
2645
+ * @param {string} url The base of the url (e.g., http://www.google.com)
2646
+ * @param {object} [params] The params to be appended
2647
+ * @returns {string} The formatted url
2648
+ */
2649
+ var buildURL = function buildURL(url, params, paramsSerializer) {
2650
+ /*eslint no-param-reassign:0*/
2651
+ if (!params) {
2652
+ return url;
2653
+ }
2654
+
2655
+ var serializedParams;
2656
+ if (paramsSerializer) {
2657
+ serializedParams = paramsSerializer(params);
2658
+ } else if (utils.isURLSearchParams(params)) {
2659
+ serializedParams = params.toString();
2660
+ } else {
2661
+ var parts = [];
2662
+
2663
+ utils.forEach(params, function serialize(val, key) {
2664
+ if (val === null || typeof val === 'undefined') {
2665
+ return;
2666
+ }
2667
+
2668
+ if (utils.isArray(val)) {
2669
+ key = key + '[]';
2670
+ } else {
2671
+ val = [val];
2672
+ }
2673
+
2674
+ utils.forEach(val, function parseValue(v) {
2675
+ if (utils.isDate(v)) {
2676
+ v = v.toISOString();
2677
+ } else if (utils.isObject(v)) {
2678
+ v = JSON.stringify(v);
2679
+ }
2680
+ parts.push(encode(key) + '=' + encode(v));
2681
+ });
2682
+ });
2683
+
2684
+ serializedParams = parts.join('&');
2685
+ }
2686
+
2687
+ if (serializedParams) {
2688
+ var hashmarkIndex = url.indexOf('#');
2689
+ if (hashmarkIndex !== -1) {
2690
+ url = url.slice(0, hashmarkIndex);
2691
+ }
2692
+
2693
+ url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
2694
+ }
2695
+
2696
+ return url;
2697
+ };
2698
+
2699
+ function InterceptorManager() {
2700
+ this.handlers = [];
2701
+ }
2702
+
2703
+ /**
2704
+ * Add a new interceptor to the stack
2705
+ *
2706
+ * @param {Function} fulfilled The function to handle `then` for a `Promise`
2707
+ * @param {Function} rejected The function to handle `reject` for a `Promise`
2708
+ *
2709
+ * @return {Number} An ID used to remove interceptor later
2710
+ */
2711
+ InterceptorManager.prototype.use = function use(fulfilled, rejected, options) {
2712
+ this.handlers.push({
2713
+ fulfilled: fulfilled,
2714
+ rejected: rejected,
2715
+ synchronous: options ? options.synchronous : false,
2716
+ runWhen: options ? options.runWhen : null
2717
+ });
2718
+ return this.handlers.length - 1;
2719
+ };
2720
+
2721
+ /**
2722
+ * Remove an interceptor from the stack
2723
+ *
2724
+ * @param {Number} id The ID that was returned by `use`
2725
+ */
2726
+ InterceptorManager.prototype.eject = function eject(id) {
2727
+ if (this.handlers[id]) {
2728
+ this.handlers[id] = null;
2729
+ }
2730
+ };
2731
+
2732
+ /**
2733
+ * Iterate over all the registered interceptors
2734
+ *
2735
+ * This method is particularly useful for skipping over any
2736
+ * interceptors that may have become `null` calling `eject`.
2737
+ *
2738
+ * @param {Function} fn The function to call for each interceptor
2739
+ */
2740
+ InterceptorManager.prototype.forEach = function forEach(fn) {
2741
+ utils.forEach(this.handlers, function forEachHandler(h) {
2742
+ if (h !== null) {
2743
+ fn(h);
2744
+ }
2745
+ });
2746
+ };
2747
+
2748
+ var InterceptorManager_1 = InterceptorManager;
2749
+
2750
+ var normalizeHeaderName = function normalizeHeaderName(headers, normalizedName) {
2751
+ utils.forEach(headers, function processHeader(value, name) {
2752
+ if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
2753
+ headers[normalizedName] = value;
2754
+ delete headers[name];
2755
+ }
2756
+ });
2757
+ };
2758
+
2759
+ /**
2760
+ * Create an Error with the specified message, config, error code, request and response.
2761
+ *
2762
+ * @param {string} message The error message.
2763
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
2764
+ * @param {Object} [config] The config.
2765
+ * @param {Object} [request] The request.
2766
+ * @param {Object} [response] The response.
2767
+ * @returns {Error} The created error.
2768
+ */
2769
+ function AxiosError(message, code, config, request, response) {
2770
+ Error.call(this);
2771
+ this.message = message;
2772
+ this.name = 'AxiosError';
2773
+ code && (this.code = code);
2774
+ config && (this.config = config);
2775
+ request && (this.request = request);
2776
+ response && (this.response = response);
2777
+ }
2778
+
2779
+ utils.inherits(AxiosError, Error, {
2780
+ toJSON: function toJSON() {
2781
+ return {
2782
+ // Standard
2783
+ message: this.message,
2784
+ name: this.name,
2785
+ // Microsoft
2786
+ description: this.description,
2787
+ number: this.number,
2788
+ // Mozilla
2789
+ fileName: this.fileName,
2790
+ lineNumber: this.lineNumber,
2791
+ columnNumber: this.columnNumber,
2792
+ stack: this.stack,
2793
+ // Axios
2794
+ config: this.config,
2795
+ code: this.code,
2796
+ status: this.response && this.response.status ? this.response.status : null
2797
+ };
2798
+ }
2799
+ });
2800
+
2801
+ var prototype = AxiosError.prototype;
2802
+ var descriptors = {};
2803
+
2804
+ [
2805
+ 'ERR_BAD_OPTION_VALUE',
2806
+ 'ERR_BAD_OPTION',
2807
+ 'ECONNABORTED',
2808
+ 'ETIMEDOUT',
2809
+ 'ERR_NETWORK',
2810
+ 'ERR_FR_TOO_MANY_REDIRECTS',
2811
+ 'ERR_DEPRECATED',
2812
+ 'ERR_BAD_RESPONSE',
2813
+ 'ERR_BAD_REQUEST',
2814
+ 'ERR_CANCELED'
2815
+ // eslint-disable-next-line func-names
2816
+ ].forEach(function(code) {
2817
+ descriptors[code] = {value: code};
2818
+ });
2819
+
2820
+ Object.defineProperties(AxiosError, descriptors);
2821
+ Object.defineProperty(prototype, 'isAxiosError', {value: true});
2822
+
2823
+ // eslint-disable-next-line func-names
2824
+ AxiosError.from = function(error, code, config, request, response, customProps) {
2825
+ var axiosError = Object.create(prototype);
2826
+
2827
+ utils.toFlatObject(error, axiosError, function filter(obj) {
2828
+ return obj !== Error.prototype;
2829
+ });
2830
+
2831
+ AxiosError.call(axiosError, error.message, code, config, request, response);
2832
+
2833
+ axiosError.name = error.name;
2834
+
2835
+ customProps && Object.assign(axiosError, customProps);
2836
+
2837
+ return axiosError;
2838
+ };
2839
+
2840
+ var AxiosError_1 = AxiosError;
2841
+
2842
+ var transitional = {
2843
+ silentJSONParsing: true,
2844
+ forcedJSONParsing: true,
2845
+ clarifyTimeoutError: false
2846
+ };
2847
+
2848
+ /**
2849
+ * Convert a data object to FormData
2850
+ * @param {Object} obj
2851
+ * @param {?Object} [formData]
2852
+ * @returns {Object}
2853
+ **/
2854
+
2855
+ function toFormData(obj, formData) {
2856
+ // eslint-disable-next-line no-param-reassign
2857
+ formData = formData || new FormData();
2858
+
2859
+ var stack = [];
2860
+
2861
+ function convertValue(value) {
2862
+ if (value === null) return '';
2863
+
2864
+ if (utils.isDate(value)) {
2865
+ return value.toISOString();
2866
+ }
2867
+
2868
+ if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
2869
+ return typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
2870
+ }
2871
+
2872
+ return value;
2873
+ }
2874
+
2875
+ function build(data, parentKey) {
2876
+ if (utils.isPlainObject(data) || utils.isArray(data)) {
2877
+ if (stack.indexOf(data) !== -1) {
2878
+ throw Error('Circular reference detected in ' + parentKey);
2879
+ }
2880
+
2881
+ stack.push(data);
2882
+
2883
+ utils.forEach(data, function each(value, key) {
2884
+ if (utils.isUndefined(value)) return;
2885
+ var fullKey = parentKey ? parentKey + '.' + key : key;
2886
+ var arr;
2887
+
2888
+ if (value && !parentKey && typeof value === 'object') {
2889
+ if (utils.endsWith(key, '{}')) {
2890
+ // eslint-disable-next-line no-param-reassign
2891
+ value = JSON.stringify(value);
2892
+ } else if (utils.endsWith(key, '[]') && (arr = utils.toArray(value))) {
2893
+ // eslint-disable-next-line func-names
2894
+ arr.forEach(function(el) {
2895
+ !utils.isUndefined(el) && formData.append(fullKey, convertValue(el));
2896
+ });
2897
+ return;
2898
+ }
2899
+ }
2900
+
2901
+ build(value, fullKey);
2902
+ });
2903
+
2904
+ stack.pop();
2905
+ } else {
2906
+ formData.append(parentKey, convertValue(data));
2907
+ }
2908
+ }
2909
+
2910
+ build(obj);
2911
+
2912
+ return formData;
2913
+ }
2914
+
2915
+ var toFormData_1 = toFormData;
2916
+
2917
+ /**
2918
+ * Resolve or reject a Promise based on response status.
2919
+ *
2920
+ * @param {Function} resolve A function that resolves the promise.
2921
+ * @param {Function} reject A function that rejects the promise.
2922
+ * @param {object} response The response.
2923
+ */
2924
+ var settle = function settle(resolve, reject, response) {
2925
+ var validateStatus = response.config.validateStatus;
2926
+ if (!response.status || !validateStatus || validateStatus(response.status)) {
2927
+ resolve(response);
2928
+ } else {
2929
+ reject(new AxiosError_1(
2930
+ 'Request failed with status code ' + response.status,
2931
+ [AxiosError_1.ERR_BAD_REQUEST, AxiosError_1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
2932
+ response.config,
2933
+ response.request,
2934
+ response
2935
+ ));
2936
+ }
2937
+ };
2938
+
2939
+ var cookies = (
2940
+ utils.isStandardBrowserEnv() ?
2941
+
2942
+ // Standard browser envs support document.cookie
2943
+ (function standardBrowserEnv() {
2944
+ return {
2945
+ write: function write(name, value, expires, path, domain, secure) {
2946
+ var cookie = [];
2947
+ cookie.push(name + '=' + encodeURIComponent(value));
2948
+
2949
+ if (utils.isNumber(expires)) {
2950
+ cookie.push('expires=' + new Date(expires).toGMTString());
2951
+ }
2952
+
2953
+ if (utils.isString(path)) {
2954
+ cookie.push('path=' + path);
2955
+ }
2956
+
2957
+ if (utils.isString(domain)) {
2958
+ cookie.push('domain=' + domain);
2959
+ }
2960
+
2961
+ if (secure === true) {
2962
+ cookie.push('secure');
2963
+ }
2964
+
2965
+ document.cookie = cookie.join('; ');
2966
+ },
2967
+
2968
+ read: function read(name) {
2969
+ var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
2970
+ return (match ? decodeURIComponent(match[3]) : null);
2971
+ },
2972
+
2973
+ remove: function remove(name) {
2974
+ this.write(name, '', Date.now() - 86400000);
2975
+ }
2976
+ };
2977
+ })() :
2978
+
2979
+ // Non standard browser env (web workers, react-native) lack needed support.
2980
+ (function nonStandardBrowserEnv() {
2981
+ return {
2982
+ write: function write() {},
2983
+ read: function read() { return null; },
2984
+ remove: function remove() {}
2985
+ };
2986
+ })()
2987
+ );
2988
+
2989
+ /**
2990
+ * Determines whether the specified URL is absolute
2991
+ *
2992
+ * @param {string} url The URL to test
2993
+ * @returns {boolean} True if the specified URL is absolute, otherwise false
2994
+ */
2995
+ var isAbsoluteURL = function isAbsoluteURL(url) {
2996
+ // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
2997
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
2998
+ // by any combination of letters, digits, plus, period, or hyphen.
2999
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
3000
+ };
3001
+
3002
+ /**
3003
+ * Creates a new URL by combining the specified URLs
3004
+ *
3005
+ * @param {string} baseURL The base URL
3006
+ * @param {string} relativeURL The relative URL
3007
+ * @returns {string} The combined URL
3008
+ */
3009
+ var combineURLs = function combineURLs(baseURL, relativeURL) {
3010
+ return relativeURL
3011
+ ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
3012
+ : baseURL;
3013
+ };
3014
+
3015
+ /**
3016
+ * Creates a new URL by combining the baseURL with the requestedURL,
3017
+ * only when the requestedURL is not already an absolute URL.
3018
+ * If the requestURL is absolute, this function returns the requestedURL untouched.
3019
+ *
3020
+ * @param {string} baseURL The base URL
3021
+ * @param {string} requestedURL Absolute or relative URL to combine
3022
+ * @returns {string} The combined full path
3023
+ */
3024
+ var buildFullPath = function buildFullPath(baseURL, requestedURL) {
3025
+ if (baseURL && !isAbsoluteURL(requestedURL)) {
3026
+ return combineURLs(baseURL, requestedURL);
3027
+ }
3028
+ return requestedURL;
3029
+ };
3030
+
3031
+ // Headers whose duplicates are ignored by node
3032
+ // c.f. https://nodejs.org/api/http.html#http_message_headers
3033
+ var ignoreDuplicateOf = [
3034
+ 'age', 'authorization', 'content-length', 'content-type', 'etag',
3035
+ 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
3036
+ 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
3037
+ 'referer', 'retry-after', 'user-agent'
3038
+ ];
3039
+
3040
+ /**
3041
+ * Parse headers into an object
3042
+ *
3043
+ * ```
3044
+ * Date: Wed, 27 Aug 2014 08:58:49 GMT
3045
+ * Content-Type: application/json
3046
+ * Connection: keep-alive
3047
+ * Transfer-Encoding: chunked
3048
+ * ```
3049
+ *
3050
+ * @param {String} headers Headers needing to be parsed
3051
+ * @returns {Object} Headers parsed into an object
3052
+ */
3053
+ var parseHeaders = function parseHeaders(headers) {
3054
+ var parsed = {};
3055
+ var key;
3056
+ var val;
3057
+ var i;
3058
+
3059
+ if (!headers) { return parsed; }
3060
+
3061
+ utils.forEach(headers.split('\n'), function parser(line) {
3062
+ i = line.indexOf(':');
3063
+ key = utils.trim(line.substr(0, i)).toLowerCase();
3064
+ val = utils.trim(line.substr(i + 1));
3065
+
3066
+ if (key) {
3067
+ if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
3068
+ return;
3069
+ }
3070
+ if (key === 'set-cookie') {
3071
+ parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
3072
+ } else {
3073
+ parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
3074
+ }
3075
+ }
3076
+ });
3077
+
3078
+ return parsed;
3079
+ };
3080
+
3081
+ var isURLSameOrigin = (
3082
+ utils.isStandardBrowserEnv() ?
3083
+
3084
+ // Standard browser envs have full support of the APIs needed to test
3085
+ // whether the request URL is of the same origin as current location.
3086
+ (function standardBrowserEnv() {
3087
+ var msie = /(msie|trident)/i.test(navigator.userAgent);
3088
+ var urlParsingNode = document.createElement('a');
3089
+ var originURL;
3090
+
3091
+ /**
3092
+ * Parse a URL to discover it's components
3093
+ *
3094
+ * @param {String} url The URL to be parsed
3095
+ * @returns {Object}
3096
+ */
3097
+ function resolveURL(url) {
3098
+ var href = url;
3099
+
3100
+ if (msie) {
3101
+ // IE needs attribute set twice to normalize properties
3102
+ urlParsingNode.setAttribute('href', href);
3103
+ href = urlParsingNode.href;
3104
+ }
3105
+
3106
+ urlParsingNode.setAttribute('href', href);
3107
+
3108
+ // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
3109
+ return {
3110
+ href: urlParsingNode.href,
3111
+ protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
3112
+ host: urlParsingNode.host,
3113
+ search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
3114
+ hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
3115
+ hostname: urlParsingNode.hostname,
3116
+ port: urlParsingNode.port,
3117
+ pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
3118
+ urlParsingNode.pathname :
3119
+ '/' + urlParsingNode.pathname
3120
+ };
3121
+ }
3122
+
3123
+ originURL = resolveURL(window.location.href);
3124
+
3125
+ /**
3126
+ * Determine if a URL shares the same origin as the current location
3127
+ *
3128
+ * @param {String} requestURL The URL to test
3129
+ * @returns {boolean} True if URL shares the same origin, otherwise false
3130
+ */
3131
+ return function isURLSameOrigin(requestURL) {
3132
+ var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
3133
+ return (parsed.protocol === originURL.protocol &&
3134
+ parsed.host === originURL.host);
3135
+ };
3136
+ })() :
3137
+
3138
+ // Non standard browser envs (web workers, react-native) lack needed support.
3139
+ (function nonStandardBrowserEnv() {
3140
+ return function isURLSameOrigin() {
3141
+ return true;
3142
+ };
3143
+ })()
3144
+ );
3145
+
3146
+ /**
3147
+ * A `CanceledError` is an object that is thrown when an operation is canceled.
3148
+ *
3149
+ * @class
3150
+ * @param {string=} message The message.
3151
+ */
3152
+ function CanceledError(message) {
3153
+ // eslint-disable-next-line no-eq-null,eqeqeq
3154
+ AxiosError_1.call(this, message == null ? 'canceled' : message, AxiosError_1.ERR_CANCELED);
3155
+ this.name = 'CanceledError';
3156
+ }
3157
+
3158
+ utils.inherits(CanceledError, AxiosError_1, {
3159
+ __CANCEL__: true
3160
+ });
3161
+
3162
+ var CanceledError_1 = CanceledError;
3163
+
3164
+ var parseProtocol = function parseProtocol(url) {
3165
+ var match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
3166
+ return match && match[1] || '';
3167
+ };
3168
+
3169
+ var xhr = function xhrAdapter(config) {
3170
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
3171
+ var requestData = config.data;
3172
+ var requestHeaders = config.headers;
3173
+ var responseType = config.responseType;
3174
+ var onCanceled;
3175
+ function done() {
3176
+ if (config.cancelToken) {
3177
+ config.cancelToken.unsubscribe(onCanceled);
3178
+ }
3179
+
3180
+ if (config.signal) {
3181
+ config.signal.removeEventListener('abort', onCanceled);
3182
+ }
3183
+ }
3184
+
3185
+ if (utils.isFormData(requestData) && utils.isStandardBrowserEnv()) {
3186
+ delete requestHeaders['Content-Type']; // Let the browser set it
3187
+ }
3188
+
3189
+ var request = new XMLHttpRequest();
3190
+
3191
+ // HTTP basic authentication
3192
+ if (config.auth) {
3193
+ var username = config.auth.username || '';
3194
+ var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
3195
+ requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
3196
+ }
3197
+
3198
+ var fullPath = buildFullPath(config.baseURL, config.url);
3199
+
3200
+ request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
3201
+
3202
+ // Set the request timeout in MS
3203
+ request.timeout = config.timeout;
3204
+
3205
+ function onloadend() {
3206
+ if (!request) {
3207
+ return;
3208
+ }
3209
+ // Prepare the response
3210
+ var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
3211
+ var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
3212
+ request.responseText : request.response;
3213
+ var response = {
3214
+ data: responseData,
3215
+ status: request.status,
3216
+ statusText: request.statusText,
3217
+ headers: responseHeaders,
3218
+ config: config,
3219
+ request: request
3220
+ };
3221
+
3222
+ settle(function _resolve(value) {
3223
+ resolve(value);
3224
+ done();
3225
+ }, function _reject(err) {
3226
+ reject(err);
3227
+ done();
3228
+ }, response);
3229
+
3230
+ // Clean up request
3231
+ request = null;
3232
+ }
3233
+
3234
+ if ('onloadend' in request) {
3235
+ // Use onloadend if available
3236
+ request.onloadend = onloadend;
3237
+ } else {
3238
+ // Listen for ready state to emulate onloadend
3239
+ request.onreadystatechange = function handleLoad() {
3240
+ if (!request || request.readyState !== 4) {
3241
+ return;
3242
+ }
3243
+
3244
+ // The request errored out and we didn't get a response, this will be
3245
+ // handled by onerror instead
3246
+ // With one exception: request that using file: protocol, most browsers
3247
+ // will return status as 0 even though it's a successful request
3248
+ if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
3249
+ return;
3250
+ }
3251
+ // readystate handler is calling before onerror or ontimeout handlers,
3252
+ // so we should call onloadend on the next 'tick'
3253
+ setTimeout(onloadend);
3254
+ };
3255
+ }
3256
+
3257
+ // Handle browser request cancellation (as opposed to a manual cancellation)
3258
+ request.onabort = function handleAbort() {
3259
+ if (!request) {
3260
+ return;
3261
+ }
3262
+
3263
+ reject(new AxiosError_1('Request aborted', AxiosError_1.ECONNABORTED, config, request));
3264
+
3265
+ // Clean up request
3266
+ request = null;
3267
+ };
3268
+
3269
+ // Handle low level network errors
3270
+ request.onerror = function handleError() {
3271
+ // Real errors are hidden from us by the browser
3272
+ // onerror should only fire if it's a network error
3273
+ reject(new AxiosError_1('Network Error', AxiosError_1.ERR_NETWORK, config, request, request));
3274
+
3275
+ // Clean up request
3276
+ request = null;
3277
+ };
3278
+
3279
+ // Handle timeout
3280
+ request.ontimeout = function handleTimeout() {
3281
+ var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
3282
+ var transitional$1 = config.transitional || transitional;
3283
+ if (config.timeoutErrorMessage) {
3284
+ timeoutErrorMessage = config.timeoutErrorMessage;
3285
+ }
3286
+ reject(new AxiosError_1(
3287
+ timeoutErrorMessage,
3288
+ transitional$1.clarifyTimeoutError ? AxiosError_1.ETIMEDOUT : AxiosError_1.ECONNABORTED,
3289
+ config,
3290
+ request));
3291
+
3292
+ // Clean up request
3293
+ request = null;
3294
+ };
3295
+
3296
+ // Add xsrf header
3297
+ // This is only done if running in a standard browser environment.
3298
+ // Specifically not if we're in a web worker, or react-native.
3299
+ if (utils.isStandardBrowserEnv()) {
3300
+ // Add xsrf header
3301
+ var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
3302
+ cookies.read(config.xsrfCookieName) :
3303
+ undefined;
3304
+
3305
+ if (xsrfValue) {
3306
+ requestHeaders[config.xsrfHeaderName] = xsrfValue;
3307
+ }
3308
+ }
3309
+
3310
+ // Add headers to the request
3311
+ if ('setRequestHeader' in request) {
3312
+ utils.forEach(requestHeaders, function setRequestHeader(val, key) {
3313
+ if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
3314
+ // Remove Content-Type if data is undefined
3315
+ delete requestHeaders[key];
3316
+ } else {
3317
+ // Otherwise add header to the request
3318
+ request.setRequestHeader(key, val);
3319
+ }
3320
+ });
3321
+ }
3322
+
3323
+ // Add withCredentials to request if needed
3324
+ if (!utils.isUndefined(config.withCredentials)) {
3325
+ request.withCredentials = !!config.withCredentials;
3326
+ }
3327
+
3328
+ // Add responseType to request if needed
3329
+ if (responseType && responseType !== 'json') {
3330
+ request.responseType = config.responseType;
3331
+ }
3332
+
3333
+ // Handle progress if needed
3334
+ if (typeof config.onDownloadProgress === 'function') {
3335
+ request.addEventListener('progress', config.onDownloadProgress);
3336
+ }
3337
+
3338
+ // Not all browsers support upload events
3339
+ if (typeof config.onUploadProgress === 'function' && request.upload) {
3340
+ request.upload.addEventListener('progress', config.onUploadProgress);
3341
+ }
3342
+
3343
+ if (config.cancelToken || config.signal) {
3344
+ // Handle cancellation
3345
+ // eslint-disable-next-line func-names
3346
+ onCanceled = function(cancel) {
3347
+ if (!request) {
3348
+ return;
3349
+ }
3350
+ reject(!cancel || (cancel && cancel.type) ? new CanceledError_1() : cancel);
3351
+ request.abort();
3352
+ request = null;
3353
+ };
3354
+
3355
+ config.cancelToken && config.cancelToken.subscribe(onCanceled);
3356
+ if (config.signal) {
3357
+ config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
3358
+ }
3359
+ }
3360
+
3361
+ if (!requestData) {
3362
+ requestData = null;
3363
+ }
3364
+
3365
+ var protocol = parseProtocol(fullPath);
3366
+
3367
+ if (protocol && [ 'http', 'https', 'file' ].indexOf(protocol) === -1) {
3368
+ reject(new AxiosError_1('Unsupported protocol ' + protocol + ':', AxiosError_1.ERR_BAD_REQUEST, config));
3369
+ return;
3370
+ }
3371
+
3372
+
3373
+ // Send the request
3374
+ request.send(requestData);
3375
+ });
3376
+ };
3377
+
3378
+ // eslint-disable-next-line strict
3379
+ var _null = null;
3380
+
3381
+ var DEFAULT_CONTENT_TYPE = {
3382
+ 'Content-Type': 'application/x-www-form-urlencoded'
3383
+ };
3384
+
3385
+ function setContentTypeIfUnset(headers, value) {
3386
+ if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
3387
+ headers['Content-Type'] = value;
3388
+ }
3389
+ }
3390
+
3391
+ function getDefaultAdapter() {
3392
+ var adapter;
3393
+ if (typeof XMLHttpRequest !== 'undefined') {
3394
+ // For browsers use XHR adapter
3395
+ adapter = xhr;
3396
+ } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
3397
+ // For node use HTTP adapter
3398
+ adapter = xhr;
3399
+ }
3400
+ return adapter;
3401
+ }
3402
+
3403
+ function stringifySafely(rawValue, parser, encoder) {
3404
+ if (utils.isString(rawValue)) {
3405
+ try {
3406
+ (parser || JSON.parse)(rawValue);
3407
+ return utils.trim(rawValue);
3408
+ } catch (e) {
3409
+ if (e.name !== 'SyntaxError') {
3410
+ throw e;
3411
+ }
3412
+ }
3413
+ }
3414
+
3415
+ return (encoder || JSON.stringify)(rawValue);
3416
+ }
3417
+
3418
+ var defaults = {
3419
+
3420
+ transitional: transitional,
3421
+
3422
+ adapter: getDefaultAdapter(),
3423
+
3424
+ transformRequest: [function transformRequest(data, headers) {
3425
+ normalizeHeaderName(headers, 'Accept');
3426
+ normalizeHeaderName(headers, 'Content-Type');
3427
+
3428
+ if (utils.isFormData(data) ||
3429
+ utils.isArrayBuffer(data) ||
3430
+ utils.isBuffer(data) ||
3431
+ utils.isStream(data) ||
3432
+ utils.isFile(data) ||
3433
+ utils.isBlob(data)
3434
+ ) {
3435
+ return data;
3436
+ }
3437
+ if (utils.isArrayBufferView(data)) {
3438
+ return data.buffer;
3439
+ }
3440
+ if (utils.isURLSearchParams(data)) {
3441
+ setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
3442
+ return data.toString();
3443
+ }
3444
+
3445
+ var isObjectPayload = utils.isObject(data);
3446
+ var contentType = headers && headers['Content-Type'];
3447
+
3448
+ var isFileList;
3449
+
3450
+ if ((isFileList = utils.isFileList(data)) || (isObjectPayload && contentType === 'multipart/form-data')) {
3451
+ var _FormData = this.env && this.env.FormData;
3452
+ return toFormData_1(isFileList ? {'files[]': data} : data, _FormData && new _FormData());
3453
+ } else if (isObjectPayload || contentType === 'application/json') {
3454
+ setContentTypeIfUnset(headers, 'application/json');
3455
+ return stringifySafely(data);
3456
+ }
3457
+
3458
+ return data;
3459
+ }],
3460
+
3461
+ transformResponse: [function transformResponse(data) {
3462
+ var transitional = this.transitional || defaults.transitional;
3463
+ var silentJSONParsing = transitional && transitional.silentJSONParsing;
3464
+ var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
3465
+ var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
3466
+
3467
+ if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) {
3468
+ try {
3469
+ return JSON.parse(data);
3470
+ } catch (e) {
3471
+ if (strictJSONParsing) {
3472
+ if (e.name === 'SyntaxError') {
3473
+ throw AxiosError_1.from(e, AxiosError_1.ERR_BAD_RESPONSE, this, null, this.response);
3474
+ }
3475
+ throw e;
3476
+ }
3477
+ }
3478
+ }
3479
+
3480
+ return data;
3481
+ }],
3482
+
3483
+ /**
3484
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
3485
+ * timeout is not created.
3486
+ */
3487
+ timeout: 0,
3488
+
3489
+ xsrfCookieName: 'XSRF-TOKEN',
3490
+ xsrfHeaderName: 'X-XSRF-TOKEN',
3491
+
3492
+ maxContentLength: -1,
3493
+ maxBodyLength: -1,
3494
+
3495
+ env: {
3496
+ FormData: _null
3497
+ },
3498
+
3499
+ validateStatus: function validateStatus(status) {
3500
+ return status >= 200 && status < 300;
3501
+ },
3502
+
3503
+ headers: {
3504
+ common: {
3505
+ 'Accept': 'application/json, text/plain, */*'
3506
+ }
3507
+ }
3508
+ };
3509
+
3510
+ utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
3511
+ defaults.headers[method] = {};
3512
+ });
3513
+
3514
+ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
3515
+ defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
3516
+ });
3517
+
3518
+ var defaults_1 = defaults;
3519
+
3520
+ /**
3521
+ * Transform the data for a request or a response
3522
+ *
3523
+ * @param {Object|String} data The data to be transformed
3524
+ * @param {Array} headers The headers for the request or response
3525
+ * @param {Array|Function} fns A single function or Array of functions
3526
+ * @returns {*} The resulting transformed data
3527
+ */
3528
+ var transformData = function transformData(data, headers, fns) {
3529
+ var context = this || defaults_1;
3530
+ /*eslint no-param-reassign:0*/
3531
+ utils.forEach(fns, function transform(fn) {
3532
+ data = fn.call(context, data, headers);
3533
+ });
3534
+
3535
+ return data;
3536
+ };
3537
+
3538
+ var isCancel = function isCancel(value) {
3539
+ return !!(value && value.__CANCEL__);
3540
+ };
3541
+
3542
+ /**
3543
+ * Throws a `CanceledError` if cancellation has been requested.
3544
+ */
3545
+ function throwIfCancellationRequested(config) {
3546
+ if (config.cancelToken) {
3547
+ config.cancelToken.throwIfRequested();
3548
+ }
3549
+
3550
+ if (config.signal && config.signal.aborted) {
3551
+ throw new CanceledError_1();
3552
+ }
3553
+ }
3554
+
3555
+ /**
3556
+ * Dispatch a request to the server using the configured adapter.
3557
+ *
3558
+ * @param {object} config The config that is to be used for the request
3559
+ * @returns {Promise} The Promise to be fulfilled
3560
+ */
3561
+ var dispatchRequest = function dispatchRequest(config) {
3562
+ throwIfCancellationRequested(config);
3563
+
3564
+ // Ensure headers exist
3565
+ config.headers = config.headers || {};
3566
+
3567
+ // Transform request data
3568
+ config.data = transformData.call(
3569
+ config,
3570
+ config.data,
3571
+ config.headers,
3572
+ config.transformRequest
3573
+ );
3574
+
3575
+ // Flatten headers
3576
+ config.headers = utils.merge(
3577
+ config.headers.common || {},
3578
+ config.headers[config.method] || {},
3579
+ config.headers
3580
+ );
3581
+
3582
+ utils.forEach(
3583
+ ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
3584
+ function cleanHeaderConfig(method) {
3585
+ delete config.headers[method];
3586
+ }
3587
+ );
3588
+
3589
+ var adapter = config.adapter || defaults_1.adapter;
3590
+
3591
+ return adapter(config).then(function onAdapterResolution(response) {
3592
+ throwIfCancellationRequested(config);
3593
+
3594
+ // Transform response data
3595
+ response.data = transformData.call(
3596
+ config,
3597
+ response.data,
3598
+ response.headers,
3599
+ config.transformResponse
3600
+ );
3601
+
3602
+ return response;
3603
+ }, function onAdapterRejection(reason) {
3604
+ if (!isCancel(reason)) {
3605
+ throwIfCancellationRequested(config);
3606
+
3607
+ // Transform response data
3608
+ if (reason && reason.response) {
3609
+ reason.response.data = transformData.call(
3610
+ config,
3611
+ reason.response.data,
3612
+ reason.response.headers,
3613
+ config.transformResponse
3614
+ );
3615
+ }
3616
+ }
3617
+
3618
+ return Promise.reject(reason);
3619
+ });
3620
+ };
3621
+
3622
+ /**
3623
+ * Config-specific merge-function which creates a new config-object
3624
+ * by merging two configuration objects together.
3625
+ *
3626
+ * @param {Object} config1
3627
+ * @param {Object} config2
3628
+ * @returns {Object} New object resulting from merging config2 to config1
3629
+ */
3630
+ var mergeConfig = function mergeConfig(config1, config2) {
3631
+ // eslint-disable-next-line no-param-reassign
3632
+ config2 = config2 || {};
3633
+ var config = {};
3634
+
3635
+ function getMergedValue(target, source) {
3636
+ if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
3637
+ return utils.merge(target, source);
3638
+ } else if (utils.isPlainObject(source)) {
3639
+ return utils.merge({}, source);
3640
+ } else if (utils.isArray(source)) {
3641
+ return source.slice();
3642
+ }
3643
+ return source;
3644
+ }
3645
+
3646
+ // eslint-disable-next-line consistent-return
3647
+ function mergeDeepProperties(prop) {
3648
+ if (!utils.isUndefined(config2[prop])) {
3649
+ return getMergedValue(config1[prop], config2[prop]);
3650
+ } else if (!utils.isUndefined(config1[prop])) {
3651
+ return getMergedValue(undefined, config1[prop]);
3652
+ }
3653
+ }
3654
+
3655
+ // eslint-disable-next-line consistent-return
3656
+ function valueFromConfig2(prop) {
3657
+ if (!utils.isUndefined(config2[prop])) {
3658
+ return getMergedValue(undefined, config2[prop]);
3659
+ }
3660
+ }
3661
+
3662
+ // eslint-disable-next-line consistent-return
3663
+ function defaultToConfig2(prop) {
3664
+ if (!utils.isUndefined(config2[prop])) {
3665
+ return getMergedValue(undefined, config2[prop]);
3666
+ } else if (!utils.isUndefined(config1[prop])) {
3667
+ return getMergedValue(undefined, config1[prop]);
3668
+ }
3669
+ }
3670
+
3671
+ // eslint-disable-next-line consistent-return
3672
+ function mergeDirectKeys(prop) {
3673
+ if (prop in config2) {
3674
+ return getMergedValue(config1[prop], config2[prop]);
3675
+ } else if (prop in config1) {
3676
+ return getMergedValue(undefined, config1[prop]);
3677
+ }
3678
+ }
3679
+
3680
+ var mergeMap = {
3681
+ 'url': valueFromConfig2,
3682
+ 'method': valueFromConfig2,
3683
+ 'data': valueFromConfig2,
3684
+ 'baseURL': defaultToConfig2,
3685
+ 'transformRequest': defaultToConfig2,
3686
+ 'transformResponse': defaultToConfig2,
3687
+ 'paramsSerializer': defaultToConfig2,
3688
+ 'timeout': defaultToConfig2,
3689
+ 'timeoutMessage': defaultToConfig2,
3690
+ 'withCredentials': defaultToConfig2,
3691
+ 'adapter': defaultToConfig2,
3692
+ 'responseType': defaultToConfig2,
3693
+ 'xsrfCookieName': defaultToConfig2,
3694
+ 'xsrfHeaderName': defaultToConfig2,
3695
+ 'onUploadProgress': defaultToConfig2,
3696
+ 'onDownloadProgress': defaultToConfig2,
3697
+ 'decompress': defaultToConfig2,
3698
+ 'maxContentLength': defaultToConfig2,
3699
+ 'maxBodyLength': defaultToConfig2,
3700
+ 'beforeRedirect': defaultToConfig2,
3701
+ 'transport': defaultToConfig2,
3702
+ 'httpAgent': defaultToConfig2,
3703
+ 'httpsAgent': defaultToConfig2,
3704
+ 'cancelToken': defaultToConfig2,
3705
+ 'socketPath': defaultToConfig2,
3706
+ 'responseEncoding': defaultToConfig2,
3707
+ 'validateStatus': mergeDirectKeys
3708
+ };
3709
+
3710
+ utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
3711
+ var merge = mergeMap[prop] || mergeDeepProperties;
3712
+ var configValue = merge(prop);
3713
+ (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
3714
+ });
3715
+
3716
+ return config;
3717
+ };
3718
+
3719
+ var data = {
3720
+ "version": "0.27.2"
3721
+ };
3722
+
3723
+ var VERSION = data.version;
3724
+
3725
+
3726
+ var validators$1 = {};
3727
+
3728
+ // eslint-disable-next-line func-names
3729
+ ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
3730
+ validators$1[type] = function validator(thing) {
3731
+ return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
3732
+ };
3733
+ });
3734
+
3735
+ var deprecatedWarnings = {};
3736
+
3737
+ /**
3738
+ * Transitional option validator
3739
+ * @param {function|boolean?} validator - set to false if the transitional option has been removed
3740
+ * @param {string?} version - deprecated version / removed since version
3741
+ * @param {string?} message - some message with additional info
3742
+ * @returns {function}
3743
+ */
3744
+ validators$1.transitional = function transitional(validator, version, message) {
3745
+ function formatMessage(opt, desc) {
3746
+ return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
3747
+ }
3748
+
3749
+ // eslint-disable-next-line func-names
3750
+ return function(value, opt, opts) {
3751
+ if (validator === false) {
3752
+ throw new AxiosError_1(
3753
+ formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
3754
+ AxiosError_1.ERR_DEPRECATED
3755
+ );
3756
+ }
3757
+
3758
+ if (version && !deprecatedWarnings[opt]) {
3759
+ deprecatedWarnings[opt] = true;
3760
+ // eslint-disable-next-line no-console
3761
+ console.warn(
3762
+ formatMessage(
3763
+ opt,
3764
+ ' has been deprecated since v' + version + ' and will be removed in the near future'
3765
+ )
3766
+ );
3767
+ }
3768
+
3769
+ return validator ? validator(value, opt, opts) : true;
3770
+ };
3771
+ };
3772
+
3773
+ /**
3774
+ * Assert object's properties type
3775
+ * @param {object} options
3776
+ * @param {object} schema
3777
+ * @param {boolean?} allowUnknown
3778
+ */
3779
+
3780
+ function assertOptions(options, schema, allowUnknown) {
3781
+ if (typeof options !== 'object') {
3782
+ throw new AxiosError_1('options must be an object', AxiosError_1.ERR_BAD_OPTION_VALUE);
3783
+ }
3784
+ var keys = Object.keys(options);
3785
+ var i = keys.length;
3786
+ while (i-- > 0) {
3787
+ var opt = keys[i];
3788
+ var validator = schema[opt];
3789
+ if (validator) {
3790
+ var value = options[opt];
3791
+ var result = value === undefined || validator(value, opt, options);
3792
+ if (result !== true) {
3793
+ throw new AxiosError_1('option ' + opt + ' must be ' + result, AxiosError_1.ERR_BAD_OPTION_VALUE);
3794
+ }
3795
+ continue;
3796
+ }
3797
+ if (allowUnknown !== true) {
3798
+ throw new AxiosError_1('Unknown option ' + opt, AxiosError_1.ERR_BAD_OPTION);
3799
+ }
3800
+ }
3801
+ }
3802
+
3803
+ var validator = {
3804
+ assertOptions: assertOptions,
3805
+ validators: validators$1
3806
+ };
3807
+
3808
+ var validators = validator.validators;
3809
+ /**
3810
+ * Create a new instance of Axios
3811
+ *
3812
+ * @param {Object} instanceConfig The default config for the instance
3813
+ */
3814
+ function Axios(instanceConfig) {
3815
+ this.defaults = instanceConfig;
3816
+ this.interceptors = {
3817
+ request: new InterceptorManager_1(),
3818
+ response: new InterceptorManager_1()
3819
+ };
3820
+ }
3821
+
3822
+ /**
3823
+ * Dispatch a request
3824
+ *
3825
+ * @param {Object} config The config specific for this request (merged with this.defaults)
3826
+ */
3827
+ Axios.prototype.request = function request(configOrUrl, config) {
3828
+ /*eslint no-param-reassign:0*/
3829
+ // Allow for axios('example/url'[, config]) a la fetch API
3830
+ if (typeof configOrUrl === 'string') {
3831
+ config = config || {};
3832
+ config.url = configOrUrl;
3833
+ } else {
3834
+ config = configOrUrl || {};
3835
+ }
3836
+
3837
+ config = mergeConfig(this.defaults, config);
3838
+
3839
+ // Set config.method
3840
+ if (config.method) {
3841
+ config.method = config.method.toLowerCase();
3842
+ } else if (this.defaults.method) {
3843
+ config.method = this.defaults.method.toLowerCase();
3844
+ } else {
3845
+ config.method = 'get';
3846
+ }
3847
+
3848
+ var transitional = config.transitional;
3849
+
3850
+ if (transitional !== undefined) {
3851
+ validator.assertOptions(transitional, {
3852
+ silentJSONParsing: validators.transitional(validators.boolean),
3853
+ forcedJSONParsing: validators.transitional(validators.boolean),
3854
+ clarifyTimeoutError: validators.transitional(validators.boolean)
3855
+ }, false);
3856
+ }
3857
+
3858
+ // filter out skipped interceptors
3859
+ var requestInterceptorChain = [];
3860
+ var synchronousRequestInterceptors = true;
3861
+ this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
3862
+ if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
3863
+ return;
3864
+ }
3865
+
3866
+ synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
3867
+
3868
+ requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
3869
+ });
3870
+
3871
+ var responseInterceptorChain = [];
3872
+ this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
3873
+ responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
3874
+ });
3875
+
3876
+ var promise;
3877
+
3878
+ if (!synchronousRequestInterceptors) {
3879
+ var chain = [dispatchRequest, undefined];
3880
+
3881
+ Array.prototype.unshift.apply(chain, requestInterceptorChain);
3882
+ chain = chain.concat(responseInterceptorChain);
3883
+
3884
+ promise = Promise.resolve(config);
3885
+ while (chain.length) {
3886
+ promise = promise.then(chain.shift(), chain.shift());
3887
+ }
3888
+
3889
+ return promise;
3890
+ }
3891
+
3892
+
3893
+ var newConfig = config;
3894
+ while (requestInterceptorChain.length) {
3895
+ var onFulfilled = requestInterceptorChain.shift();
3896
+ var onRejected = requestInterceptorChain.shift();
3897
+ try {
3898
+ newConfig = onFulfilled(newConfig);
3899
+ } catch (error) {
3900
+ onRejected(error);
3901
+ break;
3902
+ }
3903
+ }
3904
+
3905
+ try {
3906
+ promise = dispatchRequest(newConfig);
3907
+ } catch (error) {
3908
+ return Promise.reject(error);
3909
+ }
3910
+
3911
+ while (responseInterceptorChain.length) {
3912
+ promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
3913
+ }
3914
+
3915
+ return promise;
3916
+ };
3917
+
3918
+ Axios.prototype.getUri = function getUri(config) {
3919
+ config = mergeConfig(this.defaults, config);
3920
+ var fullPath = buildFullPath(config.baseURL, config.url);
3921
+ return buildURL(fullPath, config.params, config.paramsSerializer);
3922
+ };
3923
+
3924
+ // Provide aliases for supported request methods
3925
+ utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
3926
+ /*eslint func-names:0*/
3927
+ Axios.prototype[method] = function(url, config) {
3928
+ return this.request(mergeConfig(config || {}, {
3929
+ method: method,
3930
+ url: url,
3931
+ data: (config || {}).data
3932
+ }));
3933
+ };
3934
+ });
3935
+
3936
+ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
3937
+ /*eslint func-names:0*/
3938
+
3939
+ function generateHTTPMethod(isForm) {
3940
+ return function httpMethod(url, data, config) {
3941
+ return this.request(mergeConfig(config || {}, {
3942
+ method: method,
3943
+ headers: isForm ? {
3944
+ 'Content-Type': 'multipart/form-data'
3945
+ } : {},
3946
+ url: url,
3947
+ data: data
3948
+ }));
3949
+ };
3950
+ }
3951
+
3952
+ Axios.prototype[method] = generateHTTPMethod();
3953
+
3954
+ Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
3955
+ });
3956
+
3957
+ var Axios_1 = Axios;
3958
+
3959
+ /**
3960
+ * A `CancelToken` is an object that can be used to request cancellation of an operation.
3961
+ *
3962
+ * @class
3963
+ * @param {Function} executor The executor function.
3964
+ */
3965
+ function CancelToken(executor) {
3966
+ if (typeof executor !== 'function') {
3967
+ throw new TypeError('executor must be a function.');
3968
+ }
3969
+
3970
+ var resolvePromise;
3971
+
3972
+ this.promise = new Promise(function promiseExecutor(resolve) {
3973
+ resolvePromise = resolve;
3974
+ });
3975
+
3976
+ var token = this;
3977
+
3978
+ // eslint-disable-next-line func-names
3979
+ this.promise.then(function(cancel) {
3980
+ if (!token._listeners) return;
3981
+
3982
+ var i;
3983
+ var l = token._listeners.length;
3984
+
3985
+ for (i = 0; i < l; i++) {
3986
+ token._listeners[i](cancel);
3987
+ }
3988
+ token._listeners = null;
3989
+ });
3990
+
3991
+ // eslint-disable-next-line func-names
3992
+ this.promise.then = function(onfulfilled) {
3993
+ var _resolve;
3994
+ // eslint-disable-next-line func-names
3995
+ var promise = new Promise(function(resolve) {
3996
+ token.subscribe(resolve);
3997
+ _resolve = resolve;
3998
+ }).then(onfulfilled);
3999
+
4000
+ promise.cancel = function reject() {
4001
+ token.unsubscribe(_resolve);
4002
+ };
4003
+
4004
+ return promise;
4005
+ };
4006
+
4007
+ executor(function cancel(message) {
4008
+ if (token.reason) {
4009
+ // Cancellation has already been requested
4010
+ return;
4011
+ }
4012
+
4013
+ token.reason = new CanceledError_1(message);
4014
+ resolvePromise(token.reason);
4015
+ });
4016
+ }
4017
+
4018
+ /**
4019
+ * Throws a `CanceledError` if cancellation has been requested.
4020
+ */
4021
+ CancelToken.prototype.throwIfRequested = function throwIfRequested() {
4022
+ if (this.reason) {
4023
+ throw this.reason;
4024
+ }
4025
+ };
4026
+
4027
+ /**
4028
+ * Subscribe to the cancel signal
4029
+ */
4030
+
4031
+ CancelToken.prototype.subscribe = function subscribe(listener) {
4032
+ if (this.reason) {
4033
+ listener(this.reason);
4034
+ return;
4035
+ }
4036
+
4037
+ if (this._listeners) {
4038
+ this._listeners.push(listener);
4039
+ } else {
4040
+ this._listeners = [listener];
4041
+ }
4042
+ };
4043
+
4044
+ /**
4045
+ * Unsubscribe from the cancel signal
4046
+ */
4047
+
4048
+ CancelToken.prototype.unsubscribe = function unsubscribe(listener) {
4049
+ if (!this._listeners) {
4050
+ return;
4051
+ }
4052
+ var index = this._listeners.indexOf(listener);
4053
+ if (index !== -1) {
4054
+ this._listeners.splice(index, 1);
4055
+ }
4056
+ };
4057
+
4058
+ /**
4059
+ * Returns an object that contains a new `CancelToken` and a function that, when called,
4060
+ * cancels the `CancelToken`.
4061
+ */
4062
+ CancelToken.source = function source() {
4063
+ var cancel;
4064
+ var token = new CancelToken(function executor(c) {
4065
+ cancel = c;
4066
+ });
4067
+ return {
4068
+ token: token,
4069
+ cancel: cancel
4070
+ };
4071
+ };
4072
+
4073
+ var CancelToken_1 = CancelToken;
4074
+
4075
+ /**
4076
+ * Syntactic sugar for invoking a function and expanding an array for arguments.
4077
+ *
4078
+ * Common use case would be to use `Function.prototype.apply`.
4079
+ *
4080
+ * ```js
4081
+ * function f(x, y, z) {}
4082
+ * var args = [1, 2, 3];
4083
+ * f.apply(null, args);
4084
+ * ```
4085
+ *
4086
+ * With `spread` this example can be re-written.
4087
+ *
4088
+ * ```js
4089
+ * spread(function(x, y, z) {})([1, 2, 3]);
4090
+ * ```
4091
+ *
4092
+ * @param {Function} callback
4093
+ * @returns {Function}
4094
+ */
4095
+ var spread = function spread(callback) {
4096
+ return function wrap(arr) {
4097
+ return callback.apply(null, arr);
4098
+ };
4099
+ };
4100
+
4101
+ /**
4102
+ * Determines whether the payload is an error thrown by Axios
4103
+ *
4104
+ * @param {*} payload The value to test
4105
+ * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
4106
+ */
4107
+ var isAxiosError = function isAxiosError(payload) {
4108
+ return utils.isObject(payload) && (payload.isAxiosError === true);
4109
+ };
4110
+
4111
+ /**
4112
+ * Create an instance of Axios
4113
+ *
4114
+ * @param {Object} defaultConfig The default config for the instance
4115
+ * @return {Axios} A new instance of Axios
4116
+ */
4117
+ function createInstance(defaultConfig) {
4118
+ var context = new Axios_1(defaultConfig);
4119
+ var instance = bind(Axios_1.prototype.request, context);
4120
+
4121
+ // Copy axios.prototype to instance
4122
+ utils.extend(instance, Axios_1.prototype, context);
4123
+
4124
+ // Copy context to instance
4125
+ utils.extend(instance, context);
4126
+
4127
+ // Factory for creating new instances
4128
+ instance.create = function create(instanceConfig) {
4129
+ return createInstance(mergeConfig(defaultConfig, instanceConfig));
4130
+ };
4131
+
4132
+ return instance;
4133
+ }
4134
+
4135
+ // Create the default instance to be exported
4136
+ var axios$1 = createInstance(defaults_1);
4137
+
4138
+ // Expose Axios class to allow class inheritance
4139
+ axios$1.Axios = Axios_1;
4140
+
4141
+ // Expose Cancel & CancelToken
4142
+ axios$1.CanceledError = CanceledError_1;
4143
+ axios$1.CancelToken = CancelToken_1;
4144
+ axios$1.isCancel = isCancel;
4145
+ axios$1.VERSION = data.version;
4146
+ axios$1.toFormData = toFormData_1;
4147
+
4148
+ // Expose AxiosError class
4149
+ axios$1.AxiosError = AxiosError_1;
4150
+
4151
+ // alias for CanceledError for backward compatibility
4152
+ axios$1.Cancel = axios$1.CanceledError;
4153
+
4154
+ // Expose all/spread
4155
+ axios$1.all = function all(promises) {
4156
+ return Promise.all(promises);
4157
+ };
4158
+ axios$1.spread = spread;
4159
+
4160
+ // Expose isAxiosError
4161
+ axios$1.isAxiosError = isAxiosError;
4162
+
4163
+ var axios_1 = axios$1;
4164
+
4165
+ // Allow use of default import syntax in TypeScript
4166
+ var _default = axios$1;
4167
+ axios_1.default = _default;
4168
+
4169
+ var axios = axios_1;
4170
+
4171
+ function e(e){this.message=e;}e.prototype=new Error,e.prototype.name="InvalidCharacterError";var r$1="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(r){var t=String(r).replace(/=+$/,"");if(t.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,a=0,i=0,c="";o=t.charAt(i++);~o&&(n=a%4?64*n+o:o,a++%4)?c+=String.fromCharCode(255&n>>(-2*a&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return c};function t(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw "Illegal base64url string!"}try{return function(e){return decodeURIComponent(r$1(e).replace(/(.)/g,(function(e,r){var t=r.charCodeAt(0).toString(16).toUpperCase();return t.length<2&&(t="0"+t),"%"+t})))}(t)}catch(e){return r$1(t)}}function n(e){this.message=e;}function o$1(e,r){if("string"!=typeof e)throw new n("Invalid token specified");var o=!0===(r=r||{}).header?0:1;try{return JSON.parse(t(e.split(".")[o]))}catch(e){throw new n("Invalid token specified: "+e.message)}}n.prototype=new Error,n.prototype.name="InvalidTokenError";
4172
+
4173
+ var r=function(e,t,a){return alert(e)},i=function(e,t){return r(e,o.error,t)},o={error:"error",success:"success",info:"info"},l={fire:function(e,t,a){return r(e,t,a)},setNotifier:function(e){r=e,salla.event.emit("twilight::notifier.changed");},error:i,success:function(e,t){return r(e,o.success,t)},info:function(e,t){return r(e,o.info,t)},sallaInitiated:function(){var e=window.location.href.match(/([\?\&]danger=)[^&]+/g);e&&(window.history.replaceState(null,document.title,window.location.pathname),salla.event.once("twilight::notifier.changed",(function(){e.forEach((function(e){i(decodeURI(e.replace("?danger=","").replace("&danger=","")),{});}));})));},types:o},s=function(e,t){return this.api=e,this.event=t,new Proxy(this,{get:function(a,n){return "event"===n?t:"api"===n?e:e&&e[n]||a[n]}})},c=function(e,t){return c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t;}||function(e,t){for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);},c(e,t)};function d(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function a(){this.constructor=e;}c(e,t),e.prototype=null===t?Object.create(t):(a.prototype=t.prototype,new a);}var u=function(){return u=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++)for(var r in t=arguments[a])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},u.apply(this,arguments)};function p(e,t,a,n){return new(a||(a=Promise))((function(r,i){function o(e){try{s(n.next(e));}catch(e){i(e);}}function l(e){try{s(n.throw(e));}catch(e){i(e);}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof a?t:new a((function(e){e(t);}))).then(o,l);}s((n=n.apply(e,t||[])).next());}))}function h(e,t){var a,n,r,i,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(l){return function(s){return function(l){if(a)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(o=0)),o;)try{if(a=1,n&&(r=2&l[0]?n.return:l[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,l[1])).done)return r;switch(n=0,r&&(l=[2&l[0],r.value]),l[0]){case 0:case 1:r=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,n=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!r||l[1]>r[0]&&l[1]<r[3])){o.label=l[1];break}if(6===l[0]&&o.label<r[1]){o.label=r[1],r=l;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(l);break}r[2]&&o.ops.pop(),o.trys.pop();continue}l=t.call(e,o);}catch(e){l=[6,e],n=0;}finally{a=r=0;}if(5&l[0])throw l[1];return {value:l[0]?l[1]:void 0,done:!0}}([l,s])}}}function f(e,t,a){if(a||2===arguments.length)for(var n,r=0,i=t.length;r<i;r++)!n&&r in t||(n||(n=Array.prototype.slice.call(t,0,r)),n[r]=t[r]);return e.concat(n||Array.prototype.slice.call(t))}Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){for(var t=this;t;){if(t.matches(e))return t;t=t.parentElement;}}),Element.prototype.getElementSallaData=function(e){for(var t,a=[],n=1;n<arguments.length;n++)a[n-1]=arguments[n];if(this.getAttribute){if(this.hasAttribute("data-json"))try{return JSON.parse(this.getAttribute("data-json"))}catch(e){}var r=this.getAttribute("data-function");if(r&&window[r])return "function"==typeof window[r]?this.getFilteredData((t=window[r]).call.apply(t,f([this],a,!1))):this.getFilteredData(window[r]);var i=this.hasAttribute("data-form-selector")?document.querySelector(this.dataset.formSelector):void 0;if((i="FORM"===this.tagName?this:i||this.closest("form")||this.closest("[salla-form-data]")||this)&&"FORM"===i.tagName)return this.getFilteredData(new FormData(i),null,i);var o=i.querySelectorAll("[name]");if(!o.length)return this.getFilteredData();var l=Object.assign({},this.dataset);return o.forEach((function(e){if(!["checkbox","radio"].includes(e.type)||e.checked)try{var t=Salla.helpers.inputData(e.name,e.value,l);l[t.name]=t.value;}catch(t){Salla.log(e.name+" can't be send");}})),this.getFilteredData(l)}},Element.prototype.canEventFireHook=function(e){return !!this.hasAttribute&&this.hasAttribute(Salla.api.hooksPrefix+e.type)},Element.prototype.hasAttributeStartsWith=function(e,t){e=e.toLowerCase();for(var a=0;a<this.attributes.length;a++){var n=this.attributes[a].name.toLowerCase();if(0===n.indexOf(e))return !t||n}return !1},HTMLFormElement.prototype.getAjaxFormData=function(e){var t=this.querySelectorAll('input[type="file"]');t.forEach((function(e){e.files.length||e.setAttribute("disabled","");}));var a=new FormData(this);return t.forEach((function(e){e.files.length||e.removeAttribute("disabled");})),{formData:this.getFilteredData(a,e),url:this.getAttribute("action"),method:this.getAttribute("method")||"post",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}},Element.prototype.getFilteredData=function(e,t,a){var n=this;return void 0===e&&(e=null),void 0===t&&(t=null),void 0===a&&(a=null),e=e||(null==a?void 0:a.dataset)||this.dataset,a&&this.name&&void 0!==this.value&&(e=function(e,t,a){e instanceof FormData?e.append(t,a):e[t]=a;return e}(e,this.name,this.value)),["filterBeforeSubmit","filterBeforeSend"].forEach((function(r){var i=(null==a?void 0:a.dataset[r])||n.dataset[r];if(i){var o=window[i];if("function"==typeof o){if(!o(e,a||n,t)&&e)throw "Data failed to be pass verify function window.".concat(i,"(formData, element, event)!");return o(e,a||n,t)}Salla.log("window."+i+"() not found!");}})),e},HTMLAnchorElement.prototype.getAjaxFormData=function(e){return {formData:this.getFilteredData(null,e),url:this.getAttribute("href"),method:this.dataset.type||"get",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}};var g=function(){function e(){this.events={},this.namespace="";var e=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(e&&e.length>1?e[1]:"").toLowerCase();}return e.prototype.after_init=function(){this.createDynamicFunctions();},e.prototype.createDynamicFunctions=function(){var e=this;Object.keys(this.events).forEach((function(t){e.createDynamicEventFuns(t),e.createDynamicListenerFuns(t);}));},e.prototype.createDynamicEventFuns=function(e){if(!this[e]){var t=this;this[e]=function(){for(var a=[],n=0;n<arguments.length;n++)a[n]=arguments[n];return t.dispatch.apply(t,f([e],a,!1))};}},e.prototype.createDynamicListenerFuns=function(e){var t="on"+e.charAt(0).toUpperCase()+e.slice(1);if(!this[t]){var a=this;this[t]=function(t){var n=this;return a.on(e,(function(){for(var e=[],a=0;a<arguments.length;a++)e[a]=arguments[a];return p(n,void 0,void 0,(function(){return h(this,(function(a){return [2,t.apply(void 0,e)]}))}))}))};}},e.prototype.getEventName=function(e){return e=this.events[e]||e,!this.namespace||e.includes("::")?e:this.namespace+Salla.event.delimiter+e},e.prototype.dispatch=function(e){for(var t,a=[],n=1;n<arguments.length;n++)a[n-1]=arguments[n];return (t=Salla.event).emitAsync.apply(t,f([this.getEventName(e)],a,!1))},e.prototype.on=function(e,t){return Salla.event.addListener(this.getEventName(e),t)},e.prototype.once=function(e,t){return Salla.event.once(this.getEventName(e),t)},e}(),v=function(e){function t(){var t=e.call(this)||this;return t.namespace="auth",t.events={login:"login",logout:"logout",codeSent:"code.sent",codeNotSent:"code.not-sent",verified:"verified",verificationFailed:"verification.failed",loggedIn:"logged.in",registered:"registered",registrationFailed:"registration.failed",loggedOut:"logged.out",failedLogout:"failed.logout",refreshFailed:"refresh.failed",tokenFetched:"token.fetched"},t.after_init(),t}return d(t,e),t.prototype.login=function(e){return e?(e.type&&this.setTypeActionOnVerified(e.type),this.next_event=e.next_event||null,this.dispatch.apply(this,f(["login"],arguments,!1))):(this.next_event=null,this.dispatch.apply(this,f(["login"],arguments,!1)))},t.prototype.loggedIn=function(e){var t=this;return Salla.profile.info().finally((function(){return t.dispatch("loggedIn",e)}))},t.prototype.setTypeActionOnVerified=function(e){this.type_action_on_verified=e;},t.prototype.getTypeActionOnVerified=function(){return this.type_action_on_verified||"redirect"},t}(g),m=function(e){function t(){var t=e.call(this)||this;return t.namespace="cart",t.events={latestFetched:"latest.fetched",latestFailed:"latest.failed",updated:"updated",itemUpdated:"item.updated",itemUpdatedFailed:"item.updated.failed",itemAdded:"item.added",itemAddedFailed:"item.added.failed",itemDeleted:"item.deleted",itemDeletedFailed:"item.deleted.failed",submitted:"submitted",submitFailed:"submit.failed",imageDeleted:"image.deleted",imageNotDeleted:"image.not.deleted",detailsFetched:"details.fetched",detailsNotFetched:"details.not.fetched",successReset:"success.reset",priceQuoteSucceeded:"price-quote.succeeded",priceQuoteFailed:"price-quote.failed",couponAdded:"coupon.added",couponDeleted:"coupon.deleted",couponAdditionFailed:"coupon.addition.failed",couponDeletionFailed:"coupon.deletion.failed",quickOrderSettingFetched:"quick-order.fetched",quickOrderSettingFailed:"quick-order.failed",quickOrderSucceeded:"quick-order.succeeded",quickOrderFailed:"quick-order.failed"},t.after_init(),t}return d(t,e),t.prototype.updated=function(e){var t;return Salla.cookie.set("fresh_summary",1),e&&"object"==typeof e?(e.offer&&salla.product.event.offerExisted(e.offer),e.redirect&&(salla.log("The current cart is purchased!"),salla.cart.api.reset()),e.cart?(salla.storage.set("cart.summary",{total:e.cart.total,sub_total:e.cart.sub_total,discount:e.cart.discount,real_shipping_cost:e.cart.real_shipping_cost,count:e.cart.count,shipping_cost:(null===(t=e.cart.free_shipping_bar)||void 0===t?void 0:t.has_free_shipping)?0:e.cart.real_shipping_cost}),this.dispatch("updated",e.cart)):void salla.log("Failed to get the cart summary!")):(Salla.logger.info("Cart summary not an object!",e),this.dispatch("updated"))},t.prototype.latestFetched=function(e){return this.updated(e.data),this.dispatch("latestFetched",e)},t.prototype.itemAdded=function(e,t){return this.updated(e.data),this.dispatch("itemAdded",e,t)},t.prototype.itemDeleted=function(e,t){return this.updated(e.data),this.dispatch("itemDeleted",e,t)},t.prototype.itemUpdated=function(e,t){return this.updated(e.data),this.dispatch("itemUpdated",e,t)},t.prototype.couponAdded=function(e,t){return this.updated(e.data),this.dispatch("couponAdded",e,t)},t.prototype.couponDeleted=function(e,t){return this.updated(e.data),this.dispatch("couponDeleted",e,t)},t}(g),y=function(e){function t(){var t=e.call(this)||this;return t.namespace="order",t.events={canceled:"canceled",notCanceled:"not.canceled",orderCreated:"order.created",orderCreationFailed:"order.creation.failed",invoiceSent:"invoice.sent",invoiceNotSent:"invoice.not.sent"},t.after_init(),t}return d(t,e),t}(g),w=function(e){function t(){var t=e.call(this)||this;return t.namespace="scope",t.events={fetched:"fetched",notFetched:"not.fetched",productAvailabilityFetched:"product-availability.fetched",productAvailabilityNotFetched:"product-availability.not.fetched",changeSucceeded:"changed",changeFailed:"not.changed"},t.after_init(),t}return d(t,e),t}(g),b=function(e){function t(){var t=e.call(this)||this;return t.namespace="rating",t.events={orderNotFetched:"order.not.fetched",orderFetched:"order.fetched",storeRated:"store.rated",storeFailed:"store.failed",productsRated:"products.rated",productsFailed:"products.failed",shippingRated:"shipping.rated",shippingFailed:"shipping.failed"},t.after_init(),t}return d(t,e),t}(g),F=function(e){function t(){var t=e.call(this)||this;return t.namespace="comment",t.events={added:"added",additionFailed:"addition.failed",fetched:"fetched",fetchFailed:"fetch.failed"},t.after_init(),t}return d(t,e),t}(g),S=function(e){function t(){var t=e.call(this)||this;return t.namespace="loyalty",t.events={exchangeSucceeded:"exchange.succeeded",exchangeFailed:"exchange.failed",programFetched:"program.fetched",programNotFetched:"program.not.fetched",resetSucceeded:"exchange-reset.succeeded",resetFailed:"exchange-reset.failed"},t.after_init(),t}return d(t,e),t.prototype.exchangeSucceeded=function(e,t){return salla.cart.event.updated(e.data),this.dispatch("exchangeSucceeded",e,t)},t.prototype.resetSucceeded=function(e){return salla.cart.event.updated(e.data),this.dispatch("resetSucceeded",e)},t}(g),_=function(e){function t(){var t=e.call(this)||this;return t.namespace="profile",t.events={updated:"updated",updateFailed:"update.failed",verificationCodeSent:"verification.code.sent",updateContactsFailed:"update.contacts.failed",verified:"verified",unverified:"unverified",infoFetched:"info.fetched",infoNotFetched:"info.not.fetched",settingsUpdated:"settings.updated",updateSettingsFailed:"update.settings.failed",deleted:"deleted",notDeleted:"not.deleted"},t.after_init(),t}return d(t,e),t}(g),q=function(e){function t(){var t=e.call(this)||this;return t.namespace="product",t.events={priceUpdated:"price.updated",priceUpdateFailed:"price.updated.failed",availabilitySubscribed:"availability.subscribed",availabilitySubscribeFailed:"availability.subscribe.failed",categoriesFetched:"categories.fetched",categoriesFailed:"categories.failed",searchFailed:"search.failed",searchResults:"search.results",offerExisted:"offer.existed",fetchOffersFailed:"fetch.offers.failed",offersFetched:"offers.fetched",sizeGuideFetched:"size-guide.fetched",sizeGuideFetchFailed:"size-guide.failed",giftFetched:"gift.fetched",giftFetchFailed:"gift.failed",detailFetched:"detail.fetched",detailFetchFailed:"detail.failed",addGiftToCartSucceeded:"gift.add-to-cart.succeeded",addGiftToCartFailed:"gift.add-to-cart.failed",giftImageUploadSucceeded:"gift.image-upload.succeeded",giftImageUploadFailed:"gift.image-upload.failed",productListFetchSucceeded:"fetch.succeeded",productListFetchFailed:"fetch.failed"},t.after_init(),t}return d(t,e),t}(g),A=function(e){function t(){var t=e.call(this)||this;return t.namespace="document",t.events={click:"click",change:"change",submit:"submit",keyup:"keyup",leaving:"leaving",request:"request",requestFailed:"request.failed"},t.after_init(),t}return d(t,e),t.prototype.onClick=function(e,t){this.fireCallableFuns("click",e,t);},t.prototype.onChange=function(e,t){this.fireCallableFuns("change",e,t);},t.prototype.onSubmit=function(e,t){this.fireCallableFuns("submit",e,t);},t.prototype.onKeyup=function(e,t){this.fireCallableFuns("keyup",e,t);},t.prototype.fireCallableFuns=function(e,t,a){this.on(e,(function(e){"function"!=typeof t?"function"==typeof a&&e.target.matches(t)&&a(e):t(e);}));},t.prototype.fireEvent=function(e,t){for(var a=[],n=2;n<arguments.length;n++)a[n-2]=arguments[n];return this.fireEventForElements.apply(this,f([e,t,!1],a,!1))},t.prototype.fireEventForAll=function(e,t){for(var a=[],n=2;n<arguments.length;n++)a[n-2]=arguments[n];return this.fireEventForElements.apply(this,f([e,t,!0],a,!1))},t.prototype.fireEventForElements=function(e,t,a){for(var n=this,r=[],i=3;i<arguments.length;i++)r[i-3]=arguments[i];if("string"==typeof e){if(a)return document.querySelectorAll(e).forEach((function(e){return n.fireEventForElements.apply(n,f([e,t,!1],r,!1))}));e=document.querySelector(e);}if(e){var o=new(CustomEvent.bind.apply(CustomEvent,f([void 0,t],r,!1)));return e.dispatchEvent(o)}salla.log("Failed To get element to fire event: "+t);},t}(g),C=function(e){function t(){var t=e.call(this)||this;return t.namespace="wishlist",t.events={added:"added",removed:"removed",additionFailed:"addition.failed",removingFailed:"removing.failed"},t.after_init(),t}return d(t,e),t}(g),k=function(e){function t(){var t=e.call(this)||this;return t.namespace="currency",t.events={changed:"changed",failed:"failed",fetched:"fetched",failedToFetch:"failed.to.fetch"},t.after_init(),t}return d(t,e),t}(g),P=function(e){function t(){var t=e.call(this)||this;return t.namespace="infiniteScroll",t.events={scrollThreshold:"scroll.threshold",request:"request",load:"load",append:"append",error:"error",last:"last",history:"history"},t.after_init(),t}return d(t,e),t}(g),E=function(e){function t(){var t=e.call(this)||this;return t.namespace="booking",t.events={added:"added",additionFailed:"addition.failed"},t.after_init(),t}return d(t,e),t}(g),x=function(e){function t(){var t=e.call(this)||this;return t.namespace="landing",t.events={detailsFetched:"order.fetched",getDetailsFailed:"get.details.failed",orderCreated:"order.created",orderCreationFailed:"order.creation.failed"},t.after_init(),t}return d(t,e),t}(g);function T(e){e&&e.sallaInitiated&&!e.initiated&&(e.sallaInitiated(),e.initiated=!0);}Salla.event.auth=new v,Salla.event.cart=new m,Salla.event.order=new y,Salla.event.scope=new w,Salla.event.rating=new b,Salla.event.booking=new E,Salla.event.comment=new F,Salla.event.landing=new x,Salla.event.loyalty=new S,Salla.event.product=new q,Salla.event.profile=new _,Salla.event.currency=new k,Salla.event.document=new A,Salla.event.wishlist=new C,Salla.event.infiniteScroll=new P,Salla.event.on("twilight::initiated",(function(){Object.keys(Salla).forEach((function(e){"object"==typeof(e=Salla[e])&&(T(e),Object.keys(e).forEach((function(t){T(e[t]);})));}));}));var D=void 0;Salla.config.default_properties={debug:"undefined"!=typeof process&&"development"==="production",token:null,fastRequests:!0,canLeave:!0,store:{api:"https://api.salla.dev/store/v1/"},currencies:{SAR:{code:"SAR",name:"ريال سعودي",symbol:"ر.س",amount:1,country_code:"sa"}}},Salla.config.merge(Salla.config.default_properties),Salla.config.triedToGetCurrencies_=!1,Salla.config.triedToGetLanguages_=!1,Salla.config.isUser=function(){return "user"===Salla.config.get("user.type")},Salla.config.isGuest=function(){return !Salla.config.isUser()},Salla.config.languages=function(){return __awaiter(D,void 0,void 0,(function(){var e,t,a,n;return __generator(this,(function(r){switch(r.label){case 0:return Salla.config.triedToGetLanguages_?[2,Salla.config.get("languages")]:(Salla.config.triedToGetLanguages_=!0,e=!0,t=[],[4,salla.document.api.request("languages",null,"get")]);case 1:return null===(n=null===(a=r.sent())||void 0===a?void 0:a.data)||void 0===n||n.map((function(a){e&&(t=[],e=!1),a.code=a.code||a.iso_code,a.url=salla.url.get(a.code),a.is_rtl=a.is_rtl||a.rtl,t.push(a);})),Salla.config.set("languages",t),[2,t]}}))}))},Salla.config.currencies=function(){return __awaiter(D,void 0,void 0,(function(){var e,t,a,n;return __generator(this,(function(r){switch(r.label){case 0:return Salla.config.triedToGetCurrencies_?[2,Salla.config.get("currencies")]:(Salla.config.triedToGetCurrencies_=!0,e=!0,t={},[4,salla.currency.api.list()]);case 1:return null===(n=null===(a=r.sent())||void 0===a?void 0:a.data)||void 0===n||n.map((function(a){e&&(t={},e=!1),a.country_code=a.code.substr(0,2).toLowerCase(),t[a.code]=a;})),Salla.config.set("currencies",t),[2,t]}}))}))};var O=function(t){function a(e,a){var n=t.call(this,e,a)||this;return n.options={path:".infinite-scroll-btn",history:"push",status:".infinite-scroll-status",append:".list-block"},n.fetchOptions={headers:{"S-INFINITE-SCROLL":!0}},n.instances=[],n}return d(a,t),a.prototype.initiate=function(t,a,n,r){void 0===r&&(r=!1),r?((n=n||{}).fetchOptions=u(u({},this.fetchOptions),n.fetchOptions||{}),n.responseBody="json"):n=this.getCustomOptions(a,n);var i="string"!=typeof t?t:document.querySelector(t),o=n.path;if(i&&o&&("string"!=typeof o||document.querySelector(o))){var l=new js(i,n);return l.on("scrollThreshold",Salla.infiniteScroll.event.scrollThreshold),l.on("request",Salla.infiniteScroll.event.request),l.on("load",Salla.infiniteScroll.event.load),l.on("append",Salla.infiniteScroll.event.append),l.on("error",Salla.infiniteScroll.event.error),l.on("last",Salla.infiniteScroll.event.last),l.on("history",Salla.infiniteScroll.event.history),this.instances.push(l),l}Salla.logger.warn(i?"Path Option (a link that has next page link) Not Existed!":"Container For InfiniteScroll not Existed!");},a.prototype.getCustomOptions=function(e,t){return (t="object"==typeof e&&e||t||this.options).fetchOptions=this.fetchOptions,t.path=t.path||this.options.path,t.button=t.button||t.path,t.status=t.status||this.options.status,t.hasOwnProperty("history")||(t.history=this.options.history),t.nextPage=t.nextPage||t.next_page,t.append="string"==typeof e&&e||t.append||this.options.append,t},a.prototype.loadNextPage=function(e){("string"!=typeof e?e:document.querySelector(e)).loadNextPage();},a.prototype.destroy=function(e){("string"!=typeof e?e:document.querySelector(e)).destroy();},a}(s),I=function(){function e(){}return e.prototype.submit=function(e,t){var a,n,r,i;return void 0===t&&(t=null),p(this,void 0,void 0,(function(){var o,l,s;return h(this,(function(c){switch(c.label){case 0:if(o=t,"SubmitEvent"===(null===(a=null==t?void 0:t.constructor)||void 0===a?void 0:a.name)||"submit"===(null==t?void 0:t.type)){if(t.preventDefault(),"FORM"!==(null===(n=t.target)||void 0===n?void 0:n.tagName))return Salla.logger.warn("Failed find the target element for submit action. make sure you submit a form element"),[2,new Promise((function(){throw "Failed find the target element for submit action. make sure you submit a form element"}))];"SALLA-BUTTON"===(null===(i=null===(r=null==t?void 0:t.submitter)||void 0===r?void 0:r.parentElement)||void 0===i?void 0:i.tagName)&&t.submitter.parentElement.load(),o=t.target.getElementSallaData(),salla.log("Data from element",o);}return /^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/gm.test(e)?[2,salla.api.request(e,o,"post").finally((function(){var e;loaderSupported&&(null===(e=null==t?void 0:t.submitter)||void 0===e||e.parentElement.stop());}))]:(l=e.split("."),s=l.splice(-1),[4,salla.call(l.join("."))[s](o).finally((function(){var e,a;return null===(a=null===(e=null==t?void 0:t.submitter)||void 0===e?void 0:e.parentElement)||void 0===a?void 0:a.stop()})).catch((function(e){throw salla.logger.warn(e),e}))]);case 1:return [2,c.sent()]}}))}))},e.prototype.onSubmit=function(e,t){return salla.form.submit(e,t),!1},e.prototype.onChange=function(e,t){var a;return (null==t?void 0:t.currentTarget)?"FORM"!==(null===(a=null==t?void 0:t.currentTarget)||void 0===a?void 0:a.tagName)||t.currentTarget.checkValidity()?(salla.form.submit(e,t.currentTarget.getElementSallaData()),!0):(salla.logger.warn("Trying to trigger '".concat(e,"' without filling required fields!")),!1):(salla.logger.warn("Trying to trigger '".concat(e,"' without event!")),!1)},e.prototype.getPossibleValue=function(e,t,a){if(void 0===a&&(a=!1),e){if("object"!=typeof e)return e;for(var n,r=0;r<t.length&&!(n=e[t[r]])&&!("undefined"!=typeof FormData&&e instanceof FormData&&(n=e.get(t[r])));r++);return "object"!=typeof(n=n||e)||a?n:void 0}},e}(),L=function(e){function t(t){var a=this;return (t=t||{}).messages=t.messages||window.translations,t.locale=t.locale||(window.locale||navigator.language||navigator.userLanguage||"ar").split("-")[0],t.fallback=t.fallback||t.locale,(a=e.call(this,t)||this).translationsLoaded=!1,a}return d(t,e),t.prototype.onLoaded=function(e){if(this.translationsLoaded)return e();Salla.event.once("languages::translations.loaded",e);},t.prototype.loadStoreTranslations=function(){if(this.hash=salla.config.get("theme.translations_hash",salla.config.get("store.id","twilight")),this.messages||(salla.log("try to load translations from localstorage"),this.messages=salla.storage.get("s_translations.".concat(this.hash)),this.messages&&(this.translationsLoaded=!0)&&e.prototype.setMessages.call(this,this.messages)),this.messages)return salla.event.dispatch("languages::translations.loaded"),void salla.logger.info("The messages of transactions is already loaded");salla.url.get("")?this.loadScript(salla.url.get("languages/assets/".concat(this.hash,".js"))):this.loadScript("https://cdn.salla.network/js/translations.js",!1);},t.prototype.setMessages=function(t){e.prototype.setMessages.call(this,t),salla.event.dispatch("languages::translations.loaded"),this.translationsLoaded=!0;},t.prototype.loadScript=function(e,t){var a=this;void 0===t&&(t=!0);var n=document.createElement("script");n.src=e,n.onload=function(){var e;if(window.translations)return salla.storage.remove("s_translations"),salla.storage.set("s_translations",((e={})[a.hash]=window.translations,e)),a.setMessages(window.translations);n.onerror();},n.onerror=function(){if(t)return salla.logger.warn("Failed to load Translations for store, lets try load it from CDN"),a.loadScript("https://cdn.salla.network/js/translations.js",!1);salla.logger.error("Failed to load Translations, check your network logs for more details\nor: salla.lang.setMessages({....}), see https://docs.salla.dev for more information's.");},document.head.appendChild(n);},t.prototype.getWithDefault=function(e,t,a,n){var r=this.get(e,a,n);return r!==e?r:t},t.prototype.get=function(t,a,n){var r=t;(window.translations||this.translationsLoaded)&&(r="trans."+t);var i=e.prototype.get.call(this,r,a,n);return i!==r?i:e.prototype.get.call(this,r,a,"en").replace(r,t)},t.prototype.set=function(e,t){return salla.helpers.setNested(this.messages[this.getLocale()+".trans"],e,t),this},t}(lang),R=function(){function e(){this.endpoints={},this.webEndpoints=[],this.namespace="BaseApi",this.endpointsMethods={},this.endpointsHeaders={};var e=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(e&&e.length>1?e[1]:"").toLowerCase(),this.debounce={request:void 0,time:300,enabled:!0,exclude:[]};}return e.prototype.after_init=function(){},e.prototype.normalRequest=function(e,t,a){void 0===t&&(t=void 0),void 0===a&&(a=null);var n=Array.isArray(e),r=n?this.getUrl.apply(this,e):this.getUrl(e);e=n?e[0]:e,a=a||this.endpointsMethods[e]||"post";var i=this.endpointsHeaders[e];if("get"===a&&t instanceof FormData){var o={};Array.from(t.entries()).forEach((function(e){o[e[0]]=e[1];})),t={params:o};}return i&&"get"===a&&(t=t?Object.assign(t,i):i),this.webEndpoints.includes(e)?r=salla.url.get(r):"http"!==r.substring(0,4)&&(r=salla.url.api(r)),Salla.api.request(r,t,a,{headers:i})},e.prototype.request=function(e,t,a){return void 0===t&&(t=void 0),void 0===a&&(a=null),!salla.api.isFastRequestsAllowed()&&this.debounce.enabled?(this.debounce.request||(this.debounce.request=salla.helpers.debounce(this.normalRequest.bind(this),this.debounce.time)),this.debounce.request(e,t,a)):this.normalRequest(e,t,a)},e.prototype.getUrl=function(e){for(var t=this.endpoints[e]||e,a=/{[^{}]+}/i,n=1;n<arguments.length;n++)t=t.replace(a,arguments[n]);return t},e.prototype.event=function(){return salla.event[this.className]},e}(),N=function(e){function t(){var t=e.call(this)||this;return t.namespace="cart",t.endpoints={latest:"cart/latest",details:"cart/{cart}",quickAdd:"cart/{cart}/item/{product}/quick-add",addItem:"cart/{cart}/item/{product}/add",deleteItem:"cart/{cart}/item/{item}",updateItem:"cart/{cart}/item/{item}",deleteImage:"cart/{cart}/image/{image}",uploadImage:"cart/{cart}/image",status:"cart/{cart}/status",addCoupon:"cart/{id}/coupon",deleteCoupon:"cart/{id}/coupon",getQuickOrderSettings:"checkout/quick-order",createQuickOrder:"checkout/quick-order",priceQuote:"cart/{cartId}/price-quote"},t.endpointsMethods={latest:"get",details:"get",status:"get",updateItem:"post",deleteItem:"delete",deleteImage:"delete",deleteCoupon:"put",getQuickOrderSettings:"get"},t.webEndpoints=["latest"],t.latestCart=null,t.after_init(),salla.event.on("api::initiated",(function(){return t.getCurrentCartId()})),t}return d(t,e),t.prototype.getCurrentCartId=function(){return p(this,void 0,void 0,(function(){var e,t;return h(this,(function(a){switch(a.label){case 0:return salla.cart.api.latestCart?[2,salla.cart.api.latestCart.cart.id]:(e=salla.storage.get("cart.id"))?[2,e]:[4,this.latest()];case 1:return t=a.sent(),salla.cart.api.latestCart=t.data,[2,salla.cart.api.latestCart.cart.id]}}))}))},t.prototype.getUploadImageEndpoint=function(e){return salla.url.api(this.getUrl("uploadImage",e||salla.storage.get("cart.id")))},t.prototype.latest=function(){return this.request("latest",{params:{source:""}}).then((function(e){return salla.storage.set("cart",e.data.cart),salla.event.cart.latestFetched(e),e})).catch((function(e){throw salla.storage.set("cart",""),salla.event.cart.latestFailed(e),e}))},t.prototype.details=function(e,t){return void 0===t&&(t=[]),p(this,void 0,void 0,(function(){var a;return h(this,(function(n){switch(n.label){case 0:return (a=e)?[3,2]:[4,this.getCurrentCartId()];case 1:a=n.sent(),n.label=2;case 2:return e=a,[2,this.request(["details",e],{params:{with:t}}).then((function(e){return salla.cart.event.detailsFetched(e),e})).catch((function(e){throw salla.cart.event.detailsNotFetched(e),e}))]}}))}))},t.prototype.quickAdd=function(e,t){return p(this,void 0,void 0,(function(){return h(this,(function(a){return [2,this.addItem({id:e,quantity:t,endpoint:"quickAdd"})]}))}))},t.prototype.addItem=function(e){return p(this,void 0,void 0,(function(){var t,a,n,r;return h(this,(function(i){switch(i.label){case 0:return (t=this.getCartPayload(e)).id?((n=salla.form.getPossibleValue(t.payload,["endpoint"]))&&["addItem","quickAdd"].includes(n)||(n=salla.form.getPossibleValue(t.payload,["quantity","donating_amount"])?"addItem":"quickAdd"),[4,this.getCurrentCartId()]):(a='There is no product "id"!',salla.cart.event.itemAddedFailed(a),[2,salla.api.errorPromise(a)]);case 1:return r=i.sent(),[2,this.request([n,r,t.id],t.payload).then((function(e){return salla.cart.event.itemAdded(e,t.id),e})).catch((function(e){throw salla.cart.event.itemAddedFailed(e,t.id),e}))]}}))}))},t.prototype.deleteItem=function(e){return p(this,void 0,void 0,(function(){var t,a,n;return h(this,(function(r){switch(r.label){case 0:return (t=this.getCartPayload(e)).id?[4,this.getCurrentCartId()]:(a='There is no "id"!',salla.cart.event.itemDeletedFailed(a),[2,salla.api.errorPromise(a)]);case 1:return n=r.sent(),[2,this.request(["deleteItem",n,t.id]).then((function(e){return salla.cart.event.itemDeleted(e,t.id),e})).catch((function(e){throw salla.cart.event.itemDeletedFailed(e,t.id),e}))]}}))}))},t.prototype.updateItem=function(e){var t;return p(this,void 0,void 0,(function(){var a,n,r;return h(this,(function(i){switch(i.label){case 0:return (a=this.getCartPayload(e)).id?[4,this.getCurrentCartId()]:(n='There is no "id"!',salla.cart.event.itemUpdatedFailed(n),[2,salla.api.errorPromise(n)]);case 1:return r=i.sent(),"Object"===(null===(t=a.payload.constructor)||void 0===t?void 0:t.name)?a.payload._method="PUT":a.payload.append("_method","PUT"),[2,this.request(["updateItem",r,a.id],a.payload).then((function(e){return salla.cart.event.itemUpdated(e,a.id),e})).catch((function(e){throw salla.cart.event.itemUpdatedFailed(e,a.id),e}))]}}))}))},t.prototype.deleteImage=function(e){return p(this,void 0,void 0,(function(){var t,a;return h(this,(function(n){switch(n.label){case 0:return (e=salla.form.getPossibleValue(e,["id","image_id","photo_id"]))?[4,this.getCurrentCartId()]:(t='There is no "id"!',salla.cart.event.imageNotDeleted(t),[2,salla.api.errorPromise(t)]);case 1:return a=n.sent(),[2,this.request(["deleteImage",a,e]).then((function(t){return salla.cart.event.imageDeleted(t,e),t})).catch((function(t){throw salla.cart.event.imageNotDeleted(t,e),t}))]}}))}))},t.prototype.status=function(e){return p(this,void 0,void 0,(function(){var t,a,n;return h(this,(function(r){switch(r.label){case 0:return t=this.request,a=["status"],(n=e)?[3,2]:[4,this.getCurrentCartId()];case 1:n=r.sent(),r.label=2;case 2:return [2,t.apply(this,[a.concat([n]),{params:{has_apple_pay:!!window.ApplePaySession}}])]}}))}))},t.prototype.submit=function(){return p(this,void 0,void 0,(function(){var e,t=this;return h(this,(function(a){switch(a.label){case 0:return e=this.status,[4,this.getCurrentCartId()];case 1:return e.apply(this,[a.sent()]).then((function(e){var a=e.data.next_step.to;if(!["checkout","refresh","login"].includes(a)){var n="Can't find next_step );";throw salla.cart.event.submitFailed(n),n}if(salla.cart.event.submitted(e),"login"===a)return salla.auth.setCanRedirect(!1),salla.event.dispatch("login::open"),void salla.auth.event.onLoggedIn((function(e){salla.event.dispatch("login::close"),t.submit();}));"checkout"===a?window.location.href=e.data.next_step.url+(window.ApplePaySession?"?has_apple_pay=true":""):window.location.reload();})).catch((function(e){throw salla.cart.event.submitFailed(e),e})),[2]}}))}))},t.prototype.getCartPayload=function(e){var t=(null==e?void 0:e.data)||("object"==typeof e?e:void 0);return {id:e=t?salla.form.getPossibleValue(t,["prod_id","product_id","item_id","id"]):e,payload:t="object"==typeof t?t:void 0}},t.prototype.normalRequest=function(t,a,n){return void 0===a&&(a=void 0),void 0===n&&(n=null),e.prototype.normalRequest.call(this,t,a,n).catch((function(e){var t;throw 403===(null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.status)&&(salla.cart.api.reset(),salla.error(salla.lang.get("pages.checkout.try_again"))),e}))},t.prototype.reset=function(){salla.api.cart.latestCart=null,salla.storage.remove("cart"),salla.cart.event.successReset();},t.prototype.addCoupon=function(e){return p(this,void 0,void 0,(function(){var t,a;return h(this,(function(n){switch(n.label){case 0:return e=e.data||e,(e=salla.form.getPossibleValue(e,["coupon"]))?[4,salla.cart.api.getCurrentCartId()]:((t=new Error('There is no "Coupon Code"!')).name="EmptyCoupon",salla.event.cart.couponAdditionFailed(t),[2,salla.api.errorPromise(t)]);case 1:return a=n.sent(),[2,this.request(["addCoupon",a],{coupon:e}).then((function(e){return salla.event.cart.couponAdded(e,a),e})).catch((function(e){throw salla.event.cart.couponAdditionFailed(e,a),e}))]}}))}))},t.prototype.deleteCoupon=function(){return p(this,void 0,void 0,(function(){var e;return h(this,(function(t){switch(t.label){case 0:return [4,salla.cart.api.getCurrentCartId()];case 1:return e=t.sent(),[2,this.request(["deleteCoupon",e],{}).then((function(t){return salla.event.cart.couponDeleted(t,e),t})).catch((function(t){throw salla.event.cart.couponDeletionFailed(t,e),t}))]}}))}))},t.prototype.getQuickOrderSettings=function(){return this.request("getQuickOrderSettings").then((function(e){return salla.event.cart.quickOrderSettingFetched(e),e})).catch((function(e){throw salla.event.cart.quickOrderSettingFailed(e),e}))},t.prototype.createQuickOrder=function(e){return this.request("createQuickOrder",e).then((function(e){return salla.event.cart.quickOrderSucceeded(e),e})).catch((function(e){throw salla.event.cart.quickOrderFailed(e),e}))},t.prototype.priceQuote=function(e){return p(this,void 0,void 0,(function(){var t,a,n;return h(this,(function(r){switch(r.label){case 0:return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("cart::priceQuote",e),salla.event.dispatch("login::open"),[2]):(t=this.request,a=["priceQuote"],(n=e)?[3,2]:[4,this.getCurrentCartId()]);case 1:n=r.sent(),r.label=2;case 2:return [2,t.apply(this,[a.concat([n])]).then((function(e){return salla.cart.api.reset(),salla.event.cart.priceQuoteSucceeded(e).then((function(){return setTimeout((function(){return window.location.href=salla.url.get("/")}),1e3),e}))})).catch((function(e){return salla.event.cart.priceQuoteFailed(e).then((function(){var t;throw 404===(null===(t=e.error)||void 0===t?void 0:t.code)&&window.location.reload(),e}))}))]}}))}))},t}(R),j=function(e){function t(){var t=e.call(this)||this;return t.namespace="loyalty",t.endpoints={getProgram:"loyalty",exchange:"loyalty/exchange",reset:"loyalty/exchange"},t.endpointsMethods={getProgram:"get",reset:"put"},t.after_init(),t}return d(t,e),t.prototype.getProgram=function(){return this.request("getProgram").then((function(e){return salla.loyalty.event.programFetched(e),e})).catch((function(e){throw salla.loyalty.event.programNotFetched(e),e}))},t.prototype.exchange=function(e,t){return void 0===t&&(t=null),p(this,void 0,void 0,(function(){var a,n;return h(this,(function(r){switch(r.label){case 0:return (e=salla.form.getPossibleValue(e,["id","loyalty_prize_id","prize_id"]))?(a=t)?[3,2]:[4,salla.cart.getCurrentCartId()]:(n="Unable to find cart id. Please provide one.",salla.loyalty.event.exchangeFailed(n),[2,salla.api.errorPromise(n)]);case 1:a=r.sent(),r.label=2;case 2:return (t=a)?[2,this.request("exchange",{loyalty_prize_id:e,cart_id:t}).then((function(t){return salla.loyalty.event.exchangeSucceeded(t,e),t})).catch((function(t){throw salla.loyalty.event.exchangeFailed(t,e),t}))]:(n="Unable to find cart id. Please provide one.",salla.loyalty.event.exchangeFailed(n),[2,salla.api.errorPromise(n)])}}))}))},t.prototype.reset=function(e){return void 0===e&&(e=null),p(this,void 0,void 0,(function(){var t,a;return h(this,(function(n){switch(n.label){case 0:return (t=e)?[3,2]:[4,salla.cart.getCurrentCartId()];case 1:t=n.sent(),n.label=2;case 2:return (e=t)?[2,this.request("reset",{cart_id:e}).then((function(e){return salla.loyalty.event.resetSucceeded(e),e})).catch((function(e){throw salla.loyalty.event.resetFailed(e),e}))]:(a="Unable to find cart id. Please provide one.",salla.loyalty.event.resetFailed(a),[2,salla.api.errorPromise(a)])}}))}))},t}(R),U=function(e){function t(){var t=e.call(this)||this;return t.namespace="auth",t.canRedirect_=!0,t.afterLoginEvent={event:null,payload:null},t.endpoints={login:"auth/{type}/send_verification",resend:"auth/resend_verification",verify:"auth/{type}/verify",register:"auth/register",logout:"logout",refresh:"auth/refresh"},t.webEndpoints=["logout","auth/jwt","refresh"],t.endpointsMethods={logout:"get"},t.after_init(),t}return d(t,e),t.prototype.setAfterLoginEvent=function(e,t){salla.api.auth.afterLoginEvent={event:e,payload:t};},t.prototype.setCanRedirect=function(e){salla.api.auth.canRedirect_=e;},t.prototype.canRedirect=function(){return salla.api.auth.canRedirect_&&!salla.api.auth.afterLoginEvent.event},t.prototype.login=function(e){(null==e?void 0:e.data)&&(e=e.data);var t=salla.form.getPossibleValue(e,["type"]);if(!["email","mobile"].includes(t)){var a="Login type should be in: [email, mobile]";return salla.auth.event.codeNotSent(a),salla.api.errorPromise(a)}return this.request(["login",t],e).then((function(e){return salla.auth.event.codeSent(e,t),e})).catch((function(e){throw salla.auth.event.codeNotSent(e,t),e}))},t.prototype.verify=function(e,t){var a;return void 0===t&&(t=!0),p(this,void 0,void 0,(function(){var n,r,i,o;return h(this,(function(l){switch(l.label){case 0:return (n=salla.form.getPossibleValue(e,["type"]))?(t=!1!==salla.form.getPossibleValue(e,["supportWebAuth"])&&t,salla.auth.event.next_event&&(e.next_event=salla.auth.event.next_event),[4,salla.auth.api.request(["verify",n],e)]):(r="Failed to know what's login type!",salla.auth.event.verificationFailed(r),[2,salla.api.errorPromise(r)]);case 1:return 200!==(null==(i=l.sent())?void 0:i.status)?(salla.auth.event.verificationFailed(i,n),[2,salla.api.errorPromise(i)]):((o="authenticated"===(null===(a=i.data)||void 0===a?void 0:a.case))&&salla.auth.event.tokenFetched(i.data.token),t?[4,salla.auth.api.request("auth/jwt")]:[3,3]);case 2:l.sent(),l.label=3;case 3:return o&&salla.auth.event.loggedIn(i).then((function(){return salla.auth.api.afterUserLogin()})),salla.auth.event.verified(i,n),[2,salla.api.successPromise(i)]}}))}))},t.prototype.resend=function(e){var t;return (e=e.data||e).type=e.type||"mobile","mobile"!==e.type||e.phone&&e.country_code?"email"!==e.type||e.email?this.request("resend",e).then((function(t){return salla.auth.event.codeSent(t,e),t})).catch((function(t){throw salla.auth.event.codeNotSent(t,e),t})):(salla.auth.event.codeNotSent(t="There is no email!",e),salla.api.errorPromise(t)):(salla.auth.event.codeNotSent(t="There is no phone or country_code!",e),salla.api.errorPromise(t))},t.prototype.register=function(e){var t;return e.data&&(t=e.element,e=e.data),salla.auth.event.next_event&&(e.next_event=salla.auth.event.next_event),this.request("register",e).then((function(e){var a;return p(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return salla.auth.event.registered.call(t,e),"authenticated"!==(null===(a=e.data)||void 0===a?void 0:a.case)?[3,2]:(salla.auth.event.tokenFetched(e.data.token),[4,salla.auth.request("auth/jwt")]);case 1:n.sent(),salla.auth.event.loggedIn(e),salla.auth.api.afterUserLogin(),n.label=2;case 2:return [2,e]}}))}))})).catch((function(e){throw salla.auth.event.registrationFailed.call(t,e),e}))},t.prototype.logout=function(){return salla.storage.clearAll(),salla.cookie.clearAll(),salla.auth.event.loggedOut().then((function(){var e=salla.url.get("logout");console.log("Going to ".concat(e,", to do any thing before this action use: salla.auth.even.onLoggedOut(()=>{...})"));try{location.href=e;}catch(e){salla.log(e);}}))},t.prototype.refresh=function(){return this.request("refresh").then((function(e){return salla.auth.event.tokenFetched(e.data.token),e})).catch((function(e){throw salla.auth.event.refreshFailed(e),e}))},t.prototype.afterUserLogin=function(){this.afterLoginEvent.event&&salla.event.emit(this.afterLoginEvent.event,this.afterLoginEvent.payload);},t}(R),M=function(e){function t(){var t=e.call(this)||this;return t.namespace="order",t.endpoints={cancel:"orders/cancel/{id}",createCartFromOrder:"reorder/{id}",sendInvoice:"orders/send/{id}"},t.endpointsMethods={createCartFromOrder:"get"},t.after_init(),t}return d(t,e),t.prototype.show=function(e){var t=salla.form.getPossibleValue((null==e?void 0:e.data)||e,["id","order_id"]);salla.event.dispatch("mobile::order.placed",{order_id:t}),location.href=salla.form.getPossibleValue((null==e?void 0:e.data)||e,["url"]);},t.prototype.cancel=function(e){return e=e||Salla.config.get("page.id"),this.request(["cancel",e],{params:{has_apple_pay:!!window.ApplePaySession}}).then((function(t){return salla.event.order.canceled(t,e),t})).catch((function(t){throw salla.event.order.notCanceled(t,e),t}))},t.prototype.createCartFromOrder=function(e){return e=e||salla.config.get("page.id"),this.request(["createCartFromOrder",e]).then((function(t){return salla.cart.reset(),salla.event.order.orderCreated(t,e),window.location.href=t.data.url,t})).catch((function(t){throw salla.event.order.orderCreationFailed(t,e),t}))},t.prototype.sendInvoice=function(e){var t=salla.form.getPossibleValue(e,["id"])||salla.config.get("page.id");if(!t||isNaN(t)){var a="There is no id!";return salla.order.event.invoiceNotSent(a),salla.api.errorPromise(a)}return this.request(["sendInvoice",t],e).then((function(e){return salla.event.order.invoiceSent(e,t),e})).catch((function(e){throw salla.event.order.invoiceNotSent(e,t),e}))},t}(R),V=function(e){function t(){var t=e.call(this)||this;return t.namespace="product",t.previousQuery="",t.endpoints={getPrice:"products/{id}/price",availabilitySubscribe:"products/{id}/availability-notify",search:"products/search",details:"products/{product_id}/details",categories:"products/categories/{?id}",offers:"products/{product_id}/specialoffer",getSizeGuides:"products/{prod_id}/size-guides",giftDetail:"products/{product_id}/buy-as-gift",giftToCart:"products/{product_id}/buy-as-gift",giftImage:"products/buy-as-gift/image",buyNow:"products/{product_id}/buy-now",fetch:"products"},t.endpointsMethods={details:"get",giftDetail:"get",fetch:"get"},t.after_init(),t}return d(t,e),t.prototype.getPrice=function(e){var t=e.data||e,a=salla.form.getPossibleValue(t,["id","prod_id","product_id"]);return this.request(["getPrice",a],"object"==typeof t?t:void 0).then((function(e){return salla.product.event.priceUpdated(e,a),e})).catch((function(e){throw salla.product.event.priceUpdateFailed(e,a),e}))},t.prototype.categories=function(e){return this.request(["categories",e||""],null,"get").then((function(e){return salla.product.event.categoriesFetched(e),e})).catch((function(e){throw salla.product.event.categoriesFailed(e),e}))},t.prototype.availabilitySubscribe=function(e){var t=e.data||e;return e=salla.form.getPossibleValue(t,["id","prod_id"]),this.request(["availabilitySubscribe",e],"object"==typeof t?t:void 0).then((function(t){return salla.product.event.availabilitySubscribed(t,e),t})).catch((function(t){throw salla.product.event.availabilitySubscribeFailed(t,e),t}))},t.prototype.search=function(e){var t,a=e.data;if(a||(a={params:"string"==typeof e?{query:e}:e}),!(e=a instanceof FormData?a.get("query"):a.query||(null===(t=a.params)||void 0===t?void 0:t.query))){var n='There is no "query"!';return salla.product.event.searchFailed(n),salla.api.errorPromise(n)}if(e===salla.api.product.previousQuery){n="Query is same as previous one!";return salla.product.event.searchFailed(n),salla.api.product.previousQuery=null,salla.api.errorPromise(n)}return salla.api.product.previousQuery=e,this.request("search",a,"get").then((function(t){return salla.product.event.searchResults(t,e),t})).catch((function(t){throw salla.product.event.searchFailed(t,e),t}))},t.prototype.offers=function(e){if(!(e=salla.form.getPossibleValue((null==e?void 0:e.data)|e,["product_id","id"]))){var t='There is no "product_id"!';return salla.product.event.fetchOffersFailed(t),salla.api.errorPromise(t)}return this.request(["offers",e]).then((function(t){return salla.product.event.offersFetched(t,e),t})).catch((function(t){throw salla.product.event.fetchOffersFailed(t,e),t}))},t.prototype.getSizeGuides=function(e){return this.request("products/".concat(e,"/size-guides"),null,"get").then((function(t){return salla.product.event.sizeGuideFetched(t,e),t})).catch((function(t){throw salla.product.event.sizeGuideFetchFailed(t,e),t}))},t.prototype.getGiftDetails=function(e){return this.request(["giftDetail",e]).then((function(t){return salla.product.event.giftFetched(t,e),t})).catch((function(t){throw salla.product.event.giftFetchFailed(t,e),t}))},t.prototype.getDetails=function(e,t){if(void 0===t&&(t=[]),!Array.isArray(t)){var a="withItems should be array.";return salla.product.event.detailFetchFailed(a),salla.api.errorPromise(a)}if(!e){a="productId is not passed.";return salla.product.event.detailFetchFailed(a),salla.api.errorPromise(a)}return this.request(["details",e],{params:{with:t}}).then((function(t){return salla.product.event.detailFetched(t,e),t})).catch((function(t){throw salla.product.event.availabilitySubscribeFailed(t,e),t}))},t.prototype.addGiftToCart=function(e,t,a){return void 0===a&&(a=!1),this.request(["giftToCart",e],t).then((function(t){return salla.product.event.addGiftToCartSucceeded(t,e),a&&(window.location.href=t.redirect),t})).catch((function(t){throw salla.product.event.addGiftToCartFailed(t,e),t}))},t.prototype.uploadGiftImage=function(e){return this.request("giftImage",e).then((function(e){return salla.product.event.giftImageUploadSucceeded(e),e})).catch((function(e){throw salla.product.event.giftImageUploadFailed(e),e}))},t.prototype.fetch=function(e){if(!e.source){var t="Source can not be empty. Please provide one.";return salla.product.event.productListFetchFailed(t),salla.api.errorPromise(t)}if(["categories","brands","tags","selected"].includes(e.source)&&!Array.isArray(e.source_value)||"search"===e.source&&"string"!=typeof e.source_value||"related"===e.source&&isNaN(e.source_value)){t="SourceValue type error.";return salla.product.event.productListFetchFailed(t),salla.api.errorPromise(t)}return this.request(this.endpoints.fetch,{params:e},"get").then((function(e){return salla.product.event.productListFetchSucceeded(e),e})).catch((function(e){throw salla.product.event.productListFetchFailed(e),e}))},t}(R),G=function(e){function t(){var t=e.call(this)||this;return t.namespace="profile",t.endpoints={info:"auth/user",update:"profile/update",updateContacts:"profile/contacts/update",updateSettings:"profile/settings",verify:"profile/verify",delete:"profile"},t.endpointsMethods={delete:"delete"},t.after_init(),t}return d(t,e),t.prototype.info=function(){return this.request("info",null,"get").then((function(e){var t={id:e.data.id,type:"user",email:e.data.email,mobile:e.data.phone.code+e.data.phone.number,country_code:e.data.phone.country,language_code:e.data.language,currency_code:e.data.currency,notifications:e.data.notifications,pending_orders:e.data.pending_orders,avatar:e.data.avatar,first_name:e.data.first_name,last_name:e.data.last_name,fetched_at:Date.now()};return salla.config.set("user",t),salla.storage.set("user",t),salla.profile.event.infoFetched(e),e})).catch((function(e){throw salla.profile.event.infoNotFetched(e),e}))},t.prototype.update=function(e){return this.request("update",e).then((function(e){return salla.profile.event.updated(e),e})).catch((function(e){throw salla.event.profile.updateFailed(e),e}))},t.prototype.updateContacts=function(e){return this.request("updateContacts",e).then((function(e){return salla.profile.event.verificationCodeSent(e),e})).catch((function(e){throw salla.event.profile.updateContactsFailed(e),e}))},t.prototype.verify=function(e){return this.request("verify",e).then((function(e){return salla.profile.event.verified(e),e})).catch((function(e){throw salla.event.profile.unverified(e),e}))},t.prototype.updateSettings=function(e){return this.request("updateSettings",e).then((function(e){return salla.event.profile.settingsUpdated(e),e})).catch((function(e){throw salla.event.profile.updateSettingsFailed(e),e}))},t.prototype.delete=function(){return this.request("delete").then((function(e){return salla.storage.clearAll(),salla.cookie.clearAll(),salla.event.profile.deleted(e),window.location.href=salla.url.get("logout"),e})).catch((function(e){throw salla.event.profile.notDeleted(e),e}))},t}(R),H=function(e){function t(){var t=e.call(this)||this;return t.namespace="comment",t.endpoints={comments:"{type}/{id}/comments"},t.after_init(),t}return d(t,e),t.prototype.add=function(e){if((null==e?void 0:e.data)&&(e=e.data),"string"==typeof(e=this.getCommentPayload(e)))return salla.event.comment.additionFailed(e),salla.api.errorPromise(e);if(!e.comment){var t="can't find comment content!";return salla.event.comment.additionFailed(t),salla.api.errorPromise(t)}return this.request(["comments",e.type,e.id],{comment:e.comment}).then((function(t){return salla.event.comment.added(t,e.id),t})).catch((function(t){throw salla.event.comment.additionFailed(t,e.id),t}))},t.prototype.getCommentPayload=function(e){var t={};return ["id","type","comment","per_page","page"].forEach((function(a){var n=salla.form.getPossibleValue(e,[a]);n&&(t[a]=n);})),t.id?t.type&&["products","pages","product","page"].includes(t.type)?(t.type+=["product","page"].includes(t.type)?"s":"",t):"Failed to get type one of:(products, product, page, pages)!":"Failed to get id!"},t.prototype.fetch=function(e){return "string"==typeof(e=this.getCommentPayload(e))?(salla.event.comment.fetchFailed(e),salla.api.errorPromise(e)):this.request(["comments",e.type,e.id],{params:e},"get").then((function(t){return salla.event.comment.fetched(t,e),t})).catch((function(t){throw salla.event.comment.fetchFailed(t,e),t}))},t.prototype.getPageComments=function(e,t,a){return void 0===t&&(t=1),void 0===a&&(a=10),this.fetch({id:e,type:"pages",page:t,per_page:a})},t.prototype.getProductComments=function(e,t,a){return void 0===t&&(t=1),void 0===a&&(a=10),this.fetch({id:e,type:"products",page:t,per_page:a})},t}(R),Q=function(e){function t(){var t=e.call(this)||this;return t.namespace="currency",t.endpoints={change:"/",list:"currencies"},t.endpointsMethods={change:"get",list:"get"},t.webEndpoints=["change"],t.after_init(),t}return d(t,e),t.prototype.change=function(e){if(!(e=salla.form.getPossibleValue(e.data||e,["currency","code"]))){var t="Can't find currency code!";return salla.currency.event.failed(t),salla.api.errorPromise(t)}return this.request("change",{params:{change_currency:"",currency:e}}).then((function(t){return salla.cookie.set("fresh_summary",1),salla.storage.set("cart",""),salla.currency.event.changed(t,e),t})).catch((function(t){throw salla.currency.event.failed(t,e),t}))},t.prototype.list=function(){return this.request("list").then((function(e){return salla.currency.event.fetched(e),e})).catch((function(e){throw salla.currency.event.failedToFetch(e),e}))},t}(R),z=function(e){function t(){var t=e.call(this)||this;return t.namespace="document",t}return d(t,e),t}(R),B=function(e){function t(){var t=e.call(this)||this;return t.namespace="rating",t.endpoints={store:"rating/store",products:"rating/products",shipping:"rating/shipping",order:"rating/{order_id}"},t.endpointsMethods={order:"get"},t.after_init(),t}return d(t,e),t.prototype.order=function(e){var t="object"==typeof e?e:{},a=salla.form.getPossibleValue((null==e?void 0:e.data)||e,["order_id","id"]);if(!a){var n='There is no "order_id"!';return salla.event.rating.orderNotFetched(n),salla.api.errorPromise(n)}return this.request(["order",a],t).then((function(e){return salla.event.rating.orderFetched(e,a),e})).catch((function(e){throw salla.event.rating.orderNotFetched(e,a),e}))},t.prototype.store=function(e){if(!(e=(null==e?void 0:e.data)||e)){var t='There is no "data"!';return salla.event.rating.storeFailed(t),salla.api.errorPromise(t)}return this.request("store",e).then((function(t){return salla.event.rating.storeRated(t,e),t})).catch((function(t){throw salla.event.rating.storeFailed(t,e),t}))},t.prototype.products=function(e){if(!(e=(null==e?void 0:e.data)||e)){var t='There is no "data"!';return salla.event.rating.productsFailed(t),salla.api.errorPromise(t)}return this.request("products",e).then((function(t){return salla.event.rating.productsRated(t,e),t})).catch((function(t){throw salla.event.rating.productsFailed(t,e),t}))},t.prototype.shipping=function(e){if(!(e=(null==e?void 0:e.data)||e)){var t='There is no "data"!';return salla.event.rating.shippingFailed(t),salla.api.errorPromise(t)}return this.request("shipping",e).then((function(t){return salla.event.rating.shippingRated(t,e),t})).catch((function(t){throw salla.event.rating.shippingFailed(t,e),t}))},t}(R),W=function(e){function t(){var t=e.call(this)||this;return t.namespace="wishlist",t.endpoints={add:"products/favorites/{id}",remove:"products/favorites/{id}"},t.endpointsMethods={remove:"delete"},t.after_init(),t}return d(t,e),t.prototype.toggle=function(e){return salla.storage.get("salla::wishlist",[]).includes(e)?this.remove(e):this.add(e)},t.prototype.add=function(e){var t,a=this;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(t=salla.lang.get("common.messages.must_login")),salla.error(t),salla.api.errorPromise(t)):(e=salla.form.getPossibleValue((null==e?void 0:e.data)||e,["product_id","id"]))?this.request(["add",e]).then((function(t){return a.updateWishlistStorage(e),salla.wishlist.event.added(t,e),t})).catch((function(t){throw salla.wishlist.event.additionFailed(t,e),t})):(salla.wishlist.event.additionFailed(t="Failed to get product id!"),salla.api.errorPromise(t))},t.prototype.remove=function(e){var t,a=this;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(t=salla.lang.get("common.messages.must_login")),salla.error(t),salla.api.errorPromise(t)):(e=salla.form.getPossibleValue((null==e?void 0:e.data)||e,["product_id","id"]))?this.request(["remove",e]).then((function(t){return a.updateWishlistStorage(e,!1),salla.wishlist.event.removed(t,e),t})).catch((function(t){throw salla.wishlist.event.removingFailed(t,e),t})):(salla.wishlist.event.removingFailed(t="Failed to get id!"),salla.api.errorPromise(t))},t.prototype.updateWishlistStorage=function(e,t){void 0===t&&(t=!0);var a=salla.storage.get("salla::wishlist",[]);t?a.push(e):a.splice(a.indexOf(e),1),salla.storage.set("salla::wishlist",a);},t}(R),X=function(e){function t(){var t=e.call(this)||this;return t.namespace="scopes",t.endpoints={get:"scopes",change:"scopes",getProductAvailability:"scopes/availability?product_id={id}"},t.after_init(),t}return d(t,e),t.prototype.get=function(){return this.request("scopes",null,"get").then((function(e){return salla.scope.event.fetched(e),e})).catch((function(e){throw salla.scope.event.notFetched(e),e}))},t.prototype.change=function(e){return this.request("scopes",e).then((function(e){return salla.scope.event.changeSucceeded(e),e})).catch((function(e){throw salla.scope.event.changeFailed(e),e}))},t.prototype.getProductAvailability=function(e){return void 0===e&&(e=null),this.request("scopes/availability?product_id=".concat(e),null,"get").then((function(t){return salla.scope.event.productAvailabilityFetched(t,e),t})).catch((function(e){throw salla.scope.event.productAvailabilityNotFetched(e),e}))},t}(R),Z=function(e){function t(){var t=e.call(this)||this;return t.namespace="booking",t.endpoints={add:"cart/booking/product/{id}"},t.endpointsMethods={add:"get"},t}return d(t,e),t.prototype.add=function(e,t){return void 0===t&&(t=!0),p(this,void 0,void 0,(function(){var a;return h(this,(function(n){return e?[2,this.request(["add",e]).then((function(e){return salla.booking.event.added(e),t&&"booking"===e.data.redirect.to&&(window.location.href=e.data.redirect.url),e})).catch((function(e){throw salla.booking.event.additionFailed(e),e}))]:(a="Please provide product id.",salla.booking.event.additionFailed(a),[2,salla.api.errorPromise(a)])}))}))},t}(R),J=function(e){function t(){var t=e.call(this)||this;return t.namespace="landing",t.endpoints={getDetails:"landing/{landing_page_id}",createCartFromPage:"landing/{landing_page_id}"},t.endpointsMethods={getDetails:"get"},t.after_init(),t}return d(t,e),t.prototype.getDetails=function(e){if(!e){var t="page landing id not passed";return salla.event.landing.getDetailsFailed(t),salla.api.errorPromise(t)}return this.request(["getDetails",e]).then((function(t){return salla.event.landing.detailsFetched(t,e),t})).catch((function(t){throw salla.event.landing.getDetailsFailed(t,e),t}))},t.prototype.createCartFromPage=function(e){if(!e){var t="page landing id not passed";return salla.event.landing.orderCreationFailed(t),salla.api.errorPromise(t)}return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("landing::createCartFromPage",e),salla.event.dispatch("login::open"),salla.api.successPromise("")):this.request(["createCartFromPage",e]).then((function(t){return salla.event.landing.orderCreated(t,e).then((function(){return location.href=t.data.url})),t})).catch((function(t){throw salla.event.landing.orderCreationFailed(t,e),t}))},t}(R),K=function(){function e(){var e=this;salla.event.on("twilight::before.ready",(function(t){return e.initiateRequest(t)})),salla.event.on("profile::info.fetched",(function(t){return e.setCurrencyAndLanguage(t)})),salla.event.on("auth::token.fetched",(function(t){salla.storage.set("token",t),e.setToken(t),salla.cart.api.reset();})),this.notifier_handler_disabled=!1,this.axios=axios.create({headers:{common:{"X-Requested-With":"XMLHttpRequest","S-SOURCE":"twilight","S-APP-VERSION":"v2.0.0","S-APP-OS":"browser"}}});}return e.prototype.getHeaders=function(){return this.axios.defaults.headers.common},e.prototype.setHeaders=function(e){var t=this;return Object.entries(e).forEach((function(e){return t.setHeader(e[0],e[1])})),this},e.prototype.setHeader=function(e,t){return salla.infiniteScroll.fetchOptions.headers[e]=this.axios.defaults.headers.common[e]=t,this},e.prototype.withoutNotifier=function(e){return p(this,void 0,void 0,(function(){var t=this;return h(this,(function(a){switch(a.label){case 0:return this.notifier_handler_disabled=!0,[4,e().finally((function(){t.notifier_handler_disabled=!1;}))];case 1:return [2,a.sent()]}}))}))},e.prototype.initiateRequest=function(e){var t,a;this.axios.defaults.baseURL=Salla.config.get("store.api",Salla.config.get("store.url")),this.setHeaders({"Store-Identifier":Salla.config.get("store.id"),currency:(null===(t=e.user)||void 0===t?void 0:t.currency_code)||"SAR","accept-language":salla.lang.getLocale(),"s-user-id":null===(a=e.user)||void 0===a?void 0:a.id});var n=salla.storage.get("scope");n&&this.setHeaders({"s-scope-type":n.type,"s-scope-id":n.id}),this.injectTokenToTheRequests(e),salla.storage.get("affiliate_code")&&this.setHeader("s-affiliate-code",salla.storage.get("affiliate_code"));},e.prototype.injectTokenToTheRequests=function(e){var t,a,r,i=salla.storage.get("token"),o="guest"===e.user.type,l=salla.storage.get("cart"),s=null===(t=e.user)||void 0===t?void 0:t.id,c=salla.storage.get("user.id");if(c&&c!==s&&(salla.log("Api:: case1 = >user in localStorage is not same as user in the config"),salla.storage.remove("user")),l&&(l.user_id!==s||l.store_id!==(null===(a=e.store)||void 0===a?void 0:a.id)))return salla.log("cart",{user_id:l.user_id,store_id:l.store_id}),salla.log("current",{user_id:s,store_id:null===(r=e.store)||void 0===r?void 0:r.id}),salla.log("Api:: case2 => The cart is not belong to current "+(l.user_id!==s?"user":"store")+"!"),void salla.cart.api.reset();if(!o||i){if(o&&i)return salla.log("Api:: case4 => there is a token and current user is guest"),salla.log("Auth:: Token without user!"),salla.storage.remove("token"),void salla.cart.api.reset();if(!i)return salla.log("Api:: case5 => current user is logged-in but there is no token"),salla.cart.api.reset(),void salla.auth.api.refresh();var d=o$1(i);if(Date.now()/1e3>d.exp)return salla.log("Api:: case6 => current user is logged-in and there is a token, but it's expired"),salla.storage.remove("token"),salla.cart.api.reset(),void salla.auth.api.refresh();if(d.sub!==s)return salla.log("Api:: case7 => The user id is not match the token details"),salla.storage.remove("token"),salla.cart.api.reset(),void salla.auth.api.refresh();this.setToken(i),salla.log("Api:: case8 => current user is logged-in and there is a token, and it's not expired"),salla.event.emit("api::initiated");}else salla.log("Api:: case3 => current user is a guest and there is no token");},e.prototype.setToken=function(e){return this.setHeader("Authorization","Bearer "+e),salla.event.emit("api::token.injected",e),this.token=e,this},e.prototype.setCurrencyAndLanguage=function(e){return this.setHeaders({currency:e.data.currency,"accept-language":e.data.language})},e.prototype.request=function(e,t,a,n){var r=this;void 0===t&&(t=void 0),void 0===a&&(a="get"),void 0===n&&(n={});var i={endPoint:e,payload:t,method:a,options:n},o="undefined"!=typeof event?event.currentTarget:null,l=!1;return "SALLA-BUTTON"===(null==o?void 0:o.tagName)&&(l=!0),l&&(null==o||o.load()),this.axios[i.method](i.endPoint,i.payload,i.options).then((function(e){return l&&(null==o||o.stop()),e.data&&e.request&&(e=e.data),r.handleAfterResponseActions(e),e})).catch((function(e){throw l&&(null==o||o.stop()),salla.event.document.requestFailed(i,e),r.handleErrorResponse(e),e}))},e.prototype.handleAfterResponseActions=function(e){if(e){var t=e.data,a=e.googleTags,n=void 0===a?null:a,r=t&&t.googleTags?t.googleTags:n;try{window.dataLayer&&r&&window.dataLayer.push(r);}catch(e){salla.logger.error(e.message);}this.fireEventsForResponse(e),this.showAlert(e);}},e.prototype.fireEventsForResponse=function(e){var t,a,n=(null==e?void 0:e.events)||(null===(t=e.data)||void 0===t?void 0:t.events)||(null===(a=e.error)||void 0===a?void 0:a.events);"string"==typeof n&&(n=JSON.parse(n)),n&&Object.keys(n).forEach((function(e){return salla.event.dispatch(e,n[e])}));},e.prototype.handleErrorResponse=function(e){if(e.response&&e.response.data)return e.response.data.error&&e.response.data.error.fields&&!this.notifier_handler_disabled?this.handleInvalidFields(e):this.handleAfterResponseActions(e.response.data)},e.prototype.showAlert=function(e){var t,a;if(e&&!this.notifier_handler_disabled)return e.case&&e.msg?salla.notify.fire(e.msg,e.case,e):e.hasOwnProperty("success")&&(null===(t=e.data)||void 0===t?void 0:t.message)?salla.notify.fire(null===(a=e.data)||void 0===a?void 0:a.message,e.success?salla.notify.types.success:salla.notify.types.error,e):e.error&&e.error.message&&"FORBIDDEN"!==e.error.message?salla.error(e.error.message,e):void 0},e.prototype.handleInvalidFields=function(e){var t=e.response.data.error.fields,a=[];Object.keys(t).forEach((function(e){var n=t[e];Array.isArray(n)?n.forEach((function(e){return a.push(e)})):a.push(n);}));var n=(a.length>1?"* ":"")+a.join("\n* ");salla.error(n,e);},e.prototype.isFastRequestsAllowed=function(){return Salla.config.get("fastRequests")},e.prototype.promise=function(e,t){return void 0===t&&(t=!0),new Promise((function(a,n){return t?a(e):n(e)}))},e.prototype.errorPromise=function(e){return this.promise(e,!1)},e.prototype.successPromise=function(e){return this.promise(e,!0)},e}(),$=function(e){function t(){var t=e.call(this)||this;return t.auth=new U,t.cart=new N,t.loyalty=new j,t.order=new M,t.rating=new B,t.product=new V,t.profile=new G,t.comment=new H,t.currency=new Q,t.document=new z,t.wishlist=new W,t.scope=new X,t.booking=new Z,t.landing=new J,t}return d(t,e),t}(K),Y=function(){function e(e){var t,a;"ready"!==Salla.status?e?(Salla.config.merge(e),(null==e?void 0:e.events)&&Salla.event.dispatchEvents(null==e?void 0:e.events),e._token&&salla.api.setHeader("X-CSRF-TOKEN",e._token),this.injectMaintenanceAlert(),this.injectThemePreviewAlert(),this.injectEditAlert(),(null===(t=null==e?void 0:e.user)||void 0===t?void 0:t.language_code)&&salla.lang.setLocale(null===(a=null==e?void 0:e.user)||void 0===a?void 0:a.language_code),salla.lang.loadStoreTranslations(),this.setSallaReady(e)):this.setSallaReady(e):salla.log("Trying to re-initiate Salla, while its status === 'ready'!");}return e.prototype.injectMaintenanceAlert=function(){salla.config.get("maintenance")&&(document.body.classList.add("has-maintenance-bar"),document.querySelector("salla-maintenance-alert")?salla.logger.warn("salla-maintenance-alert element Existed before!"):salla.lang.onLoaded((function(){return document.body.prepend(document.createElement("salla-maintenance-alert"))})));},e.prototype.injectThemePreviewAlert=function(){"preview"===salla.config.get("theme.mode")&&(document.body.classList.add("has-preview-bar"),document.querySelector("#s-theme_preview_bar")?salla.logger.warn("#s-theme_preview_bar element Existed before!"):salla.lang.onLoaded((function(){var e=document.createElement("div");e.id="s-theme_preview_bar",e.setAttribute("style","display: flex; justify-content: space-between; text-align: center; background-color: #232323; color: #fff; padding: 10px; font-size: 0.875rem; line-height: 1.25rem; position: relative;"),e.innerHTML='\n <div style="display:flex; align-items:center;">\n <img width="32" src="https://assets.salla.sa/cp/assets/images/logo-new.png">\n <span style="margin:0 10px;">'.concat(salla.lang.get("blocks.header.preview_mode"),': <span style="background:rgba(255,255,255,0.25);border-radius:15px; padding:2px 15px 4px">').concat(salla.config.get("theme.name"),'</span></span>\n </div>\n <a href="').concat(salla.url.get("preview_theme/cancel/preview"),'" style="line-height:32px; width:32px;"><i class="sicon-cancel"></i></a>\n '),document.body.prepend(e);})));},e.prototype.injectEditAlert=function(){var e=salla.config.get("edit");e&&(document.querySelector("#s-edit-alert")?salla.logger.warn("#s-edit-alert element Existed before!"):salla.lang.onLoaded((function(){var t=document.createElement("div");t.id="s-edit-alert",t.innerHTML='\n <a href="'.concat(e,'" style="display:block; background-color:').concat(salla.config.get("theme.color.primary","#5cd5c4"),"; color:").concat(salla.config.get("theme.color.reverse","#fff"),'; padding: 10px; text-align:center; font-size: 0.875rem; line-height: 1.25rem;">\n <i class="sicon-edit"></i> \n ').concat(salla.lang.get("pages.products.quick_edit"),"\n </a>\n "),document.body.prepend(t);})));},e.prototype.handleElementAjaxRequest=function(e,t){var a=this;if(!(t instanceof HTMLFormElement||t instanceof HTMLAnchorElement))return salla.logger.warn("trying to call ajax from non Element!!"),!1;e.preventDefault();var n=t.getAjaxFormData(e),r=n.method?n.method.toLowerCase():void 0;salla.api.request(n.url,n.formData,r).then((function(e){return e.data&&e.request&&(e=e.data),salla.api.handleAfterResponseActions(e),a.callAjaxEvent(n.events.success,e,n.formData),e})).catch((function(e){throw salla.api.handleErrorResponse(e),a.callAjaxEvent(n.events.fail,e,n.formData),e}));},e.prototype.callAjaxEvent=function(e,t,a){if(e){if(a instanceof FormData){var n={};Array.from(a.entries()).forEach((function(e){n[e[0]]=e[1];})),a=n;}window[e]?window[e](t,a):salla.event.dispatch(e,t,a);}},e.prototype.setSallaReady=function(e){Salla.event.dispatch("twilight::before.ready",e),Salla.status="ready",Salla.event.dispatch("twilight::initiated",e),window.dispatchEvent(new CustomEvent("twilight::initiated",{detail:e}));},e}();Salla.status="loading",Salla.notify=l,Salla.lang=new L,Salla.form=new I,Salla.infiniteScroll=new O(void 0,salla.event.infiniteScroll),Salla.api=new $,["cart","auth","order","scope","rating","comment","loyalty","product","profile","currency","document","wishlist","booking","landing"].forEach((function(e){return Salla[e]=new s(Salla.api[e],Salla.event[e])})),Salla.call=function(e){for(var t=Salla,a=e.split(".");a.length&&(t=t[a.shift()]););return t},Salla.init=function(e){return new Y(e)},salla.event.once("twilight::init",salla.init),salla.event.once("twilight::api",(function(e){var t=null==e?void 0:e.events;t&&salla.event.dispatchEvents(t);})),Salla.success=Salla.notify.success,Salla.error=Salla.notify.error,Salla.versions.twilight="[VI]{version}[/VI]",Salla.onInitiated=function(e){return salla.event.once("twilight::initiated",e)},Salla.onReady=Salla.onReady||function(e){"ready"!==salla.status?Salla.onInitiated(e):e(salla.config.all());},window.dispatchEvent(new CustomEvent("salla::created"));
4174
+
4175
+ var lazyload_min = _commonjsHelpers.createCommonjsModule(function (module, exports) {
4176
+ !function(n,t){module.exports=t();}(_commonjsHelpers.commonjsGlobal,(function(){function n(){return n=Object.assign||function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);}return n},n.apply(this,arguments)}var t="undefined"!=typeof window,e=t&&!("onscroll"in window)||"undefined"!=typeof navigator&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),i=t&&"IntersectionObserver"in window,o=t&&"classList"in document.createElement("p"),a=t&&window.devicePixelRatio>1,r={elements_selector:".lazy",container:e||t?document:null,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",data_bg_hidpi:"bg-hidpi",data_bg_multi:"bg-multi",data_bg_multi_hidpi:"bg-multi-hidpi",data_bg_set:"bg-set",data_poster:"poster",class_applied:"applied",class_loading:"loading",class_loaded:"loaded",class_error:"error",class_entered:"entered",class_exited:"exited",unobserve_completed:!0,unobserve_entered:!1,cancel_on_exit:!0,callback_enter:null,callback_exit:null,callback_applied:null,callback_loading:null,callback_loaded:null,callback_error:null,callback_finish:null,callback_cancel:null,use_native:!1,restore_on_error:!1},c=function(t){return n({},r,t)},l=function(n,t){var e,i="LazyLoad::Initialized",o=new n(t);try{e=new CustomEvent(i,{detail:{instance:o}});}catch(n){(e=document.createEvent("CustomEvent")).initCustomEvent(i,!1,!1,{instance:o});}window.dispatchEvent(e);},u="src",s="srcset",d="sizes",f="poster",_="llOriginalAttrs",g="data",v="loading",b="loaded",m="applied",p="error",h="native",E="data-",I="ll-status",y=function(n,t){return n.getAttribute(E+t)},k=function(n){return y(n,I)},w=function(n,t){return function(n,t,e){var i="data-ll-status";null!==e?n.setAttribute(i,e):n.removeAttribute(i);}(n,0,t)},A=function(n){return w(n,null)},L=function(n){return null===k(n)},O=function(n){return k(n)===h},x=[v,b,m,p],C=function(n,t,e,i){n&&(void 0===i?void 0===e?n(t):n(t,e):n(t,e,i));},N=function(n,t){o?n.classList.add(t):n.className+=(n.className?" ":"")+t;},M=function(n,t){o?n.classList.remove(t):n.className=n.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"");},z=function(n){return n.llTempImage},T=function(n,t){if(t){var e=t._observer;e&&e.unobserve(n);}},R=function(n,t){n&&(n.loadingCount+=t);},G=function(n,t){n&&(n.toLoadCount=t);},j=function(n){for(var t,e=[],i=0;t=n.children[i];i+=1)"SOURCE"===t.tagName&&e.push(t);return e},D=function(n,t){var e=n.parentNode;e&&"PICTURE"===e.tagName&&j(e).forEach(t);},H=function(n,t){j(n).forEach(t);},V=[u],F=[u,f],B=[u,s,d],J=[g],P=function(n){return !!n[_]},S=function(n){return n[_]},U=function(n){return delete n[_]},$=function(n,t){if(!P(n)){var e={};t.forEach((function(t){e[t]=n.getAttribute(t);})),n[_]=e;}},q=function(n,t){if(P(n)){var e=S(n);t.forEach((function(t){!function(n,t,e){e?n.setAttribute(t,e):n.removeAttribute(t);}(n,t,e[t]);}));}},K=function(n,t,e){N(n,t.class_applied),w(n,m),e&&(t.unobserve_completed&&T(n,t),C(t.callback_applied,n,e));},Q=function(n,t,e){N(n,t.class_loading),w(n,v),e&&(R(e,1),C(t.callback_loading,n,e));},W=function(n,t,e){e&&n.setAttribute(t,e);},X=function(n,t){W(n,d,y(n,t.data_sizes)),W(n,s,y(n,t.data_srcset)),W(n,u,y(n,t.data_src));},Y={IMG:function(n,t){D(n,(function(n){$(n,B),X(n,t);})),$(n,B),X(n,t);},IFRAME:function(n,t){$(n,V),W(n,u,y(n,t.data_src));},VIDEO:function(n,t){H(n,(function(n){$(n,V),W(n,u,y(n,t.data_src));})),$(n,F),W(n,f,y(n,t.data_poster)),W(n,u,y(n,t.data_src)),n.load();},OBJECT:function(n,t){$(n,J),W(n,g,y(n,t.data_src));}},Z=["IMG","IFRAME","VIDEO","OBJECT"],nn=function(n,t){!t||function(n){return n.loadingCount>0}(t)||function(n){return n.toLoadCount>0}(t)||C(n.callback_finish,t);},tn=function(n,t,e){n.addEventListener(t,e),n.llEvLisnrs[t]=e;},en=function(n,t,e){n.removeEventListener(t,e);},on=function(n){return !!n.llEvLisnrs},an=function(n){if(on(n)){var t=n.llEvLisnrs;for(var e in t){var i=t[e];en(n,e,i);}delete n.llEvLisnrs;}},rn=function(n,t,e){!function(n){delete n.llTempImage;}(n),R(e,-1),function(n){n&&(n.toLoadCount-=1);}(e),M(n,t.class_loading),t.unobserve_completed&&T(n,e);},cn=function(n,t,e){var i=z(n)||n;on(i)||function(n,t,e){on(n)||(n.llEvLisnrs={});var i="VIDEO"===n.tagName?"loadeddata":"load";tn(n,i,t),tn(n,"error",e);}(i,(function(o){!function(n,t,e,i){var o=O(t);rn(t,e,i),N(t,e.class_loaded),w(t,b),C(e.callback_loaded,t,i),o||nn(e,i);}(0,n,t,e),an(i);}),(function(o){!function(n,t,e,i){var o=O(t);rn(t,e,i),N(t,e.class_error),w(t,p),C(e.callback_error,t,i),e.restore_on_error&&q(t,B),o||nn(e,i);}(0,n,t,e),an(i);}));},ln=function(n,t,e){!function(n){return Z.indexOf(n.tagName)>-1}(n)?function(n,t,e){!function(n){n.llTempImage=document.createElement("IMG");}(n),cn(n,t,e),function(n){P(n)||(n[_]={backgroundImage:n.style.backgroundImage});}(n),function(n,t,e){var i=y(n,t.data_bg),o=y(n,t.data_bg_hidpi),r=a&&o?o:i;r&&(n.style.backgroundImage='url("'.concat(r,'")'),z(n).setAttribute(u,r),Q(n,t,e));}(n,t,e),function(n,t,e){var i=y(n,t.data_bg_multi),o=y(n,t.data_bg_multi_hidpi),r=a&&o?o:i;r&&(n.style.backgroundImage=r,K(n,t,e));}(n,t,e),function(n,t,e){var i=y(n,t.data_bg_set);if(i){var o=i.split("|"),a=o.map((function(n){return "image-set(".concat(n,")")}));n.style.backgroundImage=a.join(),""===n.style.backgroundImage&&(a=o.map((function(n){return "-webkit-image-set(".concat(n,")")})),n.style.backgroundImage=a.join()),K(n,t,e);}}(n,t,e);}(n,t,e):function(n,t,e){cn(n,t,e),function(n,t,e){var i=Y[n.tagName];i&&(i(n,t),Q(n,t,e));}(n,t,e);}(n,t,e);},un=function(n){n.removeAttribute(u),n.removeAttribute(s),n.removeAttribute(d);},sn=function(n){D(n,(function(n){q(n,B);})),q(n,B);},dn={IMG:sn,IFRAME:function(n){q(n,V);},VIDEO:function(n){H(n,(function(n){q(n,V);})),q(n,F),n.load();},OBJECT:function(n){q(n,J);}},fn=function(n,t){(function(n){var t=dn[n.tagName];t?t(n):function(n){if(P(n)){var t=S(n);n.style.backgroundImage=t.backgroundImage;}}(n);})(n),function(n,t){L(n)||O(n)||(M(n,t.class_entered),M(n,t.class_exited),M(n,t.class_applied),M(n,t.class_loading),M(n,t.class_loaded),M(n,t.class_error));}(n,t),A(n),U(n);},_n=["IMG","IFRAME","VIDEO"],gn=function(n){return n.use_native&&"loading"in HTMLImageElement.prototype},vn=function(n,t,e){n.forEach((function(n){return function(n){return n.isIntersecting||n.intersectionRatio>0}(n)?function(n,t,e,i){var o=function(n){return x.indexOf(k(n))>=0}(n);w(n,"entered"),N(n,e.class_entered),M(n,e.class_exited),function(n,t,e){t.unobserve_entered&&T(n,e);}(n,e,i),C(e.callback_enter,n,t,i),o||ln(n,e,i);}(n.target,n,t,e):function(n,t,e,i){L(n)||(N(n,e.class_exited),function(n,t,e,i){e.cancel_on_exit&&function(n){return k(n)===v}(n)&&"IMG"===n.tagName&&(an(n),function(n){D(n,(function(n){un(n);})),un(n);}(n),sn(n),M(n,e.class_loading),R(i,-1),A(n),C(e.callback_cancel,n,t,i));}(n,t,e,i),C(e.callback_exit,n,t,i));}(n.target,n,t,e)}));},bn=function(n){return Array.prototype.slice.call(n)},mn=function(n){return n.container.querySelectorAll(n.elements_selector)},pn=function(n){return function(n){return k(n)===p}(n)},hn=function(n,t){return function(n){return bn(n).filter(L)}(n||mn(t))},En=function(n,e){var o=c(n);this._settings=o,this.loadingCount=0,function(n,t){i&&!gn(n)&&(t._observer=new IntersectionObserver((function(e){vn(e,n,t);}),function(n){return {root:n.container===document?null:n.container,rootMargin:n.thresholds||n.threshold+"px"}}(n)));}(o,this),function(n,e){t&&(e._onlineHandler=function(){!function(n,t){var e;(e=mn(n),bn(e).filter(pn)).forEach((function(t){M(t,n.class_error),A(t);})),t.update();}(n,e);},window.addEventListener("online",e._onlineHandler));}(o,this),this.update(e);};return En.prototype={update:function(n){var t,o,a=this._settings,r=hn(n,a);G(this,r.length),!e&&i?gn(a)?function(n,t,e){n.forEach((function(n){-1!==_n.indexOf(n.tagName)&&function(n,t,e){n.setAttribute("loading","lazy"),cn(n,t,e),function(n,t){var e=Y[n.tagName];e&&e(n,t);}(n,t),w(n,h);}(n,t,e);})),G(e,0);}(r,a,this):(o=r,function(n){n.disconnect();}(t=this._observer),function(n,t){t.forEach((function(t){n.observe(t);}));}(t,o)):this.loadAll(r);},destroy:function(){this._observer&&this._observer.disconnect(),t&&window.removeEventListener("online",this._onlineHandler),mn(this._settings).forEach((function(n){U(n);})),delete this._observer,delete this._settings,delete this._onlineHandler,delete this.loadingCount,delete this.toLoadCount;},loadAll:function(n){var t=this,e=this._settings;hn(n,e).forEach((function(n){T(n,t),ln(n,e,t);}));},restoreAll:function(){var n=this._settings;mn(n).forEach((function(t){fn(t,n);}));}},En.load=function(n,t){var e=c(t);ln(n,e);},En.resetStatus=function(n){A(n);},t&&function(n,t){if(t)if(t.length)for(var e,i=0;e=t[i];i+=1)l(n,e);else l(n,t);}(En,window.lazyLoadOptions),En}));
4177
+ });
4178
+
4179
+ /**
4180
+ * if there are a failed with ts build because twilight use the final bundle temporary
4181
+ * import '@salla.sa/twilight/dist/@salla.sa/twilight.min'
4182
+ */
4183
+ function appGlobalScript () {
4184
+ // Only initialize it one time for the entire application
4185
+ if (!document.lazyLoadInstance) {
4186
+ document.lazyLoadInstance = new lazyload_min({
4187
+ use_native: true, //native not support lazyLoad backgrounds
4188
+ // restore_on_error: true,
4189
+ // Your custom settings go here
4190
+ // callback_finish: () => document.lazyLoadBackgrounds.update(document.querySelectorAll('.lazy[data-bg]:not(.loaded)'))
4191
+ });
4192
+ document.lazyLoadBackgrounds = new lazyload_min({
4193
+ elements_selector: '.lazy[data-bg]:not(.loaded)',
4194
+ });
4195
+ //native way doesn't load backgrounds
4196
+ // document.lazyLoadBackgrounds = new LazyLoad();
4197
+ }
4198
+ //make sure that lazyLoad will be fired after loading the page too.
4199
+ if (document.readyState !== 'complete') {
4200
+ document.addEventListener("DOMContentLoaded", () => document.lazyLoadInstance.update());
4201
+ document.addEventListener("DOMContentLoaded", () => document.lazyLoadBackgrounds.update());
4202
+ }
4203
+ // fire it after each load more request;
4204
+ // @ts-ignore
4205
+ salla.infiniteScroll.event.onAppend(() => {
4206
+ document.lazyLoadInstance.update();
4207
+ document.lazyLoadBackgrounds.update();
4208
+ });
4209
+ }
4210
+
4211
+ const globalScripts = appGlobalScript;
4212
+
4213
+ exports.globalScripts = globalScripts;
4214
+
4215
+ //# sourceMappingURL=app-globals-9ad08b7a.js.map