1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1670],{26856:(e,t,n)=>{n.d(t,{L:()=>h,api:()=>T});var r=n(94914),i=n(74967);let a=null;async function l(e){return e.startsWith("".concat((0,r.h)(),"/"))?(a||(a=o().finally(()=>{a=null})),a):"unknown"}async function o(){try{var e;let t=await fetch("/api/auth/me",{credentials:"include",cache:"no-store"});if(401===t.status){let e=await t.json().catch(()=>null);if((0,i.qE)(null==e?void 0:e.detail))return(0,i.$3)(),"unknown";return"invalid"}if(!t.ok)return"unknown";let n=await t.json();return(null==n?void 0:n.status)===1&&(null!=(e=n.user_id)?e:n.id)?"valid":"unknown"}catch(e){return"unknown"}}var s=n(65348),u=n(57508);let c="x-virse-auth-session",d=["valid","invalid","unknown"];var f=n(1811);class h extends Error{constructor(e,t,n){super(e),this.status=t,this.data=n,this.name="APIError"}}let p=null,w=function(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],t={};return e&&(t["Content-Type"]="application/json"),t},m=(e,t)=>{let n=new Headers(e);return t&&new Headers(t).forEach((e,t)=>{n.set(t,e)}),n},g=e=>{if(e.startsWith("http"))return e;let t=e;return t.startsWith("/api/proxy/")?t:(t.startsWith("/api/")&&(t=t.slice(4)),t.startsWith("/")&&(t=t.slice(1)),"/api/proxy/".concat(t))},y=e=>e.replace(/[\\/]/g,"-").trim()||null;async function v(e){if(e.startsWith("/user_login")||e.startsWith("/auth/me"))return;let t=s.k.getState().wasAuthenticated;throw p||(p=Promise.resolve().then(()=>{let e="".concat(window.location.pathname).concat(window.location.search);if(t)window.location.href="/login?session_expired=true";else if(u.r.getState().isHostMounted)u.r.getState().openLoginModal({intent:"generic",redirectAfter:e});else"/login"!==window.location.pathname&&(window.location.href="/login?redirect=".concat(encodeURIComponent(e)))}).finally(()=>{p=null})),await p,new h(t?"Session expired. Please login again.":"Authentication required.",401)}async function S(e){let t,n=e.statusText||"Unknown error";try{let r=await e.json();t=r,"object"==typeof r&&null!==r&&(n="message"in r&&"string"==typeof r.message?r.message:JSON.stringify(r))}catch(t){try{let t=await e.text();t&&(n=t)}catch(e){}}return{detail:n,data:t}}async function E(e,t,n,r){if((0,i.qE)(null==e?void 0:e.detail)||(0,i.qE)(t))throw(0,i.$3)(),new h("Signed in on another device.",401,e);throw"invalid"===(null===n?await l(r):d.includes(n)?n:"unknown")&&await v(r),new h("API request failed (401): ".concat(t),401,e)}async function k(e,t){let{detail:n,data:r}=await S(e);return E(r,n,e.headers.get(c),t)}async function b(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];try{let r=g(e),i=w(!n),{headers:a,...l}=t,o=await fetch(r,{...l,headers:m(i,a)});if(401===o.status&&await k(o,e),!o.ok){let{detail:e,data:t}=await S(o);throw new h("API request failed (".concat(o.status,"): ").concat(e),o.status,t)}if((o.headers.get("content-type")||"").includes("application/json"))return await o.json();return await o.text()}catch(e){if(e instanceof h)throw e;if(e instanceof Error&&"AbortError"===e.name)throw new h("Request was cancelled",0);throw f.default.warn({msg:"API request error",error:e instanceof Error?e.message:String(e)}),new h("Network error occurred")}}async function A(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];try{let r=g(e),i=w(!n),{headers:a,...l}=t,o=await fetch(r,{...l,headers:m(i,a)});if(401===o.status&&await k(o,e),!o.ok){let{detail:e}=await S(o);throw new h("API request failed (".concat(o.status,"): ").concat(e),o.status)}return{blob:await o.blob(),filename:(e=>{if(!e)return null;let t=e.match(/filename\*=UTF-8''([^;]+)/i);if(null==t?void 0:t[1])try{return y(decodeURIComponent(t[1].trim()))}catch(e){return y(t[1].trim())}let n=e.match(/filename="([^"]+)"/i);if(null==n?void 0:n[1])return y(n[1].trim());let r=e.match(/filename=([^;]+)/i);return(null==r?void 0:r[1])?y(r[1].trim()):null})(o.headers.get("content-disposition")),contentType:o.headers.get("content-type")}}catch(e){if(e instanceof h)throw e;if(e instanceof Error&&"AbortError"===e.name)throw new h("Request was cancelled",0);throw f.default.warn({msg:"API blob request error",error:e instanceof Error?e.message:String(e)}),new h("Network error occurred")}}let T={get:e=>
1b(e),post:(e,t,n)=>t instanceof FormData?b(e,{method:"POST",body:t,...n},!0):b(e,{method:"POST",body:JSON.stringify(t),...n}),postBlob:(e,t,n)=>t instanceof FormData?A(e,{method:"POST",body:t,...n},!0):A(e,{method:"POST",body:JSON.stringify(t),...n}),upload:(e,t,n,r)=>(function(e,t,n,r){return new Promise((i,a)=>{var l,o;let s=new XMLHttpRequest;for(let[t,n]of(s.open("POST",g(e)),s.withCredentials=null==(l=null==r?void 0:r.withCredentials)||l,Object.entries(null!=(o=null==r?void 0:r.headers)?o:{})))s.setRequestHeader(t,n);s.upload.onprogress=e=>{e.lengthComputable&&!(e.total<=0)&&(null==n||n(Math.min(95,Math.round(e.loaded/e.total*100))))},s.onerror=()=>{f.default.warn({msg:"API upload request error",endpoint:e}),a(new h("Network error occurred"))},s.onabort=()=>a(new h("Request was cancelled",0)),s.onload=()=>{(async()=>{let t=s.getResponseHeader("content-type"),r=s.responseText;if(null==t?void 0:t.includes("application/json"))try{r=JSON.parse(s.responseText)}catch(e){throw new h("Invalid JSON response",s.status)}let i="object"==typeof r&&null!==r&&"message"in r&&"string"==typeof r.message?r.message:s.responseText||s.statusText||"Unknown error";if(401===s.status&&await E(r,i,s.getResponseHeader(c),e),s.status<200||s.status>=300)throw new h("API request failed (".concat(s.status,"): ").concat(i),s.status,r);return null==n||n(100),r})().then(i,a)},s.send(t)})})(e,t,n,r),put:(e,t)=>b(e,{method:"PUT",body:JSON.stringify(t)}),patch:(e,t)=>b(e,{method:"PATCH",body:JSON.stringify(t)}),delete:e=>b(e,{method:"DELETE"})}},27207:(e,t,n)=>{n.d(t,{LV:()=>o,Ym:()=>a,c3:()=>i,qB:()=>l});var r=n(22092);function i(){let{t:e}=(0,r.W)();return e}function a(){let{locale:e}=(0,r.W)();return e}function l(){let{setLocale:e}=(0,r.W)();return e}function o(){let{t:e}=(0,r.W)();return(t,n)=>e("".concat(t).concat(0===n||1===n?".singular":".plural"),{count:n})}},57508:(e,t,n)=>{n.d(t,{r:()=>a});var r=n(50438);let i={isOpen:!1,initialStep:null,initialResetToken:null,initialEmail:null,redirectAfter:null,intent:null},a=(0,r.vt)(e=>({...i,isHostMounted:!1,openLoginModal:t=>{var n,r,i,a,l;e({isOpen:!0,initialStep:null!=(n=null==t?void 0:t.initialStep)?n:null,initialResetToken:null!=(r=null==t?void 0:t.initialResetToken)?r:null,initialEmail:null!=(i=null==t?void 0:t.initialEmail)?i:null,redirectAfter:null!=(a=null==t?void 0:t.redirectAfter)?a:null,intent:null!=(l=null==t?void 0:t.intent)?l:"generic"})},closeLoginModal:()=>{e({isOpen:!1})},resetLoginModal:()=>{e({...i})},setLoginModalHostMounted:t=>{e({isHostMounted:t})}}))},65348:(e,t,n)=>{n.d(t,{k:()=>a});var r=n(50438),i=n(39361);let a=(0,r.vt)()((0,i.Zr)(e=>({userId:null,initial:null,displayName:null,email:null,pictureUrl:null,isLoaded:!1,wasAuthenticated:!1,features:[],syncFromAuthUser:t=>{var n;if(!t)return void e({userId:null,initial:null,displayName:null,email:null,pictureUrl:null,isLoaded:!1,wasAuthenticated:!1,features:[]});let r=function(e,t){if(e&&e.trim())return e.trim()[0].toUpperCase();if(t){let e=t.split("@")[0];return e?e[0].toUpperCase():"?"}return"?"}(t.name,t.email),i=function(e,t){return e&&e.trim()?e.trim():t&&t.split("@")[0]||"User"}(t.name,t.email);e({userId:t.user_id,initial:r,displayName:i,email:t.email,pictureUrl:t.picture||null,isLoaded:!0,wasAuthenticated:!0,features:null!=(n=t.features)?n:[]})},clearUserData:()=>{e({userId:null,initial:null,displayName:null,email:null,pictureUrl:null,isLoaded:!1,wasAuthenticated:!1,features:[]})}}),{name:"virse-user-display",partialize:e=>({initial:e.initial,displayName:e.displayName,email:e.email,pictureUrl:e.pictureUrl}),merge:(e,t)=>({...t,...e,userId:null,isLoaded:!1,wasAuthenticated:!1,features:[]})}))},74967:(e,t,n)=>{n.d(t,{qE:()=>a,cu:()=>o,$3:()=>s});var r=n(1811),i=n(65348);function a(e){return"string"==typeof e&&e.includes("SESSION_SUPERSEDED")}let l=!1;function o(e,t){return!!function(e,t){if(401!==e)return!1;let n=t;try{var r;n=null==(r=JSON.parse(t))?void 0:r.detail}catch(e){}return a(n)||a(t)}(e,t)&&(s(),!0)}async function s(){if(!l){l=!0,r.default.warn({msg:"[SessionSuperseded] Account signed in on another device â ending this session"});try{i.k.getState().clearUserData()}catch(e){r.default.debug({msg:"[SessionSuperseded] Failed to clear user store",error:e instanceof Error?e.message:String(e)})}try{await fetch("/api/auth/set-cookie",{method:"DELETE",credentials:"include"})}catch(e){r.default.debug({msg:"[SessionSuperseded] Failed to clear auth cookie",error:e instanceof Error?e.message:String(e)})}window.location.href="/login?session_superseded=true"}}}
1,94914:(e,t,n)=>{n.d(t,{h:()=>r});function r(){return"https://api.virse.ai".replace(/\/$/,"")}}}]);
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.