@innovastudio/contentbox-interactive-runtime 1.0.1 → 1.0.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.
|
@@ -12231,7 +12231,8 @@ class jr {
|
|
|
12231
12231
|
class $r {
|
|
12232
12232
|
constructor(e = {}) {
|
|
12233
12233
|
const i = {
|
|
12234
|
-
skin: "light"
|
|
12234
|
+
skin: "light",
|
|
12235
|
+
smoothScroll: !0
|
|
12235
12236
|
};
|
|
12236
12237
|
this.settings = Object.assign(this, i, e), window.Glide = Wn, window.FormViewer = Mr, window.NavBar = jr, window.pageReRender = () => {
|
|
12237
12238
|
this.pageReRender();
|
|
@@ -12242,7 +12243,7 @@ class $r {
|
|
|
12242
12243
|
ks.init({
|
|
12243
12244
|
duration: 1200
|
|
12244
12245
|
});
|
|
12245
|
-
}, 300), new Ks();
|
|
12246
|
+
}, 300), this.settings.smoothScroll && new Ks();
|
|
12246
12247
|
}
|
|
12247
12248
|
prepareContent() {
|
|
12248
12249
|
const e = document.querySelector(".is-wrapper");
|
|
@@ -533,4 +533,4 @@ ${R.data}
|
|
|
533
533
|
`}}this.tokenInput+=_,this.tokenOutput+=f}return!0}catch(o){return o.name==="AbortError"?this.settings.consoleLog&&console.log("Request aborted by user."):console.error("Error:",o),!1}}async assistant(e,i,s,t){this.controller=new AbortController,this.signal=this.controller.signal;let n=.6,r=.9,a=1;t||(t=[]);let l=this.settings.model;t.length>0&&(l=this.settings.model2);const c={assistantId:this.settings.assistantId,question:e,context:i,system:s,functs:t,temperature:n,topP:r,num:a,model:l,customData:this.settings.customData};try{let d={"Content-Type":"application/json",...this.settings.headers},h=await(await fetch(this.settings.assistantUrl,{signal:this.signal,method:"POST",headers:d,body:JSON.stringify(c)})).json();return h.error?(console.log(`Error:
|
|
534
534
|
`+h.error),!1):(h.usage&&(this.tokenInput+=h.usage.prompt_tokens,this.tokenOutput+=h.usage.completion_tokens),h.answer.content[0].text.value)}catch(d){return d.name==="AbortError"?this.settings.consoleLog&&console.log("Request aborted by user."):console.error("Error:",d),!1}}async assistantStream(e,i,s,t,n){this.controller=new AbortController,this.signal=this.controller.signal;let r=.6,a=.9,l=1;t||(t=[]);const c={assistantId:this.settings.assistantId,question:e,context:i,system:s,functs:t,temperature:r,topP:a,num:l,model:this.settings.model,customData:this.settings.customData};try{let d={"Content-Type":"application/json",...this.settings.headers};const o=await fetch(this.settings.assistantStreamUrl,{signal:this.signal,method:"POST",headers:d,body:JSON.stringify(c)});if(!o.ok)return console.error("Error:",o.statusText),!1;const h=o.body.getReader(),p=new TextDecoder;let g="",w=!1;for(;!w;){const{done:S,value:b}=await h.read();if(w=S,w)break;const x=p.decode(b,{stream:!0});g+=x;const m=g.split(`
|
|
535
535
|
`);g="";for(const v of m)if(v.trim()!=="")if(v.startsWith("data:")){const _=v.slice(5).trim();_==="[DONE]"&&this.settings.consoleLog&&console.log("Stream completed.");try{const f=JSON.parse(_);if(f.choices&&f.choices[0].delta&&f.choices[0].delta.content){const y=f.choices[0].delta.content;n&&n(y)}}catch{g+=v+`
|
|
536
|
-
`}}else{const _=JSON.parse(v);this.tokenInput+=_.prompt_tokens,this.tokenOutput+=_.completion_tokens;break}}return!0}catch(d){return d.name==="AbortError"?this.settings.consoleLog&&console.log("Request aborted by user."):console.error("Error:",d),!1}}hexToRgb(e){const i=e.replace("#",""),s=parseInt(i,16),t=s>>16&255,n=s>>8&255,r=s&255;return{red:t,green:n,blue:r}}getId(e="id"){return`${e}-${Math.random().toString(36).substr(2,9)}`}appendHtml(e,i){e&&i&&e.insertAdjacentHTML("beforeend",i)}cleanup(){if(this.element){let e=this.element.querySelectorAll('input[type="text"], input[type="number"], input[type="email"], input[type="tel"], input[type="url"], textarea');e.forEach(i=>{i.removeEventListener("input",this.inputListener)}),e=this.element.querySelectorAll('input[type="date"], input[type="radio"], input[type="checkbox"]'),e.forEach(i=>{i.removeEventListener("change",this.changeListener)}),this.debounceTimeout&&(clearTimeout(this.debounceTimeout),this.debounceTimeout=null)}}destroy(){try{if(this._scrollListener){let e;this.settings.isBuilder?e=document.querySelector(this.settings.previewSelector):e=this.element;const i=e.querySelector(".submit-container"),s=this.getScrollableParent(i);s?s.removeEventListener("scroll",this._scrollListener):window.removeEventListener("scroll",this._scrollListener),window.removeEventListener("resize",this._scrollListener)}}catch{}this.element&&(this.cleanup(),this.element.innerHTML="",this.element=null);for(const e in this.listeners)this.listeners[e].clear();this.listeners={}}out(e){let i=this.settings.lang[e];return i||e}}class Mr{addClass(e,i){e&&(this.hasClass(e,i)||(e.classList.length===0?e.className=i:e.className=e.className+" "+i,e.className=e.className.replace(/ +/g," ")))}removeClass(e,i){if(e&&e.classList.length>0){let s,t,n,r,a=i.split(" ");for(s=0,n=a.length;s<n;++s){if(!a[s])continue;let l=a[s],c="",d=e.className.split(" ");for(t=0,r=d.length;t<r;++t)d[t]&&d[t]!==l&&(c+=d[t]+" ");e.className=c.trim()}e.className===""&&e.removeAttribute("class")}}hasClass(e,i){if(!e)return!1;try{let s=e.getAttribute("class");return new RegExp("\\b"+i+"\\b").test(s)}catch{}}}const F=new Mr;class Ir{constructor(e={}){const i={};this.settings=Object.assign(this,i,e)}init(){const e=h=>{const p=h.parentNode,g=h.nextElementSibling;if(F.hasClass(g,"is-menu-links")){let S=g.querySelectorAll("li");S.forEach(b=>{if(b!==p){const x=b.querySelector("ul");F.removeClass(x,"active")}}),S=document.querySelectorAll(".is-menu > ul > li ul"),S.forEach(b=>{const x=b.querySelector("ul");F.removeClass(x,"active")})}F.hasClass(g,"active")&&!F.hasClass(g,"is-menu-links")&&g.querySelectorAll("li").forEach(b=>{if(b!==p){const x=b.querySelector("ul");F.removeClass(x,"active")}});const w=p.querySelector("ul");w&&F.addClass(w,"active")},i=h=>{if(h.nextElementSibling){const p=h.nextElementSibling;if(p)if(F.hasClass(p,"active"))F.removeClass(p,"active"),h.focus();else{const w=h.parentNode.parentNode;F.removeClass(w,"active"),w.previousElementSibling.focus()}else{const w=h.parentNode.parentNode;F.removeClass(w,"active"),w.previousElementSibling.focus()}}else{const g=h.parentNode.parentNode;F.removeClass(g,"active"),g.previousElementSibling.focus()}},s=h=>{const p=h.target;if(h.keyCode===27)i(h.target);else if(h.keyCode===13)h.target.nextElementSibling&&(h.target.getAttribute("href")===""||h.target.getAttribute("href")==="javascript:")&&(e(h.target),h.preventDefault());else if(h.keyCode===32)h.target.nextElementSibling&&(e(h.target),h.preventDefault());else if(h.keyCode===40)if(p.nextElementSibling)if(p.nextElementSibling.classList.contains("active"))p.nextElementSibling.querySelector("a").focus(),h.preventDefault();else if(p.parentNode.nextElementSibling)p.parentNode.nextElementSibling.querySelector("a").focus(),h.preventDefault();else{const w=p.parentNode.parentNode;w.classList.contains("active")&&(w.classList.remove("active"),w.previousElementSibling.focus(),h.preventDefault())}else if(p.parentNode.nextElementSibling)p.parentNode.nextElementSibling.querySelector("a").focus(),h.preventDefault();else{const w=p.parentNode.parentNode;w.classList.contains("active")&&(w.classList.remove("active"),w.previousElementSibling.focus(),h.preventDefault())}else if(h.keyCode===38)if(p.nextElementSibling)if(p.nextElementSibling.classList.contains("active"))p.nextElementSibling.classList.remove("active");else{const g=p.parentNode.previousElementSibling;g&&g.querySelector("a").focus()}else if(p.parentNode.previousElementSibling)p.parentNode.previousElementSibling.querySelector("a").focus();else{const w=p.parentNode.parentNode;w.classList.contains("active")&&w.classList.remove("active"),w.previousElementSibling.focus()}else if(h.which===9&&!h.shiftKey)if(p.nextElementSibling)if(p.nextElementSibling.classList.contains("active"))p.nextElementSibling.querySelector("a").focus(),h.preventDefault();else if(p.parentNode.nextElementSibling)p.parentNode.nextElementSibling.querySelector("a").focus(),h.preventDefault();else{const w=p.parentNode.parentNode;w.classList.contains("active")&&(w.classList.remove("active"),w.previousElementSibling.focus(),h.preventDefault())}else if(p.parentNode.nextElementSibling)p.parentNode.nextElementSibling.querySelector("a").focus(),h.preventDefault();else{const w=p.parentNode.parentNode;w.classList.contains("active")&&(w.classList.remove("active"),w.previousElementSibling.focus(),h.preventDefault())}else if(h.which===9&&h.shiftKey){if(p.nextElementSibling)p.nextElementSibling.classList.contains("active")&&p.nextElementSibling.classList.remove("active");else if(!p.parentNode.previousElementSibling){const w=p.parentNode.parentNode;w.classList.contains("active")&&w.classList.remove("active")}}};document.querySelectorAll(".is-menu li a").forEach(h=>{h.addEventListener("keydown",s)}),document.querySelectorAll(".is-menu li").forEach(h=>{const p=h.querySelector("span");p&&p.addEventListener("click",g=>{if(window.innerWidth>=1024)return;const b=g.target.closest("li").querySelector("ul");b&&(F.hasClass(b,"active")?(F.removeClass(b,"active"),b.style.display=""):F.addClass(b,"active")),g.preventDefault(),g.stopImmediatePropagation()}),h.addEventListener("click",g=>{const w=h.querySelector("ul"),S=window.innerWidth;let b=g.target.tagName.toLowerCase();if(S>1024){if((b==="a"||b==="i")&&!g.target.getAttribute("href")){g.preventDefault(),g.stopImmediatePropagation();return}}else{let x=!0;if((b==="a"||b==="i")&&(g.target.getAttribute("href")||(g.preventDefault(),x=!1)),x){const m=document.querySelector(".is-menu");if(m.style.right==="0px"){F.removeClass(r,"active"),m.style.right="-1000px";const v=document.querySelector(".is-menu-overlay");F.removeClass(v,"active"),document.querySelector(".is-topbar-menu").style.paddingRight="0px",document.body.style.overflowY="auto"}}}w&&(F.hasClass(w,"active")?(F.removeClass(w,"active"),w.style.display=""):(F.addClass(w,"active"),setTimeout(()=>{},0)))}),h.addEventListener("mouseleave",g=>{window.innerWidth<=1024||(this.timer=setTimeout(()=>{const S=h.querySelector("ul");S&&F.removeClass(S,"active")},200),g.preventDefault(),g.stopImmediatePropagation())}),h.addEventListener("mouseenter",g=>{const w=window.innerWidth;if(w<=1024||this.staticClose)return;const S=document.querySelector(".is-menu-search-input");if(F.hasClass(S,"active"))return;clearTimeout(this.timer);const b=h.closest("ul");if(!h.querySelector("ul"))return b.querySelectorAll("li").forEach(v=>{const _=v.querySelector("ul");F.removeClass(_,"active")}),!0;if(F.hasClass(b,"is-menu-links")){let m=b.querySelectorAll("li");m.forEach(v=>{if(v!==h){const _=v.querySelector("ul");F.removeClass(_,"active")}}),m=document.querySelectorAll(".is-menu > ul > li ul"),m.forEach(v=>{const _=v.querySelector("ul");F.removeClass(_,"active")})}F.hasClass(b,"active")&&!F.hasClass(b,"is-menu-links")&&b.querySelectorAll("li").forEach(v=>{if(v!==h){const _=v.querySelector("ul");F.removeClass(_,"active")}});const x=h.querySelector("ul");if(x&&F.addClass(x,"active"),x.style.right="",x.classList.contains("active")){const m=x.getBoundingClientRect();m.left+m.width>w&&(x.style.right=0)}g.preventDefault(),g.stopImmediatePropagation()})});const r=document.querySelector("#is-menu-toggle");r.addEventListener("click",h=>{const p=document.querySelector(".is-menu");if(p.style.right==="0px"){F.removeClass(r,"active"),p.style.right="-1000px";const g=document.querySelector(".is-menu-overlay");F.removeClass(g,"active"),document.querySelector(".is-topbar-menu").style.paddingRight="0px",document.body.style.overflowY="auto"}else{F.addClass(r,"active"),document.querySelector(".is-menu-links .is-menu-search")?(document.querySelector(".is-menu-search-input").style.display="",document.querySelector(".is-menu-links").style.marginTop=""):(document.querySelector(".is-menu-search-input").style.display="none",document.querySelector(".is-menu-links").style.marginTop="70px"),p.style.right="0px";const w=document.querySelector(".is-menu-overlay");F.addClass(w,"active"),document.querySelector(".is-topbar-menu").style.paddingRight=this.getScrollbarWidth()+"px",document.body.style.overflowY="hidden"}h.stopImmediatePropagation(),h.preventDefault()}),document.querySelector(".is-menu-overlay").addEventListener("click",h=>{document.querySelector("#is-menu-toggle").click(),h.stopImmediatePropagation(),h.preventDefault()}),window.addEventListener("resize",()=>{document.body.style.overflowY="auto",document.querySelector(".is-topbar-menu").style.paddingRight="0px";const h=document.querySelector("#is-menu-toggle");F.removeClass(h,"active"),document.querySelectorAll(".is-menu li ul").forEach(S=>{F.removeClass(S,"active")});const g=document.querySelector(".is-menu");if(g.style.transition="none",window.innerWidth>1024){g.style.right="0px",document.querySelectorAll(".is-menu li ul").forEach(x=>{x.style.display=""});const b=document.querySelector(".is-menu-overlay");F.removeClass(b,"active"),document.querySelector(".is-menu-search-input").style.display="",document.querySelector(".is-menu-links").style.marginTop=""}else g.style.right="-1000px";setTimeout(()=>{g.style.transition=""},30)}),window.addEventListener("scroll",()=>{var h=100,p=this.getCurrentScroll();p>=h?F.addClass(document.querySelector(".is-topbar"),"shrink"):F.removeClass(document.querySelector(".is-topbar"),"shrink"),window.innerWidth>=1024&&document.querySelector(".is-topbar.static")&&(p>30?this.staticClose||(document.querySelectorAll(".is-menu li ul").forEach(S=>{F.removeClass(S,"active")}),this.staticClose=!0):this.staticClose=!1)});const l=h=>{const p=document.querySelector(".is-menu-search-input");F.addClass(p,"active"),p.querySelector("input").focus(),document.querySelectorAll(".is-menu li ul").forEach(S=>{F.removeClass(S,"active")}),h.preventDefault(),h.stopImmediatePropagation()},c=document.querySelector(".is-menu-search");c&&(c.addEventListener("click",h=>{l(h)}),c.addEventListener("keydown",h=>{(h.keyCode===13||h.keyCode===32)&&l(h)})),document.addEventListener("click",h=>{const p=h.target;if(!F.hasClass(p,"is-menu-search")&&p.getAttribute("id")!=="is_btnSearch"&&p.getAttribute("id")!=="is_txtSearch"){const g=document.querySelector(".is-menu-search-input");F.removeClass(g,"active")}});const d=document.querySelector("#is_txtSearch");d.addEventListener("keydown",h=>{if(h.which==13&&this.settings.onSearch(d.value),h.which==27){const p=document.querySelector(".is-menu-search-input");F.removeClass(p,"active"),document.querySelector(".is-menu-search").focus()}}),document.querySelector("#is_btnSearch").addEventListener("click",()=>{this.settings.onSearch(d.value)})}getScrollbarWidth(){return window.innerWidth-document.documentElement.clientWidth}getCurrentScroll(){return window.pageYOffset||document.documentElement.scrollTop}}class jr{constructor(e={}){const i={skin:"light"};this.settings=Object.assign(this,i,e),window.Glide=Wn,window.FormViewer=Rr,window.NavBar=Ir,window.pageReRender=()=>{this.pageReRender()}}init(){this.prepareContent(),this.updateOnResize(),this.blockInit(),this.initeSkrollrr(),this.contentBoxOnRenderUpdate(),this.functionLightboxInit(),this.inViewSetup(),setTimeout(()=>{ks.init({duration:1200})},300),new Ks}prepareContent(){const e=document.querySelector(".is-wrapper");e.classList.add("box-v2");const i=function(r){let a=r.nextElementSibling;return a?a.classList.contains("is-section")?a:i(a):!1};document.querySelectorAll(".is-arrow-down a").forEach(function(r){r.addEventListener("click",function(a){let l=a.target.closest(".is-section");if(l){let c=i(l);c&&this.scrollIt(c,1e3,"easeInQuad")}a.preventDefault(),a.stopImmediatePropagation()})}),e&&(e.classList.contains("is-edit")||e.querySelectorAll("a").forEach(function(a){a.addEventListener("click",function(l){let c=a.getAttribute("href");if(c&&c.indexOf("#")===0)if(c.indexOf("#section")===0){let d=c.replace("#section","");if(!isNaN(parseInt(d))){let o=document.querySelectorAll(".is-section"),h,p=0;o.forEach(function(g){g.classList.contains("is-section-navbar")||(p===d-1&&(h=g),p++)}),h&&scrollIt(h,1e3,"easeInQuad"),l.preventDefault()}}else try{let d=document.querySelector(c);d&&(scrollIt(d,1e3,"easeInQuad"),l.preventDefault())}catch{}})})),document.querySelectorAll(".section-inview").forEach(function(r){r.classList.remove("section-inview")});let n=document.querySelectorAll(".is-animated,.is-scale-animated");n.forEach(function(r){r.classList.contains("once")?(r.removeAttribute("data-scroll",""),r.setAttribute("data-scroll-once","")):(r.removeAttribute("data-scroll-once",""),r.setAttribute("data-scroll",""))}),n=document.querySelectorAll(".is-container > div"),n.forEach(function(r){let a=r.querySelectorAll(".is-animated[data-scroll],.is-animated[data-scroll-once]"),l=0;a.length>1&&a.forEach(function(c){c.className.indexOf("delay-")===-1&&(l>0&&(c.style.transitionDelay=l+"s",c.style.animationDelay=l+"s"),l=l+.2)})}),this.skrollrSetup(),this.adjustBgPos()}updateOnResize(){function e(s){var t;return function(n){t&&clearTimeout(t),t=setTimeout(s,100,n)}}const i=document.querySelector(".is-wrapper");window.addEventListener("resize",e(s=>{document.body.classList.contains("data-editor")&&(i.querySelector(".pin-wrap")&&!window.noRender?this.pageReRender():window.skrollrr&&window.skrollrr.refresh(),window.noRender=!1,this.adjustBgPos())})),i.classList.contains("is-edit")&&(window.onbeforeunload=function(s){localStorage.setItem("_lastscrollpos",document.documentElement.scrollTop),window.scrollTo(0,0)},setTimeout(()=>{localStorage.getItem("_lastscrollpos")&&window.scrollTo(0,localStorage.getItem("_lastscrollpos"))},300))}initeSkrollrr(){var e=document.querySelectorAll(".is-overlay-bg");e.forEach(s=>{s.style&&s.style.filter&&s.style.filter.indexOf("grayscale")!==-1&&(s.parentNode.style.filter="grayscale(1)")});const i=new Ts({transition:"all 0.3s ease-out"});i.init(),window.skrollrr=i}_scrollTo(e,i=0){const s=e.getBoundingClientRect().top+window.pageYOffset+i;window.scrollTo({top:s,behavior:"smooth"})}scrollIt(e,i=200,s="linear",t){_scrollTo(e)}skrollrSetup(){document.querySelectorAll(".pin-wrap").forEach(a=>{const l=a.firstElementChild;a.after(l),a.parentNode.removeChild(a)}),document.querySelectorAll(".is-section").forEach(a=>{a.hasAttribute("data-section-clone")&&a.parentNode.removeChild(a),a.hasAttribute("data-section-original")&&(a.style.display="",a.removeAttribute("data-section-original"))});let s=window.innerWidth;s<=760&&document.querySelectorAll(".section-wrap").forEach(l=>{l.outerHTML=l.innerHTML});const t=window.self!==window.top;let n;t?n=document.querySelectorAll(".is-wrapper .section-pin"):n=document.querySelectorAll(".is-wrapper:not(.is-edit) .section-pin"),n.length>0&&window.scrollTo(0,0),n.forEach(function(a){s<=970&&a.querySelector(".is-box")&&(a.querySelectorAll(".is-box").forEach(c=>{const d=a.cloneNode(!1);c.getAttributeNames().map(o=>{o.indexOf("data-")!==-1&&d.setAttribute(o,c.getAttribute(o))}),d.classList.add("is-box"),c.classList.forEach(o=>{(o.indexOf("is-box-")!==-1||o.indexOf("is-content-")!==-1||o.indexOf("box-autofit")!==-1||o.indexOf("is-light-text")!==-1||o.indexOf("is-dark-text")!==-1||o.indexOf("is-align-")!==-1||o.indexOf("type-")!==-1||o.indexOf("block-click")!==-1||o.indexOf("hover-zoom")!==-1)&&d.classList.add(o)}),d.setAttribute("data-section-clone",""),d.innerHTML=c.innerHTML,a.parentNode.insertBefore(d,a)}),a.setAttribute("data-section-original",""),a.style.display="none")}),t?n=document.querySelectorAll(".is-wrapper .section-pin"):n=document.querySelectorAll(".is-wrapper:not(.is-edit) .section-pin"),n.forEach(function(a){if(a.parentNode.closest(".section-wrap")||s<=970&&a.hasAttribute("data-section-original"))return;const l=document.createElement("div");l.classList.add("pin-wrap"),a.classList.contains("m-skrollrr-off")&&l.classList.add("m-skrollrr-off"),a.classList.contains("pin-space-lg")&&l.classList.add("pin-space-lg"),a.classList.contains("pin-space-xl")&&l.classList.add("pin-space-xl"),a.classList.contains("xs-hidden")&&l.classList.add("xs-hidden"),a.classList.contains("sm-hidden")&&l.classList.add("sm-hidden"),a.classList.contains("desktop-hidden")&&l.classList.add("desktop-hidden"),a.after(l),l.appendChild(a)});const r=a=>{document.querySelectorAll(".is-section").forEach(c=>{const d=c.getBoundingClientRect().top;let o,h;c.parentNode.classList.contains("pin-wrap")?(o=c.parentNode.nextElementSibling,h=c.parentNode.previousElementSibling):(o=c.nextElementSibling,h=c.previousElementSibling),o&&o.classList.contains("pin-wrap")&&(o=o.querySelector(".is-section")),h&&h.classList.contains("pin-wrap")&&(h=h.querySelector(".is-section")),d<=0&&((c.classList.contains("no-spacing")||c.classList.contains("pin-overlap"))&&c.classList.add("section-inview"),document.querySelectorAll(".is-section").forEach(g=>{g!==c&&g.classList.remove("section-inview")}))})};setTimeout(()=>{(!document.querySelector(".is-wrapper").classList.contains("is-edit")||t)&&!window.funcScroll&&(window.addEventListener("scroll",r),window.funcScroll=!0)},300)}adjustBgPos(){const e=n=>{const r=document.createElement("div");r.style.backgroundPositionX=n.style.backgroundPositionX,r.style.backgroundPositionY=n.style.backgroundPositionY,r.style.backgroundSize=n.style.backgroundSize,n.hasAttribute("data-bg-ori")||n.setAttribute("data-bg-ori",r.style.cssText)},i=n=>{if(n.hasAttribute("data-bg-ori")){const r=document.createElement("div");r.style.cssText=n.getAttribute("data-bg-ori"),n.style.backgroundPositionX=r.style.backgroundPositionX,n.style.backgroundPositionY=r.style.backgroundPositionY,n.style.backgroundSize=r.style.backgroundSize,n.removeAttribute("data-bg-ori")}};let s=window.innerWidth;document.querySelectorAll("[data-bg-xs],[data-bg-sm],[data-bg-md],[data-bg-lg]").forEach(n=>{e(n),s<=760&&(n.hasAttribute("data-bg-xs")?n.style.cssText=n.style.cssText+";"+n.getAttribute("data-bg-xs"):i(n)),s>760&&s<=970&&(n.hasAttribute("data-bg-sm")?n.style.cssText=n.style.cssText+";"+n.getAttribute("data-bg-sm"):i(n)),s>970&&s<=1280&&(n.hasAttribute("data-bg-md")?n.style.cssText=n.style.cssText+";"+n.getAttribute("data-bg-md"):i(n)),s>1280&&(n.hasAttribute("data-bg-lg")?n.style.cssText=n.style.cssText+";"+n.getAttribute("data-bg-lg"):i(n))})}inViewSetup(){document.querySelectorAll(".is-overlay-content").forEach(t=>{t.querySelector("video.is-video-bg")&&t.setAttribute("data-scroll","")}),document.querySelectorAll(".is-container video").forEach(t=>{t.parentNode.setAttribute("data-scroll","")});const s=new Ms({trigger:{once:!0,offset:{element:{x:0,y:(t,n,r)=>.1},viewport:{x:0,y:(t,n,r)=>t.visible?0:.1}},toggle:{class:{in:"is-inview",out:[""]},callback:{in:t=>{t.element.querySelectorAll("video").forEach(r=>{if(r.innerHTML.trim()==="")return;let a=r.parentNode.querySelector(".video-bg-play");r.autoplay?a?a.innerHTML.indexOf("play")===-1&&r.play():r.play():a&&a.innerHTML.indexOf("play")===-1&&r.play()})},out:t=>{t.element.querySelectorAll("video").forEach(r=>{!r.paused&&!r.closest("[data-html]")&&r.pause()})}}}}});s.add("[data-scroll-once]"),s.add("[data-scroll]",{once:!1}),window.trigger=s}contentBoxOnRenderUpdate(){try{if(window.contentbox||parent.contentbox){let e;window.contentbox?e=window.contentbox.onRender:parent.contentbox&&(e=parent.contentbox.onRender);const i=()=>{e.call(this);try{window.trigger&&window.trigger.kill()}catch{}let s=document.querySelectorAll(".is-animated,.is-scale-animated");s.forEach(function(t){t.classList.contains("once")?(t.removeAttribute("data-scroll",""),t.setAttribute("data-scroll-once","")):(t.removeAttribute("data-scroll-once",""),t.setAttribute("data-scroll",""))}),s=document.querySelectorAll(".is-container > div"),s.forEach(function(t){let n=t.querySelectorAll(".is-animated[data-scroll],.is-animated[data-scroll-once]"),r=0;n.length>1&&n.forEach(function(a){a.className.indexOf("delay-")===-1&&(r>0&&(a.style.transitionDelay=r+"s",a.style.animationDelay=r+"s"),r=r+.2)})}),setTimeout(()=>{this.inViewSetup()},100)};window.contentbox?window.contentbox.onRender=i:parent.contentbox&&(parent.contentbox.onRender=i)}}catch{}}functionLightboxInit(){const e={touchNavigation:!0,selector:".glightbox",loop:!0,autoplayVideos:!0,zoomable:!0,slideEffect:"slide",descPosition:"bottom",skin:this.settings.skin};this.refreshLightbox(e),document.querySelectorAll(".is-lightbox,.block-click").forEach(s=>{const t=n=>{let r=s.getAttribute("href")||s.getAttribute("data-modal-url");this.openLightbox(r,s,e),n.preventDefault(),n.stopImmediatePropagation()};s.addEventListener("click",t),s._lightboxHandler=t})}refreshLightbox(e){this.glightbox&&this.glightbox.destroy(),this.glightbox=new Fi(e),window.GLightbox=Fi.default}openLightbox(e,i,s){let t=[],n=0;if(i){const a=i.closest("[data-gallery]");let l=[];a?l=a.querySelectorAll(".is-lightbox"):document.querySelectorAll(".is-lightbox,.block-click").forEach(d=>{d.closest("[data-gallery]")||l.push(d)}),l.forEach((c,d)=>{let o=c.getAttribute("href");o||(o=c.getAttribute("data-modal-url")),t.push({href:o}),e===o&&(n=d)})}const r=document.activeElement;r?.blur(),t.length>0?(this.glightbox.setElements(t),this.glightbox.openAt(n)):(this.glightbox.setElements([{href:e}]),this.glightbox.open()),this.glightbox.on("close",()=>{this.refreshLightbox(s),r?.focus()})}blockInit(){const e={start:()=>{document.querySelectorAll(".is-block").forEach(t=>{t.hasAttribute("data--t")||t.setAttribute("data--t",t.style.top),t.hasAttribute("data--l")||t.setAttribute("data--l",t.style.left),t.hasAttribute("data--b")||t.setAttribute("data--b",t.style.bottom),t.hasAttribute("data--r")||t.setAttribute("data--r",t.style.right),t.hasAttribute("data--w")||t.setAttribute("data--w",t.style.width),t.hasAttribute("data--h")||t.setAttribute("data--h",t.style.height),t.removeAttribute("data-prev"),t.removeAttribute("data-fluid"),t.removeAttribute("data-fluid-val"),t.classList.remove("fluid"),t.style.transition=""})},apply:(t,n,r)=>{if(n&&t.getAttribute("data-prev")!==n+""){if(r||(t.style.transition="all 0.35s ease"),n!==1e4){if(t.setAttribute("data-breakpoint",n),t.hasAttribute("data--t-"+n)){let a=t.getAttribute("data--t-"+n);t.style.top=a}if(t.hasAttribute("data--l-"+n)){let a=t.getAttribute("data--l-"+n);t.style.left=a}if(t.hasAttribute("data--b-"+n)){let a=t.getAttribute("data--b-"+n);t.style.bottom=a}if(t.hasAttribute("data--r-"+n)){let a=t.getAttribute("data--r-"+n);t.style.right=a}if(t.hasAttribute("data--w-"+n)){let a=t.getAttribute("data--w-"+n);t.style.width=a}if(t.hasAttribute("data--h-"+n)){let a=t.getAttribute("data--h-"+n);t.style.height=a}if(t.hasAttribute("data--transform-"+n)){let a=t.getAttribute("data--transform-"+n);t.style.transform=a,t.setAttribute("data--transform-val",n)}}else{if(t.removeAttribute("data-breakpoint"),t.hasAttribute("data--t")){let a=t.getAttribute("data--t");t.style.top=a}if(t.hasAttribute("data--l")){let a=t.getAttribute("data--l");t.style.left=a}if(t.hasAttribute("data--b")){let a=t.getAttribute("data--b");t.style.bottom=a}if(t.hasAttribute("data--r")){let a=t.getAttribute("data--r");t.style.right=a}if(t.hasAttribute("data--w")){let a=t.getAttribute("data--w");t.style.width=a}if(t.hasAttribute("data--h")){let a=t.getAttribute("data--h");t.style.height=a}if(t.hasAttribute("data--transform")){let a=t.getAttribute("data--transform");t.style.transform=a,t.setAttribute("data--transform-val","")}}t.setAttribute("data-prev",n),setTimeout(()=>{r||(t.style.transition="")},400)}},applyFluid:(t,n)=>{t.classList.toggle("fluid",n==="yes"),t.setAttribute("data-fluid",n)},resize:t=>{const n=window.innerWidth;document.querySelectorAll(".is-box").forEach(r=>{let a=[];const l=r.attributes;for(let c=0;c<l.length;c++){let o=l[c].name.match(/^data--h-(\d+)$/);if(o){const h=parseInt(o[1],10);a.push(h)}}a=[...new Set(a)],a.sort((c,d)=>d-c);for(let c=0;c<a.length;c++){const d=a[c];if(c===0){if(n>d){let o=r.getAttribute("data--h");o?r.style.height=o:r.style.height=""}}else{const o=a[c-1];if(o>=n&&n>d){let h=r.getAttribute("data--h-"+o);h&&(r.style.height=h)}}}if(a.length>0&&a[a.length-1]>=n){const d=a[a.length-1];let o=r.getAttribute("data--h-"+d);o&&(r.style.height=o)}}),document.querySelectorAll(".is-block").forEach(r=>{if(!r.classList.contains("locked")){r.offsetWidth+0>n&&!r.classList.contains("fluid")&&(r.setAttribute("data-fluid-val",r.offsetWidth),e.applyFluid(r,"yes"));let c=r.getAttribute("data-fluid-val");c&&parseInt(c)+0<=n&&r.classList.contains("fluid")&&e.applyFluid(r,"no")}let a=[];const l=r.attributes;for(let c=0;c<l.length;c++){const d=l[c].name;let o=d.match(/^data--t-(\d+)$/);if(o){const h=parseInt(o[1],10);a.push(h)}if(o=d.match(/^data--w-(\d+)$/),o){const h=parseInt(o[1],10);a.push(h)}if(o=d.match(/^data--transform-(\d+)$/),o){const h=parseInt(o[1],10);a.push(h)}}a=[...new Set(a)],a.sort((c,d)=>d-c);for(let c=0;c<a.length;c++){const d=a[c];if(c===0)n>d&&e.apply(r,1e4,t);else{const o=a[c-1];o>=n&&n>d&&e.apply(r,o,t)}}if(a.length>0){const c=a[a.length-1];c>=n&&e.apply(r,c,t)}})},render:()=>{e.start(),e.resize(!0)}},s=((t,n)=>{let r;return(...a)=>{clearTimeout(r),r=setTimeout(()=>t(...a),n)}})(()=>{e.resize()},0);window.addEventListener("resize",s),e.start(),e.resize(!0),this.Block=e}pageReRender(){this.prepareContent(),this.contentBoxOnRenderUpdate(),window.skrollrr?window.skrollrr.refresh():this.initeSkrollrr(),this.functionLightboxInit(),this.inViewSetup(),this.Block.start(),this.Block.resize()}destroy(){this.glightbox&&(this.glightbox.destroy(),this.glightbox=null),document.querySelectorAll(".is-lightbox,.block-click").forEach(i=>{i._lightboxHandler&&(i.removeEventListener("click",i._lightboxHandler),delete i._lightboxHandler)})}}return jr})();
|
|
536
|
+
`}}else{const _=JSON.parse(v);this.tokenInput+=_.prompt_tokens,this.tokenOutput+=_.completion_tokens;break}}return!0}catch(d){return d.name==="AbortError"?this.settings.consoleLog&&console.log("Request aborted by user."):console.error("Error:",d),!1}}hexToRgb(e){const i=e.replace("#",""),s=parseInt(i,16),t=s>>16&255,n=s>>8&255,r=s&255;return{red:t,green:n,blue:r}}getId(e="id"){return`${e}-${Math.random().toString(36).substr(2,9)}`}appendHtml(e,i){e&&i&&e.insertAdjacentHTML("beforeend",i)}cleanup(){if(this.element){let e=this.element.querySelectorAll('input[type="text"], input[type="number"], input[type="email"], input[type="tel"], input[type="url"], textarea');e.forEach(i=>{i.removeEventListener("input",this.inputListener)}),e=this.element.querySelectorAll('input[type="date"], input[type="radio"], input[type="checkbox"]'),e.forEach(i=>{i.removeEventListener("change",this.changeListener)}),this.debounceTimeout&&(clearTimeout(this.debounceTimeout),this.debounceTimeout=null)}}destroy(){try{if(this._scrollListener){let e;this.settings.isBuilder?e=document.querySelector(this.settings.previewSelector):e=this.element;const i=e.querySelector(".submit-container"),s=this.getScrollableParent(i);s?s.removeEventListener("scroll",this._scrollListener):window.removeEventListener("scroll",this._scrollListener),window.removeEventListener("resize",this._scrollListener)}}catch{}this.element&&(this.cleanup(),this.element.innerHTML="",this.element=null);for(const e in this.listeners)this.listeners[e].clear();this.listeners={}}out(e){let i=this.settings.lang[e];return i||e}}class Mr{addClass(e,i){e&&(this.hasClass(e,i)||(e.classList.length===0?e.className=i:e.className=e.className+" "+i,e.className=e.className.replace(/ +/g," ")))}removeClass(e,i){if(e&&e.classList.length>0){let s,t,n,r,a=i.split(" ");for(s=0,n=a.length;s<n;++s){if(!a[s])continue;let l=a[s],c="",d=e.className.split(" ");for(t=0,r=d.length;t<r;++t)d[t]&&d[t]!==l&&(c+=d[t]+" ");e.className=c.trim()}e.className===""&&e.removeAttribute("class")}}hasClass(e,i){if(!e)return!1;try{let s=e.getAttribute("class");return new RegExp("\\b"+i+"\\b").test(s)}catch{}}}const F=new Mr;class Ir{constructor(e={}){const i={};this.settings=Object.assign(this,i,e)}init(){const e=h=>{const p=h.parentNode,g=h.nextElementSibling;if(F.hasClass(g,"is-menu-links")){let S=g.querySelectorAll("li");S.forEach(b=>{if(b!==p){const x=b.querySelector("ul");F.removeClass(x,"active")}}),S=document.querySelectorAll(".is-menu > ul > li ul"),S.forEach(b=>{const x=b.querySelector("ul");F.removeClass(x,"active")})}F.hasClass(g,"active")&&!F.hasClass(g,"is-menu-links")&&g.querySelectorAll("li").forEach(b=>{if(b!==p){const x=b.querySelector("ul");F.removeClass(x,"active")}});const w=p.querySelector("ul");w&&F.addClass(w,"active")},i=h=>{if(h.nextElementSibling){const p=h.nextElementSibling;if(p)if(F.hasClass(p,"active"))F.removeClass(p,"active"),h.focus();else{const w=h.parentNode.parentNode;F.removeClass(w,"active"),w.previousElementSibling.focus()}else{const w=h.parentNode.parentNode;F.removeClass(w,"active"),w.previousElementSibling.focus()}}else{const g=h.parentNode.parentNode;F.removeClass(g,"active"),g.previousElementSibling.focus()}},s=h=>{const p=h.target;if(h.keyCode===27)i(h.target);else if(h.keyCode===13)h.target.nextElementSibling&&(h.target.getAttribute("href")===""||h.target.getAttribute("href")==="javascript:")&&(e(h.target),h.preventDefault());else if(h.keyCode===32)h.target.nextElementSibling&&(e(h.target),h.preventDefault());else if(h.keyCode===40)if(p.nextElementSibling)if(p.nextElementSibling.classList.contains("active"))p.nextElementSibling.querySelector("a").focus(),h.preventDefault();else if(p.parentNode.nextElementSibling)p.parentNode.nextElementSibling.querySelector("a").focus(),h.preventDefault();else{const w=p.parentNode.parentNode;w.classList.contains("active")&&(w.classList.remove("active"),w.previousElementSibling.focus(),h.preventDefault())}else if(p.parentNode.nextElementSibling)p.parentNode.nextElementSibling.querySelector("a").focus(),h.preventDefault();else{const w=p.parentNode.parentNode;w.classList.contains("active")&&(w.classList.remove("active"),w.previousElementSibling.focus(),h.preventDefault())}else if(h.keyCode===38)if(p.nextElementSibling)if(p.nextElementSibling.classList.contains("active"))p.nextElementSibling.classList.remove("active");else{const g=p.parentNode.previousElementSibling;g&&g.querySelector("a").focus()}else if(p.parentNode.previousElementSibling)p.parentNode.previousElementSibling.querySelector("a").focus();else{const w=p.parentNode.parentNode;w.classList.contains("active")&&w.classList.remove("active"),w.previousElementSibling.focus()}else if(h.which===9&&!h.shiftKey)if(p.nextElementSibling)if(p.nextElementSibling.classList.contains("active"))p.nextElementSibling.querySelector("a").focus(),h.preventDefault();else if(p.parentNode.nextElementSibling)p.parentNode.nextElementSibling.querySelector("a").focus(),h.preventDefault();else{const w=p.parentNode.parentNode;w.classList.contains("active")&&(w.classList.remove("active"),w.previousElementSibling.focus(),h.preventDefault())}else if(p.parentNode.nextElementSibling)p.parentNode.nextElementSibling.querySelector("a").focus(),h.preventDefault();else{const w=p.parentNode.parentNode;w.classList.contains("active")&&(w.classList.remove("active"),w.previousElementSibling.focus(),h.preventDefault())}else if(h.which===9&&h.shiftKey){if(p.nextElementSibling)p.nextElementSibling.classList.contains("active")&&p.nextElementSibling.classList.remove("active");else if(!p.parentNode.previousElementSibling){const w=p.parentNode.parentNode;w.classList.contains("active")&&w.classList.remove("active")}}};document.querySelectorAll(".is-menu li a").forEach(h=>{h.addEventListener("keydown",s)}),document.querySelectorAll(".is-menu li").forEach(h=>{const p=h.querySelector("span");p&&p.addEventListener("click",g=>{if(window.innerWidth>=1024)return;const b=g.target.closest("li").querySelector("ul");b&&(F.hasClass(b,"active")?(F.removeClass(b,"active"),b.style.display=""):F.addClass(b,"active")),g.preventDefault(),g.stopImmediatePropagation()}),h.addEventListener("click",g=>{const w=h.querySelector("ul"),S=window.innerWidth;let b=g.target.tagName.toLowerCase();if(S>1024){if((b==="a"||b==="i")&&!g.target.getAttribute("href")){g.preventDefault(),g.stopImmediatePropagation();return}}else{let x=!0;if((b==="a"||b==="i")&&(g.target.getAttribute("href")||(g.preventDefault(),x=!1)),x){const m=document.querySelector(".is-menu");if(m.style.right==="0px"){F.removeClass(r,"active"),m.style.right="-1000px";const v=document.querySelector(".is-menu-overlay");F.removeClass(v,"active"),document.querySelector(".is-topbar-menu").style.paddingRight="0px",document.body.style.overflowY="auto"}}}w&&(F.hasClass(w,"active")?(F.removeClass(w,"active"),w.style.display=""):(F.addClass(w,"active"),setTimeout(()=>{},0)))}),h.addEventListener("mouseleave",g=>{window.innerWidth<=1024||(this.timer=setTimeout(()=>{const S=h.querySelector("ul");S&&F.removeClass(S,"active")},200),g.preventDefault(),g.stopImmediatePropagation())}),h.addEventListener("mouseenter",g=>{const w=window.innerWidth;if(w<=1024||this.staticClose)return;const S=document.querySelector(".is-menu-search-input");if(F.hasClass(S,"active"))return;clearTimeout(this.timer);const b=h.closest("ul");if(!h.querySelector("ul"))return b.querySelectorAll("li").forEach(v=>{const _=v.querySelector("ul");F.removeClass(_,"active")}),!0;if(F.hasClass(b,"is-menu-links")){let m=b.querySelectorAll("li");m.forEach(v=>{if(v!==h){const _=v.querySelector("ul");F.removeClass(_,"active")}}),m=document.querySelectorAll(".is-menu > ul > li ul"),m.forEach(v=>{const _=v.querySelector("ul");F.removeClass(_,"active")})}F.hasClass(b,"active")&&!F.hasClass(b,"is-menu-links")&&b.querySelectorAll("li").forEach(v=>{if(v!==h){const _=v.querySelector("ul");F.removeClass(_,"active")}});const x=h.querySelector("ul");if(x&&F.addClass(x,"active"),x.style.right="",x.classList.contains("active")){const m=x.getBoundingClientRect();m.left+m.width>w&&(x.style.right=0)}g.preventDefault(),g.stopImmediatePropagation()})});const r=document.querySelector("#is-menu-toggle");r.addEventListener("click",h=>{const p=document.querySelector(".is-menu");if(p.style.right==="0px"){F.removeClass(r,"active"),p.style.right="-1000px";const g=document.querySelector(".is-menu-overlay");F.removeClass(g,"active"),document.querySelector(".is-topbar-menu").style.paddingRight="0px",document.body.style.overflowY="auto"}else{F.addClass(r,"active"),document.querySelector(".is-menu-links .is-menu-search")?(document.querySelector(".is-menu-search-input").style.display="",document.querySelector(".is-menu-links").style.marginTop=""):(document.querySelector(".is-menu-search-input").style.display="none",document.querySelector(".is-menu-links").style.marginTop="70px"),p.style.right="0px";const w=document.querySelector(".is-menu-overlay");F.addClass(w,"active"),document.querySelector(".is-topbar-menu").style.paddingRight=this.getScrollbarWidth()+"px",document.body.style.overflowY="hidden"}h.stopImmediatePropagation(),h.preventDefault()}),document.querySelector(".is-menu-overlay").addEventListener("click",h=>{document.querySelector("#is-menu-toggle").click(),h.stopImmediatePropagation(),h.preventDefault()}),window.addEventListener("resize",()=>{document.body.style.overflowY="auto",document.querySelector(".is-topbar-menu").style.paddingRight="0px";const h=document.querySelector("#is-menu-toggle");F.removeClass(h,"active"),document.querySelectorAll(".is-menu li ul").forEach(S=>{F.removeClass(S,"active")});const g=document.querySelector(".is-menu");if(g.style.transition="none",window.innerWidth>1024){g.style.right="0px",document.querySelectorAll(".is-menu li ul").forEach(x=>{x.style.display=""});const b=document.querySelector(".is-menu-overlay");F.removeClass(b,"active"),document.querySelector(".is-menu-search-input").style.display="",document.querySelector(".is-menu-links").style.marginTop=""}else g.style.right="-1000px";setTimeout(()=>{g.style.transition=""},30)}),window.addEventListener("scroll",()=>{var h=100,p=this.getCurrentScroll();p>=h?F.addClass(document.querySelector(".is-topbar"),"shrink"):F.removeClass(document.querySelector(".is-topbar"),"shrink"),window.innerWidth>=1024&&document.querySelector(".is-topbar.static")&&(p>30?this.staticClose||(document.querySelectorAll(".is-menu li ul").forEach(S=>{F.removeClass(S,"active")}),this.staticClose=!0):this.staticClose=!1)});const l=h=>{const p=document.querySelector(".is-menu-search-input");F.addClass(p,"active"),p.querySelector("input").focus(),document.querySelectorAll(".is-menu li ul").forEach(S=>{F.removeClass(S,"active")}),h.preventDefault(),h.stopImmediatePropagation()},c=document.querySelector(".is-menu-search");c&&(c.addEventListener("click",h=>{l(h)}),c.addEventListener("keydown",h=>{(h.keyCode===13||h.keyCode===32)&&l(h)})),document.addEventListener("click",h=>{const p=h.target;if(!F.hasClass(p,"is-menu-search")&&p.getAttribute("id")!=="is_btnSearch"&&p.getAttribute("id")!=="is_txtSearch"){const g=document.querySelector(".is-menu-search-input");F.removeClass(g,"active")}});const d=document.querySelector("#is_txtSearch");d.addEventListener("keydown",h=>{if(h.which==13&&this.settings.onSearch(d.value),h.which==27){const p=document.querySelector(".is-menu-search-input");F.removeClass(p,"active"),document.querySelector(".is-menu-search").focus()}}),document.querySelector("#is_btnSearch").addEventListener("click",()=>{this.settings.onSearch(d.value)})}getScrollbarWidth(){return window.innerWidth-document.documentElement.clientWidth}getCurrentScroll(){return window.pageYOffset||document.documentElement.scrollTop}}class jr{constructor(e={}){const i={skin:"light",smoothScroll:!0};this.settings=Object.assign(this,i,e),window.Glide=Wn,window.FormViewer=Rr,window.NavBar=Ir,window.pageReRender=()=>{this.pageReRender()}}init(){this.prepareContent(),this.updateOnResize(),this.blockInit(),this.initeSkrollrr(),this.contentBoxOnRenderUpdate(),this.functionLightboxInit(),this.inViewSetup(),setTimeout(()=>{ks.init({duration:1200})},300),this.settings.smoothScroll&&new Ks}prepareContent(){const e=document.querySelector(".is-wrapper");e.classList.add("box-v2");const i=function(r){let a=r.nextElementSibling;return a?a.classList.contains("is-section")?a:i(a):!1};document.querySelectorAll(".is-arrow-down a").forEach(function(r){r.addEventListener("click",function(a){let l=a.target.closest(".is-section");if(l){let c=i(l);c&&this.scrollIt(c,1e3,"easeInQuad")}a.preventDefault(),a.stopImmediatePropagation()})}),e&&(e.classList.contains("is-edit")||e.querySelectorAll("a").forEach(function(a){a.addEventListener("click",function(l){let c=a.getAttribute("href");if(c&&c.indexOf("#")===0)if(c.indexOf("#section")===0){let d=c.replace("#section","");if(!isNaN(parseInt(d))){let o=document.querySelectorAll(".is-section"),h,p=0;o.forEach(function(g){g.classList.contains("is-section-navbar")||(p===d-1&&(h=g),p++)}),h&&scrollIt(h,1e3,"easeInQuad"),l.preventDefault()}}else try{let d=document.querySelector(c);d&&(scrollIt(d,1e3,"easeInQuad"),l.preventDefault())}catch{}})})),document.querySelectorAll(".section-inview").forEach(function(r){r.classList.remove("section-inview")});let n=document.querySelectorAll(".is-animated,.is-scale-animated");n.forEach(function(r){r.classList.contains("once")?(r.removeAttribute("data-scroll",""),r.setAttribute("data-scroll-once","")):(r.removeAttribute("data-scroll-once",""),r.setAttribute("data-scroll",""))}),n=document.querySelectorAll(".is-container > div"),n.forEach(function(r){let a=r.querySelectorAll(".is-animated[data-scroll],.is-animated[data-scroll-once]"),l=0;a.length>1&&a.forEach(function(c){c.className.indexOf("delay-")===-1&&(l>0&&(c.style.transitionDelay=l+"s",c.style.animationDelay=l+"s"),l=l+.2)})}),this.skrollrSetup(),this.adjustBgPos()}updateOnResize(){function e(s){var t;return function(n){t&&clearTimeout(t),t=setTimeout(s,100,n)}}const i=document.querySelector(".is-wrapper");window.addEventListener("resize",e(s=>{document.body.classList.contains("data-editor")&&(i.querySelector(".pin-wrap")&&!window.noRender?this.pageReRender():window.skrollrr&&window.skrollrr.refresh(),window.noRender=!1,this.adjustBgPos())})),i.classList.contains("is-edit")&&(window.onbeforeunload=function(s){localStorage.setItem("_lastscrollpos",document.documentElement.scrollTop),window.scrollTo(0,0)},setTimeout(()=>{localStorage.getItem("_lastscrollpos")&&window.scrollTo(0,localStorage.getItem("_lastscrollpos"))},300))}initeSkrollrr(){var e=document.querySelectorAll(".is-overlay-bg");e.forEach(s=>{s.style&&s.style.filter&&s.style.filter.indexOf("grayscale")!==-1&&(s.parentNode.style.filter="grayscale(1)")});const i=new Ts({transition:"all 0.3s ease-out"});i.init(),window.skrollrr=i}_scrollTo(e,i=0){const s=e.getBoundingClientRect().top+window.pageYOffset+i;window.scrollTo({top:s,behavior:"smooth"})}scrollIt(e,i=200,s="linear",t){_scrollTo(e)}skrollrSetup(){document.querySelectorAll(".pin-wrap").forEach(a=>{const l=a.firstElementChild;a.after(l),a.parentNode.removeChild(a)}),document.querySelectorAll(".is-section").forEach(a=>{a.hasAttribute("data-section-clone")&&a.parentNode.removeChild(a),a.hasAttribute("data-section-original")&&(a.style.display="",a.removeAttribute("data-section-original"))});let s=window.innerWidth;s<=760&&document.querySelectorAll(".section-wrap").forEach(l=>{l.outerHTML=l.innerHTML});const t=window.self!==window.top;let n;t?n=document.querySelectorAll(".is-wrapper .section-pin"):n=document.querySelectorAll(".is-wrapper:not(.is-edit) .section-pin"),n.length>0&&window.scrollTo(0,0),n.forEach(function(a){s<=970&&a.querySelector(".is-box")&&(a.querySelectorAll(".is-box").forEach(c=>{const d=a.cloneNode(!1);c.getAttributeNames().map(o=>{o.indexOf("data-")!==-1&&d.setAttribute(o,c.getAttribute(o))}),d.classList.add("is-box"),c.classList.forEach(o=>{(o.indexOf("is-box-")!==-1||o.indexOf("is-content-")!==-1||o.indexOf("box-autofit")!==-1||o.indexOf("is-light-text")!==-1||o.indexOf("is-dark-text")!==-1||o.indexOf("is-align-")!==-1||o.indexOf("type-")!==-1||o.indexOf("block-click")!==-1||o.indexOf("hover-zoom")!==-1)&&d.classList.add(o)}),d.setAttribute("data-section-clone",""),d.innerHTML=c.innerHTML,a.parentNode.insertBefore(d,a)}),a.setAttribute("data-section-original",""),a.style.display="none")}),t?n=document.querySelectorAll(".is-wrapper .section-pin"):n=document.querySelectorAll(".is-wrapper:not(.is-edit) .section-pin"),n.forEach(function(a){if(a.parentNode.closest(".section-wrap")||s<=970&&a.hasAttribute("data-section-original"))return;const l=document.createElement("div");l.classList.add("pin-wrap"),a.classList.contains("m-skrollrr-off")&&l.classList.add("m-skrollrr-off"),a.classList.contains("pin-space-lg")&&l.classList.add("pin-space-lg"),a.classList.contains("pin-space-xl")&&l.classList.add("pin-space-xl"),a.classList.contains("xs-hidden")&&l.classList.add("xs-hidden"),a.classList.contains("sm-hidden")&&l.classList.add("sm-hidden"),a.classList.contains("desktop-hidden")&&l.classList.add("desktop-hidden"),a.after(l),l.appendChild(a)});const r=a=>{document.querySelectorAll(".is-section").forEach(c=>{const d=c.getBoundingClientRect().top;let o,h;c.parentNode.classList.contains("pin-wrap")?(o=c.parentNode.nextElementSibling,h=c.parentNode.previousElementSibling):(o=c.nextElementSibling,h=c.previousElementSibling),o&&o.classList.contains("pin-wrap")&&(o=o.querySelector(".is-section")),h&&h.classList.contains("pin-wrap")&&(h=h.querySelector(".is-section")),d<=0&&((c.classList.contains("no-spacing")||c.classList.contains("pin-overlap"))&&c.classList.add("section-inview"),document.querySelectorAll(".is-section").forEach(g=>{g!==c&&g.classList.remove("section-inview")}))})};setTimeout(()=>{(!document.querySelector(".is-wrapper").classList.contains("is-edit")||t)&&!window.funcScroll&&(window.addEventListener("scroll",r),window.funcScroll=!0)},300)}adjustBgPos(){const e=n=>{const r=document.createElement("div");r.style.backgroundPositionX=n.style.backgroundPositionX,r.style.backgroundPositionY=n.style.backgroundPositionY,r.style.backgroundSize=n.style.backgroundSize,n.hasAttribute("data-bg-ori")||n.setAttribute("data-bg-ori",r.style.cssText)},i=n=>{if(n.hasAttribute("data-bg-ori")){const r=document.createElement("div");r.style.cssText=n.getAttribute("data-bg-ori"),n.style.backgroundPositionX=r.style.backgroundPositionX,n.style.backgroundPositionY=r.style.backgroundPositionY,n.style.backgroundSize=r.style.backgroundSize,n.removeAttribute("data-bg-ori")}};let s=window.innerWidth;document.querySelectorAll("[data-bg-xs],[data-bg-sm],[data-bg-md],[data-bg-lg]").forEach(n=>{e(n),s<=760&&(n.hasAttribute("data-bg-xs")?n.style.cssText=n.style.cssText+";"+n.getAttribute("data-bg-xs"):i(n)),s>760&&s<=970&&(n.hasAttribute("data-bg-sm")?n.style.cssText=n.style.cssText+";"+n.getAttribute("data-bg-sm"):i(n)),s>970&&s<=1280&&(n.hasAttribute("data-bg-md")?n.style.cssText=n.style.cssText+";"+n.getAttribute("data-bg-md"):i(n)),s>1280&&(n.hasAttribute("data-bg-lg")?n.style.cssText=n.style.cssText+";"+n.getAttribute("data-bg-lg"):i(n))})}inViewSetup(){document.querySelectorAll(".is-overlay-content").forEach(t=>{t.querySelector("video.is-video-bg")&&t.setAttribute("data-scroll","")}),document.querySelectorAll(".is-container video").forEach(t=>{t.parentNode.setAttribute("data-scroll","")});const s=new Ms({trigger:{once:!0,offset:{element:{x:0,y:(t,n,r)=>.1},viewport:{x:0,y:(t,n,r)=>t.visible?0:.1}},toggle:{class:{in:"is-inview",out:[""]},callback:{in:t=>{t.element.querySelectorAll("video").forEach(r=>{if(r.innerHTML.trim()==="")return;let a=r.parentNode.querySelector(".video-bg-play");r.autoplay?a?a.innerHTML.indexOf("play")===-1&&r.play():r.play():a&&a.innerHTML.indexOf("play")===-1&&r.play()})},out:t=>{t.element.querySelectorAll("video").forEach(r=>{!r.paused&&!r.closest("[data-html]")&&r.pause()})}}}}});s.add("[data-scroll-once]"),s.add("[data-scroll]",{once:!1}),window.trigger=s}contentBoxOnRenderUpdate(){try{if(window.contentbox||parent.contentbox){let e;window.contentbox?e=window.contentbox.onRender:parent.contentbox&&(e=parent.contentbox.onRender);const i=()=>{e.call(this);try{window.trigger&&window.trigger.kill()}catch{}let s=document.querySelectorAll(".is-animated,.is-scale-animated");s.forEach(function(t){t.classList.contains("once")?(t.removeAttribute("data-scroll",""),t.setAttribute("data-scroll-once","")):(t.removeAttribute("data-scroll-once",""),t.setAttribute("data-scroll",""))}),s=document.querySelectorAll(".is-container > div"),s.forEach(function(t){let n=t.querySelectorAll(".is-animated[data-scroll],.is-animated[data-scroll-once]"),r=0;n.length>1&&n.forEach(function(a){a.className.indexOf("delay-")===-1&&(r>0&&(a.style.transitionDelay=r+"s",a.style.animationDelay=r+"s"),r=r+.2)})}),setTimeout(()=>{this.inViewSetup()},100)};window.contentbox?window.contentbox.onRender=i:parent.contentbox&&(parent.contentbox.onRender=i)}}catch{}}functionLightboxInit(){const e={touchNavigation:!0,selector:".glightbox",loop:!0,autoplayVideos:!0,zoomable:!0,slideEffect:"slide",descPosition:"bottom",skin:this.settings.skin};this.refreshLightbox(e),document.querySelectorAll(".is-lightbox,.block-click").forEach(s=>{const t=n=>{let r=s.getAttribute("href")||s.getAttribute("data-modal-url");this.openLightbox(r,s,e),n.preventDefault(),n.stopImmediatePropagation()};s.addEventListener("click",t),s._lightboxHandler=t})}refreshLightbox(e){this.glightbox&&this.glightbox.destroy(),this.glightbox=new Fi(e),window.GLightbox=Fi.default}openLightbox(e,i,s){let t=[],n=0;if(i){const a=i.closest("[data-gallery]");let l=[];a?l=a.querySelectorAll(".is-lightbox"):document.querySelectorAll(".is-lightbox,.block-click").forEach(d=>{d.closest("[data-gallery]")||l.push(d)}),l.forEach((c,d)=>{let o=c.getAttribute("href");o||(o=c.getAttribute("data-modal-url")),t.push({href:o}),e===o&&(n=d)})}const r=document.activeElement;r?.blur(),t.length>0?(this.glightbox.setElements(t),this.glightbox.openAt(n)):(this.glightbox.setElements([{href:e}]),this.glightbox.open()),this.glightbox.on("close",()=>{this.refreshLightbox(s),r?.focus()})}blockInit(){const e={start:()=>{document.querySelectorAll(".is-block").forEach(t=>{t.hasAttribute("data--t")||t.setAttribute("data--t",t.style.top),t.hasAttribute("data--l")||t.setAttribute("data--l",t.style.left),t.hasAttribute("data--b")||t.setAttribute("data--b",t.style.bottom),t.hasAttribute("data--r")||t.setAttribute("data--r",t.style.right),t.hasAttribute("data--w")||t.setAttribute("data--w",t.style.width),t.hasAttribute("data--h")||t.setAttribute("data--h",t.style.height),t.removeAttribute("data-prev"),t.removeAttribute("data-fluid"),t.removeAttribute("data-fluid-val"),t.classList.remove("fluid"),t.style.transition=""})},apply:(t,n,r)=>{if(n&&t.getAttribute("data-prev")!==n+""){if(r||(t.style.transition="all 0.35s ease"),n!==1e4){if(t.setAttribute("data-breakpoint",n),t.hasAttribute("data--t-"+n)){let a=t.getAttribute("data--t-"+n);t.style.top=a}if(t.hasAttribute("data--l-"+n)){let a=t.getAttribute("data--l-"+n);t.style.left=a}if(t.hasAttribute("data--b-"+n)){let a=t.getAttribute("data--b-"+n);t.style.bottom=a}if(t.hasAttribute("data--r-"+n)){let a=t.getAttribute("data--r-"+n);t.style.right=a}if(t.hasAttribute("data--w-"+n)){let a=t.getAttribute("data--w-"+n);t.style.width=a}if(t.hasAttribute("data--h-"+n)){let a=t.getAttribute("data--h-"+n);t.style.height=a}if(t.hasAttribute("data--transform-"+n)){let a=t.getAttribute("data--transform-"+n);t.style.transform=a,t.setAttribute("data--transform-val",n)}}else{if(t.removeAttribute("data-breakpoint"),t.hasAttribute("data--t")){let a=t.getAttribute("data--t");t.style.top=a}if(t.hasAttribute("data--l")){let a=t.getAttribute("data--l");t.style.left=a}if(t.hasAttribute("data--b")){let a=t.getAttribute("data--b");t.style.bottom=a}if(t.hasAttribute("data--r")){let a=t.getAttribute("data--r");t.style.right=a}if(t.hasAttribute("data--w")){let a=t.getAttribute("data--w");t.style.width=a}if(t.hasAttribute("data--h")){let a=t.getAttribute("data--h");t.style.height=a}if(t.hasAttribute("data--transform")){let a=t.getAttribute("data--transform");t.style.transform=a,t.setAttribute("data--transform-val","")}}t.setAttribute("data-prev",n),setTimeout(()=>{r||(t.style.transition="")},400)}},applyFluid:(t,n)=>{t.classList.toggle("fluid",n==="yes"),t.setAttribute("data-fluid",n)},resize:t=>{const n=window.innerWidth;document.querySelectorAll(".is-box").forEach(r=>{let a=[];const l=r.attributes;for(let c=0;c<l.length;c++){let o=l[c].name.match(/^data--h-(\d+)$/);if(o){const h=parseInt(o[1],10);a.push(h)}}a=[...new Set(a)],a.sort((c,d)=>d-c);for(let c=0;c<a.length;c++){const d=a[c];if(c===0){if(n>d){let o=r.getAttribute("data--h");o?r.style.height=o:r.style.height=""}}else{const o=a[c-1];if(o>=n&&n>d){let h=r.getAttribute("data--h-"+o);h&&(r.style.height=h)}}}if(a.length>0&&a[a.length-1]>=n){const d=a[a.length-1];let o=r.getAttribute("data--h-"+d);o&&(r.style.height=o)}}),document.querySelectorAll(".is-block").forEach(r=>{if(!r.classList.contains("locked")){r.offsetWidth+0>n&&!r.classList.contains("fluid")&&(r.setAttribute("data-fluid-val",r.offsetWidth),e.applyFluid(r,"yes"));let c=r.getAttribute("data-fluid-val");c&&parseInt(c)+0<=n&&r.classList.contains("fluid")&&e.applyFluid(r,"no")}let a=[];const l=r.attributes;for(let c=0;c<l.length;c++){const d=l[c].name;let o=d.match(/^data--t-(\d+)$/);if(o){const h=parseInt(o[1],10);a.push(h)}if(o=d.match(/^data--w-(\d+)$/),o){const h=parseInt(o[1],10);a.push(h)}if(o=d.match(/^data--transform-(\d+)$/),o){const h=parseInt(o[1],10);a.push(h)}}a=[...new Set(a)],a.sort((c,d)=>d-c);for(let c=0;c<a.length;c++){const d=a[c];if(c===0)n>d&&e.apply(r,1e4,t);else{const o=a[c-1];o>=n&&n>d&&e.apply(r,o,t)}}if(a.length>0){const c=a[a.length-1];c>=n&&e.apply(r,c,t)}})},render:()=>{e.start(),e.resize(!0)}},s=((t,n)=>{let r;return(...a)=>{clearTimeout(r),r=setTimeout(()=>t(...a),n)}})(()=>{e.resize()},0);window.addEventListener("resize",s),e.start(),e.resize(!0),this.Block=e}pageReRender(){this.prepareContent(),this.contentBoxOnRenderUpdate(),window.skrollrr?window.skrollrr.refresh():this.initeSkrollrr(),this.functionLightboxInit(),this.inViewSetup(),this.Block.start(),this.Block.resize()}destroy(){this.glightbox&&(this.glightbox.destroy(),this.glightbox=null),document.querySelectorAll(".is-lightbox,.block-click").forEach(i=>{i._lightboxHandler&&(i.removeEventListener("click",i._lightboxHandler),delete i._lightboxHandler)})}}return jr})();
|
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@innovastudio/contentbox-interactive-runtime",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.2",
|
|
5
5
|
"description": "Runtime libraries for ContentBox generated content",
|
|
6
6
|
"main": "dist/contentbox-interactive-runtime.esm.js",
|
|
7
7
|
"module": "dist/contentbox-interactive-runtime.esm.js",
|