@seedprotocol/react 0.4.21 → 0.4.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,51 +1,51 @@
1
- import Oe, { createContext as Xe, useContext as Ze, useState as S, useCallback as x, useEffect as I, useRef as D, useMemo as F, useLayoutEffect as et } from "react";
2
- import { flushSync as de } from "react-dom";
3
- import { getClient as me, ClientManagerState as C, eventEmitter as K, BaseDb as W, Item as _e, getAddressesForItemsFilter as tt, seeds as A, getVersionData as rt, createNewItem as nt, ItemProperty as se, metadata as T, appState as ue, Schema as he, schemas as Y, loadAllSchemasFromDb as st, SEED_PROTOCOL_SCHEMA_NAME as ot, Model as oe, models as ae, modelSchemas as be, ModelProperty as fe, properties as ee, getPropertySchema as Ue, getSchemaNameFromId as it, BaseFileManager as j, client as at, resolveMediaRef as lt, normalizeFeedItemFields as ct } from "@seedprotocol/sdk";
4
- import { orderBy as dt, debounce as ze, startCase as Ce } from "lodash-es";
1
+ import qe, { createContext as rt, useContext as nt, useState as S, useCallback as x, useEffect as w, useRef as C, useMemo as N, useLayoutEffect as st } from "react";
2
+ import { flushSync as ue } from "react-dom";
3
+ import { getClient as ge, ClientManagerState as P, eventEmitter as z, BaseDb as j, Item as Ce, EAS_SEED_DATA_SYNCED_TO_DB_EVENT as ne, getAddressesForItemsFilter as ot, seeds as D, getVersionData as it, createNewItem as at, ItemProperty as ie, metadata as k, appState as fe, Schema as be, schemas as X, loadAllSchemasFromDb as ct, SEED_PROTOCOL_SCHEMA_NAME as lt, Model as ae, models as ce, modelSchemas as ve, ModelProperty as ye, properties as te, getPropertySchema as ze, getSchemaNameFromId as dt, BaseFileManager as W, easSyncProcesses as pe, client as ut, resolveMediaRef as ft, normalizeFeedItemFields as yt } from "@seedprotocol/sdk";
4
+ import { orderBy as pt, debounce as He, startCase as Pe } from "lodash-es";
5
5
  import G from "debug";
6
- import { useSelector as Ie } from "@xstate/react";
7
- import { jsx as h, jsxs as O, Fragment as ge } from "react/jsx-runtime";
8
- import { or as te, isNull as le, eq as U, inArray as Re, sql as ut, isNotNull as Ee, and as Le, gt as ft, like as qe, desc as pt } from "drizzle-orm";
9
- import { toSnakeCase as yt } from "drizzle-orm/casing";
10
- import { useQueryClient as X, useQuery as Z, QueryClient as mt, QueryClientProvider as ht } from "@tanstack/react-query";
11
- import gt from "pluralize";
12
- const q = () => {
13
- const t = me().getService();
14
- return Ie(t, (n) => n.value === C.IDLE);
15
- }, Pe = "addresses.persisted", He = Xe(0);
16
- function Qe() {
17
- return Ze(He);
6
+ import { useSelector as Le } from "@xstate/react";
7
+ import { jsx as g, jsxs as U, Fragment as Se } from "react/jsx-runtime";
8
+ import { or as re, isNull as le, eq as q, inArray as Te, sql as mt, isNotNull as Ae, and as xe, gt as ht, like as Qe, desc as Ve } from "drizzle-orm";
9
+ import { toSnakeCase as gt } from "drizzle-orm/casing";
10
+ import { useQueryClient as Z, useQuery as ee, QueryClient as bt, QueryClientProvider as St } from "@tanstack/react-query";
11
+ import vt from "pluralize";
12
+ const Q = () => {
13
+ const t = ge().getService();
14
+ return Le(t, (n) => n.value === P.IDLE);
15
+ }, Me = "addresses.persisted", Ke = rt(0);
16
+ function je() {
17
+ return nt(Ke);
18
18
  }
19
- function bt({
19
+ function wt({
20
20
  queryClient: e,
21
21
  children: t
22
22
  }) {
23
23
  const [r, n] = S(0), o = x(() => {
24
24
  e.invalidateQueries({ queryKey: ["seed", "items"], exact: !1 }), n((a) => a + 1);
25
25
  }, [e]);
26
- return I(() => (K.on(Pe, o), () => {
27
- K.off(Pe, o);
28
- }), [o]), /* @__PURE__ */ h(He.Provider, { value: r, children: t });
26
+ return w(() => (z.on(Me, o), () => {
27
+ z.off(Me, o);
28
+ }), [o]), /* @__PURE__ */ g(Ke.Provider, { value: r, children: t });
29
29
  }
30
- function ie(e) {
31
- const [t, r] = S(void 0), n = D(null), o = q(), a = F(() => {
30
+ function Y(e) {
31
+ const [t, r] = S(void 0), n = C(null), o = Q(), a = N(() => {
32
32
  if (!o || !e)
33
33
  return null;
34
34
  try {
35
- return W.liveQuery(e);
35
+ return j.liveQuery(e);
36
36
  } catch (s) {
37
37
  return console.error("[useLiveQuery] Failed to create live query:", s), null;
38
38
  }
39
39
  }, [e, o]);
40
- return I(() => {
40
+ return w(() => {
41
41
  if (n.current && (n.current.unsubscribe(), n.current = null), !a)
42
42
  return;
43
43
  const s = a.subscribe({
44
- next: (l) => {
45
- r(l !== void 0 ? [...l] : void 0);
44
+ next: (c) => {
45
+ r(c !== void 0 ? [...c] : void 0);
46
46
  },
47
- error: (l) => {
48
- console.error("[useLiveQuery] Error:", l);
47
+ error: (c) => {
48
+ console.error("[useLiveQuery] Error:", c);
49
49
  }
50
50
  });
51
51
  return n.current = s, () => {
@@ -53,54 +53,63 @@ function ie(e) {
53
53
  };
54
54
  }, [a]), t;
55
55
  }
56
- const pe = G("seedSdk:react:item"), dr = ({ modelName: e, seedLocalId: t, seedUid: r }) => {
57
- const [n, o] = S(), [a, s] = S(!!(t || r)), [l, c] = S(null), i = D(void 0), d = D(!1), u = q(), f = Qe(), g = D(e), v = D(t), b = D(r), y = F(() => u ? !!(v.current || b.current) : !1, [u, t, r]), p = x(async () => {
58
- if (!!!(u && (v.current || b.current))) {
59
- o(void 0), s(!1), c(null);
56
+ const me = G("seedSdk:react:item"), pr = ({ modelName: e, seedLocalId: t, seedUid: r }) => {
57
+ const [n, o] = S(), [, a] = S(0), [s, c] = S(!!(t || r)), [l, i] = S(null), d = C(void 0), u = C(!1), f = Q(), b = je(), v = C(e), h = C(t), y = C(r), p = N(() => f ? !!(h.current || y.current) : !1, [f, t, r]), E = x(async () => {
58
+ if (!!!(f && (h.current || y.current))) {
59
+ o(void 0), c(!1), i(null);
60
60
  return;
61
61
  }
62
62
  try {
63
- c(null);
64
- const w = await _e.find({
65
- modelName: g.current,
66
- seedLocalId: v.current,
67
- seedUid: b.current
63
+ i(null);
64
+ const _ = await Ce.find({
65
+ modelName: v.current,
66
+ seedLocalId: h.current,
67
+ seedUid: y.current
68
68
  });
69
- if (!w) {
70
- pe("[useItem] [loadItem] no item found", g.current, v.current), o((m) => m && (m.seedLocalId && m.seedLocalId === v.current || m.seedUid && m.seedUid === b.current) ? m : void 0), s(!1), c(null);
69
+ if (!_) {
70
+ me("[useItem] [loadItem] no item found", v.current, h.current), o((R) => R && (R.seedLocalId && R.seedLocalId === h.current || R.seedUid && R.seedUid === y.current) ? R : void 0), c(!1), i(null);
71
71
  return;
72
72
  }
73
- o(w), s(!1), c(null);
74
- } catch (w) {
75
- pe("[useItem] Error loading item:", w), o(void 0), s(!1), c(w);
73
+ o(_), c(!1), i(null);
74
+ } catch (_) {
75
+ me("[useItem] Error loading item:", _), o(void 0), c(!1), i(_);
76
76
  }
77
- }, [u]);
78
- return I(() => {
79
- g.current = e, v.current = t, b.current = r;
80
- }, [e, t, r]), I(() => {
81
- if (!y) {
82
- !t && !r && (o(void 0), s(!1), c(null));
77
+ }, [f]), I = C(E);
78
+ return w(() => {
79
+ I.current = E;
80
+ }, [E]), w(() => {
81
+ v.current = e, h.current = t, y.current = r;
82
+ }, [e, t, r]), w(() => {
83
+ const m = () => {
84
+ a((_) => _ + 1), I.current();
85
+ };
86
+ return z.on(ne, m), () => {
87
+ z.off(ne, m);
88
+ };
89
+ }, []), w(() => {
90
+ if (!p) {
91
+ !t && !r && (o(void 0), c(!1), i(null));
83
92
  return;
84
93
  }
85
- p();
86
- }, [y, p, t, r, f]), I(() => {
94
+ E();
95
+ }, [p, E, t, r, b]), w(() => {
87
96
  if (!n) {
88
- i.current?.unsubscribe(), i.current = void 0, d.current = !1;
97
+ d.current?.unsubscribe(), d.current = void 0, u.current = !1;
89
98
  return;
90
99
  }
91
- i.current?.unsubscribe(), d.current = !1;
92
- const w = n.getService().subscribe((m) => {
93
- m && typeof m == "object" && "value" in m && (m.value === "idle" ? (d.current = !0, s(!1), c(null)) : m.value === "error" ? (c(new Error("Item service error")), s(!1)) : d.current && s(!0));
100
+ d.current?.unsubscribe(), u.current = !1;
101
+ const _ = n.getService().subscribe((R) => {
102
+ R && typeof R == "object" && "value" in R && (R.value === "idle" ? (u.current = !0, c(!1), i(null)) : R.value === "error" ? (i(new Error("Item service error")), c(!1)) : u.current && c(!0));
94
103
  });
95
- return i.current = w, () => {
96
- i.current?.unsubscribe(), i.current = void 0;
104
+ return d.current = _, () => {
105
+ d.current?.unsubscribe(), d.current = void 0;
97
106
  };
98
107
  }, [n]), {
99
108
  item: n,
100
- isLoading: a,
109
+ isLoading: s,
101
110
  error: l
102
111
  };
103
- }, vt = (e, t, r, n, o) => [
112
+ }, It = (e, t, r, n, o) => [
104
113
  "seed",
105
114
  "items",
106
115
  e ?? null,
@@ -108,129 +117,143 @@ const pe = G("seedSdk:react:item"), dr = ({ modelName: e, seedLocalId: t, seedUi
108
117
  r ?? !1,
109
118
  n ?? null,
110
119
  o ?? 0
111
- ], ur = ({
120
+ ], mr = ({
112
121
  modelName: e,
113
122
  deleted: t = !1,
114
123
  includeEas: r = !1,
115
124
  addressFilter: n
116
125
  }) => {
117
- const o = q(), a = Qe(), s = X(), l = D([]), c = D(/* @__PURE__ */ new Set()), i = D(!1), [d, u] = S(null);
118
- I(() => {
126
+ const o = Q(), a = je(), s = Z();
127
+ w(() => {
128
+ const I = () => {
129
+ s.invalidateQueries({ queryKey: ["seed", "items"] });
130
+ };
131
+ return z.on(ne, I), () => {
132
+ z.off(ne, I);
133
+ };
134
+ }, [s]);
135
+ const c = C([]), l = C(/* @__PURE__ */ new Set()), i = C(!1), [d, u] = S(null);
136
+ w(() => {
119
137
  if (n !== "owned" && n !== "watched") {
120
138
  u(null);
121
139
  return;
122
140
  }
123
- let w = !1;
124
- return tt(n).then((m) => {
125
- w || u(m);
141
+ let I = !1;
142
+ return ot(n).then((m) => {
143
+ I || u(m);
126
144
  }), () => {
127
- w = !0;
145
+ I = !0;
128
146
  };
129
147
  }, [n, a]);
130
- const f = F(
131
- () => vt(e, t, r, n, a),
148
+ const f = N(
149
+ () => It(e, t, r, n, a),
132
150
  [e, t, r, n, a]
133
151
  );
134
- I(() => {
152
+ w(() => {
135
153
  i.current = !1;
136
154
  }, [f]);
137
155
  const {
138
- data: g = [],
156
+ data: b = [],
139
157
  isLoading: v,
140
- error: b
141
- } = Z({
158
+ error: h
159
+ } = ee({
142
160
  queryKey: f,
143
- queryFn: () => _e.all(e, t, { waitForReady: !0, includeEas: r, addressFilter: n }),
161
+ queryFn: async () => await Ce.all(e, t, {
162
+ waitForReady: !0,
163
+ includeEas: r,
164
+ addressFilter: n
165
+ }),
144
166
  enabled: o,
145
167
  // Local SQLite + live invalidation drive freshness; Seed’s default staleTime would keep a
146
168
  // mistaken initial [] “fresh” and block refetch when another subscriber mounts.
147
169
  staleTime: 0
148
170
  });
149
- l.current = g;
150
- const y = o ? W.getAppDb() : null, p = F(() => {
171
+ c.current = b;
172
+ const y = o ? j.getAppDb() : null, p = N(() => {
151
173
  if (!y || (n === "owned" || n === "watched") && d === null)
152
174
  return null;
153
- const w = [];
154
- r || w.push(te(le(A.uid), U(A.uid, ""))), e && w.push(U(A.type, yt(e))), n === "owned" ? d && d.length > 0 && w.push(
155
- te(
156
- Re(A.publisher, d),
157
- le(A.publisher)
175
+ const I = [];
176
+ r || I.push(re(le(D.uid), q(D.uid, ""))), e && I.push(q(D.type, gt(e))), n === "owned" ? d && d.length > 0 && I.push(
177
+ re(
178
+ Te(D.publisher, d),
179
+ le(D.publisher)
158
180
  )
159
- ) : n === "watched" && (d && d.length > 0 ? w.push(Re(A.publisher, d)) : w.push(ut`1=0`)), t ? w.push(
160
- te(
161
- Ee(A._markedForDeletion),
162
- U(A._markedForDeletion, 1)
181
+ ) : n === "watched" && (d && d.length > 0 ? I.push(Te(D.publisher, d)) : I.push(mt`1=0`)), t ? I.push(
182
+ re(
183
+ Ae(D._markedForDeletion),
184
+ q(D._markedForDeletion, 1)
163
185
  )
164
- ) : (w.push(
165
- te(
166
- le(A._markedForDeletion),
167
- U(A._markedForDeletion, 0)
186
+ ) : (I.push(
187
+ re(
188
+ le(D._markedForDeletion),
189
+ q(D._markedForDeletion, 0)
168
190
  )
169
- ), w.push(
170
- te(le(A.revokedAt), U(A.revokedAt, 0))
191
+ ), I.push(
192
+ re(le(D.revokedAt), q(D.revokedAt, 0))
171
193
  ));
172
- const m = rt();
194
+ const m = it();
173
195
  return y.with(m).select({
174
- localId: A.localId,
175
- uid: A.uid,
176
- type: A.type,
177
- schemaUid: A.schemaUid,
178
- createdAt: A.createdAt,
179
- attestationCreatedAt: A.attestationCreatedAt,
180
- _markedForDeletion: A._markedForDeletion
181
- }).from(A).leftJoin(m, U(A.localId, m.seedLocalId)).where(Le(ft(m.versionsCount, 0), ...w)).groupBy(A.localId);
182
- }, [y, o, e, t, r, n, d]), E = ie(p);
183
- return I(() => {
196
+ localId: D.localId,
197
+ uid: D.uid,
198
+ type: D.type,
199
+ schemaUid: D.schemaUid,
200
+ createdAt: D.createdAt,
201
+ attestationCreatedAt: D.attestationCreatedAt,
202
+ _markedForDeletion: D._markedForDeletion
203
+ }).from(D).leftJoin(m, q(D.localId, m.seedLocalId)).where(xe(ht(m.versionsCount, 0), ...I)).groupBy(D.localId);
204
+ }, [y, o, e, t, r, n, d]), E = Y(p);
205
+ return w(() => {
184
206
  if (!o || !E) return;
185
- const w = /* @__PURE__ */ new Set();
186
- for (const N of E) {
187
- const $ = N.localId || N.uid;
188
- $ && w.add($);
207
+ const I = /* @__PURE__ */ new Set();
208
+ for (const A of E) {
209
+ const B = A.localId || A.uid;
210
+ B && I.add(B);
189
211
  }
190
212
  const m = /* @__PURE__ */ new Set();
191
- for (const N of l.current) {
192
- const $ = N.seedLocalId || N.seedUid;
193
- $ && m.add($);
213
+ for (const A of c.current) {
214
+ const B = A.seedLocalId || A.seedUid;
215
+ B && m.add(B);
194
216
  }
195
- if (w.size === 0 && m.size > 0) return;
196
- if (!i.current && (i.current = !0, w.size > 0 && m.size === 0)) {
197
- c.current = new Set(w), s.invalidateQueries({ queryKey: f });
217
+ if (I.size === 0 && m.size > 0)
218
+ return;
219
+ if (!i.current && (i.current = !0, I.size > 0 && m.size === 0)) {
220
+ l.current = new Set(I), s.invalidateQueries({ queryKey: f });
198
221
  return;
199
222
  }
200
- const P = c.current;
201
- if (P.size === w.size && [...P].every((N) => w.has(N)))
223
+ const _ = l.current;
224
+ if (_.size === I.size && [..._].every((A) => I.has(A)))
202
225
  return;
203
- if (m.size === w.size && [...m].every((N) => w.has(N))) {
204
- c.current = new Set(w);
226
+ if (m.size === I.size && [...m].every((A) => I.has(A))) {
227
+ l.current = new Set(I);
205
228
  return;
206
229
  }
207
- c.current = new Set(w), s.invalidateQueries({ queryKey: f });
230
+ l.current = new Set(I), s.invalidateQueries({ queryKey: f });
208
231
  }, [o, E, s, f]), {
209
- items: dt(
210
- g,
232
+ items: pt(
233
+ b,
211
234
  [
212
- (w) => w.lastVersionPublishedAt || w.attestationCreatedAt || w.createdAt
235
+ (I) => I.lastVersionPublishedAt || I.attestationCreatedAt || I.createdAt
213
236
  ],
214
237
  ["desc"]
215
238
  ),
216
239
  isLoading: v,
217
- error: b
240
+ error: h
218
241
  };
219
- }, fr = () => {
242
+ }, hr = () => {
220
243
  const [e, t] = S(!1), [r, n] = S(null), o = x(() => n(null), []);
221
244
  return {
222
245
  createItem: x(
223
- async (s, l) => {
246
+ async (s, c) => {
224
247
  if (e) {
225
- pe("[useCreateItem] [createItem] already creating item, skipping");
248
+ me("[useCreateItem] [createItem] already creating item, skipping");
226
249
  return;
227
250
  }
228
- n(null), de(() => t(!0));
251
+ n(null), ue(() => t(!0));
229
252
  try {
230
- const c = l ?? {}, { seedLocalId: i } = await nt({ modelName: s, ...c });
231
- return await _e.find({ modelName: s, seedLocalId: i }) ?? void 0;
232
- } catch (c) {
233
- pe("[useCreateItem] Error creating item:", c), n(c instanceof Error ? c : new Error(String(c)));
253
+ const l = c ?? {}, { seedLocalId: i } = await at({ modelName: s, ...l });
254
+ return await Ce.find({ modelName: s, seedLocalId: i }) ?? void 0;
255
+ } catch (l) {
256
+ me("[useCreateItem] Error creating item:", l), n(l instanceof Error ? l : new Error(String(l)));
234
257
  return;
235
258
  } finally {
236
259
  queueMicrotask(() => t(!1));
@@ -242,180 +265,180 @@ const pe = G("seedSdk:react:item"), dr = ({ modelName: e, seedLocalId: t, seedUi
242
265
  error: r,
243
266
  resetError: o
244
267
  };
245
- }, pr = () => {
246
- const [e, t] = S(null), [r, n] = S(!1), [o, a] = S(null), s = D(void 0), l = x(() => a(null), []), c = x((i) => {
268
+ }, gr = () => {
269
+ const [e, t] = S(null), [r, n] = S(!1), [o, a] = S(null), s = C(void 0), c = x(() => a(null), []), l = x((i) => {
247
270
  i && (t(i), a(null), i.publish().catch(() => {
248
271
  }));
249
272
  }, []);
250
- return I(() => {
273
+ return w(() => {
251
274
  if (!e) {
252
275
  s.current?.unsubscribe(), s.current = void 0, n(!1);
253
276
  return;
254
277
  }
255
278
  s.current?.unsubscribe();
256
279
  const i = e.getService(), d = i.subscribe((v) => {
257
- const b = v?.value, y = v?.context;
258
- n(b === "publishing");
280
+ const h = v?.value, y = v?.context;
281
+ n(h === "publishing");
259
282
  const p = y?._publishError;
260
283
  a(p ? new Error(p.message) : null);
261
284
  });
262
285
  s.current = d;
263
286
  const u = i.getSnapshot();
264
287
  n(u?.value === "publishing");
265
- const g = u?.context?._publishError;
266
- return a(g ? new Error(g.message) : null), () => {
288
+ const b = u?.context?._publishError;
289
+ return a(b ? new Error(b.message) : null), () => {
267
290
  s.current?.unsubscribe(), s.current = void 0;
268
291
  };
269
292
  }, [e]), {
270
- publishItem: c,
293
+ publishItem: l,
271
294
  isLoading: r,
272
295
  error: o,
273
- resetError: l
296
+ resetError: c
274
297
  };
275
- }, ye = G("seedSdk:react:property"), ne = G("seedSdk:react:itemProperties");
276
- function Ve(e, t) {
277
- const r = q(), [n, o] = S(void 0), [a, s] = S(!1), [l, c] = S(null), i = D(void 0), [, d] = S(0), f = typeof e == "object" && e != null ? e : null, g = f?.itemId, v = f?.seedLocalId, b = f?.seedUid, y = f?.propertyName, p = typeof e == "string" ? e : g !== void 0 && g !== "" ? g : void 0, w = y ?? (typeof e == "string" ? t : void 0), m = F(() => {
278
- const N = p !== void 0 && p !== "" ? p : v, $ = p !== void 0 && p !== "" ? void 0 : b;
279
- return (N != null || $ != null) && w != null && w !== "" ? {
298
+ }, he = G("seedSdk:react:property"), oe = G("seedSdk:react:itemProperties");
299
+ function We(e, t) {
300
+ const r = Q(), [n, o] = S(void 0), [a, s] = S(!1), [c, l] = S(null), i = C(void 0), [, d] = S(0), f = typeof e == "object" && e != null ? e : null, b = f?.itemId, v = f?.seedLocalId, h = f?.seedUid, y = f?.propertyName, p = typeof e == "string" ? e : b !== void 0 && b !== "" ? b : void 0, I = y ?? (typeof e == "string" ? t : void 0), m = N(() => {
301
+ const A = p !== void 0 && p !== "" ? p : v, B = p !== void 0 && p !== "" ? void 0 : h;
302
+ return (A != null || B != null) && I != null && I !== "" ? {
280
303
  type: "identifiers",
281
- seedLocalId: N ?? void 0,
282
- seedUid: $,
283
- propertyName: w
304
+ seedLocalId: A ?? void 0,
305
+ seedUid: B,
306
+ propertyName: I
284
307
  } : null;
285
- }, [p, w, v, b]);
286
- F(() => m ? !!((m.seedLocalId || m.seedUid) && m.propertyName) : !1, [m]);
287
- const P = F(() => !r || !m ? !1 : !!((m.seedLocalId || m.seedUid) && m.propertyName), [r, m]);
288
- et(() => {
289
- P && s(!0);
290
- }, [P]);
291
- const H = x(async () => {
308
+ }, [p, I, v, h]);
309
+ N(() => m ? !!((m.seedLocalId || m.seedUid) && m.propertyName) : !1, [m]);
310
+ const _ = N(() => !r || !m ? !1 : !!((m.seedLocalId || m.seedUid) && m.propertyName), [r, m]);
311
+ st(() => {
312
+ _ && s(!0);
313
+ }, [_]);
314
+ const R = x(async () => {
292
315
  if (!r || !m) {
293
- o(void 0), s(!1), c(null);
316
+ o(void 0), s(!1), l(null);
294
317
  return;
295
318
  }
296
319
  try {
297
- s(!0), c(null);
298
- const N = m.seedLocalId, $ = m.seedUid;
299
- if (!N && !$) {
300
- o(void 0), s(!1), c(null);
320
+ s(!0), l(null);
321
+ const A = m.seedLocalId, B = m.seedUid;
322
+ if (!A && !B) {
323
+ o(void 0), s(!1), l(null);
301
324
  return;
302
325
  }
303
- const Q = await se.find({
326
+ const V = await ie.find({
304
327
  propertyName: m.propertyName,
305
- seedLocalId: N,
306
- seedUid: $
328
+ seedLocalId: A,
329
+ seedUid: B
307
330
  });
308
- if (!Q) {
309
- ye(
310
- `[useItemProperty] [updateItemProperty] no property found for Item.${N || $}.${m.propertyName}`
311
- ), o(void 0), s(!1), c(null);
331
+ if (!V) {
332
+ he(
333
+ `[useItemProperty] [updateItemProperty] no property found for Item.${A || B}.${m.propertyName}`
334
+ ), o(void 0), s(!1), l(null);
312
335
  return;
313
336
  }
314
- o(Q), s(!1), c(null);
315
- } catch (N) {
316
- ye("[useItemProperty] Error updating item property:", N), o(void 0), s(!1), c(N);
337
+ o(V), s(!1), l(null);
338
+ } catch (A) {
339
+ he("[useItemProperty] Error updating item property:", A), o(void 0), s(!1), l(A);
317
340
  }
318
341
  }, [r, m]);
319
- return I(() => {
320
- if (!P) {
321
- o(void 0), s(!1), c(null);
342
+ return w(() => {
343
+ if (!_) {
344
+ o(void 0), s(!1), l(null);
322
345
  return;
323
346
  }
324
- n && m && n.propertyName === m.propertyName && (m.seedLocalId != null && n.seedLocalId === m.seedLocalId || m.seedUid != null && n.seedUid === m.seedUid) || H();
325
- }, [P, H, n, m]), I(() => {
347
+ n && m && n.propertyName === m.propertyName && (m.seedLocalId != null && n.seedLocalId === m.seedLocalId || m.seedUid != null && n.seedUid === m.seedUid) || R();
348
+ }, [_, R, n, m]), w(() => {
326
349
  if (!n) {
327
350
  i.current?.unsubscribe(), i.current = void 0;
328
351
  return;
329
352
  }
330
353
  i.current?.unsubscribe();
331
- let N = 0, $ = !1, Q;
332
- const L = 50, k = n.getService().subscribe((_) => {
333
- if (_ && typeof _ == "object" && "value" in _ && _.value === "idle") {
334
- s(!1), c(null);
335
- const M = _.context, J = JSON.stringify([M.renderValue, M.propertyValue]);
336
- (!$ || J !== Q) && ($ = !0, Q = J, d((re) => re + 1));
354
+ let A = 0, B = !1, V;
355
+ const L = 50, $ = n.getService().subscribe((F) => {
356
+ if (F && typeof F == "object" && "value" in F && F.value === "idle") {
357
+ s(!1), l(null);
358
+ const M = F.context, J = JSON.stringify([M.renderValue, M.propertyValue]);
359
+ (!B || J !== V) && (B = !0, V = J, d((se) => se + 1));
337
360
  return;
338
361
  }
339
- $ = !1, Q = void 0;
340
- const V = Date.now();
341
- V - N >= L && (N = V, d((M) => M + 1));
362
+ B = !1, V = void 0;
363
+ const K = Date.now();
364
+ K - A >= L && (A = K, d((M) => M + 1));
342
365
  });
343
- return i.current = k, () => {
366
+ return i.current = $, () => {
344
367
  i.current?.unsubscribe(), i.current = void 0;
345
368
  };
346
369
  }, [n]), {
347
370
  property: n,
348
371
  isLoading: a,
349
- error: l
372
+ error: c
350
373
  };
351
374
  }
352
- function yr(e, t = 300) {
353
- const r = "itemId" in e ? e.itemId : void 0, n = "seedLocalId" in e ? e.seedLocalId : void 0, o = "seedUid" in e ? e.seedUid : void 0, a = e.propertyName, s = F(() => r ? { seedLocalId: r, propertyName: a } : { seedLocalId: n, seedUid: o, propertyName: a }, [r, n, o, a]), { property: l, isLoading: c, error: i } = Ve(s), d = D(""), u = F(
354
- () => ze((g) => {
355
- g.getService().send({
375
+ function br(e, t = 300) {
376
+ const r = "itemId" in e ? e.itemId : void 0, n = "seedLocalId" in e ? e.seedLocalId : void 0, o = "seedUid" in e ? e.seedUid : void 0, a = e.propertyName, s = N(() => r ? { seedLocalId: r, propertyName: a } : { seedLocalId: n, seedUid: o, propertyName: a }, [r, n, o, a]), { property: c, isLoading: l, error: i } = We(s), d = C(""), u = N(
377
+ () => He((b) => {
378
+ b.getService().send({
356
379
  type: "save",
357
380
  newValue: d.current
358
381
  });
359
382
  }, t),
360
383
  [t]
361
384
  );
362
- I(() => () => u.cancel(), [u]);
385
+ w(() => () => u.cancel(), [u]);
363
386
  const f = x(
364
- (g) => {
365
- l && (d.current = g, l.getService().send({
387
+ (b) => {
388
+ c && (d.current = b, c.getService().send({
366
389
  type: "updateContext",
367
- propertyValue: g,
368
- renderValue: g
369
- }), u(l));
390
+ propertyValue: b,
391
+ renderValue: b
392
+ }), u(c));
370
393
  },
371
- [l, u]
394
+ [c, u]
372
395
  );
373
396
  return {
374
- property: l,
397
+ property: c,
375
398
  setValue: f,
376
- isLoading: c,
399
+ isLoading: l,
377
400
  error: i
378
401
  };
379
402
  }
380
- async function St(e, t) {
403
+ async function Et(e, t) {
381
404
  if (!e && !t) return [];
382
- const r = W.getAppDb();
405
+ const r = j.getAppDb();
383
406
  if (!r) return [];
384
- const n = await se.all(
407
+ const n = await ie.all(
385
408
  { seedLocalId: e ?? void 0, seedUid: t ?? void 0 },
386
409
  { waitForReady: !0 }
387
410
  ), o = [...n], a = /* @__PURE__ */ new Set();
388
- for (const c of n)
389
- c.propertyName && a.add(c.propertyName);
411
+ for (const l of n)
412
+ l.propertyName && a.add(l.propertyName);
390
413
  let s;
391
414
  if (n.length > 0) {
392
- const c = n[0];
393
- s = c.modelName ?? c.modelType, s && typeof s == "string" && (s = Ce(s));
415
+ const l = n[0];
416
+ s = l.modelName ?? l.modelType, s && typeof s == "string" && (s = Pe(s));
394
417
  }
395
418
  if (!s) {
396
- const c = await r.select({ type: A.type }).from(A).where(t ? U(A.uid, t) : U(A.localId, e)).limit(1);
397
- c.length > 0 && c[0].type && (s = Ce(c[0].type));
419
+ const l = await r.select({ type: D.type }).from(D).where(t ? q(D.uid, t) : q(D.localId, e)).limit(1);
420
+ l.length > 0 && l[0].type && (s = Pe(l[0].type));
398
421
  }
399
- const l = [];
422
+ const c = [];
400
423
  if (s)
401
424
  try {
402
- const { Model: c } = await import("@seedprotocol/sdk"), i = await c.getByNameAsync(s);
425
+ const { Model: l } = await import("@seedprotocol/sdk"), i = await l.getByNameAsync(s);
403
426
  if (i?.properties)
404
427
  for (const d of i.properties)
405
- d.name && l.push(d.name);
406
- } catch (c) {
407
- ne(`[useItemProperties] Error getting ModelProperties for ${s}:`, c);
428
+ d.name && c.push(d.name);
429
+ } catch (l) {
430
+ oe(`[useItemProperties] Error getting ModelProperties for ${s}:`, l);
408
431
  }
409
- if (s && l.length > 0) {
410
- const c = n.length > 0 ? n[0].seedLocalId ?? e : e, i = n.length > 0 ? n[0].seedUid ?? t : t;
411
- for (const d of l)
432
+ if (s && c.length > 0) {
433
+ const l = n.length > 0 ? n[0].seedLocalId ?? e : e, i = n.length > 0 ? n[0].seedUid ?? t : t;
434
+ for (const d of c)
412
435
  if (!a.has(d))
413
436
  try {
414
- const u = se.create(
437
+ const u = ie.create(
415
438
  {
416
439
  propertyName: d,
417
440
  modelName: s,
418
- seedLocalId: c || void 0,
441
+ seedLocalId: l || void 0,
419
442
  seedUid: i || void 0,
420
443
  propertyValue: null
421
444
  },
@@ -423,111 +446,111 @@ async function St(e, t) {
423
446
  );
424
447
  u && o.push(u);
425
448
  } catch (u) {
426
- ye(`[useItemProperties] Error creating ItemProperty for missing property ${d}:`, u);
449
+ he(`[useItemProperties] Error creating ItemProperty for missing property ${d}:`, u);
427
450
  }
428
451
  }
429
452
  if (e || t) {
430
- const c = await r.select({ createdAt: A.createdAt }).from(A).where(t ? U(A.uid, t) : U(A.localId, e)).limit(1);
431
- if (c.length > 0 && c[0].createdAt) {
453
+ const l = await r.select({ createdAt: D.createdAt }).from(D).where(t ? q(D.uid, t) : q(D.localId, e)).limit(1);
454
+ if (l.length > 0 && l[0].createdAt) {
432
455
  const i = "createdAt";
433
456
  if (!o.some((u) => u.propertyName === i) && s)
434
457
  try {
435
- const u = n.length > 0 ? n[0].seedLocalId ?? e : e, f = n.length > 0 ? n[0].seedUid ?? t : t, g = se.create(
458
+ const u = n.length > 0 ? n[0].seedLocalId ?? e : e, f = n.length > 0 ? n[0].seedUid ?? t : t, b = ie.create(
436
459
  {
437
460
  propertyName: i,
438
461
  modelName: s,
439
462
  seedLocalId: u || void 0,
440
463
  seedUid: f || void 0,
441
- propertyValue: c[0].createdAt.toString()
464
+ propertyValue: l[0].createdAt.toString()
442
465
  },
443
466
  { waitForReady: !1 }
444
467
  );
445
- g && o.push(g);
468
+ b && o.push(b);
446
469
  } catch (u) {
447
- ye("[useItemProperties] Error creating createdAt ItemProperty:", u);
470
+ he("[useItemProperties] Error creating createdAt ItemProperty:", u);
448
471
  }
449
472
  }
450
473
  }
451
474
  return o;
452
475
  }
453
- function mr(e) {
454
- const t = q(), r = X(), n = D(void 0), o = F(() => typeof e == "string" ? { type: "itemId", itemId: e } : typeof e == "object" ? {
476
+ function Sr(e) {
477
+ const t = Q(), r = Z(), n = C(void 0), o = N(() => typeof e == "string" ? { type: "itemId", itemId: e } : typeof e == "object" ? {
455
478
  type: "identifiers",
456
479
  seedLocalId: e.seedLocalId,
457
480
  seedUid: e.seedUid
458
- } : null, [e]), a = F(() => {
481
+ } : null, [e]), a = N(() => {
459
482
  if (o)
460
483
  return o.type === "itemId" ? o.itemId : o.seedLocalId;
461
- }, [o]), s = F(() => {
484
+ }, [o]), s = N(() => {
462
485
  if (!(!o || o.type === "itemId"))
463
486
  return o.seedUid;
464
- }, [o]), l = a ?? s ?? "", c = F(
465
- () => ["seed", "itemProperties", l],
466
- [l]
487
+ }, [o]), c = a ?? s ?? "", l = N(
488
+ () => ["seed", "itemProperties", c],
489
+ [c]
467
490
  ), {
468
491
  data: i = [],
469
492
  isLoading: d,
470
493
  error: u
471
- } = Z({
472
- queryKey: c,
473
- queryFn: () => St(a, s),
474
- enabled: t && !!l
475
- }), f = F(() => {
494
+ } = ee({
495
+ queryKey: l,
496
+ queryFn: () => Et(a, s),
497
+ enabled: t && !!c
498
+ }), f = N(() => {
476
499
  if (!t || !a && !s)
477
- return ne("[useItemProperties] Query: returning null (not ready or no identifiers)"), null;
478
- const b = W.getAppDb();
479
- if (!b)
480
- return ne("[useItemProperties] Query: returning null (no db)"), null;
481
- ne(`[useItemProperties] Query: creating query for seedLocalId=${a}, seedUid=${s}`);
482
- const y = s ? b.select({
483
- propertyName: T.propertyName,
484
- propertyValue: T.propertyValue,
485
- seedLocalId: T.seedLocalId,
486
- seedUid: T.seedUid,
487
- modelType: T.modelType,
488
- schemaUid: T.schemaUid,
489
- createdAt: T.createdAt,
490
- attestationCreatedAt: T.attestationCreatedAt
491
- }).from(T).where(
492
- Le(
493
- U(T.seedUid, s),
494
- Ee(T.propertyName)
500
+ return oe("[useItemProperties] Query: returning null (not ready or no identifiers)"), null;
501
+ const h = j.getAppDb();
502
+ if (!h)
503
+ return oe("[useItemProperties] Query: returning null (no db)"), null;
504
+ oe(`[useItemProperties] Query: creating query for seedLocalId=${a}, seedUid=${s}`);
505
+ const y = s ? h.select({
506
+ propertyName: k.propertyName,
507
+ propertyValue: k.propertyValue,
508
+ seedLocalId: k.seedLocalId,
509
+ seedUid: k.seedUid,
510
+ modelType: k.modelType,
511
+ schemaUid: k.schemaUid,
512
+ createdAt: k.createdAt,
513
+ attestationCreatedAt: k.attestationCreatedAt
514
+ }).from(k).where(
515
+ xe(
516
+ q(k.seedUid, s),
517
+ Ae(k.propertyName)
495
518
  )
496
- ) : a ? b.select({
497
- propertyName: T.propertyName,
498
- propertyValue: T.propertyValue,
499
- seedLocalId: T.seedLocalId,
500
- seedUid: T.seedUid,
501
- modelType: T.modelType,
502
- schemaUid: T.schemaUid,
503
- createdAt: T.createdAt,
504
- attestationCreatedAt: T.attestationCreatedAt
505
- }).from(T).where(
506
- Le(
507
- U(T.seedLocalId, a),
508
- Ee(T.propertyName)
519
+ ) : a ? h.select({
520
+ propertyName: k.propertyName,
521
+ propertyValue: k.propertyValue,
522
+ seedLocalId: k.seedLocalId,
523
+ seedUid: k.seedUid,
524
+ modelType: k.modelType,
525
+ schemaUid: k.schemaUid,
526
+ createdAt: k.createdAt,
527
+ attestationCreatedAt: k.attestationCreatedAt
528
+ }).from(k).where(
529
+ xe(
530
+ q(k.seedLocalId, a),
531
+ Ae(k.propertyName)
509
532
  )
510
533
  ) : null;
511
- return ne("[useItemProperties] Query: created query object", { queryType: s ? "seedUid" : "seedLocalId" }), y;
512
- }, [t, a, s]), g = ie(f), v = F(() => {
513
- if (!g || g.length === 0)
534
+ return oe("[useItemProperties] Query: created query object", { queryType: s ? "seedUid" : "seedLocalId" }), y;
535
+ }, [t, a, s]), b = Y(f), v = N(() => {
536
+ if (!b || b.length === 0)
514
537
  return [];
515
- const b = /* @__PURE__ */ new Map();
516
- for (const y of g) {
538
+ const h = /* @__PURE__ */ new Map();
539
+ for (const y of b) {
517
540
  if (!y.propertyName) continue;
518
- const p = b.get(y.propertyName);
541
+ const p = h.get(y.propertyName);
519
542
  if (!p)
520
- b.set(y.propertyName, y);
543
+ h.set(y.propertyName, y);
521
544
  else {
522
545
  const E = p.attestationCreatedAt || p.createdAt || 0;
523
- (y.attestationCreatedAt || y.createdAt || 0) > E && b.set(y.propertyName, y);
546
+ (y.attestationCreatedAt || y.createdAt || 0) > E && h.set(y.propertyName, y);
524
547
  }
525
548
  }
526
- return Array.from(b.values());
527
- }, [g]);
528
- return I(() => {
549
+ return Array.from(h.values());
550
+ }, [b]);
551
+ return w(() => {
529
552
  if (!t || !a && !s || v === void 0) return;
530
- const b = JSON.stringify(
553
+ const h = JSON.stringify(
531
554
  v.map((y) => ({
532
555
  propertyName: y.propertyName,
533
556
  propertyValue: y.propertyValue,
@@ -535,8 +558,8 @@ function mr(e) {
535
558
  seedUid: y.seedUid
536
559
  })).sort((y, p) => (y.propertyName || "").localeCompare(p.propertyName || ""))
537
560
  );
538
- n.current !== b && (n.current = b, v.length > 0 && r.invalidateQueries({ queryKey: c }));
539
- }, [t, v, i, a, s, r, c]), I(() => {
561
+ n.current !== h && (n.current = h, v.length > 0 && r.invalidateQueries({ queryKey: l }));
562
+ }, [t, v, i, a, s, r, l]), w(() => {
540
563
  n.current = void 0;
541
564
  }, [a, s]), {
542
565
  properties: i,
@@ -544,29 +567,29 @@ function mr(e) {
544
567
  error: u
545
568
  };
546
569
  }
547
- const hr = () => {
548
- const e = D(void 0), [t, r] = S(!1), [n, o] = S(null), a = x(() => o(null), []), s = x((l) => {
549
- if (!l.propertyName || !l.seedLocalId && !l.seedUid || !l.modelName) {
570
+ const vr = () => {
571
+ const e = C(void 0), [t, r] = S(!1), [n, o] = S(null), a = x(() => o(null), []), s = x((c) => {
572
+ if (!c.propertyName || !c.seedLocalId && !c.seedUid || !c.modelName) {
550
573
  const d = new Error("seedLocalId or seedUid, propertyName, and modelName are required");
551
574
  o(d);
552
575
  return;
553
576
  }
554
577
  o(null), r(!0), e.current?.unsubscribe(), e.current = void 0;
555
- const c = se.create(l, { waitForReady: !1 });
556
- if (!c) {
578
+ const l = ie.create(c, { waitForReady: !1 });
579
+ if (!l) {
557
580
  o(new Error("Failed to create item property")), r(!1);
558
581
  return;
559
582
  }
560
- const i = c.getService().subscribe((d) => {
583
+ const i = l.getService().subscribe((d) => {
561
584
  if (d?.value === "error") {
562
585
  const u = d.context?._loadingError?.error ?? new Error("Failed to create item property");
563
586
  o(u instanceof Error ? u : new Error(String(u))), r(!1);
564
587
  }
565
588
  d?.value === "idle" && (o(null), r(!1));
566
589
  });
567
- return e.current = i, c;
590
+ return e.current = i, l;
568
591
  }, []);
569
- return I(() => () => {
592
+ return w(() => () => {
570
593
  e.current?.unsubscribe(), e.current = void 0;
571
594
  }, []), {
572
595
  create: s,
@@ -574,26 +597,26 @@ const hr = () => {
574
597
  error: n,
575
598
  resetError: a
576
599
  };
577
- }, gr = () => {
600
+ }, wr = () => {
578
601
  const [e, t] = S(null), [r, n] = S({
579
602
  isLoading: !1,
580
603
  error: null
581
604
  });
582
- I(() => {
605
+ w(() => {
583
606
  if (!e) {
584
607
  n({ isLoading: !1, error: null });
585
608
  return;
586
609
  }
587
- const s = e.getService(), l = () => {
610
+ const s = e.getService(), c = () => {
588
611
  const d = s.getSnapshot().context;
589
612
  n({
590
613
  isLoading: !!d._destroyInProgress,
591
614
  error: d._destroyError ? new Error(d._destroyError.message) : null
592
615
  });
593
616
  };
594
- l();
595
- const c = s.subscribe(l);
596
- return () => c.unsubscribe();
617
+ c();
618
+ const l = s.subscribe(c);
619
+ return () => l.unsubscribe();
597
620
  }, [e]);
598
621
  const o = x(async (s) => {
599
622
  s && (t(s), await s.destroy());
@@ -606,14 +629,14 @@ const hr = () => {
606
629
  error: r.error,
607
630
  resetError: a
608
631
  };
609
- }, xe = G("seedSdk:react:services"), wt = ["idle", "ready", "done", "success", "initialized"], Ke = (e) => {
632
+ }, Ne = G("seedSdk:react:services"), Lt = ["idle", "ready", "done", "success", "initialized"], Je = (e) => {
610
633
  let t = "actor";
611
634
  const r = e;
612
- return e && r.uniqueKey && (t = r.uniqueKey), e && !r.uniqueKey && r.logic && r.logic.config && (t = De(e)), t;
613
- }, Me = (e) => {
635
+ return e && r.uniqueKey && (t = r.uniqueKey), e && !r.uniqueKey && r.logic && r.logic.config && (t = Re(e)), t;
636
+ }, ke = (e) => {
614
637
  let t;
615
- return e && e.getSnapshot() && e.getSnapshot().value && (t = e.getSnapshot().value), Ke(e) === "global" && t && typeof t == "object" && Object.keys(t).length > 0 && Object.keys(t)[0] === "initialized" && (t = "ready"), t && typeof t == "object" && (t = JSON.stringify(t)), t;
616
- }, De = (e) => {
638
+ return e && e.getSnapshot() && e.getSnapshot().value && (t = e.getSnapshot().value), Je(e) === "global" && t && typeof t == "object" && Object.keys(t).length > 0 && Object.keys(t)[0] === "initialized" && (t = "ready"), t && typeof t == "object" && (t = JSON.stringify(t)), t;
639
+ }, Re = (e) => {
617
640
  const t = e;
618
641
  if (!e || !t.logic || !t.logic.config || !t._snapshot)
619
642
  return;
@@ -626,36 +649,36 @@ const hr = () => {
626
649
  try {
627
650
  o = e.getSnapshot();
628
651
  } catch (a) {
629
- return xe("Error:", a), n;
652
+ return Ne("Error:", a), n;
630
653
  }
631
654
  if (o) {
632
655
  const a = o.context;
633
- a && a.dbName && (n = a.dbName), a && a.modelNamePlural && (n = a.modelNamePlural), a && a.modelName && (n = gt(a.modelName.toLowerCase()));
656
+ a && a.dbName && (n = a.dbName), a && a.modelNamePlural && (n = a.modelNamePlural), a && a.modelName && (n = vt(a.modelName.toLowerCase()));
634
657
  }
635
658
  return n;
636
- }, br = (e) => {
659
+ }, Ir = (e) => {
637
660
  const [t, r] = S(0), n = (s) => {
638
- let l = 0;
639
- const c = s;
640
- if (c.logic?.states) {
661
+ let c = 0;
662
+ const l = s;
663
+ if (l.logic?.states) {
641
664
  const i = [], d = [];
642
- for (const [g, v] of Object.entries(c.logic.states))
643
- v.tags?.includes("loading") && (i.push(g), d.push(v));
644
- const u = d.length, f = Me(s);
645
- if (f && wt.includes(f))
665
+ for (const [b, v] of Object.entries(l.logic.states))
666
+ v.tags?.includes("loading") && (i.push(b), d.push(v));
667
+ const u = d.length, f = ke(s);
668
+ if (f && Lt.includes(f))
646
669
  return 0;
647
- f && (l = i.indexOf(f) / u * 100);
670
+ f && (c = i.indexOf(f) / u * 100);
648
671
  }
649
- return l;
672
+ return c;
650
673
  }, o = x(
651
674
  (s) => {
652
675
  e.getSnapshot().context;
653
- const l = e.getSnapshot().value;
654
- if (l === "done" || l === "success" || l === "idle" || l === "ready") {
676
+ const c = e.getSnapshot().value;
677
+ if (c === "done" || c === "success" || c === "idle" || c === "ready") {
655
678
  clearInterval(s);
656
679
  return;
657
680
  }
658
- r((c) => c + 1);
681
+ r((l) => l + 1);
659
682
  },
660
683
  [e]
661
684
  ), a = x(() => {
@@ -664,71 +687,71 @@ const hr = () => {
664
687
  }, 1e3);
665
688
  return s;
666
689
  }, [o, e]);
667
- return I(() => {
690
+ return w(() => {
668
691
  const s = a();
669
692
  return () => clearInterval(s);
670
693
  }, []), {
671
- name: Ke(e),
694
+ name: Je(e),
672
695
  timeElapsed: t,
673
- value: Me(e),
696
+ value: ke(e),
674
697
  percentComplete: n(e),
675
- uniqueKey: De(e)
698
+ uniqueKey: Re(e)
676
699
  };
677
- }, It = () => {
678
- const [e, t] = S(!1), { internalStatus: r } = xt();
679
- return I(() => {
700
+ }, At = () => {
701
+ const [e, t] = S(!1), { internalStatus: r } = _t();
702
+ return w(() => {
680
703
  r === "ready" && t(!0);
681
- }, [r]), I(() => {
704
+ }, [r]), w(() => {
682
705
  r === "ready" && t(!0);
683
706
  }, []), e;
684
- }, vr = () => {
685
- const [e, t] = S(!1), r = Et(), { services: n, percentComplete: o } = Lt(), a = x(async () => {
686
- for (const l of n) {
687
- const c = De(l);
688
- xe(
689
- `would save to db with snapshot__${c}:`,
690
- JSON.stringify(l.getPersistedSnapshot())
707
+ }, Er = () => {
708
+ const [e, t] = S(!1), r = xt(), { services: n, percentComplete: o } = Nt(), a = x(async () => {
709
+ for (const c of n) {
710
+ const l = Re(c);
711
+ Ne(
712
+ `would save to db with snapshot__${l}:`,
713
+ JSON.stringify(c.getPersistedSnapshot())
691
714
  );
692
715
  }
693
716
  }, [n]), s = x(async () => {
694
- const l = W.getAppDb();
695
- return l ? await l.select().from(ue).where(qe(ue.key, "snapshot__%")) : [];
717
+ const c = j.getAppDb();
718
+ return c ? await c.select().from(fe).where(Qe(fe.key, "snapshot__%")) : [];
696
719
  }, []);
697
- I(() => !r || e ? void 0 : ((async () => {
698
- const c = await s();
699
- xe("persistedSnapshots:", c), t(!0);
720
+ w(() => !r || e ? void 0 : ((async () => {
721
+ const l = await s();
722
+ Ne("persistedSnapshots:", l), t(!0);
700
723
  })(), () => {
701
724
  a();
702
725
  }), [r, e]);
703
- }, Et = () => {
704
- const [e, t] = S(!1), r = It();
705
- return I(() => {
726
+ }, xt = () => {
727
+ const [e, t] = S(!1), r = At();
728
+ return w(() => {
706
729
  r && (async () => {
707
- const a = await W.getAppDb().select().from(ue).where(qe(ue.key, "snapshot__%"));
730
+ const a = await j.getAppDb().select().from(fe).where(Qe(fe.key, "snapshot__%"));
708
731
  a && a.length > 0 && t(!0);
709
732
  })();
710
733
  }, [r]), e;
711
- }, Lt = () => {
734
+ }, Nt = () => {
712
735
  const [e, t] = S([]), [r, n] = S(5);
713
- return I(() => {
714
- const a = me().getService(), s = a;
736
+ return w(() => {
737
+ const a = ge().getService(), s = a;
715
738
  s.uniqueKey = "clientManager", t([s]);
716
- const l = a.subscribe((c) => {
717
- const i = c.value;
739
+ const c = a.subscribe((l) => {
740
+ const i = l.value;
718
741
  let d = 0;
719
- i === C.IDLE ? d = 100 : i === C.ADD_MODELS_TO_DB ? d = 90 : i === C.ADD_MODELS_TO_STORE ? d = 80 : i === C.PROCESS_SCHEMA_FILES ? d = 70 : i === C.SAVE_CONFIG ? d = 60 : i === C.DB_INIT ? d = 50 : i === C.FILE_SYSTEM_INIT ? d = 30 : i === C.PLATFORM_CLASSES_INIT && (d = 10), n(d);
742
+ i === P.IDLE ? d = 100 : i === P.ADD_MODELS_TO_DB ? d = 90 : i === P.ADD_MODELS_TO_STORE ? d = 80 : i === P.PROCESS_SCHEMA_FILES ? d = 70 : i === P.SAVE_CONFIG ? d = 60 : i === P.DB_INIT ? d = 50 : i === P.FILE_SYSTEM_INIT ? d = 30 : i === P.PLATFORM_CLASSES_INIT && (d = 10), n(d);
720
743
  });
721
744
  return () => {
722
- l.unsubscribe();
745
+ c.unsubscribe();
723
746
  };
724
747
  }, []), {
725
748
  services: e,
726
749
  percentComplete: r
727
750
  };
728
- }, xt = () => {
729
- const t = me().getService(), r = Ie(t, (o) => o.value), n = Ie(t, (o) => {
751
+ }, _t = () => {
752
+ const t = ge().getService(), r = Le(t, (o) => o.value), n = Le(t, (o) => {
730
753
  const a = o.value;
731
- return a === C.DB_INIT || a === C.SAVE_CONFIG || a === C.PROCESS_SCHEMA_FILES || a === C.ADD_MODELS_TO_STORE || a === C.ADD_MODELS_TO_DB || a === C.IDLE ? "ready" : a;
754
+ return a === P.DB_INIT || a === P.SAVE_CONFIG || a === P.PROCESS_SCHEMA_FILES || a === P.ADD_MODELS_TO_STORE || a === P.ADD_MODELS_TO_DB || a === P.IDLE ? "ready" : a;
732
755
  });
733
756
  return {
734
757
  status: r,
@@ -736,21 +759,21 @@ const hr = () => {
736
759
  };
737
760
  };
738
761
  G("seedSdk:react:db");
739
- const Sr = () => {
762
+ const Lr = () => {
740
763
  const [e, t] = S(!1), r = x(() => {
741
764
  e || t(!0);
742
765
  }, []);
743
- return I(() => {
766
+ return w(() => {
744
767
  let n;
745
768
  return (async () => {
746
- const s = me().getService(), l = s.getSnapshot().value;
747
- if (l === C.DB_INIT || l === C.SAVE_CONFIG || l === C.PROCESS_SCHEMA_FILES || l === C.ADD_MODELS_TO_STORE || l === C.ADD_MODELS_TO_DB || l === C.IDLE) {
769
+ const s = ge().getService(), c = s.getSnapshot().value;
770
+ if (c === P.DB_INIT || c === P.SAVE_CONFIG || c === P.PROCESS_SCHEMA_FILES || c === P.ADD_MODELS_TO_STORE || c === P.ADD_MODELS_TO_DB || c === P.IDLE) {
748
771
  r();
749
772
  return;
750
773
  }
751
- n = s.subscribe((c) => {
752
- const i = c.value;
753
- (i === C.DB_INIT || i === C.SAVE_CONFIG || i === C.PROCESS_SCHEMA_FILES || i === C.ADD_MODELS_TO_STORE || i === C.ADD_MODELS_TO_DB || i === C.IDLE) && (r(), n?.unsubscribe());
774
+ n = s.subscribe((l) => {
775
+ const i = l.value;
776
+ (i === P.DB_INIT || i === P.SAVE_CONFIG || i === P.PROCESS_SCHEMA_FILES || i === P.ADD_MODELS_TO_STORE || i === P.ADD_MODELS_TO_DB || i === P.IDLE) && (r(), n?.unsubscribe());
754
777
  });
755
778
  })(), () => {
756
779
  n && n.unsubscribe();
@@ -758,24 +781,24 @@ const Sr = () => {
758
781
  }, []), {
759
782
  dbsAreReady: e
760
783
  };
761
- }, je = G("seedSdk:react:schema"), Nt = (e) => {
762
- const [t, r] = S(null), [n, o] = S(!!e), [a, s] = S(null), l = D(null), c = q(), i = x((d) => {
784
+ }, Ge = G("seedSdk:react:schema"), Dt = (e) => {
785
+ const [t, r] = S(null), [n, o] = S(!!e), [a, s] = S(null), c = C(null), l = Q(), i = x((d) => {
763
786
  o(!0), s(null);
764
787
  try {
765
- const u = he.create(d, {
788
+ const u = be.create(d, {
766
789
  waitForReady: !1
767
790
  });
768
791
  r(u);
769
792
  const f = u.getService();
770
- f.getSnapshot().value === "idle" ? (de(() => o(!1)), s(null)) : o(!0), l.current = f.subscribe((b) => {
771
- b.value === "idle" ? (de(() => o(!1)), s(null)) : o(!0);
793
+ f.getSnapshot().value === "idle" ? (ue(() => o(!1)), s(null)) : o(!0), c.current = f.subscribe((h) => {
794
+ h.value === "idle" ? (ue(() => o(!1)), s(null)) : o(!0);
772
795
  });
773
796
  } catch (u) {
774
- return je("[useSchema] Error creating schema:", u), s(u), r(null), o(!1), null;
797
+ return Ge("[useSchema] Error creating schema:", u), s(u), r(null), o(!1), null;
775
798
  }
776
799
  }, []);
777
- return I(() => {
778
- if (l.current && (l.current.unsubscribe(), l.current = null), !c) {
800
+ return w(() => {
801
+ if (c.current && (c.current.unsubscribe(), c.current = null), !l) {
779
802
  r(null), s(null), o(!1);
780
803
  return;
781
804
  }
@@ -784,75 +807,75 @@ const Sr = () => {
784
807
  return;
785
808
  }
786
809
  return i(e), () => {
787
- l.current && (l.current.unsubscribe(), l.current = null);
810
+ c.current && (c.current.unsubscribe(), c.current = null);
788
811
  };
789
- }, [e, c, i]), {
812
+ }, [e, l, i]), {
790
813
  schema: t,
791
814
  isLoading: n,
792
815
  error: a
793
816
  };
794
- }, ve = ["seed", "schemas"], wr = () => {
795
- const e = q(), t = X(), r = D(void 0), n = D([]), {
817
+ }, we = ["seed", "schemas"], Ar = () => {
818
+ const e = Q(), t = Z(), r = C(void 0), n = C([]), {
796
819
  data: o = [],
797
820
  isLoading: a,
798
821
  error: s
799
- } = Z({
800
- queryKey: ve,
801
- queryFn: () => he.all({ waitForReady: !0 }),
822
+ } = ee({
823
+ queryKey: we,
824
+ queryFn: () => be.all({ waitForReady: !0 }),
802
825
  enabled: e
803
826
  });
804
827
  n.current = o;
805
- const l = e ? W.getAppDb() : null, c = F(() => l ? l.select().from(Y).orderBy(Y.name, pt(Y.version)) : null, [l, e]), i = ie(c);
806
- return I(() => {
828
+ const c = e ? j.getAppDb() : null, l = N(() => c ? c.select().from(X).orderBy(X.name, Ve(X.version)) : null, [c, e]), i = Y(l);
829
+ return w(() => {
807
830
  if (typeof BroadcastChannel > "u") return;
808
831
  const d = new BroadcastChannel("seed-schemas-invalidate"), u = () => {
809
- t.invalidateQueries({ queryKey: ve });
832
+ t.invalidateQueries({ queryKey: we });
810
833
  };
811
834
  return d.addEventListener("message", u), () => {
812
835
  d.removeEventListener("message", u), d.close();
813
836
  };
814
- }, [t]), I(() => {
837
+ }, [t]), w(() => {
815
838
  if (!e || !i)
816
839
  return;
817
840
  const d = r.current, u = d ? JSON.stringify(d) : "undefined", f = i ? JSON.stringify(i) : "undefined";
818
841
  if (u === f && d !== void 0)
819
842
  return;
820
843
  r.current = i;
821
- const g = /* @__PURE__ */ new Set();
844
+ const b = /* @__PURE__ */ new Set();
822
845
  for (const p of n.current) {
823
846
  const E = p.id || p.schemaFileId;
824
847
  if (E)
825
- g.add(E);
848
+ b.add(E);
826
849
  else {
827
- const w = p.metadata?.name, m = p.version;
828
- w && m !== void 0 && g.add(`${w}:${m}`);
850
+ const I = p.metadata?.name, m = p.version;
851
+ I && m !== void 0 && b.add(`${I}:${m}`);
829
852
  }
830
853
  }
831
854
  const v = /* @__PURE__ */ new Set();
832
855
  for (const p of i)
833
856
  p.name !== "Seed Protocol" && (p.schemaFileId ? v.add(p.schemaFileId) : p.name != null && p.version !== void 0 && v.add(`${p.name}:${p.version}`));
834
- const b = g.size === v.size && [...g].every((p) => v.has(p)), y = g.size > 0 && v.size > 0 && [...v].some((p) => !g.has(p));
835
- !b && y && t.invalidateQueries({ queryKey: ve });
857
+ const h = b.size === v.size && [...b].every((p) => v.has(p)), y = b.size > 0 && v.size > 0 && [...v].some((p) => !b.has(p));
858
+ !h && y && t.invalidateQueries({ queryKey: we });
836
859
  }, [e, i, t]), {
837
860
  schemas: o,
838
861
  isLoading: a,
839
862
  error: s
840
863
  };
841
- }, Ir = () => {
842
- const e = D(null), [t, r] = S(!1), [n, o] = S(null), a = x(() => o(null), []), s = x((l) => {
864
+ }, xr = () => {
865
+ const e = C(null), [t, r] = S(!1), [n, o] = S(null), a = x(() => o(null), []), s = x((c) => {
843
866
  o(null), r(!0), e.current?.unsubscribe(), e.current = null;
844
- const c = he.create(l, {
867
+ const l = be.create(c, {
845
868
  waitForReady: !1
846
- }), i = c.getService().subscribe((d) => {
869
+ }), i = l.getService().subscribe((d) => {
847
870
  if (d.value === "error") {
848
871
  const u = d.context._loadingError?.error;
849
872
  o(u instanceof Error ? u : new Error("Failed to create schema")), r(!1);
850
873
  }
851
874
  d.value === "idle" && (o(null), r(!1));
852
875
  });
853
- return e.current = i, c;
876
+ return e.current = i, l;
854
877
  }, []);
855
- return I(() => () => {
878
+ return w(() => () => {
856
879
  e.current?.unsubscribe(), e.current = null;
857
880
  }, []), {
858
881
  createSchema: s,
@@ -860,26 +883,26 @@ const Sr = () => {
860
883
  error: n,
861
884
  resetError: a
862
885
  };
863
- }, Er = () => {
886
+ }, Nr = () => {
864
887
  const [e, t] = S(null), [r, n] = S({
865
888
  isLoading: !1,
866
889
  error: null
867
890
  });
868
- I(() => {
891
+ w(() => {
869
892
  if (!e) {
870
893
  n({ isLoading: !1, error: null });
871
894
  return;
872
895
  }
873
- const s = e.getService(), l = () => {
896
+ const s = e.getService(), c = () => {
874
897
  const d = s.getSnapshot().context;
875
898
  n({
876
899
  isLoading: !!d._destroyInProgress,
877
900
  error: d._destroyError ? new Error(d._destroyError.message) : null
878
901
  });
879
902
  };
880
- l();
881
- const c = s.subscribe(l);
882
- return () => c.unsubscribe();
903
+ c();
904
+ const l = s.subscribe(c);
905
+ return () => l.unsubscribe();
883
906
  }, [e]);
884
907
  const o = x(async (s) => {
885
908
  s && (t(s), await s.destroy());
@@ -892,49 +915,49 @@ const Sr = () => {
892
915
  error: r.error,
893
916
  resetError: a
894
917
  };
895
- }, Lr = () => {
896
- const [e, t] = S(), r = D(/* @__PURE__ */ new Map()), n = q(), o = x(async () => {
918
+ }, _r = () => {
919
+ const [e, t] = S(), r = C(/* @__PURE__ */ new Map()), n = Q(), o = x(async () => {
897
920
  if (n)
898
921
  try {
899
- const a = await st(), s = /* @__PURE__ */ new Set();
900
- for (const c of a) {
901
- const i = c.schema.metadata?.name;
922
+ const a = await ct(), s = /* @__PURE__ */ new Set();
923
+ for (const l of a) {
924
+ const i = l.schema.metadata?.name;
902
925
  i && s.add(i);
903
926
  }
904
- const l = /* @__PURE__ */ new Map();
905
- for (const c of s)
906
- if (r.current.has(c)) {
907
- const i = r.current.get(c);
908
- l.set(c, i);
927
+ const c = /* @__PURE__ */ new Map();
928
+ for (const l of s)
929
+ if (r.current.has(l)) {
930
+ const i = r.current.get(l);
931
+ c.set(l, i);
909
932
  } else {
910
- const i = he.create(c, {
933
+ const i = be.create(l, {
911
934
  waitForReady: !1
912
935
  });
913
- l.set(c, i);
936
+ c.set(l, i);
914
937
  }
915
- for (const [c, i] of r.current.entries())
916
- s.has(c) || i.unload();
917
- r.current = l, t(Array.from(l.values()));
938
+ for (const [l, i] of r.current.entries())
939
+ s.has(l) || i.unload();
940
+ r.current = c, t(Array.from(c.values()));
918
941
  } catch (a) {
919
- je("Error fetching all schema versions from database:", a), t(null);
942
+ Ge("Error fetching all schema versions from database:", a), t(null);
920
943
  }
921
944
  }, [n]);
922
- return I(() => {
945
+ return w(() => {
923
946
  n && o();
924
- }, [n, o]), I(() => () => {
947
+ }, [n, o]), w(() => () => {
925
948
  r.current.forEach((a) => {
926
949
  a.unload();
927
950
  }), r.current.clear();
928
951
  }, []), e;
929
- }, xr = () => Nt(ot), At = (e) => ["seed", "models", e], Te = /* @__PURE__ */ new Map(), Ft = (e) => {
930
- const t = q(), r = X(), n = D([]), o = F(() => At(e), [e]), {
952
+ }, Dr = () => Dt(lt), Ft = (e) => ["seed", "models", e], $e = /* @__PURE__ */ new Map(), Ct = (e) => {
953
+ const t = Q(), r = Z(), n = C([]), o = N(() => Ft(e), [e]), {
931
954
  data: a = [],
932
955
  isLoading: s,
933
- error: l
934
- } = Z({
956
+ error: c
957
+ } = ee({
935
958
  queryKey: o,
936
959
  queryFn: async () => {
937
- const y = r.getQueryData(o), p = await oe.all(e, { waitForReady: !1 });
960
+ const y = r.getQueryData(o), p = await ae.all(e, { waitForReady: !1 });
938
961
  if (Array.isArray(y) && y.length > 0 && Array.isArray(p) && p.length === 0)
939
962
  return [...y];
940
963
  if (Array.isArray(p) && p.length === 0) {
@@ -945,74 +968,74 @@ const Sr = () => {
945
968
  return p;
946
969
  },
947
970
  enabled: t && !!e
948
- }), c = e && typeof e == "string" ? e : "";
949
- a.length > 0 && Te.set(c, a);
950
- const i = n.current.length > 0 ? n.current : Te.get(c), d = e ? a.length > 0 ? a : i?.length ? i : a : a;
951
- n.current = d, I(() => {
971
+ }), l = e && typeof e == "string" ? e : "";
972
+ a.length > 0 && $e.set(l, a);
973
+ const i = n.current.length > 0 ? n.current : $e.get(l), d = e ? a.length > 0 ? a : i?.length ? i : a : a;
974
+ n.current = d, w(() => {
952
975
  if (!e || typeof BroadcastChannel > "u") return;
953
976
  const y = new BroadcastChannel("seed-models-invalidate"), p = (E) => {
954
- const { schemaName: w, schemaFileId: m } = E.data || {};
955
- (e === w || e === m) && (r.invalidateQueries({ queryKey: o }), r.refetchQueries({ queryKey: o }));
977
+ const { schemaName: I, schemaFileId: m } = E.data || {};
978
+ (e === I || e === m) && (r.invalidateQueries({ queryKey: o }), r.refetchQueries({ queryKey: o }));
956
979
  };
957
980
  return y.addEventListener("message", p), () => {
958
981
  y.removeEventListener("message", p), y.close();
959
982
  };
960
983
  }, [e, r, o]);
961
- const u = D(null), f = D(null);
962
- function g() {
963
- const y = W.getAppDb();
984
+ const u = C(null), f = C(null);
985
+ function b() {
986
+ const y = j.getAppDb();
964
987
  return !y || !e ? null : y.select({
965
- modelFileId: ae.schemaFileId,
966
- modelName: ae.name
967
- }).from(Y).innerJoin(be, U(Y.id, be.schemaId)).innerJoin(ae, U(be.modelId, ae.id)).where(
968
- te(
969
- U(Y.schemaFileId, e),
970
- U(Y.name, e)
988
+ modelFileId: ce.schemaFileId,
989
+ modelName: ce.name
990
+ }).from(X).innerJoin(ve, q(X.id, ve.schemaId)).innerJoin(ce, q(ve.modelId, ce.id)).where(
991
+ re(
992
+ q(X.schemaFileId, e),
993
+ q(X.name, e)
971
994
  )
972
995
  );
973
996
  }
974
- const v = F(() => {
997
+ const v = N(() => {
975
998
  if (!e || !t) return null;
976
999
  const y = { schemaId: e, ready: t }, p = u.current;
977
1000
  if (p && p.schemaId === y.schemaId && p.ready === y.ready && f.current !== null)
978
1001
  return f.current;
979
- const E = g();
1002
+ const E = b();
980
1003
  return E ? (u.current = y, f.current = E, E) : null;
981
- }, [e, t]), b = ie(v);
982
- return I(() => {
983
- if (!t || !b || !e) return;
1004
+ }, [e, t]), h = Y(v);
1005
+ return w(() => {
1006
+ if (!t || !h || !e) return;
984
1007
  const y = /* @__PURE__ */ new Set();
985
1008
  for (const m of n.current) {
986
- const P = m.id || m.modelFileId;
987
- P ? y.add(P) : m.modelName && y.add(m.modelName);
1009
+ const _ = m.id || m.modelFileId;
1010
+ _ ? y.add(_) : m.modelName && y.add(m.modelName);
988
1011
  }
989
1012
  const p = /* @__PURE__ */ new Set();
990
- for (const m of b)
1013
+ for (const m of h)
991
1014
  m.modelFileId ? p.add(m.modelFileId) : m.modelName && p.add(m.modelName);
992
- const E = y.size === p.size && [...y].every((m) => p.has(m)), w = p.size > 0 && [...p].some((m) => !y.has(m));
993
- !E && w && r.invalidateQueries({ queryKey: o });
994
- }, [t, b, e, r, o]), {
1015
+ const E = y.size === p.size && [...y].every((m) => p.has(m)), I = p.size > 0 && [...p].some((m) => !y.has(m));
1016
+ !E && I && r.invalidateQueries({ queryKey: o });
1017
+ }, [t, h, e, r, o]), {
995
1018
  models: d,
996
1019
  isLoading: s,
997
- error: l
1020
+ error: c
998
1021
  };
999
- }, _t = (e, t) => {
1000
- const r = q(), [n, o] = S(void 0), [a, s] = S(!1), [l, c] = S(null), i = D(void 0), [, d] = S(0), u = t == null;
1001
- if (F(() => r ? u ? !!e : !!(e && t) : !1, [r, u, e, t]), I(() => {
1022
+ }, Rt = (e, t) => {
1023
+ const r = Q(), [n, o] = S(void 0), [a, s] = S(!1), [c, l] = S(null), i = C(void 0), [, d] = S(0), u = t == null;
1024
+ if (N(() => r ? u ? !!e : !!(e && t) : !1, [r, u, e, t]), w(() => {
1002
1025
  if (!r || !u || !e) {
1003
- o(void 0), s(!1), c(null);
1026
+ o(void 0), s(!1), l(null);
1004
1027
  return;
1005
1028
  }
1006
1029
  (async () => {
1007
1030
  try {
1008
- s(!0), c(null);
1009
- const p = await oe.createById(e);
1010
- o(p || void 0), s(!1), c(null);
1031
+ s(!0), l(null);
1032
+ const p = await ae.createById(e);
1033
+ o(p || void 0), s(!1), l(null);
1011
1034
  } catch (p) {
1012
- console.error("[useModel] Error looking up model by ID:", p), o(void 0), s(!1), c(p);
1035
+ console.error("[useModel] Error looking up model by ID:", p), o(void 0), s(!1), l(p);
1013
1036
  }
1014
1037
  })();
1015
- }, [r, u, e]), I(() => {
1038
+ }, [r, u, e]), w(() => {
1016
1039
  if (!u || !n) {
1017
1040
  i.current?.unsubscribe(), i.current = void 0;
1018
1041
  return;
@@ -1028,34 +1051,34 @@ const Sr = () => {
1028
1051
  return {
1029
1052
  model: n,
1030
1053
  isLoading: a,
1031
- error: l
1054
+ error: c
1032
1055
  };
1033
- const { models: f, isLoading: g, error: v } = Ft(e), b = F(() => {
1056
+ const { models: f, isLoading: b, error: v } = Ct(e), h = N(() => {
1034
1057
  if (t)
1035
1058
  return f.find((y) => (y.modelName ?? y.name) === t);
1036
1059
  }, [f, t]);
1037
- return I(() => {
1038
- if (u || !b) {
1060
+ return w(() => {
1061
+ if (u || !h) {
1039
1062
  i.current?.unsubscribe(), i.current = void 0;
1040
1063
  return;
1041
1064
  }
1042
1065
  i.current?.unsubscribe();
1043
- const y = b.getService().subscribe((p) => {
1066
+ const y = h.getService().subscribe((p) => {
1044
1067
  d((E) => E + 1);
1045
1068
  });
1046
1069
  return i.current = y, () => {
1047
1070
  i.current?.unsubscribe(), i.current = void 0;
1048
1071
  };
1049
- }, [u, b]), {
1050
- model: b,
1051
- isLoading: g,
1072
+ }, [u, h]), {
1073
+ model: h,
1074
+ isLoading: b,
1052
1075
  error: v
1053
1076
  };
1054
- }, Nr = () => {
1055
- const e = D(void 0), [t, r] = S(!1), [n, o] = S(null), a = x(() => o(null), []), s = x(
1056
- (l, c, i) => {
1077
+ }, Fr = () => {
1078
+ const e = C(void 0), [t, r] = S(!1), [n, o] = S(null), a = x(() => o(null), []), s = x(
1079
+ (c, l, i) => {
1057
1080
  o(null), r(!0), e.current?.unsubscribe(), e.current = void 0;
1058
- const d = oe.create(c, l, {
1081
+ const d = ae.create(l, c, {
1059
1082
  ...i,
1060
1083
  waitForReady: !1
1061
1084
  }), u = d.getService().subscribe((f) => {
@@ -1067,7 +1090,7 @@ const Sr = () => {
1067
1090
  },
1068
1091
  []
1069
1092
  );
1070
- return I(() => () => {
1093
+ return w(() => () => {
1071
1094
  e.current?.unsubscribe(), e.current = void 0;
1072
1095
  }, []), {
1073
1096
  create: s,
@@ -1075,26 +1098,26 @@ const Sr = () => {
1075
1098
  error: n,
1076
1099
  resetError: a
1077
1100
  };
1078
- }, Ar = () => {
1101
+ }, Cr = () => {
1079
1102
  const [e, t] = S(null), [r, n] = S({
1080
1103
  isLoading: !1,
1081
1104
  error: null
1082
1105
  });
1083
- I(() => {
1106
+ w(() => {
1084
1107
  if (!e) {
1085
1108
  n({ isLoading: !1, error: null });
1086
1109
  return;
1087
1110
  }
1088
- const s = e.getService(), l = () => {
1111
+ const s = e.getService(), c = () => {
1089
1112
  const d = s.getSnapshot().context;
1090
1113
  n({
1091
1114
  isLoading: !!d._destroyInProgress,
1092
1115
  error: d._destroyError ? new Error(d._destroyError.message) : null
1093
1116
  });
1094
1117
  };
1095
- l();
1096
- const c = s.subscribe(l);
1097
- return () => c.unsubscribe();
1118
+ c();
1119
+ const l = s.subscribe(c);
1120
+ return () => l.unsubscribe();
1098
1121
  }, [e]);
1099
1122
  const o = x(async (s) => {
1100
1123
  s && (t(s), await s.destroy());
@@ -1109,9 +1132,9 @@ const Sr = () => {
1109
1132
  };
1110
1133
  };
1111
1134
  G("seedSdk:browser:react:modelProperty");
1112
- const Fr = (e, t) => {
1113
- const { model: r } = _t(e, t);
1114
- F(() => {
1135
+ const Rr = (e, t) => {
1136
+ const { model: r } = Rt(e, t);
1137
+ N(() => {
1115
1138
  if (r)
1116
1139
  try {
1117
1140
  return r.modelName ?? r.name;
@@ -1119,155 +1142,155 @@ const Fr = (e, t) => {
1119
1142
  return;
1120
1143
  }
1121
1144
  }, [r]);
1122
- const n = q(), o = X(), a = F(() => {
1145
+ const n = Q(), o = Z(), a = N(() => {
1123
1146
  if (!r) return null;
1124
1147
  try {
1125
1148
  return r._getSnapshotContext()._dbId;
1126
1149
  } catch {
1127
1150
  return null;
1128
1151
  }
1129
- }, [r]), s = r?.id, l = F(
1152
+ }, [r]), s = r?.id, c = N(
1130
1153
  () => ["seed", "modelProperties", s ?? ""],
1131
1154
  [s]
1132
1155
  ), {
1133
- data: c = [],
1156
+ data: l = [],
1134
1157
  isLoading: i,
1135
1158
  error: d
1136
- } = Z({
1137
- queryKey: l,
1138
- queryFn: () => fe.all(s, { waitForReady: !0 }),
1159
+ } = ee({
1160
+ queryKey: c,
1161
+ queryFn: () => ye.all(s, { waitForReady: !0 }),
1139
1162
  enabled: n && !!s
1140
- }), u = n ? W.getAppDb() : null, f = F(() => !u || !a ? null : u.select({
1141
- id: ee.id,
1142
- name: ee.name,
1143
- dataType: ee.dataType,
1144
- schemaFileId: ee.schemaFileId
1145
- }).from(ee).where(U(ee.modelId, a)), [u, n, a]), g = ie(f), v = D([]);
1146
- v.current = c, I(() => {
1147
- if (!s || c.length > 0 || !o || !l) return;
1163
+ }), u = n ? j.getAppDb() : null, f = N(() => !u || !a ? null : u.select({
1164
+ id: te.id,
1165
+ name: te.name,
1166
+ dataType: te.dataType,
1167
+ schemaFileId: te.schemaFileId
1168
+ }).from(te).where(q(te.modelId, a)), [u, n, a]), b = Y(f), v = C([]);
1169
+ v.current = l, w(() => {
1170
+ if (!s || l.length > 0 || !o || !c) return;
1148
1171
  const p = [400, 1200, 2500].map(
1149
1172
  (E) => setTimeout(() => {
1150
- o.invalidateQueries({ queryKey: l });
1173
+ o.invalidateQueries({ queryKey: c });
1151
1174
  }, E)
1152
1175
  );
1153
1176
  return () => p.forEach((E) => clearTimeout(E));
1154
- }, [s, c.length, o, l]), I(() => {
1155
- if (!n || !r?.id || !g || !l) return;
1177
+ }, [s, l.length, o, c]), w(() => {
1178
+ if (!n || !r?.id || !b || !c) return;
1156
1179
  const y = /* @__PURE__ */ new Set();
1157
1180
  for (const m of v.current) {
1158
- const H = m._getSnapshotContext()?.id;
1159
- H ? y.add(H) : m.name && y.add(m.name);
1181
+ const R = m._getSnapshotContext()?.id;
1182
+ R ? y.add(R) : m.name && y.add(m.name);
1160
1183
  }
1161
1184
  const p = /* @__PURE__ */ new Set();
1162
- for (const m of g)
1185
+ for (const m of b)
1163
1186
  m.schemaFileId ? p.add(m.schemaFileId) : m.name && p.add(m.name);
1164
- !(y.size === p.size && (y.size === 0 || [...y].every((m) => p.has(m)))) && (y.size > 0 || p.size > 0) && o.invalidateQueries({ queryKey: l });
1165
- }, [n, g, r?.id, o, l]);
1166
- const b = i && c.length === 0;
1187
+ !(y.size === p.size && (y.size === 0 || [...y].every((m) => p.has(m)))) && (y.size > 0 || p.size > 0) && o.invalidateQueries({ queryKey: c });
1188
+ }, [n, b, r?.id, o, c]);
1189
+ const h = i && l.length === 0;
1167
1190
  return {
1168
- modelProperties: c,
1169
- isLoading: b,
1191
+ modelProperties: l,
1192
+ isLoading: h,
1170
1193
  error: d
1171
1194
  };
1172
- }, Dt = async (e, t) => {
1173
- const r = await oe.createById(e);
1195
+ }, Pt = async (e, t) => {
1196
+ const r = await ae.createById(e);
1174
1197
  if (!r)
1175
1198
  return;
1176
1199
  const n = r.modelName ?? r.name;
1177
1200
  if (n)
1178
- return Ue(n, t);
1201
+ return ze(n, t);
1179
1202
  };
1180
- function _r(e, t, r) {
1181
- const n = F(() => r != null ? !!(e && t && r) : t != null ? !!(e && t) : !!e, [e, t, r]), [o, a] = S(void 0), [s, l] = S(n), [c, i] = S(null), d = D(void 0), u = q(), f = F(() => r != null ? { type: "schemaId", schemaId: e, modelName: t, propertyName: r } : t != null ? { type: "modelFileId", modelFileId: e, propertyName: t } : { type: "propertyFileId", propertyFileId: e }, [e, t, r]), g = F(() => u ? f.type === "propertyFileId" ? !!f.propertyFileId : f.type === "modelFileId" ? !!(f.modelFileId && f.propertyName) : !!(f.schemaId && f.modelName && f.propertyName) : !1, [u, f]), v = x(async () => {
1203
+ function Pr(e, t, r) {
1204
+ const n = N(() => r != null ? !!(e && t && r) : t != null ? !!(e && t) : !!e, [e, t, r]), [o, a] = S(void 0), [s, c] = S(n), [l, i] = S(null), d = C(void 0), u = Q(), f = N(() => r != null ? { type: "schemaId", schemaId: e, modelName: t, propertyName: r } : t != null ? { type: "modelFileId", modelFileId: e, propertyName: t } : { type: "propertyFileId", propertyFileId: e }, [e, t, r]), b = N(() => u ? f.type === "propertyFileId" ? !!f.propertyFileId : f.type === "modelFileId" ? !!(f.modelFileId && f.propertyName) : !!(f.schemaId && f.modelName && f.propertyName) : !1, [u, f]), v = x(async () => {
1182
1205
  if (!u) {
1183
- a(void 0), l(!1), i(null);
1206
+ a(void 0), c(!1), i(null);
1184
1207
  return;
1185
1208
  }
1186
1209
  let y, p;
1187
1210
  try {
1188
- if (l(!0), i(null), f.type === "propertyFileId") {
1211
+ if (c(!0), i(null), f.type === "propertyFileId") {
1189
1212
  if (!f.propertyFileId) {
1190
- a(void 0), l(!1), i(null);
1213
+ a(void 0), c(!1), i(null);
1191
1214
  return;
1192
1215
  }
1193
- const E = await fe.createById(f.propertyFileId);
1194
- E ? (a(E), l(!1), i(null)) : (a(void 0), l(!1), i(null));
1216
+ const E = await ye.createById(f.propertyFileId);
1217
+ E ? (a(E), c(!1), i(null)) : (a(void 0), c(!1), i(null));
1195
1218
  return;
1196
1219
  } else if (f.type === "modelFileId") {
1197
1220
  if (!f.modelFileId || !f.propertyName) {
1198
- a(void 0), l(!1), i(null);
1221
+ a(void 0), c(!1), i(null);
1199
1222
  return;
1200
1223
  }
1201
- y = await Dt(f.modelFileId, f.propertyName);
1202
- const E = await oe.createById(f.modelFileId);
1224
+ y = await Pt(f.modelFileId, f.propertyName);
1225
+ const E = await ae.createById(f.modelFileId);
1203
1226
  p = E?.modelName ?? E?.name;
1204
1227
  } else {
1205
1228
  if (!f.schemaId || !f.modelName || !f.propertyName) {
1206
- a(void 0), l(!1), i(null);
1229
+ a(void 0), c(!1), i(null);
1207
1230
  return;
1208
1231
  }
1209
- y = await Ue(f.modelName, f.propertyName), p = f.modelName;
1232
+ y = await ze(f.modelName, f.propertyName), p = f.modelName;
1210
1233
  }
1211
1234
  if (y && p) {
1212
- const E = fe.create(
1235
+ const E = ye.create(
1213
1236
  { ...y, modelName: p },
1214
1237
  { waitForReady: !1 }
1215
- ), w = E instanceof Promise ? await E : E;
1216
- de(() => {
1217
- a(w), l(!1), i(null);
1238
+ ), I = E instanceof Promise ? await E : E;
1239
+ ue(() => {
1240
+ a(I), c(!1), i(null);
1218
1241
  });
1219
1242
  } else
1220
- a(void 0), l(!1), i(null);
1243
+ a(void 0), c(!1), i(null);
1221
1244
  } catch (E) {
1222
- console.error("[useModelProperty] Error updating model property:", E), a(void 0), l(!1), i(E);
1245
+ console.error("[useModelProperty] Error updating model property:", E), a(void 0), c(!1), i(E);
1223
1246
  }
1224
1247
  }, [u, f.type, f.propertyFileId, f.modelFileId, f.propertyName, f.schemaId, f.modelName]);
1225
- I(() => {
1226
- if (!g) {
1227
- a(void 0), l(!1), i(null);
1248
+ w(() => {
1249
+ if (!b) {
1250
+ a(void 0), c(!1), i(null);
1228
1251
  return;
1229
1252
  }
1230
1253
  v();
1231
- }, [g, v]);
1232
- const b = f.type === "propertyFileId";
1233
- return I(() => {
1234
- if (!o || !b)
1254
+ }, [b, v]);
1255
+ const h = f.type === "propertyFileId";
1256
+ return w(() => {
1257
+ if (!o || !h)
1235
1258
  return;
1236
1259
  d.current?.unsubscribe();
1237
- const y = ze(v, 100), p = o.getService().subscribe(() => {
1260
+ const y = He(v, 100), p = o.getService().subscribe(() => {
1238
1261
  y();
1239
1262
  });
1240
1263
  return d.current = p, () => {
1241
1264
  y.cancel(), d.current?.unsubscribe(), d.current = void 0;
1242
1265
  };
1243
- }, [o, v, b]), {
1266
+ }, [o, v, h]), {
1244
1267
  modelProperty: o,
1245
1268
  isLoading: s,
1246
- error: c
1269
+ error: l
1247
1270
  };
1248
1271
  }
1249
- const Dr = () => {
1250
- const e = D(void 0), [t, r] = S(!1), [n, o] = S(null), a = x(() => o(null), []), s = x(
1251
- (l, c, i) => {
1252
- if (o(null), r(!0), e.current?.unsubscribe(), e.current = void 0, !c || !i.name || !i.dataType) {
1253
- const g = new Error("modelName, property name and dataType are required");
1254
- throw o(g), r(!1), g;
1272
+ const Tr = () => {
1273
+ const e = C(void 0), [t, r] = S(!1), [n, o] = S(null), a = x(() => o(null), []), s = x(
1274
+ (c, l, i) => {
1275
+ if (o(null), r(!0), e.current?.unsubscribe(), e.current = void 0, !l || !i.name || !i.dataType) {
1276
+ const b = new Error("modelName, property name and dataType are required");
1277
+ throw o(b), r(!1), b;
1255
1278
  }
1256
- const d = it(l) ?? l, u = fe.create(
1257
- { ...i, modelName: c },
1279
+ const d = dt(c) ?? c, u = ye.create(
1280
+ { ...i, modelName: l },
1258
1281
  { waitForReady: !1, schemaName: d }
1259
- ), f = u.getService().subscribe((g) => {
1260
- if (g.value === "error") {
1261
- const v = g.context._loadingError?.error ?? new Error("Failed to create model property");
1282
+ ), f = u.getService().subscribe((b) => {
1283
+ if (b.value === "error") {
1284
+ const v = b.context._loadingError?.error ?? new Error("Failed to create model property");
1262
1285
  o(v instanceof Error ? v : new Error(String(v))), r(!1);
1263
1286
  }
1264
- g.value === "idle" && (o(null), r(!1));
1287
+ b.value === "idle" && (o(null), r(!1));
1265
1288
  });
1266
1289
  return e.current = f, u;
1267
1290
  },
1268
1291
  []
1269
1292
  );
1270
- return I(() => () => {
1293
+ return w(() => () => {
1271
1294
  e.current?.unsubscribe(), e.current = void 0;
1272
1295
  }, []), {
1273
1296
  create: s,
@@ -1275,26 +1298,26 @@ const Dr = () => {
1275
1298
  error: n,
1276
1299
  resetError: a
1277
1300
  };
1278
- }, Cr = () => {
1301
+ }, Mr = () => {
1279
1302
  const [e, t] = S(null), [r, n] = S({
1280
1303
  isLoading: !1,
1281
1304
  error: null
1282
1305
  });
1283
- I(() => {
1306
+ w(() => {
1284
1307
  if (!e) {
1285
1308
  n({ isLoading: !1, error: null });
1286
1309
  return;
1287
1310
  }
1288
- const s = e.getService(), l = () => {
1311
+ const s = e.getService(), c = () => {
1289
1312
  const d = s.getSnapshot().context;
1290
1313
  n({
1291
1314
  isLoading: !!d._destroyInProgress,
1292
1315
  error: d._destroyError ? new Error(d._destroyError.message) : null
1293
1316
  });
1294
1317
  };
1295
- l();
1296
- const c = s.subscribe(l);
1297
- return () => c.unsubscribe();
1318
+ c();
1319
+ const l = s.subscribe(c);
1320
+ return () => l.unsubscribe();
1298
1321
  }, [e]);
1299
1322
  const o = x(async (s) => {
1300
1323
  s && (t(s), await s.destroy());
@@ -1307,26 +1330,26 @@ const Dr = () => {
1307
1330
  error: r.error,
1308
1331
  resetError: a
1309
1332
  };
1310
- }, Rr = () => {
1333
+ }, kr = () => {
1311
1334
  const [e, t] = S(null), [r, n] = S({
1312
1335
  isLoading: !1,
1313
1336
  error: null
1314
1337
  });
1315
- I(() => {
1338
+ w(() => {
1316
1339
  if (!e) {
1317
1340
  n({ isLoading: !1, error: null });
1318
1341
  return;
1319
1342
  }
1320
- const s = e.getService(), l = () => {
1343
+ const s = e.getService(), c = () => {
1321
1344
  const d = s.getSnapshot().context;
1322
1345
  n({
1323
1346
  isLoading: !!d._destroyInProgress,
1324
1347
  error: d._destroyError ? new Error(d._destroyError.message) : null
1325
1348
  });
1326
1349
  };
1327
- l();
1328
- const c = s.subscribe(l);
1329
- return () => c.unsubscribe();
1350
+ c();
1351
+ const l = s.subscribe(c);
1352
+ return () => l.unsubscribe();
1330
1353
  }, [e]);
1331
1354
  const o = x(async (s) => {
1332
1355
  s && (t(s), await s.destroy());
@@ -1339,26 +1362,26 @@ const Dr = () => {
1339
1362
  error: r.error,
1340
1363
  resetError: a
1341
1364
  };
1342
- }, Se = ["seed", "imageFiles"];
1343
- function Pr() {
1344
- const e = q(), t = X(), {
1365
+ }, Ie = ["seed", "imageFiles"];
1366
+ function $r() {
1367
+ const e = Q(), t = Z(), {
1345
1368
  data: r = [],
1346
1369
  isLoading: n,
1347
1370
  error: o,
1348
1371
  refetch: a
1349
- } = Z({
1350
- queryKey: Se,
1351
- queryFn: () => j.listImageFiles(),
1372
+ } = ee({
1373
+ queryKey: Ie,
1374
+ queryFn: () => W.listImageFiles(),
1352
1375
  enabled: e
1353
1376
  });
1354
- return I(() => {
1355
- const s = (c) => {
1356
- c.includes("/images/") && t.invalidateQueries({ queryKey: Se });
1357
- }, l = () => {
1358
- t.invalidateQueries({ queryKey: Se });
1377
+ return w(() => {
1378
+ const s = (l) => {
1379
+ l.includes("/images/") && t.invalidateQueries({ queryKey: Ie });
1380
+ }, c = () => {
1381
+ t.invalidateQueries({ queryKey: Ie });
1359
1382
  };
1360
- return K.on("file-saved", s), K.on("fs.downloadAll.success", l), () => {
1361
- K.off("file-saved", s), K.off("fs.downloadAll.success", l);
1383
+ return z.on("file-saved", s), z.on("fs.downloadAll.success", c), () => {
1384
+ z.off("file-saved", s), z.off("fs.downloadAll.success", c);
1362
1385
  };
1363
1386
  }, [t]), {
1364
1387
  imageFiles: r,
@@ -1367,35 +1390,63 @@ function Pr() {
1367
1390
  refetch: a
1368
1391
  };
1369
1392
  }
1370
- const Ct = ["seed", "files"];
1371
- function Mr(e = "files") {
1372
- const t = q(), r = X(), n = F(() => [...Ct, e], [e]), {
1393
+ const Tt = ["seed", "files"];
1394
+ function Br(e = "files") {
1395
+ const t = Q(), r = Z(), n = N(() => [...Tt, e], [e]), {
1373
1396
  data: o = [],
1374
1397
  isLoading: a,
1375
1398
  error: s,
1376
- refetch: l
1377
- } = Z({
1399
+ refetch: c
1400
+ } = ee({
1378
1401
  queryKey: n,
1379
- queryFn: () => j.listFiles(e),
1402
+ queryFn: () => W.listFiles(e),
1380
1403
  enabled: t
1381
1404
  });
1382
- return I(() => {
1383
- const c = (d) => {
1405
+ return w(() => {
1406
+ const l = (d) => {
1384
1407
  d.includes(`/${e}/`) && r.invalidateQueries({ queryKey: n });
1385
1408
  }, i = () => {
1386
1409
  r.invalidateQueries({ queryKey: n });
1387
1410
  };
1388
- return K.on("file-saved", c), K.on("fs.downloadAll.success", i), () => {
1389
- K.off("file-saved", c), K.off("fs.downloadAll.success", i);
1411
+ return z.on("file-saved", l), z.on("fs.downloadAll.success", i), () => {
1412
+ z.off("file-saved", l), z.off("fs.downloadAll.success", i);
1390
1413
  };
1391
1414
  }, [r, e, n]), {
1392
1415
  files: o,
1393
1416
  isLoading: a,
1394
1417
  error: s instanceof Error ? s : null,
1395
- refetch: l
1418
+ refetch: c
1396
1419
  };
1397
1420
  }
1398
- const Rt = {
1421
+ function Ye() {
1422
+ const e = j.getAppDb();
1423
+ return N(
1424
+ () => e ? e.select().from(pe).orderBy(Ve(pe.startedAt)) : null,
1425
+ [e]
1426
+ );
1427
+ }
1428
+ function Mt() {
1429
+ const e = Ye(), t = Y(e), r = N(
1430
+ () => t === void 0 ? void 0 : t.filter((n) => n.status !== "in_progress").length,
1431
+ [t]
1432
+ );
1433
+ return { records: t, nonActiveCount: r };
1434
+ }
1435
+ function Or() {
1436
+ const e = Ye();
1437
+ return Y(e);
1438
+ }
1439
+ function Ur() {
1440
+ return Mt().nonActiveCount;
1441
+ }
1442
+ function qr(e) {
1443
+ const t = j.getAppDb(), r = N(
1444
+ () => e != null && t ? t.select().from(pe).where(q(pe.id, e)).limit(1) : null,
1445
+ [t, e]
1446
+ ), n = Y(r), o = n === void 0;
1447
+ return { record: n && n.length > 0 ? n[0] : null, isLoading: o };
1448
+ }
1449
+ const kt = {
1399
1450
  queries: {
1400
1451
  networkMode: "offlineFirst",
1401
1452
  gcTime: 1e3 * 60 * 60 * 24,
@@ -1404,11 +1455,11 @@ const Rt = {
1404
1455
  // 1 minute - list data can be slightly stale
1405
1456
  }
1406
1457
  };
1407
- function We() {
1408
- return { ...Rt };
1458
+ function Xe() {
1459
+ return { ...kt };
1409
1460
  }
1410
- function Pt(e) {
1411
- const t = We();
1461
+ function $t(e) {
1462
+ const t = Xe();
1412
1463
  return e ? {
1413
1464
  queries: {
1414
1465
  ...t.queries,
@@ -1420,38 +1471,40 @@ function Pt(e) {
1420
1471
  }
1421
1472
  } : t;
1422
1473
  }
1423
- function Mt(e) {
1424
- const t = We(), { defaultOptions: r, ...n } = e ?? {};
1425
- return new mt({
1474
+ function Bt(e) {
1475
+ const t = Xe(), { defaultOptions: r, ...n } = e ?? {};
1476
+ return new bt({
1426
1477
  ...n,
1427
- defaultOptions: r ? Pt(r) : t
1478
+ defaultOptions: r ? $t(r) : t
1428
1479
  });
1429
1480
  }
1430
- let Ne = null;
1431
- function Tr(e) {
1432
- const t = Ne?.(e);
1481
+ let _e = null;
1482
+ function zr(e) {
1483
+ const t = _e?.(e);
1433
1484
  return typeof window < "u" && window.__SEED_INVALIDATE_ITEM_PROPERTIES__ && window.__SEED_INVALIDATE_ITEM_PROPERTIES__(e), Promise.resolve(t).then(() => {
1434
1485
  });
1435
1486
  }
1436
- function Tt({ queryClient: e }) {
1437
- return I(() => {
1438
- const t = (n) => {
1439
- const o = ["seed", "itemProperties", n];
1440
- return e.invalidateQueries({ queryKey: o }), e.refetchQueries({ queryKey: o });
1487
+ function Ot({ queryClient: e }) {
1488
+ return w(() => {
1489
+ const t = (o) => {
1490
+ const a = ["seed", "itemProperties", o];
1491
+ return e.invalidateQueries({ queryKey: a }), e.refetchQueries({ queryKey: a });
1441
1492
  };
1442
- Ne = t, typeof window < "u" && (window.__SEED_INVALIDATE_ITEM_PROPERTIES__ = t);
1443
- const r = (n) => {
1444
- const o = n?.seedLocalId ?? n?.seedUid;
1445
- o && t(o);
1493
+ _e = t, typeof window < "u" && (window.__SEED_INVALIDATE_ITEM_PROPERTIES__ = t);
1494
+ const r = (o) => {
1495
+ const a = o?.seedLocalId ?? o?.seedUid;
1496
+ a && t(a);
1497
+ }, n = () => {
1498
+ e.invalidateQueries({ queryKey: ["seed", "items"], exact: !1 });
1446
1499
  };
1447
- return K.on("itemProperty.saved", r), () => {
1448
- K.off("itemProperty.saved", r), Ne = null, typeof window < "u" && (window.__SEED_INVALIDATE_ITEM_PROPERTIES__ = null);
1500
+ return z.on("itemProperty.saved", r), z.on(ne, n), () => {
1501
+ z.off("itemProperty.saved", r), z.off(ne, n), _e = null, typeof window < "u" && (window.__SEED_INVALIDATE_ITEM_PROPERTIES__ = null);
1449
1502
  };
1450
1503
  }, [e]), null;
1451
1504
  }
1452
- function kr({ children: e, queryClient: t, queryClientRef: r }) {
1453
- const n = F(
1454
- () => t ?? Mt(),
1505
+ function Hr({ children: e, queryClient: t, queryClientRef: r }) {
1506
+ const n = N(
1507
+ () => t ?? Bt(),
1455
1508
  [t]
1456
1509
  );
1457
1510
  if (r && (r.current = n, typeof window < "u")) {
@@ -1462,13 +1515,13 @@ function kr({ children: e, queryClient: t, queryClientRef: r }) {
1462
1515
  } catch {
1463
1516
  }
1464
1517
  }
1465
- return /* @__PURE__ */ h(ht, { client: n, children: /* @__PURE__ */ O(bt, { queryClient: n, children: [
1466
- /* @__PURE__ */ h(Tt, { queryClient: n }),
1518
+ return /* @__PURE__ */ g(St, { client: n, children: /* @__PURE__ */ U(wt, { queryClient: n, children: [
1519
+ /* @__PURE__ */ g(Ot, { queryClient: n }),
1467
1520
  e
1468
1521
  ] }) });
1469
1522
  }
1470
- function kt() {
1471
- return /* @__PURE__ */ h(
1523
+ function Ut() {
1524
+ return /* @__PURE__ */ g(
1472
1525
  "div",
1473
1526
  {
1474
1527
  style: {
@@ -1482,7 +1535,7 @@ function kt() {
1482
1535
  }
1483
1536
  );
1484
1537
  }
1485
- function $r({
1538
+ function Qr({
1486
1539
  initConfig: e,
1487
1540
  schema: t,
1488
1541
  loadingComponent: r,
@@ -1490,8 +1543,8 @@ function $r({
1490
1543
  loadingClassName: o,
1491
1544
  children: a
1492
1545
  }) {
1493
- const s = q();
1494
- I(() => {
1546
+ const s = Q();
1547
+ w(() => {
1495
1548
  const u = t ? {
1496
1549
  ...e,
1497
1550
  config: {
@@ -1499,9 +1552,9 @@ function $r({
1499
1552
  schema: t
1500
1553
  }
1501
1554
  } : e;
1502
- at.init(u);
1555
+ ut.init(u);
1503
1556
  }, [e, t]);
1504
- const l = r ?? /* @__PURE__ */ h(kt, {}), c = n ? void 0 : { position: "relative", display: "flex", height: "100vh", width: "100vw" }, i = {
1557
+ const c = r ?? /* @__PURE__ */ g(Ut, {}), l = n ? void 0 : { position: "relative", display: "flex", height: "100vh", width: "100vw" }, i = {
1505
1558
  display: s ? "none" : "flex",
1506
1559
  ...!o && {
1507
1560
  position: "absolute",
@@ -1511,24 +1564,24 @@ function $r({
1511
1564
  justifyContent: "center"
1512
1565
  }
1513
1566
  };
1514
- return /* @__PURE__ */ O("div", { className: n, style: c, children: [
1515
- /* @__PURE__ */ h(
1567
+ return /* @__PURE__ */ U("div", { className: n, style: l, children: [
1568
+ /* @__PURE__ */ g(
1516
1569
  "div",
1517
1570
  {
1518
1571
  className: o,
1519
1572
  style: i,
1520
1573
  "aria-hidden": s,
1521
- children: l
1574
+ children: c
1522
1575
  }
1523
1576
  ),
1524
- /* @__PURE__ */ h("div", { style: {
1577
+ /* @__PURE__ */ g("div", { style: {
1525
1578
  flex: 1,
1526
1579
  display: s ? "flex" : "none",
1527
1580
  flexDirection: "column"
1528
1581
  }, children: a })
1529
1582
  ] });
1530
1583
  }
1531
- async function Je(e, t = "") {
1584
+ async function Ze(e, t = "") {
1532
1585
  const r = [];
1533
1586
  try {
1534
1587
  for await (const [n, o] of e.entries()) {
@@ -1547,7 +1600,7 @@ async function Je(e, t = "") {
1547
1600
  console.warn(`Failed to read file ${a}:`, s);
1548
1601
  }
1549
1602
  else if (o.kind === "directory") {
1550
- const s = await Je(o, a);
1603
+ const s = await Ze(o, a);
1551
1604
  r.push(...s);
1552
1605
  }
1553
1606
  }
@@ -1556,31 +1609,31 @@ async function Je(e, t = "") {
1556
1609
  }
1557
1610
  return r;
1558
1611
  }
1559
- function $t(e = {}) {
1560
- const { rootPath: t } = e, [r, n] = S([]), [o, a] = S(!0), [s, l] = S(null), c = x(async () => {
1561
- a(!0), l(null);
1612
+ function qt(e = {}) {
1613
+ const { rootPath: t } = e, [r, n] = S([]), [o, a] = S(!0), [s, c] = S(null), l = x(async () => {
1614
+ a(!0), c(null);
1562
1615
  try {
1563
1616
  let d = await navigator.storage.getDirectory();
1564
1617
  if (t) {
1565
1618
  const f = t.split("/").filter(Boolean);
1566
- for (const g of f)
1567
- d = await d.getDirectoryHandle(g);
1619
+ for (const b of f)
1620
+ d = await d.getDirectoryHandle(b);
1568
1621
  }
1569
- const u = await Je(d, t || "");
1570
- n(u.sort((f, g) => f.path.localeCompare(g.path)));
1622
+ const u = await Ze(d, t || "");
1623
+ n(u.sort((f, b) => f.path.localeCompare(b.path)));
1571
1624
  } catch (i) {
1572
- l(
1625
+ c(
1573
1626
  "Failed to access OPFS: " + (i instanceof Error ? i.message : String(i))
1574
1627
  ), console.error("OPFS access error:", i);
1575
1628
  } finally {
1576
1629
  a(!1);
1577
1630
  }
1578
1631
  }, [t]);
1579
- return I(() => {
1580
- c();
1581
- }, [c]), { files: r, isLoading: o, error: s, refetch: c };
1632
+ return w(() => {
1633
+ l();
1634
+ }, [l]), { files: r, isLoading: o, error: s, refetch: l };
1582
1635
  }
1583
- const ke = () => /* @__PURE__ */ h("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", style: { width: 20, height: 20 }, children: /* @__PURE__ */ h("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3" }) }), Bt = () => /* @__PURE__ */ h("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", style: { width: 48, height: 48 }, children: /* @__PURE__ */ h("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M2.25 12.75V12a2.25 2.25 0 012.25-2.25h15A2.25 2.25 0 0121.75 12v.75m-8.69-6.44l-2.12-2.12a1.5 1.5 0 00-1.061-.44H4.5A2.25 2.25 0 002.25 6v12a2.25 2.25 0 002.25 2.25h15A2.25 2.25 0 0021.75 18V9a2.25 2.25 0 00-2.25-2.25h-5.379a1.5 1.5 0 01-1.06-.44z" }) }), Ot = () => /* @__PURE__ */ h("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", style: { width: 20, height: 20 }, children: /* @__PURE__ */ h("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z" }) }), $e = () => /* @__PURE__ */ h("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", style: { width: 20, height: 20 }, children: /* @__PURE__ */ h("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" }) }), Ut = () => /* @__PURE__ */ O(
1636
+ const Be = () => /* @__PURE__ */ g("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", style: { width: 20, height: 20 }, children: /* @__PURE__ */ g("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3" }) }), zt = () => /* @__PURE__ */ g("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", style: { width: 48, height: 48 }, children: /* @__PURE__ */ g("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M2.25 12.75V12a2.25 2.25 0 012.25-2.25h15A2.25 2.25 0 0121.75 12v.75m-8.69-6.44l-2.12-2.12a1.5 1.5 0 00-1.061-.44H4.5A2.25 2.25 0 002.25 6v12a2.25 2.25 0 002.25 2.25h15A2.25 2.25 0 0021.75 18V9a2.25 2.25 0 00-2.25-2.25h-5.379a1.5 1.5 0 01-1.06-.44z" }) }), Ht = () => /* @__PURE__ */ g("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", style: { width: 20, height: 20 }, children: /* @__PURE__ */ g("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z" }) }), Oe = () => /* @__PURE__ */ g("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", style: { width: 20, height: 20 }, children: /* @__PURE__ */ g("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" }) }), Qt = () => /* @__PURE__ */ U(
1584
1637
  "svg",
1585
1638
  {
1586
1639
  xmlns: "http://www.w3.org/2000/svg",
@@ -1589,7 +1642,7 @@ const ke = () => /* @__PURE__ */ h("svg", { xmlns: "http://www.w3.org/2000/svg",
1589
1642
  style: { width: 32, height: 32 },
1590
1643
  "aria-hidden": !0,
1591
1644
  children: [
1592
- /* @__PURE__ */ h(
1645
+ /* @__PURE__ */ g(
1593
1646
  "circle",
1594
1647
  {
1595
1648
  style: { opacity: 0.25 },
@@ -1600,7 +1653,7 @@ const ke = () => /* @__PURE__ */ h("svg", { xmlns: "http://www.w3.org/2000/svg",
1600
1653
  strokeWidth: "4"
1601
1654
  }
1602
1655
  ),
1603
- /* @__PURE__ */ h(
1656
+ /* @__PURE__ */ g(
1604
1657
  "path",
1605
1658
  {
1606
1659
  style: { opacity: 0.75 },
@@ -1611,24 +1664,24 @@ const ke = () => /* @__PURE__ */ h("svg", { xmlns: "http://www.w3.org/2000/svg",
1611
1664
  ]
1612
1665
  }
1613
1666
  );
1614
- function zt(e) {
1667
+ function Vt(e) {
1615
1668
  if (e === 0) return "0 Bytes";
1616
1669
  const t = 1024, r = ["Bytes", "KB", "MB", "GB"], n = Math.floor(Math.log(e) / Math.log(t));
1617
1670
  return Math.round(e / Math.pow(t, n) * 100) / 100 + " " + r[n];
1618
1671
  }
1619
- function qt(e) {
1672
+ function Kt(e) {
1620
1673
  return new Date(e).toLocaleString();
1621
1674
  }
1622
- async function Ht(e, t) {
1675
+ async function jt(e, t) {
1623
1676
  const r = e.path.split("/").filter(Boolean);
1624
1677
  if (r.length === 0) throw new Error("Invalid file path");
1625
1678
  let n = t;
1626
- for (let l = 0; l < r.length - 1; l++)
1627
- n = await n.getDirectoryHandle(r[l]);
1679
+ for (let c = 0; c < r.length - 1; c++)
1680
+ n = await n.getDirectoryHandle(r[c]);
1628
1681
  const o = r[r.length - 1];
1629
1682
  return await (await n.getFileHandle(o)).getFile();
1630
1683
  }
1631
- async function Be(e, t) {
1684
+ async function Ue(e, t) {
1632
1685
  const r = e.split("/").filter(Boolean);
1633
1686
  if (r.length === 0) throw new Error("Invalid file path");
1634
1687
  let n = t;
@@ -1637,7 +1690,7 @@ async function Be(e, t) {
1637
1690
  const o = r[r.length - 1];
1638
1691
  await n.removeEntry(o);
1639
1692
  }
1640
- const Qt = {
1693
+ const Wt = {
1641
1694
  light: {
1642
1695
  title: "text-gray-900",
1643
1696
  description: "text-gray-500",
@@ -1682,7 +1735,7 @@ const Qt = {
1682
1735
  actionButton: "text-gray-400 hover:text-indigo-400",
1683
1736
  deleteButton: "text-gray-400 hover:text-red-500"
1684
1737
  }
1685
- }, R = {
1738
+ }, T = {
1686
1739
  container: { padding: "2rem 0" },
1687
1740
  header: {
1688
1741
  display: "flex",
@@ -1701,7 +1754,7 @@ const Qt = {
1701
1754
  errorBox: "rounded-md border p-4 mt-4",
1702
1755
  emptyState: "text-center py-12"
1703
1756
  };
1704
- function Br({
1757
+ function Vr({
1705
1758
  rootPath: e,
1706
1759
  filter: t,
1707
1760
  onBeforeDelete: r,
@@ -1709,110 +1762,110 @@ function Br({
1709
1762
  onDownload: o,
1710
1763
  title: a = "Files",
1711
1764
  description: s = "Browse and download all files stored in the Origin Private File System (OPFS).",
1712
- theme: l = "dark",
1713
- className: c
1765
+ theme: c = "dark",
1766
+ className: l
1714
1767
  }) {
1715
- const i = Qt[l], { files: d, isLoading: u, error: f, refetch: g } = $t({ rootPath: e }), v = t ? d.filter(t) : d, [b, y] = S(/* @__PURE__ */ new Set()), p = D(null), E = v.length > 0 && b.size === v.length, w = b.size > 0 && b.size < v.length, m = (L) => {
1716
- y((k) => {
1717
- const _ = new Set(k);
1718
- return _.has(L) ? _.delete(L) : _.add(L), _;
1768
+ const i = Wt[c], { files: d, isLoading: u, error: f, refetch: b } = qt({ rootPath: e }), v = t ? d.filter(t) : d, [h, y] = S(/* @__PURE__ */ new Set()), p = C(null), E = v.length > 0 && h.size === v.length, I = h.size > 0 && h.size < v.length, m = (L) => {
1769
+ y(($) => {
1770
+ const F = new Set($);
1771
+ return F.has(L) ? F.delete(L) : F.add(L), F;
1719
1772
  });
1720
- }, P = () => {
1773
+ }, _ = () => {
1721
1774
  y(
1722
- b.size === v.length ? /* @__PURE__ */ new Set() : new Set(v.map((L) => L.path))
1775
+ h.size === v.length ? /* @__PURE__ */ new Set() : new Set(v.map((L) => L.path))
1723
1776
  );
1724
1777
  };
1725
- I(() => {
1778
+ w(() => {
1726
1779
  y(/* @__PURE__ */ new Set());
1727
- }, [v.length]), I(() => {
1728
- p.current && (p.current.indeterminate = w);
1729
- }, [w]);
1730
- const H = async (L, k = !1) => {
1780
+ }, [v.length]), w(() => {
1781
+ p.current && (p.current.indeterminate = I);
1782
+ }, [I]);
1783
+ const R = async (L, $ = !1) => {
1731
1784
  try {
1732
- const _ = await navigator.storage.getDirectory(), z = await Ht(L, _);
1785
+ const F = await navigator.storage.getDirectory(), H = await jt(L, F);
1733
1786
  if (o)
1734
- await o(L, z);
1787
+ await o(L, H);
1735
1788
  else {
1736
- const V = URL.createObjectURL(z), M = document.createElement("a");
1737
- M.href = V, M.download = L.name, document.body.appendChild(M), M.click(), document.body.removeChild(M), URL.revokeObjectURL(V);
1789
+ const K = URL.createObjectURL(H), M = document.createElement("a");
1790
+ M.href = K, M.download = L.name, document.body.appendChild(M), M.click(), document.body.removeChild(M), URL.revokeObjectURL(K);
1738
1791
  }
1739
- } catch (_) {
1740
- const z = "Failed to download file: " + (_ instanceof Error ? _.message : String(_));
1741
- throw k || alert(z), _;
1792
+ } catch (F) {
1793
+ const H = "Failed to download file: " + (F instanceof Error ? F.message : String(F));
1794
+ throw $ || alert(H), F;
1742
1795
  }
1743
- }, N = async (L) => {
1796
+ }, A = async (L) => {
1744
1797
  if (!(r && !await r(L)) && confirm(`Are you sure you want to delete "${L.name}"? This action cannot be undone.`))
1745
1798
  try {
1746
- const k = await navigator.storage.getDirectory();
1747
- await Be(L.path, k), await g(), await n?.([L.path]);
1748
- } catch (k) {
1749
- alert("Failed to delete file: " + (k instanceof Error ? k.message : String(k)));
1799
+ const $ = await navigator.storage.getDirectory();
1800
+ await Ue(L.path, $), await b(), await n?.([L.path]);
1801
+ } catch ($) {
1802
+ alert("Failed to delete file: " + ($ instanceof Error ? $.message : String($)));
1750
1803
  }
1751
- }, $ = async () => {
1752
- if (b.size === 0) return;
1753
- const L = v.filter((_) => b.has(_.path)), k = [];
1754
- for (const _ of L)
1804
+ }, B = async () => {
1805
+ if (h.size === 0) return;
1806
+ const L = v.filter((F) => h.has(F.path)), $ = [];
1807
+ for (const F of L)
1755
1808
  try {
1756
- await H(_, !0), await new Promise((z) => setTimeout(z, 100));
1757
- } catch (z) {
1758
- k.push(`${_.name}: ${z instanceof Error ? z.message : String(z)}`);
1809
+ await R(F, !0), await new Promise((H) => setTimeout(H, 100));
1810
+ } catch (H) {
1811
+ $.push(`${F.name}: ${H instanceof Error ? H.message : String(H)}`);
1759
1812
  }
1760
- k.length > 0 && alert(`Some downloads failed:
1761
- ${k.join(`
1813
+ $.length > 0 && alert(`Some downloads failed:
1814
+ ${$.join(`
1762
1815
  `)}`);
1763
- }, Q = async () => {
1764
- if (b.size === 0) return;
1765
- const L = v.filter((M) => b.has(M.path)), k = L.map((M) => M.name).join(", ");
1816
+ }, V = async () => {
1817
+ if (h.size === 0) return;
1818
+ const L = v.filter((M) => h.has(M.path)), $ = L.map((M) => M.name).join(", ");
1766
1819
  if (!confirm(
1767
- `Are you sure you want to delete ${b.size} file(s)?
1820
+ `Are you sure you want to delete ${h.size} file(s)?
1768
1821
 
1769
- Files: ${k}
1822
+ Files: ${$}
1770
1823
 
1771
1824
  This action cannot be undone.`
1772
1825
  ))
1773
1826
  return;
1774
- const _ = await navigator.storage.getDirectory(), z = [], V = [];
1827
+ const F = await navigator.storage.getDirectory(), H = [], K = [];
1775
1828
  for (const M of L)
1776
1829
  if (!(r && !await r(M)))
1777
1830
  try {
1778
- await Be(M.path, _), z.push(M.path);
1831
+ await Ue(M.path, F), H.push(M.path);
1779
1832
  } catch (J) {
1780
- V.push(`${M.name}: ${J instanceof Error ? J.message : String(J)}`);
1833
+ K.push(`${M.name}: ${J instanceof Error ? J.message : String(J)}`);
1781
1834
  }
1782
- y(/* @__PURE__ */ new Set()), await g(), z.length > 0 && await n?.(z), V.length > 0 && alert(`Some deletions failed:
1783
- ${V.join(`
1835
+ y(/* @__PURE__ */ new Set()), await b(), H.length > 0 && await n?.(H), K.length > 0 && alert(`Some deletions failed:
1836
+ ${K.join(`
1784
1837
  `)}`);
1785
1838
  };
1786
- return /* @__PURE__ */ O("div", { className: c, style: R.container, children: [
1787
- /* @__PURE__ */ h("style", { children: "@keyframes opfs-spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}" }),
1788
- /* @__PURE__ */ O("div", { style: R.header, children: [
1789
- /* @__PURE__ */ O("div", { style: { flex: 1, minWidth: 0 }, children: [
1790
- /* @__PURE__ */ h("h1", { style: R.title, className: i.title, children: a }),
1791
- /* @__PURE__ */ h("p", { style: R.description, className: i.description, children: s })
1839
+ return /* @__PURE__ */ U("div", { className: l, style: T.container, children: [
1840
+ /* @__PURE__ */ g("style", { children: "@keyframes opfs-spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}" }),
1841
+ /* @__PURE__ */ U("div", { style: T.header, children: [
1842
+ /* @__PURE__ */ U("div", { style: { flex: 1, minWidth: 0 }, children: [
1843
+ /* @__PURE__ */ g("h1", { style: T.title, className: i.title, children: a }),
1844
+ /* @__PURE__ */ g("p", { style: T.description, className: i.description, children: s })
1792
1845
  ] }),
1793
- /* @__PURE__ */ h("button", { type: "button", onClick: g, className: R.button, children: "Refresh" })
1846
+ /* @__PURE__ */ g("button", { type: "button", onClick: b, className: T.button, children: "Refresh" })
1794
1847
  ] }),
1795
- b.size > 0 && /* @__PURE__ */ O(
1848
+ h.size > 0 && /* @__PURE__ */ U(
1796
1849
  "div",
1797
1850
  {
1798
1851
  className: `mt-4 flex items-center justify-between rounded-lg border px-4 py-3 ${i.batchBar}`,
1799
1852
  children: [
1800
- /* @__PURE__ */ O("span", { className: `text-sm font-medium ${i.batchText}`, children: [
1801
- b.size,
1853
+ /* @__PURE__ */ U("span", { className: `text-sm font-medium ${i.batchText}`, children: [
1854
+ h.size,
1802
1855
  " file",
1803
- b.size === 1 ? "" : "s",
1856
+ h.size === 1 ? "" : "s",
1804
1857
  " selected"
1805
1858
  ] }),
1806
- /* @__PURE__ */ O("div", { className: "flex items-center gap-3", children: [
1807
- /* @__PURE__ */ h("button", { onClick: $, className: R.button, children: /* @__PURE__ */ O("span", { className: "inline-flex items-center gap-2", children: [
1808
- /* @__PURE__ */ h(ke, {}),
1859
+ /* @__PURE__ */ U("div", { className: "flex items-center gap-3", children: [
1860
+ /* @__PURE__ */ g("button", { onClick: B, className: T.button, children: /* @__PURE__ */ U("span", { className: "inline-flex items-center gap-2", children: [
1861
+ /* @__PURE__ */ g(Be, {}),
1809
1862
  " Download All"
1810
1863
  ] }) }),
1811
- /* @__PURE__ */ h("button", { onClick: Q, className: R.buttonDanger, children: /* @__PURE__ */ O("span", { className: "inline-flex items-center gap-2", children: [
1812
- /* @__PURE__ */ h($e, {}),
1864
+ /* @__PURE__ */ g("button", { onClick: V, className: T.buttonDanger, children: /* @__PURE__ */ U("span", { className: "inline-flex items-center gap-2", children: [
1865
+ /* @__PURE__ */ g(Oe, {}),
1813
1866
  " Delete All"
1814
1867
  ] }) }),
1815
- /* @__PURE__ */ h(
1868
+ /* @__PURE__ */ g(
1816
1869
  "button",
1817
1870
  {
1818
1871
  onClick: () => y(/* @__PURE__ */ new Set()),
@@ -1824,78 +1877,78 @@ ${V.join(`
1824
1877
  ]
1825
1878
  }
1826
1879
  ),
1827
- /* @__PURE__ */ h("div", { className: "mt-8", children: u ? /* @__PURE__ */ O("div", { className: "flex justify-center items-center py-12 gap-3", children: [
1828
- /* @__PURE__ */ h("span", { style: { animation: "opfs-spin 1s linear infinite" }, children: /* @__PURE__ */ h(Ut, {}) }),
1829
- /* @__PURE__ */ h("span", { className: i.loadingText, children: "Loading files..." })
1830
- ] }) : f ? /* @__PURE__ */ O("div", { className: `${R.errorBox} ${i.errorBox}`, children: [
1831
- /* @__PURE__ */ h("h3", { className: `m-0 text-sm font-medium ${i.errorTitle}`, children: "Error" }),
1832
- /* @__PURE__ */ h("div", { className: `mt-2 text-sm ${i.errorText}`, children: f })
1833
- ] }) : v.length === 0 ? /* @__PURE__ */ O("div", { className: R.emptyState, children: [
1834
- /* @__PURE__ */ h("span", { className: i.emptyIcon, children: /* @__PURE__ */ h(Bt, {}) }),
1835
- /* @__PURE__ */ h("h3", { className: `mt-2 text-sm font-semibold ${i.emptyTitle}`, children: "No files" }),
1836
- /* @__PURE__ */ h("p", { className: `mt-1 text-sm ${i.emptyText}`, children: "No files found in OPFS." })
1837
- ] }) : /* @__PURE__ */ h("div", { className: "overflow-x-auto", children: /* @__PURE__ */ O("table", { className: R.table, children: [
1838
- /* @__PURE__ */ h("thead", { children: /* @__PURE__ */ O("tr", { className: i.tableBorder, children: [
1839
- /* @__PURE__ */ h("th", { className: `${R.tableHeader} w-10 ${i.tableHeader}`, children: /* @__PURE__ */ h(
1880
+ /* @__PURE__ */ g("div", { className: "mt-8", children: u ? /* @__PURE__ */ U("div", { className: "flex justify-center items-center py-12 gap-3", children: [
1881
+ /* @__PURE__ */ g("span", { style: { animation: "opfs-spin 1s linear infinite" }, children: /* @__PURE__ */ g(Qt, {}) }),
1882
+ /* @__PURE__ */ g("span", { className: i.loadingText, children: "Loading files..." })
1883
+ ] }) : f ? /* @__PURE__ */ U("div", { className: `${T.errorBox} ${i.errorBox}`, children: [
1884
+ /* @__PURE__ */ g("h3", { className: `m-0 text-sm font-medium ${i.errorTitle}`, children: "Error" }),
1885
+ /* @__PURE__ */ g("div", { className: `mt-2 text-sm ${i.errorText}`, children: f })
1886
+ ] }) : v.length === 0 ? /* @__PURE__ */ U("div", { className: T.emptyState, children: [
1887
+ /* @__PURE__ */ g("span", { className: i.emptyIcon, children: /* @__PURE__ */ g(zt, {}) }),
1888
+ /* @__PURE__ */ g("h3", { className: `mt-2 text-sm font-semibold ${i.emptyTitle}`, children: "No files" }),
1889
+ /* @__PURE__ */ g("p", { className: `mt-1 text-sm ${i.emptyText}`, children: "No files found in OPFS." })
1890
+ ] }) : /* @__PURE__ */ g("div", { className: "overflow-x-auto", children: /* @__PURE__ */ U("table", { className: T.table, children: [
1891
+ /* @__PURE__ */ g("thead", { children: /* @__PURE__ */ U("tr", { className: i.tableBorder, children: [
1892
+ /* @__PURE__ */ g("th", { className: `${T.tableHeader} w-10 ${i.tableHeader}`, children: /* @__PURE__ */ g(
1840
1893
  "input",
1841
1894
  {
1842
1895
  ref: p,
1843
1896
  type: "checkbox",
1844
1897
  checked: E,
1845
- onChange: P,
1898
+ onChange: _,
1846
1899
  "aria-label": "Select all"
1847
1900
  }
1848
1901
  ) }),
1849
- /* @__PURE__ */ h("th", { className: `${R.tableHeader} ${i.tableHeader}`, children: "Name" }),
1850
- /* @__PURE__ */ h("th", { className: `${R.tableHeader} ${i.tableHeader}`, children: "Path" }),
1851
- /* @__PURE__ */ h("th", { className: `${R.tableHeader} ${i.tableHeader}`, children: "Size" }),
1852
- /* @__PURE__ */ h("th", { className: `${R.tableHeader} ${i.tableHeader}`, children: "Type" }),
1853
- /* @__PURE__ */ h("th", { className: `${R.tableHeader} ${i.tableHeader}`, children: "Modified" }),
1854
- /* @__PURE__ */ h(
1902
+ /* @__PURE__ */ g("th", { className: `${T.tableHeader} ${i.tableHeader}`, children: "Name" }),
1903
+ /* @__PURE__ */ g("th", { className: `${T.tableHeader} ${i.tableHeader}`, children: "Path" }),
1904
+ /* @__PURE__ */ g("th", { className: `${T.tableHeader} ${i.tableHeader}`, children: "Size" }),
1905
+ /* @__PURE__ */ g("th", { className: `${T.tableHeader} ${i.tableHeader}`, children: "Type" }),
1906
+ /* @__PURE__ */ g("th", { className: `${T.tableHeader} ${i.tableHeader}`, children: "Modified" }),
1907
+ /* @__PURE__ */ g(
1855
1908
  "th",
1856
1909
  {
1857
- className: `${R.tableHeader} w-24 ${i.tableHeader}`,
1910
+ className: `${T.tableHeader} w-24 ${i.tableHeader}`,
1858
1911
  "aria-label": "Actions"
1859
1912
  }
1860
1913
  )
1861
1914
  ] }) }),
1862
- /* @__PURE__ */ h("tbody", { className: `divide-y ${i.tableBorder}`, children: v.map((L) => /* @__PURE__ */ O("tr", { className: i.tableRow, children: [
1863
- /* @__PURE__ */ h("td", { className: `${R.tableCell} ${i.tableCell}`, children: /* @__PURE__ */ h(
1915
+ /* @__PURE__ */ g("tbody", { className: `divide-y ${i.tableBorder}`, children: v.map((L) => /* @__PURE__ */ U("tr", { className: i.tableRow, children: [
1916
+ /* @__PURE__ */ g("td", { className: `${T.tableCell} ${i.tableCell}`, children: /* @__PURE__ */ g(
1864
1917
  "input",
1865
1918
  {
1866
1919
  type: "checkbox",
1867
- checked: b.has(L.path),
1920
+ checked: h.has(L.path),
1868
1921
  onChange: () => m(L.path),
1869
1922
  "aria-label": `Select ${L.name}`
1870
1923
  }
1871
1924
  ) }),
1872
- /* @__PURE__ */ h("td", { className: `${R.tableCell} ${i.tableCell}`, children: /* @__PURE__ */ O("span", { className: "flex items-center gap-2", children: [
1873
- /* @__PURE__ */ h(Ot, {}),
1925
+ /* @__PURE__ */ g("td", { className: `${T.tableCell} ${i.tableCell}`, children: /* @__PURE__ */ U("span", { className: "flex items-center gap-2", children: [
1926
+ /* @__PURE__ */ g(Ht, {}),
1874
1927
  L.name
1875
1928
  ] }) }),
1876
- /* @__PURE__ */ h("td", { className: `${R.tableCell} ${i.tableCellMuted}`, children: /* @__PURE__ */ h("code", { className: `text-xs px-2 py-1 rounded border ${i.codeBlock}`, children: L.path }) }),
1877
- /* @__PURE__ */ h("td", { className: `${R.tableCell} ${i.tableCellMuted}`, children: zt(L.size) }),
1878
- /* @__PURE__ */ h("td", { className: `${R.tableCell} ${i.tableCellMuted}`, children: L.type }),
1879
- /* @__PURE__ */ h("td", { className: `${R.tableCell} ${i.tableCellMuted}`, children: qt(L.lastModified) }),
1880
- /* @__PURE__ */ h("td", { className: R.tableCell, children: /* @__PURE__ */ O("div", { className: "flex gap-2 justify-end", children: [
1881
- /* @__PURE__ */ h(
1929
+ /* @__PURE__ */ g("td", { className: `${T.tableCell} ${i.tableCellMuted}`, children: /* @__PURE__ */ g("code", { className: `text-xs px-2 py-1 rounded border ${i.codeBlock}`, children: L.path }) }),
1930
+ /* @__PURE__ */ g("td", { className: `${T.tableCell} ${i.tableCellMuted}`, children: Vt(L.size) }),
1931
+ /* @__PURE__ */ g("td", { className: `${T.tableCell} ${i.tableCellMuted}`, children: L.type }),
1932
+ /* @__PURE__ */ g("td", { className: `${T.tableCell} ${i.tableCellMuted}`, children: Kt(L.lastModified) }),
1933
+ /* @__PURE__ */ g("td", { className: T.tableCell, children: /* @__PURE__ */ U("div", { className: "flex gap-2 justify-end", children: [
1934
+ /* @__PURE__ */ g(
1882
1935
  "button",
1883
1936
  {
1884
1937
  type: "button",
1885
- onClick: () => H(L),
1938
+ onClick: () => R(L),
1886
1939
  title: "Download",
1887
1940
  className: `p-1.5 rounded cursor-pointer bg-transparent border-0 transition-colors ${i.actionButton}`,
1888
- children: /* @__PURE__ */ h(ke, {})
1941
+ children: /* @__PURE__ */ g(Be, {})
1889
1942
  }
1890
1943
  ),
1891
- /* @__PURE__ */ h(
1944
+ /* @__PURE__ */ g(
1892
1945
  "button",
1893
1946
  {
1894
1947
  type: "button",
1895
- onClick: () => N(L),
1948
+ onClick: () => A(L),
1896
1949
  title: "Delete",
1897
1950
  className: `p-1.5 rounded cursor-pointer bg-transparent border-0 transition-colors ${i.deleteButton}`,
1898
- children: /* @__PURE__ */ h($e, {})
1951
+ children: /* @__PURE__ */ g(Oe, {})
1899
1952
  }
1900
1953
  )
1901
1954
  ] }) })
@@ -1903,118 +1956,118 @@ ${V.join(`
1903
1956
  ] }) }) })
1904
1957
  ] });
1905
1958
  }
1906
- const we = G("seedSdk:react:SeedImage"), ce = /* @__PURE__ */ new Map(), Ge = (e) => {
1959
+ const Ee = G("seedSdk:react:SeedImage"), de = /* @__PURE__ */ new Map(), et = (e) => {
1907
1960
  const t = /^(.*[\/\\])?([^\/\\]+?)(\.[^.\/\\]*)?$/, r = e.match(t);
1908
1961
  return r && r[2] ? r[2] : e;
1909
1962
  };
1910
- function Vt(e) {
1963
+ function Jt(e) {
1911
1964
  return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1912
1965
  }
1913
- function Kt(e, t) {
1914
- const r = new RegExp(`^${Vt(t)}$`), n = Ge(e);
1966
+ function Gt(e, t) {
1967
+ const r = new RegExp(`^${Jt(t)}$`), n = et(e);
1915
1968
  return r.test(n);
1916
1969
  }
1917
- const jt = ({ imageProperty: e, width: t, filename: r, ...n }) => {
1918
- const [o, a] = S(), [s, l] = S(), { property: c } = Ve({
1970
+ const Yt = ({ imageProperty: e, width: t, filename: r, ...n }) => {
1971
+ const [o, a] = S(), [s, c] = S(), { property: l } = We({
1919
1972
  propertyName: e.propertyName,
1920
1973
  seedLocalId: e.seedLocalId,
1921
1974
  seedUid: e.seedUid
1922
- }), i = e ?? c, d = r ?? i?.refResolvedValue ?? i?.value, u = i?.value, f = typeof u == "string" ? u : d, g = u != null && (u instanceof File || u instanceof Blob), [v, b] = S(null), y = Oe.useRef(null);
1923
- I(() => {
1924
- if (g && (u instanceof File || u instanceof Blob))
1925
- return y.current || (y.current = URL.createObjectURL(u), b(y.current)), () => {
1926
- y.current && (URL.revokeObjectURL(y.current), y.current = null), b(null);
1975
+ }), i = e ?? l, d = r ?? i?.refResolvedValue ?? i?.value, u = i?.value, f = typeof u == "string" ? u : d, b = u != null && (u instanceof File || u instanceof Blob), [v, h] = S(null), y = qe.useRef(null);
1976
+ w(() => {
1977
+ if (b && (u instanceof File || u instanceof Blob))
1978
+ return y.current || (y.current = URL.createObjectURL(u), h(y.current)), () => {
1979
+ y.current && (URL.revokeObjectURL(y.current), y.current = null), h(null);
1927
1980
  };
1928
- y.current = null, b(null);
1929
- }, [g, u]), I(() => {
1930
- if (!d || u && ((N) => typeof N == "string" && N.startsWith("blob:"))(u) || v) return;
1931
- let P = !1;
1981
+ y.current = null, h(null);
1982
+ }, [b, u]), w(() => {
1983
+ if (!d || u && ((A) => typeof A == "string" && A.startsWith("blob:"))(u) || v) return;
1984
+ let _ = !1;
1932
1985
  return (async () => {
1933
1986
  try {
1934
- const N = i?.localStoragePath ? i.localStoragePath : `${j.getFilesPath("images")}/${d}`;
1935
- if (await j.pathExists(N)) {
1936
- const Q = await j.getContentUrlFromPath(N);
1937
- !P && Q && l(Q);
1987
+ const A = i?.localStoragePath ? i.localStoragePath : `${W.getFilesPath("images")}/${d}`;
1988
+ if (await W.pathExists(A)) {
1989
+ const V = await W.getContentUrlFromPath(A);
1990
+ !_ && V && c(V);
1938
1991
  }
1939
- } catch (N) {
1940
- we("_getOriginalContentUrl error", N);
1992
+ } catch (A) {
1993
+ Ee("_getOriginalContentUrl error", A);
1941
1994
  }
1942
1995
  })(), () => {
1943
- P = !0;
1996
+ _ = !0;
1944
1997
  };
1945
- }, [d, u, v, i?.localStoragePath]), I(() => {
1998
+ }, [d, u, v, i?.localStoragePath]), w(() => {
1946
1999
  if (!t || !d)
1947
2000
  return;
1948
2001
  (async () => {
1949
2002
  try {
1950
- const P = await j.getFs(), H = i?.localStoragePath ? i.localStoragePath.split("/").slice(0, -1).join("/") : j.getFilesPath("images"), Q = P.readdirSync(H, { withFileTypes: !0 }).filter((B) => B.isDirectory()).map((B) => parseInt(B.name)), L = Q.reduce((B, re) => Math.abs(re - t) < Math.abs(B - t) ? re : B, Q[0]), k = Ge(d), _ = `${k}-${L}`;
1951
- if (ce.has(_))
2003
+ const _ = await W.getFs(), R = i?.localStoragePath ? i.localStoragePath.split("/").slice(0, -1).join("/") : W.getFilesPath("images"), V = _.readdirSync(R, { withFileTypes: !0 }).filter((O) => O.isDirectory()).map((O) => parseInt(O.name)), L = V.reduce((O, se) => Math.abs(se - t) < Math.abs(O - t) ? se : O, V[0]), $ = et(d), F = `${$}-${L}`;
2004
+ if (de.has(F))
1952
2005
  try {
1953
- const B = ce.get(_);
1954
- if (B && (await fetch(B)).ok) {
1955
- a(B);
2006
+ const O = de.get(F);
2007
+ if (O && (await fetch(O)).ok) {
2008
+ a(O);
1956
2009
  return;
1957
2010
  }
1958
- } catch (B) {
1959
- we("error", B), ce.delete(_);
2011
+ } catch (O) {
2012
+ Ee("error", O), de.delete(F);
1960
2013
  }
1961
- const V = P.readdirSync(`${H}/${L}`, { withFileTypes: !0 }).find((B) => B.name ? Kt(B.name, k) : !1);
1962
- if (!V)
2014
+ const K = _.readdirSync(`${R}/${L}`, { withFileTypes: !0 }).find((O) => O.name ? Gt(O.name, $) : !1);
2015
+ if (!K)
1963
2016
  return;
1964
- const M = `${H}/${L}/${V?.name}`;
1965
- if (await j.pathExists(M)) {
1966
- const B = await j.getContentUrlFromPath(M);
1967
- B && (ce.set(_, B), a(B));
2017
+ const M = `${R}/${L}/${K?.name}`;
2018
+ if (await W.pathExists(M)) {
2019
+ const O = await W.getContentUrlFromPath(M);
2020
+ O && (de.set(F, O), a(O));
1968
2021
  }
1969
- } catch (P) {
1970
- we("_getSizedContentUrl error", P);
2022
+ } catch (_) {
2023
+ Ee("_getSizedContentUrl error", _);
1971
2024
  }
1972
2025
  })();
1973
2026
  }, [i, t, f, d]);
1974
2027
  const p = (m) => typeof m == "string" && m.startsWith("blob:");
1975
2028
  if (!(!!o || !!s || !!v || !!f && p(f)) && !d)
1976
2029
  return null;
1977
- const w = o || s || v || (p(f) ? f : void 0) || "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
1978
- return /* @__PURE__ */ h("img", { src: w, alt: n.alt || e.propertyName || "Image", ...n });
1979
- }, Or = Oe.memo(
1980
- jt,
2030
+ const I = o || s || v || (p(f) ? f : void 0) || "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
2031
+ return /* @__PURE__ */ g("img", { src: I, alt: n.alt || e.propertyName || "Image", ...n });
2032
+ }, Kr = qe.memo(
2033
+ Yt,
1981
2034
  (e, t) => e.imageProperty === t.imageProperty && e.width === t.width && e.filename === t.filename
1982
2035
  );
1983
- function Ye(e) {
1984
- const { value: t, enabled: r = !0, treatAs: n } = e, [o, a] = S(0), [s, l] = S(null), [c, i] = S(null), [d, u] = S("idle");
1985
- I(() => {
1986
- let b = !1;
2036
+ function tt(e) {
2037
+ const { value: t, enabled: r = !0, treatAs: n } = e, [o, a] = S(0), [s, c] = S(null), [l, i] = S(null), [d, u] = S("idle");
2038
+ w(() => {
2039
+ let h = !1;
1987
2040
  return (async () => {
1988
2041
  if (!r || t == null || String(t).trim() === "") {
1989
- b || (l(null), i(null), u("idle"));
2042
+ h || (c(null), i(null), u("idle"));
1990
2043
  return;
1991
2044
  }
1992
- b || (u("loading"), i(null));
2045
+ h || (u("loading"), i(null));
1993
2046
  try {
1994
- const p = await lt(String(t), { treatAs: n });
1995
- if (b) return;
1996
- l(p), p.status === "empty" ? u("empty") : p.status === "ready" ? u("ready") : u("unresolved");
2047
+ const p = await ft(String(t), { treatAs: n });
2048
+ if (h) return;
2049
+ c(p), p.status === "empty" ? u("empty") : p.status === "ready" ? u("ready") : u("unresolved");
1997
2050
  } catch (p) {
1998
- if (b) return;
1999
- i(p instanceof Error ? p : new Error(String(p))), l(null), u("error");
2051
+ if (h) return;
2052
+ i(p instanceof Error ? p : new Error(String(p))), c(null), u("error");
2000
2053
  }
2001
2054
  })(), () => {
2002
- b = !0;
2055
+ h = !0;
2003
2056
  };
2004
2057
  }, [r, t, n, o]);
2005
2058
  const f = x(() => {
2006
- a((b) => b + 1);
2007
- }, []), g = s && s.status === "ready" ? s.href : void 0, v = s && s.status === "ready" ? s.source : void 0;
2059
+ a((h) => h + 1);
2060
+ }, []), b = s && s.status === "ready" ? s.href : void 0, v = s && s.status === "ready" ? s.source : void 0;
2008
2061
  return {
2009
- href: g,
2062
+ href: b,
2010
2063
  status: d,
2011
2064
  source: v,
2012
- error: c,
2065
+ error: l,
2013
2066
  result: s,
2014
2067
  refetch: f
2015
2068
  };
2016
2069
  }
2017
- function Ur({
2070
+ function jr({
2018
2071
  value: e,
2019
2072
  enabled: t,
2020
2073
  treatAs: r,
@@ -2022,20 +2075,20 @@ function Ur({
2022
2075
  alt: o,
2023
2076
  ...a
2024
2077
  }) {
2025
- const { href: s } = Ye({ value: e, enabled: t, treatAs: r });
2078
+ const { href: s } = tt({ value: e, enabled: t, treatAs: r });
2026
2079
  if (!s)
2027
2080
  return null;
2028
- const l = { ...a, src: s, alt: o ?? "" };
2029
- return n ? /* @__PURE__ */ h(ge, { children: n(l) }) : /* @__PURE__ */ h("img", { ...l });
2081
+ const c = { ...a, src: s, alt: o ?? "" };
2082
+ return n ? /* @__PURE__ */ g(Se, { children: n(c) }) : /* @__PURE__ */ g("img", { ...c });
2030
2083
  }
2031
- function Wt(e) {
2084
+ function Xt(e) {
2032
2085
  try {
2033
2086
  return new URL(e).pathname.split("/").filter(Boolean).pop() || "Open";
2034
2087
  } catch {
2035
2088
  return "Open";
2036
2089
  }
2037
2090
  }
2038
- function Jt(e) {
2091
+ function Zt(e) {
2039
2092
  try {
2040
2093
  const t = new URL(e).protocol;
2041
2094
  return t === "http:" || t === "https:";
@@ -2043,7 +2096,7 @@ function Jt(e) {
2043
2096
  return !1;
2044
2097
  }
2045
2098
  }
2046
- function zr({
2099
+ function Wr({
2047
2100
  value: e,
2048
2101
  enabled: t,
2049
2102
  treatAs: r,
@@ -2051,40 +2104,40 @@ function zr({
2051
2104
  render: o,
2052
2105
  children: a,
2053
2106
  target: s,
2054
- rel: l,
2055
- ...c
2107
+ rel: c,
2108
+ ...l
2056
2109
  }) {
2057
- const { href: i } = Ye({ value: e, enabled: t, treatAs: r });
2110
+ const { href: i } = tt({ value: e, enabled: t, treatAs: r });
2058
2111
  if (!i)
2059
2112
  return null;
2060
- const d = Jt(i), u = s !== void 0 ? s : d ? "_blank" : void 0, f = {
2061
- ...c,
2113
+ const d = Zt(i), u = s !== void 0 ? s : d ? "_blank" : void 0, f = {
2114
+ ...l,
2062
2115
  href: i,
2063
2116
  download: n,
2064
2117
  target: u,
2065
- rel: l ?? (d && u === "_blank" ? "noopener noreferrer" : void 0),
2066
- children: a ?? Wt(i)
2118
+ rel: c ?? (d && u === "_blank" ? "noopener noreferrer" : void 0),
2119
+ children: a ?? Xt(i)
2067
2120
  };
2068
- return o ? /* @__PURE__ */ h(ge, { children: o(f) }) : /* @__PURE__ */ h("a", { ...f });
2121
+ return o ? /* @__PURE__ */ g(Se, { children: o(f) }) : /* @__PURE__ */ g("a", { ...f });
2069
2122
  }
2070
- function Gt(e) {
2123
+ function er(e) {
2071
2124
  return typeof e == "string" && e.trim().length > 0;
2072
2125
  }
2073
- function qr({
2126
+ function Jr({
2074
2127
  html: e,
2075
2128
  sanitize: t,
2076
2129
  render: r,
2077
2130
  ...n
2078
2131
  }) {
2079
- if (!Gt(e))
2132
+ if (!er(e))
2080
2133
  return null;
2081
2134
  const o = t(e);
2082
- return r ? /* @__PURE__ */ h(ge, { children: r({ html: o }) }) : /* @__PURE__ */ h("div", { ...n, dangerouslySetInnerHTML: { __html: o } });
2135
+ return r ? /* @__PURE__ */ g(Se, { children: r({ html: o }) }) : /* @__PURE__ */ g("div", { ...n, dangerouslySetInnerHTML: { __html: o } });
2083
2136
  }
2084
- function Ae(e, t) {
2137
+ function De(e, t) {
2085
2138
  return e.length <= t ? e : `${e.slice(0, t)}…`;
2086
2139
  }
2087
- function Yt(e) {
2140
+ function tr(e) {
2088
2141
  const t = e.trim();
2089
2142
  return t.startsWith("{") && t.endsWith("}") || t.startsWith("[") && t.endsWith("]");
2090
2143
  }
@@ -2098,7 +2151,7 @@ function Fe(e, t, r, n, o) {
2098
2151
  if (e instanceof Date)
2099
2152
  return e.toISOString();
2100
2153
  if (typeof e == "string")
2101
- return Ae(e, r);
2154
+ return De(e, r);
2102
2155
  if (e === null || typeof e != "object")
2103
2156
  return e;
2104
2157
  if (o.has(e))
@@ -2108,11 +2161,11 @@ function Fe(e, t, r, n, o) {
2108
2161
  if (o.add(e), Array.isArray(e))
2109
2162
  return e.map((s) => Fe(s, t, r, n + 1, o));
2110
2163
  const a = {};
2111
- for (const [s, l] of Object.entries(e))
2112
- a[s] = Fe(l, t, r, n + 1, o);
2164
+ for (const [s, c] of Object.entries(e))
2165
+ a[s] = Fe(c, t, r, n + 1, o);
2113
2166
  return a;
2114
2167
  }
2115
- function Xt(e, t) {
2168
+ function rr(e, t) {
2116
2169
  const r = t?.maxDepth ?? 6, n = t?.maxStringLength ?? 5e4, o = t?.space ?? 2;
2117
2170
  if (e === void 0)
2118
2171
  return "undefined";
@@ -2120,14 +2173,14 @@ function Xt(e, t) {
2120
2173
  return "null";
2121
2174
  let a = e;
2122
2175
  if (typeof e == "string")
2123
- if (Yt(e))
2176
+ if (tr(e))
2124
2177
  try {
2125
2178
  a = JSON.parse(e);
2126
2179
  } catch {
2127
- return Ae(e, n);
2180
+ return De(e, n);
2128
2181
  }
2129
2182
  else
2130
- return Ae(e, n);
2183
+ return De(e, n);
2131
2184
  const s = Fe(a, r, n, 0, /* @__PURE__ */ new WeakSet());
2132
2185
  try {
2133
2186
  return JSON.stringify(s, null, o);
@@ -2135,75 +2188,79 @@ function Xt(e, t) {
2135
2188
  return "[Unserializable JSON]";
2136
2189
  }
2137
2190
  }
2138
- function Hr({
2191
+ function Gr({
2139
2192
  value: e,
2140
2193
  format: t,
2141
2194
  formatOptions: r,
2142
2195
  render: n,
2143
2196
  ...o
2144
2197
  }) {
2145
- const a = t ? t(e) : Xt(e, r);
2146
- return n ? /* @__PURE__ */ h(ge, { children: n({ text: a }) }) : /* @__PURE__ */ h("pre", { ...o, children: a });
2198
+ const a = t ? t(e) : rr(e, r);
2199
+ return n ? /* @__PURE__ */ g(Se, { children: n({ text: a }) }) : /* @__PURE__ */ g("pre", { ...o, children: a });
2147
2200
  }
2148
- function Qr(e, t) {
2149
- return F(() => e ? ct(e, t) : {}, [e, t]);
2201
+ function Yr(e, t) {
2202
+ return N(() => e ? yt(e, t) : {}, [e, t]);
2150
2203
  }
2151
2204
  export {
2152
- Pe as ADDRESSES_PERSISTED_EVENT,
2153
- Ct as FILES_QUERY_KEY_PREFIX,
2154
- Br as OPFSFilesManager,
2155
- $r as SeedClientGate,
2156
- qr as SeedHtml,
2157
- Or as SeedImage,
2158
- Hr as SeedJson,
2159
- zr as SeedMediaFile,
2160
- Ur as SeedMediaImage,
2161
- kr as SeedProvider,
2162
- Mt as createSeedQueryClient,
2163
- Xt as formatSeedJson,
2164
- We as getSeedQueryDefaultOptions,
2165
- Ke as getServiceName,
2166
- De as getServiceUniqueKey,
2167
- Me as getServiceValue,
2168
- Tr as invalidateItemPropertiesForItem,
2169
- Pt as mergeSeedQueryDefaults,
2170
- Lr as useAllSchemaVersions,
2171
- fr as useCreateItem,
2172
- hr as useCreateItemProperty,
2173
- Nr as useCreateModel,
2174
- Dr as useCreateModelProperty,
2175
- Ir as useCreateSchema,
2176
- Sr as useDbsAreReady,
2177
- yr as useDebouncedItemProperty,
2178
- Rr as useDeleteItem,
2179
- gr as useDestroyItemProperty,
2180
- Ar as useDestroyModel,
2181
- Cr as useDestroyModelProperty,
2182
- Er as useDestroySchema,
2183
- Mr as useFiles,
2184
- xt as useGlobalServiceStatus,
2185
- Et as useHasSavedSnapshots,
2186
- Pr as useImageFiles,
2187
- It as useIsDbReady,
2188
- dr as useItem,
2189
- mr as useItemProperties,
2190
- Ve as useItemProperty,
2191
- ur as useItems,
2192
- ie as useLiveQuery,
2193
- _t as useModel,
2194
- Fr as useModelProperties,
2195
- _r as useModelProperty,
2196
- Ft as useModels,
2197
- Qr as useNormalizedFeedItemFields,
2198
- $t as useOPFSFiles,
2199
- vr as usePersistedSnapshots,
2200
- pr as usePublishItem,
2201
- Ye as useResolvedMediaRef,
2202
- Nt as useSchema,
2203
- wr as useSchemas,
2204
- Qe as useSeedAddressRevision,
2205
- xr as useSeedProtocolSchema,
2206
- br as useService,
2207
- Lt as useServices
2205
+ Me as ADDRESSES_PERSISTED_EVENT,
2206
+ Tt as FILES_QUERY_KEY_PREFIX,
2207
+ Vr as OPFSFilesManager,
2208
+ Qr as SeedClientGate,
2209
+ Jr as SeedHtml,
2210
+ Kr as SeedImage,
2211
+ Gr as SeedJson,
2212
+ Wr as SeedMediaFile,
2213
+ jr as SeedMediaImage,
2214
+ Hr as SeedProvider,
2215
+ Bt as createSeedQueryClient,
2216
+ rr as formatSeedJson,
2217
+ Xe as getSeedQueryDefaultOptions,
2218
+ Je as getServiceName,
2219
+ Re as getServiceUniqueKey,
2220
+ ke as getServiceValue,
2221
+ zr as invalidateItemPropertiesForItem,
2222
+ $t as mergeSeedQueryDefaults,
2223
+ _r as useAllSchemaVersions,
2224
+ hr as useCreateItem,
2225
+ vr as useCreateItemProperty,
2226
+ Fr as useCreateModel,
2227
+ Tr as useCreateModelProperty,
2228
+ xr as useCreateSchema,
2229
+ Lr as useDbsAreReady,
2230
+ br as useDebouncedItemProperty,
2231
+ kr as useDeleteItem,
2232
+ wr as useDestroyItemProperty,
2233
+ Cr as useDestroyModel,
2234
+ Mr as useDestroyModelProperty,
2235
+ Nr as useDestroySchema,
2236
+ qr as useEasSyncProcessById,
2237
+ Or as useEasSyncProcesses,
2238
+ Ur as useEasSyncProcessesNonActiveCount,
2239
+ Mt as useEasSyncProcessesState,
2240
+ Br as useFiles,
2241
+ _t as useGlobalServiceStatus,
2242
+ xt as useHasSavedSnapshots,
2243
+ $r as useImageFiles,
2244
+ At as useIsDbReady,
2245
+ pr as useItem,
2246
+ Sr as useItemProperties,
2247
+ We as useItemProperty,
2248
+ mr as useItems,
2249
+ Y as useLiveQuery,
2250
+ Rt as useModel,
2251
+ Rr as useModelProperties,
2252
+ Pr as useModelProperty,
2253
+ Ct as useModels,
2254
+ Yr as useNormalizedFeedItemFields,
2255
+ qt as useOPFSFiles,
2256
+ Er as usePersistedSnapshots,
2257
+ gr as usePublishItem,
2258
+ tt as useResolvedMediaRef,
2259
+ Dt as useSchema,
2260
+ Ar as useSchemas,
2261
+ je as useSeedAddressRevision,
2262
+ Dr as useSeedProtocolSchema,
2263
+ Ir as useService,
2264
+ Nt as useServices
2208
2265
  };
2209
2266
  //# sourceMappingURL=index.js.map