@sesionario/blocks 1.13.1 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +624 -140
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +104 -13
- package/dist/index.d.ts +104 -13
- package/dist/index.js +624 -142
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -957,6 +957,38 @@ function DropdownMenuItem({
|
|
|
957
957
|
}
|
|
958
958
|
);
|
|
959
959
|
}
|
|
960
|
+
function DropdownMenuRadioGroup({
|
|
961
|
+
...props
|
|
962
|
+
}) {
|
|
963
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
964
|
+
DropdownMenuPrimitive__namespace.RadioGroup,
|
|
965
|
+
{
|
|
966
|
+
"data-slot": "dropdown-menu-radio-group",
|
|
967
|
+
...props
|
|
968
|
+
}
|
|
969
|
+
);
|
|
970
|
+
}
|
|
971
|
+
function DropdownMenuRadioItem({
|
|
972
|
+
className,
|
|
973
|
+
children,
|
|
974
|
+
...props
|
|
975
|
+
}) {
|
|
976
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
977
|
+
DropdownMenuPrimitive__namespace.RadioItem,
|
|
978
|
+
{
|
|
979
|
+
"data-slot": "dropdown-menu-radio-item",
|
|
980
|
+
className: cn(
|
|
981
|
+
"relative flex cursor-default select-none items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[highlighted]:[&_svg:not([class*='text-'])]:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:[&_svg:not([class*='text-'])]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
982
|
+
className
|
|
983
|
+
),
|
|
984
|
+
...props,
|
|
985
|
+
children: [
|
|
986
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pointer-events-none absolute left-2 flex size-3.5 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.ItemIndicator, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleIcon, { className: "size-2 fill-current" }) }) }),
|
|
987
|
+
children
|
|
988
|
+
]
|
|
989
|
+
}
|
|
990
|
+
);
|
|
991
|
+
}
|
|
960
992
|
function DropdownMenuLabel({
|
|
961
993
|
className,
|
|
962
994
|
inset,
|
|
@@ -1004,6 +1036,50 @@ function DropdownMenuShortcut({
|
|
|
1004
1036
|
}
|
|
1005
1037
|
);
|
|
1006
1038
|
}
|
|
1039
|
+
function DropdownMenuSub({
|
|
1040
|
+
...props
|
|
1041
|
+
}) {
|
|
1042
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Sub, { "data-slot": "dropdown-menu-sub", ...props });
|
|
1043
|
+
}
|
|
1044
|
+
function DropdownMenuSubTrigger({
|
|
1045
|
+
className,
|
|
1046
|
+
inset,
|
|
1047
|
+
children,
|
|
1048
|
+
...props
|
|
1049
|
+
}) {
|
|
1050
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1051
|
+
DropdownMenuPrimitive__namespace.SubTrigger,
|
|
1052
|
+
{
|
|
1053
|
+
"data-slot": "dropdown-menu-sub-trigger",
|
|
1054
|
+
"data-inset": inset,
|
|
1055
|
+
className: cn(
|
|
1056
|
+
"flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden data-[inset]:pl-8 data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[highlighted]:[&_svg:not([class*='text-'])]:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground data-[state=open]:[&_svg:not([class*='text-'])]:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:[&_svg:not([class*='text-'])]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
1057
|
+
className
|
|
1058
|
+
),
|
|
1059
|
+
...props,
|
|
1060
|
+
children: [
|
|
1061
|
+
children,
|
|
1062
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRightIcon, { className: "ml-auto size-4" })
|
|
1063
|
+
]
|
|
1064
|
+
}
|
|
1065
|
+
);
|
|
1066
|
+
}
|
|
1067
|
+
function DropdownMenuSubContent({
|
|
1068
|
+
className,
|
|
1069
|
+
...props
|
|
1070
|
+
}) {
|
|
1071
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1072
|
+
DropdownMenuPrimitive__namespace.SubContent,
|
|
1073
|
+
{
|
|
1074
|
+
"data-slot": "dropdown-menu-sub-content",
|
|
1075
|
+
className: cn(
|
|
1076
|
+
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg",
|
|
1077
|
+
className
|
|
1078
|
+
),
|
|
1079
|
+
...props
|
|
1080
|
+
}
|
|
1081
|
+
);
|
|
1082
|
+
}
|
|
1007
1083
|
var defaultLabels = {
|
|
1008
1084
|
theme: "Theme",
|
|
1009
1085
|
system: "System",
|
|
@@ -1496,7 +1572,7 @@ function LanguageSwitcher({
|
|
|
1496
1572
|
const sizes = sizeClasses2[size];
|
|
1497
1573
|
const shapeClass = shapeClasses2[shape];
|
|
1498
1574
|
const reduceMotion = framerMotion.useReducedMotion();
|
|
1499
|
-
const
|
|
1575
|
+
const defaultLabels6 = {
|
|
1500
1576
|
language: labels.language ?? "Language"
|
|
1501
1577
|
};
|
|
1502
1578
|
if (variant === "mini") {
|
|
@@ -1506,7 +1582,7 @@ function LanguageSwitcher({
|
|
|
1506
1582
|
{
|
|
1507
1583
|
variant: "ghost",
|
|
1508
1584
|
size: "icon",
|
|
1509
|
-
"aria-label":
|
|
1585
|
+
"aria-label": defaultLabels6.language,
|
|
1510
1586
|
className: cn(sizes.buttonMini, shapeClass, className),
|
|
1511
1587
|
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Languages, { className: sizes.iconMini })
|
|
1512
1588
|
}
|
|
@@ -1597,6 +1673,378 @@ function LanguageSwitcher({
|
|
|
1597
1673
|
}
|
|
1598
1674
|
);
|
|
1599
1675
|
}
|
|
1676
|
+
function PlatformNavbar({
|
|
1677
|
+
logo,
|
|
1678
|
+
leading,
|
|
1679
|
+
center,
|
|
1680
|
+
right,
|
|
1681
|
+
className,
|
|
1682
|
+
innerClassName
|
|
1683
|
+
}) {
|
|
1684
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1685
|
+
"header",
|
|
1686
|
+
{
|
|
1687
|
+
className: cn(
|
|
1688
|
+
"sticky top-0 z-30 shrink-0 border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60",
|
|
1689
|
+
className
|
|
1690
|
+
),
|
|
1691
|
+
"data-testid": "platform-navbar",
|
|
1692
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1693
|
+
"div",
|
|
1694
|
+
{
|
|
1695
|
+
className: cn(
|
|
1696
|
+
"flex h-14 min-h-14 items-center gap-2 px-4 md:px-6",
|
|
1697
|
+
innerClassName
|
|
1698
|
+
),
|
|
1699
|
+
children: [
|
|
1700
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex shrink-0 items-center gap-2", children: logo }),
|
|
1701
|
+
leading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex shrink-0 items-center gap-2", children: leading }) : null,
|
|
1702
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex min-w-0 flex-1 items-center overflow-x-auto", children: center }),
|
|
1703
|
+
right ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex shrink-0 items-center gap-2", children: right }) : null
|
|
1704
|
+
]
|
|
1705
|
+
}
|
|
1706
|
+
)
|
|
1707
|
+
}
|
|
1708
|
+
);
|
|
1709
|
+
}
|
|
1710
|
+
var LABELS = {
|
|
1711
|
+
verified: "M\xE9dico verificado",
|
|
1712
|
+
pending_review: "Verificaci\xF3n en revisi\xF3n"
|
|
1713
|
+
};
|
|
1714
|
+
var sizeClasses3 = {
|
|
1715
|
+
sm: {
|
|
1716
|
+
icon: "size-3.5",
|
|
1717
|
+
text: "text-xs",
|
|
1718
|
+
gap: "gap-1",
|
|
1719
|
+
padding: "px-1.5 py-0.5"
|
|
1720
|
+
},
|
|
1721
|
+
md: {
|
|
1722
|
+
icon: "size-4",
|
|
1723
|
+
text: "text-sm",
|
|
1724
|
+
gap: "gap-1.5",
|
|
1725
|
+
padding: "px-2 py-0.5"
|
|
1726
|
+
}
|
|
1727
|
+
};
|
|
1728
|
+
function VerifiedProfessionalBadge({
|
|
1729
|
+
status,
|
|
1730
|
+
size = "md",
|
|
1731
|
+
showLabel = false,
|
|
1732
|
+
className
|
|
1733
|
+
}) {
|
|
1734
|
+
if (status === "unverified" || status === "pending_review" && !showLabel) {
|
|
1735
|
+
return null;
|
|
1736
|
+
}
|
|
1737
|
+
const label = LABELS[status];
|
|
1738
|
+
const sizes = sizeClasses3[size];
|
|
1739
|
+
const Icon = status === "verified" ? lucideReact.BadgeCheck : lucideReact.Clock;
|
|
1740
|
+
const colorClass = status === "verified" ? "text-primary" : "text-muted-foreground";
|
|
1741
|
+
if (!showLabel) {
|
|
1742
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1743
|
+
Icon,
|
|
1744
|
+
{
|
|
1745
|
+
className: cn(sizes.icon, colorClass, className),
|
|
1746
|
+
"aria-label": label,
|
|
1747
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("title", { children: label })
|
|
1748
|
+
}
|
|
1749
|
+
);
|
|
1750
|
+
}
|
|
1751
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1752
|
+
"span",
|
|
1753
|
+
{
|
|
1754
|
+
title: label,
|
|
1755
|
+
"aria-label": label,
|
|
1756
|
+
className: cn(
|
|
1757
|
+
"inline-flex w-fit items-center rounded-full font-medium",
|
|
1758
|
+
sizes.gap,
|
|
1759
|
+
sizes.text,
|
|
1760
|
+
sizes.padding,
|
|
1761
|
+
status === "verified" ? "bg-primary/10 text-primary" : "bg-muted text-muted-foreground",
|
|
1762
|
+
className
|
|
1763
|
+
),
|
|
1764
|
+
children: [
|
|
1765
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { className: sizes.icon, "aria-hidden": "true" }),
|
|
1766
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: label })
|
|
1767
|
+
]
|
|
1768
|
+
}
|
|
1769
|
+
);
|
|
1770
|
+
}
|
|
1771
|
+
var defaultLabels3 = {
|
|
1772
|
+
accountMenu: "Account menu",
|
|
1773
|
+
settingsMenu: "Settings",
|
|
1774
|
+
personalProfile: "Personal profile",
|
|
1775
|
+
activity: "Activity",
|
|
1776
|
+
professionalProfile: "Professional profile",
|
|
1777
|
+
mainApp: "Main app",
|
|
1778
|
+
orgManagement: "Organization management",
|
|
1779
|
+
backoffice: "Backoffice",
|
|
1780
|
+
memberOrgs: "My organizations",
|
|
1781
|
+
managementOrgs: "Management team",
|
|
1782
|
+
language: "Language",
|
|
1783
|
+
theme: "Theme",
|
|
1784
|
+
themeLight: "Light",
|
|
1785
|
+
themeDark: "Dark",
|
|
1786
|
+
themeSystem: "System",
|
|
1787
|
+
signIn: "Sign in",
|
|
1788
|
+
signOut: "Sign out",
|
|
1789
|
+
signingOut: "Signing out\u2026",
|
|
1790
|
+
accountSettings: "Account settings"
|
|
1791
|
+
};
|
|
1792
|
+
function MenuAvatar({
|
|
1793
|
+
name,
|
|
1794
|
+
image,
|
|
1795
|
+
sizeClass
|
|
1796
|
+
}) {
|
|
1797
|
+
const initials = getInitials(name);
|
|
1798
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1799
|
+
"span",
|
|
1800
|
+
{
|
|
1801
|
+
className: cn(
|
|
1802
|
+
"relative flex shrink-0 overflow-hidden rounded-full",
|
|
1803
|
+
sizeClass
|
|
1804
|
+
),
|
|
1805
|
+
children: image ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1806
|
+
"img",
|
|
1807
|
+
{
|
|
1808
|
+
src: image,
|
|
1809
|
+
alt: "",
|
|
1810
|
+
className: "aspect-square size-full object-cover"
|
|
1811
|
+
}
|
|
1812
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1813
|
+
"span",
|
|
1814
|
+
{
|
|
1815
|
+
className: "flex size-full items-center justify-center text-xs font-semibold",
|
|
1816
|
+
style: avatarFallbackStyle(name),
|
|
1817
|
+
children: initials
|
|
1818
|
+
}
|
|
1819
|
+
)
|
|
1820
|
+
}
|
|
1821
|
+
);
|
|
1822
|
+
}
|
|
1823
|
+
function LanguageThemeSubs({
|
|
1824
|
+
languages,
|
|
1825
|
+
currentLanguage,
|
|
1826
|
+
onLanguageChange,
|
|
1827
|
+
labels
|
|
1828
|
+
}) {
|
|
1829
|
+
const { theme, setTheme } = nextThemes.useTheme();
|
|
1830
|
+
const themeValue = theme ?? "system";
|
|
1831
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1832
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuSub, { children: [
|
|
1833
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuSubTrigger, { className: "gap-2", children: [
|
|
1834
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Languages, { className: "size-4" }),
|
|
1835
|
+
labels.language
|
|
1836
|
+
] }),
|
|
1837
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSubContent, { className: "min-w-40", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1838
|
+
DropdownMenuRadioGroup,
|
|
1839
|
+
{
|
|
1840
|
+
value: currentLanguage,
|
|
1841
|
+
onValueChange: onLanguageChange,
|
|
1842
|
+
children: languages.map((lang) => /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuRadioItem, { value: lang.key, children: lang.nativeName }, lang.key))
|
|
1843
|
+
}
|
|
1844
|
+
) })
|
|
1845
|
+
] }),
|
|
1846
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuSub, { children: [
|
|
1847
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuSubTrigger, { className: "gap-2", children: [
|
|
1848
|
+
themeValue === "light" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Sun, { className: "size-4" }) : themeValue === "dark" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Moon, { className: "size-4" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Monitor, { className: "size-4" }),
|
|
1849
|
+
labels.theme
|
|
1850
|
+
] }),
|
|
1851
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSubContent, { className: "min-w-40", children: /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuRadioGroup, { value: themeValue, onValueChange: setTheme, children: [
|
|
1852
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuRadioItem, { value: "system", children: labels.themeSystem }),
|
|
1853
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuRadioItem, { value: "light", children: labels.themeLight }),
|
|
1854
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuRadioItem, { value: "dark", children: labels.themeDark })
|
|
1855
|
+
] }) })
|
|
1856
|
+
] })
|
|
1857
|
+
] });
|
|
1858
|
+
}
|
|
1859
|
+
function PlatformAccountMenu({
|
|
1860
|
+
variant = "platform",
|
|
1861
|
+
isPending = false,
|
|
1862
|
+
user = null,
|
|
1863
|
+
isAdmin = false,
|
|
1864
|
+
verificationStatus = "unverified",
|
|
1865
|
+
urls,
|
|
1866
|
+
memberOrgs = [],
|
|
1867
|
+
manageableOrgs = [],
|
|
1868
|
+
languages = defaultLanguages,
|
|
1869
|
+
currentLanguage,
|
|
1870
|
+
onLanguageChange,
|
|
1871
|
+
labels: labelsProp,
|
|
1872
|
+
onSignOut,
|
|
1873
|
+
extraItems,
|
|
1874
|
+
className
|
|
1875
|
+
}) {
|
|
1876
|
+
const labels = { ...defaultLabels3, ...labelsProp };
|
|
1877
|
+
const [signingOut, setSigningOut] = React7.useState(false);
|
|
1878
|
+
const loginHref = `${urls.authAppUrl}${urls.loginPath ?? "/login"}`;
|
|
1879
|
+
const accountHref = `${urls.authAppUrl}${urls.accountPath ?? "/account"}`;
|
|
1880
|
+
const activityHref = `${urls.authAppUrl}${urls.activityPath ?? "/account/activity"}`;
|
|
1881
|
+
const profileHref = `${urls.appUrl}${urls.professionalProfilePath ?? "/profile"}`;
|
|
1882
|
+
async function handleSignOut() {
|
|
1883
|
+
if (!onSignOut) return;
|
|
1884
|
+
setSigningOut(true);
|
|
1885
|
+
try {
|
|
1886
|
+
await onSignOut();
|
|
1887
|
+
} finally {
|
|
1888
|
+
setSigningOut(false);
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
if (isPending) {
|
|
1892
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1893
|
+
"div",
|
|
1894
|
+
{
|
|
1895
|
+
className: cn(
|
|
1896
|
+
"size-9 shrink-0 animate-pulse rounded-full bg-muted",
|
|
1897
|
+
className
|
|
1898
|
+
),
|
|
1899
|
+
"aria-hidden": true
|
|
1900
|
+
}
|
|
1901
|
+
);
|
|
1902
|
+
}
|
|
1903
|
+
const trigger = user ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1904
|
+
Button,
|
|
1905
|
+
{
|
|
1906
|
+
variant: "ghost",
|
|
1907
|
+
size: "icon",
|
|
1908
|
+
className: cn("size-9 rounded-full", className),
|
|
1909
|
+
"aria-label": labels.accountMenu,
|
|
1910
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(MenuAvatar, { name: user.name, image: user.image, sizeClass: "size-8" })
|
|
1911
|
+
}
|
|
1912
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1913
|
+
Button,
|
|
1914
|
+
{
|
|
1915
|
+
variant: "ghost",
|
|
1916
|
+
size: "icon",
|
|
1917
|
+
className: cn("size-9", className),
|
|
1918
|
+
"aria-label": labels.settingsMenu,
|
|
1919
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Settings, { className: "size-4" })
|
|
1920
|
+
}
|
|
1921
|
+
);
|
|
1922
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { children: [
|
|
1923
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: trigger }),
|
|
1924
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuContent, { align: "end", className: "min-w-60 rounded-lg", children: user ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1925
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuLabel, { className: "flex items-center gap-3 p-2 font-normal", children: [
|
|
1926
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1927
|
+
MenuAvatar,
|
|
1928
|
+
{
|
|
1929
|
+
name: user.name,
|
|
1930
|
+
image: user.image,
|
|
1931
|
+
sizeClass: "size-9"
|
|
1932
|
+
}
|
|
1933
|
+
),
|
|
1934
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-col", children: [
|
|
1935
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 items-center gap-1.5 truncate text-sm font-medium leading-tight", children: [
|
|
1936
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: user.name }),
|
|
1937
|
+
variant === "platform" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1938
|
+
VerifiedProfessionalBadge,
|
|
1939
|
+
{
|
|
1940
|
+
status: verificationStatus,
|
|
1941
|
+
className: "shrink-0"
|
|
1942
|
+
}
|
|
1943
|
+
) : null
|
|
1944
|
+
] }),
|
|
1945
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-xs text-muted-foreground leading-tight", children: user.email })
|
|
1946
|
+
] })
|
|
1947
|
+
] }),
|
|
1948
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {}),
|
|
1949
|
+
variant === "platform" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1950
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, { asChild: true, className: "gap-2", children: /* @__PURE__ */ jsxRuntime.jsxs("a", { href: accountHref, children: [
|
|
1951
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.User, { className: "size-4" }),
|
|
1952
|
+
labels.personalProfile
|
|
1953
|
+
] }) }),
|
|
1954
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, { asChild: true, className: "gap-2", children: /* @__PURE__ */ jsxRuntime.jsxs("a", { href: activityHref, children: [
|
|
1955
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Activity, { className: "size-4" }),
|
|
1956
|
+
labels.activity
|
|
1957
|
+
] }) }),
|
|
1958
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, { asChild: true, className: "gap-2", children: /* @__PURE__ */ jsxRuntime.jsxs("a", { href: profileHref, children: [
|
|
1959
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.User, { className: "size-4" }),
|
|
1960
|
+
labels.professionalProfile
|
|
1961
|
+
] }) }),
|
|
1962
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, { asChild: true, className: "gap-2", children: /* @__PURE__ */ jsxRuntime.jsxs("a", { href: urls.appUrl, children: [
|
|
1963
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.LayoutDashboard, { className: "size-4" }),
|
|
1964
|
+
labels.mainApp
|
|
1965
|
+
] }) }),
|
|
1966
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, { asChild: true, className: "gap-2", children: /* @__PURE__ */ jsxRuntime.jsxs("a", { href: urls.adminUrl, children: [
|
|
1967
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Building2, { className: "size-4" }),
|
|
1968
|
+
labels.orgManagement
|
|
1969
|
+
] }) }),
|
|
1970
|
+
isAdmin && urls.backofficeUrl ? /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, { asChild: true, className: "gap-2", children: /* @__PURE__ */ jsxRuntime.jsxs("a", { href: urls.backofficeUrl, children: [
|
|
1971
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.LayoutDashboard, { className: "size-4" }),
|
|
1972
|
+
labels.backoffice
|
|
1973
|
+
] }) }) : null,
|
|
1974
|
+
memberOrgs.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuSub, { children: [
|
|
1975
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuSubTrigger, { className: "gap-2", children: [
|
|
1976
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Users, { className: "size-4" }),
|
|
1977
|
+
labels.memberOrgs
|
|
1978
|
+
] }),
|
|
1979
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSubContent, { className: "min-w-48 max-h-64 overflow-y-auto", children: memberOrgs.map((org) => /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("a", { href: `${urls.appUrl}/o/${org.slug}`, children: org.name }) }, org.id)) })
|
|
1980
|
+
] }) : null,
|
|
1981
|
+
manageableOrgs.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuSub, { children: [
|
|
1982
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuSubTrigger, { className: "gap-2", children: [
|
|
1983
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Building2, { className: "size-4" }),
|
|
1984
|
+
labels.managementOrgs
|
|
1985
|
+
] }),
|
|
1986
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSubContent, { className: "min-w-48 max-h-64 overflow-y-auto", children: manageableOrgs.map((org) => /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1987
|
+
"a",
|
|
1988
|
+
{
|
|
1989
|
+
href: `${urls.adminUrl}/api/auth/org/select?id=${encodeURIComponent(org.id)}`,
|
|
1990
|
+
children: org.name
|
|
1991
|
+
}
|
|
1992
|
+
) }, org.id)) })
|
|
1993
|
+
] }) : null,
|
|
1994
|
+
extraItems,
|
|
1995
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {})
|
|
1996
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1997
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, { asChild: true, className: "gap-2", children: /* @__PURE__ */ jsxRuntime.jsxs("a", { href: accountHref, children: [
|
|
1998
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Settings, { className: "size-4" }),
|
|
1999
|
+
labels.accountSettings
|
|
2000
|
+
] }) }),
|
|
2001
|
+
extraItems,
|
|
2002
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {})
|
|
2003
|
+
] }),
|
|
2004
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2005
|
+
LanguageThemeSubs,
|
|
2006
|
+
{
|
|
2007
|
+
languages,
|
|
2008
|
+
currentLanguage,
|
|
2009
|
+
onLanguageChange,
|
|
2010
|
+
labels
|
|
2011
|
+
}
|
|
2012
|
+
),
|
|
2013
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {}),
|
|
2014
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2015
|
+
DropdownMenuItem,
|
|
2016
|
+
{
|
|
2017
|
+
variant: "destructive",
|
|
2018
|
+
className: "gap-2",
|
|
2019
|
+
disabled: signingOut || !onSignOut,
|
|
2020
|
+
onSelect: (event) => {
|
|
2021
|
+
event.preventDefault();
|
|
2022
|
+
void handleSignOut();
|
|
2023
|
+
},
|
|
2024
|
+
children: [
|
|
2025
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.LogOut, { className: "size-4" }),
|
|
2026
|
+
signingOut ? labels.signingOut : labels.signOut
|
|
2027
|
+
]
|
|
2028
|
+
}
|
|
2029
|
+
)
|
|
2030
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2031
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2032
|
+
LanguageThemeSubs,
|
|
2033
|
+
{
|
|
2034
|
+
languages,
|
|
2035
|
+
currentLanguage,
|
|
2036
|
+
onLanguageChange,
|
|
2037
|
+
labels
|
|
2038
|
+
}
|
|
2039
|
+
),
|
|
2040
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {}),
|
|
2041
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, { asChild: true, className: "gap-2", children: /* @__PURE__ */ jsxRuntime.jsxs("a", { href: loginHref, children: [
|
|
2042
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.LogIn, { className: "size-4" }),
|
|
2043
|
+
labels.signIn
|
|
2044
|
+
] }) })
|
|
2045
|
+
] }) })
|
|
2046
|
+
] });
|
|
2047
|
+
}
|
|
1600
2048
|
function Slider({
|
|
1601
2049
|
className,
|
|
1602
2050
|
defaultValue,
|
|
@@ -4915,7 +5363,7 @@ function SearchablePickerList({
|
|
|
4915
5363
|
] })
|
|
4916
5364
|
] });
|
|
4917
5365
|
}
|
|
4918
|
-
var
|
|
5366
|
+
var defaultLabels4 = {
|
|
4919
5367
|
placeholder: "Seleccionar\u2026",
|
|
4920
5368
|
searchPlaceholder: "Buscar\u2026",
|
|
4921
5369
|
empty: "No se encontraron resultados",
|
|
@@ -4988,7 +5436,7 @@ function SearchablePicker(props) {
|
|
|
4988
5436
|
"aria-label": ariaLabel
|
|
4989
5437
|
} = props;
|
|
4990
5438
|
const mode = props.mode ?? "single";
|
|
4991
|
-
const labels = { ...
|
|
5439
|
+
const labels = { ...defaultLabels4, ...userLabels };
|
|
4992
5440
|
const resolvedEmptyLabel = emptyLabel ?? labels.emptyOption;
|
|
4993
5441
|
const isMobile = useMediaQuery2("(max-width: 767px)");
|
|
4994
5442
|
const generatedId = React7.useId();
|
|
@@ -5328,7 +5776,7 @@ function SearchablePicker(props) {
|
|
|
5328
5776
|
clearButton
|
|
5329
5777
|
] });
|
|
5330
5778
|
}
|
|
5331
|
-
var
|
|
5779
|
+
var defaultLabels5 = {
|
|
5332
5780
|
placeholder: "Buscar en toda la plataforma\u2026",
|
|
5333
5781
|
dialogTitle: "Buscar",
|
|
5334
5782
|
dialogDescription: "Busca funcionalidades, eventos, documentos y m\xE1s",
|
|
@@ -5362,7 +5810,7 @@ function SearchCommand({
|
|
|
5362
5810
|
debounceMs = 200,
|
|
5363
5811
|
className
|
|
5364
5812
|
}) {
|
|
5365
|
-
const labels = { ...
|
|
5813
|
+
const labels = { ...defaultLabels5, ...userLabels };
|
|
5366
5814
|
const [query, setQuery] = React7.useState("");
|
|
5367
5815
|
const [hits, setHits] = React7.useState([]);
|
|
5368
5816
|
const [isLoading, setIsLoading] = React7.useState(false);
|
|
@@ -5804,67 +6252,6 @@ function MexicoMap({ selected, onToggle, className }) {
|
|
|
5804
6252
|
}
|
|
5805
6253
|
);
|
|
5806
6254
|
}
|
|
5807
|
-
var LABELS = {
|
|
5808
|
-
verified: "M\xE9dico verificado",
|
|
5809
|
-
pending_review: "Verificaci\xF3n en revisi\xF3n"
|
|
5810
|
-
};
|
|
5811
|
-
var sizeClasses3 = {
|
|
5812
|
-
sm: {
|
|
5813
|
-
icon: "size-3.5",
|
|
5814
|
-
text: "text-xs",
|
|
5815
|
-
gap: "gap-1",
|
|
5816
|
-
padding: "px-1.5 py-0.5"
|
|
5817
|
-
},
|
|
5818
|
-
md: {
|
|
5819
|
-
icon: "size-4",
|
|
5820
|
-
text: "text-sm",
|
|
5821
|
-
gap: "gap-1.5",
|
|
5822
|
-
padding: "px-2 py-0.5"
|
|
5823
|
-
}
|
|
5824
|
-
};
|
|
5825
|
-
function VerifiedProfessionalBadge({
|
|
5826
|
-
status,
|
|
5827
|
-
size = "md",
|
|
5828
|
-
showLabel = false,
|
|
5829
|
-
className
|
|
5830
|
-
}) {
|
|
5831
|
-
if (status === "unverified" || status === "pending_review" && !showLabel) {
|
|
5832
|
-
return null;
|
|
5833
|
-
}
|
|
5834
|
-
const label = LABELS[status];
|
|
5835
|
-
const sizes = sizeClasses3[size];
|
|
5836
|
-
const Icon = status === "verified" ? lucideReact.BadgeCheck : lucideReact.Clock;
|
|
5837
|
-
const colorClass = status === "verified" ? "text-primary" : "text-muted-foreground";
|
|
5838
|
-
if (!showLabel) {
|
|
5839
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5840
|
-
Icon,
|
|
5841
|
-
{
|
|
5842
|
-
className: cn(sizes.icon, colorClass, className),
|
|
5843
|
-
"aria-label": label,
|
|
5844
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("title", { children: label })
|
|
5845
|
-
}
|
|
5846
|
-
);
|
|
5847
|
-
}
|
|
5848
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5849
|
-
"span",
|
|
5850
|
-
{
|
|
5851
|
-
title: label,
|
|
5852
|
-
"aria-label": label,
|
|
5853
|
-
className: cn(
|
|
5854
|
-
"inline-flex w-fit items-center rounded-full font-medium",
|
|
5855
|
-
sizes.gap,
|
|
5856
|
-
sizes.text,
|
|
5857
|
-
sizes.padding,
|
|
5858
|
-
status === "verified" ? "bg-primary/10 text-primary" : "bg-muted text-muted-foreground",
|
|
5859
|
-
className
|
|
5860
|
-
),
|
|
5861
|
-
children: [
|
|
5862
|
-
/* @__PURE__ */ jsxRuntime.jsx(Icon, { className: sizes.icon, "aria-hidden": "true" }),
|
|
5863
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: label })
|
|
5864
|
-
]
|
|
5865
|
-
}
|
|
5866
|
-
);
|
|
5867
|
-
}
|
|
5868
6255
|
function MessageGroup({ className, ...props }) {
|
|
5869
6256
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5870
6257
|
"div",
|
|
@@ -6985,6 +7372,162 @@ function createSupportChatClient(basePath = "/api/chat-svc") {
|
|
|
6985
7372
|
}
|
|
6986
7373
|
var DEFAULT_RECONNECT_MS = 2e3;
|
|
6987
7374
|
var MAX_RECONNECT_MS = 3e4;
|
|
7375
|
+
var HEARTBEAT_MS = 3e4;
|
|
7376
|
+
var registry = /* @__PURE__ */ new Map();
|
|
7377
|
+
function channelKeyFromUrl(url) {
|
|
7378
|
+
const q = url.indexOf("?");
|
|
7379
|
+
return q === -1 ? url : url.slice(0, q);
|
|
7380
|
+
}
|
|
7381
|
+
function stopHeartbeat(shared) {
|
|
7382
|
+
if (shared.heartbeatTimer) {
|
|
7383
|
+
clearInterval(shared.heartbeatTimer);
|
|
7384
|
+
shared.heartbeatTimer = null;
|
|
7385
|
+
}
|
|
7386
|
+
}
|
|
7387
|
+
function startHeartbeat(shared, gen) {
|
|
7388
|
+
stopHeartbeat(shared);
|
|
7389
|
+
shared.heartbeatTimer = setInterval(() => {
|
|
7390
|
+
if (gen !== shared.gen) return;
|
|
7391
|
+
if (shared.ws?.readyState === WebSocket.OPEN) {
|
|
7392
|
+
try {
|
|
7393
|
+
shared.ws.send("ping");
|
|
7394
|
+
} catch {
|
|
7395
|
+
}
|
|
7396
|
+
}
|
|
7397
|
+
}, HEARTBEAT_MS);
|
|
7398
|
+
}
|
|
7399
|
+
function clearReconnect(shared) {
|
|
7400
|
+
if (shared.reconnectTimer) {
|
|
7401
|
+
clearTimeout(shared.reconnectTimer);
|
|
7402
|
+
shared.reconnectTimer = null;
|
|
7403
|
+
}
|
|
7404
|
+
}
|
|
7405
|
+
function openSocket(shared, url) {
|
|
7406
|
+
const gen = ++shared.gen;
|
|
7407
|
+
clearReconnect(shared);
|
|
7408
|
+
if (shared.ws) {
|
|
7409
|
+
try {
|
|
7410
|
+
shared.ws.close();
|
|
7411
|
+
} catch {
|
|
7412
|
+
}
|
|
7413
|
+
}
|
|
7414
|
+
const ws = new WebSocket(url);
|
|
7415
|
+
shared.ws = ws;
|
|
7416
|
+
ws.onopen = () => {
|
|
7417
|
+
if (gen !== shared.gen) return;
|
|
7418
|
+
shared.attempt = 0;
|
|
7419
|
+
startHeartbeat(shared, gen);
|
|
7420
|
+
};
|
|
7421
|
+
ws.onmessage = (msg) => {
|
|
7422
|
+
if (gen !== shared.gen) return;
|
|
7423
|
+
let data;
|
|
7424
|
+
try {
|
|
7425
|
+
data = JSON.parse(String(msg.data));
|
|
7426
|
+
} catch {
|
|
7427
|
+
return;
|
|
7428
|
+
}
|
|
7429
|
+
if (typeof data?.type !== "string") return;
|
|
7430
|
+
if (data.type === "pong") return;
|
|
7431
|
+
for (const listener of shared.listeners) {
|
|
7432
|
+
listener(data);
|
|
7433
|
+
}
|
|
7434
|
+
};
|
|
7435
|
+
ws.onclose = () => {
|
|
7436
|
+
if (gen !== shared.gen) return;
|
|
7437
|
+
shared.ws = null;
|
|
7438
|
+
stopHeartbeat(shared);
|
|
7439
|
+
scheduleReconnect(shared);
|
|
7440
|
+
};
|
|
7441
|
+
ws.onerror = () => {
|
|
7442
|
+
};
|
|
7443
|
+
}
|
|
7444
|
+
function scheduleReconnect(shared) {
|
|
7445
|
+
if (shared.listeners.size === 0) return;
|
|
7446
|
+
clearReconnect(shared);
|
|
7447
|
+
const delay = Math.min(
|
|
7448
|
+
shared.reconnectDelayMs * 2 ** shared.attempt,
|
|
7449
|
+
MAX_RECONNECT_MS
|
|
7450
|
+
);
|
|
7451
|
+
shared.attempt += 1;
|
|
7452
|
+
shared.reconnectTimer = setTimeout(() => {
|
|
7453
|
+
shared.reconnectTimer = null;
|
|
7454
|
+
void connectShared(shared);
|
|
7455
|
+
}, delay);
|
|
7456
|
+
}
|
|
7457
|
+
async function connectShared(shared) {
|
|
7458
|
+
if (shared.connecting || shared.listeners.size === 0) return;
|
|
7459
|
+
shared.connecting = true;
|
|
7460
|
+
let url = null;
|
|
7461
|
+
try {
|
|
7462
|
+
url = await shared.getWsUrl();
|
|
7463
|
+
} finally {
|
|
7464
|
+
shared.connecting = false;
|
|
7465
|
+
}
|
|
7466
|
+
if (shared.listeners.size === 0) return;
|
|
7467
|
+
if (!url) return;
|
|
7468
|
+
openSocket(shared, url);
|
|
7469
|
+
}
|
|
7470
|
+
function destroyShared(shared) {
|
|
7471
|
+
shared.gen += 1;
|
|
7472
|
+
clearReconnect(shared);
|
|
7473
|
+
stopHeartbeat(shared);
|
|
7474
|
+
if (shared.ws) {
|
|
7475
|
+
try {
|
|
7476
|
+
shared.ws.close();
|
|
7477
|
+
} catch {
|
|
7478
|
+
}
|
|
7479
|
+
shared.ws = null;
|
|
7480
|
+
}
|
|
7481
|
+
}
|
|
7482
|
+
function joinChannel(key, url, getWsUrl, reconnectDelayMs, listener) {
|
|
7483
|
+
ensureVisibilityHook();
|
|
7484
|
+
let shared = registry.get(key);
|
|
7485
|
+
if (!shared) {
|
|
7486
|
+
shared = {
|
|
7487
|
+
key,
|
|
7488
|
+
listeners: /* @__PURE__ */ new Set(),
|
|
7489
|
+
getWsUrl,
|
|
7490
|
+
reconnectDelayMs,
|
|
7491
|
+
ws: null,
|
|
7492
|
+
attempt: 0,
|
|
7493
|
+
reconnectTimer: null,
|
|
7494
|
+
heartbeatTimer: null,
|
|
7495
|
+
connecting: false,
|
|
7496
|
+
gen: 0
|
|
7497
|
+
};
|
|
7498
|
+
registry.set(key, shared);
|
|
7499
|
+
shared.listeners.add(listener);
|
|
7500
|
+
openSocket(shared, url);
|
|
7501
|
+
return;
|
|
7502
|
+
}
|
|
7503
|
+
shared.getWsUrl = getWsUrl;
|
|
7504
|
+
shared.listeners.add(listener);
|
|
7505
|
+
if (!shared.ws && !shared.connecting && !shared.reconnectTimer) {
|
|
7506
|
+
openSocket(shared, url);
|
|
7507
|
+
}
|
|
7508
|
+
}
|
|
7509
|
+
function leaveChannel(key, listener) {
|
|
7510
|
+
const shared = registry.get(key);
|
|
7511
|
+
if (!shared) return;
|
|
7512
|
+
shared.listeners.delete(listener);
|
|
7513
|
+
if (shared.listeners.size === 0) {
|
|
7514
|
+
destroyShared(shared);
|
|
7515
|
+
registry.delete(key);
|
|
7516
|
+
}
|
|
7517
|
+
}
|
|
7518
|
+
var visibilityHooked = false;
|
|
7519
|
+
function ensureVisibilityHook() {
|
|
7520
|
+
if (visibilityHooked || typeof document === "undefined") return;
|
|
7521
|
+
visibilityHooked = true;
|
|
7522
|
+
document.addEventListener("visibilitychange", () => {
|
|
7523
|
+
if (document.visibilityState !== "visible") return;
|
|
7524
|
+
for (const shared of registry.values()) {
|
|
7525
|
+
if (!shared.ws && !shared.reconnectTimer && !shared.connecting) {
|
|
7526
|
+
void connectShared(shared);
|
|
7527
|
+
}
|
|
7528
|
+
}
|
|
7529
|
+
});
|
|
7530
|
+
}
|
|
6988
7531
|
function useRealtimeChannel({
|
|
6989
7532
|
getWsUrl,
|
|
6990
7533
|
onEvent,
|
|
@@ -6998,87 +7541,26 @@ function useRealtimeChannel({
|
|
|
6998
7541
|
React7.useEffect(() => {
|
|
6999
7542
|
if (!enabled) return;
|
|
7000
7543
|
let cancelled = false;
|
|
7001
|
-
let
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
const
|
|
7005
|
-
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7010
|
-
};
|
|
7011
|
-
const scheduleReconnect = () => {
|
|
7012
|
-
if (cancelled) return;
|
|
7013
|
-
clearReconnect();
|
|
7014
|
-
const delay = Math.min(reconnectDelayMs * 2 ** attempt, MAX_RECONNECT_MS);
|
|
7015
|
-
attempt += 1;
|
|
7016
|
-
reconnectTimer = setTimeout(() => {
|
|
7017
|
-
void connect();
|
|
7018
|
-
}, delay);
|
|
7019
|
-
};
|
|
7020
|
-
const connect = async () => {
|
|
7021
|
-
const gen = ++connectGen.current;
|
|
7022
|
-
clearReconnect();
|
|
7023
|
-
const url = await getWsUrlRef.current();
|
|
7024
|
-
if (cancelled || gen !== connectGen.current) return;
|
|
7025
|
-
if (!url) {
|
|
7026
|
-
scheduleReconnect();
|
|
7027
|
-
return;
|
|
7028
|
-
}
|
|
7029
|
-
if (socket) {
|
|
7030
|
-
try {
|
|
7031
|
-
socket.close();
|
|
7032
|
-
} catch {
|
|
7033
|
-
}
|
|
7034
|
-
socket = null;
|
|
7035
|
-
}
|
|
7036
|
-
const ws = new WebSocket(url);
|
|
7037
|
-
socket = ws;
|
|
7038
|
-
ws.onopen = () => {
|
|
7039
|
-
if (cancelled || gen !== connectGen.current) return;
|
|
7040
|
-
attempt = 0;
|
|
7041
|
-
};
|
|
7042
|
-
ws.onmessage = (msg) => {
|
|
7043
|
-
if (cancelled || gen !== connectGen.current) return;
|
|
7044
|
-
let data;
|
|
7045
|
-
try {
|
|
7046
|
-
data = JSON.parse(String(msg.data));
|
|
7047
|
-
} catch {
|
|
7048
|
-
return;
|
|
7049
|
-
}
|
|
7050
|
-
if (typeof data?.type !== "string") return;
|
|
7051
|
-
if (data.type === "pong") return;
|
|
7052
|
-
onEventRef.current(data);
|
|
7053
|
-
};
|
|
7054
|
-
ws.onclose = () => {
|
|
7055
|
-
if (cancelled || gen !== connectGen.current) return;
|
|
7056
|
-
socket = null;
|
|
7057
|
-
scheduleReconnect();
|
|
7058
|
-
};
|
|
7059
|
-
ws.onerror = () => {
|
|
7060
|
-
};
|
|
7544
|
+
let joinedKey = null;
|
|
7545
|
+
const listener = (event) => onEventRef.current(event);
|
|
7546
|
+
const resolver = () => getWsUrlRef.current();
|
|
7547
|
+
const join = async () => {
|
|
7548
|
+
if (cancelled || joinedKey) return;
|
|
7549
|
+
const url = await resolver();
|
|
7550
|
+
if (cancelled || !url) return;
|
|
7551
|
+
joinedKey = channelKeyFromUrl(url);
|
|
7552
|
+
joinChannel(joinedKey, url, resolver, reconnectDelayMs, listener);
|
|
7061
7553
|
};
|
|
7062
7554
|
const onVisibility = () => {
|
|
7063
7555
|
if (document.visibilityState !== "visible" || cancelled) return;
|
|
7064
|
-
if (!
|
|
7065
|
-
void connect();
|
|
7066
|
-
}
|
|
7556
|
+
if (!joinedKey) void join();
|
|
7067
7557
|
};
|
|
7068
|
-
void
|
|
7558
|
+
void join();
|
|
7069
7559
|
document.addEventListener("visibilitychange", onVisibility);
|
|
7070
7560
|
return () => {
|
|
7071
7561
|
cancelled = true;
|
|
7072
|
-
connectGen.current += 1;
|
|
7073
|
-
clearReconnect();
|
|
7074
7562
|
document.removeEventListener("visibilitychange", onVisibility);
|
|
7075
|
-
if (
|
|
7076
|
-
try {
|
|
7077
|
-
socket.close();
|
|
7078
|
-
} catch {
|
|
7079
|
-
}
|
|
7080
|
-
socket = null;
|
|
7081
|
-
}
|
|
7563
|
+
if (joinedKey) leaveChannel(joinedKey, listener);
|
|
7082
7564
|
};
|
|
7083
7565
|
}, [enabled, reconnectDelayMs]);
|
|
7084
7566
|
}
|
|
@@ -7141,6 +7623,8 @@ exports.MessageScrollerViewport = MessageScrollerViewport;
|
|
|
7141
7623
|
exports.MexicoMap = MexicoMap;
|
|
7142
7624
|
exports.OrgSwitcher = OrgSwitcher;
|
|
7143
7625
|
exports.PhoneInput = PhoneInput;
|
|
7626
|
+
exports.PlatformAccountMenu = PlatformAccountMenu;
|
|
7627
|
+
exports.PlatformNavbar = PlatformNavbar;
|
|
7144
7628
|
exports.SearchCommand = SearchCommand;
|
|
7145
7629
|
exports.SearchablePicker = SearchablePicker;
|
|
7146
7630
|
exports.SupportMessengerProvider = SupportMessengerProvider;
|