analytica-frontend-lib 1.3.6 → 1.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +342 -346
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +327 -331
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -22562,43 +22562,234 @@ var NotFound_default = NotFound;
|
|
|
22562
22562
|
|
|
22563
22563
|
// src/components/RestrictedAccess/RestrictedAccess.tsx
|
|
22564
22564
|
var import_phosphor_react47 = require("phosphor-react");
|
|
22565
|
+
|
|
22566
|
+
// src/components/Auth/Auth.tsx
|
|
22567
|
+
var import_react63 = require("react");
|
|
22568
|
+
var import_react_router_dom4 = require("react-router-dom");
|
|
22569
|
+
|
|
22570
|
+
// src/components/Auth/useTokenInUrl.ts
|
|
22571
|
+
var import_react62 = require("react");
|
|
22572
|
+
var import_react_router_dom3 = require("react-router-dom");
|
|
22573
|
+
function useTokenInUrl() {
|
|
22574
|
+
const location = (0, import_react_router_dom3.useLocation)();
|
|
22575
|
+
const hasTokenInUrl = (0, import_react62.useMemo)(() => {
|
|
22576
|
+
const searchParams = new URLSearchParams(location.search);
|
|
22577
|
+
const token = searchParams.get("token");
|
|
22578
|
+
const refreshToken = searchParams.get("refreshToken");
|
|
22579
|
+
const sessionId = searchParams.get("sessionId");
|
|
22580
|
+
return !!(token && refreshToken && sessionId);
|
|
22581
|
+
}, [location.search]);
|
|
22582
|
+
return { hasTokenInUrl };
|
|
22583
|
+
}
|
|
22584
|
+
|
|
22585
|
+
// src/components/Auth/Auth.tsx
|
|
22565
22586
|
var import_jsx_runtime107 = require("react/jsx-runtime");
|
|
22587
|
+
var AuthContext = (0, import_react63.createContext)(void 0);
|
|
22588
|
+
var AuthProvider = ({
|
|
22589
|
+
children,
|
|
22590
|
+
checkAuthFn,
|
|
22591
|
+
signOutFn,
|
|
22592
|
+
initialAuthState = {},
|
|
22593
|
+
getUserFn,
|
|
22594
|
+
getSessionFn,
|
|
22595
|
+
getTokensFn
|
|
22596
|
+
}) => {
|
|
22597
|
+
const [authState, setAuthState] = (0, import_react63.useState)({
|
|
22598
|
+
isAuthenticated: false,
|
|
22599
|
+
isLoading: true,
|
|
22600
|
+
...initialAuthState
|
|
22601
|
+
});
|
|
22602
|
+
const checkAuth = (0, import_react63.useCallback)(async () => {
|
|
22603
|
+
try {
|
|
22604
|
+
setAuthState((prev) => ({ ...prev, isLoading: true }));
|
|
22605
|
+
if (!checkAuthFn) {
|
|
22606
|
+
setAuthState((prev) => ({
|
|
22607
|
+
...prev,
|
|
22608
|
+
isAuthenticated: false,
|
|
22609
|
+
isLoading: false
|
|
22610
|
+
}));
|
|
22611
|
+
return false;
|
|
22612
|
+
}
|
|
22613
|
+
const isAuth = await checkAuthFn();
|
|
22614
|
+
setAuthState((prev) => ({
|
|
22615
|
+
...prev,
|
|
22616
|
+
isAuthenticated: isAuth,
|
|
22617
|
+
isLoading: false,
|
|
22618
|
+
user: getUserFn ? getUserFn() : prev.user,
|
|
22619
|
+
sessionInfo: getSessionFn ? getSessionFn() : prev.sessionInfo,
|
|
22620
|
+
tokens: getTokensFn ? getTokensFn() : prev.tokens
|
|
22621
|
+
}));
|
|
22622
|
+
return isAuth;
|
|
22623
|
+
} catch (error) {
|
|
22624
|
+
console.error("Erro ao verificar autentica\xE7\xE3o:", error);
|
|
22625
|
+
setAuthState((prev) => ({
|
|
22626
|
+
...prev,
|
|
22627
|
+
isAuthenticated: false,
|
|
22628
|
+
isLoading: false
|
|
22629
|
+
}));
|
|
22630
|
+
return false;
|
|
22631
|
+
}
|
|
22632
|
+
}, [checkAuthFn, getUserFn, getSessionFn, getTokensFn]);
|
|
22633
|
+
const signOut = (0, import_react63.useCallback)(() => {
|
|
22634
|
+
if (signOutFn) {
|
|
22635
|
+
signOutFn();
|
|
22636
|
+
}
|
|
22637
|
+
setAuthState((prev) => ({
|
|
22638
|
+
...prev,
|
|
22639
|
+
isAuthenticated: false,
|
|
22640
|
+
user: void 0,
|
|
22641
|
+
sessionInfo: void 0,
|
|
22642
|
+
tokens: void 0
|
|
22643
|
+
}));
|
|
22644
|
+
}, [signOutFn]);
|
|
22645
|
+
(0, import_react63.useEffect)(() => {
|
|
22646
|
+
checkAuth();
|
|
22647
|
+
}, [checkAuth]);
|
|
22648
|
+
const contextValue = (0, import_react63.useMemo)(
|
|
22649
|
+
() => ({
|
|
22650
|
+
...authState,
|
|
22651
|
+
checkAuth,
|
|
22652
|
+
signOut
|
|
22653
|
+
}),
|
|
22654
|
+
[authState, checkAuth, signOut]
|
|
22655
|
+
);
|
|
22656
|
+
return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(AuthContext.Provider, { value: contextValue, children });
|
|
22657
|
+
};
|
|
22658
|
+
var useAuth = () => {
|
|
22659
|
+
const context = (0, import_react63.useContext)(AuthContext);
|
|
22660
|
+
if (context === void 0) {
|
|
22661
|
+
throw new Error("useAuth deve ser usado dentro de um AuthProvider");
|
|
22662
|
+
}
|
|
22663
|
+
return context;
|
|
22664
|
+
};
|
|
22665
|
+
var ProtectedRoute = ({
|
|
22666
|
+
children,
|
|
22667
|
+
redirectTo = "/",
|
|
22668
|
+
loadingComponent,
|
|
22669
|
+
additionalCheck
|
|
22670
|
+
}) => {
|
|
22671
|
+
const { isAuthenticated, isLoading, ...authState } = useAuth();
|
|
22672
|
+
const defaultLoadingComponent = /* @__PURE__ */ (0, import_jsx_runtime107.jsx)("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)("div", { className: "text-text-950 text-lg", children: "Carregando..." }) });
|
|
22673
|
+
if (isLoading) {
|
|
22674
|
+
return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_jsx_runtime107.Fragment, { children: loadingComponent || defaultLoadingComponent });
|
|
22675
|
+
}
|
|
22676
|
+
if (!isAuthenticated) {
|
|
22677
|
+
if (typeof window !== "undefined") {
|
|
22678
|
+
const rootDomain = getRootDomain();
|
|
22679
|
+
const currentLocation = `${window.location.protocol}//${window.location.hostname}${window.location.port ? ":" + window.location.port : ""}`;
|
|
22680
|
+
if (rootDomain !== currentLocation) {
|
|
22681
|
+
window.location.href = rootDomain;
|
|
22682
|
+
return null;
|
|
22683
|
+
}
|
|
22684
|
+
}
|
|
22685
|
+
return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_react_router_dom4.Navigate, { to: redirectTo, replace: true });
|
|
22686
|
+
}
|
|
22687
|
+
if (additionalCheck && !additionalCheck({ isAuthenticated, isLoading, ...authState })) {
|
|
22688
|
+
return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_react_router_dom4.Navigate, { to: redirectTo, replace: true });
|
|
22689
|
+
}
|
|
22690
|
+
return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_jsx_runtime107.Fragment, { children });
|
|
22691
|
+
};
|
|
22692
|
+
var PublicRoute = ({
|
|
22693
|
+
children,
|
|
22694
|
+
redirectTo = "/painel",
|
|
22695
|
+
redirectIfAuthenticated = false,
|
|
22696
|
+
checkAuthBeforeRender = false,
|
|
22697
|
+
tokenValidationComponent
|
|
22698
|
+
}) => {
|
|
22699
|
+
const { isAuthenticated, isLoading } = useAuth();
|
|
22700
|
+
const { hasTokenInUrl } = useTokenInUrl();
|
|
22701
|
+
if (hasTokenInUrl && tokenValidationComponent) {
|
|
22702
|
+
return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_jsx_runtime107.Fragment, { children: tokenValidationComponent });
|
|
22703
|
+
}
|
|
22704
|
+
if (checkAuthBeforeRender && isLoading) {
|
|
22705
|
+
return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)("div", { className: "text-text-950 text-lg", children: "Carregando..." }) });
|
|
22706
|
+
}
|
|
22707
|
+
if (isAuthenticated && redirectIfAuthenticated) {
|
|
22708
|
+
return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_react_router_dom4.Navigate, { to: redirectTo, replace: true });
|
|
22709
|
+
}
|
|
22710
|
+
return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_jsx_runtime107.Fragment, { children });
|
|
22711
|
+
};
|
|
22712
|
+
var withAuth = (Component, options = {}) => {
|
|
22713
|
+
return (props) => /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(ProtectedRoute, { ...options, children: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(Component, { ...props }) });
|
|
22714
|
+
};
|
|
22715
|
+
var useAuthGuard = (options = {}) => {
|
|
22716
|
+
const authState = useAuth();
|
|
22717
|
+
const { requireAuth = true, customCheck } = options;
|
|
22718
|
+
const canAccess = !authState.isLoading && (requireAuth ? authState.isAuthenticated && (!customCheck || customCheck(authState)) : !authState.isAuthenticated || !customCheck || customCheck(authState));
|
|
22719
|
+
return {
|
|
22720
|
+
canAccess,
|
|
22721
|
+
isLoading: authState.isLoading,
|
|
22722
|
+
authState
|
|
22723
|
+
};
|
|
22724
|
+
};
|
|
22725
|
+
var useRouteAuth = (fallbackPath = "/") => {
|
|
22726
|
+
const { isAuthenticated, isLoading } = useAuth();
|
|
22727
|
+
const location = (0, import_react_router_dom4.useLocation)();
|
|
22728
|
+
const redirectToLogin = () => /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_react_router_dom4.Navigate, { to: fallbackPath, state: { from: location }, replace: true });
|
|
22729
|
+
return {
|
|
22730
|
+
isAuthenticated,
|
|
22731
|
+
isLoading,
|
|
22732
|
+
redirectToLogin
|
|
22733
|
+
};
|
|
22734
|
+
};
|
|
22735
|
+
var getRootDomain = () => {
|
|
22736
|
+
const { hostname, protocol, port } = window.location;
|
|
22737
|
+
const portStr = port ? ":" + port : "";
|
|
22738
|
+
if (hostname === "localhost") {
|
|
22739
|
+
return `${protocol}//${hostname}${portStr}`;
|
|
22740
|
+
}
|
|
22741
|
+
const isIPv4 = /^\d{1,3}(?:\.\d{1,3}){3}$/.test(hostname);
|
|
22742
|
+
const isIPv6 = hostname.includes(":");
|
|
22743
|
+
if (isIPv4 || isIPv6) {
|
|
22744
|
+
return `${protocol}//${hostname}${portStr}`;
|
|
22745
|
+
}
|
|
22746
|
+
const parts = hostname.split(".");
|
|
22747
|
+
if (parts.length >= 3 && parts[parts.length - 2] === "com" && parts[parts.length - 1] === "br") {
|
|
22748
|
+
if (parts.length === 3) {
|
|
22749
|
+
return `${protocol}//${hostname}${portStr}`;
|
|
22750
|
+
}
|
|
22751
|
+
const base = parts.slice(-3).join(".");
|
|
22752
|
+
return `${protocol}//${base}${portStr}`;
|
|
22753
|
+
}
|
|
22754
|
+
if (parts.length > 2) {
|
|
22755
|
+
const base = parts.slice(-2).join(".");
|
|
22756
|
+
return `${protocol}//${base}${portStr}`;
|
|
22757
|
+
}
|
|
22758
|
+
return `${protocol}//${hostname}${portStr}`;
|
|
22759
|
+
};
|
|
22760
|
+
|
|
22761
|
+
// src/components/RestrictedAccess/RestrictedAccess.tsx
|
|
22762
|
+
var import_jsx_runtime108 = require("react/jsx-runtime");
|
|
22566
22763
|
var RestrictedAccess = ({
|
|
22567
22764
|
title = "\xC1rea Restrita",
|
|
22568
22765
|
description = "Este \xE9 um painel administrativo. Fa\xE7a login para acessar o sistema.",
|
|
22569
22766
|
buttonText = "Fazer Login",
|
|
22570
|
-
onLoginClick,
|
|
22571
|
-
loginUrl,
|
|
22572
22767
|
logoSrc,
|
|
22573
22768
|
logoAlt = "Logo",
|
|
22574
22769
|
footerText,
|
|
22575
22770
|
className = ""
|
|
22576
22771
|
}) => {
|
|
22577
22772
|
const handleLoginClick = () => {
|
|
22578
|
-
|
|
22579
|
-
onLoginClick();
|
|
22580
|
-
} else if (loginUrl) {
|
|
22581
|
-
globalThis.location.href = loginUrl;
|
|
22582
|
-
}
|
|
22773
|
+
globalThis.location.href = getRootDomain();
|
|
22583
22774
|
};
|
|
22584
|
-
return /* @__PURE__ */ (0,
|
|
22775
|
+
return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
|
|
22585
22776
|
"div",
|
|
22586
22777
|
{
|
|
22587
22778
|
className: cn(
|
|
22588
22779
|
"min-h-screen w-full bg-primary-800 flex flex-col items-center justify-center p-4",
|
|
22589
22780
|
className
|
|
22590
22781
|
),
|
|
22591
|
-
children: /* @__PURE__ */ (0,
|
|
22592
|
-
logoSrc && /* @__PURE__ */ (0,
|
|
22593
|
-
/* @__PURE__ */ (0,
|
|
22594
|
-
/* @__PURE__ */ (0,
|
|
22595
|
-
/* @__PURE__ */ (0,
|
|
22596
|
-
/* @__PURE__ */ (0,
|
|
22597
|
-
/* @__PURE__ */ (0,
|
|
22782
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("div", { className: "flex flex-col items-center gap-8 max-w-md w-full", children: [
|
|
22783
|
+
logoSrc && /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("img", { src: logoSrc, alt: logoAlt, className: "h-12 object-contain" }),
|
|
22784
|
+
/* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("div", { className: "bg-background rounded-xl p-8 w-full flex flex-col items-center gap-6 shadow-lg", children: [
|
|
22785
|
+
/* @__PURE__ */ (0, import_jsx_runtime108.jsx)("div", { className: "bg-primary-100 p-4 rounded-full", children: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(import_phosphor_react47.ShieldCheck, { size: 48, className: "text-primary-800" }) }),
|
|
22786
|
+
/* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("div", { className: "flex flex-col items-center gap-2 text-center", children: [
|
|
22787
|
+
/* @__PURE__ */ (0, import_jsx_runtime108.jsx)(Text_default, { size: "xl", weight: "bold", children: title }),
|
|
22788
|
+
/* @__PURE__ */ (0, import_jsx_runtime108.jsx)(Text_default, { size: "md", color: "text-text-500", children: description })
|
|
22598
22789
|
] }),
|
|
22599
|
-
|
|
22790
|
+
/* @__PURE__ */ (0, import_jsx_runtime108.jsx)(Button_default, { onClick: handleLoginClick, className: "w-full", children: buttonText })
|
|
22600
22791
|
] }),
|
|
22601
|
-
footerText && /* @__PURE__ */ (0,
|
|
22792
|
+
footerText && /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(Text_default, { size: "sm", color: "text-primary-200", children: footerText })
|
|
22602
22793
|
] })
|
|
22603
22794
|
}
|
|
22604
22795
|
);
|
|
@@ -22607,7 +22798,7 @@ var RestrictedAccess_default = RestrictedAccess;
|
|
|
22607
22798
|
|
|
22608
22799
|
// src/components/TokenValidation/TokenValidation.tsx
|
|
22609
22800
|
var import_phosphor_react48 = require("phosphor-react");
|
|
22610
|
-
var
|
|
22801
|
+
var import_jsx_runtime109 = require("react/jsx-runtime");
|
|
22611
22802
|
var TokenValidation = ({
|
|
22612
22803
|
title = "Validando acesso...",
|
|
22613
22804
|
description = "Por favor, aguarde enquanto verificamos suas credenciais.",
|
|
@@ -22615,20 +22806,20 @@ var TokenValidation = ({
|
|
|
22615
22806
|
logoAlt = "Logo",
|
|
22616
22807
|
className = ""
|
|
22617
22808
|
}) => {
|
|
22618
|
-
return /* @__PURE__ */ (0,
|
|
22809
|
+
return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
|
|
22619
22810
|
"div",
|
|
22620
22811
|
{
|
|
22621
22812
|
className: cn(
|
|
22622
22813
|
"min-h-screen w-full bg-primary-800 flex flex-col items-center justify-center p-4",
|
|
22623
22814
|
className
|
|
22624
22815
|
),
|
|
22625
|
-
children: /* @__PURE__ */ (0,
|
|
22626
|
-
logoSrc && /* @__PURE__ */ (0,
|
|
22627
|
-
/* @__PURE__ */ (0,
|
|
22628
|
-
/* @__PURE__ */ (0,
|
|
22629
|
-
/* @__PURE__ */ (0,
|
|
22630
|
-
/* @__PURE__ */ (0,
|
|
22631
|
-
/* @__PURE__ */ (0,
|
|
22816
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "flex flex-col items-center gap-8 max-w-md w-full", children: [
|
|
22817
|
+
logoSrc && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("img", { src: logoSrc, alt: logoAlt, className: "h-12 object-contain" }),
|
|
22818
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "bg-background rounded-xl p-8 w-full flex flex-col items-center gap-6 shadow-lg", children: [
|
|
22819
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)("div", { className: "bg-primary-100 p-4 rounded-full", children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_phosphor_react48.CircleNotch, { size: 48, className: "text-primary-800 animate-spin" }) }),
|
|
22820
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "flex flex-col items-center gap-2 text-center", children: [
|
|
22821
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Text_default, { size: "xl", weight: "bold", children: title }),
|
|
22822
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Text_default, { size: "md", color: "text-text-500", children: description })
|
|
22632
22823
|
] })
|
|
22633
22824
|
] })
|
|
22634
22825
|
] })
|
|
@@ -22638,14 +22829,14 @@ var TokenValidation = ({
|
|
|
22638
22829
|
var TokenValidation_default = TokenValidation;
|
|
22639
22830
|
|
|
22640
22831
|
// src/components/VideoPlayer/VideoPlayer.tsx
|
|
22641
|
-
var
|
|
22832
|
+
var import_react65 = require("react");
|
|
22642
22833
|
var import_react_dom2 = require("react-dom");
|
|
22643
22834
|
var import_phosphor_react50 = require("phosphor-react");
|
|
22644
22835
|
|
|
22645
22836
|
// src/components/DownloadButton/DownloadButton.tsx
|
|
22646
|
-
var
|
|
22837
|
+
var import_react64 = require("react");
|
|
22647
22838
|
var import_phosphor_react49 = require("phosphor-react");
|
|
22648
|
-
var
|
|
22839
|
+
var import_jsx_runtime110 = require("react/jsx-runtime");
|
|
22649
22840
|
var getMimeType = (url) => {
|
|
22650
22841
|
const extension = getFileExtension(url);
|
|
22651
22842
|
const mimeTypes = {
|
|
@@ -22720,13 +22911,13 @@ var DownloadButton = ({
|
|
|
22720
22911
|
lessonTitle = "aula",
|
|
22721
22912
|
disabled = false
|
|
22722
22913
|
}) => {
|
|
22723
|
-
const [isDownloading, setIsDownloading] = (0,
|
|
22724
|
-
const isValidUrl = (0,
|
|
22914
|
+
const [isDownloading, setIsDownloading] = (0, import_react64.useState)(false);
|
|
22915
|
+
const isValidUrl = (0, import_react64.useCallback)((url) => {
|
|
22725
22916
|
return Boolean(
|
|
22726
22917
|
url && url.trim() !== "" && url !== "undefined" && url !== "null"
|
|
22727
22918
|
);
|
|
22728
22919
|
}, []);
|
|
22729
|
-
const getAvailableContent = (0,
|
|
22920
|
+
const getAvailableContent = (0, import_react64.useCallback)(() => {
|
|
22730
22921
|
const downloads = [];
|
|
22731
22922
|
if (isValidUrl(content.urlDoc)) {
|
|
22732
22923
|
downloads.push({
|
|
@@ -22761,7 +22952,7 @@ var DownloadButton = ({
|
|
|
22761
22952
|
}
|
|
22762
22953
|
return downloads;
|
|
22763
22954
|
}, [content, isValidUrl]);
|
|
22764
|
-
const handleDownload = (0,
|
|
22955
|
+
const handleDownload = (0, import_react64.useCallback)(async () => {
|
|
22765
22956
|
if (disabled || isDownloading) return;
|
|
22766
22957
|
const availableContent = getAvailableContent();
|
|
22767
22958
|
if (availableContent.length === 0) {
|
|
@@ -22802,10 +22993,10 @@ var DownloadButton = ({
|
|
|
22802
22993
|
if (!hasContent) {
|
|
22803
22994
|
return null;
|
|
22804
22995
|
}
|
|
22805
|
-
return /* @__PURE__ */ (0,
|
|
22996
|
+
return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("div", { className: cn("flex items-center", className), children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
|
|
22806
22997
|
IconButton_default,
|
|
22807
22998
|
{
|
|
22808
|
-
icon: /* @__PURE__ */ (0,
|
|
22999
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_phosphor_react49.DownloadSimple, { size: 24 }),
|
|
22809
23000
|
onClick: handleDownload,
|
|
22810
23001
|
disabled: disabled || isDownloading,
|
|
22811
23002
|
"aria-label": (() => {
|
|
@@ -22826,7 +23017,7 @@ var DownloadButton = ({
|
|
|
22826
23017
|
var DownloadButton_default = DownloadButton;
|
|
22827
23018
|
|
|
22828
23019
|
// src/components/VideoPlayer/VideoPlayer.tsx
|
|
22829
|
-
var
|
|
23020
|
+
var import_jsx_runtime111 = require("react/jsx-runtime");
|
|
22830
23021
|
var CONTROLS_HIDE_TIMEOUT = 3e3;
|
|
22831
23022
|
var LEAVE_HIDE_TIMEOUT = 1e3;
|
|
22832
23023
|
var INIT_DELAY = 100;
|
|
@@ -22842,7 +23033,7 @@ var ProgressBar2 = ({
|
|
|
22842
23033
|
progressPercentage,
|
|
22843
23034
|
onSeek,
|
|
22844
23035
|
className = "px-4 pb-2"
|
|
22845
|
-
}) => /* @__PURE__ */ (0,
|
|
23036
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
|
|
22846
23037
|
"input",
|
|
22847
23038
|
{
|
|
22848
23039
|
type: "range",
|
|
@@ -22864,17 +23055,17 @@ var VolumeControls = ({
|
|
|
22864
23055
|
onToggleMute,
|
|
22865
23056
|
iconSize = 24,
|
|
22866
23057
|
showSlider = true
|
|
22867
|
-
}) => /* @__PURE__ */ (0,
|
|
22868
|
-
/* @__PURE__ */ (0,
|
|
23058
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
23059
|
+
/* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
|
|
22869
23060
|
IconButton_default,
|
|
22870
23061
|
{
|
|
22871
|
-
icon: isMuted ? /* @__PURE__ */ (0,
|
|
23062
|
+
icon: isMuted ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_phosphor_react50.SpeakerSlash, { size: iconSize }) : /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_phosphor_react50.SpeakerHigh, { size: iconSize }),
|
|
22872
23063
|
onClick: onToggleMute,
|
|
22873
23064
|
"aria-label": isMuted ? "Unmute" : "Mute",
|
|
22874
23065
|
className: "!bg-transparent !text-white hover:!bg-white/20"
|
|
22875
23066
|
}
|
|
22876
23067
|
),
|
|
22877
|
-
showSlider && /* @__PURE__ */ (0,
|
|
23068
|
+
showSlider && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
|
|
22878
23069
|
"input",
|
|
22879
23070
|
{
|
|
22880
23071
|
type: "range",
|
|
@@ -22899,9 +23090,9 @@ var SpeedMenu = ({
|
|
|
22899
23090
|
iconSize = 24,
|
|
22900
23091
|
isTinyMobile = false
|
|
22901
23092
|
}) => {
|
|
22902
|
-
const buttonRef = (0,
|
|
22903
|
-
const speedMenuContainerRef = (0,
|
|
22904
|
-
const speedMenuRef = (0,
|
|
23093
|
+
const buttonRef = (0, import_react65.useRef)(null);
|
|
23094
|
+
const speedMenuContainerRef = (0, import_react65.useRef)(null);
|
|
23095
|
+
const speedMenuRef = (0, import_react65.useRef)(null);
|
|
22905
23096
|
const getMenuPosition = () => {
|
|
22906
23097
|
if (!buttonRef.current) return { top: 0, left: 0 };
|
|
22907
23098
|
const rect = buttonRef.current.getBoundingClientRect();
|
|
@@ -22915,7 +23106,7 @@ var SpeedMenu = ({
|
|
|
22915
23106
|
};
|
|
22916
23107
|
};
|
|
22917
23108
|
const position = getMenuPosition();
|
|
22918
|
-
(0,
|
|
23109
|
+
(0, import_react65.useEffect)(() => {
|
|
22919
23110
|
const handleClickOutside = (event) => {
|
|
22920
23111
|
const target = event.target;
|
|
22921
23112
|
const isOutsideContainer = speedMenuContainerRef.current && !speedMenuContainerRef.current.contains(target);
|
|
@@ -22931,7 +23122,7 @@ var SpeedMenu = ({
|
|
|
22931
23122
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
22932
23123
|
};
|
|
22933
23124
|
}, [showSpeedMenu, onToggleMenu]);
|
|
22934
|
-
const menuContent = /* @__PURE__ */ (0,
|
|
23125
|
+
const menuContent = /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
|
|
22935
23126
|
"div",
|
|
22936
23127
|
{
|
|
22937
23128
|
ref: speedMenuRef,
|
|
@@ -22942,7 +23133,7 @@ var SpeedMenu = ({
|
|
|
22942
23133
|
top: `${position.top}px`,
|
|
22943
23134
|
left: `${position.left}px`
|
|
22944
23135
|
},
|
|
22945
|
-
children: [0.5, 0.75, 1, 1.25, 1.5, 2].map((speed) => /* @__PURE__ */ (0,
|
|
23136
|
+
children: [0.5, 0.75, 1, 1.25, 1.5, 2].map((speed) => /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(
|
|
22946
23137
|
"button",
|
|
22947
23138
|
{
|
|
22948
23139
|
role: "menuitemradio",
|
|
@@ -22959,12 +23150,12 @@ var SpeedMenu = ({
|
|
|
22959
23150
|
}
|
|
22960
23151
|
);
|
|
22961
23152
|
const portalContent = showSpeedMenu && globalThis.window !== void 0 && globalThis.document !== void 0 && !!globalThis.document?.body ? (0, import_react_dom2.createPortal)(menuContent, globalThis.document.body) : null;
|
|
22962
|
-
return /* @__PURE__ */ (0,
|
|
22963
|
-
/* @__PURE__ */ (0,
|
|
23153
|
+
return /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { className: "relative", ref: speedMenuContainerRef, children: [
|
|
23154
|
+
/* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
|
|
22964
23155
|
IconButton_default,
|
|
22965
23156
|
{
|
|
22966
23157
|
ref: buttonRef,
|
|
22967
|
-
icon: /* @__PURE__ */ (0,
|
|
23158
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_phosphor_react50.DotsThreeVertical, { size: iconSize }),
|
|
22968
23159
|
onClick: onToggleMenu,
|
|
22969
23160
|
"aria-label": "Playback speed",
|
|
22970
23161
|
"aria-haspopup": "menu",
|
|
@@ -22994,28 +23185,28 @@ var VideoPlayer = ({
|
|
|
22994
23185
|
onDownloadComplete,
|
|
22995
23186
|
onDownloadError
|
|
22996
23187
|
}) => {
|
|
22997
|
-
const videoRef = (0,
|
|
23188
|
+
const videoRef = (0, import_react65.useRef)(null);
|
|
22998
23189
|
const { isUltraSmallMobile, isTinyMobile } = useMobile();
|
|
22999
|
-
const [isPlaying, setIsPlaying] = (0,
|
|
23000
|
-
const [currentTime, setCurrentTime] = (0,
|
|
23001
|
-
const [duration, setDuration] = (0,
|
|
23002
|
-
const [isMuted, setIsMuted] = (0,
|
|
23003
|
-
const [volume, setVolume] = (0,
|
|
23004
|
-
const [isFullscreen, setIsFullscreen] = (0,
|
|
23005
|
-
const [showControls, setShowControls] = (0,
|
|
23006
|
-
const [hasCompleted, setHasCompleted] = (0,
|
|
23007
|
-
const [showCaptions, setShowCaptions] = (0,
|
|
23008
|
-
const [subtitlesValidation, setSubtitlesValidation] = (0,
|
|
23009
|
-
(0,
|
|
23190
|
+
const [isPlaying, setIsPlaying] = (0, import_react65.useState)(false);
|
|
23191
|
+
const [currentTime, setCurrentTime] = (0, import_react65.useState)(0);
|
|
23192
|
+
const [duration, setDuration] = (0, import_react65.useState)(0);
|
|
23193
|
+
const [isMuted, setIsMuted] = (0, import_react65.useState)(false);
|
|
23194
|
+
const [volume, setVolume] = (0, import_react65.useState)(1);
|
|
23195
|
+
const [isFullscreen, setIsFullscreen] = (0, import_react65.useState)(false);
|
|
23196
|
+
const [showControls, setShowControls] = (0, import_react65.useState)(true);
|
|
23197
|
+
const [hasCompleted, setHasCompleted] = (0, import_react65.useState)(false);
|
|
23198
|
+
const [showCaptions, setShowCaptions] = (0, import_react65.useState)(false);
|
|
23199
|
+
const [subtitlesValidation, setSubtitlesValidation] = (0, import_react65.useState)("idle");
|
|
23200
|
+
(0, import_react65.useEffect)(() => {
|
|
23010
23201
|
setHasCompleted(false);
|
|
23011
23202
|
}, [src]);
|
|
23012
|
-
const [playbackRate, setPlaybackRate] = (0,
|
|
23013
|
-
const [showSpeedMenu, setShowSpeedMenu] = (0,
|
|
23014
|
-
const lastSaveTimeRef = (0,
|
|
23015
|
-
const trackRef = (0,
|
|
23016
|
-
const controlsTimeoutRef = (0,
|
|
23017
|
-
const lastMousePositionRef = (0,
|
|
23018
|
-
const isUserInteracting = (0,
|
|
23203
|
+
const [playbackRate, setPlaybackRate] = (0, import_react65.useState)(1);
|
|
23204
|
+
const [showSpeedMenu, setShowSpeedMenu] = (0, import_react65.useState)(false);
|
|
23205
|
+
const lastSaveTimeRef = (0, import_react65.useRef)(0);
|
|
23206
|
+
const trackRef = (0, import_react65.useRef)(null);
|
|
23207
|
+
const controlsTimeoutRef = (0, import_react65.useRef)(null);
|
|
23208
|
+
const lastMousePositionRef = (0, import_react65.useRef)({ x: 0, y: 0 });
|
|
23209
|
+
const isUserInteracting = (0, import_react65.useCallback)(() => {
|
|
23019
23210
|
if (showSpeedMenu) {
|
|
23020
23211
|
return true;
|
|
23021
23212
|
}
|
|
@@ -23032,13 +23223,13 @@ var VideoPlayer = ({
|
|
|
23032
23223
|
}
|
|
23033
23224
|
return false;
|
|
23034
23225
|
}, [showSpeedMenu]);
|
|
23035
|
-
const clearControlsTimeout = (0,
|
|
23226
|
+
const clearControlsTimeout = (0, import_react65.useCallback)(() => {
|
|
23036
23227
|
if (controlsTimeoutRef.current) {
|
|
23037
23228
|
clearTimeout(controlsTimeoutRef.current);
|
|
23038
23229
|
controlsTimeoutRef.current = null;
|
|
23039
23230
|
}
|
|
23040
23231
|
}, []);
|
|
23041
|
-
const showControlsWithTimer = (0,
|
|
23232
|
+
const showControlsWithTimer = (0, import_react65.useCallback)(() => {
|
|
23042
23233
|
setShowControls(true);
|
|
23043
23234
|
clearControlsTimeout();
|
|
23044
23235
|
if (isFullscreen) {
|
|
@@ -23053,7 +23244,7 @@ var VideoPlayer = ({
|
|
|
23053
23244
|
}, CONTROLS_HIDE_TIMEOUT);
|
|
23054
23245
|
}
|
|
23055
23246
|
}, [isFullscreen, isPlaying, clearControlsTimeout]);
|
|
23056
|
-
const handleMouseMove = (0,
|
|
23247
|
+
const handleMouseMove = (0, import_react65.useCallback)(
|
|
23057
23248
|
(event) => {
|
|
23058
23249
|
const currentX = event.clientX;
|
|
23059
23250
|
const currentY = event.clientY;
|
|
@@ -23066,10 +23257,10 @@ var VideoPlayer = ({
|
|
|
23066
23257
|
},
|
|
23067
23258
|
[showControlsWithTimer]
|
|
23068
23259
|
);
|
|
23069
|
-
const handleMouseEnter = (0,
|
|
23260
|
+
const handleMouseEnter = (0, import_react65.useCallback)(() => {
|
|
23070
23261
|
showControlsWithTimer();
|
|
23071
23262
|
}, [showControlsWithTimer]);
|
|
23072
|
-
const handleMouseLeave = (0,
|
|
23263
|
+
const handleMouseLeave = (0, import_react65.useCallback)(() => {
|
|
23073
23264
|
const userInteracting = isUserInteracting();
|
|
23074
23265
|
clearControlsTimeout();
|
|
23075
23266
|
if (!isFullscreen && !userInteracting) {
|
|
@@ -23078,13 +23269,13 @@ var VideoPlayer = ({
|
|
|
23078
23269
|
}, LEAVE_HIDE_TIMEOUT);
|
|
23079
23270
|
}
|
|
23080
23271
|
}, [isFullscreen, clearControlsTimeout, isUserInteracting]);
|
|
23081
|
-
(0,
|
|
23272
|
+
(0, import_react65.useEffect)(() => {
|
|
23082
23273
|
if (videoRef.current) {
|
|
23083
23274
|
videoRef.current.volume = volume;
|
|
23084
23275
|
videoRef.current.muted = isMuted;
|
|
23085
23276
|
}
|
|
23086
23277
|
}, [volume, isMuted]);
|
|
23087
|
-
(0,
|
|
23278
|
+
(0, import_react65.useEffect)(() => {
|
|
23088
23279
|
const video = videoRef.current;
|
|
23089
23280
|
if (!video) return;
|
|
23090
23281
|
const onPlay = () => setIsPlaying(true);
|
|
@@ -23099,13 +23290,13 @@ var VideoPlayer = ({
|
|
|
23099
23290
|
video.removeEventListener("ended", onEnded);
|
|
23100
23291
|
};
|
|
23101
23292
|
}, []);
|
|
23102
|
-
(0,
|
|
23293
|
+
(0, import_react65.useEffect)(() => {
|
|
23103
23294
|
const video = videoRef.current;
|
|
23104
23295
|
if (!video) return;
|
|
23105
23296
|
video.setAttribute("playsinline", "");
|
|
23106
23297
|
video.setAttribute("webkit-playsinline", "");
|
|
23107
23298
|
}, []);
|
|
23108
|
-
(0,
|
|
23299
|
+
(0, import_react65.useEffect)(() => {
|
|
23109
23300
|
if (isPlaying) {
|
|
23110
23301
|
showControlsWithTimer();
|
|
23111
23302
|
} else {
|
|
@@ -23117,7 +23308,7 @@ var VideoPlayer = ({
|
|
|
23117
23308
|
}
|
|
23118
23309
|
}
|
|
23119
23310
|
}, [isPlaying, isFullscreen, showControlsWithTimer, clearControlsTimeout]);
|
|
23120
|
-
(0,
|
|
23311
|
+
(0, import_react65.useEffect)(() => {
|
|
23121
23312
|
const video = videoRef.current;
|
|
23122
23313
|
if (!video) return;
|
|
23123
23314
|
const handleFullscreenChange = () => {
|
|
@@ -23152,7 +23343,7 @@ var VideoPlayer = ({
|
|
|
23152
23343
|
);
|
|
23153
23344
|
};
|
|
23154
23345
|
}, [showControlsWithTimer]);
|
|
23155
|
-
(0,
|
|
23346
|
+
(0, import_react65.useEffect)(() => {
|
|
23156
23347
|
const init = () => {
|
|
23157
23348
|
if (!isFullscreen) {
|
|
23158
23349
|
showControlsWithTimer();
|
|
@@ -23174,7 +23365,7 @@ var VideoPlayer = ({
|
|
|
23174
23365
|
};
|
|
23175
23366
|
}
|
|
23176
23367
|
}, []);
|
|
23177
|
-
const getInitialTime = (0,
|
|
23368
|
+
const getInitialTime = (0, import_react65.useCallback)(() => {
|
|
23178
23369
|
if (!autoSave || !storageKey) {
|
|
23179
23370
|
return Number.isFinite(initialTime) && initialTime >= 0 ? initialTime : void 0;
|
|
23180
23371
|
}
|
|
@@ -23187,14 +23378,14 @@ var VideoPlayer = ({
|
|
|
23187
23378
|
if (hasValidSaved) return saved;
|
|
23188
23379
|
return void 0;
|
|
23189
23380
|
}, [autoSave, storageKey, src, initialTime]);
|
|
23190
|
-
(0,
|
|
23381
|
+
(0, import_react65.useEffect)(() => {
|
|
23191
23382
|
const start = getInitialTime();
|
|
23192
23383
|
if (start !== void 0 && videoRef.current) {
|
|
23193
23384
|
videoRef.current.currentTime = start;
|
|
23194
23385
|
setCurrentTime(start);
|
|
23195
23386
|
}
|
|
23196
23387
|
}, [getInitialTime]);
|
|
23197
|
-
const saveProgress = (0,
|
|
23388
|
+
const saveProgress = (0, import_react65.useCallback)(
|
|
23198
23389
|
(time) => {
|
|
23199
23390
|
if (!autoSave || !storageKey) return;
|
|
23200
23391
|
const now = Date.now();
|
|
@@ -23205,7 +23396,7 @@ var VideoPlayer = ({
|
|
|
23205
23396
|
},
|
|
23206
23397
|
[autoSave, storageKey, src]
|
|
23207
23398
|
);
|
|
23208
|
-
const togglePlayPause = (0,
|
|
23399
|
+
const togglePlayPause = (0, import_react65.useCallback)(async () => {
|
|
23209
23400
|
const video = videoRef.current;
|
|
23210
23401
|
if (!video) return;
|
|
23211
23402
|
if (!video.paused) {
|
|
@@ -23217,7 +23408,7 @@ var VideoPlayer = ({
|
|
|
23217
23408
|
} catch {
|
|
23218
23409
|
}
|
|
23219
23410
|
}, []);
|
|
23220
|
-
const handleVolumeChange = (0,
|
|
23411
|
+
const handleVolumeChange = (0, import_react65.useCallback)(
|
|
23221
23412
|
(newVolume) => {
|
|
23222
23413
|
const video = videoRef.current;
|
|
23223
23414
|
if (!video) return;
|
|
@@ -23236,7 +23427,7 @@ var VideoPlayer = ({
|
|
|
23236
23427
|
},
|
|
23237
23428
|
[isMuted]
|
|
23238
23429
|
);
|
|
23239
|
-
const toggleMute = (0,
|
|
23430
|
+
const toggleMute = (0, import_react65.useCallback)(() => {
|
|
23240
23431
|
const video = videoRef.current;
|
|
23241
23432
|
if (!video) return;
|
|
23242
23433
|
if (isMuted) {
|
|
@@ -23250,20 +23441,20 @@ var VideoPlayer = ({
|
|
|
23250
23441
|
setIsMuted(true);
|
|
23251
23442
|
}
|
|
23252
23443
|
}, [isMuted, volume]);
|
|
23253
|
-
const handleSeek = (0,
|
|
23444
|
+
const handleSeek = (0, import_react65.useCallback)((newTime) => {
|
|
23254
23445
|
const video = videoRef.current;
|
|
23255
23446
|
if (video) {
|
|
23256
23447
|
video.currentTime = newTime;
|
|
23257
23448
|
}
|
|
23258
23449
|
}, []);
|
|
23259
|
-
const isSafariIOS = (0,
|
|
23450
|
+
const isSafariIOS = (0, import_react65.useCallback)(() => {
|
|
23260
23451
|
const ua = navigator.userAgent;
|
|
23261
23452
|
const isIOS = /iPad|iPhone|iPod/.test(ua);
|
|
23262
23453
|
const isWebKit = /WebKit/.test(ua);
|
|
23263
23454
|
const isNotChrome = !/CriOS|Chrome/.test(ua);
|
|
23264
23455
|
return isIOS && isWebKit && isNotChrome;
|
|
23265
23456
|
}, []);
|
|
23266
|
-
const toggleFullscreen = (0,
|
|
23457
|
+
const toggleFullscreen = (0, import_react65.useCallback)(() => {
|
|
23267
23458
|
const video = videoRef.current;
|
|
23268
23459
|
const container = video?.parentElement;
|
|
23269
23460
|
if (!video || !container) return;
|
|
@@ -23280,24 +23471,24 @@ var VideoPlayer = ({
|
|
|
23280
23471
|
document.exitFullscreen();
|
|
23281
23472
|
}
|
|
23282
23473
|
}, [isFullscreen, isSafariIOS]);
|
|
23283
|
-
const handleSpeedChange = (0,
|
|
23474
|
+
const handleSpeedChange = (0, import_react65.useCallback)((speed) => {
|
|
23284
23475
|
if (videoRef.current) {
|
|
23285
23476
|
videoRef.current.playbackRate = speed;
|
|
23286
23477
|
setPlaybackRate(speed);
|
|
23287
23478
|
setShowSpeedMenu(false);
|
|
23288
23479
|
}
|
|
23289
23480
|
}, []);
|
|
23290
|
-
const toggleSpeedMenu = (0,
|
|
23481
|
+
const toggleSpeedMenu = (0, import_react65.useCallback)(() => {
|
|
23291
23482
|
setShowSpeedMenu(!showSpeedMenu);
|
|
23292
23483
|
}, [showSpeedMenu]);
|
|
23293
|
-
const toggleCaptions = (0,
|
|
23484
|
+
const toggleCaptions = (0, import_react65.useCallback)(() => {
|
|
23294
23485
|
if (!trackRef.current?.track || !subtitles || subtitlesValidation !== "valid")
|
|
23295
23486
|
return;
|
|
23296
23487
|
const newShowCaptions = !showCaptions;
|
|
23297
23488
|
setShowCaptions(newShowCaptions);
|
|
23298
23489
|
trackRef.current.track.mode = newShowCaptions ? "showing" : "hidden";
|
|
23299
23490
|
}, [showCaptions, subtitles, subtitlesValidation]);
|
|
23300
|
-
const checkVideoCompletion = (0,
|
|
23491
|
+
const checkVideoCompletion = (0, import_react65.useCallback)(
|
|
23301
23492
|
(progressPercent) => {
|
|
23302
23493
|
if (progressPercent >= 95 && !hasCompleted) {
|
|
23303
23494
|
setHasCompleted(true);
|
|
@@ -23306,7 +23497,7 @@ var VideoPlayer = ({
|
|
|
23306
23497
|
},
|
|
23307
23498
|
[hasCompleted, onVideoComplete]
|
|
23308
23499
|
);
|
|
23309
|
-
const handleTimeUpdate = (0,
|
|
23500
|
+
const handleTimeUpdate = (0, import_react65.useCallback)(() => {
|
|
23310
23501
|
const video = videoRef.current;
|
|
23311
23502
|
if (!video) return;
|
|
23312
23503
|
const current = video.currentTime;
|
|
@@ -23319,12 +23510,12 @@ var VideoPlayer = ({
|
|
|
23319
23510
|
checkVideoCompletion(progressPercent);
|
|
23320
23511
|
}
|
|
23321
23512
|
}, [duration, saveProgress, onTimeUpdate, onProgress, checkVideoCompletion]);
|
|
23322
|
-
const handleLoadedMetadata = (0,
|
|
23513
|
+
const handleLoadedMetadata = (0, import_react65.useCallback)(() => {
|
|
23323
23514
|
if (videoRef.current) {
|
|
23324
23515
|
setDuration(videoRef.current.duration);
|
|
23325
23516
|
}
|
|
23326
23517
|
}, []);
|
|
23327
|
-
(0,
|
|
23518
|
+
(0, import_react65.useEffect)(() => {
|
|
23328
23519
|
const controller = new AbortController();
|
|
23329
23520
|
const validateSubtitles = async () => {
|
|
23330
23521
|
if (!subtitles) {
|
|
@@ -23371,12 +23562,12 @@ var VideoPlayer = ({
|
|
|
23371
23562
|
controller.abort();
|
|
23372
23563
|
};
|
|
23373
23564
|
}, [subtitles]);
|
|
23374
|
-
(0,
|
|
23565
|
+
(0, import_react65.useEffect)(() => {
|
|
23375
23566
|
if (trackRef.current?.track) {
|
|
23376
23567
|
trackRef.current.track.mode = showCaptions && subtitles && subtitlesValidation === "valid" ? "showing" : "hidden";
|
|
23377
23568
|
}
|
|
23378
23569
|
}, [subtitles, showCaptions, subtitlesValidation]);
|
|
23379
|
-
(0,
|
|
23570
|
+
(0, import_react65.useEffect)(() => {
|
|
23380
23571
|
const handleVisibilityChange = () => {
|
|
23381
23572
|
if (document.hidden && isPlaying && videoRef.current) {
|
|
23382
23573
|
videoRef.current.pause();
|
|
@@ -23398,54 +23589,54 @@ var VideoPlayer = ({
|
|
|
23398
23589
|
};
|
|
23399
23590
|
}, [isPlaying, clearControlsTimeout]);
|
|
23400
23591
|
const progressPercentage = duration > 0 ? currentTime / duration * 100 : 0;
|
|
23401
|
-
const getIconSize2 = (0,
|
|
23592
|
+
const getIconSize2 = (0, import_react65.useCallback)(() => {
|
|
23402
23593
|
if (isTinyMobile) return 18;
|
|
23403
23594
|
if (isUltraSmallMobile) return 20;
|
|
23404
23595
|
return 24;
|
|
23405
23596
|
}, [isTinyMobile, isUltraSmallMobile]);
|
|
23406
|
-
const getControlsPadding = (0,
|
|
23597
|
+
const getControlsPadding = (0, import_react65.useCallback)(() => {
|
|
23407
23598
|
if (isTinyMobile) return "px-2 pb-2 pt-1";
|
|
23408
23599
|
if (isUltraSmallMobile) return "px-3 pb-3 pt-1";
|
|
23409
23600
|
return "px-4 pb-4";
|
|
23410
23601
|
}, [isTinyMobile, isUltraSmallMobile]);
|
|
23411
|
-
const getControlsGap = (0,
|
|
23602
|
+
const getControlsGap = (0, import_react65.useCallback)(() => {
|
|
23412
23603
|
if (isTinyMobile) return "gap-1";
|
|
23413
23604
|
if (isUltraSmallMobile) return "gap-2";
|
|
23414
23605
|
return "gap-4";
|
|
23415
23606
|
}, [isTinyMobile, isUltraSmallMobile]);
|
|
23416
|
-
const getProgressBarPadding = (0,
|
|
23607
|
+
const getProgressBarPadding = (0, import_react65.useCallback)(() => {
|
|
23417
23608
|
if (isTinyMobile) return "px-2 pb-1";
|
|
23418
23609
|
if (isUltraSmallMobile) return "px-3 pb-1";
|
|
23419
23610
|
return "px-4 pb-2";
|
|
23420
23611
|
}, [isTinyMobile, isUltraSmallMobile]);
|
|
23421
|
-
const getCenterPlayButtonPosition = (0,
|
|
23612
|
+
const getCenterPlayButtonPosition = (0, import_react65.useCallback)(() => {
|
|
23422
23613
|
if (isTinyMobile) return "items-center justify-center -translate-y-12";
|
|
23423
23614
|
if (isUltraSmallMobile) return "items-center justify-center -translate-y-8";
|
|
23424
23615
|
return "items-center justify-center";
|
|
23425
23616
|
}, [isTinyMobile, isUltraSmallMobile]);
|
|
23426
|
-
const getTopControlsOpacity = (0,
|
|
23617
|
+
const getTopControlsOpacity = (0, import_react65.useCallback)(() => {
|
|
23427
23618
|
return showControls ? "opacity-100" : "opacity-0";
|
|
23428
23619
|
}, [showControls]);
|
|
23429
|
-
const getBottomControlsOpacity = (0,
|
|
23620
|
+
const getBottomControlsOpacity = (0, import_react65.useCallback)(() => {
|
|
23430
23621
|
return showControls ? "opacity-100" : "opacity-0";
|
|
23431
23622
|
}, [showControls]);
|
|
23432
|
-
const seekBackward = (0,
|
|
23623
|
+
const seekBackward = (0, import_react65.useCallback)(() => {
|
|
23433
23624
|
if (videoRef.current) {
|
|
23434
23625
|
videoRef.current.currentTime -= 10;
|
|
23435
23626
|
}
|
|
23436
23627
|
}, []);
|
|
23437
|
-
const seekForward = (0,
|
|
23628
|
+
const seekForward = (0, import_react65.useCallback)(() => {
|
|
23438
23629
|
if (videoRef.current) {
|
|
23439
23630
|
videoRef.current.currentTime += 10;
|
|
23440
23631
|
}
|
|
23441
23632
|
}, []);
|
|
23442
|
-
const increaseVolume = (0,
|
|
23633
|
+
const increaseVolume = (0, import_react65.useCallback)(() => {
|
|
23443
23634
|
handleVolumeChange(Math.min(100, volume * 100 + 10));
|
|
23444
23635
|
}, [handleVolumeChange, volume]);
|
|
23445
|
-
const decreaseVolume = (0,
|
|
23636
|
+
const decreaseVolume = (0, import_react65.useCallback)(() => {
|
|
23446
23637
|
handleVolumeChange(Math.max(0, volume * 100 - 10));
|
|
23447
23638
|
}, [handleVolumeChange, volume]);
|
|
23448
|
-
const handleVideoKeyDown = (0,
|
|
23639
|
+
const handleVideoKeyDown = (0, import_react65.useCallback)(
|
|
23449
23640
|
(e) => {
|
|
23450
23641
|
if (!e.key) return;
|
|
23451
23642
|
e.stopPropagation();
|
|
@@ -23480,10 +23671,10 @@ var VideoPlayer = ({
|
|
|
23480
23671
|
]
|
|
23481
23672
|
);
|
|
23482
23673
|
const groupedSubTitleValid = subtitles && subtitlesValidation === "valid";
|
|
23483
|
-
return /* @__PURE__ */ (0,
|
|
23484
|
-
(title || subtitleText) && /* @__PURE__ */ (0,
|
|
23485
|
-
/* @__PURE__ */ (0,
|
|
23486
|
-
title && /* @__PURE__ */ (0,
|
|
23674
|
+
return /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { className: cn("flex flex-col", className), children: [
|
|
23675
|
+
(title || subtitleText) && /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { className: "bg-subject-1 px-8 py-4 flex items-end justify-between min-h-20", children: [
|
|
23676
|
+
/* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
23677
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
|
|
23487
23678
|
Text_default,
|
|
23488
23679
|
{
|
|
23489
23680
|
as: "h2",
|
|
@@ -23494,7 +23685,7 @@ var VideoPlayer = ({
|
|
|
23494
23685
|
children: title
|
|
23495
23686
|
}
|
|
23496
23687
|
),
|
|
23497
|
-
subtitleText && /* @__PURE__ */ (0,
|
|
23688
|
+
subtitleText && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
|
|
23498
23689
|
Text_default,
|
|
23499
23690
|
{
|
|
23500
23691
|
as: "p",
|
|
@@ -23506,7 +23697,7 @@ var VideoPlayer = ({
|
|
|
23506
23697
|
}
|
|
23507
23698
|
)
|
|
23508
23699
|
] }),
|
|
23509
|
-
showDownloadButton && downloadContent && /* @__PURE__ */ (0,
|
|
23700
|
+
showDownloadButton && downloadContent && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
|
|
23510
23701
|
DownloadButton_default,
|
|
23511
23702
|
{
|
|
23512
23703
|
content: downloadContent,
|
|
@@ -23518,7 +23709,7 @@ var VideoPlayer = ({
|
|
|
23518
23709
|
}
|
|
23519
23710
|
)
|
|
23520
23711
|
] }),
|
|
23521
|
-
/* @__PURE__ */ (0,
|
|
23712
|
+
/* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(
|
|
23522
23713
|
"section",
|
|
23523
23714
|
{
|
|
23524
23715
|
className: cn(
|
|
@@ -23533,7 +23724,7 @@ var VideoPlayer = ({
|
|
|
23533
23724
|
onTouchStart: handleMouseEnter,
|
|
23534
23725
|
onMouseLeave: handleMouseLeave,
|
|
23535
23726
|
children: [
|
|
23536
|
-
/* @__PURE__ */ (0,
|
|
23727
|
+
/* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
|
|
23537
23728
|
"video",
|
|
23538
23729
|
{
|
|
23539
23730
|
ref: videoRef,
|
|
@@ -23548,7 +23739,7 @@ var VideoPlayer = ({
|
|
|
23548
23739
|
onKeyDown: handleVideoKeyDown,
|
|
23549
23740
|
tabIndex: 0,
|
|
23550
23741
|
"aria-label": title ? `Video: ${title}` : "Video player",
|
|
23551
|
-
children: /* @__PURE__ */ (0,
|
|
23742
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
|
|
23552
23743
|
"track",
|
|
23553
23744
|
{
|
|
23554
23745
|
ref: trackRef,
|
|
@@ -23561,17 +23752,17 @@ var VideoPlayer = ({
|
|
|
23561
23752
|
)
|
|
23562
23753
|
}
|
|
23563
23754
|
),
|
|
23564
|
-
!isPlaying && /* @__PURE__ */ (0,
|
|
23755
|
+
!isPlaying && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
|
|
23565
23756
|
"div",
|
|
23566
23757
|
{
|
|
23567
23758
|
className: cn(
|
|
23568
23759
|
"absolute inset-0 flex bg-black/30 transition-opacity",
|
|
23569
23760
|
getCenterPlayButtonPosition()
|
|
23570
23761
|
),
|
|
23571
|
-
children: /* @__PURE__ */ (0,
|
|
23762
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
|
|
23572
23763
|
IconButton_default,
|
|
23573
23764
|
{
|
|
23574
|
-
icon: /* @__PURE__ */ (0,
|
|
23765
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_phosphor_react50.Play, { size: 32, weight: "regular", className: "ml-1" }),
|
|
23575
23766
|
onClick: togglePlayPause,
|
|
23576
23767
|
"aria-label": "Play video",
|
|
23577
23768
|
className: "!bg-transparent !text-white !w-auto !h-auto hover:!bg-transparent hover:!text-gray-200"
|
|
@@ -23579,17 +23770,17 @@ var VideoPlayer = ({
|
|
|
23579
23770
|
)
|
|
23580
23771
|
}
|
|
23581
23772
|
),
|
|
23582
|
-
/* @__PURE__ */ (0,
|
|
23773
|
+
/* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
|
|
23583
23774
|
"div",
|
|
23584
23775
|
{
|
|
23585
23776
|
className: cn(
|
|
23586
23777
|
"absolute top-0 left-0 right-0 p-4 bg-gradient-to-b from-black/70 to-transparent transition-opacity",
|
|
23587
23778
|
getTopControlsOpacity()
|
|
23588
23779
|
),
|
|
23589
|
-
children: /* @__PURE__ */ (0,
|
|
23780
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("div", { className: "flex justify-start", children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
|
|
23590
23781
|
IconButton_default,
|
|
23591
23782
|
{
|
|
23592
|
-
icon: isFullscreen ? /* @__PURE__ */ (0,
|
|
23783
|
+
icon: isFullscreen ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_phosphor_react50.ArrowsInSimple, { size: 24 }) : /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_phosphor_react50.ArrowsOutSimple, { size: 24 }),
|
|
23593
23784
|
onClick: toggleFullscreen,
|
|
23594
23785
|
"aria-label": isFullscreen ? "Exit fullscreen" : "Enter fullscreen",
|
|
23595
23786
|
className: "!bg-transparent !text-white hover:!bg-white/20"
|
|
@@ -23597,7 +23788,7 @@ var VideoPlayer = ({
|
|
|
23597
23788
|
) })
|
|
23598
23789
|
}
|
|
23599
23790
|
),
|
|
23600
|
-
/* @__PURE__ */ (0,
|
|
23791
|
+
/* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(
|
|
23601
23792
|
"div",
|
|
23602
23793
|
{
|
|
23603
23794
|
className: cn(
|
|
@@ -23605,7 +23796,7 @@ var VideoPlayer = ({
|
|
|
23605
23796
|
getBottomControlsOpacity()
|
|
23606
23797
|
),
|
|
23607
23798
|
children: [
|
|
23608
|
-
/* @__PURE__ */ (0,
|
|
23799
|
+
/* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
|
|
23609
23800
|
ProgressBar2,
|
|
23610
23801
|
{
|
|
23611
23802
|
currentTime,
|
|
@@ -23615,7 +23806,7 @@ var VideoPlayer = ({
|
|
|
23615
23806
|
className: getProgressBarPadding()
|
|
23616
23807
|
}
|
|
23617
23808
|
),
|
|
23618
|
-
/* @__PURE__ */ (0,
|
|
23809
|
+
/* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(
|
|
23619
23810
|
"div",
|
|
23620
23811
|
{
|
|
23621
23812
|
className: cn(
|
|
@@ -23623,17 +23814,17 @@ var VideoPlayer = ({
|
|
|
23623
23814
|
getControlsPadding()
|
|
23624
23815
|
),
|
|
23625
23816
|
children: [
|
|
23626
|
-
/* @__PURE__ */ (0,
|
|
23627
|
-
/* @__PURE__ */ (0,
|
|
23817
|
+
/* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { className: cn("flex items-center", getControlsGap()), children: [
|
|
23818
|
+
/* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
|
|
23628
23819
|
IconButton_default,
|
|
23629
23820
|
{
|
|
23630
|
-
icon: isPlaying ? /* @__PURE__ */ (0,
|
|
23821
|
+
icon: isPlaying ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_phosphor_react50.Pause, { size: getIconSize2() }) : /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_phosphor_react50.Play, { size: getIconSize2() }),
|
|
23631
23822
|
onClick: togglePlayPause,
|
|
23632
23823
|
"aria-label": isPlaying ? "Pause" : "Play",
|
|
23633
23824
|
className: "!bg-transparent !text-white hover:!bg-white/20"
|
|
23634
23825
|
}
|
|
23635
23826
|
),
|
|
23636
|
-
/* @__PURE__ */ (0,
|
|
23827
|
+
/* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
|
|
23637
23828
|
VolumeControls,
|
|
23638
23829
|
{
|
|
23639
23830
|
volume,
|
|
@@ -23644,10 +23835,10 @@ var VideoPlayer = ({
|
|
|
23644
23835
|
showSlider: !isUltraSmallMobile
|
|
23645
23836
|
}
|
|
23646
23837
|
),
|
|
23647
|
-
groupedSubTitleValid && /* @__PURE__ */ (0,
|
|
23838
|
+
groupedSubTitleValid && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
|
|
23648
23839
|
IconButton_default,
|
|
23649
23840
|
{
|
|
23650
|
-
icon: /* @__PURE__ */ (0,
|
|
23841
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_phosphor_react50.ClosedCaptioning, { size: getIconSize2() }),
|
|
23651
23842
|
onClick: toggleCaptions,
|
|
23652
23843
|
"aria-label": showCaptions ? "Hide captions" : "Show captions",
|
|
23653
23844
|
className: cn(
|
|
@@ -23656,13 +23847,13 @@ var VideoPlayer = ({
|
|
|
23656
23847
|
)
|
|
23657
23848
|
}
|
|
23658
23849
|
),
|
|
23659
|
-
/* @__PURE__ */ (0,
|
|
23850
|
+
/* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(Text_default, { size: "sm", weight: "medium", color: "text-white", children: [
|
|
23660
23851
|
formatTime2(currentTime),
|
|
23661
23852
|
" / ",
|
|
23662
23853
|
formatTime2(duration)
|
|
23663
23854
|
] })
|
|
23664
23855
|
] }),
|
|
23665
|
-
/* @__PURE__ */ (0,
|
|
23856
|
+
/* @__PURE__ */ (0, import_jsx_runtime111.jsx)("div", { className: "flex items-center gap-4", children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
|
|
23666
23857
|
SpeedMenu,
|
|
23667
23858
|
{
|
|
23668
23859
|
showSpeedMenu,
|
|
@@ -23688,9 +23879,9 @@ var VideoPlayer = ({
|
|
|
23688
23879
|
var VideoPlayer_default = VideoPlayer;
|
|
23689
23880
|
|
|
23690
23881
|
// src/components/Whiteboard/Whiteboard.tsx
|
|
23691
|
-
var
|
|
23882
|
+
var import_react66 = require("react");
|
|
23692
23883
|
var import_phosphor_react51 = require("phosphor-react");
|
|
23693
|
-
var
|
|
23884
|
+
var import_jsx_runtime112 = require("react/jsx-runtime");
|
|
23694
23885
|
var IMAGE_WIDTH = 225;
|
|
23695
23886
|
var IMAGE_HEIGHT = 90;
|
|
23696
23887
|
var Whiteboard = ({
|
|
@@ -23701,8 +23892,8 @@ var Whiteboard = ({
|
|
|
23701
23892
|
imagesPerRow = 2,
|
|
23702
23893
|
...rest
|
|
23703
23894
|
}) => {
|
|
23704
|
-
const [imageErrors, setImageErrors] = (0,
|
|
23705
|
-
const handleDownload = (0,
|
|
23895
|
+
const [imageErrors, setImageErrors] = (0, import_react66.useState)(/* @__PURE__ */ new Set());
|
|
23896
|
+
const handleDownload = (0, import_react66.useCallback)(
|
|
23706
23897
|
(image) => {
|
|
23707
23898
|
if (onDownload) {
|
|
23708
23899
|
onDownload(image);
|
|
@@ -23719,7 +23910,7 @@ var Whiteboard = ({
|
|
|
23719
23910
|
},
|
|
23720
23911
|
[onDownload]
|
|
23721
23912
|
);
|
|
23722
|
-
const handleImageError = (0,
|
|
23913
|
+
const handleImageError = (0, import_react66.useCallback)((imageId) => {
|
|
23723
23914
|
setImageErrors((prev) => new Set(prev).add(imageId));
|
|
23724
23915
|
}, []);
|
|
23725
23916
|
const gridColsClass = images?.length === 1 ? "grid-cols-1" : {
|
|
@@ -23728,7 +23919,7 @@ var Whiteboard = ({
|
|
|
23728
23919
|
4: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4"
|
|
23729
23920
|
}[imagesPerRow];
|
|
23730
23921
|
if (!images || images.length === 0) {
|
|
23731
|
-
return /* @__PURE__ */ (0,
|
|
23922
|
+
return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
|
|
23732
23923
|
"div",
|
|
23733
23924
|
{
|
|
23734
23925
|
className: cn(
|
|
@@ -23736,11 +23927,11 @@ var Whiteboard = ({
|
|
|
23736
23927
|
className
|
|
23737
23928
|
),
|
|
23738
23929
|
...rest,
|
|
23739
|
-
children: /* @__PURE__ */ (0,
|
|
23930
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)("p", { className: "text-gray-400 text-sm", children: "Nenhuma imagem dispon\xEDvel" })
|
|
23740
23931
|
}
|
|
23741
23932
|
);
|
|
23742
23933
|
}
|
|
23743
|
-
return /* @__PURE__ */ (0,
|
|
23934
|
+
return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
|
|
23744
23935
|
"div",
|
|
23745
23936
|
{
|
|
23746
23937
|
className: cn(
|
|
@@ -23748,7 +23939,7 @@ var Whiteboard = ({
|
|
|
23748
23939
|
className
|
|
23749
23940
|
),
|
|
23750
23941
|
...rest,
|
|
23751
|
-
children: /* @__PURE__ */ (0,
|
|
23942
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)("div", { className: cn("grid gap-4", gridColsClass), children: images.map((image) => /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(
|
|
23752
23943
|
"div",
|
|
23753
23944
|
{
|
|
23754
23945
|
className: "relative group overflow-hidden bg-gray-100 rounded-lg",
|
|
@@ -23756,7 +23947,7 @@ var Whiteboard = ({
|
|
|
23756
23947
|
width: `${IMAGE_WIDTH}px`
|
|
23757
23948
|
},
|
|
23758
23949
|
children: [
|
|
23759
|
-
/* @__PURE__ */ (0,
|
|
23950
|
+
/* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
|
|
23760
23951
|
"div",
|
|
23761
23952
|
{
|
|
23762
23953
|
className: "relative",
|
|
@@ -23764,8 +23955,8 @@ var Whiteboard = ({
|
|
|
23764
23955
|
width: `${IMAGE_WIDTH}px`,
|
|
23765
23956
|
height: `${IMAGE_HEIGHT}px`
|
|
23766
23957
|
},
|
|
23767
|
-
children: imageErrors.has(image.id) ? /* @__PURE__ */ (0,
|
|
23768
|
-
/* @__PURE__ */ (0,
|
|
23958
|
+
children: imageErrors.has(image.id) ? /* @__PURE__ */ (0, import_jsx_runtime112.jsx)("div", { className: "absolute inset-0 flex items-center justify-center bg-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)("p", { className: "text-gray-500 text-sm text-center px-2", children: "Imagem indispon\xEDvel" }) }) : /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(import_jsx_runtime112.Fragment, { children: [
|
|
23959
|
+
/* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
|
|
23769
23960
|
"img",
|
|
23770
23961
|
{
|
|
23771
23962
|
src: image.imageUrl,
|
|
@@ -23775,18 +23966,18 @@ var Whiteboard = ({
|
|
|
23775
23966
|
onError: () => handleImageError(image.id)
|
|
23776
23967
|
}
|
|
23777
23968
|
),
|
|
23778
|
-
/* @__PURE__ */ (0,
|
|
23969
|
+
/* @__PURE__ */ (0, import_jsx_runtime112.jsx)("div", { className: "absolute inset-0 bg-gradient-to-t from-black/20 to-transparent" })
|
|
23779
23970
|
] })
|
|
23780
23971
|
}
|
|
23781
23972
|
),
|
|
23782
|
-
showDownload && /* @__PURE__ */ (0,
|
|
23973
|
+
showDownload && /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
|
|
23783
23974
|
"button",
|
|
23784
23975
|
{
|
|
23785
23976
|
type: "button",
|
|
23786
23977
|
onClick: () => handleDownload(image),
|
|
23787
23978
|
className: "cursor-pointer absolute bottom-3 right-3 flex items-center justify-center bg-black/20 backdrop-blur-sm rounded hover:bg-black/30 transition-colors duration-200 group/button w-6 h-6",
|
|
23788
23979
|
"aria-label": `Download ${image.title || "imagem"}`,
|
|
23789
|
-
children: /* @__PURE__ */ (0,
|
|
23980
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
|
|
23790
23981
|
import_phosphor_react51.ArrowsOut,
|
|
23791
23982
|
{
|
|
23792
23983
|
size: 24,
|
|
@@ -23805,201 +23996,6 @@ var Whiteboard = ({
|
|
|
23805
23996
|
};
|
|
23806
23997
|
var Whiteboard_default = Whiteboard;
|
|
23807
23998
|
|
|
23808
|
-
// src/components/Auth/Auth.tsx
|
|
23809
|
-
var import_react66 = require("react");
|
|
23810
|
-
var import_react_router_dom4 = require("react-router-dom");
|
|
23811
|
-
|
|
23812
|
-
// src/components/Auth/useTokenInUrl.ts
|
|
23813
|
-
var import_react65 = require("react");
|
|
23814
|
-
var import_react_router_dom3 = require("react-router-dom");
|
|
23815
|
-
function useTokenInUrl() {
|
|
23816
|
-
const location = (0, import_react_router_dom3.useLocation)();
|
|
23817
|
-
const hasTokenInUrl = (0, import_react65.useMemo)(() => {
|
|
23818
|
-
const searchParams = new URLSearchParams(location.search);
|
|
23819
|
-
const token = searchParams.get("token");
|
|
23820
|
-
const refreshToken = searchParams.get("refreshToken");
|
|
23821
|
-
const sessionId = searchParams.get("sessionId");
|
|
23822
|
-
return !!(token && refreshToken && sessionId);
|
|
23823
|
-
}, [location.search]);
|
|
23824
|
-
return { hasTokenInUrl };
|
|
23825
|
-
}
|
|
23826
|
-
|
|
23827
|
-
// src/components/Auth/Auth.tsx
|
|
23828
|
-
var import_jsx_runtime112 = require("react/jsx-runtime");
|
|
23829
|
-
var AuthContext = (0, import_react66.createContext)(void 0);
|
|
23830
|
-
var AuthProvider = ({
|
|
23831
|
-
children,
|
|
23832
|
-
checkAuthFn,
|
|
23833
|
-
signOutFn,
|
|
23834
|
-
initialAuthState = {},
|
|
23835
|
-
getUserFn,
|
|
23836
|
-
getSessionFn,
|
|
23837
|
-
getTokensFn
|
|
23838
|
-
}) => {
|
|
23839
|
-
const [authState, setAuthState] = (0, import_react66.useState)({
|
|
23840
|
-
isAuthenticated: false,
|
|
23841
|
-
isLoading: true,
|
|
23842
|
-
...initialAuthState
|
|
23843
|
-
});
|
|
23844
|
-
const checkAuth = (0, import_react66.useCallback)(async () => {
|
|
23845
|
-
try {
|
|
23846
|
-
setAuthState((prev) => ({ ...prev, isLoading: true }));
|
|
23847
|
-
if (!checkAuthFn) {
|
|
23848
|
-
setAuthState((prev) => ({
|
|
23849
|
-
...prev,
|
|
23850
|
-
isAuthenticated: false,
|
|
23851
|
-
isLoading: false
|
|
23852
|
-
}));
|
|
23853
|
-
return false;
|
|
23854
|
-
}
|
|
23855
|
-
const isAuth = await checkAuthFn();
|
|
23856
|
-
setAuthState((prev) => ({
|
|
23857
|
-
...prev,
|
|
23858
|
-
isAuthenticated: isAuth,
|
|
23859
|
-
isLoading: false,
|
|
23860
|
-
user: getUserFn ? getUserFn() : prev.user,
|
|
23861
|
-
sessionInfo: getSessionFn ? getSessionFn() : prev.sessionInfo,
|
|
23862
|
-
tokens: getTokensFn ? getTokensFn() : prev.tokens
|
|
23863
|
-
}));
|
|
23864
|
-
return isAuth;
|
|
23865
|
-
} catch (error) {
|
|
23866
|
-
console.error("Erro ao verificar autentica\xE7\xE3o:", error);
|
|
23867
|
-
setAuthState((prev) => ({
|
|
23868
|
-
...prev,
|
|
23869
|
-
isAuthenticated: false,
|
|
23870
|
-
isLoading: false
|
|
23871
|
-
}));
|
|
23872
|
-
return false;
|
|
23873
|
-
}
|
|
23874
|
-
}, [checkAuthFn, getUserFn, getSessionFn, getTokensFn]);
|
|
23875
|
-
const signOut = (0, import_react66.useCallback)(() => {
|
|
23876
|
-
if (signOutFn) {
|
|
23877
|
-
signOutFn();
|
|
23878
|
-
}
|
|
23879
|
-
setAuthState((prev) => ({
|
|
23880
|
-
...prev,
|
|
23881
|
-
isAuthenticated: false,
|
|
23882
|
-
user: void 0,
|
|
23883
|
-
sessionInfo: void 0,
|
|
23884
|
-
tokens: void 0
|
|
23885
|
-
}));
|
|
23886
|
-
}, [signOutFn]);
|
|
23887
|
-
(0, import_react66.useEffect)(() => {
|
|
23888
|
-
checkAuth();
|
|
23889
|
-
}, [checkAuth]);
|
|
23890
|
-
const contextValue = (0, import_react66.useMemo)(
|
|
23891
|
-
() => ({
|
|
23892
|
-
...authState,
|
|
23893
|
-
checkAuth,
|
|
23894
|
-
signOut
|
|
23895
|
-
}),
|
|
23896
|
-
[authState, checkAuth, signOut]
|
|
23897
|
-
);
|
|
23898
|
-
return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(AuthContext.Provider, { value: contextValue, children });
|
|
23899
|
-
};
|
|
23900
|
-
var useAuth = () => {
|
|
23901
|
-
const context = (0, import_react66.useContext)(AuthContext);
|
|
23902
|
-
if (context === void 0) {
|
|
23903
|
-
throw new Error("useAuth deve ser usado dentro de um AuthProvider");
|
|
23904
|
-
}
|
|
23905
|
-
return context;
|
|
23906
|
-
};
|
|
23907
|
-
var ProtectedRoute = ({
|
|
23908
|
-
children,
|
|
23909
|
-
redirectTo = "/",
|
|
23910
|
-
loadingComponent,
|
|
23911
|
-
additionalCheck
|
|
23912
|
-
}) => {
|
|
23913
|
-
const { isAuthenticated, isLoading, ...authState } = useAuth();
|
|
23914
|
-
const defaultLoadingComponent = /* @__PURE__ */ (0, import_jsx_runtime112.jsx)("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)("div", { className: "text-text-950 text-lg", children: "Carregando..." }) });
|
|
23915
|
-
if (isLoading) {
|
|
23916
|
-
return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_jsx_runtime112.Fragment, { children: loadingComponent || defaultLoadingComponent });
|
|
23917
|
-
}
|
|
23918
|
-
if (!isAuthenticated) {
|
|
23919
|
-
if (typeof window !== "undefined") {
|
|
23920
|
-
const rootDomain = getRootDomain();
|
|
23921
|
-
const currentLocation = `${window.location.protocol}//${window.location.hostname}${window.location.port ? ":" + window.location.port : ""}`;
|
|
23922
|
-
if (rootDomain !== currentLocation) {
|
|
23923
|
-
window.location.href = rootDomain;
|
|
23924
|
-
return null;
|
|
23925
|
-
}
|
|
23926
|
-
}
|
|
23927
|
-
return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_react_router_dom4.Navigate, { to: redirectTo, replace: true });
|
|
23928
|
-
}
|
|
23929
|
-
if (additionalCheck && !additionalCheck({ isAuthenticated, isLoading, ...authState })) {
|
|
23930
|
-
return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_react_router_dom4.Navigate, { to: redirectTo, replace: true });
|
|
23931
|
-
}
|
|
23932
|
-
return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_jsx_runtime112.Fragment, { children });
|
|
23933
|
-
};
|
|
23934
|
-
var PublicRoute = ({
|
|
23935
|
-
children,
|
|
23936
|
-
redirectTo = "/painel",
|
|
23937
|
-
redirectIfAuthenticated = false,
|
|
23938
|
-
checkAuthBeforeRender = false,
|
|
23939
|
-
tokenValidationComponent
|
|
23940
|
-
}) => {
|
|
23941
|
-
const { isAuthenticated, isLoading } = useAuth();
|
|
23942
|
-
const { hasTokenInUrl } = useTokenInUrl();
|
|
23943
|
-
if (hasTokenInUrl && tokenValidationComponent) {
|
|
23944
|
-
return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_jsx_runtime112.Fragment, { children: tokenValidationComponent });
|
|
23945
|
-
}
|
|
23946
|
-
if (checkAuthBeforeRender && isLoading) {
|
|
23947
|
-
return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)("div", { className: "text-text-950 text-lg", children: "Carregando..." }) });
|
|
23948
|
-
}
|
|
23949
|
-
if (isAuthenticated && redirectIfAuthenticated) {
|
|
23950
|
-
return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_react_router_dom4.Navigate, { to: redirectTo, replace: true });
|
|
23951
|
-
}
|
|
23952
|
-
return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_jsx_runtime112.Fragment, { children });
|
|
23953
|
-
};
|
|
23954
|
-
var withAuth = (Component, options = {}) => {
|
|
23955
|
-
return (props) => /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(ProtectedRoute, { ...options, children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(Component, { ...props }) });
|
|
23956
|
-
};
|
|
23957
|
-
var useAuthGuard = (options = {}) => {
|
|
23958
|
-
const authState = useAuth();
|
|
23959
|
-
const { requireAuth = true, customCheck } = options;
|
|
23960
|
-
const canAccess = !authState.isLoading && (requireAuth ? authState.isAuthenticated && (!customCheck || customCheck(authState)) : !authState.isAuthenticated || !customCheck || customCheck(authState));
|
|
23961
|
-
return {
|
|
23962
|
-
canAccess,
|
|
23963
|
-
isLoading: authState.isLoading,
|
|
23964
|
-
authState
|
|
23965
|
-
};
|
|
23966
|
-
};
|
|
23967
|
-
var useRouteAuth = (fallbackPath = "/") => {
|
|
23968
|
-
const { isAuthenticated, isLoading } = useAuth();
|
|
23969
|
-
const location = (0, import_react_router_dom4.useLocation)();
|
|
23970
|
-
const redirectToLogin = () => /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_react_router_dom4.Navigate, { to: fallbackPath, state: { from: location }, replace: true });
|
|
23971
|
-
return {
|
|
23972
|
-
isAuthenticated,
|
|
23973
|
-
isLoading,
|
|
23974
|
-
redirectToLogin
|
|
23975
|
-
};
|
|
23976
|
-
};
|
|
23977
|
-
var getRootDomain = () => {
|
|
23978
|
-
const { hostname, protocol, port } = window.location;
|
|
23979
|
-
const portStr = port ? ":" + port : "";
|
|
23980
|
-
if (hostname === "localhost") {
|
|
23981
|
-
return `${protocol}//${hostname}${portStr}`;
|
|
23982
|
-
}
|
|
23983
|
-
const isIPv4 = /^\d{1,3}(?:\.\d{1,3}){3}$/.test(hostname);
|
|
23984
|
-
const isIPv6 = hostname.includes(":");
|
|
23985
|
-
if (isIPv4 || isIPv6) {
|
|
23986
|
-
return `${protocol}//${hostname}${portStr}`;
|
|
23987
|
-
}
|
|
23988
|
-
const parts = hostname.split(".");
|
|
23989
|
-
if (parts.length >= 3 && parts[parts.length - 2] === "com" && parts[parts.length - 1] === "br") {
|
|
23990
|
-
if (parts.length === 3) {
|
|
23991
|
-
return `${protocol}//${hostname}${portStr}`;
|
|
23992
|
-
}
|
|
23993
|
-
const base = parts.slice(-3).join(".");
|
|
23994
|
-
return `${protocol}//${base}${portStr}`;
|
|
23995
|
-
}
|
|
23996
|
-
if (parts.length > 2) {
|
|
23997
|
-
const base = parts.slice(-2).join(".");
|
|
23998
|
-
return `${protocol}//${base}${portStr}`;
|
|
23999
|
-
}
|
|
24000
|
-
return `${protocol}//${hostname}${portStr}`;
|
|
24001
|
-
};
|
|
24002
|
-
|
|
24003
23999
|
// src/components/Auth/zustandAuthAdapter.ts
|
|
24004
24000
|
function createZustandAuthAdapter(useAuthStore2) {
|
|
24005
24001
|
return {
|