@frybynite/image-cloud 0.2.5 → 0.2.6
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 +879 -775
- package/dist/image-cloud-auto-init.js.map +1 -1
- package/dist/image-cloud.js +856 -752
- 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 +12 -0
- package/package.json +1 -1
package/dist/image-cloud.umd.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
(function(A,st){typeof exports=="object"&&typeof module<"u"?st(exports):typeof define=="function"&&define.amd?define(["exports"],st):(A=typeof globalThis<"u"?globalThis:A||self,st(A.ImageCloud={}))})(this,function(A){"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})}),bt=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})}),vt=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})}),wt=Object.freeze({type:"linear"}),xt=Object.freeze({mode:"none"}),St=Object.freeze({mode:"none"}),zt=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"})}),ee=Object.freeze({rows:1,amplitude:100,frequency:2,phaseShift:0,synchronization:"offset"}),ie=Object.freeze({mobile:Object.freeze({maxWidth:767}),tablet:Object.freeze({maxWidth:1199})}),ne=Object.freeze({mode:"adaptive",minSize:50,maxSize:400,variance:Object.freeze({min:1,max:1})}),oe=Object.freeze({mode:"none",range:Object.freeze({min:-15,max:15})}),Ct=Object.freeze({sizing:ne,rotation:oe}),b=Object.freeze({loader:Object.freeze({type:"googleDrive",googleDrive:Object.freeze({apiKey:"",sources:[],apiEndpoint:"https://www.googleapis.com/drive/v3/files",allowedExtensions:["jpg","jpeg","png","gif","webp","bmp"],debugLogging:!1}),static:Object.freeze({sources:[],validateUrls:!0,validationTimeout:5e3,validationMethod:"head",failOnAllMissing:!0,allowedExtensions:["jpg","jpeg","png","gif","webp","bmp"],debugLogging:!1})}),image:Ct,layout:Object.freeze({algorithm:"radial",scaleDecay:0,responsive:ie,targetCoverage:.6,densityFactor:1,spacing:Object.freeze({padding:50,minGap:20}),debugRadials:!1,debugCenters:!1}),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:wt,rotation:xt,scale:St})}),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:void 0,showThumbnails:void 0,theme:void 0}),performance:Object.freeze({lazyLoad:void 0,preloadCount:void 0,imageQuality:void 0})}),styling:zt,debug:!1});function lt(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 se(n,t){if(!t)return{...n};const e=lt(n.default,t.default),i=lt(lt(e,n.hover),t.hover),o=lt(lt(e,n.focused),t.focused);return{default:e,hover:i,focused:o}}function ae(n,t){var i,o,s,c,a,h,l,u;if(!t)return{...n};const e={...n};if(t.sizing!==void 0&&(e.sizing={...n.sizing,...t.sizing},t.sizing.variance)){const r=t.sizing.variance,d=r.min!==void 0&&r.min>=.25&&r.min<=1?r.min:((o=(i=n.sizing)==null?void 0:i.variance)==null?void 0:o.min)??1,f=r.max!==void 0&&r.max>=1&&r.max<=1.75?r.max:((c=(s=n.sizing)==null?void 0:s.variance)==null?void 0:c.max)??1;e.sizing.variance={min:d,max:f}}if(t.rotation!==void 0&&(e.rotation={...n.rotation,...t.rotation},t.rotation.range)){const r=t.rotation.range,d=r.min!==void 0&&r.min>=-180&&r.min<=0?r.min:((h=(a=n.rotation)==null?void 0:a.range)==null?void 0:h.min)??-15,f=r.max!==void 0&&r.max>=0&&r.max<=180?r.max:((u=(l=n.rotation)==null?void 0:l.range)==null?void 0:u.max)??15;e.rotation.range={min:d,max:f}}return e}function re(n){var e;const t=(e=n.layout)==null?void 0:e.rotation;if(t&&"enabled"in t)return{rotation:{mode:t.enabled?"random":"none",range:t.range}}}function ce(n){var e,i;const t=(i=(e=n.layout)==null?void 0:e.sizing)==null?void 0:i.variance;if(t)return{sizing:{mode:"adaptive",variance:t}}}function le(n={}){var s;const t=re(n),e=ce(n);let i=n.image;(t||e)&&(i={...e||{},...t||{},...i},i.rotation&&(t!=null&&t.rotation)&&((s=n.image)!=null&&s.rotation)&&(i.rotation={...t.rotation,...n.image.rotation}));const o={loader:{...b.loader},image:ae(Ct,i),layout:{...b.layout},animation:{...b.animation},interaction:{...b.interaction},rendering:{...b.rendering},styling:se(zt,n.styling),debug:b.debug};return n.loader&&(o.loader={...b.loader,...n.loader},n.loader.googleDrive&&(o.loader.googleDrive={...b.loader.googleDrive,...n.loader.googleDrive,sources:n.loader.googleDrive.sources||b.loader.googleDrive.sources,allowedExtensions:n.loader.googleDrive.allowedExtensions||b.loader.googleDrive.allowedExtensions}),n.loader.static&&(o.loader.static={...b.loader.static,...n.loader.static,sources:n.loader.static.sources||b.loader.static.sources,allowedExtensions:n.loader.static.allowedExtensions||b.loader.static.allowedExtensions})),n.layout&&(o.layout={...b.layout,...n.layout},n.layout.responsive&&(o.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&&(o.layout.spacing={...b.layout.spacing,...n.layout.spacing})),n.animation&&(o.animation={...b.animation,...n.animation},n.animation.easing&&(o.animation.easing={...b.animation.easing,...n.animation.easing}),n.animation.queue&&(o.animation.queue={...b.animation.queue,...n.animation.queue}),n.animation.performance&&(o.animation.performance={...b.animation.performance,...n.animation.performance}),n.animation.entry&&(o.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?{...wt,...n.animation.entry.path}:b.animation.entry.path,rotation:n.animation.entry.rotation?{...xt,...n.animation.entry.rotation}:b.animation.entry.rotation,scale:n.animation.entry.scale?{...St,...n.animation.entry.scale}:b.animation.entry.scale})),n.interaction&&(o.interaction={...b.interaction,...n.interaction},n.interaction.focus&&(o.interaction.focus={...b.interaction.focus,...n.interaction.focus}),n.interaction.navigation&&(o.interaction.navigation={...b.interaction.navigation,...n.interaction.navigation}),n.interaction.gestures&&(o.interaction.gestures={...b.interaction.gestures,...n.interaction.gestures})),n.rendering&&(o.rendering={...b.rendering,...n.rendering},n.rendering.responsive&&(o.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&&(o.rendering.ui={...b.rendering.ui,...n.rendering.ui}),n.rendering.performance&&(o.rendering.performance={...b.rendering.performance,...n.rendering.performance})),n.debug!==void 0&&(o.debug=n.debug),o}function he(n,t){return{...n?yt[n]:yt.playful,...t}}function de(n,t){return{...n?bt[n]:bt.gentle,...t}}function ue(n,t){return{...n?vt[n]:vt.gentle,...t}}class Lt{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 c=o??this.config.duration,a=s??this.config.easing.default,h=this.buildTransformString(e),l=this.buildTransformString(i);t.style.transition="none";const u=t.animate([{transform:h},{transform:l}],{duration:c,easing:a,fill:"forwards"}),r={id:`anim-${++this.animationIdCounter}`,element:t,animation:u,fromState:e,toState:i,startTime:performance.now(),duration:c};return this.activeAnimations.set(t,r),u.finished.then(()=>{t.style.transform=l,this.activeAnimations.delete(t)}).catch(()=>{this.activeAnimations.delete(t)}),r}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),c=Math.atan2(o.b,o.a)*(180/Math.PI),a=o.e,h=o.f;return{x:a,y:h,rotation:c,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 c=i??this.config.duration,a=o??this.config.easing.default;t.style.transition=`transform ${c}ms ${a}, box-shadow ${c}ms ${a}`,t.style.transform=this.buildTransformString(e),setTimeout(()=>{s()},c)})}resetTransform(t,e){return this.animateTransform(t,e)}clearTransition(t){t.style.transition=""}wait(t){return new Promise(e=>setTimeout(e,t))}}function at(n,t,e){return n+(t-n)*e}function ge(n,t,e,i){const{overshoot:o,bounces:s,decayRatio:c}=i,a=e.x-t.x,h=e.y-t.y,l=me(s,c);let u=0,r=0,d=1,f=o,y=!1;for(let g=0;g<l.length;g++)if(n<=l[g].time){r=g===0?0:l[g-1].time,d=l[g].time,f=l[g].overshoot,y=l[g].isOvershoot;break}const p=(n-r)/(d-r);if(y)u=1+f*gt(p);else if(r===0)u=gt(p);else{const g=l.find((v,w)=>v.time>r&&w>0&&l[w-1].isOvershoot),m=1+((g==null?void 0:g.overshoot)||f);u=at(m,1,gt(p))}return{x:t.x+a*u,y:t.y+h*u}}function me(n,t){const e=[];let i=.6;e.push({time:i,overshoot:0,isOvershoot:!1});let o=.15;const c=.4/(n*2);for(let a=0;a<n;a++)i+=c,e.push({time:i,overshoot:o,isOvershoot:!0}),i+=c,e.push({time:i,overshoot:o*t,isOvershoot:!1}),o*=t;return e.push({time:1,overshoot:0,isOvershoot:!1}),e}function fe(n,t,e,i){const{stiffness:o,damping:s,mass:c,oscillations:a}=i,h=e.x-t.x,l=e.y-t.y,u=Math.sqrt(o/c),r=s/(2*Math.sqrt(o*c));let d;if(r<1){const f=u*Math.sqrt(1-r*r),y=Math.exp(-r*u*n*3),p=Math.cos(f*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+l*d}}function pe(n,t,e,i){const{amplitude:o,frequency:s,decay:c,decayRate:a,phase:h}=i,l=e.x-t.x,u=e.y-t.y,r=Math.sqrt(l*l+u*u),d=r>0?-u/r:0,f=r>0?l/r:1,y=s*Math.PI*2*n+h,p=c?Math.pow(1-n,a):1,g=o*Math.sin(y)*p,m=ye(n);return{x:at(t.x,e.x,m)+g*d,y:at(t.y,e.y,m)+g*f}}function gt(n){return 1-(1-n)*(1-n)}function ye(n){return 1-Math.pow(1-n,3)}function be(n,t,e){const{amplitude:i,frequency:o,decay:s}=e,c=Math.sin(n*o*Math.PI*2),a=s?Math.pow(1-n,2):1,h=i*c*a;return t+h}function ve(n,t,e){const{overshoot:i,bounces:o}=e,s=[];s.push({time:.5,scale:i});let c=i;const a=.5,l=.5/(o*2);let u=.5;for(let d=0;d<o;d++){const f=1-(c-1)*a;u+=l,s.push({time:u,scale:f}),c=1+(c-1)*a*a,u+=l,d<o-1&&s.push({time:u,scale:c})}s.push({time:1,scale:1});let r=1;for(let d=0;d<s.length;d++)if(n<=s[d].time){const f=d===0?0:s[d-1].time,y=d===0?1:s[d-1].scale,p=(n-f)/(s[d].time-f),g=gt(p);r=y+(s[d].scale-y)*g;break}return r*t}function $t(n){const{element:t,startPosition:e,endPosition:i,pathConfig:o,duration:s,imageWidth:c,imageHeight:a,rotation:h,scale:l,onComplete:u,rotationConfig:r,startRotation:d,scaleConfig:f,startScale:y}=n,p=o.type,g=d!==void 0&&d!==h,m=(r==null?void 0:r.mode)==="wobble",v=(r==null?void 0:r.wobble)||{amplitude:15,frequency:3,decay:!0},w=g||m,E=y!==void 0&&y!==l,T=(f==null?void 0:f.mode)==="pop",x=(f==null?void 0:f.pop)||{overshoot:1.2,bounces:1};if((p==="linear"||p==="arc")&&!w&&!(E||T)){u&&u();return}const G=performance.now(),_=-c/2,P=-a/2;function U(W){const C=W-G,S=Math.min(C/s,1);let F;switch(p){case"bounce":{const j=he(o.bouncePreset,o.bounce);F=ge(S,e,i,j);break}case"elastic":{const j=de(o.elasticPreset,o.elastic);F=fe(S,e,i,j);break}case"wave":{const j=ue(o.wavePreset,o.wave);F=pe(S,e,i,j);break}default:F={x:at(e.x,i.x,S),y:at(e.y,i.y,S)}}const O=F.x-i.x,z=F.y-i.y;let R;m?R=be(S,h,v):g?R=at(d,h,S):R=h;let M;T?M=ve(S,l,x):E?M=at(y,l,S):M=l,t.style.transform=`translate(${_}px, ${P}px) translate(${O}px, ${z}px) rotate(${R}deg) scale(${M})`,S<1?requestAnimationFrame(U):(t.style.transform=`translate(${_}px, ${P}px) rotate(${h}deg) scale(${l})`,u&&u())}requestAnimationFrame(U)}function Ot(n){return n==="bounce"||n==="elastic"||n==="wave"}const we={radial:"center",spiral:"center",grid:"top",cluster:"nearest-edge",random:"nearest-edge",wave:"left"};class Dt{constructor(t,e){this.config=t,this.layoutAlgorithm=e,this.resolvedStartPosition=this.resolveStartPosition(),this.pathConfig=t.path||wt,this.rotationConfig=t.rotation||xt,this.scaleConfig=t.scale||St}resolveStartPosition(){return this.config.start.position?this.config.start.position:we[this.layoutAlgorithm]||"nearest-edge"}calculateStartPosition(t,e,i,o,s){const c=this.resolvedStartPosition,a=this.config.start.offset??100;switch(c){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,c=t.y,a=s,h=i.width-s,l=c,u=i.height-c,r=Math.min(a,h,l,u);let d=t.x,f=t.y;return r===a?d=-(e.width+o):r===h?d=i.width+o:r===l?f=-(e.height+o):f=i.height+o,{x:d,y:f}}calculateEdgePosition(t,e,i,o,s){let c=e.x,a=e.y;switch(t){case"top":a=-(i.height+s);break;case"bottom":a=o.height+s;break;case"left":c=-(i.width+s);break;case"right":c=o.width+s;break}return{x:c,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"],c=s[Math.floor(Math.random()*s.length)];return this.calculateEdgePosition(c,t,e,i,o)}calculateCircularPosition(t,e,i,o,s){const c=this.config.start.circular||{},a=c.distribution||"even";let h;const l=c.radius||"120%";if(typeof l=="string"&&l.endsWith("%")){const p=parseFloat(l)/100;h=Math.sqrt(i.width**2+i.height**2)*p/2}else h=typeof l=="number"?l:500;let u;a==="even"?u=o/s*2*Math.PI:u=Math.random()*2*Math.PI;const r=i.width/2,d=i.height/2,f=r+Math.cos(u)*h,y=d+Math.sin(u)*h;return{x:f,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,c,a,h){const l=t.x-e.x,u=t.y-e.y,r=a!==void 0?a:i,d=h!==void 0?h:o,f=s!==void 0?-s/2:0,y=c!==void 0?-c/2:0,p=s!==void 0?`translate(${f}px, ${y}px)`:"translate(-50%, -50%)";return t.useScale?`${p} translate(${l}px, ${u}px) rotate(${r}deg) scale(0)`:`${p} translate(${l}px, ${u}px) rotate(${r}deg) scale(${d})`}buildFinalTransform(t,e,i,o){if(i!==void 0&&o!==void 0){const s=-i/2,c=-o/2;return`translate(${s}px, ${c}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 Ot(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;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:o,frequency:s,decay:c}=i,a=Math.sin(t*s*Math.PI*2),h=c?Math.pow(1-t,2):1,l=o*a*h;return e+l}getScaleConfig(){return this.scaleConfig}getScaleMode(){return this.scaleConfig.mode}calculateStartScale(t){switch(this.scaleConfig.mode){case"none":return t;case"grow":return(this.scaleConfig.startScale??.3)*t;case"shrink":return(this.scaleConfig.startScale??1.5)*t;case"pop":return t;case"random":{const 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,c=this.generateScaleBounceKeyframes(s,o);let a=e;for(let h=0;h<c.length;h++)if(t<=c[h].time){const l=h===0?0:c[h-1].time,u=h===0?e:c[h-1].scale,r=(t-l)/(c[h].time-l),d=this.easeOutQuad(r);a=u+(c[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 l=0;l<t;l++){const u=1-(o-1)*s;h+=a,i.push({time:h,scale:u}),o=1+(o-1)*s*s,h+=a,l<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 Pt{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){var x,$,G,_,P,U,W,C,S;const o=[],{width:s,height:c}=e,a=this.config.spacing.padding,h=i.fixedHeight??200,l=((x=this.imageConfig.rotation)==null?void 0:x.mode)??"none",u=((G=($=this.imageConfig.rotation)==null?void 0:$.range)==null?void 0:G.min)??-15,r=((P=(_=this.imageConfig.rotation)==null?void 0:_.range)==null?void 0:P.max)??15,d=((W=(U=this.imageConfig.sizing)==null?void 0:U.variance)==null?void 0:W.min)??1,f=((S=(C=this.imageConfig.sizing)==null?void 0:C.variance)==null?void 0:S.max)??1,y=d!==1||f!==1,g=h*1.5/2,m=h/2,v=s-a-g,w=c-a-m,E=a+g,T=a+m;for(let F=0;F<t;F++){const O=this.random(E,v),z=this.random(T,w),R=l==="random"?this.random(u,r):0,M=y?this.random(d,f):1,j=h*M,K={id:F,x:O,y:z,rotation:R,scale:M,baseSize:j};o.push(K)}return o}random(t,e){return Math.random()*(e-t)+t}}class Ut{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){var $,G,_,P,U,W,C,S,F;const o=[],{width:s,height:c}=e,{debugRadials:a}=this.config,h=i.fixedHeight??200,l=(($=this.imageConfig.rotation)==null?void 0:$.mode)??"none",u=((_=(G=this.imageConfig.rotation)==null?void 0:G.range)==null?void 0:_.min)??-15,r=((U=(P=this.imageConfig.rotation)==null?void 0:P.range)==null?void 0:U.max)??15,d=((C=(W=this.imageConfig.sizing)==null?void 0:W.variance)==null?void 0:C.min)??1,f=((F=(S=this.imageConfig.sizing)==null?void 0:S.variance)==null?void 0:F.max)??1,y=d!==1||f!==1,p=this.config.scaleDecay??0,g=["green","blue","red","yellow","orange","purple"],m=i.fixedHeight??h,v=s/2,w=c/2,E=Math.ceil(Math.sqrt(t));if(t>0){const O=y?this.random(d,f):1,z=m*O;o.push({id:0,x:v,y:w,rotation:l==="random"?this.random(u*.33,r*.33):0,scale:O,baseSize:z,zIndex:100,borderColor:a?"cyan":void 0})}let T=1,x=1;for(;T<t;){const O=x/E,z=p>0?1-O*p*.5:1,R=x*(m*.8),M=R*1.5,j=Math.PI*(3*(M+R)-Math.sqrt((3*M+R)*(M+3*R))),K=this.estimateWidth(m),X=Math.floor(j/(K*.7));if(X===0){x++;continue}const V=2*Math.PI/X,Q=x*(20*Math.PI/180);for(let q=0;q<X&&T<t;q++){const tt=q*V+Q,et=y?this.random(d,f):1,Y=z*et,it=m*Y;let B=v+Math.cos(tt)*M,L=w+Math.sin(tt)*R;const D=this.config.spacing.padding??50,k=it*1.5/2,H=it/2;B-k<D?B=D+k:B+k>s-D&&(B=s-D-k),L-H<D?L=D+H:L+H>c-D&&(L=c-D-H);const nt=l==="random"?this.random(u,r):0;o.push({id:T,x:B,y:L,rotation:nt,scale:Y,baseSize:it,zIndex:Math.max(1,100-x),borderColor:a?g[(x-1)%g.length]:void 0}),T++}x++}return o}estimateWidth(t){return t*1.4}random(t,e){return Math.random()*(e-t)+t}}const xe={columns:"auto",rows:"auto",stagger:"none",jitter:0,overlap:0,fillDirection:"row",alignment:"center",gap:10,overflowOffset:.25},_t=[{x:1,y:1},{x:-1,y:-1},{x:1,y:-1},{x:-1,y:1},{x:-1,y:0},{x:1,y:0},{x:0,y:-1},{x:0,y:1}];class Ht{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){var X,V,Q,q,tt,et,Y,it,B;const o=[],{width:s,height:c}=e,a={...xe,...this.config.grid},h=this.config.spacing.padding,l=i.fixedHeight??200,u=((X=this.imageConfig.rotation)==null?void 0:X.mode)??"none",r=((Q=(V=this.imageConfig.sizing)==null?void 0:V.variance)==null?void 0:Q.min)??1,d=((tt=(q=this.imageConfig.sizing)==null?void 0:q.variance)==null?void 0:tt.max)??1,f=r!==1||d!==1,y=s-2*h,p=c-2*h,{columns:g,rows:m}=this.calculateGridDimensions(t,y,p,l,a),v=a.stagger==="row",w=a.stagger==="column",E=v?g+.5:g,T=w?m+.5:m,x=(y-a.gap*(g-1))/E,$=(p-a.gap*(m-1))/T,G=v?x/2:0,_=w?$/2:0,P=1+a.overlap,U=Math.min(x,$)*P,W=i.fixedHeight?Math.min(i.fixedHeight,U):U,C=g*x+(g-1)*a.gap+G,S=m*$+(m-1)*a.gap+_,F=h+(y-C)/2,O=h+(p-S)/2,z=g*m,R=a.columns!=="auto"&&a.rows!=="auto",M=R&&t>z;typeof window<"u"&&(window.__gridOverflowDebug={gridConfigColumns:a.columns,gridConfigRows:a.rows,columns:g,rows:m,cellCount:z,hasFixedGrid:R,imageCount:t,isOverflowMode:M});const j=M?new Array(z).fill(0):[],K=Math.min(x,$)*a.overflowOffset;for(let L=0;L<t;L++){let D,N,k=0;if(M&&L>=z){const Z=L-z,J=Z%z;k=Math.floor(Z/z)+1,j[J]++,a.fillDirection==="row"?(D=J%g,N=Math.floor(J/g)):(N=J%m,D=Math.floor(J/m))}else a.fillDirection==="row"?(D=L%g,N=Math.floor(L/g)):(N=L%m,D=Math.floor(L/m));let H=F+D*(x+a.gap)+x/2,nt=O+N*($+a.gap)+$/2;if(a.stagger==="row"&&N%2===1?H+=x/2:a.stagger==="column"&&D%2===1&&(nt+=$/2),k>0){const Z=(k-1)%_t.length,J=_t[Z];H+=J.x*K,nt+=J.y*K}if(a.jitter>0){const Z=x/2*a.jitter,J=$/2*a.jitter;H+=this.random(-Z,Z),nt+=this.random(-J,J)}let ot=H,rt=nt;if(!M&&a.fillDirection==="row"){const Z=t%g||g;if(N===Math.floor((t-1)/g)&&Z<g){const te=Z*x+(Z-1)*a.gap;let Mt=0;a.alignment==="center"?Mt=(C-te)/2:a.alignment==="end"&&(Mt=C-te),ot+=Mt}}const It=f?this.random(r,d):1,ct=W*It,ft=ct*1.5/2,pt=ct/2,Rt=h+ft,At=s-h-ft,Me=h+pt,ze=c-h-pt;ot=Math.max(Rt,Math.min(ot,At)),rt=Math.max(Me,Math.min(rt,ze));let Tt=0;if(u==="random"){const Z=((Y=(et=this.imageConfig.rotation)==null?void 0:et.range)==null?void 0:Y.min)??-15,J=((B=(it=this.imageConfig.rotation)==null?void 0:it.range)==null?void 0:B.max)??15;a.jitter>0?Tt=this.random(Z*a.jitter,J*a.jitter):Tt=this.random(Z,J)}let Ft;M&&k>0?Ft=50-k:Ft=M?100+L:L+1,o.push({id:L,x:ot,y:rt,rotation:Tt,scale:It,baseSize:ct,zIndex:Ft})}return o}calculateGridDimensions(t,e,i,o,s){let c,a;if(s.columns!=="auto"&&s.rows!=="auto")c=s.columns,a=s.rows;else if(s.columns!=="auto")c=s.columns,a=Math.ceil(t/c);else if(s.rows!=="auto")a=s.rows,c=Math.ceil(t/a);else{const h=e/i;for(c=Math.max(1,Math.round(Math.sqrt(t*h/1.4))),a=Math.ceil(t/c);c>1&&(c-1)*a>=t;)c--}return{columns:Math.max(1,c),rows:Math.max(1,a)}}random(t,e){return Math.random()*(e-t)+t}}const Se=Math.PI*(3-Math.sqrt(5)),Ie={spiralType:"golden",direction:"counterclockwise",tightness:1,scaleDecay:0,startAngle:0};class jt{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){var T,x,$,G,_,P,U,W,C;const o=[],{width:s,height:c}=e,a={...Ie,...this.config.spiral},h=this.config.spacing.padding,l=i.fixedHeight??200,u=((T=this.imageConfig.rotation)==null?void 0:T.mode)??"none",r=(($=(x=this.imageConfig.rotation)==null?void 0:x.range)==null?void 0:$.min)??-15,d=((_=(G=this.imageConfig.rotation)==null?void 0:G.range)==null?void 0:_.max)??15,f=((U=(P=this.imageConfig.sizing)==null?void 0:P.variance)==null?void 0:U.min)??1,y=((C=(W=this.imageConfig.sizing)==null?void 0:W.variance)==null?void 0:C.max)??1,p=f!==1||y!==1,g=this.config.scaleDecay??a.scaleDecay,m=s/2,v=c/2,w=Math.min(m-h-l/2,v-h-l/2),E=a.direction==="clockwise"?-1:1;for(let S=0;S<t;S++){let F,O;if(a.spiralType==="golden")F=S*Se*E+a.startAngle,O=this.calculateGoldenRadius(S,t,w,a.tightness);else if(a.spiralType==="archimedean"){const H=S*.5*a.tightness;F=H*E+a.startAngle,O=this.calculateArchimedeanRadius(H,t,w,a.tightness)}else{const H=S*.3*a.tightness;F=H*E+a.startAngle,O=this.calculateLogarithmicRadius(H,t,w,a.tightness)}const z=m+Math.cos(F)*O,R=v+Math.sin(F)*O,M=O/w,j=g>0?1-M*g*.5:1,K=p?this.random(f,y):1,X=j*K,V=l*X,q=V*1.5/2,tt=V/2,et=h+q,Y=s-h-q,it=h+tt,B=c-h-tt,L=Math.max(et,Math.min(z,Y)),D=Math.max(it,Math.min(R,B));let N=0;if(u==="random"){const H=F*180/Math.PI%360,nt=this.random(r,d);N=a.spiralType==="golden"?nt:H*.1+nt*.9}else u==="tangent"&&(N=this.calculateSpiralTangent(F,O,a));const k=t-S;o.push({id:S,x:L,y:D,rotation:N,scale:X,baseSize:V,zIndex:k})}return o}calculateSpiralTangent(t,e,i){let o;if(i.spiralType==="golden")o=t+Math.PI/2;else if(i.spiralType==="archimedean"){const c=1/i.tightness,a=Math.atan(e/c);o=t+a}else{const c=.15/i.tightness,a=Math.atan(1/c);o=t+a}return o*180/Math.PI%360-90}calculateGoldenRadius(t,e,i,o){const c=i/Math.sqrt(e)*Math.sqrt(t)/o;return Math.min(c,i)}calculateArchimedeanRadius(t,e,i,o){const s=e*.5*o;return t/s*i}calculateLogarithmicRadius(t,e,i,o){const s=i*.05,c=.15/o,a=s*Math.exp(c*t),h=e*.3*o,l=s*Math.exp(c*h);return a/l*i}random(t,e){return Math.random()*(e-t)+t}}const Ee={clusterCount:"auto",clusterSpread:150,clusterSpacing:200,density:"uniform",overlap:.3,distribution:"gaussian"};class Gt{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){var E,T,x,$,G,_,P,U,W;const o=[],{width:s,height:c}=e,a={...Ee,...this.config.cluster},h=this.config.spacing.padding,l=i.fixedHeight??200,u=((E=this.imageConfig.rotation)==null?void 0:E.mode)??"none",r=((x=(T=this.imageConfig.rotation)==null?void 0:T.range)==null?void 0:x.min)??-15,d=((G=($=this.imageConfig.rotation)==null?void 0:$.range)==null?void 0:G.max)??15,f=((P=(_=this.imageConfig.sizing)==null?void 0:_.variance)==null?void 0:P.min)??1,y=((W=(U=this.imageConfig.sizing)==null?void 0:U.variance)==null?void 0:W.max)??1,p=f!==1||y!==1,g=this.calculateClusterCount(t,a.clusterCount,s,c,a.clusterSpacing),m=this.generateClusterCenters(g,s,c,h,a),v=new Array(g).fill(0);for(let C=0;C<t;C++)v[C%g]++;let w=0;for(let C=0;C<g;C++){const S=m[C],F=v[C];for(let O=0;O<F;O++){let z,R;if(a.distribution==="gaussian")z=this.gaussianRandom()*S.spread,R=this.gaussianRandom()*S.spread;else{const N=this.random(0,Math.PI*2),k=this.random(0,S.spread);z=Math.cos(N)*k,R=Math.sin(N)*k}const M=1+a.overlap*.5,j=1+a.overlap*.3;z/=M,R/=M;const K=p?this.random(f,y):1,X=j*K,V=l*X;let Q=S.x+z,q=S.y+R;const et=V*1.5/2,Y=V/2;Q=Math.max(h+et,Math.min(Q,s-h-et)),q=Math.max(h+Y,Math.min(q,c-h-Y));const it=u==="random"?this.random(r,d):0,L=Math.sqrt(z*z+R*R)/S.spread,D=Math.round((1-L)*50)+1;o.push({id:w,x:Q,y:q,rotation:it,scale:X,baseSize:V,zIndex:D}),w++}}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 c=[],h=o+s.clusterSpread,l=e-o-s.clusterSpread,u=o+s.clusterSpread,r=i-o-s.clusterSpread;for(let d=0;d<t;d++){let f=null,y=-1;for(let p=0;p<100;p++){const g={x:this.random(h,l),y:this.random(u,r),spread:this.calculateClusterSpread(s)};let m=1/0;for(const v of c){const w=g.x-v.x,E=g.y-v.y,T=Math.sqrt(w*w+E*E);m=Math.min(m,T)}if((c.length===0||m>y)&&(f=g,y=m),m>=s.clusterSpacing)break}f&&c.push(f)}return c}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 Re{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){var M,j,K,X,V,Q,q,tt,et;const o=[],{width:s,height:c}=e,a=i.fixedHeight??200,h=this.config.spacing.padding??50,l=((M=this.imageConfig.rotation)==null?void 0:M.mode)??"none",u=((K=(j=this.imageConfig.rotation)==null?void 0:j.range)==null?void 0:K.min)??-15,r=((V=(X=this.imageConfig.rotation)==null?void 0:X.range)==null?void 0:V.max)??15,d=((q=(Q=this.imageConfig.sizing)==null?void 0:Q.variance)==null?void 0:q.min)??1,f=((et=(tt=this.imageConfig.sizing)==null?void 0:tt.variance)==null?void 0:et.max)??1,y=d!==1||f!==1,p=i.fixedHeight??a,g={...ee,...this.config.wave},{rows:m,amplitude:v,frequency:w,phaseShift:E,synchronization:T}=g,x=Math.ceil(t/m),_=p*1.5/2,P=h+_,U=s-h-_,W=U-P,C=x>1?W/(x-1):0,S=h+v+p/2,F=c-h-v-p/2,O=F-S,z=m>1?O/(m-1):0;let R=0;for(let Y=0;Y<m&&R<t;Y++){const it=m===1?(S+F)/2:S+Y*z;let B=0;T==="offset"?B=Y*E:T==="alternating"&&(B=Y*Math.PI);for(let L=0;L<x&&R<t;L++){const D=x===1?(P+U)/2:P+L*C,N=this.calculateWaveY(D,s,v,w,B),k=D,H=it+N,nt=y?this.random(d,f):1,ot=p*nt;let rt=0;l==="tangent"?rt=this.calculateRotation(D,s,v,w,B):l==="random"&&(rt=this.random(u,r));const ct=ot*1.5/2,Et=ot/2,ft=h+ct,pt=s-h-ct,Rt=h+Et,At=c-h-Et;o.push({id:R,x:Math.max(ft,Math.min(k,pt)),y:Math.max(Rt,Math.min(H,At)),rotation:rt,scale:nt,baseSize:ot,zIndex:R+1}),R++}}return o}calculateWaveY(t,e,i,o,s){const c=t/e;return i*Math.sin(o*c*2*Math.PI+s)}calculateRotation(t,e,i,o,s){const c=t/e,a=i*o*2*Math.PI*Math.cos(o*c*2*Math.PI+s)/e;return Math.atan(a)*(180/Math.PI)}random(t,e){return Math.random()*(e-t)+t}}class Wt{constructor(t){this.config=t.layout,this.imageConfig=t.image,this.layouts=new Map,this.generator=this.initGenerator()}initGenerator(){switch(this.config.algorithm){case"radial":return new Ut(this.config,this.imageConfig);case"grid":return new Ht(this.config,this.imageConfig);case"spiral":return new jt(this.config,this.imageConfig);case"cluster":return new Gt(this.config,this.imageConfig);case"wave":return new Re(this.config,this.imageConfig);case"random":default:return new Pt(this.config,this.imageConfig)}}generateLayout(t,e,i={}){const o=this.generator.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.generator=this.initGenerator())),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,c=this.resolveBaseHeight(o);if(c!==void 0)return{height:c};const a=(s==null?void 0:s.minSize)??50,h=(s==null?void 0:s.maxSize)??400,l=this.config.targetCoverage??.6,u=this.config.densityFactor??1,{width:r,height:d}=t,p=r*d*l/e;let m=Math.sqrt(p/1.4);m*=u,m=Math.min(m,i);let v=this.clamp(m,a,h);if(v===a&&m<a){const w=Math.max(a*.05,20);v=Math.max(w,m)}return{height:v}}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 Ae(n){return n in st}function Te(n){return n?Ae(n)?st[n]:n:st.md}function Fe(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 ht(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 mt(n){var s,c;if(!n)return{};const t={};if(n.borderRadiusTopLeft!==void 0||n.borderRadiusTopRight!==void 0||n.borderRadiusBottomRight!==void 0||n.borderRadiusBottomLeft!==void 0){const a=((s=n.border)==null?void 0:s.radius)??0;n.borderRadiusTopLeft!==void 0?t.borderTopLeftRadius=`${n.borderRadiusTopLeft}px`:a&&(t.borderTopLeftRadius=`${a}px`),n.borderRadiusTopRight!==void 0?t.borderTopRightRadius=`${n.borderRadiusTopRight}px`:a&&(t.borderTopRightRadius=`${a}px`),n.borderRadiusBottomRight!==void 0?t.borderBottomRightRadius=`${n.borderRadiusBottomRight}px`:a&&(t.borderBottomRightRadius=`${a}px`),n.borderRadiusBottomLeft!==void 0?t.borderBottomLeftRadius=`${n.borderRadiusBottomLeft}px`:a&&(t.borderBottomLeftRadius=`${a}px`)}else((c=n.border)==null?void 0:c.radius)!==void 0&&(t.borderRadius=`${n.border.radius}px`);if(n.borderTop||n.borderRight||n.borderBottom||n.borderLeft){const a=n.border||{},h={...a,...n.borderTop},l={...a,...n.borderRight},u={...a,...n.borderBottom},r={...a,...n.borderLeft};t.borderTop=ht(h),t.borderRight=ht(l),t.borderBottom=ht(u),t.borderLeft=ht(r)}else n.border&&(t.border=ht(n.border));n.shadow!==void 0&&(t.boxShadow=Te(n.shadow));const o=Fe(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 a=n.outline.width??0,h=n.outline.style??"solid",l=n.outline.color??"#000000";t.outline=`${a}px ${h} ${l}`,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 dt(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 Nt(n){return n?Array.isArray(n)?n.join(" "):n:""}function ut(n,t){const e=Nt(t);e&&e.split(" ").forEach(i=>{i.trim()&&n.classList.add(i.trim())})}function kt(n,t){const e=Nt(t);e&&e.split(" ").forEach(i=>{i.trim()&&n.classList.remove(i.trim())})}const qt={UNFOCUSING:999,FOCUSING:1e3};class Yt{constructor(t,e,i){var o,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=mt(i==null?void 0:i.default),this.focusedStyles=mt(i==null?void 0:i.focused),this.defaultClassName=(o=i==null?void 0:i.default)==null?void 0:o.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 o=this.normalizeScalePercent(this.config.scalePercent),s=i.height*o,c=t/e;let a=s,h=a*c;const l=i.width*o;return h>l&&(h=l,a=h/c),{width:h,height:a}}calculateFocusTransform(t,e){const i=t.width/2,o=t.height/2,s=i-e.x,c=o-e.y;return{x:s,y:c,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,c,a,h){const l=this.buildDimensionZoomTransform(e),u=this.buildDimensionZoomTransform(i);return t.style.transition="none",t.animate([{transform:l,width:`${o}px`,height:`${s}px`},{transform:u,width:`${c}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"),dt(t,this.focusedStyles),ut(t,this.focusedClassName)}removeFocusedStyling(t,e){t.style.zIndex=e,t.classList.remove("fbn-ic-focused"),kt(t,this.focusedClassName),dt(t,this.defaultStyles),ut(t,this.defaultClassName)}startFocusAnimation(t,e,i,o,s){const c=t.style.zIndex||"",a=t.offsetWidth,h=t.offsetHeight,l=this.calculateFocusDimensions(a,h,e),u=this.calculateFocusTransform(e,i);this.applyFocusedStyling(t,qt.FOCUSING),this.animationEngine.cancelAllAnimations(t);const r=o??{x:0,y:0,rotation:i.rotation,scale:1},d=(s==null?void 0:s.width)??a,f=(s==null?void 0:s.height)??h,y=this.config.animationDuration??600,p=this.animateWithDimensions(t,r,u,d,f,l.width,l.height,y),g={id:`focus-${Date.now()}`,element:t,animation:p,fromState:r,toState:u,startTime:performance.now(),duration:y};return this.focusData={element:t,originalState:i,focusTransform:u,originalZIndex:c,originalWidth:a,originalHeight:h,focusWidth:l.width,focusHeight:l.height},{element:t,originalState:i,animationHandle:g,direction:"in",originalWidth:a,originalHeight:h}}startUnfocusAnimation(t,e,i,o){var y,p,g,m,v;t.style.zIndex=String(qt.UNFOCUSING),this.animationEngine.cancelAllAnimations(t);const s=i??((y=this.focusData)==null?void 0:y.focusTransform)??{x:0,y:0,rotation:0,scale:1},c=(o==null?void 0:o.width)??((p=this.focusData)==null?void 0:p.focusWidth)??t.offsetWidth,a=(o==null?void 0:o.height)??((g=this.focusData)==null?void 0:g.focusHeight)??t.offsetHeight,h={x:0,y:0,rotation:e.rotation,scale:1},l=((m=this.focusData)==null?void 0:m.originalWidth)??t.offsetWidth,u=((v=this.focusData)==null?void 0:v.originalHeight)??t.offsetHeight,r=this.config.animationDuration??600,d=this.animateWithDimensions(t,s,h,c,a,l,u,r),f={id:`unfocus-${Date.now()}`,element:t,animation:d,fromState:s,toState:h,startTime:performance.now(),duration:r};return{element:t,originalState:e,animationHandle:f,direction:"out",originalWidth:l,originalHeight:u}}async waitForAnimation(t){try{await t.animation.finished}catch{}}resetElementInstantly(t,e,i,o,s){this.animationEngine.cancelAllAnimations(t);const c=["translate(-50%, -50%)"];c.push("translate(0px, 0px)"),c.push(`rotate(${e.rotation}deg)`),t.style.transition="none",t.style.transform=c.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){var s,c,a,h,l,u,r,d,f,y,p,g;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),v={x:m.x,y:m.y,rotation:m.rotation,scale:1},w={width:t.offsetWidth,height:t.offsetHeight};this.outgoing=this.startUnfocusAnimation(t,this.incoming.originalState,v,w),this.incoming=null,this.state=I.UNFOCUSING,await this.waitForAnimation(this.outgoing.animationHandle),this.removeFocusedStyling(this.outgoing.element,((c=this.focusData)==null?void 0:c.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,((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,((h=this.focusData)==null?void 0:h.originalZIndex)||"",(l=this.focusData)==null?void 0:l.originalWidth,(u=this.focusData)==null?void 0:u.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,((r=this.outgoing.originalState.zIndex)==null?void 0:r.toString())||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=I.FOCUSED;break;case I.CROSS_ANIMATING:if(((d=this.incoming)==null?void 0:d.element)===t)return;if(((f=this.outgoing)==null?void 0:f.element)===t){const m=this.animationEngine.cancelAnimation(this.outgoing.animationHandle,!0),v={x:m.x,y:m.y,rotation:m.rotation,scale:1},w={width:t.offsetWidth,height:t.offsetHeight};if(this.incoming){const E=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),T={x:E.x,y:E.y,rotation:E.rotation,scale:1},x={width:this.incoming.element.offsetWidth,height:this.incoming.element.offsetHeight};this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,T,x)}else this.outgoing=null;if(this.incoming=this.startFocusAnimation(t,e,i,v,w),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,((y=this.outgoing.originalState.zIndex)==null?void 0:y.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,((p=this.outgoing.originalState.zIndex)==null?void 0:p.toString())||"",this.outgoing.originalWidth,this.outgoing.originalHeight),this.outgoing=null),this.incoming){const m=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),v={x:m.x,y:m.y,rotation:m.rotation,scale:1},w={width:this.incoming.element.offsetWidth,height:this.incoming.element.offsetHeight};this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,v,w)}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,((g=this.outgoing.originalState.zIndex)==null?void 0:g.toString())||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=I.FOCUSED;break}}async unfocusImage(){var s,c,a;const t=++this.focusGeneration;if(!this.currentFocus||!this.focusData){if(this.incoming&&this.state===I.FOCUSING){const h=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),l={x:h.x,y:h.y,rotation:h.rotation,scale:1},u={width:this.incoming.element.offsetWidth,height:this.incoming.element.offsetHeight};if(this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,l,u),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 h=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),l={x:h.x,y:h.y,rotation:h.rotation,scale:1},u={width:this.incoming.element.offsetWidth,height:this.incoming.element.offsetHeight},r=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,l,u);if(await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(r.animationHandle)]),this.focusGeneration!==t)return;this.outgoing&&this.removeFocusedStyling(this.outgoing.element,((c=this.outgoing.originalState.zIndex)==null?void 0:c.toString())||""),this.removeFocusedStyling(r.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,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){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}reset(){var t,e,i,o;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,(o=this.focusData)==null?void 0:o.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}}class Bt{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(e.type==="folder")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(e.type==="files"){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`,c=`${this.apiEndpoint}?q=${encodeURIComponent(o)}&fields=files(id,name,mimeType,thumbnailLink)&key=${this.apiKey}`,a=await fetch(c);if(!a.ok)throw new Error(`API request failed: ${a.status} ${a.statusText}`);const l=(await a.json()).files.filter(u=>u.mimeType.startsWith("image/")&&e.isAllowed(u.name));return this.log(`Found ${l.length} images in folder ${t} (non-recursive)`),l.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 c=`${this.apiEndpoint}/${s}?fields=name,mimeType&key=${this.apiKey}`,a=await fetch(c);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(c){this.log(`Error fetching metadata for file ${s}:`,c)}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`,c=`${this.apiEndpoint}?q=${encodeURIComponent(o)}&fields=files(id,name,mimeType,thumbnailLink)&key=${this.apiKey}`,a=await fetch(c);if(!a.ok)throw new Error(`API request failed: ${a.status} ${a.statusText}`);const h=await a.json(),l=h.files.filter(r=>r.mimeType.startsWith("image/")&&e.isAllowed(r.name)),u=h.files.filter(r=>r.mimeType==="application/vnd.google-apps.folder");this.log(`Found ${h.files.length} total items in folder ${t}`),h.files.forEach(r=>this.log(` - File: ${r.name} (${r.mimeType})`)),this.log(`- ${l.length} valid files (images only)`),this.log(`- ${u.length} subfolders`),l.forEach(r=>{i.push(`https://lh3.googleusercontent.com/d/${r.id}=s1600`),this.log(`Added file: ${r.name}`)});for(const r of u){this.log(`Loading images from subfolder: ${r.name}`);const d=await this.loadImagesRecursively(r.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(),c=/\/file\/d\/([a-zA-Z0-9_-]+)/g,a=[...s.matchAll(c)];return[...new Set(a.map(u=>u[1]))].map(u=>`https://drive.google.com/uc?export=view&id=${u}`)}catch(i){throw console.error("Direct loading failed:",i),new Error(`Unable to load images. Please ensure:
|
|
1
|
+
(function(R,st){typeof exports=="object"&&typeof module<"u"?st(exports):typeof define=="function"&&define.amd?define(["exports"],st):(R=typeof globalThis<"u"?globalThis:R||self,st(R.ImageCloud={}))})(this,function(R){"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})}),St=Object.freeze({type:"linear"}),xt=Object.freeze({mode:"none"}),Et=Object.freeze({mode:"none"}),Lt=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"})}),ne=Object.freeze({rows:1,amplitude:100,frequency:2,phaseShift:0,synchronization:"offset"}),oe=Object.freeze({mobile:Object.freeze({maxWidth:767}),tablet:Object.freeze({maxWidth:1199})}),se=Object.freeze({mode:"adaptive",minSize:50,maxSize:400,variance:Object.freeze({min:1,max:1})}),ae=Object.freeze({mode:"none",range:Object.freeze({min:-15,max:15})}),Ot=Object.freeze({sizing:se,rotation:ae}),y=Object.freeze({loader:Object.freeze({type:"googleDrive",googleDrive:Object.freeze({apiKey:"",sources:[],apiEndpoint:"https://www.googleapis.com/drive/v3/files",allowedExtensions:["jpg","jpeg","png","gif","webp","bmp"],debugLogging:!1}),static:Object.freeze({sources:[],validateUrls:!0,validationTimeout:5e3,validationMethod:"head",failOnAllMissing:!0,allowedExtensions:["jpg","jpeg","png","gif","webp","bmp"],debugLogging:!1})}),image:Ot,layout:Object.freeze({algorithm:"radial",scaleDecay:0,responsive:oe,targetCoverage:.6,densityFactor:1,spacing:Object.freeze({padding:50,minGap:20}),debugRadials:!1,debugCenters:!1}),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:St,rotation:xt,scale:Et})}),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:void 0,showThumbnails:void 0,theme:void 0}),performance:Object.freeze({lazyLoad:void 0,preloadCount:void 0,imageQuality:void 0})}),styling:Lt,debug:!1});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 re(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 ce(o,t){var i,n,s,r,a,h,l,u;if(!t)return{...o};const e={...o};if(t.sizing!==void 0&&(e.sizing={...o.sizing,...t.sizing},t.sizing.variance)){const c=t.sizing.variance,d=c.min!==void 0&&c.min>=.25&&c.min<=1?c.min:((n=(i=o.sizing)==null?void 0:i.variance)==null?void 0:n.min)??1,f=c.max!==void 0&&c.max>=1&&c.max<=1.75?c.max:((r=(s=o.sizing)==null?void 0:s.variance)==null?void 0:r.max)??1;e.sizing.variance={min:d,max:f}}if(t.rotation!==void 0&&(e.rotation={...o.rotation,...t.rotation},t.rotation.range)){const c=t.rotation.range,d=c.min!==void 0&&c.min>=-180&&c.min<=0?c.min:((h=(a=o.rotation)==null?void 0:a.range)==null?void 0:h.min)??-15,f=c.max!==void 0&&c.max>=0&&c.max<=180?c.max:((u=(l=o.rotation)==null?void 0:l.range)==null?void 0:u.max)??15;e.rotation.range={min:d,max:f}}return e}function le(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 he(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 de(o={}){var s;const t=le(o),e=he(o);let i=o.image;(t||e)&&(i={...e||{},...t||{},...i},i.rotation&&(t!=null&&t.rotation)&&((s=o.image)!=null&&s.rotation)&&(i.rotation={...t.rotation,...o.image.rotation}));const n={loader:{...y.loader},image:ce(Ot,i),layout:{...y.layout},animation:{...y.animation},interaction:{...y.interaction},rendering:{...y.rendering},styling:re(Lt,o.styling),debug:y.debug};return o.loader&&(n.loader={...y.loader,...o.loader},o.loader.googleDrive&&(n.loader.googleDrive={...y.loader.googleDrive,...o.loader.googleDrive,sources:o.loader.googleDrive.sources||y.loader.googleDrive.sources,allowedExtensions:o.loader.googleDrive.allowedExtensions||y.loader.googleDrive.allowedExtensions}),o.loader.static&&(n.loader.static={...y.loader.static,...o.loader.static,sources:o.loader.static.sources||y.loader.static.sources,allowedExtensions:o.loader.static.allowedExtensions||y.loader.static.allowedExtensions})),o.layout&&(n.layout={...y.layout,...o.layout},o.layout.responsive&&(n.layout.responsive={...y.layout.responsive,mobile:o.layout.responsive.mobile?{...y.layout.responsive.mobile,...o.layout.responsive.mobile}:y.layout.responsive.mobile,tablet:o.layout.responsive.tablet?{...y.layout.responsive.tablet,...o.layout.responsive.tablet}:y.layout.responsive.tablet}),o.layout.spacing&&(n.layout.spacing={...y.layout.spacing,...o.layout.spacing})),o.animation&&(n.animation={...y.animation,...o.animation},o.animation.easing&&(n.animation.easing={...y.animation.easing,...o.animation.easing}),o.animation.queue&&(n.animation.queue={...y.animation.queue,...o.animation.queue}),o.animation.performance&&(n.animation.performance={...y.animation.performance,...o.animation.performance}),o.animation.entry&&(n.animation.entry={...y.animation.entry,...o.animation.entry,start:o.animation.entry.start?{...y.animation.entry.start,...o.animation.entry.start,circular:o.animation.entry.start.circular?{...y.animation.entry.start.circular,...o.animation.entry.start.circular}:y.animation.entry.start.circular}:y.animation.entry.start,timing:o.animation.entry.timing?{...y.animation.entry.timing,...o.animation.entry.timing}:y.animation.entry.timing,path:o.animation.entry.path?{...St,...o.animation.entry.path}:y.animation.entry.path,rotation:o.animation.entry.rotation?{...xt,...o.animation.entry.rotation}:y.animation.entry.rotation,scale:o.animation.entry.scale?{...Et,...o.animation.entry.scale}:y.animation.entry.scale})),o.interaction&&(n.interaction={...y.interaction,...o.interaction},o.interaction.focus&&(n.interaction.focus={...y.interaction.focus,...o.interaction.focus}),o.interaction.navigation&&(n.interaction.navigation={...y.interaction.navigation,...o.interaction.navigation}),o.interaction.gestures&&(n.interaction.gestures={...y.interaction.gestures,...o.interaction.gestures})),o.rendering&&(n.rendering={...y.rendering,...o.rendering},o.rendering.responsive&&(n.rendering.responsive={...y.rendering.responsive,...o.rendering.responsive,breakpoints:o.rendering.responsive.breakpoints?{...y.rendering.responsive.breakpoints,...o.rendering.responsive.breakpoints}:y.rendering.responsive.breakpoints,mobileDetection:o.rendering.responsive.mobileDetection?o.rendering.responsive.mobileDetection:y.rendering.responsive.mobileDetection}),o.rendering.ui&&(n.rendering.ui={...y.rendering.ui,...o.rendering.ui}),o.rendering.performance&&(n.rendering.performance={...y.rendering.performance,...o.rendering.performance})),o.debug!==void 0&&(n.debug=o.debug),n}function ue(o,t){return{...o?yt[o]:yt.playful,...t}}function ge(o,t){return{...o?vt[o]:vt.gentle,...t}}function me(o,t){return{...o?wt[o]:wt.gentle,...t}}class Dt{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,h=this.buildTransformString(e),l=this.buildTransformString(i);t.style.transition="none";const u=t.animate([{transform:h},{transform:l}],{duration:r,easing:a,fill:"forwards"}),c={id:`anim-${++this.animationIdCounter}`,element:t,animation:u,fromState:e,toState:i,startTime:performance.now(),duration:r};return this.activeAnimations.set(t,c),u.finished.then(()=>{t.style.transform=l,this.activeAnimations.delete(t)}).catch(()=>{this.activeAnimations.delete(t)}),c}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,h=n.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,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 fe(o,t,e,i){const{overshoot:n,bounces:s,decayRatio:r}=i,a=e.x-t.x,h=e.y-t.y,l=pe(s,r);let u=0,c=0,d=1,f=n,b=!1;for(let g=0;g<l.length;g++)if(o<=l[g].time){c=g===0?0:l[g-1].time,d=l[g].time,f=l[g].overshoot,b=l[g].isOvershoot;break}const p=(o-c)/(d-c);if(b)u=1+f*gt(p);else if(c===0)u=gt(p);else{const g=l.find((v,w)=>v.time>c&&w>0&&l[w-1].isOvershoot),m=1+((g==null?void 0:g.overshoot)||f);u=at(m,1,gt(p))}return{x:t.x+a*u,y:t.y+h*u}}function pe(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 be(o,t,e,i){const{stiffness:n,damping:s,mass:r,oscillations:a}=i,h=e.x-t.x,l=e.y-t.y,u=Math.sqrt(n/r),c=s/(2*Math.sqrt(n*r));let d;if(c<1){const f=u*Math.sqrt(1-c*c),b=Math.exp(-c*u*o*3),p=Math.cos(f*o*a*Math.PI);d=1-b*p}else d=1-Math.exp(-u*o*3);return d=Math.max(0,Math.min(d,1.3)),{x:t.x+h*d,y:t.y+l*d}}function ye(o,t,e,i){const{amplitude:n,frequency:s,decay:r,decayRate:a,phase:h}=i,l=e.x-t.x,u=e.y-t.y,c=Math.sqrt(l*l+u*u),d=c>0?-u/c:0,f=c>0?l/c:1,b=s*Math.PI*2*o+h,p=r?Math.pow(1-o,a):1,g=n*Math.sin(b)*p,m=ve(o);return{x:at(t.x,e.x,m)+g*d,y:at(t.y,e.y,m)+g*f}}function gt(o){return 1-(1-o)*(1-o)}function ve(o){return 1-Math.pow(1-o,3)}function we(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,h=i*r*a;return t+h}function Se(o,t,e){const{overshoot:i,bounces:n}=e,s=[];s.push({time:.5,scale:i});let r=i;const a=.5,l=.5/(n*2);let u=.5;for(let d=0;d<n;d++){const f=1-(r-1)*a;u+=l,s.push({time:u,scale:f}),r=1+(r-1)*a*a,u+=l,d<n-1&&s.push({time:u,scale:r})}s.push({time:1,scale:1});let c=1;for(let d=0;d<s.length;d++)if(o<=s[d].time){const f=d===0?0:s[d-1].time,b=d===0?1:s[d-1].scale,p=(o-f)/(s[d].time-f),g=gt(p);c=b+(s[d].scale-b)*g;break}return c*t}function $t(o){const{element:t,startPosition:e,endPosition:i,pathConfig:n,duration:s,imageWidth:r,imageHeight:a,rotation:h,scale:l,onComplete:u,rotationConfig:c,startRotation:d,scaleConfig:f,startScale:b}=o,p=n.type,g=d!==void 0&&d!==h,m=(c==null?void 0:c.mode)==="wobble",v=(c==null?void 0:c.wobble)||{amplitude:15,frequency:3,decay:!0},w=g||m,I=b!==void 0&&b!==l,A=(f==null?void 0:f.mode)==="pop",S=(f==null?void 0:f.pop)||{overshoot:1.2,bounces:1};if((p==="linear"||p==="arc")&&!w&&!(I||A)){u&&u();return}const G=performance.now(),_=-r/2,P=-a/2;function U(N){const z=N-G,x=Math.min(z/s,1);let M;switch(p){case"bounce":{const j=ue(n.bouncePreset,n.bounce);M=fe(x,e,i,j);break}case"elastic":{const j=ge(n.elasticPreset,n.elastic);M=be(x,e,i,j);break}case"wave":{const j=me(n.wavePreset,n.wave);M=ye(x,e,i,j);break}default:M={x:at(e.x,i.x,x),y:at(e.y,i.y,x)}}const D=M.x-i.x,F=M.y-i.y;let T;m?T=we(x,h,v):g?T=at(d,h,x):T=h;let C;A?C=Se(x,l,S):I?C=at(b,l,x):C=l,t.style.transform=`translate(${_}px, ${P}px) translate(${D}px, ${F}px) rotate(${T}deg) scale(${C})`,x<1?requestAnimationFrame(U):(t.style.transform=`translate(${_}px, ${P}px) rotate(${h}deg) scale(${l})`,u&&u())}requestAnimationFrame(U)}function Pt(o){return o==="bounce"||o==="elastic"||o==="wave"}const xe={radial:"center",spiral:"center",grid:"top",cluster:"nearest-edge",random:"nearest-edge",wave:"left"};class Ut{constructor(t,e){this.config=t,this.layoutAlgorithm=e,this.resolvedStartPosition=this.resolveStartPosition(),this.pathConfig=t.path||St,this.rotationConfig=t.rotation||xt,this.scaleConfig=t.scale||Et}resolveStartPosition(){return this.config.start.position?this.config.start.position:xe[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,h=i.width-s,l=r,u=i.height-r,c=Math.min(a,h,l,u);let d=t.x,f=t.y;return c===a?d=-(e.width+n):c===h?d=i.width+n:c===l?f=-(e.height+n):f=i.height+n,{x:d,y:f}}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 h;const l=r.radius||"120%";if(typeof l=="string"&&l.endsWith("%")){const p=parseFloat(l)/100;h=Math.sqrt(i.width**2+i.height**2)*p/2}else h=typeof l=="number"?l:500;let u;a==="even"?u=n/s*2*Math.PI:u=Math.random()*2*Math.PI;const c=i.width/2,d=i.height/2,f=c+Math.cos(u)*h,b=d+Math.sin(u)*h;return{x:f,y:b}}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,h){const l=t.x-e.x,u=t.y-e.y,c=a!==void 0?a:i,d=h!==void 0?h:n,f=s!==void 0?-s/2:0,b=r!==void 0?-r/2:0,p=s!==void 0?`translate(${f}px, ${b}px)`:"translate(-50%, -50%)";return t.useScale?`${p} translate(${l}px, ${u}px) rotate(${c}deg) scale(0)`:`${p} translate(${l}px, ${u}px) rotate(${c}deg) scale(${d})`}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 Pt(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),h=r?Math.pow(1-t,2):1,l=n*a*h;return e+l}getScaleConfig(){return this.scaleConfig}getScaleMode(){return this.scaleConfig.mode}calculateStartScale(t){switch(this.scaleConfig.mode){case"none":return t;case"grow":return(this.scaleConfig.startScale??.3)*t;case"shrink":return(this.scaleConfig.startScale??1.5)*t;case"pop":return t;case"random":{const 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 h=0;h<r.length;h++)if(t<=r[h].time){const l=h===0?0:r[h-1].time,u=h===0?e:r[h-1].scale,c=(t-l)/(r[h].time-l),d=this.easeOutQuad(c);a=u+(r[h].scale-u)*d;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 h=.5;for(let l=0;l<t;l++){const u=1-(n-1)*s;h+=a,i.push({time:h,scale:u}),n=1+(n-1)*s*s,h+=a,l<t-1&&i.push({time:h,scale:n})}return i.push({time:1,scale:1}),i}easeOutQuad(t){return 1-(1-t)*(1-t)}}class _t{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){var S,O,G,_,P,U,N,z,x;const n=[],{width:s,height:r}=e,a=this.config.spacing.padding,h=i.fixedHeight??200,l=((S=this.imageConfig.rotation)==null?void 0:S.mode)??"none",u=((G=(O=this.imageConfig.rotation)==null?void 0:O.range)==null?void 0:G.min)??-15,c=((P=(_=this.imageConfig.rotation)==null?void 0:_.range)==null?void 0:P.max)??15,d=((N=(U=this.imageConfig.sizing)==null?void 0:U.variance)==null?void 0:N.min)??1,f=((x=(z=this.imageConfig.sizing)==null?void 0:z.variance)==null?void 0:x.max)??1,b=d!==1||f!==1,g=h*1.5/2,m=h/2,v=s-a-g,w=r-a-m,I=a+g,A=a+m;for(let M=0;M<t;M++){const D=this.random(I,v),F=this.random(A,w),T=l==="random"?this.random(u,c):0,C=b?this.random(d,f):1,j=h*C,J={id:M,x:D,y:F,rotation:T,scale:C,baseSize:j};n.push(J)}return n}random(t,e){return Math.random()*(e-t)+t}}class Ht{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){var O,G,_,P,U,N,z,x,M;const n=[],{width:s,height:r}=e,{debugRadials:a}=this.config,h=i.fixedHeight??200,l=((O=this.imageConfig.rotation)==null?void 0:O.mode)??"none",u=((_=(G=this.imageConfig.rotation)==null?void 0:G.range)==null?void 0:_.min)??-15,c=((U=(P=this.imageConfig.rotation)==null?void 0:P.range)==null?void 0:U.max)??15,d=((z=(N=this.imageConfig.sizing)==null?void 0:N.variance)==null?void 0:z.min)??1,f=((M=(x=this.imageConfig.sizing)==null?void 0:x.variance)==null?void 0:M.max)??1,b=d!==1||f!==1,p=this.config.scaleDecay??0,g=["green","blue","red","yellow","orange","purple"],m=i.fixedHeight??h,v=s/2,w=r/2,I=Math.ceil(Math.sqrt(t));if(t>0){const D=b?this.random(d,f):1,F=m*D;n.push({id:0,x:v,y:w,rotation:l==="random"?this.random(u*.33,c*.33):0,scale:D,baseSize:F,zIndex:100,borderColor:a?"cyan":void 0})}let A=1,S=1;for(;A<t;){const D=S/I,F=p>0?1-D*p*.5:1,T=S*(m*.8),C=T*1.5,j=Math.PI*(3*(C+T)-Math.sqrt((3*C+T)*(C+3*T))),J=this.estimateWidth(m),B=Math.floor(j/(J*.7));if(B===0){S++;continue}const V=2*Math.PI/B,Q=S*(20*Math.PI/180);for(let q=0;q<B&&A<t;q++){const tt=q*V+Q,et=b?this.random(d,f):1,Y=F*et,it=m*Y;let X=v+Math.cos(tt)*C,L=w+Math.sin(tt)*T;const $=this.config.spacing.padding??50,W=it*1.5/2,H=it/2;X-W<$?X=$+W:X+W>s-$&&(X=s-$-W),L-H<$?L=$+H:L+H>r-$&&(L=r-$-H);const nt=l==="random"?this.random(u,c):0;n.push({id:A,x:X,y:L,rotation:nt,scale:Y,baseSize:it,zIndex:Math.max(1,100-S),borderColor:a?g[(S-1)%g.length]:void 0}),A++}S++}return n}estimateWidth(t){return t*1.4}random(t,e){return Math.random()*(e-t)+t}}const Ee={columns:"auto",rows:"auto",stagger:"none",jitter:0,overlap:0,fillDirection:"row",alignment:"center",gap:10,overflowOffset:.25},jt=[{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 Gt{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){var B,V,Q,q,tt,et,Y,it,X;const n=[],{width:s,height:r}=e,a={...Ee,...this.config.grid},h=this.config.spacing.padding,l=i.fixedHeight??200,u=((B=this.imageConfig.rotation)==null?void 0:B.mode)??"none",c=((Q=(V=this.imageConfig.sizing)==null?void 0:V.variance)==null?void 0:Q.min)??1,d=((tt=(q=this.imageConfig.sizing)==null?void 0:q.variance)==null?void 0:tt.max)??1,f=c!==1||d!==1,b=s-2*h,p=r-2*h,{columns:g,rows:m}=this.calculateGridDimensions(t,b,p,l,a),v=a.stagger==="row",w=a.stagger==="column",I=v?g+.5:g,A=w?m+.5:m,S=(b-a.gap*(g-1))/I,O=(p-a.gap*(m-1))/A,G=v?S/2:0,_=w?O/2:0,P=1+a.overlap,U=Math.min(S,O)*P,N=i.fixedHeight?Math.min(i.fixedHeight,U):U,z=g*S+(g-1)*a.gap+G,x=m*O+(m-1)*a.gap+_,M=h+(b-z)/2,D=h+(p-x)/2,F=g*m,T=a.columns!=="auto"&&a.rows!=="auto",C=T&&t>F;typeof window<"u"&&(window.__gridOverflowDebug={gridConfigColumns:a.columns,gridConfigRows:a.rows,columns:g,rows:m,cellCount:F,hasFixedGrid:T,imageCount:t,isOverflowMode:C});const j=C?new Array(F).fill(0):[],J=Math.min(S,O)*a.overflowOffset;for(let L=0;L<t;L++){let $,k,W=0;if(C&&L>=F){const Z=L-F,K=Z%F;W=Math.floor(Z/F)+1,j[K]++,a.fillDirection==="row"?($=K%g,k=Math.floor(K/g)):(k=K%m,$=Math.floor(K/m))}else a.fillDirection==="row"?($=L%g,k=Math.floor(L/g)):(k=L%m,$=Math.floor(L/m));let H=M+$*(S+a.gap)+S/2,nt=D+k*(O+a.gap)+O/2;if(a.stagger==="row"&&k%2===1?H+=S/2:a.stagger==="column"&&$%2===1&&(nt+=O/2),W>0){const Z=(W-1)%jt.length,K=jt[Z];H+=K.x*J,nt+=K.y*J}if(a.jitter>0){const Z=S/2*a.jitter,K=O/2*a.jitter;H+=this.random(-Z,Z),nt+=this.random(-K,K)}let ot=H,rt=nt;if(!C&&a.fillDirection==="row"){const Z=t%g||g;if(k===Math.floor((t-1)/g)&&Z<g){const ie=Z*S+(Z-1)*a.gap;let zt=0;a.alignment==="center"?zt=(z-ie)/2:a.alignment==="end"&&(zt=z-ie),ot+=zt}}const Tt=f?this.random(c,d):1,ct=N*Tt,pt=ct*1.5/2,bt=ct/2,At=h+pt,Mt=s-h-pt,Ue=h+bt,_e=r-h-bt;ot=Math.max(At,Math.min(ot,Mt)),rt=Math.max(Ue,Math.min(rt,_e));let Ct=0;if(u==="random"){const Z=((Y=(et=this.imageConfig.rotation)==null?void 0:et.range)==null?void 0:Y.min)??-15,K=((X=(it=this.imageConfig.rotation)==null?void 0:it.range)==null?void 0:X.max)??15;a.jitter>0?Ct=this.random(Z*a.jitter,K*a.jitter):Ct=this.random(Z,K)}let Ft;C&&W>0?Ft=50-W:Ft=C?100+L:L+1,n.push({id:L,x:ot,y:rt,rotation:Ct,scale:Tt,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 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 Ie=Math.PI*(3-Math.sqrt(5)),Te={spiralType:"golden",direction:"counterclockwise",tightness:1,scaleDecay:0,startAngle:0};class Nt{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){var A,S,O,G,_,P,U,N,z;const n=[],{width:s,height:r}=e,a={...Te,...this.config.spiral},h=this.config.spacing.padding,l=i.fixedHeight??200,u=((A=this.imageConfig.rotation)==null?void 0:A.mode)??"none",c=((O=(S=this.imageConfig.rotation)==null?void 0:S.range)==null?void 0:O.min)??-15,d=((_=(G=this.imageConfig.rotation)==null?void 0:G.range)==null?void 0:_.max)??15,f=((U=(P=this.imageConfig.sizing)==null?void 0:P.variance)==null?void 0:U.min)??1,b=((z=(N=this.imageConfig.sizing)==null?void 0:N.variance)==null?void 0:z.max)??1,p=f!==1||b!==1,g=this.config.scaleDecay??a.scaleDecay,m=s/2,v=r/2,w=Math.min(m-h-l/2,v-h-l/2),I=a.direction==="clockwise"?-1:1;for(let x=0;x<t;x++){let M,D;if(a.spiralType==="golden")M=x*Ie*I+a.startAngle,D=this.calculateGoldenRadius(x,t,w,a.tightness);else if(a.spiralType==="archimedean"){const H=x*.5*a.tightness;M=H*I+a.startAngle,D=this.calculateArchimedeanRadius(H,t,w,a.tightness)}else{const H=x*.3*a.tightness;M=H*I+a.startAngle,D=this.calculateLogarithmicRadius(H,t,w,a.tightness)}const F=m+Math.cos(M)*D,T=v+Math.sin(M)*D,C=D/w,j=g>0?1-C*g*.5:1,J=p?this.random(f,b):1,B=j*J,V=l*B,q=V*1.5/2,tt=V/2,et=h+q,Y=s-h-q,it=h+tt,X=r-h-tt,L=Math.max(et,Math.min(F,Y)),$=Math.max(it,Math.min(T,X));let k=0;if(u==="random"){const H=M*180/Math.PI%360,nt=this.random(c,d);k=a.spiralType==="golden"?nt:H*.1+nt*.9}else u==="tangent"&&(k=this.calculateSpiralTangent(M,D,a));const W=t-x;n.push({id:x,x:L,y:$,rotation:k,scale:B,baseSize:V,zIndex:W})}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),h=e*.3*n,l=s*Math.exp(r*h);return a/l*i}random(t,e){return Math.random()*(e-t)+t}}const Re={clusterCount:"auto",clusterSpread:150,clusterSpacing:200,density:"uniform",overlap:.3,distribution:"gaussian"};class kt{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){var I,A,S,O,G,_,P,U,N;const n=[],{width:s,height:r}=e,a={...Re,...this.config.cluster},h=this.config.spacing.padding,l=i.fixedHeight??200,u=((I=this.imageConfig.rotation)==null?void 0:I.mode)??"none",c=((S=(A=this.imageConfig.rotation)==null?void 0:A.range)==null?void 0:S.min)??-15,d=((G=(O=this.imageConfig.rotation)==null?void 0:O.range)==null?void 0:G.max)??15,f=((P=(_=this.imageConfig.sizing)==null?void 0:_.variance)==null?void 0:P.min)??1,b=((N=(U=this.imageConfig.sizing)==null?void 0:U.variance)==null?void 0:N.max)??1,p=f!==1||b!==1,g=this.calculateClusterCount(t,a.clusterCount,s,r,a.clusterSpacing),m=this.generateClusterCenters(g,s,r,h,a),v=new Array(g).fill(0);for(let z=0;z<t;z++)v[z%g]++;let w=0;for(let z=0;z<g;z++){const x=m[z],M=v[z];for(let D=0;D<M;D++){let F,T;if(a.distribution==="gaussian")F=this.gaussianRandom()*x.spread,T=this.gaussianRandom()*x.spread;else{const k=this.random(0,Math.PI*2),W=this.random(0,x.spread);F=Math.cos(k)*W,T=Math.sin(k)*W}const C=1+a.overlap*.5,j=1+a.overlap*.3;F/=C,T/=C;const J=p?this.random(f,b):1,B=j*J,V=l*B;let Q=x.x+F,q=x.y+T;const et=V*1.5/2,Y=V/2;Q=Math.max(h+et,Math.min(Q,s-h-et)),q=Math.max(h+Y,Math.min(q,r-h-Y));const it=u==="random"?this.random(c,d):0,L=Math.sqrt(F*F+T*T)/x.spread,$=Math.round((1-L)*50)+1;n.push({id:w,x:Q,y:q,rotation:it,scale:B,baseSize:V,zIndex:$}),w++}}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)),h=Math.floor(i/s*(n/s)*.6);return Math.max(1,Math.min(a,h,10))}generateClusterCenters(t,e,i,n,s){const r=[],h=n+s.clusterSpread,l=e-n-s.clusterSpread,u=n+s.clusterSpread,c=i-n-s.clusterSpread;for(let d=0;d<t;d++){let f=null,b=-1;for(let p=0;p<100;p++){const g={x:this.random(h,l),y:this.random(u,c),spread:this.calculateClusterSpread(s)};let m=1/0;for(const v of r){const w=g.x-v.x,I=g.y-v.y,A=Math.sqrt(w*w+I*I);m=Math.min(m,A)}if((r.length===0||m>b)&&(f=g,b=m),m>=s.clusterSpacing)break}f&&r.push(f)}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 Ae{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){var C,j,J,B,V,Q,q,tt,et;const n=[],{width:s,height:r}=e,a=i.fixedHeight??200,h=this.config.spacing.padding??50,l=((C=this.imageConfig.rotation)==null?void 0:C.mode)??"none",u=((J=(j=this.imageConfig.rotation)==null?void 0:j.range)==null?void 0:J.min)??-15,c=((V=(B=this.imageConfig.rotation)==null?void 0:B.range)==null?void 0:V.max)??15,d=((q=(Q=this.imageConfig.sizing)==null?void 0:Q.variance)==null?void 0:q.min)??1,f=((et=(tt=this.imageConfig.sizing)==null?void 0:tt.variance)==null?void 0:et.max)??1,b=d!==1||f!==1,p=i.fixedHeight??a,g={...ne,...this.config.wave},{rows:m,amplitude:v,frequency:w,phaseShift:I,synchronization:A}=g,S=Math.ceil(t/m),_=p*1.5/2,P=h+_,U=s-h-_,N=U-P,z=S>1?N/(S-1):0,x=h+v+p/2,M=r-h-v-p/2,D=M-x,F=m>1?D/(m-1):0;let T=0;for(let Y=0;Y<m&&T<t;Y++){const it=m===1?(x+M)/2:x+Y*F;let X=0;A==="offset"?X=Y*I:A==="alternating"&&(X=Y*Math.PI);for(let L=0;L<S&&T<t;L++){const $=S===1?(P+U)/2:P+L*z,k=this.calculateWaveY($,s,v,w,X),W=$,H=it+k,nt=b?this.random(d,f):1,ot=p*nt;let rt=0;l==="tangent"?rt=this.calculateRotation($,s,v,w,X):l==="random"&&(rt=this.random(u,c));const ct=ot*1.5/2,Rt=ot/2,pt=h+ct,bt=s-h-ct,At=h+Rt,Mt=r-h-Rt;n.push({id:T,x:Math.max(pt,Math.min(W,bt)),y:Math.max(At,Math.min(H,Mt)),rotation:rt,scale:nt,baseSize:ot,zIndex:T+1}),T++}}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 Wt{constructor(t){this.config=t.layout,this.imageConfig=t.image,this.layouts=new Map,this.generator=this.initGenerator()}initGenerator(){switch(this.config.algorithm){case"radial":return new Ht(this.config,this.imageConfig);case"grid":return new Gt(this.config,this.imageConfig);case"spiral":return new Nt(this.config,this.imageConfig);case"cluster":return new kt(this.config,this.imageConfig);case"wave":return new Ae(this.config,this.imageConfig);case"random":default:return new _t(this.config,this.imageConfig)}}generateLayout(t,e,i={}){const n=this.generator.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.generator=this.initGenerator())),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,h=(s==null?void 0:s.maxSize)??400,l=this.config.targetCoverage??.6,u=this.config.densityFactor??1,{width:c,height:d}=t,p=c*d*l/e;let m=Math.sqrt(p/1.4);m*=u,m=Math.min(m,i);let v=this.clamp(m,a,h);if(v===a&&m<a){const w=Math.max(a*.05,20);v=Math.max(w,m)}return{height:v}}clamp(t,e,i){return Math.max(e,Math.min(i,t))}}var E=(o=>(o.IDLE="idle",o.FOCUSING="focusing",o.FOCUSED="focused",o.UNFOCUSING="unfocusing",o.CROSS_ANIMATING="cross_animating",o))(E||{});function Me(o){return o in st}function Ce(o){return o?Me(o)?st[o]:o:st.md}function Fe(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 mt(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||{},h={...a,...o.borderTop},l={...a,...o.borderRight},u={...a,...o.borderBottom},c={...a,...o.borderLeft};t.borderTop=ht(h),t.borderRight=ht(l),t.borderBottom=ht(u),t.borderLeft=ht(c)}else o.border&&(t.border=ht(o.border));o.shadow!==void 0&&(t.boxShadow=Ce(o.shadow));const n=Fe(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,h=o.outline.style??"solid",l=o.outline.color??"#000000";t.outline=`${a}px ${h} ${l}`,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 qt(o){return o?Array.isArray(o)?o.join(" "):o:""}function ut(o,t){const e=qt(t);e&&e.split(" ").forEach(i=>{i.trim()&&o.classList.add(i.trim())})}function Yt(o,t){const e=qt(t);e&&e.split(" ").forEach(i=>{i.trim()&&o.classList.remove(i.trim())})}const Xt={UNFOCUSING:999,FOCUSING:1e3};class Bt{constructor(t,e,i){var n,s;this.state=E.IDLE,this.currentFocus=null,this.focusData=null,this.outgoing=null,this.incoming=null,this.focusGeneration=0,this.config=t,this.animationEngine=e,this.defaultStyles=mt(i==null?void 0:i.default),this.focusedStyles=mt(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!==E.IDLE&&this.state!==E.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,h=a*r;const l=i.width*n;return h>l&&(h=l,a=h/r),{width:h,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,h){const l=this.buildDimensionZoomTransform(e),u=this.buildDimensionZoomTransform(i);return t.style.transition="none",t.animate([{transform:l,width:`${n}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"),dt(t,this.focusedStyles),ut(t,this.focusedClassName)}removeFocusedStyling(t,e){t.style.zIndex=e,t.classList.remove("fbn-ic-focused"),Yt(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,h=t.offsetHeight,l=this.calculateFocusDimensions(a,h,e),u=this.calculateFocusTransform(e,i);this.applyFocusedStyling(t,Xt.FOCUSING),this.animationEngine.cancelAllAnimations(t);const c=n??{x:0,y:0,rotation:i.rotation,scale:1},d=(s==null?void 0:s.width)??a,f=(s==null?void 0:s.height)??h,b=this.config.animationDuration??600,p=this.animateWithDimensions(t,c,u,d,f,l.width,l.height,b),g={id:`focus-${Date.now()}`,element:t,animation:p,fromState:c,toState:u,startTime:performance.now(),duration:b};return this.focusData={element:t,originalState:i,focusTransform:u,originalZIndex:r,originalWidth:a,originalHeight:h,focusWidth:l.width,focusHeight:l.height},{element:t,originalState:i,animationHandle:g,direction:"in",originalWidth:a,originalHeight:h}}startUnfocusAnimation(t,e,i,n){var b,p,g,m,v;t.style.zIndex=String(Xt.UNFOCUSING),this.animationEngine.cancelAllAnimations(t);const s=i??((b=this.focusData)==null?void 0:b.focusTransform)??{x:0,y:0,rotation:0,scale:1},r=(n==null?void 0:n.width)??((p=this.focusData)==null?void 0:p.focusWidth)??t.offsetWidth,a=(n==null?void 0:n.height)??((g=this.focusData)==null?void 0:g.focusHeight)??t.offsetHeight,h={x:0,y:0,rotation:e.rotation,scale:1},l=((m=this.focusData)==null?void 0:m.originalWidth)??t.offsetWidth,u=((v=this.focusData)==null?void 0:v.originalHeight)??t.offsetHeight,c=this.config.animationDuration??600,d=this.animateWithDimensions(t,s,h,r,a,l,u,c),f={id:`unfocus-${Date.now()}`,element:t,animation:d,fromState:s,toState:h,startTime:performance.now(),duration:c};return{element:t,originalState:e,animationHandle:f,direction:"out",originalWidth:l,originalHeight:u}}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,h,l,u,c,d,f,b,p,g;if(this.currentFocus===t&&this.state===E.FOCUSED)return this.unfocusImage();if(((s=this.incoming)==null?void 0:s.element)===t&&this.state===E.FOCUSING){const m=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),v={x:m.x,y:m.y,rotation:m.rotation,scale:1},w={width:t.offsetWidth,height:t.offsetHeight};this.outgoing=this.startUnfocusAnimation(t,this.incoming.originalState,v,w),this.incoming=null,this.state=E.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=E.IDLE;return}const n=++this.focusGeneration;switch(this.state){case E.IDLE:if(this.state=E.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=E.FOCUSED;break;case E.FOCUSED:if(this.state=E.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=E.FOCUSED;break;case E.FOCUSING:if(this.incoming&&(this.animationEngine.cancelAnimation(this.incoming.animationHandle,!1),this.resetElementInstantly(this.incoming.element,this.incoming.originalState,((h=this.focusData)==null?void 0:h.originalZIndex)||"",(l=this.focusData)==null?void 0:l.originalWidth,(u=this.focusData)==null?void 0:u.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=E.FOCUSED;break;case E.UNFOCUSING:if(this.state=E.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,((c=this.outgoing.originalState.zIndex)==null?void 0:c.toString())||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=E.FOCUSED;break;case E.CROSS_ANIMATING:if(((d=this.incoming)==null?void 0:d.element)===t)return;if(((f=this.outgoing)==null?void 0:f.element)===t){const m=this.animationEngine.cancelAnimation(this.outgoing.animationHandle,!0),v={x:m.x,y:m.y,rotation:m.rotation,scale:1},w={width:t.offsetWidth,height:t.offsetHeight};if(this.incoming){const I=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),A={x:I.x,y:I.y,rotation:I.rotation,scale:1},S={width:this.incoming.element.offsetWidth,height:this.incoming.element.offsetHeight};this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,A,S)}else this.outgoing=null;if(this.incoming=this.startFocusAnimation(t,e,i,v,w),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,((b=this.outgoing.originalState.zIndex)==null?void 0:b.toString())||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=E.FOCUSED;return}if(this.outgoing&&(this.animationEngine.cancelAnimation(this.outgoing.animationHandle,!1),this.resetElementInstantly(this.outgoing.element,this.outgoing.originalState,((p=this.outgoing.originalState.zIndex)==null?void 0:p.toString())||"",this.outgoing.originalWidth,this.outgoing.originalHeight),this.outgoing=null),this.incoming){const m=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),v={x:m.x,y:m.y,rotation:m.rotation,scale:1},w={width:this.incoming.element.offsetWidth,height:this.incoming.element.offsetHeight};this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,v,w)}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,((g=this.outgoing.originalState.zIndex)==null?void 0:g.toString())||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=E.FOCUSED;break}}async unfocusImage(){var s,r,a;const t=++this.focusGeneration;if(!this.currentFocus||!this.focusData){if(this.incoming&&this.state===E.FOCUSING){const h=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),l={x:h.x,y:h.y,rotation:h.rotation,scale:1},u={width:this.incoming.element.offsetWidth,height:this.incoming.element.offsetHeight};if(this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,l,u),this.incoming=null,this.state=E.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=E.IDLE}return}if(this.state===E.CROSS_ANIMATING&&this.incoming){const h=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),l={x:h.x,y:h.y,rotation:h.rotation,scale:1},u={width:this.incoming.element.offsetWidth,height:this.incoming.element.offsetHeight},c=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,l,u);if(await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(c.animationHandle)]),this.focusGeneration!==t)return;this.outgoing&&this.removeFocusedStyling(this.outgoing.element,((r=this.outgoing.originalState.zIndex)==null?void 0:r.toString())||""),this.removeFocusedStyling(c.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=E.IDLE;return}this.state=E.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=E.IDLE)}async swapFocus(t,e,i){return this.focusImage(t,e,i)}getCurrentFocus(){return this.currentFocus}isFocused(t){return this.currentFocus===t&&this.state===E.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!==E.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!==E.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 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(){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=E.IDLE,this.currentFocus=null,this.focusData=null,this.outgoing=null,this.incoming=null}}const ze=50,Le=.5,Oe=20,De=.3,$e=150,Pe=30,ft=class ft{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.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.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<ft.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<=Pe}if(this.touchState.isHorizontalSwipe!==!1&&this.touchState.isHorizontalSwipe===!0){t.preventDefault(),this.touchState.isDragging=!0,this.touchState.currentX=e.clientX;const s=i*De;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>=ze||n>=Le&&s>=Oe)&&(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}};ft.TOUCH_CLICK_DELAY=300;let It=ft;class Vt{constructor(t={}){if(this._prepared=!1,this._discoveredUrls=[],this.apiKey=t.apiKey??"",this.apiEndpoint=t.apiEndpoint??"https://www.googleapis.com/drive/v3/files",this.debugLogging=t.debugLogging??!1,this.sources=t.sources??[],!this.sources||this.sources.length===0)throw new Error("GoogleDriveLoader requires at least one source to be configured")}async prepare(t){this._discoveredUrls=[];for(const e of this.sources)if(e.type==="folder")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(e.type==="files"){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 l=(await a.json()).files.filter(u=>u.mimeType.startsWith("image/")&&e.isAllowed(u.name));return this.log(`Found ${l.length} images in folder ${t} (non-recursive)`),l.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 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 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 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 h=await a.json(),l=h.files.filter(c=>c.mimeType.startsWith("image/")&&e.isAllowed(c.name)),u=h.files.filter(c=>c.mimeType==="application/vnd.google-apps.folder");this.log(`Found ${h.files.length} total items in folder ${t}`),h.files.forEach(c=>this.log(` - File: ${c.name} (${c.mimeType})`)),this.log(`- ${l.length} valid files (images only)`),this.log(`- ${u.length} subfolders`),l.forEach(c=>{i.push(`https://lh3.googleusercontent.com/d/${c.id}=s1600`),this.log(`Added file: ${c.name}`)});for(const c of u){this.log(`Loading images from subfolder: ${c.name}`);const d=await this.loadImagesRecursively(c.id,e);i.push(...d)}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(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 Kt{constructor(t={}){if(this._prepared=!1,this._discoveredUrls=[],this.validateUrls=t.validateUrls!==!1,this.validationTimeout=t.validationTimeout??5e3,this.validationMethod=t.validationMethod??"head",this.sources=t.sources??[],this.debugLogging=t.debugLogging??!1,!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||!t.type?(console.warn("Invalid source object (missing type):",t),[]):t.type==="urls"?await this.processUrls(t.urls||[],e):t.type==="path"?await this.processPath(t.basePath,t.files||[],e):(console.warn(`Unknown source type: ${t.type}`),[])}async processUrls(t,e){if(!Array.isArray(t))return console.warn("URLs must be an array:",t),[];const i=[];for(const n of t){const s=n.split("/").pop()||n;if(!e.isAllowed(s)){this.log(`Skipping filtered URL: ${n}`);continue}this.validateUrls?await this.validateUrl(n)?i.push(n):console.warn(`Skipping invalid/missing URL: ${n}`):i.push(n)}return i}async processPath(t,e,i){if(!t)return console.warn("basePath is required for path-type sources"),[];if(!Array.isArray(e))return console.warn("files must be an array:",e),[];const n=[];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)?n.push(r):console.warn(`Skipping invalid/missing file: ${r}`):n.push(r)}return n}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,n=setTimeout(()=>i.abort(),this.validationTimeout),s=await fetch(t,{method:"HEAD",signal:i.signal});return clearTimeout(n),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 n=window.location.origin,r=(t.startsWith("/")?t:"/"+t).replace(/\/$/,"");return`${n}${r}/${e}`}isAbsoluteUrl(t){try{return new URL(t),!0}catch{return!1}}log(...t){this.debugLogging&&typeof console<"u"&&console.log(...t)}}class Zt{constructor(t){if(this._prepared=!1,this._discoveredUrls=[],this.loaders=t.loaders,this.debugLogging=t.debugLogging??!1,!this.loaders||this.loaders.length===0)throw new Error("CompositeLoader requires at least one loader to be configured");this.log(`CompositeLoader initialized with ${this.loaders.length} loader(s)`)}async prepare(t){this._discoveredUrls=[],this.log(`Preparing ${this.loaders.length} loader(s) in parallel`);const e=this.loaders.map((i,n)=>i.prepare(t).then(()=>{this.log(`Loader ${n} prepared with ${i.imagesLength()} images`)}).catch(s=>{console.warn(`Loader ${n} failed to prepare:`,s)}));await Promise.all(e);for(const i of this.loaders)if(i.isPrepared()){const n=i.imageURLs();this._discoveredUrls.push(...n)}this._prepared=!0,this.log(`CompositeLoader prepared with ${this._discoveredUrls.length} total images`)}imagesLength(){if(!this._prepared)throw new Error("CompositeLoader.imagesLength() called before prepare()");return this._discoveredUrls.length}imageURLs(){if(!this._prepared)throw new Error("CompositeLoader.imageURLs() called before prepare()");return[...this._discoveredUrls]}isPrepared(){return this._prepared}log(...t){this.debugLogging&&typeof console<"u"&&console.log("[CompositeLoader]",...t)}}class Jt{constructor(t){this.allowedExtensions=t||["jpg","jpeg","png","gif","webp","bmp"]}isAllowed(t){var n;const i=(n=t.split("?")[0].split(".").pop())==null?void 0:n.toLowerCase();return i?this.allowedExtensions.includes(i):!1}getAllowedExtensions(){return[...this.allowedExtensions]}}const Qt=`
|
|
5
5
|
.fbn-ic-gallery {
|
|
6
6
|
position: relative;
|
|
7
7
|
width: 100%;
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
.fbn-ic-hidden {
|
|
42
42
|
display: none !important;
|
|
43
43
|
}
|
|
44
|
-
`;function Kt(){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=Zt,document.head.appendChild(t)}class Qt{constructor(t={}){var i,o,s,c,a,h;this.fullConfig=le(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.animationEngine=new Lt(this.fullConfig.animation),this.layoutEngine=new Wt({layout:this.fullConfig.layout,image:this.fullConfig.image}),this.zoomEngine=new Yt(this.fullConfig.interaction.focus,this.animationEngine,this.fullConfig.styling),this.defaultStyles=mt((i=this.fullConfig.styling)==null?void 0:i.default),this.hoverStyles=mt((o=this.fullConfig.styling)==null?void 0:o.hover),this.defaultClassName=(c=(s=this.fullConfig.styling)==null?void 0:s.default)==null?void 0:c.className,this.hoverClassName=(h=(a=this.fullConfig.styling)==null?void 0:a.hover)==null?void 0:h.className;const e=this.fullConfig.animation.entry||b.animation.entry;this.entryAnimationEngine=new Dt(e,this.fullConfig.layout.algorithm),this.imageFilter=this.createImageFilter(),this.imageLoader=this.createLoader(),this.containerEl=null,this.loadingEl=null,this.errorEl=null}createImageFilter(){var i,o;const t=this.fullConfig.loader.type;let e;return t==="googleDrive"?e=(i=this.fullConfig.loader.googleDrive)==null?void 0:i.allowedExtensions:e=(o=this.fullConfig.loader.static)==null?void 0:o.allowedExtensions,new Jt(e)}createLoader(){return this.createLoaderFromConfig(this.fullConfig.loader)}createLoaderFromConfig(t){const e=t.type;if(e==="static"){const i=t.static;return new Xt(i)}else if(e==="composite"){const i=t.composite,o=i.loaders.map(s=>this.createLoaderFromConfig(s));return new Vt({loaders:o,debugLogging:i.debugLogging})}else{const i=t.googleDrive;return new Bt(i)}}async init(){try{if(Kt(),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.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(){this.loadingEl=document.getElementById("loading"),this.errorEl=document.getElementById("error")}setupEventListeners(){document.addEventListener("keydown",t=>{t.key==="Escape"?(this.zoomEngine.unfocusImage(),this.currentFocusIndex=null):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=>{t.target.closest(".fbn-ic-image")||(this.zoomEngine.unfocusImage(),this.currentFocusIndex=null)}),window.addEventListener("resize",()=>this.handleResize())}navigateToNextImage(){if(this.currentFocusIndex===null||this.imageElements.length===0)return;const t=(this.currentFocusIndex+1)%this.imageElements.length;this.navigateToImage(t)}navigateToPreviousImage(){if(this.currentFocusIndex===null||this.imageElements.length===0)return;const t=(this.currentFocusIndex-1+this.imageElements.length)%this.imageElements.length;this.navigateToImage(t)}async navigateToImage(t){if(t<0||t>=this.imageElements.length)return;const e=this.imageElements[t],i=this.imageLayouts[t];!e||!i||await this.handleImageClick(e,i)}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,o=(i==null?void 0:i.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 c=this.layoutEngine.calculateAdaptiveSize(i,t,o,s);this.logDebug(`Adaptive sizing result: height=${c.height}px`),await this.createImageCloud(e,c.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.debug&&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 c=0;const a=l=>{this.containerEl&&(this.containerEl.appendChild(l),this.imageElements.push(l),requestAnimationFrame(()=>{if(l.offsetWidth,l.style.opacity=this.defaultStyles.opacity??"1",l.dataset.startX&&(this.entryAnimationEngine.requiresJSAnimation()||this.entryAnimationEngine.requiresJSRotation()||this.entryAnimationEngine.requiresJSScale()||l.dataset.startRotation!==l.dataset.rotation||l.dataset.startScale!==l.dataset.scale)){const d={x:parseFloat(l.dataset.startX),y:parseFloat(l.dataset.startY)},f={x:parseFloat(l.dataset.endX),y:parseFloat(l.dataset.endY)},y=parseFloat(l.dataset.imageWidth),p=parseFloat(l.dataset.imageHeight),g=parseFloat(l.dataset.rotation),m=parseFloat(l.dataset.scale),v=l.dataset.startRotation?parseFloat(l.dataset.startRotation):g,w=l.dataset.startScale?parseFloat(l.dataset.startScale):m,E=this.entryAnimationEngine.getTiming();$t({element:l,startPosition:d,endPosition:f,pathConfig:this.entryAnimationEngine.getPathConfig(),duration:E.duration,imageWidth:y,imageHeight:p,rotation:g,scale:m,rotationConfig:this.entryAnimationEngine.getRotationConfig(),startRotation:v,scaleConfig:this.entryAnimationEngine.getScaleConfig(),startScale:w})}else{const d=l.dataset.finalTransform||"";l.style.transform=d}const r=parseInt(l.dataset.imageId||"0");if(this.fullConfig.debug&&r<3){const d=l.dataset.finalTransform||"";console.log(`Image ${r} final state:`,{left:l.style.left,top:l.style.top,width:l.style.width,height:l.style.height,computedWidth:l.offsetWidth,computedHeight:l.offsetHeight,transform:d,pathType:this.entryAnimationEngine.getPathType()})}}),c++)},h=()=>{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(o!==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)}c>=t.length&&this.displayQueue.length===0&&this.queueInterval!==null&&(clearInterval(this.queueInterval),this.queueInterval=null)},this.fullConfig.animation.queue.interval)};if("IntersectionObserver"in window&&this.containerEl){const l=new IntersectionObserver(u=>{u.forEach(r=>{r.isIntersecting&&(h(),l.disconnect())})},{threshold:.1,rootMargin:"50px"});l.observe(this.containerEl)}else h();this.fullConfig.layout.debugCenters&&this.containerEl&&(this.containerEl.querySelectorAll(".fbn-ic-debug-center").forEach(l=>l.remove()),s.forEach((l,u)=>{const r=document.createElement("div");r.className="fbn-ic-debug-center",r.style.position="absolute",r.style.width="12px",r.style.height="12px",r.style.borderRadius="50%",r.style.backgroundColor="red",r.style.border="2px solid yellow",r.style.zIndex="9999",r.style.pointerEvents="none";const d=l.x,f=l.y;r.style.left=`${d-6}px`,r.style.top=`${f-6}px`,r.title=`Image ${u}: center (${Math.round(d)}, ${Math.round(f)})`,this.containerEl.appendChild(r)})),t.forEach((l,u)=>{var f,y;const r=document.createElement("img");r.referrerPolicy="no-referrer",r.classList.add("fbn-ic-image"),r.dataset.imageId=String(u);const d=s[u];r.style.position="absolute",r.style.width="auto",r.style.height=`${e}px`,r.style.left=`${d.x}px`,r.style.top=`${d.y}px`,d.borderColor&&!((y=(f=this.fullConfig.styling)==null?void 0:f.default)!=null&&y.border)&&(r.style.border=`5px solid ${d.borderColor}`,r.style.boxSizing="border-box"),d.zIndex&&(r.style.zIndex=String(d.zIndex)),dt(r,this.defaultStyles),ut(r,this.defaultClassName),r.addEventListener("mouseenter",()=>{this.hoveredImage={element:r,layout:d},this.zoomEngine.isInvolved(r)||(dt(r,this.hoverStyles),ut(r,this.hoverClassName))}),r.addEventListener("mouseleave",()=>{this.hoveredImage=null,this.zoomEngine.isInvolved(r)||(dt(r,this.defaultStyles),kt(r,this.hoverClassName),ut(r,this.defaultClassName))}),r.addEventListener("click",p=>{p.stopPropagation(),this.handleImageClick(r,d)}),r.style.opacity="0",r.style.transition=this.entryAnimationEngine.getTransitionCSS(),r.onload=()=>{if(o!==this.loadGeneration)return;const p=r.naturalWidth/r.naturalHeight,g=e*p;r.style.width=`${g}px`;const m={x:d.x,y:d.y},v={width:g,height:e},w=this.entryAnimationEngine.calculateStartPosition(m,v,i,u,t.length),E=this.entryAnimationEngine.calculateStartRotation(d.rotation),T=this.entryAnimationEngine.calculateStartScale(d.scale),x=this.entryAnimationEngine.buildFinalTransform(d.rotation,d.scale,g,e),$=this.entryAnimationEngine.buildStartTransform(w,m,d.rotation,d.scale,g,e,E,T);this.fullConfig.debug&&u<3&&console.log(`Image ${u}:`,{finalPosition:m,imageSize:v,left:d.x,top:d.y,finalTransform:x,renderedWidth:g,renderedHeight:e}),r.style.transform=$,r.dataset.finalTransform=x,(this.entryAnimationEngine.requiresJSAnimation()||this.entryAnimationEngine.requiresJSRotation()||this.entryAnimationEngine.requiresJSScale()||E!==d.rotation||T!==d.scale)&&(r.dataset.startX=String(w.x),r.dataset.startY=String(w.y),r.dataset.endX=String(m.x),r.dataset.endY=String(m.y),r.dataset.imageWidth=String(g),r.dataset.imageHeight=String(e),r.dataset.rotation=String(d.rotation),r.dataset.scale=String(d.scale),r.dataset.startRotation=String(E),r.dataset.startScale=String(T)),this.displayQueue.push(r)},r.onerror=()=>c++,r.src=l})}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;else{const s=t.dataset.imageId;this.currentFocusIndex=s!==void 0?parseInt(s,10):null,await this.zoomEngine.focusImage(t,o,e)}}clearImageCloud(){this.queueInterval!==null&&(clearInterval(this.queueInterval),this.queueInterval=null),this.loadGeneration++,this.displayQueue=[],this.containerEl&&(this.containerEl.innerHTML=""),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")}destroy(){this.clearImageCloud(),this.resizeTimeout!==null&&clearTimeout(this.resizeTimeout)}}A.AnimationEngine=Lt,A.BOUNCE_PRESETS=yt,A.ClusterPlacementGenerator=Gt,A.CompositeLoader=Vt,A.DEFAULT_CONFIG=b,A.ELASTIC_PRESETS=bt,A.EntryAnimationEngine=Dt,A.FUNCTIONAL_CSS=Zt,A.GoogleDriveLoader=Bt,A.GridPlacementGenerator=Ht,A.ImageCloud=Qt,A.ImageFilter=Jt,A.ImageGallery=Qt,A.LayoutEngine=Wt,A.RadialPlacementGenerator=Ut,A.RandomPlacementGenerator=Pt,A.SpiralPlacementGenerator=jt,A.StaticImageLoader=Xt,A.WAVE_PATH_PRESETS=vt,A.ZoomEngine=Yt,A.animatePath=$t,A.injectFunctionalStyles=Kt,A.requiresJSAnimation=Ot,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
|
|
44
|
+
`;function te(){if(typeof document>"u")return;const o="fbn-ic-functional-styles";if(document.getElementById(o))return;const t=document.createElement("style");t.id=o,t.textContent=Qt,document.head.appendChild(t)}class ee{constructor(t={}){var i,n,s,r,a,h;this.fullConfig=de(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.animationEngine=new Dt(this.fullConfig.animation),this.layoutEngine=new Wt({layout:this.fullConfig.layout,image:this.fullConfig.image}),this.zoomEngine=new Bt(this.fullConfig.interaction.focus,this.animationEngine,this.fullConfig.styling),this.defaultStyles=mt((i=this.fullConfig.styling)==null?void 0:i.default),this.hoverStyles=mt((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=(h=(a=this.fullConfig.styling)==null?void 0:a.hover)==null?void 0:h.className;const e=this.fullConfig.animation.entry||y.animation.entry;this.entryAnimationEngine=new Ut(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 i,n;const t=this.fullConfig.loader.type;let e;return t==="googleDrive"?e=(i=this.fullConfig.loader.googleDrive)==null?void 0:i.allowedExtensions:e=(n=this.fullConfig.loader.static)==null?void 0:n.allowedExtensions,new Jt(e)}createLoader(){return this.createLoaderFromConfig(this.fullConfig.loader)}createLoaderFromConfig(t){const e=t.type;if(e==="static"){const i=t.static;return new Kt(i)}else if(e==="composite"){const i=t.composite,n=i.loaders.map(s=>this.createLoaderFromConfig(s));return new Zt({loaders:n,debugLogging:i.debugLogging})}else{const i=t.googleDrive;return new Vt(i)}}async init(){try{if(te(),this.containerRef)this.containerEl=this.containerRef;else if(this.containerEl=document.getElementById(this.containerId),!this.containerEl)throw new Error(`Container #${this.containerId} not found`);this.containerEl.classList.add("fbn-ic-gallery"),this.swipeEngine=new It(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,$e)}}),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(){this.loadingEl=document.getElementById("loading"),this.errorEl=document.getElementById("error")}setupEventListeners(){document.addEventListener("keydown",t=>{var e;t.key==="Escape"?(this.zoomEngine.unfocusImage(),this.currentFocusIndex=null,(e=this.swipeEngine)==null||e.disable()):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())}),window.addEventListener("resize",()=>this.handleResize())}navigateToNextImage(){if(this.currentFocusIndex===null||this.imageElements.length===0)return;const t=(this.currentFocusIndex+1)%this.imageElements.length;this.navigateToImage(t)}navigateToPreviousImage(){if(this.currentFocusIndex===null||this.imageElements.length===0)return;const t=(this.currentFocusIndex-1+this.imageElements.length)%this.imageElements.length;this.navigateToImage(t)}async navigateToImage(t){if(t<0||t>=this.imageElements.length)return;const e=this.imageElements[t],i=this.imageLayouts[t];!e||!i||await this.handleImageClick(e,i)}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){this.fullConfig.debug&&typeof console<"u"&&console.log(...t)}async createImageCloud(t,e){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(()=>{if(l.offsetWidth,l.style.opacity=this.defaultStyles.opacity??"1",l.dataset.startX&&(this.entryAnimationEngine.requiresJSAnimation()||this.entryAnimationEngine.requiresJSRotation()||this.entryAnimationEngine.requiresJSScale()||l.dataset.startRotation!==l.dataset.rotation||l.dataset.startScale!==l.dataset.scale)){const d={x:parseFloat(l.dataset.startX),y:parseFloat(l.dataset.startY)},f={x:parseFloat(l.dataset.endX),y:parseFloat(l.dataset.endY)},b=parseFloat(l.dataset.imageWidth),p=parseFloat(l.dataset.imageHeight),g=parseFloat(l.dataset.rotation),m=parseFloat(l.dataset.scale),v=l.dataset.startRotation?parseFloat(l.dataset.startRotation):g,w=l.dataset.startScale?parseFloat(l.dataset.startScale):m,I=this.entryAnimationEngine.getTiming();$t({element:l,startPosition:d,endPosition:f,pathConfig:this.entryAnimationEngine.getPathConfig(),duration:I.duration,imageWidth:b,imageHeight:p,rotation:g,scale:m,rotationConfig:this.entryAnimationEngine.getRotationConfig(),startRotation:v,scaleConfig:this.entryAnimationEngine.getScaleConfig(),startScale:w})}else{const d=l.dataset.finalTransform||"";l.style.transform=d}const c=parseInt(l.dataset.imageId||"0");if(this.fullConfig.debug&&c<3){const d=l.dataset.finalTransform||"";console.log(`Image ${c} final state:`,{left:l.style.left,top:l.style.top,width:l.style.width,height:l.style.height,computedWidth:l.offsetWidth,computedHeight:l.offsetHeight,transform:d,pathType:this.entryAnimationEngine.getPathType()})}}),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 l=this.displayQueue.shift();l&&a(l)}return}this.queueInterval!==null&&clearInterval(this.queueInterval),this.queueInterval=window.setInterval(()=>{if(n!==this.loadGeneration){this.queueInterval!==null&&(clearInterval(this.queueInterval),this.queueInterval=null);return}if(this.displayQueue.length>0){const l=this.displayQueue.shift();l&&a(l)}r>=t.length&&this.displayQueue.length===0&&this.queueInterval!==null&&(clearInterval(this.queueInterval),this.queueInterval=null)},this.fullConfig.animation.queue.interval)};if("IntersectionObserver"in window&&this.containerEl){const l=new IntersectionObserver(u=>{u.forEach(c=>{c.isIntersecting&&(h(),l.disconnect())})},{threshold:.1,rootMargin:"50px"});l.observe(this.containerEl)}else h();this.fullConfig.layout.debugCenters&&this.containerEl&&(this.containerEl.querySelectorAll(".fbn-ic-debug-center").forEach(l=>l.remove()),s.forEach((l,u)=>{const c=document.createElement("div");c.className="fbn-ic-debug-center",c.style.position="absolute",c.style.width="12px",c.style.height="12px",c.style.borderRadius="50%",c.style.backgroundColor="red",c.style.border="2px solid yellow",c.style.zIndex="9999",c.style.pointerEvents="none";const d=l.x,f=l.y;c.style.left=`${d-6}px`,c.style.top=`${f-6}px`,c.title=`Image ${u}: center (${Math.round(d)}, ${Math.round(f)})`,this.containerEl.appendChild(c)})),t.forEach((l,u)=>{var f,b;const c=document.createElement("img");c.referrerPolicy="no-referrer",c.classList.add("fbn-ic-image"),c.dataset.imageId=String(u);const d=s[u];c.style.position="absolute",c.style.width="auto",c.style.height=`${e}px`,c.style.left=`${d.x}px`,c.style.top=`${d.y}px`,d.borderColor&&!((b=(f=this.fullConfig.styling)==null?void 0:f.default)!=null&&b.border)&&(c.style.border=`5px solid ${d.borderColor}`,c.style.boxSizing="border-box"),d.zIndex&&(c.style.zIndex=String(d.zIndex)),dt(c,this.defaultStyles),ut(c,this.defaultClassName),c.addEventListener("mouseenter",()=>{this.hoveredImage={element:c,layout:d},this.zoomEngine.isInvolved(c)||(dt(c,this.hoverStyles),ut(c,this.hoverClassName))}),c.addEventListener("mouseleave",()=>{this.hoveredImage=null,this.zoomEngine.isInvolved(c)||(dt(c,this.defaultStyles),Yt(c,this.hoverClassName),ut(c,this.defaultClassName))}),c.addEventListener("click",p=>{p.stopPropagation(),this.handleImageClick(c,d)}),c.style.opacity="0",c.style.transition=this.entryAnimationEngine.getTransitionCSS(),c.onload=()=>{if(n!==this.loadGeneration)return;const p=c.naturalWidth/c.naturalHeight,g=e*p;c.style.width=`${g}px`;const m={x:d.x,y:d.y},v={width:g,height:e},w=this.entryAnimationEngine.calculateStartPosition(m,v,i,u,t.length),I=this.entryAnimationEngine.calculateStartRotation(d.rotation),A=this.entryAnimationEngine.calculateStartScale(d.scale),S=this.entryAnimationEngine.buildFinalTransform(d.rotation,d.scale,g,e),O=this.entryAnimationEngine.buildStartTransform(w,m,d.rotation,d.scale,g,e,I,A);this.fullConfig.debug&&u<3&&console.log(`Image ${u}:`,{finalPosition:m,imageSize:v,left:d.x,top:d.y,finalTransform:S,renderedWidth:g,renderedHeight:e}),c.style.transform=O,c.dataset.finalTransform=S,(this.entryAnimationEngine.requiresJSAnimation()||this.entryAnimationEngine.requiresJSRotation()||this.entryAnimationEngine.requiresJSScale()||I!==d.rotation||A!==d.scale)&&(c.dataset.startX=String(w.x),c.dataset.startY=String(w.y),c.dataset.endX=String(m.x),c.dataset.endY=String(m.y),c.dataset.imageWidth=String(g),c.dataset.imageHeight=String(e),c.dataset.rotation=String(d.rotation),c.dataset.scale=String(d.scale),c.dataset.startRotation=String(I),c.dataset.startScale=String(A)),this.displayQueue.push(c)},c.onerror=()=>r++,c.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();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)}}clearImageCloud(){this.queueInterval!==null&&(clearInterval(this.queueInterval),this.queueInterval=null),this.loadGeneration++,this.displayQueue=[],this.containerEl&&(this.containerEl.innerHTML=""),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")}destroy(){var t;this.clearImageCloud(),this.resizeTimeout!==null&&clearTimeout(this.resizeTimeout),(t=this.swipeEngine)==null||t.destroy()}}R.AnimationEngine=Dt,R.BOUNCE_PRESETS=yt,R.ClusterPlacementGenerator=kt,R.CompositeLoader=Zt,R.DEFAULT_CONFIG=y,R.ELASTIC_PRESETS=vt,R.EntryAnimationEngine=Ut,R.FUNCTIONAL_CSS=Qt,R.GoogleDriveLoader=Vt,R.GridPlacementGenerator=Gt,R.ImageCloud=ee,R.ImageFilter=Jt,R.ImageGallery=ee,R.LayoutEngine=Wt,R.RadialPlacementGenerator=Ht,R.RandomPlacementGenerator=_t,R.SpiralPlacementGenerator=Nt,R.StaticImageLoader=Kt,R.WAVE_PATH_PRESETS=wt,R.ZoomEngine=Bt,R.animatePath=$t,R.injectFunctionalStyles=te,R.requiresJSAnimation=Pt,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})});
|
|
45
45
|
//# sourceMappingURL=image-cloud.umd.js.map
|