PageSourceSearch

https://nano-gpt.com/_next/static/chunks/40456-d9b7ab5a2afd9341.js?dpl=dpl_8FwabnhEqknKHZ2oe6HmkRWcMUcP

js nano-gpt.com collected 2026-10-02 04:06:10 UTC 47,659 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[40456],{64164:(e,t,r)=>{r.d(t,{StoreInitializer:()=>ee});var n=r(695155),o=r(837882),a=r(212115),i=r(188074),l=r(393911),s=r(218398),u=r(808185),c=r(100879),d=r(573321),f=r(300832),h=r(960420),g=r(296201),m=r(449037),v=r(472081),p=r(231184),y=r(361915),w=r(824659),b=r(306584),S=r(152181),E=r(348303),I=r(192645),C=r(818801);let R=e=>{let{opened:t,onClose:r}=e,{conversation:o,mediaSync:l,memory:s,userData:c}=(0,u.useStores)(),[d,f]=a.useState("restore-settings-only"),[g,m]=a.useState(!1),R=async()=>{var e;if(!0!==await (null==s||null==(e=s.pullMemoryFromCloud)?void 0:e.call(s,{allowManualSync:!0,forceDownload:!0,forceApplyRemote:!0})))throw Error((null==s?void 0:s.syncError)||"Memory could not be restored from cloud.")},T=async()=>{m(!0),(0,h.fW)();try{var e,t,n;if("restore-all"===d){let r=(0,I.uA)("Restoring from cloud","Pulling conversations, media, settings, and memory…",{loading:!0,autoClose:!1}),n=(0,i.mJ)(()=>{var e,t;return{cloudSyncRunning:(null==o?void 0:o.cloudSyncRunning)===!0,cloudSyncTotal:null!=(e=null==o?void 0:o.cloudSyncTotal)?e:0,cloudSyncDone:null!=(t=null==o?void 0:o.cloudSyncDone)?t:0}},e=>{E.$e.update({id:r,title:"Restoring from cloud",message:(0,C.U)(e),loading:!0,autoClose:!1})},{fireImmediately:!0});try{await o.syncAllFromCloudIfEnabled({force:!0,reason:"post-reset-restore-all",bypassLocalDeleteSkips:!0,skipUserDataReapplyAfterConversationSync:!0}),await Promise.all([null==l||null==(e=l.pullMediaFromCloud)?void 0:e.call(l),R(),null==c||null==(t=c.pullUserDataFromCloud)?void 0:t.call(c,{forceDownload:!0,forceApplyRemote:!0})]),n(),E.$e.update({id:r,title:"Restore complete",message:"Your cloud data has been restored.",color:"teal",loading:!1,autoClose:3e3})}catch(e){n(),E.$e.update({id:r,title:"Restore partially failed",message:"Some data may not have been restored. Try refreshing the page.",color:"yellow",loading:!1,autoClose:5e3})}}else if("restore-settings-only"===d){let e=(0,I.uA)("Restoring settings","Pulling presets, folders, and memory…",{loading:!0,autoClose:!1});try{await Promise.all([R(),null==c||null==(n=c.pullUserDataFromCloud)?void 0:n.call(c,{allowManualSync:!0,bypassManualEligibilityCheck:!0,forceDownload:!0,forceApplyRemote:!0})]),E.$e.update({id:e,title:"Settings restored",message:"Your presets, folders, and memory have been restored. Conversations and media were not pulled.",color:"teal",loading:!1,autoClose:4e3})}catch(t){E.$e.update({id:e,title:"Restore partially failed",message:"Some settings may not have been restored. Try refreshing the page.",color:"yellow",loading:!1,autoClose:5e3})}}else E.$e.show({title:"Starting fresh",message:"No cloud data was restored. New activity will sync normally going forward.",color:"teal",autoClose:3e3})}finally{m(!1),r()}};return(0,n.jsx)(v.a,{opened:t,onClose:()=>{g||r()},title:"Restore from cloud?",centered:!0,closeOnClickOutside:!1,closeOnEscape:!1,withCloseButton:!1,children:(0,n.jsxs)(p.Stack,{gap:"md",children:[(0,n.jsx)(y.Text,{size:"sm",children:"Your local data was just reset. Would you like to restore data from your cloud sync?"}),(0,n.jsx)(w.s.Group,{value:d,onChange:e=>f(e),children:(0,n.jsxs)(p.Stack,{gap:"sm",children:[(0,n.jsx)(w.s,{value:"restore-all",label:"Restore everything",description:"Pull all conversations, media, settings, and memory from cloud.",disabled:g}),(0,n.jsx)(w.s,{value:"restore-settings-only",label:"Restore settings only",description:"Pull presets, folders, and memory. Leave conversations and media empty.",disabled:g}),(0,n.jsx)(w.s,{value:"start-fresh",label:"Start fresh",description:"Don't restore anything. New activity will sync to cloud going forward.",disabled:g})]})}),(0,n.jsx)(b.Group,{justify:"flex-end",children:(0,n.jsx)(S.Button,{loading:g,onClick:T,children:"start-fresh"===d?"Start fresh":"Restore"})})]})})};var T=r(747653),D=r(119347),A=r(296949),P=r(189852);let k="foreground-cloud-recovery-degraded",M=0,U=!1,L=new Map,N=()=>{M=0,U=!1,L.clear()},F=async()=>{let e=Array.from(L.entries());if(0===e.length)return!1;for(let[t,r]of e){let e=!1;try{e=await r()===!0}catch(t){e=!1}e&&L.delete(t)}return 0===L.size},x=e=>{let[t,r]=(0,a.useState)(!1),o=async()=>
1{if(t)return;r(!0);let e=!1;try{e=await F()}finally{r(!1)}e&&(N(),E.$e.hide(k))};return(0,n.jsxs)(b.Group,{justify:"space-between",align:"center",wrap:"nowrap",role:"alert","aria-live":"polite",children:[(0,n.jsx)(y.Text,{size:"sm",children:e.requiresReauth?"Your session expired before cloud data could be refreshed.":"Some cloud data could not be refreshed. Local data was kept and is not marked as synchronized."}),e.requiresReauth?(0,n.jsx)(S.Button,{component:"a",href:"/auth/signin?callbackUrl=%2F",size:"xs",variant:"light","aria-label":"Sign in to resume cloud sync",children:"Sign in"}):(0,n.jsx)(S.Button,{size:"xs",variant:"light",onClick:()=>void o(),loading:t,disabled:t,"aria-label":"Retry cloud recovery",children:"Retry now"})]})},O=async e=>{let t=[],r=0,o=0;for(let n of e.tasks)try{let e=await n.run();if(!1===e){var a;let e=null==(a=n.getFailureAfterFalse)?void 0:a.call(n);if(!e){o+=1;continue}throw e}r+=1}catch(r){let e=(0,A.G)({error:r,fallbackMessage:n.fallbackMessage});if("cancelled"===e.class){o+=1;continue}t.push({context:n.context,error:e}),(0,P.Vo)(e,n.context)}return t.length>0&&!1!==e.notify?(e=>{let t=Date.now();L.set(e.retryKey,e.retry);let r=M>0,o=r&&t-M<6e4,a=o&&e.requiresReauth&&!U;if(o&&!a)return;M=t;let i={id:k,color:"orange",title:(U=o&&U||e.requiresReauth)?"Sign in to resume cloud sync":"Cloud data may be out of date",autoClose:!1,onClose:N,message:(0,n.jsx)(x,{requiresReauth:U})};return r?E.$e.update(i):E.$e.show(i)})({retryKey:e.retryKey||"default",retry:e.retry,requiresReauth:t.some(e=>{let{error:t}=e;return"authentication"===t.class})}):0===t.length&&L.delete(e.retryKey||"default")&&0===L.size&&M>0&&(N(),E.$e.hide(k)),{failures:t,succeeded:r,skipped:o}};var B=r(734523),W=r(514314),z=r(731458),j=r(646632);let _=1e3*D.BS,G=async(e,t)=>{try{return await (0,i.z7)(t,{timeout:6e4}),!0}catch(t){return console.warn("Post-login ".concat(e," sync pull skipped because hydration did not finish"),t),!1}},V=/^\/(?:conversation|chat)(?:\/[^/]+)?$/,q=new Set(["/api","/media","/usage"]),H=["/usage/"],X=["gclid","gbraid","wbraid"],$=["track","source","referral_source",T.Z],K=e=>{let t=e||"/";return t.length<=1?t:t.replace(/\/+$/,"")||"/"},Z=e=>{let t=null==e?void 0:e.trim();return!!(t&&"landing"!==t)},Y=e=>X.some(t=>{var r;return!!(null==(r=e.get(t))?void 0:r.trim())}),Q=()=>{try{let e=new URLSearchParams(window.location.search);if(Z(e.get("source"))||Y(e))return!0;let t=e.get("callbackUrl")||e.get("callbackurl");if(t){let e=window.location.origin||"https://nano-gpt.com",r=new URL(t,e).searchParams;if(Z(r.get("source"))||Y(r))return!0}}catch(e){}try{var e;if(Z(null==(e=window.sessionStorage)?void 0:e.getItem("traffic_source")))return!0}catch(e){}try{let e=document.cookie.split(";"),t=new Map;for(let r of e){let e=r.trim(),n=e.split("=");if(n.length<2||!n[0])continue;let o=n[0];t.has(o)||t.set(o,e)}for(let e of $){let r=t.get(e);if(!r)continue;let n=r.split("=").slice(1).join("=");if(Z(decodeURIComponent(n)))return!0}}catch(e){}return!1},J=e=>null==e?"":String(e).trim(),ee=(0,s.PA)(()=>{var e,t,s;let v=(0,a.useRef)(!1),p=(0,a.useRef)(!1),y=(0,a.useRef)(new Map),w=(0,a.useRef)(!1),b=(0,a.useRef)(0),S=(0,a.useRef)(null),E=(0,a.useRef)(!1),I=(0,a.useRef)(!1),C=(0,a.useRef)(!1),T=(0,a.useRef)(null),D=(0,a.useRef)(null),{isReady:A,primaryTerminalClientHydrationIssue:P,session:k,nanoStore:M,ui:U,consent:L,folders:N,conversation:F,team:x,mediaSync:X,systemPromptPresets:$,samplerPresets:Z,memory:Y,userData:ee,savedLoras:et}=(0,u.useStores)();(0,a.useEffect)(()=>(0,i.fm)(()=>{(0,l.uE)((0,l.eD)(k,x))}),[k,x]),(0,a.useEffect)(()=>{let e=()=>{var e,t,r,n,o,a,i,l,s,u,c,d,f,h,g;return!!(F.prompt||F.visibleComposerPrompt||F.draftPromptWhilePending||F.queuedDraftPromptCarryover||(null==(e=F.state)?void 0:e.isPending)||(null==(t=F.state)?void 0:t.isPreparingSubmit)||F.isStreaming||(null==(r=F.attachments)?void 0:r.length)||(null==(n=F.scrapedUrls)?void 0:n.length)||(null==(o=F.scrapedContent)?void 0:o.length)||(null==(a=F.draftAttachmentIdsWhilePending)?void 0:a.length)||(null==(i=F.queuedDraftAttachmentIdsCarryover)?void 0:i.length)||(null==(l=F.queuedMessages)?void 0:l.length)||F.autoDequeuedQueuedMessageForRestore||(null==(s=F.draftScrapedUrlsWhilePending)?void 0:s.length)||(null==(u=F.draftScrapedContentWhilePending)?void 0:u.length)||(null==(c=F.queuedDraftScrapedUrlsCarryover)?void 0:c.length)||(null==(d=F.queuedDraftScrapedContentCarryover)?void 0:d.length)||(null==(f=F.pendingImageDescriptions)?void 0:f.length)||(null==(h=F.draftPendingImageDescriptionsWhilePending)?void 0:h.length)||(null==(g=F.queuedDraftPendingImageDescriptionsCarryover)?void 0:g.length)||F.navigationWarning||(0,j.$H)().value)},t=(0,W.aE)(e,()=>{var e;return null==(e=F.flushDraftPersistence)?void 0:e.call(F)},()=>(0,z.ju)(F)),r=(0,i.fm)(()=>{e(),(0,W.gZ)()});return()=>{r(),t()}},[F]);let er=(0,a.useCallback)(e=>{var t,r,n,o,a,i;let l=JSON.stringify([null!=(a=null==(r=k.auth)||null==(t=r.user)?void 0:t.id)?a:null,null!=(i=null==(o=k.auth)||null==(n=o.user)?void 0:n.clientSession)?i:null,(null==e?void 0:e.allowCreateIfMissing)===!0]),s=y.current.get(l);if(s)return s;let u=Promise.resolve(k.refresh(e));return y.current.set(l,u),u.catch(()=>y.current.delete(l)),u},[k]),en=(0,a.useCallback)(()=>(0,h.C9)({sessionUUID:k.sessionUUID,accountSessionId:k.accountSessionId}),[k.accountSessionId,k.sessionUUID]),eo=(0,a.useCallback)(()=>{let e=en();return(0,h.W)(e)||"guest"===e&&(0,h.LN)()},[en]),[ea,ei]=(0,a.useState)(!1),[el,es]=(0,a.useState)(!1),[eu,ec]=(0,a.useState)(!1),{data:ed,status:ef,update:eh}=(0,o.useSession)(),eg=(0,a.useRef)(ef);eg.current=ef;let em=(0,a.useRef)(ef),ev=(0,d.usePathname)(),ep="/pricing"===K(ev),ey=(0,d.useRouter)();(0,a.useEffect)(()=>{let e=()=>ey.refresh();return window.addEventListener(f.w3,e),()=>window.removeEventListener(f.w3,e)},[ey]);let ew=(null==ev?void 0:ev.startsWith("/admin/image-migration"))===!0||(null==ev?void 0:ev.startsWith("/admin/partners"))===!0,eb=(0,a.useRef)(ev||void 0);(0,a.useEffect)(()=>{eb.current=ev||void 0},[ev]),(0,a.useEffect)(()=>{U.privateWebSearchEnabled&&ev&&!V.test(K(ev))&&U.setPrivateWebSearchEnabled(!1)},[ev,U,U.privateWebSearchEnabled]),(0,a.useEffect)(()=>{let e=()=>{U.privateWebSearchEnabled&&U.setPrivateWebSearchEnabled(!1)};return window.addEventListener("pagehide",e),()=>window.removeEventListener("pagehide",e)},[U]);let eS=(0,a.useRef)(ep);(0,a.useEffect)(()=>
1{if(eS.current&&!ep)try{M.updateCurrentNanoPrice()}catch(e){}eS.current=ep},[M,ep]);let eE=(0,a.useRef)(null),eI=(0,a.useRef)(0),eC=(0,a.useRef)(null),eR=(0,a.useRef)(0),eT=(0,a.useRef)(0),eD=(0,a.useRef)(0),eA=(0,a.useRef)(0),eP=(0,a.useRef)(null),ek=(0,a.useRef)(null),eM=(0,a.useRef)(null),eU=A||!!P,eL=(()=>{try{var e;let t=new URLSearchParams(window.location.search);if("1"===t.get("debugStoreInit"))return!0;return(null==(e=window.localStorage)?void 0:e.getItem("__ngpt_debug_store_init__"))==="1"}catch(e){return!1}})(),eN=(0,a.useCallback)(function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];if(eL)try{console.log("[StoreInitializer]",...t)}catch(e){}},[eL]),eF=(0,a.useCallback)(async e=>{try{let t=await eh();if(void 0===t)return void eN("".concat(e,": NextAuth update returned undefined"));if(null===t)return eN("".concat(e,": NextAuth update returned null")),null;return eN("".concat(e,": applied refreshed NextAuth session")),k.setAuth(t),t}catch(t){console.error("Failed to refresh NextAuth session (".concat(e,")"),t);return}},[eN,eh,k]),ex=(0,a.useCallback)(()=>{var e,t,r,n;return(e=>[J(e.authUserId),J(e.authClientSession),J(e.sessionId),J(e.sessionUUID)].join("|"))({authUserId:null==k||null==(t=k.auth)||null==(e=t.user)?void 0:e.id,authClientSession:null==k||null==(n=k.auth)||null==(r=n.user)?void 0:r.clientSession,sessionId:null==k?void 0:k.sessionId,sessionUUID:null==k?void 0:k.sessionUUID})},[k]),eO=(0,a.useCallback)(e=>(e=>[e.authSessionMarker,J(e.defaultTeamId)].join("|"))({authSessionMarker:null!=e?e:ex(),defaultTeamId:x.defaultTeamId}),[ex,x]);(0,a.useEffect)(()=>{if(null===eP.current){let e=ex();eP.current=e,ek.current=eO(e)}},[ex,eO]);let eB=(0,a.useCallback)((e,t)=>{try{let r=window;if(null==r?void 0:r.requestIdleCallback){let n=r.requestIdleCallback(()=>{eN("deferWork(".concat(e,"): running")),t()},{timeout:1e3});return eN("deferWork(".concat(e,"): scheduled (requestIdleCallback)")),()=>{try{var e;null==(e=r.cancelIdleCallback)||e.call(r,n)}catch(e){}}}}catch(e){}eN("deferWork(".concat(e,"): scheduled (setTimeout)"));let r=setTimeout(()=>{eN("deferWork(".concat(e,"): running")),t()},0);return()=>{try{clearTimeout(r)}catch(e){}}},[eN]);return(0,a.useEffect)(()=>()=>{null!==D.current&&(clearTimeout(D.current),D.current=null),null!==T.current&&clearTimeout(T.current),((e,t)=>{e.current=!0;try{var r;null==(r=t.current)||r.call(t)}catch(e){}t.current=null})(I,S)},[]),(0,a.useEffect)(()=>{if(!ew)return eB("legacy-runtime-cache-cleanup",()=>{let e=(0,g.jP)(),t="__ngpt_runtime_cache_cleanup_build__";try{if(window.localStorage.getItem(t)===e)return}catch(e){}Promise.resolve().then(r.bind(r,537585)).then(e=>{let{cleanupLegacyRuntimeCaches:t}=e;return t()}).then(r=>{if(0!==r.cachesFailed)return void console.warn("Legacy runtime cache cleanup did not complete cleanly; will retry on next app bootstrap.",r);try{window.localStorage.setItem(t,e)}catch(e){}}).catch(e=>{console.warn("Failed to clean up legacy runtime caches:",e)})})},[eB,ew]),(0,a.useEffect)(()=>{!ew&&(v.current||"/join"===ev?"/join"!==ev&&eU&&el&&eu&&!w.current&&!k.sessionUUID&&(w.current=!0,k.refresh({reason:"store-init-missing-session",force:!0,allowCreateIfMissing:Q(),onSuccess:()=>{L.hydrate()}})):(v.current=!0,U.hydrate().then(async()=>{I.current||es(!0);try{await N.hydrate()}catch(e){console.error("Folders hydrate failed",e)}}).catch(e=>{console.error("Error during UI store hydration or subsequent initializations:",e),I.current||es(!0)})))},[eU,L,N,el,eu,ev,k,ew,U]),(0,a.useEffect)(()=>{if(null!==D.current&&(clearTimeout(D.current),D.current=null),ew)return;let e=em.current;if("loading"===ef){em.current=ef;return}let t=null===eE.current;if("authenticated"===ef&&ed){var r,n,o,a,l;let e=["authenticated",(null==(r=ed.user)?void 0:r.id)||"",(null==(n=ed.user)?void 0:n.clientSession)||""].join(":");if(eE.current===e)return void eN("auth effect: authenticated auth state unchanged; skipping duplicate session/team sync");eE.current=e;let i=(null==(a=k.auth)||null==(o=a.user)?void 0:o.id)?String(k.auth.user.id):null,s=(null==(l=ed.user)?void 0:l.id)?String(ed.user.id):null,u=!!(i&&s&&i!==s);null!==T.current&&(clearTimeout(T.current),T.current=null),(0,j.yK)(s),k.setAuth(ed),eN("auth effect: authenticated; refreshing session before team reload"),C.current=!0,u?x.clearTeamState():x.resetFetchState(),Promise.resolve((t?er:k.refresh)({reason:"auth-se
1ssion-update",force:!0,waitForQueue:!0,allowCreateIfMissing:Q()})).then(async()=>{k.hasAuthSessionMismatch&&(await eF("auth-session-mismatch-repair"),k.hasAuthSessionMismatch&&await k.refresh({reason:"auth-session-mismatch-repair",force:!0,waitForQueue:!0}))}).catch(e=>{console.error("Failed to refresh session after auth change:",e)}).finally(()=>{if(eE.current!==e){C.current=!1;return}x.fetchTeams({force:!0}).catch(e=>{console.error("Failed to fetch teams after auth change:",e)}).finally(()=>{C.current=!1})})}else if("unauthenticated"===ef){if("unauthenticated"===eE.current)return void eN("auth effect: unauthenticated auth state unchanged; skipping duplicate clear");eE.current="unauthenticated";let r=C.current;C.current=!1,eN("auth effect: unauthenticated; resolving cookie-backed local session state");let n=!!k.auth,o="authenticated"===e||n,a=!n&&!1===k.hasLocalSession&&!("string"==typeof k.sessionUUID&&k.sessionUUID.trim().length>0)&&!("number"==typeof k.sessionId&&Number.isFinite(k.sessionId))&&!("number"==typeof k.accountSessionId&&Number.isFinite(k.accountSessionId)),l=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;Promise.resolve((t&&!o&&1===e?er:k.refresh)({reason:"anonymous-init-check",allowCreateIfMissing:Q(),force:!0,waitForQueue:!0})).catch(e=>{eE.current=null,console.error("Failed to resolve anonymous startup session state:",e)}).finally(()=>{!1===k.hasLocalSession||!0===k.initialized||"string"==typeof k.sessionUUID&&k.sessionUUID.trim().length>0||"number"==typeof k.sessionId&&Number.isFinite(k.sessionId)||I.current||"unauthenticated"!==eg.current||(eE.current=null,e>0&&(D.current=setTimeout(()=>{D.current=null,I.current||"unauthenticated"!==eg.current||l(e-1)},1e3)))})};if(void 0!==j.sT.ownerId||j.sT.pending){let e=(0,j.au)(),t=3e3,r=()=>!I.current&&e===j.sT.generation,n=async()=>{if(T.current=null,r())try{var e;let t=await fetch("/api/auth/session",{cache:"no-store",credentials:"same-origin"});if(!t.ok)throw Error("Session ownership check failed");let n=await t.json();if(!r())return;let o=(null==n||null==(e=n.user)?void 0:e.id)?String(n.user.id):null;(0,j.yK)(o)}catch(e){if(!r())return;T.current=setTimeout(()=>{n()},t),t=Math.min(2*t,3e4)}};n()}o?(k.clearSession(),l()):a||l();let s=x.teamsFetched||x.isFetchingTeams||r;x.clearTeamState(),s&&x.fetchTeams({force:!0}).catch(e=>{console.error("Failed to fetch teams after signed-out auth resolution:",e)}),!n&&a&&(0,i.h5)(()=>{k.hasLocalSession=!1})}em.current=ef},[ed,ef,er,k,x,ew,eN,eF]),(0,a.useEffect)(()=>{if(ew||"/join"===ev||!v.current||p.current)return;p.current=!0,console.log("StoreInitializer: Starting account refresh alongside local hydration");let e=!1,t=()=>{e||(e=!0,I.current||ec(!0),console.log("StoreInitializer: Session refresh settled, continuing initialization"),eB("post-session-initialization",()=>{M.initialize({skipCurrentPrice:ep}),C.current||x.teamsFetched||x.isFetchingTeams||x.fetchTeams().catch(e=>{console.error("Failed to fetch teams during initialization:",e)})}))},r=er({reason:"store-init-initial-refresh",force:!0,allowCreateIfMissing:Q(),waitForQueue:!0});r.then(()=>L.hydrate()).catch(e=>{console.warn("StoreInitializer: Consent refresh failed during initialization",e)}),r&&"function"==typeof r.finally?r.catch(e=>{console.warn("StoreInitializer: Session refresh failed during initialization",e)}).finally(()=>{t()}):t()},[L,eB,M,ev,er,k,ew,ep,x]),(0,a.useEffect)(()=>{if(ew)return;let e=()=>{eM.current=Date.now()},t=()=>{try{"hidden"===document.visibilityState&&e()}catch(e){}},n=()=>{e()},o=e=>{var t,n,o,a;eN("pageshow",{persisted:null==e?void 0:e.persisted,pathname:ev});let l=!1;try{let e=null==(n=(o=performance).getEntriesByType)||null==(t=n.call(o,"navigation"))?void 0:t[0];l=(null==e?void 0:e.type)==="back_forward"}catch(e){}if(!e.persisted)return void eN("pageshow: not persisted; skipping restore logic",{isBackForward:l});let s=K(ev),u=V.test(s),c="/media"===s,d=(e=>{let t=K(e);return!!(V.test(t)||q.has(t))||H.some(e=>
1t.startsWith(e))})(s),f=eM.current,g="number"==typeof f?Math.max(0,Date.now()-f):null;eM.current=null;let v="number"==typeof g&&g>=_;if(eN("pageshow: persisted restore",{bfcacheInactiveMs:g,forceTeamFetchForLongRestore:v,isBackForward:l,isConversationRoute:u,isMediaRoute:c,pathname:s,shouldPreferSoftRestore:d}),!d&&!(0,W.Yv)()){try{let e="__ngpt_bfcache_reload__",t=Date.now(),r=Number(sessionStorage.getItem(e)||"0");if(t-r<2e3)return void eN("pageshow: hard reload throttled; skipping",{now:t,last:r});sessionStorage.setItem(e,String(t))}catch(e){}eN("pageshow: performing hard reload"),window.location.reload();return}eN("pageshow: soft restore; deferring heavy restore work"),b.current+=1;let p=b.current;try{null==(a=S.current)||a.call(S)}catch(e){}S.current=eB("pageshow-restore",()=>{if(I.current)return;if(b.current!==p)return void eN("pageshow: deferred restore canceled (newer restore scheduled)",{restoreGen:p,currentGen:b.current});let e=eb.current===ev;e||eN("pageshow: route changed before deferred restore; skipping route-specific init only",{restorePathname:ev,currentPathname:eb.current});let t=(async()=>{var e;let t=!!(null==k||null==(e=k.auth)?void 0:e.user),r=await eF("pageshow-preflight");return null===r&&t&&(eN("pageshow: NextAuth preflight returned null; clearing stale auth + team",{hadAuthenticatedUser:t}),k.setAuth(null),x.clearTeamState()),r})(),n=t.catch(()=>{}).then(()=>{let e=eP.current,t=ex(),r=null!==e&&e!==t;return eP.current=t,eN("pageshow: refreshing local session",{force:r,previousAuthSe
1ssionMarker:e,currentAuthSessionMarker:t}),k.refresh({reason:"pageshow-restore",force:r,freshnessOnly:!r,minIntervalMs:15e3,waitForQueue:!0})});if(e&&!(0,W.Yv)())try{ey.refresh()}catch(e){}let o=e=>{try{var t;e&&"object"==typeof e&&"isHydrated"in e&&(e.isHydrated=!1),null==e||null==(t=e.hydrate)||t.call(e)}catch(e){}};if(e){var a,l;o(N),o(L),o($),o(Z),o(Y),o(ee),o(et),o(X),eN("pageshow: triggered hydrate for critical stores");try{null==(a=$.loadPresets)||a.call($)}catch(e){}try{null==(l=Z.loadPresets)||l.call(Z,{force:!0})}catch(e){}}if(e){if(u){let e=(ev||"").split("/").filter(Boolean)[1],t=e;try{t=e?decodeURIComponent(e):e}catch(e){}if(t&&"new"!==t&&!(0,W.Yv)())eN("pageshow: conversation route; initializing conversation",{slug:t}),F.initialize({slug:t}).catch(e=>{console.error("Failed to initialize conversation on pageshow:",e),(0,B.F)(e)});else if(t&&"new"!==t){let e=()=>{var e,r,n;return!I.current&&b.current===p&&eb.current===ev&&!0===F.initialized&&F.lastInitializedSlug===t&&(null==(e=F.properties)?void 0:e.slug)===t&&!F.isIncognito&&!F.isActiveConversationPasskeyLocked&&!(null==(r=F.state)?void 0:r.isPending)&&!(null==(n=F.state)?void 0:n.isPreparingSubmit)&&!F.isStreaming};if(e()){let r=F.composerVisibleEditVersion,n=F.draftPromptContextVersion,o=ex(),a=()=>e()&&F.composerVisibleEditVersion===r&&F.draftPromptContextVersion===n&&ex()===o,l=!1,s=(0,i.fm)(e=>{a()||(l=!0,e.dispose())});Promise.resolve().then(()=>F.refreshMessages({expectedSlug:t,isStillCurrent:()=>!l&&a()})).catch(e=>{console.error("Failed to refresh draft conversation history on pageshow:",e),(0,B.F)(e)}).finally(s)}}}else if(c){eN("pageshow: media route; initializing media conversation"),Promise.all([r.e(20109),r.e(26334)]).then(r.bind(r,426334)).then(e=>e.initializeMediaConversation(F,(e,t)=>{console.error("Failed ".concat(e," on pageshow:"),t)})).catch(e=>{console.error("Failed to load media initializer on pageshow:",e)});try{window.dispatchEvent(new Event("media-history-updated"))}catch(e){}}}if((async()=>{await Promise.resolve(n).catch(()=>{});let e=ek.current,t=eO(),r=null!==e&&e!==t;ek.current=t,eN("pageshow: session.refresh settled; fetching teams",{force:r||v,forceTeamFetchForLongRestore:v,previousTeamMarker:e,currentTeamMarker:t});try{await x.fetchTeams({force:r||v})}catch(e){console.error("Failed to fetch teams on pageshow:",e)}for(let e=0;e<12&&(x.isFetchingTeams||(await new Promise(e=>setTimeout(e,0)),x.isFetchingTeams));e+=1)await new Promise(e=>setTimeout(e,100));let o=x.defaultTeamId;if(o&&o!==x.selectedTeamId&&x.teams.some(e=>e.id===o))try{x.setSelectedTeam(o)}catch(e){}(()=>{let e=x.selectedTeamId;e&&(x.fetchMemberSelfPrefs(e).catch(e=>{console.error("Failed to fetch member prefs on pageshow:",e)}),x.fetchAllowedModels(e).catch(e=>{console.error("Failed to fetch allowed models on pageshow:",e)}),x.fetchTeamBundle(e).catch(e=>{console.error("Failed to fetch team bundle on pageshow:",e)}))})()})(),!ep)try{M.updateCurrentNanoPrice()}catch(e){}try{M.checkReceivables()}catch(e){}Promise.resolve(n).catch(()=>{}).finally(()=>{(async()=>{let e=await t.catch(()=>{});if(void 0===e)eN("pageshow: NextAuth update failed; continuing restore without changing auth/team");else if(!e)return eN("pageshow: NextAuth update returned null; skipping cloud pulls");let r=(()=>{try{if("undefined"==typeof navigator)return!0;return!1!==navigator.onLine}catch(e){return!0}})();if(r){let e=null==k?void 0:k.storage,t=!!(null==e?void 0:e.syncAllConversations),n=(0,m.A)(e),o=!!((null==e?void 0:e.syncMedia)&&(null==e?void 0:e.syncBucket)),a=en(),i=eo(),l=!t&&(0,h.sD)(a);eN("pageshow: cloud pull gating",{isOnline:r,syncAllConversations:t,syncUserData:n,syncMedia:o,autoRestorePaused:i});let s=async function(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=[];return n&&!i&&r.push({context:{operation:"cloud-sync.memory-pull",domain:"cloud-sync",route:"/api/sync/pull",visibility:"foreground",retryCount:t},fallbackMessage:"Memory could not be refreshed from cloud storage.",run:async()=>{var e;return eN("pageshow: pulling memory from cloud"),null==Y||null==(e=Y.pullMemoryFromCloud)?void 0:e.call(Y,{throwOnError:!0})}}
1),(!i||l)&&r.push({context:{operation:"cloud-sync.user-data-pull",domain:"cloud-sync",route:"/api/sync/pull",visibility:"foreground",retryCount:t},fallbackMessage:"Settings and user data could not be refreshed from cloud storage.",run:async()=>{var e;return eN("pageshow: pulling userData from cloud (allowManualSync)"),null==ee||null==(e=ee.pullUserDataFromCloud)?void 0:e.call(ee,{allowManualSync:!0,bypassManualEligibilityCheck:l,throwOnError:!0})}}),o&&!i&&r.push({context:{operation:"cloud-sync.media-pull",domain:"cloud-sync",route:"/api/sync/pull",visibility:"foreground",retryCount:t},fallbackMessage:"Media history could not be refreshed from cloud storage.",run:async()=>{var e;return eN("pageshow: pulling media from cloud"),null==X||null==(e=X.pullMediaFromCloud)?void 0:e.call(X,{throwOnError:!0})}}),!i&&(null==F||null==(e=F.isCloudRefreshEnabled)?void 0:e.call(F))&&r.push({context:{operation:"cloud-sync.conversation-pull",domain:"cloud-sync",route:"/api/sync/pull",visibility:"foreground",retryCount:t},fallbackMessage:"Conversations could not be refreshed from cloud storage.",run:async()=>{var e;return null==F||null==(e=F.syncAllFromCloudIfEnabled)?void 0:e.call(F,{reason:"store-init:pageshow-check",throwOnError:!0})}}),0===(await O({tasks:r,retryKey:"bfcache-cloud-recovery",retry:()=>s(t+1)})).failures.length};await s()}else eN("pageshow: offline; skipping cloud pulls")})()})})};return window.addEventListener("pagehide",n),document.addEventListener("visibilitychange",t),window.addEventListener("pageshow",o),()=>{window.removeEventListener("pagehide",n),document.removeEventListener("visibilitychange",t),window.removeEventListener("pageshow",o)}},[L,F,eB,eN,N,ex,eO,en,eo,X,Y,M,ev,eF,ey,Z,et,k,ep,ew,$,x,ee]),(0,a.useEffect)(()=>{if(ew)return;let e=e=>{if("hidden"===document.visibilityState)return;let t=Date.now();if("online"===e){let e=eA.current;if(e>0&&t-e<5e3)return;eA.current=t}else{let e=eR.current;if(e>0&&t-e<1500)return;eR.current=t}if(!(()=>{try{if("undefined"==typeof navigator)return!0;return!1!==navigator.onLine}catch(e){return!0}})()&&"online"!==e)return;let r=eD.current;if(0===r||t-r>=15e3){eD.current=t;let r=((e,t,r)=>r&&"number"==typeof e&&Number.isFinite(e)&&t-e>=0&&t-e<6e4)(k.lastRefreshAt,t,!!(k.sessionUUID||k.sessionId));k.refresh({reason:(e=>"visibility"===e?"visibility-balance-check":"focus"===e?"focus-balance-check":"online-balance-check")(e),minIntervalMs:15e3,freshnessOnly:r}).catch(t=>{console.error("Failed to refresh balance on ".concat(e,":"),t)})}(e=>{if(x.teamsFetched||x.isFetchingTeams)return;let t=Date.now(),r=eI.current;r>0&&t-r<15e3||(eI.current=t,x.fetchTeams().catch(t=>{console.error("Failed to fetch teams on ".concat(e,":"),t)}))})(e),(e=>{let t=x.selectedTeamId;if(!t||x.memberPrefsFetchedForTeamId===t)return;let r=Date.now(),n=eC.current;n&&n.teamId===t&&n.at>0&&r-n.at<15e3||(eC.current={teamId:t,at:r},x.fetchMemberSelfPrefs(t).catch(t=>{console.error("Failed to fetch member prefs on ".concat(e,":"),t)}))})(e);let n=eT.current;if(!("online"===e||0===n||t-n>=3e4))return;eT.current=t;let o=(e=>"visibility"===e?"store-init:visibility-check":"focus"===e?"store-init:focus-check":"store-init:online-check")(e);if(!ep)try{M.updateCurrentNanoPrice()}catch(e){}let a=async function(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=[];return!eo()&&(null==F||null==(e=F.isCloudRefreshEnabled)?void 0:e.call(F))&&r.push({context:{operation:"cloud-sync.conversation-pull",domain:"cloud-sync",route:"/api/sync/pull",visibility:"foreground",retryCount:t},fallbackMessage:"Conversations could not be refreshed from cloud storage.",run:async()=>{var e;return null==F||null==(e=F.syncAllFromCloudIfEnabled)?void 0:e.call(F,{reason:o,throwOnError:!0})}}),r.push({context:{operation:"cloud-sync.media-pull",domain:"cloud-sync",route:"/api/sync/pull",visibility:"foreground",retryCount:t},fallbackMessage:"Media history could not be scheduled for refresh.",run:()=>{var e;return null==X||null==(e=X.requestForegroundPull)?void 0:e.call(X,{reason:o})}}
1),0===(await O({tasks:r,retryKey:"foreground-resume-cloud-recovery",retry:()=>a(t+1)})).failures.length};a()},t=()=>{"visible"===document.visibilityState&&e("visibility")};document.addEventListener("visibilitychange",t,!1);let r=()=>{e("focus")};window.addEventListener("focus",r,!1);let n=()=>{e("online")};return window.addEventListener("online",n,!1),()=>{document.removeEventListener("visibilitychange",t,!1),window.removeEventListener("focus",r,!1),window.removeEventListener("online",n,!1)}},[k,M,F,x,X,ew,ep,eo]),(0,a.useEffect)(()=>{if(ew)return;let e=null,t=null,r=()=>{try{var e;null==F||null==(e=F.relockPasskeyProtectedConversations)||e.call(F)}catch(e){console.error("Failed to relock passkey-protected conversations")}},n=()=>{null!==t&&(clearTimeout(t),t=null)},o=()=>{null===e&&(e=Date.now()),n(),t=setTimeout(()=>{t=null,null!==e&&("hidden"===document.visibilityState||!document.hasFocus())&&Date.now()-e>=c.eL&&r()},c.eL+1e3)},a=()=>{null!==e&&Date.now()-e>=c.eL&&r(),e=null,n()},i=()=>o(),l=()=>a(),s=()=>{"hidden"===document.visibilityState?o():document.hasFocus()&&a()};return document.addEventListener("visibilitychange",s,!1),window.addEventListener("blur",i,!1),window.addEventListener("focus",l,!1),window.addEventListener("pagehide",i,!1),window.addEventListener("pageshow",l,!1),()=>{document.removeEventListener("visibilitychange",s,!1),window.removeEventListener("blur",i,!1),window.removeEventListener("focus",l,!1),window.removeEventListener("pagehide",i,!1),window.removeEventListener("pageshow",l,!1),n()}},[F,ew]),(0,a.useEffect)(()=>{ew||k.loadLocalImage()},[k,ew]),(0,a.useEffect)(()=>{if(ew)return;let e="post_login_refresh",t=!!document.cookie.split(";").map(e=>e.trim()).find(t=>t.startsWith("".concat(e,"="))),r=()=>{try{document.cookie="".concat(e,"=; Max-Age=0; path=/")}catch(e){console.error("Failed to clear post-login refresh cookie",e)}},n=sessionStorage.getItem("postLoginRefresh");if(!(t||n)||E.current)return;E.current=!0;let o=(async()=>{if(void 0===await eF("post-login-refresh"))throw Error("NextAuth post-login refresh failed");if(await k.refresh({reason:"post-login-refresh",force:!0,waitForQueue:!0}),k.hasAuthSessionMismatch){if(void 0===await eF("post-login-mismatch-repair"))throw Error("NextAuth post-login mismatch repair failed");k.hasAuthSessionMismatch&&await k.refresh({reason:"post-login-mismatch-repair",force:!0,waitForQueue:!0})}if(!eo()){let e=null==k?void 0:k.storage,t=(0,m.A)(e),r=(null==e?void 0:e.syncMedia)===!0&&(null==e?void 0:e.syncBucket),[n,o]=await Promise.all([t?G("user data",()=>(null==ee?void 0:ee.isHydrated)===!0):Promise.resolve(!1),r?G("media",()=>(null==X?void 0:X.isHydrated)===!0):Promise.resolve(!1)]);if(I.current||eo())return;let a=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,i=null==k?void 0:k.storage,l=[];return t&&n&&(0,m.A)(i)&&l.push({context:{operation:"cloud-sync.user-data-pull",domain:"cloud-sync",route:"/api/sync/pull",visibility:"foreground",retryCount:e},fallbackMessage:"Settings and user data could not be refreshed after sign-in.",run:async()=>{var e;return null==ee||null==(e=ee.pullUserDataFromCloud)?void 0:e.call(ee,{allowManualSync:!0,throwOnError:!0})}}),r&&o&&(null==i?void 0:i.syncMedia)===!0&&(null==i?void 0:i.syncBucket)&&l.push({context:{operation:"cloud-sync.media-pull",domain:"cloud-sync",route:"/api/sync/pull",visibility:"foreground",retryCount:e},fallbackMessage:"Media history could not be refreshed after sign-in.",run:async()=>{var e;return null==X||null==(e=X.pullMediaFromCloud)?void 0:e.call(X,{throwOnError:!0})}}),0===(await O({tasks:l,retryKey:"post-login-cloud-recovery",retry:()=>a(e+1)})).failures.length};await a()}})();o&&"function"==typeof o.then?o.then(()=>{n&&sessionStorage.removeItem("postLoginRefresh"),t&&r()}).catch(e=>{console.error("Post-login refresh failed, will retry on next load:",e)}).finally(()=>{E.current=!1}):(E.current=!1,n&&sessionStorage.removeItem("postLoginRefresh"),t&&r())},[k,ew,eF,eo,ee,X]),(0,a.useEffect)(()=>{var e;if(!k.initialized||!k.sessionUUID)return;let t=(0,h.C9)({sessionUUID:k.sessionUUID,accountSessionId:k.accountSessionId});if((0,h.$x)(t)){if(!((0,m.A)(k.storage)||(null==(e=k.storage)?void 0:e.syncMedia)===!0))return void(0,h.fW)();ei(!0)}},[k.accountSessionId,k.initialized,k.sessionUUID,k.storage,null==(e=k.storage)?void 0:e.syncAllConversations,null==(t=k.storage)?void 0:t.syncUserData,null==(s=k.storage)?void 0:s.syncMedia]),ea?(0,n.jsx)(R,{opened:ea,onClose:()=>{ei(!1)}}):null})},163088:(e,t,r)=>{r.d(t,{D_:()=>i,Dp:()=>g,JP:()=>c,PI:()=>p,Q:()=>o,Uk:()=>u,b1:()=>h,dm:()=>a,eZ:()=>v,fX:()=>f,iD:()=>m,px:()=>d,sE:()=>l,sT:()=>n,x8:()=>s});var n=function(e){return e.active="active",e.permanent="permanent",e.redeemed="redeemed",e.expired="expired",e.blocked="blocked",e}({}),o=function(e){return e.invitation="invitation",e.referralLink="referralLink",e}({}),a=function(e){return e.InvalidAmount="Invalid amount",e.InsufficientBalance="Insufficient balance",e.InvalidExpiresAt="Invalid expiry date",e.InviteNotFound="Invite not found",e.InviteRedeemed="Invite already redeemed",e.InviteExpired="Invite expired",e.InviteBlocked="Invite blocked",e.NoAmountToRedeem="No amount to redeem",e.CurrencyNotSpecified="Currency must be specified",e.CurrencyNotUpdateable="The currency of an invitation cannot be changed after creation.",e.MutualReferralNotAllowed="Mutual referrals are not allowed",e}({}),i=function(e){return e.DEPOSIT="DEPOSIT",e.WITHDRAWAL="WITHDRAWAL",e.TRANSFER="TRANSFER",e.SUBSCRIPTION="SUBSCRIPTION",e.REFERRER_CREDIT="REFERRER_CREDIT",e}({}),l=function(e){return e.API="API",e.WEB="WEB",e.UNKNOWN="UNKNOWN",e}({}),s=function(e){return e.PENDING="PENDING",e.PROCESSING="PROCESSING",e.PAID="PAID",e.UNPAID="UNPAID",e.COMPLETED="COMPLETED",e.FAILED="FAILED",e.EXPIRED="EXPIRED",e.WITHHELD="WITHHELD",e}({}),u=function(e){return e.XNO="XNO",e.BCH="BCH",e.ETH="ETH",e.BASE="BASE",e.AVAX="AVAX",e.ATOM="ATOM",e.SOL="SOL",e.XMR="XMR",e.LTC="LTC",e["LTC-MWEB"]="LTC-MWEB",e.DASH="DASH",e.BTC="BTC",e["BTC-LN"]="BTC-LN",e.DOGE="DOGE",e.USDC="USDC",e.USDT="USDT",e.PYUSD="PYUSD",e.EURR="EURR",e.TRX="TRX",e.XRP="XRP",e.BNB="BNB",e.VERSE="VERSE",e.ARBITRUM="ARBITRUM",e.POLYGON="POLYGON",e.MATIC="MATIC",e.KAS="KAS",e.EGL
1D="EGLD",e.ZEC="ZEC",e.TON="TON",e.NEAR="NEAR",e.ZANO="ZANO",e.FUSD="FUSD",e.VVV="VVV",e}({}),c=function(e){return e.USD="$",e.XNO="Ӿ",e.BCH="Ƀ",e.SOL="◎",e.XMR="ɱ",e.LTC="Ł",e["LTC-MWEB"]="Ł",e.DASH="\xd0",e.BTC="₿",e["BTC-LN"]="sats",e.DOGE="\xd0",e.USDC="$",e.TRX="TRX",e.XRP="XRP",e.BNB="BNB",e.USDT="$",e.PYUSD="$",e.EURR="€",e.AVAX="AVAX",e.ATOM="ATOM",e.ETH="Ξ",e.ZEC="ⓩ",e.TON="\uD83D\uDC8E",e.VERSE="",e.KAS="K",e.EGLD="⚡",e.NEAR="Ⓝ",e.EUR="€",e.GBP="\xa3",e.ZANO="ZANO",e.FUSD="$",e.VVV="VVV",e}({}),d=function(e){return e.USD="USD",e.EUR="EUR",e.GBP="GBP",e}({});let f={AZURE:"azure",DALLE:"dalle",NOVITA:"novita",STABLECOG:"stablecog",DOUBAO:"doubao",REPLICATE:"replicate",FAL:"fal",GOOGLE:"google",CHUTES:"chutes",OPENAI:"openai",ARLI:"arli",RUNWARE:"runware",HIGGSFIELD:"higgsfield",WAVESPEED:"wavespeed",ZAI:"zai",STEPFUN:"stepfun"};var h=function(e){return e.CAKE="cake",e.MAIN="main",e.BITCOINCOM="bitcoincom",e.BCASHGPT="bcashgpt",e}({}),g=function(e){return e.chat="chat",e.translate="translate",e.image="image",e.video="video",e.model3d="model3d",e.audio="audio",e.voice="voice",e}({});let m=e=>"chat"===e||"translate"===e;var v=function(e){return e.basic="basic",e.standard="standard",e.premium="premium",e}({}),p=function(e){return e.NOT_REQUIRED="not_required",e.PENDING="pending",e.GRANTED="granted",e.DENIED="denied",e.EXPIRED="expired",e.WITHDRAWN="withdrawn",e}({})},189852:(e,t,r)=>{r.d(t,{Vo:()=>a});let n=new Map,o=function(e,t){var r;let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return{operation:t.operation,domain:t.domain,route:t.route,errorClass:e.class,status:e.status,retryCount:"number"!=typeof(r=t.retryCount)||!Number.isFinite(r)||r<0?0:Math.min(20,Math.floor(r)),requestId:e.requestId,correlationId:e.correlationId,visibility:t.visibility,occurrenceCount:Math.max(1,Math.min(100,Math.floor(n)))}},a=async(e,t)=>{if("cancelled"===e.class)return"cancelled";let r=1;if("background"===t.visibility){let a=(e=>{var t;return[e.operation,e.domain,e.route,e.errorClass,null!=(t=e.status)?t:"network"].join("|")})(o(e,t)),i=Date.now(),l=n.get(a);if(l&&i-l.reportedAt<6e4)return l.suppressed+=1,"coalesced";r+=(null==l?void 0:l.suppressed)||0,n.set(a,{reportedAt:i,suppressed:0})}let a=o(e,t,r);try{await fetch("/api/client-operation-failure",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a),keepalive:!0})}catch(e){}return"reported"}},234826:(e,t,r)=>{r.d(t,{H:()=>a});var n=r(163088);let o=e=>!!(e.videoGenerationId&&("pending"===e.videoStatus||"processing"===e.videoStatus)),a=e=>{let{mode:t,isPending:r,messages:a}=e;return!!r&&(t===n.Dp.image||t===n.Dp.video)||a.some(o)}},296949:(e,t,r)=>{r.d(t,{G:()=>h,J:()=>g});var n=r(684998);let o=["x-request-id","x-vercel-id","traceparent"],a=/^[a-zA-Z0-9_.:-]{1,128}$/,i=/[\u0000-\u001f\u007f]/,l=()=>{try{var e,t;return(null==(t=globalThis.crypto)||null==(e=t.randomUUID)?void 0:e.call(t))||"op-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2))}catch(e){return"op-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2))}},s=e=>{if("string"!=typeof e)return null;let t=e.trim();return a.test(t)?t:null},u=e=>!e||"object"!=typeof e||Array.isArray(e)?null:e,c=e=>u(null==e?void 0:e.error)||e,d=e=>401===e?"authentication":403===e?"authorization":409===e?"conflict":400===e||422===e?"validation":408===e||425===e||429===e||e>=500?"transient":"domain",f=(e,t)=>"authentication"===e?"Your session expired. Sign in again to continue.":"authorization"===e?"You do not have permission to complete this action.":"transient"===e?"The service is temporarily unavailable. Please try again.":"cancelled"===e?"":t,h=e=>{let t=e.correlationId||l();if((e=>!!e&&"object"==typeof e&&"AbortError"===e.name)(e.error))return{class:"cancelled",status:null,code:null,retryable:!1,userMessage:"",requestId:null,correlationId:t};let r=(e=>{var t;if(!e||"object"!=typeof e)return null;for(let r of[e.status,e.statusCode,null==(t=e.response)?void 0:t.status])if("number"==typeof r&&Number.isFinite(r))return r;return null})(e.error),n=null!==r?d(r):e.error instanceof TypeError?"transient":"unexpected";return{class:n,status:r,code:null,retryable:"transient"===n,userMessage:f(n,e.fallbackMessage),requestId:null,correlationId:t}},g=async e=>{var t,r;let a=l(),g=new Headers(null==(t=e.init)?void 0:t.headers);g.set("X-NanoGPT-Operation-Id",a);try{let t=await fetch(e.route,{...e.init,headers:g}),l=(e=>{for(let t of o){let r=s(e.headers.get(t));if(r)return r}return null})(t),h=null;try{h=await t.json()}catch(e){}if(t.ok)try{let t=e.parse?e.parse(h):h;return{ok:!0,data:t,requestId:l,correlationId:a}}catch(r){return{ok:!1,error:{class:"unexpected",status:t.status,code:null,retryable:!1,userMessage:e.fallbackMessage,requestId:l,correlationId:a}}}let m=u(h),v=c(m),p=d(t.status),y="boolean"==typeof(null==v?void 0:v.retryable)?v.retryable:null;
1return{ok:!1,error:{class:p,status:t.status,code:s(null!=(r=null==v?void 0:v.code)?r:null==m?void 0:m.code),retryable:null!=y?y:"transient"===p,userMessage:((e,t)=>{if(400!==t&&409!==t&&422!==t)return null;let r=c(e);if((null==r?void 0:r.code)==="unknown_fields")return"The request contains unsupported fields.";let o="string"==typeof(null==r?void 0:r.message)?r.message:"string"==typeof(null==e?void 0:e.error)?e.error:null;if(!o)return null;let a=o.trim().replace(/\s+/g," ");return!a||a.length>240||i.test(a)?null:(0,n.cp)(a,"")||null})(m,t.status)||f(p,e.fallbackMessage),requestId:l,correlationId:a}}}catch(t){return{ok:!1,error:h({error:t,correlationId:a,fallbackMessage:e.fallbackMessage})}}}},316281:(e,t,r)=>{r.d(t,{StoreProvider:()=>i});var n=r(695155),o=r(212115),a=r(808185);function i(e){let{children:t,hydrationData:r}=e;return(0,o.useEffect)(()=>{r&&a.rootStore.hydrate(r)},[r]),(0,n.jsx)(a.storeContext.Provider,{value:a.rootStore,children:t})}},393911:(e,t,r)=>{r.d(t,{RW:()=>g,VP:()=>i,a4:()=>h,eD:()=>a,eL:()=>f,uE:()=>d});var n=r(212115),o=r(399898);function a(e,t){return t.isUsingTeamBalance&&!0===t.selectedTeamZdrOnly?"team":"zdr"===e.zdr_policy?"account":!0!==e.initialized||!t.teamsFetched||t.isUsingTeamBalance&&null===t.selectedTeamZdrOnly?"pending":null}function i(e,t){let r=!(arguments.length>2)||void 0===arguments[2]||arguments[2],o=t.selectedTeamId,i=t.isUsingTeamBalance;return(0,n.useEffect)(()=>{if(!r||!i||!o)return;let e=()=>{"hidden"!==document.visibilityState&&t.fetchTeamDetails(o).catch(()=>{})};e();let n=window.setInterval(e,6e4);return document.addEventListener("visibilitychange",e),window.addEventListener("focus",e),()=>{window.clearInterval(n),document.removeEventListener("visibilitychange",e),window.removeEventListener("focus",e)}},[r,t,o,i]),a(e,t)}let l=null,s=!1,u=()=>{if(null===l){let e="undefined"!=typeof performance?Date.now()-performance.now():Date.now();l=s?Date.now():e}return l},c=()=>{l=null,s=!0};function d(e){"pending"===e?u():c()}function f(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5e3,r="pending"===e,[o,a]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{if(!r){c(),a(!1);return}let e=u()+t-Date.now();if(e<=0)return void a(!0);a(!1);let n=window.setTimeout(()=>a(!0),e);return()=>window.clearTimeout(n)},[r,t]),r&&o}function h(e,t,r){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:()=>window.location.reload(),[a,i]=(0,n.useState)("idle"),l="pending"===e;return(0,n.useEffect)(()=>{l||i("idle")},[l]),(0,n.useEffect)(()=>{if("retrying"!==a)return;let e=window.setTimeout(()=>i("reload"),4e3);return()=>window.clearTimeout(e)},[a]),{onRetry:()=>{if("retrying"!==a){if("reload"===a)return void o();i("retrying"),r.teamsFetched||(r.isFetchingTeams&&r.resetFetchState(),r.fetchTeams({force:!0}).catch(()=>{})),r.isUsingTeamBalance&&null===r.selectedTeamZdrOnly&&r.selectedTeamId&&r.fetchTeamDetails(r.selectedTeamId,{force:!0}).catch(()=>{}),!0!==t.initialized&&Promise.resolve(t.refresh({reason:"zdr-policy-retry",force:!0})).catch(()=>{})}},retrying:"retrying"===a,label:"reload"===a?"Reload page":"Retry"}}function g(e){let[t,r]=(0,n.useState)(null),[a,i]=(0,n.useState)(!1),[l,s]=(0,n.useState)(0);return(0,o.e)(JSON.stringify([e,l]),()=>{r(null),i(!1)}),(0,n.useEffect)(()=>{if(!e)return;let t=new AbortController;return(async()=>{try{let e=await fetch("/api/explore/zdr-models",{signal:t.signal});if(!e.ok)throw Error("Unable to load ZDR models");let n=await e.json();if(!Array.isArray(n.modelIds)||!n.modelIds.every(e=>"string"==typeof e))throw Error("Invalid ZDR model list");t.signal.aborted||r(new Set(n.modelIds))}catch(e){t.signal.aborted||(r(null),i(!0))}})(),()=>t.abort()},[e,l]),{modelIds:t,error:a,retry:()=>s(e=>e+1)}}},399898:(e,t,r)=>{r.d(t,{e:()=>o});var n=r(212115);function o(e,t){let[r,o]=(0,n.useState)(e);Object.is(r,e)||(o(e),t())}},731458:(e,t,r)=>{r.d(t,{KB:()=>s,Ms:()=>o,ci:()=>l,ju:()=>u});var n=r(234826);function o(e){var t,r,o,a,i;if(e.isSavingIncognitoConversation)return"This incognito chat is still being saved. Leaving now may interrupt the save and lose the chat.\n\nLeave anyway?";let l=!!(e.state.isPending||e.state.isPreparingSubmit||e.state.isConsensusStreaming||e.isStreaming||e.isGeneratingAlternative||e.continuationSubmitting||(0,n.H)({mode:e.mode,isPending:!1,messages:e.messages})),s=e.isIncognito&&!!(l||e.messages.length||e.pendingMessage||e.prompt||e.visibleComposerPrompt||(null==(t=e.attachments)?void 0:t.length)||(null==(r=e.scrapedUrls)?void 0:r.length)||(null==(o=e.scrapedContent)?void 0:o.length)||(null==(a=e.queuedMessages)?void 0:a.length)||(null==(i=e.voiceMessages)?void 0:i.length));return l||s?[...l?["A response is still generating. Leaving may interrupt it or lose the result. Usage already incurred may still be charged."]:[],...s?["This incognito chat is not saved. Leaving or starting another chat can permanently clear its messages and attachments."]:[],"Leave anyway?"].join("\n\n"):null}let a=new WeakMap,i=new WeakSet;function l(e,t){let r=i.has(e);i.add(e);try{t()}finally{r||i.delete(e)}}function s(e,t){if(i.has(e)||!t)return!0;let r=a.get(e);if((null==r?void 0:r.confirmed)||(null==r?void 0:r.warning)===t)return r.confirmed;let n={warning:t,confirmed:window.confirm(t)};return a.set(e,n),setTimeout(()=>{a.get(e)===n&&a.delete(e)},0),n.confirmed}function u(e){var t;return i.has(e)||(null==(t=a.get(e))?void 0:t.confirmed)===!0}},763781:(e,t,r)=>{r.d(t,{Iu:()=>f,Rk:()=>s,Sn:()=>n,T9:()=>a,Xn:()=>i,gK:()=>l,p0:()=>d,qS:()=>u,wl:()=>c});let n=e=>"/chat"===e||(null==e?void 0:e.startsWith("/chat/"))===!0,o=e=>"/conversation"===e||(null==e?void 0:e.startsWith("/conversation/"))===!0,a=e=>"/chat"===e||"/chat/new"===e||"/conversation"===e||"/conversation/ne
1w"===e,i=e=>n(e)||o(e)||"/voice"===e||(null==e?void 0:e.startsWith("/voice/"))===!0,l=(e,t)=>t?"chat"===t?"/chat":"/conversation/new":n(e)?"/chat":(o(e),"/conversation/new"),s=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"classic",r=arguments.length>2?arguments[2]:void 0;return"/".concat(2===r?"chat":1===r?"conversation":"chat"===t?"chat":"conversation","/").concat(encodeURIComponent(e))},u=e=>{let{pathname:t,previousSlug:r,nextSlug:n}=e;if(!t||!r||!n||r===n)return null;let o=encodeURIComponent(r),a=encodeURIComponent(n);return t==="/chat/".concat(o)?"/chat/".concat(a):t==="/conversation/".concat(o)?"/conversation/".concat(a):null},c=e=>n(e)?"/chat":o(e)?"/conversation/new":null,d=(e,t,r)=>"voice"===t?"/voice":"chat"===t?l(e,r):"/conversation/new?mode=".concat(encodeURIComponent(t)),f=e=>{let{pathname:t,isV2Conversation:r,intelligentWebSearchEnabled:o}=e,a=n(t);return{isChatSurface:a,useV2ChatAdapter:a&&r,intelligentWebSearchEnabled:a&&o}}},818801:(e,t,r)=>{function n(e){let t="number"==typeof e.cloudSyncTotal&&Number.isFinite(e.cloudSyncTotal)?Math.max(0,Math.floor(e.cloudSyncTotal)):0,r="number"==typeof e.cloudSyncDone&&Number.isFinite(e.cloudSyncDone)?Math.max(0,Math.floor(e.cloudSyncDone)):0,n=t>0?Math.min(r,t):r,o=t>0?Math.min(100,Math.round(n/t*100)):0;return{done:n,total:t,percentage:o}}function o(e,t){let{idleMessage:r="Pulling conversations, media, settings, and memory...",preparingMessage:o="Preparing conversation import...",completedMessage:a="Conversations imported. Restoring remaining cloud data..."}=t||{},i=!0===e.cloudSyncRunning,{done:l,total:s,percentage:u}=n(e);return i&&s>0?"Decrypting and importing conversations... ".concat(l," of ").concat(s," (").concat(u,"%)"):i?o:s>0&&l>=s?a:r}r.d(t,{U:()=>o,d:()=>n})},844009:(e,t,r)=>{r.d(t,{default:()=>a});var n=r(695155),o=r(837882);function a(e){let{children:t}=e;return(0,n.jsx)(o.SessionProvider,{refetchOnWindowFocus:!1,children:t})}}}]);

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.