laif-ds 0.2.12 → 0.2.14

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,8 +1,5 @@
1
1
  "use client";
2
- import { getDefaultExportFromCjs as e } from "./_commonjsHelpers.js";
3
- import { __require as r } from "../node_modules/extend/index.js";
4
- var t = r();
5
- const x = /* @__PURE__ */ e(t);
2
+ var e = { exports: {} };
6
3
  export {
7
- x as default
4
+ e as __module
8
5
  };
@@ -1,8 +1,8 @@
1
1
  "use client";
2
- import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
3
- import { __require as e } from "../node_modules/style-to-js/cjs/index.js";
4
- var t = e();
5
- const a = /* @__PURE__ */ r(t);
2
+ import { getDefaultExportFromCjs as e } from "./_commonjsHelpers.js";
3
+ import { __require as r } from "../node_modules/extend/index.js";
4
+ var t = r();
5
+ const x = /* @__PURE__ */ e(t);
6
6
  export {
7
- a as default
7
+ x as default
8
8
  };
@@ -1,5 +1,8 @@
1
1
  "use client";
2
- var e = { exports: {} };
2
+ import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
3
+ import { __require as e } from "../node_modules/style-to-js/cjs/index.js";
4
+ var t = e();
5
+ const a = /* @__PURE__ */ r(t);
3
6
  export {
4
- e as __module
7
+ a as default
5
8
  };
@@ -1,127 +1,140 @@
1
1
  "use client";
2
- import { jsxs as o, jsx as l, Fragment as _ } from "react/jsx-runtime";
3
- import { Badge as ee } from "./badge.js";
4
- import { Command as le, CommandInput as re, CommandList as te, CommandEmpty as ne, CommandGroup as M, CommandItem as k } from "./command.js";
5
- import { Label as ae } from "./label.js";
6
- import { cn as p } from "../../lib/utils.js";
2
+ import { jsxs as o, jsx as t, Fragment as te } from "react/jsx-runtime";
3
+ import { Badge as re } from "./badge.js";
4
+ import { Command as le, CommandInput as ne, CommandList as ae, CommandEmpty as se, CommandGroup as k, CommandItem as D } from "./command.js";
5
+ import { Label as oe } from "./label.js";
6
+ import { cn as g } from "../../lib/utils.js";
7
7
  import * as s from "react";
8
- import { Checkbox as se } from "./checkbox.js";
9
- import { Icon as D } from "./icon.js";
10
- import { Popover as oe, PopoverTrigger as ie, PopoverContent as de } from "./popover.js";
11
- import ce from "../../node_modules/lucide-react/dist/esm/icons/chevron-down.js";
12
- const ue = {
8
+ import { Checkbox as ie } from "./checkbox.js";
9
+ import { Icon as j } from "./icon.js";
10
+ import { Popover as de, PopoverTrigger as ce, PopoverContent as ue } from "./popover.js";
11
+ import me from "../../node_modules/lucide-react/dist/esm/icons/chevron-down.js";
12
+ const fe = {
13
13
  sm: "min-h-8 h-8 text-xs py-1.5",
14
14
  default: "min-h-9 h-9 text-sm py-2",
15
15
  lg: "min-h-10 h-10 text-base py-2"
16
- }, me = {
16
+ }, he = {
17
17
  sm: "h-5 w-5",
18
18
  default: "h-5 w-5",
19
19
  lg: "h-5.5 w-5.5"
20
20
  };
21
- function ye(j) {
21
+ function Se(B) {
22
22
  const {
23
23
  multiple: a = !1,
24
- options: m,
24
+ options: f,
25
25
  value: N,
26
- defaultValue: B,
27
- onValueChange: A,
28
- onClear: g,
29
- placeholder: R = "Seleziona...",
30
- emptyPlaceholder: E = "Nessun risultato",
31
- searchPlaceholder: F = "Cerca...",
32
- addItemPlaceholder: L = "Aggiungi",
33
- itemCountMessage: T = (e) => `${e} elementi selezionati`,
34
- maxSelectedMessage: W = (e) => `Puoi selezionare fino a ${e} elementi`,
26
+ defaultValue: A,
27
+ onValueChange: R,
28
+ onClear: b,
29
+ placeholder: E = "Seleziona...",
30
+ emptyPlaceholder: F = "Nessun risultato",
31
+ searchPlaceholder: L = "Cerca...",
32
+ addItemPlaceholder: T = "Aggiungi",
33
+ itemCountMessage: W = (e) => `${e} elementi selezionati`,
34
+ maxSelectedMessage: X = (e) => `Puoi selezionare fino a ${e} elementi`,
35
35
  label: S,
36
- className: X = "",
37
- wrpClassName: $ = "",
36
+ className: $ = "",
37
+ wrpClassName: q = "",
38
38
  searchable: P = !1,
39
- creatable: q = !1,
40
- groupBy: b = "group",
39
+ creatable: G = !1,
40
+ groupBy: v = "group",
41
41
  maxSelected: i,
42
- showChipsInsteadOfCount: G = !1,
43
- disabled: v,
42
+ showChipsInsteadOfCount: H = !1,
43
+ disabled: x,
44
44
  size: V = "default"
45
- } = j, [x, C] = s.useState(!1), [d, w] = s.useState(""), y = s.useRef(null), [H, J] = s.useState(0), z = N !== void 0, [K, Q] = s.useState(B), c = z ? N : K, u = (e) => {
46
- z || Q(e), A?.(e);
47
- }, t = s.useMemo(() => a ? Array.isArray(c) ? c : [] : c != null ? [c] : [], [c, a]), h = s.useMemo(() => {
48
- const e = m.filter((n) => t.includes(n.value));
45
+ } = B, [C, w] = s.useState(!1), [d, y] = s.useState(""), c = s.useRef(null), [J, K] = s.useState(0), [Q, z] = s.useState(null);
46
+ s.useEffect(() => {
47
+ if (c.current) {
48
+ const e = c.current.closest(
49
+ '[data-slot="drawer-content"]'
50
+ );
51
+ e && z(e);
52
+ const l = c.current.closest(
53
+ '[data-slot="sheet-content"]'
54
+ );
55
+ l && z(l);
56
+ }
57
+ }, []);
58
+ const O = N !== void 0, [U, Y] = s.useState(A), u = O ? N : U, m = (e) => {
59
+ O || Y(e), R?.(e);
60
+ }, n = s.useMemo(() => a ? Array.isArray(u) ? u : [] : u != null ? [u] : [], [u, a]), p = s.useMemo(() => {
61
+ const e = f.filter((l) => n.includes(l.value));
49
62
  if (a) {
50
- const n = t.filter((r) => !e.find((f) => f.value === r)).map((r) => ({ value: r, label: r }));
51
- return [...e, ...n];
52
- } else if (t.length && !e.length)
53
- return [{ value: t[0], label: t[0] }];
63
+ const l = n.filter((r) => !e.find((h) => h.value === r)).map((r) => ({ value: r, label: r }));
64
+ return [...e, ...l];
65
+ } else if (n.length && !e.length)
66
+ return [{ value: n[0], label: n[0] }];
54
67
  return e;
55
- }, [m, t, a]), O = (e) => {
68
+ }, [f, n, a]), I = (e) => {
56
69
  if (!e.disabled)
57
70
  if (a) {
58
- const n = t.includes(e.value);
59
- if (!n && i !== void 0 && t.length >= i)
71
+ const l = n.includes(e.value);
72
+ if (!l && i !== void 0 && n.length >= i)
60
73
  return;
61
- u(
62
- n ? t.filter((r) => r !== e.value) : [...t, e.value]
74
+ m(
75
+ l ? n.filter((r) => r !== e.value) : [...n, e.value]
63
76
  );
64
77
  } else
65
- u(e.value), C(!1);
66
- }, U = s.useCallback(() => {
67
- u([]), w(""), g && g();
68
- }, [u, g]), Y = s.useMemo(() => b ? m.reduce(
69
- (e, n) => {
70
- const r = n[b] || "";
71
- return e[r] = e[r] || [], e[r].push(n), e;
78
+ m(e.value), w(!1);
79
+ }, Z = s.useCallback(() => {
80
+ m([]), y(""), b && b();
81
+ }, [m, b]), _ = s.useMemo(() => v ? f.reduce(
82
+ (e, l) => {
83
+ const r = l[v] || "";
84
+ return e[r] = e[r] || [], e[r].push(l), e;
72
85
  },
73
86
  {}
74
- ) : { "": m }, [m, b]);
87
+ ) : { "": f }, [f, v]);
75
88
  return s.useEffect(() => {
76
- x && y.current && J(y.current.getBoundingClientRect().width);
77
- }, [x]), /* @__PURE__ */ o("div", { className: p("flex flex-col gap-2", $), children: [
78
- S && /* @__PURE__ */ l(ae, { children: S }),
89
+ C && c.current && K(c.current.getBoundingClientRect().width);
90
+ }, [C]), /* @__PURE__ */ o("div", { className: g("flex flex-col gap-2", q), children: [
91
+ S && /* @__PURE__ */ t(oe, { children: S }),
79
92
  /* @__PURE__ */ o(
80
- oe,
93
+ de,
81
94
  {
82
- open: v ? !1 : x,
83
- onOpenChange: (e) => !v && C(e),
95
+ open: x ? !1 : C,
96
+ onOpenChange: (e) => !x && w(e),
84
97
  children: [
85
- /* @__PURE__ */ l(ie, { asChild: !0, children: /* @__PURE__ */ o(
98
+ /* @__PURE__ */ t(ce, { asChild: !0, children: /* @__PURE__ */ o(
86
99
  "div",
87
100
  {
88
- ref: y,
89
- className: p(
101
+ ref: c,
102
+ className: g(
90
103
  "bg-d-input border-d-border/50 focus-within:ring-d-ring flex min-h-10 w-full min-w-[100px] items-center justify-between gap-2 rounded-md border px-3 py-2 text-sm focus-within:ring-1",
91
- ue[V],
92
- v && "cursor-not-allowed opacity-50",
93
- X
104
+ fe[V],
105
+ x && "cursor-not-allowed opacity-50",
106
+ $
94
107
  ),
95
108
  children: [
96
- h.length === 0 ? /* @__PURE__ */ l("span", { className: "text-d-muted-foreground", children: R }) : a ? /* @__PURE__ */ o("div", { className: "flex h-full w-full min-w-0 items-center justify-between gap-2", children: [
97
- /* @__PURE__ */ l("div", { className: "flex min-w-0 flex-nowrap gap-1 overflow-auto", children: G ? /* @__PURE__ */ l(_, { children: h.map((e) => /* @__PURE__ */ o(
98
- ee,
109
+ p.length === 0 ? /* @__PURE__ */ t("span", { className: "text-d-muted-foreground", children: E }) : a ? /* @__PURE__ */ o("div", { className: "flex h-full w-full min-w-0 items-center justify-between gap-2", children: [
110
+ /* @__PURE__ */ t("div", { className: "flex min-w-0 flex-nowrap gap-1 overflow-auto", children: H ? /* @__PURE__ */ t(te, { children: p.map((e) => /* @__PURE__ */ o(
111
+ re,
99
112
  {
100
113
  variant: "secondary",
101
114
  className: "hover:bg-d-secondary/100 bg-d-secondary/50 border-d-border flex cursor-pointer items-center gap-1 border",
102
- onClick: (n) => {
103
- n.stopPropagation(), O(e);
115
+ onClick: (l) => {
116
+ l.stopPropagation(), I(e);
104
117
  },
105
118
  children: [
106
119
  e.label,
107
- !e.fixed && /* @__PURE__ */ l(D, { name: "X", size: "xs" })
120
+ !e.fixed && /* @__PURE__ */ t(j, { name: "X", size: "xs" })
108
121
  ]
109
122
  },
110
123
  e.value
111
- )) }) : /* @__PURE__ */ l("div", { children: T(h.length) }) }),
112
- /* @__PURE__ */ l(
124
+ )) }) : /* @__PURE__ */ t("div", { children: W(p.length) }) }),
125
+ /* @__PURE__ */ t(
113
126
  "div",
114
127
  {
115
- className: p(
128
+ className: g(
116
129
  "border-d-input bg-d-accent flex aspect-square cursor-pointer items-center rounded-full p-1",
117
- me[V]
130
+ he[V]
118
131
  ),
119
132
  onClick: (e) => {
120
- e.stopPropagation(), e.preventDefault(), U();
133
+ e.stopPropagation(), e.preventDefault(), Z();
121
134
  },
122
135
  onMouseDown: (e) => e.preventDefault(),
123
- children: /* @__PURE__ */ l(
124
- D,
136
+ children: /* @__PURE__ */ t(
137
+ j,
125
138
  {
126
139
  name: "X",
127
140
  size: "xs",
@@ -130,67 +143,68 @@ function ye(j) {
130
143
  )
131
144
  }
132
145
  )
133
- ] }) : /* @__PURE__ */ l("span", { children: h[0]?.label }),
134
- /* @__PURE__ */ l(ce, { className: "h-4 w-4 opacity-50" })
146
+ ] }) : /* @__PURE__ */ t("span", { children: p[0]?.label }),
147
+ /* @__PURE__ */ t(me, { className: "h-4 w-4 opacity-50" })
135
148
  ]
136
149
  }
137
150
  ) }),
138
- /* @__PURE__ */ l(
139
- de,
151
+ /* @__PURE__ */ t(
152
+ ue,
140
153
  {
141
154
  className: "p-0",
142
- style: { width: H },
155
+ style: { width: J },
143
156
  align: "start",
144
157
  sideOffset: 4,
158
+ container: Q,
145
159
  children: /* @__PURE__ */ o(le, { shouldFilter: !!P, className: "w-full", children: [
146
- P && /* @__PURE__ */ l("div", { className: "border-d-border border-b p-0.5", children: /* @__PURE__ */ l(
147
- re,
160
+ P && /* @__PURE__ */ t("div", { className: "border-d-border border-b p-0.5", children: /* @__PURE__ */ t(
161
+ ne,
148
162
  {
149
- placeholder: F,
163
+ placeholder: L,
150
164
  value: d,
151
- onValueChange: w
165
+ onValueChange: y
152
166
  }
153
167
  ) }),
154
- /* @__PURE__ */ o(te, { className: "max-h-60 overflow-auto", children: [
155
- /* @__PURE__ */ l(ne, { children: E }),
156
- q && d && /* @__PURE__ */ l(M, { children: /* @__PURE__ */ l(
157
- k,
168
+ /* @__PURE__ */ o(ae, { className: "max-h-60 overflow-auto overscroll-contain", children: [
169
+ /* @__PURE__ */ t(se, { children: F }),
170
+ G && d && /* @__PURE__ */ t(k, { children: /* @__PURE__ */ t(
171
+ D,
158
172
  {
159
173
  className: "cursor-pointer",
160
174
  onSelect: () => {
161
- d && (u(a ? [...t, d] : d), w(""), !a && C(!1));
175
+ d && (m(a ? [...n, d] : d), y(""), !a && w(!1));
162
176
  },
163
177
  children: /* @__PURE__ */ o("div", { className: "text-d-foreground text-xs", children: [
164
- L,
178
+ T,
165
179
  " “",
166
180
  d,
167
181
  "”"
168
182
  ] })
169
183
  }
170
184
  ) }),
171
- Object.entries(Y).map(([e, n]) => /* @__PURE__ */ l(M, { heading: e || void 0, children: n.map((r) => {
172
- const f = t.includes(r.value), Z = a && i !== void 0 && !f && t.length >= i, I = r.disabled || Z;
185
+ Object.entries(_).map(([e, l]) => /* @__PURE__ */ t(k, { heading: e || void 0, children: l.map((r) => {
186
+ const h = n.includes(r.value), ee = a && i !== void 0 && !h && n.length >= i, M = r.disabled || ee;
173
187
  return /* @__PURE__ */ o(
174
- k,
188
+ D,
175
189
  {
176
190
  value: typeof r.label == "string" ? r.label : String(r.value),
177
- onSelect: () => !I && O(r),
178
- className: p(
191
+ onSelect: () => !M && I(r),
192
+ className: g(
179
193
  "cursor-pointer",
180
- I && "cursor-not-allowed opacity-50",
181
- !a && f && "bg-d-accent/75 text-d-accent-foreground"
194
+ M && "cursor-not-allowed opacity-50",
195
+ !a && h && "bg-d-accent/75 text-d-accent-foreground"
182
196
  // highlight single select
183
197
  ),
184
198
  children: [
185
- a && /* @__PURE__ */ l(se, { checked: f, className: "mr-1" }),
186
- /* @__PURE__ */ l("span", { children: r.label })
199
+ a && /* @__PURE__ */ t(ie, { checked: h, className: "mr-1" }),
200
+ /* @__PURE__ */ t("span", { children: r.label })
187
201
  ]
188
202
  },
189
203
  r.value
190
204
  );
191
205
  }) }, e))
192
206
  ] }),
193
- a && i !== void 0 && t.length >= i && /* @__PURE__ */ l("div", { className: "border-d-border text-d-muted-foreground border-t px-2 py-1 text-xs", children: W(i) })
207
+ a && i !== void 0 && n.length >= i && /* @__PURE__ */ t("div", { className: "border-d-border text-d-muted-foreground border-t px-2 py-1 text-xs", children: X(i) })
194
208
  ] })
195
209
  }
196
210
  )
@@ -200,5 +214,5 @@ function ye(j) {
200
214
  ] });
201
215
  }
202
216
  export {
203
- ye as AppSelect
217
+ Se as AppSelect
204
218
  };
@@ -4,8 +4,8 @@ import * as l from "react";
4
4
  import k from "../../node_modules/embla-carousel-react/esm/embla-carousel-react.esm.js";
5
5
  import { cn as d } from "../../lib/utils.js";
6
6
  import { Button as v } from "./button.js";
7
- import z from "../../node_modules/lucide-react/dist/esm/icons/arrow-left.js";
8
- import g from "../../node_modules/lucide-react/dist/esm/icons/arrow-right.js";
7
+ import z from "../../node_modules/lucide-react/dist/esm/icons/arrow-right.js";
8
+ import g from "../../node_modules/lucide-react/dist/esm/icons/arrow-left.js";
9
9
  const p = l.createContext(null);
10
10
  function m() {
11
11
  const o = l.useContext(p);
@@ -136,7 +136,7 @@ function q({
136
136
  onClick: i,
137
137
  ...s,
138
138
  children: [
139
- /* @__PURE__ */ a(z, {}),
139
+ /* @__PURE__ */ a(g, {}),
140
140
  /* @__PURE__ */ a("span", { className: "sr-only", children: "Previous slide" })
141
141
  ]
142
142
  }
@@ -164,7 +164,7 @@ function F({
164
164
  onClick: i,
165
165
  ...s,
166
166
  children: [
167
- /* @__PURE__ */ a(g, {}),
167
+ /* @__PURE__ */ a(z, {}),
168
168
  /* @__PURE__ */ a("span", { className: "sr-only", children: "Next slide" })
169
169
  ]
170
170
  }
@@ -2,8 +2,8 @@
2
2
  import { jsx as s, jsxs as f, Fragment as L } from "react/jsx-runtime";
3
3
  import * as p from "react";
4
4
  import { cn as l } from "../../lib/utils.js";
5
- import { Tooltip as T } from "../../node_modules/recharts/es6/component/Tooltip.js";
6
- import { Legend as I } from "../../node_modules/recharts/es6/component/Legend.js";
5
+ import { Legend as T } from "../../node_modules/recharts/es6/component/Legend.js";
6
+ import { Tooltip as I } from "../../node_modules/recharts/es6/component/Tooltip.js";
7
7
  import { ResponsiveContainer as K } from "../../node_modules/recharts/es6/component/ResponsiveContainer.js";
8
8
  const P = { light: "", dark: ".dark" }, N = p.createContext(null);
9
9
  function j() {
@@ -60,7 +60,7 @@ ${t.map(([d, o]) => {
60
60
  }
61
61
  }
62
62
  ) : null;
63
- }, z = T;
63
+ }, z = I;
64
64
  function A({
65
65
  active: c,
66
66
  payload: e,
@@ -155,7 +155,7 @@ function A({
155
155
  }
156
156
  );
157
157
  }
158
- const B = I;
158
+ const B = T;
159
159
  function D({
160
160
  className: c,
161
161
  hideIcon: e = !1,
@@ -18,7 +18,7 @@ const m = c.forwardRef(({ className: e, ...t }, r) => /* @__PURE__ */ o(
18
18
  }
19
19
  ));
20
20
  m.displayName = "Command";
21
- function v({
21
+ function y({
22
22
  title: e = "Command Palette",
23
23
  description: t = "Search for a command to run...",
24
24
  children: r,
@@ -67,7 +67,7 @@ function N({
67
67
  {
68
68
  "data-slot": "command-list",
69
69
  className: a(
70
- "max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",
70
+ "max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto overscroll-contain",
71
71
  e
72
72
  ),
73
73
  ...t
@@ -149,7 +149,7 @@ function I({
149
149
  }
150
150
  export {
151
151
  m as Command,
152
- v as CommandDialog,
152
+ y as CommandDialog,
153
153
  b as CommandEmpty,
154
154
  C as CommandGroup,
155
155
  w as CommandInput,
@@ -0,0 +1,170 @@
1
+ "use client";
2
+ import { jsx as t, jsxs as T } from "react/jsx-runtime";
3
+ import { createAsk as j } from "../../node_modules/use-ask/dist/index.js";
4
+ import { Dialog as U, DialogContent as O, DialogHeader as E, DialogTitle as L, DialogDescription as k } from "./dialog.js";
5
+ import { Icon as C } from "./icon.js";
6
+ import { getExt as M, guessKind as S, isHttpUrl as A, getOfficeEmbedUrl as z } from "../../lib/file-preview.js";
7
+ import { cn as H } from "../../lib/utils.js";
8
+ import { useRef as q, useState as x, useEffect as N, useMemo as g } from "react";
9
+ const [R, B] = j({});
10
+ function D(r) {
11
+ return typeof r == "string" ? { url: r } : r instanceof File ? { file: r, filename: r.name, mimeType: r.type } : typeof r == "function" ? { loader: r } : r && typeof r.then == "function" ? { loader: r } : r || {};
12
+ }
13
+ async function _(r) {
14
+ return R.ask(D(r));
15
+ }
16
+ function $(r) {
17
+ return R.safeAsk(D(r));
18
+ }
19
+ function I(r, s, a) {
20
+ const n = q(null), [d, u] = x(!1), [v, m] = x(null), [y, c] = x(null), [e, p] = x({});
21
+ N(() => {
22
+ if (!s) {
23
+ p({}), u(!1), m(null);
24
+ return;
25
+ }
26
+ const i = r || {};
27
+ p({
28
+ url: i.url,
29
+ file: i.file,
30
+ filename: i.filename,
31
+ mimeType: i.mimeType,
32
+ title: i.title
33
+ });
34
+ const o = i.loader;
35
+ if (!o) return;
36
+ let f = !1;
37
+ return u(!0), m(null), (async () => {
38
+ try {
39
+ const l = typeof o == "function" ? await o() : await o;
40
+ if (f) return;
41
+ typeof l == "string" ? p((h) => ({ ...h, url: l })) : l instanceof File ? p((h) => ({
42
+ ...h,
43
+ file: l,
44
+ filename: l.name,
45
+ mimeType: l.type
46
+ })) : l && typeof l == "object" && p((h) => ({ ...h, ...l }));
47
+ } catch (l) {
48
+ f || m(l?.message || "Errore durante il caricamento della preview");
49
+ } finally {
50
+ f || u(!1);
51
+ }
52
+ })(), () => {
53
+ f = !0;
54
+ };
55
+ }, [s, a, r]), N(() => {
56
+ if (e.file) {
57
+ const i = URL.createObjectURL(e.file);
58
+ return n.current = i, () => {
59
+ n.current && (URL.revokeObjectURL(n.current), n.current = null);
60
+ };
61
+ }
62
+ }, [e.file]);
63
+ const F = g(
64
+ () => e.file ? n.current || void 0 : e.url,
65
+ [e.file, e.url]
66
+ ), w = g(
67
+ () => e.filename || e.file?.name || M(e.url || "") || "document",
68
+ [e.filename, e.file, e.url]
69
+ ), b = g(
70
+ () => S({
71
+ mimeType: e.mimeType,
72
+ filename: w,
73
+ url: e.url
74
+ }),
75
+ [e.mimeType, w, e.url]
76
+ );
77
+ N(() => {
78
+ if (c(null), b === "text")
79
+ if (e.file) {
80
+ const i = new FileReader();
81
+ i.onload = (o) => {
82
+ if (typeof o.target?.result == "string") {
83
+ const f = o.target.result.length > 2e5 ? o.target.result.slice(0, 2e5) + `
84
+ …` : o.target.result;
85
+ c(f);
86
+ }
87
+ }, i.readAsText(e.file);
88
+ } else e.url && A(e.url) ? fetch(e.url).then((i) => i.text()).then(
89
+ (i) => c(i.length > 2e5 ? i.slice(0, 2e5) + `
90
+ …` : i)
91
+ ).catch(() => c("Anteprima non disponibile")) : c("Anteprima non disponibile");
92
+ }, [b, e.file, e.url, a]);
93
+ const P = g(
94
+ () => /* @__PURE__ */ T("span", { className: "flex items-center gap-2", children: [
95
+ /* @__PURE__ */ t(C, { name: "File", className: "h-4 w-4" }),
96
+ r?.title || e.title || w
97
+ ] }),
98
+ [r, e.title, w]
99
+ );
100
+ return { loading: d, error: v, src: F, text: y, kind: b, title: P };
101
+ }
102
+ const ee = () => {
103
+ const [{ key: r, payload: s }, { asking: a, cancel: n }] = B(), { loading: d, error: u, src: v, text: m, kind: y, title: c } = I(
104
+ s,
105
+ a,
106
+ r
107
+ );
108
+ return /* @__PURE__ */ t(U, { open: a, onOpenChange: (e) => !e && n(), children: /* @__PURE__ */ T(O, { size: "xl", className: "sm:max-w-4xl", children: [
109
+ /* @__PURE__ */ T(E, { children: [
110
+ /* @__PURE__ */ t(L, { children: c }),
111
+ u ? /* @__PURE__ */ t(k, { className: "text-red-600", children: u }) : null
112
+ ] }),
113
+ /* @__PURE__ */ t("div", { className: H("relative", "max-h-[80vh] overflow-auto p-1"), children: d ? /* @__PURE__ */ t("div", { className: "grid h-[60vh] place-items-center", children: /* @__PURE__ */ t("div", { className: "border-d-border border-t-d-foreground h-10 w-10 animate-spin rounded-full border-2" }) }) : /* @__PURE__ */ t(K, { kind: y, src: v, text: m, officeUrl: v }) })
114
+ ] }) });
115
+ }, K = ({
116
+ kind: r,
117
+ src: s,
118
+ text: a,
119
+ officeUrl: n
120
+ }) => {
121
+ if (!s && r !== "text" && r !== "office")
122
+ return /* @__PURE__ */ t("div", { className: "text-d-secondary-foreground", children: "Nessuna sorgente disponibile" });
123
+ switch (r) {
124
+ case "image":
125
+ return /* @__PURE__ */ t("div", { className: "grid place-items-center", children: /* @__PURE__ */ t(
126
+ "img",
127
+ {
128
+ src: s,
129
+ alt: "preview",
130
+ className: "max-h-[78vh] w-auto max-w-full object-contain"
131
+ }
132
+ ) });
133
+ case "pdf":
134
+ return /* @__PURE__ */ t(
135
+ "iframe",
136
+ {
137
+ src: s,
138
+ title: "PDF Preview",
139
+ className: "h-[78vh] w-full rounded"
140
+ }
141
+ );
142
+ case "audio":
143
+ return /* @__PURE__ */ t("div", { className: "grid place-items-center", children: /* @__PURE__ */ t("audio", { controls: !0, className: "w-full max-w-2xl", children: /* @__PURE__ */ t("source", { src: s }) }) });
144
+ case "video":
145
+ return /* @__PURE__ */ t("div", { className: "grid place-items-center", children: /* @__PURE__ */ t("video", { controls: !0, className: "max-h-[78vh] w-full max-w-3xl rounded", children: /* @__PURE__ */ t("source", { src: s }) }) });
146
+ case "text":
147
+ return /* @__PURE__ */ t("pre", { className: "max-h-[78vh] overflow-auto rounded border p-3 text-sm whitespace-pre-wrap", children: a || "Caricamento…" });
148
+ case "office": {
149
+ if (n && A(n)) {
150
+ const d = z(n);
151
+ return /* @__PURE__ */ t(
152
+ "iframe",
153
+ {
154
+ src: d,
155
+ title: "Office Preview",
156
+ className: "h-[78vh] w-full rounded"
157
+ }
158
+ );
159
+ }
160
+ return /* @__PURE__ */ t("div", { className: "rounded border p-3 text-sm", children: 'Anteprima Office non disponibile per file locali. Usa "Apri in nuova scheda" o "Download".' });
161
+ }
162
+ default:
163
+ return /* @__PURE__ */ t("div", { className: "rounded border p-3 text-sm", children: "Anteprima non disponibile per questo tipo di file." });
164
+ }
165
+ };
166
+ export {
167
+ ee as FilePreviewer,
168
+ _ as previewFileModal,
169
+ $ as safePreviewFileModal
170
+ };