@cupcodev/ui 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -13
- package/dist/index.cjs +610 -556
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +606 -556
- package/dist/styles.css +3 -0
- package/package.json +4 -3
package/dist/index.cjs
CHANGED
|
@@ -353,9 +353,13 @@ __export(src_exports, {
|
|
|
353
353
|
buttonVariants: () => buttonVariants,
|
|
354
354
|
cn: () => cn,
|
|
355
355
|
getMainNavItems: () => getMainNavItems,
|
|
356
|
+
getRuntimeEnv: () => getRuntimeEnv,
|
|
357
|
+
getRuntimeEnvOr: () => getRuntimeEnvOr,
|
|
358
|
+
isRuntimeDev: () => isRuntimeDev,
|
|
356
359
|
navigationMenuTriggerStyle: () => navigationMenuTriggerStyle,
|
|
357
360
|
parseAssetId: () => parseAssetId,
|
|
358
361
|
responsiveSizeClasses: () => responsiveSizeClasses,
|
|
362
|
+
setCupcodeRuntimeEnv: () => setCupcodeRuntimeEnv,
|
|
359
363
|
sonnerToast: () => import_sonner.toast,
|
|
360
364
|
toast: () => toast,
|
|
361
365
|
toggleVariants: () => toggleVariants,
|
|
@@ -1077,10 +1081,10 @@ var Dock = ({ items, className }) => {
|
|
|
1077
1081
|
const itemsRef = (0, import_react5.useRef)([]);
|
|
1078
1082
|
const OVERSHOOT = 5;
|
|
1079
1083
|
(0, import_react5.useEffect)(() => {
|
|
1080
|
-
var
|
|
1084
|
+
var _a58;
|
|
1081
1085
|
const activeItem = itemsRef.current[activeIndex];
|
|
1082
1086
|
if (!activeItem) return;
|
|
1083
|
-
const containerRect = (
|
|
1087
|
+
const containerRect = (_a58 = activeItem.parentElement) == null ? void 0 : _a58.getBoundingClientRect();
|
|
1084
1088
|
const itemRect = activeItem.getBoundingClientRect();
|
|
1085
1089
|
if (!containerRect) return;
|
|
1086
1090
|
const relativeLeft = itemRect.left - containerRect.left;
|
|
@@ -1142,9 +1146,9 @@ var Dock = ({ items, className }) => {
|
|
|
1142
1146
|
"button",
|
|
1143
1147
|
{
|
|
1144
1148
|
onClick: () => {
|
|
1145
|
-
var
|
|
1149
|
+
var _a58;
|
|
1146
1150
|
setActiveIndex(index);
|
|
1147
|
-
(
|
|
1151
|
+
(_a58 = item.onClick) == null ? void 0 : _a58.call(item);
|
|
1148
1152
|
},
|
|
1149
1153
|
className: cn(
|
|
1150
1154
|
"flex items-center justify-center w-12 h-12 rounded-xl",
|
|
@@ -1177,9 +1181,62 @@ var import_react7 = require("react");
|
|
|
1177
1181
|
|
|
1178
1182
|
// src/hooks/useTelescupAsset.ts
|
|
1179
1183
|
var import_react6 = require("react");
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
var
|
|
1184
|
+
|
|
1185
|
+
// src/lib/runtimeEnv.ts
|
|
1186
|
+
var runtimeStore = {};
|
|
1187
|
+
var normalizeValue = (value) => {
|
|
1188
|
+
if (value === null || typeof value === "undefined") return void 0;
|
|
1189
|
+
if (typeof value === "string") {
|
|
1190
|
+
const trimmed = value.trim();
|
|
1191
|
+
return trimmed === "" ? void 0 : trimmed;
|
|
1192
|
+
}
|
|
1193
|
+
return String(value);
|
|
1194
|
+
};
|
|
1195
|
+
var setCupcodeRuntimeEnv = (values) => {
|
|
1196
|
+
var _a58;
|
|
1197
|
+
const globalRef = globalThis;
|
|
1198
|
+
const nextGlobalEnv = { ...(_a58 = globalRef.__CUPCODE_ENV__) != null ? _a58 : {} };
|
|
1199
|
+
Object.entries(values).forEach(([key, value]) => {
|
|
1200
|
+
const normalized = normalizeValue(value);
|
|
1201
|
+
runtimeStore[key] = normalized;
|
|
1202
|
+
nextGlobalEnv[key] = normalized;
|
|
1203
|
+
});
|
|
1204
|
+
globalRef.__CUPCODE_ENV__ = nextGlobalEnv;
|
|
1205
|
+
};
|
|
1206
|
+
var readFromProcessEnv = (key) => {
|
|
1207
|
+
var _a58;
|
|
1208
|
+
const processEnv = (_a58 = globalThis.process) == null ? void 0 : _a58.env;
|
|
1209
|
+
return normalizeValue(processEnv == null ? void 0 : processEnv[key]);
|
|
1210
|
+
};
|
|
1211
|
+
var getRuntimeEnv = (key) => {
|
|
1212
|
+
var _a58;
|
|
1213
|
+
const normalizedKey = key.trim();
|
|
1214
|
+
if (!normalizedKey) return void 0;
|
|
1215
|
+
const fromRuntimeStore = runtimeStore[normalizedKey];
|
|
1216
|
+
if (fromRuntimeStore) return fromRuntimeStore;
|
|
1217
|
+
const fromGlobalStore = normalizeValue((_a58 = globalThis.__CUPCODE_ENV__) == null ? void 0 : _a58[normalizedKey]);
|
|
1218
|
+
if (fromGlobalStore) return fromGlobalStore;
|
|
1219
|
+
const fromGlobalKey = normalizeValue(globalThis[normalizedKey]);
|
|
1220
|
+
if (fromGlobalKey) return fromGlobalKey;
|
|
1221
|
+
return readFromProcessEnv(normalizedKey);
|
|
1222
|
+
};
|
|
1223
|
+
var getRuntimeEnvOr = (key, fallback) => {
|
|
1224
|
+
var _a58;
|
|
1225
|
+
return (_a58 = getRuntimeEnv(key)) != null ? _a58 : fallback;
|
|
1226
|
+
};
|
|
1227
|
+
var isRuntimeDev = () => {
|
|
1228
|
+
var _a58, _b5, _c;
|
|
1229
|
+
const explicitDev = (_a58 = getRuntimeEnv("DEV")) != null ? _a58 : getRuntimeEnv("VITE_DEV");
|
|
1230
|
+
if (explicitDev) {
|
|
1231
|
+
const normalized = explicitDev.toLowerCase();
|
|
1232
|
+
return normalized === "1" || normalized === "true";
|
|
1233
|
+
}
|
|
1234
|
+
const mode = ((_c = (_b5 = getRuntimeEnv("MODE")) != null ? _b5 : getRuntimeEnv("NODE_ENV")) != null ? _c : "").toLowerCase();
|
|
1235
|
+
return mode === "development";
|
|
1236
|
+
};
|
|
1237
|
+
|
|
1238
|
+
// src/hooks/useTelescupAsset.ts
|
|
1239
|
+
var getApiBase = () => getRuntimeEnvOr("VITE_TELESCUP_API_BASE", "https://cdn.cupcode.com.br").replace(/\/+$/, "");
|
|
1183
1240
|
function buildTelescupImageURL(options) {
|
|
1184
1241
|
const { id, width, height, fit = "cover", format = "avif", quality = 60 } = options;
|
|
1185
1242
|
const params = new URLSearchParams({ id });
|
|
@@ -1188,10 +1245,10 @@ function buildTelescupImageURL(options) {
|
|
|
1188
1245
|
params.set("fit", fit);
|
|
1189
1246
|
params.set("format", format);
|
|
1190
1247
|
params.set("q", quality.toString());
|
|
1191
|
-
return `${
|
|
1248
|
+
return `${getApiBase()}/i?${params.toString()}`;
|
|
1192
1249
|
}
|
|
1193
1250
|
function buildTelescupVideoURL(id) {
|
|
1194
|
-
return `${
|
|
1251
|
+
return `${getApiBase()}/i/v?id=${id}`;
|
|
1195
1252
|
}
|
|
1196
1253
|
function useTelescupMeta(id, lang = "pt-BR") {
|
|
1197
1254
|
const [meta, setMeta] = (0, import_react6.useState)({});
|
|
@@ -1200,7 +1257,7 @@ function useTelescupMeta(id, lang = "pt-BR") {
|
|
|
1200
1257
|
async function fetchMeta() {
|
|
1201
1258
|
try {
|
|
1202
1259
|
const response = await fetch(
|
|
1203
|
-
`${
|
|
1260
|
+
`${getApiBase()}/i/meta?${new URLSearchParams({ id, lang })}`
|
|
1204
1261
|
);
|
|
1205
1262
|
if (response.ok) {
|
|
1206
1263
|
const data = await response.json();
|
|
@@ -1232,15 +1289,15 @@ var isUuid = (value) => {
|
|
|
1232
1289
|
return UUID_REGEX.test(value.trim());
|
|
1233
1290
|
};
|
|
1234
1291
|
function parseAssetId(input) {
|
|
1235
|
-
var
|
|
1292
|
+
var _a58, _b5, _c, _d;
|
|
1236
1293
|
const raw = input == null ? void 0 : input.trim();
|
|
1237
1294
|
if (!raw) return void 0;
|
|
1238
1295
|
if (UUID_REGEX.test(raw)) return raw;
|
|
1239
|
-
const matchFromRaw = (
|
|
1296
|
+
const matchFromRaw = (_a58 = raw.match(UUID_IN_TEXT_REGEX)) == null ? void 0 : _a58[0];
|
|
1240
1297
|
if (isUuid(matchFromRaw)) return matchFromRaw;
|
|
1241
1298
|
try {
|
|
1242
1299
|
const url = new URL(raw);
|
|
1243
|
-
const queryParamId = (_c = (
|
|
1300
|
+
const queryParamId = (_c = (_b5 = url.searchParams.get("id")) != null ? _b5 : url.searchParams.get("asset_id")) != null ? _c : url.searchParams.get("assetId");
|
|
1244
1301
|
if (isUuid(queryParamId)) return queryParamId;
|
|
1245
1302
|
const matchFromPath = (_d = url.pathname.match(UUID_IN_TEXT_REGEX)) == null ? void 0 : _d[0];
|
|
1246
1303
|
if (isUuid(matchFromPath)) return matchFromPath;
|
|
@@ -1307,7 +1364,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
1307
1364
|
return void 0;
|
|
1308
1365
|
}, [sortedCategories]);
|
|
1309
1366
|
(0, import_react7.useEffect)(() => {
|
|
1310
|
-
var
|
|
1367
|
+
var _a58;
|
|
1311
1368
|
const root = rootRef.current;
|
|
1312
1369
|
if (!root) return;
|
|
1313
1370
|
const $ = (sel) => root.querySelector(sel);
|
|
@@ -1319,7 +1376,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
1319
1376
|
const getDockItems = () => Array.from(root.querySelectorAll(INTERACTIVE_SELECTOR));
|
|
1320
1377
|
const dockItems = getDockItems();
|
|
1321
1378
|
if (!tabbar || !dock || !listMenuShow || !tabbarUl || dockItems.length === 0) return;
|
|
1322
|
-
const persistentId = (
|
|
1379
|
+
const persistentId = (_a58 = activeCategoryId != null ? activeCategoryId : lastInteractiveId) != null ? _a58 : null;
|
|
1323
1380
|
let openItem = null;
|
|
1324
1381
|
let latestToggleToken = null;
|
|
1325
1382
|
const persistentSelector = persistentId != null ? `${INTERACTIVE_SELECTOR}[data-cat-id="${persistentId}"]` : null;
|
|
@@ -1618,8 +1675,8 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
1618
1675
|
}, total);
|
|
1619
1676
|
}
|
|
1620
1677
|
const hideBootstrapTooltip = (el) => {
|
|
1621
|
-
var
|
|
1622
|
-
const tooltip = ((
|
|
1678
|
+
var _a59, _b5;
|
|
1679
|
+
const tooltip = ((_b5 = (_a59 = window.bootstrap) == null ? void 0 : _a59.Tooltip) == null ? void 0 : _b5.getInstance) ? window.bootstrap.Tooltip.getInstance(el) : null;
|
|
1623
1680
|
tooltip == null ? void 0 : tooltip.hide();
|
|
1624
1681
|
};
|
|
1625
1682
|
const openMenuForItem = (item, menu) => {
|
|
@@ -1637,14 +1694,14 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
1637
1694
|
latestToggleToken = null;
|
|
1638
1695
|
};
|
|
1639
1696
|
const closeActiveMenu = (opts = {}) => {
|
|
1640
|
-
var
|
|
1697
|
+
var _a59;
|
|
1641
1698
|
if (!opts.onClosed) {
|
|
1642
1699
|
latestToggleToken = null;
|
|
1643
1700
|
}
|
|
1644
1701
|
const itemToClose = openItem;
|
|
1645
1702
|
if (!itemToClose) {
|
|
1646
1703
|
if (!opts.preserveWrapper) ensurePersistentHighlight();
|
|
1647
|
-
(
|
|
1704
|
+
(_a59 = opts.onClosed) == null ? void 0 : _a59.call(opts);
|
|
1648
1705
|
return;
|
|
1649
1706
|
}
|
|
1650
1707
|
const menu = getMenuFor(itemToClose);
|
|
@@ -1652,7 +1709,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
1652
1709
|
itemToClose.classList.remove("active");
|
|
1653
1710
|
delete itemToClose.dataset.menuOpen;
|
|
1654
1711
|
const finalize = () => {
|
|
1655
|
-
var
|
|
1712
|
+
var _a60;
|
|
1656
1713
|
if (!opts.preserveWrapper) {
|
|
1657
1714
|
listMenuShow.classList.remove("show");
|
|
1658
1715
|
tabbar.classList.remove("is-active-menu");
|
|
@@ -1660,7 +1717,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
1660
1717
|
setTabbarTheme(null);
|
|
1661
1718
|
ensurePersistentHighlight();
|
|
1662
1719
|
}
|
|
1663
|
-
(
|
|
1720
|
+
(_a60 = opts.onClosed) == null ? void 0 : _a60.call(opts);
|
|
1664
1721
|
};
|
|
1665
1722
|
closeMenu(menu, finalize);
|
|
1666
1723
|
};
|
|
@@ -1763,7 +1820,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
1763
1820
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "glass-overlay" }),
|
|
1764
1821
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "glass-specular" }),
|
|
1765
1822
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("ul", { className: "flex-center", children: sortedCategories.map((cat) => {
|
|
1766
|
-
var
|
|
1823
|
+
var _a58;
|
|
1767
1824
|
if (cat.type === "divider") {
|
|
1768
1825
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1769
1826
|
"li",
|
|
@@ -1775,7 +1832,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
1775
1832
|
cat.id
|
|
1776
1833
|
);
|
|
1777
1834
|
}
|
|
1778
|
-
const hasCards = (((
|
|
1835
|
+
const hasCards = (((_a58 = cat.cards) == null ? void 0 : _a58.length) || 0) > 0;
|
|
1779
1836
|
const link = cat.href;
|
|
1780
1837
|
const isCurrent = cat.id === activeCategoryId;
|
|
1781
1838
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
@@ -1809,12 +1866,12 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
1809
1866
|
);
|
|
1810
1867
|
}) }),
|
|
1811
1868
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "list-menu-mob-show", children: sortedCategories.filter((cat) => {
|
|
1812
|
-
var
|
|
1813
|
-
return cat.type !== "divider" && (((
|
|
1869
|
+
var _a58;
|
|
1870
|
+
return cat.type !== "divider" && (((_a58 = cat.cards) == null ? void 0 : _a58.length) || 0) > 0;
|
|
1814
1871
|
}).map((cat) => {
|
|
1815
|
-
var
|
|
1816
|
-
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: ((
|
|
1817
|
-
var
|
|
1872
|
+
var _a58;
|
|
1873
|
+
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: ((_a58 = cat.cards) != null ? _a58 : []).map((card, i) => {
|
|
1874
|
+
var _a59;
|
|
1818
1875
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
1819
1876
|
"div",
|
|
1820
1877
|
{
|
|
@@ -1830,8 +1887,8 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
1830
1887
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "title", children: card.title }),
|
|
1831
1888
|
card.description ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "description", children: card.description }) : null
|
|
1832
1889
|
] }),
|
|
1833
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "actions", children: ((
|
|
1834
|
-
var
|
|
1890
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "actions", children: ((_a59 = card.buttons) != null ? _a59 : []).slice(0, 2).map((btn, idx) => {
|
|
1891
|
+
var _a60, _b5, _c, _d;
|
|
1835
1892
|
const className = idx === 0 ? "saiba-mais" : "saiba-mais-1";
|
|
1836
1893
|
if (btn.type === "popup") {
|
|
1837
1894
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
@@ -1846,7 +1903,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
1846
1903
|
window.dispatchEvent(new Event(`qw:open:${btn.popupId}`));
|
|
1847
1904
|
}
|
|
1848
1905
|
},
|
|
1849
|
-
children: (
|
|
1906
|
+
children: (_a60 = btn.label) != null ? _a60 : "Abrir"
|
|
1850
1907
|
},
|
|
1851
1908
|
`${cat.id}-card-${i}-btn-${idx}`
|
|
1852
1909
|
);
|
|
@@ -1856,7 +1913,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
1856
1913
|
{
|
|
1857
1914
|
href: btn.href || "#",
|
|
1858
1915
|
className,
|
|
1859
|
-
target: ((
|
|
1916
|
+
target: ((_b5 = btn.href) == null ? void 0 : _b5.startsWith("http")) ? "_blank" : void 0,
|
|
1860
1917
|
rel: ((_c = btn.href) == null ? void 0 : _c.startsWith("http")) ? "noopener noreferrer" : void 0,
|
|
1861
1918
|
children: (_d = btn.label) != null ? _d : "Saiba mais >"
|
|
1862
1919
|
},
|
|
@@ -2623,8 +2680,8 @@ var NavbarCupcode = ({
|
|
|
2623
2680
|
isActive && "text-primary after:w-full"
|
|
2624
2681
|
);
|
|
2625
2682
|
const handleClick = (event) => {
|
|
2626
|
-
var
|
|
2627
|
-
(
|
|
2683
|
+
var _a58;
|
|
2684
|
+
(_a58 = item.onClick) == null ? void 0 : _a58.call(item, event);
|
|
2628
2685
|
};
|
|
2629
2686
|
if (item.href.startsWith("#")) {
|
|
2630
2687
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
@@ -2676,8 +2733,8 @@ var NavbarCupcode = ({
|
|
|
2676
2733
|
isActive && "text-primary"
|
|
2677
2734
|
);
|
|
2678
2735
|
const handleClick = (event) => {
|
|
2679
|
-
var
|
|
2680
|
-
(
|
|
2736
|
+
var _a58;
|
|
2737
|
+
(_a58 = item.onClick) == null ? void 0 : _a58.call(item, event);
|
|
2681
2738
|
setIsOpen(false);
|
|
2682
2739
|
};
|
|
2683
2740
|
if (item.href.startsWith("#")) {
|
|
@@ -2751,10 +2808,10 @@ function isThemeMode(value) {
|
|
|
2751
2808
|
return value === "light" || value === "dark";
|
|
2752
2809
|
}
|
|
2753
2810
|
function readStoredTheme() {
|
|
2754
|
-
var
|
|
2811
|
+
var _a58;
|
|
2755
2812
|
if (typeof window === "undefined") return null;
|
|
2756
2813
|
try {
|
|
2757
|
-
const storedTheme = (
|
|
2814
|
+
const storedTheme = (_a58 = window.localStorage.getItem(THEME_STORAGE_KEY)) != null ? _a58 : window.localStorage.getItem("theme");
|
|
2758
2815
|
return isThemeMode(storedTheme) ? storedTheme : null;
|
|
2759
2816
|
} catch (e) {
|
|
2760
2817
|
return null;
|
|
@@ -2791,11 +2848,11 @@ var ThemeToggle = ({
|
|
|
2791
2848
|
defaultTheme = "light",
|
|
2792
2849
|
onThemeChange
|
|
2793
2850
|
}) => {
|
|
2794
|
-
var
|
|
2851
|
+
var _a58;
|
|
2795
2852
|
const [mounted, setMounted] = React11.useState(false);
|
|
2796
2853
|
const [internalTheme, setInternalTheme] = React11.useState(defaultTheme);
|
|
2797
2854
|
const isControlled = typeof theme !== "undefined";
|
|
2798
|
-
const activeTheme = (
|
|
2855
|
+
const activeTheme = (_a58 = isControlled ? theme : internalTheme) != null ? _a58 : defaultTheme;
|
|
2799
2856
|
React11.useEffect(() => {
|
|
2800
2857
|
if (!isControlled) {
|
|
2801
2858
|
setInternalTheme(resolveTheme(defaultTheme));
|
|
@@ -3462,7 +3519,6 @@ function useToast() {
|
|
|
3462
3519
|
var import_react17 = __toESM(require("react"), 1);
|
|
3463
3520
|
|
|
3464
3521
|
// src/lib/telescupClient.ts
|
|
3465
|
-
var import_meta2 = {};
|
|
3466
3522
|
var TelescupClientError = class extends Error {
|
|
3467
3523
|
constructor(message, opts) {
|
|
3468
3524
|
super(message);
|
|
@@ -3477,39 +3533,39 @@ var TelescupClientError = class extends Error {
|
|
|
3477
3533
|
};
|
|
3478
3534
|
var normalizeBaseUrl = (baseUrl) => baseUrl.replace(/\/+$/, "");
|
|
3479
3535
|
var joinUrl = (base, path) => path.startsWith("/") ? `${base}${path}` : `${base}/${path}`;
|
|
3480
|
-
var
|
|
3481
|
-
var SUPABASE_URL = (
|
|
3482
|
-
var
|
|
3483
|
-
var SUPABASE_ANON_KEY = (_b = (
|
|
3536
|
+
var _a;
|
|
3537
|
+
var SUPABASE_URL = (_a = getRuntimeEnv("VITE_SUPABASE_URL")) == null ? void 0 : _a.trim();
|
|
3538
|
+
var _a2, _b;
|
|
3539
|
+
var SUPABASE_ANON_KEY = (_b = (_a2 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a2 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY")) == null ? void 0 : _b.trim();
|
|
3484
3540
|
var SUPABASE_URL_NORMALIZED = SUPABASE_URL ? normalizeBaseUrl(SUPABASE_URL) : void 0;
|
|
3485
3541
|
var DEV_REST_PROXY_BASE_URL = "/rest/v1";
|
|
3486
3542
|
var UUID_REGEX2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
3487
|
-
var
|
|
3488
|
-
var TELESCUP_MANAGER_FIRST = ((_b2 = (
|
|
3543
|
+
var _a3, _b2;
|
|
3544
|
+
var TELESCUP_MANAGER_FIRST = ((_b2 = (_a3 = getRuntimeEnv("VITE_TELESCUP_MANAGER_FIRST")) == null ? void 0 : _a3.trim().toLowerCase()) != null ? _b2 : "true") !== "false";
|
|
3545
|
+
var _a4;
|
|
3546
|
+
var TELESCUP_LIST_FUNCTION = ((_a4 = getRuntimeEnv("VITE_TELESCUP_LIST_FUNCTION")) == null ? void 0 : _a4.trim()) || "telescup-assets-list";
|
|
3489
3547
|
var _a5;
|
|
3490
|
-
var
|
|
3548
|
+
var TELESCUP_UPLOAD_INIT_FUNCTION = ((_a5 = getRuntimeEnv("VITE_TELESCUP_UPLOAD_INIT_FUNCTION")) == null ? void 0 : _a5.trim()) || "telescup-upload-init";
|
|
3491
3549
|
var _a6;
|
|
3492
|
-
var
|
|
3550
|
+
var TELESCUP_UPLOAD_COMPLETE_FUNCTION = ((_a6 = getRuntimeEnv("VITE_TELESCUP_UPLOAD_COMPLETE_FUNCTION")) == null ? void 0 : _a6.trim()) || "telescup-upload-complete";
|
|
3493
3551
|
var _a7;
|
|
3494
|
-
var
|
|
3552
|
+
var TELESCUP_UPDATE_META_FUNCTION = ((_a7 = getRuntimeEnv("VITE_TELESCUP_UPDATE_META_FUNCTION")) == null ? void 0 : _a7.trim()) || "telescup-assets-update-meta";
|
|
3495
3553
|
var _a8;
|
|
3496
|
-
var
|
|
3554
|
+
var TELESCUP_UPLOAD_DIRECT_FUNCTION = ((_a8 = getRuntimeEnv("VITE_TELESCUP_UPLOAD_DIRECT_FUNCTION")) == null ? void 0 : _a8.trim()) || "asset-api/upload";
|
|
3497
3555
|
var _a9;
|
|
3498
|
-
var
|
|
3499
|
-
var _a10;
|
|
3500
|
-
var
|
|
3501
|
-
var _a11
|
|
3502
|
-
var
|
|
3503
|
-
var _a12;
|
|
3504
|
-
var TELESCUP_ASSET_API_FACET_SEED_LIMIT_RAW = Number((_a12 = import_meta2.env.VITE_TELESCUP_FACET_SEED_LIMIT) != null ? _a12 : "120");
|
|
3556
|
+
var TELESCUP_SEARCH_DEFAULT_QUERY = ((_a9 = getRuntimeEnv("VITE_TELESCUP_SEARCH_DEFAULT_QUERY")) == null ? void 0 : _a9.trim()) || "images";
|
|
3557
|
+
var _a10, _b3;
|
|
3558
|
+
var TELESCUP_PREFER_RPC = ((_b3 = (_a10 = getRuntimeEnv("VITE_TELESCUP_PREFER_RPC")) == null ? void 0 : _a10.trim().toLowerCase()) != null ? _b3 : "false") === "true";
|
|
3559
|
+
var _a11;
|
|
3560
|
+
var TELESCUP_ASSET_API_FACET_SEED_LIMIT_RAW = Number((_a11 = getRuntimeEnv("VITE_TELESCUP_FACET_SEED_LIMIT")) != null ? _a11 : "120");
|
|
3505
3561
|
var TELESCUP_ASSET_API_FACET_SEED_LIMIT = Math.min(
|
|
3506
3562
|
500,
|
|
3507
3563
|
Math.max(50, Number.isFinite(TELESCUP_ASSET_API_FACET_SEED_LIMIT_RAW) ? Math.floor(TELESCUP_ASSET_API_FACET_SEED_LIMIT_RAW) : 120)
|
|
3508
3564
|
);
|
|
3565
|
+
var _a12;
|
|
3566
|
+
var TELESCUP_DB_SCHEMA = ((_a12 = getRuntimeEnv("VITE_TELESCUP_SCHEMA")) != null ? _a12 : "telescup").trim() || "telescup";
|
|
3509
3567
|
var _a13;
|
|
3510
|
-
var
|
|
3511
|
-
var _a14;
|
|
3512
|
-
var TELESCUP_RPC_SCHEMA = ((_a14 = import_meta2.env.VITE_TELESCUP_RPC_SCHEMA) != null ? _a14 : TELESCUP_DB_SCHEMA).trim() || TELESCUP_DB_SCHEMA;
|
|
3568
|
+
var TELESCUP_RPC_SCHEMA = ((_a13 = getRuntimeEnv("VITE_TELESCUP_RPC_SCHEMA")) != null ? _a13 : TELESCUP_DB_SCHEMA).trim() || TELESCUP_DB_SCHEMA;
|
|
3513
3569
|
var TELESCUP_DB_PROFILES = [TELESCUP_DB_SCHEMA];
|
|
3514
3570
|
var TELESCUP_TABLE_FACET_LIMIT = 1e3;
|
|
3515
3571
|
var TELESCUP_DENIED_TABLE_CACHE = /* @__PURE__ */ new Set();
|
|
@@ -3609,12 +3665,12 @@ var rpcPreferredSchema = TELESCUP_RPC_SCHEMA;
|
|
|
3609
3665
|
var RPC_MISSING_SCHEMAS_BY_PATH = /* @__PURE__ */ new Map();
|
|
3610
3666
|
var FUNCTION_NOT_FOUND_CACHE = /* @__PURE__ */ new Set();
|
|
3611
3667
|
var buildRestHeaders = (token, options) => {
|
|
3612
|
-
var
|
|
3668
|
+
var _a58;
|
|
3613
3669
|
const headers = {};
|
|
3614
3670
|
if (SUPABASE_ANON_KEY) {
|
|
3615
3671
|
headers.apikey = SUPABASE_ANON_KEY;
|
|
3616
3672
|
}
|
|
3617
|
-
const authorizationToken = (
|
|
3673
|
+
const authorizationToken = (_a58 = resolveRpcAuthorizationToken(token)) != null ? _a58 : token;
|
|
3618
3674
|
if (authorizationToken) {
|
|
3619
3675
|
headers.Authorization = `Bearer ${authorizationToken}`;
|
|
3620
3676
|
}
|
|
@@ -3632,7 +3688,7 @@ var buildRestHeaders = (token, options) => {
|
|
|
3632
3688
|
};
|
|
3633
3689
|
var resolveRpcBaseUrl = (baseUrl) => {
|
|
3634
3690
|
const functionsBaseUrl = resolveFunctionsBaseUrl(baseUrl);
|
|
3635
|
-
if (
|
|
3691
|
+
if (isRuntimeDev() && functionsBaseUrl.startsWith("/functions/v1")) {
|
|
3636
3692
|
return DEV_REST_PROXY_BASE_URL;
|
|
3637
3693
|
}
|
|
3638
3694
|
if (SUPABASE_URL) {
|
|
@@ -3749,22 +3805,22 @@ var parseAssetSize = (value) => {
|
|
|
3749
3805
|
return Number.isFinite(parsed) ? parsed : void 0;
|
|
3750
3806
|
};
|
|
3751
3807
|
var getFileExtension = (filename) => {
|
|
3752
|
-
var
|
|
3808
|
+
var _a58;
|
|
3753
3809
|
if (!filename) return void 0;
|
|
3754
3810
|
const parts = filename.split(".");
|
|
3755
3811
|
if (parts.length < 2) return void 0;
|
|
3756
|
-
const candidate = (
|
|
3812
|
+
const candidate = (_a58 = parts[parts.length - 1]) == null ? void 0 : _a58.trim().toLowerCase();
|
|
3757
3813
|
return candidate || void 0;
|
|
3758
3814
|
};
|
|
3759
3815
|
var resolveCategory = (row, activeMeta) => {
|
|
3760
|
-
var
|
|
3761
|
-
return (
|
|
3816
|
+
var _a58;
|
|
3817
|
+
return (_a58 = readString(row.category)) != null ? _a58 : readString(activeMeta.category);
|
|
3762
3818
|
};
|
|
3763
3819
|
var resolveFolderName = (row) => readString(row.folder_name);
|
|
3764
3820
|
var toTelescupAsset = (row, selectedLanguage) => {
|
|
3765
|
-
var
|
|
3821
|
+
var _a58, _b5, _c, _d, _e;
|
|
3766
3822
|
const metaByLang = normalizeMetaByLanguage(row.meta);
|
|
3767
|
-
const activeMeta = (
|
|
3823
|
+
const activeMeta = (_b5 = (_a58 = metaByLang[selectedLanguage]) != null ? _a58 : metaByLang.pt) != null ? _b5 : {};
|
|
3768
3824
|
return {
|
|
3769
3825
|
id: (_c = row.id) != null ? _c : "",
|
|
3770
3826
|
name: row.filename,
|
|
@@ -3790,14 +3846,14 @@ var buildFacetsFromItems = (items) => {
|
|
|
3790
3846
|
const extensions = /* @__PURE__ */ new Map();
|
|
3791
3847
|
const tags = /* @__PURE__ */ new Map();
|
|
3792
3848
|
items.forEach((item) => {
|
|
3793
|
-
var
|
|
3849
|
+
var _a58, _b5, _c, _d, _e, _f, _g;
|
|
3794
3850
|
if (item.category) {
|
|
3795
|
-
categories.set(item.category, ((
|
|
3851
|
+
categories.set(item.category, ((_a58 = categories.get(item.category)) != null ? _a58 : 0) + 1);
|
|
3796
3852
|
}
|
|
3797
3853
|
if (item.folderId) {
|
|
3798
3854
|
const current = folders.get(item.folderId);
|
|
3799
3855
|
folders.set(item.folderId, {
|
|
3800
|
-
label: (
|
|
3856
|
+
label: (_b5 = item.folderName) != null ? _b5 : current == null ? void 0 : current.label,
|
|
3801
3857
|
count: ((_c = current == null ? void 0 : current.count) != null ? _c : 0) + 1
|
|
3802
3858
|
});
|
|
3803
3859
|
}
|
|
@@ -3808,16 +3864,16 @@ var buildFacetsFromItems = (items) => {
|
|
|
3808
3864
|
extensions.set(item.extension, ((_e = extensions.get(item.extension)) != null ? _e : 0) + 1);
|
|
3809
3865
|
}
|
|
3810
3866
|
(_g = (_f = item.meta) == null ? void 0 : _f.tags) == null ? void 0 : _g.forEach((tag) => {
|
|
3811
|
-
var
|
|
3867
|
+
var _a59;
|
|
3812
3868
|
const normalizedTag = tag.trim();
|
|
3813
3869
|
if (!normalizedTag) return;
|
|
3814
|
-
tags.set(normalizedTag, ((
|
|
3870
|
+
tags.set(normalizedTag, ((_a59 = tags.get(normalizedTag)) != null ? _a59 : 0) + 1);
|
|
3815
3871
|
});
|
|
3816
3872
|
});
|
|
3817
3873
|
const toFacetValues = (map) => Array.from(map.entries()).map(([value, count2]) => ({ value, count: count2 })).sort((a, b) => a.value.localeCompare(b.value));
|
|
3818
3874
|
const toFolderFacetValues = (map) => Array.from(map.entries()).map(([value, info]) => ({ value, label: info.label, count: info.count })).sort((a, b) => {
|
|
3819
|
-
var
|
|
3820
|
-
return ((
|
|
3875
|
+
var _a58, _b5;
|
|
3876
|
+
return ((_a58 = a.label) != null ? _a58 : a.value).localeCompare((_b5 = b.label) != null ? _b5 : b.value);
|
|
3821
3877
|
});
|
|
3822
3878
|
return {
|
|
3823
3879
|
categories: toFacetValues(categories),
|
|
@@ -3835,7 +3891,7 @@ var isManagerScopeRetryable = (error) => {
|
|
|
3835
3891
|
return /permission|not allowed|wrong key type|insufficient|unauthorized/i.test(detailsText);
|
|
3836
3892
|
};
|
|
3837
3893
|
async function listAssetsViaRpc(config, filters) {
|
|
3838
|
-
var
|
|
3894
|
+
var _a58, _b5, _c, _d, _e, _f, _g, _h, _i;
|
|
3839
3895
|
if (!SUPABASE_ANON_KEY) {
|
|
3840
3896
|
throw new TelescupClientError(
|
|
3841
3897
|
"VITE_SUPABASE_ANON_KEY (ou VITE_SUPABASE_PUBLISHABLE_KEY) n\xE3o encontrado para fallback RPC do Telescup."
|
|
@@ -3855,11 +3911,11 @@ async function listAssetsViaRpc(config, filters) {
|
|
|
3855
3911
|
}
|
|
3856
3912
|
const shouldLoadFacetTables = isSupabaseAccessToken(token);
|
|
3857
3913
|
const pageSize = Math.min(100, Math.max(1, toPositiveInt(filters.pageSize, 24)));
|
|
3858
|
-
const page = toPositiveInt((
|
|
3914
|
+
const page = toPositiveInt((_a58 = filters.cursor) != null ? _a58 : filters.page, 1);
|
|
3859
3915
|
const selectedLanguage = normalizeLanguageKey(filters.language);
|
|
3860
3916
|
const bodyBase = {
|
|
3861
3917
|
p_user_id: userId,
|
|
3862
|
-
p_query: (
|
|
3918
|
+
p_query: (_b5 = filters.query) != null ? _b5 : null,
|
|
3863
3919
|
p_page: page,
|
|
3864
3920
|
p_page_size: pageSize,
|
|
3865
3921
|
p_type: filters.type && filters.type !== "all" ? filters.type : null,
|
|
@@ -3955,13 +4011,13 @@ var getRpcSchemaCandidates = (rpcPath) => {
|
|
|
3955
4011
|
return filtered.length ? filtered : ordered;
|
|
3956
4012
|
};
|
|
3957
4013
|
var markRpcSchemaMissing = (rpcPath, schema) => {
|
|
3958
|
-
var
|
|
3959
|
-
const set = (
|
|
4014
|
+
var _a58;
|
|
4015
|
+
const set = (_a58 = RPC_MISSING_SCHEMAS_BY_PATH.get(rpcPath)) != null ? _a58 : /* @__PURE__ */ new Set();
|
|
3960
4016
|
set.add(schema);
|
|
3961
4017
|
RPC_MISSING_SCHEMAS_BY_PATH.set(rpcPath, set);
|
|
3962
4018
|
};
|
|
3963
4019
|
async function requestRpc(config, rpcPath, payload) {
|
|
3964
|
-
var
|
|
4020
|
+
var _a58, _b5;
|
|
3965
4021
|
if (!SUPABASE_ANON_KEY) {
|
|
3966
4022
|
throw new TelescupClientError(
|
|
3967
4023
|
"VITE_SUPABASE_ANON_KEY (ou VITE_SUPABASE_PUBLISHABLE_KEY) n\xE3o encontrado para fallback RPC do Telescup."
|
|
@@ -4004,7 +4060,7 @@ async function requestRpc(config, rpcPath, payload) {
|
|
|
4004
4060
|
throw new TelescupClientError(`Falha de rede ao chamar RPC ${rpcPath}.`, { details: error });
|
|
4005
4061
|
}
|
|
4006
4062
|
if (response.ok) {
|
|
4007
|
-
const contentType = (
|
|
4063
|
+
const contentType = (_a58 = response.headers.get("content-type")) != null ? _a58 : "";
|
|
4008
4064
|
if (!contentType.includes("application/json")) {
|
|
4009
4065
|
const text = await response.text();
|
|
4010
4066
|
if (!text) return {};
|
|
@@ -4026,7 +4082,7 @@ async function requestRpc(config, rpcPath, payload) {
|
|
|
4026
4082
|
responsePayload = await response.text();
|
|
4027
4083
|
}
|
|
4028
4084
|
const payloadObject = responsePayload != null ? responsePayload : {};
|
|
4029
|
-
const message = typeof responsePayload === "string" ? responsePayload : (
|
|
4085
|
+
const message = typeof responsePayload === "string" ? responsePayload : (_b5 = payloadObject.message) != null ? _b5 : `Erro ao chamar RPC ${schema}.${rpcPath} (${response.status}).`;
|
|
4030
4086
|
const rpcError = new TelescupClientError(message, {
|
|
4031
4087
|
status: response.status,
|
|
4032
4088
|
code: payloadObject.code,
|
|
@@ -4056,7 +4112,7 @@ async function requestRpc(config, rpcPath, payload) {
|
|
|
4056
4112
|
throw new TelescupClientError(`Falha ao chamar RPC ${rpcPath}.`);
|
|
4057
4113
|
}
|
|
4058
4114
|
var toTelescupError = async (response, fallbackMessage) => {
|
|
4059
|
-
var
|
|
4115
|
+
var _a58;
|
|
4060
4116
|
let payload = void 0;
|
|
4061
4117
|
try {
|
|
4062
4118
|
payload = await response.json();
|
|
@@ -4064,7 +4120,7 @@ var toTelescupError = async (response, fallbackMessage) => {
|
|
|
4064
4120
|
payload = await response.text();
|
|
4065
4121
|
}
|
|
4066
4122
|
const payloadObject = payload != null ? payload : {};
|
|
4067
|
-
const message = typeof payload === "string" ? payload : (
|
|
4123
|
+
const message = typeof payload === "string" ? payload : (_a58 = payloadObject.message) != null ? _a58 : `${fallbackMessage} (${response.status}).`;
|
|
4068
4124
|
return new TelescupClientError(message, {
|
|
4069
4125
|
status: response.status,
|
|
4070
4126
|
code: payloadObject.code,
|
|
@@ -4112,11 +4168,11 @@ var mergeFacetEntries = (current, incoming) => {
|
|
|
4112
4168
|
const map = /* @__PURE__ */ new Map();
|
|
4113
4169
|
current == null ? void 0 : current.forEach((entry) => map.set(entry.value, entry));
|
|
4114
4170
|
incoming == null ? void 0 : incoming.forEach((entry) => {
|
|
4115
|
-
var
|
|
4171
|
+
var _a58, _b5, _c;
|
|
4116
4172
|
const previous = map.get(entry.value);
|
|
4117
4173
|
map.set(entry.value, {
|
|
4118
4174
|
value: entry.value,
|
|
4119
|
-
label: (
|
|
4175
|
+
label: (_b5 = (_a58 = entry.label) != null ? _a58 : previous == null ? void 0 : previous.label) != null ? _b5 : entry.value,
|
|
4120
4176
|
count: (_c = entry.count) != null ? _c : previous == null ? void 0 : previous.count
|
|
4121
4177
|
});
|
|
4122
4178
|
});
|
|
@@ -4136,10 +4192,10 @@ var mergeFacets = (base, incoming) => {
|
|
|
4136
4192
|
var toFacetEntriesFromRows = (rows, valueKeys, labelKeys) => {
|
|
4137
4193
|
const result = /* @__PURE__ */ new Map();
|
|
4138
4194
|
rows.forEach((row) => {
|
|
4139
|
-
var
|
|
4195
|
+
var _a58;
|
|
4140
4196
|
const value = readFirstString(row, valueKeys);
|
|
4141
4197
|
if (!value) return;
|
|
4142
|
-
const label = (
|
|
4198
|
+
const label = (_a58 = readFirstString(row, labelKeys)) != null ? _a58 : value;
|
|
4143
4199
|
result.set(value, { value, label });
|
|
4144
4200
|
});
|
|
4145
4201
|
return Array.from(result.values()).sort((a, b) => a.label.localeCompare(b.label));
|
|
@@ -4198,7 +4254,7 @@ async function loadFacetsFromTelescupTables(config) {
|
|
|
4198
4254
|
};
|
|
4199
4255
|
}
|
|
4200
4256
|
async function request(config, path, options = {}) {
|
|
4201
|
-
var
|
|
4257
|
+
var _a58, _b5, _c;
|
|
4202
4258
|
const token = await config.getAccessToken();
|
|
4203
4259
|
if (!token) {
|
|
4204
4260
|
throw new TelescupClientError("Token de acesso n\xE3o encontrado.");
|
|
@@ -4206,7 +4262,7 @@ async function request(config, path, options = {}) {
|
|
|
4206
4262
|
const functionsBaseUrl = resolveFunctionsBaseUrl(config.baseUrl);
|
|
4207
4263
|
const url = joinUrl(functionsBaseUrl, path);
|
|
4208
4264
|
const isAssetApiRoute = path.startsWith("asset-api/");
|
|
4209
|
-
const authorizationToken = isAssetApiRoute ? (
|
|
4265
|
+
const authorizationToken = isAssetApiRoute ? (_a58 = resolveRpcAuthorizationToken(token)) != null ? _a58 : token : token;
|
|
4210
4266
|
const headers = {
|
|
4211
4267
|
Authorization: `Bearer ${authorizationToken}`,
|
|
4212
4268
|
...options.headers
|
|
@@ -4222,7 +4278,7 @@ async function request(config, path, options = {}) {
|
|
|
4222
4278
|
let response;
|
|
4223
4279
|
try {
|
|
4224
4280
|
response = await fetch(url, {
|
|
4225
|
-
method: (
|
|
4281
|
+
method: (_b5 = options.method) != null ? _b5 : "POST",
|
|
4226
4282
|
headers,
|
|
4227
4283
|
body
|
|
4228
4284
|
});
|
|
@@ -4256,11 +4312,11 @@ var normalizeFunctionLanguage = (value) => {
|
|
|
4256
4312
|
return normalized;
|
|
4257
4313
|
};
|
|
4258
4314
|
var toFunctionListPayload = (filters) => {
|
|
4259
|
-
var
|
|
4260
|
-
const page = toPositiveInt((
|
|
4315
|
+
var _a58, _b5, _c, _d, _e, _f;
|
|
4316
|
+
const page = toPositiveInt((_a58 = filters.cursor) != null ? _a58 : filters.page, 1);
|
|
4261
4317
|
const pageSize = Math.min(500, Math.max(1, toPositiveInt(filters.pageSize, 24)));
|
|
4262
4318
|
return {
|
|
4263
|
-
query: (
|
|
4319
|
+
query: (_b5 = filters.query) != null ? _b5 : "",
|
|
4264
4320
|
page,
|
|
4265
4321
|
pageSize,
|
|
4266
4322
|
sort: `${normalizeSortBy(filters.sort)}:${filters.order === "asc" ? "asc" : "desc"}`,
|
|
@@ -4295,8 +4351,8 @@ var toFolderPath = (value) => {
|
|
|
4295
4351
|
return normalized.slice(0, lastSlash);
|
|
4296
4352
|
};
|
|
4297
4353
|
var normalizeFilterText = (value) => {
|
|
4298
|
-
var
|
|
4299
|
-
return (
|
|
4354
|
+
var _a58;
|
|
4355
|
+
return (_a58 = value == null ? void 0 : value.trim().toLowerCase()) != null ? _a58 : "";
|
|
4300
4356
|
};
|
|
4301
4357
|
var normalizeExtensionFilter = (value) => {
|
|
4302
4358
|
const normalized = normalizeFilterText(value);
|
|
@@ -4310,16 +4366,16 @@ var normalizeFolderFilter = (value) => {
|
|
|
4310
4366
|
var sortAssets = (items, sort, order) => {
|
|
4311
4367
|
const direction = order === "asc" ? 1 : -1;
|
|
4312
4368
|
const byName = (a, b) => {
|
|
4313
|
-
var
|
|
4314
|
-
return ((
|
|
4369
|
+
var _a58, _b5, _c, _d;
|
|
4370
|
+
return ((_b5 = (_a58 = a.fileName) != null ? _a58 : a.name) != null ? _b5 : "").localeCompare((_d = (_c = b.fileName) != null ? _c : b.name) != null ? _d : "");
|
|
4315
4371
|
};
|
|
4316
4372
|
const byDate = (a, b, key) => {
|
|
4317
|
-
var
|
|
4318
|
-
return (Date.parse((
|
|
4373
|
+
var _a58, _b5;
|
|
4374
|
+
return (Date.parse((_a58 = a[key]) != null ? _a58 : "") || 0) - (Date.parse((_b5 = b[key]) != null ? _b5 : "") || 0);
|
|
4319
4375
|
};
|
|
4320
4376
|
const bySize = (a, b) => {
|
|
4321
|
-
var
|
|
4322
|
-
return ((
|
|
4377
|
+
var _a58, _b5;
|
|
4378
|
+
return ((_a58 = a.size) != null ? _a58 : 0) - ((_b5 = b.size) != null ? _b5 : 0);
|
|
4323
4379
|
};
|
|
4324
4380
|
const sorted = [...items];
|
|
4325
4381
|
sorted.sort((a, b) => {
|
|
@@ -4354,7 +4410,7 @@ var applyAssetApiSearchFilters = (items, filters) => {
|
|
|
4354
4410
|
const folderFilter = normalizeFolderFilter(filters.folderId);
|
|
4355
4411
|
const requireAlt = filters.hasAlt === true;
|
|
4356
4412
|
return items.filter((asset) => {
|
|
4357
|
-
var
|
|
4413
|
+
var _a58, _b5, _c, _d, _e, _f, _g, _h, _i;
|
|
4358
4414
|
const haystack = [
|
|
4359
4415
|
asset.id,
|
|
4360
4416
|
asset.name,
|
|
@@ -4363,8 +4419,8 @@ var applyAssetApiSearchFilters = (items, filters) => {
|
|
|
4363
4419
|
asset.folderName,
|
|
4364
4420
|
asset.category,
|
|
4365
4421
|
asset.usage,
|
|
4366
|
-
(
|
|
4367
|
-
(
|
|
4422
|
+
(_a58 = asset.meta) == null ? void 0 : _a58.title,
|
|
4423
|
+
(_b5 = asset.meta) == null ? void 0 : _b5.description,
|
|
4368
4424
|
(_c = asset.meta) == null ? void 0 : _c.alt,
|
|
4369
4425
|
...Array.isArray((_d = asset.meta) == null ? void 0 : _d.tags) ? asset.meta.tags : []
|
|
4370
4426
|
].filter((value) => typeof value === "string" && value.trim() !== "").join(" ").toLowerCase();
|
|
@@ -4383,15 +4439,15 @@ var applyAssetApiSearchFilters = (items, filters) => {
|
|
|
4383
4439
|
});
|
|
4384
4440
|
};
|
|
4385
4441
|
var mapAssetApiSearchRowToAsset = (row) => {
|
|
4386
|
-
var
|
|
4442
|
+
var _a58, _b5, _c, _d;
|
|
4387
4443
|
const id = readFirstString(row, ["asset_id", "id"]);
|
|
4388
4444
|
if (!id) return null;
|
|
4389
|
-
const fileName = (
|
|
4445
|
+
const fileName = (_a58 = readFirstString(row, ["original_filename", "filename", "title"])) != null ? _a58 : readFirstString(row, ["file_path"]);
|
|
4390
4446
|
const mimeType = readFirstString(row, ["mime_type", "mime"]);
|
|
4391
4447
|
const extension = getFileExtension(readFirstString(row, ["file_path", "filename", "original_filename"]));
|
|
4392
4448
|
const tags = Array.isArray(row.tags) ? row.tags.filter((item) => typeof item === "string") : void 0;
|
|
4393
4449
|
const categories = readStringArray(row.categories);
|
|
4394
|
-
const category = (
|
|
4450
|
+
const category = (_b5 = readFirstString(row, ["category"])) != null ? _b5 : categories[0];
|
|
4395
4451
|
const alt = readFirstString(row, ["alt_text"]);
|
|
4396
4452
|
const title = readFirstString(row, ["title"]);
|
|
4397
4453
|
const description = readFirstString(row, ["description"]);
|
|
@@ -4434,14 +4490,14 @@ var mapAssetApiSearchRowToAsset = (row) => {
|
|
|
4434
4490
|
};
|
|
4435
4491
|
};
|
|
4436
4492
|
async function listAssetsViaAssetApiSearch(config, filters) {
|
|
4437
|
-
var
|
|
4493
|
+
var _a58, _b5;
|
|
4438
4494
|
const pageSize = Math.min(500, Math.max(1, toPositiveInt(filters.pageSize, 24)));
|
|
4439
|
-
const page = toPositiveInt((
|
|
4495
|
+
const page = toPositiveInt((_a58 = filters.cursor) != null ? _a58 : filters.page, 1);
|
|
4440
4496
|
const hasActiveFacetFilter = Boolean(filters.type && filters.type !== "all") || Boolean(filters.extension) || Boolean(filters.category) || Boolean(filters.folderId) || Boolean(filters.usage) || filters.hasAlt === true;
|
|
4441
4497
|
const baseLimit = page * pageSize + 1;
|
|
4442
4498
|
const seedLimit = hasActiveFacetFilter ? baseLimit : Math.max(baseLimit, TELESCUP_ASSET_API_FACET_SEED_LIMIT);
|
|
4443
4499
|
const limit = Math.min(500, seedLimit);
|
|
4444
|
-
const query = ((
|
|
4500
|
+
const query = ((_b5 = filters.query) != null ? _b5 : "").trim() || TELESCUP_SEARCH_DEFAULT_QUERY;
|
|
4445
4501
|
const [pathBase, rawQuery] = TELESCUP_LIST_FUNCTION.split("?");
|
|
4446
4502
|
const params = new URLSearchParams(rawQuery != null ? rawQuery : "");
|
|
4447
4503
|
params.set("q", query);
|
|
@@ -4465,12 +4521,12 @@ async function listAssetsViaAssetApiSearch(config, filters) {
|
|
|
4465
4521
|
};
|
|
4466
4522
|
}
|
|
4467
4523
|
var mapGenericRowToAsset = (row) => {
|
|
4468
|
-
var
|
|
4469
|
-
const id = (
|
|
4524
|
+
var _a58, _b5;
|
|
4525
|
+
const id = (_a58 = readFirstString(row, ["asset_id", "id", "file_id", "uuid"])) != null ? _a58 : typeof row.id === "number" ? String(row.id) : void 0;
|
|
4470
4526
|
if (!id) return null;
|
|
4471
4527
|
const fileName = readFirstString(row, ["filename", "file_name", "name", "title", "original_name"]);
|
|
4472
4528
|
const mimeType = readFirstString(row, ["mime", "mime_type", "content_type", "file_mime"]);
|
|
4473
|
-
const extension = (
|
|
4529
|
+
const extension = (_b5 = readFirstString(row, ["extension", "ext"])) != null ? _b5 : getFileExtension(fileName);
|
|
4474
4530
|
return {
|
|
4475
4531
|
id,
|
|
4476
4532
|
name: fileName,
|
|
@@ -4488,16 +4544,16 @@ var mapGenericRowToAsset = (row) => {
|
|
|
4488
4544
|
};
|
|
4489
4545
|
};
|
|
4490
4546
|
var normalizeListResponseFromFunctions = (response, filters) => {
|
|
4491
|
-
var
|
|
4547
|
+
var _a58, _b5, _c, _d, _e, _f;
|
|
4492
4548
|
const payload = response != null ? response : {};
|
|
4493
4549
|
const itemsRaw = Array.isArray(payload.items) ? payload.items : [];
|
|
4494
4550
|
const selectedLanguage = normalizeLanguageKey(filters.language);
|
|
4495
4551
|
const items = itemsRaw.map((row) => {
|
|
4496
|
-
var
|
|
4552
|
+
var _a59, _b6, _c2;
|
|
4497
4553
|
const mapped = mapGenericRowToAsset(row);
|
|
4498
4554
|
if (!mapped) return null;
|
|
4499
4555
|
const metaByLang = normalizeMetaByLanguage(row.meta);
|
|
4500
|
-
const activeMeta = (
|
|
4556
|
+
const activeMeta = (_b6 = (_a59 = metaByLang[selectedLanguage]) != null ? _a59 : metaByLang.pt) != null ? _b6 : {};
|
|
4501
4557
|
const usageFromObject = readUsageContext(row.usage);
|
|
4502
4558
|
const normalized = {
|
|
4503
4559
|
...mapped,
|
|
@@ -4509,7 +4565,7 @@ var normalizeListResponseFromFunctions = (response, filters) => {
|
|
|
4509
4565
|
};
|
|
4510
4566
|
return normalized;
|
|
4511
4567
|
}).filter((item) => item !== null);
|
|
4512
|
-
const total = (_c = (
|
|
4568
|
+
const total = (_c = (_b5 = (_a58 = readNumber(payload.total)) != null ? _a58 : readNumber(payload.totalCount)) != null ? _b5 : readNumber(payload.total_count)) != null ? _c : items.length;
|
|
4513
4569
|
const page = toPositiveInt((_e = (_d = payload.page) != null ? _d : filters.cursor) != null ? _e : filters.page, 1);
|
|
4514
4570
|
const pageSize = Math.min(100, Math.max(1, toPositiveInt((_f = payload.pageSize) != null ? _f : filters.pageSize, 24)));
|
|
4515
4571
|
const nextCursor = total > page * pageSize ? String(page + 1) : void 0;
|
|
@@ -4529,13 +4585,13 @@ var mapConflictForQueue = (value) => {
|
|
|
4529
4585
|
return "conflict";
|
|
4530
4586
|
};
|
|
4531
4587
|
var toInitPayloadForFunctions = (payload) => {
|
|
4532
|
-
var
|
|
4588
|
+
var _a58, _b5;
|
|
4533
4589
|
return {
|
|
4534
4590
|
filename: payload.fileName,
|
|
4535
4591
|
size: payload.size,
|
|
4536
4592
|
mime: payload.mimeType,
|
|
4537
|
-
folder_id: (
|
|
4538
|
-
overwritePolicy: (
|
|
4593
|
+
folder_id: (_a58 = payload.folderId) != null ? _a58 : null,
|
|
4594
|
+
overwritePolicy: (_b5 = payload.conflict) != null ? _b5 : "ask",
|
|
4539
4595
|
fileName: payload.fileName,
|
|
4540
4596
|
mimeType: payload.mimeType,
|
|
4541
4597
|
folderId: payload.folderId,
|
|
@@ -4543,10 +4599,10 @@ var toInitPayloadForFunctions = (payload) => {
|
|
|
4543
4599
|
};
|
|
4544
4600
|
};
|
|
4545
4601
|
var normalizeInitResponseFromFunctions = (response) => {
|
|
4546
|
-
var
|
|
4602
|
+
var _a58, _b5, _c, _d, _e, _f, _g;
|
|
4547
4603
|
const payload = response != null ? response : {};
|
|
4548
|
-
const existingRaw = (
|
|
4549
|
-
const existingAsset = existingRaw ? (
|
|
4604
|
+
const existingRaw = (_a58 = payload.existingAsset) != null ? _a58 : payload.existing_asset;
|
|
4605
|
+
const existingAsset = existingRaw ? (_b5 = mapGenericRowToAsset(existingRaw)) != null ? _b5 : void 0 : void 0;
|
|
4550
4606
|
const assetRaw = payload.asset;
|
|
4551
4607
|
const asset = assetRaw ? (_c = mapGenericRowToAsset(assetRaw)) != null ? _c : void 0 : void 0;
|
|
4552
4608
|
const conflictSource = (_e = readString(payload.conflict)) != null ? _e : readString((_d = payload.conflict) == null ? void 0 : _d.type);
|
|
@@ -4567,12 +4623,12 @@ var normalizeInitResponseFromFunctions = (response) => {
|
|
|
4567
4623
|
};
|
|
4568
4624
|
};
|
|
4569
4625
|
var toCompletePayloadForFunctions = (payload) => {
|
|
4570
|
-
var
|
|
4626
|
+
var _a58, _b5, _c;
|
|
4571
4627
|
return {
|
|
4572
4628
|
uploadId: payload.uploadId,
|
|
4573
|
-
assetDraftId: (
|
|
4629
|
+
assetDraftId: (_a58 = payload.assetDraftId) != null ? _a58 : payload.assetId,
|
|
4574
4630
|
storageKey: payload.storageKey,
|
|
4575
|
-
finalFilename: (
|
|
4631
|
+
finalFilename: (_b5 = payload.finalFilename) != null ? _b5 : payload.fileName,
|
|
4576
4632
|
folder_id: (_c = payload.folderId) != null ? _c : null,
|
|
4577
4633
|
upload_id: payload.uploadId,
|
|
4578
4634
|
asset_id: payload.assetId,
|
|
@@ -4580,21 +4636,21 @@ var toCompletePayloadForFunctions = (payload) => {
|
|
|
4580
4636
|
};
|
|
4581
4637
|
};
|
|
4582
4638
|
var normalizeCompleteResponseFromFunctions = (response) => {
|
|
4583
|
-
var
|
|
4639
|
+
var _a58, _b5;
|
|
4584
4640
|
const payload = response != null ? response : {};
|
|
4585
|
-
const assetRaw = (
|
|
4641
|
+
const assetRaw = (_a58 = payload.asset) != null ? _a58 : payload;
|
|
4586
4642
|
const mapped = mapGenericRowToAsset(assetRaw);
|
|
4587
4643
|
if (mapped) return { asset: mapped };
|
|
4588
|
-
const assetId = (
|
|
4644
|
+
const assetId = (_b5 = readFirstString(assetRaw, ["id", "asset_id"])) != null ? _b5 : readFirstString(payload, ["assetId", "asset_id"]);
|
|
4589
4645
|
if (!assetId) {
|
|
4590
4646
|
throw new TelescupClientError("Resposta inv\xE1lida ao finalizar upload no Telescup.");
|
|
4591
4647
|
}
|
|
4592
4648
|
return { asset: { id: assetId } };
|
|
4593
4649
|
};
|
|
4594
4650
|
var toMetaPayloadForFunctions = (payload) => {
|
|
4595
|
-
var
|
|
4651
|
+
var _a58, _b5;
|
|
4596
4652
|
if (TELESCUP_UPDATE_META_FUNCTION === "update-asset-meta") {
|
|
4597
|
-
const categories = ((
|
|
4653
|
+
const categories = ((_a58 = payload.meta) == null ? void 0 : _a58.category) ? [payload.meta.category] : [];
|
|
4598
4654
|
return {
|
|
4599
4655
|
asset_id: payload.assetId,
|
|
4600
4656
|
categories
|
|
@@ -4609,7 +4665,7 @@ var toMetaPayloadForFunctions = (payload) => {
|
|
|
4609
4665
|
en: {},
|
|
4610
4666
|
es: {}
|
|
4611
4667
|
};
|
|
4612
|
-
const target = (
|
|
4668
|
+
const target = (_b5 = byLanguage[language]) != null ? _b5 : byLanguage.pt;
|
|
4613
4669
|
if (payload.meta) {
|
|
4614
4670
|
if (typeof payload.meta.alt === "string") target.alt = payload.meta.alt;
|
|
4615
4671
|
if (typeof payload.meta.title === "string") target.title = payload.meta.title;
|
|
@@ -4705,7 +4761,7 @@ var createTelescupClient = (config) => ({
|
|
|
4705
4761
|
body: toMetaPayloadForFunctions(payload)
|
|
4706
4762
|
}),
|
|
4707
4763
|
uploadDirect: async (file) => {
|
|
4708
|
-
var
|
|
4764
|
+
var _a58;
|
|
4709
4765
|
const token = await config.getAccessToken();
|
|
4710
4766
|
const userId = resolveUserIdFromToken(token);
|
|
4711
4767
|
if (!userId) {
|
|
@@ -4733,7 +4789,7 @@ var createTelescupClient = (config) => ({
|
|
|
4733
4789
|
}
|
|
4734
4790
|
});
|
|
4735
4791
|
const payload = response != null ? response : {};
|
|
4736
|
-
const asset = mapAssetApiSearchRowToAsset((
|
|
4792
|
+
const asset = mapAssetApiSearchRowToAsset((_a58 = payload.asset) != null ? _a58 : {});
|
|
4737
4793
|
if (!asset) {
|
|
4738
4794
|
throw new TelescupClientError("Resposta inv\xE1lida do upload direto (asset-api).");
|
|
4739
4795
|
}
|
|
@@ -4805,9 +4861,9 @@ function useTelescupAssets(options) {
|
|
|
4805
4861
|
...sanitizeFilters(filters),
|
|
4806
4862
|
pageSize
|
|
4807
4863
|
}).then((data) => {
|
|
4808
|
-
var
|
|
4864
|
+
var _a58;
|
|
4809
4865
|
return {
|
|
4810
|
-
items: (
|
|
4866
|
+
items: (_a58 = data.items) != null ? _a58 : [],
|
|
4811
4867
|
nextCursor: data.nextCursor,
|
|
4812
4868
|
total: data.total,
|
|
4813
4869
|
facets: data.facets
|
|
@@ -4830,7 +4886,7 @@ function useTelescupAssets(options) {
|
|
|
4830
4886
|
[cacheKey, cacheTimeMs, enabled, filters, pageSize, resolvedClient]
|
|
4831
4887
|
);
|
|
4832
4888
|
const loadMore = (0, import_react13.useCallback)(async () => {
|
|
4833
|
-
var
|
|
4889
|
+
var _a58, _b5, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
4834
4890
|
if (!state.nextCursor || isLoadingMore || isLoading) return;
|
|
4835
4891
|
const requestSeq = requestSeqRef.current;
|
|
4836
4892
|
setIsLoadingMore(true);
|
|
@@ -4844,9 +4900,9 @@ function useTelescupAssets(options) {
|
|
|
4844
4900
|
});
|
|
4845
4901
|
if (!aliveRef.current || requestSeq !== requestSeqRef.current) return;
|
|
4846
4902
|
const merged = {
|
|
4847
|
-
items: [...state.items, ...(
|
|
4903
|
+
items: [...state.items, ...(_a58 = data.items) != null ? _a58 : []],
|
|
4848
4904
|
nextCursor: data.nextCursor,
|
|
4849
|
-
total: (
|
|
4905
|
+
total: (_b5 = data.total) != null ? _b5 : state.total,
|
|
4850
4906
|
facets: {
|
|
4851
4907
|
categories: (_d = (_c = data.facets) == null ? void 0 : _c.categories) != null ? _d : previousFacets == null ? void 0 : previousFacets.categories,
|
|
4852
4908
|
folders: (_f = (_e = data.facets) == null ? void 0 : _e.folders) != null ? _f : previousFacets == null ? void 0 : previousFacets.folders,
|
|
@@ -4995,12 +5051,12 @@ var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "we
|
|
|
4995
5051
|
var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set(["mp4", "mov", "webm", "mkv", "avi", "m4v", "wmv"]);
|
|
4996
5052
|
var AUDIO_EXTENSIONS = /* @__PURE__ */ new Set(["mp3", "wav", "aac", "ogg", "flac", "m4a"]);
|
|
4997
5053
|
var resolveAssetFamily = (asset) => {
|
|
4998
|
-
var
|
|
4999
|
-
const explicitType = (
|
|
5054
|
+
var _a58, _b5, _c;
|
|
5055
|
+
const explicitType = (_a58 = asset.type) == null ? void 0 : _a58.toLowerCase();
|
|
5000
5056
|
if (explicitType === "image" || explicitType === "video" || explicitType === "audio" || explicitType === "file") {
|
|
5001
5057
|
return explicitType;
|
|
5002
5058
|
}
|
|
5003
|
-
const mime = (
|
|
5059
|
+
const mime = (_b5 = asset.mimeType) == null ? void 0 : _b5.toLowerCase();
|
|
5004
5060
|
if (mime == null ? void 0 : mime.startsWith("image/")) return "image";
|
|
5005
5061
|
if (mime == null ? void 0 : mime.startsWith("video/")) return "video";
|
|
5006
5062
|
if (mime == null ? void 0 : mime.startsWith("audio/")) return "audio";
|
|
@@ -5012,9 +5068,9 @@ var resolveAssetFamily = (asset) => {
|
|
|
5012
5068
|
return "file";
|
|
5013
5069
|
};
|
|
5014
5070
|
var matchesAllowedAsset = (asset, allowed) => {
|
|
5015
|
-
var
|
|
5071
|
+
var _a58, _b5, _c, _d;
|
|
5016
5072
|
if (!allowed || allowed.length === 0) return true;
|
|
5017
|
-
const mime = (
|
|
5073
|
+
const mime = (_b5 = (_a58 = asset.mimeType) == null ? void 0 : _a58.toLowerCase()) != null ? _b5 : "";
|
|
5018
5074
|
const ext = asset.extension ? `.${asset.extension.toLowerCase()}` : "";
|
|
5019
5075
|
const type = (_d = (_c = asset.type) == null ? void 0 : _c.toLowerCase()) != null ? _d : "";
|
|
5020
5076
|
const family = resolveAssetFamily(asset);
|
|
@@ -5060,12 +5116,12 @@ var getPreview = (asset) => {
|
|
|
5060
5116
|
var normalizeFacetOptions = (entries) => {
|
|
5061
5117
|
if (!entries || !entries.length) return [];
|
|
5062
5118
|
return entries.reduce((acc, entry) => {
|
|
5063
|
-
var
|
|
5064
|
-
const value = (
|
|
5119
|
+
var _a58, _b5;
|
|
5120
|
+
const value = (_a58 = entry.value) == null ? void 0 : _a58.trim();
|
|
5065
5121
|
if (!value) return acc;
|
|
5066
5122
|
acc.push({
|
|
5067
5123
|
value,
|
|
5068
|
-
label: ((
|
|
5124
|
+
label: ((_b5 = entry.label) == null ? void 0 : _b5.trim()) || value,
|
|
5069
5125
|
count: typeof entry.count === "number" ? entry.count : void 0
|
|
5070
5126
|
});
|
|
5071
5127
|
return acc;
|
|
@@ -5074,13 +5130,13 @@ var normalizeFacetOptions = (entries) => {
|
|
|
5074
5130
|
var collectFacetOptions = (items, pick, pickLabel) => {
|
|
5075
5131
|
const options = /* @__PURE__ */ new Map();
|
|
5076
5132
|
items.forEach((asset) => {
|
|
5077
|
-
var
|
|
5078
|
-
const value = (
|
|
5133
|
+
var _a58, _b5, _c;
|
|
5134
|
+
const value = (_a58 = pick(asset)) == null ? void 0 : _a58.trim();
|
|
5079
5135
|
if (!value) return;
|
|
5080
5136
|
const current = options.get(value);
|
|
5081
5137
|
options.set(value, {
|
|
5082
5138
|
value,
|
|
5083
|
-
label: ((
|
|
5139
|
+
label: ((_b5 = pickLabel == null ? void 0 : pickLabel(asset)) == null ? void 0 : _b5.trim()) || (current == null ? void 0 : current.label) || value,
|
|
5084
5140
|
count: ((_c = current == null ? void 0 : current.count) != null ? _c : 0) + 1
|
|
5085
5141
|
});
|
|
5086
5142
|
});
|
|
@@ -5229,10 +5285,8 @@ var import_react16 = require("react");
|
|
|
5229
5285
|
|
|
5230
5286
|
// src/hooks/useTelescupUploadQueue.tsx
|
|
5231
5287
|
var import_react15 = require("react");
|
|
5232
|
-
var import_meta3 = {};
|
|
5233
5288
|
var DEFAULT_CONCURRENCY = 3;
|
|
5234
|
-
var
|
|
5235
|
-
var TELESCUP_UPLOAD_MODE = (_b4 = (_a15 = import_meta3.env.VITE_TELESCUP_UPLOAD_MODE) == null ? void 0 : _a15.trim().toLowerCase()) != null ? _b4 : "standard";
|
|
5289
|
+
var TELESCUP_UPLOAD_MODE = getRuntimeEnvOr("VITE_TELESCUP_UPLOAD_MODE", "standard").trim().toLowerCase();
|
|
5236
5290
|
var makeId = () => Math.random().toString(36).slice(2, 10);
|
|
5237
5291
|
var matchesAllowedType = (file, allowed) => {
|
|
5238
5292
|
if (!allowed || allowed.length === 0) return true;
|
|
@@ -5337,7 +5391,7 @@ function useTelescupUploadQueue(options) {
|
|
|
5337
5391
|
activeRef.current += 1;
|
|
5338
5392
|
updateItem(next.id, { status: "uploading", progress: 0, error: void 0 });
|
|
5339
5393
|
const run = async () => {
|
|
5340
|
-
var
|
|
5394
|
+
var _a58, _b5, _c;
|
|
5341
5395
|
try {
|
|
5342
5396
|
if (TELESCUP_UPLOAD_MODE === "direct") {
|
|
5343
5397
|
const completed2 = await client.uploadDirect(next.file);
|
|
@@ -5356,7 +5410,7 @@ function useTelescupUploadQueue(options) {
|
|
|
5356
5410
|
size: next.file.size,
|
|
5357
5411
|
mimeType: next.file.type,
|
|
5358
5412
|
folderId,
|
|
5359
|
-
conflict: (
|
|
5413
|
+
conflict: (_a58 = next.conflictPolicy) != null ? _a58 : conflictPolicy
|
|
5360
5414
|
});
|
|
5361
5415
|
const conflictDetected = init.conflict === "ask" || init.conflict === "conflict" || init.conflict === "exists" || init.existingAsset && !init.uploadUrl;
|
|
5362
5416
|
if (conflictDetected) {
|
|
@@ -5395,7 +5449,7 @@ function useTelescupUploadQueue(options) {
|
|
|
5395
5449
|
storageKey: init.storageKey,
|
|
5396
5450
|
finalFilename: init.finalFilename,
|
|
5397
5451
|
folderId,
|
|
5398
|
-
assetId: (
|
|
5452
|
+
assetId: (_b5 = init.asset) == null ? void 0 : _b5.id,
|
|
5399
5453
|
fileName: (_c = init.resolvedName) != null ? _c : next.file.name
|
|
5400
5454
|
});
|
|
5401
5455
|
updateItem(next.id, {
|
|
@@ -5494,7 +5548,7 @@ var TelescupUploader = ({
|
|
|
5494
5548
|
className,
|
|
5495
5549
|
onAssetUploaded
|
|
5496
5550
|
}) => {
|
|
5497
|
-
var
|
|
5551
|
+
var _a58;
|
|
5498
5552
|
const inputRef = (0, import_react16.useRef)(null);
|
|
5499
5553
|
const [dragActive, setDragActive] = (0, import_react16.useState)(false);
|
|
5500
5554
|
const {
|
|
@@ -5561,8 +5615,8 @@ var TelescupUploader = ({
|
|
|
5561
5615
|
size: "sm",
|
|
5562
5616
|
variant: "secondary",
|
|
5563
5617
|
onClick: () => {
|
|
5564
|
-
var
|
|
5565
|
-
return (
|
|
5618
|
+
var _a59;
|
|
5619
|
+
return (_a59 = inputRef.current) == null ? void 0 : _a59.click();
|
|
5566
5620
|
},
|
|
5567
5621
|
children: labels.uploader.browse
|
|
5568
5622
|
}
|
|
@@ -5576,8 +5630,8 @@ var TelescupUploader = ({
|
|
|
5576
5630
|
accept,
|
|
5577
5631
|
multiple,
|
|
5578
5632
|
onChange: (event) => {
|
|
5579
|
-
var
|
|
5580
|
-
if ((
|
|
5633
|
+
var _a59;
|
|
5634
|
+
if ((_a59 = event.target.files) == null ? void 0 : _a59.length) {
|
|
5581
5635
|
handleFiles(event.target.files);
|
|
5582
5636
|
event.currentTarget.value = "";
|
|
5583
5637
|
}
|
|
@@ -5612,7 +5666,7 @@ var TelescupUploader = ({
|
|
|
5612
5666
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(AlertDialogTitle, { children: labels.conflict.title }),
|
|
5613
5667
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(AlertDialogDescription, { children: labels.conflict.description })
|
|
5614
5668
|
] }),
|
|
5615
|
-
((
|
|
5669
|
+
((_a58 = conflictItem == null ? void 0 : conflictItem.existingAsset) == null ? void 0 : _a58.id) ? /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "mt-3 rounded-lg border border-border bg-muted/30 p-3", children: [
|
|
5616
5670
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "text-xs font-semibold text-muted-foreground", children: "Asset existente" }),
|
|
5617
5671
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "mt-2 h-28 overflow-hidden rounded-md", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
5618
5672
|
TelescupImage,
|
|
@@ -5835,7 +5889,7 @@ var DEFAULT_LABELS = {
|
|
|
5835
5889
|
}
|
|
5836
5890
|
};
|
|
5837
5891
|
var mergeLabels = (overrides) => {
|
|
5838
|
-
var
|
|
5892
|
+
var _a58;
|
|
5839
5893
|
if (!overrides) return DEFAULT_LABELS;
|
|
5840
5894
|
return {
|
|
5841
5895
|
...DEFAULT_LABELS,
|
|
@@ -5849,17 +5903,17 @@ var mergeLabels = (overrides) => {
|
|
|
5849
5903
|
meta: {
|
|
5850
5904
|
...DEFAULT_LABELS.meta,
|
|
5851
5905
|
...overrides.meta,
|
|
5852
|
-
fields: { ...DEFAULT_LABELS.meta.fields, ...(
|
|
5906
|
+
fields: { ...DEFAULT_LABELS.meta.fields, ...(_a58 = overrides.meta) == null ? void 0 : _a58.fields }
|
|
5853
5907
|
},
|
|
5854
5908
|
toasts: { ...DEFAULT_LABELS.toasts, ...overrides.toasts }
|
|
5855
5909
|
};
|
|
5856
5910
|
};
|
|
5857
5911
|
var LANGUAGES = ["pt", "en", "es"];
|
|
5858
5912
|
var getAssetMeta = (asset, lang) => {
|
|
5859
|
-
var
|
|
5913
|
+
var _a58, _b5;
|
|
5860
5914
|
if (!asset) return {};
|
|
5861
|
-
if ((
|
|
5862
|
-
return (
|
|
5915
|
+
if ((_a58 = asset.metaByLang) == null ? void 0 : _a58[lang]) return asset.metaByLang[lang];
|
|
5916
|
+
return (_b5 = asset.meta) != null ? _b5 : {};
|
|
5863
5917
|
};
|
|
5864
5918
|
var TelescupMetaEditor = ({
|
|
5865
5919
|
client,
|
|
@@ -5869,8 +5923,8 @@ var TelescupMetaEditor = ({
|
|
|
5869
5923
|
labels,
|
|
5870
5924
|
onAssetUpdated
|
|
5871
5925
|
}) => {
|
|
5872
|
-
var
|
|
5873
|
-
const [activeAssetId, setActiveAssetId] = (0, import_react17.useState)((
|
|
5926
|
+
var _a58, _b5, _c, _d, _e, _f, _g, _h;
|
|
5927
|
+
const [activeAssetId, setActiveAssetId] = (0, import_react17.useState)((_b5 = (_a58 = assets[0]) == null ? void 0 : _a58.id) != null ? _b5 : "");
|
|
5874
5928
|
const [activeLang, setActiveLang] = (0, import_react17.useState)(
|
|
5875
5929
|
LANGUAGES.includes(defaultLanguage) ? defaultLanguage : "pt"
|
|
5876
5930
|
);
|
|
@@ -5888,18 +5942,18 @@ var TelescupMetaEditor = ({
|
|
|
5888
5942
|
}, [activeAssetId, assets]);
|
|
5889
5943
|
const asset = assets.find((item) => item.id === activeAssetId);
|
|
5890
5944
|
const currentDraft = (0, import_react17.useMemo)(() => {
|
|
5891
|
-
var
|
|
5892
|
-
const existing = (
|
|
5945
|
+
var _a59;
|
|
5946
|
+
const existing = (_a59 = drafts[activeAssetId]) == null ? void 0 : _a59[activeLang];
|
|
5893
5947
|
if (existing) return existing;
|
|
5894
5948
|
return getAssetMeta(asset, activeLang);
|
|
5895
5949
|
}, [activeAssetId, activeLang, asset, drafts]);
|
|
5896
5950
|
const updateDraft = (field, value) => {
|
|
5897
5951
|
setDrafts((prev) => {
|
|
5898
|
-
var
|
|
5952
|
+
var _a59;
|
|
5899
5953
|
return {
|
|
5900
5954
|
...prev,
|
|
5901
5955
|
[activeAssetId]: {
|
|
5902
|
-
...(
|
|
5956
|
+
...(_a59 = prev[activeAssetId]) != null ? _a59 : {},
|
|
5903
5957
|
[activeLang]: {
|
|
5904
5958
|
...currentDraft,
|
|
5905
5959
|
[field]: value
|
|
@@ -5967,11 +6021,11 @@ var TelescupMetaEditor = ({
|
|
|
5967
6021
|
onAssetUpdated == null ? void 0 : onAssetUpdated(updated);
|
|
5968
6022
|
const updatedMeta = getAssetMeta(updated, activeLang);
|
|
5969
6023
|
setDrafts((prev) => {
|
|
5970
|
-
var
|
|
6024
|
+
var _a59;
|
|
5971
6025
|
return {
|
|
5972
6026
|
...prev,
|
|
5973
6027
|
[asset.id]: {
|
|
5974
|
-
...(
|
|
6028
|
+
...(_a59 = prev[asset.id]) != null ? _a59 : {},
|
|
5975
6029
|
[activeLang]: updatedMeta
|
|
5976
6030
|
}
|
|
5977
6031
|
};
|
|
@@ -6278,7 +6332,6 @@ var TelescupUpload = ({
|
|
|
6278
6332
|
|
|
6279
6333
|
// src/components/cupcode/UserMenuCupcode.tsx
|
|
6280
6334
|
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
6281
|
-
var import_meta4 = {};
|
|
6282
6335
|
var PRESENCE_META = {
|
|
6283
6336
|
online: { label: "On-line", group: "online", kind: "dot", dotClass: "bg-success" },
|
|
6284
6337
|
away: { label: "Ausente", group: "away", kind: "crescent" },
|
|
@@ -6399,10 +6452,10 @@ var SHARED_FILE_EXTENSIONS = [
|
|
|
6399
6452
|
".mov",
|
|
6400
6453
|
".avi"
|
|
6401
6454
|
];
|
|
6402
|
-
var
|
|
6403
|
-
var ACCOUNTS_BASE_URL = ((
|
|
6404
|
-
var
|
|
6405
|
-
var MC_BASE_URL = ((
|
|
6455
|
+
var _a14;
|
|
6456
|
+
var ACCOUNTS_BASE_URL = ((_a14 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a14 : "https://accounts.cupcode.com.br").trim().replace(/\/+$/, "");
|
|
6457
|
+
var _a15;
|
|
6458
|
+
var MC_BASE_URL = ((_a15 = getRuntimeEnv("VITE_MC_BASE_URL")) != null ? _a15 : "https://mc.cupcode.com.br").trim().replace(/\/+$/, "");
|
|
6406
6459
|
var LANGUAGE_OPTIONS = [
|
|
6407
6460
|
{ value: "pt-BR", shortLabel: "BR", label: "Portugu\xEAs (Brasil)" },
|
|
6408
6461
|
{ value: "en-US", shortLabel: "EN", label: "English" },
|
|
@@ -6543,16 +6596,16 @@ var normalizeContrastMode = (value) => {
|
|
|
6543
6596
|
return (value == null ? void 0 : value.trim().toLowerCase()) === "high" ? "high" : "normal";
|
|
6544
6597
|
};
|
|
6545
6598
|
var readStoredExperienceSettings = () => {
|
|
6546
|
-
var
|
|
6599
|
+
var _a58, _b5, _c;
|
|
6547
6600
|
const fallback = defaultExperienceSettings();
|
|
6548
6601
|
if (typeof window === "undefined") return fallback;
|
|
6549
6602
|
try {
|
|
6550
6603
|
const raw = window.localStorage.getItem(EXPERIENCE_SETTINGS_STORAGE_KEY);
|
|
6551
6604
|
const parsed = raw ? JSON.parse(raw) : null;
|
|
6552
6605
|
const storedThemePreference = window.localStorage.getItem(THEME_PREFERENCE_STORAGE_KEY);
|
|
6553
|
-
const legacyTheme = (
|
|
6606
|
+
const legacyTheme = (_a58 = window.localStorage.getItem(THEME_STORAGE_KEY2)) != null ? _a58 : window.localStorage.getItem(LEGACY_THEME_STORAGE_KEY);
|
|
6554
6607
|
return {
|
|
6555
|
-
theme: normalizeThemePreference((_c = (
|
|
6608
|
+
theme: normalizeThemePreference((_c = (_b5 = parsed == null ? void 0 : parsed.theme) != null ? _b5 : storedThemePreference) != null ? _c : legacyTheme),
|
|
6556
6609
|
density: normalizeDensityMode(parsed == null ? void 0 : parsed.density),
|
|
6557
6610
|
contrast: normalizeContrastMode(parsed == null ? void 0 : parsed.contrast),
|
|
6558
6611
|
showEmailPublicly: typeof (parsed == null ? void 0 : parsed.showEmailPublicly) === "boolean" ? parsed.showEmailPublicly : fallback.showEmailPublicly
|
|
@@ -6694,7 +6747,7 @@ var getNotificationTimestamp = (notification) => {
|
|
|
6694
6747
|
return Number.isNaN(parsed) ? 0 : parsed;
|
|
6695
6748
|
};
|
|
6696
6749
|
var formatNotificationDateTime = (notification) => {
|
|
6697
|
-
var
|
|
6750
|
+
var _a58;
|
|
6698
6751
|
if (notification.createdAt) {
|
|
6699
6752
|
const parsed = new Date(notification.createdAt);
|
|
6700
6753
|
if (!Number.isNaN(parsed.getTime())) {
|
|
@@ -6706,7 +6759,7 @@ var formatNotificationDateTime = (notification) => {
|
|
|
6706
6759
|
});
|
|
6707
6760
|
}
|
|
6708
6761
|
}
|
|
6709
|
-
return ((
|
|
6762
|
+
return ((_a58 = notification.timeLabel) == null ? void 0 : _a58.trim()) || "Agora";
|
|
6710
6763
|
};
|
|
6711
6764
|
var getNotificationDayKey = (notification) => {
|
|
6712
6765
|
const timestamp = getNotificationTimestamp(notification);
|
|
@@ -6786,9 +6839,9 @@ var isCupcodeCdnUrl = (value) => {
|
|
|
6786
6839
|
}
|
|
6787
6840
|
};
|
|
6788
6841
|
var resolveTelescupImageUrl = (value, options) => {
|
|
6789
|
-
var
|
|
6790
|
-
const width = (
|
|
6791
|
-
const height = (
|
|
6842
|
+
var _a58, _b5, _c;
|
|
6843
|
+
const width = (_a58 = options == null ? void 0 : options.width) != null ? _a58 : 96;
|
|
6844
|
+
const height = (_b5 = options == null ? void 0 : options.height) != null ? _b5 : 96;
|
|
6792
6845
|
const quality = (_c = options == null ? void 0 : options.quality) != null ? _c : 72;
|
|
6793
6846
|
const raw = value == null ? void 0 : value.trim();
|
|
6794
6847
|
if (!raw) return void 0;
|
|
@@ -6805,12 +6858,12 @@ var resolveTelescupImageUrl = (value, options) => {
|
|
|
6805
6858
|
return buildTelescupImageURL({ id: parsedId, width, height, fit: "cover", format: "avif", quality });
|
|
6806
6859
|
};
|
|
6807
6860
|
var resolveGroupAvatarFromTelescup = (asset, fallbackId) => {
|
|
6808
|
-
var
|
|
6809
|
-
return (
|
|
6861
|
+
var _a58, _b5;
|
|
6862
|
+
return (_b5 = (_a58 = resolveTelescupImageUrl(asset == null ? void 0 : asset.url)) != null ? _a58 : resolveTelescupImageUrl(asset == null ? void 0 : asset.id)) != null ? _b5 : resolveTelescupImageUrl(fallbackId);
|
|
6810
6863
|
};
|
|
6811
6864
|
var resolveProfileAvatarFromTelescup = (asset, fallbackId) => {
|
|
6812
|
-
var
|
|
6813
|
-
return (
|
|
6865
|
+
var _a58, _b5;
|
|
6866
|
+
return (_b5 = (_a58 = resolveTelescupImageUrl(asset == null ? void 0 : asset.url, { width: 384, height: 384, quality: 80 })) != null ? _a58 : resolveTelescupImageUrl(asset == null ? void 0 : asset.id, { width: 384, height: 384, quality: 80 })) != null ? _b5 : resolveTelescupImageUrl(fallbackId, { width: 384, height: 384, quality: 80 });
|
|
6814
6867
|
};
|
|
6815
6868
|
var playIncomingMessageSound = () => {
|
|
6816
6869
|
if (typeof window === "undefined") return;
|
|
@@ -6945,7 +6998,7 @@ var UserMenuCupcode = ({
|
|
|
6945
6998
|
panels,
|
|
6946
6999
|
className
|
|
6947
7000
|
}) => {
|
|
6948
|
-
var
|
|
7001
|
+
var _a58;
|
|
6949
7002
|
const [open, setOpen] = (0, import_react18.useState)(false);
|
|
6950
7003
|
const [activeTab, setActiveTab] = (0, import_react18.useState)("profile");
|
|
6951
7004
|
const [isLoggingOut, setIsLoggingOut] = (0, import_react18.useState)(false);
|
|
@@ -7041,12 +7094,12 @@ var UserMenuCupcode = ({
|
|
|
7041
7094
|
);
|
|
7042
7095
|
const normalizedNotificationFeed = (0, import_react18.useMemo)(
|
|
7043
7096
|
() => resolvedNotificationFeed.map((notification) => {
|
|
7044
|
-
var
|
|
7097
|
+
var _a59;
|
|
7045
7098
|
const kind = normalizeNotificationKind(notification.kind);
|
|
7046
7099
|
return {
|
|
7047
7100
|
...notification,
|
|
7048
7101
|
kind,
|
|
7049
|
-
topic: (
|
|
7102
|
+
topic: (_a59 = notification.topic) != null ? _a59 : NOTIFICATION_KIND_META[kind].topicFallback
|
|
7050
7103
|
};
|
|
7051
7104
|
}),
|
|
7052
7105
|
[resolvedNotificationFeed]
|
|
@@ -7081,10 +7134,10 @@ var UserMenuCupcode = ({
|
|
|
7081
7134
|
const groupedNotifications = (0, import_react18.useMemo)(() => {
|
|
7082
7135
|
const groups = /* @__PURE__ */ new Map();
|
|
7083
7136
|
filteredNotifications.forEach((notification) => {
|
|
7084
|
-
var
|
|
7137
|
+
var _a59, _b5;
|
|
7085
7138
|
const kind = normalizeNotificationKind(notification.kind);
|
|
7086
|
-
const key = notificationPreferences.grouping === "topic" ? (
|
|
7087
|
-
const current = (
|
|
7139
|
+
const key = notificationPreferences.grouping === "topic" ? (_a59 = notification.topic) != null ? _a59 : NOTIFICATION_KIND_META[kind].topicFallback : getNotificationDayKey(notification);
|
|
7140
|
+
const current = (_b5 = groups.get(key)) != null ? _b5 : [];
|
|
7088
7141
|
current.push(notification);
|
|
7089
7142
|
groups.set(key, current);
|
|
7090
7143
|
});
|
|
@@ -7171,7 +7224,7 @@ var UserMenuCupcode = ({
|
|
|
7171
7224
|
}).slice(0, 6);
|
|
7172
7225
|
}, [recentActivity]);
|
|
7173
7226
|
const isSendingChatMessage = isChatSending || isSendingInternalChatMessage;
|
|
7174
|
-
const activeReactionPickerMessageId = (
|
|
7227
|
+
const activeReactionPickerMessageId = (_a58 = activeReactionPicker == null ? void 0 : activeReactionPicker.messageId) != null ? _a58 : null;
|
|
7175
7228
|
const isChatSidebarOpen = isChatSidebarExpanded || isChatSidebarPinned;
|
|
7176
7229
|
const hasTelescupAvatarSupport = Boolean(telescupBaseUrl && getTelescupAccessToken);
|
|
7177
7230
|
const hasTelescupGroupAvatarSupport = hasTelescupAvatarSupport;
|
|
@@ -7185,8 +7238,8 @@ var UserMenuCupcode = ({
|
|
|
7185
7238
|
meta.set(user.id, { lastMessage: null, lastTimestamp: 0, unreadCount: 0 });
|
|
7186
7239
|
});
|
|
7187
7240
|
resolvedAllChatMessages.forEach((message) => {
|
|
7188
|
-
var
|
|
7189
|
-
const current = (
|
|
7241
|
+
var _a59;
|
|
7242
|
+
const current = (_a59 = meta.get(message.contactId)) != null ? _a59 : { lastMessage: null, lastTimestamp: 0, unreadCount: 0 };
|
|
7190
7243
|
const timestamp = getChatMessageTimestamp(message);
|
|
7191
7244
|
if (timestamp >= current.lastTimestamp) {
|
|
7192
7245
|
current.lastTimestamp = timestamp;
|
|
@@ -7199,8 +7252,8 @@ var UserMenuCupcode = ({
|
|
|
7199
7252
|
});
|
|
7200
7253
|
if (chatUnreadByUser) {
|
|
7201
7254
|
Object.entries(chatUnreadByUser).forEach(([contactId, unreadCount]) => {
|
|
7202
|
-
var
|
|
7203
|
-
const current = (
|
|
7255
|
+
var _a59;
|
|
7256
|
+
const current = (_a59 = meta.get(contactId)) != null ? _a59 : { lastMessage: null, lastTimestamp: 0, unreadCount: 0 };
|
|
7204
7257
|
current.unreadCount = unreadCount;
|
|
7205
7258
|
meta.set(contactId, current);
|
|
7206
7259
|
});
|
|
@@ -7214,11 +7267,11 @@ var UserMenuCupcode = ({
|
|
|
7214
7267
|
return haystack.includes(query);
|
|
7215
7268
|
});
|
|
7216
7269
|
return filtered.sort((left, right) => {
|
|
7217
|
-
var
|
|
7270
|
+
var _a59, _b5, _c, _d;
|
|
7218
7271
|
const leftMeta = conversationMetaByUserId.get(left.id);
|
|
7219
7272
|
const rightMeta = conversationMetaByUserId.get(right.id);
|
|
7220
|
-
const leftTimestamp = (
|
|
7221
|
-
const rightTimestamp = (
|
|
7273
|
+
const leftTimestamp = (_a59 = leftMeta == null ? void 0 : leftMeta.lastTimestamp) != null ? _a59 : 0;
|
|
7274
|
+
const rightTimestamp = (_b5 = rightMeta == null ? void 0 : rightMeta.lastTimestamp) != null ? _b5 : 0;
|
|
7222
7275
|
if (leftTimestamp !== rightTimestamp) return rightTimestamp - leftTimestamp;
|
|
7223
7276
|
const leftUnread = (_c = leftMeta == null ? void 0 : leftMeta.unreadCount) != null ? _c : 0;
|
|
7224
7277
|
const rightUnread = (_d = rightMeta == null ? void 0 : rightMeta.unreadCount) != null ? _d : 0;
|
|
@@ -7269,11 +7322,11 @@ var UserMenuCupcode = ({
|
|
|
7269
7322
|
const visibleChatUnreadCount = isBadgeSuppressedByFocus ? 0 : resolvedChatUnreadCount;
|
|
7270
7323
|
const firstUnreadChatUserId = (0, import_react18.useMemo)(
|
|
7271
7324
|
() => {
|
|
7272
|
-
var
|
|
7273
|
-
return (
|
|
7274
|
-
var
|
|
7275
|
-
return ((
|
|
7276
|
-
})) == null ? void 0 :
|
|
7325
|
+
var _a59, _b5;
|
|
7326
|
+
return (_b5 = (_a59 = filteredAndSortedChatUsers.find((user) => {
|
|
7327
|
+
var _a60;
|
|
7328
|
+
return ((_a60 = resolvedChatUnreadByUser[user.id]) != null ? _a60 : 0) > 0;
|
|
7329
|
+
})) == null ? void 0 : _a59.id) != null ? _b5 : null;
|
|
7277
7330
|
},
|
|
7278
7331
|
[filteredAndSortedChatUsers, resolvedChatUnreadByUser]
|
|
7279
7332
|
);
|
|
@@ -7303,11 +7356,11 @@ var UserMenuCupcode = ({
|
|
|
7303
7356
|
);
|
|
7304
7357
|
const openChatPanel = (0, import_react18.useCallback)(
|
|
7305
7358
|
(contactId) => {
|
|
7306
|
-
var
|
|
7359
|
+
var _a59, _b5, _c, _d, _e;
|
|
7307
7360
|
setIsLogoutConfirmOpen(false);
|
|
7308
7361
|
setOpen(true);
|
|
7309
7362
|
setActiveTab("chat");
|
|
7310
|
-
const targetContactId = (_e = (_d = (
|
|
7363
|
+
const targetContactId = (_e = (_d = (_b5 = contactId != null ? contactId : firstUnreadChatUserId) != null ? _b5 : (_a59 = filteredAndSortedChatUsers[0]) == null ? void 0 : _a59.id) != null ? _d : (_c = chatUsersList[0]) == null ? void 0 : _c.id) != null ? _e : "";
|
|
7311
7364
|
if (!targetContactId) return;
|
|
7312
7365
|
setActiveChatUserId(targetContactId);
|
|
7313
7366
|
markConversationRead(targetContactId);
|
|
@@ -7317,9 +7370,9 @@ var UserMenuCupcode = ({
|
|
|
7317
7370
|
const reactionsByMessageId = (0, import_react18.useMemo)(() => {
|
|
7318
7371
|
const grouped = /* @__PURE__ */ new Map();
|
|
7319
7372
|
resolvedAllChatReactions.forEach((reaction) => {
|
|
7320
|
-
var
|
|
7321
|
-
const byEmoji = (
|
|
7322
|
-
const current = (
|
|
7373
|
+
var _a59, _b5;
|
|
7374
|
+
const byEmoji = (_a59 = grouped.get(reaction.messageId)) != null ? _a59 : /* @__PURE__ */ new Map();
|
|
7375
|
+
const current = (_b5 = byEmoji.get(reaction.emoji)) != null ? _b5 : { emoji: reaction.emoji, count: 0, reactedByMe: false };
|
|
7323
7376
|
current.count += 1;
|
|
7324
7377
|
if (resolvedCurrentChatUserId && reaction.userId === resolvedCurrentChatUserId) {
|
|
7325
7378
|
current.reactedByMe = true;
|
|
@@ -7506,9 +7559,9 @@ var UserMenuCupcode = ({
|
|
|
7506
7559
|
const wasFocusModeActive = wasFocusModeActiveRef.current;
|
|
7507
7560
|
if (wasFocusModeActive && !isFocusModeActive && suppressedFocusNotifications.length) {
|
|
7508
7561
|
const byType = suppressedFocusNotifications.reduce((acc, notification) => {
|
|
7509
|
-
var
|
|
7562
|
+
var _a59;
|
|
7510
7563
|
const kind = normalizeNotificationKind(notification.kind);
|
|
7511
|
-
acc[kind] = ((
|
|
7564
|
+
acc[kind] = ((_a59 = acc[kind]) != null ? _a59 : 0) + 1;
|
|
7512
7565
|
return acc;
|
|
7513
7566
|
}, { system: 0, comment: 0, access: 0, billing: 0, chat: 0, security: 0 });
|
|
7514
7567
|
const summaryParts = NOTIFICATION_KIND_ORDER.filter((kind) => byType[kind] > 0).map(
|
|
@@ -7538,9 +7591,9 @@ var UserMenuCupcode = ({
|
|
|
7538
7591
|
return;
|
|
7539
7592
|
}
|
|
7540
7593
|
setActiveChatUserId((current) => {
|
|
7541
|
-
var
|
|
7594
|
+
var _a59, _b5;
|
|
7542
7595
|
if (current && chatUsersList.some((user) => user.id === current)) return current;
|
|
7543
|
-
return (
|
|
7596
|
+
return (_b5 = (_a59 = filteredAndSortedChatUsers[0]) == null ? void 0 : _a59.id) != null ? _b5 : chatUsersList[0].id;
|
|
7544
7597
|
});
|
|
7545
7598
|
}, [chatUsersList, filteredAndSortedChatUsers]);
|
|
7546
7599
|
(0, import_react18.useEffect)(() => {
|
|
@@ -7582,7 +7635,7 @@ var UserMenuCupcode = ({
|
|
|
7582
7635
|
};
|
|
7583
7636
|
}, [activeReactionPickerMessageId]);
|
|
7584
7637
|
(0, import_react18.useEffect)(() => {
|
|
7585
|
-
var
|
|
7638
|
+
var _a59;
|
|
7586
7639
|
const knownIncomingIds = seenIncomingMessageIdsRef.current;
|
|
7587
7640
|
const incomingMessages = resolvedAllChatMessages.filter((message) => message.sender === "them");
|
|
7588
7641
|
if (!hasBootstrappedIncomingMessagesRef.current) {
|
|
@@ -7603,14 +7656,14 @@ var UserMenuCupcode = ({
|
|
|
7603
7656
|
return;
|
|
7604
7657
|
}
|
|
7605
7658
|
const generatedNotifications = relevantIncomingMessages.map((message) => {
|
|
7606
|
-
var
|
|
7659
|
+
var _a60, _b5, _c;
|
|
7607
7660
|
const contact = chatUsersList.find((user) => user.id === message.contactId);
|
|
7608
|
-
const createdAt = (
|
|
7661
|
+
const createdAt = (_a60 = message.createdAt) != null ? _a60 : (/* @__PURE__ */ new Date()).toISOString();
|
|
7609
7662
|
const previewText = chatSettings.showMessagePreview ? summarizeChatText(message.text, 100) : "Nova mensagem no chat.";
|
|
7610
7663
|
return {
|
|
7611
7664
|
id: `chat-notification-${message.id}`,
|
|
7612
7665
|
kind: "chat",
|
|
7613
|
-
title: `Mensagem de ${(
|
|
7666
|
+
title: `Mensagem de ${(_b5 = contact == null ? void 0 : contact.name) != null ? _b5 : "usu\xE1rio"}`,
|
|
7614
7667
|
description: previewText,
|
|
7615
7668
|
createdAt,
|
|
7616
7669
|
timeLabel: formatChatTime({ ...message, createdAt }),
|
|
@@ -7631,7 +7684,7 @@ var UserMenuCupcode = ({
|
|
|
7631
7684
|
)[0];
|
|
7632
7685
|
if (latestRelevantMessage) {
|
|
7633
7686
|
const latestContact = chatUsersList.find((user) => user.id === latestRelevantMessage.contactId);
|
|
7634
|
-
const senderName = (
|
|
7687
|
+
const senderName = (_a59 = latestContact == null ? void 0 : latestContact.name) != null ? _a59 : "usu\xE1rio";
|
|
7635
7688
|
const latestPreview = chatSettings.showMessagePreview ? summarizeChatText(latestRelevantMessage.text, 96) : "Nova mensagem";
|
|
7636
7689
|
const remainingCount = Math.max(relevantIncomingMessages.length - 1, 0);
|
|
7637
7690
|
const toastTitle = remainingCount > 0 ? `Mensagem de ${senderName} (+${remainingCount})` : `Mensagem de ${senderName}`;
|
|
@@ -7665,10 +7718,10 @@ var UserMenuCupcode = ({
|
|
|
7665
7718
|
return;
|
|
7666
7719
|
}
|
|
7667
7720
|
generatedNotifications.forEach((chatNotification) => {
|
|
7668
|
-
var
|
|
7721
|
+
var _a60;
|
|
7669
7722
|
const notification = new Notification(chatNotification.title, {
|
|
7670
7723
|
body: chatSettings.showMessagePreview ? chatNotification.description : "Voc\xEA recebeu uma nova mensagem.",
|
|
7671
|
-
tag: `cc-chat-${(
|
|
7724
|
+
tag: `cc-chat-${(_a60 = chatNotification.actionChatUserId) != null ? _a60 : chatNotification.id}`
|
|
7672
7725
|
});
|
|
7673
7726
|
notification.onclick = () => {
|
|
7674
7727
|
window.focus();
|
|
@@ -7695,14 +7748,14 @@ var UserMenuCupcode = ({
|
|
|
7695
7748
|
]);
|
|
7696
7749
|
const activeChatUser = (0, import_react18.useMemo)(
|
|
7697
7750
|
() => {
|
|
7698
|
-
var
|
|
7699
|
-
return (
|
|
7751
|
+
var _a59;
|
|
7752
|
+
return (_a59 = chatUsersList.find((user) => user.id === activeChatUserId)) != null ? _a59 : null;
|
|
7700
7753
|
},
|
|
7701
7754
|
[activeChatUserId, chatUsersList]
|
|
7702
7755
|
);
|
|
7703
7756
|
const activeGroupMembers = (0, import_react18.useMemo)(() => {
|
|
7704
|
-
var
|
|
7705
|
-
if (!(activeChatUser == null ? void 0 : activeChatUser.isGroup) || !((
|
|
7757
|
+
var _a59;
|
|
7758
|
+
if (!(activeChatUser == null ? void 0 : activeChatUser.isGroup) || !((_a59 = activeChatUser.memberIds) == null ? void 0 : _a59.length)) return [];
|
|
7706
7759
|
const members = activeChatUser.memberIds.map((memberId) => baseChatUsersList.find((user) => user.id === memberId)).filter((member) => Boolean(member));
|
|
7707
7760
|
return members;
|
|
7708
7761
|
}, [activeChatUser, baseChatUsersList]);
|
|
@@ -7750,9 +7803,9 @@ var UserMenuCupcode = ({
|
|
|
7750
7803
|
});
|
|
7751
7804
|
}, [activeChatUser, resolvedChatLogs]);
|
|
7752
7805
|
const replyToMessage = (0, import_react18.useMemo)(() => {
|
|
7753
|
-
var
|
|
7806
|
+
var _a59;
|
|
7754
7807
|
if (!replyToMessageId) return null;
|
|
7755
|
-
return (
|
|
7808
|
+
return (_a59 = activeChatMessagesMap.get(replyToMessageId)) != null ? _a59 : null;
|
|
7756
7809
|
}, [activeChatMessagesMap, replyToMessageId]);
|
|
7757
7810
|
(0, import_react18.useEffect)(() => {
|
|
7758
7811
|
if (!replyToMessageId) return;
|
|
@@ -7779,9 +7832,9 @@ var UserMenuCupcode = ({
|
|
|
7779
7832
|
}
|
|
7780
7833
|
}, [activeChatUser]);
|
|
7781
7834
|
(0, import_react18.useEffect)(() => {
|
|
7782
|
-
var
|
|
7835
|
+
var _a59;
|
|
7783
7836
|
if (!open || activeTab !== "chat" || !activeChatUser || activeChatUser.isGroup) return;
|
|
7784
|
-
const unreadCount = (
|
|
7837
|
+
const unreadCount = (_a59 = resolvedChatUnreadByUser[activeChatUser.id]) != null ? _a59 : 0;
|
|
7785
7838
|
if (unreadCount <= 0) return;
|
|
7786
7839
|
const requestKey = `${activeChatUser.id}:${unreadCount}`;
|
|
7787
7840
|
if (lastReadRequestRef.current === requestKey) return;
|
|
@@ -7855,13 +7908,13 @@ var UserMenuCupcode = ({
|
|
|
7855
7908
|
openAccountsPath("/security#sessions");
|
|
7856
7909
|
};
|
|
7857
7910
|
const runOpenIntegrations = (provider) => {
|
|
7858
|
-
var
|
|
7911
|
+
var _a59;
|
|
7859
7912
|
if (!provider) {
|
|
7860
7913
|
openAccountsPath("/integrations");
|
|
7861
7914
|
return;
|
|
7862
7915
|
}
|
|
7863
7916
|
const option = INTEGRATION_OPTIONS.find((integration) => integration.id === provider);
|
|
7864
|
-
openAccountsPath((
|
|
7917
|
+
openAccountsPath((_a59 = option == null ? void 0 : option.accountPath) != null ? _a59 : "/integrations");
|
|
7865
7918
|
};
|
|
7866
7919
|
const changeStatus = (nextStatus) => {
|
|
7867
7920
|
if (nextStatus === "offline") return;
|
|
@@ -8213,10 +8266,10 @@ var UserMenuCupcode = ({
|
|
|
8213
8266
|
};
|
|
8214
8267
|
const handleProfileAvatarChange = (0, import_react18.useCallback)(
|
|
8215
8268
|
async (ids, assets) => {
|
|
8216
|
-
var
|
|
8269
|
+
var _a59, _b5, _c;
|
|
8217
8270
|
const selectedAsset = assets == null ? void 0 : assets[0];
|
|
8218
|
-
const selectedIdRaw = (
|
|
8219
|
-
const selectedId = (_c = (
|
|
8271
|
+
const selectedIdRaw = (_a59 = ids[0]) == null ? void 0 : _a59.trim();
|
|
8272
|
+
const selectedId = (_c = (_b5 = parseAssetId(selectedIdRaw)) != null ? _b5 : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.id)) != null ? _c : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.url);
|
|
8220
8273
|
if (!selectedId) {
|
|
8221
8274
|
toast({
|
|
8222
8275
|
title: "Imagem inv\xE1lida",
|
|
@@ -8258,7 +8311,7 @@ var UserMenuCupcode = ({
|
|
|
8258
8311
|
[isProfileAvatarSaving, onProfileAvatarChange, resolvedProfileAvatarUrl]
|
|
8259
8312
|
);
|
|
8260
8313
|
const sendChatMessage = async () => {
|
|
8261
|
-
var
|
|
8314
|
+
var _a59, _b5;
|
|
8262
8315
|
if (!activeChatUser) return;
|
|
8263
8316
|
const text = chatDraft.trim();
|
|
8264
8317
|
if (!text || isSendingChatMessage) return;
|
|
@@ -8269,7 +8322,7 @@ var UserMenuCupcode = ({
|
|
|
8269
8322
|
await onChatSendMessage({
|
|
8270
8323
|
recipientId: activeChatUser.id,
|
|
8271
8324
|
text,
|
|
8272
|
-
replyToMessageId: (
|
|
8325
|
+
replyToMessageId: (_a59 = replyToMessage == null ? void 0 : replyToMessage.id) != null ? _a59 : null
|
|
8273
8326
|
});
|
|
8274
8327
|
setChatDraft("");
|
|
8275
8328
|
setShowEmojiPicker(false);
|
|
@@ -8289,7 +8342,7 @@ var UserMenuCupcode = ({
|
|
|
8289
8342
|
timeLabel,
|
|
8290
8343
|
createdAt,
|
|
8291
8344
|
readAt: null,
|
|
8292
|
-
replyToMessageId: (
|
|
8345
|
+
replyToMessageId: (_b5 = replyToMessage == null ? void 0 : replyToMessage.id) != null ? _b5 : null
|
|
8293
8346
|
};
|
|
8294
8347
|
if (isLocalGroupConversation) {
|
|
8295
8348
|
setInternalGroupMessages((current) => [...current, message]);
|
|
@@ -8301,7 +8354,7 @@ var UserMenuCupcode = ({
|
|
|
8301
8354
|
setReplyToMessageId(null);
|
|
8302
8355
|
};
|
|
8303
8356
|
const renderDefaultPanel = () => {
|
|
8304
|
-
var
|
|
8357
|
+
var _a59, _b5, _c, _d;
|
|
8305
8358
|
if (activeTab === "profile") {
|
|
8306
8359
|
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "space-y-4", children: [
|
|
8307
8360
|
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "pt-1 text-center", children: [
|
|
@@ -8581,7 +8634,7 @@ var UserMenuCupcode = ({
|
|
|
8581
8634
|
visibleGroupedNotifications.length ? visibleGroupedNotifications.map((group) => /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("section", { className: "space-y-1.5", children: [
|
|
8582
8635
|
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("p", { className: "px-0.5 text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground", children: group.label }),
|
|
8583
8636
|
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "space-y-1.5", children: group.items.map((notification) => {
|
|
8584
|
-
var
|
|
8637
|
+
var _a60;
|
|
8585
8638
|
const kind = normalizeNotificationKind(notification.kind);
|
|
8586
8639
|
const meta = NOTIFICATION_KIND_META[kind];
|
|
8587
8640
|
const Icon3 = meta.icon;
|
|
@@ -8610,7 +8663,7 @@ var UserMenuCupcode = ({
|
|
|
8610
8663
|
className: "inline-flex h-6 items-center gap-1 rounded-md border border-border/70 px-1.5 text-[11px] font-semibold text-foreground transition-all hover:bg-muted/45",
|
|
8611
8664
|
children: [
|
|
8612
8665
|
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_lucide_react11.ExternalLink, { className: "h-3 w-3" }),
|
|
8613
|
-
(
|
|
8666
|
+
(_a60 = notification.actionLabel) != null ? _a60 : "Abrir"
|
|
8614
8667
|
]
|
|
8615
8668
|
}
|
|
8616
8669
|
),
|
|
@@ -8838,7 +8891,7 @@ var UserMenuCupcode = ({
|
|
|
8838
8891
|
}
|
|
8839
8892
|
if (activeTab === "chat") {
|
|
8840
8893
|
const canSendChatMessage = Boolean(activeChatUser) && chatDraft.trim() !== "" && !isSendingChatMessage && !isChatLoading;
|
|
8841
|
-
const activeConversationUnreadCount = activeChatUser ? (
|
|
8894
|
+
const activeConversationUnreadCount = activeChatUser ? (_a59 = resolvedChatUnreadByUser[activeChatUser.id]) != null ? _a59 : 0 : 0;
|
|
8842
8895
|
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "h-full", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
|
|
8843
8896
|
"div",
|
|
8844
8897
|
{
|
|
@@ -8917,12 +8970,12 @@ var UserMenuCupcode = ({
|
|
|
8917
8970
|
}
|
|
8918
8971
|
),
|
|
8919
8972
|
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "space-y-1", children: users.map((user) => {
|
|
8920
|
-
var
|
|
8973
|
+
var _a60, _b6, _c2;
|
|
8921
8974
|
const userInitials = buildInitials(user.name, user.username);
|
|
8922
8975
|
const isCurrent = user.id === activeChatUserId;
|
|
8923
|
-
const unreadCount = (
|
|
8976
|
+
const unreadCount = (_a60 = resolvedChatUnreadByUser[user.id]) != null ? _a60 : 0;
|
|
8924
8977
|
const hasUnread = unreadCount > 0;
|
|
8925
|
-
const lastMessage = (
|
|
8978
|
+
const lastMessage = (_b6 = conversationMetaByUserId.get(user.id)) == null ? void 0 : _b6.lastMessage;
|
|
8926
8979
|
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
|
|
8927
8980
|
"button",
|
|
8928
8981
|
{
|
|
@@ -9122,13 +9175,13 @@ var UserMenuCupcode = ({
|
|
|
9122
9175
|
] }) }),
|
|
9123
9176
|
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { ref: chatMessagesPaneRef, className: "cc-scrollbar cc-scrollbar-pink relative flex-1 space-y-2 overflow-y-auto px-3 py-2.5", children: [
|
|
9124
9177
|
isChatLoading ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("p", { className: "rounded-xl border border-dashed border-border/70 bg-background/35 px-3 py-3 text-[11px] text-muted-foreground", children: "Carregando conversa..." }) : activeChatMessages.length ? activeChatTimeline.map((item) => {
|
|
9125
|
-
var
|
|
9178
|
+
var _a60, _b6;
|
|
9126
9179
|
if (item.type === "day") {
|
|
9127
9180
|
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "flex justify-center py-1", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "inline-flex items-center rounded-full border border-border/70 bg-background/85 px-2.5 py-0.5 text-[10px] font-medium text-muted-foreground shadow-[var(--elevation-2)]", children: item.label }) }, item.key);
|
|
9128
9181
|
}
|
|
9129
9182
|
const { message } = item;
|
|
9130
|
-
const replyMessage = message.replyToMessageId ? (
|
|
9131
|
-
const reactions = (
|
|
9183
|
+
const replyMessage = message.replyToMessageId ? (_a60 = activeChatMessagesMap.get(message.replyToMessageId)) != null ? _a60 : null : null;
|
|
9184
|
+
const reactions = (_b6 = reactionsByMessageId.get(message.id)) != null ? _b6 : [];
|
|
9132
9185
|
const hasReadReceipt = Boolean(message.readAt);
|
|
9133
9186
|
const isEditing = editingMessageId === message.id;
|
|
9134
9187
|
const canEditOrDelete = message.sender === "me";
|
|
@@ -9305,7 +9358,7 @@ var UserMenuCupcode = ({
|
|
|
9305
9358
|
"div",
|
|
9306
9359
|
{
|
|
9307
9360
|
ref: reactionPickerRef,
|
|
9308
|
-
style: { top: `${(
|
|
9361
|
+
style: { top: `${(_b5 = activeReactionPicker == null ? void 0 : activeReactionPicker.top) != null ? _b5 : 0}px`, left: `${(_c = activeReactionPicker == null ? void 0 : activeReactionPicker.left) != null ? _c : 0}px` },
|
|
9309
9362
|
className: "absolute z-[1900] flex w-[14.35rem] items-center gap-1 whitespace-nowrap rounded-xl border border-border/70 bg-background/95 p-1.5 shadow-[var(--elevation-4)]",
|
|
9310
9363
|
children: MESSAGE_REACTION_OPTIONS.map((emoji) => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
9311
9364
|
"button",
|
|
@@ -9445,8 +9498,8 @@ var UserMenuCupcode = ({
|
|
|
9445
9498
|
] })
|
|
9446
9499
|
] }),
|
|
9447
9500
|
isChatSuperAdmin ? activeConversationLogs.length ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "space-y-2", children: activeConversationLogs.map((entry) => {
|
|
9448
|
-
var
|
|
9449
|
-
const actorName = entry.actorId && entry.actorId === resolvedCurrentChatUserId ? "Voc\xEA" : (
|
|
9501
|
+
var _a60;
|
|
9502
|
+
const actorName = entry.actorId && entry.actorId === resolvedCurrentChatUserId ? "Voc\xEA" : (_a60 = entry.actorId) != null ? _a60 : "Usu\xE1rio";
|
|
9450
9503
|
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
|
|
9451
9504
|
"article",
|
|
9452
9505
|
{
|
|
@@ -10387,7 +10440,7 @@ var FunctionsClient = class {
|
|
|
10387
10440
|
*/
|
|
10388
10441
|
invoke(functionName_1) {
|
|
10389
10442
|
return __awaiter(this, arguments, void 0, function* (functionName, options = {}) {
|
|
10390
|
-
var
|
|
10443
|
+
var _a58;
|
|
10391
10444
|
let timeoutId;
|
|
10392
10445
|
let timeoutController;
|
|
10393
10446
|
try {
|
|
@@ -10453,7 +10506,7 @@ var FunctionsClient = class {
|
|
|
10453
10506
|
if (!response.ok) {
|
|
10454
10507
|
throw new FunctionsHttpError(response);
|
|
10455
10508
|
}
|
|
10456
|
-
let responseType = ((
|
|
10509
|
+
let responseType = ((_a58 = response.headers.get("Content-Type")) !== null && _a58 !== void 0 ? _a58 : "text/plain").split(";")[0].trim();
|
|
10457
10510
|
let data;
|
|
10458
10511
|
if (responseType === "application/json") {
|
|
10459
10512
|
data = yield response.json();
|
|
@@ -11699,7 +11752,7 @@ var WebSocketFactory = class {
|
|
|
11699
11752
|
constructor() {
|
|
11700
11753
|
}
|
|
11701
11754
|
static detectEnvironment() {
|
|
11702
|
-
var
|
|
11755
|
+
var _a58;
|
|
11703
11756
|
if (typeof WebSocket !== "undefined") {
|
|
11704
11757
|
return { type: "native", constructor: WebSocket };
|
|
11705
11758
|
}
|
|
@@ -11716,7 +11769,7 @@ var WebSocketFactory = class {
|
|
|
11716
11769
|
workaround: "Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."
|
|
11717
11770
|
};
|
|
11718
11771
|
}
|
|
11719
|
-
if (typeof globalThis !== "undefined" && globalThis.EdgeRuntime || typeof navigator !== "undefined" && ((
|
|
11772
|
+
if (typeof globalThis !== "undefined" && globalThis.EdgeRuntime || typeof navigator !== "undefined" && ((_a58 = navigator.userAgent) === null || _a58 === void 0 ? void 0 : _a58.includes("Vercel-Edge"))) {
|
|
11720
11773
|
return {
|
|
11721
11774
|
type: "unsupported",
|
|
11722
11775
|
error: "Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",
|
|
@@ -11800,7 +11853,7 @@ Suggested solution: ${env.workaround}`;
|
|
|
11800
11853
|
try {
|
|
11801
11854
|
const env = this.detectEnvironment();
|
|
11802
11855
|
return env.type === "native" || env.type === "ws";
|
|
11803
|
-
} catch (
|
|
11856
|
+
} catch (_a58) {
|
|
11804
11857
|
return false;
|
|
11805
11858
|
}
|
|
11806
11859
|
}
|
|
@@ -11874,30 +11927,30 @@ var Serializer = class {
|
|
|
11874
11927
|
return callback(JSON.stringify(payload));
|
|
11875
11928
|
}
|
|
11876
11929
|
_binaryEncodeUserBroadcastPush(message) {
|
|
11877
|
-
var
|
|
11878
|
-
if (this._isArrayBuffer((
|
|
11930
|
+
var _a58;
|
|
11931
|
+
if (this._isArrayBuffer((_a58 = message.payload) === null || _a58 === void 0 ? void 0 : _a58.payload)) {
|
|
11879
11932
|
return this._encodeBinaryUserBroadcastPush(message);
|
|
11880
11933
|
} else {
|
|
11881
11934
|
return this._encodeJsonUserBroadcastPush(message);
|
|
11882
11935
|
}
|
|
11883
11936
|
}
|
|
11884
11937
|
_encodeBinaryUserBroadcastPush(message) {
|
|
11885
|
-
var
|
|
11886
|
-
const userPayload = (
|
|
11938
|
+
var _a58, _b5;
|
|
11939
|
+
const userPayload = (_b5 = (_a58 = message.payload) === null || _a58 === void 0 ? void 0 : _a58.payload) !== null && _b5 !== void 0 ? _b5 : new ArrayBuffer(0);
|
|
11887
11940
|
return this._encodeUserBroadcastPush(message, this.BINARY_ENCODING, userPayload);
|
|
11888
11941
|
}
|
|
11889
11942
|
_encodeJsonUserBroadcastPush(message) {
|
|
11890
|
-
var
|
|
11891
|
-
const userPayload = (
|
|
11943
|
+
var _a58, _b5;
|
|
11944
|
+
const userPayload = (_b5 = (_a58 = message.payload) === null || _a58 === void 0 ? void 0 : _a58.payload) !== null && _b5 !== void 0 ? _b5 : {};
|
|
11892
11945
|
const encoder = new TextEncoder();
|
|
11893
11946
|
const encodedUserPayload = encoder.encode(JSON.stringify(userPayload)).buffer;
|
|
11894
11947
|
return this._encodeUserBroadcastPush(message, this.JSON_ENCODING, encodedUserPayload);
|
|
11895
11948
|
}
|
|
11896
11949
|
_encodeUserBroadcastPush(message, encodingType, encodedPayload) {
|
|
11897
|
-
var
|
|
11950
|
+
var _a58, _b5;
|
|
11898
11951
|
const topic = message.topic;
|
|
11899
|
-
const ref = (
|
|
11900
|
-
const joinRef = (
|
|
11952
|
+
const ref = (_a58 = message.ref) !== null && _a58 !== void 0 ? _a58 : "";
|
|
11953
|
+
const joinRef = (_b5 = message.join_ref) !== null && _b5 !== void 0 ? _b5 : "";
|
|
11901
11954
|
const userEvent = message.payload.event;
|
|
11902
11955
|
const rest = this.allowedMetadataKeys ? this._pick(message.payload, this.allowedMetadataKeys) : {};
|
|
11903
11956
|
const metadata = Object.keys(rest).length === 0 ? "" : JSON.stringify(rest);
|
|
@@ -11983,8 +12036,8 @@ var Serializer = class {
|
|
|
11983
12036
|
return { join_ref: null, ref: null, topic, event: this.BROADCAST_EVENT, payload: data };
|
|
11984
12037
|
}
|
|
11985
12038
|
_isArrayBuffer(buffer) {
|
|
11986
|
-
var
|
|
11987
|
-
return buffer instanceof ArrayBuffer || ((
|
|
12039
|
+
var _a58;
|
|
12040
|
+
return buffer instanceof ArrayBuffer || ((_a58 = buffer === null || buffer === void 0 ? void 0 : buffer.constructor) === null || _a58 === void 0 ? void 0 : _a58.name) === "ArrayBuffer";
|
|
11988
12041
|
}
|
|
11989
12042
|
_pick(obj, keys) {
|
|
11990
12043
|
if (!obj || typeof obj !== "object") {
|
|
@@ -12048,8 +12101,8 @@ var PostgresTypes;
|
|
|
12048
12101
|
PostgresTypes2["tstzrange"] = "tstzrange";
|
|
12049
12102
|
})(PostgresTypes || (PostgresTypes = {}));
|
|
12050
12103
|
var convertChangeData = (columns, record, options = {}) => {
|
|
12051
|
-
var
|
|
12052
|
-
const skipTypes = (
|
|
12104
|
+
var _a58;
|
|
12105
|
+
const skipTypes = (_a58 = options.skipTypes) !== null && _a58 !== void 0 ? _a58 : [];
|
|
12053
12106
|
if (!record) {
|
|
12054
12107
|
return {};
|
|
12055
12108
|
}
|
|
@@ -12139,7 +12192,7 @@ var toJson = (value) => {
|
|
|
12139
12192
|
if (typeof value === "string") {
|
|
12140
12193
|
try {
|
|
12141
12194
|
return JSON.parse(value);
|
|
12142
|
-
} catch (
|
|
12195
|
+
} catch (_a58) {
|
|
12143
12196
|
return value;
|
|
12144
12197
|
}
|
|
12145
12198
|
}
|
|
@@ -12231,9 +12284,9 @@ var Push = class {
|
|
|
12231
12284
|
this.payload = Object.assign(Object.assign({}, this.payload), payload);
|
|
12232
12285
|
}
|
|
12233
12286
|
receive(status, callback) {
|
|
12234
|
-
var
|
|
12287
|
+
var _a58;
|
|
12235
12288
|
if (this._hasReceived(status)) {
|
|
12236
|
-
callback((
|
|
12289
|
+
callback((_a58 = this.receivedResp) === null || _a58 === void 0 ? void 0 : _a58.response);
|
|
12237
12290
|
}
|
|
12238
12291
|
this.recHooks.push({ status, callback });
|
|
12239
12292
|
return this;
|
|
@@ -12424,8 +12477,8 @@ var RealtimePresence = class _RealtimePresence {
|
|
|
12424
12477
|
};
|
|
12425
12478
|
}
|
|
12426
12479
|
this.map(joins, (key, newPresences) => {
|
|
12427
|
-
var
|
|
12428
|
-
const currentPresences = (
|
|
12480
|
+
var _a58;
|
|
12481
|
+
const currentPresences = (_a58 = state[key]) !== null && _a58 !== void 0 ? _a58 : [];
|
|
12429
12482
|
state[key] = this.cloneDeep(newPresences);
|
|
12430
12483
|
if (currentPresences.length > 0) {
|
|
12431
12484
|
const joinedPresenceRefs = state[key].map((m) => m.presence_ref);
|
|
@@ -12553,7 +12606,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
12553
12606
|
* ```
|
|
12554
12607
|
*/
|
|
12555
12608
|
constructor(topic, params = { config: {} }, socket) {
|
|
12556
|
-
var
|
|
12609
|
+
var _a58, _b5;
|
|
12557
12610
|
this.topic = topic;
|
|
12558
12611
|
this.params = params;
|
|
12559
12612
|
this.socket = socket;
|
|
@@ -12612,19 +12665,19 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
12612
12665
|
this.presence = new RealtimePresence(this);
|
|
12613
12666
|
this.broadcastEndpointURL = httpEndpointURL(this.socket.endPoint);
|
|
12614
12667
|
this.private = this.params.config.private || false;
|
|
12615
|
-
if (!this.private && ((
|
|
12668
|
+
if (!this.private && ((_b5 = (_a58 = this.params.config) === null || _a58 === void 0 ? void 0 : _a58.broadcast) === null || _b5 === void 0 ? void 0 : _b5.replay)) {
|
|
12616
12669
|
throw `tried to use replay on public channel '${this.topic}'. It must be a private channel.`;
|
|
12617
12670
|
}
|
|
12618
12671
|
}
|
|
12619
12672
|
/** Subscribe registers your client with the server */
|
|
12620
12673
|
subscribe(callback, timeout = this.timeout) {
|
|
12621
|
-
var
|
|
12674
|
+
var _a58, _b5, _c;
|
|
12622
12675
|
if (!this.socket.isConnected()) {
|
|
12623
12676
|
this.socket.connect();
|
|
12624
12677
|
}
|
|
12625
12678
|
if (this.state == CHANNEL_STATES.closed) {
|
|
12626
12679
|
const { config: { broadcast, presence, private: isPrivate } } = this.params;
|
|
12627
|
-
const postgres_changes = (
|
|
12680
|
+
const postgres_changes = (_b5 = (_a58 = this.bindings.postgres_changes) === null || _a58 === void 0 ? void 0 : _a58.map((r) => r.filter)) !== null && _b5 !== void 0 ? _b5 : [];
|
|
12628
12681
|
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;
|
|
12629
12682
|
const accessTokenPayload = {};
|
|
12630
12683
|
const config = {
|
|
@@ -12642,7 +12695,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
12642
12695
|
this.joinedOnce = true;
|
|
12643
12696
|
this._rejoin(timeout);
|
|
12644
12697
|
this.joinPush.receive("ok", async ({ postgres_changes: postgres_changes2 }) => {
|
|
12645
|
-
var
|
|
12698
|
+
var _a59;
|
|
12646
12699
|
if (!this.socket._isManualToken()) {
|
|
12647
12700
|
this.socket.setAuth();
|
|
12648
12701
|
}
|
|
@@ -12651,7 +12704,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
12651
12704
|
return;
|
|
12652
12705
|
} else {
|
|
12653
12706
|
const clientPostgresBindings = this.bindings.postgres_changes;
|
|
12654
|
-
const bindingsLen = (
|
|
12707
|
+
const bindingsLen = (_a59 = clientPostgresBindings === null || clientPostgresBindings === void 0 ? void 0 : clientPostgresBindings.length) !== null && _a59 !== void 0 ? _a59 : 0;
|
|
12655
12708
|
const newPostgresBindings = [];
|
|
12656
12709
|
for (let i = 0; i < bindingsLen; i++) {
|
|
12657
12710
|
const clientPostgresBinding = clientPostgresBindings[i];
|
|
@@ -12729,7 +12782,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
12729
12782
|
* @returns Promise resolving to object with success status, and error details if failed
|
|
12730
12783
|
*/
|
|
12731
12784
|
async httpSend(event, payload, opts = {}) {
|
|
12732
|
-
var
|
|
12785
|
+
var _a58;
|
|
12733
12786
|
if (payload === void 0 || payload === null) {
|
|
12734
12787
|
return Promise.reject("Payload is required for httpSend()");
|
|
12735
12788
|
}
|
|
@@ -12754,7 +12807,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
12754
12807
|
]
|
|
12755
12808
|
})
|
|
12756
12809
|
};
|
|
12757
|
-
const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (
|
|
12810
|
+
const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a58 = opts.timeout) !== null && _a58 !== void 0 ? _a58 : this.timeout);
|
|
12758
12811
|
if (response.status === 202) {
|
|
12759
12812
|
return { success: true };
|
|
12760
12813
|
}
|
|
@@ -12762,7 +12815,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
12762
12815
|
try {
|
|
12763
12816
|
const errorBody = await response.json();
|
|
12764
12817
|
errorMessage = errorBody.error || errorBody.message || errorMessage;
|
|
12765
|
-
} catch (
|
|
12818
|
+
} catch (_b5) {
|
|
12766
12819
|
}
|
|
12767
12820
|
return Promise.reject(new Error(errorMessage));
|
|
12768
12821
|
}
|
|
@@ -12776,7 +12829,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
12776
12829
|
* @param opts Options to be used during the send process
|
|
12777
12830
|
*/
|
|
12778
12831
|
async send(args, opts = {}) {
|
|
12779
|
-
var
|
|
12832
|
+
var _a58, _b5;
|
|
12780
12833
|
if (!this._canPush() && args.type === "broadcast") {
|
|
12781
12834
|
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.");
|
|
12782
12835
|
const { event, payload: endpoint_payload } = args;
|
|
@@ -12802,8 +12855,8 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
12802
12855
|
})
|
|
12803
12856
|
};
|
|
12804
12857
|
try {
|
|
12805
|
-
const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (
|
|
12806
|
-
await ((
|
|
12858
|
+
const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a58 = opts.timeout) !== null && _a58 !== void 0 ? _a58 : this.timeout);
|
|
12859
|
+
await ((_b5 = response.body) === null || _b5 === void 0 ? void 0 : _b5.cancel());
|
|
12807
12860
|
return response.ok ? "ok" : "error";
|
|
12808
12861
|
} catch (error) {
|
|
12809
12862
|
if (error.name === "AbortError") {
|
|
@@ -12814,9 +12867,9 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
12814
12867
|
}
|
|
12815
12868
|
} else {
|
|
12816
12869
|
return new Promise((resolve) => {
|
|
12817
|
-
var
|
|
12870
|
+
var _a59, _b6, _c;
|
|
12818
12871
|
const push = this._push(args.type, args, opts.timeout || this.timeout);
|
|
12819
|
-
if (args.type === "broadcast" && !((_c = (
|
|
12872
|
+
if (args.type === "broadcast" && !((_c = (_b6 = (_a59 = this.params) === null || _a59 === void 0 ? void 0 : _a59.config) === null || _b6 === void 0 ? void 0 : _b6.broadcast) === null || _c === void 0 ? void 0 : _c.ack)) {
|
|
12820
12873
|
resolve("ok");
|
|
12821
12874
|
}
|
|
12822
12875
|
push.receive("ok", () => resolve("ok"));
|
|
@@ -12935,7 +12988,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
12935
12988
|
}
|
|
12936
12989
|
/** @internal */
|
|
12937
12990
|
_trigger(type, payload, ref) {
|
|
12938
|
-
var
|
|
12991
|
+
var _a58, _b5;
|
|
12939
12992
|
const typeLower = type.toLocaleLowerCase();
|
|
12940
12993
|
const { close, error, leave, join } = CHANNEL_EVENTS;
|
|
12941
12994
|
const events = [close, error, leave, join];
|
|
@@ -12947,18 +13000,18 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
12947
13000
|
throw "channel onMessage callbacks must return the payload, modified or unmodified";
|
|
12948
13001
|
}
|
|
12949
13002
|
if (["insert", "update", "delete"].includes(typeLower)) {
|
|
12950
|
-
(
|
|
12951
|
-
var
|
|
12952
|
-
return ((
|
|
13003
|
+
(_a58 = this.bindings.postgres_changes) === null || _a58 === void 0 ? void 0 : _a58.filter((bind) => {
|
|
13004
|
+
var _a59, _b6, _c;
|
|
13005
|
+
return ((_a59 = bind.filter) === null || _a59 === void 0 ? void 0 : _a59.event) === "*" || ((_c = (_b6 = bind.filter) === null || _b6 === void 0 ? void 0 : _b6.event) === null || _c === void 0 ? void 0 : _c.toLocaleLowerCase()) === typeLower;
|
|
12953
13006
|
}).map((bind) => bind.callback(handledPayload, ref));
|
|
12954
13007
|
} else {
|
|
12955
|
-
(
|
|
12956
|
-
var
|
|
13008
|
+
(_b5 = this.bindings[typeLower]) === null || _b5 === void 0 ? void 0 : _b5.filter((bind) => {
|
|
13009
|
+
var _a59, _b6, _c, _d, _e, _f, _g, _h;
|
|
12957
13010
|
if (["broadcast", "presence", "postgres_changes"].includes(typeLower)) {
|
|
12958
13011
|
if ("id" in bind) {
|
|
12959
13012
|
const bindId = bind.id;
|
|
12960
|
-
const bindEvent = (
|
|
12961
|
-
return bindId && ((
|
|
13013
|
+
const bindEvent = (_a59 = bind.filter) === null || _a59 === void 0 ? void 0 : _a59.event;
|
|
13014
|
+
return bindId && ((_b6 = payload.ids) === null || _b6 === void 0 ? void 0 : _b6.includes(bindId)) && (bindEvent === "*" || (bindEvent === null || bindEvent === void 0 ? void 0 : bindEvent.toLocaleLowerCase()) === ((_c = payload.data) === null || _c === void 0 ? void 0 : _c.type.toLocaleLowerCase())) && (!((_d = bind.filter) === null || _d === void 0 ? void 0 : _d.table) || bind.filter.table === ((_e = payload.data) === null || _e === void 0 ? void 0 : _e.table));
|
|
12962
13015
|
} else {
|
|
12963
13016
|
const bindEvent = (_g = (_f = bind === null || bind === void 0 ? void 0 : bind.filter) === null || _f === void 0 ? void 0 : _f.event) === null || _g === void 0 ? void 0 : _g.toLocaleLowerCase();
|
|
12964
13017
|
return bindEvent === "*" || bindEvent === ((_h = payload === null || payload === void 0 ? void 0 : payload.event) === null || _h === void 0 ? void 0 : _h.toLocaleLowerCase());
|
|
@@ -13025,8 +13078,8 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
13025
13078
|
const typeLower = type.toLocaleLowerCase();
|
|
13026
13079
|
if (this.bindings[typeLower]) {
|
|
13027
13080
|
this.bindings[typeLower] = this.bindings[typeLower].filter((bind) => {
|
|
13028
|
-
var
|
|
13029
|
-
return !(((
|
|
13081
|
+
var _a58;
|
|
13082
|
+
return !(((_a58 = bind.type) === null || _a58 === void 0 ? void 0 : _a58.toLocaleLowerCase()) === typeLower && _RealtimeChannel.isEqual(bind.filter, filter));
|
|
13030
13083
|
});
|
|
13031
13084
|
}
|
|
13032
13085
|
return this;
|
|
@@ -13156,7 +13209,7 @@ var RealtimeClient = class {
|
|
|
13156
13209
|
* ```
|
|
13157
13210
|
*/
|
|
13158
13211
|
constructor(endPoint, options) {
|
|
13159
|
-
var
|
|
13212
|
+
var _a58;
|
|
13160
13213
|
this.accessTokenValue = null;
|
|
13161
13214
|
this.apiKey = null;
|
|
13162
13215
|
this._manuallySetToken = false;
|
|
@@ -13195,7 +13248,7 @@ var RealtimeClient = class {
|
|
|
13195
13248
|
}
|
|
13196
13249
|
return (...args) => fetch(...args);
|
|
13197
13250
|
};
|
|
13198
|
-
if (!((
|
|
13251
|
+
if (!((_a58 = options === null || options === void 0 ? void 0 : options.params) === null || _a58 === void 0 ? void 0 : _a58.apikey)) {
|
|
13199
13252
|
throw new Error("API key is required to connect to Realtime");
|
|
13200
13253
|
}
|
|
13201
13254
|
this.apiKey = options.params.apikey;
|
|
@@ -13377,8 +13430,8 @@ Option 2: Install and provide the "ws" package:
|
|
|
13377
13430
|
const { topic, event, payload, ref } = data;
|
|
13378
13431
|
const callback = () => {
|
|
13379
13432
|
this.encode(data, (result) => {
|
|
13380
|
-
var
|
|
13381
|
-
(
|
|
13433
|
+
var _a58;
|
|
13434
|
+
(_a58 = this.conn) === null || _a58 === void 0 ? void 0 : _a58.send(result);
|
|
13382
13435
|
});
|
|
13383
13436
|
};
|
|
13384
13437
|
this.log("push", `${topic} ${event} (${ref})`, payload);
|
|
@@ -13428,7 +13481,7 @@ Option 2: Install and provide the "ws" package:
|
|
|
13428
13481
|
* Sends a heartbeat message if the socket is connected.
|
|
13429
13482
|
*/
|
|
13430
13483
|
async sendHeartbeat() {
|
|
13431
|
-
var
|
|
13484
|
+
var _a58;
|
|
13432
13485
|
if (!this.isConnected()) {
|
|
13433
13486
|
try {
|
|
13434
13487
|
this.heartbeatCallback("disconnected");
|
|
@@ -13447,11 +13500,11 @@ Option 2: Install and provide the "ws" package:
|
|
|
13447
13500
|
this.log("error", "error in heartbeat callback", e);
|
|
13448
13501
|
}
|
|
13449
13502
|
this._wasManualDisconnect = false;
|
|
13450
|
-
(
|
|
13503
|
+
(_a58 = this.conn) === null || _a58 === void 0 ? void 0 : _a58.close(WS_CLOSE_NORMAL, "heartbeat timeout");
|
|
13451
13504
|
setTimeout(() => {
|
|
13452
|
-
var
|
|
13505
|
+
var _a59;
|
|
13453
13506
|
if (!this.isConnected()) {
|
|
13454
|
-
(
|
|
13507
|
+
(_a59 = this.reconnectTimer) === null || _a59 === void 0 ? void 0 : _a59.scheduleTimeout();
|
|
13455
13508
|
}
|
|
13456
13509
|
}, CONNECTION_TIMEOUTS.HEARTBEAT_TIMEOUT_FALLBACK);
|
|
13457
13510
|
return;
|
|
@@ -13549,12 +13602,12 @@ Option 2: Install and provide the "ws" package:
|
|
|
13549
13602
|
* @internal
|
|
13550
13603
|
*/
|
|
13551
13604
|
_clearTimer(timer) {
|
|
13552
|
-
var
|
|
13605
|
+
var _a58;
|
|
13553
13606
|
if (timer === "heartbeat" && this.heartbeatTimer) {
|
|
13554
13607
|
clearInterval(this.heartbeatTimer);
|
|
13555
13608
|
this.heartbeatTimer = void 0;
|
|
13556
13609
|
} else if (timer === "reconnect") {
|
|
13557
|
-
(
|
|
13610
|
+
(_a58 = this.reconnectTimer) === null || _a58 === void 0 ? void 0 : _a58.reset();
|
|
13558
13611
|
}
|
|
13559
13612
|
}
|
|
13560
13613
|
/**
|
|
@@ -13669,13 +13722,13 @@ Option 2: Install and provide the "ws" package:
|
|
|
13669
13722
|
}
|
|
13670
13723
|
/** @internal */
|
|
13671
13724
|
_onConnClose(event) {
|
|
13672
|
-
var
|
|
13725
|
+
var _a58;
|
|
13673
13726
|
this._setConnectionState("disconnected");
|
|
13674
13727
|
this.log("transport", "close", event);
|
|
13675
13728
|
this._triggerChanError();
|
|
13676
13729
|
this._clearTimer("heartbeat");
|
|
13677
13730
|
if (!this._wasManualDisconnect) {
|
|
13678
|
-
(
|
|
13731
|
+
(_a58 = this.reconnectTimer) === null || _a58 === void 0 ? void 0 : _a58.scheduleTimeout();
|
|
13679
13732
|
}
|
|
13680
13733
|
this._triggerStateCallbacks("close", event);
|
|
13681
13734
|
}
|
|
@@ -13818,9 +13871,9 @@ Option 2: Install and provide the "ws" package:
|
|
|
13818
13871
|
* @internal
|
|
13819
13872
|
*/
|
|
13820
13873
|
_initializeOptions(options) {
|
|
13821
|
-
var
|
|
13822
|
-
this.transport = (
|
|
13823
|
-
this.timeout = (
|
|
13874
|
+
var _a58, _b5, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
13875
|
+
this.transport = (_a58 = options === null || options === void 0 ? void 0 : options.transport) !== null && _a58 !== void 0 ? _a58 : null;
|
|
13876
|
+
this.timeout = (_b5 = options === null || options === void 0 ? void 0 : options.timeout) !== null && _b5 !== void 0 ? _b5 : DEFAULT_TIMEOUT;
|
|
13824
13877
|
this.heartbeatIntervalMs = (_c = options === null || options === void 0 ? void 0 : options.heartbeatIntervalMs) !== null && _c !== void 0 ? _c : CONNECTION_TIMEOUTS.HEARTBEAT_INTERVAL;
|
|
13825
13878
|
this.worker = (_d = options === null || options === void 0 ? void 0 : options.worker) !== null && _d !== void 0 ? _d : false;
|
|
13826
13879
|
this.accessToken = (_e = options === null || options === void 0 ? void 0 : options.accessToken) !== null && _e !== void 0 ? _e : null;
|
|
@@ -13865,14 +13918,14 @@ Option 2: Install and provide the "ws" package:
|
|
|
13865
13918
|
// node_modules/iceberg-js/dist/index.mjs
|
|
13866
13919
|
var IcebergError = class extends Error {
|
|
13867
13920
|
constructor(message, opts) {
|
|
13868
|
-
var
|
|
13921
|
+
var _a58;
|
|
13869
13922
|
super(message);
|
|
13870
13923
|
this.name = "IcebergError";
|
|
13871
13924
|
this.status = opts.status;
|
|
13872
13925
|
this.icebergType = opts.icebergType;
|
|
13873
13926
|
this.icebergCode = opts.icebergCode;
|
|
13874
13927
|
this.details = opts.details;
|
|
13875
|
-
this.isCommitStateUnknown = opts.icebergType === "CommitStateUnknownException" || [500, 502, 504].includes(opts.status) && ((
|
|
13928
|
+
this.isCommitStateUnknown = opts.icebergType === "CommitStateUnknownException" || [500, 502, 504].includes(opts.status) && ((_a58 = opts.icebergType) == null ? void 0 : _a58.includes("CommitState")) === true;
|
|
13876
13929
|
}
|
|
13877
13930
|
/**
|
|
13878
13931
|
* Returns true if the error is a 404 Not Found error.
|
|
@@ -13920,8 +13973,8 @@ async function buildAuthHeaders(auth) {
|
|
|
13920
13973
|
return {};
|
|
13921
13974
|
}
|
|
13922
13975
|
function createFetchClient(options) {
|
|
13923
|
-
var
|
|
13924
|
-
const fetchFn = (
|
|
13976
|
+
var _a58;
|
|
13977
|
+
const fetchFn = (_a58 = options.fetchImpl) != null ? _a58 : globalThis.fetch;
|
|
13925
13978
|
return {
|
|
13926
13979
|
async request({
|
|
13927
13980
|
method,
|
|
@@ -13930,7 +13983,7 @@ function createFetchClient(options) {
|
|
|
13930
13983
|
body,
|
|
13931
13984
|
headers
|
|
13932
13985
|
}) {
|
|
13933
|
-
var
|
|
13986
|
+
var _a59;
|
|
13934
13987
|
const url = buildUrl(options.baseUrl, path, query);
|
|
13935
13988
|
const authHeaders = await buildAuthHeaders(options.auth);
|
|
13936
13989
|
const res = await fetchFn(url, {
|
|
@@ -13949,7 +14002,7 @@ function createFetchClient(options) {
|
|
|
13949
14002
|
const errBody = isJson ? data : void 0;
|
|
13950
14003
|
const errorDetail = errBody == null ? void 0 : errBody.error;
|
|
13951
14004
|
throw new IcebergError(
|
|
13952
|
-
(
|
|
14005
|
+
(_a59 = errorDetail == null ? void 0 : errorDetail.message) != null ? _a59 : `Request failed with status ${res.status}`,
|
|
13953
14006
|
{
|
|
13954
14007
|
status: res.status,
|
|
13955
14008
|
icebergType: errorDetail == null ? void 0 : errorDetail.type,
|
|
@@ -14072,11 +14125,11 @@ var TableOperations = class {
|
|
|
14072
14125
|
};
|
|
14073
14126
|
}
|
|
14074
14127
|
async dropTable(id, options) {
|
|
14075
|
-
var
|
|
14128
|
+
var _a58;
|
|
14076
14129
|
await this.client.request({
|
|
14077
14130
|
method: "DELETE",
|
|
14078
14131
|
path: `${this.prefix}/namespaces/${namespaceToPath2(id.namespace)}/tables/${id.name}`,
|
|
14079
|
-
query: { purgeRequested: String((
|
|
14132
|
+
query: { purgeRequested: String((_a58 = options == null ? void 0 : options.purge) != null ? _a58 : false) }
|
|
14080
14133
|
});
|
|
14081
14134
|
}
|
|
14082
14135
|
async loadTable(id) {
|
|
@@ -14128,7 +14181,7 @@ var IcebergRestCatalog = class {
|
|
|
14128
14181
|
* @param options - Configuration options for the catalog client
|
|
14129
14182
|
*/
|
|
14130
14183
|
constructor(options) {
|
|
14131
|
-
var
|
|
14184
|
+
var _a58;
|
|
14132
14185
|
let prefix = "v1";
|
|
14133
14186
|
if (options.catalogName) {
|
|
14134
14187
|
prefix += `/${options.catalogName}`;
|
|
@@ -14139,7 +14192,7 @@ var IcebergRestCatalog = class {
|
|
|
14139
14192
|
auth: options.auth,
|
|
14140
14193
|
fetchImpl: options.fetch
|
|
14141
14194
|
});
|
|
14142
|
-
this.accessDelegation = (
|
|
14195
|
+
this.accessDelegation = (_a58 = options.accessDelegation) == null ? void 0 : _a58.join(",");
|
|
14143
14196
|
this.namespaceOps = new NamespaceOperations(this.client, prefix);
|
|
14144
14197
|
this.tableOps = new TableOperations(this.client, prefix, this.accessDelegation);
|
|
14145
14198
|
}
|
|
@@ -17478,7 +17531,7 @@ var getItemAsync = async (storage, key) => {
|
|
|
17478
17531
|
}
|
|
17479
17532
|
try {
|
|
17480
17533
|
return JSON.parse(value);
|
|
17481
|
-
} catch (
|
|
17534
|
+
} catch (_a58) {
|
|
17482
17535
|
return value;
|
|
17483
17536
|
}
|
|
17484
17537
|
};
|
|
@@ -17689,7 +17742,7 @@ function deepClone(obj) {
|
|
|
17689
17742
|
var _getErrorMessage2 = (err) => err.msg || err.message || err.error_description || err.error || JSON.stringify(err);
|
|
17690
17743
|
var NETWORK_ERROR_CODES = [502, 503, 504];
|
|
17691
17744
|
async function handleError2(error) {
|
|
17692
|
-
var
|
|
17745
|
+
var _a58;
|
|
17693
17746
|
if (!looksLikeFetchResponse(error)) {
|
|
17694
17747
|
throw new AuthRetryableFetchError(_getErrorMessage2(error), 0);
|
|
17695
17748
|
}
|
|
@@ -17714,7 +17767,7 @@ async function handleError2(error) {
|
|
|
17714
17767
|
throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, data.weak_password.reasons);
|
|
17715
17768
|
}
|
|
17716
17769
|
} else if (errorCode === "weak_password") {
|
|
17717
|
-
throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, ((
|
|
17770
|
+
throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, ((_a58 = data.weak_password) === null || _a58 === void 0 ? void 0 : _a58.reasons) || []);
|
|
17718
17771
|
} else if (errorCode === "session_not_found") {
|
|
17719
17772
|
throw new AuthSessionMissingError();
|
|
17720
17773
|
}
|
|
@@ -17730,7 +17783,7 @@ var _getRequestParams2 = (method, options, parameters, body) => {
|
|
|
17730
17783
|
return Object.assign(Object.assign({}, params), parameters);
|
|
17731
17784
|
};
|
|
17732
17785
|
async function _request(fetcher, method, url, options) {
|
|
17733
|
-
var
|
|
17786
|
+
var _a58;
|
|
17734
17787
|
const headers = Object.assign({}, options === null || options === void 0 ? void 0 : options.headers);
|
|
17735
17788
|
if (!headers[API_VERSION_HEADER_NAME]) {
|
|
17736
17789
|
headers[API_VERSION_HEADER_NAME] = API_VERSIONS["2024-01-01"].name;
|
|
@@ -17738,7 +17791,7 @@ async function _request(fetcher, method, url, options) {
|
|
|
17738
17791
|
if (options === null || options === void 0 ? void 0 : options.jwt) {
|
|
17739
17792
|
headers["Authorization"] = `Bearer ${options.jwt}`;
|
|
17740
17793
|
}
|
|
17741
|
-
const qs = (
|
|
17794
|
+
const qs = (_a58 = options === null || options === void 0 ? void 0 : options.query) !== null && _a58 !== void 0 ? _a58 : {};
|
|
17742
17795
|
if (options === null || options === void 0 ? void 0 : options.redirectTo) {
|
|
17743
17796
|
qs["redirect_to"] = options.redirectTo;
|
|
17744
17797
|
}
|
|
@@ -17771,7 +17824,7 @@ async function _handleRequest2(fetcher, method, url, options, parameters, body)
|
|
|
17771
17824
|
}
|
|
17772
17825
|
}
|
|
17773
17826
|
function _sessionResponse(data) {
|
|
17774
|
-
var
|
|
17827
|
+
var _a58;
|
|
17775
17828
|
let session = null;
|
|
17776
17829
|
if (hasSession(data)) {
|
|
17777
17830
|
session = Object.assign({}, data);
|
|
@@ -17779,7 +17832,7 @@ function _sessionResponse(data) {
|
|
|
17779
17832
|
session.expires_at = expiresAt(data.expires_in);
|
|
17780
17833
|
}
|
|
17781
17834
|
}
|
|
17782
|
-
const user = (
|
|
17835
|
+
const user = (_a58 = data.user) !== null && _a58 !== void 0 ? _a58 : data;
|
|
17783
17836
|
return { data: { session, user }, error: null };
|
|
17784
17837
|
}
|
|
17785
17838
|
function _sessionResponsePassword(data) {
|
|
@@ -17790,8 +17843,8 @@ function _sessionResponsePassword(data) {
|
|
|
17790
17843
|
return response;
|
|
17791
17844
|
}
|
|
17792
17845
|
function _userResponse(data) {
|
|
17793
|
-
var
|
|
17794
|
-
const user = (
|
|
17846
|
+
var _a58;
|
|
17847
|
+
const user = (_a58 = data.user) !== null && _a58 !== void 0 ? _a58 : data;
|
|
17795
17848
|
return { data: { user }, error: null };
|
|
17796
17849
|
}
|
|
17797
17850
|
function _ssoResponse(data) {
|
|
@@ -17960,14 +18013,14 @@ var GoTrueAdminApi = class {
|
|
|
17960
18013
|
* @param params An object which supports `page` and `perPage` as numbers, to alter the paginated results.
|
|
17961
18014
|
*/
|
|
17962
18015
|
async listUsers(params) {
|
|
17963
|
-
var
|
|
18016
|
+
var _a58, _b5, _c, _d, _e, _f, _g;
|
|
17964
18017
|
try {
|
|
17965
18018
|
const pagination = { nextPage: null, lastPage: 0, total: 0 };
|
|
17966
18019
|
const response = await _request(this.fetch, "GET", `${this.url}/admin/users`, {
|
|
17967
18020
|
headers: this.headers,
|
|
17968
18021
|
noResolveJson: true,
|
|
17969
18022
|
query: {
|
|
17970
|
-
page: (
|
|
18023
|
+
page: (_b5 = (_a58 = params === null || params === void 0 ? void 0 : params.page) === null || _a58 === void 0 ? void 0 : _a58.toString()) !== null && _b5 !== void 0 ? _b5 : "",
|
|
17971
18024
|
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 : ""
|
|
17972
18025
|
},
|
|
17973
18026
|
xform: _noResolveJsonResponse
|
|
@@ -18101,14 +18154,14 @@ var GoTrueAdminApi = class {
|
|
|
18101
18154
|
* This function should only be called on a server. Never expose your `service_role` key in the browser.
|
|
18102
18155
|
*/
|
|
18103
18156
|
async _listOAuthClients(params) {
|
|
18104
|
-
var
|
|
18157
|
+
var _a58, _b5, _c, _d, _e, _f, _g;
|
|
18105
18158
|
try {
|
|
18106
18159
|
const pagination = { nextPage: null, lastPage: 0, total: 0 };
|
|
18107
18160
|
const response = await _request(this.fetch, "GET", `${this.url}/admin/oauth/clients`, {
|
|
18108
18161
|
headers: this.headers,
|
|
18109
18162
|
noResolveJson: true,
|
|
18110
18163
|
query: {
|
|
18111
|
-
page: (
|
|
18164
|
+
page: (_b5 = (_a58 = params === null || params === void 0 ? void 0 : params.page) === null || _a58 === void 0 ? void 0 : _a58.toString()) !== null && _b5 !== void 0 ? _b5 : "",
|
|
18112
18165
|
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 : ""
|
|
18113
18166
|
},
|
|
18114
18167
|
xform: _noResolveJsonResponse
|
|
@@ -18361,7 +18414,7 @@ function toHex(value) {
|
|
|
18361
18414
|
return "0x" + hex;
|
|
18362
18415
|
}
|
|
18363
18416
|
function createSiweMessage(parameters) {
|
|
18364
|
-
var
|
|
18417
|
+
var _a58;
|
|
18365
18418
|
const { chainId, domain, expirationTime, issuedAt = /* @__PURE__ */ new Date(), nonce, notBefore, requestId, resources, scheme, uri, version: version5 } = parameters;
|
|
18366
18419
|
{
|
|
18367
18420
|
if (!Number.isInteger(chainId))
|
|
@@ -18374,7 +18427,7 @@ function createSiweMessage(parameters) {
|
|
|
18374
18427
|
throw new Error(`@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.`);
|
|
18375
18428
|
if (version5 !== "1")
|
|
18376
18429
|
throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${version5}`);
|
|
18377
|
-
if ((
|
|
18430
|
+
if ((_a58 = parameters.statement) === null || _a58 === void 0 ? void 0 : _a58.includes("\n"))
|
|
18378
18431
|
throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${parameters.statement}`);
|
|
18379
18432
|
}
|
|
18380
18433
|
const address = getAddress(parameters.address);
|
|
@@ -18416,10 +18469,10 @@ ${suffix}`;
|
|
|
18416
18469
|
// node_modules/@supabase/auth-js/dist/module/lib/webauthn.errors.js
|
|
18417
18470
|
var WebAuthnError = class extends Error {
|
|
18418
18471
|
constructor({ message, code, cause, name }) {
|
|
18419
|
-
var
|
|
18472
|
+
var _a58;
|
|
18420
18473
|
super(message, { cause });
|
|
18421
18474
|
this.__isWebAuthnError = true;
|
|
18422
|
-
this.name = (
|
|
18475
|
+
this.name = (_a58 = name !== null && name !== void 0 ? name : cause instanceof Error ? cause.name : void 0) !== null && _a58 !== void 0 ? _a58 : "Unknown Error";
|
|
18423
18476
|
this.code = code;
|
|
18424
18477
|
}
|
|
18425
18478
|
};
|
|
@@ -18435,7 +18488,7 @@ var WebAuthnUnknownError = class extends WebAuthnError {
|
|
|
18435
18488
|
}
|
|
18436
18489
|
};
|
|
18437
18490
|
function identifyRegistrationError({ error, options }) {
|
|
18438
|
-
var
|
|
18491
|
+
var _a58, _b5, _c;
|
|
18439
18492
|
const { publicKey } = options;
|
|
18440
18493
|
if (!publicKey) {
|
|
18441
18494
|
throw Error("options was missing required publicKey property");
|
|
@@ -18449,7 +18502,7 @@ function identifyRegistrationError({ error, options }) {
|
|
|
18449
18502
|
});
|
|
18450
18503
|
}
|
|
18451
18504
|
} else if (error.name === "ConstraintError") {
|
|
18452
|
-
if (((
|
|
18505
|
+
if (((_a58 = publicKey.authenticatorSelection) === null || _a58 === void 0 ? void 0 : _a58.requireResidentKey) === true) {
|
|
18453
18506
|
return new WebAuthnError({
|
|
18454
18507
|
message: "Discoverable credentials were required but no available authenticator supported it",
|
|
18455
18508
|
code: "ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",
|
|
@@ -18457,7 +18510,7 @@ function identifyRegistrationError({ error, options }) {
|
|
|
18457
18510
|
});
|
|
18458
18511
|
} else if (
|
|
18459
18512
|
// @ts-ignore: `mediation` doesn't yet exist on CredentialCreationOptions but it's possible as of Sept 2024
|
|
18460
|
-
options.mediation === "conditional" && ((
|
|
18513
|
+
options.mediation === "conditional" && ((_b5 = publicKey.authenticatorSelection) === null || _b5 === void 0 ? void 0 : _b5.userVerification) === "required"
|
|
18461
18514
|
) {
|
|
18462
18515
|
return new WebAuthnError({
|
|
18463
18516
|
message: "User verification was required during automatic registration but it could not be performed",
|
|
@@ -18678,7 +18731,7 @@ function deserializeCredentialRequestOptions(options) {
|
|
|
18678
18731
|
return result;
|
|
18679
18732
|
}
|
|
18680
18733
|
function serializeCredentialCreationResponse(credential) {
|
|
18681
|
-
var
|
|
18734
|
+
var _a58;
|
|
18682
18735
|
if ("toJSON" in credential && typeof credential.toJSON === "function") {
|
|
18683
18736
|
return credential.toJSON();
|
|
18684
18737
|
}
|
|
@@ -18693,11 +18746,11 @@ function serializeCredentialCreationResponse(credential) {
|
|
|
18693
18746
|
type: "public-key",
|
|
18694
18747
|
clientExtensionResults: credential.getClientExtensionResults(),
|
|
18695
18748
|
// Convert null to undefined and cast to AuthenticatorAttachment type
|
|
18696
|
-
authenticatorAttachment: (
|
|
18749
|
+
authenticatorAttachment: (_a58 = credentialWithAttachment.authenticatorAttachment) !== null && _a58 !== void 0 ? _a58 : void 0
|
|
18697
18750
|
};
|
|
18698
18751
|
}
|
|
18699
18752
|
function serializeCredentialRequestResponse(credential) {
|
|
18700
|
-
var
|
|
18753
|
+
var _a58;
|
|
18701
18754
|
if ("toJSON" in credential && typeof credential.toJSON === "function") {
|
|
18702
18755
|
return credential.toJSON();
|
|
18703
18756
|
}
|
|
@@ -18717,7 +18770,7 @@ function serializeCredentialRequestResponse(credential) {
|
|
|
18717
18770
|
type: "public-key",
|
|
18718
18771
|
clientExtensionResults,
|
|
18719
18772
|
// Convert null to undefined and cast to AuthenticatorAttachment type
|
|
18720
|
-
authenticatorAttachment: (
|
|
18773
|
+
authenticatorAttachment: (_a58 = credentialWithAttachment.authenticatorAttachment) !== null && _a58 !== void 0 ? _a58 : void 0
|
|
18721
18774
|
};
|
|
18722
18775
|
}
|
|
18723
18776
|
function isValidDomain(hostname) {
|
|
@@ -18727,8 +18780,8 @@ function isValidDomain(hostname) {
|
|
|
18727
18780
|
);
|
|
18728
18781
|
}
|
|
18729
18782
|
function browserSupportsWebAuthn() {
|
|
18730
|
-
var
|
|
18731
|
-
return !!(isBrowser() && "PublicKeyCredential" in window && window.PublicKeyCredential && "credentials" in navigator && typeof ((
|
|
18783
|
+
var _a58, _b5;
|
|
18784
|
+
return !!(isBrowser() && "PublicKeyCredential" in window && window.PublicKeyCredential && "credentials" in navigator && typeof ((_a58 = navigator === null || navigator === void 0 ? void 0 : navigator.credentials) === null || _a58 === void 0 ? void 0 : _a58.create) === "function" && typeof ((_b5 = navigator === null || navigator === void 0 ? void 0 : navigator.credentials) === null || _b5 === void 0 ? void 0 : _b5.get) === "function");
|
|
18732
18785
|
}
|
|
18733
18786
|
async function createCredential(options) {
|
|
18734
18787
|
try {
|
|
@@ -19057,8 +19110,8 @@ var WebAuthnApi = class {
|
|
|
19057
19110
|
});
|
|
19058
19111
|
if (!factor) {
|
|
19059
19112
|
await this.client.mfa.listFactors().then((factors) => {
|
|
19060
|
-
var
|
|
19061
|
-
return (
|
|
19113
|
+
var _a58;
|
|
19114
|
+
return (_a58 = factors.data) === null || _a58 === void 0 ? void 0 : _a58.all.find((v) => v.factor_type === "webauthn" && v.friendly_name === friendlyName && v.status !== "unverified");
|
|
19062
19115
|
}).then((factor2) => factor2 ? this.client.mfa.unenroll({ factorId: factor2 === null || factor2 === void 0 ? void 0 : factor2.id }) : void 0);
|
|
19063
19116
|
return { data: null, error: enrollError };
|
|
19064
19117
|
}
|
|
@@ -19120,15 +19173,15 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
19120
19173
|
* The JWKS used for verifying asymmetric JWTs
|
|
19121
19174
|
*/
|
|
19122
19175
|
get jwks() {
|
|
19123
|
-
var
|
|
19124
|
-
return (
|
|
19176
|
+
var _a58, _b5;
|
|
19177
|
+
return (_b5 = (_a58 = GLOBAL_JWKS[this.storageKey]) === null || _a58 === void 0 ? void 0 : _a58.jwks) !== null && _b5 !== void 0 ? _b5 : { keys: [] };
|
|
19125
19178
|
}
|
|
19126
19179
|
set jwks(value) {
|
|
19127
19180
|
GLOBAL_JWKS[this.storageKey] = Object.assign(Object.assign({}, GLOBAL_JWKS[this.storageKey]), { jwks: value });
|
|
19128
19181
|
}
|
|
19129
19182
|
get jwks_cached_at() {
|
|
19130
|
-
var
|
|
19131
|
-
return (
|
|
19183
|
+
var _a58, _b5;
|
|
19184
|
+
return (_b5 = (_a58 = GLOBAL_JWKS[this.storageKey]) === null || _a58 === void 0 ? void 0 : _a58.cachedAt) !== null && _b5 !== void 0 ? _b5 : Number.MIN_SAFE_INTEGER;
|
|
19132
19185
|
}
|
|
19133
19186
|
set jwks_cached_at(value) {
|
|
19134
19187
|
GLOBAL_JWKS[this.storageKey] = Object.assign(Object.assign({}, GLOBAL_JWKS[this.storageKey]), { cachedAt: value });
|
|
@@ -19148,7 +19201,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
19148
19201
|
* ```
|
|
19149
19202
|
*/
|
|
19150
19203
|
constructor(options) {
|
|
19151
|
-
var
|
|
19204
|
+
var _a58, _b5, _c;
|
|
19152
19205
|
this.userStorage = null;
|
|
19153
19206
|
this.memoryStorage = null;
|
|
19154
19207
|
this.stateChangeEmitters = /* @__PURE__ */ new Map();
|
|
@@ -19166,7 +19219,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
19166
19219
|
this.logger = console.log;
|
|
19167
19220
|
const settings = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options);
|
|
19168
19221
|
this.storageKey = settings.storageKey;
|
|
19169
|
-
this.instanceID = (
|
|
19222
|
+
this.instanceID = (_a58 = _GoTrueClient.nextInstanceID[this.storageKey]) !== null && _a58 !== void 0 ? _a58 : 0;
|
|
19170
19223
|
_GoTrueClient.nextInstanceID[this.storageKey] = this.instanceID + 1;
|
|
19171
19224
|
this.logDebugMessages = !!settings.debug;
|
|
19172
19225
|
if (typeof settings.debug === "function") {
|
|
@@ -19197,7 +19250,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
19197
19250
|
this.lockAcquireTimeout = settings.lockAcquireTimeout;
|
|
19198
19251
|
if (settings.lock) {
|
|
19199
19252
|
this.lock = settings.lock;
|
|
19200
|
-
} else if (this.persistSession && isBrowser() && ((
|
|
19253
|
+
} else if (this.persistSession && isBrowser() && ((_b5 = globalThis === null || globalThis === void 0 ? void 0 : globalThis.navigator) === null || _b5 === void 0 ? void 0 : _b5.locks)) {
|
|
19201
19254
|
this.lock = navigatorLock;
|
|
19202
19255
|
} else {
|
|
19203
19256
|
this.lock = lockNoOp;
|
|
@@ -19303,7 +19356,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
19303
19356
|
* the whole lifetime of the client
|
|
19304
19357
|
*/
|
|
19305
19358
|
async _initialize() {
|
|
19306
|
-
var
|
|
19359
|
+
var _a58;
|
|
19307
19360
|
try {
|
|
19308
19361
|
let params = {};
|
|
19309
19362
|
let callbackUrlType = "none";
|
|
@@ -19320,7 +19373,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
19320
19373
|
if (error) {
|
|
19321
19374
|
this._debug("#_initialize()", "error detecting session from URL", error);
|
|
19322
19375
|
if (isAuthImplicitGrantRedirectError(error)) {
|
|
19323
|
-
const errorCode = (
|
|
19376
|
+
const errorCode = (_a58 = error.details) === null || _a58 === void 0 ? void 0 : _a58.code;
|
|
19324
19377
|
if (errorCode === "identity_already_exists" || errorCode === "identity_not_found" || errorCode === "single_identity_not_deletable") {
|
|
19325
19378
|
return { error };
|
|
19326
19379
|
}
|
|
@@ -19359,12 +19412,12 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
19359
19412
|
* @returns A session where the is_anonymous claim in the access token JWT set to true
|
|
19360
19413
|
*/
|
|
19361
19414
|
async signInAnonymously(credentials) {
|
|
19362
|
-
var
|
|
19415
|
+
var _a58, _b5, _c;
|
|
19363
19416
|
try {
|
|
19364
19417
|
const res = await _request(this.fetch, "POST", `${this.url}/signup`, {
|
|
19365
19418
|
headers: this.headers,
|
|
19366
19419
|
body: {
|
|
19367
|
-
data: (
|
|
19420
|
+
data: (_b5 = (_a58 = credentials === null || credentials === void 0 ? void 0 : credentials.options) === null || _a58 === void 0 ? void 0 : _a58.data) !== null && _b5 !== void 0 ? _b5 : {},
|
|
19368
19421
|
gotrue_meta_security: { captcha_token: (_c = credentials === null || credentials === void 0 ? void 0 : credentials.options) === null || _c === void 0 ? void 0 : _c.captchaToken }
|
|
19369
19422
|
},
|
|
19370
19423
|
xform: _sessionResponse
|
|
@@ -19398,7 +19451,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
19398
19451
|
* @returns A user if the server has "autoconfirm" OFF
|
|
19399
19452
|
*/
|
|
19400
19453
|
async signUp(credentials) {
|
|
19401
|
-
var
|
|
19454
|
+
var _a58, _b5, _c;
|
|
19402
19455
|
try {
|
|
19403
19456
|
let res;
|
|
19404
19457
|
if ("email" in credentials) {
|
|
@@ -19415,7 +19468,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
19415
19468
|
body: {
|
|
19416
19469
|
email,
|
|
19417
19470
|
password,
|
|
19418
|
-
data: (
|
|
19471
|
+
data: (_a58 = options === null || options === void 0 ? void 0 : options.data) !== null && _a58 !== void 0 ? _a58 : {},
|
|
19419
19472
|
gotrue_meta_security: { captcha_token: options === null || options === void 0 ? void 0 : options.captchaToken },
|
|
19420
19473
|
code_challenge: codeChallenge,
|
|
19421
19474
|
code_challenge_method: codeChallengeMethod
|
|
@@ -19429,7 +19482,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
19429
19482
|
body: {
|
|
19430
19483
|
phone,
|
|
19431
19484
|
password,
|
|
19432
|
-
data: (
|
|
19485
|
+
data: (_b5 = options === null || options === void 0 ? void 0 : options.data) !== null && _b5 !== void 0 ? _b5 : {},
|
|
19433
19486
|
channel: (_c = options === null || options === void 0 ? void 0 : options.channel) !== null && _c !== void 0 ? _c : "sms",
|
|
19434
19487
|
gotrue_meta_security: { captcha_token: options === null || options === void 0 ? void 0 : options.captchaToken }
|
|
19435
19488
|
},
|
|
@@ -19521,10 +19574,10 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
19521
19574
|
* This method supports the PKCE flow.
|
|
19522
19575
|
*/
|
|
19523
19576
|
async signInWithOAuth(credentials) {
|
|
19524
|
-
var
|
|
19577
|
+
var _a58, _b5, _c, _d;
|
|
19525
19578
|
return await this._handleProviderSignIn(credentials.provider, {
|
|
19526
|
-
redirectTo: (
|
|
19527
|
-
scopes: (
|
|
19579
|
+
redirectTo: (_a58 = credentials.options) === null || _a58 === void 0 ? void 0 : _a58.redirectTo,
|
|
19580
|
+
scopes: (_b5 = credentials.options) === null || _b5 === void 0 ? void 0 : _b5.scopes,
|
|
19528
19581
|
queryParams: (_c = credentials.options) === null || _c === void 0 ? void 0 : _c.queryParams,
|
|
19529
19582
|
skipBrowserRedirect: (_d = credentials.options) === null || _d === void 0 ? void 0 : _d.skipBrowserRedirect
|
|
19530
19583
|
});
|
|
@@ -19557,7 +19610,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
19557
19610
|
}
|
|
19558
19611
|
}
|
|
19559
19612
|
async signInWithEthereum(credentials) {
|
|
19560
|
-
var
|
|
19613
|
+
var _a58, _b5, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
19561
19614
|
let message;
|
|
19562
19615
|
let signature;
|
|
19563
19616
|
if ("message" in credentials) {
|
|
@@ -19581,7 +19634,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
19581
19634
|
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.`);
|
|
19582
19635
|
}
|
|
19583
19636
|
}
|
|
19584
|
-
const url = new URL((
|
|
19637
|
+
const url = new URL((_a58 = options === null || options === void 0 ? void 0 : options.url) !== null && _a58 !== void 0 ? _a58 : window.location.href);
|
|
19585
19638
|
const accounts = await resolvedWallet.request({
|
|
19586
19639
|
method: "eth_requestAccounts"
|
|
19587
19640
|
}).then((accs) => accs).catch(() => {
|
|
@@ -19591,7 +19644,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
19591
19644
|
throw new Error(`@supabase/auth-js: No accounts available. Please ensure the wallet is connected.`);
|
|
19592
19645
|
}
|
|
19593
19646
|
const address = getAddress(accounts[0]);
|
|
19594
|
-
let chainId = (
|
|
19647
|
+
let chainId = (_b5 = options === null || options === void 0 ? void 0 : options.signInWithEthereum) === null || _b5 === void 0 ? void 0 : _b5.chainId;
|
|
19595
19648
|
if (!chainId) {
|
|
19596
19649
|
const chainIdHex = await resolvedWallet.request({
|
|
19597
19650
|
method: "eth_chainId"
|
|
@@ -19648,7 +19701,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
19648
19701
|
}
|
|
19649
19702
|
}
|
|
19650
19703
|
async signInWithSolana(credentials) {
|
|
19651
|
-
var
|
|
19704
|
+
var _a58, _b5, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
19652
19705
|
let message;
|
|
19653
19706
|
let signature;
|
|
19654
19707
|
if ("message" in credentials) {
|
|
@@ -19672,7 +19725,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
19672
19725
|
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.`);
|
|
19673
19726
|
}
|
|
19674
19727
|
}
|
|
19675
|
-
const url = new URL((
|
|
19728
|
+
const url = new URL((_a58 = options === null || options === void 0 ? void 0 : options.url) !== null && _a58 !== void 0 ? _a58 : window.location.href);
|
|
19676
19729
|
if ("signIn" in resolvedWallet && resolvedWallet.signIn) {
|
|
19677
19730
|
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), {
|
|
19678
19731
|
// non-overridable properties
|
|
@@ -19704,7 +19757,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
19704
19757
|
...statement ? ["", statement, ""] : [""],
|
|
19705
19758
|
"Version: 1",
|
|
19706
19759
|
`URI: ${url.href}`,
|
|
19707
|
-
`Issued At: ${(_c = (
|
|
19760
|
+
`Issued At: ${(_c = (_b5 = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _b5 === void 0 ? void 0 : _b5.issuedAt) !== null && _c !== void 0 ? _c : (/* @__PURE__ */ new Date()).toISOString()}`,
|
|
19708
19761
|
...((_d = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _d === void 0 ? void 0 : _d.notBefore) ? [`Not Before: ${options.signInWithSolana.notBefore}`] : [],
|
|
19709
19762
|
...((_e = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _e === void 0 ? void 0 : _e.expirationTime) ? [`Expiration Time: ${options.signInWithSolana.expirationTime}`] : [],
|
|
19710
19763
|
...((_f = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _f === void 0 ? void 0 : _f.chainId) ? [`Chain ID: ${options.signInWithSolana.chainId}`] : [],
|
|
@@ -19846,7 +19899,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
19846
19899
|
* This method supports PKCE when an email is passed.
|
|
19847
19900
|
*/
|
|
19848
19901
|
async signInWithOtp(credentials) {
|
|
19849
|
-
var
|
|
19902
|
+
var _a58, _b5, _c, _d, _e;
|
|
19850
19903
|
try {
|
|
19851
19904
|
if ("email" in credentials) {
|
|
19852
19905
|
const { email, options } = credentials;
|
|
@@ -19860,8 +19913,8 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
19860
19913
|
headers: this.headers,
|
|
19861
19914
|
body: {
|
|
19862
19915
|
email,
|
|
19863
|
-
data: (
|
|
19864
|
-
create_user: (
|
|
19916
|
+
data: (_a58 = options === null || options === void 0 ? void 0 : options.data) !== null && _a58 !== void 0 ? _a58 : {},
|
|
19917
|
+
create_user: (_b5 = options === null || options === void 0 ? void 0 : options.shouldCreateUser) !== null && _b5 !== void 0 ? _b5 : true,
|
|
19865
19918
|
gotrue_meta_security: { captcha_token: options === null || options === void 0 ? void 0 : options.captchaToken },
|
|
19866
19919
|
code_challenge: codeChallenge,
|
|
19867
19920
|
code_challenge_method: codeChallengeMethod
|
|
@@ -19900,13 +19953,13 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
19900
19953
|
* Log in a user given a User supplied OTP or TokenHash received through mobile or email.
|
|
19901
19954
|
*/
|
|
19902
19955
|
async verifyOtp(params) {
|
|
19903
|
-
var
|
|
19956
|
+
var _a58, _b5;
|
|
19904
19957
|
try {
|
|
19905
19958
|
let redirectTo = void 0;
|
|
19906
19959
|
let captchaToken = void 0;
|
|
19907
19960
|
if ("options" in params) {
|
|
19908
|
-
redirectTo = (
|
|
19909
|
-
captchaToken = (
|
|
19961
|
+
redirectTo = (_a58 = params.options) === null || _a58 === void 0 ? void 0 : _a58.redirectTo;
|
|
19962
|
+
captchaToken = (_b5 = params.options) === null || _b5 === void 0 ? void 0 : _b5.captchaToken;
|
|
19910
19963
|
}
|
|
19911
19964
|
const { data, error } = await _request(this.fetch, "POST", `${this.url}/verify`, {
|
|
19912
19965
|
headers: this.headers,
|
|
@@ -19950,7 +20003,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
19950
20003
|
* organization's SSO Identity Provider UUID directly instead.
|
|
19951
20004
|
*/
|
|
19952
20005
|
async signInWithSSO(params) {
|
|
19953
|
-
var
|
|
20006
|
+
var _a58, _b5, _c, _d, _e;
|
|
19954
20007
|
try {
|
|
19955
20008
|
let codeChallenge = null;
|
|
19956
20009
|
let codeChallengeMethod = null;
|
|
@@ -19959,7 +20012,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
19959
20012
|
[codeChallenge, codeChallengeMethod] = await getCodeChallengeAndMethod(this.storage, this.storageKey);
|
|
19960
20013
|
}
|
|
19961
20014
|
const result = await _request(this.fetch, "POST", `${this.url}/sso`, {
|
|
19962
|
-
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: (
|
|
20015
|
+
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: (_b5 = (_a58 = params.options) === null || _a58 === void 0 ? void 0 : _a58.redirectTo) !== null && _b5 !== void 0 ? _b5 : 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 }),
|
|
19963
20016
|
headers: this.headers,
|
|
19964
20017
|
xform: _ssoResponse
|
|
19965
20018
|
});
|
|
@@ -20213,17 +20266,17 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
20213
20266
|
});
|
|
20214
20267
|
}
|
|
20215
20268
|
return await this._useSession(async (result) => {
|
|
20216
|
-
var
|
|
20269
|
+
var _a58, _b5, _c;
|
|
20217
20270
|
const { data, error } = result;
|
|
20218
20271
|
if (error) {
|
|
20219
20272
|
throw error;
|
|
20220
20273
|
}
|
|
20221
|
-
if (!((
|
|
20274
|
+
if (!((_a58 = data.session) === null || _a58 === void 0 ? void 0 : _a58.access_token) && !this.hasCustomAuthorizationHeader) {
|
|
20222
20275
|
return { data: { user: null }, error: new AuthSessionMissingError() };
|
|
20223
20276
|
}
|
|
20224
20277
|
return await _request(this.fetch, "GET", `${this.url}/user`, {
|
|
20225
20278
|
headers: this.headers,
|
|
20226
|
-
jwt: (_c = (
|
|
20279
|
+
jwt: (_c = (_b5 = data.session) === null || _b5 === void 0 ? void 0 : _b5.access_token) !== null && _c !== void 0 ? _c : void 0,
|
|
20227
20280
|
xform: _userResponse
|
|
20228
20281
|
});
|
|
20229
20282
|
});
|
|
@@ -20360,13 +20413,13 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
20360
20413
|
async _refreshSession(currentSession) {
|
|
20361
20414
|
try {
|
|
20362
20415
|
return await this._useSession(async (result) => {
|
|
20363
|
-
var
|
|
20416
|
+
var _a58;
|
|
20364
20417
|
if (!currentSession) {
|
|
20365
20418
|
const { data, error: error2 } = result;
|
|
20366
20419
|
if (error2) {
|
|
20367
20420
|
throw error2;
|
|
20368
20421
|
}
|
|
20369
|
-
currentSession = (
|
|
20422
|
+
currentSession = (_a58 = data.session) !== null && _a58 !== void 0 ? _a58 : void 0;
|
|
20370
20423
|
}
|
|
20371
20424
|
if (!(currentSession === null || currentSession === void 0 ? void 0 : currentSession.refresh_token)) {
|
|
20372
20425
|
throw new AuthSessionMissingError();
|
|
@@ -20504,12 +20557,12 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
20504
20557
|
}
|
|
20505
20558
|
async _signOut({ scope } = { scope: "global" }) {
|
|
20506
20559
|
return await this._useSession(async (result) => {
|
|
20507
|
-
var
|
|
20560
|
+
var _a58;
|
|
20508
20561
|
const { data, error: sessionError } = result;
|
|
20509
20562
|
if (sessionError) {
|
|
20510
20563
|
return this._returnResult({ error: sessionError });
|
|
20511
20564
|
}
|
|
20512
|
-
const accessToken = (
|
|
20565
|
+
const accessToken = (_a58 = data.session) === null || _a58 === void 0 ? void 0 : _a58.access_token;
|
|
20513
20566
|
if (accessToken) {
|
|
20514
20567
|
const { error } = await this.admin.signOut(accessToken, scope);
|
|
20515
20568
|
if (error) {
|
|
@@ -20547,15 +20600,15 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
20547
20600
|
}
|
|
20548
20601
|
async _emitInitialSession(id) {
|
|
20549
20602
|
return await this._useSession(async (result) => {
|
|
20550
|
-
var
|
|
20603
|
+
var _a58, _b5;
|
|
20551
20604
|
try {
|
|
20552
20605
|
const { data: { session }, error } = result;
|
|
20553
20606
|
if (error)
|
|
20554
20607
|
throw error;
|
|
20555
|
-
await ((
|
|
20608
|
+
await ((_a58 = this.stateChangeEmitters.get(id)) === null || _a58 === void 0 ? void 0 : _a58.callback("INITIAL_SESSION", session));
|
|
20556
20609
|
this._debug("INITIAL_SESSION", "callback id", id, "session", session);
|
|
20557
20610
|
} catch (err) {
|
|
20558
|
-
await ((
|
|
20611
|
+
await ((_b5 = this.stateChangeEmitters.get(id)) === null || _b5 === void 0 ? void 0 : _b5.callback("INITIAL_SESSION", null));
|
|
20559
20612
|
this._debug("INITIAL_SESSION", "callback id", id, "error", err);
|
|
20560
20613
|
console.error(err);
|
|
20561
20614
|
}
|
|
@@ -20603,12 +20656,12 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
20603
20656
|
* Gets all the identities linked to a user.
|
|
20604
20657
|
*/
|
|
20605
20658
|
async getUserIdentities() {
|
|
20606
|
-
var
|
|
20659
|
+
var _a58;
|
|
20607
20660
|
try {
|
|
20608
20661
|
const { data, error } = await this.getUser();
|
|
20609
20662
|
if (error)
|
|
20610
20663
|
throw error;
|
|
20611
|
-
return this._returnResult({ data: { identities: (
|
|
20664
|
+
return this._returnResult({ data: { identities: (_a58 = data.user.identities) !== null && _a58 !== void 0 ? _a58 : [] }, error: null });
|
|
20612
20665
|
} catch (error) {
|
|
20613
20666
|
if (isAuthError(error)) {
|
|
20614
20667
|
return this._returnResult({ data: null, error });
|
|
@@ -20623,16 +20676,16 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
20623
20676
|
return this.linkIdentityOAuth(credentials);
|
|
20624
20677
|
}
|
|
20625
20678
|
async linkIdentityOAuth(credentials) {
|
|
20626
|
-
var
|
|
20679
|
+
var _a58;
|
|
20627
20680
|
try {
|
|
20628
20681
|
const { data, error } = await this._useSession(async (result) => {
|
|
20629
|
-
var
|
|
20682
|
+
var _a59, _b5, _c, _d, _e;
|
|
20630
20683
|
const { data: data2, error: error2 } = result;
|
|
20631
20684
|
if (error2)
|
|
20632
20685
|
throw error2;
|
|
20633
20686
|
const url = await this._getUrlForProvider(`${this.url}/user/identities/authorize`, credentials.provider, {
|
|
20634
|
-
redirectTo: (
|
|
20635
|
-
scopes: (
|
|
20687
|
+
redirectTo: (_a59 = credentials.options) === null || _a59 === void 0 ? void 0 : _a59.redirectTo,
|
|
20688
|
+
scopes: (_b5 = credentials.options) === null || _b5 === void 0 ? void 0 : _b5.scopes,
|
|
20636
20689
|
queryParams: (_c = credentials.options) === null || _c === void 0 ? void 0 : _c.queryParams,
|
|
20637
20690
|
skipBrowserRedirect: true
|
|
20638
20691
|
});
|
|
@@ -20643,7 +20696,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
20643
20696
|
});
|
|
20644
20697
|
if (error)
|
|
20645
20698
|
throw error;
|
|
20646
|
-
if (isBrowser() && !((
|
|
20699
|
+
if (isBrowser() && !((_a58 = credentials.options) === null || _a58 === void 0 ? void 0 : _a58.skipBrowserRedirect)) {
|
|
20647
20700
|
window.location.assign(data === null || data === void 0 ? void 0 : data.url);
|
|
20648
20701
|
}
|
|
20649
20702
|
return this._returnResult({
|
|
@@ -20659,7 +20712,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
20659
20712
|
}
|
|
20660
20713
|
async linkIdentityIdToken(credentials) {
|
|
20661
20714
|
return await this._useSession(async (result) => {
|
|
20662
|
-
var
|
|
20715
|
+
var _a58;
|
|
20663
20716
|
try {
|
|
20664
20717
|
const { error: sessionError, data: { session } } = result;
|
|
20665
20718
|
if (sessionError)
|
|
@@ -20667,7 +20720,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
20667
20720
|
const { options, provider, token, access_token, nonce } = credentials;
|
|
20668
20721
|
const res = await _request(this.fetch, "POST", `${this.url}/token?grant_type=id_token`, {
|
|
20669
20722
|
headers: this.headers,
|
|
20670
|
-
jwt: (
|
|
20723
|
+
jwt: (_a58 = session === null || session === void 0 ? void 0 : session.access_token) !== null && _a58 !== void 0 ? _a58 : void 0,
|
|
20671
20724
|
body: {
|
|
20672
20725
|
provider,
|
|
20673
20726
|
id_token: token,
|
|
@@ -20707,14 +20760,14 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
20707
20760
|
async unlinkIdentity(identity) {
|
|
20708
20761
|
try {
|
|
20709
20762
|
return await this._useSession(async (result) => {
|
|
20710
|
-
var
|
|
20763
|
+
var _a58, _b5;
|
|
20711
20764
|
const { data, error } = result;
|
|
20712
20765
|
if (error) {
|
|
20713
20766
|
throw error;
|
|
20714
20767
|
}
|
|
20715
20768
|
return await _request(this.fetch, "DELETE", `${this.url}/user/identities/${identity.identity_id}`, {
|
|
20716
20769
|
headers: this.headers,
|
|
20717
|
-
jwt: (
|
|
20770
|
+
jwt: (_b5 = (_a58 = data.session) === null || _a58 === void 0 ? void 0 : _a58.access_token) !== null && _b5 !== void 0 ? _b5 : void 0
|
|
20718
20771
|
});
|
|
20719
20772
|
});
|
|
20720
20773
|
} catch (error) {
|
|
@@ -20779,7 +20832,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
20779
20832
|
* Note: this method is async to accommodate for AsyncStorage e.g. in React native.
|
|
20780
20833
|
*/
|
|
20781
20834
|
async _recoverAndRefresh() {
|
|
20782
|
-
var
|
|
20835
|
+
var _a58, _b5;
|
|
20783
20836
|
const debugName = "#_recoverAndRefresh()";
|
|
20784
20837
|
this._debug(debugName, "begin");
|
|
20785
20838
|
try {
|
|
@@ -20790,7 +20843,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
20790
20843
|
maybeUser = { user: currentSession.user };
|
|
20791
20844
|
await setItemAsync(this.userStorage, this.storageKey + "-user", maybeUser);
|
|
20792
20845
|
}
|
|
20793
|
-
currentSession.user = (
|
|
20846
|
+
currentSession.user = (_a58 = maybeUser === null || maybeUser === void 0 ? void 0 : maybeUser.user) !== null && _a58 !== void 0 ? _a58 : userNotAvailableProxy();
|
|
20794
20847
|
} else if (currentSession && !currentSession.user) {
|
|
20795
20848
|
if (!currentSession.user) {
|
|
20796
20849
|
const separateUser = await getItemAsync(this.storage, this.storageKey + "-user");
|
|
@@ -20811,7 +20864,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
20811
20864
|
}
|
|
20812
20865
|
return;
|
|
20813
20866
|
}
|
|
20814
|
-
const expiresWithMargin = ((
|
|
20867
|
+
const expiresWithMargin = ((_b5 = currentSession.expires_at) !== null && _b5 !== void 0 ? _b5 : Infinity) * 1e3 - Date.now() < EXPIRY_MARGIN_MS;
|
|
20815
20868
|
this._debug(debugName, `session has${expiresWithMargin ? "" : " not"} expired with margin of ${EXPIRY_MARGIN_MS}s`);
|
|
20816
20869
|
if (expiresWithMargin) {
|
|
20817
20870
|
if (this.autoRefreshToken && currentSession.refresh_token) {
|
|
@@ -20850,7 +20903,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
20850
20903
|
}
|
|
20851
20904
|
}
|
|
20852
20905
|
async _callRefreshToken(refreshToken) {
|
|
20853
|
-
var
|
|
20906
|
+
var _a58, _b5;
|
|
20854
20907
|
if (!refreshToken) {
|
|
20855
20908
|
throw new AuthSessionMissingError();
|
|
20856
20909
|
}
|
|
@@ -20878,10 +20931,10 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
20878
20931
|
if (!isAuthRetryableFetchError(error)) {
|
|
20879
20932
|
await this._removeSession();
|
|
20880
20933
|
}
|
|
20881
|
-
(
|
|
20934
|
+
(_a58 = this.refreshingDeferred) === null || _a58 === void 0 ? void 0 : _a58.resolve(result);
|
|
20882
20935
|
return result;
|
|
20883
20936
|
}
|
|
20884
|
-
(
|
|
20937
|
+
(_b5 = this.refreshingDeferred) === null || _b5 === void 0 ? void 0 : _b5.reject(error);
|
|
20885
20938
|
throw error;
|
|
20886
20939
|
} finally {
|
|
20887
20940
|
this.refreshingDeferred = null;
|
|
@@ -21167,14 +21220,14 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
21167
21220
|
async _unenroll(params) {
|
|
21168
21221
|
try {
|
|
21169
21222
|
return await this._useSession(async (result) => {
|
|
21170
|
-
var
|
|
21223
|
+
var _a58;
|
|
21171
21224
|
const { data: sessionData, error: sessionError } = result;
|
|
21172
21225
|
if (sessionError) {
|
|
21173
21226
|
return this._returnResult({ data: null, error: sessionError });
|
|
21174
21227
|
}
|
|
21175
21228
|
return await _request(this.fetch, "DELETE", `${this.url}/factors/${params.factorId}`, {
|
|
21176
21229
|
headers: this.headers,
|
|
21177
|
-
jwt: (
|
|
21230
|
+
jwt: (_a58 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a58 === void 0 ? void 0 : _a58.access_token
|
|
21178
21231
|
});
|
|
21179
21232
|
});
|
|
21180
21233
|
} catch (error) {
|
|
@@ -21187,7 +21240,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
21187
21240
|
async _enroll(params) {
|
|
21188
21241
|
try {
|
|
21189
21242
|
return await this._useSession(async (result) => {
|
|
21190
|
-
var
|
|
21243
|
+
var _a58, _b5;
|
|
21191
21244
|
const { data: sessionData, error: sessionError } = result;
|
|
21192
21245
|
if (sessionError) {
|
|
21193
21246
|
return this._returnResult({ data: null, error: sessionError });
|
|
@@ -21196,12 +21249,12 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
21196
21249
|
const { data, error } = await _request(this.fetch, "POST", `${this.url}/factors`, {
|
|
21197
21250
|
body,
|
|
21198
21251
|
headers: this.headers,
|
|
21199
|
-
jwt: (
|
|
21252
|
+
jwt: (_a58 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a58 === void 0 ? void 0 : _a58.access_token
|
|
21200
21253
|
});
|
|
21201
21254
|
if (error) {
|
|
21202
21255
|
return this._returnResult({ data: null, error });
|
|
21203
21256
|
}
|
|
21204
|
-
if (params.factorType === "totp" && data.type === "totp" && ((
|
|
21257
|
+
if (params.factorType === "totp" && data.type === "totp" && ((_b5 = data === null || data === void 0 ? void 0 : data.totp) === null || _b5 === void 0 ? void 0 : _b5.qr_code)) {
|
|
21205
21258
|
data.totp.qr_code = `data:image/svg+xml;utf-8,${data.totp.qr_code}`;
|
|
21206
21259
|
}
|
|
21207
21260
|
return this._returnResult({ data, error: null });
|
|
@@ -21217,7 +21270,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
21217
21270
|
return this._acquireLock(this.lockAcquireTimeout, async () => {
|
|
21218
21271
|
try {
|
|
21219
21272
|
return await this._useSession(async (result) => {
|
|
21220
|
-
var
|
|
21273
|
+
var _a58;
|
|
21221
21274
|
const { data: sessionData, error: sessionError } = result;
|
|
21222
21275
|
if (sessionError) {
|
|
21223
21276
|
return this._returnResult({ data: null, error: sessionError });
|
|
@@ -21228,7 +21281,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
21228
21281
|
const { data, error } = await _request(this.fetch, "POST", `${this.url}/factors/${params.factorId}/verify`, {
|
|
21229
21282
|
body,
|
|
21230
21283
|
headers: this.headers,
|
|
21231
|
-
jwt: (
|
|
21284
|
+
jwt: (_a58 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a58 === void 0 ? void 0 : _a58.access_token
|
|
21232
21285
|
});
|
|
21233
21286
|
if (error) {
|
|
21234
21287
|
return this._returnResult({ data: null, error });
|
|
@@ -21249,7 +21302,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
21249
21302
|
return this._acquireLock(this.lockAcquireTimeout, async () => {
|
|
21250
21303
|
try {
|
|
21251
21304
|
return await this._useSession(async (result) => {
|
|
21252
|
-
var
|
|
21305
|
+
var _a58;
|
|
21253
21306
|
const { data: sessionData, error: sessionError } = result;
|
|
21254
21307
|
if (sessionError) {
|
|
21255
21308
|
return this._returnResult({ data: null, error: sessionError });
|
|
@@ -21257,7 +21310,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
21257
21310
|
const response = await _request(this.fetch, "POST", `${this.url}/factors/${params.factorId}/challenge`, {
|
|
21258
21311
|
body: params,
|
|
21259
21312
|
headers: this.headers,
|
|
21260
|
-
jwt: (
|
|
21313
|
+
jwt: (_a58 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a58 === void 0 ? void 0 : _a58.access_token
|
|
21261
21314
|
});
|
|
21262
21315
|
if (response.error) {
|
|
21263
21316
|
return response;
|
|
@@ -21307,7 +21360,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
21307
21360
|
* {@see GoTrueMFAApi#listFactors}
|
|
21308
21361
|
*/
|
|
21309
21362
|
async _listFactors() {
|
|
21310
|
-
var
|
|
21363
|
+
var _a58;
|
|
21311
21364
|
const { data: { user }, error: userError } = await this.getUser();
|
|
21312
21365
|
if (userError) {
|
|
21313
21366
|
return { data: null, error: userError };
|
|
@@ -21318,7 +21371,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
21318
21371
|
totp: [],
|
|
21319
21372
|
webauthn: []
|
|
21320
21373
|
};
|
|
21321
|
-
for (const factor of (
|
|
21374
|
+
for (const factor of (_a58 = user === null || user === void 0 ? void 0 : user.factors) !== null && _a58 !== void 0 ? _a58 : []) {
|
|
21322
21375
|
data.all.push(factor);
|
|
21323
21376
|
if (factor.status === "verified") {
|
|
21324
21377
|
;
|
|
@@ -21334,7 +21387,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
21334
21387
|
* {@see GoTrueMFAApi#getAuthenticatorAssuranceLevel}
|
|
21335
21388
|
*/
|
|
21336
21389
|
async _getAuthenticatorAssuranceLevel() {
|
|
21337
|
-
var
|
|
21390
|
+
var _a58, _b5;
|
|
21338
21391
|
const { data: { session }, error: sessionError } = await this.getSession();
|
|
21339
21392
|
if (sessionError) {
|
|
21340
21393
|
return this._returnResult({ data: null, error: sessionError });
|
|
@@ -21351,7 +21404,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
21351
21404
|
currentLevel = payload.aal;
|
|
21352
21405
|
}
|
|
21353
21406
|
let nextLevel = currentLevel;
|
|
21354
|
-
const verifiedFactors = (
|
|
21407
|
+
const verifiedFactors = (_b5 = (_a58 = session.user.factors) === null || _a58 === void 0 ? void 0 : _a58.filter((factor) => factor.status === "verified")) !== null && _b5 !== void 0 ? _b5 : [];
|
|
21355
21408
|
if (verifiedFactors.length > 0) {
|
|
21356
21409
|
nextLevel = "aal2";
|
|
21357
21410
|
}
|
|
@@ -21954,15 +22007,15 @@ function shouldShowDeprecationWarning() {
|
|
|
21954
22007
|
if (shouldShowDeprecationWarning()) console.warn("\u26A0\uFE0F Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");
|
|
21955
22008
|
|
|
21956
22009
|
// src/lib/supabase.ts
|
|
21957
|
-
var import_meta5 = {};
|
|
21958
22010
|
var cachedStargate = null;
|
|
21959
22011
|
function getSupabase() {
|
|
22012
|
+
var _a58;
|
|
21960
22013
|
if (cachedStargate) return cachedStargate;
|
|
21961
|
-
const url =
|
|
21962
|
-
const anon =
|
|
21963
|
-
const schema =
|
|
22014
|
+
const url = getRuntimeEnv("VITE_SUPABASE_URL");
|
|
22015
|
+
const anon = (_a58 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a58 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY");
|
|
22016
|
+
const schema = getRuntimeEnvOr("VITE_SUPABASE_SCHEMA", "public");
|
|
21964
22017
|
if (!url || !anon) {
|
|
21965
|
-
if (
|
|
22018
|
+
if (isRuntimeDev()) {
|
|
21966
22019
|
console.log("[supabase] getSupabase: env faltando", { hasUrl: !!url, hasAnon: !!anon, schema });
|
|
21967
22020
|
}
|
|
21968
22021
|
return null;
|
|
@@ -22033,8 +22086,6 @@ var Toaster = ({ theme, ...props }) => {
|
|
|
22033
22086
|
};
|
|
22034
22087
|
|
|
22035
22088
|
// src/lib/accountsAuth.ts
|
|
22036
|
-
var import_meta6 = {};
|
|
22037
|
-
var ENV = import_meta6.env;
|
|
22038
22089
|
var decodeJwt = (token) => {
|
|
22039
22090
|
if (!token) return null;
|
|
22040
22091
|
const parts = token.split(".");
|
|
@@ -22050,100 +22101,99 @@ var decodeJwt = (token) => {
|
|
|
22050
22101
|
|
|
22051
22102
|
// src/components/cupcode/MainNavbar.tsx
|
|
22052
22103
|
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
22053
|
-
var
|
|
22054
|
-
var
|
|
22055
|
-
var
|
|
22104
|
+
var _a16, _b4;
|
|
22105
|
+
var SUPABASE_SCHEMA = ((_b4 = (_a16 = getRuntimeEnv("VITE_CHAT_SCHEMA")) != null ? _a16 : getRuntimeEnv("VITE_SUPABASE_SCHEMA")) != null ? _b4 : "public").trim();
|
|
22106
|
+
var _a17;
|
|
22107
|
+
var USER_PRESENCE_TABLE = ((_a17 = getRuntimeEnv("VITE_USER_PRESENCE_TABLE")) != null ? _a17 : "user_presence").trim();
|
|
22108
|
+
var _a18;
|
|
22109
|
+
var USER_PRESENCE_USER_ID_COLUMN = ((_a18 = getRuntimeEnv("VITE_USER_PRESENCE_USER_ID_COLUMN")) != null ? _a18 : "user_id").trim();
|
|
22056
22110
|
var _a19;
|
|
22057
|
-
var
|
|
22111
|
+
var USER_PRESENCE_STATUS_COLUMN = ((_a19 = getRuntimeEnv("VITE_USER_PRESENCE_STATUS_COLUMN")) != null ? _a19 : "status").trim();
|
|
22058
22112
|
var _a20;
|
|
22059
|
-
var
|
|
22113
|
+
var CHAT_USERS_TABLE = ((_a20 = getRuntimeEnv("VITE_CHAT_USERS_TABLE")) != null ? _a20 : "users").trim();
|
|
22060
22114
|
var _a21;
|
|
22061
|
-
var
|
|
22115
|
+
var CHAT_USERS_ID_COLUMN = ((_a21 = getRuntimeEnv("VITE_CHAT_USERS_ID_COLUMN")) != null ? _a21 : "id").trim();
|
|
22062
22116
|
var _a22;
|
|
22063
|
-
var
|
|
22117
|
+
var CHAT_USERS_NAME_COLUMN = ((_a22 = getRuntimeEnv("VITE_CHAT_USERS_NAME_COLUMN")) != null ? _a22 : "name").trim();
|
|
22064
22118
|
var _a23;
|
|
22065
|
-
var
|
|
22119
|
+
var CHAT_USERS_USERNAME_COLUMN = ((_a23 = getRuntimeEnv("VITE_CHAT_USERS_USERNAME_COLUMN")) != null ? _a23 : "username").trim();
|
|
22066
22120
|
var _a24;
|
|
22067
|
-
var
|
|
22121
|
+
var CHAT_USERS_EMAIL_COLUMN = ((_a24 = getRuntimeEnv("VITE_CHAT_USERS_EMAIL_COLUMN")) != null ? _a24 : "email").trim();
|
|
22068
22122
|
var _a25;
|
|
22069
|
-
var
|
|
22123
|
+
var CHAT_USERS_AVATAR_COLUMN = ((_a25 = getRuntimeEnv("VITE_CHAT_USERS_AVATAR_COLUMN")) != null ? _a25 : "avatar_url").trim();
|
|
22070
22124
|
var _a26;
|
|
22071
|
-
var
|
|
22072
|
-
var _a27;
|
|
22073
|
-
var CHAT_USERS_AVATAR_COLUMN = ((_a27 = import_meta7.env.VITE_CHAT_USERS_AVATAR_COLUMN) != null ? _a27 : "avatar_url").trim();
|
|
22074
|
-
var _a28;
|
|
22075
|
-
var CHAT_USERS_ROLE_COLUMN = ((_a28 = import_meta7.env.VITE_CHAT_USERS_ROLE_COLUMN) != null ? _a28 : "job_title").trim();
|
|
22125
|
+
var CHAT_USERS_ROLE_COLUMN = ((_a26 = getRuntimeEnv("VITE_CHAT_USERS_ROLE_COLUMN")) != null ? _a26 : "job_title").trim();
|
|
22076
22126
|
var CHAT_USERS_UPDATE_TABLE = "profiles";
|
|
22077
22127
|
var CHAT_USERS_UPDATE_ID_COLUMN = "id";
|
|
22078
22128
|
var CHAT_USERS_UPDATE_EMAIL_COLUMN = "email";
|
|
22079
22129
|
var CHAT_USERS_UPDATE_AVATAR_COLUMN = "avatar_url";
|
|
22130
|
+
var _a27;
|
|
22131
|
+
var CHAT_MESSAGES_TABLE = ((_a27 = getRuntimeEnv("VITE_CHAT_MESSAGES_TABLE")) != null ? _a27 : "chat_messages").trim();
|
|
22132
|
+
var _a28;
|
|
22133
|
+
var CHAT_MESSAGES_ID_COLUMN = ((_a28 = getRuntimeEnv("VITE_CHAT_MESSAGES_ID_COLUMN")) != null ? _a28 : "id").trim();
|
|
22080
22134
|
var _a29;
|
|
22081
|
-
var
|
|
22135
|
+
var CHAT_MESSAGES_SENDER_COLUMN = ((_a29 = getRuntimeEnv("VITE_CHAT_MESSAGES_SENDER_COLUMN")) != null ? _a29 : "sender_id").trim();
|
|
22082
22136
|
var _a30;
|
|
22083
|
-
var
|
|
22137
|
+
var CHAT_MESSAGES_RECIPIENT_COLUMN = ((_a30 = getRuntimeEnv("VITE_CHAT_MESSAGES_RECIPIENT_COLUMN")) != null ? _a30 : "recipient_id").trim();
|
|
22084
22138
|
var _a31;
|
|
22085
|
-
var
|
|
22139
|
+
var CHAT_MESSAGES_TEXT_COLUMN = ((_a31 = getRuntimeEnv("VITE_CHAT_MESSAGES_TEXT_COLUMN")) != null ? _a31 : "text").trim();
|
|
22086
22140
|
var _a32;
|
|
22087
|
-
var
|
|
22141
|
+
var CHAT_MESSAGES_CREATED_AT_COLUMN = ((_a32 = getRuntimeEnv("VITE_CHAT_MESSAGES_CREATED_AT_COLUMN")) != null ? _a32 : "created_at").trim();
|
|
22088
22142
|
var _a33;
|
|
22089
|
-
var
|
|
22143
|
+
var CHAT_MESSAGES_READ_AT_COLUMN = ((_a33 = getRuntimeEnv("VITE_CHAT_MESSAGES_READ_AT_COLUMN")) != null ? _a33 : "read_at").trim();
|
|
22090
22144
|
var _a34;
|
|
22091
|
-
var
|
|
22145
|
+
var CHAT_MESSAGES_REPLY_TO_COLUMN = ((_a34 = getRuntimeEnv("VITE_CHAT_MESSAGES_REPLY_TO_COLUMN")) != null ? _a34 : "reply_to_message_id").trim();
|
|
22092
22146
|
var _a35;
|
|
22093
|
-
var
|
|
22147
|
+
var CHAT_MESSAGES_EDITED_AT_COLUMN = ((_a35 = getRuntimeEnv("VITE_CHAT_MESSAGES_EDITED_AT_COLUMN")) != null ? _a35 : "edited_at").trim();
|
|
22094
22148
|
var _a36;
|
|
22095
|
-
var
|
|
22149
|
+
var CHAT_MESSAGES_DELETED_AT_COLUMN = ((_a36 = getRuntimeEnv("VITE_CHAT_MESSAGES_DELETED_AT_COLUMN")) != null ? _a36 : "deleted_at").trim();
|
|
22096
22150
|
var _a37;
|
|
22097
|
-
var
|
|
22151
|
+
var CHAT_MESSAGES_DELETED_BY_COLUMN = ((_a37 = getRuntimeEnv("VITE_CHAT_MESSAGES_DELETED_BY_COLUMN")) != null ? _a37 : "deleted_by").trim();
|
|
22098
22152
|
var _a38;
|
|
22099
|
-
var
|
|
22153
|
+
var CHAT_REACTIONS_TABLE = ((_a38 = getRuntimeEnv("VITE_CHAT_REACTIONS_TABLE")) != null ? _a38 : "chat_message_reactions").trim();
|
|
22100
22154
|
var _a39;
|
|
22101
|
-
var
|
|
22155
|
+
var CHAT_REACTIONS_ID_COLUMN = ((_a39 = getRuntimeEnv("VITE_CHAT_REACTIONS_ID_COLUMN")) != null ? _a39 : "id").trim();
|
|
22102
22156
|
var _a40;
|
|
22103
|
-
var
|
|
22157
|
+
var CHAT_REACTIONS_MESSAGE_ID_COLUMN = ((_a40 = getRuntimeEnv("VITE_CHAT_REACTIONS_MESSAGE_ID_COLUMN")) != null ? _a40 : "message_id").trim();
|
|
22104
22158
|
var _a41;
|
|
22105
|
-
var
|
|
22159
|
+
var CHAT_REACTIONS_USER_ID_COLUMN = ((_a41 = getRuntimeEnv("VITE_CHAT_REACTIONS_USER_ID_COLUMN")) != null ? _a41 : "user_id").trim();
|
|
22106
22160
|
var _a42;
|
|
22107
|
-
var
|
|
22161
|
+
var CHAT_REACTIONS_EMOJI_COLUMN = ((_a42 = getRuntimeEnv("VITE_CHAT_REACTIONS_EMOJI_COLUMN")) != null ? _a42 : "emoji").trim();
|
|
22108
22162
|
var _a43;
|
|
22109
|
-
var
|
|
22163
|
+
var CHAT_REACTIONS_CREATED_AT_COLUMN = ((_a43 = getRuntimeEnv("VITE_CHAT_REACTIONS_CREATED_AT_COLUMN")) != null ? _a43 : "created_at").trim();
|
|
22110
22164
|
var _a44;
|
|
22111
|
-
var
|
|
22165
|
+
var CHAT_LOGS_TABLE = ((_a44 = getRuntimeEnv("VITE_CHAT_LOGS_TABLE")) != null ? _a44 : "chat_message_logs").trim();
|
|
22112
22166
|
var _a45;
|
|
22113
|
-
var
|
|
22167
|
+
var CHAT_LOGS_ID_COLUMN = ((_a45 = getRuntimeEnv("VITE_CHAT_LOGS_ID_COLUMN")) != null ? _a45 : "id").trim();
|
|
22114
22168
|
var _a46;
|
|
22115
|
-
var
|
|
22169
|
+
var CHAT_LOGS_MESSAGE_ID_COLUMN = ((_a46 = getRuntimeEnv("VITE_CHAT_LOGS_MESSAGE_ID_COLUMN")) != null ? _a46 : "message_id").trim();
|
|
22116
22170
|
var _a47;
|
|
22117
|
-
var
|
|
22171
|
+
var CHAT_LOGS_ACTOR_ID_COLUMN = ((_a47 = getRuntimeEnv("VITE_CHAT_LOGS_ACTOR_ID_COLUMN")) != null ? _a47 : "actor_id").trim();
|
|
22118
22172
|
var _a48;
|
|
22119
|
-
var
|
|
22173
|
+
var CHAT_LOGS_ACTION_COLUMN = ((_a48 = getRuntimeEnv("VITE_CHAT_LOGS_ACTION_COLUMN")) != null ? _a48 : "action").trim();
|
|
22120
22174
|
var _a49;
|
|
22121
|
-
var
|
|
22175
|
+
var CHAT_LOGS_PREVIOUS_TEXT_COLUMN = ((_a49 = getRuntimeEnv("VITE_CHAT_LOGS_PREVIOUS_TEXT_COLUMN")) != null ? _a49 : "previous_text").trim();
|
|
22122
22176
|
var _a50;
|
|
22123
|
-
var
|
|
22177
|
+
var CHAT_LOGS_NEXT_TEXT_COLUMN = ((_a50 = getRuntimeEnv("VITE_CHAT_LOGS_NEXT_TEXT_COLUMN")) != null ? _a50 : "next_text").trim();
|
|
22124
22178
|
var _a51;
|
|
22125
|
-
var
|
|
22126
|
-
var _a52;
|
|
22127
|
-
var CHAT_LOGS_NEXT_TEXT_COLUMN = ((_a52 = import_meta7.env.VITE_CHAT_LOGS_NEXT_TEXT_COLUMN) != null ? _a52 : "next_text").trim();
|
|
22128
|
-
var _a53;
|
|
22129
|
-
var CHAT_LOGS_CREATED_AT_COLUMN = ((_a53 = import_meta7.env.VITE_CHAT_LOGS_CREATED_AT_COLUMN) != null ? _a53 : "created_at").trim();
|
|
22179
|
+
var CHAT_LOGS_CREATED_AT_COLUMN = ((_a51 = getRuntimeEnv("VITE_CHAT_LOGS_CREATED_AT_COLUMN")) != null ? _a51 : "created_at").trim();
|
|
22130
22180
|
var CHAT_MESSAGE_HISTORY_LIMIT = 200;
|
|
22131
22181
|
var CHAT_EDIT_WINDOW_MINUTES2 = 15;
|
|
22132
22182
|
var CHAT_DELETED_PLACEHOLDER_TEXT2 = "Mensagem deletada";
|
|
22133
|
-
var
|
|
22134
|
-
var TELESCUP_BASE_URL = (
|
|
22135
|
-
var
|
|
22136
|
-
var SUPABASE_URL2 = (
|
|
22183
|
+
var _a52;
|
|
22184
|
+
var TELESCUP_BASE_URL = (_a52 = getRuntimeEnv("VITE_TELESCUP_BASE_URL")) == null ? void 0 : _a52.trim();
|
|
22185
|
+
var _a53;
|
|
22186
|
+
var SUPABASE_URL2 = (_a53 = getRuntimeEnv("VITE_SUPABASE_URL")) == null ? void 0 : _a53.trim();
|
|
22137
22187
|
var TELESCUP_BASE_URL_FALLBACK = SUPABASE_URL2 ? `${SUPABASE_URL2.replace(/\/+$/, "")}/functions/v1` : void 0;
|
|
22138
22188
|
var ACCESS_TOKEN_STORAGE_KEY = "cc_access_token";
|
|
22189
|
+
var _a54;
|
|
22190
|
+
var ACCOUNTS_BASE_URL2 = ((_a54 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a54 : "https://accounts.cupcode.com.br").trim().replace(/\/+$/, "");
|
|
22191
|
+
var _a55;
|
|
22192
|
+
var MC_BASE_URL2 = ((_a55 = getRuntimeEnv("VITE_MC_BASE_URL")) != null ? _a55 : "https://mc.cupcode.com.br").trim().replace(/\/+$/, "");
|
|
22139
22193
|
var _a56;
|
|
22140
|
-
var
|
|
22194
|
+
var ACCOUNTS_LANGUAGE_ENDPOINT = (_a56 = getRuntimeEnv("VITE_ACCOUNTS_LANGUAGE_ENDPOINT")) == null ? void 0 : _a56.trim();
|
|
22141
22195
|
var _a57;
|
|
22142
|
-
var
|
|
22143
|
-
var _a58;
|
|
22144
|
-
var ACCOUNTS_LANGUAGE_ENDPOINT = (_a58 = import_meta7.env.VITE_ACCOUNTS_LANGUAGE_ENDPOINT) == null ? void 0 : _a58.trim();
|
|
22145
|
-
var _a59;
|
|
22146
|
-
var ACCOUNTS_ACTIVITY_ENDPOINT = (_a59 = import_meta7.env.VITE_ACCOUNTS_ACTIVITY_ENDPOINT) == null ? void 0 : _a59.trim();
|
|
22196
|
+
var ACCOUNTS_ACTIVITY_ENDPOINT = (_a57 = getRuntimeEnv("VITE_ACCOUNTS_ACTIVITY_ENDPOINT")) == null ? void 0 : _a57.trim();
|
|
22147
22197
|
var PRESENCE_STATUS_VALUES = [
|
|
22148
22198
|
"online",
|
|
22149
22199
|
"away",
|
|
@@ -22308,8 +22358,8 @@ var parseRecentActivityItems = (payload) => {
|
|
|
22308
22358
|
return [];
|
|
22309
22359
|
};
|
|
22310
22360
|
return toRows(payload).map((item, index) => {
|
|
22311
|
-
var
|
|
22312
|
-
const id = (
|
|
22361
|
+
var _a58, _b5, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
22362
|
+
const id = (_b5 = (_a58 = toStringOrUndefined(item.id)) != null ? _a58 : toStringOrUndefined(item.event_id)) != null ? _b5 : `accounts-activity-${index}`;
|
|
22313
22363
|
const title = (_e = (_d = (_c = toStringOrUndefined(item.title)) != null ? _c : toStringOrUndefined(item.action)) != null ? _d : toStringOrUndefined(item.event)) != null ? _e : toStringOrUndefined(item.type);
|
|
22314
22364
|
if (!title) return null;
|
|
22315
22365
|
const description = (_h = (_g = (_f = toStringOrUndefined(item.description)) != null ? _f : toStringOrUndefined(item.details)) != null ? _g : toStringOrUndefined(item.message)) != null ? _h : toStringOrUndefined(item.summary);
|
|
@@ -22399,25 +22449,25 @@ var dedupeAndSortReactions = (reactions) => {
|
|
|
22399
22449
|
});
|
|
22400
22450
|
};
|
|
22401
22451
|
var isMissingColumnError = (error, column) => {
|
|
22402
|
-
var
|
|
22403
|
-
const normalized = (
|
|
22452
|
+
var _a58, _b5;
|
|
22453
|
+
const normalized = (_b5 = (_a58 = error == null ? void 0 : error.message) == null ? void 0 : _a58.toLowerCase()) != null ? _b5 : "";
|
|
22404
22454
|
const code = error == null ? void 0 : error.code;
|
|
22405
22455
|
return code === "42703" && normalized.includes(column.toLowerCase());
|
|
22406
22456
|
};
|
|
22407
22457
|
var isMissingTableError = (error, table) => {
|
|
22408
|
-
var
|
|
22409
|
-
const normalized = (
|
|
22458
|
+
var _a58, _b5;
|
|
22459
|
+
const normalized = (_b5 = (_a58 = error == null ? void 0 : error.message) == null ? void 0 : _a58.toLowerCase()) != null ? _b5 : "";
|
|
22410
22460
|
const code = error == null ? void 0 : error.code;
|
|
22411
22461
|
return code === "PGRST205" && normalized.includes(table.toLowerCase());
|
|
22412
22462
|
};
|
|
22413
22463
|
var toChatMessage = (row, currentUserId) => {
|
|
22414
|
-
var
|
|
22415
|
-
const id = (
|
|
22464
|
+
var _a58, _b5, _c, _d, _e, _f;
|
|
22465
|
+
const id = (_a58 = toStringOrUndefined(row[CHAT_MESSAGES_ID_COLUMN])) != null ? _a58 : `${toStringOrUndefined(row[CHAT_MESSAGES_SENDER_COLUMN])}-${toStringOrUndefined(row[CHAT_MESSAGES_RECIPIENT_COLUMN])}-${toStringOrUndefined(row[CHAT_MESSAGES_CREATED_AT_COLUMN])}`;
|
|
22416
22466
|
const senderId = toStringOrUndefined(row[CHAT_MESSAGES_SENDER_COLUMN]);
|
|
22417
22467
|
const recipientId = toStringOrUndefined(row[CHAT_MESSAGES_RECIPIENT_COLUMN]);
|
|
22418
22468
|
const text = toStringOrUndefined(row[CHAT_MESSAGES_TEXT_COLUMN]);
|
|
22419
22469
|
const createdAt = toStringOrUndefined(row[CHAT_MESSAGES_CREATED_AT_COLUMN]);
|
|
22420
|
-
const editedAt = (
|
|
22470
|
+
const editedAt = (_b5 = toStringOrUndefined(row[CHAT_MESSAGES_EDITED_AT_COLUMN])) != null ? _b5 : null;
|
|
22421
22471
|
const readAt = (_c = toStringOrUndefined(row[CHAT_MESSAGES_READ_AT_COLUMN])) != null ? _c : null;
|
|
22422
22472
|
const replyToMessageId = (_d = toStringOrUndefined(row[CHAT_MESSAGES_REPLY_TO_COLUMN])) != null ? _d : null;
|
|
22423
22473
|
const deletedAt = (_e = toStringOrUndefined(row[CHAT_MESSAGES_DELETED_AT_COLUMN])) != null ? _e : null;
|
|
@@ -22452,13 +22502,13 @@ var toChatReaction = (row) => {
|
|
|
22452
22502
|
return { id, messageId, userId, emoji, createdAt };
|
|
22453
22503
|
};
|
|
22454
22504
|
var toChatMessageLog = (row, messagesById) => {
|
|
22455
|
-
var
|
|
22505
|
+
var _a58, _b5;
|
|
22456
22506
|
const id = toStringOrUndefined(row[CHAT_LOGS_ID_COLUMN]);
|
|
22457
22507
|
const messageId = toStringOrUndefined(row[CHAT_LOGS_MESSAGE_ID_COLUMN]);
|
|
22458
22508
|
const actorId = toStringOrUndefined(row[CHAT_LOGS_ACTOR_ID_COLUMN]);
|
|
22459
22509
|
const action = toStringOrUndefined(row[CHAT_LOGS_ACTION_COLUMN]);
|
|
22460
|
-
const previousText = (
|
|
22461
|
-
const nextText = (
|
|
22510
|
+
const previousText = (_a58 = toStringOrUndefined(row[CHAT_LOGS_PREVIOUS_TEXT_COLUMN])) != null ? _a58 : null;
|
|
22511
|
+
const nextText = (_b5 = toStringOrUndefined(row[CHAT_LOGS_NEXT_TEXT_COLUMN])) != null ? _b5 : null;
|
|
22462
22512
|
const createdAt = toStringOrUndefined(row[CHAT_LOGS_CREATED_AT_COLUMN]);
|
|
22463
22513
|
if (!id || !messageId || !action || action !== "edit" && action !== "delete") return null;
|
|
22464
22514
|
const relatedMessage = messagesById.get(messageId);
|
|
@@ -22499,7 +22549,7 @@ var MainNavbar = ({
|
|
|
22499
22549
|
onOpenAccountClick,
|
|
22500
22550
|
getAccessToken
|
|
22501
22551
|
}) => {
|
|
22502
|
-
var
|
|
22552
|
+
var _a58, _b5, _c;
|
|
22503
22553
|
const [chatUsers, setChatUsers] = (0, import_react19.useState)([]);
|
|
22504
22554
|
const [chatMessages, setChatMessages] = (0, import_react19.useState)([]);
|
|
22505
22555
|
const [chatMessageLogs, setChatMessageLogs] = (0, import_react19.useState)([]);
|
|
@@ -22534,8 +22584,8 @@ var MainNavbar = ({
|
|
|
22534
22584
|
const currentUserId = (0, import_react19.useMemo)(() => resolveCurrentUserId(authUser), [authUser]);
|
|
22535
22585
|
const authEmail = (0, import_react19.useMemo)(() => toStringOrUndefined(authUser == null ? void 0 : authUser.email), [authUser == null ? void 0 : authUser.email]);
|
|
22536
22586
|
const isChatSuperAdmin = (0, import_react19.useMemo)(() => {
|
|
22537
|
-
var
|
|
22538
|
-
const roleTokens = `${(
|
|
22587
|
+
var _a59, _b6;
|
|
22588
|
+
const roleTokens = `${(_a59 = authUser == null ? void 0 : authUser.role) != null ? _a59 : ""} ${(_b6 = authUser == null ? void 0 : authUser.jobTitle) != null ? _b6 : ""}`.toLowerCase();
|
|
22539
22589
|
return roleTokens.includes("superadmin") || roleTokens.includes("super admin");
|
|
22540
22590
|
}, [authUser == null ? void 0 : authUser.jobTitle, authUser == null ? void 0 : authUser.role]);
|
|
22541
22591
|
const resolvedTelescupBaseUrl = (0, import_react19.useMemo)(() => {
|
|
@@ -22544,7 +22594,7 @@ var MainNavbar = ({
|
|
|
22544
22594
|
}
|
|
22545
22595
|
return TELESCUP_BASE_URL_FALLBACK;
|
|
22546
22596
|
}, []);
|
|
22547
|
-
const resolvedProfileAvatarUrl = (
|
|
22597
|
+
const resolvedProfileAvatarUrl = (_b5 = (_a58 = resolveChatAvatarUrl(persistedProfileAvatarValue)) != null ? _a58 : authUser == null ? void 0 : authUser.picture) != null ? _b5 : void 0;
|
|
22548
22598
|
const effectiveCurrentUserId = resolvedSenderId != null ? resolvedSenderId : currentUserId;
|
|
22549
22599
|
const isAuthenticated = authStatus === "authenticated";
|
|
22550
22600
|
(0, import_react19.useEffect)(() => {
|
|
@@ -22587,7 +22637,7 @@ var MainNavbar = ({
|
|
|
22587
22637
|
}
|
|
22588
22638
|
if (canceled) return;
|
|
22589
22639
|
if (error) {
|
|
22590
|
-
if (
|
|
22640
|
+
if (isRuntimeDev()) {
|
|
22591
22641
|
console.warn("[chat] Falha ao resolver sender_id por email:", error.message);
|
|
22592
22642
|
}
|
|
22593
22643
|
setResolvedSenderId(fallbackId);
|
|
@@ -22601,7 +22651,7 @@ var MainNavbar = ({
|
|
|
22601
22651
|
setResolvedSenderId(mappedId != null ? mappedId : fallbackId);
|
|
22602
22652
|
setPersistedProfileAvatarValue(mappedAvatar);
|
|
22603
22653
|
} catch (error) {
|
|
22604
|
-
if (
|
|
22654
|
+
if (isRuntimeDev()) {
|
|
22605
22655
|
console.warn("[chat] Excecao ao resolver sender_id por email:", error.message);
|
|
22606
22656
|
}
|
|
22607
22657
|
if (!canceled) {
|
|
@@ -22627,7 +22677,7 @@ var MainNavbar = ({
|
|
|
22627
22677
|
return sessionStorage.getItem(ACCESS_TOKEN_STORAGE_KEY);
|
|
22628
22678
|
};
|
|
22629
22679
|
const loadAccountsContext = async () => {
|
|
22630
|
-
var
|
|
22680
|
+
var _a59, _b6, _c2, _d, _e, _f, _g;
|
|
22631
22681
|
setIsAccountsActivityLoading(true);
|
|
22632
22682
|
try {
|
|
22633
22683
|
const token = await resolveAccountsToken();
|
|
@@ -22637,9 +22687,9 @@ var MainNavbar = ({
|
|
|
22637
22687
|
}
|
|
22638
22688
|
return;
|
|
22639
22689
|
}
|
|
22640
|
-
const claims = (
|
|
22690
|
+
const claims = (_a59 = decodeJwt(token)) != null ? _a59 : {};
|
|
22641
22691
|
const languageFromToken = normalizeMenuLanguage(
|
|
22642
|
-
(_d = (_c2 = (
|
|
22692
|
+
(_d = (_c2 = (_b6 = claims.locale) != null ? _b6 : claims.lang) != null ? _c2 : claims.language) != null ? _d : claims["https://cupcode.com/locale"]
|
|
22643
22693
|
);
|
|
22644
22694
|
if (!canceled) {
|
|
22645
22695
|
setAccountsLanguage(languageFromToken);
|
|
@@ -22676,7 +22726,7 @@ var MainNavbar = ({
|
|
|
22676
22726
|
}
|
|
22677
22727
|
}
|
|
22678
22728
|
} catch (error) {
|
|
22679
|
-
if (
|
|
22729
|
+
if (isRuntimeDev()) {
|
|
22680
22730
|
console.warn("[accounts] Falha ao carregar idioma/atividade recente:", error.message);
|
|
22681
22731
|
}
|
|
22682
22732
|
} finally {
|
|
@@ -22728,7 +22778,7 @@ var MainNavbar = ({
|
|
|
22728
22778
|
}
|
|
22729
22779
|
let canceled = false;
|
|
22730
22780
|
const loadChatData = async () => {
|
|
22731
|
-
var
|
|
22781
|
+
var _a59, _b6, _c2, _d, _e, _f;
|
|
22732
22782
|
setIsChatLoading(true);
|
|
22733
22783
|
setChatError(null);
|
|
22734
22784
|
const userColumns = Array.from(
|
|
@@ -22828,11 +22878,11 @@ var MainNavbar = ({
|
|
|
22828
22878
|
if (canceled) return;
|
|
22829
22879
|
const presenceMap = /* @__PURE__ */ new Map();
|
|
22830
22880
|
if (presenceResponse.error) {
|
|
22831
|
-
if (
|
|
22881
|
+
if (isRuntimeDev()) {
|
|
22832
22882
|
console.warn("[chat] Falha ao carregar presen\xE7a:", presenceResponse.error.message);
|
|
22833
22883
|
}
|
|
22834
22884
|
} else {
|
|
22835
|
-
(
|
|
22885
|
+
(_a59 = presenceResponse.data) == null ? void 0 : _a59.forEach((row) => {
|
|
22836
22886
|
const userId = toStringOrUndefined(row[USER_PRESENCE_USER_ID_COLUMN]);
|
|
22837
22887
|
if (!userId) return;
|
|
22838
22888
|
presenceMap.set(userId, normalizePresenceStatus(row[USER_PRESENCE_STATUS_COLUMN]));
|
|
@@ -22840,17 +22890,17 @@ var MainNavbar = ({
|
|
|
22840
22890
|
}
|
|
22841
22891
|
const usersMap = /* @__PURE__ */ new Map();
|
|
22842
22892
|
if (usersResponse.error) {
|
|
22843
|
-
if (
|
|
22893
|
+
if (isRuntimeDev()) {
|
|
22844
22894
|
console.warn("[chat] Falha ao carregar tabela de usu\xE1rios:", usersResponse.error.message);
|
|
22845
22895
|
}
|
|
22846
22896
|
} else {
|
|
22847
|
-
(
|
|
22848
|
-
var
|
|
22897
|
+
(_b6 = usersResponse.data) == null ? void 0 : _b6.forEach((row) => {
|
|
22898
|
+
var _a60, _b7, _c3;
|
|
22849
22899
|
const id = toStringOrUndefined(row[CHAT_USERS_ID_COLUMN]);
|
|
22850
22900
|
if (!id || id === effectiveCurrentUserId) return;
|
|
22851
22901
|
const email = toStringOrUndefined(row[CHAT_USERS_EMAIL_COLUMN]);
|
|
22852
22902
|
const username = buildHandle2(toStringOrUndefined(row[CHAT_USERS_USERNAME_COLUMN]), email, id);
|
|
22853
|
-
const name = (
|
|
22903
|
+
const name = (_b7 = (_a60 = toStringOrUndefined(row[CHAT_USERS_NAME_COLUMN])) != null ? _a60 : toStringOrUndefined(row[CHAT_USERS_USERNAME_COLUMN])) != null ? _b7 : username;
|
|
22854
22904
|
usersMap.set(id, {
|
|
22855
22905
|
id,
|
|
22856
22906
|
name,
|
|
@@ -22875,7 +22925,7 @@ var MainNavbar = ({
|
|
|
22875
22925
|
const resolvedUsers = [...usersMap.values()].sort((left, right) => left.name.localeCompare(right.name, "pt-BR"));
|
|
22876
22926
|
setChatUsers(resolvedUsers);
|
|
22877
22927
|
if (messageErrors.length > 0) {
|
|
22878
|
-
if (
|
|
22928
|
+
if (isRuntimeDev()) {
|
|
22879
22929
|
messageErrors.forEach((error) => console.warn("[chat] Falha ao carregar mensagens:", error == null ? void 0 : error.message));
|
|
22880
22930
|
}
|
|
22881
22931
|
}
|
|
@@ -22907,7 +22957,7 @@ var MainNavbar = ({
|
|
|
22907
22957
|
setChatMessageLogs([]);
|
|
22908
22958
|
} else if (logsQuery.error) {
|
|
22909
22959
|
logsError = logsQuery.error;
|
|
22910
|
-
if (
|
|
22960
|
+
if (isRuntimeDev()) {
|
|
22911
22961
|
console.warn("[chat] Falha ao carregar logs:", logsQuery.error.message);
|
|
22912
22962
|
}
|
|
22913
22963
|
setChatMessageLogs([]);
|
|
@@ -22920,7 +22970,7 @@ var MainNavbar = ({
|
|
|
22920
22970
|
setChatMessageLogs([]);
|
|
22921
22971
|
}
|
|
22922
22972
|
if (reactionsResponse.error) {
|
|
22923
|
-
if (
|
|
22973
|
+
if (isRuntimeDev()) {
|
|
22924
22974
|
console.warn("[chat] Falha ao carregar rea\xE7\xF5es:", reactionsResponse.error.message);
|
|
22925
22975
|
}
|
|
22926
22976
|
setChatReactions([]);
|
|
@@ -22969,7 +23019,7 @@ var MainNavbar = ({
|
|
|
22969
23019
|
table: CHAT_MESSAGES_TABLE
|
|
22970
23020
|
},
|
|
22971
23021
|
(payload) => {
|
|
22972
|
-
var
|
|
23022
|
+
var _a59;
|
|
22973
23023
|
const row = payload.new;
|
|
22974
23024
|
const message = upsertChatMessage(row);
|
|
22975
23025
|
if (!message) return;
|
|
@@ -22979,7 +23029,7 @@ var MainNavbar = ({
|
|
|
22979
23029
|
if (notifiedMessagesRef.current.has(message.id)) return;
|
|
22980
23030
|
notifiedMessagesRef.current.add(message.id);
|
|
22981
23031
|
const sender = usersByIdRef.current.get(senderId);
|
|
22982
|
-
const senderName = (
|
|
23032
|
+
const senderName = (_a59 = sender == null ? void 0 : sender.name) != null ? _a59 : senderId;
|
|
22983
23033
|
const senderAvatar = sender == null ? void 0 : sender.avatarUrl;
|
|
22984
23034
|
const preview = summarizeMessage(message.text);
|
|
22985
23035
|
const initials = buildInitials2(senderName);
|
|
@@ -23115,10 +23165,10 @@ var MainNavbar = ({
|
|
|
23115
23165
|
if (!chatFeatureFlagsRef.current.hasReadAt) return {};
|
|
23116
23166
|
const counters = {};
|
|
23117
23167
|
chatMessages.forEach((message) => {
|
|
23118
|
-
var
|
|
23168
|
+
var _a59;
|
|
23119
23169
|
if (message.sender !== "them") return;
|
|
23120
23170
|
if (message.readAt) return;
|
|
23121
|
-
counters[message.contactId] = ((
|
|
23171
|
+
counters[message.contactId] = ((_a59 = counters[message.contactId]) != null ? _a59 : 0) + 1;
|
|
23122
23172
|
});
|
|
23123
23173
|
return counters;
|
|
23124
23174
|
}, [chatMessages]);
|
|
@@ -23146,7 +23196,7 @@ var MainNavbar = ({
|
|
|
23146
23196
|
updateChatFeatureFlags({ hasReadAt: false });
|
|
23147
23197
|
return;
|
|
23148
23198
|
}
|
|
23149
|
-
if (
|
|
23199
|
+
if (isRuntimeDev()) {
|
|
23150
23200
|
console.warn("[chat] Falha ao marcar mensagens como lidas:", error.message);
|
|
23151
23201
|
}
|
|
23152
23202
|
}
|
|
@@ -23256,7 +23306,7 @@ var MainNavbar = ({
|
|
|
23256
23306
|
updateChatFeatureFlags({ hasLogsTable: false });
|
|
23257
23307
|
return;
|
|
23258
23308
|
}
|
|
23259
|
-
if (
|
|
23309
|
+
if (isRuntimeDev()) {
|
|
23260
23310
|
console.warn("[chat] Falha ao registrar log de mensagem:", error.message);
|
|
23261
23311
|
}
|
|
23262
23312
|
},
|
|
@@ -23314,8 +23364,8 @@ var MainNavbar = ({
|
|
|
23314
23364
|
(current) => dedupeAndSortMessages(
|
|
23315
23365
|
current.map(
|
|
23316
23366
|
(message) => {
|
|
23317
|
-
var
|
|
23318
|
-
return message.id === messageId ? { ...message, text: previousText, editedAt: (
|
|
23367
|
+
var _a59;
|
|
23368
|
+
return message.id === messageId ? { ...message, text: previousText, editedAt: (_a59 = targetMessage.editedAt) != null ? _a59 : null } : message;
|
|
23319
23369
|
}
|
|
23320
23370
|
)
|
|
23321
23371
|
)
|
|
@@ -23346,13 +23396,13 @@ var MainNavbar = ({
|
|
|
23346
23396
|
(current) => dedupeAndSortMessages(
|
|
23347
23397
|
current.map(
|
|
23348
23398
|
(message) => {
|
|
23349
|
-
var
|
|
23399
|
+
var _a59;
|
|
23350
23400
|
return message.id === messageId ? {
|
|
23351
23401
|
...message,
|
|
23352
23402
|
text: CHAT_DELETED_PLACEHOLDER_TEXT2,
|
|
23353
23403
|
deletedAt,
|
|
23354
23404
|
deletedBy: effectiveCurrentUserId,
|
|
23355
|
-
editedAt: (
|
|
23405
|
+
editedAt: (_a59 = message.editedAt) != null ? _a59 : deletedAt
|
|
23356
23406
|
} : message;
|
|
23357
23407
|
}
|
|
23358
23408
|
)
|
|
@@ -23537,8 +23587,8 @@ var MainNavbar = ({
|
|
|
23537
23587
|
...item,
|
|
23538
23588
|
isActive,
|
|
23539
23589
|
onClick: isAnchor ? item.onClick : (event) => {
|
|
23540
|
-
var
|
|
23541
|
-
(
|
|
23590
|
+
var _a59;
|
|
23591
|
+
(_a59 = item.onClick) == null ? void 0 : _a59.call(item, event);
|
|
23542
23592
|
if (!onNavigate || event.defaultPrevented) return;
|
|
23543
23593
|
event.preventDefault();
|
|
23544
23594
|
onNavigate(item.href);
|
|
@@ -23580,9 +23630,9 @@ var MainNavbar = ({
|
|
|
23580
23630
|
window.open(`${MC_BASE_URL2}/tasks`, "_blank", "noopener,noreferrer");
|
|
23581
23631
|
};
|
|
23582
23632
|
const handleChatOpenUserProfile = (0, import_react19.useCallback)(({ userId }) => {
|
|
23583
|
-
var
|
|
23633
|
+
var _a59;
|
|
23584
23634
|
if (!userId || typeof window === "undefined") return;
|
|
23585
|
-
const baseUrl = ((
|
|
23635
|
+
const baseUrl = ((_a59 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a59 : "https://accounts.cupcode.com.br").replace(
|
|
23586
23636
|
/\/+$/,
|
|
23587
23637
|
""
|
|
23588
23638
|
);
|
|
@@ -23639,11 +23689,11 @@ var MainNavbar = ({
|
|
|
23639
23689
|
},
|
|
23640
23690
|
body: JSON.stringify({ language: nextLanguage })
|
|
23641
23691
|
});
|
|
23642
|
-
if (!response.ok &&
|
|
23692
|
+
if (!response.ok && isRuntimeDev()) {
|
|
23643
23693
|
console.warn("[accounts] Falha ao atualizar idioma:", response.status, response.statusText);
|
|
23644
23694
|
}
|
|
23645
23695
|
} catch (error) {
|
|
23646
|
-
if (
|
|
23696
|
+
if (isRuntimeDev()) {
|
|
23647
23697
|
console.warn("[accounts] Falha ao atualizar idioma:", error.message);
|
|
23648
23698
|
}
|
|
23649
23699
|
}
|
|
@@ -23652,8 +23702,8 @@ var MainNavbar = ({
|
|
|
23652
23702
|
);
|
|
23653
23703
|
const handleProfileAvatarChange = (0, import_react19.useCallback)(
|
|
23654
23704
|
async ({ avatarId, avatarUrl }) => {
|
|
23655
|
-
var
|
|
23656
|
-
const normalizedAvatarId = (
|
|
23705
|
+
var _a59;
|
|
23706
|
+
const normalizedAvatarId = (_a59 = parseAssetId(avatarId)) != null ? _a59 : parseAssetId(avatarUrl);
|
|
23657
23707
|
if (!normalizedAvatarId) {
|
|
23658
23708
|
throw new Error("ID da imagem inv\xE1lido.");
|
|
23659
23709
|
}
|
|
@@ -23669,27 +23719,27 @@ var MainNavbar = ({
|
|
|
23669
23719
|
);
|
|
23670
23720
|
const updateErrors = [];
|
|
23671
23721
|
const isRecoverableUpdateError = (error) => {
|
|
23672
|
-
var
|
|
23673
|
-
const message = ((
|
|
23722
|
+
var _a60;
|
|
23723
|
+
const message = ((_a60 = error.message) != null ? _a60 : "").toLowerCase();
|
|
23674
23724
|
return error.code === "55000" || error.code === "42P01" || error.code === "42703" || error.code === "42501" || error.code === "22P02" || message.includes("cannot update view") || message.includes("not automatically updatable") || message.includes("permission denied") || message.includes("invalid input syntax") || message.includes("relation") && message.includes("does not exist") || message.includes("column") && message.includes("does not exist");
|
|
23675
23725
|
};
|
|
23676
23726
|
const isRecoverableLookupError = (error) => {
|
|
23677
|
-
var
|
|
23678
|
-
const message = ((
|
|
23727
|
+
var _a60;
|
|
23728
|
+
const message = ((_a60 = error.message) != null ? _a60 : "").toLowerCase();
|
|
23679
23729
|
return error.code === "42P01" || error.code === "42703" || error.code === "42501" || message.includes("relation") && message.includes("does not exist") || message.includes("column") && message.includes("does not exist") || message.includes("permission denied");
|
|
23680
23730
|
};
|
|
23681
23731
|
const isPermissionDeniedError2 = (error) => {
|
|
23682
|
-
var
|
|
23683
|
-
const message = ((
|
|
23732
|
+
var _a60;
|
|
23733
|
+
const message = ((_a60 = error.message) != null ? _a60 : "").toLowerCase();
|
|
23684
23734
|
return error.code === "42501" || message.includes("permission denied");
|
|
23685
23735
|
};
|
|
23686
23736
|
const updateAvatarByUserId = async (userId) => {
|
|
23687
|
-
var
|
|
23737
|
+
var _a60, _b6, _c2, _d, _e;
|
|
23688
23738
|
for (const tableName of updateTargets) {
|
|
23689
23739
|
const updateWithSelect = await supabase.from(tableName).update({ [CHAT_USERS_UPDATE_AVATAR_COLUMN]: normalizedAvatarId }).eq(CHAT_USERS_UPDATE_ID_COLUMN, userId).select(CHAT_USERS_UPDATE_ID_COLUMN).limit(1);
|
|
23690
23740
|
if (!updateWithSelect.error) {
|
|
23691
23741
|
const rows = updateWithSelect.data;
|
|
23692
|
-
const row = (
|
|
23742
|
+
const row = (_a60 = rows == null ? void 0 : rows[0]) != null ? _a60 : null;
|
|
23693
23743
|
if (row) {
|
|
23694
23744
|
return row;
|
|
23695
23745
|
}
|
|
@@ -23709,7 +23759,7 @@ var MainNavbar = ({
|
|
|
23709
23759
|
throw new Error(`Falha ao atualizar avatar em "${tableName}": ${withoutSelectError.message}`);
|
|
23710
23760
|
}
|
|
23711
23761
|
updateErrors.push(
|
|
23712
|
-
`${tableName}: ${(
|
|
23762
|
+
`${tableName}: ${(_b6 = withoutSelectError.code) != null ? _b6 : "erro"} ${(_c2 = withoutSelectError.message) != null ? _c2 : "falha desconhecida"}`
|
|
23713
23763
|
);
|
|
23714
23764
|
continue;
|
|
23715
23765
|
}
|
|
@@ -23721,13 +23771,13 @@ var MainNavbar = ({
|
|
|
23721
23771
|
return null;
|
|
23722
23772
|
};
|
|
23723
23773
|
const resolveUserIdByEmail = async (emailValue) => {
|
|
23724
|
-
var
|
|
23774
|
+
var _a60;
|
|
23725
23775
|
let lastRecoverableError = null;
|
|
23726
23776
|
for (const tableName of lookupTargets) {
|
|
23727
23777
|
const { data, error } = await supabase.from(tableName).select(CHAT_USERS_UPDATE_ID_COLUMN).ilike(CHAT_USERS_UPDATE_EMAIL_COLUMN, emailValue).limit(1);
|
|
23728
23778
|
if (!error) {
|
|
23729
23779
|
const rows = data;
|
|
23730
|
-
const resolvedId = toStringOrUndefined((
|
|
23780
|
+
const resolvedId = toStringOrUndefined((_a60 = rows == null ? void 0 : rows[0]) == null ? void 0 : _a60[CHAT_USERS_UPDATE_ID_COLUMN]);
|
|
23731
23781
|
if (resolvedId) {
|
|
23732
23782
|
return resolvedId;
|
|
23733
23783
|
}
|
|
@@ -23738,7 +23788,7 @@ var MainNavbar = ({
|
|
|
23738
23788
|
}
|
|
23739
23789
|
lastRecoverableError = error;
|
|
23740
23790
|
}
|
|
23741
|
-
if (lastRecoverableError &&
|
|
23791
|
+
if (lastRecoverableError && isRuntimeDev()) {
|
|
23742
23792
|
console.warn("[chat] Falha ao buscar usu\xE1rio por e-mail para salvar avatar:", lastRecoverableError.message);
|
|
23743
23793
|
}
|
|
23744
23794
|
return null;
|
|
@@ -24926,8 +24976,8 @@ var ChartStyle = ({ id, config }) => {
|
|
|
24926
24976
|
([theme, prefix]) => `
|
|
24927
24977
|
${prefix} [data-chart=${id}] {
|
|
24928
24978
|
${colorConfig.map(([key, itemConfig]) => {
|
|
24929
|
-
var
|
|
24930
|
-
const color = ((
|
|
24979
|
+
var _a58;
|
|
24980
|
+
const color = ((_a58 = itemConfig.theme) == null ? void 0 : _a58[theme]) || itemConfig.color;
|
|
24931
24981
|
return color ? ` --color-${key}: ${color};` : null;
|
|
24932
24982
|
}).join("\n")}
|
|
24933
24983
|
}
|
|
@@ -24956,14 +25006,14 @@ var ChartTooltipContent = React43.forwardRef(
|
|
|
24956
25006
|
}, ref) => {
|
|
24957
25007
|
const { config } = useChart();
|
|
24958
25008
|
const tooltipLabel = React43.useMemo(() => {
|
|
24959
|
-
var
|
|
25009
|
+
var _a58;
|
|
24960
25010
|
if (hideLabel || !(payload == null ? void 0 : payload.length)) {
|
|
24961
25011
|
return null;
|
|
24962
25012
|
}
|
|
24963
25013
|
const [item] = payload;
|
|
24964
25014
|
const key = `${labelKey || item.dataKey || item.name || "value"}`;
|
|
24965
25015
|
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
24966
|
-
const value = !labelKey && typeof label === "string" ? ((
|
|
25016
|
+
const value = !labelKey && typeof label === "string" ? ((_a58 = config[label]) == null ? void 0 : _a58.label) || label : itemConfig == null ? void 0 : itemConfig.label;
|
|
24967
25017
|
if (labelFormatter) {
|
|
24968
25018
|
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: cn("font-medium", labelClassName), children: labelFormatter(value, payload) });
|
|
24969
25019
|
}
|
|
@@ -26878,9 +26928,13 @@ ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
|
|
|
26878
26928
|
buttonVariants,
|
|
26879
26929
|
cn,
|
|
26880
26930
|
getMainNavItems,
|
|
26931
|
+
getRuntimeEnv,
|
|
26932
|
+
getRuntimeEnvOr,
|
|
26933
|
+
isRuntimeDev,
|
|
26881
26934
|
navigationMenuTriggerStyle,
|
|
26882
26935
|
parseAssetId,
|
|
26883
26936
|
responsiveSizeClasses,
|
|
26937
|
+
setCupcodeRuntimeEnv,
|
|
26884
26938
|
sonnerToast,
|
|
26885
26939
|
toast,
|
|
26886
26940
|
toggleVariants,
|