@cupcodev/ui 8.1.2 → 8.1.3
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.cjs +447 -508
- package/dist/index.d.cts +4 -11
- package/dist/index.d.ts +4 -11
- package/dist/index.js +447 -507
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1286,7 +1286,6 @@ __export(src_exports, {
|
|
|
1286
1286
|
cn: () => cn,
|
|
1287
1287
|
completeTelescupOidcCallback: () => completeTelescupOidcCallback,
|
|
1288
1288
|
createTelescupClient: () => createTelescupClient,
|
|
1289
|
-
cupcodeRuntimeEnv: () => cupcodeRuntimeEnv,
|
|
1290
1289
|
decodeJwt: () => decodeJwt,
|
|
1291
1290
|
defaultSidebarGroups: () => defaultSidebarGroups,
|
|
1292
1291
|
ensureTelescupOidcToken: () => ensureTelescupOidcToken,
|
|
@@ -1653,10 +1652,10 @@ var Dock = ({ items, className }) => {
|
|
|
1653
1652
|
const itemsRef = (0, import_react5.useRef)([]);
|
|
1654
1653
|
const OVERSHOOT = 5;
|
|
1655
1654
|
(0, import_react5.useEffect)(() => {
|
|
1656
|
-
var
|
|
1655
|
+
var _a25;
|
|
1657
1656
|
const activeItem = itemsRef.current[activeIndex];
|
|
1658
1657
|
if (!activeItem) return;
|
|
1659
|
-
const containerRect = (
|
|
1658
|
+
const containerRect = (_a25 = activeItem.parentElement) == null ? void 0 : _a25.getBoundingClientRect();
|
|
1660
1659
|
const itemRect = activeItem.getBoundingClientRect();
|
|
1661
1660
|
if (!containerRect) return;
|
|
1662
1661
|
const relativeLeft = itemRect.left - containerRect.left;
|
|
@@ -1718,9 +1717,9 @@ var Dock = ({ items, className }) => {
|
|
|
1718
1717
|
"button",
|
|
1719
1718
|
{
|
|
1720
1719
|
onClick: () => {
|
|
1721
|
-
var
|
|
1720
|
+
var _a25;
|
|
1722
1721
|
setActiveIndex(index);
|
|
1723
|
-
(
|
|
1722
|
+
(_a25 = item.onClick) == null ? void 0 : _a25.call(item);
|
|
1724
1723
|
},
|
|
1725
1724
|
className: cn(
|
|
1726
1725
|
"flex items-center justify-center w-12 h-12 rounded-xl",
|
|
@@ -1788,9 +1787,9 @@ var normalizeValue = (value) => {
|
|
|
1788
1787
|
return String(value);
|
|
1789
1788
|
};
|
|
1790
1789
|
var setCupcodeRuntimeEnv = (values) => {
|
|
1791
|
-
var
|
|
1790
|
+
var _a25;
|
|
1792
1791
|
const globalRef = globalThis;
|
|
1793
|
-
const nextGlobalEnv = { ...(
|
|
1792
|
+
const nextGlobalEnv = { ...(_a25 = globalRef.__CUPCODE_ENV__) != null ? _a25 : {} };
|
|
1794
1793
|
Object.entries(values).forEach(([key, value]) => {
|
|
1795
1794
|
const normalized = normalizeValue(value);
|
|
1796
1795
|
runtimeStore[key] = normalized;
|
|
@@ -1799,8 +1798,8 @@ var setCupcodeRuntimeEnv = (values) => {
|
|
|
1799
1798
|
globalRef.__CUPCODE_ENV__ = nextGlobalEnv;
|
|
1800
1799
|
};
|
|
1801
1800
|
var readFromProcessEnv = (key) => {
|
|
1802
|
-
var
|
|
1803
|
-
const processEnv = (
|
|
1801
|
+
var _a25;
|
|
1802
|
+
const processEnv = (_a25 = globalThis.process) == null ? void 0 : _a25.env;
|
|
1804
1803
|
return normalizeValue(processEnv == null ? void 0 : processEnv[key]);
|
|
1805
1804
|
};
|
|
1806
1805
|
var readFromImportMetaEnv = (key) => {
|
|
@@ -1812,12 +1811,12 @@ var readFromImportMetaEnv = (key) => {
|
|
|
1812
1811
|
}
|
|
1813
1812
|
};
|
|
1814
1813
|
var getRuntimeEnv = (key) => {
|
|
1815
|
-
var
|
|
1814
|
+
var _a25;
|
|
1816
1815
|
const normalizedKey = key.trim();
|
|
1817
1816
|
if (!normalizedKey) return void 0;
|
|
1818
1817
|
const fromRuntimeStore = runtimeStore[normalizedKey];
|
|
1819
1818
|
if (fromRuntimeStore) return fromRuntimeStore;
|
|
1820
|
-
const fromGlobalStore = normalizeValue((
|
|
1819
|
+
const fromGlobalStore = normalizeValue((_a25 = globalThis.__CUPCODE_ENV__) == null ? void 0 : _a25[normalizedKey]);
|
|
1821
1820
|
if (fromGlobalStore) return fromGlobalStore;
|
|
1822
1821
|
const fromGlobalKey = normalizeValue(globalThis[normalizedKey]);
|
|
1823
1822
|
if (fromGlobalKey) return fromGlobalKey;
|
|
@@ -1826,12 +1825,12 @@ var getRuntimeEnv = (key) => {
|
|
|
1826
1825
|
return readFromProcessEnv(normalizedKey);
|
|
1827
1826
|
};
|
|
1828
1827
|
var getRuntimeEnvOr = (key, fallback) => {
|
|
1829
|
-
var
|
|
1830
|
-
return (
|
|
1828
|
+
var _a25;
|
|
1829
|
+
return (_a25 = getRuntimeEnv(key)) != null ? _a25 : fallback;
|
|
1831
1830
|
};
|
|
1832
1831
|
var isRuntimeDev = () => {
|
|
1833
|
-
var
|
|
1834
|
-
const explicitDev = (
|
|
1832
|
+
var _a25, _b3, _c;
|
|
1833
|
+
const explicitDev = (_a25 = getRuntimeEnv("DEV")) != null ? _a25 : getRuntimeEnv("VITE_DEV");
|
|
1835
1834
|
if (explicitDev) {
|
|
1836
1835
|
const normalized = explicitDev.toLowerCase();
|
|
1837
1836
|
return normalized === "1" || normalized === "true";
|
|
@@ -1857,11 +1856,11 @@ var isUuid = (value) => {
|
|
|
1857
1856
|
return UUID_REGEX.test(value.trim());
|
|
1858
1857
|
};
|
|
1859
1858
|
function parseAssetId(input) {
|
|
1860
|
-
var
|
|
1859
|
+
var _a25, _b3, _c, _d;
|
|
1861
1860
|
const raw = input == null ? void 0 : input.trim();
|
|
1862
1861
|
if (!raw) return void 0;
|
|
1863
1862
|
if (UUID_REGEX.test(raw)) return raw;
|
|
1864
|
-
const matchFromRaw = (
|
|
1863
|
+
const matchFromRaw = (_a25 = raw.match(UUID_IN_TEXT_REGEX)) == null ? void 0 : _a25[0];
|
|
1865
1864
|
if (isUuid(matchFromRaw)) return matchFromRaw;
|
|
1866
1865
|
try {
|
|
1867
1866
|
const url = new URL(raw);
|
|
@@ -1904,7 +1903,7 @@ function buildTelescupImageURL(options) {
|
|
|
1904
1903
|
return `${getApiBase()}/i?${params.toString()}`;
|
|
1905
1904
|
}
|
|
1906
1905
|
function resolveTelescupImageURL(value, options) {
|
|
1907
|
-
var
|
|
1906
|
+
var _a25;
|
|
1908
1907
|
const raw = value == null ? void 0 : value.trim();
|
|
1909
1908
|
if (!raw) return void 0;
|
|
1910
1909
|
const parsedId = parseAssetId(raw);
|
|
@@ -1926,7 +1925,7 @@ function resolveTelescupImageURL(value, options) {
|
|
|
1926
1925
|
width: options == null ? void 0 : options.width,
|
|
1927
1926
|
height: options == null ? void 0 : options.height,
|
|
1928
1927
|
fit: options == null ? void 0 : options.fit,
|
|
1929
|
-
format: (
|
|
1928
|
+
format: (_a25 = options == null ? void 0 : options.format) != null ? _a25 : "webp",
|
|
1930
1929
|
quality: options == null ? void 0 : options.quality
|
|
1931
1930
|
});
|
|
1932
1931
|
}
|
|
@@ -2022,7 +2021,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
2022
2021
|
return void 0;
|
|
2023
2022
|
}, [sortedCategories]);
|
|
2024
2023
|
(0, import_react7.useEffect)(() => {
|
|
2025
|
-
var
|
|
2024
|
+
var _a25;
|
|
2026
2025
|
const root = rootRef.current;
|
|
2027
2026
|
if (!root) return;
|
|
2028
2027
|
const $ = (sel) => root.querySelector(sel);
|
|
@@ -2034,7 +2033,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
2034
2033
|
const getDockItems = () => Array.from(root.querySelectorAll(INTERACTIVE_SELECTOR));
|
|
2035
2034
|
const dockItems = getDockItems();
|
|
2036
2035
|
if (!tabbar || !dock || !listMenuShow || !tabbarUl || dockItems.length === 0) return;
|
|
2037
|
-
const persistentId = (
|
|
2036
|
+
const persistentId = (_a25 = activeCategoryId != null ? activeCategoryId : lastInteractiveId) != null ? _a25 : null;
|
|
2038
2037
|
let openItem = null;
|
|
2039
2038
|
let latestToggleToken = null;
|
|
2040
2039
|
const persistentSelector = persistentId != null ? `${INTERACTIVE_SELECTOR}[data-cat-id="${persistentId}"]` : null;
|
|
@@ -2333,8 +2332,8 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
2333
2332
|
}, total);
|
|
2334
2333
|
}
|
|
2335
2334
|
const hideBootstrapTooltip = (el) => {
|
|
2336
|
-
var
|
|
2337
|
-
const tooltip = ((_b3 = (
|
|
2335
|
+
var _a26, _b3;
|
|
2336
|
+
const tooltip = ((_b3 = (_a26 = window.bootstrap) == null ? void 0 : _a26.Tooltip) == null ? void 0 : _b3.getInstance) ? window.bootstrap.Tooltip.getInstance(el) : null;
|
|
2338
2337
|
tooltip == null ? void 0 : tooltip.hide();
|
|
2339
2338
|
};
|
|
2340
2339
|
const openMenuForItem = (item, menu) => {
|
|
@@ -2352,14 +2351,14 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
2352
2351
|
latestToggleToken = null;
|
|
2353
2352
|
};
|
|
2354
2353
|
const closeActiveMenu = (opts = {}) => {
|
|
2355
|
-
var
|
|
2354
|
+
var _a26;
|
|
2356
2355
|
if (!opts.onClosed) {
|
|
2357
2356
|
latestToggleToken = null;
|
|
2358
2357
|
}
|
|
2359
2358
|
const itemToClose = openItem;
|
|
2360
2359
|
if (!itemToClose) {
|
|
2361
2360
|
if (!opts.preserveWrapper) ensurePersistentHighlight();
|
|
2362
|
-
(
|
|
2361
|
+
(_a26 = opts.onClosed) == null ? void 0 : _a26.call(opts);
|
|
2363
2362
|
return;
|
|
2364
2363
|
}
|
|
2365
2364
|
const menu = getMenuFor(itemToClose);
|
|
@@ -2367,7 +2366,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
2367
2366
|
itemToClose.classList.remove("active");
|
|
2368
2367
|
delete itemToClose.dataset.menuOpen;
|
|
2369
2368
|
const finalize = () => {
|
|
2370
|
-
var
|
|
2369
|
+
var _a27;
|
|
2371
2370
|
if (!opts.preserveWrapper) {
|
|
2372
2371
|
listMenuShow.classList.remove("show");
|
|
2373
2372
|
tabbar.classList.remove("is-active-menu");
|
|
@@ -2375,7 +2374,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
2375
2374
|
setTabbarTheme(null);
|
|
2376
2375
|
ensurePersistentHighlight();
|
|
2377
2376
|
}
|
|
2378
|
-
(
|
|
2377
|
+
(_a27 = opts.onClosed) == null ? void 0 : _a27.call(opts);
|
|
2379
2378
|
};
|
|
2380
2379
|
closeMenu(menu, finalize);
|
|
2381
2380
|
};
|
|
@@ -2478,7 +2477,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
2478
2477
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "glass-overlay" }),
|
|
2479
2478
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "glass-specular" }),
|
|
2480
2479
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("ul", { className: "flex-center", children: sortedCategories.map((cat) => {
|
|
2481
|
-
var
|
|
2480
|
+
var _a25;
|
|
2482
2481
|
if (cat.type === "divider") {
|
|
2483
2482
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2484
2483
|
"li",
|
|
@@ -2490,7 +2489,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
2490
2489
|
cat.id
|
|
2491
2490
|
);
|
|
2492
2491
|
}
|
|
2493
|
-
const hasCards = (((
|
|
2492
|
+
const hasCards = (((_a25 = cat.cards) == null ? void 0 : _a25.length) || 0) > 0;
|
|
2494
2493
|
const link = cat.href;
|
|
2495
2494
|
const isCurrent = cat.id === activeCategoryId;
|
|
2496
2495
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
@@ -2524,12 +2523,12 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
2524
2523
|
);
|
|
2525
2524
|
}) }),
|
|
2526
2525
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "list-menu-mob-show", children: sortedCategories.filter((cat) => {
|
|
2527
|
-
var
|
|
2528
|
-
return cat.type !== "divider" && (((
|
|
2526
|
+
var _a25;
|
|
2527
|
+
return cat.type !== "divider" && (((_a25 = cat.cards) == null ? void 0 : _a25.length) || 0) > 0;
|
|
2529
2528
|
}).map((cat) => {
|
|
2530
|
-
var
|
|
2531
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "mob-list-menu hide", "data-tagget": cat.slug, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: `submenu-stack ${cat.slug}`, children: ((
|
|
2532
|
-
var
|
|
2529
|
+
var _a25;
|
|
2530
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "mob-list-menu hide", "data-tagget": cat.slug, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: `submenu-stack ${cat.slug}`, children: ((_a25 = cat.cards) != null ? _a25 : []).map((card, i) => {
|
|
2531
|
+
var _a26;
|
|
2533
2532
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
2534
2533
|
"div",
|
|
2535
2534
|
{
|
|
@@ -2545,8 +2544,8 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
2545
2544
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "title", children: card.title }),
|
|
2546
2545
|
card.description ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "description", children: card.description }) : null
|
|
2547
2546
|
] }),
|
|
2548
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "actions", children: ((
|
|
2549
|
-
var
|
|
2547
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "actions", children: ((_a26 = card.buttons) != null ? _a26 : []).slice(0, 2).map((btn, idx) => {
|
|
2548
|
+
var _a27, _b3, _c, _d;
|
|
2550
2549
|
const className = idx === 0 ? "saiba-mais" : "saiba-mais-1";
|
|
2551
2550
|
if (btn.type === "popup") {
|
|
2552
2551
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
@@ -2561,7 +2560,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
2561
2560
|
window.dispatchEvent(new Event(`qw:open:${btn.popupId}`));
|
|
2562
2561
|
}
|
|
2563
2562
|
},
|
|
2564
|
-
children: (
|
|
2563
|
+
children: (_a27 = btn.label) != null ? _a27 : "Abrir"
|
|
2565
2564
|
},
|
|
2566
2565
|
`${cat.id}-card-${i}-btn-${idx}`
|
|
2567
2566
|
);
|
|
@@ -2707,10 +2706,10 @@ var NavbarCupcode = ({
|
|
|
2707
2706
|
React5.useEffect(() => {
|
|
2708
2707
|
if (!hasItems || !isOpen) return;
|
|
2709
2708
|
const handlePointerDown = (event) => {
|
|
2710
|
-
var
|
|
2709
|
+
var _a25, _b3;
|
|
2711
2710
|
const target = event.target;
|
|
2712
2711
|
if (!(target instanceof Node)) return;
|
|
2713
|
-
if (!((
|
|
2712
|
+
if (!((_a25 = navRef.current) == null ? void 0 : _a25.contains(target)) && !((_b3 = mobileDrawerRef.current) == null ? void 0 : _b3.contains(target))) {
|
|
2714
2713
|
setIsOpen(false);
|
|
2715
2714
|
}
|
|
2716
2715
|
};
|
|
@@ -2779,9 +2778,9 @@ var NavbarCupcode = ({
|
|
|
2779
2778
|
isActive && "text-[hsl(var(--cc-navbar-link-active))] after:w-full after:bg-[hsl(var(--cc-navbar-link-active))]"
|
|
2780
2779
|
);
|
|
2781
2780
|
const handleClick = (event) => {
|
|
2782
|
-
var
|
|
2781
|
+
var _a25;
|
|
2783
2782
|
logNavClick("navbar-desktop", item);
|
|
2784
|
-
(
|
|
2783
|
+
(_a25 = item.onClick) == null ? void 0 : _a25.call(item, event);
|
|
2785
2784
|
};
|
|
2786
2785
|
if (item.href.startsWith("#")) {
|
|
2787
2786
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
@@ -2882,9 +2881,9 @@ var NavbarCupcode = ({
|
|
|
2882
2881
|
isActive && "text-[hsl(var(--cc-navbar-link-active))]"
|
|
2883
2882
|
);
|
|
2884
2883
|
const handleClick = (event) => {
|
|
2885
|
-
var
|
|
2884
|
+
var _a25;
|
|
2886
2885
|
logNavClick("navbar-mobile", item);
|
|
2887
|
-
(
|
|
2886
|
+
(_a25 = item.onClick) == null ? void 0 : _a25.call(item, event);
|
|
2888
2887
|
setIsOpen(false);
|
|
2889
2888
|
};
|
|
2890
2889
|
if (item.href.startsWith("#")) {
|
|
@@ -3121,11 +3120,11 @@ JellyButton.displayName = "JellyButton";
|
|
|
3121
3120
|
// src/components/cupcode/JellyButtonOriginal.tsx
|
|
3122
3121
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
3123
3122
|
var resolveResponsiveSize = (value, currentBp) => {
|
|
3124
|
-
var
|
|
3123
|
+
var _a25, _b3, _c, _d, _e;
|
|
3125
3124
|
if (typeof value === "string") {
|
|
3126
3125
|
return value;
|
|
3127
3126
|
}
|
|
3128
|
-
const fallback = (_e = (_d = (_c = (_b3 = (
|
|
3127
|
+
const fallback = (_e = (_d = (_c = (_b3 = (_a25 = value.base) != null ? _a25 : value.sm) != null ? _b3 : value.md) != null ? _c : value.lg) != null ? _d : value.xl) != null ? _e : "md";
|
|
3129
3128
|
if (!currentBp) {
|
|
3130
3129
|
return fallback;
|
|
3131
3130
|
}
|
|
@@ -3498,12 +3497,12 @@ var isAccountsOidcToken = (token) => {
|
|
|
3498
3497
|
return issuer.startsWith(ACCOUNTS_BASE_URL_NORMALIZED) || issuer.includes("accounts.cupcode.com.br");
|
|
3499
3498
|
};
|
|
3500
3499
|
var readStoredIdToken = () => {
|
|
3501
|
-
var
|
|
3500
|
+
var _a25;
|
|
3502
3501
|
if (typeof window === "undefined" || typeof window.sessionStorage === "undefined") {
|
|
3503
3502
|
return void 0;
|
|
3504
3503
|
}
|
|
3505
3504
|
for (const key of SESSION_ID_TOKEN_KEYS) {
|
|
3506
|
-
const value = (
|
|
3505
|
+
const value = (_a25 = window.sessionStorage.getItem(key)) == null ? void 0 : _a25.trim();
|
|
3507
3506
|
if (value) return value;
|
|
3508
3507
|
}
|
|
3509
3508
|
return void 0;
|
|
@@ -3597,11 +3596,11 @@ var readUsageContext = (value) => {
|
|
|
3597
3596
|
return void 0;
|
|
3598
3597
|
};
|
|
3599
3598
|
var getFileExtension = (filename) => {
|
|
3600
|
-
var
|
|
3599
|
+
var _a25;
|
|
3601
3600
|
if (!filename) return void 0;
|
|
3602
3601
|
const parts = filename.split(".");
|
|
3603
3602
|
if (parts.length < 2) return void 0;
|
|
3604
|
-
const candidate = (
|
|
3603
|
+
const candidate = (_a25 = parts[parts.length - 1]) == null ? void 0 : _a25.trim().toLowerCase();
|
|
3605
3604
|
return candidate || void 0;
|
|
3606
3605
|
};
|
|
3607
3606
|
var buildFacetsFromItems = (items) => {
|
|
@@ -3611,9 +3610,9 @@ var buildFacetsFromItems = (items) => {
|
|
|
3611
3610
|
const extensions = /* @__PURE__ */ new Map();
|
|
3612
3611
|
const tags = /* @__PURE__ */ new Map();
|
|
3613
3612
|
items.forEach((item) => {
|
|
3614
|
-
var
|
|
3613
|
+
var _a25, _b3, _c, _d, _e, _f, _g;
|
|
3615
3614
|
if (item.category) {
|
|
3616
|
-
categories.set(item.category, ((
|
|
3615
|
+
categories.set(item.category, ((_a25 = categories.get(item.category)) != null ? _a25 : 0) + 1);
|
|
3617
3616
|
}
|
|
3618
3617
|
if (item.folderId) {
|
|
3619
3618
|
const current = folders.get(item.folderId);
|
|
@@ -3629,16 +3628,16 @@ var buildFacetsFromItems = (items) => {
|
|
|
3629
3628
|
extensions.set(item.extension, ((_e = extensions.get(item.extension)) != null ? _e : 0) + 1);
|
|
3630
3629
|
}
|
|
3631
3630
|
(_g = (_f = item.meta) == null ? void 0 : _f.tags) == null ? void 0 : _g.forEach((tag) => {
|
|
3632
|
-
var
|
|
3631
|
+
var _a26;
|
|
3633
3632
|
const normalizedTag = tag.trim();
|
|
3634
3633
|
if (!normalizedTag) return;
|
|
3635
|
-
tags.set(normalizedTag, ((
|
|
3634
|
+
tags.set(normalizedTag, ((_a26 = tags.get(normalizedTag)) != null ? _a26 : 0) + 1);
|
|
3636
3635
|
});
|
|
3637
3636
|
});
|
|
3638
3637
|
const toFacetValues = (map) => Array.from(map.entries()).map(([value, count2]) => ({ value, count: count2 })).sort((a, b) => a.value.localeCompare(b.value));
|
|
3639
3638
|
const toFolderFacetValues = (map) => Array.from(map.entries()).map(([value, info]) => ({ value, label: info.label, count: info.count })).sort((a, b) => {
|
|
3640
|
-
var
|
|
3641
|
-
return ((
|
|
3639
|
+
var _a25, _b3;
|
|
3640
|
+
return ((_a25 = a.label) != null ? _a25 : a.value).localeCompare((_b3 = b.label) != null ? _b3 : b.value);
|
|
3642
3641
|
});
|
|
3643
3642
|
return {
|
|
3644
3643
|
categories: toFacetValues(categories),
|
|
@@ -3649,7 +3648,7 @@ var buildFacetsFromItems = (items) => {
|
|
|
3649
3648
|
};
|
|
3650
3649
|
};
|
|
3651
3650
|
async function request(config, path, options = {}) {
|
|
3652
|
-
var
|
|
3651
|
+
var _a25, _b3;
|
|
3653
3652
|
const token = await config.getAccessToken();
|
|
3654
3653
|
if (!token) {
|
|
3655
3654
|
throw new TelescupClientError("Token de acesso n\xE3o encontrado.");
|
|
@@ -3679,7 +3678,7 @@ async function request(config, path, options = {}) {
|
|
|
3679
3678
|
let response;
|
|
3680
3679
|
try {
|
|
3681
3680
|
response = await fetch(url, {
|
|
3682
|
-
method: (
|
|
3681
|
+
method: (_a25 = options.method) != null ? _a25 : "POST",
|
|
3683
3682
|
headers,
|
|
3684
3683
|
body
|
|
3685
3684
|
});
|
|
@@ -3709,8 +3708,8 @@ var normalizeFunctionLanguage = (value) => {
|
|
|
3709
3708
|
return normalized;
|
|
3710
3709
|
};
|
|
3711
3710
|
var toFunctionListPayload = (filters) => {
|
|
3712
|
-
var
|
|
3713
|
-
const page = toPositiveInt((
|
|
3711
|
+
var _a25, _b3, _c, _d, _e, _f;
|
|
3712
|
+
const page = toPositiveInt((_a25 = filters.cursor) != null ? _a25 : filters.page, 1);
|
|
3714
3713
|
const pageSize = Math.min(500, Math.max(1, toPositiveInt(filters.pageSize, 24)));
|
|
3715
3714
|
return {
|
|
3716
3715
|
query: (_b3 = filters.query) != null ? _b3 : "",
|
|
@@ -3731,8 +3730,8 @@ var toFunctionListPayload = (filters) => {
|
|
|
3731
3730
|
};
|
|
3732
3731
|
};
|
|
3733
3732
|
var mapGenericRowToAsset = (row) => {
|
|
3734
|
-
var
|
|
3735
|
-
const id = (
|
|
3733
|
+
var _a25, _b3;
|
|
3734
|
+
const id = (_a25 = readFirstString(row, ["asset_id", "id", "file_id", "uuid"])) != null ? _a25 : typeof row.id === "number" ? String(row.id) : void 0;
|
|
3736
3735
|
if (!id) return null;
|
|
3737
3736
|
const fileName = readFirstString(row, ["filename", "file_name", "name", "title", "original_name"]);
|
|
3738
3737
|
const mimeType = readFirstString(row, ["mime", "mime_type", "content_type", "file_mime"]);
|
|
@@ -3754,16 +3753,16 @@ var mapGenericRowToAsset = (row) => {
|
|
|
3754
3753
|
};
|
|
3755
3754
|
};
|
|
3756
3755
|
var normalizeListResponseFromFunctions = (response, filters) => {
|
|
3757
|
-
var
|
|
3756
|
+
var _a25, _b3, _c, _d, _e, _f;
|
|
3758
3757
|
const payload = response != null ? response : {};
|
|
3759
3758
|
const itemsRaw = Array.isArray(payload.items) ? payload.items : [];
|
|
3760
3759
|
const selectedLanguage = normalizeLanguageKey(filters.language);
|
|
3761
3760
|
const items = itemsRaw.map((row) => {
|
|
3762
|
-
var
|
|
3761
|
+
var _a26, _b4, _c2;
|
|
3763
3762
|
const mapped = mapGenericRowToAsset(row);
|
|
3764
3763
|
if (!mapped) return null;
|
|
3765
3764
|
const metaByLang = normalizeMetaByLanguage(row.meta);
|
|
3766
|
-
const activeMeta = (_b4 = (
|
|
3765
|
+
const activeMeta = (_b4 = (_a26 = metaByLang[selectedLanguage]) != null ? _a26 : metaByLang.pt) != null ? _b4 : {};
|
|
3767
3766
|
const usageFromObject = readUsageContext(row.usage);
|
|
3768
3767
|
const normalized = {
|
|
3769
3768
|
...mapped,
|
|
@@ -3775,7 +3774,7 @@ var normalizeListResponseFromFunctions = (response, filters) => {
|
|
|
3775
3774
|
};
|
|
3776
3775
|
return normalized;
|
|
3777
3776
|
}).filter((item) => item !== null);
|
|
3778
|
-
const total = (_c = (_b3 = (
|
|
3777
|
+
const total = (_c = (_b3 = (_a25 = readNumber(payload.total)) != null ? _a25 : readNumber(payload.totalCount)) != null ? _b3 : readNumber(payload.total_count)) != null ? _c : items.length;
|
|
3779
3778
|
const page = toPositiveInt((_e = (_d = payload.page) != null ? _d : filters.cursor) != null ? _e : filters.page, 1);
|
|
3780
3779
|
const pageSize = Math.min(100, Math.max(1, toPositiveInt((_f = payload.pageSize) != null ? _f : filters.pageSize, 24)));
|
|
3781
3780
|
const nextCursor = total > page * pageSize ? String(page + 1) : void 0;
|
|
@@ -3795,12 +3794,12 @@ var mapConflictForQueue = (value) => {
|
|
|
3795
3794
|
return "conflict";
|
|
3796
3795
|
};
|
|
3797
3796
|
var toInitPayloadForFunctions = (payload) => {
|
|
3798
|
-
var
|
|
3797
|
+
var _a25, _b3;
|
|
3799
3798
|
return {
|
|
3800
3799
|
filename: payload.fileName,
|
|
3801
3800
|
size: payload.size,
|
|
3802
3801
|
mime: payload.mimeType,
|
|
3803
|
-
folder_id: (
|
|
3802
|
+
folder_id: (_a25 = payload.folderId) != null ? _a25 : null,
|
|
3804
3803
|
overwritePolicy: (_b3 = payload.conflict) != null ? _b3 : "ask",
|
|
3805
3804
|
fileName: payload.fileName,
|
|
3806
3805
|
mimeType: payload.mimeType,
|
|
@@ -3809,9 +3808,9 @@ var toInitPayloadForFunctions = (payload) => {
|
|
|
3809
3808
|
};
|
|
3810
3809
|
};
|
|
3811
3810
|
var normalizeInitResponseFromFunctions = (response) => {
|
|
3812
|
-
var
|
|
3811
|
+
var _a25, _b3, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
3813
3812
|
const payload = response != null ? response : {};
|
|
3814
|
-
const existingRaw = (
|
|
3813
|
+
const existingRaw = (_a25 = payload.existingAsset) != null ? _a25 : payload.existing_asset;
|
|
3815
3814
|
const existingAsset = existingRaw ? (_b3 = mapGenericRowToAsset(existingRaw)) != null ? _b3 : void 0 : void 0;
|
|
3816
3815
|
const assetRaw = payload.asset;
|
|
3817
3816
|
const asset = assetRaw ? (_c = mapGenericRowToAsset(assetRaw)) != null ? _c : void 0 : void 0;
|
|
@@ -3888,10 +3887,10 @@ var uploadBinaryWithProgress = async (config, file, payload, onProgress) => {
|
|
|
3888
3887
|
});
|
|
3889
3888
|
};
|
|
3890
3889
|
var toCompletePayloadForFunctions = (payload) => {
|
|
3891
|
-
var
|
|
3890
|
+
var _a25, _b3, _c;
|
|
3892
3891
|
return {
|
|
3893
3892
|
uploadId: payload.uploadId,
|
|
3894
|
-
assetDraftId: (
|
|
3893
|
+
assetDraftId: (_a25 = payload.assetDraftId) != null ? _a25 : payload.assetId,
|
|
3895
3894
|
storageKey: payload.storageKey,
|
|
3896
3895
|
finalFilename: (_b3 = payload.finalFilename) != null ? _b3 : payload.fileName,
|
|
3897
3896
|
folder_id: (_c = payload.folderId) != null ? _c : null,
|
|
@@ -3901,9 +3900,9 @@ var toCompletePayloadForFunctions = (payload) => {
|
|
|
3901
3900
|
};
|
|
3902
3901
|
};
|
|
3903
3902
|
var normalizeCompleteResponseFromFunctions = (response) => {
|
|
3904
|
-
var
|
|
3903
|
+
var _a25, _b3, _c, _d, _e, _f;
|
|
3905
3904
|
const payload = response != null ? response : {};
|
|
3906
|
-
const assetRaw = (
|
|
3905
|
+
const assetRaw = (_a25 = payload.asset) != null ? _a25 : payload;
|
|
3907
3906
|
const mapped = mapGenericRowToAsset(assetRaw);
|
|
3908
3907
|
if (mapped) {
|
|
3909
3908
|
const title = readFirstString(assetRaw, ["title", "title_text"]);
|
|
@@ -3932,7 +3931,7 @@ var normalizeCompleteResponseFromFunctions = (response) => {
|
|
|
3932
3931
|
return { asset: { id: assetId } };
|
|
3933
3932
|
};
|
|
3934
3933
|
var toMetaPayloadForFunctions = (payload) => {
|
|
3935
|
-
var
|
|
3934
|
+
var _a25;
|
|
3936
3935
|
if (payload.action && payload.action !== "update") {
|
|
3937
3936
|
return payload;
|
|
3938
3937
|
}
|
|
@@ -3942,7 +3941,7 @@ var toMetaPayloadForFunctions = (payload) => {
|
|
|
3942
3941
|
en: {},
|
|
3943
3942
|
es: {}
|
|
3944
3943
|
};
|
|
3945
|
-
const target = (
|
|
3944
|
+
const target = (_a25 = byLanguage[language]) != null ? _a25 : byLanguage.pt;
|
|
3946
3945
|
if (payload.meta) {
|
|
3947
3946
|
if (typeof payload.meta.alt === "string") target.alt = payload.meta.alt;
|
|
3948
3947
|
if (typeof payload.meta.title === "string") target.title = payload.meta.title;
|
|
@@ -3972,7 +3971,7 @@ var createTelescupClient = (config) => ({
|
|
|
3972
3971
|
return normalizeListResponseFromFunctions(response, filters);
|
|
3973
3972
|
},
|
|
3974
3973
|
initUpload: async (payload) => {
|
|
3975
|
-
var
|
|
3974
|
+
var _a25;
|
|
3976
3975
|
try {
|
|
3977
3976
|
const response = await request(
|
|
3978
3977
|
config,
|
|
@@ -3985,7 +3984,7 @@ var createTelescupClient = (config) => ({
|
|
|
3985
3984
|
return normalizeInitResponseFromFunctions(response);
|
|
3986
3985
|
} catch (error) {
|
|
3987
3986
|
if (error instanceof TelescupClientError && error.status === 409) {
|
|
3988
|
-
const details = (
|
|
3987
|
+
const details = (_a25 = error.details) != null ? _a25 : {};
|
|
3989
3988
|
const hasConflictPayload = Boolean(
|
|
3990
3989
|
details.existingAsset || details.existing_asset || details.conflict || details.duplicate || details.suggestedName || details.suggested_name
|
|
3991
3990
|
);
|
|
@@ -4013,14 +4012,14 @@ var createTelescupClient = (config) => ({
|
|
|
4013
4012
|
body: toMetaPayloadForFunctions(payload)
|
|
4014
4013
|
}),
|
|
4015
4014
|
generateAlt: async (asset, language = "pt") => {
|
|
4016
|
-
var
|
|
4015
|
+
var _a25, _b3, _c;
|
|
4017
4016
|
const response = await request(config, "generate-alt", {
|
|
4018
4017
|
method: "POST",
|
|
4019
4018
|
body: {
|
|
4020
4019
|
items: [
|
|
4021
4020
|
{
|
|
4022
4021
|
id: asset.id,
|
|
4023
|
-
file_path: (
|
|
4022
|
+
file_path: (_a25 = asset.filePath) != null ? _a25 : asset.storageKey,
|
|
4024
4023
|
mime_type: asset.mimeType
|
|
4025
4024
|
}
|
|
4026
4025
|
],
|
|
@@ -4050,12 +4049,12 @@ var createTelescupClient = (config) => ({
|
|
|
4050
4049
|
});
|
|
4051
4050
|
const payload = response != null ? response : {};
|
|
4052
4051
|
const toMeta = (value) => {
|
|
4053
|
-
var
|
|
4052
|
+
var _a25;
|
|
4054
4053
|
if (!value || typeof value !== "object") return void 0;
|
|
4055
4054
|
const row = value;
|
|
4056
4055
|
const title = readString(row.title);
|
|
4057
4056
|
const alt = readString(row.alt);
|
|
4058
|
-
const description = (
|
|
4057
|
+
const description = (_a25 = readString(row.description)) != null ? _a25 : readString(row.desc);
|
|
4059
4058
|
if (!title && !alt && !description) return void 0;
|
|
4060
4059
|
return {
|
|
4061
4060
|
...title ? { title } : {},
|
|
@@ -4085,17 +4084,17 @@ var mergeFacetValues = (current, incoming) => {
|
|
|
4085
4084
|
const map = /* @__PURE__ */ new Map();
|
|
4086
4085
|
current == null ? void 0 : current.forEach((entry) => map.set(entry.value, entry));
|
|
4087
4086
|
incoming == null ? void 0 : incoming.forEach((entry) => {
|
|
4088
|
-
var
|
|
4087
|
+
var _a25, _b3, _c;
|
|
4089
4088
|
const previous = map.get(entry.value);
|
|
4090
4089
|
map.set(entry.value, {
|
|
4091
4090
|
value: entry.value,
|
|
4092
|
-
label: (_b3 = (
|
|
4091
|
+
label: (_b3 = (_a25 = entry.label) != null ? _a25 : previous == null ? void 0 : previous.label) != null ? _b3 : entry.value,
|
|
4093
4092
|
count: (_c = entry.count) != null ? _c : previous == null ? void 0 : previous.count
|
|
4094
4093
|
});
|
|
4095
4094
|
});
|
|
4096
4095
|
return Array.from(map.values()).sort((a, b) => {
|
|
4097
|
-
var
|
|
4098
|
-
return ((
|
|
4096
|
+
var _a25, _b3;
|
|
4097
|
+
return ((_a25 = a.label) != null ? _a25 : a.value).localeCompare((_b3 = b.label) != null ? _b3 : b.value);
|
|
4099
4098
|
});
|
|
4100
4099
|
};
|
|
4101
4100
|
var DEFAULT_CACHE_MS = 3e5;
|
|
@@ -4104,8 +4103,8 @@ var inFlight = /* @__PURE__ */ new Map();
|
|
|
4104
4103
|
var LIST_CACHE_STORAGE_PREFIX = "telescup:list:v4";
|
|
4105
4104
|
var canUseLocalStorage = () => typeof window !== "undefined" && typeof window.localStorage !== "undefined";
|
|
4106
4105
|
var isEmptyAssetsState = (data) => {
|
|
4107
|
-
var
|
|
4108
|
-
return !((
|
|
4106
|
+
var _a25, _b3;
|
|
4107
|
+
return !((_a25 = data == null ? void 0 : data.items) == null ? void 0 : _a25.length) && ((_b3 = data == null ? void 0 : data.total) != null ? _b3 : 0) === 0;
|
|
4109
4108
|
};
|
|
4110
4109
|
var isCacheableAssetsState = (data) => !isEmptyAssetsState(data);
|
|
4111
4110
|
var readPersistentCache = (key, cacheTimeMs) => {
|
|
@@ -4239,9 +4238,9 @@ function useTelescupAssets(options) {
|
|
|
4239
4238
|
...sanitizeFilters(filters),
|
|
4240
4239
|
pageSize
|
|
4241
4240
|
}).then((data) => {
|
|
4242
|
-
var
|
|
4241
|
+
var _a25;
|
|
4243
4242
|
return {
|
|
4244
|
-
items: (
|
|
4243
|
+
items: (_a25 = data.items) != null ? _a25 : [],
|
|
4245
4244
|
nextCursor: data.nextCursor,
|
|
4246
4245
|
total: data.total,
|
|
4247
4246
|
facets: data.facets
|
|
@@ -4269,7 +4268,7 @@ function useTelescupAssets(options) {
|
|
|
4269
4268
|
[cacheKey, cacheTimeMs, enabled, filters, pageSize, resolvedClient]
|
|
4270
4269
|
);
|
|
4271
4270
|
const loadMore = (0, import_react10.useCallback)(async () => {
|
|
4272
|
-
var
|
|
4271
|
+
var _a25, _b3, _c, _d, _e, _f, _g;
|
|
4273
4272
|
if (!state.nextCursor || isLoadingMore || isLoading) return;
|
|
4274
4273
|
const requestSeq = requestSeqRef.current;
|
|
4275
4274
|
setIsLoadingMore(true);
|
|
@@ -4283,7 +4282,7 @@ function useTelescupAssets(options) {
|
|
|
4283
4282
|
});
|
|
4284
4283
|
if (!aliveRef.current || requestSeq !== requestSeqRef.current) return;
|
|
4285
4284
|
const merged = {
|
|
4286
|
-
items: [...state.items, ...(
|
|
4285
|
+
items: [...state.items, ...(_a25 = data.items) != null ? _a25 : []],
|
|
4287
4286
|
nextCursor: data.nextCursor,
|
|
4288
4287
|
total: (_b3 = data.total) != null ? _b3 : state.total,
|
|
4289
4288
|
facets: {
|
|
@@ -4585,8 +4584,8 @@ var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "we
|
|
|
4585
4584
|
var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set(["mp4", "mov", "webm", "mkv", "avi", "m4v", "wmv"]);
|
|
4586
4585
|
var AUDIO_EXTENSIONS = /* @__PURE__ */ new Set(["mp3", "wav", "aac", "ogg", "flac", "m4a"]);
|
|
4587
4586
|
var resolveAssetFamily = (asset) => {
|
|
4588
|
-
var
|
|
4589
|
-
const explicitType = (
|
|
4587
|
+
var _a25, _b3, _c;
|
|
4588
|
+
const explicitType = (_a25 = asset.type) == null ? void 0 : _a25.toLowerCase();
|
|
4590
4589
|
if (explicitType === "image" || explicitType === "video" || explicitType === "audio" || explicitType === "file") {
|
|
4591
4590
|
return explicitType;
|
|
4592
4591
|
}
|
|
@@ -4602,9 +4601,9 @@ var resolveAssetFamily = (asset) => {
|
|
|
4602
4601
|
return "file";
|
|
4603
4602
|
};
|
|
4604
4603
|
var matchesAllowedAsset = (asset, allowed) => {
|
|
4605
|
-
var
|
|
4604
|
+
var _a25, _b3, _c, _d;
|
|
4606
4605
|
if (!allowed || allowed.length === 0) return true;
|
|
4607
|
-
const mime = (_b3 = (
|
|
4606
|
+
const mime = (_b3 = (_a25 = asset.mimeType) == null ? void 0 : _a25.toLowerCase()) != null ? _b3 : "";
|
|
4608
4607
|
const ext = asset.extension ? `.${asset.extension.toLowerCase()}` : "";
|
|
4609
4608
|
const type = (_d = (_c = asset.type) == null ? void 0 : _c.toLowerCase()) != null ? _d : "";
|
|
4610
4609
|
const family = resolveAssetFamily(asset);
|
|
@@ -4660,10 +4659,10 @@ var UUID_REGEX2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[
|
|
|
4660
4659
|
var ROOT_FOLDERS_TO_HIDE = /* @__PURE__ */ new Set(["images", "videos"]);
|
|
4661
4660
|
var normalizeFolderToken = (value) => value.trim().replace(/^\/+|\/+$/g, "").toLowerCase();
|
|
4662
4661
|
var getLeafName = (value) => {
|
|
4663
|
-
var
|
|
4662
|
+
var _a25;
|
|
4664
4663
|
const normalized = normalizeFolderToken(value);
|
|
4665
4664
|
const parts = normalized.split("/").filter(Boolean);
|
|
4666
|
-
return (
|
|
4665
|
+
return (_a25 = parts[parts.length - 1]) != null ? _a25 : normalized;
|
|
4667
4666
|
};
|
|
4668
4667
|
var scoreFolderValue = (value, label) => {
|
|
4669
4668
|
const normalizedValue = normalizeFolderToken(value);
|
|
@@ -4679,8 +4678,8 @@ var normalizeFacetOptions = (entries) => {
|
|
|
4679
4678
|
if (!entries || !entries.length) return [];
|
|
4680
4679
|
const byLabel = /* @__PURE__ */ new Map();
|
|
4681
4680
|
entries.forEach((entry) => {
|
|
4682
|
-
var
|
|
4683
|
-
const value = (
|
|
4681
|
+
var _a25, _b3, _c, _d;
|
|
4682
|
+
const value = (_a25 = entry.value) == null ? void 0 : _a25.trim();
|
|
4684
4683
|
if (!value) return;
|
|
4685
4684
|
const label = ((_b3 = entry.label) == null ? void 0 : _b3.trim()) || value;
|
|
4686
4685
|
const key = normalizeFolderToken(label);
|
|
@@ -4710,16 +4709,16 @@ var normalizeFacetOptions = (entries) => {
|
|
|
4710
4709
|
const options = Array.from(byLabel.values());
|
|
4711
4710
|
const groups = /* @__PURE__ */ new Map();
|
|
4712
4711
|
options.forEach((option) => {
|
|
4713
|
-
var
|
|
4712
|
+
var _a25;
|
|
4714
4713
|
const leaf = getLeafName(option.label || option.value);
|
|
4715
|
-
const list = (
|
|
4714
|
+
const list = (_a25 = groups.get(leaf)) != null ? _a25 : [];
|
|
4716
4715
|
list.push(option);
|
|
4717
4716
|
groups.set(leaf, list);
|
|
4718
4717
|
});
|
|
4719
4718
|
const collapsed = options.filter((option) => {
|
|
4720
|
-
var
|
|
4719
|
+
var _a25;
|
|
4721
4720
|
const leaf = getLeafName(option.label || option.value);
|
|
4722
|
-
const group = (
|
|
4721
|
+
const group = (_a25 = groups.get(leaf)) != null ? _a25 : [];
|
|
4723
4722
|
const hasPathVariant = group.some((entry) => normalizeFolderToken(entry.label).includes("/"));
|
|
4724
4723
|
if (!hasPathVariant) return true;
|
|
4725
4724
|
return normalizeFolderToken(option.label).includes("/");
|
|
@@ -4730,8 +4729,8 @@ var normalizeFacetOptions = (entries) => {
|
|
|
4730
4729
|
var collectFacetOptions = (items, pick, pickLabel) => {
|
|
4731
4730
|
const options = /* @__PURE__ */ new Map();
|
|
4732
4731
|
items.forEach((asset) => {
|
|
4733
|
-
var
|
|
4734
|
-
const value = (
|
|
4732
|
+
var _a25, _b3, _c, _d;
|
|
4733
|
+
const value = (_a25 = pick(asset)) == null ? void 0 : _a25.trim();
|
|
4735
4734
|
if (!value) return;
|
|
4736
4735
|
const current = options.get(value);
|
|
4737
4736
|
options.set(value, {
|
|
@@ -4813,21 +4812,21 @@ var TelescupAssetPicker = ({
|
|
|
4813
4812
|
return folderOptions.find((option) => option.value === folderFilter);
|
|
4814
4813
|
}, [folderFilter, folderOptions]);
|
|
4815
4814
|
const filteredItems = (0, import_react11.useMemo)(() => {
|
|
4816
|
-
var
|
|
4815
|
+
var _a25;
|
|
4817
4816
|
const selectedFolderAliases = new Set(
|
|
4818
|
-
((
|
|
4817
|
+
((_a25 = selectedFolderOption == null ? void 0 : selectedFolderOption.aliases) != null ? _a25 : folderFilter === "all" ? [] : [folderFilter]).map(
|
|
4819
4818
|
(entry) => normalizeFolderToken(entry)
|
|
4820
4819
|
)
|
|
4821
4820
|
);
|
|
4822
4821
|
return items.filter((asset) => {
|
|
4823
|
-
var
|
|
4822
|
+
var _a26, _b3;
|
|
4824
4823
|
if (!matchesAllowedAsset(asset, allowedTypes)) return false;
|
|
4825
4824
|
if (typeFilter !== "all") {
|
|
4826
4825
|
const family = resolveAssetFamily(asset);
|
|
4827
4826
|
if (family !== typeFilter) return false;
|
|
4828
4827
|
}
|
|
4829
4828
|
if (folderFilter !== "all") {
|
|
4830
|
-
const folderIdToken = normalizeFolderToken((
|
|
4829
|
+
const folderIdToken = normalizeFolderToken((_a26 = asset.folderId) != null ? _a26 : "");
|
|
4831
4830
|
const folderNameToken = normalizeFolderToken((_b3 = asset.folderName) != null ? _b3 : "");
|
|
4832
4831
|
if (!selectedFolderAliases.has(folderIdToken) && !selectedFolderAliases.has(folderNameToken)) {
|
|
4833
4832
|
return false;
|
|
@@ -5123,14 +5122,14 @@ function useTelescupUploadQueue(options) {
|
|
|
5123
5122
|
activeRef.current += 1;
|
|
5124
5123
|
updateItem(next.id, { status: "uploading", progress: 0, error: void 0 });
|
|
5125
5124
|
const run = async () => {
|
|
5126
|
-
var
|
|
5125
|
+
var _a25, _b3, _c;
|
|
5127
5126
|
try {
|
|
5128
5127
|
const init = await client.initUpload({
|
|
5129
5128
|
fileName: next.file.name,
|
|
5130
5129
|
size: next.file.size,
|
|
5131
5130
|
mimeType: next.file.type,
|
|
5132
5131
|
folderId,
|
|
5133
|
-
conflict: (
|
|
5132
|
+
conflict: (_a25 = next.conflictPolicy) != null ? _a25 : conflictPolicy
|
|
5134
5133
|
});
|
|
5135
5134
|
const conflictDetected = init.conflict === "ask" || init.conflict === "conflict" || init.conflict === "exists" || init.existingAsset && !init.uploadUrl;
|
|
5136
5135
|
if (conflictDetected) {
|
|
@@ -5329,8 +5328,8 @@ Progress.displayName = ProgressPrimitive.Root.displayName;
|
|
|
5329
5328
|
// src/components/cupcode/TelescupUploader.tsx
|
|
5330
5329
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
5331
5330
|
var formatLabel = (template, values) => template.replace(/\{(\w+)\}/g, (_, key) => {
|
|
5332
|
-
var
|
|
5333
|
-
return (
|
|
5331
|
+
var _a25;
|
|
5332
|
+
return (_a25 = values[key]) != null ? _a25 : "";
|
|
5334
5333
|
});
|
|
5335
5334
|
var suggestRename = (filename) => {
|
|
5336
5335
|
const dot = filename.lastIndexOf(".");
|
|
@@ -5448,7 +5447,7 @@ var TelescupUploader = ({
|
|
|
5448
5447
|
queue.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Button, { variant: "ghost", size: "sm", onClick: clearFinished, children: labels.uploader.clearFinished }) : null
|
|
5449
5448
|
] }),
|
|
5450
5449
|
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "space-y-3", children: queue.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "rounded-md border border-border bg-muted/30 p-4 text-sm text-muted-foreground", children: labels.uploader.ready }) : queue.map((item) => {
|
|
5451
|
-
var
|
|
5450
|
+
var _a25;
|
|
5452
5451
|
const suggestedName = item.suggestedName || suggestRename(item.file.name);
|
|
5453
5452
|
const conflictDescription = formatLabel(labels.conflict.descriptionWithSuggestion, {
|
|
5454
5453
|
filename: item.file.name,
|
|
@@ -5469,7 +5468,7 @@ var TelescupUploader = ({
|
|
|
5469
5468
|
item.status === "conflict" ? /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "mt-3 space-y-3 rounded-md border border-amber-500/30 bg-amber-500/5 p-3", children: [
|
|
5470
5469
|
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { className: "text-sm text-foreground", children: conflictDescription }),
|
|
5471
5470
|
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { className: "text-xs text-muted-foreground", children: formatLabel(labels.conflict.queueHint, { filename: item.file.name }) }),
|
|
5472
|
-
((
|
|
5471
|
+
((_a25 = item.existingAsset) == null ? void 0 : _a25.id) ? /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "rounded-md border border-border bg-muted/30 p-3", children: [
|
|
5473
5472
|
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { className: "text-xs font-semibold text-muted-foreground", children: labels.conflict.existingLabel }),
|
|
5474
5473
|
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { className: "mt-1 truncate text-xs text-foreground", children: item.existingAsset.name || item.existingAsset.fileName || item.existingAsset.id }),
|
|
5475
5474
|
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "mt-2 h-28 overflow-hidden rounded-md", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
@@ -5717,7 +5716,7 @@ var DEFAULT_LABELS = {
|
|
|
5717
5716
|
}
|
|
5718
5717
|
};
|
|
5719
5718
|
var mergeLabels = (overrides) => {
|
|
5720
|
-
var
|
|
5719
|
+
var _a25;
|
|
5721
5720
|
if (!overrides) return DEFAULT_LABELS;
|
|
5722
5721
|
return {
|
|
5723
5722
|
...DEFAULT_LABELS,
|
|
@@ -5731,7 +5730,7 @@ var mergeLabels = (overrides) => {
|
|
|
5731
5730
|
meta: {
|
|
5732
5731
|
...DEFAULT_LABELS.meta,
|
|
5733
5732
|
...overrides.meta,
|
|
5734
|
-
fields: { ...DEFAULT_LABELS.meta.fields, ...(
|
|
5733
|
+
fields: { ...DEFAULT_LABELS.meta.fields, ...(_a25 = overrides.meta) == null ? void 0 : _a25.fields }
|
|
5735
5734
|
},
|
|
5736
5735
|
toasts: { ...DEFAULT_LABELS.toasts, ...overrides.toasts }
|
|
5737
5736
|
};
|
|
@@ -5750,9 +5749,9 @@ var normalizeApiLanguageKey = (value) => {
|
|
|
5750
5749
|
return "pt-BR";
|
|
5751
5750
|
};
|
|
5752
5751
|
var getAssetMeta = (asset, lang) => {
|
|
5753
|
-
var
|
|
5752
|
+
var _a25, _b3;
|
|
5754
5753
|
if (!asset) return {};
|
|
5755
|
-
if ((
|
|
5754
|
+
if ((_a25 = asset.metaByLang) == null ? void 0 : _a25[lang]) return asset.metaByLang[lang];
|
|
5756
5755
|
return (_b3 = asset.meta) != null ? _b3 : {};
|
|
5757
5756
|
};
|
|
5758
5757
|
var TelescupMetaEditor = ({
|
|
@@ -5763,8 +5762,8 @@ var TelescupMetaEditor = ({
|
|
|
5763
5762
|
labels,
|
|
5764
5763
|
onAssetUpdated
|
|
5765
5764
|
}) => {
|
|
5766
|
-
var
|
|
5767
|
-
const [activeAssetId, setActiveAssetId] = (0, import_react14.useState)((_b3 = (
|
|
5765
|
+
var _a25, _b3, _c, _d, _e, _f, _g, _h;
|
|
5766
|
+
const [activeAssetId, setActiveAssetId] = (0, import_react14.useState)((_b3 = (_a25 = assets[0]) == null ? void 0 : _a25.id) != null ? _b3 : "");
|
|
5768
5767
|
const [activeLang, setActiveLang] = (0, import_react14.useState)(
|
|
5769
5768
|
LANGUAGES.includes(defaultLanguage) ? defaultLanguage : "pt"
|
|
5770
5769
|
);
|
|
@@ -5782,18 +5781,18 @@ var TelescupMetaEditor = ({
|
|
|
5782
5781
|
}, [activeAssetId, assets]);
|
|
5783
5782
|
const asset = assets.find((item) => item.id === activeAssetId);
|
|
5784
5783
|
const currentDraft = (0, import_react14.useMemo)(() => {
|
|
5785
|
-
var
|
|
5786
|
-
const existing = (
|
|
5784
|
+
var _a26;
|
|
5785
|
+
const existing = (_a26 = drafts[activeAssetId]) == null ? void 0 : _a26[activeLang];
|
|
5787
5786
|
if (existing) return existing;
|
|
5788
5787
|
return getAssetMeta(asset, activeLang);
|
|
5789
5788
|
}, [activeAssetId, activeLang, asset, drafts]);
|
|
5790
5789
|
const updateDraft = (field, value) => {
|
|
5791
5790
|
setDrafts((prev) => {
|
|
5792
|
-
var
|
|
5791
|
+
var _a26;
|
|
5793
5792
|
return {
|
|
5794
5793
|
...prev,
|
|
5795
5794
|
[activeAssetId]: {
|
|
5796
|
-
...(
|
|
5795
|
+
...(_a26 = prev[activeAssetId]) != null ? _a26 : {},
|
|
5797
5796
|
[activeLang]: {
|
|
5798
5797
|
...currentDraft,
|
|
5799
5798
|
[field]: value
|
|
@@ -5861,11 +5860,11 @@ var TelescupMetaEditor = ({
|
|
|
5861
5860
|
onAssetUpdated == null ? void 0 : onAssetUpdated(updated);
|
|
5862
5861
|
const updatedMeta = getAssetMeta(updated, activeLang);
|
|
5863
5862
|
setDrafts((prev) => {
|
|
5864
|
-
var
|
|
5863
|
+
var _a26;
|
|
5865
5864
|
return {
|
|
5866
5865
|
...prev,
|
|
5867
5866
|
[asset.id]: {
|
|
5868
|
-
...(
|
|
5867
|
+
...(_a26 = prev[asset.id]) != null ? _a26 : {},
|
|
5869
5868
|
[activeLang]: updatedMeta
|
|
5870
5869
|
}
|
|
5871
5870
|
};
|
|
@@ -6031,9 +6030,9 @@ var TelescupUpload = ({
|
|
|
6031
6030
|
}, []);
|
|
6032
6031
|
const enrichUploadedAsset = (0, import_react14.useCallback)(
|
|
6033
6032
|
async (asset) => {
|
|
6034
|
-
var
|
|
6033
|
+
var _a25, _b3, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
6035
6034
|
if (!autoGenerateMetadataOnUpload) return asset;
|
|
6036
|
-
const mimeType = (_b3 = (
|
|
6035
|
+
const mimeType = (_b3 = (_a25 = asset.mimeType) == null ? void 0 : _a25.toLowerCase()) != null ? _b3 : "";
|
|
6037
6036
|
const assetType = (_d = (_c = asset.type) == null ? void 0 : _c.toLowerCase()) != null ? _d : "";
|
|
6038
6037
|
const isImage = assetType === "image" || mimeType.startsWith("image/");
|
|
6039
6038
|
if (!isImage) return asset;
|
|
@@ -6297,16 +6296,16 @@ var toStringOrUndefined = (value) => {
|
|
|
6297
6296
|
};
|
|
6298
6297
|
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6299
6298
|
var resolveAccountsApiBaseUrl = () => {
|
|
6300
|
-
var
|
|
6301
|
-
const appsApiBase = ((_b3 = (
|
|
6299
|
+
var _a25, _b3, _c, _d;
|
|
6300
|
+
const appsApiBase = ((_b3 = (_a25 = getRuntimeEnv("VITE_APPS_API_BASE_URL")) != null ? _a25 : getRuntimeEnv("VITE_APPS_API_BASE")) != null ? _b3 : "").trim().replace(/\/+$/, "");
|
|
6302
6301
|
if (appsApiBase) return `${appsApiBase}/api/accounts`;
|
|
6303
6302
|
const accountsBase = ((_c = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _c : "https://accounts.cupcode.com.br").trim().replace(/\/+$/, "");
|
|
6304
6303
|
const accountsApi = ((_d = getRuntimeEnv("VITE_ACCOUNTS_API_BASE_URL")) != null ? _d : "").trim().replace(/\/+$/, "");
|
|
6305
6304
|
return accountsApi || accountsBase;
|
|
6306
6305
|
};
|
|
6307
6306
|
var parseBrowserFromUserAgent = (userAgent) => {
|
|
6308
|
-
var
|
|
6309
|
-
const ua = (
|
|
6307
|
+
var _a25;
|
|
6308
|
+
const ua = (_a25 = userAgent == null ? void 0 : userAgent.trim()) != null ? _a25 : "";
|
|
6310
6309
|
if (!ua) return "Desconhecido";
|
|
6311
6310
|
if (/Edg\//.test(ua)) return "Edge";
|
|
6312
6311
|
if (/Chrome\//.test(ua)) return "Chrome";
|
|
@@ -6316,8 +6315,8 @@ var parseBrowserFromUserAgent = (userAgent) => {
|
|
|
6316
6315
|
return ua.split(" ")[0] || "Desconhecido";
|
|
6317
6316
|
};
|
|
6318
6317
|
var parseOsFromUserAgent = (userAgent) => {
|
|
6319
|
-
var
|
|
6320
|
-
const ua = (
|
|
6318
|
+
var _a25;
|
|
6319
|
+
const ua = (_a25 = userAgent == null ? void 0 : userAgent.trim()) != null ? _a25 : "";
|
|
6321
6320
|
if (!ua) return null;
|
|
6322
6321
|
if (/Windows NT/.test(ua)) return "Windows";
|
|
6323
6322
|
if (/Mac OS X/.test(ua)) return "macOS";
|
|
@@ -6329,8 +6328,8 @@ var parseOsFromUserAgent = (userAgent) => {
|
|
|
6329
6328
|
var normalizeLoginHistorySessions = (value) => {
|
|
6330
6329
|
if (!Array.isArray(value)) return [];
|
|
6331
6330
|
return value.filter(isRecord).map((row, index) => {
|
|
6332
|
-
var
|
|
6333
|
-
const id = (
|
|
6331
|
+
var _a25, _b3, _c, _d, _e, _f;
|
|
6332
|
+
const id = (_a25 = toStringOrUndefined(row.id)) != null ? _a25 : `session-${index}`;
|
|
6334
6333
|
return {
|
|
6335
6334
|
id,
|
|
6336
6335
|
createdAt: (_b3 = toStringOrUndefined(row.created_at)) != null ? _b3 : toStringOrUndefined(row.createdAt),
|
|
@@ -6350,18 +6349,18 @@ var isLoginHistorySessionActive = (session, now = Date.now()) => {
|
|
|
6350
6349
|
return Boolean(session.active) && expiresAt2 > now;
|
|
6351
6350
|
};
|
|
6352
6351
|
var readStoredAccessToken = () => {
|
|
6353
|
-
var
|
|
6352
|
+
var _a25;
|
|
6354
6353
|
if (typeof window === "undefined") return null;
|
|
6355
6354
|
const keys = ["cc_access_token", "access_token"];
|
|
6356
6355
|
for (const key of keys) {
|
|
6357
|
-
const value = (
|
|
6356
|
+
const value = (_a25 = window.sessionStorage.getItem(key)) == null ? void 0 : _a25.trim();
|
|
6358
6357
|
if (value) return value;
|
|
6359
6358
|
}
|
|
6360
6359
|
return null;
|
|
6361
6360
|
};
|
|
6362
6361
|
async function fetchAccountsLoginHistory(options) {
|
|
6363
|
-
var
|
|
6364
|
-
const base = ((
|
|
6362
|
+
var _a25;
|
|
6363
|
+
const base = ((_a25 = options == null ? void 0 : options.accountsApiBaseUrl) != null ? _a25 : resolveAccountsApiBaseUrl()).replace(/\/+$/, "");
|
|
6365
6364
|
const resolveToken = async () => {
|
|
6366
6365
|
if (options == null ? void 0 : options.getAccessToken) {
|
|
6367
6366
|
try {
|
|
@@ -6453,13 +6452,13 @@ var LoginHistoryCupcode = ({
|
|
|
6453
6452
|
);
|
|
6454
6453
|
}
|
|
6455
6454
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: cn(isCompact ? "space-y-1.5" : "space-y-2", className), children: visibleSessions.map((session, index) => {
|
|
6456
|
-
var
|
|
6455
|
+
var _a25;
|
|
6457
6456
|
const browser = parseBrowserFromUserAgent(session.userAgent);
|
|
6458
6457
|
const os = parseOsFromUserAgent(session.userAgent);
|
|
6459
6458
|
const isActive = isLoginHistorySessionActive(session);
|
|
6460
6459
|
const loginLabel = formatDateTime(session.createdAt);
|
|
6461
6460
|
const lastSeenLabel = formatDateTime(session.lastSeen);
|
|
6462
|
-
const ip = ((
|
|
6461
|
+
const ip = ((_a25 = session.ip) == null ? void 0 : _a25.trim()) || "unknown";
|
|
6463
6462
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
6464
6463
|
"div",
|
|
6465
6464
|
{
|
|
@@ -6546,14 +6545,14 @@ function parseStoredThemePreference(value) {
|
|
|
6546
6545
|
return value === "light" || value === "dark" || value === "system" ? value : null;
|
|
6547
6546
|
}
|
|
6548
6547
|
function normalizeStoredThemePreference(value) {
|
|
6549
|
-
var
|
|
6550
|
-
return (
|
|
6548
|
+
var _a25;
|
|
6549
|
+
return (_a25 = parseStoredThemePreference(value)) != null ? _a25 : "system";
|
|
6551
6550
|
}
|
|
6552
6551
|
function readStoredThemeMode() {
|
|
6553
|
-
var
|
|
6552
|
+
var _a25;
|
|
6554
6553
|
if (typeof window === "undefined") return null;
|
|
6555
6554
|
try {
|
|
6556
|
-
const storedTheme = (
|
|
6555
|
+
const storedTheme = (_a25 = window.localStorage.getItem(THEME_STORAGE_KEY)) != null ? _a25 : window.localStorage.getItem(LEGACY_THEME_STORAGE_KEY);
|
|
6557
6556
|
return isStoredThemeMode(storedTheme) ? storedTheme : null;
|
|
6558
6557
|
} catch (e) {
|
|
6559
6558
|
return null;
|
|
@@ -6609,7 +6608,7 @@ function persistThemePreferenceSelection(preference) {
|
|
|
6609
6608
|
);
|
|
6610
6609
|
}
|
|
6611
6610
|
function resolveStoredThemePreference(experienceSettingsTheme) {
|
|
6612
|
-
var
|
|
6611
|
+
var _a25;
|
|
6613
6612
|
if (typeof window === "undefined") {
|
|
6614
6613
|
return normalizeStoredThemePreference(experienceSettingsTheme);
|
|
6615
6614
|
}
|
|
@@ -6625,7 +6624,7 @@ function resolveStoredThemePreference(experienceSettingsTheme) {
|
|
|
6625
6624
|
if (parsedExperienceTheme === "system" && storedThemeMode) {
|
|
6626
6625
|
return storedThemeMode;
|
|
6627
6626
|
}
|
|
6628
|
-
return (
|
|
6627
|
+
return (_a25 = parsedExperienceTheme != null ? parsedExperienceTheme : storedThemeMode) != null ? _a25 : "system";
|
|
6629
6628
|
} catch (e) {
|
|
6630
6629
|
return normalizeStoredThemePreference(experienceSettingsTheme);
|
|
6631
6630
|
}
|
|
@@ -6699,9 +6698,9 @@ var applyThemePreference = (preference) => {
|
|
|
6699
6698
|
persistThemePreferenceSelection(preference);
|
|
6700
6699
|
};
|
|
6701
6700
|
var resolveTelescupImageUrl = (value, options) => {
|
|
6702
|
-
var
|
|
6701
|
+
var _a25, _b3, _c;
|
|
6703
6702
|
return resolveTelescupImageURL(value, {
|
|
6704
|
-
width: (
|
|
6703
|
+
width: (_a25 = options == null ? void 0 : options.width) != null ? _a25 : 96,
|
|
6705
6704
|
height: (_b3 = options == null ? void 0 : options.height) != null ? _b3 : 96,
|
|
6706
6705
|
fit: "cover",
|
|
6707
6706
|
format: "avif",
|
|
@@ -6709,8 +6708,8 @@ var resolveTelescupImageUrl = (value, options) => {
|
|
|
6709
6708
|
});
|
|
6710
6709
|
};
|
|
6711
6710
|
var resolveProfileAvatarFromTelescup = (asset, fallbackId) => {
|
|
6712
|
-
var
|
|
6713
|
-
return (_b3 = (
|
|
6711
|
+
var _a25, _b3;
|
|
6712
|
+
return (_b3 = (_a25 = resolveTelescupImageUrl(asset == null ? void 0 : asset.url, { width: 384, height: 384, quality: 80 })) != null ? _a25 : resolveTelescupImageUrl(asset == null ? void 0 : asset.id, { width: 384, height: 384, quality: 80 })) != null ? _b3 : resolveTelescupImageUrl(fallbackId, { width: 384, height: 384, quality: 80 });
|
|
6714
6713
|
};
|
|
6715
6714
|
var normalizeLanguage = (value) => {
|
|
6716
6715
|
const normalized = value == null ? void 0 : value.trim().toLowerCase();
|
|
@@ -6935,9 +6934,9 @@ var UserMenuCupcode = ({
|
|
|
6935
6934
|
};
|
|
6936
6935
|
const handleProfileAvatarChange = (0, import_react16.useCallback)(
|
|
6937
6936
|
async (ids, assets) => {
|
|
6938
|
-
var
|
|
6937
|
+
var _a25, _b3, _c;
|
|
6939
6938
|
const selectedAsset = assets == null ? void 0 : assets[0];
|
|
6940
|
-
const selectedIdRaw = (
|
|
6939
|
+
const selectedIdRaw = (_a25 = ids[0]) == null ? void 0 : _a25.trim();
|
|
6941
6940
|
const selectedId = (_c = (_b3 = parseAssetId(selectedIdRaw)) != null ? _b3 : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.id)) != null ? _c : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.url);
|
|
6942
6941
|
if (!selectedId) {
|
|
6943
6942
|
toast({
|
|
@@ -6980,7 +6979,7 @@ var UserMenuCupcode = ({
|
|
|
6980
6979
|
[isProfileAvatarSaving, onProfileAvatarChange, resolvedProfileAvatarUrl]
|
|
6981
6980
|
);
|
|
6982
6981
|
const renderDefaultPanel = () => {
|
|
6983
|
-
var
|
|
6982
|
+
var _a25;
|
|
6984
6983
|
if (activeTab === "profile") {
|
|
6985
6984
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "space-y-4", children: [
|
|
6986
6985
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "pt-1 text-center", children: [
|
|
@@ -7150,7 +7149,7 @@ var UserMenuCupcode = ({
|
|
|
7150
7149
|
"Idioma"
|
|
7151
7150
|
] }),
|
|
7152
7151
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "mt-2", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(Select, { value: resolvedLanguage, onValueChange: (value) => changeLanguage(value), children: [
|
|
7153
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(SelectTrigger, { className: "h-9 rounded-md border-border/70 bg-background/55 text-[11px] text-foreground shadow-none", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "truncate", children: (
|
|
7152
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(SelectTrigger, { className: "h-9 rounded-md border-border/70 bg-background/55 text-[11px] text-foreground shadow-none", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "truncate", children: (_a25 = LANGUAGE_OPTIONS.find((option) => option.value === resolvedLanguage)) == null ? void 0 : _a25.label }) }),
|
|
7154
7153
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(SelectContent, { className: "z-[820] rounded-md border border-border/70 bg-background text-foreground shadow-none", children: LANGUAGE_OPTIONS.map((option) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(SelectItem, { value: option.value, className: "text-xs", children: option.label }, option.value)) })
|
|
7155
7154
|
] }) })
|
|
7156
7155
|
] }) })
|
|
@@ -7937,10 +7936,10 @@ var ignoreLoopbackUrlOnPublicOrigin = (value) => {
|
|
|
7937
7936
|
return isLoopbackUrl(value) ? void 0 : value;
|
|
7938
7937
|
};
|
|
7939
7938
|
var getAppsApiBaseUrl = () => {
|
|
7940
|
-
var
|
|
7939
|
+
var _a25, _b3;
|
|
7941
7940
|
return normalizeBaseUrl2(
|
|
7942
7941
|
(_b3 = ignoreLoopbackUrlOnPublicOrigin(
|
|
7943
|
-
(
|
|
7942
|
+
(_a25 = getRuntimeEnv("VITE_APPS_API_BASE_URL")) != null ? _a25 : getRuntimeEnv("VITE_APPS_API_BASE")
|
|
7944
7943
|
)) != null ? _b3 : "https://api.apps.cupcode.com.br"
|
|
7945
7944
|
);
|
|
7946
7945
|
};
|
|
@@ -7973,15 +7972,15 @@ var fetchWithTimeout = async (input, init, timeoutMs = AUTH_REQUEST_TIMEOUT_MS)
|
|
|
7973
7972
|
}
|
|
7974
7973
|
};
|
|
7975
7974
|
var resolveIssuerBaseUrl = () => {
|
|
7976
|
-
var
|
|
7977
|
-
const issuer = (
|
|
7975
|
+
var _a25;
|
|
7976
|
+
const issuer = (_a25 = ignoreLoopbackUrlOnPublicOrigin(getRuntimeEnv("VITE_OIDC_ISSUER"))) != null ? _a25 : ignoreLoopbackUrlOnPublicOrigin(getRuntimeEnv("VITE_ACCOUNTS_BASE_URL"));
|
|
7978
7977
|
return issuer ? normalizeBaseUrl2(issuer) : void 0;
|
|
7979
7978
|
};
|
|
7980
7979
|
var getAccountsConfig = () => {
|
|
7981
|
-
var
|
|
7980
|
+
var _a25, _b3, _c, _d;
|
|
7982
7981
|
const issuerBaseUrl = resolveIssuerBaseUrl();
|
|
7983
7982
|
const baseUrl = normalizeBaseUrl2(
|
|
7984
|
-
(
|
|
7983
|
+
(_a25 = issuerBaseUrl != null ? issuerBaseUrl : getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a25 : "https://accounts.cupcode.com.br"
|
|
7985
7984
|
);
|
|
7986
7985
|
const clientId = getRuntimeEnv("VITE_ACCOUNTS_CLIENT_ID");
|
|
7987
7986
|
if (!clientId) {
|
|
@@ -8008,7 +8007,7 @@ var getAccountsConfig = () => {
|
|
|
8008
8007
|
};
|
|
8009
8008
|
var cachedDiscovery = null;
|
|
8010
8009
|
var resolveOidcEndpoints = async (config) => {
|
|
8011
|
-
var
|
|
8010
|
+
var _a25, _b3, _c, _d, _e, _f;
|
|
8012
8011
|
if (config.authUrl && config.tokenUrl) {
|
|
8013
8012
|
return {
|
|
8014
8013
|
authUrl: config.authUrl,
|
|
@@ -8018,7 +8017,7 @@ var resolveOidcEndpoints = async (config) => {
|
|
|
8018
8017
|
}
|
|
8019
8018
|
if (cachedDiscovery) {
|
|
8020
8019
|
return {
|
|
8021
|
-
authUrl: (
|
|
8020
|
+
authUrl: (_a25 = cachedDiscovery.authorization_endpoint) != null ? _a25 : config.authUrl,
|
|
8022
8021
|
tokenUrl: (_b3 = cachedDiscovery.token_endpoint) != null ? _b3 : config.tokenUrl,
|
|
8023
8022
|
logoutUrl: (_c = cachedDiscovery.end_session_endpoint) != null ? _c : config.logoutUrl
|
|
8024
8023
|
};
|
|
@@ -8228,10 +8227,10 @@ var resolveLocalTelescupRedirectUri = () => {
|
|
|
8228
8227
|
return `${window.location.protocol}//localhost:${port}/oidc/callback`;
|
|
8229
8228
|
};
|
|
8230
8229
|
var readStorageItem = (key) => {
|
|
8231
|
-
var
|
|
8230
|
+
var _a25;
|
|
8232
8231
|
if (!canUseWindow()) return null;
|
|
8233
8232
|
try {
|
|
8234
|
-
return (
|
|
8233
|
+
return (_a25 = window.sessionStorage.getItem(key)) != null ? _a25 : window.localStorage.getItem(key);
|
|
8235
8234
|
} catch (e) {
|
|
8236
8235
|
return null;
|
|
8237
8236
|
}
|
|
@@ -8341,10 +8340,10 @@ var getPopupOrigin = () => {
|
|
|
8341
8340
|
return window.location.origin;
|
|
8342
8341
|
};
|
|
8343
8342
|
var getTelescupAccountsConfig = () => {
|
|
8344
|
-
var
|
|
8343
|
+
var _a25, _b3, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
8345
8344
|
const primary = getAccountsConfig();
|
|
8346
8345
|
const runtimeRedirectUri = ignoreLoopbackUrlOnPublicOrigin2(
|
|
8347
|
-
(
|
|
8346
|
+
(_a25 = getRuntimeEnv("VITE_TELESCUP_ACCOUNTS_REDIRECT_URI")) != null ? _a25 : getRuntimeEnv("VITE_TELESCUP_OIDC_REDIRECT_URI")
|
|
8348
8347
|
);
|
|
8349
8348
|
const fallbackRedirectUri = canUseWindow() ? `${window.location.origin}/oidc/callback` : "http://localhost:8083/oidc/callback";
|
|
8350
8349
|
const redirectUri = isLocalBrowserOrigin2() && runtimeRedirectUri && !runtimeRedirectUri.includes("localhost") ? resolveLocalTelescupRedirectUri() : runtimeRedirectUri != null ? runtimeRedirectUri : fallbackRedirectUri;
|
|
@@ -8362,8 +8361,8 @@ var getTelescupAccountsConfig = () => {
|
|
|
8362
8361
|
};
|
|
8363
8362
|
};
|
|
8364
8363
|
var buildTokenBundle = (tokens, config, previous) => {
|
|
8365
|
-
var
|
|
8366
|
-
const idToken = ((
|
|
8364
|
+
var _a25, _b3, _c, _d, _e, _f;
|
|
8365
|
+
const idToken = ((_a25 = tokens.id_token) == null ? void 0 : _a25.trim()) || (previous == null ? void 0 : previous.idToken) || "";
|
|
8367
8366
|
if (!idToken) {
|
|
8368
8367
|
throw new Error("Token ID do Telescup n\xE3o retornado pelo Accounts.");
|
|
8369
8368
|
}
|
|
@@ -8410,10 +8409,10 @@ var centerPopupFeatures = () => {
|
|
|
8410
8409
|
return `popup,width=${width},height=${height},left=${left},top=${top},resizable=yes,scrollbars=yes`;
|
|
8411
8410
|
};
|
|
8412
8411
|
var notifyOpener = (result) => {
|
|
8413
|
-
var
|
|
8412
|
+
var _a25;
|
|
8414
8413
|
if (!canUseWindow()) return;
|
|
8415
8414
|
try {
|
|
8416
|
-
(
|
|
8415
|
+
(_a25 = window.opener) == null ? void 0 : _a25.postMessage(result, getPopupOrigin());
|
|
8417
8416
|
} catch (e) {
|
|
8418
8417
|
}
|
|
8419
8418
|
};
|
|
@@ -8522,7 +8521,7 @@ var ensureTelescupOidcToken = async () => {
|
|
|
8522
8521
|
return pendingTokenPromise;
|
|
8523
8522
|
};
|
|
8524
8523
|
var completeTelescupOidcCallback = async () => {
|
|
8525
|
-
var
|
|
8524
|
+
var _a25;
|
|
8526
8525
|
if (!canUseWindow()) {
|
|
8527
8526
|
return { ok: false, error: "Callback do Telescup indispon\xEDvel fora do navegador." };
|
|
8528
8527
|
}
|
|
@@ -8551,7 +8550,7 @@ var completeTelescupOidcCallback = async () => {
|
|
|
8551
8550
|
throw new Error("Token endpoint do Telescup n\xE3o encontrado.");
|
|
8552
8551
|
}
|
|
8553
8552
|
const tokens = await exchangeCodeForToken(config, tokenUrl, code, flow.verifier);
|
|
8554
|
-
const nonce = String(((
|
|
8553
|
+
const nonce = String(((_a25 = decodeJwt(tokens.id_token)) == null ? void 0 : _a25.nonce) || "").trim();
|
|
8555
8554
|
if (!nonce || nonce !== flow.nonce) {
|
|
8556
8555
|
throw new Error("Nonce inv\xE1lido no callback do Telescup.");
|
|
8557
8556
|
}
|
|
@@ -8576,8 +8575,8 @@ var TELESCUP_CDN_HOSTS = /* @__PURE__ */ new Set([
|
|
|
8576
8575
|
"cdn.cupcode.com.br"
|
|
8577
8576
|
]);
|
|
8578
8577
|
var resolveAppsApiBaseUrl = () => {
|
|
8579
|
-
var
|
|
8580
|
-
return ((_b3 = (
|
|
8578
|
+
var _a25, _b3;
|
|
8579
|
+
return ((_b3 = (_a25 = getRuntimeEnv("VITE_APPS_API_BASE_URL")) != null ? _a25 : getRuntimeEnv("VITE_APPS_API_BASE")) != null ? _b3 : "").trim().replace(/\/+$/, "");
|
|
8581
8580
|
};
|
|
8582
8581
|
var isTelescupCdnUrl = (value) => {
|
|
8583
8582
|
const normalized = value == null ? void 0 : value.trim();
|
|
@@ -8589,10 +8588,10 @@ var isTelescupCdnUrl = (value) => {
|
|
|
8589
8588
|
}
|
|
8590
8589
|
};
|
|
8591
8590
|
var resolveTelescupBaseUrl = () => {
|
|
8592
|
-
var
|
|
8591
|
+
var _a25;
|
|
8593
8592
|
const appsApiBase = resolveAppsApiBaseUrl();
|
|
8594
8593
|
const apiFromApps = appsApiBase ? `${appsApiBase}/api/telescup` : "";
|
|
8595
|
-
const explicitBase = (
|
|
8594
|
+
const explicitBase = (_a25 = getRuntimeEnv("VITE_TELESCUP_BASE_URL")) == null ? void 0 : _a25.trim();
|
|
8596
8595
|
if (explicitBase && !isTelescupCdnUrl(explicitBase)) {
|
|
8597
8596
|
return explicitBase.replace(/\/+$/, "");
|
|
8598
8597
|
}
|
|
@@ -8601,17 +8600,17 @@ var resolveTelescupBaseUrl = () => {
|
|
|
8601
8600
|
var ACCESS_TOKEN_STORAGE_KEY = "cc_access_token";
|
|
8602
8601
|
var ID_TOKEN_STORAGE_KEYS = ["cc_id_token", "id_token"];
|
|
8603
8602
|
var isJwtUsable = (token, skewMs = 5e3) => {
|
|
8604
|
-
var
|
|
8603
|
+
var _a25;
|
|
8605
8604
|
const claims = decodeJwt(token);
|
|
8606
|
-
const exp = Number((
|
|
8605
|
+
const exp = Number((_a25 = claims == null ? void 0 : claims.exp) != null ? _a25 : 0);
|
|
8607
8606
|
if (!Number.isFinite(exp) || exp <= 0) return true;
|
|
8608
8607
|
return exp * 1e3 > Date.now() + skewMs;
|
|
8609
8608
|
};
|
|
8610
8609
|
var readStoredIdToken2 = () => {
|
|
8611
|
-
var
|
|
8610
|
+
var _a25;
|
|
8612
8611
|
if (typeof window === "undefined") return null;
|
|
8613
8612
|
for (const key of ID_TOKEN_STORAGE_KEYS) {
|
|
8614
|
-
const value = (
|
|
8613
|
+
const value = (_a25 = sessionStorage.getItem(key)) == null ? void 0 : _a25.trim();
|
|
8615
8614
|
if (value) return value;
|
|
8616
8615
|
}
|
|
8617
8616
|
return null;
|
|
@@ -8645,25 +8644,25 @@ var resolveCurrentUserId = (user) => {
|
|
|
8645
8644
|
return null;
|
|
8646
8645
|
};
|
|
8647
8646
|
var resolveUserIdFromClaims = (claims) => {
|
|
8648
|
-
var
|
|
8649
|
-
return (_e = (_d = (_c = (_b3 = (
|
|
8647
|
+
var _a25, _b3, _c, _d, _e;
|
|
8648
|
+
return (_e = (_d = (_c = (_b3 = (_a25 = toStringOrUndefined2(claims.sub)) != null ? _a25 : toStringOrUndefined2(claims.user_id)) != null ? _b3 : toStringOrUndefined2(claims.userId)) != null ? _c : toStringOrUndefined2(claims.uid)) != null ? _d : toStringOrUndefined2(claims.id)) != null ? _e : toStringOrUndefined2(claims["https://cupcode.com/user_id"]);
|
|
8650
8649
|
};
|
|
8651
8650
|
var resolveEmailFromClaims = (claims) => {
|
|
8652
|
-
var
|
|
8653
|
-
const candidate = (_b3 = (
|
|
8651
|
+
var _a25, _b3;
|
|
8652
|
+
const candidate = (_b3 = (_a25 = toStringOrUndefined2(claims.email)) != null ? _a25 : toStringOrUndefined2(claims["https://cupcode.com/email"])) != null ? _b3 : toStringOrUndefined2(claims.preferred_username);
|
|
8654
8653
|
if (!candidate || !candidate.includes("@")) return void 0;
|
|
8655
8654
|
return candidate.toLowerCase();
|
|
8656
8655
|
};
|
|
8657
8656
|
var normalizeTenantId = (value) => {
|
|
8658
|
-
var
|
|
8659
|
-
const normalized = (
|
|
8657
|
+
var _a25;
|
|
8658
|
+
const normalized = (_a25 = toStringOrUndefined2(value)) == null ? void 0 : _a25.toLowerCase();
|
|
8660
8659
|
if (!normalized) return void 0;
|
|
8661
8660
|
return normalized.replace(/^@/, "");
|
|
8662
8661
|
};
|
|
8663
8662
|
var resolveTenantIdFromClaims = (claims) => {
|
|
8664
|
-
var
|
|
8663
|
+
var _a25, _b3, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
8665
8664
|
return normalizeTenantId(
|
|
8666
|
-
(_j = (_i = (_h = (_g = (_f = (_e = (_d = (_c = (_b3 = (
|
|
8665
|
+
(_j = (_i = (_h = (_g = (_f = (_e = (_d = (_c = (_b3 = (_a25 = toStringOrUndefined2(claims.tenant_id)) != null ? _a25 : toStringOrUndefined2(claims.tenantId)) != null ? _b3 : toStringOrUndefined2(claims.tenant_slug)) != null ? _c : toStringOrUndefined2(claims.tenantSlug)) != null ? _d : toStringOrUndefined2(claims.company_slug)) != null ? _e : toStringOrUndefined2(claims.companySlug)) != null ? _f : toStringOrUndefined2(claims.company)) != null ? _g : toStringOrUndefined2(claims.org_slug)) != null ? _h : toStringOrUndefined2(claims.orgSlug)) != null ? _i : toStringOrUndefined2(claims["https://cupcode.com/tenant_id"])) != null ? _j : toStringOrUndefined2(claims["https://cupcode.com/tenant_slug"])
|
|
8667
8666
|
);
|
|
8668
8667
|
};
|
|
8669
8668
|
var AVATAR_IMAGE_OPTIONS = {
|
|
@@ -8674,8 +8673,8 @@ var AVATAR_IMAGE_OPTIONS = {
|
|
|
8674
8673
|
quality: 80
|
|
8675
8674
|
};
|
|
8676
8675
|
var resolveAvatarPreviewUrl = (asset, fallback) => {
|
|
8677
|
-
var
|
|
8678
|
-
return (_c = (_b3 = (
|
|
8676
|
+
var _a25, _b3, _c;
|
|
8677
|
+
return (_c = (_b3 = (_a25 = resolveTelescupImageURL(asset == null ? void 0 : asset.thumb_url, AVATAR_IMAGE_OPTIONS)) != null ? _a25 : resolveTelescupImageURL(asset == null ? void 0 : asset.preview_url, AVATAR_IMAGE_OPTIONS)) != null ? _b3 : resolveTelescupImageURL(asset == null ? void 0 : asset.url, AVATAR_IMAGE_OPTIONS)) != null ? _c : resolveTelescupImageURL(fallback, AVATAR_IMAGE_OPTIONS);
|
|
8679
8678
|
};
|
|
8680
8679
|
var isGenericRecord = (value) => typeof value === "object" && value !== null;
|
|
8681
8680
|
var buildExternalUrl = (baseUrl, target) => {
|
|
@@ -8708,11 +8707,11 @@ var normalizeMenuLanguage = (value) => {
|
|
|
8708
8707
|
return "pt-BR";
|
|
8709
8708
|
};
|
|
8710
8709
|
var resolveMenuLanguageFromRecord = (record) => {
|
|
8711
|
-
var
|
|
8710
|
+
var _a25, _b3, _c, _d, _e;
|
|
8712
8711
|
if (!record) return void 0;
|
|
8713
8712
|
const profile = isGenericRecord(record.profile) ? record.profile : null;
|
|
8714
8713
|
const preferences = isGenericRecord(record.preferences) ? record.preferences : null;
|
|
8715
|
-
const rawLanguage = (_e = (_d = (_c = (_b3 = (
|
|
8714
|
+
const rawLanguage = (_e = (_d = (_c = (_b3 = (_a25 = record.language) != null ? _a25 : record.locale) != null ? _b3 : profile == null ? void 0 : profile.language) != null ? _c : profile == null ? void 0 : profile.locale) != null ? _d : preferences == null ? void 0 : preferences.language) != null ? _e : preferences == null ? void 0 : preferences.locale;
|
|
8716
8715
|
if (typeof rawLanguage !== "string" || !rawLanguage.trim()) return void 0;
|
|
8717
8716
|
return normalizeMenuLanguage(rawLanguage);
|
|
8718
8717
|
};
|
|
@@ -8753,8 +8752,8 @@ var parseRecentActivityItems = (payload) => {
|
|
|
8753
8752
|
return [];
|
|
8754
8753
|
};
|
|
8755
8754
|
return toRows(payload).map((item, index) => {
|
|
8756
|
-
var
|
|
8757
|
-
const id = (_b3 = (
|
|
8755
|
+
var _a25, _b3, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
8756
|
+
const id = (_b3 = (_a25 = toStringOrUndefined2(item.id)) != null ? _a25 : toStringOrUndefined2(item.event_id)) != null ? _b3 : `accounts-activity-${index}`;
|
|
8758
8757
|
const title = (_e = (_d = (_c = toStringOrUndefined2(item.title)) != null ? _c : toStringOrUndefined2(item.action)) != null ? _d : toStringOrUndefined2(item.event)) != null ? _e : toStringOrUndefined2(item.type);
|
|
8759
8758
|
if (!title) return null;
|
|
8760
8759
|
const description = (_h = (_g = (_f = toStringOrUndefined2(item.description)) != null ? _f : toStringOrUndefined2(item.details)) != null ? _g : toStringOrUndefined2(item.message)) != null ? _h : toStringOrUndefined2(item.summary);
|
|
@@ -8823,7 +8822,7 @@ var MainNavbar = ({
|
|
|
8823
8822
|
getAccessToken,
|
|
8824
8823
|
appVersion
|
|
8825
8824
|
}) => {
|
|
8826
|
-
var
|
|
8825
|
+
var _a25, _b3, _c;
|
|
8827
8826
|
const [tokenDerivedUserId, setTokenDerivedUserId] = (0, import_react19.useState)(null);
|
|
8828
8827
|
const [tokenDerivedEmail, setTokenDerivedEmail] = (0, import_react19.useState)(void 0);
|
|
8829
8828
|
const [tokenDerivedTenantId, setTokenDerivedTenantId] = (0, import_react19.useState)(void 0);
|
|
@@ -8841,13 +8840,13 @@ var MainNavbar = ({
|
|
|
8841
8840
|
return "/";
|
|
8842
8841
|
}, [pathname]);
|
|
8843
8842
|
const currentUserId = (0, import_react19.useMemo)(() => {
|
|
8844
|
-
var
|
|
8845
|
-
return (
|
|
8843
|
+
var _a26;
|
|
8844
|
+
return (_a26 = resolveCurrentUserId(authUser)) != null ? _a26 : tokenDerivedUserId;
|
|
8846
8845
|
}, [authUser, tokenDerivedUserId]);
|
|
8847
8846
|
const resolvedTenantId = (0, import_react19.useMemo)(() => {
|
|
8848
|
-
var
|
|
8847
|
+
var _a26, _b4, _c2, _d, _e, _f;
|
|
8849
8848
|
const candidate = normalizeTenantId(
|
|
8850
|
-
(_f = (_e = (_d = (_c2 = (_b4 = (
|
|
8849
|
+
(_f = (_e = (_d = (_c2 = (_b4 = (_a26 = authUser == null ? void 0 : authUser.tenantSlug) != null ? _a26 : authUser == null ? void 0 : authUser.tenantId) != 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
|
|
8851
8850
|
);
|
|
8852
8851
|
if (!candidate || !currentUserId) return candidate;
|
|
8853
8852
|
if (candidate === currentUserId) return void 0;
|
|
@@ -8865,7 +8864,7 @@ var MainNavbar = ({
|
|
|
8865
8864
|
const resolvedTelescupBaseUrl = (0, import_react19.useMemo)(() => {
|
|
8866
8865
|
return resolveTelescupBaseUrl();
|
|
8867
8866
|
}, []);
|
|
8868
|
-
const resolvedProfileAvatarUrl = (
|
|
8867
|
+
const resolvedProfileAvatarUrl = (_a25 = resolveAvatarPreviewUrl({ url: persistedProfileAvatarValue != null ? persistedProfileAvatarValue : authUser == null ? void 0 : authUser.picture })) != null ? _a25 : void 0;
|
|
8869
8868
|
const hasStoredAccessToken = (() => {
|
|
8870
8869
|
if (typeof window === "undefined") return false;
|
|
8871
8870
|
try {
|
|
@@ -8903,7 +8902,7 @@ var MainNavbar = ({
|
|
|
8903
8902
|
}
|
|
8904
8903
|
let canceled = false;
|
|
8905
8904
|
const resolveIdentityFromToken = async () => {
|
|
8906
|
-
var
|
|
8905
|
+
var _a26, _b4;
|
|
8907
8906
|
try {
|
|
8908
8907
|
let token = null;
|
|
8909
8908
|
if (typeof window !== "undefined") {
|
|
@@ -8924,7 +8923,7 @@ var MainNavbar = ({
|
|
|
8924
8923
|
}
|
|
8925
8924
|
return;
|
|
8926
8925
|
}
|
|
8927
|
-
const claims = (
|
|
8926
|
+
const claims = (_a26 = decodeJwt(token)) != null ? _a26 : {};
|
|
8928
8927
|
if (canceled) return;
|
|
8929
8928
|
setTokenDerivedUserId((_b4 = resolveUserIdFromClaims(claims)) != null ? _b4 : null);
|
|
8930
8929
|
setTokenDerivedEmail(resolveEmailFromClaims(claims));
|
|
@@ -8984,7 +8983,7 @@ var MainNavbar = ({
|
|
|
8984
8983
|
});
|
|
8985
8984
|
};
|
|
8986
8985
|
const loadAccountsContext = async () => {
|
|
8987
|
-
var
|
|
8986
|
+
var _a26;
|
|
8988
8987
|
setIsAccountsActivityLoading(true);
|
|
8989
8988
|
setIsAccountsLoginHistoryLoading(true);
|
|
8990
8989
|
setIsTwoFactorStatusLoading(true);
|
|
@@ -8997,7 +8996,7 @@ var MainNavbar = ({
|
|
|
8997
8996
|
}
|
|
8998
8997
|
return;
|
|
8999
8998
|
}
|
|
9000
|
-
const claims = (
|
|
8999
|
+
const claims = (_a26 = decodeJwt(token)) != null ? _a26 : {};
|
|
9001
9000
|
const twoFactorFromToken = resolveTwoFactorEnabledFromClaims(claims);
|
|
9002
9001
|
if (!canceled) {
|
|
9003
9002
|
setAccountsRecentActivity(buildActivityFromTokenClaims(claims));
|
|
@@ -9066,7 +9065,7 @@ var MainNavbar = ({
|
|
|
9066
9065
|
};
|
|
9067
9066
|
}, [getAccessToken, isAuthenticated, currentUserId]);
|
|
9068
9067
|
const items = (0, import_react19.useMemo)(() => {
|
|
9069
|
-
var
|
|
9068
|
+
var _a26;
|
|
9070
9069
|
if (!showNavItems) return [];
|
|
9071
9070
|
const normalizedPathname = currentPathname === "" ? "/" : currentPathname;
|
|
9072
9071
|
const navItems = getMainNavItems({ includePrivate: resolvedAuthStatus === "authenticated" });
|
|
@@ -9076,7 +9075,7 @@ var MainNavbar = ({
|
|
|
9076
9075
|
if (normalizedPathname.startsWith(`${href}/`)) return href.length;
|
|
9077
9076
|
return -1;
|
|
9078
9077
|
};
|
|
9079
|
-
const bestMatchHref = (
|
|
9078
|
+
const bestMatchHref = (_a26 = 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 : _a26.href;
|
|
9080
9079
|
return navItems.map((item) => {
|
|
9081
9080
|
const isAnchor = item.href.startsWith("#");
|
|
9082
9081
|
const isActive = !isAnchor ? item.href === bestMatchHref : false;
|
|
@@ -9084,8 +9083,8 @@ var MainNavbar = ({
|
|
|
9084
9083
|
...item,
|
|
9085
9084
|
isActive,
|
|
9086
9085
|
onClick: isAnchor ? item.onClick : (event) => {
|
|
9087
|
-
var
|
|
9088
|
-
(
|
|
9086
|
+
var _a27;
|
|
9087
|
+
(_a27 = item.onClick) == null ? void 0 : _a27.call(item, event);
|
|
9089
9088
|
if (!onNavigate || event.defaultPrevented) return;
|
|
9090
9089
|
event.preventDefault();
|
|
9091
9090
|
onNavigate(item.href);
|
|
@@ -9143,11 +9142,11 @@ var MainNavbar = ({
|
|
|
9143
9142
|
}, [getAccessToken]);
|
|
9144
9143
|
const handleLanguageChange = (0, import_react19.useCallback)(
|
|
9145
9144
|
async (nextLanguage) => {
|
|
9146
|
-
var
|
|
9145
|
+
var _a26;
|
|
9147
9146
|
setAccountsLanguage(nextLanguage);
|
|
9148
9147
|
if (typeof window === "undefined") return;
|
|
9149
9148
|
try {
|
|
9150
|
-
const token = getAccessToken ? await getAccessToken() : (
|
|
9149
|
+
const token = getAccessToken ? await getAccessToken() : (_a26 = sessionStorage.getItem(ACCESS_TOKEN_STORAGE_KEY)) != null ? _a26 : readStoredIdToken2();
|
|
9151
9150
|
if (!token || !isJwtUsable(token)) return;
|
|
9152
9151
|
const response = await fetch(buildExternalUrl(resolveAccountsApiBaseUrl2(), ACCOUNTS_ME_ENDPOINT), {
|
|
9153
9152
|
method: "PATCH",
|
|
@@ -9170,8 +9169,8 @@ var MainNavbar = ({
|
|
|
9170
9169
|
);
|
|
9171
9170
|
const handleProfileAvatarChange = (0, import_react19.useCallback)(
|
|
9172
9171
|
async ({ avatarId, avatarUrl }) => {
|
|
9173
|
-
var
|
|
9174
|
-
const normalizedAvatarId = (
|
|
9172
|
+
var _a26, _b4, _c2, _d;
|
|
9173
|
+
const normalizedAvatarId = (_a26 = parseAssetId(avatarId)) != null ? _a26 : parseAssetId(avatarUrl);
|
|
9175
9174
|
if (!normalizedAvatarId) {
|
|
9176
9175
|
throw new Error("ID da imagem inv\xE1lido.");
|
|
9177
9176
|
}
|
|
@@ -9873,7 +9872,7 @@ var DocumentationSearchDialog = ({ open, onOpenChange }) => {
|
|
|
9873
9872
|
const totalSections = map.sections.length;
|
|
9874
9873
|
const mapMatches = normalizedQuery.length === 0 || normalizeText([map.title, map.subtitle, map.searchLabel].join(" ")).includes(normalizedQuery);
|
|
9875
9874
|
const sections = map.sections.filter((section) => {
|
|
9876
|
-
var
|
|
9875
|
+
var _a25, _b3, _c;
|
|
9877
9876
|
if (mapMatches) return true;
|
|
9878
9877
|
const parent = section.parentId ? parents.get(section.parentId) : null;
|
|
9879
9878
|
const haystack = normalizeText(
|
|
@@ -9882,7 +9881,7 @@ var DocumentationSearchDialog = ({ open, onOpenChange }) => {
|
|
|
9882
9881
|
map.searchLabel,
|
|
9883
9882
|
section.label,
|
|
9884
9883
|
section.group,
|
|
9885
|
-
(
|
|
9884
|
+
(_a25 = section.description) != null ? _a25 : "",
|
|
9886
9885
|
(_b3 = parent == null ? void 0 : parent.label) != null ? _b3 : "",
|
|
9887
9886
|
...(_c = section.keywords) != null ? _c : []
|
|
9888
9887
|
].join(" ")
|
|
@@ -10002,9 +10001,9 @@ var DocumentationSearchDialog = ({ open, onOpenChange }) => {
|
|
|
10002
10001
|
// src/components/layout/sidebar-groups.tsx
|
|
10003
10002
|
var toStableId = (value) => value.toLowerCase().normalize("NFD").replace(/\p{Diacritic}+/gu, "").replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)+/g, "");
|
|
10004
10003
|
var getGroupMetadata = (item) => {
|
|
10005
|
-
var
|
|
10004
|
+
var _a25, _b3;
|
|
10006
10005
|
return {
|
|
10007
|
-
id: ((
|
|
10006
|
+
id: ((_a25 = item.groupId) == null ? void 0 : _a25.trim()) || "",
|
|
10008
10007
|
label: ((_b3 = item.groupLabel) == null ? void 0 : _b3.trim()) || "",
|
|
10009
10008
|
icon: item.groupIcon
|
|
10010
10009
|
};
|
|
@@ -10020,7 +10019,7 @@ var buildSidebarGroupsFromNavItems = (items, defaultGroupLabel = "Principal") =>
|
|
|
10020
10019
|
if (navItems.length === 0) return [];
|
|
10021
10020
|
const groupsMap = /* @__PURE__ */ new Map();
|
|
10022
10021
|
navItems.forEach((item) => {
|
|
10023
|
-
var
|
|
10022
|
+
var _a25;
|
|
10024
10023
|
const groupId = item.group.id || toStableId(item.group.label || defaultGroupLabel);
|
|
10025
10024
|
const groupLabel = item.group.label || defaultGroupLabel;
|
|
10026
10025
|
const existing = groupsMap.get(groupId);
|
|
@@ -10028,7 +10027,7 @@ var buildSidebarGroupsFromNavItems = (items, defaultGroupLabel = "Principal") =>
|
|
|
10028
10027
|
groupsMap.set(groupId, {
|
|
10029
10028
|
id: groupId,
|
|
10030
10029
|
label: groupLabel,
|
|
10031
|
-
icon: (
|
|
10030
|
+
icon: (_a25 = item.group.icon) != null ? _a25 : item.icon,
|
|
10032
10031
|
items: [{ id: item.id, label: item.label, icon: item.icon, route: item.route }]
|
|
10033
10032
|
});
|
|
10034
10033
|
return;
|
|
@@ -10045,8 +10044,8 @@ var defaultSidebarGroups = buildSidebarGroupsFromNavItems(getMainNavItems());
|
|
|
10045
10044
|
// src/components/layout/sidebar.tsx
|
|
10046
10045
|
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
10047
10046
|
var findGroupByRoute = (groups, pathname) => {
|
|
10048
|
-
var
|
|
10049
|
-
return (_b3 = (
|
|
10047
|
+
var _a25, _b3;
|
|
10048
|
+
return (_b3 = (_a25 = groups.find((group) => group.items.some((item) => item.route === pathname))) == null ? void 0 : _a25.label) != null ? _b3 : null;
|
|
10050
10049
|
};
|
|
10051
10050
|
var IconFallback = () => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_lucide_react12.Circle, { className: "h-3 w-3 opacity-80", "aria-hidden": "true" });
|
|
10052
10051
|
var DEFAULT_EXPANDED_LOGO_SLOT = /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "h-10 w-[175px] shrink-0", "aria-hidden": "true" });
|
|
@@ -10500,12 +10499,12 @@ var FOOTER_LAYOUT_AREAS = {
|
|
|
10500
10499
|
legal: "Barra legal"
|
|
10501
10500
|
};
|
|
10502
10501
|
var groupLinksBySection = (links) => {
|
|
10503
|
-
var
|
|
10502
|
+
var _a25;
|
|
10504
10503
|
const groups = /* @__PURE__ */ new Map();
|
|
10505
10504
|
for (const link of links) {
|
|
10506
10505
|
const section = link.section.trim();
|
|
10507
10506
|
if (!section) continue;
|
|
10508
|
-
const bucket = (
|
|
10507
|
+
const bucket = (_a25 = groups.get(section)) != null ? _a25 : [];
|
|
10509
10508
|
bucket.push({ label: link.label, href: link.href });
|
|
10510
10509
|
groups.set(section, bucket);
|
|
10511
10510
|
}
|
|
@@ -10515,18 +10514,18 @@ var groupLinksBySection = (links) => {
|
|
|
10515
10514
|
}));
|
|
10516
10515
|
};
|
|
10517
10516
|
var buildFooterLayout = (links) => {
|
|
10518
|
-
var
|
|
10517
|
+
var _a25;
|
|
10519
10518
|
const byArea = /* @__PURE__ */ new Map();
|
|
10520
10519
|
for (const link of links) {
|
|
10521
10520
|
const area = link.area.trim();
|
|
10522
10521
|
if (!area) continue;
|
|
10523
|
-
const bucket = (
|
|
10522
|
+
const bucket = (_a25 = byArea.get(area)) != null ? _a25 : [];
|
|
10524
10523
|
bucket.push(link);
|
|
10525
10524
|
byArea.set(area, bucket);
|
|
10526
10525
|
}
|
|
10527
10526
|
const pickArea = (area) => {
|
|
10528
|
-
var
|
|
10529
|
-
return (
|
|
10527
|
+
var _a26;
|
|
10528
|
+
return (_a26 = byArea.get(area)) != null ? _a26 : [];
|
|
10530
10529
|
};
|
|
10531
10530
|
const footerLeftGroups = groupLinksBySection(pickArea(FOOTER_LAYOUT_AREAS.left));
|
|
10532
10531
|
const footerServiceGroups = [
|
|
@@ -10578,9 +10577,9 @@ var requestJson = async (path, init) => {
|
|
|
10578
10577
|
return payload;
|
|
10579
10578
|
};
|
|
10580
10579
|
var loadFooterLinks = async () => {
|
|
10581
|
-
var
|
|
10580
|
+
var _a25;
|
|
10582
10581
|
const data = await requestJson("/api/ds/footer-links");
|
|
10583
|
-
return ((
|
|
10582
|
+
return ((_a25 = data.links) != null ? _a25 : []).map(toLink);
|
|
10584
10583
|
};
|
|
10585
10584
|
|
|
10586
10585
|
// src/hooks/useFooterLinks.ts
|
|
@@ -11620,10 +11619,10 @@ function isThemeMode(value) {
|
|
|
11620
11619
|
return value === "light" || value === "dark";
|
|
11621
11620
|
}
|
|
11622
11621
|
function readStoredTheme() {
|
|
11623
|
-
var
|
|
11622
|
+
var _a25;
|
|
11624
11623
|
if (typeof window === "undefined") return null;
|
|
11625
11624
|
try {
|
|
11626
|
-
const storedTheme = (
|
|
11625
|
+
const storedTheme = (_a25 = window.localStorage.getItem(THEME_STORAGE_KEY2)) != null ? _a25 : window.localStorage.getItem("theme");
|
|
11627
11626
|
return isThemeMode(storedTheme) ? storedTheme : null;
|
|
11628
11627
|
} catch (e) {
|
|
11629
11628
|
return null;
|
|
@@ -11646,10 +11645,10 @@ function applyThemeClass(theme) {
|
|
|
11646
11645
|
root.style.colorScheme = theme;
|
|
11647
11646
|
}
|
|
11648
11647
|
function readThemeFromRoot() {
|
|
11649
|
-
var
|
|
11648
|
+
var _a25;
|
|
11650
11649
|
if (typeof document === "undefined") return null;
|
|
11651
11650
|
const root = document.documentElement;
|
|
11652
|
-
const datasetTheme = (
|
|
11651
|
+
const datasetTheme = (_a25 = root.dataset.theme) != null ? _a25 : null;
|
|
11653
11652
|
if (isThemeMode(datasetTheme)) return datasetTheme;
|
|
11654
11653
|
if (root.classList.contains("dark")) return "dark";
|
|
11655
11654
|
if (root.classList.contains("light")) return "light";
|
|
@@ -11672,13 +11671,13 @@ var ThemeToggle2 = ({
|
|
|
11672
11671
|
defaultTheme = "light",
|
|
11673
11672
|
onThemeChange
|
|
11674
11673
|
}) => {
|
|
11675
|
-
var
|
|
11674
|
+
var _a25;
|
|
11676
11675
|
const themeContext = React31.useContext(ThemeContext);
|
|
11677
11676
|
const [mounted, setMounted] = React31.useState(false);
|
|
11678
11677
|
const [internalTheme, setInternalTheme] = React31.useState(defaultTheme);
|
|
11679
11678
|
const isControlled = typeof theme !== "undefined";
|
|
11680
11679
|
const usesProviderTheme = !isControlled && themeContext !== null;
|
|
11681
|
-
const activeTheme = (
|
|
11680
|
+
const activeTheme = (_a25 = isControlled ? theme : usesProviderTheme ? themeContext.theme : internalTheme) != null ? _a25 : defaultTheme;
|
|
11682
11681
|
React31.useEffect(() => {
|
|
11683
11682
|
if (!isControlled && !usesProviderTheme) {
|
|
11684
11683
|
setInternalTheme(resolveTheme(defaultTheme));
|
|
@@ -11703,8 +11702,8 @@ var ThemeToggle2 = ({
|
|
|
11703
11702
|
return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: cn("w-10 h-10 rounded-lg bg-muted", className) });
|
|
11704
11703
|
}
|
|
11705
11704
|
const handleToggle = (event) => {
|
|
11706
|
-
var
|
|
11707
|
-
const currentTheme = (
|
|
11705
|
+
var _a26;
|
|
11706
|
+
const currentTheme = (_a26 = readThemeFromRoot()) != null ? _a26 : activeTheme;
|
|
11708
11707
|
const nextTheme = currentTheme === "dark" ? "light" : "dark";
|
|
11709
11708
|
if (usesProviderTheme) {
|
|
11710
11709
|
themeContext.toggleTheme({
|
|
@@ -11758,11 +11757,11 @@ function getPreferredTheme() {
|
|
|
11758
11757
|
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
11759
11758
|
}
|
|
11760
11759
|
function getStoredTheme() {
|
|
11761
|
-
var
|
|
11760
|
+
var _a25;
|
|
11762
11761
|
if (typeof window === "undefined") {
|
|
11763
11762
|
return null;
|
|
11764
11763
|
}
|
|
11765
|
-
const storedTheme = (
|
|
11764
|
+
const storedTheme = (_a25 = window.localStorage.getItem(STORAGE_KEY)) != null ? _a25 : window.localStorage.getItem(LEGACY_STORAGE_KEY);
|
|
11766
11765
|
return storedTheme === "light" || storedTheme === "dark" ? storedTheme : null;
|
|
11767
11766
|
}
|
|
11768
11767
|
function getThemeFromRoot() {
|
|
@@ -11783,8 +11782,8 @@ function getThemeFromRoot() {
|
|
|
11783
11782
|
return null;
|
|
11784
11783
|
}
|
|
11785
11784
|
function resolveTheme2() {
|
|
11786
|
-
var
|
|
11787
|
-
return (_b3 = (
|
|
11785
|
+
var _a25, _b3;
|
|
11786
|
+
return (_b3 = (_a25 = getThemeFromRoot()) != null ? _a25 : getStoredTheme()) != null ? _b3 : getPreferredTheme();
|
|
11788
11787
|
}
|
|
11789
11788
|
function applyThemeToRoot(theme) {
|
|
11790
11789
|
const root = document.documentElement;
|
|
@@ -11854,7 +11853,7 @@ function ThemeProvider({ children }) {
|
|
|
11854
11853
|
return () => observer.disconnect();
|
|
11855
11854
|
}, []);
|
|
11856
11855
|
const applyThemeSelection = (0, import_react28.useCallback)((nextTheme, coords) => {
|
|
11857
|
-
var
|
|
11856
|
+
var _a25;
|
|
11858
11857
|
const documentWithTransition = document;
|
|
11859
11858
|
const root = document.documentElement;
|
|
11860
11859
|
const prefersReducedMotion = window.matchMedia(
|
|
@@ -11879,7 +11878,7 @@ function ThemeProvider({ children }) {
|
|
|
11879
11878
|
root.style.setProperty("--theme-x", "50%");
|
|
11880
11879
|
root.style.setProperty("--theme-y", "50%");
|
|
11881
11880
|
}
|
|
11882
|
-
(
|
|
11881
|
+
(_a25 = documentWithTransition.startViewTransition) == null ? void 0 : _a25.call(documentWithTransition, () => {
|
|
11883
11882
|
(0, import_react_dom.flushSync)(() => {
|
|
11884
11883
|
commitTheme();
|
|
11885
11884
|
});
|
|
@@ -11889,8 +11888,8 @@ function ThemeProvider({ children }) {
|
|
|
11889
11888
|
applyThemeSelection(nextTheme);
|
|
11890
11889
|
}, [applyThemeSelection]);
|
|
11891
11890
|
const toggleTheme = (0, import_react28.useCallback)((coords) => {
|
|
11892
|
-
var
|
|
11893
|
-
const currentTheme = (
|
|
11891
|
+
var _a25;
|
|
11892
|
+
const currentTheme = (_a25 = getThemeFromRoot()) != null ? _a25 : theme;
|
|
11894
11893
|
const nextTheme = currentTheme === "light" ? "dark" : "light";
|
|
11895
11894
|
applyThemeSelection(nextTheme, coords);
|
|
11896
11895
|
}, [applyThemeSelection, theme]);
|
|
@@ -12597,8 +12596,8 @@ var ChartStyle = ({ id, config }) => {
|
|
|
12597
12596
|
([theme, prefix]) => `
|
|
12598
12597
|
${prefix} [data-chart=${id}] {
|
|
12599
12598
|
${colorConfig.map(([key, itemConfig]) => {
|
|
12600
|
-
var
|
|
12601
|
-
const color = ((
|
|
12599
|
+
var _a25;
|
|
12600
|
+
const color = ((_a25 = itemConfig.theme) == null ? void 0 : _a25[theme]) || itemConfig.color;
|
|
12602
12601
|
return color ? ` --color-${key}: ${color};` : null;
|
|
12603
12602
|
}).join("\n")}
|
|
12604
12603
|
}
|
|
@@ -12627,14 +12626,14 @@ var ChartTooltipContent = React40.forwardRef(
|
|
|
12627
12626
|
}, ref) => {
|
|
12628
12627
|
const { config } = useChart();
|
|
12629
12628
|
const tooltipLabel = React40.useMemo(() => {
|
|
12630
|
-
var
|
|
12629
|
+
var _a25;
|
|
12631
12630
|
if (hideLabel || !(payload == null ? void 0 : payload.length)) {
|
|
12632
12631
|
return null;
|
|
12633
12632
|
}
|
|
12634
12633
|
const [item] = payload;
|
|
12635
12634
|
const key = `${labelKey || item.dataKey || item.name || "value"}`;
|
|
12636
12635
|
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
12637
|
-
const value = !labelKey && typeof label === "string" ? ((
|
|
12636
|
+
const value = !labelKey && typeof label === "string" ? ((_a25 = config[label]) == null ? void 0 : _a25.label) || label : itemConfig == null ? void 0 : itemConfig.label;
|
|
12638
12637
|
if (labelFormatter) {
|
|
12639
12638
|
return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: cn("font-medium", labelClassName), children: labelFormatter(value, payload) });
|
|
12640
12639
|
}
|
|
@@ -14354,9 +14353,9 @@ ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
|
|
|
14354
14353
|
// src/hooks/useActiveSection.ts
|
|
14355
14354
|
var import_react30 = require("react");
|
|
14356
14355
|
var resolveActiveFromOffsets = (sectionIds, topById, offset, scrollY) => {
|
|
14357
|
-
var
|
|
14356
|
+
var _a25;
|
|
14358
14357
|
const line = scrollY + offset;
|
|
14359
|
-
let nextActive = (
|
|
14358
|
+
let nextActive = (_a25 = sectionIds[0]) != null ? _a25 : "";
|
|
14360
14359
|
for (const id of sectionIds) {
|
|
14361
14360
|
const top = topById.get(id);
|
|
14362
14361
|
if (typeof top !== "number") continue;
|
|
@@ -14369,10 +14368,10 @@ var resolveActiveFromOffsets = (sectionIds, topById, offset, scrollY) => {
|
|
|
14369
14368
|
return nextActive;
|
|
14370
14369
|
};
|
|
14371
14370
|
var useActiveSection = (sectionIds, offset = 180) => {
|
|
14372
|
-
var
|
|
14373
|
-
const [activeId, setActiveId] = (0, import_react30.useState)((
|
|
14371
|
+
var _a25;
|
|
14372
|
+
const [activeId, setActiveId] = (0, import_react30.useState)((_a25 = sectionIds[0]) != null ? _a25 : "");
|
|
14374
14373
|
(0, import_react30.useEffect)(() => {
|
|
14375
|
-
var
|
|
14374
|
+
var _a26;
|
|
14376
14375
|
if (!sectionIds.length || typeof window === "undefined") return;
|
|
14377
14376
|
const sections = sectionIds.map((id) => {
|
|
14378
14377
|
const element = document.getElementById(id);
|
|
@@ -14380,7 +14379,7 @@ var useActiveSection = (sectionIds, offset = 180) => {
|
|
|
14380
14379
|
return { id, element };
|
|
14381
14380
|
}).filter((section) => section !== null);
|
|
14382
14381
|
if (!sections.length) {
|
|
14383
|
-
setActiveId((
|
|
14382
|
+
setActiveId((_a26 = sectionIds[0]) != null ? _a26 : "");
|
|
14384
14383
|
return;
|
|
14385
14384
|
}
|
|
14386
14385
|
const topById = /* @__PURE__ */ new Map();
|
|
@@ -14515,9 +14514,9 @@ var useLayoutMode = () => {
|
|
|
14515
14514
|
setMode(normalizeLayoutMode(event.newValue));
|
|
14516
14515
|
};
|
|
14517
14516
|
const handleModeChange = (event) => {
|
|
14518
|
-
var
|
|
14517
|
+
var _a25;
|
|
14519
14518
|
const customEvent = event;
|
|
14520
|
-
setMode((
|
|
14519
|
+
setMode((_a25 = customEvent.detail) != null ? _a25 : readStoredLayoutMode());
|
|
14521
14520
|
};
|
|
14522
14521
|
window.addEventListener("storage", handleStorage);
|
|
14523
14522
|
window.addEventListener(LAYOUT_MODE_CHANGE_EVENT, handleModeChange);
|
|
@@ -14674,7 +14673,7 @@ var FunctionsClient = class {
|
|
|
14674
14673
|
*/
|
|
14675
14674
|
invoke(functionName_1) {
|
|
14676
14675
|
return __awaiter(this, arguments, void 0, function* (functionName, options = {}) {
|
|
14677
|
-
var
|
|
14676
|
+
var _a25;
|
|
14678
14677
|
let timeoutId;
|
|
14679
14678
|
let timeoutController;
|
|
14680
14679
|
try {
|
|
@@ -14740,7 +14739,7 @@ var FunctionsClient = class {
|
|
|
14740
14739
|
if (!response.ok) {
|
|
14741
14740
|
throw new FunctionsHttpError(response);
|
|
14742
14741
|
}
|
|
14743
|
-
let responseType = ((
|
|
14742
|
+
let responseType = ((_a25 = response.headers.get("Content-Type")) !== null && _a25 !== void 0 ? _a25 : "text/plain").split(";")[0].trim();
|
|
14744
14743
|
let data;
|
|
14745
14744
|
if (responseType === "application/json") {
|
|
14746
14745
|
data = yield response.json();
|
|
@@ -16089,7 +16088,7 @@ var WebSocketFactory = class {
|
|
|
16089
16088
|
constructor() {
|
|
16090
16089
|
}
|
|
16091
16090
|
static detectEnvironment() {
|
|
16092
|
-
var
|
|
16091
|
+
var _a25;
|
|
16093
16092
|
if (typeof WebSocket !== "undefined") {
|
|
16094
16093
|
return { type: "native", constructor: WebSocket };
|
|
16095
16094
|
}
|
|
@@ -16106,7 +16105,7 @@ var WebSocketFactory = class {
|
|
|
16106
16105
|
workaround: "Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."
|
|
16107
16106
|
};
|
|
16108
16107
|
}
|
|
16109
|
-
if (typeof globalThis !== "undefined" && globalThis.EdgeRuntime || typeof navigator !== "undefined" && ((
|
|
16108
|
+
if (typeof globalThis !== "undefined" && globalThis.EdgeRuntime || typeof navigator !== "undefined" && ((_a25 = navigator.userAgent) === null || _a25 === void 0 ? void 0 : _a25.includes("Vercel-Edge"))) {
|
|
16110
16109
|
return {
|
|
16111
16110
|
type: "unsupported",
|
|
16112
16111
|
error: "Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",
|
|
@@ -16190,7 +16189,7 @@ Suggested solution: ${env.workaround}`;
|
|
|
16190
16189
|
try {
|
|
16191
16190
|
const env = this.detectEnvironment();
|
|
16192
16191
|
return env.type === "native" || env.type === "ws";
|
|
16193
|
-
} catch (
|
|
16192
|
+
} catch (_a25) {
|
|
16194
16193
|
return false;
|
|
16195
16194
|
}
|
|
16196
16195
|
}
|
|
@@ -16264,29 +16263,29 @@ var Serializer = class {
|
|
|
16264
16263
|
return callback(JSON.stringify(payload));
|
|
16265
16264
|
}
|
|
16266
16265
|
_binaryEncodeUserBroadcastPush(message) {
|
|
16267
|
-
var
|
|
16268
|
-
if (this._isArrayBuffer((
|
|
16266
|
+
var _a25;
|
|
16267
|
+
if (this._isArrayBuffer((_a25 = message.payload) === null || _a25 === void 0 ? void 0 : _a25.payload)) {
|
|
16269
16268
|
return this._encodeBinaryUserBroadcastPush(message);
|
|
16270
16269
|
} else {
|
|
16271
16270
|
return this._encodeJsonUserBroadcastPush(message);
|
|
16272
16271
|
}
|
|
16273
16272
|
}
|
|
16274
16273
|
_encodeBinaryUserBroadcastPush(message) {
|
|
16275
|
-
var
|
|
16276
|
-
const userPayload = (_b3 = (
|
|
16274
|
+
var _a25, _b3;
|
|
16275
|
+
const userPayload = (_b3 = (_a25 = message.payload) === null || _a25 === void 0 ? void 0 : _a25.payload) !== null && _b3 !== void 0 ? _b3 : new ArrayBuffer(0);
|
|
16277
16276
|
return this._encodeUserBroadcastPush(message, this.BINARY_ENCODING, userPayload);
|
|
16278
16277
|
}
|
|
16279
16278
|
_encodeJsonUserBroadcastPush(message) {
|
|
16280
|
-
var
|
|
16281
|
-
const userPayload = (_b3 = (
|
|
16279
|
+
var _a25, _b3;
|
|
16280
|
+
const userPayload = (_b3 = (_a25 = message.payload) === null || _a25 === void 0 ? void 0 : _a25.payload) !== null && _b3 !== void 0 ? _b3 : {};
|
|
16282
16281
|
const encoder = new TextEncoder();
|
|
16283
16282
|
const encodedUserPayload = encoder.encode(JSON.stringify(userPayload)).buffer;
|
|
16284
16283
|
return this._encodeUserBroadcastPush(message, this.JSON_ENCODING, encodedUserPayload);
|
|
16285
16284
|
}
|
|
16286
16285
|
_encodeUserBroadcastPush(message, encodingType, encodedPayload) {
|
|
16287
|
-
var
|
|
16286
|
+
var _a25, _b3;
|
|
16288
16287
|
const topic = message.topic;
|
|
16289
|
-
const ref = (
|
|
16288
|
+
const ref = (_a25 = message.ref) !== null && _a25 !== void 0 ? _a25 : "";
|
|
16290
16289
|
const joinRef = (_b3 = message.join_ref) !== null && _b3 !== void 0 ? _b3 : "";
|
|
16291
16290
|
const userEvent = message.payload.event;
|
|
16292
16291
|
const rest = this.allowedMetadataKeys ? this._pick(message.payload, this.allowedMetadataKeys) : {};
|
|
@@ -16373,8 +16372,8 @@ var Serializer = class {
|
|
|
16373
16372
|
return { join_ref: null, ref: null, topic, event: this.BROADCAST_EVENT, payload: data };
|
|
16374
16373
|
}
|
|
16375
16374
|
_isArrayBuffer(buffer) {
|
|
16376
|
-
var
|
|
16377
|
-
return buffer instanceof ArrayBuffer || ((
|
|
16375
|
+
var _a25;
|
|
16376
|
+
return buffer instanceof ArrayBuffer || ((_a25 = buffer === null || buffer === void 0 ? void 0 : buffer.constructor) === null || _a25 === void 0 ? void 0 : _a25.name) === "ArrayBuffer";
|
|
16378
16377
|
}
|
|
16379
16378
|
_pick(obj, keys) {
|
|
16380
16379
|
if (!obj || typeof obj !== "object") {
|
|
@@ -16438,8 +16437,8 @@ var PostgresTypes;
|
|
|
16438
16437
|
PostgresTypes2["tstzrange"] = "tstzrange";
|
|
16439
16438
|
})(PostgresTypes || (PostgresTypes = {}));
|
|
16440
16439
|
var convertChangeData = (columns, record, options = {}) => {
|
|
16441
|
-
var
|
|
16442
|
-
const skipTypes = (
|
|
16440
|
+
var _a25;
|
|
16441
|
+
const skipTypes = (_a25 = options.skipTypes) !== null && _a25 !== void 0 ? _a25 : [];
|
|
16443
16442
|
if (!record) {
|
|
16444
16443
|
return {};
|
|
16445
16444
|
}
|
|
@@ -16529,7 +16528,7 @@ var toJson = (value) => {
|
|
|
16529
16528
|
if (typeof value === "string") {
|
|
16530
16529
|
try {
|
|
16531
16530
|
return JSON.parse(value);
|
|
16532
|
-
} catch (
|
|
16531
|
+
} catch (_a25) {
|
|
16533
16532
|
return value;
|
|
16534
16533
|
}
|
|
16535
16534
|
}
|
|
@@ -16621,9 +16620,9 @@ var Push = class {
|
|
|
16621
16620
|
this.payload = Object.assign(Object.assign({}, this.payload), payload);
|
|
16622
16621
|
}
|
|
16623
16622
|
receive(status, callback) {
|
|
16624
|
-
var
|
|
16623
|
+
var _a25;
|
|
16625
16624
|
if (this._hasReceived(status)) {
|
|
16626
|
-
callback((
|
|
16625
|
+
callback((_a25 = this.receivedResp) === null || _a25 === void 0 ? void 0 : _a25.response);
|
|
16627
16626
|
}
|
|
16628
16627
|
this.recHooks.push({ status, callback });
|
|
16629
16628
|
return this;
|
|
@@ -16814,8 +16813,8 @@ var RealtimePresence = class _RealtimePresence {
|
|
|
16814
16813
|
};
|
|
16815
16814
|
}
|
|
16816
16815
|
this.map(joins, (key, newPresences) => {
|
|
16817
|
-
var
|
|
16818
|
-
const currentPresences = (
|
|
16816
|
+
var _a25;
|
|
16817
|
+
const currentPresences = (_a25 = state[key]) !== null && _a25 !== void 0 ? _a25 : [];
|
|
16819
16818
|
state[key] = this.cloneDeep(newPresences);
|
|
16820
16819
|
if (currentPresences.length > 0) {
|
|
16821
16820
|
const joinedPresenceRefs = state[key].map((m) => m.presence_ref);
|
|
@@ -16943,7 +16942,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
16943
16942
|
* ```
|
|
16944
16943
|
*/
|
|
16945
16944
|
constructor(topic, params = { config: {} }, socket) {
|
|
16946
|
-
var
|
|
16945
|
+
var _a25, _b3;
|
|
16947
16946
|
this.topic = topic;
|
|
16948
16947
|
this.params = params;
|
|
16949
16948
|
this.socket = socket;
|
|
@@ -17002,19 +17001,19 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
17002
17001
|
this.presence = new RealtimePresence(this);
|
|
17003
17002
|
this.broadcastEndpointURL = httpEndpointURL(this.socket.endPoint);
|
|
17004
17003
|
this.private = this.params.config.private || false;
|
|
17005
|
-
if (!this.private && ((_b3 = (
|
|
17004
|
+
if (!this.private && ((_b3 = (_a25 = this.params.config) === null || _a25 === void 0 ? void 0 : _a25.broadcast) === null || _b3 === void 0 ? void 0 : _b3.replay)) {
|
|
17006
17005
|
throw `tried to use replay on public channel '${this.topic}'. It must be a private channel.`;
|
|
17007
17006
|
}
|
|
17008
17007
|
}
|
|
17009
17008
|
/** Subscribe registers your client with the server */
|
|
17010
17009
|
subscribe(callback, timeout = this.timeout) {
|
|
17011
|
-
var
|
|
17010
|
+
var _a25, _b3, _c;
|
|
17012
17011
|
if (!this.socket.isConnected()) {
|
|
17013
17012
|
this.socket.connect();
|
|
17014
17013
|
}
|
|
17015
17014
|
if (this.state == CHANNEL_STATES.closed) {
|
|
17016
17015
|
const { config: { broadcast, presence, private: isPrivate } } = this.params;
|
|
17017
|
-
const postgres_changes = (_b3 = (
|
|
17016
|
+
const postgres_changes = (_b3 = (_a25 = this.bindings.postgres_changes) === null || _a25 === void 0 ? void 0 : _a25.map((r) => r.filter)) !== null && _b3 !== void 0 ? _b3 : [];
|
|
17018
17017
|
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;
|
|
17019
17018
|
const accessTokenPayload = {};
|
|
17020
17019
|
const config = {
|
|
@@ -17032,7 +17031,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
17032
17031
|
this.joinedOnce = true;
|
|
17033
17032
|
this._rejoin(timeout);
|
|
17034
17033
|
this.joinPush.receive("ok", async ({ postgres_changes: postgres_changes2 }) => {
|
|
17035
|
-
var
|
|
17034
|
+
var _a26;
|
|
17036
17035
|
if (!this.socket._isManualToken()) {
|
|
17037
17036
|
this.socket.setAuth();
|
|
17038
17037
|
}
|
|
@@ -17041,7 +17040,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
17041
17040
|
return;
|
|
17042
17041
|
} else {
|
|
17043
17042
|
const clientPostgresBindings = this.bindings.postgres_changes;
|
|
17044
|
-
const bindingsLen = (
|
|
17043
|
+
const bindingsLen = (_a26 = clientPostgresBindings === null || clientPostgresBindings === void 0 ? void 0 : clientPostgresBindings.length) !== null && _a26 !== void 0 ? _a26 : 0;
|
|
17045
17044
|
const newPostgresBindings = [];
|
|
17046
17045
|
for (let i = 0; i < bindingsLen; i++) {
|
|
17047
17046
|
const clientPostgresBinding = clientPostgresBindings[i];
|
|
@@ -17119,7 +17118,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
17119
17118
|
* @returns Promise resolving to object with success status, and error details if failed
|
|
17120
17119
|
*/
|
|
17121
17120
|
async httpSend(event, payload, opts = {}) {
|
|
17122
|
-
var
|
|
17121
|
+
var _a25;
|
|
17123
17122
|
if (payload === void 0 || payload === null) {
|
|
17124
17123
|
return Promise.reject("Payload is required for httpSend()");
|
|
17125
17124
|
}
|
|
@@ -17144,7 +17143,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
17144
17143
|
]
|
|
17145
17144
|
})
|
|
17146
17145
|
};
|
|
17147
|
-
const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (
|
|
17146
|
+
const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a25 = opts.timeout) !== null && _a25 !== void 0 ? _a25 : this.timeout);
|
|
17148
17147
|
if (response.status === 202) {
|
|
17149
17148
|
return { success: true };
|
|
17150
17149
|
}
|
|
@@ -17166,7 +17165,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
17166
17165
|
* @param opts Options to be used during the send process
|
|
17167
17166
|
*/
|
|
17168
17167
|
async send(args, opts = {}) {
|
|
17169
|
-
var
|
|
17168
|
+
var _a25, _b3;
|
|
17170
17169
|
if (!this._canPush() && args.type === "broadcast") {
|
|
17171
17170
|
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.");
|
|
17172
17171
|
const { event, payload: endpoint_payload } = args;
|
|
@@ -17192,7 +17191,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
17192
17191
|
})
|
|
17193
17192
|
};
|
|
17194
17193
|
try {
|
|
17195
|
-
const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (
|
|
17194
|
+
const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a25 = opts.timeout) !== null && _a25 !== void 0 ? _a25 : this.timeout);
|
|
17196
17195
|
await ((_b3 = response.body) === null || _b3 === void 0 ? void 0 : _b3.cancel());
|
|
17197
17196
|
return response.ok ? "ok" : "error";
|
|
17198
17197
|
} catch (error) {
|
|
@@ -17204,9 +17203,9 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
17204
17203
|
}
|
|
17205
17204
|
} else {
|
|
17206
17205
|
return new Promise((resolve) => {
|
|
17207
|
-
var
|
|
17206
|
+
var _a26, _b4, _c;
|
|
17208
17207
|
const push = this._push(args.type, args, opts.timeout || this.timeout);
|
|
17209
|
-
if (args.type === "broadcast" && !((_c = (_b4 = (
|
|
17208
|
+
if (args.type === "broadcast" && !((_c = (_b4 = (_a26 = this.params) === null || _a26 === void 0 ? void 0 : _a26.config) === null || _b4 === void 0 ? void 0 : _b4.broadcast) === null || _c === void 0 ? void 0 : _c.ack)) {
|
|
17210
17209
|
resolve("ok");
|
|
17211
17210
|
}
|
|
17212
17211
|
push.receive("ok", () => resolve("ok"));
|
|
@@ -17325,7 +17324,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
17325
17324
|
}
|
|
17326
17325
|
/** @internal */
|
|
17327
17326
|
_trigger(type, payload, ref) {
|
|
17328
|
-
var
|
|
17327
|
+
var _a25, _b3;
|
|
17329
17328
|
const typeLower = type.toLocaleLowerCase();
|
|
17330
17329
|
const { close, error, leave, join } = CHANNEL_EVENTS;
|
|
17331
17330
|
const events = [close, error, leave, join];
|
|
@@ -17337,17 +17336,17 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
17337
17336
|
throw "channel onMessage callbacks must return the payload, modified or unmodified";
|
|
17338
17337
|
}
|
|
17339
17338
|
if (["insert", "update", "delete"].includes(typeLower)) {
|
|
17340
|
-
(
|
|
17341
|
-
var
|
|
17342
|
-
return ((
|
|
17339
|
+
(_a25 = this.bindings.postgres_changes) === null || _a25 === void 0 ? void 0 : _a25.filter((bind) => {
|
|
17340
|
+
var _a26, _b4, _c;
|
|
17341
|
+
return ((_a26 = bind.filter) === null || _a26 === void 0 ? void 0 : _a26.event) === "*" || ((_c = (_b4 = bind.filter) === null || _b4 === void 0 ? void 0 : _b4.event) === null || _c === void 0 ? void 0 : _c.toLocaleLowerCase()) === typeLower;
|
|
17343
17342
|
}).map((bind) => bind.callback(handledPayload, ref));
|
|
17344
17343
|
} else {
|
|
17345
17344
|
(_b3 = this.bindings[typeLower]) === null || _b3 === void 0 ? void 0 : _b3.filter((bind) => {
|
|
17346
|
-
var
|
|
17345
|
+
var _a26, _b4, _c, _d, _e, _f;
|
|
17347
17346
|
if (["broadcast", "presence", "postgres_changes"].includes(typeLower)) {
|
|
17348
17347
|
if ("id" in bind) {
|
|
17349
17348
|
const bindId = bind.id;
|
|
17350
|
-
const bindEvent = (
|
|
17349
|
+
const bindEvent = (_a26 = bind.filter) === null || _a26 === void 0 ? void 0 : _a26.event;
|
|
17351
17350
|
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()));
|
|
17352
17351
|
} else {
|
|
17353
17352
|
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();
|
|
@@ -17415,8 +17414,8 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
17415
17414
|
const typeLower = type.toLocaleLowerCase();
|
|
17416
17415
|
if (this.bindings[typeLower]) {
|
|
17417
17416
|
this.bindings[typeLower] = this.bindings[typeLower].filter((bind) => {
|
|
17418
|
-
var
|
|
17419
|
-
return !(((
|
|
17417
|
+
var _a25;
|
|
17418
|
+
return !(((_a25 = bind.type) === null || _a25 === void 0 ? void 0 : _a25.toLocaleLowerCase()) === typeLower && _RealtimeChannel.isEqual(bind.filter, filter));
|
|
17420
17419
|
});
|
|
17421
17420
|
}
|
|
17422
17421
|
return this;
|
|
@@ -17546,7 +17545,7 @@ var RealtimeClient = class {
|
|
|
17546
17545
|
* ```
|
|
17547
17546
|
*/
|
|
17548
17547
|
constructor(endPoint, options) {
|
|
17549
|
-
var
|
|
17548
|
+
var _a25;
|
|
17550
17549
|
this.accessTokenValue = null;
|
|
17551
17550
|
this.apiKey = null;
|
|
17552
17551
|
this._manuallySetToken = false;
|
|
@@ -17585,7 +17584,7 @@ var RealtimeClient = class {
|
|
|
17585
17584
|
}
|
|
17586
17585
|
return (...args) => fetch(...args);
|
|
17587
17586
|
};
|
|
17588
|
-
if (!((
|
|
17587
|
+
if (!((_a25 = options === null || options === void 0 ? void 0 : options.params) === null || _a25 === void 0 ? void 0 : _a25.apikey)) {
|
|
17589
17588
|
throw new Error("API key is required to connect to Realtime");
|
|
17590
17589
|
}
|
|
17591
17590
|
this.apiKey = options.params.apikey;
|
|
@@ -17770,8 +17769,8 @@ Option 2: Install and provide the "ws" package:
|
|
|
17770
17769
|
const { topic, event, payload, ref } = data;
|
|
17771
17770
|
const callback = () => {
|
|
17772
17771
|
this.encode(data, (result) => {
|
|
17773
|
-
var
|
|
17774
|
-
(
|
|
17772
|
+
var _a25;
|
|
17773
|
+
(_a25 = this.conn) === null || _a25 === void 0 ? void 0 : _a25.send(result);
|
|
17775
17774
|
});
|
|
17776
17775
|
};
|
|
17777
17776
|
this.log("push", `${topic} ${event} (${ref})`, payload);
|
|
@@ -17821,7 +17820,7 @@ Option 2: Install and provide the "ws" package:
|
|
|
17821
17820
|
* Sends a heartbeat message if the socket is connected.
|
|
17822
17821
|
*/
|
|
17823
17822
|
async sendHeartbeat() {
|
|
17824
|
-
var
|
|
17823
|
+
var _a25;
|
|
17825
17824
|
if (!this.isConnected()) {
|
|
17826
17825
|
try {
|
|
17827
17826
|
this.heartbeatCallback("disconnected");
|
|
@@ -17840,11 +17839,11 @@ Option 2: Install and provide the "ws" package:
|
|
|
17840
17839
|
this.log("error", "error in heartbeat callback", e);
|
|
17841
17840
|
}
|
|
17842
17841
|
this._wasManualDisconnect = false;
|
|
17843
|
-
(
|
|
17842
|
+
(_a25 = this.conn) === null || _a25 === void 0 ? void 0 : _a25.close(WS_CLOSE_NORMAL, "heartbeat timeout");
|
|
17844
17843
|
setTimeout(() => {
|
|
17845
|
-
var
|
|
17844
|
+
var _a26;
|
|
17846
17845
|
if (!this.isConnected()) {
|
|
17847
|
-
(
|
|
17846
|
+
(_a26 = this.reconnectTimer) === null || _a26 === void 0 ? void 0 : _a26.scheduleTimeout();
|
|
17848
17847
|
}
|
|
17849
17848
|
}, CONNECTION_TIMEOUTS.HEARTBEAT_TIMEOUT_FALLBACK);
|
|
17850
17849
|
return;
|
|
@@ -17942,12 +17941,12 @@ Option 2: Install and provide the "ws" package:
|
|
|
17942
17941
|
* @internal
|
|
17943
17942
|
*/
|
|
17944
17943
|
_clearTimer(timer) {
|
|
17945
|
-
var
|
|
17944
|
+
var _a25;
|
|
17946
17945
|
if (timer === "heartbeat" && this.heartbeatTimer) {
|
|
17947
17946
|
clearInterval(this.heartbeatTimer);
|
|
17948
17947
|
this.heartbeatTimer = void 0;
|
|
17949
17948
|
} else if (timer === "reconnect") {
|
|
17950
|
-
(
|
|
17949
|
+
(_a25 = this.reconnectTimer) === null || _a25 === void 0 ? void 0 : _a25.reset();
|
|
17951
17950
|
}
|
|
17952
17951
|
}
|
|
17953
17952
|
/**
|
|
@@ -18062,13 +18061,13 @@ Option 2: Install and provide the "ws" package:
|
|
|
18062
18061
|
}
|
|
18063
18062
|
/** @internal */
|
|
18064
18063
|
_onConnClose(event) {
|
|
18065
|
-
var
|
|
18064
|
+
var _a25;
|
|
18066
18065
|
this._setConnectionState("disconnected");
|
|
18067
18066
|
this.log("transport", "close", event);
|
|
18068
18067
|
this._triggerChanError();
|
|
18069
18068
|
this._clearTimer("heartbeat");
|
|
18070
18069
|
if (!this._wasManualDisconnect) {
|
|
18071
|
-
(
|
|
18070
|
+
(_a25 = this.reconnectTimer) === null || _a25 === void 0 ? void 0 : _a25.scheduleTimeout();
|
|
18072
18071
|
}
|
|
18073
18072
|
this._triggerStateCallbacks("close", event);
|
|
18074
18073
|
}
|
|
@@ -18216,8 +18215,8 @@ Option 2: Install and provide the "ws" package:
|
|
|
18216
18215
|
* @internal
|
|
18217
18216
|
*/
|
|
18218
18217
|
_initializeOptions(options) {
|
|
18219
|
-
var
|
|
18220
|
-
this.transport = (
|
|
18218
|
+
var _a25, _b3, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
18219
|
+
this.transport = (_a25 = options === null || options === void 0 ? void 0 : options.transport) !== null && _a25 !== void 0 ? _a25 : null;
|
|
18221
18220
|
this.timeout = (_b3 = options === null || options === void 0 ? void 0 : options.timeout) !== null && _b3 !== void 0 ? _b3 : DEFAULT_TIMEOUT;
|
|
18222
18221
|
this.heartbeatIntervalMs = (_c = options === null || options === void 0 ? void 0 : options.heartbeatIntervalMs) !== null && _c !== void 0 ? _c : CONNECTION_TIMEOUTS.HEARTBEAT_INTERVAL;
|
|
18223
18222
|
this.worker = (_d = options === null || options === void 0 ? void 0 : options.worker) !== null && _d !== void 0 ? _d : false;
|
|
@@ -18263,14 +18262,14 @@ Option 2: Install and provide the "ws" package:
|
|
|
18263
18262
|
// node_modules/.pnpm/iceberg-js@0.8.1/node_modules/iceberg-js/dist/index.mjs
|
|
18264
18263
|
var IcebergError = class extends Error {
|
|
18265
18264
|
constructor(message, opts) {
|
|
18266
|
-
var
|
|
18265
|
+
var _a25;
|
|
18267
18266
|
super(message);
|
|
18268
18267
|
this.name = "IcebergError";
|
|
18269
18268
|
this.status = opts.status;
|
|
18270
18269
|
this.icebergType = opts.icebergType;
|
|
18271
18270
|
this.icebergCode = opts.icebergCode;
|
|
18272
18271
|
this.details = opts.details;
|
|
18273
|
-
this.isCommitStateUnknown = opts.icebergType === "CommitStateUnknownException" || [500, 502, 504].includes(opts.status) && ((
|
|
18272
|
+
this.isCommitStateUnknown = opts.icebergType === "CommitStateUnknownException" || [500, 502, 504].includes(opts.status) && ((_a25 = opts.icebergType) == null ? void 0 : _a25.includes("CommitState")) === true;
|
|
18274
18273
|
}
|
|
18275
18274
|
/**
|
|
18276
18275
|
* Returns true if the error is a 404 Not Found error.
|
|
@@ -18318,8 +18317,8 @@ async function buildAuthHeaders(auth) {
|
|
|
18318
18317
|
return {};
|
|
18319
18318
|
}
|
|
18320
18319
|
function createFetchClient(options) {
|
|
18321
|
-
var
|
|
18322
|
-
const fetchFn = (
|
|
18320
|
+
var _a25;
|
|
18321
|
+
const fetchFn = (_a25 = options.fetchImpl) != null ? _a25 : globalThis.fetch;
|
|
18323
18322
|
return {
|
|
18324
18323
|
async request({
|
|
18325
18324
|
method,
|
|
@@ -18328,7 +18327,7 @@ function createFetchClient(options) {
|
|
|
18328
18327
|
body,
|
|
18329
18328
|
headers
|
|
18330
18329
|
}) {
|
|
18331
|
-
var
|
|
18330
|
+
var _a26;
|
|
18332
18331
|
const url = buildUrl(options.baseUrl, path, query);
|
|
18333
18332
|
const authHeaders = await buildAuthHeaders(options.auth);
|
|
18334
18333
|
const res = await fetchFn(url, {
|
|
@@ -18347,7 +18346,7 @@ function createFetchClient(options) {
|
|
|
18347
18346
|
const errBody = isJson ? data : void 0;
|
|
18348
18347
|
const errorDetail = errBody == null ? void 0 : errBody.error;
|
|
18349
18348
|
throw new IcebergError(
|
|
18350
|
-
(
|
|
18349
|
+
(_a26 = errorDetail == null ? void 0 : errorDetail.message) != null ? _a26 : `Request failed with status ${res.status}`,
|
|
18351
18350
|
{
|
|
18352
18351
|
status: res.status,
|
|
18353
18352
|
icebergType: errorDetail == null ? void 0 : errorDetail.type,
|
|
@@ -18470,11 +18469,11 @@ var TableOperations = class {
|
|
|
18470
18469
|
};
|
|
18471
18470
|
}
|
|
18472
18471
|
async dropTable(id, options) {
|
|
18473
|
-
var
|
|
18472
|
+
var _a25;
|
|
18474
18473
|
await this.client.request({
|
|
18475
18474
|
method: "DELETE",
|
|
18476
18475
|
path: `${this.prefix}/namespaces/${namespaceToPath2(id.namespace)}/tables/${id.name}`,
|
|
18477
|
-
query: { purgeRequested: String((
|
|
18476
|
+
query: { purgeRequested: String((_a25 = options == null ? void 0 : options.purge) != null ? _a25 : false) }
|
|
18478
18477
|
});
|
|
18479
18478
|
}
|
|
18480
18479
|
async loadTable(id) {
|
|
@@ -18526,7 +18525,7 @@ var IcebergRestCatalog = class {
|
|
|
18526
18525
|
* @param options - Configuration options for the catalog client
|
|
18527
18526
|
*/
|
|
18528
18527
|
constructor(options) {
|
|
18529
|
-
var
|
|
18528
|
+
var _a25;
|
|
18530
18529
|
let prefix = "v1";
|
|
18531
18530
|
if (options.catalogName) {
|
|
18532
18531
|
prefix += `/${options.catalogName}`;
|
|
@@ -18537,7 +18536,7 @@ var IcebergRestCatalog = class {
|
|
|
18537
18536
|
auth: options.auth,
|
|
18538
18537
|
fetchImpl: options.fetch
|
|
18539
18538
|
});
|
|
18540
|
-
this.accessDelegation = (
|
|
18539
|
+
this.accessDelegation = (_a25 = options.accessDelegation) == null ? void 0 : _a25.join(",");
|
|
18541
18540
|
this.namespaceOps = new NamespaceOperations(this.client, prefix);
|
|
18542
18541
|
this.tableOps = new TableOperations(this.client, prefix, this.accessDelegation);
|
|
18543
18542
|
}
|
|
@@ -21510,7 +21509,7 @@ var getItemAsync = async (storage, key) => {
|
|
|
21510
21509
|
}
|
|
21511
21510
|
try {
|
|
21512
21511
|
return JSON.parse(value);
|
|
21513
|
-
} catch (
|
|
21512
|
+
} catch (_a25) {
|
|
21514
21513
|
return value;
|
|
21515
21514
|
}
|
|
21516
21515
|
};
|
|
@@ -21721,7 +21720,7 @@ function deepClone(obj) {
|
|
|
21721
21720
|
var _getErrorMessage2 = (err) => err.msg || err.message || err.error_description || err.error || JSON.stringify(err);
|
|
21722
21721
|
var NETWORK_ERROR_CODES = [502, 503, 504];
|
|
21723
21722
|
async function handleError2(error) {
|
|
21724
|
-
var
|
|
21723
|
+
var _a25;
|
|
21725
21724
|
if (!looksLikeFetchResponse(error)) {
|
|
21726
21725
|
throw new AuthRetryableFetchError(_getErrorMessage2(error), 0);
|
|
21727
21726
|
}
|
|
@@ -21746,7 +21745,7 @@ async function handleError2(error) {
|
|
|
21746
21745
|
throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, data.weak_password.reasons);
|
|
21747
21746
|
}
|
|
21748
21747
|
} else if (errorCode === "weak_password") {
|
|
21749
|
-
throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, ((
|
|
21748
|
+
throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, ((_a25 = data.weak_password) === null || _a25 === void 0 ? void 0 : _a25.reasons) || []);
|
|
21750
21749
|
} else if (errorCode === "session_not_found") {
|
|
21751
21750
|
throw new AuthSessionMissingError();
|
|
21752
21751
|
}
|
|
@@ -21762,7 +21761,7 @@ var _getRequestParams2 = (method, options, parameters, body) => {
|
|
|
21762
21761
|
return Object.assign(Object.assign({}, params), parameters);
|
|
21763
21762
|
};
|
|
21764
21763
|
async function _request(fetcher, method, url, options) {
|
|
21765
|
-
var
|
|
21764
|
+
var _a25;
|
|
21766
21765
|
const headers = Object.assign({}, options === null || options === void 0 ? void 0 : options.headers);
|
|
21767
21766
|
if (!headers[API_VERSION_HEADER_NAME]) {
|
|
21768
21767
|
headers[API_VERSION_HEADER_NAME] = API_VERSIONS["2024-01-01"].name;
|
|
@@ -21770,7 +21769,7 @@ async function _request(fetcher, method, url, options) {
|
|
|
21770
21769
|
if (options === null || options === void 0 ? void 0 : options.jwt) {
|
|
21771
21770
|
headers["Authorization"] = `Bearer ${options.jwt}`;
|
|
21772
21771
|
}
|
|
21773
|
-
const qs = (
|
|
21772
|
+
const qs = (_a25 = options === null || options === void 0 ? void 0 : options.query) !== null && _a25 !== void 0 ? _a25 : {};
|
|
21774
21773
|
if (options === null || options === void 0 ? void 0 : options.redirectTo) {
|
|
21775
21774
|
qs["redirect_to"] = options.redirectTo;
|
|
21776
21775
|
}
|
|
@@ -21803,7 +21802,7 @@ async function _handleRequest2(fetcher, method, url, options, parameters, body)
|
|
|
21803
21802
|
}
|
|
21804
21803
|
}
|
|
21805
21804
|
function _sessionResponse(data) {
|
|
21806
|
-
var
|
|
21805
|
+
var _a25;
|
|
21807
21806
|
let session = null;
|
|
21808
21807
|
if (hasSession(data)) {
|
|
21809
21808
|
session = Object.assign({}, data);
|
|
@@ -21811,7 +21810,7 @@ function _sessionResponse(data) {
|
|
|
21811
21810
|
session.expires_at = expiresAt(data.expires_in);
|
|
21812
21811
|
}
|
|
21813
21812
|
}
|
|
21814
|
-
const user = (
|
|
21813
|
+
const user = (_a25 = data.user) !== null && _a25 !== void 0 ? _a25 : data;
|
|
21815
21814
|
return { data: { session, user }, error: null };
|
|
21816
21815
|
}
|
|
21817
21816
|
function _sessionResponsePassword(data) {
|
|
@@ -21822,8 +21821,8 @@ function _sessionResponsePassword(data) {
|
|
|
21822
21821
|
return response;
|
|
21823
21822
|
}
|
|
21824
21823
|
function _userResponse(data) {
|
|
21825
|
-
var
|
|
21826
|
-
const user = (
|
|
21824
|
+
var _a25;
|
|
21825
|
+
const user = (_a25 = data.user) !== null && _a25 !== void 0 ? _a25 : data;
|
|
21827
21826
|
return { data: { user }, error: null };
|
|
21828
21827
|
}
|
|
21829
21828
|
function _ssoResponse(data) {
|
|
@@ -21992,14 +21991,14 @@ var GoTrueAdminApi = class {
|
|
|
21992
21991
|
* @param params An object which supports `page` and `perPage` as numbers, to alter the paginated results.
|
|
21993
21992
|
*/
|
|
21994
21993
|
async listUsers(params) {
|
|
21995
|
-
var
|
|
21994
|
+
var _a25, _b3, _c, _d, _e, _f, _g;
|
|
21996
21995
|
try {
|
|
21997
21996
|
const pagination = { nextPage: null, lastPage: 0, total: 0 };
|
|
21998
21997
|
const response = await _request(this.fetch, "GET", `${this.url}/admin/users`, {
|
|
21999
21998
|
headers: this.headers,
|
|
22000
21999
|
noResolveJson: true,
|
|
22001
22000
|
query: {
|
|
22002
|
-
page: (_b3 = (
|
|
22001
|
+
page: (_b3 = (_a25 = params === null || params === void 0 ? void 0 : params.page) === null || _a25 === void 0 ? void 0 : _a25.toString()) !== null && _b3 !== void 0 ? _b3 : "",
|
|
22003
22002
|
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 : ""
|
|
22004
22003
|
},
|
|
22005
22004
|
xform: _noResolveJsonResponse
|
|
@@ -22133,14 +22132,14 @@ var GoTrueAdminApi = class {
|
|
|
22133
22132
|
* This function should only be called on a server. Never expose your `service_role` key in the browser.
|
|
22134
22133
|
*/
|
|
22135
22134
|
async _listOAuthClients(params) {
|
|
22136
|
-
var
|
|
22135
|
+
var _a25, _b3, _c, _d, _e, _f, _g;
|
|
22137
22136
|
try {
|
|
22138
22137
|
const pagination = { nextPage: null, lastPage: 0, total: 0 };
|
|
22139
22138
|
const response = await _request(this.fetch, "GET", `${this.url}/admin/oauth/clients`, {
|
|
22140
22139
|
headers: this.headers,
|
|
22141
22140
|
noResolveJson: true,
|
|
22142
22141
|
query: {
|
|
22143
|
-
page: (_b3 = (
|
|
22142
|
+
page: (_b3 = (_a25 = params === null || params === void 0 ? void 0 : params.page) === null || _a25 === void 0 ? void 0 : _a25.toString()) !== null && _b3 !== void 0 ? _b3 : "",
|
|
22144
22143
|
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 : ""
|
|
22145
22144
|
},
|
|
22146
22145
|
xform: _noResolveJsonResponse
|
|
@@ -22393,7 +22392,7 @@ function toHex(value) {
|
|
|
22393
22392
|
return "0x" + hex;
|
|
22394
22393
|
}
|
|
22395
22394
|
function createSiweMessage(parameters) {
|
|
22396
|
-
var
|
|
22395
|
+
var _a25;
|
|
22397
22396
|
const { chainId, domain, expirationTime, issuedAt = /* @__PURE__ */ new Date(), nonce, notBefore, requestId, resources, scheme, uri, version: version5 } = parameters;
|
|
22398
22397
|
{
|
|
22399
22398
|
if (!Number.isInteger(chainId))
|
|
@@ -22406,7 +22405,7 @@ function createSiweMessage(parameters) {
|
|
|
22406
22405
|
throw new Error(`@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.`);
|
|
22407
22406
|
if (version5 !== "1")
|
|
22408
22407
|
throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${version5}`);
|
|
22409
|
-
if ((
|
|
22408
|
+
if ((_a25 = parameters.statement) === null || _a25 === void 0 ? void 0 : _a25.includes("\n"))
|
|
22410
22409
|
throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${parameters.statement}`);
|
|
22411
22410
|
}
|
|
22412
22411
|
const address = getAddress(parameters.address);
|
|
@@ -22448,10 +22447,10 @@ ${suffix}`;
|
|
|
22448
22447
|
// node_modules/.pnpm/@supabase+auth-js@2.95.1/node_modules/@supabase/auth-js/dist/module/lib/webauthn.errors.js
|
|
22449
22448
|
var WebAuthnError = class extends Error {
|
|
22450
22449
|
constructor({ message, code, cause, name }) {
|
|
22451
|
-
var
|
|
22450
|
+
var _a25;
|
|
22452
22451
|
super(message, { cause });
|
|
22453
22452
|
this.__isWebAuthnError = true;
|
|
22454
|
-
this.name = (
|
|
22453
|
+
this.name = (_a25 = name !== null && name !== void 0 ? name : cause instanceof Error ? cause.name : void 0) !== null && _a25 !== void 0 ? _a25 : "Unknown Error";
|
|
22455
22454
|
this.code = code;
|
|
22456
22455
|
}
|
|
22457
22456
|
};
|
|
@@ -22467,7 +22466,7 @@ var WebAuthnUnknownError = class extends WebAuthnError {
|
|
|
22467
22466
|
}
|
|
22468
22467
|
};
|
|
22469
22468
|
function identifyRegistrationError({ error, options }) {
|
|
22470
|
-
var
|
|
22469
|
+
var _a25, _b3, _c;
|
|
22471
22470
|
const { publicKey } = options;
|
|
22472
22471
|
if (!publicKey) {
|
|
22473
22472
|
throw Error("options was missing required publicKey property");
|
|
@@ -22481,7 +22480,7 @@ function identifyRegistrationError({ error, options }) {
|
|
|
22481
22480
|
});
|
|
22482
22481
|
}
|
|
22483
22482
|
} else if (error.name === "ConstraintError") {
|
|
22484
|
-
if (((
|
|
22483
|
+
if (((_a25 = publicKey.authenticatorSelection) === null || _a25 === void 0 ? void 0 : _a25.requireResidentKey) === true) {
|
|
22485
22484
|
return new WebAuthnError({
|
|
22486
22485
|
message: "Discoverable credentials were required but no available authenticator supported it",
|
|
22487
22486
|
code: "ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",
|
|
@@ -22710,7 +22709,7 @@ function deserializeCredentialRequestOptions(options) {
|
|
|
22710
22709
|
return result;
|
|
22711
22710
|
}
|
|
22712
22711
|
function serializeCredentialCreationResponse(credential) {
|
|
22713
|
-
var
|
|
22712
|
+
var _a25;
|
|
22714
22713
|
if ("toJSON" in credential && typeof credential.toJSON === "function") {
|
|
22715
22714
|
return credential.toJSON();
|
|
22716
22715
|
}
|
|
@@ -22725,11 +22724,11 @@ function serializeCredentialCreationResponse(credential) {
|
|
|
22725
22724
|
type: "public-key",
|
|
22726
22725
|
clientExtensionResults: credential.getClientExtensionResults(),
|
|
22727
22726
|
// Convert null to undefined and cast to AuthenticatorAttachment type
|
|
22728
|
-
authenticatorAttachment: (
|
|
22727
|
+
authenticatorAttachment: (_a25 = credentialWithAttachment.authenticatorAttachment) !== null && _a25 !== void 0 ? _a25 : void 0
|
|
22729
22728
|
};
|
|
22730
22729
|
}
|
|
22731
22730
|
function serializeCredentialRequestResponse(credential) {
|
|
22732
|
-
var
|
|
22731
|
+
var _a25;
|
|
22733
22732
|
if ("toJSON" in credential && typeof credential.toJSON === "function") {
|
|
22734
22733
|
return credential.toJSON();
|
|
22735
22734
|
}
|
|
@@ -22749,7 +22748,7 @@ function serializeCredentialRequestResponse(credential) {
|
|
|
22749
22748
|
type: "public-key",
|
|
22750
22749
|
clientExtensionResults,
|
|
22751
22750
|
// Convert null to undefined and cast to AuthenticatorAttachment type
|
|
22752
|
-
authenticatorAttachment: (
|
|
22751
|
+
authenticatorAttachment: (_a25 = credentialWithAttachment.authenticatorAttachment) !== null && _a25 !== void 0 ? _a25 : void 0
|
|
22753
22752
|
};
|
|
22754
22753
|
}
|
|
22755
22754
|
function isValidDomain(hostname) {
|
|
@@ -22759,8 +22758,8 @@ function isValidDomain(hostname) {
|
|
|
22759
22758
|
);
|
|
22760
22759
|
}
|
|
22761
22760
|
function browserSupportsWebAuthn() {
|
|
22762
|
-
var
|
|
22763
|
-
return !!(isBrowser() && "PublicKeyCredential" in window && window.PublicKeyCredential && "credentials" in navigator && typeof ((
|
|
22761
|
+
var _a25, _b3;
|
|
22762
|
+
return !!(isBrowser() && "PublicKeyCredential" in window && window.PublicKeyCredential && "credentials" in navigator && typeof ((_a25 = navigator === null || navigator === void 0 ? void 0 : navigator.credentials) === null || _a25 === void 0 ? void 0 : _a25.create) === "function" && typeof ((_b3 = navigator === null || navigator === void 0 ? void 0 : navigator.credentials) === null || _b3 === void 0 ? void 0 : _b3.get) === "function");
|
|
22764
22763
|
}
|
|
22765
22764
|
async function createCredential(options) {
|
|
22766
22765
|
try {
|
|
@@ -22908,7 +22907,7 @@ var WebAuthnApi = class {
|
|
|
22908
22907
|
* @see {@link https://w3c.github.io/webauthn/#sctn-verifying-assertion W3C WebAuthn Spec - Verifying Assertion}
|
|
22909
22908
|
*/
|
|
22910
22909
|
async _challenge({ factorId, webauthn, friendlyName, signal }, overrides) {
|
|
22911
|
-
var
|
|
22910
|
+
var _a25;
|
|
22912
22911
|
try {
|
|
22913
22912
|
const { data: challengeResponse, error: challengeError } = await this.client.mfa.challenge({
|
|
22914
22913
|
factorId,
|
|
@@ -22925,7 +22924,7 @@ var WebAuthnApi = class {
|
|
|
22925
22924
|
if (!nameToUse) {
|
|
22926
22925
|
const currentUser = await this.client.getUser();
|
|
22927
22926
|
const userData = currentUser.data.user;
|
|
22928
|
-
const fallbackName = ((
|
|
22927
|
+
const fallbackName = ((_a25 = userData === null || userData === void 0 ? void 0 : userData.user_metadata) === null || _a25 === void 0 ? void 0 : _a25.name) || (userData === null || userData === void 0 ? void 0 : userData.email) || (userData === null || userData === void 0 ? void 0 : userData.id) || "User";
|
|
22929
22928
|
user.name = `${user.id}:${fallbackName}`;
|
|
22930
22929
|
} else {
|
|
22931
22930
|
user.name = `${user.id}:${nameToUse}`;
|
|
@@ -23098,8 +23097,8 @@ var WebAuthnApi = class {
|
|
|
23098
23097
|
});
|
|
23099
23098
|
if (!factor) {
|
|
23100
23099
|
await this.client.mfa.listFactors().then((factors) => {
|
|
23101
|
-
var
|
|
23102
|
-
return (
|
|
23100
|
+
var _a25;
|
|
23101
|
+
return (_a25 = factors.data) === null || _a25 === void 0 ? void 0 : _a25.all.find((v) => v.factor_type === "webauthn" && v.friendly_name === friendlyName && v.status !== "unverified");
|
|
23103
23102
|
}).then((factor2) => factor2 ? this.client.mfa.unenroll({ factorId: factor2 === null || factor2 === void 0 ? void 0 : factor2.id }) : void 0);
|
|
23104
23103
|
return { data: null, error: enrollError };
|
|
23105
23104
|
}
|
|
@@ -23161,15 +23160,15 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23161
23160
|
* The JWKS used for verifying asymmetric JWTs
|
|
23162
23161
|
*/
|
|
23163
23162
|
get jwks() {
|
|
23164
|
-
var
|
|
23165
|
-
return (_b3 = (
|
|
23163
|
+
var _a25, _b3;
|
|
23164
|
+
return (_b3 = (_a25 = GLOBAL_JWKS[this.storageKey]) === null || _a25 === void 0 ? void 0 : _a25.jwks) !== null && _b3 !== void 0 ? _b3 : { keys: [] };
|
|
23166
23165
|
}
|
|
23167
23166
|
set jwks(value) {
|
|
23168
23167
|
GLOBAL_JWKS[this.storageKey] = Object.assign(Object.assign({}, GLOBAL_JWKS[this.storageKey]), { jwks: value });
|
|
23169
23168
|
}
|
|
23170
23169
|
get jwks_cached_at() {
|
|
23171
|
-
var
|
|
23172
|
-
return (_b3 = (
|
|
23170
|
+
var _a25, _b3;
|
|
23171
|
+
return (_b3 = (_a25 = GLOBAL_JWKS[this.storageKey]) === null || _a25 === void 0 ? void 0 : _a25.cachedAt) !== null && _b3 !== void 0 ? _b3 : Number.MIN_SAFE_INTEGER;
|
|
23173
23172
|
}
|
|
23174
23173
|
set jwks_cached_at(value) {
|
|
23175
23174
|
GLOBAL_JWKS[this.storageKey] = Object.assign(Object.assign({}, GLOBAL_JWKS[this.storageKey]), { cachedAt: value });
|
|
@@ -23189,7 +23188,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23189
23188
|
* ```
|
|
23190
23189
|
*/
|
|
23191
23190
|
constructor(options) {
|
|
23192
|
-
var
|
|
23191
|
+
var _a25, _b3, _c;
|
|
23193
23192
|
this.userStorage = null;
|
|
23194
23193
|
this.memoryStorage = null;
|
|
23195
23194
|
this.stateChangeEmitters = /* @__PURE__ */ new Map();
|
|
@@ -23207,7 +23206,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23207
23206
|
this.logger = console.log;
|
|
23208
23207
|
const settings = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options);
|
|
23209
23208
|
this.storageKey = settings.storageKey;
|
|
23210
|
-
this.instanceID = (
|
|
23209
|
+
this.instanceID = (_a25 = _GoTrueClient.nextInstanceID[this.storageKey]) !== null && _a25 !== void 0 ? _a25 : 0;
|
|
23211
23210
|
_GoTrueClient.nextInstanceID[this.storageKey] = this.instanceID + 1;
|
|
23212
23211
|
this.logDebugMessages = !!settings.debug;
|
|
23213
23212
|
if (typeof settings.debug === "function") {
|
|
@@ -23350,7 +23349,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23350
23349
|
* the whole lifetime of the client
|
|
23351
23350
|
*/
|
|
23352
23351
|
async _initialize() {
|
|
23353
|
-
var
|
|
23352
|
+
var _a25;
|
|
23354
23353
|
try {
|
|
23355
23354
|
let params = {};
|
|
23356
23355
|
let callbackUrlType = "none";
|
|
@@ -23367,7 +23366,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23367
23366
|
if (error) {
|
|
23368
23367
|
this._debug("#_initialize()", "error detecting session from URL", error);
|
|
23369
23368
|
if (isAuthImplicitGrantRedirectError(error)) {
|
|
23370
|
-
const errorCode = (
|
|
23369
|
+
const errorCode = (_a25 = error.details) === null || _a25 === void 0 ? void 0 : _a25.code;
|
|
23371
23370
|
if (errorCode === "identity_already_exists" || errorCode === "identity_not_found" || errorCode === "single_identity_not_deletable") {
|
|
23372
23371
|
return { error };
|
|
23373
23372
|
}
|
|
@@ -23406,12 +23405,12 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23406
23405
|
* @returns A session where the is_anonymous claim in the access token JWT set to true
|
|
23407
23406
|
*/
|
|
23408
23407
|
async signInAnonymously(credentials) {
|
|
23409
|
-
var
|
|
23408
|
+
var _a25, _b3, _c;
|
|
23410
23409
|
try {
|
|
23411
23410
|
const res = await _request(this.fetch, "POST", `${this.url}/signup`, {
|
|
23412
23411
|
headers: this.headers,
|
|
23413
23412
|
body: {
|
|
23414
|
-
data: (_b3 = (
|
|
23413
|
+
data: (_b3 = (_a25 = credentials === null || credentials === void 0 ? void 0 : credentials.options) === null || _a25 === void 0 ? void 0 : _a25.data) !== null && _b3 !== void 0 ? _b3 : {},
|
|
23415
23414
|
gotrue_meta_security: { captcha_token: (_c = credentials === null || credentials === void 0 ? void 0 : credentials.options) === null || _c === void 0 ? void 0 : _c.captchaToken }
|
|
23416
23415
|
},
|
|
23417
23416
|
xform: _sessionResponse
|
|
@@ -23445,7 +23444,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23445
23444
|
* @returns A user if the server has "autoconfirm" OFF
|
|
23446
23445
|
*/
|
|
23447
23446
|
async signUp(credentials) {
|
|
23448
|
-
var
|
|
23447
|
+
var _a25, _b3, _c;
|
|
23449
23448
|
try {
|
|
23450
23449
|
let res;
|
|
23451
23450
|
if ("email" in credentials) {
|
|
@@ -23462,7 +23461,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23462
23461
|
body: {
|
|
23463
23462
|
email,
|
|
23464
23463
|
password,
|
|
23465
|
-
data: (
|
|
23464
|
+
data: (_a25 = options === null || options === void 0 ? void 0 : options.data) !== null && _a25 !== void 0 ? _a25 : {},
|
|
23466
23465
|
gotrue_meta_security: { captcha_token: options === null || options === void 0 ? void 0 : options.captchaToken },
|
|
23467
23466
|
code_challenge: codeChallenge,
|
|
23468
23467
|
code_challenge_method: codeChallengeMethod
|
|
@@ -23568,9 +23567,9 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23568
23567
|
* This method supports the PKCE flow.
|
|
23569
23568
|
*/
|
|
23570
23569
|
async signInWithOAuth(credentials) {
|
|
23571
|
-
var
|
|
23570
|
+
var _a25, _b3, _c, _d;
|
|
23572
23571
|
return await this._handleProviderSignIn(credentials.provider, {
|
|
23573
|
-
redirectTo: (
|
|
23572
|
+
redirectTo: (_a25 = credentials.options) === null || _a25 === void 0 ? void 0 : _a25.redirectTo,
|
|
23574
23573
|
scopes: (_b3 = credentials.options) === null || _b3 === void 0 ? void 0 : _b3.scopes,
|
|
23575
23574
|
queryParams: (_c = credentials.options) === null || _c === void 0 ? void 0 : _c.queryParams,
|
|
23576
23575
|
skipBrowserRedirect: (_d = credentials.options) === null || _d === void 0 ? void 0 : _d.skipBrowserRedirect
|
|
@@ -23604,7 +23603,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23604
23603
|
}
|
|
23605
23604
|
}
|
|
23606
23605
|
async signInWithEthereum(credentials) {
|
|
23607
|
-
var
|
|
23606
|
+
var _a25, _b3, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
23608
23607
|
let message;
|
|
23609
23608
|
let signature;
|
|
23610
23609
|
if ("message" in credentials) {
|
|
@@ -23628,7 +23627,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23628
23627
|
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.`);
|
|
23629
23628
|
}
|
|
23630
23629
|
}
|
|
23631
|
-
const url = new URL((
|
|
23630
|
+
const url = new URL((_a25 = options === null || options === void 0 ? void 0 : options.url) !== null && _a25 !== void 0 ? _a25 : window.location.href);
|
|
23632
23631
|
const accounts = await resolvedWallet.request({
|
|
23633
23632
|
method: "eth_requestAccounts"
|
|
23634
23633
|
}).then((accs) => accs).catch(() => {
|
|
@@ -23695,7 +23694,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23695
23694
|
}
|
|
23696
23695
|
}
|
|
23697
23696
|
async signInWithSolana(credentials) {
|
|
23698
|
-
var
|
|
23697
|
+
var _a25, _b3, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
23699
23698
|
let message;
|
|
23700
23699
|
let signature;
|
|
23701
23700
|
if ("message" in credentials) {
|
|
@@ -23719,7 +23718,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23719
23718
|
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.`);
|
|
23720
23719
|
}
|
|
23721
23720
|
}
|
|
23722
|
-
const url = new URL((
|
|
23721
|
+
const url = new URL((_a25 = options === null || options === void 0 ? void 0 : options.url) !== null && _a25 !== void 0 ? _a25 : window.location.href);
|
|
23723
23722
|
if ("signIn" in resolvedWallet && resolvedWallet.signIn) {
|
|
23724
23723
|
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), {
|
|
23725
23724
|
// non-overridable properties
|
|
@@ -23891,7 +23890,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23891
23890
|
* This method supports PKCE when an email is passed.
|
|
23892
23891
|
*/
|
|
23893
23892
|
async signInWithOtp(credentials) {
|
|
23894
|
-
var
|
|
23893
|
+
var _a25, _b3, _c, _d, _e;
|
|
23895
23894
|
try {
|
|
23896
23895
|
if ("email" in credentials) {
|
|
23897
23896
|
const { email, options } = credentials;
|
|
@@ -23905,7 +23904,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23905
23904
|
headers: this.headers,
|
|
23906
23905
|
body: {
|
|
23907
23906
|
email,
|
|
23908
|
-
data: (
|
|
23907
|
+
data: (_a25 = options === null || options === void 0 ? void 0 : options.data) !== null && _a25 !== void 0 ? _a25 : {},
|
|
23909
23908
|
create_user: (_b3 = options === null || options === void 0 ? void 0 : options.shouldCreateUser) !== null && _b3 !== void 0 ? _b3 : true,
|
|
23910
23909
|
gotrue_meta_security: { captcha_token: options === null || options === void 0 ? void 0 : options.captchaToken },
|
|
23911
23910
|
code_challenge: codeChallenge,
|
|
@@ -23945,12 +23944,12 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23945
23944
|
* Log in a user given a User supplied OTP or TokenHash received through mobile or email.
|
|
23946
23945
|
*/
|
|
23947
23946
|
async verifyOtp(params) {
|
|
23948
|
-
var
|
|
23947
|
+
var _a25, _b3;
|
|
23949
23948
|
try {
|
|
23950
23949
|
let redirectTo = void 0;
|
|
23951
23950
|
let captchaToken = void 0;
|
|
23952
23951
|
if ("options" in params) {
|
|
23953
|
-
redirectTo = (
|
|
23952
|
+
redirectTo = (_a25 = params.options) === null || _a25 === void 0 ? void 0 : _a25.redirectTo;
|
|
23954
23953
|
captchaToken = (_b3 = params.options) === null || _b3 === void 0 ? void 0 : _b3.captchaToken;
|
|
23955
23954
|
}
|
|
23956
23955
|
const { data, error } = await _request(this.fetch, "POST", `${this.url}/verify`, {
|
|
@@ -23995,7 +23994,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23995
23994
|
* organization's SSO Identity Provider UUID directly instead.
|
|
23996
23995
|
*/
|
|
23997
23996
|
async signInWithSSO(params) {
|
|
23998
|
-
var
|
|
23997
|
+
var _a25, _b3, _c, _d, _e;
|
|
23999
23998
|
try {
|
|
24000
23999
|
let codeChallenge = null;
|
|
24001
24000
|
let codeChallengeMethod = null;
|
|
@@ -24004,7 +24003,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24004
24003
|
[codeChallenge, codeChallengeMethod] = await getCodeChallengeAndMethod(this.storage, this.storageKey);
|
|
24005
24004
|
}
|
|
24006
24005
|
const result = await _request(this.fetch, "POST", `${this.url}/sso`, {
|
|
24007
|
-
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 = (
|
|
24006
|
+
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 = (_a25 = params.options) === null || _a25 === void 0 ? void 0 : _a25.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 }),
|
|
24008
24007
|
headers: this.headers,
|
|
24009
24008
|
xform: _ssoResponse
|
|
24010
24009
|
});
|
|
@@ -24258,12 +24257,12 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24258
24257
|
});
|
|
24259
24258
|
}
|
|
24260
24259
|
return await this._useSession(async (result) => {
|
|
24261
|
-
var
|
|
24260
|
+
var _a25, _b3, _c;
|
|
24262
24261
|
const { data, error } = result;
|
|
24263
24262
|
if (error) {
|
|
24264
24263
|
throw error;
|
|
24265
24264
|
}
|
|
24266
|
-
if (!((
|
|
24265
|
+
if (!((_a25 = data.session) === null || _a25 === void 0 ? void 0 : _a25.access_token) && !this.hasCustomAuthorizationHeader) {
|
|
24267
24266
|
return { data: { user: null }, error: new AuthSessionMissingError() };
|
|
24268
24267
|
}
|
|
24269
24268
|
return await _request(this.fetch, "GET", `${this.url}/user`, {
|
|
@@ -24405,13 +24404,13 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24405
24404
|
async _refreshSession(currentSession) {
|
|
24406
24405
|
try {
|
|
24407
24406
|
return await this._useSession(async (result) => {
|
|
24408
|
-
var
|
|
24407
|
+
var _a25;
|
|
24409
24408
|
if (!currentSession) {
|
|
24410
24409
|
const { data, error: error2 } = result;
|
|
24411
24410
|
if (error2) {
|
|
24412
24411
|
throw error2;
|
|
24413
24412
|
}
|
|
24414
|
-
currentSession = (
|
|
24413
|
+
currentSession = (_a25 = data.session) !== null && _a25 !== void 0 ? _a25 : void 0;
|
|
24415
24414
|
}
|
|
24416
24415
|
if (!(currentSession === null || currentSession === void 0 ? void 0 : currentSession.refresh_token)) {
|
|
24417
24416
|
throw new AuthSessionMissingError();
|
|
@@ -24549,12 +24548,12 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24549
24548
|
}
|
|
24550
24549
|
async _signOut({ scope } = { scope: "global" }) {
|
|
24551
24550
|
return await this._useSession(async (result) => {
|
|
24552
|
-
var
|
|
24551
|
+
var _a25;
|
|
24553
24552
|
const { data, error: sessionError } = result;
|
|
24554
24553
|
if (sessionError && !isAuthSessionMissingError(sessionError)) {
|
|
24555
24554
|
return this._returnResult({ error: sessionError });
|
|
24556
24555
|
}
|
|
24557
|
-
const accessToken = (
|
|
24556
|
+
const accessToken = (_a25 = data.session) === null || _a25 === void 0 ? void 0 : _a25.access_token;
|
|
24558
24557
|
if (accessToken) {
|
|
24559
24558
|
const { error } = await this.admin.signOut(accessToken, scope);
|
|
24560
24559
|
if (error) {
|
|
@@ -24592,12 +24591,12 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24592
24591
|
}
|
|
24593
24592
|
async _emitInitialSession(id) {
|
|
24594
24593
|
return await this._useSession(async (result) => {
|
|
24595
|
-
var
|
|
24594
|
+
var _a25, _b3;
|
|
24596
24595
|
try {
|
|
24597
24596
|
const { data: { session }, error } = result;
|
|
24598
24597
|
if (error)
|
|
24599
24598
|
throw error;
|
|
24600
|
-
await ((
|
|
24599
|
+
await ((_a25 = this.stateChangeEmitters.get(id)) === null || _a25 === void 0 ? void 0 : _a25.callback("INITIAL_SESSION", session));
|
|
24601
24600
|
this._debug("INITIAL_SESSION", "callback id", id, "session", session);
|
|
24602
24601
|
} catch (err) {
|
|
24603
24602
|
await ((_b3 = this.stateChangeEmitters.get(id)) === null || _b3 === void 0 ? void 0 : _b3.callback("INITIAL_SESSION", null));
|
|
@@ -24648,12 +24647,12 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24648
24647
|
* Gets all the identities linked to a user.
|
|
24649
24648
|
*/
|
|
24650
24649
|
async getUserIdentities() {
|
|
24651
|
-
var
|
|
24650
|
+
var _a25;
|
|
24652
24651
|
try {
|
|
24653
24652
|
const { data, error } = await this.getUser();
|
|
24654
24653
|
if (error)
|
|
24655
24654
|
throw error;
|
|
24656
|
-
return this._returnResult({ data: { identities: (
|
|
24655
|
+
return this._returnResult({ data: { identities: (_a25 = data.user.identities) !== null && _a25 !== void 0 ? _a25 : [] }, error: null });
|
|
24657
24656
|
} catch (error) {
|
|
24658
24657
|
if (isAuthError(error)) {
|
|
24659
24658
|
return this._returnResult({ data: null, error });
|
|
@@ -24668,15 +24667,15 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24668
24667
|
return this.linkIdentityOAuth(credentials);
|
|
24669
24668
|
}
|
|
24670
24669
|
async linkIdentityOAuth(credentials) {
|
|
24671
|
-
var
|
|
24670
|
+
var _a25;
|
|
24672
24671
|
try {
|
|
24673
24672
|
const { data, error } = await this._useSession(async (result) => {
|
|
24674
|
-
var
|
|
24673
|
+
var _a26, _b3, _c, _d, _e;
|
|
24675
24674
|
const { data: data2, error: error2 } = result;
|
|
24676
24675
|
if (error2)
|
|
24677
24676
|
throw error2;
|
|
24678
24677
|
const url = await this._getUrlForProvider(`${this.url}/user/identities/authorize`, credentials.provider, {
|
|
24679
|
-
redirectTo: (
|
|
24678
|
+
redirectTo: (_a26 = credentials.options) === null || _a26 === void 0 ? void 0 : _a26.redirectTo,
|
|
24680
24679
|
scopes: (_b3 = credentials.options) === null || _b3 === void 0 ? void 0 : _b3.scopes,
|
|
24681
24680
|
queryParams: (_c = credentials.options) === null || _c === void 0 ? void 0 : _c.queryParams,
|
|
24682
24681
|
skipBrowserRedirect: true
|
|
@@ -24688,7 +24687,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24688
24687
|
});
|
|
24689
24688
|
if (error)
|
|
24690
24689
|
throw error;
|
|
24691
|
-
if (isBrowser() && !((
|
|
24690
|
+
if (isBrowser() && !((_a25 = credentials.options) === null || _a25 === void 0 ? void 0 : _a25.skipBrowserRedirect)) {
|
|
24692
24691
|
window.location.assign(data === null || data === void 0 ? void 0 : data.url);
|
|
24693
24692
|
}
|
|
24694
24693
|
return this._returnResult({
|
|
@@ -24704,7 +24703,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24704
24703
|
}
|
|
24705
24704
|
async linkIdentityIdToken(credentials) {
|
|
24706
24705
|
return await this._useSession(async (result) => {
|
|
24707
|
-
var
|
|
24706
|
+
var _a25;
|
|
24708
24707
|
try {
|
|
24709
24708
|
const { error: sessionError, data: { session } } = result;
|
|
24710
24709
|
if (sessionError)
|
|
@@ -24712,7 +24711,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24712
24711
|
const { options, provider, token, access_token, nonce } = credentials;
|
|
24713
24712
|
const res = await _request(this.fetch, "POST", `${this.url}/token?grant_type=id_token`, {
|
|
24714
24713
|
headers: this.headers,
|
|
24715
|
-
jwt: (
|
|
24714
|
+
jwt: (_a25 = session === null || session === void 0 ? void 0 : session.access_token) !== null && _a25 !== void 0 ? _a25 : void 0,
|
|
24716
24715
|
body: {
|
|
24717
24716
|
provider,
|
|
24718
24717
|
id_token: token,
|
|
@@ -24752,14 +24751,14 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24752
24751
|
async unlinkIdentity(identity) {
|
|
24753
24752
|
try {
|
|
24754
24753
|
return await this._useSession(async (result) => {
|
|
24755
|
-
var
|
|
24754
|
+
var _a25, _b3;
|
|
24756
24755
|
const { data, error } = result;
|
|
24757
24756
|
if (error) {
|
|
24758
24757
|
throw error;
|
|
24759
24758
|
}
|
|
24760
24759
|
return await _request(this.fetch, "DELETE", `${this.url}/user/identities/${identity.identity_id}`, {
|
|
24761
24760
|
headers: this.headers,
|
|
24762
|
-
jwt: (_b3 = (
|
|
24761
|
+
jwt: (_b3 = (_a25 = data.session) === null || _a25 === void 0 ? void 0 : _a25.access_token) !== null && _b3 !== void 0 ? _b3 : void 0
|
|
24763
24762
|
});
|
|
24764
24763
|
});
|
|
24765
24764
|
} catch (error) {
|
|
@@ -24824,7 +24823,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24824
24823
|
* Note: this method is async to accommodate for AsyncStorage e.g. in React native.
|
|
24825
24824
|
*/
|
|
24826
24825
|
async _recoverAndRefresh() {
|
|
24827
|
-
var
|
|
24826
|
+
var _a25, _b3;
|
|
24828
24827
|
const debugName = "#_recoverAndRefresh()";
|
|
24829
24828
|
this._debug(debugName, "begin");
|
|
24830
24829
|
try {
|
|
@@ -24835,7 +24834,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24835
24834
|
maybeUser = { user: currentSession.user };
|
|
24836
24835
|
await setItemAsync(this.userStorage, this.storageKey + "-user", maybeUser);
|
|
24837
24836
|
}
|
|
24838
|
-
currentSession.user = (
|
|
24837
|
+
currentSession.user = (_a25 = maybeUser === null || maybeUser === void 0 ? void 0 : maybeUser.user) !== null && _a25 !== void 0 ? _a25 : userNotAvailableProxy();
|
|
24839
24838
|
} else if (currentSession && !currentSession.user) {
|
|
24840
24839
|
if (!currentSession.user) {
|
|
24841
24840
|
const separateUser = await getItemAsync(this.storage, this.storageKey + "-user");
|
|
@@ -24895,7 +24894,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24895
24894
|
}
|
|
24896
24895
|
}
|
|
24897
24896
|
async _callRefreshToken(refreshToken) {
|
|
24898
|
-
var
|
|
24897
|
+
var _a25, _b3;
|
|
24899
24898
|
if (!refreshToken) {
|
|
24900
24899
|
throw new AuthSessionMissingError();
|
|
24901
24900
|
}
|
|
@@ -24923,7 +24922,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24923
24922
|
if (!isAuthRetryableFetchError(error)) {
|
|
24924
24923
|
await this._removeSession();
|
|
24925
24924
|
}
|
|
24926
|
-
(
|
|
24925
|
+
(_a25 = this.refreshingDeferred) === null || _a25 === void 0 ? void 0 : _a25.resolve(result);
|
|
24927
24926
|
return result;
|
|
24928
24927
|
}
|
|
24929
24928
|
(_b3 = this.refreshingDeferred) === null || _b3 === void 0 ? void 0 : _b3.reject(error);
|
|
@@ -25218,14 +25217,14 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
25218
25217
|
async _unenroll(params) {
|
|
25219
25218
|
try {
|
|
25220
25219
|
return await this._useSession(async (result) => {
|
|
25221
|
-
var
|
|
25220
|
+
var _a25;
|
|
25222
25221
|
const { data: sessionData, error: sessionError } = result;
|
|
25223
25222
|
if (sessionError) {
|
|
25224
25223
|
return this._returnResult({ data: null, error: sessionError });
|
|
25225
25224
|
}
|
|
25226
25225
|
return await _request(this.fetch, "DELETE", `${this.url}/factors/${params.factorId}`, {
|
|
25227
25226
|
headers: this.headers,
|
|
25228
|
-
jwt: (
|
|
25227
|
+
jwt: (_a25 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a25 === void 0 ? void 0 : _a25.access_token
|
|
25229
25228
|
});
|
|
25230
25229
|
});
|
|
25231
25230
|
} catch (error) {
|
|
@@ -25238,7 +25237,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
25238
25237
|
async _enroll(params) {
|
|
25239
25238
|
try {
|
|
25240
25239
|
return await this._useSession(async (result) => {
|
|
25241
|
-
var
|
|
25240
|
+
var _a25, _b3;
|
|
25242
25241
|
const { data: sessionData, error: sessionError } = result;
|
|
25243
25242
|
if (sessionError) {
|
|
25244
25243
|
return this._returnResult({ data: null, error: sessionError });
|
|
@@ -25247,7 +25246,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
25247
25246
|
const { data, error } = await _request(this.fetch, "POST", `${this.url}/factors`, {
|
|
25248
25247
|
body,
|
|
25249
25248
|
headers: this.headers,
|
|
25250
|
-
jwt: (
|
|
25249
|
+
jwt: (_a25 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a25 === void 0 ? void 0 : _a25.access_token
|
|
25251
25250
|
});
|
|
25252
25251
|
if (error) {
|
|
25253
25252
|
return this._returnResult({ data: null, error });
|
|
@@ -25268,7 +25267,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
25268
25267
|
return this._acquireLock(this.lockAcquireTimeout, async () => {
|
|
25269
25268
|
try {
|
|
25270
25269
|
return await this._useSession(async (result) => {
|
|
25271
|
-
var
|
|
25270
|
+
var _a25;
|
|
25272
25271
|
const { data: sessionData, error: sessionError } = result;
|
|
25273
25272
|
if (sessionError) {
|
|
25274
25273
|
return this._returnResult({ data: null, error: sessionError });
|
|
@@ -25279,7 +25278,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
25279
25278
|
const { data, error } = await _request(this.fetch, "POST", `${this.url}/factors/${params.factorId}/verify`, {
|
|
25280
25279
|
body,
|
|
25281
25280
|
headers: this.headers,
|
|
25282
|
-
jwt: (
|
|
25281
|
+
jwt: (_a25 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a25 === void 0 ? void 0 : _a25.access_token
|
|
25283
25282
|
});
|
|
25284
25283
|
if (error) {
|
|
25285
25284
|
return this._returnResult({ data: null, error });
|
|
@@ -25300,7 +25299,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
25300
25299
|
return this._acquireLock(this.lockAcquireTimeout, async () => {
|
|
25301
25300
|
try {
|
|
25302
25301
|
return await this._useSession(async (result) => {
|
|
25303
|
-
var
|
|
25302
|
+
var _a25;
|
|
25304
25303
|
const { data: sessionData, error: sessionError } = result;
|
|
25305
25304
|
if (sessionError) {
|
|
25306
25305
|
return this._returnResult({ data: null, error: sessionError });
|
|
@@ -25308,7 +25307,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
25308
25307
|
const response = await _request(this.fetch, "POST", `${this.url}/factors/${params.factorId}/challenge`, {
|
|
25309
25308
|
body: params,
|
|
25310
25309
|
headers: this.headers,
|
|
25311
|
-
jwt: (
|
|
25310
|
+
jwt: (_a25 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a25 === void 0 ? void 0 : _a25.access_token
|
|
25312
25311
|
});
|
|
25313
25312
|
if (response.error) {
|
|
25314
25313
|
return response;
|
|
@@ -25358,7 +25357,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
25358
25357
|
* {@see GoTrueMFAApi#listFactors}
|
|
25359
25358
|
*/
|
|
25360
25359
|
async _listFactors() {
|
|
25361
|
-
var
|
|
25360
|
+
var _a25;
|
|
25362
25361
|
const { data: { user }, error: userError } = await this.getUser();
|
|
25363
25362
|
if (userError) {
|
|
25364
25363
|
return { data: null, error: userError };
|
|
@@ -25369,7 +25368,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
25369
25368
|
totp: [],
|
|
25370
25369
|
webauthn: []
|
|
25371
25370
|
};
|
|
25372
|
-
for (const factor of (
|
|
25371
|
+
for (const factor of (_a25 = user === null || user === void 0 ? void 0 : user.factors) !== null && _a25 !== void 0 ? _a25 : []) {
|
|
25373
25372
|
data.all.push(factor);
|
|
25374
25373
|
if (factor.status === "verified") {
|
|
25375
25374
|
;
|
|
@@ -25385,7 +25384,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
25385
25384
|
* {@see GoTrueMFAApi#getAuthenticatorAssuranceLevel}
|
|
25386
25385
|
*/
|
|
25387
25386
|
async _getAuthenticatorAssuranceLevel(jwt) {
|
|
25388
|
-
var
|
|
25387
|
+
var _a25, _b3, _c, _d;
|
|
25389
25388
|
if (jwt) {
|
|
25390
25389
|
try {
|
|
25391
25390
|
const { payload: payload2 } = decodeJWT(jwt);
|
|
@@ -25398,7 +25397,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
25398
25397
|
if (userError) {
|
|
25399
25398
|
return this._returnResult({ data: null, error: userError });
|
|
25400
25399
|
}
|
|
25401
|
-
const verifiedFactors2 = (_b3 = (
|
|
25400
|
+
const verifiedFactors2 = (_b3 = (_a25 = user === null || user === void 0 ? void 0 : user.factors) === null || _a25 === void 0 ? void 0 : _a25.filter((factor) => factor.status === "verified")) !== null && _b3 !== void 0 ? _b3 : [];
|
|
25402
25401
|
if (verifiedFactors2.length > 0) {
|
|
25403
25402
|
nextLevel2 = "aal2";
|
|
25404
25403
|
}
|
|
@@ -26035,10 +26034,10 @@ if (shouldShowDeprecationWarning()) console.warn("\u26A0\uFE0F Node.js 18 and b
|
|
|
26035
26034
|
var cachedStargate = null;
|
|
26036
26035
|
var cachedPublic = null;
|
|
26037
26036
|
function getSupabase() {
|
|
26038
|
-
var
|
|
26037
|
+
var _a25;
|
|
26039
26038
|
if (cachedStargate) return cachedStargate;
|
|
26040
26039
|
const url = getRuntimeEnv("VITE_SUPABASE_URL");
|
|
26041
|
-
const anon = (
|
|
26040
|
+
const anon = (_a25 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a25 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY");
|
|
26042
26041
|
const schema = getRuntimeEnvOr("VITE_SUPABASE_SCHEMA", "public");
|
|
26043
26042
|
if (!url || !anon) {
|
|
26044
26043
|
return null;
|
|
@@ -26053,10 +26052,10 @@ function getSupabase() {
|
|
|
26053
26052
|
return cachedStargate;
|
|
26054
26053
|
}
|
|
26055
26054
|
function getSupabasePublic() {
|
|
26056
|
-
var
|
|
26055
|
+
var _a25;
|
|
26057
26056
|
if (cachedPublic) return cachedPublic;
|
|
26058
26057
|
const url = getRuntimeEnv("VITE_SUPABASE_URL");
|
|
26059
|
-
const anon = (
|
|
26058
|
+
const anon = (_a25 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a25 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY");
|
|
26060
26059
|
if (!url || !anon) {
|
|
26061
26060
|
return null;
|
|
26062
26061
|
}
|
|
@@ -26272,13 +26271,13 @@ var toTimestampMs = (value) => {
|
|
|
26272
26271
|
return Number.isNaN(parsed) ? void 0 : parsed;
|
|
26273
26272
|
};
|
|
26274
26273
|
var readStoredProfileAvatar = () => {
|
|
26275
|
-
var
|
|
26274
|
+
var _a25;
|
|
26276
26275
|
if (typeof window === "undefined") return void 0;
|
|
26277
26276
|
const raw = localStorage.getItem(STORAGE_KEYS.profileAvatar) || sessionStorage.getItem(STORAGE_KEYS.profileAvatar);
|
|
26278
26277
|
if (!raw) return void 0;
|
|
26279
26278
|
try {
|
|
26280
26279
|
const parsed = JSON.parse(raw);
|
|
26281
|
-
return (
|
|
26280
|
+
return (_a25 = toNonEmptyString(parsed.avatarUrl)) != null ? _a25 : toNonEmptyString(parsed.avatarId);
|
|
26282
26281
|
} catch (e) {
|
|
26283
26282
|
return toNonEmptyString(raw);
|
|
26284
26283
|
}
|
|
@@ -26309,8 +26308,8 @@ var readPresenceRow = (payload) => {
|
|
|
26309
26308
|
return null;
|
|
26310
26309
|
};
|
|
26311
26310
|
var isMissingColumnError = (error, column) => {
|
|
26312
|
-
var
|
|
26313
|
-
const message = ((
|
|
26311
|
+
var _a25;
|
|
26312
|
+
const message = ((_a25 = error == null ? void 0 : error.message) != null ? _a25 : "").toLowerCase();
|
|
26314
26313
|
const code = error == null ? void 0 : error.code;
|
|
26315
26314
|
const token = column.trim().toLowerCase();
|
|
26316
26315
|
if (!token) return false;
|
|
@@ -26332,8 +26331,8 @@ var readStoredPresence = () => {
|
|
|
26332
26331
|
return isUserPresenceStatus(stored) ? stored : DEFAULT_PRESENCE_STATUS;
|
|
26333
26332
|
};
|
|
26334
26333
|
var readStoredPresenceSource = () => {
|
|
26335
|
-
var
|
|
26336
|
-
const stored = (
|
|
26334
|
+
var _a25;
|
|
26335
|
+
const stored = (_a25 = sessionStorage.getItem(STORAGE_KEYS.presenceSource)) != null ? _a25 : localStorage.getItem(LOCAL_STORAGE_KEYS.presenceSource);
|
|
26337
26336
|
if (isPresenceSource(stored)) return stored;
|
|
26338
26337
|
return "auto";
|
|
26339
26338
|
};
|
|
@@ -26380,9 +26379,9 @@ var readClaimValue = (claims, keys) => {
|
|
|
26380
26379
|
return void 0;
|
|
26381
26380
|
};
|
|
26382
26381
|
var readClaimRole = (claims) => {
|
|
26383
|
-
var
|
|
26382
|
+
var _a25, _b3, _c;
|
|
26384
26383
|
if (!claims) return void 0;
|
|
26385
|
-
const roleClaim = (_c = (_b3 = (
|
|
26384
|
+
const roleClaim = (_c = (_b3 = (_a25 = claims.role) != null ? _a25 : claims.roles) != null ? _b3 : claims["https://cupcode.com/role"]) != null ? _c : claims["https://cupcode.com/roles"];
|
|
26386
26385
|
if (typeof roleClaim === "string") return toNonEmptyString(roleClaim);
|
|
26387
26386
|
if (Array.isArray(roleClaim)) {
|
|
26388
26387
|
return roleClaim.find((entry) => typeof entry === "string" && entry.trim() !== "");
|
|
@@ -26393,7 +26392,7 @@ var buildUserFromTokens = ({
|
|
|
26393
26392
|
idToken,
|
|
26394
26393
|
accessToken
|
|
26395
26394
|
}) => {
|
|
26396
|
-
var
|
|
26395
|
+
var _a25;
|
|
26397
26396
|
const idClaims = decodeJwt(idToken != null ? idToken : void 0);
|
|
26398
26397
|
const accessClaims = decodeJwt(accessToken != null ? accessToken : void 0);
|
|
26399
26398
|
if (!idClaims && !accessClaims) return null;
|
|
@@ -26420,7 +26419,7 @@ var buildUserFromTokens = ({
|
|
|
26420
26419
|
"id",
|
|
26421
26420
|
"sub"
|
|
26422
26421
|
]);
|
|
26423
|
-
const resolvedSub = (
|
|
26422
|
+
const resolvedSub = (_a25 = readFromClaims(["sub"])) != null ? _a25 : resolvedId;
|
|
26424
26423
|
const preferredUsername = readFromClaims([
|
|
26425
26424
|
"preferred_username",
|
|
26426
26425
|
"preferredUsername",
|
|
@@ -26499,11 +26498,11 @@ var AuthProvider = ({ children }) => {
|
|
|
26499
26498
|
}
|
|
26500
26499
|
}, []);
|
|
26501
26500
|
const resolvePresenceUserId = (0, import_react32.useCallback)(async (targetUser) => {
|
|
26502
|
-
var
|
|
26501
|
+
var _a25, _b3, _c, _d;
|
|
26503
26502
|
const sub = toNonEmptyString(targetUser == null ? void 0 : targetUser.sub);
|
|
26504
26503
|
const id = toNonEmptyString(targetUser == null ? void 0 : targetUser.id);
|
|
26505
26504
|
const userId = toNonEmptyString(targetUser == null ? void 0 : targetUser.userId);
|
|
26506
|
-
const email = (
|
|
26505
|
+
const email = (_a25 = toNonEmptyString(targetUser == null ? void 0 : targetUser.email)) == null ? void 0 : _a25.toLowerCase();
|
|
26507
26506
|
const identityKey = [sub != null ? sub : "", id != null ? id : "", userId != null ? userId : "", email != null ? email : ""].join("|");
|
|
26508
26507
|
if (resolvedPresenceIdentityKeyRef.current === identityKey && resolvedPresenceUserIdRef.current) {
|
|
26509
26508
|
return resolvedPresenceUserIdRef.current;
|
|
@@ -26538,9 +26537,9 @@ var AuthProvider = ({ children }) => {
|
|
|
26538
26537
|
}, []);
|
|
26539
26538
|
const syncPresenceFromRecord = (0, import_react32.useCallback)(
|
|
26540
26539
|
(rawRow) => {
|
|
26541
|
-
var
|
|
26540
|
+
var _a25, _b3, _c;
|
|
26542
26541
|
if (!rawRow) return;
|
|
26543
|
-
const statusValue = toNonEmptyString((
|
|
26542
|
+
const statusValue = toNonEmptyString((_a25 = rawRow[USER_PRESENCE_STATUS_COLUMN]) != null ? _a25 : rawRow.status);
|
|
26544
26543
|
if (!isUserPresenceStatus(statusValue)) return;
|
|
26545
26544
|
const sourceValue = normalizePresenceSource((_b3 = rawRow[USER_PRESENCE_SOURCE_COLUMN]) != null ? _b3 : rawRow.status_source);
|
|
26546
26545
|
const lastActiveTimestamp = toTimestampMs((_c = rawRow[USER_PRESENCE_LAST_ACTIVE_COLUMN]) != null ? _c : rawRow.last_active_at);
|
|
@@ -26616,8 +26615,8 @@ var AuthProvider = ({ children }) => {
|
|
|
26616
26615
|
);
|
|
26617
26616
|
const touchPresence = (0, import_react32.useCallback)(
|
|
26618
26617
|
async (options) => {
|
|
26619
|
-
var
|
|
26620
|
-
const targetUser = (
|
|
26618
|
+
var _a25;
|
|
26619
|
+
const targetUser = (_a25 = options == null ? void 0 : options.targetUser) != null ? _a25 : user;
|
|
26621
26620
|
const userId = await resolvePresenceUserId(targetUser);
|
|
26622
26621
|
if (!userId) return;
|
|
26623
26622
|
const now = Date.now();
|
|
@@ -26742,7 +26741,7 @@ var AuthProvider = ({ children }) => {
|
|
|
26742
26741
|
}, []);
|
|
26743
26742
|
const startAuthorization = (0, import_react32.useCallback)(
|
|
26744
26743
|
async (options) => {
|
|
26745
|
-
var
|
|
26744
|
+
var _a25, _b3;
|
|
26746
26745
|
const config = getAccountsConfig();
|
|
26747
26746
|
const { authUrl } = await resolveOidcEndpoints(config);
|
|
26748
26747
|
if (!authUrl) {
|
|
@@ -26752,7 +26751,7 @@ var AuthProvider = ({ children }) => {
|
|
|
26752
26751
|
const challenge = await generateCodeChallenge(verifier);
|
|
26753
26752
|
const state = generateState();
|
|
26754
26753
|
const nonce = generateNonce();
|
|
26755
|
-
const redirectTo = (
|
|
26754
|
+
const redirectTo = (_a25 = options == null ? void 0 : options.redirectTo) != null ? _a25 : window.location.pathname + window.location.search + window.location.hash;
|
|
26756
26755
|
const mode = (_b3 = options == null ? void 0 : options.mode) != null ? _b3 : "interactive";
|
|
26757
26756
|
if (mode === "interactive") {
|
|
26758
26757
|
clearLogoutIntent();
|
|
@@ -26787,14 +26786,14 @@ var AuthProvider = ({ children }) => {
|
|
|
26787
26786
|
(0, import_react32.useEffect)(() => {
|
|
26788
26787
|
let cancelled = false;
|
|
26789
26788
|
const initializeAuth = async () => {
|
|
26790
|
-
var
|
|
26789
|
+
var _a25;
|
|
26791
26790
|
const stored = readStoredToken();
|
|
26792
26791
|
const storedPresence = readStoredPresence();
|
|
26793
26792
|
setPresenceStatusState(storedPresence);
|
|
26794
26793
|
if (stored == null ? void 0 : stored.accessToken) {
|
|
26795
26794
|
if (cancelled) return;
|
|
26796
26795
|
const hydratedUser = buildUserFromTokens({
|
|
26797
|
-
idToken: (
|
|
26796
|
+
idToken: (_a25 = stored.idToken) != null ? _a25 : void 0,
|
|
26798
26797
|
accessToken: stored.accessToken
|
|
26799
26798
|
});
|
|
26800
26799
|
setAccessToken(stored.accessToken);
|
|
@@ -26830,13 +26829,13 @@ var AuthProvider = ({ children }) => {
|
|
|
26830
26829
|
};
|
|
26831
26830
|
}, [attemptSilentLogin]);
|
|
26832
26831
|
(0, import_react32.useEffect)(() => {
|
|
26833
|
-
var
|
|
26832
|
+
var _a25;
|
|
26834
26833
|
if (status !== "authenticated") return;
|
|
26835
26834
|
if (user) return;
|
|
26836
26835
|
const stored = readStoredToken();
|
|
26837
26836
|
if (!(stored == null ? void 0 : stored.accessToken)) return;
|
|
26838
26837
|
const hydratedUser = buildUserFromTokens({
|
|
26839
|
-
idToken: (
|
|
26838
|
+
idToken: (_a25 = stored.idToken) != null ? _a25 : void 0,
|
|
26840
26839
|
accessToken: stored.accessToken
|
|
26841
26840
|
});
|
|
26842
26841
|
if (!hydratedUser) return;
|
|
@@ -26882,9 +26881,9 @@ var AuthProvider = ({ children }) => {
|
|
|
26882
26881
|
table: USER_PRESENCE_TABLE
|
|
26883
26882
|
},
|
|
26884
26883
|
(payload) => {
|
|
26885
|
-
var
|
|
26884
|
+
var _a25, _b3;
|
|
26886
26885
|
const row = payload.new || payload.old;
|
|
26887
|
-
const rowUserId = toNonEmptyString((_b3 = (
|
|
26886
|
+
const rowUserId = toNonEmptyString((_b3 = (_a25 = row == null ? void 0 : row[USER_PRESENCE_USER_ID_COLUMN]) != null ? _a25 : row == null ? void 0 : row.user_id) != null ? _b3 : row == null ? void 0 : row.id);
|
|
26888
26887
|
if (!rowUserId || rowUserId !== currentUserId) return;
|
|
26889
26888
|
if (payload.eventType === "DELETE") {
|
|
26890
26889
|
storePresenceStatus("offline", "system");
|
|
@@ -26958,9 +26957,9 @@ var AuthProvider = ({ children }) => {
|
|
|
26958
26957
|
});
|
|
26959
26958
|
}, [startAuthorization]);
|
|
26960
26959
|
const completeLogin = (0, import_react32.useCallback)(async () => {
|
|
26961
|
-
var
|
|
26960
|
+
var _a25;
|
|
26962
26961
|
const params = new URLSearchParams(window.location.search);
|
|
26963
|
-
const redirectTo = (
|
|
26962
|
+
const redirectTo = (_a25 = sessionStorage.getItem(STORAGE_KEYS.redirect)) != null ? _a25 : "/";
|
|
26964
26963
|
const authMode = sessionStorage.getItem(STORAGE_KEYS.authMode);
|
|
26965
26964
|
const isSilentAuth = authMode === "silent";
|
|
26966
26965
|
const error = params.get("error");
|
|
@@ -27032,10 +27031,10 @@ var AuthProvider = ({ children }) => {
|
|
|
27032
27031
|
}
|
|
27033
27032
|
}, [clearAuthFlowState]);
|
|
27034
27033
|
const logout = (0, import_react32.useCallback)(async () => {
|
|
27035
|
-
var
|
|
27034
|
+
var _a25, _b3;
|
|
27036
27035
|
const config = getAccountsConfig();
|
|
27037
27036
|
const { logoutUrl } = await resolveOidcEndpoints(config);
|
|
27038
|
-
const idToken = (
|
|
27037
|
+
const idToken = (_a25 = sessionStorage.getItem(STORAGE_KEYS.idToken)) != null ? _a25 : void 0;
|
|
27039
27038
|
const refreshToken = (_b3 = sessionStorage.getItem(STORAGE_KEYS.refreshToken)) != null ? _b3 : void 0;
|
|
27040
27039
|
const currentUser = user;
|
|
27041
27040
|
await setPresenceNetworkStatus("offline", "system", currentUser);
|
|
@@ -27059,8 +27058,8 @@ var AuthProvider = ({ children }) => {
|
|
|
27059
27058
|
return refreshInFlightRef.current;
|
|
27060
27059
|
}
|
|
27061
27060
|
const run = (async () => {
|
|
27062
|
-
var
|
|
27063
|
-
const refreshToken = (
|
|
27061
|
+
var _a25, _b3, _c;
|
|
27062
|
+
const refreshToken = (_a25 = sessionStorage.getItem(STORAGE_KEYS.refreshToken)) == null ? void 0 : _a25.trim();
|
|
27064
27063
|
if (!refreshToken) {
|
|
27065
27064
|
throw new Error("Sess\xE3o expirada. Fa\xE7a login novamente.");
|
|
27066
27065
|
}
|
|
@@ -27093,11 +27092,11 @@ var AuthProvider = ({ children }) => {
|
|
|
27093
27092
|
}
|
|
27094
27093
|
}, []);
|
|
27095
27094
|
const getAccessToken = (0, import_react32.useCallback)(async () => {
|
|
27096
|
-
var
|
|
27095
|
+
var _a25;
|
|
27097
27096
|
const stored = readStoredToken();
|
|
27098
27097
|
if (stored == null ? void 0 : stored.accessToken) return stored.accessToken;
|
|
27099
27098
|
if (accessToken) return accessToken;
|
|
27100
|
-
const hasRefreshToken = Boolean((
|
|
27099
|
+
const hasRefreshToken = Boolean((_a25 = sessionStorage.getItem(STORAGE_KEYS.refreshToken)) == null ? void 0 : _a25.trim());
|
|
27101
27100
|
if (hasRefreshToken) {
|
|
27102
27101
|
return refreshAccessToken();
|
|
27103
27102
|
}
|
|
@@ -27137,65 +27136,6 @@ var useAuth = () => {
|
|
|
27137
27136
|
}
|
|
27138
27137
|
return ctx;
|
|
27139
27138
|
};
|
|
27140
|
-
|
|
27141
|
-
// src/lib/cupcodeRuntimeEnv.ts
|
|
27142
|
-
var import_meta2 = {};
|
|
27143
|
-
var TELESCUP_CDN_HOSTS2 = /* @__PURE__ */ new Set([
|
|
27144
|
-
"cdn.telescup.com.br",
|
|
27145
|
-
"telescup.cupcode.dev",
|
|
27146
|
-
"cdn.cupcode.com.br"
|
|
27147
|
-
]);
|
|
27148
|
-
var normalize = (value) => {
|
|
27149
|
-
if (value === null || typeof value === "undefined") return void 0;
|
|
27150
|
-
const normalized = String(value).trim();
|
|
27151
|
-
return normalized.length > 0 ? normalized : void 0;
|
|
27152
|
-
};
|
|
27153
|
-
var isTelescupCdnUrl2 = (value) => {
|
|
27154
|
-
if (!value) return false;
|
|
27155
|
-
try {
|
|
27156
|
-
return TELESCUP_CDN_HOSTS2.has(new URL(value).hostname);
|
|
27157
|
-
} catch (e) {
|
|
27158
|
-
return false;
|
|
27159
|
-
}
|
|
27160
|
-
};
|
|
27161
|
-
var deriveAppsApiBaseUrl = () => {
|
|
27162
|
-
const explicit = normalize(import_meta2.env.VITE_APPS_API_BASE_URL) || normalize(import_meta2.env.VITE_APPS_API_BASE);
|
|
27163
|
-
if (explicit) return explicit.replace(/\/+$/, "");
|
|
27164
|
-
return void 0;
|
|
27165
|
-
};
|
|
27166
|
-
var resolveTelescupFunctionsBase = (appsApiBaseUrl) => {
|
|
27167
|
-
const explicit = normalize(import_meta2.env.VITE_TELESCUP_BASE_URL);
|
|
27168
|
-
if (explicit && !isTelescupCdnUrl2(explicit)) {
|
|
27169
|
-
return explicit.replace(/\/+$/, "");
|
|
27170
|
-
}
|
|
27171
|
-
if (appsApiBaseUrl) {
|
|
27172
|
-
return `${appsApiBaseUrl}/api/telescup`;
|
|
27173
|
-
}
|
|
27174
|
-
return void 0;
|
|
27175
|
-
};
|
|
27176
|
-
var runtimeSupabaseUrl = normalize(import_meta2.env.VITE_SUPABASE_URL);
|
|
27177
|
-
var runtimeSupabaseAnonKey = normalize(import_meta2.env.VITE_SUPABASE_ANON_KEY) || normalize(import_meta2.env.VITE_SUPABASE_PUBLISHABLE_KEY);
|
|
27178
|
-
var runtimeSupabasePublishableKey = normalize(import_meta2.env.VITE_SUPABASE_PUBLISHABLE_KEY) || runtimeSupabaseAnonKey;
|
|
27179
|
-
var runtimeAppsApiBaseUrl = deriveAppsApiBaseUrl();
|
|
27180
|
-
var runtimeTelescupCdnBase = normalize(import_meta2.env.VITE_TELESCUP_CDN_BASE) || normalize(import_meta2.env.VITE_TELESCUP_API_BASE) || "https://cdn.telescup.com.br";
|
|
27181
|
-
var runtimeTelescupFunctionsBase = resolveTelescupFunctionsBase(runtimeAppsApiBaseUrl);
|
|
27182
|
-
var runtimeAccountsBaseUrl = normalize(import_meta2.env.VITE_ACCOUNTS_BASE_URL) || normalize(import_meta2.env.VITE_OIDC_ISSUER);
|
|
27183
|
-
var cupcodeRuntimeEnv = {
|
|
27184
|
-
VITE_SUPABASE_URL: runtimeSupabaseUrl,
|
|
27185
|
-
VITE_SUPABASE_ANON_KEY: runtimeSupabaseAnonKey,
|
|
27186
|
-
VITE_SUPABASE_PUBLISHABLE_KEY: runtimeSupabasePublishableKey,
|
|
27187
|
-
VITE_APPS_API_BASE_URL: runtimeAppsApiBaseUrl,
|
|
27188
|
-
VITE_APPS_API_BASE: runtimeAppsApiBaseUrl,
|
|
27189
|
-
VITE_TELESCUP_BASE_URL: runtimeTelescupFunctionsBase,
|
|
27190
|
-
VITE_TELESCUP_API_BASE: runtimeTelescupCdnBase,
|
|
27191
|
-
VITE_ACCOUNTS_BASE_URL: runtimeAccountsBaseUrl
|
|
27192
|
-
};
|
|
27193
|
-
var globalWithCupcodeEnv = globalThis;
|
|
27194
|
-
var _a25;
|
|
27195
|
-
globalWithCupcodeEnv.__CUPCODE_ENV__ = {
|
|
27196
|
-
...(_a25 = globalWithCupcodeEnv.__CUPCODE_ENV__) != null ? _a25 : {},
|
|
27197
|
-
...cupcodeRuntimeEnv
|
|
27198
|
-
};
|
|
27199
27139
|
// Annotate the CommonJS export names for ESM import in node:
|
|
27200
27140
|
0 && (module.exports = {
|
|
27201
27141
|
Accordion,
|
|
@@ -27562,7 +27502,6 @@ globalWithCupcodeEnv.__CUPCODE_ENV__ = {
|
|
|
27562
27502
|
cn,
|
|
27563
27503
|
completeTelescupOidcCallback,
|
|
27564
27504
|
createTelescupClient,
|
|
27565
|
-
cupcodeRuntimeEnv,
|
|
27566
27505
|
decodeJwt,
|
|
27567
27506
|
defaultSidebarGroups,
|
|
27568
27507
|
ensureTelescupOidcToken,
|