@fiddle-digital/string-tune
Version:
StringTune is a cutting-edge JavaScript library designed to deliver high-performance, modular web effects. Whether you're looking to add smooth parallax scrolling, dynamic cursor interactions, progress tracking, or autoplay videos, StringTune empowers dev
1 lines • 142 kB
JavaScript
var St=class{constructor(e=.1,t){this.SETTLE_THRESHOLD=.1;this.lastMouseX=0;this.lastMouseY=0;this.lastMouseTime=0;this.smoothingFactor=e,this.context=t,this.onSettingsChange({isDesktop:t.data.viewport.windowWidth>1024,isForceRebuild:!1,widthChanged:!0,heightChanged:!0,scrollHeightChanged:!0})}onMouseMove(e){this.context.data.cursor.targetX=e.clientX,this.context.data.cursor.targetY=e.clientY;let t=performance.now(),r=t-this.lastMouseTime;r>0&&(this.context.data.cursor.velocityX=(e.clientX-this.lastMouseX)/r,this.context.data.cursor.velocityY=(e.clientY-this.lastMouseY)/r),this.lastMouseX=e.clientX,this.lastMouseY=e.clientY,this.lastMouseTime=t}onFrame(){let{targetX:e,targetY:t,smoothedX:r,smoothedY:i}=this.context.data.cursor,n=this.context.tools.lerp.process({from:r,to:e,progress:this.smoothingFactor}),s=this.context.tools.lerp.process({from:i,to:t,progress:this.smoothingFactor}),o=this.getStepDistance(n,s);this.isSettled(o)?this.snapToTarget():this.applyStep(n,s)}onSettingsChange(e){let t=Number(this.context.settings["cursor-lerp"]);this.setLerpFactor(t)}setLerpFactor(e){this.smoothingFactor=this.context.tools.adaptiveLerp.process({value:e,inMin:.1,inMax:1,outMin:.05,outMax:.65})}getStepDistance(e,t){return Math.hypot(e,t)}isSettled(e){return e<this.SETTLE_THRESHOLD}snapToTarget(){this.context.data.cursor.smoothedX=this.context.data.cursor.targetX,this.context.data.cursor.smoothedY=this.context.data.cursor.targetY,this.context.data.cursor.stepX=0,this.context.data.cursor.stepY=0}applyStep(e,t){this.context.data.cursor.smoothedX+=e,this.context.data.cursor.smoothedY+=t,this.context.data.cursor.stepX=e,this.context.data.cursor.stepY=t}};var Q=class{constructor(){this.listeners={};this.stateEvents=new Set;this.lastPayloads={};this.stateEvents.add("screen:mobile"),this.stateEvents.add("screen:tablet"),this.stateEvents.add("screen:laptop"),this.stateEvents.add("screen:desktop"),this.stateEvents.add("start")}on(e,t,r){let i=r?`${e}:${r}`:e;this.listeners[i]||(this.listeners[i]=new Set),this.listeners[i].add(t),this.stateEvents.has(i)&&this.lastPayloads[i]!==void 0&&t(this.lastPayloads[i])}off(e,t,r){let i=r?`${e}:${r}`:e;this.listeners[i]&&this.listeners[i].delete(t)}emit(e,t){this.stateEvents.has(e)&&(this.lastPayloads[e]=t);let r=this.listeners[e];if(r)for(let i of r)i(t)}onProgress(e,t){this.on(`progress:${e}`,t)}emitProgress(e,t){this.emit(`progress:${e}`,t)}onInview(e,t){this.on(`object:inview:${e}`,t)}emitInview(e,t){this.emit(`object:inview:${e}`,t)}onScroll(e){this.on("scroll",e)}emitScroll(e){this.emit("scroll",e)}onUpdate(e){this.on("update",e)}emitUpdate(){this.emit("update")}clear(e){delete this.listeners[e]}clearAll(){this.listeners={}}};function _e(c,e,t,r){switch(c){case"onFrame":case"onMutate":case"onScrollMeasure":case"onMouseMoveMeasure":case"onScroll":return[e];case"onMouseMove":case"onWheel":return t?[t]:[];case"onDOMMutate":return t&&r?[t,r]:[];case"onSettingsChange":return[];default:return[]}}var Mt=class{constructor(e){this.data=e;this.modules=[];this.uiModules=[];this.allModules=[]}register(e){e.type===1?this.modules.push(e):e.type===2&&this.uiModules.push(e),this.rebuildAllModules()}find(e){return this.modules.find(t=>t instanceof e)}onInit(){this.callAll("onInit")}onFrame(){this.callAll("onFrame")}onMutate(){this.callAll("onMutate")}onScrollMeasure(){this.callAll("onScrollMeasure")}onMouseMoveMeasure(){this.callAll("onMouseMoveMeasure")}onScroll(){this.callAll("onScroll")}onResizeWidth(){this.callAll("onResizeWidth")}onResize(){this.callAll("onResize")}onMouseMove(e){this.callAll("onMouseMove",e)}onWheel(e){this.callAll("onWheel",e)}onDirectionChange(){this.callAll("onDirectionChange")}onScrollStart(){this.callAll("onScrollStart")}onScrollStop(){this.callAll("onScrollStop")}onAxisChange(){this.callAll("onAxisChange")}onDeviceChange(){this.callAll("onDeviceChange")}onScrollConfigChange(){this.callAll("onScrollConfigChange")}onSettingsChange(e){this.callAll("onSettingsChange")}onDOMMutate(e,t){this.callAll("onDOMMutate",e,t)}destroy(){this.callAll("destroy"),this.modules=[],this.uiModules=[],this.allModules=[]}get all(){return this.allModules}get core(){return this.modules}get ui(){return this.uiModules}callAll(e,t,r){this.callLifecycle(this.modules,e,t,r),this.callLifecycle(this.uiModules,e,t,r)}callLifecycle(e,t,r,i){if(e.length===0)return;let n=_e(t,this.data,r,i);for(let s=0;s<e.length;s++){let o=e[s];o&&o[t](...n)}}rebuildAllModules(){this.allModules=[...this.modules,...this.uiModules]}};var Et=class{constructor(e,t,r){this.parent=r;this.properties=new Map;this.id=e,this.htmlElement=t}get parentObject(){return this.parent}setProperty(e,t){this.properties.set(e,t)}getProperty(e){return this.properties.get(e)??null}setEasing(e){this.easingFn=e??void 0}getEasing(){return this.easingFn}applyProgress(e,t){let r=this.easingFn??t;return r?r(e):e}};var tt=class{constructor(e,t){this.id="";this.keys=[];this.mirrors=new Map;this.properties=new Map;this.modules=[];this.events=new Q;this.htmlElement=t,this.id=e}setProperty(e,t){this.properties.set(e,t)}getProperty(e){return this.properties.get(e)??null}enter(){this.events.emit("enter",this),this.setProperty("active",!0),this.modules.forEach(e=>{e.enterObject(this.id,this)})}leave(){this.events.emit("leave",this),this.setProperty("active",!1),this.modules.forEach(e=>{e.exitObject(this.id)})}remove(){this.modules.forEach(e=>{e.removeObject(this.id)})}show(){this.htmlElement.classList.add("-inview")}hide(){this.getProperty("repeat")&&this.htmlElement.classList.remove("-inview")}connect(e){this.modules.includes(e)||this.modules.push(e)}addMirror(e){this.mirrors.set(e.id,e)}removeMirror(e){this.mirrors.delete(e)}get mirrorObjects(){return Array.from(this.mirrors.values())}get connects(){return this.mirrorObjects.map(e=>e.htmlElement)}};var xt=class{constructor(e,t,r,i){this.data=e;this.modules=t;this.events=r;this.tools=i;this.objects=new Map;this.connectQueue=[];this.mirrors=new Map;this.mirrorId=1;this.globalId=1}get all(){return this.objects}add(e){let t=`string-${this.globalId++}`,r="string-id";e.getAttribute("string-id")&&(t=e.getAttribute("string-id"),r="string-id"),e.getAttribute("data-string-id")&&(t=e.getAttribute("data-string-id"),r="data-string-id");let i=t&&this.objects.has(t)?this.objects.get(t):new tt(t,e);e.setAttribute(r,i.id);let n=e.getAttribute("string")??e.getAttribute("data-string");n&&(i.keys=(n??"").split("|").map(a=>a.trim()).filter(Boolean)),e.setAttribute("string-inited",""),this.objects.set(i.id,i);let s=this.getAllAttributes(e);this.modules.core.forEach(a=>{"setupCoreProperties"in a&&typeof a.setupCoreProperties=="function"&&a.setupCoreProperties(i,e,s)}),this.modules.core.forEach(a=>{a.canConnect(i)&&(a.initializeObject(this.globalId,i,e,s),a.calculatePositions(i,this.data.viewport.windowHeight),a.connectObject(i),a.addObject(i.id,i))}),this.connectQueue.filter(a=>a.id===i.id).forEach(a=>this.attachMirrorToObject(i,a.element)),this.connectQueue=this.connectQueue.filter(a=>a.id!==i.id),this.initObservers(i,e),this.checkInviewForObject(i)}remove(e){let t=this.objects.get(e);t&&(t.events.clearAll(),t.getProperty("observer-progress")?.disconnect(),t.getProperty("observer-inview")?.disconnect(),t.htmlElement.removeAttribute("string-inited"),t.leave(),t.remove(),t.mirrorObjects.forEach(r=>{r.htmlElement.removeAttribute("string-mirror-id"),this.mirrors.delete(r.id);let i=r.htmlElement.getAttribute("string-copy-from")??r.htmlElement.getAttribute("data-string-copy-from");i&&this.enqueueConnection(i,r.htmlElement)}),this.objects.delete(e))}enqueueConnection(e,t){this.connectQueue.some(r=>r.id===e&&r.element===t)||this.connectQueue.push({id:e,element:t})}linkMirror(e,t){let r=this.objects.get(e);r?this.attachMirrorToObject(r,t):this.enqueueConnection(e,t)}attachMirrorToObject(e,t){let r=t.getAttribute("string-mirror-id")??t.getAttribute("data-string-mirror-id");if(r){let o=this.mirrors.get(r);if(o){if(o.parentObject===e)return o;o.parentObject.removeMirror(r),this.mirrors.delete(r)}}let i=r??`string-mirror-${this.mirrorId++}`,n=new Et(i,t,e);t.setAttribute("string-mirror-id",i),e.addMirror(n),this.mirrors.set(i,n);let s=t.getAttribute("string-easing")??t.getAttribute("data-string-easing");return s&&s.trim().length>0&&(n.setEasing(this.tools.easingFunction.process({easing:s})),n.setProperty("easing",s)),n}detachMirrorByElement(e){let t=e.getAttribute("string-mirror-id")??e.getAttribute("data-string-mirror-id");t&&(this.detachMirrorById(t),e.removeAttribute("string-mirror-id"))}detachMirrorById(e){let t=this.mirrors.get(e);t&&(t.parentObject.removeMirror(e),this.mirrors.delete(e))}getAllAttributes(e){let t={};return Array.from(e.attributes).forEach(r=>{t[r.name]=r.value}),t}initObservers(e,t){let r=e.getProperty("offset-top")??0,i=e.getProperty("offset-bottom")??0;e.getProperty("observer-progress")?.disconnect();let n=m=>{m.forEach(b=>{this.events.emit(`object:activate:${e.id}`,b.isIntersecting),b.isIntersecting?e.enter():e.leave()})},s=e.getProperty("outside-container"),o=t.getAttribute("string-outside-container")??t.getAttribute("data-string-outside-container"),a=o!=null?o.trim().toLowerCase():null,l=a===""||a==="true"||a==="1",u=s!=null?s===!0:l,p=this.data.scroll.container===document.body||u?null:this.data.scroll.container,d=new IntersectionObserver(n,{root:p,rootMargin:`${i+this.data.viewport.windowHeight}px 0px ${r+this.data.viewport.windowHeight}px 0px`,threshold:0});d.observe(t),e.setProperty("observer-progress",d)}observeDOM(){new MutationObserver(t=>{t.forEach(r=>{r.type==="childList"&&(r.removedNodes.forEach(i=>{if(i.nodeType!==Node.ELEMENT_NODE)return;let n=i;this.detachMirrorByElement(n),!this.isFixed(n)&&(n.hasAttribute("string")&&this.handleRemoved(n),n.querySelectorAll("[string],[data-string]").forEach(s=>{this.isFixed(s)||this.handleRemoved(s)}),n.querySelectorAll("[string-copy-from],[data-string-copy-from]").forEach(s=>this.detachMirrorByElement(s)))}),r.addedNodes.forEach(i=>{if(i.nodeType!==Node.ELEMENT_NODE)return;let n=i;if(this.isFixed(n))return;n.hasAttribute("string")&&!n.hasAttribute("string-inited")&&this.add(n),n.querySelectorAll("[string]:not([string-inited]),[data-string]:not([string-inited])").forEach(o=>this.add(o));let s=n.getAttribute("string-copy-from")??n.getAttribute("data-string-copy-from");s&&this.linkMirror(s,n),n.querySelectorAll("[string-copy-from],[data-string-copy-from]").forEach(o=>{let a=o.getAttribute("string-copy-from")??o.getAttribute("data-string-copy-from");a&&this.linkMirror(a,o)})}),(r.addedNodes.length>0||r.removedNodes.length>0)&&this.modules.onDOMMutate(r.addedNodes,r.removedNodes),this.modules.all.forEach(i=>i.onDOMRebuild()))})}).observe(document.body,{childList:!0,subtree:!0})}handleRemoved(e){let t=e.getAttribute("string-id")??e.getAttribute("data-string-id");if(!t)return;let r=e.getAttribute("string-copy-from")??e.getAttribute("data-string-copy-from");r&&(this.connectQueue=this.connectQueue.filter(i=>i.id!==r)),this.remove(t)}onSettingsChange(e){this.objects.forEach(t=>{this.modules.core.forEach(r=>{let i=!1;if(e.isDesktop?(r.permissions.desktop.rebuild.scrollHeight&&e.scrollHeightChanged&&(i=!0),r.permissions.desktop.rebuild.width&&e.widthChanged&&(i=!0),r.permissions.desktop.rebuild.height&&e.heightChanged&&(i=!0)):(r.permissions.mobile.rebuild.scrollHeight&&e.scrollHeightChanged&&(i=!0),r.permissions.mobile.rebuild.width&&e.widthChanged&&(i=!0),r.permissions.mobile.rebuild.height&&e.heightChanged&&(i=!0)),(i||e.isForceRebuild)&&r.canConnect(t)){let n=this.getAllAttributes(t.htmlElement);r.initializeObject(this.globalId,t,t.htmlElement,n),r.calculatePositions(t,this.data.viewport.windowHeight),r.connectObject(t)}})})}isFixed(e){return e.hasAttribute("string-fixed")}checkInview(){this.objects.forEach(e=>{this.checkInviewForObject(e)})}checkInviewForObject(e){let t=this.data.scroll.transformedCurrent,r=e.getProperty("inview-start-position"),i=e.getProperty("inview-end-position"),n=e.getProperty("is-inview")??!1,s=Math.min(r,i),o=Math.max(r,i),a=t>=s&&t<=o,l=null;if(!n&&a){let u=Math.abs(t-s),p=Math.abs(o-t);l=u<=p?"enter-top":"enter-bottom"}else n&&!a&&(l=t<s?"exit-top":"exit-bottom");a!==n&&(e.setProperty("is-inview",a),this.events.emit(`object:inview:${e.id}`,{inView:a,direction:l}),a?e.show():e.hide())}};var N=class{constructor(e){this.name="";this.isProg=!1;this.isParallaxEnabled=!1;this._scrollDirection="vertical";this.isBottomScrollDirection=null;this.isLastBottomScrollDirection=!0;this.scrollTriggerRules=[];this.onChangeDirection=()=>{};this.onScrollStart=()=>{};this.onScrollStop=()=>{};this.onCalcUpdate=()=>{this.context.data.scroll.scrollContainer?.scrollTo(0,this.context.data.scroll.current),this.triggerScrollRules()};this.document=document,this.context=e}set scrollDirection(e){this._scrollDirection=e,this._scrollDirection==="vertical"?this.onCalcUpdate=()=>{this.context.data.scroll.scrollContainer?.scrollTo(0,this.context.data.scroll.current),this.triggerScrollRules()}:this._scrollDirection==="horizontal"&&(this.onCalcUpdate=()=>{this.context.data.scroll.scrollContainer?.scrollTo(this.context.data.scroll.current,0)})}onFrame(){}onWheel(e){}onScroll(e){}disableScrollEvents(){}enableScrollEvents(){}triggerScrollRules(){this.scrollTriggerRules.forEach(e=>{(e.direction==="any"||this.isLastBottomScrollDirection&&e.direction==="forward")&&this.context.data.scroll.current>=e.offset?(e.onEnter?.(),e.toggleClass&&e.toggleClass.target.classList.add(e.toggleClass.className)):(e.onLeave?.(),e.toggleClass&&e.toggleClass.target.classList.remove(e.toggleClass.className))})}addScrollMark(e){this.scrollTriggerRules.push(e)}removeScrollMark(e){this.scrollTriggerRules=this.scrollTriggerRules.filter(t=>t.id!==e)}scrollTo(e){}};var wt=class extends N{constructor(t){super(t);this.name="default"}onFrame(){if(this.context.data.scroll.delta!==0){let t=this.context.data.scroll.delta*this.context.data.scroll.speedAccelerate;this.context.data.scroll.delta-=t,this.context.data.scroll.lerped=t,Math.abs(this.context.data.scroll.lerped)<.1&&(this.context.data.scroll.delta=0,this.context.data.scroll.lerped=0,this.onScrollStop())}}onScroll(t){let r=this.context.data.scroll.elementContainer.scrollTop;this.context.data.scroll.current=r,this.context.data.scroll.target=r,this.context.data.scroll.transformedCurrent=r}onWheel(t){if(t.deltaY!==0){this.context.data.scroll.delta===0&&this.onScrollStart();let r=t.deltaY;this.context.data.scroll.target===0&&(this.context.data.scroll.delta+=Math.max(0,t.deltaY)),this.context.data.scroll.delta+=r}}scrollTo(t){this.context.data.scroll.target=t,this.context.data.scroll.delta=1}};var Tt=class extends N{constructor(t){super(t);this.name="disable";this.preventScroll=t=>{t.preventDefault()};this.preventKeyScroll=t=>{["ArrowUp","ArrowDown","PageUp","PageDown"," ","Home","End"].includes(t.key)&&t.preventDefault()};this.onPreventScroll=this.preventScroll.bind(this);this.onPreventKeyScroll=this.preventKeyScroll.bind(this)}disableScrollEvents(){window.addEventListener("touchmove",this.onPreventScroll,{passive:!1}),window.addEventListener("keydown",this.onPreventKeyScroll)}enableScrollEvents(){window.removeEventListener("touchmove",this.onPreventScroll),window.removeEventListener("keydown",this.onPreventKeyScroll)}onFrame(){}onWheel(t){t.preventDefault()}onScroll(t){t.preventDefault()}};var X={SCROLL_FORWARD:"-scroll-forward",SCROLL_BACKWARD:"-scroll-backward",SCROLLING_FORWARD:"-scrolling-forward",SCROLLING_BACKWARD:"-scrolling-backward"};var Pt=class extends N{constructor(t){super(t);this.name="smooth";this.isScrollbarManipulation=!1;this.scrollForce=0;this.wheelImpulse=0;this.previousCurrent=0;this.velocityThreshold=.1}updateScrollDirection(t){if(this.isLastBottomScrollDirection=t,this.isBottomScrollDirection===null){this.isBottomScrollDirection=t;return}this.context.data.scroll.isScrollingDown=t,this.onChangeDirection(),this.context.events.emit("scroll:direction:change",this.context.data.scroll.isScrollingDown),this.context.settings["global-class"]&&(document.documentElement.classList.toggle(X.SCROLLING_FORWARD,t),document.documentElement.classList.toggle(X.SCROLLING_BACKWARD,!t),document.documentElement.classList.toggle(X.SCROLL_FORWARD,t),document.documentElement.classList.toggle(X.SCROLL_BACKWARD,!t))}stopScroll(){this.context.data.scroll.lerped=0,this.context.data.scroll.delta=0,this.context.data.scroll.target=this.context.data.scroll.current,this.isProg=!1,this.onCalcUpdate(),document.documentElement.classList.remove(X.SCROLLING_BACKWARD,X.SCROLLING_FORWARD),this.isBottomScrollDirection=null}onFrame(){if(this.isScrollbarManipulation){this.isScrollbarManipulation=!1,this.context.data.scroll.current=this.context.data.scroll.elementContainer.scrollTop,this.context.data.scroll.target=this.context.data.scroll.elementContainer.scrollTop,this.context.data.scroll.transformedCurrent=this.context.data.scroll.current*this.context.data.viewport.transformScale;return}if(this.context.data.scroll.delta!==0){this.scrollForce=this.context.data.scroll.delta*this.context.data.scroll.speedAccelerate,this.context.data.scroll.target=Math.min(Math.max(0,this.context.data.scroll.target+this.scrollForce),this.context.data.scroll.bottomPosition),this.context.data.scroll.delta-=this.scrollForce,this.context.data.scroll.lerped=(this.context.data.scroll.target-this.context.data.scroll.current)*this.context.data.scroll.speed;let t=Math.abs(this.context.data.scroll.lerped);this.context.data.scroll.lerped>0?this.context.data.scroll.current=Math.ceil(this.context.data.scroll.current+this.context.data.scroll.lerped):this.context.data.scroll.current=Math.floor(this.context.data.scroll.current+this.context.data.scroll.lerped),this.context.data.scroll.transformedCurrent=this.context.data.scroll.current*this.context.data.viewport.transformScale,this.updateScrollDirection(this.context.data.scroll.lerped>0),t<this.velocityThreshold?(this.stopScroll(),this.onScrollStop()):(this.isProg=!0,this.previousCurrent!==this.context.data.scroll.current&&(this.previousCurrent=this.context.data.scroll.current,this.onCalcUpdate()))}}onWheel(t){if(t.deltaY!==0&&t.preventDefault(),this.wheelImpulse=t.deltaY,this.wheelImpulse===0)return;this.context.data.scroll.delta===0&&this.onScrollStart();let r=Math.sign(this.wheelImpulse),i=this.context.data.scroll.target===0&&r<0,n=this.context.data.scroll.target===this.context.data.scroll.bottomPosition&&r>0;i||n||(this.context.data.scroll.delta+=this.wheelImpulse)}onScroll(t){this.isProg||(this.isScrollbarManipulation=!0)}scrollTo(t){this.context.data.scroll.target=t,this.context.data.scroll.delta=1}};var Ct=class{constructor(e){this.context=e;this.modes=new Map;this.modes.set("smooth",new Pt(e)),this.modes.set("default",new wt(e)),this.modes.set("disable",new Tt(e)),this.updateResponsiveMode()}setMobileMode(e){this.context.data.scroll.modeMobile=e,this.updateResponsiveMode()}setDesktopMode(e){this.context.data.scroll.modeDesktop=e,this.updateResponsiveMode()}updateResponsiveMode(){let t=window.innerWidth<1024?this.context.data.scroll.modeMobile:this.context.data.scroll.modeDesktop;this.setMode(t)}updatePosition(){this.modes.forEach(e=>{e.onCalcUpdate()})}setMode(e){if(!this.modes.has(e)){console.warn(`[ScrollManager] Unknown scroll mode: ${e}`);return}this.get().enableScrollEvents(),this.context.data.scroll.mode=e,this.get().disableScrollEvents()}get(){return this.modes.get(this.context.data.scroll.mode)}getEngines(){return this.modes}onFrame(){this.get().onFrame()}onScroll(e){this.get().onScroll(e)}onWheel(e){this.get().onWheel(e)}bindEvents(e){this.modes.forEach(t=>{t.onScrollStart=e.onScrollStart,t.onScrollStop=e.onScrollStop,t.onChangeDirection=e.onDirectionChange})}addScrollMark(e){this.modes.forEach(t=>{t.addScrollMark(e)})}removeScrollMark(e){this.modes.forEach(t=>{t.removeScrollMark(e)})}};var Lt=class{constructor(){this.targetX=0;this.targetY=0;this.smoothedX=0;this.smoothedY=0;this.stepX=0;this.stepY=0;this.velocityX=0;this.velocityY=0}};var Ot=class{constructor(){this.threeInstance=null}};var Dt=class{constructor(){this.target=0;this.current=0;this.transformedCurrent=0;this.delta=0;this.lerped=0;this.displacement=0;this.isScrollingDown=!1;this.topPosition=0;this.bottomPosition=0;this.direction="vertical";this.elementContainer=document.documentElement;this.scrollContainer=window;this.container=document.body;this.mode="smooth";this.modeMobile="smooth";this.modeDesktop="smooth";this.speed=.1;this.speedAccelerate=.25}};var kt=class{constructor(){this.fpsTracker=!1;this.positionTracker=!1}};var It=class{constructor(){this.now=0;this.previous=0;this.delta=0;this.elapsed=0}};var At=class{constructor(){this.windowWidth=0;this.windowHeight=0;this.contentWidth=0;this.contentHeight=0;this.scaleWidth=1;this.scaleHeight=1;this.transformScale=1;this.baseRem=16}};var Rt=class{constructor(){this.scroll=new Dt;this.viewport=new At;this.cursor=new Lt;this.render=new Ot;this.time=new It;this.system=new kt}};var Ft=class{constructor(){this.desktop={rebuild:{width:!0,height:!0,scrollHeight:!0}};this.mobile={rebuild:{width:!0,height:!0,scrollHeight:!0}}}};var E=class{constructor(e){this.objectMapOnPage=new Map;this.objectsOnPage=[];this.objectMap=new Map;this.objects=[];this.htmlKey="";this._type=1;this.permissions=new Ft;this.tools=e.tools,this.data=e.data,this.settings=e.settings,this.events=e.events,this.centers=e.centers,this.hover=e.hover,this.attributesToMap=[{key:"active",type:"boolean",fallback:this.settings.active},{key:"fixed",type:"boolean",fallback:this.settings.fixed},{key:"outside-container",type:"boolean",fallback:this.settings["outside-container"]},{key:"repeat",type:"boolean",fallback:this.settings.repeat},{key:"self-disable",type:"boolean",fallback:this.settings["self-disable"]},{key:"abs",type:"boolean",fallback:this.settings.abs},{key:"key",type:"string",fallback:this.settings.key},{key:"offset-top",type:"dimension",fallback:this.settings["offset-top"]},{key:"offset-bottom",type:"dimension",fallback:this.settings["offset-bottom"]},{key:"inview-top",type:"dimension",fallback:this.settings["inview-top"]},{key:"inview-bottom",type:"dimension",fallback:this.settings["inview-bottom"]},{key:"start",type:"number",fallback:(t,r,i)=>{let n=i.top;return Math.floor(n)+this.data.scroll.container.scrollTop*this.data.viewport.transformScale}},{key:"end",type:"number",fallback:(t,r,i)=>{let n=i.top,s=i.height;return n+s-this.data.scroll.transformedCurrent}},{key:"size",type:"number",fallback:(t,r,i)=>i.height},{key:"half-width",type:"number",fallback:(t,r,i)=>i.width/2},{key:"half-height",type:"number",fallback:(t,r,i)=>i.height/2},{key:"enter-el",type:"string",fallback:this.settings["enter-el"]},{key:"enter-vp",type:"string",fallback:this.settings["enter-vp"]},{key:"exit-el",type:"string",fallback:this.settings["exit-el"]},{key:"exit-vp",type:"string",fallback:this.settings["exit-vp"]}]}get type(){return this._type}initializeObject(e,t,r,i){let n=this.tools.boundingClientRect.process({element:r});for(let{key:s,type:o,fallback:a,transform:l}of this.attributesToMap){let u=typeof a=="function"?a(r,t,n):a,p=this.tools.domAttribute.process({element:r,key:s,fallback:i[s]??this.settings[s]??u}),d=this.parseAttribute(p,o,{element:r,boundingRect:n,viewportHeight:this.data.viewport.windowHeight,baseRem:this.data.viewport.baseRem});l&&(d=l(d)),t.setProperty(s,d)}}calculatePositions(e,t){let r=e.getProperty("start"),i=e.getProperty("size"),n=e.getProperty("offset-bottom"),s=e.getProperty("offset-top"),o=e.getProperty("enter-el"),a=e.getProperty("enter-vp"),l=e.getProperty("exit-el"),u=e.getProperty("exit-vp"),p=0,d=0,m=0,b=0;o==="top"&&a==="top"||o==="left"&&a==="left"?(m=-t+1,p=r-n):o==="top"&&a==="bottom"||o==="left"&&a==="right"?p=r-t-n:o==="bottom"&&a==="top"||o==="right"&&a==="left"?(m=-t-i+1,p=r+i-n):(o==="bottom"&&a==="bottom"||o==="right"&&a==="right")&&(m=-i+1,p=r-t+i-n),l==="top"&&u==="top"||l==="left"&&u==="left"?(b=-i+1,d=r+s):l==="top"&&u==="bottom"||l==="left"&&u==="right"?(b=-t-i+1,d=r-t+s):l==="bottom"&&u==="top"||l==="right"&&u==="left"?d=r+i+s:(l==="bottom"&&u==="bottom"||l==="right"&&u==="right")&&(b=-t+1,d=r-t+i+s),e.setProperty("start-bias",m),e.setProperty("end-bias",b),e.setProperty("start-position",p-this.data.scroll.topPosition),e.setProperty("end-position",d-this.data.scroll.topPosition),e.setProperty("difference-position",d-p);let h=e.getProperty("inview-top")??0,f=e.getProperty("inview-bottom")??0;e.setProperty("inview-start-position",e.getProperty("start-position")+h),e.setProperty("inview-end-position",e.getProperty("end-position")+f)}parseAttribute(e,t,r={}){if(e==null)return null;if(typeof t=="object"&&t.type==="enum")return t.values.includes(e)?e:t.values[0];switch(t){case"number":return parseFloat(e);case"boolean":return e===""||e==="true";case"json":try{return JSON.parse(e)}catch{return null}case"tuple":return e.trim().split(/\s+/);case"easing":return this.tools.easingFunction.process({easing:e});case"color":return this.tools.colorParser.process({value:e});case"dimension":return e=="0"?0:r.element!=null&&r.viewportHeight!=null&&r.baseRem!=null&&r.boundingRect!=null?this.tools.unitParser.process({value:e,element:r.element,viewportHeight:r.viewportHeight,boundingRect:r.boundingRect,baseRem:r.baseRem}):0;case"breakpoint-dimension":if(r.element!=null&&r.viewportHeight!=null&&r.baseRem!=null&&r.boundingRect!=null){let i=e.trim().split("|"),n=[];for(let s of i)if(s.includes(":")){let[o,a]=s.split(":");n.push({breakpoint:parseInt(o),value:this.tools.unitParser.process({value:`${a}|`,element:r.element,viewportHeight:r.viewportHeight,boundingRect:r.boundingRect,baseRem:r.baseRem})})}else n.push({breakpoint:0,value:this.tools.unitParser.process({value:s,element:r.element,viewportHeight:r.viewportHeight,boundingRect:r.boundingRect,baseRem:r.baseRem})});return n}default:return e}}canConnect(e){return e.keys.includes(this.htmlKey)}connectObject(e){e.connect(this),this.onObjectConnected(e)}enterObject(e,t){this.objectMap.has(e)||(this.objectMap.set(e,t),this.objects.push(t))}exitObject(e){let t=this.objectMap.get(e);if(!t)return;this.objectMap.delete(e);let r=this.objects.indexOf(t);r!==-1&&this.objects.splice(r,1)}addObject(e,t){this.objectMapOnPage.has(e)||(this.objectMapOnPage.set(e,t),this.objectsOnPage.push(t))}removeObject(e){let t=this.objectMapOnPage.get(e);if(!t)return;this.objectMapOnPage.delete(e);let r=this.objectsOnPage.indexOf(t);r!==-1&&this.objectsOnPage.splice(r,1),this.onObjectDisconnected(t)}onObjectConnected(e){}onObjectDisconnected(e){}applyToElementAndConnects(e,t,r=t){e.getProperty("self-disable")!==!0&&t(e.htmlElement),e.mirrorObjects.forEach(i=>r(i.htmlElement,i))}destroy(){this.objects=[],this.objectMap=new Map}onInit(){}onFrame(e){}onMutate(e){}onScrollMeasure(e){}onMouseMoveMeasure(e){}onResize(){}onResizeWidth(){}onScroll(e){}onDirectionChange(){}onScrollStart(){}onScrollStop(){}onScrollDirectionChange(){}onAxisChange(){}onDeviceChange(){}onScrollConfigChange(){}onSettingsChange(){}onDOMRebuild(){}onMouseMove(e){}onWheel(e){}onDOMMutate(e,t){}};var et=class{process({element:e}){return e.getBoundingClientRect()}};var rt=class{process({element:e,key:t,fallback:r=null}){return e.getAttribute(`string-${t}`)??e.getAttribute(`data-string-${t}`)??r}};var it=class{process({record:e,name:t,fallback:r=null}){return e[t]??e[`data-${t}`]??r}};var K=class{process({element:e}){let t=e.getBoundingClientRect(),i=getComputedStyle(e).transform.match(/-?[\d.]+/g)?.map(parseFloat)??[];if(i.length===6){let[n,s,o,a,l,u]=i,p=n*a-s*o;return{width:t.width/(n||1),height:t.height/(a||1),left:(t.left*a-t.top*o+o*u-l*a)/p,top:(-t.left*s+t.top*n+l*s-n*u)/p}}return t}};var nt=class{constructor(e=new K){this.transformTool=e}process({element:e,container:t=document.body}){let r;try{r=t.getBoundingClientRect()}catch{r=document.body.getBoundingClientRect()}let i=this.transformTool.process({element:e});return{top:i.top-r.top,left:i.left-r.left}}};var st=class{process({from:e,to:t,progress:r}){return(t-e)*r}};var ot=class{process({value:e,element:t,viewportHeight:r,baseRem:i,boundingRect:n}){let s=e.split("|").map(a=>a.trim()).filter(Boolean),o=0;for(let a of s){let l=a,u=!1;l.startsWith("-")&&(u=!0,l=l.slice(1));let p=0;l==="selfHeight"?p=t.offsetHeight:l.endsWith("px")?p=parseFloat(l):l.endsWith("%")?p=parseFloat(l)/100*r:l.endsWith("rem")?p=parseFloat(l)*i:l.endsWith("sh")?p=parseFloat(l)*n.height/100:p=parseFloat(l),o+=u?-p:p}return o}};var at=class{process({value:e,inMin:t=.1,inMax:r=1,outMin:i=.05,outMax:n=.65}){if(e<t)return n;if(e>1&&(e=1),e<=r){let s=(e-t)/(r-t);return n-s*(n-i)}return i}};var V={left:0,center:.5,right:1},W={top:0,center:.5,bottom:1},lt=class{process({value:e}){if(!e)return"center";let t=e.trim();if(t.startsWith("random(")&&t.endsWith(")")){let r=t.slice(7,-1).split(",").map(n=>n.trim()).filter(Boolean),i=Math.floor(Math.random()*r.length);return r[i]}return t}toNormalized({value:e}){let r=this.process({value:e}).toLowerCase().split(/\s+/).filter(Boolean);if(r.length===0)return{x:.5,y:.5};if(r.length===1){let a=r[0],l=this.parseValue(a);return a in V&&!(a in W)?{x:l,y:.5}:a in W&&!(a in V)?{x:.5,y:l}:{x:l,y:l}}let[i,n]=r,s=i in W&&!(i in V),o=n in V&&!(n in W);return s||o?{x:this.parseValue(n,"horizontal"),y:this.parseValue(i,"vertical")}:{x:this.parseValue(i,"horizontal"),y:this.parseValue(n,"vertical")}}parseValue(e,t){if(t==="horizontal"&&e in V)return V[e];if(t==="vertical"&&e in W)return W[e];if(e in V)return V[e];if(e in W)return W[e];if(e.endsWith("%")){let i=parseFloat(e);if(!isNaN(i))return i/100}let r=parseFloat(e);return isNaN(r)?.5:r>1?r/100:r}};var ct=class{process({value:e}){let t=e.trim().toLowerCase();if(t.startsWith("#")){let n=t.slice(1);n.length===3&&(n=n.split("").map(u=>u+u).join(""));let s=parseInt(n.slice(0,2),16),o=parseInt(n.slice(2,4),16),a=parseInt(n.slice(4,6),16),l=n.length===8?parseInt(n.slice(6,8),16)/255:1;return{r:s,g:o,b:a,a:l}}let r=t.match(/rgba?\(([^)]+)\)/);if(r){let[n,s,o,a=1]=r[1].split(",").map(l=>parseFloat(l.trim()));return{r:n,g:s,b:o,a}}let i=t.match(/hsla?\(([^)]+)\)/);if(i){let[n,s,o,a="1"]=i[1].split(",").map(d=>d.trim()),[l,u,p]=this.hslToRgb(parseFloat(n),parseFloat(s),parseFloat(o));return{r:l,g:u,b:p,a:parseFloat(a)}}return{r:0,g:0,b:0,a:0}}hslToRgb(e,t,r){e=e/360,t=parseFloat(t.toString())/100,r=parseFloat(r.toString())/100;let i=(u,p,d)=>(d<0&&(d+=1),d>1&&(d-=1),d<1/6?u+(p-u)*6*d:d<1/2?p:d<2/3?u+(p-u)*(2/3-d)*6:u),n=r<.5?r*(1+t):r+t-r*t,s=2*r-n,o=Math.round(i(s,n,e+1/3)*255),a=Math.round(i(s,n,e)*255),l=Math.round(i(s,n,e-1/3)*255);return[o,a,l]}};var ut=class{constructor(){this.namedCurves={linear:[0,0,1,1],ease:[.25,.1,.25,1],"ease-in":[.42,0,1,1],"ease-out":[0,0,.58,1],"ease-in-out":[.42,0,.58,1]}}process({easing:e}){let t=e.trim();if(this.namedCurves[t])return this.cubicBezier(...this.namedCurves[t]);let r=t.match(/^cubic-bezier\s*\(\s*([-+]?\d*\.?\d+)\s*,\s*([-+]?\d*\.?\d+)\s*,\s*([-+]?\d*\.?\d+)\s*,\s*([-+]?\d*\.?\d+)\s*\)$/);if(r){let[i,n,s,o]=r.slice(1).map(Number);return this.cubicBezier(i,n,s,o)}return i=>i}cubicBezier(e,t,r,i){let n=3*e,s=3*(r-e)-n,o=1-n-s,a=3*t,l=3*(i-t)-a,u=1-a-l;function p(h){return((o*h+s)*h+n)*h}function d(h){return((u*h+l)*h+a)*h}function m(h){return(3*o*h+2*s)*h+n}function b(h,f=1e-5){let g,y,v=h,S,M,w;for(w=0;w<8;w++){if(S=p(v)-h,Math.abs(S)<f)return v;if(M=m(v),Math.abs(M)<1e-6)break;v=v-S/M}for(g=0,y=1,v=h;g<y;){if(S=p(v)-h,Math.abs(S)<f)return v;S>0?y=v:g=v,v=(y+g)/2}return v}return function(h){return d(b(h))}}};var pt=class{process({distance:e,radius:t,strength:r}){if(e>=t)return 0;let i=(t-e)/t;return r*i}};var dt=class{process({from:e,to:t,progress:r}){return{r:e.r+(t.r-e.r)*r,g:e.g+(t.g-e.g)*r,b:e.b+(t.b-e.b)*r,a:e.a+(t.a-e.a)*r}}};var ht=class{process({from:e,to:t,progress:r}){return{x:(t.x-e.x)*r,y:(t.y-e.y)*r}}};var mt=class{process({value:e}){let r=e?.trim();if(!r||r==="none")return 1;try{if(r.startsWith("matrix(")){let i=r.match(/matrix\(([^)]+)\)/);if(i&&i[1]){let n=i[1].split(",").map(s=>parseFloat(s.trim()));if(n.length>=1&&!isNaN(n[0]))return n[0]}}if(r.startsWith("scale(")){let i=r.match(/scale\(([^)]+)\)/);if(i&&i[1]){let n=i[1].split(",").map(s=>parseFloat(s.trim()));if(n.length>=1&&!isNaN(n[0]))return n[0]}}if(r.startsWith("scaleX(")){let i=r.match(/scaleX\(([^)]+)\)/);if(i&&i[1]){let n=parseFloat(i[1].trim());if(!isNaN(n))return n}}if(r.startsWith("scale3d(")){let i=r.match(/scale3d\(([^)]+)\)/);if(i&&i[1]){let n=i[1].split(",").map(s=>parseFloat(s.trim()));if(n.length>=1&&!isNaN(n[0]))return n[0]}}if(r.startsWith("matrix3d(")){let i=r.match(/matrix3d\(([^)]+)\)/);if(i&&i[1]){let n=i[1].split(",").map(s=>parseFloat(s.trim()));if(n.length>=1&&!isNaN(n[0]))return n[0]}}}catch(i){return console.error(`Error parsing transform string "${r}":`,i),1}return 1}};var Ht=class{process({attributeValue:e}){let t={line:[],word:[],char:[],charLine:[],charWord:[],wordLine:[]};return e&&e.split("|").forEach(i=>{let n=i.trim();if(!n)return;let s=n.match(/^(\w+-)?(\w+)(\[(.*?)\])?$/);if(s){let o=s[1]||"",a=s[2],l=o+a,p=(s[4]||"").split(";").map(m=>m.trim()).filter(m=>m.length>0),d=this.parseParamsArray(p);switch(l){case"line":t.line.push(d);break;case"word":t.word.push(d);break;case"char":t.char.push(d);break;case"charLine":t.charLine.push(d);break;case"charWord":t.charWord.push(d);break;case"wordLine":t.wordLine.push(d);break;default:console.warn(`SplitOptionsParserTool: Unrecognized option type "${l}" in part "${n}"`);break}}else console.warn(`SplitOptionsParserTool: Could not parse part format "${n}"`)}),t}parseParamsArray(e){let t={align:"start"};return e.forEach(r=>{if(r==="abs")t.abs=!0;else if(r.startsWith("random")){t.align="random";let i=r.match(/random\(\s*(\d+)\s*,\s*(\d+)\s*\)/);i&&(t.random={min:parseInt(i[1],10),max:parseInt(i[2],10)})}else["start","center","end"].includes(r)&&(t.align=r)}),t}};var gt=class{process({value:e}){let t=[],r="",i=0;for(let n=0;n<e.length;n++){let s=e[n];s==="("&&i++,s===")"&&i--,s==="|"&&i===0?(r.trim()&&t.push(r.trim()),r=""):r+=s}return r.trim()&&t.push(r.trim()),t.map(n=>{let s=n.match(/^(\w+)(?:\((.*)\))?$/);if(s){let[,a,l]=s;return l?{key:a,params:l.split(",").map(u=>u.trim())}:{key:a}}let o=n.indexOf(":");if(o!==-1){let a=n.slice(0,o).trim(),l=n.slice(o+1).trim(),u=l?l.split(",").map(p=>p.trim()):void 0;return{key:a,params:u}}return{key:n}})}};var Nt=class{constructor(){this.inputValidators={required:e=>e!=null&&String(e).trim()!=="",min:(e,t)=>typeof e=="string"&&e.length>=Number(t?.[0]??0),max:(e,t)=>typeof e=="string"&&e.length<=Number(t?.[0]??Number.MAX_SAFE_INTEGER),checked:e=>{if(Array.isArray(e))return e.length>0;if(e===!0||e==="true"||e===1||e==="1")return!0;if(typeof e=="string"){let t=e.trim().toLowerCase();return t==="false"||t==="0"?!1:t.length>0}return!!e},email:e=>typeof e=="string"&&/^[\w-.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e),phone:e=>{if(typeof e!="string")return!1;let t=e.trim();if(t===""||!/^[0-9()\s+-.]+$/.test(t))return!1;let r=t.replace(/\D/g,"").length;return r>=7&&r<=15},number:e=>typeof e=="string"&&/^-?\d+(\.\d+)?$/.test(e),integer:e=>typeof e=="string"&&/^-?\d+$/.test(e),url:e=>typeof e=="string"&&/^(https?:\/\/)?([\w\-]+\.)+[\w\-]+(\/[\w\-._~:\/?#[\]@!$&'()*+,;=]*)?$/.test(e),regex:(e,t)=>this.testByRegex(e,t?.[0]),alpha:e=>this.testByRegex(e,"^[A-Za-z]+$",!0),alpha_num:e=>this.testByRegex(e,"^[A-Za-z0-9]+$",!0),alpha_dash:e=>this.testByRegex(e,"^[A-Za-z0-9_-]+$",!0),same:(e,t,r)=>{let i=t?.[0],n=this.getContextValue(r,i);return i&&n===void 0?!1:this.areValuesEqual(e,n)},different:(e,t,r)=>{let i=t?.[0],n=this.getContextValue(r,i);return i&&n===void 0?!1:!this.areValuesEqual(e,n)},range:(e,t)=>{if(e==null||e==="")return!0;let r=Number(e),i=Number(t?.[0]),n=Number(t?.[1]);return Number.isNaN(r)||Number.isNaN(i)||Number.isNaN(n)?!1:r>=i&&r<=n},digits:(e,t)=>{if(typeof e!="string")return!1;let r=Number(t?.[0]??0);return r<=0?!1:new RegExp(`^\\d{${r}}$`).test(e)},ip:e=>typeof e=="string"&&(this.isIPv4(e)||this.isIPv6(e)),mimes:(e,t)=>this.validateMimes(e,t),max_size:(e,t)=>{let r=Number(t?.[0]);return!r||r<=0?!0:this.validateMaxSize(e,r)},after:(e,t,r)=>this.compareDates(e,t,r,"after"),before:(e,t,r)=>this.compareDates(e,t,r,"before")};this.beforeInputValidators={number:e=>/^-?\d*\.?\d*$/.test(e),integer:e=>/^-?\d*$/.test(e),email:e=>/^[\w@.\-+]*$/.test(e),phone:e=>/^[0-9()\s+-.]*$/.test(e),letters:e=>/^[a-zA-Z]*$/.test(e),lettersSpaces:e=>/^[a-zA-Z\s]*$/.test(e),lettersNumbers:e=>/^[a-zA-Z0-9]*$/.test(e),alpha:e=>/^[A-Za-z]*$/.test(e),alpha_num:e=>/^[A-Za-z0-9]*$/.test(e),alpha_dash:e=>/^[A-Za-z0-9_-]*$/.test(e),digits:(e,t)=>{let r=Number(t?.[0]??0);return r<=0?/^\d*$/.test(e):new RegExp(`^\\d{0,${r}}$`).test(e)},url:e=>/^[a-zA-Z0-9\-._~:\/?#\[\]@!$&'()*+,;=%]*$/.test(e),pattern:(e,t)=>{try{return new RegExp(t?.[0]||"").test(e)}catch{return!0}}}}process({rules:e,value:t,type:r="input",context:i}){let n=[];for(let u of e){var s=null,o=null,a=!0,l=!0;r=="input"&&(o=this.inputValidators[u.key],!o)||r=="beforeinput"&&(s=this.beforeInputValidators[u.key],!s)||(o&&(a=o(t,u.params,i)),s&&(l=s(t,u.params,i)),l||n.push(this.getErrorMessage(u.key,u.params)),a||n.push(this.getErrorMessage(u.key,u.params)))}return{valid:n.length===0,errors:n}}getErrorMessage(e,t){switch(e){case"required":return"This field is required";case"email":return"Invalid email address";case"min":return`Minimum ${t?.[0]} characters`;case"max":return`Maximum ${t?.[0]} characters`;case"phone":return"Invalid phone number";case"number":return"Only numbers are allowed";case"integer":return"Only whole numbers are allowed";case"url":return"Invalid URL address";case"checked":return"You must accept";case"regex":return"Value does not match the required pattern";case"alpha":return"Only letters are allowed";case"alpha_num":return"Only letters and numbers are allowed";case"alpha_dash":return"Only letters, numbers, dashes, and underscores are allowed";case"same":return"Values do not match";case"different":return"Values must be different";case"range":return`Value must be between ${t?.[0]} and ${t?.[1]}`;case"digits":return`Value must contain exactly ${t?.[0]} digits`;case"ip":return"Invalid IP address";case"mimes":return`Allowed file types: ${t?.join(", ")}`;case"max_size":return`File must be smaller than ${t?.[0]} KB`;case"after":return`Date must be after ${t?.[0]}`;case"before":return`Date must be before ${t?.[0]}`;default:return"Invalid value"}}validateMimes(e,t){if(!t||t.length===0)return!0;let r=this.extractFiles(e);if(r.length===0)return!0;let i=t.map(n=>n.trim().toLowerCase());return r.every(n=>this.isMimeAllowed(n,i))}validateMaxSize(e,t){let r=this.extractFiles(e);if(r.length===0)return!0;let i=t*1024;return r.every(n=>typeof n.size!="number"?!0:n.size<=i)}extractFiles(e){if(!e)return[];let t=[];return typeof File<"u"&&e instanceof File?(t.push(e),t):typeof FileList<"u"&&e instanceof FileList?Array.from(e):Array.isArray(e)?(e.forEach(r=>{t.push(...this.extractFiles(r))}),t):typeof e=="object"&&("name"in e||"size"in e||"type"in e)?(t.push(e),t):(typeof e=="string"&&e!==""&&t.push({name:e}),t)}isMimeAllowed(e,t){let r=(e.type||"").toLowerCase(),i=this.getFileExtension(e.name);return t.some(n=>{let s=n.replace(/^\./,"").toLowerCase();return s?s.includes("/")?r===s:i===s:!1})}getFileExtension(e){if(!e)return"";let t=e.split(".");return t.length<=1?"":(t.pop()||"").toLowerCase()}compareDates(e,t,r,i){if(e==null||e==="")return!0;let n=t?.[0];if(!n)return!0;let s=this.toDate(e),o=this.resolveDateReference(n,r);return!s||!o?!1:i==="after"?s.getTime()>o.getTime():s.getTime()<o.getTime()}resolveDateReference(e,t){let r=this.getContextValue(t,e);if(r!==void 0)return this.toDate(r);if(e.toLowerCase()==="now")return new Date;if(e.toLowerCase()==="today"){let i=new Date;return i.setHours(0,0,0,0),i}return this.toDate(e)}toDate(e){if(e==null||e==="")return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:e;if(typeof e=="number"){let t=new Date(e);return Number.isNaN(t.getTime())?null:t}if(typeof e=="string"){let t=Date.parse(e);if(!Number.isNaN(t))return new Date(t)}return null}testByRegex(e,t,r=!1){if(t==null||t==="")return!0;let i=typeof e=="string"?e:e==null?"":String(e);if(r&&i==="")return!0;try{let{source:n,flags:s}=this.normalizeRegex(t);return new RegExp(n,s).test(i)}catch{return!0}}normalizeRegex(e){let t=e.trim();if(t.startsWith("/")&&t.lastIndexOf("/")>0){let r=t.lastIndexOf("/"),i=t.slice(1,r),n=t.slice(r+1);return{source:i,flags:n}}return{source:t,flags:""}}getContextValue(e,t){if(!(!e||!t)){if(e.values&&Object.prototype.hasOwnProperty.call(e.values,t))return e.values[t];if(e.getValue)return e.getValue(t)}}areValuesEqual(e,t){return Array.isArray(e)||Array.isArray(t)?JSON.stringify(e)===JSON.stringify(t):e===t}isIPv4(e){let t=e.split(".");return t.length!==4?!1:t.every(r=>{if(!/^\d+$/.test(r))return!1;let i=Number(r);return i>=0&&i<=255})}isIPv6(e){if(!e)return!1;if(e==="::")return!0;let t=e.split("::");if(t.length>2)return!1;let r=/^[0-9a-fA-F]{1,4}$/,i=e.split(":");return t.length===2?i.every(n=>n===""||r.test(n))&&i.length<=8:i.length===8&&i.every(n=>r.test(n))}};var Vt=class{constructor(){this.domAttribute=new rt;this.recordAttribute=new it;this.transformNullify=new K;this.boundingClientRect=new et;this.relativePosition=new nt(this.transformNullify);this.unitParser=new ot;this.lerp=new st;this.adaptiveLerp=new at;this.originParser=new lt;this.colorParser=new ct;this.validation=new Nt;this.easingFunction=new ut;this.magneticPull=new pt;this.lerpColor=new dt;this.lerpVector=new ht;this.transformScaleParser=new mt;this.optionsParser=new Ht;this.ruleParser=new gt}};function Wt(){let c=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)").matches:!1,e=typeof navigator<"u"?(navigator.maxTouchPoints||0)>0:!1,t=typeof window<"u"?window.innerWidth<=768:!1;return c||e||t}var Kt=class{constructor(){this.pendingVars=new Map;this.pendingProps=new Map;this.isOpen=!1}begin(){this.isOpen||(this.isOpen=!0)}setVars(e,t){if(!this.isOpen){console.warn("StyleTxn: call begin() first to set custom properties.");return}let r=this.pendingVars.get(e)??{};for(let[i,n]of Object.entries(t))r[i]!==n&&(r[i]=n);this.pendingVars.set(e,r)}setProps(e,t){if(!this.isOpen){console.warn("StyleTxn: call begin() first to set standard properties.");return}let r=this.pendingProps.get(e)??{};for(let[i,n]of Object.entries(t))r[i]!==n&&(r[i]=n);this.pendingProps.set(e,r)}run(e){let t=this.isOpen;t||this.begin();try{e(),t||this.commit()}catch(r){throw t||this.cancel(),r}}commit(){if(this.isOpen){this.isOpen=!1;for(let[e,t]of this.pendingVars){let r=e.style;for(let[i,n]of Object.entries(t))r.setProperty(i,String(n))}this.pendingVars.clear();for(let[e,t]of this.pendingProps){let r=e.style;for(let[i,n]of Object.entries(t))r[i]=String(n)}this.pendingProps.clear()}}cancel(){this.pendingVars.clear(),this.pendingProps.clear(),this.isOpen=!1}},C=new Kt;var we=new WeakMap,A=5e-4,Z="default",Gt="[string-cursor],[data-string-cursor]",Te="[string-cursor-content],[data-string-cursor-content]",Qt=1/240;function qe(c){let e=we.get(c);return e||(e={prevX:Number.NaN,prevY:Number.NaN},we.set(c,e)),e}var Zt=class extends E{constructor(t){super(t);this.cursorPrev={x:Number.NaN,y:Number.NaN,stepX:Number.NaN,stepY:Number.NaN};this.cursorPortals=new Map;this.hoveredObjects=new Set;this.globalListenersBound=!1;this.boundBeforeUnload=()=>this.cleanupHoverTargets();this.boundPageHide=()=>this.cleanupHoverTargets();this.boundVisibilityChange=()=>{document.hidden&&this.cleanupHoverTargets()};this.enabled=!0;this.lastFrameTime=0;this.htmlKey="cursor",this.permissions.mobile.rebuild.height=!1,this.permissions.mobile.rebuild.width=!1,this.permissions.mobile.rebuild.scrollHeight=!1,this.attributesToMap=[...this.attributesToMap,{key:"target-disable",type:"boolean",fallback:this.settings["target-disable"]},{key:"target-style-disable",type:"boolean",fallback:this.settings["target-style-disable"]},{key:"cursor-target",type:"string",fallback:this.settings["cursor-target"]??Z},{key:"target-class",type:"string",fallback:this.settings["target-class"]},{key:"cursor-class",type:"string",fallback:this.settings["cursor-class"]},{key:"alignment",type:{type:"enum",values:["start","center","end"]},fallback:this.settings.alignment},{key:"lerp",type:"number",fallback:this.settings.lerp,transform:r=>this.tools.adaptiveLerp.process({value:r,inMin:.1,inMax:1,outMin:.05,outMax:.65})}],Wt()&&(this.enabled=!1),this.collectCursorPortals(),this.enabled&&this.bindGlobalLifecycleListeners()}initializeObject(t,r,i,n){super.initializeObject(t,r,i,n),r.setProperty("mouse-x",0),r.setProperty("mouse-y",0),r.setProperty("mouse-pixel-x",0),r.setProperty("mouse-pixel-y",0),r.setProperty("is-mouse-over",!1),r.setProperty("is-mouse-move",!1)}onMutate(t){if(!this.enabled)return;let r=performance.now(),i=this.lastFrameTime?(r-this.lastFrameTime)/1e3:.016;this.lastFrameTime=r,i>.1&&(i=.1),i<Qt&&(i=Qt);let n=this.data.cursor.targetX,s=this.data.cursor.targetY;if(this.objects.forEach(o=>{let a=o.getProperty("is-mouse-over"),l=o.getProperty("cursor-target-disable"),u=o.getProperty("lerp")??.15,p=this.getFrameAdjustedLerp(u,i),d=this.getObjectDimensions(o),{halfWidth:m,halfHeight:b,width:h,height:f}=d;if(a&&!l){let{cx:g,cy:y}=this.centers.getCenter(o),v=n-(g-m),S=s-(y-b),M=o.getProperty("mouse-pixel-x")??0,w=o.getProperty("mouse-pixel-y")??0,x=M-v,P=w-S;if(x*x+P*P>1e-4){(o.getProperty("is-mouse-move")??!1)||(o.setProperty("is-mouse-move",!0),o.setProperty("mouse-pixel-x",v),o.setProperty("mouse-pixel-y",S),o.setProperty("mouse-x",v),o.setProperty("mouse-y",S),M=v,w=S,this.events.emit(`cursor:start:${o.id}`,null));let D=this.tools.lerp.process({from:M,to:v,progress:p}),L=this.tools.lerp.process({from:w,to:S,progress:p}),k=M+D,I=w+L,H=Math.abs(k-M)>A||Math.abs(I-w)>A;o.setProperty("mouse-pixel-x",k),o.setProperty("mouse-pixel-y",I);let j=o.getProperty("alignment")??"center",U=this.calculateOffset(j,k,h),Y=this.calculateOffset(j,I,f);o.setProperty("mouse-x",U),o.setProperty("mouse-y",Y),this.setMouseCoordinates(o,U,Y)&&this.events.emit(`cursor:move:${o.id}`,{x:U,y:Y}),H&&this.events.emit(`cursor:pixel:${o.id}`,{x:k,y:I})}else o.setProperty("mouse-pixel-x",v),o.setProperty("mouse-pixel-y",S),o.getProperty("is-mouse-move")&&(o.setProperty("is-mouse-move",!1),this.events.emit(`cursor:end:${o.id}`,null)),this.setMouseCoordinates(o,0,0)}else{let g=o.getProperty("mouse-x")??0,y=o.getProperty("mouse-y")??0;if(g!==0||y!==0){o.setProperty("is-mouse-move",!1);let v=this.calculateOffset("center",m,h),S=this.calculateOffset("center",b,f),M=g+this.tools.lerp.process({from:g,to:v,progress:p}),w=y+this.tools.lerp.process({from:y,to:S,progress:p});o.setProperty("mouse-x",M),o.setProperty("mouse-y",w),Math.abs(M)<.001&&Math.abs(w)<.001?(o.setProperty("mouse-x",0),o.setProperty("mouse-y",0),o.setProperty("mouse-pixel-x",0),o.setProperty("mouse-pixel-y",0),this.setMouseCoordinates(o,0,0)):this.setMouseCoordinates(o,M,w)}}}),this.cursorPortals.size>0){let{stepX:o,stepY:a,smoothedX:l,smoothedY:u}=this.data.cursor,p=this.cursorPrev;(!Number.isFinite(p.x)||Math.abs(l-p.x)>A||Math.abs(u-p.y)>A||Math.abs(o-p.stepX)>A||Math.abs(a-p.stepY)>A)&&(this.events.emit("cursor",{stepX:o,stepY:a,x:l,y:u}),this.cursorPrev={x:l,y:u,stepX:o,stepY:a});let m=this.data.cursor.targetX,b=this.data.cursor.targetY;this.cursorPortals.forEach(h=>{h.forEach(f=>{this.updatePortalPosition(f,m,b,i)})})}}onObjectConnected(t){let r=t.htmlElement;this.centers.attach(t),t.setProperty("mouseleave",()=>{this.onMouseLeave(t)}),t.setProperty("mouseenter",()=>{this.onMouseEnter(t)}),t.setProperty("onEnterEvent",this.onEnterObject.bind(this)),t.events.on("enter",t.getProperty("onEnterEvent")),t.setProperty("onLeaveEvent",this.onLeaveObject.bind(this)),t.events.on("leave",t.getProperty("onLeaveEvent"))}getCursorClass(t){let r=t.getProperty("cursor-class");return r!=null&&r.length>0?r:null}onMouseEnter(t){if(!document.contains(t.htmlElement))return;t.setProperty("is-mouse-over",!0),this.hoveredObjects.add(t);let r=this.getCursorClass(t);this.withPortalsForObject(t,i=>{r&&i.element.classList.add(r),this.incrementPortalHover(i)}),t.htmlElement.addEventListener("mouseleave",t.getProperty("mouseleave"))}onMouseLeave(t){t.setProperty("is-mouse-over",!1),this.hoveredObjects.delete(t);let r=this.getCursorClass(t);this.withPortalsForObject(t,i=>{r&&i.element.classList.remove(r),this.decrementPortalHover(i)}),document.contains(t.htmlElement)&&t.htmlElement.removeEventListener("mouseleave",t.getProperty("mouseleave"))}onEnterObject(t){t.htmlElement.addEventListener("mouseenter",t.getProperty("mouseenter"))}onLeaveObject(t){t.htmlElement.removeEventListener("mouseenter",t.getProperty("mouseenter")),t.htmlElement.removeEventListener("mouseleave",t.getProperty("mouseleave"))}safariNavigationCleanup(t){t.getProperty("is-mouse-over")&&this.onMouseLeave(t)}onElementRemovedFromDOM(t){t.getProperty("is-mouse-over")&&this.onMouseLeave(t)}onObjectDisconnected(t){t.getProperty("is-mouse-over")&&this.onMouseLeave(t)}onDOMRebuild(){this.enabled&&this.collectCursorPortals()}onDOMMutate(t,r){this.enabled&&((this.shouldRefreshPortals(t)||this.shouldRefreshPortals(r))&&this.collectCursorPortals(),r.length>0&&this.handleRemovedNodes(r))}collectCursorPortals(){this.cursorPortals.clear(),document.querySelectorAll(Gt).forEach(r=>{if(!(r instanceof HTMLElement))return;let i=this.resolvePortalId(r),n=this.resolvePortalLerp(r),s=r.matches(Te)?r:r.querySelector(Te),o=this.data.cursor.targetX,a=this.data.cursor.targetY,l={id:i,element:r,content:s,prev:{x:o,y:a,stepX:0,stepY:0},hoverCount:0,showTimer:null,lerp:n},u=this.cursorPortals.get(i);u?u.push(l):this.cursorPortals.set(i,[l])})}resolvePortalId(t){let r=[t.getAttribute("data-string-cursor"),t.getAttribute("string-cursor"),t.getAttribute("data-string-cursor-id"),t.getAttribute("string-cursor-id")];for(let i of r)if(i&&i.trim().length>0)return i.trim();return Z}resolvePortalLerp(t){let r=t.getAttribute("data-string-cursor-lerp")??t.getAttribute("string-cursor-lerp")??th