@cupcodev/ui 1.3.0 → 1.4.0

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
@@ -202,7 +202,7 @@ var BackgroundRainbow = () => {
202
202
  will-change: transform;
203
203
  }
204
204
 
205
- /* usa tuas globais #ed1e79 e #7c5bbb com ~0.4 de opacidade */
205
+ /* usa as cores globais de hover/purple com ~0.4 de opacidade */
206
206
  .cc-a {
207
207
  background: radial-gradient(circle at center,
208
208
  color-mix(in srgb, var(--color-one) 40%, transparent) 0%,
@@ -465,10 +465,10 @@ function BackgroundStars() {
465
465
  const halo2 = size * 7.2 * k;
466
466
  const halo3 = size * 10.8 * k;
467
467
  drawHalo(starsCtx, 0, 0, halo1, "rgba(251,88,235,0.65)");
468
- drawHalo(starsCtx, 0, 0, halo2, "rgba(237,30,121,0.58)");
468
+ drawHalo(starsCtx, 0, 0, halo2, "rgba(151,90,182,0.58)");
469
469
  drawHalo(starsCtx, 0, 0, halo3, "rgba(124,91,187,0.52)");
470
470
  const gp = size * (1.8 + glow);
471
- drawHalo(starsCtx, 0, 0, gp, "rgba(233,12,211,0.28)");
471
+ drawHalo(starsCtx, 0, 0, gp, "rgba(151,90,182,0.28)");
472
472
  if (s.isHighlight) {
473
473
  starsCtx.globalAlpha = opacity * (0.35 + 0.65 * sparkBoost);
474
474
  starsCtx.rotate(0);
@@ -514,12 +514,12 @@ function BackgroundStars() {
514
514
  ctx.rotate(c.angle);
515
515
  ctx.globalAlpha = 0.2 + 0.8 * ease;
516
516
  drawHalo(ctx, 0, 0, 0.85, "rgba(255,255,255,1)");
517
- drawHalo(ctx, 0, 0, 8, "rgba(237,30,121,0.75)");
517
+ drawHalo(ctx, 0, 0, 8, "rgba(151,90,182,0.75)");
518
518
  drawHalo(ctx, 0, 0, 14, "rgba(124,91,187,0.6)");
519
519
  const tailLen = c.len;
520
520
  const grd = ctx.createLinearGradient(0, 0, -tailLen, 0);
521
521
  grd.addColorStop(0, "rgba(255,255,255,0.95)");
522
- grd.addColorStop(0.4, "rgba(237,30,121,0.75)");
522
+ grd.addColorStop(0.4, "rgba(151,90,182,0.75)");
523
523
  grd.addColorStop(0.75, "rgba(124,91,187,0.55)");
524
524
  grd.addColorStop(1, "rgba(0,0,0,0)");
525
525
  ctx.fillStyle = grd;
@@ -708,10 +708,10 @@ var Dock = ({ items, className }) => {
708
708
  const itemsRef = useRef3([]);
709
709
  const OVERSHOOT = 5;
710
710
  useEffect3(() => {
711
- var _a72;
711
+ var _a74;
712
712
  const activeItem = itemsRef.current[activeIndex];
713
713
  if (!activeItem) return;
714
- const containerRect = (_a72 = activeItem.parentElement) == null ? void 0 : _a72.getBoundingClientRect();
714
+ const containerRect = (_a74 = activeItem.parentElement) == null ? void 0 : _a74.getBoundingClientRect();
715
715
  const itemRect = activeItem.getBoundingClientRect();
716
716
  if (!containerRect) return;
717
717
  const relativeLeft = itemRect.left - containerRect.left;
@@ -773,9 +773,9 @@ var Dock = ({ items, className }) => {
773
773
  "button",
774
774
  {
775
775
  onClick: () => {
776
- var _a72;
776
+ var _a74;
777
777
  setActiveIndex(index);
778
- (_a72 = item.onClick) == null ? void 0 : _a72.call(item);
778
+ (_a74 = item.onClick) == null ? void 0 : _a74.call(item);
779
779
  },
780
780
  className: cn(
781
781
  "flex items-center justify-center w-12 h-12 rounded-xl",
@@ -821,9 +821,9 @@ var normalizeValue = (value) => {
821
821
  return String(value);
822
822
  };
823
823
  var setCupcodeRuntimeEnv = (values) => {
824
- var _a72;
824
+ var _a74;
825
825
  const globalRef = globalThis;
826
- const nextGlobalEnv = { ...(_a72 = globalRef.__CUPCODE_ENV__) != null ? _a72 : {} };
826
+ const nextGlobalEnv = { ...(_a74 = globalRef.__CUPCODE_ENV__) != null ? _a74 : {} };
827
827
  Object.entries(values).forEach(([key, value]) => {
828
828
  const normalized = normalizeValue(value);
829
829
  runtimeStore[key] = normalized;
@@ -832,8 +832,8 @@ var setCupcodeRuntimeEnv = (values) => {
832
832
  globalRef.__CUPCODE_ENV__ = nextGlobalEnv;
833
833
  };
834
834
  var readFromProcessEnv = (key) => {
835
- var _a72;
836
- const processEnv = (_a72 = globalThis.process) == null ? void 0 : _a72.env;
835
+ var _a74;
836
+ const processEnv = (_a74 = globalThis.process) == null ? void 0 : _a74.env;
837
837
  return normalizeValue(processEnv == null ? void 0 : processEnv[key]);
838
838
  };
839
839
  var readFromImportMetaEnv = (key) => {
@@ -845,12 +845,12 @@ var readFromImportMetaEnv = (key) => {
845
845
  }
846
846
  };
847
847
  var getRuntimeEnv = (key) => {
848
- var _a72;
848
+ var _a74;
849
849
  const normalizedKey = key.trim();
850
850
  if (!normalizedKey) return void 0;
851
851
  const fromRuntimeStore = runtimeStore[normalizedKey];
852
852
  if (fromRuntimeStore) return fromRuntimeStore;
853
- const fromGlobalStore = normalizeValue((_a72 = globalThis.__CUPCODE_ENV__) == null ? void 0 : _a72[normalizedKey]);
853
+ const fromGlobalStore = normalizeValue((_a74 = globalThis.__CUPCODE_ENV__) == null ? void 0 : _a74[normalizedKey]);
854
854
  if (fromGlobalStore) return fromGlobalStore;
855
855
  const fromGlobalKey = normalizeValue(globalThis[normalizedKey]);
856
856
  if (fromGlobalKey) return fromGlobalKey;
@@ -859,17 +859,17 @@ var getRuntimeEnv = (key) => {
859
859
  return readFromProcessEnv(normalizedKey);
860
860
  };
861
861
  var getRuntimeEnvOr = (key, fallback) => {
862
- var _a72;
863
- return (_a72 = getRuntimeEnv(key)) != null ? _a72 : fallback;
862
+ var _a74;
863
+ return (_a74 = getRuntimeEnv(key)) != null ? _a74 : fallback;
864
864
  };
865
865
  var isRuntimeDev = () => {
866
- var _a72, _b6, _c;
867
- const explicitDev = (_a72 = getRuntimeEnv("DEV")) != null ? _a72 : getRuntimeEnv("VITE_DEV");
866
+ var _a74, _b7, _c;
867
+ const explicitDev = (_a74 = getRuntimeEnv("DEV")) != null ? _a74 : getRuntimeEnv("VITE_DEV");
868
868
  if (explicitDev) {
869
869
  const normalized = explicitDev.toLowerCase();
870
870
  return normalized === "1" || normalized === "true";
871
871
  }
872
- const mode = ((_c = (_b6 = getRuntimeEnv("MODE")) != null ? _b6 : getRuntimeEnv("NODE_ENV")) != null ? _c : "").toLowerCase();
872
+ const mode = ((_c = (_b7 = getRuntimeEnv("MODE")) != null ? _b7 : getRuntimeEnv("NODE_ENV")) != null ? _c : "").toLowerCase();
873
873
  return mode === "development";
874
874
  };
875
875
 
@@ -881,15 +881,15 @@ var isUuid = (value) => {
881
881
  return UUID_REGEX.test(value.trim());
882
882
  };
883
883
  function parseAssetId(input) {
884
- var _a72, _b6, _c, _d;
884
+ var _a74, _b7, _c, _d;
885
885
  const raw = input == null ? void 0 : input.trim();
886
886
  if (!raw) return void 0;
887
887
  if (UUID_REGEX.test(raw)) return raw;
888
- const matchFromRaw = (_a72 = raw.match(UUID_IN_TEXT_REGEX)) == null ? void 0 : _a72[0];
888
+ const matchFromRaw = (_a74 = raw.match(UUID_IN_TEXT_REGEX)) == null ? void 0 : _a74[0];
889
889
  if (isUuid(matchFromRaw)) return matchFromRaw;
890
890
  try {
891
891
  const url = new URL(raw);
892
- const queryParamId = (_c = (_b6 = url.searchParams.get("id")) != null ? _b6 : url.searchParams.get("asset_id")) != null ? _c : url.searchParams.get("assetId");
892
+ const queryParamId = (_c = (_b7 = url.searchParams.get("id")) != null ? _b7 : url.searchParams.get("asset_id")) != null ? _c : url.searchParams.get("assetId");
893
893
  if (isUuid(queryParamId)) return queryParamId;
894
894
  const matchFromPath = (_d = url.pathname.match(UUID_IN_TEXT_REGEX)) == null ? void 0 : _d[0];
895
895
  if (isUuid(matchFromPath)) return matchFromPath;
@@ -1021,7 +1021,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1021
1021
  return void 0;
1022
1022
  }, [sortedCategories]);
1023
1023
  useEffect5(() => {
1024
- var _a72;
1024
+ var _a74;
1025
1025
  const root = rootRef.current;
1026
1026
  if (!root) return;
1027
1027
  const $ = (sel) => root.querySelector(sel);
@@ -1033,7 +1033,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1033
1033
  const getDockItems = () => Array.from(root.querySelectorAll(INTERACTIVE_SELECTOR));
1034
1034
  const dockItems = getDockItems();
1035
1035
  if (!tabbar || !dock || !listMenuShow || !tabbarUl || dockItems.length === 0) return;
1036
- const persistentId = (_a72 = activeCategoryId != null ? activeCategoryId : lastInteractiveId) != null ? _a72 : null;
1036
+ const persistentId = (_a74 = activeCategoryId != null ? activeCategoryId : lastInteractiveId) != null ? _a74 : null;
1037
1037
  let openItem = null;
1038
1038
  let latestToggleToken = null;
1039
1039
  const persistentSelector = persistentId != null ? `${INTERACTIVE_SELECTOR}[data-cat-id="${persistentId}"]` : null;
@@ -1332,8 +1332,8 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1332
1332
  }, total);
1333
1333
  }
1334
1334
  const hideBootstrapTooltip = (el) => {
1335
- var _a73, _b6;
1336
- const tooltip = ((_b6 = (_a73 = window.bootstrap) == null ? void 0 : _a73.Tooltip) == null ? void 0 : _b6.getInstance) ? window.bootstrap.Tooltip.getInstance(el) : null;
1335
+ var _a75, _b7;
1336
+ const tooltip = ((_b7 = (_a75 = window.bootstrap) == null ? void 0 : _a75.Tooltip) == null ? void 0 : _b7.getInstance) ? window.bootstrap.Tooltip.getInstance(el) : null;
1337
1337
  tooltip == null ? void 0 : tooltip.hide();
1338
1338
  };
1339
1339
  const openMenuForItem = (item, menu) => {
@@ -1351,14 +1351,14 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1351
1351
  latestToggleToken = null;
1352
1352
  };
1353
1353
  const closeActiveMenu = (opts = {}) => {
1354
- var _a73;
1354
+ var _a75;
1355
1355
  if (!opts.onClosed) {
1356
1356
  latestToggleToken = null;
1357
1357
  }
1358
1358
  const itemToClose = openItem;
1359
1359
  if (!itemToClose) {
1360
1360
  if (!opts.preserveWrapper) ensurePersistentHighlight();
1361
- (_a73 = opts.onClosed) == null ? void 0 : _a73.call(opts);
1361
+ (_a75 = opts.onClosed) == null ? void 0 : _a75.call(opts);
1362
1362
  return;
1363
1363
  }
1364
1364
  const menu = getMenuFor(itemToClose);
@@ -1366,7 +1366,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1366
1366
  itemToClose.classList.remove("active");
1367
1367
  delete itemToClose.dataset.menuOpen;
1368
1368
  const finalize = () => {
1369
- var _a74;
1369
+ var _a76;
1370
1370
  if (!opts.preserveWrapper) {
1371
1371
  listMenuShow.classList.remove("show");
1372
1372
  tabbar.classList.remove("is-active-menu");
@@ -1374,7 +1374,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1374
1374
  setTabbarTheme(null);
1375
1375
  ensurePersistentHighlight();
1376
1376
  }
1377
- (_a74 = opts.onClosed) == null ? void 0 : _a74.call(opts);
1377
+ (_a76 = opts.onClosed) == null ? void 0 : _a76.call(opts);
1378
1378
  };
1379
1379
  closeMenu(menu, finalize);
1380
1380
  };
@@ -1477,7 +1477,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1477
1477
  /* @__PURE__ */ jsx10("div", { className: "glass-overlay" }),
1478
1478
  /* @__PURE__ */ jsx10("div", { className: "glass-specular" }),
1479
1479
  /* @__PURE__ */ jsx10("ul", { className: "flex-center", children: sortedCategories.map((cat) => {
1480
- var _a72;
1480
+ var _a74;
1481
1481
  if (cat.type === "divider") {
1482
1482
  return /* @__PURE__ */ jsx10(
1483
1483
  "li",
@@ -1489,7 +1489,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1489
1489
  cat.id
1490
1490
  );
1491
1491
  }
1492
- const hasCards = (((_a72 = cat.cards) == null ? void 0 : _a72.length) || 0) > 0;
1492
+ const hasCards = (((_a74 = cat.cards) == null ? void 0 : _a74.length) || 0) > 0;
1493
1493
  const link = cat.href;
1494
1494
  const isCurrent = cat.id === activeCategoryId;
1495
1495
  return /* @__PURE__ */ jsxs8(
@@ -1523,12 +1523,12 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1523
1523
  );
1524
1524
  }) }),
1525
1525
  /* @__PURE__ */ jsx10("div", { className: "list-menu-mob-show", children: sortedCategories.filter((cat) => {
1526
- var _a72;
1527
- return cat.type !== "divider" && (((_a72 = cat.cards) == null ? void 0 : _a72.length) || 0) > 0;
1526
+ var _a74;
1527
+ return cat.type !== "divider" && (((_a74 = cat.cards) == null ? void 0 : _a74.length) || 0) > 0;
1528
1528
  }).map((cat) => {
1529
- var _a72;
1530
- return /* @__PURE__ */ jsx10("div", { className: "mob-list-menu hide", "data-tagget": cat.slug, children: /* @__PURE__ */ jsx10("div", { className: `submenu-stack ${cat.slug}`, children: ((_a72 = cat.cards) != null ? _a72 : []).map((card, i) => {
1531
- var _a73;
1529
+ var _a74;
1530
+ return /* @__PURE__ */ jsx10("div", { className: "mob-list-menu hide", "data-tagget": cat.slug, children: /* @__PURE__ */ jsx10("div", { className: `submenu-stack ${cat.slug}`, children: ((_a74 = cat.cards) != null ? _a74 : []).map((card, i) => {
1531
+ var _a75;
1532
1532
  return /* @__PURE__ */ jsxs8(
1533
1533
  "div",
1534
1534
  {
@@ -1544,8 +1544,8 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1544
1544
  /* @__PURE__ */ jsx10("div", { className: "title", children: card.title }),
1545
1545
  card.description ? /* @__PURE__ */ jsx10("div", { className: "description", children: card.description }) : null
1546
1546
  ] }),
1547
- /* @__PURE__ */ jsx10("div", { className: "actions", children: ((_a73 = card.buttons) != null ? _a73 : []).slice(0, 2).map((btn, idx) => {
1548
- var _a74, _b6, _c, _d;
1547
+ /* @__PURE__ */ jsx10("div", { className: "actions", children: ((_a75 = card.buttons) != null ? _a75 : []).slice(0, 2).map((btn, idx) => {
1548
+ var _a76, _b7, _c, _d;
1549
1549
  const className = idx === 0 ? "saiba-mais" : "saiba-mais-1";
1550
1550
  if (btn.type === "popup") {
1551
1551
  return /* @__PURE__ */ jsx10(
@@ -1560,7 +1560,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1560
1560
  window.dispatchEvent(new Event(`qw:open:${btn.popupId}`));
1561
1561
  }
1562
1562
  },
1563
- children: (_a74 = btn.label) != null ? _a74 : "Abrir"
1563
+ children: (_a76 = btn.label) != null ? _a76 : "Abrir"
1564
1564
  },
1565
1565
  `${cat.id}-card-${i}-btn-${idx}`
1566
1566
  );
@@ -1570,7 +1570,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1570
1570
  {
1571
1571
  href: btn.href || "#",
1572
1572
  className,
1573
- target: ((_b6 = btn.href) == null ? void 0 : _b6.startsWith("http")) ? "_blank" : void 0,
1573
+ target: ((_b7 = btn.href) == null ? void 0 : _b7.startsWith("http")) ? "_blank" : void 0,
1574
1574
  rel: ((_c = btn.href) == null ? void 0 : _c.startsWith("http")) ? "noopener noreferrer" : void 0,
1575
1575
  children: (_d = btn.label) != null ? _d : "Saiba mais >"
1576
1576
  },
@@ -1892,7 +1892,7 @@ var HeroTitle = ({
1892
1892
  eyebrow && /* @__PURE__ */ jsx15("span", { className: "span-destaque animate-fade-in", children: eyebrow }),
1893
1893
  /* @__PURE__ */ jsxs12(Tag, { className: "font-display font-bold leading-tight animate-slide-up", children: [
1894
1894
  smallPrefix && /* @__PURE__ */ jsx15("small", { className: "block text-base font-normal opacity-70 mb-1", children: smallPrefix }),
1895
- /* @__PURE__ */ jsx15("b", { className: "block bg-gradient-to-r from-cupcode-pink to-cupcode-purple bg-clip-text text-transparent", children: strong })
1895
+ /* @__PURE__ */ jsx15("b", { className: "block bg-gradient-to-r from-cupcode-hover to-cupcode-purple bg-clip-text text-transparent", children: strong })
1896
1896
  ] })
1897
1897
  ] });
1898
1898
  };
@@ -2319,10 +2319,10 @@ var NavbarCupcode = ({
2319
2319
  React10.useEffect(() => {
2320
2320
  if (!isOpen) return;
2321
2321
  const handlePointerDown = (event) => {
2322
- var _a72;
2322
+ var _a74;
2323
2323
  const target = event.target;
2324
2324
  if (!(target instanceof Node)) return;
2325
- if (!((_a72 = navRef.current) == null ? void 0 : _a72.contains(target))) {
2325
+ if (!((_a74 = navRef.current) == null ? void 0 : _a74.contains(target))) {
2326
2326
  setIsOpen(false);
2327
2327
  }
2328
2328
  };
@@ -2382,8 +2382,8 @@ var NavbarCupcode = ({
2382
2382
  isActive && "text-primary after:w-full"
2383
2383
  );
2384
2384
  const handleClick = (event) => {
2385
- var _a72;
2386
- (_a72 = item.onClick) == null ? void 0 : _a72.call(item, event);
2385
+ var _a74;
2386
+ (_a74 = item.onClick) == null ? void 0 : _a74.call(item, event);
2387
2387
  };
2388
2388
  if (item.href.startsWith("#")) {
2389
2389
  return /* @__PURE__ */ jsxs17(
@@ -2444,8 +2444,8 @@ var NavbarCupcode = ({
2444
2444
  isActive && "text-primary"
2445
2445
  );
2446
2446
  const handleClick = (event) => {
2447
- var _a72;
2448
- (_a72 = item.onClick) == null ? void 0 : _a72.call(item, event);
2447
+ var _a74;
2448
+ (_a74 = item.onClick) == null ? void 0 : _a74.call(item, event);
2449
2449
  setIsOpen(false);
2450
2450
  };
2451
2451
  if (item.href.startsWith("#")) {
@@ -3129,33 +3129,43 @@ var DEV_REST_PROXY_BASE_URL = "/rest/v1";
3129
3129
  var UUID_REGEX2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
3130
3130
  var _a3, _b2;
3131
3131
  var TELESCUP_MANAGER_FIRST = ((_b2 = (_a3 = getRuntimeEnv("VITE_TELESCUP_MANAGER_FIRST")) == null ? void 0 : _a3.trim().toLowerCase()) != null ? _b2 : "true") !== "false";
3132
- var _a4;
3133
- var TELESCUP_LIST_FUNCTION = ((_a4 = getRuntimeEnv("VITE_TELESCUP_LIST_FUNCTION")) == null ? void 0 : _a4.trim()) || "telescup-assets-list";
3132
+ var _a4, _b3;
3133
+ var TELESCUP_MANAGER_FALLBACK = ((_b3 = (_a4 = getRuntimeEnv("VITE_TELESCUP_MANAGER_FALLBACK")) == null ? void 0 : _a4.trim().toLowerCase()) != null ? _b3 : "true") !== "false";
3134
3134
  var _a5;
3135
- var TELESCUP_UPLOAD_INIT_FUNCTION = ((_a5 = getRuntimeEnv("VITE_TELESCUP_UPLOAD_INIT_FUNCTION")) == null ? void 0 : _a5.trim()) || "telescup-upload-init";
3135
+ var TELESCUP_LIST_FUNCTION = ((_a5 = getRuntimeEnv("VITE_TELESCUP_LIST_FUNCTION")) == null ? void 0 : _a5.trim()) || "asset-api/search";
3136
3136
  var _a6;
3137
- var TELESCUP_UPLOAD_COMPLETE_FUNCTION = ((_a6 = getRuntimeEnv("VITE_TELESCUP_UPLOAD_COMPLETE_FUNCTION")) == null ? void 0 : _a6.trim()) || "telescup-upload-complete";
3137
+ var TELESCUP_UPLOAD_INIT_FUNCTION = ((_a6 = getRuntimeEnv("VITE_TELESCUP_UPLOAD_INIT_FUNCTION")) == null ? void 0 : _a6.trim()) || "telescup-upload-init";
3138
3138
  var _a7;
3139
- var TELESCUP_UPDATE_META_FUNCTION = ((_a7 = getRuntimeEnv("VITE_TELESCUP_UPDATE_META_FUNCTION")) == null ? void 0 : _a7.trim()) || "telescup-assets-update-meta";
3139
+ var TELESCUP_UPLOAD_COMPLETE_FUNCTION = ((_a7 = getRuntimeEnv("VITE_TELESCUP_UPLOAD_COMPLETE_FUNCTION")) == null ? void 0 : _a7.trim()) || "telescup-upload-complete";
3140
3140
  var _a8;
3141
- var TELESCUP_UPLOAD_DIRECT_FUNCTION = ((_a8 = getRuntimeEnv("VITE_TELESCUP_UPLOAD_DIRECT_FUNCTION")) == null ? void 0 : _a8.trim()) || "asset-api/upload";
3141
+ var TELESCUP_UPDATE_META_FUNCTION = ((_a8 = getRuntimeEnv("VITE_TELESCUP_UPDATE_META_FUNCTION")) == null ? void 0 : _a8.trim()) || "telescup-assets-update-meta";
3142
3142
  var _a9;
3143
- var TELESCUP_SEARCH_DEFAULT_QUERY = ((_a9 = getRuntimeEnv("VITE_TELESCUP_SEARCH_DEFAULT_QUERY")) == null ? void 0 : _a9.trim()) || "images";
3144
- var _a10, _b3;
3145
- var TELESCUP_PREFER_RPC = ((_b3 = (_a10 = getRuntimeEnv("VITE_TELESCUP_PREFER_RPC")) == null ? void 0 : _a10.trim().toLowerCase()) != null ? _b3 : "false") === "true";
3146
- var _a11;
3147
- var TELESCUP_ASSET_API_FACET_SEED_LIMIT_RAW = Number((_a11 = getRuntimeEnv("VITE_TELESCUP_FACET_SEED_LIMIT")) != null ? _a11 : "120");
3143
+ var TELESCUP_UPLOAD_DIRECT_FUNCTION = ((_a9 = getRuntimeEnv("VITE_TELESCUP_UPLOAD_DIRECT_FUNCTION")) == null ? void 0 : _a9.trim()) || "asset-api/upload";
3144
+ var _a10;
3145
+ var TELESCUP_SEARCH_DEFAULT_QUERY = ((_a10 = getRuntimeEnv("VITE_TELESCUP_SEARCH_DEFAULT_QUERY")) == null ? void 0 : _a10.trim()) || "images";
3146
+ var _a11, _b4;
3147
+ var TELESCUP_PREFER_RPC = ((_b4 = (_a11 = getRuntimeEnv("VITE_TELESCUP_PREFER_RPC")) == null ? void 0 : _a11.trim().toLowerCase()) != null ? _b4 : "false") === "true";
3148
+ var _a12;
3149
+ var TELESCUP_ASSET_API_FACET_SEED_LIMIT_RAW = Number((_a12 = getRuntimeEnv("VITE_TELESCUP_FACET_SEED_LIMIT")) != null ? _a12 : "120");
3148
3150
  var TELESCUP_ASSET_API_FACET_SEED_LIMIT = Math.min(
3149
- 500,
3150
- Math.max(50, Number.isFinite(TELESCUP_ASSET_API_FACET_SEED_LIMIT_RAW) ? Math.floor(TELESCUP_ASSET_API_FACET_SEED_LIMIT_RAW) : 120)
3151
+ 5e3,
3152
+ Math.max(1, Number.isFinite(TELESCUP_ASSET_API_FACET_SEED_LIMIT_RAW) ? Math.floor(TELESCUP_ASSET_API_FACET_SEED_LIMIT_RAW) : 120)
3151
3153
  );
3152
- var _a12;
3153
- var TELESCUP_DB_SCHEMA = ((_a12 = getRuntimeEnv("VITE_TELESCUP_SCHEMA")) != null ? _a12 : "telescup").trim() || "telescup";
3154
3154
  var _a13;
3155
- var TELESCUP_RPC_SCHEMA = ((_a13 = getRuntimeEnv("VITE_TELESCUP_RPC_SCHEMA")) != null ? _a13 : TELESCUP_DB_SCHEMA).trim() || TELESCUP_DB_SCHEMA;
3155
+ var TELESCUP_DB_SCHEMA = ((_a13 = getRuntimeEnv("VITE_TELESCUP_SCHEMA")) != null ? _a13 : "telescup").trim() || "telescup";
3156
+ var _a14;
3157
+ var TELESCUP_RPC_SCHEMA = ((_a14 = getRuntimeEnv("VITE_TELESCUP_RPC_SCHEMA")) != null ? _a14 : TELESCUP_DB_SCHEMA).trim() || TELESCUP_DB_SCHEMA;
3156
3158
  var TELESCUP_DB_PROFILES = [TELESCUP_DB_SCHEMA];
3157
3159
  var TELESCUP_TABLE_FACET_LIMIT = 1e3;
3158
3160
  var TELESCUP_DENIED_TABLE_CACHE = /* @__PURE__ */ new Set();
3161
+ var _a15;
3162
+ var TELESCUP_FACET_CACHE_MS_RAW = Number((_a15 = getRuntimeEnv("VITE_TELESCUP_FACET_CACHE_MS")) != null ? _a15 : "300000");
3163
+ var TELESCUP_FACET_CACHE_MS = Math.max(
3164
+ 0,
3165
+ Number.isFinite(TELESCUP_FACET_CACHE_MS_RAW) ? Math.floor(TELESCUP_FACET_CACHE_MS_RAW) : 3e5
3166
+ );
3167
+ var TELESCUP_FACET_CACHE_KEY_PREFIX = "telescup:facets:v1";
3168
+ var TELESCUP_TABLE_FACETS_CACHE = /* @__PURE__ */ new Map();
3159
3169
  var readString = (value) => {
3160
3170
  if (typeof value !== "string") return void 0;
3161
3171
  const normalized = value.trim();
@@ -3182,6 +3192,39 @@ var readFirstNumber = (row, keys) => {
3182
3192
  var resolveFunctionsBaseUrl = (baseUrl) => {
3183
3193
  return normalizeBaseUrl(baseUrl);
3184
3194
  };
3195
+ var getFacetCacheKey = (config) => `${TELESCUP_FACET_CACHE_KEY_PREFIX}:${normalizeBaseUrl(config.baseUrl)}:${TELESCUP_DB_SCHEMA}`;
3196
+ var canUseLocalStorage = () => typeof window !== "undefined" && typeof window.localStorage !== "undefined";
3197
+ var readCachedTableFacets = (config) => {
3198
+ if (TELESCUP_FACET_CACHE_MS <= 0) return void 0;
3199
+ const key = getFacetCacheKey(config);
3200
+ const cachedMemory = TELESCUP_TABLE_FACETS_CACHE.get(key);
3201
+ if (cachedMemory && Date.now() - cachedMemory.ts < TELESCUP_FACET_CACHE_MS) {
3202
+ return cachedMemory.facets;
3203
+ }
3204
+ if (!canUseLocalStorage()) return void 0;
3205
+ try {
3206
+ const raw = window.localStorage.getItem(key);
3207
+ if (!raw) return void 0;
3208
+ const parsed = JSON.parse(raw);
3209
+ if (!parsed || typeof parsed.ts !== "number" || !parsed.facets) return void 0;
3210
+ if (Date.now() - parsed.ts >= TELESCUP_FACET_CACHE_MS) return void 0;
3211
+ TELESCUP_TABLE_FACETS_CACHE.set(key, { ts: parsed.ts, facets: parsed.facets });
3212
+ return parsed.facets;
3213
+ } catch (e) {
3214
+ return void 0;
3215
+ }
3216
+ };
3217
+ var writeCachedTableFacets = (config, facets) => {
3218
+ if (!facets || TELESCUP_FACET_CACHE_MS <= 0) return;
3219
+ const key = getFacetCacheKey(config);
3220
+ const payload = { ts: Date.now(), facets };
3221
+ TELESCUP_TABLE_FACETS_CACHE.set(key, payload);
3222
+ if (!canUseLocalStorage()) return;
3223
+ try {
3224
+ window.localStorage.setItem(key, JSON.stringify(payload));
3225
+ } catch (e) {
3226
+ }
3227
+ };
3185
3228
  var isUuid2 = (value) => {
3186
3229
  if (!value) return false;
3187
3230
  return UUID_REGEX2.test(value.trim());
@@ -3252,12 +3295,12 @@ var rpcPreferredSchema = TELESCUP_RPC_SCHEMA;
3252
3295
  var RPC_MISSING_SCHEMAS_BY_PATH = /* @__PURE__ */ new Map();
3253
3296
  var FUNCTION_NOT_FOUND_CACHE = /* @__PURE__ */ new Set();
3254
3297
  var buildRestHeaders = (token, options) => {
3255
- var _a72;
3298
+ var _a74;
3256
3299
  const headers = {};
3257
3300
  if (SUPABASE_ANON_KEY) {
3258
3301
  headers.apikey = SUPABASE_ANON_KEY;
3259
3302
  }
3260
- const authorizationToken = (_a72 = resolveRpcAuthorizationToken(token)) != null ? _a72 : token;
3303
+ const authorizationToken = (_a74 = resolveRpcAuthorizationToken(token)) != null ? _a74 : token;
3261
3304
  if (authorizationToken) {
3262
3305
  headers.Authorization = `Bearer ${authorizationToken}`;
3263
3306
  }
@@ -3392,22 +3435,22 @@ var parseAssetSize = (value) => {
3392
3435
  return Number.isFinite(parsed) ? parsed : void 0;
3393
3436
  };
3394
3437
  var getFileExtension = (filename) => {
3395
- var _a72;
3438
+ var _a74;
3396
3439
  if (!filename) return void 0;
3397
3440
  const parts = filename.split(".");
3398
3441
  if (parts.length < 2) return void 0;
3399
- const candidate = (_a72 = parts[parts.length - 1]) == null ? void 0 : _a72.trim().toLowerCase();
3442
+ const candidate = (_a74 = parts[parts.length - 1]) == null ? void 0 : _a74.trim().toLowerCase();
3400
3443
  return candidate || void 0;
3401
3444
  };
3402
3445
  var resolveCategory = (row, activeMeta) => {
3403
- var _a72;
3404
- return (_a72 = readString(row.category)) != null ? _a72 : readString(activeMeta.category);
3446
+ var _a74;
3447
+ return (_a74 = readString(row.category)) != null ? _a74 : readString(activeMeta.category);
3405
3448
  };
3406
3449
  var resolveFolderName = (row) => readString(row.folder_name);
3407
3450
  var toTelescupAsset = (row, selectedLanguage) => {
3408
- var _a72, _b6, _c, _d, _e;
3451
+ var _a74, _b7, _c, _d, _e;
3409
3452
  const metaByLang = normalizeMetaByLanguage(row.meta);
3410
- const activeMeta = (_b6 = (_a72 = metaByLang[selectedLanguage]) != null ? _a72 : metaByLang.pt) != null ? _b6 : {};
3453
+ const activeMeta = (_b7 = (_a74 = metaByLang[selectedLanguage]) != null ? _a74 : metaByLang.pt) != null ? _b7 : {};
3411
3454
  return {
3412
3455
  id: (_c = row.id) != null ? _c : "",
3413
3456
  name: row.filename,
@@ -3433,14 +3476,14 @@ var buildFacetsFromItems = (items) => {
3433
3476
  const extensions = /* @__PURE__ */ new Map();
3434
3477
  const tags = /* @__PURE__ */ new Map();
3435
3478
  items.forEach((item) => {
3436
- var _a72, _b6, _c, _d, _e, _f, _g;
3479
+ var _a74, _b7, _c, _d, _e, _f, _g;
3437
3480
  if (item.category) {
3438
- categories.set(item.category, ((_a72 = categories.get(item.category)) != null ? _a72 : 0) + 1);
3481
+ categories.set(item.category, ((_a74 = categories.get(item.category)) != null ? _a74 : 0) + 1);
3439
3482
  }
3440
3483
  if (item.folderId) {
3441
3484
  const current = folders.get(item.folderId);
3442
3485
  folders.set(item.folderId, {
3443
- label: (_b6 = item.folderName) != null ? _b6 : current == null ? void 0 : current.label,
3486
+ label: (_b7 = item.folderName) != null ? _b7 : current == null ? void 0 : current.label,
3444
3487
  count: ((_c = current == null ? void 0 : current.count) != null ? _c : 0) + 1
3445
3488
  });
3446
3489
  }
@@ -3451,16 +3494,16 @@ var buildFacetsFromItems = (items) => {
3451
3494
  extensions.set(item.extension, ((_e = extensions.get(item.extension)) != null ? _e : 0) + 1);
3452
3495
  }
3453
3496
  (_g = (_f = item.meta) == null ? void 0 : _f.tags) == null ? void 0 : _g.forEach((tag) => {
3454
- var _a73;
3497
+ var _a75;
3455
3498
  const normalizedTag = tag.trim();
3456
3499
  if (!normalizedTag) return;
3457
- tags.set(normalizedTag, ((_a73 = tags.get(normalizedTag)) != null ? _a73 : 0) + 1);
3500
+ tags.set(normalizedTag, ((_a75 = tags.get(normalizedTag)) != null ? _a75 : 0) + 1);
3458
3501
  });
3459
3502
  });
3460
3503
  const toFacetValues = (map) => Array.from(map.entries()).map(([value, count2]) => ({ value, count: count2 })).sort((a, b) => a.value.localeCompare(b.value));
3461
3504
  const toFolderFacetValues = (map) => Array.from(map.entries()).map(([value, info]) => ({ value, label: info.label, count: info.count })).sort((a, b) => {
3462
- var _a72, _b6;
3463
- return ((_a72 = a.label) != null ? _a72 : a.value).localeCompare((_b6 = b.label) != null ? _b6 : b.value);
3505
+ var _a74, _b7;
3506
+ return ((_a74 = a.label) != null ? _a74 : a.value).localeCompare((_b7 = b.label) != null ? _b7 : b.value);
3464
3507
  });
3465
3508
  return {
3466
3509
  categories: toFacetValues(categories),
@@ -3478,7 +3521,7 @@ var isManagerScopeRetryable = (error) => {
3478
3521
  return /permission|not allowed|wrong key type|insufficient|unauthorized/i.test(detailsText);
3479
3522
  };
3480
3523
  async function listAssetsViaRpc(config, filters) {
3481
- var _a72, _b6, _c, _d, _e, _f, _g, _h, _i;
3524
+ var _a74, _b7, _c, _d, _e, _f, _g, _h, _i;
3482
3525
  if (!SUPABASE_ANON_KEY) {
3483
3526
  throw new TelescupClientError(
3484
3527
  "VITE_SUPABASE_ANON_KEY (ou VITE_SUPABASE_PUBLISHABLE_KEY) n\xE3o encontrado para fallback RPC do Telescup."
@@ -3496,13 +3539,12 @@ async function listAssetsViaRpc(config, filters) {
3496
3539
  "N\xE3o foi poss\xEDvel identificar o UUID do usu\xE1rio no token para listar assets do Telescup."
3497
3540
  );
3498
3541
  }
3499
- const shouldLoadFacetTables = isSupabaseAccessToken(token);
3500
3542
  const pageSize = Math.min(100, Math.max(1, toPositiveInt(filters.pageSize, 24)));
3501
- const page = toPositiveInt((_a72 = filters.cursor) != null ? _a72 : filters.page, 1);
3543
+ const page = toPositiveInt((_a74 = filters.cursor) != null ? _a74 : filters.page, 1);
3502
3544
  const selectedLanguage = normalizeLanguageKey(filters.language);
3503
3545
  const bodyBase = {
3504
3546
  p_user_id: userId,
3505
- p_query: (_b6 = filters.query) != null ? _b6 : null,
3547
+ p_query: (_b7 = filters.query) != null ? _b7 : null,
3506
3548
  p_page: page,
3507
3549
  p_page_size: pageSize,
3508
3550
  p_type: filters.type && filters.type !== "all" ? filters.type : null,
@@ -3515,7 +3557,7 @@ async function listAssetsViaRpc(config, filters) {
3515
3557
  p_sort_by: normalizeSortBy(filters.sort),
3516
3558
  p_sort_dir: filters.order === "asc" ? "asc" : "desc"
3517
3559
  };
3518
- const managerCandidates = TELESCUP_MANAGER_FIRST ? [true, false] : [false, true];
3560
+ const managerCandidates = TELESCUP_MANAGER_FALLBACK ? TELESCUP_MANAGER_FIRST ? [true, false] : [false, true] : [TELESCUP_MANAGER_FIRST];
3519
3561
  const managerModes = managerCandidates.filter(
3520
3562
  (mode, index, list) => list.findIndex((entry) => entry === mode) === index
3521
3563
  );
@@ -3555,9 +3597,9 @@ async function listAssetsViaRpc(config, filters) {
3555
3597
  const hasMore = page * pageSize < total;
3556
3598
  const itemFacets = buildFacetsFromItems(items);
3557
3599
  let tableFacets;
3558
- if (page === 1 && shouldLoadFacetTables) {
3600
+ if (page === 1) {
3559
3601
  try {
3560
- tableFacets = await loadFacetsFromTelescupTables(config);
3602
+ tableFacets = await loadFacetsFromTelescupTablesCached(config);
3561
3603
  } catch (e) {
3562
3604
  tableFacets = void 0;
3563
3605
  }
@@ -3598,13 +3640,13 @@ var getRpcSchemaCandidates = (rpcPath) => {
3598
3640
  return filtered.length ? filtered : ordered;
3599
3641
  };
3600
3642
  var markRpcSchemaMissing = (rpcPath, schema) => {
3601
- var _a72;
3602
- const set = (_a72 = RPC_MISSING_SCHEMAS_BY_PATH.get(rpcPath)) != null ? _a72 : /* @__PURE__ */ new Set();
3643
+ var _a74;
3644
+ const set = (_a74 = RPC_MISSING_SCHEMAS_BY_PATH.get(rpcPath)) != null ? _a74 : /* @__PURE__ */ new Set();
3603
3645
  set.add(schema);
3604
3646
  RPC_MISSING_SCHEMAS_BY_PATH.set(rpcPath, set);
3605
3647
  };
3606
3648
  async function requestRpc(config, rpcPath, payload) {
3607
- var _a72, _b6;
3649
+ var _a74, _b7;
3608
3650
  if (!SUPABASE_ANON_KEY) {
3609
3651
  throw new TelescupClientError(
3610
3652
  "VITE_SUPABASE_ANON_KEY (ou VITE_SUPABASE_PUBLISHABLE_KEY) n\xE3o encontrado para fallback RPC do Telescup."
@@ -3647,7 +3689,7 @@ async function requestRpc(config, rpcPath, payload) {
3647
3689
  throw new TelescupClientError(`Falha de rede ao chamar RPC ${rpcPath}.`, { details: error });
3648
3690
  }
3649
3691
  if (response.ok) {
3650
- const contentType = (_a72 = response.headers.get("content-type")) != null ? _a72 : "";
3692
+ const contentType = (_a74 = response.headers.get("content-type")) != null ? _a74 : "";
3651
3693
  if (!contentType.includes("application/json")) {
3652
3694
  const text = await response.text();
3653
3695
  if (!text) return {};
@@ -3669,7 +3711,7 @@ async function requestRpc(config, rpcPath, payload) {
3669
3711
  responsePayload = await response.text();
3670
3712
  }
3671
3713
  const payloadObject = responsePayload != null ? responsePayload : {};
3672
- const message = typeof responsePayload === "string" ? responsePayload : (_b6 = payloadObject.message) != null ? _b6 : `Erro ao chamar RPC ${schema}.${rpcPath} (${response.status}).`;
3714
+ const message = typeof responsePayload === "string" ? responsePayload : (_b7 = payloadObject.message) != null ? _b7 : `Erro ao chamar RPC ${schema}.${rpcPath} (${response.status}).`;
3673
3715
  const rpcError = new TelescupClientError(message, {
3674
3716
  status: response.status,
3675
3717
  code: payloadObject.code,
@@ -3699,7 +3741,7 @@ async function requestRpc(config, rpcPath, payload) {
3699
3741
  throw new TelescupClientError(`Falha ao chamar RPC ${rpcPath}.`);
3700
3742
  }
3701
3743
  var toTelescupError = async (response, fallbackMessage) => {
3702
- var _a72;
3744
+ var _a74;
3703
3745
  let payload = void 0;
3704
3746
  try {
3705
3747
  payload = await response.json();
@@ -3707,7 +3749,7 @@ var toTelescupError = async (response, fallbackMessage) => {
3707
3749
  payload = await response.text();
3708
3750
  }
3709
3751
  const payloadObject = payload != null ? payload : {};
3710
- const message = typeof payload === "string" ? payload : (_a72 = payloadObject.message) != null ? _a72 : `${fallbackMessage} (${response.status}).`;
3752
+ const message = typeof payload === "string" ? payload : (_a74 = payloadObject.message) != null ? _a74 : `${fallbackMessage} (${response.status}).`;
3711
3753
  return new TelescupClientError(message, {
3712
3754
  status: response.status,
3713
3755
  code: payloadObject.code,
@@ -3755,11 +3797,11 @@ var mergeFacetEntries = (current, incoming) => {
3755
3797
  const map = /* @__PURE__ */ new Map();
3756
3798
  current == null ? void 0 : current.forEach((entry) => map.set(entry.value, entry));
3757
3799
  incoming == null ? void 0 : incoming.forEach((entry) => {
3758
- var _a72, _b6, _c;
3800
+ var _a74, _b7, _c;
3759
3801
  const previous = map.get(entry.value);
3760
3802
  map.set(entry.value, {
3761
3803
  value: entry.value,
3762
- label: (_b6 = (_a72 = entry.label) != null ? _a72 : previous == null ? void 0 : previous.label) != null ? _b6 : entry.value,
3804
+ label: (_b7 = (_a74 = entry.label) != null ? _a74 : previous == null ? void 0 : previous.label) != null ? _b7 : entry.value,
3763
3805
  count: (_c = entry.count) != null ? _c : previous == null ? void 0 : previous.count
3764
3806
  });
3765
3807
  });
@@ -3779,10 +3821,10 @@ var mergeFacets = (base, incoming) => {
3779
3821
  var toFacetEntriesFromRows = (rows, valueKeys, labelKeys) => {
3780
3822
  const result = /* @__PURE__ */ new Map();
3781
3823
  rows.forEach((row) => {
3782
- var _a72;
3824
+ var _a74;
3783
3825
  const value = readFirstString(row, valueKeys);
3784
3826
  if (!value) return;
3785
- const label = (_a72 = readFirstString(row, labelKeys)) != null ? _a72 : value;
3827
+ const label = (_a74 = readFirstString(row, labelKeys)) != null ? _a74 : value;
3786
3828
  result.set(value, { value, label });
3787
3829
  });
3788
3830
  return Array.from(result.values()).sort((a, b) => a.label.localeCompare(b.label));
@@ -3840,8 +3882,15 @@ async function loadFacetsFromTelescupTables(config) {
3840
3882
  tags: tagEntries
3841
3883
  };
3842
3884
  }
3885
+ async function loadFacetsFromTelescupTablesCached(config) {
3886
+ const cached = readCachedTableFacets(config);
3887
+ if (cached) return cached;
3888
+ const facets = await loadFacetsFromTelescupTables(config);
3889
+ writeCachedTableFacets(config, facets);
3890
+ return facets;
3891
+ }
3843
3892
  async function request(config, path, options = {}) {
3844
- var _a72, _b6, _c;
3893
+ var _a74, _b7, _c;
3845
3894
  const token = await config.getAccessToken();
3846
3895
  if (!token) {
3847
3896
  throw new TelescupClientError("Token de acesso n\xE3o encontrado.");
@@ -3849,7 +3898,7 @@ async function request(config, path, options = {}) {
3849
3898
  const functionsBaseUrl = resolveFunctionsBaseUrl(config.baseUrl);
3850
3899
  const url = joinUrl(functionsBaseUrl, path);
3851
3900
  const isAssetApiRoute = path.startsWith("asset-api/");
3852
- const authorizationToken = isAssetApiRoute ? (_a72 = resolveRpcAuthorizationToken(token)) != null ? _a72 : token : token;
3901
+ const authorizationToken = isAssetApiRoute ? (_a74 = resolveRpcAuthorizationToken(token)) != null ? _a74 : token : token;
3853
3902
  const headers = {
3854
3903
  Authorization: `Bearer ${authorizationToken}`,
3855
3904
  ...options.headers
@@ -3865,7 +3914,7 @@ async function request(config, path, options = {}) {
3865
3914
  let response;
3866
3915
  try {
3867
3916
  response = await fetch(url, {
3868
- method: (_b6 = options.method) != null ? _b6 : "POST",
3917
+ method: (_b7 = options.method) != null ? _b7 : "POST",
3869
3918
  headers,
3870
3919
  body
3871
3920
  });
@@ -3899,11 +3948,11 @@ var normalizeFunctionLanguage = (value) => {
3899
3948
  return normalized;
3900
3949
  };
3901
3950
  var toFunctionListPayload = (filters) => {
3902
- var _a72, _b6, _c, _d, _e, _f;
3903
- const page = toPositiveInt((_a72 = filters.cursor) != null ? _a72 : filters.page, 1);
3951
+ var _a74, _b7, _c, _d, _e, _f;
3952
+ const page = toPositiveInt((_a74 = filters.cursor) != null ? _a74 : filters.page, 1);
3904
3953
  const pageSize = Math.min(500, Math.max(1, toPositiveInt(filters.pageSize, 24)));
3905
3954
  return {
3906
- query: (_b6 = filters.query) != null ? _b6 : "",
3955
+ query: (_b7 = filters.query) != null ? _b7 : "",
3907
3956
  page,
3908
3957
  pageSize,
3909
3958
  sort: `${normalizeSortBy(filters.sort)}:${filters.order === "asc" ? "asc" : "desc"}`,
@@ -3938,9 +3987,10 @@ var toFolderPath = (value) => {
3938
3987
  return normalized.slice(0, lastSlash);
3939
3988
  };
3940
3989
  var normalizeFilterText = (value) => {
3941
- var _a72;
3942
- return (_a72 = value == null ? void 0 : value.trim().toLowerCase()) != null ? _a72 : "";
3990
+ var _a74;
3991
+ return (_a74 = value == null ? void 0 : value.trim().toLowerCase()) != null ? _a74 : "";
3943
3992
  };
3993
+ var hasActiveFacetFilter = (filters) => Boolean(filters.type && filters.type !== "all") || Boolean(filters.extension) || Boolean(filters.category) || Boolean(filters.folderId) || Boolean(filters.usage) || filters.hasAlt === true;
3944
3994
  var normalizeExtensionFilter = (value) => {
3945
3995
  const normalized = normalizeFilterText(value);
3946
3996
  return normalized.startsWith(".") ? normalized.slice(1) : normalized;
@@ -3953,16 +4003,16 @@ var normalizeFolderFilter = (value) => {
3953
4003
  var sortAssets = (items, sort, order) => {
3954
4004
  const direction = order === "asc" ? 1 : -1;
3955
4005
  const byName = (a, b) => {
3956
- var _a72, _b6, _c, _d;
3957
- return ((_b6 = (_a72 = a.fileName) != null ? _a72 : a.name) != null ? _b6 : "").localeCompare((_d = (_c = b.fileName) != null ? _c : b.name) != null ? _d : "");
4006
+ var _a74, _b7, _c, _d;
4007
+ return ((_b7 = (_a74 = a.fileName) != null ? _a74 : a.name) != null ? _b7 : "").localeCompare((_d = (_c = b.fileName) != null ? _c : b.name) != null ? _d : "");
3958
4008
  };
3959
4009
  const byDate = (a, b, key) => {
3960
- var _a72, _b6;
3961
- return (Date.parse((_a72 = a[key]) != null ? _a72 : "") || 0) - (Date.parse((_b6 = b[key]) != null ? _b6 : "") || 0);
4010
+ var _a74, _b7;
4011
+ return (Date.parse((_a74 = a[key]) != null ? _a74 : "") || 0) - (Date.parse((_b7 = b[key]) != null ? _b7 : "") || 0);
3962
4012
  };
3963
4013
  const bySize = (a, b) => {
3964
- var _a72, _b6;
3965
- return ((_a72 = a.size) != null ? _a72 : 0) - ((_b6 = b.size) != null ? _b6 : 0);
4014
+ var _a74, _b7;
4015
+ return ((_a74 = a.size) != null ? _a74 : 0) - ((_b7 = b.size) != null ? _b7 : 0);
3966
4016
  };
3967
4017
  const sorted = [...items];
3968
4018
  sorted.sort((a, b) => {
@@ -3997,7 +4047,7 @@ var applyAssetApiSearchFilters = (items, filters) => {
3997
4047
  const folderFilter = normalizeFolderFilter(filters.folderId);
3998
4048
  const requireAlt = filters.hasAlt === true;
3999
4049
  return items.filter((asset) => {
4000
- var _a72, _b6, _c, _d, _e, _f, _g, _h, _i;
4050
+ var _a74, _b7, _c, _d, _e, _f, _g, _h, _i;
4001
4051
  const haystack = [
4002
4052
  asset.id,
4003
4053
  asset.name,
@@ -4006,8 +4056,8 @@ var applyAssetApiSearchFilters = (items, filters) => {
4006
4056
  asset.folderName,
4007
4057
  asset.category,
4008
4058
  asset.usage,
4009
- (_a72 = asset.meta) == null ? void 0 : _a72.title,
4010
- (_b6 = asset.meta) == null ? void 0 : _b6.description,
4059
+ (_a74 = asset.meta) == null ? void 0 : _a74.title,
4060
+ (_b7 = asset.meta) == null ? void 0 : _b7.description,
4011
4061
  (_c = asset.meta) == null ? void 0 : _c.alt,
4012
4062
  ...Array.isArray((_d = asset.meta) == null ? void 0 : _d.tags) ? asset.meta.tags : []
4013
4063
  ].filter((value) => typeof value === "string" && value.trim() !== "").join(" ").toLowerCase();
@@ -4026,15 +4076,15 @@ var applyAssetApiSearchFilters = (items, filters) => {
4026
4076
  });
4027
4077
  };
4028
4078
  var mapAssetApiSearchRowToAsset = (row) => {
4029
- var _a72, _b6, _c, _d;
4079
+ var _a74, _b7, _c, _d;
4030
4080
  const id = readFirstString(row, ["asset_id", "id"]);
4031
4081
  if (!id) return null;
4032
- const fileName = (_a72 = readFirstString(row, ["original_filename", "filename", "title"])) != null ? _a72 : readFirstString(row, ["file_path"]);
4082
+ const fileName = (_a74 = readFirstString(row, ["original_filename", "filename", "title"])) != null ? _a74 : readFirstString(row, ["file_path"]);
4033
4083
  const mimeType = readFirstString(row, ["mime_type", "mime"]);
4034
4084
  const extension = getFileExtension(readFirstString(row, ["file_path", "filename", "original_filename"]));
4035
4085
  const tags = Array.isArray(row.tags) ? row.tags.filter((item) => typeof item === "string") : void 0;
4036
4086
  const categories = readStringArray(row.categories);
4037
- const category = (_b6 = readFirstString(row, ["category"])) != null ? _b6 : categories[0];
4087
+ const category = (_b7 = readFirstString(row, ["category"])) != null ? _b7 : categories[0];
4038
4088
  const alt = readFirstString(row, ["alt_text"]);
4039
4089
  const title = readFirstString(row, ["title"]);
4040
4090
  const description = readFirstString(row, ["description"]);
@@ -4077,14 +4127,14 @@ var mapAssetApiSearchRowToAsset = (row) => {
4077
4127
  };
4078
4128
  };
4079
4129
  async function listAssetsViaAssetApiSearch(config, filters) {
4080
- var _a72, _b6;
4130
+ var _a74, _b7;
4081
4131
  const pageSize = Math.min(500, Math.max(1, toPositiveInt(filters.pageSize, 24)));
4082
- const page = toPositiveInt((_a72 = filters.cursor) != null ? _a72 : filters.page, 1);
4083
- const hasActiveFacetFilter = Boolean(filters.type && filters.type !== "all") || Boolean(filters.extension) || Boolean(filters.category) || Boolean(filters.folderId) || Boolean(filters.usage) || filters.hasAlt === true;
4132
+ const page = toPositiveInt((_a74 = filters.cursor) != null ? _a74 : filters.page, 1);
4133
+ const hasFilter = hasActiveFacetFilter(filters);
4084
4134
  const baseLimit = page * pageSize + 1;
4085
- const seedLimit = hasActiveFacetFilter ? baseLimit : Math.max(baseLimit, TELESCUP_ASSET_API_FACET_SEED_LIMIT);
4135
+ const seedLimit = hasFilter ? baseLimit : Math.max(baseLimit, TELESCUP_ASSET_API_FACET_SEED_LIMIT);
4086
4136
  const limit = Math.min(500, seedLimit);
4087
- const query = ((_b6 = filters.query) != null ? _b6 : "").trim() || TELESCUP_SEARCH_DEFAULT_QUERY;
4137
+ const query = ((_b7 = filters.query) != null ? _b7 : "").trim() || TELESCUP_SEARCH_DEFAULT_QUERY;
4088
4138
  const [pathBase, rawQuery] = TELESCUP_LIST_FUNCTION.split("?");
4089
4139
  const params = new URLSearchParams(rawQuery != null ? rawQuery : "");
4090
4140
  params.set("q", query);
@@ -4100,20 +4150,28 @@ async function listAssetsViaAssetApiSearch(config, filters) {
4100
4150
  const start = (page - 1) * pageSize;
4101
4151
  const pagedItems = sorted.slice(start, start + pageSize);
4102
4152
  const hasMore = sorted.length > start + pageSize;
4153
+ let tableFacets;
4154
+ if (page === 1) {
4155
+ try {
4156
+ tableFacets = await loadFacetsFromTelescupTablesCached(config);
4157
+ } catch (e) {
4158
+ tableFacets = void 0;
4159
+ }
4160
+ }
4103
4161
  return {
4104
4162
  items: pagedItems,
4105
4163
  total: sorted.length,
4106
4164
  nextCursor: hasMore ? String(page + 1) : void 0,
4107
- facets: buildFacetsFromItems(sorted)
4165
+ facets: mergeFacets(buildFacetsFromItems(sorted), tableFacets)
4108
4166
  };
4109
4167
  }
4110
4168
  var mapGenericRowToAsset = (row) => {
4111
- var _a72, _b6;
4112
- const id = (_a72 = readFirstString(row, ["asset_id", "id", "file_id", "uuid"])) != null ? _a72 : typeof row.id === "number" ? String(row.id) : void 0;
4169
+ var _a74, _b7;
4170
+ const id = (_a74 = readFirstString(row, ["asset_id", "id", "file_id", "uuid"])) != null ? _a74 : typeof row.id === "number" ? String(row.id) : void 0;
4113
4171
  if (!id) return null;
4114
4172
  const fileName = readFirstString(row, ["filename", "file_name", "name", "title", "original_name"]);
4115
4173
  const mimeType = readFirstString(row, ["mime", "mime_type", "content_type", "file_mime"]);
4116
- const extension = (_b6 = readFirstString(row, ["extension", "ext"])) != null ? _b6 : getFileExtension(fileName);
4174
+ const extension = (_b7 = readFirstString(row, ["extension", "ext"])) != null ? _b7 : getFileExtension(fileName);
4117
4175
  return {
4118
4176
  id,
4119
4177
  name: fileName,
@@ -4131,16 +4189,16 @@ var mapGenericRowToAsset = (row) => {
4131
4189
  };
4132
4190
  };
4133
4191
  var normalizeListResponseFromFunctions = (response, filters) => {
4134
- var _a72, _b6, _c, _d, _e, _f;
4192
+ var _a74, _b7, _c, _d, _e, _f;
4135
4193
  const payload = response != null ? response : {};
4136
4194
  const itemsRaw = Array.isArray(payload.items) ? payload.items : [];
4137
4195
  const selectedLanguage = normalizeLanguageKey(filters.language);
4138
4196
  const items = itemsRaw.map((row) => {
4139
- var _a73, _b7, _c2;
4197
+ var _a75, _b8, _c2;
4140
4198
  const mapped = mapGenericRowToAsset(row);
4141
4199
  if (!mapped) return null;
4142
4200
  const metaByLang = normalizeMetaByLanguage(row.meta);
4143
- const activeMeta = (_b7 = (_a73 = metaByLang[selectedLanguage]) != null ? _a73 : metaByLang.pt) != null ? _b7 : {};
4201
+ const activeMeta = (_b8 = (_a75 = metaByLang[selectedLanguage]) != null ? _a75 : metaByLang.pt) != null ? _b8 : {};
4144
4202
  const usageFromObject = readUsageContext(row.usage);
4145
4203
  const normalized = {
4146
4204
  ...mapped,
@@ -4152,7 +4210,7 @@ var normalizeListResponseFromFunctions = (response, filters) => {
4152
4210
  };
4153
4211
  return normalized;
4154
4212
  }).filter((item) => item !== null);
4155
- const total = (_c = (_b6 = (_a72 = readNumber(payload.total)) != null ? _a72 : readNumber(payload.totalCount)) != null ? _b6 : readNumber(payload.total_count)) != null ? _c : items.length;
4213
+ const total = (_c = (_b7 = (_a74 = readNumber(payload.total)) != null ? _a74 : readNumber(payload.totalCount)) != null ? _b7 : readNumber(payload.total_count)) != null ? _c : items.length;
4156
4214
  const page = toPositiveInt((_e = (_d = payload.page) != null ? _d : filters.cursor) != null ? _e : filters.page, 1);
4157
4215
  const pageSize = Math.min(100, Math.max(1, toPositiveInt((_f = payload.pageSize) != null ? _f : filters.pageSize, 24)));
4158
4216
  const nextCursor = total > page * pageSize ? String(page + 1) : void 0;
@@ -4172,13 +4230,13 @@ var mapConflictForQueue = (value) => {
4172
4230
  return "conflict";
4173
4231
  };
4174
4232
  var toInitPayloadForFunctions = (payload) => {
4175
- var _a72, _b6;
4233
+ var _a74, _b7;
4176
4234
  return {
4177
4235
  filename: payload.fileName,
4178
4236
  size: payload.size,
4179
4237
  mime: payload.mimeType,
4180
- folder_id: (_a72 = payload.folderId) != null ? _a72 : null,
4181
- overwritePolicy: (_b6 = payload.conflict) != null ? _b6 : "ask",
4238
+ folder_id: (_a74 = payload.folderId) != null ? _a74 : null,
4239
+ overwritePolicy: (_b7 = payload.conflict) != null ? _b7 : "ask",
4182
4240
  fileName: payload.fileName,
4183
4241
  mimeType: payload.mimeType,
4184
4242
  folderId: payload.folderId,
@@ -4186,10 +4244,10 @@ var toInitPayloadForFunctions = (payload) => {
4186
4244
  };
4187
4245
  };
4188
4246
  var normalizeInitResponseFromFunctions = (response) => {
4189
- var _a72, _b6, _c, _d, _e, _f, _g;
4247
+ var _a74, _b7, _c, _d, _e, _f, _g;
4190
4248
  const payload = response != null ? response : {};
4191
- const existingRaw = (_a72 = payload.existingAsset) != null ? _a72 : payload.existing_asset;
4192
- const existingAsset = existingRaw ? (_b6 = mapGenericRowToAsset(existingRaw)) != null ? _b6 : void 0 : void 0;
4249
+ const existingRaw = (_a74 = payload.existingAsset) != null ? _a74 : payload.existing_asset;
4250
+ const existingAsset = existingRaw ? (_b7 = mapGenericRowToAsset(existingRaw)) != null ? _b7 : void 0 : void 0;
4193
4251
  const assetRaw = payload.asset;
4194
4252
  const asset = assetRaw ? (_c = mapGenericRowToAsset(assetRaw)) != null ? _c : void 0 : void 0;
4195
4253
  const conflictSource = (_e = readString(payload.conflict)) != null ? _e : readString((_d = payload.conflict) == null ? void 0 : _d.type);
@@ -4210,12 +4268,12 @@ var normalizeInitResponseFromFunctions = (response) => {
4210
4268
  };
4211
4269
  };
4212
4270
  var toCompletePayloadForFunctions = (payload) => {
4213
- var _a72, _b6, _c;
4271
+ var _a74, _b7, _c;
4214
4272
  return {
4215
4273
  uploadId: payload.uploadId,
4216
- assetDraftId: (_a72 = payload.assetDraftId) != null ? _a72 : payload.assetId,
4274
+ assetDraftId: (_a74 = payload.assetDraftId) != null ? _a74 : payload.assetId,
4217
4275
  storageKey: payload.storageKey,
4218
- finalFilename: (_b6 = payload.finalFilename) != null ? _b6 : payload.fileName,
4276
+ finalFilename: (_b7 = payload.finalFilename) != null ? _b7 : payload.fileName,
4219
4277
  folder_id: (_c = payload.folderId) != null ? _c : null,
4220
4278
  upload_id: payload.uploadId,
4221
4279
  asset_id: payload.assetId,
@@ -4223,21 +4281,21 @@ var toCompletePayloadForFunctions = (payload) => {
4223
4281
  };
4224
4282
  };
4225
4283
  var normalizeCompleteResponseFromFunctions = (response) => {
4226
- var _a72, _b6;
4284
+ var _a74, _b7;
4227
4285
  const payload = response != null ? response : {};
4228
- const assetRaw = (_a72 = payload.asset) != null ? _a72 : payload;
4286
+ const assetRaw = (_a74 = payload.asset) != null ? _a74 : payload;
4229
4287
  const mapped = mapGenericRowToAsset(assetRaw);
4230
4288
  if (mapped) return { asset: mapped };
4231
- const assetId = (_b6 = readFirstString(assetRaw, ["id", "asset_id"])) != null ? _b6 : readFirstString(payload, ["assetId", "asset_id"]);
4289
+ const assetId = (_b7 = readFirstString(assetRaw, ["id", "asset_id"])) != null ? _b7 : readFirstString(payload, ["assetId", "asset_id"]);
4232
4290
  if (!assetId) {
4233
4291
  throw new TelescupClientError("Resposta inv\xE1lida ao finalizar upload no Telescup.");
4234
4292
  }
4235
4293
  return { asset: { id: assetId } };
4236
4294
  };
4237
4295
  var toMetaPayloadForFunctions = (payload) => {
4238
- var _a72, _b6;
4296
+ var _a74, _b7;
4239
4297
  if (TELESCUP_UPDATE_META_FUNCTION === "update-asset-meta") {
4240
- const categories = ((_a72 = payload.meta) == null ? void 0 : _a72.category) ? [payload.meta.category] : [];
4298
+ const categories = ((_a74 = payload.meta) == null ? void 0 : _a74.category) ? [payload.meta.category] : [];
4241
4299
  return {
4242
4300
  asset_id: payload.assetId,
4243
4301
  categories
@@ -4252,7 +4310,7 @@ var toMetaPayloadForFunctions = (payload) => {
4252
4310
  en: {},
4253
4311
  es: {}
4254
4312
  };
4255
- const target = (_b6 = byLanguage[language]) != null ? _b6 : byLanguage.pt;
4313
+ const target = (_b7 = byLanguage[language]) != null ? _b7 : byLanguage.pt;
4256
4314
  if (payload.meta) {
4257
4315
  if (typeof payload.meta.alt === "string") target.alt = payload.meta.alt;
4258
4316
  if (typeof payload.meta.title === "string") target.title = payload.meta.title;
@@ -4275,6 +4333,25 @@ var toMetaPayloadForFunctions = (payload) => {
4275
4333
  };
4276
4334
  var createTelescupClient = (config) => ({
4277
4335
  listAssets: async (filters) => {
4336
+ const fallbackFunctions = Array.from(
4337
+ new Set([TELESCUP_LIST_FUNCTION, "telescup-assets-list"].filter((path) => !path.startsWith("asset-api/search")))
4338
+ );
4339
+ const listAssetsViaFunctions = async (initialError) => {
4340
+ let lastFunctionError = initialError;
4341
+ for (const functionPath of fallbackFunctions) {
4342
+ try {
4343
+ const response = await request(config, functionPath, {
4344
+ method: "POST",
4345
+ body: toFunctionListPayload(filters)
4346
+ });
4347
+ return normalizeListResponseFromFunctions(response, filters);
4348
+ } catch (error) {
4349
+ lastFunctionError = error;
4350
+ }
4351
+ }
4352
+ if (lastFunctionError instanceof Error) throw lastFunctionError;
4353
+ throw new TelescupClientError("N\xE3o foi poss\xEDvel listar assets no Telescup com as fun\xE7\xF5es dispon\xEDveis.");
4354
+ };
4278
4355
  let rpcError = null;
4279
4356
  const shouldTryRpcFirst = TELESCUP_PREFER_RPC && !TELESCUP_LIST_FUNCTION.startsWith("asset-api/search");
4280
4357
  if (shouldTryRpcFirst) {
@@ -4286,33 +4363,17 @@ var createTelescupClient = (config) => ({
4286
4363
  }
4287
4364
  if (TELESCUP_LIST_FUNCTION.startsWith("asset-api/search")) {
4288
4365
  try {
4289
- return await listAssetsViaAssetApiSearch(config, filters);
4366
+ return await listAssetsViaRpc(config, filters);
4290
4367
  } catch (error) {
4291
- const isNotFound = error instanceof TelescupClientError && error.status === 404;
4292
- if (!isNotFound) {
4293
- throw error;
4294
- }
4368
+ rpcError = error;
4295
4369
  }
4296
- }
4297
- const fallbackFunctions = Array.from(
4298
- new Set([TELESCUP_LIST_FUNCTION, "telescup-assets-list"].filter((path) => !path.startsWith("asset-api/search")))
4299
- );
4300
- let lastFunctionError = rpcError;
4301
- for (const functionPath of fallbackFunctions) {
4302
4370
  try {
4303
- const response = await request(config, functionPath, {
4304
- method: "POST",
4305
- body: toFunctionListPayload(filters)
4306
- });
4307
- return normalizeListResponseFromFunctions(response, filters);
4308
- } catch (error) {
4309
- lastFunctionError = error;
4371
+ return await listAssetsViaFunctions(rpcError);
4372
+ } catch (e) {
4373
+ return await listAssetsViaAssetApiSearch(config, filters);
4310
4374
  }
4311
4375
  }
4312
- if (lastFunctionError instanceof Error) {
4313
- throw lastFunctionError;
4314
- }
4315
- throw new TelescupClientError("N\xE3o foi poss\xEDvel listar assets no Telescup com as fun\xE7\xF5es dispon\xEDveis.");
4376
+ return listAssetsViaFunctions(rpcError);
4316
4377
  },
4317
4378
  initUpload: async (payload) => {
4318
4379
  try {
@@ -4348,7 +4409,7 @@ var createTelescupClient = (config) => ({
4348
4409
  body: toMetaPayloadForFunctions(payload)
4349
4410
  }),
4350
4411
  uploadDirect: async (file) => {
4351
- var _a72;
4412
+ var _a74;
4352
4413
  const token = await config.getAccessToken();
4353
4414
  const userId = resolveUserIdFromToken(token);
4354
4415
  if (!userId) {
@@ -4376,7 +4437,7 @@ var createTelescupClient = (config) => ({
4376
4437
  }
4377
4438
  });
4378
4439
  const payload = response != null ? response : {};
4379
- const asset = mapAssetApiSearchRowToAsset((_a72 = payload.asset) != null ? _a72 : {});
4440
+ const asset = mapAssetApiSearchRowToAsset((_a74 = payload.asset) != null ? _a74 : {});
4380
4441
  if (!asset) {
4381
4442
  throw new TelescupClientError("Resposta inv\xE1lida do upload direto (asset-api).");
4382
4443
  }
@@ -4392,9 +4453,52 @@ import React21, { useCallback as useCallback2, useMemo as useMemo3, useState as
4392
4453
 
4393
4454
  // src/hooks/useTelescupAssets.ts
4394
4455
  import { useCallback, useEffect as useEffect11, useMemo as useMemo2, useRef as useRef8, useState as useState6 } from "react";
4395
- var DEFAULT_CACHE_MS = 3e4;
4456
+ var mergeFacetValues = (current, incoming) => {
4457
+ if (!current && !incoming) return void 0;
4458
+ const map = /* @__PURE__ */ new Map();
4459
+ current == null ? void 0 : current.forEach((entry) => map.set(entry.value, entry));
4460
+ incoming == null ? void 0 : incoming.forEach((entry) => {
4461
+ var _a74, _b7, _c;
4462
+ const previous = map.get(entry.value);
4463
+ map.set(entry.value, {
4464
+ value: entry.value,
4465
+ label: (_b7 = (_a74 = entry.label) != null ? _a74 : previous == null ? void 0 : previous.label) != null ? _b7 : entry.value,
4466
+ count: (_c = entry.count) != null ? _c : previous == null ? void 0 : previous.count
4467
+ });
4468
+ });
4469
+ return Array.from(map.values()).sort((a, b) => {
4470
+ var _a74, _b7;
4471
+ return ((_a74 = a.label) != null ? _a74 : a.value).localeCompare((_b7 = b.label) != null ? _b7 : b.value);
4472
+ });
4473
+ };
4474
+ var DEFAULT_CACHE_MS = 3e5;
4396
4475
  var listCache = /* @__PURE__ */ new Map();
4397
4476
  var inFlight = /* @__PURE__ */ new Map();
4477
+ var LIST_CACHE_STORAGE_PREFIX = "telescup:list:v1";
4478
+ var canUseLocalStorage2 = () => typeof window !== "undefined" && typeof window.localStorage !== "undefined";
4479
+ var readPersistentCache = (key, cacheTimeMs) => {
4480
+ if (!canUseLocalStorage2() || cacheTimeMs <= 0) return void 0;
4481
+ try {
4482
+ const raw = window.localStorage.getItem(`${LIST_CACHE_STORAGE_PREFIX}:${key}`);
4483
+ if (!raw) return void 0;
4484
+ const parsed = JSON.parse(raw);
4485
+ if (!parsed || typeof parsed.ts !== "number" || !parsed.data) return void 0;
4486
+ if (Date.now() - parsed.ts >= cacheTimeMs) return void 0;
4487
+ return parsed.data;
4488
+ } catch (e) {
4489
+ return void 0;
4490
+ }
4491
+ };
4492
+ var writePersistentCache = (key, data) => {
4493
+ if (!canUseLocalStorage2()) return;
4494
+ try {
4495
+ window.localStorage.setItem(
4496
+ `${LIST_CACHE_STORAGE_PREFIX}:${key}`,
4497
+ JSON.stringify({ ts: Date.now(), data })
4498
+ );
4499
+ } catch (e) {
4500
+ }
4501
+ };
4398
4502
  var sanitizeFilters = (filters) => {
4399
4503
  if (!filters) return {};
4400
4504
  const { cursor, ...rest } = filters;
@@ -4442,15 +4546,25 @@ function useTelescupAssets(options) {
4442
4546
  setIsLoading(false);
4443
4547
  return;
4444
4548
  }
4549
+ if (!skipCache) {
4550
+ const persisted = readPersistentCache(cacheKey, cacheTimeMs);
4551
+ if (persisted) {
4552
+ if (requestSeq !== requestSeqRef.current || !aliveRef.current) return;
4553
+ setState(persisted);
4554
+ listCache.set(cacheKey, { data: persisted, ts: Date.now() });
4555
+ setIsLoading(false);
4556
+ return;
4557
+ }
4558
+ }
4445
4559
  let promise = inFlight.get(cacheKey);
4446
4560
  if (!promise) {
4447
4561
  promise = resolvedClient.listAssets({
4448
4562
  ...sanitizeFilters(filters),
4449
4563
  pageSize
4450
4564
  }).then((data) => {
4451
- var _a72;
4565
+ var _a74;
4452
4566
  return {
4453
- items: (_a72 = data.items) != null ? _a72 : [],
4567
+ items: (_a74 = data.items) != null ? _a74 : [],
4454
4568
  nextCursor: data.nextCursor,
4455
4569
  total: data.total,
4456
4570
  facets: data.facets
@@ -4463,6 +4577,7 @@ function useTelescupAssets(options) {
4463
4577
  if (!aliveRef.current || requestSeq !== requestSeqRef.current) return;
4464
4578
  setState(data);
4465
4579
  listCache.set(cacheKey, { data, ts: Date.now() });
4580
+ writePersistentCache(cacheKey, data);
4466
4581
  } catch (err) {
4467
4582
  if (!aliveRef.current || requestSeq !== requestSeqRef.current) return;
4468
4583
  setError(err);
@@ -4473,7 +4588,7 @@ function useTelescupAssets(options) {
4473
4588
  [cacheKey, cacheTimeMs, enabled, filters, pageSize, resolvedClient]
4474
4589
  );
4475
4590
  const loadMore = useCallback(async () => {
4476
- var _a72, _b6, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
4591
+ var _a74, _b7, _c, _d, _e, _f, _g;
4477
4592
  if (!state.nextCursor || isLoadingMore || isLoading) return;
4478
4593
  const requestSeq = requestSeqRef.current;
4479
4594
  setIsLoadingMore(true);
@@ -4487,19 +4602,20 @@ function useTelescupAssets(options) {
4487
4602
  });
4488
4603
  if (!aliveRef.current || requestSeq !== requestSeqRef.current) return;
4489
4604
  const merged = {
4490
- items: [...state.items, ...(_a72 = data.items) != null ? _a72 : []],
4605
+ items: [...state.items, ...(_a74 = data.items) != null ? _a74 : []],
4491
4606
  nextCursor: data.nextCursor,
4492
- total: (_b6 = data.total) != null ? _b6 : state.total,
4607
+ total: (_b7 = data.total) != null ? _b7 : state.total,
4493
4608
  facets: {
4494
- categories: (_d = (_c = data.facets) == null ? void 0 : _c.categories) != null ? _d : previousFacets == null ? void 0 : previousFacets.categories,
4495
- folders: (_f = (_e = data.facets) == null ? void 0 : _e.folders) != null ? _f : previousFacets == null ? void 0 : previousFacets.folders,
4496
- usages: (_h = (_g = data.facets) == null ? void 0 : _g.usages) != null ? _h : previousFacets == null ? void 0 : previousFacets.usages,
4497
- extensions: (_j = (_i = data.facets) == null ? void 0 : _i.extensions) != null ? _j : previousFacets == null ? void 0 : previousFacets.extensions,
4498
- tags: (_l = (_k = data.facets) == null ? void 0 : _k.tags) != null ? _l : previousFacets == null ? void 0 : previousFacets.tags
4609
+ categories: mergeFacetValues(previousFacets == null ? void 0 : previousFacets.categories, (_c = data.facets) == null ? void 0 : _c.categories),
4610
+ folders: mergeFacetValues(previousFacets == null ? void 0 : previousFacets.folders, (_d = data.facets) == null ? void 0 : _d.folders),
4611
+ usages: mergeFacetValues(previousFacets == null ? void 0 : previousFacets.usages, (_e = data.facets) == null ? void 0 : _e.usages),
4612
+ extensions: mergeFacetValues(previousFacets == null ? void 0 : previousFacets.extensions, (_f = data.facets) == null ? void 0 : _f.extensions),
4613
+ tags: mergeFacetValues(previousFacets == null ? void 0 : previousFacets.tags, (_g = data.facets) == null ? void 0 : _g.tags)
4499
4614
  }
4500
4615
  };
4501
4616
  setState(merged);
4502
4617
  listCache.set(cacheKey, { data: merged, ts: Date.now() });
4618
+ writePersistentCache(cacheKey, merged);
4503
4619
  } catch (err) {
4504
4620
  if (aliveRef.current && requestSeq === requestSeqRef.current) setError(err);
4505
4621
  } finally {
@@ -4609,11 +4725,21 @@ function Skeleton2({ className, ...props }) {
4609
4725
  import * as React20 from "react";
4610
4726
  import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area";
4611
4727
  import { jsx as jsx34, jsxs as jsxs22 } from "react/jsx-runtime";
4612
- var ScrollArea = React20.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs22(ScrollAreaPrimitive.Root, { ref, className: cn("relative overflow-hidden", className), ...props, children: [
4613
- /* @__PURE__ */ jsx34(ScrollAreaPrimitive.Viewport, { className: "h-full w-full rounded-[inherit]", children }),
4614
- /* @__PURE__ */ jsx34(ScrollBar, {}),
4615
- /* @__PURE__ */ jsx34(ScrollAreaPrimitive.Corner, {})
4616
- ] }));
4728
+ var ScrollArea = React20.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs22(
4729
+ ScrollAreaPrimitive.Root,
4730
+ {
4731
+ ref,
4732
+ type: "always",
4733
+ scrollHideDelay: 0,
4734
+ className: cn("relative overflow-hidden", className),
4735
+ ...props,
4736
+ children: [
4737
+ /* @__PURE__ */ jsx34(ScrollAreaPrimitive.Viewport, { className: "h-full w-full rounded-[inherit]", children }),
4738
+ /* @__PURE__ */ jsx34(ScrollBar, {}),
4739
+ /* @__PURE__ */ jsx34(ScrollAreaPrimitive.Corner, {})
4740
+ ]
4741
+ }
4742
+ ));
4617
4743
  ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
4618
4744
  var ScrollBar = React20.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ jsx34(
4619
4745
  ScrollAreaPrimitive.ScrollAreaScrollbar,
@@ -4622,28 +4748,29 @@ var ScrollBar = React20.forwardRef(({ className, orientation = "vertical", ...pr
4622
4748
  orientation,
4623
4749
  className: cn(
4624
4750
  "flex touch-none select-none transition-colors",
4625
- orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent p-[1px]",
4626
- orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent p-[1px]",
4751
+ orientation === "vertical" && "h-full w-3 border-l border-l-border/30 bg-background/30 p-[2px] dark:border-l-white/15 dark:bg-black/20",
4752
+ orientation === "horizontal" && "h-3 flex-col border-t border-t-border/30 bg-background/30 p-[2px] dark:border-t-white/15 dark:bg-black/20",
4627
4753
  className
4628
4754
  ),
4629
4755
  ...props,
4630
- children: /* @__PURE__ */ jsx34(ScrollAreaPrimitive.ScrollAreaThumb, { className: "relative flex-1 rounded-full bg-border" })
4756
+ children: /* @__PURE__ */ jsx34(ScrollAreaPrimitive.ScrollAreaThumb, { className: "relative flex-1 rounded-full bg-foreground/45 dark:bg-white/50" })
4631
4757
  }
4632
4758
  ));
4633
4759
  ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
4634
4760
 
4635
4761
  // src/components/cupcode/TelescupAssetPicker.tsx
4762
+ import { Expand } from "lucide-react";
4636
4763
  import { jsx as jsx35, jsxs as jsxs23 } from "react/jsx-runtime";
4637
4764
  var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "webp", "avif", "svg", "bmp", "ico", "tif", "tiff"]);
4638
4765
  var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set(["mp4", "mov", "webm", "mkv", "avi", "m4v", "wmv"]);
4639
4766
  var AUDIO_EXTENSIONS = /* @__PURE__ */ new Set(["mp3", "wav", "aac", "ogg", "flac", "m4a"]);
4640
4767
  var resolveAssetFamily = (asset) => {
4641
- var _a72, _b6, _c;
4642
- const explicitType = (_a72 = asset.type) == null ? void 0 : _a72.toLowerCase();
4768
+ var _a74, _b7, _c;
4769
+ const explicitType = (_a74 = asset.type) == null ? void 0 : _a74.toLowerCase();
4643
4770
  if (explicitType === "image" || explicitType === "video" || explicitType === "audio" || explicitType === "file") {
4644
4771
  return explicitType;
4645
4772
  }
4646
- const mime = (_b6 = asset.mimeType) == null ? void 0 : _b6.toLowerCase();
4773
+ const mime = (_b7 = asset.mimeType) == null ? void 0 : _b7.toLowerCase();
4647
4774
  if (mime == null ? void 0 : mime.startsWith("image/")) return "image";
4648
4775
  if (mime == null ? void 0 : mime.startsWith("video/")) return "video";
4649
4776
  if (mime == null ? void 0 : mime.startsWith("audio/")) return "audio";
@@ -4655,9 +4782,9 @@ var resolveAssetFamily = (asset) => {
4655
4782
  return "file";
4656
4783
  };
4657
4784
  var matchesAllowedAsset = (asset, allowed) => {
4658
- var _a72, _b6, _c, _d;
4785
+ var _a74, _b7, _c, _d;
4659
4786
  if (!allowed || allowed.length === 0) return true;
4660
- const mime = (_b6 = (_a72 = asset.mimeType) == null ? void 0 : _a72.toLowerCase()) != null ? _b6 : "";
4787
+ const mime = (_b7 = (_a74 = asset.mimeType) == null ? void 0 : _a74.toLowerCase()) != null ? _b7 : "";
4661
4788
  const ext = asset.extension ? `.${asset.extension.toLowerCase()}` : "";
4662
4789
  const type = (_d = (_c = asset.type) == null ? void 0 : _c.toLowerCase()) != null ? _d : "";
4663
4790
  const family = resolveAssetFamily(asset);
@@ -4677,7 +4804,7 @@ var matchesAllowedAsset = (asset, allowed) => {
4677
4804
  return type === normalizedRule || family === normalizedRule;
4678
4805
  });
4679
4806
  };
4680
- var getPreview = (asset) => {
4807
+ var getPreview = (asset, className = "h-full w-full rounded-lg object-contain") => {
4681
4808
  if (resolveAssetFamily(asset) === "video") {
4682
4809
  return /* @__PURE__ */ jsx35(
4683
4810
  TelescupVideo,
@@ -4685,7 +4812,7 @@ var getPreview = (asset) => {
4685
4812
  apiId: asset.id,
4686
4813
  muted: true,
4687
4814
  playsInline: true,
4688
- className: "h-full w-full rounded-lg object-cover"
4815
+ className
4689
4816
  }
4690
4817
  );
4691
4818
  }
@@ -4696,35 +4823,101 @@ var getPreview = (asset) => {
4696
4823
  imageWidth: 200,
4697
4824
  imageHeight: 200,
4698
4825
  alt: asset.name || asset.fileName || asset.id,
4699
- className: "h-full w-full rounded-lg object-cover"
4826
+ className
4700
4827
  }
4701
4828
  );
4702
4829
  };
4830
+ var toMediaLabel = (asset) => {
4831
+ const family = resolveAssetFamily(asset);
4832
+ if (family === "image") return "imagem";
4833
+ if (family === "video") return "video";
4834
+ if (family === "audio") return "audio";
4835
+ if (family === "file") return "arquivo";
4836
+ return void 0;
4837
+ };
4838
+ var UUID_REGEX3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
4839
+ var ROOT_FOLDERS_TO_HIDE = /* @__PURE__ */ new Set(["images", "videos"]);
4840
+ var normalizeFolderToken = (value) => value.trim().replace(/^\/+|\/+$/g, "").toLowerCase();
4841
+ var getLeafName = (value) => {
4842
+ var _a74;
4843
+ const normalized = normalizeFolderToken(value);
4844
+ const parts = normalized.split("/").filter(Boolean);
4845
+ return (_a74 = parts[parts.length - 1]) != null ? _a74 : normalized;
4846
+ };
4847
+ var scoreFolderValue = (value, label) => {
4848
+ const normalizedValue = normalizeFolderToken(value);
4849
+ const normalizedLabel = normalizeFolderToken(label);
4850
+ let score = 0;
4851
+ if (normalizedValue === normalizedLabel) score += 40;
4852
+ if (normalizedValue.includes("/")) score += 20;
4853
+ if (!UUID_REGEX3.test(normalizedValue)) score += 10;
4854
+ score -= Math.max(0, normalizedValue.length - 24) * 0.01;
4855
+ return score;
4856
+ };
4703
4857
  var normalizeFacetOptions = (entries) => {
4704
4858
  if (!entries || !entries.length) return [];
4705
- return entries.reduce((acc, entry) => {
4706
- var _a72, _b6;
4707
- const value = (_a72 = entry.value) == null ? void 0 : _a72.trim();
4708
- if (!value) return acc;
4709
- acc.push({
4710
- value,
4711
- label: ((_b6 = entry.label) == null ? void 0 : _b6.trim()) || value,
4712
- count: typeof entry.count === "number" ? entry.count : void 0
4859
+ const byLabel = /* @__PURE__ */ new Map();
4860
+ entries.forEach((entry) => {
4861
+ var _a74, _b7, _c, _d;
4862
+ const value = (_a74 = entry.value) == null ? void 0 : _a74.trim();
4863
+ if (!value) return;
4864
+ const label = ((_b7 = entry.label) == null ? void 0 : _b7.trim()) || value;
4865
+ const key = normalizeFolderToken(label);
4866
+ const incomingCount = typeof entry.count === "number" ? entry.count : 0;
4867
+ const existing = byLabel.get(key);
4868
+ if (!existing) {
4869
+ byLabel.set(key, {
4870
+ value,
4871
+ label,
4872
+ count: incomingCount || void 0,
4873
+ aliases: [value]
4874
+ });
4875
+ return;
4876
+ }
4877
+ const existingScore = scoreFolderValue(existing.value, existing.label);
4878
+ const incomingScore = scoreFolderValue(value, label);
4879
+ const nextValue = incomingScore > existingScore ? value : existing.value;
4880
+ const nextLabel = existing.label.length >= label.length ? existing.label : label;
4881
+ const totalCount = ((_c = existing.count) != null ? _c : 0) + incomingCount;
4882
+ byLabel.set(key, {
4883
+ value: nextValue,
4884
+ label: nextLabel,
4885
+ count: totalCount || void 0,
4886
+ aliases: Array.from(/* @__PURE__ */ new Set([...(_d = existing.aliases) != null ? _d : [existing.value], value]))
4713
4887
  });
4714
- return acc;
4715
- }, []).sort((a, b) => a.label.localeCompare(b.label));
4888
+ });
4889
+ const options = Array.from(byLabel.values());
4890
+ const groups = /* @__PURE__ */ new Map();
4891
+ options.forEach((option) => {
4892
+ var _a74;
4893
+ const leaf = getLeafName(option.label || option.value);
4894
+ const list = (_a74 = groups.get(leaf)) != null ? _a74 : [];
4895
+ list.push(option);
4896
+ groups.set(leaf, list);
4897
+ });
4898
+ const collapsed = options.filter((option) => {
4899
+ var _a74;
4900
+ const leaf = getLeafName(option.label || option.value);
4901
+ const group = (_a74 = groups.get(leaf)) != null ? _a74 : [];
4902
+ const hasPathVariant = group.some((entry) => normalizeFolderToken(entry.label).includes("/"));
4903
+ if (!hasPathVariant) return true;
4904
+ return normalizeFolderToken(option.label).includes("/");
4905
+ });
4906
+ const visible = collapsed.filter((option) => !ROOT_FOLDERS_TO_HIDE.has(normalizeFolderToken(option.label)));
4907
+ return visible.sort((a, b) => a.label.localeCompare(b.label));
4716
4908
  };
4717
4909
  var collectFacetOptions = (items, pick, pickLabel) => {
4718
4910
  const options = /* @__PURE__ */ new Map();
4719
4911
  items.forEach((asset) => {
4720
- var _a72, _b6, _c;
4721
- const value = (_a72 = pick(asset)) == null ? void 0 : _a72.trim();
4912
+ var _a74, _b7, _c, _d;
4913
+ const value = (_a74 = pick(asset)) == null ? void 0 : _a74.trim();
4722
4914
  if (!value) return;
4723
4915
  const current = options.get(value);
4724
4916
  options.set(value, {
4725
4917
  value,
4726
- label: ((_b6 = pickLabel == null ? void 0 : pickLabel(asset)) == null ? void 0 : _b6.trim()) || (current == null ? void 0 : current.label) || value,
4727
- count: ((_c = current == null ? void 0 : current.count) != null ? _c : 0) + 1
4918
+ label: ((_b7 = pickLabel == null ? void 0 : pickLabel(asset)) == null ? void 0 : _b7.trim()) || (current == null ? void 0 : current.label) || value,
4919
+ count: ((_c = current == null ? void 0 : current.count) != null ? _c : 0) + 1,
4920
+ aliases: (_d = current == null ? void 0 : current.aliases) != null ? _d : [value]
4728
4921
  });
4729
4922
  });
4730
4923
  return Array.from(options.values()).sort((a, b) => a.label.localeCompare(b.label));
@@ -4739,24 +4932,26 @@ var TelescupAssetPicker = ({
4739
4932
  labels,
4740
4933
  className,
4741
4934
  enabled = true,
4742
- onAssetsLoaded
4935
+ onAssetsLoaded,
4936
+ onTotalAssetsChange
4743
4937
  }) => {
4744
4938
  const [query, setQuery] = useState7("");
4745
4939
  const [typeFilter, setTypeFilter] = useState7("all");
4746
4940
  const [folderFilter, setFolderFilter] = useState7("all");
4747
- const filters = useMemo3(
4941
+ const [previewAsset, setPreviewAsset] = useState7(null);
4942
+ const baseFilters = useMemo3(
4748
4943
  () => ({
4749
4944
  query: query || void 0,
4750
4945
  // Mantemos type fora da query server-side porque dados legados podem ter kind incorreto.
4751
4946
  // O filtro de tipo (imagem/video) eh aplicado no client por mime/extensao.
4752
4947
  type: void 0,
4753
- folderId: folderFilter === "all" ? folderId || void 0 : folderFilter
4948
+ folderId: folderId || void 0
4754
4949
  }),
4755
- [folderFilter, folderId, query]
4950
+ [folderId, query]
4756
4951
  );
4757
- const { items, facets, isLoading, isLoadingMore, hasMore, loadMore, error } = useTelescupAssets({
4952
+ const { items, total, facets, isLoading, isLoadingMore, hasMore, loadMore, error } = useTelescupAssets({
4758
4953
  client,
4759
- filters,
4954
+ filters: baseFilters,
4760
4955
  enabled,
4761
4956
  pageSize: 500
4762
4957
  });
@@ -4768,23 +4963,41 @@ var TelescupAssetPicker = ({
4768
4963
  (asset) => asset.folderName
4769
4964
  );
4770
4965
  }, [facets == null ? void 0 : facets.folders, items]);
4966
+ const selectedFolderOption = useMemo3(() => {
4967
+ if (folderFilter === "all") return void 0;
4968
+ return folderOptions.find((option) => option.value === folderFilter);
4969
+ }, [folderFilter, folderOptions]);
4771
4970
  const filteredItems = useMemo3(() => {
4971
+ var _a74;
4972
+ const selectedFolderAliases = new Set(
4973
+ ((_a74 = selectedFolderOption == null ? void 0 : selectedFolderOption.aliases) != null ? _a74 : folderFilter === "all" ? [] : [folderFilter]).map(
4974
+ (entry) => normalizeFolderToken(entry)
4975
+ )
4976
+ );
4772
4977
  return items.filter((asset) => {
4978
+ var _a75, _b7;
4773
4979
  if (!matchesAllowedAsset(asset, allowedTypes)) return false;
4774
4980
  if (typeFilter !== "all") {
4775
4981
  const family = resolveAssetFamily(asset);
4776
4982
  if (family !== typeFilter) return false;
4777
4983
  }
4984
+ if (folderFilter !== "all") {
4985
+ const folderIdToken = normalizeFolderToken((_a75 = asset.folderId) != null ? _a75 : "");
4986
+ const folderNameToken = normalizeFolderToken((_b7 = asset.folderName) != null ? _b7 : "");
4987
+ if (!selectedFolderAliases.has(folderIdToken) && !selectedFolderAliases.has(folderNameToken)) {
4988
+ return false;
4989
+ }
4990
+ }
4778
4991
  return true;
4779
4992
  });
4780
- }, [allowedTypes, items, typeFilter]);
4993
+ }, [allowedTypes, folderFilter, items, selectedFolderOption == null ? void 0 : selectedFolderOption.aliases, typeFilter]);
4781
4994
  const handleSelect = useCallback2(
4782
4995
  (asset) => {
4783
4996
  let nextIds = [];
4784
4997
  if (multiple) {
4785
4998
  nextIds = value.includes(asset.id) ? value.filter((id) => id !== asset.id) : [...value, asset.id];
4786
4999
  } else {
4787
- nextIds = [asset.id];
5000
+ nextIds = value.includes(asset.id) ? [] : [asset.id];
4788
5001
  }
4789
5002
  const nextAssets = filteredItems.filter((item) => nextIds.includes(item.id));
4790
5003
  onChange == null ? void 0 : onChange(nextIds, nextAssets);
@@ -4794,6 +5007,9 @@ var TelescupAssetPicker = ({
4794
5007
  React21.useEffect(() => {
4795
5008
  if (filteredItems.length) onAssetsLoaded == null ? void 0 : onAssetsLoaded(filteredItems);
4796
5009
  }, [filteredItems, onAssetsLoaded]);
5010
+ React21.useEffect(() => {
5011
+ onTotalAssetsChange == null ? void 0 : onTotalAssetsChange(total != null ? total : 0);
5012
+ }, [onTotalAssetsChange, total]);
4797
5013
  React21.useEffect(() => {
4798
5014
  if (!enabled) return;
4799
5015
  if (isLoading || isLoadingMore) return;
@@ -4801,17 +5017,18 @@ var TelescupAssetPicker = ({
4801
5017
  void loadMore();
4802
5018
  }, [enabled, hasMore, isLoading, isLoadingMore, loadMore]);
4803
5019
  return /* @__PURE__ */ jsxs23("div", { className: cn("flex flex-col gap-4", className), children: [
4804
- /* @__PURE__ */ jsxs23("div", { className: "grid gap-3 md:grid-cols-4", children: [
4805
- /* @__PURE__ */ jsx35("div", { className: "md:col-span-2", children: /* @__PURE__ */ jsx35(
5020
+ /* @__PURE__ */ jsxs23("div", { className: "grid grid-cols-4 gap-3", children: [
5021
+ /* @__PURE__ */ jsx35("div", { className: "col-span-2", children: /* @__PURE__ */ jsx35(
4806
5022
  Input,
4807
5023
  {
5024
+ className: "border-border/70 bg-background/60 dark:border-white/15",
4808
5025
  value: query,
4809
5026
  onChange: (event) => setQuery(event.target.value),
4810
5027
  placeholder: labels.searchPlaceholder
4811
5028
  }
4812
5029
  ) }),
4813
5030
  /* @__PURE__ */ jsxs23(Select, { value: typeFilter, onValueChange: setTypeFilter, children: [
4814
- /* @__PURE__ */ jsx35(SelectTrigger, { children: /* @__PURE__ */ jsx35(SelectValue, { placeholder: labels.filters.type }) }),
5031
+ /* @__PURE__ */ jsx35(SelectTrigger, { className: "border-border/70 bg-background/60 dark:border-white/15", children: /* @__PURE__ */ jsx35(SelectValue, { placeholder: labels.filters.type }) }),
4815
5032
  /* @__PURE__ */ jsxs23(SelectContent, { children: [
4816
5033
  /* @__PURE__ */ jsx35(SelectItem, { value: "all", children: labels.filters.allTypes }),
4817
5034
  /* @__PURE__ */ jsx35(SelectItem, { value: "image", children: "Imagem" }),
@@ -4819,7 +5036,7 @@ var TelescupAssetPicker = ({
4819
5036
  ] })
4820
5037
  ] }),
4821
5038
  /* @__PURE__ */ jsxs23(Select, { value: folderFilter, onValueChange: setFolderFilter, children: [
4822
- /* @__PURE__ */ jsx35(SelectTrigger, { children: /* @__PURE__ */ jsx35(SelectValue, { placeholder: labels.filters.folder }) }),
5039
+ /* @__PURE__ */ jsx35(SelectTrigger, { className: "border-border/70 bg-background/60 dark:border-white/15", children: /* @__PURE__ */ jsx35(SelectValue, { placeholder: labels.filters.folder }) }),
4823
5040
  /* @__PURE__ */ jsxs23(SelectContent, { children: [
4824
5041
  /* @__PURE__ */ jsx35(SelectItem, { value: "all", children: labels.filters.allTypes }),
4825
5042
  folderOptions.map((option) => /* @__PURE__ */ jsxs23(SelectItem, { value: option.value, children: [
@@ -4830,7 +5047,7 @@ var TelescupAssetPicker = ({
4830
5047
  ] })
4831
5048
  ] }),
4832
5049
  error ? /* @__PURE__ */ jsx35("div", { className: "rounded-lg border border-destructive/30 bg-destructive/10 p-3 text-sm text-destructive", children: error.message }) : null,
4833
- /* @__PURE__ */ jsx35(ScrollArea, { className: "h-[420px] rounded-xl border border-border bg-background/40", children: /* @__PURE__ */ jsx35("div", { className: "h-[420px] overflow-y-auto p-4", children: isLoading ? /* @__PURE__ */ jsx35("div", { className: "grid gap-4 sm:grid-cols-2 lg:grid-cols-3", children: Array.from({ length: 6 }).map((_, idx) => /* @__PURE__ */ jsx35(Skeleton2, { className: "h-40 w-full" }, idx)) }) : filteredItems.length === 0 ? /* @__PURE__ */ jsx35(EmptyState, { title: labels.empty.title, description: labels.empty.description }) : /* @__PURE__ */ jsx35("div", { className: "grid gap-4 sm:grid-cols-2 lg:grid-cols-3", children: filteredItems.map((asset) => {
5050
+ /* @__PURE__ */ jsx35(ScrollArea, { className: "h-[420px] rounded-xl border border-border/70 bg-background/40 dark:border-white/15", children: /* @__PURE__ */ jsx35("div", { className: "p-4", children: isLoading ? /* @__PURE__ */ jsx35("div", { className: "grid grid-cols-2 gap-4 lg:grid-cols-3", children: Array.from({ length: 6 }).map((_, idx) => /* @__PURE__ */ jsx35(Skeleton2, { className: "h-40 w-full" }, idx)) }) : filteredItems.length === 0 ? /* @__PURE__ */ jsx35(EmptyState, { title: labels.empty.title, description: labels.empty.description }) : /* @__PURE__ */ jsx35("div", { className: "grid grid-cols-2 gap-4 lg:grid-cols-3", children: filteredItems.map((asset) => {
4834
5051
  const selected = value.includes(asset.id);
4835
5052
  return /* @__PURE__ */ jsxs23(
4836
5053
  "button",
@@ -4838,32 +5055,43 @@ var TelescupAssetPicker = ({
4838
5055
  type: "button",
4839
5056
  onClick: () => handleSelect(asset),
4840
5057
  className: cn(
4841
- "group flex flex-col gap-3 rounded-xl border p-3 text-left transition",
4842
- selected ? "border-primary bg-primary/10" : "border-border bg-background/60 hover:border-primary/50"
5058
+ "group flex flex-col gap-0 overflow-hidden rounded-xl border p-0 text-left transition dark:border-white/15",
5059
+ selected ? "border-primary bg-primary/10 dark:border-primary/70" : "border-border bg-background/60 hover:border-primary/50 dark:border-white/15 dark:hover:border-white/35"
4843
5060
  ),
4844
5061
  children: [
4845
- /* @__PURE__ */ jsxs23("div", { className: "relative h-32 w-full overflow-hidden rounded-lg bg-muted", children: [
5062
+ /* @__PURE__ */ jsxs23("div", { className: "relative h-40 w-full overflow-hidden rounded-lg bg-muted p-2", children: [
4846
5063
  getPreview(asset),
4847
- selected ? /* @__PURE__ */ jsx35("span", { className: "absolute right-2 top-2 rounded-full bg-primary px-2 py-1 text-xs text-white", children: "Selecionado" }) : null
4848
- ] }),
4849
- /* @__PURE__ */ jsxs23("div", { className: "space-y-1", children: [
4850
- /* @__PURE__ */ jsx35("p", { className: "text-sm font-semibold text-foreground line-clamp-1", children: asset.name || asset.fileName || asset.id }),
4851
- /* @__PURE__ */ jsxs23("div", { className: "flex flex-wrap gap-2 text-xs text-muted-foreground", children: [
4852
- asset.type ? /* @__PURE__ */ jsx35(Badge2, { variant: "secondary", children: asset.type }) : null,
4853
- asset.extension ? /* @__PURE__ */ jsxs23(Badge2, { variant: "outline", children: [
4854
- ".",
4855
- asset.extension
4856
- ] }) : null,
4857
- asset.usage ? /* @__PURE__ */ jsx35(Badge2, { variant: "outline", children: asset.usage }) : null,
4858
- asset.category ? /* @__PURE__ */ jsx35(Badge2, { variant: "outline", children: asset.category }) : null,
4859
- asset.folderName ? /* @__PURE__ */ jsx35(Badge2, { variant: "outline", children: asset.folderName }) : null
5064
+ /* @__PURE__ */ jsx35(
5065
+ "button",
5066
+ {
5067
+ type: "button",
5068
+ onClick: (event) => {
5069
+ event.preventDefault();
5070
+ event.stopPropagation();
5071
+ setPreviewAsset(asset);
5072
+ },
5073
+ className: "absolute right-2 top-2 inline-flex h-7 w-7 items-center justify-center rounded-md border border-border/60 bg-background/80 text-foreground hover:bg-background",
5074
+ "aria-label": "Ver em tela cheia",
5075
+ children: /* @__PURE__ */ jsx35(Expand, { className: "h-4 w-4" })
5076
+ }
5077
+ ),
5078
+ selected ? /* @__PURE__ */ jsx35("span", { className: "absolute left-2 top-2 rounded-full bg-primary px-2 py-1 text-xs text-white", children: "Selecionado" }) : null,
5079
+ /* @__PURE__ */ jsxs23("div", { className: "pointer-events-none absolute bottom-2 right-2 flex flex-wrap items-center justify-end gap-1", children: [
5080
+ toMediaLabel(asset) ? /* @__PURE__ */ jsx35(Badge2, { className: "bg-background/85 text-[10px] font-semibold text-foreground", children: toMediaLabel(asset) }) : null,
5081
+ asset.extension ? /* @__PURE__ */ jsx35(Badge2, { className: "bg-background/85 text-[10px] font-semibold text-foreground", children: asset.extension.toLowerCase() }) : null
4860
5082
  ] })
4861
- ] })
5083
+ ] }),
5084
+ /* @__PURE__ */ jsx35("div", { className: "px-[10px] py-[20px]", children: /* @__PURE__ */ jsx35("p", { className: "text-sm font-semibold text-foreground line-clamp-1", children: asset.name || asset.fileName || asset.id }) })
4862
5085
  ]
4863
5086
  },
4864
5087
  asset.id
4865
5088
  );
4866
- }) }) }) })
5089
+ }) }) }) }),
5090
+ /* @__PURE__ */ jsx35(Dialog, { open: Boolean(previewAsset), onOpenChange: (open) => !open ? setPreviewAsset(null) : void 0, children: /* @__PURE__ */ jsxs23(DialogContent, { className: "z-[4700] max-w-6xl border-border/60 bg-background/95 p-3", children: [
5091
+ /* @__PURE__ */ jsx35(DialogTitle, { className: "sr-only", children: (previewAsset == null ? void 0 : previewAsset.name) || (previewAsset == null ? void 0 : previewAsset.fileName) || "Preview do asset" }),
5092
+ /* @__PURE__ */ jsx35(DialogDescription, { className: "sr-only", children: "Visualiza\xE7\xE3o do asset em tela cheia." }),
5093
+ /* @__PURE__ */ jsx35("div", { className: "flex h-[80vh] w-full items-center justify-center rounded-lg bg-muted/40 p-4", children: previewAsset ? getPreview(previewAsset, "h-full w-full rounded-lg object-contain") : null })
5094
+ ] }) })
4867
5095
  ] });
4868
5096
  };
4869
5097
 
@@ -4978,7 +5206,7 @@ function useTelescupUploadQueue(options) {
4978
5206
  activeRef.current += 1;
4979
5207
  updateItem(next.id, { status: "uploading", progress: 0, error: void 0 });
4980
5208
  const run = async () => {
4981
- var _a72, _b6, _c;
5209
+ var _a74, _b7, _c;
4982
5210
  try {
4983
5211
  if (TELESCUP_UPLOAD_MODE === "direct") {
4984
5212
  const completed2 = await client.uploadDirect(next.file);
@@ -4997,7 +5225,7 @@ function useTelescupUploadQueue(options) {
4997
5225
  size: next.file.size,
4998
5226
  mimeType: next.file.type,
4999
5227
  folderId,
5000
- conflict: (_a72 = next.conflictPolicy) != null ? _a72 : conflictPolicy
5228
+ conflict: (_a74 = next.conflictPolicy) != null ? _a74 : conflictPolicy
5001
5229
  });
5002
5230
  const conflictDetected = init.conflict === "ask" || init.conflict === "conflict" || init.conflict === "exists" || init.existingAsset && !init.uploadUrl;
5003
5231
  if (conflictDetected) {
@@ -5036,7 +5264,7 @@ function useTelescupUploadQueue(options) {
5036
5264
  storageKey: init.storageKey,
5037
5265
  finalFilename: init.finalFilename,
5038
5266
  folderId,
5039
- assetId: (_b6 = init.asset) == null ? void 0 : _b6.id,
5267
+ assetId: (_b7 = init.asset) == null ? void 0 : _b7.id,
5040
5268
  fileName: (_c = init.resolvedName) != null ? _c : next.file.name
5041
5269
  });
5042
5270
  updateItem(next.id, {
@@ -5135,7 +5363,7 @@ var TelescupUploader = ({
5135
5363
  className,
5136
5364
  onAssetUploaded
5137
5365
  }) => {
5138
- var _a72;
5366
+ var _a74;
5139
5367
  const inputRef = useRef10(null);
5140
5368
  const [dragActive, setDragActive] = useState9(false);
5141
5369
  const {
@@ -5202,8 +5430,8 @@ var TelescupUploader = ({
5202
5430
  size: "sm",
5203
5431
  variant: "secondary",
5204
5432
  onClick: () => {
5205
- var _a73;
5206
- return (_a73 = inputRef.current) == null ? void 0 : _a73.click();
5433
+ var _a75;
5434
+ return (_a75 = inputRef.current) == null ? void 0 : _a75.click();
5207
5435
  },
5208
5436
  children: labels.uploader.browse
5209
5437
  }
@@ -5217,8 +5445,8 @@ var TelescupUploader = ({
5217
5445
  accept,
5218
5446
  multiple,
5219
5447
  onChange: (event) => {
5220
- var _a73;
5221
- if ((_a73 = event.target.files) == null ? void 0 : _a73.length) {
5448
+ var _a75;
5449
+ if ((_a75 = event.target.files) == null ? void 0 : _a75.length) {
5222
5450
  handleFiles(event.target.files);
5223
5451
  event.currentTarget.value = "";
5224
5452
  }
@@ -5253,7 +5481,7 @@ var TelescupUploader = ({
5253
5481
  /* @__PURE__ */ jsx37(AlertDialogTitle, { children: labels.conflict.title }),
5254
5482
  /* @__PURE__ */ jsx37(AlertDialogDescription, { children: labels.conflict.description })
5255
5483
  ] }),
5256
- ((_a72 = conflictItem == null ? void 0 : conflictItem.existingAsset) == null ? void 0 : _a72.id) ? /* @__PURE__ */ jsxs24("div", { className: "mt-3 rounded-lg border border-border bg-muted/30 p-3", children: [
5484
+ ((_a74 = conflictItem == null ? void 0 : conflictItem.existingAsset) == null ? void 0 : _a74.id) ? /* @__PURE__ */ jsxs24("div", { className: "mt-3 rounded-lg border border-border bg-muted/30 p-3", children: [
5257
5485
  /* @__PURE__ */ jsx37("p", { className: "text-xs font-semibold text-muted-foreground", children: "Asset existente" }),
5258
5486
  /* @__PURE__ */ jsx37("div", { className: "mt-2 h-28 overflow-hidden rounded-md", children: /* @__PURE__ */ jsx37(
5259
5487
  TelescupImage,
@@ -5476,7 +5704,7 @@ var DEFAULT_LABELS = {
5476
5704
  }
5477
5705
  };
5478
5706
  var mergeLabels = (overrides) => {
5479
- var _a72;
5707
+ var _a74;
5480
5708
  if (!overrides) return DEFAULT_LABELS;
5481
5709
  return {
5482
5710
  ...DEFAULT_LABELS,
@@ -5490,17 +5718,17 @@ var mergeLabels = (overrides) => {
5490
5718
  meta: {
5491
5719
  ...DEFAULT_LABELS.meta,
5492
5720
  ...overrides.meta,
5493
- fields: { ...DEFAULT_LABELS.meta.fields, ...(_a72 = overrides.meta) == null ? void 0 : _a72.fields }
5721
+ fields: { ...DEFAULT_LABELS.meta.fields, ...(_a74 = overrides.meta) == null ? void 0 : _a74.fields }
5494
5722
  },
5495
5723
  toasts: { ...DEFAULT_LABELS.toasts, ...overrides.toasts }
5496
5724
  };
5497
5725
  };
5498
5726
  var LANGUAGES = ["pt", "en", "es"];
5499
5727
  var getAssetMeta = (asset, lang) => {
5500
- var _a72, _b6;
5728
+ var _a74, _b7;
5501
5729
  if (!asset) return {};
5502
- if ((_a72 = asset.metaByLang) == null ? void 0 : _a72[lang]) return asset.metaByLang[lang];
5503
- return (_b6 = asset.meta) != null ? _b6 : {};
5730
+ if ((_a74 = asset.metaByLang) == null ? void 0 : _a74[lang]) return asset.metaByLang[lang];
5731
+ return (_b7 = asset.meta) != null ? _b7 : {};
5504
5732
  };
5505
5733
  var TelescupMetaEditor = ({
5506
5734
  client,
@@ -5510,8 +5738,8 @@ var TelescupMetaEditor = ({
5510
5738
  labels,
5511
5739
  onAssetUpdated
5512
5740
  }) => {
5513
- var _a72, _b6, _c, _d, _e, _f, _g, _h;
5514
- const [activeAssetId, setActiveAssetId] = useState10((_b6 = (_a72 = assets[0]) == null ? void 0 : _a72.id) != null ? _b6 : "");
5741
+ var _a74, _b7, _c, _d, _e, _f, _g, _h;
5742
+ const [activeAssetId, setActiveAssetId] = useState10((_b7 = (_a74 = assets[0]) == null ? void 0 : _a74.id) != null ? _b7 : "");
5515
5743
  const [activeLang, setActiveLang] = useState10(
5516
5744
  LANGUAGES.includes(defaultLanguage) ? defaultLanguage : "pt"
5517
5745
  );
@@ -5529,18 +5757,18 @@ var TelescupMetaEditor = ({
5529
5757
  }, [activeAssetId, assets]);
5530
5758
  const asset = assets.find((item) => item.id === activeAssetId);
5531
5759
  const currentDraft = useMemo6(() => {
5532
- var _a73;
5533
- const existing = (_a73 = drafts[activeAssetId]) == null ? void 0 : _a73[activeLang];
5760
+ var _a75;
5761
+ const existing = (_a75 = drafts[activeAssetId]) == null ? void 0 : _a75[activeLang];
5534
5762
  if (existing) return existing;
5535
5763
  return getAssetMeta(asset, activeLang);
5536
5764
  }, [activeAssetId, activeLang, asset, drafts]);
5537
5765
  const updateDraft = (field, value) => {
5538
5766
  setDrafts((prev) => {
5539
- var _a73;
5767
+ var _a75;
5540
5768
  return {
5541
5769
  ...prev,
5542
5770
  [activeAssetId]: {
5543
- ...(_a73 = prev[activeAssetId]) != null ? _a73 : {},
5771
+ ...(_a75 = prev[activeAssetId]) != null ? _a75 : {},
5544
5772
  [activeLang]: {
5545
5773
  ...currentDraft,
5546
5774
  [field]: value
@@ -5608,11 +5836,11 @@ var TelescupMetaEditor = ({
5608
5836
  onAssetUpdated == null ? void 0 : onAssetUpdated(updated);
5609
5837
  const updatedMeta = getAssetMeta(updated, activeLang);
5610
5838
  setDrafts((prev) => {
5611
- var _a73;
5839
+ var _a75;
5612
5840
  return {
5613
5841
  ...prev,
5614
5842
  [asset.id]: {
5615
- ...(_a73 = prev[asset.id]) != null ? _a73 : {},
5843
+ ...(_a75 = prev[asset.id]) != null ? _a75 : {},
5616
5844
  [activeLang]: updatedMeta
5617
5845
  }
5618
5846
  };
@@ -5744,6 +5972,8 @@ var TelescupUpload = ({
5744
5972
  const isOpen = isControlled ? open : internalOpen;
5745
5973
  const [internalSelection, setInternalSelection] = useState10(value != null ? value : []);
5746
5974
  const [stagedSelection, setStagedSelection] = useState10(null);
5975
+ const [totalAssets, setTotalAssets] = useState10(0);
5976
+ const [activeTab, setActiveTab] = useState10("library");
5747
5977
  const [assetRevision, setAssetRevision] = useState10(0);
5748
5978
  const assetMapRef = React27.useRef(/* @__PURE__ */ new Map());
5749
5979
  useEffect13(() => {
@@ -5790,6 +6020,13 @@ var TelescupUpload = ({
5790
6020
  },
5791
6021
  [commitSelection, deferSelectionCommit, updateAssets]
5792
6022
  );
6023
+ const clearSelection = useCallback4(() => {
6024
+ if (deferSelectionCommit) {
6025
+ setStagedSelection([]);
6026
+ return;
6027
+ }
6028
+ updateSelection([], []);
6029
+ }, [deferSelectionCommit, updateSelection]);
5793
6030
  const handleClose = useCallback4(() => {
5794
6031
  setStagedSelection(null);
5795
6032
  if (!isControlled) setInternalOpen(false);
@@ -5798,15 +6035,16 @@ var TelescupUpload = ({
5798
6035
  useEffect13(() => {
5799
6036
  if (isOpen) return;
5800
6037
  setStagedSelection(null);
6038
+ setActiveTab("library");
5801
6039
  }, [isOpen]);
5802
6040
  const content = /* @__PURE__ */ jsxs26("div", { className: cn("flex h-full flex-col gap-4", className), children: [
5803
6041
  /* @__PURE__ */ jsxs26("header", { className: "flex flex-wrap items-center justify-between gap-3", children: [
5804
6042
  /* @__PURE__ */ jsxs26("div", { children: [
5805
6043
  /* @__PURE__ */ jsx41("h2", { className: "text-lg font-semibold text-foreground", children: labels.title }),
5806
6044
  /* @__PURE__ */ jsxs26("p", { className: "text-xs text-muted-foreground", children: [
5807
- effectiveSelectedIds.length,
5808
- " selecionado",
5809
- effectiveSelectedIds.length === 1 ? "" : "s"
6045
+ totalAssets,
6046
+ " asset",
6047
+ totalAssets === 1 ? "" : "s"
5810
6048
  ] })
5811
6049
  ] }),
5812
6050
  /* @__PURE__ */ jsxs26("div", { className: "flex items-center gap-2", children: [
@@ -5838,57 +6076,92 @@ var TelescupUpload = ({
5838
6076
  },
5839
6077
  children: commitButtonLabel
5840
6078
  }
5841
- ) : null,
5842
- /* @__PURE__ */ jsx41(Button, { variant: "outline", size: "sm", onClick: handleClose, children: labels.actions.close })
6079
+ ) : null
5843
6080
  ] })
5844
6081
  ] }),
5845
- /* @__PURE__ */ jsxs26(Tabs, { defaultValue: "library", className: "flex-1", children: [
5846
- /* @__PURE__ */ jsxs26(TabsList, { className: "grid w-full grid-cols-3", children: [
5847
- /* @__PURE__ */ jsx41(TabsTrigger, { value: "library", children: labels.tabs.library }),
5848
- /* @__PURE__ */ jsx41(TabsTrigger, { value: "upload", children: labels.tabs.upload }),
5849
- enableMetaEditor ? /* @__PURE__ */ jsx41(TabsTrigger, { value: "meta", children: labels.tabs.meta }) : null
5850
- ] }),
5851
- /* @__PURE__ */ jsx41(TabsContent, { value: "library", className: "pt-4", children: /* @__PURE__ */ jsx41(
5852
- TelescupAssetPicker,
5853
- {
5854
- client,
5855
- value: effectiveSelectedIds,
5856
- onChange: updateSelection,
5857
- multiple,
5858
- allowedTypes,
5859
- folderId,
5860
- labels,
5861
- enabled: isOpen,
5862
- onAssetsLoaded: updateAssets
5863
- }
5864
- ) }),
5865
- /* @__PURE__ */ jsx41(TabsContent, { value: "upload", className: "pt-4", children: /* @__PURE__ */ jsx41(
5866
- TelescupUploader,
5867
- {
5868
- client,
5869
- folderId,
5870
- allowedTypes,
5871
- maxSizeMB,
5872
- multiple,
5873
- labels,
5874
- onAssetUploaded: (asset) => {
5875
- const nextIds = multiple ? Array.from(/* @__PURE__ */ new Set([...effectiveSelectedIds, asset.id])) : [asset.id];
5876
- updateSelection(nextIds, [asset]);
6082
+ /* @__PURE__ */ jsxs26(
6083
+ Tabs,
6084
+ {
6085
+ value: activeTab,
6086
+ onValueChange: (next) => {
6087
+ const nextTab = next;
6088
+ if (activeTab === "library" && nextTab !== "library" && effectiveSelectedIds.length > 0) {
6089
+ clearSelection();
5877
6090
  }
5878
- }
5879
- ) }),
5880
- enableMetaEditor ? /* @__PURE__ */ jsx41(TabsContent, { value: "meta", className: "pt-4", children: /* @__PURE__ */ jsx41(
5881
- TelescupMetaEditor,
5882
- {
5883
- client,
5884
- assets: selectedAssets,
5885
- defaultLanguage,
5886
- enableAI,
5887
- labels,
5888
- onAssetUpdated: (asset) => updateAssets([asset])
5889
- }
5890
- ) }) : null
5891
- ] })
6091
+ setActiveTab(nextTab);
6092
+ },
6093
+ className: "flex-1",
6094
+ children: [
6095
+ /* @__PURE__ */ jsxs26(TabsList, { className: "inline-flex h-11 w-auto max-w-full justify-start gap-1 overflow-x-auto whitespace-nowrap rounded-2xl border border-border/70 bg-muted/70 px-2 py-1 dark:border-white/15", children: [
6096
+ /* @__PURE__ */ jsx41(
6097
+ TabsTrigger,
6098
+ {
6099
+ className: "rounded-xl border border-transparent px-5 data-[state=active]:border-border/80 data-[state=active]:bg-background/90 dark:data-[state=active]:border-white/25",
6100
+ value: "library",
6101
+ children: labels.tabs.library
6102
+ }
6103
+ ),
6104
+ /* @__PURE__ */ jsx41(
6105
+ TabsTrigger,
6106
+ {
6107
+ className: "rounded-xl border border-transparent px-5 data-[state=active]:border-border/80 data-[state=active]:bg-background/90 dark:data-[state=active]:border-white/25",
6108
+ value: "upload",
6109
+ children: labels.tabs.upload
6110
+ }
6111
+ ),
6112
+ enableMetaEditor ? /* @__PURE__ */ jsx41(
6113
+ TabsTrigger,
6114
+ {
6115
+ className: "rounded-xl border border-transparent px-5 data-[state=active]:border-border/80 data-[state=active]:bg-background/90 dark:data-[state=active]:border-white/25",
6116
+ value: "meta",
6117
+ children: labels.tabs.meta
6118
+ }
6119
+ ) : null
6120
+ ] }),
6121
+ /* @__PURE__ */ jsx41(TabsContent, { value: "library", className: "pt-4", children: /* @__PURE__ */ jsx41(
6122
+ TelescupAssetPicker,
6123
+ {
6124
+ client,
6125
+ value: effectiveSelectedIds,
6126
+ onChange: updateSelection,
6127
+ multiple,
6128
+ allowedTypes,
6129
+ folderId,
6130
+ labels,
6131
+ enabled: isOpen,
6132
+ onAssetsLoaded: updateAssets,
6133
+ onTotalAssetsChange: setTotalAssets
6134
+ }
6135
+ ) }),
6136
+ /* @__PURE__ */ jsx41(TabsContent, { value: "upload", className: "pt-4", children: /* @__PURE__ */ jsx41(
6137
+ TelescupUploader,
6138
+ {
6139
+ client,
6140
+ folderId,
6141
+ allowedTypes,
6142
+ maxSizeMB,
6143
+ multiple,
6144
+ labels,
6145
+ onAssetUploaded: (asset) => {
6146
+ const nextIds = multiple ? Array.from(/* @__PURE__ */ new Set([...effectiveSelectedIds, asset.id])) : [asset.id];
6147
+ updateSelection(nextIds, [asset]);
6148
+ }
6149
+ }
6150
+ ) }),
6151
+ enableMetaEditor ? /* @__PURE__ */ jsx41(TabsContent, { value: "meta", className: "pt-4", children: /* @__PURE__ */ jsx41(
6152
+ TelescupMetaEditor,
6153
+ {
6154
+ client,
6155
+ assets: selectedAssets,
6156
+ defaultLanguage,
6157
+ enableAI,
6158
+ labels,
6159
+ onAssetUpdated: (asset) => updateAssets([asset])
6160
+ }
6161
+ ) }) : null
6162
+ ]
6163
+ }
6164
+ )
5892
6165
  ] });
5893
6166
  if (!isControlled && renderTrigger) {
5894
6167
  return /* @__PURE__ */ jsxs26(Fragment2, { children: [
@@ -6039,10 +6312,10 @@ var SHARED_FILE_EXTENSIONS = [
6039
6312
  ".mov",
6040
6313
  ".avi"
6041
6314
  ];
6042
- var _a14;
6043
- var ACCOUNTS_BASE_URL = ((_a14 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a14 : "https://accounts.cupcode.com.br").trim().replace(/\/+$/, "");
6044
- var _a15;
6045
- var MC_BASE_URL = ((_a15 = getRuntimeEnv("VITE_MC_BASE_URL")) != null ? _a15 : "https://mc.cupcode.com.br").trim().replace(/\/+$/, "");
6315
+ var _a16;
6316
+ var ACCOUNTS_BASE_URL = ((_a16 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a16 : "https://accounts.cupcode.com.br").trim().replace(/\/+$/, "");
6317
+ var _a17;
6318
+ var MC_BASE_URL = ((_a17 = getRuntimeEnv("VITE_MC_BASE_URL")) != null ? _a17 : "https://mc.cupcode.com.br").trim().replace(/\/+$/, "");
6046
6319
  var LANGUAGE_OPTIONS = [
6047
6320
  { value: "pt-BR", shortLabel: "BR", label: "Portugu\xEAs (Brasil)" },
6048
6321
  { value: "en-US", shortLabel: "EN", label: "English" },
@@ -6188,16 +6461,16 @@ var normalizeContrastMode = (value) => {
6188
6461
  return (value == null ? void 0 : value.trim().toLowerCase()) === "high" ? "high" : "normal";
6189
6462
  };
6190
6463
  var readStoredExperienceSettings = () => {
6191
- var _a72, _b6, _c;
6464
+ var _a74, _b7, _c;
6192
6465
  const fallback = defaultExperienceSettings();
6193
6466
  if (typeof window === "undefined") return fallback;
6194
6467
  try {
6195
6468
  const raw = window.localStorage.getItem(EXPERIENCE_SETTINGS_STORAGE_KEY);
6196
6469
  const parsed = raw ? JSON.parse(raw) : null;
6197
6470
  const storedThemePreference = window.localStorage.getItem(THEME_PREFERENCE_STORAGE_KEY);
6198
- const legacyTheme = (_a72 = window.localStorage.getItem(THEME_STORAGE_KEY)) != null ? _a72 : window.localStorage.getItem(LEGACY_THEME_STORAGE_KEY);
6471
+ const legacyTheme = (_a74 = window.localStorage.getItem(THEME_STORAGE_KEY)) != null ? _a74 : window.localStorage.getItem(LEGACY_THEME_STORAGE_KEY);
6199
6472
  return {
6200
- theme: normalizeThemePreference((_c = (_b6 = parsed == null ? void 0 : parsed.theme) != null ? _b6 : storedThemePreference) != null ? _c : legacyTheme),
6473
+ theme: normalizeThemePreference((_c = (_b7 = parsed == null ? void 0 : parsed.theme) != null ? _b7 : storedThemePreference) != null ? _c : legacyTheme),
6201
6474
  density: normalizeDensityMode(parsed == null ? void 0 : parsed.density),
6202
6475
  contrast: normalizeContrastMode(parsed == null ? void 0 : parsed.contrast),
6203
6476
  showEmailPublicly: typeof (parsed == null ? void 0 : parsed.showEmailPublicly) === "boolean" ? parsed.showEmailPublicly : fallback.showEmailPublicly
@@ -6339,7 +6612,7 @@ var getNotificationTimestamp = (notification) => {
6339
6612
  return Number.isNaN(parsed) ? 0 : parsed;
6340
6613
  };
6341
6614
  var formatNotificationDateTime = (notification) => {
6342
- var _a72;
6615
+ var _a74;
6343
6616
  if (notification.createdAt) {
6344
6617
  const parsed = new Date(notification.createdAt);
6345
6618
  if (!Number.isNaN(parsed.getTime())) {
@@ -6351,7 +6624,7 @@ var formatNotificationDateTime = (notification) => {
6351
6624
  });
6352
6625
  }
6353
6626
  }
6354
- return ((_a72 = notification.timeLabel) == null ? void 0 : _a72.trim()) || "Agora";
6627
+ return ((_a74 = notification.timeLabel) == null ? void 0 : _a74.trim()) || "Agora";
6355
6628
  };
6356
6629
  var getNotificationDayKey = (notification) => {
6357
6630
  const timestamp = getNotificationTimestamp(notification);
@@ -6424,22 +6697,22 @@ var extractSharedFilesFromMessages = (messages) => {
6424
6697
  return files;
6425
6698
  };
6426
6699
  var resolveTelescupImageUrl = (value, options) => {
6427
- var _a72, _b6, _c;
6700
+ var _a74, _b7, _c;
6428
6701
  return resolveTelescupImageURL(value, {
6429
- width: (_a72 = options == null ? void 0 : options.width) != null ? _a72 : 96,
6430
- height: (_b6 = options == null ? void 0 : options.height) != null ? _b6 : 96,
6702
+ width: (_a74 = options == null ? void 0 : options.width) != null ? _a74 : 96,
6703
+ height: (_b7 = options == null ? void 0 : options.height) != null ? _b7 : 96,
6431
6704
  fit: "cover",
6432
6705
  format: "avif",
6433
6706
  quality: (_c = options == null ? void 0 : options.quality) != null ? _c : 72
6434
6707
  });
6435
6708
  };
6436
6709
  var resolveGroupAvatarFromTelescup = (asset, fallbackId) => {
6437
- var _a72, _b6;
6438
- return (_b6 = (_a72 = resolveTelescupImageUrl(asset == null ? void 0 : asset.url)) != null ? _a72 : resolveTelescupImageUrl(asset == null ? void 0 : asset.id)) != null ? _b6 : resolveTelescupImageUrl(fallbackId);
6710
+ var _a74, _b7;
6711
+ return (_b7 = (_a74 = resolveTelescupImageUrl(asset == null ? void 0 : asset.url)) != null ? _a74 : resolveTelescupImageUrl(asset == null ? void 0 : asset.id)) != null ? _b7 : resolveTelescupImageUrl(fallbackId);
6439
6712
  };
6440
6713
  var resolveProfileAvatarFromTelescup = (asset, fallbackId) => {
6441
- var _a72, _b6;
6442
- return (_b6 = (_a72 = resolveTelescupImageUrl(asset == null ? void 0 : asset.url, { width: 384, height: 384, quality: 80 })) != null ? _a72 : resolveTelescupImageUrl(asset == null ? void 0 : asset.id, { width: 384, height: 384, quality: 80 })) != null ? _b6 : resolveTelescupImageUrl(fallbackId, { width: 384, height: 384, quality: 80 });
6714
+ var _a74, _b7;
6715
+ return (_b7 = (_a74 = resolveTelescupImageUrl(asset == null ? void 0 : asset.url, { width: 384, height: 384, quality: 80 })) != null ? _a74 : resolveTelescupImageUrl(asset == null ? void 0 : asset.id, { width: 384, height: 384, quality: 80 })) != null ? _b7 : resolveTelescupImageUrl(fallbackId, { width: 384, height: 384, quality: 80 });
6443
6716
  };
6444
6717
  var playIncomingMessageSound = () => {
6445
6718
  if (typeof window === "undefined") return;
@@ -6572,7 +6845,7 @@ var UserMenuCupcode = ({
6572
6845
  panels,
6573
6846
  className
6574
6847
  }) => {
6575
- var _a72;
6848
+ var _a74;
6576
6849
  const [open, setOpen] = useState11(false);
6577
6850
  const [activeTab, setActiveTab] = useState11("profile");
6578
6851
  const [isLoggingOut, setIsLoggingOut] = useState11(false);
@@ -6674,12 +6947,12 @@ var UserMenuCupcode = ({
6674
6947
  );
6675
6948
  const normalizedNotificationFeed = useMemo7(
6676
6949
  () => resolvedNotificationFeed.map((notification) => {
6677
- var _a73;
6950
+ var _a75;
6678
6951
  const kind = normalizeNotificationKind(notification.kind);
6679
6952
  return {
6680
6953
  ...notification,
6681
6954
  kind,
6682
- topic: (_a73 = notification.topic) != null ? _a73 : NOTIFICATION_KIND_META[kind].topicFallback
6955
+ topic: (_a75 = notification.topic) != null ? _a75 : NOTIFICATION_KIND_META[kind].topicFallback
6683
6956
  };
6684
6957
  }),
6685
6958
  [resolvedNotificationFeed]
@@ -6714,10 +6987,10 @@ var UserMenuCupcode = ({
6714
6987
  const groupedNotifications = useMemo7(() => {
6715
6988
  const groups = /* @__PURE__ */ new Map();
6716
6989
  filteredNotifications.forEach((notification) => {
6717
- var _a73, _b6;
6990
+ var _a75, _b7;
6718
6991
  const kind = normalizeNotificationKind(notification.kind);
6719
- const key = notificationPreferences.grouping === "topic" ? (_a73 = notification.topic) != null ? _a73 : NOTIFICATION_KIND_META[kind].topicFallback : getNotificationDayKey(notification);
6720
- const current = (_b6 = groups.get(key)) != null ? _b6 : [];
6992
+ const key = notificationPreferences.grouping === "topic" ? (_a75 = notification.topic) != null ? _a75 : NOTIFICATION_KIND_META[kind].topicFallback : getNotificationDayKey(notification);
6993
+ const current = (_b7 = groups.get(key)) != null ? _b7 : [];
6721
6994
  current.push(notification);
6722
6995
  groups.set(key, current);
6723
6996
  });
@@ -6804,7 +7077,7 @@ var UserMenuCupcode = ({
6804
7077
  }).slice(0, 6);
6805
7078
  }, [recentActivity]);
6806
7079
  const isSendingChatMessage = isChatSending || isSendingInternalChatMessage;
6807
- const activeReactionPickerMessageId = (_a72 = activeReactionPicker == null ? void 0 : activeReactionPicker.messageId) != null ? _a72 : null;
7080
+ const activeReactionPickerMessageId = (_a74 = activeReactionPicker == null ? void 0 : activeReactionPicker.messageId) != null ? _a74 : null;
6808
7081
  const isChatSidebarOpen = isChatSidebarExpanded || isChatSidebarPinned;
6809
7082
  const hasTelescupAvatarSupport = Boolean(telescupBaseUrl && getTelescupAccessToken);
6810
7083
  const hasTelescupGroupAvatarSupport = hasTelescupAvatarSupport;
@@ -6818,8 +7091,8 @@ var UserMenuCupcode = ({
6818
7091
  meta.set(user.id, { lastMessage: null, lastTimestamp: 0, unreadCount: 0 });
6819
7092
  });
6820
7093
  resolvedAllChatMessages.forEach((message) => {
6821
- var _a73;
6822
- const current = (_a73 = meta.get(message.contactId)) != null ? _a73 : { lastMessage: null, lastTimestamp: 0, unreadCount: 0 };
7094
+ var _a75;
7095
+ const current = (_a75 = meta.get(message.contactId)) != null ? _a75 : { lastMessage: null, lastTimestamp: 0, unreadCount: 0 };
6823
7096
  const timestamp = getChatMessageTimestamp(message);
6824
7097
  if (timestamp >= current.lastTimestamp) {
6825
7098
  current.lastTimestamp = timestamp;
@@ -6839,11 +7112,11 @@ var UserMenuCupcode = ({
6839
7112
  return haystack.includes(query);
6840
7113
  });
6841
7114
  return filtered.sort((left, right) => {
6842
- var _a73, _b6, _c, _d;
7115
+ var _a75, _b7, _c, _d;
6843
7116
  const leftMeta = conversationMetaByUserId.get(left.id);
6844
7117
  const rightMeta = conversationMetaByUserId.get(right.id);
6845
- const leftUnread = (_a73 = leftMeta == null ? void 0 : leftMeta.unreadCount) != null ? _a73 : 0;
6846
- const rightUnread = (_b6 = rightMeta == null ? void 0 : rightMeta.unreadCount) != null ? _b6 : 0;
7118
+ const leftUnread = (_a75 = leftMeta == null ? void 0 : leftMeta.unreadCount) != null ? _a75 : 0;
7119
+ const rightUnread = (_b7 = rightMeta == null ? void 0 : rightMeta.unreadCount) != null ? _b7 : 0;
6847
7120
  if (leftUnread !== rightUnread) return rightUnread - leftUnread;
6848
7121
  const leftTimestamp = (_c = leftMeta == null ? void 0 : leftMeta.lastTimestamp) != null ? _c : 0;
6849
7122
  const rightTimestamp = (_d = rightMeta == null ? void 0 : rightMeta.lastTimestamp) != null ? _d : 0;
@@ -6892,11 +7165,11 @@ var UserMenuCupcode = ({
6892
7165
  let changed = false;
6893
7166
  const next = { ...current };
6894
7167
  normalizedNotificationFeed.forEach((notification) => {
6895
- var _a73;
7168
+ var _a75;
6896
7169
  if (normalizeNotificationKind(notification.kind) !== "chat") return;
6897
7170
  const contactId = notification.actionChatUserId;
6898
7171
  if (!contactId) return;
6899
- if (((_a73 = resolvedChatUnreadByUser[contactId]) != null ? _a73 : 0) > 0) return;
7172
+ if (((_a75 = resolvedChatUnreadByUser[contactId]) != null ? _a75 : 0) > 0) return;
6900
7173
  if (next[notification.id] === true) return;
6901
7174
  next[notification.id] = true;
6902
7175
  changed = true;
@@ -6910,11 +7183,11 @@ var UserMenuCupcode = ({
6910
7183
  const visibleChatUnreadCount = resolvedChatUnreadCount;
6911
7184
  const firstUnreadChatUserId = useMemo7(
6912
7185
  () => {
6913
- var _a73, _b6;
6914
- return (_b6 = (_a73 = filteredAndSortedChatUsers.find((user) => {
6915
- var _a74;
6916
- return ((_a74 = resolvedChatUnreadByUser[user.id]) != null ? _a74 : 0) > 0;
6917
- })) == null ? void 0 : _a73.id) != null ? _b6 : null;
7186
+ var _a75, _b7;
7187
+ return (_b7 = (_a75 = filteredAndSortedChatUsers.find((user) => {
7188
+ var _a76;
7189
+ return ((_a76 = resolvedChatUnreadByUser[user.id]) != null ? _a76 : 0) > 0;
7190
+ })) == null ? void 0 : _a75.id) != null ? _b7 : null;
6918
7191
  },
6919
7192
  [filteredAndSortedChatUsers, resolvedChatUnreadByUser]
6920
7193
  );
@@ -6973,11 +7246,11 @@ var UserMenuCupcode = ({
6973
7246
  );
6974
7247
  const openChatPanel = useCallback5(
6975
7248
  (contactId) => {
6976
- var _a73, _b6, _c, _d, _e;
7249
+ var _a75, _b7, _c, _d, _e;
6977
7250
  setIsLogoutConfirmOpen(false);
6978
7251
  setOpen(true);
6979
7252
  setActiveTab("chat");
6980
- const targetContactId = (_e = (_d = (_b6 = contactId != null ? contactId : firstUnreadChatUserId) != null ? _b6 : (_a73 = filteredAndSortedChatUsers[0]) == null ? void 0 : _a73.id) != null ? _d : (_c = chatUsersList[0]) == null ? void 0 : _c.id) != null ? _e : "";
7253
+ const targetContactId = (_e = (_d = (_b7 = contactId != null ? contactId : firstUnreadChatUserId) != null ? _b7 : (_a75 = filteredAndSortedChatUsers[0]) == null ? void 0 : _a75.id) != null ? _d : (_c = chatUsersList[0]) == null ? void 0 : _c.id) != null ? _e : "";
6981
7254
  if (!targetContactId) return;
6982
7255
  setActiveChatUserId(targetContactId);
6983
7256
  markConversationRead(targetContactId);
@@ -7011,9 +7284,9 @@ var UserMenuCupcode = ({
7011
7284
  const reactionsByMessageId = useMemo7(() => {
7012
7285
  const grouped = /* @__PURE__ */ new Map();
7013
7286
  resolvedAllChatReactions.forEach((reaction) => {
7014
- var _a73, _b6;
7015
- const byEmoji = (_a73 = grouped.get(reaction.messageId)) != null ? _a73 : /* @__PURE__ */ new Map();
7016
- const current = (_b6 = byEmoji.get(reaction.emoji)) != null ? _b6 : { emoji: reaction.emoji, count: 0, reactedByMe: false };
7287
+ var _a75, _b7;
7288
+ const byEmoji = (_a75 = grouped.get(reaction.messageId)) != null ? _a75 : /* @__PURE__ */ new Map();
7289
+ const current = (_b7 = byEmoji.get(reaction.emoji)) != null ? _b7 : { emoji: reaction.emoji, count: 0, reactedByMe: false };
7017
7290
  current.count += 1;
7018
7291
  if (resolvedCurrentChatUserId && reaction.userId === resolvedCurrentChatUserId) {
7019
7292
  current.reactedByMe = true;
@@ -7210,9 +7483,9 @@ var UserMenuCupcode = ({
7210
7483
  const wasFocusModeActive = wasFocusModeActiveRef.current;
7211
7484
  if (wasFocusModeActive && !isFocusModeActive && suppressedFocusNotifications.length) {
7212
7485
  const byType = suppressedFocusNotifications.reduce((acc, notification) => {
7213
- var _a73;
7486
+ var _a75;
7214
7487
  const kind = normalizeNotificationKind(notification.kind);
7215
- acc[kind] = ((_a73 = acc[kind]) != null ? _a73 : 0) + 1;
7488
+ acc[kind] = ((_a75 = acc[kind]) != null ? _a75 : 0) + 1;
7216
7489
  return acc;
7217
7490
  }, { system: 0, comment: 0, access: 0, billing: 0, chat: 0, security: 0 });
7218
7491
  const summaryParts = NOTIFICATION_KIND_ORDER.filter((kind) => byType[kind] > 0).map(
@@ -7242,9 +7515,9 @@ var UserMenuCupcode = ({
7242
7515
  return;
7243
7516
  }
7244
7517
  setActiveChatUserId((current) => {
7245
- var _a73, _b6;
7518
+ var _a75, _b7;
7246
7519
  if (current && chatUsersList.some((user) => user.id === current)) return current;
7247
- return (_b6 = (_a73 = filteredAndSortedChatUsers[0]) == null ? void 0 : _a73.id) != null ? _b6 : chatUsersList[0].id;
7520
+ return (_b7 = (_a75 = filteredAndSortedChatUsers[0]) == null ? void 0 : _a75.id) != null ? _b7 : chatUsersList[0].id;
7248
7521
  });
7249
7522
  }, [chatUsersList, filteredAndSortedChatUsers]);
7250
7523
  useEffect14(() => {
@@ -7286,7 +7559,7 @@ var UserMenuCupcode = ({
7286
7559
  };
7287
7560
  }, [activeReactionPickerMessageId]);
7288
7561
  useEffect14(() => {
7289
- var _a73;
7562
+ var _a75;
7290
7563
  if (!hasBootstrappedIncomingMessagesRef.current && isChatLoading) return;
7291
7564
  const knownIncomingIds = seenIncomingMessageIdsRef.current;
7292
7565
  const incomingMessages = resolvedAllChatMessages.filter((message) => message.sender === "them" && !message.readAt);
@@ -7308,14 +7581,14 @@ var UserMenuCupcode = ({
7308
7581
  return;
7309
7582
  }
7310
7583
  const generatedNotifications = relevantIncomingMessages.map((message) => {
7311
- var _a74, _b6, _c;
7584
+ var _a76, _b7, _c;
7312
7585
  const contact = chatUsersList.find((user) => user.id === message.contactId);
7313
- const createdAt = (_a74 = message.createdAt) != null ? _a74 : (/* @__PURE__ */ new Date()).toISOString();
7586
+ const createdAt = (_a76 = message.createdAt) != null ? _a76 : (/* @__PURE__ */ new Date()).toISOString();
7314
7587
  const previewText = chatSettings.showMessagePreview ? summarizeChatText(message.text, 100) : "Nova mensagem no chat.";
7315
7588
  return {
7316
7589
  id: `chat-notification-${message.id}`,
7317
7590
  kind: "chat",
7318
- title: `Mensagem de ${(_b6 = contact == null ? void 0 : contact.name) != null ? _b6 : "usu\xE1rio"}`,
7591
+ title: `Mensagem de ${(_b7 = contact == null ? void 0 : contact.name) != null ? _b7 : "usu\xE1rio"}`,
7319
7592
  description: previewText,
7320
7593
  createdAt,
7321
7594
  timeLabel: formatChatTime({ ...message, createdAt }),
@@ -7332,7 +7605,7 @@ var UserMenuCupcode = ({
7332
7605
  )[0];
7333
7606
  if (latestRelevantMessage) {
7334
7607
  const latestContact = chatUsersList.find((user) => user.id === latestRelevantMessage.contactId);
7335
- const senderName = (_a73 = latestContact == null ? void 0 : latestContact.name) != null ? _a73 : "usu\xE1rio";
7608
+ const senderName = (_a75 = latestContact == null ? void 0 : latestContact.name) != null ? _a75 : "usu\xE1rio";
7336
7609
  const latestPreview = chatSettings.showMessagePreview ? summarizeChatText(latestRelevantMessage.text, 96) : "Nova mensagem";
7337
7610
  const messageCount = relevantIncomingMessages.length;
7338
7611
  const messageCountLabel = messageCount > 99 ? "99+" : String(messageCount);
@@ -7381,10 +7654,10 @@ var UserMenuCupcode = ({
7381
7654
  return;
7382
7655
  }
7383
7656
  generatedNotifications.forEach((chatNotification) => {
7384
- var _a74;
7657
+ var _a76;
7385
7658
  const notification = new Notification(chatNotification.title, {
7386
7659
  body: chatSettings.showMessagePreview ? chatNotification.description : "Voc\xEA recebeu uma nova mensagem.",
7387
- tag: `cc-chat-${(_a74 = chatNotification.actionChatUserId) != null ? _a74 : chatNotification.id}`
7660
+ tag: `cc-chat-${(_a76 = chatNotification.actionChatUserId) != null ? _a76 : chatNotification.id}`
7388
7661
  });
7389
7662
  notification.onclick = () => {
7390
7663
  window.focus();
@@ -7411,14 +7684,14 @@ var UserMenuCupcode = ({
7411
7684
  ]);
7412
7685
  const activeChatUser = useMemo7(
7413
7686
  () => {
7414
- var _a73;
7415
- return (_a73 = chatUsersList.find((user) => user.id === activeChatUserId)) != null ? _a73 : null;
7687
+ var _a75;
7688
+ return (_a75 = chatUsersList.find((user) => user.id === activeChatUserId)) != null ? _a75 : null;
7416
7689
  },
7417
7690
  [activeChatUserId, chatUsersList]
7418
7691
  );
7419
7692
  const activeGroupMembers = useMemo7(() => {
7420
- var _a73;
7421
- if (!(activeChatUser == null ? void 0 : activeChatUser.isGroup) || !((_a73 = activeChatUser.memberIds) == null ? void 0 : _a73.length)) return [];
7693
+ var _a75;
7694
+ if (!(activeChatUser == null ? void 0 : activeChatUser.isGroup) || !((_a75 = activeChatUser.memberIds) == null ? void 0 : _a75.length)) return [];
7422
7695
  const members = activeChatUser.memberIds.map((memberId) => baseChatUsersList.find((user) => user.id === memberId)).filter((member) => Boolean(member));
7423
7696
  return members;
7424
7697
  }, [activeChatUser, baseChatUsersList]);
@@ -7457,8 +7730,8 @@ var UserMenuCupcode = ({
7457
7730
  return items;
7458
7731
  }, [activeChatMessages]);
7459
7732
  useEffect14(() => {
7460
- var _a73;
7461
- const conversationId = (_a73 = activeChatUser == null ? void 0 : activeChatUser.id) != null ? _a73 : null;
7733
+ var _a75;
7734
+ const conversationId = (_a75 = activeChatUser == null ? void 0 : activeChatUser.id) != null ? _a75 : null;
7462
7735
  if (!conversationId) {
7463
7736
  activeConversationIdRef.current = null;
7464
7737
  activeConversationMessageIdsRef.current = /* @__PURE__ */ new Set();
@@ -7511,9 +7784,9 @@ var UserMenuCupcode = ({
7511
7784
  });
7512
7785
  }, [activeChatUser, resolvedChatLogs]);
7513
7786
  const replyToMessage = useMemo7(() => {
7514
- var _a73;
7787
+ var _a75;
7515
7788
  if (!replyToMessageId) return null;
7516
- return (_a73 = activeChatMessagesMap.get(replyToMessageId)) != null ? _a73 : null;
7789
+ return (_a75 = activeChatMessagesMap.get(replyToMessageId)) != null ? _a75 : null;
7517
7790
  }, [activeChatMessagesMap, replyToMessageId]);
7518
7791
  useEffect14(() => {
7519
7792
  if (!replyToMessageId) return;
@@ -7540,9 +7813,9 @@ var UserMenuCupcode = ({
7540
7813
  }
7541
7814
  }, [activeChatUser]);
7542
7815
  useEffect14(() => {
7543
- var _a73;
7816
+ var _a75;
7544
7817
  if (!open || activeTab !== "chat" || !activeChatUser || activeChatUser.isGroup) return;
7545
- const unreadCount = (_a73 = resolvedChatUnreadByUser[activeChatUser.id]) != null ? _a73 : 0;
7818
+ const unreadCount = (_a75 = resolvedChatUnreadByUser[activeChatUser.id]) != null ? _a75 : 0;
7546
7819
  if (unreadCount <= 0) return;
7547
7820
  const contactId = activeChatUser.id;
7548
7821
  if (pendingReadRequestsRef.current.has(contactId)) return;
@@ -7618,13 +7891,13 @@ var UserMenuCupcode = ({
7618
7891
  openAccountsPath("/security#sessions");
7619
7892
  };
7620
7893
  const runOpenIntegrations = (provider) => {
7621
- var _a73;
7894
+ var _a75;
7622
7895
  if (!provider) {
7623
7896
  openAccountsPath("/integrations");
7624
7897
  return;
7625
7898
  }
7626
7899
  const option = INTEGRATION_OPTIONS.find((integration) => integration.id === provider);
7627
- openAccountsPath((_a73 = option == null ? void 0 : option.accountPath) != null ? _a73 : "/integrations");
7900
+ openAccountsPath((_a75 = option == null ? void 0 : option.accountPath) != null ? _a75 : "/integrations");
7628
7901
  };
7629
7902
  const changeStatus = (nextStatus) => {
7630
7903
  if (nextStatus === "offline") return;
@@ -7991,10 +8264,10 @@ var UserMenuCupcode = ({
7991
8264
  };
7992
8265
  const handleProfileAvatarChange = useCallback5(
7993
8266
  async (ids, assets) => {
7994
- var _a73, _b6, _c;
8267
+ var _a75, _b7, _c;
7995
8268
  const selectedAsset = assets == null ? void 0 : assets[0];
7996
- const selectedIdRaw = (_a73 = ids[0]) == null ? void 0 : _a73.trim();
7997
- const selectedId = (_c = (_b6 = parseAssetId(selectedIdRaw)) != null ? _b6 : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.id)) != null ? _c : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.url);
8269
+ const selectedIdRaw = (_a75 = ids[0]) == null ? void 0 : _a75.trim();
8270
+ const selectedId = (_c = (_b7 = parseAssetId(selectedIdRaw)) != null ? _b7 : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.id)) != null ? _c : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.url);
7998
8271
  if (!selectedId) {
7999
8272
  toast({
8000
8273
  title: "Imagem inv\xE1lida",
@@ -8036,7 +8309,7 @@ var UserMenuCupcode = ({
8036
8309
  [isProfileAvatarSaving, onProfileAvatarChange, resolvedProfileAvatarUrl]
8037
8310
  );
8038
8311
  const sendChatMessage = async () => {
8039
- var _a73, _b6;
8312
+ var _a75, _b7;
8040
8313
  if (!activeChatUser) return;
8041
8314
  const text = chatDraft.trim();
8042
8315
  if (!text || isSendingChatMessage) return;
@@ -8048,7 +8321,7 @@ var UserMenuCupcode = ({
8048
8321
  await onChatSendMessage({
8049
8322
  recipientId: activeChatUser.id,
8050
8323
  text,
8051
- replyToMessageId: (_a73 = replyToMessage == null ? void 0 : replyToMessage.id) != null ? _a73 : null
8324
+ replyToMessageId: (_a75 = replyToMessage == null ? void 0 : replyToMessage.id) != null ? _a75 : null
8052
8325
  });
8053
8326
  setChatDraft("");
8054
8327
  setShowEmojiPicker(false);
@@ -8075,7 +8348,7 @@ var UserMenuCupcode = ({
8075
8348
  timeLabel,
8076
8349
  createdAt,
8077
8350
  readAt: null,
8078
- replyToMessageId: (_b6 = replyToMessage == null ? void 0 : replyToMessage.id) != null ? _b6 : null
8351
+ replyToMessageId: (_b7 = replyToMessage == null ? void 0 : replyToMessage.id) != null ? _b7 : null
8079
8352
  };
8080
8353
  if (isLocalGroupConversation) {
8081
8354
  setInternalGroupMessages((current) => [...current, message]);
@@ -8090,7 +8363,7 @@ var UserMenuCupcode = ({
8090
8363
  });
8091
8364
  };
8092
8365
  const renderDefaultPanel = () => {
8093
- var _a73, _b6, _c, _d;
8366
+ var _a75, _b7, _c, _d;
8094
8367
  if (activeTab === "profile") {
8095
8368
  return /* @__PURE__ */ jsxs27("div", { className: "space-y-4", children: [
8096
8369
  /* @__PURE__ */ jsxs27("div", { className: "pt-1 text-center", children: [
@@ -8357,11 +8630,11 @@ var UserMenuCupcode = ({
8357
8630
  ),
8358
8631
  style: { backfaceVisibility: "hidden", WebkitBackfaceVisibility: "hidden" },
8359
8632
  "aria-hidden": isNotificationsPreferencesBackVisible,
8360
- children: /* @__PURE__ */ jsxs27("div", { className: "cc-scrollbar cc-scrollbar-pink h-full overflow-y-auto pr-1", children: [
8633
+ children: /* @__PURE__ */ jsxs27("div", { className: "cc-scrollbar cc-scrollbar-purple h-full overflow-y-auto pr-1", children: [
8361
8634
  visibleGroupedNotifications.length ? visibleGroupedNotifications.map((group) => /* @__PURE__ */ jsxs27("section", { className: "space-y-1.5", children: [
8362
8635
  /* @__PURE__ */ jsx42("p", { className: "px-0.5 text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground", children: group.label }),
8363
8636
  /* @__PURE__ */ jsx42("div", { className: "space-y-1.5", children: group.items.map((notification) => {
8364
- var _a74;
8637
+ var _a76;
8365
8638
  const kind = normalizeNotificationKind(notification.kind);
8366
8639
  const meta = NOTIFICATION_KIND_META[kind];
8367
8640
  const Icon3 = meta.icon;
@@ -8390,7 +8663,7 @@ var UserMenuCupcode = ({
8390
8663
  className: "inline-flex h-6 items-center gap-1 rounded-md border border-border/70 px-1.5 text-[11px] font-semibold text-foreground transition-all hover:bg-muted/45",
8391
8664
  children: [
8392
8665
  /* @__PURE__ */ jsx42(ExternalLink, { className: "h-3 w-3" }),
8393
- (_a74 = notification.actionLabel) != null ? _a74 : "Abrir"
8666
+ (_a76 = notification.actionLabel) != null ? _a76 : "Abrir"
8394
8667
  ]
8395
8668
  }
8396
8669
  ),
@@ -8460,7 +8733,7 @@ var UserMenuCupcode = ({
8460
8733
  }
8461
8734
  )
8462
8735
  ] }),
8463
- /* @__PURE__ */ jsxs27("div", { className: "cc-scrollbar cc-scrollbar-pink h-full space-y-2 overflow-y-auto pr-1", children: [
8736
+ /* @__PURE__ */ jsxs27("div", { className: "cc-scrollbar cc-scrollbar-purple h-full space-y-2 overflow-y-auto pr-1", children: [
8464
8737
  /* @__PURE__ */ jsxs27("div", { className: "rounded-lg border border-border/70 bg-background/40 p-2", children: [
8465
8738
  /* @__PURE__ */ jsx42("p", { className: "text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground", children: "Eventos" }),
8466
8739
  /* @__PURE__ */ jsx42("div", { className: "mt-1 space-y-1", children: NOTIFICATION_KIND_ORDER.map((kind) => {
@@ -8618,7 +8891,7 @@ var UserMenuCupcode = ({
8618
8891
  }
8619
8892
  if (activeTab === "chat") {
8620
8893
  const canSendChatMessage = Boolean(activeChatUser) && chatDraft.trim() !== "" && !isSendingChatMessage && !isChatLoading;
8621
- const activeConversationUnreadCount = activeChatUser ? (_a73 = resolvedChatUnreadByUser[activeChatUser.id]) != null ? _a73 : 0 : 0;
8894
+ const activeConversationUnreadCount = activeChatUser ? (_a75 = resolvedChatUnreadByUser[activeChatUser.id]) != null ? _a75 : 0 : 0;
8622
8895
  return /* @__PURE__ */ jsx42("div", { className: "h-full", children: /* @__PURE__ */ jsxs27(
8623
8896
  "div",
8624
8897
  {
@@ -8682,7 +8955,7 @@ var UserMenuCupcode = ({
8682
8955
  }
8683
8956
  ),
8684
8957
  isChatLoading && !filteredAndSortedChatUsers.length ? /* @__PURE__ */ jsx42("p", { className: "px-1 text-center text-[11px] text-muted-foreground", children: "Carregando..." }) : null,
8685
- /* @__PURE__ */ jsx42("div", { className: "cc-scrollbar cc-scrollbar-pink min-h-0 flex-1 space-y-2 overflow-y-auto pr-0.5", children: PRESENCE_GROUP_ORDER.map((group) => {
8958
+ /* @__PURE__ */ jsx42("div", { className: "cc-scrollbar cc-scrollbar-purple min-h-0 flex-1 space-y-2 overflow-y-auto pr-0.5", children: PRESENCE_GROUP_ORDER.map((group) => {
8686
8959
  const users = groupedChatUsers[group];
8687
8960
  if (!users.length) return null;
8688
8961
  return /* @__PURE__ */ jsxs27("section", { className: "space-y-1", children: [
@@ -8697,12 +8970,12 @@ var UserMenuCupcode = ({
8697
8970
  }
8698
8971
  ),
8699
8972
  /* @__PURE__ */ jsx42("div", { className: "space-y-1", children: users.map((user) => {
8700
- var _a74, _b7, _c2;
8973
+ var _a76, _b8, _c2;
8701
8974
  const userInitials = buildInitials(user.name, user.username);
8702
8975
  const isCurrent = user.id === activeChatUserId;
8703
- const unreadCount = (_a74 = resolvedChatUnreadByUser[user.id]) != null ? _a74 : 0;
8976
+ const unreadCount = (_a76 = resolvedChatUnreadByUser[user.id]) != null ? _a76 : 0;
8704
8977
  const hasUnread = unreadCount > 0;
8705
- const lastMessage = (_b7 = conversationMetaByUserId.get(user.id)) == null ? void 0 : _b7.lastMessage;
8978
+ const lastMessage = (_b8 = conversationMetaByUserId.get(user.id)) == null ? void 0 : _b8.lastMessage;
8706
8979
  return /* @__PURE__ */ jsxs27(
8707
8980
  "button",
8708
8981
  {
@@ -8914,16 +9187,16 @@ var UserMenuCupcode = ({
8914
9187
  {
8915
9188
  ref: chatMessagesPaneRef,
8916
9189
  onScroll: handleChatMessagesScroll,
8917
- className: "cc-scrollbar cc-scrollbar-pink relative flex-1 space-y-2 overflow-y-auto px-3 py-2.5",
9190
+ className: "cc-scrollbar cc-scrollbar-purple relative flex-1 space-y-2 overflow-y-auto px-3 py-2.5",
8918
9191
  children: [
8919
9192
  isChatLoading ? /* @__PURE__ */ jsx42("p", { className: "rounded-xl border border-dashed border-border/70 bg-background/35 px-3 py-3 text-[11px] text-muted-foreground", children: "Carregando conversa..." }) : activeChatMessages.length ? activeChatTimeline.map((item) => {
8920
- var _a74, _b7;
9193
+ var _a76, _b8;
8921
9194
  if (item.type === "day") {
8922
9195
  return /* @__PURE__ */ jsx42("div", { className: "flex justify-center py-1", children: /* @__PURE__ */ jsx42("span", { className: "inline-flex items-center rounded-full border border-border/70 bg-background/85 px-2.5 py-0.5 text-[10px] font-medium text-muted-foreground shadow-[var(--elevation-2)]", children: item.label }) }, item.key);
8923
9196
  }
8924
9197
  const { message } = item;
8925
- const replyMessage = message.replyToMessageId ? (_a74 = activeChatMessagesMap.get(message.replyToMessageId)) != null ? _a74 : null : null;
8926
- const reactions = (_b7 = reactionsByMessageId.get(message.id)) != null ? _b7 : [];
9198
+ const replyMessage = message.replyToMessageId ? (_a76 = activeChatMessagesMap.get(message.replyToMessageId)) != null ? _a76 : null : null;
9199
+ const reactions = (_b8 = reactionsByMessageId.get(message.id)) != null ? _b8 : [];
8927
9200
  const hasReadReceipt = Boolean(message.readAt);
8928
9201
  const isEditing = editingMessageId === message.id;
8929
9202
  const canEditOrDelete = message.sender === "me";
@@ -9096,7 +9369,7 @@ var UserMenuCupcode = ({
9096
9369
  "div",
9097
9370
  {
9098
9371
  ref: reactionPickerRef,
9099
- style: { top: `${(_b6 = activeReactionPicker == null ? void 0 : activeReactionPicker.top) != null ? _b6 : 0}px`, left: `${(_c = activeReactionPicker == null ? void 0 : activeReactionPicker.left) != null ? _c : 0}px` },
9372
+ style: { top: `${(_b7 = activeReactionPicker == null ? void 0 : activeReactionPicker.top) != null ? _b7 : 0}px`, left: `${(_c = activeReactionPicker == null ? void 0 : activeReactionPicker.left) != null ? _c : 0}px` },
9100
9373
  className: "absolute z-[1900] flex w-[14.35rem] items-center gap-1 whitespace-nowrap rounded-xl border border-border/70 bg-background/95 p-1.5 shadow-[var(--elevation-4)]",
9101
9374
  children: MESSAGE_REACTION_OPTIONS.map((emoji) => /* @__PURE__ */ jsx42(
9102
9375
  "button",
@@ -9252,8 +9525,8 @@ var UserMenuCupcode = ({
9252
9525
  ] })
9253
9526
  ] }),
9254
9527
  isChatSuperAdmin ? activeConversationLogs.length ? /* @__PURE__ */ jsx42("div", { className: "space-y-2", children: activeConversationLogs.map((entry) => {
9255
- var _a74;
9256
- const actorName = entry.actorId && entry.actorId === resolvedCurrentChatUserId ? "Voc\xEA" : (_a74 = entry.actorId) != null ? _a74 : "Usu\xE1rio";
9528
+ var _a76;
9529
+ const actorName = entry.actorId && entry.actorId === resolvedCurrentChatUserId ? "Voc\xEA" : (_a76 = entry.actorId) != null ? _a76 : "Usu\xE1rio";
9257
9530
  return /* @__PURE__ */ jsxs27(
9258
9531
  "article",
9259
9532
  {
@@ -9977,7 +10250,7 @@ var UserMenuCupcode = ({
9977
10250
  {
9978
10251
  className: cn(
9979
10252
  "mt-4 flex-1",
9980
- activeTab === "chat" ? "min-h-0 overflow-hidden" : "cc-scrollbar cc-scrollbar-pink overflow-y-auto pr-1"
10253
+ activeTab === "chat" ? "min-h-0 overflow-hidden" : "cc-scrollbar cc-scrollbar-purple overflow-y-auto pr-1"
9981
10254
  ),
9982
10255
  children: hasCustomPanel ? customPanel : renderDefaultPanel()
9983
10256
  }
@@ -10206,7 +10479,7 @@ var FunctionsClient = class {
10206
10479
  */
10207
10480
  invoke(functionName_1) {
10208
10481
  return __awaiter(this, arguments, void 0, function* (functionName, options = {}) {
10209
- var _a72;
10482
+ var _a74;
10210
10483
  let timeoutId;
10211
10484
  let timeoutController;
10212
10485
  try {
@@ -10272,7 +10545,7 @@ var FunctionsClient = class {
10272
10545
  if (!response.ok) {
10273
10546
  throw new FunctionsHttpError(response);
10274
10547
  }
10275
- let responseType = ((_a72 = response.headers.get("Content-Type")) !== null && _a72 !== void 0 ? _a72 : "text/plain").split(";")[0].trim();
10548
+ let responseType = ((_a74 = response.headers.get("Content-Type")) !== null && _a74 !== void 0 ? _a74 : "text/plain").split(";")[0].trim();
10276
10549
  let data;
10277
10550
  if (responseType === "application/json") {
10278
10551
  data = yield response.json();
@@ -11518,7 +11791,7 @@ var WebSocketFactory = class {
11518
11791
  constructor() {
11519
11792
  }
11520
11793
  static detectEnvironment() {
11521
- var _a72;
11794
+ var _a74;
11522
11795
  if (typeof WebSocket !== "undefined") {
11523
11796
  return { type: "native", constructor: WebSocket };
11524
11797
  }
@@ -11535,7 +11808,7 @@ var WebSocketFactory = class {
11535
11808
  workaround: "Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."
11536
11809
  };
11537
11810
  }
11538
- if (typeof globalThis !== "undefined" && globalThis.EdgeRuntime || typeof navigator !== "undefined" && ((_a72 = navigator.userAgent) === null || _a72 === void 0 ? void 0 : _a72.includes("Vercel-Edge"))) {
11811
+ if (typeof globalThis !== "undefined" && globalThis.EdgeRuntime || typeof navigator !== "undefined" && ((_a74 = navigator.userAgent) === null || _a74 === void 0 ? void 0 : _a74.includes("Vercel-Edge"))) {
11539
11812
  return {
11540
11813
  type: "unsupported",
11541
11814
  error: "Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",
@@ -11619,7 +11892,7 @@ Suggested solution: ${env.workaround}`;
11619
11892
  try {
11620
11893
  const env = this.detectEnvironment();
11621
11894
  return env.type === "native" || env.type === "ws";
11622
- } catch (_a72) {
11895
+ } catch (_a74) {
11623
11896
  return false;
11624
11897
  }
11625
11898
  }
@@ -11693,30 +11966,30 @@ var Serializer = class {
11693
11966
  return callback(JSON.stringify(payload));
11694
11967
  }
11695
11968
  _binaryEncodeUserBroadcastPush(message) {
11696
- var _a72;
11697
- if (this._isArrayBuffer((_a72 = message.payload) === null || _a72 === void 0 ? void 0 : _a72.payload)) {
11969
+ var _a74;
11970
+ if (this._isArrayBuffer((_a74 = message.payload) === null || _a74 === void 0 ? void 0 : _a74.payload)) {
11698
11971
  return this._encodeBinaryUserBroadcastPush(message);
11699
11972
  } else {
11700
11973
  return this._encodeJsonUserBroadcastPush(message);
11701
11974
  }
11702
11975
  }
11703
11976
  _encodeBinaryUserBroadcastPush(message) {
11704
- var _a72, _b6;
11705
- const userPayload = (_b6 = (_a72 = message.payload) === null || _a72 === void 0 ? void 0 : _a72.payload) !== null && _b6 !== void 0 ? _b6 : new ArrayBuffer(0);
11977
+ var _a74, _b7;
11978
+ const userPayload = (_b7 = (_a74 = message.payload) === null || _a74 === void 0 ? void 0 : _a74.payload) !== null && _b7 !== void 0 ? _b7 : new ArrayBuffer(0);
11706
11979
  return this._encodeUserBroadcastPush(message, this.BINARY_ENCODING, userPayload);
11707
11980
  }
11708
11981
  _encodeJsonUserBroadcastPush(message) {
11709
- var _a72, _b6;
11710
- const userPayload = (_b6 = (_a72 = message.payload) === null || _a72 === void 0 ? void 0 : _a72.payload) !== null && _b6 !== void 0 ? _b6 : {};
11982
+ var _a74, _b7;
11983
+ const userPayload = (_b7 = (_a74 = message.payload) === null || _a74 === void 0 ? void 0 : _a74.payload) !== null && _b7 !== void 0 ? _b7 : {};
11711
11984
  const encoder = new TextEncoder();
11712
11985
  const encodedUserPayload = encoder.encode(JSON.stringify(userPayload)).buffer;
11713
11986
  return this._encodeUserBroadcastPush(message, this.JSON_ENCODING, encodedUserPayload);
11714
11987
  }
11715
11988
  _encodeUserBroadcastPush(message, encodingType, encodedPayload) {
11716
- var _a72, _b6;
11989
+ var _a74, _b7;
11717
11990
  const topic = message.topic;
11718
- const ref = (_a72 = message.ref) !== null && _a72 !== void 0 ? _a72 : "";
11719
- const joinRef = (_b6 = message.join_ref) !== null && _b6 !== void 0 ? _b6 : "";
11991
+ const ref = (_a74 = message.ref) !== null && _a74 !== void 0 ? _a74 : "";
11992
+ const joinRef = (_b7 = message.join_ref) !== null && _b7 !== void 0 ? _b7 : "";
11720
11993
  const userEvent = message.payload.event;
11721
11994
  const rest = this.allowedMetadataKeys ? this._pick(message.payload, this.allowedMetadataKeys) : {};
11722
11995
  const metadata = Object.keys(rest).length === 0 ? "" : JSON.stringify(rest);
@@ -11802,8 +12075,8 @@ var Serializer = class {
11802
12075
  return { join_ref: null, ref: null, topic, event: this.BROADCAST_EVENT, payload: data };
11803
12076
  }
11804
12077
  _isArrayBuffer(buffer) {
11805
- var _a72;
11806
- return buffer instanceof ArrayBuffer || ((_a72 = buffer === null || buffer === void 0 ? void 0 : buffer.constructor) === null || _a72 === void 0 ? void 0 : _a72.name) === "ArrayBuffer";
12078
+ var _a74;
12079
+ return buffer instanceof ArrayBuffer || ((_a74 = buffer === null || buffer === void 0 ? void 0 : buffer.constructor) === null || _a74 === void 0 ? void 0 : _a74.name) === "ArrayBuffer";
11807
12080
  }
11808
12081
  _pick(obj, keys) {
11809
12082
  if (!obj || typeof obj !== "object") {
@@ -11867,8 +12140,8 @@ var PostgresTypes;
11867
12140
  PostgresTypes2["tstzrange"] = "tstzrange";
11868
12141
  })(PostgresTypes || (PostgresTypes = {}));
11869
12142
  var convertChangeData = (columns, record, options = {}) => {
11870
- var _a72;
11871
- const skipTypes = (_a72 = options.skipTypes) !== null && _a72 !== void 0 ? _a72 : [];
12143
+ var _a74;
12144
+ const skipTypes = (_a74 = options.skipTypes) !== null && _a74 !== void 0 ? _a74 : [];
11872
12145
  if (!record) {
11873
12146
  return {};
11874
12147
  }
@@ -11958,7 +12231,7 @@ var toJson = (value) => {
11958
12231
  if (typeof value === "string") {
11959
12232
  try {
11960
12233
  return JSON.parse(value);
11961
- } catch (_a72) {
12234
+ } catch (_a74) {
11962
12235
  return value;
11963
12236
  }
11964
12237
  }
@@ -12050,9 +12323,9 @@ var Push = class {
12050
12323
  this.payload = Object.assign(Object.assign({}, this.payload), payload);
12051
12324
  }
12052
12325
  receive(status, callback) {
12053
- var _a72;
12326
+ var _a74;
12054
12327
  if (this._hasReceived(status)) {
12055
- callback((_a72 = this.receivedResp) === null || _a72 === void 0 ? void 0 : _a72.response);
12328
+ callback((_a74 = this.receivedResp) === null || _a74 === void 0 ? void 0 : _a74.response);
12056
12329
  }
12057
12330
  this.recHooks.push({ status, callback });
12058
12331
  return this;
@@ -12243,8 +12516,8 @@ var RealtimePresence = class _RealtimePresence {
12243
12516
  };
12244
12517
  }
12245
12518
  this.map(joins, (key, newPresences) => {
12246
- var _a72;
12247
- const currentPresences = (_a72 = state[key]) !== null && _a72 !== void 0 ? _a72 : [];
12519
+ var _a74;
12520
+ const currentPresences = (_a74 = state[key]) !== null && _a74 !== void 0 ? _a74 : [];
12248
12521
  state[key] = this.cloneDeep(newPresences);
12249
12522
  if (currentPresences.length > 0) {
12250
12523
  const joinedPresenceRefs = state[key].map((m) => m.presence_ref);
@@ -12372,7 +12645,7 @@ var RealtimeChannel = class _RealtimeChannel {
12372
12645
  * ```
12373
12646
  */
12374
12647
  constructor(topic, params = { config: {} }, socket) {
12375
- var _a72, _b6;
12648
+ var _a74, _b7;
12376
12649
  this.topic = topic;
12377
12650
  this.params = params;
12378
12651
  this.socket = socket;
@@ -12431,19 +12704,19 @@ var RealtimeChannel = class _RealtimeChannel {
12431
12704
  this.presence = new RealtimePresence(this);
12432
12705
  this.broadcastEndpointURL = httpEndpointURL(this.socket.endPoint);
12433
12706
  this.private = this.params.config.private || false;
12434
- if (!this.private && ((_b6 = (_a72 = this.params.config) === null || _a72 === void 0 ? void 0 : _a72.broadcast) === null || _b6 === void 0 ? void 0 : _b6.replay)) {
12707
+ if (!this.private && ((_b7 = (_a74 = this.params.config) === null || _a74 === void 0 ? void 0 : _a74.broadcast) === null || _b7 === void 0 ? void 0 : _b7.replay)) {
12435
12708
  throw `tried to use replay on public channel '${this.topic}'. It must be a private channel.`;
12436
12709
  }
12437
12710
  }
12438
12711
  /** Subscribe registers your client with the server */
12439
12712
  subscribe(callback, timeout = this.timeout) {
12440
- var _a72, _b6, _c;
12713
+ var _a74, _b7, _c;
12441
12714
  if (!this.socket.isConnected()) {
12442
12715
  this.socket.connect();
12443
12716
  }
12444
12717
  if (this.state == CHANNEL_STATES.closed) {
12445
12718
  const { config: { broadcast, presence, private: isPrivate } } = this.params;
12446
- const postgres_changes = (_b6 = (_a72 = this.bindings.postgres_changes) === null || _a72 === void 0 ? void 0 : _a72.map((r) => r.filter)) !== null && _b6 !== void 0 ? _b6 : [];
12719
+ const postgres_changes = (_b7 = (_a74 = this.bindings.postgres_changes) === null || _a74 === void 0 ? void 0 : _a74.map((r) => r.filter)) !== null && _b7 !== void 0 ? _b7 : [];
12447
12720
  const presence_enabled = !!this.bindings[REALTIME_LISTEN_TYPES.PRESENCE] && this.bindings[REALTIME_LISTEN_TYPES.PRESENCE].length > 0 || ((_c = this.params.config.presence) === null || _c === void 0 ? void 0 : _c.enabled) === true;
12448
12721
  const accessTokenPayload = {};
12449
12722
  const config = {
@@ -12461,7 +12734,7 @@ var RealtimeChannel = class _RealtimeChannel {
12461
12734
  this.joinedOnce = true;
12462
12735
  this._rejoin(timeout);
12463
12736
  this.joinPush.receive("ok", async ({ postgres_changes: postgres_changes2 }) => {
12464
- var _a73;
12737
+ var _a75;
12465
12738
  if (!this.socket._isManualToken()) {
12466
12739
  this.socket.setAuth();
12467
12740
  }
@@ -12470,7 +12743,7 @@ var RealtimeChannel = class _RealtimeChannel {
12470
12743
  return;
12471
12744
  } else {
12472
12745
  const clientPostgresBindings = this.bindings.postgres_changes;
12473
- const bindingsLen = (_a73 = clientPostgresBindings === null || clientPostgresBindings === void 0 ? void 0 : clientPostgresBindings.length) !== null && _a73 !== void 0 ? _a73 : 0;
12746
+ const bindingsLen = (_a75 = clientPostgresBindings === null || clientPostgresBindings === void 0 ? void 0 : clientPostgresBindings.length) !== null && _a75 !== void 0 ? _a75 : 0;
12474
12747
  const newPostgresBindings = [];
12475
12748
  for (let i = 0; i < bindingsLen; i++) {
12476
12749
  const clientPostgresBinding = clientPostgresBindings[i];
@@ -12548,7 +12821,7 @@ var RealtimeChannel = class _RealtimeChannel {
12548
12821
  * @returns Promise resolving to object with success status, and error details if failed
12549
12822
  */
12550
12823
  async httpSend(event, payload, opts = {}) {
12551
- var _a72;
12824
+ var _a74;
12552
12825
  if (payload === void 0 || payload === null) {
12553
12826
  return Promise.reject("Payload is required for httpSend()");
12554
12827
  }
@@ -12573,7 +12846,7 @@ var RealtimeChannel = class _RealtimeChannel {
12573
12846
  ]
12574
12847
  })
12575
12848
  };
12576
- const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a72 = opts.timeout) !== null && _a72 !== void 0 ? _a72 : this.timeout);
12849
+ const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a74 = opts.timeout) !== null && _a74 !== void 0 ? _a74 : this.timeout);
12577
12850
  if (response.status === 202) {
12578
12851
  return { success: true };
12579
12852
  }
@@ -12581,7 +12854,7 @@ var RealtimeChannel = class _RealtimeChannel {
12581
12854
  try {
12582
12855
  const errorBody = await response.json();
12583
12856
  errorMessage = errorBody.error || errorBody.message || errorMessage;
12584
- } catch (_b6) {
12857
+ } catch (_b7) {
12585
12858
  }
12586
12859
  return Promise.reject(new Error(errorMessage));
12587
12860
  }
@@ -12595,7 +12868,7 @@ var RealtimeChannel = class _RealtimeChannel {
12595
12868
  * @param opts Options to be used during the send process
12596
12869
  */
12597
12870
  async send(args, opts = {}) {
12598
- var _a72, _b6;
12871
+ var _a74, _b7;
12599
12872
  if (!this._canPush() && args.type === "broadcast") {
12600
12873
  console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.");
12601
12874
  const { event, payload: endpoint_payload } = args;
@@ -12621,8 +12894,8 @@ var RealtimeChannel = class _RealtimeChannel {
12621
12894
  })
12622
12895
  };
12623
12896
  try {
12624
- const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a72 = opts.timeout) !== null && _a72 !== void 0 ? _a72 : this.timeout);
12625
- await ((_b6 = response.body) === null || _b6 === void 0 ? void 0 : _b6.cancel());
12897
+ const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a74 = opts.timeout) !== null && _a74 !== void 0 ? _a74 : this.timeout);
12898
+ await ((_b7 = response.body) === null || _b7 === void 0 ? void 0 : _b7.cancel());
12626
12899
  return response.ok ? "ok" : "error";
12627
12900
  } catch (error) {
12628
12901
  if (error.name === "AbortError") {
@@ -12633,9 +12906,9 @@ var RealtimeChannel = class _RealtimeChannel {
12633
12906
  }
12634
12907
  } else {
12635
12908
  return new Promise((resolve) => {
12636
- var _a73, _b7, _c;
12909
+ var _a75, _b8, _c;
12637
12910
  const push = this._push(args.type, args, opts.timeout || this.timeout);
12638
- if (args.type === "broadcast" && !((_c = (_b7 = (_a73 = this.params) === null || _a73 === void 0 ? void 0 : _a73.config) === null || _b7 === void 0 ? void 0 : _b7.broadcast) === null || _c === void 0 ? void 0 : _c.ack)) {
12911
+ if (args.type === "broadcast" && !((_c = (_b8 = (_a75 = this.params) === null || _a75 === void 0 ? void 0 : _a75.config) === null || _b8 === void 0 ? void 0 : _b8.broadcast) === null || _c === void 0 ? void 0 : _c.ack)) {
12639
12912
  resolve("ok");
12640
12913
  }
12641
12914
  push.receive("ok", () => resolve("ok"));
@@ -12754,7 +13027,7 @@ var RealtimeChannel = class _RealtimeChannel {
12754
13027
  }
12755
13028
  /** @internal */
12756
13029
  _trigger(type, payload, ref) {
12757
- var _a72, _b6;
13030
+ var _a74, _b7;
12758
13031
  const typeLower = type.toLocaleLowerCase();
12759
13032
  const { close, error, leave, join } = CHANNEL_EVENTS;
12760
13033
  const events = [close, error, leave, join];
@@ -12766,18 +13039,18 @@ var RealtimeChannel = class _RealtimeChannel {
12766
13039
  throw "channel onMessage callbacks must return the payload, modified or unmodified";
12767
13040
  }
12768
13041
  if (["insert", "update", "delete"].includes(typeLower)) {
12769
- (_a72 = this.bindings.postgres_changes) === null || _a72 === void 0 ? void 0 : _a72.filter((bind) => {
12770
- var _a73, _b7, _c;
12771
- return ((_a73 = bind.filter) === null || _a73 === void 0 ? void 0 : _a73.event) === "*" || ((_c = (_b7 = bind.filter) === null || _b7 === void 0 ? void 0 : _b7.event) === null || _c === void 0 ? void 0 : _c.toLocaleLowerCase()) === typeLower;
13042
+ (_a74 = this.bindings.postgres_changes) === null || _a74 === void 0 ? void 0 : _a74.filter((bind) => {
13043
+ var _a75, _b8, _c;
13044
+ return ((_a75 = bind.filter) === null || _a75 === void 0 ? void 0 : _a75.event) === "*" || ((_c = (_b8 = bind.filter) === null || _b8 === void 0 ? void 0 : _b8.event) === null || _c === void 0 ? void 0 : _c.toLocaleLowerCase()) === typeLower;
12772
13045
  }).map((bind) => bind.callback(handledPayload, ref));
12773
13046
  } else {
12774
- (_b6 = this.bindings[typeLower]) === null || _b6 === void 0 ? void 0 : _b6.filter((bind) => {
12775
- var _a73, _b7, _c, _d, _e, _f, _g, _h;
13047
+ (_b7 = this.bindings[typeLower]) === null || _b7 === void 0 ? void 0 : _b7.filter((bind) => {
13048
+ var _a75, _b8, _c, _d, _e, _f, _g, _h;
12776
13049
  if (["broadcast", "presence", "postgres_changes"].includes(typeLower)) {
12777
13050
  if ("id" in bind) {
12778
13051
  const bindId = bind.id;
12779
- const bindEvent = (_a73 = bind.filter) === null || _a73 === void 0 ? void 0 : _a73.event;
12780
- return bindId && ((_b7 = payload.ids) === null || _b7 === void 0 ? void 0 : _b7.includes(bindId)) && (bindEvent === "*" || (bindEvent === null || bindEvent === void 0 ? void 0 : bindEvent.toLocaleLowerCase()) === ((_c = payload.data) === null || _c === void 0 ? void 0 : _c.type.toLocaleLowerCase())) && (!((_d = bind.filter) === null || _d === void 0 ? void 0 : _d.table) || bind.filter.table === ((_e = payload.data) === null || _e === void 0 ? void 0 : _e.table));
13052
+ const bindEvent = (_a75 = bind.filter) === null || _a75 === void 0 ? void 0 : _a75.event;
13053
+ return bindId && ((_b8 = payload.ids) === null || _b8 === void 0 ? void 0 : _b8.includes(bindId)) && (bindEvent === "*" || (bindEvent === null || bindEvent === void 0 ? void 0 : bindEvent.toLocaleLowerCase()) === ((_c = payload.data) === null || _c === void 0 ? void 0 : _c.type.toLocaleLowerCase())) && (!((_d = bind.filter) === null || _d === void 0 ? void 0 : _d.table) || bind.filter.table === ((_e = payload.data) === null || _e === void 0 ? void 0 : _e.table));
12781
13054
  } else {
12782
13055
  const bindEvent = (_g = (_f = bind === null || bind === void 0 ? void 0 : bind.filter) === null || _f === void 0 ? void 0 : _f.event) === null || _g === void 0 ? void 0 : _g.toLocaleLowerCase();
12783
13056
  return bindEvent === "*" || bindEvent === ((_h = payload === null || payload === void 0 ? void 0 : payload.event) === null || _h === void 0 ? void 0 : _h.toLocaleLowerCase());
@@ -12844,8 +13117,8 @@ var RealtimeChannel = class _RealtimeChannel {
12844
13117
  const typeLower = type.toLocaleLowerCase();
12845
13118
  if (this.bindings[typeLower]) {
12846
13119
  this.bindings[typeLower] = this.bindings[typeLower].filter((bind) => {
12847
- var _a72;
12848
- return !(((_a72 = bind.type) === null || _a72 === void 0 ? void 0 : _a72.toLocaleLowerCase()) === typeLower && _RealtimeChannel.isEqual(bind.filter, filter));
13120
+ var _a74;
13121
+ return !(((_a74 = bind.type) === null || _a74 === void 0 ? void 0 : _a74.toLocaleLowerCase()) === typeLower && _RealtimeChannel.isEqual(bind.filter, filter));
12849
13122
  });
12850
13123
  }
12851
13124
  return this;
@@ -12975,7 +13248,7 @@ var RealtimeClient = class {
12975
13248
  * ```
12976
13249
  */
12977
13250
  constructor(endPoint, options) {
12978
- var _a72;
13251
+ var _a74;
12979
13252
  this.accessTokenValue = null;
12980
13253
  this.apiKey = null;
12981
13254
  this._manuallySetToken = false;
@@ -13014,7 +13287,7 @@ var RealtimeClient = class {
13014
13287
  }
13015
13288
  return (...args) => fetch(...args);
13016
13289
  };
13017
- if (!((_a72 = options === null || options === void 0 ? void 0 : options.params) === null || _a72 === void 0 ? void 0 : _a72.apikey)) {
13290
+ if (!((_a74 = options === null || options === void 0 ? void 0 : options.params) === null || _a74 === void 0 ? void 0 : _a74.apikey)) {
13018
13291
  throw new Error("API key is required to connect to Realtime");
13019
13292
  }
13020
13293
  this.apiKey = options.params.apikey;
@@ -13196,8 +13469,8 @@ Option 2: Install and provide the "ws" package:
13196
13469
  const { topic, event, payload, ref } = data;
13197
13470
  const callback = () => {
13198
13471
  this.encode(data, (result) => {
13199
- var _a72;
13200
- (_a72 = this.conn) === null || _a72 === void 0 ? void 0 : _a72.send(result);
13472
+ var _a74;
13473
+ (_a74 = this.conn) === null || _a74 === void 0 ? void 0 : _a74.send(result);
13201
13474
  });
13202
13475
  };
13203
13476
  this.log("push", `${topic} ${event} (${ref})`, payload);
@@ -13247,7 +13520,7 @@ Option 2: Install and provide the "ws" package:
13247
13520
  * Sends a heartbeat message if the socket is connected.
13248
13521
  */
13249
13522
  async sendHeartbeat() {
13250
- var _a72;
13523
+ var _a74;
13251
13524
  if (!this.isConnected()) {
13252
13525
  try {
13253
13526
  this.heartbeatCallback("disconnected");
@@ -13266,11 +13539,11 @@ Option 2: Install and provide the "ws" package:
13266
13539
  this.log("error", "error in heartbeat callback", e);
13267
13540
  }
13268
13541
  this._wasManualDisconnect = false;
13269
- (_a72 = this.conn) === null || _a72 === void 0 ? void 0 : _a72.close(WS_CLOSE_NORMAL, "heartbeat timeout");
13542
+ (_a74 = this.conn) === null || _a74 === void 0 ? void 0 : _a74.close(WS_CLOSE_NORMAL, "heartbeat timeout");
13270
13543
  setTimeout(() => {
13271
- var _a73;
13544
+ var _a75;
13272
13545
  if (!this.isConnected()) {
13273
- (_a73 = this.reconnectTimer) === null || _a73 === void 0 ? void 0 : _a73.scheduleTimeout();
13546
+ (_a75 = this.reconnectTimer) === null || _a75 === void 0 ? void 0 : _a75.scheduleTimeout();
13274
13547
  }
13275
13548
  }, CONNECTION_TIMEOUTS.HEARTBEAT_TIMEOUT_FALLBACK);
13276
13549
  return;
@@ -13368,12 +13641,12 @@ Option 2: Install and provide the "ws" package:
13368
13641
  * @internal
13369
13642
  */
13370
13643
  _clearTimer(timer) {
13371
- var _a72;
13644
+ var _a74;
13372
13645
  if (timer === "heartbeat" && this.heartbeatTimer) {
13373
13646
  clearInterval(this.heartbeatTimer);
13374
13647
  this.heartbeatTimer = void 0;
13375
13648
  } else if (timer === "reconnect") {
13376
- (_a72 = this.reconnectTimer) === null || _a72 === void 0 ? void 0 : _a72.reset();
13649
+ (_a74 = this.reconnectTimer) === null || _a74 === void 0 ? void 0 : _a74.reset();
13377
13650
  }
13378
13651
  }
13379
13652
  /**
@@ -13488,13 +13761,13 @@ Option 2: Install and provide the "ws" package:
13488
13761
  }
13489
13762
  /** @internal */
13490
13763
  _onConnClose(event) {
13491
- var _a72;
13764
+ var _a74;
13492
13765
  this._setConnectionState("disconnected");
13493
13766
  this.log("transport", "close", event);
13494
13767
  this._triggerChanError();
13495
13768
  this._clearTimer("heartbeat");
13496
13769
  if (!this._wasManualDisconnect) {
13497
- (_a72 = this.reconnectTimer) === null || _a72 === void 0 ? void 0 : _a72.scheduleTimeout();
13770
+ (_a74 = this.reconnectTimer) === null || _a74 === void 0 ? void 0 : _a74.scheduleTimeout();
13498
13771
  }
13499
13772
  this._triggerStateCallbacks("close", event);
13500
13773
  }
@@ -13637,9 +13910,9 @@ Option 2: Install and provide the "ws" package:
13637
13910
  * @internal
13638
13911
  */
13639
13912
  _initializeOptions(options) {
13640
- var _a72, _b6, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
13641
- this.transport = (_a72 = options === null || options === void 0 ? void 0 : options.transport) !== null && _a72 !== void 0 ? _a72 : null;
13642
- this.timeout = (_b6 = options === null || options === void 0 ? void 0 : options.timeout) !== null && _b6 !== void 0 ? _b6 : DEFAULT_TIMEOUT;
13913
+ var _a74, _b7, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
13914
+ this.transport = (_a74 = options === null || options === void 0 ? void 0 : options.transport) !== null && _a74 !== void 0 ? _a74 : null;
13915
+ this.timeout = (_b7 = options === null || options === void 0 ? void 0 : options.timeout) !== null && _b7 !== void 0 ? _b7 : DEFAULT_TIMEOUT;
13643
13916
  this.heartbeatIntervalMs = (_c = options === null || options === void 0 ? void 0 : options.heartbeatIntervalMs) !== null && _c !== void 0 ? _c : CONNECTION_TIMEOUTS.HEARTBEAT_INTERVAL;
13644
13917
  this.worker = (_d = options === null || options === void 0 ? void 0 : options.worker) !== null && _d !== void 0 ? _d : false;
13645
13918
  this.accessToken = (_e = options === null || options === void 0 ? void 0 : options.accessToken) !== null && _e !== void 0 ? _e : null;
@@ -13684,14 +13957,14 @@ Option 2: Install and provide the "ws" package:
13684
13957
  // node_modules/iceberg-js/dist/index.mjs
13685
13958
  var IcebergError = class extends Error {
13686
13959
  constructor(message, opts) {
13687
- var _a72;
13960
+ var _a74;
13688
13961
  super(message);
13689
13962
  this.name = "IcebergError";
13690
13963
  this.status = opts.status;
13691
13964
  this.icebergType = opts.icebergType;
13692
13965
  this.icebergCode = opts.icebergCode;
13693
13966
  this.details = opts.details;
13694
- this.isCommitStateUnknown = opts.icebergType === "CommitStateUnknownException" || [500, 502, 504].includes(opts.status) && ((_a72 = opts.icebergType) == null ? void 0 : _a72.includes("CommitState")) === true;
13967
+ this.isCommitStateUnknown = opts.icebergType === "CommitStateUnknownException" || [500, 502, 504].includes(opts.status) && ((_a74 = opts.icebergType) == null ? void 0 : _a74.includes("CommitState")) === true;
13695
13968
  }
13696
13969
  /**
13697
13970
  * Returns true if the error is a 404 Not Found error.
@@ -13739,8 +14012,8 @@ async function buildAuthHeaders(auth) {
13739
14012
  return {};
13740
14013
  }
13741
14014
  function createFetchClient(options) {
13742
- var _a72;
13743
- const fetchFn = (_a72 = options.fetchImpl) != null ? _a72 : globalThis.fetch;
14015
+ var _a74;
14016
+ const fetchFn = (_a74 = options.fetchImpl) != null ? _a74 : globalThis.fetch;
13744
14017
  return {
13745
14018
  async request({
13746
14019
  method,
@@ -13749,7 +14022,7 @@ function createFetchClient(options) {
13749
14022
  body,
13750
14023
  headers
13751
14024
  }) {
13752
- var _a73;
14025
+ var _a75;
13753
14026
  const url = buildUrl(options.baseUrl, path, query);
13754
14027
  const authHeaders = await buildAuthHeaders(options.auth);
13755
14028
  const res = await fetchFn(url, {
@@ -13768,7 +14041,7 @@ function createFetchClient(options) {
13768
14041
  const errBody = isJson ? data : void 0;
13769
14042
  const errorDetail = errBody == null ? void 0 : errBody.error;
13770
14043
  throw new IcebergError(
13771
- (_a73 = errorDetail == null ? void 0 : errorDetail.message) != null ? _a73 : `Request failed with status ${res.status}`,
14044
+ (_a75 = errorDetail == null ? void 0 : errorDetail.message) != null ? _a75 : `Request failed with status ${res.status}`,
13772
14045
  {
13773
14046
  status: res.status,
13774
14047
  icebergType: errorDetail == null ? void 0 : errorDetail.type,
@@ -13891,11 +14164,11 @@ var TableOperations = class {
13891
14164
  };
13892
14165
  }
13893
14166
  async dropTable(id, options) {
13894
- var _a72;
14167
+ var _a74;
13895
14168
  await this.client.request({
13896
14169
  method: "DELETE",
13897
14170
  path: `${this.prefix}/namespaces/${namespaceToPath2(id.namespace)}/tables/${id.name}`,
13898
- query: { purgeRequested: String((_a72 = options == null ? void 0 : options.purge) != null ? _a72 : false) }
14171
+ query: { purgeRequested: String((_a74 = options == null ? void 0 : options.purge) != null ? _a74 : false) }
13899
14172
  });
13900
14173
  }
13901
14174
  async loadTable(id) {
@@ -13947,7 +14220,7 @@ var IcebergRestCatalog = class {
13947
14220
  * @param options - Configuration options for the catalog client
13948
14221
  */
13949
14222
  constructor(options) {
13950
- var _a72;
14223
+ var _a74;
13951
14224
  let prefix = "v1";
13952
14225
  if (options.catalogName) {
13953
14226
  prefix += `/${options.catalogName}`;
@@ -13958,7 +14231,7 @@ var IcebergRestCatalog = class {
13958
14231
  auth: options.auth,
13959
14232
  fetchImpl: options.fetch
13960
14233
  });
13961
- this.accessDelegation = (_a72 = options.accessDelegation) == null ? void 0 : _a72.join(",");
14234
+ this.accessDelegation = (_a74 = options.accessDelegation) == null ? void 0 : _a74.join(",");
13962
14235
  this.namespaceOps = new NamespaceOperations(this.client, prefix);
13963
14236
  this.tableOps = new TableOperations(this.client, prefix, this.accessDelegation);
13964
14237
  }
@@ -17297,7 +17570,7 @@ var getItemAsync = async (storage, key) => {
17297
17570
  }
17298
17571
  try {
17299
17572
  return JSON.parse(value);
17300
- } catch (_a72) {
17573
+ } catch (_a74) {
17301
17574
  return value;
17302
17575
  }
17303
17576
  };
@@ -17451,9 +17724,9 @@ function getAlgorithm(alg) {
17451
17724
  throw new Error("Invalid alg claim");
17452
17725
  }
17453
17726
  }
17454
- var UUID_REGEX3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
17727
+ var UUID_REGEX4 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
17455
17728
  function validateUUID(str) {
17456
- if (!UUID_REGEX3.test(str)) {
17729
+ if (!UUID_REGEX4.test(str)) {
17457
17730
  throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not");
17458
17731
  }
17459
17732
  }
@@ -17508,7 +17781,7 @@ function deepClone(obj) {
17508
17781
  var _getErrorMessage2 = (err) => err.msg || err.message || err.error_description || err.error || JSON.stringify(err);
17509
17782
  var NETWORK_ERROR_CODES = [502, 503, 504];
17510
17783
  async function handleError2(error) {
17511
- var _a72;
17784
+ var _a74;
17512
17785
  if (!looksLikeFetchResponse(error)) {
17513
17786
  throw new AuthRetryableFetchError(_getErrorMessage2(error), 0);
17514
17787
  }
@@ -17533,7 +17806,7 @@ async function handleError2(error) {
17533
17806
  throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, data.weak_password.reasons);
17534
17807
  }
17535
17808
  } else if (errorCode === "weak_password") {
17536
- throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, ((_a72 = data.weak_password) === null || _a72 === void 0 ? void 0 : _a72.reasons) || []);
17809
+ throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, ((_a74 = data.weak_password) === null || _a74 === void 0 ? void 0 : _a74.reasons) || []);
17537
17810
  } else if (errorCode === "session_not_found") {
17538
17811
  throw new AuthSessionMissingError();
17539
17812
  }
@@ -17549,7 +17822,7 @@ var _getRequestParams2 = (method, options, parameters, body) => {
17549
17822
  return Object.assign(Object.assign({}, params), parameters);
17550
17823
  };
17551
17824
  async function _request(fetcher, method, url, options) {
17552
- var _a72;
17825
+ var _a74;
17553
17826
  const headers = Object.assign({}, options === null || options === void 0 ? void 0 : options.headers);
17554
17827
  if (!headers[API_VERSION_HEADER_NAME]) {
17555
17828
  headers[API_VERSION_HEADER_NAME] = API_VERSIONS["2024-01-01"].name;
@@ -17557,7 +17830,7 @@ async function _request(fetcher, method, url, options) {
17557
17830
  if (options === null || options === void 0 ? void 0 : options.jwt) {
17558
17831
  headers["Authorization"] = `Bearer ${options.jwt}`;
17559
17832
  }
17560
- const qs = (_a72 = options === null || options === void 0 ? void 0 : options.query) !== null && _a72 !== void 0 ? _a72 : {};
17833
+ const qs = (_a74 = options === null || options === void 0 ? void 0 : options.query) !== null && _a74 !== void 0 ? _a74 : {};
17561
17834
  if (options === null || options === void 0 ? void 0 : options.redirectTo) {
17562
17835
  qs["redirect_to"] = options.redirectTo;
17563
17836
  }
@@ -17590,7 +17863,7 @@ async function _handleRequest2(fetcher, method, url, options, parameters, body)
17590
17863
  }
17591
17864
  }
17592
17865
  function _sessionResponse(data) {
17593
- var _a72;
17866
+ var _a74;
17594
17867
  let session = null;
17595
17868
  if (hasSession(data)) {
17596
17869
  session = Object.assign({}, data);
@@ -17598,7 +17871,7 @@ function _sessionResponse(data) {
17598
17871
  session.expires_at = expiresAt(data.expires_in);
17599
17872
  }
17600
17873
  }
17601
- const user = (_a72 = data.user) !== null && _a72 !== void 0 ? _a72 : data;
17874
+ const user = (_a74 = data.user) !== null && _a74 !== void 0 ? _a74 : data;
17602
17875
  return { data: { session, user }, error: null };
17603
17876
  }
17604
17877
  function _sessionResponsePassword(data) {
@@ -17609,8 +17882,8 @@ function _sessionResponsePassword(data) {
17609
17882
  return response;
17610
17883
  }
17611
17884
  function _userResponse(data) {
17612
- var _a72;
17613
- const user = (_a72 = data.user) !== null && _a72 !== void 0 ? _a72 : data;
17885
+ var _a74;
17886
+ const user = (_a74 = data.user) !== null && _a74 !== void 0 ? _a74 : data;
17614
17887
  return { data: { user }, error: null };
17615
17888
  }
17616
17889
  function _ssoResponse(data) {
@@ -17779,14 +18052,14 @@ var GoTrueAdminApi = class {
17779
18052
  * @param params An object which supports `page` and `perPage` as numbers, to alter the paginated results.
17780
18053
  */
17781
18054
  async listUsers(params) {
17782
- var _a72, _b6, _c, _d, _e, _f, _g;
18055
+ var _a74, _b7, _c, _d, _e, _f, _g;
17783
18056
  try {
17784
18057
  const pagination = { nextPage: null, lastPage: 0, total: 0 };
17785
18058
  const response = await _request(this.fetch, "GET", `${this.url}/admin/users`, {
17786
18059
  headers: this.headers,
17787
18060
  noResolveJson: true,
17788
18061
  query: {
17789
- page: (_b6 = (_a72 = params === null || params === void 0 ? void 0 : params.page) === null || _a72 === void 0 ? void 0 : _a72.toString()) !== null && _b6 !== void 0 ? _b6 : "",
18062
+ page: (_b7 = (_a74 = params === null || params === void 0 ? void 0 : params.page) === null || _a74 === void 0 ? void 0 : _a74.toString()) !== null && _b7 !== void 0 ? _b7 : "",
17790
18063
  per_page: (_d = (_c = params === null || params === void 0 ? void 0 : params.perPage) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : ""
17791
18064
  },
17792
18065
  xform: _noResolveJsonResponse
@@ -17920,14 +18193,14 @@ var GoTrueAdminApi = class {
17920
18193
  * This function should only be called on a server. Never expose your `service_role` key in the browser.
17921
18194
  */
17922
18195
  async _listOAuthClients(params) {
17923
- var _a72, _b6, _c, _d, _e, _f, _g;
18196
+ var _a74, _b7, _c, _d, _e, _f, _g;
17924
18197
  try {
17925
18198
  const pagination = { nextPage: null, lastPage: 0, total: 0 };
17926
18199
  const response = await _request(this.fetch, "GET", `${this.url}/admin/oauth/clients`, {
17927
18200
  headers: this.headers,
17928
18201
  noResolveJson: true,
17929
18202
  query: {
17930
- page: (_b6 = (_a72 = params === null || params === void 0 ? void 0 : params.page) === null || _a72 === void 0 ? void 0 : _a72.toString()) !== null && _b6 !== void 0 ? _b6 : "",
18203
+ page: (_b7 = (_a74 = params === null || params === void 0 ? void 0 : params.page) === null || _a74 === void 0 ? void 0 : _a74.toString()) !== null && _b7 !== void 0 ? _b7 : "",
17931
18204
  per_page: (_d = (_c = params === null || params === void 0 ? void 0 : params.perPage) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : ""
17932
18205
  },
17933
18206
  xform: _noResolveJsonResponse
@@ -18180,7 +18453,7 @@ function toHex(value) {
18180
18453
  return "0x" + hex;
18181
18454
  }
18182
18455
  function createSiweMessage(parameters) {
18183
- var _a72;
18456
+ var _a74;
18184
18457
  const { chainId, domain, expirationTime, issuedAt = /* @__PURE__ */ new Date(), nonce, notBefore, requestId, resources, scheme, uri, version: version5 } = parameters;
18185
18458
  {
18186
18459
  if (!Number.isInteger(chainId))
@@ -18193,7 +18466,7 @@ function createSiweMessage(parameters) {
18193
18466
  throw new Error(`@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.`);
18194
18467
  if (version5 !== "1")
18195
18468
  throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${version5}`);
18196
- if ((_a72 = parameters.statement) === null || _a72 === void 0 ? void 0 : _a72.includes("\n"))
18469
+ if ((_a74 = parameters.statement) === null || _a74 === void 0 ? void 0 : _a74.includes("\n"))
18197
18470
  throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${parameters.statement}`);
18198
18471
  }
18199
18472
  const address = getAddress(parameters.address);
@@ -18235,10 +18508,10 @@ ${suffix}`;
18235
18508
  // node_modules/@supabase/auth-js/dist/module/lib/webauthn.errors.js
18236
18509
  var WebAuthnError = class extends Error {
18237
18510
  constructor({ message, code, cause, name }) {
18238
- var _a72;
18511
+ var _a74;
18239
18512
  super(message, { cause });
18240
18513
  this.__isWebAuthnError = true;
18241
- this.name = (_a72 = name !== null && name !== void 0 ? name : cause instanceof Error ? cause.name : void 0) !== null && _a72 !== void 0 ? _a72 : "Unknown Error";
18514
+ this.name = (_a74 = name !== null && name !== void 0 ? name : cause instanceof Error ? cause.name : void 0) !== null && _a74 !== void 0 ? _a74 : "Unknown Error";
18242
18515
  this.code = code;
18243
18516
  }
18244
18517
  };
@@ -18254,7 +18527,7 @@ var WebAuthnUnknownError = class extends WebAuthnError {
18254
18527
  }
18255
18528
  };
18256
18529
  function identifyRegistrationError({ error, options }) {
18257
- var _a72, _b6, _c;
18530
+ var _a74, _b7, _c;
18258
18531
  const { publicKey } = options;
18259
18532
  if (!publicKey) {
18260
18533
  throw Error("options was missing required publicKey property");
@@ -18268,7 +18541,7 @@ function identifyRegistrationError({ error, options }) {
18268
18541
  });
18269
18542
  }
18270
18543
  } else if (error.name === "ConstraintError") {
18271
- if (((_a72 = publicKey.authenticatorSelection) === null || _a72 === void 0 ? void 0 : _a72.requireResidentKey) === true) {
18544
+ if (((_a74 = publicKey.authenticatorSelection) === null || _a74 === void 0 ? void 0 : _a74.requireResidentKey) === true) {
18272
18545
  return new WebAuthnError({
18273
18546
  message: "Discoverable credentials were required but no available authenticator supported it",
18274
18547
  code: "ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",
@@ -18276,7 +18549,7 @@ function identifyRegistrationError({ error, options }) {
18276
18549
  });
18277
18550
  } else if (
18278
18551
  // @ts-ignore: `mediation` doesn't yet exist on CredentialCreationOptions but it's possible as of Sept 2024
18279
- options.mediation === "conditional" && ((_b6 = publicKey.authenticatorSelection) === null || _b6 === void 0 ? void 0 : _b6.userVerification) === "required"
18552
+ options.mediation === "conditional" && ((_b7 = publicKey.authenticatorSelection) === null || _b7 === void 0 ? void 0 : _b7.userVerification) === "required"
18280
18553
  ) {
18281
18554
  return new WebAuthnError({
18282
18555
  message: "User verification was required during automatic registration but it could not be performed",
@@ -18497,7 +18770,7 @@ function deserializeCredentialRequestOptions(options) {
18497
18770
  return result;
18498
18771
  }
18499
18772
  function serializeCredentialCreationResponse(credential) {
18500
- var _a72;
18773
+ var _a74;
18501
18774
  if ("toJSON" in credential && typeof credential.toJSON === "function") {
18502
18775
  return credential.toJSON();
18503
18776
  }
@@ -18512,11 +18785,11 @@ function serializeCredentialCreationResponse(credential) {
18512
18785
  type: "public-key",
18513
18786
  clientExtensionResults: credential.getClientExtensionResults(),
18514
18787
  // Convert null to undefined and cast to AuthenticatorAttachment type
18515
- authenticatorAttachment: (_a72 = credentialWithAttachment.authenticatorAttachment) !== null && _a72 !== void 0 ? _a72 : void 0
18788
+ authenticatorAttachment: (_a74 = credentialWithAttachment.authenticatorAttachment) !== null && _a74 !== void 0 ? _a74 : void 0
18516
18789
  };
18517
18790
  }
18518
18791
  function serializeCredentialRequestResponse(credential) {
18519
- var _a72;
18792
+ var _a74;
18520
18793
  if ("toJSON" in credential && typeof credential.toJSON === "function") {
18521
18794
  return credential.toJSON();
18522
18795
  }
@@ -18536,7 +18809,7 @@ function serializeCredentialRequestResponse(credential) {
18536
18809
  type: "public-key",
18537
18810
  clientExtensionResults,
18538
18811
  // Convert null to undefined and cast to AuthenticatorAttachment type
18539
- authenticatorAttachment: (_a72 = credentialWithAttachment.authenticatorAttachment) !== null && _a72 !== void 0 ? _a72 : void 0
18812
+ authenticatorAttachment: (_a74 = credentialWithAttachment.authenticatorAttachment) !== null && _a74 !== void 0 ? _a74 : void 0
18540
18813
  };
18541
18814
  }
18542
18815
  function isValidDomain(hostname) {
@@ -18546,8 +18819,8 @@ function isValidDomain(hostname) {
18546
18819
  );
18547
18820
  }
18548
18821
  function browserSupportsWebAuthn() {
18549
- var _a72, _b6;
18550
- return !!(isBrowser() && "PublicKeyCredential" in window && window.PublicKeyCredential && "credentials" in navigator && typeof ((_a72 = navigator === null || navigator === void 0 ? void 0 : navigator.credentials) === null || _a72 === void 0 ? void 0 : _a72.create) === "function" && typeof ((_b6 = navigator === null || navigator === void 0 ? void 0 : navigator.credentials) === null || _b6 === void 0 ? void 0 : _b6.get) === "function");
18822
+ var _a74, _b7;
18823
+ return !!(isBrowser() && "PublicKeyCredential" in window && window.PublicKeyCredential && "credentials" in navigator && typeof ((_a74 = navigator === null || navigator === void 0 ? void 0 : navigator.credentials) === null || _a74 === void 0 ? void 0 : _a74.create) === "function" && typeof ((_b7 = navigator === null || navigator === void 0 ? void 0 : navigator.credentials) === null || _b7 === void 0 ? void 0 : _b7.get) === "function");
18551
18824
  }
18552
18825
  async function createCredential(options) {
18553
18826
  try {
@@ -18876,8 +19149,8 @@ var WebAuthnApi = class {
18876
19149
  });
18877
19150
  if (!factor) {
18878
19151
  await this.client.mfa.listFactors().then((factors) => {
18879
- var _a72;
18880
- return (_a72 = factors.data) === null || _a72 === void 0 ? void 0 : _a72.all.find((v) => v.factor_type === "webauthn" && v.friendly_name === friendlyName && v.status !== "unverified");
19152
+ var _a74;
19153
+ return (_a74 = factors.data) === null || _a74 === void 0 ? void 0 : _a74.all.find((v) => v.factor_type === "webauthn" && v.friendly_name === friendlyName && v.status !== "unverified");
18881
19154
  }).then((factor2) => factor2 ? this.client.mfa.unenroll({ factorId: factor2 === null || factor2 === void 0 ? void 0 : factor2.id }) : void 0);
18882
19155
  return { data: null, error: enrollError };
18883
19156
  }
@@ -18939,15 +19212,15 @@ var GoTrueClient = class _GoTrueClient {
18939
19212
  * The JWKS used for verifying asymmetric JWTs
18940
19213
  */
18941
19214
  get jwks() {
18942
- var _a72, _b6;
18943
- return (_b6 = (_a72 = GLOBAL_JWKS[this.storageKey]) === null || _a72 === void 0 ? void 0 : _a72.jwks) !== null && _b6 !== void 0 ? _b6 : { keys: [] };
19215
+ var _a74, _b7;
19216
+ return (_b7 = (_a74 = GLOBAL_JWKS[this.storageKey]) === null || _a74 === void 0 ? void 0 : _a74.jwks) !== null && _b7 !== void 0 ? _b7 : { keys: [] };
18944
19217
  }
18945
19218
  set jwks(value) {
18946
19219
  GLOBAL_JWKS[this.storageKey] = Object.assign(Object.assign({}, GLOBAL_JWKS[this.storageKey]), { jwks: value });
18947
19220
  }
18948
19221
  get jwks_cached_at() {
18949
- var _a72, _b6;
18950
- return (_b6 = (_a72 = GLOBAL_JWKS[this.storageKey]) === null || _a72 === void 0 ? void 0 : _a72.cachedAt) !== null && _b6 !== void 0 ? _b6 : Number.MIN_SAFE_INTEGER;
19222
+ var _a74, _b7;
19223
+ return (_b7 = (_a74 = GLOBAL_JWKS[this.storageKey]) === null || _a74 === void 0 ? void 0 : _a74.cachedAt) !== null && _b7 !== void 0 ? _b7 : Number.MIN_SAFE_INTEGER;
18951
19224
  }
18952
19225
  set jwks_cached_at(value) {
18953
19226
  GLOBAL_JWKS[this.storageKey] = Object.assign(Object.assign({}, GLOBAL_JWKS[this.storageKey]), { cachedAt: value });
@@ -18967,7 +19240,7 @@ var GoTrueClient = class _GoTrueClient {
18967
19240
  * ```
18968
19241
  */
18969
19242
  constructor(options) {
18970
- var _a72, _b6, _c;
19243
+ var _a74, _b7, _c;
18971
19244
  this.userStorage = null;
18972
19245
  this.memoryStorage = null;
18973
19246
  this.stateChangeEmitters = /* @__PURE__ */ new Map();
@@ -18985,7 +19258,7 @@ var GoTrueClient = class _GoTrueClient {
18985
19258
  this.logger = console.log;
18986
19259
  const settings = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options);
18987
19260
  this.storageKey = settings.storageKey;
18988
- this.instanceID = (_a72 = _GoTrueClient.nextInstanceID[this.storageKey]) !== null && _a72 !== void 0 ? _a72 : 0;
19261
+ this.instanceID = (_a74 = _GoTrueClient.nextInstanceID[this.storageKey]) !== null && _a74 !== void 0 ? _a74 : 0;
18989
19262
  _GoTrueClient.nextInstanceID[this.storageKey] = this.instanceID + 1;
18990
19263
  this.logDebugMessages = !!settings.debug;
18991
19264
  if (typeof settings.debug === "function") {
@@ -19016,7 +19289,7 @@ var GoTrueClient = class _GoTrueClient {
19016
19289
  this.lockAcquireTimeout = settings.lockAcquireTimeout;
19017
19290
  if (settings.lock) {
19018
19291
  this.lock = settings.lock;
19019
- } else if (this.persistSession && isBrowser() && ((_b6 = globalThis === null || globalThis === void 0 ? void 0 : globalThis.navigator) === null || _b6 === void 0 ? void 0 : _b6.locks)) {
19292
+ } else if (this.persistSession && isBrowser() && ((_b7 = globalThis === null || globalThis === void 0 ? void 0 : globalThis.navigator) === null || _b7 === void 0 ? void 0 : _b7.locks)) {
19020
19293
  this.lock = navigatorLock;
19021
19294
  } else {
19022
19295
  this.lock = lockNoOp;
@@ -19122,7 +19395,7 @@ var GoTrueClient = class _GoTrueClient {
19122
19395
  * the whole lifetime of the client
19123
19396
  */
19124
19397
  async _initialize() {
19125
- var _a72;
19398
+ var _a74;
19126
19399
  try {
19127
19400
  let params = {};
19128
19401
  let callbackUrlType = "none";
@@ -19139,7 +19412,7 @@ var GoTrueClient = class _GoTrueClient {
19139
19412
  if (error) {
19140
19413
  this._debug("#_initialize()", "error detecting session from URL", error);
19141
19414
  if (isAuthImplicitGrantRedirectError(error)) {
19142
- const errorCode = (_a72 = error.details) === null || _a72 === void 0 ? void 0 : _a72.code;
19415
+ const errorCode = (_a74 = error.details) === null || _a74 === void 0 ? void 0 : _a74.code;
19143
19416
  if (errorCode === "identity_already_exists" || errorCode === "identity_not_found" || errorCode === "single_identity_not_deletable") {
19144
19417
  return { error };
19145
19418
  }
@@ -19178,12 +19451,12 @@ var GoTrueClient = class _GoTrueClient {
19178
19451
  * @returns A session where the is_anonymous claim in the access token JWT set to true
19179
19452
  */
19180
19453
  async signInAnonymously(credentials) {
19181
- var _a72, _b6, _c;
19454
+ var _a74, _b7, _c;
19182
19455
  try {
19183
19456
  const res = await _request(this.fetch, "POST", `${this.url}/signup`, {
19184
19457
  headers: this.headers,
19185
19458
  body: {
19186
- data: (_b6 = (_a72 = credentials === null || credentials === void 0 ? void 0 : credentials.options) === null || _a72 === void 0 ? void 0 : _a72.data) !== null && _b6 !== void 0 ? _b6 : {},
19459
+ data: (_b7 = (_a74 = credentials === null || credentials === void 0 ? void 0 : credentials.options) === null || _a74 === void 0 ? void 0 : _a74.data) !== null && _b7 !== void 0 ? _b7 : {},
19187
19460
  gotrue_meta_security: { captcha_token: (_c = credentials === null || credentials === void 0 ? void 0 : credentials.options) === null || _c === void 0 ? void 0 : _c.captchaToken }
19188
19461
  },
19189
19462
  xform: _sessionResponse
@@ -19217,7 +19490,7 @@ var GoTrueClient = class _GoTrueClient {
19217
19490
  * @returns A user if the server has "autoconfirm" OFF
19218
19491
  */
19219
19492
  async signUp(credentials) {
19220
- var _a72, _b6, _c;
19493
+ var _a74, _b7, _c;
19221
19494
  try {
19222
19495
  let res;
19223
19496
  if ("email" in credentials) {
@@ -19234,7 +19507,7 @@ var GoTrueClient = class _GoTrueClient {
19234
19507
  body: {
19235
19508
  email,
19236
19509
  password,
19237
- data: (_a72 = options === null || options === void 0 ? void 0 : options.data) !== null && _a72 !== void 0 ? _a72 : {},
19510
+ data: (_a74 = options === null || options === void 0 ? void 0 : options.data) !== null && _a74 !== void 0 ? _a74 : {},
19238
19511
  gotrue_meta_security: { captcha_token: options === null || options === void 0 ? void 0 : options.captchaToken },
19239
19512
  code_challenge: codeChallenge,
19240
19513
  code_challenge_method: codeChallengeMethod
@@ -19248,7 +19521,7 @@ var GoTrueClient = class _GoTrueClient {
19248
19521
  body: {
19249
19522
  phone,
19250
19523
  password,
19251
- data: (_b6 = options === null || options === void 0 ? void 0 : options.data) !== null && _b6 !== void 0 ? _b6 : {},
19524
+ data: (_b7 = options === null || options === void 0 ? void 0 : options.data) !== null && _b7 !== void 0 ? _b7 : {},
19252
19525
  channel: (_c = options === null || options === void 0 ? void 0 : options.channel) !== null && _c !== void 0 ? _c : "sms",
19253
19526
  gotrue_meta_security: { captcha_token: options === null || options === void 0 ? void 0 : options.captchaToken }
19254
19527
  },
@@ -19340,10 +19613,10 @@ var GoTrueClient = class _GoTrueClient {
19340
19613
  * This method supports the PKCE flow.
19341
19614
  */
19342
19615
  async signInWithOAuth(credentials) {
19343
- var _a72, _b6, _c, _d;
19616
+ var _a74, _b7, _c, _d;
19344
19617
  return await this._handleProviderSignIn(credentials.provider, {
19345
- redirectTo: (_a72 = credentials.options) === null || _a72 === void 0 ? void 0 : _a72.redirectTo,
19346
- scopes: (_b6 = credentials.options) === null || _b6 === void 0 ? void 0 : _b6.scopes,
19618
+ redirectTo: (_a74 = credentials.options) === null || _a74 === void 0 ? void 0 : _a74.redirectTo,
19619
+ scopes: (_b7 = credentials.options) === null || _b7 === void 0 ? void 0 : _b7.scopes,
19347
19620
  queryParams: (_c = credentials.options) === null || _c === void 0 ? void 0 : _c.queryParams,
19348
19621
  skipBrowserRedirect: (_d = credentials.options) === null || _d === void 0 ? void 0 : _d.skipBrowserRedirect
19349
19622
  });
@@ -19376,7 +19649,7 @@ var GoTrueClient = class _GoTrueClient {
19376
19649
  }
19377
19650
  }
19378
19651
  async signInWithEthereum(credentials) {
19379
- var _a72, _b6, _c, _d, _e, _f, _g, _h, _j, _k, _l;
19652
+ var _a74, _b7, _c, _d, _e, _f, _g, _h, _j, _k, _l;
19380
19653
  let message;
19381
19654
  let signature;
19382
19655
  if ("message" in credentials) {
@@ -19400,7 +19673,7 @@ var GoTrueClient = class _GoTrueClient {
19400
19673
  throw new Error(`@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.`);
19401
19674
  }
19402
19675
  }
19403
- const url = new URL((_a72 = options === null || options === void 0 ? void 0 : options.url) !== null && _a72 !== void 0 ? _a72 : window.location.href);
19676
+ const url = new URL((_a74 = options === null || options === void 0 ? void 0 : options.url) !== null && _a74 !== void 0 ? _a74 : window.location.href);
19404
19677
  const accounts = await resolvedWallet.request({
19405
19678
  method: "eth_requestAccounts"
19406
19679
  }).then((accs) => accs).catch(() => {
@@ -19410,7 +19683,7 @@ var GoTrueClient = class _GoTrueClient {
19410
19683
  throw new Error(`@supabase/auth-js: No accounts available. Please ensure the wallet is connected.`);
19411
19684
  }
19412
19685
  const address = getAddress(accounts[0]);
19413
- let chainId = (_b6 = options === null || options === void 0 ? void 0 : options.signInWithEthereum) === null || _b6 === void 0 ? void 0 : _b6.chainId;
19686
+ let chainId = (_b7 = options === null || options === void 0 ? void 0 : options.signInWithEthereum) === null || _b7 === void 0 ? void 0 : _b7.chainId;
19414
19687
  if (!chainId) {
19415
19688
  const chainIdHex = await resolvedWallet.request({
19416
19689
  method: "eth_chainId"
@@ -19467,7 +19740,7 @@ var GoTrueClient = class _GoTrueClient {
19467
19740
  }
19468
19741
  }
19469
19742
  async signInWithSolana(credentials) {
19470
- var _a72, _b6, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
19743
+ var _a74, _b7, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
19471
19744
  let message;
19472
19745
  let signature;
19473
19746
  if ("message" in credentials) {
@@ -19491,7 +19764,7 @@ var GoTrueClient = class _GoTrueClient {
19491
19764
  throw new Error(`@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.`);
19492
19765
  }
19493
19766
  }
19494
- const url = new URL((_a72 = options === null || options === void 0 ? void 0 : options.url) !== null && _a72 !== void 0 ? _a72 : window.location.href);
19767
+ const url = new URL((_a74 = options === null || options === void 0 ? void 0 : options.url) !== null && _a74 !== void 0 ? _a74 : window.location.href);
19495
19768
  if ("signIn" in resolvedWallet && resolvedWallet.signIn) {
19496
19769
  const output = await resolvedWallet.signIn(Object.assign(Object.assign(Object.assign({ issuedAt: (/* @__PURE__ */ new Date()).toISOString() }, options === null || options === void 0 ? void 0 : options.signInWithSolana), {
19497
19770
  // non-overridable properties
@@ -19523,7 +19796,7 @@ var GoTrueClient = class _GoTrueClient {
19523
19796
  ...statement ? ["", statement, ""] : [""],
19524
19797
  "Version: 1",
19525
19798
  `URI: ${url.href}`,
19526
- `Issued At: ${(_c = (_b6 = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _b6 === void 0 ? void 0 : _b6.issuedAt) !== null && _c !== void 0 ? _c : (/* @__PURE__ */ new Date()).toISOString()}`,
19799
+ `Issued At: ${(_c = (_b7 = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _b7 === void 0 ? void 0 : _b7.issuedAt) !== null && _c !== void 0 ? _c : (/* @__PURE__ */ new Date()).toISOString()}`,
19527
19800
  ...((_d = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _d === void 0 ? void 0 : _d.notBefore) ? [`Not Before: ${options.signInWithSolana.notBefore}`] : [],
19528
19801
  ...((_e = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _e === void 0 ? void 0 : _e.expirationTime) ? [`Expiration Time: ${options.signInWithSolana.expirationTime}`] : [],
19529
19802
  ...((_f = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _f === void 0 ? void 0 : _f.chainId) ? [`Chain ID: ${options.signInWithSolana.chainId}`] : [],
@@ -19665,7 +19938,7 @@ var GoTrueClient = class _GoTrueClient {
19665
19938
  * This method supports PKCE when an email is passed.
19666
19939
  */
19667
19940
  async signInWithOtp(credentials) {
19668
- var _a72, _b6, _c, _d, _e;
19941
+ var _a74, _b7, _c, _d, _e;
19669
19942
  try {
19670
19943
  if ("email" in credentials) {
19671
19944
  const { email, options } = credentials;
@@ -19679,8 +19952,8 @@ var GoTrueClient = class _GoTrueClient {
19679
19952
  headers: this.headers,
19680
19953
  body: {
19681
19954
  email,
19682
- data: (_a72 = options === null || options === void 0 ? void 0 : options.data) !== null && _a72 !== void 0 ? _a72 : {},
19683
- create_user: (_b6 = options === null || options === void 0 ? void 0 : options.shouldCreateUser) !== null && _b6 !== void 0 ? _b6 : true,
19955
+ data: (_a74 = options === null || options === void 0 ? void 0 : options.data) !== null && _a74 !== void 0 ? _a74 : {},
19956
+ create_user: (_b7 = options === null || options === void 0 ? void 0 : options.shouldCreateUser) !== null && _b7 !== void 0 ? _b7 : true,
19684
19957
  gotrue_meta_security: { captcha_token: options === null || options === void 0 ? void 0 : options.captchaToken },
19685
19958
  code_challenge: codeChallenge,
19686
19959
  code_challenge_method: codeChallengeMethod
@@ -19719,13 +19992,13 @@ var GoTrueClient = class _GoTrueClient {
19719
19992
  * Log in a user given a User supplied OTP or TokenHash received through mobile or email.
19720
19993
  */
19721
19994
  async verifyOtp(params) {
19722
- var _a72, _b6;
19995
+ var _a74, _b7;
19723
19996
  try {
19724
19997
  let redirectTo = void 0;
19725
19998
  let captchaToken = void 0;
19726
19999
  if ("options" in params) {
19727
- redirectTo = (_a72 = params.options) === null || _a72 === void 0 ? void 0 : _a72.redirectTo;
19728
- captchaToken = (_b6 = params.options) === null || _b6 === void 0 ? void 0 : _b6.captchaToken;
20000
+ redirectTo = (_a74 = params.options) === null || _a74 === void 0 ? void 0 : _a74.redirectTo;
20001
+ captchaToken = (_b7 = params.options) === null || _b7 === void 0 ? void 0 : _b7.captchaToken;
19729
20002
  }
19730
20003
  const { data, error } = await _request(this.fetch, "POST", `${this.url}/verify`, {
19731
20004
  headers: this.headers,
@@ -19769,7 +20042,7 @@ var GoTrueClient = class _GoTrueClient {
19769
20042
  * organization's SSO Identity Provider UUID directly instead.
19770
20043
  */
19771
20044
  async signInWithSSO(params) {
19772
- var _a72, _b6, _c, _d, _e;
20045
+ var _a74, _b7, _c, _d, _e;
19773
20046
  try {
19774
20047
  let codeChallenge = null;
19775
20048
  let codeChallengeMethod = null;
@@ -19778,7 +20051,7 @@ var GoTrueClient = class _GoTrueClient {
19778
20051
  [codeChallenge, codeChallengeMethod] = await getCodeChallengeAndMethod(this.storage, this.storageKey);
19779
20052
  }
19780
20053
  const result = await _request(this.fetch, "POST", `${this.url}/sso`, {
19781
- body: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, "providerId" in params ? { provider_id: params.providerId } : null), "domain" in params ? { domain: params.domain } : null), { redirect_to: (_b6 = (_a72 = params.options) === null || _a72 === void 0 ? void 0 : _a72.redirectTo) !== null && _b6 !== void 0 ? _b6 : void 0 }), ((_c = params === null || params === void 0 ? void 0 : params.options) === null || _c === void 0 ? void 0 : _c.captchaToken) ? { gotrue_meta_security: { captcha_token: params.options.captchaToken } } : null), { skip_http_redirect: true, code_challenge: codeChallenge, code_challenge_method: codeChallengeMethod }),
20054
+ body: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, "providerId" in params ? { provider_id: params.providerId } : null), "domain" in params ? { domain: params.domain } : null), { redirect_to: (_b7 = (_a74 = params.options) === null || _a74 === void 0 ? void 0 : _a74.redirectTo) !== null && _b7 !== void 0 ? _b7 : void 0 }), ((_c = params === null || params === void 0 ? void 0 : params.options) === null || _c === void 0 ? void 0 : _c.captchaToken) ? { gotrue_meta_security: { captcha_token: params.options.captchaToken } } : null), { skip_http_redirect: true, code_challenge: codeChallenge, code_challenge_method: codeChallengeMethod }),
19782
20055
  headers: this.headers,
19783
20056
  xform: _ssoResponse
19784
20057
  });
@@ -20032,17 +20305,17 @@ var GoTrueClient = class _GoTrueClient {
20032
20305
  });
20033
20306
  }
20034
20307
  return await this._useSession(async (result) => {
20035
- var _a72, _b6, _c;
20308
+ var _a74, _b7, _c;
20036
20309
  const { data, error } = result;
20037
20310
  if (error) {
20038
20311
  throw error;
20039
20312
  }
20040
- if (!((_a72 = data.session) === null || _a72 === void 0 ? void 0 : _a72.access_token) && !this.hasCustomAuthorizationHeader) {
20313
+ if (!((_a74 = data.session) === null || _a74 === void 0 ? void 0 : _a74.access_token) && !this.hasCustomAuthorizationHeader) {
20041
20314
  return { data: { user: null }, error: new AuthSessionMissingError() };
20042
20315
  }
20043
20316
  return await _request(this.fetch, "GET", `${this.url}/user`, {
20044
20317
  headers: this.headers,
20045
- jwt: (_c = (_b6 = data.session) === null || _b6 === void 0 ? void 0 : _b6.access_token) !== null && _c !== void 0 ? _c : void 0,
20318
+ jwt: (_c = (_b7 = data.session) === null || _b7 === void 0 ? void 0 : _b7.access_token) !== null && _c !== void 0 ? _c : void 0,
20046
20319
  xform: _userResponse
20047
20320
  });
20048
20321
  });
@@ -20179,13 +20452,13 @@ var GoTrueClient = class _GoTrueClient {
20179
20452
  async _refreshSession(currentSession) {
20180
20453
  try {
20181
20454
  return await this._useSession(async (result) => {
20182
- var _a72;
20455
+ var _a74;
20183
20456
  if (!currentSession) {
20184
20457
  const { data, error: error2 } = result;
20185
20458
  if (error2) {
20186
20459
  throw error2;
20187
20460
  }
20188
- currentSession = (_a72 = data.session) !== null && _a72 !== void 0 ? _a72 : void 0;
20461
+ currentSession = (_a74 = data.session) !== null && _a74 !== void 0 ? _a74 : void 0;
20189
20462
  }
20190
20463
  if (!(currentSession === null || currentSession === void 0 ? void 0 : currentSession.refresh_token)) {
20191
20464
  throw new AuthSessionMissingError();
@@ -20323,12 +20596,12 @@ var GoTrueClient = class _GoTrueClient {
20323
20596
  }
20324
20597
  async _signOut({ scope } = { scope: "global" }) {
20325
20598
  return await this._useSession(async (result) => {
20326
- var _a72;
20599
+ var _a74;
20327
20600
  const { data, error: sessionError } = result;
20328
20601
  if (sessionError) {
20329
20602
  return this._returnResult({ error: sessionError });
20330
20603
  }
20331
- const accessToken = (_a72 = data.session) === null || _a72 === void 0 ? void 0 : _a72.access_token;
20604
+ const accessToken = (_a74 = data.session) === null || _a74 === void 0 ? void 0 : _a74.access_token;
20332
20605
  if (accessToken) {
20333
20606
  const { error } = await this.admin.signOut(accessToken, scope);
20334
20607
  if (error) {
@@ -20366,15 +20639,15 @@ var GoTrueClient = class _GoTrueClient {
20366
20639
  }
20367
20640
  async _emitInitialSession(id) {
20368
20641
  return await this._useSession(async (result) => {
20369
- var _a72, _b6;
20642
+ var _a74, _b7;
20370
20643
  try {
20371
20644
  const { data: { session }, error } = result;
20372
20645
  if (error)
20373
20646
  throw error;
20374
- await ((_a72 = this.stateChangeEmitters.get(id)) === null || _a72 === void 0 ? void 0 : _a72.callback("INITIAL_SESSION", session));
20647
+ await ((_a74 = this.stateChangeEmitters.get(id)) === null || _a74 === void 0 ? void 0 : _a74.callback("INITIAL_SESSION", session));
20375
20648
  this._debug("INITIAL_SESSION", "callback id", id, "session", session);
20376
20649
  } catch (err) {
20377
- await ((_b6 = this.stateChangeEmitters.get(id)) === null || _b6 === void 0 ? void 0 : _b6.callback("INITIAL_SESSION", null));
20650
+ await ((_b7 = this.stateChangeEmitters.get(id)) === null || _b7 === void 0 ? void 0 : _b7.callback("INITIAL_SESSION", null));
20378
20651
  this._debug("INITIAL_SESSION", "callback id", id, "error", err);
20379
20652
  console.error(err);
20380
20653
  }
@@ -20422,12 +20695,12 @@ var GoTrueClient = class _GoTrueClient {
20422
20695
  * Gets all the identities linked to a user.
20423
20696
  */
20424
20697
  async getUserIdentities() {
20425
- var _a72;
20698
+ var _a74;
20426
20699
  try {
20427
20700
  const { data, error } = await this.getUser();
20428
20701
  if (error)
20429
20702
  throw error;
20430
- return this._returnResult({ data: { identities: (_a72 = data.user.identities) !== null && _a72 !== void 0 ? _a72 : [] }, error: null });
20703
+ return this._returnResult({ data: { identities: (_a74 = data.user.identities) !== null && _a74 !== void 0 ? _a74 : [] }, error: null });
20431
20704
  } catch (error) {
20432
20705
  if (isAuthError(error)) {
20433
20706
  return this._returnResult({ data: null, error });
@@ -20442,16 +20715,16 @@ var GoTrueClient = class _GoTrueClient {
20442
20715
  return this.linkIdentityOAuth(credentials);
20443
20716
  }
20444
20717
  async linkIdentityOAuth(credentials) {
20445
- var _a72;
20718
+ var _a74;
20446
20719
  try {
20447
20720
  const { data, error } = await this._useSession(async (result) => {
20448
- var _a73, _b6, _c, _d, _e;
20721
+ var _a75, _b7, _c, _d, _e;
20449
20722
  const { data: data2, error: error2 } = result;
20450
20723
  if (error2)
20451
20724
  throw error2;
20452
20725
  const url = await this._getUrlForProvider(`${this.url}/user/identities/authorize`, credentials.provider, {
20453
- redirectTo: (_a73 = credentials.options) === null || _a73 === void 0 ? void 0 : _a73.redirectTo,
20454
- scopes: (_b6 = credentials.options) === null || _b6 === void 0 ? void 0 : _b6.scopes,
20726
+ redirectTo: (_a75 = credentials.options) === null || _a75 === void 0 ? void 0 : _a75.redirectTo,
20727
+ scopes: (_b7 = credentials.options) === null || _b7 === void 0 ? void 0 : _b7.scopes,
20455
20728
  queryParams: (_c = credentials.options) === null || _c === void 0 ? void 0 : _c.queryParams,
20456
20729
  skipBrowserRedirect: true
20457
20730
  });
@@ -20462,7 +20735,7 @@ var GoTrueClient = class _GoTrueClient {
20462
20735
  });
20463
20736
  if (error)
20464
20737
  throw error;
20465
- if (isBrowser() && !((_a72 = credentials.options) === null || _a72 === void 0 ? void 0 : _a72.skipBrowserRedirect)) {
20738
+ if (isBrowser() && !((_a74 = credentials.options) === null || _a74 === void 0 ? void 0 : _a74.skipBrowserRedirect)) {
20466
20739
  window.location.assign(data === null || data === void 0 ? void 0 : data.url);
20467
20740
  }
20468
20741
  return this._returnResult({
@@ -20478,7 +20751,7 @@ var GoTrueClient = class _GoTrueClient {
20478
20751
  }
20479
20752
  async linkIdentityIdToken(credentials) {
20480
20753
  return await this._useSession(async (result) => {
20481
- var _a72;
20754
+ var _a74;
20482
20755
  try {
20483
20756
  const { error: sessionError, data: { session } } = result;
20484
20757
  if (sessionError)
@@ -20486,7 +20759,7 @@ var GoTrueClient = class _GoTrueClient {
20486
20759
  const { options, provider, token, access_token, nonce } = credentials;
20487
20760
  const res = await _request(this.fetch, "POST", `${this.url}/token?grant_type=id_token`, {
20488
20761
  headers: this.headers,
20489
- jwt: (_a72 = session === null || session === void 0 ? void 0 : session.access_token) !== null && _a72 !== void 0 ? _a72 : void 0,
20762
+ jwt: (_a74 = session === null || session === void 0 ? void 0 : session.access_token) !== null && _a74 !== void 0 ? _a74 : void 0,
20490
20763
  body: {
20491
20764
  provider,
20492
20765
  id_token: token,
@@ -20526,14 +20799,14 @@ var GoTrueClient = class _GoTrueClient {
20526
20799
  async unlinkIdentity(identity) {
20527
20800
  try {
20528
20801
  return await this._useSession(async (result) => {
20529
- var _a72, _b6;
20802
+ var _a74, _b7;
20530
20803
  const { data, error } = result;
20531
20804
  if (error) {
20532
20805
  throw error;
20533
20806
  }
20534
20807
  return await _request(this.fetch, "DELETE", `${this.url}/user/identities/${identity.identity_id}`, {
20535
20808
  headers: this.headers,
20536
- jwt: (_b6 = (_a72 = data.session) === null || _a72 === void 0 ? void 0 : _a72.access_token) !== null && _b6 !== void 0 ? _b6 : void 0
20809
+ jwt: (_b7 = (_a74 = data.session) === null || _a74 === void 0 ? void 0 : _a74.access_token) !== null && _b7 !== void 0 ? _b7 : void 0
20537
20810
  });
20538
20811
  });
20539
20812
  } catch (error) {
@@ -20598,7 +20871,7 @@ var GoTrueClient = class _GoTrueClient {
20598
20871
  * Note: this method is async to accommodate for AsyncStorage e.g. in React native.
20599
20872
  */
20600
20873
  async _recoverAndRefresh() {
20601
- var _a72, _b6;
20874
+ var _a74, _b7;
20602
20875
  const debugName = "#_recoverAndRefresh()";
20603
20876
  this._debug(debugName, "begin");
20604
20877
  try {
@@ -20609,7 +20882,7 @@ var GoTrueClient = class _GoTrueClient {
20609
20882
  maybeUser = { user: currentSession.user };
20610
20883
  await setItemAsync(this.userStorage, this.storageKey + "-user", maybeUser);
20611
20884
  }
20612
- currentSession.user = (_a72 = maybeUser === null || maybeUser === void 0 ? void 0 : maybeUser.user) !== null && _a72 !== void 0 ? _a72 : userNotAvailableProxy();
20885
+ currentSession.user = (_a74 = maybeUser === null || maybeUser === void 0 ? void 0 : maybeUser.user) !== null && _a74 !== void 0 ? _a74 : userNotAvailableProxy();
20613
20886
  } else if (currentSession && !currentSession.user) {
20614
20887
  if (!currentSession.user) {
20615
20888
  const separateUser = await getItemAsync(this.storage, this.storageKey + "-user");
@@ -20630,7 +20903,7 @@ var GoTrueClient = class _GoTrueClient {
20630
20903
  }
20631
20904
  return;
20632
20905
  }
20633
- const expiresWithMargin = ((_b6 = currentSession.expires_at) !== null && _b6 !== void 0 ? _b6 : Infinity) * 1e3 - Date.now() < EXPIRY_MARGIN_MS;
20906
+ const expiresWithMargin = ((_b7 = currentSession.expires_at) !== null && _b7 !== void 0 ? _b7 : Infinity) * 1e3 - Date.now() < EXPIRY_MARGIN_MS;
20634
20907
  this._debug(debugName, `session has${expiresWithMargin ? "" : " not"} expired with margin of ${EXPIRY_MARGIN_MS}s`);
20635
20908
  if (expiresWithMargin) {
20636
20909
  if (this.autoRefreshToken && currentSession.refresh_token) {
@@ -20669,7 +20942,7 @@ var GoTrueClient = class _GoTrueClient {
20669
20942
  }
20670
20943
  }
20671
20944
  async _callRefreshToken(refreshToken) {
20672
- var _a72, _b6;
20945
+ var _a74, _b7;
20673
20946
  if (!refreshToken) {
20674
20947
  throw new AuthSessionMissingError();
20675
20948
  }
@@ -20697,10 +20970,10 @@ var GoTrueClient = class _GoTrueClient {
20697
20970
  if (!isAuthRetryableFetchError(error)) {
20698
20971
  await this._removeSession();
20699
20972
  }
20700
- (_a72 = this.refreshingDeferred) === null || _a72 === void 0 ? void 0 : _a72.resolve(result);
20973
+ (_a74 = this.refreshingDeferred) === null || _a74 === void 0 ? void 0 : _a74.resolve(result);
20701
20974
  return result;
20702
20975
  }
20703
- (_b6 = this.refreshingDeferred) === null || _b6 === void 0 ? void 0 : _b6.reject(error);
20976
+ (_b7 = this.refreshingDeferred) === null || _b7 === void 0 ? void 0 : _b7.reject(error);
20704
20977
  throw error;
20705
20978
  } finally {
20706
20979
  this.refreshingDeferred = null;
@@ -20986,14 +21259,14 @@ var GoTrueClient = class _GoTrueClient {
20986
21259
  async _unenroll(params) {
20987
21260
  try {
20988
21261
  return await this._useSession(async (result) => {
20989
- var _a72;
21262
+ var _a74;
20990
21263
  const { data: sessionData, error: sessionError } = result;
20991
21264
  if (sessionError) {
20992
21265
  return this._returnResult({ data: null, error: sessionError });
20993
21266
  }
20994
21267
  return await _request(this.fetch, "DELETE", `${this.url}/factors/${params.factorId}`, {
20995
21268
  headers: this.headers,
20996
- jwt: (_a72 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a72 === void 0 ? void 0 : _a72.access_token
21269
+ jwt: (_a74 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a74 === void 0 ? void 0 : _a74.access_token
20997
21270
  });
20998
21271
  });
20999
21272
  } catch (error) {
@@ -21006,7 +21279,7 @@ var GoTrueClient = class _GoTrueClient {
21006
21279
  async _enroll(params) {
21007
21280
  try {
21008
21281
  return await this._useSession(async (result) => {
21009
- var _a72, _b6;
21282
+ var _a74, _b7;
21010
21283
  const { data: sessionData, error: sessionError } = result;
21011
21284
  if (sessionError) {
21012
21285
  return this._returnResult({ data: null, error: sessionError });
@@ -21015,12 +21288,12 @@ var GoTrueClient = class _GoTrueClient {
21015
21288
  const { data, error } = await _request(this.fetch, "POST", `${this.url}/factors`, {
21016
21289
  body,
21017
21290
  headers: this.headers,
21018
- jwt: (_a72 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a72 === void 0 ? void 0 : _a72.access_token
21291
+ jwt: (_a74 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a74 === void 0 ? void 0 : _a74.access_token
21019
21292
  });
21020
21293
  if (error) {
21021
21294
  return this._returnResult({ data: null, error });
21022
21295
  }
21023
- if (params.factorType === "totp" && data.type === "totp" && ((_b6 = data === null || data === void 0 ? void 0 : data.totp) === null || _b6 === void 0 ? void 0 : _b6.qr_code)) {
21296
+ if (params.factorType === "totp" && data.type === "totp" && ((_b7 = data === null || data === void 0 ? void 0 : data.totp) === null || _b7 === void 0 ? void 0 : _b7.qr_code)) {
21024
21297
  data.totp.qr_code = `data:image/svg+xml;utf-8,${data.totp.qr_code}`;
21025
21298
  }
21026
21299
  return this._returnResult({ data, error: null });
@@ -21036,7 +21309,7 @@ var GoTrueClient = class _GoTrueClient {
21036
21309
  return this._acquireLock(this.lockAcquireTimeout, async () => {
21037
21310
  try {
21038
21311
  return await this._useSession(async (result) => {
21039
- var _a72;
21312
+ var _a74;
21040
21313
  const { data: sessionData, error: sessionError } = result;
21041
21314
  if (sessionError) {
21042
21315
  return this._returnResult({ data: null, error: sessionError });
@@ -21047,7 +21320,7 @@ var GoTrueClient = class _GoTrueClient {
21047
21320
  const { data, error } = await _request(this.fetch, "POST", `${this.url}/factors/${params.factorId}/verify`, {
21048
21321
  body,
21049
21322
  headers: this.headers,
21050
- jwt: (_a72 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a72 === void 0 ? void 0 : _a72.access_token
21323
+ jwt: (_a74 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a74 === void 0 ? void 0 : _a74.access_token
21051
21324
  });
21052
21325
  if (error) {
21053
21326
  return this._returnResult({ data: null, error });
@@ -21068,7 +21341,7 @@ var GoTrueClient = class _GoTrueClient {
21068
21341
  return this._acquireLock(this.lockAcquireTimeout, async () => {
21069
21342
  try {
21070
21343
  return await this._useSession(async (result) => {
21071
- var _a72;
21344
+ var _a74;
21072
21345
  const { data: sessionData, error: sessionError } = result;
21073
21346
  if (sessionError) {
21074
21347
  return this._returnResult({ data: null, error: sessionError });
@@ -21076,7 +21349,7 @@ var GoTrueClient = class _GoTrueClient {
21076
21349
  const response = await _request(this.fetch, "POST", `${this.url}/factors/${params.factorId}/challenge`, {
21077
21350
  body: params,
21078
21351
  headers: this.headers,
21079
- jwt: (_a72 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a72 === void 0 ? void 0 : _a72.access_token
21352
+ jwt: (_a74 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a74 === void 0 ? void 0 : _a74.access_token
21080
21353
  });
21081
21354
  if (response.error) {
21082
21355
  return response;
@@ -21126,7 +21399,7 @@ var GoTrueClient = class _GoTrueClient {
21126
21399
  * {@see GoTrueMFAApi#listFactors}
21127
21400
  */
21128
21401
  async _listFactors() {
21129
- var _a72;
21402
+ var _a74;
21130
21403
  const { data: { user }, error: userError } = await this.getUser();
21131
21404
  if (userError) {
21132
21405
  return { data: null, error: userError };
@@ -21137,7 +21410,7 @@ var GoTrueClient = class _GoTrueClient {
21137
21410
  totp: [],
21138
21411
  webauthn: []
21139
21412
  };
21140
- for (const factor of (_a72 = user === null || user === void 0 ? void 0 : user.factors) !== null && _a72 !== void 0 ? _a72 : []) {
21413
+ for (const factor of (_a74 = user === null || user === void 0 ? void 0 : user.factors) !== null && _a74 !== void 0 ? _a74 : []) {
21141
21414
  data.all.push(factor);
21142
21415
  if (factor.status === "verified") {
21143
21416
  ;
@@ -21153,7 +21426,7 @@ var GoTrueClient = class _GoTrueClient {
21153
21426
  * {@see GoTrueMFAApi#getAuthenticatorAssuranceLevel}
21154
21427
  */
21155
21428
  async _getAuthenticatorAssuranceLevel() {
21156
- var _a72, _b6;
21429
+ var _a74, _b7;
21157
21430
  const { data: { session }, error: sessionError } = await this.getSession();
21158
21431
  if (sessionError) {
21159
21432
  return this._returnResult({ data: null, error: sessionError });
@@ -21170,7 +21443,7 @@ var GoTrueClient = class _GoTrueClient {
21170
21443
  currentLevel = payload.aal;
21171
21444
  }
21172
21445
  let nextLevel = currentLevel;
21173
- const verifiedFactors = (_b6 = (_a72 = session.user.factors) === null || _a72 === void 0 ? void 0 : _a72.filter((factor) => factor.status === "verified")) !== null && _b6 !== void 0 ? _b6 : [];
21446
+ const verifiedFactors = (_b7 = (_a74 = session.user.factors) === null || _a74 === void 0 ? void 0 : _a74.filter((factor) => factor.status === "verified")) !== null && _b7 !== void 0 ? _b7 : [];
21174
21447
  if (verifiedFactors.length > 0) {
21175
21448
  nextLevel = "aal2";
21176
21449
  }
@@ -21776,10 +22049,10 @@ if (shouldShowDeprecationWarning()) console.warn("\u26A0\uFE0F Node.js 18 and b
21776
22049
  var cachedStargate = null;
21777
22050
  var cachedPublic = null;
21778
22051
  function getSupabase() {
21779
- var _a72;
22052
+ var _a74;
21780
22053
  if (cachedStargate) return cachedStargate;
21781
22054
  const url = getRuntimeEnv("VITE_SUPABASE_URL");
21782
- const anon = (_a72 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a72 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY");
22055
+ const anon = (_a74 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a74 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY");
21783
22056
  const schema = getRuntimeEnvOr("VITE_SUPABASE_SCHEMA", "public");
21784
22057
  if (!url || !anon) {
21785
22058
  if (isRuntimeDev()) {
@@ -21797,10 +22070,10 @@ function getSupabase() {
21797
22070
  return cachedStargate;
21798
22071
  }
21799
22072
  function getSupabasePublic() {
21800
- var _a72;
22073
+ var _a74;
21801
22074
  if (cachedPublic) return cachedPublic;
21802
22075
  const url = getRuntimeEnv("VITE_SUPABASE_URL");
21803
- const anon = (_a72 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a72 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY");
22076
+ const anon = (_a74 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a74 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY");
21804
22077
  if (!url || !anon) {
21805
22078
  if (isRuntimeDev()) {
21806
22079
  console.log("[supabase] getSupabasePublic: env faltando", { hasUrl: !!url, hasAnon: !!anon });
@@ -21875,15 +22148,15 @@ var Toaster = ({ theme, ...props }) => {
21875
22148
  // src/lib/accountsAuth.ts
21876
22149
  var normalizeBaseUrl2 = (value) => value.replace(/\/+$/, "");
21877
22150
  var getAccountsConfig = () => {
21878
- var _a72, _b6, _c;
22151
+ var _a74, _b7, _c;
21879
22152
  const baseUrl = normalizeBaseUrl2(
21880
- (_a72 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a72 : "https://accounts.cupcode.com.br"
22153
+ (_a74 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a74 : "https://accounts.cupcode.com.br"
21881
22154
  );
21882
22155
  const clientId = getRuntimeEnv("VITE_ACCOUNTS_CLIENT_ID");
21883
22156
  if (!clientId) {
21884
22157
  throw new Error("VITE_ACCOUNTS_CLIENT_ID \xE9 obrigat\xF3rio para login.");
21885
22158
  }
21886
- const redirectUri = (_b6 = getRuntimeEnv("VITE_ACCOUNTS_REDIRECT_URI")) != null ? _b6 : `${window.location.origin}/auth/callback`;
22159
+ const redirectUri = (_b7 = getRuntimeEnv("VITE_ACCOUNTS_REDIRECT_URI")) != null ? _b7 : `${window.location.origin}/auth/callback`;
21887
22160
  return {
21888
22161
  baseUrl,
21889
22162
  clientId,
@@ -21898,7 +22171,7 @@ var getAccountsConfig = () => {
21898
22171
  };
21899
22172
  var cachedDiscovery = null;
21900
22173
  var resolveOidcEndpoints = async (config) => {
21901
- var _a72, _b6, _c, _d, _e, _f;
22174
+ var _a74, _b7, _c, _d, _e, _f;
21902
22175
  if (config.authUrl && config.tokenUrl) {
21903
22176
  return {
21904
22177
  authUrl: config.authUrl,
@@ -21908,8 +22181,8 @@ var resolveOidcEndpoints = async (config) => {
21908
22181
  }
21909
22182
  if (cachedDiscovery) {
21910
22183
  return {
21911
- authUrl: (_a72 = cachedDiscovery.authorization_endpoint) != null ? _a72 : config.authUrl,
21912
- tokenUrl: (_b6 = cachedDiscovery.token_endpoint) != null ? _b6 : config.tokenUrl,
22184
+ authUrl: (_a74 = cachedDiscovery.authorization_endpoint) != null ? _a74 : config.authUrl,
22185
+ tokenUrl: (_b7 = cachedDiscovery.token_endpoint) != null ? _b7 : config.tokenUrl,
21913
22186
  logoutUrl: (_c = cachedDiscovery.end_session_endpoint) != null ? _c : config.logoutUrl
21914
22187
  };
21915
22188
  }
@@ -22014,36 +22287,36 @@ var decodeJwt = (token) => {
22014
22287
 
22015
22288
  // src/components/cupcode/MainNavbar.tsx
22016
22289
  import { Fragment as Fragment4, jsx as jsx45, jsxs as jsxs28 } from "react/jsx-runtime";
22017
- var _a16, _b4;
22018
- var SUPABASE_SCHEMA = ((_b4 = (_a16 = getRuntimeEnv("VITE_CHAT_SCHEMA")) != null ? _a16 : getRuntimeEnv("VITE_SUPABASE_SCHEMA")) != null ? _b4 : "public").trim();
22019
- var _a17;
22020
- var USER_PRESENCE_TABLE = ((_a17 = getRuntimeEnv("VITE_USER_PRESENCE_TABLE")) != null ? _a17 : "user_presence").trim();
22021
- var _a18;
22022
- var USER_PRESENCE_USER_ID_COLUMN = ((_a18 = getRuntimeEnv("VITE_USER_PRESENCE_USER_ID_COLUMN")) != null ? _a18 : "user_id").trim();
22290
+ var _a18, _b5;
22291
+ var SUPABASE_SCHEMA = ((_b5 = (_a18 = getRuntimeEnv("VITE_CHAT_SCHEMA")) != null ? _a18 : getRuntimeEnv("VITE_SUPABASE_SCHEMA")) != null ? _b5 : "public").trim();
22023
22292
  var _a19;
22024
- var USER_PRESENCE_STATUS_COLUMN = ((_a19 = getRuntimeEnv("VITE_USER_PRESENCE_STATUS_COLUMN")) != null ? _a19 : "status").trim();
22293
+ var USER_PRESENCE_TABLE = ((_a19 = getRuntimeEnv("VITE_USER_PRESENCE_TABLE")) != null ? _a19 : "user_presence").trim();
22025
22294
  var _a20;
22026
- var CHAT_USERS_TABLE = ((_a20 = getRuntimeEnv("VITE_CHAT_USERS_TABLE")) != null ? _a20 : "chat_users").trim();
22295
+ var USER_PRESENCE_USER_ID_COLUMN = ((_a20 = getRuntimeEnv("VITE_USER_PRESENCE_USER_ID_COLUMN")) != null ? _a20 : "user_id").trim();
22027
22296
  var _a21;
22028
- var CHAT_USERS_ID_COLUMN = ((_a21 = getRuntimeEnv("VITE_CHAT_USERS_ID_COLUMN")) != null ? _a21 : "id").trim();
22297
+ var USER_PRESENCE_STATUS_COLUMN = ((_a21 = getRuntimeEnv("VITE_USER_PRESENCE_STATUS_COLUMN")) != null ? _a21 : "status").trim();
22029
22298
  var _a22;
22030
- var CHAT_USERS_NAME_COLUMN = ((_a22 = getRuntimeEnv("VITE_CHAT_USERS_NAME_COLUMN")) != null ? _a22 : "name").trim();
22299
+ var CHAT_USERS_TABLE = ((_a22 = getRuntimeEnv("VITE_CHAT_USERS_TABLE")) != null ? _a22 : "chat_users").trim();
22031
22300
  var _a23;
22032
- var CHAT_USERS_USERNAME_COLUMN = ((_a23 = getRuntimeEnv("VITE_CHAT_USERS_USERNAME_COLUMN")) != null ? _a23 : "username").trim();
22301
+ var CHAT_USERS_ID_COLUMN = ((_a23 = getRuntimeEnv("VITE_CHAT_USERS_ID_COLUMN")) != null ? _a23 : "id").trim();
22033
22302
  var _a24;
22034
- var CHAT_USERS_EMAIL_COLUMN = ((_a24 = getRuntimeEnv("VITE_CHAT_USERS_EMAIL_COLUMN")) != null ? _a24 : "email").trim();
22303
+ var CHAT_USERS_NAME_COLUMN = ((_a24 = getRuntimeEnv("VITE_CHAT_USERS_NAME_COLUMN")) != null ? _a24 : "name").trim();
22035
22304
  var _a25;
22036
- var CHAT_USERS_AVATAR_COLUMN = ((_a25 = getRuntimeEnv("VITE_CHAT_USERS_AVATAR_COLUMN")) != null ? _a25 : "avatar_url").trim();
22305
+ var CHAT_USERS_USERNAME_COLUMN = ((_a25 = getRuntimeEnv("VITE_CHAT_USERS_USERNAME_COLUMN")) != null ? _a25 : "username").trim();
22037
22306
  var _a26;
22038
- var CHAT_USERS_ROLE_COLUMN = ((_a26 = getRuntimeEnv("VITE_CHAT_USERS_ROLE_COLUMN")) != null ? _a26 : "job_title").trim();
22307
+ var CHAT_USERS_EMAIL_COLUMN = ((_a26 = getRuntimeEnv("VITE_CHAT_USERS_EMAIL_COLUMN")) != null ? _a26 : "email").trim();
22039
22308
  var _a27;
22040
- var CHAT_USERS_UPDATE_TABLE = ((_a27 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_TABLE")) != null ? _a27 : "profiles").trim();
22309
+ var CHAT_USERS_AVATAR_COLUMN = ((_a27 = getRuntimeEnv("VITE_CHAT_USERS_AVATAR_COLUMN")) != null ? _a27 : "avatar_url").trim();
22041
22310
  var _a28;
22042
- var CHAT_USERS_UPDATE_ID_COLUMN = ((_a28 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_ID_COLUMN")) != null ? _a28 : "id").trim();
22311
+ var CHAT_USERS_ROLE_COLUMN = ((_a28 = getRuntimeEnv("VITE_CHAT_USERS_ROLE_COLUMN")) != null ? _a28 : "job_title").trim();
22043
22312
  var _a29;
22044
- var CHAT_USERS_UPDATE_EMAIL_COLUMN = ((_a29 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_EMAIL_COLUMN")) != null ? _a29 : "email").trim();
22313
+ var CHAT_USERS_UPDATE_TABLE = ((_a29 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_TABLE")) != null ? _a29 : "profiles").trim();
22045
22314
  var _a30;
22046
- var CHAT_USERS_UPDATE_AVATAR_COLUMN = ((_a30 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_AVATAR_COLUMN")) != null ? _a30 : "avatar_url").trim();
22315
+ var CHAT_USERS_UPDATE_ID_COLUMN = ((_a30 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_ID_COLUMN")) != null ? _a30 : "id").trim();
22316
+ var _a31;
22317
+ var CHAT_USERS_UPDATE_EMAIL_COLUMN = ((_a31 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_EMAIL_COLUMN")) != null ? _a31 : "email").trim();
22318
+ var _a32;
22319
+ var CHAT_USERS_UPDATE_AVATAR_COLUMN = ((_a32 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_AVATAR_COLUMN")) != null ? _a32 : "avatar_url").trim();
22047
22320
  var CHAT_USERS_LOOKUP_TABLES = Array.from(
22048
22321
  new Set(
22049
22322
  [CHAT_USERS_TABLE, "chat_users", CHAT_USERS_UPDATE_TABLE, "profiles", "users"].map((entry) => entry.trim()).filter((entry) => entry.length > 0)
@@ -22059,73 +22332,73 @@ var CHAT_USERS_LOOKUP_EMAIL_COLUMNS = Array.from(
22059
22332
  [CHAT_USERS_EMAIL_COLUMN, CHAT_USERS_UPDATE_EMAIL_COLUMN, "email"].map((entry) => entry.trim()).filter((entry) => entry.length > 0)
22060
22333
  )
22061
22334
  );
22062
- var _a31;
22063
- var CHAT_MESSAGES_TABLE = ((_a31 = getRuntimeEnv("VITE_CHAT_MESSAGES_TABLE")) != null ? _a31 : "chat_messages").trim();
22064
- var _a32;
22065
- var CHAT_MESSAGES_ID_COLUMN = ((_a32 = getRuntimeEnv("VITE_CHAT_MESSAGES_ID_COLUMN")) != null ? _a32 : "id").trim();
22066
22335
  var _a33;
22067
- var CHAT_MESSAGES_SENDER_COLUMN = ((_a33 = getRuntimeEnv("VITE_CHAT_MESSAGES_SENDER_COLUMN")) != null ? _a33 : "sender_id").trim();
22336
+ var CHAT_MESSAGES_TABLE = ((_a33 = getRuntimeEnv("VITE_CHAT_MESSAGES_TABLE")) != null ? _a33 : "chat_messages").trim();
22068
22337
  var _a34;
22069
- var CHAT_MESSAGES_RECIPIENT_COLUMN = ((_a34 = getRuntimeEnv("VITE_CHAT_MESSAGES_RECIPIENT_COLUMN")) != null ? _a34 : "recipient_id").trim();
22338
+ var CHAT_MESSAGES_ID_COLUMN = ((_a34 = getRuntimeEnv("VITE_CHAT_MESSAGES_ID_COLUMN")) != null ? _a34 : "id").trim();
22070
22339
  var _a35;
22071
- var CHAT_MESSAGES_TEXT_COLUMN = ((_a35 = getRuntimeEnv("VITE_CHAT_MESSAGES_TEXT_COLUMN")) != null ? _a35 : "text").trim();
22340
+ var CHAT_MESSAGES_SENDER_COLUMN = ((_a35 = getRuntimeEnv("VITE_CHAT_MESSAGES_SENDER_COLUMN")) != null ? _a35 : "sender_id").trim();
22072
22341
  var _a36;
22073
- var CHAT_MESSAGES_CREATED_AT_COLUMN = ((_a36 = getRuntimeEnv("VITE_CHAT_MESSAGES_CREATED_AT_COLUMN")) != null ? _a36 : "created_at").trim();
22342
+ var CHAT_MESSAGES_RECIPIENT_COLUMN = ((_a36 = getRuntimeEnv("VITE_CHAT_MESSAGES_RECIPIENT_COLUMN")) != null ? _a36 : "recipient_id").trim();
22074
22343
  var _a37;
22075
- var CHAT_MESSAGES_READ_AT_COLUMN = ((_a37 = getRuntimeEnv("VITE_CHAT_MESSAGES_READ_AT_COLUMN")) != null ? _a37 : "read_at").trim();
22344
+ var CHAT_MESSAGES_TEXT_COLUMN = ((_a37 = getRuntimeEnv("VITE_CHAT_MESSAGES_TEXT_COLUMN")) != null ? _a37 : "text").trim();
22076
22345
  var _a38;
22077
- var CHAT_MESSAGES_REPLY_TO_COLUMN = ((_a38 = getRuntimeEnv("VITE_CHAT_MESSAGES_REPLY_TO_COLUMN")) != null ? _a38 : "reply_to_message_id").trim();
22346
+ var CHAT_MESSAGES_CREATED_AT_COLUMN = ((_a38 = getRuntimeEnv("VITE_CHAT_MESSAGES_CREATED_AT_COLUMN")) != null ? _a38 : "created_at").trim();
22078
22347
  var _a39;
22079
- var CHAT_MESSAGES_EDITED_AT_COLUMN = ((_a39 = getRuntimeEnv("VITE_CHAT_MESSAGES_EDITED_AT_COLUMN")) != null ? _a39 : "edited_at").trim();
22348
+ var CHAT_MESSAGES_READ_AT_COLUMN = ((_a39 = getRuntimeEnv("VITE_CHAT_MESSAGES_READ_AT_COLUMN")) != null ? _a39 : "read_at").trim();
22080
22349
  var _a40;
22081
- var CHAT_MESSAGES_DELETED_AT_COLUMN = ((_a40 = getRuntimeEnv("VITE_CHAT_MESSAGES_DELETED_AT_COLUMN")) != null ? _a40 : "deleted_at").trim();
22350
+ var CHAT_MESSAGES_REPLY_TO_COLUMN = ((_a40 = getRuntimeEnv("VITE_CHAT_MESSAGES_REPLY_TO_COLUMN")) != null ? _a40 : "reply_to_message_id").trim();
22082
22351
  var _a41;
22083
- var CHAT_MESSAGES_DELETED_BY_COLUMN = ((_a41 = getRuntimeEnv("VITE_CHAT_MESSAGES_DELETED_BY_COLUMN")) != null ? _a41 : "deleted_by").trim();
22352
+ var CHAT_MESSAGES_EDITED_AT_COLUMN = ((_a41 = getRuntimeEnv("VITE_CHAT_MESSAGES_EDITED_AT_COLUMN")) != null ? _a41 : "edited_at").trim();
22084
22353
  var _a42;
22085
- var CHAT_REACTIONS_TABLE = ((_a42 = getRuntimeEnv("VITE_CHAT_REACTIONS_TABLE")) != null ? _a42 : "chat_message_reactions").trim();
22354
+ var CHAT_MESSAGES_DELETED_AT_COLUMN = ((_a42 = getRuntimeEnv("VITE_CHAT_MESSAGES_DELETED_AT_COLUMN")) != null ? _a42 : "deleted_at").trim();
22086
22355
  var _a43;
22087
- var CHAT_REACTIONS_ID_COLUMN = ((_a43 = getRuntimeEnv("VITE_CHAT_REACTIONS_ID_COLUMN")) != null ? _a43 : "id").trim();
22356
+ var CHAT_MESSAGES_DELETED_BY_COLUMN = ((_a43 = getRuntimeEnv("VITE_CHAT_MESSAGES_DELETED_BY_COLUMN")) != null ? _a43 : "deleted_by").trim();
22088
22357
  var _a44;
22089
- var CHAT_REACTIONS_MESSAGE_ID_COLUMN = ((_a44 = getRuntimeEnv("VITE_CHAT_REACTIONS_MESSAGE_ID_COLUMN")) != null ? _a44 : "message_id").trim();
22358
+ var CHAT_REACTIONS_TABLE = ((_a44 = getRuntimeEnv("VITE_CHAT_REACTIONS_TABLE")) != null ? _a44 : "chat_message_reactions").trim();
22090
22359
  var _a45;
22091
- var CHAT_REACTIONS_USER_ID_COLUMN = ((_a45 = getRuntimeEnv("VITE_CHAT_REACTIONS_USER_ID_COLUMN")) != null ? _a45 : "user_id").trim();
22360
+ var CHAT_REACTIONS_ID_COLUMN = ((_a45 = getRuntimeEnv("VITE_CHAT_REACTIONS_ID_COLUMN")) != null ? _a45 : "id").trim();
22092
22361
  var _a46;
22093
- var CHAT_REACTIONS_EMOJI_COLUMN = ((_a46 = getRuntimeEnv("VITE_CHAT_REACTIONS_EMOJI_COLUMN")) != null ? _a46 : "emoji").trim();
22362
+ var CHAT_REACTIONS_MESSAGE_ID_COLUMN = ((_a46 = getRuntimeEnv("VITE_CHAT_REACTIONS_MESSAGE_ID_COLUMN")) != null ? _a46 : "message_id").trim();
22094
22363
  var _a47;
22095
- var CHAT_REACTIONS_CREATED_AT_COLUMN = ((_a47 = getRuntimeEnv("VITE_CHAT_REACTIONS_CREATED_AT_COLUMN")) != null ? _a47 : "created_at").trim();
22364
+ var CHAT_REACTIONS_USER_ID_COLUMN = ((_a47 = getRuntimeEnv("VITE_CHAT_REACTIONS_USER_ID_COLUMN")) != null ? _a47 : "user_id").trim();
22096
22365
  var _a48;
22097
- var CHAT_LOGS_TABLE = ((_a48 = getRuntimeEnv("VITE_CHAT_LOGS_TABLE")) != null ? _a48 : "chat_message_logs").trim();
22366
+ var CHAT_REACTIONS_EMOJI_COLUMN = ((_a48 = getRuntimeEnv("VITE_CHAT_REACTIONS_EMOJI_COLUMN")) != null ? _a48 : "emoji").trim();
22098
22367
  var _a49;
22099
- var CHAT_LOGS_ID_COLUMN = ((_a49 = getRuntimeEnv("VITE_CHAT_LOGS_ID_COLUMN")) != null ? _a49 : "id").trim();
22368
+ var CHAT_REACTIONS_CREATED_AT_COLUMN = ((_a49 = getRuntimeEnv("VITE_CHAT_REACTIONS_CREATED_AT_COLUMN")) != null ? _a49 : "created_at").trim();
22100
22369
  var _a50;
22101
- var CHAT_LOGS_MESSAGE_ID_COLUMN = ((_a50 = getRuntimeEnv("VITE_CHAT_LOGS_MESSAGE_ID_COLUMN")) != null ? _a50 : "message_id").trim();
22370
+ var CHAT_LOGS_TABLE = ((_a50 = getRuntimeEnv("VITE_CHAT_LOGS_TABLE")) != null ? _a50 : "chat_message_logs").trim();
22102
22371
  var _a51;
22103
- var CHAT_LOGS_ACTOR_ID_COLUMN = ((_a51 = getRuntimeEnv("VITE_CHAT_LOGS_ACTOR_ID_COLUMN")) != null ? _a51 : "actor_id").trim();
22372
+ var CHAT_LOGS_ID_COLUMN = ((_a51 = getRuntimeEnv("VITE_CHAT_LOGS_ID_COLUMN")) != null ? _a51 : "id").trim();
22104
22373
  var _a52;
22105
- var CHAT_LOGS_ACTION_COLUMN = ((_a52 = getRuntimeEnv("VITE_CHAT_LOGS_ACTION_COLUMN")) != null ? _a52 : "action").trim();
22374
+ var CHAT_LOGS_MESSAGE_ID_COLUMN = ((_a52 = getRuntimeEnv("VITE_CHAT_LOGS_MESSAGE_ID_COLUMN")) != null ? _a52 : "message_id").trim();
22106
22375
  var _a53;
22107
- var CHAT_LOGS_PREVIOUS_TEXT_COLUMN = ((_a53 = getRuntimeEnv("VITE_CHAT_LOGS_PREVIOUS_TEXT_COLUMN")) != null ? _a53 : "previous_text").trim();
22376
+ var CHAT_LOGS_ACTOR_ID_COLUMN = ((_a53 = getRuntimeEnv("VITE_CHAT_LOGS_ACTOR_ID_COLUMN")) != null ? _a53 : "actor_id").trim();
22108
22377
  var _a54;
22109
- var CHAT_LOGS_NEXT_TEXT_COLUMN = ((_a54 = getRuntimeEnv("VITE_CHAT_LOGS_NEXT_TEXT_COLUMN")) != null ? _a54 : "next_text").trim();
22378
+ var CHAT_LOGS_ACTION_COLUMN = ((_a54 = getRuntimeEnv("VITE_CHAT_LOGS_ACTION_COLUMN")) != null ? _a54 : "action").trim();
22110
22379
  var _a55;
22111
- var CHAT_LOGS_CREATED_AT_COLUMN = ((_a55 = getRuntimeEnv("VITE_CHAT_LOGS_CREATED_AT_COLUMN")) != null ? _a55 : "created_at").trim();
22380
+ var CHAT_LOGS_PREVIOUS_TEXT_COLUMN = ((_a55 = getRuntimeEnv("VITE_CHAT_LOGS_PREVIOUS_TEXT_COLUMN")) != null ? _a55 : "previous_text").trim();
22381
+ var _a56;
22382
+ var CHAT_LOGS_NEXT_TEXT_COLUMN = ((_a56 = getRuntimeEnv("VITE_CHAT_LOGS_NEXT_TEXT_COLUMN")) != null ? _a56 : "next_text").trim();
22383
+ var _a57;
22384
+ var CHAT_LOGS_CREATED_AT_COLUMN = ((_a57 = getRuntimeEnv("VITE_CHAT_LOGS_CREATED_AT_COLUMN")) != null ? _a57 : "created_at").trim();
22112
22385
  var CHAT_MESSAGE_HISTORY_LIMIT = 200;
22113
22386
  var CHAT_EDIT_WINDOW_MINUTES2 = 15;
22114
22387
  var CHAT_DELETED_PLACEHOLDER_TEXT2 = "Mensagem deletada";
22115
- var _a56;
22116
- var TELESCUP_BASE_URL = (_a56 = getRuntimeEnv("VITE_TELESCUP_BASE_URL")) == null ? void 0 : _a56.trim();
22117
- var _a57;
22118
- var SUPABASE_URL2 = (_a57 = getRuntimeEnv("VITE_SUPABASE_URL")) == null ? void 0 : _a57.trim();
22119
- var TELESCUP_BASE_URL_FALLBACK = SUPABASE_URL2 ? `${SUPABASE_URL2.replace(/\/+$/, "")}/functions/v1` : void 0;
22120
- var ACCESS_TOKEN_STORAGE_KEY = "cc_access_token";
22121
22388
  var _a58;
22122
- var ACCOUNTS_BASE_URL2 = ((_a58 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a58 : "https://accounts.cupcode.com.br").trim().replace(/\/+$/, "");
22389
+ var TELESCUP_BASE_URL = (_a58 = getRuntimeEnv("VITE_TELESCUP_BASE_URL")) == null ? void 0 : _a58.trim();
22123
22390
  var _a59;
22124
- var MC_BASE_URL2 = ((_a59 = getRuntimeEnv("VITE_MC_BASE_URL")) != null ? _a59 : "https://mc.cupcode.com.br").trim().replace(/\/+$/, "");
22391
+ var SUPABASE_URL2 = (_a59 = getRuntimeEnv("VITE_SUPABASE_URL")) == null ? void 0 : _a59.trim();
22392
+ var TELESCUP_BASE_URL_FALLBACK = SUPABASE_URL2 ? `${SUPABASE_URL2.replace(/\/+$/, "")}/functions/v1` : void 0;
22393
+ var ACCESS_TOKEN_STORAGE_KEY = "cc_access_token";
22125
22394
  var _a60;
22126
- var ACCOUNTS_LANGUAGE_ENDPOINT = (_a60 = getRuntimeEnv("VITE_ACCOUNTS_LANGUAGE_ENDPOINT")) == null ? void 0 : _a60.trim();
22395
+ var ACCOUNTS_BASE_URL2 = ((_a60 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a60 : "https://accounts.cupcode.com.br").trim().replace(/\/+$/, "");
22127
22396
  var _a61;
22128
- var ACCOUNTS_ACTIVITY_ENDPOINT = (_a61 = getRuntimeEnv("VITE_ACCOUNTS_ACTIVITY_ENDPOINT")) == null ? void 0 : _a61.trim();
22397
+ var MC_BASE_URL2 = ((_a61 = getRuntimeEnv("VITE_MC_BASE_URL")) != null ? _a61 : "https://mc.cupcode.com.br").trim().replace(/\/+$/, "");
22398
+ var _a62;
22399
+ var ACCOUNTS_LANGUAGE_ENDPOINT = (_a62 = getRuntimeEnv("VITE_ACCOUNTS_LANGUAGE_ENDPOINT")) == null ? void 0 : _a62.trim();
22400
+ var _a63;
22401
+ var ACCOUNTS_ACTIVITY_ENDPOINT = (_a63 = getRuntimeEnv("VITE_ACCOUNTS_ACTIVITY_ENDPOINT")) == null ? void 0 : _a63.trim();
22129
22402
  var PRESENCE_STATUS_VALUES = [
22130
22403
  "online",
22131
22404
  "away",
@@ -22185,10 +22458,10 @@ var toStringOrUndefined = (value) => {
22185
22458
  const trimmed = value.trim();
22186
22459
  return trimmed === "" ? void 0 : trimmed;
22187
22460
  };
22188
- var UUID_REGEX4 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
22461
+ var UUID_REGEX5 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
22189
22462
  var isLikelyUuid = (value) => {
22190
22463
  if (!value) return false;
22191
- return UUID_REGEX4.test(value.trim());
22464
+ return UUID_REGEX5.test(value.trim());
22192
22465
  };
22193
22466
  var isMeaningfulUserLabel = (value) => {
22194
22467
  const normalized = toStringOrUndefined(value);
@@ -22266,12 +22539,12 @@ var resolveCurrentUserId = (user) => {
22266
22539
  return null;
22267
22540
  };
22268
22541
  var resolveUserIdFromClaims = (claims) => {
22269
- var _a72, _b6, _c, _d, _e;
22270
- return (_e = (_d = (_c = (_b6 = (_a72 = toStringOrUndefined(claims.sub)) != null ? _a72 : toStringOrUndefined(claims.user_id)) != null ? _b6 : toStringOrUndefined(claims.userId)) != null ? _c : toStringOrUndefined(claims.uid)) != null ? _d : toStringOrUndefined(claims.id)) != null ? _e : toStringOrUndefined(claims["https://cupcode.com/user_id"]);
22542
+ var _a74, _b7, _c, _d, _e;
22543
+ return (_e = (_d = (_c = (_b7 = (_a74 = toStringOrUndefined(claims.sub)) != null ? _a74 : toStringOrUndefined(claims.user_id)) != null ? _b7 : toStringOrUndefined(claims.userId)) != null ? _c : toStringOrUndefined(claims.uid)) != null ? _d : toStringOrUndefined(claims.id)) != null ? _e : toStringOrUndefined(claims["https://cupcode.com/user_id"]);
22271
22544
  };
22272
22545
  var resolveEmailFromClaims = (claims) => {
22273
- var _a72, _b6;
22274
- const candidate = (_b6 = (_a72 = toStringOrUndefined(claims.email)) != null ? _a72 : toStringOrUndefined(claims["https://cupcode.com/email"])) != null ? _b6 : toStringOrUndefined(claims.preferred_username);
22546
+ var _a74, _b7;
22547
+ const candidate = (_b7 = (_a74 = toStringOrUndefined(claims.email)) != null ? _a74 : toStringOrUndefined(claims["https://cupcode.com/email"])) != null ? _b7 : toStringOrUndefined(claims.preferred_username);
22275
22548
  if (!candidate || !candidate.includes("@")) return void 0;
22276
22549
  return candidate.toLowerCase();
22277
22550
  };
@@ -22336,8 +22609,8 @@ var parseRecentActivityItems = (payload) => {
22336
22609
  return [];
22337
22610
  };
22338
22611
  return toRows(payload).map((item, index) => {
22339
- var _a72, _b6, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
22340
- const id = (_b6 = (_a72 = toStringOrUndefined(item.id)) != null ? _a72 : toStringOrUndefined(item.event_id)) != null ? _b6 : `accounts-activity-${index}`;
22612
+ var _a74, _b7, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
22613
+ const id = (_b7 = (_a74 = toStringOrUndefined(item.id)) != null ? _a74 : toStringOrUndefined(item.event_id)) != null ? _b7 : `accounts-activity-${index}`;
22341
22614
  const title = (_e = (_d = (_c = toStringOrUndefined(item.title)) != null ? _c : toStringOrUndefined(item.action)) != null ? _d : toStringOrUndefined(item.event)) != null ? _e : toStringOrUndefined(item.type);
22342
22615
  if (!title) return null;
22343
22616
  const description = (_h = (_g = (_f = toStringOrUndefined(item.description)) != null ? _f : toStringOrUndefined(item.details)) != null ? _g : toStringOrUndefined(item.message)) != null ? _h : toStringOrUndefined(item.summary);
@@ -22420,9 +22693,9 @@ var dedupeAndSortReactions = (reactions) => {
22420
22693
  });
22421
22694
  };
22422
22695
  var getErrorText = (error) => {
22423
- var _a72, _b6, _c;
22696
+ var _a74, _b7, _c;
22424
22697
  const typed = error;
22425
- return `${(_a72 = typed == null ? void 0 : typed.message) != null ? _a72 : ""} ${(_b6 = typed == null ? void 0 : typed.details) != null ? _b6 : ""} ${(_c = typed == null ? void 0 : typed.hint) != null ? _c : ""}`.toLowerCase();
22698
+ return `${(_a74 = typed == null ? void 0 : typed.message) != null ? _a74 : ""} ${(_b7 = typed == null ? void 0 : typed.details) != null ? _b7 : ""} ${(_c = typed == null ? void 0 : typed.hint) != null ? _c : ""}`.toLowerCase();
22426
22699
  };
22427
22700
  var isMissingColumnError = (error, column) => {
22428
22701
  const normalized = getErrorText(error);
@@ -22448,13 +22721,13 @@ var isRecoverableLookupError = (error, relationName) => {
22448
22721
  return normalized.includes("schema cache") || normalized.includes("permission denied") || normalized.includes("does not exist") || normalized.includes("could not find");
22449
22722
  };
22450
22723
  var toChatMessage = (row, currentUserId) => {
22451
- var _a72, _b6, _c, _d, _e, _f;
22452
- const id = (_a72 = toStringOrUndefined(row[CHAT_MESSAGES_ID_COLUMN])) != null ? _a72 : `${toStringOrUndefined(row[CHAT_MESSAGES_SENDER_COLUMN])}-${toStringOrUndefined(row[CHAT_MESSAGES_RECIPIENT_COLUMN])}-${toStringOrUndefined(row[CHAT_MESSAGES_CREATED_AT_COLUMN])}`;
22724
+ var _a74, _b7, _c, _d, _e, _f;
22725
+ const id = (_a74 = toStringOrUndefined(row[CHAT_MESSAGES_ID_COLUMN])) != null ? _a74 : `${toStringOrUndefined(row[CHAT_MESSAGES_SENDER_COLUMN])}-${toStringOrUndefined(row[CHAT_MESSAGES_RECIPIENT_COLUMN])}-${toStringOrUndefined(row[CHAT_MESSAGES_CREATED_AT_COLUMN])}`;
22453
22726
  const senderId = toStringOrUndefined(row[CHAT_MESSAGES_SENDER_COLUMN]);
22454
22727
  const recipientId = toStringOrUndefined(row[CHAT_MESSAGES_RECIPIENT_COLUMN]);
22455
22728
  const text = toStringOrUndefined(row[CHAT_MESSAGES_TEXT_COLUMN]);
22456
22729
  const createdAt = toStringOrUndefined(row[CHAT_MESSAGES_CREATED_AT_COLUMN]);
22457
- const editedAt = (_b6 = toStringOrUndefined(row[CHAT_MESSAGES_EDITED_AT_COLUMN])) != null ? _b6 : null;
22730
+ const editedAt = (_b7 = toStringOrUndefined(row[CHAT_MESSAGES_EDITED_AT_COLUMN])) != null ? _b7 : null;
22458
22731
  const readAt = (_c = toStringOrUndefined(row[CHAT_MESSAGES_READ_AT_COLUMN])) != null ? _c : null;
22459
22732
  const replyToMessageId = (_d = toStringOrUndefined(row[CHAT_MESSAGES_REPLY_TO_COLUMN])) != null ? _d : null;
22460
22733
  const deletedAt = (_e = toStringOrUndefined(row[CHAT_MESSAGES_DELETED_AT_COLUMN])) != null ? _e : null;
@@ -22489,13 +22762,13 @@ var toChatReaction = (row) => {
22489
22762
  return { id, messageId, userId, emoji, createdAt };
22490
22763
  };
22491
22764
  var toChatMessageLog = (row, messagesById) => {
22492
- var _a72, _b6;
22765
+ var _a74, _b7;
22493
22766
  const id = toStringOrUndefined(row[CHAT_LOGS_ID_COLUMN]);
22494
22767
  const messageId = toStringOrUndefined(row[CHAT_LOGS_MESSAGE_ID_COLUMN]);
22495
22768
  const actorId = toStringOrUndefined(row[CHAT_LOGS_ACTOR_ID_COLUMN]);
22496
22769
  const action = toStringOrUndefined(row[CHAT_LOGS_ACTION_COLUMN]);
22497
- const previousText = (_a72 = toStringOrUndefined(row[CHAT_LOGS_PREVIOUS_TEXT_COLUMN])) != null ? _a72 : null;
22498
- const nextText = (_b6 = toStringOrUndefined(row[CHAT_LOGS_NEXT_TEXT_COLUMN])) != null ? _b6 : null;
22770
+ const previousText = (_a74 = toStringOrUndefined(row[CHAT_LOGS_PREVIOUS_TEXT_COLUMN])) != null ? _a74 : null;
22771
+ const nextText = (_b7 = toStringOrUndefined(row[CHAT_LOGS_NEXT_TEXT_COLUMN])) != null ? _b7 : null;
22499
22772
  const createdAt = toStringOrUndefined(row[CHAT_LOGS_CREATED_AT_COLUMN]);
22500
22773
  if (!id || !messageId || !action || action !== "edit" && action !== "delete") return null;
22501
22774
  const relatedMessage = messagesById.get(messageId);
@@ -22536,7 +22809,7 @@ var MainNavbar = ({
22536
22809
  onOpenAccountClick,
22537
22810
  getAccessToken
22538
22811
  }) => {
22539
- var _a72, _b6, _c;
22812
+ var _a74, _b7, _c;
22540
22813
  const [chatUsers, setChatUsers] = useState13([]);
22541
22814
  const [chatMessages, setChatMessages] = useState13([]);
22542
22815
  const [chatMessageLogs, setChatMessageLogs] = useState13([]);
@@ -22567,19 +22840,19 @@ var MainNavbar = ({
22567
22840
  return "/";
22568
22841
  }, [pathname]);
22569
22842
  const currentUserId = useMemo8(() => {
22570
- var _a73;
22571
- return (_a73 = resolveCurrentUserId(authUser)) != null ? _a73 : tokenDerivedUserId;
22843
+ var _a75;
22844
+ return (_a75 = resolveCurrentUserId(authUser)) != null ? _a75 : tokenDerivedUserId;
22572
22845
  }, [authUser, tokenDerivedUserId]);
22573
22846
  const authEmail = useMemo8(
22574
22847
  () => {
22575
- var _a73, _b7;
22576
- return (_b7 = (_a73 = toStringOrUndefined(authUser == null ? void 0 : authUser.email)) == null ? void 0 : _a73.toLowerCase()) != null ? _b7 : tokenDerivedEmail;
22848
+ var _a75, _b8;
22849
+ return (_b8 = (_a75 = toStringOrUndefined(authUser == null ? void 0 : authUser.email)) == null ? void 0 : _a75.toLowerCase()) != null ? _b8 : tokenDerivedEmail;
22577
22850
  },
22578
22851
  [authUser == null ? void 0 : authUser.email, tokenDerivedEmail]
22579
22852
  );
22580
22853
  const isChatSuperAdmin = useMemo8(() => {
22581
- var _a73, _b7;
22582
- const roleTokens = `${(_a73 = authUser == null ? void 0 : authUser.role) != null ? _a73 : ""} ${(_b7 = authUser == null ? void 0 : authUser.jobTitle) != null ? _b7 : ""}`.toLowerCase();
22854
+ var _a75, _b8;
22855
+ const roleTokens = `${(_a75 = authUser == null ? void 0 : authUser.role) != null ? _a75 : ""} ${(_b8 = authUser == null ? void 0 : authUser.jobTitle) != null ? _b8 : ""}`.toLowerCase();
22583
22856
  return roleTokens.includes("superadmin") || roleTokens.includes("super admin");
22584
22857
  }, [authUser == null ? void 0 : authUser.jobTitle, authUser == null ? void 0 : authUser.role]);
22585
22858
  const resolvedTelescupBaseUrl = useMemo8(() => {
@@ -22588,7 +22861,7 @@ var MainNavbar = ({
22588
22861
  }
22589
22862
  return TELESCUP_BASE_URL_FALLBACK;
22590
22863
  }, []);
22591
- const resolvedProfileAvatarUrl = (_b6 = (_a72 = resolveChatAvatarUrl(persistedProfileAvatarValue)) != null ? _a72 : authUser == null ? void 0 : authUser.picture) != null ? _b6 : void 0;
22864
+ const resolvedProfileAvatarUrl = (_b7 = (_a74 = resolveChatAvatarUrl(persistedProfileAvatarValue)) != null ? _a74 : authUser == null ? void 0 : authUser.picture) != null ? _b7 : void 0;
22592
22865
  const effectiveCurrentUserId = resolvedSenderId != null ? resolvedSenderId : currentUserId;
22593
22866
  const hasStoredAccessToken = (() => {
22594
22867
  if (typeof window === "undefined") return false;
@@ -22626,7 +22899,7 @@ var MainNavbar = ({
22626
22899
  }
22627
22900
  let canceled = false;
22628
22901
  const resolveIdentityFromToken = async () => {
22629
- var _a73, _b7;
22902
+ var _a75, _b8;
22630
22903
  try {
22631
22904
  let token = null;
22632
22905
  if (typeof window !== "undefined") {
@@ -22646,9 +22919,9 @@ var MainNavbar = ({
22646
22919
  }
22647
22920
  return;
22648
22921
  }
22649
- const claims = (_a73 = decodeJwt(token)) != null ? _a73 : {};
22922
+ const claims = (_a75 = decodeJwt(token)) != null ? _a75 : {};
22650
22923
  if (canceled) return;
22651
- setTokenDerivedUserId((_b7 = resolveUserIdFromClaims(claims)) != null ? _b7 : null);
22924
+ setTokenDerivedUserId((_b8 = resolveUserIdFromClaims(claims)) != null ? _b8 : null);
22652
22925
  setTokenDerivedEmail(resolveEmailFromClaims(claims));
22653
22926
  } catch (error) {
22654
22927
  if (isRuntimeDev()) {
@@ -22691,7 +22964,7 @@ var MainNavbar = ({
22691
22964
  );
22692
22965
  const warnings = [];
22693
22966
  const runLookup = async (kind, value, columns) => {
22694
- var _a73, _b7, _c2;
22967
+ var _a75, _b8, _c2;
22695
22968
  for (const tableName of CHAT_USERS_LOOKUP_TABLES) {
22696
22969
  for (const columnName of columns) {
22697
22970
  if (!columnName) continue;
@@ -22700,10 +22973,10 @@ var MainNavbar = ({
22700
22973
  const lookupError = response.error;
22701
22974
  if (lookupError) {
22702
22975
  if (isRecoverableLookupError(lookupError, tableName)) {
22703
- warnings.push(`${tableName}.${columnName}: ${(_a73 = lookupError.message) != null ? _a73 : "falha de lookup"}`);
22976
+ warnings.push(`${tableName}.${columnName}: ${(_a75 = lookupError.message) != null ? _a75 : "falha de lookup"}`);
22704
22977
  continue;
22705
22978
  }
22706
- warnings.push(`${tableName}.${columnName}: ${(_b7 = lookupError.message) != null ? _b7 : "falha de lookup"}`);
22979
+ warnings.push(`${tableName}.${columnName}: ${(_b8 = lookupError.message) != null ? _b8 : "falha de lookup"}`);
22707
22980
  continue;
22708
22981
  }
22709
22982
  const row2 = (_c2 = response.data) == null ? void 0 : _c2[0];
@@ -22752,7 +23025,7 @@ var MainNavbar = ({
22752
23025
  return sessionStorage.getItem(ACCESS_TOKEN_STORAGE_KEY);
22753
23026
  };
22754
23027
  const loadAccountsContext = async () => {
22755
- var _a73, _b7, _c2, _d, _e, _f, _g;
23028
+ var _a75, _b8, _c2, _d, _e, _f, _g;
22756
23029
  setIsAccountsActivityLoading(true);
22757
23030
  try {
22758
23031
  const token = await resolveAccountsToken();
@@ -22762,9 +23035,9 @@ var MainNavbar = ({
22762
23035
  }
22763
23036
  return;
22764
23037
  }
22765
- const claims = (_a73 = decodeJwt(token)) != null ? _a73 : {};
23038
+ const claims = (_a75 = decodeJwt(token)) != null ? _a75 : {};
22766
23039
  const languageFromToken = normalizeMenuLanguage(
22767
- (_d = (_c2 = (_b7 = claims.locale) != null ? _b7 : claims.lang) != null ? _c2 : claims.language) != null ? _d : claims["https://cupcode.com/locale"]
23040
+ (_d = (_c2 = (_b8 = claims.locale) != null ? _b8 : claims.lang) != null ? _c2 : claims.language) != null ? _d : claims["https://cupcode.com/locale"]
22768
23041
  );
22769
23042
  if (!canceled) {
22770
23043
  setAccountsLanguage(languageFromToken);
@@ -22850,11 +23123,11 @@ var MainNavbar = ({
22850
23123
  }
22851
23124
  let canceled = false;
22852
23125
  const loadChatData = async () => {
22853
- var _a73, _b7, _c2, _d, _e, _f, _g, _h, _i;
23126
+ var _a75, _b8, _c2, _d, _e, _f, _g, _h, _i;
22854
23127
  setIsChatLoading(true);
22855
23128
  setChatError(null);
22856
23129
  const fetchFirstAvailableTable = async (tableNames) => {
22857
- var _a74;
23130
+ var _a76;
22858
23131
  let lastError = null;
22859
23132
  for (const tableName of tableNames) {
22860
23133
  const response = await supabase.from(tableName).select("*");
@@ -22876,7 +23149,7 @@ var MainNavbar = ({
22876
23149
  }
22877
23150
  }
22878
23151
  return {
22879
- tableName: (_a74 = tableNames[0]) != null ? _a74 : null,
23152
+ tableName: (_a76 = tableNames[0]) != null ? _a76 : null,
22880
23153
  data: null,
22881
23154
  error: lastError
22882
23155
  };
@@ -22978,7 +23251,7 @@ var MainNavbar = ({
22978
23251
  console.warn("[chat] Falha ao carregar presen\xE7a:", presenceResponse.error.message);
22979
23252
  }
22980
23253
  } else {
22981
- (_a73 = presenceResponse.data) == null ? void 0 : _a73.forEach((row) => {
23254
+ (_a75 = presenceResponse.data) == null ? void 0 : _a75.forEach((row) => {
22982
23255
  const userId = readFirstRecordString(row, [USER_PRESENCE_USER_ID_COLUMN, "user_id", "id"]);
22983
23256
  if (!userId) return;
22984
23257
  const statusValue = readFirstRecordString(row, [USER_PRESENCE_STATUS_COLUMN, "status", "presence_status"]);
@@ -22992,7 +23265,7 @@ var MainNavbar = ({
22992
23265
  console.warn("[chat] Falha ao carregar profiles para enriquecimento:", profilesResponse.error.message);
22993
23266
  }
22994
23267
  } else {
22995
- (_b7 = profilesResponse.data) == null ? void 0 : _b7.forEach((row) => {
23268
+ (_b8 = profilesResponse.data) == null ? void 0 : _b8.forEach((row) => {
22996
23269
  const id = readFirstRecordString(row, [...CHAT_USERS_LOOKUP_ID_COLUMNS, "id", "user_id"]);
22997
23270
  const email = readFirstRecordString(row, [...CHAT_USERS_LOOKUP_EMAIL_COLUMNS, "email"]);
22998
23271
  if (id) profileById.set(id, row);
@@ -23020,13 +23293,13 @@ var MainNavbar = ({
23020
23293
  }
23021
23294
  } else {
23022
23295
  (_e = usersResponse.data) == null ? void 0 : _e.forEach((row) => {
23023
- var _a74, _b8, _c3, _d2, _e2, _f2, _g2, _h2;
23296
+ var _a76, _b9, _c3, _d2, _e2, _f2, _g2, _h2;
23024
23297
  const id = readFirstRecordString(row, [...CHAT_USERS_LOOKUP_ID_COLUMNS, "id", "user_id"]);
23025
23298
  if (!id || id === effectiveCurrentUserId) return;
23026
23299
  const rowEmail = readFirstRecordString(row, [...CHAT_USERS_LOOKUP_EMAIL_COLUMNS, "email"]);
23027
- const profile = (_a74 = profileById.get(id)) != null ? _a74 : rowEmail ? profileByEmail.get(rowEmail.toLowerCase()) : void 0;
23300
+ const profile = (_a76 = profileById.get(id)) != null ? _a76 : rowEmail ? profileByEmail.get(rowEmail.toLowerCase()) : void 0;
23028
23301
  const email = rowEmail != null ? rowEmail : readFirstRecordString(profile, [CHAT_USERS_UPDATE_EMAIL_COLUMN, CHAT_USERS_EMAIL_COLUMN, "email"]);
23029
- const rawUsername = (_b8 = readFirstRecordString(row, [CHAT_USERS_USERNAME_COLUMN, "username", "user_name"])) != null ? _b8 : readFirstRecordString(profile, [CHAT_USERS_USERNAME_COLUMN, "username", "user_name"]);
23302
+ const rawUsername = (_b9 = readFirstRecordString(row, [CHAT_USERS_USERNAME_COLUMN, "username", "user_name"])) != null ? _b9 : readFirstRecordString(profile, [CHAT_USERS_USERNAME_COLUMN, "username", "user_name"]);
23030
23303
  const username = buildHandle2(rawUsername, email);
23031
23304
  const rawName = (_c3 = readFirstRecordString(row, [CHAT_USERS_NAME_COLUMN, "full_name", "display_name", "name", "username"])) != null ? _c3 : readFirstRecordString(profile, [CHAT_USERS_NAME_COLUMN, "full_name", "display_name", "name", "username"]);
23032
23305
  const name = resolveReadableUserLabel(rawName, rawUsername, email, id);
@@ -23044,7 +23317,7 @@ var MainNavbar = ({
23044
23317
  });
23045
23318
  }
23046
23319
  profileById.forEach((profile, id) => {
23047
- var _a74, _b8;
23320
+ var _a76, _b9;
23048
23321
  if (!id || id === effectiveCurrentUserId || usersMap.has(id)) return;
23049
23322
  const email = readFirstRecordString(profile, [CHAT_USERS_UPDATE_EMAIL_COLUMN, CHAT_USERS_EMAIL_COLUMN, "email"]);
23050
23323
  const rawUsername = readFirstRecordString(profile, [CHAT_USERS_USERNAME_COLUMN, "username", "user_name"]);
@@ -23065,7 +23338,7 @@ var MainNavbar = ({
23065
23338
  email,
23066
23339
  avatarUrl: resolveChatAvatarUrl(avatarValue),
23067
23340
  roleLabel,
23068
- status: (_b8 = (_a74 = presenceMap.get(id)) != null ? _a74 : readPresenceStatusFromRecord(profile)) != null ? _b8 : "offline"
23341
+ status: (_b9 = (_a76 = presenceMap.get(id)) != null ? _a76 : readPresenceStatusFromRecord(profile)) != null ? _b9 : "offline"
23069
23342
  });
23070
23343
  });
23071
23344
  presenceMap.forEach((statusValue, id) => {
@@ -23107,7 +23380,7 @@ var MainNavbar = ({
23107
23380
  );
23108
23381
  setChatMessages(resolvedMessages);
23109
23382
  resolvedMessages.forEach((message) => {
23110
- var _a74, _b8;
23383
+ var _a76, _b9;
23111
23384
  const contactId = message.contactId;
23112
23385
  if (!contactId || contactId === effectiveCurrentUserId || usersMap.has(contactId)) return;
23113
23386
  const profile = profileById.get(contactId);
@@ -23130,7 +23403,7 @@ var MainNavbar = ({
23130
23403
  email,
23131
23404
  avatarUrl: resolveChatAvatarUrl(avatarValue),
23132
23405
  roleLabel,
23133
- status: (_b8 = (_a74 = presenceMap.get(contactId)) != null ? _a74 : readPresenceStatusFromRecord(profile)) != null ? _b8 : "offline"
23406
+ status: (_b9 = (_a76 = presenceMap.get(contactId)) != null ? _a76 : readPresenceStatusFromRecord(profile)) != null ? _b9 : "offline"
23134
23407
  });
23135
23408
  });
23136
23409
  const resolvedUsers = [...usersMap.values()].sort((left, right) => left.name.localeCompare(right.name, "pt-BR"));
@@ -23315,10 +23588,10 @@ var MainNavbar = ({
23315
23588
  const chatUnreadByUser = useMemo8(() => {
23316
23589
  const counters = {};
23317
23590
  chatMessages.forEach((message) => {
23318
- var _a73;
23591
+ var _a75;
23319
23592
  if (message.sender !== "them") return;
23320
23593
  if (message.readAt) return;
23321
- counters[message.contactId] = ((_a73 = counters[message.contactId]) != null ? _a73 : 0) + 1;
23594
+ counters[message.contactId] = ((_a75 = counters[message.contactId]) != null ? _a75 : 0) + 1;
23322
23595
  });
23323
23596
  return counters;
23324
23597
  }, [chatMessages]);
@@ -23366,9 +23639,9 @@ var MainNavbar = ({
23366
23639
  }
23367
23640
  const persistedReadAtByMessageId = /* @__PURE__ */ new Map();
23368
23641
  (data != null ? data : []).forEach((row) => {
23369
- var _a73;
23642
+ var _a75;
23370
23643
  const messageId = toStringOrUndefined(row[CHAT_MESSAGES_ID_COLUMN]);
23371
- const persistedReadAt = (_a73 = toStringOrUndefined(row[CHAT_MESSAGES_READ_AT_COLUMN])) != null ? _a73 : readAt;
23644
+ const persistedReadAt = (_a75 = toStringOrUndefined(row[CHAT_MESSAGES_READ_AT_COLUMN])) != null ? _a75 : readAt;
23372
23645
  if (!messageId) return;
23373
23646
  persistedReadAtByMessageId.set(messageId, persistedReadAt);
23374
23647
  });
@@ -23537,8 +23810,8 @@ var MainNavbar = ({
23537
23810
  (current) => dedupeAndSortMessages(
23538
23811
  current.map(
23539
23812
  (message) => {
23540
- var _a73;
23541
- return message.id === messageId ? { ...message, text: previousText, editedAt: (_a73 = targetMessage.editedAt) != null ? _a73 : null } : message;
23813
+ var _a75;
23814
+ return message.id === messageId ? { ...message, text: previousText, editedAt: (_a75 = targetMessage.editedAt) != null ? _a75 : null } : message;
23542
23815
  }
23543
23816
  )
23544
23817
  )
@@ -23569,13 +23842,13 @@ var MainNavbar = ({
23569
23842
  (current) => dedupeAndSortMessages(
23570
23843
  current.map(
23571
23844
  (message) => {
23572
- var _a73;
23845
+ var _a75;
23573
23846
  return message.id === messageId ? {
23574
23847
  ...message,
23575
23848
  text: CHAT_DELETED_PLACEHOLDER_TEXT2,
23576
23849
  deletedAt,
23577
23850
  deletedBy: effectiveCurrentUserId,
23578
- editedAt: (_a73 = message.editedAt) != null ? _a73 : deletedAt
23851
+ editedAt: (_a75 = message.editedAt) != null ? _a75 : deletedAt
23579
23852
  } : message;
23580
23853
  }
23581
23854
  )
@@ -23759,8 +24032,8 @@ var MainNavbar = ({
23759
24032
  ...item,
23760
24033
  isActive,
23761
24034
  onClick: isAnchor ? item.onClick : (event) => {
23762
- var _a73;
23763
- (_a73 = item.onClick) == null ? void 0 : _a73.call(item, event);
24035
+ var _a75;
24036
+ (_a75 = item.onClick) == null ? void 0 : _a75.call(item, event);
23764
24037
  if (!onNavigate || event.defaultPrevented) return;
23765
24038
  event.preventDefault();
23766
24039
  onNavigate(item.href);
@@ -23802,9 +24075,9 @@ var MainNavbar = ({
23802
24075
  window.open(`${MC_BASE_URL2}/tasks`, "_blank", "noopener,noreferrer");
23803
24076
  };
23804
24077
  const handleChatOpenUserProfile = useCallback6(({ userId }) => {
23805
- var _a73;
24078
+ var _a75;
23806
24079
  if (!userId || typeof window === "undefined") return;
23807
- const baseUrl = ((_a73 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a73 : "https://accounts.cupcode.com.br").replace(
24080
+ const baseUrl = ((_a75 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a75 : "https://accounts.cupcode.com.br").replace(
23808
24081
  /\/+$/,
23809
24082
  ""
23810
24083
  );
@@ -23874,8 +24147,8 @@ var MainNavbar = ({
23874
24147
  );
23875
24148
  const handleProfileAvatarChange = useCallback6(
23876
24149
  async ({ avatarId, avatarUrl }) => {
23877
- var _a73;
23878
- const normalizedAvatarId = (_a73 = parseAssetId(avatarId)) != null ? _a73 : parseAssetId(avatarUrl);
24150
+ var _a75;
24151
+ const normalizedAvatarId = (_a75 = parseAssetId(avatarId)) != null ? _a75 : parseAssetId(avatarUrl);
23879
24152
  if (!normalizedAvatarId) {
23880
24153
  throw new Error("ID da imagem inv\xE1lido.");
23881
24154
  }
@@ -23891,27 +24164,27 @@ var MainNavbar = ({
23891
24164
  );
23892
24165
  const updateErrors = [];
23893
24166
  const isRecoverableUpdateError = (error) => {
23894
- var _a74;
23895
- const message = ((_a74 = error.message) != null ? _a74 : "").toLowerCase();
24167
+ var _a76;
24168
+ const message = ((_a76 = error.message) != null ? _a76 : "").toLowerCase();
23896
24169
  return error.code === "55000" || error.code === "42P01" || error.code === "42703" || error.code === "42501" || error.code === "22P02" || message.includes("cannot update view") || message.includes("not automatically updatable") || message.includes("permission denied") || message.includes("invalid input syntax") || message.includes("relation") && message.includes("does not exist") || message.includes("column") && message.includes("does not exist");
23897
24170
  };
23898
24171
  const isRecoverableLookupError2 = (error) => {
23899
- var _a74;
23900
- const message = ((_a74 = error.message) != null ? _a74 : "").toLowerCase();
24172
+ var _a76;
24173
+ const message = ((_a76 = error.message) != null ? _a76 : "").toLowerCase();
23901
24174
  return error.code === "42P01" || error.code === "42703" || error.code === "42501" || message.includes("relation") && message.includes("does not exist") || message.includes("column") && message.includes("does not exist") || message.includes("permission denied");
23902
24175
  };
23903
24176
  const isPermissionDeniedError2 = (error) => {
23904
- var _a74;
23905
- const message = ((_a74 = error.message) != null ? _a74 : "").toLowerCase();
24177
+ var _a76;
24178
+ const message = ((_a76 = error.message) != null ? _a76 : "").toLowerCase();
23906
24179
  return error.code === "42501" || message.includes("permission denied");
23907
24180
  };
23908
24181
  const updateAvatarByUserId = async (userId) => {
23909
- var _a74, _b7, _c2, _d, _e;
24182
+ var _a76, _b8, _c2, _d, _e;
23910
24183
  for (const tableName of updateTargets) {
23911
24184
  const updateWithSelect = await supabase.from(tableName).update({ [CHAT_USERS_UPDATE_AVATAR_COLUMN]: normalizedAvatarId }).eq(CHAT_USERS_UPDATE_ID_COLUMN, userId).select(CHAT_USERS_UPDATE_ID_COLUMN).limit(1);
23912
24185
  if (!updateWithSelect.error) {
23913
24186
  const rows = updateWithSelect.data;
23914
- const row = (_a74 = rows == null ? void 0 : rows[0]) != null ? _a74 : null;
24187
+ const row = (_a76 = rows == null ? void 0 : rows[0]) != null ? _a76 : null;
23915
24188
  if (row) {
23916
24189
  return row;
23917
24190
  }
@@ -23931,7 +24204,7 @@ var MainNavbar = ({
23931
24204
  throw new Error(`Falha ao atualizar avatar em "${tableName}": ${withoutSelectError.message}`);
23932
24205
  }
23933
24206
  updateErrors.push(
23934
- `${tableName}: ${(_b7 = withoutSelectError.code) != null ? _b7 : "erro"} ${(_c2 = withoutSelectError.message) != null ? _c2 : "falha desconhecida"}`
24207
+ `${tableName}: ${(_b8 = withoutSelectError.code) != null ? _b8 : "erro"} ${(_c2 = withoutSelectError.message) != null ? _c2 : "falha desconhecida"}`
23935
24208
  );
23936
24209
  continue;
23937
24210
  }
@@ -23943,13 +24216,13 @@ var MainNavbar = ({
23943
24216
  return null;
23944
24217
  };
23945
24218
  const resolveUserIdByEmail = async (emailValue) => {
23946
- var _a74;
24219
+ var _a76;
23947
24220
  let lastRecoverableError = null;
23948
24221
  for (const tableName of lookupTargets) {
23949
24222
  const { data, error } = await supabase.from(tableName).select(CHAT_USERS_UPDATE_ID_COLUMN).ilike(CHAT_USERS_UPDATE_EMAIL_COLUMN, emailValue).limit(1);
23950
24223
  if (!error) {
23951
24224
  const rows = data;
23952
- const resolvedId = toStringOrUndefined((_a74 = rows == null ? void 0 : rows[0]) == null ? void 0 : _a74[CHAT_USERS_UPDATE_ID_COLUMN]);
24225
+ const resolvedId = toStringOrUndefined((_a76 = rows == null ? void 0 : rows[0]) == null ? void 0 : _a76[CHAT_USERS_UPDATE_ID_COLUMN]);
23953
24226
  if (resolvedId) {
23954
24227
  return resolvedId;
23955
24228
  }
@@ -24570,10 +24843,10 @@ function isThemeMode(value) {
24570
24843
  return value === "light" || value === "dark";
24571
24844
  }
24572
24845
  function readStoredTheme() {
24573
- var _a72;
24846
+ var _a74;
24574
24847
  if (typeof window === "undefined") return null;
24575
24848
  try {
24576
- const storedTheme = (_a72 = window.localStorage.getItem(THEME_STORAGE_KEY2)) != null ? _a72 : window.localStorage.getItem("theme");
24849
+ const storedTheme = (_a74 = window.localStorage.getItem(THEME_STORAGE_KEY2)) != null ? _a74 : window.localStorage.getItem("theme");
24577
24850
  return isThemeMode(storedTheme) ? storedTheme : null;
24578
24851
  } catch (e) {
24579
24852
  return null;
@@ -24610,11 +24883,11 @@ var ThemeToggle = ({
24610
24883
  defaultTheme = "light",
24611
24884
  onThemeChange
24612
24885
  }) => {
24613
- var _a72;
24886
+ var _a74;
24614
24887
  const [mounted, setMounted] = React35.useState(false);
24615
24888
  const [internalTheme, setInternalTheme] = React35.useState(defaultTheme);
24616
24889
  const isControlled = typeof theme !== "undefined";
24617
- const activeTheme = (_a72 = isControlled ? theme : internalTheme) != null ? _a72 : defaultTheme;
24890
+ const activeTheme = (_a74 = isControlled ? theme : internalTheme) != null ? _a74 : defaultTheme;
24618
24891
  React35.useEffect(() => {
24619
24892
  if (!isControlled) {
24620
24893
  setInternalTheme(resolveTheme(defaultTheme));
@@ -25252,8 +25525,8 @@ var ChartStyle = ({ id, config }) => {
25252
25525
  ([theme, prefix]) => `
25253
25526
  ${prefix} [data-chart=${id}] {
25254
25527
  ${colorConfig.map(([key, itemConfig]) => {
25255
- var _a72;
25256
- const color = ((_a72 = itemConfig.theme) == null ? void 0 : _a72[theme]) || itemConfig.color;
25528
+ var _a74;
25529
+ const color = ((_a74 = itemConfig.theme) == null ? void 0 : _a74[theme]) || itemConfig.color;
25257
25530
  return color ? ` --color-${key}: ${color};` : null;
25258
25531
  }).join("\n")}
25259
25532
  }
@@ -25282,14 +25555,14 @@ var ChartTooltipContent = React42.forwardRef(
25282
25555
  }, ref) => {
25283
25556
  const { config } = useChart();
25284
25557
  const tooltipLabel = React42.useMemo(() => {
25285
- var _a72;
25558
+ var _a74;
25286
25559
  if (hideLabel || !(payload == null ? void 0 : payload.length)) {
25287
25560
  return null;
25288
25561
  }
25289
25562
  const [item] = payload;
25290
25563
  const key = `${labelKey || item.dataKey || item.name || "value"}`;
25291
25564
  const itemConfig = getPayloadConfigFromPayload(config, item, key);
25292
- const value = !labelKey && typeof label === "string" ? ((_a72 = config[label]) == null ? void 0 : _a72.label) || label : itemConfig == null ? void 0 : itemConfig.label;
25565
+ const value = !labelKey && typeof label === "string" ? ((_a74 = config[label]) == null ? void 0 : _a74.label) || label : itemConfig == null ? void 0 : itemConfig.label;
25293
25566
  if (labelFormatter) {
25294
25567
  return /* @__PURE__ */ jsx64("div", { className: cn("font-medium", labelClassName), children: labelFormatter(value, payload) });
25295
25568
  }
@@ -26974,8 +27247,8 @@ ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
26974
27247
  // src/hooks/useActiveSection.ts
26975
27248
  import { useEffect as useEffect23, useState as useState18 } from "react";
26976
27249
  var useActiveSection = (sectionIds, offset = 180) => {
26977
- var _a72;
26978
- const [activeId, setActiveId] = useState18((_a72 = sectionIds[0]) != null ? _a72 : "");
27250
+ var _a74;
27251
+ const [activeId, setActiveId] = useState18((_a74 = sectionIds[0]) != null ? _a74 : "");
26979
27252
  useEffect23(() => {
26980
27253
  if (!sectionIds.length || typeof window === "undefined") return;
26981
27254
  const update = () => {
@@ -27023,26 +27296,26 @@ var LOCAL_STORAGE_KEYS = {
27023
27296
  lastActivityAt: "cc_last_activity_at",
27024
27297
  presenceSource: "cc_user_presence_source"
27025
27298
  };
27026
- var _a62;
27027
- var USER_PRESENCE_TABLE2 = ((_a62 = getRuntimeEnv("VITE_USER_PRESENCE_TABLE")) != null ? _a62 : "user_presence").trim();
27028
- var _a63;
27029
- var USER_PRESENCE_USER_ID_COLUMN2 = ((_a63 = getRuntimeEnv("VITE_USER_PRESENCE_USER_ID_COLUMN")) != null ? _a63 : "user_id").trim();
27030
27299
  var _a64;
27031
- var USER_PRESENCE_STATUS_COLUMN2 = ((_a64 = getRuntimeEnv("VITE_USER_PRESENCE_STATUS_COLUMN")) != null ? _a64 : "status").trim();
27032
- var _a65, _b5;
27033
- var SUPABASE_CHAT_SCHEMA = ((_b5 = (_a65 = getRuntimeEnv("VITE_CHAT_SCHEMA")) != null ? _a65 : getRuntimeEnv("VITE_SUPABASE_SCHEMA")) != null ? _b5 : "public").trim();
27300
+ var USER_PRESENCE_TABLE2 = ((_a64 = getRuntimeEnv("VITE_USER_PRESENCE_TABLE")) != null ? _a64 : "user_presence").trim();
27301
+ var _a65;
27302
+ var USER_PRESENCE_USER_ID_COLUMN2 = ((_a65 = getRuntimeEnv("VITE_USER_PRESENCE_USER_ID_COLUMN")) != null ? _a65 : "user_id").trim();
27034
27303
  var _a66;
27035
- var CHAT_USERS_TABLE2 = ((_a66 = getRuntimeEnv("VITE_CHAT_USERS_TABLE")) != null ? _a66 : "chat_users").trim();
27036
- var _a67;
27037
- var CHAT_USERS_ID_COLUMN2 = ((_a67 = getRuntimeEnv("VITE_CHAT_USERS_ID_COLUMN")) != null ? _a67 : "id").trim();
27304
+ var USER_PRESENCE_STATUS_COLUMN2 = ((_a66 = getRuntimeEnv("VITE_USER_PRESENCE_STATUS_COLUMN")) != null ? _a66 : "status").trim();
27305
+ var _a67, _b6;
27306
+ var SUPABASE_CHAT_SCHEMA = ((_b6 = (_a67 = getRuntimeEnv("VITE_CHAT_SCHEMA")) != null ? _a67 : getRuntimeEnv("VITE_SUPABASE_SCHEMA")) != null ? _b6 : "public").trim();
27038
27307
  var _a68;
27039
- var CHAT_USERS_EMAIL_COLUMN2 = ((_a68 = getRuntimeEnv("VITE_CHAT_USERS_EMAIL_COLUMN")) != null ? _a68 : "email").trim();
27308
+ var CHAT_USERS_TABLE2 = ((_a68 = getRuntimeEnv("VITE_CHAT_USERS_TABLE")) != null ? _a68 : "chat_users").trim();
27040
27309
  var _a69;
27041
- var CHAT_USERS_UPDATE_TABLE2 = ((_a69 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_TABLE")) != null ? _a69 : "profiles").trim();
27310
+ var CHAT_USERS_ID_COLUMN2 = ((_a69 = getRuntimeEnv("VITE_CHAT_USERS_ID_COLUMN")) != null ? _a69 : "id").trim();
27042
27311
  var _a70;
27043
- var CHAT_USERS_UPDATE_ID_COLUMN2 = ((_a70 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_ID_COLUMN")) != null ? _a70 : "id").trim();
27312
+ var CHAT_USERS_EMAIL_COLUMN2 = ((_a70 = getRuntimeEnv("VITE_CHAT_USERS_EMAIL_COLUMN")) != null ? _a70 : "email").trim();
27044
27313
  var _a71;
27045
- var CHAT_USERS_UPDATE_EMAIL_COLUMN2 = ((_a71 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_EMAIL_COLUMN")) != null ? _a71 : "email").trim();
27314
+ var CHAT_USERS_UPDATE_TABLE2 = ((_a71 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_TABLE")) != null ? _a71 : "profiles").trim();
27315
+ var _a72;
27316
+ var CHAT_USERS_UPDATE_ID_COLUMN2 = ((_a72 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_ID_COLUMN")) != null ? _a72 : "id").trim();
27317
+ var _a73;
27318
+ var CHAT_USERS_UPDATE_EMAIL_COLUMN2 = ((_a73 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_EMAIL_COLUMN")) != null ? _a73 : "email").trim();
27046
27319
  var PRESENCE_USER_LOOKUP_TABLES = Array.from(
27047
27320
  new Set(
27048
27321
  [CHAT_USERS_UPDATE_TABLE2, CHAT_USERS_TABLE2, "profiles", "chat_users"].map((entry) => entry.trim()).filter((entry) => entry.length > 0)
@@ -27095,8 +27368,8 @@ var readStoredPresence = () => {
27095
27368
  return isUserPresenceStatus(stored) ? stored : DEFAULT_PRESENCE_STATUS;
27096
27369
  };
27097
27370
  var readStoredPresenceSource = () => {
27098
- var _a72;
27099
- const stored = (_a72 = sessionStorage.getItem(STORAGE_KEYS.presenceSource)) != null ? _a72 : localStorage.getItem(LOCAL_STORAGE_KEYS.presenceSource);
27371
+ var _a74;
27372
+ const stored = (_a74 = sessionStorage.getItem(STORAGE_KEYS.presenceSource)) != null ? _a74 : localStorage.getItem(LOCAL_STORAGE_KEYS.presenceSource);
27100
27373
  return stored === "system" ? "system" : "manual";
27101
27374
  };
27102
27375
  var AuthContext = createContext6(void 0);
@@ -27114,21 +27387,21 @@ var readStoredToken = () => {
27114
27387
  return { accessToken, idToken };
27115
27388
  };
27116
27389
  var storeTokens = (tokens) => {
27117
- var _a72;
27390
+ var _a74;
27118
27391
  sessionStorage.setItem(STORAGE_KEYS.accessToken, tokens.accessToken);
27119
27392
  if (tokens.idToken) sessionStorage.setItem(STORAGE_KEYS.idToken, tokens.idToken);
27120
27393
  if (tokens.refreshToken) sessionStorage.setItem(STORAGE_KEYS.refreshToken, tokens.refreshToken);
27121
- const expiresAt2 = Date.now() + ((_a72 = tokens.expiresIn) != null ? _a72 : 3600) * 1e3;
27394
+ const expiresAt2 = Date.now() + ((_a74 = tokens.expiresIn) != null ? _a74 : 3600) * 1e3;
27122
27395
  sessionStorage.setItem(STORAGE_KEYS.expiresAt, String(expiresAt2));
27123
27396
  };
27124
27397
  var clearTokens = () => {
27125
27398
  Object.values(STORAGE_KEYS).forEach((key) => sessionStorage.removeItem(key));
27126
27399
  };
27127
27400
  var buildUserFromToken = (idToken) => {
27128
- var _a72, _b6, _c, _d, _e, _f, _g, _h;
27401
+ var _a74, _b7, _c, _d, _e, _f, _g, _h;
27129
27402
  const payload = decodeJwt(idToken);
27130
27403
  if (!payload) return null;
27131
- const resolvedId = (_d = (_c = (_b6 = (_a72 = toNonEmptyString(payload["https://cupcode.com/user_id"])) != null ? _a72 : toNonEmptyString(payload.user_id)) != null ? _b6 : toNonEmptyString(payload.userId)) != null ? _c : toNonEmptyString(payload.uid)) != null ? _d : toNonEmptyString(payload.id);
27404
+ const resolvedId = (_d = (_c = (_b7 = (_a74 = toNonEmptyString(payload["https://cupcode.com/user_id"])) != null ? _a74 : toNonEmptyString(payload.user_id)) != null ? _b7 : toNonEmptyString(payload.userId)) != null ? _c : toNonEmptyString(payload.uid)) != null ? _d : toNonEmptyString(payload.id);
27132
27405
  const roleClaim = (_e = payload.role) != null ? _e : payload.roles;
27133
27406
  const resolvedRole = typeof roleClaim === "string" ? roleClaim : Array.isArray(roleClaim) ? roleClaim.find((entry) => typeof entry === "string") : void 0;
27134
27407
  const jobTitleClaim = (_g = (_f = payload.job_title) != null ? _f : payload.jobTitle) != null ? _g : payload.title;
@@ -27166,16 +27439,16 @@ var AuthProvider = ({ children }) => {
27166
27439
  sessionStorage.setItem(STORAGE_KEYS.presence, nextStatus);
27167
27440
  }, []);
27168
27441
  const resolvePresenceUserId = useCallback9(async (targetUser) => {
27169
- var _a72, _b6, _c, _d;
27442
+ var _a74, _b7, _c, _d;
27170
27443
  const sub = toNonEmptyString(targetUser == null ? void 0 : targetUser.sub);
27171
27444
  const id = toNonEmptyString(targetUser == null ? void 0 : targetUser.id);
27172
27445
  const userId = toNonEmptyString(targetUser == null ? void 0 : targetUser.userId);
27173
- const email = (_a72 = toNonEmptyString(targetUser == null ? void 0 : targetUser.email)) == null ? void 0 : _a72.toLowerCase();
27446
+ const email = (_a74 = toNonEmptyString(targetUser == null ? void 0 : targetUser.email)) == null ? void 0 : _a74.toLowerCase();
27174
27447
  const identityKey = [sub != null ? sub : "", id != null ? id : "", userId != null ? userId : "", email != null ? email : ""].join("|");
27175
27448
  if (resolvedPresenceIdentityKeyRef.current === identityKey && resolvedPresenceUserIdRef.current) {
27176
27449
  return resolvedPresenceUserIdRef.current;
27177
27450
  }
27178
- const fallbackUserId = (_d = (_c = (_b6 = sub != null ? sub : id) != null ? _b6 : userId) != null ? _c : email) != null ? _d : null;
27451
+ const fallbackUserId = (_d = (_c = (_b7 = sub != null ? sub : id) != null ? _b7 : userId) != null ? _c : email) != null ? _d : null;
27179
27452
  if (!email) {
27180
27453
  resolvedPresenceIdentityKeyRef.current = identityKey;
27181
27454
  resolvedPresenceUserIdRef.current = fallbackUserId;
@@ -27283,7 +27556,7 @@ var AuthProvider = ({ children }) => {
27283
27556
  }, []);
27284
27557
  const startAuthorization = useCallback9(
27285
27558
  async (options) => {
27286
- var _a72, _b6;
27559
+ var _a74, _b7;
27287
27560
  const config = getAccountsConfig();
27288
27561
  const { authUrl } = await resolveOidcEndpoints(config);
27289
27562
  if (!authUrl) {
@@ -27293,8 +27566,8 @@ var AuthProvider = ({ children }) => {
27293
27566
  const challenge = await generateCodeChallenge(verifier);
27294
27567
  const state = generateState();
27295
27568
  const nonce = generateNonce();
27296
- const redirectTo = (_a72 = options == null ? void 0 : options.redirectTo) != null ? _a72 : window.location.pathname + window.location.search + window.location.hash;
27297
- const mode = (_b6 = options == null ? void 0 : options.mode) != null ? _b6 : "interactive";
27569
+ const redirectTo = (_a74 = options == null ? void 0 : options.redirectTo) != null ? _a74 : window.location.pathname + window.location.search + window.location.hash;
27570
+ const mode = (_b7 = options == null ? void 0 : options.mode) != null ? _b7 : "interactive";
27298
27571
  sessionStorage.setItem(STORAGE_KEYS.verifier, verifier);
27299
27572
  sessionStorage.setItem(STORAGE_KEYS.state, state);
27300
27573
  sessionStorage.setItem(STORAGE_KEYS.nonce, nonce);
@@ -27321,14 +27594,14 @@ var AuthProvider = ({ children }) => {
27321
27594
  useEffect24(() => {
27322
27595
  let cancelled = false;
27323
27596
  const initializeAuth = async () => {
27324
- var _a72;
27597
+ var _a74;
27325
27598
  const stored = readStoredToken();
27326
27599
  const storedPresence = readStoredPresence();
27327
27600
  setPresenceStatusState(storedPresence);
27328
27601
  if (stored == null ? void 0 : stored.accessToken) {
27329
27602
  if (cancelled) return;
27330
27603
  setAccessToken(stored.accessToken);
27331
- setUser(buildUserFromToken((_a72 = stored.idToken) != null ? _a72 : void 0));
27604
+ setUser(buildUserFromToken((_a74 = stored.idToken) != null ? _a74 : void 0));
27332
27605
  setStatus("authenticated");
27333
27606
  return;
27334
27607
  }
@@ -27402,9 +27675,9 @@ var AuthProvider = ({ children }) => {
27402
27675
  };
27403
27676
  }, [resolvePresenceUserId, status, syncPresenceFromDatabase, user]);
27404
27677
  useEffect24(() => {
27405
- var _a72;
27678
+ var _a74;
27406
27679
  if (status !== "authenticated") return;
27407
- const initialFromStorage = Number((_a72 = localStorage.getItem(LOCAL_STORAGE_KEYS.lastActivityAt)) != null ? _a72 : "0");
27680
+ const initialFromStorage = Number((_a74 = localStorage.getItem(LOCAL_STORAGE_KEYS.lastActivityAt)) != null ? _a74 : "0");
27408
27681
  if (Number.isFinite(initialFromStorage) && initialFromStorage > 0) {
27409
27682
  lastActivityAtRef.current = Math.max(lastActivityAtRef.current, initialFromStorage);
27410
27683
  } else {
@@ -27479,9 +27752,9 @@ var AuthProvider = ({ children }) => {
27479
27752
  });
27480
27753
  }, [startAuthorization]);
27481
27754
  const completeLogin = useCallback9(async () => {
27482
- var _a72;
27755
+ var _a74;
27483
27756
  const params = new URLSearchParams(window.location.search);
27484
- const redirectTo = (_a72 = sessionStorage.getItem(STORAGE_KEYS.redirect)) != null ? _a72 : "/";
27757
+ const redirectTo = (_a74 = sessionStorage.getItem(STORAGE_KEYS.redirect)) != null ? _a74 : "/";
27485
27758
  const authMode = sessionStorage.getItem(STORAGE_KEYS.authMode);
27486
27759
  const isSilentAuth = authMode === "silent";
27487
27760
  const error = params.get("error");
@@ -27545,10 +27818,10 @@ var AuthProvider = ({ children }) => {
27545
27818
  }
27546
27819
  }, [clearAuthFlowState]);
27547
27820
  const logout = useCallback9(async () => {
27548
- var _a72;
27821
+ var _a74;
27549
27822
  const config = getAccountsConfig();
27550
27823
  const { logoutUrl } = await resolveOidcEndpoints(config);
27551
- const idToken = (_a72 = sessionStorage.getItem(STORAGE_KEYS.idToken)) != null ? _a72 : void 0;
27824
+ const idToken = (_a74 = sessionStorage.getItem(STORAGE_KEYS.idToken)) != null ? _a74 : void 0;
27552
27825
  const currentUser = user;
27553
27826
  await persistPresenceStatus("offline", currentUser);
27554
27827
  clearTokens();