Files
web-alterflixhub/assets/use-session-DJs-YY25.js
T
Bkk1234 e6c4ebff48 chore(publish): replace source tree with static export at repo root
Publish the prerendered static export (index.html, 404.html, cinema/,
c/, about/, for-cinemas/, for-film-lovers/, assets/, images/, og/,
sitemap.xml, robots.txt) as the site root and remove the React Router
+ Nitro source tree from this branch. Source remains available in
history at 0548772.

Note: public/sw.js here reports VERSION v2.0.5 while the removed source
tree (v2.1.0) was newer, and .gitignore was not carried over.
2026-11-22 22:24:36 +07:00

1 line
6.9 KiB
JavaScript

import{i as e,t}from"./react-B8IZ02wI.js";import{c as n,d as r,f as i,l as a,o,s,u as c}from"./analytics-hbCOwHmS.js";import{l}from"./session-replay-endpoint-CkXvYk-L.js";var u=[`en-US`,`es-ES`,`fr-FR`,`de-DE`,`pt-BR`,`zh-CN`,`zh-TW`,`ja-JP`,`ko-KR`,`hi-IN`,`ar-SA`],ee=`en-US`,d=`agent-native:locale-preference`,f=`__AGENT_NATIVE_LOCALE__`;new Set(u);var p={"zh-cn":`zh-CN`,"zh-hans":`zh-CN`,"zh-hans-cn":`zh-CN`,"zh-hans-sg":`zh-CN`,"zh-hant":`zh-TW`,"zh-hant-hk":`zh-TW`,"zh-hant-mo":`zh-TW`,"zh-hant-tw":`zh-TW`,"zh-hk":`zh-TW`,"zh-mo":`zh-TW`,"zh-sg":`zh-CN`,"zh-tw":`zh-TW`};function te(e){let t=e.toLowerCase(),n=p[t];if(n)return n;let r=t.split(`-`);return r[0]===`zh`?r.includes(`hant`)||r.includes(`tw`)||r.includes(`hk`)||r.includes(`mo`)?`zh-TW`:r.includes(`hans`)||r.includes(`cn`)||r.includes(`sg`)?`zh-CN`:null:null}function m(e){if(typeof e!=`string`||e.trim().length===0)return null;try{return Intl.getCanonicalLocales(e.trim())[0]??null}catch{return null}}function ne(e,t=u){let n=m(e);if(!n)return null;let r=t.map(e=>m(e)).filter(e=>e!==null),i=r.find(e=>e===n);if(i)return i;let a=te(n);if(a&&r.includes(a))return a;let o=n.split(`-`)[0]?.toLowerCase();return r.find(e=>e.split(`-`)[0]?.toLowerCase()===o)??null}var h=e(t(),1),g=`__agentNativeNavigationStarted`,_=2e3,re=`agent-native:session-navigation-released`;function ie(){return typeof window<`u`&&typeof window.__agentNativeNavigationStarted==`string`}function v(e){window.__agentNativeNavigationStarted===e&&(delete window[g],window.dispatchEvent?.(new Event(re)))}function ae(e){return typeof window>`u`||ie()?!1:(window[g]=e,window.addEventListener?.(`pageshow`,t=>{t.persisted&&v(e)}),setTimeout(()=>v(e),_),window.location.replace(e),!0)}function oe(e,t){if(typeof window>`u`)return;let n=window.parent===window?window:window.parent,r=x()||window.location.origin;n.postMessage({type:e,data:t},r)}var y=null;function b(e){if(typeof e!=`string`)return null;if(e===`null`)return`null`;try{return new URL(e).origin}catch{return null}}function x(){let e=w();return e===`null`?`*`:e}var S=!1,C=0;function se(){if(typeof document>`u`)return 0;let e=document.documentElement,t=document.body;return Math.ceil(Math.max(e?e.scrollHeight:0,t?t.scrollHeight:0))}function ce(){if(typeof window>`u`||window.parent===window)return;let e=se();!e||Math.abs(e-C)<2||(C=e,oe(`agentNative.contentHeight`,{height:e}))}function le(){if(S||typeof window>`u`||window.parent===window)return;S=!0;let e=!1,t=()=>{typeof window>`u`||e||(e=!0,window.requestAnimationFrame(()=>{e=!1,!(typeof window>`u`)&&ce()}))};t();for(let e of[100,300,800,1500])window.setTimeout(t,e);try{let e=new ResizeObserver(t);document.documentElement&&e.observe(document.documentElement),document.body&&e.observe(document.body)}catch{window.addEventListener(`resize`,t,{passive:!0})}window.addEventListener(`load`,t,{passive:!0})}typeof window<`u`&&window.addEventListener(`message`,e=>{let t=b(e.origin),n=b(e.data?.origin),r=t??n;e.data?.type===`agentNative.frameOrigin`&&r&&(!n||n===r||r===`null`)&&!y&&e.source===window.parent&&(y=r,window.parent.postMessage({type:`agentNative.embeddedAppReady`},x()??window.location.origin),le())});function w(){return y}(0,h.createContext)(!1);var T,E;function ue(e,t){let n=ae(e);if(n&&t)try{s(`session_navigation`,{reason:t,...t===`signed_out`&&E?{evidence:E.evidence,read_failures:E.readFailures,resolved_after_ms:E.resolvedAfterMs}:{},page_age_ms:Math.round(performance.now())})}catch{}return n}var D=a,O=3e4,de=500,fe=5e3,pe=`agent-native:session-invalidated`,k=`/_agent-native/auth/session`,A,j=0,M,N,P,F=0,I=!1,L,R={session:null,status:`loading`,error:null},z=R,B=new Set,V=0,H=0;function U(e){return e.status===`authenticated`||e.status===`unauthenticated`}function W(e){if(z.status!==`signing-out`&&!(e.status===z.status&&e.session===z.session&&e.error===z.error)){z=e;for(let e of B)e()}}function G(){return performance.now()}var K=Symbol(`retry-budget-exceeded`);function me(e){return new Promise(t=>{setTimeout(()=>t(K),Math.max(e,0))})}function q(){return A!==void 0&&Date.now()-j<D}function he(e){let t=e?.userId??e?.email??null,r=e?.authUserId;(N!==t||P!==r)&&(N=t,P=r,e?o({id:e.userId,email:e.email,username:e.name,authUserId:r,testIdentity:e.testIdentity},e.orgId??null):o(null,null)),n(!!e)}function ge(e){if(typeof window>`u`||window.parent===window||!w())return;let t=x();if(t)try{window.parent.postMessage({type:`agentNative.authState`,data:{status:e}},t)}catch{}}function J(){F+=1,A=void 0,j=0,T=void 0,M=void 0,clearTimeout(L),L=void 0}function Y(){return B.size===0?(V+=1,H=0,z.status!==`signing-out`&&(z=R),Promise.resolve()):$()}function X(){return J(),i(k),Y()}function Z(){J(),c(k),Y()}function Q(){if(!q()||!A){Z();return}if(L!==void 0)return;let e=j;L=setTimeout(()=>{L=void 0,j===e&&(document.visibilityState!==`visible`||!document.hasFocus()||Z())},Math.max(0,e+D-Date.now()))}function _e(){I||typeof window>`u`||typeof document>`u`||(I=!0,window.addEventListener(`focus`,Q),window.addEventListener(`storage`,e=>{e.key===pe&&(X(),setTimeout(()=>void X(),D))}),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&Q()}))}function ve(){if(l())return Promise.resolve({state:`resolved`,session:null});if(q())return Promise.resolve({state:`resolved`,session:A??null});if(M)return M;let e=F,t;return t=(async()=>{try{let t=await r();if(e!==F)return{state:`superseded`};if(t.state===`unavailable`&&t.status!==401)return{state:`unreadable`};let n=t.state===`available`?t.value:{error:`Not authenticated`};if(n.error!==void 0&&n.error!==`Not authenticated`)return{state:`unreadable`};let i=n.error===`Not authenticated`?null:n;return A=i,j=Date.now(),T=i?`signed_in`:t.state===`unavailable`?`http_401`:`signed_out_body`,he(i),{state:`resolved`,session:i}}catch{return{state:`unreadable`}}})().finally(()=>{M===t&&(M=void 0)}),M=t,M}async function $(){let e=++V;H=e;let t=()=>e===V&&!0,n=G(),r=0;try{for(;;){let e=O-(G()-n),a=await Promise.race([ve(),me(e)]);if(!t())return;let o,s=!1;if(a===K?(J(),i(k),s=!0,o={state:`unreadable`}):o=a,o.state===`resolved`){E={evidence:T??(o.session?`signed_in`:`signed_out_body`),readFailures:r,resolvedAfterMs:Math.round(G()-n)},W({session:o.session,status:o.session?`authenticated`:`unauthenticated`,error:null}),ge(o.session?`authenticated`:`unauthenticated`);return}o.state===`unreadable`&&(r+=1);let c=O-(G()-n);if(c<=0){let e=Error(`Could not read the session after ${r} attempts.`);W(U(z)?{...z,error:e}:{session:null,status:`unavailable`,error:e}),s&&!U(z)&&queueMicrotask(()=>void $());return}let l=o.state===`superseded`?0:Math.min(de*2**(r-1),fe,c);if(await new Promise(e=>setTimeout(e,l)),!t())return}}finally{H===e&&(H=0)}}function ye(){W(R),$()}function be(e){return B.add(e),H===0&&(U(z)?q()||Z():z.status===`loading`&&$()),()=>{B.delete(e)}}function xe(){return z}function Se(){return R}function Ce(){_e();let e=(0,h.useSyncExternalStore)(be,xe,Se),t=e.status===`loading`||e.status===`unavailable`;return{session:e.session,isLoading:t,status:e.status,error:e.error,retry:ye}}export{d as a,f as i,Ce as n,ne as o,ee as r,ue as t};