@frybynite/image-cloud 0.4.1 → 0.5.0

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.
@@ -1,4 +1,4 @@
1
- (function(T,V){typeof exports=="object"&&typeof module<"u"?V(exports):typeof define=="function"&&define.amd?define(["exports"],V):(T=typeof globalThis<"u"?globalThis:T||self,V(T.ImageCloud={}))})(this,(function(T){"use strict";const V=Object.freeze({none:"none",sm:"0 2px 4px rgba(0,0,0,0.1)",md:"0 4px 16px rgba(0,0,0,0.4)",lg:"0 8px 32px rgba(0,0,0,0.5)",glow:"0 0 30px rgba(255,255,255,0.6)"}),lt=Object.freeze({energetic:Object.freeze({overshoot:.25,bounces:2,decayRatio:.5}),playful:Object.freeze({overshoot:.15,bounces:1,decayRatio:.5}),subtle:Object.freeze({overshoot:.08,bounces:1,decayRatio:.5})}),ht=Object.freeze({gentle:Object.freeze({stiffness:150,damping:30,mass:1,oscillations:2}),bouncy:Object.freeze({stiffness:300,damping:15,mass:1,oscillations:4}),wobbly:Object.freeze({stiffness:180,damping:12,mass:1.5,oscillations:5}),snappy:Object.freeze({stiffness:400,damping:25,mass:.8,oscillations:2})}),dt=Object.freeze({gentle:Object.freeze({amplitude:30,frequency:1.5,decay:!0,decayRate:.9,phase:0}),playful:Object.freeze({amplitude:50,frequency:2.5,decay:!0,decayRate:.7,phase:0}),serpentine:Object.freeze({amplitude:60,frequency:3,decay:!1,decayRate:1,phase:0}),flutter:Object.freeze({amplitude:20,frequency:4,decay:!0,decayRate:.5,phase:0})}),ut=Object.freeze({type:"linear"}),gt=Object.freeze({mode:"none"}),mt=Object.freeze({mode:"none"}),It=Object.freeze({default:Object.freeze({border:Object.freeze({width:0,color:"#000000",radius:0,style:"solid"}),shadow:"none",filter:Object.freeze({}),opacity:1,cursor:"pointer",outline:Object.freeze({width:0,color:"#000000",style:"solid",offset:0})}),hover:Object.freeze({shadow:"none"}),focused:Object.freeze({shadow:"none"})}),Zt=Object.freeze({rows:1,amplitude:100,frequency:2,phaseShift:0,synchronization:"offset"}),Kt=Object.freeze({mobile:Object.freeze({maxWidth:767}),tablet:Object.freeze({maxWidth:1199})}),Qt=Object.freeze({mode:"adaptive",minSize:50,maxSize:400,variance:Object.freeze({min:1,max:1})}),te=Object.freeze({mode:"none",range:Object.freeze({min:-15,max:15})}),Tt=Object.freeze({sizing:Qt,rotation:te}),ft=Object.freeze({validateUrls:!0,validationTimeout:5e3,validationMethod:"head",allowedExtensions:["jpg","jpeg","png","gif","webp","bmp"]}),At=Object.freeze({enabled:!1,centers:!1,loaders:!1}),b=Object.freeze({loaders:[],config:Object.freeze({loaders:ft,debug:At}),image:Tt,layout:Object.freeze({algorithm:"radial",scaleDecay:0,responsive:Kt,targetCoverage:.6,densityFactor:1,spacing:Object.freeze({padding:50,minGap:20})}),animation:Object.freeze({duration:600,easing:Object.freeze({default:"cubic-bezier(0.4, 0.0, 0.2, 1)",bounce:"cubic-bezier(0.68, -0.55, 0.265, 1.55)",focus:"cubic-bezier(0.4, 0.0, 0.2, 1)"}),queue:Object.freeze({enabled:!0,interval:150,maxConcurrent:void 0}),performance:Object.freeze({useGPU:void 0,reduceMotion:void 0}),entry:Object.freeze({start:Object.freeze({position:"nearest-edge",offset:100,circular:Object.freeze({radius:"120%",distribution:"even"})}),timing:Object.freeze({duration:600,stagger:150}),easing:"cubic-bezier(0.25, 1, 0.5, 1)",path:ut,rotation:gt,scale:mt})}),interaction:Object.freeze({focus:Object.freeze({scalePercent:.8,zIndex:1e3,animationDuration:void 0}),navigation:Object.freeze({keyboard:void 0,swipe:void 0,mouseWheel:void 0}),gestures:Object.freeze({pinchToZoom:void 0,doubleTapToFocus:void 0})}),rendering:Object.freeze({responsive:Object.freeze({breakpoints:Object.freeze({mobile:768,tablet:void 0,desktop:void 0}),mobileDetection:()=>typeof window>"u"?!1:window.innerWidth<=768}),ui:Object.freeze({showLoadingSpinner:!1,showImageCounter:!1,showThumbnails:void 0,theme:void 0}),performance:Object.freeze({lazyLoad:void 0,preloadCount:void 0,imageQuality:void 0})}),styling:It});function tt(n,t){if(!n)return t||{};if(!t)return{...n};const e={...n};return t.border!==void 0&&(e.border={...n.border,...t.border}),t.borderTop!==void 0&&(e.borderTop={...n.borderTop,...t.borderTop}),t.borderRight!==void 0&&(e.borderRight={...n.borderRight,...t.borderRight}),t.borderBottom!==void 0&&(e.borderBottom={...n.borderBottom,...t.borderBottom}),t.borderLeft!==void 0&&(e.borderLeft={...n.borderLeft,...t.borderLeft}),t.filter!==void 0&&(e.filter={...n.filter,...t.filter}),t.outline!==void 0&&(e.outline={...n.outline,...t.outline}),t.shadow!==void 0&&(e.shadow=t.shadow),t.opacity!==void 0&&(e.opacity=t.opacity),t.cursor!==void 0&&(e.cursor=t.cursor),t.className!==void 0&&(e.className=t.className),t.objectFit!==void 0&&(e.objectFit=t.objectFit),t.aspectRatio!==void 0&&(e.aspectRatio=t.aspectRatio),t.borderRadiusTopLeft!==void 0&&(e.borderRadiusTopLeft=t.borderRadiusTopLeft),t.borderRadiusTopRight!==void 0&&(e.borderRadiusTopRight=t.borderRadiusTopRight),t.borderRadiusBottomRight!==void 0&&(e.borderRadiusBottomRight=t.borderRadiusBottomRight),t.borderRadiusBottomLeft!==void 0&&(e.borderRadiusBottomLeft=t.borderRadiusBottomLeft),e}function ee(n,t){if(!t)return{...n};const e=tt(n.default,t.default),i=tt(tt(e,n.hover),t.hover),o=tt(tt(e,n.focused),t.focused);return{default:e,hover:i,focused:o}}function ie(n,t){if(!t)return{...n};const e={...n};if(t.sizing!==void 0&&(e.sizing={...n.sizing,...t.sizing},t.sizing.variance)){const i=t.sizing.variance,o=i.min!==void 0&&i.min>=.25&&i.min<=1?i.min:n.sizing?.variance?.min??1,s=i.max!==void 0&&i.max>=1&&i.max<=1.75?i.max:n.sizing?.variance?.max??1;e.sizing.variance={min:o,max:s}}if(t.rotation!==void 0&&(e.rotation={...n.rotation,...t.rotation},t.rotation.range)){const i=t.rotation.range,o=i.min!==void 0&&i.min>=-180&&i.min<=0?i.min:n.rotation?.range?.min??-15,s=i.max!==void 0&&i.max>=0&&i.max<=180?i.max:n.rotation?.range?.max??15;e.rotation.range={min:o,max:s}}return e}function ne(n){const t=n.layout?.rotation;if(t&&"enabled"in t)return{rotation:{mode:t.enabled?"random":"none",range:t.range}}}function oe(n){const t=n.layout?.sizing?.variance;if(t)return{sizing:{mode:"adaptive",variance:t}}}function se(n={}){const t=ne(n),e=oe(n);let i=n.image;(t||e)&&(i={...e||{},...t||{},...i},i.rotation&&t?.rotation&&n.image?.rotation&&(i.rotation={...t.rotation,...n.image.rotation}));const o=[...n.loaders??[]];n.images&&n.images.length>0&&o.unshift({static:{sources:[{urls:n.images}]}});const r={loaders:{...ft,...n.config?.loaders??{}}},a={loaders:o,config:r,image:ie(Tt,i),layout:{...b.layout},animation:{...b.animation},interaction:{...b.interaction},rendering:{...b.rendering},styling:ee(It,n.styling)};return n.layout&&(a.layout={...b.layout,...n.layout},n.layout.responsive&&(a.layout.responsive={...b.layout.responsive,mobile:n.layout.responsive.mobile?{...b.layout.responsive.mobile,...n.layout.responsive.mobile}:b.layout.responsive.mobile,tablet:n.layout.responsive.tablet?{...b.layout.responsive.tablet,...n.layout.responsive.tablet}:b.layout.responsive.tablet}),n.layout.spacing&&(a.layout.spacing={...b.layout.spacing,...n.layout.spacing})),n.animation&&(a.animation={...b.animation,...n.animation},n.animation.easing&&(a.animation.easing={...b.animation.easing,...n.animation.easing}),n.animation.queue&&(a.animation.queue={...b.animation.queue,...n.animation.queue}),n.animation.performance&&(a.animation.performance={...b.animation.performance,...n.animation.performance}),n.animation.entry&&(a.animation.entry={...b.animation.entry,...n.animation.entry,start:n.animation.entry.start?{...b.animation.entry.start,...n.animation.entry.start,circular:n.animation.entry.start.circular?{...b.animation.entry.start.circular,...n.animation.entry.start.circular}:b.animation.entry.start.circular}:b.animation.entry.start,timing:n.animation.entry.timing?{...b.animation.entry.timing,...n.animation.entry.timing}:b.animation.entry.timing,path:n.animation.entry.path?{...ut,...n.animation.entry.path}:b.animation.entry.path,rotation:n.animation.entry.rotation?{...gt,...n.animation.entry.rotation}:b.animation.entry.rotation,scale:n.animation.entry.scale?{...mt,...n.animation.entry.scale}:b.animation.entry.scale})),n.interaction&&(a.interaction={...b.interaction,...n.interaction},n.interaction.focus&&(a.interaction.focus={...b.interaction.focus,...n.interaction.focus}),n.interaction.navigation&&(a.interaction.navigation={...b.interaction.navigation,...n.interaction.navigation}),n.interaction.gestures&&(a.interaction.gestures={...b.interaction.gestures,...n.interaction.gestures})),n.rendering&&(a.rendering={...b.rendering,...n.rendering},n.rendering.responsive&&(a.rendering.responsive={...b.rendering.responsive,...n.rendering.responsive,breakpoints:n.rendering.responsive.breakpoints?{...b.rendering.responsive.breakpoints,...n.rendering.responsive.breakpoints}:b.rendering.responsive.breakpoints,mobileDetection:n.rendering.responsive.mobileDetection?n.rendering.responsive.mobileDetection:b.rendering.responsive.mobileDetection}),n.rendering.ui&&(a.rendering.ui={...b.rendering.ui,...n.rendering.ui}),n.rendering.performance&&(a.rendering.performance={...b.rendering.performance,...n.rendering.performance})),a.config.debug={...At,...n.config?.debug??{}},a}function ae(n,t){return{...n?lt[n]:lt.playful,...t}}function re(n,t){return{...n?ht[n]:ht.gentle,...t}}function ce(n,t){return{...n?dt[n]:dt.gentle,...t}}class Ct{constructor(t){this.activeAnimations=new Map,this.animationIdCounter=0,this.config=t}buildTransformString(t){const e=["translate(-50%, -50%)"];if(t.x!==void 0||t.y!==void 0){const i=t.x??0,o=t.y??0;e.push(`translate(${i}px, ${o}px)`)}return t.rotation!==void 0&&e.push(`rotate(${t.rotation}deg)`),t.scale!==void 0&&e.push(`scale(${t.scale})`),e.join(" ")}animateTransformCancellable(t,e,i,o=null,s=null){this.cancelAllAnimations(t);const r=o??this.config.duration,a=s??this.config.easing.default,h=this.buildTransformString(e),c=this.buildTransformString(i);t.style.transition="none";const u=t.animate([{transform:h},{transform:c}],{duration:r,easing:a,fill:"forwards"}),l={id:`anim-${++this.animationIdCounter}`,element:t,animation:u,fromState:e,toState:i,startTime:performance.now(),duration:r};return this.activeAnimations.set(t,l),u.finished.then(()=>{t.style.transform=c,this.activeAnimations.delete(t)}).catch(()=>{this.activeAnimations.delete(t)}),l}cancelAnimation(t,e=!0){const i=this.getCurrentTransform(t.element);if(t.animation.cancel(),e){const o=this.buildTransformString({x:i.x,y:i.y,rotation:i.rotation,scale:i.scale});t.element.style.transform=o}return this.activeAnimations.delete(t.element),i}cancelAllAnimations(t){const e=this.activeAnimations.get(t);e&&this.cancelAnimation(e,!1);const i=t.getAnimations();for(const o of i)o.cancel()}getCurrentTransform(t){const i=getComputedStyle(t).transform;if(i==="none"||!i)return{x:0,y:0,rotation:0,scale:1};const o=new DOMMatrix(i),s=Math.sqrt(o.a*o.a+o.b*o.b),r=Math.atan2(o.b,o.a)*(180/Math.PI),a=o.e,h=o.f;return{x:a,y:h,rotation:r,scale:s}}hasActiveAnimation(t){return this.activeAnimations.has(t)}getAnimationHandle(t){return this.activeAnimations.get(t)}animateTransform(t,e,i=null,o=null){return new Promise(s=>{const r=i??this.config.duration,a=o??this.config.easing.default;t.style.transition=`transform ${r}ms ${a}, box-shadow ${r}ms ${a}`,t.style.transform=this.buildTransformString(e),setTimeout(()=>{s()},r)})}resetTransform(t,e){return this.animateTransform(t,e)}clearTransition(t){t.style.transition=""}wait(t){return new Promise(e=>setTimeout(e,t))}}function Z(n,t,e){return n+(t-n)*e}function le(n,t,e,i){const{overshoot:o,bounces:s,decayRatio:r}=i,a=e.x-t.x,h=e.y-t.y,c=he(s,r);let u=0,l=0,d=1,m=o,y=!1;for(let g=0;g<c.length;g++)if(n<=c[g].time){l=g===0?0:c[g-1].time,d=c[g].time,m=c[g].overshoot,y=c[g].isOvershoot;break}const p=(n-l)/(d-l);if(y)u=1+m*ot(p);else if(l===0)u=ot(p);else{const f=1+(c.find((S,v)=>S.time>l&&v>0&&c[v-1].isOvershoot)?.overshoot||m);u=Z(f,1,ot(p))}return{x:t.x+a*u,y:t.y+h*u}}function he(n,t){const e=[];let i=.6;e.push({time:i,overshoot:0,isOvershoot:!1});let o=.15;const r=.4/(n*2);for(let a=0;a<n;a++)i+=r,e.push({time:i,overshoot:o,isOvershoot:!0}),i+=r,e.push({time:i,overshoot:o*t,isOvershoot:!1}),o*=t;return e.push({time:1,overshoot:0,isOvershoot:!1}),e}function de(n,t,e,i){const{stiffness:o,damping:s,mass:r,oscillations:a}=i,h=e.x-t.x,c=e.y-t.y,u=Math.sqrt(o/r),l=s/(2*Math.sqrt(o*r));let d;if(l<1){const m=u*Math.sqrt(1-l*l),y=Math.exp(-l*u*n*3),p=Math.cos(m*n*a*Math.PI);d=1-y*p}else d=1-Math.exp(-u*n*3);return d=Math.max(0,Math.min(d,1.3)),{x:t.x+h*d,y:t.y+c*d}}function ue(n,t,e,i){const{amplitude:o,frequency:s,decay:r,decayRate:a,phase:h}=i,c=e.x-t.x,u=e.y-t.y,l=Math.sqrt(c*c+u*u),d=l>0?-u/l:0,m=l>0?c/l:1,y=s*Math.PI*2*n+h,p=r?Math.pow(1-n,a):1,g=o*Math.sin(y)*p,f=ge(n);return{x:Z(t.x,e.x,f)+g*d,y:Z(t.y,e.y,f)+g*m}}function ot(n){return 1-(1-n)*(1-n)}function ge(n){return 1-Math.pow(1-n,3)}function me(n,t,e){const{amplitude:i,frequency:o,decay:s}=e,r=Math.sin(n*o*Math.PI*2),a=s?Math.pow(1-n,2):1,h=i*r*a;return t+h}function fe(n,t,e){const{overshoot:i,bounces:o}=e,s=[];s.push({time:.5,scale:i});let r=i;const a=.5,c=.5/(o*2);let u=.5;for(let d=0;d<o;d++){const m=1-(r-1)*a;u+=c,s.push({time:u,scale:m}),r=1+(r-1)*a*a,u+=c,d<o-1&&s.push({time:u,scale:r})}s.push({time:1,scale:1});let l=1;for(let d=0;d<s.length;d++)if(n<=s[d].time){const m=d===0?0:s[d-1].time,y=d===0?1:s[d-1].scale,p=(n-m)/(s[d].time-m),g=ot(p);l=y+(s[d].scale-y)*g;break}return l*t}function Rt(n){const{element:t,startPosition:e,endPosition:i,pathConfig:o,duration:s,imageWidth:r,imageHeight:a,rotation:h,scale:c,onComplete:u,rotationConfig:l,startRotation:d,scaleConfig:m,startScale:y}=n,p=o.type,g=d!==void 0&&d!==h,f=l?.mode==="wobble",S=l?.wobble||{amplitude:15,frequency:3,decay:!0},v=g||f,w=y!==void 0&&y!==c,x=m?.mode==="pop",E=m?.pop||{overshoot:1.2,bounces:1};if((p==="linear"||p==="arc")&&!v&&!(w||x)){u&&u();return}const M=performance.now(),z=-r/2,_=-a/2;function H(X){const j=X-M,C=Math.min(j/s,1);let O;switch(p){case"bounce":{const $=ae(o.bouncePreset,o.bounce);O=le(C,e,i,$);break}case"elastic":{const $=re(o.elasticPreset,o.elastic);O=de(C,e,i,$);break}case"wave":{const $=ce(o.wavePreset,o.wave);O=ue(C,e,i,$);break}default:O={x:Z(e.x,i.x,C),y:Z(e.y,i.y,C)}}const W=O.x-i.x,N=O.y-i.y;let L;f?L=me(C,h,S):g?L=Z(d,h,C):L=h;let R;x?R=fe(C,c,E):w?R=Z(y,c,C):R=c,t.style.transform=`translate(${z}px, ${_}px) translate(${W}px, ${N}px) rotate(${L}deg) scale(${R})`,C<1?requestAnimationFrame(H):(t.style.transform=`translate(${z}px, ${_}px) rotate(${h}deg) scale(${c})`,u&&u())}requestAnimationFrame(H)}function Lt(n){return n==="bounce"||n==="elastic"||n==="wave"}const pe={radial:"center",spiral:"center",grid:"top",cluster:"nearest-edge",random:"nearest-edge",wave:"left"};class Ft{constructor(t,e){this.config=t,this.layoutAlgorithm=e,this.resolvedStartPosition=this.resolveStartPosition(),this.pathConfig=t.path||ut,this.rotationConfig=t.rotation||gt,this.scaleConfig=t.scale||mt}resolveStartPosition(){return this.config.start.position?this.config.start.position:pe[this.layoutAlgorithm]||"nearest-edge"}calculateStartPosition(t,e,i,o,s){const r=this.resolvedStartPosition,a=this.config.start.offset??100;switch(r){case"nearest-edge":return this.calculateNearestEdge(t,e,i,a);case"top":return this.calculateEdgePosition("top",t,e,i,a);case"bottom":return this.calculateEdgePosition("bottom",t,e,i,a);case"left":return this.calculateEdgePosition("left",t,e,i,a);case"right":return this.calculateEdgePosition("right",t,e,i,a);case"center":return this.calculateCenterPosition(i,t,e);case"random-edge":return this.calculateRandomEdge(t,e,i,a);case"circular":return this.calculateCircularPosition(t,e,i,o,s);default:return this.calculateNearestEdge(t,e,i,a)}}calculateNearestEdge(t,e,i,o){const s=t.x,r=t.y,a=s,h=i.width-s,c=r,u=i.height-r,l=Math.min(a,h,c,u);let d=t.x,m=t.y;return l===a?d=-(e.width+o):l===h?d=i.width+o:l===c?m=-(e.height+o):m=i.height+o,{x:d,y:m}}calculateEdgePosition(t,e,i,o,s){let r=e.x,a=e.y;switch(t){case"top":a=-(i.height+s);break;case"bottom":a=o.height+s;break;case"left":r=-(i.width+s);break;case"right":r=o.width+s;break}return{x:r,y:a}}calculateCenterPosition(t,e,i){const o=t.width/2,s=t.height/2;return{x:o,y:s,useScale:!0}}calculateRandomEdge(t,e,i,o){const s=["top","bottom","left","right"],r=s[Math.floor(Math.random()*s.length)];return this.calculateEdgePosition(r,t,e,i,o)}calculateCircularPosition(t,e,i,o,s){const r=this.config.start.circular||{},a=r.distribution||"even";let h;const c=r.radius||"120%";if(typeof c=="string"&&c.endsWith("%")){const p=parseFloat(c)/100;h=Math.sqrt(i.width**2+i.height**2)*p/2}else h=typeof c=="number"?c:500;let u;a==="even"?u=o/s*2*Math.PI:u=Math.random()*2*Math.PI;const l=i.width/2,d=i.height/2,m=l+Math.cos(u)*h,y=d+Math.sin(u)*h;return{x:m,y}}getAnimationParams(t){const e=this.config.timing.duration,i=this.config.timing.stagger,o=this.config.easing;return{startTransform:"",duration:e,delay:t*i,easing:o}}buildStartTransform(t,e,i,o,s,r,a,h){const c=t.x-e.x,u=t.y-e.y,l=a!==void 0?a:i,d=h!==void 0?h:o,m=s!==void 0?-s/2:0,y=r!==void 0?-r/2:0,p=s!==void 0?`translate(${m}px, ${y}px)`:"translate(-50%, -50%)";return t.useScale?`${p} translate(${c}px, ${u}px) rotate(${l}deg) scale(0)`:`${p} translate(${c}px, ${u}px) rotate(${l}deg) scale(${d})`}buildFinalTransform(t,e,i,o){if(i!==void 0&&o!==void 0){const s=-i/2,r=-o/2;return`translate(${s}px, ${r}px) rotate(${t}deg) scale(${e})`}return`translate(-50%, -50%) rotate(${t}deg) scale(${e})`}getTransitionCSS(){const t=this.config.timing.duration,e=this.config.easing;return this.requiresJSAnimation()?`opacity ${t}ms ease-out`:`opacity ${t}ms ease-out, transform ${t}ms ${e}`}requiresJSAnimation(){return Lt(this.pathConfig.type)}getPathConfig(){return this.pathConfig}getPathType(){return this.pathConfig.type}getTiming(){return{duration:this.config.timing.duration,stagger:this.config.timing.stagger}}getRotationConfig(){return this.rotationConfig}getRotationMode(){return this.rotationConfig.mode}calculateStartRotation(t){switch(this.rotationConfig.mode){case"none":return t;case"settle":{const i=this.rotationConfig.startRotation;if(i===void 0)return t+(Math.random()-.5)*60;if(typeof i=="number")return i;const o=i.max-i.min;return i.min+Math.random()*o}case"spin":{const i=this.rotationConfig.spinCount??1,o=this.resolveSpinDirection(t);return t+i*360*o}case"random":return t+(Math.random()-.5)*60;case"wobble":return t;default:return t}}resolveSpinDirection(t){switch(this.rotationConfig.direction??"auto"){case"clockwise":return-1;case"counterclockwise":return 1;case"random":return Math.random()<.5?1:-1;default:return t>=0?1:-1}}requiresJSRotation(){return this.rotationConfig.mode==="wobble"}calculateWobbleRotation(t,e){if(this.rotationConfig.mode!=="wobble")return e;const i=this.rotationConfig.wobble||{amplitude:15,frequency:3,decay:!0},{amplitude:o,frequency:s,decay:r}=i,a=Math.sin(t*s*Math.PI*2),h=r?Math.pow(1-t,2):1,c=o*a*h;return e+c}getScaleConfig(){return this.scaleConfig}getScaleMode(){return this.scaleConfig.mode}calculateStartScale(t){switch(this.scaleConfig.mode){case"none":return t;case"grow":return(this.scaleConfig.startScale??.3)*t;case"shrink":return(this.scaleConfig.startScale??1.5)*t;case"pop":return t;case"random":{const i=this.scaleConfig.range??{min:.5,max:1};return(i.min+Math.random()*(i.max-i.min))*t}default:return t}}requiresJSScale(){return this.scaleConfig.mode==="pop"}calculatePopScale(t,e){if(this.scaleConfig.mode!=="pop")return e;const i=this.scaleConfig.pop||{overshoot:1.2,bounces:1},{overshoot:o,bounces:s}=i,r=this.generateScaleBounceKeyframes(s,o);let a=e;for(let h=0;h<r.length;h++)if(t<=r[h].time){const c=h===0?0:r[h-1].time,u=h===0?e:r[h-1].scale,l=(t-c)/(r[h].time-c),d=this.easeOutQuad(l);a=u+(r[h].scale-u)*d;break}return a*e}generateScaleBounceKeyframes(t,e){const i=[];i.push({time:.5,scale:e});let o=e;const s=.5,a=.5/(t*2);let h=.5;for(let c=0;c<t;c++){const u=1-(o-1)*s;h+=a,i.push({time:h,scale:u}),o=1+(o-1)*s*s,h+=a,c<t-1&&i.push({time:h,scale:o})}return i.push({time:1,scale:1}),i}easeOutQuad(t){return 1-(1-t)*(1-t)}}class Mt{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){const o=[],{width:s,height:r}=e,a=this.config.spacing.padding,h=i.fixedHeight??200,c=this.imageConfig.rotation?.mode??"none",u=this.imageConfig.rotation?.range?.min??-15,l=this.imageConfig.rotation?.range?.max??15,d=this.imageConfig.sizing?.variance?.min??1,m=this.imageConfig.sizing?.variance?.max??1,y=d!==1||m!==1,g=h*1.5/2,f=h/2,S=s-a-g,v=r-a-f,w=a+g,x=a+f;for(let E=0;E<t;E++){const A=this.random(w,S),M=this.random(x,v),z=c==="random"?this.random(u,l):0,_=y?this.random(d,m):1,H=h*_,X={id:E,x:A,y:M,rotation:z,scale:_,baseSize:H};o.push(X)}return o}random(t,e){return Math.random()*(e-t)+t}}class zt{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){const o=[],{width:s,height:r}=e,a=i.fixedHeight??200,h=this.imageConfig.rotation?.mode??"none",c=this.imageConfig.rotation?.range?.min??-15,u=this.imageConfig.rotation?.range?.max??15,l=this.imageConfig.sizing?.variance?.min??1,d=this.imageConfig.sizing?.variance?.max??1,m=l!==1||d!==1,y=this.config.scaleDecay??0,p=i.fixedHeight??a,g=s/2,f=r/2,S=Math.ceil(Math.sqrt(t));if(t>0){const x=m?this.random(l,d):1,E=p*x;o.push({id:0,x:g,y:f,rotation:h==="random"?this.random(c*.33,u*.33):0,scale:x,baseSize:E,zIndex:100})}let v=1,w=1;for(;v<t;){const x=w/S,E=y>0?1-x*y*.5:1,A=w*(p*.8),M=A*1.5,z=Math.PI*(3*(M+A)-Math.sqrt((3*M+A)*(M+3*A))),_=this.estimateWidth(p),H=Math.floor(z/(_*.7));if(H===0){w++;continue}const X=2*Math.PI/H,j=w*(20*Math.PI/180);for(let C=0;C<H&&v<t;C++){const O=C*X+j,W=m?this.random(l,d):1,N=E*W,L=p*N;let R=g+Math.cos(O)*M,$=f+Math.sin(O)*A;const P=this.config.spacing.padding??50,U=L*1.5/2,F=L/2;R-U<P?R=P+U:R+U>s-P&&(R=s-P-U),$-F<P?$=P+F:$+F>r-P&&($=r-P-F);const G=h==="random"?this.random(c,u):0;o.push({id:v,x:R,y:$,rotation:G,scale:N,baseSize:L,zIndex:Math.max(1,100-w)}),v++}w++}return o}estimateWidth(t){return t*1.4}random(t,e){return Math.random()*(e-t)+t}}const ye={columns:"auto",rows:"auto",stagger:"none",jitter:0,overlap:0,fillDirection:"row",alignment:"center",gap:10,overflowOffset:.25},Dt=[{x:1,y:1},{x:-1,y:-1},{x:1,y:-1},{x:-1,y:1},{x:-1,y:0},{x:1,y:0},{x:0,y:-1},{x:0,y:1}];class Ot{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){const o=[],{width:s,height:r}=e,a={...ye,...this.config.grid},h=this.config.spacing.padding,c=i.fixedHeight??200,u=this.imageConfig.rotation?.mode??"none",l=this.imageConfig.sizing?.variance?.min??1,d=this.imageConfig.sizing?.variance?.max??1,m=l!==1||d!==1,y=s-2*h,p=r-2*h,{columns:g,rows:f}=this.calculateGridDimensions(t,y,p,c,a),S=a.stagger==="row",v=a.stagger==="column",w=S?g+.5:g,x=v?f+.5:f,E=(y-a.gap*(g-1))/w,A=(p-a.gap*(f-1))/x,M=S?E/2:0,z=v?A/2:0,_=1+a.overlap,H=Math.min(E,A)*_,X=i.fixedHeight?Math.min(i.fixedHeight,H):H,j=g*E+(g-1)*a.gap+M,C=f*A+(f-1)*a.gap+z,O=h+(y-j)/2,W=h+(p-C)/2,N=g*f,L=a.columns!=="auto"&&a.rows!=="auto",R=L&&t>N;typeof window<"u"&&(window.__gridOverflowDebug={gridConfigColumns:a.columns,gridConfigRows:a.rows,columns:g,rows:f,cellCount:N,hasFixedGrid:L,imageCount:t,isOverflowMode:R});const $=R?new Array(N).fill(0):[],P=Math.min(E,A)*a.overflowOffset;for(let D=0;D<t;D++){let U,F,G=0;if(R&&D>=N){const Y=D-N,k=Y%N;G=Math.floor(Y/N)+1,$[k]++,a.fillDirection==="row"?(U=k%g,F=Math.floor(k/g)):(F=k%f,U=Math.floor(k/f))}else a.fillDirection==="row"?(U=D%g,F=Math.floor(D/g)):(F=D%f,U=Math.floor(D/f));let q=O+U*(E+a.gap)+E/2,B=W+F*(A+a.gap)+A/2;if(a.stagger==="row"&&F%2===1?q+=E/2:a.stagger==="column"&&U%2===1&&(B+=A/2),G>0){const Y=(G-1)%Dt.length,k=Dt[Y];q+=k.x*P,B+=k.y*P}if(a.jitter>0){const Y=E/2*a.jitter,k=A/2*a.jitter;q+=this.random(-Y,Y),B+=this.random(-k,k)}let J=q,K=B;if(!R&&a.fillDirection==="row"){const Y=t%g||g;if(F===Math.floor((t-1)/g)&&Y<g){const Vt=Y*E+(Y-1)*a.gap;let xt=0;a.alignment==="center"?xt=(j-Vt)/2:a.alignment==="end"&&(xt=j-Vt),J+=xt}}const yt=m?this.random(l,d):1,Q=X*yt,rt=Q*1.5/2,ct=Q/2,vt=h+rt,wt=s-h-rt,Fe=h+ct,Me=r-h-ct;J=Math.max(vt,Math.min(J,wt)),K=Math.max(Fe,Math.min(K,Me));let Et=0;if(u==="random"){const Y=this.imageConfig.rotation?.range?.min??-15,k=this.imageConfig.rotation?.range?.max??15;a.jitter>0?Et=this.random(Y*a.jitter,k*a.jitter):Et=this.random(Y,k)}let St;R&&G>0?St=50-G:St=R?100+D:D+1,o.push({id:D,x:J,y:K,rotation:Et,scale:yt,baseSize:Q,zIndex:St})}return o}calculateGridDimensions(t,e,i,o,s){let r,a;if(s.columns!=="auto"&&s.rows!=="auto")r=s.columns,a=s.rows;else if(s.columns!=="auto")r=s.columns,a=Math.ceil(t/r);else if(s.rows!=="auto")a=s.rows,r=Math.ceil(t/a);else{const h=e/i;for(r=Math.max(1,Math.round(Math.sqrt(t*h/1.4))),a=Math.ceil(t/r);r>1&&(r-1)*a>=t;)r--}return{columns:Math.max(1,r),rows:Math.max(1,a)}}random(t,e){return Math.random()*(e-t)+t}}const be=Math.PI*(3-Math.sqrt(5)),ve={spiralType:"golden",direction:"counterclockwise",tightness:1,scaleDecay:0,startAngle:0};class $t{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){const o=[],{width:s,height:r}=e,a={...ve,...this.config.spiral},h=this.config.spacing.padding,c=i.fixedHeight??200,u=this.imageConfig.rotation?.mode??"none",l=this.imageConfig.rotation?.range?.min??-15,d=this.imageConfig.rotation?.range?.max??15,m=this.imageConfig.sizing?.variance?.min??1,y=this.imageConfig.sizing?.variance?.max??1,p=m!==1||y!==1,g=this.config.scaleDecay??a.scaleDecay,f=s/2,S=r/2,v=Math.min(f-h-c/2,S-h-c/2),w=a.direction==="clockwise"?-1:1;for(let x=0;x<t;x++){let E,A;if(a.spiralType==="golden")E=x*be*w+a.startAngle,A=this.calculateGoldenRadius(x,t,v,a.tightness);else if(a.spiralType==="archimedean"){const q=x*.5*a.tightness;E=q*w+a.startAngle,A=this.calculateArchimedeanRadius(q,t,v,a.tightness)}else{const q=x*.3*a.tightness;E=q*w+a.startAngle,A=this.calculateLogarithmicRadius(q,t,v,a.tightness)}const M=f+Math.cos(E)*A,z=S+Math.sin(E)*A,_=A/v,H=g>0?1-_*g*.5:1,X=p?this.random(m,y):1,j=H*X,C=c*j,W=C*1.5/2,N=C/2,L=h+W,R=s-h-W,$=h+N,P=r-h-N,D=Math.max(L,Math.min(M,R)),U=Math.max($,Math.min(z,P));let F=0;if(u==="random"){const q=E*180/Math.PI%360,B=this.random(l,d);F=a.spiralType==="golden"?B:q*.1+B*.9}else u==="tangent"&&(F=this.calculateSpiralTangent(E,A,a));const G=t-x;o.push({id:x,x:D,y:U,rotation:F,scale:j,baseSize:C,zIndex:G})}return o}calculateSpiralTangent(t,e,i){let o;if(i.spiralType==="golden")o=t+Math.PI/2;else if(i.spiralType==="archimedean"){const r=1/i.tightness,a=Math.atan(e/r);o=t+a}else{const r=.15/i.tightness,a=Math.atan(1/r);o=t+a}return o*180/Math.PI%360-90}calculateGoldenRadius(t,e,i,o){const r=i/Math.sqrt(e)*Math.sqrt(t)/o;return Math.min(r,i)}calculateArchimedeanRadius(t,e,i,o){const s=e*.5*o;return t/s*i}calculateLogarithmicRadius(t,e,i,o){const s=i*.05,r=.15/o,a=s*Math.exp(r*t),h=e*.3*o,c=s*Math.exp(r*h);return a/c*i}random(t,e){return Math.random()*(e-t)+t}}const we={clusterCount:"auto",clusterSpread:150,clusterSpacing:200,density:"uniform",overlap:.3,distribution:"gaussian"};class Pt{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){const o=[],{width:s,height:r}=e,a={...we,...this.config.cluster},h=this.config.spacing.padding,c=i.fixedHeight??200,u=this.imageConfig.rotation?.mode??"none",l=this.imageConfig.rotation?.range?.min??-15,d=this.imageConfig.rotation?.range?.max??15,m=this.imageConfig.sizing?.variance?.min??1,y=this.imageConfig.sizing?.variance?.max??1,p=m!==1||y!==1,g=this.calculateClusterCount(t,a.clusterCount,s,r,a.clusterSpacing),f=this.generateClusterCenters(g,s,r,h,a),S=new Array(g).fill(0);for(let w=0;w<t;w++)S[w%g]++;let v=0;for(let w=0;w<g;w++){const x=f[w],E=S[w];for(let A=0;A<E;A++){let M,z;if(a.distribution==="gaussian")M=this.gaussianRandom()*x.spread,z=this.gaussianRandom()*x.spread;else{const F=this.random(0,Math.PI*2),G=this.random(0,x.spread);M=Math.cos(F)*G,z=Math.sin(F)*G}const _=1+a.overlap*.5,H=1+a.overlap*.3;M/=_,z/=_;const X=p?this.random(m,y):1,j=H*X,C=c*j;let O=x.x+M,W=x.y+z;const L=C*1.5/2,R=C/2;O=Math.max(h+L,Math.min(O,s-h-L)),W=Math.max(h+R,Math.min(W,r-h-R));const $=u==="random"?this.random(l,d):0,D=Math.sqrt(M*M+z*z)/x.spread,U=Math.round((1-D)*50)+1;o.push({id:v,x:O,y:W,rotation:$,scale:j,baseSize:C,zIndex:U}),v++}}return o}calculateClusterCount(t,e,i,o,s){if(e!=="auto")return Math.max(1,Math.min(e,t));const a=Math.max(1,Math.ceil(t/8)),h=Math.floor(i/s*(o/s)*.6);return Math.max(1,Math.min(a,h,10))}generateClusterCenters(t,e,i,o,s){const r=[],h=o+s.clusterSpread,c=e-o-s.clusterSpread,u=o+s.clusterSpread,l=i-o-s.clusterSpread;for(let d=0;d<t;d++){let m=null,y=-1;for(let p=0;p<100;p++){const g={x:this.random(h,c),y:this.random(u,l),spread:this.calculateClusterSpread(s)};let f=1/0;for(const S of r){const v=g.x-S.x,w=g.y-S.y,x=Math.sqrt(v*v+w*w);f=Math.min(f,x)}if((r.length===0||f>y)&&(m=g,y=f),f>=s.clusterSpacing)break}m&&r.push(m)}return r}calculateClusterSpread(t){return t.density==="uniform"?t.clusterSpread:t.clusterSpread*this.random(.5,1.5)}gaussianRandom(){let t=0,e=0;for(;t===0;)t=Math.random();for(;e===0;)e=Math.random();const i=Math.sqrt(-2*Math.log(t))*Math.cos(2*Math.PI*e);return Math.max(-3,Math.min(3,i))/3}random(t,e){return Math.random()*(e-t)+t}}class Ut{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){const o=[],{width:s,height:r}=e,a=i.fixedHeight??200,h=this.config.spacing.padding??50,c=this.imageConfig.rotation?.mode??"none",u=this.imageConfig.rotation?.range?.min??-15,l=this.imageConfig.rotation?.range?.max??15,d=this.imageConfig.sizing?.variance?.min??1,m=this.imageConfig.sizing?.variance?.max??1,y=d!==1||m!==1,p=i.fixedHeight??a,g={...Zt,...this.config.wave},{rows:f,amplitude:S,frequency:v,phaseShift:w,synchronization:x}=g,E=Math.ceil(t/f),z=p*1.5/2,_=h+z,H=s-h-z,X=H-_,j=E>1?X/(E-1):0,C=h+S+p/2,O=r-h-S-p/2,W=O-C,N=f>1?W/(f-1):0;let L=0;for(let R=0;R<f&&L<t;R++){const $=f===1?(C+O)/2:C+R*N;let P=0;x==="offset"?P=R*w:x==="alternating"&&(P=R*Math.PI);for(let D=0;D<E&&L<t;D++){const U=E===1?(_+H)/2:_+D*j,F=this.calculateWaveY(U,s,S,v,P),G=U,q=$+F,B=y?this.random(d,m):1,J=p*B;let K=0;c==="tangent"?K=this.calculateRotation(U,s,S,v,P):c==="random"&&(K=this.random(u,l));const Q=J*1.5/2,bt=J/2,rt=h+Q,ct=s-h-Q,vt=h+bt,wt=r-h-bt;o.push({id:L,x:Math.max(rt,Math.min(G,ct)),y:Math.max(vt,Math.min(q,wt)),rotation:K,scale:B,baseSize:J,zIndex:L+1}),L++}}return o}calculateWaveY(t,e,i,o,s){const r=t/e;return i*Math.sin(o*r*2*Math.PI+s)}calculateRotation(t,e,i,o,s){const r=t/e,a=i*o*2*Math.PI*Math.cos(o*r*2*Math.PI+s)/e;return Math.atan(a)*(180/Math.PI)}random(t,e){return Math.random()*(e-t)+t}}class _t{constructor(t){this.config=t.layout,this.imageConfig=t.image,this.layouts=new Map,this.placementLayout=this.initLayout()}initLayout(){switch(this.config.algorithm){case"radial":return new zt(this.config,this.imageConfig);case"grid":return new Ot(this.config,this.imageConfig);case"spiral":return new $t(this.config,this.imageConfig);case"cluster":return new Pt(this.config,this.imageConfig);case"wave":return new Ut(this.config,this.imageConfig);default:return new Mt(this.config,this.imageConfig)}}generateLayout(t,e,i={}){const o=this.placementLayout.generate(t,e,i);return o.forEach(s=>{this.layouts.set(s.id,s)}),o}getOriginalState(t){return this.layouts.get(Number(t))}reset(){this.layouts.clear()}updateConfig(t){t.layout&&(Object.assign(this.config,t.layout),t.layout.algorithm&&t.layout.algorithm!==this.config.algorithm&&(this.placementLayout=this.initLayout())),t.image&&Object.assign(this.imageConfig,t.image)}getBreakpoints(){return this.config.responsive??{mobile:{maxWidth:767},tablet:{maxWidth:1199}}}resolveBreakpoint(t){const e=this.getBreakpoints();return t<=e.mobile.maxWidth?"mobile":t<=e.tablet.maxWidth?"tablet":"screen"}resolveBaseHeight(t){const e=this.imageConfig.sizing;if(!e||e.mode==="adaptive")return;const i=e.height;if(i===void 0)return;if(typeof i=="number")return i;const o=i,s=this.resolveBreakpoint(t);return s==="mobile"?o.mobile??o.tablet??o.screen:s==="tablet"?o.tablet??o.screen??o.mobile:o.screen??o.tablet??o.mobile}calculateAdaptiveSize(t,e,i,o){const s=this.imageConfig.sizing,r=this.resolveBaseHeight(o);if(r!==void 0)return{height:r};const a=s?.minSize??50,h=s?.maxSize??400,c=this.config.targetCoverage??.6,u=this.config.densityFactor??1,{width:l,height:d}=t,p=l*d*c/e;let f=Math.sqrt(p/1.4);f*=u,f=Math.min(f,i);let S=this.clamp(f,a,h);if(S===a&&f<a){const v=Math.max(a*.05,20);S=Math.max(v,f)}return{height:S}}clamp(t,e,i){return Math.max(e,Math.min(i,t))}}var I=(n=>(n.IDLE="idle",n.FOCUSING="focusing",n.FOCUSED="focused",n.UNFOCUSING="unfocusing",n.CROSS_ANIMATING="cross_animating",n))(I||{});function Ee(n){return n in V}function Se(n){return n?Ee(n)?V[n]:n:V.md}function xe(n){if(!n)return"";const t=[];if(n.grayscale!==void 0&&t.push(`grayscale(${n.grayscale})`),n.blur!==void 0&&t.push(`blur(${n.blur}px)`),n.brightness!==void 0&&t.push(`brightness(${n.brightness})`),n.contrast!==void 0&&t.push(`contrast(${n.contrast})`),n.saturate!==void 0&&t.push(`saturate(${n.saturate})`),n.opacity!==void 0&&t.push(`opacity(${n.opacity})`),n.sepia!==void 0&&t.push(`sepia(${n.sepia})`),n.hueRotate!==void 0&&t.push(`hue-rotate(${n.hueRotate}deg)`),n.invert!==void 0&&t.push(`invert(${n.invert})`),n.dropShadow!==void 0)if(typeof n.dropShadow=="string")t.push(`drop-shadow(${n.dropShadow})`);else{const e=n.dropShadow;t.push(`drop-shadow(${e.x}px ${e.y}px ${e.blur}px ${e.color})`)}return t.join(" ")}function et(n){if(!n||n.style==="none"||n.width===0)return"none";const t=n.width??0,e=n.style??"solid",i=n.color??"#000000";return`${t}px ${e} ${i}`}function st(n){if(!n)return{};const t={};if(n.borderRadiusTopLeft!==void 0||n.borderRadiusTopRight!==void 0||n.borderRadiusBottomRight!==void 0||n.borderRadiusBottomLeft!==void 0){const s=n.border?.radius??0;n.borderRadiusTopLeft!==void 0?t.borderTopLeftRadius=`${n.borderRadiusTopLeft}px`:s&&(t.borderTopLeftRadius=`${s}px`),n.borderRadiusTopRight!==void 0?t.borderTopRightRadius=`${n.borderRadiusTopRight}px`:s&&(t.borderTopRightRadius=`${s}px`),n.borderRadiusBottomRight!==void 0?t.borderBottomRightRadius=`${n.borderRadiusBottomRight}px`:s&&(t.borderBottomRightRadius=`${s}px`),n.borderRadiusBottomLeft!==void 0?t.borderBottomLeftRadius=`${n.borderRadiusBottomLeft}px`:s&&(t.borderBottomLeftRadius=`${s}px`)}else n.border?.radius!==void 0&&(t.borderRadius=`${n.border.radius}px`);if(n.borderTop||n.borderRight||n.borderBottom||n.borderLeft){const s=n.border||{},r={...s,...n.borderTop},a={...s,...n.borderRight},h={...s,...n.borderBottom},c={...s,...n.borderLeft};t.borderTop=et(r),t.borderRight=et(a),t.borderBottom=et(h),t.borderLeft=et(c)}else n.border&&(t.border=et(n.border));n.shadow!==void 0&&(t.boxShadow=Se(n.shadow));const o=xe(n.filter);if(t.filter=o||"none",n.opacity!==void 0&&(t.opacity=String(n.opacity)),n.cursor!==void 0&&(t.cursor=n.cursor),n.outline&&n.outline.style!=="none"&&(n.outline.width??0)>0){const s=n.outline.width??0,r=n.outline.style??"solid",a=n.outline.color??"#000000";t.outline=`${s}px ${r} ${a}`,n.outline.offset!==void 0&&(t.outlineOffset=`${n.outline.offset}px`)}return n.objectFit!==void 0&&(t.objectFit=n.objectFit),n.aspectRatio!==void 0&&(t.aspectRatio=n.aspectRatio),t}function it(n,t){t.borderRadius!==void 0&&(n.style.borderRadius=t.borderRadius),t.borderTopLeftRadius!==void 0&&(n.style.borderTopLeftRadius=t.borderTopLeftRadius),t.borderTopRightRadius!==void 0&&(n.style.borderTopRightRadius=t.borderTopRightRadius),t.borderBottomRightRadius!==void 0&&(n.style.borderBottomRightRadius=t.borderBottomRightRadius),t.borderBottomLeftRadius!==void 0&&(n.style.borderBottomLeftRadius=t.borderBottomLeftRadius),t.border!==void 0&&(n.style.border=t.border),t.borderTop!==void 0&&(n.style.borderTop=t.borderTop),t.borderRight!==void 0&&(n.style.borderRight=t.borderRight),t.borderBottom!==void 0&&(n.style.borderBottom=t.borderBottom),t.borderLeft!==void 0&&(n.style.borderLeft=t.borderLeft),t.boxShadow!==void 0&&(n.style.boxShadow=t.boxShadow),t.filter!==void 0&&(n.style.filter=t.filter),t.opacity!==void 0&&(n.style.opacity=t.opacity),t.cursor!==void 0&&(n.style.cursor=t.cursor),t.outline!==void 0&&(n.style.outline=t.outline),t.outlineOffset!==void 0&&(n.style.outlineOffset=t.outlineOffset),t.objectFit!==void 0&&(n.style.objectFit=t.objectFit),t.aspectRatio!==void 0&&(n.style.aspectRatio=t.aspectRatio)}function Ht(n){return n?Array.isArray(n)?n.join(" "):n:""}function nt(n,t){const e=Ht(t);e&&e.split(" ").forEach(i=>{i.trim()&&n.classList.add(i.trim())})}function Nt(n,t){const e=Ht(t);e&&e.split(" ").forEach(i=>{i.trim()&&n.classList.remove(i.trim())})}const jt={UNFOCUSING:999,FOCUSING:1e3};class kt{constructor(t,e,i){this.state=I.IDLE,this.currentFocus=null,this.focusData=null,this.outgoing=null,this.incoming=null,this.focusGeneration=0,this.config=t,this.animationEngine=e,this.defaultStyles=st(i?.default),this.focusedStyles=st(i?.focused),this.defaultClassName=i?.default?.className,this.focusedClassName=i?.focused?.className}getState(){return this.state}isAnimating(){return this.state!==I.IDLE&&this.state!==I.FOCUSED}normalizeScalePercent(t){return t>1?t/100:t}calculateFocusDimensions(t,e,i){const o=this.normalizeScalePercent(this.config.scalePercent),s=i.height*o,r=t/e;let a=s,h=a*r;const c=i.width*o;return h>c&&(h=c,a=h/r),{width:h,height:a}}calculateFocusTransform(t,e){const i=t.width/2,o=t.height/2,s=i-e.x,r=o-e.y;return{x:s,y:r,rotation:0,scale:1}}buildDimensionZoomTransform(t){const e=["translate(-50%, -50%)"];if(t.x!==void 0||t.y!==void 0){const i=t.x??0,o=t.y??0;e.push(`translate(${i}px, ${o}px)`)}return t.rotation!==void 0&&e.push(`rotate(${t.rotation}deg)`),e.join(" ")}animateWithDimensions(t,e,i,o,s,r,a,h){const c=this.buildDimensionZoomTransform(e),u=this.buildDimensionZoomTransform(i);return t.style.transition="none",t.animate([{transform:c,width:`${o}px`,height:`${s}px`},{transform:u,width:`${r}px`,height:`${a}px`}],{duration:h,easing:"cubic-bezier(0.4, 0, 0.2, 1)",fill:"forwards"})}applyFocusedStyling(t,e){t.style.zIndex=String(e),t.classList.add("fbn-ic-focused"),it(t,this.focusedStyles),nt(t,this.focusedClassName)}removeFocusedStyling(t,e){t.style.zIndex=e,t.classList.remove("fbn-ic-focused"),Nt(t,this.focusedClassName),it(t,this.defaultStyles),nt(t,this.defaultClassName)}startFocusAnimation(t,e,i,o,s){const r=t.style.zIndex||"",a=t.offsetWidth,h=t.offsetHeight,c=this.calculateFocusDimensions(a,h,e),u=this.calculateFocusTransform(e,i);this.applyFocusedStyling(t,jt.FOCUSING),this.animationEngine.cancelAllAnimations(t);const l=o??{x:0,y:0,rotation:i.rotation,scale:1},d=s?.width??a,m=s?.height??h,y=this.config.animationDuration??600,p=this.animateWithDimensions(t,l,u,d,m,c.width,c.height,y),g={id:`focus-${Date.now()}`,element:t,animation:p,fromState:l,toState:u,startTime:performance.now(),duration:y};return this.focusData={element:t,originalState:i,focusTransform:u,originalZIndex:r,originalWidth:a,originalHeight:h,focusWidth:c.width,focusHeight:c.height},{element:t,originalState:i,animationHandle:g,direction:"in",originalWidth:a,originalHeight:h}}startUnfocusAnimation(t,e,i,o){t.style.zIndex=String(jt.UNFOCUSING),this.animationEngine.cancelAllAnimations(t);const s=i??this.focusData?.focusTransform??{x:0,y:0,rotation:0,scale:1},r=o?.width??this.focusData?.focusWidth??t.offsetWidth,a=o?.height??this.focusData?.focusHeight??t.offsetHeight,h={x:0,y:0,rotation:e.rotation,scale:1},c=this.focusData?.originalWidth??t.offsetWidth,u=this.focusData?.originalHeight??t.offsetHeight,l=this.config.animationDuration??600,d=this.animateWithDimensions(t,s,h,r,a,c,u,l),m={id:`unfocus-${Date.now()}`,element:t,animation:d,fromState:s,toState:h,startTime:performance.now(),duration:l};return{element:t,originalState:e,animationHandle:m,direction:"out",originalWidth:c,originalHeight:u}}async waitForAnimation(t){try{await t.animation.finished}catch{}}resetElementInstantly(t,e,i,o,s){this.animationEngine.cancelAllAnimations(t);const r=["translate(-50%, -50%)"];r.push("translate(0px, 0px)"),r.push(`rotate(${e.rotation}deg)`),t.style.transition="none",t.style.transform=r.join(" "),o!==void 0&&s!==void 0&&(t.style.width=`${o}px`,t.style.height=`${s}px`),this.removeFocusedStyling(t,i)}async focusImage(t,e,i){if(this.currentFocus===t&&this.state===I.FOCUSED)return this.unfocusImage();if(this.incoming?.element===t&&this.state===I.FOCUSING){const s=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),r={x:s.x,y:s.y,rotation:s.rotation,scale:1},a={width:t.offsetWidth,height:t.offsetHeight};this.outgoing=this.startUnfocusAnimation(t,this.incoming.originalState,r,a),this.incoming=null,this.state=I.UNFOCUSING,await this.waitForAnimation(this.outgoing.animationHandle),this.removeFocusedStyling(this.outgoing.element,this.focusData?.originalZIndex||""),this.outgoing=null,this.currentFocus=null,this.focusData=null,this.state=I.IDLE;return}const o=++this.focusGeneration;switch(this.state){case I.IDLE:if(this.state=I.FOCUSING,this.incoming=this.startFocusAnimation(t,e,i),await this.waitForAnimation(this.incoming.animationHandle),this.focusGeneration!==o)return;this.currentFocus=t,this.incoming=null,this.state=I.FOCUSED;break;case I.FOCUSED:if(this.state=I.CROSS_ANIMATING,this.currentFocus&&this.focusData&&(this.outgoing=this.startUnfocusAnimation(this.currentFocus,this.focusData.originalState)),this.incoming=this.startFocusAnimation(t,e,i),await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(this.incoming.animationHandle)]),this.focusGeneration!==o)return;this.outgoing&&(this.removeFocusedStyling(this.outgoing.element,this.outgoing.originalState.zIndex?.toString()||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=I.FOCUSED;break;case I.FOCUSING:if(this.incoming&&(this.animationEngine.cancelAnimation(this.incoming.animationHandle,!1),this.resetElementInstantly(this.incoming.element,this.incoming.originalState,this.focusData?.originalZIndex||"",this.focusData?.originalWidth,this.focusData?.originalHeight),this.incoming=null),this.incoming=this.startFocusAnimation(t,e,i),await this.waitForAnimation(this.incoming.animationHandle),this.focusGeneration!==o)return;this.currentFocus=t,this.incoming=null,this.state=I.FOCUSED;break;case I.UNFOCUSING:if(this.state=I.CROSS_ANIMATING,this.incoming=this.startFocusAnimation(t,e,i),await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(this.incoming.animationHandle)]),this.focusGeneration!==o)return;this.outgoing&&(this.removeFocusedStyling(this.outgoing.element,this.outgoing.originalState.zIndex?.toString()||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=I.FOCUSED;break;case I.CROSS_ANIMATING:if(this.incoming?.element===t)return;if(this.outgoing?.element===t){const s=this.animationEngine.cancelAnimation(this.outgoing.animationHandle,!0),r={x:s.x,y:s.y,rotation:s.rotation,scale:1},a={width:t.offsetWidth,height:t.offsetHeight};if(this.incoming){const h=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),c={x:h.x,y:h.y,rotation:h.rotation,scale:1},u={width:this.incoming.element.offsetWidth,height:this.incoming.element.offsetHeight};this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,c,u)}else this.outgoing=null;if(this.incoming=this.startFocusAnimation(t,e,i,r,a),await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(this.incoming.animationHandle)]),this.focusGeneration!==o)return;this.outgoing&&(this.removeFocusedStyling(this.outgoing.element,this.outgoing.originalState.zIndex?.toString()||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=I.FOCUSED;return}if(this.outgoing&&(this.animationEngine.cancelAnimation(this.outgoing.animationHandle,!1),this.resetElementInstantly(this.outgoing.element,this.outgoing.originalState,this.outgoing.originalState.zIndex?.toString()||"",this.outgoing.originalWidth,this.outgoing.originalHeight),this.outgoing=null),this.incoming){const s=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),r={x:s.x,y:s.y,rotation:s.rotation,scale:1},a={width:this.incoming.element.offsetWidth,height:this.incoming.element.offsetHeight};this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,r,a)}if(this.incoming=this.startFocusAnimation(t,e,i),await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(this.incoming.animationHandle)]),this.focusGeneration!==o)return;this.outgoing&&(this.removeFocusedStyling(this.outgoing.element,this.outgoing.originalState.zIndex?.toString()||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=I.FOCUSED;break}}async unfocusImage(){const t=++this.focusGeneration;if(!this.currentFocus||!this.focusData){if(this.incoming&&this.state===I.FOCUSING){const s=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),r={x:s.x,y:s.y,rotation:s.rotation,scale:1},a={width:this.incoming.element.offsetWidth,height:this.incoming.element.offsetHeight};if(this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,r,a),this.incoming=null,this.state=I.UNFOCUSING,await this.waitForAnimation(this.outgoing.animationHandle),this.focusGeneration!==t)return;this.removeFocusedStyling(this.outgoing.element,this.focusData?.originalZIndex||""),this.outgoing=null,this.focusData=null,this.state=I.IDLE}return}if(this.state===I.CROSS_ANIMATING&&this.incoming){const s=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),r={x:s.x,y:s.y,rotation:s.rotation,scale:1},a={width:this.incoming.element.offsetWidth,height:this.incoming.element.offsetHeight},h=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,r,a);if(await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(h.animationHandle)]),this.focusGeneration!==t)return;this.outgoing&&this.removeFocusedStyling(this.outgoing.element,this.outgoing.originalState.zIndex?.toString()||""),this.removeFocusedStyling(h.element,this.incoming.originalState.zIndex?.toString()||""),this.outgoing=null,this.incoming=null,this.currentFocus=null,this.focusData=null,this.state=I.IDLE;return}this.state=I.UNFOCUSING;const e=this.currentFocus,i=this.focusData.originalState,o=this.focusData.originalZIndex;this.outgoing=this.startUnfocusAnimation(e,i),await this.waitForAnimation(this.outgoing.animationHandle),this.focusGeneration===t&&(this.removeFocusedStyling(e,o),this.outgoing=null,this.currentFocus=null,this.focusData=null,this.state=I.IDLE)}async swapFocus(t,e,i){return this.focusImage(t,e,i)}getCurrentFocus(){return this.currentFocus}isFocused(t){return this.currentFocus===t&&this.state===I.FOCUSED}isTargetingFocus(t){return this.incoming?.element===t}isInvolved(t){return this.currentFocus===t||this.incoming?.element===t||this.outgoing?.element===t}setDragOffset(t){if(!this.currentFocus||!this.focusData||this.state!==I.FOCUSED)return;const e=this.currentFocus,i=this.focusData.focusTransform,o=["translate(-50%, -50%)"],s=(i.x??0)+t,r=i.y??0;o.push(`translate(${s}px, ${r}px)`),i.rotation!==void 0&&o.push(`rotate(${i.rotation}deg)`),e.style.transition="none",e.style.transform=o.join(" ")}clearDragOffset(t,e=150){if(!this.currentFocus||!this.focusData||this.state!==I.FOCUSED)return;const i=this.currentFocus,o=this.focusData.focusTransform,s=["translate(-50%, -50%)"],r=o.x??0,a=o.y??0;s.push(`translate(${r}px, ${a}px)`),o.rotation!==void 0&&s.push(`rotate(${o.rotation}deg)`);const h=s.join(" ");t?(i.style.transition=`transform ${e}ms ease-out`,i.style.transform=h,setTimeout(()=>{this.currentFocus===i&&(i.style.transition="none")},e)):(i.style.transition="none",i.style.transform=h)}reset(){this.outgoing&&(this.animationEngine.cancelAnimation(this.outgoing.animationHandle,!1),this.resetElementInstantly(this.outgoing.element,this.outgoing.originalState,this.outgoing.originalState.zIndex?.toString()||"",this.outgoing.originalWidth,this.outgoing.originalHeight)),this.incoming&&(this.animationEngine.cancelAnimation(this.incoming.animationHandle,!1),this.resetElementInstantly(this.incoming.element,this.incoming.originalState,this.focusData?.originalZIndex||"",this.focusData?.originalWidth,this.focusData?.originalHeight)),this.currentFocus&&this.focusData&&this.resetElementInstantly(this.currentFocus,this.focusData.originalState,this.focusData.originalZIndex,this.focusData.originalWidth,this.focusData.originalHeight),this.state=I.IDLE,this.currentFocus=null,this.focusData=null,this.outgoing=null,this.incoming=null}}const Ie=50,Te=.5,Ae=20,Ce=.3,Re=150,Le=30,at=class at{constructor(t,e){this.enabled=!1,this.touchState=null,this.recentTouchTimestamp=0,this.container=t,this.callbacks=e,this.boundTouchStart=this.handleTouchStart.bind(this),this.boundTouchMove=this.handleTouchMove.bind(this),this.boundTouchEnd=this.handleTouchEnd.bind(this),this.boundTouchCancel=this.handleTouchCancel.bind(this)}enable(){this.enabled||(this.enabled=!0,this.container.style.touchAction="pan-y",this.container.addEventListener("touchstart",this.boundTouchStart,{passive:!1}),this.container.addEventListener("touchmove",this.boundTouchMove,{passive:!1}),this.container.addEventListener("touchend",this.boundTouchEnd,{passive:!0}),this.container.addEventListener("touchcancel",this.boundTouchCancel,{passive:!0}))}disable(){this.enabled&&(this.enabled=!1,this.container.style.touchAction="",this.container.removeEventListener("touchstart",this.boundTouchStart),this.container.removeEventListener("touchmove",this.boundTouchMove),this.container.removeEventListener("touchend",this.boundTouchEnd),this.container.removeEventListener("touchcancel",this.boundTouchCancel),this.touchState?.isDragging&&this.callbacks.onDragEnd(!1),this.touchState=null)}destroy(){this.disable()}hadRecentTouch(){return Date.now()-this.recentTouchTimestamp<at.TOUCH_CLICK_DELAY}handleTouchStart(t){if(t.touches.length!==1)return;this.recentTouchTimestamp=Date.now();const e=t.touches[0];this.touchState={startX:e.clientX,startY:e.clientY,startTime:performance.now(),currentX:e.clientX,isDragging:!1,isHorizontalSwipe:null}}handleTouchMove(t){if(!this.touchState||t.touches.length!==1)return;const e=t.touches[0],i=e.clientX-this.touchState.startX,o=e.clientY-this.touchState.startY;if(this.touchState.isHorizontalSwipe===null&&Math.sqrt(i*i+o*o)>10){const a=Math.atan2(Math.abs(o),Math.abs(i))*(180/Math.PI);this.touchState.isHorizontalSwipe=a<=Le}if(this.touchState.isHorizontalSwipe!==!1&&this.touchState.isHorizontalSwipe===!0){t.preventDefault(),this.touchState.isDragging=!0,this.touchState.currentX=e.clientX;const s=i*Ce;this.callbacks.onDragOffset(s)}}handleTouchEnd(t){if(!this.touchState)return;this.recentTouchTimestamp=Date.now();const e=this.touchState.currentX-this.touchState.startX,i=performance.now()-this.touchState.startTime,o=Math.abs(e)/i,s=Math.abs(e);let r=!1;this.touchState.isHorizontalSwipe===!0&&this.touchState.isDragging&&(s>=Ie||o>=Te&&s>=Ae)&&(r=!0,e<0?this.callbacks.onNext():this.callbacks.onPrev()),this.touchState.isDragging&&this.callbacks.onDragEnd(r),this.touchState=null}handleTouchCancel(t){this.touchState?.isDragging&&this.callbacks.onDragEnd(!1),this.touchState=null}};at.TOUCH_CLICK_DELAY=300;let pt=at;class Wt{constructor(t){if(this._prepared=!1,this._discoveredUrls=[],this.apiKey=t.apiKey??"",this.apiEndpoint=t.apiEndpoint??"https://www.googleapis.com/drive/v3/files",this.debugLogging=t.debugLogging??!1,this.sources=t.sources??[],!this.sources||this.sources.length===0)throw new Error("GoogleDriveLoader requires at least one source to be configured")}async prepare(t){this._discoveredUrls=[];for(const e of this.sources)if("folders"in e)for(const i of e.folders){const o=e.recursive!==void 0?e.recursive:!0,s=await this.loadFromFolder(i,t,o);this._discoveredUrls.push(...s)}else if("files"in e){const i=await this.loadFiles(e.files,t);this._discoveredUrls.push(...i)}this._prepared=!0}imagesLength(){if(!this._prepared)throw new Error("GoogleDriveLoader.imagesLength() called before prepare()");return this._discoveredUrls.length}imageURLs(){if(!this._prepared)throw new Error("GoogleDriveLoader.imageURLs() called before prepare()");return[...this._discoveredUrls]}isPrepared(){return this._prepared}extractFolderId(t){const e=[/\/folders\/([a-zA-Z0-9_-]+)/,/id=([a-zA-Z0-9_-]+)/];for(const i of e){const o=t.match(i);if(o&&o[1])return o[1]}return null}async loadFromFolder(t,e,i=!0){const o=this.extractFolderId(t);if(!o)throw new Error("Invalid Google Drive folder URL. Please check the URL format.");if(!this.apiKey||this.apiKey==="YOUR_API_KEY_HERE")return this.loadImagesDirectly(o,e);try{return i?await this.loadImagesRecursively(o,e):await this.loadImagesFromSingleFolder(o,e)}catch(s){return console.error("Error loading from Google Drive API:",s),this.loadImagesDirectly(o,e)}}async loadImagesFromSingleFolder(t,e){const i=[],o=`'${t}' in parents and trashed=false`,r=`${this.apiEndpoint}?q=${encodeURIComponent(o)}&fields=files(id,name,mimeType,thumbnailLink)&key=${this.apiKey}`,a=await fetch(r);if(!a.ok)throw new Error(`API request failed: ${a.status} ${a.statusText}`);const c=(await a.json()).files.filter(u=>u.mimeType.startsWith("image/")&&e.isAllowed(u.name));return this.log(`Found ${c.length} images in folder ${t} (non-recursive)`),c.forEach(u=>{i.push(`https://lh3.googleusercontent.com/d/${u.id}=s1600`),this.log(`Added file: ${u.name}`)}),i}async loadFiles(t,e){const i=[];for(const o of t){const s=this.extractFileId(o);if(!s){this.log(`Skipping invalid file URL: ${o}`);continue}if(this.apiKey&&this.apiKey!=="YOUR_API_KEY_HERE")try{const r=`${this.apiEndpoint}/${s}?fields=name,mimeType&key=${this.apiKey}`,a=await fetch(r);if(a.ok){const h=await a.json();h.mimeType.startsWith("image/")&&e.isAllowed(h.name)?(i.push(`https://lh3.googleusercontent.com/d/${s}=s1600`),this.log(`Added file: ${h.name}`)):this.log(`Skipping non-image file: ${h.name} (${h.mimeType})`)}else this.log(`Failed to fetch metadata for file ${s}: ${a.status}`)}catch(r){this.log(`Error fetching metadata for file ${s}:`,r)}else i.push(`https://lh3.googleusercontent.com/d/${s}=s1600`)}return i}extractFileId(t){if(!/[/:.]/.test(t))return t;const e=[/\/file\/d\/([a-zA-Z0-9_-]+)/,/\/open\?id=([a-zA-Z0-9_-]+)/,/id=([a-zA-Z0-9_-]+)/];for(const i of e){const o=t.match(i);if(o&&o[1])return o[1]}return null}async loadImagesRecursively(t,e){const i=[],o=`'${t}' in parents and trashed=false`,r=`${this.apiEndpoint}?q=${encodeURIComponent(o)}&fields=files(id,name,mimeType,thumbnailLink)&key=${this.apiKey}`,a=await fetch(r);if(!a.ok)throw new Error(`API request failed: ${a.status} ${a.statusText}`);const h=await a.json(),c=h.files.filter(l=>l.mimeType.startsWith("image/")&&e.isAllowed(l.name)),u=h.files.filter(l=>l.mimeType==="application/vnd.google-apps.folder");this.log(`Found ${h.files.length} total items in folder ${t}`),h.files.forEach(l=>this.log(` - File: ${l.name} (${l.mimeType})`)),this.log(`- ${c.length} valid files (images only)`),this.log(`- ${u.length} subfolders`),c.forEach(l=>{i.push(`https://lh3.googleusercontent.com/d/${l.id}=s1600`),this.log(`Added file: ${l.name}`)});for(const l of u){this.log(`Loading images from subfolder: ${l.name}`);const d=await this.loadImagesRecursively(l.id,e);i.push(...d)}return i}async loadImagesDirectly(t,e){try{const i=`https://drive.google.com/embeddedfolderview?id=${t}`,o=await fetch(i,{mode:"cors"});if(!o.ok)throw new Error("Cannot access folder directly (CORS or permissions issue)");const s=await o.text(),r=/\/file\/d\/([a-zA-Z0-9_-]+)/g,a=[...s.matchAll(r)];return[...new Set(a.map(u=>u[1]))].map(u=>`https://drive.google.com/uc?export=view&id=${u}`)}catch(i){throw console.error("Direct loading failed:",i),new Error(`Unable to load images. Please ensure:
1
+ (function(T,V){typeof exports=="object"&&typeof module<"u"?V(exports):typeof define=="function"&&define.amd?define(["exports"],V):(T=typeof globalThis<"u"?globalThis:T||self,V(T.ImageCloud={}))})(this,(function(T){"use strict";const V=Object.freeze({none:"none",sm:"0 2px 4px rgba(0,0,0,0.1)",md:"0 4px 16px rgba(0,0,0,0.4)",lg:"0 8px 32px rgba(0,0,0,0.5)",glow:"0 0 30px rgba(255,255,255,0.6)"}),lt=Object.freeze({energetic:Object.freeze({overshoot:.25,bounces:2,decayRatio:.5}),playful:Object.freeze({overshoot:.15,bounces:1,decayRatio:.5}),subtle:Object.freeze({overshoot:.08,bounces:1,decayRatio:.5})}),ht=Object.freeze({gentle:Object.freeze({stiffness:150,damping:30,mass:1,oscillations:2}),bouncy:Object.freeze({stiffness:300,damping:15,mass:1,oscillations:4}),wobbly:Object.freeze({stiffness:180,damping:12,mass:1.5,oscillations:5}),snappy:Object.freeze({stiffness:400,damping:25,mass:.8,oscillations:2})}),dt=Object.freeze({gentle:Object.freeze({amplitude:30,frequency:1.5,decay:!0,decayRate:.9,phase:0}),playful:Object.freeze({amplitude:50,frequency:2.5,decay:!0,decayRate:.7,phase:0}),serpentine:Object.freeze({amplitude:60,frequency:3,decay:!1,decayRate:1,phase:0}),flutter:Object.freeze({amplitude:20,frequency:4,decay:!0,decayRate:.5,phase:0})}),ut=Object.freeze({type:"linear"}),gt=Object.freeze({mode:"none"}),mt=Object.freeze({mode:"none"}),It=Object.freeze({default:Object.freeze({border:Object.freeze({width:0,color:"#000000",radius:0,style:"solid"}),shadow:"none",filter:Object.freeze({}),opacity:1,cursor:"pointer",outline:Object.freeze({width:0,color:"#000000",style:"solid",offset:0})}),hover:Object.freeze({shadow:"none"}),focused:Object.freeze({shadow:"none"})}),Zt=Object.freeze({rows:1,amplitude:100,frequency:2,phaseShift:0,synchronization:"offset"}),Kt=Object.freeze({mobile:Object.freeze({maxWidth:767}),tablet:Object.freeze({maxWidth:1199})}),Qt=Object.freeze({mode:"adaptive",minSize:50,maxSize:400,variance:Object.freeze({min:1,max:1})}),te=Object.freeze({mode:"none",range:Object.freeze({min:-15,max:15})}),Tt=Object.freeze({sizing:Qt,rotation:te}),ft=Object.freeze({validateUrls:!0,validationTimeout:5e3,validationMethod:"head",allowedExtensions:["jpg","jpeg","png","gif","webp","bmp"]}),At=Object.freeze({enabled:!1,centers:!1,loaders:!1}),b=Object.freeze({loaders:[],config:Object.freeze({loaders:ft,debug:At}),image:Tt,layout:Object.freeze({algorithm:"radial",scaleDecay:0,responsive:Kt,targetCoverage:.6,densityFactor:1,spacing:Object.freeze({padding:50,minGap:20})}),animation:Object.freeze({duration:600,easing:Object.freeze({default:"cubic-bezier(0.4, 0.0, 0.2, 1)",bounce:"cubic-bezier(0.68, -0.55, 0.265, 1.55)",focus:"cubic-bezier(0.4, 0.0, 0.2, 1)"}),queue:Object.freeze({enabled:!0,interval:150,maxConcurrent:void 0}),performance:Object.freeze({useGPU:void 0,reduceMotion:void 0}),entry:Object.freeze({start:Object.freeze({position:"nearest-edge",offset:100,circular:Object.freeze({radius:"120%",distribution:"even"})}),timing:Object.freeze({duration:600}),easing:"cubic-bezier(0.25, 1, 0.5, 1)",path:ut,rotation:gt,scale:mt})}),interaction:Object.freeze({focus:Object.freeze({scalePercent:.8,zIndex:1e3,animationDuration:void 0}),navigation:Object.freeze({keyboard:void 0,swipe:void 0,mouseWheel:void 0}),gestures:Object.freeze({pinchToZoom:void 0,doubleTapToFocus:void 0})}),rendering:Object.freeze({responsive:Object.freeze({breakpoints:Object.freeze({mobile:768,tablet:void 0,desktop:void 0}),mobileDetection:()=>typeof window>"u"?!1:window.innerWidth<=768}),ui:Object.freeze({showLoadingSpinner:!1,showImageCounter:!1,showThumbnails:void 0,theme:void 0}),performance:Object.freeze({lazyLoad:void 0,preloadCount:void 0,imageQuality:void 0})}),styling:It});function tt(n,t){if(!n)return t||{};if(!t)return{...n};const e={...n};return t.border!==void 0&&(e.border={...n.border,...t.border}),t.borderTop!==void 0&&(e.borderTop={...n.borderTop,...t.borderTop}),t.borderRight!==void 0&&(e.borderRight={...n.borderRight,...t.borderRight}),t.borderBottom!==void 0&&(e.borderBottom={...n.borderBottom,...t.borderBottom}),t.borderLeft!==void 0&&(e.borderLeft={...n.borderLeft,...t.borderLeft}),t.filter!==void 0&&(e.filter={...n.filter,...t.filter}),t.outline!==void 0&&(e.outline={...n.outline,...t.outline}),t.shadow!==void 0&&(e.shadow=t.shadow),t.opacity!==void 0&&(e.opacity=t.opacity),t.cursor!==void 0&&(e.cursor=t.cursor),t.className!==void 0&&(e.className=t.className),t.objectFit!==void 0&&(e.objectFit=t.objectFit),t.aspectRatio!==void 0&&(e.aspectRatio=t.aspectRatio),t.borderRadiusTopLeft!==void 0&&(e.borderRadiusTopLeft=t.borderRadiusTopLeft),t.borderRadiusTopRight!==void 0&&(e.borderRadiusTopRight=t.borderRadiusTopRight),t.borderRadiusBottomRight!==void 0&&(e.borderRadiusBottomRight=t.borderRadiusBottomRight),t.borderRadiusBottomLeft!==void 0&&(e.borderRadiusBottomLeft=t.borderRadiusBottomLeft),e}function ee(n,t){if(!t)return{...n};const e=tt(n.default,t.default),i=tt(tt(e,n.hover),t.hover),o=tt(tt(e,n.focused),t.focused);return{default:e,hover:i,focused:o}}function ie(n,t){if(!t)return{...n};const e={...n};if(t.sizing!==void 0&&(e.sizing={...n.sizing,...t.sizing},t.sizing.variance)){const i=t.sizing.variance,o=i.min!==void 0&&i.min>=.25&&i.min<=1?i.min:n.sizing?.variance?.min??1,s=i.max!==void 0&&i.max>=1&&i.max<=1.75?i.max:n.sizing?.variance?.max??1;e.sizing.variance={min:o,max:s}}if(t.rotation!==void 0&&(e.rotation={...n.rotation,...t.rotation},t.rotation.range)){const i=t.rotation.range,o=i.min!==void 0&&i.min>=-180&&i.min<=0?i.min:n.rotation?.range?.min??-15,s=i.max!==void 0&&i.max>=0&&i.max<=180?i.max:n.rotation?.range?.max??15;e.rotation.range={min:o,max:s}}return e}function ne(n){const t=n.layout?.rotation;if(t&&"enabled"in t)return{rotation:{mode:t.enabled?"random":"none",range:t.range}}}function oe(n){const t=n.layout?.sizing?.variance;if(t)return{sizing:{mode:"adaptive",variance:t}}}function se(n={}){const t=ne(n),e=oe(n);let i=n.image;(t||e)&&(i={...e||{},...t||{},...i},i.rotation&&t?.rotation&&n.image?.rotation&&(i.rotation={...t.rotation,...n.image.rotation}));const o=[...n.loaders??[]];n.images&&n.images.length>0&&o.unshift({static:{sources:[{urls:n.images}]}});const r={loaders:{...ft,...n.config?.loaders??{}}},a={loaders:o,config:r,image:ie(Tt,i),layout:{...b.layout},animation:{...b.animation},interaction:{...b.interaction},rendering:{...b.rendering},styling:ee(It,n.styling)};return n.layout&&(a.layout={...b.layout,...n.layout},n.layout.responsive&&(a.layout.responsive={...b.layout.responsive,mobile:n.layout.responsive.mobile?{...b.layout.responsive.mobile,...n.layout.responsive.mobile}:b.layout.responsive.mobile,tablet:n.layout.responsive.tablet?{...b.layout.responsive.tablet,...n.layout.responsive.tablet}:b.layout.responsive.tablet}),n.layout.spacing&&(a.layout.spacing={...b.layout.spacing,...n.layout.spacing})),n.animation&&(a.animation={...b.animation,...n.animation},n.animation.easing&&(a.animation.easing={...b.animation.easing,...n.animation.easing}),n.animation.queue&&(a.animation.queue={...b.animation.queue,...n.animation.queue}),n.animation.performance&&(a.animation.performance={...b.animation.performance,...n.animation.performance}),n.animation.entry&&(a.animation.entry={...b.animation.entry,...n.animation.entry,start:n.animation.entry.start?{...b.animation.entry.start,...n.animation.entry.start,circular:n.animation.entry.start.circular?{...b.animation.entry.start.circular,...n.animation.entry.start.circular}:b.animation.entry.start.circular}:b.animation.entry.start,timing:n.animation.entry.timing?{...b.animation.entry.timing,...n.animation.entry.timing}:b.animation.entry.timing,path:n.animation.entry.path?{...ut,...n.animation.entry.path}:b.animation.entry.path,rotation:n.animation.entry.rotation?{...gt,...n.animation.entry.rotation}:b.animation.entry.rotation,scale:n.animation.entry.scale?{...mt,...n.animation.entry.scale}:b.animation.entry.scale})),n.interaction&&(a.interaction={...b.interaction,...n.interaction},n.interaction.focus&&(a.interaction.focus={...b.interaction.focus,...n.interaction.focus}),n.interaction.navigation&&(a.interaction.navigation={...b.interaction.navigation,...n.interaction.navigation}),n.interaction.gestures&&(a.interaction.gestures={...b.interaction.gestures,...n.interaction.gestures})),n.rendering&&(a.rendering={...b.rendering,...n.rendering},n.rendering.responsive&&(a.rendering.responsive={...b.rendering.responsive,...n.rendering.responsive,breakpoints:n.rendering.responsive.breakpoints?{...b.rendering.responsive.breakpoints,...n.rendering.responsive.breakpoints}:b.rendering.responsive.breakpoints,mobileDetection:n.rendering.responsive.mobileDetection?n.rendering.responsive.mobileDetection:b.rendering.responsive.mobileDetection}),n.rendering.ui&&(a.rendering.ui={...b.rendering.ui,...n.rendering.ui}),n.rendering.performance&&(a.rendering.performance={...b.rendering.performance,...n.rendering.performance})),a.config.debug={...At,...n.config?.debug??{}},a}function ae(n,t){return{...n?lt[n]:lt.playful,...t}}function re(n,t){return{...n?ht[n]:ht.gentle,...t}}function ce(n,t){return{...n?dt[n]:dt.gentle,...t}}class Ct{constructor(t){this.activeAnimations=new Map,this.animationIdCounter=0,this.config=t}buildTransformString(t){const e=["translate(-50%, -50%)"];if(t.x!==void 0||t.y!==void 0){const i=t.x??0,o=t.y??0;e.push(`translate(${i}px, ${o}px)`)}return t.rotation!==void 0&&e.push(`rotate(${t.rotation}deg)`),t.scale!==void 0&&e.push(`scale(${t.scale})`),e.join(" ")}animateTransformCancellable(t,e,i,o=null,s=null){this.cancelAllAnimations(t);const r=o??this.config.duration,a=s??this.config.easing.default,h=this.buildTransformString(e),c=this.buildTransformString(i);t.style.transition="none";const u=t.animate([{transform:h},{transform:c}],{duration:r,easing:a,fill:"forwards"}),l={id:`anim-${++this.animationIdCounter}`,element:t,animation:u,fromState:e,toState:i,startTime:performance.now(),duration:r};return this.activeAnimations.set(t,l),u.finished.then(()=>{t.style.transform=c,this.activeAnimations.delete(t)}).catch(()=>{this.activeAnimations.delete(t)}),l}cancelAnimation(t,e=!0){const i=this.getCurrentTransform(t.element);if(t.animation.cancel(),e){const o=this.buildTransformString({x:i.x,y:i.y,rotation:i.rotation,scale:i.scale});t.element.style.transform=o}return this.activeAnimations.delete(t.element),i}cancelAllAnimations(t){const e=this.activeAnimations.get(t);e&&this.cancelAnimation(e,!1);const i=t.getAnimations();for(const o of i)o.cancel()}getCurrentTransform(t){const i=getComputedStyle(t).transform;if(i==="none"||!i)return{x:0,y:0,rotation:0,scale:1};const o=new DOMMatrix(i),s=Math.sqrt(o.a*o.a+o.b*o.b),r=Math.atan2(o.b,o.a)*(180/Math.PI),a=o.e,h=o.f;return{x:a,y:h,rotation:r,scale:s}}hasActiveAnimation(t){return this.activeAnimations.has(t)}getAnimationHandle(t){return this.activeAnimations.get(t)}animateTransform(t,e,i=null,o=null){return new Promise(s=>{const r=i??this.config.duration,a=o??this.config.easing.default;t.style.transition=`transform ${r}ms ${a}, box-shadow ${r}ms ${a}`,t.style.transform=this.buildTransformString(e),setTimeout(()=>{s()},r)})}resetTransform(t,e){return this.animateTransform(t,e)}clearTransition(t){t.style.transition=""}wait(t){return new Promise(e=>setTimeout(e,t))}}function Z(n,t,e){return n+(t-n)*e}function le(n,t,e,i){const{overshoot:o,bounces:s,decayRatio:r}=i,a=e.x-t.x,h=e.y-t.y,c=he(s,r);let u=0,l=0,d=1,m=o,y=!1;for(let g=0;g<c.length;g++)if(n<=c[g].time){l=g===0?0:c[g-1].time,d=c[g].time,m=c[g].overshoot,y=c[g].isOvershoot;break}const p=(n-l)/(d-l);if(y)u=1+m*ot(p);else if(l===0)u=ot(p);else{const f=1+(c.find((S,v)=>S.time>l&&v>0&&c[v-1].isOvershoot)?.overshoot||m);u=Z(f,1,ot(p))}return{x:t.x+a*u,y:t.y+h*u}}function he(n,t){const e=[];let i=.6;e.push({time:i,overshoot:0,isOvershoot:!1});let o=.15;const r=.4/(n*2);for(let a=0;a<n;a++)i+=r,e.push({time:i,overshoot:o,isOvershoot:!0}),i+=r,e.push({time:i,overshoot:o*t,isOvershoot:!1}),o*=t;return e.push({time:1,overshoot:0,isOvershoot:!1}),e}function de(n,t,e,i){const{stiffness:o,damping:s,mass:r,oscillations:a}=i,h=e.x-t.x,c=e.y-t.y,u=Math.sqrt(o/r),l=s/(2*Math.sqrt(o*r));let d;if(l<1){const m=u*Math.sqrt(1-l*l),y=Math.exp(-l*u*n*3),p=Math.cos(m*n*a*Math.PI);d=1-y*p}else d=1-Math.exp(-u*n*3);return d=Math.max(0,Math.min(d,1.3)),{x:t.x+h*d,y:t.y+c*d}}function ue(n,t,e,i){const{amplitude:o,frequency:s,decay:r,decayRate:a,phase:h}=i,c=e.x-t.x,u=e.y-t.y,l=Math.sqrt(c*c+u*u),d=l>0?-u/l:0,m=l>0?c/l:1,y=s*Math.PI*2*n+h,p=r?Math.pow(1-n,a):1,g=o*Math.sin(y)*p,f=ge(n);return{x:Z(t.x,e.x,f)+g*d,y:Z(t.y,e.y,f)+g*m}}function ot(n){return 1-(1-n)*(1-n)}function ge(n){return 1-Math.pow(1-n,3)}function me(n,t,e){const{amplitude:i,frequency:o,decay:s}=e,r=Math.sin(n*o*Math.PI*2),a=s?Math.pow(1-n,2):1,h=i*r*a;return t+h}function fe(n,t,e){const{overshoot:i,bounces:o}=e,s=[];s.push({time:.5,scale:i});let r=i;const a=.5,c=.5/(o*2);let u=.5;for(let d=0;d<o;d++){const m=1-(r-1)*a;u+=c,s.push({time:u,scale:m}),r=1+(r-1)*a*a,u+=c,d<o-1&&s.push({time:u,scale:r})}s.push({time:1,scale:1});let l=1;for(let d=0;d<s.length;d++)if(n<=s[d].time){const m=d===0?0:s[d-1].time,y=d===0?1:s[d-1].scale,p=(n-m)/(s[d].time-m),g=ot(p);l=y+(s[d].scale-y)*g;break}return l*t}function Rt(n){const{element:t,startPosition:e,endPosition:i,pathConfig:o,duration:s,imageWidth:r,imageHeight:a,rotation:h,scale:c,onComplete:u,rotationConfig:l,startRotation:d,scaleConfig:m,startScale:y}=n,p=o.type,g=d!==void 0&&d!==h,f=l?.mode==="wobble",S=l?.wobble||{amplitude:15,frequency:3,decay:!0},v=g||f,w=y!==void 0&&y!==c,x=m?.mode==="pop",E=m?.pop||{overshoot:1.2,bounces:1};if((p==="linear"||p==="arc")&&!v&&!(w||x)){u&&u();return}const M=performance.now(),z=-r/2,_=-a/2;function H(X){const j=X-M,C=Math.min(j/s,1);let O;switch(p){case"bounce":{const $=ae(o.bouncePreset,o.bounce);O=le(C,e,i,$);break}case"elastic":{const $=re(o.elasticPreset,o.elastic);O=de(C,e,i,$);break}case"wave":{const $=ce(o.wavePreset,o.wave);O=ue(C,e,i,$);break}default:O={x:Z(e.x,i.x,C),y:Z(e.y,i.y,C)}}const W=O.x-i.x,N=O.y-i.y;let L;f?L=me(C,h,S):g?L=Z(d,h,C):L=h;let R;x?R=fe(C,c,E):w?R=Z(y,c,C):R=c,t.style.transform=`translate(${z}px, ${_}px) translate(${W}px, ${N}px) rotate(${L}deg) scale(${R})`,C<1?requestAnimationFrame(H):(t.style.transform=`translate(${z}px, ${_}px) rotate(${h}deg) scale(${c})`,u&&u())}requestAnimationFrame(H)}function Lt(n){return n==="bounce"||n==="elastic"||n==="wave"}const pe={radial:"center",spiral:"center",grid:"top",cluster:"nearest-edge",random:"nearest-edge",wave:"left"};class Ft{constructor(t,e){this.config=t,this.layoutAlgorithm=e,this.resolvedStartPosition=this.resolveStartPosition(),this.pathConfig=t.path||ut,this.rotationConfig=t.rotation||gt,this.scaleConfig=t.scale||mt}resolveStartPosition(){return this.config.start.position?this.config.start.position:pe[this.layoutAlgorithm]||"nearest-edge"}calculateStartPosition(t,e,i,o,s){const r=this.resolvedStartPosition,a=this.config.start.offset??100;switch(r){case"nearest-edge":return this.calculateNearestEdge(t,e,i,a);case"top":return this.calculateEdgePosition("top",t,e,i,a);case"bottom":return this.calculateEdgePosition("bottom",t,e,i,a);case"left":return this.calculateEdgePosition("left",t,e,i,a);case"right":return this.calculateEdgePosition("right",t,e,i,a);case"center":return this.calculateCenterPosition(i,t,e);case"random-edge":return this.calculateRandomEdge(t,e,i,a);case"circular":return this.calculateCircularPosition(t,e,i,o,s);default:return this.calculateNearestEdge(t,e,i,a)}}calculateNearestEdge(t,e,i,o){const s=t.x,r=t.y,a=s,h=i.width-s,c=r,u=i.height-r,l=Math.min(a,h,c,u);let d=t.x,m=t.y;return l===a?d=-(e.width+o):l===h?d=i.width+o:l===c?m=-(e.height+o):m=i.height+o,{x:d,y:m}}calculateEdgePosition(t,e,i,o,s){let r=e.x,a=e.y;switch(t){case"top":a=-(i.height+s);break;case"bottom":a=o.height+s;break;case"left":r=-(i.width+s);break;case"right":r=o.width+s;break}return{x:r,y:a}}calculateCenterPosition(t,e,i){const o=t.width/2,s=t.height/2;return{x:o,y:s,useScale:!0}}calculateRandomEdge(t,e,i,o){const s=["top","bottom","left","right"],r=s[Math.floor(Math.random()*s.length)];return this.calculateEdgePosition(r,t,e,i,o)}calculateCircularPosition(t,e,i,o,s){const r=this.config.start.circular||{},a=r.distribution||"even";let h;const c=r.radius||"120%";if(typeof c=="string"&&c.endsWith("%")){const p=parseFloat(c)/100;h=Math.sqrt(i.width**2+i.height**2)*p/2}else h=typeof c=="number"?c:500;let u;a==="even"?u=o/s*2*Math.PI:u=Math.random()*2*Math.PI;const l=i.width/2,d=i.height/2,m=l+Math.cos(u)*h,y=d+Math.sin(u)*h;return{x:m,y}}getAnimationParams(t){const e=this.config.timing.duration,i=this.config.easing;return{startTransform:"",duration:e,delay:0,easing:i}}buildStartTransform(t,e,i,o,s,r,a,h){const c=t.x-e.x,u=t.y-e.y,l=a!==void 0?a:i,d=h!==void 0?h:o,m=s!==void 0?-s/2:0,y=r!==void 0?-r/2:0,p=s!==void 0?`translate(${m}px, ${y}px)`:"translate(-50%, -50%)";return t.useScale?`${p} translate(${c}px, ${u}px) rotate(${l}deg) scale(0)`:`${p} translate(${c}px, ${u}px) rotate(${l}deg) scale(${d})`}buildFinalTransform(t,e,i,o){if(i!==void 0&&o!==void 0){const s=-i/2,r=-o/2;return`translate(${s}px, ${r}px) rotate(${t}deg) scale(${e})`}return`translate(-50%, -50%) rotate(${t}deg) scale(${e})`}getTransitionCSS(){const t=this.config.timing.duration,e=this.config.easing;return this.requiresJSAnimation()?`opacity ${t}ms ease-out`:`opacity ${t}ms ease-out, transform ${t}ms ${e}`}requiresJSAnimation(){return Lt(this.pathConfig.type)}getPathConfig(){return this.pathConfig}getPathType(){return this.pathConfig.type}getTiming(){return{duration:this.config.timing.duration}}getRotationConfig(){return this.rotationConfig}getRotationMode(){return this.rotationConfig.mode}calculateStartRotation(t){switch(this.rotationConfig.mode){case"none":return t;case"settle":{const i=this.rotationConfig.startRotation;if(i===void 0)return t+(Math.random()-.5)*60;if(typeof i=="number")return i;const o=i.max-i.min;return i.min+Math.random()*o}case"spin":{const i=this.rotationConfig.spinCount??1,o=this.resolveSpinDirection(t);return t+i*360*o}case"random":return t+(Math.random()-.5)*60;case"wobble":return t;default:return t}}resolveSpinDirection(t){switch(this.rotationConfig.direction??"auto"){case"clockwise":return-1;case"counterclockwise":return 1;case"random":return Math.random()<.5?1:-1;default:return t>=0?1:-1}}requiresJSRotation(){return this.rotationConfig.mode==="wobble"}calculateWobbleRotation(t,e){if(this.rotationConfig.mode!=="wobble")return e;const i=this.rotationConfig.wobble||{amplitude:15,frequency:3,decay:!0},{amplitude:o,frequency:s,decay:r}=i,a=Math.sin(t*s*Math.PI*2),h=r?Math.pow(1-t,2):1,c=o*a*h;return e+c}getScaleConfig(){return this.scaleConfig}getScaleMode(){return this.scaleConfig.mode}calculateStartScale(t){switch(this.scaleConfig.mode){case"none":return t;case"grow":return(this.scaleConfig.startScale??.3)*t;case"shrink":return(this.scaleConfig.startScale??1.5)*t;case"pop":return t;case"random":{const i=this.scaleConfig.range??{min:.5,max:1};return(i.min+Math.random()*(i.max-i.min))*t}default:return t}}requiresJSScale(){return this.scaleConfig.mode==="pop"}calculatePopScale(t,e){if(this.scaleConfig.mode!=="pop")return e;const i=this.scaleConfig.pop||{overshoot:1.2,bounces:1},{overshoot:o,bounces:s}=i,r=this.generateScaleBounceKeyframes(s,o);let a=e;for(let h=0;h<r.length;h++)if(t<=r[h].time){const c=h===0?0:r[h-1].time,u=h===0?e:r[h-1].scale,l=(t-c)/(r[h].time-c),d=this.easeOutQuad(l);a=u+(r[h].scale-u)*d;break}return a*e}generateScaleBounceKeyframes(t,e){const i=[];i.push({time:.5,scale:e});let o=e;const s=.5,a=.5/(t*2);let h=.5;for(let c=0;c<t;c++){const u=1-(o-1)*s;h+=a,i.push({time:h,scale:u}),o=1+(o-1)*s*s,h+=a,c<t-1&&i.push({time:h,scale:o})}return i.push({time:1,scale:1}),i}easeOutQuad(t){return 1-(1-t)*(1-t)}}class Mt{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){const o=[],{width:s,height:r}=e,a=this.config.spacing.padding,h=i.fixedHeight??200,c=this.imageConfig.rotation?.mode??"none",u=this.imageConfig.rotation?.range?.min??-15,l=this.imageConfig.rotation?.range?.max??15,d=this.imageConfig.sizing?.variance?.min??1,m=this.imageConfig.sizing?.variance?.max??1,y=d!==1||m!==1,g=h*1.5/2,f=h/2,S=s-a-g,v=r-a-f,w=a+g,x=a+f;for(let E=0;E<t;E++){const A=this.random(w,S),M=this.random(x,v),z=c==="random"?this.random(u,l):0,_=y?this.random(d,m):1,H=h*_,X={id:E,x:A,y:M,rotation:z,scale:_,baseSize:H};o.push(X)}return o}random(t,e){return Math.random()*(e-t)+t}}class zt{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){const o=[],{width:s,height:r}=e,a=i.fixedHeight??200,h=this.imageConfig.rotation?.mode??"none",c=this.imageConfig.rotation?.range?.min??-15,u=this.imageConfig.rotation?.range?.max??15,l=this.imageConfig.sizing?.variance?.min??1,d=this.imageConfig.sizing?.variance?.max??1,m=l!==1||d!==1,y=this.config.scaleDecay??0,p=i.fixedHeight??a,g=s/2,f=r/2,S=Math.ceil(Math.sqrt(t));if(t>0){const x=m?this.random(l,d):1,E=p*x;o.push({id:0,x:g,y:f,rotation:h==="random"?this.random(c*.33,u*.33):0,scale:x,baseSize:E,zIndex:100})}let v=1,w=1;for(;v<t;){const x=w/S,E=y>0?1-x*y*.5:1,A=w*(p*.8),M=A*1.5,z=Math.PI*(3*(M+A)-Math.sqrt((3*M+A)*(M+3*A))),_=this.estimateWidth(p),H=Math.floor(z/(_*.7));if(H===0){w++;continue}const X=2*Math.PI/H,j=w*(20*Math.PI/180);for(let C=0;C<H&&v<t;C++){const O=C*X+j,W=m?this.random(l,d):1,N=E*W,L=p*N;let R=g+Math.cos(O)*M,$=f+Math.sin(O)*A;const P=this.config.spacing.padding??50,U=L*1.5/2,F=L/2;R-U<P?R=P+U:R+U>s-P&&(R=s-P-U),$-F<P?$=P+F:$+F>r-P&&($=r-P-F);const G=h==="random"?this.random(c,u):0;o.push({id:v,x:R,y:$,rotation:G,scale:N,baseSize:L,zIndex:Math.max(1,100-w)}),v++}w++}return o}estimateWidth(t){return t*1.4}random(t,e){return Math.random()*(e-t)+t}}const ye={columns:"auto",rows:"auto",stagger:"none",jitter:0,overlap:0,fillDirection:"row",alignment:"center",gap:10,overflowOffset:.25},Dt=[{x:1,y:1},{x:-1,y:-1},{x:1,y:-1},{x:-1,y:1},{x:-1,y:0},{x:1,y:0},{x:0,y:-1},{x:0,y:1}];class Ot{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){const o=[],{width:s,height:r}=e,a={...ye,...this.config.grid},h=this.config.spacing.padding,c=i.fixedHeight??200,u=this.imageConfig.rotation?.mode??"none",l=this.imageConfig.sizing?.variance?.min??1,d=this.imageConfig.sizing?.variance?.max??1,m=l!==1||d!==1,y=s-2*h,p=r-2*h,{columns:g,rows:f}=this.calculateGridDimensions(t,y,p,c,a),S=a.stagger==="row",v=a.stagger==="column",w=S?g+.5:g,x=v?f+.5:f,E=(y-a.gap*(g-1))/w,A=(p-a.gap*(f-1))/x,M=S?E/2:0,z=v?A/2:0,_=1+a.overlap,H=Math.min(E,A)*_,X=i.fixedHeight?Math.min(i.fixedHeight,H):H,j=g*E+(g-1)*a.gap+M,C=f*A+(f-1)*a.gap+z,O=h+(y-j)/2,W=h+(p-C)/2,N=g*f,L=a.columns!=="auto"&&a.rows!=="auto",R=L&&t>N;typeof window<"u"&&(window.__gridOverflowDebug={gridConfigColumns:a.columns,gridConfigRows:a.rows,columns:g,rows:f,cellCount:N,hasFixedGrid:L,imageCount:t,isOverflowMode:R});const $=R?new Array(N).fill(0):[],P=Math.min(E,A)*a.overflowOffset;for(let D=0;D<t;D++){let U,F,G=0;if(R&&D>=N){const Y=D-N,k=Y%N;G=Math.floor(Y/N)+1,$[k]++,a.fillDirection==="row"?(U=k%g,F=Math.floor(k/g)):(F=k%f,U=Math.floor(k/f))}else a.fillDirection==="row"?(U=D%g,F=Math.floor(D/g)):(F=D%f,U=Math.floor(D/f));let q=O+U*(E+a.gap)+E/2,B=W+F*(A+a.gap)+A/2;if(a.stagger==="row"&&F%2===1?q+=E/2:a.stagger==="column"&&U%2===1&&(B+=A/2),G>0){const Y=(G-1)%Dt.length,k=Dt[Y];q+=k.x*P,B+=k.y*P}if(a.jitter>0){const Y=E/2*a.jitter,k=A/2*a.jitter;q+=this.random(-Y,Y),B+=this.random(-k,k)}let J=q,K=B;if(!R&&a.fillDirection==="row"){const Y=t%g||g;if(F===Math.floor((t-1)/g)&&Y<g){const Vt=Y*E+(Y-1)*a.gap;let xt=0;a.alignment==="center"?xt=(j-Vt)/2:a.alignment==="end"&&(xt=j-Vt),J+=xt}}const yt=m?this.random(l,d):1,Q=X*yt,rt=Q*1.5/2,ct=Q/2,vt=h+rt,wt=s-h-rt,Fe=h+ct,Me=r-h-ct;J=Math.max(vt,Math.min(J,wt)),K=Math.max(Fe,Math.min(K,Me));let Et=0;if(u==="random"){const Y=this.imageConfig.rotation?.range?.min??-15,k=this.imageConfig.rotation?.range?.max??15;a.jitter>0?Et=this.random(Y*a.jitter,k*a.jitter):Et=this.random(Y,k)}let St;R&&G>0?St=50-G:St=R?100+D:D+1,o.push({id:D,x:J,y:K,rotation:Et,scale:yt,baseSize:Q,zIndex:St})}return o}calculateGridDimensions(t,e,i,o,s){let r,a;if(s.columns!=="auto"&&s.rows!=="auto")r=s.columns,a=s.rows;else if(s.columns!=="auto")r=s.columns,a=Math.ceil(t/r);else if(s.rows!=="auto")a=s.rows,r=Math.ceil(t/a);else{const h=e/i;for(r=Math.max(1,Math.round(Math.sqrt(t*h/1.4))),a=Math.ceil(t/r);r>1&&(r-1)*a>=t;)r--}return{columns:Math.max(1,r),rows:Math.max(1,a)}}random(t,e){return Math.random()*(e-t)+t}}const be=Math.PI*(3-Math.sqrt(5)),ve={spiralType:"golden",direction:"counterclockwise",tightness:1,scaleDecay:0,startAngle:0};class $t{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){const o=[],{width:s,height:r}=e,a={...ve,...this.config.spiral},h=this.config.spacing.padding,c=i.fixedHeight??200,u=this.imageConfig.rotation?.mode??"none",l=this.imageConfig.rotation?.range?.min??-15,d=this.imageConfig.rotation?.range?.max??15,m=this.imageConfig.sizing?.variance?.min??1,y=this.imageConfig.sizing?.variance?.max??1,p=m!==1||y!==1,g=this.config.scaleDecay??a.scaleDecay,f=s/2,S=r/2,v=Math.min(f-h-c/2,S-h-c/2),w=a.direction==="clockwise"?-1:1;for(let x=0;x<t;x++){let E,A;if(a.spiralType==="golden")E=x*be*w+a.startAngle,A=this.calculateGoldenRadius(x,t,v,a.tightness);else if(a.spiralType==="archimedean"){const q=x*.5*a.tightness;E=q*w+a.startAngle,A=this.calculateArchimedeanRadius(q,t,v,a.tightness)}else{const q=x*.3*a.tightness;E=q*w+a.startAngle,A=this.calculateLogarithmicRadius(q,t,v,a.tightness)}const M=f+Math.cos(E)*A,z=S+Math.sin(E)*A,_=A/v,H=g>0?1-_*g*.5:1,X=p?this.random(m,y):1,j=H*X,C=c*j,W=C*1.5/2,N=C/2,L=h+W,R=s-h-W,$=h+N,P=r-h-N,D=Math.max(L,Math.min(M,R)),U=Math.max($,Math.min(z,P));let F=0;if(u==="random"){const q=E*180/Math.PI%360,B=this.random(l,d);F=a.spiralType==="golden"?B:q*.1+B*.9}else u==="tangent"&&(F=this.calculateSpiralTangent(E,A,a));const G=t-x;o.push({id:x,x:D,y:U,rotation:F,scale:j,baseSize:C,zIndex:G})}return o}calculateSpiralTangent(t,e,i){let o;if(i.spiralType==="golden")o=t+Math.PI/2;else if(i.spiralType==="archimedean"){const r=1/i.tightness,a=Math.atan(e/r);o=t+a}else{const r=.15/i.tightness,a=Math.atan(1/r);o=t+a}return o*180/Math.PI%360-90}calculateGoldenRadius(t,e,i,o){const r=i/Math.sqrt(e)*Math.sqrt(t)/o;return Math.min(r,i)}calculateArchimedeanRadius(t,e,i,o){const s=e*.5*o;return t/s*i}calculateLogarithmicRadius(t,e,i,o){const s=i*.05,r=.15/o,a=s*Math.exp(r*t),h=e*.3*o,c=s*Math.exp(r*h);return a/c*i}random(t,e){return Math.random()*(e-t)+t}}const we={clusterCount:"auto",clusterSpread:150,clusterSpacing:200,density:"uniform",overlap:.3,distribution:"gaussian"};class Pt{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){const o=[],{width:s,height:r}=e,a={...we,...this.config.cluster},h=this.config.spacing.padding,c=i.fixedHeight??200,u=this.imageConfig.rotation?.mode??"none",l=this.imageConfig.rotation?.range?.min??-15,d=this.imageConfig.rotation?.range?.max??15,m=this.imageConfig.sizing?.variance?.min??1,y=this.imageConfig.sizing?.variance?.max??1,p=m!==1||y!==1,g=this.calculateClusterCount(t,a.clusterCount,s,r,a.clusterSpacing),f=this.generateClusterCenters(g,s,r,h,a),S=new Array(g).fill(0);for(let w=0;w<t;w++)S[w%g]++;let v=0;for(let w=0;w<g;w++){const x=f[w],E=S[w];for(let A=0;A<E;A++){let M,z;if(a.distribution==="gaussian")M=this.gaussianRandom()*x.spread,z=this.gaussianRandom()*x.spread;else{const F=this.random(0,Math.PI*2),G=this.random(0,x.spread);M=Math.cos(F)*G,z=Math.sin(F)*G}const _=1+a.overlap*.5,H=1+a.overlap*.3;M/=_,z/=_;const X=p?this.random(m,y):1,j=H*X,C=c*j;let O=x.x+M,W=x.y+z;const L=C*1.5/2,R=C/2;O=Math.max(h+L,Math.min(O,s-h-L)),W=Math.max(h+R,Math.min(W,r-h-R));const $=u==="random"?this.random(l,d):0,D=Math.sqrt(M*M+z*z)/x.spread,U=Math.round((1-D)*50)+1;o.push({id:v,x:O,y:W,rotation:$,scale:j,baseSize:C,zIndex:U}),v++}}return o}calculateClusterCount(t,e,i,o,s){if(e!=="auto")return Math.max(1,Math.min(e,t));const a=Math.max(1,Math.ceil(t/8)),h=Math.floor(i/s*(o/s)*.6);return Math.max(1,Math.min(a,h,10))}generateClusterCenters(t,e,i,o,s){const r=[],h=o+s.clusterSpread,c=e-o-s.clusterSpread,u=o+s.clusterSpread,l=i-o-s.clusterSpread;for(let d=0;d<t;d++){let m=null,y=-1;for(let p=0;p<100;p++){const g={x:this.random(h,c),y:this.random(u,l),spread:this.calculateClusterSpread(s)};let f=1/0;for(const S of r){const v=g.x-S.x,w=g.y-S.y,x=Math.sqrt(v*v+w*w);f=Math.min(f,x)}if((r.length===0||f>y)&&(m=g,y=f),f>=s.clusterSpacing)break}m&&r.push(m)}return r}calculateClusterSpread(t){return t.density==="uniform"?t.clusterSpread:t.clusterSpread*this.random(.5,1.5)}gaussianRandom(){let t=0,e=0;for(;t===0;)t=Math.random();for(;e===0;)e=Math.random();const i=Math.sqrt(-2*Math.log(t))*Math.cos(2*Math.PI*e);return Math.max(-3,Math.min(3,i))/3}random(t,e){return Math.random()*(e-t)+t}}class Ut{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){const o=[],{width:s,height:r}=e,a=i.fixedHeight??200,h=this.config.spacing.padding??50,c=this.imageConfig.rotation?.mode??"none",u=this.imageConfig.rotation?.range?.min??-15,l=this.imageConfig.rotation?.range?.max??15,d=this.imageConfig.sizing?.variance?.min??1,m=this.imageConfig.sizing?.variance?.max??1,y=d!==1||m!==1,p=i.fixedHeight??a,g={...Zt,...this.config.wave},{rows:f,amplitude:S,frequency:v,phaseShift:w,synchronization:x}=g,E=Math.ceil(t/f),z=p*1.5/2,_=h+z,H=s-h-z,X=H-_,j=E>1?X/(E-1):0,C=h+S+p/2,O=r-h-S-p/2,W=O-C,N=f>1?W/(f-1):0;let L=0;for(let R=0;R<f&&L<t;R++){const $=f===1?(C+O)/2:C+R*N;let P=0;x==="offset"?P=R*w:x==="alternating"&&(P=R*Math.PI);for(let D=0;D<E&&L<t;D++){const U=E===1?(_+H)/2:_+D*j,F=this.calculateWaveY(U,s,S,v,P),G=U,q=$+F,B=y?this.random(d,m):1,J=p*B;let K=0;c==="tangent"?K=this.calculateRotation(U,s,S,v,P):c==="random"&&(K=this.random(u,l));const Q=J*1.5/2,bt=J/2,rt=h+Q,ct=s-h-Q,vt=h+bt,wt=r-h-bt;o.push({id:L,x:Math.max(rt,Math.min(G,ct)),y:Math.max(vt,Math.min(q,wt)),rotation:K,scale:B,baseSize:J,zIndex:L+1}),L++}}return o}calculateWaveY(t,e,i,o,s){const r=t/e;return i*Math.sin(o*r*2*Math.PI+s)}calculateRotation(t,e,i,o,s){const r=t/e,a=i*o*2*Math.PI*Math.cos(o*r*2*Math.PI+s)/e;return Math.atan(a)*(180/Math.PI)}random(t,e){return Math.random()*(e-t)+t}}class _t{constructor(t){this.config=t.layout,this.imageConfig=t.image,this.layouts=new Map,this.placementLayout=this.initLayout()}initLayout(){switch(this.config.algorithm){case"radial":return new zt(this.config,this.imageConfig);case"grid":return new Ot(this.config,this.imageConfig);case"spiral":return new $t(this.config,this.imageConfig);case"cluster":return new Pt(this.config,this.imageConfig);case"wave":return new Ut(this.config,this.imageConfig);default:return new Mt(this.config,this.imageConfig)}}generateLayout(t,e,i={}){const o=this.placementLayout.generate(t,e,i);return o.forEach(s=>{this.layouts.set(s.id,s)}),o}getOriginalState(t){return this.layouts.get(Number(t))}reset(){this.layouts.clear()}updateConfig(t){t.layout&&(Object.assign(this.config,t.layout),t.layout.algorithm&&t.layout.algorithm!==this.config.algorithm&&(this.placementLayout=this.initLayout())),t.image&&Object.assign(this.imageConfig,t.image)}getBreakpoints(){return this.config.responsive??{mobile:{maxWidth:767},tablet:{maxWidth:1199}}}resolveBreakpoint(t){const e=this.getBreakpoints();return t<=e.mobile.maxWidth?"mobile":t<=e.tablet.maxWidth?"tablet":"screen"}resolveBaseHeight(t){const e=this.imageConfig.sizing;if(!e||e.mode==="adaptive")return;const i=e.height;if(i===void 0)return;if(typeof i=="number")return i;const o=i,s=this.resolveBreakpoint(t);return s==="mobile"?o.mobile??o.tablet??o.screen:s==="tablet"?o.tablet??o.screen??o.mobile:o.screen??o.tablet??o.mobile}calculateAdaptiveSize(t,e,i,o){const s=this.imageConfig.sizing,r=this.resolveBaseHeight(o);if(r!==void 0)return{height:r};const a=s?.minSize??50,h=s?.maxSize??400,c=this.config.targetCoverage??.6,u=this.config.densityFactor??1,{width:l,height:d}=t,p=l*d*c/e;let f=Math.sqrt(p/1.4);f*=u,f=Math.min(f,i);let S=this.clamp(f,a,h);if(S===a&&f<a){const v=Math.max(a*.05,20);S=Math.max(v,f)}return{height:S}}clamp(t,e,i){return Math.max(e,Math.min(i,t))}}var I=(n=>(n.IDLE="idle",n.FOCUSING="focusing",n.FOCUSED="focused",n.UNFOCUSING="unfocusing",n.CROSS_ANIMATING="cross_animating",n))(I||{});function Ee(n){return n in V}function Se(n){return n?Ee(n)?V[n]:n:V.md}function xe(n){if(!n)return"";const t=[];if(n.grayscale!==void 0&&t.push(`grayscale(${n.grayscale})`),n.blur!==void 0&&t.push(`blur(${n.blur}px)`),n.brightness!==void 0&&t.push(`brightness(${n.brightness})`),n.contrast!==void 0&&t.push(`contrast(${n.contrast})`),n.saturate!==void 0&&t.push(`saturate(${n.saturate})`),n.opacity!==void 0&&t.push(`opacity(${n.opacity})`),n.sepia!==void 0&&t.push(`sepia(${n.sepia})`),n.hueRotate!==void 0&&t.push(`hue-rotate(${n.hueRotate}deg)`),n.invert!==void 0&&t.push(`invert(${n.invert})`),n.dropShadow!==void 0)if(typeof n.dropShadow=="string")t.push(`drop-shadow(${n.dropShadow})`);else{const e=n.dropShadow;t.push(`drop-shadow(${e.x}px ${e.y}px ${e.blur}px ${e.color})`)}return t.join(" ")}function et(n){if(!n||n.style==="none"||n.width===0)return"none";const t=n.width??0,e=n.style??"solid",i=n.color??"#000000";return`${t}px ${e} ${i}`}function st(n){if(!n)return{};const t={};if(n.borderRadiusTopLeft!==void 0||n.borderRadiusTopRight!==void 0||n.borderRadiusBottomRight!==void 0||n.borderRadiusBottomLeft!==void 0){const s=n.border?.radius??0;n.borderRadiusTopLeft!==void 0?t.borderTopLeftRadius=`${n.borderRadiusTopLeft}px`:s&&(t.borderTopLeftRadius=`${s}px`),n.borderRadiusTopRight!==void 0?t.borderTopRightRadius=`${n.borderRadiusTopRight}px`:s&&(t.borderTopRightRadius=`${s}px`),n.borderRadiusBottomRight!==void 0?t.borderBottomRightRadius=`${n.borderRadiusBottomRight}px`:s&&(t.borderBottomRightRadius=`${s}px`),n.borderRadiusBottomLeft!==void 0?t.borderBottomLeftRadius=`${n.borderRadiusBottomLeft}px`:s&&(t.borderBottomLeftRadius=`${s}px`)}else n.border?.radius!==void 0&&(t.borderRadius=`${n.border.radius}px`);if(n.borderTop||n.borderRight||n.borderBottom||n.borderLeft){const s=n.border||{},r={...s,...n.borderTop},a={...s,...n.borderRight},h={...s,...n.borderBottom},c={...s,...n.borderLeft};t.borderTop=et(r),t.borderRight=et(a),t.borderBottom=et(h),t.borderLeft=et(c)}else n.border&&(t.border=et(n.border));n.shadow!==void 0&&(t.boxShadow=Se(n.shadow));const o=xe(n.filter);if(t.filter=o||"none",n.opacity!==void 0&&(t.opacity=String(n.opacity)),n.cursor!==void 0&&(t.cursor=n.cursor),n.outline&&n.outline.style!=="none"&&(n.outline.width??0)>0){const s=n.outline.width??0,r=n.outline.style??"solid",a=n.outline.color??"#000000";t.outline=`${s}px ${r} ${a}`,n.outline.offset!==void 0&&(t.outlineOffset=`${n.outline.offset}px`)}return n.objectFit!==void 0&&(t.objectFit=n.objectFit),n.aspectRatio!==void 0&&(t.aspectRatio=n.aspectRatio),t}function it(n,t){t.borderRadius!==void 0&&(n.style.borderRadius=t.borderRadius),t.borderTopLeftRadius!==void 0&&(n.style.borderTopLeftRadius=t.borderTopLeftRadius),t.borderTopRightRadius!==void 0&&(n.style.borderTopRightRadius=t.borderTopRightRadius),t.borderBottomRightRadius!==void 0&&(n.style.borderBottomRightRadius=t.borderBottomRightRadius),t.borderBottomLeftRadius!==void 0&&(n.style.borderBottomLeftRadius=t.borderBottomLeftRadius),t.border!==void 0&&(n.style.border=t.border),t.borderTop!==void 0&&(n.style.borderTop=t.borderTop),t.borderRight!==void 0&&(n.style.borderRight=t.borderRight),t.borderBottom!==void 0&&(n.style.borderBottom=t.borderBottom),t.borderLeft!==void 0&&(n.style.borderLeft=t.borderLeft),t.boxShadow!==void 0&&(n.style.boxShadow=t.boxShadow),t.filter!==void 0&&(n.style.filter=t.filter),t.opacity!==void 0&&(n.style.opacity=t.opacity),t.cursor!==void 0&&(n.style.cursor=t.cursor),t.outline!==void 0&&(n.style.outline=t.outline),t.outlineOffset!==void 0&&(n.style.outlineOffset=t.outlineOffset),t.objectFit!==void 0&&(n.style.objectFit=t.objectFit),t.aspectRatio!==void 0&&(n.style.aspectRatio=t.aspectRatio)}function Ht(n){return n?Array.isArray(n)?n.join(" "):n:""}function nt(n,t){const e=Ht(t);e&&e.split(" ").forEach(i=>{i.trim()&&n.classList.add(i.trim())})}function Nt(n,t){const e=Ht(t);e&&e.split(" ").forEach(i=>{i.trim()&&n.classList.remove(i.trim())})}const jt={UNFOCUSING:999,FOCUSING:1e3};class kt{constructor(t,e,i){this.state=I.IDLE,this.currentFocus=null,this.focusData=null,this.outgoing=null,this.incoming=null,this.focusGeneration=0,this.config=t,this.animationEngine=e,this.defaultStyles=st(i?.default),this.focusedStyles=st(i?.focused),this.defaultClassName=i?.default?.className,this.focusedClassName=i?.focused?.className}getState(){return this.state}isAnimating(){return this.state!==I.IDLE&&this.state!==I.FOCUSED}normalizeScalePercent(t){return t>1?t/100:t}calculateFocusDimensions(t,e,i){const o=this.normalizeScalePercent(this.config.scalePercent),s=i.height*o,r=t/e;let a=s,h=a*r;const c=i.width*o;return h>c&&(h=c,a=h/r),{width:h,height:a}}calculateFocusTransform(t,e){const i=t.width/2,o=t.height/2,s=i-e.x,r=o-e.y;return{x:s,y:r,rotation:0,scale:1}}buildDimensionZoomTransform(t){const e=["translate(-50%, -50%)"];if(t.x!==void 0||t.y!==void 0){const i=t.x??0,o=t.y??0;e.push(`translate(${i}px, ${o}px)`)}return t.rotation!==void 0&&e.push(`rotate(${t.rotation}deg)`),e.join(" ")}animateWithDimensions(t,e,i,o,s,r,a,h){const c=this.buildDimensionZoomTransform(e),u=this.buildDimensionZoomTransform(i);return t.style.transition="none",t.animate([{transform:c,width:`${o}px`,height:`${s}px`},{transform:u,width:`${r}px`,height:`${a}px`}],{duration:h,easing:"cubic-bezier(0.4, 0, 0.2, 1)",fill:"forwards"})}applyFocusedStyling(t,e){t.style.zIndex=String(e),t.classList.add("fbn-ic-focused"),it(t,this.focusedStyles),nt(t,this.focusedClassName)}removeFocusedStyling(t,e){t.style.zIndex=e,t.classList.remove("fbn-ic-focused"),Nt(t,this.focusedClassName),it(t,this.defaultStyles),nt(t,this.defaultClassName)}startFocusAnimation(t,e,i,o,s){const r=t.style.zIndex||"",a=t.offsetWidth,h=t.offsetHeight,c=this.calculateFocusDimensions(a,h,e),u=this.calculateFocusTransform(e,i);this.applyFocusedStyling(t,jt.FOCUSING),this.animationEngine.cancelAllAnimations(t);const l=o??{x:0,y:0,rotation:i.rotation,scale:1},d=s?.width??a,m=s?.height??h,y=this.config.animationDuration??600,p=this.animateWithDimensions(t,l,u,d,m,c.width,c.height,y),g={id:`focus-${Date.now()}`,element:t,animation:p,fromState:l,toState:u,startTime:performance.now(),duration:y};return this.focusData={element:t,originalState:i,focusTransform:u,originalZIndex:r,originalWidth:a,originalHeight:h,focusWidth:c.width,focusHeight:c.height},{element:t,originalState:i,animationHandle:g,direction:"in",originalWidth:a,originalHeight:h}}startUnfocusAnimation(t,e,i,o){t.style.zIndex=String(jt.UNFOCUSING),this.animationEngine.cancelAllAnimations(t);const s=i??this.focusData?.focusTransform??{x:0,y:0,rotation:0,scale:1},r=o?.width??this.focusData?.focusWidth??t.offsetWidth,a=o?.height??this.focusData?.focusHeight??t.offsetHeight,h={x:0,y:0,rotation:e.rotation,scale:1},c=this.focusData?.originalWidth??t.offsetWidth,u=this.focusData?.originalHeight??t.offsetHeight,l=this.config.animationDuration??600,d=this.animateWithDimensions(t,s,h,r,a,c,u,l),m={id:`unfocus-${Date.now()}`,element:t,animation:d,fromState:s,toState:h,startTime:performance.now(),duration:l};return{element:t,originalState:e,animationHandle:m,direction:"out",originalWidth:c,originalHeight:u}}async waitForAnimation(t){try{await t.animation.finished}catch{}}resetElementInstantly(t,e,i,o,s){this.animationEngine.cancelAllAnimations(t);const r=["translate(-50%, -50%)"];r.push("translate(0px, 0px)"),r.push(`rotate(${e.rotation}deg)`),t.style.transition="none",t.style.transform=r.join(" "),o!==void 0&&s!==void 0&&(t.style.width=`${o}px`,t.style.height=`${s}px`),this.removeFocusedStyling(t,i)}async focusImage(t,e,i){if(this.currentFocus===t&&this.state===I.FOCUSED)return this.unfocusImage();if(this.incoming?.element===t&&this.state===I.FOCUSING){const s=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),r={x:s.x,y:s.y,rotation:s.rotation,scale:1},a={width:t.offsetWidth,height:t.offsetHeight};this.outgoing=this.startUnfocusAnimation(t,this.incoming.originalState,r,a),this.incoming=null,this.state=I.UNFOCUSING,await this.waitForAnimation(this.outgoing.animationHandle),this.removeFocusedStyling(this.outgoing.element,this.focusData?.originalZIndex||""),this.outgoing=null,this.currentFocus=null,this.focusData=null,this.state=I.IDLE;return}const o=++this.focusGeneration;switch(this.state){case I.IDLE:if(this.state=I.FOCUSING,this.incoming=this.startFocusAnimation(t,e,i),await this.waitForAnimation(this.incoming.animationHandle),this.focusGeneration!==o)return;this.currentFocus=t,this.incoming=null,this.state=I.FOCUSED;break;case I.FOCUSED:if(this.state=I.CROSS_ANIMATING,this.currentFocus&&this.focusData&&(this.outgoing=this.startUnfocusAnimation(this.currentFocus,this.focusData.originalState)),this.incoming=this.startFocusAnimation(t,e,i),await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(this.incoming.animationHandle)]),this.focusGeneration!==o)return;this.outgoing&&(this.removeFocusedStyling(this.outgoing.element,this.outgoing.originalState.zIndex?.toString()||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=I.FOCUSED;break;case I.FOCUSING:if(this.incoming&&(this.animationEngine.cancelAnimation(this.incoming.animationHandle,!1),this.resetElementInstantly(this.incoming.element,this.incoming.originalState,this.focusData?.originalZIndex||"",this.focusData?.originalWidth,this.focusData?.originalHeight),this.incoming=null),this.incoming=this.startFocusAnimation(t,e,i),await this.waitForAnimation(this.incoming.animationHandle),this.focusGeneration!==o)return;this.currentFocus=t,this.incoming=null,this.state=I.FOCUSED;break;case I.UNFOCUSING:if(this.state=I.CROSS_ANIMATING,this.incoming=this.startFocusAnimation(t,e,i),await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(this.incoming.animationHandle)]),this.focusGeneration!==o)return;this.outgoing&&(this.removeFocusedStyling(this.outgoing.element,this.outgoing.originalState.zIndex?.toString()||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=I.FOCUSED;break;case I.CROSS_ANIMATING:if(this.incoming?.element===t)return;if(this.outgoing?.element===t){const s=this.animationEngine.cancelAnimation(this.outgoing.animationHandle,!0),r={x:s.x,y:s.y,rotation:s.rotation,scale:1},a={width:t.offsetWidth,height:t.offsetHeight};if(this.incoming){const h=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),c={x:h.x,y:h.y,rotation:h.rotation,scale:1},u={width:this.incoming.element.offsetWidth,height:this.incoming.element.offsetHeight};this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,c,u)}else this.outgoing=null;if(this.incoming=this.startFocusAnimation(t,e,i,r,a),await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(this.incoming.animationHandle)]),this.focusGeneration!==o)return;this.outgoing&&(this.removeFocusedStyling(this.outgoing.element,this.outgoing.originalState.zIndex?.toString()||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=I.FOCUSED;return}if(this.outgoing&&(this.animationEngine.cancelAnimation(this.outgoing.animationHandle,!1),this.resetElementInstantly(this.outgoing.element,this.outgoing.originalState,this.outgoing.originalState.zIndex?.toString()||"",this.outgoing.originalWidth,this.outgoing.originalHeight),this.outgoing=null),this.incoming){const s=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),r={x:s.x,y:s.y,rotation:s.rotation,scale:1},a={width:this.incoming.element.offsetWidth,height:this.incoming.element.offsetHeight};this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,r,a)}if(this.incoming=this.startFocusAnimation(t,e,i),await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(this.incoming.animationHandle)]),this.focusGeneration!==o)return;this.outgoing&&(this.removeFocusedStyling(this.outgoing.element,this.outgoing.originalState.zIndex?.toString()||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=I.FOCUSED;break}}async unfocusImage(){const t=++this.focusGeneration;if(!this.currentFocus||!this.focusData){if(this.incoming&&this.state===I.FOCUSING){const s=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),r={x:s.x,y:s.y,rotation:s.rotation,scale:1},a={width:this.incoming.element.offsetWidth,height:this.incoming.element.offsetHeight};if(this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,r,a),this.incoming=null,this.state=I.UNFOCUSING,await this.waitForAnimation(this.outgoing.animationHandle),this.focusGeneration!==t)return;this.removeFocusedStyling(this.outgoing.element,this.focusData?.originalZIndex||""),this.outgoing=null,this.focusData=null,this.state=I.IDLE}return}if(this.state===I.CROSS_ANIMATING&&this.incoming){const s=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),r={x:s.x,y:s.y,rotation:s.rotation,scale:1},a={width:this.incoming.element.offsetWidth,height:this.incoming.element.offsetHeight},h=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,r,a);if(await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(h.animationHandle)]),this.focusGeneration!==t)return;this.outgoing&&this.removeFocusedStyling(this.outgoing.element,this.outgoing.originalState.zIndex?.toString()||""),this.removeFocusedStyling(h.element,this.incoming.originalState.zIndex?.toString()||""),this.outgoing=null,this.incoming=null,this.currentFocus=null,this.focusData=null,this.state=I.IDLE;return}this.state=I.UNFOCUSING;const e=this.currentFocus,i=this.focusData.originalState,o=this.focusData.originalZIndex;this.outgoing=this.startUnfocusAnimation(e,i),await this.waitForAnimation(this.outgoing.animationHandle),this.focusGeneration===t&&(this.removeFocusedStyling(e,o),this.outgoing=null,this.currentFocus=null,this.focusData=null,this.state=I.IDLE)}async swapFocus(t,e,i){return this.focusImage(t,e,i)}getCurrentFocus(){return this.currentFocus}isFocused(t){return this.currentFocus===t&&this.state===I.FOCUSED}isTargetingFocus(t){return this.incoming?.element===t}isInvolved(t){return this.currentFocus===t||this.incoming?.element===t||this.outgoing?.element===t}setDragOffset(t){if(!this.currentFocus||!this.focusData||this.state!==I.FOCUSED)return;const e=this.currentFocus,i=this.focusData.focusTransform,o=["translate(-50%, -50%)"],s=(i.x??0)+t,r=i.y??0;o.push(`translate(${s}px, ${r}px)`),i.rotation!==void 0&&o.push(`rotate(${i.rotation}deg)`),e.style.transition="none",e.style.transform=o.join(" ")}clearDragOffset(t,e=150){if(!this.currentFocus||!this.focusData||this.state!==I.FOCUSED)return;const i=this.currentFocus,o=this.focusData.focusTransform,s=["translate(-50%, -50%)"],r=o.x??0,a=o.y??0;s.push(`translate(${r}px, ${a}px)`),o.rotation!==void 0&&s.push(`rotate(${o.rotation}deg)`);const h=s.join(" ");t?(i.style.transition=`transform ${e}ms ease-out`,i.style.transform=h,setTimeout(()=>{this.currentFocus===i&&(i.style.transition="none")},e)):(i.style.transition="none",i.style.transform=h)}reset(){this.outgoing&&(this.animationEngine.cancelAnimation(this.outgoing.animationHandle,!1),this.resetElementInstantly(this.outgoing.element,this.outgoing.originalState,this.outgoing.originalState.zIndex?.toString()||"",this.outgoing.originalWidth,this.outgoing.originalHeight)),this.incoming&&(this.animationEngine.cancelAnimation(this.incoming.animationHandle,!1),this.resetElementInstantly(this.incoming.element,this.incoming.originalState,this.focusData?.originalZIndex||"",this.focusData?.originalWidth,this.focusData?.originalHeight)),this.currentFocus&&this.focusData&&this.resetElementInstantly(this.currentFocus,this.focusData.originalState,this.focusData.originalZIndex,this.focusData.originalWidth,this.focusData.originalHeight),this.state=I.IDLE,this.currentFocus=null,this.focusData=null,this.outgoing=null,this.incoming=null}}const Ie=50,Te=.5,Ae=20,Ce=.3,Re=150,Le=30,at=class at{constructor(t,e){this.enabled=!1,this.touchState=null,this.recentTouchTimestamp=0,this.container=t,this.callbacks=e,this.boundTouchStart=this.handleTouchStart.bind(this),this.boundTouchMove=this.handleTouchMove.bind(this),this.boundTouchEnd=this.handleTouchEnd.bind(this),this.boundTouchCancel=this.handleTouchCancel.bind(this)}enable(){this.enabled||(this.enabled=!0,this.container.style.touchAction="pan-y",this.container.addEventListener("touchstart",this.boundTouchStart,{passive:!1}),this.container.addEventListener("touchmove",this.boundTouchMove,{passive:!1}),this.container.addEventListener("touchend",this.boundTouchEnd,{passive:!0}),this.container.addEventListener("touchcancel",this.boundTouchCancel,{passive:!0}))}disable(){this.enabled&&(this.enabled=!1,this.container.style.touchAction="",this.container.removeEventListener("touchstart",this.boundTouchStart),this.container.removeEventListener("touchmove",this.boundTouchMove),this.container.removeEventListener("touchend",this.boundTouchEnd),this.container.removeEventListener("touchcancel",this.boundTouchCancel),this.touchState?.isDragging&&this.callbacks.onDragEnd(!1),this.touchState=null)}destroy(){this.disable()}hadRecentTouch(){return Date.now()-this.recentTouchTimestamp<at.TOUCH_CLICK_DELAY}handleTouchStart(t){if(t.touches.length!==1)return;this.recentTouchTimestamp=Date.now();const e=t.touches[0];this.touchState={startX:e.clientX,startY:e.clientY,startTime:performance.now(),currentX:e.clientX,isDragging:!1,isHorizontalSwipe:null}}handleTouchMove(t){if(!this.touchState||t.touches.length!==1)return;const e=t.touches[0],i=e.clientX-this.touchState.startX,o=e.clientY-this.touchState.startY;if(this.touchState.isHorizontalSwipe===null&&Math.sqrt(i*i+o*o)>10){const a=Math.atan2(Math.abs(o),Math.abs(i))*(180/Math.PI);this.touchState.isHorizontalSwipe=a<=Le}if(this.touchState.isHorizontalSwipe!==!1&&this.touchState.isHorizontalSwipe===!0){t.preventDefault(),this.touchState.isDragging=!0,this.touchState.currentX=e.clientX;const s=i*Ce;this.callbacks.onDragOffset(s)}}handleTouchEnd(t){if(!this.touchState)return;this.recentTouchTimestamp=Date.now();const e=this.touchState.currentX-this.touchState.startX,i=performance.now()-this.touchState.startTime,o=Math.abs(e)/i,s=Math.abs(e);let r=!1;this.touchState.isHorizontalSwipe===!0&&this.touchState.isDragging&&(s>=Ie||o>=Te&&s>=Ae)&&(r=!0,e<0?this.callbacks.onNext():this.callbacks.onPrev()),this.touchState.isDragging&&this.callbacks.onDragEnd(r),this.touchState=null}handleTouchCancel(t){this.touchState?.isDragging&&this.callbacks.onDragEnd(!1),this.touchState=null}};at.TOUCH_CLICK_DELAY=300;let pt=at;class Wt{constructor(t){if(this._prepared=!1,this._discoveredUrls=[],this.apiKey=t.apiKey??"",this.apiEndpoint=t.apiEndpoint??"https://www.googleapis.com/drive/v3/files",this.debugLogging=t.debugLogging??!1,this.sources=t.sources??[],!this.sources||this.sources.length===0)throw new Error("GoogleDriveLoader requires at least one source to be configured")}async prepare(t){this._discoveredUrls=[];for(const e of this.sources)if("folders"in e)for(const i of e.folders){const o=e.recursive!==void 0?e.recursive:!0,s=await this.loadFromFolder(i,t,o);this._discoveredUrls.push(...s)}else if("files"in e){const i=await this.loadFiles(e.files,t);this._discoveredUrls.push(...i)}this._prepared=!0}imagesLength(){if(!this._prepared)throw new Error("GoogleDriveLoader.imagesLength() called before prepare()");return this._discoveredUrls.length}imageURLs(){if(!this._prepared)throw new Error("GoogleDriveLoader.imageURLs() called before prepare()");return[...this._discoveredUrls]}isPrepared(){return this._prepared}extractFolderId(t){const e=[/\/folders\/([a-zA-Z0-9_-]+)/,/id=([a-zA-Z0-9_-]+)/];for(const i of e){const o=t.match(i);if(o&&o[1])return o[1]}return null}async loadFromFolder(t,e,i=!0){const o=this.extractFolderId(t);if(!o)throw new Error("Invalid Google Drive folder URL. Please check the URL format.");if(!this.apiKey||this.apiKey==="YOUR_API_KEY_HERE")return this.loadImagesDirectly(o,e);try{return i?await this.loadImagesRecursively(o,e):await this.loadImagesFromSingleFolder(o,e)}catch(s){return console.error("Error loading from Google Drive API:",s),this.loadImagesDirectly(o,e)}}async loadImagesFromSingleFolder(t,e){const i=[],o=`'${t}' in parents and trashed=false`,r=`${this.apiEndpoint}?q=${encodeURIComponent(o)}&fields=files(id,name,mimeType,thumbnailLink)&key=${this.apiKey}`,a=await fetch(r);if(!a.ok)throw new Error(`API request failed: ${a.status} ${a.statusText}`);const c=(await a.json()).files.filter(u=>u.mimeType.startsWith("image/")&&e.isAllowed(u.name));return this.log(`Found ${c.length} images in folder ${t} (non-recursive)`),c.forEach(u=>{i.push(`https://lh3.googleusercontent.com/d/${u.id}=s1600`),this.log(`Added file: ${u.name}`)}),i}async loadFiles(t,e){const i=[];for(const o of t){const s=this.extractFileId(o);if(!s){this.log(`Skipping invalid file URL: ${o}`);continue}if(this.apiKey&&this.apiKey!=="YOUR_API_KEY_HERE")try{const r=`${this.apiEndpoint}/${s}?fields=name,mimeType&key=${this.apiKey}`,a=await fetch(r);if(a.ok){const h=await a.json();h.mimeType.startsWith("image/")&&e.isAllowed(h.name)?(i.push(`https://lh3.googleusercontent.com/d/${s}=s1600`),this.log(`Added file: ${h.name}`)):this.log(`Skipping non-image file: ${h.name} (${h.mimeType})`)}else this.log(`Failed to fetch metadata for file ${s}: ${a.status}`)}catch(r){this.log(`Error fetching metadata for file ${s}:`,r)}else i.push(`https://lh3.googleusercontent.com/d/${s}=s1600`)}return i}extractFileId(t){if(!/[/:.]/.test(t))return t;const e=[/\/file\/d\/([a-zA-Z0-9_-]+)/,/\/open\?id=([a-zA-Z0-9_-]+)/,/id=([a-zA-Z0-9_-]+)/];for(const i of e){const o=t.match(i);if(o&&o[1])return o[1]}return null}async loadImagesRecursively(t,e){const i=[],o=`'${t}' in parents and trashed=false`,r=`${this.apiEndpoint}?q=${encodeURIComponent(o)}&fields=files(id,name,mimeType,thumbnailLink)&key=${this.apiKey}`,a=await fetch(r);if(!a.ok)throw new Error(`API request failed: ${a.status} ${a.statusText}`);const h=await a.json(),c=h.files.filter(l=>l.mimeType.startsWith("image/")&&e.isAllowed(l.name)),u=h.files.filter(l=>l.mimeType==="application/vnd.google-apps.folder");this.log(`Found ${h.files.length} total items in folder ${t}`),h.files.forEach(l=>this.log(` - File: ${l.name} (${l.mimeType})`)),this.log(`- ${c.length} valid files (images only)`),this.log(`- ${u.length} subfolders`),c.forEach(l=>{i.push(`https://lh3.googleusercontent.com/d/${l.id}=s1600`),this.log(`Added file: ${l.name}`)});for(const l of u){this.log(`Loading images from subfolder: ${l.name}`);const d=await this.loadImagesRecursively(l.id,e);i.push(...d)}return i}async loadImagesDirectly(t,e){try{const i=`https://drive.google.com/embeddedfolderview?id=${t}`,o=await fetch(i,{mode:"cors"});if(!o.ok)throw new Error("Cannot access folder directly (CORS or permissions issue)");const s=await o.text(),r=/\/file\/d\/([a-zA-Z0-9_-]+)/g,a=[...s.matchAll(r)];return[...new Set(a.map(u=>u[1]))].map(u=>`https://drive.google.com/uc?export=view&id=${u}`)}catch(i){throw console.error("Direct loading failed:",i),new Error(`Unable to load images. Please ensure:
2
2
  1. The folder is shared publicly (Anyone with the link can view)
3
3
  2. The folder contains image files
4
4
  3. Consider adding a Google Drive API key in config.js for better reliability`)}}manualImageUrls(t){return t.map(e=>`https://drive.google.com/uc?export=view&id=${e}`)}log(...t){this.debugLogging&&typeof console<"u"&&console.log(...t)}}class Gt{constructor(t){if(this._prepared=!1,this._discoveredUrls=[],this.validateUrls=t.validateUrls!==!1,this.validationTimeout=t.validationTimeout??5e3,this.validationMethod=t.validationMethod??"head",this.debugLogging=t.debugLogging??!1,this.sources=t.sources??[],!this.sources||this.sources.length===0)throw new Error("StaticImageLoader requires at least one source to be configured");this.log("StaticImageLoader initialized with config:",t)}async prepare(t){this._discoveredUrls=[],this.log(`Processing ${this.sources.length} source(s)`);for(const e of this.sources)try{const i=await this.processSource(e,t);this._discoveredUrls.push(...i)}catch(i){console.warn("Failed to process source:",e,i)}this._prepared=!0,this.log(`Successfully loaded ${this._discoveredUrls.length} image(s)`)}imagesLength(){if(!this._prepared)throw new Error("StaticImageLoader.imagesLength() called before prepare()");return this._discoveredUrls.length}imageURLs(){if(!this._prepared)throw new Error("StaticImageLoader.imageURLs() called before prepare()");return[...this._discoveredUrls]}isPrepared(){return this._prepared}async processSource(t,e){return t?"urls"in t?await this.processUrls(t.urls,e):"path"in t?await this.processPath(t.path,t.files,e):"json"in t?await this.processJson(t.json,e):(console.warn("Unknown source shape:",t),[]):(console.warn("Invalid source object:",t),[])}async processUrls(t,e){if(!Array.isArray(t))return console.warn("URLs must be an array:",t),[];const i=[];for(const o of t){const s=o.split("/").pop()||o;if(!e.isAllowed(s)){this.log(`Skipping filtered URL: ${o}`);continue}this.validateUrls?await this.validateUrl(o)?i.push(o):console.warn(`Skipping invalid/missing URL: ${o}`):i.push(o)}return i}async processPath(t,e,i){if(!Array.isArray(e))return console.warn("files must be an array:",e),[];const o=[];for(const s of e){if(!i.isAllowed(s)){this.log(`Skipping filtered file: ${s}`);continue}const r=this.constructUrl(t,s);this.validateUrls?await this.validateUrl(r)?o.push(r):console.warn(`Skipping invalid/missing file: ${r}`):o.push(r)}return o}async processJson(t,e){this.log(`Fetching JSON endpoint: ${t}`);const i=new AbortController,o=setTimeout(()=>i.abort(),1e4);try{const s=await fetch(t,{signal:i.signal});if(clearTimeout(o),!s.ok)throw new Error(`HTTP ${s.status} fetching ${t}`);const r=await s.json();if(!r||!Array.isArray(r.images))throw new Error('JSON source must return JSON with shape { "images": ["url1", "url2", ...] }');return this.log(`JSON endpoint returned ${r.images.length} image(s)`),await this.processUrls(r.images,e)}catch(s){throw clearTimeout(o),s instanceof Error&&s.name==="AbortError"?new Error(`Timeout fetching JSON endpoint: ${t}`):s}}async validateUrl(t){if(this.validationMethod==="none")return!0;if(this.validationMethod==="simple")try{return typeof window<"u"?new URL(t,window.location.origin):new URL(t),!0}catch{return!1}if(typeof window>"u")return!0;if(!(t.startsWith(window.location.origin)||t.startsWith("/")))return this.log(`Skipping validation for cross-origin URL: ${t}`),!0;try{const i=new AbortController,o=setTimeout(()=>i.abort(),this.validationTimeout),s=await fetch(t,{method:"HEAD",signal:i.signal});return clearTimeout(o),s.ok?!0:(this.log(`Validation failed for ${t}: HTTP ${s.status}`),!1)}catch(i){return i instanceof Error&&(i.name==="AbortError"?this.log(`Validation timeout for ${t}`):this.log(`Validation failed for ${t}:`,i.message)),!1}}constructUrl(t,e){const i=t.replace(/\/$/,"");if(this.isAbsoluteUrl(t))return`${i}/${e}`;if(typeof window>"u")return`${i}/${e}`;const o=window.location.origin,r=(t.startsWith("/")?t:"/"+t).replace(/\/$/,"");return`${o}${r}/${e}`}isAbsoluteUrl(t){try{return new URL(t),!0}catch{return!1}}log(...t){this.debugLogging&&typeof console<"u"&&console.log(...t)}}class qt{constructor(t){if(this._prepared=!1,this._discoveredUrls=[],this.loaders=t.loaders,this.debugLogging=t.debugLogging??!1,!this.loaders||this.loaders.length===0)throw new Error("CompositeLoader requires at least one loader to be configured");this.log(`CompositeLoader initialized with ${this.loaders.length} loader(s)`)}async prepare(t){this._discoveredUrls=[],this.log(`Preparing ${this.loaders.length} loader(s) in parallel`);const e=this.loaders.map((i,o)=>i.prepare(t).then(()=>{this.log(`Loader ${o} prepared with ${i.imagesLength()} images`)}).catch(s=>{console.warn(`Loader ${o} failed to prepare:`,s)}));await Promise.all(e);for(const i of this.loaders)if(i.isPrepared()){const o=i.imageURLs();this._discoveredUrls.push(...o)}this._prepared=!0,this.log(`CompositeLoader prepared with ${this._discoveredUrls.length} total images`)}imagesLength(){if(!this._prepared)throw new Error("CompositeLoader.imagesLength() called before prepare()");return this._discoveredUrls.length}imageURLs(){if(!this._prepared)throw new Error("CompositeLoader.imageURLs() called before prepare()");return[...this._discoveredUrls]}isPrepared(){return this._prepared}log(...t){this.debugLogging&&typeof console<"u"&&console.log("[CompositeLoader]",...t)}}class Yt{constructor(t){this.allowedExtensions=t||["jpg","jpeg","png","gif","webp","bmp"]}isAllowed(t){const i=t.split("?")[0].split(".").pop()?.toLowerCase();return i?this.allowedExtensions.includes(i):!1}getAllowedExtensions(){return[...this.allowedExtensions]}}const Xt=`