@cupcodev/ui 8.1.2 → 8.1.4
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 +482 -515
- package/dist/index.d.cts +4 -11
- package/dist/index.d.ts +4 -11
- package/dist/index.js +482 -514
- 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;
|
|
@@ -6282,11 +6281,29 @@ var TelescupUpload = ({
|
|
|
6282
6281
|
] }) })
|
|
6283
6282
|
] });
|
|
6284
6283
|
}
|
|
6285
|
-
return mode === "drawer" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Drawer, { open: Boolean(open), onOpenChange: (next) => !next ? handleClose() : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DrawerContent, { className: "h-[90vh] p-6", children: content }) }) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6284
|
+
return mode === "drawer" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Drawer, { open: Boolean(open), onOpenChange: (next) => !next ? handleClose() : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DrawerContent, { className: "h-[90vh] p-6", children: content }) }) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
6285
|
+
Dialog,
|
|
6286
|
+
{
|
|
6287
|
+
open: Boolean(open),
|
|
6288
|
+
onOpenChange: (next) => {
|
|
6289
|
+
if (!next) handleClose();
|
|
6290
|
+
},
|
|
6291
|
+
modal: true,
|
|
6292
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
|
|
6293
|
+
DialogContent,
|
|
6294
|
+
{
|
|
6295
|
+
className: "z-[4600] max-w-5xl rounded-md sm:rounded-md",
|
|
6296
|
+
onInteractOutside: (event) => event.preventDefault(),
|
|
6297
|
+
onPointerDownOutside: (event) => event.preventDefault(),
|
|
6298
|
+
children: [
|
|
6299
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DialogTitle, { className: "sr-only", children: labels.title }),
|
|
6300
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DialogDescription, { className: "sr-only", children: "Sele\xE7\xE3o e upload de assets com metadados do Telescup." }),
|
|
6301
|
+
content
|
|
6302
|
+
]
|
|
6303
|
+
}
|
|
6304
|
+
)
|
|
6305
|
+
}
|
|
6306
|
+
);
|
|
6290
6307
|
};
|
|
6291
6308
|
|
|
6292
6309
|
// src/lib/accountsLoginHistory.ts
|
|
@@ -6297,16 +6314,16 @@ var toStringOrUndefined = (value) => {
|
|
|
6297
6314
|
};
|
|
6298
6315
|
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6299
6316
|
var resolveAccountsApiBaseUrl = () => {
|
|
6300
|
-
var
|
|
6301
|
-
const appsApiBase = ((_b3 = (
|
|
6317
|
+
var _a25, _b3, _c, _d;
|
|
6318
|
+
const appsApiBase = ((_b3 = (_a25 = getRuntimeEnv("VITE_APPS_API_BASE_URL")) != null ? _a25 : getRuntimeEnv("VITE_APPS_API_BASE")) != null ? _b3 : "").trim().replace(/\/+$/, "");
|
|
6302
6319
|
if (appsApiBase) return `${appsApiBase}/api/accounts`;
|
|
6303
6320
|
const accountsBase = ((_c = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _c : "https://accounts.cupcode.com.br").trim().replace(/\/+$/, "");
|
|
6304
6321
|
const accountsApi = ((_d = getRuntimeEnv("VITE_ACCOUNTS_API_BASE_URL")) != null ? _d : "").trim().replace(/\/+$/, "");
|
|
6305
6322
|
return accountsApi || accountsBase;
|
|
6306
6323
|
};
|
|
6307
6324
|
var parseBrowserFromUserAgent = (userAgent) => {
|
|
6308
|
-
var
|
|
6309
|
-
const ua = (
|
|
6325
|
+
var _a25;
|
|
6326
|
+
const ua = (_a25 = userAgent == null ? void 0 : userAgent.trim()) != null ? _a25 : "";
|
|
6310
6327
|
if (!ua) return "Desconhecido";
|
|
6311
6328
|
if (/Edg\//.test(ua)) return "Edge";
|
|
6312
6329
|
if (/Chrome\//.test(ua)) return "Chrome";
|
|
@@ -6316,8 +6333,8 @@ var parseBrowserFromUserAgent = (userAgent) => {
|
|
|
6316
6333
|
return ua.split(" ")[0] || "Desconhecido";
|
|
6317
6334
|
};
|
|
6318
6335
|
var parseOsFromUserAgent = (userAgent) => {
|
|
6319
|
-
var
|
|
6320
|
-
const ua = (
|
|
6336
|
+
var _a25;
|
|
6337
|
+
const ua = (_a25 = userAgent == null ? void 0 : userAgent.trim()) != null ? _a25 : "";
|
|
6321
6338
|
if (!ua) return null;
|
|
6322
6339
|
if (/Windows NT/.test(ua)) return "Windows";
|
|
6323
6340
|
if (/Mac OS X/.test(ua)) return "macOS";
|
|
@@ -6329,8 +6346,8 @@ var parseOsFromUserAgent = (userAgent) => {
|
|
|
6329
6346
|
var normalizeLoginHistorySessions = (value) => {
|
|
6330
6347
|
if (!Array.isArray(value)) return [];
|
|
6331
6348
|
return value.filter(isRecord).map((row, index) => {
|
|
6332
|
-
var
|
|
6333
|
-
const id = (
|
|
6349
|
+
var _a25, _b3, _c, _d, _e, _f;
|
|
6350
|
+
const id = (_a25 = toStringOrUndefined(row.id)) != null ? _a25 : `session-${index}`;
|
|
6334
6351
|
return {
|
|
6335
6352
|
id,
|
|
6336
6353
|
createdAt: (_b3 = toStringOrUndefined(row.created_at)) != null ? _b3 : toStringOrUndefined(row.createdAt),
|
|
@@ -6350,18 +6367,18 @@ var isLoginHistorySessionActive = (session, now = Date.now()) => {
|
|
|
6350
6367
|
return Boolean(session.active) && expiresAt2 > now;
|
|
6351
6368
|
};
|
|
6352
6369
|
var readStoredAccessToken = () => {
|
|
6353
|
-
var
|
|
6370
|
+
var _a25;
|
|
6354
6371
|
if (typeof window === "undefined") return null;
|
|
6355
6372
|
const keys = ["cc_access_token", "access_token"];
|
|
6356
6373
|
for (const key of keys) {
|
|
6357
|
-
const value = (
|
|
6374
|
+
const value = (_a25 = window.sessionStorage.getItem(key)) == null ? void 0 : _a25.trim();
|
|
6358
6375
|
if (value) return value;
|
|
6359
6376
|
}
|
|
6360
6377
|
return null;
|
|
6361
6378
|
};
|
|
6362
6379
|
async function fetchAccountsLoginHistory(options) {
|
|
6363
|
-
var
|
|
6364
|
-
const base = ((
|
|
6380
|
+
var _a25;
|
|
6381
|
+
const base = ((_a25 = options == null ? void 0 : options.accountsApiBaseUrl) != null ? _a25 : resolveAccountsApiBaseUrl()).replace(/\/+$/, "");
|
|
6365
6382
|
const resolveToken = async () => {
|
|
6366
6383
|
if (options == null ? void 0 : options.getAccessToken) {
|
|
6367
6384
|
try {
|
|
@@ -6453,13 +6470,13 @@ var LoginHistoryCupcode = ({
|
|
|
6453
6470
|
);
|
|
6454
6471
|
}
|
|
6455
6472
|
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
|
|
6473
|
+
var _a25;
|
|
6457
6474
|
const browser = parseBrowserFromUserAgent(session.userAgent);
|
|
6458
6475
|
const os = parseOsFromUserAgent(session.userAgent);
|
|
6459
6476
|
const isActive = isLoginHistorySessionActive(session);
|
|
6460
6477
|
const loginLabel = formatDateTime(session.createdAt);
|
|
6461
6478
|
const lastSeenLabel = formatDateTime(session.lastSeen);
|
|
6462
|
-
const ip = ((
|
|
6479
|
+
const ip = ((_a25 = session.ip) == null ? void 0 : _a25.trim()) || "unknown";
|
|
6463
6480
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
6464
6481
|
"div",
|
|
6465
6482
|
{
|
|
@@ -6546,14 +6563,14 @@ function parseStoredThemePreference(value) {
|
|
|
6546
6563
|
return value === "light" || value === "dark" || value === "system" ? value : null;
|
|
6547
6564
|
}
|
|
6548
6565
|
function normalizeStoredThemePreference(value) {
|
|
6549
|
-
var
|
|
6550
|
-
return (
|
|
6566
|
+
var _a25;
|
|
6567
|
+
return (_a25 = parseStoredThemePreference(value)) != null ? _a25 : "system";
|
|
6551
6568
|
}
|
|
6552
6569
|
function readStoredThemeMode() {
|
|
6553
|
-
var
|
|
6570
|
+
var _a25;
|
|
6554
6571
|
if (typeof window === "undefined") return null;
|
|
6555
6572
|
try {
|
|
6556
|
-
const storedTheme = (
|
|
6573
|
+
const storedTheme = (_a25 = window.localStorage.getItem(THEME_STORAGE_KEY)) != null ? _a25 : window.localStorage.getItem(LEGACY_THEME_STORAGE_KEY);
|
|
6557
6574
|
return isStoredThemeMode(storedTheme) ? storedTheme : null;
|
|
6558
6575
|
} catch (e) {
|
|
6559
6576
|
return null;
|
|
@@ -6609,7 +6626,7 @@ function persistThemePreferenceSelection(preference) {
|
|
|
6609
6626
|
);
|
|
6610
6627
|
}
|
|
6611
6628
|
function resolveStoredThemePreference(experienceSettingsTheme) {
|
|
6612
|
-
var
|
|
6629
|
+
var _a25;
|
|
6613
6630
|
if (typeof window === "undefined") {
|
|
6614
6631
|
return normalizeStoredThemePreference(experienceSettingsTheme);
|
|
6615
6632
|
}
|
|
@@ -6625,7 +6642,7 @@ function resolveStoredThemePreference(experienceSettingsTheme) {
|
|
|
6625
6642
|
if (parsedExperienceTheme === "system" && storedThemeMode) {
|
|
6626
6643
|
return storedThemeMode;
|
|
6627
6644
|
}
|
|
6628
|
-
return (
|
|
6645
|
+
return (_a25 = parsedExperienceTheme != null ? parsedExperienceTheme : storedThemeMode) != null ? _a25 : "system";
|
|
6629
6646
|
} catch (e) {
|
|
6630
6647
|
return normalizeStoredThemePreference(experienceSettingsTheme);
|
|
6631
6648
|
}
|
|
@@ -6699,9 +6716,9 @@ var applyThemePreference = (preference) => {
|
|
|
6699
6716
|
persistThemePreferenceSelection(preference);
|
|
6700
6717
|
};
|
|
6701
6718
|
var resolveTelescupImageUrl = (value, options) => {
|
|
6702
|
-
var
|
|
6719
|
+
var _a25, _b3, _c;
|
|
6703
6720
|
return resolveTelescupImageURL(value, {
|
|
6704
|
-
width: (
|
|
6721
|
+
width: (_a25 = options == null ? void 0 : options.width) != null ? _a25 : 96,
|
|
6705
6722
|
height: (_b3 = options == null ? void 0 : options.height) != null ? _b3 : 96,
|
|
6706
6723
|
fit: "cover",
|
|
6707
6724
|
format: "avif",
|
|
@@ -6709,8 +6726,8 @@ var resolveTelescupImageUrl = (value, options) => {
|
|
|
6709
6726
|
});
|
|
6710
6727
|
};
|
|
6711
6728
|
var resolveProfileAvatarFromTelescup = (asset, fallbackId) => {
|
|
6712
|
-
var
|
|
6713
|
-
return (_b3 = (
|
|
6729
|
+
var _a25, _b3;
|
|
6730
|
+
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
6731
|
};
|
|
6715
6732
|
var normalizeLanguage = (value) => {
|
|
6716
6733
|
const normalized = value == null ? void 0 : value.trim().toLowerCase();
|
|
@@ -6829,8 +6846,10 @@ var UserMenuCupcode = ({
|
|
|
6829
6846
|
if (!hasTelescupAvatarSupport || isTelescupAuthPending || isProfileAvatarSaving) return;
|
|
6830
6847
|
try {
|
|
6831
6848
|
await ensureTelescupAuth();
|
|
6849
|
+
setIsProfileImageDialogOpen(false);
|
|
6832
6850
|
setIsProfileAvatarUploadOpen(true);
|
|
6833
6851
|
} catch (error) {
|
|
6852
|
+
console.error("[UserMenuCupcode] telescup avatar auth failed", error);
|
|
6834
6853
|
toast({
|
|
6835
6854
|
title: "Falha ao autenticar no Telescup",
|
|
6836
6855
|
description: error instanceof Error ? error.message : "N\xE3o foi poss\xEDvel abrir a biblioteca agora.",
|
|
@@ -6935,9 +6954,9 @@ var UserMenuCupcode = ({
|
|
|
6935
6954
|
};
|
|
6936
6955
|
const handleProfileAvatarChange = (0, import_react16.useCallback)(
|
|
6937
6956
|
async (ids, assets) => {
|
|
6938
|
-
var
|
|
6957
|
+
var _a25, _b3, _c;
|
|
6939
6958
|
const selectedAsset = assets == null ? void 0 : assets[0];
|
|
6940
|
-
const selectedIdRaw = (
|
|
6959
|
+
const selectedIdRaw = (_a25 = ids[0]) == null ? void 0 : _a25.trim();
|
|
6941
6960
|
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
6961
|
if (!selectedId) {
|
|
6943
6962
|
toast({
|
|
@@ -6980,7 +6999,7 @@ var UserMenuCupcode = ({
|
|
|
6980
6999
|
[isProfileAvatarSaving, onProfileAvatarChange, resolvedProfileAvatarUrl]
|
|
6981
7000
|
);
|
|
6982
7001
|
const renderDefaultPanel = () => {
|
|
6983
|
-
var
|
|
7002
|
+
var _a25;
|
|
6984
7003
|
if (activeTab === "profile") {
|
|
6985
7004
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "space-y-4", children: [
|
|
6986
7005
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "pt-1 text-center", children: [
|
|
@@ -7150,7 +7169,7 @@ var UserMenuCupcode = ({
|
|
|
7150
7169
|
"Idioma"
|
|
7151
7170
|
] }),
|
|
7152
7171
|
/* @__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: (
|
|
7172
|
+
/* @__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
7173
|
/* @__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
7174
|
] }) })
|
|
7156
7175
|
] }) })
|
|
@@ -7937,10 +7956,10 @@ var ignoreLoopbackUrlOnPublicOrigin = (value) => {
|
|
|
7937
7956
|
return isLoopbackUrl(value) ? void 0 : value;
|
|
7938
7957
|
};
|
|
7939
7958
|
var getAppsApiBaseUrl = () => {
|
|
7940
|
-
var
|
|
7959
|
+
var _a25, _b3;
|
|
7941
7960
|
return normalizeBaseUrl2(
|
|
7942
7961
|
(_b3 = ignoreLoopbackUrlOnPublicOrigin(
|
|
7943
|
-
(
|
|
7962
|
+
(_a25 = getRuntimeEnv("VITE_APPS_API_BASE_URL")) != null ? _a25 : getRuntimeEnv("VITE_APPS_API_BASE")
|
|
7944
7963
|
)) != null ? _b3 : "https://api.apps.cupcode.com.br"
|
|
7945
7964
|
);
|
|
7946
7965
|
};
|
|
@@ -7973,15 +7992,15 @@ var fetchWithTimeout = async (input, init, timeoutMs = AUTH_REQUEST_TIMEOUT_MS)
|
|
|
7973
7992
|
}
|
|
7974
7993
|
};
|
|
7975
7994
|
var resolveIssuerBaseUrl = () => {
|
|
7976
|
-
var
|
|
7977
|
-
const issuer = (
|
|
7995
|
+
var _a25;
|
|
7996
|
+
const issuer = (_a25 = ignoreLoopbackUrlOnPublicOrigin(getRuntimeEnv("VITE_OIDC_ISSUER"))) != null ? _a25 : ignoreLoopbackUrlOnPublicOrigin(getRuntimeEnv("VITE_ACCOUNTS_BASE_URL"));
|
|
7978
7997
|
return issuer ? normalizeBaseUrl2(issuer) : void 0;
|
|
7979
7998
|
};
|
|
7980
7999
|
var getAccountsConfig = () => {
|
|
7981
|
-
var
|
|
8000
|
+
var _a25, _b3, _c, _d;
|
|
7982
8001
|
const issuerBaseUrl = resolveIssuerBaseUrl();
|
|
7983
8002
|
const baseUrl = normalizeBaseUrl2(
|
|
7984
|
-
(
|
|
8003
|
+
(_a25 = issuerBaseUrl != null ? issuerBaseUrl : getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a25 : "https://accounts.cupcode.com.br"
|
|
7985
8004
|
);
|
|
7986
8005
|
const clientId = getRuntimeEnv("VITE_ACCOUNTS_CLIENT_ID");
|
|
7987
8006
|
if (!clientId) {
|
|
@@ -8008,7 +8027,7 @@ var getAccountsConfig = () => {
|
|
|
8008
8027
|
};
|
|
8009
8028
|
var cachedDiscovery = null;
|
|
8010
8029
|
var resolveOidcEndpoints = async (config) => {
|
|
8011
|
-
var
|
|
8030
|
+
var _a25, _b3, _c, _d, _e, _f;
|
|
8012
8031
|
if (config.authUrl && config.tokenUrl) {
|
|
8013
8032
|
return {
|
|
8014
8033
|
authUrl: config.authUrl,
|
|
@@ -8018,7 +8037,7 @@ var resolveOidcEndpoints = async (config) => {
|
|
|
8018
8037
|
}
|
|
8019
8038
|
if (cachedDiscovery) {
|
|
8020
8039
|
return {
|
|
8021
|
-
authUrl: (
|
|
8040
|
+
authUrl: (_a25 = cachedDiscovery.authorization_endpoint) != null ? _a25 : config.authUrl,
|
|
8022
8041
|
tokenUrl: (_b3 = cachedDiscovery.token_endpoint) != null ? _b3 : config.tokenUrl,
|
|
8023
8042
|
logoutUrl: (_c = cachedDiscovery.end_session_endpoint) != null ? _c : config.logoutUrl
|
|
8024
8043
|
};
|
|
@@ -8228,10 +8247,10 @@ var resolveLocalTelescupRedirectUri = () => {
|
|
|
8228
8247
|
return `${window.location.protocol}//localhost:${port}/oidc/callback`;
|
|
8229
8248
|
};
|
|
8230
8249
|
var readStorageItem = (key) => {
|
|
8231
|
-
var
|
|
8250
|
+
var _a25;
|
|
8232
8251
|
if (!canUseWindow()) return null;
|
|
8233
8252
|
try {
|
|
8234
|
-
return (
|
|
8253
|
+
return (_a25 = window.sessionStorage.getItem(key)) != null ? _a25 : window.localStorage.getItem(key);
|
|
8235
8254
|
} catch (e) {
|
|
8236
8255
|
return null;
|
|
8237
8256
|
}
|
|
@@ -8247,6 +8266,13 @@ var writeTokenBundle = (bundle) => {
|
|
|
8247
8266
|
window.localStorage.setItem(TOKEN_STORAGE_KEY, serialized);
|
|
8248
8267
|
} catch (e) {
|
|
8249
8268
|
}
|
|
8269
|
+
try {
|
|
8270
|
+
window.sessionStorage.setItem("cc_id_token", bundle.idToken);
|
|
8271
|
+
if (bundle.accessToken) {
|
|
8272
|
+
window.sessionStorage.setItem("access_token", bundle.accessToken);
|
|
8273
|
+
}
|
|
8274
|
+
} catch (e) {
|
|
8275
|
+
}
|
|
8250
8276
|
};
|
|
8251
8277
|
var getFlowStorageKey = (state) => `${FLOW_STORAGE_KEY_PREFIX}${state}`;
|
|
8252
8278
|
var writeFlowState = (flow) => {
|
|
@@ -8341,10 +8367,10 @@ var getPopupOrigin = () => {
|
|
|
8341
8367
|
return window.location.origin;
|
|
8342
8368
|
};
|
|
8343
8369
|
var getTelescupAccountsConfig = () => {
|
|
8344
|
-
var
|
|
8370
|
+
var _a25, _b3, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
8345
8371
|
const primary = getAccountsConfig();
|
|
8346
8372
|
const runtimeRedirectUri = ignoreLoopbackUrlOnPublicOrigin2(
|
|
8347
|
-
(
|
|
8373
|
+
(_a25 = getRuntimeEnv("VITE_TELESCUP_ACCOUNTS_REDIRECT_URI")) != null ? _a25 : getRuntimeEnv("VITE_TELESCUP_OIDC_REDIRECT_URI")
|
|
8348
8374
|
);
|
|
8349
8375
|
const fallbackRedirectUri = canUseWindow() ? `${window.location.origin}/oidc/callback` : "http://localhost:8083/oidc/callback";
|
|
8350
8376
|
const redirectUri = isLocalBrowserOrigin2() && runtimeRedirectUri && !runtimeRedirectUri.includes("localhost") ? resolveLocalTelescupRedirectUri() : runtimeRedirectUri != null ? runtimeRedirectUri : fallbackRedirectUri;
|
|
@@ -8362,8 +8388,8 @@ var getTelescupAccountsConfig = () => {
|
|
|
8362
8388
|
};
|
|
8363
8389
|
};
|
|
8364
8390
|
var buildTokenBundle = (tokens, config, previous) => {
|
|
8365
|
-
var
|
|
8366
|
-
const idToken = ((
|
|
8391
|
+
var _a25, _b3, _c, _d, _e, _f;
|
|
8392
|
+
const idToken = ((_a25 = tokens.id_token) == null ? void 0 : _a25.trim()) || (previous == null ? void 0 : previous.idToken) || "";
|
|
8367
8393
|
if (!idToken) {
|
|
8368
8394
|
throw new Error("Token ID do Telescup n\xE3o retornado pelo Accounts.");
|
|
8369
8395
|
}
|
|
@@ -8410,10 +8436,10 @@ var centerPopupFeatures = () => {
|
|
|
8410
8436
|
return `popup,width=${width},height=${height},left=${left},top=${top},resizable=yes,scrollbars=yes`;
|
|
8411
8437
|
};
|
|
8412
8438
|
var notifyOpener = (result) => {
|
|
8413
|
-
var
|
|
8439
|
+
var _a25;
|
|
8414
8440
|
if (!canUseWindow()) return;
|
|
8415
8441
|
try {
|
|
8416
|
-
(
|
|
8442
|
+
(_a25 = window.opener) == null ? void 0 : _a25.postMessage(result, getPopupOrigin());
|
|
8417
8443
|
} catch (e) {
|
|
8418
8444
|
}
|
|
8419
8445
|
};
|
|
@@ -8439,8 +8465,9 @@ var ensureTelescupOidcToken = async () => {
|
|
|
8439
8465
|
throw new Error("Autentica\xE7\xE3o do Telescup indispon\xEDvel fora do navegador.");
|
|
8440
8466
|
}
|
|
8441
8467
|
if (pendingTokenPromise) return pendingTokenPromise;
|
|
8442
|
-
const
|
|
8443
|
-
|
|
8468
|
+
const popupWindowName = `${POPUP_WINDOW_NAME}-${Date.now()}`;
|
|
8469
|
+
const popup = window.open("about:blank", popupWindowName, centerPopupFeatures());
|
|
8470
|
+
if (!popup || popup.closed) {
|
|
8444
8471
|
throw new Error("N\xE3o foi poss\xEDvel abrir a autentica\xE7\xE3o do Telescup. Verifique o bloqueador de popups.");
|
|
8445
8472
|
}
|
|
8446
8473
|
pendingTokenPromise = new Promise((resolve, reject) => {
|
|
@@ -8522,7 +8549,7 @@ var ensureTelescupOidcToken = async () => {
|
|
|
8522
8549
|
return pendingTokenPromise;
|
|
8523
8550
|
};
|
|
8524
8551
|
var completeTelescupOidcCallback = async () => {
|
|
8525
|
-
var
|
|
8552
|
+
var _a25;
|
|
8526
8553
|
if (!canUseWindow()) {
|
|
8527
8554
|
return { ok: false, error: "Callback do Telescup indispon\xEDvel fora do navegador." };
|
|
8528
8555
|
}
|
|
@@ -8551,7 +8578,7 @@ var completeTelescupOidcCallback = async () => {
|
|
|
8551
8578
|
throw new Error("Token endpoint do Telescup n\xE3o encontrado.");
|
|
8552
8579
|
}
|
|
8553
8580
|
const tokens = await exchangeCodeForToken(config, tokenUrl, code, flow.verifier);
|
|
8554
|
-
const nonce = String(((
|
|
8581
|
+
const nonce = String(((_a25 = decodeJwt(tokens.id_token)) == null ? void 0 : _a25.nonce) || "").trim();
|
|
8555
8582
|
if (!nonce || nonce !== flow.nonce) {
|
|
8556
8583
|
throw new Error("Nonce inv\xE1lido no callback do Telescup.");
|
|
8557
8584
|
}
|
|
@@ -8576,8 +8603,8 @@ var TELESCUP_CDN_HOSTS = /* @__PURE__ */ new Set([
|
|
|
8576
8603
|
"cdn.cupcode.com.br"
|
|
8577
8604
|
]);
|
|
8578
8605
|
var resolveAppsApiBaseUrl = () => {
|
|
8579
|
-
var
|
|
8580
|
-
return ((_b3 = (
|
|
8606
|
+
var _a25, _b3;
|
|
8607
|
+
return ((_b3 = (_a25 = getRuntimeEnv("VITE_APPS_API_BASE_URL")) != null ? _a25 : getRuntimeEnv("VITE_APPS_API_BASE")) != null ? _b3 : "").trim().replace(/\/+$/, "");
|
|
8581
8608
|
};
|
|
8582
8609
|
var isTelescupCdnUrl = (value) => {
|
|
8583
8610
|
const normalized = value == null ? void 0 : value.trim();
|
|
@@ -8589,10 +8616,10 @@ var isTelescupCdnUrl = (value) => {
|
|
|
8589
8616
|
}
|
|
8590
8617
|
};
|
|
8591
8618
|
var resolveTelescupBaseUrl = () => {
|
|
8592
|
-
var
|
|
8619
|
+
var _a25;
|
|
8593
8620
|
const appsApiBase = resolveAppsApiBaseUrl();
|
|
8594
8621
|
const apiFromApps = appsApiBase ? `${appsApiBase}/api/telescup` : "";
|
|
8595
|
-
const explicitBase = (
|
|
8622
|
+
const explicitBase = (_a25 = getRuntimeEnv("VITE_TELESCUP_BASE_URL")) == null ? void 0 : _a25.trim();
|
|
8596
8623
|
if (explicitBase && !isTelescupCdnUrl(explicitBase)) {
|
|
8597
8624
|
return explicitBase.replace(/\/+$/, "");
|
|
8598
8625
|
}
|
|
@@ -8601,17 +8628,17 @@ var resolveTelescupBaseUrl = () => {
|
|
|
8601
8628
|
var ACCESS_TOKEN_STORAGE_KEY = "cc_access_token";
|
|
8602
8629
|
var ID_TOKEN_STORAGE_KEYS = ["cc_id_token", "id_token"];
|
|
8603
8630
|
var isJwtUsable = (token, skewMs = 5e3) => {
|
|
8604
|
-
var
|
|
8631
|
+
var _a25;
|
|
8605
8632
|
const claims = decodeJwt(token);
|
|
8606
|
-
const exp = Number((
|
|
8633
|
+
const exp = Number((_a25 = claims == null ? void 0 : claims.exp) != null ? _a25 : 0);
|
|
8607
8634
|
if (!Number.isFinite(exp) || exp <= 0) return true;
|
|
8608
8635
|
return exp * 1e3 > Date.now() + skewMs;
|
|
8609
8636
|
};
|
|
8610
8637
|
var readStoredIdToken2 = () => {
|
|
8611
|
-
var
|
|
8638
|
+
var _a25;
|
|
8612
8639
|
if (typeof window === "undefined") return null;
|
|
8613
8640
|
for (const key of ID_TOKEN_STORAGE_KEYS) {
|
|
8614
|
-
const value = (
|
|
8641
|
+
const value = (_a25 = sessionStorage.getItem(key)) == null ? void 0 : _a25.trim();
|
|
8615
8642
|
if (value) return value;
|
|
8616
8643
|
}
|
|
8617
8644
|
return null;
|
|
@@ -8645,25 +8672,25 @@ var resolveCurrentUserId = (user) => {
|
|
|
8645
8672
|
return null;
|
|
8646
8673
|
};
|
|
8647
8674
|
var resolveUserIdFromClaims = (claims) => {
|
|
8648
|
-
var
|
|
8649
|
-
return (_e = (_d = (_c = (_b3 = (
|
|
8675
|
+
var _a25, _b3, _c, _d, _e;
|
|
8676
|
+
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
8677
|
};
|
|
8651
8678
|
var resolveEmailFromClaims = (claims) => {
|
|
8652
|
-
var
|
|
8653
|
-
const candidate = (_b3 = (
|
|
8679
|
+
var _a25, _b3;
|
|
8680
|
+
const candidate = (_b3 = (_a25 = toStringOrUndefined2(claims.email)) != null ? _a25 : toStringOrUndefined2(claims["https://cupcode.com/email"])) != null ? _b3 : toStringOrUndefined2(claims.preferred_username);
|
|
8654
8681
|
if (!candidate || !candidate.includes("@")) return void 0;
|
|
8655
8682
|
return candidate.toLowerCase();
|
|
8656
8683
|
};
|
|
8657
8684
|
var normalizeTenantId = (value) => {
|
|
8658
|
-
var
|
|
8659
|
-
const normalized = (
|
|
8685
|
+
var _a25;
|
|
8686
|
+
const normalized = (_a25 = toStringOrUndefined2(value)) == null ? void 0 : _a25.toLowerCase();
|
|
8660
8687
|
if (!normalized) return void 0;
|
|
8661
8688
|
return normalized.replace(/^@/, "");
|
|
8662
8689
|
};
|
|
8663
8690
|
var resolveTenantIdFromClaims = (claims) => {
|
|
8664
|
-
var
|
|
8691
|
+
var _a25, _b3, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
8665
8692
|
return normalizeTenantId(
|
|
8666
|
-
(_j = (_i = (_h = (_g = (_f = (_e = (_d = (_c = (_b3 = (
|
|
8693
|
+
(_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
8694
|
);
|
|
8668
8695
|
};
|
|
8669
8696
|
var AVATAR_IMAGE_OPTIONS = {
|
|
@@ -8674,8 +8701,8 @@ var AVATAR_IMAGE_OPTIONS = {
|
|
|
8674
8701
|
quality: 80
|
|
8675
8702
|
};
|
|
8676
8703
|
var resolveAvatarPreviewUrl = (asset, fallback) => {
|
|
8677
|
-
var
|
|
8678
|
-
return (_c = (_b3 = (
|
|
8704
|
+
var _a25, _b3, _c;
|
|
8705
|
+
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
8706
|
};
|
|
8680
8707
|
var isGenericRecord = (value) => typeof value === "object" && value !== null;
|
|
8681
8708
|
var buildExternalUrl = (baseUrl, target) => {
|
|
@@ -8708,11 +8735,11 @@ var normalizeMenuLanguage = (value) => {
|
|
|
8708
8735
|
return "pt-BR";
|
|
8709
8736
|
};
|
|
8710
8737
|
var resolveMenuLanguageFromRecord = (record) => {
|
|
8711
|
-
var
|
|
8738
|
+
var _a25, _b3, _c, _d, _e;
|
|
8712
8739
|
if (!record) return void 0;
|
|
8713
8740
|
const profile = isGenericRecord(record.profile) ? record.profile : null;
|
|
8714
8741
|
const preferences = isGenericRecord(record.preferences) ? record.preferences : null;
|
|
8715
|
-
const rawLanguage = (_e = (_d = (_c = (_b3 = (
|
|
8742
|
+
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
8743
|
if (typeof rawLanguage !== "string" || !rawLanguage.trim()) return void 0;
|
|
8717
8744
|
return normalizeMenuLanguage(rawLanguage);
|
|
8718
8745
|
};
|
|
@@ -8753,8 +8780,8 @@ var parseRecentActivityItems = (payload) => {
|
|
|
8753
8780
|
return [];
|
|
8754
8781
|
};
|
|
8755
8782
|
return toRows(payload).map((item, index) => {
|
|
8756
|
-
var
|
|
8757
|
-
const id = (_b3 = (
|
|
8783
|
+
var _a25, _b3, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
8784
|
+
const id = (_b3 = (_a25 = toStringOrUndefined2(item.id)) != null ? _a25 : toStringOrUndefined2(item.event_id)) != null ? _b3 : `accounts-activity-${index}`;
|
|
8758
8785
|
const title = (_e = (_d = (_c = toStringOrUndefined2(item.title)) != null ? _c : toStringOrUndefined2(item.action)) != null ? _d : toStringOrUndefined2(item.event)) != null ? _e : toStringOrUndefined2(item.type);
|
|
8759
8786
|
if (!title) return null;
|
|
8760
8787
|
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 +8850,7 @@ var MainNavbar = ({
|
|
|
8823
8850
|
getAccessToken,
|
|
8824
8851
|
appVersion
|
|
8825
8852
|
}) => {
|
|
8826
|
-
var
|
|
8853
|
+
var _a25, _b3, _c;
|
|
8827
8854
|
const [tokenDerivedUserId, setTokenDerivedUserId] = (0, import_react19.useState)(null);
|
|
8828
8855
|
const [tokenDerivedEmail, setTokenDerivedEmail] = (0, import_react19.useState)(void 0);
|
|
8829
8856
|
const [tokenDerivedTenantId, setTokenDerivedTenantId] = (0, import_react19.useState)(void 0);
|
|
@@ -8841,13 +8868,13 @@ var MainNavbar = ({
|
|
|
8841
8868
|
return "/";
|
|
8842
8869
|
}, [pathname]);
|
|
8843
8870
|
const currentUserId = (0, import_react19.useMemo)(() => {
|
|
8844
|
-
var
|
|
8845
|
-
return (
|
|
8871
|
+
var _a26;
|
|
8872
|
+
return (_a26 = resolveCurrentUserId(authUser)) != null ? _a26 : tokenDerivedUserId;
|
|
8846
8873
|
}, [authUser, tokenDerivedUserId]);
|
|
8847
8874
|
const resolvedTenantId = (0, import_react19.useMemo)(() => {
|
|
8848
|
-
var
|
|
8875
|
+
var _a26, _b4, _c2, _d, _e, _f;
|
|
8849
8876
|
const candidate = normalizeTenantId(
|
|
8850
|
-
(_f = (_e = (_d = (_c2 = (_b4 = (
|
|
8877
|
+
(_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
8878
|
);
|
|
8852
8879
|
if (!candidate || !currentUserId) return candidate;
|
|
8853
8880
|
if (candidate === currentUserId) return void 0;
|
|
@@ -8865,7 +8892,7 @@ var MainNavbar = ({
|
|
|
8865
8892
|
const resolvedTelescupBaseUrl = (0, import_react19.useMemo)(() => {
|
|
8866
8893
|
return resolveTelescupBaseUrl();
|
|
8867
8894
|
}, []);
|
|
8868
|
-
const resolvedProfileAvatarUrl = (
|
|
8895
|
+
const resolvedProfileAvatarUrl = (_a25 = resolveAvatarPreviewUrl({ url: persistedProfileAvatarValue != null ? persistedProfileAvatarValue : authUser == null ? void 0 : authUser.picture })) != null ? _a25 : void 0;
|
|
8869
8896
|
const hasStoredAccessToken = (() => {
|
|
8870
8897
|
if (typeof window === "undefined") return false;
|
|
8871
8898
|
try {
|
|
@@ -8903,7 +8930,7 @@ var MainNavbar = ({
|
|
|
8903
8930
|
}
|
|
8904
8931
|
let canceled = false;
|
|
8905
8932
|
const resolveIdentityFromToken = async () => {
|
|
8906
|
-
var
|
|
8933
|
+
var _a26, _b4;
|
|
8907
8934
|
try {
|
|
8908
8935
|
let token = null;
|
|
8909
8936
|
if (typeof window !== "undefined") {
|
|
@@ -8924,7 +8951,7 @@ var MainNavbar = ({
|
|
|
8924
8951
|
}
|
|
8925
8952
|
return;
|
|
8926
8953
|
}
|
|
8927
|
-
const claims = (
|
|
8954
|
+
const claims = (_a26 = decodeJwt(token)) != null ? _a26 : {};
|
|
8928
8955
|
if (canceled) return;
|
|
8929
8956
|
setTokenDerivedUserId((_b4 = resolveUserIdFromClaims(claims)) != null ? _b4 : null);
|
|
8930
8957
|
setTokenDerivedEmail(resolveEmailFromClaims(claims));
|
|
@@ -8984,7 +9011,7 @@ var MainNavbar = ({
|
|
|
8984
9011
|
});
|
|
8985
9012
|
};
|
|
8986
9013
|
const loadAccountsContext = async () => {
|
|
8987
|
-
var
|
|
9014
|
+
var _a26;
|
|
8988
9015
|
setIsAccountsActivityLoading(true);
|
|
8989
9016
|
setIsAccountsLoginHistoryLoading(true);
|
|
8990
9017
|
setIsTwoFactorStatusLoading(true);
|
|
@@ -8997,7 +9024,7 @@ var MainNavbar = ({
|
|
|
8997
9024
|
}
|
|
8998
9025
|
return;
|
|
8999
9026
|
}
|
|
9000
|
-
const claims = (
|
|
9027
|
+
const claims = (_a26 = decodeJwt(token)) != null ? _a26 : {};
|
|
9001
9028
|
const twoFactorFromToken = resolveTwoFactorEnabledFromClaims(claims);
|
|
9002
9029
|
if (!canceled) {
|
|
9003
9030
|
setAccountsRecentActivity(buildActivityFromTokenClaims(claims));
|
|
@@ -9066,7 +9093,7 @@ var MainNavbar = ({
|
|
|
9066
9093
|
};
|
|
9067
9094
|
}, [getAccessToken, isAuthenticated, currentUserId]);
|
|
9068
9095
|
const items = (0, import_react19.useMemo)(() => {
|
|
9069
|
-
var
|
|
9096
|
+
var _a26;
|
|
9070
9097
|
if (!showNavItems) return [];
|
|
9071
9098
|
const normalizedPathname = currentPathname === "" ? "/" : currentPathname;
|
|
9072
9099
|
const navItems = getMainNavItems({ includePrivate: resolvedAuthStatus === "authenticated" });
|
|
@@ -9076,7 +9103,7 @@ var MainNavbar = ({
|
|
|
9076
9103
|
if (normalizedPathname.startsWith(`${href}/`)) return href.length;
|
|
9077
9104
|
return -1;
|
|
9078
9105
|
};
|
|
9079
|
-
const bestMatchHref = (
|
|
9106
|
+
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
9107
|
return navItems.map((item) => {
|
|
9081
9108
|
const isAnchor = item.href.startsWith("#");
|
|
9082
9109
|
const isActive = !isAnchor ? item.href === bestMatchHref : false;
|
|
@@ -9084,8 +9111,8 @@ var MainNavbar = ({
|
|
|
9084
9111
|
...item,
|
|
9085
9112
|
isActive,
|
|
9086
9113
|
onClick: isAnchor ? item.onClick : (event) => {
|
|
9087
|
-
var
|
|
9088
|
-
(
|
|
9114
|
+
var _a27;
|
|
9115
|
+
(_a27 = item.onClick) == null ? void 0 : _a27.call(item, event);
|
|
9089
9116
|
if (!onNavigate || event.defaultPrevented) return;
|
|
9090
9117
|
event.preventDefault();
|
|
9091
9118
|
onNavigate(item.href);
|
|
@@ -9143,11 +9170,11 @@ var MainNavbar = ({
|
|
|
9143
9170
|
}, [getAccessToken]);
|
|
9144
9171
|
const handleLanguageChange = (0, import_react19.useCallback)(
|
|
9145
9172
|
async (nextLanguage) => {
|
|
9146
|
-
var
|
|
9173
|
+
var _a26;
|
|
9147
9174
|
setAccountsLanguage(nextLanguage);
|
|
9148
9175
|
if (typeof window === "undefined") return;
|
|
9149
9176
|
try {
|
|
9150
|
-
const token = getAccessToken ? await getAccessToken() : (
|
|
9177
|
+
const token = getAccessToken ? await getAccessToken() : (_a26 = sessionStorage.getItem(ACCESS_TOKEN_STORAGE_KEY)) != null ? _a26 : readStoredIdToken2();
|
|
9151
9178
|
if (!token || !isJwtUsable(token)) return;
|
|
9152
9179
|
const response = await fetch(buildExternalUrl(resolveAccountsApiBaseUrl2(), ACCOUNTS_ME_ENDPOINT), {
|
|
9153
9180
|
method: "PATCH",
|
|
@@ -9170,8 +9197,8 @@ var MainNavbar = ({
|
|
|
9170
9197
|
);
|
|
9171
9198
|
const handleProfileAvatarChange = (0, import_react19.useCallback)(
|
|
9172
9199
|
async ({ avatarId, avatarUrl }) => {
|
|
9173
|
-
var
|
|
9174
|
-
const normalizedAvatarId = (
|
|
9200
|
+
var _a26, _b4, _c2, _d;
|
|
9201
|
+
const normalizedAvatarId = (_a26 = parseAssetId(avatarId)) != null ? _a26 : parseAssetId(avatarUrl);
|
|
9175
9202
|
if (!normalizedAvatarId) {
|
|
9176
9203
|
throw new Error("ID da imagem inv\xE1lido.");
|
|
9177
9204
|
}
|
|
@@ -9873,7 +9900,7 @@ var DocumentationSearchDialog = ({ open, onOpenChange }) => {
|
|
|
9873
9900
|
const totalSections = map.sections.length;
|
|
9874
9901
|
const mapMatches = normalizedQuery.length === 0 || normalizeText([map.title, map.subtitle, map.searchLabel].join(" ")).includes(normalizedQuery);
|
|
9875
9902
|
const sections = map.sections.filter((section) => {
|
|
9876
|
-
var
|
|
9903
|
+
var _a25, _b3, _c;
|
|
9877
9904
|
if (mapMatches) return true;
|
|
9878
9905
|
const parent = section.parentId ? parents.get(section.parentId) : null;
|
|
9879
9906
|
const haystack = normalizeText(
|
|
@@ -9882,7 +9909,7 @@ var DocumentationSearchDialog = ({ open, onOpenChange }) => {
|
|
|
9882
9909
|
map.searchLabel,
|
|
9883
9910
|
section.label,
|
|
9884
9911
|
section.group,
|
|
9885
|
-
(
|
|
9912
|
+
(_a25 = section.description) != null ? _a25 : "",
|
|
9886
9913
|
(_b3 = parent == null ? void 0 : parent.label) != null ? _b3 : "",
|
|
9887
9914
|
...(_c = section.keywords) != null ? _c : []
|
|
9888
9915
|
].join(" ")
|
|
@@ -10002,9 +10029,9 @@ var DocumentationSearchDialog = ({ open, onOpenChange }) => {
|
|
|
10002
10029
|
// src/components/layout/sidebar-groups.tsx
|
|
10003
10030
|
var toStableId = (value) => value.toLowerCase().normalize("NFD").replace(/\p{Diacritic}+/gu, "").replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)+/g, "");
|
|
10004
10031
|
var getGroupMetadata = (item) => {
|
|
10005
|
-
var
|
|
10032
|
+
var _a25, _b3;
|
|
10006
10033
|
return {
|
|
10007
|
-
id: ((
|
|
10034
|
+
id: ((_a25 = item.groupId) == null ? void 0 : _a25.trim()) || "",
|
|
10008
10035
|
label: ((_b3 = item.groupLabel) == null ? void 0 : _b3.trim()) || "",
|
|
10009
10036
|
icon: item.groupIcon
|
|
10010
10037
|
};
|
|
@@ -10020,7 +10047,7 @@ var buildSidebarGroupsFromNavItems = (items, defaultGroupLabel = "Principal") =>
|
|
|
10020
10047
|
if (navItems.length === 0) return [];
|
|
10021
10048
|
const groupsMap = /* @__PURE__ */ new Map();
|
|
10022
10049
|
navItems.forEach((item) => {
|
|
10023
|
-
var
|
|
10050
|
+
var _a25;
|
|
10024
10051
|
const groupId = item.group.id || toStableId(item.group.label || defaultGroupLabel);
|
|
10025
10052
|
const groupLabel = item.group.label || defaultGroupLabel;
|
|
10026
10053
|
const existing = groupsMap.get(groupId);
|
|
@@ -10028,7 +10055,7 @@ var buildSidebarGroupsFromNavItems = (items, defaultGroupLabel = "Principal") =>
|
|
|
10028
10055
|
groupsMap.set(groupId, {
|
|
10029
10056
|
id: groupId,
|
|
10030
10057
|
label: groupLabel,
|
|
10031
|
-
icon: (
|
|
10058
|
+
icon: (_a25 = item.group.icon) != null ? _a25 : item.icon,
|
|
10032
10059
|
items: [{ id: item.id, label: item.label, icon: item.icon, route: item.route }]
|
|
10033
10060
|
});
|
|
10034
10061
|
return;
|
|
@@ -10045,8 +10072,8 @@ var defaultSidebarGroups = buildSidebarGroupsFromNavItems(getMainNavItems());
|
|
|
10045
10072
|
// src/components/layout/sidebar.tsx
|
|
10046
10073
|
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
10047
10074
|
var findGroupByRoute = (groups, pathname) => {
|
|
10048
|
-
var
|
|
10049
|
-
return (_b3 = (
|
|
10075
|
+
var _a25, _b3;
|
|
10076
|
+
return (_b3 = (_a25 = groups.find((group) => group.items.some((item) => item.route === pathname))) == null ? void 0 : _a25.label) != null ? _b3 : null;
|
|
10050
10077
|
};
|
|
10051
10078
|
var IconFallback = () => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_lucide_react12.Circle, { className: "h-3 w-3 opacity-80", "aria-hidden": "true" });
|
|
10052
10079
|
var DEFAULT_EXPANDED_LOGO_SLOT = /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "h-10 w-[175px] shrink-0", "aria-hidden": "true" });
|
|
@@ -10500,12 +10527,12 @@ var FOOTER_LAYOUT_AREAS = {
|
|
|
10500
10527
|
legal: "Barra legal"
|
|
10501
10528
|
};
|
|
10502
10529
|
var groupLinksBySection = (links) => {
|
|
10503
|
-
var
|
|
10530
|
+
var _a25;
|
|
10504
10531
|
const groups = /* @__PURE__ */ new Map();
|
|
10505
10532
|
for (const link of links) {
|
|
10506
10533
|
const section = link.section.trim();
|
|
10507
10534
|
if (!section) continue;
|
|
10508
|
-
const bucket = (
|
|
10535
|
+
const bucket = (_a25 = groups.get(section)) != null ? _a25 : [];
|
|
10509
10536
|
bucket.push({ label: link.label, href: link.href });
|
|
10510
10537
|
groups.set(section, bucket);
|
|
10511
10538
|
}
|
|
@@ -10515,18 +10542,18 @@ var groupLinksBySection = (links) => {
|
|
|
10515
10542
|
}));
|
|
10516
10543
|
};
|
|
10517
10544
|
var buildFooterLayout = (links) => {
|
|
10518
|
-
var
|
|
10545
|
+
var _a25;
|
|
10519
10546
|
const byArea = /* @__PURE__ */ new Map();
|
|
10520
10547
|
for (const link of links) {
|
|
10521
10548
|
const area = link.area.trim();
|
|
10522
10549
|
if (!area) continue;
|
|
10523
|
-
const bucket = (
|
|
10550
|
+
const bucket = (_a25 = byArea.get(area)) != null ? _a25 : [];
|
|
10524
10551
|
bucket.push(link);
|
|
10525
10552
|
byArea.set(area, bucket);
|
|
10526
10553
|
}
|
|
10527
10554
|
const pickArea = (area) => {
|
|
10528
|
-
var
|
|
10529
|
-
return (
|
|
10555
|
+
var _a26;
|
|
10556
|
+
return (_a26 = byArea.get(area)) != null ? _a26 : [];
|
|
10530
10557
|
};
|
|
10531
10558
|
const footerLeftGroups = groupLinksBySection(pickArea(FOOTER_LAYOUT_AREAS.left));
|
|
10532
10559
|
const footerServiceGroups = [
|
|
@@ -10578,9 +10605,9 @@ var requestJson = async (path, init) => {
|
|
|
10578
10605
|
return payload;
|
|
10579
10606
|
};
|
|
10580
10607
|
var loadFooterLinks = async () => {
|
|
10581
|
-
var
|
|
10608
|
+
var _a25;
|
|
10582
10609
|
const data = await requestJson("/api/ds/footer-links");
|
|
10583
|
-
return ((
|
|
10610
|
+
return ((_a25 = data.links) != null ? _a25 : []).map(toLink);
|
|
10584
10611
|
};
|
|
10585
10612
|
|
|
10586
10613
|
// src/hooks/useFooterLinks.ts
|
|
@@ -11620,10 +11647,10 @@ function isThemeMode(value) {
|
|
|
11620
11647
|
return value === "light" || value === "dark";
|
|
11621
11648
|
}
|
|
11622
11649
|
function readStoredTheme() {
|
|
11623
|
-
var
|
|
11650
|
+
var _a25;
|
|
11624
11651
|
if (typeof window === "undefined") return null;
|
|
11625
11652
|
try {
|
|
11626
|
-
const storedTheme = (
|
|
11653
|
+
const storedTheme = (_a25 = window.localStorage.getItem(THEME_STORAGE_KEY2)) != null ? _a25 : window.localStorage.getItem("theme");
|
|
11627
11654
|
return isThemeMode(storedTheme) ? storedTheme : null;
|
|
11628
11655
|
} catch (e) {
|
|
11629
11656
|
return null;
|
|
@@ -11646,10 +11673,10 @@ function applyThemeClass(theme) {
|
|
|
11646
11673
|
root.style.colorScheme = theme;
|
|
11647
11674
|
}
|
|
11648
11675
|
function readThemeFromRoot() {
|
|
11649
|
-
var
|
|
11676
|
+
var _a25;
|
|
11650
11677
|
if (typeof document === "undefined") return null;
|
|
11651
11678
|
const root = document.documentElement;
|
|
11652
|
-
const datasetTheme = (
|
|
11679
|
+
const datasetTheme = (_a25 = root.dataset.theme) != null ? _a25 : null;
|
|
11653
11680
|
if (isThemeMode(datasetTheme)) return datasetTheme;
|
|
11654
11681
|
if (root.classList.contains("dark")) return "dark";
|
|
11655
11682
|
if (root.classList.contains("light")) return "light";
|
|
@@ -11672,13 +11699,13 @@ var ThemeToggle2 = ({
|
|
|
11672
11699
|
defaultTheme = "light",
|
|
11673
11700
|
onThemeChange
|
|
11674
11701
|
}) => {
|
|
11675
|
-
var
|
|
11702
|
+
var _a25;
|
|
11676
11703
|
const themeContext = React31.useContext(ThemeContext);
|
|
11677
11704
|
const [mounted, setMounted] = React31.useState(false);
|
|
11678
11705
|
const [internalTheme, setInternalTheme] = React31.useState(defaultTheme);
|
|
11679
11706
|
const isControlled = typeof theme !== "undefined";
|
|
11680
11707
|
const usesProviderTheme = !isControlled && themeContext !== null;
|
|
11681
|
-
const activeTheme = (
|
|
11708
|
+
const activeTheme = (_a25 = isControlled ? theme : usesProviderTheme ? themeContext.theme : internalTheme) != null ? _a25 : defaultTheme;
|
|
11682
11709
|
React31.useEffect(() => {
|
|
11683
11710
|
if (!isControlled && !usesProviderTheme) {
|
|
11684
11711
|
setInternalTheme(resolveTheme(defaultTheme));
|
|
@@ -11703,8 +11730,8 @@ var ThemeToggle2 = ({
|
|
|
11703
11730
|
return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: cn("w-10 h-10 rounded-lg bg-muted", className) });
|
|
11704
11731
|
}
|
|
11705
11732
|
const handleToggle = (event) => {
|
|
11706
|
-
var
|
|
11707
|
-
const currentTheme = (
|
|
11733
|
+
var _a26;
|
|
11734
|
+
const currentTheme = (_a26 = readThemeFromRoot()) != null ? _a26 : activeTheme;
|
|
11708
11735
|
const nextTheme = currentTheme === "dark" ? "light" : "dark";
|
|
11709
11736
|
if (usesProviderTheme) {
|
|
11710
11737
|
themeContext.toggleTheme({
|
|
@@ -11758,11 +11785,11 @@ function getPreferredTheme() {
|
|
|
11758
11785
|
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
11759
11786
|
}
|
|
11760
11787
|
function getStoredTheme() {
|
|
11761
|
-
var
|
|
11788
|
+
var _a25;
|
|
11762
11789
|
if (typeof window === "undefined") {
|
|
11763
11790
|
return null;
|
|
11764
11791
|
}
|
|
11765
|
-
const storedTheme = (
|
|
11792
|
+
const storedTheme = (_a25 = window.localStorage.getItem(STORAGE_KEY)) != null ? _a25 : window.localStorage.getItem(LEGACY_STORAGE_KEY);
|
|
11766
11793
|
return storedTheme === "light" || storedTheme === "dark" ? storedTheme : null;
|
|
11767
11794
|
}
|
|
11768
11795
|
function getThemeFromRoot() {
|
|
@@ -11783,8 +11810,8 @@ function getThemeFromRoot() {
|
|
|
11783
11810
|
return null;
|
|
11784
11811
|
}
|
|
11785
11812
|
function resolveTheme2() {
|
|
11786
|
-
var
|
|
11787
|
-
return (_b3 = (
|
|
11813
|
+
var _a25, _b3;
|
|
11814
|
+
return (_b3 = (_a25 = getThemeFromRoot()) != null ? _a25 : getStoredTheme()) != null ? _b3 : getPreferredTheme();
|
|
11788
11815
|
}
|
|
11789
11816
|
function applyThemeToRoot(theme) {
|
|
11790
11817
|
const root = document.documentElement;
|
|
@@ -11854,7 +11881,7 @@ function ThemeProvider({ children }) {
|
|
|
11854
11881
|
return () => observer.disconnect();
|
|
11855
11882
|
}, []);
|
|
11856
11883
|
const applyThemeSelection = (0, import_react28.useCallback)((nextTheme, coords) => {
|
|
11857
|
-
var
|
|
11884
|
+
var _a25;
|
|
11858
11885
|
const documentWithTransition = document;
|
|
11859
11886
|
const root = document.documentElement;
|
|
11860
11887
|
const prefersReducedMotion = window.matchMedia(
|
|
@@ -11879,7 +11906,7 @@ function ThemeProvider({ children }) {
|
|
|
11879
11906
|
root.style.setProperty("--theme-x", "50%");
|
|
11880
11907
|
root.style.setProperty("--theme-y", "50%");
|
|
11881
11908
|
}
|
|
11882
|
-
(
|
|
11909
|
+
(_a25 = documentWithTransition.startViewTransition) == null ? void 0 : _a25.call(documentWithTransition, () => {
|
|
11883
11910
|
(0, import_react_dom.flushSync)(() => {
|
|
11884
11911
|
commitTheme();
|
|
11885
11912
|
});
|
|
@@ -11889,8 +11916,8 @@ function ThemeProvider({ children }) {
|
|
|
11889
11916
|
applyThemeSelection(nextTheme);
|
|
11890
11917
|
}, [applyThemeSelection]);
|
|
11891
11918
|
const toggleTheme = (0, import_react28.useCallback)((coords) => {
|
|
11892
|
-
var
|
|
11893
|
-
const currentTheme = (
|
|
11919
|
+
var _a25;
|
|
11920
|
+
const currentTheme = (_a25 = getThemeFromRoot()) != null ? _a25 : theme;
|
|
11894
11921
|
const nextTheme = currentTheme === "light" ? "dark" : "light";
|
|
11895
11922
|
applyThemeSelection(nextTheme, coords);
|
|
11896
11923
|
}, [applyThemeSelection, theme]);
|
|
@@ -12597,8 +12624,8 @@ var ChartStyle = ({ id, config }) => {
|
|
|
12597
12624
|
([theme, prefix]) => `
|
|
12598
12625
|
${prefix} [data-chart=${id}] {
|
|
12599
12626
|
${colorConfig.map(([key, itemConfig]) => {
|
|
12600
|
-
var
|
|
12601
|
-
const color = ((
|
|
12627
|
+
var _a25;
|
|
12628
|
+
const color = ((_a25 = itemConfig.theme) == null ? void 0 : _a25[theme]) || itemConfig.color;
|
|
12602
12629
|
return color ? ` --color-${key}: ${color};` : null;
|
|
12603
12630
|
}).join("\n")}
|
|
12604
12631
|
}
|
|
@@ -12627,14 +12654,14 @@ var ChartTooltipContent = React40.forwardRef(
|
|
|
12627
12654
|
}, ref) => {
|
|
12628
12655
|
const { config } = useChart();
|
|
12629
12656
|
const tooltipLabel = React40.useMemo(() => {
|
|
12630
|
-
var
|
|
12657
|
+
var _a25;
|
|
12631
12658
|
if (hideLabel || !(payload == null ? void 0 : payload.length)) {
|
|
12632
12659
|
return null;
|
|
12633
12660
|
}
|
|
12634
12661
|
const [item] = payload;
|
|
12635
12662
|
const key = `${labelKey || item.dataKey || item.name || "value"}`;
|
|
12636
12663
|
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
12637
|
-
const value = !labelKey && typeof label === "string" ? ((
|
|
12664
|
+
const value = !labelKey && typeof label === "string" ? ((_a25 = config[label]) == null ? void 0 : _a25.label) || label : itemConfig == null ? void 0 : itemConfig.label;
|
|
12638
12665
|
if (labelFormatter) {
|
|
12639
12666
|
return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: cn("font-medium", labelClassName), children: labelFormatter(value, payload) });
|
|
12640
12667
|
}
|
|
@@ -14354,9 +14381,9 @@ ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
|
|
|
14354
14381
|
// src/hooks/useActiveSection.ts
|
|
14355
14382
|
var import_react30 = require("react");
|
|
14356
14383
|
var resolveActiveFromOffsets = (sectionIds, topById, offset, scrollY) => {
|
|
14357
|
-
var
|
|
14384
|
+
var _a25;
|
|
14358
14385
|
const line = scrollY + offset;
|
|
14359
|
-
let nextActive = (
|
|
14386
|
+
let nextActive = (_a25 = sectionIds[0]) != null ? _a25 : "";
|
|
14360
14387
|
for (const id of sectionIds) {
|
|
14361
14388
|
const top = topById.get(id);
|
|
14362
14389
|
if (typeof top !== "number") continue;
|
|
@@ -14369,10 +14396,10 @@ var resolveActiveFromOffsets = (sectionIds, topById, offset, scrollY) => {
|
|
|
14369
14396
|
return nextActive;
|
|
14370
14397
|
};
|
|
14371
14398
|
var useActiveSection = (sectionIds, offset = 180) => {
|
|
14372
|
-
var
|
|
14373
|
-
const [activeId, setActiveId] = (0, import_react30.useState)((
|
|
14399
|
+
var _a25;
|
|
14400
|
+
const [activeId, setActiveId] = (0, import_react30.useState)((_a25 = sectionIds[0]) != null ? _a25 : "");
|
|
14374
14401
|
(0, import_react30.useEffect)(() => {
|
|
14375
|
-
var
|
|
14402
|
+
var _a26;
|
|
14376
14403
|
if (!sectionIds.length || typeof window === "undefined") return;
|
|
14377
14404
|
const sections = sectionIds.map((id) => {
|
|
14378
14405
|
const element = document.getElementById(id);
|
|
@@ -14380,7 +14407,7 @@ var useActiveSection = (sectionIds, offset = 180) => {
|
|
|
14380
14407
|
return { id, element };
|
|
14381
14408
|
}).filter((section) => section !== null);
|
|
14382
14409
|
if (!sections.length) {
|
|
14383
|
-
setActiveId((
|
|
14410
|
+
setActiveId((_a26 = sectionIds[0]) != null ? _a26 : "");
|
|
14384
14411
|
return;
|
|
14385
14412
|
}
|
|
14386
14413
|
const topById = /* @__PURE__ */ new Map();
|
|
@@ -14515,9 +14542,9 @@ var useLayoutMode = () => {
|
|
|
14515
14542
|
setMode(normalizeLayoutMode(event.newValue));
|
|
14516
14543
|
};
|
|
14517
14544
|
const handleModeChange = (event) => {
|
|
14518
|
-
var
|
|
14545
|
+
var _a25;
|
|
14519
14546
|
const customEvent = event;
|
|
14520
|
-
setMode((
|
|
14547
|
+
setMode((_a25 = customEvent.detail) != null ? _a25 : readStoredLayoutMode());
|
|
14521
14548
|
};
|
|
14522
14549
|
window.addEventListener("storage", handleStorage);
|
|
14523
14550
|
window.addEventListener(LAYOUT_MODE_CHANGE_EVENT, handleModeChange);
|
|
@@ -14674,7 +14701,7 @@ var FunctionsClient = class {
|
|
|
14674
14701
|
*/
|
|
14675
14702
|
invoke(functionName_1) {
|
|
14676
14703
|
return __awaiter(this, arguments, void 0, function* (functionName, options = {}) {
|
|
14677
|
-
var
|
|
14704
|
+
var _a25;
|
|
14678
14705
|
let timeoutId;
|
|
14679
14706
|
let timeoutController;
|
|
14680
14707
|
try {
|
|
@@ -14740,7 +14767,7 @@ var FunctionsClient = class {
|
|
|
14740
14767
|
if (!response.ok) {
|
|
14741
14768
|
throw new FunctionsHttpError(response);
|
|
14742
14769
|
}
|
|
14743
|
-
let responseType = ((
|
|
14770
|
+
let responseType = ((_a25 = response.headers.get("Content-Type")) !== null && _a25 !== void 0 ? _a25 : "text/plain").split(";")[0].trim();
|
|
14744
14771
|
let data;
|
|
14745
14772
|
if (responseType === "application/json") {
|
|
14746
14773
|
data = yield response.json();
|
|
@@ -16089,7 +16116,7 @@ var WebSocketFactory = class {
|
|
|
16089
16116
|
constructor() {
|
|
16090
16117
|
}
|
|
16091
16118
|
static detectEnvironment() {
|
|
16092
|
-
var
|
|
16119
|
+
var _a25;
|
|
16093
16120
|
if (typeof WebSocket !== "undefined") {
|
|
16094
16121
|
return { type: "native", constructor: WebSocket };
|
|
16095
16122
|
}
|
|
@@ -16106,7 +16133,7 @@ var WebSocketFactory = class {
|
|
|
16106
16133
|
workaround: "Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."
|
|
16107
16134
|
};
|
|
16108
16135
|
}
|
|
16109
|
-
if (typeof globalThis !== "undefined" && globalThis.EdgeRuntime || typeof navigator !== "undefined" && ((
|
|
16136
|
+
if (typeof globalThis !== "undefined" && globalThis.EdgeRuntime || typeof navigator !== "undefined" && ((_a25 = navigator.userAgent) === null || _a25 === void 0 ? void 0 : _a25.includes("Vercel-Edge"))) {
|
|
16110
16137
|
return {
|
|
16111
16138
|
type: "unsupported",
|
|
16112
16139
|
error: "Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",
|
|
@@ -16190,7 +16217,7 @@ Suggested solution: ${env.workaround}`;
|
|
|
16190
16217
|
try {
|
|
16191
16218
|
const env = this.detectEnvironment();
|
|
16192
16219
|
return env.type === "native" || env.type === "ws";
|
|
16193
|
-
} catch (
|
|
16220
|
+
} catch (_a25) {
|
|
16194
16221
|
return false;
|
|
16195
16222
|
}
|
|
16196
16223
|
}
|
|
@@ -16264,29 +16291,29 @@ var Serializer = class {
|
|
|
16264
16291
|
return callback(JSON.stringify(payload));
|
|
16265
16292
|
}
|
|
16266
16293
|
_binaryEncodeUserBroadcastPush(message) {
|
|
16267
|
-
var
|
|
16268
|
-
if (this._isArrayBuffer((
|
|
16294
|
+
var _a25;
|
|
16295
|
+
if (this._isArrayBuffer((_a25 = message.payload) === null || _a25 === void 0 ? void 0 : _a25.payload)) {
|
|
16269
16296
|
return this._encodeBinaryUserBroadcastPush(message);
|
|
16270
16297
|
} else {
|
|
16271
16298
|
return this._encodeJsonUserBroadcastPush(message);
|
|
16272
16299
|
}
|
|
16273
16300
|
}
|
|
16274
16301
|
_encodeBinaryUserBroadcastPush(message) {
|
|
16275
|
-
var
|
|
16276
|
-
const userPayload = (_b3 = (
|
|
16302
|
+
var _a25, _b3;
|
|
16303
|
+
const userPayload = (_b3 = (_a25 = message.payload) === null || _a25 === void 0 ? void 0 : _a25.payload) !== null && _b3 !== void 0 ? _b3 : new ArrayBuffer(0);
|
|
16277
16304
|
return this._encodeUserBroadcastPush(message, this.BINARY_ENCODING, userPayload);
|
|
16278
16305
|
}
|
|
16279
16306
|
_encodeJsonUserBroadcastPush(message) {
|
|
16280
|
-
var
|
|
16281
|
-
const userPayload = (_b3 = (
|
|
16307
|
+
var _a25, _b3;
|
|
16308
|
+
const userPayload = (_b3 = (_a25 = message.payload) === null || _a25 === void 0 ? void 0 : _a25.payload) !== null && _b3 !== void 0 ? _b3 : {};
|
|
16282
16309
|
const encoder = new TextEncoder();
|
|
16283
16310
|
const encodedUserPayload = encoder.encode(JSON.stringify(userPayload)).buffer;
|
|
16284
16311
|
return this._encodeUserBroadcastPush(message, this.JSON_ENCODING, encodedUserPayload);
|
|
16285
16312
|
}
|
|
16286
16313
|
_encodeUserBroadcastPush(message, encodingType, encodedPayload) {
|
|
16287
|
-
var
|
|
16314
|
+
var _a25, _b3;
|
|
16288
16315
|
const topic = message.topic;
|
|
16289
|
-
const ref = (
|
|
16316
|
+
const ref = (_a25 = message.ref) !== null && _a25 !== void 0 ? _a25 : "";
|
|
16290
16317
|
const joinRef = (_b3 = message.join_ref) !== null && _b3 !== void 0 ? _b3 : "";
|
|
16291
16318
|
const userEvent = message.payload.event;
|
|
16292
16319
|
const rest = this.allowedMetadataKeys ? this._pick(message.payload, this.allowedMetadataKeys) : {};
|
|
@@ -16373,8 +16400,8 @@ var Serializer = class {
|
|
|
16373
16400
|
return { join_ref: null, ref: null, topic, event: this.BROADCAST_EVENT, payload: data };
|
|
16374
16401
|
}
|
|
16375
16402
|
_isArrayBuffer(buffer) {
|
|
16376
|
-
var
|
|
16377
|
-
return buffer instanceof ArrayBuffer || ((
|
|
16403
|
+
var _a25;
|
|
16404
|
+
return buffer instanceof ArrayBuffer || ((_a25 = buffer === null || buffer === void 0 ? void 0 : buffer.constructor) === null || _a25 === void 0 ? void 0 : _a25.name) === "ArrayBuffer";
|
|
16378
16405
|
}
|
|
16379
16406
|
_pick(obj, keys) {
|
|
16380
16407
|
if (!obj || typeof obj !== "object") {
|
|
@@ -16438,8 +16465,8 @@ var PostgresTypes;
|
|
|
16438
16465
|
PostgresTypes2["tstzrange"] = "tstzrange";
|
|
16439
16466
|
})(PostgresTypes || (PostgresTypes = {}));
|
|
16440
16467
|
var convertChangeData = (columns, record, options = {}) => {
|
|
16441
|
-
var
|
|
16442
|
-
const skipTypes = (
|
|
16468
|
+
var _a25;
|
|
16469
|
+
const skipTypes = (_a25 = options.skipTypes) !== null && _a25 !== void 0 ? _a25 : [];
|
|
16443
16470
|
if (!record) {
|
|
16444
16471
|
return {};
|
|
16445
16472
|
}
|
|
@@ -16529,7 +16556,7 @@ var toJson = (value) => {
|
|
|
16529
16556
|
if (typeof value === "string") {
|
|
16530
16557
|
try {
|
|
16531
16558
|
return JSON.parse(value);
|
|
16532
|
-
} catch (
|
|
16559
|
+
} catch (_a25) {
|
|
16533
16560
|
return value;
|
|
16534
16561
|
}
|
|
16535
16562
|
}
|
|
@@ -16621,9 +16648,9 @@ var Push = class {
|
|
|
16621
16648
|
this.payload = Object.assign(Object.assign({}, this.payload), payload);
|
|
16622
16649
|
}
|
|
16623
16650
|
receive(status, callback) {
|
|
16624
|
-
var
|
|
16651
|
+
var _a25;
|
|
16625
16652
|
if (this._hasReceived(status)) {
|
|
16626
|
-
callback((
|
|
16653
|
+
callback((_a25 = this.receivedResp) === null || _a25 === void 0 ? void 0 : _a25.response);
|
|
16627
16654
|
}
|
|
16628
16655
|
this.recHooks.push({ status, callback });
|
|
16629
16656
|
return this;
|
|
@@ -16814,8 +16841,8 @@ var RealtimePresence = class _RealtimePresence {
|
|
|
16814
16841
|
};
|
|
16815
16842
|
}
|
|
16816
16843
|
this.map(joins, (key, newPresences) => {
|
|
16817
|
-
var
|
|
16818
|
-
const currentPresences = (
|
|
16844
|
+
var _a25;
|
|
16845
|
+
const currentPresences = (_a25 = state[key]) !== null && _a25 !== void 0 ? _a25 : [];
|
|
16819
16846
|
state[key] = this.cloneDeep(newPresences);
|
|
16820
16847
|
if (currentPresences.length > 0) {
|
|
16821
16848
|
const joinedPresenceRefs = state[key].map((m) => m.presence_ref);
|
|
@@ -16943,7 +16970,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
16943
16970
|
* ```
|
|
16944
16971
|
*/
|
|
16945
16972
|
constructor(topic, params = { config: {} }, socket) {
|
|
16946
|
-
var
|
|
16973
|
+
var _a25, _b3;
|
|
16947
16974
|
this.topic = topic;
|
|
16948
16975
|
this.params = params;
|
|
16949
16976
|
this.socket = socket;
|
|
@@ -17002,19 +17029,19 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
17002
17029
|
this.presence = new RealtimePresence(this);
|
|
17003
17030
|
this.broadcastEndpointURL = httpEndpointURL(this.socket.endPoint);
|
|
17004
17031
|
this.private = this.params.config.private || false;
|
|
17005
|
-
if (!this.private && ((_b3 = (
|
|
17032
|
+
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
17033
|
throw `tried to use replay on public channel '${this.topic}'. It must be a private channel.`;
|
|
17007
17034
|
}
|
|
17008
17035
|
}
|
|
17009
17036
|
/** Subscribe registers your client with the server */
|
|
17010
17037
|
subscribe(callback, timeout = this.timeout) {
|
|
17011
|
-
var
|
|
17038
|
+
var _a25, _b3, _c;
|
|
17012
17039
|
if (!this.socket.isConnected()) {
|
|
17013
17040
|
this.socket.connect();
|
|
17014
17041
|
}
|
|
17015
17042
|
if (this.state == CHANNEL_STATES.closed) {
|
|
17016
17043
|
const { config: { broadcast, presence, private: isPrivate } } = this.params;
|
|
17017
|
-
const postgres_changes = (_b3 = (
|
|
17044
|
+
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
17045
|
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
17046
|
const accessTokenPayload = {};
|
|
17020
17047
|
const config = {
|
|
@@ -17032,7 +17059,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
17032
17059
|
this.joinedOnce = true;
|
|
17033
17060
|
this._rejoin(timeout);
|
|
17034
17061
|
this.joinPush.receive("ok", async ({ postgres_changes: postgres_changes2 }) => {
|
|
17035
|
-
var
|
|
17062
|
+
var _a26;
|
|
17036
17063
|
if (!this.socket._isManualToken()) {
|
|
17037
17064
|
this.socket.setAuth();
|
|
17038
17065
|
}
|
|
@@ -17041,7 +17068,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
17041
17068
|
return;
|
|
17042
17069
|
} else {
|
|
17043
17070
|
const clientPostgresBindings = this.bindings.postgres_changes;
|
|
17044
|
-
const bindingsLen = (
|
|
17071
|
+
const bindingsLen = (_a26 = clientPostgresBindings === null || clientPostgresBindings === void 0 ? void 0 : clientPostgresBindings.length) !== null && _a26 !== void 0 ? _a26 : 0;
|
|
17045
17072
|
const newPostgresBindings = [];
|
|
17046
17073
|
for (let i = 0; i < bindingsLen; i++) {
|
|
17047
17074
|
const clientPostgresBinding = clientPostgresBindings[i];
|
|
@@ -17119,7 +17146,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
17119
17146
|
* @returns Promise resolving to object with success status, and error details if failed
|
|
17120
17147
|
*/
|
|
17121
17148
|
async httpSend(event, payload, opts = {}) {
|
|
17122
|
-
var
|
|
17149
|
+
var _a25;
|
|
17123
17150
|
if (payload === void 0 || payload === null) {
|
|
17124
17151
|
return Promise.reject("Payload is required for httpSend()");
|
|
17125
17152
|
}
|
|
@@ -17144,7 +17171,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
17144
17171
|
]
|
|
17145
17172
|
})
|
|
17146
17173
|
};
|
|
17147
|
-
const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (
|
|
17174
|
+
const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a25 = opts.timeout) !== null && _a25 !== void 0 ? _a25 : this.timeout);
|
|
17148
17175
|
if (response.status === 202) {
|
|
17149
17176
|
return { success: true };
|
|
17150
17177
|
}
|
|
@@ -17166,7 +17193,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
17166
17193
|
* @param opts Options to be used during the send process
|
|
17167
17194
|
*/
|
|
17168
17195
|
async send(args, opts = {}) {
|
|
17169
|
-
var
|
|
17196
|
+
var _a25, _b3;
|
|
17170
17197
|
if (!this._canPush() && args.type === "broadcast") {
|
|
17171
17198
|
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
17199
|
const { event, payload: endpoint_payload } = args;
|
|
@@ -17192,7 +17219,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
17192
17219
|
})
|
|
17193
17220
|
};
|
|
17194
17221
|
try {
|
|
17195
|
-
const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (
|
|
17222
|
+
const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a25 = opts.timeout) !== null && _a25 !== void 0 ? _a25 : this.timeout);
|
|
17196
17223
|
await ((_b3 = response.body) === null || _b3 === void 0 ? void 0 : _b3.cancel());
|
|
17197
17224
|
return response.ok ? "ok" : "error";
|
|
17198
17225
|
} catch (error) {
|
|
@@ -17204,9 +17231,9 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
17204
17231
|
}
|
|
17205
17232
|
} else {
|
|
17206
17233
|
return new Promise((resolve) => {
|
|
17207
|
-
var
|
|
17234
|
+
var _a26, _b4, _c;
|
|
17208
17235
|
const push = this._push(args.type, args, opts.timeout || this.timeout);
|
|
17209
|
-
if (args.type === "broadcast" && !((_c = (_b4 = (
|
|
17236
|
+
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
17237
|
resolve("ok");
|
|
17211
17238
|
}
|
|
17212
17239
|
push.receive("ok", () => resolve("ok"));
|
|
@@ -17325,7 +17352,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
17325
17352
|
}
|
|
17326
17353
|
/** @internal */
|
|
17327
17354
|
_trigger(type, payload, ref) {
|
|
17328
|
-
var
|
|
17355
|
+
var _a25, _b3;
|
|
17329
17356
|
const typeLower = type.toLocaleLowerCase();
|
|
17330
17357
|
const { close, error, leave, join } = CHANNEL_EVENTS;
|
|
17331
17358
|
const events = [close, error, leave, join];
|
|
@@ -17337,17 +17364,17 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
17337
17364
|
throw "channel onMessage callbacks must return the payload, modified or unmodified";
|
|
17338
17365
|
}
|
|
17339
17366
|
if (["insert", "update", "delete"].includes(typeLower)) {
|
|
17340
|
-
(
|
|
17341
|
-
var
|
|
17342
|
-
return ((
|
|
17367
|
+
(_a25 = this.bindings.postgres_changes) === null || _a25 === void 0 ? void 0 : _a25.filter((bind) => {
|
|
17368
|
+
var _a26, _b4, _c;
|
|
17369
|
+
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
17370
|
}).map((bind) => bind.callback(handledPayload, ref));
|
|
17344
17371
|
} else {
|
|
17345
17372
|
(_b3 = this.bindings[typeLower]) === null || _b3 === void 0 ? void 0 : _b3.filter((bind) => {
|
|
17346
|
-
var
|
|
17373
|
+
var _a26, _b4, _c, _d, _e, _f;
|
|
17347
17374
|
if (["broadcast", "presence", "postgres_changes"].includes(typeLower)) {
|
|
17348
17375
|
if ("id" in bind) {
|
|
17349
17376
|
const bindId = bind.id;
|
|
17350
|
-
const bindEvent = (
|
|
17377
|
+
const bindEvent = (_a26 = bind.filter) === null || _a26 === void 0 ? void 0 : _a26.event;
|
|
17351
17378
|
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
17379
|
} else {
|
|
17353
17380
|
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 +17442,8 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
17415
17442
|
const typeLower = type.toLocaleLowerCase();
|
|
17416
17443
|
if (this.bindings[typeLower]) {
|
|
17417
17444
|
this.bindings[typeLower] = this.bindings[typeLower].filter((bind) => {
|
|
17418
|
-
var
|
|
17419
|
-
return !(((
|
|
17445
|
+
var _a25;
|
|
17446
|
+
return !(((_a25 = bind.type) === null || _a25 === void 0 ? void 0 : _a25.toLocaleLowerCase()) === typeLower && _RealtimeChannel.isEqual(bind.filter, filter));
|
|
17420
17447
|
});
|
|
17421
17448
|
}
|
|
17422
17449
|
return this;
|
|
@@ -17546,7 +17573,7 @@ var RealtimeClient = class {
|
|
|
17546
17573
|
* ```
|
|
17547
17574
|
*/
|
|
17548
17575
|
constructor(endPoint, options) {
|
|
17549
|
-
var
|
|
17576
|
+
var _a25;
|
|
17550
17577
|
this.accessTokenValue = null;
|
|
17551
17578
|
this.apiKey = null;
|
|
17552
17579
|
this._manuallySetToken = false;
|
|
@@ -17585,7 +17612,7 @@ var RealtimeClient = class {
|
|
|
17585
17612
|
}
|
|
17586
17613
|
return (...args) => fetch(...args);
|
|
17587
17614
|
};
|
|
17588
|
-
if (!((
|
|
17615
|
+
if (!((_a25 = options === null || options === void 0 ? void 0 : options.params) === null || _a25 === void 0 ? void 0 : _a25.apikey)) {
|
|
17589
17616
|
throw new Error("API key is required to connect to Realtime");
|
|
17590
17617
|
}
|
|
17591
17618
|
this.apiKey = options.params.apikey;
|
|
@@ -17770,8 +17797,8 @@ Option 2: Install and provide the "ws" package:
|
|
|
17770
17797
|
const { topic, event, payload, ref } = data;
|
|
17771
17798
|
const callback = () => {
|
|
17772
17799
|
this.encode(data, (result) => {
|
|
17773
|
-
var
|
|
17774
|
-
(
|
|
17800
|
+
var _a25;
|
|
17801
|
+
(_a25 = this.conn) === null || _a25 === void 0 ? void 0 : _a25.send(result);
|
|
17775
17802
|
});
|
|
17776
17803
|
};
|
|
17777
17804
|
this.log("push", `${topic} ${event} (${ref})`, payload);
|
|
@@ -17821,7 +17848,7 @@ Option 2: Install and provide the "ws" package:
|
|
|
17821
17848
|
* Sends a heartbeat message if the socket is connected.
|
|
17822
17849
|
*/
|
|
17823
17850
|
async sendHeartbeat() {
|
|
17824
|
-
var
|
|
17851
|
+
var _a25;
|
|
17825
17852
|
if (!this.isConnected()) {
|
|
17826
17853
|
try {
|
|
17827
17854
|
this.heartbeatCallback("disconnected");
|
|
@@ -17840,11 +17867,11 @@ Option 2: Install and provide the "ws" package:
|
|
|
17840
17867
|
this.log("error", "error in heartbeat callback", e);
|
|
17841
17868
|
}
|
|
17842
17869
|
this._wasManualDisconnect = false;
|
|
17843
|
-
(
|
|
17870
|
+
(_a25 = this.conn) === null || _a25 === void 0 ? void 0 : _a25.close(WS_CLOSE_NORMAL, "heartbeat timeout");
|
|
17844
17871
|
setTimeout(() => {
|
|
17845
|
-
var
|
|
17872
|
+
var _a26;
|
|
17846
17873
|
if (!this.isConnected()) {
|
|
17847
|
-
(
|
|
17874
|
+
(_a26 = this.reconnectTimer) === null || _a26 === void 0 ? void 0 : _a26.scheduleTimeout();
|
|
17848
17875
|
}
|
|
17849
17876
|
}, CONNECTION_TIMEOUTS.HEARTBEAT_TIMEOUT_FALLBACK);
|
|
17850
17877
|
return;
|
|
@@ -17942,12 +17969,12 @@ Option 2: Install and provide the "ws" package:
|
|
|
17942
17969
|
* @internal
|
|
17943
17970
|
*/
|
|
17944
17971
|
_clearTimer(timer) {
|
|
17945
|
-
var
|
|
17972
|
+
var _a25;
|
|
17946
17973
|
if (timer === "heartbeat" && this.heartbeatTimer) {
|
|
17947
17974
|
clearInterval(this.heartbeatTimer);
|
|
17948
17975
|
this.heartbeatTimer = void 0;
|
|
17949
17976
|
} else if (timer === "reconnect") {
|
|
17950
|
-
(
|
|
17977
|
+
(_a25 = this.reconnectTimer) === null || _a25 === void 0 ? void 0 : _a25.reset();
|
|
17951
17978
|
}
|
|
17952
17979
|
}
|
|
17953
17980
|
/**
|
|
@@ -18062,13 +18089,13 @@ Option 2: Install and provide the "ws" package:
|
|
|
18062
18089
|
}
|
|
18063
18090
|
/** @internal */
|
|
18064
18091
|
_onConnClose(event) {
|
|
18065
|
-
var
|
|
18092
|
+
var _a25;
|
|
18066
18093
|
this._setConnectionState("disconnected");
|
|
18067
18094
|
this.log("transport", "close", event);
|
|
18068
18095
|
this._triggerChanError();
|
|
18069
18096
|
this._clearTimer("heartbeat");
|
|
18070
18097
|
if (!this._wasManualDisconnect) {
|
|
18071
|
-
(
|
|
18098
|
+
(_a25 = this.reconnectTimer) === null || _a25 === void 0 ? void 0 : _a25.scheduleTimeout();
|
|
18072
18099
|
}
|
|
18073
18100
|
this._triggerStateCallbacks("close", event);
|
|
18074
18101
|
}
|
|
@@ -18216,8 +18243,8 @@ Option 2: Install and provide the "ws" package:
|
|
|
18216
18243
|
* @internal
|
|
18217
18244
|
*/
|
|
18218
18245
|
_initializeOptions(options) {
|
|
18219
|
-
var
|
|
18220
|
-
this.transport = (
|
|
18246
|
+
var _a25, _b3, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
18247
|
+
this.transport = (_a25 = options === null || options === void 0 ? void 0 : options.transport) !== null && _a25 !== void 0 ? _a25 : null;
|
|
18221
18248
|
this.timeout = (_b3 = options === null || options === void 0 ? void 0 : options.timeout) !== null && _b3 !== void 0 ? _b3 : DEFAULT_TIMEOUT;
|
|
18222
18249
|
this.heartbeatIntervalMs = (_c = options === null || options === void 0 ? void 0 : options.heartbeatIntervalMs) !== null && _c !== void 0 ? _c : CONNECTION_TIMEOUTS.HEARTBEAT_INTERVAL;
|
|
18223
18250
|
this.worker = (_d = options === null || options === void 0 ? void 0 : options.worker) !== null && _d !== void 0 ? _d : false;
|
|
@@ -18263,14 +18290,14 @@ Option 2: Install and provide the "ws" package:
|
|
|
18263
18290
|
// node_modules/.pnpm/iceberg-js@0.8.1/node_modules/iceberg-js/dist/index.mjs
|
|
18264
18291
|
var IcebergError = class extends Error {
|
|
18265
18292
|
constructor(message, opts) {
|
|
18266
|
-
var
|
|
18293
|
+
var _a25;
|
|
18267
18294
|
super(message);
|
|
18268
18295
|
this.name = "IcebergError";
|
|
18269
18296
|
this.status = opts.status;
|
|
18270
18297
|
this.icebergType = opts.icebergType;
|
|
18271
18298
|
this.icebergCode = opts.icebergCode;
|
|
18272
18299
|
this.details = opts.details;
|
|
18273
|
-
this.isCommitStateUnknown = opts.icebergType === "CommitStateUnknownException" || [500, 502, 504].includes(opts.status) && ((
|
|
18300
|
+
this.isCommitStateUnknown = opts.icebergType === "CommitStateUnknownException" || [500, 502, 504].includes(opts.status) && ((_a25 = opts.icebergType) == null ? void 0 : _a25.includes("CommitState")) === true;
|
|
18274
18301
|
}
|
|
18275
18302
|
/**
|
|
18276
18303
|
* Returns true if the error is a 404 Not Found error.
|
|
@@ -18318,8 +18345,8 @@ async function buildAuthHeaders(auth) {
|
|
|
18318
18345
|
return {};
|
|
18319
18346
|
}
|
|
18320
18347
|
function createFetchClient(options) {
|
|
18321
|
-
var
|
|
18322
|
-
const fetchFn = (
|
|
18348
|
+
var _a25;
|
|
18349
|
+
const fetchFn = (_a25 = options.fetchImpl) != null ? _a25 : globalThis.fetch;
|
|
18323
18350
|
return {
|
|
18324
18351
|
async request({
|
|
18325
18352
|
method,
|
|
@@ -18328,7 +18355,7 @@ function createFetchClient(options) {
|
|
|
18328
18355
|
body,
|
|
18329
18356
|
headers
|
|
18330
18357
|
}) {
|
|
18331
|
-
var
|
|
18358
|
+
var _a26;
|
|
18332
18359
|
const url = buildUrl(options.baseUrl, path, query);
|
|
18333
18360
|
const authHeaders = await buildAuthHeaders(options.auth);
|
|
18334
18361
|
const res = await fetchFn(url, {
|
|
@@ -18347,7 +18374,7 @@ function createFetchClient(options) {
|
|
|
18347
18374
|
const errBody = isJson ? data : void 0;
|
|
18348
18375
|
const errorDetail = errBody == null ? void 0 : errBody.error;
|
|
18349
18376
|
throw new IcebergError(
|
|
18350
|
-
(
|
|
18377
|
+
(_a26 = errorDetail == null ? void 0 : errorDetail.message) != null ? _a26 : `Request failed with status ${res.status}`,
|
|
18351
18378
|
{
|
|
18352
18379
|
status: res.status,
|
|
18353
18380
|
icebergType: errorDetail == null ? void 0 : errorDetail.type,
|
|
@@ -18470,11 +18497,11 @@ var TableOperations = class {
|
|
|
18470
18497
|
};
|
|
18471
18498
|
}
|
|
18472
18499
|
async dropTable(id, options) {
|
|
18473
|
-
var
|
|
18500
|
+
var _a25;
|
|
18474
18501
|
await this.client.request({
|
|
18475
18502
|
method: "DELETE",
|
|
18476
18503
|
path: `${this.prefix}/namespaces/${namespaceToPath2(id.namespace)}/tables/${id.name}`,
|
|
18477
|
-
query: { purgeRequested: String((
|
|
18504
|
+
query: { purgeRequested: String((_a25 = options == null ? void 0 : options.purge) != null ? _a25 : false) }
|
|
18478
18505
|
});
|
|
18479
18506
|
}
|
|
18480
18507
|
async loadTable(id) {
|
|
@@ -18526,7 +18553,7 @@ var IcebergRestCatalog = class {
|
|
|
18526
18553
|
* @param options - Configuration options for the catalog client
|
|
18527
18554
|
*/
|
|
18528
18555
|
constructor(options) {
|
|
18529
|
-
var
|
|
18556
|
+
var _a25;
|
|
18530
18557
|
let prefix = "v1";
|
|
18531
18558
|
if (options.catalogName) {
|
|
18532
18559
|
prefix += `/${options.catalogName}`;
|
|
@@ -18537,7 +18564,7 @@ var IcebergRestCatalog = class {
|
|
|
18537
18564
|
auth: options.auth,
|
|
18538
18565
|
fetchImpl: options.fetch
|
|
18539
18566
|
});
|
|
18540
|
-
this.accessDelegation = (
|
|
18567
|
+
this.accessDelegation = (_a25 = options.accessDelegation) == null ? void 0 : _a25.join(",");
|
|
18541
18568
|
this.namespaceOps = new NamespaceOperations(this.client, prefix);
|
|
18542
18569
|
this.tableOps = new TableOperations(this.client, prefix, this.accessDelegation);
|
|
18543
18570
|
}
|
|
@@ -21510,7 +21537,7 @@ var getItemAsync = async (storage, key) => {
|
|
|
21510
21537
|
}
|
|
21511
21538
|
try {
|
|
21512
21539
|
return JSON.parse(value);
|
|
21513
|
-
} catch (
|
|
21540
|
+
} catch (_a25) {
|
|
21514
21541
|
return value;
|
|
21515
21542
|
}
|
|
21516
21543
|
};
|
|
@@ -21721,7 +21748,7 @@ function deepClone(obj) {
|
|
|
21721
21748
|
var _getErrorMessage2 = (err) => err.msg || err.message || err.error_description || err.error || JSON.stringify(err);
|
|
21722
21749
|
var NETWORK_ERROR_CODES = [502, 503, 504];
|
|
21723
21750
|
async function handleError2(error) {
|
|
21724
|
-
var
|
|
21751
|
+
var _a25;
|
|
21725
21752
|
if (!looksLikeFetchResponse(error)) {
|
|
21726
21753
|
throw new AuthRetryableFetchError(_getErrorMessage2(error), 0);
|
|
21727
21754
|
}
|
|
@@ -21746,7 +21773,7 @@ async function handleError2(error) {
|
|
|
21746
21773
|
throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, data.weak_password.reasons);
|
|
21747
21774
|
}
|
|
21748
21775
|
} else if (errorCode === "weak_password") {
|
|
21749
|
-
throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, ((
|
|
21776
|
+
throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, ((_a25 = data.weak_password) === null || _a25 === void 0 ? void 0 : _a25.reasons) || []);
|
|
21750
21777
|
} else if (errorCode === "session_not_found") {
|
|
21751
21778
|
throw new AuthSessionMissingError();
|
|
21752
21779
|
}
|
|
@@ -21762,7 +21789,7 @@ var _getRequestParams2 = (method, options, parameters, body) => {
|
|
|
21762
21789
|
return Object.assign(Object.assign({}, params), parameters);
|
|
21763
21790
|
};
|
|
21764
21791
|
async function _request(fetcher, method, url, options) {
|
|
21765
|
-
var
|
|
21792
|
+
var _a25;
|
|
21766
21793
|
const headers = Object.assign({}, options === null || options === void 0 ? void 0 : options.headers);
|
|
21767
21794
|
if (!headers[API_VERSION_HEADER_NAME]) {
|
|
21768
21795
|
headers[API_VERSION_HEADER_NAME] = API_VERSIONS["2024-01-01"].name;
|
|
@@ -21770,7 +21797,7 @@ async function _request(fetcher, method, url, options) {
|
|
|
21770
21797
|
if (options === null || options === void 0 ? void 0 : options.jwt) {
|
|
21771
21798
|
headers["Authorization"] = `Bearer ${options.jwt}`;
|
|
21772
21799
|
}
|
|
21773
|
-
const qs = (
|
|
21800
|
+
const qs = (_a25 = options === null || options === void 0 ? void 0 : options.query) !== null && _a25 !== void 0 ? _a25 : {};
|
|
21774
21801
|
if (options === null || options === void 0 ? void 0 : options.redirectTo) {
|
|
21775
21802
|
qs["redirect_to"] = options.redirectTo;
|
|
21776
21803
|
}
|
|
@@ -21803,7 +21830,7 @@ async function _handleRequest2(fetcher, method, url, options, parameters, body)
|
|
|
21803
21830
|
}
|
|
21804
21831
|
}
|
|
21805
21832
|
function _sessionResponse(data) {
|
|
21806
|
-
var
|
|
21833
|
+
var _a25;
|
|
21807
21834
|
let session = null;
|
|
21808
21835
|
if (hasSession(data)) {
|
|
21809
21836
|
session = Object.assign({}, data);
|
|
@@ -21811,7 +21838,7 @@ function _sessionResponse(data) {
|
|
|
21811
21838
|
session.expires_at = expiresAt(data.expires_in);
|
|
21812
21839
|
}
|
|
21813
21840
|
}
|
|
21814
|
-
const user = (
|
|
21841
|
+
const user = (_a25 = data.user) !== null && _a25 !== void 0 ? _a25 : data;
|
|
21815
21842
|
return { data: { session, user }, error: null };
|
|
21816
21843
|
}
|
|
21817
21844
|
function _sessionResponsePassword(data) {
|
|
@@ -21822,8 +21849,8 @@ function _sessionResponsePassword(data) {
|
|
|
21822
21849
|
return response;
|
|
21823
21850
|
}
|
|
21824
21851
|
function _userResponse(data) {
|
|
21825
|
-
var
|
|
21826
|
-
const user = (
|
|
21852
|
+
var _a25;
|
|
21853
|
+
const user = (_a25 = data.user) !== null && _a25 !== void 0 ? _a25 : data;
|
|
21827
21854
|
return { data: { user }, error: null };
|
|
21828
21855
|
}
|
|
21829
21856
|
function _ssoResponse(data) {
|
|
@@ -21992,14 +22019,14 @@ var GoTrueAdminApi = class {
|
|
|
21992
22019
|
* @param params An object which supports `page` and `perPage` as numbers, to alter the paginated results.
|
|
21993
22020
|
*/
|
|
21994
22021
|
async listUsers(params) {
|
|
21995
|
-
var
|
|
22022
|
+
var _a25, _b3, _c, _d, _e, _f, _g;
|
|
21996
22023
|
try {
|
|
21997
22024
|
const pagination = { nextPage: null, lastPage: 0, total: 0 };
|
|
21998
22025
|
const response = await _request(this.fetch, "GET", `${this.url}/admin/users`, {
|
|
21999
22026
|
headers: this.headers,
|
|
22000
22027
|
noResolveJson: true,
|
|
22001
22028
|
query: {
|
|
22002
|
-
page: (_b3 = (
|
|
22029
|
+
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
22030
|
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
22031
|
},
|
|
22005
22032
|
xform: _noResolveJsonResponse
|
|
@@ -22133,14 +22160,14 @@ var GoTrueAdminApi = class {
|
|
|
22133
22160
|
* This function should only be called on a server. Never expose your `service_role` key in the browser.
|
|
22134
22161
|
*/
|
|
22135
22162
|
async _listOAuthClients(params) {
|
|
22136
|
-
var
|
|
22163
|
+
var _a25, _b3, _c, _d, _e, _f, _g;
|
|
22137
22164
|
try {
|
|
22138
22165
|
const pagination = { nextPage: null, lastPage: 0, total: 0 };
|
|
22139
22166
|
const response = await _request(this.fetch, "GET", `${this.url}/admin/oauth/clients`, {
|
|
22140
22167
|
headers: this.headers,
|
|
22141
22168
|
noResolveJson: true,
|
|
22142
22169
|
query: {
|
|
22143
|
-
page: (_b3 = (
|
|
22170
|
+
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
22171
|
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
22172
|
},
|
|
22146
22173
|
xform: _noResolveJsonResponse
|
|
@@ -22393,7 +22420,7 @@ function toHex(value) {
|
|
|
22393
22420
|
return "0x" + hex;
|
|
22394
22421
|
}
|
|
22395
22422
|
function createSiweMessage(parameters) {
|
|
22396
|
-
var
|
|
22423
|
+
var _a25;
|
|
22397
22424
|
const { chainId, domain, expirationTime, issuedAt = /* @__PURE__ */ new Date(), nonce, notBefore, requestId, resources, scheme, uri, version: version5 } = parameters;
|
|
22398
22425
|
{
|
|
22399
22426
|
if (!Number.isInteger(chainId))
|
|
@@ -22406,7 +22433,7 @@ function createSiweMessage(parameters) {
|
|
|
22406
22433
|
throw new Error(`@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.`);
|
|
22407
22434
|
if (version5 !== "1")
|
|
22408
22435
|
throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${version5}`);
|
|
22409
|
-
if ((
|
|
22436
|
+
if ((_a25 = parameters.statement) === null || _a25 === void 0 ? void 0 : _a25.includes("\n"))
|
|
22410
22437
|
throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${parameters.statement}`);
|
|
22411
22438
|
}
|
|
22412
22439
|
const address = getAddress(parameters.address);
|
|
@@ -22448,10 +22475,10 @@ ${suffix}`;
|
|
|
22448
22475
|
// node_modules/.pnpm/@supabase+auth-js@2.95.1/node_modules/@supabase/auth-js/dist/module/lib/webauthn.errors.js
|
|
22449
22476
|
var WebAuthnError = class extends Error {
|
|
22450
22477
|
constructor({ message, code, cause, name }) {
|
|
22451
|
-
var
|
|
22478
|
+
var _a25;
|
|
22452
22479
|
super(message, { cause });
|
|
22453
22480
|
this.__isWebAuthnError = true;
|
|
22454
|
-
this.name = (
|
|
22481
|
+
this.name = (_a25 = name !== null && name !== void 0 ? name : cause instanceof Error ? cause.name : void 0) !== null && _a25 !== void 0 ? _a25 : "Unknown Error";
|
|
22455
22482
|
this.code = code;
|
|
22456
22483
|
}
|
|
22457
22484
|
};
|
|
@@ -22467,7 +22494,7 @@ var WebAuthnUnknownError = class extends WebAuthnError {
|
|
|
22467
22494
|
}
|
|
22468
22495
|
};
|
|
22469
22496
|
function identifyRegistrationError({ error, options }) {
|
|
22470
|
-
var
|
|
22497
|
+
var _a25, _b3, _c;
|
|
22471
22498
|
const { publicKey } = options;
|
|
22472
22499
|
if (!publicKey) {
|
|
22473
22500
|
throw Error("options was missing required publicKey property");
|
|
@@ -22481,7 +22508,7 @@ function identifyRegistrationError({ error, options }) {
|
|
|
22481
22508
|
});
|
|
22482
22509
|
}
|
|
22483
22510
|
} else if (error.name === "ConstraintError") {
|
|
22484
|
-
if (((
|
|
22511
|
+
if (((_a25 = publicKey.authenticatorSelection) === null || _a25 === void 0 ? void 0 : _a25.requireResidentKey) === true) {
|
|
22485
22512
|
return new WebAuthnError({
|
|
22486
22513
|
message: "Discoverable credentials were required but no available authenticator supported it",
|
|
22487
22514
|
code: "ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",
|
|
@@ -22710,7 +22737,7 @@ function deserializeCredentialRequestOptions(options) {
|
|
|
22710
22737
|
return result;
|
|
22711
22738
|
}
|
|
22712
22739
|
function serializeCredentialCreationResponse(credential) {
|
|
22713
|
-
var
|
|
22740
|
+
var _a25;
|
|
22714
22741
|
if ("toJSON" in credential && typeof credential.toJSON === "function") {
|
|
22715
22742
|
return credential.toJSON();
|
|
22716
22743
|
}
|
|
@@ -22725,11 +22752,11 @@ function serializeCredentialCreationResponse(credential) {
|
|
|
22725
22752
|
type: "public-key",
|
|
22726
22753
|
clientExtensionResults: credential.getClientExtensionResults(),
|
|
22727
22754
|
// Convert null to undefined and cast to AuthenticatorAttachment type
|
|
22728
|
-
authenticatorAttachment: (
|
|
22755
|
+
authenticatorAttachment: (_a25 = credentialWithAttachment.authenticatorAttachment) !== null && _a25 !== void 0 ? _a25 : void 0
|
|
22729
22756
|
};
|
|
22730
22757
|
}
|
|
22731
22758
|
function serializeCredentialRequestResponse(credential) {
|
|
22732
|
-
var
|
|
22759
|
+
var _a25;
|
|
22733
22760
|
if ("toJSON" in credential && typeof credential.toJSON === "function") {
|
|
22734
22761
|
return credential.toJSON();
|
|
22735
22762
|
}
|
|
@@ -22749,7 +22776,7 @@ function serializeCredentialRequestResponse(credential) {
|
|
|
22749
22776
|
type: "public-key",
|
|
22750
22777
|
clientExtensionResults,
|
|
22751
22778
|
// Convert null to undefined and cast to AuthenticatorAttachment type
|
|
22752
|
-
authenticatorAttachment: (
|
|
22779
|
+
authenticatorAttachment: (_a25 = credentialWithAttachment.authenticatorAttachment) !== null && _a25 !== void 0 ? _a25 : void 0
|
|
22753
22780
|
};
|
|
22754
22781
|
}
|
|
22755
22782
|
function isValidDomain(hostname) {
|
|
@@ -22759,8 +22786,8 @@ function isValidDomain(hostname) {
|
|
|
22759
22786
|
);
|
|
22760
22787
|
}
|
|
22761
22788
|
function browserSupportsWebAuthn() {
|
|
22762
|
-
var
|
|
22763
|
-
return !!(isBrowser() && "PublicKeyCredential" in window && window.PublicKeyCredential && "credentials" in navigator && typeof ((
|
|
22789
|
+
var _a25, _b3;
|
|
22790
|
+
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
22791
|
}
|
|
22765
22792
|
async function createCredential(options) {
|
|
22766
22793
|
try {
|
|
@@ -22908,7 +22935,7 @@ var WebAuthnApi = class {
|
|
|
22908
22935
|
* @see {@link https://w3c.github.io/webauthn/#sctn-verifying-assertion W3C WebAuthn Spec - Verifying Assertion}
|
|
22909
22936
|
*/
|
|
22910
22937
|
async _challenge({ factorId, webauthn, friendlyName, signal }, overrides) {
|
|
22911
|
-
var
|
|
22938
|
+
var _a25;
|
|
22912
22939
|
try {
|
|
22913
22940
|
const { data: challengeResponse, error: challengeError } = await this.client.mfa.challenge({
|
|
22914
22941
|
factorId,
|
|
@@ -22925,7 +22952,7 @@ var WebAuthnApi = class {
|
|
|
22925
22952
|
if (!nameToUse) {
|
|
22926
22953
|
const currentUser = await this.client.getUser();
|
|
22927
22954
|
const userData = currentUser.data.user;
|
|
22928
|
-
const fallbackName = ((
|
|
22955
|
+
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
22956
|
user.name = `${user.id}:${fallbackName}`;
|
|
22930
22957
|
} else {
|
|
22931
22958
|
user.name = `${user.id}:${nameToUse}`;
|
|
@@ -23098,8 +23125,8 @@ var WebAuthnApi = class {
|
|
|
23098
23125
|
});
|
|
23099
23126
|
if (!factor) {
|
|
23100
23127
|
await this.client.mfa.listFactors().then((factors) => {
|
|
23101
|
-
var
|
|
23102
|
-
return (
|
|
23128
|
+
var _a25;
|
|
23129
|
+
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
23130
|
}).then((factor2) => factor2 ? this.client.mfa.unenroll({ factorId: factor2 === null || factor2 === void 0 ? void 0 : factor2.id }) : void 0);
|
|
23104
23131
|
return { data: null, error: enrollError };
|
|
23105
23132
|
}
|
|
@@ -23161,15 +23188,15 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23161
23188
|
* The JWKS used for verifying asymmetric JWTs
|
|
23162
23189
|
*/
|
|
23163
23190
|
get jwks() {
|
|
23164
|
-
var
|
|
23165
|
-
return (_b3 = (
|
|
23191
|
+
var _a25, _b3;
|
|
23192
|
+
return (_b3 = (_a25 = GLOBAL_JWKS[this.storageKey]) === null || _a25 === void 0 ? void 0 : _a25.jwks) !== null && _b3 !== void 0 ? _b3 : { keys: [] };
|
|
23166
23193
|
}
|
|
23167
23194
|
set jwks(value) {
|
|
23168
23195
|
GLOBAL_JWKS[this.storageKey] = Object.assign(Object.assign({}, GLOBAL_JWKS[this.storageKey]), { jwks: value });
|
|
23169
23196
|
}
|
|
23170
23197
|
get jwks_cached_at() {
|
|
23171
|
-
var
|
|
23172
|
-
return (_b3 = (
|
|
23198
|
+
var _a25, _b3;
|
|
23199
|
+
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
23200
|
}
|
|
23174
23201
|
set jwks_cached_at(value) {
|
|
23175
23202
|
GLOBAL_JWKS[this.storageKey] = Object.assign(Object.assign({}, GLOBAL_JWKS[this.storageKey]), { cachedAt: value });
|
|
@@ -23189,7 +23216,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23189
23216
|
* ```
|
|
23190
23217
|
*/
|
|
23191
23218
|
constructor(options) {
|
|
23192
|
-
var
|
|
23219
|
+
var _a25, _b3, _c;
|
|
23193
23220
|
this.userStorage = null;
|
|
23194
23221
|
this.memoryStorage = null;
|
|
23195
23222
|
this.stateChangeEmitters = /* @__PURE__ */ new Map();
|
|
@@ -23207,7 +23234,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23207
23234
|
this.logger = console.log;
|
|
23208
23235
|
const settings = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options);
|
|
23209
23236
|
this.storageKey = settings.storageKey;
|
|
23210
|
-
this.instanceID = (
|
|
23237
|
+
this.instanceID = (_a25 = _GoTrueClient.nextInstanceID[this.storageKey]) !== null && _a25 !== void 0 ? _a25 : 0;
|
|
23211
23238
|
_GoTrueClient.nextInstanceID[this.storageKey] = this.instanceID + 1;
|
|
23212
23239
|
this.logDebugMessages = !!settings.debug;
|
|
23213
23240
|
if (typeof settings.debug === "function") {
|
|
@@ -23350,7 +23377,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23350
23377
|
* the whole lifetime of the client
|
|
23351
23378
|
*/
|
|
23352
23379
|
async _initialize() {
|
|
23353
|
-
var
|
|
23380
|
+
var _a25;
|
|
23354
23381
|
try {
|
|
23355
23382
|
let params = {};
|
|
23356
23383
|
let callbackUrlType = "none";
|
|
@@ -23367,7 +23394,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23367
23394
|
if (error) {
|
|
23368
23395
|
this._debug("#_initialize()", "error detecting session from URL", error);
|
|
23369
23396
|
if (isAuthImplicitGrantRedirectError(error)) {
|
|
23370
|
-
const errorCode = (
|
|
23397
|
+
const errorCode = (_a25 = error.details) === null || _a25 === void 0 ? void 0 : _a25.code;
|
|
23371
23398
|
if (errorCode === "identity_already_exists" || errorCode === "identity_not_found" || errorCode === "single_identity_not_deletable") {
|
|
23372
23399
|
return { error };
|
|
23373
23400
|
}
|
|
@@ -23406,12 +23433,12 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23406
23433
|
* @returns A session where the is_anonymous claim in the access token JWT set to true
|
|
23407
23434
|
*/
|
|
23408
23435
|
async signInAnonymously(credentials) {
|
|
23409
|
-
var
|
|
23436
|
+
var _a25, _b3, _c;
|
|
23410
23437
|
try {
|
|
23411
23438
|
const res = await _request(this.fetch, "POST", `${this.url}/signup`, {
|
|
23412
23439
|
headers: this.headers,
|
|
23413
23440
|
body: {
|
|
23414
|
-
data: (_b3 = (
|
|
23441
|
+
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
23442
|
gotrue_meta_security: { captcha_token: (_c = credentials === null || credentials === void 0 ? void 0 : credentials.options) === null || _c === void 0 ? void 0 : _c.captchaToken }
|
|
23416
23443
|
},
|
|
23417
23444
|
xform: _sessionResponse
|
|
@@ -23445,7 +23472,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23445
23472
|
* @returns A user if the server has "autoconfirm" OFF
|
|
23446
23473
|
*/
|
|
23447
23474
|
async signUp(credentials) {
|
|
23448
|
-
var
|
|
23475
|
+
var _a25, _b3, _c;
|
|
23449
23476
|
try {
|
|
23450
23477
|
let res;
|
|
23451
23478
|
if ("email" in credentials) {
|
|
@@ -23462,7 +23489,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23462
23489
|
body: {
|
|
23463
23490
|
email,
|
|
23464
23491
|
password,
|
|
23465
|
-
data: (
|
|
23492
|
+
data: (_a25 = options === null || options === void 0 ? void 0 : options.data) !== null && _a25 !== void 0 ? _a25 : {},
|
|
23466
23493
|
gotrue_meta_security: { captcha_token: options === null || options === void 0 ? void 0 : options.captchaToken },
|
|
23467
23494
|
code_challenge: codeChallenge,
|
|
23468
23495
|
code_challenge_method: codeChallengeMethod
|
|
@@ -23568,9 +23595,9 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23568
23595
|
* This method supports the PKCE flow.
|
|
23569
23596
|
*/
|
|
23570
23597
|
async signInWithOAuth(credentials) {
|
|
23571
|
-
var
|
|
23598
|
+
var _a25, _b3, _c, _d;
|
|
23572
23599
|
return await this._handleProviderSignIn(credentials.provider, {
|
|
23573
|
-
redirectTo: (
|
|
23600
|
+
redirectTo: (_a25 = credentials.options) === null || _a25 === void 0 ? void 0 : _a25.redirectTo,
|
|
23574
23601
|
scopes: (_b3 = credentials.options) === null || _b3 === void 0 ? void 0 : _b3.scopes,
|
|
23575
23602
|
queryParams: (_c = credentials.options) === null || _c === void 0 ? void 0 : _c.queryParams,
|
|
23576
23603
|
skipBrowserRedirect: (_d = credentials.options) === null || _d === void 0 ? void 0 : _d.skipBrowserRedirect
|
|
@@ -23604,7 +23631,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23604
23631
|
}
|
|
23605
23632
|
}
|
|
23606
23633
|
async signInWithEthereum(credentials) {
|
|
23607
|
-
var
|
|
23634
|
+
var _a25, _b3, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
23608
23635
|
let message;
|
|
23609
23636
|
let signature;
|
|
23610
23637
|
if ("message" in credentials) {
|
|
@@ -23628,7 +23655,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23628
23655
|
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
23656
|
}
|
|
23630
23657
|
}
|
|
23631
|
-
const url = new URL((
|
|
23658
|
+
const url = new URL((_a25 = options === null || options === void 0 ? void 0 : options.url) !== null && _a25 !== void 0 ? _a25 : window.location.href);
|
|
23632
23659
|
const accounts = await resolvedWallet.request({
|
|
23633
23660
|
method: "eth_requestAccounts"
|
|
23634
23661
|
}).then((accs) => accs).catch(() => {
|
|
@@ -23695,7 +23722,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23695
23722
|
}
|
|
23696
23723
|
}
|
|
23697
23724
|
async signInWithSolana(credentials) {
|
|
23698
|
-
var
|
|
23725
|
+
var _a25, _b3, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
23699
23726
|
let message;
|
|
23700
23727
|
let signature;
|
|
23701
23728
|
if ("message" in credentials) {
|
|
@@ -23719,7 +23746,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23719
23746
|
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
23747
|
}
|
|
23721
23748
|
}
|
|
23722
|
-
const url = new URL((
|
|
23749
|
+
const url = new URL((_a25 = options === null || options === void 0 ? void 0 : options.url) !== null && _a25 !== void 0 ? _a25 : window.location.href);
|
|
23723
23750
|
if ("signIn" in resolvedWallet && resolvedWallet.signIn) {
|
|
23724
23751
|
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
23752
|
// non-overridable properties
|
|
@@ -23891,7 +23918,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23891
23918
|
* This method supports PKCE when an email is passed.
|
|
23892
23919
|
*/
|
|
23893
23920
|
async signInWithOtp(credentials) {
|
|
23894
|
-
var
|
|
23921
|
+
var _a25, _b3, _c, _d, _e;
|
|
23895
23922
|
try {
|
|
23896
23923
|
if ("email" in credentials) {
|
|
23897
23924
|
const { email, options } = credentials;
|
|
@@ -23905,7 +23932,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23905
23932
|
headers: this.headers,
|
|
23906
23933
|
body: {
|
|
23907
23934
|
email,
|
|
23908
|
-
data: (
|
|
23935
|
+
data: (_a25 = options === null || options === void 0 ? void 0 : options.data) !== null && _a25 !== void 0 ? _a25 : {},
|
|
23909
23936
|
create_user: (_b3 = options === null || options === void 0 ? void 0 : options.shouldCreateUser) !== null && _b3 !== void 0 ? _b3 : true,
|
|
23910
23937
|
gotrue_meta_security: { captcha_token: options === null || options === void 0 ? void 0 : options.captchaToken },
|
|
23911
23938
|
code_challenge: codeChallenge,
|
|
@@ -23945,12 +23972,12 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23945
23972
|
* Log in a user given a User supplied OTP or TokenHash received through mobile or email.
|
|
23946
23973
|
*/
|
|
23947
23974
|
async verifyOtp(params) {
|
|
23948
|
-
var
|
|
23975
|
+
var _a25, _b3;
|
|
23949
23976
|
try {
|
|
23950
23977
|
let redirectTo = void 0;
|
|
23951
23978
|
let captchaToken = void 0;
|
|
23952
23979
|
if ("options" in params) {
|
|
23953
|
-
redirectTo = (
|
|
23980
|
+
redirectTo = (_a25 = params.options) === null || _a25 === void 0 ? void 0 : _a25.redirectTo;
|
|
23954
23981
|
captchaToken = (_b3 = params.options) === null || _b3 === void 0 ? void 0 : _b3.captchaToken;
|
|
23955
23982
|
}
|
|
23956
23983
|
const { data, error } = await _request(this.fetch, "POST", `${this.url}/verify`, {
|
|
@@ -23995,7 +24022,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23995
24022
|
* organization's SSO Identity Provider UUID directly instead.
|
|
23996
24023
|
*/
|
|
23997
24024
|
async signInWithSSO(params) {
|
|
23998
|
-
var
|
|
24025
|
+
var _a25, _b3, _c, _d, _e;
|
|
23999
24026
|
try {
|
|
24000
24027
|
let codeChallenge = null;
|
|
24001
24028
|
let codeChallengeMethod = null;
|
|
@@ -24004,7 +24031,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24004
24031
|
[codeChallenge, codeChallengeMethod] = await getCodeChallengeAndMethod(this.storage, this.storageKey);
|
|
24005
24032
|
}
|
|
24006
24033
|
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 = (
|
|
24034
|
+
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
24035
|
headers: this.headers,
|
|
24009
24036
|
xform: _ssoResponse
|
|
24010
24037
|
});
|
|
@@ -24258,12 +24285,12 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24258
24285
|
});
|
|
24259
24286
|
}
|
|
24260
24287
|
return await this._useSession(async (result) => {
|
|
24261
|
-
var
|
|
24288
|
+
var _a25, _b3, _c;
|
|
24262
24289
|
const { data, error } = result;
|
|
24263
24290
|
if (error) {
|
|
24264
24291
|
throw error;
|
|
24265
24292
|
}
|
|
24266
|
-
if (!((
|
|
24293
|
+
if (!((_a25 = data.session) === null || _a25 === void 0 ? void 0 : _a25.access_token) && !this.hasCustomAuthorizationHeader) {
|
|
24267
24294
|
return { data: { user: null }, error: new AuthSessionMissingError() };
|
|
24268
24295
|
}
|
|
24269
24296
|
return await _request(this.fetch, "GET", `${this.url}/user`, {
|
|
@@ -24405,13 +24432,13 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24405
24432
|
async _refreshSession(currentSession) {
|
|
24406
24433
|
try {
|
|
24407
24434
|
return await this._useSession(async (result) => {
|
|
24408
|
-
var
|
|
24435
|
+
var _a25;
|
|
24409
24436
|
if (!currentSession) {
|
|
24410
24437
|
const { data, error: error2 } = result;
|
|
24411
24438
|
if (error2) {
|
|
24412
24439
|
throw error2;
|
|
24413
24440
|
}
|
|
24414
|
-
currentSession = (
|
|
24441
|
+
currentSession = (_a25 = data.session) !== null && _a25 !== void 0 ? _a25 : void 0;
|
|
24415
24442
|
}
|
|
24416
24443
|
if (!(currentSession === null || currentSession === void 0 ? void 0 : currentSession.refresh_token)) {
|
|
24417
24444
|
throw new AuthSessionMissingError();
|
|
@@ -24549,12 +24576,12 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24549
24576
|
}
|
|
24550
24577
|
async _signOut({ scope } = { scope: "global" }) {
|
|
24551
24578
|
return await this._useSession(async (result) => {
|
|
24552
|
-
var
|
|
24579
|
+
var _a25;
|
|
24553
24580
|
const { data, error: sessionError } = result;
|
|
24554
24581
|
if (sessionError && !isAuthSessionMissingError(sessionError)) {
|
|
24555
24582
|
return this._returnResult({ error: sessionError });
|
|
24556
24583
|
}
|
|
24557
|
-
const accessToken = (
|
|
24584
|
+
const accessToken = (_a25 = data.session) === null || _a25 === void 0 ? void 0 : _a25.access_token;
|
|
24558
24585
|
if (accessToken) {
|
|
24559
24586
|
const { error } = await this.admin.signOut(accessToken, scope);
|
|
24560
24587
|
if (error) {
|
|
@@ -24592,12 +24619,12 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24592
24619
|
}
|
|
24593
24620
|
async _emitInitialSession(id) {
|
|
24594
24621
|
return await this._useSession(async (result) => {
|
|
24595
|
-
var
|
|
24622
|
+
var _a25, _b3;
|
|
24596
24623
|
try {
|
|
24597
24624
|
const { data: { session }, error } = result;
|
|
24598
24625
|
if (error)
|
|
24599
24626
|
throw error;
|
|
24600
|
-
await ((
|
|
24627
|
+
await ((_a25 = this.stateChangeEmitters.get(id)) === null || _a25 === void 0 ? void 0 : _a25.callback("INITIAL_SESSION", session));
|
|
24601
24628
|
this._debug("INITIAL_SESSION", "callback id", id, "session", session);
|
|
24602
24629
|
} catch (err) {
|
|
24603
24630
|
await ((_b3 = this.stateChangeEmitters.get(id)) === null || _b3 === void 0 ? void 0 : _b3.callback("INITIAL_SESSION", null));
|
|
@@ -24648,12 +24675,12 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24648
24675
|
* Gets all the identities linked to a user.
|
|
24649
24676
|
*/
|
|
24650
24677
|
async getUserIdentities() {
|
|
24651
|
-
var
|
|
24678
|
+
var _a25;
|
|
24652
24679
|
try {
|
|
24653
24680
|
const { data, error } = await this.getUser();
|
|
24654
24681
|
if (error)
|
|
24655
24682
|
throw error;
|
|
24656
|
-
return this._returnResult({ data: { identities: (
|
|
24683
|
+
return this._returnResult({ data: { identities: (_a25 = data.user.identities) !== null && _a25 !== void 0 ? _a25 : [] }, error: null });
|
|
24657
24684
|
} catch (error) {
|
|
24658
24685
|
if (isAuthError(error)) {
|
|
24659
24686
|
return this._returnResult({ data: null, error });
|
|
@@ -24668,15 +24695,15 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24668
24695
|
return this.linkIdentityOAuth(credentials);
|
|
24669
24696
|
}
|
|
24670
24697
|
async linkIdentityOAuth(credentials) {
|
|
24671
|
-
var
|
|
24698
|
+
var _a25;
|
|
24672
24699
|
try {
|
|
24673
24700
|
const { data, error } = await this._useSession(async (result) => {
|
|
24674
|
-
var
|
|
24701
|
+
var _a26, _b3, _c, _d, _e;
|
|
24675
24702
|
const { data: data2, error: error2 } = result;
|
|
24676
24703
|
if (error2)
|
|
24677
24704
|
throw error2;
|
|
24678
24705
|
const url = await this._getUrlForProvider(`${this.url}/user/identities/authorize`, credentials.provider, {
|
|
24679
|
-
redirectTo: (
|
|
24706
|
+
redirectTo: (_a26 = credentials.options) === null || _a26 === void 0 ? void 0 : _a26.redirectTo,
|
|
24680
24707
|
scopes: (_b3 = credentials.options) === null || _b3 === void 0 ? void 0 : _b3.scopes,
|
|
24681
24708
|
queryParams: (_c = credentials.options) === null || _c === void 0 ? void 0 : _c.queryParams,
|
|
24682
24709
|
skipBrowserRedirect: true
|
|
@@ -24688,7 +24715,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24688
24715
|
});
|
|
24689
24716
|
if (error)
|
|
24690
24717
|
throw error;
|
|
24691
|
-
if (isBrowser() && !((
|
|
24718
|
+
if (isBrowser() && !((_a25 = credentials.options) === null || _a25 === void 0 ? void 0 : _a25.skipBrowserRedirect)) {
|
|
24692
24719
|
window.location.assign(data === null || data === void 0 ? void 0 : data.url);
|
|
24693
24720
|
}
|
|
24694
24721
|
return this._returnResult({
|
|
@@ -24704,7 +24731,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24704
24731
|
}
|
|
24705
24732
|
async linkIdentityIdToken(credentials) {
|
|
24706
24733
|
return await this._useSession(async (result) => {
|
|
24707
|
-
var
|
|
24734
|
+
var _a25;
|
|
24708
24735
|
try {
|
|
24709
24736
|
const { error: sessionError, data: { session } } = result;
|
|
24710
24737
|
if (sessionError)
|
|
@@ -24712,7 +24739,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24712
24739
|
const { options, provider, token, access_token, nonce } = credentials;
|
|
24713
24740
|
const res = await _request(this.fetch, "POST", `${this.url}/token?grant_type=id_token`, {
|
|
24714
24741
|
headers: this.headers,
|
|
24715
|
-
jwt: (
|
|
24742
|
+
jwt: (_a25 = session === null || session === void 0 ? void 0 : session.access_token) !== null && _a25 !== void 0 ? _a25 : void 0,
|
|
24716
24743
|
body: {
|
|
24717
24744
|
provider,
|
|
24718
24745
|
id_token: token,
|
|
@@ -24752,14 +24779,14 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24752
24779
|
async unlinkIdentity(identity) {
|
|
24753
24780
|
try {
|
|
24754
24781
|
return await this._useSession(async (result) => {
|
|
24755
|
-
var
|
|
24782
|
+
var _a25, _b3;
|
|
24756
24783
|
const { data, error } = result;
|
|
24757
24784
|
if (error) {
|
|
24758
24785
|
throw error;
|
|
24759
24786
|
}
|
|
24760
24787
|
return await _request(this.fetch, "DELETE", `${this.url}/user/identities/${identity.identity_id}`, {
|
|
24761
24788
|
headers: this.headers,
|
|
24762
|
-
jwt: (_b3 = (
|
|
24789
|
+
jwt: (_b3 = (_a25 = data.session) === null || _a25 === void 0 ? void 0 : _a25.access_token) !== null && _b3 !== void 0 ? _b3 : void 0
|
|
24763
24790
|
});
|
|
24764
24791
|
});
|
|
24765
24792
|
} catch (error) {
|
|
@@ -24824,7 +24851,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24824
24851
|
* Note: this method is async to accommodate for AsyncStorage e.g. in React native.
|
|
24825
24852
|
*/
|
|
24826
24853
|
async _recoverAndRefresh() {
|
|
24827
|
-
var
|
|
24854
|
+
var _a25, _b3;
|
|
24828
24855
|
const debugName = "#_recoverAndRefresh()";
|
|
24829
24856
|
this._debug(debugName, "begin");
|
|
24830
24857
|
try {
|
|
@@ -24835,7 +24862,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24835
24862
|
maybeUser = { user: currentSession.user };
|
|
24836
24863
|
await setItemAsync(this.userStorage, this.storageKey + "-user", maybeUser);
|
|
24837
24864
|
}
|
|
24838
|
-
currentSession.user = (
|
|
24865
|
+
currentSession.user = (_a25 = maybeUser === null || maybeUser === void 0 ? void 0 : maybeUser.user) !== null && _a25 !== void 0 ? _a25 : userNotAvailableProxy();
|
|
24839
24866
|
} else if (currentSession && !currentSession.user) {
|
|
24840
24867
|
if (!currentSession.user) {
|
|
24841
24868
|
const separateUser = await getItemAsync(this.storage, this.storageKey + "-user");
|
|
@@ -24895,7 +24922,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24895
24922
|
}
|
|
24896
24923
|
}
|
|
24897
24924
|
async _callRefreshToken(refreshToken) {
|
|
24898
|
-
var
|
|
24925
|
+
var _a25, _b3;
|
|
24899
24926
|
if (!refreshToken) {
|
|
24900
24927
|
throw new AuthSessionMissingError();
|
|
24901
24928
|
}
|
|
@@ -24923,7 +24950,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24923
24950
|
if (!isAuthRetryableFetchError(error)) {
|
|
24924
24951
|
await this._removeSession();
|
|
24925
24952
|
}
|
|
24926
|
-
(
|
|
24953
|
+
(_a25 = this.refreshingDeferred) === null || _a25 === void 0 ? void 0 : _a25.resolve(result);
|
|
24927
24954
|
return result;
|
|
24928
24955
|
}
|
|
24929
24956
|
(_b3 = this.refreshingDeferred) === null || _b3 === void 0 ? void 0 : _b3.reject(error);
|
|
@@ -25218,14 +25245,14 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
25218
25245
|
async _unenroll(params) {
|
|
25219
25246
|
try {
|
|
25220
25247
|
return await this._useSession(async (result) => {
|
|
25221
|
-
var
|
|
25248
|
+
var _a25;
|
|
25222
25249
|
const { data: sessionData, error: sessionError } = result;
|
|
25223
25250
|
if (sessionError) {
|
|
25224
25251
|
return this._returnResult({ data: null, error: sessionError });
|
|
25225
25252
|
}
|
|
25226
25253
|
return await _request(this.fetch, "DELETE", `${this.url}/factors/${params.factorId}`, {
|
|
25227
25254
|
headers: this.headers,
|
|
25228
|
-
jwt: (
|
|
25255
|
+
jwt: (_a25 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a25 === void 0 ? void 0 : _a25.access_token
|
|
25229
25256
|
});
|
|
25230
25257
|
});
|
|
25231
25258
|
} catch (error) {
|
|
@@ -25238,7 +25265,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
25238
25265
|
async _enroll(params) {
|
|
25239
25266
|
try {
|
|
25240
25267
|
return await this._useSession(async (result) => {
|
|
25241
|
-
var
|
|
25268
|
+
var _a25, _b3;
|
|
25242
25269
|
const { data: sessionData, error: sessionError } = result;
|
|
25243
25270
|
if (sessionError) {
|
|
25244
25271
|
return this._returnResult({ data: null, error: sessionError });
|
|
@@ -25247,7 +25274,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
25247
25274
|
const { data, error } = await _request(this.fetch, "POST", `${this.url}/factors`, {
|
|
25248
25275
|
body,
|
|
25249
25276
|
headers: this.headers,
|
|
25250
|
-
jwt: (
|
|
25277
|
+
jwt: (_a25 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a25 === void 0 ? void 0 : _a25.access_token
|
|
25251
25278
|
});
|
|
25252
25279
|
if (error) {
|
|
25253
25280
|
return this._returnResult({ data: null, error });
|
|
@@ -25268,7 +25295,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
25268
25295
|
return this._acquireLock(this.lockAcquireTimeout, async () => {
|
|
25269
25296
|
try {
|
|
25270
25297
|
return await this._useSession(async (result) => {
|
|
25271
|
-
var
|
|
25298
|
+
var _a25;
|
|
25272
25299
|
const { data: sessionData, error: sessionError } = result;
|
|
25273
25300
|
if (sessionError) {
|
|
25274
25301
|
return this._returnResult({ data: null, error: sessionError });
|
|
@@ -25279,7 +25306,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
25279
25306
|
const { data, error } = await _request(this.fetch, "POST", `${this.url}/factors/${params.factorId}/verify`, {
|
|
25280
25307
|
body,
|
|
25281
25308
|
headers: this.headers,
|
|
25282
|
-
jwt: (
|
|
25309
|
+
jwt: (_a25 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a25 === void 0 ? void 0 : _a25.access_token
|
|
25283
25310
|
});
|
|
25284
25311
|
if (error) {
|
|
25285
25312
|
return this._returnResult({ data: null, error });
|
|
@@ -25300,7 +25327,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
25300
25327
|
return this._acquireLock(this.lockAcquireTimeout, async () => {
|
|
25301
25328
|
try {
|
|
25302
25329
|
return await this._useSession(async (result) => {
|
|
25303
|
-
var
|
|
25330
|
+
var _a25;
|
|
25304
25331
|
const { data: sessionData, error: sessionError } = result;
|
|
25305
25332
|
if (sessionError) {
|
|
25306
25333
|
return this._returnResult({ data: null, error: sessionError });
|
|
@@ -25308,7 +25335,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
25308
25335
|
const response = await _request(this.fetch, "POST", `${this.url}/factors/${params.factorId}/challenge`, {
|
|
25309
25336
|
body: params,
|
|
25310
25337
|
headers: this.headers,
|
|
25311
|
-
jwt: (
|
|
25338
|
+
jwt: (_a25 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a25 === void 0 ? void 0 : _a25.access_token
|
|
25312
25339
|
});
|
|
25313
25340
|
if (response.error) {
|
|
25314
25341
|
return response;
|
|
@@ -25358,7 +25385,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
25358
25385
|
* {@see GoTrueMFAApi#listFactors}
|
|
25359
25386
|
*/
|
|
25360
25387
|
async _listFactors() {
|
|
25361
|
-
var
|
|
25388
|
+
var _a25;
|
|
25362
25389
|
const { data: { user }, error: userError } = await this.getUser();
|
|
25363
25390
|
if (userError) {
|
|
25364
25391
|
return { data: null, error: userError };
|
|
@@ -25369,7 +25396,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
25369
25396
|
totp: [],
|
|
25370
25397
|
webauthn: []
|
|
25371
25398
|
};
|
|
25372
|
-
for (const factor of (
|
|
25399
|
+
for (const factor of (_a25 = user === null || user === void 0 ? void 0 : user.factors) !== null && _a25 !== void 0 ? _a25 : []) {
|
|
25373
25400
|
data.all.push(factor);
|
|
25374
25401
|
if (factor.status === "verified") {
|
|
25375
25402
|
;
|
|
@@ -25385,7 +25412,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
25385
25412
|
* {@see GoTrueMFAApi#getAuthenticatorAssuranceLevel}
|
|
25386
25413
|
*/
|
|
25387
25414
|
async _getAuthenticatorAssuranceLevel(jwt) {
|
|
25388
|
-
var
|
|
25415
|
+
var _a25, _b3, _c, _d;
|
|
25389
25416
|
if (jwt) {
|
|
25390
25417
|
try {
|
|
25391
25418
|
const { payload: payload2 } = decodeJWT(jwt);
|
|
@@ -25398,7 +25425,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
25398
25425
|
if (userError) {
|
|
25399
25426
|
return this._returnResult({ data: null, error: userError });
|
|
25400
25427
|
}
|
|
25401
|
-
const verifiedFactors2 = (_b3 = (
|
|
25428
|
+
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
25429
|
if (verifiedFactors2.length > 0) {
|
|
25403
25430
|
nextLevel2 = "aal2";
|
|
25404
25431
|
}
|
|
@@ -26035,10 +26062,10 @@ if (shouldShowDeprecationWarning()) console.warn("\u26A0\uFE0F Node.js 18 and b
|
|
|
26035
26062
|
var cachedStargate = null;
|
|
26036
26063
|
var cachedPublic = null;
|
|
26037
26064
|
function getSupabase() {
|
|
26038
|
-
var
|
|
26065
|
+
var _a25;
|
|
26039
26066
|
if (cachedStargate) return cachedStargate;
|
|
26040
26067
|
const url = getRuntimeEnv("VITE_SUPABASE_URL");
|
|
26041
|
-
const anon = (
|
|
26068
|
+
const anon = (_a25 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a25 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY");
|
|
26042
26069
|
const schema = getRuntimeEnvOr("VITE_SUPABASE_SCHEMA", "public");
|
|
26043
26070
|
if (!url || !anon) {
|
|
26044
26071
|
return null;
|
|
@@ -26053,10 +26080,10 @@ function getSupabase() {
|
|
|
26053
26080
|
return cachedStargate;
|
|
26054
26081
|
}
|
|
26055
26082
|
function getSupabasePublic() {
|
|
26056
|
-
var
|
|
26083
|
+
var _a25;
|
|
26057
26084
|
if (cachedPublic) return cachedPublic;
|
|
26058
26085
|
const url = getRuntimeEnv("VITE_SUPABASE_URL");
|
|
26059
|
-
const anon = (
|
|
26086
|
+
const anon = (_a25 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a25 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY");
|
|
26060
26087
|
if (!url || !anon) {
|
|
26061
26088
|
return null;
|
|
26062
26089
|
}
|
|
@@ -26272,13 +26299,13 @@ var toTimestampMs = (value) => {
|
|
|
26272
26299
|
return Number.isNaN(parsed) ? void 0 : parsed;
|
|
26273
26300
|
};
|
|
26274
26301
|
var readStoredProfileAvatar = () => {
|
|
26275
|
-
var
|
|
26302
|
+
var _a25;
|
|
26276
26303
|
if (typeof window === "undefined") return void 0;
|
|
26277
26304
|
const raw = localStorage.getItem(STORAGE_KEYS.profileAvatar) || sessionStorage.getItem(STORAGE_KEYS.profileAvatar);
|
|
26278
26305
|
if (!raw) return void 0;
|
|
26279
26306
|
try {
|
|
26280
26307
|
const parsed = JSON.parse(raw);
|
|
26281
|
-
return (
|
|
26308
|
+
return (_a25 = toNonEmptyString(parsed.avatarUrl)) != null ? _a25 : toNonEmptyString(parsed.avatarId);
|
|
26282
26309
|
} catch (e) {
|
|
26283
26310
|
return toNonEmptyString(raw);
|
|
26284
26311
|
}
|
|
@@ -26309,8 +26336,8 @@ var readPresenceRow = (payload) => {
|
|
|
26309
26336
|
return null;
|
|
26310
26337
|
};
|
|
26311
26338
|
var isMissingColumnError = (error, column) => {
|
|
26312
|
-
var
|
|
26313
|
-
const message = ((
|
|
26339
|
+
var _a25;
|
|
26340
|
+
const message = ((_a25 = error == null ? void 0 : error.message) != null ? _a25 : "").toLowerCase();
|
|
26314
26341
|
const code = error == null ? void 0 : error.code;
|
|
26315
26342
|
const token = column.trim().toLowerCase();
|
|
26316
26343
|
if (!token) return false;
|
|
@@ -26332,8 +26359,8 @@ var readStoredPresence = () => {
|
|
|
26332
26359
|
return isUserPresenceStatus(stored) ? stored : DEFAULT_PRESENCE_STATUS;
|
|
26333
26360
|
};
|
|
26334
26361
|
var readStoredPresenceSource = () => {
|
|
26335
|
-
var
|
|
26336
|
-
const stored = (
|
|
26362
|
+
var _a25;
|
|
26363
|
+
const stored = (_a25 = sessionStorage.getItem(STORAGE_KEYS.presenceSource)) != null ? _a25 : localStorage.getItem(LOCAL_STORAGE_KEYS.presenceSource);
|
|
26337
26364
|
if (isPresenceSource(stored)) return stored;
|
|
26338
26365
|
return "auto";
|
|
26339
26366
|
};
|
|
@@ -26380,9 +26407,9 @@ var readClaimValue = (claims, keys) => {
|
|
|
26380
26407
|
return void 0;
|
|
26381
26408
|
};
|
|
26382
26409
|
var readClaimRole = (claims) => {
|
|
26383
|
-
var
|
|
26410
|
+
var _a25, _b3, _c;
|
|
26384
26411
|
if (!claims) return void 0;
|
|
26385
|
-
const roleClaim = (_c = (_b3 = (
|
|
26412
|
+
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
26413
|
if (typeof roleClaim === "string") return toNonEmptyString(roleClaim);
|
|
26387
26414
|
if (Array.isArray(roleClaim)) {
|
|
26388
26415
|
return roleClaim.find((entry) => typeof entry === "string" && entry.trim() !== "");
|
|
@@ -26393,7 +26420,7 @@ var buildUserFromTokens = ({
|
|
|
26393
26420
|
idToken,
|
|
26394
26421
|
accessToken
|
|
26395
26422
|
}) => {
|
|
26396
|
-
var
|
|
26423
|
+
var _a25;
|
|
26397
26424
|
const idClaims = decodeJwt(idToken != null ? idToken : void 0);
|
|
26398
26425
|
const accessClaims = decodeJwt(accessToken != null ? accessToken : void 0);
|
|
26399
26426
|
if (!idClaims && !accessClaims) return null;
|
|
@@ -26420,7 +26447,7 @@ var buildUserFromTokens = ({
|
|
|
26420
26447
|
"id",
|
|
26421
26448
|
"sub"
|
|
26422
26449
|
]);
|
|
26423
|
-
const resolvedSub = (
|
|
26450
|
+
const resolvedSub = (_a25 = readFromClaims(["sub"])) != null ? _a25 : resolvedId;
|
|
26424
26451
|
const preferredUsername = readFromClaims([
|
|
26425
26452
|
"preferred_username",
|
|
26426
26453
|
"preferredUsername",
|
|
@@ -26499,11 +26526,11 @@ var AuthProvider = ({ children }) => {
|
|
|
26499
26526
|
}
|
|
26500
26527
|
}, []);
|
|
26501
26528
|
const resolvePresenceUserId = (0, import_react32.useCallback)(async (targetUser) => {
|
|
26502
|
-
var
|
|
26529
|
+
var _a25, _b3, _c, _d;
|
|
26503
26530
|
const sub = toNonEmptyString(targetUser == null ? void 0 : targetUser.sub);
|
|
26504
26531
|
const id = toNonEmptyString(targetUser == null ? void 0 : targetUser.id);
|
|
26505
26532
|
const userId = toNonEmptyString(targetUser == null ? void 0 : targetUser.userId);
|
|
26506
|
-
const email = (
|
|
26533
|
+
const email = (_a25 = toNonEmptyString(targetUser == null ? void 0 : targetUser.email)) == null ? void 0 : _a25.toLowerCase();
|
|
26507
26534
|
const identityKey = [sub != null ? sub : "", id != null ? id : "", userId != null ? userId : "", email != null ? email : ""].join("|");
|
|
26508
26535
|
if (resolvedPresenceIdentityKeyRef.current === identityKey && resolvedPresenceUserIdRef.current) {
|
|
26509
26536
|
return resolvedPresenceUserIdRef.current;
|
|
@@ -26538,9 +26565,9 @@ var AuthProvider = ({ children }) => {
|
|
|
26538
26565
|
}, []);
|
|
26539
26566
|
const syncPresenceFromRecord = (0, import_react32.useCallback)(
|
|
26540
26567
|
(rawRow) => {
|
|
26541
|
-
var
|
|
26568
|
+
var _a25, _b3, _c;
|
|
26542
26569
|
if (!rawRow) return;
|
|
26543
|
-
const statusValue = toNonEmptyString((
|
|
26570
|
+
const statusValue = toNonEmptyString((_a25 = rawRow[USER_PRESENCE_STATUS_COLUMN]) != null ? _a25 : rawRow.status);
|
|
26544
26571
|
if (!isUserPresenceStatus(statusValue)) return;
|
|
26545
26572
|
const sourceValue = normalizePresenceSource((_b3 = rawRow[USER_PRESENCE_SOURCE_COLUMN]) != null ? _b3 : rawRow.status_source);
|
|
26546
26573
|
const lastActiveTimestamp = toTimestampMs((_c = rawRow[USER_PRESENCE_LAST_ACTIVE_COLUMN]) != null ? _c : rawRow.last_active_at);
|
|
@@ -26616,8 +26643,8 @@ var AuthProvider = ({ children }) => {
|
|
|
26616
26643
|
);
|
|
26617
26644
|
const touchPresence = (0, import_react32.useCallback)(
|
|
26618
26645
|
async (options) => {
|
|
26619
|
-
var
|
|
26620
|
-
const targetUser = (
|
|
26646
|
+
var _a25;
|
|
26647
|
+
const targetUser = (_a25 = options == null ? void 0 : options.targetUser) != null ? _a25 : user;
|
|
26621
26648
|
const userId = await resolvePresenceUserId(targetUser);
|
|
26622
26649
|
if (!userId) return;
|
|
26623
26650
|
const now = Date.now();
|
|
@@ -26742,7 +26769,7 @@ var AuthProvider = ({ children }) => {
|
|
|
26742
26769
|
}, []);
|
|
26743
26770
|
const startAuthorization = (0, import_react32.useCallback)(
|
|
26744
26771
|
async (options) => {
|
|
26745
|
-
var
|
|
26772
|
+
var _a25, _b3;
|
|
26746
26773
|
const config = getAccountsConfig();
|
|
26747
26774
|
const { authUrl } = await resolveOidcEndpoints(config);
|
|
26748
26775
|
if (!authUrl) {
|
|
@@ -26752,7 +26779,7 @@ var AuthProvider = ({ children }) => {
|
|
|
26752
26779
|
const challenge = await generateCodeChallenge(verifier);
|
|
26753
26780
|
const state = generateState();
|
|
26754
26781
|
const nonce = generateNonce();
|
|
26755
|
-
const redirectTo = (
|
|
26782
|
+
const redirectTo = (_a25 = options == null ? void 0 : options.redirectTo) != null ? _a25 : window.location.pathname + window.location.search + window.location.hash;
|
|
26756
26783
|
const mode = (_b3 = options == null ? void 0 : options.mode) != null ? _b3 : "interactive";
|
|
26757
26784
|
if (mode === "interactive") {
|
|
26758
26785
|
clearLogoutIntent();
|
|
@@ -26787,14 +26814,14 @@ var AuthProvider = ({ children }) => {
|
|
|
26787
26814
|
(0, import_react32.useEffect)(() => {
|
|
26788
26815
|
let cancelled = false;
|
|
26789
26816
|
const initializeAuth = async () => {
|
|
26790
|
-
var
|
|
26817
|
+
var _a25;
|
|
26791
26818
|
const stored = readStoredToken();
|
|
26792
26819
|
const storedPresence = readStoredPresence();
|
|
26793
26820
|
setPresenceStatusState(storedPresence);
|
|
26794
26821
|
if (stored == null ? void 0 : stored.accessToken) {
|
|
26795
26822
|
if (cancelled) return;
|
|
26796
26823
|
const hydratedUser = buildUserFromTokens({
|
|
26797
|
-
idToken: (
|
|
26824
|
+
idToken: (_a25 = stored.idToken) != null ? _a25 : void 0,
|
|
26798
26825
|
accessToken: stored.accessToken
|
|
26799
26826
|
});
|
|
26800
26827
|
setAccessToken(stored.accessToken);
|
|
@@ -26830,13 +26857,13 @@ var AuthProvider = ({ children }) => {
|
|
|
26830
26857
|
};
|
|
26831
26858
|
}, [attemptSilentLogin]);
|
|
26832
26859
|
(0, import_react32.useEffect)(() => {
|
|
26833
|
-
var
|
|
26860
|
+
var _a25;
|
|
26834
26861
|
if (status !== "authenticated") return;
|
|
26835
26862
|
if (user) return;
|
|
26836
26863
|
const stored = readStoredToken();
|
|
26837
26864
|
if (!(stored == null ? void 0 : stored.accessToken)) return;
|
|
26838
26865
|
const hydratedUser = buildUserFromTokens({
|
|
26839
|
-
idToken: (
|
|
26866
|
+
idToken: (_a25 = stored.idToken) != null ? _a25 : void 0,
|
|
26840
26867
|
accessToken: stored.accessToken
|
|
26841
26868
|
});
|
|
26842
26869
|
if (!hydratedUser) return;
|
|
@@ -26882,9 +26909,9 @@ var AuthProvider = ({ children }) => {
|
|
|
26882
26909
|
table: USER_PRESENCE_TABLE
|
|
26883
26910
|
},
|
|
26884
26911
|
(payload) => {
|
|
26885
|
-
var
|
|
26912
|
+
var _a25, _b3;
|
|
26886
26913
|
const row = payload.new || payload.old;
|
|
26887
|
-
const rowUserId = toNonEmptyString((_b3 = (
|
|
26914
|
+
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
26915
|
if (!rowUserId || rowUserId !== currentUserId) return;
|
|
26889
26916
|
if (payload.eventType === "DELETE") {
|
|
26890
26917
|
storePresenceStatus("offline", "system");
|
|
@@ -26958,9 +26985,9 @@ var AuthProvider = ({ children }) => {
|
|
|
26958
26985
|
});
|
|
26959
26986
|
}, [startAuthorization]);
|
|
26960
26987
|
const completeLogin = (0, import_react32.useCallback)(async () => {
|
|
26961
|
-
var
|
|
26988
|
+
var _a25;
|
|
26962
26989
|
const params = new URLSearchParams(window.location.search);
|
|
26963
|
-
const redirectTo = (
|
|
26990
|
+
const redirectTo = (_a25 = sessionStorage.getItem(STORAGE_KEYS.redirect)) != null ? _a25 : "/";
|
|
26964
26991
|
const authMode = sessionStorage.getItem(STORAGE_KEYS.authMode);
|
|
26965
26992
|
const isSilentAuth = authMode === "silent";
|
|
26966
26993
|
const error = params.get("error");
|
|
@@ -27032,10 +27059,10 @@ var AuthProvider = ({ children }) => {
|
|
|
27032
27059
|
}
|
|
27033
27060
|
}, [clearAuthFlowState]);
|
|
27034
27061
|
const logout = (0, import_react32.useCallback)(async () => {
|
|
27035
|
-
var
|
|
27062
|
+
var _a25, _b3;
|
|
27036
27063
|
const config = getAccountsConfig();
|
|
27037
27064
|
const { logoutUrl } = await resolveOidcEndpoints(config);
|
|
27038
|
-
const idToken = (
|
|
27065
|
+
const idToken = (_a25 = sessionStorage.getItem(STORAGE_KEYS.idToken)) != null ? _a25 : void 0;
|
|
27039
27066
|
const refreshToken = (_b3 = sessionStorage.getItem(STORAGE_KEYS.refreshToken)) != null ? _b3 : void 0;
|
|
27040
27067
|
const currentUser = user;
|
|
27041
27068
|
await setPresenceNetworkStatus("offline", "system", currentUser);
|
|
@@ -27059,8 +27086,8 @@ var AuthProvider = ({ children }) => {
|
|
|
27059
27086
|
return refreshInFlightRef.current;
|
|
27060
27087
|
}
|
|
27061
27088
|
const run = (async () => {
|
|
27062
|
-
var
|
|
27063
|
-
const refreshToken = (
|
|
27089
|
+
var _a25, _b3, _c;
|
|
27090
|
+
const refreshToken = (_a25 = sessionStorage.getItem(STORAGE_KEYS.refreshToken)) == null ? void 0 : _a25.trim();
|
|
27064
27091
|
if (!refreshToken) {
|
|
27065
27092
|
throw new Error("Sess\xE3o expirada. Fa\xE7a login novamente.");
|
|
27066
27093
|
}
|
|
@@ -27093,11 +27120,11 @@ var AuthProvider = ({ children }) => {
|
|
|
27093
27120
|
}
|
|
27094
27121
|
}, []);
|
|
27095
27122
|
const getAccessToken = (0, import_react32.useCallback)(async () => {
|
|
27096
|
-
var
|
|
27123
|
+
var _a25;
|
|
27097
27124
|
const stored = readStoredToken();
|
|
27098
27125
|
if (stored == null ? void 0 : stored.accessToken) return stored.accessToken;
|
|
27099
27126
|
if (accessToken) return accessToken;
|
|
27100
|
-
const hasRefreshToken = Boolean((
|
|
27127
|
+
const hasRefreshToken = Boolean((_a25 = sessionStorage.getItem(STORAGE_KEYS.refreshToken)) == null ? void 0 : _a25.trim());
|
|
27101
27128
|
if (hasRefreshToken) {
|
|
27102
27129
|
return refreshAccessToken();
|
|
27103
27130
|
}
|
|
@@ -27137,65 +27164,6 @@ var useAuth = () => {
|
|
|
27137
27164
|
}
|
|
27138
27165
|
return ctx;
|
|
27139
27166
|
};
|
|
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
27167
|
// Annotate the CommonJS export names for ESM import in node:
|
|
27200
27168
|
0 && (module.exports = {
|
|
27201
27169
|
Accordion,
|
|
@@ -27562,7 +27530,6 @@ globalWithCupcodeEnv.__CUPCODE_ENV__ = {
|
|
|
27562
27530
|
cn,
|
|
27563
27531
|
completeTelescupOidcCallback,
|
|
27564
27532
|
createTelescupClient,
|
|
27565
|
-
cupcodeRuntimeEnv,
|
|
27566
27533
|
decodeJwt,
|
|
27567
27534
|
defaultSidebarGroups,
|
|
27568
27535
|
ensureTelescupOidcToken,
|