PageSourceSearch

https://www.kallistogaiapress.org/wp-content/themes/themify-ultra/themify/js/main.js?ver=7.2.6

js kallistogaiapress.org collected 2026-09-26 00:26:47 UTC 63,124 bytes, 1,390 lines download raw bytes

1var Themify;
2((win, doc, und, vars)=>{
3    'use strict';
4    const OnOf=(on,el,ev,f,p)=>{
5        ev=typeof ev==='string'?ev.split(' '):ev;
6        for(let i=ev.length-1;i>-1;--i){
7            on===true?el.addEventListener(ev[i],f,p):el.removeEventListener(ev[i],f,p);
8        }
9        return el;
10    };
11    Node.prototype.tfClass=function(sel){
12        return this.getElementsByClassName(sel);
13    };
14    Node.prototype.tfTag=function(sel){
15        return this.getElementsByTagName(sel);
16    };
17    Node.prototype.tfId=function(id){
18        return this.getElementById(id);
19    };
20    EventTarget.prototype.tfOn=function(ev,f,p){
21        return OnOf(true,this,ev,f,p);
22    };
23    EventTarget.prototype.tfOff=function(ev,f,p){
24        return OnOf(null,this,ev,f,p);
25    };
26    Themify = {
27        events:new Map,
28        cssLazy:new Map,
29        jsLazy:new Map,
30        fontsQueue:new Set,
31        device: 'desktop',
32        lazyScrolling: null,
33        observer: null,
34        triggerEvent(el, type, params,isNotCustom) {
35            let ev;
36            if (isNotCustom===true || type === 'click' || type === 'submit' || type === 'input' || type==='resize' || (type === 'change' && !params) || type.indexOf('pointer') === 0 || type.indexOf('touch') === 0 || type.indexOf('mouse') === 0) {
37                if (!params) {
38                    params = {};
39                }
40                if (params.bubbles === und) {
41                    params.bubbles = true;
42                }
43                if (params.cancelable === und) {
44                    params.cancelable = true;
45                }
46                ev = (type==='click' || type.indexOf('pointer') === 0)?new PointerEvent(type, params):(type.indexOf('mouse') === 0?new MouseEvent(type, params):new Event(type, params));
47                Object.defineProperty(ev, 'target', {value: params.target || el, enumerable: true});
48            } else {
49                ev = new win.CustomEvent(type, {detail: params});
50            }
51            el.dispatchEvent(ev);
52            return this;
53        },
54        on(ev, f, once,check) {
55            if(check===true){
56                f();
57                if(once===true){
58                    return this;
59                }
60            }
61            ev = ev.split(' ');
62            const len = ev.length;
63            for (let i = len-1; i>-1;--i) {
64                let events=this.events.get(ev[i]) || new Map;
65                events.set(f,!!once);
66                this.events.set(ev[i],events);
67            }
68            return this;
69        },
70        off(ev, f) {
71            const items=this.events.get(ev);
72            if(items!==und){
73                if(f){
74                    items.delete(f);
75                    if(items.size===0){
76                        this.events.delete(ev);
77                    }
78                }
79                else{
80                    this.events.delete(ev);
81                }
82            }
83            return this;
84        },
85        trigger(ev, args) {
86            const items = this.events.get(ev),
87                proms=[];
88            if (items !== und) {
89                if(args!==und){
90                    if(!Array.isArray(args)){
91                        args=[args];
92                    }
93                }
94                for(let [f,once] of items){
95                    try{
96                        let pr=f.apply(null, args);
97                        if(pr!==und && pr instanceof Promise){
98                            proms.push(pr);
99                        }
100                    }
101                    catch(e){
102                        console.error(e);
103                    }
104                    if(once===true){
105                        items.delete(f);
106                    }
107                }
108                if(items.size===0){
109                    this.events.delete(ev);
110                }
111            }
112            if(proms.length===0 && args!==und){
113                proms.push(Promise.resolve(args));
114            }
115            return Promise.all(proms);
116        },
117        requestIdleCallback(callback, timeout,timer2) {
118            if (win.requestIdleCallback) {
119                win.requestIdleCallback(callback, {timeout: timeout});
120            } else {
121                timeout=timer2>0?timer2:(timeout<0?2500:timeout);
122                setTimeout(callback, timeout);
123            }
124        },
125        parseVideo(url) {
126            const m = url.match(/(http:|https:|)\/\/(player.|www.)?(vimeo\.com|youtu(be\.com|\.be|be\.googleapis\.com))\/(video\/|embed\/|watch\?v=|v\/)?([A-Za-z0-9._%-]*)(\&\S+)?\/?([A-Za-z0-9._%-]*)(\&\S+)?/i),
127                attrs = {
128                    type: m !== null ? (m[3].includes('youtu') ? 'youtube' : (m[3].includes('vimeo') ? 'vimeo' : false)) : false,
129                    id: m !== null ? m[6] : false
130                };
131            if('vimeo' === attrs.type && m[8]){
132                attrs.h = m[8];
133            }
134            return attrs;
135        },
136        hash(s) {
137            let hash = 0;
138            for (let i = s.length - 1; i > -1; --i) {
139                hash = ((hash << 5) - hash) + s.charCodeAt(i);
140                hash = hash & hash; // Convert to 32bit integer
141            }
142            return hash;
143        },
144        scrollTo(val, speed, complete, progress) {
145            if (!speed) {
146                speed = 800;
147            }
148            if (!val) {
149                val = 0;
150            }
151            const doc = jQuery('html,body'),
152                hasScroll = doc.css('scroll-behavior') === 'smooth';
153            if (hasScroll) {
154                doc.css('scroll-behavior', 'auto');
155            }
156            doc.stop().animate({
157                scrollTop: val
158            }, {
159                progress: progress,
160                duration: speed,
161                done() {
162                    if (hasScroll) {
163                        doc.css('scroll-behavior', '');
164                    }
165                    if (complete) {
166                        complete();
167                    }
168                }
169            });
170        },
171        imagesLoad(items) {
172            return new Promise(resolve=>{
173                if (items !== null) {
174                    if (items.length === und) {
175                        items = [items];
176                    }
177                    const prms=[];
178                    for(let i=items.length-1;i>-1;--i){
179                        let images=items[i].tagName==='IMG'?[items[i]]:items[i].tfTag('img');
180                        for(let j=images.legnth-1;j>-1;--j){
181                            if(!images[j].complete){
182                                let elem=images[j];
183                                prms.push(new Promise((resolve, reject) => {
184                                    elem.onload = resolve;
185                                    elem.onerror = reject;
186                                    elem=null;
187                                }));
188                            }
189                        }
190                    }
191                    Promise.all(prms).finally(()=>{
192                        resolve(items[0]);
193                    });
194                }
195                else{
196                    resolve();
197                }
198            });
199        },
200        updateQueryString(d,a,b){
201            b||(b=win.location.href);const e=new URL(b,win.location),f=e.searchParams;null===a?f.delete(d):f.set(d,a);let g=f.toString();return''!==g&&(g='?'+g),b.split('?')[0]+g+e.hash;
202        },
203        selectWithParent(selector, el) {
204            let items = null;
205            const isCl = !selector.includes('.') && !selector.includes('['),
206                isTag = isCl === true && (selector === 'video' || selector === 'audio' || selector === 'img');
207            if (el && el[0] !== und) {
208                el = el[0];
209            }
210            if (el) {
211                items = isCl === false ? el.querySelectorAll(selector) : (isTag === true ? el.tfTag(selector) : el.tfClass(selector));
212                if ((isCl === true && el.classList.contains(selector)) || (isCl === false && el.matches(selector)) || (isTag === true && el.tagName.toLowerCase() === selector)) {
213                    items = this.convert(items, el);
214                }
215            } else {
216                items = isCl === false ? doc.querySelectorAll(selector) : (isTag === true ? doc.tfTag(selector) : doc.tfClass(selector));
217            }
218            return items;
219        },
220        convert(items, el) {
221            let l = items.length;
222            const arr = new Array(l);
223            while (l--) {
224                arr[l] = items[l];
225            }
226            if (el) {
227                arr.push(el);
228            }
229            return arr;
230        },
231        init() {
232            this.is_builder_active = doc.body.classList.contains('themify_builder_active');
233            const windowLoad = ()=>{
234                this.body = jQuery('body');
235                this.w = win.innerWidth;
236                this.h = win.innerHeight;
237                this.isRTL = doc.body.classList.contains('rtl');
238                this.isTouch = !!(('ontouchstart' in win) || navigator.msMaxTouchPoints > 0);
239                this.lazyDisable = this.is_builder_active === true || doc.body.classList.contains('tf_lazy_disable');
240                this.click=this.isTouch?'pointerdown':'click';
241                if (this.isTouch) {
242                    const ori = screen.orientation?.angle!==und? screen.orientation.angle : win.orientation,
243                        w = ori === 90 || ori === -90 ? this.h : this.w;
244                    if (w < 769) {
245                        this.device = w < 681 ? 'mobile' : 'tablet';
246                    }
247                }
248                requestAnimationFrame(()=>{
249                    if(this.urlArgs!==null){
250                        this.urlArgs='&'+(new URLSearchParams({media:this.urlArgs})).toString();
251                    }
252                    this.cssUrl = this.url + 'css/modules/';
253                    this.builder_url=vars.theme_v?(this.url+'themify-builder/'):this.url.substring(0,this.url.slice(0, -1).lastIndexOf('/') + 1);
254
255                    if (vars.done !== und) {
256                        this.cssLazy = new Map(Object.entries(vars.done));
257                    }
258                    this.requestIdleCallback(()=> {this.mobileMenu();},40);
259                    this.trigger('tf_init');
260                    win.loaded = true;
261                    if (!vars.is_admin) {
262                        if (vars.theme_v) {
263                            vars.theme_url=this.url.split('/').slice(0,-2).join('/');
264                            this.loadJs(vars.theme_url+'/js/themify.script', null, vars.theme_v);
265                        }
266                        if (this.is_builder_active === false) {
267                            const prms=win.tbLocalScript && doc.tfClass('module_row')[0]?this.loadJs(this.builder_url+'js/themify.builder.script'):Promise.resolve();
268                            prms.then(()=>{
269                                this.lazyLoading();
270                            });
271                            this.requestIdleCallback(()=> {this.commonJs();},-1);
272                            this.requestIdleCallback(()=> {this.tooltips();},110);
273                        }
274                        this.requestIdleCallback(()=> {this.wc();},50);
275                        this.requestIdleCallback(()=> {this.touchDropDown();},60);
276                        setTimeout(()=>{
277                            this.requestIdleCallback(()=> {this.gallery();},100);
278                        }, 800);
279                    }
280                    this.requestIdleCallback(()=> {this.resizer();},-1,2000);
281                });
282            };
283            const sc=doc.currentScript,
284                url=new URL(sc.src,win.location.origin);
285            this.is_min = url.href.includes('.min.js');
286            this.v=url.searchParams.get('ver') || sc.dataset.v;
287            this.urlArgs=url.searchParams.get('media') || null;//need for cdn
288            this.urlHost=url.hostname;
289            this.url = url.href.split('js/main.')[0].trim();
290            this.includesURL=url.origin+'/wp-includes/';
291            this.cdnPlugin=sc.dataset.plHref.split('?')[0].replace('/fake.css','');
292            if (doc.readyState === 'complete' || this.is_builder_active === true) {
293                this.requestIdleCallback(windowLoad,50);
294            } else {
295                win.tfOn('load', windowLoad, {once: true, passive: true});
296            }
297            /* add lightboxed class when site is displayed in iframe (excluding Customizer) */
298            if ( win.self !== win.top && typeof win.wp?.customize === und ) {
299                doc.body.className += ' lightboxed';
300            }
301        },
302        async initComponents(el, isLazy) {
303            if (isLazy === true && el.tagName === 'IMG') {
304                return;
305            }
306            let items;
307            const loading={VIDEO:'video',AUDIO:'audio',auto_tiles:'autoTiles',tf_carousel:'carousel',themify_map:'map','[data-lax]':'lax',masonry:'isotop',tf_search_form:'ajaxSearch',tf_sticky_form_wrap:'stickyBuy'},
308                prms=[];
309            for(let cl in loading){
310                items=null;
311                if (isLazy === true) {
312                    if(cl==='tf_sticky_form_wrap'){
313                        if(el.id===cl){
314                            items = [el];
315                        }
316                    }
317                    else if(cl==='[data-lax]'){
318                        if(el.hasAttribute('data-lax')){
319                            items = [el];
320                        }
321                    }
322                    else if (el.tagName === cl || el.classList.contains(cl) || (cl==='tf_search_form' && el.classList.contains('tf_search_icon'))) {
323                        items = [el];
324                    }
325                } else {
326                    items = this.selectWithParent(cl.toLowerCase(), el);
327                }
328                if (items?.length > 0) {
329                    prms.push(this[loading[cl]](items));
330                }
331            }
332            items=null;
333            if (isLazy === true) {
334                if (el.classList.contains('wp-embedded-content')) {
335                    items = [el];
336                } else {
337                    prms.push(this.wpEmbed(el.tfClass('wp-embedded-content')));
338                }
339            } else {
340                items = this.selectWithParent('wp-embedded-content', el);
341            }
342            if (items?.length > 0) {
343                prms.push(this.wpEmbed(items));
344            }
345            items=null;
346            this.largeImages(el);
347            return Promise.all(prms);
348        },
349        fixedHeader(options) {
350            if (!this.is_builder_active) {
351                return new Promise((resolve,reject)=>{
352                    this.loadJs('fixedheader').then(()=>{
353                        this.requestIdleCallback(()=> {
354                            this.trigger('tf_fixed_header_init', options);
355                            resolve();
356                        },50);
357                    })
358                        .catch(reject);
359                });
360            }
361        },
362        async lax(items, is_live) {
363            if ((is_live === true || !this.is_builder_active) && items.length>0) {
364                await this.loadJs('lax');
365                this.trigger('tf_lax_init', [items]);
366            }
367        },
368        async video(items) {
369            if (items?.length>0) {
370                for(let i=items.length-1;i>-1;--i){
371                    let src=items[i].dataset.poster;
372                    if(src){
373                        let img=new Image();
374                        img.src=src;
375                        img.decode()
376                            .catch(()=>{})
377                            .finally(()=>{
378                                items[i].poster=src;
379                            });
380                        items[i].removeAttribute('data-poster');
381                    }
382                }
383                await this.loadJs('video-player');
384                this.trigger('tf_video_init', [items]);
385            }
386        },
387        async audio(items, options) {
388            if (items?.length>0) {
389                await Promise.all([this.loadCss('audio','tf_audio'),this.loadJs('audio-player')]);
390                this.trigger('tf_audio_init', [items, options]);
391            }
392        },
393        async sideMenu(items, options) {
394            if (items && (items.length>0 || items.length===und)) {
395                await this.loadJs('themify.sidemenu');
396                this.trigger('tf_sidemenu_init', [items, options]);
397            }
398        },
399        async edgeMenu(menu) {
400            if(doc.tfClass('sub-menu')[0]!==und){
401                await this.loadJs('edge.Menu');
402                this.trigger('tf_edge_init', menu);
403            }
404        },
405        async sharer(type, url, title) {
406            await this.loadJs('sharer');
407            this.trigger('tf_sharer_init', [type, url, title]);
408        },
409        async autoTiles(items) {
410            await this.loadJs('autoTiles');
411            this.trigger('tf_autotiles_init', [items]);
412        },
413        async map(items) {
414            await this.loadJs('map');
415            this.trigger('tf_map_init', [items]);
416        },
417        async carousel(items, options) {
418            if (items) {
419                await this.loadJs('themify.carousel');
420                this.trigger('tf_carousel_init', [items, options]);
421            }
422        },
423        async infinity(container, options) {
424            if (!container || container.length === 0 || this.is_builder_active === true || (!options.button && options.hasOwnProperty('button')) || (options.path && typeof options.path === 'string' && doc.querySelector(options.path) === null)) {
425                return;
426            }
427            // there are no elements to apply the Infinite effect on
428            if (options.append && doc.querySelector(options.append)===null) {
429                // show the Load More button, just in case.
430                if (options.button) {
431                    options.button.style.display = 'block';
432                }
433                return;
434            }
435            await this.loadJs('infinite');
436            this.trigger('tf_infinite_init', [container, options]);
437        },
438        async isotop(items, options) {
439            if (items.length === und) {
440                items = [items];
441            }
442            const res = [];
443            for (let i = items.length - 1; i > -1; --i) {
444                let cl = items[i].classList;
445                if (!cl.contains('masonry-done') && (!cl.contains('auto_tiles') || !cl.contains('list-post') || !items[i].previousElementSibling || items[i].previousElementSibling.classList.contains('post-filter'))) {
446                    res.push(items[i]);
447                }
448            }
449            if (res.length > 0) {
450                await Promise.all([
451                    this.loadJs('jquery.isotope.min',typeof jQuery.fn.packery !== 'undefined','3.0.6'),
452                    this.loadJs('isotop')
453                ]);
454                this.trigger('tf_isotop_init', [res, options]);
455            }
456        },
457        fonts(icons) {
458            return new Promise((resolve,reject)=>{
459                if (icons) {
460                    if (typeof icons === 'string') {
461                        icons = [icons];
462                    } else if (!Array.isArray(icons)) {
463                        if (icons instanceof jQuery) {
464                            icons = icons[0];
465                        }
466                        icons = this.selectWithParent('tf_fa', icons);
467                    }
468                } else {
469                    icons = doc.tfClass('tf_fa');
470                }
471                const Loaded = new Set,
472                    needToLoad = [],
473                    parents = [],
474                    svg = doc.tfId('tf_svg').firstChild,
475                    loadedIcons = svg.tfTag('symbol');
476                for (let i = loadedIcons.length - 1; i > -1; --i) {
477                    Loaded.add(loadedIcons[i].id);
478                    Loaded.add(loadedIcons[i].id.replace('tf-',''));
479                }
480                for (let i = icons.length - 1; i > -1; --i) {
481                    if(icons[i].tagName!==und && icons[i].tagName!=='svg'){
482                        continue;
483                    }
484                    let id = icons[i].classList?.[1] || icons[i];
485                    if (id && !Loaded.has(id)) {
486                        if (!this.fontsQueue.has(id)) {
487                            this.fontsQueue.add(id);
488                            let tmp = id.replace('tf-', ''),
489                                tmp2 = tmp.split('-');
490                            if (tmp2[0] === 'fas' || tmp2[0] === 'far' || tmp2[0] === 'fab') {
491                                let pre = tmp2[0];
492                                tmp2.shift();
493                                tmp = pre + ' ' + tmp2.join('-');
494                            }
495                            needToLoad.push(tmp);
496                        }
497                        if (icons[i].classList) {
498                            let p = icons[i].parentNode;
499                            p.classList.add('tf_lazy');
500                            parents.push(p);
501                        }
502                    }
503                }
504                if (needToLoad.length > 0) {
505                    const time = this.is_builder_active ? 5 : 2000;
506       
506             setTimeout( ()=>{
507                        this.fetch({action: 'tf_load_icons',icons: JSON.stringify(needToLoad)},null,{credentials:'omit'}).then(res => {
508                            const fr = doc.createDocumentFragment(),
509                                ns = 'http://www.w3.org/2000/svg',
510                                st = [];
511                            for (let i in res) {
512                                let s = doc.createElementNS(ns, 'symbol'),
513                                    p = doc.createElementNS(ns, 'path'),
514                                    k = 'tf-' + i.replace(' ', '-'),
515                                    viewBox = '0 0 ';
516                                viewBox += res[i].vw!==und && res[i].vw!==''?res[i].vw:'32';
517                                viewBox +=' ';
518                                viewBox +=res[i].vh!==und && res[i].vh!==''?res[i].vh:'32';
519                                s.id = k;
520                                s.setAttributeNS(null, 'viewBox', viewBox);
521                                p.setAttributeNS(null, 'd', res[i].p);
522                                s.appendChild(p);
523                                fr.appendChild(s);
524                                if (res[i].w) {
525                                    st.push('.tf_fa.' + k + '{width:' + res[i].w + 'em}');
526                                }
527                            }
528                            svg.appendChild(fr);
529                            if (st.length > 0) {
530                                let css = doc.tfId('tf_fonts_style');
531                                if (css === null) {
532                                    css = doc.createElement('style');
533                                    css.id = 'tf_fonts_style';
534                                    svg.appendChild(css);
535                                }
536                                css.textContent += st.join('');
537                            }
538                            this.fontsQueue.clear();
539                            for (let i = parents.length - 1; i > -1; --i) {
540                                if (parents[i]) {
541                                    parents[i].classList.remove('tf_lazy');
542                                }
543                            }
544                            resolve();
545                        }).catch(reject);
546                    }, time);
547                }
548                else{
549                    resolve();
550                }
551            });
552        },
553        commonJs() {
554            return new Promise((resolve,reject)=>{
555                if(doc.tfTag('tf-lottie')[0]){
556                    this.loadJs('lottie',!!win.TF_Lottie);
557                }
558                this.requestIdleCallback(()=> {
559                    this.fonts().then(resolve).catch(reject);
560                }, 200);
561                if (vars.commentUrl) {
562                    this.requestIdleCallback(()=> {
563                        if (!win.addComment && vars.commentUrl && doc.tfId('cancel-comment-reply-link')) {
564                            this.loadJs('comments');
565                        }
566                    }, -1,3000);
567                }
568                if (vars.wp_emoji) {
569                    this.requestIdleCallback(()=> {
570                        const emoji = doc.createElement('script');
571                        emoji.text = vars.wp_emoji;
572                        requestAnimationFrame(()=>{
573                            doc.head.appendChild(emoji);
574                            win._wpemojiSettings.DOMReady = true;
575                        });
576                        vars.wp_emoji = null;
577                    }, -1,4000);
578                }
579            });
580        },
581        loadJs(src, test, version, async) {
582            const origSrc=src;
583            let pr=this.jsLazy.get(origSrc);
584            if(pr===und){
585                pr=new Promise((resolve,reject)=>{
586                    if(test===true){
587                        requestAnimationFrame(resolve);
588                        return;
589                    }
590                    if(vars.plugin_url!==this.cdnPlugin && src.indexOf(vars.plugin_url)===0){
591                        src=src.replace(vars.plugin_url,this.cdnPlugin);
592                    }
593                    const isLocal=src.includes(this.urlHost) || origSrc.includes(this.urlHost),
594                        s = doc.createElement('script');
595                    if(isLocal===true || (!src.includes('http') && src.indexOf('//')!==0)){
596                        if(!src.includes('.js')){
597                            src+='.js';
598                        }
599                        if (version !== false){
600                            if(isLocal===false){
601                                src=this.url+'js/modules/'+src;
602                            }
603                            if (this.is_min === true && !src.includes('.min.js')) {
604                                src = src.replace(this.urlHost,"$D$").replace('.js', '.min.js').replace("$D$",this.urlHost);
605                            }
606                            if (!src.includes('ver=')) {
607                                if(!version){
608                                    version = this.v;
609                                }
610                                src+='?ver=' + version;
611                            }
612                            if(this.urlArgs!==null){
613                                src+=this.urlArgs;
614                            }
615                        }
616                    }
617                    s.async=async!==false;
618                    s.tfOn('load', ()=> {
619                        requestAnimationFrame(resolve);
620                    }, {passive: true, once: true})
621                        .tfOn('error', reject, {passive: true, once: true});
622                    s.src=src;
623                    requestAnimationFrame(()=>{
624                        doc.head.appendChild(s);
625                    });
626                });
627                this.jsLazy.set(origSrc,pr);
628            }
629            return pr;
630        },
631        loadCss(href,id, version, before, media) {
632            if(!id){
633                id = 'tf_'+this.hash(href);
634            }
635            let prms=this.cssLazy.get(id);
636            if (prms===und) {
637                prms=new Promise((resolve,reject)=>{
638                    const d=before?before.getRootNode():doc,
639                        orighref=href,
640                        el = d.tfId(id);
641                    if(el!==null && el.media!== 'print'){
642                        resolve();
643                        return;
644                    }
645                    if(vars.plugin_url!==this.cdnPlugin && href.indexOf(vars.plugin_url)===0){
646                        href=href.replace(vars.plugin_url,this.cdnPlugin);
647                    }
648                    const ss = doc.createElement('link'),
649                        onload = function () {
650                            if (!media) {
651                                media = 'all';
652                            }
653                            this.media=media;
654                            const key = this.id,
655                                checkApply = ()=>{
656                                    const sheets = this.getRootNode().styleSheets;
657                                    let found = false;
658                                    for (let i = sheets.length - 1; i > -1; --i) {
659                                        if (sheets[i].ownerNode!==null && sheets[i].ownerNode.id === key) {
660                                            found = true;
661                                            break;
662                                        }
663                                    }
664                                    if (found === true) {
665                                        resolve();
666                                    }
667                                    else {
668                                        requestAnimationFrame(()=>{
669                                            checkApply();
670                                        });
671                                    }
672                                };
673                            requestAnimationFrame(()=>{
674                                checkApply();
675                            });
676                        },
677                        isLocal=href.includes(this.urlHost)  || orighref.includes(this.urlHost);
678                    if(isLocal===true || (!href.includes('http') && href.indexOf('//')!==0)){
679                        if(!href.includes('.css')){
680                            href+='.css';
681                        }
682                        if(version !== false){
683                            if(isLocal===false){
684                                href=this.url+'css/modules/'+href;
685                            }
686                            if (this.is_min === true && !href.includes('.min.css')) {
687                                href = href.replace(this.urlHost,"$D$").replace('.css', '.min.css').replace("$D$",this.urlHost);
688                            }
689                            if (!href.includes('ver=')) {
690                                if(!version){
691                                    version = this.v;
692                                }
693                                href+='?ver=' + version;
694                            }
695                            if(this.urlArgs!==null){
696                                href+=this.urlArgs;
697                            }
698                        }
699                    }
700                    ss.rel='stylesheet';
701                    ss.media='print';
702                    ss.id=id;
703                    ss.href=href;
704                    ss.setAttribute('fetchpriority', 'low');
705                    if ('isApplicationInstalled' in navigator) {
706                        ss.onloadcssdefined(onload);
707                    } else {
708                        ss.tfOn('load', onload, {passive: true, once: true});
709                    }
710                    ss.tfOn('error', reject, {passive: true, once: true});
711                    let ref = before;
712                    requestAnimationFrame(()=>{
713                        if (!ref?.parentNode) {
714                            ref = doc.tfId('tf_lazy_common')?.nextSibling || doc.head.firstElementChild;
715                        }
716                        ref.parentNode.insertBefore(ss, (before ? ref : ref.nextSibling));
717                    });
718                });
719                this.cssLazy.set(id,prms);
720            }
721            else if(prms===true){
722                prms=Promise.resolve();
723                this.cssLazy.set(id,prms);
724            }
725            else if(before?.getRootNode().tfId(id)===null){//maybe it's shadow root,need to recheck
726                this.cssLazy.delete(id);
727                return this.loadCss(href,id, version, before, media);
728            }
729            return prms;
730        },
731        gallery() {
732            const lbox = this.is_builder_active === false && vars.lightbox ? vars.lightbox : false;
733            if (lbox !== false && lbox.lightboxOn !== false && !this.jsLazy.has('tf_gal')) {
734                this.jsLazy.set('tf_gal',true);
735                let isWorking = false;
736                const hash = win.location.hash.replace('#', ''),
737                    args = {
738                        extraLightboxArgs: vars.extraLightboxArgs,
739                        lightboxSelector: lbox.lightboxSelector || '.themify_lightbox',
740                        gallerySelector: lbox.gallerySelector || '.gallery-item a',
741                        contentImagesAreas: lbox.contentImagesAreas,
742                        i18n: lbox.i18n || [],
743                        disableSharing:lbox.disable_sharing
744                    },
745                    isImg =  url=>{
746                        return url?url.match(/\.(gif|jpg|jpeg|tiff|png|webp|apng)(\?fit=\d+(,|%2C)\d+)?(\&ssl=\d+)?$/i):null;
747                    },
748                    openLightbox = el=> {
749                        if (isWorking === true) {
750                            return;
751                        }
752                        doc.tfOff('click',globalClick);
753                        isWorking = true;
754                        const link = el.getAttribute('href'),
755                            loaderP = doc.createElement('div'),
756                            loaderC = doc.createElement('div');
757                        loaderP.className = 'tf_lazy_lightbox tf_w tf_h';
758                        if (isImg(link)) {
759                            loaderP.textContent = 'Loading...';
760                            const img = new Image();
761                            img.decoding = 'async';
762                            img.src = link;
763                            img.decode();
764                        } else {
765                            loaderC.className = 'tf_lazy tf_w tf_h';
766                            loaderP.appendChild(loaderC);
767                        }
768                        doc.body.appendChild(loaderP);
769
770                        Promise.all([
771                            this.loadCss('lightbox','tf_lightbox'),
772                            this.loadJs('lightbox.min','undefined' !== typeof jQuery.fn.magnificPopup),
773                            this.loadJs('themify.gallery')
774                        ])
775                            .then(()=>{
776                                this.trigger('tf_gallery_init', args);
777                                el.click();
778                            }).
779                        finally(()=>{
780                            loaderP.remove();
781                        });
782                    },
783                    globalClick=e=>{
784                        const el=e.target?e.target.closest('a'):null;
785                        if(el){
786                            const galSel=args.gallerySelector,
787                                contentSel=args.contentImagesAreas,
788                                lbSel=args.lightboxSelector;
789                            if(el.closest(lbSel) || (isImg(el.getAttribute('href')) && ((contentSel && el.closest(contentSel)) || (galSel && (el.matches(galSel) || el.closest(galSel)) && !el.closest('.module-gallery'))))){
790                                e.preventDefault();
791                                e.stopImmediatePropagation();
792                                openLightbox(el);
793                            }
794                        }
795                    };
796                doc.tfOn('click',globalClick);
797                if (hash && hash !== '#') {
798                    const h=decodeURI(hash);
799                    let item = doc.querySelector('img[alt="' + h + '"],img[title="' + h + '"]');
800                    if (item) {
801                        item = item.closest('.themify_lightbox');
802                        if (item) {
803                            openLightbox(item);
804                        }
805                    }
806                }
807            }
808        },
809        lazyLoading(parent) {
810            if (this.lazyDisable === true) {
811                return;
812            }
813            if (!parent) {
814                parent = doc;
815            }
816            const items = (parent instanceof Document || parent instanceof HTMLElement) ? parent.querySelectorAll('[data-lazy]') : parent,
817                len = items.length;
818            if (len > 0) {
819                const lazy =  (entries, _self, init)=>{
820                    for (let i = entries.length - 1; i > -1; --i) {
821                        if (this.lazyScrolling === null && entries[i].isIntersecting === true) {
822                            _self.unobserve(entries[i].target);
823                            requestAnimationFrame(()=> {
824                                this.lazyScroll([entries[i].target], init);
825                            });
826                        }
827                    }
828                };
829                let observerInit;
830                if (this.observer === null) {
831                    observerInit = new IntersectionObserver((entries, _self)=>{
832                        lazy(entries, _self, true);
833                        _self.disconnect();
834                        let intersect2 = false;
835                        const ev = this.isTouch ? 'touchstart' : 'mousemove',
836                            oneScroll = ()=> {//pre cache after one scroll/mousemove
837                                if (intersect2) {
838                                    intersect2.disconnect();
839                                }
840                                intersect2 = null;
841                                win.tfOff('scroll '+ev, oneScroll, {once: true, passive: true});
842                                this.observer = new IntersectionObserver((entries, _self)=> {
843                                    lazy(entries, _self);
844                                }, {
845                                    rootMargin: '300px 0px'
846                                });
847                                let j = 0;
848                                const prefetched = new Set;
849                                for (let i = 0; i < len; ++i) {
850                                    let item=items[i];
851                                    if (item.hasAttribute('data-lazy') && !item.hasAttribute('data-tf-not-load')) {
852                                        this.observer.observe(item);
853                                        if (j < 10 && item.hasAttribute('data-tf-src') && item.hasAttribute('data-lazy')) {
854                                            let src = item.getAttribute('data-tf-src');
855                                            if (src && !prefetched.has(src)) {
856                                                prefetched.add(src);
857                                                let img = new Image(),
858                                                    srcset=item.getAttribute('data-tf-srcset');
859                                                img.decoding = 'async';
860                                                if(srcset){
861                                                    img.srcset = srcset;
862                                                }
863                                                img.src = src;
864                                                img.decode();
865                                                ++j;
866                                            }
867                                        }
868                                    }
869                                }
870                                if (doc.tfClass('wow')[0]) {
871                                    this.requestIdleCallback(()=> {
872                                        this.wow();
873                                    }, 1500);
874                                }
875                                prefetched.clear();
876                            };
877                        win.tfOn('beforeprint', ()=> {
878                            this.lazyScroll(doc.querySelectorAll('[data-lazy]'), true);
879                        }, {passive: true})
880                            .tfOn('scroll '+ev, oneScroll, {once: true, passive: true});
881
882                        setTimeout(()=>{
883                            if (intersect2 === false) {
884                                intersect2 = new IntersectionObserver((entries, _self)=>{
885                                    if (intersect2 !== null) {
886                                        lazy(entries, _self, true);
887                                    }
888                                    _self.disconnect();
889                                });
890                                const len2 = len > 15 ? 15 : len;
891                                for (let i = 0; i < len2; ++i) {
892                                    let item=items[i];
893                                    if (item && item.hasAttribute('data-lazy') && !item.hasAttribute('data-tf-not-load')) {
894                                        intersect2.observe(item);
895                                    }
896                                }
897                            }
898                        }, 1600);
899                    });
900                } else {
901                    observerInit = this.observer;
902                }
903                if (observerInit) {
904                    for (let i = 0; i < len; ++i) {
905                        if (!items[i].hasAttribute('data-tf-not-load')) {
906                            observerInit.observe(items[i]);
907                        }
908                    }
909                }
910            }
911        },
912        async lazyScroll(items, init) {
913            let len = 0;
914            if (items) {
915                len = items.length;
916                if (len === und) {
917                    items = [items];
918                    len = 1;
919                }
920                else if (len === 0) {
921                    return;
922                }
923            }
924            const svg_callback = function () {
925                    this.classList.remove('tf_svg_lazy_loaded', 'tf_svg_lazy');
926                },
927                prms=[];
928            for (let i = len - 1; i > -1; --i) {
929                let el = items[i],
930                    tagName = el.tagName;
931                if (!el?.hasAttribute('data-lazy')) {
932                    el?.removeAttribute('data-lazy');
933                }
934                else {
935                    el.removeAttribute('data-lazy');
936                    if (tagName !== 'IMG' && (tagName === 'DIV' || !el.hasAttribute('data-tf-src'))) {
937                        try {
938                            if(tagName!=='TF-LOTTIE'){
939                                el.classList.remove('tf_lazy');
940                            }
941                            prms.push(this.reRun(el, true));
942                            prms.push(this.trigger('tf_lazy', el));
943                        } catch (e) {
944                            console.log(e);
945                        }
946                    }
947                    else if (tagName !== 'svg') {
948                        let src = el.dataset.tfSrc,
949                            srcset = el.dataset.tfSrcset,
950                            sizes = srcset?el.dataset.tfSizes:null;
951                        if(src || srcset){
952                            if(tagName==='IMG'){
953                                let img=new Image(),
954                                    attr=el.attributes;
955                                for(let j=attr.length-1;j>-1;--j){
956                                    let n=attr[j].name;
957                                    if(n!=='src' && n!=='srcset' && n!=='sizes' && n!=='loading' && !n.includes('data-tf')){
958                                        img.setAttribute(n,attr[j].value);
959                                    }
960                                }
961                                img.decoding='async';
962                                if (srcset) {
963                                    if (sizes) {
964                                        img.setAttribute('sizes', sizes);
965                                    }
966                                    img.srcset=srcset;
967                                }
968                                if (src) {
969                                    img.src=src;
970                                }
971                                let p= new Promise(resolve=>{
972                                    img.decode()
973                                        .catch(()=>{})//need for svg
974                                        .finally(()=>{
975                                            requestAnimationFrame(()=>{
976                                                el.replaceWith(img);
977                                                if(img.classList.contains('tf_svg_lazy')){
978                                                    img.tfOn('transitionend', svg_callback, {once: true, passive: true});
979                                                    requestAnimationFrame(()=>{
980                                                        img.classList.add('tf_svg_lazy_loaded');
981                                                    });
982                                                }
983                                                resolve();
984                                            });
985                                        });
986                                });
987                                prms.push(p);
988                            }
989                            else{
990                                if (src) {
991                                    el.src=src;
992                                    el.removeAttribute('data-tf-src');
993                                }
994                                el.removeAttribute('loading');
995                                if(init !== true && el.parentNode !== doc.body){
996                                    el.parentNode.classList.add('tf_lazy');
997                                    let p=this.imagesLoad(el).then(item=>{
998                                        item.parentNode.classList.remove('tf_lazy');
999                                    });
1000                                    prms.push(p);
1001                                }
1002                                this.largeImages();
1003                            }
1004                        }
1005                    }
1006                }
1007                if (this.observer !== null && el) {
1008                    this.observer.unobserve(el);
1009                }
1010            }
1011            return Promise.all(prms).catch(()=>{});
1012        },
1013        async reRun(el, isLazy) {
1014            if (isLazy !== true) {
1015                this.commonJs();
1016            }
1017            if(vars && !vars.is_admin){
1018                const isBuilder=this.is_builder_loaded===true || typeof ThemifyBuilderModuleJs !== 'undefined',
1019                    pr=[];
1020                if(isBuilder===true || (win.tbLocalScript && doc.tfClass('module_row')[0]!==und)){
1021                    if(isBuilder===false){
1022                        await this.loadJs(this.builder_url+'js/themify.builder.script',typeof ThemifyBuilderModuleJs !== 'undefined');
1023                    }
1024                    pr.push(ThemifyBuilderModuleJs.loadModules(el, isLazy));
1025                }
1026                pr.push(this.initComponents(el, isLazy));
1027                return Promise.all(pr);
1028            }
1029        },
1030        animateCss() {
1031            return this.loadCss('animate.min','animate');
1032        },
1033        wow() {
1034            return Promise.all([this.animateCss(),this.loadJs('tf_wow')]);
1035        },
1036        async dropDown(items, load_stylesheet) {
1037            if (items?.length>0) {
1038                const prms=[];
1039                if (load_stylesheet !== false) {
1040                    prms.push(this.loadCss('dropdown','tf_dropdown'));
1041                }
1042                prms.push(this.loadJs('themify.dropdown'));
1043                await Promise.all(prms);
1044                this.trigger('tf_dropdown_init', [items]);
1045            }
1046        },
1047        resizer() {
1048            let running = false,
1049                timeout,
1050                timer;
1051            const ev = 'onorientationchange' in win ? 'orientationchange' : 'resize';
1052            win.tfOn(ev, ()=> {
1053                if (running) {
1054                    return;
1055                }
1056                running = true;
1057                if (timeout) {
1058                    clearTimeout(timeout);
1059                }
1060                timeout = setTimeout(()=>{
1061                    if (timer) {
1062                        cancelAnimationFrame(timer);
1063                    }
1064                    timer = requestAnimationFrame(()=>{
1065                        const w = win.innerWidth,
1066                            h = win.innerHeight;
1067                        if (h !== this.h || w !== this.w) {
1068                            this.trigger('tfsmartresize', {w: w, h: h});
1069                            this.w = w;
1070                            this.h = h;
1071                        }
1072                        running = false;
1073                        timer = timeout = null;
1074                    });
1075                }, 150);
1076            }, {passive: true});
1077        },
1078        mobileMenu() {//deprecated
1079            if (vars.menu_point) {
1080                const w = parseInt(vars.menu_point),
1081                    _init = e=> {
1082                        const cl = doc.body.classList;
1083                        if ((!e && this.w <= w) || (e && e.w <= w)) {
1084                            cl.add('mobile_menu_active');
1085                        } else if (e !== und) {
1086                            cl.remove('mobile_menu_active');
1087                        }
1088                    };
1089                _init();
1090                this.on('tfsmartresize', _init);
1091            }
1092        },
1093        async wc(force) {
1094            if (vars.wc_js) {
1095                if (!vars.wc_js_normal) {
1096                    setTimeout(()=>{
1097                        doc.tfOn((this.isTouch ? 'touchstart' : 'mousemove'), ()=>{
1098                            const fr = doc.createDocumentFragment();
1099                            for (let i in vars.wc_js) {
1100                                let link = doc.createElement('link'),
1101                                    href = vars.wc_js[i];
1102                                if (!href.includes('ver', 12)) {
1103                                    href += '?ver=' + vars.wc_version;
1104                                }
1105                                link.as = 'script';
1106                                link.rel = 'prefetch';
1107                                link.href = href;
1108                                fr.appendChild(link);
1109                            }
1110                            doc.head.appendChild(fr);
1111                        }, {once: true, passive: true});
1112                    }, 1800);
1113                }
1114                await this.loadJs('wc');
1115                this.trigger('tf_wc_init', force);
1116            }
1117        },
1118        megaMenu(menu) {
1119            if (menu && !menu.dataset.init) {
1120                menu.dataset.init = true;
1121                const self = this,
1122                    maxW = 1 * vars.menu_point + 1,
1123                    removeDisplay = function (e) {
1124                        const el = e instanceof jQuery ? e : this,
1125                            w = e instanceof jQuery ? self.w : e.w;
1126                        if (w > maxW) {
1127                            el.css('display', '');
1128                        } else {
1129                            self.on('tfsmartresize', removeDisplay.bind(el), true);
1130                        }
1131                    },
1132                    closeDropdown = function (e) {
1133                        const el = e instanceof jQuery ? e : this;
1134                        if (e.target && !el[0].parentNode.contains(e.target)) {
1135                            el.css('display', '')
1136                                [0].parentNode.classList.remove('toggle-on');
1137                        } else {
1138                            doc.tfOn('touchstart', closeDropdown.bind(el), {once: true});
1139                        }
1140                    };
1141                if(this.cssLazy.has('tf_megamenu') && menu.tfClass('mega-link')[0]){
1142                    Promise.all([
1143                        this.loadCss(this.url+'megamenu/css/megamenu', 'tf_megamenu',null, null, 'screen and (min-width:' + maxW + 'px)'),
1144                        this.loadJs(this.url+'megamenu/js/themify.mega-menu')]
1145                    ).then(()=>{
1146                        this.trigger('tf_mega_menu', [menu, maxW]);
1147                    });
1148                }
1149                else{
1150                    this.requestIdleCallback( ()=>  {
1151                        this.edgeMenu();
1152                    },-1,2000);
1153                }
1154                menu.tfOn('click', function (e) {
1155                    const target=e.target;
1156                    if (!target.closest('.with-sub-arrow') && (target.classList.contains('child-arrow') || (target.tagName === 'A' && (!target.href || target.getAttribute('href') === '#' || target.parentNode.classList.contains('themify_toggle_dropdown'))))) {
1157                        let el = jQuery(e.target);
1158                        if (el[0].tagName === 'A') {
1159                            if (!el.find('.child-arrow')[0]) {
1160                                return;
1161                            }
1162                        } else {
1163                            el = el.parent();
1164                        }
1165                        e.preventDefault();
1166                        e.stopPropagation();
1167                        const li = el.parent();
1168                        let els = null;
1169                        if (und !== vars.m_m_toggle && !li.hasClass('toggle-on') && self.w < maxW) {
1170                            els = li.siblings('.toggle-on');
1171                            if(els.length===0){
1172                                els=null;
1173                            }
1174                        }
1175                        if (self.w < maxW || e.target.classList.contains('child-arrow') || el.find('.child-arrow:visible').length > 0) {
1176                            const items = el.next('div, ul'),
1177                                ist = items[0].style,
1178                                headerwrap = doc.tfId('headerwrap');
1179                            if (self.w < maxW && (ist === null || ist === '')) {
1180                                removeDisplay(items);
1181                            }
1182                            if (self.isTouch && !li.hasClass('toggle-on') && !doc.body.classList.contains('mobile-menu-visible') && (null === headerwrap || (headerwrap.offsetWidth >
1182 400))) {
1183                                closeDropdown(items);
1184                                li.siblings('.toggle-on').removeClass('toggle-on');
1185                            }
1186                            items.toggle('fast');
1187                            if (els) {
1188                                const slbs = els.find('>div,>ul'),
1189                                    sst = slbs[0].style;
1190                                if (self.w < maxW && (sst === null || sst === '')) {
1191                                    removeDisplay(slbs);
1192                                }
1193                                slbs.toggle('fast');
1194                            }
1195                        }
1196                        if (els) {
1197                            els.removeClass('toggle-on');
1198                        }
1199                        li.toggleClass('toggle-on');
1200                    }
1201                });
1202            }
1203        },
1204        touchDropDown() {
1205            const menus = doc.querySelectorAll('ul:not(.sub-menu)>.menu-item:first-child');
1206            for (let i = menus.length - 1; i > -1; --i) {
1207                let m = menus[i].parentNode,
1208                    p = m.parentNode;
1209                if (p.tagName !== 'LI' && !p.classList.contains('sub-menu')) {
1210                    this.megaMenu(m);
1211                }
1212            }
1213        },
1214        ajaxSearch(items) {
1215            if(this.is_builder_active===false){
1216                const __callback=e=>{
1217                    const el=e.currentTarget,
1218                        isOverlay=e.type==='click',
1219                        type=isOverlay?'overlay':'dropdown',
1220                        css=['search_form','search_form_ajax','search_form_' + type];
1221                    if(isOverlay){
1222                        e.preventDefault();
1223                        e.stopImmediatePropagation();
1224                    }
1225                    if(isOverlay && el.classList.contains('tf_search_icon')){
1226                        css.push('searchform_overlay');
1227                    }
1228                    const prms=[this.loadJs('ajax-search')];
1229                    for(let i=css.length-1;i>-1;--i){
1230                        let url='',
1231                            v=null;
1232                        if(css[i]==='searchform_overlay'){
1233                            v=vars.theme_v;
1234                            url=vars.theme_url+'/styles/modules/';
1235                        }
1236                        prms.push(this.loadCss(url+css[i].replaceAll('_','-'),null, v));
1237                    }
1238                    Promise.all(prms).finally(()=>{
1239                        this.trigger('themify_overlay_search_init', [el]);
1240                        this.triggerEvent(el, e.type);
1241                    });
1242                };
1243                for(let i=items.length-1;i>-1;--i){
1244                    if(items[i].hasAttribute('data-ajax') && items[i].dataset.ajax===''){
1245                        continue;
1246                    }
1247                    let isIcon=items[i].classList.contains('tf_search_icon'),
1248                        isOverlay= isIcon || items[i].classList.contains('tf_search_overlay'),
1249                        el,
1250                        ev;
1251                    if(isOverlay===false){
1252                        ev='focus';
1253                        el=items[i].querySelector('input[name="s"]');
1254                        el.autocomplete = 'off';
1255                    }
1256                    else{
1257                        ev='click';
1258                        el=isIcon?items[i]:items[i].tfClass('tf_search_icon')[0];
1259                    }
1260                    if(el){
1261                        el.tfOn(ev,__callback, {once: true,passive:!isOverlay});
1262                    }
1263                }
1264            }
1265        },
1266        async stickyBuy(el) {
1267            await Promise.all([this.loadCss('sticky-buy'),this.loadJs('sticky-buy')]);
1268            this.trigger('tf_sticky_buy_init', el);
1269        },
1270        async wpEmbed(items) {
1271            if (items.length === und) {
1272                items = [items];
1273            }
1274            if (items[0] !== und) {
1275                const embeds = [];
1276                for (let i = items.length - 1; i > -1; --i) {
1277                    if (items[i].tagName === 'IFRAME' && !items[i].dataset.done) {
1278                        items[i].dataset.done=1;
1279                        embeds.push(items[i]);
1280                    }
1281                }
1282                if (embeds[0] !== und) {
1283                    await this.loadJs(this.includesURL+'js/wp-embed.min.js',(!!win.wp && !!win.wp.receiveEmbedMessage),vars.wp);
1284                    for (let i = embeds.length - 1; i > -1; --i) {
1285                        let secret = embeds[i].dataset.secret;
1286                        if (!secret) {
1287                            secret = Math.random().toString(36).substr(2, 10);
1288                            embeds[i].setAttribute('data-secret', secret);
1289                        }
1290                        if (!embeds[i].hasAttribute('src')) {
1291                            embeds[i].src=embeds[i].dataset.tfSrc;
1292                        }
1293                        win.wp.receiveEmbedMessage({data: {message: 'height', value: this.h, secret: secret}, source: embeds[i].contentWindow});
1294                    }
1295                }
1296            }
1297        },
1298        largeImages(el){
1299            return new Promise( resolve=>{
1300                if((vars.lgi!==und || this.is_builder_active===true) && doc.querySelector('.tf_large_img:not(.tf_large_img_done)')){
1301                    this.requestIdleCallback(async()=>{
1302                        await this.loadJs('large-image-alert.min');
1303                        this.trigger('tf_large_images_init', el);
1304                        resolve();
1305                    },-1,1000);
1306                }
1307                else{
1308                    resolve();
1309                }
1310            });
1311        },
1312        async tooltips() {
1313            return vars.menu_tooltips.length || vars.builder_tooltips?this.loadJs( 'tooltip'):1;
1314        },
1315        fetch(data,type,params,url){
1316            url=url || vars.ajax_url;
1317            params=Object.assign({
1318                credentials:'same-origin',
1319                method:'POST',
1320                headers:{}
1321            }, params);
1322
1323            if(params.mode===und && !url.includes(location.origin)){
1324                params.mode='cors';
1325            }
1326            else if(params.mode!=='cors'){
1327                params.headers['X-Requested-With']='XMLHttpRequest';
1328            }
1329            if(!type){
1330                type='json';
1331            }
1332            if(type==='json'){
1333                params.headers.accept='application/json,text/javascript,*/*;q=0.01';
1334            }
1335            if(data){
1336                let body;
1337                if(data instanceof FormData){
1338                    body=data;
1339                }
1340                else{
1341                    body=new FormData();
1342                    for(let k in data){
1343                        if(typeof data[k]==='object' && !(data[k] instanceof Blob)){
1344                            body.set(k,JSON.stringify(data[k]));
1345                        }
1346                        else{
1347                            body.set(k,data[k]);
1348                        }
1349                    }
1350                }
1351                if(params.method==='POST'){
1352                    if(params.headers['Content-type']==='application/x-www-form-urlencoded'){
1353                        body=new URLSearchParams(body);
1354                    }
1355                    params.body=body;
1356                }
1357                else{
1358                    url = new URL(url,win.location);
1359                    for(let pair of body.entries()) {
1360                        url.searchParams.set(pair[0],pair[1]);
1361                    }
1362                }
1363            }
1364            return fetch(url,params).then(res=>{
1365                if(!res.ok){
1366                    throw res;
1367                }
1368                if(type==='json'){
1369                    return res.json();
1370                }
1371                if(type==='blob'){
1372                    return res.blob();
1373                }
1374                return res.text();
1375            }).
1376            then(res=>{
1377                if(res && (type==='html' || type==='text')){
1378                    res=res.trim();
1379                    if(type==='html' && res){
1380                        const tmp=doc.createElement('template');
1381                        tmp.innerHTML=res;
1382                        res=tmp.content;
1383                    }
1384                }
1385                return res;
1386            });
1387        }
1388    };
1389    Themify.init();
1390})(window, document, undefined, themify_vars);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.