import{l as r,C as s,f as u,i as f,M as g}from"./index-ByQHsvE1.js";try{let e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},s=(new e.Error).stack;s&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[s]="c0ac272b-69b6-48d5-a01d-50bd44dd54ce",e._sentryDebugIdIdentifier="sentry-dbid-c0ac272b-69b6-48d5-a01d-50bd44dd54ce")}catch{}async function w(e,t){try{const i=e();if(!i)return r.log("No session stored; continuing without a client"),null;r.log("Using a standalone client");const{user_id:l,device_id:n,access_token:o,passwordlessUser:a}=i,c={baseUrl:s.defaultHomeserverUrl(),accessToken:o,userId:l,deviceId:n,fallbackICEServerAllowed:u,livekitServiceURL:s.get().livekit?.livekit_service_url};try{return{widgetApi:null,client:await f(c,!0),passwordlessUser:a}}catch(e){if(e instanceof g&&"M_UNKNOWN_TOKEN"===e.errcode)return r.log("The session from local store is invalid; continuing without a client"),t(),null;throw e}}catch(e){throw t(),e}}export{w as initSPA};