@declarion/react 0.2.1 → 0.2.2

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.
@@ -219,8 +219,35 @@ var O = (e) => JSON.stringify(e ?? {}), k = null, A = class extends Error {
219
219
  constructor(e) {
220
220
  super(`refresh failed terminally (${e})`), this.status = e, this.name = "RefreshDeadError";
221
221
  }
222
- };
223
- async function pe() {
222
+ }, j = null, M = null, pe = 3e4, me = 5e3;
223
+ function he() {
224
+ F().catch((e) => {
225
+ e instanceof A && I();
226
+ });
227
+ }
228
+ function N(e) {
229
+ if (j &&= (clearTimeout(j), null), M = null, !e || typeof window > "u") return;
230
+ let t = Date.parse(e);
231
+ if (Number.isNaN(t)) return;
232
+ M = t;
233
+ let n = Math.max(t - Date.now() - pe, me);
234
+ j = setTimeout(() => {
235
+ j = null, he();
236
+ }, n);
237
+ }
238
+ function ge() {
239
+ j &&= (clearTimeout(j), null), M = null;
240
+ }
241
+ typeof document < "u" && document.addEventListener("visibilitychange", () => {
242
+ document.visibilityState === "visible" && M !== null && Date.now() >= M - pe && he();
243
+ });
244
+ async function P(e) {
245
+ try {
246
+ let t = await e.json();
247
+ N(t?.result?.expires_at ?? t?.expires_at);
248
+ } catch {}
249
+ }
250
+ async function _e() {
224
251
  let e = {
225
252
  method: "POST",
226
253
  credentials: "include",
@@ -232,36 +259,38 @@ async function pe() {
232
259
  await new Promise((e) => setTimeout(e, n * 1e3));
233
260
  let r = await fetch("/api/actions/auth.refresh", e);
234
261
  if (!r.ok) throw new A(r.status);
262
+ await P(r);
235
263
  return;
236
264
  }
237
265
  if (!t.ok) throw new A(t.status);
266
+ await P(t);
238
267
  }
239
- async function j() {
240
- return k || (k = pe().finally(() => {
268
+ async function F() {
269
+ return k || (k = _e().finally(() => {
241
270
  k = null;
242
271
  }), k);
243
272
  }
244
- var M = () => {
273
+ var I = () => {
245
274
  if (typeof window > "u") return;
246
275
  let { pathname: e } = window.location;
247
276
  e.startsWith("/login") || e.startsWith("/signup") || e === "/reset" || e === "/forgot" || (window.location.href = te());
248
277
  };
249
- function me(e) {
250
- let t = M;
251
- return M = e, t;
278
+ function ve(e) {
279
+ let t = I;
280
+ return I = e, t;
252
281
  }
253
- function N() {
254
- return M;
282
+ function L() {
283
+ return I;
255
284
  }
256
- var he = ({ status: e, code: t, message: n }) => {
285
+ var ye = ({ status: e, code: t, message: n }) => {
257
286
  console.error(`[API ${e}] ${t}: ${n}`);
258
287
  };
259
- function P(e, t, n, r) {
288
+ function R(e, t, n, r) {
260
289
  let i = new Headers(e);
261
290
  return !i.has("Content-Type") && t && i.set("Content-Type", "application/json"), n.setAccept && !i.has("Accept") && i.set("Accept", "*/*"), r && i.set("Authorization", `Bearer ${r}`), i;
262
291
  }
263
- async function F(e, t, n, r) {
264
- let i = b(), a = i ? "omit" : "include", o = P(t.headers, !!t.body, n, i ? x() : null), s = await fetch(e, {
292
+ async function z(e, t, n, r) {
293
+ let i = b(), a = i ? "omit" : "include", o = R(t.headers, !!t.body, n, i ? x() : null), s = await fetch(e, {
265
294
  ...t,
266
295
  headers: o,
267
296
  credentials: a
@@ -275,14 +304,14 @@ async function F(e, t, n, r) {
275
304
  } catch {}
276
305
  if (s.status === 401 && (l === "TOKEN_REFRESH_NEEDED" || l === "UNAUTHORIZED")) try {
277
306
  let o = null;
278
- i ? (S(), o = await C()) : await j();
279
- let s = P(t.headers, !!t.body, n, o), l = await fetch(e, {
307
+ i ? (S(), o = await C()) : await F();
308
+ let s = R(t.headers, !!t.body, n, o), l = await fetch(e, {
280
309
  ...t,
281
310
  headers: s,
282
311
  credentials: a
283
312
  });
284
313
  if (!l.ok) {
285
- M();
314
+ I();
286
315
  let e = await l.json().catch(() => ({ error: {
287
316
  message: "Request failed",
288
317
  code: "UNKNOWN"
@@ -291,9 +320,9 @@ async function F(e, t, n, r) {
291
320
  }
292
321
  return r(l);
293
322
  } catch (e) {
294
- throw e instanceof c ? e : (M(), new c(401, o, l, u));
323
+ throw e instanceof c ? e : (I(), new c(401, o, l, u));
295
324
  }
296
- throw s.status === 401 && M(), he({
325
+ throw s.status === 401 && I(), ye({
297
326
  status: s.status,
298
327
  code: l,
299
328
  message: o
@@ -301,23 +330,23 @@ async function F(e, t, n, r) {
301
330
  }
302
331
  return r(s);
303
332
  }
304
- function ge(e) {
333
+ function be(e) {
305
334
  return e.status === 204 ? Promise.resolve(void 0) : e.json();
306
335
  }
307
- async function I(e, t = {}) {
308
- return F(e, t, { setAccept: !1 }, ge);
336
+ async function B(e, t = {}) {
337
+ return z(e, t, { setAccept: !1 }, be);
309
338
  }
310
- async function _e(e) {
339
+ async function xe(e) {
311
340
  return {
312
341
  blob: await e.blob(),
313
- filename: ye(e.headers),
342
+ filename: Ce(e.headers),
314
343
  headers: e.headers
315
344
  };
316
345
  }
317
- async function ve(e, t = {}) {
318
- return F(e, t, { setAccept: !0 }, _e);
346
+ async function Se(e, t = {}) {
347
+ return z(e, t, { setAccept: !0 }, xe);
319
348
  }
320
- function ye(e) {
349
+ function Ce(e) {
321
350
  let t = e.get("Content-Disposition");
322
351
  if (!t) return "";
323
352
  let n = t.match(/filename\*\s*=\s*([^']*)'([^']*)'([^;]+)/i);
@@ -327,32 +356,32 @@ function ye(e) {
327
356
  let r = t.match(/filename\s*=\s*("([^"]+)"|([^;]+))/i);
328
357
  return r ? (r[2] ?? r[3] ?? "").trim() : "";
329
358
  }
330
- async function L(e, t = {}) {
331
- return (await I(`/api/actions/${encodeURIComponent(e)}`, {
359
+ async function V(e, t = {}) {
360
+ return (await B(`/api/actions/${encodeURIComponent(e)}`, {
332
361
  method: "POST",
333
362
  body: O(t)
334
363
  })).result;
335
364
  }
336
365
  //#endregion
337
366
  //#region src/embed/file-src.ts
338
- var R = "/api/files";
339
- function be(e) {
367
+ var H = "/api/files";
368
+ function we(e) {
340
369
  if (typeof e != "object" || !e) return !1;
341
370
  let t = e;
342
371
  return typeof t.url == "string" && typeof t.proxy == "boolean";
343
372
  }
344
- function xe(e, t) {
373
+ function Te(e, t) {
345
374
  let n = encodeURIComponent(e);
346
- return typeof t == "object" ? `${R}/${n}/derived/${encodeURIComponent(t.derivation)}/url` : `${R}/${n}/url`;
375
+ return typeof t == "object" ? `${H}/${n}/derived/${encodeURIComponent(t.derivation)}/url` : `${H}/${n}/url`;
347
376
  }
348
- var z = class extends Error {
377
+ var U = class extends Error {
349
378
  fileId;
350
379
  key;
351
380
  constructor(e, t) {
352
381
  super(`derivation "${t}" of file ${e} is still generating`), this.fileId = e, this.key = t, this.name = "DerivationPendingError";
353
382
  }
354
383
  };
355
- function B(e, t) {
384
+ function W(e, t) {
356
385
  return {
357
386
  method: "GET",
358
387
  credentials: "omit",
@@ -360,28 +389,28 @@ function B(e, t) {
360
389
  signal: t
361
390
  };
362
391
  }
363
- function Se(e) {
392
+ function Ee(e) {
364
393
  return `${e}${e.includes("?") ? "&" : "?"}disposition=attachment`;
365
394
  }
366
- async function V(e, t) {
367
- let n = await C(), r = await fetch(e, B(n, t));
395
+ async function G(e, t) {
396
+ let n = await C(), r = await fetch(e, W(n, t));
368
397
  if (r.status !== 401) return r;
369
398
  S();
370
399
  let i = await C();
371
- return fetch(e, B(i, t));
400
+ return fetch(e, W(i, t));
372
401
  }
373
- async function H(e, t, n) {
402
+ async function K(e, t, n) {
374
403
  if (!b()) throw Error("resolveEmbedFileSrc called outside embed token mode");
375
- let r = await V(xe(e, t), n);
376
- if (r.status === 202 && typeof t == "object") throw new z(e, t.derivation);
404
+ let r = await G(Te(e, t), n);
405
+ if (r.status === 202 && typeof t == "object") throw new U(e, t.derivation);
377
406
  if (!r.ok) throw Error(`embed file url request failed: ${r.status} ${r.statusText}`);
378
407
  let i = await r.json();
379
- if (!be(i)) throw Error("embed file url response is malformed");
408
+ if (!we(i)) throw Error("embed file url response is malformed");
380
409
  if (!i.proxy) return {
381
410
  url: i.url,
382
411
  kind: "direct"
383
412
  };
384
- let a = await V(t === "download" ? Se(i.url) : i.url, n);
413
+ let a = await G(t === "download" ? Ee(i.url) : i.url, n);
385
414
  if (!a.ok) throw Error(`embed file proxy fetch failed: ${a.status} ${a.statusText}`);
386
415
  let o = await a.blob();
387
416
  return {
@@ -391,37 +420,37 @@ async function H(e, t, n) {
391
420
  }
392
421
  //#endregion
393
422
  //#region src/components/file-widgets/upload.ts
394
- var U = class extends Error {
423
+ var q = class extends Error {
395
424
  code;
396
425
  status;
397
426
  constructor(e, t, n) {
398
427
  super(n), this.code = t, this.status = e;
399
428
  }
400
429
  };
401
- async function Ce(e) {
430
+ async function De(e) {
402
431
  let t = b();
403
432
  try {
404
- return await W(e, t ? await C() : null);
433
+ return await J(e, t ? await C() : null);
405
434
  } catch (n) {
406
- if (!(n instanceof U && n.status === 401 && (n.code === "TOKEN_REFRESH_NEEDED" || n.code === "UNAUTHORIZED"))) throw n;
435
+ if (!(n instanceof q && n.status === 401 && (n.code === "TOKEN_REFRESH_NEEDED" || n.code === "UNAUTHORIZED"))) throw n;
407
436
  let r = null;
408
437
  try {
409
- t ? (S(), r = await C()) : await j();
438
+ t ? (S(), r = await C()) : await F();
410
439
  } catch {
411
- throw N()(), n;
440
+ throw L()(), n;
412
441
  }
413
442
  try {
414
- return await W(e, r);
443
+ return await J(e, r);
415
444
  } catch (e) {
416
- throw e instanceof U && e.status === 401 && N()(), e;
445
+ throw e instanceof q && e.status === 401 && L()(), e;
417
446
  }
418
447
  }
419
448
  }
420
- function W(e, t) {
449
+ function J(e, t) {
421
450
  let { file: n, entityCode: r, fieldCode: i, slotCode: a, onProgress: o, signal: s } = e;
422
451
  return new Promise((e, c) => {
423
452
  let l = new XMLHttpRequest();
424
- if (l.open("POST", we(r, i, a)), l.withCredentials = t === null, t && l.setRequestHeader("Authorization", `Bearer ${t}`), l.upload.onprogress = (e) => {
453
+ if (l.open("POST", Oe(r, i, a)), l.withCredentials = t === null, t && l.setRequestHeader("Authorization", `Bearer ${t}`), l.upload.onprogress = (e) => {
425
454
  if (!o) return;
426
455
  let t = e.lengthComputable ? e.total : n.size, r = t > 0 ? Math.min(100, Math.round(e.loaded / t * 100)) : 0;
427
456
  o({
@@ -435,23 +464,23 @@ function W(e, t) {
435
464
  n = t ? JSON.parse(t) : null;
436
465
  } catch {}
437
466
  if (l.status >= 200 && l.status < 300) {
438
- let t = G(n);
467
+ let t = Y(n);
439
468
  if (!t || !t.id) {
440
- c(new U(l.status, "BAD_RESPONSE", "Upload returned no file id"));
469
+ c(new q(l.status, "BAD_RESPONSE", "Upload returned no file id"));
441
470
  return;
442
471
  }
443
472
  e(t);
444
473
  return;
445
474
  }
446
475
  let r = n, i = r?.error?.code ?? "UPLOAD_FAILED", a = r?.error?.message ?? `Upload failed (${l.status})`;
447
- c(new U(l.status, i, a));
476
+ c(new q(l.status, i, a));
448
477
  }, l.onerror = () => {
449
- c(new U(0, "NETWORK_ERROR", "Network error during upload"));
478
+ c(new q(0, "NETWORK_ERROR", "Network error during upload"));
450
479
  }, l.onabort = () => {
451
- c(new U(0, "ABORTED", "Upload aborted"));
480
+ c(new q(0, "ABORTED", "Upload aborted"));
452
481
  }, s) {
453
482
  if (s.aborted) {
454
- l.abort(), c(new U(0, "ABORTED", "Upload aborted"));
483
+ l.abort(), c(new q(0, "ABORTED", "Upload aborted"));
455
484
  return;
456
485
  }
457
486
  s.addEventListener("abort", () => l.abort(), { once: !0 });
@@ -460,56 +489,56 @@ function W(e, t) {
460
489
  u.append("file", n, n.name), l.send(u);
461
490
  });
462
491
  }
463
- function we(e, t, n) {
492
+ function Oe(e, t, n) {
464
493
  let r = new URLSearchParams();
465
494
  e && t && (r.set("entity_code", e), r.set("field_code", t), n && r.set("slot_code", n));
466
495
  let i = r.toString();
467
496
  return i ? `/api/files/upload?${i}` : "/api/files/upload";
468
497
  }
469
- function G(e) {
470
- return K(e) ? K(e.result) ? G(e.result) : K(e.file) ? Te(e.file) : typeof e.id == "string" ? e : null : null;
498
+ function Y(e) {
499
+ return X(e) ? X(e.result) ? Y(e.result) : X(e.file) ? ke(e.file) : typeof e.id == "string" ? e : null : null;
471
500
  }
472
- function Te(e) {
473
- let t = q(e.file_id);
501
+ function ke(e) {
502
+ let t = Z(e.file_id);
474
503
  return t ? {
475
504
  id: t,
476
- filename: q(e.filename_original) ?? q(e.filename_normalized) ?? t,
477
- content_type: q(e.content_type) ?? "application/octet-stream",
478
- size_bytes: Ee(e.size_bytes) ?? 0,
479
- sha256: q(e.sha256) ?? "",
480
- dedup: De(e.dedup)
505
+ filename: Z(e.filename_original) ?? Z(e.filename_normalized) ?? t,
506
+ content_type: Z(e.content_type) ?? "application/octet-stream",
507
+ size_bytes: Ae(e.size_bytes) ?? 0,
508
+ sha256: Z(e.sha256) ?? "",
509
+ dedup: je(e.dedup)
481
510
  } : null;
482
511
  }
483
- function K(e) {
512
+ function X(e) {
484
513
  return typeof e == "object" && !!e;
485
514
  }
486
- function q(e) {
515
+ function Z(e) {
487
516
  return typeof e == "string" ? e : void 0;
488
517
  }
489
- function Ee(e) {
518
+ function Ae(e) {
490
519
  return typeof e == "number" ? e : void 0;
491
520
  }
492
- function De(e) {
521
+ function je(e) {
493
522
  return typeof e == "boolean" ? e : void 0;
494
523
  }
495
- async function Oe(e) {
496
- await L("files.discard", { file_id: e });
524
+ async function Me(e) {
525
+ await V("files.discard", { file_id: e });
497
526
  }
498
- function ke(e, t, n) {
527
+ function Ne(e, t, n) {
499
528
  if (n && e.size > n) return {
500
529
  code: "FILE_TOO_LARGE",
501
- message: `File is ${J(e.size)}, max ${J(n)}`
530
+ message: `File is ${Q(e.size)}, max ${Q(n)}`
502
531
  };
503
532
  if (t && t.length > 0) {
504
533
  let n = e.type || "application/octet-stream";
505
- if (!t.some((e) => Ae(e, n))) return {
534
+ if (!t.some((e) => Pe(e, n))) return {
506
535
  code: "MIME_NOT_ACCEPTED",
507
536
  message: `File type ${n} is not accepted`
508
537
  };
509
538
  }
510
539
  return null;
511
540
  }
512
- function Ae(e, t) {
541
+ function Pe(e, t) {
513
542
  if (e === "*/*" || e === "*") return !0;
514
543
  if (e.endsWith("/*")) {
515
544
  let n = e.slice(0, e.length - 1);
@@ -517,7 +546,7 @@ function Ae(e, t) {
517
546
  }
518
547
  return e === t;
519
548
  }
520
- function J(e) {
549
+ function Q(e) {
521
550
  if (e < 1024) return `${e} B`;
522
551
  let t = [
523
552
  "KB",
@@ -529,11 +558,11 @@ function J(e) {
529
558
  }
530
559
  //#endregion
531
560
  //#region src/components/file-widgets/helpers.ts
532
- var Y = ["thumb_200", "thumb_300"];
533
- function je() {
561
+ var Fe = ["thumb_200", "thumb_300"];
562
+ function Ie() {
534
563
  return typeof navigator > "u" ? ["en"] : (navigator.languages?.length ? navigator.languages : [navigator.language]).filter((e) => typeof e == "string" && e.length > 0);
535
564
  }
536
- function Me(e, t) {
565
+ function Le(e, t) {
537
566
  for (let n of t) {
538
567
  if (e[n]) return e[n];
539
568
  let t = n.split("-")[0];
@@ -541,17 +570,17 @@ function Me(e, t) {
541
570
  }
542
571
  for (let t of Object.values(e)) if (typeof t == "string" && t.length > 0) return t;
543
572
  }
544
- function Ne(e, t, n) {
573
+ function Re(e, t, n) {
545
574
  if (t) return t;
546
575
  let r = e?.metadata?.alt_text;
547
576
  if (typeof r == "string" && r.length > 0) return r;
548
577
  if (r && typeof r == "object" && !Array.isArray(r)) {
549
- let e = Me(Object.fromEntries(Object.entries(r).filter((e) => e[0].length > 0 && typeof e[1] == "string")), je());
578
+ let e = Le(Object.fromEntries(Object.entries(r).filter((e) => e[0].length > 0 && typeof e[1] == "string")), Ie());
550
579
  if (e) return e;
551
580
  }
552
581
  return n;
553
582
  }
554
- var Pe = new Set([
583
+ var ze = new Set([
555
584
  "image/png",
556
585
  "image/jpeg",
557
586
  "image/webp",
@@ -559,30 +588,30 @@ var Pe = new Set([
559
588
  "image/avif",
560
589
  "application/pdf"
561
590
  ]);
562
- function Fe(e) {
591
+ function Be(e) {
563
592
  let t = e.content_type?.toLowerCase().split(";")[0]?.trim() ?? "";
564
- return Pe.has(t);
593
+ return ze.has(t);
565
594
  }
566
- function Ie(e) {
595
+ function Ve(e) {
567
596
  return e.url ?? e.presigned_url;
568
597
  }
569
- function Le(e) {
570
- return e.url ? Be(e.url, "attachment") : e.presigned_url;
598
+ function He(e) {
599
+ return e.url ? Ge(e.url, "attachment") : e.presigned_url;
571
600
  }
572
- function Re(e, t) {
601
+ function Ue(e, t) {
573
602
  if (!e) return;
574
603
  let n = e.derivations ?? {};
575
604
  if (t && n[t]) return n[t];
576
- for (let e of Y) if (n[e]) return n[e];
605
+ for (let e of Fe) if (n[e]) return n[e];
577
606
  return e.url ?? e.presigned_url;
578
607
  }
579
- function ze(e, t) {
608
+ function We(e, t) {
580
609
  let n = e?.derivations ?? {};
581
610
  if (t && n[t]) return { derivation: t };
582
- for (let e of Y) if (n[e]) return { derivation: e };
611
+ for (let e of Fe) if (n[e]) return { derivation: e };
583
612
  return "preview";
584
613
  }
585
- function Be(e, t) {
614
+ function Ge(e, t) {
586
615
  try {
587
616
  let n = new URL(e, typeof window < "u" ? window.location.origin : "http://localhost");
588
617
  return n.searchParams.set("disposition", t), /^https?:\/\//i.test(e) ? n.toString() : `${n.pathname}${n.search}${n.hash}`;
@@ -590,7 +619,7 @@ function Be(e, t) {
590
619
  return `${e}${e.includes("?") ? "&" : "?"}disposition=${t}`;
591
620
  }
592
621
  }
593
- function Ve(e) {
622
+ function Ke(e) {
594
623
  let t = e?.metadata?.focal_point;
595
624
  if (!t || typeof t != "object" || Array.isArray(t)) return null;
596
625
  let n = t, r = typeof n.x == "number" ? n.x : NaN, i = typeof n.y == "number" ? n.y : NaN;
@@ -599,10 +628,10 @@ function Ve(e) {
599
628
  y: i
600
629
  };
601
630
  }
602
- function He(e) {
631
+ function qe(e) {
603
632
  if (e) return `${e.x * 100}% ${e.y * 100}%`;
604
633
  }
605
- function Ue(e, t) {
634
+ function Je(e, t) {
606
635
  return {
607
636
  ...e,
608
637
  metadata: {
@@ -613,7 +642,7 @@ function Ue(e, t) {
613
642
  }
614
643
  //#endregion
615
644
  //#region src/components/file-widgets/draft-scope.tsx
616
- var X = e({
645
+ var Ye = e({
617
646
  registerDraft() {},
618
647
  unregisterDraft() {},
619
648
  hasDraft() {
@@ -622,7 +651,7 @@ var X = e({
622
651
  flushAllDrafts: async () => {},
623
652
  markCommitted() {}
624
653
  });
625
- function Z({ children: e }) {
654
+ function Xe({ children: e }) {
626
655
  let t = a(/* @__PURE__ */ new Map()), n = i(() => ({
627
656
  registerDraft(e) {
628
657
  t.current.set(e.fileId, e);
@@ -641,16 +670,16 @@ function Z({ children: e }) {
641
670
  t.current.clear(), await Promise.allSettled(e.map((e) => Promise.resolve(e.discard())));
642
671
  }
643
672
  }), []);
644
- return /* @__PURE__ */ s(X.Provider, {
673
+ return /* @__PURE__ */ s(Ye.Provider, {
645
674
  value: n,
646
675
  children: e
647
676
  });
648
677
  }
649
- function Q() {
650
- return n(X);
678
+ function Ze() {
679
+ return n(Ye);
651
680
  }
652
- function We() {
653
- let e = Q();
681
+ function Qe() {
682
+ let e = Ze();
654
683
  return {
655
684
  register: t((t, n) => {
656
685
  e.registerDraft({
@@ -669,14 +698,14 @@ function We() {
669
698
  }
670
699
  //#endregion
671
700
  //#region src/components/file-widgets/useEmbedFileSrc.ts
672
- function Ge(e) {
701
+ function $e(e) {
673
702
  return typeof e == "object" ? `derivation:${e.derivation}` : e;
674
703
  }
675
- function Ke(e) {
704
+ function et(e) {
676
705
  return e.startsWith("derivation:") ? { derivation: e.slice(11) } : e === "download" ? "download" : "preview";
677
706
  }
678
- function qe(e, t, n) {
679
- let i = Ge(t), [a, s] = o(() => b() ? void 0 : n);
707
+ function tt(e, t, n) {
708
+ let i = $e(t), [a, s] = o(() => b() ? void 0 : n);
680
709
  return r(() => {
681
710
  b() || s(n);
682
711
  }, [n]), r(() => {
@@ -686,7 +715,7 @@ function qe(e, t, n) {
686
715
  return;
687
716
  }
688
717
  let t = null, n = !1, r = new AbortController();
689
- return s(void 0), H(e, Ke(i), r.signal).then((e) => {
718
+ return s(void 0), K(e, et(i), r.signal).then((e) => {
690
719
  if (n) {
691
720
  e.kind === "blob" && URL.revokeObjectURL(e.url);
692
721
  return;
@@ -694,7 +723,7 @@ function qe(e, t, n) {
694
723
  e.kind === "blob" && (t = e.url), s(e.url);
695
724
  }).catch((e) => {
696
725
  if (!n) {
697
- if (e instanceof z) {
726
+ if (e instanceof U) {
698
727
  s(void 0);
699
728
  return;
700
729
  }
@@ -705,7 +734,7 @@ function qe(e, t, n) {
705
734
  };
706
735
  }, [e, i]), a;
707
736
  }
708
- function Je() {
737
+ function nt() {
709
738
  let e = a([]);
710
739
  return r(() => () => {
711
740
  for (let t of e.current) URL.revokeObjectURL(t);
@@ -715,10 +744,10 @@ function Je() {
715
744
  r && window.open(r, "_blank", "noopener");
716
745
  return;
717
746
  }
718
- t && H(t, n).then((t) => {
747
+ t && K(t, n).then((t) => {
719
748
  t.kind === "blob" && e.current.push(t.url), window.open(t.url, "_blank", "noopener");
720
749
  }).catch((e) => {
721
- e instanceof z || console.error("[declarion-embed] file open failed:", e);
750
+ e instanceof U || console.error("[declarion-embed] file open failed:", e);
722
751
  });
723
752
  }, []) };
724
753
  }
@@ -727,13 +756,13 @@ function Je() {
727
756
  function $(e) {
728
757
  return typeof e == "object" && !!e && typeof e.id == "string";
729
758
  }
730
- function Ye(e) {
759
+ function rt(e) {
731
760
  return e ? Array.isArray(e) ? e.find($) ?? null : $(e) ? e : null : null;
732
761
  }
733
- function Xe(e) {
762
+ function it(e) {
734
763
  return e ? Array.isArray(e) ? e.filter($) : $(e) ? [e] : [] : [];
735
764
  }
736
765
  //#endregion
737
- export { fe as A, m as B, I as C, N as D, j as E, b as F, c as H, oe as I, h as L, S as M, x as N, me as O, re as P, g as R, A as S, L as T, p as V, U as _, Z as a, Ce as b, Fe as c, Re as d, ze as f, Ue as g, Ne as h, qe as i, C as j, E as k, Le as l, Ve as m, Ye as n, We as o, Ie as p, Je as r, Q as s, Xe as t, He as u, Oe as v, ve as w, ke as x, J as y, _ as z };
766
+ export { ve as A, g as B, B as C, F as D, ge as E, x as F, m as H, re as I, b as L, fe as M, C as N, L as O, S as P, oe as R, A as S, V as T, p as U, _ as V, c as W, q as _, Xe as a, De as b, Be as c, Ue as d, We as f, Je as g, Re as h, tt as i, E as j, N as k, He as l, Ke as m, rt as n, Qe as o, Ve as p, nt as r, Ze as s, it as t, qe as u, Me as v, Se as w, Ne as x, Q as y, h as z };
738
767
 
739
- //# sourceMappingURL=value-DFpIiSZ-.js.map
768
+ //# sourceMappingURL=value-qao1rdkR.js.map