@frybynite/image-cloud 0.9.5 → 0.10.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.
- package/README.md +14 -15
- package/dist/image-cloud-auto-init.js +47 -46
- package/dist/image-cloud-auto-init.js.map +1 -1
- package/dist/image-cloud.js +79 -74
- package/dist/image-cloud.js.map +1 -1
- package/dist/image-cloud.umd.js +3 -3
- package/dist/image-cloud.umd.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/react.d.ts +2 -0
- package/dist/react.js +101 -101
- package/dist/react.js.map +1 -1
- package/dist/vue.d.ts +2 -0
- package/dist/vue.js +53 -53
- package/dist/vue.js.map +1 -1
- package/dist/web-component.d.ts +2 -0
- package/dist/web-component.js +3 -3
- package/dist/web-component.js.map +1 -1
- package/package.json +1 -1
package/dist/image-cloud.umd.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
(function(S,J){typeof exports=="object"&&typeof module<"u"?J(exports):typeof define=="function"&&define.amd?define(["exports"],J):(S=typeof globalThis<"u"?globalThis:S||self,J(S.ImageCloud={}))})(this,(function(S){"use strict";const J=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)"}),ht=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})}),dt=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})}),ut=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})}),ft=Object.freeze({type:"linear"}),gt=Object.freeze({mode:"none"}),mt=Object.freeze({mode:"none"}),Tt=Object.freeze({default:Object.freeze({border:Object.freeze({width:0,color:"#000000",radius:0,style:"solid"}),shadow:"none",clipPath:void 0,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"})}),ne=Object.freeze({tightness:1}),oe=Object.freeze({rows:1,amplitude:100,frequency:2,phaseShift:0,synchronization:"offset"}),se=Object.freeze({spacing:0}),ae=Object.freeze({mobile:Object.freeze({maxWidth:767}),tablet:Object.freeze({maxWidth:1199})}),re=Object.freeze({mode:"adaptive",minSize:50,maxSize:400,variance:Object.freeze({min:1,max:1})}),ce=Object.freeze({mode:"none",range:Object.freeze({min:-15,max:15})}),Lt=Object.freeze({sizing:re,rotation:ce}),pt=Object.freeze({validateUrls:!0,validationTimeout:5e3,validationMethod:"head",allowedExtensions:["jpg","jpeg","png","gif","webp","bmp"]}),Ft=Object.freeze({enabled:!1,centers:!1,loaders:!1}),le=Object.freeze({maxAngle:5,speed:2e3,sync:"random"}),he=Object.freeze({minScale:.95,maxScale:1.05,speed:2400,sync:"random"}),de=Object.freeze({onRatio:.7,speed:3e3,style:"snap"}),ue=Object.freeze({speed:4e3,direction:"clockwise"}),Mt=Object.freeze({type:"none"}),A=Object.freeze({loaders:[],config:Object.freeze({loaders:pt,debug:Ft}),image:Lt,layout:Object.freeze({algorithm:"radial",scaleDecay:0,responsive:ae,targetCoverage:.6,densityFactor:1,spacing:Object.freeze({padding:50})}),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}),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:ft,rotation:gt,scale:mt}),idle:Mt}),interaction:Object.freeze({focus:Object.freeze({scalePercent:.8,zIndex:1e3,animationDuration:void 0}),navigation:Object.freeze({keyboard:!0,swipe:!0,mouseWheel:void 0}),dragging:!0}),ui:Object.freeze({showLoadingSpinner:!1,showImageCounter:!1,showNavButtons:!1,showFocusOutline:!1}),styling:Tt});function tt(o,t){if(!o)return t||{};if(!t)return{...o};const i={...o};return t.border!==void 0&&(i.border={...o.border,...t.border}),t.borderTop!==void 0&&(i.borderTop={...o.borderTop,...t.borderTop}),t.borderRight!==void 0&&(i.borderRight={...o.borderRight,...t.borderRight}),t.borderBottom!==void 0&&(i.borderBottom={...o.borderBottom,...t.borderBottom}),t.borderLeft!==void 0&&(i.borderLeft={...o.borderLeft,...t.borderLeft}),t.filter!==void 0&&(i.filter={...o.filter,...t.filter}),t.outline!==void 0&&(i.outline={...o.outline,...t.outline}),t.shadow!==void 0&&(i.shadow=t.shadow),t.clipPath!==void 0&&(i.clipPath=t.clipPath),t.opacity!==void 0&&(i.opacity=t.opacity),t.cursor!==void 0&&(i.cursor=t.cursor),t.className!==void 0&&(i.className=t.className),t.objectFit!==void 0&&(i.objectFit=t.objectFit),t.aspectRatio!==void 0&&(i.aspectRatio=t.aspectRatio),t.borderRadiusTopLeft!==void 0&&(i.borderRadiusTopLeft=t.borderRadiusTopLeft),t.borderRadiusTopRight!==void 0&&(i.borderRadiusTopRight=t.borderRadiusTopRight),t.borderRadiusBottomRight!==void 0&&(i.borderRadiusBottomRight=t.borderRadiusBottomRight),t.borderRadiusBottomLeft!==void 0&&(i.borderRadiusBottomLeft=t.borderRadiusBottomLeft),i}function fe(o,t){if(!t)return{...o};const i=tt(o.default,t.default),e=tt(tt(i,o.hover),t.hover),n=tt(tt(i,o.focused),t.focused);return{default:i,hover:e,focused:n}}function ge(o,t){if(!t)return{...o};const i={...o};if(t.sizing!==void 0&&(i.sizing={...o.sizing,...t.sizing},t.sizing.variance)){const e=t.sizing.variance,n=e.min!==void 0&&e.min>=.25&&e.min<=1?e.min:o.sizing?.variance?.min??1,s=e.max!==void 0&&e.max>=1&&e.max<=1.75?e.max:o.sizing?.variance?.max??1;i.sizing.variance={min:n,max:s}}if(t.rotation!==void 0&&(i.rotation={...o.rotation,...t.rotation},t.rotation.range)){const e=t.rotation.range,n=e.min!==void 0&&e.min>=-180&&e.min<=0?e.min:o.rotation?.range?.min??-15,s=e.max!==void 0&&e.max>=0&&e.max<=180?e.max:o.rotation?.range?.max??15;i.rotation.range={min:n,max:s}}return i}function me(o){const t=o.layout?.rotation;if(t&&"enabled"in t)return{rotation:{mode:t.enabled?"random":"none",range:t.range}}}function pe(o){const t=o.layout?.sizing?.variance;if(t)return{sizing:{mode:"adaptive",variance:t}}}function be(o={}){const t=me(o),i=pe(o);let e=o.image;(t||i)&&(e={...i||{},...t||{},...e},e.rotation&&t?.rotation&&o.image?.rotation&&(e.rotation={...t.rotation,...o.image.rotation}));const n=[...o.loaders??[]];o.images&&o.images.length>0&&n.unshift({static:{sources:[{urls:o.images}]}});const r={loaders:{...pt,...o.config?.loaders??{}}},a={loaders:n,config:r,image:ge(Lt,e),layout:{...A.layout},animation:{...A.animation},interaction:{...A.interaction},ui:{...A.ui},styling:fe(Tt,o.styling)};o.layout&&(a.layout={...A.layout,...o.layout},o.layout.responsive&&(a.layout.responsive={...A.layout.responsive,mobile:o.layout.responsive.mobile?{...A.layout.responsive.mobile,...o.layout.responsive.mobile}:A.layout.responsive.mobile,tablet:o.layout.responsive.tablet?{...A.layout.responsive.tablet,...o.layout.responsive.tablet}:A.layout.responsive.tablet}),o.layout.spacing&&(a.layout.spacing={...A.layout.spacing,...o.layout.spacing})),o.animation&&(a.animation={...A.animation,...o.animation},o.animation.easing&&(a.animation.easing={...A.animation.easing,...o.animation.easing}),o.animation.queue&&(a.animation.queue={...A.animation.queue,...o.animation.queue}),o.animation.entry&&(a.animation.entry={...A.animation.entry,...o.animation.entry,start:o.animation.entry.start?{...A.animation.entry.start,...o.animation.entry.start,circular:o.animation.entry.start.circular?{...A.animation.entry.start.circular,...o.animation.entry.start.circular}:A.animation.entry.start.circular}:A.animation.entry.start,timing:o.animation.entry.timing?{...A.animation.entry.timing,...o.animation.entry.timing}:A.animation.entry.timing,path:o.animation.entry.path?{...ft,...o.animation.entry.path}:A.animation.entry.path,rotation:o.animation.entry.rotation?{...gt,...o.animation.entry.rotation}:A.animation.entry.rotation,scale:o.animation.entry.scale?{...mt,...o.animation.entry.scale}:A.animation.entry.scale}),o.animation.idle&&(a.animation.idle={...Mt,...o.animation.idle})),o.interaction&&(a.interaction={...A.interaction,...o.interaction},o.interaction.focus&&(a.interaction.focus={...A.interaction.focus,...o.interaction.focus}),o.interaction.navigation&&(a.interaction.navigation={...A.interaction.navigation,...o.interaction.navigation}));const c=o.rendering?.ui;if(c&&console.warn("[ImageCloud] rendering.ui is deprecated. Use top-level ui instead."),a.ui={...A.ui,...c,...o.ui},a.config.debug={...Ft,...o.config?.debug??{}},a.layout.algorithm==="honeycomb"&&a.styling){const l={shape:"hexagon",mode:"height-relative"};a.styling={...a.styling,default:{...a.styling.default,clipPath:l},hover:{...a.styling.hover,clipPath:l}}}return a}function ye(o,t){return{...o?ht[o]:ht.playful,...t}}function ve(o,t){return{...o?dt[o]:dt.gentle,...t}}function Ee(o,t){return{...o?ut[o]:ut.gentle,...t}}class Ot{constructor(t){this.activeAnimations=new Map,this.animationIdCounter=0,this.config=t}buildTransformString(t){const i=["translate(-50%, -50%)"];if(t.x!==void 0||t.y!==void 0){const e=t.x??0,n=t.y??0;i.push(`translate(${e}px, ${n}px)`)}return t.rotation!==void 0&&i.push(`rotate(${t.rotation}deg)`),t.scale!==void 0&&i.push(`scale(${t.scale})`),i.join(" ")}animateTransformCancellable(t,i,e,n=null,s=null){this.cancelAllAnimations(t);const r=n??this.config.duration,a=s??this.config.easing.default,c=this.buildTransformString(i),l=this.buildTransformString(e);t.style.transition="none";const u=t.animate([{transform:c},{transform:l}],{duration:r,easing:a,fill:"forwards"}),h={id:`anim-${++this.animationIdCounter}`,element:t,animation:u,fromState:i,toState:e,startTime:performance.now(),duration:r};return this.activeAnimations.set(t,h),u.finished.then(()=>{t.style.transform=l,this.activeAnimations.delete(t)}).catch(()=>{this.activeAnimations.delete(t)}),h}cancelAnimation(t,i=!0){const e=this.getCurrentTransform(t.element);if(t.animation.cancel(),i){const n=this.buildTransformString({x:e.x,y:e.y,rotation:e.rotation,scale:e.scale});t.element.style.transform=n}return this.activeAnimations.delete(t.element),e}cancelAllAnimations(t){const i=this.activeAnimations.get(t);i&&this.cancelAnimation(i,!1);const e=t.getAnimations();for(const n of e)n.cancel()}getCurrentTransform(t){const e=getComputedStyle(t).transform;if(e==="none"||!e)return{x:0,y:0,rotation:0,scale:1};const n=new DOMMatrix(e),s=Math.sqrt(n.a*n.a+n.b*n.b),r=Math.atan2(n.b,n.a)*(180/Math.PI),a=n.e,c=n.f;return{x:a,y:c,rotation:r,scale:s}}hasActiveAnimation(t){return this.activeAnimations.has(t)}getAnimationHandle(t){return this.activeAnimations.get(t)}animateTransform(t,i,e=null,n=null){return new Promise(s=>{const r=e??this.config.duration,a=n??this.config.easing.default;t.style.transition=`transform ${r}ms ${a}, box-shadow ${r}ms ${a}`,t.style.transform=this.buildTransformString(i),setTimeout(()=>{s()},r)})}resetTransform(t,i){return this.animateTransform(t,i)}clearTransition(t){t.style.transition=""}wait(t){return new Promise(i=>setTimeout(i,t))}}function K(o,t,i){return o+(t-o)*i}function we(o,t,i,e){const{overshoot:n,bounces:s,decayRatio:r}=e,a=i.x-t.x,c=i.y-t.y,l=xe(s,r);let u=0,h=0,d=1,g=n,b=!1;for(let f=0;f<l.length;f++)if(o<=l[f].time){h=f===0?0:l[f-1].time,d=l[f].time,g=l[f].overshoot,b=l[f].isOvershoot;break}const p=(o-h)/(d-h);if(b)u=1+g*st(p);else if(h===0)u=st(p);else{const m=1+(l.find((y,E)=>y.time>h&&E>0&&l[E-1].isOvershoot)?.overshoot||g);u=K(m,1,st(p))}return{x:t.x+a*u,y:t.y+c*u}}function xe(o,t){const i=[];let e=.6;i.push({time:e,overshoot:0,isOvershoot:!1});let n=.15;const r=.4/(o*2);for(let a=0;a<o;a++)e+=r,i.push({time:e,overshoot:n,isOvershoot:!0}),e+=r,i.push({time:e,overshoot:n*t,isOvershoot:!1}),n*=t;return i.push({time:1,overshoot:0,isOvershoot:!1}),i}function Se(o,t,i,e){const{stiffness:n,damping:s,mass:r,oscillations:a}=e,c=i.x-t.x,l=i.y-t.y,u=Math.sqrt(n/r),h=s/(2*Math.sqrt(n*r));let d;if(h<1){const g=u*Math.sqrt(1-h*h),b=Math.exp(-h*u*o*3),p=Math.cos(g*o*a*Math.PI);d=1-b*p}else d=1-Math.exp(-u*o*3);return d=Math.max(0,Math.min(d,1.3)),{x:t.x+c*d,y:t.y+l*d}}function Ie(o,t,i,e){const{amplitude:n,frequency:s,decay:r,decayRate:a,phase:c}=e,l=i.x-t.x,u=i.y-t.y,h=Math.sqrt(l*l+u*u),d=h>0?-u/h:0,g=h>0?l/h:1,b=s*Math.PI*2*o+c,p=r?Math.pow(1-o,a):1,f=n*Math.sin(b)*p,m=Ae(o);return{x:K(t.x,i.x,m)+f*d,y:K(t.y,i.y,m)+f*g}}function st(o){return 1-(1-o)*(1-o)}function Ae(o){return 1-Math.pow(1-o,3)}function Ce(o,t,i){const{amplitude:e,frequency:n,decay:s}=i,r=Math.sin(o*n*Math.PI*2),a=s?Math.pow(1-o,2):1,c=e*r*a;return t+c}function Re(o,t,i){const{overshoot:e,bounces:n}=i,s=[];s.push({time:.5,scale:e});let r=e;const a=.5,l=.5/(n*2);let u=.5;for(let d=0;d<n;d++){const g=1-(r-1)*a;u+=l,s.push({time:u,scale:g}),r=1+(r-1)*a*a,u+=l,d<n-1&&s.push({time:u,scale:r})}s.push({time:1,scale:1});let h=1;for(let d=0;d<s.length;d++)if(o<=s[d].time){const g=d===0?0:s[d-1].time,b=d===0?1:s[d-1].scale,p=(o-g)/(s[d].time-g),f=st(p);h=b+(s[d].scale-b)*f;break}return h*t}function zt(o){const{element:t,startPosition:i,endPosition:e,pathConfig:n,duration:s,imageWidth:r,imageHeight:a,rotation:c,scale:l,onComplete:u,rotationConfig:h,startRotation:d,scaleConfig:g,startScale:b}=o,p=n.type,f=d!==void 0&&d!==c,m=h?.mode==="wobble",y=h?.wobble||{amplitude:15,frequency:3,decay:!0},E=f||m,v=b!==void 0&&b!==l,I=g?.mode==="pop",w=g?.pop||{overshoot:1.2,bounces:1};if((p==="linear"||p==="arc")&&!E&&!(v||I)){u&&u();return}const z=performance.now(),F=-r/2,U=-a/2;function D(N){const k=N-z,R=Math.min(k/s,1);let P;switch(p){case"bounce":{const B=ye(n.bouncePreset,n.bounce);P=we(R,i,e,B);break}case"elastic":{const B=ve(n.elasticPreset,n.elastic);P=Se(R,i,e,B);break}case"wave":{const B=Ee(n.wavePreset,n.wave);P=Ie(R,i,e,B);break}default:P={x:K(i.x,e.x,R),y:K(i.y,e.y,R)}}const G=P.x-e.x,H=P.y-e.y;let M;m?M=Ce(R,c,y):f?M=K(d,c,R):M=c;let T;I?T=Re(R,l,w):v?T=K(b,l,R):T=l,t.style.transform=`translate(${F}px, ${U}px) translate(${G}px, ${H}px) rotate(${M}deg) scale(${T})`,R<1?requestAnimationFrame(D):(t.style.transform=`translate(${F}px, ${U}px) rotate(${c}deg) scale(${l})`,u&&u())}requestAnimationFrame(D)}function Dt(o){return o==="bounce"||o==="elastic"||o==="wave"}const Te={radial:"center",spiral:"center",grid:"top",cluster:"nearest-edge",random:"nearest-edge",wave:"left",honeycomb:"center"};class Pt{constructor(t,i){this.config=t,this.layoutAlgorithm=i,this.resolvedStartPosition=this.resolveStartPosition(),this.pathConfig=t.path||ft,this.rotationConfig=t.rotation||gt,this.scaleConfig=t.scale||mt}resolveStartPosition(){return this.config.start.position?this.config.start.position:Te[this.layoutAlgorithm]||"nearest-edge"}calculateStartPosition(t,i,e,n,s){const r=this.resolvedStartPosition,a=this.config.start.offset??100;switch(r){case"nearest-edge":return this.calculateNearestEdge(t,i,e,a);case"top":return this.calculateEdgePosition("top",t,i,e,a);case"bottom":return this.calculateEdgePosition("bottom",t,i,e,a);case"left":return this.calculateEdgePosition("left",t,i,e,a);case"right":return this.calculateEdgePosition("right",t,i,e,a);case"center":return this.calculateCenterPosition(e,t,i);case"random-edge":return this.calculateRandomEdge(t,i,e,a);case"circular":return this.calculateCircularPosition(t,i,e,n,s);default:return this.calculateNearestEdge(t,i,e,a)}}calculateNearestEdge(t,i,e,n){const s=t.x,r=t.y,a=s,c=e.width-s,l=r,u=e.height-r,h=Math.min(a,c,l,u);let d=t.x,g=t.y;return h===a?d=-(i.width+n):h===c?d=e.width+n:h===l?g=-(i.height+n):g=e.height+n,{x:d,y:g}}calculateEdgePosition(t,i,e,n,s){let r=i.x,a=i.y;switch(t){case"top":a=-(e.height+s);break;case"bottom":a=n.height+s;break;case"left":r=-(e.width+s);break;case"right":r=n.width+s;break}return{x:r,y:a}}calculateCenterPosition(t,i,e){const n=t.width/2,s=t.height/2;return{x:n,y:s,useScale:!0}}calculateRandomEdge(t,i,e,n){const s=["top","bottom","left","right"],r=s[Math.floor(Math.random()*s.length)];return this.calculateEdgePosition(r,t,i,e,n)}calculateCircularPosition(t,i,e,n,s){const r=this.config.start.circular||{},a=r.distribution||"even";let c;const l=r.radius||"120%";if(typeof l=="string"&&l.endsWith("%")){const p=parseFloat(l)/100;c=Math.sqrt(e.width**2+e.height**2)*p/2}else c=typeof l=="number"?l:500;let u;a==="even"?u=n/s*2*Math.PI:u=Math.random()*2*Math.PI;const h=e.width/2,d=e.height/2,g=h+Math.cos(u)*c,b=d+Math.sin(u)*c;return{x:g,y:b}}getAnimationParams(t){const i=this.config.timing.duration,e=this.config.easing;return{startTransform:"",duration:i,delay:0,easing:e}}buildStartTransform(t,i,e,n,s,r,a,c){const l=t.x-i.x,u=t.y-i.y,h=a!==void 0?a:e,d=c!==void 0?c:n,g=s!==void 0?-s/2:0,b=r!==void 0?-r/2:0,p=s!==void 0?`translate(${g}px, ${b}px)`:"translate(-50%, -50%)";return t.useScale?`${p} translate(${l}px, ${u}px) rotate(${h}deg) scale(0)`:`${p} translate(${l}px, ${u}px) rotate(${h}deg) scale(${d})`}buildFinalTransform(t,i,e,n){if(e!==void 0&&n!==void 0){const s=-e/2,r=-n/2;return`translate(${s}px, ${r}px) rotate(${t}deg) scale(${i})`}return`translate(-50%, -50%) rotate(${t}deg) scale(${i})`}getTransitionCSS(){const t=this.config.timing.duration,i=this.config.easing;return this.requiresJSAnimation()?`opacity ${t}ms ease-out`:`opacity ${t}ms ease-out, transform ${t}ms ${i}`}requiresJSAnimation(){return Dt(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 e=this.rotationConfig.startRotation;if(e===void 0)return t+(Math.random()-.5)*60;if(typeof e=="number")return e;const n=e.max-e.min;return e.min+Math.random()*n}case"spin":{const e=this.rotationConfig.spinCount??1,n=this.resolveSpinDirection(t);return t+e*360*n}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,i){if(this.rotationConfig.mode!=="wobble")return i;const e=this.rotationConfig.wobble||{amplitude:15,frequency:3,decay:!0},{amplitude:n,frequency:s,decay:r}=e,a=Math.sin(t*s*Math.PI*2),c=r?Math.pow(1-t,2):1,l=n*a*c;return i+l}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 e=this.scaleConfig.range??{min:.5,max:1};return(e.min+Math.random()*(e.max-e.min))*t}default:return t}}requiresJSScale(){return this.scaleConfig.mode==="pop"}calculatePopScale(t,i){if(this.scaleConfig.mode!=="pop")return i;const e=this.scaleConfig.pop||{overshoot:1.2,bounces:1},{overshoot:n,bounces:s}=e,r=this.generateScaleBounceKeyframes(s,n);let a=i;for(let c=0;c<r.length;c++)if(t<=r[c].time){const l=c===0?0:r[c-1].time,u=c===0?i:r[c-1].scale,h=(t-l)/(r[c].time-l),d=this.easeOutQuad(h);a=u+(r[c].scale-u)*d;break}return a*i}generateScaleBounceKeyframes(t,i){const e=[];e.push({time:.5,scale:i});let n=i;const s=.5,a=.5/(t*2);let c=.5;for(let l=0;l<t;l++){const u=1-(n-1)*s;c+=a,e.push({time:c,scale:u}),n=1+(n-1)*s*s,c+=a,l<t-1&&e.push({time:c,scale:n})}return e.push({time:1,scale:1}),e}easeOutQuad(t){return 1-(1-t)*(1-t)}}class Le{constructor(t,i=600){this.entries=new Map,this.togetherRafId=null,this.togetherSpeed=0,this.config=t,this.entryDurationMs=i}register(t,i,e,n){if(this.entries.has(t))return;const s=n??this.entryDurationMs,r=this.config.startDelay??s,a={element:t,index:i,totalImages:e,animation:null,blinkAnimation:null,customTeardown:null,paused:!1,stopped:!1,startTimer:null};this.entries.set(t,a),a.startTimer=setTimeout(()=>{a.startTimer=null,!a.stopped&&!a.paused&&this._startAnimation(a)},r)}pauseForImage(t){const i=this.entries.get(t);i&&(i.paused=!0,i.startTimer!==null&&(clearTimeout(i.startTimer),i.startTimer=null),this._pauseEntry(i))}resumeForImage(t){const i=this.entries.get(t);!i||i.stopped||(i.paused=!1,this._startAnimation(i))}stopForImage(t){const i=this.entries.get(t);i&&(i.stopped=!0,i.startTimer!==null&&(clearTimeout(i.startTimer),i.startTimer=null),this._cancelEntry(i),this.entries.delete(t))}pauseAll(){for(const t of this.entries.values())t.paused=!0,t.startTimer!==null&&(clearTimeout(t.startTimer),t.startTimer=null),this._pauseEntry(t)}resumeAll(){for(const t of this.entries.values())t.stopped||(t.paused=!1,this._startAnimation(t))}stopAll(){for(const t of this.entries.values())t.stopped=!0,t.startTimer!==null&&(clearTimeout(t.startTimer),t.startTimer=null),this._cancelEntry(t);this.entries.clear(),this._stopTogetherLoop()}_startAnimation(t){const{type:i}=this.config;switch(i){case"wiggle":this._startWiggle(t);break;case"pulse":this._startPulse(t);break;case"blink":this._startBlink(t);break;case"spin":this._startSpin(t);break;case"custom":this._startCustom(t);break}}_startWiggle(t){const i={...le,...this.config.wiggle},e=[{transform:"rotate(0deg)",offset:0},{transform:`rotate(${i.maxAngle}deg)`,offset:.25},{transform:"rotate(0deg)",offset:.5},{transform:`rotate(${-i.maxAngle}deg)`,offset:.75},{transform:"rotate(0deg)",offset:1}];i.sync==="together"?(t.animation=t.element.animate(e,{duration:i.speed,iterations:1/0,composite:"add",fill:"both"}),t.animation.pause(),this._startTogetherLoop(i.speed)):t.animation=t.element.animate(e,{duration:i.speed,delay:-(Math.random()*i.speed),iterations:1/0,composite:"add"})}_startPulse(t){const i={...he,...this.config.pulse},e=[{transform:"scale(1)",offset:0},{transform:`scale(${i.maxScale})`,offset:.25},{transform:"scale(1)",offset:.5},{transform:`scale(${i.minScale})`,offset:.75},{transform:"scale(1)",offset:1}];i.sync==="together"?(t.animation=t.element.animate(e,{duration:i.speed,iterations:1/0,composite:"add",fill:"both"}),t.animation.pause(),this._startTogetherLoop(i.speed)):t.animation=t.element.animate(e,{duration:i.speed,delay:-(Math.random()*i.speed),iterations:1/0,composite:"add"})}_startBlink(t){const i={...de,...this.config.blink},e=-(Math.random()*i.speed),n=parseFloat(getComputedStyle(t.element).opacity)||1;let s,r;i.style==="fade"?(s=[{opacity:n,offset:0},{opacity:0,offset:.5},{opacity:n,offset:1}],r={duration:i.speed,delay:e,iterations:1/0,easing:"ease-in-out"}):(s=[{opacity:n,offset:0},{opacity:n,offset:i.onRatio},{opacity:0,offset:Math.min(i.onRatio+.01,.99)},{opacity:0,offset:.99},{opacity:n,offset:1}],r={duration:i.speed,delay:e,iterations:1/0}),t.blinkAnimation=t.element.animate(s,r)}_startSpin(t){const i={...ue,...this.config.spin},e=i.direction==="clockwise"?360:-360;t.animation=t.element.animate([{transform:"rotate(0deg)"},{transform:`rotate(${e}deg)`}],{duration:i.speed,iterations:1/0,easing:"linear",composite:"add"})}_startCustom(t){const i=this.config.custom;if(!i)return;const e=i({element:t.element,index:t.index,totalImages:t.totalImages});typeof e=="function"?t.customTeardown=e:e&&typeof e.play=="function"&&(t.animation=e)}_startTogetherLoop(t){if(this.togetherSpeed=t,this.togetherRafId!==null)return;const i=()=>{const e=performance.now()%this.togetherSpeed;for(const n of this.entries.values())!n.stopped&&!n.paused&&n.animation&&(n.animation.currentTime=e);this.togetherRafId=requestAnimationFrame(i)};this.togetherRafId=requestAnimationFrame(i)}_stopTogetherLoop(){this.togetherRafId!==null&&(cancelAnimationFrame(this.togetherRafId),this.togetherRafId=null)}_pauseEntry(t){t.animation&&(t.animation.cancel(),t.animation=null),t.blinkAnimation&&(t.blinkAnimation.cancel(),t.blinkAnimation=null)}_cancelEntry(t){t.animation&&(t.animation.cancel(),t.animation=null),t.blinkAnimation&&(t.blinkAnimation.cancel(),t.blinkAnimation=null),t.customTeardown&&(t.customTeardown(),t.customTeardown=null)}}class $t{constructor(t,i={}){this.config=t,this.imageConfig=i}generate(t,i,e={}){const n=[],{width:s,height:r}=i,a=this.config.spacing.padding,c=e.fixedHeight??200,l=this.imageConfig.rotation?.mode??"none",u=this.imageConfig.rotation?.range?.min??-15,h=this.imageConfig.rotation?.range?.max??15,d=this.imageConfig.sizing?.variance?.min??1,g=this.imageConfig.sizing?.variance?.max??1,b=d!==1||g!==1,f=c*1.5/2,m=c/2,y=s-a-f,E=r-a-m,v=a+f,I=a+m;for(let w=0;w<t;w++){const C=this.random(v,y),z=this.random(I,E),F=l==="random"?this.random(u,h):0,U=b?this.random(d,g):1,D=c*U,N={id:w,x:C,y:z,rotation:F,scale:U,baseSize:D};n.push(N)}return n}random(t,i){return Math.random()*(i-t)+t}}class _t{constructor(t,i={}){this.config=t,this.imageConfig=i}generate(t,i,e={}){const n=[],{width:s,height:r}=i,a=e.fixedHeight??200,c=this.imageConfig.rotation?.mode??"none",l=this.imageConfig.rotation?.range?.min??-15,u=this.imageConfig.rotation?.range?.max??15,h=this.imageConfig.sizing?.variance?.min??1,d=this.imageConfig.sizing?.variance?.max??1,g=h!==1||d!==1,b=this.config.scaleDecay??0,p={...ne,...this.config.radial},f=e.fixedHeight??a,m=s/2,y=r/2,E=Math.ceil(Math.sqrt(t)),v=this.config.spacing.padding??50,I=Math.max(f*.8,Math.min(m-v-f/2,y-v-f/2));if(t>0){const z=g?this.random(h,d):1,F=f*z;n.push({id:0,x:m,y,rotation:c==="random"?this.random(l*.33,u*.33):0,scale:z,baseSize:F,zIndex:100})}let w=1,C=1;for(;w<t;){const z=C/E,F=b>0?1-z*b*.5:1,U=Math.max(f*.8,I/E*1.5/p.tightness),D=C*U,N=D*1.5,k=Math.PI*(3*(N+D)-Math.sqrt((3*N+D)*(N+3*D))),R=this.estimateWidth(f),P=Math.floor(k/(R*.7));if(P===0){C++;continue}const G=2*Math.PI/P,H=C*(20*Math.PI/180);for(let M=0;M<P&&w<t;M++){const T=M*G+H,B=g?this.random(h,d):1,X=F*B,L=f*X;let $=m+Math.cos(T)*N,O=y+Math.sin(T)*D;const _=L*1.5/2,j=L/2;$-_<v?$=v+_:$+_>s-v&&($=s-v-_),O-j<v?O=v+j:O+j>r-v&&(O=r-v-j);const V=c==="random"?this.random(l,u):0;n.push({id:w,x:$,y:O,rotation:V,scale:X,baseSize:L,zIndex:Math.max(1,100-C)}),w++}C++}return n}estimateWidth(t){return t*1.4}random(t,i){return Math.random()*(i-t)+t}}const Fe={columns:"auto",rows:"auto",stagger:"none",jitter:0,overlap:0,fillDirection:"row",alignment:"center",gap:10,overflowOffset:.25},Ut=[{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 Ht{constructor(t,i={}){this.config=t,this.imageConfig=i}generate(t,i,e={}){const n=[],{width:s,height:r}=i,a={...Fe,...this.config.grid},c=this.config.spacing.padding,l=e.fixedHeight??200,u=this.imageConfig.rotation?.mode??"none",h=this.imageConfig.sizing?.variance?.min??1,d=this.imageConfig.sizing?.variance?.max??1,g=h!==1||d!==1,b=s-2*c,p=r-2*c,{columns:f,rows:m}=this.calculateGridDimensions(t,b,p,l,a),y=a.stagger==="row",E=a.stagger==="column",v=y?f+.5:f,I=E?m+.5:m,w=(b-a.gap*(f-1))/v,C=(p-a.gap*(m-1))/I,z=y?w/2:0,F=E?C/2:0,U=1+a.overlap,D=Math.min(w,C)*U,N=e.fixedHeight?Math.min(e.fixedHeight,D):D,k=f*w+(f-1)*a.gap+z,R=m*C+(m-1)*a.gap+F,P=c+(b-k)/2,G=c+(p-R)/2,H=f*m,M=a.columns!=="auto"&&a.rows!=="auto",T=M&&t>H;typeof window<"u"&&(window.__gridOverflowDebug={gridConfigColumns:a.columns,gridConfigRows:a.rows,columns:f,rows:m,cellCount:H,hasFixedGrid:M,imageCount:t,isOverflowMode:T});const B=T?new Array(H).fill(0):[],X=Math.min(w,C)*a.overflowOffset;for(let L=0;L<t;L++){let $,O,Y=0;if(T&&L>=H){const q=L-H,W=q%H;Y=Math.floor(q/H)+1,B[W]++,a.fillDirection==="row"?($=W%f,O=Math.floor(W/f)):(O=W%m,$=Math.floor(W/m))}else a.fillDirection==="row"?($=L%f,O=Math.floor(L/f)):(O=L%m,$=Math.floor(L/m));let _=P+$*(w+a.gap)+w/2,j=G+O*(C+a.gap)+C/2;if(a.stagger==="row"&&O%2===1?_+=w/2:a.stagger==="column"&&$%2===1&&(j+=C/2),Y>0){const q=(Y-1)%Ut.length,W=Ut[q];_+=W.x*X,j+=W.y*X}if(a.jitter>0){const q=w/2*a.jitter,W=C/2*a.jitter;_+=this.random(-q,q),j+=this.random(-W,W)}let V=_,Z=j;if(!T&&a.fillDirection==="row"){const q=t%f||f;if(O===Math.floor((t-1)/f)&&q<f){const ie=q*w+(q-1)*a.gap;let Rt=0;a.alignment==="center"?Rt=(k-ie)/2:a.alignment==="end"&&(Rt=k-ie),V+=Rt}}const wt=g?this.random(h,d):1,Q=N*wt,ct=Q*1.5/2,lt=Q/2,St=c+ct,It=s-c-ct,Qe=c+lt,ti=r-c-lt;V=Math.max(St,Math.min(V,It)),Z=Math.max(Qe,Math.min(Z,ti));let At=0;if(u==="random"){const q=this.imageConfig.rotation?.range?.min??-15,W=this.imageConfig.rotation?.range?.max??15;a.jitter>0?At=this.random(q*a.jitter,W*a.jitter):At=this.random(q,W)}let Ct;T&&Y>0?Ct=50-Y:Ct=T?100+L:L+1,n.push({id:L,x:V,y:Z,rotation:At,scale:wt,baseSize:Q,zIndex:Ct})}return n}calculateGridDimensions(t,i,e,n,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 c=i/e;for(r=Math.max(1,Math.round(Math.sqrt(t*c/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,i){return Math.random()*(i-t)+t}}const Me=Math.PI*(3-Math.sqrt(5)),Oe={spiralType:"golden",direction:"counterclockwise",tightness:1,scaleDecay:0,startAngle:0};class Nt{constructor(t,i={}){this.config=t,this.imageConfig=i}generate(t,i,e={}){const n=[],{width:s,height:r}=i,a={...Oe,...this.config.spiral},c=this.config.spacing.padding,l=e.fixedHeight??200,u=this.imageConfig.rotation?.mode??"none",h=this.imageConfig.rotation?.range?.min??-15,d=this.imageConfig.rotation?.range?.max??15,g=this.imageConfig.sizing?.variance?.min??1,b=this.imageConfig.sizing?.variance?.max??1,p=g!==1||b!==1,f=this.config.scaleDecay??a.scaleDecay,m=s/2,y=r/2,E=Math.min(m-c-l/2,y-c-l/2),v=a.direction==="clockwise"?-1:1;for(let I=0;I<t;I++){let w,C;if(a.spiralType==="golden")w=I*Me*v+a.startAngle,C=this.calculateGoldenRadius(I,t,E,a.tightness);else if(a.spiralType==="archimedean"){const _=I*.5*a.tightness;w=_*v+a.startAngle,C=this.calculateArchimedeanRadius(_,t,E,a.tightness)}else{const _=I*.3*a.tightness;w=_*v+a.startAngle,C=this.calculateLogarithmicRadius(_,t,E,a.tightness)}const z=m+Math.cos(w)*C,F=y+Math.sin(w)*C,U=C/E,D=f>0?1-U*f*.5:1,N=p?this.random(g,b):1,k=D*N,R=l*k,G=R*1.5/2,H=R/2,M=c+G,T=s-c-G,B=c+H,X=r-c-H,L=Math.max(M,Math.min(z,T)),$=Math.max(B,Math.min(F,X));let O=0;if(u==="random"){const _=w*180/Math.PI%360,j=this.random(h,d);O=a.spiralType==="golden"?j:_*.1+j*.9}else u==="tangent"&&(O=this.calculateSpiralTangent(w,C,a));const Y=t-I;n.push({id:I,x:L,y:$,rotation:O,scale:k,baseSize:R,zIndex:Y})}return n}calculateSpiralTangent(t,i,e){let n;if(e.spiralType==="golden")n=t+Math.PI/2;else if(e.spiralType==="archimedean"){const r=1/e.tightness,a=Math.atan(i/r);n=t+a}else{const r=.15/e.tightness,a=Math.atan(1/r);n=t+a}return n*180/Math.PI%360-90}calculateGoldenRadius(t,i,e,n){const r=e/Math.sqrt(i)*Math.sqrt(t)/n;return Math.min(r,e)}calculateArchimedeanRadius(t,i,e,n){const s=i*.5*n;return t/s*e}calculateLogarithmicRadius(t,i,e,n){const s=e*.05,r=.15/n,a=s*Math.exp(r*t),c=i*.3*n,l=s*Math.exp(r*c);return a/l*e}random(t,i){return Math.random()*(i-t)+t}}const ze={clusterCount:"auto",clusterSpread:150,clusterSpacing:200,density:"uniform",overlap:.3,distribution:"gaussian"};class kt{constructor(t,i={}){this.config=t,this.imageConfig=i}generate(t,i,e={}){const n=[],{width:s,height:r}=i,a={...ze,...this.config.cluster},c=this.config.spacing.padding,l=e.fixedHeight??200,u=this.imageConfig.rotation?.mode??"none",h=this.imageConfig.rotation?.range?.min??-15,d=this.imageConfig.rotation?.range?.max??15,g=this.imageConfig.sizing?.variance?.min??1,b=this.imageConfig.sizing?.variance?.max??1,p=g!==1||b!==1,f=this.calculateClusterCount(t,a.clusterCount,s,r,a.clusterSpacing),m=this.generateClusterCenters(f,s,r,c,a),y=new Array(f).fill(0);for(let v=0;v<t;v++)y[v%f]++;let E=0;for(let v=0;v<f;v++){const I=m[v],w=y[v];for(let C=0;C<w;C++){let z,F;if(a.distribution==="gaussian")z=this.gaussianRandom()*I.spread,F=this.gaussianRandom()*I.spread;else{const O=this.random(0,Math.PI*2),Y=this.random(0,I.spread);z=Math.cos(O)*Y,F=Math.sin(O)*Y}const U=1+a.overlap*.5,D=1+a.overlap*.3;z/=U,F/=U;const N=p?this.random(g,b):1,k=D*N,R=l*k;let P=I.x+z,G=I.y+F;const M=R*1.5/2,T=R/2;P=Math.max(c+M,Math.min(P,s-c-M)),G=Math.max(c+T,Math.min(G,r-c-T));const B=u==="random"?this.random(h,d):0,L=Math.sqrt(z*z+F*F)/I.spread,$=Math.round((1-L)*50)+1;n.push({id:E,x:P,y:G,rotation:B,scale:k,baseSize:R,zIndex:$}),E++}}return n}calculateClusterCount(t,i,e,n,s){if(i!=="auto")return Math.max(1,Math.min(i,t));const a=Math.max(1,Math.ceil(t/8)),c=Math.floor(e/s*(n/s)*.6);return Math.max(1,Math.min(a,c,10))}generateClusterCenters(t,i,e,n,s){const r=[],c=n+s.clusterSpread,l=i-n-s.clusterSpread,u=n+s.clusterSpread,h=e-n-s.clusterSpread;for(let d=0;d<t;d++){let g=null,b=-1;for(let p=0;p<100;p++){const f={x:this.random(c,l),y:this.random(u,h),spread:this.calculateClusterSpread(s)};let m=1/0;for(const y of r){const E=f.x-y.x,v=f.y-y.y,I=Math.sqrt(E*E+v*v);m=Math.min(m,I)}if((r.length===0||m>b)&&(g=f,b=m),m>=s.clusterSpacing)break}g&&r.push(g)}return r}calculateClusterSpread(t){return t.density==="uniform"?t.clusterSpread:t.clusterSpread*this.random(.5,1.5)}gaussianRandom(){let t=0,i=0;for(;t===0;)t=Math.random();for(;i===0;)i=Math.random();const e=Math.sqrt(-2*Math.log(t))*Math.cos(2*Math.PI*i);return Math.max(-3,Math.min(3,e))/3}random(t,i){return Math.random()*(i-t)+t}}class Bt{constructor(t,i={}){this.config=t,this.imageConfig=i}generate(t,i,e={}){const n=[],{width:s,height:r}=i,a=e.fixedHeight??200,c=this.config.spacing.padding??50,l=this.imageConfig.rotation?.mode??"none",u=this.imageConfig.rotation?.range?.min??-15,h=this.imageConfig.rotation?.range?.max??15,d=this.imageConfig.sizing?.variance?.min??1,g=this.imageConfig.sizing?.variance?.max??1,b=d!==1||g!==1,p=e.fixedHeight??a,f={...oe,...this.config.wave},{rows:m,amplitude:y,frequency:E,phaseShift:v,synchronization:I}=f,w=Math.ceil(t/m),F=p*1.5/2,U=c+F,D=s-c-F,N=D-U,k=w>1?N/(w-1):0,R=c+y+p/2,P=r-c-y-p/2,G=P-R,H=m>1?G/(m-1):0;let M=0;for(let T=0;T<m&&M<t;T++){const B=m===1?(R+P)/2:R+T*H;let X=0;I==="offset"?X=T*v:I==="alternating"&&(X=T*Math.PI);for(let L=0;L<w&&M<t;L++){const $=w===1?(U+D)/2:U+L*k,O=this.calculateWaveY($,s,y,E,X),Y=$,_=B+O,j=b?this.random(d,g):1,V=p*j;let Z=0;l==="tangent"?Z=this.calculateRotation($,s,y,E,X):l==="random"&&(Z=this.random(u,h));const Q=V*1.5/2,xt=V/2,ct=c+Q,lt=s-c-Q,St=c+xt,It=r-c-xt;n.push({id:M,x:Math.max(ct,Math.min(Y,lt)),y:Math.max(St,Math.min(_,It)),rotation:Z,scale:j,baseSize:V,zIndex:M+1}),M++}}return n}calculateWaveY(t,i,e,n,s){const r=t/i;return e*Math.sin(n*r*2*Math.PI+s)}calculateRotation(t,i,e,n,s){const r=t/i,a=e*n*2*Math.PI*Math.cos(n*r*2*Math.PI+s)/i;return Math.atan(a)*(180/Math.PI)}random(t,i){return Math.random()*(i-t)+t}}const bt=100,et=100/Math.sqrt(3),yt=[[et/2,0],[3*et/2,0],[2*et,50],[3*et/2,100],[et/2,100],[0,50]],De=yt[1][0]/bt,Pe=yt[2][1]/bt;function $e(o){return{colStep:De*o,rowOffset:Pe*o}}function _e(o,t,i,e,n,s){const{colStep:r}=$e(s);return{px:e+r*o,py:n+s*(t+o/2)}}const Ue=[[1,0,-1],[0,1,-1],[-1,1,0],[-1,0,1],[0,-1,1],[1,-1,0]];function He(o){if(o===0)return[[0,0,0]];const t=[];let[i,e,n]=[0,-o,o];for(const[s,r,a]of Ue)for(let c=0;c<o;c++)t.push([i,e,n]),i+=s,e+=r,n+=a;return t}class jt{constructor(t,i={}){this.config=t}generate(t,i,e={}){const n=[],{width:s,height:r}=i,a=s/2,c=r/2,l=e.fixedHeight??200,h={...se,...this.config.honeycomb}.spacing??0,d=l+h;let g=0,b=0;for(;g<t;){const p=He(b);for(const[f,m,y]of p){if(g>=t)break;const{px:E,py:v}=_e(f,m,y,a,c,d);n.push({id:g,x:E,y:v,rotation:0,scale:1,baseSize:l,zIndex:Math.max(1,100-b)}),g++}b++}return n}}class Wt{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 _t(this.config,this.imageConfig);case"grid":return new Ht(this.config,this.imageConfig);case"spiral":return new Nt(this.config,this.imageConfig);case"cluster":return new kt(this.config,this.imageConfig);case"wave":return new Bt(this.config,this.imageConfig);case"honeycomb":return new jt(this.config,this.imageConfig);default:return new $t(this.config,this.imageConfig)}}generateLayout(t,i,e={}){const n=this.placementLayout.generate(t,i,e);return n.forEach(s=>{this.layouts.set(s.id,s)}),n}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 i=this.getBreakpoints();return t<=i.mobile.maxWidth?"mobile":t<=i.tablet.maxWidth?"tablet":"screen"}resolveBaseHeight(t){const i=this.imageConfig.sizing;if(!i||i.mode==="adaptive")return;const e=i.height;if(e===void 0)return;if(typeof e=="number")return e;const n=e,s=this.resolveBreakpoint(t);return s==="mobile"?n.mobile??n.tablet??n.screen:s==="tablet"?n.tablet??n.screen??n.mobile:n.screen??n.tablet??n.mobile}calculateAdaptiveSize(t,i,e,n){const s=this.imageConfig.sizing,r=this.resolveBaseHeight(n);if(r!==void 0)return{height:r};const a=s?.minSize??50,c=s?.maxSize??400,l=this.config.targetCoverage??.6,u=this.config.densityFactor??1,{width:h,height:d}=t,p=h*d*l/i;let m=Math.sqrt(p/1.4);m*=u,m=Math.min(m,e);let y=this.clamp(m,a,c);if(y===a&&m<a){const E=Math.max(a*.05,20);y=Math.max(E,m)}return this.config.algorithm==="honeycomb"&&(y=Math.min(y,this.honeycombMaxImageHeight(i,t))),{height:y}}honeycombMaxImageHeight(t,i){if(t<=1)return 1/0;let e=0,n=1;for(;n<t;)e++,n+=6*e;const s=this.config.spacing?.padding??50,r=this.config.honeycomb?.spacing??0,a=i.width/2,c=i.height/2,l=Math.sqrt(3)/2,u=1/Math.sqrt(3),h=(c-s-r*e)/(e+.5),d=(a-s-l*r*e)/(l*e+u);return Math.max(10,Math.min(h,d))}clamp(t,i,e){return Math.max(i,Math.min(e,t))}}var x=(o=>(o.IDLE="idle",o.FOCUSING="focusing",o.FOCUSED="focused",o.UNFOCUSING="unfocusing",o.CROSS_ANIMATING="cross_animating",o))(x||{});const Gt={circle:"circle(50%)",square:"polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)",triangle:"polygon(50% 0%, 100% 100%, 0% 100%)",pentagon:"polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%)",hexagon:"polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%)",octagon:"polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%)",diamond:"polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%)"},Ne={circle:{refHeight:100,points:[]},square:{refHeight:100,points:[[0,0],[100,0],[100,100],[0,100]]},triangle:{refHeight:100,points:[[50,0],[100,100],[0,100]]},pentagon:{refHeight:100,points:[[50,0],[100,38],[82,100],[18,100],[0,38]]},hexagon:{refHeight:bt,points:yt},octagon:{refHeight:100,points:[[30,0],[70,0],[100,30],[100,70],[70,100],[30,100],[0,70],[0,30]]},diamond:{refHeight:100,points:[[50,0],[100,50],[50,100],[0,50]]}};function ke(o){if(o)return o in Gt?Gt[o]:o}function Be(o,t,i){const e=Ne[o];if(!e)return"";const n=t/e.refHeight;if(o==="circle")return`circle(${Math.round(50*n*100)/100}px)`;const s=e.points.map(([p])=>p),r=e.points.map(([,p])=>p),a=(Math.min(...s)+Math.max(...s))/2*n,c=(Math.min(...r)+Math.max(...r))/2*n,l=(Math.max(...s)-Math.min(...s))*n,u=(i??l)/2,h=t/2,d=u-a,g=h-c;return`polygon(${e.points.map(([p,f])=>{const m=Math.round((p*n+d)*100)/100,y=Math.round((f*n+g)*100)/100;return`${m}px ${y}px`}).join(", ")})`}function je(o){return o in J}function We(o){return o?je(o)?J[o]:o:J.md}function Ge(o){if(!o)return"";const t=[];if(o.grayscale!==void 0&&t.push(`grayscale(${o.grayscale})`),o.blur!==void 0&&t.push(`blur(${o.blur}px)`),o.brightness!==void 0&&t.push(`brightness(${o.brightness})`),o.contrast!==void 0&&t.push(`contrast(${o.contrast})`),o.saturate!==void 0&&t.push(`saturate(${o.saturate})`),o.opacity!==void 0&&t.push(`opacity(${o.opacity})`),o.sepia!==void 0&&t.push(`sepia(${o.sepia})`),o.hueRotate!==void 0&&t.push(`hue-rotate(${o.hueRotate}deg)`),o.invert!==void 0&&t.push(`invert(${o.invert})`),o.dropShadow!==void 0)if(typeof o.dropShadow=="string")t.push(`drop-shadow(${o.dropShadow})`);else{const i=o.dropShadow;t.push(`drop-shadow(${i.x}px ${i.y}px ${i.blur}px ${i.color})`)}return t.join(" ")}function it(o){if(!o||o.style==="none"||o.width===0)return"none";const t=o.width??0,i=o.style??"solid",e=o.color??"#000000";return`${t}px ${i} ${e}`}function nt(o,t,i){if(!o)return{};const e={};if(o.borderRadiusTopLeft!==void 0||o.borderRadiusTopRight!==void 0||o.borderRadiusBottomRight!==void 0||o.borderRadiusBottomLeft!==void 0){const a=o.border?.radius??0;o.borderRadiusTopLeft!==void 0?e.borderTopLeftRadius=`${o.borderRadiusTopLeft}px`:a&&(e.borderTopLeftRadius=`${a}px`),o.borderRadiusTopRight!==void 0?e.borderTopRightRadius=`${o.borderRadiusTopRight}px`:a&&(e.borderTopRightRadius=`${a}px`),o.borderRadiusBottomRight!==void 0?e.borderBottomRightRadius=`${o.borderRadiusBottomRight}px`:a&&(e.borderBottomRightRadius=`${a}px`),o.borderRadiusBottomLeft!==void 0?e.borderBottomLeftRadius=`${o.borderRadiusBottomLeft}px`:a&&(e.borderBottomLeftRadius=`${a}px`)}else o.border?.radius!==void 0&&(e.borderRadius=`${o.border.radius}px`);if(o.borderTop||o.borderRight||o.borderBottom||o.borderLeft){const a=o.border||{},c={...a,...o.borderTop},l={...a,...o.borderRight},u={...a,...o.borderBottom},h={...a,...o.borderLeft};e.borderTop=it(c),e.borderRight=it(l),e.borderBottom=it(u),e.borderLeft=it(h)}else o.border&&(e.border=it(o.border));o.shadow!==void 0&&(e.boxShadow=We(o.shadow));const r=Ge(o.filter);if(e.filter=r||"none",o.opacity!==void 0&&(e.opacity=String(o.opacity)),o.cursor!==void 0&&(e.cursor=o.cursor),o.outline&&o.outline.style!=="none"&&(o.outline.width??0)>0){const a=o.outline.width??0,c=o.outline.style??"solid",l=o.outline.color??"#000000";e.outline=`${a}px ${c} ${l}`,o.outline.offset!==void 0&&(e.outlineOffset=`${o.outline.offset}px`)}if(o.objectFit!==void 0&&(e.objectFit=o.objectFit),o.aspectRatio!==void 0&&(e.aspectRatio=o.aspectRatio),o.clipPath!==void 0){let a;const c=typeof o.clipPath=="object"&&o.clipPath!==null&&"shape"in o.clipPath,l=c?o.clipPath:void 0;if(l?.mode==="height-relative"&&t)a=Be(l.shape,t,i);else{const u=c&&l?l.shape:o.clipPath;a=ke(u)}a&&(a==="none"?e.clipPath="unset":(e.clipPath=a,e.overflow="hidden"))}return e}function qe(o,t){t.borderRadius!==void 0&&(o.style.borderRadius=t.borderRadius),t.borderTopLeftRadius!==void 0&&(o.style.borderTopLeftRadius=t.borderTopLeftRadius),t.borderTopRightRadius!==void 0&&(o.style.borderTopRightRadius=t.borderTopRightRadius),t.borderBottomRightRadius!==void 0&&(o.style.borderBottomRightRadius=t.borderBottomRightRadius),t.borderBottomLeftRadius!==void 0&&(o.style.borderBottomLeftRadius=t.borderBottomLeftRadius),t.border!==void 0&&(o.style.border=t.border),t.borderTop!==void 0&&(o.style.borderTop=t.borderTop),t.borderRight!==void 0&&(o.style.borderRight=t.borderRight),t.borderBottom!==void 0&&(o.style.borderBottom=t.borderBottom),t.borderLeft!==void 0&&(o.style.borderLeft=t.borderLeft),t.boxShadow!==void 0&&(o.style.boxShadow=t.boxShadow),t.filter!==void 0&&(o.style.filter=t.filter),t.opacity!==void 0&&(o.style.opacity=t.opacity),t.cursor!==void 0&&(o.style.cursor=t.cursor),t.outline!==void 0&&(o.style.outline=t.outline),t.outlineOffset!==void 0&&(o.style.outlineOffset=t.outlineOffset),t.objectFit!==void 0&&(o.style.objectFit=t.objectFit),t.aspectRatio!==void 0&&(o.style.aspectRatio=t.aspectRatio),t.clipPath!==void 0&&(o.style.clipPath=t.clipPath),t.overflow!==void 0&&(o.style.overflow=t.overflow)}function at(o,t,i,e){const n=nt(t,i,e);qe(o,n)}function qt(o){return o?Array.isArray(o)?o.join(" "):o:""}function ot(o,t){const i=qt(t);i&&i.split(" ").forEach(e=>{e.trim()&&o.classList.add(e.trim())})}function vt(o,t){const i=qt(t);i&&i.split(" ").forEach(e=>{e.trim()&&o.classList.remove(e.trim())})}const Xt={UNFOCUSING:999,FOCUSING:1e3};class Yt{constructor(t,i,e){this.state=x.IDLE,this.currentFocus=null,this.focusData=null,this.outgoing=null,this.incoming=null,this.focusGeneration=0,this.onUnfocusComplete=null,this.config=t,this.animationEngine=i,this.styling=e,this.focusedClassName=e?.focused?.className}setOnUnfocusCompleteCallback(t){this.onUnfocusComplete=t}getState(){return this.state}isAnimating(){return this.state!==x.IDLE&&this.state!==x.FOCUSED}normalizeScalePercent(t){return t>1?t/100:t}calculateFocusDimensions(t,i,e){const n=this.normalizeScalePercent(this.config.scalePercent),s=e.height*n,r=t/i;let a=s,c=a*r;const l=e.width*n;return c>l&&(c=l,a=c/r),{width:c,height:a}}calculateFocusTransform(t,i){const e=t.width/2,n=t.height/2,s=e-i.x,r=n-i.y;return{x:s,y:r,rotation:0,scale:1}}buildDimensionZoomTransform(t){const i=["translate(-50%, -50%)"];if(t.x!==void 0||t.y!==void 0){const e=t.x??0,n=t.y??0;i.push(`translate(${e}px, ${n}px)`)}return t.rotation!==void 0&&i.push(`rotate(${t.rotation}deg)`),i.join(" ")}animateWithDimensions(t,i,e,n,s,r,a,c){const l=this.buildDimensionZoomTransform(i),u=this.buildDimensionZoomTransform(e);return t.style.transition="none",t.animate([{transform:l,width:`${n}px`,height:`${s}px`},{transform:u,width:`${r}px`,height:`${a}px`}],{duration:c,easing:"cubic-bezier(0.4, 0, 0.2, 1)",fill:"forwards"})}applyFocusedStyling(t,i){if(t.style.zIndex=String(i),t.classList.add("fbn-ic-focused"),ot(t,this.focusedClassName),this.styling?.focused){const e=nt(this.styling.focused,t.offsetHeight,t.offsetWidth);e.borderRadius!==void 0&&(t.style.borderRadius=e.borderRadius),e.borderTopLeftRadius!==void 0&&(t.style.borderTopLeftRadius=e.borderTopLeftRadius),e.borderTopRightRadius!==void 0&&(t.style.borderTopRightRadius=e.borderTopRightRadius),e.borderBottomRightRadius!==void 0&&(t.style.borderBottomRightRadius=e.borderBottomRightRadius),e.borderBottomLeftRadius!==void 0&&(t.style.borderBottomLeftRadius=e.borderBottomLeftRadius),e.border!==void 0&&(t.style.border=e.border),e.borderTop!==void 0&&(t.style.borderTop=e.borderTop),e.borderRight!==void 0&&(t.style.borderRight=e.borderRight),e.borderBottom!==void 0&&(t.style.borderBottom=e.borderBottom),e.borderLeft!==void 0&&(t.style.borderLeft=e.borderLeft),e.boxShadow!==void 0&&(t.style.boxShadow=e.boxShadow),e.filter!==void 0&&(t.style.filter=e.filter),e.opacity!==void 0&&(t.style.opacity=e.opacity),e.cursor!==void 0&&(t.style.cursor=e.cursor),e.outline!==void 0&&(t.style.outline=e.outline),e.outlineOffset!==void 0&&(t.style.outlineOffset=e.outlineOffset),e.objectFit!==void 0&&(t.style.objectFit=e.objectFit),e.aspectRatio!==void 0&&(t.style.aspectRatio=e.aspectRatio)}}removeFocusedStyling(t,i){if(t.style.zIndex=i,t.classList.remove("fbn-ic-focused"),vt(t,this.focusedClassName),this.styling?.default){const e=nt(this.styling.default,t.offsetHeight,t.offsetWidth);e.borderRadius!==void 0&&(t.style.borderRadius=e.borderRadius),e.borderTopLeftRadius!==void 0&&(t.style.borderTopLeftRadius=e.borderTopLeftRadius),e.borderTopRightRadius!==void 0&&(t.style.borderTopRightRadius=e.borderTopRightRadius),e.borderBottomRightRadius!==void 0&&(t.style.borderBottomRightRadius=e.borderBottomRightRadius),e.borderBottomLeftRadius!==void 0&&(t.style.borderBottomLeftRadius=e.borderBottomLeftRadius),e.border!==void 0&&(t.style.border=e.border),e.borderTop!==void 0&&(t.style.borderTop=e.borderTop),e.borderRight!==void 0&&(t.style.borderRight=e.borderRight),e.borderBottom!==void 0&&(t.style.borderBottom=e.borderBottom),e.borderLeft!==void 0&&(t.style.borderLeft=e.borderLeft),e.boxShadow!==void 0&&(t.style.boxShadow=e.boxShadow),e.filter!==void 0&&(t.style.filter=e.filter),e.opacity!==void 0&&(t.style.opacity=e.opacity),e.cursor!==void 0&&(t.style.cursor=e.cursor),e.outline!==void 0&&(t.style.outline=e.outline),e.outlineOffset!==void 0&&(t.style.outlineOffset=e.outlineOffset),e.objectFit!==void 0&&(t.style.objectFit=e.objectFit),e.aspectRatio!==void 0&&(t.style.aspectRatio=e.aspectRatio)}}startClipPathAnimation(t,i,e){let n=e?this.styling?.focused??this.styling?.default:this.styling?.default;e&&this.styling?.focused&&this.styling.focused.clipPath===void 0&&(n={...n,clipPath:void 0});const s=()=>{const r=t.offsetHeight,a=t.offsetWidth,c=nt(n,r,a);c.clipPath!==void 0?t.style.clipPath=c.clipPath:t.style.clipPath="unset",c.overflow!==void 0&&(t.style.overflow=c.overflow),i.animation.playState==="running"&&requestAnimationFrame(s)};requestAnimationFrame(s)}startFocusAnimation(t,i,e,n,s){const r=t.style.zIndex||"",a=t.offsetWidth,c=t.offsetHeight,l=this.calculateFocusDimensions(a,c,i),u=this.calculateFocusTransform(i,e);this.animationEngine.cancelAllAnimations(t);const h=this.config.animationDuration??600;this.applyFocusedStyling(t,Xt.FOCUSING);const d=n??{x:0,y:0,rotation:e.rotation,scale:1},g=s?.width??a,b=s?.height??c,p=this.animateWithDimensions(t,d,u,g,b,l.width,l.height,h),f={id:`focus-${Date.now()}`,element:t,animation:p,fromState:d,toState:u,startTime:performance.now(),duration:h};return this.focusData={element:t,originalState:e,focusTransform:u,originalZIndex:r,originalWidth:a,originalHeight:c,focusWidth:l.width,focusHeight:l.height},this.startClipPathAnimation(t,f,!0),{element:t,originalState:e,animationHandle:f,direction:"in",originalWidth:a,originalHeight:c}}startUnfocusAnimation(t,i,e,n){t.style.zIndex=String(Xt.UNFOCUSING),this.animationEngine.cancelAllAnimations(t);const s=this.config.animationDuration??600;t.classList.remove("fbn-ic-focused"),vt(t,this.focusedClassName);const r=e??this.focusData?.focusTransform??{x:0,y:0,rotation:0,scale:1},a=n?.width??this.focusData?.focusWidth??t.offsetWidth,c=n?.height??this.focusData?.focusHeight??t.offsetHeight,l={x:0,y:0,rotation:i.rotation,scale:1},u=this.focusData?.originalWidth??t.offsetWidth,h=this.focusData?.originalHeight??t.offsetHeight,d=this.animateWithDimensions(t,r,l,a,c,u,h,s),g={id:`unfocus-${Date.now()}`,element:t,animation:d,fromState:r,toState:l,startTime:performance.now(),duration:s};return this.startClipPathAnimation(t,g,!1),{element:t,originalState:i,animationHandle:g,direction:"out",originalWidth:u,originalHeight:h}}captureMidAnimationState(t){const i=getComputedStyle(t),e=new DOMMatrix(i.transform),n=t.offsetWidth,s=t.offsetHeight,r=e.e+n*.5,a=e.f+s*.5,c=Math.atan2(e.b,e.a)*(180/Math.PI);return t.style.width=`${n}px`,t.style.height=`${s}px`,t.style.transform=`translate(-50%, -50%) translate(${r}px, ${a}px) rotate(${c}deg)`,t.style.transition="none",{transform:{x:r,y:a,rotation:c,scale:1},dimensions:{width:n,height:s}}}async waitForAnimation(t){try{await t.animation.finished}catch{}}resetElementInstantly(t,i,e,n,s){this.animationEngine.cancelAllAnimations(t);const r=["translate(-50%, -50%)"];r.push("translate(0px, 0px)"),r.push(`rotate(${i.rotation}deg)`),t.style.transition="none",t.style.transform=r.join(" "),n!==void 0&&s!==void 0&&(t.style.width=`${n}px`,t.style.height=`${s}px`),this.removeFocusedStyling(t,e)}async focusImage(t,i,e){if(this.currentFocus===t&&this.state===x.FOCUSED)return this.unfocusImage();if(this.incoming?.element===t&&this.state===x.FOCUSING){const{transform:s,dimensions:r}=this.captureMidAnimationState(t);this.animationEngine.cancelAllAnimations(t),this.outgoing=this.startUnfocusAnimation(t,this.incoming.originalState,s,r),this.incoming=null,this.state=x.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=x.IDLE;return}const n=++this.focusGeneration;switch(this.state){case x.IDLE:if(this.state=x.FOCUSING,this.incoming=this.startFocusAnimation(t,i,e),await this.waitForAnimation(this.incoming.animationHandle),this.focusGeneration!==n)return;this.currentFocus=t,this.incoming=null,this.state=x.FOCUSED;break;case x.FOCUSED:if(this.state=x.CROSS_ANIMATING,this.currentFocus&&this.focusData&&(this.outgoing=this.startUnfocusAnimation(this.currentFocus,this.focusData.originalState)),this.incoming=this.startFocusAnimation(t,i,e),await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(this.incoming.animationHandle)]),this.focusGeneration!==n)return;if(this.outgoing){const s=this.outgoing.element;this.removeFocusedStyling(s,this.outgoing.originalState.zIndex?.toString()||""),this.outgoing=null,this.onUnfocusComplete?.(s)}this.currentFocus=t,this.incoming=null,this.state=x.FOCUSED;break;case x.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,i,e),await this.waitForAnimation(this.incoming.animationHandle),this.focusGeneration!==n)return;this.currentFocus=t,this.incoming=null,this.state=x.FOCUSED;break;case x.UNFOCUSING:if(this.state=x.CROSS_ANIMATING,this.incoming=this.startFocusAnimation(t,i,e),await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(this.incoming.animationHandle)]),this.focusGeneration!==n)return;if(this.outgoing){const s=this.outgoing.element;this.removeFocusedStyling(s,this.outgoing.originalState.zIndex?.toString()||""),this.outgoing=null,this.onUnfocusComplete?.(s)}this.currentFocus=t,this.incoming=null,this.state=x.FOCUSED;break;case x.CROSS_ANIMATING:if(this.incoming?.element===t)return;if(this.outgoing?.element===t){const{transform:s,dimensions:r}=this.captureMidAnimationState(t);if(this.animationEngine.cancelAllAnimations(t),this.incoming){const{transform:a,dimensions:c}=this.captureMidAnimationState(this.incoming.element);this.animationEngine.cancelAllAnimations(this.incoming.element),this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,a,c)}else this.outgoing=null;if(this.incoming=this.startFocusAnimation(t,i,e,s,r),await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(this.incoming.animationHandle)]),this.focusGeneration!==n)return;if(this.outgoing){const a=this.outgoing.element;this.removeFocusedStyling(a,this.outgoing.originalState.zIndex?.toString()||""),this.outgoing=null,this.onUnfocusComplete?.(a)}this.currentFocus=t,this.incoming=null,this.state=x.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{transform:s,dimensions:r}=this.captureMidAnimationState(this.incoming.element);this.animationEngine.cancelAllAnimations(this.incoming.element),this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,s,r)}if(this.incoming=this.startFocusAnimation(t,i,e),await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(this.incoming.animationHandle)]),this.focusGeneration!==n)return;if(this.outgoing){const s=this.outgoing.element;this.removeFocusedStyling(s,this.outgoing.originalState.zIndex?.toString()||""),this.outgoing=null,this.onUnfocusComplete?.(s)}this.currentFocus=t,this.incoming=null,this.state=x.FOCUSED;break}}async unfocusImage(){if(this.state===x.UNFOCUSING)return;const t=++this.focusGeneration;if(!this.currentFocus||!this.focusData){if(this.incoming&&this.state===x.FOCUSING){const{transform:s,dimensions:r}=this.captureMidAnimationState(this.incoming.element);if(this.animationEngine.cancelAllAnimations(this.incoming.element),this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,s,r),this.incoming=null,this.state=x.UNFOCUSING,await this.waitForAnimation(this.outgoing.animationHandle),this.focusGeneration!==t)return;const a=this.outgoing.element;this.removeFocusedStyling(a,this.focusData?.originalZIndex||""),this.outgoing=null,this.focusData=null,this.state=x.IDLE,this.onUnfocusComplete?.(a)}return}if(this.state===x.CROSS_ANIMATING&&this.incoming){const{transform:s,dimensions:r}=this.captureMidAnimationState(this.incoming.element);this.animationEngine.cancelAllAnimations(this.incoming.element);const a=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,s,r);if(await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(a.animationHandle)]),this.focusGeneration!==t)return;let c=null;this.outgoing&&(c=this.outgoing.element,this.removeFocusedStyling(c,this.outgoing.originalState.zIndex?.toString()||""));const l=a.element;this.removeFocusedStyling(l,this.incoming.originalState.zIndex?.toString()||""),this.outgoing=null,this.incoming=null,this.currentFocus=null,this.focusData=null,this.state=x.IDLE,c&&this.onUnfocusComplete?.(c),this.onUnfocusComplete?.(l);return}this.state=x.UNFOCUSING;const i=this.currentFocus,e=this.focusData.originalState,n=this.focusData.originalZIndex;this.outgoing=this.startUnfocusAnimation(i,e),await this.waitForAnimation(this.outgoing.animationHandle),this.focusGeneration===t&&(this.removeFocusedStyling(i,n),this.outgoing=null,this.currentFocus=null,this.focusData=null,this.state=x.IDLE,this.onUnfocusComplete?.(i))}async swapFocus(t,i,e){return this.focusImage(t,i,e)}getCurrentFocus(){return this.currentFocus}isFocused(t){return this.currentFocus===t&&this.state===x.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!==x.FOCUSED)return;const i=this.currentFocus,e=this.focusData.focusTransform,n=["translate(-50%, -50%)"],s=(e.x??0)+t,r=e.y??0;n.push(`translate(${s}px, ${r}px)`),e.rotation!==void 0&&n.push(`rotate(${e.rotation}deg)`),i.style.transition="none",i.style.transform=n.join(" ")}clearDragOffset(t,i=150){if(!this.currentFocus||!this.focusData||this.state!==x.FOCUSED)return;const e=this.currentFocus,n=this.focusData.focusTransform,s=["translate(-50%, -50%)"],r=n.x??0,a=n.y??0;s.push(`translate(${r}px, ${a}px)`),n.rotation!==void 0&&s.push(`rotate(${n.rotation}deg)`);const c=s.join(" ");t?(e.style.transition=`transform ${i}ms ease-out`,e.style.transform=c,setTimeout(()=>{this.currentFocus===e&&(e.style.transition="none")},i)):(e.style.transition="none",e.style.transform=c)}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=x.IDLE,this.currentFocus=null,this.focusData=null,this.outgoing=null,this.incoming=null}}const Xe=50,Ye=.5,Ve=20,Je=.3,Ke=150,Ze=30,rt=class rt{constructor(t,i){this.enabled=!1,this.touchState=null,this.recentTouchTimestamp=0,this.container=t,this.callbacks=i,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<rt.TOUCH_CLICK_DELAY}handleTouchStart(t){if(t.touches.length!==1)return;this.recentTouchTimestamp=Date.now();const i=t.touches[0];this.touchState={startX:i.clientX,startY:i.clientY,startTime:performance.now(),currentX:i.clientX,isDragging:!1,isHorizontalSwipe:null}}handleTouchMove(t){if(!this.touchState||t.touches.length!==1)return;const i=t.touches[0],e=i.clientX-this.touchState.startX,n=i.clientY-this.touchState.startY;if(this.touchState.isHorizontalSwipe===null&&Math.sqrt(e*e+n*n)>10){const a=Math.atan2(Math.abs(n),Math.abs(e))*(180/Math.PI);this.touchState.isHorizontalSwipe=a<=Ze}if(this.touchState.isHorizontalSwipe!==!1&&this.touchState.isHorizontalSwipe===!0){t.preventDefault(),this.touchState.isDragging=!0,this.touchState.currentX=i.clientX;const s=e*Je;this.callbacks.onDragOffset(s)}}handleTouchEnd(t){if(!this.touchState)return;this.recentTouchTimestamp=Date.now();const i=this.touchState.currentX-this.touchState.startX,e=performance.now()-this.touchState.startTime,n=Math.abs(i)/e,s=Math.abs(i);let r=!1;this.touchState.isHorizontalSwipe===!0&&this.touchState.isDragging&&(s>=Xe||n>=Ye&&s>=Ve)&&(r=!0,i<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}};rt.TOUCH_CLICK_DELAY=300;let Et=rt;class Vt{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 i of this.sources)if("folders"in i)for(const e of i.folders){const n=i.recursive!==void 0?i.recursive:!0,s=await this.loadFromFolder(e,t,n);this._discoveredUrls.push(...s)}else if("files"in i){const e=await this.loadFiles(i.files,t);this._discoveredUrls.push(...e)}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 i=[/\/folders\/([a-zA-Z0-9_-]+)/,/id=([a-zA-Z0-9_-]+)/];for(const e of i){const n=t.match(e);if(n&&n[1])return n[1]}return null}async loadFromFolder(t,i,e=!0){const n=this.extractFolderId(t);if(!n)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(n,i);try{return e?await this.loadImagesRecursively(n,i):await this.loadImagesFromSingleFolder(n,i)}catch(s){return console.error("Error loading from Google Drive API:",s),this.loadImagesDirectly(n,i)}}async loadImagesFromSingleFolder(t,i){const e=[],n=`'${t}' in parents and trashed=false`,r=`${this.apiEndpoint}?q=${encodeURIComponent(n)}&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 l=(await a.json()).files.filter(u=>u.mimeType.startsWith("image/")&&i.isAllowed(u.name));return this.log(`Found ${l.length} images in folder ${t} (non-recursive)`),l.forEach(u=>{e.push(`https://lh3.googleusercontent.com/d/${u.id}=s1600`),this.log(`Added file: ${u.name}`)}),e}async loadFiles(t,i){const e=[];for(const n of t){const s=this.extractFileId(n);if(!s){this.log(`Skipping invalid file URL: ${n}`);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 c=await a.json();c.mimeType.startsWith("image/")&&i.isAllowed(c.name)?(e.push(`https://lh3.googleusercontent.com/d/${s}=s1600`),this.log(`Added file: ${c.name}`)):this.log(`Skipping non-image file: ${c.name} (${c.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 e.push(`https://lh3.googleusercontent.com/d/${s}=s1600`)}return e}extractFileId(t){if(!/[/:.]/.test(t))return t;const i=[/\/file\/d\/([a-zA-Z0-9_-]+)/,/\/open\?id=([a-zA-Z0-9_-]+)/,/id=([a-zA-Z0-9_-]+)/];for(const e of i){const n=t.match(e);if(n&&n[1])return n[1]}return null}async loadImagesRecursively(t,i){const e=[],n=`'${t}' in parents and trashed=false`,r=`${this.apiEndpoint}?q=${encodeURIComponent(n)}&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(),l=c.files.filter(h=>h.mimeType.startsWith("image/")&&i.isAllowed(h.name)),u=c.files.filter(h=>h.mimeType==="application/vnd.google-apps.folder");this.log(`Found ${c.files.length} total items in folder ${t}`),c.files.forEach(h=>this.log(` - File: ${h.name} (${h.mimeType})`)),this.log(`- ${l.length} valid files (images only)`),this.log(`- ${u.length} subfolders`),l.forEach(h=>{e.push(`https://lh3.googleusercontent.com/d/${h.id}=s1600`),this.log(`Added file: ${h.name}`)});for(const h of u){this.log(`Loading images from subfolder: ${h.name}`);const d=await this.loadImagesRecursively(h.id,i);e.push(...d)}return e}async loadImagesDirectly(t,i){try{const e=`https://drive.google.com/embeddedfolderview?id=${t}`,n=await fetch(e,{mode:"cors"});if(!n.ok)throw new Error("Cannot access folder directly (CORS or permissions issue)");const s=await n.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(e){throw console.error("Direct loading failed:",e),new Error(`Unable to load images. Please ensure:
|
|
1
|
+
(function(S,J){typeof exports=="object"&&typeof module<"u"?J(exports):typeof define=="function"&&define.amd?define(["exports"],J):(S=typeof globalThis<"u"?globalThis:S||self,J(S.ImageCloud={}))})(this,(function(S){"use strict";const J=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)"}),ht=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})}),dt=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})}),ut=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})}),ft=Object.freeze({type:"linear"}),gt=Object.freeze({mode:"none"}),mt=Object.freeze({mode:"none"}),Lt=Object.freeze({default:Object.freeze({border:Object.freeze({width:0,color:"#000000",radius:0,style:"solid"}),shadow:"none",clipPath:void 0,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"})}),ne=Object.freeze({tightness:1}),oe=Object.freeze({rows:1,amplitude:100,frequency:2,phaseShift:0,synchronization:"offset"}),se=Object.freeze({spacing:0}),ae=Object.freeze({mobile:Object.freeze({maxWidth:767}),tablet:Object.freeze({maxWidth:1199})}),re=Object.freeze({mode:"adaptive",minSize:50,maxSize:400,variance:Object.freeze({min:1,max:1})}),ce=Object.freeze({mode:"none",range:Object.freeze({min:-15,max:15})}),Ft=Object.freeze({sizing:re,rotation:ce}),pt=Object.freeze({validateUrls:!0,validationTimeout:5e3,validationMethod:"head",allowedExtensions:["jpg","jpeg","png","gif","webp","bmp"]}),Mt=Object.freeze({enabled:!1,centers:!1,loaders:!1}),le=Object.freeze({maxAngle:5,speed:2e3,sync:"random"}),he=Object.freeze({minScale:.95,maxScale:1.05,speed:2400,sync:"random"}),de=Object.freeze({onRatio:.7,speed:3e3,style:"snap"}),ue=Object.freeze({speed:4e3,direction:"clockwise"}),Ot=Object.freeze({type:"none"}),A=Object.freeze({loaders:[],config:Object.freeze({loaders:pt,debug:Mt}),image:Ft,layout:Object.freeze({algorithm:"radial",scaleDecay:0,responsive:ae,targetCoverage:.6,densityFactor:1,spacing:Object.freeze({padding:50})}),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}),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:ft,rotation:gt,scale:mt}),idle:Ot}),interaction:Object.freeze({focus:Object.freeze({scalePercent:.8,zIndex:1e3,animationDuration:void 0}),navigation:Object.freeze({keyboard:!0,swipe:!0,mouseWheel:void 0}),dragging:!0}),ui:Object.freeze({showLoadingSpinner:!1,showImageCounter:!1,showNavButtons:!1,showFocusOutline:!1}),styling:Lt});function tt(o,t){if(!o)return t||{};if(!t)return{...o};const i={...o};return t.border!==void 0&&(i.border={...o.border,...t.border}),t.borderTop!==void 0&&(i.borderTop={...o.borderTop,...t.borderTop}),t.borderRight!==void 0&&(i.borderRight={...o.borderRight,...t.borderRight}),t.borderBottom!==void 0&&(i.borderBottom={...o.borderBottom,...t.borderBottom}),t.borderLeft!==void 0&&(i.borderLeft={...o.borderLeft,...t.borderLeft}),t.filter!==void 0&&(i.filter={...o.filter,...t.filter}),t.outline!==void 0&&(i.outline={...o.outline,...t.outline}),t.shadow!==void 0&&(i.shadow=t.shadow),t.clipPath!==void 0&&(i.clipPath=t.clipPath),t.opacity!==void 0&&(i.opacity=t.opacity),t.cursor!==void 0&&(i.cursor=t.cursor),t.className!==void 0&&(i.className=t.className),t.objectFit!==void 0&&(i.objectFit=t.objectFit),t.aspectRatio!==void 0&&(i.aspectRatio=t.aspectRatio),t.borderRadiusTopLeft!==void 0&&(i.borderRadiusTopLeft=t.borderRadiusTopLeft),t.borderRadiusTopRight!==void 0&&(i.borderRadiusTopRight=t.borderRadiusTopRight),t.borderRadiusBottomRight!==void 0&&(i.borderRadiusBottomRight=t.borderRadiusBottomRight),t.borderRadiusBottomLeft!==void 0&&(i.borderRadiusBottomLeft=t.borderRadiusBottomLeft),i}function fe(o,t){if(!t)return{...o};const i=tt(o.default,t.default),e=tt(tt(i,o.hover),t.hover),n=tt(tt(i,o.focused),t.focused);return{default:i,hover:e,focused:n}}function ge(o,t){if(!t)return{...o};const i={...o};if(t.sizing!==void 0&&(i.sizing={...o.sizing,...t.sizing},t.sizing.variance)){const e=t.sizing.variance,n=e.min!==void 0&&e.min>=.25&&e.min<=1?e.min:o.sizing?.variance?.min??1,s=e.max!==void 0&&e.max>=1&&e.max<=1.75?e.max:o.sizing?.variance?.max??1;i.sizing.variance={min:n,max:s}}if(t.rotation!==void 0&&(i.rotation={...o.rotation,...t.rotation},t.rotation.range)){const e=t.rotation.range,n=e.min!==void 0&&e.min>=-180&&e.min<=0?e.min:o.rotation?.range?.min??-15,s=e.max!==void 0&&e.max>=0&&e.max<=180?e.max:o.rotation?.range?.max??15;i.rotation.range={min:n,max:s}}return i}function me(o){const t=o.layout?.rotation;if(t&&"enabled"in t)return{rotation:{mode:t.enabled?"random":"none",range:t.range}}}function pe(o){const t=o.layout?.sizing?.variance;if(t)return{sizing:{mode:"adaptive",variance:t}}}function be(o={}){const t=me(o),i=pe(o);let e=o.image;(t||i)&&(e={...i||{},...t||{},...e},e.rotation&&t?.rotation&&o.image?.rotation&&(e.rotation={...t.rotation,...o.image.rotation}));const n=[...o.loaders??[]];o.images&&o.images.length>0&&n.unshift({static:{sources:[{urls:o.images}]}});const r={loaders:{...pt,...o.config?.loaders??{}}},a={loaders:n,config:r,image:ge(Ft,e),layout:{...A.layout},animation:{...A.animation},interaction:{...A.interaction},ui:{...A.ui},styling:fe(Lt,o.styling)};o.layout&&(a.layout={...A.layout,...o.layout},o.layout.responsive&&(a.layout.responsive={...A.layout.responsive,mobile:o.layout.responsive.mobile?{...A.layout.responsive.mobile,...o.layout.responsive.mobile}:A.layout.responsive.mobile,tablet:o.layout.responsive.tablet?{...A.layout.responsive.tablet,...o.layout.responsive.tablet}:A.layout.responsive.tablet}),o.layout.spacing&&(a.layout.spacing={...A.layout.spacing,...o.layout.spacing})),o.animation&&(a.animation={...A.animation,...o.animation},o.animation.easing&&(a.animation.easing={...A.animation.easing,...o.animation.easing}),o.animation.queue&&(a.animation.queue={...A.animation.queue,...o.animation.queue}),o.animation.entry&&(a.animation.entry={...A.animation.entry,...o.animation.entry,start:o.animation.entry.start?{...A.animation.entry.start,...o.animation.entry.start,circular:o.animation.entry.start.circular?{...A.animation.entry.start.circular,...o.animation.entry.start.circular}:A.animation.entry.start.circular}:A.animation.entry.start,timing:o.animation.entry.timing?{...A.animation.entry.timing,...o.animation.entry.timing}:A.animation.entry.timing,path:o.animation.entry.path?{...ft,...o.animation.entry.path}:A.animation.entry.path,rotation:o.animation.entry.rotation?{...gt,...o.animation.entry.rotation}:A.animation.entry.rotation,scale:o.animation.entry.scale?{...mt,...o.animation.entry.scale}:A.animation.entry.scale}),o.animation.idle&&(a.animation.idle={...Ot,...o.animation.idle})),o.interaction&&(a.interaction={...A.interaction,...o.interaction},o.interaction.focus&&(a.interaction.focus={...A.interaction.focus,...o.interaction.focus}),o.interaction.navigation&&(a.interaction.navigation={...A.interaction.navigation,...o.interaction.navigation}));const c=o.rendering?.ui;if(c&&console.warn("[ImageCloud] rendering.ui is deprecated. Use top-level ui instead."),a.ui={...A.ui,...c,...o.ui},a.config.debug={...Mt,...o.config?.debug??{}},a.layout.algorithm==="honeycomb"&&a.styling){const l={shape:"hexagon",mode:"height-relative"};a.styling={...a.styling,default:{...a.styling.default,clipPath:l},hover:{...a.styling.hover,clipPath:l}}}return a}function ye(o,t){return{...o?ht[o]:ht.playful,...t}}function ve(o,t){return{...o?dt[o]:dt.gentle,...t}}function Ee(o,t){return{...o?ut[o]:ut.gentle,...t}}class zt{constructor(t){this.activeAnimations=new Map,this.animationIdCounter=0,this.config=t}buildTransformString(t){const i=["translate(-50%, -50%)"];if(t.x!==void 0||t.y!==void 0){const e=t.x??0,n=t.y??0;i.push(`translate(${e}px, ${n}px)`)}return t.rotation!==void 0&&i.push(`rotate(${t.rotation}deg)`),t.scale!==void 0&&i.push(`scale(${t.scale})`),i.join(" ")}animateTransformCancellable(t,i,e,n=null,s=null){this.cancelAllAnimations(t);const r=n??this.config.duration,a=s??this.config.easing.default,c=this.buildTransformString(i),l=this.buildTransformString(e);t.style.transition="none";const u=t.animate([{transform:c},{transform:l}],{duration:r,easing:a,fill:"forwards"}),h={id:`anim-${++this.animationIdCounter}`,element:t,animation:u,fromState:i,toState:e,startTime:performance.now(),duration:r};return this.activeAnimations.set(t,h),u.finished.then(()=>{t.style.transform=l,this.activeAnimations.delete(t)}).catch(()=>{this.activeAnimations.delete(t)}),h}cancelAnimation(t,i=!0){const e=this.getCurrentTransform(t.element);if(t.animation.cancel(),i){const n=this.buildTransformString({x:e.x,y:e.y,rotation:e.rotation,scale:e.scale});t.element.style.transform=n}return this.activeAnimations.delete(t.element),e}cancelAllAnimations(t){const i=this.activeAnimations.get(t);i&&this.cancelAnimation(i,!1);const e=t.getAnimations();for(const n of e)n.cancel()}getCurrentTransform(t){const e=getComputedStyle(t).transform;if(e==="none"||!e)return{x:0,y:0,rotation:0,scale:1};const n=new DOMMatrix(e),s=Math.sqrt(n.a*n.a+n.b*n.b),r=Math.atan2(n.b,n.a)*(180/Math.PI),a=n.e,c=n.f;return{x:a,y:c,rotation:r,scale:s}}hasActiveAnimation(t){return this.activeAnimations.has(t)}getAnimationHandle(t){return this.activeAnimations.get(t)}animateTransform(t,i,e=null,n=null){return new Promise(s=>{const r=e??this.config.duration,a=n??this.config.easing.default;t.style.transition=`transform ${r}ms ${a}, box-shadow ${r}ms ${a}`,t.style.transform=this.buildTransformString(i),setTimeout(()=>{s()},r)})}resetTransform(t,i){return this.animateTransform(t,i)}clearTransition(t){t.style.transition=""}wait(t){return new Promise(i=>setTimeout(i,t))}}function K(o,t,i){return o+(t-o)*i}function we(o,t,i,e){const{overshoot:n,bounces:s,decayRatio:r}=e,a=i.x-t.x,c=i.y-t.y,l=xe(s,r);let u=0,h=0,d=1,g=n,b=!1;for(let f=0;f<l.length;f++)if(o<=l[f].time){h=f===0?0:l[f-1].time,d=l[f].time,g=l[f].overshoot,b=l[f].isOvershoot;break}const p=(o-h)/(d-h);if(b)u=1+g*st(p);else if(h===0)u=st(p);else{const m=1+(l.find((y,E)=>y.time>h&&E>0&&l[E-1].isOvershoot)?.overshoot||g);u=K(m,1,st(p))}return{x:t.x+a*u,y:t.y+c*u}}function xe(o,t){const i=[];let e=.6;i.push({time:e,overshoot:0,isOvershoot:!1});let n=.15;const r=.4/(o*2);for(let a=0;a<o;a++)e+=r,i.push({time:e,overshoot:n,isOvershoot:!0}),e+=r,i.push({time:e,overshoot:n*t,isOvershoot:!1}),n*=t;return i.push({time:1,overshoot:0,isOvershoot:!1}),i}function Se(o,t,i,e){const{stiffness:n,damping:s,mass:r,oscillations:a}=e,c=i.x-t.x,l=i.y-t.y,u=Math.sqrt(n/r),h=s/(2*Math.sqrt(n*r));let d;if(h<1){const g=u*Math.sqrt(1-h*h),b=Math.exp(-h*u*o*3),p=Math.cos(g*o*a*Math.PI);d=1-b*p}else d=1-Math.exp(-u*o*3);return d=Math.max(0,Math.min(d,1.3)),{x:t.x+c*d,y:t.y+l*d}}function Ie(o,t,i,e){const{amplitude:n,frequency:s,decay:r,decayRate:a,phase:c}=e,l=i.x-t.x,u=i.y-t.y,h=Math.sqrt(l*l+u*u),d=h>0?-u/h:0,g=h>0?l/h:1,b=s*Math.PI*2*o+c,p=r?Math.pow(1-o,a):1,f=n*Math.sin(b)*p,m=Ae(o);return{x:K(t.x,i.x,m)+f*d,y:K(t.y,i.y,m)+f*g}}function st(o){return 1-(1-o)*(1-o)}function Ae(o){return 1-Math.pow(1-o,3)}function Ce(o,t,i){const{amplitude:e,frequency:n,decay:s}=i,r=Math.sin(o*n*Math.PI*2),a=s?Math.pow(1-o,2):1,c=e*r*a;return t+c}function Re(o,t,i){const{overshoot:e,bounces:n}=i,s=[];s.push({time:.5,scale:e});let r=e;const a=.5,l=.5/(n*2);let u=.5;for(let d=0;d<n;d++){const g=1-(r-1)*a;u+=l,s.push({time:u,scale:g}),r=1+(r-1)*a*a,u+=l,d<n-1&&s.push({time:u,scale:r})}s.push({time:1,scale:1});let h=1;for(let d=0;d<s.length;d++)if(o<=s[d].time){const g=d===0?0:s[d-1].time,b=d===0?1:s[d-1].scale,p=(o-g)/(s[d].time-g),f=st(p);h=b+(s[d].scale-b)*f;break}return h*t}function Dt(o){const{element:t,startPosition:i,endPosition:e,pathConfig:n,duration:s,imageWidth:r,imageHeight:a,rotation:c,scale:l,onComplete:u,rotationConfig:h,startRotation:d,scaleConfig:g,startScale:b}=o,p=n.type,f=d!==void 0&&d!==c,m=h?.mode==="wobble",y=h?.wobble||{amplitude:15,frequency:3,decay:!0},E=f||m,v=b!==void 0&&b!==l,I=g?.mode==="pop",w=g?.pop||{overshoot:1.2,bounces:1};if((p==="linear"||p==="arc")&&!E&&!(v||I)){u&&u();return}const z=performance.now(),F=-r/2,U=-a/2;function D(N){const k=N-z,R=Math.min(k/s,1);let P;switch(p){case"bounce":{const B=ye(n.bouncePreset,n.bounce);P=we(R,i,e,B);break}case"elastic":{const B=ve(n.elasticPreset,n.elastic);P=Se(R,i,e,B);break}case"wave":{const B=Ee(n.wavePreset,n.wave);P=Ie(R,i,e,B);break}default:P={x:K(i.x,e.x,R),y:K(i.y,e.y,R)}}const G=P.x-e.x,H=P.y-e.y;let M;m?M=Ce(R,c,y):f?M=K(d,c,R):M=c;let T;I?T=Re(R,l,w):v?T=K(b,l,R):T=l,t.style.transform=`translate(${F}px, ${U}px) translate(${G}px, ${H}px) rotate(${M}deg) scale(${T})`,R<1?requestAnimationFrame(D):(t.style.transform=`translate(${F}px, ${U}px) rotate(${c}deg) scale(${l})`,u&&u())}requestAnimationFrame(D)}function Pt(o){return o==="bounce"||o==="elastic"||o==="wave"}const Te={radial:"center",spiral:"center",grid:"top",cluster:"nearest-edge",random:"nearest-edge",wave:"left",honeycomb:"center"};class $t{constructor(t,i){this.config=t,this.layoutAlgorithm=i,this.resolvedStartPosition=this.resolveStartPosition(),this.pathConfig=t.path||ft,this.rotationConfig=t.rotation||gt,this.scaleConfig=t.scale||mt}resolveStartPosition(){return this.config.start.position?this.config.start.position:Te[this.layoutAlgorithm]||"nearest-edge"}calculateStartPosition(t,i,e,n,s){const r=this.resolvedStartPosition,a=this.config.start.offset??100;switch(r){case"nearest-edge":return this.calculateNearestEdge(t,i,e,a);case"top":return this.calculateEdgePosition("top",t,i,e,a);case"bottom":return this.calculateEdgePosition("bottom",t,i,e,a);case"left":return this.calculateEdgePosition("left",t,i,e,a);case"right":return this.calculateEdgePosition("right",t,i,e,a);case"center":return this.calculateCenterPosition(e,t,i);case"random-edge":return this.calculateRandomEdge(t,i,e,a);case"circular":return this.calculateCircularPosition(t,i,e,n,s);default:return this.calculateNearestEdge(t,i,e,a)}}calculateNearestEdge(t,i,e,n){const s=t.x,r=t.y,a=s,c=e.width-s,l=r,u=e.height-r,h=Math.min(a,c,l,u);let d=t.x,g=t.y;return h===a?d=-(i.width+n):h===c?d=e.width+n:h===l?g=-(i.height+n):g=e.height+n,{x:d,y:g}}calculateEdgePosition(t,i,e,n,s){let r=i.x,a=i.y;switch(t){case"top":a=-(e.height+s);break;case"bottom":a=n.height+s;break;case"left":r=-(e.width+s);break;case"right":r=n.width+s;break}return{x:r,y:a}}calculateCenterPosition(t,i,e){const n=t.width/2,s=t.height/2;return{x:n,y:s,useScale:!0}}calculateRandomEdge(t,i,e,n){const s=["top","bottom","left","right"],r=s[Math.floor(Math.random()*s.length)];return this.calculateEdgePosition(r,t,i,e,n)}calculateCircularPosition(t,i,e,n,s){const r=this.config.start.circular||{},a=r.distribution||"even";let c;const l=r.radius||"120%";if(typeof l=="string"&&l.endsWith("%")){const p=parseFloat(l)/100;c=Math.sqrt(e.width**2+e.height**2)*p/2}else c=typeof l=="number"?l:500;let u;a==="even"?u=n/s*2*Math.PI:u=Math.random()*2*Math.PI;const h=e.width/2,d=e.height/2,g=h+Math.cos(u)*c,b=d+Math.sin(u)*c;return{x:g,y:b}}getAnimationParams(t){const i=this.config.timing.duration,e=this.config.easing;return{startTransform:"",duration:i,delay:0,easing:e}}buildStartTransform(t,i,e,n,s,r,a,c){const l=t.x-i.x,u=t.y-i.y,h=a!==void 0?a:e,d=c!==void 0?c:n,g=s!==void 0?-s/2:0,b=r!==void 0?-r/2:0,p=s!==void 0?`translate(${g}px, ${b}px)`:"translate(-50%, -50%)";return t.useScale?`${p} translate(${l}px, ${u}px) rotate(${h}deg) scale(0)`:`${p} translate(${l}px, ${u}px) rotate(${h}deg) scale(${d})`}buildFinalTransform(t,i,e,n){if(e!==void 0&&n!==void 0){const s=-e/2,r=-n/2;return`translate(${s}px, ${r}px) rotate(${t}deg) scale(${i})`}return`translate(-50%, -50%) rotate(${t}deg) scale(${i})`}getTransitionCSS(){const t=this.config.timing.duration,i=this.config.easing;return this.requiresJSAnimation()?`opacity ${t}ms ease-out`:`opacity ${t}ms ease-out, transform ${t}ms ${i}`}requiresJSAnimation(){return Pt(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 e=this.rotationConfig.startRotation;if(e===void 0)return t+(Math.random()-.5)*60;if(typeof e=="number")return e;const n=e.max-e.min;return e.min+Math.random()*n}case"spin":{const e=this.rotationConfig.spinCount??1,n=this.resolveSpinDirection(t);return t+e*360*n}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,i){if(this.rotationConfig.mode!=="wobble")return i;const e=this.rotationConfig.wobble||{amplitude:15,frequency:3,decay:!0},{amplitude:n,frequency:s,decay:r}=e,a=Math.sin(t*s*Math.PI*2),c=r?Math.pow(1-t,2):1,l=n*a*c;return i+l}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 e=this.scaleConfig.range??{min:.5,max:1};return(e.min+Math.random()*(e.max-e.min))*t}default:return t}}requiresJSScale(){return this.scaleConfig.mode==="pop"}calculatePopScale(t,i){if(this.scaleConfig.mode!=="pop")return i;const e=this.scaleConfig.pop||{overshoot:1.2,bounces:1},{overshoot:n,bounces:s}=e,r=this.generateScaleBounceKeyframes(s,n);let a=i;for(let c=0;c<r.length;c++)if(t<=r[c].time){const l=c===0?0:r[c-1].time,u=c===0?i:r[c-1].scale,h=(t-l)/(r[c].time-l),d=this.easeOutQuad(h);a=u+(r[c].scale-u)*d;break}return a*i}generateScaleBounceKeyframes(t,i){const e=[];e.push({time:.5,scale:i});let n=i;const s=.5,a=.5/(t*2);let c=.5;for(let l=0;l<t;l++){const u=1-(n-1)*s;c+=a,e.push({time:c,scale:u}),n=1+(n-1)*s*s,c+=a,l<t-1&&e.push({time:c,scale:n})}return e.push({time:1,scale:1}),e}easeOutQuad(t){return 1-(1-t)*(1-t)}}class Le{constructor(t,i=600){this.entries=new Map,this.togetherRafId=null,this.togetherSpeed=0,this.config=t,this.entryDurationMs=i}register(t,i,e,n){if(this.entries.has(t))return;const s=n??this.entryDurationMs,r=this.config.startDelay??s,a={element:t,index:i,totalImages:e,animation:null,blinkAnimation:null,customTeardown:null,paused:!1,stopped:!1,startTimer:null};this.entries.set(t,a),a.startTimer=setTimeout(()=>{a.startTimer=null,!a.stopped&&!a.paused&&this._startAnimation(a)},r)}pauseForImage(t){const i=this.entries.get(t);i&&(i.paused=!0,i.startTimer!==null&&(clearTimeout(i.startTimer),i.startTimer=null),this._pauseEntry(i))}resumeForImage(t){const i=this.entries.get(t);!i||i.stopped||(i.paused=!1,this._startAnimation(i))}stopForImage(t){const i=this.entries.get(t);i&&(i.stopped=!0,i.startTimer!==null&&(clearTimeout(i.startTimer),i.startTimer=null),this._cancelEntry(i),this.entries.delete(t))}pauseAll(){for(const t of this.entries.values())t.paused=!0,t.startTimer!==null&&(clearTimeout(t.startTimer),t.startTimer=null),this._pauseEntry(t)}resumeAll(){for(const t of this.entries.values())t.stopped||(t.paused=!1,this._startAnimation(t))}stopAll(){for(const t of this.entries.values())t.stopped=!0,t.startTimer!==null&&(clearTimeout(t.startTimer),t.startTimer=null),this._cancelEntry(t);this.entries.clear(),this._stopTogetherLoop()}_startAnimation(t){const{type:i}=this.config;switch(i){case"wiggle":this._startWiggle(t);break;case"pulse":this._startPulse(t);break;case"blink":this._startBlink(t);break;case"spin":this._startSpin(t);break;case"custom":this._startCustom(t);break}}_startWiggle(t){const i={...le,...this.config.wiggle},e=[{transform:"rotate(0deg)",offset:0},{transform:`rotate(${i.maxAngle}deg)`,offset:.25},{transform:"rotate(0deg)",offset:.5},{transform:`rotate(${-i.maxAngle}deg)`,offset:.75},{transform:"rotate(0deg)",offset:1}];i.sync==="together"?(t.animation=t.element.animate(e,{duration:i.speed,iterations:1/0,composite:"add",fill:"both"}),t.animation.pause(),this._startTogetherLoop(i.speed)):t.animation=t.element.animate(e,{duration:i.speed,delay:-(Math.random()*i.speed),iterations:1/0,composite:"add"})}_startPulse(t){const i={...he,...this.config.pulse},e=[{transform:"scale(1)",offset:0},{transform:`scale(${i.maxScale})`,offset:.25},{transform:"scale(1)",offset:.5},{transform:`scale(${i.minScale})`,offset:.75},{transform:"scale(1)",offset:1}];i.sync==="together"?(t.animation=t.element.animate(e,{duration:i.speed,iterations:1/0,composite:"add",fill:"both"}),t.animation.pause(),this._startTogetherLoop(i.speed)):t.animation=t.element.animate(e,{duration:i.speed,delay:-(Math.random()*i.speed),iterations:1/0,composite:"add"})}_startBlink(t){const i={...de,...this.config.blink},e=-(Math.random()*i.speed),n=parseFloat(getComputedStyle(t.element).opacity)||1;let s,r;i.style==="fade"?(s=[{opacity:n,offset:0},{opacity:0,offset:.5},{opacity:n,offset:1}],r={duration:i.speed,delay:e,iterations:1/0,easing:"ease-in-out"}):(s=[{opacity:n,offset:0},{opacity:n,offset:i.onRatio},{opacity:0,offset:Math.min(i.onRatio+.01,.99)},{opacity:0,offset:.99},{opacity:n,offset:1}],r={duration:i.speed,delay:e,iterations:1/0}),t.blinkAnimation=t.element.animate(s,r)}_startSpin(t){const i={...ue,...this.config.spin},e=i.direction==="clockwise"?360:-360;t.animation=t.element.animate([{transform:"rotate(0deg)"},{transform:`rotate(${e}deg)`}],{duration:i.speed,iterations:1/0,easing:"linear",composite:"add"})}_startCustom(t){const i=this.config.custom;if(!i)return;const e=i({element:t.element,index:t.index,totalImages:t.totalImages});typeof e=="function"?t.customTeardown=e:e&&typeof e.play=="function"&&(t.animation=e)}_startTogetherLoop(t){if(this.togetherSpeed=t,this.togetherRafId!==null)return;const i=()=>{const e=performance.now()%this.togetherSpeed;for(const n of this.entries.values())!n.stopped&&!n.paused&&n.animation&&(n.animation.currentTime=e);this.togetherRafId=requestAnimationFrame(i)};this.togetherRafId=requestAnimationFrame(i)}_stopTogetherLoop(){this.togetherRafId!==null&&(cancelAnimationFrame(this.togetherRafId),this.togetherRafId=null)}_pauseEntry(t){t.animation&&(t.animation.cancel(),t.animation=null),t.blinkAnimation&&(t.blinkAnimation.cancel(),t.blinkAnimation=null)}_cancelEntry(t){t.animation&&(t.animation.cancel(),t.animation=null),t.blinkAnimation&&(t.blinkAnimation.cancel(),t.blinkAnimation=null),t.customTeardown&&(t.customTeardown(),t.customTeardown=null)}}class _t{constructor(t,i={}){this.config=t,this.imageConfig=i}generate(t,i,e={}){const n=[],{width:s,height:r}=i,a=this.config.spacing.padding,c=e.fixedHeight??200,l=this.imageConfig.rotation?.mode??"none",u=this.imageConfig.rotation?.range?.min??-15,h=this.imageConfig.rotation?.range?.max??15,d=this.imageConfig.sizing?.variance?.min??1,g=this.imageConfig.sizing?.variance?.max??1,b=d!==1||g!==1,f=c*1.5/2,m=c/2,y=s-a-f,E=r-a-m,v=a+f,I=a+m;for(let w=0;w<t;w++){const C=this.random(v,y),z=this.random(I,E),F=l==="random"?this.random(u,h):0,U=b?this.random(d,g):1,D=c*U,N={id:w,x:C,y:z,rotation:F,scale:U,baseSize:D};n.push(N)}return n}random(t,i){return Math.random()*(i-t)+t}}class Ut{constructor(t,i={}){this.config=t,this.imageConfig=i}generate(t,i,e={}){const n=[],{width:s,height:r}=i,a=e.fixedHeight??200,c=this.imageConfig.rotation?.mode??"none",l=this.imageConfig.rotation?.range?.min??-15,u=this.imageConfig.rotation?.range?.max??15,h=this.imageConfig.sizing?.variance?.min??1,d=this.imageConfig.sizing?.variance?.max??1,g=h!==1||d!==1,b=this.config.scaleDecay??0,p={...ne,...this.config.radial},f=e.fixedHeight??a,m=s/2,y=r/2,E=Math.ceil(Math.sqrt(t)),v=this.config.spacing.padding??50,I=Math.max(f*.8,Math.min(m-v-f/2,y-v-f/2));if(t>0){const z=g?this.random(h,d):1,F=f*z;n.push({id:0,x:m,y,rotation:c==="random"?this.random(l*.33,u*.33):0,scale:z,baseSize:F,zIndex:100})}let w=1,C=1;for(;w<t;){const z=C/E,F=b>0?1-z*b*.5:1,U=Math.max(f*.8,I/E*1.5/p.tightness),D=C*U,N=D*1.5,k=Math.PI*(3*(N+D)-Math.sqrt((3*N+D)*(N+3*D))),R=this.estimateWidth(f),P=Math.floor(k/(R*.7));if(P===0){C++;continue}const G=2*Math.PI/P,H=C*(20*Math.PI/180);for(let M=0;M<P&&w<t;M++){const T=M*G+H,B=g?this.random(h,d):1,X=F*B,L=f*X;let $=m+Math.cos(T)*N,O=y+Math.sin(T)*D;const _=L*1.5/2,j=L/2;$-_<v?$=v+_:$+_>s-v&&($=s-v-_),O-j<v?O=v+j:O+j>r-v&&(O=r-v-j);const V=c==="random"?this.random(l,u):0;n.push({id:w,x:$,y:O,rotation:V,scale:X,baseSize:L,zIndex:Math.max(1,100-C)}),w++}C++}return n}estimateWidth(t){return t*1.4}random(t,i){return Math.random()*(i-t)+t}}const Fe={columns:"auto",rows:"auto",stagger:"none",jitter:0,overlap:0,fillDirection:"row",alignment:"center",gap:10,overflowOffset:.25},Ht=[{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 Nt{constructor(t,i={}){this.config=t,this.imageConfig=i}generate(t,i,e={}){const n=[],{width:s,height:r}=i,a={...Fe,...this.config.grid},c=this.config.spacing.padding,l=e.fixedHeight??200,u=this.imageConfig.rotation?.mode??"none",h=this.imageConfig.sizing?.variance?.min??1,d=this.imageConfig.sizing?.variance?.max??1,g=h!==1||d!==1,b=s-2*c,p=r-2*c,{columns:f,rows:m}=this.calculateGridDimensions(t,b,p,l,a),y=a.stagger==="row",E=a.stagger==="column",v=y?f+.5:f,I=E?m+.5:m,w=(b-a.gap*(f-1))/v,C=(p-a.gap*(m-1))/I,z=y?w/2:0,F=E?C/2:0,U=1+a.overlap,D=Math.min(w,C)*U,N=e.fixedHeight?Math.min(e.fixedHeight,D):D,k=f*w+(f-1)*a.gap+z,R=m*C+(m-1)*a.gap+F,P=c+(b-k)/2,G=c+(p-R)/2,H=f*m,M=a.columns!=="auto"&&a.rows!=="auto",T=M&&t>H;typeof window<"u"&&(window.__gridOverflowDebug={gridConfigColumns:a.columns,gridConfigRows:a.rows,columns:f,rows:m,cellCount:H,hasFixedGrid:M,imageCount:t,isOverflowMode:T});const B=T?new Array(H).fill(0):[],X=Math.min(w,C)*a.overflowOffset;for(let L=0;L<t;L++){let $,O,Y=0;if(T&&L>=H){const q=L-H,W=q%H;Y=Math.floor(q/H)+1,B[W]++,a.fillDirection==="row"?($=W%f,O=Math.floor(W/f)):(O=W%m,$=Math.floor(W/m))}else a.fillDirection==="row"?($=L%f,O=Math.floor(L/f)):(O=L%m,$=Math.floor(L/m));let _=P+$*(w+a.gap)+w/2,j=G+O*(C+a.gap)+C/2;if(a.stagger==="row"&&O%2===1?_+=w/2:a.stagger==="column"&&$%2===1&&(j+=C/2),Y>0){const q=(Y-1)%Ht.length,W=Ht[q];_+=W.x*X,j+=W.y*X}if(a.jitter>0){const q=w/2*a.jitter,W=C/2*a.jitter;_+=this.random(-q,q),j+=this.random(-W,W)}let V=_,Z=j;if(!T&&a.fillDirection==="row"){const q=t%f||f;if(O===Math.floor((t-1)/f)&&q<f){const ie=q*w+(q-1)*a.gap;let Tt=0;a.alignment==="center"?Tt=(k-ie)/2:a.alignment==="end"&&(Tt=k-ie),V+=Tt}}const xt=g?this.random(h,d):1,Q=N*xt,ct=Q*1.5/2,lt=Q/2,It=c+ct,At=s-c-ct,ti=c+lt,ei=r-c-lt;V=Math.max(It,Math.min(V,At)),Z=Math.max(ti,Math.min(Z,ei));let Ct=0;if(u==="random"){const q=this.imageConfig.rotation?.range?.min??-15,W=this.imageConfig.rotation?.range?.max??15;a.jitter>0?Ct=this.random(q*a.jitter,W*a.jitter):Ct=this.random(q,W)}let Rt;T&&Y>0?Rt=50-Y:Rt=T?100+L:L+1,n.push({id:L,x:V,y:Z,rotation:Ct,scale:xt,baseSize:Q,zIndex:Rt})}return n}calculateGridDimensions(t,i,e,n,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 c=i/e;for(r=Math.max(1,Math.round(Math.sqrt(t*c/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,i){return Math.random()*(i-t)+t}}const Me=Math.PI*(3-Math.sqrt(5)),Oe={spiralType:"golden",direction:"counterclockwise",tightness:1,scaleDecay:0,startAngle:0};class kt{constructor(t,i={}){this.config=t,this.imageConfig=i}generate(t,i,e={}){const n=[],{width:s,height:r}=i,a={...Oe,...this.config.spiral},c=this.config.spacing.padding,l=e.fixedHeight??200,u=this.imageConfig.rotation?.mode??"none",h=this.imageConfig.rotation?.range?.min??-15,d=this.imageConfig.rotation?.range?.max??15,g=this.imageConfig.sizing?.variance?.min??1,b=this.imageConfig.sizing?.variance?.max??1,p=g!==1||b!==1,f=this.config.scaleDecay??a.scaleDecay,m=s/2,y=r/2,E=Math.min(m-c-l/2,y-c-l/2),v=a.direction==="clockwise"?-1:1;for(let I=0;I<t;I++){let w,C;if(a.spiralType==="golden")w=I*Me*v+a.startAngle,C=this.calculateGoldenRadius(I,t,E,a.tightness);else if(a.spiralType==="archimedean"){const _=I*.5*a.tightness;w=_*v+a.startAngle,C=this.calculateArchimedeanRadius(_,t,E,a.tightness)}else{const _=I*.3*a.tightness;w=_*v+a.startAngle,C=this.calculateLogarithmicRadius(_,t,E,a.tightness)}const z=m+Math.cos(w)*C,F=y+Math.sin(w)*C,U=C/E,D=f>0?1-U*f*.5:1,N=p?this.random(g,b):1,k=D*N,R=l*k,G=R*1.5/2,H=R/2,M=c+G,T=s-c-G,B=c+H,X=r-c-H,L=Math.max(M,Math.min(z,T)),$=Math.max(B,Math.min(F,X));let O=0;if(u==="random"){const _=w*180/Math.PI%360,j=this.random(h,d);O=a.spiralType==="golden"?j:_*.1+j*.9}else u==="tangent"&&(O=this.calculateSpiralTangent(w,C,a));const Y=t-I;n.push({id:I,x:L,y:$,rotation:O,scale:k,baseSize:R,zIndex:Y})}return n}calculateSpiralTangent(t,i,e){let n;if(e.spiralType==="golden")n=t+Math.PI/2;else if(e.spiralType==="archimedean"){const r=1/e.tightness,a=Math.atan(i/r);n=t+a}else{const r=.15/e.tightness,a=Math.atan(1/r);n=t+a}return n*180/Math.PI%360-90}calculateGoldenRadius(t,i,e,n){const r=e/Math.sqrt(i)*Math.sqrt(t)/n;return Math.min(r,e)}calculateArchimedeanRadius(t,i,e,n){const s=i*.5*n;return t/s*e}calculateLogarithmicRadius(t,i,e,n){const s=e*.05,r=.15/n,a=s*Math.exp(r*t),c=i*.3*n,l=s*Math.exp(r*c);return a/l*e}random(t,i){return Math.random()*(i-t)+t}}const ze={clusterCount:"auto",clusterSpread:150,clusterSpacing:200,density:"uniform",overlap:.3,distribution:"gaussian"};class Bt{constructor(t,i={}){this.config=t,this.imageConfig=i}generate(t,i,e={}){const n=[],{width:s,height:r}=i,a={...ze,...this.config.cluster},c=this.config.spacing.padding,l=e.fixedHeight??200,u=this.imageConfig.rotation?.mode??"none",h=this.imageConfig.rotation?.range?.min??-15,d=this.imageConfig.rotation?.range?.max??15,g=this.imageConfig.sizing?.variance?.min??1,b=this.imageConfig.sizing?.variance?.max??1,p=g!==1||b!==1,f=this.calculateClusterCount(t,a.clusterCount,s,r,a.clusterSpacing),m=this.generateClusterCenters(f,s,r,c,a),y=new Array(f).fill(0);for(let v=0;v<t;v++)y[v%f]++;let E=0;for(let v=0;v<f;v++){const I=m[v],w=y[v];for(let C=0;C<w;C++){let z,F;if(a.distribution==="gaussian")z=this.gaussianRandom()*I.spread,F=this.gaussianRandom()*I.spread;else{const O=this.random(0,Math.PI*2),Y=this.random(0,I.spread);z=Math.cos(O)*Y,F=Math.sin(O)*Y}const U=1+a.overlap*.5,D=1+a.overlap*.3;z/=U,F/=U;const N=p?this.random(g,b):1,k=D*N,R=l*k;let P=I.x+z,G=I.y+F;const M=R*1.5/2,T=R/2;P=Math.max(c+M,Math.min(P,s-c-M)),G=Math.max(c+T,Math.min(G,r-c-T));const B=u==="random"?this.random(h,d):0,L=Math.sqrt(z*z+F*F)/I.spread,$=Math.round((1-L)*50)+1;n.push({id:E,x:P,y:G,rotation:B,scale:k,baseSize:R,zIndex:$}),E++}}return n}calculateClusterCount(t,i,e,n,s){if(i!=="auto")return Math.max(1,Math.min(i,t));const a=Math.max(1,Math.ceil(t/8)),c=Math.floor(e/s*(n/s)*.6);return Math.max(1,Math.min(a,c,10))}generateClusterCenters(t,i,e,n,s){const r=[],c=n+s.clusterSpread,l=i-n-s.clusterSpread,u=n+s.clusterSpread,h=e-n-s.clusterSpread;for(let d=0;d<t;d++){let g=null,b=-1;for(let p=0;p<100;p++){const f={x:this.random(c,l),y:this.random(u,h),spread:this.calculateClusterSpread(s)};let m=1/0;for(const y of r){const E=f.x-y.x,v=f.y-y.y,I=Math.sqrt(E*E+v*v);m=Math.min(m,I)}if((r.length===0||m>b)&&(g=f,b=m),m>=s.clusterSpacing)break}g&&r.push(g)}return r}calculateClusterSpread(t){return t.density==="uniform"?t.clusterSpread:t.clusterSpread*this.random(.5,1.5)}gaussianRandom(){let t=0,i=0;for(;t===0;)t=Math.random();for(;i===0;)i=Math.random();const e=Math.sqrt(-2*Math.log(t))*Math.cos(2*Math.PI*i);return Math.max(-3,Math.min(3,e))/3}random(t,i){return Math.random()*(i-t)+t}}class jt{constructor(t,i={}){this.config=t,this.imageConfig=i}generate(t,i,e={}){const n=[],{width:s,height:r}=i,a=e.fixedHeight??200,c=this.config.spacing.padding??50,l=this.imageConfig.rotation?.mode??"none",u=this.imageConfig.rotation?.range?.min??-15,h=this.imageConfig.rotation?.range?.max??15,d=this.imageConfig.sizing?.variance?.min??1,g=this.imageConfig.sizing?.variance?.max??1,b=d!==1||g!==1,p=e.fixedHeight??a,f={...oe,...this.config.wave},{rows:m,amplitude:y,frequency:E,phaseShift:v,synchronization:I}=f,w=Math.ceil(t/m),F=p*1.5/2,U=c+F,D=s-c-F,N=D-U,k=w>1?N/(w-1):0,R=c+y+p/2,P=r-c-y-p/2,G=P-R,H=m>1?G/(m-1):0;let M=0;for(let T=0;T<m&&M<t;T++){const B=m===1?(R+P)/2:R+T*H;let X=0;I==="offset"?X=T*v:I==="alternating"&&(X=T*Math.PI);for(let L=0;L<w&&M<t;L++){const $=w===1?(U+D)/2:U+L*k,O=this.calculateWaveY($,s,y,E,X),Y=$,_=B+O,j=b?this.random(d,g):1,V=p*j;let Z=0;l==="tangent"?Z=this.calculateRotation($,s,y,E,X):l==="random"&&(Z=this.random(u,h));const Q=V*1.5/2,St=V/2,ct=c+Q,lt=s-c-Q,It=c+St,At=r-c-St;n.push({id:M,x:Math.max(ct,Math.min(Y,lt)),y:Math.max(It,Math.min(_,At)),rotation:Z,scale:j,baseSize:V,zIndex:M+1}),M++}}return n}calculateWaveY(t,i,e,n,s){const r=t/i;return e*Math.sin(n*r*2*Math.PI+s)}calculateRotation(t,i,e,n,s){const r=t/i,a=e*n*2*Math.PI*Math.cos(n*r*2*Math.PI+s)/i;return Math.atan(a)*(180/Math.PI)}random(t,i){return Math.random()*(i-t)+t}}const bt=100,et=100/Math.sqrt(3),yt=[[et/2,0],[3*et/2,0],[2*et,50],[3*et/2,100],[et/2,100],[0,50]],De=yt[1][0]/bt,Pe=yt[2][1]/bt;function $e(o){return{colStep:De*o,rowOffset:Pe*o}}function _e(o,t,i,e,n,s){const{colStep:r}=$e(s);return{px:e+r*o,py:n+s*(t+o/2)}}const Ue=[[1,0,-1],[0,1,-1],[-1,1,0],[-1,0,1],[0,-1,1],[1,-1,0]];function He(o){if(o===0)return[[0,0,0]];const t=[];let[i,e,n]=[0,-o,o];for(const[s,r,a]of Ue)for(let c=0;c<o;c++)t.push([i,e,n]),i+=s,e+=r,n+=a;return t}class Wt{constructor(t,i={}){this.config=t}generate(t,i,e={}){const n=[],{width:s,height:r}=i,a=s/2,c=r/2,l=e.fixedHeight??200,h={...se,...this.config.honeycomb}.spacing??0,d=l+h;let g=0,b=0;for(;g<t;){const p=He(b);for(const[f,m,y]of p){if(g>=t)break;const{px:E,py:v}=_e(f,m,y,a,c,d);n.push({id:g,x:E,y:v,rotation:0,scale:1,baseSize:l,zIndex:Math.max(1,100-b)}),g++}b++}return n}}class Gt{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 Ut(this.config,this.imageConfig);case"grid":return new Nt(this.config,this.imageConfig);case"spiral":return new kt(this.config,this.imageConfig);case"cluster":return new Bt(this.config,this.imageConfig);case"wave":return new jt(this.config,this.imageConfig);case"honeycomb":return new Wt(this.config,this.imageConfig);default:return new _t(this.config,this.imageConfig)}}generateLayout(t,i,e={}){const n=this.placementLayout.generate(t,i,e);return n.forEach(s=>{this.layouts.set(s.id,s)}),n}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 i=this.getBreakpoints();return t<=i.mobile.maxWidth?"mobile":t<=i.tablet.maxWidth?"tablet":"screen"}resolveBaseHeight(t){const i=this.imageConfig.sizing;if(!i||i.mode==="adaptive")return;const e=i.height;if(e===void 0)return;if(typeof e=="number")return e;const n=e,s=this.resolveBreakpoint(t);return s==="mobile"?n.mobile??n.tablet??n.screen:s==="tablet"?n.tablet??n.screen??n.mobile:n.screen??n.tablet??n.mobile}calculateAdaptiveSize(t,i,e,n){const s=this.imageConfig.sizing,r=this.resolveBaseHeight(n);if(r!==void 0)return{height:r};const a=s?.minSize??50,c=s?.maxSize??400,l=this.config.targetCoverage??.6,u=this.config.densityFactor??1,{width:h,height:d}=t,p=h*d*l/i;let m=Math.sqrt(p/1.4);m*=u,m=Math.min(m,e);let y=this.clamp(m,a,c);if(y===a&&m<a){const E=Math.max(a*.05,20);y=Math.max(E,m)}return this.config.algorithm==="honeycomb"&&(y=Math.min(y,this.honeycombMaxImageHeight(i,t))),{height:y}}honeycombMaxImageHeight(t,i){if(t<=1)return 1/0;let e=0,n=1;for(;n<t;)e++,n+=6*e;const s=this.config.spacing?.padding??50,r=this.config.honeycomb?.spacing??0,a=i.width/2,c=i.height/2,l=Math.sqrt(3)/2,u=1/Math.sqrt(3),h=(c-s-r*e)/(e+.5),d=(a-s-l*r*e)/(l*e+u);return Math.max(10,Math.min(h,d))}clamp(t,i,e){return Math.max(i,Math.min(e,t))}}var x=(o=>(o.IDLE="idle",o.FOCUSING="focusing",o.FOCUSED="focused",o.UNFOCUSING="unfocusing",o.CROSS_ANIMATING="cross_animating",o))(x||{});const qt={circle:"circle(50%)",square:"polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)",triangle:"polygon(50% 0%, 100% 100%, 0% 100%)",pentagon:"polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%)",hexagon:"polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%)",octagon:"polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%)",diamond:"polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%)"},Ne={circle:{refHeight:100,points:[]},square:{refHeight:100,points:[[0,0],[100,0],[100,100],[0,100]]},triangle:{refHeight:100,points:[[50,0],[100,100],[0,100]]},pentagon:{refHeight:100,points:[[50,0],[100,38],[82,100],[18,100],[0,38]]},hexagon:{refHeight:bt,points:yt},octagon:{refHeight:100,points:[[30,0],[70,0],[100,30],[100,70],[70,100],[30,100],[0,70],[0,30]]},diamond:{refHeight:100,points:[[50,0],[100,50],[50,100],[0,50]]}};function ke(o){if(o)return o in qt?qt[o]:o}function Be(o,t,i){const e=Ne[o];if(!e)return"";const n=t/e.refHeight;if(o==="circle")return`circle(${Math.round(50*n*100)/100}px)`;const s=e.points.map(([p])=>p),r=e.points.map(([,p])=>p),a=(Math.min(...s)+Math.max(...s))/2*n,c=(Math.min(...r)+Math.max(...r))/2*n,l=(Math.max(...s)-Math.min(...s))*n,u=(i??l)/2,h=t/2,d=u-a,g=h-c;return`polygon(${e.points.map(([p,f])=>{const m=Math.round((p*n+d)*100)/100,y=Math.round((f*n+g)*100)/100;return`${m}px ${y}px`}).join(", ")})`}function je(o){return o in J}function We(o){return o?je(o)?J[o]:o:J.md}function Ge(o){if(!o)return"";const t=[];if(o.grayscale!==void 0&&t.push(`grayscale(${o.grayscale})`),o.blur!==void 0&&t.push(`blur(${o.blur}px)`),o.brightness!==void 0&&t.push(`brightness(${o.brightness})`),o.contrast!==void 0&&t.push(`contrast(${o.contrast})`),o.saturate!==void 0&&t.push(`saturate(${o.saturate})`),o.opacity!==void 0&&t.push(`opacity(${o.opacity})`),o.sepia!==void 0&&t.push(`sepia(${o.sepia})`),o.hueRotate!==void 0&&t.push(`hue-rotate(${o.hueRotate}deg)`),o.invert!==void 0&&t.push(`invert(${o.invert})`),o.dropShadow!==void 0)if(typeof o.dropShadow=="string")t.push(`drop-shadow(${o.dropShadow})`);else{const i=o.dropShadow;t.push(`drop-shadow(${i.x}px ${i.y}px ${i.blur}px ${i.color})`)}return t.join(" ")}function it(o){if(!o||o.style==="none"||o.width===0)return"none";const t=o.width??0,i=o.style??"solid",e=o.color??"#000000";return`${t}px ${i} ${e}`}function nt(o,t,i){if(!o)return{};const e={};if(o.borderRadiusTopLeft!==void 0||o.borderRadiusTopRight!==void 0||o.borderRadiusBottomRight!==void 0||o.borderRadiusBottomLeft!==void 0){const a=o.border?.radius??0;o.borderRadiusTopLeft!==void 0?e.borderTopLeftRadius=`${o.borderRadiusTopLeft}px`:a&&(e.borderTopLeftRadius=`${a}px`),o.borderRadiusTopRight!==void 0?e.borderTopRightRadius=`${o.borderRadiusTopRight}px`:a&&(e.borderTopRightRadius=`${a}px`),o.borderRadiusBottomRight!==void 0?e.borderBottomRightRadius=`${o.borderRadiusBottomRight}px`:a&&(e.borderBottomRightRadius=`${a}px`),o.borderRadiusBottomLeft!==void 0?e.borderBottomLeftRadius=`${o.borderRadiusBottomLeft}px`:a&&(e.borderBottomLeftRadius=`${a}px`)}else o.border?.radius!==void 0&&(e.borderRadius=`${o.border.radius}px`);if(o.borderTop||o.borderRight||o.borderBottom||o.borderLeft){const a=o.border||{},c={...a,...o.borderTop},l={...a,...o.borderRight},u={...a,...o.borderBottom},h={...a,...o.borderLeft};e.borderTop=it(c),e.borderRight=it(l),e.borderBottom=it(u),e.borderLeft=it(h)}else o.border&&(e.border=it(o.border));o.shadow!==void 0&&(e.boxShadow=We(o.shadow));const r=Ge(o.filter);if(e.filter=r||"none",o.opacity!==void 0&&(e.opacity=String(o.opacity)),o.cursor!==void 0&&(e.cursor=o.cursor),o.outline&&o.outline.style!=="none"&&(o.outline.width??0)>0){const a=o.outline.width??0,c=o.outline.style??"solid",l=o.outline.color??"#000000";e.outline=`${a}px ${c} ${l}`,o.outline.offset!==void 0&&(e.outlineOffset=`${o.outline.offset}px`)}if(o.objectFit!==void 0&&(e.objectFit=o.objectFit),o.aspectRatio!==void 0&&(e.aspectRatio=o.aspectRatio),o.clipPath!==void 0){let a;const c=typeof o.clipPath=="object"&&o.clipPath!==null&&"shape"in o.clipPath,l=c?o.clipPath:void 0;if(l?.mode==="height-relative"&&t)a=Be(l.shape,t,i);else{const u=c&&l?l.shape:o.clipPath;a=ke(u)}a&&(a==="none"?e.clipPath="unset":(e.clipPath=a,e.overflow="hidden"))}return e}function qe(o,t){t.borderRadius!==void 0&&(o.style.borderRadius=t.borderRadius),t.borderTopLeftRadius!==void 0&&(o.style.borderTopLeftRadius=t.borderTopLeftRadius),t.borderTopRightRadius!==void 0&&(o.style.borderTopRightRadius=t.borderTopRightRadius),t.borderBottomRightRadius!==void 0&&(o.style.borderBottomRightRadius=t.borderBottomRightRadius),t.borderBottomLeftRadius!==void 0&&(o.style.borderBottomLeftRadius=t.borderBottomLeftRadius),t.border!==void 0&&(o.style.border=t.border),t.borderTop!==void 0&&(o.style.borderTop=t.borderTop),t.borderRight!==void 0&&(o.style.borderRight=t.borderRight),t.borderBottom!==void 0&&(o.style.borderBottom=t.borderBottom),t.borderLeft!==void 0&&(o.style.borderLeft=t.borderLeft),t.boxShadow!==void 0&&(o.style.boxShadow=t.boxShadow),t.filter!==void 0&&(o.style.filter=t.filter),t.opacity!==void 0&&(o.style.opacity=t.opacity),t.cursor!==void 0&&(o.style.cursor=t.cursor),t.outline!==void 0&&(o.style.outline=t.outline),t.outlineOffset!==void 0&&(o.style.outlineOffset=t.outlineOffset),t.objectFit!==void 0&&(o.style.objectFit=t.objectFit),t.aspectRatio!==void 0&&(o.style.aspectRatio=t.aspectRatio),t.clipPath!==void 0&&(o.style.clipPath=t.clipPath),t.overflow!==void 0&&(o.style.overflow=t.overflow)}function at(o,t,i,e){const n=nt(t,i,e);qe(o,n)}function Xt(o){return o?Array.isArray(o)?o.join(" "):o:""}function ot(o,t){const i=Xt(t);i&&i.split(" ").forEach(e=>{e.trim()&&o.classList.add(e.trim())})}function vt(o,t){const i=Xt(t);i&&i.split(" ").forEach(e=>{e.trim()&&o.classList.remove(e.trim())})}const Yt={UNFOCUSING:999,FOCUSING:1e3};class Vt{constructor(t,i,e){this.state=x.IDLE,this.currentFocus=null,this.focusData=null,this.outgoing=null,this.incoming=null,this.focusGeneration=0,this.onUnfocusComplete=null,this.config=t,this.animationEngine=i,this.styling=e,this.focusedClassName=e?.focused?.className}setOnUnfocusCompleteCallback(t){this.onUnfocusComplete=t}getState(){return this.state}isAnimating(){return this.state!==x.IDLE&&this.state!==x.FOCUSED}normalizeScalePercent(t){return t>1?t/100:t}calculateFocusDimensions(t,i,e){const n=this.normalizeScalePercent(this.config.scalePercent),s=e.height*n,r=t/i;let a=s,c=a*r;const l=e.width*n;return c>l&&(c=l,a=c/r),{width:c,height:a}}calculateFocusTransform(t,i){const e=t.width/2,n=t.height/2,s=e-i.x,r=n-i.y;return{x:s,y:r,rotation:0,scale:1}}buildDimensionZoomTransform(t){const i=["translate(-50%, -50%)"];if(t.x!==void 0||t.y!==void 0){const e=t.x??0,n=t.y??0;i.push(`translate(${e}px, ${n}px)`)}return t.rotation!==void 0&&i.push(`rotate(${t.rotation}deg)`),i.join(" ")}animateWithDimensions(t,i,e,n,s,r,a,c){const l=this.buildDimensionZoomTransform(i),u=this.buildDimensionZoomTransform(e);return t.style.transition="none",t.animate([{transform:l,width:`${n}px`,height:`${s}px`},{transform:u,width:`${r}px`,height:`${a}px`}],{duration:c,easing:"cubic-bezier(0.4, 0, 0.2, 1)",fill:"forwards"})}applyFocusedStyling(t,i){if(t.style.zIndex=String(i),t.classList.add("fbn-ic-focused"),ot(t,this.focusedClassName),this.styling?.focused){const e=nt(this.styling.focused,t.offsetHeight,t.offsetWidth);e.borderRadius!==void 0&&(t.style.borderRadius=e.borderRadius),e.borderTopLeftRadius!==void 0&&(t.style.borderTopLeftRadius=e.borderTopLeftRadius),e.borderTopRightRadius!==void 0&&(t.style.borderTopRightRadius=e.borderTopRightRadius),e.borderBottomRightRadius!==void 0&&(t.style.borderBottomRightRadius=e.borderBottomRightRadius),e.borderBottomLeftRadius!==void 0&&(t.style.borderBottomLeftRadius=e.borderBottomLeftRadius),e.border!==void 0&&(t.style.border=e.border),e.borderTop!==void 0&&(t.style.borderTop=e.borderTop),e.borderRight!==void 0&&(t.style.borderRight=e.borderRight),e.borderBottom!==void 0&&(t.style.borderBottom=e.borderBottom),e.borderLeft!==void 0&&(t.style.borderLeft=e.borderLeft),e.boxShadow!==void 0&&(t.style.boxShadow=e.boxShadow),e.filter!==void 0&&(t.style.filter=e.filter),e.opacity!==void 0&&(t.style.opacity=e.opacity),e.cursor!==void 0&&(t.style.cursor=e.cursor),e.outline!==void 0&&(t.style.outline=e.outline),e.outlineOffset!==void 0&&(t.style.outlineOffset=e.outlineOffset),e.objectFit!==void 0&&(t.style.objectFit=e.objectFit),e.aspectRatio!==void 0&&(t.style.aspectRatio=e.aspectRatio)}}removeFocusedStyling(t,i){if(t.style.zIndex=i,t.classList.remove("fbn-ic-focused"),vt(t,this.focusedClassName),this.styling?.default){const e=nt(this.styling.default,t.offsetHeight,t.offsetWidth);e.borderRadius!==void 0&&(t.style.borderRadius=e.borderRadius),e.borderTopLeftRadius!==void 0&&(t.style.borderTopLeftRadius=e.borderTopLeftRadius),e.borderTopRightRadius!==void 0&&(t.style.borderTopRightRadius=e.borderTopRightRadius),e.borderBottomRightRadius!==void 0&&(t.style.borderBottomRightRadius=e.borderBottomRightRadius),e.borderBottomLeftRadius!==void 0&&(t.style.borderBottomLeftRadius=e.borderBottomLeftRadius),e.border!==void 0&&(t.style.border=e.border),e.borderTop!==void 0&&(t.style.borderTop=e.borderTop),e.borderRight!==void 0&&(t.style.borderRight=e.borderRight),e.borderBottom!==void 0&&(t.style.borderBottom=e.borderBottom),e.borderLeft!==void 0&&(t.style.borderLeft=e.borderLeft),e.boxShadow!==void 0&&(t.style.boxShadow=e.boxShadow),e.filter!==void 0&&(t.style.filter=e.filter),e.opacity!==void 0&&(t.style.opacity=e.opacity),e.cursor!==void 0&&(t.style.cursor=e.cursor),e.outline!==void 0&&(t.style.outline=e.outline),e.outlineOffset!==void 0&&(t.style.outlineOffset=e.outlineOffset),e.objectFit!==void 0&&(t.style.objectFit=e.objectFit),e.aspectRatio!==void 0&&(t.style.aspectRatio=e.aspectRatio)}}startClipPathAnimation(t,i,e){let n=e?this.styling?.focused??this.styling?.default:this.styling?.default;e&&this.styling?.focused&&this.styling.focused.clipPath===void 0&&(n={...n,clipPath:void 0});const s=()=>{const r=t.offsetHeight,a=t.offsetWidth,c=nt(n,r,a);c.clipPath!==void 0?t.style.clipPath=c.clipPath:t.style.clipPath="unset",c.overflow!==void 0&&(t.style.overflow=c.overflow),i.animation.playState==="running"&&requestAnimationFrame(s)};requestAnimationFrame(s)}startFocusAnimation(t,i,e,n,s){const r=t.style.zIndex||"",a=t.offsetWidth,c=t.offsetHeight,l=this.calculateFocusDimensions(a,c,i),u=this.calculateFocusTransform(i,e);this.animationEngine.cancelAllAnimations(t);const h=this.config.animationDuration??600;this.applyFocusedStyling(t,Yt.FOCUSING);const d=n??{x:0,y:0,rotation:e.rotation,scale:1},g=s?.width??a,b=s?.height??c,p=this.animateWithDimensions(t,d,u,g,b,l.width,l.height,h),f={id:`focus-${Date.now()}`,element:t,animation:p,fromState:d,toState:u,startTime:performance.now(),duration:h};return this.focusData={element:t,originalState:e,focusTransform:u,originalZIndex:r,originalWidth:a,originalHeight:c,focusWidth:l.width,focusHeight:l.height},this.startClipPathAnimation(t,f,!0),{element:t,originalState:e,animationHandle:f,direction:"in",originalWidth:a,originalHeight:c}}startUnfocusAnimation(t,i,e,n){t.style.zIndex=String(Yt.UNFOCUSING),this.animationEngine.cancelAllAnimations(t);const s=this.config.animationDuration??600;t.classList.remove("fbn-ic-focused"),vt(t,this.focusedClassName);const r=e??this.focusData?.focusTransform??{x:0,y:0,rotation:0,scale:1},a=n?.width??this.focusData?.focusWidth??t.offsetWidth,c=n?.height??this.focusData?.focusHeight??t.offsetHeight,l={x:0,y:0,rotation:i.rotation,scale:1},u=this.focusData?.originalWidth??t.offsetWidth,h=this.focusData?.originalHeight??t.offsetHeight,d=this.animateWithDimensions(t,r,l,a,c,u,h,s),g={id:`unfocus-${Date.now()}`,element:t,animation:d,fromState:r,toState:l,startTime:performance.now(),duration:s};return this.startClipPathAnimation(t,g,!1),{element:t,originalState:i,animationHandle:g,direction:"out",originalWidth:u,originalHeight:h}}captureMidAnimationState(t){const i=getComputedStyle(t),e=new DOMMatrix(i.transform),n=t.offsetWidth,s=t.offsetHeight,r=e.e+n*.5,a=e.f+s*.5,c=Math.atan2(e.b,e.a)*(180/Math.PI);return t.style.width=`${n}px`,t.style.height=`${s}px`,t.style.transform=`translate(-50%, -50%) translate(${r}px, ${a}px) rotate(${c}deg)`,t.style.transition="none",{transform:{x:r,y:a,rotation:c,scale:1},dimensions:{width:n,height:s}}}async waitForAnimation(t){try{await t.animation.finished}catch{}}resetElementInstantly(t,i,e,n,s){this.animationEngine.cancelAllAnimations(t);const r=["translate(-50%, -50%)"];r.push("translate(0px, 0px)"),r.push(`rotate(${i.rotation}deg)`),t.style.transition="none",t.style.transform=r.join(" "),n!==void 0&&s!==void 0&&(t.style.width=`${n}px`,t.style.height=`${s}px`),this.removeFocusedStyling(t,e)}async focusImage(t,i,e){if(this.currentFocus===t&&this.state===x.FOCUSED)return this.unfocusImage();if(this.incoming?.element===t&&this.state===x.FOCUSING){const{transform:s,dimensions:r}=this.captureMidAnimationState(t);this.animationEngine.cancelAllAnimations(t),this.outgoing=this.startUnfocusAnimation(t,this.incoming.originalState,s,r),this.incoming=null,this.state=x.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=x.IDLE;return}const n=++this.focusGeneration;switch(this.state){case x.IDLE:if(this.state=x.FOCUSING,this.incoming=this.startFocusAnimation(t,i,e),await this.waitForAnimation(this.incoming.animationHandle),this.focusGeneration!==n)return;this.currentFocus=t,this.incoming=null,this.state=x.FOCUSED;break;case x.FOCUSED:if(this.state=x.CROSS_ANIMATING,this.currentFocus&&this.focusData&&(this.outgoing=this.startUnfocusAnimation(this.currentFocus,this.focusData.originalState)),this.incoming=this.startFocusAnimation(t,i,e),await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(this.incoming.animationHandle)]),this.focusGeneration!==n)return;if(this.outgoing){const s=this.outgoing.element;this.removeFocusedStyling(s,this.outgoing.originalState.zIndex?.toString()||""),this.outgoing=null,this.onUnfocusComplete?.(s)}this.currentFocus=t,this.incoming=null,this.state=x.FOCUSED;break;case x.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,i,e),await this.waitForAnimation(this.incoming.animationHandle),this.focusGeneration!==n)return;this.currentFocus=t,this.incoming=null,this.state=x.FOCUSED;break;case x.UNFOCUSING:if(this.state=x.CROSS_ANIMATING,this.incoming=this.startFocusAnimation(t,i,e),await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(this.incoming.animationHandle)]),this.focusGeneration!==n)return;if(this.outgoing){const s=this.outgoing.element;this.removeFocusedStyling(s,this.outgoing.originalState.zIndex?.toString()||""),this.outgoing=null,this.onUnfocusComplete?.(s)}this.currentFocus=t,this.incoming=null,this.state=x.FOCUSED;break;case x.CROSS_ANIMATING:if(this.incoming?.element===t)return;if(this.outgoing?.element===t){const{transform:s,dimensions:r}=this.captureMidAnimationState(t);if(this.animationEngine.cancelAllAnimations(t),this.incoming){const{transform:a,dimensions:c}=this.captureMidAnimationState(this.incoming.element);this.animationEngine.cancelAllAnimations(this.incoming.element),this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,a,c)}else this.outgoing=null;if(this.incoming=this.startFocusAnimation(t,i,e,s,r),await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(this.incoming.animationHandle)]),this.focusGeneration!==n)return;if(this.outgoing){const a=this.outgoing.element;this.removeFocusedStyling(a,this.outgoing.originalState.zIndex?.toString()||""),this.outgoing=null,this.onUnfocusComplete?.(a)}this.currentFocus=t,this.incoming=null,this.state=x.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{transform:s,dimensions:r}=this.captureMidAnimationState(this.incoming.element);this.animationEngine.cancelAllAnimations(this.incoming.element),this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,s,r)}if(this.incoming=this.startFocusAnimation(t,i,e),await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(this.incoming.animationHandle)]),this.focusGeneration!==n)return;if(this.outgoing){const s=this.outgoing.element;this.removeFocusedStyling(s,this.outgoing.originalState.zIndex?.toString()||""),this.outgoing=null,this.onUnfocusComplete?.(s)}this.currentFocus=t,this.incoming=null,this.state=x.FOCUSED;break}}async unfocusImage(){if(this.state===x.UNFOCUSING)return;const t=++this.focusGeneration;if(!this.currentFocus||!this.focusData){if(this.incoming&&this.state===x.FOCUSING){const{transform:s,dimensions:r}=this.captureMidAnimationState(this.incoming.element);if(this.animationEngine.cancelAllAnimations(this.incoming.element),this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,s,r),this.incoming=null,this.state=x.UNFOCUSING,await this.waitForAnimation(this.outgoing.animationHandle),this.focusGeneration!==t)return;const a=this.outgoing.element;this.removeFocusedStyling(a,this.focusData?.originalZIndex||""),this.outgoing=null,this.focusData=null,this.state=x.IDLE,this.onUnfocusComplete?.(a)}return}if(this.state===x.CROSS_ANIMATING&&this.incoming){const{transform:s,dimensions:r}=this.captureMidAnimationState(this.incoming.element);this.animationEngine.cancelAllAnimations(this.incoming.element);const a=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,s,r);if(await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(a.animationHandle)]),this.focusGeneration!==t)return;let c=null;this.outgoing&&(c=this.outgoing.element,this.removeFocusedStyling(c,this.outgoing.originalState.zIndex?.toString()||""));const l=a.element;this.removeFocusedStyling(l,this.incoming.originalState.zIndex?.toString()||""),this.outgoing=null,this.incoming=null,this.currentFocus=null,this.focusData=null,this.state=x.IDLE,c&&this.onUnfocusComplete?.(c),this.onUnfocusComplete?.(l);return}this.state=x.UNFOCUSING;const i=this.currentFocus,e=this.focusData.originalState,n=this.focusData.originalZIndex;this.outgoing=this.startUnfocusAnimation(i,e),await this.waitForAnimation(this.outgoing.animationHandle),this.focusGeneration===t&&(this.removeFocusedStyling(i,n),this.outgoing=null,this.currentFocus=null,this.focusData=null,this.state=x.IDLE,this.onUnfocusComplete?.(i))}async swapFocus(t,i,e){return this.focusImage(t,i,e)}getCurrentFocus(){return this.currentFocus}isFocused(t){return this.currentFocus===t&&this.state===x.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!==x.FOCUSED)return;const i=this.currentFocus,e=this.focusData.focusTransform,n=["translate(-50%, -50%)"],s=(e.x??0)+t,r=e.y??0;n.push(`translate(${s}px, ${r}px)`),e.rotation!==void 0&&n.push(`rotate(${e.rotation}deg)`),i.style.transition="none",i.style.transform=n.join(" ")}clearDragOffset(t,i=150){if(!this.currentFocus||!this.focusData||this.state!==x.FOCUSED)return;const e=this.currentFocus,n=this.focusData.focusTransform,s=["translate(-50%, -50%)"],r=n.x??0,a=n.y??0;s.push(`translate(${r}px, ${a}px)`),n.rotation!==void 0&&s.push(`rotate(${n.rotation}deg)`);const c=s.join(" ");t?(e.style.transition=`transform ${i}ms ease-out`,e.style.transform=c,setTimeout(()=>{this.currentFocus===e&&(e.style.transition="none")},i)):(e.style.transition="none",e.style.transform=c)}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=x.IDLE,this.currentFocus=null,this.focusData=null,this.outgoing=null,this.incoming=null}}const Xe=50,Ye=.5,Ve=20,Je=.3,Ke=150,Ze=30,rt=class rt{constructor(t,i){this.enabled=!1,this.touchState=null,this.recentTouchTimestamp=0,this.container=t,this.callbacks=i,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<rt.TOUCH_CLICK_DELAY}handleTouchStart(t){if(t.touches.length!==1)return;this.recentTouchTimestamp=Date.now();const i=t.touches[0];this.touchState={startX:i.clientX,startY:i.clientY,startTime:performance.now(),currentX:i.clientX,isDragging:!1,isHorizontalSwipe:null}}handleTouchMove(t){if(!this.touchState||t.touches.length!==1)return;const i=t.touches[0],e=i.clientX-this.touchState.startX,n=i.clientY-this.touchState.startY;if(this.touchState.isHorizontalSwipe===null&&Math.sqrt(e*e+n*n)>10){const a=Math.atan2(Math.abs(n),Math.abs(e))*(180/Math.PI);this.touchState.isHorizontalSwipe=a<=Ze}if(this.touchState.isHorizontalSwipe!==!1&&this.touchState.isHorizontalSwipe===!0){t.preventDefault(),this.touchState.isDragging=!0,this.touchState.currentX=i.clientX;const s=e*Je;this.callbacks.onDragOffset(s)}}handleTouchEnd(t){if(!this.touchState)return;this.recentTouchTimestamp=Date.now();const i=this.touchState.currentX-this.touchState.startX,e=performance.now()-this.touchState.startTime,n=Math.abs(i)/e,s=Math.abs(i);let r=!1;this.touchState.isHorizontalSwipe===!0&&this.touchState.isDragging&&(s>=Xe||n>=Ye&&s>=Ve)&&(r=!0,i<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}};rt.TOUCH_CLICK_DELAY=300;let Et=rt;class Jt{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 i of this.sources)if("folders"in i)for(const e of i.folders){const n=i.recursive!==void 0?i.recursive:!0,s=await this.loadFromFolder(e,t,n);this._discoveredUrls.push(...s)}else if("files"in i){const e=await this.loadFiles(i.files,t);this._discoveredUrls.push(...e)}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 i=[/\/folders\/([a-zA-Z0-9_-]+)/,/id=([a-zA-Z0-9_-]+)/];for(const e of i){const n=t.match(e);if(n&&n[1])return n[1]}return null}async loadFromFolder(t,i,e=!0){const n=this.extractFolderId(t);if(!n)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(n,i);try{return e?await this.loadImagesRecursively(n,i):await this.loadImagesFromSingleFolder(n,i)}catch(s){return console.error("Error loading from Google Drive API:",s),this.loadImagesDirectly(n,i)}}async loadImagesFromSingleFolder(t,i){const e=[],n=`'${t}' in parents and trashed=false`,r=`${this.apiEndpoint}?q=${encodeURIComponent(n)}&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 l=(await a.json()).files.filter(u=>u.mimeType.startsWith("image/")&&i.isAllowed(u.name));return this.log(`Found ${l.length} images in folder ${t} (non-recursive)`),l.forEach(u=>{e.push(`https://lh3.googleusercontent.com/d/${u.id}=s1600`),this.log(`Added file: ${u.name}`)}),e}async loadFiles(t,i){const e=[];for(const n of t){const s=this.extractFileId(n);if(!s){this.log(`Skipping invalid file URL: ${n}`);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 c=await a.json();c.mimeType.startsWith("image/")&&i.isAllowed(c.name)?(e.push(`https://lh3.googleusercontent.com/d/${s}=s1600`),this.log(`Added file: ${c.name}`)):this.log(`Skipping non-image file: ${c.name} (${c.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 e.push(`https://lh3.googleusercontent.com/d/${s}=s1600`)}return e}extractFileId(t){if(!/[/:.]/.test(t))return t;const i=[/\/file\/d\/([a-zA-Z0-9_-]+)/,/\/open\?id=([a-zA-Z0-9_-]+)/,/id=([a-zA-Z0-9_-]+)/];for(const e of i){const n=t.match(e);if(n&&n[1])return n[1]}return null}async loadImagesRecursively(t,i){const e=[],n=`'${t}' in parents and trashed=false`,r=`${this.apiEndpoint}?q=${encodeURIComponent(n)}&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(),l=c.files.filter(h=>h.mimeType.startsWith("image/")&&i.isAllowed(h.name)),u=c.files.filter(h=>h.mimeType==="application/vnd.google-apps.folder");this.log(`Found ${c.files.length} total items in folder ${t}`),c.files.forEach(h=>this.log(` - File: ${h.name} (${h.mimeType})`)),this.log(`- ${l.length} valid files (images only)`),this.log(`- ${u.length} subfolders`),l.forEach(h=>{e.push(`https://lh3.googleusercontent.com/d/${h.id}=s1600`),this.log(`Added file: ${h.name}`)});for(const h of u){this.log(`Loading images from subfolder: ${h.name}`);const d=await this.loadImagesRecursively(h.id,i);e.push(...d)}return e}async loadImagesDirectly(t,i){try{const e=`https://drive.google.com/embeddedfolderview?id=${t}`,n=await fetch(e,{mode:"cors"});if(!n.ok)throw new Error("Cannot access folder directly (CORS or permissions issue)");const s=await n.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(e){throw console.error("Direct loading failed:",e),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
|
-
3. Consider adding a Google Drive API key in config.js for better reliability`)}}manualImageUrls(t){return t.map(i=>`https://drive.google.com/uc?export=view&id=${i}`)}log(...t){this.debugLogging&&typeof console<"u"&&console.log(...t)}}class
|
|
4
|
+
3. Consider adding a Google Drive API key in config.js for better reliability`)}}manualImageUrls(t){return t.map(i=>`https://drive.google.com/uc?export=view&id=${i}`)}log(...t){this.debugLogging&&typeof console<"u"&&console.log(...t)}}class Kt{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 i of this.sources)try{const e=await this.processSource(i,t);this._discoveredUrls.push(...e)}catch(e){console.warn("Failed to process source:",i,e)}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,i){return t?"urls"in t?await this.processUrls(t.urls,i):"path"in t?await this.processPath(t.path,t.files,i):"json"in t?await this.processJson(t.json,i):(console.warn("Unknown source shape:",t),[]):(console.warn("Invalid source object:",t),[])}async processUrls(t,i){if(!Array.isArray(t))return console.warn("URLs must be an array:",t),[];const e=[];for(const n of t){const s=n.split("/").pop()||n;if(!i.isAllowed(s)){this.log(`Skipping filtered URL: ${n}`);continue}this.validateUrls?await this.validateUrl(n)?e.push(n):console.warn(`Skipping invalid/missing URL: ${n}`):e.push(n)}return e}async processPath(t,i,e){if(!Array.isArray(i))return console.warn("files must be an array:",i),[];const n=[];for(const s of i){if(!e.isAllowed(s)){this.log(`Skipping filtered file: ${s}`);continue}const r=this.constructUrl(t,s);this.validateUrls?await this.validateUrl(r)?n.push(r):console.warn(`Skipping invalid/missing file: ${r}`):n.push(r)}return n}async processJson(t,i){this.log(`Fetching JSON endpoint: ${t}`);const e=new AbortController,n=setTimeout(()=>e.abort(),1e4);try{const s=await fetch(t,{signal:e.signal});if(clearTimeout(n),!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,i)}catch(s){throw clearTimeout(n),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 e=new AbortController,n=setTimeout(()=>e.abort(),this.validationTimeout),s=await fetch(t,{method:"HEAD",signal:e.signal});return clearTimeout(n),s.ok?!0:(this.log(`Validation failed for ${t}: HTTP ${s.status}`),!1)}catch(e){return e instanceof Error&&(e.name==="AbortError"?this.log(`Validation timeout for ${t}`):this.log(`Validation failed for ${t}:`,e.message)),!1}}constructUrl(t,i){const e=t.replace(/\/$/,"");if(this.isAbsoluteUrl(t))return`${e}/${i}`;if(typeof window>"u")return`${e}/${i}`;const n=window.location.origin,r=(t.startsWith("/")?t:"/"+t).replace(/\/$/,"");return`${n}${r}/${i}`}isAbsoluteUrl(t){try{return new URL(t),!0}catch{return!1}}log(...t){this.debugLogging&&typeof console<"u"&&console.log(...t)}}class Zt{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 i=this.loaders.map((e,n)=>e.prepare(t).then(()=>{this.log(`Loader ${n} prepared with ${e.imagesLength()} images`)}).catch(s=>{console.warn(`Loader ${n} failed to prepare:`,s)}));await Promise.all(i);for(const e of this.loaders)if(e.isPrepared()){const n=e.imageURLs();this._discoveredUrls.push(...n)}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 Qt{constructor(t){this.allowedExtensions=t||["jpg","jpeg","png","gif","webp","bmp"]}isAllowed(t){const e=t.split("?")[0].split(".").pop()?.toLowerCase();return e?this.allowedExtensions.includes(e):!1}getAllowedExtensions(){return[...this.allowedExtensions]}}const te=`
|
|
5
5
|
.fbn-ic-gallery {
|
|
6
6
|
position: relative;
|
|
7
7
|
width: 100%;
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
.fbn-ic-hidden {
|
|
82
82
|
display: none !important;
|
|
83
83
|
}
|
|
84
|
-
`;function te(){if(typeof document>"u")return;const o="fbn-ic-functional-styles";if(document.getElementById(o))return;const t=document.createElement("style");t.id=o,t.textContent=Qt,document.head.appendChild(t)}class ee{constructor(t={}){this.fullConfig=be(t),t.container instanceof HTMLElement?(this.containerRef=t.container,this.containerId=null):(this.containerRef=null,this.containerId=t.container||"imageCloud"),this.imagesLoaded=!1,this.imageElements=[],this.imageLayouts=[],this.currentImageHeight=225,this.currentFocusIndex=null,this.hoveredImage=null,this.resizeTimeout=null,this.displayQueue=[],this.queueInterval=null,this.loadGeneration=0,this.loadingElAutoCreated=!1,this.errorElAutoCreated=!1,this.counterEl=null,this.counterElAutoCreated=!1,this.prevButtonEl=null,this.nextButtonEl=null,this.prevButtonElAutoCreated=!1,this.nextButtonElAutoCreated=!1,this.animationEngine=new Ot(this.fullConfig.animation),this.layoutEngine=new Wt({layout:this.fullConfig.layout,image:this.fullConfig.image}),this.zoomEngine=new Yt(this.fullConfig.interaction.focus,this.animationEngine,this.fullConfig.styling),this.defaultStyles=nt(this.fullConfig.styling?.default),this.defaultClassName=this.fullConfig.styling?.default?.className,this.hoverClassName=this.fullConfig.styling?.hover?.className;const i=this.fullConfig.animation.entry||A.animation.entry;this.entryAnimationEngine=new Pt(i,this.fullConfig.layout.algorithm);const e=this.fullConfig.animation.idle;e&&e.type!=="none"?this.idleAnimationEngine=new Le(e,i.timing?.duration??600):this.idleAnimationEngine=null,this.zoomEngine.setOnUnfocusCompleteCallback(n=>{this.idleAnimationEngine?.resumeForImage(n);const s=n;requestAnimationFrame(()=>{if(s.matches(":hover")&&this.fullConfig.styling?.hover){const r=this.imageElements.indexOf(s);if(r!==-1){const a=s.offsetHeight,c=s.cachedRenderedWidth;at(s,this.fullConfig.styling.hover,a,c),ot(s,this.hoverClassName),this.hoveredImage={element:s,layout:this.imageLayouts[r]}}}})}),this.swipeEngine=null,this.imageFilter=this.createImageFilter(),this.imageLoader=this.createLoader(),this.containerEl=null,this.loadingEl=null,this.errorEl=null}createImageFilter(){const t=this.fullConfig.config.loaders?.allowedExtensions;return new Zt(t)}createLoader(){const t=this.fullConfig.loaders,i=this.fullConfig.config.loaders??{};if(!t||t.length===0)throw new Error("No loaders configured. Provide `images`, `loaders`, or both.");const e=t.map(n=>this.createLoaderFromEntry(n,i));return e.length===1?e[0]:new Kt({loaders:e,debugLogging:this.fullConfig.config.debug?.loaders})}createLoaderFromEntry(t,i){if("static"in t){const e=t.static,n={...e,validateUrls:e.validateUrls??i.validateUrls,validationTimeout:e.validationTimeout??i.validationTimeout,validationMethod:e.validationMethod??i.validationMethod,allowedExtensions:e.allowedExtensions??i.allowedExtensions,debugLogging:e.debugLogging??this.fullConfig.config.debug?.loaders};return new Jt(n)}else if("googleDrive"in t){const e=t.googleDrive,n={...e,allowedExtensions:e.allowedExtensions??i.allowedExtensions,debugLogging:e.debugLogging??this.fullConfig.config.debug?.loaders};return new Vt(n)}else throw new Error(`Unknown loader entry: ${JSON.stringify(t)}`)}async init(){try{if(te(),this.containerRef)this.containerEl=this.containerRef;else if(this.containerEl=document.getElementById(this.containerId),!this.containerEl)throw new Error(`Container #${this.containerId} not found`);this.containerEl.classList.add("fbn-ic-gallery"),this.containerEl.setAttribute("tabindex","0"),this.fullConfig.interaction.navigation?.swipe!==!1&&(this.swipeEngine=new Et(this.containerEl,{onNext:()=>this.navigateToNextImage(),onPrev:()=>this.navigateToPreviousImage(),onDragOffset:t=>this.zoomEngine.setDragOffset(t),onDragEnd:t=>{t?this.zoomEngine.clearDragOffset(!1):this.zoomEngine.clearDragOffset(!0,Ke)}})),this.setupUI(),this.setupEventListeners(),this.logDebug("ImageCloud initialized"),await this.loadImages()}catch(t){console.error("Gallery initialization failed:",t),this.errorEl&&t instanceof Error&&this.showError("Gallery failed to initialize: "+t.message)}}setupUI(){const t=this.fullConfig.ui;t.showFocusOutline?this.containerEl?.classList.remove("fbn-ic-suppress-outline"):this.containerEl?.classList.add("fbn-ic-suppress-outline"),t.showLoadingSpinner&&(t.loadingElement?(this.loadingEl=this.resolveElement(t.loadingElement),this.loadingElAutoCreated=!1):(this.loadingEl=this.createDefaultLoadingElement(),this.loadingElAutoCreated=!0)),t.errorElement?(this.errorEl=this.resolveElement(t.errorElement),this.errorElAutoCreated=!1):(this.errorEl=this.createDefaultErrorElement(),this.errorElAutoCreated=!0),t.showImageCounter&&(t.counterElement?(this.counterEl=this.resolveElement(t.counterElement),this.counterElAutoCreated=!1):(this.counterEl=this.createDefaultCounterElement(),this.counterElAutoCreated=!0)),t.showNavButtons&&(t.prevButtonElement?(this.prevButtonEl=this.resolveElement(t.prevButtonElement),this.prevButtonElAutoCreated=!1):(this.prevButtonEl=this.createDefaultPrevButtonElement(),this.prevButtonElAutoCreated=!0),t.nextButtonElement?(this.nextButtonEl=this.resolveElement(t.nextButtonElement),this.nextButtonElAutoCreated=!1):(this.nextButtonEl=this.createDefaultNextButtonElement(),this.nextButtonElAutoCreated=!0),this.prevButtonEl?.addEventListener("click",i=>{i.stopPropagation(),this.navigateToPreviousImage()}),this.nextButtonEl?.addEventListener("click",i=>{i.stopPropagation(),this.navigateToNextImage()}))}resolveElement(t){return t instanceof HTMLElement?t:document.getElementById(t)}createDefaultLoadingElement(){const t=document.createElement("div");t.className="fbn-ic-loading fbn-ic-hidden";const i=document.createElement("div");i.className="fbn-ic-spinner",t.appendChild(i);const e=document.createElement("p");return e.textContent="Loading images...",t.appendChild(e),this.containerEl.appendChild(t),t}createDefaultErrorElement(){const t=document.createElement("div");return t.className="fbn-ic-error fbn-ic-hidden",this.containerEl.appendChild(t),t}createDefaultCounterElement(){const t=document.createElement("div");return t.className="fbn-ic-counter fbn-ic-hidden",this.containerEl.appendChild(t),t}createDefaultPrevButtonElement(){const t=document.createElement("button");return t.className="fbn-ic-nav-btn fbn-ic-nav-btn-prev fbn-ic-hidden",t.textContent="‹",t.setAttribute("aria-label","Previous image"),t.setAttribute("tabindex","-1"),this.containerEl.appendChild(t),t}createDefaultNextButtonElement(){const t=document.createElement("button");return t.className="fbn-ic-nav-btn fbn-ic-nav-btn-next fbn-ic-hidden",t.textContent="›",t.setAttribute("aria-label","Next image"),t.setAttribute("tabindex","-1"),this.containerEl.appendChild(t),t}setupEventListeners(){this.fullConfig.interaction.navigation?.keyboard!==!1&&this.containerEl.addEventListener("keydown",t=>{t.key==="Escape"?(this.zoomEngine.unfocusImage(),this.currentFocusIndex=null,this.swipeEngine?.disable(),this.hideCounter(),this.hideNavButtons(),this.hideFocusIndicator()):t.key==="ArrowRight"?this.navigateToNextImage():t.key==="ArrowLeft"?this.navigateToPreviousImage():(t.key==="Enter"||t.key===" ")&&this.hoveredImage&&(this.handleImageClick(this.hoveredImage.element,this.hoveredImage.layout),t.preventDefault())}),document.addEventListener("click",t=>{this.swipeEngine?.hadRecentTouch()||!t.target.closest(".fbn-ic-image")&&!t.target.closest(".fbn-ic-nav-btn")&&(this.zoomEngine.unfocusImage(),this.currentFocusIndex=null,this.swipeEngine?.disable(),this.hideCounter(),this.hideNavButtons(),this.hideFocusIndicator())}),window.addEventListener("resize",()=>this.handleResize())}navigateToNextImage(){if(this.currentFocusIndex===null||this.imageElements.length===0)return;const t=(this.currentFocusIndex+1)%this.imageLayouts.length,i=this.imageElements.find(n=>n.dataset.imageId===String(t));if(!i)return;const e=this.imageLayouts[t];e&&(this.currentFocusIndex=t,this.handleImageClick(i,e),this.updateCounter(t),this.showNavButtons(),this.showFocusIndicator())}navigateToPreviousImage(){if(this.currentFocusIndex===null||this.imageElements.length===0)return;const t=(this.currentFocusIndex-1+this.imageLayouts.length)%this.imageLayouts.length,i=this.imageElements.find(n=>n.dataset.imageId===String(t));if(!i)return;const e=this.imageLayouts[t];e&&(this.currentFocusIndex=t,this.handleImageClick(i,e),this.updateCounter(t),this.showNavButtons(),this.showFocusIndicator())}handleResize(){this.imagesLoaded&&(this.resizeTimeout!==null&&clearTimeout(this.resizeTimeout),this.resizeTimeout=window.setTimeout(()=>{const t=this.getImageHeight();t!==this.currentImageHeight?(this.logDebug(`Window resized to new breakpoint (height: ${t}px). Reloading images...`),this.loadImages()):this.logDebug("Window resized (no breakpoint change)")},500))}getImageHeight(){const t=window.innerWidth,i=this.fullConfig.layout.responsive,n=this.fullConfig.image.sizing?.maxSize??400;return i?t<=i.mobile.maxWidth?Math.min(100,n):t<=i.tablet.maxWidth?Math.min(180,n):Math.min(225,n):t<=767?Math.min(100,n):t<=1199?Math.min(180,n):Math.min(225,n)}getContainerBounds(){return this.containerEl?{width:this.containerEl.offsetWidth,height:this.containerEl.offsetHeight||window.innerHeight*.7}:{width:window.innerWidth,height:window.innerHeight*.7}}async loadImages(){try{this.showLoading(!0),this.hideError(),this.clearImageCloud(),await this.imageLoader.prepare(this.imageFilter);const t=this.imageLoader.imagesLength();let i=this.imageLoader.imageURLs();if(t===0){this.showError("No images found."),this.showLoading(!1);return}const e=this.getContainerBounds(),n=this.getImageHeight(),s=window.innerWidth;this.logDebug(`Adaptive sizing input: container=${e.width}x${e.height}px, images=${t}, responsiveMax=${n}px`);const r=this.layoutEngine.calculateAdaptiveSize(e,t,n,s);this.logDebug(`Adaptive sizing result: height=${r.height}px`),await this.createImageCloud(i,r.height),this.showLoading(!1),this.imagesLoaded=!0}catch(t){console.error("Error loading images:",t),t instanceof Error&&this.showError(t.message||"Failed to load images."),this.showLoading(!1)}}logDebug(...t){this.fullConfig.config.debug?.enabled&&typeof console<"u"&&console.log(...t)}async createImageCloud(t,i){if(!this.containerEl)return;const e=this.getContainerBounds();this.currentImageHeight=i;const n=this.loadGeneration,s=this.layoutEngine.generateLayout(t.length,e,{fixedHeight:i});this.imageLayouts=s,this.displayQueue=[];let r=0;const a=l=>{this.containerEl&&(this.containerEl.appendChild(l),this.imageElements.push(l),requestAnimationFrame(()=>{if(l.offsetWidth,l.style.opacity=this.defaultStyles.opacity??"1",l.dataset.startX&&(this.entryAnimationEngine.requiresJSAnimation()||this.entryAnimationEngine.requiresJSRotation()||this.entryAnimationEngine.requiresJSScale()||l.dataset.startRotation!==l.dataset.rotation||l.dataset.startScale!==l.dataset.scale)){const d={x:parseFloat(l.dataset.startX),y:parseFloat(l.dataset.startY)},g={x:parseFloat(l.dataset.endX),y:parseFloat(l.dataset.endY)},b=parseFloat(l.dataset.imageWidth),p=parseFloat(l.dataset.imageHeight),f=parseFloat(l.dataset.rotation),m=parseFloat(l.dataset.scale),y=l.dataset.startRotation?parseFloat(l.dataset.startRotation):f,E=l.dataset.startScale?parseFloat(l.dataset.startScale):m,v=this.entryAnimationEngine.getTiming();zt({element:l,startPosition:d,endPosition:g,pathConfig:this.entryAnimationEngine.getPathConfig(),duration:v.duration,imageWidth:b,imageHeight:p,rotation:f,scale:m,rotationConfig:this.entryAnimationEngine.getRotationConfig(),startRotation:y,scaleConfig:this.entryAnimationEngine.getScaleConfig(),startScale:E})}else{const d=l.dataset.finalTransform||"";l.style.transform=d}const h=parseInt(l.dataset.imageId||"0");if(this.fullConfig.config.debug?.enabled&&h<3){const d=l.dataset.finalTransform||"";console.log(`Image ${h} final state:`,{left:l.style.left,top:l.style.top,width:l.style.width,height:l.style.height,computedWidth:l.offsetWidth,computedHeight:l.offsetHeight,transform:d,pathType:this.entryAnimationEngine.getPathType()})}if(this.idleAnimationEngine){const d=this.entryAnimationEngine.getTiming().duration;this.idleAnimationEngine.register(l,h,this.imageElements.length,d)}}),r++)},c=()=>{if(this.logDebug("Starting queue processing, enabled:",this.fullConfig.animation.queue.enabled),!this.fullConfig.animation.queue.enabled){for(;this.displayQueue.length>0;){const l=this.displayQueue.shift();l&&a(l)}return}this.queueInterval!==null&&clearInterval(this.queueInterval),this.queueInterval=window.setInterval(()=>{if(n!==this.loadGeneration){this.queueInterval!==null&&(clearInterval(this.queueInterval),this.queueInterval=null);return}if(this.displayQueue.length>0){const l=this.displayQueue.shift();l&&a(l)}r>=t.length&&this.displayQueue.length===0&&this.queueInterval!==null&&(clearInterval(this.queueInterval),this.queueInterval=null)},this.fullConfig.animation.queue.interval)};if("IntersectionObserver"in window&&this.containerEl){const l=new IntersectionObserver(u=>{u.forEach(h=>{h.isIntersecting&&(c(),l.disconnect())})},{threshold:.1,rootMargin:"50px"});l.observe(this.containerEl)}else c();this.fullConfig.config.debug?.centers&&this.containerEl&&(this.containerEl.querySelectorAll(".fbn-ic-debug-center").forEach(l=>l.remove()),s.forEach((l,u)=>{const h=document.createElement("div");h.className="fbn-ic-debug-center",h.style.position="absolute",h.style.width="12px",h.style.height="12px",h.style.borderRadius="50%",h.style.backgroundColor="red",h.style.border="2px solid yellow",h.style.zIndex="9999",h.style.pointerEvents="none";const d=l.x,g=l.y;h.style.left=`${d-6}px`,h.style.top=`${g-6}px`,h.title=`Image ${u}: center (${Math.round(d)}, ${Math.round(g)})`,this.containerEl.appendChild(h)})),t.forEach((l,u)=>{const h=document.createElement("img");h.referrerPolicy="no-referrer",h.classList.add("fbn-ic-image"),this.fullConfig.interaction.dragging===!1&&(h.draggable=!1),h.dataset.imageId=String(u),h.dataset.createdFlag="true";const d=s[u];h.style.position="absolute",h.style.width="auto",h.style.height=`${i}px`,h.style.left=`${d.x}px`,h.style.top=`${d.y}px`,d.zIndex&&(h.style.zIndex=String(d.zIndex)),ot(h,this.defaultClassName),h.addEventListener("mouseenter",()=>{if(this.hoveredImage={element:h,layout:d},!this.zoomEngine.isInvolved(h)){const g=h.cachedRenderedWidth;at(h,this.fullConfig.styling?.hover,i,g),ot(h,this.hoverClassName)}}),h.addEventListener("mouseleave",()=>{if(this.hoveredImage=null,!this.zoomEngine.isInvolved(h)){const g=h.cachedRenderedWidth;at(h,this.fullConfig.styling?.default,i,g),vt(h,this.hoverClassName),ot(h,this.defaultClassName)}}),h.addEventListener("click",g=>{g.stopPropagation(),this.handleImageClick(h,d)}),h.style.opacity="0",h.style.transition=this.entryAnimationEngine.getTransitionCSS(),h.onload=()=>{if(n!==this.loadGeneration)return;const g=h.naturalWidth/h.naturalHeight,b=i*g;h.dataset.onloadCalled="true",window.DEBUG_CLIPPATH&&console.log(`[onload #${u}] Called with imageHeight=${i}, renderedWidth=${b}`),h.style.width=`${b}px`,h.cachedRenderedWidth=b,h.aspectRatio=g,at(h,this.fullConfig.styling?.default,i,b);const p={x:d.x,y:d.y},f={width:b,height:i},m=this.entryAnimationEngine.calculateStartPosition(p,f,e,u,t.length),y=this.entryAnimationEngine.calculateStartRotation(d.rotation),E=this.entryAnimationEngine.calculateStartScale(d.scale),v=this.entryAnimationEngine.buildFinalTransform(d.rotation,d.scale,b,i),I=this.entryAnimationEngine.buildStartTransform(m,p,d.rotation,d.scale,b,i,y,E);this.fullConfig.config.debug?.enabled&&u<3&&console.log(`Image ${u}:`,{finalPosition:p,imageSize:f,left:d.x,top:d.y,finalTransform:v,renderedWidth:b,renderedHeight:i}),h.style.transform=I,h.dataset.finalTransform=v,(this.entryAnimationEngine.requiresJSAnimation()||this.entryAnimationEngine.requiresJSRotation()||this.entryAnimationEngine.requiresJSScale()||y!==d.rotation||E!==d.scale)&&(h.dataset.startX=String(m.x),h.dataset.startY=String(m.y),h.dataset.endX=String(p.x),h.dataset.endY=String(p.y),h.dataset.imageWidth=String(b),h.dataset.imageHeight=String(i),h.dataset.rotation=String(d.rotation),h.dataset.scale=String(d.scale),h.dataset.startRotation=String(y),h.dataset.startScale=String(E)),this.displayQueue.push(h)},h.onerror=()=>r++,h.src=l})}async handleImageClick(t,i){if(!this.containerEl)return;const e=this.zoomEngine.isFocused(t),n={width:this.containerEl.offsetWidth,height:this.containerEl.offsetHeight};if(e)await this.zoomEngine.unfocusImage(),this.currentFocusIndex=null,this.swipeEngine?.disable(),this.hideCounter(),this.hideNavButtons(),this.hideFocusIndicator();else{this.idleAnimationEngine?.pauseForImage(t);const s=t.dataset.imageId;this.currentFocusIndex=s!==void 0?parseInt(s,10):null,this.swipeEngine?.enable(),this.containerEl?.focus({preventScroll:!0}),await this.zoomEngine.focusImage(t,n,i),this.currentFocusIndex!==null&&this.updateCounter(this.currentFocusIndex),this.showNavButtons(),this.showFocusIndicator()}}clearImageCloud(){this.queueInterval!==null&&(clearInterval(this.queueInterval),this.queueInterval=null),this.loadGeneration++,this.displayQueue=[],this.hideFocusIndicator(),this.containerEl&&this.containerEl.querySelectorAll(".fbn-ic-image, .fbn-ic-debug-center").forEach(t=>t.remove()),this.imageElements=[],this.imageLayouts=[],this.currentFocusIndex=null,this.hoveredImage=null,this.layoutEngine.reset(),this.zoomEngine.reset(),this.idleAnimationEngine?.stopAll(),this.imagesLoaded=!1}showLoading(t){!this.fullConfig.ui.showLoadingSpinner||!this.loadingEl||(t?this.loadingEl.classList.remove("fbn-ic-hidden"):this.loadingEl.classList.add("fbn-ic-hidden"))}showError(t){this.errorEl&&(this.errorEl.textContent=t,this.errorEl.classList.remove("fbn-ic-hidden"))}hideError(){this.errorEl&&this.errorEl.classList.add("fbn-ic-hidden")}updateCounter(t){!this.fullConfig.ui.showImageCounter||!this.counterEl||(this.counterEl.textContent=`${t+1} of ${this.imageElements.length}`,this.counterEl.classList.remove("fbn-ic-hidden"))}hideCounter(){this.counterEl&&this.counterEl.classList.add("fbn-ic-hidden")}showFocusIndicator(){this.containerEl?.classList.add("fbn-ic-has-focus")}hideFocusIndicator(){this.containerEl?.classList.remove("fbn-ic-has-focus")}showNavButtons(){this.prevButtonEl?.classList.remove("fbn-ic-hidden"),this.nextButtonEl?.classList.remove("fbn-ic-hidden")}hideNavButtons(){this.prevButtonEl?.classList.add("fbn-ic-hidden"),this.nextButtonEl?.classList.add("fbn-ic-hidden")}destroy(){this.clearImageCloud(),this.loadingElAutoCreated&&this.loadingEl&&(this.loadingEl.remove(),this.loadingEl=null),this.errorElAutoCreated&&this.errorEl&&(this.errorEl.remove(),this.errorEl=null),this.counterElAutoCreated&&this.counterEl&&(this.counterEl.remove(),this.counterEl=null),this.prevButtonElAutoCreated&&this.prevButtonEl&&(this.prevButtonEl.remove(),this.prevButtonEl=null),this.nextButtonElAutoCreated&&this.nextButtonEl&&(this.nextButtonEl.remove(),this.nextButtonEl=null),this.resizeTimeout!==null&&clearTimeout(this.resizeTimeout),this.swipeEngine?.destroy(),this.idleAnimationEngine?.stopAll(),this.idleAnimationEngine=null}}S.AnimationEngine=Ot,S.BOUNCE_PRESETS=ht,S.ClusterPlacementLayout=kt,S.CompositeLoader=Kt,S.DEFAULT_CONFIG=A,S.DEFAULT_SHARED_LOADER_CONFIG=pt,S.ELASTIC_PRESETS=dt,S.EntryAnimationEngine=Pt,S.FUNCTIONAL_CSS=Qt,S.GoogleDriveLoader=Vt,S.GridPlacementLayout=Ht,S.HoneycombPlacementLayout=jt,S.ImageCloud=ee,S.ImageFilter=Zt,S.ImageGallery=ee,S.LayoutEngine=Wt,S.RadialPlacementLayout=_t,S.RandomPlacementLayout=$t,S.SpiralPlacementLayout=Nt,S.StaticImageLoader=Jt,S.WAVE_PATH_PRESETS=ut,S.WavePlacementLayout=Bt,S.ZoomEngine=Yt,S.animatePath=zt,S.injectFunctionalStyles=te,S.requiresJSAnimation=Dt,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})}));
|
|
84
|
+
`;function ee(){if(typeof document>"u")return;const o="fbn-ic-functional-styles";if(document.getElementById(o))return;const t=document.createElement("style");t.id=o,t.textContent=te,document.head.appendChild(t)}class wt{constructor(t={}){this.fullConfig=be(t),t.container instanceof HTMLElement?(this.containerRef=t.container,this.containerId=null):(this.containerRef=null,this.containerId=t.container||"imageCloud"),this.imagesLoaded=!1,this.imageElements=[],this.imageLayouts=[],this.currentImageHeight=225,this.currentFocusIndex=null,this.hoveredImage=null,this.resizeTimeout=null,this.displayQueue=[],this.queueInterval=null,this.loadGeneration=0,this.loadingElAutoCreated=!1,this.errorElAutoCreated=!1,this.counterEl=null,this.counterElAutoCreated=!1,this.prevButtonEl=null,this.nextButtonEl=null,this.prevButtonElAutoCreated=!1,this.nextButtonElAutoCreated=!1,this.animationEngine=new zt(this.fullConfig.animation),this.layoutEngine=new Gt({layout:this.fullConfig.layout,image:this.fullConfig.image}),this.zoomEngine=new Vt(this.fullConfig.interaction.focus,this.animationEngine,this.fullConfig.styling),this.defaultStyles=nt(this.fullConfig.styling?.default),this.defaultClassName=this.fullConfig.styling?.default?.className,this.hoverClassName=this.fullConfig.styling?.hover?.className;const i=this.fullConfig.animation.entry||A.animation.entry;this.entryAnimationEngine=new $t(i,this.fullConfig.layout.algorithm);const e=this.fullConfig.animation.idle;e&&e.type!=="none"?this.idleAnimationEngine=new Le(e,i.timing?.duration??600):this.idleAnimationEngine=null,this.zoomEngine.setOnUnfocusCompleteCallback(n=>{this.idleAnimationEngine?.resumeForImage(n);const s=n;requestAnimationFrame(()=>{if(s.matches(":hover")&&this.fullConfig.styling?.hover){const r=this.imageElements.indexOf(s);if(r!==-1){const a=s.offsetHeight,c=s.cachedRenderedWidth;at(s,this.fullConfig.styling.hover,a,c),ot(s,this.hoverClassName),this.hoveredImage={element:s,layout:this.imageLayouts[r]}}}})}),this.swipeEngine=null,this.imageFilter=this.createImageFilter(),this.imageLoader=this.createLoader(),this.containerEl=null,this.loadingEl=null,this.errorEl=null}createImageFilter(){const t=this.fullConfig.config.loaders?.allowedExtensions;return new Qt(t)}createLoader(){const t=this.fullConfig.loaders,i=this.fullConfig.config.loaders??{};if(!t||t.length===0)throw new Error("No loaders configured. Provide `images`, `loaders`, or both.\n Example: imageCloud({ container: 'id', images: ['https://...'] })");const e=t.map(n=>this.createLoaderFromEntry(n,i));return e.length===1?e[0]:new Zt({loaders:e,debugLogging:this.fullConfig.config.debug?.loaders})}createLoaderFromEntry(t,i){if("static"in t){const e=t.static,n={...e,validateUrls:e.validateUrls??i.validateUrls,validationTimeout:e.validationTimeout??i.validationTimeout,validationMethod:e.validationMethod??i.validationMethod,allowedExtensions:e.allowedExtensions??i.allowedExtensions,debugLogging:e.debugLogging??this.fullConfig.config.debug?.loaders};return new Kt(n)}else if("googleDrive"in t){const e=t.googleDrive,n={...e,allowedExtensions:e.allowedExtensions??i.allowedExtensions,debugLogging:e.debugLogging??this.fullConfig.config.debug?.loaders};return new Jt(n)}else throw new Error(`Unknown loader entry: ${JSON.stringify(t)}`)}async init(){try{if(ee(),this.containerRef)this.containerEl=this.containerRef;else if(this.containerEl=document.getElementById(this.containerId),!this.containerEl)throw new Error(`Container "#${this.containerId}" not found. Ensure an element with id="${this.containerId}" exists in the DOM before calling imageCloud().`);this.containerEl.classList.add("fbn-ic-gallery"),this.containerEl.setAttribute("tabindex","0"),this.fullConfig.interaction.navigation?.swipe!==!1&&(this.swipeEngine=new Et(this.containerEl,{onNext:()=>this.navigateToNextImage(),onPrev:()=>this.navigateToPreviousImage(),onDragOffset:t=>this.zoomEngine.setDragOffset(t),onDragEnd:t=>{t?this.zoomEngine.clearDragOffset(!1):this.zoomEngine.clearDragOffset(!0,Ke)}})),this.setupUI(),this.setupEventListeners(),this.logDebug("ImageCloud initialized"),await this.loadImages()}catch(t){console.error(`ImageCloud initialization failed (container: "${this.containerId??"element"}"):`,t),this.errorEl&&t instanceof Error&&this.showError("Gallery failed to initialize: "+t.message)}}setupUI(){const t=this.fullConfig.ui;t.showFocusOutline?this.containerEl?.classList.remove("fbn-ic-suppress-outline"):this.containerEl?.classList.add("fbn-ic-suppress-outline"),t.showLoadingSpinner&&(t.loadingElement?(this.loadingEl=this.resolveElement(t.loadingElement),this.loadingElAutoCreated=!1):(this.loadingEl=this.createDefaultLoadingElement(),this.loadingElAutoCreated=!0)),t.errorElement?(this.errorEl=this.resolveElement(t.errorElement),this.errorElAutoCreated=!1):(this.errorEl=this.createDefaultErrorElement(),this.errorElAutoCreated=!0),t.showImageCounter&&(t.counterElement?(this.counterEl=this.resolveElement(t.counterElement),this.counterElAutoCreated=!1):(this.counterEl=this.createDefaultCounterElement(),this.counterElAutoCreated=!0)),t.showNavButtons&&(t.prevButtonElement?(this.prevButtonEl=this.resolveElement(t.prevButtonElement),this.prevButtonElAutoCreated=!1):(this.prevButtonEl=this.createDefaultPrevButtonElement(),this.prevButtonElAutoCreated=!0),t.nextButtonElement?(this.nextButtonEl=this.resolveElement(t.nextButtonElement),this.nextButtonElAutoCreated=!1):(this.nextButtonEl=this.createDefaultNextButtonElement(),this.nextButtonElAutoCreated=!0),this.prevButtonEl?.addEventListener("click",i=>{i.stopPropagation(),this.navigateToPreviousImage()}),this.nextButtonEl?.addEventListener("click",i=>{i.stopPropagation(),this.navigateToNextImage()}))}resolveElement(t){return t instanceof HTMLElement?t:document.getElementById(t)}createDefaultLoadingElement(){const t=document.createElement("div");t.className="fbn-ic-loading fbn-ic-hidden";const i=document.createElement("div");i.className="fbn-ic-spinner",t.appendChild(i);const e=document.createElement("p");return e.textContent="Loading images...",t.appendChild(e),this.containerEl.appendChild(t),t}createDefaultErrorElement(){const t=document.createElement("div");return t.className="fbn-ic-error fbn-ic-hidden",this.containerEl.appendChild(t),t}createDefaultCounterElement(){const t=document.createElement("div");return t.className="fbn-ic-counter fbn-ic-hidden",this.containerEl.appendChild(t),t}createDefaultPrevButtonElement(){const t=document.createElement("button");return t.className="fbn-ic-nav-btn fbn-ic-nav-btn-prev fbn-ic-hidden",t.textContent="‹",t.setAttribute("aria-label","Previous image"),t.setAttribute("tabindex","-1"),this.containerEl.appendChild(t),t}createDefaultNextButtonElement(){const t=document.createElement("button");return t.className="fbn-ic-nav-btn fbn-ic-nav-btn-next fbn-ic-hidden",t.textContent="›",t.setAttribute("aria-label","Next image"),t.setAttribute("tabindex","-1"),this.containerEl.appendChild(t),t}setupEventListeners(){this.fullConfig.interaction.navigation?.keyboard!==!1&&this.containerEl.addEventListener("keydown",t=>{t.key==="Escape"?(this.zoomEngine.unfocusImage(),this.currentFocusIndex=null,this.swipeEngine?.disable(),this.hideCounter(),this.hideNavButtons(),this.hideFocusIndicator()):t.key==="ArrowRight"?this.navigateToNextImage():t.key==="ArrowLeft"?this.navigateToPreviousImage():(t.key==="Enter"||t.key===" ")&&this.hoveredImage&&(this.handleImageClick(this.hoveredImage.element,this.hoveredImage.layout),t.preventDefault())}),document.addEventListener("click",t=>{this.swipeEngine?.hadRecentTouch()||!t.target.closest(".fbn-ic-image")&&!t.target.closest(".fbn-ic-nav-btn")&&(this.zoomEngine.unfocusImage(),this.currentFocusIndex=null,this.swipeEngine?.disable(),this.hideCounter(),this.hideNavButtons(),this.hideFocusIndicator())}),window.addEventListener("resize",()=>this.handleResize())}navigateToNextImage(){if(this.currentFocusIndex===null||this.imageElements.length===0)return;const t=(this.currentFocusIndex+1)%this.imageLayouts.length,i=this.imageElements.find(n=>n.dataset.imageId===String(t));if(!i)return;const e=this.imageLayouts[t];e&&(this.currentFocusIndex=t,this.handleImageClick(i,e),this.updateCounter(t),this.showNavButtons(),this.showFocusIndicator())}navigateToPreviousImage(){if(this.currentFocusIndex===null||this.imageElements.length===0)return;const t=(this.currentFocusIndex-1+this.imageLayouts.length)%this.imageLayouts.length,i=this.imageElements.find(n=>n.dataset.imageId===String(t));if(!i)return;const e=this.imageLayouts[t];e&&(this.currentFocusIndex=t,this.handleImageClick(i,e),this.updateCounter(t),this.showNavButtons(),this.showFocusIndicator())}handleResize(){this.imagesLoaded&&(this.resizeTimeout!==null&&clearTimeout(this.resizeTimeout),this.resizeTimeout=window.setTimeout(()=>{const t=this.getImageHeight();t!==this.currentImageHeight?(this.logDebug(`Window resized to new breakpoint (height: ${t}px). Reloading images...`),this.loadImages()):this.logDebug("Window resized (no breakpoint change)")},500))}getImageHeight(){const t=window.innerWidth,i=this.fullConfig.layout.responsive,n=this.fullConfig.image.sizing?.maxSize??400;return i?t<=i.mobile.maxWidth?Math.min(100,n):t<=i.tablet.maxWidth?Math.min(180,n):Math.min(225,n):t<=767?Math.min(100,n):t<=1199?Math.min(180,n):Math.min(225,n)}getContainerBounds(){return this.containerEl?{width:this.containerEl.offsetWidth,height:this.containerEl.offsetHeight||window.innerHeight*.7}:{width:window.innerWidth,height:window.innerHeight*.7}}async loadImages(){try{this.showLoading(!0),this.hideError(),this.clearImageCloud(),await this.imageLoader.prepare(this.imageFilter);const t=this.imageLoader.imagesLength();let i=this.imageLoader.imageURLs();if(t===0){this.showError("No images found."),this.showLoading(!1);return}const e=this.getContainerBounds(),n=this.getImageHeight(),s=window.innerWidth;this.logDebug(`Adaptive sizing input: container=${e.width}x${e.height}px, images=${t}, responsiveMax=${n}px`);const r=this.layoutEngine.calculateAdaptiveSize(e,t,n,s);this.logDebug(`Adaptive sizing result: height=${r.height}px`),await this.createImageCloud(i,r.height),this.showLoading(!1),this.imagesLoaded=!0}catch(t){console.error("Error loading images:",t),t instanceof Error&&this.showError(t.message||"Failed to load images."),this.showLoading(!1)}}logDebug(...t){this.fullConfig.config.debug?.enabled&&typeof console<"u"&&console.log(...t)}async createImageCloud(t,i){if(!this.containerEl)return;const e=this.getContainerBounds();this.currentImageHeight=i;const n=this.loadGeneration,s=this.layoutEngine.generateLayout(t.length,e,{fixedHeight:i});this.imageLayouts=s,this.displayQueue=[];let r=0;const a=l=>{this.containerEl&&(this.containerEl.appendChild(l),this.imageElements.push(l),requestAnimationFrame(()=>{if(l.offsetWidth,l.style.opacity=this.defaultStyles.opacity??"1",l.dataset.startX&&(this.entryAnimationEngine.requiresJSAnimation()||this.entryAnimationEngine.requiresJSRotation()||this.entryAnimationEngine.requiresJSScale()||l.dataset.startRotation!==l.dataset.rotation||l.dataset.startScale!==l.dataset.scale)){const d={x:parseFloat(l.dataset.startX),y:parseFloat(l.dataset.startY)},g={x:parseFloat(l.dataset.endX),y:parseFloat(l.dataset.endY)},b=parseFloat(l.dataset.imageWidth),p=parseFloat(l.dataset.imageHeight),f=parseFloat(l.dataset.rotation),m=parseFloat(l.dataset.scale),y=l.dataset.startRotation?parseFloat(l.dataset.startRotation):f,E=l.dataset.startScale?parseFloat(l.dataset.startScale):m,v=this.entryAnimationEngine.getTiming();Dt({element:l,startPosition:d,endPosition:g,pathConfig:this.entryAnimationEngine.getPathConfig(),duration:v.duration,imageWidth:b,imageHeight:p,rotation:f,scale:m,rotationConfig:this.entryAnimationEngine.getRotationConfig(),startRotation:y,scaleConfig:this.entryAnimationEngine.getScaleConfig(),startScale:E})}else{const d=l.dataset.finalTransform||"";l.style.transform=d}const h=parseInt(l.dataset.imageId||"0");if(this.fullConfig.config.debug?.enabled&&h<3){const d=l.dataset.finalTransform||"";console.log(`Image ${h} final state:`,{left:l.style.left,top:l.style.top,width:l.style.width,height:l.style.height,computedWidth:l.offsetWidth,computedHeight:l.offsetHeight,transform:d,pathType:this.entryAnimationEngine.getPathType()})}if(this.idleAnimationEngine){const d=this.entryAnimationEngine.getTiming().duration;this.idleAnimationEngine.register(l,h,this.imageElements.length,d)}}),r++)},c=()=>{if(this.logDebug("Starting queue processing, enabled:",this.fullConfig.animation.queue.enabled),!this.fullConfig.animation.queue.enabled){for(;this.displayQueue.length>0;){const l=this.displayQueue.shift();l&&a(l)}return}this.queueInterval!==null&&clearInterval(this.queueInterval),this.queueInterval=window.setInterval(()=>{if(n!==this.loadGeneration){this.queueInterval!==null&&(clearInterval(this.queueInterval),this.queueInterval=null);return}if(this.displayQueue.length>0){const l=this.displayQueue.shift();l&&a(l)}r>=t.length&&this.displayQueue.length===0&&this.queueInterval!==null&&(clearInterval(this.queueInterval),this.queueInterval=null)},this.fullConfig.animation.queue.interval)};if("IntersectionObserver"in window&&this.containerEl){const l=new IntersectionObserver(u=>{u.forEach(h=>{h.isIntersecting&&(c(),l.disconnect())})},{threshold:.1,rootMargin:"50px"});l.observe(this.containerEl)}else c();this.fullConfig.config.debug?.centers&&this.containerEl&&(this.containerEl.querySelectorAll(".fbn-ic-debug-center").forEach(l=>l.remove()),s.forEach((l,u)=>{const h=document.createElement("div");h.className="fbn-ic-debug-center",h.style.position="absolute",h.style.width="12px",h.style.height="12px",h.style.borderRadius="50%",h.style.backgroundColor="red",h.style.border="2px solid yellow",h.style.zIndex="9999",h.style.pointerEvents="none";const d=l.x,g=l.y;h.style.left=`${d-6}px`,h.style.top=`${g-6}px`,h.title=`Image ${u}: center (${Math.round(d)}, ${Math.round(g)})`,this.containerEl.appendChild(h)})),t.forEach((l,u)=>{const h=document.createElement("img");h.referrerPolicy="no-referrer",h.classList.add("fbn-ic-image"),this.fullConfig.interaction.dragging===!1&&(h.draggable=!1),h.dataset.imageId=String(u),h.dataset.createdFlag="true";const d=s[u];h.style.position="absolute",h.style.width="auto",h.style.height=`${i}px`,h.style.left=`${d.x}px`,h.style.top=`${d.y}px`,d.zIndex&&(h.style.zIndex=String(d.zIndex)),ot(h,this.defaultClassName),h.addEventListener("mouseenter",()=>{if(this.hoveredImage={element:h,layout:d},!this.zoomEngine.isInvolved(h)){const g=h.cachedRenderedWidth;at(h,this.fullConfig.styling?.hover,i,g),ot(h,this.hoverClassName)}}),h.addEventListener("mouseleave",()=>{if(this.hoveredImage=null,!this.zoomEngine.isInvolved(h)){const g=h.cachedRenderedWidth;at(h,this.fullConfig.styling?.default,i,g),vt(h,this.hoverClassName),ot(h,this.defaultClassName)}}),h.addEventListener("click",g=>{g.stopPropagation(),this.handleImageClick(h,d)}),h.style.opacity="0",h.style.transition=this.entryAnimationEngine.getTransitionCSS(),h.onload=()=>{if(n!==this.loadGeneration)return;const g=h.naturalWidth/h.naturalHeight,b=i*g;h.dataset.onloadCalled="true",window.DEBUG_CLIPPATH&&console.log(`[onload #${u}] Called with imageHeight=${i}, renderedWidth=${b}`),h.style.width=`${b}px`,h.cachedRenderedWidth=b,h.aspectRatio=g,at(h,this.fullConfig.styling?.default,i,b);const p={x:d.x,y:d.y},f={width:b,height:i},m=this.entryAnimationEngine.calculateStartPosition(p,f,e,u,t.length),y=this.entryAnimationEngine.calculateStartRotation(d.rotation),E=this.entryAnimationEngine.calculateStartScale(d.scale),v=this.entryAnimationEngine.buildFinalTransform(d.rotation,d.scale,b,i),I=this.entryAnimationEngine.buildStartTransform(m,p,d.rotation,d.scale,b,i,y,E);this.fullConfig.config.debug?.enabled&&u<3&&console.log(`Image ${u}:`,{finalPosition:p,imageSize:f,left:d.x,top:d.y,finalTransform:v,renderedWidth:b,renderedHeight:i}),h.style.transform=I,h.dataset.finalTransform=v,(this.entryAnimationEngine.requiresJSAnimation()||this.entryAnimationEngine.requiresJSRotation()||this.entryAnimationEngine.requiresJSScale()||y!==d.rotation||E!==d.scale)&&(h.dataset.startX=String(m.x),h.dataset.startY=String(m.y),h.dataset.endX=String(p.x),h.dataset.endY=String(p.y),h.dataset.imageWidth=String(b),h.dataset.imageHeight=String(i),h.dataset.rotation=String(d.rotation),h.dataset.scale=String(d.scale),h.dataset.startRotation=String(y),h.dataset.startScale=String(E)),this.displayQueue.push(h)},h.onerror=()=>r++,h.src=l})}async handleImageClick(t,i){if(!this.containerEl)return;const e=this.zoomEngine.isFocused(t),n={width:this.containerEl.offsetWidth,height:this.containerEl.offsetHeight};if(e)await this.zoomEngine.unfocusImage(),this.currentFocusIndex=null,this.swipeEngine?.disable(),this.hideCounter(),this.hideNavButtons(),this.hideFocusIndicator();else{this.idleAnimationEngine?.pauseForImage(t);const s=t.dataset.imageId;this.currentFocusIndex=s!==void 0?parseInt(s,10):null,this.swipeEngine?.enable(),this.containerEl?.focus({preventScroll:!0}),await this.zoomEngine.focusImage(t,n,i),this.currentFocusIndex!==null&&this.updateCounter(this.currentFocusIndex),this.showNavButtons(),this.showFocusIndicator()}}clearImageCloud(){this.queueInterval!==null&&(clearInterval(this.queueInterval),this.queueInterval=null),this.loadGeneration++,this.displayQueue=[],this.hideFocusIndicator(),this.containerEl&&this.containerEl.querySelectorAll(".fbn-ic-image, .fbn-ic-debug-center").forEach(t=>t.remove()),this.imageElements=[],this.imageLayouts=[],this.currentFocusIndex=null,this.hoveredImage=null,this.layoutEngine.reset(),this.zoomEngine.reset(),this.idleAnimationEngine?.stopAll(),this.imagesLoaded=!1}showLoading(t){!this.fullConfig.ui.showLoadingSpinner||!this.loadingEl||(t?this.loadingEl.classList.remove("fbn-ic-hidden"):this.loadingEl.classList.add("fbn-ic-hidden"))}showError(t){this.errorEl&&(this.errorEl.textContent=t,this.errorEl.classList.remove("fbn-ic-hidden"))}hideError(){this.errorEl&&this.errorEl.classList.add("fbn-ic-hidden")}updateCounter(t){!this.fullConfig.ui.showImageCounter||!this.counterEl||(this.counterEl.textContent=`${t+1} of ${this.imageElements.length}`,this.counterEl.classList.remove("fbn-ic-hidden"))}hideCounter(){this.counterEl&&this.counterEl.classList.add("fbn-ic-hidden")}showFocusIndicator(){this.containerEl?.classList.add("fbn-ic-has-focus")}hideFocusIndicator(){this.containerEl?.classList.remove("fbn-ic-has-focus")}showNavButtons(){this.prevButtonEl?.classList.remove("fbn-ic-hidden"),this.nextButtonEl?.classList.remove("fbn-ic-hidden")}hideNavButtons(){this.prevButtonEl?.classList.add("fbn-ic-hidden"),this.nextButtonEl?.classList.add("fbn-ic-hidden")}destroy(){this.clearImageCloud(),this.loadingElAutoCreated&&this.loadingEl&&(this.loadingEl.remove(),this.loadingEl=null),this.errorElAutoCreated&&this.errorEl&&(this.errorEl.remove(),this.errorEl=null),this.counterElAutoCreated&&this.counterEl&&(this.counterEl.remove(),this.counterEl=null),this.prevButtonElAutoCreated&&this.prevButtonEl&&(this.prevButtonEl.remove(),this.prevButtonEl=null),this.nextButtonElAutoCreated&&this.nextButtonEl&&(this.nextButtonEl.remove(),this.nextButtonEl=null),this.resizeTimeout!==null&&clearTimeout(this.resizeTimeout),this.swipeEngine?.destroy(),this.idleAnimationEngine?.stopAll(),this.idleAnimationEngine=null}}async function Qe(o){const t=new wt(o);return await t.init(),t}S.AnimationEngine=zt,S.BOUNCE_PRESETS=ht,S.ClusterPlacementLayout=Bt,S.CompositeLoader=Zt,S.DEFAULT_CONFIG=A,S.DEFAULT_SHARED_LOADER_CONFIG=pt,S.ELASTIC_PRESETS=dt,S.EntryAnimationEngine=$t,S.FUNCTIONAL_CSS=te,S.GoogleDriveLoader=Jt,S.GridPlacementLayout=Nt,S.HoneycombPlacementLayout=Wt,S.ImageCloud=wt,S.ImageFilter=Qt,S.ImageGallery=wt,S.LayoutEngine=Gt,S.RadialPlacementLayout=Ut,S.RandomPlacementLayout=_t,S.SpiralPlacementLayout=kt,S.StaticImageLoader=Kt,S.WAVE_PATH_PRESETS=ut,S.WavePlacementLayout=jt,S.ZoomEngine=Vt,S.animatePath=Dt,S.imageCloud=Qe,S.injectFunctionalStyles=ee,S.requiresJSAnimation=Pt,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})}));
|
|
85
85
|
//# sourceMappingURL=image-cloud.umd.js.map
|