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