1import{aT as B,r as e,a0 as I,k as _,aU as P,o as Q,i as n,w as V,T as k,ac as N,a3 as q,$ as G,u as K,p as d,a as Y,aF as y,j as l,aV as F,a4 as W,aW as X}from"./index.js";import{D as C}from"./steps.js";import{u as $}from"./useBrowserStatePolling.js";import{v as z,u as H}from"./store.js";const ae=()=>{const i=B(),L=e.useMemo(()=>{const r=new URLSearchParams(i.search).get("docId")?.trim();return r||null},[i.search]),m=e.useMemo(()=>{const r=new URLSearchParams(i.search).get("sessione")?.trim();return r||null},[i.search]);I();const p=_(),{token:t}=P(),{state:J,dispatch:a}=Q(),E=n(V),S=n(k),h=n(N),R=n(q),O=n(G),[Z,U]=K(X),{session:c,start:v,stop:s}=$(t??""),A=e.useRef(null);e.useEffect(()=>{c?.idRichiesta&&c.idRichiesta>0&&(A.current=c)},[c]);const b=A.current,o=b?.idRichiesta??0,T=b?.status??null;e.useEffect(()=>{m&&a({type:d.UpdateData,payload:{sessione:m}})},[m,a]);const j=e.useMemo(()=>({request:"DbOperations/validateMobileSession",method:"POST",shouldCache:!1,sleeper:!0,silent:!0}),[]),[u,w]=Y(j),[x,g]=e.useState(null);e.useEffect(()=>{t&&(sessionStorage.setItem(z,window.location.href),sessionStorage.setItem(H,"1"))},[t]),e.useEffect(()=>{t&&a({type:d.UpdateMobileToken,payload:t})},[t,a]),e.useEffect(()=>{if(t)return v(),()=>s()},[t,v,s]);const M=e.useRef(!1);e.useEffect(()=>{t&&o&&(M.current||(M.current=!0,w({body:{idSessioneMobile:t,idRichiesta:o}})))},[t,o,w]),e.useEffect(()=>{T==="EXPIRED"&&(s(),g("Sessione scaduta.#Ci vediamo sul computer."))},[T,s]),e.useEffect(()=>{u===!1&&(s(),g("Sessione non valida o scaduta.#Torna sul computer e genera un nuovo QR code per continuare."))},[u,s]);const D=e.useRef(!1);return e.useEffect(()=>{if(!t||!o||u!==!0||D.current)return;D.current=!0,a({type:d.SetIdRichiesta,payload:o}),U(!0),E(y.CONTATTI);const f=I()?C.ALLEGA:C.FOTOGRAFA;R(r=>({...r,[y.CONTATTI]:f})),S("selectDocument"),h(!0),O("mobileQr"),s(),p("/richiesta",{replace:!0})},[t,o,u,a,p,s,E,R,S,h,L]),t?x?l.jsx(F,{error:new Error(x),resetErrorBoundary:()=>{window.location.href="/preventivatore/simulatore"}}):l.jsx("div",{className:"flex items-center justify-center h-screen",children:l.jsx("img",{src:W,alt:"loader",className:"w-[120px] h-[120px] animate-spin"})}):l.jsx(F,{error:new Error("Errore generico.#Token mancante"),resetErrorBoundary:()=>{window.location.href="/preventivatore/simulatore"}})};export{ae as MobileBootFromQR};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.