@openchambery/web 1.18.4-beta.3 → 1.18.4-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/assets/{AssistantView-dp-Ffv4m.js → AssistantView-epTdbN5j.js} +1 -1
  2. package/dist/assets/{ChatContainer-DDnVzDEm.js → ChatContainer-CgtAWWrX.js} +7 -7
  3. package/dist/assets/{DiagramView-B8wbKkCc.js → DiagramView-ULI73qc-.js} +1 -1
  4. package/dist/assets/{MarkdownRendererImpl-5pG4R3MC.js → MarkdownRendererImpl-uWHU7Rym.js} +1 -1
  5. package/dist/assets/{MobileDetailNavigation-Clxl7A1c.js → MobileDetailNavigation-Cy4ty1yY.js} +1 -1
  6. package/dist/assets/{MobileShareBridge-CzL_qql3.js → MobileShareBridge-DzHJ1UIg.js} +1 -1
  7. package/dist/assets/{MobileSurface-BcEhI0za.js → MobileSurface-CifcK_VS.js} +1 -1
  8. package/dist/assets/{MultiRunWindow-DGCwZYux.js → MultiRunWindow-CHvMEEgJ.js} +1 -1
  9. package/dist/assets/{OnboardingScreen-C1n_wVb-.js → OnboardingScreen-BN4L1hqu.js} +1 -1
  10. package/dist/assets/{SettingsView-Cn-1NGfr.js → SettingsView-Cs57SEuc.js} +1 -1
  11. package/dist/assets/{SettingsWindow-CPjytuX6.js → SettingsWindow-DbyP7rYq.js} +1 -1
  12. package/dist/assets/{TerminalView-CXbbSGpU.js → TerminalView-CgK-kbfK.js} +1 -1
  13. package/dist/assets/{ToolOutputDialog-BWtMR2ct.js → ToolOutputDialog-ChljB1CN.js} +1 -1
  14. package/dist/assets/{appThemeRegistry-BfC78Ze-.js → appThemeRegistry-Ii1BsWpN.js} +2 -2
  15. package/dist/assets/{button-BQY5ugjh.js → button-KTZJ84Mx.js} +1 -1
  16. package/dist/assets/{context-menu-E7GOhSf7.js → context-menu-CPREQT2S.js} +1 -1
  17. package/dist/assets/{gitApi-Dc8B6EYC.js → gitApi-hpklqU10.js} +1 -1
  18. package/dist/assets/{insertionBoundaries-C7yNiWO-.js → insertionBoundaries-BNfO7xim.js} +1 -1
  19. package/dist/assets/{main-D6MgGFxh.js → main-Bog_9j7q.js} +4 -4
  20. package/dist/assets/{main-D9qBzZpU.js → main-hWnOf28D.js} +2 -2
  21. package/dist/assets/{miniChat-B7g3gXRa.js → miniChat-D_XI2D45.js} +2 -2
  22. package/dist/assets/{mobile-I5gQEcaR.js → mobile-DoZizfm3.js} +2 -2
  23. package/dist/assets/{multirun-CvzAwx9Z.js → multirun-B9Fz0sR2.js} +1 -1
  24. package/dist/assets/{projectMeta-A8_j9NDY.js → projectMeta-Dgoh4hEg.js} +1 -1
  25. package/dist/assets/radio-EJi50i5B.js +1 -0
  26. package/dist/assets/{renderElectronMiniChatApp-CKHAdXda.js → renderElectronMiniChatApp-B7bg9CG2.js} +2 -2
  27. package/dist/assets/{renderMobileApp-z5FQQ0YS.js → renderMobileApp-DTgy4Ew9.js} +4 -4
  28. package/dist/assets/{runtimeConfig-CTI932Qg.js → runtimeConfig-CfCsNs7j.js} +1 -1
  29. package/dist/assets/{runtimeEndpointReset-CLXx9Rkb.js → runtimeEndpointReset-B69CvGxR.js} +1 -1
  30. package/dist/assets/{src-DF4hiLrB.css → src-CV_a1GoP.css} +1 -1
  31. package/dist/assets/{useAppFontEffects-DcBn8EaV.js → useAppFontEffects-RMk6ydUI.js} +2 -2
  32. package/dist/assets/{useDesktopWindowControlsLayout-DQ35ZeYs.js → useDesktopWindowControlsLayout-DdYFPvMA.js} +1 -1
  33. package/dist/assets/{useEffectiveDirectory-BBtnDd-j.js → useEffectiveDirectory-CPIfG0kt.js} +1 -1
  34. package/dist/assets/{useMobileNavigationStore-DtVJ24rj.js → useMobileNavigationStore-BULVe95f.js} +1 -1
  35. package/dist/assets/{useSessionAutoCleanup-Da2QnnIs.js → useSessionAutoCleanup-BC1Ok7X-.js} +1 -1
  36. package/dist/assets/{useWorkerHighlightedLines-Dv-hd_Ks.js → useWorkerHighlightedLines-C7q5oiKH.js} +1 -1
  37. package/dist/index.html +3 -3
  38. package/dist/mini-chat.html +3 -3
  39. package/dist/mobile.html +3 -3
  40. package/package.json +1 -1
  41. package/dist/assets/radio-DPw90a6Z.js +0 -1
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{M as t,t as n}from"./useUIStore-BJpkPwky.js";import{Kt as r,kn as i,qt as a,u as o}from"./persistence-DwXJK4-j.js";import{h as s}from"./desktopHosts-aA40MHzB.js";import{a as c,i as l,o as u,r as d}from"./desktopRelayRestore-CxUYRC6v.js";import{nt as f,rt as p}from"./vendor-base-ui-CnHfUmDN.js";import{Nt as m}from"./platform-CXJwZIZe.js";import{n as h}from"./vendor-react-DLPElpoQ.js";import{n as g}from"./vendor-tanstack-query-core-BWz0ose6.js";import{i as _,r as v}from"./vendor-tanstack-react-query-D7pys_c9.js";import{n as y,t as b}from"./clipboard-BvJ7NunE.js";import{i as ee,t as te}from"./store-BuXogmxp.js";import{fr as ne,hr as x,l as re,oa as S,or as C,vr as ie}from"./useMobileNavigationStore-DtVJ24rj.js";import{t as w}from"./utils-DfPDhqys.js";import{n as T}from"./Icon-BhSwbLaF.js";import{t as E}from"./button-BQY5ugjh.js";import{i as ae,n as oe,r as se,t as ce}from"./vendor-simplewebauthn-browser-Dwhcdg_5.js";import{n as le,r as ue}from"./radio-DPw90a6Z.js";var D=h(),O=[`desktopHostSwitch`],k=class extends Error{result;host;constructor(e,t){super(e.reason),this.name=`DesktopHostSwitchError`,this.result=e,this.host=t}},de=(e,t)=>te(ee.getState().dictionary,e,t),fe=async e=>{let{host:n}=e;if(n.id===`local`){let r=(e.localApiOrigin||``).trim();if(!r)throw new k({ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unreachable`},n);return t({apiBaseUrl:r,clientToken:e.localClientToken||null,runtimeKey:l(n)}),{ok:!0,via:`direct`,status:{status:`ok`,latencyMs:0}}}if(n.viaSshRelay){let e=await u(n);if(!e.ok)throw new k(e,n);return e}let r=await c(n,{cachedProbe:e.cachedProbe});if(!r.ok)throw new k(r,n);return r},A=null,pe=()=>A||(A=new g(o,{mutationKey:O,mutationFn:fe,onError:(e,t)=>{e instanceof k&&e.result.reason!==`unsupported`&&ie.error(de(`desktopHostSwitcher.toast.instanceUnreachable`,{host:s(t.host.label)}))}}),A.subscribe(()=>void 0),A),me=async e=>{if(d(e.host))return{ok:!0,via:`direct`,status:e.cachedProbe?.status===`ok`?e.cachedProbe:{status:`ok`,latencyMs:0}};if(o.isMutating({mutationKey:O})>0)return{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unsupported`};try{return await pe().mutate(e)}catch(e){if(e instanceof k)return e.result;throw e}},he=()=>{let e=(0,D.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={mutationKey:O},e[0]=t):t=e[0],v(t)>0},ge=()=>{let e=(0,D.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={filters:{mutationKey:O,status:`pending`},select:_e},e[0]=t):t=e[0],_(t)[0]?.host.id??null};function _e(e){return e.state.variables}var j=e=>typeof e==`object`&&!!e,M=(e,t)=>{let n=e[t];return typeof n==`string`?n:null},N=(e,t)=>{let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:null},P=(e,t)=>{let n=e[t];return typeof n==`boolean`?n:null},F=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],I=()=>r()?(e,t)=>a(e,t):null,L=e=>{if(!j(e))return;let t=P(e,`enabled`)??!1,n=M(e,`store`)?.toLowerCase()===`settings`?`settings`:`never`,r=M(e,`value`);return{enabled:t,store:n,...r?{value:r}:{}}},ve=e=>e===`remote`||e===`dynamic`?e:`local`,ye=e=>{if(!j(e))return null;let t=M(e,`id`);if(!t)return null;let n=P(e,`enabled`)??!0,r=ve(M(e,`type`)),i=M(e,`localHost`)||M(e,`local_host`)||void 0,a=N(e,`localPort`)??N(e,`local_port`)??void 0,o=M(e,`remoteHost`)||M(e,`remote_host`)||void 0,s=N(e,`remotePort`)??N(e,`remote_port`)??void 0;return{id:t,enabled:n,type:r,...i?{localHost:i}:{},...typeof a==`number`?{localPort:a}:{},...o?{remoteHost:o}:{},...typeof s==`number`?{remotePort:s}:{}}},be=e=>{if(!j(e))return null;let t=M(e,`id`),n=M(e,`sshCommand`)||M(e,`ssh_command`);if(!t||!n)return null;let r=M(e,`nickname`),i=e.sshParsed,a=j(i)?{destination:M(i,`destination`)||``,args:F(i.args)}:void 0,o=j(e.remoteOpenchamber)?e.remoteOpenchamber:j(e.remote_openchamber)?e.remote_openchamber:{},s=j(e.localForward)?e.localForward:j(e.local_forward)?e.local_forward:{},c=j(e.auth)?e.auth:{},l=M(o,`mode`)?.toLowerCase()===`external`?`external`:`managed`,u=M(o,`installMethod`)||M(o,`install_method`),d=u===`npm`||u===`download_release`||u===`upload_bundle`?u:`bun`,f=M(s,`bindHost`)||M(s,`bind_host`)||`127.0.0.1`,p=f===`localhost`||f===`0.0.0.0`?f:`127.0.0.1`,m=(Array.isArray(e.portForwards)?e.portForwards:Array.isArray(e.port_forwards)?e.port_forwards:[]).map(e=>ye(e)).filter(e=>!!e),h=N(o,`preferredPort`)??N(o,`preferred_port`),g=N(s,`preferredLocalPort`)??N(s,`preferred_local_port`),_=L(c.sshPassword||c.ssh_password),v=L(c.openchamberPassword||c.openchamber_password);return{id:t,...r?{nickname:r}:{},sshCommand:n,...a&&a.destination?{sshParsed:a}:{},connectionTimeoutSec:N(e,`connectionTimeoutSec`)??N(e,`connection_timeout_sec`)??60,remoteOpenchamber:{mode:l,keepRunning:P(o,`keepRunning`)??P(o,`keep_running`)??!0,...h?{preferredPort:h}:{},installMethod:d,uploadBundleOverSsh:P(o,`uploadBundleOverSsh`)??P(o,`upload_bundle_over_ssh`)??!1},localForward:{...g?{preferredLocalPort:g}:{},bindHost:p},auth:{..._?{sshPassword:_}:{},...v?{openchamberPassword:v}:{}},portForwards:m}},xe=e=>{switch(e){case`config_resolved`:case`auth_check`:case`master_connecting`:case`remote_probe`:case`installing`:case`updating`:case`server_detecting`:case`server_starting`:case`forwarding`:case`ready`:case`degraded`:case`error`:return e;default:return`idle`}},R=e=>{if(!j(e))return null;let t=M(e,`id`);return t?{id:t,phase:xe(M(e,`phase`)),...M(e,`detail`)?{detail:M(e,`detail`)||void 0}:{},...M(e,`localUrl`)||M(e,`local_url`)?{localUrl:M(e,`localUrl`)||M(e,`local_url`)||void 0}:{},...typeof(N(e,`localPort`)??N(e,`local_port`))==`number`?{localPort:N(e,`localPort`)??N(e,`local_port`)??void 0}:{},...typeof(N(e,`remotePort`)??N(e,`remote_port`))==`number`?{remotePort:N(e,`remotePort`)??N(e,`remote_port`)??void 0}:{},startedByUs:P(e,`startedByUs`)??P(e,`started_by_us`)??!1,retryAttempt:N(e,`retryAttempt`)??N(e,`retry_attempt`)??0,requiresUserAction:P(e,`requiresUserAction`)??P(e,`requires_user_action`)??!1,...M(e,`errorCode`)||M(e,`error_code`)?{errorCode:M(e,`errorCode`)||M(e,`error_code`)||void 0}:{},updatedAtMs:N(e,`updatedAtMs`)??N(e,`updated_at_ms`)??Date.now()}:null},Se=e=>{if(!j(e))return null;let t=M(e,`host`),n=M(e,`source`),r=M(e,`sshCommand`)||M(e,`ssh_command`);return!t||!n||!r?null:{host:t,source:n,sshCommand:r,pattern:P(e,`pattern`)??!1}},Ce=(e,t)=>({id:e,sshCommand:t,connectionTimeoutSec:60,remoteOpenchamber:{mode:`managed`,keepRunning:!0,installMethod:`bun`,uploadBundleOverSsh:!1},localForward:{bindHost:`127.0.0.1`},auth:{},portForwards:[]}),we=async()=>{let e=I();if(!e)return{instances:[]};let t=await e(`desktop_ssh_instances_get`);return j(t)?{instances:(Array.isArray(t.instances)?t.instances:Array.isArray(t.desktopSshInstances)?t.desktopSshInstances:[]).map(e=>be(e)).filter(e=>!!e)}:{instances:[]}},Te=async e=>{let t=I();t&&await t(`desktop_ssh_instances_set`,{config:{instances:e.instances}})},Ee=async()=>{let e=I();if(!e)return[];let t=await e(`desktop_ssh_import_hosts`);return Array.isArray(t)?t.map(e=>Se(e)).filter(e=>!!e):[]},De=async e=>{let t=I();t&&await t(`desktop_ssh_connect`,{id:e})},Oe=async e=>{let t=I();t&&await t(`desktop_ssh_disconnect`,{id:e})},ke=async e=>{let t=I();if(!t)return[];let n=await t(`desktop_ssh_status`,{...e?{id:e}:{}});return Array.isArray(n)?n.map(e=>R(e)).filter(e=>!!e):[]},Ae=async(e,t)=>{let n=I();if(!n)return[];let r=await n(`desktop_ssh_logs`,{id:e,...typeof t==`number`?{limit:t}:{}});return Array.isArray(r)?r.filter(e=>typeof e==`string`):[]},je=async e=>{let t=I();t&&await t(`desktop_ssh_logs_clear`,{id:e})},Me=(e,t)=>{let n=Math.max(0,Math.trunc(Number(e.fileGroups)||0)),r=Math.max(0,Math.trunc(Number(e.singleFiles)||0)),i=Math.max(0,Math.trunc(Number(e.directories)||0));return{fileGroups:Array.from({length:n},()=>!0),singleFiles:Array.from({length:r},()=>!0),directories:Array.from({length:i},()=>!0),agentsRoot:!0,authFile:t?.includeAuthFile===!0}},Ne=e=>{if(!j(e))return null;let t=M(e,`path`),n=N(e,`bytes`);return!t||n===null?null:{path:t,bytes:n}},Pe=e=>{if(!j(e))return null;let t=M(e,`path`),n=N(e,`fileCount`)??N(e,`file_count`),r=N(e,`bytes`);return!t||n===null||r===null?null:{path:t,fileCount:n,bytes:r}},Fe=e=>{if(e==null||!j(e))return null;let t=N(e,`fileCount`)??N(e,`file_count`),n=N(e,`bytes`);return t===null||n===null?null:{fileCount:t,bytes:n}},z=e=>{if(e==null||!j(e))return null;let t=N(e,`bytes`);return t===null?null:{bytes:t}},B=e=>{if(!j(e))return null;let t=Array.isArray(e.files)?e.files:null,n=Array.isArray(e.directories)?e.directories:null,r=F(e.deletes),i=N(e,`totalBytes`)??N(e,`total_bytes`);if(!t||!n||i===null||!(`agentsRoot`in e)&&!(`agents_root`in e))return null;let a=t.map(e=>Ne(e)).filter(e=>!!e),o=n.map(e=>Pe(e)).filter(e=>!!e);if(a.length!==t.length||o.length!==n.length)return null;let s=e.agentsRoot??e.agents_root,c=s==null?null:Fe(s);if(s!=null&&c===null)return null;let l=e.authFile??e.auth_file,u=l==null?null:z(l),d=e.direction===`pull`||e.direction===`push`?e.direction:void 0,f=e.selections,p=j(f)?{fileGroups:Array.isArray(f.fileGroups)?f.fileGroups.map(e=>e!==!1):[],singleFiles:Array.isArray(f.singleFiles)?f.singleFiles.map(e=>e!==!1):[],directories:Array.isArray(f.directories)?f.directories.map(e=>e!==!1):[],agentsRoot:f.agentsRoot!==!1,authFile:f.authFile===!0}:void 0,m=V(e.selectionShape??e.selection_shape);return{files:a,directories:o,agentsRoot:c,authFile:u,deletes:r,totalBytes:i,...d?{direction:d}:{},...p?{selections:p}:{},...m?{selectionShape:m}:{}}},V=e=>{if(!j(e))return null;let t=N(e,`fileGroups`)??N(e,`file_groups`),n=N(e,`singleFiles`)??N(e,`single_files`),r=N(e,`directories`);return t===null||n===null||r===null||t<0||n<0||r<0?null:{fileGroups:t,singleFiles:n,directories:r}},Ie=e=>{if(!j(e))return null;let t=B(e.plan);if(!t)return null;let n=V(e.selectionShape??e.selection_shape)??t.selectionShape??null;return{plan:t,remoteExisting:F(e.remoteExisting??e.remote_existing),remoteAgentsRootExists:P(e,`remoteAgentsRootExists`)??P(e,`remote_agents_root_exists`)??!1,remoteAuthFileExists:P(e,`remoteAuthFileExists`)??P(e,`remote_auth_file_exists`)??!1,...typeof e.credentialAuthorized==`boolean`?{credentialAuthorized:e.credentialAuthorized}:{},...n?{selectionShape:n}:{}}},Le=e=>{if(!j(e)||P(e,`ok`)!==!0)return null;let t=N(e,`files`),n=N(e,`directories`),r=N(e,`deletes`),i=N(e,`totalBytes`)??N(e,`total_bytes`);if(t===null||n===null||r===null||i===null||!(`agentsRoot`in e)&&!(`agents_root`in e))return null;let a=e.agentsRoot??e.agents_root,o=null;if(a!=null){if(!j(a))return null;let e=N(a,`fileCount`)??N(a,`file_count`);if(e===null)return null;o={fileCount:e}}let s=e.authFile??e.auth_file,c=s==null?null:z(s);return{ok:!0,files:t,directories:n,deletes:r,totalBytes:i,agentsRoot:o,authFile:c}},Re=async(e={})=>{let t=I();if(!t)return null;let n=await t(`desktop_ssh_sync_opencode_config`,{stage:`local`,...e.direction?{direction:e.direction}:{},...e.selections?{selections:e.selections}:{}});if(!j(n))return null;let r=B(n.plan);if(!r)return null;let i=V(n.selectionShape??n.selection_shape)??r.selectionShape??null;return i?{...r,selectionShape:i}:r},ze=async(e,t={})=>{let n=I();return n?Ie(await n(`desktop_ssh_sync_opencode_config`,{id:e,...t.targetKind?{targetKind:t.targetKind}:{},...t.direction?{direction:t.direction}:{},...t.selections?{selections:t.selections}:{}})):null},Be=async(e,t={})=>{let n=I();return n?Le(await n(`desktop_ssh_sync_opencode_config`,{id:e,apply:!0,...t.targetKind?{targetKind:t.targetKind}:{},...t.direction?{direction:t.direction}:{},...t.selections?{selections:t.selections}:{}})):null},Ve=async(e,t={})=>{let n=I();if(!n)return[];let r=await n(`desktop_ssh_sync_runs_list`,{id:e,...t.targetKind?{targetKind:t.targetKind}:{}});return Array.isArray(r)?r.filter(e=>j(e)&&typeof e.syncRunId==`string`&&typeof e.targetId==`string`):[]},H=e=>{if(!j(e))return null;let t=typeof e.targetId==`string`?e.targetId.trim():``;if(!t)return null;let n=e.authorized===!0,r=typeof e.grantedAt==`string`&&e.grantedAt.trim()?e.grantedAt.trim():void 0,i=typeof e.channel==`string`&&e.channel.trim()?e.channel.trim():void 0;return{targetId:t,authorized:n,...r?{grantedAt:r}:{},...i?{channel:i}:{}}},He=async(e,t={})=>{let n=I();return n?H(await n(`desktop_ssh_credential_sync_get`,{id:e,...t.targetKind?{targetKind:t.targetKind}:{}})):null},Ue=async(e,t={})=>{let n=I();return n?H(await n(`desktop_ssh_credential_sync_grant`,{id:e,...t.targetKind?{targetKind:t.targetKind}:{}})):null},We=async(e,t={})=>{let n=I();return n?H(await n(`desktop_ssh_credential_sync_revoke`,{id:e,...t.targetKind?{targetKind:t.targetKind}:{}})):null},Ge=async e=>{if(!r())return async()=>{};let t=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof t!=`function`)return async()=>{};let n=await t(`openchamber:ssh-instance-status`,t=>{let n=R(t?.payload);n&&e(n)});return async()=>{await n()}},Ke=new Set([`nodeRuntimeMissing`,`packageManagerMissing`,`nativeBinding`,`openchamberInstall`,`opencodeInstall`,`serverStart`,`sshAuth`,`sshUnreachable`,`timeout`,`unknown`]),qe=e=>typeof e==`string`&&Ke.has(e),Je=e=>{let t=String(e||``);return/requires Node\.js \d+|no supported Node runtime/i.test(t)?`nodeRuntimeMissing`:/neither bun nor npm/i.test(t)?`packageManagerMissing`:/better-sqlite3|node_gyp_bins|gyp ERR|failed to prepare better-sqlite3/i.test(t)?`nativeBinding`:/Failed to install OpenChamber|OpenChamber installation completed but the executable is unavailable/i.test(t)?`openchamberInstall`:/Failed to install OpenCode|OpenCode CLI/i.test(t)?`opencodeInstall`:/failed to become reachable|Managed OpenChamber server failed/i.test(t)?`serverStart`:/Permission denied|Authentication failed|publickey|keyboard-interactive/i.test(t)?`sshAuth`:/Could not resolve hostname|Connection refused|Connection timed out|ControlMaster connection timed out|SSH master process exited|Network is unreachable/i.test(t)?`sshUnreachable`:/Timed out waiting for SSH|Timed out waiting for forwarded/i.test(t)?`timeout`:`unknown`},U=(e,t)=>qe(e)?e:Je(t),W=e=>{switch(e){case`nodeRuntimeMissing`:return`desktopHostSwitcher.sshError.nodeRuntimeMissing.title`;case`packageManagerMissing`:return`desktopHostSwitcher.sshError.packageManagerMissing.title`;case`nativeBinding`:return`desktopHostSwitcher.sshError.nativeBinding.title`;case`openchamberInstall`:return`desktopHostSwitcher.sshError.openchamberInstall.title`;case`opencodeInstall`:return`desktopHostSwitcher.sshError.opencodeInstall.title`;case`serverStart`:return`desktopHostSwitcher.sshError.serverStart.title`;case`sshAuth`:return`desktopHostSwitcher.sshError.sshAuth.title`;case`sshUnreachable`:return`desktopHostSwitcher.sshError.sshUnreachable.title`;case`timeout`:return`desktopHostSwitcher.sshError.timeout.title`;default:return`desktopHostSwitcher.sshError.unknown.title`}},G=e=>{switch(e){case`nodeRuntimeMissing`:return`desktopHostSwitcher.sshError.nodeRuntimeMissing.guidance`;case`packageManagerMissing`:return`desktopHostSwitcher.sshError.packageManagerMissing.guidance`;case`nativeBinding`:return`desktopHostSwitcher.sshError.nativeBinding.guidance`;case`openchamberInstall`:return`desktopHostSwitcher.sshError.openchamberInstall.guidance`;case`opencodeInstall`:return`desktopHostSwitcher.sshError.opencodeInstall.guidance`;case`serverStart`:return`desktopHostSwitcher.sshError.serverStart.guidance`;case`sshAuth`:return`desktopHostSwitcher.sshError.sshAuth.guidance`;case`sshUnreachable`:return`desktopHostSwitcher.sshError.sshUnreachable.guidance`;case`timeout`:return`desktopHostSwitcher.sshError.timeout.guidance`;default:return`desktopHostSwitcher.sshError.unknown.guidance`}},K=f();function Ye(e){let t=(0,D.c)(17),{errorCode:n,detail:r,className:i}=e,{t:a}=y(),o,s,c,l;if(t[0]!==i||t[1]!==r||t[2]!==n||t[3]!==a){let e=U(n,r);t[8]===i?c=t[9]:(c=w(`space-y-1`,i),t[8]=i,t[9]=c),l=(0,K.jsx)(`p`,{className:`typography-ui-label text-[var(--status-error)]`,children:a(W(e))}),o=`typography-meta text-muted-foreground`,s=a(G(e)),t[0]=i,t[1]=r,t[2]=n,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else o=t[4],s=t[5],c=t[6],l=t[7];let u;t[10]!==o||t[11]!==s?(u=(0,K.jsx)(`p`,{className:o,children:s}),t[10]=o,t[11]=s,t[12]=u):u=t[12];let d;return t[13]!==c||t[14]!==l||t[15]!==u?(d=(0,K.jsxs)(`div`,{className:c,children:[l,u]}),t[13]=c,t[14]=l,t[15]=u,t[16]=d):d=t[16],d}var Xe=`/auth/passkey/authenticate/options`,Ze=`/auth/passkey/authenticate/verify`,Qe=`/auth/passkey/register/options`,$e=`/auth/passkey/register/verify`,q=`/api/passkeys`,et=`/auth/passkey/status`,tt=`/api/auth/reset`,nt={enabled:!1,hasPasskeys:!1,passkeyCount:0,rpID:null},J=async(e,t)=>i(e,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:t===void 0?void 0:JSON.stringify(t)}),Y=async(e,t)=>{try{let t=await e.json();if(t&&typeof t.error==`string`&&t.error.trim())return t.error}catch{}return t},rt=e=>e instanceof ae&&e.code===`ERROR_CEREMONY_ABORTED`,it=()=>{se.cancelCeremony()},X=()=>typeof window>`u`?{supported:!1,reason:`Passkeys are unavailable outside the browser.`}:window.isSecureContext?{supported:!0,reason:``}:{supported:!1,reason:`Passkeys require HTTPS or localhost.`},at=async()=>{let e=X();if(!e.supported)throw Error(e.reason);let t=await J(Qe,{label:typeof navigator.userAgent==`string`&&navigator.userAgent.trim()?navigator.userAgent:`This device`});if(!t.ok)throw Error(await Y(t,`Could not start passkey setup.`));let{requestId:n,optionsJSON:r}=await t.json(),i=await J($e,{requestId:n,response:await oe({optionsJSON:r})});if(!i.ok)throw Error(await Y(i,`Could not finish passkey setup.`));return i.json().catch(()=>null)},ot=async(e,t={})=>{let n=X();if(!n.supported)throw Error(n.reason);let r=await J(Xe);if(!r.ok)throw Error(await Y(r,`Passkey sign-in is not available right now.`));let{requestId:i,optionsJSON:a}=await r.json(),o=await J(Ze,{requestId:i,response:await ce({optionsJSON:a}),trustDevice:e,issueClientToken:t.issueClientToken===!0,clientLabel:t.clientLabel,clientKind:t.clientKind,dedupeKey:t.dedupeKey});if(!o.ok)throw Error(await Y(o,`Passkey sign-in failed.`));return o.json().catch(()=>null)},st=async()=>{let e=await i(et,{method:`GET`,credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return nt;let t=await e.json().catch(()=>null);return{enabled:t?.enabled===!0,hasPasskeys:t?.hasPasskeys===!0,passkeyCount:typeof t?.passkeyCount==`number`?t.passkeyCount:0,rpID:typeof t?.rpID==`string`&&t.rpID?t.rpID:null}},ct=async()=>{let e=await i(q,{method:`GET`,credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(await Y(e,`Could not load passkeys.`));let t=await e.json().catch(()=>null);return Array.isArray(t?.passkeys)?t.passkeys:[]},lt=async e=>{let t=await i(`${q}/${encodeURIComponent(e)}`,{method:`DELETE`,credentials:`include`,headers:{Accept:`application/json`}});if(!t.ok)throw Error(await Y(t,`Could not remove passkey.`));return t.json().catch(()=>null)},ut=async()=>{let e=await J(tt);if(!e.ok)throw Error(await Y(e,`Could not clear saved authentication.`));return e.json().catch(()=>null)},Z=e(p(),1);function dt(e){let t=(0,D.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=w(`bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,K.jsx)(`div`,{"data-slot":`card`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function ft(e){let t=(0,D.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=w(`@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,K.jsx)(`div`,{"data-slot":`card-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function pt(e){let t=(0,D.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=w(`leading-none font-semibold`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,K.jsx)(`div`,{"data-slot":`card-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function mt(e){let t=(0,D.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=w(`px-6`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,K.jsx)(`div`,{"data-slot":`card-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var ht=class extends Z.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){this.setState({error:e,errorInfo:t,copied:!1}),console.error(`Error caught by boundary:`,e,t)}handleReset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})};handleCopy=async()=>{let{strings:e}=this.props,t=`${this.state.error?String(this.state.error):e.unknownError}${this.state.error?.stack?`\n\nStack:\n${this.state.error.stack}`:``}${this.state.errorInfo?.componentStack?`\n\n${e.componentStackLabel}${this.state.errorInfo.componentStack}`:``}`;(await b(t)).ok&&(this.setState({copied:!0}),window.setTimeout(()=>{this.setState(e=>e.copied?{copied:!1}:null)},1500))};render(){let{strings:e}=this.props;return this.state.hasError?this.props.fallback?this.props.fallback:(0,K.jsx)(`div`,{className:`p-4 flex items-center justify-center min-h-screen`,children:(0,K.jsxs)(dt,{className:`w-full max-w-md`,children:[(0,K.jsx)(ft,{className:`text-center`,children:(0,K.jsxs)(pt,{className:`flex items-center justify-center gap-2 text-destructive`,children:[(0,K.jsx)(T,{name:`error-warning`,className:`h-5 w-5`}),e.title]})}),(0,K.jsxs)(mt,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground text-center`,children:e.description}),this.state.error&&(0,K.jsxs)(`details`,{className:`text-xs font-mono bg-muted p-3 rounded`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer hover:bg-interactive-hover/80`,children:e.detailsSummary}),(0,K.jsxs)(`pre`,{className:`mt-2 max-h-48 overflow-auto`,children:[this.state.error.toString(),this.state.errorInfo?.componentStack?`\n\n${e.componentStackLabel}${this.state.errorInfo.componentStack}`:``]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(E,{onClick:this.handleReset,variant:`outline`,className:`flex-1`,children:[(0,K.jsx)(T,{name:`restart`,className:`h-4 w-4 mr-2`}),e.tryAgain]}),(0,K.jsx)(E,{onClick:this.handleCopy,variant:`outline`,className:`flex-1`,children:this.state.copied?e.copied:e.copy})]})]})]})}):this.props.children}},gt=e=>{let t=(0,D.c)(29),{children:n,fallback:r}=e,{t:i}=y(),a;t[0]===i?a=t[1]:(a=i(`errorBoundary.state.unknownError`),t[0]=i,t[1]=a);let o;t[2]===i?o=t[3]:(o=i(`errorBoundary.title`),t[2]=i,t[3]=o);let s;t[4]===i?s=t[5]:(s=i(`errorBoundary.description`),t[4]=i,t[5]=s);let c;t[6]===i?c=t[7]:(c=i(`errorBoundary.actions.errorDetails`),t[6]=i,t[7]=c);let l;t[8]===i?l=t[9]:(l=i(`errorBoundary.state.componentStackLabel`),t[8]=i,t[9]=l);let u;t[10]===i?u=t[11]:(u=i(`errorBoundary.actions.tryAgain`),t[10]=i,t[11]=u);let d;t[12]===i?d=t[13]:(d=i(`errorBoundary.actions.copied`),t[12]=i,t[13]=d);let f;t[14]===i?f=t[15]:(f=i(`errorBoundary.actions.copy`),t[14]=i,t[15]=f);let p;t[16]!==a||t[17]!==o||t[18]!==s||t[19]!==c||t[20]!==l||t[21]!==u||t[22]!==d||t[23]!==f?(p={unknownError:a,title:o,description:s,detailsSummary:c,componentStackLabel:l,tryAgain:u,copied:d,copy:f},t[16]=a,t[17]=o,t[18]=s,t[19]=c,t[20]=l,t[21]=u,t[22]=d,t[23]=f,t[24]=p):p=t[24];let m=p,h;return t[25]!==n||t[26]!==r||t[27]!==m?(h=(0,K.jsx)(ht,{fallback:r,strings:m,children:n}),t[25]=n,t[26]=r,t[27]=m,t[28]=h):h=t[28],h},Q=e=>te(ee.getState().dictionary,e),_t=e=>typeof e!=`number`||!Number.isFinite(e)?null:Math.max(0,Math.min(100,Math.round(e))),vt=e=>typeof e!=`number`||!Number.isFinite(e)?`-`:`${Math.round(e)}%`,yt=(e,t)=>e??vt(t),bt=(e,t,n=`auto`)=>{if(!e)return t??``;try{let r=new Date(e);if(!Number.isFinite(r.getTime()))return t??``;let i=new Date;return r.toDateString()===i.toDateString()?ue(r,n,{fallback:t??``}):le(r,n,{month:`short`,day:`numeric`,weekday:`short`,hour:`numeric`,minute:`2-digit`})}catch{return t??``}},xt=e=>e===null?`safe`:e>=80?`critical`:e>=50?`warn`:`safe`,St=e=>e===`5h`?Q(`quota.window.5h`):e===`7d`?Q(`quota.window.7d`):e===`7d-sonnet`?Q(`quota.window.7dSonnet`):e===`7d-opus`?Q(`quota.window.7dOpus`):e===`weekly`?Q(`quota.window.weekly`):e===`daily`?Q(`quota.window.daily`):e===`monthly`?Q(`quota.window.monthly`):e===`credits`?Q(`quota.window.credits`):e===`credits_balance`?Q(`quota.window.creditsBalance`):e===`billing_cycle`?Q(`quota.window.billingCycle`):e===`auto`?Q(`quota.window.auto`):e===`api`?Q(`quota.window.api`):e===`plan_limit`?Q(`quota.window.planLimit`):e===`on_demand`?Q(`quota.window.onDemand`):e===`session`?Q(`quota.window.session`):e===`premium`?Q(`quota.window.premium`):e===`chat`?Q(`quota.window.chat`):e===`completions`?Q(`quota.window.completions`):e===`premium_interactions`?Q(`quota.window.premiumInteractions`):e,Ct=e=>{let t=e.toLowerCase().trim();if(t===`5h`)return 18e3;if(t===`7d`||t===`weekly`||t===`7d-sonnet`||t===`7d-opus`)return 604800;if(t===`monthly`)return 2592e3;if(t===`24h`||t===`daily`)return 86400;if(t===`1h`)return 3600;let n=t.match(/^(\d+)h$/);if(n)return parseInt(n[1],10)*3600;let r=t.match(/^(\d+)d$/);return r?parseInt(r[1],10)*86400:null},wt=(e,t,n,r)=>{let i=n;if(i===null&&r&&(i=Ct(r)),e===null||t===null||i===null||i<=0)return null;let a=Math.max(0,(t-Date.now())/1e3),o=Math.max(0,Math.min(i,i-a)),s=Math.max(0,Math.min(1,o/i)),c=e/100,l=e>=100&&a>0,u;u=s>.01?Math.min(999,c/s*100):e;let d;d=l?`exhausted`:c<=s?`on-track`:u<=130?`slightly-fast`:`too-fast`;let f=i>=432e3,p=f?86400:3600,m=f?`d`:`h`,h=i/p,g=e/Math.max(o/p,h*.01),_=Number.isFinite(g)?`${Math.min(999.9,Math.max(0,g)).toFixed(1)}%/${m}`:`-`,v=u>100?`+${Math.round(u)}%`:`${Math.round(u)}%`,y=null,b=i/86400;return b>=7&&(y=100/b),{elapsedRatio:s,usageRatio:c,predictedFinalPercent:u,remainingSeconds:a,isExhausted:l,elapsedSeconds:o,totalSeconds:i,status:d,paceRateText:_,predictText:v,dailyAllocationPercent:y}},Tt=e=>{switch(e){case`exhausted`:case`too-fast`:return`var(--status-error)`;case`slightly-fast`:return`var(--status-warning)`;case`on-track`:return`var(--status-success)`}},Et=e=>{let t=Math.floor(Math.max(0,Math.floor(e))/60),n=Math.floor(t/60),r=Math.floor(n/24),i=n%24,a=t%60;return r>0?`${r}d ${i}h`:n>0?`${n}h`:t===0?`<1m`:`${a}m`},Dt=e=>Math.min(100,Math.max(0,e*100)),Ot=[`standalone`,`minimal-ui`,`fullscreen`,`window-controls-overlay`],kt=`openchamber.pwaRecentSessions`,At=e=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(display-mode: ${e})`).matches,jt=()=>typeof window>`u`?`browser`:typeof document<`u`&&document.referrer.startsWith(`android-app://`)?`twa`:window.navigator.standalone?`standalone`:Ot.find(e=>At(e))??`browser`,Mt=864e5,Nt=5,Pt=864e5,$=e=>e.time?.updated??e.time?.created??0,Ft=({sessions:e,currentSessionId:t,cutoffDays:n,keepRecent:r=Nt,now:i=Date.now()})=>{if(!Array.isArray(e)||n<=0)return[];let a=i-n*Mt,o=[...e].sort((e,t)=>$(t)-$(e)),s=new Set(o.slice(0,r).map(e=>e.id));return o.filter(e=>{if(!e?.id||s.has(e.id)||e.id===t||e.share)return!1;let n=$(e);return n?n<a:!1}).map(e=>e.id)},It=e=>{let t=typeof e==`object`?e:void 0,r=t?.autoRun!==!1,i=typeof e==`boolean`?e:t?.enabled??!0,a=re(e=>e.currentSessionId),o=re(e=>e.isLoading),s=x(e=>e.activeSessions),c=x(e=>e.hasLoadedFullCatalog),l=n(e=>e.autoDeleteEnabled),u=n(e=>e.autoDeleteAfterDays),d=n(e=>e.sessionRetentionAction),f=n(e=>e.autoDeleteLastRunAt),p=n(e=>e.setAutoDeleteLastRunAt),[h,g]=Z.useState(!1),_=Z.useRef(!1);Z.useEffect(()=>{if(!i||!r||!l||u<=0)return;let e=window.setTimeout(()=>{C(S())},8e3);return()=>window.clearTimeout(e)},[u,l,r,i]);let v=Z.useMemo(()=>u<=0?[]:Ft({sessions:s,currentSessionId:a,cutoffDays:u}),[u,a,s]),y=Z.useCallback(async({force:e=!1}={})=>{if(_.current)return{completedIds:[],failedIds:[],action:d,skippedReason:`running`};if((!l||u<=0)&&!e)return{completedIds:[],failedIds:[],action:d,skippedReason:`disabled`};if(o)return{completedIds:[],failedIds:[],action:d,skippedReason:`loading`};let t=Date.now();if(!e&&f&&t-f<Pt)return{completedIds:[],failedIds:[],action:d,skippedReason:`cooldown`};let{activeSessions:n}=await C(S());if(n.length===0)return{completedIds:[],failedIds:[],action:d,skippedReason:`no-candidates`};let r=Ft({sessions:n,currentSessionId:a,cutoffDays:u,now:t});if(r.length===0)return p(t),{completedIds:[],failedIds:[],action:d,skippedReason:`no-candidates`};_.current=!0,g(!0);try{let e=new Map(n.map(e=>[e.id,e])),t=[],i=[];for(let n of r){let r=e.get(n),a=r?ne(r):null;if(!a){i.push(n);continue}try{d===`archive`?await m.updateSession(n,{time:{archived:Date.now()}},a):await m.deleteSession(n,a),t.push(n)}catch{i.push(n)}}return d===`archive`?x.getState().archiveSessions(t):x.getState().removeSessions(t),{completedIds:t,failedIds:i,action:d}}finally{_.current=!1,g(!1),p(Date.now())}},[u,l,f,a,o,d,p]);return Z.useEffect(()=>{i&&r&&(!l||u<=0||o||!c||s.length===0||f&&Date.now()-f<Pt||y())},[u,l,f,r,i,c,s.length,o,y]),{candidates:v,isRunning:h,runCleanup:y,keepRecentCount:Nt,action:d}};export{G as A,we as B,X as C,lt as D,ut as E,He as F,Be as G,Ae as H,Ue as I,Ve as J,Re as K,We as L,Me as M,Ce as N,Ye as O,De as P,ge as Q,Oe as R,ct as S,at as T,je as U,Te as V,ke as W,me as X,Ge as Y,he as Z,pt as _,wt as a,nt as b,yt as c,Tt as d,xt as f,ft as g,mt as h,Dt as i,W as j,U as k,Et as l,dt as m,kt as n,_t as o,gt as p,ze as q,jt as r,bt as s,It as t,St as u,ot as v,rt as w,st as x,it as y,Ee as z};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{M as t,t as n}from"./useUIStore-BJpkPwky.js";import{Kt as r,kn as i,qt as a,u as o}from"./persistence-DwXJK4-j.js";import{h as s}from"./desktopHosts-aA40MHzB.js";import{a as c,i as l,o as u,r as d}from"./desktopRelayRestore-CxUYRC6v.js";import{nt as f,rt as p}from"./vendor-base-ui-CnHfUmDN.js";import{Nt as m}from"./platform-CXJwZIZe.js";import{n as h}from"./vendor-react-DLPElpoQ.js";import{n as g}from"./vendor-tanstack-query-core-BWz0ose6.js";import{i as _,r as v}from"./vendor-tanstack-react-query-D7pys_c9.js";import{n as y,t as b}from"./clipboard-BvJ7NunE.js";import{i as ee,t as te}from"./store-BuXogmxp.js";import{fr as ne,hr as x,l as re,oa as S,or as C,vr as ie}from"./useMobileNavigationStore-BULVe95f.js";import{t as w}from"./utils-DfPDhqys.js";import{n as T}from"./Icon-BhSwbLaF.js";import{t as E}from"./button-KTZJ84Mx.js";import{i as ae,n as oe,r as se,t as ce}from"./vendor-simplewebauthn-browser-Dwhcdg_5.js";import{n as le,r as ue}from"./radio-EJi50i5B.js";var D=h(),O=[`desktopHostSwitch`],k=class extends Error{result;host;constructor(e,t){super(e.reason),this.name=`DesktopHostSwitchError`,this.result=e,this.host=t}},de=(e,t)=>te(ee.getState().dictionary,e,t),fe=async e=>{let{host:n}=e;if(n.id===`local`){let r=(e.localApiOrigin||``).trim();if(!r)throw new k({ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unreachable`},n);return t({apiBaseUrl:r,clientToken:e.localClientToken||null,runtimeKey:l(n)}),{ok:!0,via:`direct`,status:{status:`ok`,latencyMs:0}}}if(n.viaSshRelay){let e=await u(n);if(!e.ok)throw new k(e,n);return e}let r=await c(n,{cachedProbe:e.cachedProbe});if(!r.ok)throw new k(r,n);return r},A=null,pe=()=>A||(A=new g(o,{mutationKey:O,mutationFn:fe,onError:(e,t)=>{e instanceof k&&e.result.reason!==`unsupported`&&ie.error(de(`desktopHostSwitcher.toast.instanceUnreachable`,{host:s(t.host.label)}))}}),A.subscribe(()=>void 0),A),me=async e=>{if(d(e.host))return{ok:!0,via:`direct`,status:e.cachedProbe?.status===`ok`?e.cachedProbe:{status:`ok`,latencyMs:0}};if(o.isMutating({mutationKey:O})>0)return{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unsupported`};try{return await pe().mutate(e)}catch(e){if(e instanceof k)return e.result;throw e}},he=()=>{let e=(0,D.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={mutationKey:O},e[0]=t):t=e[0],v(t)>0},ge=()=>{let e=(0,D.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={filters:{mutationKey:O,status:`pending`},select:_e},e[0]=t):t=e[0],_(t)[0]?.host.id??null};function _e(e){return e.state.variables}var j=e=>typeof e==`object`&&!!e,M=(e,t)=>{let n=e[t];return typeof n==`string`?n:null},N=(e,t)=>{let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:null},P=(e,t)=>{let n=e[t];return typeof n==`boolean`?n:null},F=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],I=()=>r()?(e,t)=>a(e,t):null,L=e=>{if(!j(e))return;let t=P(e,`enabled`)??!1,n=M(e,`store`)?.toLowerCase()===`settings`?`settings`:`never`,r=M(e,`value`);return{enabled:t,store:n,...r?{value:r}:{}}},ve=e=>e===`remote`||e===`dynamic`?e:`local`,ye=e=>{if(!j(e))return null;let t=M(e,`id`);if(!t)return null;let n=P(e,`enabled`)??!0,r=ve(M(e,`type`)),i=M(e,`localHost`)||M(e,`local_host`)||void 0,a=N(e,`localPort`)??N(e,`local_port`)??void 0,o=M(e,`remoteHost`)||M(e,`remote_host`)||void 0,s=N(e,`remotePort`)??N(e,`remote_port`)??void 0;return{id:t,enabled:n,type:r,...i?{localHost:i}:{},...typeof a==`number`?{localPort:a}:{},...o?{remoteHost:o}:{},...typeof s==`number`?{remotePort:s}:{}}},be=e=>{if(!j(e))return null;let t=M(e,`id`),n=M(e,`sshCommand`)||M(e,`ssh_command`);if(!t||!n)return null;let r=M(e,`nickname`),i=e.sshParsed,a=j(i)?{destination:M(i,`destination`)||``,args:F(i.args)}:void 0,o=j(e.remoteOpenchamber)?e.remoteOpenchamber:j(e.remote_openchamber)?e.remote_openchamber:{},s=j(e.localForward)?e.localForward:j(e.local_forward)?e.local_forward:{},c=j(e.auth)?e.auth:{},l=M(o,`mode`)?.toLowerCase()===`external`?`external`:`managed`,u=M(o,`installMethod`)||M(o,`install_method`),d=u===`npm`||u===`download_release`||u===`upload_bundle`?u:`bun`,f=M(s,`bindHost`)||M(s,`bind_host`)||`127.0.0.1`,p=f===`localhost`||f===`0.0.0.0`?f:`127.0.0.1`,m=(Array.isArray(e.portForwards)?e.portForwards:Array.isArray(e.port_forwards)?e.port_forwards:[]).map(e=>ye(e)).filter(e=>!!e),h=N(o,`preferredPort`)??N(o,`preferred_port`),g=N(s,`preferredLocalPort`)??N(s,`preferred_local_port`),_=L(c.sshPassword||c.ssh_password),v=L(c.openchamberPassword||c.openchamber_password);return{id:t,...r?{nickname:r}:{},sshCommand:n,...a&&a.destination?{sshParsed:a}:{},connectionTimeoutSec:N(e,`connectionTimeoutSec`)??N(e,`connection_timeout_sec`)??60,remoteOpenchamber:{mode:l,keepRunning:P(o,`keepRunning`)??P(o,`keep_running`)??!0,...h?{preferredPort:h}:{},installMethod:d,uploadBundleOverSsh:P(o,`uploadBundleOverSsh`)??P(o,`upload_bundle_over_ssh`)??!1},localForward:{...g?{preferredLocalPort:g}:{},bindHost:p},auth:{..._?{sshPassword:_}:{},...v?{openchamberPassword:v}:{}},portForwards:m}},xe=e=>{switch(e){case`config_resolved`:case`auth_check`:case`master_connecting`:case`remote_probe`:case`installing`:case`updating`:case`server_detecting`:case`server_starting`:case`forwarding`:case`ready`:case`degraded`:case`error`:return e;default:return`idle`}},R=e=>{if(!j(e))return null;let t=M(e,`id`);return t?{id:t,phase:xe(M(e,`phase`)),...M(e,`detail`)?{detail:M(e,`detail`)||void 0}:{},...M(e,`localUrl`)||M(e,`local_url`)?{localUrl:M(e,`localUrl`)||M(e,`local_url`)||void 0}:{},...typeof(N(e,`localPort`)??N(e,`local_port`))==`number`?{localPort:N(e,`localPort`)??N(e,`local_port`)??void 0}:{},...typeof(N(e,`remotePort`)??N(e,`remote_port`))==`number`?{remotePort:N(e,`remotePort`)??N(e,`remote_port`)??void 0}:{},startedByUs:P(e,`startedByUs`)??P(e,`started_by_us`)??!1,retryAttempt:N(e,`retryAttempt`)??N(e,`retry_attempt`)??0,requiresUserAction:P(e,`requiresUserAction`)??P(e,`requires_user_action`)??!1,...M(e,`errorCode`)||M(e,`error_code`)?{errorCode:M(e,`errorCode`)||M(e,`error_code`)||void 0}:{},updatedAtMs:N(e,`updatedAtMs`)??N(e,`updated_at_ms`)??Date.now()}:null},Se=e=>{if(!j(e))return null;let t=M(e,`host`),n=M(e,`source`),r=M(e,`sshCommand`)||M(e,`ssh_command`);return!t||!n||!r?null:{host:t,source:n,sshCommand:r,pattern:P(e,`pattern`)??!1}},Ce=(e,t)=>({id:e,sshCommand:t,connectionTimeoutSec:60,remoteOpenchamber:{mode:`managed`,keepRunning:!0,installMethod:`bun`,uploadBundleOverSsh:!1},localForward:{bindHost:`127.0.0.1`},auth:{},portForwards:[]}),we=async()=>{let e=I();if(!e)return{instances:[]};let t=await e(`desktop_ssh_instances_get`);return j(t)?{instances:(Array.isArray(t.instances)?t.instances:Array.isArray(t.desktopSshInstances)?t.desktopSshInstances:[]).map(e=>be(e)).filter(e=>!!e)}:{instances:[]}},Te=async e=>{let t=I();t&&await t(`desktop_ssh_instances_set`,{config:{instances:e.instances}})},Ee=async()=>{let e=I();if(!e)return[];let t=await e(`desktop_ssh_import_hosts`);return Array.isArray(t)?t.map(e=>Se(e)).filter(e=>!!e):[]},De=async e=>{let t=I();t&&await t(`desktop_ssh_connect`,{id:e})},Oe=async e=>{let t=I();t&&await t(`desktop_ssh_disconnect`,{id:e})},ke=async e=>{let t=I();if(!t)return[];let n=await t(`desktop_ssh_status`,{...e?{id:e}:{}});return Array.isArray(n)?n.map(e=>R(e)).filter(e=>!!e):[]},Ae=async(e,t)=>{let n=I();if(!n)return[];let r=await n(`desktop_ssh_logs`,{id:e,...typeof t==`number`?{limit:t}:{}});return Array.isArray(r)?r.filter(e=>typeof e==`string`):[]},je=async e=>{let t=I();t&&await t(`desktop_ssh_logs_clear`,{id:e})},Me=(e,t)=>{let n=Math.max(0,Math.trunc(Number(e.fileGroups)||0)),r=Math.max(0,Math.trunc(Number(e.singleFiles)||0)),i=Math.max(0,Math.trunc(Number(e.directories)||0));return{fileGroups:Array.from({length:n},()=>!0),singleFiles:Array.from({length:r},()=>!0),directories:Array.from({length:i},()=>!0),agentsRoot:!0,authFile:t?.includeAuthFile===!0}},Ne=e=>{if(!j(e))return null;let t=M(e,`path`),n=N(e,`bytes`);return!t||n===null?null:{path:t,bytes:n}},Pe=e=>{if(!j(e))return null;let t=M(e,`path`),n=N(e,`fileCount`)??N(e,`file_count`),r=N(e,`bytes`);return!t||n===null||r===null?null:{path:t,fileCount:n,bytes:r}},Fe=e=>{if(e==null||!j(e))return null;let t=N(e,`fileCount`)??N(e,`file_count`),n=N(e,`bytes`);return t===null||n===null?null:{fileCount:t,bytes:n}},z=e=>{if(e==null||!j(e))return null;let t=N(e,`bytes`);return t===null?null:{bytes:t}},B=e=>{if(!j(e))return null;let t=Array.isArray(e.files)?e.files:null,n=Array.isArray(e.directories)?e.directories:null,r=F(e.deletes),i=N(e,`totalBytes`)??N(e,`total_bytes`);if(!t||!n||i===null||!(`agentsRoot`in e)&&!(`agents_root`in e))return null;let a=t.map(e=>Ne(e)).filter(e=>!!e),o=n.map(e=>Pe(e)).filter(e=>!!e);if(a.length!==t.length||o.length!==n.length)return null;let s=e.agentsRoot??e.agents_root,c=s==null?null:Fe(s);if(s!=null&&c===null)return null;let l=e.authFile??e.auth_file,u=l==null?null:z(l),d=e.direction===`pull`||e.direction===`push`?e.direction:void 0,f=e.selections,p=j(f)?{fileGroups:Array.isArray(f.fileGroups)?f.fileGroups.map(e=>e!==!1):[],singleFiles:Array.isArray(f.singleFiles)?f.singleFiles.map(e=>e!==!1):[],directories:Array.isArray(f.directories)?f.directories.map(e=>e!==!1):[],agentsRoot:f.agentsRoot!==!1,authFile:f.authFile===!0}:void 0,m=V(e.selectionShape??e.selection_shape);return{files:a,directories:o,agentsRoot:c,authFile:u,deletes:r,totalBytes:i,...d?{direction:d}:{},...p?{selections:p}:{},...m?{selectionShape:m}:{}}},V=e=>{if(!j(e))return null;let t=N(e,`fileGroups`)??N(e,`file_groups`),n=N(e,`singleFiles`)??N(e,`single_files`),r=N(e,`directories`);return t===null||n===null||r===null||t<0||n<0||r<0?null:{fileGroups:t,singleFiles:n,directories:r}},Ie=e=>{if(!j(e))return null;let t=B(e.plan);if(!t)return null;let n=V(e.selectionShape??e.selection_shape)??t.selectionShape??null;return{plan:t,remoteExisting:F(e.remoteExisting??e.remote_existing),remoteAgentsRootExists:P(e,`remoteAgentsRootExists`)??P(e,`remote_agents_root_exists`)??!1,remoteAuthFileExists:P(e,`remoteAuthFileExists`)??P(e,`remote_auth_file_exists`)??!1,...typeof e.credentialAuthorized==`boolean`?{credentialAuthorized:e.credentialAuthorized}:{},...n?{selectionShape:n}:{}}},Le=e=>{if(!j(e)||P(e,`ok`)!==!0)return null;let t=N(e,`files`),n=N(e,`directories`),r=N(e,`deletes`),i=N(e,`totalBytes`)??N(e,`total_bytes`);if(t===null||n===null||r===null||i===null||!(`agentsRoot`in e)&&!(`agents_root`in e))return null;let a=e.agentsRoot??e.agents_root,o=null;if(a!=null){if(!j(a))return null;let e=N(a,`fileCount`)??N(a,`file_count`);if(e===null)return null;o={fileCount:e}}let s=e.authFile??e.auth_file,c=s==null?null:z(s);return{ok:!0,files:t,directories:n,deletes:r,totalBytes:i,agentsRoot:o,authFile:c}},Re=async(e={})=>{let t=I();if(!t)return null;let n=await t(`desktop_ssh_sync_opencode_config`,{stage:`local`,...e.direction?{direction:e.direction}:{},...e.selections?{selections:e.selections}:{}});if(!j(n))return null;let r=B(n.plan);if(!r)return null;let i=V(n.selectionShape??n.selection_shape)??r.selectionShape??null;return i?{...r,selectionShape:i}:r},ze=async(e,t={})=>{let n=I();return n?Ie(await n(`desktop_ssh_sync_opencode_config`,{id:e,...t.targetKind?{targetKind:t.targetKind}:{},...t.direction?{direction:t.direction}:{},...t.selections?{selections:t.selections}:{}})):null},Be=async(e,t={})=>{let n=I();return n?Le(await n(`desktop_ssh_sync_opencode_config`,{id:e,apply:!0,...t.targetKind?{targetKind:t.targetKind}:{},...t.direction?{direction:t.direction}:{},...t.selections?{selections:t.selections}:{}})):null},Ve=async(e,t={})=>{let n=I();if(!n)return[];let r=await n(`desktop_ssh_sync_runs_list`,{id:e,...t.targetKind?{targetKind:t.targetKind}:{}});return Array.isArray(r)?r.filter(e=>j(e)&&typeof e.syncRunId==`string`&&typeof e.targetId==`string`):[]},H=e=>{if(!j(e))return null;let t=typeof e.targetId==`string`?e.targetId.trim():``;if(!t)return null;let n=e.authorized===!0,r=typeof e.grantedAt==`string`&&e.grantedAt.trim()?e.grantedAt.trim():void 0,i=typeof e.channel==`string`&&e.channel.trim()?e.channel.trim():void 0;return{targetId:t,authorized:n,...r?{grantedAt:r}:{},...i?{channel:i}:{}}},He=async(e,t={})=>{let n=I();return n?H(await n(`desktop_ssh_credential_sync_get`,{id:e,...t.targetKind?{targetKind:t.targetKind}:{}})):null},Ue=async(e,t={})=>{let n=I();return n?H(await n(`desktop_ssh_credential_sync_grant`,{id:e,...t.targetKind?{targetKind:t.targetKind}:{}})):null},We=async(e,t={})=>{let n=I();return n?H(await n(`desktop_ssh_credential_sync_revoke`,{id:e,...t.targetKind?{targetKind:t.targetKind}:{}})):null},Ge=async e=>{if(!r())return async()=>{};let t=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof t!=`function`)return async()=>{};let n=await t(`openchamber:ssh-instance-status`,t=>{let n=R(t?.payload);n&&e(n)});return async()=>{await n()}},Ke=new Set([`nodeRuntimeMissing`,`packageManagerMissing`,`nativeBinding`,`openchamberInstall`,`opencodeInstall`,`serverStart`,`sshAuth`,`sshUnreachable`,`timeout`,`unknown`]),qe=e=>typeof e==`string`&&Ke.has(e),Je=e=>{let t=String(e||``);return/requires Node\.js \d+|no supported Node runtime/i.test(t)?`nodeRuntimeMissing`:/neither bun nor npm/i.test(t)?`packageManagerMissing`:/better-sqlite3|node_gyp_bins|gyp ERR|failed to prepare better-sqlite3/i.test(t)?`nativeBinding`:/Failed to install OpenChamber|OpenChamber installation completed but the executable is unavailable/i.test(t)?`openchamberInstall`:/Failed to install OpenCode|OpenCode CLI/i.test(t)?`opencodeInstall`:/failed to become reachable|Managed OpenChamber server failed/i.test(t)?`serverStart`:/Permission denied|Authentication failed|publickey|keyboard-interactive/i.test(t)?`sshAuth`:/Could not resolve hostname|Connection refused|Connection timed out|ControlMaster connection timed out|SSH master process exited|Network is unreachable/i.test(t)?`sshUnreachable`:/Timed out waiting for SSH|Timed out waiting for forwarded/i.test(t)?`timeout`:`unknown`},U=(e,t)=>qe(e)?e:Je(t),W=e=>{switch(e){case`nodeRuntimeMissing`:return`desktopHostSwitcher.sshError.nodeRuntimeMissing.title`;case`packageManagerMissing`:return`desktopHostSwitcher.sshError.packageManagerMissing.title`;case`nativeBinding`:return`desktopHostSwitcher.sshError.nativeBinding.title`;case`openchamberInstall`:return`desktopHostSwitcher.sshError.openchamberInstall.title`;case`opencodeInstall`:return`desktopHostSwitcher.sshError.opencodeInstall.title`;case`serverStart`:return`desktopHostSwitcher.sshError.serverStart.title`;case`sshAuth`:return`desktopHostSwitcher.sshError.sshAuth.title`;case`sshUnreachable`:return`desktopHostSwitcher.sshError.sshUnreachable.title`;case`timeout`:return`desktopHostSwitcher.sshError.timeout.title`;default:return`desktopHostSwitcher.sshError.unknown.title`}},G=e=>{switch(e){case`nodeRuntimeMissing`:return`desktopHostSwitcher.sshError.nodeRuntimeMissing.guidance`;case`packageManagerMissing`:return`desktopHostSwitcher.sshError.packageManagerMissing.guidance`;case`nativeBinding`:return`desktopHostSwitcher.sshError.nativeBinding.guidance`;case`openchamberInstall`:return`desktopHostSwitcher.sshError.openchamberInstall.guidance`;case`opencodeInstall`:return`desktopHostSwitcher.sshError.opencodeInstall.guidance`;case`serverStart`:return`desktopHostSwitcher.sshError.serverStart.guidance`;case`sshAuth`:return`desktopHostSwitcher.sshError.sshAuth.guidance`;case`sshUnreachable`:return`desktopHostSwitcher.sshError.sshUnreachable.guidance`;case`timeout`:return`desktopHostSwitcher.sshError.timeout.guidance`;default:return`desktopHostSwitcher.sshError.unknown.guidance`}},K=f();function Ye(e){let t=(0,D.c)(17),{errorCode:n,detail:r,className:i}=e,{t:a}=y(),o,s,c,l;if(t[0]!==i||t[1]!==r||t[2]!==n||t[3]!==a){let e=U(n,r);t[8]===i?c=t[9]:(c=w(`space-y-1`,i),t[8]=i,t[9]=c),l=(0,K.jsx)(`p`,{className:`typography-ui-label text-[var(--status-error)]`,children:a(W(e))}),o=`typography-meta text-muted-foreground`,s=a(G(e)),t[0]=i,t[1]=r,t[2]=n,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else o=t[4],s=t[5],c=t[6],l=t[7];let u;t[10]!==o||t[11]!==s?(u=(0,K.jsx)(`p`,{className:o,children:s}),t[10]=o,t[11]=s,t[12]=u):u=t[12];let d;return t[13]!==c||t[14]!==l||t[15]!==u?(d=(0,K.jsxs)(`div`,{className:c,children:[l,u]}),t[13]=c,t[14]=l,t[15]=u,t[16]=d):d=t[16],d}var Xe=`/auth/passkey/authenticate/options`,Ze=`/auth/passkey/authenticate/verify`,Qe=`/auth/passkey/register/options`,$e=`/auth/passkey/register/verify`,q=`/api/passkeys`,et=`/auth/passkey/status`,tt=`/api/auth/reset`,nt={enabled:!1,hasPasskeys:!1,passkeyCount:0,rpID:null},J=async(e,t)=>i(e,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:t===void 0?void 0:JSON.stringify(t)}),Y=async(e,t)=>{try{let t=await e.json();if(t&&typeof t.error==`string`&&t.error.trim())return t.error}catch{}return t},rt=e=>e instanceof ae&&e.code===`ERROR_CEREMONY_ABORTED`,it=()=>{se.cancelCeremony()},X=()=>typeof window>`u`?{supported:!1,reason:`Passkeys are unavailable outside the browser.`}:window.isSecureContext?{supported:!0,reason:``}:{supported:!1,reason:`Passkeys require HTTPS or localhost.`},at=async()=>{let e=X();if(!e.supported)throw Error(e.reason);let t=await J(Qe,{label:typeof navigator.userAgent==`string`&&navigator.userAgent.trim()?navigator.userAgent:`This device`});if(!t.ok)throw Error(await Y(t,`Could not start passkey setup.`));let{requestId:n,optionsJSON:r}=await t.json(),i=await J($e,{requestId:n,response:await oe({optionsJSON:r})});if(!i.ok)throw Error(await Y(i,`Could not finish passkey setup.`));return i.json().catch(()=>null)},ot=async(e,t={})=>{let n=X();if(!n.supported)throw Error(n.reason);let r=await J(Xe);if(!r.ok)throw Error(await Y(r,`Passkey sign-in is not available right now.`));let{requestId:i,optionsJSON:a}=await r.json(),o=await J(Ze,{requestId:i,response:await ce({optionsJSON:a}),trustDevice:e,issueClientToken:t.issueClientToken===!0,clientLabel:t.clientLabel,clientKind:t.clientKind,dedupeKey:t.dedupeKey});if(!o.ok)throw Error(await Y(o,`Passkey sign-in failed.`));return o.json().catch(()=>null)},st=async()=>{let e=await i(et,{method:`GET`,credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return nt;let t=await e.json().catch(()=>null);return{enabled:t?.enabled===!0,hasPasskeys:t?.hasPasskeys===!0,passkeyCount:typeof t?.passkeyCount==`number`?t.passkeyCount:0,rpID:typeof t?.rpID==`string`&&t.rpID?t.rpID:null}},ct=async()=>{let e=await i(q,{method:`GET`,credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(await Y(e,`Could not load passkeys.`));let t=await e.json().catch(()=>null);return Array.isArray(t?.passkeys)?t.passkeys:[]},lt=async e=>{let t=await i(`${q}/${encodeURIComponent(e)}`,{method:`DELETE`,credentials:`include`,headers:{Accept:`application/json`}});if(!t.ok)throw Error(await Y(t,`Could not remove passkey.`));return t.json().catch(()=>null)},ut=async()=>{let e=await J(tt);if(!e.ok)throw Error(await Y(e,`Could not clear saved authentication.`));return e.json().catch(()=>null)},Z=e(p(),1);function dt(e){let t=(0,D.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=w(`bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,K.jsx)(`div`,{"data-slot":`card`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function ft(e){let t=(0,D.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=w(`@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,K.jsx)(`div`,{"data-slot":`card-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function pt(e){let t=(0,D.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=w(`leading-none font-semibold`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,K.jsx)(`div`,{"data-slot":`card-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function mt(e){let t=(0,D.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=w(`px-6`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,K.jsx)(`div`,{"data-slot":`card-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var ht=class extends Z.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){this.setState({error:e,errorInfo:t,copied:!1}),console.error(`Error caught by boundary:`,e,t)}handleReset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})};handleCopy=async()=>{let{strings:e}=this.props,t=`${this.state.error?String(this.state.error):e.unknownError}${this.state.error?.stack?`\n\nStack:\n${this.state.error.stack}`:``}${this.state.errorInfo?.componentStack?`\n\n${e.componentStackLabel}${this.state.errorInfo.componentStack}`:``}`;(await b(t)).ok&&(this.setState({copied:!0}),window.setTimeout(()=>{this.setState(e=>e.copied?{copied:!1}:null)},1500))};render(){let{strings:e}=this.props;return this.state.hasError?this.props.fallback?this.props.fallback:(0,K.jsx)(`div`,{className:`p-4 flex items-center justify-center min-h-screen`,children:(0,K.jsxs)(dt,{className:`w-full max-w-md`,children:[(0,K.jsx)(ft,{className:`text-center`,children:(0,K.jsxs)(pt,{className:`flex items-center justify-center gap-2 text-destructive`,children:[(0,K.jsx)(T,{name:`error-warning`,className:`h-5 w-5`}),e.title]})}),(0,K.jsxs)(mt,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground text-center`,children:e.description}),this.state.error&&(0,K.jsxs)(`details`,{className:`text-xs font-mono bg-muted p-3 rounded`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer hover:bg-interactive-hover/80`,children:e.detailsSummary}),(0,K.jsxs)(`pre`,{className:`mt-2 max-h-48 overflow-auto`,children:[this.state.error.toString(),this.state.errorInfo?.componentStack?`\n\n${e.componentStackLabel}${this.state.errorInfo.componentStack}`:``]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(E,{onClick:this.handleReset,variant:`outline`,className:`flex-1`,children:[(0,K.jsx)(T,{name:`restart`,className:`h-4 w-4 mr-2`}),e.tryAgain]}),(0,K.jsx)(E,{onClick:this.handleCopy,variant:`outline`,className:`flex-1`,children:this.state.copied?e.copied:e.copy})]})]})]})}):this.props.children}},gt=e=>{let t=(0,D.c)(29),{children:n,fallback:r}=e,{t:i}=y(),a;t[0]===i?a=t[1]:(a=i(`errorBoundary.state.unknownError`),t[0]=i,t[1]=a);let o;t[2]===i?o=t[3]:(o=i(`errorBoundary.title`),t[2]=i,t[3]=o);let s;t[4]===i?s=t[5]:(s=i(`errorBoundary.description`),t[4]=i,t[5]=s);let c;t[6]===i?c=t[7]:(c=i(`errorBoundary.actions.errorDetails`),t[6]=i,t[7]=c);let l;t[8]===i?l=t[9]:(l=i(`errorBoundary.state.componentStackLabel`),t[8]=i,t[9]=l);let u;t[10]===i?u=t[11]:(u=i(`errorBoundary.actions.tryAgain`),t[10]=i,t[11]=u);let d;t[12]===i?d=t[13]:(d=i(`errorBoundary.actions.copied`),t[12]=i,t[13]=d);let f;t[14]===i?f=t[15]:(f=i(`errorBoundary.actions.copy`),t[14]=i,t[15]=f);let p;t[16]!==a||t[17]!==o||t[18]!==s||t[19]!==c||t[20]!==l||t[21]!==u||t[22]!==d||t[23]!==f?(p={unknownError:a,title:o,description:s,detailsSummary:c,componentStackLabel:l,tryAgain:u,copied:d,copy:f},t[16]=a,t[17]=o,t[18]=s,t[19]=c,t[20]=l,t[21]=u,t[22]=d,t[23]=f,t[24]=p):p=t[24];let m=p,h;return t[25]!==n||t[26]!==r||t[27]!==m?(h=(0,K.jsx)(ht,{fallback:r,strings:m,children:n}),t[25]=n,t[26]=r,t[27]=m,t[28]=h):h=t[28],h},Q=e=>te(ee.getState().dictionary,e),_t=e=>typeof e!=`number`||!Number.isFinite(e)?null:Math.max(0,Math.min(100,Math.round(e))),vt=e=>typeof e!=`number`||!Number.isFinite(e)?`-`:`${Math.round(e)}%`,yt=(e,t)=>e??vt(t),bt=(e,t,n=`auto`)=>{if(!e)return t??``;try{let r=new Date(e);if(!Number.isFinite(r.getTime()))return t??``;let i=new Date;return r.toDateString()===i.toDateString()?ue(r,n,{fallback:t??``}):le(r,n,{month:`short`,day:`numeric`,weekday:`short`,hour:`numeric`,minute:`2-digit`})}catch{return t??``}},xt=e=>e===null?`safe`:e>=80?`critical`:e>=50?`warn`:`safe`,St=e=>e===`5h`?Q(`quota.window.5h`):e===`7d`?Q(`quota.window.7d`):e===`7d-sonnet`?Q(`quota.window.7dSonnet`):e===`7d-opus`?Q(`quota.window.7dOpus`):e===`weekly`?Q(`quota.window.weekly`):e===`daily`?Q(`quota.window.daily`):e===`monthly`?Q(`quota.window.monthly`):e===`credits`?Q(`quota.window.credits`):e===`credits_balance`?Q(`quota.window.creditsBalance`):e===`billing_cycle`?Q(`quota.window.billingCycle`):e===`auto`?Q(`quota.window.auto`):e===`api`?Q(`quota.window.api`):e===`plan_limit`?Q(`quota.window.planLimit`):e===`on_demand`?Q(`quota.window.onDemand`):e===`session`?Q(`quota.window.session`):e===`premium`?Q(`quota.window.premium`):e===`chat`?Q(`quota.window.chat`):e===`completions`?Q(`quota.window.completions`):e===`premium_interactions`?Q(`quota.window.premiumInteractions`):e,Ct=e=>{let t=e.toLowerCase().trim();if(t===`5h`)return 18e3;if(t===`7d`||t===`weekly`||t===`7d-sonnet`||t===`7d-opus`)return 604800;if(t===`monthly`)return 2592e3;if(t===`24h`||t===`daily`)return 86400;if(t===`1h`)return 3600;let n=t.match(/^(\d+)h$/);if(n)return parseInt(n[1],10)*3600;let r=t.match(/^(\d+)d$/);return r?parseInt(r[1],10)*86400:null},wt=(e,t,n,r)=>{let i=n;if(i===null&&r&&(i=Ct(r)),e===null||t===null||i===null||i<=0)return null;let a=Math.max(0,(t-Date.now())/1e3),o=Math.max(0,Math.min(i,i-a)),s=Math.max(0,Math.min(1,o/i)),c=e/100,l=e>=100&&a>0,u;u=s>.01?Math.min(999,c/s*100):e;let d;d=l?`exhausted`:c<=s?`on-track`:u<=130?`slightly-fast`:`too-fast`;let f=i>=432e3,p=f?86400:3600,m=f?`d`:`h`,h=i/p,g=e/Math.max(o/p,h*.01),_=Number.isFinite(g)?`${Math.min(999.9,Math.max(0,g)).toFixed(1)}%/${m}`:`-`,v=u>100?`+${Math.round(u)}%`:`${Math.round(u)}%`,y=null,b=i/86400;return b>=7&&(y=100/b),{elapsedRatio:s,usageRatio:c,predictedFinalPercent:u,remainingSeconds:a,isExhausted:l,elapsedSeconds:o,totalSeconds:i,status:d,paceRateText:_,predictText:v,dailyAllocationPercent:y}},Tt=e=>{switch(e){case`exhausted`:case`too-fast`:return`var(--status-error)`;case`slightly-fast`:return`var(--status-warning)`;case`on-track`:return`var(--status-success)`}},Et=e=>{let t=Math.floor(Math.max(0,Math.floor(e))/60),n=Math.floor(t/60),r=Math.floor(n/24),i=n%24,a=t%60;return r>0?`${r}d ${i}h`:n>0?`${n}h`:t===0?`<1m`:`${a}m`},Dt=e=>Math.min(100,Math.max(0,e*100)),Ot=[`standalone`,`minimal-ui`,`fullscreen`,`window-controls-overlay`],kt=`openchamber.pwaRecentSessions`,At=e=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(display-mode: ${e})`).matches,jt=()=>typeof window>`u`?`browser`:typeof document<`u`&&document.referrer.startsWith(`android-app://`)?`twa`:window.navigator.standalone?`standalone`:Ot.find(e=>At(e))??`browser`,Mt=864e5,Nt=5,Pt=864e5,$=e=>e.time?.updated??e.time?.created??0,Ft=({sessions:e,currentSessionId:t,cutoffDays:n,keepRecent:r=Nt,now:i=Date.now()})=>{if(!Array.isArray(e)||n<=0)return[];let a=i-n*Mt,o=[...e].sort((e,t)=>$(t)-$(e)),s=new Set(o.slice(0,r).map(e=>e.id));return o.filter(e=>{if(!e?.id||s.has(e.id)||e.id===t||e.share)return!1;let n=$(e);return n?n<a:!1}).map(e=>e.id)},It=e=>{let t=typeof e==`object`?e:void 0,r=t?.autoRun!==!1,i=typeof e==`boolean`?e:t?.enabled??!0,a=re(e=>e.currentSessionId),o=re(e=>e.isLoading),s=x(e=>e.activeSessions),c=x(e=>e.hasLoadedFullCatalog),l=n(e=>e.autoDeleteEnabled),u=n(e=>e.autoDeleteAfterDays),d=n(e=>e.sessionRetentionAction),f=n(e=>e.autoDeleteLastRunAt),p=n(e=>e.setAutoDeleteLastRunAt),[h,g]=Z.useState(!1),_=Z.useRef(!1);Z.useEffect(()=>{if(!i||!r||!l||u<=0)return;let e=window.setTimeout(()=>{C(S())},8e3);return()=>window.clearTimeout(e)},[u,l,r,i]);let v=Z.useMemo(()=>u<=0?[]:Ft({sessions:s,currentSessionId:a,cutoffDays:u}),[u,a,s]),y=Z.useCallback(async({force:e=!1}={})=>{if(_.current)return{completedIds:[],failedIds:[],action:d,skippedReason:`running`};if((!l||u<=0)&&!e)return{completedIds:[],failedIds:[],action:d,skippedReason:`disabled`};if(o)return{completedIds:[],failedIds:[],action:d,skippedReason:`loading`};let t=Date.now();if(!e&&f&&t-f<Pt)return{completedIds:[],failedIds:[],action:d,skippedReason:`cooldown`};let{activeSessions:n}=await C(S());if(n.length===0)return{completedIds:[],failedIds:[],action:d,skippedReason:`no-candidates`};let r=Ft({sessions:n,currentSessionId:a,cutoffDays:u,now:t});if(r.length===0)return p(t),{completedIds:[],failedIds:[],action:d,skippedReason:`no-candidates`};_.current=!0,g(!0);try{let e=new Map(n.map(e=>[e.id,e])),t=[],i=[];for(let n of r){let r=e.get(n),a=r?ne(r):null;if(!a){i.push(n);continue}try{d===`archive`?await m.updateSession(n,{time:{archived:Date.now()}},a):await m.deleteSession(n,a),t.push(n)}catch{i.push(n)}}return d===`archive`?x.getState().archiveSessions(t):x.getState().removeSessions(t),{completedIds:t,failedIds:i,action:d}}finally{_.current=!1,g(!1),p(Date.now())}},[u,l,f,a,o,d,p]);return Z.useEffect(()=>{i&&r&&(!l||u<=0||o||!c||s.length===0||f&&Date.now()-f<Pt||y())},[u,l,f,r,i,c,s.length,o,y]),{candidates:v,isRunning:h,runCleanup:y,keepRecentCount:Nt,action:d}};export{G as A,we as B,X as C,lt as D,ut as E,He as F,Be as G,Ae as H,Ue as I,Ve as J,Re as K,We as L,Me as M,Ce as N,Ye as O,De as P,ge as Q,Oe as R,ct as S,at as T,je as U,Te as V,ke as W,me as X,Ge as Y,he as Z,pt as _,wt as a,nt as b,yt as c,Tt as d,xt as f,ft as g,mt as h,Dt as i,W as j,U as k,Et as l,dt as m,kt as n,_t as o,gt as p,ze as q,jt as r,bt as s,It as t,St as u,ot as v,rt as w,st as x,it as y,Ee as z};
@@ -1,4 +1,4 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{_ as t}from"./useUIStore-BJpkPwky.js";import{$t as n,kn as r,xn as i}from"./persistence-DwXJK4-j.js";import{nt as a,rt as o}from"./vendor-base-ui-CnHfUmDN.js";import{n as s}from"./platform-CXJwZIZe.js";import{a as c,n as l}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as u}from"./vendor-react-DLPElpoQ.js";import{n as d}from"./clipboard-BvJ7NunE.js";import{t as f}from"./utils-DfPDhqys.js";import{n as p}from"./Icon-BhSwbLaF.js";import{t as m}from"./button-BQY5ugjh.js";import{i as h,n as g,t as _}from"./tooltip-rN8LrxMF.js";import{n as v}from"./useThemeSystem-DMzWVJaW.js";import{c as y,n as b,o as x,r as S,s as C}from"./markdownTheme-BdF4C4-o.js";import{i as w}from"./appThemeRegistry-BfC78Ze-.js";import{d as T,n as E,t as D,u as ee}from"./markdown-worker-C5Om4TVK.js";import{t as te}from"./vendor-tanstack-react-virtual-tlDgH6PG.js";var O=e(o(),1),k=u(),A=a(),ne=`w-[min(30rem,calc(100cqw-1rem))] min-w-[280px] max-w-full overflow-hidden rounded-xl shadow-[inset_0_1px_0_0_rgba(255,255,255,0.8),inset_0_0_0_1px_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.10),0_1px_2px_-0.5px_rgba(0,0,0,0.08),0_4px_8px_-2px_rgba(0,0,0,0.08),0_12px_20px_-4px_rgba(0,0,0,0.08)] dark:shadow-[inset_0_1px_0_0_rgba(255,255,255,0.12),inset_0_0_0_1px_rgba(255,255,255,0.08),0_0_0_1px_rgba(0,0,0,0.36),0_1px_1px_-0.5px_rgba(0,0,0,0.22),0_3px_3px_-1.5px_rgba(0,0,0,0.20),0_6px_6px_-3px_rgba(0,0,0,0.16)]`,j={maxWidth:`min(28rem, calc(100cqw - 4ch))`,backgroundColor:`var(--surface-elevated)`,color:`var(--surface-elevated-foreground)`},M=`flex items-center justify-between gap-3 border-b border-[var(--surface-subtle)] px-3 py-2.5`,N=`text-xs font-medium leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,re=`text-xs tabular-nums leading-4 text-muted-foreground md:text-[0.8125rem] md:leading-5`,P=`m-0 list-none divide-y divide-[var(--surface-subtle)] p-0`,F=`${P} max-h-[min(22rem,50vh)] overflow-y-auto`,ie=`${P} w-full`,ae={className:`p-0 rounded-none`,maxHeightClass:`max-h-[46vh]`,disableHorizontal:!0},I=`px-2.5 py-1.5 text-xs leading-4 md:py-2 md:text-[0.8125rem] md:leading-5`,oe=`flex min-w-0 items-center gap-1 text-xs leading-4 text-muted-foreground md:gap-1.5 md:text-[0.8125rem] md:leading-5`,se=`min-w-0 truncate text-xs leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,ce=`inline-flex shrink-0 items-center gap-1 text-xs leading-4 tabular-nums text-muted-foreground md:text-[0.8125rem] md:leading-5`,le=`h-3 w-3 shrink-0 md:h-3.5 md:w-3.5`,ue={in_progress:`text-foreground`,pending:`text-foreground`,completed:`text-muted-foreground line-through`,cancelled:`text-muted-foreground line-through`},L={in_progress:`chat.statusRow.todo.status.inProgress`,pending:`chat.statusRow.todo.status.pending`,completed:`chat.statusRow.todo.status.completed`,cancelled:`chat.statusRow.todo.status.cancelled`},R=e=>{let t=(0,k.c)(26),{todo:n,isActive:r,activeRef:i}=e,{t:a}=d(),o=z.has(n.status)?n.status:`pending`,s=L[o],c;t[0]!==a||t[1]!==s?(c=a(s),t[0]=a,t[1]=s,t[2]=c):c=t[2];let l=c,u;t[3]===o?u=t[4]:(u=o===`in_progress`?(0,A.jsx)(p,{name:`record-circle`,className:`h-3.5 w-3.5 text-[var(--status-info)]`,"aria-hidden":`true`}):o===`completed`?(0,A.jsx)(p,{name:`checkbox-circle`,className:`h-3.5 w-3.5 text-[var(--status-success)]`,"aria-hidden":`true`}):(0,A.jsx)(p,{name:`time`,className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),t[3]=o,t[4]=u);let m=u,v=r?`step`:void 0,y=r&&`bg-[var(--surface-muted)] before:absolute before:inset-y-2 before:left-0 before:w-0.5 before:rounded-full before:bg-[var(--status-info)]`,b;t[5]===y?b=t[6]:(b=f(`group relative grid min-w-0 grid-cols-[1rem_minmax(0,1fr)] items-start gap-2.5`,I,y),t[5]=y,t[6]=b);let x;t[7]!==m||t[8]!==l?(x=(0,A.jsx)(h,{asChild:!0,children:(0,A.jsx)(`span`,{className:`flex size-4 items-center justify-center`,"aria-label":l,children:m})}),t[7]=m,t[8]=l,t[9]=x):x=t[9];let S;t[10]===l?S=t[11]:(S=(0,A.jsx)(g,{side:`left`,sideOffset:6,children:l}),t[10]=l,t[11]=S);let C;t[12]!==x||t[13]!==S?(C=(0,A.jsxs)(_,{children:[x,S]}),t[12]=x,t[13]=S,t[14]=C):C=t[14];let w=ue[o],T;t[15]===w?T=t[16]:(T=f(`block whitespace-normal break-words`,w),t[15]=w,t[16]=T);let E;t[17]!==T||t[18]!==n.content?(E=(0,A.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,A.jsx)(`span`,{className:T,children:n.content})}),t[17]=T,t[18]=n.content,t[19]=E):E=t[19];let D;return t[20]!==i||t[21]!==E||t[22]!==v||t[23]!==b||t[24]!==C?(D=(0,A.jsxs)(`li`,{ref:i,"aria-current":v,className:b,children:[C,E]}),t[20]=i,t[21]=E,t[22]=v,t[23]=b,t[24]=C,t[25]=D):D=t[25],D},z=new Set([`in_progress`,`pending`,`completed`,`cancelled`]),B=`image/png`,V=c(`OpenChamberMedia`),H=e=>{let t=e.toLowerCase().split(`;`)[0]?.trim()||B;if(t===`image/jpeg`||t===`image/jpg`)return`jpg`;if(t===`image/webp`)return`webp`;if(t===`image/gif`)return`gif`;if(t===`image/svg+xml`)return`svg`;if(t===`image/png`)return`png`;let n=t.split(`/`)[1];return n&&/^[a-z0-9.+-]+$/i.test(n)?n:`png`},U=(e,t)=>{let n=`image.${H(t)}`,r=(((e||``).trim()||n).split(/[\\/]/).pop()||n).replace(/[^\w.\- ()[\]]+/g,`_`).replace(/^\.+/,``);return r?/\.[a-z0-9]{1,8}$/i.test(r)?r:`${r}.${H(t)}`:n},W=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{if(typeof r.result==`string`){t(r.result);return}n(Error(`Failed to encode image`))},r.onerror=()=>n(r.error??Error(`Failed to encode image`)),r.readAsDataURL(e)}),de=async e=>{let t=await W(e),n=t.indexOf(`,`);return n>=0?t.slice(n+1):t},fe=(e,t)=>{let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.setTimeout(()=>URL.revokeObjectURL(n),1e3)},G=async(e,t)=>{let n=await fetch(e,{signal:t,cache:`no-store`});if(!n.ok)throw Error(`Image fetch failed (${n.status})`);return n.blob()},pe=async(e,t=B)=>{if(!e.naturalWidth||!e.naturalHeight)return null;let n=e.currentSrc||e.src;if(n&&(/^(?:blob:|data:|openchamber-asset:)/i.test(n)||/^https?:/i.test(n)||/^\/api(?=\/|[?#]|$)/.test(n)))try{let e=await G(n);if(e.size>0)return e}catch{}try{let n=document.createElement(`canvas`);n.width=e.naturalWidth,n.height=e.naturalHeight;let r=n.getContext(`2d`);if(!r)return null;r.drawImage(e,0,0);let i=t.startsWith(`image/`)?t:B,a=await new Promise(e=>{n.toBlob(t=>e(t),i===`image/jpg`?`image/jpeg`:i)});return a&&a.size>0?a:null}catch{return null}},me=async(e,t)=>{let n=``;try{return n=await S(e,t??new AbortController().signal),await G(n,t)}finally{n&&C(n)}},he=async(e,t)=>{let n=e.effectiveDirectory??``,i=null;e.prefetchedBlob&&e.prefetchedBlob.size>0&&(i=e.prefetchedBlob);let a=e.displayUrl?.trim();if(!i&&a)try{i=await G(a,t)}catch{i=null}if(!i){let a=e.sourceUrl.trim();if(!a)throw Error(`Image source is empty`);if(/^(?:data|blob):/i.test(a)||/^https?:/i.test(a)||/^\/api(?=\/|[?#]|$)/.test(a))i=await G(a,t);else{let e=y(a,n);if(x(e))try{i=await me(e.path,t)}catch{let n=await r(`/api/fs/raw`,{method:`GET`,cache:`no-store`,query:{path:e.path},signal:t});if(!n.ok)throw Error(`Image source request failed with status ${n.status}`);i=await n.blob()}else i=await G(e.source,t)}}if(!i||i.size<=0)throw Error(`Image is empty`);let o=(e.mimeType||(i.type&&i.type.startsWith(`image/`)?i.type:``)||B).split(`;`)[0].trim()||B;return{blob:i,filename:U(e.filename,o),mimeType:o}},ge=()=>!s()||l===void 0?!1:l.isPluginAvailable(`OpenChamberMedia`),_e=async(e,t)=>{let{blob:r,filename:a,mimeType:o}=await he(e,t);if(ge()){let e=await de(r);return await V.saveImage({dataBase64:e,mimeType:o,filename:a}),`saved`}if(n()){let e=i()?.vscode;if(e?.saveImage){let t=await W(r);return await e.saveImage({fileName:a,dataUrl:t}),`saved`}}return fe(r,a),`downloaded`},ve=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`),ye=e=>e?Object.entries(e).map(([e,t])=>t==null?``:`${e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}:${typeof t==`number`?`${t}px`:t};`).join(``):``,K=(e,t,n)=>{let r=e.querySelector(`pre`);r&&(r.style.margin=`0`,r.style.background=`transparent`,r.style.whiteSpace=t?`pre-wrap`:`pre`,t&&(r.style.wordBreak=`break-word`,r.style.overflowWrap=`break-word`));let i=e.querySelector(`code`);if(i){let e=ye(n);e&&i.setAttribute(`style`,`${i.getAttribute(`style`)??``}${e}`)}},be=e=>`<pre><code>${ve(e)}</code></pre>`,xe=e=>{let t=(0,k.c)(21),{code:n,language:r,className:i,style:a,codeStyle:o,wrap:s}=e,c=s!==void 0&&s,{currentTheme:l}=v(),u=O.useRef(null),d;t[0]===l?d=t[1]:(d=b(l),t[0]=l,t[1]=d);let p=d,m,h;t[2]!==n||t[3]!==o||t[4]!==c?(m=()=>{let e=u.current;e&&(e.innerHTML=be(n),K(e,c,o))},h=[n,c,o],t[2]=n,t[3]=o,t[4]=c,t[5]=m,t[6]=h):(m=t[5],h=t[6]),O.useLayoutEffect(m,h);let g,_;t[7]!==n||t[8]!==o||t[9]!==r||t[10]!==c?(g=()=>{let e=u.current;if(!e)return;let t=!0,i=new AbortController;return D(n,(r||`text`).toLowerCase(),{signal:i.signal,priority:`visible`}).then(n=>{!t||!e||!n||(e.innerHTML=n,K(e,c,o))}),()=>{t=!1,i.abort()}},_=[n,r,c,o],t[7]=n,t[8]=o,t[9]=r,t[10]=c,t[11]=g,t[12]=_):(g=t[11],_=t[12]),O.useEffect(g,_);let y;t[13]===i?y=t[14]:(y=f(`typography-code`,i),t[13]=i,t[14]=y);let x=p,S;t[15]!==a||t[16]!==x?(S={...x,...a},t[15]=a,t[16]=x,t[17]=S):S=t[17];let C;return t[18]!==y||t[19]!==S?(C=(0,A.jsx)(`div`,{ref:u,className:y,style:S}),t[18]=y,t[19]=S,t[20]=C):C=t[20],C},Se=e=>{let t=e.replace(/^<file>\s*\n?/,``).replace(/\n?<\/file>\s*$/,``);return t=t.replace(/^\s*\d{5}\|\s?/gm,``),t.trim()},Ce=(e,t=``)=>{if(typeof e==`string`)return e;if(e==null)return t;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)}catch{return t}},we=e=>e?e.includes(`<diagnostics`)||e.includes(`<file_diagnostics>`)||e.includes(`LSP errors detected`)||e.includes(`This file has errors`):!1,Te=e=>e?e.replace(/\n{0,2}LSP errors detected[\s\S]*?<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/\n{0,2}This file has errors[\s\S]*?<\/file_diagnostics>/g,``).replace(/<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/<file_diagnostics>[\s\S]*?<\/file_diagnostics>/g,``).trim():``,Ee=(e,t)=>!e||typeof e!=`object`?String(e):T(e,t||``),q=e=>{if(typeof e==`string`){let t=e.trim();return t.length>0?t:void 0}if(e&&typeof e==`object`){let t=e.patch;if(typeof t==`string`){let e=t.trim();return e.length>0?e:void 0}}},De=e=>{if(!e||typeof e!=`object`)return;let t=q(e.patch)??q(e.diff);if(t)return t;let n=Array.isArray(e.files)?e.files:[];for(let e of n){if(!e||typeof e!=`object`)continue;let t=q(e.patch)??q(e.diff);if(t)return t}},Oe=e=>{if(!e||typeof e!=`string`)return{data:null,isJson:!1};let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`)||!t.endsWith(`}`)&&!t.endsWith(`]`)||t.length<2)return{data:null,isJson:!1};try{let e=JSON.parse(t);return typeof e==`object`&&e?{data:e,isJson:!0}:{data:null,isJson:!1}}catch{return{data:null,isJson:!1}}},ke=(e,t,n)=>{let r=Se(e);if((t===`edit`||t===`multiedit`||t===`write`||t===`apply_patch`)&&we(r)&&(r=Te(r)),(t===`edit`||t===`multiedit`||t===`apply_patch`)&&r.trim().length===0){let e=De(n);if(e)return e}return r},Ae=e=>{let t=e.match(/<type>(file|directory)<\/type>/i)?.[1]?.toLowerCase()??`unknown`,n=(e.match(/<content>([\s\S]*?)<\/content>/i)?.[1]??e).replace(/\r\n/g,`
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{_ as t}from"./useUIStore-BJpkPwky.js";import{$t as n,kn as r,xn as i}from"./persistence-DwXJK4-j.js";import{nt as a,rt as o}from"./vendor-base-ui-CnHfUmDN.js";import{n as s}from"./platform-CXJwZIZe.js";import{a as c,n as l}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as u}from"./vendor-react-DLPElpoQ.js";import{n as d}from"./clipboard-BvJ7NunE.js";import{t as f}from"./utils-DfPDhqys.js";import{n as p}from"./Icon-BhSwbLaF.js";import{t as m}from"./button-KTZJ84Mx.js";import{i as h,n as g,t as _}from"./tooltip-rN8LrxMF.js";import{n as v}from"./useThemeSystem-DMzWVJaW.js";import{c as y,n as b,o as x,r as S,s as C}from"./markdownTheme-BdF4C4-o.js";import{i as w}from"./appThemeRegistry-Ii1BsWpN.js";import{d as T,n as E,t as D,u as ee}from"./markdown-worker-C5Om4TVK.js";import{t as te}from"./vendor-tanstack-react-virtual-tlDgH6PG.js";var O=e(o(),1),k=u(),A=a(),ne=`w-[min(30rem,calc(100cqw-1rem))] min-w-[280px] max-w-full overflow-hidden rounded-xl shadow-[inset_0_1px_0_0_rgba(255,255,255,0.8),inset_0_0_0_1px_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.10),0_1px_2px_-0.5px_rgba(0,0,0,0.08),0_4px_8px_-2px_rgba(0,0,0,0.08),0_12px_20px_-4px_rgba(0,0,0,0.08)] dark:shadow-[inset_0_1px_0_0_rgba(255,255,255,0.12),inset_0_0_0_1px_rgba(255,255,255,0.08),0_0_0_1px_rgba(0,0,0,0.36),0_1px_1px_-0.5px_rgba(0,0,0,0.22),0_3px_3px_-1.5px_rgba(0,0,0,0.20),0_6px_6px_-3px_rgba(0,0,0,0.16)]`,j={maxWidth:`min(28rem, calc(100cqw - 4ch))`,backgroundColor:`var(--surface-elevated)`,color:`var(--surface-elevated-foreground)`},M=`flex items-center justify-between gap-3 border-b border-[var(--surface-subtle)] px-3 py-2.5`,N=`text-xs font-medium leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,re=`text-xs tabular-nums leading-4 text-muted-foreground md:text-[0.8125rem] md:leading-5`,P=`m-0 list-none divide-y divide-[var(--surface-subtle)] p-0`,F=`${P} max-h-[min(22rem,50vh)] overflow-y-auto`,ie=`${P} w-full`,ae={className:`p-0 rounded-none`,maxHeightClass:`max-h-[46vh]`,disableHorizontal:!0},I=`px-2.5 py-1.5 text-xs leading-4 md:py-2 md:text-[0.8125rem] md:leading-5`,oe=`flex min-w-0 items-center gap-1 text-xs leading-4 text-muted-foreground md:gap-1.5 md:text-[0.8125rem] md:leading-5`,se=`min-w-0 truncate text-xs leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,ce=`inline-flex shrink-0 items-center gap-1 text-xs leading-4 tabular-nums text-muted-foreground md:text-[0.8125rem] md:leading-5`,le=`h-3 w-3 shrink-0 md:h-3.5 md:w-3.5`,ue={in_progress:`text-foreground`,pending:`text-foreground`,completed:`text-muted-foreground line-through`,cancelled:`text-muted-foreground line-through`},L={in_progress:`chat.statusRow.todo.status.inProgress`,pending:`chat.statusRow.todo.status.pending`,completed:`chat.statusRow.todo.status.completed`,cancelled:`chat.statusRow.todo.status.cancelled`},R=e=>{let t=(0,k.c)(26),{todo:n,isActive:r,activeRef:i}=e,{t:a}=d(),o=z.has(n.status)?n.status:`pending`,s=L[o],c;t[0]!==a||t[1]!==s?(c=a(s),t[0]=a,t[1]=s,t[2]=c):c=t[2];let l=c,u;t[3]===o?u=t[4]:(u=o===`in_progress`?(0,A.jsx)(p,{name:`record-circle`,className:`h-3.5 w-3.5 text-[var(--status-info)]`,"aria-hidden":`true`}):o===`completed`?(0,A.jsx)(p,{name:`checkbox-circle`,className:`h-3.5 w-3.5 text-[var(--status-success)]`,"aria-hidden":`true`}):(0,A.jsx)(p,{name:`time`,className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),t[3]=o,t[4]=u);let m=u,v=r?`step`:void 0,y=r&&`bg-[var(--surface-muted)] before:absolute before:inset-y-2 before:left-0 before:w-0.5 before:rounded-full before:bg-[var(--status-info)]`,b;t[5]===y?b=t[6]:(b=f(`group relative grid min-w-0 grid-cols-[1rem_minmax(0,1fr)] items-start gap-2.5`,I,y),t[5]=y,t[6]=b);let x;t[7]!==m||t[8]!==l?(x=(0,A.jsx)(h,{asChild:!0,children:(0,A.jsx)(`span`,{className:`flex size-4 items-center justify-center`,"aria-label":l,children:m})}),t[7]=m,t[8]=l,t[9]=x):x=t[9];let S;t[10]===l?S=t[11]:(S=(0,A.jsx)(g,{side:`left`,sideOffset:6,children:l}),t[10]=l,t[11]=S);let C;t[12]!==x||t[13]!==S?(C=(0,A.jsxs)(_,{children:[x,S]}),t[12]=x,t[13]=S,t[14]=C):C=t[14];let w=ue[o],T;t[15]===w?T=t[16]:(T=f(`block whitespace-normal break-words`,w),t[15]=w,t[16]=T);let E;t[17]!==T||t[18]!==n.content?(E=(0,A.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,A.jsx)(`span`,{className:T,children:n.content})}),t[17]=T,t[18]=n.content,t[19]=E):E=t[19];let D;return t[20]!==i||t[21]!==E||t[22]!==v||t[23]!==b||t[24]!==C?(D=(0,A.jsxs)(`li`,{ref:i,"aria-current":v,className:b,children:[C,E]}),t[20]=i,t[21]=E,t[22]=v,t[23]=b,t[24]=C,t[25]=D):D=t[25],D},z=new Set([`in_progress`,`pending`,`completed`,`cancelled`]),B=`image/png`,V=c(`OpenChamberMedia`),H=e=>{let t=e.toLowerCase().split(`;`)[0]?.trim()||B;if(t===`image/jpeg`||t===`image/jpg`)return`jpg`;if(t===`image/webp`)return`webp`;if(t===`image/gif`)return`gif`;if(t===`image/svg+xml`)return`svg`;if(t===`image/png`)return`png`;let n=t.split(`/`)[1];return n&&/^[a-z0-9.+-]+$/i.test(n)?n:`png`},U=(e,t)=>{let n=`image.${H(t)}`,r=(((e||``).trim()||n).split(/[\\/]/).pop()||n).replace(/[^\w.\- ()[\]]+/g,`_`).replace(/^\.+/,``);return r?/\.[a-z0-9]{1,8}$/i.test(r)?r:`${r}.${H(t)}`:n},W=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{if(typeof r.result==`string`){t(r.result);return}n(Error(`Failed to encode image`))},r.onerror=()=>n(r.error??Error(`Failed to encode image`)),r.readAsDataURL(e)}),de=async e=>{let t=await W(e),n=t.indexOf(`,`);return n>=0?t.slice(n+1):t},fe=(e,t)=>{let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.setTimeout(()=>URL.revokeObjectURL(n),1e3)},G=async(e,t)=>{let n=await fetch(e,{signal:t,cache:`no-store`});if(!n.ok)throw Error(`Image fetch failed (${n.status})`);return n.blob()},pe=async(e,t=B)=>{if(!e.naturalWidth||!e.naturalHeight)return null;let n=e.currentSrc||e.src;if(n&&(/^(?:blob:|data:|openchamber-asset:)/i.test(n)||/^https?:/i.test(n)||/^\/api(?=\/|[?#]|$)/.test(n)))try{let e=await G(n);if(e.size>0)return e}catch{}try{let n=document.createElement(`canvas`);n.width=e.naturalWidth,n.height=e.naturalHeight;let r=n.getContext(`2d`);if(!r)return null;r.drawImage(e,0,0);let i=t.startsWith(`image/`)?t:B,a=await new Promise(e=>{n.toBlob(t=>e(t),i===`image/jpg`?`image/jpeg`:i)});return a&&a.size>0?a:null}catch{return null}},me=async(e,t)=>{let n=``;try{return n=await S(e,t??new AbortController().signal),await G(n,t)}finally{n&&C(n)}},he=async(e,t)=>{let n=e.effectiveDirectory??``,i=null;e.prefetchedBlob&&e.prefetchedBlob.size>0&&(i=e.prefetchedBlob);let a=e.displayUrl?.trim();if(!i&&a)try{i=await G(a,t)}catch{i=null}if(!i){let a=e.sourceUrl.trim();if(!a)throw Error(`Image source is empty`);if(/^(?:data|blob):/i.test(a)||/^https?:/i.test(a)||/^\/api(?=\/|[?#]|$)/.test(a))i=await G(a,t);else{let e=y(a,n);if(x(e))try{i=await me(e.path,t)}catch{let n=await r(`/api/fs/raw`,{method:`GET`,cache:`no-store`,query:{path:e.path},signal:t});if(!n.ok)throw Error(`Image source request failed with status ${n.status}`);i=await n.blob()}else i=await G(e.source,t)}}if(!i||i.size<=0)throw Error(`Image is empty`);let o=(e.mimeType||(i.type&&i.type.startsWith(`image/`)?i.type:``)||B).split(`;`)[0].trim()||B;return{blob:i,filename:U(e.filename,o),mimeType:o}},ge=()=>!s()||l===void 0?!1:l.isPluginAvailable(`OpenChamberMedia`),_e=async(e,t)=>{let{blob:r,filename:a,mimeType:o}=await he(e,t);if(ge()){let e=await de(r);return await V.saveImage({dataBase64:e,mimeType:o,filename:a}),`saved`}if(n()){let e=i()?.vscode;if(e?.saveImage){let t=await W(r);return await e.saveImage({fileName:a,dataUrl:t}),`saved`}}return fe(r,a),`downloaded`},ve=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`),ye=e=>e?Object.entries(e).map(([e,t])=>t==null?``:`${e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}:${typeof t==`number`?`${t}px`:t};`).join(``):``,K=(e,t,n)=>{let r=e.querySelector(`pre`);r&&(r.style.margin=`0`,r.style.background=`transparent`,r.style.whiteSpace=t?`pre-wrap`:`pre`,t&&(r.style.wordBreak=`break-word`,r.style.overflowWrap=`break-word`));let i=e.querySelector(`code`);if(i){let e=ye(n);e&&i.setAttribute(`style`,`${i.getAttribute(`style`)??``}${e}`)}},be=e=>`<pre><code>${ve(e)}</code></pre>`,xe=e=>{let t=(0,k.c)(21),{code:n,language:r,className:i,style:a,codeStyle:o,wrap:s}=e,c=s!==void 0&&s,{currentTheme:l}=v(),u=O.useRef(null),d;t[0]===l?d=t[1]:(d=b(l),t[0]=l,t[1]=d);let p=d,m,h;t[2]!==n||t[3]!==o||t[4]!==c?(m=()=>{let e=u.current;e&&(e.innerHTML=be(n),K(e,c,o))},h=[n,c,o],t[2]=n,t[3]=o,t[4]=c,t[5]=m,t[6]=h):(m=t[5],h=t[6]),O.useLayoutEffect(m,h);let g,_;t[7]!==n||t[8]!==o||t[9]!==r||t[10]!==c?(g=()=>{let e=u.current;if(!e)return;let t=!0,i=new AbortController;return D(n,(r||`text`).toLowerCase(),{signal:i.signal,priority:`visible`}).then(n=>{!t||!e||!n||(e.innerHTML=n,K(e,c,o))}),()=>{t=!1,i.abort()}},_=[n,r,c,o],t[7]=n,t[8]=o,t[9]=r,t[10]=c,t[11]=g,t[12]=_):(g=t[11],_=t[12]),O.useEffect(g,_);let y;t[13]===i?y=t[14]:(y=f(`typography-code`,i),t[13]=i,t[14]=y);let x=p,S;t[15]!==a||t[16]!==x?(S={...x,...a},t[15]=a,t[16]=x,t[17]=S):S=t[17];let C;return t[18]!==y||t[19]!==S?(C=(0,A.jsx)(`div`,{ref:u,className:y,style:S}),t[18]=y,t[19]=S,t[20]=C):C=t[20],C},Se=e=>{let t=e.replace(/^<file>\s*\n?/,``).replace(/\n?<\/file>\s*$/,``);return t=t.replace(/^\s*\d{5}\|\s?/gm,``),t.trim()},Ce=(e,t=``)=>{if(typeof e==`string`)return e;if(e==null)return t;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)}catch{return t}},we=e=>e?e.includes(`<diagnostics`)||e.includes(`<file_diagnostics>`)||e.includes(`LSP errors detected`)||e.includes(`This file has errors`):!1,Te=e=>e?e.replace(/\n{0,2}LSP errors detected[\s\S]*?<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/\n{0,2}This file has errors[\s\S]*?<\/file_diagnostics>/g,``).replace(/<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/<file_diagnostics>[\s\S]*?<\/file_diagnostics>/g,``).trim():``,Ee=(e,t)=>!e||typeof e!=`object`?String(e):T(e,t||``),q=e=>{if(typeof e==`string`){let t=e.trim();return t.length>0?t:void 0}if(e&&typeof e==`object`){let t=e.patch;if(typeof t==`string`){let e=t.trim();return e.length>0?e:void 0}}},De=e=>{if(!e||typeof e!=`object`)return;let t=q(e.patch)??q(e.diff);if(t)return t;let n=Array.isArray(e.files)?e.files:[];for(let e of n){if(!e||typeof e!=`object`)continue;let t=q(e.patch)??q(e.diff);if(t)return t}},Oe=e=>{if(!e||typeof e!=`string`)return{data:null,isJson:!1};let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`)||!t.endsWith(`}`)&&!t.endsWith(`]`)||t.length<2)return{data:null,isJson:!1};try{let e=JSON.parse(t);return typeof e==`object`&&e?{data:e,isJson:!0}:{data:null,isJson:!1}}catch{return{data:null,isJson:!1}}},ke=(e,t,n)=>{let r=Se(e);if((t===`edit`||t===`multiedit`||t===`write`||t===`apply_patch`)&&we(r)&&(r=Te(r)),(t===`edit`||t===`multiedit`||t===`apply_patch`)&&r.trim().length===0){let e=De(n);if(e)return e}return r},Ae=e=>{let t=e.match(/<type>(file|directory)<\/type>/i)?.[1]?.toLowerCase()??`unknown`,n=(e.match(/<content>([\s\S]*?)<\/content>/i)?.[1]??e).replace(/\r\n/g,`
2
2
  `).split(`
3
3
  `),r=e=>/\(\s*File has more lines\..*offset.*\)/i.test(e.trim());return{type:t,lines:n.map(e=>{let n=e.trim(),i=n.startsWith(`(`)&&n.endsWith(`)`)||r(n);if(t!==`directory`){let t=e.match(/^(\d+):\s?(.*)$/);if(t){let e=t[2],n=e.trim(),i=n.startsWith(`(`)&&n.endsWith(`)`)||r(n);return{lineNumber:i?null:Number(t[1]),text:e,isInfo:i}}}return{lineNumber:null,text:e,isInfo:i}}).filter((e,t,n)=>{if(e.text.trim().length>0)return!0;let r=n[t-1],i=n[t+1],a=!!(r?.isInfo||i?.isInfo),o=e.lineNumber!==null;return!(a&&o)})}},je=(e,n)=>{try{let r=e.trim().split(`
4
4
  `).filter(Boolean);if(r.length===0)return null;let i=[];return r.forEach(e=>{let t=e.match(/^(\s*)(.+)$/);if(t){let[,e,n]=t,r=Math.floor(e.length/2),a=!n.endsWith(`/`);i.push({name:n.replace(/\/$/,``),depth:r,isFile:a})}}),(0,A.jsx)(`div`,{className:f(`w-full min-w-0 font-mono space-y-0.5`,n?.unstyled?null:`p-3 bg-muted/20 rounded-xl border border-border/30`),style:t.tool.popup,children:i.map((e,t)=>(0,A.jsx)(`div`,{className:`min-w-0`,style:{paddingLeft:`${e.depth*20}px`},children:e.isFile?(0,A.jsx)(`span`,{className:`text-foreground/90 block truncate`,children:e.name}):(0,A.jsxs)(`span`,{className:`font-semibold text-foreground block truncate`,children:[e.name,`/`]})},t))})}catch{return null}},Me={backgroundColor:`var(--status-info)`,opacity:.6},Ne=(e,n,r)=>{try{let i=e.trim().split(`
package/dist/index.html CHANGED
@@ -552,7 +552,7 @@
552
552
  opacity: 0.72;
553
553
  }
554
554
  </style>
555
- <script type="module" crossorigin src="/assets/main-D9qBzZpU.js"></script>
555
+ <script type="module" crossorigin src="/assets/main-hWnOf28D.js"></script>
556
556
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-C0FnF6B9.js">
557
557
  <link rel="modulepreload" crossorigin href="/assets/vendor-base-ui-CnHfUmDN.js">
558
558
  <link rel="modulepreload" crossorigin href="/assets/vendor-zustand-B4dlGEM2.js">
@@ -569,8 +569,8 @@
569
569
  <link rel="modulepreload" crossorigin href="/assets/terminalApi-jfes-HIU.js">
570
570
  <link rel="modulepreload" crossorigin href="/assets/types-BuiqMmh_.js">
571
571
  <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DCowZ2ab.js">
572
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-CTI932Qg.js">
573
- <link rel="stylesheet" crossorigin href="/assets/src-DF4hiLrB.css">
572
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-CfCsNs7j.js">
573
+ <link rel="stylesheet" crossorigin href="/assets/src-CV_a1GoP.css">
574
574
  </head>
575
575
  <body class="h-full bg-background text-foreground">
576
576
  <!-- Keep the startup layer outside #root. React replaces every child of
@@ -74,7 +74,7 @@
74
74
  }
75
75
  </style>
76
76
 
77
- <script type="module" crossorigin src="/assets/miniChat-B7g3gXRa.js"></script>
77
+ <script type="module" crossorigin src="/assets/miniChat-D_XI2D45.js"></script>
78
78
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-C0FnF6B9.js">
79
79
  <link rel="modulepreload" crossorigin href="/assets/vendor-base-ui-CnHfUmDN.js">
80
80
  <link rel="modulepreload" crossorigin href="/assets/vendor-zustand-B4dlGEM2.js">
@@ -91,8 +91,8 @@
91
91
  <link rel="modulepreload" crossorigin href="/assets/terminalApi-jfes-HIU.js">
92
92
  <link rel="modulepreload" crossorigin href="/assets/types-BuiqMmh_.js">
93
93
  <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DCowZ2ab.js">
94
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-CTI932Qg.js">
95
- <link rel="stylesheet" crossorigin href="/assets/src-DF4hiLrB.css">
94
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-CfCsNs7j.js">
95
+ <link rel="stylesheet" crossorigin href="/assets/src-CV_a1GoP.css">
96
96
  </head>
97
97
  <body class="h-full bg-background text-foreground">
98
98
  <div id="root" class="h-full">
package/dist/mobile.html CHANGED
@@ -63,7 +63,7 @@
63
63
  })();
64
64
  </script>
65
65
 
66
- <script type="module" crossorigin src="/assets/mobile-I5gQEcaR.js"></script>
66
+ <script type="module" crossorigin src="/assets/mobile-DoZizfm3.js"></script>
67
67
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-C0FnF6B9.js">
68
68
  <link rel="modulepreload" crossorigin href="/assets/vendor-base-ui-CnHfUmDN.js">
69
69
  <link rel="modulepreload" crossorigin href="/assets/vendor-zustand-B4dlGEM2.js">
@@ -80,8 +80,8 @@
80
80
  <link rel="modulepreload" crossorigin href="/assets/terminalApi-jfes-HIU.js">
81
81
  <link rel="modulepreload" crossorigin href="/assets/types-BuiqMmh_.js">
82
82
  <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DCowZ2ab.js">
83
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-CTI932Qg.js">
84
- <link rel="stylesheet" crossorigin href="/assets/src-DF4hiLrB.css">
83
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-CfCsNs7j.js">
84
+ <link rel="stylesheet" crossorigin href="/assets/src-CV_a1GoP.css">
85
85
  </head>
86
86
  <body class="h-full bg-background text-foreground">
87
87
  <div id="root" class="h-full"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openchambery/web",
3
- "version": "1.18.4-beta.3",
3
+ "version": "1.18.4-beta.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./server/index.js",
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{D as t,t as n}from"./useUIStore-BJpkPwky.js";import{Xt as r,d as i,kn as a,u as o,xn as s}from"./persistence-DwXJK4-j.js";import{A as c,D as l,E as u,F as d,I as f,M as p,N as m,P as h,j as g,k as _,nt as v,rt as y,tt as b}from"./vendor-base-ui-CnHfUmDN.js";import{n as x}from"./vendor-react-DLPElpoQ.js";import{s as S}from"./vendor-tanstack-react-query-D7pys_c9.js";import{P as C,V as w,a as T,f as E,l as D}from"./vendor-codemirror-autocomplete-DHomsvW7.js";import{c as O,o as k,r as A}from"./vendor-codemirror-lang-angular-DShkBD6m.js";import{n as j,r as M}from"./vendor-codemirror-lang-json-CYJRHck9.js";import{n as N}from"./vendor-codemirror-lang-markdown-WORgx6ZD.js";import{n as P}from"./vendor-codemirror-lang-python-Du6XQ8Zw.js";import{O as F}from"./vendor-codemirror-legacy-modes-DuRAjNvB.js";import{n as I}from"./vendor-reactuses-core-DDoDDyM9.js";import{n as ee,r as te}from"./clipboard-BvJ7NunE.js";import{Qa as ne,Xa as re,_o as ie,ia as L,ro as ae}from"./useMobileNavigationStore-DtVJ24rj.js";import{t as R}from"./AgentAvatar-BvhXxFvg.js";import{s as z,t as B}from"./utils-DfPDhqys.js";import{n as V}from"./Icon-BhSwbLaF.js";import{t as H}from"./button-BQY5ugjh.js";import{A as oe,C as U,E as W,O as G,T as K,k as se,w as q}from"./projectMeta-A8_j9NDY.js";import{t as ce}from"./input-CgIoxUJc.js";import{t as le}from"./useThemeSystem-DMzWVJaW.js";import{i as ue}from"./OverlayScrollbar-CXFN6Cqq.js";import{t as de}from"./vendor-codemirror-language-data-BfYFhIH1.js";var J=e(y(),1),Y=v(),fe=[.2,.45,.15,.55,.35,.1,.5,.25,.4,.3,.45,.15,.55,.2,.35,.1],pe=[.3,.15,.45,.25,.5,.35,.1,.4,.2,.55,.3,.15,.45,.25,.4,.2],me=(e,t,n,r,i=4)=>{let a=[];for(let o=0;o<i;o++)for(let s=0;s<i;s++){let c=s/i,l=(s+1)/i,u=o/i,d=(o+1)/i,f=(e,t,n)=>e+(t-e)*n,p=(e,t,n,r,i,a)=>{let o=f(e,t,i),s=f(r,n,i);return f(o,s,a)},m={x:p(e.x,t.x,n.x,r.x,c,u),y:p(e.y,t.y,n.y,r.y,c,u)},h={x:p(e.x,t.x,n.x,r.x,l,u),y:p(e.y,t.y,n.y,r.y,l,u)},g={x:p(e.x,t.x,n.x,r.x,l,d),y:p(e.y,t.y,n.y,r.y,l,d)},_={x:p(e.x,t.x,n.x,r.x,c,d),y:p(e.y,t.y,n.y,r.y,c,d)};a.push({path:`M${m.x} ${m.y} L${h.x} ${h.y} L${g.x} ${g.y} L${_.x} ${_.y} Z`,row:o,col:s})}return a},he=({className:e=``,width:t=70,height:n=70,isAnimated:r=!1})=>{let{t:i}=ee(),a=le(),o=!0;a?o=a.currentTheme.metadata.variant!==`light`:typeof window<`u`&&(o=window.matchMedia(`(prefers-color-scheme: dark)`).matches);let s=(0,J.useMemo)(()=>{if(a)return a.currentTheme.colors.surface.foreground;if(typeof window<`u`){let e=getComputedStyle(document.documentElement).getPropertyValue(`--splash-stroke`).trim();if(e)return e}return o?`white`:`black`},[a,o]),c=(0,J.useMemo)(()=>typeof window>`u`||typeof CSS>`u`||typeof CSS.supports!=`function`?!1:CSS.supports(`color`,`color-mix(in srgb, white 50%, transparent)`),[]),l=(0,J.useMemo)(()=>{if(a)return c?`color-mix(in srgb, ${s} 15%, transparent)`:o?`rgba(255,255,255,0.15)`:`rgba(0,0,0,0.15)`;if(typeof window<`u`){let e=getComputedStyle(document.documentElement).getPropertyValue(`--splash-face-fill`).trim();if(e)return e}return o?`rgba(255,255,255,0.15)`:`rgba(0,0,0,0.15)`},[a,c,s,o]),u=(0,J.useMemo)(()=>{if(a)return c?`color-mix(in srgb, ${s} 35%, transparent)`:o?`rgba(255,255,255,0.35)`:`rgba(0,0,0,0.4)`;if(typeof window<`u`){let e=getComputedStyle(document.documentElement).getPropertyValue(`--splash-cell-fill`).trim();if(e)return e}return o?`rgba(255,255,255,0.35)`:`rgba(0,0,0,0.4)`},[a,c,s,o]),d=s,f=.866,p=.5,m={x:50,y:2},h={x:50-48*f,y:50-48*p},g={x:91.568,y:50-48*p},_={x:50,y:50},v={x:50-48*f,y:74},y={x:91.568,y:74},b={x:50,y:98},x=`matrix(0.866, 0.5, -0.866, 0.5, 50, ${(m.y+h.y+_.y+g.y)/4})`,S=me(h,_,b,v),C=me(_,g,y,b);return(0,Y.jsxs)(`svg`,{width:t,height:n,viewBox:`0 0 100 100`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,className:e,role:`img`,"aria-label":i(`openChamberLogo.aria.logo`),children:[r?(0,Y.jsx)(`style`,{children:`@keyframes oc-logo-glow{0%,100%{filter:drop-shadow(0 0 0 transparent)}50%{filter:drop-shadow(0 0 4px var(--oc-glow-color))}}.oc-logo-glow{animation:oc-logo-glow 1.8s ease-in-out infinite}@media (prefers-reduced-motion:reduce){.oc-logo-glow{animation:none}}`}):null,(0,Y.jsx)(`path`,{d:`M${_.x} ${_.y} L${h.x} ${h.y} L${v.x} ${v.y} L${b.x} ${b.y} Z`,fill:l,stroke:s,strokeWidth:`2`,strokeLinejoin:`round`}),S.map((e,t)=>(0,Y.jsx)(`path`,{d:e.path,fill:u,opacity:fe[e.row*4+(3-e.col)]??.35},`left-${t}`)),(0,Y.jsx)(`path`,{d:`M${_.x} ${_.y} L${g.x} ${g.y} L${y.x} ${y.y} L${b.x} ${b.y} Z`,fill:l,stroke:s,strokeWidth:`2`,strokeLinejoin:`round`}),C.map((e,t)=>(0,Y.jsx)(`path`,{d:e.path,fill:u,opacity:pe[e.row*4+e.col]??.35},`right-${t}`)),(0,Y.jsx)(`path`,{d:`M${m.x} ${m.y} L${h.x} ${h.y} L${_.x} ${_.y} L${g.x} ${g.y} Z`,fill:`none`,stroke:s,strokeWidth:`2`,strokeLinejoin:`round`}),(0,Y.jsx)(`g`,{opacity:1,className:r?`oc-logo-glow`:void 0,style:r?{"--oc-glow-color":s}:void 0,children:(0,Y.jsxs)(`g`,{transform:`${x} scale(0.75)`,children:[(0,Y.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M-16 -20 L16 -20 L16 20 L-16 20 Z M-8 -12 L-8 12 L8 12 L8 -12 Z`,fill:d}),(0,Y.jsx)(`path`,{d:`M-8 -4 L8 -4 L8 12 L-8 12 Z`,fill:d,fillOpacity:`0.4`})]})})]})},X=x(),ge=e(b(),1),Z=0,_e=()=>{Z=Date.now()+800},Q=()=>Date.now()<Z,ve=`__unassigned__`,ye={mod:`mod`,shift:`shift`,alt:`alt`,option:`alt`,ctrl:`ctrl`,meta:`mod`,cmd:`mod`,command:`mod`},be={mod:z()&&r()?`⌘`:`Ctrl`,shift:`⇧`,alt:`⌥`,option:`⌥`,ctrl:`⌃`},xe={comma:`,`,period:`.`,enter:`Enter`,escape:`Esc`,tab:`Tab`,space:`Space`,backspace:`⌫`,delete:`⌦`,arrowup:`↑`,arrowdown:`↓`,arrowleft:`←`,arrowright:`→`,home:`Home`,end:`End`,pageup:`Page Up`,pagedown:`Page Down`,backtick:"`",grave:"`","=":`=`,equal:`=`,plus:`+`,minus:`-`,"-":`-`},Se=[`mod`,`ctrl`,`shift`,`alt`],Ce={"{":`[`,"}":`]`,":":`;`,'"':`'`,"<":`,`,">":`.`,"?":`/`,"|":`\\`,"~":"`","!":`1`,"@":`2`,"#":`3`,$:`4`,"%":`5`,"^":`6`,"&":`7`,"*":`8`,"(":`9`,")":`0`};function $(e){return e.trim().toLowerCase()===ve}function we(e){let t=e.toLowerCase();return t===`,`?`comma`:t===`.`?`period`:t===` `?`space`:t===`esc`?`escape`:t===`+`?`plus`:t===`-`||t===`_`?`minus`:t===`arrowup`?`arrowup`:t===`arrowdown`?`arrowdown`:t===`arrowleft`?`arrowleft`:t===`arrowright`?`arrowright`:t==="`"?`backtick`:Ce[t]??t}var Te=[{id:`open_go_to_line`,defaultCombo:`alt+g`,label:`Go to line (files editor)`,description:`Open go to line in the files editor`,customizable:!0},{id:`open_command_palette`,defaultCombo:`mod+p`,label:`Open command palette`,description:`Open the command palette`,customizable:!0},{id:`focus_input`,defaultCombo:`mod+i`,label:`Focus input`,description:`Focus the chat input field`,customizable:!0},{id:`open_status`,defaultCombo:`mod+shift+o`,label:`Open OpenCode status`,description:`Open the OpenCode status dialog`},{id:`open_settings`,defaultCombo:`mod+comma`,label:`Open settings`,description:`Open the settings panel`,customizable:!0},{id:`toggle_terminal`,defaultCombo:`ctrl+backtick`,label:`Toggle terminal`,description:`Toggle the integrated terminal`,customizable:!0},{id:`toggle_bottom_panel`,defaultCombo:`mod+j`,label:`Toggle bottom panel`,description:`Toggle the bottom panel dock`,customizable:!0},{id:`toggle_terminal_expanded`,defaultCombo:`mod+shift+j`,label:`Toggle terminal expanded`,description:`Toggle terminal expanded or collapsed`,customizable:!0},{id:`new_terminal_tab`,defaultCombo:`mod+t`,label:`New terminal tab`,description:`Create a new terminal tab when the terminal is focused`,customizable:!0},{id:`open_new_terminal`,defaultCombo:`mod+shift+backtick`,label:`Open new terminal`,description:`Open the terminal panel and create a new terminal tab`,customizable:!0},{id:`previous_terminal_tab`,defaultCombo:`mod+shift+[`,label:`Previous terminal tab`,description:`Switch to the previous terminal tab when the terminal is focused`,customizable:!0},{id:`next_terminal_tab`,defaultCombo:`mod+shift+]`,label:`Next terminal tab`,description:`Switch to the next terminal tab when the terminal is focused`,customizable:!0},{id:`toggle_files`,defaultCombo:`mod+shift+f`,label:`Toggle files`,description:`Toggle the files panel`},{id:`toggle_sidebar`,defaultCombo:`mod+b`,label:`Toggle sidebar`,description:`Toggle the session sidebar`,customizable:!0},{id:`open_timeline_dialog`,defaultCombo:`mod+t`,label:`Open conversation timeline`,description:`Search and navigate within current conversation`,customizable:!0},{id:`toggle_prompt_navigator`,defaultCombo:`mod+alt+p`,label:`Toggle prompt navigator`,description:`Show or hide the prompt navigator panel in chat`,customizable:!0},{id:`toggle_right_sidebar`,defaultCombo:`mod+alt+b`,defaultAliases:[`mod+\\`],label:`Toggle review panel`,description:`Toggle the review panel (right sidebar)`,customizable:!0},{id:`open_right_sidebar_git`,defaultCombo:`mod+shift+g`,label:`Open right sidebar Git tab`,description:`Open right sidebar and select Git`,customizable:!0},{id:`open_right_sidebar_files`,defaultCombo:`mod+shift+f`,label:`Open right sidebar Files tab`,description:`Open right sidebar and select Files`,customizable:!0},{id:`cycle_right_sidebar_tab`,defaultCombo:`mod+alt+shift+r`,label:`Cycle right sidebar tab`,description:`Cycle through right sidebar tabs`,customizable:!0},{id:`close_context_panel_tab`,defaultCombo:`mod+w`,label:`Close context panel tab`,description:`Close the active context panel tab (closes the panel when empty)`,customizable:!0},{id:`previous_session`,defaultCombo:`mod+shift+[`,defaultAliases:[`mod+arrowup`],label:`Previous session`,description:`Switch to the previous session`,customizable:!0},{id:`next_session`,defaultCombo:`mod+shift+]`,defaultAliases:[`mod+arrowdown`],label:`Next session`,description:`Switch to the next session`,customizable:!0},{id:`new_chat`,defaultCombo:`mod+n`,label:`New session`,description:`Start a new session`,customizable:!0},{id:`new_chat_worktree`,defaultCombo:`mod+shift+alt+n`,label:`New worktree draft`,description:`Create a new worktree and open a draft in it`,customizable:!0},{id:`new_mini_chat`,defaultCombo:`mod+alt+n`,label:`New Mini Chat window`,description:`Open a new Mini Chat draft window`,customizable:!0},{id:`submit_message`,defaultCombo:`mod+enter`,label:`Submit message`,description:`Submit the current message`},{id:`clear_input`,defaultCombo:`escape`,label:`Clear input`,description:`Clear the input field`},{id:`clear_all_messages`,defaultCombo:`ctrl+c`,label:`Clear all messages`,description:`Clear the composer input and queued messages`,customizable:!0},{id:`open_diff_panel`,defaultCombo:`mod+2`,label:`Open diff panel`,description:`Switch to the diff panel`},{id:`open_terminal_panel`,defaultCombo:`mod+3`,label:`Open terminal panel`,description:`Switch to the terminal panel`},{id:`open_git_panel`,defaultCombo:`mod+4`,label:`Open git panel`,description:`Switch to the git panel`},{id:`open_help`,defaultCombo:`mod+.`,label:`Open keyboard shortcuts`,description:`Show the keyboard shortcuts help`,customizable:!0},{id:`toggle_context_plan`,defaultCombo:`mod+shift+p`,label:`Toggle plan context panel`,description:`Open or close plan in the context panel`,customizable:!0},{id:`toggle_services_menu`,defaultCombo:`mod+shift+s`,label:`Toggle services menu`,description:`Open or close the services menu`,customizable:!0},{id:`open_usage`,defaultCombo:`mod+shift+c`,label:`Open usage`,description:`Open the usage panel`,customizable:!0},{id:`cycle_services_tab`,defaultCombo:`mod+alt+shift+s`,label:`Cycle services tab`,description:`Cycle through tabs in the services menu`,customizable:!0},{id:`cycle_theme`,defaultCombo:`mod+/`,label:`Cycle theme`,description:`Cycle between light, dark, and system theme`,customizable:!0},{id:`zoom_in`,defaultCombo:`mod+=`,label:`Zoom in`,description:`Increase the webview zoom level`,customizable:!0},{id:`zoom_out`,defaultCombo:`mod+-`,label:`Zoom out`,description:`Decrease the webview zoom level`,customizable:!0},{id:`zoom_reset`,defaultCombo:`mod+0`,label:`Reset zoom`,description:`Reset the webview zoom level to 100%`,customizable:!0},{id:`leader_key`,defaultCombo:`ctrl+x`,label:`Leader key`,description:`Start an OpenCode-style chord, then press M / A / N / C`,customizable:!0},{id:`open_model_selector`,defaultCombo:`mod+shift+m`,label:`Open model selector`,description:`Open model selector while in chat`,customizable:!0},{id:`cycle_thinking_variant`,defaultCombo:`mod+shift+t`,label:`Cycle thinking variant`,description:`Cycle thinking variant while in chat`},{id:`cycle_agent`,defaultCombo:`tab`,label:`Cycle agent`,description:`Cycle agent while the model selector is open`,customizable:!0},{id:`cycle_favorite_model_forward`,defaultCombo:`ctrl+]`,label:`Cycle favorite model forward`,description:`Cycle forward through starred models without opening the picker`,customizable:!0},{id:`cycle_favorite_model_backward`,defaultCombo:`ctrl+[`,label:`Cycle favorite model backward`,description:`Cycle backward through starred models without opening the picker`,customizable:!0},{id:`expand_input`,defaultCombo:`mod+shift+e`,label:`Expand input`,description:`Toggle focus mode for the chat input`,customizable:!0},{id:`toggle_dictation`,defaultCombo:`mod+alt+v`,label:`Voice input`,description:`Start dictation; press again to confirm and insert the transcript`,customizable:!0},{id:`abort_run`,defaultCombo:`escape`,label:`Abort active run`,description:`Abort the currently running task (double press)`},{id:`switch_tab_1`,defaultCombo:`mod+1`,label:`Switch to visible session 1`,description:`Switch to the first visible sidebar session`},{id:`switch_tab_2`,defaultCombo:`mod+2`,label:`Switch to visible session 2`,description:`Switch to the second visible sidebar session`},{id:`switch_tab_3`,defaultCombo:`mod+3`,label:`Switch to visible session 3`,description:`Switch to the third visible sidebar session`},{id:`switch_tab_4`,defaultCombo:`mod+4`,label:`Switch to visible session 4`,description:`Switch to the fourth visible sidebar session`},{id:`switch_tab_5`,defaultCombo:`mod+5`,label:`Switch to visible session 5`,description:`Switch to the fifth visible sidebar session`},{id:`switch_tab_6`,defaultCombo:`mod+6`,label:`Switch to visible session 6`,description:`Switch to the sixth visible sidebar session`},{id:`switch_tab_7`,defaultCombo:`mod+7`,label:`Switch to visible session 7`,description:`Switch to the seventh visible sidebar session`},{id:`switch_tab_8`,defaultCombo:`mod+8`,label:`Switch to visible session 8`,description:`Switch to the eighth visible sidebar session`},{id:`switch_tab_9`,defaultCombo:`mod+9`,label:`Switch to visible session 9`,description:`Switch to the ninth visible sidebar session`}];function Ee(e){if($(e))return ve;let t=e.toLowerCase().trim().split(`+`).map(e=>e.trim()).filter(Boolean),n=new Set,r=``;for(let e of t){let t=e===`,`?`comma`:e===`.`?`period`:e,i=ye[t];if(i){n.add(i);continue}r=t}return[...Se.filter(e=>n.has(e)),r].filter(Boolean).join(`+`)}function De(e){return $(e)?!0:Oe(e).key.trim().length>0}function Oe(e){if($(e))return{modifiers:new Set,key:ve};let t=Ee(e).split(`+`),n=new Set,r=``;for(let e of t){let t=ye[e];t?n.add(t):r=e}return{modifiers:n,key:r}}function ke(e){if($(e))return`Unassigned`;let t=Oe(e);if(!t.key&&t.modifiers.size===0)return`Unassigned`;let n=[];for(let e of Se)t.modifiers.has(e)&&n.push(be[e]);if(t.key){let e=xe[t.key.toLowerCase()]||t.key.toUpperCase();n.push(e)}return n.join(` + `)}function Ae(e){return Te.find(t=>t.id===e)}function je(){return Te.filter(e=>e.customizable===!0)}function Me(e,t){let n=Ae(e);if(!n)return``;let r=t?.[e];if(typeof r==`string`){if(r.trim().toLowerCase()===`__unassigned__`)return``;let e=Ee(r);if(e===`__unassigned__`)return ve;if(De(e))return e}return n.defaultCombo}function Ne(e,t){let n=Ae(e);if(!n)return[];let r=Me(e,t);return r===n.defaultCombo?[n.defaultCombo,...n.defaultAliases??[]]:r?[r]:[]}function Pe(e){if($(e))return!1;let t=Oe(e);if(!t.modifiers.has(`mod`))return!1;let n=t.key.toLowerCase();return new Set([`w`,`t`,`r`,`p`,`s`,`f`,`l`,`n`]).has(n)&&!t.modifiers.has(`shift`)&&!t.modifiers.has(`alt`)}function Fe(e,t){let n=typeof t==`string`?t:t.defaultCombo;if($(n))return!1;let i=Oe(n),a=i.modifiers.has(`mod`),o=i.modifiers.has(`shift`),s=i.modifiers.has(`alt`),c=i.modifiers.has(`ctrl`),l=z()&&r(),u=z(),d=l?e.metaKey:u&&e.metaKey||e.ctrlKey;if(a&&!d||!a&&e.metaKey||o!==e.shiftKey||s!==e.altKey)return!1;if(c){if(!e.ctrlKey)return!1}else{let t=a&&!l&&e.ctrlKey;if(e.ctrlKey&&!t)return!1}let f=e.key;return(!f||f===`Dead`)&&e.code===`Backquote`&&(f="`"),e.altKey&&(e.code.startsWith(`Key`)&&e.code.length===4?f=e.code.slice(3).toLowerCase():e.code.startsWith(`Digit`)&&e.code.length===6&&(f=e.code.slice(5))),we(f)===we(i.key)}function Ie(){return z()&&r()?`⌘`:`Ctrl`}function Le(e,t,n){if(Fe(e,n))return!0;let i=Ee(n),a=z()&&r(),o=z();return!(a?e.metaKey:o&&e.metaKey||e.ctrlKey)||e.altKey||a&&e.ctrlKey&&!e.metaKey?!1:t===`in`&&i===`mod+=`?e.key===`+`||e.code===`NumpadAdd`:t===`out`&&(i===`mod+-`||i===`mod+minus`)?e.key===`_`||e.code===`NumpadSubtract`:!1}var Re=`app-region-no-drag transition-all duration-150 ease-out data-[starting-style]:opacity-0 data-[starting-style]:scale-95 data-[ending-style]:opacity-0 data-[ending-style]:scale-95 z-50 max-h-[var(--available-height)] min-w-[8rem] origin-[var(--transform-origin)] overflow-visible rounded-xl p-1 shadow-[inset_0_1px_0_0_rgba(255,255,255,0.8),inset_0_0_0_1px_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.10),0_1px_2px_-0.5px_rgba(0,0,0,0.08),0_4px_8px_-2px_rgba(0,0,0,0.08),0_12px_20px_-4px_rgba(0,0,0,0.08)] dark:shadow-[inset_0_1px_0_0_rgba(255,255,255,0.12),inset_0_0_0_1px_rgba(255,255,255,0.08),0_0_0_1px_rgba(0,0,0,0.36),0_1px_1px_-0.5px_rgba(0,0,0,0.22),0_3px_3px_-1.5px_rgba(0,0,0,0.20),0_6px_6px_-3px_rgba(0,0,0,0.16)]`,ze=`data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover data-[variant=destructive]:text-destructive data-[variant=destructive]:hover:bg-destructive/10 dark:data-[variant=destructive]:hover:bg-destructive/20 data-[variant=destructive]:hover:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1 typography-ui-label outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5`,Be=`data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1 typography-ui-label outline-hidden select-none data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5`,Ve=`bg-border -mx-1 my-0.5 h-px`,He=J.createContext(null),Ue=e=>e?e.closest(`[data-slot="dialog-content"], [role="dialog"]`):null;function We(e,t){return e&&J.isValidElement(t)?{render:t}:{children:t}}function Ge(e){let t=(0,X.c)(9),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let[r,i]=J.useState(null),a;t[2]===r?a=t[3]:(a={portalContainer:r,setPortalContainer:i},t[2]=r,t[3]=a);let o=a,s;t[4]===n?s=t[5]:(s=(0,Y.jsx)(_,{...n}),t[4]=n,t[5]=s);let c;return t[6]!==o||t[7]!==s?(c=(0,Y.jsx)(He.Provider,{value:o,children:s}),t[6]=o,t[7]=s,t[8]=c):c=t[8],c}function Ke(e){let t=(0,X.c)(22),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({asChild:n,children:r,onPointerDownCapture:a,onFocusCapture:i,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=J.useContext(He),c;t[6]===s?c=t[7]:(c=e=>{if(!s)return;let t=e instanceof HTMLElement?e:null;s.setPortalContainer(Ue(t))},t[6]=s,t[7]=c);let u=c,d;t[8]!==n||t[9]!==r?(d=We(n,r),t[8]=n,t[9]=r,t[10]=d):d=t[10];let f=d,p;t[11]!==a||t[12]!==u?(p=e=>{u(e.currentTarget),a?.(e)},t[11]=a,t[12]=u,t[13]=p):p=t[13];let m;t[14]!==i||t[15]!==u?(m=e=>{u(e.currentTarget),i?.(e)},t[14]=i,t[15]=u,t[16]=m):m=t[16];let h;return t[17]!==o||t[18]!==f||t[19]!==p||t[20]!==m?(h=(0,Y.jsx)(l,{"data-slot":`dropdown-menu-trigger`,onPointerDownCapture:p,onFocusCapture:m,...o,...f}),t[17]=o,t[18]=f,t[19]=p,t[20]=m,t[21]=h):h=t[21],h}function qe(e){let t=(0,X.c)(40),n,r,i,a,o,s,c,l,u,f,p,g,_;if(t[0]!==e){let{className:d,sideOffset:m,align:h,side:v,alignOffset:y,anchor:b,portalToBody:x,positionerClassName:S,style:C,children:w,onCloseAutoFocus:T,collisionPadding:E,collisionAvoidance:D,...O}=e;o=d,f=m,n=h,l=v,r=y,i=b,p=x,s=S,u=C,a=w,g=E,_=D,c=O,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=u,t[10]=f,t[11]=p,t[12]=g,t[13]=_}else n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],u=t[9],f=t[10],p=t[11],g=t[12],_=t[13];let v=f===void 0?4:f,y=p!==void 0&&p,b=g===void 0?8:g,x;t[14]===_?x=t[15]:(x=_===void 0?{side:`shift`,align:`shift`}:_,t[14]=_,t[15]=x);let S=x,C=J.useContext(He),w=y?void 0:C?.portalContainer||void 0,T;t[16]===s?T=t[17]:(T=B(`app-region-no-drag z-50`,s),t[16]=s,t[17]=T);let E;t[18]===u?E=t[19]:(E={backgroundColor:`var(--surface-elevated)`,color:`var(--surface-elevated-foreground)`,...u},t[18]=u,t[19]=E);let D;t[20]===o?D=t[21]:(D=B(Re,o),t[20]=o,t[21]=D);let O;t[22]!==a||t[23]!==c||t[24]!==E||t[25]!==D?(O=(0,Y.jsx)(d,{"data-slot":`dropdown-menu-content`,style:E,className:D,...c,children:a}),t[22]=a,t[23]=c,t[24]=E,t[25]=D,t[26]=O):O=t[26];let k;t[27]!==n||t[28]!==r||t[29]!==i||t[30]!==S||t[31]!==b||t[32]!==l||t[33]!==v||t[34]!==O||t[35]!==T?(k=(0,Y.jsx)(m,{anchor:i,sideOffset:v,align:n,side:l,alignOffset:r,collisionPadding:b,collisionAvoidance:S,className:T,children:O}),t[27]=n,t[28]=r,t[29]=i,t[30]=S,t[31]=b,t[32]=l,t[33]=v,t[34]=O,t[35]=T,t[36]=k):k=t[36];let A;return t[37]!==k||t[38]!==w?(A=(0,Y.jsx)(h,{container:w,children:k}),t[37]=k,t[38]=w,t[39]=A):A=t[39],A}function Je(e){let t=(0,X.c)(24),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({className:i,inset:a,variant:l,asChild:n,children:r,onSelect:s,onClick:o,...c}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u=l===void 0?`default`:l,d;t[9]!==n||t[10]!==r?(d=We(n,r),t[9]=n,t[10]=r,t[11]=d):d=t[11];let p=d,m;t[12]!==o||t[13]!==s?(m=e=>{o?.(e),e.defaultPrevented||s?.(e)},t[12]=o,t[13]=s,t[14]=m):m=t[14];let h=m,g;t[15]===i?g=t[16]:(g=B(ze,i),t[15]=i,t[16]=g);let _;return t[17]!==h||t[18]!==a||t[19]!==c||t[20]!==p||t[21]!==g||t[22]!==u?(_=(0,Y.jsx)(f,{"data-slot":`dropdown-menu-item`,"data-inset":a,"data-variant":u,className:g,...c,onClick:h,...p}),t[17]=h,t[18]=a,t[19]=c,t[20]=p,t[21]=g,t[22]=u,t[23]=_):_=t[23],_}function Ye(e){let t=(0,X.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Y.jsx)(p,{"data-slot":`dropdown-menu-radio-group`,...n}),t[2]=n,t[3]=r),r}function Xe(e){let t=(0,X.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=B(`data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover data-[checked]:bg-interactive-selection data-[checked]:text-interactive-selection-foreground relative flex cursor-pointer items-start gap-2 rounded-lg py-1 pl-2 pr-8 typography-ui-label outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5`,r),t[4]=r,t[5]=a);let o;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Y.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-3.5 items-center justify-center text-primary`,children:(0,Y.jsx)(c,{children:(0,Y.jsx)(V,{name:`check`,className:`size-3`})})}),t[6]=o):o=t[6];let s;return t[7]!==n||t[8]!==i||t[9]!==a?(s=(0,Y.jsxs)(g,{"data-slot":`dropdown-menu-radio-item`,className:a,...i,children:[o,n]}),t[7]=n,t[8]=i,t[9]=a,t[10]=s):s=t[10],s}function Ze(e){let t=(0,X.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,inset:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=B(`px-2 py-1 typography-ui-label font-medium data-[inset]:pl-8`,n),t[4]=n,t[5]=a);let o;return t[6]!==r||t[7]!==i||t[8]!==a?(o=(0,Y.jsx)(`div`,{"data-slot":`dropdown-menu-label`,"data-inset":r,className:a,...i}),t[6]=r,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function Qe(e){let t=(0,X.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=B(Ve,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Y.jsx)(u,{"data-slot":`dropdown-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var $e=(e,t)=>{let n=`flex min-h-0 flex-col bg-background shadow-none`;if(e===`page`)return`${n} h-full w-full`;let r=`${n} pwa-overlay-panel`;return t===`top`?`${r} mx-auto mb-auto max-h-[calc(100dvh-0.75rem)] w-full max-w-lg rounded-b-xl border-x border-b border-border/50`:t===`left`?`${r} h-full w-[min(86vw,24rem)] rounded-r-xl border-r border-y border-border/50`:t===`right`?`${r} ml-auto h-full w-[min(86vw,24rem)] rounded-l-xl border-l border-y border-border/50`:`${r} mx-auto mt-auto max-h-[calc(100dvh-0.75rem)] w-full max-w-lg rounded-t-2xl border-x border-t border-border/50 pb-[max(0.5rem,var(--oc-app-bottom-safe,0px),var(--oc-safe-area-bottom,env(safe-area-inset-bottom,0px)))]`},et=e=>Math.min(1,Math.max(0,Number.isFinite(e)?e:0)),tt=(e,t,n)=>{let r=Number.isFinite(t)&&t>0?t:1,i=Math.max(0,Number.isFinite(e)?e:0)/r,a=et(n[0]??1),o=Math.abs(i-a);for(let e=1;e<n.length;e+=1){let t=et(n[e]??a),r=Math.abs(i-t);r<o&&(a=t,o=r)}return a},nt=(e,t)=>{let n=et(t),r=`${(1-n)*100}%`;return{progress:n,scrimOpacity:n,surfaceOpacity:n,surfaceTransform:e===`left`?`translate3d(-${r}, 0, 0)`:e===`right`?`translate3d(${r}, 0, 0)`:e===`top`?`translate3d(0, -${r}, 0)`:`translate3d(0, ${r}, 0)`}},rt=(e,t)=>{let n=et(t);return e===`present`?n:1-n},it=(e,t)=>e===`present`?+(t===`commit`):t===`commit`?0:1,at=e=>+!!e,ot=.72,st=.98,ct=[ot,st],lt=180,ut=`cubic-bezier(0.32, 0.72, 0, 1)`,dt=64,ft=()=>Math.max(1,window.innerHeight),pt=(e,t,n=dt,r)=>e<=ht(t,r)-n,mt=(e,t,n)=>Math.min(t*st,Math.max(n?0:t*ot,e)),ht=(e,t)=>{let n=Math.max(1,e)*ot;return t==null||!Number.isFinite(t)?n:Math.min(n,Math.max(0,t))},gt=(e,t,n)=>{let r=ht(t,n),i=Math.max(1,t)*st;return Math.abs(e-r)<=Math.abs(e-i)?ot:st},_t=({initialSnapPoint:e=ot,fitContent:t=!1,onDismiss:n,dismissThresholdPx:r=dt}={})=>{let i=J.useRef(null),a=J.useRef(null),o=J.useRef(null),s=J.useRef(null),c=J.useRef(null),l=J.useRef(null),u=J.useRef(!1),[d,f]=J.useState(e),p=J.useRef(e),m=J.useRef(n);m.current=n;let h=J.useCallback(()=>{o.current!==null&&window.cancelAnimationFrame(o.current),o.current=null},[]),g=J.useCallback((e,n)=>{let r=i.current,a=p.current;if(p.current=e,f(e),h(),s.current=null,c.current?.cancel(),c.current=null,!r)return;let o=n??r.getBoundingClientRect().height;t&&a===.72&&l.current===null&&(l.current=ht(ft(),o));let u=e===.72?ht(ft(),t?l.current:void 0):ft()*st;if(r.style.height=``,r.style.willChange=``,Math.abs(o-u)<1||typeof r.animate!=`function`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let d=r.animate([{height:`${o}px`},{height:`${u}px`}],{duration:lt,easing:ut,fill:`both`});c.current=d,d.finished.catch(()=>void 0).then(()=>{c.current===d&&(c.current=null,d.cancel())})},[h,t]),_=J.useCallback(e=>{if(!e.isPrimary||e.pointerType===`mouse`&&e.button!==0)return;let n=i.current;if(!n)return;let r=n.getBoundingClientRect().height;t&&p.current===.72&&(l.current=ht(ft(),r)),c.current?.cancel(),c.current=null,n.style.height=`${r}px`,n.style.willChange=`height`,a.current={pointerId:e.pointerId,startY:e.clientY,startHeight:r,startSnapPoint:p.current,viewportHeight:ft()},u.current=!1,e.currentTarget.setPointerCapture(e.pointerId),e.preventDefault()},[t]),v=J.useCallback(e=>{let t=a.current,n=i.current;if(!t||t.pointerId!==e.pointerId||!n)return;let r=t.startY-e.clientY;Math.abs(r)>3&&(u.current=!0),s.current=mt(t.startHeight+r,t.viewportHeight,!!m.current),o.current===null&&(o.current=window.requestAnimationFrame(()=>{o.current=null,i.current&&s.current!==null&&(i.current.style.height=`${s.current}px`)})),e.preventDefault()},[]),y=J.useCallback((e,n)=>{let o=a.current,c=i.current;if(!o||o.pointerId!==e.pointerId||!c)return;a.current=null,h();let u=s.current??c.getBoundingClientRect().height;if(s.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),!n&&m.current&&pt(u,o.viewportHeight,r,t?l.current:void 0)){c.style.willChange=``,m.current(),e.preventDefault();return}let d=n?o.startSnapPoint:t?gt(u,o.viewportHeight,l.current):tt(u,o.viewportHeight,ct);g(d,u),e.preventDefault()},[h,r,t,g]),b=J.useCallback(()=>{if(u.current){u.current=!1;return}g(p.current===.98?ot:st)},[g]),x=J.useCallback(e=>{let t=null;(e.key===`ArrowUp`||e.key===`Home`)&&(t=st),(e.key===`ArrowDown`||e.key===`End`)&&(t=ot),(e.key===`Enter`||e.key===` `)&&(t=p.current===.98?ot:st),t!==null&&(e.preventDefault(),g(t))},[g]),S=J.useCallback(()=>{a.current=null,h(),s.current=null,c.current?.cancel(),c.current=null,l.current=null,p.current=e,f(e),i.current&&(i.current.style.height=``,i.current.style.willChange=``)},[h,e]);return J.useEffect(()=>()=>{h(),c.current?.cancel()},[h]),{surfaceRef:i,snapPoint:d,handlePointerDown:_,handlePointerMove:v,handlePointerUp:e=>y(e,!1),handlePointerCancel:e=>y(e,!0),handleClick:b,handleKeyDown:x,reset:S}},vt=e=>{let t=(0,X.c)(12),{controller:n,ariaLabel:r}=e,i;t[0]===n.snapPoint?i=t[1]:(i=Math.round(n.snapPoint*100),t[0]=n.snapPoint,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Y.jsx)(`div`,{className:`h-1.5 w-11 rounded-full bg-[var(--interactive-border)]`}),t[2]=a):a=t[2];let o;return t[3]!==r||t[4]!==n.handleClick||t[5]!==n.handleKeyDown||t[6]!==n.handlePointerCancel||t[7]!==n.handlePointerDown||t[8]!==n.handlePointerMove||t[9]!==n.handlePointerUp||t[10]!==i?(o=(0,Y.jsx)(`div`,{"data-mobile-sheet-snap-handle":!0,role:`separator`,tabIndex:0,"aria-label":r,"aria-orientation":`horizontal`,"aria-valuemin":ot*100,"aria-valuemax":st*100,"aria-valuenow":i,className:`flex min-h-8 cursor-ns-resize touch-none justify-center pt-2.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,onPointerDown:n.handlePointerDown,onPointerMove:n.handlePointerMove,onPointerUp:n.handlePointerUp,onPointerCancel:n.handlePointerCancel,onClick:n.handleClick,onKeyDown:n.handleKeyDown,children:a}),t[3]=r,t[4]=n.handleClick,t[5]=n.handleKeyDown,t[6]=n.handlePointerCancel,t[7]=n.handlePointerDown,t[8]=n.handlePointerMove,t[9]=n.handlePointerUp,t[10]=i,t[11]=o):o=t[11],o},yt=new WeakMap;function bt(e){yt.set(e.currentTarget,!0)}function xt(e){if(yt.delete(e.currentTarget))return!0;if(e.detail!==0)return!1;if(typeof document>`u`)return!0;let t=document.activeElement,n=e.currentTarget;return n instanceof Node&&t instanceof Node&&n.contains(t)}function St(e){e.target===e.currentTarget&&bt(e)}function Ct(e){return e.target===e.currentTarget&&xt(e)}var wt=new class{entries=[];listeners=new Set;previousOverflow=null;getSnapshot=()=>this.entries.at(-1)?.id??null;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));add(e,t){return this.entries=[...this.entries.filter(t=>t.id!==e.id),e],this.entries.length===1&&t&&(this.previousOverflow=t.style.overflow,t.style.overflow=`hidden`),this.emit(),()=>this.remove(e.id,t)}remove(e,t){let n=this.entries.length;this.entries=this.entries.filter(t=>t.id!==e),n>0&&this.entries.length===0&&t&&this.previousOverflow!==null&&(t.style.overflow=this.previousOverflow,this.previousOverflow=null),this.emit()}closeTop(){this.entries.at(-1)?.onClose()}emit(){for(let e of this.listeners)e()}},Tt=`mobile-sessions`,Et=new Map,Dt=e=>Et.get(e)??null,Ot=(e,t)=>(Et.set(e,t),()=>{Et.get(e)===t&&Et.delete(e)}),kt=`.overlay-scrollbar-container`,At=1,jt=e=>e===`left`||e===`right`?`x`:`y`,Mt=e=>e===`bottom`||e===`right`?1:-1,Nt=(e,t,n)=>{let r=jt(e)===`x`?t:n;return Math.max(0,r*Mt(e))},Pt=(e,t,n,r,i)=>{let a=Nt(e,t,n),o=Math.abs(jt(e)===`x`?n:t);return Math.hypot(t,n)>r&&a>0&&o<a*i},Ft=(e,t)=>Math.min(1,Math.max(0,e/Math.max(1,t))),It=(e,t,n,r)=>Math.min(r,Math.max(n,e*t)),Lt=(e,t,n,r,i)=>e>=n||e>=i&&t>=r,Rt=(e,t,n,r,i)=>t!==0&&n>0?t*i/n:r>80?0:e,zt=(e,t,n=At)=>{if(t===`bottom`)return e.scrollTop<=n;if(t===`top`)return e.scrollTop>=e.scrollHeight-e.clientHeight-n;if(e.matches?.(`:dir(rtl)`)){let r=e.scrollWidth-e.clientWidth;return t===`right`?Math.abs(e.scrollLeft)<=n:Math.abs(e.scrollLeft)>=r-n}return t===`right`?e.scrollLeft<=n:e.scrollLeft>=e.scrollWidth-e.clientWidth-n},Bt=(e,t)=>{for(let n=0;n<e.length;n+=1){let r=e.item(n);if(r?.identifier===t)return r}return null},Vt=(e,t)=>{let n=window.getComputedStyle(e),r=jt(t),i=r===`x`?n.overflowX:n.overflowY,a=r===`x`?e.scrollWidth:e.scrollHeight,o=r===`x`?e.clientWidth:e.clientHeight;return(i===`auto`||i===`scroll`||i===`overlay`)&&a>o},Ht=(e,t,n,r)=>{let i=t instanceof Element?t:null,a=i instanceof HTMLElement?i:i?.parentElement??null;for(;a&&e.contains(a);){if(Vt(a,n))return a;if(a===e)break;a=a.parentElement}let o=i?.closest(r)??null;return o&&e.contains(o)&&Vt(o,n)?o:null},Ut=e=>{let t=J.useRef(e),n=J.useRef(null),r=J.useRef(null);return t.current=e,J.useCallback(e=>{if(n.current?.(),n.current=null,!e)return;let i=()=>{let e=r.current;r.current=null,e?.active&&e.controller?.finish(`cancel`)},a=(e,t,n)=>{let r=jt(e.edge)===`x`?t.clientX:t.clientY,i=n-e.lastTime,a=r-e.lastPrimary;e.velocity=Rt(e.velocity,a,i,n-e.lastVelocityTime,Mt(e.edge)),a!==0&&i>0&&(e.lastVelocityTime=n),e.lastPrimary=r,e.lastTime=n,e.distance=Nt(e.edge,t.clientX-e.startX,t.clientY-e.startY)},o=n=>{i();let a=t.current;if(a.disabled||n.touches.length!==1)return;let o=n.target instanceof Element?n.target:null,s=a.reservedTargetSelector?o?.closest(a.reservedTargetSelector):null;if(s&&e.contains(s)||o?.closest(`input, textarea, select, [contenteditable=""], [contenteditable="true"], [data-mobile-sheet-no-dismiss]`))return;let c=n.touches[0],l=Ht(e,n.target,a.edge,a.scrollContainerSelector??kt);if(l&&!zt(l,a.edge))return;let u=e.getBoundingClientRect(),d=jt(a.edge)===`x`?u.width||window.innerWidth:u.height||window.innerHeight;r.current={edge:a.edge,motionId:a.motionId,touchId:c.identifier,startX:c.clientX,startY:c.clientY,lastPrimary:jt(a.edge)===`x`?c.clientX:c.clientY,lastTime:n.timeStamp,lastVelocityTime:n.timeStamp,velocity:0,distance:0,commitDistance:It(d,a.commitDistanceRatio??.1,a.minCommitDistance??40,a.maxCommitDistance??64),motionDistance:d,intentDistance:a.intentDistance??8,maxOffAxisRatio:a.maxOffAxisRatio??1,flingVelocity:a.flingVelocity??.65,flingMinDistance:a.flingMinDistance??12,controller:null,active:!1}},s=e=>{let n=r.current;if(!n)return;if(t.current.disabled||e.touches.length!==1){i();return}let o=Bt(e.touches,n.touchId);if(!o){i();return}if(a(n,o,e.timeStamp),!n.active){if(Math.hypot(o.clientX-n.startX,o.clientY-n.startY)<=n.intentDistance)return;if(!Pt(n.edge,o.clientX-n.startX,o.clientY-n.startY,n.intentDistance,n.maxOffAxisRatio)){r.current=null;return}let e=Dt(n.motionId);if(!e){r.current=null;return}if(!e.begin(`dismiss`)){r.current=null;return}n.active=!0,n.controller=e}n.controller?.update(Ft(n.distance,n.motionDistance)),e.preventDefault()},c=e=>{let t=r.current;if(!t)return;let n=Bt(e.changedTouches,t.touchId);if(!n){i();return}if(r.current=null,!t.active)return;a(t,n,e.timeStamp),t.controller?.update(Ft(t.distance,t.motionDistance));let o=Lt(t.distance,t.velocity,t.commitDistance,t.flingVelocity,t.flingMinDistance);t.controller?.finish(o?`commit`:`cancel`),e.preventDefault()},l=()=>i();e.addEventListener(`touchstart`,o,{passive:!0,capture:!0}),e.addEventListener(`touchmove`,s,{passive:!1,capture:!0}),e.addEventListener(`touchend`,c,{passive:!1,capture:!0}),e.addEventListener(`touchcancel`,l,{passive:!0,capture:!0}),n.current=()=>{i(),e.removeEventListener(`touchstart`,o,!0),e.removeEventListener(`touchmove`,s,!0),e.removeEventListener(`touchend`,c,!0),e.removeEventListener(`touchcancel`,l,!0)}},[])},Wt=`mobile-overlay-root`,Gt=200,Kt=80,qt=`cubic-bezier(0.32, 0.72, 0, 1)`,Jt=`a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])`,Yt=()=>{if(typeof document>`u`)return null;let e=document.getElementById(Wt);return e||(e=document.createElement(`div`),e.id=Wt,document.body.appendChild(e)),e},Xt=()=>typeof window<`u`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,Zt=({id:e,open:t,onOpenChange:n,keepMounted:r=!1,presentation:i=`sheet`,edge:a=`bottom`,children:o,className:s,scrimClassName:c,surfaceClassName:l,surfaceElementRef:u,dismissGesture:d=!1,onExitComplete:f,ariaLabel:p})=>{let m=J.useRef(null),h=J.useRef(null),g=J.useRef(null),_=J.useRef(t),v=J.useRef(n),y=J.useRef(f),b=J.useRef(0),x=J.useRef(0),S=J.useRef(null),C=J.useRef(null),w=J.useRef([]),T=J.useRef(null),E=J.useRef(`standard`),D=J.useRef(`present`),O=J.useRef(0),k=J.useRef(!1),A=J.useRef(t),j=J.useRef(!1),M=J.useRef(t),N=J.useRef(null),[P,F]=J.useState(t),[I,ee]=J.useState(t),[te,ne]=J.useState(`standard`),[re,ie]=J.useState(!1),L=te===`interactive-present`,ae=J.useSyncExternalStore(wt.subscribe,wt.getSnapshot,wt.getSnapshot),R=I&&!L&&ae===e,z=Ut({motionId:e,edge:a,disabled:!d,...typeof d==`object`?d:{}}),V=J.useCallback(e=>{g.current=e,z(e),typeof u==`function`?u(e):u&&typeof u==`object`&&(u.current=e)},[z,u]),H=J.useCallback(()=>{M.current&&(M.current=!1,ee(!1),r||F(!1),y.current?.())},[r]);_.current=t,v.current=n,y.current=f,typeof document<`u`&&!m.current&&(m.current=Yt());let oe=J.useCallback(e=>{let t=nt(a,e);b.current=t.progress,!(!h.current||!g.current)&&(h.current.style.opacity=String(t.scrimOpacity),g.current.style.transform=t.surfaceTransform,g.current.style.opacity=String(t.surfaceOpacity))},[a]),U=J.useCallback(()=>{S.current!==null&&window.cancelAnimationFrame(S.current),S.current=null},[]),W=J.useCallback(()=>{C.current!==null&&window.cancelAnimationFrame(C.current),C.current=null},[]),G=J.useCallback(()=>{h.current&&(h.current.style.willChange=``),g.current&&(g.current.style.willChange=``)},[]),K=J.useCallback((e=w.current)=>{for(let t of e)t.cancel();w.current=[]},[]),se=J.useCallback(()=>{U();let e=T.current;if(e){let t=e.animations[1]?.effect?.getComputedTiming().progress;oe(typeof t==`number`&&Number.isFinite(t)?e.from+(e.target-e.from)*t:b.current),K(e.animations),T.current=null}else K();G(),ie(!1)},[oe,K,U,G]),q=J.useCallback((e,t)=>{if(T.current?.target===e)return;se();let n=b.current,r=h.current,i=g.current;if(ie(!0),!r||!i||Xt()||n===e){oe(e),G(),ie(!1),t?.();return}let o=nt(a,n),s=nt(a,e);r.style.willChange=`opacity`,i.style.willChange=`transform, opacity`;let c=Math.max(Kt,Gt*Math.abs(e-n)),l=[r.animate([{opacity:o.scrimOpacity},{opacity:s.scrimOpacity}],{duration:c,easing:qt,fill:`forwards`}),i.animate([{transform:o.surfaceTransform,opacity:o.surfaceOpacity},{transform:s.surfaceTransform,opacity:s.surfaceOpacity}],{duration:c,easing:qt,fill:`forwards`})];w.current=l;let u={from:n,target:e,animations:l};T.current=u,Promise.all(l.map(e=>e.finished.catch(()=>void 0))).then(()=>{T.current===u&&(oe(e),K(l),T.current=null,G(),ie(!1),t?.())})},[oe,K,G,a,se]);if(J.useLayoutEffect(()=>{j.current=P,P&&oe(x.current)},[oe,P]),J.useLayoutEffect(()=>{M.current=I},[I]),J.useEffect(()=>{W(),t&&!j.current&&(x.current=b.current,F(!0)),t&&!M.current&&(M.current=!0,ee(!0)),j.current&&E.current===`standard`&&q(at(t),()=>{!_.current&&E.current===`standard`&&H()})},[W,H,t,q]),J.useLayoutEffect(()=>{!P||E.current!==`standard`||C.current!==null||q(+!!t,()=>{!_.current&&E.current===`standard`&&H()})},[H,P,t,q]),J.useEffect(()=>{if(!(!I||L))return window.dispatchEvent(new Event(`oc:mobile-overlay-opened`)),()=>{window.dispatchEvent(new Event(`oc:mobile-overlay-closed`))}},[I,L]),J.useEffect(()=>{if(!(!I||L))return wt.add({id:e,onClose:()=>v.current(!1)},document.body)},[I,e,L]),J.useEffect(()=>{if(!I||L||!R)return;let e=g.current,t=document.activeElement instanceof HTMLElement?document.activeElement:null;e?.focus({preventScroll:!0});let n=t=>{if(t.key===`Escape`&&wt.closeTop(),t.key!==`Tab`||!e)return;let n=Array.from(e.querySelectorAll(Jt)).filter(e=>!e.closest(`[data-mobile-sheet-snap-handle]`)),r=n[0]??e,i=n.at(-1)??e;t.shiftKey&&document.activeElement===r&&(t.preventDefault(),i.focus({preventScroll:!0})),!t.shiftKey&&document.activeElement===i&&(t.preventDefault(),r.focus({preventScroll:!0}))};return document.addEventListener(`keydown`,n),()=>{document.removeEventListener(`keydown`,n),Q()||t?.focus({preventScroll:!0})}},[I,L,R]),N.current={begin:e=>{if(e===`dismiss`&&(!M.current||E.current===`interactive-present`))return!1;W(),se(),O.current+=1,k.current=!0,D.current=e;let t=e===`present`?`interactive-present`:`interactive-dismiss`;return E.current=t,ne(t),ie(!0),e===`present`&&(x.current=b.current,M.current=!0,ee(!0),F(!0)),!0},update:e=>{k.current&&(x.current=rt(D.current,e),S.current===null&&(S.current=window.requestAnimationFrame(()=>{S.current=null,k.current&&oe(x.current)})))},finish:e=>{if(!k.current)return;k.current=!1;let t=O.current,n=D.current,r=it(n,e);S.current!==null&&(U(),oe(x.current)),q(r,()=>{t===O.current&&(e===`commit`&&v.current(n===`present`),n===`present`&&e===`cancel`&&!_.current&&H(),E.current=`standard`,ne(`standard`),C.current=window.requestAnimationFrame(()=>{if(C.current=null,t!==O.current)return;let e=at(_.current);q(e,()=>{t===O.current&&!_.current&&H()})}))})},interrupt:()=>{W(),O.current+=1,k.current=!1;let e=E.current===`interactive-present`&&!_.current;e||(E.current=`standard`,ne(`standard`)),se(),q(at(_.current),()=>{_.current||H(),e&&(E.current=`standard`,ne(`standard`))})}},J.useLayoutEffect(()=>{let e=A.current;A.current=t,e&&!t&&E.current!==`standard`&&N.current?.interrupt()},[t]),J.useEffect(()=>{let t=Ot(e,{begin:e=>N.current?.begin(e)??!1,update:e=>N.current?.update(e),finish:e=>N.current?.finish(e),interrupt:()=>N.current?.interrupt()});return()=>{t(),W(),U(),K(),T.current=null,G(),N.current=null}},[K,U,W,G,e]),!P||!m.current)return null;let ce=(0,Y.jsx)(`div`,{ref:h,className:B(`oc-mobile-window-motion oc-keyboard-inset-surface fixed inset-0 z-[60] flex flex-col bg-[rgb(0_0_0_/_0.45)]`,re&&`oc-mobile-window-motion-active`,!I&&!L&&`pointer-events-none invisible`,c,s),"data-mobile-overlay-active":String(I),role:L?void 0:`dialog`,"aria-label":L?void 0:p,"aria-modal":I&&R?`true`:void 0,"aria-hidden":L||!I||!R||void 0,inert:L||!I||!R||void 0,onPointerDown:St,onClick:e=>{!I||L||!R||Ct(e)&&v.current(!1)},children:(0,Y.jsx)(`div`,{ref:V,tabIndex:-1,className:B(`oc-mobile-floating-shell`,$e(i,a),l),style:{contain:`layout paint style`},onClick:e=>e.stopPropagation(),children:o})});return(0,ge.createPortal)(ce,m.current)},Qt=J.createContext(null),$t=e=>{let t=(0,X.c)(5),{children:n}=e,r=J.useContext(Qt);if(!r)return null;let i;t[0]===n?i=t[1]:(i=(0,Y.jsx)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:n}),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,ge.createPortal)(i,r),t[2]=r,t[3]=i,t[4]=a):a=t[4],a},en=e=>{let t=(0,X.c)(40),{id:n,open:r,onOpenChange:i,title:a,leading:o,trailing:s,ariaLabel:c,closeAriaLabel:l,resizeAriaLabel:u,initiallyExpanded:d,fitContent:f,bodyClassName:p,children:m}=e,h=d!==void 0&&d,g=f!==void 0&&f,_=h?st:void 0,v;t[0]===i?v=t[1]:(v=()=>i(!1),t[0]=i,t[1]=v);let y;t[2]!==g||t[3]!==_||t[4]!==v?(y={initialSnapPoint:_,fitContent:g,onDismiss:v},t[2]=g,t[3]=_,t[4]=v,t[5]=y):y=t[5];let b=_t(y),[x,S]=J.useState(null),C=a!=null||o!=null||s!=null,w;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(w={reservedTargetSelector:`[data-mobile-sheet-snap-handle]`},t[6]=w):w=t[6];let T=b.snapPoint===.98?`h-[98dvh] max-h-[98dvh]`:g?`h-auto max-h-[72dvh]`:`h-[72dvh] max-h-[98dvh]`,E=b.surfaceRef,D=b.reset,O;t[7]!==u||t[8]!==b?(O=(0,Y.jsx)(vt,{controller:b,ariaLabel:u}),t[7]=u,t[8]=b,t[9]=O):O=t[9];let k;t[10]!==l||t[11]!==C||t[12]!==o||t[13]!==i||t[14]!==a||t[15]!==s?(k=C?(0,Y.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2 px-4 pb-2`,children:[o?(0,Y.jsx)(`div`,{className:`flex shrink-0 items-center`,children:o}):null,(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`,children:a}),s?(0,Y.jsx)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:s}):null,(0,Y.jsx)(`div`,{ref:S,className:`contents`}),(0,Y.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>i(!1),"aria-label":l,className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,Y.jsx)(V,{name:`close`,className:`size-5`})})]}):null,t[10]=l,t[11]=C,t[12]=o,t[13]=i,t[14]=a,t[15]=s,t[16]=k):k=t[16];let A;t[17]!==O||t[18]!==k?(A=(0,Y.jsxs)(`div`,{className:`shrink-0`,children:[O,k]}),t[17]=O,t[18]=k,t[19]=A):A=t[19];let j;t[20]===p?j=t[21]:(j=B(`flex min-h-0 flex-1 flex-col overflow-hidden`,p),t[20]=p,t[21]=j);let M;t[22]!==m||t[23]!==j?(M=(0,Y.jsx)(`div`,{className:j,"data-page-scroll-lock":`true`,children:m}),t[22]=m,t[23]=j,t[24]=M):M=t[24];let N;t[25]!==A||t[26]!==M?(N=(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[A,M]}),t[25]=A,t[26]=M,t[27]=N):N=t[27];let P;t[28]!==c||t[29]!==n||t[30]!==i||t[31]!==r||t[32]!==b.reset||t[33]!==b.surfaceRef||t[34]!==N||t[35]!==T?(P=(0,Y.jsx)(Zt,{id:n,open:r,onOpenChange:i,presentation:`sheet`,edge:`bottom`,dismissGesture:w,ariaLabel:c,surfaceClassName:T,surfaceElementRef:E,onExitComplete:D,children:N}),t[28]=c,t[29]=n,t[30]=i,t[31]=r,t[32]=b.reset,t[33]=b.surfaceRef,t[34]=N,t[35]=T,t[36]=P):P=t[36];let F;return t[37]!==x||t[38]!==P?(F=(0,Y.jsx)(Qt.Provider,{value:x,children:P}),t[37]=x,t[38]=P,t[39]=F):F=t[39],F};function tn(){let e=(0,X.c)(5),t=L(on),n=L(an),r=L(rn),i=L(nn),a=t||i,o=!a&&r===`init_error`,s=!a&&!o,c;return e[0]!==n||e[1]!==a||e[2]!==o||e[3]!==s?(c={isReady:a,isLoading:s,isUnavailable:o,connectionPhase:n},e[0]=n,e[1]=a,e[2]=o,e[3]=s,e[4]=c):c=e[4],c}function nn(e){return e.providers.length>0}function rn(e){return e.lastDisconnectReason}function an(e){return e.connectionPhase}function on(e){return e.isInitialized}var sn=e=>{let t=(0,X.c)(41),{agentName:r,onChange:i,className:a,filter:o,dropdownPortalToBody:s,showIcon:c,agents:l}=e,u=s!==void 0&&s,d=c===void 0||c,{t:f}=ee(),{isReady:p,isUnavailable:m}=tn(),h=L(cn),g=ae(ln),_=L(un),{data:v}=ie(),y;t[0]===v?y=t[1]:(y=v===void 0?[]:v,t[0]=v,t[1]=y);let b=y,x;bb0:{if(l){x=l;break bb0}if(Array.isArray(h)&&h.length>0){x=h;break bb0}x=b}let S=x,C;if(t[2]!==o||t[3]!==S){let e=ne(S);C=o?e.filter(o):e,t[2]=o,t[3]=S,t[4]=C}else C=t[4];let w=C,T=n(dn),{isMobile:E}=ue(),D=T||E,[O,k]=J.useState(!1),A;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(A=()=>{k(!0),L.getState().refreshCatalogsOnPickerOpen({source:`agentSelector:mobilePanel`})},t[5]=A):A=t[5];let j=I(A),M=I(fn),N=J.useId(),P,F;t[6]!==l||t[7]!==g||t[8]!==_||t[9]!==S.length?(P=()=>{l||S.length>0||(_(),g())},F=[l,S.length,_,g],t[6]=l,t[7]=g,t[8]=_,t[9]=S.length,t[10]=P,t[11]=F):(P=t[10],F=t[11]),J.useEffect(P,F);let te;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(te=()=>k(!1),t[12]=te):te=t[12];let re=te,z;t[13]===i?z=t[14]:(z=e=>{i(e)},t[13]=i,t[14]=z);let H=z,U;t[15]!==r||t[16]!==w||t[17]!==H||t[18]!==D||t[19]!==O||t[20]!==N||t[21]!==f?(U=()=>D?(0,Y.jsx)(en,{id:`mobile-agent-selector-sheet-${N}`,open:O,onOpenChange:e=>{e||re()},ariaLabel:f(`settings.commands.agentSelector.title`),closeAriaLabel:f(`mobile.surface.closeAria`),resizeAriaLabel:f(`mobile.sessions.sheet.resizeAria`),bodyClassName:`px-2`,children:(0,Y.jsxs)(oe,{useScrollShadow:!0,disableHorizontal:!0,preventOverscroll:!0,outerClassName:`min-h-0 flex-1`,className:`flex flex-col gap-1 overscroll-contain`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:B(`grid w-full grid-cols-[1rem_minmax(0,1fr)_auto] items-center gap-x-2 rounded-lg border border-border/40 bg-background/95 px-2 py-1.5 text-left`,r?`text-foreground`:`bg-primary/10 text-primary`),onClick:()=>{H(``),re()},children:[(0,Y.jsx)(R,{name:`default`,size:16}),(0,Y.jsx)(`span`,{className:B(`min-w-0 typography-meta`,r?`text-muted-foreground`:`font-medium`),children:f(`settings.commands.agentSelector.notSelected`)}),!r&&(0,Y.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-primary`})]}),w.map(e=>{let t=e.name===r;return(0,Y.jsxs)(`button`,{type:`button`,className:B(`grid w-full grid-cols-[1rem_minmax(0,1fr)_auto] items-start gap-x-2 rounded-lg border border-border/40 bg-background/95 px-2 py-1.5 text-left`,t?`bg-primary/10 text-primary`:`text-foreground`),onClick:()=>{H(e.name),re()},children:[(0,Y.jsx)(R,{name:e.name,size:16,className:`mt-1.5`}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`typography-meta font-medium`,children:e.name}),e.description&&(0,Y.jsx)(`span`,{className:`mt-0.5 block whitespace-normal break-words typography-micro text-muted-foreground`,children:e.description})]}),t&&(0,Y.jsx)(`div`,{className:`mt-2 h-2 w-2 rounded-full bg-primary`})]},e.name)})]})}):null,t[15]=r,t[16]=w,t[17]=H,t[18]=D,t[19]=O,t[20]=N,t[21]=f,t[22]=U):U=t[22];let W=U,G;t[23]!==r||t[24]!==w||t[25]!==a||t[26]!==u||t[27]!==H||t[28]!==M||t[29]!==D||t[30]!==p||t[31]!==m||t[32]!==j||t[33]!==d||t[34]!==f?(G=D?(0,Y.jsxs)(`button`,{type:`button`,onClick:p?j:void 0,disabled:!p,className:B(`flex w-full items-center justify-between gap-2 rounded-lg border border-border/40 bg-background/95 px-2 py-1.5 text-left`,!p&&`opacity-60 cursor-not-allowed`,a),children:[(0,Y.jsx)(`div`,{className:`flex items-center gap-2`,children:p?(0,Y.jsxs)(Y.Fragment,{children:[d?(0,Y.jsx)(R,{name:r||`default`,size:14}):null,(0,Y.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:r||f(`settings.commands.agentSelector.selectAgentPlaceholder`)})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(V,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:f(m?`common.unavailable`:`common.loading`)})]})}),(0,Y.jsx)(V,{name:`arrow-down-s`,className:`h-3 w-3 text-muted-foreground`})]}):p?(0,Y.jsxs)(Ge,{onOpenChange:M,children:[(0,Y.jsx)(Ke,{asChild:!0,children:(0,Y.jsxs)(`div`,{className:B(`flex items-center gap-2 px-2 rounded-lg bg-interactive-selection/20 border border-border/20 cursor-pointer hover:bg-interactive-hover/30 h-6 w-fit`,a),children:[d?(0,Y.jsx)(R,{name:r||`default`,size:14}):null,(0,Y.jsx)(`span`,{className:`typography-micro font-medium whitespace-nowrap`,children:r||f(`settings.commands.agentSelector.notSelected`)}),(0,Y.jsx)(V,{name:`arrow-down-s`,className:`h-3 w-3 flex-shrink-0 text-muted-foreground`})]})}),(0,Y.jsxs)(qe,{className:`max-w-[300px]`,portalToBody:u,children:[(0,Y.jsxs)(Je,{className:`typography-meta`,onSelect:()=>H(``),children:[(0,Y.jsx)(R,{name:`default`,size:14}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:f(`settings.commands.agentSelector.notSelected`)})]}),w.map(e=>(0,Y.jsxs)(Je,{className:`typography-meta`,onSelect:()=>H(e.name),children:[(0,Y.jsx)(R,{name:e.name,size:14}),(0,Y.jsx)(`span`,{className:`font-medium`,children:e.name})]},e.name))]})]}):(0,Y.jsxs)(`div`,{className:B(`flex items-center gap-2 px-2 rounded-lg bg-interactive-selection/20 border border-border/20 h-6 w-fit opacity-60`,a),children:[(0,Y.jsx)(V,{name:`loader-4`,className:`h-3 w-3 animate-spin text-muted-foreground flex-shrink-0`}),(0,Y.jsx)(`span`,{className:`typography-micro font-medium whitespace-nowrap text-muted-foreground`,children:f(m?`common.unavailable`:`common.loading`)})]}),t[23]=r,t[24]=w,t[25]=a,t[26]=u,t[27]=H,t[28]=M,t[29]=D,t[30]=p,t[31]=m,t[32]=j,t[33]=d,t[34]=f,t[35]=G):G=t[35];let K;t[36]===W?K=t[37]:(K=W(),t[36]=W,t[37]=K);let se;return t[38]!==G||t[39]!==K?(se=(0,Y.jsxs)(Y.Fragment,{children:[G,K]}),t[38]=G,t[39]=K,t[40]=se):se=t[40],se};function cn(e){return e.agents}function ln(e){return e.loadAgents}function un(e){return e.loadAgents}function dn(e){return e.isMobile}function fn(e){e&&L.getState().refreshCatalogsOnPickerOpen({source:`agentSelector:desktopMenu`})}var pn=8,mn=e=>typeof e!=`number`||Number.isNaN(e)?``:new Intl.NumberFormat(te(),{notation:`compact`,compactDisplay:`short`,maximumFractionDigits:1}).format(e),hn=(e,t,n)=>{let r=e.find(e=>e.id===t)?.models?.find(e=>e.id===n);return r?.variants?Object.keys(r.variants):[]},gn=e=>{let t=(0,X.c)(160),{open:n,onClose:r,selectedProviderID:i,selectedModelID:a,resolveSelectedVariant:o,onSelect:s,providers:c,favoriteModels:l,recentModels:u,hiddenModels:d,allowedProviderIds:f,allowedModelIdsByProvider:p,providerOrder:m,variantSelectionEnabled:h,isFavorite:g,onToggleFavorite:_,getMetadata:v,view:y,onViewChange:b}=e,x;t[0]===d?x=t[1]:(x=d===void 0?[]:d,t[0]=d,t[1]=x);let S=x,C=h===void 0||h,{t:w}=ee(),T=J.useId(),[E,D]=J.useState(``),O;t[2]===i?O=t[3]:(O=()=>new Set(i?[i]:[]),t[2]=i,t[3]=O);let[k,A]=J.useState(O),[j,M]=J.useState(null),[N,P]=J.useState(`model`),[F,I]=J.useState(null),te=J.useRef(!1),ne=y??N,ie,L;t[4]!==n||t[5]!==i?(ie=()=>{n&&!te.current&&A(new Set(i?[i]:[])),n||(D(``),M(null),P(`model`),I(null)),te.current=n},L=[n,i],t[4]=n,t[5]=i,t[6]=ie,t[7]=L):(ie=t[6],L=t[7]),J.useEffect(ie,L);let ae;t[8]===b?ae=t[9]:(ae=e=>{P(e),b?.(e)},t[8]=b,t[9]=ae);let R=ae,z;t[10]===f?z=t[11]:(z=f&&f.length>0?new Set(f):null,t[10]=f,t[11]=z);let U=z,G;t[12]===p?G=t[13]:(G=p?new Map(Object.entries(p).map(_n)):null,t[12]=p,t[13]=G);let le=G,ue;t[14]===S?ue=t[15]:(ue=new Set(S.map(vn)),t[14]=S,t[15]=ue);let de=ue,fe;t[16]===c?fe=t[17]:(fe=new Map(c.map(yn)),t[16]=c,t[17]=fe);let pe=fe,me;bb0:{if(!m?.length){me=c;break bb0}let e;t[18]===m?e=t[19]:(e=new Map(m.map(bn)),t[18]=m,t[19]=e);let n=e,r;if(t[20]!==c||t[21]!==n){let e;t[23]===n?e=t[24]:(e=(e,t)=>{let r=n.get(e.id),i=n.get(t.id);return r===void 0&&i===void 0?0:r===void 0?1:i===void 0?-1:r-i},t[23]=n,t[24]=e),r=[...c].sort(e),t[20]=c,t[21]=n,t[22]=r}else r=t[22];me=r}let he=me,ge;t[25]!==le||t[26]!==U||t[27]!==de?(ge=(e,t)=>U&&!U.has(e)||le&&le.get(e)?.has(t)!==!0?!1:!de.has(`${e}:${t}`),t[25]=le,t[26]=U,t[27]=de,t[28]=ge):ge=t[28];let Z=ge,_e;t[29]!==pe||t[30]!==E?(_e=e=>{let t=E.trim();if(!t)return!0;let n=pe.get(e.providerID)?.name||e.providerID,r=re(e.model,e.modelID,{maxLength:40});return q(r,t)||q(e.modelID,t)||q(n,t)},t[29]=pe,t[30]=E,t[31]=_e):_e=t[31];let Q=_e,ve;if(t[32]!==l||t[33]!==Z||t[34]!==Q){let e;t[36]!==Z||t[37]!==Q?(e=e=>Z(e.providerID,e.modelID)&&Q(e),t[36]=Z,t[37]=Q,t[38]=e):e=t[38],ve=l.filter(e),t[32]=l,t[33]=Z,t[34]=Q,t[35]=ve}else ve=t[35];let ye=ve,be;if(t[39]!==Z||t[40]!==Q||t[41]!==u){let e;t[43]!==Z||t[44]!==Q?(e=e=>Z(e.providerID,e.modelID)&&Q(e),t[43]=Z,t[44]=Q,t[45]=e):e=t[45],be=u.filter(e),t[39]=Z,t[40]=Q,t[41]=u,t[42]=be}else be=t[42];let xe=be,Se;if(t[46]!==U||t[47]!==Z||t[48]!==he||t[49]!==E){let e;t[51]===U?e=t[52]:(e=e=>!U||U.has(e.id),t[51]=U,t[52]=e);let n;t[53]!==Z||t[54]!==E?(n=e=>{let t=E.trim().length>0&&(q(e.name||e.id,E.trim())||q(e.id,E.trim()));return{provider:e,models:(e.models??[]).filter(n=>{let r=typeof n.id==`string`?n.id:``;return!r||!Z(e.id,r)?!1:t||!E.trim()?!0:q(re(n,r,{maxLength:40}),E.trim())||q(r,E.trim())})}},t[53]=Z,t[54]=E,t[55]=n):n=t[55],Se=he.filter(e).map(n).filter(xn),t[46]=U,t[47]=Z,t[48]=he,t[49]=E,t[50]=Se}else Se=t[50];let Ce=Se,$;t[56]===w?$=t[57]:($=e=>{if(!e?.trim())return w(`chat.modelControls.default`);let t=e.trim();return/^\d+(\.\d+)?$/.test(t)?t:t.charAt(0).toUpperCase()+t.slice(1)},t[56]=w,t[57]=$);let we=$,Te;t[58]===w?Te=t[59]:(Te=e=>{let t=[];e?.tool_call&&t.push({key:`tool_call`,icon:`tools`,label:w(`chat.modelControls.capability.toolCalling`)}),e?.reasoning&&t.push({key:`reasoning`,icon:`brain-ai-3`,label:w(`chat.modelControls.capability.reasoning`)});let n={text:{icon:`text`,label:w(`chat.modelControls.modality.text`)},image:{icon:`file-image`,label:w(`chat.modelControls.modality.image`)},video:{icon:`file-video`,label:w(`chat.modelControls.modality.video`)},audio:{icon:`file-music`,label:w(`chat.modelControls.modality.audio`)},pdf:{icon:`file-pdf`,label:w(`chat.modelControls.modality.pdf`)}};for(let r of[...e?.modalities?.input??[],...e?.modalities?.output??[]]){let e=r.trim().toLowerCase(),i=n[e];i&&!t.some(t=>t.key===e)&&t.push({key:e,...i})}return t},t[58]=w,t[59]=Te);let Ee=Te,De;t[60]===R?De=t[61]:(De=(e,t,n)=>{I(n===void 0?{providerID:e,modelID:t}:{providerID:e,modelID:t,variant:n}),R(`variant`)},t[60]=R,t[61]=De);let Oe=De,ke;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(ke={onPointerDown:bt,onClickCapture:Sn},t[62]=ke):ke=t[62];let Ae=ke,je;t[63]!==j||t[64]!==we||t[65]!==v||t[66]!==Ee||t[67]!==g||t[68]!==s||t[69]!==_||t[70]!==Oe||t[71]!==pe||t[72]!==c||t[73]!==o||t[74]!==a||t[75]!==i||t[76]!==w||t[77]!==C?(je=(e,t)=>{let n=t===void 0?{}:t,{model:r,providerID:l,modelID:u}=e,d=`${l}:${u}`,f=l===i&&u===a,p=K(l,r,v?.(l,u)),m=C?hn(c,l,u):[],h=o(l,u),y=n.preferRememberedVariant&&e.variant!==void 0&&m.includes(e.variant)?e.variant:void 0,b=y===void 0?h:y,x=f||y===void 0?h:y,S=[void 0,...m].slice(0,pn),T=j===d,E=Ee(p),D=p?.limit?.context?`${mn(p.limit.context)} ctx`:null;return(0,Y.jsxs)(`div`,{className:B(`border-b border-border/30 last:border-b-0`,f&&`bg-interactive-selection/15 text-interactive-selection-foreground`),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[(0,Y.jsx)(`button`,{type:`button`,...Ae,onClick:()=>s(l,u,b),className:`flex min-w-0 flex-1 items-start gap-2 rounded-lg text-left focus:outline-none focus-visible:ring-1 focus-visible:ring-primary`,children:(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[n.showProvider?(0,Y.jsx)(`span`,{className:`truncate text-[10px] leading-none text-muted-foreground/60`,children:pe.get(l)?.name||l}):null,(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Y.jsx)(se,{modelId:u,providerId:l,className:`size-3.5 flex-shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate typography-meta font-medium text-foreground`,children:re(r,u,{maxLength:40})}),f?(0,Y.jsx)(V,{name:`check`,className:`size-4 flex-shrink-0 text-primary`}):null]}),D||E.length>0?(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 overflow-hidden typography-micro text-muted-foreground`,children:[D?(0,Y.jsx)(`span`,{className:`flex-shrink-0 whitespace-nowrap`,children:D}):null,D&&E.length>0?(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-px flex-shrink-0 bg-border/50`}):null,(0,Y.jsx)(`div`,{className:`flex min-w-0 items-center gap-1 overflow-hidden whitespace-nowrap pl-0.5`,children:E.map(e=>{let{key:t,icon:n,label:r}=e;return(0,Y.jsx)(`span`,{className:`flex size-4 flex-shrink-0 items-center justify-center text-muted-foreground`,title:r,"aria-label":r,children:(0,Y.jsx)(V,{name:n,className:`size-3`})},`${d}-${t}`)})})]}):null]})}),m.length>0?(0,Y.jsxs)(`button`,{type:`button`,...Ae,onClick:()=>M(e=>e===d?null:d),className:`flex flex-shrink-0 items-center gap-0.5 typography-micro font-medium text-muted-foreground hover:text-foreground`,"aria-expanded":T,"aria-label":w(T?`chat.modelControls.hideThinkingModes`:`chat.modelControls.showThinkingModes`),children:[(0,Y.jsx)(`span`,{className:`whitespace-nowrap`,children:we(x)}),(0,Y.jsx)(V,{name:T?`arrow-down-s`:`arrow-right-s`,className:`size-3.5`})]}):null,(0,Y.jsx)(`button`,{type:`button`,...Ae,onClick:e=>{e.preventDefault(),e.stopPropagation(),_(l,u)},className:B(`model-favorite-button flex size-5 flex-shrink-0 items-center justify-center hover:text-primary/80`,g(l,u)?`text-primary`:`text-muted-foreground`),"aria-label":g(l,u)?w(`chat.modelControls.unfavoriteAria`):w(`chat.modelControls.favoriteAria`),title:g(l,u)?w(`chat.modelControls.removeFromFavorites`):w(`chat.modelControls.addToFavorites`),children:(0,Y.jsx)(V,{name:g(l,u)?`star-fill`:`star`,className:`size-4`})})]}),T&&m.length>0?(0,Y.jsx)(`div`,{className:`border-t border-border/30 p-2`,children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[S.map(e=>{let t=e===x||!e&&!x;return(0,Y.jsx)(`button`,{type:`button`,...Ae,onClick:()=>s(l,u,e),className:B(`inline-flex items-center rounded-full border px-2.5 py-1 typography-meta font-medium`,t?`border-primary/30 bg-primary/10 text-foreground`:`border-border/40 text-muted-foreground hover:bg-interactive-hover/50`),"aria-pressed":t,children:we(e)},`${d}-${e??`default`}`)}),S.length<m.length+1?(0,Y.jsx)(`button`,{type:`button`,...Ae,onClick:()=>Oe(l,u,x),className:`inline-flex items-center rounded-full border border-border/40 px-2.5 py-1 typography-meta font-medium text-muted-foreground hover:bg-interactive-hover/50`,"aria-label":w(`chat.modelControls.moreThinkingModes`),children:w(`inlineComment.actions.showMore`)}):null]})}):null]},`mobile-model-${d}`)},t[63]=j,t[64]=we,t[65]=v,t[66]=Ee,t[67]=g,t[68]=s,t[69]=_,t[70]=Oe,t[71]=pe,t[72]=c,t[73]=o,t[74]=a,t[75]=i,t[76]=w,t[77]=C,t[78]=je):je=t[78];let Me=je,Ne,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,We,Ge,Ke,qe,Je,Ye,Xe,Ze;if(t[79]!==ne||t[80]!==k||t[81]!==ye||t[82]!==Ce||t[83]!==xe||t[84]!==we||t[85]!==T||t[86]!==r||t[87]!==s||t[88]!==n||t[89]!==c||t[90]!==E||t[91]!==Me||t[92]!==o||t[93]!==a||t[94]!==i||t[95]!==R||t[96]!==w||t[97]!==F){let e=F??(ne===`variant`&&i&&a?{providerID:i,modelID:a}:null),l=e?hn(c,e.providerID,e.modelID):[],u;bb1:{if(!e){u=void 0;break bb1}if(e.providerID===i&&e.modelID===a){u=o(e.providerID,e.modelID);break bb1}u=(e.variant!==void 0&&l.includes(e.variant)?e.variant:void 0)??o(e.providerID,e.modelID)}let d=u,f=ye.length>0||xe.length>0||Ce.length>0,p=ne===`variant`&&!!e;Pe=en,We=`mobile-model-picker-sheet-${T}`,Ge=n,t[117]===r?Ke=t[118]:(Ke=e=>{e||r()},t[117]=r,t[118]=Ke),t[119]!==p||t[120]!==R||t[121]!==w?(qe=p?(0,Y.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>R(`model`),"aria-label":w(`onboarding.common.actions.back`),children:(0,Y.jsx)(V,{name:`arrow-left`,className:`size-5`})}):void 0,t[119]=p,t[120]=R,t[121]=w,t[122]=qe):qe=t[122],t[123]!==p||t[124]!==w?(Je=w(p?`chat.modelControls.thinking`:`chat.modelControls.selectModel`),t[123]=p,t[124]=w,t[125]=Je):Je=t[125],t[126]===w?Ye=t[127]:(Ye=w(`mobile.surface.closeAria`),t[126]=w,t[127]=Ye),t[128]===w?Xe=t[129]:(Xe=w(`mobile.sessions.sheet.resizeAria`),t[128]=w,t[129]=Xe),Ze=`px-2`,He=`flex min-h-0 flex-1 flex-col gap-2`,t[130]!==p||t[131]!==E||t[132]!==w?(Ue=p?null:(0,Y.jsxs)(`div`,{className:`relative z-10 shrink-0`,"data-mobile-sheet-no-dismiss":``,"data-mobile-sheet-search":``,children:[(0,Y.jsx)(V,{name:`search`,className:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,Y.jsx)(ce,{type:`text`,value:E,onChange:e=>{D(e.target.value),M(null)},onPointerUp:Cn,placeholder:w(`chat.modelControls.searchProvidersOrModels`),className:`h-9 rounded-xl border-border/40 bg-[var(--surface-elevated)] pl-7 typography-meta`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,enterKeyHint:`search`,inputMode:`search`}),E?(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{D(``),M(null)},className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,"aria-label":w(`chat.modelControls.clearSearch`),children:(0,Y.jsx)(V,{name:`close-circle`,className:`size-4`})}):null]}),t[130]=p,t[131]=E,t[132]=w,t[133]=Ue):Ue=t[133],Ne=oe,Le=!0,Re=!0,ze=!0,Be=`min-h-0 flex-1`,Ve=`overscroll-contain`,Fe=`flex flex-col gap-2`,Ie=p&&e?(0,Y.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:[void 0,...l].map(t=>{let n=t===d||!t&&!d;return(0,Y.jsxs)(`button`,{type:`button`,className:B(`flex w-full items-center justify-between gap-2 rounded-xl border px-2 py-1.5 text-left focus:outline-none focus-visible:ring-1 focus-visible:ring-primary`,n?`border-primary/30 bg-primary/10`:`border-border/40`),...Ae,onClick:()=>s(e.providerID,e.modelID,t),children:[(0,Y.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:we(t)}),n?(0,Y.jsx)(V,{name:`check`,className:`size-4 flex-shrink-0 text-primary`}):null]},t??`default`)})}):(0,Y.jsxs)(Y.Fragment,{children:[f?null:(0,Y.jsx)(`div`,{className:`px-3 py-8 text-center typography-meta text-muted-foreground`,children:w(`chat.modelControls.noProvidersOrModelsFound`)}),ye.length>0?(0,Y.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border/40 bg-[var(--surface-elevated)]`,children:[(0,Y.jsxs)(`div`,{className:`px-2 py-1.5 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,Y.jsx)(V,{name:`star-fill`,className:`mr-1.5 inline-block size-3 text-primary`}),w(`chat.modelControls.favorites`)]}),(0,Y.jsx)(`div`,{className:`flex flex-col border-t border-border/30`,children:ye.map(e=>Me(e,{showProvider:!0,preferRememberedVariant:!0}))})]}):null,xe.length>0?(0,Y.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border/40 bg-[var(--surface-elevated)]`,children:[(0,Y.jsxs)(`div`,{className:`px-2 py-1.5 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,Y.jsx)(V,{name:`time`,className:`mr-1.5 inline-block size-3`}),w(`chat.modelControls.recent`)]}),(0,Y.jsx)(`div`,{className:`flex flex-col border-t border-border/30`,children:xe.map(e=>Me(e,{showProvider:!0,preferRememberedVariant:!0}))})]}):null,Ce.map(e=>{let{provider:t,models:n}=e,r=k.has(t.id)||E.trim().length>0;return(0,Y.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border/40 bg-[var(--surface-elevated)]`,children:[(0,Y.jsxs)(`button`,{type:`button`,...Ae,onClick:()=>{E.trim()||A(e=>{let n=new Set(e);return n.has(t.id)?n.delete(t.id):n.add(t.id),n})},className:`flex w-full items-center justify-between gap-1.5 px-2 py-1.5 text-left`,"aria-expanded":r,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(W,{providerId:t.id,className:`size-3.5`}),(0,Y.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:t.name||t.id}),t.id===i?(0,Y.jsx)(`span`,{className:`typography-micro text-primary/80`,children:w(`chat.modelControls.current`)}):null]}),(0,Y.jsx)(V,{name:r?`arrow-down-s`:`arrow-right-s`,className:`size-3 text-muted-foreground`})]}),r?(0,Y.jsx)(`div`,{className:`flex flex-col border-t border-border/30`,children:n.map(e=>Me({model:e,providerID:t.id,modelID:e.id}))}):null]},t.id)})]}),t[79]=ne,t[80]=k,t[81]=ye,t[82]=Ce,t[83]=xe,t[84]=we,t[85]=T,t[86]=r,t[87]=s,t[88]=n,t[89]=c,t[90]=E,t[91]=Me,t[92]=o,t[93]=a,t[94]=i,t[95]=R,t[96]=w,t[97]=F,t[98]=Ne,t[99]=Pe,t[100]=Fe,t[101]=Ie,t[102]=Le,t[103]=Re,t[104]=ze,t[105]=Be,t[106]=Ve,t[107]=He,t[108]=Ue,t[109]=We,t[110]=Ge,t[111]=Ke,t[112]=qe,t[113]=Je,t[114]=Ye,t[115]=Xe,t[116]=Ze}else Ne=t[98],Pe=t[99],Fe=t[100],Ie=t[101],Le=t[102],Re=t[103],ze=t[104],Be=t[105],Ve=t[106],He=t[107],Ue=t[108],We=t[109],Ge=t[110],Ke=t[111],qe=t[112],Je=t[113],Ye=t[114],Xe=t[115],Ze=t[116];let Qe;t[134]!==Fe||t[135]!==Ie?(Qe=(0,Y.jsx)(`div`,{className:Fe,children:Ie}),t[134]=Fe,t[135]=Ie,t[136]=Qe):Qe=t[136];let $e;t[137]!==Ne||t[138]!==Le||t[139]!==Re||t[140]!==ze||t[141]!==Be||t[142]!==Ve||t[143]!==Qe?($e=(0,Y.jsx)(Ne,{useScrollShadow:Le,disableHorizontal:Re,preventOverscroll:ze,outerClassName:Be,className:Ve,children:Qe}),t[137]=Ne,t[138]=Le,t[139]=Re,t[140]=ze,t[141]=Be,t[142]=Ve,t[143]=Qe,t[144]=$e):$e=t[144];let et;t[145]!==He||t[146]!==Ue||t[147]!==$e?(et=(0,Y.jsxs)(`div`,{className:He,children:[Ue,$e]}),t[145]=He,t[146]=Ue,t[147]=$e,t[148]=et):et=t[148];let tt;return t[149]!==Pe||t[150]!==We||t[151]!==Ge||t[152]!==Ke||t[153]!==qe||t[154]!==Je||t[155]!==Ye||t[156]!==Xe||t[157]!==Ze||t[158]!==et?(tt=(0,Y.jsx)(Pe,{id:We,open:Ge,onOpenChange:Ke,leading:qe,ariaLabel:Je,closeAriaLabel:Ye,resizeAriaLabel:Xe,bodyClassName:Ze,children:et}),t[149]=Pe,t[150]=We,t[151]=Ge,t[152]=Ke,t[153]=qe,t[154]=Je,t[155]=Ye,t[156]=Xe,t[157]=Ze,t[158]=et,t[159]=tt):tt=t[159],tt};function _n(e){let[t,n]=e;return[t,new Set(n)]}function vn(e){return`${e.providerID}:${e.modelID}`}function yn(e){return[e.id,e]}function bn(e,t){return[e,t]}function xn(e){return e.models.length>0}function Sn(e){xt(e)||(e.preventDefault(),e.stopPropagation())}function Cn(e){e.currentTarget.focus({preventScroll:!0})}var wn=e=>{let t=(0,X.c)(217),{providerId:r,modelId:i,variant:a,onChange:o,className:s,allowedProviderIds:c,allowedModelIdsByProvider:l,placeholder:u,tooltipsEnabled:d,dropdownPortalToBody:f,showIcon:p,providers:m}=e,h=d===void 0||d,g=f!==void 0&&f,_=p===void 0||p,{t:v}=ee(),{isReady:y,isUnavailable:b}=tn(),x=L(Tn),S=m??x,C=L(En),w=n(Dn),T=n(On),E=n(kn),D=n(An),O=n(jn),k=n(Mn),A;t[0]!==i||t[1]!==r?(A={currentProviderID:r,currentModelID:i},t[0]=i,t[1]=r,t[2]=A):A=t[2];let{favoriteModelsList:j,recentModelsList:M}=G(A),{isMobile:N}=ue(),P=w||N,[F,te]=J.useState(!1),[ne,re]=J.useState(!1),ie;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(ie=()=>{te(!0),L.getState().refreshCatalogsOnPickerOpen({source:`modelSelector:mobilePanel`})},t[3]=ie):ie=t[3];let ae=I(ie),R;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(R=e=>{re(e),e&&L.getState().refreshCatalogsOnPickerOpen({source:`modelSelector:desktopMenu`})},t[4]=R):R=t[4];let z=I(R),[H,oe]=J.useState(``),[W,K]=J.useState(null),q=a!==void 0,ce;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(ce=()=>{te(!1),re(!1),oe(``),K(null)},t[5]=ce):ce=t[5];let le=ce,de;t[6]===S?de=t[7]:(de=e=>{let t=S.find(t=>t.id===e.providerID)?.models?.find(t=>t.id===e.modelID);return t?.variants?Object.keys(t.variants):[]},t[6]=S,t[7]=de);let fe=de,pe;t[8]!==O||t[9]!==fe||t[10]!==i||t[11]!==o||t[12]!==r||t[13]!==a||t[14]!==q?(pe=e=>{let t=fe(e),n=e.providerID===r&&e.modelID===i,s=e.variant!==void 0&&t.includes(e.variant)?e.variant:void 0,c=n&&a&&t.includes(a)?a:s??``;o(e.providerID,e.modelID,q?c:void 0),O(e.providerID,e.modelID,q&&c||void 0),le()},t[8]=O,t[9]=fe,t[10]=i,t[11]=o,t[12]=r,t[13]=a,t[14]=q,t[15]=pe):pe=t[15];let me=pe,he;t[16]!==o||t[17]!==q?(he=()=>{o(``,``,q?``:void 0),le()},t[16]=o,t[17]=q,t[18]=he):he=t[18];let ge=he,Z;t[19]!==O||t[20]!==o||t[21]!==W?(Z=e=>{W&&(o(W.providerID,W.modelID,e),O(W.providerID,W.modelID,e||void 0),le())},t[19]=O,t[20]=o,t[21]=W,t[22]=Z):Z=t[22];let _e=Z,Q;t[23]===v?Q=t[24]:(Q=v(`settings.agents.modelSelector.searchPlaceholder`),t[23]=v,t[24]=Q);let ve;t[25]===v?ve=t[26]:(ve=v(`settings.agents.modelSelector.state.noModelsFound`),t[25]=v,t[26]=ve);let ye;t[27]===v?ye=t[28]:(ye=v(`settings.agents.modelSelector.section.favorites`),t[27]=v,t[28]=ye);let be;t[29]===v?be=t[30]:(be=v(`settings.agents.modelSelector.section.recent`),t[29]=v,t[30]=be);let xe;t[31]===v?xe=t[32]:(xe=v(`settings.agents.modelSelector.keyboardHints`),t[31]=v,t[32]=xe);let Se;t[33]!==u||t[34]!==v?(Se=u||v(`settings.agents.modelSelector.notSelected`),t[33]=u,t[34]=v,t[35]=Se):Se=t[35];let Ce;t[36]===v?Ce=t[37]:(Ce=v(`settings.agents.modelSelector.actions.favorite`),t[36]=v,t[37]=Ce);let $;t[38]===v?$=t[39]:($=v(`settings.agents.modelSelector.actions.unfavorite`),t[38]=v,t[39]=$);let we;t[40]===v?we=t[41]:(we=v(`chat.modelControls.provider`),t[40]=v,t[41]=we);let Te;t[42]===v?Te=t[43]:(Te=v(`chat.modelControls.capabilities`),t[42]=v,t[43]=Te);let Ee;t[44]===v?Ee=t[45]:(Ee=v(`chat.modelControls.capability.toolCalling`),t[44]=v,t[45]=Ee);let De;t[46]===v?De=t[47]:(De=v(`chat.modelControls.capability.reasoning`),t[46]=v,t[47]=De);let Oe;t[48]===v?Oe=t[49]:(Oe=v(`chat.modelControls.modality.image`),t[48]=v,t[49]=Oe);let ke;t[50]===v?ke=t[51]:(ke=v(`chat.modelControls.modality.video`),t[50]=v,t[51]=ke);let Ae;t[52]===v?Ae=t[53]:(Ae=v(`chat.modelControls.modality.audio`),t[52]=v,t[53]=Ae);let je;t[54]===v?je=t[55]:(je=v(`chat.modelControls.costPerMillion`),t[54]=v,t[55]=je);let Me;t[56]===v?Me=t[57]:(Me=v(`chat.modelControls.costInput`),t[56]=v,t[57]=Me);let Ne;t[58]===v?Ne=t[59]:(Ne=v(`chat.modelControls.costOutput`),t[58]=v,t[59]=Ne);let Pe;t[60]!==Q||t[61]!==ve||t[62]!==ye||t[63]!==be||t[64]!==xe||t[65]!==Se||t[66]!==Ce||t[67]!==$||t[68]!==we||t[69]!==Te||t[70]!==Ee||t[71]!==De||t[72]!==Oe||t[73]!==ke||t[74]!==Ae||t[75]!==je||t[76]!==Me||t[77]!==Ne?(Pe={searchPlaceholder:Q,noResults:ve,favorites:ye,recent:be,keyboardHint:xe,notSelected:Se,favorite:Ce,unfavorite:$,provider:we,capabilities:Te,capabilityToolCalling:Ee,capabilityReasoning:De,modalityImage:Oe,modalityVideo:ke,modalityAudio:Ae,costPerMillion:je,costInput:Me,costOutput:Ne},t[60]=Q,t[61]=ve,t[62]=ye,t[63]=be,t[64]=xe,t[65]=Se,t[66]=Ce,t[67]=$,t[68]=we,t[69]=Te,t[70]=Ee,t[71]=De,t[72]=Oe,t[73]=ke,t[74]=Ae,t[75]=je,t[76]=Me,t[77]=Ne,t[78]=Pe):Pe=t[78];let Fe=Pe,Ie;t[79]!==i||t[80]!==r?(Ie=r&&i?{providerID:r,modelID:i}:null,t[79]=i,t[80]=r,t[81]=Ie):Ie=t[81];let Le=Ie,Re;t[82]!==i||t[83]!==u||t[84]!==r||t[85]!==v?(Re=r&&i?`${r}/${i}`:u||v(`settings.agents.modelSelector.notSelected`),t[82]=i,t[83]=u,t[84]=r,t[85]=v,t[86]=Re):Re=t[86];let ze=Re,Be;t[87]!==v||t[88]!==a||t[89]!==q?(Be=q?a||v(`chat.modelControls.default`):null,t[87]=v,t[88]=a,t[89]=q,t[90]=Be):Be=t[90];let Ve=Be,He;t[91]!==i||t[92]!==r||t[93]!==a||t[94]!==q?(He=(e,t)=>{if(!(!q||e!==r||t!==i))return a||void 0},t[91]=i,t[92]=r,t[93]=a,t[94]=q,t[95]=He):He=t[95];let Ue=He,We;t[96]!==O||t[97]!==o||t[98]!==q?(We=(e,t,n)=>{o(e,t,q?n??``:void 0),O(e,t,q&&n||void 0),le()},t[96]=O,t[97]=o,t[98]=q,t[99]=We):We=t[99];let Je=We,Ye;t[100]!==fe||t[101]!==v||t[102]!==a||t[103]!==q?(Ye=(e,t)=>{let n=fe(e);if(!q||n.length===0)return null;let r=e.variant!==void 0&&n.includes(e.variant)?e.variant:void 0,i=t.isSelected?a:r??``;return(0,Y.jsxs)(`button`,{type:`button`,className:`flex min-h-9 shrink-0 items-center gap-0.5 rounded-md px-1.5 typography-micro font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground`,onClick:t=>{t.preventDefault(),t.stopPropagation(),K(e)},"aria-label":v(`chat.modelControls.showThinkingModes`),children:[(0,Y.jsx)(`span`,{className:`max-w-24 truncate`,children:i||v(`chat.modelControls.default`)}),(0,Y.jsx)(V,{name:`arrow-right-s`,className:`size-3.5`})]})},t[100]=fe,t[101]=v,t[102]=a,t[103]=q,t[104]=Ye):Ye=t[104];let Xe=Ye,Ze=P?`max-h-none flex-1`:void 0,Qe=h&&(P?F:ne),$e;t[105]===D?$e=t[106]:($e=e=>D(e.providerID,e.modelID),t[105]=D,t[106]=$e);let et;t[107]!==i||t[108]!==r||t[109]!==E||t[110]!==a?(et=e=>E(e.providerID,e.modelID,e.providerID===r&&e.modelID===i?a||void 0:e.variant),t[107]=i,t[108]=r,t[109]=E,t[110]=a,t[111]=et):et=t[111];let tt;t[112]!==l||t[113]!==c||t[114]!==j||t[115]!==C||t[116]!==me||t[117]!==ge||t[118]!==T||t[119]!==Fe||t[120]!==k||t[121]!==S||t[122]!==M||t[123]!==Xe||t[124]!==H||t[125]!==Le||t[126]!==Ze||t[127]!==Qe||t[128]!==$e||t[129]!==et?(tt=(0,Y.jsx)(U,{providers:S,providerOrder:k,favoriteModels:j,recentModels:M,getMetadata:C,searchQuery:H,onSearchQueryChange:oe,onSelect:me,labels:Fe,selectedModel:Le,hiddenModels:T,allowedProviderIds:c,allowedModelIdsByProvider:l,includeNotSelected:!0,onSelectNone:ge,onEscape:le,maxHeightClassName:Ze,tooltipsEnabled:Qe,isFavorite:$e,onToggleFavorite:et,renderRowEnd:Xe}),t[112]=l,t[113]=c,t[114]=j,t[115]=C,t[116]=me,t[117]=ge,t[118]=T,t[119]=Fe,t[120]=k,t[121]=S,t[122]=M,t[123]=Xe,t[124]=H,t[125]=Le,t[126]=Ze,t[127]=Qe,t[128]=$e,t[129]=et,t[130]=tt):tt=t[130];let nt=tt,rt;t[131]!==fe||t[132]!==W?(rt=W?fe(W):[],t[131]=fe,t[132]=W,t[133]=rt):rt=t[133];let it=rt,at;bb0:{if(!W){at=``;break bb0}if(W.providerID===r&&W.modelID===i){at=a||``;break bb0}at=W.variant!==void 0&&it.includes(W.variant)?W.variant:``}let ot=at,st;t[134]!==_e||t[135]!==v||t[136]!==W||t[137]!==ot||t[138]!==it?(st=W?(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`flex min-h-11 items-center gap-2 border-b border-border/40 px-3 text-left typography-ui-label font-medium text-foreground hover:bg-interactive-hover`,onClick:()=>K(null),"aria-label":v(`header.actions.backAria`),children:[(0,Y.jsx)(V,{name:`arrow-left`,className:`size-4`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:W.modelID})]}),(0,Y.jsx)(`div`,{className:`space-y-1 p-2`,role:`listbox`,"aria-label":v(`chat.modelControls.thinking`),children:[``,...it].map(e=>{let t=ot===e;return(0,Y.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,className:B(`flex min-h-11 w-full items-center justify-between rounded-lg px-3 text-left typography-ui-label transition-colors`,t?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),onClick:()=>_e(e),children:[(0,Y.jsx)(`span`,{className:`truncate`,children:e||v(`chat.modelControls.default`)}),t?(0,Y.jsx)(V,{name:`check`,className:`size-4 shrink-0`}):null]},e||`__default`)})})]}):null,t[134]=_e,t[135]=v,t[136]=W,t[137]=ot,t[138]=it,t[139]=st):st=t[139];let ct=st||nt;if(P){let e=y?ae:void 0,n=!y,o=!y&&`opacity-60 cursor-not-allowed`,u;t[140]!==s||t[141]!==o?(u=B(`flex w-full items-center justify-between gap-2 rounded-lg border border-border/40 bg-[var(--surface-elevated)] px-2 py-1.5 text-left`,o,s),t[140]=s,t[141]=o,t[142]=u):u=t[142];let d;t[143]!==y||t[144]!==b||t[145]!==i||t[146]!==r||t[147]!==_||t[148]!==v?(d=y?_&&(r||i)?(0,Y.jsx)(se,{modelId:i,providerId:r,className:`h-3.5 w-3.5 flex-shrink-0`}):_?(0,Y.jsx)(V,{name:`pencil-ai`,className:`h-3 w-3 text-muted-foreground`}):null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(V,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:v(b?`common.unavailable`:`common.loading`)})]}),t[143]=y,t[144]=b,t[145]=i,t[146]=r,t[147]=_,t[148]=v,t[149]=d):d=t[149];let f;t[150]!==y||t[151]!==ze?(f=y?(0,Y.jsx)(`span`,{className:`typography-meta font-medium text-foreground truncate`,children:ze}):null,t[150]=y,t[151]=ze,t[152]=f):f=t[152];let p;t[153]!==y||t[154]!==Ve?(p=y&&Ve?(0,Y.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground`,children:Ve}):null,t[153]=y,t[154]=Ve,t[155]=p):p=t[155];let m;t[156]!==d||t[157]!==f||t[158]!==p?(m=(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[d,f,p]}),t[156]=d,t[157]=f,t[158]=p,t[159]=m):m=t[159];let h;t[160]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Y.jsx)(V,{name:`arrow-down-s`,className:`h-3 w-3 flex-shrink-0 text-muted-foreground`}),t[160]=h):h=t[160];let g;t[161]!==e||t[162]!==n||t[163]!==u||t[164]!==m?(g=(0,Y.jsxs)(`button`,{type:`button`,onClick:e,disabled:n,className:u,children:[m,h]}),t[161]=e,t[162]=n,t[163]=u,t[164]=m,t[165]=g):g=t[165];let x;t[166]!==j||t[167]!==i||t[168]!==r||t[169]!==M||t[170]!==E||t[171]!==a?(x=(e,t)=>E(e,t,e===r&&t===i?a||void 0:j.find(n=>n.providerID===e&&n.modelID===t)?.variant??M.find(n=>n.providerID===e&&n.modelID===t)?.variant),t[166]=j,t[167]=i,t[168]=r,t[169]=M,t[170]=E,t[171]=a,t[172]=x):x=t[172];let w;t[173]!==l||t[174]!==c||t[175]!==j||t[176]!==C||t[177]!==Je||t[178]!==T||t[179]!==D||t[180]!==F||t[181]!==i||t[182]!==r||t[183]!==k||t[184]!==S||t[185]!==M||t[186]!==Ue||t[187]!==x||t[188]!==q?(w=(0,Y.jsx)(gn,{open:F,onClose:le,selectedProviderID:r,selectedModelID:i,resolveSelectedVariant:Ue,onSelect:Je,providers:S,favoriteModels:j,recentModels:M,getMetadata:C,hiddenModels:T,allowedProviderIds:c,allowedModelIdsByProvider:l,providerOrder:k,variantSelectionEnabled:q,isFavorite:D,onToggleFavorite:x}),t[173]=l,t[174]=c,t[175]=j,t[176]=C,t[177]=Je,t[178]=T,t[179]=D,t[180]=F,t[181]=i,t[182]=r,t[183]=k,t[184]=S,t[185]=M,t[186]=Ue,t[187]=x,t[188]=q,t[189]=w):w=t[189];let O;return t[190]!==g||t[191]!==w?(O=(0,Y.jsxs)(Y.Fragment,{children:[g,w]}),t[190]=g,t[191]=w,t[192]=O):O=t[192],O}let lt=y&&ne,ut=y?z:void 0,dt=!y&&`opacity-60 cursor-not-allowed`,ft;t[193]!==s||t[194]!==dt?(ft=B(`border-input data-[placeholder]:text-muted-foreground flex min-w-0 items-center justify-between gap-2 rounded-lg border bg-transparent px-2 py-2 typography-ui-label whitespace-nowrap shadow-none outline-none hover:bg-interactive-hover data-[popup-open]:bg-interactive-active h-6 w-fit`,dt,s),t[193]=s,t[194]=dt,t[195]=ft):ft=t[195];let pt;t[196]!==y||t[197]!==b||t[198]!==i||t[199]!==r||t[200]!==_||t[201]!==v||t[202]!==ze||t[203]!==Ve?(pt=y?(0,Y.jsxs)(Y.Fragment,{children:[_?r||i?(0,Y.jsx)(se,{modelId:i,providerId:r,className:`h-3.5 w-3.5 flex-shrink-0`}):(0,Y.jsx)(V,{name:`pencil-ai`,className:`h-3.5 w-3.5 flex-shrink-0 text-muted-foreground`}):null,(0,Y.jsx)(`span`,{className:`typography-ui-label min-w-0 flex-1 truncate text-left font-normal text-foreground`,children:ze}),Ve?(0,Y.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground`,children:Ve}):null]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(V,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin text-muted-foreground flex-shrink-0`}),(0,Y.jsx)(`span`,{className:`typography-ui-label font-normal whitespace-nowrap text-muted-foreground`,children:v(b?`common.unavailable`:`common.loading`)})]}),t[196]=y,t[197]=b,t[198]=i,t[199]=r,t[200]=_,t[201]=v,t[202]=ze,t[203]=Ve,t[204]=pt):pt=t[204];let mt;t[205]===Symbol.for(`react.memo_cache_sentinel`)?(mt=(0,Y.jsx)(V,{name:`arrow-down-s`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground/50`}),t[205]=mt):mt=t[205];let ht;t[206]!==ft||t[207]!==pt?(ht=(0,Y.jsx)(Ke,{asChild:!0,children:(0,Y.jsxs)(`div`,{className:ft,children:[pt,mt]})}),t[206]=ft,t[207]=pt,t[208]=ht):ht=t[208];let gt;t[209]!==g||t[210]!==ct?(gt=(0,Y.jsx)(qe,{className:`w-[min(380px,calc(100vw-2rem))] p-0 flex flex-col`,align:`start`,portalToBody:g,children:ct}),t[209]=g,t[210]=ct,t[211]=gt):gt=t[211];let _t;return t[212]!==lt||t[213]!==ut||t[214]!==ht||t[215]!==gt?(_t=(0,Y.jsxs)(Ge,{open:lt,onOpenChange:ut,children:[ht,gt]}),t[212]=lt,t[213]=ut,t[214]=ht,t[215]=gt,t[216]=_t):_t=t[216],_t};function Tn(e){return e.providers}function En(e){return e.getModelMetadata}function Dn(e){return e.isMobile}function On(e){return e.hiddenModels}function kn(e){return e.toggleFavoriteModel}function An(e){return e.isFavoriteModel}function jn(e){return e.addRecentModel}function Mn(e){return e.providerOrder}var Nn=e=>e??s()?.github,Pn=(e=t())=>i.github.auth(e),Fn=async(e,t)=>{if(e)return e.authStatus();let n=await a(`/api/github/auth/status`,{method:`GET`,headers:{Accept:`application/json`},signal:t}),r=await n.json().catch(()=>null);if(!n.ok||!r)throw Error(r?.error||n.statusText||`Failed to load GitHub status`);return r},In=(e,n=t())=>{let r=Nn(e);return{queryKey:Pn(n),queryFn:async({signal:e})=>Fn(r,e),retry:2}},Ln=e=>!!e&&typeof e==`object`&&`authStatus`in e,Rn=e=>{let t=(0,X.c)(5),n=Ln(e)?e:void 0,r=Ln(e)?void 0:e?.enabled,i;t[0]===n?i=t[1]:(i=In(n),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a={...i,enabled:r},t[2]=r,t[3]=i,t[4]=a):a=t[4],S(a)},zn=(e=o,n=t())=>e.getQueryData(Pn(n))??null,Bn=async(e,n,r)=>t()===r?e.fetchQuery({...In(n,r),staleTime:0}):e.getQueryData(Pn(r))??null,Vn=(e=o,n,r=t())=>{e.setQueryData(Pn(r),n)},Hn=E.define(F),Un=M.data.of({commentTokens:{line:`//`,block:{open:`/*`,close:`*/`}}});function Wn(e){let t=e.trim().toLowerCase();switch(t){case`bash`:case`sh`:case`zsh`:case`shell`:case`shellsession`:case`console`:return Hn;case`json`:case`jsonc`:case`json5`:return j().language;case`js`:case`javascript`:return k().language;case`jsx`:return k({jsx:!0}).language;case`ts`:case`typescript`:return k({typescript:!0}).language;case`tsx`:return k({typescript:!0,jsx:!0}).language;case`html`:return A().language;case`css`:return O().language;case`py`:case`python`:return P().language;case`md`:case`markdown`:case`mdown`:case`mkd`:return N().language;case`heex`:case`eex`:case`leex`:return A().language;default:return D.matchLanguageName(de,t,!0)}}var Gn=e=>e.split(`/`).pop()?.toLowerCase()??``,Kn=e=>{let t=Gn(e);return t?D.matchFilename(de,t):null},qn=()=>C(T.define([{tag:[w.heading1,w.heading2,w.heading3,w.heading4,w.heading5,w.heading6],fontWeight:`600`},{tag:w.strong,fontWeight:`600`},{tag:w.emphasis,fontStyle:`italic`},{tag:w.strikethrough,textDecoration:`line-through`},{tag:[w.link,w.url],color:`var(--markdown-link, currentColor)`,textDecoration:`underline`},{tag:w.monospace,color:`var(--markdown-inline-code, currentColor)`,backgroundColor:`var(--markdown-inline-code-bg, transparent)`},{tag:w.quote,color:`var(--markdown-blockquote, currentColor)`,fontStyle:`italic`},{tag:w.list,color:`color-mix(in srgb, var(--muted-foreground) 40%, var(--foreground) 60%)`},{tag:w.heading,color:`var(--markdown-heading1, currentColor)`}]));function Jn(e){let t=e.toLowerCase();switch(Gn(t)){case`makefile`:case`gnumakefile`:return Hn}let n=t.lastIndexOf(`.`),r=n>=0?t.slice(n+1):``;switch(r){case`ts`:case`tsx`:case`mts`:case`cts`:return k({typescript:!0,jsx:r===`tsx`});case`js`:case`jsx`:case`mjs`:case`cjs`:return k({typescript:!1,jsx:r===`jsx`});case`jsonc`:case`json5`:return[j(),Un];case`json`:case`jsonl`:case`ndjson`:case`geojson`:return j();case`css`:case`scss`:case`sass`:case`less`:return O();case`html`:case`htm`:case`xml`:case`drawio`:case`dio`:return A();case`md`:case`mdx`:case`markdown`:case`mdown`:case`mkd`:return[N({codeLanguages:Wn}),qn()];case`sh`:case`bash`:case`zsh`:case`fish`:case`env`:return Hn;case`py`:case`pyw`:case`pyi`:return P();default:return null}}async function Yn(e){let t=Kn(e);if(!t)return null;if(t.support)return t.support;try{return await t.load()}catch{return null}}var Xn=60,Zn=400;function Qn(e){let t=e.replace(/\s+/g,` `).trim();if(!t)return[];let n=t.match(/[^.!?…]+[.!?…]+["')\]]*\s*|[^.!?…]+$/g)??[t],r=[],i=``;for(let e of n)for(let t=0;t<e.length;t+=Zn){let n=e.slice(t,t+Zn);i&&i.length+n.length>Zn&&(r.push(i.trim()),i=``),i+=n,i.length>=Xn&&/[.!?…]["')\]]*\s*$/.test(i)&&(r.push(i.trim()),i=``)}if(i.trim()&&r.push(i.trim()),r.length>0&&r[0].length>120){let e=r[0],t=/[,;:]\s/g,n=-1,i;for(;(i=t.exec(e))!==null;){let e=i.index+1;if(!(e<40)){if(e>160)break;n=e;break}}if(n>0){let t=e.slice(0,n).trim(),i=e.slice(n).trim();r.splice(0,1,t,i)}}return r}var $n=null;function er(){return $n||=new(window.AudioContext||window.webkitAudioContext),$n}function tr(){let[e,t]=(0,J.useState)(!1),[n,r]=(0,J.useState)(null),i=(0,J.useRef)(null),o=(0,J.useRef)(null),s=(0,J.useCallback)(async()=>{try{let e=er();e.state===`suspended`&&await e.resume();let t=e.createBuffer(1,1,22050),n=e.createBufferSource();n.buffer=t,n.connect(e.destination),n.start(0)}catch{}},[]),c=(0,J.useCallback)(()=>{let e=o.current;if(e&&(e.cancelled=!0,e.abort.abort(),o.current=null),i.current){try{i.current.onended=null,i.current.stop()}catch{}i.current=null}t(!1)},[]),l=(0,J.useCallback)(async(e,n)=>{c();let s=Qn(e);if(s.length===0){r(`No text to speak`),n?.onError?.(`No text to speak`);return}r(null);let l={cancelled:!1,abort:new AbortController};o.current=l;let u=async e=>{let t=await a(`/api/dictation/tts/speak`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e,...typeof n?.speakerId==`number`?{speakerId:n.speakerId}:{},...typeof n?.speed==`number`?{speed:n.speed}:{}}),signal:l.abort.signal});if(!t.ok){let e=await t.json().catch(()=>({error:`Unknown error`}));throw Error(e.error||`HTTP ${t.status}`)}return(await t.blob()).arrayBuffer()},d=async e=>{let t=er();t.state===`suspended`&&await t.resume();let n=await t.decodeAudioData(e);l.cancelled||await new Promise(e=>{let r=t.createBufferSource();r.buffer=n,r.connect(t.destination),i.current=r,r.onended=()=>{i.current===r&&(i.current=null),e()},r.start(0)})};try{t(!0),n?.onStart?.();let e=u(s[0]);for(let t=0;t<s.length;t+=1){let n=await e;if(l.cancelled||(t+1<s.length&&(e=u(s[t+1])),await d(n),l.cancelled))return}t(!1),n?.onEnd?.()}catch(e){if(e.name===`AbortError`||l.cancelled)return;let i=e instanceof Error?e.message:`Failed to speak`;r(i),n?.onError?.(i),t(!1)}finally{o.current===l&&(o.current=null)}},[c]);return(0,J.useEffect)(()=>()=>{c()},[c]),{isPlaying:e,error:n,speak:l,stop:c,unlockAudio:s}}var nr=new class{recognition=null;isListening=!1;currentLang=`en-US`;onResultCallback=null;onErrorCallback=null;restartOnEnd=!1;conversationMode=!1;isSpeaking=!1;audioContext=null;audioUnlockRequired=!1;isSupported(){let e=`SpeechRecognition`in window||`webkitSpeechRecognition`in window,t=`speechSynthesis`in window;return e&&t}getSupportDetails(){return{recognition:`SpeechRecognition`in window||`webkitSpeechRecognition`in window,synthesis:`speechSynthesis`in window,prefixed:!(`SpeechRecognition`in window)&&`webkitSpeechRecognition`in window,secureContext:window.isSecureContext}}setConversationMode(e){this.conversationMode=e,e||(this.restartOnEnd=!1)}isConversationMode(){return this.conversationMode}pauseListening(){if(this.restartOnEnd=!1,this.recognition)try{this.recognition.stop()}catch{}this.isListening=!1}resumeListening(){if(this.conversationMode,this.onResultCallback,this.isSpeaking,this.currentLang,this.conversationMode&&this.onResultCallback&&!this.isSpeaking)try{this.startListeningSync(this.currentLang,this.onResultCallback,this.onErrorCallback||void 0)}catch(e){console.error(`[BrowserVoiceService] Failed to resume listening:`,e)}}async checkMicrophonePermission(){try{return`permissions`in navigator&&(await navigator.permissions.query({name:`microphone`})).state===`granted`}catch{return!1}}async prepareListening(){if(!this.isSupported())throw Error(`Web Speech API not supported in this browser`);if(typeof navigator>`u`||typeof navigator.mediaDevices?.getUserMedia!=`function`)return!0;try{return(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(e=>e.stop()),!0}catch(e){let t=typeof e==`object`&&e&&`name`in e?String(e.name):``;if(t===`NotAllowedError`)throw Error(`Microphone permission denied`);if(t===`NotFoundError`)throw Error(`No microphone found`);let n=e instanceof Error?e.message:`Unable to access microphone`;throw Error(n)}}startListeningSync(e,t,n){if(!this.isSupported()){let e=`Web Speech API not supported in this browser`;throw n?.(e),Error(e)}this.stopListening();let r=window.SpeechRecognition||window.webkitSpeechRecognition;if(!r){let e=`Web Speech API not supported in this browser`;throw n?.(e),Error(e)}let i=new r;this.recognition=i,this.currentLang=e,this.onResultCallback=t,this.onErrorCallback=n||null,i.continuous=!0,i.interimResults=!0,i.lang=e,i.onstart=()=>{this.isListening=!0,this.restartOnEnd=!0},i.onaudiostart=()=>{},i.onsoundstart=()=>{},i.onresult=e=>{e.results.length;let t=``,n=``;for(let r=e.resultIndex;r<e.results.length;r++){let i=e.results[r];i.isFinal?t+=i[0].transcript:n+=i[0].transcript}n&&this.onResultCallback?.(n,!1),t&&this.onResultCallback?.(t,!0)},i.onerror=e=>{if(e.error===`aborted`)return;let t=this.getErrorMessage(e.error);this.onErrorCallback?.(t),(e.error===`not-allowed`||e.error===`service-not-allowed`||e.error===`network`)&&(this.restartOnEnd=!1,this.isListening=!1)},i.onend=()=>{if(this.isListening=!1,this.restartOnEnd&&this.recognition&&!this.isSpeaking)try{this.recognition.start()}catch{}};try{i.start()}catch(e){let t=e instanceof Error?e.message:`Failed to start speech recognition`;throw n?.(t),Error(t)}}async startListening(e,t,n){this.startListeningSync(e,t,n)}stopListening(){if(this.restartOnEnd=!1,this.recognition){try{this.recognition.stop()}catch{}this.recognition=null}this.isListening=!1}getIsListening(){return this.isListening}getCurrentLang(){return this.currentLang}async resumeAudioContext(){this.audioContext||=new(window.AudioContext||window.webkitAudioContext),this.audioContext.state===`suspended`&&await this.audioContext.resume()}isAudioUnlockRequired(){return this.audioUnlockRequired}async unlockAudio(){try{let e=new Audio;if(e.src=`data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA`,e.volume=.01,await e.play(),await this.resumeAudioContext(),this.isMobileDevice()&&`speechSynthesis`in window){let e=new SpeechSynthesisUtterance(``);e.volume=0,window.speechSynthesis.speak(e),window.speechSynthesis.cancel()}return this.audioUnlockRequired=!1,!0}catch(e){return console.error(`[BrowserVoiceService] Failed to unlock audio:`,e),!1}}async speakText(e,t,n,r){if(!(`speechSynthesis`in window))throw Error(`Speech synthesis not supported`);await this.resumeAudioContext();let i=await this.waitForVoices();await new Promise(e=>setTimeout(e,50)),this.isSpeaking=!0,this.pauseListening(),window.speechSynthesis.cancel();let a=new SpeechSynthesisUtterance(e);a.lang=t,a.rate=r?.rate??1,a.pitch=r?.pitch??1,a.volume=r?.volume??1;let o=null;return r?.voiceName&&(o=i.find(e=>e.name===r.voiceName)||null,o?`${o.name}${o.lang}`:console.warn(`[BrowserVoiceService] Selected voice "${r.voiceName}" not found, falling back to language match`)),o||(o=this.findBestVoice(i,t),o?`${o.name}${o.lang}`:console.warn(`[BrowserVoiceService] No voice found for language: ${t}, using default`)),o&&(a.voice=o),`${e.length}${t}`,new Promise((e,t)=>{let r=!1;a.onstart=()=>{r=!0,e()},a.onend=()=>{this.isSpeaking=!1,n?.()},a.onerror=e=>{this.isSpeaking=!1,console.error(`[BrowserVoiceService] Speech synthesis error:`,e.error),(e.error===`not-allowed`||e.error===`interrupted`)&&(this.audioUnlockRequired=!0);let n=`Speech synthesis error: ${e.error||`unknown`}`;e.error===`not-allowed`?n=`Audio blocked by browser autoplay policy. Please interact with the page first.`:e.error===`interrupted`&&(n=`Speech was interrupted. Please try again.`),t(Error(n))},setTimeout(()=>{r||(console.warn(`[BrowserVoiceService] Speech start timeout - audio may be blocked`),this.audioUnlockRequired=!0)},2e3),window.speechSynthesis.speak(a)})}cancelSpeech(){`speechSynthesis`in window&&window.speechSynthesis.cancel()}getVoices(){return`speechSynthesis`in window?window.speechSynthesis.getVoices():[]}async waitForVoices(){if(!(`speechSynthesis`in window))return[];let e=window.speechSynthesis.getVoices();return e.length>0?e:new Promise(e=>{let t=()=>{e(window.speechSynthesis.getVoices()),window.speechSynthesis.onvoiceschanged=null};window.speechSynthesis.onvoiceschanged=t,setTimeout(()=>{e(window.speechSynthesis.getVoices()),window.speechSynthesis.onvoiceschanged=null},1e3)})}findBestVoice(e,t){let n=e.find(e=>e.lang===t);if(!n){let r=t.split(`-`)[0];n=e.find(e=>e.lang.startsWith(r))}return n||=e.find(e=>e.lang.startsWith(t.split(`-`)[0])&&e.localService),n||null}isMobileDevice(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent.toLowerCase();return/iphone|ipad|ipod|android|mobile|webos|blackberry|iemobile|opera mini/i.test(e)}isIOSSafari(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent.toLowerCase(),t=/iphone|ipad|ipod/i.test(e),n=/safari/i.test(e)&&!/chrome|crios|crmo/i.test(e);return t&&n}getErrorMessage(e){let t=this.isMobileDevice(),n=this.isIOSSafari();return{"no-speech":`No speech detected`,aborted:`Speech recognition aborted`,"audio-capture":`No microphone found`,network:`Network error - check connection`,"not-allowed":t?`Microphone permission denied. Check Settings > Safari > Microphone`:`Microphone permission denied`,"service-not-allowed":n?`Speech recognition requires a user gesture. Please tap the microphone button again.`:`Speech recognition service not allowed`,"bad-grammar":`Grammar error`,"language-not-supported":`Language not supported`}[e]||`Speech recognition error: ${e}`}},rr=e=>{if(e===`12h`)return!0;if(e===`24h`)return!1},ir=(e,t,n={})=>{let r=e instanceof Date?e:new Date(e);return Number.isFinite(r.getTime())?r.toLocaleTimeString(te(),{hour:n.hour??`numeric`,minute:`2-digit`,second:n.precision===`second`?`2-digit`:void 0,hour12:rr(t)}):n.fallback??``},ar=(e,t,n)=>{let r=e instanceof Date?e:new Date(e);return Number.isFinite(r.getTime())?r.toLocaleString(te(),{...n,hour12:n.hour?rr(t):n.hour12}):``},or=J.memo(function(e){let t=(0,X.c)(24),{checked:n,onChange:r,disabled:i,ariaLabel:a,className:o,iconClassName:s}=e,c=i!==void 0&&i,l;t[0]!==n||t[1]!==c||t[2]!==r?(l=e=>{e.preventDefault(),e.stopPropagation(),!c&&!n&&r()},t[0]=n,t[1]=c,t[2]=r,t[3]=l):l=t[3];let u=l,d;t[4]!==n||t[5]!==c||t[6]!==r?(d=e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),!c&&!n&&r())},t[4]=n,t[5]=c,t[6]=r,t[7]=d):d=t[7];let f=d,p=n?`bg-[color-mix(in_srgb,var(--primary-base)_80%,transparent)] shadow-none hover:bg-[var(--primary-base)]`:`bg-[var(--surface-muted)] shadow-[inset_0_0_0_1px_var(--interactive-border)] hover:bg-[var(--interactive-hover)]`,m;t[8]!==o||t[9]!==p?(m=B(`group/radio relative flex h-[14px] w-[14px] min-h-[14px] min-w-[14px] shrink-0 self-center items-center justify-center rounded-full outline-none`,`transition-[background-color,box-shadow] duration-200 ease-out`,p,`focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-background`,`disabled:cursor-not-allowed disabled:opacity-50`,o),t[8]=o,t[9]=p,t[10]=m):m=t[10];let h=!n&&`opacity-0`,g;t[11]!==s||t[12]!==h?(g=B(`block h-[5px] w-[5px] rounded-full bg-white`,h,s),t[11]=s,t[12]=h,t[13]=g):g=t[13];let _;t[14]===g?_=t[15]:(_=(0,Y.jsx)(`span`,{"aria-hidden":!0,className:g}),t[14]=g,t[15]=_);let v;return t[16]!==a||t[17]!==n||t[18]!==c||t[19]!==u||t[20]!==f||t[21]!==m||t[22]!==_?(v=(0,Y.jsx)(`button`,{type:`button`,role:`radio`,onClick:u,onKeyDown:f,disabled:c,"aria-checked":n,"aria-label":a,className:m,children:_}),t[16]=a,t[17]=n,t[18]=c,t[19]=u,t[20]=f,t[21]=m,t[22]=_,t[23]=v):v=t[23],v});export{he as $,Ze as A,Fe as B,Ct as C,Ge as D,_t as E,ze as F,Ne as G,ke as H,Re as I,Pe as J,Ie as K,Ve as L,Xe as M,Qe as N,qe as O,Ke as P,_e as Q,Be as R,St as S,st as T,je as U,Le as V,Me as W,Ee as X,we as Y,Q as Z,en as _,tr as a,Tt as b,Yn as c,Vn as d,Rn as f,tn as g,sn as h,nr as i,Ye as j,Je as k,zn as l,gn as m,ar as n,Wn as o,wn as p,Ae as q,ir as r,Jn as s,or as t,Bn as u,$t as v,vt as w,Dt as x,Zt as y,ve as z};