@chaibuilder/pages 0.4.8-beta.2 → 0.4.8-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { c, T as l, P as m, a as u, D as v, Q as i } from "./B4MFY5CR-Y1TSYFEO.js";
2
- import { g as d, c as f, a as e } from "./index-C657rWjb.js";
1
+ import { c, T as l, P as m, a as u, D as v, Q as i } from "./B4MFY5CR-BwIm3qbQ.js";
2
+ import { g as d, c as f, a as e } from "./index-gqdpcAQ2.js";
3
3
  var p = (a) => {
4
4
  const [r, t] = c({
5
5
  prefix: "TanstackQueryDevtools"
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./B4MFY5CR-De2uSYsE.cjs"),t=require("./index-B9qohq82.cjs");var s=c=>{const[r,o]=e.createLocalStorage({prefix:"TanstackQueryDevtools"}),l=t.getPreferredColorScheme(),a=t.createMemo(()=>{const n=r.theme_preference||e.THEME_PREFERENCE;return n!=="system"?n:l()});return t.createComponent(e.QueryDevtoolsContext.Provider,{value:c,get children(){return t.createComponent(e.PiPProvider,{localStore:r,setLocalStore:o,get children(){return t.createComponent(e.ThemeContext.Provider,{value:a,get children(){return t.createComponent(e.Devtools,{localStore:r,setLocalStore:o})}})}})}})},u=s;exports.default=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./B4MFY5CR-DY8Z5ymd.cjs"),t=require("./index-CisI4Eqe.cjs");var s=c=>{const[r,o]=e.createLocalStorage({prefix:"TanstackQueryDevtools"}),l=t.getPreferredColorScheme(),a=t.createMemo(()=>{const n=r.theme_preference||e.THEME_PREFERENCE;return n!=="system"?n:l()});return t.createComponent(e.QueryDevtoolsContext.Provider,{value:c,get children(){return t.createComponent(e.PiPProvider,{localStore:r,setLocalStore:o,get children(){return t.createComponent(e.ThemeContext.Provider,{value:a,get children(){return t.createComponent(e.Devtools,{localStore:r,setLocalStore:o})}})}})}})},u=s;exports.default=u;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./B4MFY5CR-De2uSYsE.cjs"),t=require("./index-B9qohq82.cjs");var u=o=>{const[r,n]=e.createLocalStorage({prefix:"TanstackQueryDevtools"}),c=t.getPreferredColorScheme(),a=t.createMemo(()=>{const l=r.theme_preference||e.THEME_PREFERENCE;return l!=="system"?l:c()});return t.createComponent(e.QueryDevtoolsContext.Provider,{value:o,get children(){return t.createComponent(e.PiPProvider,{disabled:!0,localStore:r,setLocalStore:n,get children(){return t.createComponent(e.ThemeContext.Provider,{value:a,get children(){return t.createComponent(e.ParentPanel,{get children(){return t.createComponent(e.ContentView,{localStore:r,setLocalStore:n,get onClose(){return o.onClose},showPanelViewOnly:!0})}})}})}})}})},i=u;exports.default=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./B4MFY5CR-DY8Z5ymd.cjs"),t=require("./index-CisI4Eqe.cjs");var u=o=>{const[r,n]=e.createLocalStorage({prefix:"TanstackQueryDevtools"}),c=t.getPreferredColorScheme(),a=t.createMemo(()=>{const l=r.theme_preference||e.THEME_PREFERENCE;return l!=="system"?l:c()});return t.createComponent(e.QueryDevtoolsContext.Provider,{value:o,get children(){return t.createComponent(e.PiPProvider,{disabled:!0,localStore:r,setLocalStore:n,get children(){return t.createComponent(e.ThemeContext.Provider,{value:a,get children(){return t.createComponent(e.ParentPanel,{get children(){return t.createComponent(e.ContentView,{localStore:r,setLocalStore:n,get onClose(){return o.onClose},showPanelViewOnly:!0})}})}})}})}})},i=u;exports.default=i;
@@ -1,5 +1,5 @@
1
- import { c as s, T as c, P as u, a as i, b as m, C as P, Q as d } from "./B4MFY5CR-Y1TSYFEO.js";
2
- import { g as v, c as C, a as e } from "./index-C657rWjb.js";
1
+ import { c as s, T as c, P as u, a as i, b as m, C as P, Q as d } from "./B4MFY5CR-BwIm3qbQ.js";
2
+ import { g as v, c as C, a as e } from "./index-gqdpcAQ2.js";
3
3
  var h = (t) => {
4
4
  const [r, o] = s({
5
5
  prefix: "TanstackQueryDevtools"
@@ -1,8 +1,8 @@
1
1
  import { jsxs as i, Fragment as w, jsx as a } from "react/jsx-runtime";
2
- import { Dialog as u, DialogContent as h, DialogHeader as b, DialogTitle as N, Label as r, Textarea as y, DialogFooter as D, Button as p } from "@chaibuilder/sdk/ui";
3
- import { Eye as F } from "lucide-react";
2
+ import { Dialog as u, DialogContent as h, DialogHeader as N, DialogTitle as b, Label as r, Textarea as D, DialogFooter as F, Button as p } from "@chaibuilder/sdk/ui";
3
+ import { Eye as y } from "lucide-react";
4
4
  import { useState as n } from "react";
5
- function E({
5
+ function k({
6
6
  asset: e,
7
7
  onSave: l,
8
8
  onCancel: o
@@ -19,7 +19,7 @@ function E({
19
19
  };
20
20
  return /* @__PURE__ */ i(w, { children: [
21
21
  /* @__PURE__ */ a(u, { open: !0, onOpenChange: () => o(), children: /* @__PURE__ */ i(h, { className: "sm:max-w-[700px]", children: [
22
- /* @__PURE__ */ a(b, { children: /* @__PURE__ */ a(N, { children: "Edit Asset Details" }) }),
22
+ /* @__PURE__ */ a(N, { children: /* @__PURE__ */ a(b, { children: "Edit Asset Details" }) }),
23
23
  /* @__PURE__ */ i("div", { className: "flex gap-4", children: [
24
24
  /* @__PURE__ */ i("div", { className: "relative group", children: [
25
25
  /* @__PURE__ */ a(
@@ -34,7 +34,7 @@ function E({
34
34
  {
35
35
  onClick: () => s(!0),
36
36
  className: "absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity rounded-md",
37
- children: /* @__PURE__ */ a(F, { className: "h-8 w-8 text-white" })
37
+ children: /* @__PURE__ */ a(y, { className: "h-8 w-8 text-white" })
38
38
  }
39
39
  )
40
40
  ] }),
@@ -62,7 +62,7 @@ function E({
62
62
  /* @__PURE__ */ i("div", { className: "grid gap-2", children: [
63
63
  /* @__PURE__ */ a(r, { htmlFor: "description", children: "Description" }),
64
64
  /* @__PURE__ */ a(
65
- y,
65
+ D,
66
66
  {
67
67
  id: "description",
68
68
  value: c,
@@ -74,7 +74,7 @@ function E({
74
74
  ] })
75
75
  ] })
76
76
  ] }),
77
- /* @__PURE__ */ i(D, { children: [
77
+ /* @__PURE__ */ i(F, { children: [
78
78
  /* @__PURE__ */ a(p, { variant: "outline", onClick: o, children: "Cancel" }),
79
79
  /* @__PURE__ */ a(p, { onClick: x, disabled: d, children: d ? "Saving..." : "Save Changes" })
80
80
  ] })
@@ -90,7 +90,7 @@ function E({
90
90
  ] });
91
91
  }
92
92
  function S(e) {
93
- return e < 1024 ? `${e.toFixed(2)} KB` : `${(e / 1024).toFixed(2)} MB`;
93
+ return e < 1024 ? `${e.toFixed(2)} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(2)} KB` : `${(e / (1024 * 1024)).toFixed(2)} MB`;
94
94
  }
95
95
  function g(e) {
96
96
  if (!e) return "N/A";
@@ -104,5 +104,5 @@ function g(e) {
104
104
  }).format(l);
105
105
  }
106
106
  export {
107
- E as default
107
+ k as default
108
108
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("@chaibuilder/sdk/ui"),g=require("lucide-react"),n=require("react");function p({asset:t,onSave:l,onCancel:r}){const[s,m]=n.useState(t.description||""),[c,o]=n.useState(!1),[h,d]=n.useState(!1),x=async()=>{o(!0);try{await l({description:s||void 0})}finally{o(!1)}};return e.jsxs(e.Fragment,{children:[e.jsx(a.Dialog,{open:!0,onOpenChange:()=>r(),children:e.jsxs(a.DialogContent,{className:"sm:max-w-[700px]",children:[e.jsx(a.DialogHeader,{children:e.jsx(a.DialogTitle,{children:"Edit Asset Details"})}),e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:t.url,className:"max-h-96 w-96 border rounded-md p-2"}),e.jsx("button",{onClick:()=>d(!0),className:"absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity rounded-md",children:e.jsx(g.Eye,{className:"h-8 w-8 text-white"})})]}),e.jsxs("div",{className:"grid gap-3 w-full",children:[e.jsx(a.Label,{htmlFor:"description",children:"Details"}),e.jsx("div",{className:"grid grid-cols-1 gap-2 text-sm border rounded-md p-2",children:[{label:"File Name",value:t.name},{label:"Type",value:t.type},{label:"Format",value:t.format},{label:"Size",value:j(t.size)},{label:"Dimensions",value:`${t.width} × ${t.height}`},{label:"Created",value:u(t.createdAt)},{label:"Updated",value:u((t==null?void 0:t.updatedAt)||"")}].map(i=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Label,{className:"w-max text-left px-2 w-1/4 font-normal text-gray-700",children:i.label}),":",e.jsx("div",{className:"w-max text-left font-medium text-gray-900 capitalize",children:i.value})]}))}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(a.Label,{htmlFor:"description",children:"Description"}),e.jsx(a.Textarea,{id:"description",value:s,placeholder:"Enter a description for the asset",onChange:i=>m(i.target.value),rows:3})]})]})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(a.Button,{variant:"outline",onClick:r,children:"Cancel"}),e.jsx(a.Button,{onClick:x,disabled:c,children:c?"Saving...":"Save Changes"})]})]})}),e.jsx(a.Dialog,{open:h,onOpenChange:d,children:e.jsx(a.DialogContent,{className:"w-[60vw] h-[60vh] p-0 flex items-center justify-center bg-gray-100",children:e.jsx("img",{src:t.url,className:"w-full h-full object-contain",alt:t.name})})})]})}function j(t){return t<1024?`${t.toFixed(2)} KB`:`${(t/1024).toFixed(2)} MB`}function u(t){if(!t)return"N/A";const l=new Date(t);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(l)}exports.default=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("@chaibuilder/sdk/ui"),g=require("lucide-react"),r=require("react");function p({asset:t,onSave:l,onCancel:n}){const[s,m]=r.useState(t.description||""),[o,c]=r.useState(!1),[x,d]=r.useState(!1),h=async()=>{c(!0);try{await l({description:s||void 0})}finally{c(!1)}};return e.jsxs(e.Fragment,{children:[e.jsx(a.Dialog,{open:!0,onOpenChange:()=>n(),children:e.jsxs(a.DialogContent,{className:"sm:max-w-[700px]",children:[e.jsx(a.DialogHeader,{children:e.jsx(a.DialogTitle,{children:"Edit Asset Details"})}),e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:t.url,className:"max-h-96 w-96 border rounded-md p-2"}),e.jsx("button",{onClick:()=>d(!0),className:"absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity rounded-md",children:e.jsx(g.Eye,{className:"h-8 w-8 text-white"})})]}),e.jsxs("div",{className:"grid gap-3 w-full",children:[e.jsx(a.Label,{htmlFor:"description",children:"Details"}),e.jsx("div",{className:"grid grid-cols-1 gap-2 text-sm border rounded-md p-2",children:[{label:"File Name",value:t.name},{label:"Type",value:t.type},{label:"Format",value:t.format},{label:"Size",value:f(t.size)},{label:"Dimensions",value:`${t.width} × ${t.height}`},{label:"Created",value:u(t.createdAt)},{label:"Updated",value:u((t==null?void 0:t.updatedAt)||"")}].map(i=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Label,{className:"w-max text-left px-2 w-1/4 font-normal text-gray-700",children:i.label}),":",e.jsx("div",{className:"w-max text-left font-medium text-gray-900 capitalize",children:i.value})]}))}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(a.Label,{htmlFor:"description",children:"Description"}),e.jsx(a.Textarea,{id:"description",value:s,placeholder:"Enter a description for the asset",onChange:i=>m(i.target.value),rows:3})]})]})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(a.Button,{variant:"outline",onClick:n,children:"Cancel"}),e.jsx(a.Button,{onClick:h,disabled:o,children:o?"Saving...":"Save Changes"})]})]})}),e.jsx(a.Dialog,{open:x,onOpenChange:d,children:e.jsx(a.DialogContent,{className:"w-[60vw] h-[60vh] p-0 flex items-center justify-center bg-gray-100",children:e.jsx("img",{src:t.url,className:"w-full h-full object-contain",alt:t.name})})})]})}function f(t){return t<1024?`${t.toFixed(2)} B`:t<1024*1024?`${(t/1024).toFixed(2)} KB`:`${(t/(1024*1024)).toFixed(2)} MB`}function u(t){if(!t)return"N/A";const l=new Date(t);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(l)}exports.default=p;
@@ -1,21 +1,21 @@
1
- import { jsxs as a, Fragment as Q, jsx as e } from "react/jsx-runtime";
2
- import X, { useState as w, useCallback as A, useMemo as oe, useRef as ce, Suspense as Y } from "react";
1
+ import { jsxs as t, Fragment as Q, jsx as e } from "react/jsx-runtime";
2
+ import Z, { useState as S, useCallback as w, useMemo as ce, useRef as de, Suspense as Y } from "react";
3
3
  import { mergeClasses as $ } from "@chaibuilder/sdk";
4
- import { Tabs as de, TabsList as ue, TabsTrigger as H, Button as f, TabsContent as V, Input as me, Card as he, CardContent as ge, Dialog as pe, DialogContent as fe, DialogHeader as ye, DialogTitle as ve, DialogDescription as xe, DialogFooter as Ne } from "@chaibuilder/sdk/ui";
5
- import { debounce as Ae, find as Se, merge as we } from "lodash-es";
6
- import { Search as be, Film as Ce, ImageIcon as Ee, Edit as Te, Trash2 as De, Loader2 as W, Upload as Pe } from "lucide-react";
7
- import { useDropzone as Ue } from "react-dropzone";
8
- import { useQueryClient as R, useMutation as K, useQuery as Fe } from "@tanstack/react-query";
4
+ import { Tabs as ue, TabsList as me, TabsTrigger as H, Button as f, TabsContent as V, Input as he, Card as ge, CardContent as pe, Dialog as fe, DialogContent as ye, DialogHeader as ve, DialogTitle as xe, DialogDescription as Ne, DialogFooter as we } from "@chaibuilder/sdk/ui";
5
+ import { debounce as Ae, find as Se, pick as W, first as be, merge as Ce } from "lodash-es";
6
+ import { Search as Ee, Film as Te, ImageIcon as De, Edit as Pe, Trash2 as Ue, Loader2 as X, Upload as Fe } from "lucide-react";
7
+ import { useDropzone as ze } from "react-dropzone";
8
+ import { useQueryClient as R, useMutation as K, useQuery as ke } from "@tanstack/react-query";
9
9
  import { toast as b } from "sonner";
10
- import { W as F, X as z, Y as y, Z as k } from "./index-C657rWjb.js";
11
- const ze = () => {
12
- const t = F(), r = R(), o = z();
10
+ import { W as F, X as z, Y as y, Z as k } from "./index-gqdpcAQ2.js";
11
+ const Me = () => {
12
+ const a = F(), r = R(), o = z();
13
13
  return K({
14
14
  mutationFn: async ({
15
15
  file: i,
16
16
  folderId: d,
17
17
  name: u
18
- }) => o(t, {
18
+ }) => o(a, {
19
19
  action: y.UPLOAD_ASSET,
20
20
  data: { file: i, folderId: d, name: u }
21
21
  }),
@@ -28,10 +28,10 @@ const ze = () => {
28
28
  b.error("Failed to upload asset");
29
29
  }
30
30
  });
31
- }, ke = () => {
32
- const t = F(), r = R(), o = z();
31
+ }, Ie = () => {
32
+ const a = F(), r = R(), o = z();
33
33
  return K({
34
- mutationFn: async (i) => o(t, {
34
+ mutationFn: async (i) => o(a, {
35
35
  action: y.DELETE_ASSET,
36
36
  data: { id: i }
37
37
  }),
@@ -44,10 +44,10 @@ const ze = () => {
44
44
  b.error("Failed to delete asset");
45
45
  }
46
46
  });
47
- }, Me = () => {
48
- const t = F(), r = R(), o = z();
47
+ }, qe = () => {
48
+ const a = F(), r = R(), o = z();
49
49
  return K({
50
- mutationFn: async (i) => o(t, {
50
+ mutationFn: async (i) => o(a, {
51
51
  action: y.UPDATE_ASSET,
52
52
  data: i
53
53
  }),
@@ -60,9 +60,9 @@ const ze = () => {
60
60
  b.error("Failed to update asset");
61
61
  }
62
62
  });
63
- }, Ie = (t = {}) => {
64
- const r = F(), o = z(), { search: i, page: d = 1, limit: u = 10 } = t;
65
- return Fe({
63
+ }, je = (a = {}) => {
64
+ const r = F(), o = z(), { search: i, page: d = 1, limit: u = 10 } = a;
65
+ return ke({
66
66
  queryKey: [k, y.GET_ASSETS, i, d, u],
67
67
  queryFn: async () => await o(r, {
68
68
  action: y.GET_ASSETS,
@@ -75,16 +75,16 @@ const ze = () => {
75
75
  retry: 1
76
76
  });
77
77
  };
78
- function qe() {
79
- const [r, o] = w([]), [i, d] = w({
78
+ function _e() {
79
+ const [r, o] = S([]), [i, d] = S({
80
80
  query: "",
81
81
  page: 1,
82
82
  pageSize: 10
83
- }), u = Ae(() => i.query, 300)(), { data: n, isLoading: C } = Ie({
83
+ }), u = Ae(() => i.query, 300)(), { data: n, isLoading: C } = je({
84
84
  search: (u == null ? void 0 : u.toLowerCase().trim()) || "",
85
85
  page: i.page,
86
86
  limit: i.pageSize
87
- }), v = n ? Math.ceil(n.total / n.pageSize) : 0, c = (n == null ? void 0 : n.page) || 1, g = c < v, m = c > 1, { mutate: E, isPending: M } = Me(), { mutate: S, isPending: p } = ze(), { mutate: T, isPending: D } = ke(), x = A(
87
+ }), v = n ? Math.ceil(n.total / n.pageSize) : 0, c = (n == null ? void 0 : n.page) || 1, p = c < v, m = c > 1, { mutate: E, isPending: M } = qe(), { mutate: A, isPending: g } = Me(), { mutate: T, isPending: D } = Ie(), x = w(
88
88
  (h) => {
89
89
  h >= 1 && h <= v && d((N) => ({
90
90
  ...N,
@@ -92,23 +92,23 @@ function qe() {
92
92
  }));
93
93
  },
94
94
  [v]
95
- ), I = A(() => {
96
- g && x(c + 1);
97
- }, [c, g, x]), q = A(() => {
95
+ ), I = w(() => {
96
+ p && x(c + 1);
97
+ }, [c, p, x]), q = w(() => {
98
98
  m && x(c - 1);
99
- }, [c, m, x]), j = A((h) => {
99
+ }, [c, m, x]), j = w((h) => {
100
100
  d((N) => ({
101
101
  ...N,
102
102
  query: h,
103
103
  page: 1
104
104
  // Reset to first page on new search
105
105
  }));
106
- }, []), P = A(
106
+ }, []), P = w(
107
107
  (h) => {
108
108
  o((N) => Se(N, { id: h.id }) ? [] : [h]);
109
109
  },
110
110
  [!1]
111
- ), _ = A(() => {
111
+ ), _ = w(() => {
112
112
  o([]);
113
113
  }, []);
114
114
  return {
@@ -118,10 +118,10 @@ function qe() {
118
118
  assets: (n == null ? void 0 : n.assets) || [],
119
119
  currentPage: c,
120
120
  totalPages: v,
121
- hasNextPage: g,
121
+ hasNextPage: p,
122
122
  hasPreviousPage: m,
123
123
  // Mutations
124
- uploadAsset: S,
124
+ uploadAsset: A,
125
125
  updateAsset: E,
126
126
  deleteAsset: T,
127
127
  goToPage: x,
@@ -132,22 +132,22 @@ function qe() {
132
132
  updateSelectedAssets: P,
133
133
  // Loading
134
134
  isLoadingAssets: C,
135
- isUploadingAsset: p,
135
+ isUploadingAsset: g,
136
136
  isUpdatingAsset: M,
137
137
  isDeletingAsset: D
138
138
  };
139
139
  }
140
- const je = X.lazy(() => import("./asset-metadata-editor-r5vYHUfm.js")), _e = X.lazy(() => import("./image-editor-CwVua57o.js"));
141
- function Xe({
142
- close: t,
140
+ const Le = Z.lazy(() => import("./asset-metadata-editor-CyTBhS-V.js")), Be = Z.lazy(() => import("./image-editor-By8RDHso.js"));
141
+ function Je({
142
+ close: a,
143
143
  onSelect: r,
144
144
  mode: o = "image"
145
145
  }) {
146
- const d = oe(() => [o], [o]), [u, n] = w("browse"), [C, v] = w(null), [c, g] = w(null), [m, E] = w({ show: !1, file: "" }), {
146
+ const d = ce(() => [o], [o]), [u, n] = S("browse"), [C, v] = S(null), [c, p] = S(null), [m, E] = S({ show: !1, file: "" }), {
147
147
  // Data
148
148
  query: M,
149
- assets: S,
150
- selectedAssets: p,
149
+ assets: A,
150
+ selectedAssets: g,
151
151
  // Mutations
152
152
  uploadAsset: T,
153
153
  updateAsset: D,
@@ -160,7 +160,7 @@ function Xe({
160
160
  isUploadingAsset: _,
161
161
  isUpdatingAsset: h
162
162
  // isDeletingAsset,
163
- } = qe(), N = ce(null), G = A(
163
+ } = _e(), N = de(null), G = w(
164
164
  async (s) => new Promise((l, L) => {
165
165
  const O = s[0], U = new FileReader();
166
166
  U.readAsDataURL(O), U.onload = async () => {
@@ -180,25 +180,27 @@ function Xe({
180
180
  }, U.onerror = (B) => L(B);
181
181
  }),
182
182
  [T]
183
- ), { getRootProps: Z, getInputProps: J, isDragActive: ee } = Ue({
183
+ ), { getRootProps: J, getInputProps: ee, isDragActive: se } = ze({
184
184
  onDrop: G,
185
185
  accept: {
186
186
  "image/*": d.includes("image") ? [] : []
187
187
  },
188
188
  maxSize: 10 * 1024 * 1024
189
- }), se = () => {
190
- r([p[0].url]), t();
189
+ }), te = () => {
190
+ g.length !== 0 && (r(
191
+ W(be(g), ["url", "width", "height", "description"])
192
+ ), a());
191
193
  }, ae = async (s) => {
192
- g(s);
193
- }, te = async () => {
194
- c && (await x(c.id), g(null));
195
- }, le = (s) => {
194
+ p(s);
195
+ }, le = async () => {
196
+ c && (await x(c.id), p(null));
197
+ }, ie = (s) => {
196
198
  v(s);
197
- }, ie = async (s, l) => {
198
- await D(we(s, l)), t();
199
- }, ne = (s) => {
199
+ }, ne = async (s, l) => {
200
+ await D(Ce(s, W(l, ["id", "description"]))), a();
201
+ }, re = (s) => {
200
202
  I(s.target.value);
201
- }, re = async (s, l) => {
203
+ }, oe = async (s, l) => {
202
204
  try {
203
205
  l ? await T({
204
206
  file: s,
@@ -212,23 +214,23 @@ function Xe({
212
214
  console.error("Error saving edited image:", L);
213
215
  }
214
216
  };
215
- return /* @__PURE__ */ a(Q, { children: [
216
- /* @__PURE__ */ a("div", { className: "min-w-[700px] min-h-[600px] w-[900px] max-w-[900px]", children: [
217
+ return /* @__PURE__ */ t(Q, { children: [
218
+ /* @__PURE__ */ t("div", { className: "min-w-[700px] min-h-[600px] w-[900px] max-w-[900px]", children: [
217
219
  /* @__PURE__ */ e("h1", { className: "text-lg font-medium pb-4", children: "Digital Asset Manager" }),
218
- /* @__PURE__ */ a(
219
- de,
220
+ /* @__PURE__ */ t(
221
+ ue,
220
222
  {
221
223
  value: u,
222
224
  onValueChange: (s) => n(s),
223
225
  className: "flex-1 flex flex-col h-full",
224
226
  children: [
225
- /* @__PURE__ */ a("div", { className: "flex justify-between items-center mb-2", children: [
226
- /* @__PURE__ */ a(ue, { children: [
227
+ /* @__PURE__ */ t("div", { className: "flex justify-between items-center mb-2", children: [
228
+ /* @__PURE__ */ t(me, { children: [
227
229
  /* @__PURE__ */ e(H, { value: "browse", children: "Browse Assets" }),
228
230
  /* @__PURE__ */ e(H, { value: "upload", children: "Upload" })
229
231
  ] }),
230
- /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
231
- p.length > 0 && /* @__PURE__ */ e(Q, { children: /* @__PURE__ */ e(
232
+ /* @__PURE__ */ t("div", { className: "flex items-center gap-2", children: [
233
+ g.length > 0 && /* @__PURE__ */ e(Q, { children: /* @__PURE__ */ e(
232
234
  f,
233
235
  {
234
236
  variant: "outline",
@@ -242,27 +244,27 @@ function Xe({
242
244
  f,
243
245
  {
244
246
  size: "sm",
245
- onClick: se,
246
- disabled: p.length === 0,
247
+ onClick: te,
248
+ disabled: g.length === 0,
247
249
  children: "Select Asset"
248
250
  }
249
251
  )
250
252
  ] })
251
253
  ] }),
252
- /* @__PURE__ */ a(V, { value: "browse", className: "flex-1 flex flex-col", children: [
253
- /* @__PURE__ */ e("div", { className: "flex items-center gap-2 mb-2", children: /* @__PURE__ */ a("div", { className: "relative w-full", children: [
254
- /* @__PURE__ */ e(be, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
254
+ /* @__PURE__ */ t(V, { value: "browse", className: "flex-1 flex flex-col", children: [
255
+ /* @__PURE__ */ e("div", { className: "flex items-center gap-2 mb-2", children: /* @__PURE__ */ t("div", { className: "relative w-full", children: [
256
+ /* @__PURE__ */ e(Ee, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
255
257
  /* @__PURE__ */ e(
256
- me,
258
+ he,
257
259
  {
258
260
  placeholder: "Search assets...",
259
261
  value: M,
260
- onChange: ne,
262
+ onChange: re,
261
263
  className: "pl-8"
262
264
  }
263
265
  )
264
266
  ] }) }),
265
- P && S.length === 0 ? /* @__PURE__ */ a("div", { className: "grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-2 overflow-y-auto max-h-[550px] p-1", children: [
267
+ P && A.length === 0 ? /* @__PURE__ */ t("div", { className: "grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-2 overflow-y-auto max-h-[550px] p-1", children: [
266
268
  /* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
267
269
  /* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
268
270
  /* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
@@ -273,28 +275,28 @@ function Xe({
273
275
  /* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
274
276
  /* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
275
277
  /* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" })
276
- ] }) : S.length === 0 ? /* @__PURE__ */ a("div", { className: "flex flex-col items-center justify-center text-center p-12 h-[380px]", children: [
277
- /* @__PURE__ */ a("div", { className: "text-muted-foreground mb-2", children: [
278
+ ] }) : A.length === 0 ? /* @__PURE__ */ t("div", { className: "flex flex-col items-center justify-center text-center p-12 h-[380px]", children: [
279
+ /* @__PURE__ */ t("div", { className: "text-muted-foreground mb-2", children: [
278
280
  /* @__PURE__ */ e("h3", { className: "text-gray-800 font-medium", children: "No assets to display" }),
279
281
  /* @__PURE__ */ e("p", { className: "text-sm", children: "You haven't uploaded any assets yet. Start by uploading your first asset." })
280
282
  ] }),
281
283
  /* @__PURE__ */ e("div", { className: "flex gap-2 pt-4", children: /* @__PURE__ */ e(f, { size: "lg", onClick: () => n("upload"), children: "Upload Assets" }) })
282
- ] }) : /* @__PURE__ */ a(
284
+ ] }) : /* @__PURE__ */ t(
283
285
  "div",
284
286
  {
285
287
  ref: N,
286
288
  className: "grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-2 overflow-y-auto max-h-[550px] p-1",
287
289
  children: [
288
- S.map((s) => /* @__PURE__ */ e(
289
- he,
290
+ A.map((s) => /* @__PURE__ */ e(
291
+ ge,
290
292
  {
291
293
  className: $(
292
294
  "cursor-pointer overflow-hidden transition-all",
293
- p.some((l) => l.id === s.id) ? "ring-2 ring-primary" : "hover:ring-2 hover:ring-primary/20"
295
+ g.some((l) => l.id === s.id) ? "ring-2 ring-primary" : "hover:ring-2 hover:ring-primary/20"
294
296
  ),
295
297
  onClick: () => j(s),
296
- children: /* @__PURE__ */ a(ge, { className: "p-0 relative group", children: [
297
- /* @__PURE__ */ a("div", { className: "aspect-square relative overflow-hidden bg-muted", children: [
298
+ children: /* @__PURE__ */ t(pe, { className: "p-0 relative group", children: [
299
+ /* @__PURE__ */ t("div", { className: "aspect-square relative overflow-hidden bg-muted", children: [
298
300
  s.type === "image" ? /* @__PURE__ */ e(
299
301
  "img",
300
302
  {
@@ -302,8 +304,8 @@ function Xe({
302
304
  alt: s.name,
303
305
  className: "object-cover w-full h-full min-h-[100px]"
304
306
  }
305
- ) : /* @__PURE__ */ a("div", { className: "flex items-center justify-center h-full", children: [
306
- /* @__PURE__ */ e(Ce, { className: "h-12 w-12 text-muted-foreground" }),
307
+ ) : /* @__PURE__ */ t("div", { className: "flex items-center justify-center h-full", children: [
308
+ /* @__PURE__ */ e(Te, { className: "h-12 w-12 text-muted-foreground" }),
307
309
  s.thumbnailUrl && /* @__PURE__ */ e(
308
310
  "img",
309
311
  {
@@ -313,7 +315,7 @@ function Xe({
313
315
  }
314
316
  )
315
317
  ] }),
316
- /* @__PURE__ */ a("div", { className: "absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2", children: [
318
+ /* @__PURE__ */ t("div", { className: "absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2", children: [
317
319
  /* @__PURE__ */ e(
318
320
  f,
319
321
  {
@@ -321,9 +323,9 @@ function Xe({
321
323
  size: "icon",
322
324
  className: "h-8 w-8",
323
325
  onClick: (l) => {
324
- l.stopPropagation(), le(s);
326
+ l.stopPropagation(), ie(s);
325
327
  },
326
- children: /* @__PURE__ */ e(Ee, { className: "h-4 w-4" })
328
+ children: /* @__PURE__ */ e(De, { className: "h-4 w-4" })
327
329
  }
328
330
  ),
329
331
  /* @__PURE__ */ e(
@@ -340,7 +342,7 @@ function Xe({
340
342
  name: s.name
341
343
  });
342
344
  },
343
- children: /* @__PURE__ */ e(Te, { className: "h-4 w-4" })
345
+ children: /* @__PURE__ */ e(Pe, { className: "h-4 w-4" })
344
346
  }
345
347
  ),
346
348
  /* @__PURE__ */ e(
@@ -352,15 +354,15 @@ function Xe({
352
354
  onClick: (l) => {
353
355
  l.stopPropagation(), ae(s);
354
356
  },
355
- children: /* @__PURE__ */ e(De, { className: "h-4 w-4" })
357
+ children: /* @__PURE__ */ e(Ue, { className: "h-4 w-4" })
356
358
  }
357
359
  )
358
360
  ] }),
359
- p.some((l) => l.id === s.id) && /* @__PURE__ */ e("div", { className: "absolute top-2 left-2", children: /* @__PURE__ */ e(
361
+ g.some((l) => l.id === s.id) && /* @__PURE__ */ e("div", { className: "absolute top-2 left-2", children: /* @__PURE__ */ e(
360
362
  "input",
361
363
  {
362
364
  type: "checkbox",
363
- checked: p.some(
365
+ checked: g.some(
364
366
  (l) => l.id === s.id
365
367
  ),
366
368
  readOnly: !0,
@@ -368,7 +370,7 @@ function Xe({
368
370
  }
369
371
  ) })
370
372
  ] }),
371
- /* @__PURE__ */ a("div", { className: "p-2", children: [
373
+ /* @__PURE__ */ t("div", { className: "p-2", children: [
372
374
  /* @__PURE__ */ e(
373
375
  "div",
374
376
  {
@@ -377,44 +379,44 @@ function Xe({
377
379
  children: s.name
378
380
  }
379
381
  ),
380
- /* @__PURE__ */ a("div", { className: "text-xs text-muted-foreground flex items-center justify-between", children: [
381
- /* @__PURE__ */ e("span", { children: Le((s == null ? void 0 : s.size) || 0) }),
382
- /* @__PURE__ */ e("span", { children: Be(s.createdAt) })
382
+ /* @__PURE__ */ t("div", { className: "text-xs text-muted-foreground flex items-center justify-between", children: [
383
+ /* @__PURE__ */ e("span", { children: Qe((s == null ? void 0 : s.size) || 0) }),
384
+ /* @__PURE__ */ e("span", { children: Re(s.createdAt) })
383
385
  ] })
384
386
  ] })
385
387
  ] })
386
388
  },
387
389
  s.id
388
390
  )),
389
- P && S.length > 0 && /* @__PURE__ */ e("div", { className: "col-span-full flex justify-center py-4", children: /* @__PURE__ */ e(W, { className: "h-6 w-6 animate-spin text-muted-foreground" }) })
391
+ P && A.length > 0 && /* @__PURE__ */ e("div", { className: "col-span-full flex justify-center py-4", children: /* @__PURE__ */ e(X, { className: "h-6 w-6 animate-spin text-muted-foreground" }) })
390
392
  ]
391
393
  }
392
394
  )
393
395
  ] }),
394
- /* @__PURE__ */ e(V, { value: "upload", className: "flex-1 ", children: /* @__PURE__ */ a(
396
+ /* @__PURE__ */ e(V, { value: "upload", className: "flex-1 ", children: /* @__PURE__ */ t(
395
397
  "div",
396
398
  {
397
- ...Z(),
399
+ ...J(),
398
400
  className: $(
399
401
  "border-2 border-dashed rounded-lg h-[380px] flex flex-col items-center justify-center text-center cursor-pointer hover:bg-gray-50",
400
- ee ? "border-primary bg-primary/5" : "border-muted-foreground/20"
402
+ se ? "border-primary bg-primary/5" : "border-muted-foreground/20"
401
403
  ),
402
404
  children: [
403
- /* @__PURE__ */ e("input", { ...J() }),
404
- h || _ ? /* @__PURE__ */ a("div", { className: "flex flex-col items-center", children: [
405
- /* @__PURE__ */ e(W, { className: "h-12 w-12 text-primary animate-spin mb-4" }),
405
+ /* @__PURE__ */ e("input", { ...ee() }),
406
+ h || _ ? /* @__PURE__ */ t("div", { className: "flex flex-col items-center", children: [
407
+ /* @__PURE__ */ e(X, { className: "h-12 w-12 text-primary animate-spin mb-4" }),
406
408
  /* @__PURE__ */ e("h3", { className: "text-lg font-medium mb-1", children: "Uploading files..." }),
407
409
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: "Please wait while your files are being processed." })
408
- ] }) : /* @__PURE__ */ a(Q, { children: [
409
- /* @__PURE__ */ e(Pe, { className: "h-12 w-12 text-muted-foreground mb-4" }),
410
+ ] }) : /* @__PURE__ */ t(Q, { children: [
411
+ /* @__PURE__ */ e(Fe, { className: "h-12 w-12 text-muted-foreground mb-4" }),
410
412
  /* @__PURE__ */ e("h3", { className: "text-lg font-medium mb-1", children: "Drag & drop files here" }),
411
413
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground mb-4", children: "or click to browse your files" }),
412
- /* @__PURE__ */ a("div", { className: "text-xs text-muted-foreground", children: [
413
- /* @__PURE__ */ a("p", { children: [
414
+ /* @__PURE__ */ t("div", { className: "text-xs text-muted-foreground", children: [
415
+ /* @__PURE__ */ t("p", { children: [
414
416
  "Accepted file types: ",
415
417
  d.join(", ")
416
418
  ] }),
417
- /* @__PURE__ */ a("p", { children: [
419
+ /* @__PURE__ */ t("p", { children: [
418
420
  "Maximum file size: ",
419
421
  10,
420
422
  "MB"
@@ -429,53 +431,53 @@ function Xe({
429
431
  )
430
432
  ] }),
431
433
  C && /* @__PURE__ */ e(Y, { fallback: /* @__PURE__ */ e("div", { children: "Loading..." }), children: /* @__PURE__ */ e(
432
- je,
434
+ Le,
433
435
  {
434
436
  asset: C,
435
- onSave: (s) => ie(C, s),
437
+ onSave: (s) => ne(C, s),
436
438
  onCancel: () => {
437
439
  v(null);
438
440
  }
439
441
  }
440
442
  ) }),
441
443
  m.show && /* @__PURE__ */ e(Y, { fallback: /* @__PURE__ */ e("div", { children: "Loading..." }), children: /* @__PURE__ */ e(
442
- _e,
444
+ Be,
443
445
  {
444
446
  imageUrl: m.file,
445
- onSave: re,
447
+ onSave: oe,
446
448
  onClose: () => E({ show: !1, file: "" }),
447
449
  defaultSavedImageName: m.name,
448
450
  isEditing: !!m.id
449
451
  }
450
452
  ) }),
451
453
  c && /* @__PURE__ */ e(
452
- pe,
454
+ fe,
453
455
  {
454
456
  open: !!c,
455
- onOpenChange: () => g(null),
456
- children: /* @__PURE__ */ a(fe, { children: [
457
- /* @__PURE__ */ a(ye, { children: [
458
- /* @__PURE__ */ e(ve, { children: "Delete Asset" }),
459
- /* @__PURE__ */ a(xe, { children: [
457
+ onOpenChange: () => p(null),
458
+ children: /* @__PURE__ */ t(ye, { children: [
459
+ /* @__PURE__ */ t(ve, { children: [
460
+ /* @__PURE__ */ e(xe, { children: "Delete Asset" }),
461
+ /* @__PURE__ */ t(Ne, { children: [
460
462
  'Are you sure you want to delete "',
461
463
  c.name,
462
464
  '"? This action cannot be undone.'
463
465
  ] })
464
466
  ] }),
465
- /* @__PURE__ */ a(Ne, { className: "gap-2 sm:gap-0", children: [
466
- /* @__PURE__ */ e(f, { variant: "outline", onClick: () => g(null), children: "Cancel" }),
467
- /* @__PURE__ */ e(f, { variant: "destructive", onClick: te, children: "Delete" })
467
+ /* @__PURE__ */ t(we, { className: "gap-2 sm:gap-0", children: [
468
+ /* @__PURE__ */ e(f, { variant: "outline", onClick: () => p(null), children: "Cancel" }),
469
+ /* @__PURE__ */ e(f, { variant: "destructive", onClick: le, children: "Delete" })
468
470
  ] })
469
471
  ] })
470
472
  }
471
473
  )
472
474
  ] });
473
475
  }
474
- function Le(t) {
475
- return t < 1024 ? `${t.toFixed(2)} B` : t < 1024 * 1024 ? `${(t / 1024).toFixed(2)} KB` : `${(t / (1024 * 1024)).toFixed(2)} MB`;
476
+ function Qe(a) {
477
+ return a < 1024 ? `${a.toFixed(2)} B` : a < 1024 * 1024 ? `${(a / 1024).toFixed(2)} KB` : `${(a / (1024 * 1024)).toFixed(2)} MB`;
476
478
  }
477
- function Be(t) {
478
- const r = new Date(t);
479
+ function Re(a) {
480
+ const r = new Date(a);
479
481
  return new Intl.DateTimeFormat("en-US", {
480
482
  month: "short",
481
483
  day: "numeric",
@@ -483,5 +485,5 @@ function Be(t) {
483
485
  }).format(r);
484
486
  }
485
487
  export {
486
- Xe as default
488
+ Je as default
487
489
  };