@frybynite/image-cloud 0.6.4 → 0.6.5

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-cloud-CO9PMUGK.js","sources":["image-cloud.js"],"sourcesContent":["const pt = Object.freeze({\n none: \"none\",\n sm: \"0 2px 4px rgba(0,0,0,0.1)\",\n md: \"0 4px 16px rgba(0,0,0,0.4)\",\n lg: \"0 8px 32px rgba(0,0,0,0.5)\",\n glow: \"0 0 30px rgba(255,255,255,0.6)\"\n}), St = Object.freeze({\n energetic: Object.freeze({ overshoot: 0.25, bounces: 2, decayRatio: 0.5 }),\n playful: Object.freeze({ overshoot: 0.15, bounces: 1, decayRatio: 0.5 }),\n subtle: Object.freeze({ overshoot: 0.08, bounces: 1, decayRatio: 0.5 })\n}), Et = Object.freeze({\n gentle: Object.freeze({ stiffness: 150, damping: 30, mass: 1, oscillations: 2 }),\n bouncy: Object.freeze({ stiffness: 300, damping: 15, mass: 1, oscillations: 4 }),\n wobbly: Object.freeze({ stiffness: 180, damping: 12, mass: 1.5, oscillations: 5 }),\n snappy: Object.freeze({ stiffness: 400, damping: 25, mass: 0.8, oscillations: 2 })\n}), It = Object.freeze({\n gentle: Object.freeze({ amplitude: 30, frequency: 1.5, decay: !0, decayRate: 0.9, phase: 0 }),\n playful: Object.freeze({ amplitude: 50, frequency: 2.5, decay: !0, decayRate: 0.7, phase: 0 }),\n serpentine: Object.freeze({ amplitude: 60, frequency: 3, decay: !1, decayRate: 1, phase: 0 }),\n flutter: Object.freeze({ amplitude: 20, frequency: 4, decay: !0, decayRate: 0.5, phase: 0 })\n}), yt = Object.freeze({\n type: \"linear\"\n}), vt = Object.freeze({\n mode: \"none\"\n}), wt = Object.freeze({\n mode: \"none\"\n}), Ct = Object.freeze({\n default: Object.freeze({\n border: Object.freeze({\n width: 0,\n color: \"#000000\",\n radius: 0,\n style: \"solid\"\n }),\n shadow: \"none\",\n filter: Object.freeze({}),\n opacity: 1,\n cursor: \"pointer\",\n outline: Object.freeze({\n width: 0,\n color: \"#000000\",\n style: \"solid\",\n offset: 0\n })\n }),\n hover: Object.freeze({\n shadow: \"none\"\n }),\n focused: Object.freeze({\n shadow: \"none\"\n })\n}), $t = Object.freeze({\n rows: 1,\n amplitude: 100,\n frequency: 2,\n phaseShift: 0,\n synchronization: \"offset\"\n // Note: Image rotation along wave is now controlled via image.rotation.mode = 'tangent'\n}), Ut = Object.freeze({\n mobile: Object.freeze({ maxWidth: 767 }),\n tablet: Object.freeze({ maxWidth: 1199 })\n}), Pt = Object.freeze({\n mode: \"adaptive\",\n // Default to adaptive sizing\n minSize: 50,\n // Adaptive mode minimum\n maxSize: 400,\n // Adaptive mode maximum\n variance: Object.freeze({\n min: 1,\n // No variance by default\n max: 1\n })\n}), _t = Object.freeze({\n mode: \"none\",\n range: Object.freeze({\n min: -15,\n max: 15\n })\n}), Rt = Object.freeze({\n sizing: Pt,\n rotation: _t\n}), Lt = Object.freeze({\n validateUrls: !0,\n validationTimeout: 5e3,\n validationMethod: \"head\",\n allowedExtensions: [\"jpg\", \"jpeg\", \"png\", \"gif\", \"webp\", \"bmp\"]\n}), Mt = Object.freeze({\n enabled: !1,\n centers: !1,\n loaders: !1\n}), y = Object.freeze({\n // Loader configuration (always an array, composite behavior is implicit)\n loaders: [],\n // Shared loader settings and debug config\n config: Object.freeze({\n loaders: Lt,\n debug: Mt\n }),\n // Image sizing and rotation configuration\n image: Rt,\n // Pattern-based layout configuration\n layout: Object.freeze({\n algorithm: \"radial\",\n scaleDecay: 0,\n // No decay by default (0-1 for radial/spiral)\n responsive: Ut,\n targetCoverage: 0.6,\n // Target 60% of container area\n densityFactor: 1,\n // Default density\n spacing: Object.freeze({\n padding: 50,\n // padding from viewport edges\n minGap: 20\n // minimum spacing between images\n })\n }),\n // Pattern-based animation configuration\n animation: Object.freeze({\n duration: 600,\n // milliseconds\n easing: Object.freeze({\n default: \"cubic-bezier(0.4, 0.0, 0.2, 1)\",\n // smooth easing\n bounce: \"cubic-bezier(0.68, -0.55, 0.265, 1.55)\",\n // bounce effect\n focus: \"cubic-bezier(0.4, 0.0, 0.2, 1)\"\n // focus/zoom easing\n }),\n queue: Object.freeze({\n enabled: !0,\n // When false, all images display simultaneously\n interval: 150,\n // ms between processing queue items (when enabled)\n maxConcurrent: void 0\n // STUB: Not implemented yet\n }),\n performance: Object.freeze({\n useGPU: void 0,\n // STUB: Not implemented yet\n reduceMotion: void 0\n // STUB: Not implemented yet\n }),\n entry: Object.freeze({\n start: Object.freeze({\n position: \"nearest-edge\",\n // Default to nearest edge (current behavior)\n offset: 100,\n // pixels beyond edge\n circular: Object.freeze({\n radius: \"120%\",\n // 120% of container diagonal\n distribution: \"even\"\n })\n }),\n timing: Object.freeze({\n duration: 600\n // ms\n }),\n easing: \"cubic-bezier(0.25, 1, 0.5, 1)\",\n // smooth deceleration\n path: yt,\n rotation: vt,\n scale: wt\n })\n }),\n // Pattern-based interaction configuration\n interaction: Object.freeze({\n focus: Object.freeze({\n scalePercent: 0.8,\n // 80% of container height\n zIndex: 1e3,\n animationDuration: void 0\n // Use default animation duration\n }),\n navigation: Object.freeze({\n keyboard: void 0,\n // STUB: Not implemented yet\n swipe: void 0,\n // STUB: Not implemented yet\n mouseWheel: void 0\n // STUB: Not implemented yet\n }),\n gestures: Object.freeze({\n pinchToZoom: void 0,\n // STUB: Not implemented yet\n doubleTapToFocus: void 0\n // STUB: Not implemented yet\n })\n }),\n // Pattern-based rendering configuration\n rendering: Object.freeze({\n responsive: Object.freeze({\n breakpoints: Object.freeze({\n mobile: 768,\n tablet: void 0,\n // STUB: Not implemented yet\n desktop: void 0\n // STUB: Not implemented yet\n }),\n mobileDetection: () => typeof window > \"u\" ? !1 : window.innerWidth <= 768\n }),\n ui: Object.freeze({\n showLoadingSpinner: !1,\n showImageCounter: !1,\n showThumbnails: void 0,\n // STUB: Not implemented yet\n theme: void 0\n // STUB: Not implemented yet\n }),\n performance: Object.freeze({\n lazyLoad: void 0,\n // STUB: Not implemented yet\n preloadCount: void 0,\n // STUB: Not implemented yet\n imageQuality: void 0\n // STUB: Not implemented yet\n })\n }),\n // Image styling\n styling: Ct\n});\nfunction Q(o, t) {\n if (!o) return t || {};\n if (!t) return { ...o };\n const e = { ...o };\n 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;\n}\nfunction Ht(o, t) {\n if (!t) return { ...o };\n const e = Q(o.default, t.default), i = Q(\n Q(e, o.hover),\n t.hover\n ), n = Q(\n Q(e, o.focused),\n t.focused\n );\n return {\n default: e,\n hover: i,\n focused: n\n };\n}\nfunction Nt(o, t) {\n if (!t) return { ...o };\n const e = { ...o };\n if (t.sizing !== void 0 && (e.sizing = {\n ...o.sizing,\n ...t.sizing\n }, t.sizing.variance)) {\n const i = t.sizing.variance, n = i.min !== void 0 && i.min >= 0.25 && i.min <= 1 ? i.min : o.sizing?.variance?.min ?? 1, s = i.max !== void 0 && i.max >= 1 && i.max <= 1.75 ? i.max : o.sizing?.variance?.max ?? 1;\n e.sizing.variance = { min: n, max: s };\n }\n if (t.rotation !== void 0 && (e.rotation = {\n ...o.rotation,\n ...t.rotation\n }, t.rotation.range)) {\n const i = t.rotation.range, n = i.min !== void 0 && i.min >= -180 && i.min <= 0 ? i.min : o.rotation?.range?.min ?? -15, s = i.max !== void 0 && i.max >= 0 && i.max <= 180 ? i.max : o.rotation?.range?.max ?? 15;\n e.rotation.range = { min: n, max: s };\n }\n return e;\n}\nfunction jt(o) {\n const t = o.layout?.rotation;\n if (t && \"enabled\" in t)\n return {\n rotation: {\n mode: t.enabled ? \"random\" : \"none\",\n range: t.range\n }\n };\n}\nfunction kt(o) {\n const t = o.layout?.sizing?.variance;\n if (t)\n return {\n sizing: {\n mode: \"adaptive\",\n // Legacy variance config implies adaptive mode\n variance: t\n }\n };\n}\nfunction Gt(o = {}) {\n const t = jt(o), e = kt(o);\n let i = o.image;\n (t || e) && (i = {\n ...e || {},\n ...t || {},\n ...i\n }, i.rotation && t?.rotation && o.image?.rotation && (i.rotation = {\n ...t.rotation,\n ...o.image.rotation\n }));\n const n = [...o.loaders ?? []];\n o.images && o.images.length > 0 && n.unshift({\n static: {\n sources: [{ urls: o.images }]\n }\n });\n const r = {\n loaders: {\n ...Lt,\n ...o.config?.loaders ?? {}\n }\n }, a = {\n loaders: n,\n config: r,\n image: Nt(Rt, i),\n layout: { ...y.layout },\n animation: { ...y.animation },\n interaction: { ...y.interaction },\n rendering: { ...y.rendering },\n styling: Ht(Ct, o.styling)\n };\n return o.layout && (a.layout = {\n ...y.layout,\n ...o.layout\n }, o.layout.responsive && (a.layout.responsive = {\n ...y.layout.responsive,\n mobile: o.layout.responsive.mobile ? { ...y.layout.responsive.mobile, ...o.layout.responsive.mobile } : y.layout.responsive.mobile,\n tablet: o.layout.responsive.tablet ? { ...y.layout.responsive.tablet, ...o.layout.responsive.tablet } : y.layout.responsive.tablet\n }), o.layout.spacing && (a.layout.spacing = {\n ...y.layout.spacing,\n ...o.layout.spacing\n })), o.animation && (a.animation = {\n ...y.animation,\n ...o.animation\n }, o.animation.easing && (a.animation.easing = {\n ...y.animation.easing,\n ...o.animation.easing\n }), o.animation.queue && (a.animation.queue = {\n ...y.animation.queue,\n ...o.animation.queue\n }), o.animation.performance && (a.animation.performance = {\n ...y.animation.performance,\n ...o.animation.performance\n }), o.animation.entry && (a.animation.entry = {\n ...y.animation.entry,\n ...o.animation.entry,\n start: o.animation.entry.start ? {\n ...y.animation.entry.start,\n ...o.animation.entry.start,\n circular: o.animation.entry.start.circular ? { ...y.animation.entry.start.circular, ...o.animation.entry.start.circular } : y.animation.entry.start.circular\n } : y.animation.entry.start,\n timing: o.animation.entry.timing ? { ...y.animation.entry.timing, ...o.animation.entry.timing } : y.animation.entry.timing,\n path: o.animation.entry.path ? { ...yt, ...o.animation.entry.path } : y.animation.entry.path,\n rotation: o.animation.entry.rotation ? { ...vt, ...o.animation.entry.rotation } : y.animation.entry.rotation,\n scale: o.animation.entry.scale ? { ...wt, ...o.animation.entry.scale } : y.animation.entry.scale\n })), o.interaction && (a.interaction = {\n ...y.interaction,\n ...o.interaction\n }, o.interaction.focus && (a.interaction.focus = {\n ...y.interaction.focus,\n ...o.interaction.focus\n }), o.interaction.navigation && (a.interaction.navigation = {\n ...y.interaction.navigation,\n ...o.interaction.navigation\n }), o.interaction.gestures && (a.interaction.gestures = {\n ...y.interaction.gestures,\n ...o.interaction.gestures\n })), o.rendering && (a.rendering = {\n ...y.rendering,\n ...o.rendering\n }, o.rendering.responsive && (a.rendering.responsive = {\n ...y.rendering.responsive,\n ...o.rendering.responsive,\n breakpoints: o.rendering.responsive.breakpoints ? { ...y.rendering.responsive.breakpoints, ...o.rendering.responsive.breakpoints } : y.rendering.responsive.breakpoints,\n mobileDetection: o.rendering.responsive.mobileDetection ? o.rendering.responsive.mobileDetection : y.rendering.responsive.mobileDetection\n }), o.rendering.ui && (a.rendering.ui = {\n ...y.rendering.ui,\n ...o.rendering.ui\n }), o.rendering.performance && (a.rendering.performance = {\n ...y.rendering.performance,\n ...o.rendering.performance\n })), a.config.debug = {\n ...Mt,\n ...o.config?.debug ?? {}\n }, a;\n}\nfunction Wt(o, t) {\n return { ...o ? St[o] : St.playful, ...t };\n}\nfunction qt(o, t) {\n return { ...o ? Et[o] : Et.gentle, ...t };\n}\nfunction Yt(o, t) {\n return { ...o ? It[o] : It.gentle, ...t };\n}\nclass Xt {\n constructor(t) {\n this.activeAnimations = /* @__PURE__ */ new Map(), this.animationIdCounter = 0, this.config = t;\n }\n /**\n * Build transform string from transform params\n * Always starts with centering transform to match image positioning system\n */\n buildTransformString(t) {\n const e = [\"translate(-50%, -50%)\"];\n if (t.x !== void 0 || t.y !== void 0) {\n const i = t.x ?? 0, n = t.y ?? 0;\n e.push(`translate(${i}px, ${n}px)`);\n }\n return t.rotation !== void 0 && e.push(`rotate(${t.rotation}deg)`), t.scale !== void 0 && e.push(`scale(${t.scale})`), e.join(\" \");\n }\n /**\n * Start a cancellable transform animation using Web Animations API\n * @param element - The element to animate\n * @param from - Starting transform state\n * @param to - Ending transform state\n * @param duration - Animation duration in ms (optional)\n * @param easing - CSS easing function (optional)\n * @returns AnimationHandle that can be used to cancel or query the animation\n */\n animateTransformCancellable(t, e, i, n = null, s = null) {\n this.cancelAllAnimations(t);\n const r = n ?? this.config.duration, a = s ?? this.config.easing.default, h = this.buildTransformString(e), c = this.buildTransformString(i);\n t.style.transition = \"none\";\n const u = t.animate(\n [\n { transform: h },\n { transform: c }\n ],\n {\n duration: r,\n easing: a,\n fill: \"forwards\"\n // Keep final state after animation\n }\n ), l = {\n id: `anim-${++this.animationIdCounter}`,\n element: t,\n animation: u,\n fromState: e,\n toState: i,\n startTime: performance.now(),\n duration: r\n };\n return this.activeAnimations.set(t, l), u.finished.then(() => {\n t.style.transform = c, this.activeAnimations.delete(t);\n }).catch(() => {\n this.activeAnimations.delete(t);\n }), l;\n }\n /**\n * Cancel an active animation\n * @param handle - The animation handle to cancel\n * @param commitStyle - If true, keeps current position; if false, no style change\n * @returns Snapshot of where the animation was when cancelled\n */\n cancelAnimation(t, e = !0) {\n const i = this.getCurrentTransform(t.element);\n if (t.animation.cancel(), e) {\n const n = this.buildTransformString({\n x: i.x,\n y: i.y,\n rotation: i.rotation,\n scale: i.scale\n });\n t.element.style.transform = n;\n }\n return this.activeAnimations.delete(t.element), i;\n }\n /**\n * Cancel all animations on an element\n * Uses Web Animations API to find and cancel ALL animations, not just tracked ones\n * @param element - The element to cancel animations for\n */\n cancelAllAnimations(t) {\n const e = this.activeAnimations.get(t);\n e && this.cancelAnimation(e, !1);\n const i = t.getAnimations();\n for (const n of i)\n n.cancel();\n }\n /**\n * Get current transform state of an element (works mid-animation)\n * Uses DOMMatrix to parse the computed transform\n * @param element - The element to query\n * @returns Current transform snapshot\n */\n getCurrentTransform(t) {\n const i = getComputedStyle(t).transform;\n if (i === \"none\" || !i)\n return { x: 0, y: 0, rotation: 0, scale: 1 };\n 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;\n return { x: a, y: h, rotation: r, scale: s };\n }\n /**\n * Check if an element has an active animation\n * @param element - The element to check\n * @returns True if animation is in progress\n */\n hasActiveAnimation(t) {\n return this.activeAnimations.has(t);\n }\n /**\n * Get animation handle for an element if it exists\n * @param element - The element to query\n * @returns AnimationHandle or undefined\n */\n getAnimationHandle(t) {\n return this.activeAnimations.get(t);\n }\n /**\n * Animate element transform with smooth easing (CSS transitions - legacy method)\n * @param element - The element to animate\n * @param properties - Transform properties {x, y, rotation, scale}\n * @param duration - Animation duration in ms (optional)\n * @param easing - CSS easing function (optional)\n * @returns Promise that resolves when animation completes\n */\n animateTransform(t, e, i = null, n = null) {\n return new Promise((s) => {\n const r = i ?? this.config.duration, a = n ?? this.config.easing.default;\n t.style.transition = `transform ${r}ms ${a}, box-shadow ${r}ms ${a}`, t.style.transform = this.buildTransformString(e), setTimeout(() => {\n s();\n }, r);\n });\n }\n /**\n * Reset element to its original transform\n * @param element - The element to reset\n * @param originalState - Original transform state {x, y, rotation, scale}\n * @returns Promise that resolves when animation completes\n */\n resetTransform(t, e) {\n return this.animateTransform(t, e);\n }\n /**\n * Remove transition styles from element\n * @param element - The element to clear\n */\n clearTransition(t) {\n t.style.transition = \"\";\n }\n /**\n * Utility: Wait for a specified duration\n * @param ms - Milliseconds to wait\n * @returns Promise that resolves after the specified duration\n */\n wait(t) {\n return new Promise((e) => setTimeout(e, t));\n }\n}\nfunction V(o, t, e) {\n return o + (t - o) * e;\n}\nfunction Bt(o, t, e, i) {\n const { overshoot: n, bounces: s, decayRatio: r } = i, a = e.x - t.x, h = e.y - t.y, c = Jt(s, r);\n let u = 0, l = 0, d = 1, m = n, b = !1;\n for (let g = 0; g < c.length; g++)\n if (o <= c[g].time) {\n l = g === 0 ? 0 : c[g - 1].time, d = c[g].time, m = c[g].overshoot, b = c[g].isOvershoot;\n break;\n }\n const p = (o - l) / (d - l);\n if (b)\n u = 1 + m * at(p);\n else if (l === 0)\n u = at(p);\n else {\n const f = 1 + (c.find(\n (S, v) => S.time > l && v > 0 && c[v - 1].isOvershoot\n )?.overshoot || m);\n u = V(f, 1, at(p));\n }\n return {\n x: t.x + a * u,\n y: t.y + h * u\n };\n}\nfunction Jt(o, t) {\n const e = [];\n let i = 0.6;\n e.push({ time: i, overshoot: 0, isOvershoot: !1 });\n let n = 0.15;\n const r = 0.4 / (o * 2);\n for (let a = 0; a < o; a++)\n i += r, e.push({ time: i, overshoot: n, isOvershoot: !0 }), i += r, e.push({ time: i, overshoot: n * t, isOvershoot: !1 }), n *= t;\n return e.push({ time: 1, overshoot: 0, isOvershoot: !1 }), e;\n}\nfunction Vt(o, t, e, i) {\n const { stiffness: n, damping: s, mass: r, oscillations: a } = i, h = e.x - t.x, c = e.y - t.y, u = Math.sqrt(n / r), l = s / (2 * Math.sqrt(n * r));\n let d;\n if (l < 1) {\n const m = u * Math.sqrt(1 - l * l), b = Math.exp(-l * u * o * 3), p = Math.cos(m * o * a * Math.PI);\n d = 1 - b * p;\n } else\n d = 1 - Math.exp(-u * o * 3);\n return d = Math.max(0, Math.min(d, 1.3)), {\n x: t.x + h * d,\n y: t.y + c * d\n };\n}\nfunction Kt(o, t, e, i) {\n const { amplitude: n, frequency: s, decay: r, decayRate: a, phase: h } = i, c = e.x - t.x, u = e.y - t.y, l = Math.sqrt(c * c + u * u), d = l > 0 ? -u / l : 0, m = l > 0 ? c / l : 1, b = s * Math.PI * 2 * o + h, p = r ? Math.pow(1 - o, a) : 1, g = n * Math.sin(b) * p, f = Zt(o);\n return {\n x: V(t.x, e.x, f) + g * d,\n y: V(t.y, e.y, f) + g * m\n };\n}\nfunction at(o) {\n return 1 - (1 - o) * (1 - o);\n}\nfunction Zt(o) {\n return 1 - Math.pow(1 - o, 3);\n}\nfunction Qt(o, t, e) {\n 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;\n return t + h;\n}\nfunction te(o, t, e) {\n const { overshoot: i, bounces: n } = e, s = [];\n s.push({ time: 0.5, scale: i });\n let r = i;\n const a = 0.5, c = 0.5 / (n * 2);\n let u = 0.5;\n for (let d = 0; d < n; d++) {\n const m = 1 - (r - 1) * a;\n u += c, s.push({ time: u, scale: m }), r = 1 + (r - 1) * a * a, u += c, d < n - 1 && s.push({ time: u, scale: r });\n }\n s.push({ time: 1, scale: 1 });\n let l = 1;\n for (let d = 0; d < s.length; d++)\n if (o <= s[d].time) {\n const m = d === 0 ? 0 : s[d - 1].time, b = d === 0 ? 1 : s[d - 1].scale, p = (o - m) / (s[d].time - m), g = at(p);\n l = b + (s[d].scale - b) * g;\n break;\n }\n return l * t;\n}\nfunction ee(o) {\n const {\n element: t,\n startPosition: e,\n endPosition: i,\n pathConfig: n,\n duration: s,\n imageWidth: r,\n imageHeight: a,\n rotation: h,\n scale: c,\n onComplete: u,\n rotationConfig: l,\n startRotation: d,\n scaleConfig: m,\n startScale: b\n } = o, p = n.type, g = d !== void 0 && d !== h, f = l?.mode === \"wobble\", S = l?.wobble || { amplitude: 15, frequency: 3, decay: !0 }, v = g || f, w = b !== void 0 && b !== c, E = m?.mode === \"pop\", x = m?.pop || { overshoot: 1.2, bounces: 1 };\n if ((p === \"linear\" || p === \"arc\") && !v && !(w || E)) {\n u && u();\n return;\n }\n const M = performance.now(), z = -r / 2, P = -a / 2;\n function _(Y) {\n const N = Y - M, T = Math.min(N / s, 1);\n let D;\n switch (p) {\n case \"bounce\": {\n const O = Wt(\n n.bouncePreset,\n n.bounce\n );\n D = Bt(T, e, i, O);\n break;\n }\n case \"elastic\": {\n const O = qt(\n n.elasticPreset,\n n.elastic\n );\n D = Vt(T, e, i, O);\n break;\n }\n case \"wave\": {\n const O = Yt(\n n.wavePreset,\n n.wave\n );\n D = Kt(T, e, i, O);\n break;\n }\n default:\n D = {\n x: V(e.x, i.x, T),\n y: V(e.y, i.y, T)\n };\n }\n const k = D.x - i.x, H = D.y - i.y;\n let R;\n f ? R = Qt(T, h, S) : g ? R = V(d, h, T) : R = h;\n let C;\n E ? C = te(T, c, x) : w ? C = V(b, c, T) : C = c, t.style.transform = `translate(${z}px, ${P}px) translate(${k}px, ${H}px) rotate(${R}deg) scale(${C})`, T < 1 ? requestAnimationFrame(_) : (t.style.transform = `translate(${z}px, ${P}px) rotate(${h}deg) scale(${c})`, u && u());\n }\n requestAnimationFrame(_);\n}\nfunction ie(o) {\n return o === \"bounce\" || o === \"elastic\" || o === \"wave\";\n}\nconst ne = {\n radial: \"center\",\n spiral: \"center\",\n grid: \"top\",\n cluster: \"nearest-edge\",\n random: \"nearest-edge\",\n wave: \"left\"\n};\nclass oe {\n constructor(t, e) {\n this.config = t, this.layoutAlgorithm = e, this.resolvedStartPosition = this.resolveStartPosition(), this.pathConfig = t.path || yt, this.rotationConfig = t.rotation || vt, this.scaleConfig = t.scale || wt;\n }\n /**\n * Get the effective start position, considering layout-aware defaults\n */\n resolveStartPosition() {\n return this.config.start.position ? this.config.start.position : ne[this.layoutAlgorithm] || \"nearest-edge\";\n }\n /**\n * Calculate the starting position for an image's entry animation\n */\n calculateStartPosition(t, e, i, n, s) {\n const r = this.resolvedStartPosition, a = this.config.start.offset ?? 100;\n switch (r) {\n case \"nearest-edge\":\n return this.calculateNearestEdge(t, e, i, a);\n case \"top\":\n return this.calculateEdgePosition(\"top\", t, e, i, a);\n case \"bottom\":\n return this.calculateEdgePosition(\"bottom\", t, e, i, a);\n case \"left\":\n return this.calculateEdgePosition(\"left\", t, e, i, a);\n case \"right\":\n return this.calculateEdgePosition(\"right\", t, e, i, a);\n case \"center\":\n return this.calculateCenterPosition(i, t, e);\n case \"random-edge\":\n return this.calculateRandomEdge(t, e, i, a);\n case \"circular\":\n return this.calculateCircularPosition(\n t,\n e,\n i,\n n,\n s\n );\n default:\n return this.calculateNearestEdge(t, e, i, a);\n }\n }\n /**\n * Calculate start position from the nearest edge (current default behavior)\n */\n calculateNearestEdge(t, e, i, n) {\n const s = t.x, r = t.y, a = s, h = i.width - s, c = r, u = i.height - r, l = Math.min(a, h, c, u);\n let d = t.x, m = t.y;\n return l === a ? d = -(e.width + n) : l === h ? d = i.width + n : l === c ? m = -(e.height + n) : m = i.height + n, { x: d, y: m };\n }\n /**\n * Calculate start position from a specific edge\n */\n calculateEdgePosition(t, e, i, n, s) {\n let r = e.x, a = e.y;\n switch (t) {\n case \"top\":\n a = -(i.height + s);\n break;\n case \"bottom\":\n a = n.height + s;\n break;\n case \"left\":\n r = -(i.width + s);\n break;\n case \"right\":\n r = n.width + s;\n break;\n }\n return { x: r, y: a };\n }\n /**\n * Calculate start position from center with scale animation\n */\n calculateCenterPosition(t, e, i) {\n const n = t.width / 2, s = t.height / 2;\n return {\n x: n,\n y: s,\n useScale: !0\n // Signal to use scale animation from 0\n };\n }\n /**\n * Calculate start position from a random edge\n */\n calculateRandomEdge(t, e, i, n) {\n const s = [\"top\", \"bottom\", \"left\", \"right\"], r = s[Math.floor(Math.random() * s.length)];\n return this.calculateEdgePosition(r, t, e, i, n);\n }\n /**\n * Calculate start position on a circle around the container\n */\n calculateCircularPosition(t, e, i, n, s) {\n const r = this.config.start.circular || {}, a = r.distribution || \"even\";\n let h;\n const c = r.radius || \"120%\";\n if (typeof c == \"string\" && c.endsWith(\"%\")) {\n const p = parseFloat(c) / 100;\n h = Math.sqrt(\n i.width ** 2 + i.height ** 2\n ) * p / 2;\n } else\n h = typeof c == \"number\" ? c : 500;\n let u;\n a === \"even\" ? u = n / s * 2 * Math.PI : u = Math.random() * 2 * Math.PI;\n const l = i.width / 2, d = i.height / 2, m = l + Math.cos(u) * h, b = d + Math.sin(u) * h;\n return { x: m, y: b };\n }\n /**\n * Get animation parameters for an image\n */\n getAnimationParams(t) {\n const e = this.config.timing.duration, i = this.config.easing;\n return {\n startTransform: \"\",\n // Will be computed by caller based on start position\n duration: e,\n delay: 0,\n easing: i\n };\n }\n /**\n * Build a CSS transform string for the start position\n * Uses pixel-based centering offset for reliable cross-browser behavior\n */\n buildStartTransform(t, e, i, n, s, r, a, h) {\n const c = t.x - e.x, u = t.y - e.y, l = a !== void 0 ? a : i, d = h !== void 0 ? h : n, m = s !== void 0 ? -s / 2 : 0, b = r !== void 0 ? -r / 2 : 0, p = s !== void 0 ? `translate(${m}px, ${b}px)` : \"translate(-50%, -50%)\";\n return t.useScale ? `${p} translate(${c}px, ${u}px) rotate(${l}deg) scale(0)` : `${p} translate(${c}px, ${u}px) rotate(${l}deg) scale(${d})`;\n }\n /**\n * Build the final CSS transform string\n * Uses pixel-based centering offset for reliable cross-browser behavior\n */\n buildFinalTransform(t, e, i, n) {\n if (i !== void 0 && n !== void 0) {\n const s = -i / 2, r = -n / 2;\n return `translate(${s}px, ${r}px) rotate(${t}deg) scale(${e})`;\n }\n return `translate(-50%, -50%) rotate(${t}deg) scale(${e})`;\n }\n /**\n * Get the transition CSS for entry animation\n * For JS-animated paths, only animate opacity (transform handled by JS)\n */\n getTransitionCSS() {\n const t = this.config.timing.duration, e = this.config.easing;\n return this.requiresJSAnimation() ? `opacity ${t}ms ease-out` : `opacity ${t}ms ease-out, transform ${t}ms ${e}`;\n }\n /**\n * Check if the current path type requires JavaScript animation\n */\n requiresJSAnimation() {\n return ie(this.pathConfig.type);\n }\n /**\n * Get the path configuration\n */\n getPathConfig() {\n return this.pathConfig;\n }\n /**\n * Get the path type\n */\n getPathType() {\n return this.pathConfig.type;\n }\n /**\n * Get animation timing configuration\n */\n getTiming() {\n return {\n duration: this.config.timing.duration\n };\n }\n /**\n * Get the rotation configuration\n */\n getRotationConfig() {\n return this.rotationConfig;\n }\n /**\n * Get the rotation mode\n */\n getRotationMode() {\n return this.rotationConfig.mode;\n }\n /**\n * Calculate the starting rotation for an entry animation\n * @param finalRotation - The final rotation from the layout\n * @returns The starting rotation in degrees\n */\n calculateStartRotation(t) {\n switch (this.rotationConfig.mode) {\n case \"none\":\n return t;\n case \"settle\": {\n const i = this.rotationConfig.startRotation;\n if (i === void 0)\n return t + (Math.random() - 0.5) * 60;\n if (typeof i == \"number\")\n return i;\n const n = i.max - i.min;\n return i.min + Math.random() * n;\n }\n case \"spin\": {\n const i = this.rotationConfig.spinCount ?? 1, n = this.resolveSpinDirection(t);\n return t + i * 360 * n;\n }\n case \"random\":\n return t + (Math.random() - 0.5) * 60;\n case \"wobble\":\n return t;\n default:\n return t;\n }\n }\n /**\n * Resolve spin direction based on config\n * @returns 1 for clockwise, -1 for counterclockwise\n */\n resolveSpinDirection(t) {\n switch (this.rotationConfig.direction ?? \"auto\") {\n case \"clockwise\":\n return -1;\n // Negative rotation = clockwise spin to final\n case \"counterclockwise\":\n return 1;\n // Positive rotation = counterclockwise spin to final\n case \"random\":\n return Math.random() < 0.5 ? 1 : -1;\n default:\n return t >= 0 ? 1 : -1;\n }\n }\n /**\n * Check if the current rotation mode requires JavaScript animation\n * (as opposed to CSS transitions)\n */\n requiresJSRotation() {\n return this.rotationConfig.mode === \"wobble\";\n }\n /**\n * Calculate wobble rotation for a given animation progress\n * @param progress - Animation progress from 0 to 1\n * @param finalRotation - The final rotation in degrees\n * @returns The current rotation in degrees\n */\n calculateWobbleRotation(t, e) {\n if (this.rotationConfig.mode !== \"wobble\")\n return e;\n const i = this.rotationConfig.wobble || {\n amplitude: 15,\n frequency: 3,\n decay: !0\n }, { amplitude: n, frequency: s, decay: r } = i, a = Math.sin(t * s * Math.PI * 2), h = r ? Math.pow(1 - t, 2) : 1, c = n * a * h;\n return e + c;\n }\n /**\n * Get the scale configuration\n */\n getScaleConfig() {\n return this.scaleConfig;\n }\n /**\n * Get the scale mode\n */\n getScaleMode() {\n return this.scaleConfig.mode;\n }\n /**\n * Calculate the starting scale for an entry animation\n * @param finalScale - The final scale from the layout\n * @returns The starting scale\n */\n calculateStartScale(t) {\n switch (this.scaleConfig.mode) {\n case \"none\":\n return t;\n case \"grow\":\n return (this.scaleConfig.startScale ?? 0.3) * t;\n case \"shrink\":\n return (this.scaleConfig.startScale ?? 1.5) * t;\n case \"pop\":\n return t;\n case \"random\": {\n const i = this.scaleConfig.range ?? { min: 0.5, max: 1 };\n return (i.min + Math.random() * (i.max - i.min)) * t;\n }\n default:\n return t;\n }\n }\n /**\n * Check if the current scale mode requires JavaScript animation\n * (as opposed to CSS transitions)\n */\n requiresJSScale() {\n return this.scaleConfig.mode === \"pop\";\n }\n /**\n * Calculate pop scale for a given animation progress\n * @param progress - Animation progress from 0 to 1\n * @param finalScale - The final scale value\n * @returns The current scale value with bounce effect\n */\n calculatePopScale(t, e) {\n if (this.scaleConfig.mode !== \"pop\")\n return e;\n const i = this.scaleConfig.pop || {\n overshoot: 1.2,\n bounces: 1\n }, { overshoot: n, bounces: s } = i, r = this.generateScaleBounceKeyframes(s, n);\n let a = e;\n for (let h = 0; h < r.length; h++)\n if (t <= r[h].time) {\n const c = h === 0 ? 0 : r[h - 1].time, u = h === 0 ? e : r[h - 1].scale, l = (t - c) / (r[h].time - c), d = this.easeOutQuad(l);\n a = u + (r[h].scale - u) * d;\n break;\n }\n return a * e;\n }\n /**\n * Generate keyframes for scale bounce animation\n */\n generateScaleBounceKeyframes(t, e) {\n const i = [];\n i.push({ time: 0.5, scale: e });\n let n = e;\n const s = 0.5, a = 0.5 / (t * 2);\n let h = 0.5;\n for (let c = 0; c < t; c++) {\n const u = 1 - (n - 1) * s;\n h += a, i.push({ time: h, scale: u }), n = 1 + (n - 1) * s * s, h += a, c < t - 1 && i.push({ time: h, scale: n });\n }\n return i.push({ time: 1, scale: 1 }), i;\n }\n /**\n * Easing function for smooth transitions\n */\n easeOutQuad(t) {\n return 1 - (1 - t) * (1 - t);\n }\n}\nclass se {\n constructor(t, e = {}) {\n this.config = t, this.imageConfig = e;\n }\n /**\n * Generate random layout positions for images\n * @param imageCount - Number of images to layout\n * @param containerBounds - Container dimensions {width, height}\n * @param options - Optional overrides (includes fixedHeight)\n * @returns Array of layout objects with position, rotation, scale\n */\n generate(t, e, i = {}) {\n const n = [], { width: s, height: r } = e, a = this.config.spacing.padding, h = i.fixedHeight ?? 200, c = this.imageConfig.rotation?.mode ?? \"none\", u = this.imageConfig.rotation?.range?.min ?? -15, l = this.imageConfig.rotation?.range?.max ?? 15, d = this.imageConfig.sizing?.variance?.min ?? 1, m = this.imageConfig.sizing?.variance?.max ?? 1, b = d !== 1 || m !== 1, g = h * 1.5 / 2, f = h / 2, S = s - a - g, v = r - a - f, w = a + g, E = a + f;\n for (let x = 0; x < t; x++) {\n const A = this.random(w, S), M = this.random(E, v), z = c === \"random\" ? this.random(u, l) : 0, P = b ? this.random(d, m) : 1, _ = h * P, Y = {\n id: x,\n x: A,\n y: M,\n rotation: z,\n scale: P,\n baseSize: _\n };\n n.push(Y);\n }\n return n;\n }\n /**\n * Utility: Generate random number between min and max\n * @param min - Minimum value\n * @param max - Maximum value\n * @returns Random number in range\n */\n random(t, e) {\n return Math.random() * (e - t) + t;\n }\n}\nclass ae {\n constructor(t, e = {}) {\n this.config = t, this.imageConfig = e;\n }\n /**\n * Generate radial layout positions for images\n * @param imageCount - Number of images to layout\n * @param containerBounds - Container dimensions {width, height}\n * @param options - Optional overrides\n * @returns Array of layout objects with position, rotation, scale\n */\n generate(t, e, i = {}) {\n const n = [], { width: s, height: r } = e, a = i.fixedHeight ?? 200, h = this.imageConfig.rotation?.mode ?? \"none\", c = this.imageConfig.rotation?.range?.min ?? -15, u = this.imageConfig.rotation?.range?.max ?? 15, l = this.imageConfig.sizing?.variance?.min ?? 1, d = this.imageConfig.sizing?.variance?.max ?? 1, m = l !== 1 || d !== 1, b = this.config.scaleDecay ?? 0, p = i.fixedHeight ?? a, g = s / 2, f = r / 2, S = Math.ceil(Math.sqrt(t));\n if (t > 0) {\n const E = m ? this.random(l, d) : 1, x = p * E;\n n.push({\n id: 0,\n x: g,\n y: f,\n rotation: h === \"random\" ? this.random(c * 0.33, u * 0.33) : 0,\n // Less rotation for center\n scale: E,\n baseSize: x,\n zIndex: 100\n // Center image is highest\n });\n }\n let v = 1, w = 1;\n for (; v < t; ) {\n const E = w / S, x = b > 0 ? 1 - E * b * 0.5 : 1, A = w * (p * 0.8), M = A * 1.5, z = Math.PI * (3 * (M + A) - Math.sqrt((3 * M + A) * (M + 3 * A))), P = this.estimateWidth(p), _ = Math.floor(z / (P * 0.7));\n if (_ === 0) {\n w++;\n continue;\n }\n const Y = 2 * Math.PI / _, N = w * (20 * Math.PI / 180);\n for (let T = 0; T < _ && v < t; T++) {\n const D = T * Y + N, k = m ? this.random(l, d) : 1, H = x * k, R = p * H;\n let C = g + Math.cos(D) * M, O = f + Math.sin(D) * A;\n const $ = this.config.spacing.padding ?? 50, U = R * 1.5 / 2, L = R / 2;\n C - U < $ ? C = $ + U : C + U > s - $ && (C = s - $ - U), O - L < $ ? O = $ + L : O + L > r - $ && (O = r - $ - L);\n const G = h === \"random\" ? this.random(c, u) : 0;\n n.push({\n id: v,\n x: C,\n y: O,\n rotation: G,\n scale: H,\n baseSize: R,\n zIndex: Math.max(1, 100 - w)\n // Outer rings have lower z-index\n }), v++;\n }\n w++;\n }\n return n;\n }\n /**\n * Estimate image width based on height\n * Assumes landscape aspect ratio (approximately 1.4:1)\n * @param height - Image height\n * @returns Estimated width\n */\n estimateWidth(t) {\n return t * 1.4;\n }\n /**\n * Utility: Generate random number between min and max\n * @param min - Minimum value\n * @param max - Maximum value\n * @returns Random number in range\n */\n random(t, e) {\n return Math.random() * (e - t) + t;\n }\n}\nconst re = {\n columns: \"auto\",\n rows: \"auto\",\n stagger: \"none\",\n jitter: 0,\n overlap: 0,\n fillDirection: \"row\",\n alignment: \"center\",\n gap: 10,\n overflowOffset: 0.25\n}, At = [\n { x: 1, y: 1 },\n // bottom-right\n { x: -1, y: -1 },\n // upper-left\n { x: 1, y: -1 },\n // upper-right\n { x: -1, y: 1 },\n // bottom-left\n { x: -1, y: 0 },\n // left\n { x: 1, y: 0 },\n // right\n { x: 0, y: -1 },\n // up\n { x: 0, y: 1 }\n // down\n];\nclass ce {\n constructor(t, e = {}) {\n this.config = t, this.imageConfig = e;\n }\n /**\n * Generate grid layout positions for images\n * @param imageCount - Number of images to layout\n * @param containerBounds - Container dimensions {width, height}\n * @param options - Optional overrides (includes fixedHeight)\n * @returns Array of layout objects with position, rotation, scale\n */\n generate(t, e, i = {}) {\n const n = [], { width: s, height: r } = e, a = { ...re, ...this.config.grid }, h = this.config.spacing.padding, c = i.fixedHeight ?? 200, u = this.imageConfig.rotation?.mode ?? \"none\", l = this.imageConfig.sizing?.variance?.min ?? 1, d = this.imageConfig.sizing?.variance?.max ?? 1, m = l !== 1 || d !== 1, b = s - 2 * h, p = r - 2 * h, { columns: g, rows: f } = this.calculateGridDimensions(\n t,\n b,\n p,\n c,\n a\n ), S = a.stagger === \"row\", v = a.stagger === \"column\", w = S ? g + 0.5 : g, E = v ? f + 0.5 : f, x = (b - a.gap * (g - 1)) / w, A = (p - a.gap * (f - 1)) / E, M = S ? x / 2 : 0, z = v ? A / 2 : 0, P = 1 + a.overlap, _ = Math.min(x, A) * P, Y = i.fixedHeight ? Math.min(i.fixedHeight, _) : _, N = g * x + (g - 1) * a.gap + M, T = f * A + (f - 1) * a.gap + z, D = h + (b - N) / 2, k = h + (p - T) / 2, H = g * f, R = a.columns !== \"auto\" && a.rows !== \"auto\", C = R && t > H;\n typeof window < \"u\" && (window.__gridOverflowDebug = {\n gridConfigColumns: a.columns,\n gridConfigRows: a.rows,\n columns: g,\n rows: f,\n cellCount: H,\n hasFixedGrid: R,\n imageCount: t,\n isOverflowMode: C\n });\n const O = C ? new Array(H).fill(0) : [], $ = Math.min(x, A) * a.overflowOffset;\n for (let F = 0; F < t; F++) {\n let U, L, G = 0;\n if (C && F >= H) {\n const q = F - H, j = q % H;\n G = Math.floor(q / H) + 1, O[j]++, a.fillDirection === \"row\" ? (U = j % g, L = Math.floor(j / g)) : (L = j % f, U = Math.floor(j / f));\n } else\n a.fillDirection === \"row\" ? (U = F % g, L = Math.floor(F / g)) : (L = F % f, U = Math.floor(F / f));\n let W = D + U * (x + a.gap) + x / 2, X = k + L * (A + a.gap) + A / 2;\n if (a.stagger === \"row\" && L % 2 === 1 ? W += x / 2 : a.stagger === \"column\" && U % 2 === 1 && (X += A / 2), G > 0) {\n const q = (G - 1) % At.length, j = At[q];\n W += j.x * $, X += j.y * $;\n }\n if (a.jitter > 0) {\n const q = x / 2 * a.jitter, j = A / 2 * a.jitter;\n W += this.random(-q, q), X += this.random(-j, j);\n }\n let B = W, J = X;\n if (!C && a.fillDirection === \"row\") {\n const q = t % g || g;\n if (L === Math.floor((t - 1) / g) && q < g) {\n const xt = q * x + (q - 1) * a.gap;\n let ft = 0;\n a.alignment === \"center\" ? ft = (N - xt) / 2 : a.alignment === \"end\" && (ft = N - xt), B += ft;\n }\n }\n const lt = m ? this.random(l, d) : 1, K = Y * lt, ot = K * 1.5 / 2, st = K / 2, dt = h + ot, ut = s - h - ot, Dt = h + st, Ot = r - h - st;\n B = Math.max(dt, Math.min(B, ut)), J = Math.max(Dt, Math.min(J, Ot));\n let gt = 0;\n if (u === \"random\") {\n const q = this.imageConfig.rotation?.range?.min ?? -15, j = this.imageConfig.rotation?.range?.max ?? 15;\n a.jitter > 0 ? gt = this.random(q * a.jitter, j * a.jitter) : gt = this.random(q, j);\n }\n let mt;\n C && G > 0 ? mt = 50 - G : mt = C ? 100 + F : F + 1, n.push({\n id: F,\n x: B,\n y: J,\n rotation: gt,\n scale: lt,\n baseSize: K,\n zIndex: mt\n });\n }\n return n;\n }\n /**\n * Calculate optimal grid dimensions based on image count and container\n */\n calculateGridDimensions(t, e, i, n, s) {\n let r, a;\n if (s.columns !== \"auto\" && s.rows !== \"auto\")\n r = s.columns, a = s.rows;\n else if (s.columns !== \"auto\")\n r = s.columns, a = Math.ceil(t / r);\n else if (s.rows !== \"auto\")\n a = s.rows, r = Math.ceil(t / a);\n else {\n const h = e / i;\n for (r = Math.max(1, Math.round(Math.sqrt(t * h / 1.4))), a = Math.ceil(t / r); r > 1 && (r - 1) * a >= t; )\n r--;\n }\n return { columns: Math.max(1, r), rows: Math.max(1, a) };\n }\n /**\n * Utility: Generate random number between min and max\n */\n random(t, e) {\n return Math.random() * (e - t) + t;\n }\n}\nconst le = Math.PI * (3 - Math.sqrt(5)), he = {\n spiralType: \"golden\",\n direction: \"counterclockwise\",\n tightness: 1,\n scaleDecay: 0,\n startAngle: 0\n};\nclass de {\n constructor(t, e = {}) {\n this.config = t, this.imageConfig = e;\n }\n /**\n * Generate spiral layout positions for images\n * @param imageCount - Number of images to layout\n * @param containerBounds - Container dimensions {width, height}\n * @param options - Optional overrides (includes fixedHeight)\n * @returns Array of layout objects with position, rotation, scale\n */\n generate(t, e, i = {}) {\n const n = [], { width: s, height: r } = e, a = { ...he, ...this.config.spiral }, h = this.config.spacing.padding, c = i.fixedHeight ?? 200, u = this.imageConfig.rotation?.mode ?? \"none\", l = this.imageConfig.rotation?.range?.min ?? -15, d = this.imageConfig.rotation?.range?.max ?? 15, m = this.imageConfig.sizing?.variance?.min ?? 1, b = this.imageConfig.sizing?.variance?.max ?? 1, p = m !== 1 || b !== 1, g = this.config.scaleDecay ?? a.scaleDecay, f = s / 2, S = r / 2, v = Math.min(\n f - h - c / 2,\n S - h - c / 2\n ), w = a.direction === \"clockwise\" ? -1 : 1;\n for (let E = 0; E < t; E++) {\n let x, A;\n if (a.spiralType === \"golden\")\n x = E * le * w + a.startAngle, A = this.calculateGoldenRadius(E, t, v, a.tightness);\n else if (a.spiralType === \"archimedean\") {\n const W = E * 0.5 * a.tightness;\n x = W * w + a.startAngle, A = this.calculateArchimedeanRadius(W, t, v, a.tightness);\n } else {\n const W = E * 0.3 * a.tightness;\n x = W * w + a.startAngle, A = this.calculateLogarithmicRadius(W, t, v, a.tightness);\n }\n const M = f + Math.cos(x) * A, z = S + Math.sin(x) * A, P = A / v, _ = g > 0 ? 1 - P * g * 0.5 : 1, Y = p ? this.random(m, b) : 1, N = _ * Y, T = c * N, k = T * 1.5 / 2, H = T / 2, R = h + k, C = s - h - k, O = h + H, $ = r - h - H, F = Math.max(R, Math.min(M, C)), U = Math.max(O, Math.min(z, $));\n let L = 0;\n if (u === \"random\") {\n const W = x * 180 / Math.PI % 360, X = this.random(l, d);\n L = a.spiralType === \"golden\" ? X : W * 0.1 + X * 0.9;\n } else u === \"tangent\" && (L = this.calculateSpiralTangent(x, A, a));\n const G = t - E;\n n.push({\n id: E,\n x: F,\n y: U,\n rotation: L,\n scale: N,\n baseSize: T,\n zIndex: G\n });\n }\n return n;\n }\n /**\n * Calculate tangent angle for spiral curve at given position\n * This aligns the image along the spiral's direction of travel\n */\n calculateSpiralTangent(t, e, i) {\n let n;\n if (i.spiralType === \"golden\")\n n = t + Math.PI / 2;\n else if (i.spiralType === \"archimedean\") {\n const r = 1 / i.tightness, a = Math.atan(e / r);\n n = t + a;\n } else {\n const r = 0.15 / i.tightness, a = Math.atan(1 / r);\n n = t + a;\n }\n return n * 180 / Math.PI % 360 - 90;\n }\n /**\n * Calculate radius for golden spiral (Vogel's model)\n * Creates even distribution like sunflower seeds\n */\n calculateGoldenRadius(t, e, i, n) {\n const r = i / Math.sqrt(e) * Math.sqrt(t) / n;\n return Math.min(r, i);\n }\n /**\n * Calculate radius for Archimedean spiral\n * r = a + b*θ (constant spacing between arms)\n */\n calculateArchimedeanRadius(t, e, i, n) {\n const s = e * 0.5 * n;\n return t / s * i;\n }\n /**\n * Calculate radius for logarithmic (equiangular) spiral\n * r = a * e^(b*θ)\n */\n calculateLogarithmicRadius(t, e, i, n) {\n const s = i * 0.05, r = 0.15 / n, a = s * Math.exp(r * t), h = e * 0.3 * n, c = s * Math.exp(r * h);\n return a / c * i;\n }\n /**\n * Utility: Generate random number between min and max\n */\n random(t, e) {\n return Math.random() * (e - t) + t;\n }\n}\nconst ue = {\n clusterCount: \"auto\",\n clusterSpread: 150,\n clusterSpacing: 200,\n density: \"uniform\",\n overlap: 0.3,\n distribution: \"gaussian\"\n};\nclass ge {\n constructor(t, e = {}) {\n this.config = t, this.imageConfig = e;\n }\n /**\n * Generate cluster layout positions for images\n * @param imageCount - Number of images to layout\n * @param containerBounds - Container dimensions {width, height}\n * @param options - Optional overrides (includes fixedHeight)\n * @returns Array of layout objects with position, rotation, scale\n */\n generate(t, e, i = {}) {\n const n = [], { width: s, height: r } = e, a = { ...ue, ...this.config.cluster }, h = this.config.spacing.padding, c = i.fixedHeight ?? 200, u = this.imageConfig.rotation?.mode ?? \"none\", l = this.imageConfig.rotation?.range?.min ?? -15, d = this.imageConfig.rotation?.range?.max ?? 15, m = this.imageConfig.sizing?.variance?.min ?? 1, b = this.imageConfig.sizing?.variance?.max ?? 1, p = m !== 1 || b !== 1, g = this.calculateClusterCount(\n t,\n a.clusterCount,\n s,\n r,\n a.clusterSpacing\n ), f = this.generateClusterCenters(\n g,\n s,\n r,\n h,\n a\n ), S = new Array(g).fill(0);\n for (let w = 0; w < t; w++)\n S[w % g]++;\n let v = 0;\n for (let w = 0; w < g; w++) {\n const E = f[w], x = S[w];\n for (let A = 0; A < x; A++) {\n let M, z;\n if (a.distribution === \"gaussian\")\n M = this.gaussianRandom() * E.spread, z = this.gaussianRandom() * E.spread;\n else {\n const L = this.random(0, Math.PI * 2), G = this.random(0, E.spread);\n M = Math.cos(L) * G, z = Math.sin(L) * G;\n }\n const P = 1 + a.overlap * 0.5, _ = 1 + a.overlap * 0.3;\n M /= P, z /= P;\n const Y = p ? this.random(m, b) : 1, N = _ * Y, T = c * N;\n let D = E.x + M, k = E.y + z;\n const R = T * 1.5 / 2, C = T / 2;\n D = Math.max(h + R, Math.min(D, s - h - R)), k = Math.max(h + C, Math.min(k, r - h - C));\n const O = u === \"random\" ? this.random(l, d) : 0, F = Math.sqrt(M * M + z * z) / E.spread, U = Math.round((1 - F) * 50) + 1;\n n.push({\n id: v,\n x: D,\n y: k,\n rotation: O,\n scale: N,\n baseSize: T,\n zIndex: U\n }), v++;\n }\n }\n return n;\n }\n /**\n * Calculate optimal number of clusters based on image count and container\n */\n calculateClusterCount(t, e, i, n, s) {\n if (e !== \"auto\")\n return Math.max(1, Math.min(e, t));\n const a = Math.max(1, Math.ceil(t / 8)), h = Math.floor(\n i / s * (n / s) * 0.6\n );\n return Math.max(1, Math.min(a, h, 10));\n }\n /**\n * Generate cluster center positions with spacing constraints\n */\n generateClusterCenters(t, e, i, n, s) {\n const r = [], h = n + s.clusterSpread, c = e - n - s.clusterSpread, u = n + s.clusterSpread, l = i - n - s.clusterSpread;\n for (let d = 0; d < t; d++) {\n let m = null, b = -1;\n for (let p = 0; p < 100; p++) {\n const g = {\n x: this.random(h, c),\n y: this.random(u, l),\n spread: this.calculateClusterSpread(s)\n };\n let f = 1 / 0;\n for (const S of r) {\n const v = g.x - S.x, w = g.y - S.y, E = Math.sqrt(v * v + w * w);\n f = Math.min(f, E);\n }\n if ((r.length === 0 || f > b) && (m = g, b = f), f >= s.clusterSpacing)\n break;\n }\n m && r.push(m);\n }\n return r;\n }\n /**\n * Calculate spread for a cluster (may vary if density='varied')\n */\n calculateClusterSpread(t) {\n return t.density === \"uniform\" ? t.clusterSpread : t.clusterSpread * this.random(0.5, 1.5);\n }\n /**\n * Generate a random number with approximately Gaussian distribution\n * Using Box-Muller transform\n */\n gaussianRandom() {\n let t = 0, e = 0;\n for (; t === 0; ) t = Math.random();\n for (; e === 0; ) e = Math.random();\n const i = Math.sqrt(-2 * Math.log(t)) * Math.cos(2 * Math.PI * e);\n return Math.max(-3, Math.min(3, i)) / 3;\n }\n /**\n * Utility: Generate random number between min and max\n */\n random(t, e) {\n return Math.random() * (e - t) + t;\n }\n}\nclass me {\n constructor(t, e = {}) {\n this.config = t, this.imageConfig = e;\n }\n /**\n * Generate wave layout positions for images\n * @param imageCount - Number of images to layout\n * @param containerBounds - Container dimensions {width, height}\n * @param options - Optional overrides\n * @returns Array of layout objects with position, rotation, scale\n */\n generate(t, e, i = {}) {\n const n = [], { width: s, height: r } = e, a = i.fixedHeight ?? 200, h = this.config.spacing.padding ?? 50, c = this.imageConfig.rotation?.mode ?? \"none\", u = this.imageConfig.rotation?.range?.min ?? -15, l = this.imageConfig.rotation?.range?.max ?? 15, d = this.imageConfig.sizing?.variance?.min ?? 1, m = this.imageConfig.sizing?.variance?.max ?? 1, b = d !== 1 || m !== 1, p = i.fixedHeight ?? a, g = {\n ...$t,\n ...this.config.wave\n }, { rows: f, amplitude: S, frequency: v, phaseShift: w, synchronization: E } = g, x = Math.ceil(t / f), z = p * 1.5 / 2, P = h + z, _ = s - h - z, Y = _ - P, N = x > 1 ? Y / (x - 1) : 0, T = h + S + p / 2, D = r - h - S - p / 2, k = D - T, H = f > 1 ? k / (f - 1) : 0;\n let R = 0;\n for (let C = 0; C < f && R < t; C++) {\n const O = f === 1 ? (T + D) / 2 : T + C * H;\n let $ = 0;\n E === \"offset\" ? $ = C * w : E === \"alternating\" && ($ = C * Math.PI);\n for (let F = 0; F < x && R < t; F++) {\n const U = x === 1 ? (P + _) / 2 : P + F * N, L = this.calculateWaveY(U, s, S, v, $), G = U, W = O + L, X = b ? this.random(d, m) : 1, B = p * X;\n let J = 0;\n c === \"tangent\" ? J = this.calculateRotation(U, s, S, v, $) : c === \"random\" && (J = this.random(u, l));\n const K = B * 1.5 / 2, ht = B / 2, ot = h + K, st = s - h - K, dt = h + ht, ut = r - h - ht;\n n.push({\n id: R,\n x: Math.max(ot, Math.min(G, st)),\n y: Math.max(dt, Math.min(W, ut)),\n rotation: J,\n scale: X,\n baseSize: B,\n zIndex: R + 1\n }), R++;\n }\n }\n return n;\n }\n /**\n * Calculate Y position displacement on wave curve\n * @param x - Horizontal position\n * @param containerWidth - Container width\n * @param amplitude - Wave amplitude\n * @param frequency - Wave frequency\n * @param phase - Phase offset\n * @returns Y displacement from baseline\n */\n calculateWaveY(t, e, i, n, s) {\n const r = t / e;\n return i * Math.sin(n * r * 2 * Math.PI + s);\n }\n /**\n * Calculate rotation based on wave tangent\n * @param x - Horizontal position\n * @param containerWidth - Container width\n * @param amplitude - Wave amplitude\n * @param frequency - Wave frequency\n * @param phase - Phase offset\n * @returns Rotation angle in degrees\n */\n calculateRotation(t, e, i, n, s) {\n const r = t / e, a = i * n * 2 * Math.PI * Math.cos(n * r * 2 * Math.PI + s) / e;\n return Math.atan(a) * (180 / Math.PI);\n }\n /**\n * Estimate image width based on height\n /**\n * Utility: Generate random number between min and max\n * @param min - Minimum value\n * @param max - Maximum value\n * @returns Random number in range\n */\n random(t, e) {\n return Math.random() * (e - t) + t;\n }\n}\nclass fe {\n constructor(t) {\n this.config = t.layout, this.imageConfig = t.image, this.layouts = /* @__PURE__ */ new Map(), this.placementLayout = this.initLayout();\n }\n /**\n * Initialize the appropriate placement layout based on config type\n * @returns Initialized placement layout\n */\n initLayout() {\n switch (this.config.algorithm) {\n case \"radial\":\n return new ae(this.config, this.imageConfig);\n case \"grid\":\n return new ce(this.config, this.imageConfig);\n case \"spiral\":\n return new de(this.config, this.imageConfig);\n case \"cluster\":\n return new ge(this.config, this.imageConfig);\n case \"wave\":\n return new me(this.config, this.imageConfig);\n default:\n return new se(this.config, this.imageConfig);\n }\n }\n /**\n * Generate layout positions for images\n * @param imageCount - Number of images to layout\n * @param containerBounds - Container dimensions {width, height}\n * @param options - Optional overrides for configuration (e.g. fixedHeight)\n * @returns Array of layout objects with position, rotation, scale\n */\n generateLayout(t, e, i = {}) {\n const n = this.placementLayout.generate(t, e, i);\n return n.forEach((s) => {\n this.layouts.set(s.id, s);\n }), n;\n }\n /**\n * Get the original layout state for an image\n * @param imageId - The image ID (number or string)\n * @returns Original layout state or undefined if not found\n */\n getOriginalState(t) {\n return this.layouts.get(Number(t));\n }\n /**\n * Reset all stored layouts\n */\n reset() {\n this.layouts.clear();\n }\n /**\n * Update config dynamically (useful for responsive changes)\n * @param newConfig - Updated configuration\n */\n updateConfig(t) {\n t.layout && (Object.assign(this.config, t.layout), t.layout.algorithm && t.layout.algorithm !== this.config.algorithm && (this.placementLayout = this.initLayout())), t.image && Object.assign(this.imageConfig, t.image);\n }\n /**\n * Get responsive breakpoints from layout config\n */\n getBreakpoints() {\n return this.config.responsive ?? {\n mobile: { maxWidth: 767 },\n tablet: { maxWidth: 1199 }\n };\n }\n /**\n * Resolve breakpoint name based on viewport width\n */\n resolveBreakpoint(t) {\n const e = this.getBreakpoints();\n return t <= e.mobile.maxWidth ? \"mobile\" : t <= e.tablet.maxWidth ? \"tablet\" : \"screen\";\n }\n /**\n * Resolve the effective base height based on image config and current viewport\n * @param viewportWidth - Current viewport width\n * @returns Resolved base height or undefined if should auto-calculate (adaptive mode)\n */\n resolveBaseHeight(t) {\n const e = this.imageConfig.sizing;\n if (!e || e.mode === \"adaptive\")\n return;\n const i = e.height;\n if (i === void 0)\n return;\n if (typeof i == \"number\")\n return i;\n const n = i, s = this.resolveBreakpoint(t);\n return s === \"mobile\" ? n.mobile ?? n.tablet ?? n.screen : s === \"tablet\" ? n.tablet ?? n.screen ?? n.mobile : n.screen ?? n.tablet ?? n.mobile;\n }\n /**\n * Calculate adaptive image size based on container dimensions and image count\n * @param containerBounds - Container dimensions {width, height}\n * @param imageCount - Number of images to display\n * @param maxHeight - Maximum height constraint (upper bound)\n * @param viewportWidth - Current viewport width for baseHeight resolution\n * @returns Calculated sizing result with height\n */\n calculateAdaptiveSize(t, e, i, n) {\n const s = this.imageConfig.sizing, r = this.resolveBaseHeight(n);\n if (r !== void 0)\n return { height: r };\n const a = s?.minSize ?? 50, h = s?.maxSize ?? 400, c = this.config.targetCoverage ?? 0.6, u = this.config.densityFactor ?? 1, { width: l, height: d } = t, p = l * d * c / e;\n let f = Math.sqrt(p / 1.4);\n f *= u, f = Math.min(f, i);\n let S = this.clamp(f, a, h);\n if (S === a && f < a) {\n const v = Math.max(a * 0.05, 20);\n S = Math.max(v, f);\n }\n return { height: S };\n }\n /**\n * Utility: Clamp a value between min and max\n */\n clamp(t, e, i) {\n return Math.max(e, Math.min(i, t));\n }\n}\nconst Z = class Z {\n /**\n * Register a loader implementation with the registry\n * @param name - Loader identifier (e.g., 'static', 'google-drive', 'composite')\n * @param Loader - Loader class constructor to register\n */\n static registerLoader(t, e) {\n Z.registry.set(t, e);\n }\n /**\n * Get a registered loader implementation\n * @param name - Loader identifier\n * @returns Loader class constructor\n * @throws Error if loader is not registered\n */\n static getLoader(t) {\n const e = Z.registry.get(t);\n if (!e)\n throw new Error(\n `Loader \"${t}\" is not registered. Import \"@frybynite/image-cloud/loaders/${t}\" or \"@frybynite/image-cloud/loaders/all\".`\n );\n return e;\n }\n /**\n * Check if a loader is registered\n * @param name - Loader identifier\n * @returns True if the loader is registered, false otherwise\n */\n static isRegistered(t) {\n return Z.registry.has(t);\n }\n};\nZ.registry = /* @__PURE__ */ new Map();\nlet et = Z;\nvar I = /* @__PURE__ */ ((o) => (o.IDLE = \"idle\", o.FOCUSING = \"focusing\", o.FOCUSED = \"focused\", o.UNFOCUSING = \"unfocusing\", o.CROSS_ANIMATING = \"cross_animating\", o))(I || {});\nfunction pe(o) {\n return o in pt;\n}\nfunction be(o) {\n return o ? pe(o) ? pt[o] : o : pt.md;\n}\nfunction ye(o) {\n if (!o) return \"\";\n const t = [];\n 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)\n if (typeof o.dropShadow == \"string\")\n t.push(`drop-shadow(${o.dropShadow})`);\n else {\n const e = o.dropShadow;\n t.push(`drop-shadow(${e.x}px ${e.y}px ${e.blur}px ${e.color})`);\n }\n return t.join(\" \");\n}\nfunction tt(o) {\n if (!o || o.style === \"none\" || o.width === 0)\n return \"none\";\n const t = o.width ?? 0, e = o.style ?? \"solid\", i = o.color ?? \"#000000\";\n return `${t}px ${e} ${i}`;\n}\nfunction rt(o) {\n if (!o) return {};\n const t = {};\n if (o.borderRadiusTopLeft !== void 0 || o.borderRadiusTopRight !== void 0 || o.borderRadiusBottomRight !== void 0 || o.borderRadiusBottomLeft !== void 0) {\n const s = o.border?.radius ?? 0;\n o.borderRadiusTopLeft !== void 0 ? t.borderTopLeftRadius = `${o.borderRadiusTopLeft}px` : s && (t.borderTopLeftRadius = `${s}px`), o.borderRadiusTopRight !== void 0 ? t.borderTopRightRadius = `${o.borderRadiusTopRight}px` : s && (t.borderTopRightRadius = `${s}px`), o.borderRadiusBottomRight !== void 0 ? t.borderBottomRightRadius = `${o.borderRadiusBottomRight}px` : s && (t.borderBottomRightRadius = `${s}px`), o.borderRadiusBottomLeft !== void 0 ? t.borderBottomLeftRadius = `${o.borderRadiusBottomLeft}px` : s && (t.borderBottomLeftRadius = `${s}px`);\n } else o.border?.radius !== void 0 && (t.borderRadius = `${o.border.radius}px`);\n if (o.borderTop || o.borderRight || o.borderBottom || o.borderLeft) {\n const s = o.border || {}, r = { ...s, ...o.borderTop }, a = { ...s, ...o.borderRight }, h = { ...s, ...o.borderBottom }, c = { ...s, ...o.borderLeft };\n t.borderTop = tt(r), t.borderRight = tt(a), t.borderBottom = tt(h), t.borderLeft = tt(c);\n } else o.border && (t.border = tt(o.border));\n o.shadow !== void 0 && (t.boxShadow = be(o.shadow));\n const n = ye(o.filter);\n 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) {\n const s = o.outline.width ?? 0, r = o.outline.style ?? \"solid\", a = o.outline.color ?? \"#000000\";\n t.outline = `${s}px ${r} ${a}`, o.outline.offset !== void 0 && (t.outlineOffset = `${o.outline.offset}px`);\n }\n return o.objectFit !== void 0 && (t.objectFit = o.objectFit), o.aspectRatio !== void 0 && (t.aspectRatio = o.aspectRatio), t;\n}\nfunction it(o, t) {\n 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);\n}\nfunction zt(o) {\n return o ? Array.isArray(o) ? o.join(\" \") : o : \"\";\n}\nfunction nt(o, t) {\n const e = zt(t);\n e && e.split(\" \").forEach((i) => {\n i.trim() && o.classList.add(i.trim());\n });\n}\nfunction Ft(o, t) {\n const e = zt(t);\n e && e.split(\" \").forEach((i) => {\n i.trim() && o.classList.remove(i.trim());\n });\n}\nconst Tt = {\n UNFOCUSING: 999,\n FOCUSING: 1e3\n};\nclass ve {\n constructor(t, e, i) {\n 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 = rt(i?.default), this.focusedStyles = rt(i?.focused), this.defaultClassName = i?.default?.className, this.focusedClassName = i?.focused?.className;\n }\n /**\n * Get current state machine state\n */\n getState() {\n return this.state;\n }\n /**\n * Check if any animation is in progress\n */\n isAnimating() {\n return this.state !== I.IDLE && this.state !== I.FOCUSED;\n }\n /**\n * Normalize scalePercent value\n */\n normalizeScalePercent(t) {\n return t > 1 ? t / 100 : t;\n }\n /**\n * Calculate target dimensions for focused image\n * Returns actual pixel dimensions instead of scale factor for sharper rendering\n */\n calculateFocusDimensions(t, e, i) {\n const n = this.normalizeScalePercent(this.config.scalePercent), s = i.height * n, r = t / e;\n let a = s, h = a * r;\n const c = i.width * n;\n return h > c && (h = c, a = h / r), { width: h, height: a };\n }\n /**\n * Calculate the transform needed to center an image (position only, no scale)\n * Scale is handled by animating actual dimensions for sharper rendering\n */\n calculateFocusTransform(t, e) {\n const i = t.width / 2, n = t.height / 2, s = i - e.x, r = n - e.y;\n return {\n x: s,\n y: r,\n rotation: 0,\n scale: 1\n // No scale transform - dimensions are animated instead\n };\n }\n /**\n * Build transform string for dimension-based zoom (no scale in transform)\n */\n buildDimensionZoomTransform(t) {\n const e = [\"translate(-50%, -50%)\"];\n if (t.x !== void 0 || t.y !== void 0) {\n const i = t.x ?? 0, n = t.y ?? 0;\n e.push(`translate(${i}px, ${n}px)`);\n }\n return t.rotation !== void 0 && e.push(`rotate(${t.rotation}deg)`), e.join(\" \");\n }\n /**\n * Create a Web Animation that animates both transform (position) and dimensions\n * This provides sharper zoom by re-rendering at target size instead of scaling pixels\n */\n animateWithDimensions(t, e, i, n, s, r, a, h) {\n const c = this.buildDimensionZoomTransform(e), u = this.buildDimensionZoomTransform(i);\n return t.style.transition = \"none\", t.animate(\n [\n {\n transform: c,\n width: `${n}px`,\n height: `${s}px`\n },\n {\n transform: u,\n width: `${r}px`,\n height: `${a}px`\n }\n ],\n {\n duration: h,\n easing: \"cubic-bezier(0.4, 0, 0.2, 1)\",\n fill: \"forwards\"\n }\n );\n }\n /**\n * Apply focused styling to an element\n */\n applyFocusedStyling(t, e) {\n t.style.zIndex = String(e), t.classList.add(\"fbn-ic-focused\"), it(t, this.focusedStyles), nt(t, this.focusedClassName);\n }\n /**\n * Remove focused styling from an element\n */\n removeFocusedStyling(t, e) {\n t.style.zIndex = e, t.classList.remove(\"fbn-ic-focused\"), Ft(t, this.focusedClassName), it(t, this.defaultStyles), nt(t, this.defaultClassName);\n }\n /**\n * Start focus animation for an image using dimension-based zoom\n * Animates actual width/height for sharper rendering instead of transform scale\n * @param fromTransform - Optional starting transform (for mid-animation reversals)\n * @param fromDimensions - Optional starting dimensions (for mid-animation reversals)\n */\n startFocusAnimation(t, e, i, n, s) {\n const r = t.style.zIndex || \"\", a = t.offsetWidth, h = t.offsetHeight, c = this.calculateFocusDimensions(a, h, e), u = this.calculateFocusTransform(e, i);\n this.applyFocusedStyling(t, Tt.FOCUSING), this.animationEngine.cancelAllAnimations(t);\n const l = n ?? {\n x: 0,\n y: 0,\n rotation: i.rotation,\n scale: 1\n // No scale - using dimensions\n }, d = s?.width ?? a, m = s?.height ?? h, b = this.config.animationDuration ?? 600, p = this.animateWithDimensions(\n t,\n l,\n u,\n d,\n m,\n c.width,\n c.height,\n b\n ), g = {\n id: `focus-${Date.now()}`,\n element: t,\n animation: p,\n fromState: l,\n toState: u,\n startTime: performance.now(),\n duration: b\n };\n return this.focusData = {\n element: t,\n originalState: i,\n focusTransform: u,\n originalZIndex: r,\n originalWidth: a,\n originalHeight: h,\n focusWidth: c.width,\n focusHeight: c.height\n }, {\n element: t,\n originalState: i,\n animationHandle: g,\n direction: \"in\",\n originalWidth: a,\n originalHeight: h\n };\n }\n /**\n * Start unfocus animation for an image using dimension-based zoom\n * Animates back to original dimensions for consistent behavior\n * @param fromDimensions - Optional starting dimensions (for mid-animation reversals)\n */\n startUnfocusAnimation(t, e, i, n) {\n t.style.zIndex = String(Tt.UNFOCUSING), this.animationEngine.cancelAllAnimations(t);\n const s = i ?? this.focusData?.focusTransform ?? { x: 0, y: 0, rotation: 0, scale: 1 }, r = n?.width ?? this.focusData?.focusWidth ?? t.offsetWidth, a = n?.height ?? this.focusData?.focusHeight ?? t.offsetHeight, h = {\n x: 0,\n y: 0,\n rotation: e.rotation,\n scale: 1\n // No scale - using dimensions\n }, c = this.focusData?.originalWidth ?? t.offsetWidth, u = this.focusData?.originalHeight ?? t.offsetHeight, l = this.config.animationDuration ?? 600, d = this.animateWithDimensions(\n t,\n s,\n h,\n r,\n a,\n c,\n u,\n l\n ), m = {\n id: `unfocus-${Date.now()}`,\n element: t,\n animation: d,\n fromState: s,\n toState: h,\n startTime: performance.now(),\n duration: l\n };\n return {\n element: t,\n originalState: e,\n animationHandle: m,\n direction: \"out\",\n originalWidth: c,\n originalHeight: u\n };\n }\n /**\n * Capture the current visual state of an element mid-animation, BEFORE cancelling.\n *\n * The computed matrix.e/f include the -50%/-50% centering offset resolved to pixels.\n * buildDimensionZoomTransform prepends its own translate(-50%,-50%), so passing raw\n * matrix.e/f doubles the centering and produces the wrong starting position.\n *\n * This method extracts the PURE positional offset (pureX = matrix.e + 0.5*midWidth)\n * and commits width/height/transform to inline styles before the animation is cancelled,\n * preventing any visual snap.\n *\n * Must be called while the animation is still running (offsetWidth reflects animated size).\n * Caller is responsible for calling animationEngine.cancelAllAnimations() afterwards.\n */\n captureMidAnimationState(t) {\n const e = getComputedStyle(t), i = new DOMMatrix(e.transform), n = t.offsetWidth, s = t.offsetHeight, r = i.e + n * 0.5, a = i.f + s * 0.5, h = Math.atan2(i.b, i.a) * (180 / Math.PI);\n return t.style.width = `${n}px`, t.style.height = `${s}px`, t.style.transform = `translate(-50%, -50%) translate(${r}px, ${a}px) rotate(${h}deg)`, t.style.transition = \"none\", {\n transform: { x: r, y: a, rotation: h, scale: 1 },\n dimensions: { width: n, height: s }\n };\n }\n /**\n * Handle animation completion\n */\n async waitForAnimation(t) {\n try {\n await t.animation.finished;\n } catch {\n }\n }\n /**\n * Reset an element instantly to its original position and dimensions (no animation)\n */\n resetElementInstantly(t, e, i, n, s) {\n this.animationEngine.cancelAllAnimations(t);\n const r = [\"translate(-50%, -50%)\"];\n 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);\n }\n /**\n * Focus (zoom) an image to center of container\n * Implements cross-animation when swapping focus\n */\n async focusImage(t, e, i) {\n if (this.currentFocus === t && this.state === I.FOCUSED)\n return this.unfocusImage();\n if (this.incoming?.element === t && this.state === I.FOCUSING) {\n const { transform: s, dimensions: r } = this.captureMidAnimationState(t);\n this.animationEngine.cancelAllAnimations(t), this.outgoing = this.startUnfocusAnimation(\n t,\n this.incoming.originalState,\n s,\n r\n ), this.incoming = null, this.state = I.UNFOCUSING, await this.waitForAnimation(this.outgoing.animationHandle), this.removeFocusedStyling(this.outgoing.element, this.focusData?.originalZIndex || \"\"), this.outgoing = null, this.currentFocus = null, this.focusData = null, this.state = I.IDLE;\n return;\n }\n const n = ++this.focusGeneration;\n switch (this.state) {\n case I.IDLE:\n if (this.state = I.FOCUSING, this.incoming = this.startFocusAnimation(t, e, i), await this.waitForAnimation(this.incoming.animationHandle), this.focusGeneration !== n) return;\n this.currentFocus = t, this.incoming = null, this.state = I.FOCUSED;\n break;\n case I.FOCUSED:\n if (this.state = I.CROSS_ANIMATING, this.currentFocus && this.focusData && (this.outgoing = this.startUnfocusAnimation(\n this.currentFocus,\n this.focusData.originalState\n )), this.incoming = this.startFocusAnimation(t, e, i), await Promise.all([\n this.outgoing ? this.waitForAnimation(this.outgoing.animationHandle) : Promise.resolve(),\n this.waitForAnimation(this.incoming.animationHandle)\n ]), this.focusGeneration !== n)\n return;\n this.outgoing && (this.removeFocusedStyling(this.outgoing.element, this.outgoing.originalState.zIndex?.toString() || \"\"), this.outgoing = null), this.currentFocus = t, this.incoming = null, this.state = I.FOCUSED;\n break;\n case I.FOCUSING:\n if (this.incoming && (this.animationEngine.cancelAnimation(this.incoming.animationHandle, !1), this.resetElementInstantly(\n this.incoming.element,\n this.incoming.originalState,\n this.focusData?.originalZIndex || \"\",\n this.focusData?.originalWidth,\n this.focusData?.originalHeight\n ), this.incoming = null), this.incoming = this.startFocusAnimation(t, e, i), await this.waitForAnimation(this.incoming.animationHandle), this.focusGeneration !== n) return;\n this.currentFocus = t, this.incoming = null, this.state = I.FOCUSED;\n break;\n case I.UNFOCUSING:\n if (this.state = I.CROSS_ANIMATING, this.incoming = this.startFocusAnimation(t, e, i), await Promise.all([\n this.outgoing ? this.waitForAnimation(this.outgoing.animationHandle) : Promise.resolve(),\n this.waitForAnimation(this.incoming.animationHandle)\n ]), this.focusGeneration !== n) return;\n this.outgoing && (this.removeFocusedStyling(this.outgoing.element, this.outgoing.originalState.zIndex?.toString() || \"\"), this.outgoing = null), this.currentFocus = t, this.incoming = null, this.state = I.FOCUSED;\n break;\n case I.CROSS_ANIMATING:\n if (this.incoming?.element === t)\n return;\n if (this.outgoing?.element === t) {\n const { transform: s, dimensions: r } = this.captureMidAnimationState(t);\n if (this.animationEngine.cancelAllAnimations(t), this.incoming) {\n const { transform: a, dimensions: h } = this.captureMidAnimationState(this.incoming.element);\n this.animationEngine.cancelAllAnimations(this.incoming.element), this.outgoing = this.startUnfocusAnimation(\n this.incoming.element,\n this.incoming.originalState,\n a,\n h\n );\n } else\n this.outgoing = null;\n if (this.incoming = this.startFocusAnimation(t, e, i, s, r), await Promise.all([\n this.outgoing ? this.waitForAnimation(this.outgoing.animationHandle) : Promise.resolve(),\n this.waitForAnimation(this.incoming.animationHandle)\n ]), this.focusGeneration !== n) return;\n this.outgoing && (this.removeFocusedStyling(this.outgoing.element, this.outgoing.originalState.zIndex?.toString() || \"\"), this.outgoing = null), this.currentFocus = t, this.incoming = null, this.state = I.FOCUSED;\n return;\n }\n if (this.outgoing && (this.animationEngine.cancelAnimation(this.outgoing.animationHandle, !1), this.resetElementInstantly(\n this.outgoing.element,\n this.outgoing.originalState,\n this.outgoing.originalState.zIndex?.toString() || \"\",\n this.outgoing.originalWidth,\n this.outgoing.originalHeight\n ), this.outgoing = null), this.incoming) {\n const { transform: s, dimensions: r } = this.captureMidAnimationState(this.incoming.element);\n this.animationEngine.cancelAllAnimations(this.incoming.element), this.outgoing = this.startUnfocusAnimation(\n this.incoming.element,\n this.incoming.originalState,\n s,\n r\n );\n }\n if (this.incoming = this.startFocusAnimation(t, e, i), await Promise.all([\n this.outgoing ? this.waitForAnimation(this.outgoing.animationHandle) : Promise.resolve(),\n this.waitForAnimation(this.incoming.animationHandle)\n ]), this.focusGeneration !== n) return;\n this.outgoing && (this.removeFocusedStyling(this.outgoing.element, this.outgoing.originalState.zIndex?.toString() || \"\"), this.outgoing = null), this.currentFocus = t, this.incoming = null, this.state = I.FOCUSED;\n break;\n }\n }\n /**\n * Unfocus current image, returning it to original position\n */\n async unfocusImage() {\n if (this.state === I.UNFOCUSING)\n return;\n const t = ++this.focusGeneration;\n if (!this.currentFocus || !this.focusData) {\n if (this.incoming && this.state === I.FOCUSING) {\n const { transform: s, dimensions: r } = this.captureMidAnimationState(this.incoming.element);\n if (this.animationEngine.cancelAllAnimations(this.incoming.element), this.outgoing = this.startUnfocusAnimation(\n this.incoming.element,\n this.incoming.originalState,\n s,\n r\n ), this.incoming = null, this.state = I.UNFOCUSING, await this.waitForAnimation(this.outgoing.animationHandle), this.focusGeneration !== t) return;\n this.removeFocusedStyling(this.outgoing.element, this.focusData?.originalZIndex || \"\"), this.outgoing = null, this.focusData = null, this.state = I.IDLE;\n }\n return;\n }\n if (this.state === I.CROSS_ANIMATING && this.incoming) {\n const { transform: s, dimensions: r } = this.captureMidAnimationState(this.incoming.element);\n this.animationEngine.cancelAllAnimations(this.incoming.element);\n const a = this.startUnfocusAnimation(\n this.incoming.element,\n this.incoming.originalState,\n s,\n r\n );\n if (await Promise.all([\n this.outgoing ? this.waitForAnimation(this.outgoing.animationHandle) : Promise.resolve(),\n this.waitForAnimation(a.animationHandle)\n ]), this.focusGeneration !== t) return;\n this.outgoing && this.removeFocusedStyling(this.outgoing.element, this.outgoing.originalState.zIndex?.toString() || \"\"), this.removeFocusedStyling(a.element, this.incoming.originalState.zIndex?.toString() || \"\"), this.outgoing = null, this.incoming = null, this.currentFocus = null, this.focusData = null, this.state = I.IDLE;\n return;\n }\n this.state = I.UNFOCUSING;\n const e = this.currentFocus, i = this.focusData.originalState, n = this.focusData.originalZIndex;\n this.outgoing = this.startUnfocusAnimation(e, i), await this.waitForAnimation(this.outgoing.animationHandle), this.focusGeneration === t && (this.removeFocusedStyling(e, n), this.outgoing = null, this.currentFocus = null, this.focusData = null, this.state = I.IDLE);\n }\n /**\n * Swap focus from current image to a new one (alias for focusImage with cross-animation)\n */\n async swapFocus(t, e, i) {\n return this.focusImage(t, e, i);\n }\n /**\n * Get currently focused image element\n */\n getCurrentFocus() {\n return this.currentFocus;\n }\n /**\n * Check if an image is currently focused (stable state)\n */\n isFocused(t) {\n return this.currentFocus === t && this.state === I.FOCUSED;\n }\n /**\n * Check if an image is the target of current focus animation\n */\n isTargetingFocus(t) {\n return this.incoming?.element === t;\n }\n /**\n * Check if an image is involved in any focus/animation state\n * Returns true if the image is focused, animating in, or animating out\n * Useful for hover state management - don't apply hover to animating images\n */\n isInvolved(t) {\n return this.currentFocus === t || this.incoming?.element === t || this.outgoing?.element === t;\n }\n /**\n * Apply a temporary horizontal drag offset to the focused image\n * Used during swipe gestures for visual feedback\n */\n setDragOffset(t) {\n if (!this.currentFocus || !this.focusData || this.state !== I.FOCUSED) return;\n const e = this.currentFocus, i = this.focusData.focusTransform, n = [\"translate(-50%, -50%)\"], s = (i.x ?? 0) + t, r = i.y ?? 0;\n 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(\" \");\n }\n /**\n * Clear the drag offset, optionally animating back to center\n * @param animate - If true, animate back to center; if false, snap instantly\n * @param duration - Animation duration in ms (default 150)\n */\n clearDragOffset(t, e = 150) {\n if (!this.currentFocus || !this.focusData || this.state !== I.FOCUSED) return;\n const i = this.currentFocus, n = this.focusData.focusTransform, s = [\"translate(-50%, -50%)\"], r = n.x ?? 0, a = n.y ?? 0;\n s.push(`translate(${r}px, ${a}px)`), n.rotation !== void 0 && s.push(`rotate(${n.rotation}deg)`);\n const h = s.join(\" \");\n t ? (i.style.transition = `transform ${e}ms ease-out`, i.style.transform = h, setTimeout(() => {\n this.currentFocus === i && (i.style.transition = \"none\");\n }, e)) : (i.style.transition = \"none\", i.style.transform = h);\n }\n /**\n * Reset zoom state (cancels all animations)\n */\n reset() {\n this.outgoing && (this.animationEngine.cancelAnimation(this.outgoing.animationHandle, !1), this.resetElementInstantly(\n this.outgoing.element,\n this.outgoing.originalState,\n this.outgoing.originalState.zIndex?.toString() || \"\",\n this.outgoing.originalWidth,\n this.outgoing.originalHeight\n )), this.incoming && (this.animationEngine.cancelAnimation(this.incoming.animationHandle, !1), this.resetElementInstantly(\n this.incoming.element,\n this.incoming.originalState,\n this.focusData?.originalZIndex || \"\",\n this.focusData?.originalWidth,\n this.focusData?.originalHeight\n )), this.currentFocus && this.focusData && this.resetElementInstantly(\n this.currentFocus,\n this.focusData.originalState,\n this.focusData.originalZIndex,\n this.focusData.originalWidth,\n this.focusData.originalHeight\n ), this.state = I.IDLE, this.currentFocus = null, this.focusData = null, this.outgoing = null, this.incoming = null;\n }\n}\nconst we = 50, xe = 0.5, Se = 20, Ee = 0.3, Ie = 150, Ae = 30, ct = class ct {\n constructor(t, e) {\n 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);\n }\n /**\n * Start listening for touch events\n */\n enable() {\n this.enabled || (this.enabled = !0, this.container.style.touchAction = \"pan-y\", this.container.addEventListener(\"touchstart\", this.boundTouchStart, { passive: !1 }), this.container.addEventListener(\"touchmove\", this.boundTouchMove, { passive: !1 }), this.container.addEventListener(\"touchend\", this.boundTouchEnd, { passive: !0 }), this.container.addEventListener(\"touchcancel\", this.boundTouchCancel, { passive: !0 }));\n }\n /**\n * Stop listening for touch events\n */\n disable() {\n this.enabled && (this.enabled = !1, this.container.style.touchAction = \"\", this.container.removeEventListener(\"touchstart\", this.boundTouchStart), this.container.removeEventListener(\"touchmove\", this.boundTouchMove), this.container.removeEventListener(\"touchend\", this.boundTouchEnd), this.container.removeEventListener(\"touchcancel\", this.boundTouchCancel), this.touchState?.isDragging && this.callbacks.onDragEnd(!1), this.touchState = null);\n }\n /**\n * Clean up all event listeners\n */\n destroy() {\n this.disable();\n }\n /**\n * Check if a touch interaction happened recently\n * Used to prevent click-outside from unfocusing immediately after touch\n */\n hadRecentTouch() {\n return Date.now() - this.recentTouchTimestamp < ct.TOUCH_CLICK_DELAY;\n }\n handleTouchStart(t) {\n if (t.touches.length !== 1) return;\n this.recentTouchTimestamp = Date.now();\n const e = t.touches[0];\n this.touchState = {\n startX: e.clientX,\n startY: e.clientY,\n startTime: performance.now(),\n currentX: e.clientX,\n isDragging: !1,\n isHorizontalSwipe: null\n };\n }\n handleTouchMove(t) {\n if (!this.touchState || t.touches.length !== 1) return;\n const e = t.touches[0], i = e.clientX - this.touchState.startX, n = e.clientY - this.touchState.startY;\n if (this.touchState.isHorizontalSwipe === null && Math.sqrt(i * i + n * n) > 10) {\n const a = Math.atan2(Math.abs(n), Math.abs(i)) * (180 / Math.PI);\n this.touchState.isHorizontalSwipe = a <= Ae;\n }\n if (this.touchState.isHorizontalSwipe !== !1 && this.touchState.isHorizontalSwipe === !0) {\n t.preventDefault(), this.touchState.isDragging = !0, this.touchState.currentX = e.clientX;\n const s = i * Ee;\n this.callbacks.onDragOffset(s);\n }\n }\n handleTouchEnd(t) {\n if (!this.touchState) return;\n this.recentTouchTimestamp = Date.now();\n const e = this.touchState.currentX - this.touchState.startX, i = performance.now() - this.touchState.startTime, n = Math.abs(e) / i, s = Math.abs(e);\n let r = !1;\n this.touchState.isHorizontalSwipe === !0 && this.touchState.isDragging && (s >= we || n >= xe && s >= Se) && (r = !0, e < 0 ? this.callbacks.onNext() : this.callbacks.onPrev()), this.touchState.isDragging && this.callbacks.onDragEnd(r), this.touchState = null;\n }\n handleTouchCancel(t) {\n this.touchState?.isDragging && this.callbacks.onDragEnd(!1), this.touchState = null;\n }\n};\nct.TOUCH_CLICK_DELAY = 300;\nlet bt = ct;\nclass Te {\n /**\n * Create a new ImageFilter\n * @param extensions - Array of allowed file extensions (without dots)\n * Defaults to common image formats if not provided\n */\n constructor(t) {\n this.allowedExtensions = t || [\n \"jpg\",\n \"jpeg\",\n \"png\",\n \"gif\",\n \"webp\",\n \"bmp\"\n ];\n }\n /**\n * Check if a filename has an allowed extension\n * @param filename - The filename to check (can include path or query string)\n * @returns True if the file extension is allowed\n */\n isAllowed(t) {\n const i = t.split(\"?\")[0].split(\".\").pop()?.toLowerCase();\n return i ? this.allowedExtensions.includes(i) : !1;\n }\n /**\n * Get the list of allowed extensions\n * @returns Array of allowed extensions\n */\n getAllowedExtensions() {\n return [...this.allowedExtensions];\n }\n // Future expansion methods:\n // isAllowedSize(sizeBytes: number): boolean\n // isAllowedDate(date: Date): boolean\n // isAllowedDimensions(width: number, height: number): boolean\n}\nconst Ce = `\n.fbn-ic-gallery {\n position: relative;\n width: 100%;\n height: 100%;\n overflow: hidden;\n perspective: 1000px;\n}\n\n.fbn-ic-image {\n position: absolute;\n cursor: pointer;\n transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1),\n box-shadow 0.6s cubic-bezier(0.4, 0, 0.2, 1),\n filter 0.3s cubic-bezier(0.4, 0, 0.2, 1),\n opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),\n border 0.3s cubic-bezier(0.4, 0, 0.2, 1),\n outline 0.3s cubic-bezier(0.4, 0, 0.2, 1),\n z-index 0s 0.6s;\n will-change: transform;\n user-select: none;\n backface-visibility: hidden;\n -webkit-backface-visibility: hidden;\n}\n\n.fbn-ic-image.fbn-ic-focused {\n z-index: 1000;\n transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1),\n box-shadow 0.6s cubic-bezier(0.4, 0, 0.2, 1),\n filter 0.3s cubic-bezier(0.4, 0, 0.2, 1),\n opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),\n border 0.3s cubic-bezier(0.4, 0, 0.2, 1),\n outline 0.3s cubic-bezier(0.4, 0, 0.2, 1),\n z-index 0s 0s;\n will-change: auto;\n}\n\n.fbn-ic-counter {\n position: fixed;\n bottom: 24px;\n left: 50%;\n transform: translateX(-50%);\n z-index: 10001;\n pointer-events: none;\n}\n\n.fbn-ic-hidden {\n display: none !important;\n}\n`;\nfunction Re() {\n if (typeof document > \"u\") return;\n const o = \"fbn-ic-functional-styles\";\n if (document.getElementById(o)) return;\n const t = document.createElement(\"style\");\n t.id = o, t.textContent = Ce, document.head.appendChild(t);\n}\nclass Le {\n constructor(t = {}) {\n this.fullConfig = Gt(t), t.container instanceof HTMLElement ? (this.containerRef = t.container, this.containerId = null) : (this.containerRef = null, this.containerId = t.container || \"imageCloud\"), this.imagesLoaded = !1, this.imageElements = [], this.imageLayouts = [], this.currentImageHeight = 225, this.currentFocusIndex = null, this.hoveredImage = null, this.resizeTimeout = null, this.displayQueue = [], this.queueInterval = null, this.loadGeneration = 0, this.loadingElAutoCreated = !1, this.errorElAutoCreated = !1, this.counterEl = null, this.counterElAutoCreated = !1, this.animationEngine = new Xt(this.fullConfig.animation), this.layoutEngine = new fe({\n layout: this.fullConfig.layout,\n image: this.fullConfig.image\n }), this.zoomEngine = new ve(this.fullConfig.interaction.focus, this.animationEngine, this.fullConfig.styling), this.defaultStyles = rt(this.fullConfig.styling?.default), this.hoverStyles = rt(this.fullConfig.styling?.hover), this.defaultClassName = this.fullConfig.styling?.default?.className, this.hoverClassName = this.fullConfig.styling?.hover?.className;\n const e = this.fullConfig.animation.entry || y.animation.entry;\n this.entryAnimationEngine = new oe(\n e,\n this.fullConfig.layout.algorithm\n ), this.swipeEngine = null, this.imageFilter = this.createImageFilter(), this.containerEl = null, this.loadingEl = null, this.errorEl = null;\n }\n /**\n * Create image filter based on shared loader config\n */\n createImageFilter() {\n const t = this.fullConfig.config.loaders?.allowedExtensions;\n return new Te(t);\n }\n /**\n * Create appropriate image loader based on config\n * Processes loaders array, merges shared config, wraps in CompositeLoader if needed\n * Uses dynamic imports to trigger loader registration and enable tree-shaking\n */\n async createLoader() {\n const t = this.fullConfig.loaders, e = this.fullConfig.config.loaders ?? {};\n if (!t || t.length === 0)\n throw new Error(\"No loaders configured. Provide `images`, `loaders`, or both.\");\n const i = await Promise.all(\n t.map((s) => this.createLoaderFromEntry(s, e))\n );\n if (i.length === 1)\n return i[0];\n await import(\"@frybynite/image-cloud/loaders/composite\");\n const n = et.getLoader(\"composite\");\n return new n({\n loaders: i,\n debugLogging: this.fullConfig.config.debug?.loaders\n });\n }\n /**\n * Create a single loader from a LoaderEntry, merging shared config\n * Uses dynamic imports to trigger loader registration and enable tree-shaking\n */\n async createLoaderFromEntry(t, e) {\n if (\"static\" in t) {\n await import(\"@frybynite/image-cloud/loaders/static\");\n const i = et.getLoader(\"static\"), n = t.static, s = {\n ...n,\n validateUrls: n.validateUrls ?? e.validateUrls,\n validationTimeout: n.validationTimeout ?? e.validationTimeout,\n validationMethod: n.validationMethod ?? e.validationMethod,\n allowedExtensions: n.allowedExtensions ?? e.allowedExtensions,\n debugLogging: n.debugLogging ?? this.fullConfig.config.debug?.loaders\n };\n return new i(s);\n } else if (\"googleDrive\" in t) {\n await import(\"@frybynite/image-cloud/loaders/google-drive\");\n const i = et.getLoader(\"google-drive\"), n = t.googleDrive, s = {\n ...n,\n allowedExtensions: n.allowedExtensions ?? e.allowedExtensions,\n debugLogging: n.debugLogging ?? this.fullConfig.config.debug?.loaders\n };\n return new i(s);\n } else\n throw new Error(`Unknown loader entry: ${JSON.stringify(t)}`);\n }\n /**\n * Initialize the gallery\n */\n async init() {\n try {\n if (Re(), this.containerRef)\n this.containerEl = this.containerRef;\n else if (this.containerEl = document.getElementById(this.containerId), !this.containerEl)\n throw new Error(`Container #${this.containerId} not found`);\n this.containerEl.classList.add(\"fbn-ic-gallery\"), this.swipeEngine = new bt(this.containerEl, {\n onNext: () => this.navigateToNextImage(),\n onPrev: () => this.navigateToPreviousImage(),\n onDragOffset: (t) => this.zoomEngine.setDragOffset(t),\n onDragEnd: (t) => {\n t ? this.zoomEngine.clearDragOffset(!1) : this.zoomEngine.clearDragOffset(!0, Ie);\n }\n }), this.setupUI(), this.setupEventListeners(), this.imageLoader = await this.createLoader(), this.logDebug(\"ImageCloud initialized\"), await this.loadImages();\n } catch (t) {\n console.error(\"Gallery initialization failed:\", t), this.errorEl && t instanceof Error && this.showError(\"Gallery failed to initialize: \" + t.message);\n }\n }\n setupUI() {\n const t = this.fullConfig.rendering.ui;\n t.showLoadingSpinner && (t.loadingElement ? (this.loadingEl = this.resolveElement(t.loadingElement), this.loadingElAutoCreated = !1) : (this.loadingEl = this.createDefaultLoadingElement(), this.loadingElAutoCreated = !0)), t.errorElement ? (this.errorEl = this.resolveElement(t.errorElement), this.errorElAutoCreated = !1) : (this.errorEl = this.createDefaultErrorElement(), this.errorElAutoCreated = !0), t.showImageCounter && (t.counterElement ? (this.counterEl = this.resolveElement(t.counterElement), this.counterElAutoCreated = !1) : (this.counterEl = this.createDefaultCounterElement(), this.counterElAutoCreated = !0));\n }\n resolveElement(t) {\n return t instanceof HTMLElement ? t : document.getElementById(t);\n }\n createDefaultLoadingElement() {\n const t = document.createElement(\"div\");\n t.className = \"fbn-ic-loading fbn-ic-hidden\";\n const e = document.createElement(\"div\");\n e.className = \"fbn-ic-spinner\", t.appendChild(e);\n const i = document.createElement(\"p\");\n return i.textContent = \"Loading images...\", t.appendChild(i), this.containerEl.appendChild(t), t;\n }\n createDefaultErrorElement() {\n const t = document.createElement(\"div\");\n return t.className = \"fbn-ic-error fbn-ic-hidden\", this.containerEl.appendChild(t), t;\n }\n createDefaultCounterElement() {\n const t = document.createElement(\"div\");\n return t.className = \"fbn-ic-counter fbn-ic-hidden\", this.containerEl.appendChild(t), t;\n }\n setupEventListeners() {\n document.addEventListener(\"keydown\", (t) => {\n t.key === \"Escape\" ? (this.zoomEngine.unfocusImage(), this.currentFocusIndex = null, this.swipeEngine?.disable(), this.hideCounter()) : t.key === \"ArrowRight\" ? this.navigateToNextImage() : t.key === \"ArrowLeft\" ? this.navigateToPreviousImage() : (t.key === \"Enter\" || t.key === \" \") && this.hoveredImage && (this.handleImageClick(this.hoveredImage.element, this.hoveredImage.layout), t.preventDefault());\n }), document.addEventListener(\"click\", (t) => {\n this.swipeEngine?.hadRecentTouch() || t.target.closest(\".fbn-ic-image\") || (this.zoomEngine.unfocusImage(), this.currentFocusIndex = null, this.swipeEngine?.disable(), this.hideCounter());\n }), window.addEventListener(\"resize\", () => this.handleResize());\n }\n /**\n * Navigate to the next image (Right arrow)\n */\n navigateToNextImage() {\n if (this.currentFocusIndex === null || this.imageElements.length === 0) return;\n const t = (this.currentFocusIndex + 1) % this.imageLayouts.length, e = this.imageElements.find(\n (n) => n.dataset.imageId === String(t)\n );\n if (!e) return;\n const i = this.imageLayouts[t];\n i && (this.currentFocusIndex = t, this.handleImageClick(e, i), this.updateCounter(t));\n }\n /**\n * Navigate to the previous image (Left arrow)\n */\n navigateToPreviousImage() {\n if (this.currentFocusIndex === null || this.imageElements.length === 0) return;\n const t = (this.currentFocusIndex - 1 + this.imageLayouts.length) % this.imageLayouts.length, e = this.imageElements.find(\n (n) => n.dataset.imageId === String(t)\n );\n if (!e) return;\n const i = this.imageLayouts[t];\n i && (this.currentFocusIndex = t, this.handleImageClick(e, i), this.updateCounter(t));\n }\n /**\n * Navigate to a specific image by index\n */\n handleResize() {\n this.imagesLoaded && (this.resizeTimeout !== null && clearTimeout(this.resizeTimeout), this.resizeTimeout = window.setTimeout(() => {\n const t = this.getImageHeight();\n t !== this.currentImageHeight ? (this.logDebug(`Window resized to new breakpoint (height: ${t}px). Reloading images...`), this.loadImages()) : this.logDebug(\"Window resized (no breakpoint change)\");\n }, 500));\n }\n getImageHeight() {\n const t = window.innerWidth, e = this.fullConfig.layout.responsive, n = this.fullConfig.image.sizing?.maxSize ?? 400;\n 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);\n }\n /**\n * Get container bounds for layout calculations\n */\n getContainerBounds() {\n return this.containerEl ? {\n width: this.containerEl.offsetWidth,\n height: this.containerEl.offsetHeight || window.innerHeight * 0.7\n } : { width: window.innerWidth, height: window.innerHeight * 0.7 };\n }\n /**\n * Load images using the unified loader interface\n */\n async loadImages() {\n try {\n this.showLoading(!0), this.hideError(), this.clearImageCloud(), await this.imageLoader.prepare(this.imageFilter);\n const t = this.imageLoader.imagesLength();\n let e = this.imageLoader.imageURLs();\n if (t === 0) {\n this.showError(\"No images found.\"), this.showLoading(!1);\n return;\n }\n const i = this.getContainerBounds(), n = this.getImageHeight(), s = window.innerWidth;\n this.logDebug(`Adaptive sizing input: container=${i.width}x${i.height}px, images=${t}, responsiveMax=${n}px`);\n const r = this.layoutEngine.calculateAdaptiveSize(\n i,\n t,\n n,\n s\n );\n this.logDebug(`Adaptive sizing result: height=${r.height}px`), await this.createImageCloud(e, r.height), this.showLoading(!1), this.imagesLoaded = !0;\n } catch (t) {\n console.error(\"Error loading images:\", t), t instanceof Error && this.showError(t.message || \"Failed to load images.\"), this.showLoading(!1);\n }\n }\n /**\n * Helper for debug logging\n */\n logDebug(...t) {\n this.fullConfig.config.debug?.enabled && typeof console < \"u\" && console.log(...t);\n }\n async createImageCloud(t, e) {\n if (!this.containerEl) return;\n const i = this.getContainerBounds();\n this.currentImageHeight = e;\n const n = this.loadGeneration, s = this.layoutEngine.generateLayout(t.length, i, { fixedHeight: e });\n this.imageLayouts = s, this.displayQueue = [];\n let r = 0;\n const a = (c) => {\n this.containerEl && (this.containerEl.appendChild(c), this.imageElements.push(c), requestAnimationFrame(() => {\n if (c.offsetWidth, c.style.opacity = this.defaultStyles.opacity ?? \"1\", c.dataset.startX && (this.entryAnimationEngine.requiresJSAnimation() || this.entryAnimationEngine.requiresJSRotation() || this.entryAnimationEngine.requiresJSScale() || c.dataset.startRotation !== c.dataset.rotation || c.dataset.startScale !== c.dataset.scale)) {\n const d = {\n x: parseFloat(c.dataset.startX),\n y: parseFloat(c.dataset.startY)\n }, m = {\n x: parseFloat(c.dataset.endX),\n y: parseFloat(c.dataset.endY)\n }, b = parseFloat(c.dataset.imageWidth), p = parseFloat(c.dataset.imageHeight), g = parseFloat(c.dataset.rotation), f = parseFloat(c.dataset.scale), S = c.dataset.startRotation ? parseFloat(c.dataset.startRotation) : g, v = c.dataset.startScale ? parseFloat(c.dataset.startScale) : f, w = this.entryAnimationEngine.getTiming();\n ee({\n element: c,\n startPosition: d,\n endPosition: m,\n pathConfig: this.entryAnimationEngine.getPathConfig(),\n duration: w.duration,\n imageWidth: b,\n imageHeight: p,\n rotation: g,\n scale: f,\n rotationConfig: this.entryAnimationEngine.getRotationConfig(),\n startRotation: S,\n scaleConfig: this.entryAnimationEngine.getScaleConfig(),\n startScale: v\n });\n } else {\n const d = c.dataset.finalTransform || \"\";\n c.style.transform = d;\n }\n const l = parseInt(c.dataset.imageId || \"0\");\n if (this.fullConfig.config.debug?.enabled && l < 3) {\n const d = c.dataset.finalTransform || \"\";\n console.log(`Image ${l} final state:`, {\n left: c.style.left,\n top: c.style.top,\n width: c.style.width,\n height: c.style.height,\n computedWidth: c.offsetWidth,\n computedHeight: c.offsetHeight,\n transform: d,\n pathType: this.entryAnimationEngine.getPathType()\n });\n }\n }), r++);\n }, h = () => {\n if (this.logDebug(\"Starting queue processing, enabled:\", this.fullConfig.animation.queue.enabled), !this.fullConfig.animation.queue.enabled) {\n for (; this.displayQueue.length > 0; ) {\n const c = this.displayQueue.shift();\n c && a(c);\n }\n return;\n }\n this.queueInterval !== null && clearInterval(this.queueInterval), this.queueInterval = window.setInterval(() => {\n if (n !== this.loadGeneration) {\n this.queueInterval !== null && (clearInterval(this.queueInterval), this.queueInterval = null);\n return;\n }\n if (this.displayQueue.length > 0) {\n const c = this.displayQueue.shift();\n c && a(c);\n }\n r >= t.length && this.displayQueue.length === 0 && this.queueInterval !== null && (clearInterval(this.queueInterval), this.queueInterval = null);\n }, this.fullConfig.animation.queue.interval);\n };\n if (\"IntersectionObserver\" in window && this.containerEl) {\n const c = new IntersectionObserver((u) => {\n u.forEach((l) => {\n l.isIntersecting && (h(), c.disconnect());\n });\n }, { threshold: 0.1, rootMargin: \"50px\" });\n c.observe(this.containerEl);\n } else\n h();\n this.fullConfig.config.debug?.centers && this.containerEl && (this.containerEl.querySelectorAll(\".fbn-ic-debug-center\").forEach((c) => c.remove()), s.forEach((c, u) => {\n const l = document.createElement(\"div\");\n l.className = \"fbn-ic-debug-center\", l.style.position = \"absolute\", l.style.width = \"12px\", l.style.height = \"12px\", l.style.borderRadius = \"50%\", l.style.backgroundColor = \"red\", l.style.border = \"2px solid yellow\", l.style.zIndex = \"9999\", l.style.pointerEvents = \"none\";\n const d = c.x, m = c.y;\n l.style.left = `${d - 6}px`, l.style.top = `${m - 6}px`, l.title = `Image ${u}: center (${Math.round(d)}, ${Math.round(m)})`, this.containerEl.appendChild(l);\n })), t.forEach((c, u) => {\n const l = document.createElement(\"img\");\n l.referrerPolicy = \"no-referrer\", l.classList.add(\"fbn-ic-image\"), l.dataset.imageId = String(u);\n const d = s[u];\n l.style.position = \"absolute\", l.style.width = \"auto\", l.style.height = `${e}px`, l.style.left = `${d.x}px`, l.style.top = `${d.y}px`, d.zIndex && (l.style.zIndex = String(d.zIndex)), it(l, this.defaultStyles), nt(l, this.defaultClassName), l.addEventListener(\"mouseenter\", () => {\n this.hoveredImage = { element: l, layout: d }, this.zoomEngine.isInvolved(l) || (it(l, this.hoverStyles), nt(l, this.hoverClassName));\n }), l.addEventListener(\"mouseleave\", () => {\n this.hoveredImage = null, this.zoomEngine.isInvolved(l) || (it(l, this.defaultStyles), Ft(l, this.hoverClassName), nt(l, this.defaultClassName));\n }), l.addEventListener(\"click\", (m) => {\n m.stopPropagation(), this.handleImageClick(l, d);\n }), l.style.opacity = \"0\", l.style.transition = this.entryAnimationEngine.getTransitionCSS(), l.onload = () => {\n if (n !== this.loadGeneration)\n return;\n const m = l.naturalWidth / l.naturalHeight, b = e * m;\n l.style.width = `${b}px`;\n const p = { x: d.x, y: d.y }, g = { width: b, height: e }, f = this.entryAnimationEngine.calculateStartPosition(\n p,\n g,\n i,\n u,\n t.length\n ), S = this.entryAnimationEngine.calculateStartRotation(d.rotation), v = this.entryAnimationEngine.calculateStartScale(d.scale), w = this.entryAnimationEngine.buildFinalTransform(\n d.rotation,\n d.scale,\n b,\n e\n ), E = this.entryAnimationEngine.buildStartTransform(\n f,\n p,\n d.rotation,\n d.scale,\n b,\n e,\n S,\n v\n );\n this.fullConfig.config.debug?.enabled && u < 3 && console.log(`Image ${u}:`, {\n finalPosition: p,\n imageSize: g,\n left: d.x,\n top: d.y,\n finalTransform: w,\n renderedWidth: b,\n renderedHeight: e\n }), l.style.transform = E, l.dataset.finalTransform = w, (this.entryAnimationEngine.requiresJSAnimation() || this.entryAnimationEngine.requiresJSRotation() || this.entryAnimationEngine.requiresJSScale() || S !== d.rotation || v !== d.scale) && (l.dataset.startX = String(f.x), l.dataset.startY = String(f.y), l.dataset.endX = String(p.x), l.dataset.endY = String(p.y), l.dataset.imageWidth = String(b), l.dataset.imageHeight = String(e), l.dataset.rotation = String(d.rotation), l.dataset.scale = String(d.scale), l.dataset.startRotation = String(S), l.dataset.startScale = String(v)), this.displayQueue.push(l);\n }, l.onerror = () => r++, l.src = c;\n });\n }\n async handleImageClick(t, e) {\n if (!this.containerEl) return;\n const i = this.zoomEngine.isFocused(t), n = {\n width: this.containerEl.offsetWidth,\n height: this.containerEl.offsetHeight\n };\n if (i)\n await this.zoomEngine.unfocusImage(), this.currentFocusIndex = null, this.swipeEngine?.disable(), this.hideCounter();\n else {\n const s = t.dataset.imageId;\n this.currentFocusIndex = s !== void 0 ? parseInt(s, 10) : null, this.swipeEngine?.enable(), await this.zoomEngine.focusImage(t, n, e), this.currentFocusIndex !== null && this.updateCounter(this.currentFocusIndex);\n }\n }\n /**\n * Clear the image cloud and reset state\n */\n clearImageCloud() {\n this.queueInterval !== null && (clearInterval(this.queueInterval), this.queueInterval = null), this.loadGeneration++, this.displayQueue = [], this.containerEl && this.containerEl.querySelectorAll(\".fbn-ic-image, .fbn-ic-debug-center\").forEach((t) => t.remove()), this.imageElements = [], this.imageLayouts = [], this.currentFocusIndex = null, this.hoveredImage = null, this.layoutEngine.reset(), this.zoomEngine.reset(), this.imagesLoaded = !1;\n }\n showLoading(t) {\n !this.fullConfig.rendering.ui.showLoadingSpinner || !this.loadingEl || (t ? this.loadingEl.classList.remove(\"fbn-ic-hidden\") : this.loadingEl.classList.add(\"fbn-ic-hidden\"));\n }\n showError(t) {\n this.errorEl && (this.errorEl.textContent = t, this.errorEl.classList.remove(\"fbn-ic-hidden\"));\n }\n hideError() {\n this.errorEl && this.errorEl.classList.add(\"fbn-ic-hidden\");\n }\n updateCounter(t) {\n !this.fullConfig.rendering.ui.showImageCounter || !this.counterEl || (this.counterEl.textContent = `${t + 1} of ${this.imageElements.length}`, this.counterEl.classList.remove(\"fbn-ic-hidden\"));\n }\n hideCounter() {\n this.counterEl && this.counterEl.classList.add(\"fbn-ic-hidden\");\n }\n /**\n * Destroy the gallery and clean up resources\n */\n destroy() {\n this.clearImageCloud(), this.loadingElAutoCreated && this.loadingEl && (this.loadingEl.remove(), this.loadingEl = null), this.errorElAutoCreated && this.errorEl && (this.errorEl.remove(), this.errorEl = null), this.counterElAutoCreated && this.counterEl && (this.counterEl.remove(), this.counterEl = null), this.resizeTimeout !== null && clearTimeout(this.resizeTimeout), this.swipeEngine?.destroy();\n }\n}\nclass Me {\n constructor(t) {\n 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)\n throw new Error(\"GoogleDriveLoader requires at least one source to be configured\");\n }\n /**\n * Prepare the loader by discovering all images from configured sources\n * @param filter - Filter to apply to discovered images\n */\n async prepare(t) {\n this._discoveredUrls = [];\n for (const e of this.sources)\n if (\"folders\" in e)\n for (const i of e.folders) {\n const n = e.recursive !== void 0 ? e.recursive : !0, s = await this.loadFromFolder(i, t, n);\n this._discoveredUrls.push(...s);\n }\n else if (\"files\" in e) {\n const i = await this.loadFiles(e.files, t);\n this._discoveredUrls.push(...i);\n }\n this._prepared = !0;\n }\n /**\n * Get the number of discovered images\n * @throws Error if called before prepare()\n */\n imagesLength() {\n if (!this._prepared)\n throw new Error(\"GoogleDriveLoader.imagesLength() called before prepare()\");\n return this._discoveredUrls.length;\n }\n /**\n * Get the ordered list of image URLs\n * @throws Error if called before prepare()\n */\n imageURLs() {\n if (!this._prepared)\n throw new Error(\"GoogleDriveLoader.imageURLs() called before prepare()\");\n return [...this._discoveredUrls];\n }\n /**\n * Check if the loader has been prepared\n */\n isPrepared() {\n return this._prepared;\n }\n /**\n * Extract folder ID from various Google Drive URL formats\n * @param folderUrl - Google Drive folder URL\n * @returns Folder ID or null if invalid\n */\n extractFolderId(t) {\n const e = [\n /\\/folders\\/([a-zA-Z0-9_-]+)/,\n // Standard format\n /id=([a-zA-Z0-9_-]+)/\n // Alternative format\n ];\n for (const i of e) {\n const n = t.match(i);\n if (n && n[1])\n return n[1];\n }\n return null;\n }\n /**\n * Load images from a Google Drive folder\n * @param folderUrl - Google Drive folder URL\n * @param filter - Filter to apply to discovered images\n * @param recursive - Whether to include images from subfolders\n * @returns Promise resolving to array of image URLs\n */\n async loadFromFolder(t, e, i = !0) {\n const n = this.extractFolderId(t);\n if (!n)\n throw new Error(\"Invalid Google Drive folder URL. Please check the URL format.\");\n if (!this.apiKey || this.apiKey === \"YOUR_API_KEY_HERE\")\n return this.loadImagesDirectly(n, e);\n try {\n return i ? await this.loadImagesRecursively(n, e) : await this.loadImagesFromSingleFolder(n, e);\n } catch (s) {\n return console.error(\"Error loading from Google Drive API:\", s), this.loadImagesDirectly(n, e);\n }\n }\n /**\n * Load images from a single folder (non-recursive)\n * @param folderId - Google Drive folder ID\n * @param filter - Filter to apply to discovered images\n * @returns Promise resolving to array of image URLs\n */\n async loadImagesFromSingleFolder(t, e) {\n 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);\n if (!a.ok)\n throw new Error(`API request failed: ${a.status} ${a.statusText}`);\n const c = (await a.json()).files.filter(\n (u) => u.mimeType.startsWith(\"image/\") && e.isAllowed(u.name)\n );\n return this.log(`Found ${c.length} images in folder ${t} (non-recursive)`), c.forEach((u) => {\n i.push(`https://lh3.googleusercontent.com/d/${u.id}=s1600`), this.log(`Added file: ${u.name}`);\n }), i;\n }\n /**\n * Load specific files by their URLs or IDs\n * @param fileUrls - Array of Google Drive file URLs or IDs\n * @param filter - Filter to apply to discovered images\n * @returns Promise resolving to array of image URLs\n */\n async loadFiles(t, e) {\n const i = [];\n for (const n of t) {\n const s = this.extractFileId(n);\n if (!s) {\n this.log(`Skipping invalid file URL: ${n}`);\n continue;\n }\n if (this.apiKey && this.apiKey !== \"YOUR_API_KEY_HERE\")\n try {\n const r = `${this.apiEndpoint}/${s}?fields=name,mimeType&key=${this.apiKey}`, a = await fetch(r);\n if (a.ok) {\n const h = await a.json();\n 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})`);\n } else\n this.log(`Failed to fetch metadata for file ${s}: ${a.status}`);\n } catch (r) {\n this.log(`Error fetching metadata for file ${s}:`, r);\n }\n else\n i.push(`https://lh3.googleusercontent.com/d/${s}=s1600`);\n }\n return i;\n }\n /**\n * Extract file ID from Google Drive file URL\n * @param fileUrl - Google Drive file URL or file ID\n * @returns File ID or null if invalid\n */\n extractFileId(t) {\n if (!/[/:.]/.test(t))\n return t;\n const e = [\n /\\/file\\/d\\/([a-zA-Z0-9_-]+)/,\n // Standard file format\n /\\/open\\?id=([a-zA-Z0-9_-]+)/,\n // Alternative format\n /id=([a-zA-Z0-9_-]+)/\n // Generic id parameter\n ];\n for (const i of e) {\n const n = t.match(i);\n if (n && n[1])\n return n[1];\n }\n return null;\n }\n /**\n * Recursively load images from a folder and all its subfolders\n * @param folderId - Google Drive folder ID\n * @param filter - Filter to apply to discovered images\n * @returns Promise resolving to array of image URLs\n */\n async loadImagesRecursively(t, e) {\n 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);\n if (!a.ok)\n throw new Error(`API request failed: ${a.status} ${a.statusText}`);\n const h = await a.json(), c = h.files.filter(\n (l) => l.mimeType.startsWith(\"image/\") && e.isAllowed(l.name)\n ), u = h.files.filter(\n (l) => l.mimeType === \"application/vnd.google-apps.folder\"\n );\n this.log(`Found ${h.files.length} total items in folder ${t}`), h.files.forEach((l) => this.log(` - File: ${l.name} (${l.mimeType})`)), this.log(`- ${c.length} valid files (images only)`), this.log(`- ${u.length} subfolders`), c.forEach((l) => {\n i.push(`https://lh3.googleusercontent.com/d/${l.id}=s1600`), this.log(`Added file: ${l.name}`);\n });\n for (const l of u) {\n this.log(`Loading images from subfolder: ${l.name}`);\n const d = await this.loadImagesRecursively(l.id, e);\n i.push(...d);\n }\n return i;\n }\n /**\n * Direct loading method (no API key required, but less reliable)\n * Uses embedded folder view to scrape image IDs\n * @param folderId - Google Drive folder ID\n * @param filter - Filter to apply (not used in fallback mode)\n * @returns Promise resolving to array of image URLs\n */\n async loadImagesDirectly(t, e) {\n try {\n const i = `https://drive.google.com/embeddedfolderview?id=${t}`, n = await fetch(i, { mode: \"cors\" });\n if (!n.ok)\n throw new Error(\"Cannot access folder directly (CORS or permissions issue)\");\n const s = await n.text(), r = /\\/file\\/d\\/([a-zA-Z0-9_-]+)/g, a = [...s.matchAll(r)];\n return [...new Set(a.map((u) => u[1]))].map(\n (u) => `https://drive.google.com/uc?export=view&id=${u}`\n );\n } catch (i) {\n throw console.error(\"Direct loading failed:\", i), new Error(\n `Unable to load images. Please ensure:\n1. The folder is shared publicly (Anyone with the link can view)\n2. The folder contains image files\n3. Consider adding a Google Drive API key in config.js for better reliability`\n );\n }\n }\n /**\n * Manually add image URLs (for testing or when auto-loading fails)\n * @param imageIds - Array of Google Drive file IDs\n * @returns Array of direct image URLs\n */\n manualImageUrls(t) {\n return t.map((e) => `https://drive.google.com/uc?export=view&id=${e}`);\n }\n /**\n * Debug logging helper\n * @param args - Arguments to log\n */\n log(...t) {\n this.debugLogging && typeof console < \"u\" && console.log(...t);\n }\n}\nclass ze {\n constructor(t) {\n if (this._prepared = !1, this._discoveredUrls = [], this.validateUrls = t.validateUrls !== !1, this.validationTimeout = t.validationTimeout ?? 5e3, this.validationMethod = t.validationMethod ?? \"head\", this.debugLogging = t.debugLogging ?? !1, this.sources = t.sources ?? [], !this.sources || this.sources.length === 0)\n throw new Error(\"StaticImageLoader requires at least one source to be configured\");\n this.log(\"StaticImageLoader initialized with config:\", t);\n }\n /**\n * Prepare the loader by discovering all images from configured sources\n * @param filter - Filter to apply to discovered images\n */\n async prepare(t) {\n this._discoveredUrls = [], this.log(`Processing ${this.sources.length} source(s)`);\n for (const e of this.sources)\n try {\n const i = await this.processSource(e, t);\n this._discoveredUrls.push(...i);\n } catch (i) {\n console.warn(\"Failed to process source:\", e, i);\n }\n this._prepared = !0, this.log(`Successfully loaded ${this._discoveredUrls.length} image(s)`);\n }\n /**\n * Get the number of discovered images\n * @throws Error if called before prepare()\n */\n imagesLength() {\n if (!this._prepared)\n throw new Error(\"StaticImageLoader.imagesLength() called before prepare()\");\n return this._discoveredUrls.length;\n }\n /**\n * Get the ordered list of image URLs\n * @throws Error if called before prepare()\n */\n imageURLs() {\n if (!this._prepared)\n throw new Error(\"StaticImageLoader.imageURLs() called before prepare()\");\n return [...this._discoveredUrls];\n }\n /**\n * Check if the loader has been prepared\n */\n isPrepared() {\n return this._prepared;\n }\n /**\n * Process a single source object using shape-based detection\n * @param source - Source configuration detected by key presence\n * @param filter - Filter to apply to discovered images\n * @returns Promise resolving to array of valid URLs from this source\n */\n async processSource(t, e) {\n return t ? \"urls\" in t ? await this.processUrls(t.urls, e) : \"path\" in t ? await this.processPath(t.path, t.files, e) : \"json\" in t ? await this.processJson(t.json, e) : (console.warn(\"Unknown source shape:\", t), []) : (console.warn(\"Invalid source object:\", t), []);\n }\n /**\n * Process a list of direct URLs\n * @param urls - Array of image URLs\n * @param filter - Filter to apply to discovered images\n * @returns Promise resolving to array of validated URLs\n */\n async processUrls(t, e) {\n if (!Array.isArray(t))\n return console.warn(\"URLs must be an array:\", t), [];\n const i = [];\n for (const n of t) {\n const s = n.split(\"/\").pop() || n;\n if (!e.isAllowed(s)) {\n this.log(`Skipping filtered URL: ${n}`);\n continue;\n }\n this.validateUrls ? await this.validateUrl(n) ? i.push(n) : console.warn(`Skipping invalid/missing URL: ${n}`) : i.push(n);\n }\n return i;\n }\n /**\n * Process a path-based source\n * @param basePath - Base path (relative or absolute)\n * @param files - Array of filenames\n * @param filter - Filter to apply to discovered images\n * @returns Promise resolving to array of validated URLs\n */\n async processPath(t, e, i) {\n if (!Array.isArray(e))\n return console.warn(\"files must be an array:\", e), [];\n const n = [];\n for (const s of e) {\n if (!i.isAllowed(s)) {\n this.log(`Skipping filtered file: ${s}`);\n continue;\n }\n const r = this.constructUrl(t, s);\n this.validateUrls ? await this.validateUrl(r) ? n.push(r) : console.warn(`Skipping invalid/missing file: ${r}`) : n.push(r);\n }\n return n;\n }\n /**\n * Process a JSON endpoint source\n * Fetches a JSON endpoint that returns { images: string[] }\n * @param url - JSON endpoint URL\n * @param filter - Filter to apply to discovered images\n * @returns Promise resolving to array of validated URLs\n */\n async processJson(t, e) {\n this.log(`Fetching JSON endpoint: ${t}`);\n const i = new AbortController(), n = setTimeout(() => i.abort(), 1e4);\n try {\n const s = await fetch(t, { signal: i.signal });\n if (clearTimeout(n), !s.ok)\n throw new Error(`HTTP ${s.status} fetching ${t}`);\n const r = await s.json();\n if (!r || !Array.isArray(r.images))\n throw new Error('JSON source must return JSON with shape { \"images\": [\"url1\", \"url2\", ...] }');\n return this.log(`JSON endpoint returned ${r.images.length} image(s)`), await this.processUrls(r.images, e);\n } catch (s) {\n throw clearTimeout(n), s instanceof Error && s.name === \"AbortError\" ? new Error(`Timeout fetching JSON endpoint: ${t}`) : s;\n }\n }\n /**\n * Validate a single URL using HEAD request\n * @param url - URL to validate\n * @returns Promise resolving to true if valid and accessible\n */\n async validateUrl(t) {\n if (this.validationMethod === \"none\")\n return !0;\n if (this.validationMethod === \"simple\")\n try {\n return typeof window < \"u\" ? new URL(t, window.location.origin) : new URL(t), !0;\n } catch {\n return !1;\n }\n if (typeof window > \"u\")\n return !0;\n if (!(t.startsWith(window.location.origin) || t.startsWith(\"/\")))\n return this.log(`Skipping validation for cross-origin URL: ${t}`), !0;\n try {\n const i = new AbortController(), n = setTimeout(() => i.abort(), this.validationTimeout), s = await fetch(t, {\n method: \"HEAD\",\n signal: i.signal\n });\n return clearTimeout(n), s.ok ? !0 : (this.log(`Validation failed for ${t}: HTTP ${s.status}`), !1);\n } catch (i) {\n return i instanceof Error && (i.name === \"AbortError\" ? this.log(`Validation timeout for ${t}`) : this.log(`Validation failed for ${t}:`, i.message)), !1;\n }\n }\n /**\n * Construct full URL from basePath and filename\n * @param basePath - Base path (relative or absolute)\n * @param filename - Filename to append\n * @returns Complete URL\n */\n constructUrl(t, e) {\n const i = t.replace(/\\/$/, \"\");\n if (this.isAbsoluteUrl(t))\n return `${i}/${e}`;\n if (typeof window > \"u\")\n return `${i}/${e}`;\n const n = window.location.origin, r = (t.startsWith(\"/\") ? t : \"/\" + t).replace(/\\/$/, \"\");\n return `${n}${r}/${e}`;\n }\n /**\n * Check if URL is absolute (contains protocol)\n * @param url - URL to check\n * @returns True if absolute URL\n */\n isAbsoluteUrl(t) {\n try {\n return new URL(t), !0;\n } catch {\n return !1;\n }\n }\n /**\n * Debug logging helper\n * @param args - Arguments to log\n */\n log(...t) {\n this.debugLogging && typeof console < \"u\" && console.log(...t);\n }\n}\nclass Fe {\n constructor(t) {\n if (this._prepared = !1, this._discoveredUrls = [], this.loaders = t.loaders, this.debugLogging = t.debugLogging ?? !1, !this.loaders || this.loaders.length === 0)\n throw new Error(\"CompositeLoader requires at least one loader to be configured\");\n this.log(`CompositeLoader initialized with ${this.loaders.length} loader(s)`);\n }\n /**\n * Prepare all loaders in parallel and combine their results\n * @param filter - Filter to apply to discovered images\n */\n async prepare(t) {\n this._discoveredUrls = [], this.log(`Preparing ${this.loaders.length} loader(s) in parallel`);\n const e = this.loaders.map((i, n) => i.prepare(t).then(() => {\n this.log(`Loader ${n} prepared with ${i.imagesLength()} images`);\n }).catch((s) => {\n console.warn(`Loader ${n} failed to prepare:`, s);\n }));\n await Promise.all(e);\n for (const i of this.loaders)\n if (i.isPrepared()) {\n const n = i.imageURLs();\n this._discoveredUrls.push(...n);\n }\n this._prepared = !0, this.log(`CompositeLoader prepared with ${this._discoveredUrls.length} total images`);\n }\n /**\n * Get the combined number of discovered images\n * @throws Error if called before prepare()\n */\n imagesLength() {\n if (!this._prepared)\n throw new Error(\"CompositeLoader.imagesLength() called before prepare()\");\n return this._discoveredUrls.length;\n }\n /**\n * Get the combined ordered list of image URLs\n * @throws Error if called before prepare()\n */\n imageURLs() {\n if (!this._prepared)\n throw new Error(\"CompositeLoader.imageURLs() called before prepare()\");\n return [...this._discoveredUrls];\n }\n /**\n * Check if the loader has been prepared\n */\n isPrepared() {\n return this._prepared;\n }\n /**\n * Debug logging helper\n * @param args - Arguments to log\n */\n log(...t) {\n this.debugLogging && typeof console < \"u\" && console.log(\"[CompositeLoader]\", ...t);\n }\n}\nexport {\n Xt as AnimationEngine,\n St as BOUNCE_PRESETS,\n ge as ClusterPlacementLayout,\n Fe as CompositeLoader,\n y as DEFAULT_CONFIG,\n Lt as DEFAULT_SHARED_LOADER_CONFIG,\n Et as ELASTIC_PRESETS,\n oe as EntryAnimationEngine,\n Ce as FUNCTIONAL_CSS,\n Me as GoogleDriveLoader,\n ce as GridPlacementLayout,\n Le as ImageCloud,\n Te as ImageFilter,\n Le as ImageGallery,\n fe as LayoutEngine,\n et as LoaderRegistry,\n ae as RadialPlacementLayout,\n se as RandomPlacementLayout,\n de as SpiralPlacementLayout,\n ze as StaticImageLoader,\n It as WAVE_PATH_PRESETS,\n me as WavePlacementLayout,\n ve as ZoomEngine,\n ee as animatePath,\n Re as injectFunctionalStyles,\n ie as requiresJSAnimation\n};\n//# sourceMappingURL=image-cloud.js.map\n"],"names":["Z","t","e","et"],"mappings":"AAmrDA,MAAMA,IAAI,MAAMA,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMhB,OAAO,eAAeC,GAAGC,GAAG;AAC1B,IAAAF,EAAE,SAAS,IAAIC,GAAGC,CAAC;AAAA,EACrB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,UAAUD,GAAG;AAClB,UAAMC,IAAIF,EAAE,SAAS,IAAIC,CAAC;AAC1B,QAAI,CAACC;AACH,YAAM,IAAI;AAAA,QACR,WAAWD,CAAC,+DAA+DA,CAAC;AAAA,MACpF;AACI,WAAOC;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,aAAaD,GAAG;AACrB,WAAOD,EAAE,SAAS,IAAIC,CAAC;AAAA,EACzB;AACF;AACAD,EAAE,WAA2B,oBAAI,IAAG;AACjC,IAACG,IAAKH;"}
@@ -3258,6 +3258,7 @@ export {
3258
3258
  Te as ImageFilter,
3259
3259
  Le as ImageGallery,
3260
3260
  fe as LayoutEngine,
3261
+ et as LoaderRegistry,
3261
3262
  ae as RadialPlacementLayout,
3262
3263
  se as RandomPlacementLayout,
3263
3264
  de as SpiralPlacementLayout,