@pagehub/sdk 0.1.5 → 0.1.7

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.
Files changed (142) hide show
  1. package/README.md +1 -1
  2. package/dist/chrome/viewport/Viewport/hooks/usePageLoadIndicator.d.ts +2 -2
  3. package/dist/chrome/viewport/design-system/hooks/useDesignSystem.d.ts +2 -2
  4. package/dist/chrome/viewport/design-system/hooks/usePaletteState.d.ts +2 -2
  5. package/dist/chunks/ActionEditorPanel-9v50QUwu.js +89 -0
  6. package/dist/chunks/ActionInput-CTt7sOs6.js +929 -0
  7. package/dist/chunks/ActionsAddPicker-BeTPUUor.js +51 -0
  8. package/dist/chunks/ActionsInput-D0h-zLYj.js +174 -0
  9. package/dist/chunks/AnchoredPopover-CckPTxXu.js +2676 -0
  10. package/dist/chunks/AnimationEditorPanel-CXNmsTqV.js +26 -0
  11. package/dist/chunks/AnimationsInput-Djyz0uXG.js +292 -0
  12. package/dist/chunks/AnimationsInputPopover-B2-oNebx.js +71 -0
  13. package/dist/chunks/AnimationsPanel-DungA9qb.js +25 -0
  14. package/dist/chunks/Audio.render-CsR69fZ9.js +22 -0
  15. package/dist/chunks/AudioMainTab-BljM2NMQ.js +70 -0
  16. package/dist/chunks/BackdropEditorPanel-CA2k-6SR.js +26 -0
  17. package/dist/chunks/BackgroundImageInputPopover-vB_217Ig.js +94 -0
  18. package/dist/chunks/BackgroundImagePanel-BvMhF9eU.js +100 -0
  19. package/dist/chunks/BackgroundMainTab-CI4c5DEF.js +10 -0
  20. package/dist/chunks/BundleRowPanel-BcYfyfGQ.js +33 -0
  21. package/dist/chunks/ButtonMainTab-Civy_DoA.js +43 -0
  22. package/dist/chunks/CSSEditorInput-C1ITwAh3.js +73 -0
  23. package/dist/chunks/ClassNameInput-Ce0fGQES.js +720 -0
  24. package/dist/chunks/CodeEditor-axBXmPH8.js +33370 -0
  25. package/dist/chunks/ColorInput-BSfMNt86.js +187 -0
  26. package/dist/chunks/ColorPanel-DOLrT-gS.js +562 -0
  27. package/dist/chunks/ComponentImportExportPanel-DVcnGhGx.js +161 -0
  28. package/dist/chunks/ComponentImportExportPopover-BY1_oxU8.js +26 -0
  29. package/dist/chunks/ConditionEditorPanel-DLbqYaSF.js +43 -0
  30. package/dist/chunks/ConditionsAddPicker-SsHJlc1E.js +54 -0
  31. package/dist/chunks/ConditionsInput-B_5Nge8o.js +474 -0
  32. package/dist/chunks/ContainerMainTab-kkktm1Ns.js +1107 -0
  33. package/dist/chunks/ContainerOverflowSectionPanel-ibKXf-1N.js +120 -0
  34. package/dist/chunks/ContainerOverflowSectionPopover-CRQ9EPsn.js +24 -0
  35. package/dist/chunks/ContainerPaddingOverlay-Cd3xOv-S.js +340 -0
  36. package/dist/chunks/ContainerScrollEffectSection-Dbztqdnr.js +123 -0
  37. package/dist/chunks/ContainerStateSection-DY_gjBJL.js +478 -0
  38. package/dist/chunks/ConversionFields-Bpfl-SGP.js +135 -0
  39. package/dist/chunks/CraftListEditor-_TIy1ogW.js +73 -0
  40. package/dist/chunks/CreateTokenDialog-DNWtWqJd.js +147 -0
  41. package/dist/chunks/Data.render-DTmaqSyz.js +10 -0
  42. package/dist/chunks/DataAttributesPanel-mYhisO_O.js +125 -0
  43. package/dist/chunks/DataMainTab-Batm515E.js +23 -0
  44. package/dist/chunks/DataSourceSectionSlot-BKoO6Vxn.js +10 -0
  45. package/dist/chunks/EditorEmptyLeafHintView-D3E3UN_0.js +78 -0
  46. package/dist/chunks/EffectRowInputPopover-CYhfjFwJ.js +323 -0
  47. package/dist/chunks/EffectsClassInput-Yujuchwy.js +315 -0
  48. package/dist/chunks/Embed.render-BgKpUV8n.js +17 -0
  49. package/dist/chunks/EmbedMainTab-d_-Bnkug.js +225 -0
  50. package/dist/chunks/FilterEditorPanel-CRa0IpLr.js +26 -0
  51. package/dist/chunks/FlexDirectionInput-C5gYjk5W.js +78 -0
  52. package/dist/chunks/FloatingPanel-DJP5Vhua.js +553 -0
  53. package/dist/chunks/FontFamilyInput-CVNnVylt.js +111 -0
  54. package/dist/chunks/Form.render-6GjcmL2u.js +54 -0
  55. package/dist/chunks/FormElement.render-DWrG-2ID.js +36 -0
  56. package/dist/chunks/FormElementMainTab-DSbF3F6e.js +470 -0
  57. package/dist/chunks/FormMainTab-SHny1HxF.js +240 -0
  58. package/dist/chunks/GradientInputPopover-1K6O9jBq.js +103 -0
  59. package/dist/chunks/GradientPanel-DSRQKkaB.js +194 -0
  60. package/dist/chunks/HTMLCodeInput-CCe4Bj5z.js +69 -0
  61. package/dist/chunks/HandlerEditorPanel-DiOXobsl.js +93 -0
  62. package/dist/chunks/HandlersAddPicker-DWTgjKgo.js +101 -0
  63. package/dist/chunks/HandlersInput-p49STTn8.js +132 -0
  64. package/dist/chunks/IconDialogInput-C-81_L2n.js +105 -0
  65. package/dist/chunks/IconInput-D2Gy7Hvf.js +182 -0
  66. package/dist/chunks/IconMainTab-CNrVjDWP.js +26 -0
  67. package/dist/chunks/IconPickerPanel-BjNOlCh6.js +670 -0
  68. package/dist/chunks/ImageMainTab-C4O7RjX0.js +66 -0
  69. package/dist/chunks/ImageSettingsPanel-dvOmGg3C.js +485 -0
  70. package/dist/chunks/LayoutPresetPanel-CNAVAcvw.js +81 -0
  71. package/dist/chunks/LayoutPresetSlot-BqMTdE33.js +16 -0
  72. package/dist/chunks/LinkMainTab-BfFZx0AU.js +13 -0
  73. package/dist/chunks/ListEditor-mD-CmRNE.js +178 -0
  74. package/dist/chunks/Map.render-DFkmncHz.js +82 -0
  75. package/dist/chunks/MapLeaflet-DOfmZ3Pk.js +6588 -0
  76. package/dist/chunks/MapMainTab-CxI7IS1_.js +165 -0
  77. package/dist/chunks/MapPoint.render-0OAfCZTp.js +16 -0
  78. package/dist/chunks/MapPointMainTab-CmLcaSR5.js +60 -0
  79. package/dist/chunks/MediaInput-DHs3D8TJ.js +672 -0
  80. package/dist/chunks/MediaManagerModal-Dc5PK3dn.js +240 -0
  81. package/dist/chunks/MiniPreviewTile-B4zxTj9Y.js +32 -0
  82. package/dist/chunks/ModifierChipList-CwsWklih.js +33 -0
  83. package/dist/chunks/ModifiersAddPicker-D-vSYw7O.js +74 -0
  84. package/dist/chunks/ModifiersPickerPanel-CTefidBx.js +243 -0
  85. package/dist/chunks/NodeAiContextInputPopover-D5bn5o_T.js +66 -0
  86. package/dist/chunks/NodeAiContextPanel-Bx4rcjiM.js +81 -0
  87. package/dist/chunks/NumberSettingsPanel-DASi_l6V.js +56 -0
  88. package/dist/chunks/PageSettingsModal-D6o450IR.js +2678 -0
  89. package/dist/chunks/PatternInputPopover-qMWBv_nl.js +100 -0
  90. package/dist/chunks/PatternPanel-D2fgWDd-.js +352 -0
  91. package/dist/chunks/PeekTargetButton-ClrJX7zh.js +26 -0
  92. package/dist/chunks/PermissionsSection-DwobrV40.js +82 -0
  93. package/dist/chunks/PresetAddChildList-D6a0xdt8.js +35 -0
  94. package/dist/chunks/PropertiesInput-9O39ngbb.js +125 -0
  95. package/dist/chunks/PropertiesPanel-DO0RlalO.js +76 -0
  96. package/dist/chunks/SaveModifierPanel-B6mjKyrT.js +130 -0
  97. package/dist/chunks/ScrollEffectEditorPanel-CllGUhui.js +26 -0
  98. package/dist/chunks/SearchInput-DRUztbM0.js +76 -0
  99. package/dist/chunks/SearchableMenuPopover-DZKVXiEl.js +1251 -0
  100. package/dist/chunks/SlotRenderer-CaLf_2_C.js +38 -0
  101. package/dist/chunks/StateBindingEditorPanel-DKdcG5py.js +101 -0
  102. package/dist/chunks/StateBindingsAddPicker-DxMNAWAD.js +91 -0
  103. package/dist/chunks/StateBindingsInput-iWiqvAVB.js +103 -0
  104. package/dist/chunks/TailwindInput-660FZtyK.js +24 -0
  105. package/dist/chunks/TextEditor-B2O7DlN8.js +22032 -0
  106. package/dist/chunks/TextMainTab-B5udsXsk.js +260 -0
  107. package/dist/chunks/TextStyleEditorPanel-GRNPGzUL.js +381 -0
  108. package/dist/chunks/TextStylePickerPanel-l108SmGQ.js +140 -0
  109. package/dist/chunks/TextareaSettingsPanel-C1rQuF1O.js +50 -0
  110. package/dist/chunks/TokenPicker-Q0LToF_p.js +291 -0
  111. package/dist/chunks/ToolbarDashedButton-DbUxGmDg.js +23 -0
  112. package/dist/chunks/TransformEditorPanel-BGwyznZ6.js +26 -0
  113. package/dist/chunks/TransitionEditorPanel-BSvk58Ow.js +26 -0
  114. package/dist/chunks/TypographyPresetInput-DqnGSgR2.js +296 -0
  115. package/dist/chunks/ValidationPanel-CmA9SfoF.js +56 -0
  116. package/dist/chunks/Video.render-Dg6xvis4.js +21 -0
  117. package/dist/chunks/VideoMainTab-v5UFhUm-.js +174 -0
  118. package/dist/chunks/YouTube.esm-EbHnLU1Z.js +744 -0
  119. package/dist/chunks/dialogAtoms-CeQ2G05l.js +59 -0
  120. package/dist/chunks/extends-hS2Bh-Yp.js +12 -0
  121. package/dist/chunks/formatStorage-C3o2s3dk.js +22 -0
  122. package/dist/chunks/googleFonts-Dj4AntNi.js +323 -0
  123. package/dist/chunks/helpers-Cll72tMn.js +18 -0
  124. package/dist/chunks/index-B-GJd039.js +2875 -0
  125. package/dist/chunks/index-C66dAl3Q.js +32177 -0
  126. package/dist/chunks/index.esm-mqFx3NOs.js +644 -0
  127. package/dist/chunks/popoverOpenRequestAtom-hBS_siXv.js +22 -0
  128. package/dist/chunks/propertyRegistry-CMhVNOgl.js +38 -0
  129. package/dist/chunks/resolveAnchorsViaCraft-Cixm6ZyJ.js +31 -0
  130. package/dist/chunks/toolboxUtils-DjTMslSn.js +370 -0
  131. package/dist/chunks/uiPrimitives-BtohldWg.js +15 -0
  132. package/dist/chunks/use-event-listener-DO3Sk7g0.js +15 -0
  133. package/dist/chunks/useElementPicker-DoNuXNMQ.js +41 -0
  134. package/dist/chunks/useLayoutPreset-wOMV5YnO.js +528 -0
  135. package/dist/chunks/useMediaManager-CmKDbFfw.js +4629 -0
  136. package/dist/chunks/usePopoverAutoOpen-CxIjt0ez.js +25 -0
  137. package/dist/chunks/usePopoverPosition-83Vti7Aw.js +15 -0
  138. package/dist/render/static/index.js +9 -0
  139. package/dist/theme.css +168 -0
  140. package/package.json +25 -14
  141. package/dist/pagehub-viewer.umd.cjs +0 -574
  142. package/dist/pagehub.umd.cjs +0 -1130
@@ -0,0 +1,4629 @@
1
+ import { jsx as a, jsxs as s, Fragment as se } from "react/jsx-runtime";
2
+ import Qe from "react-dom";
3
+ import { ct as qe, dc as Ye, dd as ze, aA as Re, de as ke, bY as Fe, df as Ze, P as ee, dg as $t, aQ as ge, dh as yt, a4 as ut, di as Kt, dj as Bt, dk as Ot, dl as Je, dm as et, dn as tt, dp as at, c6 as _t, Q as Qt, dq as Xe, dr as Nt, ds as Ct, c8 as St, H as Yt, aO as ye, G as jt, dt as Gt, du as Ht, dv as Vt, dw as Wt, aB as Mt, dx as mt, dy as Xt, dz as qt, cd as ht, dA as Zt, dB as Jt, z as ea, ci as ta, dC as aa, dD as na, ca as ra, al as ia, aS as Ae, a_ as nt, d as la, dE as sa, dF as oa, cs as da, dG as ca, bZ as ua, db as pt, dH as ma, u as ha, b$ as pa, dI as ga } from "./index-C66dAl3Q.js";
4
+ import { useState as S, useRef as le, useCallback as J, useEffect as re, useMemo as Ie, useSyncExternalStore as fa } from "react";
5
+ import { b as ba, c as xa, d as va } from "./FloatingPanel-DJP5Vhua.js";
6
+ import { S as Aa } from "./SlotRenderer-CaLf_2_C.js";
7
+ import { ROOT_NODE as q } from "@craftjs/utils";
8
+ import { useEditor as rt } from "@craftjs/core";
9
+ function wa(e) {
10
+ if (!e || typeof e.closest != "function") return !1;
11
+ const t = e, i = t.tagName;
12
+ if (i === "INPUT" || i === "TEXTAREA" || i === "SELECT" || t.isContentEditable) return !0;
13
+ const l = typeof t.getAttribute == "function" ? t.getAttribute("contenteditable") : null;
14
+ return !!(l === "true" || l === "" || t.closest(".ProseMirror") || t.closest(".cm-editor") || t.closest(".cm-content") || t.closest(".monaco-editor"));
15
+ }
16
+ const ya = ({
17
+ isOpen: e,
18
+ onClose: t,
19
+ onConfirm: i,
20
+ title: l,
21
+ message: r,
22
+ confirmText: n = "Confirm",
23
+ cancelText: c = "Cancel",
24
+ variant: m = "danger",
25
+ icon: h
26
+ }) => {
27
+ const d = ba(e), p = xa();
28
+ if (qe({
29
+ id: `confirm-dialog:${l}`,
30
+ isOpen: e,
31
+ onDismiss: t
32
+ }), !e) return null;
33
+ const f = () => {
34
+ switch (m) {
35
+ case "danger":
36
+ return {
37
+ iconBg: "bg-red-100",
38
+ iconColor: "text-red-600",
39
+ confirmBg: "bg-red-600 hover:bg-red-700",
40
+ confirmText: "text-white"
41
+ };
42
+ case "warning":
43
+ return {
44
+ iconBg: "bg-yellow-100",
45
+ iconColor: "text-yellow-600",
46
+ confirmBg: "bg-yellow-600 hover:bg-yellow-700",
47
+ confirmText: "text-white"
48
+ };
49
+ case "info":
50
+ return {
51
+ iconBg: "bg-blue-100",
52
+ iconColor: "text-blue-600",
53
+ confirmBg: "bg-blue-600 hover:bg-blue-700",
54
+ confirmText: "text-white"
55
+ };
56
+ case "success":
57
+ return {
58
+ iconBg: "bg-green-100",
59
+ iconColor: "text-green-600",
60
+ confirmBg: "bg-green-600 hover:bg-green-700",
61
+ confirmText: "text-white"
62
+ };
63
+ default:
64
+ return {
65
+ iconBg: "bg-red-100",
66
+ iconColor: "text-red-600",
67
+ confirmBg: "bg-red-600 hover:bg-red-700",
68
+ confirmText: "text-white"
69
+ };
70
+ }
71
+ }, u = () => {
72
+ switch (m) {
73
+ case "danger":
74
+ return /* @__PURE__ */ a(ze, { className: "text-2xl" });
75
+ case "warning":
76
+ return /* @__PURE__ */ a(ze, { className: "text-2xl" });
77
+ case "info":
78
+ return /* @__PURE__ */ a(ze, { className: "text-2xl" });
79
+ case "success":
80
+ return /* @__PURE__ */ a(Re, { className: "text-2xl" });
81
+ default:
82
+ return /* @__PURE__ */ a(ze, { className: "text-2xl" });
83
+ }
84
+ }, C = f(), o = h || u(), x = () => {
85
+ i(), t(), p(`${l} confirmed`, "assertive");
86
+ };
87
+ return Qe.createPortal(
88
+ /* @__PURE__ */ a(
89
+ "div",
90
+ {
91
+ className: "pagehub-sdk-root ph-modal-backdrop ph-modal-backdrop--center",
92
+ style: { zIndex: Ye },
93
+ onClick: t,
94
+ children: /* @__PURE__ */ a(
95
+ "div",
96
+ {
97
+ ref: d,
98
+ role: "dialog",
99
+ "aria-modal": "true",
100
+ "aria-labelledby": "confirm-dialog-title",
101
+ className: "pagehub-sdk-root ph-modal-surface w-full max-w-md overflow-hidden",
102
+ onClick: (A) => A.stopPropagation(),
103
+ children: /* @__PURE__ */ s("div", { className: "p-6", children: [
104
+ /* @__PURE__ */ s("div", { className: "mb-4 flex items-start gap-4", children: [
105
+ /* @__PURE__ */ a("div", { className: `${C.iconBg} ${C.iconColor} shrink-0 rounded-full p-3`, children: o }),
106
+ /* @__PURE__ */ s("div", { className: "flex-1", children: [
107
+ /* @__PURE__ */ a(
108
+ "h3",
109
+ {
110
+ id: "confirm-dialog-title",
111
+ className: "text-base-content mb-2 text-lg font-semibold",
112
+ children: l
113
+ }
114
+ ),
115
+ /* @__PURE__ */ a("p", { className: "text-neutral-content text-sm", children: r })
116
+ ] })
117
+ ] }),
118
+ /* @__PURE__ */ s("div", { className: "flex justify-end gap-3", children: [
119
+ /* @__PURE__ */ a(
120
+ "button",
121
+ {
122
+ onClick: t,
123
+ className: "border-base-300 text-neutral-content hover:bg-neutral hover:text-base-content rounded-md border px-4 py-2 text-sm font-medium transition-colors",
124
+ children: c
125
+ }
126
+ ),
127
+ /* @__PURE__ */ a(
128
+ "button",
129
+ {
130
+ onClick: x,
131
+ className: `px-4 py-2 text-sm font-medium ${C.confirmBg} ${C.confirmText} rounded-lg transition-colors`,
132
+ children: n
133
+ }
134
+ )
135
+ ] })
136
+ ] })
137
+ }
138
+ )
139
+ }
140
+ ),
141
+ document.querySelector(".pagehub-sdk-root") || document.body
142
+ );
143
+ }, Na = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAABAAEDASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAv/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAX/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwCdABmX/9k=";
144
+ function Ca({ crop: e }) {
145
+ const t = e.getImageUrl();
146
+ return /* @__PURE__ */ s("div", { className: "relative min-h-[400px] flex-1 p-4 lg:min-h-0 lg:p-6", children: [
147
+ /* @__PURE__ */ a("div", { className: "flex h-full flex-col", children: /* @__PURE__ */ a(
148
+ "div",
149
+ {
150
+ role: "presentation",
151
+ "aria-hidden": "true",
152
+ className: "relative flex flex-1 cursor-grab touch-none items-center justify-center overflow-hidden select-none",
153
+ style: {
154
+ cursor: e.isPanning ? "grabbing" : "grab",
155
+ userSelect: "none",
156
+ WebkitUserSelect: "none"
157
+ },
158
+ onPointerDown: e.handlePointerDown,
159
+ onDragStart: (i) => i.preventDefault(),
160
+ onWheel: e.handleWheel,
161
+ onTouchStart: e.handleTouchStart,
162
+ onTouchMove: e.handleTouchMove,
163
+ children: /* @__PURE__ */ a(
164
+ "div",
165
+ {
166
+ ref: e.containerRef,
167
+ className: "relative",
168
+ style: { transform: `scale(${e.previewScale})`, transformOrigin: "center" },
169
+ children: t && /* @__PURE__ */ s(
170
+ "div",
171
+ {
172
+ className: "relative inline-block",
173
+ style: {
174
+ transform: `translate(${e.viewportPosition.x}px, ${e.viewportPosition.y}px)`
175
+ },
176
+ children: [
177
+ /* @__PURE__ */ a(
178
+ "div",
179
+ {
180
+ className: "relative size-full",
181
+ style: {
182
+ width: e.imageSize.width || 400,
183
+ height: e.imageSize.height || 400
184
+ },
185
+ children: /* @__PURE__ */ a(
186
+ ke,
187
+ {
188
+ ref: e.imageRef,
189
+ src: t,
190
+ alt: "Crop preview",
191
+ fill: !0,
192
+ className: "object-contain",
193
+ draggable: !1,
194
+ onLoad: e.handleImageLoad,
195
+ onDragStart: (i) => i.preventDefault(),
196
+ placeholder: "blur",
197
+ blurDataURL: Na,
198
+ crossOrigin: "anonymous"
199
+ }
200
+ )
201
+ }
202
+ ),
203
+ e.imageSize.width > 0 && /* @__PURE__ */ a(
204
+ "div",
205
+ {
206
+ className: "pointer-events-none absolute",
207
+ style: {
208
+ left: 0,
209
+ top: 0,
210
+ width: e.imageSize.width,
211
+ height: e.imageSize.height,
212
+ background: `linear-gradient(to right,
213
+ rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.5) ${e.cropArea.x}px,
214
+ transparent ${e.cropArea.x}px, transparent ${e.cropArea.x + e.cropArea.width}px,
215
+ rgba(0,0,0,0.5) ${e.cropArea.x + e.cropArea.width}px, rgba(0,0,0,0.5) 100%
216
+ ),
217
+ linear-gradient(to bottom,
218
+ rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.5) ${e.cropArea.y}px,
219
+ transparent ${e.cropArea.y}px, transparent ${e.cropArea.y + e.cropArea.height}px,
220
+ rgba(0,0,0,0.5) ${e.cropArea.y + e.cropArea.height}px, rgba(0,0,0,0.5) 100%
221
+ )`
222
+ }
223
+ }
224
+ ),
225
+ e.imageSize.width > 0 && /* @__PURE__ */ s(
226
+ "div",
227
+ {
228
+ className: "pointer-events-none absolute border-2 border-white bg-transparent shadow-lg",
229
+ style: {
230
+ left: e.cropArea.x,
231
+ top: e.cropArea.y,
232
+ width: e.cropArea.width,
233
+ height: e.cropArea.height
234
+ },
235
+ children: [
236
+ /* @__PURE__ */ a(Ke, { position: "-left-1 -top-1", cursor: "nw-resize" }),
237
+ /* @__PURE__ */ a(Ke, { position: "-right-1 -top-1", cursor: "ne-resize" }),
238
+ /* @__PURE__ */ a(Ke, { position: "-bottom-1 -left-1", cursor: "sw-resize" }),
239
+ /* @__PURE__ */ a(Ke, { position: "-bottom-1 -right-1", cursor: "se-resize" }),
240
+ /* @__PURE__ */ a("div", { className: "pointer-events-auto absolute -top-1 left-1/2 h-3 w-2 -translate-x-1/2 cursor-n-resize rounded-full border-2 border-gray-800 bg-white shadow-lg transition-transform hover:scale-110" }),
241
+ /* @__PURE__ */ a("div", { className: "pointer-events-auto absolute -bottom-1 left-1/2 h-3 w-2 -translate-x-1/2 cursor-s-resize rounded-full border-2 border-gray-800 bg-white shadow-lg transition-transform hover:scale-110" }),
242
+ /* @__PURE__ */ a("div", { className: "pointer-events-auto absolute top-1/2 -left-1 h-2 w-3 -translate-y-1/2 cursor-w-resize rounded-full border-2 border-gray-800 bg-white shadow-lg transition-transform hover:scale-110" }),
243
+ /* @__PURE__ */ a("div", { className: "pointer-events-auto absolute top-1/2 -right-1 h-2 w-3 -translate-y-1/2 cursor-e-resize rounded-full border-2 border-gray-800 bg-white shadow-lg transition-transform hover:scale-110" })
244
+ ]
245
+ }
246
+ )
247
+ ]
248
+ }
249
+ )
250
+ }
251
+ )
252
+ }
253
+ ) }),
254
+ e.saveError && /* @__PURE__ */ s("div", { className: "border-error/20 bg-error/10 text-error absolute inset-x-6 top-6 rounded-lg border p-3 text-sm", children: [
255
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
256
+ /* @__PURE__ */ a(Fe, { className: "size-4" }),
257
+ /* @__PURE__ */ a("span", { className: "font-medium", children: "Save Failed" })
258
+ ] }),
259
+ /* @__PURE__ */ a("p", { className: "text-error/80 mt-1", children: e.saveError }),
260
+ /* @__PURE__ */ a(
261
+ "button",
262
+ {
263
+ onClick: () => e.setSaveError(null),
264
+ className: "mt-2 text-xs underline hover:no-underline",
265
+ children: "Dismiss"
266
+ }
267
+ )
268
+ ] }),
269
+ e.saveSuccess && /* @__PURE__ */ s("div", { className: "absolute inset-x-6 top-6 rounded-lg border border-green-500/20 bg-green-500/10 p-3 text-sm text-green-600", children: [
270
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
271
+ /* @__PURE__ */ a(Re, { className: "size-4" }),
272
+ /* @__PURE__ */ a("span", { className: "font-medium", children: "Success!" })
273
+ ] }),
274
+ /* @__PURE__ */ a("p", { className: "mt-1 text-green-600/80", children: e.saveMode === "override" ? `Image cropped and original file replaced on CDN (${e.imageFormat.toUpperCase()}, ${e.imageQuality}% quality)` : `Image cropped and saved as new variant on CDN (${e.imageFormat.toUpperCase()}, ${e.imageQuality}% quality)` })
275
+ ] }),
276
+ /* @__PURE__ */ a("div", { className: "border-base-300 bg-base-200/95 absolute right-3 bottom-3 rounded-lg border px-3 py-1.5 backdrop-blur-sm", children: /* @__PURE__ */ s("div", { className: "flex items-center justify-between gap-6", children: [
277
+ /* @__PURE__ */ s("label", { className: "text-neutral-content flex cursor-pointer items-center gap-2 text-sm", children: [
278
+ "Override original",
279
+ /* @__PURE__ */ a(
280
+ "input",
281
+ {
282
+ type: "checkbox",
283
+ checked: e.saveMode === "override",
284
+ onChange: (i) => e.setSaveMode(i.target.checked ? "override" : "new"),
285
+ className: "border-base-300 bg-neutral text-accent focus:ring-ring size-4 rounded"
286
+ }
287
+ )
288
+ ] }),
289
+ /* @__PURE__ */ a(
290
+ "button",
291
+ {
292
+ type: "button",
293
+ onClick: e.handleSave,
294
+ disabled: e.isSaving,
295
+ className: "btn btn-primary flex items-center gap-2",
296
+ children: e.isSaving ? /* @__PURE__ */ s(se, { children: [
297
+ /* @__PURE__ */ a(Ze, { className: "animate-spin" }),
298
+ "Processing..."
299
+ ] }) : e.saveSuccess ? /* @__PURE__ */ s(se, { children: [
300
+ /* @__PURE__ */ a(Re, {}),
301
+ "Saved!"
302
+ ] }) : /* @__PURE__ */ a(se, { children: e.saveMode === "new" ? "Save as New Variant" : "Override Original" })
303
+ }
304
+ )
305
+ ] }) })
306
+ ] });
307
+ }
308
+ function Ke({ position: e, cursor: t }) {
309
+ return /* @__PURE__ */ a(
310
+ "div",
311
+ {
312
+ className: `pointer-events-auto absolute ${e} size-3 cursor-${t} rounded-full border-2 border-gray-800 bg-white shadow-lg transition-transform hover:scale-110`,
313
+ "data-tooltip-id": ee,
314
+ "data-tooltip-content": `Resize from ${t.replace("-resize", "")}`
315
+ }
316
+ );
317
+ }
318
+ const Sa = (e) => new Promise((t, i) => {
319
+ const l = new Image();
320
+ l.onload = () => {
321
+ const r = {
322
+ width: l.naturalWidth,
323
+ height: l.naturalHeight,
324
+ aspectRatio: l.naturalWidth / l.naturalHeight
325
+ };
326
+ t(r);
327
+ }, l.onerror = () => {
328
+ i(new Error("Failed to load image for dimension extraction"));
329
+ }, l.src = URL.createObjectURL(e);
330
+ }), gt = (e) => new Promise((t, i) => {
331
+ const l = new Image();
332
+ l.onload = () => {
333
+ const r = {
334
+ width: l.naturalWidth,
335
+ height: l.naturalHeight,
336
+ aspectRatio: l.naturalWidth / l.naturalHeight
337
+ };
338
+ t(r);
339
+ }, l.onerror = () => {
340
+ i(new Error("Failed to load image from URL for dimension extraction"));
341
+ }, l.src = e;
342
+ }), it = (e) => {
343
+ const t = e.aspectRatio;
344
+ let i = "";
345
+ return Math.abs(t - 16 / 9) < 0.01 ? i = "16:9" : Math.abs(t - 4 / 3) < 0.01 ? i = "4:3" : Math.abs(t - 1) < 0.01 ? i = "1:1" : Math.abs(t - 3 / 2) < 0.01 ? i = "3:2" : Math.abs(t - 21 / 9) < 0.01 && (i = "21:9"), i ? `${e.width} × ${e.height} (${i})` : `${e.width} × ${e.height}`;
346
+ }, Ma = {
347
+ too_large: "MEDIA_TOO_LARGE",
348
+ bad_mime: "MEDIA_BAD_MIME",
349
+ quota: "MEDIA_QUOTA",
350
+ cf_rejected: "MEDIA_CF_REJECTED",
351
+ auth: "MEDIA_AUTH",
352
+ rate_limited: "MEDIA_RATE_LIMITED",
353
+ network: "MEDIA_NETWORK",
354
+ unknown: "MEDIA_UNKNOWN"
355
+ };
356
+ class we extends $t {
357
+ constructor(t, i, l) {
358
+ super({ code: Ma[t] ?? "MEDIA_UNKNOWN", message: i }), this.name = "MediaUploadError", this.code = t, this.status = l;
359
+ }
360
+ }
361
+ const It = "image/png,image/jpeg,image/jpg,image/gif,image/webp,image/avif,image/svg+xml";
362
+ function lt() {
363
+ return It;
364
+ }
365
+ async function Me(e, t = {}) {
366
+ throw new we(
367
+ "unknown",
368
+ "No media upload handler registered — call registerMediaUploadHandler() at app boot"
369
+ );
370
+ }
371
+ const Ia = [
372
+ { name: "Mobile Hero", width: 375, height: 667, ratio: 0.562 },
373
+ { name: "Desktop Hero", width: 1920, height: 1080, ratio: 1.778 },
374
+ { name: "Square", width: 400, height: 400, ratio: 1 },
375
+ { name: "Instagram Post", width: 1080, height: 1080, ratio: 1 },
376
+ { name: "Instagram Story", width: 1080, height: 1920, ratio: 0.562 },
377
+ { name: "Facebook Cover", width: 1200, height: 630, ratio: 1.905 },
378
+ { name: "Twitter Header", width: 1500, height: 500, ratio: 3 },
379
+ { name: "LinkedIn Cover", width: 1584, height: 396, ratio: 4 }
380
+ ];
381
+ function ka({ media: e, onSave: t, onClose: i, settings: l }) {
382
+ const [r, n] = S({ x: 0, y: 0, width: 200, height: 200 }), [c, m] = S({
383
+ x: 0,
384
+ y: 0,
385
+ width: 200,
386
+ height: 200
387
+ }), [h, d] = S(null), [p, f] = S(!1), [u, C] = S(400), [o, x] = S(400), [A, y] = S(1), [g, b] = S({ width: 0, height: 0 }), [v, k] = S(1), [M, z] = S({ x: 0, y: 0 }), $ = le(!1), _ = le({ x: 0, y: 0 }), B = le(null), H = le(null), V = le(!1), W = le({ x: 0, y: 0 }), [te, Z] = S(!1), [de, fe] = S(0), [oe, ce] = S(1), [O, Ce] = S("new"), [Se, F] = S(!1), [w, D] = S(null), [R, T] = S(!1), [E, Q] = S("webp"), [L, U] = S(90), [Y, ue] = S(""), X = le(null), me = le(null), Ee = () => {
388
+ var I;
389
+ return (e == null ? void 0 : e.type) === "url" ? (I = e.metadata) == null ? void 0 : I.url : (e == null ? void 0 : e.type) === "svg" ? null : e ? ge(e.cdnId || e.id, { width: 800, format: "auto" }) : null;
390
+ }, he = J(
391
+ (I) => {
392
+ n((P) => {
393
+ let N = { ...P, ...I };
394
+ return p && h && (I.width !== void 0 ? N.height = N.width / h : I.height !== void 0 && (N.width = N.height * h)), N.x = Math.max(0, Math.min(N.x, g.width - N.width)), N.y = Math.max(0, Math.min(N.y, g.height - N.height)), N.width = Math.max(50, Math.min(N.width, g.width - N.x)), N.height = Math.max(50, Math.min(N.height, g.height - N.y)), p && h && (I.width !== void 0 ? (N.height = Math.min(N.height, N.width / h), N.width = N.height * h) : I.height !== void 0 && (N.width = Math.min(N.width, N.height * h), N.height = N.width / h)), N;
395
+ });
396
+ },
397
+ [p, h, g]
398
+ ), Te = () => {
399
+ if (!X.current) return;
400
+ const { naturalWidth: I, naturalHeight: P } = X.current;
401
+ if (b({ width: I, height: P }), r.width === 0 && r.height === 0) {
402
+ const N = Math.min(I, P) * 0.5, K = {
403
+ x: (I - N) / 2,
404
+ y: (P - N) / 2,
405
+ width: N,
406
+ height: N
407
+ };
408
+ n(K), m(K);
409
+ }
410
+ y(1), z({ x: 0, y: 0 }), W.current = { x: 0, y: 0 };
411
+ }, { onPointerDown: Pe } = va({
412
+ onStart: (I) => {
413
+ if (!me.current || !X.current) return !1;
414
+ const P = X.current.getBoundingClientRect(), N = (I.clientX - P.left) / v, K = (I.clientY - P.top) / v, j = 8, pe = (ie) => {
415
+ const be = ie.includes("w") ? r.x : r.x + r.width, xe = ie.includes("n") ? r.y : r.y + r.height;
416
+ return Math.abs(N - be) <= j && Math.abs(K - xe) <= j;
417
+ };
418
+ for (const ie of ["nw", "ne", "sw", "se"])
419
+ if (pe(ie)) {
420
+ $.current = !0, B.current = "resize", H.current = ie, _.current = { x: N, y: K };
421
+ return;
422
+ }
423
+ N >= r.x && N <= r.x + r.width && K >= r.y && K <= r.y + r.height ? ($.current = !0, B.current = "move", _.current = { x: N - r.x, y: K - r.y }) : (V.current = !0, _.current = { x: I.clientX, y: I.clientY }, W.current = M, Z(!0));
424
+ },
425
+ onMove: (I) => {
426
+ if (!(!me.current || !X.current))
427
+ if ($.current) {
428
+ const P = X.current.getBoundingClientRect(), N = (I.clientX - P.left) / v, K = (I.clientY - P.top) / v;
429
+ if (B.current === "move")
430
+ he({ x: N - _.current.x, y: K - _.current.y });
431
+ else if (B.current === "resize" && H.current) {
432
+ const j = { ...r };
433
+ switch (H.current) {
434
+ case "nw":
435
+ j.width = r.width + (r.x - N), j.height = r.height + (r.y - K), j.x = N, j.y = K;
436
+ break;
437
+ case "ne":
438
+ j.width = N - r.x, j.height = r.height + (r.y - K), j.y = K;
439
+ break;
440
+ case "sw":
441
+ j.width = r.width + (r.x - N), j.height = K - r.y, j.x = N;
442
+ break;
443
+ case "se":
444
+ j.width = N - r.x, j.height = K - r.y;
445
+ break;
446
+ }
447
+ he(j);
448
+ }
449
+ } else V.current && z({
450
+ x: W.current.x + (I.clientX - _.current.x),
451
+ y: W.current.y + (I.clientY - _.current.y)
452
+ });
453
+ },
454
+ onEnd: () => {
455
+ $.current = !1, B.current = null, H.current = null, V.current = !1, W.current = { x: 0, y: 0 }, Z(!1);
456
+ }
457
+ }), Ge = (I) => {
458
+ if (I.preventDefault(), !me.current || !X.current) return;
459
+ const P = me.current.getBoundingClientRect(), N = I.clientX - P.left, K = I.clientY - P.top, j = I.deltaY > 0 ? 0.9 : 1.1, pe = Math.max(0.1, Math.min(10, v * j));
460
+ if (pe !== v) {
461
+ const ie = X.current.getBoundingClientRect(), be = N - ie.width / 2, xe = K - ie.height / 2, ve = pe / v;
462
+ k(pe), z({
463
+ x: M.x - be * (ve - 1),
464
+ y: M.y - xe * (ve - 1)
465
+ });
466
+ }
467
+ }, Le = (I, P) => Math.sqrt((I.clientX - P.clientX) ** 2 + (I.clientY - P.clientY) ** 2), ot = (I) => {
468
+ I.touches.length === 2 && (I.preventDefault(), fe(Le(I.touches[0], I.touches[1])), ce(v));
469
+ }, dt = (I) => {
470
+ if (I.touches.length !== 2) return;
471
+ I.preventDefault();
472
+ const P = Le(I.touches[0], I.touches[1]), N = Math.max(0.1, Math.min(10, P / de * oe));
473
+ if (N !== v && me.current && X.current) {
474
+ const K = (I.touches[0].clientX + I.touches[1].clientX) / 2, j = (I.touches[0].clientY + I.touches[1].clientY) / 2, pe = me.current.getBoundingClientRect(), ie = X.current.getBoundingClientRect(), be = K - pe.left - ie.width / 2, xe = j - pe.top - ie.height / 2, ve = N / v;
475
+ k(N), z({
476
+ x: M.x - be * (ve - 1),
477
+ y: M.y - xe * (ve - 1)
478
+ });
479
+ }
480
+ }, ae = (I) => {
481
+ C(I.width), x(I.height), d(I.ratio), f(!0);
482
+ const P = Math.min(r.width, g.width - r.x), N = { ...r, width: P, height: P / I.ratio };
483
+ he(N), m(N);
484
+ }, He = (I) => {
485
+ y(I);
486
+ const P = Math.min(c.width * I, g.width), N = p && h ? P / h : Math.min(c.height * I, g.height), K = c.x + c.width / 2, j = c.y + c.height / 2;
487
+ he({
488
+ x: Math.max(0, Math.min(K - P / 2, g.width - P)),
489
+ y: Math.max(0, Math.min(j - N / 2, g.height - N)),
490
+ width: P,
491
+ height: N
492
+ });
493
+ }, $e = (I, P) => {
494
+ I === "width" ? (C(P), p && h && x(P / h)) : (x(P), p && h && C(P * h));
495
+ }, Pt = async () => new Promise((I, P) => {
496
+ const N = X.current;
497
+ if (!N || !N.complete) {
498
+ P(new Error("Image not loaded"));
499
+ return;
500
+ }
501
+ const K = document.createElement("canvas"), j = K.getContext("2d");
502
+ if (!j) {
503
+ P(new Error("Canvas context not available"));
504
+ return;
505
+ }
506
+ K.width = u, K.height = o;
507
+ const pe = X.current.getBoundingClientRect(), ie = g.width / pe.width, be = g.height / pe.height;
508
+ j.drawImage(
509
+ N,
510
+ r.x * ie,
511
+ r.y * be,
512
+ r.width * ie,
513
+ r.height * be,
514
+ 0,
515
+ 0,
516
+ u,
517
+ o
518
+ ), K.toBlob(
519
+ (xe) => {
520
+ var ct;
521
+ if (!xe) {
522
+ P(new Error("Failed to create image blob"));
523
+ return;
524
+ }
525
+ const ve = Y.trim() || `${((ct = e.metadata) == null ? void 0 : ct.title) || e.id}-${u}x${o}`, Lt = O === "new" ? `${ve}-${Date.now()}.${E}` : `${ve}.${E}`;
526
+ I(new File([xe], Lt, { type: `image/${E}` }));
527
+ },
528
+ `image/${E}`,
529
+ L / 100
530
+ );
531
+ });
532
+ return {
533
+ // Crop
534
+ cropArea: r,
535
+ imageSize: g,
536
+ aspectRatio: h,
537
+ lockAspectRatio: p,
538
+ customWidth: u,
539
+ customHeight: o,
540
+ cropScale: A,
541
+ baseCropArea: c,
542
+ setLockAspectRatio: f,
543
+ setAspectRatio: d,
544
+ updateCropArea: he,
545
+ handleImageLoad: Te,
546
+ handlePresetSelect: ae,
547
+ handleCropScaleChange: He,
548
+ handleCustomSizeChange: $e,
549
+ // Viewport
550
+ previewScale: v,
551
+ setPreviewScale: k,
552
+ viewportPosition: M,
553
+ setViewportPosition: z,
554
+ isPanning: te,
555
+ // Drag
556
+ handlePointerDown: Pe,
557
+ handleWheel: Ge,
558
+ handleTouchStart: ot,
559
+ handleTouchMove: dt,
560
+ // Save
561
+ saveMode: O,
562
+ setSaveMode: Ce,
563
+ isSaving: Se,
564
+ saveError: w,
565
+ setSaveError: D,
566
+ saveSuccess: R,
567
+ handleSave: async () => {
568
+ var I, P;
569
+ F(!0), D(null), T(!1);
570
+ try {
571
+ const N = await Pt(), { mediaId: K } = await Me(N, {
572
+ skipPreprocess: !0
573
+ });
574
+ if (O === "override")
575
+ try {
576
+ await yt(e.id, l);
577
+ } catch {
578
+ }
579
+ const j = {
580
+ ...e,
581
+ id: O === "new" ? K : e.id,
582
+ metadata: {
583
+ ...e.metadata,
584
+ title: Y.trim() || `${((I = e.metadata) == null ? void 0 : I.title) || e.id} (${u}x${o})`,
585
+ versionName: Y.trim() || `${u}x${o}`,
586
+ cropArea: r,
587
+ customWidth: u,
588
+ customHeight: o,
589
+ aspectRatio: h,
590
+ isVariant: O === "new",
591
+ parentId: O === "new" ? e.id : void 0,
592
+ dimensions: {
593
+ width: u,
594
+ height: o,
595
+ aspectRatio: u / o
596
+ },
597
+ ...O === "override" && {
598
+ originalFileReplaced: !0,
599
+ replacedAt: (/* @__PURE__ */ new Date()).toISOString(),
600
+ originalDimensions: (P = e.metadata) == null ? void 0 : P.dimensions,
601
+ newCdnId: K
602
+ }
603
+ }
604
+ };
605
+ t(j), T(!0), setTimeout(() => i(), 1500);
606
+ } catch (N) {
607
+ const K = N instanceof we || N instanceof Error ? N.message : "Failed to save image";
608
+ D(K);
609
+ } finally {
610
+ F(!1);
611
+ }
612
+ },
613
+ // Export
614
+ imageFormat: E,
615
+ setImageFormat: Q,
616
+ imageQuality: L,
617
+ setImageQuality: U,
618
+ versionName: Y,
619
+ setVersionName: ue,
620
+ // Refs
621
+ imageRef: X,
622
+ containerRef: me,
623
+ // Image
624
+ getImageUrl: Ee
625
+ };
626
+ }
627
+ function Oe({ title: e, children: t }) {
628
+ return /* @__PURE__ */ s("div", { className: "space-y-3", children: [
629
+ /* @__PURE__ */ s("h3", { className: "toolbar-label flex items-center gap-2 font-semibold", children: [
630
+ /* @__PURE__ */ a("div", { className: "bg-primary h-4 w-1 rounded-full" }),
631
+ e
632
+ ] }),
633
+ /* @__PURE__ */ a("div", { className: "border-base-300/30 bg-base-200 rounded-lg border p-4", children: t })
634
+ ] });
635
+ }
636
+ function ft({
637
+ title: e,
638
+ value: t,
639
+ onChange: i,
640
+ min: l = 0.1,
641
+ max: r = 10,
642
+ step: n = 0.1,
643
+ presets: c = [0.5, 1, 2]
644
+ }) {
645
+ return /* @__PURE__ */ s(Oe, { title: e, children: [
646
+ /* @__PURE__ */ s("div", { className: "mb-3 flex items-center gap-3", children: [
647
+ /* @__PURE__ */ a("span", { className: "toolbar-label font-medium", children: "Scale:" }),
648
+ /* @__PURE__ */ a("div", { className: "relative flex-1", children: /* @__PURE__ */ a(
649
+ "input",
650
+ {
651
+ type: "range",
652
+ min: l,
653
+ max: r,
654
+ step: n,
655
+ value: t,
656
+ onChange: (m) => i(parseFloat(m.target.value)),
657
+ className: "slider bg-neutral h-2 w-full cursor-pointer appearance-none rounded-lg"
658
+ }
659
+ ) }),
660
+ /* @__PURE__ */ s("div", { className: "bg-primary/10 text-primary min-w-12 rounded-md px-2 py-1 text-center text-sm font-semibold", children: [
661
+ Math.round(t * 100),
662
+ "%"
663
+ ] })
664
+ ] }),
665
+ /* @__PURE__ */ a("div", { className: "flex gap-2", children: c.map((m) => /* @__PURE__ */ s(
666
+ "button",
667
+ {
668
+ onClick: () => i(m),
669
+ className: "bg-neutral text-neutral-content hover:bg-primary/10 hover:text-primary flex-1 rounded-md px-3 py-2 text-xs font-medium transition-colors",
670
+ children: [
671
+ Math.round(m * 100),
672
+ "%"
673
+ ]
674
+ },
675
+ m
676
+ )) })
677
+ ] });
678
+ }
679
+ function Da({ crop: e }) {
680
+ return /* @__PURE__ */ a(ut, { className: "border-base-300 from-neutral/20 to-neutral/40 w-full bg-linear-to-b p-4 pb-20 sm:w-64 md:w-72 lg:w-80 lg:border-r lg:p-6", children: /* @__PURE__ */ s("div", { className: "space-y-6", children: [
681
+ /* @__PURE__ */ a(Oe, { title: "Aspect Ratios", children: /* @__PURE__ */ a(ut, { className: "h-32 pr-1", children: /* @__PURE__ */ a("div", { className: "grid grid-cols-2 gap-2", children: Ia.map((t) => /* @__PURE__ */ s(
682
+ "button",
683
+ {
684
+ onClick: () => e.handlePresetSelect(t),
685
+ className: "group border-base-300 bg-base-200 hover:border-primary/30 hover:bg-primary/5 rounded-lg border p-2 text-left text-xs hover:shadow-sm",
686
+ children: [
687
+ /* @__PURE__ */ a("div", { className: "text-base-content group-hover:text-primary font-semibold transition-colors", children: t.name }),
688
+ /* @__PURE__ */ s("div", { className: "text-neutral-content text-xs", children: [
689
+ t.width,
690
+ " × ",
691
+ t.height
692
+ ] })
693
+ ]
694
+ },
695
+ t.name
696
+ )) }) }) }),
697
+ /* @__PURE__ */ a(Oe, { title: "Dimensions", children: /* @__PURE__ */ s("div", { className: "flex items-center gap-3", children: [
698
+ /* @__PURE__ */ s("div", { className: "flex-1", children: [
699
+ /* @__PURE__ */ a(
700
+ "label",
701
+ {
702
+ htmlFor: "crop-width-input",
703
+ className: "text-neutral-content mb-1 block text-xs font-medium",
704
+ children: "Width"
705
+ }
706
+ ),
707
+ /* @__PURE__ */ a(
708
+ "input",
709
+ {
710
+ id: "crop-width-input",
711
+ type: "number",
712
+ value: e.customWidth,
713
+ onChange: (t) => e.handleCustomSizeChange("width", parseInt(t.target.value) || 0),
714
+ className: "input-dialog-md focus:border-primary focus:ring-primary/20 focus:ring-1"
715
+ }
716
+ )
717
+ ] }),
718
+ /* @__PURE__ */ a(
719
+ "button",
720
+ {
721
+ onClick: () => e.setLockAspectRatio(!e.lockAspectRatio),
722
+ className: `rounded-lg p-2 ${e.lockAspectRatio ? "bg-primary text-primary-content shadow-sm" : "bg-neutral text-neutral-content hover:bg-primary/10 hover:text-primary"}`,
723
+ "data-tooltip-id": ee,
724
+ "data-tooltip-content": e.lockAspectRatio ? "Unlock aspect ratio" : "Lock aspect ratio",
725
+ children: e.lockAspectRatio ? /* @__PURE__ */ a(Kt, { className: "size-4" }) : /* @__PURE__ */ a(Bt, { className: "size-4" })
726
+ }
727
+ ),
728
+ /* @__PURE__ */ s("div", { className: "flex-1", children: [
729
+ /* @__PURE__ */ a(
730
+ "label",
731
+ {
732
+ htmlFor: "crop-height-input",
733
+ className: "text-neutral-content mb-1 block text-xs font-medium",
734
+ children: "Height"
735
+ }
736
+ ),
737
+ /* @__PURE__ */ a(
738
+ "input",
739
+ {
740
+ id: "crop-height-input",
741
+ type: "number",
742
+ value: e.customHeight,
743
+ onChange: (t) => e.handleCustomSizeChange("height", parseInt(t.target.value) || 0),
744
+ className: "input-dialog-md focus:border-primary focus:ring-primary/20 focus:ring-1"
745
+ }
746
+ )
747
+ ] })
748
+ ] }) }),
749
+ /* @__PURE__ */ a(
750
+ ft,
751
+ {
752
+ title: "Crop Size",
753
+ value: e.cropScale,
754
+ onChange: e.handleCropScaleChange,
755
+ min: 0.1,
756
+ max: 3,
757
+ presets: [0.5, 1, 2]
758
+ }
759
+ ),
760
+ /* @__PURE__ */ a(
761
+ ft,
762
+ {
763
+ title: "Zoom",
764
+ value: e.previewScale,
765
+ onChange: (t) => {
766
+ e.setPreviewScale(t), e.setViewportPosition({ x: 0, y: 0 });
767
+ },
768
+ min: 0.1,
769
+ max: 10,
770
+ presets: [0.5, 1, 2]
771
+ }
772
+ ),
773
+ /* @__PURE__ */ s(Oe, { title: "Export Settings", children: [
774
+ /* @__PURE__ */ s("div", { className: "mb-4", children: [
775
+ /* @__PURE__ */ a(
776
+ "label",
777
+ {
778
+ htmlFor: "crop-version-name-input",
779
+ className: "text-neutral-content mb-1 block text-xs font-medium",
780
+ children: "Version Name"
781
+ }
782
+ ),
783
+ /* @__PURE__ */ a(
784
+ "input",
785
+ {
786
+ id: "crop-version-name-input",
787
+ type: "text",
788
+ value: e.versionName,
789
+ onChange: (t) => e.setVersionName(t.target.value),
790
+ placeholder: `${e.customWidth}x${e.customHeight} crop`,
791
+ className: "input-dialog-md focus:border-primary focus:ring-primary/20 focus:ring-1"
792
+ }
793
+ )
794
+ ] }),
795
+ /* @__PURE__ */ s("div", { className: "mb-4", children: [
796
+ /* @__PURE__ */ a("span", { className: "toolbar-label mb-2 block font-medium", children: "Format" }),
797
+ /* @__PURE__ */ a("div", { className: "grid grid-cols-3 gap-1", children: [
798
+ { value: "webp", label: "WebP", desc: "Best" },
799
+ { value: "png", label: "PNG", desc: "Lossless" },
800
+ { value: "jpeg", label: "JPEG", desc: "Universal" }
801
+ ].map((t) => /* @__PURE__ */ s(
802
+ "button",
803
+ {
804
+ onClick: () => e.setImageFormat(t.value),
805
+ className: `rounded-md p-1.5 text-xs font-medium transition-colors ${e.imageFormat === t.value ? "bg-primary text-primary-content" : "bg-neutral text-neutral-content hover:bg-primary/10 hover:text-primary"}`,
806
+ children: [
807
+ /* @__PURE__ */ a("div", { className: "text-xs font-semibold", children: t.label }),
808
+ /* @__PURE__ */ a("div", { className: "text-xs opacity-70", children: t.desc })
809
+ ]
810
+ },
811
+ t.value
812
+ )) })
813
+ ] }),
814
+ /* @__PURE__ */ s("div", { children: [
815
+ /* @__PURE__ */ s("div", { className: "mb-3 flex items-center gap-3", children: [
816
+ /* @__PURE__ */ a("span", { className: "toolbar-label font-medium", children: "Quality:" }),
817
+ /* @__PURE__ */ a("div", { className: "relative flex-1", children: /* @__PURE__ */ a(
818
+ "input",
819
+ {
820
+ type: "range",
821
+ min: "10",
822
+ max: "100",
823
+ step: "5",
824
+ value: e.imageQuality,
825
+ onChange: (t) => e.setImageQuality(parseInt(t.target.value)),
826
+ className: "slider bg-neutral h-2 w-full cursor-pointer appearance-none rounded-lg"
827
+ }
828
+ ) }),
829
+ /* @__PURE__ */ s("div", { className: "bg-primary/10 text-primary min-w-12 rounded-md px-2 py-1 text-center text-sm font-semibold", children: [
830
+ e.imageQuality,
831
+ "%"
832
+ ] })
833
+ ] }),
834
+ /* @__PURE__ */ a("div", { className: "flex gap-2", children: [50, 75, 90, 100].map((t) => /* @__PURE__ */ s(
835
+ "button",
836
+ {
837
+ onClick: () => e.setImageQuality(t),
838
+ className: `flex-1 rounded-lg px-3 py-2 text-xs font-medium transition-colors ${e.imageQuality === t ? "bg-primary text-primary-content" : "bg-neutral text-neutral-content hover:bg-primary/10 hover:text-primary"}`,
839
+ children: [
840
+ t,
841
+ "%"
842
+ ]
843
+ },
844
+ t
845
+ )) })
846
+ ] })
847
+ ] })
848
+ ] }) });
849
+ }
850
+ function Fn({ isOpen: e, onClose: t, media: i, onSave: l, settings: r }) {
851
+ var c;
852
+ const n = ka({ media: i, onSave: l, onClose: t, settings: r });
853
+ return e ? Qe.createPortal(
854
+ /* @__PURE__ */ a(
855
+ "div",
856
+ {
857
+ className: "pagehub-sdk-root ph-modal-backdrop ph-modal-backdrop--center",
858
+ style: { zIndex: Ye },
859
+ onClick: t,
860
+ children: /* @__PURE__ */ s(
861
+ "div",
862
+ {
863
+ className: "pagehub-sdk-root ph-modal-surface bg-base-200! relative mx-4 max-h-[90vh] w-full max-w-6xl overflow-hidden",
864
+ onClick: (m) => m.stopPropagation(),
865
+ children: [
866
+ /* @__PURE__ */ s("div", { className: "border-base-300 bg-neutral/20 flex items-center justify-between border-b px-6 py-4", children: [
867
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-4", children: [
868
+ /* @__PURE__ */ a("div", { className: "border-primary/20 bg-primary/10 flex size-10 items-center justify-center rounded-lg border", children: /* @__PURE__ */ a(Ot, { className: "text-primary text-lg" }) }),
869
+ /* @__PURE__ */ s("div", { children: [
870
+ /* @__PURE__ */ a("h2", { className: "text-base-content text-xl font-semibold", children: "Image Cropper" }),
871
+ /* @__PURE__ */ a("p", { className: "text-neutral-content text-sm font-medium", children: ((c = i == null ? void 0 : i.metadata) == null ? void 0 : c.title) || (i == null ? void 0 : i.id) })
872
+ ] })
873
+ ] }),
874
+ /* @__PURE__ */ a(
875
+ "button",
876
+ {
877
+ onClick: t,
878
+ className: "text-neutral-content hover:bg-neutral hover:text-base-content rounded-md p-2 transition-colors",
879
+ "data-tooltip-id": ee,
880
+ "data-tooltip-content": "Close",
881
+ children: /* @__PURE__ */ a(Fe, { className: "text-lg" })
882
+ }
883
+ )
884
+ ] }),
885
+ /* @__PURE__ */ s("div", { className: "relative flex h-full max-h-[calc(90vh-120px)] flex-col lg:flex-row", children: [
886
+ /* @__PURE__ */ a(Da, { crop: n }),
887
+ /* @__PURE__ */ a(Ca, { crop: n })
888
+ ] })
889
+ ]
890
+ }
891
+ )
892
+ }
893
+ ),
894
+ document.querySelector(".pagehub-sdk-root") || document.body
895
+ ) : null;
896
+ }
897
+ const je = {
898
+ image: "Image",
899
+ video: "Video",
900
+ audio: "Audio",
901
+ pdf: "PDF",
902
+ archive: "Archive",
903
+ other: "File"
904
+ };
905
+ function De(e) {
906
+ var i;
907
+ const t = ((i = e.metadata) == null ? void 0 : i.contentType) || "";
908
+ return e.type === "svg" || e.type === "cdn" || e.type === "url" || t.startsWith("image/") ? "image" : t.startsWith("video/") ? "video" : t.startsWith("audio/") ? "audio" : t === "application/pdf" ? "pdf" : t === "application/zip" ? "archive" : "other";
909
+ }
910
+ function kt(e) {
911
+ switch (De(e)) {
912
+ case "image":
913
+ return It;
914
+ case "video":
915
+ return "video/*";
916
+ case "audio":
917
+ return "audio/*";
918
+ case "pdf":
919
+ return "application/pdf";
920
+ case "archive":
921
+ return "application/zip";
922
+ default:
923
+ return "*/*";
924
+ }
925
+ }
926
+ function Ue(e) {
927
+ if (e === 0) return "0 B";
928
+ const t = 1024, i = ["B", "KB", "MB", "GB"], l = Math.floor(Math.log(e) / Math.log(t));
929
+ return `${(e / Math.pow(t, l)).toFixed(1)} ${i[l]}`;
930
+ }
931
+ function Fa(e, t, i) {
932
+ return [...e].sort((l, r) => {
933
+ var m, h, d, p;
934
+ let n, c;
935
+ switch (t) {
936
+ case "name":
937
+ n = ((m = l.metadata) == null ? void 0 : m.title) || l.id, c = ((h = r.metadata) == null ? void 0 : h.title) || r.id;
938
+ break;
939
+ case "size":
940
+ n = ((d = l.metadata) == null ? void 0 : d.size) || 0, c = ((p = r.metadata) == null ? void 0 : p.size) || 0;
941
+ break;
942
+ case "createdAt":
943
+ n = l.uploadedAt || l.createdAt || 0, c = r.uploadedAt || r.createdAt || 0;
944
+ break;
945
+ case "order":
946
+ n = l.order || 0, c = r.order || 0;
947
+ break;
948
+ default:
949
+ return 0;
950
+ }
951
+ return typeof n == "string" && typeof c == "string" ? i === "asc" ? n.localeCompare(c) : c.localeCompare(n) : i === "asc" ? n - c : c - n;
952
+ });
953
+ }
954
+ function Dt(e) {
955
+ let t = e.trim();
956
+ t = t.replace(/<\?xml[^?]*\?>/gi, ""), t = t.replace(/<!DOCTYPE[^>]*>/gi, ""), t = t.replace(/<!--[\s\S]*?-->/g, "");
957
+ const i = t.match(/<svg[\s\S]*<\/svg>/i);
958
+ return i && (t = i[0]), t = t.replace(/\s*(width|height)\s*=\s*["'][^"']*["']/gi, ""), t = t.replace(/fill\s*=\s*["']#000000["']/gi, 'fill="currentColor"'), t = t.replace(/fill\s*=\s*["']#000["']/gi, 'fill="currentColor"'), t = t.replace(/fill\s*=\s*["']black["']/gi, 'fill="currentColor"'), t = t.replace(/fill\s*=\s*["']rgb\(0,\s*0,\s*0\)["']/gi, 'fill="currentColor"'), t = t.replace(/fill\s*=\s*["']rgba\(0,\s*0,\s*0,\s*1\)["']/gi, 'fill="currentColor"'), t.trim();
959
+ }
960
+ const bt = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAABAAEDASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAv/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAX/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwCdABmX/9k=";
961
+ function Ea({
962
+ editingMedia: e,
963
+ savingMetadata: t,
964
+ canUseImageAnalyze: i,
965
+ mediaEditAiActionsContext: l,
966
+ onClose: r,
967
+ onSave: n,
968
+ onUpdate: c
969
+ }) {
970
+ var h, d, p, f, u, C, o, x, A, y, g;
971
+ const m = (b, v) => {
972
+ c({
973
+ ...e,
974
+ metadata: { ...e.metadata, [b]: v }
975
+ });
976
+ };
977
+ return Qe.createPortal(
978
+ /* @__PURE__ */ a(
979
+ "div",
980
+ {
981
+ role: "button",
982
+ tabIndex: 0,
983
+ className: "bg-base-100/60 text-neutral-content fixed inset-0 flex items-center justify-center backdrop-blur-sm",
984
+ style: { zIndex: Ye },
985
+ onClick: r,
986
+ onKeyDown: (b) => {
987
+ (b.key === "Enter" || b.key === " ") && (b.preventDefault(), r());
988
+ },
989
+ children: /* @__PURE__ */ s(
990
+ "div",
991
+ {
992
+ onClick: (b) => b.stopPropagation(),
993
+ className: "pagehub-sdk-root ph-modal-surface-heavy flex max-h-[80vh] w-full max-w-2xl flex-col overflow-hidden",
994
+ children: [
995
+ /* @__PURE__ */ s("div", { className: "border-base-300 flex items-center justify-between border-b p-6", children: [
996
+ /* @__PURE__ */ a("h3", { className: "text-base-content text-xl font-bold", children: "Edit Media" }),
997
+ /* @__PURE__ */ a(
998
+ "button",
999
+ {
1000
+ onClick: r,
1001
+ className: "text-neutral-content hover:text-base-content text-xl",
1002
+ children: /* @__PURE__ */ a(Fe, {})
1003
+ }
1004
+ )
1005
+ ] }),
1006
+ /* @__PURE__ */ s("div", { className: "scrollbar-light relative flex-1 space-y-4 overflow-y-auto p-6", children: [
1007
+ /* @__PURE__ */ s("div", { className: "border-base-300 bg-neutral text-neutral-content flex items-center gap-4 rounded-lg border p-4", children: [
1008
+ e.type === "url" ? /* @__PURE__ */ a("div", { className: "bg-neutral relative size-24 overflow-hidden rounded-lg", children: /* @__PURE__ */ a(
1009
+ ke,
1010
+ {
1011
+ src: (h = e.metadata) == null ? void 0 : h.url,
1012
+ alt: ((d = e.metadata) == null ? void 0 : d.alt) || "Preview",
1013
+ width: 96,
1014
+ height: 96,
1015
+ className: "object-cover",
1016
+ placeholder: "blur",
1017
+ blurDataURL: bt
1018
+ }
1019
+ ) }) : e.type === "svg" ? /* @__PURE__ */ a(
1020
+ "div",
1021
+ {
1022
+ className: "border-base-300 flex size-24 items-center justify-center rounded-lg border",
1023
+ dangerouslySetInnerHTML: { __html: ((p = e.metadata) == null ? void 0 : p.svg) || "" }
1024
+ }
1025
+ ) : /* @__PURE__ */ a("div", { className: "bg-neutral relative size-24 overflow-hidden rounded-lg", children: /* @__PURE__ */ a(
1026
+ ke,
1027
+ {
1028
+ src: ge(e.cdnId || e.id, {
1029
+ width: 200,
1030
+ format: "auto"
1031
+ }),
1032
+ alt: ((f = e.metadata) == null ? void 0 : f.alt) || "Preview",
1033
+ width: 96,
1034
+ height: 96,
1035
+ className: "object-cover",
1036
+ placeholder: "blur",
1037
+ blurDataURL: bt
1038
+ },
1039
+ `${e.id}-${e.uploadedAt || 0}`
1040
+ ) }),
1041
+ /* @__PURE__ */ s("div", { className: "flex-1", children: [
1042
+ /* @__PURE__ */ a("p", { className: "text-neutral-content font-mono text-sm", children: e.id }),
1043
+ /* @__PURE__ */ s("p", { className: "text-neutral-content mt-1 text-xs", children: [
1044
+ "Type: ",
1045
+ e.type || "cdn"
1046
+ ] }),
1047
+ ((u = e.metadata) == null ? void 0 : u.size) && /* @__PURE__ */ s("p", { className: "text-neutral-content mt-1 text-xs", children: [
1048
+ "Size: ",
1049
+ Ue(e.metadata.size)
1050
+ ] }),
1051
+ ((C = e.metadata) == null ? void 0 : C.dimensions) && /* @__PURE__ */ s("p", { className: "text-neutral-content mt-1 text-xs", children: [
1052
+ "Dimensions: ",
1053
+ it(e.metadata.dimensions)
1054
+ ] })
1055
+ ] })
1056
+ ] }),
1057
+ e.type === "url" && /* @__PURE__ */ s("div", { children: [
1058
+ /* @__PURE__ */ s("label", { htmlFor: "edit-image-url", className: "toolbar-label mb-2 block font-medium", children: [
1059
+ "Image URL ",
1060
+ /* @__PURE__ */ a("span", { className: "text-error", children: "*" })
1061
+ ] }),
1062
+ /* @__PURE__ */ a(
1063
+ "input",
1064
+ {
1065
+ id: "edit-image-url",
1066
+ type: "text",
1067
+ value: ((o = e.metadata) == null ? void 0 : o.url) || "",
1068
+ onChange: (b) => m("url", b.target.value),
1069
+ placeholder: "https://example.com/image.jpg",
1070
+ className: "input placeholder:text-neutral-content"
1071
+ }
1072
+ )
1073
+ ] }),
1074
+ e.type === "svg" && /* @__PURE__ */ s("div", { children: [
1075
+ /* @__PURE__ */ s("label", { htmlFor: "edit-svg-code", className: "toolbar-label mb-2 block font-medium", children: [
1076
+ "SVG Code ",
1077
+ /* @__PURE__ */ a("span", { className: "text-error", children: "*" })
1078
+ ] }),
1079
+ /* @__PURE__ */ a(
1080
+ "textarea",
1081
+ {
1082
+ id: "edit-svg-code",
1083
+ value: ((x = e.metadata) == null ? void 0 : x.svg) || "",
1084
+ onChange: (b) => m("svg", b.target.value),
1085
+ placeholder: "<svg>...</svg>",
1086
+ className: "input placeholder:text-neutral-content min-h-[8rem] resize-none font-mono text-sm",
1087
+ rows: 6
1088
+ }
1089
+ )
1090
+ ] }),
1091
+ /* @__PURE__ */ s("div", { children: [
1092
+ /* @__PURE__ */ a("label", { htmlFor: "edit-file-name", className: "toolbar-label mb-2 block font-medium", children: "File Name" }),
1093
+ /* @__PURE__ */ a(
1094
+ "input",
1095
+ {
1096
+ id: "edit-file-name",
1097
+ type: "text",
1098
+ value: ((A = e.metadata) == null ? void 0 : A.title) || "",
1099
+ onChange: (b) => m("title", b.target.value),
1100
+ placeholder: "Enter file name",
1101
+ className: "input placeholder:text-neutral-content"
1102
+ }
1103
+ )
1104
+ ] }),
1105
+ /* @__PURE__ */ s("div", { children: [
1106
+ /* @__PURE__ */ s("label", { htmlFor: "edit-alt-text", className: "toolbar-label mb-2 block font-medium", children: [
1107
+ "Alt Text ",
1108
+ /* @__PURE__ */ a("span", { className: "text-error", children: "*" })
1109
+ ] }),
1110
+ /* @__PURE__ */ a(
1111
+ "input",
1112
+ {
1113
+ id: "edit-alt-text",
1114
+ type: "text",
1115
+ value: ((y = e.metadata) == null ? void 0 : y.alt) || "",
1116
+ onChange: (b) => m("alt", b.target.value),
1117
+ placeholder: "Describe the image for accessibility",
1118
+ className: "input placeholder:text-neutral-content"
1119
+ }
1120
+ ),
1121
+ /* @__PURE__ */ a("p", { className: "text-neutral-content mt-1 text-xs", children: "Important for accessibility and SEO" })
1122
+ ] }),
1123
+ /* @__PURE__ */ s("div", { children: [
1124
+ /* @__PURE__ */ a("label", { htmlFor: "edit-description", className: "toolbar-label mb-2 block font-medium", children: "Description" }),
1125
+ /* @__PURE__ */ a(
1126
+ "textarea",
1127
+ {
1128
+ id: "edit-description",
1129
+ value: ((g = e.metadata) == null ? void 0 : g.description) || "",
1130
+ onChange: (b) => m("description", b.target.value),
1131
+ placeholder: "Additional details about this media",
1132
+ rows: 3,
1133
+ className: "input placeholder:text-neutral-content min-h-[4.5rem] resize-none"
1134
+ }
1135
+ )
1136
+ ] }),
1137
+ i && e.type !== "svg" && l && /* @__PURE__ */ a("div", { className: "border-base-300 border-t pt-4", children: /* @__PURE__ */ a(Aa, { id: "media-edit/ai-actions", ctx: l }) })
1138
+ ] }),
1139
+ /* @__PURE__ */ s("div", { className: "border-base-300 bg-neutral text-neutral-content flex justify-end gap-3 border-t p-6", children: [
1140
+ /* @__PURE__ */ a("button", { type: "button", onClick: r, className: "btn btn-secondary", children: "Cancel" }),
1141
+ /* @__PURE__ */ a(
1142
+ "button",
1143
+ {
1144
+ type: "button",
1145
+ onClick: (b) => {
1146
+ b.preventDefault(), b.stopPropagation(), n();
1147
+ },
1148
+ disabled: t !== "idle",
1149
+ className: `btn btn-primary flex items-center gap-2 ${t === "saving" ? "cursor-not-allowed opacity-60" : ""}`,
1150
+ children: t === "saving" ? /* @__PURE__ */ s(se, { children: [
1151
+ /* @__PURE__ */ a(Ze, { className: "animate-spin" }),
1152
+ "Saving..."
1153
+ ] }) : t === "saved" ? /* @__PURE__ */ s(se, { children: [
1154
+ /* @__PURE__ */ a(Re, {}),
1155
+ "Saved"
1156
+ ] }) : /* @__PURE__ */ s(se, { children: [
1157
+ /* @__PURE__ */ a(Je, {}),
1158
+ "Save Changes"
1159
+ ] })
1160
+ }
1161
+ )
1162
+ ] })
1163
+ ]
1164
+ }
1165
+ )
1166
+ }
1167
+ ),
1168
+ document.querySelector(".pagehub-sdk-root") || document.body
1169
+ );
1170
+ }
1171
+ const Ta = "flex w-full cursor-pointer items-center gap-1 px-3 py-3 text-neutral-content hover:bg-neutral";
1172
+ function za({ children: e }) {
1173
+ return /* @__PURE__ */ a("div", { className: "text-neutral-content/60 px-3 pt-3 pb-1 text-[10px] font-medium tracking-widest uppercase", children: e });
1174
+ }
1175
+ function Ve({ icon: e, label: t, onClick: i, kbd: l }) {
1176
+ return /* @__PURE__ */ s("button", { type: "button", onClick: i, className: Ta, children: [
1177
+ /* @__PURE__ */ a("div", { className: "shrink-0 text-base", children: e }),
1178
+ /* @__PURE__ */ a("div", { className: "min-w-0 flex-1 text-left", children: t }),
1179
+ l ?? null
1180
+ ] });
1181
+ }
1182
+ const xt = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAABAAEDASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAv/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAX/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwCdABmX/9k=", Ft = "grid-cols-[2rem_minmax(0,2.4fr)_minmax(4.5rem,.7fr)_minmax(4.8rem,.75fr)_minmax(6.2rem,.9fr)_minmax(6rem,.8fr)]";
1183
+ function Ra({
1184
+ filteredMedia: e,
1185
+ viewMode: t,
1186
+ sortField: i,
1187
+ selectedMedia: l,
1188
+ selectedMediaIds: r,
1189
+ deletingMedia: n,
1190
+ searchQuery: c,
1191
+ uploadProgress: m,
1192
+ isDragOver: h,
1193
+ dropProps: d,
1194
+ selectionMode: p,
1195
+ onSelect: f,
1196
+ onClose: u,
1197
+ onItemSelect: C,
1198
+ onPreview: o,
1199
+ onSetAddMode: x,
1200
+ folderNameById: A,
1201
+ fileInputRef: y
1202
+ }) {
1203
+ return /* @__PURE__ */ s(
1204
+ "div",
1205
+ {
1206
+ className: `scrollbar-light bg-base-100 relative h-full overflow-y-auto transition-colors ${h ? "border-accent bg-accent border-2 border-dashed" : ""} ${m ? "pt-16" : "p-3"}`,
1207
+ ...d,
1208
+ children: [
1209
+ h && /* @__PURE__ */ a("div", { className: "border-accent bg-base-200/75 absolute inset-0 z-40 flex items-center justify-center rounded-lg border-2 border-dashed backdrop-blur-sm", children: /* @__PURE__ */ s("div", { className: "text-accent-content flex flex-col items-center gap-4", children: [
1210
+ /* @__PURE__ */ a(et, { className: "text-6xl" }),
1211
+ /* @__PURE__ */ s("div", { className: "text-center", children: [
1212
+ /* @__PURE__ */ a("p", { className: "text-xl font-semibold", children: "Drop files here" }),
1213
+ /* @__PURE__ */ a("p", { className: "text-sm opacity-75", children: "Release to upload multiple files" })
1214
+ ] })
1215
+ ] }) }),
1216
+ m && /* @__PURE__ */ s("div", { className: "border-base-300 bg-base-200 absolute inset-x-0 top-0 z-30 border-b p-4", children: [
1217
+ /* @__PURE__ */ s("div", { className: "mb-2 flex items-center justify-between", children: [
1218
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
1219
+ /* @__PURE__ */ a("div", { className: "border-accent size-4 animate-spin rounded-full border-2 border-t-transparent" }),
1220
+ /* @__PURE__ */ s("span", { className: "text-base-content text-sm font-medium", children: [
1221
+ "Uploading ",
1222
+ m.current + 1,
1223
+ " of ",
1224
+ m.total,
1225
+ " files"
1226
+ ] })
1227
+ ] }),
1228
+ /* @__PURE__ */ s("span", { className: "text-neutral-content text-xs", children: [
1229
+ Math.round((m.current + 1) / m.total * 100),
1230
+ "%"
1231
+ ] })
1232
+ ] }),
1233
+ /* @__PURE__ */ a("div", { className: "bg-neutral text-neutral-content mb-2 h-2 w-full rounded-full", children: /* @__PURE__ */ a(
1234
+ "div",
1235
+ {
1236
+ className: "bg-accent text-accent-content h-2 rounded-full transition-all duration-300 ease-out",
1237
+ style: {
1238
+ width: `${(m.current + 1) / m.total * 100}%`
1239
+ }
1240
+ }
1241
+ ) }),
1242
+ m.currentFile && /* @__PURE__ */ s("div", { className: "text-neutral-content truncate text-xs", children: [
1243
+ /* @__PURE__ */ a(tt, { className: "mr-1 inline" }),
1244
+ " ",
1245
+ m.currentFile
1246
+ ] }),
1247
+ m.completedFiles.length > 0 && /* @__PURE__ */ s("div", { className: "text-secondary-content mt-1 text-xs", children: [
1248
+ /* @__PURE__ */ a(Re, { className: "mr-1 inline" }),
1249
+ " Completed:",
1250
+ " ",
1251
+ m.completedFiles.join(", ")
1252
+ ] })
1253
+ ] }),
1254
+ e.length === 0 ? /* @__PURE__ */ a("div", { className: "flex h-full flex-col items-center justify-center p-8 text-center", children: c ? /* @__PURE__ */ s("div", { className: "animate-modal-in flex flex-col items-center", children: [
1255
+ /* @__PURE__ */ a("div", { className: "bg-neutral mb-4 rounded-full p-6", children: /* @__PURE__ */ a(at, { className: "text-neutral-content text-5xl" }) }),
1256
+ /* @__PURE__ */ a("p", { className: "text-base-content mb-2 text-xl font-semibold", children: "No media found" }),
1257
+ /* @__PURE__ */ a("p", { className: "text-neutral-content text-sm", children: "Try adjusting search or folder/type filters" })
1258
+ ] }) : /* @__PURE__ */ a(Ua, { onSetAddMode: x, fileInputRef: y }) }) : /* @__PURE__ */ s(se, { children: [
1259
+ t === "list" && /* @__PURE__ */ s(
1260
+ "div",
1261
+ {
1262
+ className: `text-base-content/60 border-base-300/70 bg-base-100/80 mb-1 grid ${Ft} items-center gap-3 rounded-md border px-4 py-2 text-[10px] font-semibold tracking-[0.08em] uppercase`,
1263
+ children: [
1264
+ /* @__PURE__ */ a("span", {}),
1265
+ /* @__PURE__ */ a("span", { children: "Name" }),
1266
+ /* @__PURE__ */ a("span", { children: "Type" }),
1267
+ /* @__PURE__ */ a("span", { children: "Size" }),
1268
+ /* @__PURE__ */ a("span", { children: "Modified" }),
1269
+ /* @__PURE__ */ a("span", { children: "Folder" })
1270
+ ]
1271
+ }
1272
+ ),
1273
+ /* @__PURE__ */ a(
1274
+ "div",
1275
+ {
1276
+ className: t === "cards" ? "grid grid-cols-[repeat(auto-fill,minmax(11.5rem,1fr))] gap-3" : "border-base-300/70 bg-base-100 overflow-hidden rounded-md border",
1277
+ children: e.map((g) => {
1278
+ const b = r.includes(g.id);
1279
+ return /* @__PURE__ */ a(
1280
+ Pa,
1281
+ {
1282
+ media: g,
1283
+ viewMode: t,
1284
+ sortField: i,
1285
+ isSelected: b,
1286
+ isDeleting: n.includes(g.id),
1287
+ folderNameById: A,
1288
+ selectionMode: p,
1289
+ onSelect: (v) => C(g.id, v),
1290
+ onDoubleClick: () => {
1291
+ p && f && (f(g.id), u());
1292
+ },
1293
+ onPreview: () => o(g.id)
1294
+ },
1295
+ g.id
1296
+ );
1297
+ })
1298
+ }
1299
+ )
1300
+ ] }),
1301
+ l && p && f && /* @__PURE__ */ a("div", { className: "absolute right-4 bottom-4", children: /* @__PURE__ */ a(
1302
+ "button",
1303
+ {
1304
+ type: "button",
1305
+ onClick: () => {
1306
+ f(l), u();
1307
+ },
1308
+ className: "btn btn-primary shadow-lg",
1309
+ children: "Select"
1310
+ }
1311
+ ) })
1312
+ ]
1313
+ }
1314
+ );
1315
+ }
1316
+ function Ua({
1317
+ onSetAddMode: e,
1318
+ fileInputRef: t
1319
+ }) {
1320
+ return /* @__PURE__ */ s("div", { className: "flex w-full max-w-2xl animate-[slide-up_0.8s_ease-out_forwards] flex-col items-center justify-center gap-8", children: [
1321
+ /* @__PURE__ */ s("div", { className: "w-full max-w-lg", children: [
1322
+ /* @__PURE__ */ a(za, { children: "Add media" }),
1323
+ /* @__PURE__ */ s("div", { className: "border-base-300 bg-base-100 overflow-hidden rounded-xl border", children: [
1324
+ /* @__PURE__ */ a(
1325
+ Ve,
1326
+ {
1327
+ icon: /* @__PURE__ */ a(et, { className: "size-5" }),
1328
+ label: /* @__PURE__ */ s("div", { children: [
1329
+ /* @__PURE__ */ a("div", { className: "text-base-content text-sm font-medium", children: "Upload Files" }),
1330
+ /* @__PURE__ */ a("div", { className: "text-neutral-content text-xs", children: "Drag & drop or click to upload files" })
1331
+ ] }),
1332
+ onClick: () => {
1333
+ var i;
1334
+ e("upload"), (i = t.current) == null || i.click();
1335
+ }
1336
+ }
1337
+ ),
1338
+ /* @__PURE__ */ a("div", { className: "bg-base-300 h-px", "aria-hidden": !0 }),
1339
+ /* @__PURE__ */ a(
1340
+ Ve,
1341
+ {
1342
+ icon: /* @__PURE__ */ a(_t, { className: "size-5" }),
1343
+ label: /* @__PURE__ */ s("div", { children: [
1344
+ /* @__PURE__ */ a("div", { className: "text-base-content text-sm font-medium", children: "Use URLs" }),
1345
+ /* @__PURE__ */ a("div", { className: "text-neutral-content text-xs", children: "Link to assets hosted anywhere" })
1346
+ ] }),
1347
+ onClick: () => e("url")
1348
+ }
1349
+ ),
1350
+ /* @__PURE__ */ a("div", { className: "bg-base-300 h-px", "aria-hidden": !0 }),
1351
+ /* @__PURE__ */ a(
1352
+ Ve,
1353
+ {
1354
+ icon: /* @__PURE__ */ a(Qt, { className: "size-5" }),
1355
+ label: /* @__PURE__ */ s("div", { children: [
1356
+ /* @__PURE__ */ a("div", { className: "text-base-content text-sm font-medium", children: "Paste SVG" }),
1357
+ /* @__PURE__ */ a("div", { className: "text-neutral-content text-xs", children: "Add inline SVG code directly" })
1358
+ ] }),
1359
+ onClick: () => e("svg")
1360
+ }
1361
+ )
1362
+ ] })
1363
+ ] }),
1364
+ /* @__PURE__ */ s("div", { className: "text-neutral-content flex flex-col gap-2 text-xs", children: [
1365
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
1366
+ /* @__PURE__ */ a(Xe, { className: "text-primary text-base" }),
1367
+ /* @__PURE__ */ a("span", { children: "Paste images from your clipboard anywhere in this window" })
1368
+ ] }),
1369
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
1370
+ /* @__PURE__ */ a(Xe, { className: "text-primary text-base" }),
1371
+ /* @__PURE__ */ a("span", { children: "Drag and drop multiple files at once for batch upload" })
1372
+ ] })
1373
+ ] })
1374
+ ] });
1375
+ }
1376
+ function Pa({
1377
+ media: e,
1378
+ viewMode: t,
1379
+ sortField: i,
1380
+ isSelected: l,
1381
+ isDeleting: r,
1382
+ folderNameById: n,
1383
+ selectionMode: c,
1384
+ onSelect: m,
1385
+ onDoubleClick: h,
1386
+ onPreview: d
1387
+ }) {
1388
+ var C;
1389
+ const p = De(e), f = (C = e.metadata) != null && C.folderId ? n.get(e.metadata.folderId) ?? "Unfiled" : "Unfiled", u = (o) => {
1390
+ m({ shiftKey: o.shiftKey, metaKey: o.metaKey, ctrlKey: o.ctrlKey });
1391
+ };
1392
+ return /* @__PURE__ */ s(
1393
+ "div",
1394
+ {
1395
+ role: "button",
1396
+ tabIndex: 0,
1397
+ className: `group relative cursor-pointer ${t === "cards" ? `border-base-300 bg-base-200 overflow-hidden rounded-lg border ${l ? "ring-primary ring-offset-background ring-2 ring-offset-2" : "hover:border-primary"}` : `border-base-300/70 grid ${Ft} items-center gap-3 border-b px-4 py-2 ${l ? "bg-primary/10" : "hover:bg-base-200/55"}`} ${r ? "pointer-events-none opacity-60" : ""}`,
1398
+ onClick: u,
1399
+ onDoubleClick: h,
1400
+ onKeyDown: (o) => {
1401
+ (o.key === "Enter" || o.key === " ") && (o.preventDefault(), m());
1402
+ },
1403
+ children: [
1404
+ r && /* @__PURE__ */ a("div", { className: "bg-error/20 absolute inset-0 z-50 flex items-center justify-center backdrop-blur-sm", children: /* @__PURE__ */ s("div", { className: "flex flex-col items-center gap-2", children: [
1405
+ /* @__PURE__ */ a(Ze, { className: "text-error size-8 animate-spin" }),
1406
+ /* @__PURE__ */ a("span", { className: "text-error text-xs font-medium", children: "Deleting..." })
1407
+ ] }) }),
1408
+ !c && t === "list" && /* @__PURE__ */ a("div", { className: "flex items-center", onClick: (o) => o.stopPropagation(), children: /* @__PURE__ */ a(
1409
+ "input",
1410
+ {
1411
+ type: "checkbox",
1412
+ checked: l,
1413
+ onChange: () => {
1414
+ },
1415
+ onClick: (o) => {
1416
+ o.stopPropagation(), m({ shiftKey: o.shiftKey, metaKey: !0 });
1417
+ },
1418
+ className: "checkbox checkbox-sm border-base-300 bg-base-100/95",
1419
+ "aria-label": "Select media item"
1420
+ }
1421
+ ) }),
1422
+ t === "cards" ? /* @__PURE__ */ a(La, { media: e, sortField: i, folderLabel: f, kind: p }) : /* @__PURE__ */ a(
1423
+ $a,
1424
+ {
1425
+ media: e,
1426
+ folderLabel: f,
1427
+ kind: p,
1428
+ showLeadingSpacer: c
1429
+ }
1430
+ ),
1431
+ !c && t === "cards" && /* @__PURE__ */ a("div", { className: "absolute top-1 left-1", onClick: (o) => o.stopPropagation(), children: /* @__PURE__ */ a(
1432
+ "input",
1433
+ {
1434
+ type: "checkbox",
1435
+ checked: l,
1436
+ onChange: () => {
1437
+ },
1438
+ onClick: (o) => {
1439
+ o.stopPropagation(), m({ shiftKey: o.shiftKey, metaKey: !0 });
1440
+ },
1441
+ className: "checkbox checkbox-sm border-base-300 bg-base-100/95",
1442
+ "aria-label": "Select media item"
1443
+ }
1444
+ ) }),
1445
+ t === "cards" && /* @__PURE__ */ a(
1446
+ "button",
1447
+ {
1448
+ type: "button",
1449
+ onClick: (o) => {
1450
+ o.stopPropagation(), d();
1451
+ },
1452
+ className: "bg-base-100/90 text-base-content absolute top-1 right-1 rounded p-1.5 opacity-0 transition-opacity group-hover:opacity-100",
1453
+ "aria-label": "Preview media",
1454
+ "data-tooltip-id": ee,
1455
+ "data-tooltip-content": "Preview",
1456
+ "data-tooltip-place": "top",
1457
+ "data-tooltip-offset": 8,
1458
+ children: /* @__PURE__ */ a(Nt, { className: "size-4" })
1459
+ }
1460
+ )
1461
+ ]
1462
+ }
1463
+ );
1464
+ }
1465
+ function La({
1466
+ media: e,
1467
+ sortField: t,
1468
+ folderLabel: i,
1469
+ kind: l
1470
+ }) {
1471
+ var d, p, f, u, C, o, x;
1472
+ const r = e.type === "r2", n = ((d = e.metadata) == null ? void 0 : d.contentType) || "", c = r && n.startsWith("video/"), m = r && n.startsWith("audio/"), h = (p = e.metadata) == null ? void 0 : p.deliveryURL;
1473
+ return /* @__PURE__ */ s("div", { className: "flex h-full flex-col", children: [
1474
+ /* @__PURE__ */ s(
1475
+ "div",
1476
+ {
1477
+ className: "bg-neutral relative aspect-square overflow-hidden bg-cover bg-center",
1478
+ style: {
1479
+ backgroundImage: e.type === "url" ? `url("${(f = e.metadata) == null ? void 0 : f.url}")` : e.type === "svg" || r ? void 0 : `url(${ge(e.cdnId || e.id, { width: 400, format: "auto" })})`
1480
+ },
1481
+ children: [
1482
+ /* @__PURE__ */ a("div", { className: "bg-base-100/95 text-base-content absolute top-1 right-1 rounded px-1.5 py-0.5 text-[10px] font-medium", children: je[l] }),
1483
+ e.type === "svg" && /* @__PURE__ */ a(
1484
+ "div",
1485
+ {
1486
+ className: "flex size-full items-center justify-center p-2",
1487
+ dangerouslySetInnerHTML: { __html: ((u = e.metadata) == null ? void 0 : u.svg) || "" }
1488
+ }
1489
+ ),
1490
+ c && h && /* @__PURE__ */ a(
1491
+ "video",
1492
+ {
1493
+ src: h,
1494
+ className: "size-full object-cover",
1495
+ preload: "metadata",
1496
+ muted: !0,
1497
+ playsInline: !0
1498
+ }
1499
+ ),
1500
+ r && !c && /* @__PURE__ */ s("div", { className: "text-base-content/70 flex size-full flex-col items-center justify-center gap-1 p-2", children: [
1501
+ m ? /* @__PURE__ */ a(Ct, { className: "size-8" }) : /* @__PURE__ */ a(St, { className: "size-8" }),
1502
+ /* @__PURE__ */ a("span", { className: "truncate text-[10px]", children: n || "file" })
1503
+ ] })
1504
+ ]
1505
+ }
1506
+ ),
1507
+ /* @__PURE__ */ s("div", { className: "bg-base-100 flex min-h-[4.5rem] flex-col gap-0.5 p-2", children: [
1508
+ /* @__PURE__ */ a("p", { className: "text-base-content truncate text-xs font-semibold", children: ((C = e.metadata) == null ? void 0 : C.title) || e.id }),
1509
+ /* @__PURE__ */ s("p", { className: "text-neutral-content truncate text-[10px]", children: [
1510
+ (o = e.metadata) != null && o.size ? Ue(e.metadata.size) : "--",
1511
+ (x = e.metadata) != null && x.dimensions ? ` • ${it(e.metadata.dimensions)}` : ""
1512
+ ] }),
1513
+ /* @__PURE__ */ s("p", { className: "text-neutral-content truncate text-[10px]", children: [
1514
+ t === "createdAt" ? e.uploadedAt ? new Date(e.uploadedAt).toLocaleDateString() : "Unknown date" : i,
1515
+ t !== "createdAt" ? "" : ` • ${i}`
1516
+ ] })
1517
+ ] })
1518
+ ] });
1519
+ }
1520
+ function $a({
1521
+ media: e,
1522
+ folderLabel: t,
1523
+ kind: i,
1524
+ showLeadingSpacer: l
1525
+ }) {
1526
+ var d, p, f, u, C, o, x, A;
1527
+ const r = e.type === "r2", n = ((d = e.metadata) == null ? void 0 : d.contentType) || "", c = r && n.startsWith("video/"), m = r && n.startsWith("audio/"), h = (p = e.metadata) == null ? void 0 : p.deliveryURL;
1528
+ return /* @__PURE__ */ s(se, { children: [
1529
+ l ? /* @__PURE__ */ a("span", {}) : null,
1530
+ /* @__PURE__ */ s("div", { className: "flex min-w-0 items-center gap-3", children: [
1531
+ /* @__PURE__ */ a("div", { className: "border-base-300 bg-neutral flex size-12 shrink-0 items-center justify-center overflow-hidden rounded-md border", children: e.type === "url" ? /* @__PURE__ */ a("div", { className: "bg-neutral relative size-full", children: /* @__PURE__ */ a(
1532
+ ke,
1533
+ {
1534
+ src: (f = e.metadata) == null ? void 0 : f.url,
1535
+ alt: ((u = e.metadata) == null ? void 0 : u.alt) || e.id,
1536
+ fill: !0,
1537
+ className: "object-cover",
1538
+ onError: (y) => {
1539
+ y.currentTarget.style.display = "none";
1540
+ },
1541
+ placeholder: "blur",
1542
+ blurDataURL: xt
1543
+ },
1544
+ `${e.id}-url-${e.uploadedAt || 0}`
1545
+ ) }) : e.type === "svg" ? /* @__PURE__ */ a(
1546
+ "div",
1547
+ {
1548
+ className: "size-full p-1",
1549
+ dangerouslySetInnerHTML: { __html: ((C = e.metadata) == null ? void 0 : C.svg) || "" }
1550
+ }
1551
+ ) : c && h ? /* @__PURE__ */ a(
1552
+ "video",
1553
+ {
1554
+ src: h,
1555
+ className: "size-full object-cover",
1556
+ preload: "metadata",
1557
+ muted: !0,
1558
+ playsInline: !0
1559
+ }
1560
+ ) : r ? /* @__PURE__ */ a("div", { className: "text-base-content/70 flex size-full items-center justify-center", children: m ? /* @__PURE__ */ a(Ct, { className: "size-5" }) : /* @__PURE__ */ a(St, { className: "size-5" }) }) : /* @__PURE__ */ a("div", { className: "bg-neutral relative size-full", children: /* @__PURE__ */ a(
1561
+ ke,
1562
+ {
1563
+ src: ge(e.cdnId || e.id, { width: 100, format: "auto" }),
1564
+ alt: ((o = e.metadata) == null ? void 0 : o.alt) || e.id,
1565
+ fill: !0,
1566
+ className: "object-cover",
1567
+ loading: "lazy",
1568
+ onError: (y) => {
1569
+ y.currentTarget.style.display = "none";
1570
+ },
1571
+ placeholder: "blur",
1572
+ blurDataURL: xt
1573
+ },
1574
+ `${e.id}-cdn-${e.uploadedAt || 0}`
1575
+ ) }) }),
1576
+ /* @__PURE__ */ s("div", { className: "min-w-0", children: [
1577
+ /* @__PURE__ */ a("p", { className: "text-base-content truncate text-sm font-medium", children: ((x = e.metadata) == null ? void 0 : x.title) || e.id }),
1578
+ /* @__PURE__ */ a("p", { className: "text-neutral-content truncate text-[10px]", children: e.id })
1579
+ ] })
1580
+ ] }),
1581
+ /* @__PURE__ */ a("div", { className: "text-base-content/70 truncate text-xs font-medium", children: je[i] }),
1582
+ /* @__PURE__ */ a("div", { className: "text-base-content/75 truncate text-xs font-medium", children: (A = e.metadata) != null && A.size ? Ue(e.metadata.size) : "--" }),
1583
+ /* @__PURE__ */ a("div", { className: "text-base-content/70 truncate text-xs", children: e.uploadedAt ? new Date(e.uploadedAt).toLocaleDateString() : "--" }),
1584
+ /* @__PURE__ */ a("div", { className: "text-base-content/70 truncate text-xs", children: t })
1585
+ ] });
1586
+ }
1587
+ const Et = "h-8", Ne = `tool-bg-flat ${Et} shrink-0 !items-stretch !justify-start !gap-0.5 !px-0 !py-0 text-neutral-content [&_button.tool-button]:h-full [&_button.tool-button]:min-h-0 [&_button.tool-button]:rounded-sm [&_button.tool-button]:px-1.5`;
1588
+ function ne({
1589
+ onClick: e,
1590
+ tooltip: t,
1591
+ children: i,
1592
+ active: l,
1593
+ disabled: r,
1594
+ className: n
1595
+ }) {
1596
+ return /* @__PURE__ */ a(
1597
+ "button",
1598
+ {
1599
+ type: "button",
1600
+ onClick: e,
1601
+ disabled: r,
1602
+ className: `tool-button flex h-full items-stretch px-2 ${l ? "bg-base-200 text-base-content" : ""} ${n || ""}`,
1603
+ "data-tooltip-id": ee,
1604
+ "data-tooltip-content": t,
1605
+ "data-tooltip-place": "bottom",
1606
+ "data-tooltip-offset": 10,
1607
+ children: i
1608
+ }
1609
+ );
1610
+ }
1611
+ function Ka({
1612
+ addMode: e,
1613
+ uploading: t,
1614
+ hasImageInClipboard: i,
1615
+ canUseImageGenerate: l,
1616
+ fileInputRef: r,
1617
+ setAddMode: n,
1618
+ handlePasteClick: c,
1619
+ onClose: m
1620
+ }) {
1621
+ const h = Yt(Ht);
1622
+ return /* @__PURE__ */ s("div", { className: `${Ne} order-2`, children: [
1623
+ /* @__PURE__ */ a(
1624
+ ne,
1625
+ {
1626
+ onClick: () => {
1627
+ var d;
1628
+ n("upload"), (d = r.current) == null || d.click();
1629
+ },
1630
+ disabled: t,
1631
+ active: e === "upload",
1632
+ tooltip: "Upload files",
1633
+ children: /* @__PURE__ */ a(et, { className: "size-4" })
1634
+ }
1635
+ ),
1636
+ /* @__PURE__ */ a("div", { className: "flex h-full min-h-0 w-[2.5rem] items-stretch md:w-full md:max-w-[8.5rem] [&_button.input-plain]:text-xs", children: /* @__PURE__ */ s(
1637
+ ye,
1638
+ {
1639
+ wrap: "control",
1640
+ propKey: "media-add-actions",
1641
+ tooltipId: ee,
1642
+ tooltipContent: "Add media actions",
1643
+ placeholder: /* @__PURE__ */ a(jt, { className: "size-4" }),
1644
+ value: "",
1645
+ onChange: (d) => {
1646
+ d === "url" && n("url"), d === "svg" && n("svg"), d === "ai" && l && (m(), h({
1647
+ revealPanel: !0,
1648
+ freshChat: !0,
1649
+ assistantScope: "media",
1650
+ mediaContext: { intent: "generate-image" },
1651
+ promptHint: "Generate a new image for my media library."
1652
+ })), d === "paste" && c();
1653
+ },
1654
+ children: [
1655
+ /* @__PURE__ */ a("option", { value: "url", children: "Add from URL" }),
1656
+ /* @__PURE__ */ a("option", { value: "svg", children: "Paste SVG" }),
1657
+ l && /* @__PURE__ */ a("option", { value: "ai", children: "Generate with AI" }),
1658
+ /* @__PURE__ */ a("option", { value: "paste", children: "Paste from clipboard" })
1659
+ ]
1660
+ }
1661
+ ) }),
1662
+ /* @__PURE__ */ a(
1663
+ ne,
1664
+ {
1665
+ onClick: c,
1666
+ disabled: !i || t,
1667
+ tooltip: i ? "Paste image from clipboard (Ctrl+V / Cmd+V)" : "No image in clipboard",
1668
+ children: /* @__PURE__ */ a(Gt, { className: "size-4" })
1669
+ }
1670
+ )
1671
+ ] });
1672
+ }
1673
+ function Ba({ inputRef: e, searchQuery: t, onSearch: i }) {
1674
+ return /* @__PURE__ */ a("div", { className: "mt-2", children: /* @__PURE__ */ s(
1675
+ "div",
1676
+ {
1677
+ className: `input-wrapper input-hover relative flex min-h-0 w-full items-center ${Et}`,
1678
+ children: [
1679
+ /* @__PURE__ */ a(at, { className: "text-neutral-content pointer-events-none absolute top-1/2 left-3 z-10 size-4 -translate-y-1/2" }),
1680
+ /* @__PURE__ */ a(
1681
+ "input",
1682
+ {
1683
+ ref: e,
1684
+ type: "text",
1685
+ value: t,
1686
+ onChange: (l) => i(l.target.value),
1687
+ placeholder: "Search media...",
1688
+ className: "input-plain-search h-full! min-h-0 pl-10"
1689
+ }
1690
+ )
1691
+ ]
1692
+ }
1693
+ ) });
1694
+ }
1695
+ function Oa({
1696
+ filteredCount: e,
1697
+ busy: t,
1698
+ canRenameOrDeleteFolder: i,
1699
+ onSelectVisible: l,
1700
+ onCreateFolder: r,
1701
+ onRenameFolder: n,
1702
+ onDeleteFolder: c
1703
+ }) {
1704
+ return /* @__PURE__ */ s("div", { className: `${Ne} order-2`, children: [
1705
+ e > 0 && /* @__PURE__ */ a(
1706
+ ne,
1707
+ {
1708
+ onClick: l,
1709
+ disabled: t,
1710
+ tooltip: "Select all items in current view",
1711
+ children: /* @__PURE__ */ a(Vt, { className: "size-4" })
1712
+ }
1713
+ ),
1714
+ /* @__PURE__ */ a(ne, { onClick: r, disabled: t, tooltip: "Create folder", children: /* @__PURE__ */ a(Wt, { className: "size-4" }) }),
1715
+ /* @__PURE__ */ a(
1716
+ ne,
1717
+ {
1718
+ onClick: n,
1719
+ disabled: !i || t,
1720
+ tooltip: "Rename selected folder tab",
1721
+ children: /* @__PURE__ */ a(Je, { className: "size-4" })
1722
+ }
1723
+ ),
1724
+ /* @__PURE__ */ a(
1725
+ ne,
1726
+ {
1727
+ onClick: c,
1728
+ disabled: !i || t,
1729
+ tooltip: "Delete selected folder tab",
1730
+ className: "text-error",
1731
+ children: /* @__PURE__ */ a(Mt, { className: "size-4" })
1732
+ }
1733
+ )
1734
+ ] });
1735
+ }
1736
+ function _a({
1737
+ fileInputRef: e,
1738
+ replaceInputRef: t,
1739
+ replaceAccept: i,
1740
+ handleUpload: l,
1741
+ handleReplaceMedia: r
1742
+ }) {
1743
+ return /* @__PURE__ */ s(se, { children: [
1744
+ /* @__PURE__ */ a(
1745
+ "input",
1746
+ {
1747
+ ref: e,
1748
+ type: "file",
1749
+ accept: lt(),
1750
+ multiple: !0,
1751
+ onChange: (n) => l(n.target.files),
1752
+ className: "hidden"
1753
+ }
1754
+ ),
1755
+ /* @__PURE__ */ a(
1756
+ "input",
1757
+ {
1758
+ ref: t,
1759
+ type: "file",
1760
+ accept: i,
1761
+ onChange: (n) => r(n.target.files),
1762
+ className: "hidden"
1763
+ }
1764
+ )
1765
+ ] });
1766
+ }
1767
+ function Qa({
1768
+ selectionMode: e,
1769
+ selectedCount: t,
1770
+ filteredCount: i,
1771
+ totalCount: l,
1772
+ searchQuery: r
1773
+ }) {
1774
+ return /* @__PURE__ */ a("div", { className: "text-neutral-content order-3 ml-auto shrink-0 text-[11px]", children: e ? `${i} ${i === 1 ? "item" : "items"}` : t > 0 ? `${t} selected` : r ? `${i} of ${l}` : `${i} ${i === 1 ? "item" : "items"}` });
1775
+ }
1776
+ function vt({
1777
+ total: e,
1778
+ counts: t
1779
+ }) {
1780
+ return /* @__PURE__ */ s(se, { children: [
1781
+ /* @__PURE__ */ s("option", { value: "all", children: [
1782
+ "All types (",
1783
+ e,
1784
+ ")"
1785
+ ] }),
1786
+ /* @__PURE__ */ s("option", { value: "image", children: [
1787
+ "Image (",
1788
+ t.image || 0,
1789
+ ")"
1790
+ ] }),
1791
+ /* @__PURE__ */ s("option", { value: "video", children: [
1792
+ "Video (",
1793
+ t.video || 0,
1794
+ ")"
1795
+ ] }),
1796
+ /* @__PURE__ */ s("option", { value: "audio", children: [
1797
+ "Audio (",
1798
+ t.audio || 0,
1799
+ ")"
1800
+ ] }),
1801
+ /* @__PURE__ */ s("option", { value: "pdf", children: [
1802
+ "PDF (",
1803
+ t.pdf || 0,
1804
+ ")"
1805
+ ] }),
1806
+ /* @__PURE__ */ s("option", { value: "archive", children: [
1807
+ "Archive (",
1808
+ t.archive || 0,
1809
+ ")"
1810
+ ] }),
1811
+ /* @__PURE__ */ s("option", { value: "other", children: [
1812
+ je.other,
1813
+ " (",
1814
+ t.other || 0,
1815
+ ")"
1816
+ ] })
1817
+ ] });
1818
+ }
1819
+ function Ya({ mediaList: e, kindCounts: t, onChange: i }) {
1820
+ return /* @__PURE__ */ s("div", { className: `${Ne} order-2 min-w-0`, children: [
1821
+ /* @__PURE__ */ a("div", { className: "hidden h-full min-h-0 items-stretch md:flex", children: /* @__PURE__ */ a(
1822
+ ye,
1823
+ {
1824
+ wrap: "control",
1825
+ propKey: "media-kind-filter",
1826
+ tooltipId: ee,
1827
+ tooltipContent: "Filter by media type",
1828
+ placeholder: /* @__PURE__ */ a(mt, { className: "size-4" }),
1829
+ value: "",
1830
+ onChange: (l) => i(l),
1831
+ children: /* @__PURE__ */ a(vt, { total: e.length, counts: t })
1832
+ }
1833
+ ) }),
1834
+ /* @__PURE__ */ a("div", { className: "flex h-full min-h-0 items-stretch md:hidden", children: /* @__PURE__ */ a(
1835
+ ye,
1836
+ {
1837
+ wrap: "control",
1838
+ propKey: "media-kind-filter-compact",
1839
+ tooltipId: ee,
1840
+ tooltipContent: "Filter by media type",
1841
+ placeholder: /* @__PURE__ */ a(mt, { className: "size-4" }),
1842
+ value: "",
1843
+ onChange: (l) => i(l),
1844
+ children: /* @__PURE__ */ a(vt, { total: e.length, counts: t })
1845
+ }
1846
+ ) })
1847
+ ] });
1848
+ }
1849
+ function ja({ showCompactSearch: e, hasSearchQuery: t, onToggle: i }) {
1850
+ return /* @__PURE__ */ a("div", { className: `${Ne} order-1`, children: /* @__PURE__ */ a(
1851
+ ne,
1852
+ {
1853
+ onClick: i,
1854
+ tooltip: "Search media",
1855
+ active: e || t,
1856
+ children: /* @__PURE__ */ a(at, { className: "size-4" })
1857
+ }
1858
+ ) });
1859
+ }
1860
+ function Ga({
1861
+ busy: e,
1862
+ folders: t,
1863
+ singleSelectedId: i,
1864
+ onMoveSelectedToFolder: l,
1865
+ onPreviewSingleSelected: r,
1866
+ onEditSingleSelected: n,
1867
+ onCropSingleSelected: c,
1868
+ onReplaceSingleSelected: m,
1869
+ onDeleteSelected: h,
1870
+ onClearSelection: d
1871
+ }) {
1872
+ return /* @__PURE__ */ s("div", { className: `${Ne} order-2`, children: [
1873
+ /* @__PURE__ */ s(
1874
+ ye,
1875
+ {
1876
+ wrap: "control",
1877
+ propKey: "media-move-selected",
1878
+ tooltipId: ee,
1879
+ tooltipContent: "Move selected items",
1880
+ placeholder: /* @__PURE__ */ a(tt, { className: "size-4" }),
1881
+ value: "",
1882
+ onChange: (p) => l(p === "unfiled" ? null : p),
1883
+ children: [
1884
+ /* @__PURE__ */ a("option", { value: "unfiled", children: "Move to Unfiled" }),
1885
+ t.map((p) => /* @__PURE__ */ s("option", { value: p.id, children: [
1886
+ "Move to ",
1887
+ p.name
1888
+ ] }, p.id))
1889
+ ]
1890
+ }
1891
+ ),
1892
+ i && /* @__PURE__ */ s(se, { children: [
1893
+ /* @__PURE__ */ a(
1894
+ ne,
1895
+ {
1896
+ onClick: r,
1897
+ disabled: e,
1898
+ tooltip: "Preview selected",
1899
+ children: /* @__PURE__ */ a(Nt, { className: "size-4" })
1900
+ }
1901
+ ),
1902
+ /* @__PURE__ */ a(
1903
+ ne,
1904
+ {
1905
+ onClick: n,
1906
+ disabled: e,
1907
+ tooltip: "Edit selected",
1908
+ children: /* @__PURE__ */ a(Je, { className: "size-4" })
1909
+ }
1910
+ ),
1911
+ /* @__PURE__ */ a(
1912
+ ne,
1913
+ {
1914
+ onClick: c,
1915
+ disabled: e,
1916
+ tooltip: "Crop selected",
1917
+ children: /* @__PURE__ */ a(Xt, { className: "size-4" })
1918
+ }
1919
+ ),
1920
+ /* @__PURE__ */ a(
1921
+ ne,
1922
+ {
1923
+ onClick: m,
1924
+ disabled: e,
1925
+ tooltip: "Replace selected",
1926
+ children: /* @__PURE__ */ a(qt, { className: "size-4" })
1927
+ }
1928
+ )
1929
+ ] }),
1930
+ /* @__PURE__ */ a(
1931
+ ne,
1932
+ {
1933
+ onClick: h,
1934
+ disabled: e,
1935
+ tooltip: "Delete selected",
1936
+ className: "text-error",
1937
+ children: /* @__PURE__ */ a(Mt, { className: "size-4" })
1938
+ }
1939
+ ),
1940
+ /* @__PURE__ */ a(ne, { onClick: d, disabled: e, tooltip: "Clear selection", children: /* @__PURE__ */ a(Fe, { className: "size-4" }) })
1941
+ ] });
1942
+ }
1943
+ const At = /* @__PURE__ */ s(se, { children: [
1944
+ /* @__PURE__ */ a("option", { value: "createdAt", children: "Date" }),
1945
+ /* @__PURE__ */ a("option", { value: "name", children: "Name" }),
1946
+ /* @__PURE__ */ a("option", { value: "size", children: "Size" }),
1947
+ /* @__PURE__ */ a("option", { value: "order", children: "Order" })
1948
+ ] });
1949
+ function Ha({
1950
+ sortField: e,
1951
+ sortDirection: t,
1952
+ onChangeSortField: i,
1953
+ onToggleDirection: l
1954
+ }) {
1955
+ const r = `${e} • ${t === "asc" ? "ascending" : "descending"}`, n = `Sort ${t === "asc" ? "ascending" : "descending"}`, c = t === "asc" ? Zt : Jt, m = (h) => /* @__PURE__ */ a(
1956
+ "button",
1957
+ {
1958
+ type: "button",
1959
+ onClick: l,
1960
+ className: "tool-button flex h-full items-stretch px-1.5",
1961
+ "data-tooltip-id": ee,
1962
+ "data-tooltip-content": h,
1963
+ "data-tooltip-place": "bottom",
1964
+ "data-tooltip-offset": 10,
1965
+ children: /* @__PURE__ */ a(c, { className: "size-3.5" })
1966
+ }
1967
+ );
1968
+ return /* @__PURE__ */ s("div", { className: `${Ne} order-2 min-w-0`, children: [
1969
+ /* @__PURE__ */ a("div", { className: "hidden h-full min-h-0 items-stretch md:flex", children: /* @__PURE__ */ a(
1970
+ ye,
1971
+ {
1972
+ wrap: "control",
1973
+ propKey: "media-sort-field",
1974
+ tooltipId: ee,
1975
+ tooltipContent: "Sort by",
1976
+ placeholder: /* @__PURE__ */ a(ht, { className: "size-4" }),
1977
+ value: "",
1978
+ onChange: (h) => i(h),
1979
+ append: m(r),
1980
+ children: At
1981
+ }
1982
+ ) }),
1983
+ /* @__PURE__ */ s("div", { className: "flex h-full min-h-0 items-stretch md:hidden", children: [
1984
+ /* @__PURE__ */ a(
1985
+ ye,
1986
+ {
1987
+ wrap: "control",
1988
+ propKey: "media-sort-field-compact",
1989
+ tooltipId: ee,
1990
+ tooltipContent: "Sort by",
1991
+ placeholder: /* @__PURE__ */ a(ht, { className: "size-4" }),
1992
+ value: "",
1993
+ onChange: (h) => i(h),
1994
+ children: At
1995
+ }
1996
+ ),
1997
+ m(n)
1998
+ ] })
1999
+ ] });
2000
+ }
2001
+ function Va({ svgInput: e, setSvgInput: t, handleAddSvg: i }) {
2002
+ return /* @__PURE__ */ s("div", { className: "mt-2", children: [
2003
+ /* @__PURE__ */ s("div", { className: "flex gap-2", children: [
2004
+ /* @__PURE__ */ a(
2005
+ "textarea",
2006
+ {
2007
+ value: e,
2008
+ onChange: (l) => t(l.target.value),
2009
+ placeholder: "<svg>...</svg>",
2010
+ className: "input-dialog placeholder:text-neutral-content min-h-[4.5rem] flex-1 resize-none font-mono text-xs",
2011
+ rows: 3,
2012
+ autoFocus: !0
2013
+ }
2014
+ ),
2015
+ /* @__PURE__ */ a(
2016
+ "button",
2017
+ {
2018
+ type: "button",
2019
+ onClick: i,
2020
+ disabled: !e.trim(),
2021
+ className: "btn btn-primary text-sm!",
2022
+ children: "Add"
2023
+ }
2024
+ )
2025
+ ] }),
2026
+ /* @__PURE__ */ s("p", { className: "text-neutral-content mt-1.5 ml-0.5 text-xs", children: [
2027
+ "Find SVGs @",
2028
+ " ",
2029
+ /* @__PURE__ */ a(
2030
+ "a",
2031
+ {
2032
+ href: "https://www.svgrepo.com/",
2033
+ target: "_blank",
2034
+ rel: "noopener noreferrer",
2035
+ className: "text-primary hover:text-primary underline",
2036
+ children: "svgrepo.com"
2037
+ }
2038
+ )
2039
+ ] })
2040
+ ] });
2041
+ }
2042
+ function Wa({
2043
+ urlInput: e,
2044
+ saveUrlToCdn: t,
2045
+ uploading: i,
2046
+ setUrlInput: l,
2047
+ setSaveUrlToCdn: r,
2048
+ handleAddUrl: n
2049
+ }) {
2050
+ return /* @__PURE__ */ s("div", { className: "mt-2", children: [
2051
+ /* @__PURE__ */ s("div", { className: "flex gap-2", children: [
2052
+ /* @__PURE__ */ a(
2053
+ "input",
2054
+ {
2055
+ type: "text",
2056
+ value: e,
2057
+ onChange: (c) => l(c.target.value),
2058
+ placeholder: "https://example.com/image.jpg",
2059
+ className: "input-dialog placeholder:text-neutral-content flex-1",
2060
+ onKeyDown: (c) => c.key === "Enter" && n(),
2061
+ autoFocus: !0
2062
+ }
2063
+ ),
2064
+ /* @__PURE__ */ a(
2065
+ "button",
2066
+ {
2067
+ type: "button",
2068
+ onClick: n,
2069
+ disabled: !e.trim() || i,
2070
+ className: "btn btn-primary text-sm!",
2071
+ children: "Add"
2072
+ }
2073
+ )
2074
+ ] }),
2075
+ /* @__PURE__ */ s("div", { className: "mt-2 flex items-center gap-2", children: [
2076
+ /* @__PURE__ */ a(
2077
+ "input",
2078
+ {
2079
+ type: "checkbox",
2080
+ id: "saveUrlToCdn",
2081
+ checked: t,
2082
+ onChange: (c) => r(c.target.checked),
2083
+ className: "border-base-300 bg-neutral text-accent focus:ring-ring size-4 rounded-lg"
2084
+ }
2085
+ ),
2086
+ /* @__PURE__ */ a("label", { htmlFor: "saveUrlToCdn", className: "text-neutral-content text-xs", children: "Save to CDN (downloads image to your account)" })
2087
+ ] }),
2088
+ /* @__PURE__ */ s("div", { className: "text-neutral-content mt-2 text-xs", children: [
2089
+ /* @__PURE__ */ a(Xe, { className: "mr-1 inline" }),
2090
+ " Tip: You can also paste images directly (Ctrl+V / Cmd+V) or use the clipboard button above!"
2091
+ ] })
2092
+ ] });
2093
+ }
2094
+ function Xa(e) {
2095
+ const [t, i] = S(!1), l = le(null);
2096
+ return re(() => {
2097
+ var r;
2098
+ t && ((r = l.current) == null || r.focus());
2099
+ }, [t]), re(() => {
2100
+ if (!t) return;
2101
+ const r = (n) => {
2102
+ var m;
2103
+ const c = n.target;
2104
+ c && ((m = e.current) != null && m.contains(c) || i(!1));
2105
+ };
2106
+ return document.addEventListener("mousedown", r), () => {
2107
+ document.removeEventListener("mousedown", r);
2108
+ };
2109
+ }, [t, e]), qe({
2110
+ id: "media-compact-search",
2111
+ isOpen: t,
2112
+ onDismiss: () => i(!1)
2113
+ }), { showCompactSearch: t, setShowCompactSearch: i, compactSearchInputRef: l };
2114
+ }
2115
+ function qa({ viewMode: e, setViewMode: t }) {
2116
+ return /* @__PURE__ */ s("div", { className: `${Ne} order-2`, children: [
2117
+ /* @__PURE__ */ a(
2118
+ ne,
2119
+ {
2120
+ onClick: () => t("cards"),
2121
+ tooltip: "Card view",
2122
+ active: e === "cards",
2123
+ children: /* @__PURE__ */ a(ea, { className: "size-4" })
2124
+ }
2125
+ ),
2126
+ /* @__PURE__ */ a(
2127
+ ne,
2128
+ {
2129
+ onClick: () => t("list"),
2130
+ tooltip: "List view",
2131
+ active: e === "list",
2132
+ children: /* @__PURE__ */ a(ta, { className: "size-4" })
2133
+ }
2134
+ )
2135
+ ] });
2136
+ }
2137
+ function Za({
2138
+ manager: e,
2139
+ selectionMode: t,
2140
+ filteredCount: i,
2141
+ totalCount: l,
2142
+ selectedCount: r,
2143
+ busy: n,
2144
+ canRenameOrDeleteFolder: c,
2145
+ onSelectVisible: m,
2146
+ onCreateFolder: h,
2147
+ onRenameFolder: d,
2148
+ onDeleteFolder: p,
2149
+ folders: f,
2150
+ singleSelectedId: u,
2151
+ onMoveSelectedToFolder: C,
2152
+ onPreviewSingleSelected: o,
2153
+ onEditSingleSelected: x,
2154
+ onCropSingleSelected: A,
2155
+ onReplaceSingleSelected: y,
2156
+ onDeleteSelected: g,
2157
+ onClearSelection: b
2158
+ }) {
2159
+ const {
2160
+ searchQuery: v,
2161
+ viewMode: k,
2162
+ sortField: M,
2163
+ sortDirection: z,
2164
+ addMode: $,
2165
+ urlInput: _,
2166
+ svgInput: B,
2167
+ saveUrlToCdn: H,
2168
+ hasImageInClipboard: V,
2169
+ uploading: W,
2170
+ canUseImageGenerate: te,
2171
+ toolbarRef: Z,
2172
+ fileInputRef: de,
2173
+ replaceInputRef: fe,
2174
+ mediaList: oe,
2175
+ replacingMedia: ce,
2176
+ setViewMode: O,
2177
+ setSortField: Ce,
2178
+ setSortDirection: Se,
2179
+ setKindFilter: F,
2180
+ setAddMode: w,
2181
+ setUrlInput: D,
2182
+ setSvgInput: R,
2183
+ setSaveUrlToCdn: T,
2184
+ handleSearch: E,
2185
+ handleUpload: Q,
2186
+ handleAddUrl: L,
2187
+ handleAddSvg: U,
2188
+ handlePasteClick: Y,
2189
+ handleReplaceMedia: ue,
2190
+ resortFilteredMedia: X,
2191
+ onClose: me
2192
+ } = e, { showCompactSearch: Ee, setShowCompactSearch: he, compactSearchInputRef: Te } = Xa(Z), Pe = ce ? oe.find((ae) => ae.id === ce) : null, Ge = Pe ? kt(Pe) : lt(), Le = Ie(
2193
+ () => oe.reduce(
2194
+ (ae, He) => {
2195
+ const $e = De(He);
2196
+ return ae[$e] = (ae[$e] || 0) + 1, ae;
2197
+ },
2198
+ {}
2199
+ ),
2200
+ [oe]
2201
+ );
2202
+ return /* @__PURE__ */ s("div", { ref: Z, className: "border-base-300 bg-neutral border-b px-3 py-1", children: [
2203
+ /* @__PURE__ */ a("div", { children: /* @__PURE__ */ s("div", { className: "flex w-full min-w-0 items-center gap-1", children: [
2204
+ /* @__PURE__ */ a(
2205
+ ja,
2206
+ {
2207
+ showCompactSearch: Ee,
2208
+ hasSearchQuery: !!v,
2209
+ onToggle: () => he((ae) => !ae)
2210
+ }
2211
+ ),
2212
+ /* @__PURE__ */ a(qa, { viewMode: k, setViewMode: O }),
2213
+ /* @__PURE__ */ a(
2214
+ Ha,
2215
+ {
2216
+ sortField: M,
2217
+ sortDirection: z,
2218
+ onChangeSortField: (ae) => {
2219
+ Ce(ae), X({ sortField: ae });
2220
+ },
2221
+ onToggleDirection: () => {
2222
+ const ae = z === "asc" ? "desc" : "asc";
2223
+ Se(ae), X({ sortDirection: ae });
2224
+ }
2225
+ }
2226
+ ),
2227
+ /* @__PURE__ */ a(
2228
+ Ya,
2229
+ {
2230
+ mediaList: oe,
2231
+ kindCounts: Le,
2232
+ onChange: F
2233
+ }
2234
+ ),
2235
+ /* @__PURE__ */ a(
2236
+ Ka,
2237
+ {
2238
+ addMode: $,
2239
+ uploading: W,
2240
+ hasImageInClipboard: V,
2241
+ canUseImageGenerate: te,
2242
+ fileInputRef: de,
2243
+ setAddMode: w,
2244
+ handlePasteClick: Y,
2245
+ onClose: me
2246
+ }
2247
+ ),
2248
+ !t && /* @__PURE__ */ a(
2249
+ Oa,
2250
+ {
2251
+ filteredCount: i,
2252
+ busy: n,
2253
+ canRenameOrDeleteFolder: c,
2254
+ onSelectVisible: m,
2255
+ onCreateFolder: h,
2256
+ onRenameFolder: d,
2257
+ onDeleteFolder: p
2258
+ }
2259
+ ),
2260
+ !t && r > 0 && /* @__PURE__ */ a(
2261
+ Ga,
2262
+ {
2263
+ busy: n,
2264
+ folders: f,
2265
+ singleSelectedId: u,
2266
+ onMoveSelectedToFolder: C,
2267
+ onPreviewSingleSelected: o,
2268
+ onEditSingleSelected: x,
2269
+ onCropSingleSelected: A,
2270
+ onReplaceSingleSelected: y,
2271
+ onDeleteSelected: g,
2272
+ onClearSelection: b
2273
+ }
2274
+ ),
2275
+ /* @__PURE__ */ a(
2276
+ Qa,
2277
+ {
2278
+ selectionMode: t,
2279
+ selectedCount: r,
2280
+ filteredCount: i,
2281
+ totalCount: l,
2282
+ searchQuery: v
2283
+ }
2284
+ )
2285
+ ] }) }),
2286
+ Ee && /* @__PURE__ */ a(
2287
+ Ba,
2288
+ {
2289
+ inputRef: Te,
2290
+ searchQuery: v,
2291
+ onSearch: E
2292
+ }
2293
+ ),
2294
+ $ === "url" && /* @__PURE__ */ a(
2295
+ Wa,
2296
+ {
2297
+ urlInput: _,
2298
+ saveUrlToCdn: H,
2299
+ uploading: W,
2300
+ setUrlInput: D,
2301
+ setSaveUrlToCdn: T,
2302
+ handleAddUrl: L
2303
+ }
2304
+ ),
2305
+ $ === "svg" && /* @__PURE__ */ a(Va, { svgInput: B, setSvgInput: R, handleAddSvg: U }),
2306
+ /* @__PURE__ */ a(
2307
+ _a,
2308
+ {
2309
+ fileInputRef: de,
2310
+ replaceInputRef: fe,
2311
+ replaceAccept: Ge,
2312
+ handleUpload: Q,
2313
+ handleReplaceMedia: ue
2314
+ }
2315
+ )
2316
+ ] });
2317
+ }
2318
+ function En({
2319
+ manager: e,
2320
+ selectionMode: t,
2321
+ onSelect: i,
2322
+ onClose: l,
2323
+ popover: r
2324
+ }) {
2325
+ const [n, c] = S(null), [m, h] = S(""), [d, p] = S(!1), f = Ie(
2326
+ () => e.mediaList.filter((M) => e.selectedMediaIds.includes(M.id)),
2327
+ [e.mediaList, e.selectedMediaIds]
2328
+ ), u = f.length === 1 ? f[0] : null, C = e.uploading || e.savingMetadata === "saving" || e.deletingMedia.length > 0, o = e.folderFilter !== "all" && e.folderFilter !== "unfiled" && e.folders.find((M) => M.id === e.folderFilter) || null, x = (M) => {
2329
+ e.setReplacingMedia(M);
2330
+ const z = e.mediaList.find((_) => _.id === M), $ = e.replaceInputRef.current;
2331
+ $ && ($.accept = z ? kt(z) : "*/*", $.click());
2332
+ }, A = () => {
2333
+ c("create"), h("");
2334
+ }, y = () => {
2335
+ o && (c("rename"), h(o.name));
2336
+ }, g = () => {
2337
+ o && p(!0);
2338
+ }, b = () => {
2339
+ const M = m.trim();
2340
+ if (M) {
2341
+ if (n === "create") {
2342
+ const z = e.createFolder(M);
2343
+ z && e.setFolderFilter(z.id);
2344
+ } else n === "rename" && o && e.renameFolder(o.id, M);
2345
+ c(null), h("");
2346
+ }
2347
+ }, v = () => {
2348
+ c(null), h("");
2349
+ }, k = () => {
2350
+ o && (e.deleteFolder(o.id), p(!1));
2351
+ };
2352
+ return /* @__PURE__ */ s(se, { children: [
2353
+ /* @__PURE__ */ s(
2354
+ "div",
2355
+ {
2356
+ className: r ? "flex min-h-0 flex-1 flex-col overflow-hidden" : "-mx-6 -my-6 flex min-h-0 flex-1 flex-col overflow-hidden",
2357
+ children: [
2358
+ e.uploadError && /* @__PURE__ */ a("div", { className: "border-error bg-error/10 border-b px-6 py-3", children: /* @__PURE__ */ s("div", { className: "flex items-start gap-3", children: [
2359
+ /* @__PURE__ */ a(ze, { className: "text-error mt-0.5 size-5 shrink-0" }),
2360
+ /* @__PURE__ */ a("div", { className: "flex-1", children: /* @__PURE__ */ a("p", { className: "text-error text-sm whitespace-pre-line", children: e.uploadError }) }),
2361
+ /* @__PURE__ */ a(
2362
+ "button",
2363
+ {
2364
+ onClick: () => e.setUploadError(null),
2365
+ className: "hover:bg-error/20 shrink-0 rounded p-1 transition-colors",
2366
+ children: /* @__PURE__ */ a(Fe, { className: "text-error size-4" })
2367
+ }
2368
+ )
2369
+ ] }) }),
2370
+ r && /* @__PURE__ */ s("div", { className: "border-base-300 bg-neutral flex items-center gap-2 border-b px-3 py-1.5", children: [
2371
+ /* @__PURE__ */ a("span", { className: "text-neutral-content shrink-0 text-[11px]", children: "Folder" }),
2372
+ /* @__PURE__ */ a("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ s(
2373
+ ye,
2374
+ {
2375
+ wrap: "control",
2376
+ propKey: "media-folder-filter-popover",
2377
+ placeholder: /* @__PURE__ */ a(tt, { className: "size-3.5" }),
2378
+ value: e.folderFilter,
2379
+ onChange: (M) => e.setFolderFilter(M),
2380
+ children: [
2381
+ /* @__PURE__ */ s("option", { value: "all", children: [
2382
+ "All (",
2383
+ e.folderCounts.all,
2384
+ ")"
2385
+ ] }),
2386
+ /* @__PURE__ */ s("option", { value: "unfiled", children: [
2387
+ "Unfiled (",
2388
+ e.folderCounts.unfiled,
2389
+ ")"
2390
+ ] }),
2391
+ e.folders.map((M) => /* @__PURE__ */ s("option", { value: M.id, children: [
2392
+ M.name,
2393
+ " (",
2394
+ e.folderCounts.byId.get(M.id) || 0,
2395
+ ")"
2396
+ ] }, M.id))
2397
+ ]
2398
+ }
2399
+ ) })
2400
+ ] }),
2401
+ /* @__PURE__ */ a(
2402
+ Za,
2403
+ {
2404
+ manager: e,
2405
+ selectionMode: t,
2406
+ filteredCount: e.filteredMedia.length,
2407
+ totalCount: e.mediaList.length,
2408
+ selectedCount: e.selectedMediaIds.length,
2409
+ busy: C,
2410
+ canRenameOrDeleteFolder: !!o,
2411
+ onSelectVisible: e.selectAllVisible,
2412
+ onCreateFolder: A,
2413
+ onRenameFolder: y,
2414
+ onDeleteFolder: g,
2415
+ folders: e.folders,
2416
+ singleSelectedId: (u == null ? void 0 : u.id) ?? null,
2417
+ onMoveSelectedToFolder: e.moveSelectedToFolder,
2418
+ onPreviewSingleSelected: () => u && e.setPreviewMedia(u.id),
2419
+ onEditSingleSelected: () => u && e.openEditModal(u),
2420
+ onCropSingleSelected: () => u && e.setCropMedia(u),
2421
+ onReplaceSingleSelected: () => u && x(u.id),
2422
+ onDeleteSelected: e.handleDeleteSelected,
2423
+ onClearSelection: e.clearSelection
2424
+ }
2425
+ ),
2426
+ n && !t && /* @__PURE__ */ s("div", { className: "border-base-300 bg-base-100 flex items-center gap-2 border-b px-3 py-2", children: [
2427
+ /* @__PURE__ */ a("div", { className: "input-wrapper input-hover relative flex h-8 min-h-0 flex-1 items-center", children: /* @__PURE__ */ a(
2428
+ "input",
2429
+ {
2430
+ type: "text",
2431
+ value: m,
2432
+ onChange: (M) => h(M.target.value),
2433
+ placeholder: n === "create" ? "New folder name" : "Rename folder",
2434
+ className: "input-plain-search h-full! min-h-0 px-3",
2435
+ autoFocus: !0,
2436
+ onKeyDown: (M) => {
2437
+ M.key === "Enter" && b(), M.key === "Escape" && v();
2438
+ }
2439
+ }
2440
+ ) }),
2441
+ /* @__PURE__ */ a(
2442
+ "button",
2443
+ {
2444
+ type: "button",
2445
+ onClick: b,
2446
+ disabled: !m.trim() || C,
2447
+ className: "btn btn-primary btn-sm",
2448
+ children: n === "create" ? "Create" : "Save"
2449
+ }
2450
+ ),
2451
+ /* @__PURE__ */ a(
2452
+ "button",
2453
+ {
2454
+ type: "button",
2455
+ onClick: v,
2456
+ disabled: C,
2457
+ className: "btn btn-ghost btn-sm",
2458
+ children: "Cancel"
2459
+ }
2460
+ )
2461
+ ] }),
2462
+ /* @__PURE__ */ a("div", { className: "min-h-0 min-w-0 flex-1", children: /* @__PURE__ */ a(
2463
+ Ra,
2464
+ {
2465
+ filteredMedia: e.filteredMedia,
2466
+ viewMode: e.viewMode,
2467
+ sortField: e.sortField,
2468
+ selectedMedia: e.selectedMedia,
2469
+ selectedMediaIds: e.selectedMediaIds,
2470
+ deletingMedia: e.deletingMedia,
2471
+ searchQuery: e.searchQuery,
2472
+ uploadProgress: e.uploadProgress,
2473
+ isDragOver: e.isDragOver,
2474
+ dropProps: e.dropProps,
2475
+ selectionMode: t,
2476
+ onSelect: i,
2477
+ onClose: l,
2478
+ onItemSelect: e.handleMediaSelection,
2479
+ onPreview: (M) => e.setPreviewMedia(M),
2480
+ onSetAddMode: e.setAddMode,
2481
+ folderNameById: e.folderNameById,
2482
+ fileInputRef: e.fileInputRef
2483
+ }
2484
+ ) })
2485
+ ]
2486
+ }
2487
+ ),
2488
+ e.editingMedia && /* @__PURE__ */ a(
2489
+ Ea,
2490
+ {
2491
+ editingMedia: e.editingMedia,
2492
+ savingMetadata: e.savingMetadata,
2493
+ canUseImageAnalyze: e.canUseImageAnalyze,
2494
+ mediaEditAiActionsContext: e.mediaEditAiActionsContext,
2495
+ onClose: e.closeEditModal,
2496
+ onSave: e.saveEditedMetadata,
2497
+ onUpdate: e.setEditingMedia
2498
+ }
2499
+ ),
2500
+ /* @__PURE__ */ a(
2501
+ ya,
2502
+ {
2503
+ isOpen: d,
2504
+ onClose: () => p(!1),
2505
+ onConfirm: k,
2506
+ title: "Delete Folder",
2507
+ message: o ? `Delete folder "${o.name}"? Items will be moved to Unfiled.` : "Delete this folder? Items will be moved to Unfiled.",
2508
+ confirmText: "Delete Folder",
2509
+ cancelText: "Cancel",
2510
+ variant: "danger"
2511
+ },
2512
+ "delete-folder-confirm-dialog"
2513
+ )
2514
+ ] });
2515
+ }
2516
+ function Tn({
2517
+ previewMedia: e,
2518
+ filteredMedia: t,
2519
+ onClose: i,
2520
+ onPrevious: l,
2521
+ onNext: r
2522
+ }) {
2523
+ var u, C, o, x, A, y, g, b, v, k, M, z, $, _, B, H, V, W, te, Z, de, fe, oe, ce;
2524
+ if (!e) return null;
2525
+ const n = t.find((O) => O.id === e);
2526
+ if (!n) return null;
2527
+ const c = t.findIndex((O) => O.id === e), m = c > 0, h = c < t.length - 1, d = De(n), p = n.type === "r2" ? (u = n.metadata) == null ? void 0 : u.deliveryURL : n.type === "url" ? (C = n.metadata) == null ? void 0 : C.url : d === "image" ? ge(n.cdnId || n.id, { width: 2048, format: "auto" }) : void 0, f = ((o = n.metadata) == null ? void 0 : o.title) || n.id;
2528
+ return Qe.createPortal(
2529
+ /* @__PURE__ */ s(
2530
+ "div",
2531
+ {
2532
+ className: "animate-backdrop-in fixed inset-0 flex items-center justify-center bg-black/90 backdrop-blur-sm",
2533
+ style: { zIndex: Ye },
2534
+ onClick: i,
2535
+ children: [
2536
+ /* @__PURE__ */ s("div", { className: "absolute top-4 right-4 z-10 flex items-center gap-2", children: [
2537
+ /* @__PURE__ */ a(Ja, { mediaId: n.id }),
2538
+ p && /* @__PURE__ */ a(
2539
+ "a",
2540
+ {
2541
+ href: p,
2542
+ download: f,
2543
+ target: "_blank",
2544
+ rel: "noopener noreferrer",
2545
+ onClick: (O) => O.stopPropagation(),
2546
+ className: "rounded-lg bg-white/10 p-2 text-white transition-colors hover:bg-white/20",
2547
+ "data-tooltip-id": ee,
2548
+ "data-tooltip-content": "Download",
2549
+ children: /* @__PURE__ */ a(aa, { className: "size-6" })
2550
+ }
2551
+ ),
2552
+ /* @__PURE__ */ a(
2553
+ "button",
2554
+ {
2555
+ onClick: i,
2556
+ className: "rounded-lg bg-white/10 p-2 text-white transition-colors hover:bg-white/20",
2557
+ "data-tooltip-id": ee,
2558
+ "data-tooltip-content": "Close (ESC)",
2559
+ children: /* @__PURE__ */ a(Fe, { className: "size-6" })
2560
+ }
2561
+ )
2562
+ ] }),
2563
+ m && /* @__PURE__ */ a(
2564
+ "button",
2565
+ {
2566
+ onClick: (O) => {
2567
+ O.stopPropagation(), l();
2568
+ },
2569
+ className: "absolute top-1/2 left-4 z-10 -translate-y-1/2 rounded-lg bg-white/10 p-3 text-white transition-colors hover:bg-white/20",
2570
+ "data-tooltip-id": ee,
2571
+ "data-tooltip-content": "Previous (←)",
2572
+ children: /* @__PURE__ */ a(na, { className: "size-8" })
2573
+ }
2574
+ ),
2575
+ h && /* @__PURE__ */ a(
2576
+ "button",
2577
+ {
2578
+ onClick: (O) => {
2579
+ O.stopPropagation(), r();
2580
+ },
2581
+ className: "absolute top-1/2 right-4 z-10 -translate-y-1/2 rounded-lg bg-white/10 p-3 text-white transition-colors hover:bg-white/20",
2582
+ "data-tooltip-id": ee,
2583
+ "data-tooltip-content": "Next (→)",
2584
+ children: /* @__PURE__ */ a(ra, { className: "size-8" })
2585
+ }
2586
+ ),
2587
+ /* @__PURE__ */ s(
2588
+ "div",
2589
+ {
2590
+ role: "button",
2591
+ tabIndex: 0,
2592
+ className: "relative max-h-[90vh] max-w-[90vw]",
2593
+ onClick: (O) => O.stopPropagation(),
2594
+ onKeyDown: (O) => {
2595
+ (O.key === "Enter" || O.key === " ") && (O.preventDefault(), O.stopPropagation());
2596
+ },
2597
+ children: [
2598
+ n.type === "svg" ? /* @__PURE__ */ a(
2599
+ "div",
2600
+ {
2601
+ className: "flex max-h-[90vh] max-w-[90vw] items-center justify-center bg-white/5 p-8 backdrop-blur-sm",
2602
+ dangerouslySetInnerHTML: { __html: ((x = n.metadata) == null ? void 0 : x.svg) || "" }
2603
+ }
2604
+ ) : d === "video" && ((A = n.metadata) != null && A.deliveryURL) ? /* @__PURE__ */ a(
2605
+ "video",
2606
+ {
2607
+ src: n.metadata.deliveryURL,
2608
+ controls: !0,
2609
+ playsInline: !0,
2610
+ className: "max-h-[90vh] max-w-[90vw]"
2611
+ }
2612
+ ) : d === "audio" && ((y = n.metadata) != null && y.deliveryURL) ? /* @__PURE__ */ s("div", { className: "flex max-w-[90vw] flex-col items-center gap-4 rounded-lg bg-white/5 p-8 backdrop-blur-sm", children: [
2613
+ /* @__PURE__ */ a("p", { className: "text-sm text-white/80", children: ((g = n.metadata) == null ? void 0 : g.title) || n.id }),
2614
+ /* @__PURE__ */ a("audio", { src: n.metadata.deliveryURL, controls: !0, className: "min-w-[400px]" })
2615
+ ] }) : d === "pdf" && ((b = n.metadata) != null && b.deliveryURL) ? /* @__PURE__ */ a(
2616
+ "iframe",
2617
+ {
2618
+ src: n.metadata.deliveryURL,
2619
+ title: ((v = n.metadata) == null ? void 0 : v.title) || n.id,
2620
+ className: "h-[90vh] w-[90vw] bg-white"
2621
+ }
2622
+ ) : d !== "image" ? /* @__PURE__ */ s("div", { className: "flex max-w-[90vw] flex-col items-center gap-4 rounded-lg bg-white/5 p-12 text-center backdrop-blur-sm", children: [
2623
+ /* @__PURE__ */ a("p", { className: "text-lg text-white", children: ((k = n.metadata) == null ? void 0 : k.title) || n.id }),
2624
+ /* @__PURE__ */ s("p", { className: "text-sm text-white/60", children: [
2625
+ ((M = n.metadata) == null ? void 0 : M.contentType) || "file",
2626
+ " —",
2627
+ " ",
2628
+ (z = n.metadata) != null && z.size ? Ue(n.metadata.size) : "unknown size"
2629
+ ] }),
2630
+ p && /* @__PURE__ */ a(
2631
+ "a",
2632
+ {
2633
+ href: p,
2634
+ download: f,
2635
+ target: "_blank",
2636
+ rel: "noopener noreferrer",
2637
+ onClick: (O) => O.stopPropagation(),
2638
+ className: "btn btn-primary",
2639
+ children: "Download"
2640
+ }
2641
+ )
2642
+ ] }) : /* @__PURE__ */ a("div", { className: "relative max-h-[90vh] max-w-[90vw]", children: /* @__PURE__ */ a(
2643
+ ke,
2644
+ {
2645
+ src: n.type === "url" ? ($ = n.metadata) == null ? void 0 : $.url : ge(n.cdnId || n.id, { width: 2e3, format: "auto" }),
2646
+ alt: ((_ = n.metadata) == null ? void 0 : _.alt) || ((B = n.metadata) == null ? void 0 : B.title) || n.id,
2647
+ width: ((V = (H = n.metadata) == null ? void 0 : H.dimensions) == null ? void 0 : V.width) || 1200,
2648
+ height: ((te = (W = n.metadata) == null ? void 0 : W.dimensions) == null ? void 0 : te.height) || 800,
2649
+ className: "max-h-[90vh] max-w-[90vw] object-contain",
2650
+ quality: 90
2651
+ }
2652
+ ) }),
2653
+ (d === "image" || n.type === "svg") && /* @__PURE__ */ s("div", { className: "absolute inset-x-0 bottom-0 bg-linear-to-t from-black/80 to-transparent p-4 text-white", children: [
2654
+ /* @__PURE__ */ a("h3", { className: "text-lg font-semibold", children: ((Z = n.metadata) == null ? void 0 : Z.title) || n.id }),
2655
+ ((de = n.metadata) == null ? void 0 : de.description) && /* @__PURE__ */ a("p", { className: "mt-1 text-sm text-white/80", children: n.metadata.description }),
2656
+ /* @__PURE__ */ s("div", { className: "mt-2 flex flex-wrap gap-4 text-xs text-white/60", children: [
2657
+ ((fe = n.metadata) == null ? void 0 : fe.dimensions) && /* @__PURE__ */ a("span", { children: it(n.metadata.dimensions) }),
2658
+ ((oe = n.metadata) == null ? void 0 : oe.size) && /* @__PURE__ */ a("span", { children: Ue(n.metadata.size) }),
2659
+ ((ce = n.metadata) == null ? void 0 : ce.contentType) && /* @__PURE__ */ a("span", { children: n.metadata.contentType }),
2660
+ n.uploadedAt && /* @__PURE__ */ a("span", { children: new Date(n.uploadedAt).toLocaleDateString() }),
2661
+ /* @__PURE__ */ s("span", { children: [
2662
+ c + 1,
2663
+ " / ",
2664
+ t.length
2665
+ ] })
2666
+ ] })
2667
+ ] })
2668
+ ]
2669
+ }
2670
+ )
2671
+ ]
2672
+ }
2673
+ ),
2674
+ document.querySelector(".pagehub-sdk-root") || document.body
2675
+ );
2676
+ }
2677
+ function Ja({ mediaId: e }) {
2678
+ const [t, i] = S(!1);
2679
+ return /* @__PURE__ */ a(
2680
+ "button",
2681
+ {
2682
+ onClick: (r) => {
2683
+ r.stopPropagation(), navigator.clipboard.writeText(e).then(() => {
2684
+ i(!0), setTimeout(() => i(!1), 1500);
2685
+ });
2686
+ },
2687
+ className: "rounded-lg bg-white/10 p-2 text-white transition-colors hover:bg-white/20",
2688
+ title: t ? "Copied!" : "Copy media ID",
2689
+ children: /* @__PURE__ */ a(ia, { className: "size-6" })
2690
+ }
2691
+ );
2692
+ }
2693
+ function en({
2694
+ refreshMediaList: e,
2695
+ generateMetadataForImage: t,
2696
+ setUploading: i
2697
+ }) {
2698
+ const { query: l, actions: r } = rt(), [n, c] = S(""), [m, h] = S(!1), [d, p] = S(!1), [f, u] = S(""), [C, o] = S(""), [x, A] = S(""), [y, g] = S(null), [b, v] = S(null), [k, M] = S(null), [z, $] = S("gpt-image-1"), [_, B] = S(100), [H, V] = S({ x: 0, y: 0 }), [W, te] = S(!1), [Z, de] = S({ x: 0, y: 0 });
2699
+ return {
2700
+ aiPrompt: n,
2701
+ aiModel: z,
2702
+ aiImagePreview: y,
2703
+ aiOptimizedPrompt: b,
2704
+ aiClaudeUsage: k,
2705
+ aiImageScale: _,
2706
+ aiImagePosition: H,
2707
+ aiError: f,
2708
+ metadataError: C,
2709
+ aiSuccess: x,
2710
+ isGeneratingAi: m,
2711
+ isDragging: W,
2712
+ isGeneratingMetadata: d,
2713
+ setAiPrompt: c,
2714
+ setAiModel: $,
2715
+ setAiImageScale: B,
2716
+ setAiError: u,
2717
+ setMetadataError: o,
2718
+ setAiSuccess: A,
2719
+ setIsGeneratingAi: h,
2720
+ setIsGeneratingMetadata: p,
2721
+ applyGeneratedImage: ({
2722
+ imageUrl: w,
2723
+ optimizedPrompt: D,
2724
+ usage: R
2725
+ }) => {
2726
+ g(w), v(D ?? null), M(R ?? null);
2727
+ },
2728
+ handleSaveAiImage: async (w) => {
2729
+ const D = (w == null ? void 0 : w.imageUrl) ?? y, R = ((w == null ? void 0 : w.prompt) ?? n).trim();
2730
+ if (D) {
2731
+ i(!0);
2732
+ try {
2733
+ const E = await (await fetch(D)).blob(), Q = new File([E], `ai-generated-${Date.now()}.png`, { type: "image/png" }), { mediaId: L, file: U, width: Y, height: ue } = await Me(Q);
2734
+ Ae(l, r, L, "cdn", "media-manager"), r.setProp(q, (me) => {
2735
+ const he = (me.pageMedia || []).find((Te) => Te.id === L);
2736
+ he && (he.metadata = {
2737
+ ...he.metadata,
2738
+ title: R ? `AI Generated: ${R}` : "AI Generated Image",
2739
+ alt: R || "AI generated image",
2740
+ size: U.size,
2741
+ ...Y && ue ? { dimensions: { width: Y, height: ue, aspectRatio: Y / ue } } : {},
2742
+ aiGenerated: !0,
2743
+ aiPrompt: R || void 0
2744
+ });
2745
+ });
2746
+ const X = ge(L, { width: 800, format: "auto" });
2747
+ t(L, X), e(), u(""), A("Image saved successfully!"), setTimeout(() => A(""), 3e3);
2748
+ } catch (T) {
2749
+ const E = T instanceof we ? T.message : T == null ? void 0 : T.message;
2750
+ u(`Failed to save image: ${E}`);
2751
+ } finally {
2752
+ i(!1);
2753
+ }
2754
+ }
2755
+ },
2756
+ handleImageMouseDown: (w) => {
2757
+ w.preventDefault(), te(!0), de({ x: w.clientX - H.x, y: w.clientY - H.y });
2758
+ },
2759
+ handleImageMouseMove: (w) => {
2760
+ W && (w.preventDefault(), V({ x: w.clientX - Z.x, y: w.clientY - Z.y }));
2761
+ },
2762
+ handleImageMouseUp: () => te(!1),
2763
+ handleWheel: (w) => {
2764
+ w.preventDefault();
2765
+ const D = w.deltaY > 0 ? -10 : 10;
2766
+ B((R) => Math.max(25, Math.min(300, R + D)));
2767
+ },
2768
+ resetImageView: () => {
2769
+ B(100), V({ x: 0, y: 0 });
2770
+ }
2771
+ };
2772
+ }
2773
+ function tn({
2774
+ query: e,
2775
+ actions: t,
2776
+ settings: i,
2777
+ selectedMediaIds: l,
2778
+ refreshMediaList: r,
2779
+ clearSelection: n
2780
+ }) {
2781
+ const [c, m] = S({ isOpen: !1, mediaIds: [] }), [h, d] = S([]);
2782
+ return {
2783
+ deleteConfirm: c,
2784
+ setDeleteConfirm: m,
2785
+ deletingMedia: h,
2786
+ handleDelete: (C) => {
2787
+ m({ isOpen: !0, mediaIds: [C] });
2788
+ },
2789
+ handleDeleteSelected: () => {
2790
+ l.length && m({ isOpen: !0, mediaIds: l });
2791
+ },
2792
+ confirmDelete: async () => {
2793
+ if (!c.mediaIds.length) return;
2794
+ const C = c.mediaIds;
2795
+ m({ isOpen: !1, mediaIds: [] }), d((o) => Array.from(/* @__PURE__ */ new Set([...o, ...C])));
2796
+ for (const o of C)
2797
+ try {
2798
+ await yt(o, i, e, t);
2799
+ } catch (x) {
2800
+ nt.error("Failed to delete media:", x);
2801
+ }
2802
+ t.setProp(q, (o) => {
2803
+ const x = o.pageMedia;
2804
+ if (!x) return;
2805
+ const A = new Set(C);
2806
+ o.pageMedia = x.filter((y) => !A.has(y.id));
2807
+ }), r(), n(), d((o) => o.filter((x) => !C.includes(x)));
2808
+ }
2809
+ };
2810
+ }
2811
+ function an({
2812
+ query: e,
2813
+ actions: t,
2814
+ ai: i,
2815
+ designContext: l,
2816
+ refreshMediaList: r
2817
+ }) {
2818
+ const [n, c] = S(null), [m, h] = S(null), [d, p] = S("idle"), [f, u] = la(
2819
+ sa
2820
+ ), C = (v) => {
2821
+ var k, M, z, $, _, B;
2822
+ c({
2823
+ ...v,
2824
+ metadata: {
2825
+ alt: ((k = v.metadata) == null ? void 0 : k.alt) || "",
2826
+ title: ((M = v.metadata) == null ? void 0 : M.title) || "",
2827
+ description: ((z = v.metadata) == null ? void 0 : z.description) || "",
2828
+ url: (($ = v.metadata) == null ? void 0 : $.url) || "",
2829
+ svg: ((_ = v.metadata) == null ? void 0 : _.svg) || "",
2830
+ folderId: (B = v.metadata) == null ? void 0 : B.folderId
2831
+ }
2832
+ }), p("idle"), i.setMetadataError("");
2833
+ }, o = () => {
2834
+ c(null), p("idle"), i.setMetadataError("");
2835
+ }, x = async () => {
2836
+ if (n) {
2837
+ p("saving");
2838
+ try {
2839
+ const v = { ...n.metadata };
2840
+ if (n.type === "svg" && (v != null && v.svg)) {
2841
+ const k = Dt(v.svg);
2842
+ v.svg = k, v.size = new Blob([k]).size;
2843
+ }
2844
+ await new Promise((k) => setTimeout(k, 300)), oa(e, t, n.id, v), r(), p("saved"), setTimeout(() => p("idle"), 2e3);
2845
+ } catch (v) {
2846
+ nt.error("Failed to save metadata:", v), p("idle");
2847
+ }
2848
+ }
2849
+ }, A = (v) => {
2850
+ n && c({
2851
+ ...n,
2852
+ metadata: {
2853
+ ...n.metadata,
2854
+ ...v
2855
+ }
2856
+ });
2857
+ }, y = (v) => {
2858
+ t.setProp(q, (k) => {
2859
+ const M = k.pageMedia;
2860
+ M && (k.pageMedia = [...M, v]);
2861
+ }), r(), h(null);
2862
+ }, g = Ie(() => {
2863
+ var v;
2864
+ if (!(!n || n.type === "svg"))
2865
+ return n.type === "url" ? ((v = n.metadata) == null ? void 0 : v.url) || void 0 : ge(n.cdnId || n.id, { width: 800, format: "auto" });
2866
+ }, [n]), b = n ? {
2867
+ media: {
2868
+ id: n.id,
2869
+ type: n.type,
2870
+ cdnId: n.cdnId,
2871
+ metadata: n.metadata
2872
+ },
2873
+ imageUrl: g,
2874
+ isGenerating: i.isGeneratingMetadata,
2875
+ error: i.metadataError,
2876
+ designNotes: l.designNotes,
2877
+ designTags: l.designTags,
2878
+ setGenerating: i.setIsGeneratingMetadata,
2879
+ setError: i.setMetadataError,
2880
+ applyMetadata: A
2881
+ } : null;
2882
+ return re(() => {
2883
+ !f || !n || f.mediaId === n.id && (A({
2884
+ title: f.title,
2885
+ alt: f.alt,
2886
+ description: f.description
2887
+ }), i.setMetadataError(""), u(null));
2888
+ }, [
2889
+ f,
2890
+ n,
2891
+ A,
2892
+ i,
2893
+ u
2894
+ ]), {
2895
+ editingMedia: n,
2896
+ setEditingMedia: c,
2897
+ cropMedia: m,
2898
+ setCropMedia: h,
2899
+ savingMetadata: d,
2900
+ openEditModal: C,
2901
+ closeEditModal: o,
2902
+ saveEditedMetadata: x,
2903
+ applyGeneratedMetadata: A,
2904
+ handleSaveCroppedImage: y,
2905
+ analysisImageUrl: g,
2906
+ mediaEditAiActionsContext: b
2907
+ };
2908
+ }
2909
+ function nn({
2910
+ actions: e,
2911
+ mediaList: t,
2912
+ folderNameById: i,
2913
+ validFolderIdSet: l,
2914
+ searchQuery: r,
2915
+ kindFilter: n,
2916
+ folderFilter: c,
2917
+ sortField: m,
2918
+ sortDirection: h
2919
+ }) {
2920
+ const [d, p] = S([]), f = J(
2921
+ (o, x) => {
2922
+ const A = (x == null ? void 0 : x.kind) ?? n, y = (x == null ? void 0 : x.folder) ?? c, g = (x == null ? void 0 : x.search) ?? r, b = (x == null ? void 0 : x.sortField) ?? m, v = (x == null ? void 0 : x.sortDirection) ?? h;
2923
+ let k = o;
2924
+ if (A !== "all" && (k = k.filter((M) => De(M) === A)), y === "unfiled" ? k = k.filter((M) => {
2925
+ var $;
2926
+ const z = ($ = M.metadata) == null ? void 0 : $.folderId;
2927
+ return !z || !l.has(z);
2928
+ }) : y !== "all" && (k = k.filter((M) => {
2929
+ var z;
2930
+ return ((z = M.metadata) == null ? void 0 : z.folderId) === y;
2931
+ })), g.trim()) {
2932
+ const M = g.toLowerCase();
2933
+ k = k.filter((z) => {
2934
+ var H, V, W, te, Z;
2935
+ const $ = je[De(z)].toLowerCase(), _ = (H = z.metadata) != null && H.folderId ? i.get(z.metadata.folderId) || "" : "unfiled";
2936
+ return [
2937
+ z.id,
2938
+ (V = z.metadata) == null ? void 0 : V.title,
2939
+ (W = z.metadata) == null ? void 0 : W.alt,
2940
+ (te = z.metadata) == null ? void 0 : te.description,
2941
+ (Z = z.metadata) == null ? void 0 : Z.contentType,
2942
+ $,
2943
+ _
2944
+ ].filter(Boolean).join(" ").toLowerCase().includes(M);
2945
+ });
2946
+ }
2947
+ return Fa(k, b, v);
2948
+ },
2949
+ [
2950
+ c,
2951
+ i,
2952
+ n,
2953
+ r,
2954
+ h,
2955
+ m,
2956
+ l
2957
+ ]
2958
+ );
2959
+ return re(() => {
2960
+ p(f(t));
2961
+ }, [f, t]), {
2962
+ filteredMedia: d,
2963
+ setFilteredMedia: p,
2964
+ applyFilters: f,
2965
+ handleReorder: (o, x) => {
2966
+ if (o === x) return;
2967
+ const A = d.findIndex((k) => k.id === o), y = d.findIndex((k) => k.id === x);
2968
+ if (A === -1 || y === -1) return;
2969
+ const g = [...d], [b] = g.splice(A, 1);
2970
+ g.splice(y, 0, b);
2971
+ const v = g.map((k, M) => ({ ...k, order: M }));
2972
+ e.setProp(q, (k) => {
2973
+ const M = k.pageMedia;
2974
+ M && (k.pageMedia = M.map((z) => {
2975
+ const $ = v.find((_) => _.id === z.id);
2976
+ return $ ? { ...z, order: $.order } : z;
2977
+ }));
2978
+ }), p(v);
2979
+ },
2980
+ resortFilteredMedia: (o) => p(
2981
+ f(t, {
2982
+ sortField: o == null ? void 0 : o.sortField,
2983
+ sortDirection: o == null ? void 0 : o.sortDirection
2984
+ })
2985
+ )
2986
+ };
2987
+ }
2988
+ function rn({
2989
+ isOpen: e,
2990
+ selectionMode: t,
2991
+ onSelect: i,
2992
+ onClose: l,
2993
+ filteredMedia: r,
2994
+ selectedMedia: n,
2995
+ selectedMediaIds: c,
2996
+ previewMedia: m,
2997
+ editingMedia: h,
2998
+ viewMode: d,
2999
+ clearSelection: p,
3000
+ selectSingle: f,
3001
+ setPreviewMedia: u
3002
+ }) {
3003
+ re(() => {
3004
+ if (!e || m || h) return;
3005
+ const C = (o) => {
3006
+ var k;
3007
+ if (wa(o.target)) return;
3008
+ const x = c.length > 0;
3009
+ if (o.key === "Escape") {
3010
+ x && (o.preventDefault(), p());
3011
+ return;
3012
+ }
3013
+ if (o.key === "Enter" && n) {
3014
+ o.preventDefault(), t && i ? (i(n), l()) : u(n);
3015
+ return;
3016
+ }
3017
+ if (o.key !== "ArrowLeft" && o.key !== "ArrowRight" && o.key !== "ArrowUp" && o.key !== "ArrowDown" || !r.length) return;
3018
+ o.preventDefault();
3019
+ const A = n || r[0].id, y = Math.max(
3020
+ 0,
3021
+ r.findIndex((M) => M.id === A)
3022
+ ), g = d === "cards" ? 5 : 1;
3023
+ let b = y;
3024
+ o.key === "ArrowLeft" && (b = Math.max(0, y - 1)), o.key === "ArrowRight" && (b = Math.min(r.length - 1, y + 1)), o.key === "ArrowUp" && (b = Math.max(0, y - g)), o.key === "ArrowDown" && (b = Math.min(r.length - 1, y + g));
3025
+ const v = (k = r[b]) == null ? void 0 : k.id;
3026
+ v && f(v);
3027
+ };
3028
+ return document.addEventListener("keydown", C), () => document.removeEventListener("keydown", C);
3029
+ }, [
3030
+ p,
3031
+ h,
3032
+ r,
3033
+ e,
3034
+ l,
3035
+ i,
3036
+ m,
3037
+ f,
3038
+ n,
3039
+ c.length,
3040
+ t,
3041
+ d,
3042
+ u
3043
+ ]);
3044
+ }
3045
+ function ln({
3046
+ isOpen: e,
3047
+ selectionMode: t,
3048
+ selectedCount: i,
3049
+ selectAllVisible: l,
3050
+ handleDeleteSelected: r
3051
+ }) {
3052
+ const { context: n } = da();
3053
+ re(() => (n.set("media.modalOpen", e), () => {
3054
+ n.set("media.modalOpen", !1);
3055
+ }), [n, e]), re(() => {
3056
+ n.set("media.selectionMode", t);
3057
+ }, [n, t]), re(() => {
3058
+ n.set("media.selectedCount", i);
3059
+ }, [n, i]), re(() => {
3060
+ if (e)
3061
+ return () => {
3062
+ };
3063
+ }, [e, l, r]);
3064
+ }
3065
+ function sn(e) {
3066
+ return Array.isArray(e) ? e.map((t, i) => {
3067
+ const l = typeof (t == null ? void 0 : t.name) == "string" ? t.name.trim() : "", r = typeof (t == null ? void 0 : t.id) == "string" ? t.id : "";
3068
+ if (!l || !r) return null;
3069
+ const n = Date.now();
3070
+ return {
3071
+ id: r,
3072
+ name: l,
3073
+ order: Number.isFinite(t == null ? void 0 : t.order) ? Number(t.order) : i,
3074
+ createdAt: Number.isFinite(t == null ? void 0 : t.createdAt) ? Number(t.createdAt) : n,
3075
+ updatedAt: Number.isFinite(t == null ? void 0 : t.updatedAt) ? Number(t.updatedAt) : n
3076
+ };
3077
+ }).filter((t) => !!t).sort((t, i) => t.order - i.order || t.name.localeCompare(i.name)) : [];
3078
+ }
3079
+ function on() {
3080
+ const { query: e, actions: t } = rt(), [i, l] = S([]), [r, n] = S([]), c = Ie(() => {
3081
+ const x = /* @__PURE__ */ new Map();
3082
+ for (const A of r) x.set(A.id, A.name);
3083
+ return x;
3084
+ }, [r]), m = Ie(() => new Set(r.map((x) => x.id)), [r]), h = Ie(() => {
3085
+ var y;
3086
+ const x = /* @__PURE__ */ new Map();
3087
+ let A = 0;
3088
+ for (const g of i) {
3089
+ const b = (y = g.metadata) == null ? void 0 : y.folderId;
3090
+ if (!b || !m.has(b)) {
3091
+ A += 1;
3092
+ continue;
3093
+ }
3094
+ x.set(b, (x.get(b) ?? 0) + 1);
3095
+ }
3096
+ return {
3097
+ all: i.length,
3098
+ unfiled: A,
3099
+ byId: x
3100
+ };
3101
+ }, [i, m]), d = J(() => {
3102
+ var b;
3103
+ const x = ca(e), A = e.node(q).get(), y = (b = A == null ? void 0 : A.data) == null ? void 0 : b.props, g = sn(y == null ? void 0 : y.mediaFolders);
3104
+ l(x), n(g);
3105
+ }, [e]), p = J(
3106
+ (x) => {
3107
+ t.setProp(q, (A) => {
3108
+ A.mediaFolders = x;
3109
+ }), n(x);
3110
+ },
3111
+ [t]
3112
+ ), f = J(
3113
+ (x) => {
3114
+ const A = x.trim();
3115
+ if (!A) return null;
3116
+ const y = Date.now(), g = {
3117
+ id: `folder_${y.toString(36)}_${Math.random().toString(36).slice(2, 8)}`,
3118
+ name: A,
3119
+ order: r.length,
3120
+ createdAt: y,
3121
+ updatedAt: y
3122
+ };
3123
+ return p([...r, g]), g;
3124
+ },
3125
+ [r, p]
3126
+ ), u = J(
3127
+ (x, A) => {
3128
+ const y = A.trim();
3129
+ if (!y) return;
3130
+ const g = r.map(
3131
+ (b) => b.id === x ? { ...b, name: y, updatedAt: Date.now() } : b
3132
+ );
3133
+ p(g);
3134
+ },
3135
+ [r, p]
3136
+ ), C = J(
3137
+ (x, A) => {
3138
+ const y = r.filter((g) => g.id !== x);
3139
+ t.setProp(q, (g) => {
3140
+ g.mediaFolders = y, Array.isArray(g.pageMedia) && (g.pageMedia = g.pageMedia.map((b) => {
3141
+ var k;
3142
+ if (((k = b.metadata) == null ? void 0 : k.folderId) !== x) return b;
3143
+ const v = { ...b.metadata || {} };
3144
+ return delete v.folderId, { ...b, metadata: v };
3145
+ }));
3146
+ }), n(y), A == null || A(), d();
3147
+ },
3148
+ [t, r, d]
3149
+ ), o = J(
3150
+ (x, A) => {
3151
+ if (!x.length) return;
3152
+ const y = new Set(x);
3153
+ t.setProp(q, (g) => {
3154
+ Array.isArray(g.pageMedia) && (g.pageMedia = g.pageMedia.map((b) => {
3155
+ if (!y.has(b.id)) return b;
3156
+ const v = { ...b.metadata || {} };
3157
+ return A ? v.folderId = A : delete v.folderId, { ...b, metadata: v };
3158
+ }));
3159
+ }), d();
3160
+ },
3161
+ [t, d]
3162
+ );
3163
+ return {
3164
+ query: e,
3165
+ actions: t,
3166
+ mediaList: i,
3167
+ setMediaList: l,
3168
+ folders: r,
3169
+ setFolders: n,
3170
+ folderNameById: c,
3171
+ validFolderIdSet: m,
3172
+ folderCounts: h,
3173
+ refreshMediaList: d,
3174
+ createFolder: f,
3175
+ renameFolder: u,
3176
+ deleteFolderById: C,
3177
+ moveMediaToFolder: o
3178
+ };
3179
+ }
3180
+ function dn(e) {
3181
+ const [t, i] = S(null), l = () => {
3182
+ if (!t) return;
3183
+ const n = e.findIndex((c) => c.id === t);
3184
+ n < e.length - 1 && i(e[n + 1].id);
3185
+ }, r = () => {
3186
+ if (!t) return;
3187
+ const n = e.findIndex((c) => c.id === t);
3188
+ n > 0 && i(e[n - 1].id);
3189
+ };
3190
+ return re(() => {
3191
+ if (!t) return;
3192
+ const n = (c) => {
3193
+ c.key === "ArrowLeft" ? r() : c.key === "ArrowRight" && l();
3194
+ };
3195
+ return document.addEventListener("keydown", n), () => document.removeEventListener("keydown", n);
3196
+ }, [t, e]), qe({
3197
+ id: "media-preview",
3198
+ isOpen: t != null,
3199
+ onDismiss: () => i(null)
3200
+ }), { previewMedia: t, setPreviewMedia: i, handlePreviewNext: l, handlePreviewPrevious: r };
3201
+ }
3202
+ function cn(e, t) {
3203
+ const [i, l] = S(null), [r, n] = S([]), c = le(null), m = J(() => {
3204
+ n([]), l(null), c.current = null;
3205
+ }, []), h = J((f) => {
3206
+ if (!f) {
3207
+ n([]), l(null), c.current = null;
3208
+ return;
3209
+ }
3210
+ l(f), n([f]), c.current = f;
3211
+ }, []), d = J(
3212
+ (f, u) => {
3213
+ if (t) {
3214
+ h(f);
3215
+ return;
3216
+ }
3217
+ const C = !!(u != null && u.shiftKey), o = !!(u != null && u.metaKey) || !!(u != null && u.ctrlKey);
3218
+ if (C && c.current) {
3219
+ const x = e.findIndex((y) => y.id === c.current), A = e.findIndex((y) => y.id === f);
3220
+ if (x > -1 && A > -1) {
3221
+ const [y, g] = [Math.min(x, A), Math.max(x, A)], b = e.slice(y, g + 1).map((v) => v.id);
3222
+ n((v) => o ? Array.from(/* @__PURE__ */ new Set([...v, ...b])) : b), l(f), c.current = f;
3223
+ return;
3224
+ }
3225
+ }
3226
+ if (o) {
3227
+ n((x) => x.includes(f) ? x.filter((A) => A !== f) : [...x, f]), l(f), c.current = f;
3228
+ return;
3229
+ }
3230
+ h(f);
3231
+ },
3232
+ [e, h, t]
3233
+ ), p = J(() => {
3234
+ if (t) return;
3235
+ const f = e.map((u) => u.id);
3236
+ n(f), l(f[0] || null), c.current = f[f.length - 1] || null;
3237
+ }, [e, t]);
3238
+ return {
3239
+ selectedMedia: i,
3240
+ setSelectedMedia: l,
3241
+ selectedMediaIds: r,
3242
+ setSelectedMediaIds: n,
3243
+ lastSelectedMediaIdRef: c,
3244
+ clearSelection: m,
3245
+ selectSingle: h,
3246
+ handleMediaSelection: d,
3247
+ selectAllVisible: p
3248
+ };
3249
+ }
3250
+ function un(e, t) {
3251
+ const i = t.trim();
3252
+ return !i || i === "*" || i === "*/*" ? !0 : i.split(",").some((l) => {
3253
+ const r = l.trim();
3254
+ return r ? r === "*" || r === "*/*" ? !0 : r.endsWith("/*") ? e.startsWith(r.slice(0, -1)) : r.endsWith("/") ? e.startsWith(r) : e === r : !1;
3255
+ });
3256
+ }
3257
+ function mn({
3258
+ onFiles: e,
3259
+ accept: t = "image/",
3260
+ max: i = 10,
3261
+ maxSizeBytes: l,
3262
+ onRejected: r,
3263
+ disabled: n = !1
3264
+ }) {
3265
+ const [c, m] = S(!1), h = J(
3266
+ (u) => {
3267
+ u.preventDefault(), n || m(!0);
3268
+ },
3269
+ [n]
3270
+ ), d = J(
3271
+ (u) => {
3272
+ u.preventDefault(), n || m(!0);
3273
+ },
3274
+ [n]
3275
+ ), p = J((u) => {
3276
+ u.currentTarget.contains(u.relatedTarget) || m(!1);
3277
+ }, []), f = J(
3278
+ (u) => {
3279
+ if (u.preventDefault(), u.stopPropagation(), m(!1), n) return;
3280
+ const C = [];
3281
+ for (const o of Array.from(u.dataTransfer.files)) {
3282
+ if (!un(o.type, t)) {
3283
+ r == null || r(o, "bad_mime");
3284
+ continue;
3285
+ }
3286
+ if (l && o.size > l) {
3287
+ r == null || r(o, "too_large");
3288
+ continue;
3289
+ }
3290
+ if (C.length >= i) {
3291
+ r == null || r(o, "over_max_count");
3292
+ continue;
3293
+ }
3294
+ C.push(o);
3295
+ }
3296
+ C.length > 0 && e(C);
3297
+ },
3298
+ [e, t, i, l, r, n]
3299
+ );
3300
+ return {
3301
+ isDragOver: c,
3302
+ dropProps: { onDragOver: h, onDragEnter: d, onDragLeave: p, onDrop: f }
3303
+ };
3304
+ }
3305
+ let _e;
3306
+ typeof window < "u" ? window.btoa ? _e = function(e) {
3307
+ return btoa(unescape(encodeURIComponent(e)));
3308
+ } : _e = function(e) {
3309
+ const t = unescape(encodeURIComponent(e + ""));
3310
+ let i = "";
3311
+ for (let l, r, n = 0, c = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; t.charAt(n | 0) || (c = "=", n % 1); i += c.charAt(63 & l >> 8 - n % 1 * 8)) {
3312
+ if (r = t.charCodeAt(n += 3 / 4), r > 255)
3313
+ throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");
3314
+ l = l << 8 | r;
3315
+ }
3316
+ return i;
3317
+ } : _e = function(e) {
3318
+ return Buffer.from(e).toString("base64");
3319
+ };
3320
+ function G(e, t) {
3321
+ let i = wt(e, t);
3322
+ return (t && t.fallback !== void 0 ? t.fallback : G.defaults.fallback) === !0 && i === "" && (i = wt(_e(e), t)), i;
3323
+ }
3324
+ const Tt = {
3325
+ // http://www.eki.ee/wgrs/rom1_bg.pdf
3326
+ bg: { Й: "Y", й: "y", X: "H", x: "h", Ц: "Ts", ц: "ts", Щ: "Sht", щ: "sht", Ъ: "A", ъ: "a", Ь: "Y", ь: "y" },
3327
+ // Need a reference URL for German, although this is pretty well-known.
3328
+ de: { Ä: "AE", ä: "ae", Ö: "OE", ö: "oe", Ü: "UE", ü: "ue" },
3329
+ // Need a reference URL for Serbian.
3330
+ sr: { đ: "dj", Đ: "DJ" },
3331
+ // https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/864314/ROMANIZATION_OF_UKRAINIAN.pdf
3332
+ uk: { И: "Y", и: "y", Й: "Y", й: "y", Ц: "Ts", ц: "ts", Х: "Kh", х: "kh", Щ: "Shch", щ: "shch", Г: "H", г: "h" }
3333
+ };
3334
+ let st = {};
3335
+ function wt(e, t) {
3336
+ if (typeof e != "string")
3337
+ throw new Error("slug() requires a string argument, received " + typeof e);
3338
+ if (!e.isWellFormed())
3339
+ throw new Error("slug() received a malformed string with lone surrogates");
3340
+ typeof t == "string" && (t = { replacement: t }), t = t ? Object.assign({}, t) : {}, t.mode = t.mode || G.defaults.mode;
3341
+ const i = G.defaults.modes[t.mode], l = ["replacement", "multicharmap", "charmap", "remove", "lower", "trim"];
3342
+ for (let h, d = 0, p = l.length; d < p; d++)
3343
+ h = l[d], t[h] = h in t ? t[h] : i[h];
3344
+ const r = Tt[t.locale] || st;
3345
+ let n = [];
3346
+ for (const h in t.multicharmap) {
3347
+ if (!Object.prototype.hasOwnProperty.call(t.multicharmap, h))
3348
+ continue;
3349
+ const d = h.length;
3350
+ n.indexOf(d) === -1 && n.push(d);
3351
+ }
3352
+ n = n.sort(function(h, d) {
3353
+ return d - h;
3354
+ });
3355
+ const c = t.mode === "rfc3986" ? /[^\w\s\-.~]/ : /[^A-Za-z0-9\s]/;
3356
+ let m = "";
3357
+ for (let h, d = 0, p = e.length; d < p; d++) {
3358
+ h = e[d];
3359
+ let f = !1;
3360
+ for (let u = 0; u < n.length; u++) {
3361
+ const C = n[u], o = e.substr(d, C);
3362
+ if (t.multicharmap[o]) {
3363
+ d += C - 1, h = t.multicharmap[o], f = !0;
3364
+ break;
3365
+ }
3366
+ }
3367
+ f || (r[h] ? h = r[h] : t.charmap[h] ? h = t.charmap[h].replace(t.replacement, " ") : h.includes(t.replacement) ? h = h.replace(t.replacement, " ") : h = h.replace(c, "")), m += h;
3368
+ }
3369
+ return t.remove && (m = m.replace(t.remove, "")), t.trim && (m = m.trim()), m = m.replace(/\s+/g, t.replacement), t.lower && (m = m.toLowerCase()), m;
3370
+ }
3371
+ const zt = {
3372
+ // multibyte devanagari characters (hindi, sanskrit, etc.)
3373
+ फ़: "Fi",
3374
+ ग़: "Ghi",
3375
+ ख़: "Khi",
3376
+ क़: "Qi",
3377
+ ड़: "ugDha",
3378
+ ढ़: "ugDhha",
3379
+ य़: "Yi",
3380
+ ज़: "Za",
3381
+ // hebrew
3382
+ // Refs: http://www.eki.ee/wgrs/rom1_he.pdf
3383
+ // Refs: https://en.wikipedia.org/wiki/Niqqud
3384
+ בִי: "i",
3385
+ בֵ: "e",
3386
+ בֵי: "e",
3387
+ בֶ: "e",
3388
+ בַ: "a",
3389
+ בָ: "a",
3390
+ בֹ: "o",
3391
+ וֹ: "o",
3392
+ בֻ: "u",
3393
+ וּ: "u",
3394
+ בּ: "b",
3395
+ כּ: "k",
3396
+ ךּ: "k",
3397
+ פּ: "p",
3398
+ שׁ: "sh",
3399
+ שׂ: "s",
3400
+ בְ: "e",
3401
+ חֱ: "e",
3402
+ חֲ: "a",
3403
+ חֳ: "o",
3404
+ בִ: "i"
3405
+ }, Rt = {
3406
+ // latin
3407
+ À: "A",
3408
+ Á: "A",
3409
+ Â: "A",
3410
+ Ã: "A",
3411
+ Ä: "A",
3412
+ Å: "A",
3413
+ Æ: "AE",
3414
+ Ç: "C",
3415
+ È: "E",
3416
+ É: "E",
3417
+ Ê: "E",
3418
+ Ë: "E",
3419
+ Ì: "I",
3420
+ Í: "I",
3421
+ Î: "I",
3422
+ Ï: "I",
3423
+ Ð: "D",
3424
+ Ñ: "N",
3425
+ Ò: "O",
3426
+ Ó: "O",
3427
+ Ô: "O",
3428
+ Õ: "O",
3429
+ Ö: "O",
3430
+ Ő: "O",
3431
+ Ø: "O",
3432
+ Ō: "O",
3433
+ Ù: "U",
3434
+ Ú: "U",
3435
+ Û: "U",
3436
+ Ü: "U",
3437
+ Ű: "U",
3438
+ Ý: "Y",
3439
+ Þ: "TH",
3440
+ ß: "ss",
3441
+ à: "a",
3442
+ á: "a",
3443
+ â: "a",
3444
+ ã: "a",
3445
+ ä: "a",
3446
+ å: "a",
3447
+ æ: "ae",
3448
+ ç: "c",
3449
+ è: "e",
3450
+ é: "e",
3451
+ ê: "e",
3452
+ ë: "e",
3453
+ ì: "i",
3454
+ í: "i",
3455
+ î: "i",
3456
+ ï: "i",
3457
+ ð: "d",
3458
+ ñ: "n",
3459
+ ò: "o",
3460
+ ó: "o",
3461
+ ô: "o",
3462
+ õ: "o",
3463
+ ö: "o",
3464
+ ő: "o",
3465
+ ø: "o",
3466
+ ō: "o",
3467
+ Œ: "OE",
3468
+ œ: "oe",
3469
+ ù: "u",
3470
+ ú: "u",
3471
+ û: "u",
3472
+ ü: "u",
3473
+ ű: "u",
3474
+ ý: "y",
3475
+ þ: "th",
3476
+ ÿ: "y",
3477
+ "ẞ": "SS",
3478
+ // greek
3479
+ α: "a",
3480
+ β: "b",
3481
+ γ: "g",
3482
+ δ: "d",
3483
+ ε: "e",
3484
+ ζ: "z",
3485
+ η: "h",
3486
+ θ: "th",
3487
+ ι: "i",
3488
+ κ: "k",
3489
+ λ: "l",
3490
+ μ: "m",
3491
+ ν: "n",
3492
+ ξ: "3",
3493
+ ο: "o",
3494
+ π: "p",
3495
+ ρ: "r",
3496
+ σ: "s",
3497
+ τ: "t",
3498
+ υ: "y",
3499
+ φ: "f",
3500
+ χ: "x",
3501
+ ψ: "ps",
3502
+ ω: "w",
3503
+ ά: "a",
3504
+ έ: "e",
3505
+ ί: "i",
3506
+ ό: "o",
3507
+ ύ: "y",
3508
+ ή: "h",
3509
+ ώ: "w",
3510
+ ς: "s",
3511
+ ϊ: "i",
3512
+ ΰ: "y",
3513
+ ϋ: "y",
3514
+ ΐ: "i",
3515
+ Α: "A",
3516
+ Β: "B",
3517
+ Γ: "G",
3518
+ Δ: "D",
3519
+ Ε: "E",
3520
+ Ζ: "Z",
3521
+ Η: "H",
3522
+ Θ: "Th",
3523
+ Ι: "I",
3524
+ Κ: "K",
3525
+ Λ: "L",
3526
+ Μ: "M",
3527
+ Ν: "N",
3528
+ Ξ: "3",
3529
+ Ο: "O",
3530
+ Π: "P",
3531
+ Ρ: "R",
3532
+ Σ: "S",
3533
+ Τ: "T",
3534
+ Υ: "Y",
3535
+ Φ: "F",
3536
+ Χ: "X",
3537
+ Ψ: "PS",
3538
+ Ω: "W",
3539
+ Ά: "A",
3540
+ Έ: "E",
3541
+ Ί: "I",
3542
+ Ό: "O",
3543
+ Ύ: "Y",
3544
+ Ή: "H",
3545
+ Ώ: "W",
3546
+ Ϊ: "I",
3547
+ Ϋ: "Y",
3548
+ // turkish
3549
+ ş: "s",
3550
+ Ş: "S",
3551
+ ı: "i",
3552
+ İ: "I",
3553
+ ğ: "g",
3554
+ Ğ: "G",
3555
+ // russian
3556
+ а: "a",
3557
+ б: "b",
3558
+ в: "v",
3559
+ г: "g",
3560
+ д: "d",
3561
+ е: "e",
3562
+ ё: "yo",
3563
+ ж: "zh",
3564
+ з: "z",
3565
+ и: "i",
3566
+ й: "j",
3567
+ к: "k",
3568
+ л: "l",
3569
+ м: "m",
3570
+ н: "n",
3571
+ о: "o",
3572
+ п: "p",
3573
+ р: "r",
3574
+ с: "s",
3575
+ т: "t",
3576
+ у: "u",
3577
+ ф: "f",
3578
+ х: "h",
3579
+ ц: "c",
3580
+ ч: "ch",
3581
+ ш: "sh",
3582
+ щ: "sh",
3583
+ ъ: "u",
3584
+ ы: "y",
3585
+ ь: "",
3586
+ э: "e",
3587
+ ю: "yu",
3588
+ я: "ya",
3589
+ А: "A",
3590
+ Б: "B",
3591
+ В: "V",
3592
+ Г: "G",
3593
+ Д: "D",
3594
+ Е: "E",
3595
+ Ё: "Yo",
3596
+ Ж: "Zh",
3597
+ З: "Z",
3598
+ И: "I",
3599
+ Й: "J",
3600
+ К: "K",
3601
+ Л: "L",
3602
+ М: "M",
3603
+ Н: "N",
3604
+ О: "O",
3605
+ П: "P",
3606
+ Р: "R",
3607
+ С: "S",
3608
+ Т: "T",
3609
+ У: "U",
3610
+ Ф: "F",
3611
+ Х: "H",
3612
+ Ц: "C",
3613
+ Ч: "Ch",
3614
+ Ш: "Sh",
3615
+ Щ: "Sh",
3616
+ Ъ: "U",
3617
+ Ы: "Y",
3618
+ Ь: "",
3619
+ Э: "E",
3620
+ Ю: "Yu",
3621
+ Я: "Ya",
3622
+ // ukranian
3623
+ Є: "Ye",
3624
+ І: "I",
3625
+ Ї: "Yi",
3626
+ Ґ: "G",
3627
+ є: "ye",
3628
+ і: "i",
3629
+ ї: "yi",
3630
+ ґ: "g",
3631
+ // czech
3632
+ č: "c",
3633
+ ď: "d",
3634
+ ě: "e",
3635
+ ň: "n",
3636
+ ř: "r",
3637
+ š: "s",
3638
+ ť: "t",
3639
+ ů: "u",
3640
+ ž: "z",
3641
+ Č: "C",
3642
+ Ď: "D",
3643
+ Ě: "E",
3644
+ Ň: "N",
3645
+ Ř: "R",
3646
+ Š: "S",
3647
+ Ť: "T",
3648
+ Ů: "U",
3649
+ Ž: "Z",
3650
+ // slovak
3651
+ ľ: "l",
3652
+ ĺ: "l",
3653
+ ŕ: "r",
3654
+ Ľ: "L",
3655
+ Ĺ: "L",
3656
+ Ŕ: "R",
3657
+ // polish
3658
+ ą: "a",
3659
+ ć: "c",
3660
+ ę: "e",
3661
+ ł: "l",
3662
+ ń: "n",
3663
+ ś: "s",
3664
+ ź: "z",
3665
+ ż: "z",
3666
+ Ą: "A",
3667
+ Ć: "C",
3668
+ Ę: "E",
3669
+ Ł: "L",
3670
+ Ń: "N",
3671
+ Ś: "S",
3672
+ Ź: "Z",
3673
+ Ż: "Z",
3674
+ // latvian
3675
+ ā: "a",
3676
+ ē: "e",
3677
+ ģ: "g",
3678
+ ī: "i",
3679
+ ķ: "k",
3680
+ ļ: "l",
3681
+ ņ: "n",
3682
+ ū: "u",
3683
+ Ā: "A",
3684
+ Ē: "E",
3685
+ Ģ: "G",
3686
+ Ī: "I",
3687
+ Ķ: "K",
3688
+ Ļ: "L",
3689
+ Ņ: "N",
3690
+ Ū: "U",
3691
+ // arabic
3692
+ أ: "a",
3693
+ إ: "i",
3694
+ ب: "b",
3695
+ ت: "t",
3696
+ ث: "th",
3697
+ ج: "g",
3698
+ ح: "h",
3699
+ خ: "kh",
3700
+ د: "d",
3701
+ ذ: "th",
3702
+ ر: "r",
3703
+ ز: "z",
3704
+ س: "s",
3705
+ ش: "sh",
3706
+ ص: "s",
3707
+ ض: "d",
3708
+ ط: "t",
3709
+ ظ: "th",
3710
+ ع: "aa",
3711
+ غ: "gh",
3712
+ ف: "f",
3713
+ ق: "k",
3714
+ ك: "k",
3715
+ ل: "l",
3716
+ م: "m",
3717
+ ن: "n",
3718
+ ه: "h",
3719
+ و: "o",
3720
+ ي: "y",
3721
+ ء: "aa",
3722
+ ة: "a",
3723
+ // farsi
3724
+ آ: "a",
3725
+ ا: "a",
3726
+ پ: "p",
3727
+ ژ: "zh",
3728
+ گ: "g",
3729
+ چ: "ch",
3730
+ ک: "k",
3731
+ ی: "i",
3732
+ // lithuanian
3733
+ ė: "e",
3734
+ į: "i",
3735
+ ų: "u",
3736
+ Ė: "E",
3737
+ Į: "I",
3738
+ Ų: "U",
3739
+ // romanian
3740
+ ț: "t",
3741
+ Ț: "T",
3742
+ ţ: "t",
3743
+ Ţ: "T",
3744
+ ș: "s",
3745
+ Ș: "S",
3746
+ ă: "a",
3747
+ Ă: "A",
3748
+ // vietnamese
3749
+ Ạ: "A",
3750
+ Ả: "A",
3751
+ Ầ: "A",
3752
+ Ấ: "A",
3753
+ Ậ: "A",
3754
+ Ẩ: "A",
3755
+ Ẫ: "A",
3756
+ Ằ: "A",
3757
+ Ắ: "A",
3758
+ Ặ: "A",
3759
+ Ẳ: "A",
3760
+ Ẵ: "A",
3761
+ Ẹ: "E",
3762
+ Ẻ: "E",
3763
+ Ẽ: "E",
3764
+ Ề: "E",
3765
+ Ế: "E",
3766
+ Ệ: "E",
3767
+ Ể: "E",
3768
+ Ễ: "E",
3769
+ Ị: "I",
3770
+ Ỉ: "I",
3771
+ Ĩ: "I",
3772
+ Ọ: "O",
3773
+ Ỏ: "O",
3774
+ Ồ: "O",
3775
+ Ố: "O",
3776
+ Ộ: "O",
3777
+ Ổ: "O",
3778
+ Ỗ: "O",
3779
+ Ơ: "O",
3780
+ Ờ: "O",
3781
+ Ớ: "O",
3782
+ Ợ: "O",
3783
+ Ở: "O",
3784
+ Ỡ: "O",
3785
+ Ụ: "U",
3786
+ Ủ: "U",
3787
+ Ũ: "U",
3788
+ Ư: "U",
3789
+ Ừ: "U",
3790
+ Ứ: "U",
3791
+ Ự: "U",
3792
+ Ử: "U",
3793
+ Ữ: "U",
3794
+ Ỳ: "Y",
3795
+ Ỵ: "Y",
3796
+ Ỷ: "Y",
3797
+ Ỹ: "Y",
3798
+ Đ: "D",
3799
+ ạ: "a",
3800
+ ả: "a",
3801
+ ầ: "a",
3802
+ ấ: "a",
3803
+ ậ: "a",
3804
+ ẩ: "a",
3805
+ ẫ: "a",
3806
+ ằ: "a",
3807
+ ắ: "a",
3808
+ ặ: "a",
3809
+ ẳ: "a",
3810
+ ẵ: "a",
3811
+ ẹ: "e",
3812
+ ẻ: "e",
3813
+ ẽ: "e",
3814
+ ề: "e",
3815
+ ế: "e",
3816
+ ệ: "e",
3817
+ ể: "e",
3818
+ ễ: "e",
3819
+ ị: "i",
3820
+ ỉ: "i",
3821
+ ĩ: "i",
3822
+ ọ: "o",
3823
+ ỏ: "o",
3824
+ ồ: "o",
3825
+ ố: "o",
3826
+ ộ: "o",
3827
+ ổ: "o",
3828
+ ỗ: "o",
3829
+ ơ: "o",
3830
+ ờ: "o",
3831
+ ớ: "o",
3832
+ ợ: "o",
3833
+ ở: "o",
3834
+ ỡ: "o",
3835
+ ụ: "u",
3836
+ ủ: "u",
3837
+ ũ: "u",
3838
+ ư: "u",
3839
+ ừ: "u",
3840
+ ứ: "u",
3841
+ ự: "u",
3842
+ ử: "u",
3843
+ ữ: "u",
3844
+ ỳ: "y",
3845
+ ỵ: "y",
3846
+ ỷ: "y",
3847
+ ỹ: "y",
3848
+ đ: "d",
3849
+ // kazakh
3850
+ Ә: "AE",
3851
+ ә: "ae",
3852
+ Ғ: "GH",
3853
+ ғ: "gh",
3854
+ Қ: "KH",
3855
+ қ: "kh",
3856
+ Ң: "NG",
3857
+ ң: "ng",
3858
+ Ү: "UE",
3859
+ ү: "ue",
3860
+ Ұ: "U",
3861
+ ұ: "u",
3862
+ Һ: "H",
3863
+ һ: "h",
3864
+ Ө: "OE",
3865
+ ө: "oe",
3866
+ // serbian
3867
+ ђ: "dj",
3868
+ ј: "j",
3869
+ љ: "lj",
3870
+ њ: "nj",
3871
+ ћ: "c",
3872
+ џ: "dz",
3873
+ Ђ: "Dj",
3874
+ Ј: "j",
3875
+ Љ: "Lj",
3876
+ Њ: "Nj",
3877
+ Ћ: "C",
3878
+ Џ: "Dz",
3879
+ nj: "nj",
3880
+ lj: "lj",
3881
+ Nj: "NJ",
3882
+ Lj: "LJ",
3883
+ // hindi
3884
+ अ: "a",
3885
+ आ: "aa",
3886
+ ए: "e",
3887
+ ई: "ii",
3888
+ ऍ: "ei",
3889
+ ऎ: "ae",
3890
+ ऐ: "ai",
3891
+ इ: "i",
3892
+ ओ: "o",
3893
+ ऑ: "oi",
3894
+ ऒ: "oii",
3895
+ ऊ: "uu",
3896
+ औ: "ou",
3897
+ उ: "u",
3898
+ ब: "B",
3899
+ भ: "Bha",
3900
+ च: "Ca",
3901
+ छ: "Chha",
3902
+ ड: "Da",
3903
+ ढ: "Dha",
3904
+ फ: "Fa",
3905
+ ग: "Ga",
3906
+ घ: "Gha",
3907
+ ग़: "Ghi",
3908
+ ह: "Ha",
3909
+ ज: "Ja",
3910
+ झ: "Jha",
3911
+ क: "Ka",
3912
+ ख: "Kha",
3913
+ ख़: "Khi",
3914
+ ल: "L",
3915
+ ळ: "Li",
3916
+ ऌ: "Li",
3917
+ ऴ: "Lii",
3918
+ ॡ: "Lii",
3919
+ म: "Ma",
3920
+ न: "Na",
3921
+ ङ: "Na",
3922
+ ञ: "Nia",
3923
+ ण: "Nae",
3924
+ ऩ: "Ni",
3925
+ ॐ: "oms",
3926
+ प: "Pa",
3927
+ क़: "Qi",
3928
+ र: "Ra",
3929
+ ऋ: "Ri",
3930
+ ॠ: "Ri",
3931
+ ऱ: "Ri",
3932
+ स: "Sa",
3933
+ श: "Sha",
3934
+ ष: "Shha",
3935
+ ट: "Ta",
3936
+ त: "Ta",
3937
+ ठ: "Tha",
3938
+ द: "Tha",
3939
+ थ: "Tha",
3940
+ ध: "Thha",
3941
+ ड़: "ugDha",
3942
+ ढ़: "ugDhha",
3943
+ व: "Va",
3944
+ य: "Ya",
3945
+ य़: "Yi",
3946
+ ज़: "Za",
3947
+ // azerbaijani
3948
+ ə: "e",
3949
+ Ə: "E",
3950
+ // georgian
3951
+ ა: "a",
3952
+ ბ: "b",
3953
+ გ: "g",
3954
+ დ: "d",
3955
+ ე: "e",
3956
+ ვ: "v",
3957
+ ზ: "z",
3958
+ თ: "t",
3959
+ ი: "i",
3960
+ კ: "k",
3961
+ ლ: "l",
3962
+ მ: "m",
3963
+ ნ: "n",
3964
+ ო: "o",
3965
+ პ: "p",
3966
+ ჟ: "zh",
3967
+ რ: "r",
3968
+ ს: "s",
3969
+ ტ: "t",
3970
+ უ: "u",
3971
+ ფ: "p",
3972
+ ქ: "k",
3973
+ ღ: "gh",
3974
+ ყ: "q",
3975
+ შ: "sh",
3976
+ ჩ: "ch",
3977
+ ც: "ts",
3978
+ ძ: "dz",
3979
+ წ: "ts",
3980
+ ჭ: "ch",
3981
+ ხ: "kh",
3982
+ ჯ: "j",
3983
+ ჰ: "h",
3984
+ // hebrew
3985
+ ב: "v",
3986
+ גּ: "g",
3987
+ ג: "g",
3988
+ ד: "d",
3989
+ דּ: "d",
3990
+ ה: "h",
3991
+ ו: "v",
3992
+ ז: "z",
3993
+ ח: "h",
3994
+ ט: "t",
3995
+ י: "y",
3996
+ כ: "kh",
3997
+ ך: "kh",
3998
+ ל: "l",
3999
+ מ: "m",
4000
+ ם: "m",
4001
+ נ: "n",
4002
+ ן: "n",
4003
+ ס: "s",
4004
+ פ: "f",
4005
+ ף: "f",
4006
+ ץ: "ts",
4007
+ צ: "ts",
4008
+ ק: "k",
4009
+ ר: "r",
4010
+ תּ: "t",
4011
+ ת: "t"
4012
+ };
4013
+ G.charmap = Object.assign({}, Rt);
4014
+ G.multicharmap = Object.assign({}, zt);
4015
+ G.defaults = {
4016
+ charmap: G.charmap,
4017
+ mode: "pretty",
4018
+ modes: {
4019
+ rfc3986: {
4020
+ replacement: "-",
4021
+ remove: null,
4022
+ lower: !0,
4023
+ charmap: G.charmap,
4024
+ multicharmap: G.multicharmap,
4025
+ trim: !0
4026
+ },
4027
+ pretty: {
4028
+ replacement: "-",
4029
+ remove: null,
4030
+ lower: !0,
4031
+ charmap: G.charmap,
4032
+ multicharmap: G.multicharmap,
4033
+ trim: !0
4034
+ }
4035
+ },
4036
+ multicharmap: G.multicharmap,
4037
+ fallback: !0
4038
+ };
4039
+ G.reset = function() {
4040
+ G.defaults.modes.rfc3986.charmap = G.defaults.modes.pretty.charmap = G.charmap = G.defaults.charmap = Object.assign({}, Rt), G.defaults.modes.rfc3986.multicharmap = G.defaults.modes.pretty.multicharmap = G.multicharmap = G.defaults.multicharmap = Object.assign({}, zt), st = "";
4041
+ };
4042
+ G.extend = function(e) {
4043
+ const t = Object.keys(e), i = {}, l = {};
4044
+ for (let r = 0; r < t.length; r++)
4045
+ t[r].length > 1 ? i[t[r]] = e[t[r]] : l[t[r]] = e[t[r]];
4046
+ Object.assign(G.charmap, l), Object.assign(G.multicharmap, i);
4047
+ };
4048
+ G.setLocale = function(e) {
4049
+ st = Tt[e] || {};
4050
+ };
4051
+ let Be = [], Ut = { activePageId: null, siteId: null };
4052
+ function hn(e) {
4053
+ return Be = [...Be, e], () => {
4054
+ Be = Be.filter((t) => t !== e);
4055
+ };
4056
+ }
4057
+ function pn() {
4058
+ return Ut;
4059
+ }
4060
+ const gn = { activePageId: null, siteId: null };
4061
+ function fn() {
4062
+ return gn;
4063
+ }
4064
+ typeof window < "u" && window.addEventListener("popstate", () => {
4065
+ });
4066
+ function bn(e, t, i, l) {
4067
+ }
4068
+ function xn(e) {
4069
+ }
4070
+ function We() {
4071
+ return Ut.siteId;
4072
+ }
4073
+ function zn() {
4074
+ const e = fa(hn, pn, fn);
4075
+ return {
4076
+ activePageId: e.activePageId,
4077
+ siteId: e.siteId,
4078
+ navigateToPage: bn,
4079
+ setSiteId: xn
4080
+ };
4081
+ }
4082
+ function vn({
4083
+ isOpen: e,
4084
+ refreshMediaList: t,
4085
+ generateMetadataForImage: i
4086
+ }) {
4087
+ const { query: l, actions: r } = rt(), { config: n, save: c } = ua(), m = async () => {
4088
+ if (!We()) {
4089
+ try {
4090
+ await c({ isDraft: !0 });
4091
+ } catch (F) {
4092
+ if (We()) return;
4093
+ throw nt.warn("[MediaManager] page save before upload failed:", F), F;
4094
+ }
4095
+ if (!We())
4096
+ throw new Error("Site is not saved yet. Please wait for save to finish, then retry upload.");
4097
+ }
4098
+ }, [h, d] = S(!1), [p, f] = S(null), [u, C] = S(null), [o, x] = S(null), [A, y] = S("upload"), [g, b] = S(""), [v, k] = S(""), [M, z] = S(!1), [$, _] = S(!1), B = le(null), H = le(null), V = le(null), W = async (F, w, D, R = "cf-images", T) => {
4099
+ if (R === "r2") {
4100
+ Ae(l, r, F, "r2", "media-manager"), r.setProp(q, (E) => {
4101
+ var U;
4102
+ const L = (E.pageMedia || []).find((Y) => Y.id === F);
4103
+ L && (L.metadata = {
4104
+ ...L.metadata,
4105
+ title: w.name || F,
4106
+ alt: ((U = w.name) == null ? void 0 : U.replace(/\.[^/.]+$/, "")) || F,
4107
+ size: w.size,
4108
+ source: D,
4109
+ contentType: w.type,
4110
+ deliveryURL: T
4111
+ });
4112
+ });
4113
+ return;
4114
+ }
4115
+ Ae(l, r, F, "cdn", "media-manager");
4116
+ try {
4117
+ const E = await Sa(w);
4118
+ r.setProp(q, (Q) => {
4119
+ var Y;
4120
+ const U = (Q.pageMedia || []).find((ue) => ue.id === F);
4121
+ U && (U.metadata = {
4122
+ ...U.metadata,
4123
+ title: w.name || "Pasted Image",
4124
+ alt: ((Y = w.name) == null ? void 0 : Y.replace(/\.[^/.]+$/, "")) || "Pasted Image",
4125
+ size: w.size,
4126
+ source: D,
4127
+ dimensions: {
4128
+ width: E.width,
4129
+ height: E.height,
4130
+ aspectRatio: E.aspectRatio
4131
+ }
4132
+ });
4133
+ });
4134
+ } catch {
4135
+ r.setProp(q, (E) => {
4136
+ var U;
4137
+ const L = (E.pageMedia || []).find((Y) => Y.id === F);
4138
+ L && (L.metadata = {
4139
+ ...L.metadata,
4140
+ title: w.name || "Pasted Image",
4141
+ alt: ((U = w.name) == null ? void 0 : U.replace(/\.[^/.]+$/, "")) || "Pasted Image",
4142
+ size: w.size,
4143
+ source: D
4144
+ });
4145
+ });
4146
+ }
4147
+ ge(F, { width: 800, format: "auto" });
4148
+ }, te = async (F) => {
4149
+ if (!F || F.length === 0) return;
4150
+ d(!0), C(null), f({ current: 0, total: F.length, currentFile: "", completedFiles: [] }), await m();
4151
+ const w = [];
4152
+ try {
4153
+ for (let D = 0; D < F.length; D++) {
4154
+ const R = F[D];
4155
+ f((T) => T ? { ...T, current: D, currentFile: R.name } : null);
4156
+ try {
4157
+ const {
4158
+ mediaId: T,
4159
+ file: E,
4160
+ destination: Q,
4161
+ deliveryURL: L
4162
+ } = await Me(R);
4163
+ f(
4164
+ (U) => U ? { ...U, completedFiles: [...U.completedFiles, R.name] } : null
4165
+ ), await W(T, E, "upload", Q, L);
4166
+ } catch (T) {
4167
+ const E = T instanceof we ? T.message : T == null ? void 0 : T.message;
4168
+ w.push({ name: R.name, error: E || "Unknown error" });
4169
+ }
4170
+ }
4171
+ if (t(), w.length > 0) {
4172
+ const D = w.length === 1 ? `Failed to upload ${w[0].name}: ${w[0].error}` : `Failed to upload ${w.length} file(s):
4173
+ ${w.map((R) => `• ${R.name}: ${R.error}`).join(`
4174
+ `)}`;
4175
+ C(D);
4176
+ }
4177
+ } catch (D) {
4178
+ C(D.message || "Upload failed");
4179
+ } finally {
4180
+ d(!1), f(null);
4181
+ }
4182
+ }, Z = async (F) => {
4183
+ if (!(!F || F.length === 0 || !o)) {
4184
+ d(!0), f({ current: 0, total: 1, currentFile: F[0].name, completedFiles: [] }), await m();
4185
+ try {
4186
+ const w = F[0], {
4187
+ mediaId: D,
4188
+ file: R,
4189
+ destination: T,
4190
+ deliveryURL: E
4191
+ } = await Me(w);
4192
+ r.setProp("ROOT", (Q) => {
4193
+ const L = Q.pageMedia;
4194
+ if (!L) return;
4195
+ const U = L.find((Y) => Y.id === o);
4196
+ if (U) {
4197
+ const Y = T === "r2" ? "r2" : "cdn";
4198
+ U.cdnId = D, U.uploadedAt = Date.now(), U.type = Y, U.metadata && (U.metadata.title = R.name, U.metadata.size = R.size, U.metadata.contentType = R.type || U.metadata.contentType, delete U.metadata.svg, delete U.metadata.url, T === "r2" ? U.metadata.deliveryURL = E : delete U.metadata.deliveryURL);
4199
+ }
4200
+ }), t(), x(null);
4201
+ } catch (w) {
4202
+ const D = w instanceof we ? w.message : w == null ? void 0 : w.message;
4203
+ C(`Replace failed: ${D || "Unknown error"}`);
4204
+ } finally {
4205
+ d(!1), f(null);
4206
+ }
4207
+ }
4208
+ }, de = async () => {
4209
+ if (g.trim()) {
4210
+ d(!0), f({ current: 0, total: 1, currentFile: g, completedFiles: [] }), await m();
4211
+ try {
4212
+ if (M) {
4213
+ const F = n.apiBaseUrl || "", w = await fetch(`${F}/api/download-image`, {
4214
+ method: "POST",
4215
+ headers: { "Content-Type": "application/json" },
4216
+ body: JSON.stringify({ imageUrl: g, saveToCdn: !0 })
4217
+ });
4218
+ if (!w.ok) {
4219
+ const T = await w.json();
4220
+ throw new Error(T.error || "Failed to download image");
4221
+ }
4222
+ const D = await w.json(), R = D.mediaId;
4223
+ Ae(l, r, R, "cdn", "media-manager");
4224
+ try {
4225
+ const T = ge(R, { width: 800, format: "auto" }), E = await gt(T);
4226
+ r.setProp(q, (Q) => {
4227
+ const U = (Q.pageMedia || []).find((Y) => Y.id === R);
4228
+ U && (U.metadata = {
4229
+ ...U.metadata,
4230
+ title: D.filename,
4231
+ alt: D.filename.replace(/\.[^/.]+$/, ""),
4232
+ size: D.size,
4233
+ dimensions: {
4234
+ width: E.width,
4235
+ height: E.height,
4236
+ aspectRatio: E.aspectRatio
4237
+ },
4238
+ originalUrl: g
4239
+ });
4240
+ }), i(R, T);
4241
+ } catch {
4242
+ r.setProp(q, (E) => {
4243
+ const L = (E.pageMedia || []).find((U) => U.id === R);
4244
+ L && (L.metadata = {
4245
+ ...L.metadata,
4246
+ title: D.filename,
4247
+ alt: D.filename.replace(/\.[^/.]+$/, ""),
4248
+ size: D.size,
4249
+ originalUrl: g
4250
+ });
4251
+ });
4252
+ const T = ge(R, { width: 800, format: "auto" });
4253
+ i(R, T);
4254
+ }
4255
+ } else {
4256
+ const F = `url-${Date.now()}`;
4257
+ Ae(l, r, F, "url", "media-manager");
4258
+ try {
4259
+ const w = await gt(g);
4260
+ r.setProp(q, (D) => {
4261
+ const T = (D.pageMedia || []).find((E) => E.id === F);
4262
+ T && (T.metadata = {
4263
+ ...T.metadata,
4264
+ title: g.split("/").pop() || g,
4265
+ url: g,
4266
+ dimensions: {
4267
+ width: w.width,
4268
+ height: w.height,
4269
+ aspectRatio: w.aspectRatio
4270
+ }
4271
+ });
4272
+ }), i(F, g);
4273
+ } catch {
4274
+ r.setProp(q, (w) => {
4275
+ const R = (w.pageMedia || []).find((T) => T.id === F);
4276
+ R && (R.metadata = {
4277
+ ...R.metadata,
4278
+ title: g.split("/").pop() || g,
4279
+ url: g
4280
+ });
4281
+ }), i(F, g);
4282
+ }
4283
+ }
4284
+ t(), b(""), z(!1), y("upload");
4285
+ } catch (F) {
4286
+ alert(`Failed to add URL: ${F.message}`);
4287
+ } finally {
4288
+ d(!1), f(null);
4289
+ }
4290
+ }
4291
+ }, fe = async () => {
4292
+ if (v.trim()) {
4293
+ d(!0), f({ current: 0, total: 1, currentFile: "SVG Image", completedFiles: [] }), await m();
4294
+ try {
4295
+ const F = Dt(v), w = new Blob([F]).size, D = `svg-${Date.now()}`;
4296
+ Ae(l, r, D, "svg", "media-manager"), r.setProp(q, (R) => {
4297
+ const E = (R.pageMedia || []).find((Q) => Q.id === D);
4298
+ E && (E.metadata = {
4299
+ ...E.metadata,
4300
+ title: "SVG Image",
4301
+ svg: F,
4302
+ size: w
4303
+ });
4304
+ }), t(), k(""), y("upload");
4305
+ } finally {
4306
+ d(!1), f(null);
4307
+ }
4308
+ }
4309
+ }, oe = async () => {
4310
+ try {
4311
+ const F = await navigator.clipboard.read();
4312
+ _(
4313
+ F.some((w) => w.types.some((D) => D.startsWith("image/")))
4314
+ );
4315
+ } catch {
4316
+ _(!1);
4317
+ }
4318
+ }, ce = async (F) => {
4319
+ var R;
4320
+ const w = F.target;
4321
+ if (w.tagName === "INPUT" || w.tagName === "TEXTAREA") return;
4322
+ const D = (R = F.clipboardData) == null ? void 0 : R.items;
4323
+ if (D)
4324
+ for (let T = 0; T < D.length; T++) {
4325
+ const E = D[T];
4326
+ if (E.type.indexOf("image") !== -1) {
4327
+ F.preventDefault();
4328
+ const Q = E.getAsFile();
4329
+ if (!Q) continue;
4330
+ d(!0), f({
4331
+ current: 0,
4332
+ total: 1,
4333
+ currentFile: Q.name || "Pasted image",
4334
+ completedFiles: []
4335
+ }), await m();
4336
+ try {
4337
+ const { mediaId: L, file: U } = await Me(Q);
4338
+ await W(L, U, "paste"), t();
4339
+ } catch (L) {
4340
+ const U = L instanceof we ? L.message : L == null ? void 0 : L.message;
4341
+ alert(`Failed to upload pasted image: ${U}`);
4342
+ } finally {
4343
+ d(!1), f(null);
4344
+ }
4345
+ break;
4346
+ }
4347
+ }
4348
+ }, O = async () => {
4349
+ if ($)
4350
+ try {
4351
+ const F = await navigator.clipboard.read();
4352
+ for (const w of F)
4353
+ for (const D of w.types)
4354
+ if (D.startsWith("image/")) {
4355
+ const R = await w.getType(D), T = new File([R], `pasted-image-${Date.now()}.${D.split("/")[1]}`, {
4356
+ type: D
4357
+ });
4358
+ d(!0), await m();
4359
+ try {
4360
+ const { mediaId: E, file: Q } = await Me(T);
4361
+ Ae(l, r, E, "cdn", "media-manager"), r.setProp(q, (L) => {
4362
+ const Y = (L.pageMedia || []).find((ue) => ue.id === E);
4363
+ Y && (Y.metadata = {
4364
+ ...Y.metadata,
4365
+ title: Q.name,
4366
+ alt: Q.name.replace(/\.[^/.]+$/, ""),
4367
+ size: Q.size,
4368
+ source: "paste"
4369
+ });
4370
+ }), t();
4371
+ } catch (E) {
4372
+ const Q = E instanceof we ? E.message : E == null ? void 0 : E.message;
4373
+ alert(`Failed to upload pasted image: ${Q}`);
4374
+ } finally {
4375
+ d(!1);
4376
+ }
4377
+ return;
4378
+ }
4379
+ } catch {
4380
+ alert("Failed to access clipboard. Please try pasting with Ctrl+V / Cmd+V instead.");
4381
+ }
4382
+ }, { isDragOver: Ce, dropProps: Se } = mn({
4383
+ onFiles: (F) => {
4384
+ const w = new DataTransfer();
4385
+ F.forEach((D) => w.items.add(D)), te(w.files);
4386
+ },
4387
+ accept: lt()
4388
+ });
4389
+ return re(() => (e && (oe(), document.addEventListener("paste", ce)), () => document.removeEventListener("paste", ce)), [e]), re(() => {
4390
+ const F = (w) => {
4391
+ var D;
4392
+ (D = w.target) != null && D.closest("[data-ai-login-modal]") || V.current && !V.current.contains(w.target) && (A === "url" || A === "svg") && y("upload");
4393
+ };
4394
+ if (e)
4395
+ return document.addEventListener("mousedown", F), () => document.removeEventListener("mousedown", F);
4396
+ }, [e, A]), {
4397
+ // State
4398
+ uploading: h,
4399
+ uploadProgress: p,
4400
+ uploadError: u,
4401
+ addMode: A,
4402
+ urlInput: g,
4403
+ svgInput: v,
4404
+ saveUrlToCdn: M,
4405
+ hasImageInClipboard: $,
4406
+ isDragOver: Ce,
4407
+ dropProps: Se,
4408
+ replacingMedia: o,
4409
+ // Setters
4410
+ setAddMode: y,
4411
+ setUrlInput: b,
4412
+ setSvgInput: k,
4413
+ setSaveUrlToCdn: z,
4414
+ setUploading: d,
4415
+ setUploadError: C,
4416
+ setReplacingMedia: x,
4417
+ // Handlers
4418
+ handleUpload: te,
4419
+ handleReplaceMedia: Z,
4420
+ handleAddUrl: de,
4421
+ handleAddSvg: fe,
4422
+ handlePasteClick: O,
4423
+ // Refs
4424
+ fileInputRef: B,
4425
+ replaceInputRef: H,
4426
+ toolbarRef: V
4427
+ };
4428
+ }
4429
+ function An() {
4430
+ const [e, t] = S(""), [i, l] = S(() => {
4431
+ if (typeof window < "u") {
4432
+ const o = pt.get("media-view");
4433
+ return o === "list" || o === "cards" ? o : "cards";
4434
+ }
4435
+ return "cards";
4436
+ }), [r, n] = S("createdAt"), [c, m] = S("desc"), [h, d] = S("all"), [p, f] = S("all");
4437
+ return re(() => {
4438
+ typeof window < "u" && pt.set("media-view", i);
4439
+ }, [i]), {
4440
+ searchQuery: e,
4441
+ setSearchQuery: t,
4442
+ viewMode: i,
4443
+ setViewMode: l,
4444
+ sortField: r,
4445
+ setSortField: n,
4446
+ sortDirection: c,
4447
+ setSortDirection: m,
4448
+ kindFilter: h,
4449
+ setKindFilter: d,
4450
+ folderFilter: p,
4451
+ setFolderFilter: f,
4452
+ handleSearch: (o) => t(o),
4453
+ handleKindFilterChange: (o) => d(o)
4454
+ };
4455
+ }
4456
+ function Rn({
4457
+ isOpen: e,
4458
+ onClose: t,
4459
+ onSelect: i,
4460
+ selectionMode: l
4461
+ }) {
4462
+ var _;
4463
+ const r = ma(), n = ha(pa), c = ga("media-edit/ai-actions", void 0), m = r, h = r && c !== null, d = on(), p = An(), f = nn({
4464
+ actions: d.actions,
4465
+ mediaList: d.mediaList,
4466
+ folderNameById: d.folderNameById,
4467
+ validFolderIdSet: d.validFolderIdSet,
4468
+ searchQuery: p.searchQuery,
4469
+ kindFilter: p.kindFilter,
4470
+ folderFilter: p.folderFilter,
4471
+ sortField: p.sortField,
4472
+ sortDirection: p.sortDirection
4473
+ }), u = vn({
4474
+ isOpen: e,
4475
+ refreshMediaList: d.refreshMediaList,
4476
+ generateMetadataForImage: () => {
4477
+ }
4478
+ }), C = en({
4479
+ refreshMediaList: d.refreshMediaList,
4480
+ generateMetadataForImage: () => {
4481
+ },
4482
+ setUploading: u.setUploading
4483
+ }), o = d.query.node(q).get(), x = (_ = o == null ? void 0 : o.data) == null ? void 0 : _.props, A = x == null ? void 0 : x.design, y = {
4484
+ designNotes: typeof (A == null ? void 0 : A.notes) == "string" ? A.notes : void 0,
4485
+ designTags: Array.isArray(A == null ? void 0 : A.tags) ? A.tags : void 0
4486
+ }, g = an({
4487
+ query: d.query,
4488
+ actions: d.actions,
4489
+ ai: C,
4490
+ designContext: y,
4491
+ refreshMediaList: d.refreshMediaList
4492
+ }), b = cn(f.filteredMedia, l), v = dn(f.filteredMedia), k = tn({
4493
+ query: d.query,
4494
+ actions: d.actions,
4495
+ settings: n,
4496
+ selectedMediaIds: b.selectedMediaIds,
4497
+ refreshMediaList: d.refreshMediaList,
4498
+ clearSelection: b.clearSelection
4499
+ }), M = (B) => d.deleteFolderById(B, () => {
4500
+ p.folderFilter === B && p.setFolderFilter("all");
4501
+ }), z = (B) => d.moveMediaToFolder(b.selectedMediaIds, B);
4502
+ re(() => {
4503
+ e && (d.refreshMediaList(), p.setSearchQuery(""), b.clearSelection(), g.setEditingMedia(null), p.setFolderFilter("all"));
4504
+ }, [e, d.refreshMediaList, b.clearSelection]), re(() => {
4505
+ b.setSelectedMediaIds(
4506
+ (B) => B.filter((H) => d.mediaList.some((V) => V.id === H))
4507
+ ), b.setSelectedMedia(
4508
+ (B) => B && d.mediaList.some((H) => H.id === B) ? B : null
4509
+ );
4510
+ }, [d.mediaList]), rn({
4511
+ isOpen: e,
4512
+ selectionMode: l,
4513
+ onSelect: i,
4514
+ onClose: t,
4515
+ filteredMedia: f.filteredMedia,
4516
+ selectedMedia: b.selectedMedia,
4517
+ selectedMediaIds: b.selectedMediaIds,
4518
+ previewMedia: v.previewMedia,
4519
+ editingMedia: g.editingMedia,
4520
+ viewMode: p.viewMode,
4521
+ clearSelection: b.clearSelection,
4522
+ selectSingle: b.selectSingle,
4523
+ setPreviewMedia: v.setPreviewMedia
4524
+ }), ln({
4525
+ isOpen: e && !v.previewMedia && !g.editingMedia,
4526
+ selectionMode: l,
4527
+ selectedCount: b.selectedMediaIds.length,
4528
+ selectAllVisible: b.selectAllVisible,
4529
+ handleDeleteSelected: k.handleDeleteSelected
4530
+ });
4531
+ const $ = b.selectedMediaIds.length === 1;
4532
+ return {
4533
+ mediaList: d.mediaList,
4534
+ filteredMedia: f.filteredMedia,
4535
+ folders: d.folders,
4536
+ folderNameById: d.folderNameById,
4537
+ folderCounts: d.folderCounts,
4538
+ folderFilter: p.folderFilter,
4539
+ searchQuery: p.searchQuery,
4540
+ selectedMedia: b.selectedMedia,
4541
+ selectedMediaIds: b.selectedMediaIds,
4542
+ editingMedia: g.editingMedia,
4543
+ cropMedia: g.cropMedia,
4544
+ viewMode: p.viewMode,
4545
+ sortField: p.sortField,
4546
+ sortDirection: p.sortDirection,
4547
+ kindFilter: p.kindFilter,
4548
+ previewMedia: v.previewMedia,
4549
+ deleteConfirm: k.deleteConfirm,
4550
+ deletingMedia: k.deletingMedia,
4551
+ savingMetadata: g.savingMetadata,
4552
+ uploading: u.uploading,
4553
+ uploadProgress: u.uploadProgress,
4554
+ uploadError: u.uploadError,
4555
+ addMode: u.addMode,
4556
+ urlInput: u.urlInput,
4557
+ svgInput: u.svgInput,
4558
+ saveUrlToCdn: u.saveUrlToCdn,
4559
+ hasImageInClipboard: u.hasImageInClipboard,
4560
+ isDragOver: u.isDragOver,
4561
+ dropProps: u.dropProps,
4562
+ replacingMedia: u.replacingMedia,
4563
+ fileInputRef: u.fileInputRef,
4564
+ replaceInputRef: u.replaceInputRef,
4565
+ toolbarRef: u.toolbarRef,
4566
+ canUseImageAnalyze: h,
4567
+ canUseImageGenerate: m,
4568
+ canEditSelected: $,
4569
+ mediaEditAiActionsContext: g.mediaEditAiActionsContext,
4570
+ setSearchQuery: p.setSearchQuery,
4571
+ setSelectedMedia: b.setSelectedMedia,
4572
+ setViewMode: p.setViewMode,
4573
+ setSortField: p.setSortField,
4574
+ setSortDirection: p.setSortDirection,
4575
+ setKindFilter: p.handleKindFilterChange,
4576
+ setFolderFilter: p.setFolderFilter,
4577
+ setPreviewMedia: v.setPreviewMedia,
4578
+ setCropMedia: g.setCropMedia,
4579
+ setEditingMedia: g.setEditingMedia,
4580
+ setAddMode: u.setAddMode,
4581
+ setUrlInput: u.setUrlInput,
4582
+ setSvgInput: u.setSvgInput,
4583
+ setSaveUrlToCdn: u.setSaveUrlToCdn,
4584
+ setUploadError: u.setUploadError,
4585
+ setReplacingMedia: u.setReplacingMedia,
4586
+ setDeleteConfirm: k.setDeleteConfirm,
4587
+ handleSearch: p.handleSearch,
4588
+ handleDelete: k.handleDelete,
4589
+ handleDeleteSelected: k.handleDeleteSelected,
4590
+ confirmDelete: k.confirmDelete,
4591
+ handlePreviewNext: v.handlePreviewNext,
4592
+ handlePreviewPrevious: v.handlePreviewPrevious,
4593
+ handleReorder: f.handleReorder,
4594
+ handleSaveCroppedImage: g.handleSaveCroppedImage,
4595
+ handleMediaSelection: b.handleMediaSelection,
4596
+ clearSelection: b.clearSelection,
4597
+ selectAllVisible: b.selectAllVisible,
4598
+ openEditModal: g.openEditModal,
4599
+ closeEditModal: g.closeEditModal,
4600
+ saveEditedMetadata: g.saveEditedMetadata,
4601
+ handleUpload: u.handleUpload,
4602
+ handleReplaceMedia: u.handleReplaceMedia,
4603
+ handleAddUrl: u.handleAddUrl,
4604
+ handleAddSvg: u.handleAddSvg,
4605
+ handlePasteClick: u.handlePasteClick,
4606
+ createFolder: d.createFolder,
4607
+ renameFolder: d.renameFolder,
4608
+ deleteFolder: M,
4609
+ moveMediaToFolder: d.moveMediaToFolder,
4610
+ moveSelectedToFolder: z,
4611
+ selectionMode: l,
4612
+ onSelect: i,
4613
+ onClose: t,
4614
+ settings: n,
4615
+ resortFilteredMedia: f.resortFilteredMedia
4616
+ };
4617
+ }
4618
+ export {
4619
+ ya as C,
4620
+ Fn as I,
4621
+ En as M,
4622
+ Tn as a,
4623
+ zn as b,
4624
+ Me as c,
4625
+ we as d,
4626
+ De as g,
4627
+ G as s,
4628
+ Rn as u
4629
+ };