/* * Extracted from browser-delivered Turbopack chunk: 2cd465e94e439d21.d295534e06.js * Module id: 211478 * For reading/searching only; this factory depends on the original Turbopack runtime. */ const moduleFactory = (e) => { "use strict"; var t = e.i(462214), r = e.i(358379), o = e.i(677588), n = e.i(325528); e.i(606823); var i = e.i(104596); e.i(693602); var a = e.i(40456), s = e.i(50602), l = e.i(640958), c = e.i(135623); let u = ({ onClose: e, visible: o }) => { let { isLoading: u, setLoadingState: d, setSuccessState: f, setFailState: p, } = (0, i.useLoadingHooks)(), g = (0, r.useRef)(null), m = (0, r.useMemo)(() => { let e = new URLSearchParams(window.location.search), t = e.get("bd_vid") || "", r = e.get("track_id") || "", o = e.get("qhclickid") || "", i = e.get("msclkid") || "", a = e.get("cb") || "", s = ""; return (t && (s = `&bd_vid=${t}`), r && (s = `&track_id=${r}`), o && (s = `&qhclickid=${o}`), i && (s = `&msclkid=${i}`), a && (s = `&cb=${a}`), "test" === n.config.name) ? `https://www-test.liblib.art/login?platform=libtv${s}` : "pre" === n.config.name ? `https://www-pre.liblib.art/login?platform=libtv${s}` : "online" === n.config.name ? `https://www.liblib.art/login?platform=libtv${s}` : void 0; }, []); return ((0, r.useEffect)(() => { if (!o) return () => void 0; { d(), g.current && clearTimeout(g.current), (g.current = setTimeout(() => { e?.(), p(""); }, 15e3)); let t = (t) => { try { if (!t.data) return; let { type: r, token: o, data: i, } = "object" == typeof t.data ? t.data : JSON.parse(String(t.data)); if ("onLoginClose" === r) e?.(); else if ("onLoginPageLoadFinish" === r) f(), g.current && clearTimeout(g.current); else if ("loginSuccess" === r) { let e = String(o ?? i ?? ""), t = (0, c.getCookieWebid)(); (0, l.setCookieLongTerm)("usertoken", e, { secure: "https" === window.location.protocol, sameSite: "https" === window.location.protocol ? "none" : "", }); try { (0, a.getSSOClient)({ siteId: n.config.tv.domain, bridgeUrl: n.config.tv.bridgeUrl, }).notifyLogin({ token: e, webid: t, type: "login" }); } catch (e) { console.error("notifyLogin error:", e); } window.location.reload(); } else "onPageColse" === r ? e?.() : "redirectUrl" === r && i && (window.location.href = String(i)); } catch (e) { console.error("LibLogin messageListener error", e); } }; return ( window.addEventListener("message", t), () => { window.removeEventListener("message", t), g.current && (clearTimeout(g.current), (g.current = null)); } ); } }, [o, e, d, f, p]), o && m) ? (0, t.jsxs)(t.Fragment, { children: [ (0, t.jsx)(s.LoadingOverlay, { visible: u, zIndex: 1e3, overlayProps: { color: "transparent" }, }), (0, t.jsx)("iframe", { src: m, style: { width: "100%", height: "100%", background: "transparent", colorScheme: "normal", }, }), ], }) : null; }, d = (0, r.createContext)(null); e.s( [ "LoginProvider", 0, ({ children: e }) => { let [n, i] = (0, r.useState)(null), a = !!n, s = (0, r.useCallback)(() => { i(null); }, []), l = (0, r.useCallback)((e) => { (0, o.reportLog)({ page: 13, t: 1, e: "user.login.page.show", var: { platform: "xingliu" }, }), i({ ...e }); }, []), c = (0, r.useMemo)( () => ({ closeLogin: s, openLogin: l, isOpen: a }), [s, l, a], ); return (0, t.jsxs)(d.Provider, { value: c, children: [ e, (0, t.jsx)("div", { className: "login-modal-container", style: { position: "fixed", top: 0, left: 0, right: 0, bottom: 0, zIndex: a ? "var(--z-critical)" : -1, background: "transparent", pointerEvents: a ? "auto" : "none", }, children: (0, t.jsx)(u, { visible: a, onClose: s }), }), ], }); }, "useLogin", 0, () => { let e = (0, r.useContext)(d); if (!e) throw Error("useLogin must be used within a LoginProvider"); return e; }, ], 211478, ); }; export default moduleFactory;