@cupcodev/ui 8.0.0 → 8.0.1

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
@@ -1199,10 +1199,10 @@ var Dock = ({ items, className }) => {
1199
1199
  const itemsRef = useRef3([]);
1200
1200
  const OVERSHOOT = 5;
1201
1201
  useEffect3(() => {
1202
- var _a68;
1202
+ var _a66;
1203
1203
  const activeItem = itemsRef.current[activeIndex];
1204
1204
  if (!activeItem) return;
1205
- const containerRect = (_a68 = activeItem.parentElement) == null ? void 0 : _a68.getBoundingClientRect();
1205
+ const containerRect = (_a66 = activeItem.parentElement) == null ? void 0 : _a66.getBoundingClientRect();
1206
1206
  const itemRect = activeItem.getBoundingClientRect();
1207
1207
  if (!containerRect) return;
1208
1208
  const relativeLeft = itemRect.left - containerRect.left;
@@ -1264,9 +1264,9 @@ var Dock = ({ items, className }) => {
1264
1264
  "button",
1265
1265
  {
1266
1266
  onClick: () => {
1267
- var _a68;
1267
+ var _a66;
1268
1268
  setActiveIndex(index);
1269
- (_a68 = item.onClick) == null ? void 0 : _a68.call(item);
1269
+ (_a66 = item.onClick) == null ? void 0 : _a66.call(item);
1270
1270
  },
1271
1271
  className: cn(
1272
1272
  "flex items-center justify-center w-12 h-12 rounded-xl",
@@ -1334,9 +1334,9 @@ var normalizeValue = (value) => {
1334
1334
  return String(value);
1335
1335
  };
1336
1336
  var setCupcodeRuntimeEnv = (values) => {
1337
- var _a68;
1337
+ var _a66;
1338
1338
  const globalRef = globalThis;
1339
- const nextGlobalEnv = { ...(_a68 = globalRef.__CUPCODE_ENV__) != null ? _a68 : {} };
1339
+ const nextGlobalEnv = { ...(_a66 = globalRef.__CUPCODE_ENV__) != null ? _a66 : {} };
1340
1340
  Object.entries(values).forEach(([key, value]) => {
1341
1341
  const normalized = normalizeValue(value);
1342
1342
  runtimeStore[key] = normalized;
@@ -1345,8 +1345,8 @@ var setCupcodeRuntimeEnv = (values) => {
1345
1345
  globalRef.__CUPCODE_ENV__ = nextGlobalEnv;
1346
1346
  };
1347
1347
  var readFromProcessEnv = (key) => {
1348
- var _a68;
1349
- const processEnv = (_a68 = globalThis.process) == null ? void 0 : _a68.env;
1348
+ var _a66;
1349
+ const processEnv = (_a66 = globalThis.process) == null ? void 0 : _a66.env;
1350
1350
  return normalizeValue(processEnv == null ? void 0 : processEnv[key]);
1351
1351
  };
1352
1352
  var readFromImportMetaEnv = (key) => {
@@ -1358,12 +1358,12 @@ var readFromImportMetaEnv = (key) => {
1358
1358
  }
1359
1359
  };
1360
1360
  var getRuntimeEnv = (key) => {
1361
- var _a68;
1361
+ var _a66;
1362
1362
  const normalizedKey = key.trim();
1363
1363
  if (!normalizedKey) return void 0;
1364
1364
  const fromRuntimeStore = runtimeStore[normalizedKey];
1365
1365
  if (fromRuntimeStore) return fromRuntimeStore;
1366
- const fromGlobalStore = normalizeValue((_a68 = globalThis.__CUPCODE_ENV__) == null ? void 0 : _a68[normalizedKey]);
1366
+ const fromGlobalStore = normalizeValue((_a66 = globalThis.__CUPCODE_ENV__) == null ? void 0 : _a66[normalizedKey]);
1367
1367
  if (fromGlobalStore) return fromGlobalStore;
1368
1368
  const fromGlobalKey = normalizeValue(globalThis[normalizedKey]);
1369
1369
  if (fromGlobalKey) return fromGlobalKey;
@@ -1372,17 +1372,17 @@ var getRuntimeEnv = (key) => {
1372
1372
  return readFromProcessEnv(normalizedKey);
1373
1373
  };
1374
1374
  var getRuntimeEnvOr = (key, fallback) => {
1375
- var _a68;
1376
- return (_a68 = getRuntimeEnv(key)) != null ? _a68 : fallback;
1375
+ var _a66;
1376
+ return (_a66 = getRuntimeEnv(key)) != null ? _a66 : fallback;
1377
1377
  };
1378
1378
  var isRuntimeDev = () => {
1379
- var _a68, _b4, _c;
1380
- const explicitDev = (_a68 = getRuntimeEnv("DEV")) != null ? _a68 : getRuntimeEnv("VITE_DEV");
1379
+ var _a66, _b3, _c;
1380
+ const explicitDev = (_a66 = getRuntimeEnv("DEV")) != null ? _a66 : getRuntimeEnv("VITE_DEV");
1381
1381
  if (explicitDev) {
1382
1382
  const normalized = explicitDev.toLowerCase();
1383
1383
  return normalized === "1" || normalized === "true";
1384
1384
  }
1385
- const mode = ((_c = (_b4 = getRuntimeEnv("MODE")) != null ? _b4 : getRuntimeEnv("NODE_ENV")) != null ? _c : "").toLowerCase();
1385
+ const mode = ((_c = (_b3 = getRuntimeEnv("MODE")) != null ? _b3 : getRuntimeEnv("NODE_ENV")) != null ? _c : "").toLowerCase();
1386
1386
  return mode === "development";
1387
1387
  };
1388
1388
  var resolveCupcodeAppVersion = (explicitVersion) => {
@@ -1403,15 +1403,15 @@ var isUuid = (value) => {
1403
1403
  return UUID_REGEX.test(value.trim());
1404
1404
  };
1405
1405
  function parseAssetId(input) {
1406
- var _a68, _b4, _c, _d;
1406
+ var _a66, _b3, _c, _d;
1407
1407
  const raw = input == null ? void 0 : input.trim();
1408
1408
  if (!raw) return void 0;
1409
1409
  if (UUID_REGEX.test(raw)) return raw;
1410
- const matchFromRaw = (_a68 = raw.match(UUID_IN_TEXT_REGEX)) == null ? void 0 : _a68[0];
1410
+ const matchFromRaw = (_a66 = raw.match(UUID_IN_TEXT_REGEX)) == null ? void 0 : _a66[0];
1411
1411
  if (isUuid(matchFromRaw)) return matchFromRaw;
1412
1412
  try {
1413
1413
  const url = new URL(raw);
1414
- const queryParamId = (_c = (_b4 = url.searchParams.get("id")) != null ? _b4 : url.searchParams.get("asset_id")) != null ? _c : url.searchParams.get("assetId");
1414
+ const queryParamId = (_c = (_b3 = url.searchParams.get("id")) != null ? _b3 : url.searchParams.get("asset_id")) != null ? _c : url.searchParams.get("assetId");
1415
1415
  if (isUuid(queryParamId)) return queryParamId;
1416
1416
  const matchFromPath = (_d = url.pathname.match(UUID_IN_TEXT_REGEX)) == null ? void 0 : _d[0];
1417
1417
  if (isUuid(matchFromPath)) return matchFromPath;
@@ -1557,7 +1557,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1557
1557
  return void 0;
1558
1558
  }, [sortedCategories]);
1559
1559
  useEffect5(() => {
1560
- var _a68;
1560
+ var _a66;
1561
1561
  const root = rootRef.current;
1562
1562
  if (!root) return;
1563
1563
  const $ = (sel) => root.querySelector(sel);
@@ -1569,7 +1569,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1569
1569
  const getDockItems = () => Array.from(root.querySelectorAll(INTERACTIVE_SELECTOR));
1570
1570
  const dockItems = getDockItems();
1571
1571
  if (!tabbar || !dock || !listMenuShow || !tabbarUl || dockItems.length === 0) return;
1572
- const persistentId = (_a68 = activeCategoryId != null ? activeCategoryId : lastInteractiveId) != null ? _a68 : null;
1572
+ const persistentId = (_a66 = activeCategoryId != null ? activeCategoryId : lastInteractiveId) != null ? _a66 : null;
1573
1573
  let openItem = null;
1574
1574
  let latestToggleToken = null;
1575
1575
  const persistentSelector = persistentId != null ? `${INTERACTIVE_SELECTOR}[data-cat-id="${persistentId}"]` : null;
@@ -1868,8 +1868,8 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1868
1868
  }, total);
1869
1869
  }
1870
1870
  const hideBootstrapTooltip = (el) => {
1871
- var _a69, _b4;
1872
- const tooltip = ((_b4 = (_a69 = window.bootstrap) == null ? void 0 : _a69.Tooltip) == null ? void 0 : _b4.getInstance) ? window.bootstrap.Tooltip.getInstance(el) : null;
1871
+ var _a67, _b3;
1872
+ const tooltip = ((_b3 = (_a67 = window.bootstrap) == null ? void 0 : _a67.Tooltip) == null ? void 0 : _b3.getInstance) ? window.bootstrap.Tooltip.getInstance(el) : null;
1873
1873
  tooltip == null ? void 0 : tooltip.hide();
1874
1874
  };
1875
1875
  const openMenuForItem = (item, menu) => {
@@ -1887,14 +1887,14 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1887
1887
  latestToggleToken = null;
1888
1888
  };
1889
1889
  const closeActiveMenu = (opts = {}) => {
1890
- var _a69;
1890
+ var _a67;
1891
1891
  if (!opts.onClosed) {
1892
1892
  latestToggleToken = null;
1893
1893
  }
1894
1894
  const itemToClose = openItem;
1895
1895
  if (!itemToClose) {
1896
1896
  if (!opts.preserveWrapper) ensurePersistentHighlight();
1897
- (_a69 = opts.onClosed) == null ? void 0 : _a69.call(opts);
1897
+ (_a67 = opts.onClosed) == null ? void 0 : _a67.call(opts);
1898
1898
  return;
1899
1899
  }
1900
1900
  const menu = getMenuFor(itemToClose);
@@ -1902,7 +1902,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1902
1902
  itemToClose.classList.remove("active");
1903
1903
  delete itemToClose.dataset.menuOpen;
1904
1904
  const finalize = () => {
1905
- var _a70;
1905
+ var _a68;
1906
1906
  if (!opts.preserveWrapper) {
1907
1907
  listMenuShow.classList.remove("show");
1908
1908
  tabbar.classList.remove("is-active-menu");
@@ -1910,7 +1910,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1910
1910
  setTabbarTheme(null);
1911
1911
  ensurePersistentHighlight();
1912
1912
  }
1913
- (_a70 = opts.onClosed) == null ? void 0 : _a70.call(opts);
1913
+ (_a68 = opts.onClosed) == null ? void 0 : _a68.call(opts);
1914
1914
  };
1915
1915
  closeMenu(menu, finalize);
1916
1916
  };
@@ -2013,7 +2013,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
2013
2013
  /* @__PURE__ */ jsx10("div", { className: "glass-overlay" }),
2014
2014
  /* @__PURE__ */ jsx10("div", { className: "glass-specular" }),
2015
2015
  /* @__PURE__ */ jsx10("ul", { className: "flex-center", children: sortedCategories.map((cat) => {
2016
- var _a68;
2016
+ var _a66;
2017
2017
  if (cat.type === "divider") {
2018
2018
  return /* @__PURE__ */ jsx10(
2019
2019
  "li",
@@ -2025,7 +2025,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
2025
2025
  cat.id
2026
2026
  );
2027
2027
  }
2028
- const hasCards = (((_a68 = cat.cards) == null ? void 0 : _a68.length) || 0) > 0;
2028
+ const hasCards = (((_a66 = cat.cards) == null ? void 0 : _a66.length) || 0) > 0;
2029
2029
  const link = cat.href;
2030
2030
  const isCurrent = cat.id === activeCategoryId;
2031
2031
  return /* @__PURE__ */ jsxs8(
@@ -2059,12 +2059,12 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
2059
2059
  );
2060
2060
  }) }),
2061
2061
  /* @__PURE__ */ jsx10("div", { className: "list-menu-mob-show", children: sortedCategories.filter((cat) => {
2062
- var _a68;
2063
- return cat.type !== "divider" && (((_a68 = cat.cards) == null ? void 0 : _a68.length) || 0) > 0;
2062
+ var _a66;
2063
+ return cat.type !== "divider" && (((_a66 = cat.cards) == null ? void 0 : _a66.length) || 0) > 0;
2064
2064
  }).map((cat) => {
2065
- var _a68;
2066
- return /* @__PURE__ */ jsx10("div", { className: "mob-list-menu hide", "data-tagget": cat.slug, children: /* @__PURE__ */ jsx10("div", { className: `submenu-stack ${cat.slug}`, children: ((_a68 = cat.cards) != null ? _a68 : []).map((card, i) => {
2067
- var _a69;
2065
+ var _a66;
2066
+ return /* @__PURE__ */ jsx10("div", { className: "mob-list-menu hide", "data-tagget": cat.slug, children: /* @__PURE__ */ jsx10("div", { className: `submenu-stack ${cat.slug}`, children: ((_a66 = cat.cards) != null ? _a66 : []).map((card, i) => {
2067
+ var _a67;
2068
2068
  return /* @__PURE__ */ jsxs8(
2069
2069
  "div",
2070
2070
  {
@@ -2080,8 +2080,8 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
2080
2080
  /* @__PURE__ */ jsx10("div", { className: "title", children: card.title }),
2081
2081
  card.description ? /* @__PURE__ */ jsx10("div", { className: "description", children: card.description }) : null
2082
2082
  ] }),
2083
- /* @__PURE__ */ jsx10("div", { className: "actions", children: ((_a69 = card.buttons) != null ? _a69 : []).slice(0, 2).map((btn, idx) => {
2084
- var _a70, _b4, _c, _d;
2083
+ /* @__PURE__ */ jsx10("div", { className: "actions", children: ((_a67 = card.buttons) != null ? _a67 : []).slice(0, 2).map((btn, idx) => {
2084
+ var _a68, _b3, _c, _d;
2085
2085
  const className = idx === 0 ? "saiba-mais" : "saiba-mais-1";
2086
2086
  if (btn.type === "popup") {
2087
2087
  return /* @__PURE__ */ jsx10(
@@ -2096,7 +2096,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
2096
2096
  window.dispatchEvent(new Event(`qw:open:${btn.popupId}`));
2097
2097
  }
2098
2098
  },
2099
- children: (_a70 = btn.label) != null ? _a70 : "Abrir"
2099
+ children: (_a68 = btn.label) != null ? _a68 : "Abrir"
2100
2100
  },
2101
2101
  `${cat.id}-card-${i}-btn-${idx}`
2102
2102
  );
@@ -2106,7 +2106,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
2106
2106
  {
2107
2107
  href: btn.href || "#",
2108
2108
  className,
2109
- target: ((_b4 = btn.href) == null ? void 0 : _b4.startsWith("http")) ? "_blank" : void 0,
2109
+ target: ((_b3 = btn.href) == null ? void 0 : _b3.startsWith("http")) ? "_blank" : void 0,
2110
2110
  rel: ((_c = btn.href) == null ? void 0 : _c.startsWith("http")) ? "noopener noreferrer" : void 0,
2111
2111
  children: (_d = btn.label) != null ? _d : "Saiba mais >"
2112
2112
  },
@@ -2174,10 +2174,10 @@ var NavbarCupcode = ({
2174
2174
  React5.useEffect(() => {
2175
2175
  if (!hasItems || !isOpen) return;
2176
2176
  const handlePointerDown = (event) => {
2177
- var _a68, _b4;
2177
+ var _a66, _b3;
2178
2178
  const target = event.target;
2179
2179
  if (!(target instanceof Node)) return;
2180
- if (!((_a68 = navRef.current) == null ? void 0 : _a68.contains(target)) && !((_b4 = mobileDrawerRef.current) == null ? void 0 : _b4.contains(target))) {
2180
+ if (!((_a66 = navRef.current) == null ? void 0 : _a66.contains(target)) && !((_b3 = mobileDrawerRef.current) == null ? void 0 : _b3.contains(target))) {
2181
2181
  setIsOpen(false);
2182
2182
  }
2183
2183
  };
@@ -2246,8 +2246,8 @@ var NavbarCupcode = ({
2246
2246
  isActive && "text-[hsl(var(--cc-navbar-link-active))] after:w-full after:bg-[hsl(var(--cc-navbar-link-active))]"
2247
2247
  );
2248
2248
  const handleClick = (event) => {
2249
- var _a68;
2250
- (_a68 = item.onClick) == null ? void 0 : _a68.call(item, event);
2249
+ var _a66;
2250
+ (_a66 = item.onClick) == null ? void 0 : _a66.call(item, event);
2251
2251
  };
2252
2252
  if (item.href.startsWith("#")) {
2253
2253
  return /* @__PURE__ */ jsxs9(
@@ -2348,8 +2348,8 @@ var NavbarCupcode = ({
2348
2348
  isActive && "text-[hsl(var(--cc-navbar-link-active))]"
2349
2349
  );
2350
2350
  const handleClick = (event) => {
2351
- var _a68;
2352
- (_a68 = item.onClick) == null ? void 0 : _a68.call(item, event);
2351
+ var _a66;
2352
+ (_a66 = item.onClick) == null ? void 0 : _a66.call(item, event);
2353
2353
  setIsOpen(false);
2354
2354
  };
2355
2355
  if (item.href.startsWith("#")) {
@@ -2397,8 +2397,6 @@ import {
2397
2397
  Mail,
2398
2398
  MessageCircle,
2399
2399
  MessageSquare,
2400
- Monitor,
2401
- Moon,
2402
2400
  MoreVertical,
2403
2401
  Pause,
2404
2402
  Pencil,
@@ -2410,7 +2408,6 @@ import {
2410
2408
  ShieldCheck,
2411
2409
  SlidersHorizontal,
2412
2410
  SmilePlus,
2413
- Sun,
2414
2411
  Trash2,
2415
2412
  Type,
2416
2413
  UserRound,
@@ -2636,11 +2633,11 @@ JellyButton.displayName = "JellyButton";
2636
2633
  // src/components/cupcode/JellyButtonOriginal.tsx
2637
2634
  import { jsx as jsx15, jsxs as jsxs12 } from "react/jsx-runtime";
2638
2635
  var resolveResponsiveSize = (value, currentBp) => {
2639
- var _a68, _b4, _c, _d, _e;
2636
+ var _a66, _b3, _c, _d, _e;
2640
2637
  if (typeof value === "string") {
2641
2638
  return value;
2642
2639
  }
2643
- const fallback = (_e = (_d = (_c = (_b4 = (_a68 = value.base) != null ? _a68 : value.sm) != null ? _b4 : value.md) != null ? _c : value.lg) != null ? _d : value.xl) != null ? _e : "md";
2640
+ const fallback = (_e = (_d = (_c = (_b3 = (_a66 = value.base) != null ? _a66 : value.sm) != null ? _b3 : value.md) != null ? _c : value.lg) != null ? _d : value.xl) != null ? _e : "md";
2644
2641
  if (!currentBp) {
2645
2642
  return fallback;
2646
2643
  }
@@ -3190,12 +3187,12 @@ var isAccountsOidcToken = (token) => {
3190
3187
  return issuer.startsWith(ACCOUNTS_BASE_URL_NORMALIZED) || issuer.includes("accounts.cupcode.com.br");
3191
3188
  };
3192
3189
  var readStoredIdToken = () => {
3193
- var _a68;
3190
+ var _a66;
3194
3191
  if (typeof window === "undefined" || typeof window.sessionStorage === "undefined") {
3195
3192
  return void 0;
3196
3193
  }
3197
3194
  for (const key of SESSION_ID_TOKEN_KEYS) {
3198
- const value = (_a68 = window.sessionStorage.getItem(key)) == null ? void 0 : _a68.trim();
3195
+ const value = (_a66 = window.sessionStorage.getItem(key)) == null ? void 0 : _a66.trim();
3199
3196
  if (value) return value;
3200
3197
  }
3201
3198
  return void 0;
@@ -3289,11 +3286,11 @@ var readUsageContext = (value) => {
3289
3286
  return void 0;
3290
3287
  };
3291
3288
  var getFileExtension = (filename) => {
3292
- var _a68;
3289
+ var _a66;
3293
3290
  if (!filename) return void 0;
3294
3291
  const parts = filename.split(".");
3295
3292
  if (parts.length < 2) return void 0;
3296
- const candidate = (_a68 = parts[parts.length - 1]) == null ? void 0 : _a68.trim().toLowerCase();
3293
+ const candidate = (_a66 = parts[parts.length - 1]) == null ? void 0 : _a66.trim().toLowerCase();
3297
3294
  return candidate || void 0;
3298
3295
  };
3299
3296
  var buildFacetsFromItems = (items) => {
@@ -3303,14 +3300,14 @@ var buildFacetsFromItems = (items) => {
3303
3300
  const extensions = /* @__PURE__ */ new Map();
3304
3301
  const tags = /* @__PURE__ */ new Map();
3305
3302
  items.forEach((item) => {
3306
- var _a68, _b4, _c, _d, _e, _f, _g;
3303
+ var _a66, _b3, _c, _d, _e, _f, _g;
3307
3304
  if (item.category) {
3308
- categories.set(item.category, ((_a68 = categories.get(item.category)) != null ? _a68 : 0) + 1);
3305
+ categories.set(item.category, ((_a66 = categories.get(item.category)) != null ? _a66 : 0) + 1);
3309
3306
  }
3310
3307
  if (item.folderId) {
3311
3308
  const current = folders.get(item.folderId);
3312
3309
  folders.set(item.folderId, {
3313
- label: (_b4 = item.folderName) != null ? _b4 : current == null ? void 0 : current.label,
3310
+ label: (_b3 = item.folderName) != null ? _b3 : current == null ? void 0 : current.label,
3314
3311
  count: ((_c = current == null ? void 0 : current.count) != null ? _c : 0) + 1
3315
3312
  });
3316
3313
  }
@@ -3321,16 +3318,16 @@ var buildFacetsFromItems = (items) => {
3321
3318
  extensions.set(item.extension, ((_e = extensions.get(item.extension)) != null ? _e : 0) + 1);
3322
3319
  }
3323
3320
  (_g = (_f = item.meta) == null ? void 0 : _f.tags) == null ? void 0 : _g.forEach((tag) => {
3324
- var _a69;
3321
+ var _a67;
3325
3322
  const normalizedTag = tag.trim();
3326
3323
  if (!normalizedTag) return;
3327
- tags.set(normalizedTag, ((_a69 = tags.get(normalizedTag)) != null ? _a69 : 0) + 1);
3324
+ tags.set(normalizedTag, ((_a67 = tags.get(normalizedTag)) != null ? _a67 : 0) + 1);
3328
3325
  });
3329
3326
  });
3330
3327
  const toFacetValues = (map) => Array.from(map.entries()).map(([value, count2]) => ({ value, count: count2 })).sort((a, b) => a.value.localeCompare(b.value));
3331
3328
  const toFolderFacetValues = (map) => Array.from(map.entries()).map(([value, info]) => ({ value, label: info.label, count: info.count })).sort((a, b) => {
3332
- var _a68, _b4;
3333
- return ((_a68 = a.label) != null ? _a68 : a.value).localeCompare((_b4 = b.label) != null ? _b4 : b.value);
3329
+ var _a66, _b3;
3330
+ return ((_a66 = a.label) != null ? _a66 : a.value).localeCompare((_b3 = b.label) != null ? _b3 : b.value);
3334
3331
  });
3335
3332
  return {
3336
3333
  categories: toFacetValues(categories),
@@ -3341,7 +3338,7 @@ var buildFacetsFromItems = (items) => {
3341
3338
  };
3342
3339
  };
3343
3340
  async function request(config, path, options = {}) {
3344
- var _a68, _b4;
3341
+ var _a66, _b3;
3345
3342
  const token = await config.getAccessToken();
3346
3343
  if (!token) {
3347
3344
  throw new TelescupClientError("Token de acesso n\xE3o encontrado.");
@@ -3371,7 +3368,7 @@ async function request(config, path, options = {}) {
3371
3368
  let response;
3372
3369
  try {
3373
3370
  response = await fetch(url, {
3374
- method: (_a68 = options.method) != null ? _a68 : "POST",
3371
+ method: (_a66 = options.method) != null ? _a66 : "POST",
3375
3372
  headers,
3376
3373
  body
3377
3374
  });
@@ -3386,7 +3383,7 @@ async function request(config, path, options = {}) {
3386
3383
  payload = await response.text();
3387
3384
  }
3388
3385
  const payloadObject = payload != null ? payload : {};
3389
- const message = typeof payload === "string" ? payload : (_b4 = payloadObject.message) != null ? _b4 : `Erro ao chamar ${path} (${response.status}).`;
3386
+ const message = typeof payload === "string" ? payload : (_b3 = payloadObject.message) != null ? _b3 : `Erro ao chamar ${path} (${response.status}).`;
3390
3387
  throw new TelescupClientError(message, {
3391
3388
  status: response.status,
3392
3389
  code: payloadObject.code,
@@ -3401,11 +3398,11 @@ var normalizeFunctionLanguage = (value) => {
3401
3398
  return normalized;
3402
3399
  };
3403
3400
  var toFunctionListPayload = (filters) => {
3404
- var _a68, _b4, _c, _d, _e, _f;
3405
- const page = toPositiveInt((_a68 = filters.cursor) != null ? _a68 : filters.page, 1);
3401
+ var _a66, _b3, _c, _d, _e, _f;
3402
+ const page = toPositiveInt((_a66 = filters.cursor) != null ? _a66 : filters.page, 1);
3406
3403
  const pageSize = Math.min(500, Math.max(1, toPositiveInt(filters.pageSize, 24)));
3407
3404
  return {
3408
- query: (_b4 = filters.query) != null ? _b4 : "",
3405
+ query: (_b3 = filters.query) != null ? _b3 : "",
3409
3406
  page,
3410
3407
  pageSize,
3411
3408
  sort: `${normalizeSortBy(filters.sort)}:${filters.order === "asc" ? "asc" : "desc"}`,
@@ -3423,12 +3420,12 @@ var toFunctionListPayload = (filters) => {
3423
3420
  };
3424
3421
  };
3425
3422
  var mapGenericRowToAsset = (row) => {
3426
- var _a68, _b4;
3427
- const id = (_a68 = readFirstString(row, ["asset_id", "id", "file_id", "uuid"])) != null ? _a68 : typeof row.id === "number" ? String(row.id) : void 0;
3423
+ var _a66, _b3;
3424
+ const id = (_a66 = readFirstString(row, ["asset_id", "id", "file_id", "uuid"])) != null ? _a66 : typeof row.id === "number" ? String(row.id) : void 0;
3428
3425
  if (!id) return null;
3429
3426
  const fileName = readFirstString(row, ["filename", "file_name", "name", "title", "original_name"]);
3430
3427
  const mimeType = readFirstString(row, ["mime", "mime_type", "content_type", "file_mime"]);
3431
- const extension = (_b4 = readFirstString(row, ["extension", "ext"])) != null ? _b4 : getFileExtension(fileName);
3428
+ const extension = (_b3 = readFirstString(row, ["extension", "ext"])) != null ? _b3 : getFileExtension(fileName);
3432
3429
  return {
3433
3430
  id,
3434
3431
  name: fileName,
@@ -3446,16 +3443,16 @@ var mapGenericRowToAsset = (row) => {
3446
3443
  };
3447
3444
  };
3448
3445
  var normalizeListResponseFromFunctions = (response, filters) => {
3449
- var _a68, _b4, _c, _d, _e, _f;
3446
+ var _a66, _b3, _c, _d, _e, _f;
3450
3447
  const payload = response != null ? response : {};
3451
3448
  const itemsRaw = Array.isArray(payload.items) ? payload.items : [];
3452
3449
  const selectedLanguage = normalizeLanguageKey(filters.language);
3453
3450
  const items = itemsRaw.map((row) => {
3454
- var _a69, _b5, _c2;
3451
+ var _a67, _b4, _c2;
3455
3452
  const mapped = mapGenericRowToAsset(row);
3456
3453
  if (!mapped) return null;
3457
3454
  const metaByLang = normalizeMetaByLanguage(row.meta);
3458
- const activeMeta = (_b5 = (_a69 = metaByLang[selectedLanguage]) != null ? _a69 : metaByLang.pt) != null ? _b5 : {};
3455
+ const activeMeta = (_b4 = (_a67 = metaByLang[selectedLanguage]) != null ? _a67 : metaByLang.pt) != null ? _b4 : {};
3459
3456
  const usageFromObject = readUsageContext(row.usage);
3460
3457
  const normalized = {
3461
3458
  ...mapped,
@@ -3467,7 +3464,7 @@ var normalizeListResponseFromFunctions = (response, filters) => {
3467
3464
  };
3468
3465
  return normalized;
3469
3466
  }).filter((item) => item !== null);
3470
- const total = (_c = (_b4 = (_a68 = readNumber(payload.total)) != null ? _a68 : readNumber(payload.totalCount)) != null ? _b4 : readNumber(payload.total_count)) != null ? _c : items.length;
3467
+ const total = (_c = (_b3 = (_a66 = readNumber(payload.total)) != null ? _a66 : readNumber(payload.totalCount)) != null ? _b3 : readNumber(payload.total_count)) != null ? _c : items.length;
3471
3468
  const page = toPositiveInt((_e = (_d = payload.page) != null ? _d : filters.cursor) != null ? _e : filters.page, 1);
3472
3469
  const pageSize = Math.min(100, Math.max(1, toPositiveInt((_f = payload.pageSize) != null ? _f : filters.pageSize, 24)));
3473
3470
  const nextCursor = total > page * pageSize ? String(page + 1) : void 0;
@@ -3487,13 +3484,13 @@ var mapConflictForQueue = (value) => {
3487
3484
  return "conflict";
3488
3485
  };
3489
3486
  var toInitPayloadForFunctions = (payload) => {
3490
- var _a68, _b4;
3487
+ var _a66, _b3;
3491
3488
  return {
3492
3489
  filename: payload.fileName,
3493
3490
  size: payload.size,
3494
3491
  mime: payload.mimeType,
3495
- folder_id: (_a68 = payload.folderId) != null ? _a68 : null,
3496
- overwritePolicy: (_b4 = payload.conflict) != null ? _b4 : "ask",
3492
+ folder_id: (_a66 = payload.folderId) != null ? _a66 : null,
3493
+ overwritePolicy: (_b3 = payload.conflict) != null ? _b3 : "ask",
3497
3494
  fileName: payload.fileName,
3498
3495
  mimeType: payload.mimeType,
3499
3496
  folderId: payload.folderId,
@@ -3501,10 +3498,10 @@ var toInitPayloadForFunctions = (payload) => {
3501
3498
  };
3502
3499
  };
3503
3500
  var normalizeInitResponseFromFunctions = (response) => {
3504
- var _a68, _b4, _c, _d, _e, _f, _g;
3501
+ var _a66, _b3, _c, _d, _e, _f, _g;
3505
3502
  const payload = response != null ? response : {};
3506
- const existingRaw = (_a68 = payload.existingAsset) != null ? _a68 : payload.existing_asset;
3507
- const existingAsset = existingRaw ? (_b4 = mapGenericRowToAsset(existingRaw)) != null ? _b4 : void 0 : void 0;
3503
+ const existingRaw = (_a66 = payload.existingAsset) != null ? _a66 : payload.existing_asset;
3504
+ const existingAsset = existingRaw ? (_b3 = mapGenericRowToAsset(existingRaw)) != null ? _b3 : void 0 : void 0;
3508
3505
  const assetRaw = payload.asset;
3509
3506
  const asset = assetRaw ? (_c = mapGenericRowToAsset(assetRaw)) != null ? _c : void 0 : void 0;
3510
3507
  const conflictSource = (_e = readString(payload.conflict)) != null ? _e : readString((_d = payload.conflict) == null ? void 0 : _d.type);
@@ -3525,12 +3522,12 @@ var normalizeInitResponseFromFunctions = (response) => {
3525
3522
  };
3526
3523
  };
3527
3524
  var toCompletePayloadForFunctions = (payload) => {
3528
- var _a68, _b4, _c;
3525
+ var _a66, _b3, _c;
3529
3526
  return {
3530
3527
  uploadId: payload.uploadId,
3531
- assetDraftId: (_a68 = payload.assetDraftId) != null ? _a68 : payload.assetId,
3528
+ assetDraftId: (_a66 = payload.assetDraftId) != null ? _a66 : payload.assetId,
3532
3529
  storageKey: payload.storageKey,
3533
- finalFilename: (_b4 = payload.finalFilename) != null ? _b4 : payload.fileName,
3530
+ finalFilename: (_b3 = payload.finalFilename) != null ? _b3 : payload.fileName,
3534
3531
  folder_id: (_c = payload.folderId) != null ? _c : null,
3535
3532
  upload_id: payload.uploadId,
3536
3533
  asset_id: payload.assetId,
@@ -3538,16 +3535,16 @@ var toCompletePayloadForFunctions = (payload) => {
3538
3535
  };
3539
3536
  };
3540
3537
  var normalizeCompleteResponseFromFunctions = (response) => {
3541
- var _a68, _b4, _c, _d, _e, _f;
3538
+ var _a66, _b3, _c, _d, _e, _f;
3542
3539
  const payload = response != null ? response : {};
3543
- const assetRaw = (_a68 = payload.asset) != null ? _a68 : payload;
3540
+ const assetRaw = (_a66 = payload.asset) != null ? _a66 : payload;
3544
3541
  const mapped = mapGenericRowToAsset(assetRaw);
3545
3542
  if (mapped) {
3546
3543
  const title = readFirstString(assetRaw, ["title", "title_text"]);
3547
3544
  const alt = readFirstString(assetRaw, ["alt", "alt_text"]);
3548
3545
  if (title || alt) {
3549
3546
  mapped.meta = {
3550
- ...(_b4 = mapped.meta) != null ? _b4 : {},
3547
+ ...(_b3 = mapped.meta) != null ? _b3 : {},
3551
3548
  ...title ? { title } : {},
3552
3549
  ...alt ? { alt } : {}
3553
3550
  };
@@ -3569,7 +3566,7 @@ var normalizeCompleteResponseFromFunctions = (response) => {
3569
3566
  return { asset: { id: assetId } };
3570
3567
  };
3571
3568
  var toMetaPayloadForFunctions = (payload) => {
3572
- var _a68;
3569
+ var _a66;
3573
3570
  if (payload.action && payload.action !== "update") {
3574
3571
  return payload;
3575
3572
  }
@@ -3579,7 +3576,7 @@ var toMetaPayloadForFunctions = (payload) => {
3579
3576
  en: {},
3580
3577
  es: {}
3581
3578
  };
3582
- const target = (_a68 = byLanguage[language]) != null ? _a68 : byLanguage.pt;
3579
+ const target = (_a66 = byLanguage[language]) != null ? _a66 : byLanguage.pt;
3583
3580
  if (payload.meta) {
3584
3581
  if (typeof payload.meta.alt === "string") target.alt = payload.meta.alt;
3585
3582
  if (typeof payload.meta.title === "string") target.title = payload.meta.title;
@@ -3642,14 +3639,14 @@ var createTelescupClient = (config) => ({
3642
3639
  body: toMetaPayloadForFunctions(payload)
3643
3640
  }),
3644
3641
  generateAlt: async (asset, language = "pt") => {
3645
- var _a68, _b4, _c;
3642
+ var _a66, _b3, _c;
3646
3643
  const response = await request(config, "generate-alt", {
3647
3644
  method: "POST",
3648
3645
  body: {
3649
3646
  items: [
3650
3647
  {
3651
3648
  id: asset.id,
3652
- file_path: (_a68 = asset.filePath) != null ? _a68 : asset.storageKey,
3649
+ file_path: (_a66 = asset.filePath) != null ? _a66 : asset.storageKey,
3653
3650
  mime_type: asset.mimeType
3654
3651
  }
3655
3652
  ],
@@ -3661,7 +3658,7 @@ var createTelescupClient = (config) => ({
3661
3658
  const titles = payload.titles && typeof payload.titles === "object" ? payload.titles : {};
3662
3659
  const results = Array.isArray(payload.results) ? payload.results : [];
3663
3660
  const row = results.find((item) => readFirstString(item, ["id"]) === asset.id);
3664
- const alt = (_b4 = readString(alts[asset.id])) != null ? _b4 : readFirstString(row != null ? row : {}, ["alt", "alt_text"]);
3661
+ const alt = (_b3 = readString(alts[asset.id])) != null ? _b3 : readFirstString(row != null ? row : {}, ["alt", "alt_text"]);
3665
3662
  const title = (_c = readString(titles[asset.id])) != null ? _c : readFirstString(row != null ? row : {}, ["title", "title_text"]);
3666
3663
  return {
3667
3664
  ...title ? { title } : {},
@@ -3679,12 +3676,12 @@ var createTelescupClient = (config) => ({
3679
3676
  });
3680
3677
  const payload = response != null ? response : {};
3681
3678
  const toMeta = (value) => {
3682
- var _a68;
3679
+ var _a66;
3683
3680
  if (!value || typeof value !== "object") return void 0;
3684
3681
  const row = value;
3685
3682
  const title = readString(row.title);
3686
3683
  const alt = readString(row.alt);
3687
- const description = (_a68 = readString(row.description)) != null ? _a68 : readString(row.desc);
3684
+ const description = (_a66 = readString(row.description)) != null ? _a66 : readString(row.desc);
3688
3685
  if (!title && !alt && !description) return void 0;
3689
3686
  return {
3690
3687
  ...title ? { title } : {},
@@ -3717,17 +3714,17 @@ var mergeFacetValues = (current, incoming) => {
3717
3714
  const map = /* @__PURE__ */ new Map();
3718
3715
  current == null ? void 0 : current.forEach((entry) => map.set(entry.value, entry));
3719
3716
  incoming == null ? void 0 : incoming.forEach((entry) => {
3720
- var _a68, _b4, _c;
3717
+ var _a66, _b3, _c;
3721
3718
  const previous = map.get(entry.value);
3722
3719
  map.set(entry.value, {
3723
3720
  value: entry.value,
3724
- label: (_b4 = (_a68 = entry.label) != null ? _a68 : previous == null ? void 0 : previous.label) != null ? _b4 : entry.value,
3721
+ label: (_b3 = (_a66 = entry.label) != null ? _a66 : previous == null ? void 0 : previous.label) != null ? _b3 : entry.value,
3725
3722
  count: (_c = entry.count) != null ? _c : previous == null ? void 0 : previous.count
3726
3723
  });
3727
3724
  });
3728
3725
  return Array.from(map.values()).sort((a, b) => {
3729
- var _a68, _b4;
3730
- return ((_a68 = a.label) != null ? _a68 : a.value).localeCompare((_b4 = b.label) != null ? _b4 : b.value);
3726
+ var _a66, _b3;
3727
+ return ((_a66 = a.label) != null ? _a66 : a.value).localeCompare((_b3 = b.label) != null ? _b3 : b.value);
3731
3728
  });
3732
3729
  };
3733
3730
  var DEFAULT_CACHE_MS = 3e5;
@@ -3821,9 +3818,9 @@ function useTelescupAssets(options) {
3821
3818
  ...sanitizeFilters(filters),
3822
3819
  pageSize
3823
3820
  }).then((data) => {
3824
- var _a68;
3821
+ var _a66;
3825
3822
  return {
3826
- items: (_a68 = data.items) != null ? _a68 : [],
3823
+ items: (_a66 = data.items) != null ? _a66 : [],
3827
3824
  nextCursor: data.nextCursor,
3828
3825
  total: data.total,
3829
3826
  facets: data.facets
@@ -3847,7 +3844,7 @@ function useTelescupAssets(options) {
3847
3844
  [cacheKey, cacheTimeMs, enabled, filters, pageSize, resolvedClient]
3848
3845
  );
3849
3846
  const loadMore = useCallback(async () => {
3850
- var _a68, _b4, _c, _d, _e, _f, _g;
3847
+ var _a66, _b3, _c, _d, _e, _f, _g;
3851
3848
  if (!state.nextCursor || isLoadingMore || isLoading) return;
3852
3849
  const requestSeq = requestSeqRef.current;
3853
3850
  setIsLoadingMore(true);
@@ -3861,9 +3858,9 @@ function useTelescupAssets(options) {
3861
3858
  });
3862
3859
  if (!aliveRef.current || requestSeq !== requestSeqRef.current) return;
3863
3860
  const merged = {
3864
- items: [...state.items, ...(_a68 = data.items) != null ? _a68 : []],
3861
+ items: [...state.items, ...(_a66 = data.items) != null ? _a66 : []],
3865
3862
  nextCursor: data.nextCursor,
3866
- total: (_b4 = data.total) != null ? _b4 : state.total,
3863
+ total: (_b3 = data.total) != null ? _b3 : state.total,
3867
3864
  facets: {
3868
3865
  categories: mergeFacetValues(previousFacets == null ? void 0 : previousFacets.categories, (_c = data.facets) == null ? void 0 : _c.categories),
3869
3866
  folders: mergeFacetValues(previousFacets == null ? void 0 : previousFacets.folders, (_d = data.facets) == null ? void 0 : _d.folders),
@@ -4092,12 +4089,12 @@ var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "we
4092
4089
  var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set(["mp4", "mov", "webm", "mkv", "avi", "m4v", "wmv"]);
4093
4090
  var AUDIO_EXTENSIONS = /* @__PURE__ */ new Set(["mp3", "wav", "aac", "ogg", "flac", "m4a"]);
4094
4091
  var resolveAssetFamily = (asset) => {
4095
- var _a68, _b4, _c;
4096
- const explicitType = (_a68 = asset.type) == null ? void 0 : _a68.toLowerCase();
4092
+ var _a66, _b3, _c;
4093
+ const explicitType = (_a66 = asset.type) == null ? void 0 : _a66.toLowerCase();
4097
4094
  if (explicitType === "image" || explicitType === "video" || explicitType === "audio" || explicitType === "file") {
4098
4095
  return explicitType;
4099
4096
  }
4100
- const mime = (_b4 = asset.mimeType) == null ? void 0 : _b4.toLowerCase();
4097
+ const mime = (_b3 = asset.mimeType) == null ? void 0 : _b3.toLowerCase();
4101
4098
  if (mime == null ? void 0 : mime.startsWith("image/")) return "image";
4102
4099
  if (mime == null ? void 0 : mime.startsWith("video/")) return "video";
4103
4100
  if (mime == null ? void 0 : mime.startsWith("audio/")) return "audio";
@@ -4109,9 +4106,9 @@ var resolveAssetFamily = (asset) => {
4109
4106
  return "file";
4110
4107
  };
4111
4108
  var matchesAllowedAsset = (asset, allowed) => {
4112
- var _a68, _b4, _c, _d;
4109
+ var _a66, _b3, _c, _d;
4113
4110
  if (!allowed || allowed.length === 0) return true;
4114
- const mime = (_b4 = (_a68 = asset.mimeType) == null ? void 0 : _a68.toLowerCase()) != null ? _b4 : "";
4111
+ const mime = (_b3 = (_a66 = asset.mimeType) == null ? void 0 : _a66.toLowerCase()) != null ? _b3 : "";
4115
4112
  const ext = asset.extension ? `.${asset.extension.toLowerCase()}` : "";
4116
4113
  const type = (_d = (_c = asset.type) == null ? void 0 : _c.toLowerCase()) != null ? _d : "";
4117
4114
  const family = resolveAssetFamily(asset);
@@ -4166,10 +4163,10 @@ var UUID_REGEX2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[
4166
4163
  var ROOT_FOLDERS_TO_HIDE = /* @__PURE__ */ new Set(["images", "videos"]);
4167
4164
  var normalizeFolderToken = (value) => value.trim().replace(/^\/+|\/+$/g, "").toLowerCase();
4168
4165
  var getLeafName = (value) => {
4169
- var _a68;
4166
+ var _a66;
4170
4167
  const normalized = normalizeFolderToken(value);
4171
4168
  const parts = normalized.split("/").filter(Boolean);
4172
- return (_a68 = parts[parts.length - 1]) != null ? _a68 : normalized;
4169
+ return (_a66 = parts[parts.length - 1]) != null ? _a66 : normalized;
4173
4170
  };
4174
4171
  var scoreFolderValue = (value, label) => {
4175
4172
  const normalizedValue = normalizeFolderToken(value);
@@ -4185,10 +4182,10 @@ var normalizeFacetOptions = (entries) => {
4185
4182
  if (!entries || !entries.length) return [];
4186
4183
  const byLabel = /* @__PURE__ */ new Map();
4187
4184
  entries.forEach((entry) => {
4188
- var _a68, _b4, _c, _d;
4189
- const value = (_a68 = entry.value) == null ? void 0 : _a68.trim();
4185
+ var _a66, _b3, _c, _d;
4186
+ const value = (_a66 = entry.value) == null ? void 0 : _a66.trim();
4190
4187
  if (!value) return;
4191
- const label = ((_b4 = entry.label) == null ? void 0 : _b4.trim()) || value;
4188
+ const label = ((_b3 = entry.label) == null ? void 0 : _b3.trim()) || value;
4192
4189
  const key = normalizeFolderToken(label);
4193
4190
  const incomingCount = typeof entry.count === "number" ? entry.count : 0;
4194
4191
  const existing = byLabel.get(key);
@@ -4216,16 +4213,16 @@ var normalizeFacetOptions = (entries) => {
4216
4213
  const options = Array.from(byLabel.values());
4217
4214
  const groups = /* @__PURE__ */ new Map();
4218
4215
  options.forEach((option) => {
4219
- var _a68;
4216
+ var _a66;
4220
4217
  const leaf = getLeafName(option.label || option.value);
4221
- const list = (_a68 = groups.get(leaf)) != null ? _a68 : [];
4218
+ const list = (_a66 = groups.get(leaf)) != null ? _a66 : [];
4222
4219
  list.push(option);
4223
4220
  groups.set(leaf, list);
4224
4221
  });
4225
4222
  const collapsed = options.filter((option) => {
4226
- var _a68;
4223
+ var _a66;
4227
4224
  const leaf = getLeafName(option.label || option.value);
4228
- const group = (_a68 = groups.get(leaf)) != null ? _a68 : [];
4225
+ const group = (_a66 = groups.get(leaf)) != null ? _a66 : [];
4229
4226
  const hasPathVariant = group.some((entry) => normalizeFolderToken(entry.label).includes("/"));
4230
4227
  if (!hasPathVariant) return true;
4231
4228
  return normalizeFolderToken(option.label).includes("/");
@@ -4236,13 +4233,13 @@ var normalizeFacetOptions = (entries) => {
4236
4233
  var collectFacetOptions = (items, pick, pickLabel) => {
4237
4234
  const options = /* @__PURE__ */ new Map();
4238
4235
  items.forEach((asset) => {
4239
- var _a68, _b4, _c, _d;
4240
- const value = (_a68 = pick(asset)) == null ? void 0 : _a68.trim();
4236
+ var _a66, _b3, _c, _d;
4237
+ const value = (_a66 = pick(asset)) == null ? void 0 : _a66.trim();
4241
4238
  if (!value) return;
4242
4239
  const current = options.get(value);
4243
4240
  options.set(value, {
4244
4241
  value,
4245
- label: ((_b4 = pickLabel == null ? void 0 : pickLabel(asset)) == null ? void 0 : _b4.trim()) || (current == null ? void 0 : current.label) || value,
4242
+ label: ((_b3 = pickLabel == null ? void 0 : pickLabel(asset)) == null ? void 0 : _b3.trim()) || (current == null ? void 0 : current.label) || value,
4246
4243
  count: ((_c = current == null ? void 0 : current.count) != null ? _c : 0) + 1,
4247
4244
  aliases: (_d = current == null ? void 0 : current.aliases) != null ? _d : [value]
4248
4245
  });
@@ -4316,22 +4313,22 @@ var TelescupAssetPicker = ({
4316
4313
  return folderOptions.find((option) => option.value === folderFilter);
4317
4314
  }, [folderFilter, folderOptions]);
4318
4315
  const filteredItems = useMemo4(() => {
4319
- var _a68;
4316
+ var _a66;
4320
4317
  const selectedFolderAliases = new Set(
4321
- ((_a68 = selectedFolderOption == null ? void 0 : selectedFolderOption.aliases) != null ? _a68 : folderFilter === "all" ? [] : [folderFilter]).map(
4318
+ ((_a66 = selectedFolderOption == null ? void 0 : selectedFolderOption.aliases) != null ? _a66 : folderFilter === "all" ? [] : [folderFilter]).map(
4322
4319
  (entry) => normalizeFolderToken(entry)
4323
4320
  )
4324
4321
  );
4325
4322
  return items.filter((asset) => {
4326
- var _a69, _b4;
4323
+ var _a67, _b3;
4327
4324
  if (!matchesAllowedAsset(asset, allowedTypes)) return false;
4328
4325
  if (typeFilter !== "all") {
4329
4326
  const family = resolveAssetFamily(asset);
4330
4327
  if (family !== typeFilter) return false;
4331
4328
  }
4332
4329
  if (folderFilter !== "all") {
4333
- const folderIdToken = normalizeFolderToken((_a69 = asset.folderId) != null ? _a69 : "");
4334
- const folderNameToken = normalizeFolderToken((_b4 = asset.folderName) != null ? _b4 : "");
4330
+ const folderIdToken = normalizeFolderToken((_a67 = asset.folderId) != null ? _a67 : "");
4331
+ const folderNameToken = normalizeFolderToken((_b3 = asset.folderName) != null ? _b3 : "");
4335
4332
  if (!selectedFolderAliases.has(folderIdToken) && !selectedFolderAliases.has(folderNameToken)) {
4336
4333
  return false;
4337
4334
  }
@@ -4342,9 +4339,9 @@ var TelescupAssetPicker = ({
4342
4339
  React16.useEffect(() => {
4343
4340
  if (!isRuntimeDev()) return;
4344
4341
  const familyCount = items.reduce((acc, asset) => {
4345
- var _a68, _b4;
4346
- const key = (_a68 = resolveAssetFamily(asset)) != null ? _a68 : "unknown";
4347
- acc[key] = ((_b4 = acc[key]) != null ? _b4 : 0) + 1;
4342
+ var _a66, _b3;
4343
+ const key = (_a66 = resolveAssetFamily(asset)) != null ? _a66 : "unknown";
4344
+ acc[key] = ((_b3 = acc[key]) != null ? _b3 : 0) + 1;
4348
4345
  return acc;
4349
4346
  }, {});
4350
4347
  console.log("[telescup][picker]", {
@@ -4593,14 +4590,14 @@ function useTelescupUploadQueue(options) {
4593
4590
  activeRef.current += 1;
4594
4591
  updateItem(next.id, { status: "uploading", progress: 0, error: void 0 });
4595
4592
  const run = async () => {
4596
- var _a68, _b4, _c;
4593
+ var _a66, _b3, _c;
4597
4594
  try {
4598
4595
  const init = await client.initUpload({
4599
4596
  fileName: next.file.name,
4600
4597
  size: next.file.size,
4601
4598
  mimeType: next.file.type,
4602
4599
  folderId,
4603
- conflict: (_a68 = next.conflictPolicy) != null ? _a68 : conflictPolicy
4600
+ conflict: (_a66 = next.conflictPolicy) != null ? _a66 : conflictPolicy
4604
4601
  });
4605
4602
  const conflictDetected = init.conflict === "ask" || init.conflict === "conflict" || init.conflict === "exists" || init.existingAsset && !init.uploadUrl;
4606
4603
  if (conflictDetected) {
@@ -4639,7 +4636,7 @@ function useTelescupUploadQueue(options) {
4639
4636
  storageKey: init.storageKey,
4640
4637
  finalFilename: init.finalFilename,
4641
4638
  folderId,
4642
- assetId: (_b4 = init.asset) == null ? void 0 : _b4.id,
4639
+ assetId: (_b3 = init.asset) == null ? void 0 : _b3.id,
4643
4640
  fileName: (_c = init.resolvedName) != null ? _c : next.file.name
4644
4641
  });
4645
4642
  updateItem(next.id, {
@@ -4738,7 +4735,7 @@ var TelescupUploader = ({
4738
4735
  className,
4739
4736
  onAssetUploaded
4740
4737
  }) => {
4741
- var _a68;
4738
+ var _a66;
4742
4739
  const inputRef = useRef8(null);
4743
4740
  const [dragActive, setDragActive] = useState9(false);
4744
4741
  const {
@@ -4805,8 +4802,8 @@ var TelescupUploader = ({
4805
4802
  size: "sm",
4806
4803
  variant: "secondary",
4807
4804
  onClick: () => {
4808
- var _a69;
4809
- return (_a69 = inputRef.current) == null ? void 0 : _a69.click();
4805
+ var _a67;
4806
+ return (_a67 = inputRef.current) == null ? void 0 : _a67.click();
4810
4807
  },
4811
4808
  children: labels.uploader.browse
4812
4809
  }
@@ -4820,8 +4817,8 @@ var TelescupUploader = ({
4820
4817
  accept,
4821
4818
  multiple,
4822
4819
  onChange: (event) => {
4823
- var _a69;
4824
- if ((_a69 = event.target.files) == null ? void 0 : _a69.length) {
4820
+ var _a67;
4821
+ if ((_a67 = event.target.files) == null ? void 0 : _a67.length) {
4825
4822
  handleFiles(event.target.files);
4826
4823
  event.currentTarget.value = "";
4827
4824
  }
@@ -4856,7 +4853,7 @@ var TelescupUploader = ({
4856
4853
  /* @__PURE__ */ jsx30(AlertDialogTitle, { children: labels.conflict.title }),
4857
4854
  /* @__PURE__ */ jsx30(AlertDialogDescription, { children: labels.conflict.description })
4858
4855
  ] }),
4859
- ((_a68 = conflictItem == null ? void 0 : conflictItem.existingAsset) == null ? void 0 : _a68.id) ? /* @__PURE__ */ jsxs19("div", { className: "mt-3 rounded-lg border border-border bg-muted/30 p-3", children: [
4856
+ ((_a66 = conflictItem == null ? void 0 : conflictItem.existingAsset) == null ? void 0 : _a66.id) ? /* @__PURE__ */ jsxs19("div", { className: "mt-3 rounded-lg border border-border bg-muted/30 p-3", children: [
4860
4857
  /* @__PURE__ */ jsx30("p", { className: "text-xs font-semibold text-muted-foreground", children: "Asset existente" }),
4861
4858
  /* @__PURE__ */ jsx30("div", { className: "mt-2 h-28 overflow-hidden rounded-md", children: /* @__PURE__ */ jsx30(
4862
4859
  TelescupImage,
@@ -5079,7 +5076,7 @@ var DEFAULT_LABELS = {
5079
5076
  }
5080
5077
  };
5081
5078
  var mergeLabels = (overrides) => {
5082
- var _a68;
5079
+ var _a66;
5083
5080
  if (!overrides) return DEFAULT_LABELS;
5084
5081
  return {
5085
5082
  ...DEFAULT_LABELS,
@@ -5093,7 +5090,7 @@ var mergeLabels = (overrides) => {
5093
5090
  meta: {
5094
5091
  ...DEFAULT_LABELS.meta,
5095
5092
  ...overrides.meta,
5096
- fields: { ...DEFAULT_LABELS.meta.fields, ...(_a68 = overrides.meta) == null ? void 0 : _a68.fields }
5093
+ fields: { ...DEFAULT_LABELS.meta.fields, ...(_a66 = overrides.meta) == null ? void 0 : _a66.fields }
5097
5094
  },
5098
5095
  toasts: { ...DEFAULT_LABELS.toasts, ...overrides.toasts }
5099
5096
  };
@@ -5112,10 +5109,10 @@ var normalizeApiLanguageKey = (value) => {
5112
5109
  return "pt-BR";
5113
5110
  };
5114
5111
  var getAssetMeta = (asset, lang) => {
5115
- var _a68, _b4;
5112
+ var _a66, _b3;
5116
5113
  if (!asset) return {};
5117
- if ((_a68 = asset.metaByLang) == null ? void 0 : _a68[lang]) return asset.metaByLang[lang];
5118
- return (_b4 = asset.meta) != null ? _b4 : {};
5114
+ if ((_a66 = asset.metaByLang) == null ? void 0 : _a66[lang]) return asset.metaByLang[lang];
5115
+ return (_b3 = asset.meta) != null ? _b3 : {};
5119
5116
  };
5120
5117
  var TelescupMetaEditor = ({
5121
5118
  client,
@@ -5125,8 +5122,8 @@ var TelescupMetaEditor = ({
5125
5122
  labels,
5126
5123
  onAssetUpdated
5127
5124
  }) => {
5128
- var _a68, _b4, _c, _d, _e, _f, _g, _h;
5129
- const [activeAssetId, setActiveAssetId] = useState10((_b4 = (_a68 = assets[0]) == null ? void 0 : _a68.id) != null ? _b4 : "");
5125
+ var _a66, _b3, _c, _d, _e, _f, _g, _h;
5126
+ const [activeAssetId, setActiveAssetId] = useState10((_b3 = (_a66 = assets[0]) == null ? void 0 : _a66.id) != null ? _b3 : "");
5130
5127
  const [activeLang, setActiveLang] = useState10(
5131
5128
  LANGUAGES.includes(defaultLanguage) ? defaultLanguage : "pt"
5132
5129
  );
@@ -5144,18 +5141,18 @@ var TelescupMetaEditor = ({
5144
5141
  }, [activeAssetId, assets]);
5145
5142
  const asset = assets.find((item) => item.id === activeAssetId);
5146
5143
  const currentDraft = useMemo7(() => {
5147
- var _a69;
5148
- const existing = (_a69 = drafts[activeAssetId]) == null ? void 0 : _a69[activeLang];
5144
+ var _a67;
5145
+ const existing = (_a67 = drafts[activeAssetId]) == null ? void 0 : _a67[activeLang];
5149
5146
  if (existing) return existing;
5150
5147
  return getAssetMeta(asset, activeLang);
5151
5148
  }, [activeAssetId, activeLang, asset, drafts]);
5152
5149
  const updateDraft = (field, value) => {
5153
5150
  setDrafts((prev) => {
5154
- var _a69;
5151
+ var _a67;
5155
5152
  return {
5156
5153
  ...prev,
5157
5154
  [activeAssetId]: {
5158
- ...(_a69 = prev[activeAssetId]) != null ? _a69 : {},
5155
+ ...(_a67 = prev[activeAssetId]) != null ? _a67 : {},
5159
5156
  [activeLang]: {
5160
5157
  ...currentDraft,
5161
5158
  [field]: value
@@ -5223,11 +5220,11 @@ var TelescupMetaEditor = ({
5223
5220
  onAssetUpdated == null ? void 0 : onAssetUpdated(updated);
5224
5221
  const updatedMeta = getAssetMeta(updated, activeLang);
5225
5222
  setDrafts((prev) => {
5226
- var _a69;
5223
+ var _a67;
5227
5224
  return {
5228
5225
  ...prev,
5229
5226
  [asset.id]: {
5230
- ...(_a69 = prev[asset.id]) != null ? _a69 : {},
5227
+ ...(_a67 = prev[asset.id]) != null ? _a67 : {},
5231
5228
  [activeLang]: updatedMeta
5232
5229
  }
5233
5230
  };
@@ -5391,9 +5388,9 @@ var TelescupUpload = ({
5391
5388
  }, []);
5392
5389
  const enrichUploadedAsset = useCallback4(
5393
5390
  async (asset) => {
5394
- var _a68, _b4, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
5391
+ var _a66, _b3, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
5395
5392
  if (!autoGenerateMetadataOnUpload) return asset;
5396
- const mimeType = (_b4 = (_a68 = asset.mimeType) == null ? void 0 : _a68.toLowerCase()) != null ? _b4 : "";
5393
+ const mimeType = (_b3 = (_a66 = asset.mimeType) == null ? void 0 : _a66.toLowerCase()) != null ? _b3 : "";
5397
5394
  const assetType = (_d = (_c = asset.type) == null ? void 0 : _c.toLowerCase()) != null ? _d : "";
5398
5395
  const isImage = assetType === "image" || mimeType.startsWith("image/");
5399
5396
  if (!isImage) return asset;
@@ -5655,14 +5652,14 @@ function parseStoredThemePreference(value) {
5655
5652
  return value === "light" || value === "dark" || value === "system" ? value : null;
5656
5653
  }
5657
5654
  function normalizeStoredThemePreference(value) {
5658
- var _a68;
5659
- return (_a68 = parseStoredThemePreference(value)) != null ? _a68 : "system";
5655
+ var _a66;
5656
+ return (_a66 = parseStoredThemePreference(value)) != null ? _a66 : "system";
5660
5657
  }
5661
5658
  function readStoredThemeMode() {
5662
- var _a68;
5659
+ var _a66;
5663
5660
  if (typeof window === "undefined") return null;
5664
5661
  try {
5665
- const storedTheme = (_a68 = window.localStorage.getItem(THEME_STORAGE_KEY)) != null ? _a68 : window.localStorage.getItem(LEGACY_THEME_STORAGE_KEY);
5662
+ const storedTheme = (_a66 = window.localStorage.getItem(THEME_STORAGE_KEY)) != null ? _a66 : window.localStorage.getItem(LEGACY_THEME_STORAGE_KEY);
5666
5663
  return isStoredThemeMode(storedTheme) ? storedTheme : null;
5667
5664
  } catch (e) {
5668
5665
  return null;
@@ -5718,7 +5715,7 @@ function persistThemePreferenceSelection(preference) {
5718
5715
  );
5719
5716
  }
5720
5717
  function resolveStoredThemePreference(experienceSettingsTheme) {
5721
- var _a68;
5718
+ var _a66;
5722
5719
  if (typeof window === "undefined") {
5723
5720
  return normalizeStoredThemePreference(experienceSettingsTheme);
5724
5721
  }
@@ -5734,7 +5731,7 @@ function resolveStoredThemePreference(experienceSettingsTheme) {
5734
5731
  if (parsedExperienceTheme === "system" && storedThemeMode) {
5735
5732
  return storedThemeMode;
5736
5733
  }
5737
- return (_a68 = parsedExperienceTheme != null ? parsedExperienceTheme : storedThemeMode) != null ? _a68 : "system";
5734
+ return (_a66 = parsedExperienceTheme != null ? parsedExperienceTheme : storedThemeMode) != null ? _a66 : "system";
5738
5735
  } catch (e) {
5739
5736
  return normalizeStoredThemePreference(experienceSettingsTheme);
5740
5737
  }
@@ -5868,11 +5865,6 @@ var LANGUAGE_OPTIONS = [
5868
5865
  { value: "en-US", shortLabel: "EN", label: "English" },
5869
5866
  { value: "es-ES", shortLabel: "ES", label: "Espa\xF1ol" }
5870
5867
  ];
5871
- var THEME_OPTIONS = [
5872
- { value: "light", label: "Light", icon: Sun },
5873
- { value: "dark", label: "Dark", icon: Moon },
5874
- { value: "system", label: "Sistema", icon: Monitor }
5875
- ];
5876
5868
  var DENSITY_OPTIONS = [
5877
5869
  { value: "compact", label: "Compacto" },
5878
5870
  { value: "comfortable", label: "Confort\xE1vel" }
@@ -6150,7 +6142,7 @@ var getNotificationTimestamp = (notification) => {
6150
6142
  return Number.isNaN(parsed) ? 0 : parsed;
6151
6143
  };
6152
6144
  var formatNotificationDateTime = (notification) => {
6153
- var _a68;
6145
+ var _a66;
6154
6146
  if (notification.createdAt) {
6155
6147
  const parsed = new Date(notification.createdAt);
6156
6148
  if (!Number.isNaN(parsed.getTime())) {
@@ -6162,7 +6154,7 @@ var formatNotificationDateTime = (notification) => {
6162
6154
  });
6163
6155
  }
6164
6156
  }
6165
- return ((_a68 = notification.timeLabel) == null ? void 0 : _a68.trim()) || "Agora";
6157
+ return ((_a66 = notification.timeLabel) == null ? void 0 : _a66.trim()) || "Agora";
6166
6158
  };
6167
6159
  var getNotificationDayKey = (notification) => {
6168
6160
  const timestamp = getNotificationTimestamp(notification);
@@ -6235,22 +6227,22 @@ var extractSharedFilesFromMessages = (messages) => {
6235
6227
  return files;
6236
6228
  };
6237
6229
  var resolveTelescupImageUrl = (value, options) => {
6238
- var _a68, _b4, _c;
6230
+ var _a66, _b3, _c;
6239
6231
  return resolveTelescupImageURL(value, {
6240
- width: (_a68 = options == null ? void 0 : options.width) != null ? _a68 : 96,
6241
- height: (_b4 = options == null ? void 0 : options.height) != null ? _b4 : 96,
6232
+ width: (_a66 = options == null ? void 0 : options.width) != null ? _a66 : 96,
6233
+ height: (_b3 = options == null ? void 0 : options.height) != null ? _b3 : 96,
6242
6234
  fit: "cover",
6243
6235
  format: "avif",
6244
6236
  quality: (_c = options == null ? void 0 : options.quality) != null ? _c : 72
6245
6237
  });
6246
6238
  };
6247
6239
  var resolveGroupAvatarFromTelescup = (asset, fallbackId) => {
6248
- var _a68, _b4;
6249
- return (_b4 = (_a68 = resolveTelescupImageUrl(asset == null ? void 0 : asset.url)) != null ? _a68 : resolveTelescupImageUrl(asset == null ? void 0 : asset.id)) != null ? _b4 : resolveTelescupImageUrl(fallbackId);
6240
+ var _a66, _b3;
6241
+ return (_b3 = (_a66 = resolveTelescupImageUrl(asset == null ? void 0 : asset.url)) != null ? _a66 : resolveTelescupImageUrl(asset == null ? void 0 : asset.id)) != null ? _b3 : resolveTelescupImageUrl(fallbackId);
6250
6242
  };
6251
6243
  var resolveProfileAvatarFromTelescup = (asset, fallbackId) => {
6252
- var _a68, _b4;
6253
- return (_b4 = (_a68 = resolveTelescupImageUrl(asset == null ? void 0 : asset.url, { width: 384, height: 384, quality: 80 })) != null ? _a68 : resolveTelescupImageUrl(asset == null ? void 0 : asset.id, { width: 384, height: 384, quality: 80 })) != null ? _b4 : resolveTelescupImageUrl(fallbackId, { width: 384, height: 384, quality: 80 });
6244
+ var _a66, _b3;
6245
+ return (_b3 = (_a66 = resolveTelescupImageUrl(asset == null ? void 0 : asset.url, { width: 384, height: 384, quality: 80 })) != null ? _a66 : resolveTelescupImageUrl(asset == null ? void 0 : asset.id, { width: 384, height: 384, quality: 80 })) != null ? _b3 : resolveTelescupImageUrl(fallbackId, { width: 384, height: 384, quality: 80 });
6254
6246
  };
6255
6247
  var playIncomingMessageSound = () => {
6256
6248
  if (typeof window === "undefined") return;
@@ -6389,7 +6381,7 @@ var UserMenuCupcode = ({
6389
6381
  panels,
6390
6382
  className
6391
6383
  }) => {
6392
- var _a68;
6384
+ var _a66;
6393
6385
  const [open, setOpen] = useState11(false);
6394
6386
  const [activeTab, setActiveTab] = useState11("profile");
6395
6387
  const [isLoggingOut, setIsLoggingOut] = useState11(false);
@@ -6494,12 +6486,12 @@ var UserMenuCupcode = ({
6494
6486
  );
6495
6487
  const normalizedNotificationFeed = useMemo8(
6496
6488
  () => resolvedNotificationFeed.map((notification) => {
6497
- var _a69;
6489
+ var _a67;
6498
6490
  const kind = normalizeNotificationKind(notification.kind);
6499
6491
  return {
6500
6492
  ...notification,
6501
6493
  kind,
6502
- topic: (_a69 = notification.topic) != null ? _a69 : NOTIFICATION_KIND_META[kind].topicFallback
6494
+ topic: (_a67 = notification.topic) != null ? _a67 : NOTIFICATION_KIND_META[kind].topicFallback
6503
6495
  };
6504
6496
  }),
6505
6497
  [resolvedNotificationFeed]
@@ -6534,10 +6526,10 @@ var UserMenuCupcode = ({
6534
6526
  const groupedNotifications = useMemo8(() => {
6535
6527
  const groups = /* @__PURE__ */ new Map();
6536
6528
  filteredNotifications.forEach((notification) => {
6537
- var _a69, _b4;
6529
+ var _a67, _b3;
6538
6530
  const kind = normalizeNotificationKind(notification.kind);
6539
- const key = notificationPreferences.grouping === "topic" ? (_a69 = notification.topic) != null ? _a69 : NOTIFICATION_KIND_META[kind].topicFallback : getNotificationDayKey(notification);
6540
- const current = (_b4 = groups.get(key)) != null ? _b4 : [];
6531
+ const key = notificationPreferences.grouping === "topic" ? (_a67 = notification.topic) != null ? _a67 : NOTIFICATION_KIND_META[kind].topicFallback : getNotificationDayKey(notification);
6532
+ const current = (_b3 = groups.get(key)) != null ? _b3 : [];
6541
6533
  current.push(notification);
6542
6534
  groups.set(key, current);
6543
6535
  });
@@ -6624,7 +6616,7 @@ var UserMenuCupcode = ({
6624
6616
  }).slice(0, 6);
6625
6617
  }, [recentActivity]);
6626
6618
  const isSendingChatMessage = isChatSending || isSendingInternalChatMessage;
6627
- const activeReactionPickerMessageId = (_a68 = activeReactionPicker == null ? void 0 : activeReactionPicker.messageId) != null ? _a68 : null;
6619
+ const activeReactionPickerMessageId = (_a66 = activeReactionPicker == null ? void 0 : activeReactionPicker.messageId) != null ? _a66 : null;
6628
6620
  const isChatSidebarOpen = isChatSidebarExpanded || isChatSidebarPinned;
6629
6621
  const hasTelescupAvatarSupport = Boolean(telescupBaseUrl && getTelescupAccessToken);
6630
6622
  const hasTelescupGroupAvatarSupport = hasTelescupAvatarSupport;
@@ -6675,8 +6667,8 @@ var UserMenuCupcode = ({
6675
6667
  meta.set(user.id, { lastMessage: null, lastTimestamp: 0, unreadCount: 0 });
6676
6668
  });
6677
6669
  resolvedAllChatMessages.forEach((message) => {
6678
- var _a69;
6679
- const current = (_a69 = meta.get(message.contactId)) != null ? _a69 : { lastMessage: null, lastTimestamp: 0, unreadCount: 0 };
6670
+ var _a67;
6671
+ const current = (_a67 = meta.get(message.contactId)) != null ? _a67 : { lastMessage: null, lastTimestamp: 0, unreadCount: 0 };
6680
6672
  const timestamp = getChatMessageTimestamp(message);
6681
6673
  if (timestamp >= current.lastTimestamp) {
6682
6674
  current.lastTimestamp = timestamp;
@@ -6696,11 +6688,11 @@ var UserMenuCupcode = ({
6696
6688
  return haystack.includes(query);
6697
6689
  });
6698
6690
  return filtered.sort((left, right) => {
6699
- var _a69, _b4, _c, _d;
6691
+ var _a67, _b3, _c, _d;
6700
6692
  const leftMeta = conversationMetaByUserId.get(left.id);
6701
6693
  const rightMeta = conversationMetaByUserId.get(right.id);
6702
- const leftUnread = (_a69 = leftMeta == null ? void 0 : leftMeta.unreadCount) != null ? _a69 : 0;
6703
- const rightUnread = (_b4 = rightMeta == null ? void 0 : rightMeta.unreadCount) != null ? _b4 : 0;
6694
+ const leftUnread = (_a67 = leftMeta == null ? void 0 : leftMeta.unreadCount) != null ? _a67 : 0;
6695
+ const rightUnread = (_b3 = rightMeta == null ? void 0 : rightMeta.unreadCount) != null ? _b3 : 0;
6704
6696
  if (leftUnread !== rightUnread) return rightUnread - leftUnread;
6705
6697
  const leftTimestamp = (_c = leftMeta == null ? void 0 : leftMeta.lastTimestamp) != null ? _c : 0;
6706
6698
  const rightTimestamp = (_d = rightMeta == null ? void 0 : rightMeta.lastTimestamp) != null ? _d : 0;
@@ -6749,11 +6741,11 @@ var UserMenuCupcode = ({
6749
6741
  let changed = false;
6750
6742
  const next = { ...current };
6751
6743
  normalizedNotificationFeed.forEach((notification) => {
6752
- var _a69;
6744
+ var _a67;
6753
6745
  if (normalizeNotificationKind(notification.kind) !== "chat") return;
6754
6746
  const contactId = notification.actionChatUserId;
6755
6747
  if (!contactId) return;
6756
- if (((_a69 = resolvedChatUnreadByUser[contactId]) != null ? _a69 : 0) > 0) return;
6748
+ if (((_a67 = resolvedChatUnreadByUser[contactId]) != null ? _a67 : 0) > 0) return;
6757
6749
  if (next[notification.id] === true) return;
6758
6750
  next[notification.id] = true;
6759
6751
  changed = true;
@@ -6767,11 +6759,11 @@ var UserMenuCupcode = ({
6767
6759
  const visibleChatUnreadCount = resolvedChatUnreadCount;
6768
6760
  const firstUnreadChatUserId = useMemo8(
6769
6761
  () => {
6770
- var _a69, _b4;
6771
- return (_b4 = (_a69 = filteredAndSortedChatUsers.find((user) => {
6772
- var _a70;
6773
- return ((_a70 = resolvedChatUnreadByUser[user.id]) != null ? _a70 : 0) > 0;
6774
- })) == null ? void 0 : _a69.id) != null ? _b4 : null;
6762
+ var _a67, _b3;
6763
+ return (_b3 = (_a67 = filteredAndSortedChatUsers.find((user) => {
6764
+ var _a68;
6765
+ return ((_a68 = resolvedChatUnreadByUser[user.id]) != null ? _a68 : 0) > 0;
6766
+ })) == null ? void 0 : _a67.id) != null ? _b3 : null;
6775
6767
  },
6776
6768
  [filteredAndSortedChatUsers, resolvedChatUnreadByUser]
6777
6769
  );
@@ -6830,11 +6822,11 @@ var UserMenuCupcode = ({
6830
6822
  );
6831
6823
  const openChatPanel = useCallback5(
6832
6824
  (contactId) => {
6833
- var _a69, _b4, _c, _d, _e;
6825
+ var _a67, _b3, _c, _d, _e;
6834
6826
  setIsLogoutConfirmOpen(false);
6835
6827
  setOpen(true);
6836
6828
  setActiveTab("chat");
6837
- const targetContactId = (_e = (_d = (_b4 = contactId != null ? contactId : firstUnreadChatUserId) != null ? _b4 : (_a69 = filteredAndSortedChatUsers[0]) == null ? void 0 : _a69.id) != null ? _d : (_c = chatUsersList[0]) == null ? void 0 : _c.id) != null ? _e : "";
6829
+ const targetContactId = (_e = (_d = (_b3 = contactId != null ? contactId : firstUnreadChatUserId) != null ? _b3 : (_a67 = filteredAndSortedChatUsers[0]) == null ? void 0 : _a67.id) != null ? _d : (_c = chatUsersList[0]) == null ? void 0 : _c.id) != null ? _e : "";
6838
6830
  if (!targetContactId) return;
6839
6831
  setActiveChatUserId(targetContactId);
6840
6832
  markConversationRead(targetContactId);
@@ -6868,9 +6860,9 @@ var UserMenuCupcode = ({
6868
6860
  const reactionsByMessageId = useMemo8(() => {
6869
6861
  const grouped = /* @__PURE__ */ new Map();
6870
6862
  resolvedAllChatReactions.forEach((reaction) => {
6871
- var _a69, _b4;
6872
- const byEmoji = (_a69 = grouped.get(reaction.messageId)) != null ? _a69 : /* @__PURE__ */ new Map();
6873
- const current = (_b4 = byEmoji.get(reaction.emoji)) != null ? _b4 : { emoji: reaction.emoji, count: 0, reactedByMe: false };
6863
+ var _a67, _b3;
6864
+ const byEmoji = (_a67 = grouped.get(reaction.messageId)) != null ? _a67 : /* @__PURE__ */ new Map();
6865
+ const current = (_b3 = byEmoji.get(reaction.emoji)) != null ? _b3 : { emoji: reaction.emoji, count: 0, reactedByMe: false };
6874
6866
  current.count += 1;
6875
6867
  if (resolvedCurrentChatUserId && reaction.userId === resolvedCurrentChatUserId) {
6876
6868
  current.reactedByMe = true;
@@ -7078,9 +7070,9 @@ var UserMenuCupcode = ({
7078
7070
  const wasFocusModeActive = wasFocusModeActiveRef.current;
7079
7071
  if (wasFocusModeActive && !isFocusModeActive && suppressedFocusNotifications.length) {
7080
7072
  const byType = suppressedFocusNotifications.reduce((acc, notification) => {
7081
- var _a69;
7073
+ var _a67;
7082
7074
  const kind = normalizeNotificationKind(notification.kind);
7083
- acc[kind] = ((_a69 = acc[kind]) != null ? _a69 : 0) + 1;
7075
+ acc[kind] = ((_a67 = acc[kind]) != null ? _a67 : 0) + 1;
7084
7076
  return acc;
7085
7077
  }, { system: 0, comment: 0, access: 0, billing: 0, chat: 0, security: 0 });
7086
7078
  const summaryParts = NOTIFICATION_KIND_ORDER.filter((kind) => byType[kind] > 0).map(
@@ -7110,9 +7102,9 @@ var UserMenuCupcode = ({
7110
7102
  return;
7111
7103
  }
7112
7104
  setActiveChatUserId((current) => {
7113
- var _a69, _b4;
7105
+ var _a67, _b3;
7114
7106
  if (current && chatUsersList.some((user) => user.id === current)) return current;
7115
- return (_b4 = (_a69 = filteredAndSortedChatUsers[0]) == null ? void 0 : _a69.id) != null ? _b4 : chatUsersList[0].id;
7107
+ return (_b3 = (_a67 = filteredAndSortedChatUsers[0]) == null ? void 0 : _a67.id) != null ? _b3 : chatUsersList[0].id;
7116
7108
  });
7117
7109
  }, [chatUsersList, filteredAndSortedChatUsers]);
7118
7110
  useEffect12(() => {
@@ -7154,7 +7146,7 @@ var UserMenuCupcode = ({
7154
7146
  };
7155
7147
  }, [activeReactionPickerMessageId]);
7156
7148
  useEffect12(() => {
7157
- var _a69;
7149
+ var _a67;
7158
7150
  if (!hasBootstrappedIncomingMessagesRef.current && isChatLoading) return;
7159
7151
  const knownIncomingIds = seenIncomingMessageIdsRef.current;
7160
7152
  const incomingMessages = resolvedAllChatMessages.filter((message) => message.sender === "them" && !message.readAt);
@@ -7176,14 +7168,14 @@ var UserMenuCupcode = ({
7176
7168
  return;
7177
7169
  }
7178
7170
  const generatedNotifications = relevantIncomingMessages.map((message) => {
7179
- var _a70, _b4, _c;
7171
+ var _a68, _b3, _c;
7180
7172
  const contact = chatUsersList.find((user) => user.id === message.contactId);
7181
- const createdAt = (_a70 = message.createdAt) != null ? _a70 : (/* @__PURE__ */ new Date()).toISOString();
7173
+ const createdAt = (_a68 = message.createdAt) != null ? _a68 : (/* @__PURE__ */ new Date()).toISOString();
7182
7174
  const previewText = chatSettings.showMessagePreview ? summarizeChatText(message.text, 100) : "Nova mensagem no chat.";
7183
7175
  return {
7184
7176
  id: `chat-notification-${message.id}`,
7185
7177
  kind: "chat",
7186
- title: `Mensagem de ${(_b4 = contact == null ? void 0 : contact.name) != null ? _b4 : "usu\xE1rio"}`,
7178
+ title: `Mensagem de ${(_b3 = contact == null ? void 0 : contact.name) != null ? _b3 : "usu\xE1rio"}`,
7187
7179
  description: previewText,
7188
7180
  createdAt,
7189
7181
  timeLabel: formatChatTime({ ...message, createdAt }),
@@ -7200,7 +7192,7 @@ var UserMenuCupcode = ({
7200
7192
  )[0];
7201
7193
  if (latestRelevantMessage) {
7202
7194
  const latestContact = chatUsersList.find((user) => user.id === latestRelevantMessage.contactId);
7203
- const senderName = (_a69 = latestContact == null ? void 0 : latestContact.name) != null ? _a69 : "usu\xE1rio";
7195
+ const senderName = (_a67 = latestContact == null ? void 0 : latestContact.name) != null ? _a67 : "usu\xE1rio";
7204
7196
  const latestPreview = chatSettings.showMessagePreview ? summarizeChatText(latestRelevantMessage.text, 96) : "Nova mensagem";
7205
7197
  const messageCount = relevantIncomingMessages.length;
7206
7198
  const messageCountLabel = messageCount > 99 ? "99+" : String(messageCount);
@@ -7249,10 +7241,10 @@ var UserMenuCupcode = ({
7249
7241
  return;
7250
7242
  }
7251
7243
  generatedNotifications.forEach((chatNotification) => {
7252
- var _a70;
7244
+ var _a68;
7253
7245
  const notification = new Notification(chatNotification.title, {
7254
7246
  body: chatSettings.showMessagePreview ? chatNotification.description : "Voc\xEA recebeu uma nova mensagem.",
7255
- tag: `cc-chat-${(_a70 = chatNotification.actionChatUserId) != null ? _a70 : chatNotification.id}`
7247
+ tag: `cc-chat-${(_a68 = chatNotification.actionChatUserId) != null ? _a68 : chatNotification.id}`
7256
7248
  });
7257
7249
  notification.onclick = () => {
7258
7250
  window.focus();
@@ -7279,31 +7271,31 @@ var UserMenuCupcode = ({
7279
7271
  ]);
7280
7272
  const activeChatUser = useMemo8(
7281
7273
  () => {
7282
- var _a69;
7283
- return (_a69 = chatUsersList.find((user) => user.id === activeChatUserId)) != null ? _a69 : null;
7274
+ var _a67;
7275
+ return (_a67 = chatUsersList.find((user) => user.id === activeChatUserId)) != null ? _a67 : null;
7284
7276
  },
7285
7277
  [activeChatUserId, chatUsersList]
7286
7278
  );
7287
7279
  const activeGroupMembers = useMemo8(() => {
7288
- var _a69;
7289
- if (!(activeChatUser == null ? void 0 : activeChatUser.isGroup) || !((_a69 = activeChatUser.memberIds) == null ? void 0 : _a69.length)) return [];
7280
+ var _a67;
7281
+ if (!(activeChatUser == null ? void 0 : activeChatUser.isGroup) || !((_a67 = activeChatUser.memberIds) == null ? void 0 : _a67.length)) return [];
7290
7282
  const members = activeChatUser.memberIds.map((memberId) => baseChatUsersList.find((user) => user.id === memberId)).filter((member) => Boolean(member));
7291
7283
  return members;
7292
7284
  }, [activeChatUser, baseChatUsersList]);
7293
7285
  const activeChatStatusLabel = useMemo8(() => {
7294
- var _a69;
7286
+ var _a67;
7295
7287
  if (!activeChatUser) return "";
7296
7288
  if (activeChatUser.isGroup) return "Grupo";
7297
- return (_a69 = activeChatUser.statusLabel) != null ? _a69 : PRESENCE_META[activeChatUser.status].label;
7289
+ return (_a67 = activeChatUser.statusLabel) != null ? _a67 : PRESENCE_META[activeChatUser.status].label;
7298
7290
  }, [activeChatUser]);
7299
7291
  const activeChatLastSeenDetail = useMemo8(() => {
7300
7292
  if (!activeChatUser || activeChatUser.isGroup) return null;
7301
7293
  return extractLastSeenDetail(activeChatStatusLabel);
7302
7294
  }, [activeChatStatusLabel, activeChatUser]);
7303
7295
  const activeChatRoleBadgeLabel = useMemo8(() => {
7304
- var _a69;
7296
+ var _a67;
7305
7297
  if (!activeChatUser || activeChatUser.isGroup) return null;
7306
- const normalizedRoleLabel = (_a69 = activeChatUser.roleLabel) == null ? void 0 : _a69.trim();
7298
+ const normalizedRoleLabel = (_a67 = activeChatUser.roleLabel) == null ? void 0 : _a67.trim();
7307
7299
  return normalizedRoleLabel || null;
7308
7300
  }, [activeChatUser]);
7309
7301
  const activeChatMessages = useMemo8(() => {
@@ -7341,8 +7333,8 @@ var UserMenuCupcode = ({
7341
7333
  return items;
7342
7334
  }, [activeChatMessages]);
7343
7335
  useEffect12(() => {
7344
- var _a69;
7345
- const conversationId = (_a69 = activeChatUser == null ? void 0 : activeChatUser.id) != null ? _a69 : null;
7336
+ var _a67;
7337
+ const conversationId = (_a67 = activeChatUser == null ? void 0 : activeChatUser.id) != null ? _a67 : null;
7346
7338
  if (!conversationId) {
7347
7339
  activeConversationIdRef.current = null;
7348
7340
  activeConversationMessageIdsRef.current = /* @__PURE__ */ new Set();
@@ -7395,9 +7387,9 @@ var UserMenuCupcode = ({
7395
7387
  });
7396
7388
  }, [activeChatUser, resolvedChatLogs]);
7397
7389
  const replyToMessage = useMemo8(() => {
7398
- var _a69;
7390
+ var _a67;
7399
7391
  if (!replyToMessageId) return null;
7400
- return (_a69 = activeChatMessagesMap.get(replyToMessageId)) != null ? _a69 : null;
7392
+ return (_a67 = activeChatMessagesMap.get(replyToMessageId)) != null ? _a67 : null;
7401
7393
  }, [activeChatMessagesMap, replyToMessageId]);
7402
7394
  useEffect12(() => {
7403
7395
  if (!replyToMessageId) return;
@@ -7424,9 +7416,9 @@ var UserMenuCupcode = ({
7424
7416
  }
7425
7417
  }, [activeChatUser]);
7426
7418
  useEffect12(() => {
7427
- var _a69;
7419
+ var _a67;
7428
7420
  if (!open || activeTab !== "chat" || !activeChatUser || activeChatUser.isGroup) return;
7429
- const unreadCount = (_a69 = resolvedChatUnreadByUser[activeChatUser.id]) != null ? _a69 : 0;
7421
+ const unreadCount = (_a67 = resolvedChatUnreadByUser[activeChatUser.id]) != null ? _a67 : 0;
7430
7422
  if (unreadCount <= 0) return;
7431
7423
  const contactId = activeChatUser.id;
7432
7424
  if (pendingReadRequestsRef.current.has(contactId)) return;
@@ -7502,13 +7494,13 @@ var UserMenuCupcode = ({
7502
7494
  openAccountsPath("/security#sessions");
7503
7495
  };
7504
7496
  const runOpenIntegrations = (provider) => {
7505
- var _a69;
7497
+ var _a67;
7506
7498
  if (!provider) {
7507
7499
  openAccountsPath("/integrations");
7508
7500
  return;
7509
7501
  }
7510
7502
  const option = INTEGRATION_OPTIONS.find((integration) => integration.id === provider);
7511
- openAccountsPath((_a69 = option == null ? void 0 : option.accountPath) != null ? _a69 : "/integrations");
7503
+ openAccountsPath((_a67 = option == null ? void 0 : option.accountPath) != null ? _a67 : "/integrations");
7512
7504
  };
7513
7505
  const changeStatus = (nextStatus) => {
7514
7506
  if (nextStatus === "offline") return;
@@ -7875,10 +7867,10 @@ var UserMenuCupcode = ({
7875
7867
  };
7876
7868
  const handleProfileAvatarChange = useCallback5(
7877
7869
  async (ids, assets) => {
7878
- var _a69, _b4, _c;
7870
+ var _a67, _b3, _c;
7879
7871
  const selectedAsset = assets == null ? void 0 : assets[0];
7880
- const selectedIdRaw = (_a69 = ids[0]) == null ? void 0 : _a69.trim();
7881
- const selectedId = (_c = (_b4 = parseAssetId(selectedIdRaw)) != null ? _b4 : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.id)) != null ? _c : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.url);
7872
+ const selectedIdRaw = (_a67 = ids[0]) == null ? void 0 : _a67.trim();
7873
+ const selectedId = (_c = (_b3 = parseAssetId(selectedIdRaw)) != null ? _b3 : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.id)) != null ? _c : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.url);
7882
7874
  if (!selectedId) {
7883
7875
  toast({
7884
7876
  title: "Imagem inv\xE1lida",
@@ -7920,7 +7912,7 @@ var UserMenuCupcode = ({
7920
7912
  [isProfileAvatarSaving, onProfileAvatarChange, resolvedProfileAvatarUrl]
7921
7913
  );
7922
7914
  const sendChatMessage = async () => {
7923
- var _a69, _b4;
7915
+ var _a67, _b3;
7924
7916
  if (!activeChatUser) return;
7925
7917
  const text = chatDraft.trim();
7926
7918
  if (!text || isSendingChatMessage) return;
@@ -7932,7 +7924,7 @@ var UserMenuCupcode = ({
7932
7924
  await onChatSendMessage({
7933
7925
  recipientId: activeChatUser.id,
7934
7926
  text,
7935
- replyToMessageId: (_a69 = replyToMessage == null ? void 0 : replyToMessage.id) != null ? _a69 : null
7927
+ replyToMessageId: (_a67 = replyToMessage == null ? void 0 : replyToMessage.id) != null ? _a67 : null
7936
7928
  });
7937
7929
  setChatDraft("");
7938
7930
  setShowEmojiPicker(false);
@@ -7959,7 +7951,7 @@ var UserMenuCupcode = ({
7959
7951
  timeLabel,
7960
7952
  createdAt,
7961
7953
  readAt: null,
7962
- replyToMessageId: (_b4 = replyToMessage == null ? void 0 : replyToMessage.id) != null ? _b4 : null
7954
+ replyToMessageId: (_b3 = replyToMessage == null ? void 0 : replyToMessage.id) != null ? _b3 : null
7963
7955
  };
7964
7956
  if (isLocalGroupConversation) {
7965
7957
  setInternalGroupMessages((current) => [...current, message]);
@@ -7974,7 +7966,7 @@ var UserMenuCupcode = ({
7974
7966
  });
7975
7967
  };
7976
7968
  const renderDefaultPanel = () => {
7977
- var _a69, _b4, _c, _d;
7969
+ var _a67, _b3, _c, _d;
7978
7970
  if (activeTab === "profile") {
7979
7971
  return /* @__PURE__ */ jsxs22("div", { className: "space-y-4", children: [
7980
7972
  /* @__PURE__ */ jsxs22("div", { className: "pt-1 text-center", children: [
@@ -8247,7 +8239,7 @@ var UserMenuCupcode = ({
8247
8239
  visibleGroupedNotifications.length ? visibleGroupedNotifications.map((group) => /* @__PURE__ */ jsxs22("section", { className: "space-y-1.5", children: [
8248
8240
  /* @__PURE__ */ jsx35("p", { className: "px-0.5 text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground", children: group.label }),
8249
8241
  /* @__PURE__ */ jsx35("div", { className: "space-y-1.5", children: group.items.map((notification) => {
8250
- var _a70;
8242
+ var _a68;
8251
8243
  const kind = normalizeNotificationKind(notification.kind);
8252
8244
  const meta = NOTIFICATION_KIND_META[kind];
8253
8245
  const Icon3 = meta.icon;
@@ -8276,7 +8268,7 @@ var UserMenuCupcode = ({
8276
8268
  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",
8277
8269
  children: [
8278
8270
  /* @__PURE__ */ jsx35(ExternalLink, { className: "h-3 w-3" }),
8279
- (_a70 = notification.actionLabel) != null ? _a70 : "Abrir"
8271
+ (_a68 = notification.actionLabel) != null ? _a68 : "Abrir"
8280
8272
  ]
8281
8273
  }
8282
8274
  ),
@@ -8504,7 +8496,7 @@ var UserMenuCupcode = ({
8504
8496
  }
8505
8497
  if (activeTab === "chat") {
8506
8498
  const canSendChatMessage = Boolean(activeChatUser) && chatDraft.trim() !== "" && !isSendingChatMessage && !isChatLoading;
8507
- const activeConversationUnreadCount = activeChatUser ? (_a69 = resolvedChatUnreadByUser[activeChatUser.id]) != null ? _a69 : 0 : 0;
8499
+ const activeConversationUnreadCount = activeChatUser ? (_a67 = resolvedChatUnreadByUser[activeChatUser.id]) != null ? _a67 : 0 : 0;
8508
8500
  return /* @__PURE__ */ jsx35("div", { className: "h-full", children: /* @__PURE__ */ jsxs22(
8509
8501
  "div",
8510
8502
  {
@@ -8583,12 +8575,12 @@ var UserMenuCupcode = ({
8583
8575
  }
8584
8576
  ),
8585
8577
  /* @__PURE__ */ jsx35("div", { className: "space-y-1", children: users.map((user) => {
8586
- var _a70, _b5, _c2, _d2;
8578
+ var _a68, _b4, _c2, _d2;
8587
8579
  const userInitials = buildInitials(user.name, user.username);
8588
8580
  const isCurrent = user.id === activeChatUserId;
8589
- const unreadCount = (_a70 = resolvedChatUnreadByUser[user.id]) != null ? _a70 : 0;
8581
+ const unreadCount = (_a68 = resolvedChatUnreadByUser[user.id]) != null ? _a68 : 0;
8590
8582
  const hasUnread = unreadCount > 0;
8591
- const lastMessage = (_b5 = conversationMetaByUserId.get(user.id)) == null ? void 0 : _b5.lastMessage;
8583
+ const lastMessage = (_b4 = conversationMetaByUserId.get(user.id)) == null ? void 0 : _b4.lastMessage;
8592
8584
  return /* @__PURE__ */ jsxs22(
8593
8585
  "button",
8594
8586
  {
@@ -8793,13 +8785,13 @@ var UserMenuCupcode = ({
8793
8785
  className: "cc-scrollbar cc-scrollbar-purple relative flex-1 space-y-2 overflow-y-auto px-3 py-2.5",
8794
8786
  children: [
8795
8787
  isChatLoading ? /* @__PURE__ */ jsx35("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) => {
8796
- var _a70, _b5;
8788
+ var _a68, _b4;
8797
8789
  if (item.type === "day") {
8798
8790
  return /* @__PURE__ */ jsx35("div", { className: "flex justify-center py-1", children: /* @__PURE__ */ jsx35("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);
8799
8791
  }
8800
8792
  const { message } = item;
8801
- const replyMessage = message.replyToMessageId ? (_a70 = activeChatMessagesMap.get(message.replyToMessageId)) != null ? _a70 : null : null;
8802
- const reactions = (_b5 = reactionsByMessageId.get(message.id)) != null ? _b5 : [];
8793
+ const replyMessage = message.replyToMessageId ? (_a68 = activeChatMessagesMap.get(message.replyToMessageId)) != null ? _a68 : null : null;
8794
+ const reactions = (_b4 = reactionsByMessageId.get(message.id)) != null ? _b4 : [];
8803
8795
  const hasReadReceipt = Boolean(message.readAt);
8804
8796
  const isEditing = editingMessageId === message.id;
8805
8797
  const canEditOrDelete = message.sender === "me";
@@ -8972,7 +8964,7 @@ var UserMenuCupcode = ({
8972
8964
  "div",
8973
8965
  {
8974
8966
  ref: reactionPickerRef,
8975
- style: { top: `${(_b4 = activeReactionPicker == null ? void 0 : activeReactionPicker.top) != null ? _b4 : 0}px`, left: `${(_c = activeReactionPicker == null ? void 0 : activeReactionPicker.left) != null ? _c : 0}px` },
8967
+ style: { top: `${(_b3 = activeReactionPicker == null ? void 0 : activeReactionPicker.top) != null ? _b3 : 0}px`, left: `${(_c = activeReactionPicker == null ? void 0 : activeReactionPicker.left) != null ? _c : 0}px` },
8976
8968
  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)]",
8977
8969
  children: MESSAGE_REACTION_OPTIONS.map((emoji) => /* @__PURE__ */ jsx35(
8978
8970
  "button",
@@ -9128,8 +9120,8 @@ var UserMenuCupcode = ({
9128
9120
  ] })
9129
9121
  ] }),
9130
9122
  isChatSuperAdmin ? activeConversationLogs.length ? /* @__PURE__ */ jsx35("div", { className: "space-y-2", children: activeConversationLogs.map((entry) => {
9131
- var _a70;
9132
- const actorName = entry.actorId && entry.actorId === resolvedCurrentChatUserId ? "Voc\xEA" : (_a70 = entry.actorId) != null ? _a70 : "Usu\xE1rio";
9123
+ var _a68;
9124
+ const actorName = entry.actorId && entry.actorId === resolvedCurrentChatUserId ? "Voc\xEA" : (_a68 = entry.actorId) != null ? _a68 : "Usu\xE1rio";
9133
9125
  return /* @__PURE__ */ jsxs22(
9134
9126
  "article",
9135
9127
  {
@@ -9387,32 +9379,6 @@ var UserMenuCupcode = ({
9387
9379
  /* @__PURE__ */ jsx35("p", { className: "mt-1 text-[11px] leading-relaxed text-muted-foreground", children: "Prefer\xEAncias que afetam o uso no dia a dia." })
9388
9380
  ] }),
9389
9381
  /* @__PURE__ */ jsxs22("div", { className: "mt-3 space-y-2.5", children: [
9390
- /* @__PURE__ */ jsxs22("div", { className: settingsItemClassName, children: [
9391
- /* @__PURE__ */ jsxs22("p", { className: "flex items-center gap-1.5 text-xs font-semibold text-foreground", children: [
9392
- /* @__PURE__ */ jsx35(Sun, { className: "h-3.5 w-3.5 text-primary" }),
9393
- "Tema"
9394
- ] }),
9395
- /* @__PURE__ */ jsx35("div", { className: "mt-2 grid grid-cols-3 gap-1", children: THEME_OPTIONS.map((option) => {
9396
- const Icon3 = option.icon;
9397
- const isActive = experienceSettings.theme === option.value;
9398
- return /* @__PURE__ */ jsxs22(
9399
- "button",
9400
- {
9401
- type: "button",
9402
- onClick: () => updateExperienceSetting("theme", option.value),
9403
- className: cn(
9404
- "inline-flex h-8 items-center justify-center gap-1 rounded-md border px-2 text-[11px] font-semibold transition-all",
9405
- isActive ? "border-primary/45 bg-primary/12 text-primary" : "border-border/70 text-foreground hover:bg-muted/45"
9406
- ),
9407
- children: [
9408
- /* @__PURE__ */ jsx35(Icon3, { className: "h-3.5 w-3.5" }),
9409
- option.label
9410
- ]
9411
- },
9412
- option.value
9413
- );
9414
- }) })
9415
- ] }),
9416
9382
  /* @__PURE__ */ jsxs22("div", { className: settingsItemClassName, children: [
9417
9383
  /* @__PURE__ */ jsxs22("p", { className: "flex items-center gap-1.5 text-xs font-semibold text-foreground", children: [
9418
9384
  /* @__PURE__ */ jsx35(Languages, { className: "h-3.5 w-3.5 text-primary" }),
@@ -9957,11 +9923,7 @@ var UserMenuCupcode_default = UserMenuCupcode;
9957
9923
  import {
9958
9924
  Loader2,
9959
9925
  LogOut as LogOut2,
9960
- Monitor as Monitor2,
9961
- Moon as Moon2,
9962
- Palette,
9963
9926
  Pencil as Pencil2,
9964
- Sun as Sun2,
9965
9927
  UserRound as UserRound2,
9966
9928
  X as X6
9967
9929
  } from "lucide-react";
@@ -10046,41 +10008,16 @@ SheetDescription.displayName = SheetPrimitive.Description.displayName;
10046
10008
 
10047
10009
  // src/components/cupcode/CustomerUserMenuCupcode.tsx
10048
10010
  import { Fragment as Fragment5, jsx as jsx37, jsxs as jsxs24 } from "react/jsx-runtime";
10049
- var THEME_OPTIONS2 = [
10050
- {
10051
- value: "system",
10052
- label: "Sistema",
10053
- icon: Monitor2
10054
- },
10055
- {
10056
- value: "light",
10057
- label: "Claro",
10058
- icon: Sun2
10059
- },
10060
- {
10061
- value: "dark",
10062
- label: "Escuro",
10063
- icon: Moon2
10064
- }
10065
- ];
10066
- var applyThemeToRoot = (theme) => {
10067
- if (typeof document === "undefined") return;
10068
- const root = document.documentElement;
10069
- root.classList.toggle("dark", theme === "dark");
10070
- root.classList.toggle("light", theme === "light");
10071
- root.dataset.theme = theme;
10072
- root.style.colorScheme = theme;
10073
- };
10074
10011
  var resolveAvatarUrlFromTelescup = (asset, fallbackId) => {
10075
- var _a68, _b4;
10012
+ var _a66, _b3;
10076
10013
  const options = { width: 384, height: 384, fit: "cover", format: "avif", quality: 80 };
10077
- return (_b4 = (_a68 = resolveTelescupImageURL(asset == null ? void 0 : asset.url, options)) != null ? _a68 : resolveTelescupImageURL(asset == null ? void 0 : asset.id, options)) != null ? _b4 : resolveTelescupImageURL(fallbackId, options);
10014
+ return (_b3 = (_a66 = resolveTelescupImageURL(asset == null ? void 0 : asset.url, options)) != null ? _a66 : resolveTelescupImageURL(asset == null ? void 0 : asset.id, options)) != null ? _b3 : resolveTelescupImageURL(fallbackId, options);
10078
10015
  };
10079
10016
  var buildInitials2 = (displayName, email) => {
10080
- var _a68, _b4, _c, _d, _e;
10081
- const source = (displayName == null ? void 0 : displayName.trim()) || ((_a68 = email == null ? void 0 : email.split("@")[0]) == null ? void 0 : _a68.trim()) || "U";
10017
+ var _a66, _b3, _c, _d, _e;
10018
+ const source = (displayName == null ? void 0 : displayName.trim()) || ((_a66 = email == null ? void 0 : email.split("@")[0]) == null ? void 0 : _a66.trim()) || "U";
10082
10019
  const parts = source.split(/\s+/).filter(Boolean);
10083
- const initials = parts.length > 1 ? `${(_c = (_b4 = parts[0]) == null ? void 0 : _b4[0]) != null ? _c : ""}${(_e = (_d = parts[1]) == null ? void 0 : _d[0]) != null ? _e : ""}` : source.slice(0, 2);
10020
+ const initials = parts.length > 1 ? `${(_c = (_b3 = parts[0]) == null ? void 0 : _b3[0]) != null ? _c : ""}${(_e = (_d = parts[1]) == null ? void 0 : _d[0]) != null ? _e : ""}` : source.slice(0, 2);
10084
10021
  return initials.toUpperCase();
10085
10022
  };
10086
10023
  function CustomerUserMenuCupcode({
@@ -10104,25 +10041,12 @@ function CustomerUserMenuCupcode({
10104
10041
  const [isSavingAvatar, setIsSavingAvatar] = useState12(false);
10105
10042
  const [isLoggingOut, setIsLoggingOut] = useState12(false);
10106
10043
  const [profileAvatarUrl, setProfileAvatarUrl] = useState12(avatarUrl);
10107
- const [themePreference, setThemePreference] = useState12(() => resolveStoredThemePreference());
10108
10044
  useEffect13(() => {
10109
10045
  setProfileAvatarUrl(avatarUrl);
10110
10046
  }, [avatarUrl]);
10111
- useEffect13(() => {
10112
- if (typeof window === "undefined") return;
10113
- const syncThemePreference = () => setThemePreference(resolveStoredThemePreference());
10114
- window.addEventListener(THEME_PREFERENCE_CHANGE_EVENT, syncThemePreference);
10115
- return () => window.removeEventListener(THEME_PREFERENCE_CHANGE_EVENT, syncThemePreference);
10116
- }, []);
10117
10047
  const initials = useMemo9(() => buildInitials2(displayName, email), [displayName, email]);
10118
10048
  const userHandle = username ? `@${username.replace(/^@/, "")}` : email;
10119
10049
  const hasTelescupUpload = Boolean(telescupBaseUrl && getTelescupAccessToken);
10120
- const handleThemeSelect = useCallback6((nextPreference) => {
10121
- const appliedTheme = resolveAppliedThemeMode(nextPreference);
10122
- persistThemePreferenceSelection(nextPreference);
10123
- applyThemeToRoot(appliedTheme);
10124
- setThemePreference(nextPreference);
10125
- }, []);
10126
10050
  const openAvatarUpload = useCallback6(() => {
10127
10051
  if (!hasTelescupUpload || isSavingAvatar) return;
10128
10052
  setIsOpen(false);
@@ -10130,9 +10054,9 @@ function CustomerUserMenuCupcode({
10130
10054
  }, [hasTelescupUpload, isSavingAvatar]);
10131
10055
  const handleAvatarChange = useCallback6(
10132
10056
  async (ids, assets) => {
10133
- var _a68, _b4;
10057
+ var _a66, _b3;
10134
10058
  const selectedAsset = assets == null ? void 0 : assets[0];
10135
- const selectedId = (_b4 = (_a68 = parseAssetId(ids[0])) != null ? _a68 : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.id)) != null ? _b4 : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.url);
10059
+ const selectedId = (_b3 = (_a66 = parseAssetId(ids[0])) != null ? _a66 : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.id)) != null ? _b3 : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.url);
10136
10060
  if (!selectedId) {
10137
10061
  toast({
10138
10062
  title: "Imagem inv\xE1lida",
@@ -10223,61 +10147,32 @@ function CustomerUserMenuCupcode({
10223
10147
  /* @__PURE__ */ jsx37("span", { className: "sr-only", children: "Fechar" })
10224
10148
  ] })
10225
10149
  ] }),
10226
- /* @__PURE__ */ jsxs24("div", { className: "flex-1 space-y-5 px-5 py-5", children: [
10227
- /* @__PURE__ */ jsx37("section", { className: "rounded-[22px] border border-white/12 bg-white/[0.06] p-5", children: /* @__PURE__ */ jsxs24("div", { className: "flex items-center gap-4", children: [
10228
- /* @__PURE__ */ jsxs24("div", { className: "relative shrink-0", children: [
10229
- /* @__PURE__ */ jsxs24(Avatar2, { className: "h-24 w-24 border border-white/16 bg-[#24163b]", children: [
10230
- /* @__PURE__ */ jsx37(AvatarImage2, { src: profileAvatarUrl, alt: displayName != null ? displayName : "Perfil" }),
10231
- /* @__PURE__ */ jsx37(AvatarFallback2, { className: "bg-[#24163b] text-3xl font-black text-white", children: initials })
10232
- ] }),
10233
- /* @__PURE__ */ jsx37(
10234
- "button",
10235
- {
10236
- type: "button",
10237
- disabled: !hasTelescupUpload || isSavingAvatar,
10238
- onClick: openAvatarUpload,
10239
- className: "absolute -right-1 top-1 inline-flex h-10 w-10 items-center justify-center rounded-full border border-white/18 bg-[#7c3aed] text-white shadow-lg transition hover:bg-[#8b5cf6] disabled:cursor-not-allowed disabled:opacity-50",
10240
- "aria-label": "Alterar foto de perfil",
10241
- title: hasTelescupUpload ? "Alterar foto" : "Upload indispon\xEDvel",
10242
- children: isSavingAvatar ? /* @__PURE__ */ jsx37(Loader2, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx37(Pencil2, { className: "h-4 w-4" })
10243
- }
10244
- )
10150
+ /* @__PURE__ */ jsx37("div", { className: "flex-1 space-y-5 px-5 py-5", children: /* @__PURE__ */ jsx37("section", { className: "rounded-[22px] border border-white/12 bg-white/[0.06] p-5", children: /* @__PURE__ */ jsxs24("div", { className: "flex items-center gap-4", children: [
10151
+ /* @__PURE__ */ jsxs24("div", { className: "relative shrink-0", children: [
10152
+ /* @__PURE__ */ jsxs24(Avatar2, { className: "h-24 w-24 border border-white/16 bg-[#24163b]", children: [
10153
+ /* @__PURE__ */ jsx37(AvatarImage2, { src: profileAvatarUrl, alt: displayName != null ? displayName : "Perfil" }),
10154
+ /* @__PURE__ */ jsx37(AvatarFallback2, { className: "bg-[#24163b] text-3xl font-black text-white", children: initials })
10245
10155
  ] }),
10246
- /* @__PURE__ */ jsxs24("div", { className: "min-w-0 flex-1 text-left", children: [
10247
- /* @__PURE__ */ jsx37("p", { className: "truncate text-xl font-black text-white", children: displayName != null ? displayName : "Usu\xE1rio" }),
10248
- userHandle ? /* @__PURE__ */ jsx37("p", { className: "mt-1 truncate text-sm text-white/62", children: userHandle }) : null,
10249
- tenantId ? /* @__PURE__ */ jsx37("p", { className: "mt-1 inline-flex max-w-full rounded-full border border-[#a78bfa]/28 bg-[#7c3aed]/16 px-2.5 py-1 text-xs font-bold uppercase tracking-wide text-[#d8c6ff]", children: /* @__PURE__ */ jsx37("span", { className: "truncate", children: tenantId }) }) : null,
10250
- roleLabel ? /* @__PURE__ */ jsx37("p", { className: "mt-2 text-xs font700 uppercase tracking-wide text-[#d4b8ff]", children: roleLabel }) : null
10251
- ] })
10252
- ] }) }),
10253
- /* @__PURE__ */ jsxs24("section", { className: "rounded-[22px] border border-white/12 bg-white/[0.06] p-4", children: [
10254
- /* @__PURE__ */ jsxs24("div", { className: "mb-3 flex items-center gap-2", children: [
10255
- /* @__PURE__ */ jsx37(Palette, { className: "h-4 w-4 text-[#d4b8ff]" }),
10256
- /* @__PURE__ */ jsx37("h3", { className: "text-sm font-extrabold text-white", children: "Tema" })
10257
- ] }),
10258
- /* @__PURE__ */ jsx37("div", { className: "grid grid-cols-3 gap-2", children: THEME_OPTIONS2.map((option) => {
10259
- const Icon3 = option.icon;
10260
- const isActive = themePreference === option.value;
10261
- return /* @__PURE__ */ jsxs24(
10262
- "button",
10263
- {
10264
- type: "button",
10265
- onClick: () => handleThemeSelect(option.value),
10266
- className: [
10267
- "flex min-h-24 flex-col items-center justify-center gap-2 rounded-2xl border px-2 text-center transition",
10268
- isActive ? "border-[#a78bfa]/70 bg-[#7c3aed]/28 text-white" : "border-white/10 bg-black/12 text-white/72 hover:bg-white/8 hover:text-white"
10269
- ].join(" "),
10270
- "aria-pressed": isActive,
10271
- children: [
10272
- /* @__PURE__ */ jsx37("span", { className: "inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-white/10", children: /* @__PURE__ */ jsx37(Icon3, { className: "h-4 w-4" }) }),
10273
- /* @__PURE__ */ jsx37("span", { className: "min-w-0", children: /* @__PURE__ */ jsx37("span", { className: "block text-sm font-extrabold", children: option.label }) })
10274
- ]
10275
- },
10276
- option.value
10277
- );
10278
- }) })
10156
+ /* @__PURE__ */ jsx37(
10157
+ "button",
10158
+ {
10159
+ type: "button",
10160
+ disabled: !hasTelescupUpload || isSavingAvatar,
10161
+ onClick: openAvatarUpload,
10162
+ className: "absolute -right-1 top-1 inline-flex h-10 w-10 items-center justify-center rounded-full border border-white/18 bg-[#7c3aed] text-white shadow-lg transition hover:bg-[#8b5cf6] disabled:cursor-not-allowed disabled:opacity-50",
10163
+ "aria-label": "Alterar foto de perfil",
10164
+ title: hasTelescupUpload ? "Alterar foto" : "Upload indispon\xEDvel",
10165
+ children: isSavingAvatar ? /* @__PURE__ */ jsx37(Loader2, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx37(Pencil2, { className: "h-4 w-4" })
10166
+ }
10167
+ )
10168
+ ] }),
10169
+ /* @__PURE__ */ jsxs24("div", { className: "min-w-0 flex-1 text-left", children: [
10170
+ /* @__PURE__ */ jsx37("p", { className: "truncate text-xl font-black text-white", children: displayName != null ? displayName : "Usu\xE1rio" }),
10171
+ userHandle ? /* @__PURE__ */ jsx37("p", { className: "mt-1 truncate text-sm text-white/62", children: userHandle }) : null,
10172
+ tenantId ? /* @__PURE__ */ jsx37("p", { className: "mt-1 inline-flex max-w-full rounded-full border border-[#a78bfa]/28 bg-[#7c3aed]/16 px-2.5 py-1 text-xs font-bold uppercase tracking-wide text-[#d8c6ff]", children: /* @__PURE__ */ jsx37("span", { className: "truncate", children: tenantId }) }) : null,
10173
+ roleLabel ? /* @__PURE__ */ jsx37("p", { className: "mt-2 text-xs font700 uppercase tracking-wide text-[#d4b8ff]", children: roleLabel }) : null
10279
10174
  ] })
10280
- ] }),
10175
+ ] }) }) }),
10281
10176
  /* @__PURE__ */ jsx37("div", { className: "border-t border-white/10 p-5", children: /* @__PURE__ */ jsxs24(
10282
10177
  Button,
10283
10178
  {
@@ -10487,7 +10382,7 @@ var FunctionsClient = class {
10487
10382
  */
10488
10383
  invoke(functionName_1) {
10489
10384
  return __awaiter(this, arguments, void 0, function* (functionName, options = {}) {
10490
- var _a68;
10385
+ var _a66;
10491
10386
  let timeoutId;
10492
10387
  let timeoutController;
10493
10388
  try {
@@ -10553,7 +10448,7 @@ var FunctionsClient = class {
10553
10448
  if (!response.ok) {
10554
10449
  throw new FunctionsHttpError(response);
10555
10450
  }
10556
- let responseType = ((_a68 = response.headers.get("Content-Type")) !== null && _a68 !== void 0 ? _a68 : "text/plain").split(";")[0].trim();
10451
+ let responseType = ((_a66 = response.headers.get("Content-Type")) !== null && _a66 !== void 0 ? _a66 : "text/plain").split(";")[0].trim();
10557
10452
  let data;
10558
10453
  if (responseType === "application/json") {
10559
10454
  data = yield response.json();
@@ -11902,7 +11797,7 @@ var WebSocketFactory = class {
11902
11797
  constructor() {
11903
11798
  }
11904
11799
  static detectEnvironment() {
11905
- var _a68;
11800
+ var _a66;
11906
11801
  if (typeof WebSocket !== "undefined") {
11907
11802
  return { type: "native", constructor: WebSocket };
11908
11803
  }
@@ -11919,7 +11814,7 @@ var WebSocketFactory = class {
11919
11814
  workaround: "Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."
11920
11815
  };
11921
11816
  }
11922
- if (typeof globalThis !== "undefined" && globalThis.EdgeRuntime || typeof navigator !== "undefined" && ((_a68 = navigator.userAgent) === null || _a68 === void 0 ? void 0 : _a68.includes("Vercel-Edge"))) {
11817
+ if (typeof globalThis !== "undefined" && globalThis.EdgeRuntime || typeof navigator !== "undefined" && ((_a66 = navigator.userAgent) === null || _a66 === void 0 ? void 0 : _a66.includes("Vercel-Edge"))) {
11923
11818
  return {
11924
11819
  type: "unsupported",
11925
11820
  error: "Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",
@@ -12003,7 +11898,7 @@ Suggested solution: ${env.workaround}`;
12003
11898
  try {
12004
11899
  const env = this.detectEnvironment();
12005
11900
  return env.type === "native" || env.type === "ws";
12006
- } catch (_a68) {
11901
+ } catch (_a66) {
12007
11902
  return false;
12008
11903
  }
12009
11904
  }
@@ -12077,30 +11972,30 @@ var Serializer = class {
12077
11972
  return callback(JSON.stringify(payload));
12078
11973
  }
12079
11974
  _binaryEncodeUserBroadcastPush(message) {
12080
- var _a68;
12081
- if (this._isArrayBuffer((_a68 = message.payload) === null || _a68 === void 0 ? void 0 : _a68.payload)) {
11975
+ var _a66;
11976
+ if (this._isArrayBuffer((_a66 = message.payload) === null || _a66 === void 0 ? void 0 : _a66.payload)) {
12082
11977
  return this._encodeBinaryUserBroadcastPush(message);
12083
11978
  } else {
12084
11979
  return this._encodeJsonUserBroadcastPush(message);
12085
11980
  }
12086
11981
  }
12087
11982
  _encodeBinaryUserBroadcastPush(message) {
12088
- var _a68, _b4;
12089
- const userPayload = (_b4 = (_a68 = message.payload) === null || _a68 === void 0 ? void 0 : _a68.payload) !== null && _b4 !== void 0 ? _b4 : new ArrayBuffer(0);
11983
+ var _a66, _b3;
11984
+ const userPayload = (_b3 = (_a66 = message.payload) === null || _a66 === void 0 ? void 0 : _a66.payload) !== null && _b3 !== void 0 ? _b3 : new ArrayBuffer(0);
12090
11985
  return this._encodeUserBroadcastPush(message, this.BINARY_ENCODING, userPayload);
12091
11986
  }
12092
11987
  _encodeJsonUserBroadcastPush(message) {
12093
- var _a68, _b4;
12094
- const userPayload = (_b4 = (_a68 = message.payload) === null || _a68 === void 0 ? void 0 : _a68.payload) !== null && _b4 !== void 0 ? _b4 : {};
11988
+ var _a66, _b3;
11989
+ const userPayload = (_b3 = (_a66 = message.payload) === null || _a66 === void 0 ? void 0 : _a66.payload) !== null && _b3 !== void 0 ? _b3 : {};
12095
11990
  const encoder = new TextEncoder();
12096
11991
  const encodedUserPayload = encoder.encode(JSON.stringify(userPayload)).buffer;
12097
11992
  return this._encodeUserBroadcastPush(message, this.JSON_ENCODING, encodedUserPayload);
12098
11993
  }
12099
11994
  _encodeUserBroadcastPush(message, encodingType, encodedPayload) {
12100
- var _a68, _b4;
11995
+ var _a66, _b3;
12101
11996
  const topic = message.topic;
12102
- const ref = (_a68 = message.ref) !== null && _a68 !== void 0 ? _a68 : "";
12103
- const joinRef = (_b4 = message.join_ref) !== null && _b4 !== void 0 ? _b4 : "";
11997
+ const ref = (_a66 = message.ref) !== null && _a66 !== void 0 ? _a66 : "";
11998
+ const joinRef = (_b3 = message.join_ref) !== null && _b3 !== void 0 ? _b3 : "";
12104
11999
  const userEvent = message.payload.event;
12105
12000
  const rest = this.allowedMetadataKeys ? this._pick(message.payload, this.allowedMetadataKeys) : {};
12106
12001
  const metadata = Object.keys(rest).length === 0 ? "" : JSON.stringify(rest);
@@ -12186,8 +12081,8 @@ var Serializer = class {
12186
12081
  return { join_ref: null, ref: null, topic, event: this.BROADCAST_EVENT, payload: data };
12187
12082
  }
12188
12083
  _isArrayBuffer(buffer) {
12189
- var _a68;
12190
- return buffer instanceof ArrayBuffer || ((_a68 = buffer === null || buffer === void 0 ? void 0 : buffer.constructor) === null || _a68 === void 0 ? void 0 : _a68.name) === "ArrayBuffer";
12084
+ var _a66;
12085
+ return buffer instanceof ArrayBuffer || ((_a66 = buffer === null || buffer === void 0 ? void 0 : buffer.constructor) === null || _a66 === void 0 ? void 0 : _a66.name) === "ArrayBuffer";
12191
12086
  }
12192
12087
  _pick(obj, keys) {
12193
12088
  if (!obj || typeof obj !== "object") {
@@ -12251,8 +12146,8 @@ var PostgresTypes;
12251
12146
  PostgresTypes2["tstzrange"] = "tstzrange";
12252
12147
  })(PostgresTypes || (PostgresTypes = {}));
12253
12148
  var convertChangeData = (columns, record, options = {}) => {
12254
- var _a68;
12255
- const skipTypes = (_a68 = options.skipTypes) !== null && _a68 !== void 0 ? _a68 : [];
12149
+ var _a66;
12150
+ const skipTypes = (_a66 = options.skipTypes) !== null && _a66 !== void 0 ? _a66 : [];
12256
12151
  if (!record) {
12257
12152
  return {};
12258
12153
  }
@@ -12342,7 +12237,7 @@ var toJson = (value) => {
12342
12237
  if (typeof value === "string") {
12343
12238
  try {
12344
12239
  return JSON.parse(value);
12345
- } catch (_a68) {
12240
+ } catch (_a66) {
12346
12241
  return value;
12347
12242
  }
12348
12243
  }
@@ -12434,9 +12329,9 @@ var Push = class {
12434
12329
  this.payload = Object.assign(Object.assign({}, this.payload), payload);
12435
12330
  }
12436
12331
  receive(status, callback) {
12437
- var _a68;
12332
+ var _a66;
12438
12333
  if (this._hasReceived(status)) {
12439
- callback((_a68 = this.receivedResp) === null || _a68 === void 0 ? void 0 : _a68.response);
12334
+ callback((_a66 = this.receivedResp) === null || _a66 === void 0 ? void 0 : _a66.response);
12440
12335
  }
12441
12336
  this.recHooks.push({ status, callback });
12442
12337
  return this;
@@ -12627,8 +12522,8 @@ var RealtimePresence = class _RealtimePresence {
12627
12522
  };
12628
12523
  }
12629
12524
  this.map(joins, (key, newPresences) => {
12630
- var _a68;
12631
- const currentPresences = (_a68 = state[key]) !== null && _a68 !== void 0 ? _a68 : [];
12525
+ var _a66;
12526
+ const currentPresences = (_a66 = state[key]) !== null && _a66 !== void 0 ? _a66 : [];
12632
12527
  state[key] = this.cloneDeep(newPresences);
12633
12528
  if (currentPresences.length > 0) {
12634
12529
  const joinedPresenceRefs = state[key].map((m) => m.presence_ref);
@@ -12756,7 +12651,7 @@ var RealtimeChannel = class _RealtimeChannel {
12756
12651
  * ```
12757
12652
  */
12758
12653
  constructor(topic, params = { config: {} }, socket) {
12759
- var _a68, _b4;
12654
+ var _a66, _b3;
12760
12655
  this.topic = topic;
12761
12656
  this.params = params;
12762
12657
  this.socket = socket;
@@ -12815,19 +12710,19 @@ var RealtimeChannel = class _RealtimeChannel {
12815
12710
  this.presence = new RealtimePresence(this);
12816
12711
  this.broadcastEndpointURL = httpEndpointURL(this.socket.endPoint);
12817
12712
  this.private = this.params.config.private || false;
12818
- if (!this.private && ((_b4 = (_a68 = this.params.config) === null || _a68 === void 0 ? void 0 : _a68.broadcast) === null || _b4 === void 0 ? void 0 : _b4.replay)) {
12713
+ if (!this.private && ((_b3 = (_a66 = this.params.config) === null || _a66 === void 0 ? void 0 : _a66.broadcast) === null || _b3 === void 0 ? void 0 : _b3.replay)) {
12819
12714
  throw `tried to use replay on public channel '${this.topic}'. It must be a private channel.`;
12820
12715
  }
12821
12716
  }
12822
12717
  /** Subscribe registers your client with the server */
12823
12718
  subscribe(callback, timeout = this.timeout) {
12824
- var _a68, _b4, _c;
12719
+ var _a66, _b3, _c;
12825
12720
  if (!this.socket.isConnected()) {
12826
12721
  this.socket.connect();
12827
12722
  }
12828
12723
  if (this.state == CHANNEL_STATES.closed) {
12829
12724
  const { config: { broadcast, presence, private: isPrivate } } = this.params;
12830
- const postgres_changes = (_b4 = (_a68 = this.bindings.postgres_changes) === null || _a68 === void 0 ? void 0 : _a68.map((r) => r.filter)) !== null && _b4 !== void 0 ? _b4 : [];
12725
+ const postgres_changes = (_b3 = (_a66 = this.bindings.postgres_changes) === null || _a66 === void 0 ? void 0 : _a66.map((r) => r.filter)) !== null && _b3 !== void 0 ? _b3 : [];
12831
12726
  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;
12832
12727
  const accessTokenPayload = {};
12833
12728
  const config = {
@@ -12845,7 +12740,7 @@ var RealtimeChannel = class _RealtimeChannel {
12845
12740
  this.joinedOnce = true;
12846
12741
  this._rejoin(timeout);
12847
12742
  this.joinPush.receive("ok", async ({ postgres_changes: postgres_changes2 }) => {
12848
- var _a69;
12743
+ var _a67;
12849
12744
  if (!this.socket._isManualToken()) {
12850
12745
  this.socket.setAuth();
12851
12746
  }
@@ -12854,7 +12749,7 @@ var RealtimeChannel = class _RealtimeChannel {
12854
12749
  return;
12855
12750
  } else {
12856
12751
  const clientPostgresBindings = this.bindings.postgres_changes;
12857
- const bindingsLen = (_a69 = clientPostgresBindings === null || clientPostgresBindings === void 0 ? void 0 : clientPostgresBindings.length) !== null && _a69 !== void 0 ? _a69 : 0;
12752
+ const bindingsLen = (_a67 = clientPostgresBindings === null || clientPostgresBindings === void 0 ? void 0 : clientPostgresBindings.length) !== null && _a67 !== void 0 ? _a67 : 0;
12858
12753
  const newPostgresBindings = [];
12859
12754
  for (let i = 0; i < bindingsLen; i++) {
12860
12755
  const clientPostgresBinding = clientPostgresBindings[i];
@@ -12932,7 +12827,7 @@ var RealtimeChannel = class _RealtimeChannel {
12932
12827
  * @returns Promise resolving to object with success status, and error details if failed
12933
12828
  */
12934
12829
  async httpSend(event, payload, opts = {}) {
12935
- var _a68;
12830
+ var _a66;
12936
12831
  if (payload === void 0 || payload === null) {
12937
12832
  return Promise.reject("Payload is required for httpSend()");
12938
12833
  }
@@ -12957,7 +12852,7 @@ var RealtimeChannel = class _RealtimeChannel {
12957
12852
  ]
12958
12853
  })
12959
12854
  };
12960
- const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a68 = opts.timeout) !== null && _a68 !== void 0 ? _a68 : this.timeout);
12855
+ const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a66 = opts.timeout) !== null && _a66 !== void 0 ? _a66 : this.timeout);
12961
12856
  if (response.status === 202) {
12962
12857
  return { success: true };
12963
12858
  }
@@ -12965,7 +12860,7 @@ var RealtimeChannel = class _RealtimeChannel {
12965
12860
  try {
12966
12861
  const errorBody = await response.json();
12967
12862
  errorMessage = errorBody.error || errorBody.message || errorMessage;
12968
- } catch (_b4) {
12863
+ } catch (_b3) {
12969
12864
  }
12970
12865
  return Promise.reject(new Error(errorMessage));
12971
12866
  }
@@ -12979,7 +12874,7 @@ var RealtimeChannel = class _RealtimeChannel {
12979
12874
  * @param opts Options to be used during the send process
12980
12875
  */
12981
12876
  async send(args, opts = {}) {
12982
- var _a68, _b4;
12877
+ var _a66, _b3;
12983
12878
  if (!this._canPush() && args.type === "broadcast") {
12984
12879
  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.");
12985
12880
  const { event, payload: endpoint_payload } = args;
@@ -13005,8 +12900,8 @@ var RealtimeChannel = class _RealtimeChannel {
13005
12900
  })
13006
12901
  };
13007
12902
  try {
13008
- const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a68 = opts.timeout) !== null && _a68 !== void 0 ? _a68 : this.timeout);
13009
- await ((_b4 = response.body) === null || _b4 === void 0 ? void 0 : _b4.cancel());
12903
+ const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a66 = opts.timeout) !== null && _a66 !== void 0 ? _a66 : this.timeout);
12904
+ await ((_b3 = response.body) === null || _b3 === void 0 ? void 0 : _b3.cancel());
13010
12905
  return response.ok ? "ok" : "error";
13011
12906
  } catch (error) {
13012
12907
  if (error.name === "AbortError") {
@@ -13017,9 +12912,9 @@ var RealtimeChannel = class _RealtimeChannel {
13017
12912
  }
13018
12913
  } else {
13019
12914
  return new Promise((resolve) => {
13020
- var _a69, _b5, _c;
12915
+ var _a67, _b4, _c;
13021
12916
  const push = this._push(args.type, args, opts.timeout || this.timeout);
13022
- if (args.type === "broadcast" && !((_c = (_b5 = (_a69 = this.params) === null || _a69 === void 0 ? void 0 : _a69.config) === null || _b5 === void 0 ? void 0 : _b5.broadcast) === null || _c === void 0 ? void 0 : _c.ack)) {
12917
+ if (args.type === "broadcast" && !((_c = (_b4 = (_a67 = this.params) === null || _a67 === void 0 ? void 0 : _a67.config) === null || _b4 === void 0 ? void 0 : _b4.broadcast) === null || _c === void 0 ? void 0 : _c.ack)) {
13023
12918
  resolve("ok");
13024
12919
  }
13025
12920
  push.receive("ok", () => resolve("ok"));
@@ -13138,7 +13033,7 @@ var RealtimeChannel = class _RealtimeChannel {
13138
13033
  }
13139
13034
  /** @internal */
13140
13035
  _trigger(type, payload, ref) {
13141
- var _a68, _b4;
13036
+ var _a66, _b3;
13142
13037
  const typeLower = type.toLocaleLowerCase();
13143
13038
  const { close, error, leave, join } = CHANNEL_EVENTS;
13144
13039
  const events = [close, error, leave, join];
@@ -13150,18 +13045,18 @@ var RealtimeChannel = class _RealtimeChannel {
13150
13045
  throw "channel onMessage callbacks must return the payload, modified or unmodified";
13151
13046
  }
13152
13047
  if (["insert", "update", "delete"].includes(typeLower)) {
13153
- (_a68 = this.bindings.postgres_changes) === null || _a68 === void 0 ? void 0 : _a68.filter((bind) => {
13154
- var _a69, _b5, _c;
13155
- return ((_a69 = bind.filter) === null || _a69 === void 0 ? void 0 : _a69.event) === "*" || ((_c = (_b5 = bind.filter) === null || _b5 === void 0 ? void 0 : _b5.event) === null || _c === void 0 ? void 0 : _c.toLocaleLowerCase()) === typeLower;
13048
+ (_a66 = this.bindings.postgres_changes) === null || _a66 === void 0 ? void 0 : _a66.filter((bind) => {
13049
+ var _a67, _b4, _c;
13050
+ return ((_a67 = bind.filter) === null || _a67 === void 0 ? void 0 : _a67.event) === "*" || ((_c = (_b4 = bind.filter) === null || _b4 === void 0 ? void 0 : _b4.event) === null || _c === void 0 ? void 0 : _c.toLocaleLowerCase()) === typeLower;
13156
13051
  }).map((bind) => bind.callback(handledPayload, ref));
13157
13052
  } else {
13158
- (_b4 = this.bindings[typeLower]) === null || _b4 === void 0 ? void 0 : _b4.filter((bind) => {
13159
- var _a69, _b5, _c, _d, _e, _f;
13053
+ (_b3 = this.bindings[typeLower]) === null || _b3 === void 0 ? void 0 : _b3.filter((bind) => {
13054
+ var _a67, _b4, _c, _d, _e, _f;
13160
13055
  if (["broadcast", "presence", "postgres_changes"].includes(typeLower)) {
13161
13056
  if ("id" in bind) {
13162
13057
  const bindId = bind.id;
13163
- const bindEvent = (_a69 = bind.filter) === null || _a69 === void 0 ? void 0 : _a69.event;
13164
- return bindId && ((_b5 = payload.ids) === null || _b5 === void 0 ? void 0 : _b5.includes(bindId)) && (bindEvent === "*" || (bindEvent === null || bindEvent === void 0 ? void 0 : bindEvent.toLocaleLowerCase()) === ((_c = payload.data) === null || _c === void 0 ? void 0 : _c.type.toLocaleLowerCase()));
13058
+ const bindEvent = (_a67 = bind.filter) === null || _a67 === void 0 ? void 0 : _a67.event;
13059
+ return bindId && ((_b4 = payload.ids) === null || _b4 === void 0 ? void 0 : _b4.includes(bindId)) && (bindEvent === "*" || (bindEvent === null || bindEvent === void 0 ? void 0 : bindEvent.toLocaleLowerCase()) === ((_c = payload.data) === null || _c === void 0 ? void 0 : _c.type.toLocaleLowerCase()));
13165
13060
  } else {
13166
13061
  const bindEvent = (_e = (_d = bind === null || bind === void 0 ? void 0 : bind.filter) === null || _d === void 0 ? void 0 : _d.event) === null || _e === void 0 ? void 0 : _e.toLocaleLowerCase();
13167
13062
  return bindEvent === "*" || bindEvent === ((_f = payload === null || payload === void 0 ? void 0 : payload.event) === null || _f === void 0 ? void 0 : _f.toLocaleLowerCase());
@@ -13228,8 +13123,8 @@ var RealtimeChannel = class _RealtimeChannel {
13228
13123
  const typeLower = type.toLocaleLowerCase();
13229
13124
  if (this.bindings[typeLower]) {
13230
13125
  this.bindings[typeLower] = this.bindings[typeLower].filter((bind) => {
13231
- var _a68;
13232
- return !(((_a68 = bind.type) === null || _a68 === void 0 ? void 0 : _a68.toLocaleLowerCase()) === typeLower && _RealtimeChannel.isEqual(bind.filter, filter));
13126
+ var _a66;
13127
+ return !(((_a66 = bind.type) === null || _a66 === void 0 ? void 0 : _a66.toLocaleLowerCase()) === typeLower && _RealtimeChannel.isEqual(bind.filter, filter));
13233
13128
  });
13234
13129
  }
13235
13130
  return this;
@@ -13359,7 +13254,7 @@ var RealtimeClient = class {
13359
13254
  * ```
13360
13255
  */
13361
13256
  constructor(endPoint, options) {
13362
- var _a68;
13257
+ var _a66;
13363
13258
  this.accessTokenValue = null;
13364
13259
  this.apiKey = null;
13365
13260
  this._manuallySetToken = false;
@@ -13398,7 +13293,7 @@ var RealtimeClient = class {
13398
13293
  }
13399
13294
  return (...args) => fetch(...args);
13400
13295
  };
13401
- if (!((_a68 = options === null || options === void 0 ? void 0 : options.params) === null || _a68 === void 0 ? void 0 : _a68.apikey)) {
13296
+ if (!((_a66 = options === null || options === void 0 ? void 0 : options.params) === null || _a66 === void 0 ? void 0 : _a66.apikey)) {
13402
13297
  throw new Error("API key is required to connect to Realtime");
13403
13298
  }
13404
13299
  this.apiKey = options.params.apikey;
@@ -13583,8 +13478,8 @@ Option 2: Install and provide the "ws" package:
13583
13478
  const { topic, event, payload, ref } = data;
13584
13479
  const callback = () => {
13585
13480
  this.encode(data, (result) => {
13586
- var _a68;
13587
- (_a68 = this.conn) === null || _a68 === void 0 ? void 0 : _a68.send(result);
13481
+ var _a66;
13482
+ (_a66 = this.conn) === null || _a66 === void 0 ? void 0 : _a66.send(result);
13588
13483
  });
13589
13484
  };
13590
13485
  this.log("push", `${topic} ${event} (${ref})`, payload);
@@ -13634,7 +13529,7 @@ Option 2: Install and provide the "ws" package:
13634
13529
  * Sends a heartbeat message if the socket is connected.
13635
13530
  */
13636
13531
  async sendHeartbeat() {
13637
- var _a68;
13532
+ var _a66;
13638
13533
  if (!this.isConnected()) {
13639
13534
  try {
13640
13535
  this.heartbeatCallback("disconnected");
@@ -13653,11 +13548,11 @@ Option 2: Install and provide the "ws" package:
13653
13548
  this.log("error", "error in heartbeat callback", e);
13654
13549
  }
13655
13550
  this._wasManualDisconnect = false;
13656
- (_a68 = this.conn) === null || _a68 === void 0 ? void 0 : _a68.close(WS_CLOSE_NORMAL, "heartbeat timeout");
13551
+ (_a66 = this.conn) === null || _a66 === void 0 ? void 0 : _a66.close(WS_CLOSE_NORMAL, "heartbeat timeout");
13657
13552
  setTimeout(() => {
13658
- var _a69;
13553
+ var _a67;
13659
13554
  if (!this.isConnected()) {
13660
- (_a69 = this.reconnectTimer) === null || _a69 === void 0 ? void 0 : _a69.scheduleTimeout();
13555
+ (_a67 = this.reconnectTimer) === null || _a67 === void 0 ? void 0 : _a67.scheduleTimeout();
13661
13556
  }
13662
13557
  }, CONNECTION_TIMEOUTS.HEARTBEAT_TIMEOUT_FALLBACK);
13663
13558
  return;
@@ -13755,12 +13650,12 @@ Option 2: Install and provide the "ws" package:
13755
13650
  * @internal
13756
13651
  */
13757
13652
  _clearTimer(timer) {
13758
- var _a68;
13653
+ var _a66;
13759
13654
  if (timer === "heartbeat" && this.heartbeatTimer) {
13760
13655
  clearInterval(this.heartbeatTimer);
13761
13656
  this.heartbeatTimer = void 0;
13762
13657
  } else if (timer === "reconnect") {
13763
- (_a68 = this.reconnectTimer) === null || _a68 === void 0 ? void 0 : _a68.reset();
13658
+ (_a66 = this.reconnectTimer) === null || _a66 === void 0 ? void 0 : _a66.reset();
13764
13659
  }
13765
13660
  }
13766
13661
  /**
@@ -13875,13 +13770,13 @@ Option 2: Install and provide the "ws" package:
13875
13770
  }
13876
13771
  /** @internal */
13877
13772
  _onConnClose(event) {
13878
- var _a68;
13773
+ var _a66;
13879
13774
  this._setConnectionState("disconnected");
13880
13775
  this.log("transport", "close", event);
13881
13776
  this._triggerChanError();
13882
13777
  this._clearTimer("heartbeat");
13883
13778
  if (!this._wasManualDisconnect) {
13884
- (_a68 = this.reconnectTimer) === null || _a68 === void 0 ? void 0 : _a68.scheduleTimeout();
13779
+ (_a66 = this.reconnectTimer) === null || _a66 === void 0 ? void 0 : _a66.scheduleTimeout();
13885
13780
  }
13886
13781
  this._triggerStateCallbacks("close", event);
13887
13782
  }
@@ -14029,9 +13924,9 @@ Option 2: Install and provide the "ws" package:
14029
13924
  * @internal
14030
13925
  */
14031
13926
  _initializeOptions(options) {
14032
- var _a68, _b4, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
14033
- this.transport = (_a68 = options === null || options === void 0 ? void 0 : options.transport) !== null && _a68 !== void 0 ? _a68 : null;
14034
- this.timeout = (_b4 = options === null || options === void 0 ? void 0 : options.timeout) !== null && _b4 !== void 0 ? _b4 : DEFAULT_TIMEOUT;
13927
+ var _a66, _b3, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
13928
+ this.transport = (_a66 = options === null || options === void 0 ? void 0 : options.transport) !== null && _a66 !== void 0 ? _a66 : null;
13929
+ this.timeout = (_b3 = options === null || options === void 0 ? void 0 : options.timeout) !== null && _b3 !== void 0 ? _b3 : DEFAULT_TIMEOUT;
14035
13930
  this.heartbeatIntervalMs = (_c = options === null || options === void 0 ? void 0 : options.heartbeatIntervalMs) !== null && _c !== void 0 ? _c : CONNECTION_TIMEOUTS.HEARTBEAT_INTERVAL;
14036
13931
  this.worker = (_d = options === null || options === void 0 ? void 0 : options.worker) !== null && _d !== void 0 ? _d : false;
14037
13932
  this.accessToken = (_e = options === null || options === void 0 ? void 0 : options.accessToken) !== null && _e !== void 0 ? _e : null;
@@ -14076,14 +13971,14 @@ Option 2: Install and provide the "ws" package:
14076
13971
  // node_modules/.pnpm/iceberg-js@0.8.1/node_modules/iceberg-js/dist/index.mjs
14077
13972
  var IcebergError = class extends Error {
14078
13973
  constructor(message, opts) {
14079
- var _a68;
13974
+ var _a66;
14080
13975
  super(message);
14081
13976
  this.name = "IcebergError";
14082
13977
  this.status = opts.status;
14083
13978
  this.icebergType = opts.icebergType;
14084
13979
  this.icebergCode = opts.icebergCode;
14085
13980
  this.details = opts.details;
14086
- this.isCommitStateUnknown = opts.icebergType === "CommitStateUnknownException" || [500, 502, 504].includes(opts.status) && ((_a68 = opts.icebergType) == null ? void 0 : _a68.includes("CommitState")) === true;
13981
+ this.isCommitStateUnknown = opts.icebergType === "CommitStateUnknownException" || [500, 502, 504].includes(opts.status) && ((_a66 = opts.icebergType) == null ? void 0 : _a66.includes("CommitState")) === true;
14087
13982
  }
14088
13983
  /**
14089
13984
  * Returns true if the error is a 404 Not Found error.
@@ -14131,8 +14026,8 @@ async function buildAuthHeaders(auth) {
14131
14026
  return {};
14132
14027
  }
14133
14028
  function createFetchClient(options) {
14134
- var _a68;
14135
- const fetchFn = (_a68 = options.fetchImpl) != null ? _a68 : globalThis.fetch;
14029
+ var _a66;
14030
+ const fetchFn = (_a66 = options.fetchImpl) != null ? _a66 : globalThis.fetch;
14136
14031
  return {
14137
14032
  async request({
14138
14033
  method,
@@ -14141,7 +14036,7 @@ function createFetchClient(options) {
14141
14036
  body,
14142
14037
  headers
14143
14038
  }) {
14144
- var _a69;
14039
+ var _a67;
14145
14040
  const url = buildUrl(options.baseUrl, path, query);
14146
14041
  const authHeaders = await buildAuthHeaders(options.auth);
14147
14042
  const res = await fetchFn(url, {
@@ -14160,7 +14055,7 @@ function createFetchClient(options) {
14160
14055
  const errBody = isJson ? data : void 0;
14161
14056
  const errorDetail = errBody == null ? void 0 : errBody.error;
14162
14057
  throw new IcebergError(
14163
- (_a69 = errorDetail == null ? void 0 : errorDetail.message) != null ? _a69 : `Request failed with status ${res.status}`,
14058
+ (_a67 = errorDetail == null ? void 0 : errorDetail.message) != null ? _a67 : `Request failed with status ${res.status}`,
14164
14059
  {
14165
14060
  status: res.status,
14166
14061
  icebergType: errorDetail == null ? void 0 : errorDetail.type,
@@ -14283,11 +14178,11 @@ var TableOperations = class {
14283
14178
  };
14284
14179
  }
14285
14180
  async dropTable(id, options) {
14286
- var _a68;
14181
+ var _a66;
14287
14182
  await this.client.request({
14288
14183
  method: "DELETE",
14289
14184
  path: `${this.prefix}/namespaces/${namespaceToPath2(id.namespace)}/tables/${id.name}`,
14290
- query: { purgeRequested: String((_a68 = options == null ? void 0 : options.purge) != null ? _a68 : false) }
14185
+ query: { purgeRequested: String((_a66 = options == null ? void 0 : options.purge) != null ? _a66 : false) }
14291
14186
  });
14292
14187
  }
14293
14188
  async loadTable(id) {
@@ -14339,7 +14234,7 @@ var IcebergRestCatalog = class {
14339
14234
  * @param options - Configuration options for the catalog client
14340
14235
  */
14341
14236
  constructor(options) {
14342
- var _a68;
14237
+ var _a66;
14343
14238
  let prefix = "v1";
14344
14239
  if (options.catalogName) {
14345
14240
  prefix += `/${options.catalogName}`;
@@ -14350,7 +14245,7 @@ var IcebergRestCatalog = class {
14350
14245
  auth: options.auth,
14351
14246
  fetchImpl: options.fetch
14352
14247
  });
14353
- this.accessDelegation = (_a68 = options.accessDelegation) == null ? void 0 : _a68.join(",");
14248
+ this.accessDelegation = (_a66 = options.accessDelegation) == null ? void 0 : _a66.join(",");
14354
14249
  this.namespaceOps = new NamespaceOperations(this.client, prefix);
14355
14250
  this.tableOps = new TableOperations(this.client, prefix, this.accessDelegation);
14356
14251
  }
@@ -17323,7 +17218,7 @@ var getItemAsync = async (storage, key) => {
17323
17218
  }
17324
17219
  try {
17325
17220
  return JSON.parse(value);
17326
- } catch (_a68) {
17221
+ } catch (_a66) {
17327
17222
  return value;
17328
17223
  }
17329
17224
  };
@@ -17534,7 +17429,7 @@ function deepClone(obj) {
17534
17429
  var _getErrorMessage2 = (err) => err.msg || err.message || err.error_description || err.error || JSON.stringify(err);
17535
17430
  var NETWORK_ERROR_CODES = [502, 503, 504];
17536
17431
  async function handleError2(error) {
17537
- var _a68;
17432
+ var _a66;
17538
17433
  if (!looksLikeFetchResponse(error)) {
17539
17434
  throw new AuthRetryableFetchError(_getErrorMessage2(error), 0);
17540
17435
  }
@@ -17559,7 +17454,7 @@ async function handleError2(error) {
17559
17454
  throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, data.weak_password.reasons);
17560
17455
  }
17561
17456
  } else if (errorCode === "weak_password") {
17562
- throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, ((_a68 = data.weak_password) === null || _a68 === void 0 ? void 0 : _a68.reasons) || []);
17457
+ throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, ((_a66 = data.weak_password) === null || _a66 === void 0 ? void 0 : _a66.reasons) || []);
17563
17458
  } else if (errorCode === "session_not_found") {
17564
17459
  throw new AuthSessionMissingError();
17565
17460
  }
@@ -17575,7 +17470,7 @@ var _getRequestParams2 = (method, options, parameters, body) => {
17575
17470
  return Object.assign(Object.assign({}, params), parameters);
17576
17471
  };
17577
17472
  async function _request(fetcher, method, url, options) {
17578
- var _a68;
17473
+ var _a66;
17579
17474
  const headers = Object.assign({}, options === null || options === void 0 ? void 0 : options.headers);
17580
17475
  if (!headers[API_VERSION_HEADER_NAME]) {
17581
17476
  headers[API_VERSION_HEADER_NAME] = API_VERSIONS["2024-01-01"].name;
@@ -17583,7 +17478,7 @@ async function _request(fetcher, method, url, options) {
17583
17478
  if (options === null || options === void 0 ? void 0 : options.jwt) {
17584
17479
  headers["Authorization"] = `Bearer ${options.jwt}`;
17585
17480
  }
17586
- const qs = (_a68 = options === null || options === void 0 ? void 0 : options.query) !== null && _a68 !== void 0 ? _a68 : {};
17481
+ const qs = (_a66 = options === null || options === void 0 ? void 0 : options.query) !== null && _a66 !== void 0 ? _a66 : {};
17587
17482
  if (options === null || options === void 0 ? void 0 : options.redirectTo) {
17588
17483
  qs["redirect_to"] = options.redirectTo;
17589
17484
  }
@@ -17616,7 +17511,7 @@ async function _handleRequest2(fetcher, method, url, options, parameters, body)
17616
17511
  }
17617
17512
  }
17618
17513
  function _sessionResponse(data) {
17619
- var _a68;
17514
+ var _a66;
17620
17515
  let session = null;
17621
17516
  if (hasSession(data)) {
17622
17517
  session = Object.assign({}, data);
@@ -17624,7 +17519,7 @@ function _sessionResponse(data) {
17624
17519
  session.expires_at = expiresAt(data.expires_in);
17625
17520
  }
17626
17521
  }
17627
- const user = (_a68 = data.user) !== null && _a68 !== void 0 ? _a68 : data;
17522
+ const user = (_a66 = data.user) !== null && _a66 !== void 0 ? _a66 : data;
17628
17523
  return { data: { session, user }, error: null };
17629
17524
  }
17630
17525
  function _sessionResponsePassword(data) {
@@ -17635,8 +17530,8 @@ function _sessionResponsePassword(data) {
17635
17530
  return response;
17636
17531
  }
17637
17532
  function _userResponse(data) {
17638
- var _a68;
17639
- const user = (_a68 = data.user) !== null && _a68 !== void 0 ? _a68 : data;
17533
+ var _a66;
17534
+ const user = (_a66 = data.user) !== null && _a66 !== void 0 ? _a66 : data;
17640
17535
  return { data: { user }, error: null };
17641
17536
  }
17642
17537
  function _ssoResponse(data) {
@@ -17805,14 +17700,14 @@ var GoTrueAdminApi = class {
17805
17700
  * @param params An object which supports `page` and `perPage` as numbers, to alter the paginated results.
17806
17701
  */
17807
17702
  async listUsers(params) {
17808
- var _a68, _b4, _c, _d, _e, _f, _g;
17703
+ var _a66, _b3, _c, _d, _e, _f, _g;
17809
17704
  try {
17810
17705
  const pagination = { nextPage: null, lastPage: 0, total: 0 };
17811
17706
  const response = await _request(this.fetch, "GET", `${this.url}/admin/users`, {
17812
17707
  headers: this.headers,
17813
17708
  noResolveJson: true,
17814
17709
  query: {
17815
- page: (_b4 = (_a68 = params === null || params === void 0 ? void 0 : params.page) === null || _a68 === void 0 ? void 0 : _a68.toString()) !== null && _b4 !== void 0 ? _b4 : "",
17710
+ page: (_b3 = (_a66 = params === null || params === void 0 ? void 0 : params.page) === null || _a66 === void 0 ? void 0 : _a66.toString()) !== null && _b3 !== void 0 ? _b3 : "",
17816
17711
  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 : ""
17817
17712
  },
17818
17713
  xform: _noResolveJsonResponse
@@ -17946,14 +17841,14 @@ var GoTrueAdminApi = class {
17946
17841
  * This function should only be called on a server. Never expose your `service_role` key in the browser.
17947
17842
  */
17948
17843
  async _listOAuthClients(params) {
17949
- var _a68, _b4, _c, _d, _e, _f, _g;
17844
+ var _a66, _b3, _c, _d, _e, _f, _g;
17950
17845
  try {
17951
17846
  const pagination = { nextPage: null, lastPage: 0, total: 0 };
17952
17847
  const response = await _request(this.fetch, "GET", `${this.url}/admin/oauth/clients`, {
17953
17848
  headers: this.headers,
17954
17849
  noResolveJson: true,
17955
17850
  query: {
17956
- page: (_b4 = (_a68 = params === null || params === void 0 ? void 0 : params.page) === null || _a68 === void 0 ? void 0 : _a68.toString()) !== null && _b4 !== void 0 ? _b4 : "",
17851
+ page: (_b3 = (_a66 = params === null || params === void 0 ? void 0 : params.page) === null || _a66 === void 0 ? void 0 : _a66.toString()) !== null && _b3 !== void 0 ? _b3 : "",
17957
17852
  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 : ""
17958
17853
  },
17959
17854
  xform: _noResolveJsonResponse
@@ -18206,7 +18101,7 @@ function toHex(value) {
18206
18101
  return "0x" + hex;
18207
18102
  }
18208
18103
  function createSiweMessage(parameters) {
18209
- var _a68;
18104
+ var _a66;
18210
18105
  const { chainId, domain, expirationTime, issuedAt = /* @__PURE__ */ new Date(), nonce, notBefore, requestId, resources, scheme, uri, version: version5 } = parameters;
18211
18106
  {
18212
18107
  if (!Number.isInteger(chainId))
@@ -18219,7 +18114,7 @@ function createSiweMessage(parameters) {
18219
18114
  throw new Error(`@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.`);
18220
18115
  if (version5 !== "1")
18221
18116
  throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${version5}`);
18222
- if ((_a68 = parameters.statement) === null || _a68 === void 0 ? void 0 : _a68.includes("\n"))
18117
+ if ((_a66 = parameters.statement) === null || _a66 === void 0 ? void 0 : _a66.includes("\n"))
18223
18118
  throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${parameters.statement}`);
18224
18119
  }
18225
18120
  const address = getAddress(parameters.address);
@@ -18261,10 +18156,10 @@ ${suffix}`;
18261
18156
  // node_modules/.pnpm/@supabase+auth-js@2.95.1/node_modules/@supabase/auth-js/dist/module/lib/webauthn.errors.js
18262
18157
  var WebAuthnError = class extends Error {
18263
18158
  constructor({ message, code, cause, name }) {
18264
- var _a68;
18159
+ var _a66;
18265
18160
  super(message, { cause });
18266
18161
  this.__isWebAuthnError = true;
18267
- this.name = (_a68 = name !== null && name !== void 0 ? name : cause instanceof Error ? cause.name : void 0) !== null && _a68 !== void 0 ? _a68 : "Unknown Error";
18162
+ this.name = (_a66 = name !== null && name !== void 0 ? name : cause instanceof Error ? cause.name : void 0) !== null && _a66 !== void 0 ? _a66 : "Unknown Error";
18268
18163
  this.code = code;
18269
18164
  }
18270
18165
  };
@@ -18280,7 +18175,7 @@ var WebAuthnUnknownError = class extends WebAuthnError {
18280
18175
  }
18281
18176
  };
18282
18177
  function identifyRegistrationError({ error, options }) {
18283
- var _a68, _b4, _c;
18178
+ var _a66, _b3, _c;
18284
18179
  const { publicKey } = options;
18285
18180
  if (!publicKey) {
18286
18181
  throw Error("options was missing required publicKey property");
@@ -18294,7 +18189,7 @@ function identifyRegistrationError({ error, options }) {
18294
18189
  });
18295
18190
  }
18296
18191
  } else if (error.name === "ConstraintError") {
18297
- if (((_a68 = publicKey.authenticatorSelection) === null || _a68 === void 0 ? void 0 : _a68.requireResidentKey) === true) {
18192
+ if (((_a66 = publicKey.authenticatorSelection) === null || _a66 === void 0 ? void 0 : _a66.requireResidentKey) === true) {
18298
18193
  return new WebAuthnError({
18299
18194
  message: "Discoverable credentials were required but no available authenticator supported it",
18300
18195
  code: "ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",
@@ -18302,7 +18197,7 @@ function identifyRegistrationError({ error, options }) {
18302
18197
  });
18303
18198
  } else if (
18304
18199
  // @ts-ignore: `mediation` doesn't yet exist on CredentialCreationOptions but it's possible as of Sept 2024
18305
- options.mediation === "conditional" && ((_b4 = publicKey.authenticatorSelection) === null || _b4 === void 0 ? void 0 : _b4.userVerification) === "required"
18200
+ options.mediation === "conditional" && ((_b3 = publicKey.authenticatorSelection) === null || _b3 === void 0 ? void 0 : _b3.userVerification) === "required"
18306
18201
  ) {
18307
18202
  return new WebAuthnError({
18308
18203
  message: "User verification was required during automatic registration but it could not be performed",
@@ -18523,7 +18418,7 @@ function deserializeCredentialRequestOptions(options) {
18523
18418
  return result;
18524
18419
  }
18525
18420
  function serializeCredentialCreationResponse(credential) {
18526
- var _a68;
18421
+ var _a66;
18527
18422
  if ("toJSON" in credential && typeof credential.toJSON === "function") {
18528
18423
  return credential.toJSON();
18529
18424
  }
@@ -18538,11 +18433,11 @@ function serializeCredentialCreationResponse(credential) {
18538
18433
  type: "public-key",
18539
18434
  clientExtensionResults: credential.getClientExtensionResults(),
18540
18435
  // Convert null to undefined and cast to AuthenticatorAttachment type
18541
- authenticatorAttachment: (_a68 = credentialWithAttachment.authenticatorAttachment) !== null && _a68 !== void 0 ? _a68 : void 0
18436
+ authenticatorAttachment: (_a66 = credentialWithAttachment.authenticatorAttachment) !== null && _a66 !== void 0 ? _a66 : void 0
18542
18437
  };
18543
18438
  }
18544
18439
  function serializeCredentialRequestResponse(credential) {
18545
- var _a68;
18440
+ var _a66;
18546
18441
  if ("toJSON" in credential && typeof credential.toJSON === "function") {
18547
18442
  return credential.toJSON();
18548
18443
  }
@@ -18562,7 +18457,7 @@ function serializeCredentialRequestResponse(credential) {
18562
18457
  type: "public-key",
18563
18458
  clientExtensionResults,
18564
18459
  // Convert null to undefined and cast to AuthenticatorAttachment type
18565
- authenticatorAttachment: (_a68 = credentialWithAttachment.authenticatorAttachment) !== null && _a68 !== void 0 ? _a68 : void 0
18460
+ authenticatorAttachment: (_a66 = credentialWithAttachment.authenticatorAttachment) !== null && _a66 !== void 0 ? _a66 : void 0
18566
18461
  };
18567
18462
  }
18568
18463
  function isValidDomain(hostname) {
@@ -18572,8 +18467,8 @@ function isValidDomain(hostname) {
18572
18467
  );
18573
18468
  }
18574
18469
  function browserSupportsWebAuthn() {
18575
- var _a68, _b4;
18576
- return !!(isBrowser() && "PublicKeyCredential" in window && window.PublicKeyCredential && "credentials" in navigator && typeof ((_a68 = navigator === null || navigator === void 0 ? void 0 : navigator.credentials) === null || _a68 === void 0 ? void 0 : _a68.create) === "function" && typeof ((_b4 = navigator === null || navigator === void 0 ? void 0 : navigator.credentials) === null || _b4 === void 0 ? void 0 : _b4.get) === "function");
18470
+ var _a66, _b3;
18471
+ return !!(isBrowser() && "PublicKeyCredential" in window && window.PublicKeyCredential && "credentials" in navigator && typeof ((_a66 = navigator === null || navigator === void 0 ? void 0 : navigator.credentials) === null || _a66 === void 0 ? void 0 : _a66.create) === "function" && typeof ((_b3 = navigator === null || navigator === void 0 ? void 0 : navigator.credentials) === null || _b3 === void 0 ? void 0 : _b3.get) === "function");
18577
18472
  }
18578
18473
  async function createCredential(options) {
18579
18474
  try {
@@ -18721,7 +18616,7 @@ var WebAuthnApi = class {
18721
18616
  * @see {@link https://w3c.github.io/webauthn/#sctn-verifying-assertion W3C WebAuthn Spec - Verifying Assertion}
18722
18617
  */
18723
18618
  async _challenge({ factorId, webauthn, friendlyName, signal }, overrides) {
18724
- var _a68;
18619
+ var _a66;
18725
18620
  try {
18726
18621
  const { data: challengeResponse, error: challengeError } = await this.client.mfa.challenge({
18727
18622
  factorId,
@@ -18738,7 +18633,7 @@ var WebAuthnApi = class {
18738
18633
  if (!nameToUse) {
18739
18634
  const currentUser = await this.client.getUser();
18740
18635
  const userData = currentUser.data.user;
18741
- const fallbackName = ((_a68 = userData === null || userData === void 0 ? void 0 : userData.user_metadata) === null || _a68 === void 0 ? void 0 : _a68.name) || (userData === null || userData === void 0 ? void 0 : userData.email) || (userData === null || userData === void 0 ? void 0 : userData.id) || "User";
18636
+ const fallbackName = ((_a66 = userData === null || userData === void 0 ? void 0 : userData.user_metadata) === null || _a66 === void 0 ? void 0 : _a66.name) || (userData === null || userData === void 0 ? void 0 : userData.email) || (userData === null || userData === void 0 ? void 0 : userData.id) || "User";
18742
18637
  user.name = `${user.id}:${fallbackName}`;
18743
18638
  } else {
18744
18639
  user.name = `${user.id}:${nameToUse}`;
@@ -18911,8 +18806,8 @@ var WebAuthnApi = class {
18911
18806
  });
18912
18807
  if (!factor) {
18913
18808
  await this.client.mfa.listFactors().then((factors) => {
18914
- var _a68;
18915
- return (_a68 = factors.data) === null || _a68 === void 0 ? void 0 : _a68.all.find((v) => v.factor_type === "webauthn" && v.friendly_name === friendlyName && v.status !== "unverified");
18809
+ var _a66;
18810
+ return (_a66 = factors.data) === null || _a66 === void 0 ? void 0 : _a66.all.find((v) => v.factor_type === "webauthn" && v.friendly_name === friendlyName && v.status !== "unverified");
18916
18811
  }).then((factor2) => factor2 ? this.client.mfa.unenroll({ factorId: factor2 === null || factor2 === void 0 ? void 0 : factor2.id }) : void 0);
18917
18812
  return { data: null, error: enrollError };
18918
18813
  }
@@ -18974,15 +18869,15 @@ var GoTrueClient = class _GoTrueClient {
18974
18869
  * The JWKS used for verifying asymmetric JWTs
18975
18870
  */
18976
18871
  get jwks() {
18977
- var _a68, _b4;
18978
- return (_b4 = (_a68 = GLOBAL_JWKS[this.storageKey]) === null || _a68 === void 0 ? void 0 : _a68.jwks) !== null && _b4 !== void 0 ? _b4 : { keys: [] };
18872
+ var _a66, _b3;
18873
+ return (_b3 = (_a66 = GLOBAL_JWKS[this.storageKey]) === null || _a66 === void 0 ? void 0 : _a66.jwks) !== null && _b3 !== void 0 ? _b3 : { keys: [] };
18979
18874
  }
18980
18875
  set jwks(value) {
18981
18876
  GLOBAL_JWKS[this.storageKey] = Object.assign(Object.assign({}, GLOBAL_JWKS[this.storageKey]), { jwks: value });
18982
18877
  }
18983
18878
  get jwks_cached_at() {
18984
- var _a68, _b4;
18985
- return (_b4 = (_a68 = GLOBAL_JWKS[this.storageKey]) === null || _a68 === void 0 ? void 0 : _a68.cachedAt) !== null && _b4 !== void 0 ? _b4 : Number.MIN_SAFE_INTEGER;
18879
+ var _a66, _b3;
18880
+ return (_b3 = (_a66 = GLOBAL_JWKS[this.storageKey]) === null || _a66 === void 0 ? void 0 : _a66.cachedAt) !== null && _b3 !== void 0 ? _b3 : Number.MIN_SAFE_INTEGER;
18986
18881
  }
18987
18882
  set jwks_cached_at(value) {
18988
18883
  GLOBAL_JWKS[this.storageKey] = Object.assign(Object.assign({}, GLOBAL_JWKS[this.storageKey]), { cachedAt: value });
@@ -19002,7 +18897,7 @@ var GoTrueClient = class _GoTrueClient {
19002
18897
  * ```
19003
18898
  */
19004
18899
  constructor(options) {
19005
- var _a68, _b4, _c;
18900
+ var _a66, _b3, _c;
19006
18901
  this.userStorage = null;
19007
18902
  this.memoryStorage = null;
19008
18903
  this.stateChangeEmitters = /* @__PURE__ */ new Map();
@@ -19020,7 +18915,7 @@ var GoTrueClient = class _GoTrueClient {
19020
18915
  this.logger = console.log;
19021
18916
  const settings = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options);
19022
18917
  this.storageKey = settings.storageKey;
19023
- this.instanceID = (_a68 = _GoTrueClient.nextInstanceID[this.storageKey]) !== null && _a68 !== void 0 ? _a68 : 0;
18918
+ this.instanceID = (_a66 = _GoTrueClient.nextInstanceID[this.storageKey]) !== null && _a66 !== void 0 ? _a66 : 0;
19024
18919
  _GoTrueClient.nextInstanceID[this.storageKey] = this.instanceID + 1;
19025
18920
  this.logDebugMessages = !!settings.debug;
19026
18921
  if (typeof settings.debug === "function") {
@@ -19051,7 +18946,7 @@ var GoTrueClient = class _GoTrueClient {
19051
18946
  this.lockAcquireTimeout = settings.lockAcquireTimeout;
19052
18947
  if (settings.lock) {
19053
18948
  this.lock = settings.lock;
19054
- } else if (this.persistSession && isBrowser() && ((_b4 = globalThis === null || globalThis === void 0 ? void 0 : globalThis.navigator) === null || _b4 === void 0 ? void 0 : _b4.locks)) {
18949
+ } else if (this.persistSession && isBrowser() && ((_b3 = globalThis === null || globalThis === void 0 ? void 0 : globalThis.navigator) === null || _b3 === void 0 ? void 0 : _b3.locks)) {
19055
18950
  this.lock = navigatorLock;
19056
18951
  } else {
19057
18952
  this.lock = lockNoOp;
@@ -19163,7 +19058,7 @@ var GoTrueClient = class _GoTrueClient {
19163
19058
  * the whole lifetime of the client
19164
19059
  */
19165
19060
  async _initialize() {
19166
- var _a68;
19061
+ var _a66;
19167
19062
  try {
19168
19063
  let params = {};
19169
19064
  let callbackUrlType = "none";
@@ -19180,7 +19075,7 @@ var GoTrueClient = class _GoTrueClient {
19180
19075
  if (error) {
19181
19076
  this._debug("#_initialize()", "error detecting session from URL", error);
19182
19077
  if (isAuthImplicitGrantRedirectError(error)) {
19183
- const errorCode = (_a68 = error.details) === null || _a68 === void 0 ? void 0 : _a68.code;
19078
+ const errorCode = (_a66 = error.details) === null || _a66 === void 0 ? void 0 : _a66.code;
19184
19079
  if (errorCode === "identity_already_exists" || errorCode === "identity_not_found" || errorCode === "single_identity_not_deletable") {
19185
19080
  return { error };
19186
19081
  }
@@ -19219,12 +19114,12 @@ var GoTrueClient = class _GoTrueClient {
19219
19114
  * @returns A session where the is_anonymous claim in the access token JWT set to true
19220
19115
  */
19221
19116
  async signInAnonymously(credentials) {
19222
- var _a68, _b4, _c;
19117
+ var _a66, _b3, _c;
19223
19118
  try {
19224
19119
  const res = await _request(this.fetch, "POST", `${this.url}/signup`, {
19225
19120
  headers: this.headers,
19226
19121
  body: {
19227
- data: (_b4 = (_a68 = credentials === null || credentials === void 0 ? void 0 : credentials.options) === null || _a68 === void 0 ? void 0 : _a68.data) !== null && _b4 !== void 0 ? _b4 : {},
19122
+ data: (_b3 = (_a66 = credentials === null || credentials === void 0 ? void 0 : credentials.options) === null || _a66 === void 0 ? void 0 : _a66.data) !== null && _b3 !== void 0 ? _b3 : {},
19228
19123
  gotrue_meta_security: { captcha_token: (_c = credentials === null || credentials === void 0 ? void 0 : credentials.options) === null || _c === void 0 ? void 0 : _c.captchaToken }
19229
19124
  },
19230
19125
  xform: _sessionResponse
@@ -19258,7 +19153,7 @@ var GoTrueClient = class _GoTrueClient {
19258
19153
  * @returns A user if the server has "autoconfirm" OFF
19259
19154
  */
19260
19155
  async signUp(credentials) {
19261
- var _a68, _b4, _c;
19156
+ var _a66, _b3, _c;
19262
19157
  try {
19263
19158
  let res;
19264
19159
  if ("email" in credentials) {
@@ -19275,7 +19170,7 @@ var GoTrueClient = class _GoTrueClient {
19275
19170
  body: {
19276
19171
  email,
19277
19172
  password,
19278
- data: (_a68 = options === null || options === void 0 ? void 0 : options.data) !== null && _a68 !== void 0 ? _a68 : {},
19173
+ data: (_a66 = options === null || options === void 0 ? void 0 : options.data) !== null && _a66 !== void 0 ? _a66 : {},
19279
19174
  gotrue_meta_security: { captcha_token: options === null || options === void 0 ? void 0 : options.captchaToken },
19280
19175
  code_challenge: codeChallenge,
19281
19176
  code_challenge_method: codeChallengeMethod
@@ -19289,7 +19184,7 @@ var GoTrueClient = class _GoTrueClient {
19289
19184
  body: {
19290
19185
  phone,
19291
19186
  password,
19292
- data: (_b4 = options === null || options === void 0 ? void 0 : options.data) !== null && _b4 !== void 0 ? _b4 : {},
19187
+ data: (_b3 = options === null || options === void 0 ? void 0 : options.data) !== null && _b3 !== void 0 ? _b3 : {},
19293
19188
  channel: (_c = options === null || options === void 0 ? void 0 : options.channel) !== null && _c !== void 0 ? _c : "sms",
19294
19189
  gotrue_meta_security: { captcha_token: options === null || options === void 0 ? void 0 : options.captchaToken }
19295
19190
  },
@@ -19381,10 +19276,10 @@ var GoTrueClient = class _GoTrueClient {
19381
19276
  * This method supports the PKCE flow.
19382
19277
  */
19383
19278
  async signInWithOAuth(credentials) {
19384
- var _a68, _b4, _c, _d;
19279
+ var _a66, _b3, _c, _d;
19385
19280
  return await this._handleProviderSignIn(credentials.provider, {
19386
- redirectTo: (_a68 = credentials.options) === null || _a68 === void 0 ? void 0 : _a68.redirectTo,
19387
- scopes: (_b4 = credentials.options) === null || _b4 === void 0 ? void 0 : _b4.scopes,
19281
+ redirectTo: (_a66 = credentials.options) === null || _a66 === void 0 ? void 0 : _a66.redirectTo,
19282
+ scopes: (_b3 = credentials.options) === null || _b3 === void 0 ? void 0 : _b3.scopes,
19388
19283
  queryParams: (_c = credentials.options) === null || _c === void 0 ? void 0 : _c.queryParams,
19389
19284
  skipBrowserRedirect: (_d = credentials.options) === null || _d === void 0 ? void 0 : _d.skipBrowserRedirect
19390
19285
  });
@@ -19417,7 +19312,7 @@ var GoTrueClient = class _GoTrueClient {
19417
19312
  }
19418
19313
  }
19419
19314
  async signInWithEthereum(credentials) {
19420
- var _a68, _b4, _c, _d, _e, _f, _g, _h, _j, _k, _l;
19315
+ var _a66, _b3, _c, _d, _e, _f, _g, _h, _j, _k, _l;
19421
19316
  let message;
19422
19317
  let signature;
19423
19318
  if ("message" in credentials) {
@@ -19441,7 +19336,7 @@ var GoTrueClient = class _GoTrueClient {
19441
19336
  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.`);
19442
19337
  }
19443
19338
  }
19444
- const url = new URL((_a68 = options === null || options === void 0 ? void 0 : options.url) !== null && _a68 !== void 0 ? _a68 : window.location.href);
19339
+ const url = new URL((_a66 = options === null || options === void 0 ? void 0 : options.url) !== null && _a66 !== void 0 ? _a66 : window.location.href);
19445
19340
  const accounts = await resolvedWallet.request({
19446
19341
  method: "eth_requestAccounts"
19447
19342
  }).then((accs) => accs).catch(() => {
@@ -19451,7 +19346,7 @@ var GoTrueClient = class _GoTrueClient {
19451
19346
  throw new Error(`@supabase/auth-js: No accounts available. Please ensure the wallet is connected.`);
19452
19347
  }
19453
19348
  const address = getAddress(accounts[0]);
19454
- let chainId = (_b4 = options === null || options === void 0 ? void 0 : options.signInWithEthereum) === null || _b4 === void 0 ? void 0 : _b4.chainId;
19349
+ let chainId = (_b3 = options === null || options === void 0 ? void 0 : options.signInWithEthereum) === null || _b3 === void 0 ? void 0 : _b3.chainId;
19455
19350
  if (!chainId) {
19456
19351
  const chainIdHex = await resolvedWallet.request({
19457
19352
  method: "eth_chainId"
@@ -19508,7 +19403,7 @@ var GoTrueClient = class _GoTrueClient {
19508
19403
  }
19509
19404
  }
19510
19405
  async signInWithSolana(credentials) {
19511
- var _a68, _b4, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
19406
+ var _a66, _b3, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
19512
19407
  let message;
19513
19408
  let signature;
19514
19409
  if ("message" in credentials) {
@@ -19532,7 +19427,7 @@ var GoTrueClient = class _GoTrueClient {
19532
19427
  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.`);
19533
19428
  }
19534
19429
  }
19535
- const url = new URL((_a68 = options === null || options === void 0 ? void 0 : options.url) !== null && _a68 !== void 0 ? _a68 : window.location.href);
19430
+ const url = new URL((_a66 = options === null || options === void 0 ? void 0 : options.url) !== null && _a66 !== void 0 ? _a66 : window.location.href);
19536
19431
  if ("signIn" in resolvedWallet && resolvedWallet.signIn) {
19537
19432
  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), {
19538
19433
  // non-overridable properties
@@ -19564,7 +19459,7 @@ var GoTrueClient = class _GoTrueClient {
19564
19459
  ...statement ? ["", statement, ""] : [""],
19565
19460
  "Version: 1",
19566
19461
  `URI: ${url.href}`,
19567
- `Issued At: ${(_c = (_b4 = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _b4 === void 0 ? void 0 : _b4.issuedAt) !== null && _c !== void 0 ? _c : (/* @__PURE__ */ new Date()).toISOString()}`,
19462
+ `Issued At: ${(_c = (_b3 = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _b3 === void 0 ? void 0 : _b3.issuedAt) !== null && _c !== void 0 ? _c : (/* @__PURE__ */ new Date()).toISOString()}`,
19568
19463
  ...((_d = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _d === void 0 ? void 0 : _d.notBefore) ? [`Not Before: ${options.signInWithSolana.notBefore}`] : [],
19569
19464
  ...((_e = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _e === void 0 ? void 0 : _e.expirationTime) ? [`Expiration Time: ${options.signInWithSolana.expirationTime}`] : [],
19570
19465
  ...((_f = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _f === void 0 ? void 0 : _f.chainId) ? [`Chain ID: ${options.signInWithSolana.chainId}`] : [],
@@ -19704,7 +19599,7 @@ var GoTrueClient = class _GoTrueClient {
19704
19599
  * This method supports PKCE when an email is passed.
19705
19600
  */
19706
19601
  async signInWithOtp(credentials) {
19707
- var _a68, _b4, _c, _d, _e;
19602
+ var _a66, _b3, _c, _d, _e;
19708
19603
  try {
19709
19604
  if ("email" in credentials) {
19710
19605
  const { email, options } = credentials;
@@ -19718,8 +19613,8 @@ var GoTrueClient = class _GoTrueClient {
19718
19613
  headers: this.headers,
19719
19614
  body: {
19720
19615
  email,
19721
- data: (_a68 = options === null || options === void 0 ? void 0 : options.data) !== null && _a68 !== void 0 ? _a68 : {},
19722
- create_user: (_b4 = options === null || options === void 0 ? void 0 : options.shouldCreateUser) !== null && _b4 !== void 0 ? _b4 : true,
19616
+ data: (_a66 = options === null || options === void 0 ? void 0 : options.data) !== null && _a66 !== void 0 ? _a66 : {},
19617
+ create_user: (_b3 = options === null || options === void 0 ? void 0 : options.shouldCreateUser) !== null && _b3 !== void 0 ? _b3 : true,
19723
19618
  gotrue_meta_security: { captcha_token: options === null || options === void 0 ? void 0 : options.captchaToken },
19724
19619
  code_challenge: codeChallenge,
19725
19620
  code_challenge_method: codeChallengeMethod
@@ -19758,13 +19653,13 @@ var GoTrueClient = class _GoTrueClient {
19758
19653
  * Log in a user given a User supplied OTP or TokenHash received through mobile or email.
19759
19654
  */
19760
19655
  async verifyOtp(params) {
19761
- var _a68, _b4;
19656
+ var _a66, _b3;
19762
19657
  try {
19763
19658
  let redirectTo = void 0;
19764
19659
  let captchaToken = void 0;
19765
19660
  if ("options" in params) {
19766
- redirectTo = (_a68 = params.options) === null || _a68 === void 0 ? void 0 : _a68.redirectTo;
19767
- captchaToken = (_b4 = params.options) === null || _b4 === void 0 ? void 0 : _b4.captchaToken;
19661
+ redirectTo = (_a66 = params.options) === null || _a66 === void 0 ? void 0 : _a66.redirectTo;
19662
+ captchaToken = (_b3 = params.options) === null || _b3 === void 0 ? void 0 : _b3.captchaToken;
19768
19663
  }
19769
19664
  const { data, error } = await _request(this.fetch, "POST", `${this.url}/verify`, {
19770
19665
  headers: this.headers,
@@ -19808,7 +19703,7 @@ var GoTrueClient = class _GoTrueClient {
19808
19703
  * organization's SSO Identity Provider UUID directly instead.
19809
19704
  */
19810
19705
  async signInWithSSO(params) {
19811
- var _a68, _b4, _c, _d, _e;
19706
+ var _a66, _b3, _c, _d, _e;
19812
19707
  try {
19813
19708
  let codeChallenge = null;
19814
19709
  let codeChallengeMethod = null;
@@ -19817,7 +19712,7 @@ var GoTrueClient = class _GoTrueClient {
19817
19712
  [codeChallenge, codeChallengeMethod] = await getCodeChallengeAndMethod(this.storage, this.storageKey);
19818
19713
  }
19819
19714
  const result = await _request(this.fetch, "POST", `${this.url}/sso`, {
19820
- 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: (_b4 = (_a68 = params.options) === null || _a68 === void 0 ? void 0 : _a68.redirectTo) !== null && _b4 !== void 0 ? _b4 : 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 }),
19715
+ 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: (_b3 = (_a66 = params.options) === null || _a66 === void 0 ? void 0 : _a66.redirectTo) !== null && _b3 !== void 0 ? _b3 : 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 }),
19821
19716
  headers: this.headers,
19822
19717
  xform: _ssoResponse
19823
19718
  });
@@ -20071,17 +19966,17 @@ var GoTrueClient = class _GoTrueClient {
20071
19966
  });
20072
19967
  }
20073
19968
  return await this._useSession(async (result) => {
20074
- var _a68, _b4, _c;
19969
+ var _a66, _b3, _c;
20075
19970
  const { data, error } = result;
20076
19971
  if (error) {
20077
19972
  throw error;
20078
19973
  }
20079
- if (!((_a68 = data.session) === null || _a68 === void 0 ? void 0 : _a68.access_token) && !this.hasCustomAuthorizationHeader) {
19974
+ if (!((_a66 = data.session) === null || _a66 === void 0 ? void 0 : _a66.access_token) && !this.hasCustomAuthorizationHeader) {
20080
19975
  return { data: { user: null }, error: new AuthSessionMissingError() };
20081
19976
  }
20082
19977
  return await _request(this.fetch, "GET", `${this.url}/user`, {
20083
19978
  headers: this.headers,
20084
- jwt: (_c = (_b4 = data.session) === null || _b4 === void 0 ? void 0 : _b4.access_token) !== null && _c !== void 0 ? _c : void 0,
19979
+ jwt: (_c = (_b3 = data.session) === null || _b3 === void 0 ? void 0 : _b3.access_token) !== null && _c !== void 0 ? _c : void 0,
20085
19980
  xform: _userResponse
20086
19981
  });
20087
19982
  });
@@ -20218,13 +20113,13 @@ var GoTrueClient = class _GoTrueClient {
20218
20113
  async _refreshSession(currentSession) {
20219
20114
  try {
20220
20115
  return await this._useSession(async (result) => {
20221
- var _a68;
20116
+ var _a66;
20222
20117
  if (!currentSession) {
20223
20118
  const { data, error: error2 } = result;
20224
20119
  if (error2) {
20225
20120
  throw error2;
20226
20121
  }
20227
- currentSession = (_a68 = data.session) !== null && _a68 !== void 0 ? _a68 : void 0;
20122
+ currentSession = (_a66 = data.session) !== null && _a66 !== void 0 ? _a66 : void 0;
20228
20123
  }
20229
20124
  if (!(currentSession === null || currentSession === void 0 ? void 0 : currentSession.refresh_token)) {
20230
20125
  throw new AuthSessionMissingError();
@@ -20362,12 +20257,12 @@ var GoTrueClient = class _GoTrueClient {
20362
20257
  }
20363
20258
  async _signOut({ scope } = { scope: "global" }) {
20364
20259
  return await this._useSession(async (result) => {
20365
- var _a68;
20260
+ var _a66;
20366
20261
  const { data, error: sessionError } = result;
20367
20262
  if (sessionError && !isAuthSessionMissingError(sessionError)) {
20368
20263
  return this._returnResult({ error: sessionError });
20369
20264
  }
20370
- const accessToken = (_a68 = data.session) === null || _a68 === void 0 ? void 0 : _a68.access_token;
20265
+ const accessToken = (_a66 = data.session) === null || _a66 === void 0 ? void 0 : _a66.access_token;
20371
20266
  if (accessToken) {
20372
20267
  const { error } = await this.admin.signOut(accessToken, scope);
20373
20268
  if (error) {
@@ -20405,15 +20300,15 @@ var GoTrueClient = class _GoTrueClient {
20405
20300
  }
20406
20301
  async _emitInitialSession(id) {
20407
20302
  return await this._useSession(async (result) => {
20408
- var _a68, _b4;
20303
+ var _a66, _b3;
20409
20304
  try {
20410
20305
  const { data: { session }, error } = result;
20411
20306
  if (error)
20412
20307
  throw error;
20413
- await ((_a68 = this.stateChangeEmitters.get(id)) === null || _a68 === void 0 ? void 0 : _a68.callback("INITIAL_SESSION", session));
20308
+ await ((_a66 = this.stateChangeEmitters.get(id)) === null || _a66 === void 0 ? void 0 : _a66.callback("INITIAL_SESSION", session));
20414
20309
  this._debug("INITIAL_SESSION", "callback id", id, "session", session);
20415
20310
  } catch (err) {
20416
- await ((_b4 = this.stateChangeEmitters.get(id)) === null || _b4 === void 0 ? void 0 : _b4.callback("INITIAL_SESSION", null));
20311
+ await ((_b3 = this.stateChangeEmitters.get(id)) === null || _b3 === void 0 ? void 0 : _b3.callback("INITIAL_SESSION", null));
20417
20312
  this._debug("INITIAL_SESSION", "callback id", id, "error", err);
20418
20313
  console.error(err);
20419
20314
  }
@@ -20461,12 +20356,12 @@ var GoTrueClient = class _GoTrueClient {
20461
20356
  * Gets all the identities linked to a user.
20462
20357
  */
20463
20358
  async getUserIdentities() {
20464
- var _a68;
20359
+ var _a66;
20465
20360
  try {
20466
20361
  const { data, error } = await this.getUser();
20467
20362
  if (error)
20468
20363
  throw error;
20469
- return this._returnResult({ data: { identities: (_a68 = data.user.identities) !== null && _a68 !== void 0 ? _a68 : [] }, error: null });
20364
+ return this._returnResult({ data: { identities: (_a66 = data.user.identities) !== null && _a66 !== void 0 ? _a66 : [] }, error: null });
20470
20365
  } catch (error) {
20471
20366
  if (isAuthError(error)) {
20472
20367
  return this._returnResult({ data: null, error });
@@ -20481,16 +20376,16 @@ var GoTrueClient = class _GoTrueClient {
20481
20376
  return this.linkIdentityOAuth(credentials);
20482
20377
  }
20483
20378
  async linkIdentityOAuth(credentials) {
20484
- var _a68;
20379
+ var _a66;
20485
20380
  try {
20486
20381
  const { data, error } = await this._useSession(async (result) => {
20487
- var _a69, _b4, _c, _d, _e;
20382
+ var _a67, _b3, _c, _d, _e;
20488
20383
  const { data: data2, error: error2 } = result;
20489
20384
  if (error2)
20490
20385
  throw error2;
20491
20386
  const url = await this._getUrlForProvider(`${this.url}/user/identities/authorize`, credentials.provider, {
20492
- redirectTo: (_a69 = credentials.options) === null || _a69 === void 0 ? void 0 : _a69.redirectTo,
20493
- scopes: (_b4 = credentials.options) === null || _b4 === void 0 ? void 0 : _b4.scopes,
20387
+ redirectTo: (_a67 = credentials.options) === null || _a67 === void 0 ? void 0 : _a67.redirectTo,
20388
+ scopes: (_b3 = credentials.options) === null || _b3 === void 0 ? void 0 : _b3.scopes,
20494
20389
  queryParams: (_c = credentials.options) === null || _c === void 0 ? void 0 : _c.queryParams,
20495
20390
  skipBrowserRedirect: true
20496
20391
  });
@@ -20501,7 +20396,7 @@ var GoTrueClient = class _GoTrueClient {
20501
20396
  });
20502
20397
  if (error)
20503
20398
  throw error;
20504
- if (isBrowser() && !((_a68 = credentials.options) === null || _a68 === void 0 ? void 0 : _a68.skipBrowserRedirect)) {
20399
+ if (isBrowser() && !((_a66 = credentials.options) === null || _a66 === void 0 ? void 0 : _a66.skipBrowserRedirect)) {
20505
20400
  window.location.assign(data === null || data === void 0 ? void 0 : data.url);
20506
20401
  }
20507
20402
  return this._returnResult({
@@ -20517,7 +20412,7 @@ var GoTrueClient = class _GoTrueClient {
20517
20412
  }
20518
20413
  async linkIdentityIdToken(credentials) {
20519
20414
  return await this._useSession(async (result) => {
20520
- var _a68;
20415
+ var _a66;
20521
20416
  try {
20522
20417
  const { error: sessionError, data: { session } } = result;
20523
20418
  if (sessionError)
@@ -20525,7 +20420,7 @@ var GoTrueClient = class _GoTrueClient {
20525
20420
  const { options, provider, token, access_token, nonce } = credentials;
20526
20421
  const res = await _request(this.fetch, "POST", `${this.url}/token?grant_type=id_token`, {
20527
20422
  headers: this.headers,
20528
- jwt: (_a68 = session === null || session === void 0 ? void 0 : session.access_token) !== null && _a68 !== void 0 ? _a68 : void 0,
20423
+ jwt: (_a66 = session === null || session === void 0 ? void 0 : session.access_token) !== null && _a66 !== void 0 ? _a66 : void 0,
20529
20424
  body: {
20530
20425
  provider,
20531
20426
  id_token: token,
@@ -20565,14 +20460,14 @@ var GoTrueClient = class _GoTrueClient {
20565
20460
  async unlinkIdentity(identity) {
20566
20461
  try {
20567
20462
  return await this._useSession(async (result) => {
20568
- var _a68, _b4;
20463
+ var _a66, _b3;
20569
20464
  const { data, error } = result;
20570
20465
  if (error) {
20571
20466
  throw error;
20572
20467
  }
20573
20468
  return await _request(this.fetch, "DELETE", `${this.url}/user/identities/${identity.identity_id}`, {
20574
20469
  headers: this.headers,
20575
- jwt: (_b4 = (_a68 = data.session) === null || _a68 === void 0 ? void 0 : _a68.access_token) !== null && _b4 !== void 0 ? _b4 : void 0
20470
+ jwt: (_b3 = (_a66 = data.session) === null || _a66 === void 0 ? void 0 : _a66.access_token) !== null && _b3 !== void 0 ? _b3 : void 0
20576
20471
  });
20577
20472
  });
20578
20473
  } catch (error) {
@@ -20637,7 +20532,7 @@ var GoTrueClient = class _GoTrueClient {
20637
20532
  * Note: this method is async to accommodate for AsyncStorage e.g. in React native.
20638
20533
  */
20639
20534
  async _recoverAndRefresh() {
20640
- var _a68, _b4;
20535
+ var _a66, _b3;
20641
20536
  const debugName = "#_recoverAndRefresh()";
20642
20537
  this._debug(debugName, "begin");
20643
20538
  try {
@@ -20648,7 +20543,7 @@ var GoTrueClient = class _GoTrueClient {
20648
20543
  maybeUser = { user: currentSession.user };
20649
20544
  await setItemAsync(this.userStorage, this.storageKey + "-user", maybeUser);
20650
20545
  }
20651
- currentSession.user = (_a68 = maybeUser === null || maybeUser === void 0 ? void 0 : maybeUser.user) !== null && _a68 !== void 0 ? _a68 : userNotAvailableProxy();
20546
+ currentSession.user = (_a66 = maybeUser === null || maybeUser === void 0 ? void 0 : maybeUser.user) !== null && _a66 !== void 0 ? _a66 : userNotAvailableProxy();
20652
20547
  } else if (currentSession && !currentSession.user) {
20653
20548
  if (!currentSession.user) {
20654
20549
  const separateUser = await getItemAsync(this.storage, this.storageKey + "-user");
@@ -20669,7 +20564,7 @@ var GoTrueClient = class _GoTrueClient {
20669
20564
  }
20670
20565
  return;
20671
20566
  }
20672
- const expiresWithMargin = ((_b4 = currentSession.expires_at) !== null && _b4 !== void 0 ? _b4 : Infinity) * 1e3 - Date.now() < EXPIRY_MARGIN_MS;
20567
+ const expiresWithMargin = ((_b3 = currentSession.expires_at) !== null && _b3 !== void 0 ? _b3 : Infinity) * 1e3 - Date.now() < EXPIRY_MARGIN_MS;
20673
20568
  this._debug(debugName, `session has${expiresWithMargin ? "" : " not"} expired with margin of ${EXPIRY_MARGIN_MS}s`);
20674
20569
  if (expiresWithMargin) {
20675
20570
  if (this.autoRefreshToken && currentSession.refresh_token) {
@@ -20708,7 +20603,7 @@ var GoTrueClient = class _GoTrueClient {
20708
20603
  }
20709
20604
  }
20710
20605
  async _callRefreshToken(refreshToken) {
20711
- var _a68, _b4;
20606
+ var _a66, _b3;
20712
20607
  if (!refreshToken) {
20713
20608
  throw new AuthSessionMissingError();
20714
20609
  }
@@ -20736,10 +20631,10 @@ var GoTrueClient = class _GoTrueClient {
20736
20631
  if (!isAuthRetryableFetchError(error)) {
20737
20632
  await this._removeSession();
20738
20633
  }
20739
- (_a68 = this.refreshingDeferred) === null || _a68 === void 0 ? void 0 : _a68.resolve(result);
20634
+ (_a66 = this.refreshingDeferred) === null || _a66 === void 0 ? void 0 : _a66.resolve(result);
20740
20635
  return result;
20741
20636
  }
20742
- (_b4 = this.refreshingDeferred) === null || _b4 === void 0 ? void 0 : _b4.reject(error);
20637
+ (_b3 = this.refreshingDeferred) === null || _b3 === void 0 ? void 0 : _b3.reject(error);
20743
20638
  throw error;
20744
20639
  } finally {
20745
20640
  this.refreshingDeferred = null;
@@ -21031,14 +20926,14 @@ var GoTrueClient = class _GoTrueClient {
21031
20926
  async _unenroll(params) {
21032
20927
  try {
21033
20928
  return await this._useSession(async (result) => {
21034
- var _a68;
20929
+ var _a66;
21035
20930
  const { data: sessionData, error: sessionError } = result;
21036
20931
  if (sessionError) {
21037
20932
  return this._returnResult({ data: null, error: sessionError });
21038
20933
  }
21039
20934
  return await _request(this.fetch, "DELETE", `${this.url}/factors/${params.factorId}`, {
21040
20935
  headers: this.headers,
21041
- jwt: (_a68 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a68 === void 0 ? void 0 : _a68.access_token
20936
+ jwt: (_a66 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a66 === void 0 ? void 0 : _a66.access_token
21042
20937
  });
21043
20938
  });
21044
20939
  } catch (error) {
@@ -21051,7 +20946,7 @@ var GoTrueClient = class _GoTrueClient {
21051
20946
  async _enroll(params) {
21052
20947
  try {
21053
20948
  return await this._useSession(async (result) => {
21054
- var _a68, _b4;
20949
+ var _a66, _b3;
21055
20950
  const { data: sessionData, error: sessionError } = result;
21056
20951
  if (sessionError) {
21057
20952
  return this._returnResult({ data: null, error: sessionError });
@@ -21060,12 +20955,12 @@ var GoTrueClient = class _GoTrueClient {
21060
20955
  const { data, error } = await _request(this.fetch, "POST", `${this.url}/factors`, {
21061
20956
  body,
21062
20957
  headers: this.headers,
21063
- jwt: (_a68 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a68 === void 0 ? void 0 : _a68.access_token
20958
+ jwt: (_a66 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a66 === void 0 ? void 0 : _a66.access_token
21064
20959
  });
21065
20960
  if (error) {
21066
20961
  return this._returnResult({ data: null, error });
21067
20962
  }
21068
- if (params.factorType === "totp" && data.type === "totp" && ((_b4 = data === null || data === void 0 ? void 0 : data.totp) === null || _b4 === void 0 ? void 0 : _b4.qr_code)) {
20963
+ if (params.factorType === "totp" && data.type === "totp" && ((_b3 = data === null || data === void 0 ? void 0 : data.totp) === null || _b3 === void 0 ? void 0 : _b3.qr_code)) {
21069
20964
  data.totp.qr_code = `data:image/svg+xml;utf-8,${data.totp.qr_code}`;
21070
20965
  }
21071
20966
  return this._returnResult({ data, error: null });
@@ -21081,7 +20976,7 @@ var GoTrueClient = class _GoTrueClient {
21081
20976
  return this._acquireLock(this.lockAcquireTimeout, async () => {
21082
20977
  try {
21083
20978
  return await this._useSession(async (result) => {
21084
- var _a68;
20979
+ var _a66;
21085
20980
  const { data: sessionData, error: sessionError } = result;
21086
20981
  if (sessionError) {
21087
20982
  return this._returnResult({ data: null, error: sessionError });
@@ -21092,7 +20987,7 @@ var GoTrueClient = class _GoTrueClient {
21092
20987
  const { data, error } = await _request(this.fetch, "POST", `${this.url}/factors/${params.factorId}/verify`, {
21093
20988
  body,
21094
20989
  headers: this.headers,
21095
- jwt: (_a68 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a68 === void 0 ? void 0 : _a68.access_token
20990
+ jwt: (_a66 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a66 === void 0 ? void 0 : _a66.access_token
21096
20991
  });
21097
20992
  if (error) {
21098
20993
  return this._returnResult({ data: null, error });
@@ -21113,7 +21008,7 @@ var GoTrueClient = class _GoTrueClient {
21113
21008
  return this._acquireLock(this.lockAcquireTimeout, async () => {
21114
21009
  try {
21115
21010
  return await this._useSession(async (result) => {
21116
- var _a68;
21011
+ var _a66;
21117
21012
  const { data: sessionData, error: sessionError } = result;
21118
21013
  if (sessionError) {
21119
21014
  return this._returnResult({ data: null, error: sessionError });
@@ -21121,7 +21016,7 @@ var GoTrueClient = class _GoTrueClient {
21121
21016
  const response = await _request(this.fetch, "POST", `${this.url}/factors/${params.factorId}/challenge`, {
21122
21017
  body: params,
21123
21018
  headers: this.headers,
21124
- jwt: (_a68 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a68 === void 0 ? void 0 : _a68.access_token
21019
+ jwt: (_a66 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a66 === void 0 ? void 0 : _a66.access_token
21125
21020
  });
21126
21021
  if (response.error) {
21127
21022
  return response;
@@ -21171,7 +21066,7 @@ var GoTrueClient = class _GoTrueClient {
21171
21066
  * {@see GoTrueMFAApi#listFactors}
21172
21067
  */
21173
21068
  async _listFactors() {
21174
- var _a68;
21069
+ var _a66;
21175
21070
  const { data: { user }, error: userError } = await this.getUser();
21176
21071
  if (userError) {
21177
21072
  return { data: null, error: userError };
@@ -21182,7 +21077,7 @@ var GoTrueClient = class _GoTrueClient {
21182
21077
  totp: [],
21183
21078
  webauthn: []
21184
21079
  };
21185
- for (const factor of (_a68 = user === null || user === void 0 ? void 0 : user.factors) !== null && _a68 !== void 0 ? _a68 : []) {
21080
+ for (const factor of (_a66 = user === null || user === void 0 ? void 0 : user.factors) !== null && _a66 !== void 0 ? _a66 : []) {
21186
21081
  data.all.push(factor);
21187
21082
  if (factor.status === "verified") {
21188
21083
  ;
@@ -21198,7 +21093,7 @@ var GoTrueClient = class _GoTrueClient {
21198
21093
  * {@see GoTrueMFAApi#getAuthenticatorAssuranceLevel}
21199
21094
  */
21200
21095
  async _getAuthenticatorAssuranceLevel(jwt) {
21201
- var _a68, _b4, _c, _d;
21096
+ var _a66, _b3, _c, _d;
21202
21097
  if (jwt) {
21203
21098
  try {
21204
21099
  const { payload: payload2 } = decodeJWT(jwt);
@@ -21211,7 +21106,7 @@ var GoTrueClient = class _GoTrueClient {
21211
21106
  if (userError) {
21212
21107
  return this._returnResult({ data: null, error: userError });
21213
21108
  }
21214
- const verifiedFactors2 = (_b4 = (_a68 = user === null || user === void 0 ? void 0 : user.factors) === null || _a68 === void 0 ? void 0 : _a68.filter((factor) => factor.status === "verified")) !== null && _b4 !== void 0 ? _b4 : [];
21109
+ const verifiedFactors2 = (_b3 = (_a66 = user === null || user === void 0 ? void 0 : user.factors) === null || _a66 === void 0 ? void 0 : _a66.filter((factor) => factor.status === "verified")) !== null && _b3 !== void 0 ? _b3 : [];
21215
21110
  if (verifiedFactors2.length > 0) {
21216
21111
  nextLevel2 = "aal2";
21217
21112
  }
@@ -21848,10 +21743,10 @@ if (shouldShowDeprecationWarning()) console.warn("\u26A0\uFE0F Node.js 18 and b
21848
21743
  var cachedStargate = null;
21849
21744
  var cachedPublic = null;
21850
21745
  function getSupabase() {
21851
- var _a68;
21746
+ var _a66;
21852
21747
  if (cachedStargate) return cachedStargate;
21853
21748
  const url = getRuntimeEnv("VITE_SUPABASE_URL");
21854
- const anon = (_a68 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a68 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY");
21749
+ const anon = (_a66 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a66 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY");
21855
21750
  const schema = getRuntimeEnvOr("VITE_SUPABASE_SCHEMA", "public");
21856
21751
  if (!url || !anon) {
21857
21752
  return null;
@@ -21866,10 +21761,10 @@ function getSupabase() {
21866
21761
  return cachedStargate;
21867
21762
  }
21868
21763
  function getSupabasePublic() {
21869
- var _a68;
21764
+ var _a66;
21870
21765
  if (cachedPublic) return cachedPublic;
21871
21766
  const url = getRuntimeEnv("VITE_SUPABASE_URL");
21872
- const anon = (_a68 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a68 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY");
21767
+ const anon = (_a66 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a66 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY");
21873
21768
  if (!url || !anon) {
21874
21769
  return null;
21875
21770
  }
@@ -22420,11 +22315,11 @@ var ignoreLoopbackUrlOnPublicOrigin = (value) => {
22420
22315
  return isLoopbackUrl(value) ? void 0 : value;
22421
22316
  };
22422
22317
  var getAppsApiBaseUrl = () => {
22423
- var _a68, _b4;
22318
+ var _a66, _b3;
22424
22319
  return normalizeBaseUrl2(
22425
- (_b4 = ignoreLoopbackUrlOnPublicOrigin(
22426
- (_a68 = getRuntimeEnv("VITE_APPS_API_BASE_URL")) != null ? _a68 : getRuntimeEnv("VITE_APPS_API_BASE")
22427
- )) != null ? _b4 : isLocalBrowserOrigin() ? "http://localhost:8787" : "https://api.apps.cupcode.com.br"
22320
+ (_b3 = ignoreLoopbackUrlOnPublicOrigin(
22321
+ (_a66 = getRuntimeEnv("VITE_APPS_API_BASE_URL")) != null ? _a66 : getRuntimeEnv("VITE_APPS_API_BASE")
22322
+ )) != null ? _b3 : isLocalBrowserOrigin() ? "http://localhost:8787" : "https://api.apps.cupcode.com.br"
22428
22323
  );
22429
22324
  };
22430
22325
  var isLocalBrowserOrigin = () => {
@@ -22456,9 +22351,9 @@ var fetchWithTimeout = async (input, init, timeoutMs = AUTH_REQUEST_TIMEOUT_MS)
22456
22351
  }
22457
22352
  };
22458
22353
  var getAccountsConfig = () => {
22459
- var _a68, _b4;
22354
+ var _a66, _b3;
22460
22355
  const baseUrl = normalizeBaseUrl2(
22461
- (_a68 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a68 : "https://accounts.cupcode.com.br"
22356
+ (_a66 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a66 : "https://accounts.cupcode.com.br"
22462
22357
  );
22463
22358
  const clientId = getRuntimeEnv("VITE_ACCOUNTS_CLIENT_ID");
22464
22359
  if (!clientId) {
@@ -22472,7 +22367,7 @@ var getAccountsConfig = () => {
22472
22367
  baseUrl,
22473
22368
  clientId,
22474
22369
  redirectUri,
22475
- scope: (_b4 = getRuntimeEnv("VITE_ACCOUNTS_SCOPE")) != null ? _b4 : "openid profile email",
22370
+ scope: (_b3 = getRuntimeEnv("VITE_ACCOUNTS_SCOPE")) != null ? _b3 : "openid profile email",
22476
22371
  audience: getRuntimeEnv("VITE_ACCOUNTS_AUDIENCE"),
22477
22372
  authUrl: getRuntimeEnv("VITE_ACCOUNTS_AUTH_URL"),
22478
22373
  tokenUrl: runtimeTokenUrl != null ? runtimeTokenUrl : `${getAppsApiBaseUrl()}/api/accounts/oidc-token`,
@@ -22482,7 +22377,7 @@ var getAccountsConfig = () => {
22482
22377
  };
22483
22378
  var cachedDiscovery = null;
22484
22379
  var resolveOidcEndpoints = async (config) => {
22485
- var _a68, _b4, _c, _d, _e, _f;
22380
+ var _a66, _b3, _c, _d, _e, _f;
22486
22381
  if (config.authUrl && config.tokenUrl) {
22487
22382
  return {
22488
22383
  authUrl: config.authUrl,
@@ -22492,8 +22387,8 @@ var resolveOidcEndpoints = async (config) => {
22492
22387
  }
22493
22388
  if (cachedDiscovery) {
22494
22389
  return {
22495
- authUrl: (_a68 = cachedDiscovery.authorization_endpoint) != null ? _a68 : config.authUrl,
22496
- tokenUrl: (_b4 = cachedDiscovery.token_endpoint) != null ? _b4 : config.tokenUrl,
22390
+ authUrl: (_a66 = cachedDiscovery.authorization_endpoint) != null ? _a66 : config.authUrl,
22391
+ tokenUrl: (_b3 = cachedDiscovery.token_endpoint) != null ? _b3 : config.tokenUrl,
22497
22392
  logoutUrl: (_c = cachedDiscovery.end_session_endpoint) != null ? _c : config.logoutUrl
22498
22393
  };
22499
22394
  }
@@ -22673,10 +22568,10 @@ var resolveLocalTelescupRedirectUri = () => {
22673
22568
  return `${window.location.protocol}//localhost:${port}/oidc/callback`;
22674
22569
  };
22675
22570
  var readStorageItem = (key) => {
22676
- var _a68;
22571
+ var _a66;
22677
22572
  if (!canUseWindow()) return null;
22678
22573
  try {
22679
- return (_a68 = window.sessionStorage.getItem(key)) != null ? _a68 : window.localStorage.getItem(key);
22574
+ return (_a66 = window.sessionStorage.getItem(key)) != null ? _a66 : window.localStorage.getItem(key);
22680
22575
  } catch (e) {
22681
22576
  return null;
22682
22577
  }
@@ -22786,16 +22681,16 @@ var getPopupOrigin = () => {
22786
22681
  return window.location.origin;
22787
22682
  };
22788
22683
  var getTelescupAccountsConfig = () => {
22789
- var _a68, _b4, _c, _d, _e, _f, _g, _h, _i, _j, _k;
22684
+ var _a66, _b3, _c, _d, _e, _f, _g, _h, _i, _j, _k;
22790
22685
  const primary = getAccountsConfig();
22791
22686
  const runtimeRedirectUri = ignoreLoopbackUrlOnPublicOrigin2(
22792
- (_a68 = getRuntimeEnv("VITE_TELESCUP_ACCOUNTS_REDIRECT_URI")) != null ? _a68 : getRuntimeEnv("VITE_TELESCUP_OIDC_REDIRECT_URI")
22687
+ (_a66 = getRuntimeEnv("VITE_TELESCUP_ACCOUNTS_REDIRECT_URI")) != null ? _a66 : getRuntimeEnv("VITE_TELESCUP_OIDC_REDIRECT_URI")
22793
22688
  );
22794
22689
  const fallbackRedirectUri = canUseWindow() ? `${window.location.origin}/oidc/callback` : "http://localhost:8080/oidc/callback";
22795
22690
  const redirectUri = isLocalBrowserOrigin2() && runtimeRedirectUri && !runtimeRedirectUri.includes("localhost") ? resolveLocalTelescupRedirectUri() : runtimeRedirectUri != null ? runtimeRedirectUri : fallbackRedirectUri;
22796
22691
  return {
22797
22692
  ...primary,
22798
- baseUrl: (_b4 = getRuntimeEnv("VITE_TELESCUP_ACCOUNTS_BASE_URL")) != null ? _b4 : primary.baseUrl,
22693
+ baseUrl: (_b3 = getRuntimeEnv("VITE_TELESCUP_ACCOUNTS_BASE_URL")) != null ? _b3 : primary.baseUrl,
22799
22694
  clientId: (_d = (_c = getRuntimeEnv("VITE_TELESCUP_ACCOUNTS_CLIENT_ID")) != null ? _c : getRuntimeEnv("VITE_TELESCUP_OIDC_CLIENT_ID")) != null ? _d : "telescup-local",
22800
22695
  redirectUri,
22801
22696
  scope: (_f = (_e = getRuntimeEnv("VITE_TELESCUP_ACCOUNTS_SCOPE")) != null ? _e : getRuntimeEnv("VITE_TELESCUP_OIDC_SCOPE")) != null ? _f : "openid profile email offline_access",
@@ -22807,12 +22702,12 @@ var getTelescupAccountsConfig = () => {
22807
22702
  };
22808
22703
  };
22809
22704
  var buildTokenBundle = (tokens, config, previous) => {
22810
- var _a68, _b4, _c, _d, _e, _f;
22811
- const idToken = ((_a68 = tokens.id_token) == null ? void 0 : _a68.trim()) || (previous == null ? void 0 : previous.idToken) || "";
22705
+ var _a66, _b3, _c, _d, _e, _f;
22706
+ const idToken = ((_a66 = tokens.id_token) == null ? void 0 : _a66.trim()) || (previous == null ? void 0 : previous.idToken) || "";
22812
22707
  if (!idToken) {
22813
22708
  throw new Error("Token ID do Telescup n\xE3o retornado pelo Accounts.");
22814
22709
  }
22815
- const expiresAt2 = (_d = (_c = (_b4 = getTokenExpiryMs(idToken)) != null ? _b4 : getTokenExpiryMs(tokens.access_token)) != null ? _c : previous == null ? void 0 : previous.expiresAt) != null ? _d : Date.now() + 55 * 60 * 1e3;
22710
+ const expiresAt2 = (_d = (_c = (_b3 = getTokenExpiryMs(idToken)) != null ? _b3 : getTokenExpiryMs(tokens.access_token)) != null ? _c : previous == null ? void 0 : previous.expiresAt) != null ? _d : Date.now() + 55 * 60 * 1e3;
22816
22711
  return {
22817
22712
  idToken,
22818
22713
  accessToken: ((_e = tokens.access_token) == null ? void 0 : _e.trim()) || (previous == null ? void 0 : previous.accessToken),
@@ -22855,10 +22750,10 @@ var centerPopupFeatures = () => {
22855
22750
  return `popup,width=${width},height=${height},left=${left},top=${top},resizable=yes,scrollbars=yes`;
22856
22751
  };
22857
22752
  var notifyOpener = (result) => {
22858
- var _a68;
22753
+ var _a66;
22859
22754
  if (!canUseWindow()) return;
22860
22755
  try {
22861
- (_a68 = window.opener) == null ? void 0 : _a68.postMessage(result, getPopupOrigin());
22756
+ (_a66 = window.opener) == null ? void 0 : _a66.postMessage(result, getPopupOrigin());
22862
22757
  } catch (e) {
22863
22758
  }
22864
22759
  };
@@ -22967,7 +22862,7 @@ var ensureTelescupOidcToken = async () => {
22967
22862
  return pendingTokenPromise;
22968
22863
  };
22969
22864
  var completeTelescupOidcCallback = async () => {
22970
- var _a68;
22865
+ var _a66;
22971
22866
  if (!canUseWindow()) {
22972
22867
  return { ok: false, error: "Callback do Telescup indispon\xEDvel fora do navegador." };
22973
22868
  }
@@ -22996,7 +22891,7 @@ var completeTelescupOidcCallback = async () => {
22996
22891
  throw new Error("Token endpoint do Telescup n\xE3o encontrado.");
22997
22892
  }
22998
22893
  const tokens = await exchangeCodeForToken(config, tokenUrl, code, flow.verifier);
22999
- const nonce = String(((_a68 = decodeJwt(tokens.id_token)) == null ? void 0 : _a68.nonce) || "").trim();
22894
+ const nonce = String(((_a66 = decodeJwt(tokens.id_token)) == null ? void 0 : _a66.nonce) || "").trim();
23000
22895
  if (!nonce || nonce !== flow.nonce) {
23001
22896
  throw new Error("Nonce inv\xE1lido no callback do Telescup.");
23002
22897
  }
@@ -23128,20 +23023,23 @@ var CHAT_LOGS_CREATED_AT_COLUMN = ((_a49 = getRuntimeEnv("VITE_CHAT_LOGS_CREATED
23128
23023
  var CHAT_MESSAGE_HISTORY_LIMIT = 200;
23129
23024
  var CHAT_EDIT_WINDOW_MINUTES2 = 15;
23130
23025
  var CHAT_DELETED_PLACEHOLDER_TEXT2 = "Mensagem deletada";
23131
- var _a50, _b2;
23132
- var APPS_API_BASE_URL = ((_b2 = (_a50 = getRuntimeEnv("VITE_APPS_API_BASE_URL")) != null ? _a50 : getRuntimeEnv("VITE_APPS_API_BASE")) != null ? _b2 : "http://localhost:8787").trim().replace(/\/+$/, "");
23133
- var _a51;
23134
- var TELESCUP_BASE_URL = (_a51 = getRuntimeEnv("VITE_TELESCUP_BASE_URL")) == null ? void 0 : _a51.trim();
23135
- var TELESCUP_LOCAL_API_BASE_URL = `${APPS_API_BASE_URL}/api/telescup`;
23026
+ var resolveAppsApiBaseUrl = () => {
23027
+ var _a66, _b3;
23028
+ return ((_b3 = (_a66 = getRuntimeEnv("VITE_APPS_API_BASE_URL")) != null ? _a66 : getRuntimeEnv("VITE_APPS_API_BASE")) != null ? _b3 : "http://localhost:8787").trim().replace(/\/+$/, "");
23029
+ };
23030
+ var resolveTelescupBaseUrl = () => {
23031
+ var _a66;
23032
+ return ((_a66 = getRuntimeEnv("VITE_TELESCUP_BASE_URL")) == null ? void 0 : _a66.trim()) || `${resolveAppsApiBaseUrl()}/api/telescup`;
23033
+ };
23136
23034
  var ACCESS_TOKEN_STORAGE_KEY = "cc_access_token";
23035
+ var _a50;
23036
+ var ACCOUNTS_BASE_URL2 = ((_a50 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a50 : "https://accounts.cupcode.com.br").trim().replace(/\/+$/, "");
23037
+ var _a51;
23038
+ var MC_BASE_URL2 = ((_a51 = getRuntimeEnv("VITE_MC_BASE_URL")) != null ? _a51 : "https://mc.cupcode.com.br").trim().replace(/\/+$/, "");
23137
23039
  var _a52;
23138
- var ACCOUNTS_BASE_URL2 = ((_a52 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a52 : "https://accounts.cupcode.com.br").trim().replace(/\/+$/, "");
23040
+ var ACCOUNTS_LANGUAGE_ENDPOINT = (_a52 = getRuntimeEnv("VITE_ACCOUNTS_LANGUAGE_ENDPOINT")) == null ? void 0 : _a52.trim();
23139
23041
  var _a53;
23140
- var MC_BASE_URL2 = ((_a53 = getRuntimeEnv("VITE_MC_BASE_URL")) != null ? _a53 : "https://mc.cupcode.com.br").trim().replace(/\/+$/, "");
23141
- var _a54;
23142
- var ACCOUNTS_LANGUAGE_ENDPOINT = (_a54 = getRuntimeEnv("VITE_ACCOUNTS_LANGUAGE_ENDPOINT")) == null ? void 0 : _a54.trim();
23143
- var _a55;
23144
- var ACCOUNTS_ACTIVITY_ENDPOINT = (_a55 = getRuntimeEnv("VITE_ACCOUNTS_ACTIVITY_ENDPOINT")) == null ? void 0 : _a55.trim();
23042
+ var ACCOUNTS_ACTIVITY_ENDPOINT = (_a53 = getRuntimeEnv("VITE_ACCOUNTS_ACTIVITY_ENDPOINT")) == null ? void 0 : _a53.trim();
23145
23043
  var PRESENCE_STATUS_VALUES = [
23146
23044
  "online",
23147
23045
  "away",
@@ -23355,10 +23253,10 @@ var resolvePresenceStatusLabel = (snapshot, effectiveStatus, now = Date.now()) =
23355
23253
  return PRESENCE_STATUS_LABELS[effectiveStatus];
23356
23254
  };
23357
23255
  var readPresenceSnapshotFromRecord = (row) => {
23358
- var _a68, _b4, _c, _d;
23256
+ var _a66, _b3, _c, _d;
23359
23257
  if (!row) return null;
23360
- const status = normalizePresenceStatus((_a68 = row[USER_PRESENCE_STATUS_COLUMN]) != null ? _a68 : row.status);
23361
- const source = normalizePresenceSource((_b4 = row[USER_PRESENCE_SOURCE_COLUMN]) != null ? _b4 : row.status_source);
23258
+ const status = normalizePresenceStatus((_a66 = row[USER_PRESENCE_STATUS_COLUMN]) != null ? _a66 : row.status);
23259
+ const source = normalizePresenceSource((_b3 = row[USER_PRESENCE_SOURCE_COLUMN]) != null ? _b3 : row.status_source);
23362
23260
  const lastActiveAtMs = toTimestampMs((_d = (_c = row[USER_PRESENCE_LAST_ACTIVE_COLUMN]) != null ? _c : row.last_active_at) != null ? _d : row.updated_at);
23363
23261
  return { status, source, lastActiveAtMs };
23364
23262
  };
@@ -23391,25 +23289,25 @@ var resolveCurrentUserId = (user) => {
23391
23289
  return null;
23392
23290
  };
23393
23291
  var resolveUserIdFromClaims = (claims) => {
23394
- var _a68, _b4, _c, _d, _e;
23395
- return (_e = (_d = (_c = (_b4 = (_a68 = toStringOrUndefined(claims.sub)) != null ? _a68 : toStringOrUndefined(claims.user_id)) != null ? _b4 : toStringOrUndefined(claims.userId)) != null ? _c : toStringOrUndefined(claims.uid)) != null ? _d : toStringOrUndefined(claims.id)) != null ? _e : toStringOrUndefined(claims["https://cupcode.com/user_id"]);
23292
+ var _a66, _b3, _c, _d, _e;
23293
+ return (_e = (_d = (_c = (_b3 = (_a66 = toStringOrUndefined(claims.sub)) != null ? _a66 : toStringOrUndefined(claims.user_id)) != null ? _b3 : toStringOrUndefined(claims.userId)) != null ? _c : toStringOrUndefined(claims.uid)) != null ? _d : toStringOrUndefined(claims.id)) != null ? _e : toStringOrUndefined(claims["https://cupcode.com/user_id"]);
23396
23294
  };
23397
23295
  var resolveEmailFromClaims = (claims) => {
23398
- var _a68, _b4;
23399
- const candidate = (_b4 = (_a68 = toStringOrUndefined(claims.email)) != null ? _a68 : toStringOrUndefined(claims["https://cupcode.com/email"])) != null ? _b4 : toStringOrUndefined(claims.preferred_username);
23296
+ var _a66, _b3;
23297
+ const candidate = (_b3 = (_a66 = toStringOrUndefined(claims.email)) != null ? _a66 : toStringOrUndefined(claims["https://cupcode.com/email"])) != null ? _b3 : toStringOrUndefined(claims.preferred_username);
23400
23298
  if (!candidate || !candidate.includes("@")) return void 0;
23401
23299
  return candidate.toLowerCase();
23402
23300
  };
23403
23301
  var normalizeTenantId = (value) => {
23404
- var _a68;
23405
- const normalized = (_a68 = toStringOrUndefined(value)) == null ? void 0 : _a68.toLowerCase();
23302
+ var _a66;
23303
+ const normalized = (_a66 = toStringOrUndefined(value)) == null ? void 0 : _a66.toLowerCase();
23406
23304
  if (!normalized) return void 0;
23407
23305
  return normalized.replace(/^@/, "");
23408
23306
  };
23409
23307
  var resolveTenantIdFromClaims = (claims) => {
23410
- var _a68, _b4, _c, _d, _e, _f, _g, _h, _i, _j;
23308
+ var _a66, _b3, _c, _d, _e, _f, _g, _h, _i, _j;
23411
23309
  return normalizeTenantId(
23412
- (_j = (_i = (_h = (_g = (_f = (_e = (_d = (_c = (_b4 = (_a68 = toStringOrUndefined(claims.tenant_id)) != null ? _a68 : toStringOrUndefined(claims.tenantId)) != null ? _b4 : toStringOrUndefined(claims.tenant_slug)) != null ? _c : toStringOrUndefined(claims.tenantSlug)) != null ? _d : toStringOrUndefined(claims.company_slug)) != null ? _e : toStringOrUndefined(claims.companySlug)) != null ? _f : toStringOrUndefined(claims.company)) != null ? _g : toStringOrUndefined(claims.org_slug)) != null ? _h : toStringOrUndefined(claims.orgSlug)) != null ? _i : toStringOrUndefined(claims["https://cupcode.com/tenant_id"])) != null ? _j : toStringOrUndefined(claims["https://cupcode.com/tenant_slug"])
23310
+ (_j = (_i = (_h = (_g = (_f = (_e = (_d = (_c = (_b3 = (_a66 = toStringOrUndefined(claims.tenant_id)) != null ? _a66 : toStringOrUndefined(claims.tenantId)) != null ? _b3 : toStringOrUndefined(claims.tenant_slug)) != null ? _c : toStringOrUndefined(claims.tenantSlug)) != null ? _d : toStringOrUndefined(claims.company_slug)) != null ? _e : toStringOrUndefined(claims.companySlug)) != null ? _f : toStringOrUndefined(claims.company)) != null ? _g : toStringOrUndefined(claims.org_slug)) != null ? _h : toStringOrUndefined(claims.orgSlug)) != null ? _i : toStringOrUndefined(claims["https://cupcode.com/tenant_id"])) != null ? _j : toStringOrUndefined(claims["https://cupcode.com/tenant_slug"])
23413
23311
  );
23414
23312
  };
23415
23313
  var formatMessageTime = (rawTimestamp) => {
@@ -23422,8 +23320,8 @@ var resolveChatAvatarUrl = (value) => {
23422
23320
  return resolveTelescupImageURL(value, { width: 72, height: 72, fit: "cover", format: "avif", quality: 70 });
23423
23321
  };
23424
23322
  var resolveAvatarPreviewUrl = (asset, fallback) => {
23425
- var _a68, _b4, _c;
23426
- return (_c = (_b4 = (_a68 = resolveTelescupImageURL(asset == null ? void 0 : asset.thumb_url, { width: 300, height: 300, fit: "cover", format: "avif", quality: 80 })) != null ? _a68 : resolveTelescupImageURL(asset == null ? void 0 : asset.preview_url, { width: 300, height: 300, fit: "cover", format: "avif", quality: 80 })) != null ? _b4 : resolveTelescupImageURL(asset == null ? void 0 : asset.url, { width: 300, height: 300, fit: "cover", format: "avif", quality: 80 })) != null ? _c : resolveTelescupImageURL(fallback, { width: 300, height: 300, fit: "cover", format: "avif", quality: 80 });
23323
+ var _a66, _b3, _c;
23324
+ return (_c = (_b3 = (_a66 = resolveTelescupImageURL(asset == null ? void 0 : asset.thumb_url, { width: 300, height: 300, fit: "cover", format: "avif", quality: 80 })) != null ? _a66 : resolveTelescupImageURL(asset == null ? void 0 : asset.preview_url, { width: 300, height: 300, fit: "cover", format: "avif", quality: 80 })) != null ? _b3 : resolveTelescupImageURL(asset == null ? void 0 : asset.url, { width: 300, height: 300, fit: "cover", format: "avif", quality: 80 })) != null ? _c : resolveTelescupImageURL(fallback, { width: 300, height: 300, fit: "cover", format: "avif", quality: 80 });
23427
23325
  };
23428
23326
  var isGenericRecord = (value) => typeof value === "object" && value !== null;
23429
23327
  var buildExternalUrl = (baseUrl, target) => {
@@ -23477,8 +23375,8 @@ var parseRecentActivityItems = (payload) => {
23477
23375
  return [];
23478
23376
  };
23479
23377
  return toRows(payload).map((item, index) => {
23480
- var _a68, _b4, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
23481
- const id = (_b4 = (_a68 = toStringOrUndefined(item.id)) != null ? _a68 : toStringOrUndefined(item.event_id)) != null ? _b4 : `accounts-activity-${index}`;
23378
+ var _a66, _b3, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
23379
+ const id = (_b3 = (_a66 = toStringOrUndefined(item.id)) != null ? _a66 : toStringOrUndefined(item.event_id)) != null ? _b3 : `accounts-activity-${index}`;
23482
23380
  const title = (_e = (_d = (_c = toStringOrUndefined(item.title)) != null ? _c : toStringOrUndefined(item.action)) != null ? _d : toStringOrUndefined(item.event)) != null ? _e : toStringOrUndefined(item.type);
23483
23381
  if (!title) return null;
23484
23382
  const description = (_h = (_g = (_f = toStringOrUndefined(item.description)) != null ? _f : toStringOrUndefined(item.details)) != null ? _g : toStringOrUndefined(item.message)) != null ? _h : toStringOrUndefined(item.summary);
@@ -23561,9 +23459,9 @@ var dedupeAndSortReactions = (reactions) => {
23561
23459
  });
23562
23460
  };
23563
23461
  var getErrorText = (error) => {
23564
- var _a68, _b4, _c;
23462
+ var _a66, _b3, _c;
23565
23463
  const typed = error;
23566
- return `${(_a68 = typed == null ? void 0 : typed.message) != null ? _a68 : ""} ${(_b4 = typed == null ? void 0 : typed.details) != null ? _b4 : ""} ${(_c = typed == null ? void 0 : typed.hint) != null ? _c : ""}`.toLowerCase();
23464
+ return `${(_a66 = typed == null ? void 0 : typed.message) != null ? _a66 : ""} ${(_b3 = typed == null ? void 0 : typed.details) != null ? _b3 : ""} ${(_c = typed == null ? void 0 : typed.hint) != null ? _c : ""}`.toLowerCase();
23567
23465
  };
23568
23466
  var isMissingColumnError = (error, column) => {
23569
23467
  const normalized = getErrorText(error);
@@ -23589,13 +23487,13 @@ var isRecoverableLookupError = (error, relationName) => {
23589
23487
  return normalized.includes("schema cache") || normalized.includes("permission denied") || normalized.includes("does not exist") || normalized.includes("could not find");
23590
23488
  };
23591
23489
  var toChatMessage = (row, currentUserId) => {
23592
- var _a68, _b4, _c, _d, _e, _f;
23593
- const id = (_a68 = toStringOrUndefined(row[CHAT_MESSAGES_ID_COLUMN])) != null ? _a68 : `${toStringOrUndefined(row[CHAT_MESSAGES_SENDER_COLUMN])}-${toStringOrUndefined(row[CHAT_MESSAGES_RECIPIENT_COLUMN])}-${toStringOrUndefined(row[CHAT_MESSAGES_CREATED_AT_COLUMN])}`;
23490
+ var _a66, _b3, _c, _d, _e, _f;
23491
+ const id = (_a66 = toStringOrUndefined(row[CHAT_MESSAGES_ID_COLUMN])) != null ? _a66 : `${toStringOrUndefined(row[CHAT_MESSAGES_SENDER_COLUMN])}-${toStringOrUndefined(row[CHAT_MESSAGES_RECIPIENT_COLUMN])}-${toStringOrUndefined(row[CHAT_MESSAGES_CREATED_AT_COLUMN])}`;
23594
23492
  const senderId = toStringOrUndefined(row[CHAT_MESSAGES_SENDER_COLUMN]);
23595
23493
  const recipientId = toStringOrUndefined(row[CHAT_MESSAGES_RECIPIENT_COLUMN]);
23596
23494
  const text = toStringOrUndefined(row[CHAT_MESSAGES_TEXT_COLUMN]);
23597
23495
  const createdAt = toStringOrUndefined(row[CHAT_MESSAGES_CREATED_AT_COLUMN]);
23598
- const editedAt = (_b4 = toStringOrUndefined(row[CHAT_MESSAGES_EDITED_AT_COLUMN])) != null ? _b4 : null;
23496
+ const editedAt = (_b3 = toStringOrUndefined(row[CHAT_MESSAGES_EDITED_AT_COLUMN])) != null ? _b3 : null;
23599
23497
  const readAt = (_c = toStringOrUndefined(row[CHAT_MESSAGES_READ_AT_COLUMN])) != null ? _c : null;
23600
23498
  const replyToMessageId = (_d = toStringOrUndefined(row[CHAT_MESSAGES_REPLY_TO_COLUMN])) != null ? _d : null;
23601
23499
  const deletedAt = (_e = toStringOrUndefined(row[CHAT_MESSAGES_DELETED_AT_COLUMN])) != null ? _e : null;
@@ -23630,13 +23528,13 @@ var toChatReaction = (row) => {
23630
23528
  return { id, messageId, userId, emoji, createdAt };
23631
23529
  };
23632
23530
  var toChatMessageLog = (row, messagesById) => {
23633
- var _a68, _b4;
23531
+ var _a66, _b3;
23634
23532
  const id = toStringOrUndefined(row[CHAT_LOGS_ID_COLUMN]);
23635
23533
  const messageId = toStringOrUndefined(row[CHAT_LOGS_MESSAGE_ID_COLUMN]);
23636
23534
  const actorId = toStringOrUndefined(row[CHAT_LOGS_ACTOR_ID_COLUMN]);
23637
23535
  const action = toStringOrUndefined(row[CHAT_LOGS_ACTION_COLUMN]);
23638
- const previousText = (_a68 = toStringOrUndefined(row[CHAT_LOGS_PREVIOUS_TEXT_COLUMN])) != null ? _a68 : null;
23639
- const nextText = (_b4 = toStringOrUndefined(row[CHAT_LOGS_NEXT_TEXT_COLUMN])) != null ? _b4 : null;
23536
+ const previousText = (_a66 = toStringOrUndefined(row[CHAT_LOGS_PREVIOUS_TEXT_COLUMN])) != null ? _a66 : null;
23537
+ const nextText = (_b3 = toStringOrUndefined(row[CHAT_LOGS_NEXT_TEXT_COLUMN])) != null ? _b3 : null;
23640
23538
  const createdAt = toStringOrUndefined(row[CHAT_LOGS_CREATED_AT_COLUMN]);
23641
23539
  if (!id || !messageId || !action || action !== "edit" && action !== "delete") return null;
23642
23540
  const relatedMessage = messagesById.get(messageId);
@@ -23682,7 +23580,7 @@ var MainNavbar = ({
23682
23580
  getAccessToken,
23683
23581
  appVersion
23684
23582
  }) => {
23685
- var _a68, _b4, _c;
23583
+ var _a66, _b3, _c;
23686
23584
  const [chatUsers, setChatUsers] = useState14([]);
23687
23585
  const [chatMessages, setChatMessages] = useState14([]);
23688
23586
  const [chatMessageLogs, setChatMessageLogs] = useState14([]);
@@ -23715,21 +23613,21 @@ var MainNavbar = ({
23715
23613
  return "/";
23716
23614
  }, [pathname]);
23717
23615
  const currentUserId = useMemo10(() => {
23718
- var _a69;
23719
- return (_a69 = resolveCurrentUserId(authUser)) != null ? _a69 : tokenDerivedUserId;
23616
+ var _a67;
23617
+ return (_a67 = resolveCurrentUserId(authUser)) != null ? _a67 : tokenDerivedUserId;
23720
23618
  }, [authUser, tokenDerivedUserId]);
23721
23619
  const authEmail = useMemo10(
23722
23620
  () => {
23723
- var _a69, _b5;
23724
- return (_b5 = (_a69 = toStringOrUndefined(authUser == null ? void 0 : authUser.email)) == null ? void 0 : _a69.toLowerCase()) != null ? _b5 : tokenDerivedEmail;
23621
+ var _a67, _b4;
23622
+ return (_b4 = (_a67 = toStringOrUndefined(authUser == null ? void 0 : authUser.email)) == null ? void 0 : _a67.toLowerCase()) != null ? _b4 : tokenDerivedEmail;
23725
23623
  },
23726
23624
  [authUser == null ? void 0 : authUser.email, tokenDerivedEmail]
23727
23625
  );
23728
23626
  const resolvedTenantId = useMemo10(
23729
23627
  () => {
23730
- var _a69, _b5, _c2, _d, _e, _f;
23628
+ var _a67, _b4, _c2, _d, _e, _f;
23731
23629
  return normalizeTenantId(
23732
- (_f = (_e = (_d = (_c2 = (_b5 = (_a69 = authUser == null ? void 0 : authUser.tenantId) != null ? _a69 : authUser == null ? void 0 : authUser.tenantSlug) != null ? _b5 : authUser == null ? void 0 : authUser.tenant_id) != null ? _c2 : authUser == null ? void 0 : authUser.companySlug) != null ? _d : authUser == null ? void 0 : authUser.company) != null ? _e : authUser == null ? void 0 : authUser.orgSlug) != null ? _f : tokenDerivedTenantId
23630
+ (_f = (_e = (_d = (_c2 = (_b4 = (_a67 = authUser == null ? void 0 : authUser.tenantId) != null ? _a67 : authUser == null ? void 0 : authUser.tenantSlug) != null ? _b4 : authUser == null ? void 0 : authUser.tenant_id) != null ? _c2 : authUser == null ? void 0 : authUser.companySlug) != null ? _d : authUser == null ? void 0 : authUser.company) != null ? _e : authUser == null ? void 0 : authUser.orgSlug) != null ? _f : tokenDerivedTenantId
23733
23631
  );
23734
23632
  },
23735
23633
  [
@@ -23744,14 +23642,14 @@ var MainNavbar = ({
23744
23642
  );
23745
23643
  const isCupcodeTenant = resolvedTenantId === "cupcode-admin";
23746
23644
  const isChatSuperAdmin = useMemo10(() => {
23747
- var _a69, _b5;
23748
- const roleTokens = `${(_a69 = authUser == null ? void 0 : authUser.role) != null ? _a69 : ""} ${(_b5 = authUser == null ? void 0 : authUser.jobTitle) != null ? _b5 : ""}`.toLowerCase();
23645
+ var _a67, _b4;
23646
+ const roleTokens = `${(_a67 = authUser == null ? void 0 : authUser.role) != null ? _a67 : ""} ${(_b4 = authUser == null ? void 0 : authUser.jobTitle) != null ? _b4 : ""}`.toLowerCase();
23749
23647
  return roleTokens.includes("superadmin") || roleTokens.includes("super admin");
23750
23648
  }, [authUser == null ? void 0 : authUser.jobTitle, authUser == null ? void 0 : authUser.role]);
23751
23649
  const resolvedTelescupBaseUrl = useMemo10(() => {
23752
- return TELESCUP_BASE_URL || TELESCUP_LOCAL_API_BASE_URL;
23650
+ return resolveTelescupBaseUrl();
23753
23651
  }, []);
23754
- const resolvedProfileAvatarUrl = (_a68 = resolveAvatarPreviewUrl({ url: persistedProfileAvatarValue != null ? persistedProfileAvatarValue : authUser == null ? void 0 : authUser.picture })) != null ? _a68 : void 0;
23652
+ const resolvedProfileAvatarUrl = (_a66 = resolveAvatarPreviewUrl({ url: persistedProfileAvatarValue != null ? persistedProfileAvatarValue : authUser == null ? void 0 : authUser.picture })) != null ? _a66 : void 0;
23755
23653
  const effectiveCurrentUserId = resolvedSenderId != null ? resolvedSenderId : currentUserId;
23756
23654
  const hasStoredAccessToken = (() => {
23757
23655
  if (typeof window === "undefined") return false;
@@ -23790,7 +23688,7 @@ var MainNavbar = ({
23790
23688
  }
23791
23689
  let canceled = false;
23792
23690
  const resolveIdentityFromToken = async () => {
23793
- var _a69, _b5;
23691
+ var _a67, _b4;
23794
23692
  try {
23795
23693
  let token = null;
23796
23694
  if (typeof window !== "undefined") {
@@ -23811,9 +23709,9 @@ var MainNavbar = ({
23811
23709
  }
23812
23710
  return;
23813
23711
  }
23814
- const claims = (_a69 = decodeJwt(token)) != null ? _a69 : {};
23712
+ const claims = (_a67 = decodeJwt(token)) != null ? _a67 : {};
23815
23713
  if (canceled) return;
23816
- setTokenDerivedUserId((_b5 = resolveUserIdFromClaims(claims)) != null ? _b5 : null);
23714
+ setTokenDerivedUserId((_b4 = resolveUserIdFromClaims(claims)) != null ? _b4 : null);
23817
23715
  setTokenDerivedEmail(resolveEmailFromClaims(claims));
23818
23716
  setTokenDerivedTenantId(resolveTenantIdFromClaims(claims));
23819
23717
  } catch (error) {
@@ -23857,7 +23755,7 @@ var MainNavbar = ({
23857
23755
  );
23858
23756
  const warnings = [];
23859
23757
  const runLookup = async (kind, value, columns) => {
23860
- var _a69, _b5, _c2;
23758
+ var _a67, _b4, _c2;
23861
23759
  for (const tableName of CHAT_USERS_LOOKUP_TABLES) {
23862
23760
  for (const columnName of columns) {
23863
23761
  if (!columnName) continue;
@@ -23866,10 +23764,10 @@ var MainNavbar = ({
23866
23764
  const lookupError = response.error;
23867
23765
  if (lookupError) {
23868
23766
  if (isRecoverableLookupError(lookupError, tableName)) {
23869
- warnings.push(`${tableName}.${columnName}: ${(_a69 = lookupError.message) != null ? _a69 : "falha de lookup"}`);
23767
+ warnings.push(`${tableName}.${columnName}: ${(_a67 = lookupError.message) != null ? _a67 : "falha de lookup"}`);
23870
23768
  continue;
23871
23769
  }
23872
- warnings.push(`${tableName}.${columnName}: ${(_b5 = lookupError.message) != null ? _b5 : "falha de lookup"}`);
23770
+ warnings.push(`${tableName}.${columnName}: ${(_b4 = lookupError.message) != null ? _b4 : "falha de lookup"}`);
23873
23771
  continue;
23874
23772
  }
23875
23773
  const row2 = (_c2 = response.data) == null ? void 0 : _c2[0];
@@ -23918,7 +23816,7 @@ var MainNavbar = ({
23918
23816
  return sessionStorage.getItem(ACCESS_TOKEN_STORAGE_KEY);
23919
23817
  };
23920
23818
  const loadAccountsContext = async () => {
23921
- var _a69, _b5, _c2, _d, _e, _f, _g;
23819
+ var _a67, _b4, _c2, _d, _e, _f, _g;
23922
23820
  setIsAccountsActivityLoading(true);
23923
23821
  try {
23924
23822
  const token = await resolveAccountsToken();
@@ -23928,9 +23826,9 @@ var MainNavbar = ({
23928
23826
  }
23929
23827
  return;
23930
23828
  }
23931
- const claims = (_a69 = decodeJwt(token)) != null ? _a69 : {};
23829
+ const claims = (_a67 = decodeJwt(token)) != null ? _a67 : {};
23932
23830
  const languageFromToken = normalizeMenuLanguage(
23933
- (_d = (_c2 = (_b5 = claims.locale) != null ? _b5 : claims.lang) != null ? _c2 : claims.language) != null ? _d : claims["https://cupcode.com/locale"]
23831
+ (_d = (_c2 = (_b4 = claims.locale) != null ? _b4 : claims.lang) != null ? _c2 : claims.language) != null ? _d : claims["https://cupcode.com/locale"]
23934
23832
  );
23935
23833
  if (!canceled) {
23936
23834
  setAccountsLanguage(languageFromToken);
@@ -24019,11 +23917,11 @@ var MainNavbar = ({
24019
23917
  }
24020
23918
  let canceled = false;
24021
23919
  const loadChatData = async () => {
24022
- var _a69, _b5, _c2, _d, _e, _f, _g, _h, _i;
23920
+ var _a67, _b4, _c2, _d, _e, _f, _g, _h, _i;
24023
23921
  setIsChatLoading(true);
24024
23922
  setChatError(null);
24025
23923
  const fetchFirstAvailableTable = async (tableNames) => {
24026
- var _a70;
23924
+ var _a68;
24027
23925
  let lastError = null;
24028
23926
  for (const tableName of tableNames) {
24029
23927
  const response = await supabase.from(tableName).select("*");
@@ -24045,7 +23943,7 @@ var MainNavbar = ({
24045
23943
  }
24046
23944
  }
24047
23945
  return {
24048
- tableName: (_a70 = tableNames[0]) != null ? _a70 : null,
23946
+ tableName: (_a68 = tableNames[0]) != null ? _a68 : null,
24049
23947
  data: null,
24050
23948
  error: lastError
24051
23949
  };
@@ -24159,7 +24057,7 @@ var MainNavbar = ({
24159
24057
  console.warn("[chat] Falha ao carregar presen\xE7a:", presenceResponse.error.message);
24160
24058
  }
24161
24059
  } else {
24162
- (_a69 = presenceResponse.data) == null ? void 0 : _a69.forEach((row) => {
24060
+ (_a67 = presenceResponse.data) == null ? void 0 : _a67.forEach((row) => {
24163
24061
  const userId = readFirstRecordString(row, [USER_PRESENCE_USER_ID_COLUMN, "user_id", "id"]);
24164
24062
  if (!userId) return;
24165
24063
  const snapshot = readPresenceSnapshotFromRecord(row);
@@ -24178,7 +24076,7 @@ var MainNavbar = ({
24178
24076
  console.warn("[chat] Falha ao carregar profiles para enriquecimento:", profilesResponse.error.message);
24179
24077
  }
24180
24078
  } else {
24181
- (_b5 = profilesResponse.data) == null ? void 0 : _b5.forEach((row) => {
24079
+ (_b4 = profilesResponse.data) == null ? void 0 : _b4.forEach((row) => {
24182
24080
  const id = readFirstRecordString(row, [...CHAT_USERS_LOOKUP_ID_COLUMNS, "id", "user_id"]);
24183
24081
  const email = readFirstRecordString(row, [...CHAT_USERS_LOOKUP_EMAIL_COLUMNS, "email"]);
24184
24082
  if (id) profileById.set(id, row);
@@ -24206,13 +24104,13 @@ var MainNavbar = ({
24206
24104
  }
24207
24105
  } else {
24208
24106
  (_e = usersResponse.data) == null ? void 0 : _e.forEach((row) => {
24209
- var _a70, _b6, _c3, _d2, _e2, _f2, _g2, _h2, _i2;
24107
+ var _a68, _b5, _c3, _d2, _e2, _f2, _g2, _h2, _i2;
24210
24108
  const id = readFirstRecordString(row, [...CHAT_USERS_LOOKUP_ID_COLUMNS, "id", "user_id"]);
24211
24109
  if (!id || id === effectiveCurrentUserId) return;
24212
24110
  const rowEmail = readFirstRecordString(row, [...CHAT_USERS_LOOKUP_EMAIL_COLUMNS, "email"]);
24213
- const profile = (_a70 = profileById.get(id)) != null ? _a70 : rowEmail ? profileByEmail.get(rowEmail.toLowerCase()) : void 0;
24111
+ const profile = (_a68 = profileById.get(id)) != null ? _a68 : rowEmail ? profileByEmail.get(rowEmail.toLowerCase()) : void 0;
24214
24112
  const email = rowEmail != null ? rowEmail : readFirstRecordString(profile, [CHAT_USERS_UPDATE_EMAIL_COLUMN, CHAT_USERS_EMAIL_COLUMN, "email"]);
24215
- const rawUsername = (_b6 = readFirstRecordString(row, [CHAT_USERS_USERNAME_COLUMN, "username", "user_name"])) != null ? _b6 : readFirstRecordString(profile, [CHAT_USERS_USERNAME_COLUMN, "username", "user_name"]);
24113
+ const rawUsername = (_b5 = readFirstRecordString(row, [CHAT_USERS_USERNAME_COLUMN, "username", "user_name"])) != null ? _b5 : readFirstRecordString(profile, [CHAT_USERS_USERNAME_COLUMN, "username", "user_name"]);
24216
24114
  const username = buildHandle2(rawUsername, email);
24217
24115
  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"]);
24218
24116
  const name = resolveReadableUserLabel(rawName, rawUsername, email, id);
@@ -24232,7 +24130,7 @@ var MainNavbar = ({
24232
24130
  });
24233
24131
  }
24234
24132
  profileById.forEach((profile, id) => {
24235
- var _a70, _b6, _c3;
24133
+ var _a68, _b5, _c3;
24236
24134
  if (!id || id === effectiveCurrentUserId || usersMap.has(id)) return;
24237
24135
  const email = readFirstRecordString(profile, [CHAT_USERS_UPDATE_EMAIL_COLUMN, CHAT_USERS_EMAIL_COLUMN, "email"]);
24238
24136
  const rawUsername = readFirstRecordString(profile, [CHAT_USERS_USERNAME_COLUMN, "username", "user_name"]);
@@ -24246,7 +24144,7 @@ var MainNavbar = ({
24246
24144
  "avatar"
24247
24145
  ]);
24248
24146
  const roleLabel = readFirstRecordString(profile, [CHAT_USERS_ROLE_COLUMN, "job_title", "role"]);
24249
- const resolvedStatus = (_b6 = (_a70 = presenceMap.get(id)) != null ? _a70 : readPresenceStatusFromRecord(profile)) != null ? _b6 : "offline";
24147
+ const resolvedStatus = (_b5 = (_a68 = presenceMap.get(id)) != null ? _a68 : readPresenceStatusFromRecord(profile)) != null ? _b5 : "offline";
24250
24148
  usersMap.set(id, {
24251
24149
  id,
24252
24150
  name: resolveReadableUserLabel(rawName, rawUsername, email, id),
@@ -24259,7 +24157,7 @@ var MainNavbar = ({
24259
24157
  });
24260
24158
  });
24261
24159
  presenceMap.forEach((statusValue, id) => {
24262
- var _a70;
24160
+ var _a68;
24263
24161
  if (id === effectiveCurrentUserId || usersMap.has(id)) return;
24264
24162
  const profile = profileById.get(id);
24265
24163
  const email = readFirstRecordString(profile, [CHAT_USERS_UPDATE_EMAIL_COLUMN, CHAT_USERS_EMAIL_COLUMN, "email"]);
@@ -24282,7 +24180,7 @@ var MainNavbar = ({
24282
24180
  avatarUrl: resolveChatAvatarUrl(avatarValue),
24283
24181
  roleLabel,
24284
24182
  status: statusValue,
24285
- statusLabel: (_a70 = presenceStatusLabelMap.get(id)) != null ? _a70 : PRESENCE_STATUS_LABELS[statusValue]
24183
+ statusLabel: (_a68 = presenceStatusLabelMap.get(id)) != null ? _a68 : PRESENCE_STATUS_LABELS[statusValue]
24286
24184
  });
24287
24185
  });
24288
24186
  if (messageErrors.length > 0) {
@@ -24299,7 +24197,7 @@ var MainNavbar = ({
24299
24197
  );
24300
24198
  setChatMessages(resolvedMessages);
24301
24199
  resolvedMessages.forEach((message) => {
24302
- var _a70, _b6, _c3;
24200
+ var _a68, _b5, _c3;
24303
24201
  const contactId = message.contactId;
24304
24202
  if (!contactId || contactId === effectiveCurrentUserId || usersMap.has(contactId)) return;
24305
24203
  const profile = profileById.get(contactId);
@@ -24315,7 +24213,7 @@ var MainNavbar = ({
24315
24213
  "avatar"
24316
24214
  ]);
24317
24215
  const roleLabel = readFirstRecordString(profile, [CHAT_USERS_ROLE_COLUMN, "job_title", "role"]);
24318
- const resolvedStatus = (_b6 = (_a70 = presenceMap.get(contactId)) != null ? _a70 : readPresenceStatusFromRecord(profile)) != null ? _b6 : "offline";
24216
+ const resolvedStatus = (_b5 = (_a68 = presenceMap.get(contactId)) != null ? _a68 : readPresenceStatusFromRecord(profile)) != null ? _b5 : "offline";
24319
24217
  usersMap.set(contactId, {
24320
24218
  id: contactId,
24321
24219
  name: resolveReadableUserLabel(rawName, rawUsername, email, contactId),
@@ -24471,9 +24369,9 @@ var MainNavbar = ({
24471
24369
  table: USER_PRESENCE_TABLE
24472
24370
  },
24473
24371
  (payload) => {
24474
- var _a69, _b5;
24372
+ var _a67, _b4;
24475
24373
  const row = payload.new || payload.old;
24476
- const userId = toStringOrUndefined((_b5 = (_a69 = row[USER_PRESENCE_USER_ID_COLUMN]) != null ? _a69 : row.user_id) != null ? _b5 : row.id);
24374
+ const userId = toStringOrUndefined((_b4 = (_a67 = row[USER_PRESENCE_USER_ID_COLUMN]) != null ? _a67 : row.user_id) != null ? _b4 : row.id);
24477
24375
  if (!userId || userId === effectiveCurrentUserId) return;
24478
24376
  let nextStatus = "offline";
24479
24377
  let nextStatusLabel = PRESENCE_STATUS_LABELS.offline;
@@ -24547,10 +24445,10 @@ var MainNavbar = ({
24547
24445
  const chatUnreadByUser = useMemo10(() => {
24548
24446
  const counters = {};
24549
24447
  chatMessages.forEach((message) => {
24550
- var _a69;
24448
+ var _a67;
24551
24449
  if (message.sender !== "them") return;
24552
24450
  if (message.readAt) return;
24553
- counters[message.contactId] = ((_a69 = counters[message.contactId]) != null ? _a69 : 0) + 1;
24451
+ counters[message.contactId] = ((_a67 = counters[message.contactId]) != null ? _a67 : 0) + 1;
24554
24452
  });
24555
24453
  return counters;
24556
24454
  }, [chatMessages]);
@@ -24598,9 +24496,9 @@ var MainNavbar = ({
24598
24496
  }
24599
24497
  const persistedReadAtByMessageId = /* @__PURE__ */ new Map();
24600
24498
  (data != null ? data : []).forEach((row) => {
24601
- var _a69;
24499
+ var _a67;
24602
24500
  const messageId = toStringOrUndefined(row[CHAT_MESSAGES_ID_COLUMN]);
24603
- const persistedReadAt = (_a69 = toStringOrUndefined(row[CHAT_MESSAGES_READ_AT_COLUMN])) != null ? _a69 : readAt;
24501
+ const persistedReadAt = (_a67 = toStringOrUndefined(row[CHAT_MESSAGES_READ_AT_COLUMN])) != null ? _a67 : readAt;
24604
24502
  if (!messageId) return;
24605
24503
  persistedReadAtByMessageId.set(messageId, persistedReadAt);
24606
24504
  });
@@ -24769,8 +24667,8 @@ var MainNavbar = ({
24769
24667
  (current) => dedupeAndSortMessages(
24770
24668
  current.map(
24771
24669
  (message) => {
24772
- var _a69;
24773
- return message.id === messageId ? { ...message, text: previousText, editedAt: (_a69 = targetMessage.editedAt) != null ? _a69 : null } : message;
24670
+ var _a67;
24671
+ return message.id === messageId ? { ...message, text: previousText, editedAt: (_a67 = targetMessage.editedAt) != null ? _a67 : null } : message;
24774
24672
  }
24775
24673
  )
24776
24674
  )
@@ -24801,13 +24699,13 @@ var MainNavbar = ({
24801
24699
  (current) => dedupeAndSortMessages(
24802
24700
  current.map(
24803
24701
  (message) => {
24804
- var _a69;
24702
+ var _a67;
24805
24703
  return message.id === messageId ? {
24806
24704
  ...message,
24807
24705
  text: CHAT_DELETED_PLACEHOLDER_TEXT2,
24808
24706
  deletedAt,
24809
24707
  deletedBy: effectiveCurrentUserId,
24810
- editedAt: (_a69 = message.editedAt) != null ? _a69 : deletedAt
24708
+ editedAt: (_a67 = message.editedAt) != null ? _a67 : deletedAt
24811
24709
  } : message;
24812
24710
  }
24813
24711
  )
@@ -24983,7 +24881,7 @@ var MainNavbar = ({
24983
24881
  [effectiveCurrentUserId, updateChatFeatureFlags]
24984
24882
  );
24985
24883
  const items = useMemo10(() => {
24986
- var _a69;
24884
+ var _a67;
24987
24885
  if (!showNavItems) return [];
24988
24886
  const normalizedPathname = currentPathname === "" ? "/" : currentPathname;
24989
24887
  const navItems = getMainNavItems();
@@ -24993,7 +24891,7 @@ var MainNavbar = ({
24993
24891
  if (normalizedPathname.startsWith(`${href}/`)) return href.length;
24994
24892
  return -1;
24995
24893
  };
24996
- const bestMatchHref = (_a69 = navItems.filter((item) => !item.href.startsWith("#")).map((item) => ({ href: item.href, score: scoreRouteMatch(item.href) })).filter((candidate) => candidate.score >= 0).sort((left, right) => right.score - left.score)[0]) == null ? void 0 : _a69.href;
24894
+ const bestMatchHref = (_a67 = navItems.filter((item) => !item.href.startsWith("#")).map((item) => ({ href: item.href, score: scoreRouteMatch(item.href) })).filter((candidate) => candidate.score >= 0).sort((left, right) => right.score - left.score)[0]) == null ? void 0 : _a67.href;
24997
24895
  return navItems.map((item) => {
24998
24896
  const isAnchor = item.href.startsWith("#");
24999
24897
  const isActive = !isAnchor ? item.href === bestMatchHref : false;
@@ -25001,8 +24899,8 @@ var MainNavbar = ({
25001
24899
  ...item,
25002
24900
  isActive,
25003
24901
  onClick: isAnchor ? item.onClick : (event) => {
25004
- var _a70;
25005
- (_a70 = item.onClick) == null ? void 0 : _a70.call(item, event);
24902
+ var _a68;
24903
+ (_a68 = item.onClick) == null ? void 0 : _a68.call(item, event);
25006
24904
  if (!onNavigate || event.defaultPrevented) return;
25007
24905
  event.preventDefault();
25008
24906
  onNavigate(item.href);
@@ -25049,9 +24947,9 @@ var MainNavbar = ({
25049
24947
  window.open(`${MC_BASE_URL2}/tasks`, "_blank", "noopener,noreferrer");
25050
24948
  };
25051
24949
  const handleChatOpenUserProfile = useCallback7(({ userId }) => {
25052
- var _a69;
24950
+ var _a67;
25053
24951
  if (!userId || typeof window === "undefined") return;
25054
- const baseUrl = ((_a69 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a69 : "https://accounts.cupcode.com.br").replace(
24952
+ const baseUrl = ((_a67 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a67 : "https://accounts.cupcode.com.br").replace(
25055
24953
  /\/+$/,
25056
24954
  ""
25057
24955
  );
@@ -25118,121 +25016,54 @@ var MainNavbar = ({
25118
25016
  );
25119
25017
  const handleProfileAvatarChange = useCallback7(
25120
25018
  async ({ avatarId, avatarUrl }) => {
25121
- var _a69, _b5;
25122
- const normalizedAvatarId = (_a69 = parseAssetId(avatarId)) != null ? _a69 : parseAssetId(avatarUrl);
25019
+ var _a67, _b4, _c2, _d, _e;
25020
+ const normalizedAvatarId = (_a67 = parseAssetId(avatarId)) != null ? _a67 : parseAssetId(avatarUrl);
25123
25021
  if (!normalizedAvatarId) {
25124
25022
  throw new Error("ID da imagem inv\xE1lido.");
25125
25023
  }
25126
- const supabase = getSupabase();
25127
- if (!supabase) {
25024
+ const nextAvatarValue = avatarUrl || normalizedAvatarId;
25025
+ const token = await getTelescupAccessToken().catch(() => "");
25026
+ if (!resolvedTelescupBaseUrl || !token || typeof fetch === "undefined") {
25128
25027
  throw new Error("N\xE3o foi poss\xEDvel salvar sua nova imagem agora.");
25129
25028
  }
25130
- const updateTargets = [CHAT_USERS_UPDATE_TABLE];
25131
- const lookupTargets = Array.from(
25132
- new Set(
25133
- [CHAT_USERS_TABLE, CHAT_USERS_UPDATE_TABLE, "profiles", "users"].map((entry) => entry.trim()).filter((entry) => entry.length > 0)
25134
- )
25135
- );
25136
- const updateErrors = [];
25137
- const isRecoverableUpdateError = (error) => {
25138
- var _a70;
25139
- const message = ((_a70 = error.message) != null ? _a70 : "").toLowerCase();
25140
- 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");
25141
- };
25142
- const isRecoverableLookupError2 = (error) => {
25143
- var _a70;
25144
- const message = ((_a70 = error.message) != null ? _a70 : "").toLowerCase();
25145
- 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");
25146
- };
25147
- const isPermissionDeniedError = (error) => {
25148
- var _a70;
25149
- const message = ((_a70 = error.message) != null ? _a70 : "").toLowerCase();
25150
- return error.code === "42501" || message.includes("permission denied");
25151
- };
25152
- const updateAvatarByUserId = async (userId) => {
25153
- var _a70, _b6, _c2, _d, _e;
25154
- for (const tableName of updateTargets) {
25155
- 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);
25156
- if (!updateWithSelect.error) {
25157
- const rows = updateWithSelect.data;
25158
- const row = (_a70 = rows == null ? void 0 : rows[0]) != null ? _a70 : null;
25159
- if (row) {
25160
- return row;
25161
- }
25162
- continue;
25163
- }
25164
- const selectError = updateWithSelect.error;
25165
- if (isPermissionDeniedError(selectError)) {
25166
- const updateWithoutSelect = await supabase.from(tableName).update({ [CHAT_USERS_UPDATE_AVATAR_COLUMN]: normalizedAvatarId }).eq(CHAT_USERS_UPDATE_ID_COLUMN, userId);
25167
- if (!updateWithoutSelect.error) {
25168
- return {
25169
- [CHAT_USERS_UPDATE_ID_COLUMN]: userId,
25170
- [CHAT_USERS_UPDATE_AVATAR_COLUMN]: normalizedAvatarId
25171
- };
25172
- }
25173
- const withoutSelectError = updateWithoutSelect.error;
25174
- if (!isRecoverableUpdateError(withoutSelectError)) {
25175
- throw new Error(`Falha ao atualizar avatar em "${tableName}": ${withoutSelectError.message}`);
25176
- }
25177
- updateErrors.push(
25178
- `${tableName}: ${(_b6 = withoutSelectError.code) != null ? _b6 : "erro"} ${(_c2 = withoutSelectError.message) != null ? _c2 : "falha desconhecida"}`
25179
- );
25180
- continue;
25181
- }
25182
- if (!isRecoverableUpdateError(selectError)) {
25183
- throw new Error(`Falha ao atualizar avatar em "${tableName}": ${selectError.message}`);
25184
- }
25185
- updateErrors.push(`${tableName}: ${(_d = selectError.code) != null ? _d : "erro"} ${(_e = selectError.message) != null ? _e : "falha desconhecida"}`);
25186
- }
25187
- return null;
25188
- };
25189
- const resolveUserIdByEmail = async (emailValue) => {
25190
- var _a70;
25191
- let lastRecoverableError = null;
25192
- for (const tableName of lookupTargets) {
25193
- const { data, error } = await supabase.from(tableName).select(CHAT_USERS_UPDATE_ID_COLUMN).ilike(CHAT_USERS_UPDATE_EMAIL_COLUMN, emailValue).limit(1);
25194
- if (!error) {
25195
- const rows = data;
25196
- const resolvedId = toStringOrUndefined((_a70 = rows == null ? void 0 : rows[0]) == null ? void 0 : _a70[CHAT_USERS_UPDATE_ID_COLUMN]);
25197
- if (resolvedId) {
25198
- return resolvedId;
25199
- }
25200
- continue;
25201
- }
25202
- if (!isRecoverableLookupError2(error)) {
25203
- throw new Error(`Falha ao localizar usu\xE1rio em "${tableName}" por e-mail: ${error.message}`);
25204
- }
25205
- lastRecoverableError = error;
25206
- }
25207
- if (lastRecoverableError && isRuntimeDev()) {
25208
- console.warn("[chat] Falha ao buscar usu\xE1rio por e-mail para salvar avatar:", lastRecoverableError.message);
25209
- }
25210
- return null;
25211
- };
25212
- const currentCandidateId = resolvedSenderId != null ? resolvedSenderId : currentUserId;
25213
- let updatedRow = null;
25214
- let finalUserId = currentCandidateId != null ? currentCandidateId : null;
25215
- if (currentCandidateId) {
25216
- updatedRow = await updateAvatarByUserId(currentCandidateId);
25217
- }
25218
- if (!updatedRow && authEmail) {
25219
- const normalizedEmail = authEmail.toLowerCase();
25220
- const resolvedByEmailId = await resolveUserIdByEmail(normalizedEmail);
25221
- if (resolvedByEmailId) {
25222
- updatedRow = await updateAvatarByUserId(resolvedByEmailId);
25223
- finalUserId = resolvedByEmailId;
25224
- }
25225
- }
25226
- if (!updatedRow) {
25227
- throw new Error("N\xE3o foi poss\xEDvel salvar sua nova imagem agora.");
25029
+ const response = await fetch(buildExternalUrl(resolvedTelescupBaseUrl.replace(/\/+$/, ""), "/tenant-users-admin"), {
25030
+ method: "POST",
25031
+ headers: {
25032
+ Authorization: `Bearer ${token}`,
25033
+ "Content-Type": "application/json"
25034
+ },
25035
+ body: JSON.stringify({
25036
+ action: "update_self_avatar",
25037
+ avatar_id: normalizedAvatarId,
25038
+ avatar_url: nextAvatarValue
25039
+ })
25040
+ });
25041
+ if (!response.ok) {
25042
+ throw new Error(`Falha ao salvar avatar pela API: ${response.status}`);
25228
25043
  }
25044
+ const payload = await response.json().catch(() => null);
25045
+ const profile = payload == null ? void 0 : payload.profile;
25046
+ const finalUserId = (_d = (_c2 = (_b4 = toStringOrUndefined(profile == null ? void 0 : profile.user_id)) != null ? _b4 : toStringOrUndefined(profile == null ? void 0 : profile.id)) != null ? _c2 : resolvedSenderId) != null ? _d : currentUserId;
25229
25047
  if (finalUserId && finalUserId !== resolvedSenderId) {
25230
25048
  setResolvedSenderId(finalUserId);
25231
25049
  }
25232
- setPersistedProfileAvatarValue((_b5 = resolveAvatarPreviewUrl({ url: avatarUrl }, normalizedAvatarId)) != null ? _b5 : normalizedAvatarId);
25050
+ const nextAvatarPreview = (_e = resolveAvatarPreviewUrl({ url: avatarUrl }, normalizedAvatarId)) != null ? _e : normalizedAvatarId;
25051
+ setPersistedProfileAvatarValue(nextAvatarPreview);
25052
+ if (typeof window !== "undefined") {
25053
+ window.dispatchEvent(
25054
+ new CustomEvent("cupcode:profile-avatar-change", {
25055
+ detail: {
25056
+ avatarId: normalizedAvatarId,
25057
+ avatarUrl: nextAvatarPreview,
25058
+ rawAvatarUrl: nextAvatarValue,
25059
+ userId: finalUserId
25060
+ }
25061
+ })
25062
+ );
25063
+ }
25233
25064
  toast2.success("Nova imagem salva com sucesso");
25234
25065
  },
25235
- [authEmail, currentUserId, resolvedSenderId]
25066
+ [currentUserId, getTelescupAccessToken, resolvedSenderId, resolvedTelescupBaseUrl]
25236
25067
  );
25237
25068
  return /* @__PURE__ */ jsx41(Fragment6, { children: /* @__PURE__ */ jsx41(
25238
25069
  NavbarCupcode,
@@ -25242,7 +25073,7 @@ var MainNavbar = ({
25242
25073
  leadingSlot,
25243
25074
  className,
25244
25075
  actions: /* @__PURE__ */ jsxs26("div", { className: "flex items-center gap-3", children: [
25245
- isCupcodeTenant ? /* @__PURE__ */ jsx41(ThemeToggle, {}) : null,
25076
+ /* @__PURE__ */ jsx41(ThemeToggle, {}),
25246
25077
  isCupcodeTenant ? /* @__PURE__ */ jsx41(
25247
25078
  UserMenuCupcode,
25248
25079
  {
@@ -25250,7 +25081,7 @@ var MainNavbar = ({
25250
25081
  isLoading: resolvedAuthStatus === "loading",
25251
25082
  loginLabel: ctaLabel,
25252
25083
  displayName: authUser == null ? void 0 : authUser.name,
25253
- username: (_b4 = authUser == null ? void 0 : authUser.preferredUsername) != null ? _b4 : authUser == null ? void 0 : authUser.nickname,
25084
+ username: (_b3 = authUser == null ? void 0 : authUser.preferredUsername) != null ? _b3 : authUser == null ? void 0 : authUser.nickname,
25254
25085
  email: authUser == null ? void 0 : authUser.email,
25255
25086
  avatarUrl: resolvedProfileAvatarUrl,
25256
25087
  roleLabel: authUser == null ? void 0 : authUser.jobTitle,
@@ -25923,7 +25754,7 @@ var DocumentationSearchDialog = ({ open, onOpenChange }) => {
25923
25754
  const totalSections = map.sections.length;
25924
25755
  const mapMatches = normalizedQuery.length === 0 || normalizeText([map.title, map.subtitle, map.searchLabel].join(" ")).includes(normalizedQuery);
25925
25756
  const sections = map.sections.filter((section) => {
25926
- var _a68, _b4, _c;
25757
+ var _a66, _b3, _c;
25927
25758
  if (mapMatches) return true;
25928
25759
  const parent = section.parentId ? parents.get(section.parentId) : null;
25929
25760
  const haystack = normalizeText(
@@ -25932,8 +25763,8 @@ var DocumentationSearchDialog = ({ open, onOpenChange }) => {
25932
25763
  map.searchLabel,
25933
25764
  section.label,
25934
25765
  section.group,
25935
- (_a68 = section.description) != null ? _a68 : "",
25936
- (_b4 = parent == null ? void 0 : parent.label) != null ? _b4 : "",
25766
+ (_a66 = section.description) != null ? _a66 : "",
25767
+ (_b3 = parent == null ? void 0 : parent.label) != null ? _b3 : "",
25937
25768
  ...(_c = section.keywords) != null ? _c : []
25938
25769
  ].join(" ")
25939
25770
  );
@@ -26052,10 +25883,10 @@ var DocumentationSearchDialog = ({ open, onOpenChange }) => {
26052
25883
  // src/components/layout/sidebar-groups.tsx
26053
25884
  var toStableId = (value) => value.toLowerCase().normalize("NFD").replace(/\p{Diacritic}+/gu, "").replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)+/g, "");
26054
25885
  var getGroupMetadata = (item) => {
26055
- var _a68, _b4;
25886
+ var _a66, _b3;
26056
25887
  return {
26057
- id: ((_a68 = item.groupId) == null ? void 0 : _a68.trim()) || "",
26058
- label: ((_b4 = item.groupLabel) == null ? void 0 : _b4.trim()) || "",
25888
+ id: ((_a66 = item.groupId) == null ? void 0 : _a66.trim()) || "",
25889
+ label: ((_b3 = item.groupLabel) == null ? void 0 : _b3.trim()) || "",
26059
25890
  icon: item.groupIcon
26060
25891
  };
26061
25892
  };
@@ -26070,7 +25901,7 @@ var buildSidebarGroupsFromNavItems = (items, defaultGroupLabel = "Principal") =>
26070
25901
  if (navItems.length === 0) return [];
26071
25902
  const groupsMap = /* @__PURE__ */ new Map();
26072
25903
  navItems.forEach((item) => {
26073
- var _a68;
25904
+ var _a66;
26074
25905
  const groupId = item.group.id || toStableId(item.group.label || defaultGroupLabel);
26075
25906
  const groupLabel = item.group.label || defaultGroupLabel;
26076
25907
  const existing = groupsMap.get(groupId);
@@ -26078,7 +25909,7 @@ var buildSidebarGroupsFromNavItems = (items, defaultGroupLabel = "Principal") =>
26078
25909
  groupsMap.set(groupId, {
26079
25910
  id: groupId,
26080
25911
  label: groupLabel,
26081
- icon: (_a68 = item.group.icon) != null ? _a68 : item.icon,
25912
+ icon: (_a66 = item.group.icon) != null ? _a66 : item.icon,
26082
25913
  items: [{ id: item.id, label: item.label, icon: item.icon, route: item.route }]
26083
25914
  });
26084
25915
  return;
@@ -26095,8 +25926,8 @@ var defaultSidebarGroups = buildSidebarGroupsFromNavItems(getMainNavItems());
26095
25926
  // src/components/layout/sidebar.tsx
26096
25927
  import { jsx as jsx43, jsxs as jsxs28 } from "react/jsx-runtime";
26097
25928
  var findGroupByRoute = (groups, pathname) => {
26098
- var _a68, _b4;
26099
- return (_b4 = (_a68 = groups.find((group) => group.items.some((item) => item.route === pathname))) == null ? void 0 : _a68.label) != null ? _b4 : null;
25929
+ var _a66, _b3;
25930
+ return (_b3 = (_a66 = groups.find((group) => group.items.some((item) => item.route === pathname))) == null ? void 0 : _a66.label) != null ? _b3 : null;
26100
25931
  };
26101
25932
  var IconFallback = () => /* @__PURE__ */ jsx43(Circle2, { className: "h-3 w-3 opacity-80", "aria-hidden": "true" });
26102
25933
  var DEFAULT_EXPANDED_LOGO_SLOT = /* @__PURE__ */ jsx43("div", { className: "h-10 w-[175px] shrink-0", "aria-hidden": "true" });
@@ -27282,17 +27113,17 @@ var ThemeBackground = ({ enableStars = true }) => {
27282
27113
 
27283
27114
  // src/components/cupcode/ThemeToggle.tsx
27284
27115
  import * as React34 from "react";
27285
- import { Moon as Moon3, Sun as Sun3 } from "lucide-react";
27116
+ import { Moon, Sun } from "lucide-react";
27286
27117
  import { jsx as jsx61, jsxs as jsxs40 } from "react/jsx-runtime";
27287
27118
  var THEME_STORAGE_KEY2 = "cupcode-theme";
27288
27119
  function isThemeMode(value) {
27289
27120
  return value === "light" || value === "dark";
27290
27121
  }
27291
27122
  function readStoredTheme() {
27292
- var _a68;
27123
+ var _a66;
27293
27124
  if (typeof window === "undefined") return null;
27294
27125
  try {
27295
- const storedTheme = (_a68 = window.localStorage.getItem(THEME_STORAGE_KEY2)) != null ? _a68 : window.localStorage.getItem("theme");
27126
+ const storedTheme = (_a66 = window.localStorage.getItem(THEME_STORAGE_KEY2)) != null ? _a66 : window.localStorage.getItem("theme");
27296
27127
  return isThemeMode(storedTheme) ? storedTheme : null;
27297
27128
  } catch (e) {
27298
27129
  return null;
@@ -27315,10 +27146,10 @@ function applyThemeClass(theme) {
27315
27146
  root.style.colorScheme = theme;
27316
27147
  }
27317
27148
  function readThemeFromRoot() {
27318
- var _a68;
27149
+ var _a66;
27319
27150
  if (typeof document === "undefined") return null;
27320
27151
  const root = document.documentElement;
27321
- const datasetTheme = (_a68 = root.dataset.theme) != null ? _a68 : null;
27152
+ const datasetTheme = (_a66 = root.dataset.theme) != null ? _a66 : null;
27322
27153
  if (isThemeMode(datasetTheme)) return datasetTheme;
27323
27154
  if (root.classList.contains("dark")) return "dark";
27324
27155
  if (root.classList.contains("light")) return "light";
@@ -27341,13 +27172,13 @@ var ThemeToggle2 = ({
27341
27172
  defaultTheme = "light",
27342
27173
  onThemeChange
27343
27174
  }) => {
27344
- var _a68;
27175
+ var _a66;
27345
27176
  const themeContext = React34.useContext(ThemeContext);
27346
27177
  const [mounted, setMounted] = React34.useState(false);
27347
27178
  const [internalTheme, setInternalTheme] = React34.useState(defaultTheme);
27348
27179
  const isControlled = typeof theme !== "undefined";
27349
27180
  const usesProviderTheme = !isControlled && themeContext !== null;
27350
- const activeTheme = (_a68 = isControlled ? theme : usesProviderTheme ? themeContext.theme : internalTheme) != null ? _a68 : defaultTheme;
27181
+ const activeTheme = (_a66 = isControlled ? theme : usesProviderTheme ? themeContext.theme : internalTheme) != null ? _a66 : defaultTheme;
27351
27182
  React34.useEffect(() => {
27352
27183
  if (!isControlled && !usesProviderTheme) {
27353
27184
  setInternalTheme(resolveTheme(defaultTheme));
@@ -27372,8 +27203,8 @@ var ThemeToggle2 = ({
27372
27203
  return /* @__PURE__ */ jsx61("div", { className: cn("w-10 h-10 rounded-lg bg-muted", className) });
27373
27204
  }
27374
27205
  const handleToggle = (event) => {
27375
- var _a69;
27376
- const currentTheme = (_a69 = readThemeFromRoot()) != null ? _a69 : activeTheme;
27206
+ var _a67;
27207
+ const currentTheme = (_a67 = readThemeFromRoot()) != null ? _a67 : activeTheme;
27377
27208
  const nextTheme = currentTheme === "dark" ? "light" : "dark";
27378
27209
  if (usesProviderTheme) {
27379
27210
  themeContext.toggleTheme({
@@ -27403,8 +27234,8 @@ var ThemeToggle2 = ({
27403
27234
  ),
27404
27235
  "aria-label": "Toggle theme",
27405
27236
  children: [
27406
- /* @__PURE__ */ jsx61(Sun3, { className: "h-5 w-5 text-cupcode-purple rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" }),
27407
- /* @__PURE__ */ jsx61(Moon3, { className: "absolute h-5 w-5 text-cupcode-hover rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" }),
27237
+ /* @__PURE__ */ jsx61(Sun, { className: "h-5 w-5 text-cupcode-purple rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" }),
27238
+ /* @__PURE__ */ jsx61(Moon, { className: "absolute h-5 w-5 text-cupcode-hover rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" }),
27408
27239
  /* @__PURE__ */ jsxs40("span", { className: "sr-only", children: [
27409
27240
  "Current theme: ",
27410
27241
  activeTheme
@@ -27427,11 +27258,11 @@ function getPreferredTheme() {
27427
27258
  return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
27428
27259
  }
27429
27260
  function getStoredTheme() {
27430
- var _a68;
27261
+ var _a66;
27431
27262
  if (typeof window === "undefined") {
27432
27263
  return null;
27433
27264
  }
27434
- const storedTheme = (_a68 = window.localStorage.getItem(STORAGE_KEY2)) != null ? _a68 : window.localStorage.getItem(LEGACY_STORAGE_KEY);
27265
+ const storedTheme = (_a66 = window.localStorage.getItem(STORAGE_KEY2)) != null ? _a66 : window.localStorage.getItem(LEGACY_STORAGE_KEY);
27435
27266
  return storedTheme === "light" || storedTheme === "dark" ? storedTheme : null;
27436
27267
  }
27437
27268
  function getThemeFromRoot() {
@@ -27452,10 +27283,10 @@ function getThemeFromRoot() {
27452
27283
  return null;
27453
27284
  }
27454
27285
  function resolveTheme2() {
27455
- var _a68, _b4;
27456
- return (_b4 = (_a68 = getThemeFromRoot()) != null ? _a68 : getStoredTheme()) != null ? _b4 : getPreferredTheme();
27286
+ var _a66, _b3;
27287
+ return (_b3 = (_a66 = getThemeFromRoot()) != null ? _a66 : getStoredTheme()) != null ? _b3 : getPreferredTheme();
27457
27288
  }
27458
- function applyThemeToRoot2(theme) {
27289
+ function applyThemeToRoot(theme) {
27459
27290
  const root = document.documentElement;
27460
27291
  root.classList.toggle("dark", theme === "dark");
27461
27292
  root.classList.toggle("light", theme === "light");
@@ -27472,7 +27303,7 @@ function ThemeProvider({ children }) {
27472
27303
  useEffect22(() => {
27473
27304
  const initialTheme = resolveTheme2();
27474
27305
  setThemeState((currentTheme) => currentTheme === initialTheme ? currentTheme : initialTheme);
27475
- applyThemeToRoot2(initialTheme);
27306
+ applyThemeToRoot(initialTheme);
27476
27307
  setMounted(true);
27477
27308
  }, []);
27478
27309
  useEffect22(() => {
@@ -27481,7 +27312,7 @@ function ThemeProvider({ children }) {
27481
27312
  }
27482
27313
  const rootTheme = getThemeFromRoot();
27483
27314
  if (rootTheme !== theme) {
27484
- applyThemeToRoot2(theme);
27315
+ applyThemeToRoot(theme);
27485
27316
  }
27486
27317
  const storedTheme = getStoredTheme();
27487
27318
  if (storedTheme !== theme) {
@@ -27499,7 +27330,7 @@ function ThemeProvider({ children }) {
27499
27330
  }
27500
27331
  const nextTheme = mediaQuery.matches ? "dark" : "light";
27501
27332
  setThemeState(nextTheme);
27502
- applyThemeToRoot2(nextTheme);
27333
+ applyThemeToRoot(nextTheme);
27503
27334
  };
27504
27335
  mediaQuery.addEventListener("change", handleChange);
27505
27336
  return () => mediaQuery.removeEventListener("change", handleChange);
@@ -27523,7 +27354,7 @@ function ThemeProvider({ children }) {
27523
27354
  return () => observer.disconnect();
27524
27355
  }, []);
27525
27356
  const applyThemeSelection = useCallback9((nextTheme, coords) => {
27526
- var _a68;
27357
+ var _a66;
27527
27358
  const documentWithTransition = document;
27528
27359
  const root = document.documentElement;
27529
27360
  const prefersReducedMotion = window.matchMedia(
@@ -27531,7 +27362,7 @@ function ThemeProvider({ children }) {
27531
27362
  ).matches;
27532
27363
  const supportsTransition = typeof documentWithTransition.startViewTransition === "function";
27533
27364
  const commitTheme = () => {
27534
- applyThemeToRoot2(nextTheme);
27365
+ applyThemeToRoot(nextTheme);
27535
27366
  persistThemePreferenceSelection(nextTheme);
27536
27367
  setThemeState(
27537
27368
  (currentTheme) => currentTheme === nextTheme ? currentTheme : nextTheme
@@ -27548,7 +27379,7 @@ function ThemeProvider({ children }) {
27548
27379
  root.style.setProperty("--theme-x", "50%");
27549
27380
  root.style.setProperty("--theme-y", "50%");
27550
27381
  }
27551
- (_a68 = documentWithTransition.startViewTransition) == null ? void 0 : _a68.call(documentWithTransition, () => {
27382
+ (_a66 = documentWithTransition.startViewTransition) == null ? void 0 : _a66.call(documentWithTransition, () => {
27552
27383
  flushSync(() => {
27553
27384
  commitTheme();
27554
27385
  });
@@ -27558,8 +27389,8 @@ function ThemeProvider({ children }) {
27558
27389
  applyThemeSelection(nextTheme);
27559
27390
  }, [applyThemeSelection]);
27560
27391
  const toggleTheme = useCallback9((coords) => {
27561
- var _a68;
27562
- const currentTheme = (_a68 = getThemeFromRoot()) != null ? _a68 : theme;
27392
+ var _a66;
27393
+ const currentTheme = (_a66 = getThemeFromRoot()) != null ? _a66 : theme;
27563
27394
  const nextTheme = currentTheme === "light" ? "dark" : "light";
27564
27395
  applyThemeSelection(nextTheme, coords);
27565
27396
  }, [applyThemeSelection, theme]);
@@ -28212,8 +28043,8 @@ var ChartStyle = ({ id, config }) => {
28212
28043
  ([theme, prefix]) => `
28213
28044
  ${prefix} [data-chart=${id}] {
28214
28045
  ${colorConfig.map(([key, itemConfig]) => {
28215
- var _a68;
28216
- const color = ((_a68 = itemConfig.theme) == null ? void 0 : _a68[theme]) || itemConfig.color;
28046
+ var _a66;
28047
+ const color = ((_a66 = itemConfig.theme) == null ? void 0 : _a66[theme]) || itemConfig.color;
28217
28048
  return color ? ` --color-${key}: ${color};` : null;
28218
28049
  }).join("\n")}
28219
28050
  }
@@ -28242,14 +28073,14 @@ var ChartTooltipContent = React42.forwardRef(
28242
28073
  }, ref) => {
28243
28074
  const { config } = useChart();
28244
28075
  const tooltipLabel = React42.useMemo(() => {
28245
- var _a68;
28076
+ var _a66;
28246
28077
  if (hideLabel || !(payload == null ? void 0 : payload.length)) {
28247
28078
  return null;
28248
28079
  }
28249
28080
  const [item] = payload;
28250
28081
  const key = `${labelKey || item.dataKey || item.name || "value"}`;
28251
28082
  const itemConfig = getPayloadConfigFromPayload(config, item, key);
28252
- const value = !labelKey && typeof label === "string" ? ((_a68 = config[label]) == null ? void 0 : _a68.label) || label : itemConfig == null ? void 0 : itemConfig.label;
28083
+ const value = !labelKey && typeof label === "string" ? ((_a66 = config[label]) == null ? void 0 : _a66.label) || label : itemConfig == null ? void 0 : itemConfig.label;
28253
28084
  if (labelFormatter) {
28254
28085
  return /* @__PURE__ */ jsx73("div", { className: cn("font-medium", labelClassName), children: labelFormatter(value, payload) });
28255
28086
  }
@@ -29867,9 +29698,9 @@ ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
29867
29698
  // src/hooks/useActiveSection.ts
29868
29699
  import { useEffect as useEffect26, useState as useState23 } from "react";
29869
29700
  var resolveActiveFromOffsets = (sectionIds, topById, offset, scrollY) => {
29870
- var _a68;
29701
+ var _a66;
29871
29702
  const line = scrollY + offset;
29872
- let nextActive = (_a68 = sectionIds[0]) != null ? _a68 : "";
29703
+ let nextActive = (_a66 = sectionIds[0]) != null ? _a66 : "";
29873
29704
  for (const id of sectionIds) {
29874
29705
  const top = topById.get(id);
29875
29706
  if (typeof top !== "number") continue;
@@ -29882,10 +29713,10 @@ var resolveActiveFromOffsets = (sectionIds, topById, offset, scrollY) => {
29882
29713
  return nextActive;
29883
29714
  };
29884
29715
  var useActiveSection = (sectionIds, offset = 180) => {
29885
- var _a68;
29886
- const [activeId, setActiveId] = useState23((_a68 = sectionIds[0]) != null ? _a68 : "");
29716
+ var _a66;
29717
+ const [activeId, setActiveId] = useState23((_a66 = sectionIds[0]) != null ? _a66 : "");
29887
29718
  useEffect26(() => {
29888
- var _a69;
29719
+ var _a67;
29889
29720
  if (!sectionIds.length || typeof window === "undefined") return;
29890
29721
  const sections = sectionIds.map((id) => {
29891
29722
  const element = document.getElementById(id);
@@ -29893,7 +29724,7 @@ var useActiveSection = (sectionIds, offset = 180) => {
29893
29724
  return { id, element };
29894
29725
  }).filter((section) => section !== null);
29895
29726
  if (!sections.length) {
29896
- setActiveId((_a69 = sectionIds[0]) != null ? _a69 : "");
29727
+ setActiveId((_a67 = sectionIds[0]) != null ? _a67 : "");
29897
29728
  return;
29898
29729
  }
29899
29730
  const topById = /* @__PURE__ */ new Map();
@@ -30028,9 +29859,9 @@ var useLayoutMode = () => {
30028
29859
  setMode(normalizeLayoutMode(event.newValue));
30029
29860
  };
30030
29861
  const handleModeChange = (event) => {
30031
- var _a68;
29862
+ var _a66;
30032
29863
  const customEvent = event;
30033
- setMode((_a68 = customEvent.detail) != null ? _a68 : readStoredLayoutMode());
29864
+ setMode((_a66 = customEvent.detail) != null ? _a66 : readStoredLayoutMode());
30034
29865
  };
30035
29866
  window.addEventListener("storage", handleStorage);
30036
29867
  window.addEventListener(LAYOUT_MODE_CHANGE_EVENT, handleModeChange);
@@ -30061,6 +29892,7 @@ var STORAGE_KEYS = {
30061
29892
  state: "cc_auth_state",
30062
29893
  nonce: "cc_auth_nonce",
30063
29894
  authMode: "cc_auth_mode",
29895
+ profileAvatar: "cc_profile_avatar",
30064
29896
  silentCheckDone: "cc_auth_silent_check_done",
30065
29897
  logoutIntent: "cc_auth_logout_intent",
30066
29898
  redirect: "cc_post_login_redirect",
@@ -30070,18 +29902,18 @@ var STORAGE_KEYS = {
30070
29902
  var LOCAL_STORAGE_KEYS = {
30071
29903
  presenceSource: "cc_user_presence_source"
30072
29904
  };
29905
+ var _a54;
29906
+ var USER_PRESENCE_TABLE2 = ((_a54 = getRuntimeEnv("VITE_USER_PRESENCE_TABLE")) != null ? _a54 : "user_presence").trim();
29907
+ var _a55;
29908
+ var USER_PRESENCE_USER_ID_COLUMN2 = ((_a55 = getRuntimeEnv("VITE_USER_PRESENCE_USER_ID_COLUMN")) != null ? _a55 : "user_id").trim();
30073
29909
  var _a56;
30074
- var USER_PRESENCE_TABLE2 = ((_a56 = getRuntimeEnv("VITE_USER_PRESENCE_TABLE")) != null ? _a56 : "user_presence").trim();
29910
+ var USER_PRESENCE_STATUS_COLUMN2 = ((_a56 = getRuntimeEnv("VITE_USER_PRESENCE_STATUS_COLUMN")) != null ? _a56 : "status").trim();
30075
29911
  var _a57;
30076
- var USER_PRESENCE_USER_ID_COLUMN2 = ((_a57 = getRuntimeEnv("VITE_USER_PRESENCE_USER_ID_COLUMN")) != null ? _a57 : "user_id").trim();
29912
+ var USER_PRESENCE_SOURCE_COLUMN2 = ((_a57 = getRuntimeEnv("VITE_USER_PRESENCE_SOURCE_COLUMN")) != null ? _a57 : "status_source").trim();
30077
29913
  var _a58;
30078
- var USER_PRESENCE_STATUS_COLUMN2 = ((_a58 = getRuntimeEnv("VITE_USER_PRESENCE_STATUS_COLUMN")) != null ? _a58 : "status").trim();
30079
- var _a59;
30080
- var USER_PRESENCE_SOURCE_COLUMN2 = ((_a59 = getRuntimeEnv("VITE_USER_PRESENCE_SOURCE_COLUMN")) != null ? _a59 : "status_source").trim();
30081
- var _a60;
30082
- var USER_PRESENCE_LAST_ACTIVE_COLUMN2 = ((_a60 = getRuntimeEnv("VITE_USER_PRESENCE_LAST_ACTIVE_COLUMN")) != null ? _a60 : "last_active_at").trim();
30083
- var _a61, _b3;
30084
- var SUPABASE_CHAT_SCHEMA = ((_b3 = (_a61 = getRuntimeEnv("VITE_CHAT_SCHEMA")) != null ? _a61 : getRuntimeEnv("VITE_SUPABASE_SCHEMA")) != null ? _b3 : "public").trim();
29914
+ var USER_PRESENCE_LAST_ACTIVE_COLUMN2 = ((_a58 = getRuntimeEnv("VITE_USER_PRESENCE_LAST_ACTIVE_COLUMN")) != null ? _a58 : "last_active_at").trim();
29915
+ var _a59, _b2;
29916
+ var SUPABASE_CHAT_SCHEMA = ((_b2 = (_a59 = getRuntimeEnv("VITE_CHAT_SCHEMA")) != null ? _a59 : getRuntimeEnv("VITE_SUPABASE_SCHEMA")) != null ? _b2 : "public").trim();
30085
29917
  var PRESENCE_TOUCH_RPC = "cc_presence_touch";
30086
29918
  var PRESENCE_MARK_IDLE_RPC = "cc_presence_mark_idle";
30087
29919
  var PRESENCE_SET_STATUS_RPC = "cc_presence_set_status";
@@ -30090,18 +29922,18 @@ var parsePositiveInteger2 = (rawValue, fallback) => {
30090
29922
  if (!Number.isFinite(parsed) || parsed <= 0) return fallback;
30091
29923
  return Math.floor(parsed);
30092
29924
  };
29925
+ var _a60;
29926
+ var CHAT_USERS_TABLE2 = ((_a60 = getRuntimeEnv("VITE_CHAT_USERS_TABLE")) != null ? _a60 : "chat_users").trim();
29927
+ var _a61;
29928
+ var CHAT_USERS_ID_COLUMN2 = ((_a61 = getRuntimeEnv("VITE_CHAT_USERS_ID_COLUMN")) != null ? _a61 : "id").trim();
30093
29929
  var _a62;
30094
- var CHAT_USERS_TABLE2 = ((_a62 = getRuntimeEnv("VITE_CHAT_USERS_TABLE")) != null ? _a62 : "chat_users").trim();
29930
+ var CHAT_USERS_EMAIL_COLUMN2 = ((_a62 = getRuntimeEnv("VITE_CHAT_USERS_EMAIL_COLUMN")) != null ? _a62 : "email").trim();
30095
29931
  var _a63;
30096
- var CHAT_USERS_ID_COLUMN2 = ((_a63 = getRuntimeEnv("VITE_CHAT_USERS_ID_COLUMN")) != null ? _a63 : "id").trim();
29932
+ var CHAT_USERS_UPDATE_TABLE2 = ((_a63 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_TABLE")) != null ? _a63 : "profiles").trim();
30097
29933
  var _a64;
30098
- var CHAT_USERS_EMAIL_COLUMN2 = ((_a64 = getRuntimeEnv("VITE_CHAT_USERS_EMAIL_COLUMN")) != null ? _a64 : "email").trim();
29934
+ var CHAT_USERS_UPDATE_ID_COLUMN2 = ((_a64 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_ID_COLUMN")) != null ? _a64 : "id").trim();
30099
29935
  var _a65;
30100
- var CHAT_USERS_UPDATE_TABLE2 = ((_a65 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_TABLE")) != null ? _a65 : "profiles").trim();
30101
- var _a66;
30102
- var CHAT_USERS_UPDATE_ID_COLUMN2 = ((_a66 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_ID_COLUMN")) != null ? _a66 : "id").trim();
30103
- var _a67;
30104
- var CHAT_USERS_UPDATE_EMAIL_COLUMN2 = ((_a67 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_EMAIL_COLUMN")) != null ? _a67 : "email").trim();
29936
+ var CHAT_USERS_UPDATE_EMAIL_COLUMN2 = ((_a65 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_EMAIL_COLUMN")) != null ? _a65 : "email").trim();
30105
29937
  var PRESENCE_USER_LOOKUP_TABLES = Array.from(
30106
29938
  new Set(
30107
29939
  [CHAT_USERS_UPDATE_TABLE2, CHAT_USERS_TABLE2, "profiles", "chat_users"].map((entry) => entry.trim()).filter((entry) => entry.length > 0)
@@ -30218,6 +30050,32 @@ var toTimestampMs2 = (value) => {
30218
30050
  const parsed = new Date(trimmed).getTime();
30219
30051
  return Number.isNaN(parsed) ? void 0 : parsed;
30220
30052
  };
30053
+ var readStoredProfileAvatar = () => {
30054
+ var _a66;
30055
+ if (typeof window === "undefined") return void 0;
30056
+ const raw = localStorage.getItem(STORAGE_KEYS.profileAvatar) || sessionStorage.getItem(STORAGE_KEYS.profileAvatar);
30057
+ if (!raw) return void 0;
30058
+ try {
30059
+ const parsed = JSON.parse(raw);
30060
+ return (_a66 = toNonEmptyString(parsed.avatarUrl)) != null ? _a66 : toNonEmptyString(parsed.avatarId);
30061
+ } catch (e) {
30062
+ return toNonEmptyString(raw);
30063
+ }
30064
+ };
30065
+ var writeStoredProfileAvatar = (payload) => {
30066
+ if (typeof window === "undefined") return;
30067
+ const avatarId = toNonEmptyString(payload.avatarId);
30068
+ const avatarUrl = toNonEmptyString(payload.avatarUrl);
30069
+ if (!avatarId && !avatarUrl) return;
30070
+ const serialized = JSON.stringify({ avatarId, avatarUrl });
30071
+ sessionStorage.setItem(STORAGE_KEYS.profileAvatar, serialized);
30072
+ localStorage.setItem(STORAGE_KEYS.profileAvatar, serialized);
30073
+ };
30074
+ var applyStoredProfileAvatar = (user) => {
30075
+ if (!user) return user;
30076
+ const storedAvatar = readStoredProfileAvatar();
30077
+ return storedAvatar ? { ...user, picture: storedAvatar } : user;
30078
+ };
30221
30079
  var readPresenceRow = (payload) => {
30222
30080
  if (!payload) return null;
30223
30081
  if (Array.isArray(payload)) {
@@ -30230,8 +30088,8 @@ var readPresenceRow = (payload) => {
30230
30088
  return null;
30231
30089
  };
30232
30090
  var isMissingColumnError2 = (error, column) => {
30233
- var _a68;
30234
- const message = ((_a68 = error == null ? void 0 : error.message) != null ? _a68 : "").toLowerCase();
30091
+ var _a66;
30092
+ const message = ((_a66 = error == null ? void 0 : error.message) != null ? _a66 : "").toLowerCase();
30235
30093
  const code = error == null ? void 0 : error.code;
30236
30094
  const token = column.trim().toLowerCase();
30237
30095
  if (!token) return false;
@@ -30253,8 +30111,8 @@ var readStoredPresence = () => {
30253
30111
  return isUserPresenceStatus(stored) ? stored : DEFAULT_PRESENCE_STATUS;
30254
30112
  };
30255
30113
  var readStoredPresenceSource = () => {
30256
- var _a68;
30257
- const stored = (_a68 = sessionStorage.getItem(STORAGE_KEYS.presenceSource)) != null ? _a68 : localStorage.getItem(LOCAL_STORAGE_KEYS.presenceSource);
30114
+ var _a66;
30115
+ const stored = (_a66 = sessionStorage.getItem(STORAGE_KEYS.presenceSource)) != null ? _a66 : localStorage.getItem(LOCAL_STORAGE_KEYS.presenceSource);
30258
30116
  if (isPresenceSource(stored)) return stored;
30259
30117
  return "auto";
30260
30118
  };
@@ -30301,9 +30159,9 @@ var readClaimValue = (claims, keys) => {
30301
30159
  return void 0;
30302
30160
  };
30303
30161
  var readClaimRole = (claims) => {
30304
- var _a68, _b4, _c;
30162
+ var _a66, _b3, _c;
30305
30163
  if (!claims) return void 0;
30306
- const roleClaim = (_c = (_b4 = (_a68 = claims.role) != null ? _a68 : claims.roles) != null ? _b4 : claims["https://cupcode.com/role"]) != null ? _c : claims["https://cupcode.com/roles"];
30164
+ const roleClaim = (_c = (_b3 = (_a66 = claims.role) != null ? _a66 : claims.roles) != null ? _b3 : claims["https://cupcode.com/role"]) != null ? _c : claims["https://cupcode.com/roles"];
30307
30165
  if (typeof roleClaim === "string") return toNonEmptyString(roleClaim);
30308
30166
  if (Array.isArray(roleClaim)) {
30309
30167
  return roleClaim.find((entry) => typeof entry === "string" && entry.trim() !== "");
@@ -30314,7 +30172,7 @@ var buildUserFromTokens = ({
30314
30172
  idToken,
30315
30173
  accessToken
30316
30174
  }) => {
30317
- var _a68;
30175
+ var _a66;
30318
30176
  const idClaims = decodeJwt(idToken != null ? idToken : void 0);
30319
30177
  const accessClaims = decodeJwt(accessToken != null ? accessToken : void 0);
30320
30178
  if (!idClaims && !accessClaims) return null;
@@ -30341,7 +30199,7 @@ var buildUserFromTokens = ({
30341
30199
  "id",
30342
30200
  "sub"
30343
30201
  ]);
30344
- const resolvedSub = (_a68 = readFromClaims(["sub"])) != null ? _a68 : resolvedId;
30202
+ const resolvedSub = (_a66 = readFromClaims(["sub"])) != null ? _a66 : resolvedId;
30345
30203
  const preferredUsername = readFromClaims([
30346
30204
  "preferred_username",
30347
30205
  "preferredUsername",
@@ -30376,7 +30234,7 @@ var buildUserFromTokens = ({
30376
30234
  "photoURL",
30377
30235
  "https://cupcode.com/picture"
30378
30236
  ]);
30379
- return {
30237
+ return applyStoredProfileAvatar({
30380
30238
  sub: resolvedSub,
30381
30239
  id: resolvedId,
30382
30240
  userId: resolvedId,
@@ -30389,7 +30247,7 @@ var buildUserFromTokens = ({
30389
30247
  nickname,
30390
30248
  role: readRole(),
30391
30249
  jobTitle: readFromClaims(["job_title", "jobTitle", "title", "position", "https://cupcode.com/job_title"])
30392
- };
30250
+ });
30393
30251
  };
30394
30252
  var AuthProvider = ({ children }) => {
30395
30253
  const [status, setStatus] = useState25("loading");
@@ -30413,16 +30271,16 @@ var AuthProvider = ({ children }) => {
30413
30271
  }
30414
30272
  }, []);
30415
30273
  const resolvePresenceUserId = useCallback13(async (targetUser) => {
30416
- var _a68, _b4, _c, _d;
30274
+ var _a66, _b3, _c, _d;
30417
30275
  const sub = toNonEmptyString(targetUser == null ? void 0 : targetUser.sub);
30418
30276
  const id = toNonEmptyString(targetUser == null ? void 0 : targetUser.id);
30419
30277
  const userId = toNonEmptyString(targetUser == null ? void 0 : targetUser.userId);
30420
- const email = (_a68 = toNonEmptyString(targetUser == null ? void 0 : targetUser.email)) == null ? void 0 : _a68.toLowerCase();
30278
+ const email = (_a66 = toNonEmptyString(targetUser == null ? void 0 : targetUser.email)) == null ? void 0 : _a66.toLowerCase();
30421
30279
  const identityKey = [sub != null ? sub : "", id != null ? id : "", userId != null ? userId : "", email != null ? email : ""].join("|");
30422
30280
  if (resolvedPresenceIdentityKeyRef.current === identityKey && resolvedPresenceUserIdRef.current) {
30423
30281
  return resolvedPresenceUserIdRef.current;
30424
30282
  }
30425
- const fallbackUserId = (_d = (_c = (_b4 = sub != null ? sub : id) != null ? _b4 : userId) != null ? _c : email) != null ? _d : null;
30283
+ const fallbackUserId = (_d = (_c = (_b3 = sub != null ? sub : id) != null ? _b3 : userId) != null ? _c : email) != null ? _d : null;
30426
30284
  if (!email) {
30427
30285
  resolvedPresenceIdentityKeyRef.current = identityKey;
30428
30286
  resolvedPresenceUserIdRef.current = fallbackUserId;
@@ -30452,11 +30310,11 @@ var AuthProvider = ({ children }) => {
30452
30310
  }, []);
30453
30311
  const syncPresenceFromRecord = useCallback13(
30454
30312
  (rawRow) => {
30455
- var _a68, _b4, _c;
30313
+ var _a66, _b3, _c;
30456
30314
  if (!rawRow) return;
30457
- const statusValue = toNonEmptyString((_a68 = rawRow[USER_PRESENCE_STATUS_COLUMN2]) != null ? _a68 : rawRow.status);
30315
+ const statusValue = toNonEmptyString((_a66 = rawRow[USER_PRESENCE_STATUS_COLUMN2]) != null ? _a66 : rawRow.status);
30458
30316
  if (!isUserPresenceStatus(statusValue)) return;
30459
- const sourceValue = normalizePresenceSource2((_b4 = rawRow[USER_PRESENCE_SOURCE_COLUMN2]) != null ? _b4 : rawRow.status_source);
30317
+ const sourceValue = normalizePresenceSource2((_b3 = rawRow[USER_PRESENCE_SOURCE_COLUMN2]) != null ? _b3 : rawRow.status_source);
30460
30318
  const lastActiveTimestamp = toTimestampMs2((_c = rawRow[USER_PRESENCE_LAST_ACTIVE_COLUMN2]) != null ? _c : rawRow.last_active_at);
30461
30319
  if (typeof lastActiveTimestamp === "number" && Number.isFinite(lastActiveTimestamp)) {
30462
30320
  lastActivityAtRef.current = Math.max(lastActivityAtRef.current, lastActiveTimestamp);
@@ -30530,8 +30388,8 @@ var AuthProvider = ({ children }) => {
30530
30388
  );
30531
30389
  const touchPresence = useCallback13(
30532
30390
  async (options) => {
30533
- var _a68;
30534
- const targetUser = (_a68 = options == null ? void 0 : options.targetUser) != null ? _a68 : user;
30391
+ var _a66;
30392
+ const targetUser = (_a66 = options == null ? void 0 : options.targetUser) != null ? _a66 : user;
30535
30393
  const userId = await resolvePresenceUserId(targetUser);
30536
30394
  if (!userId) return;
30537
30395
  const now = Date.now();
@@ -30656,7 +30514,7 @@ var AuthProvider = ({ children }) => {
30656
30514
  }, []);
30657
30515
  const startAuthorization = useCallback13(
30658
30516
  async (options) => {
30659
- var _a68, _b4;
30517
+ var _a66, _b3;
30660
30518
  const config = getAccountsConfig();
30661
30519
  const { authUrl } = await resolveOidcEndpoints(config);
30662
30520
  if (!authUrl) {
@@ -30666,8 +30524,8 @@ var AuthProvider = ({ children }) => {
30666
30524
  const challenge = await generateCodeChallenge(verifier);
30667
30525
  const state = generateState();
30668
30526
  const nonce = generateNonce();
30669
- const redirectTo = (_a68 = options == null ? void 0 : options.redirectTo) != null ? _a68 : window.location.pathname + window.location.search + window.location.hash;
30670
- const mode = (_b4 = options == null ? void 0 : options.mode) != null ? _b4 : "interactive";
30527
+ const redirectTo = (_a66 = options == null ? void 0 : options.redirectTo) != null ? _a66 : window.location.pathname + window.location.search + window.location.hash;
30528
+ const mode = (_b3 = options == null ? void 0 : options.mode) != null ? _b3 : "interactive";
30671
30529
  if (mode === "interactive") {
30672
30530
  clearLogoutIntent();
30673
30531
  }
@@ -30701,14 +30559,14 @@ var AuthProvider = ({ children }) => {
30701
30559
  useEffect28(() => {
30702
30560
  let cancelled = false;
30703
30561
  const initializeAuth = async () => {
30704
- var _a68;
30562
+ var _a66;
30705
30563
  const stored = readStoredToken();
30706
30564
  const storedPresence = readStoredPresence();
30707
30565
  setPresenceStatusState(storedPresence);
30708
30566
  if (stored == null ? void 0 : stored.accessToken) {
30709
30567
  if (cancelled) return;
30710
30568
  const hydratedUser = buildUserFromTokens({
30711
- idToken: (_a68 = stored.idToken) != null ? _a68 : void 0,
30569
+ idToken: (_a66 = stored.idToken) != null ? _a66 : void 0,
30712
30570
  accessToken: stored.accessToken
30713
30571
  });
30714
30572
  setAccessToken(stored.accessToken);
@@ -30744,18 +30602,33 @@ var AuthProvider = ({ children }) => {
30744
30602
  };
30745
30603
  }, [attemptSilentLogin]);
30746
30604
  useEffect28(() => {
30747
- var _a68;
30605
+ var _a66;
30748
30606
  if (status !== "authenticated") return;
30749
30607
  if (user) return;
30750
30608
  const stored = readStoredToken();
30751
30609
  if (!(stored == null ? void 0 : stored.accessToken)) return;
30752
30610
  const hydratedUser = buildUserFromTokens({
30753
- idToken: (_a68 = stored.idToken) != null ? _a68 : void 0,
30611
+ idToken: (_a66 = stored.idToken) != null ? _a66 : void 0,
30754
30612
  accessToken: stored.accessToken
30755
30613
  });
30756
30614
  if (!hydratedUser) return;
30757
30615
  setUser(hydratedUser);
30758
30616
  }, [status, user]);
30617
+ useEffect28(() => {
30618
+ if (typeof window === "undefined") return;
30619
+ const handleProfileAvatarChange = (event) => {
30620
+ const detail = event.detail;
30621
+ writeStoredProfileAvatar({
30622
+ avatarId: detail == null ? void 0 : detail.avatarId,
30623
+ avatarUrl: detail == null ? void 0 : detail.avatarUrl
30624
+ });
30625
+ const nextPicture = readStoredProfileAvatar();
30626
+ if (!nextPicture) return;
30627
+ setUser((current) => current ? { ...current, picture: nextPicture } : current);
30628
+ };
30629
+ window.addEventListener("cupcode:profile-avatar-change", handleProfileAvatarChange);
30630
+ return () => window.removeEventListener("cupcode:profile-avatar-change", handleProfileAvatarChange);
30631
+ }, []);
30759
30632
  useEffect28(() => {
30760
30633
  resolvedPresenceIdentityKeyRef.current = null;
30761
30634
  resolvedPresenceUserIdRef.current = null;
@@ -30781,9 +30654,9 @@ var AuthProvider = ({ children }) => {
30781
30654
  table: USER_PRESENCE_TABLE2
30782
30655
  },
30783
30656
  (payload) => {
30784
- var _a68, _b4;
30657
+ var _a66, _b3;
30785
30658
  const row = payload.new || payload.old;
30786
- const rowUserId = toNonEmptyString((_b4 = (_a68 = row == null ? void 0 : row[USER_PRESENCE_USER_ID_COLUMN2]) != null ? _a68 : row == null ? void 0 : row.user_id) != null ? _b4 : row == null ? void 0 : row.id);
30659
+ const rowUserId = toNonEmptyString((_b3 = (_a66 = row == null ? void 0 : row[USER_PRESENCE_USER_ID_COLUMN2]) != null ? _a66 : row == null ? void 0 : row.user_id) != null ? _b3 : row == null ? void 0 : row.id);
30787
30660
  if (!rowUserId || rowUserId !== currentUserId) return;
30788
30661
  if (payload.eventType === "DELETE") {
30789
30662
  storePresenceStatus("offline", "system");
@@ -30857,9 +30730,9 @@ var AuthProvider = ({ children }) => {
30857
30730
  });
30858
30731
  }, [startAuthorization]);
30859
30732
  const completeLogin = useCallback13(async () => {
30860
- var _a68;
30733
+ var _a66;
30861
30734
  const params = new URLSearchParams(window.location.search);
30862
- const redirectTo = (_a68 = sessionStorage.getItem(STORAGE_KEYS.redirect)) != null ? _a68 : "/";
30735
+ const redirectTo = (_a66 = sessionStorage.getItem(STORAGE_KEYS.redirect)) != null ? _a66 : "/";
30863
30736
  const authMode = sessionStorage.getItem(STORAGE_KEYS.authMode);
30864
30737
  const isSilentAuth = authMode === "silent";
30865
30738
  const error = params.get("error");
@@ -30928,11 +30801,11 @@ var AuthProvider = ({ children }) => {
30928
30801
  }
30929
30802
  }, [clearAuthFlowState]);
30930
30803
  const logout = useCallback13(async () => {
30931
- var _a68, _b4;
30804
+ var _a66, _b3;
30932
30805
  const config = getAccountsConfig();
30933
30806
  const { logoutUrl } = await resolveOidcEndpoints(config);
30934
- const idToken = (_a68 = sessionStorage.getItem(STORAGE_KEYS.idToken)) != null ? _a68 : void 0;
30935
- const refreshToken = (_b4 = sessionStorage.getItem(STORAGE_KEYS.refreshToken)) != null ? _b4 : void 0;
30807
+ const idToken = (_a66 = sessionStorage.getItem(STORAGE_KEYS.idToken)) != null ? _a66 : void 0;
30808
+ const refreshToken = (_b3 = sessionStorage.getItem(STORAGE_KEYS.refreshToken)) != null ? _b3 : void 0;
30936
30809
  const currentUser = user;
30937
30810
  await setPresenceNetworkStatus("offline", "system", currentUser);
30938
30811
  clearTokens();