@openchambery/web 2.1.6-beta.7 → 2.1.6-beta.8
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.
- package/dist/assets/{AssistantView-BAn7c1j0.js → AssistantView-DEgk8zFQ.js} +3 -3
- package/dist/assets/{DiagramView-CcT2y7La.js → DiagramView-TqJ96jNZ.js} +1 -1
- package/dist/assets/{MarkdownRenderer-DVE7BXyU.js → MarkdownRenderer-ay1C0iBl.js} +2 -2
- package/dist/assets/{MarkdownRendererImpl-BoidX86O.js → MarkdownRendererImpl-BQ5gjm84.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-B8MznUfR.js → MarkstreamRendererImpl-D6oVn8YB.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-BB2hRMes.js → MobileDetailNavigation-DjSx2XsI.js} +1 -1
- package/dist/assets/{MobileShareBridge-DmY_F56w.js → MobileShareBridge-bUVeRgMu.js} +1 -1
- package/dist/assets/{MobileTabPageHeader-wyNSBINq.js → MobileTabPageHeader-C-qELMht.js} +1 -1
- package/dist/assets/{MultiRunWindow-CQdG8Sjp.js → MultiRunWindow-bdZ8KxQ4.js} +1 -1
- package/dist/assets/{SettingsView-CpA3P8Hj.js → SettingsView-Cm_O8_wY.js} +1 -1
- package/dist/assets/{SettingsWindow-MxNLysXf.js → SettingsWindow-DUm002Qh.js} +1 -1
- package/dist/assets/{TerminalView-Bc1rQTuK.js → TerminalView-CrA4woEt.js} +1 -1
- package/dist/assets/{ToolOutputDialog-0MzoUb8d.js → ToolOutputDialog-BqEW9vXz.js} +1 -1
- package/dist/assets/{appThemeRegistry-DuusPsuR.js → appThemeRegistry-7wsjg75c.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-zYNvEOA7.js → fileMentionTouchSelection-CAgwUaAa.js} +1 -1
- package/dist/assets/{gitApi-k8hCwYqu.js → gitApi-C5PWzwrk.js} +1 -1
- package/dist/assets/{insertionBoundaries-D2KDgrS0.js → insertionBoundaries-h6CWdDVI.js} +1 -1
- package/dist/assets/{main-rsLnx-58.js → main-DN90NOFu.js} +2 -2
- package/dist/assets/{main-CDLieC0x.js → main-DrGR36R7.js} +4 -4
- package/dist/assets/{mcpQueries-DxtC14uJ.js → mcpQueries-vZ-Xi7QR.js} +1 -1
- package/dist/assets/{miniChat-_WMT0ocE.js → miniChat-C5aDHUCn.js} +2 -2
- package/dist/assets/{mobile-DlsyRhzT.js → mobile-8DIjKQCb.js} +2 -2
- package/dist/assets/{multirun-TuZ84E4i.js → multirun-CQTZn3hi.js} +1 -1
- package/dist/assets/{projectMeta-CRGyp6h1.js → projectMeta-2C2lGY_I.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-CcwM2ERi.js → renderElectronMiniChatApp-U1X0c-Nd.js} +2 -2
- package/dist/assets/{renderMobileApp-Ci90vrGl.js → renderMobileApp-PfqXZ9p3.js} +4 -4
- package/dist/assets/{runtimeConfig-DnxTxkDG.js → runtimeConfig-Cr-E7r-Q.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-DLwrJ8o6.js → runtimeEndpointReset-20oUvfZu.js} +1 -1
- package/dist/assets/{sessionChangeSummary-DjTq4ZTb.js → sessionChangeSummary-CsT4E_f7.js} +1 -1
- package/dist/assets/{sessionLookup-ai7V-fcR.js → sessionLookup-DcnUxyqW.js} +1 -1
- package/dist/assets/{speechSettingsQueries-GUD7hwQt.js → speechSettingsQueries-B642gwwQ.js} +1 -1
- package/dist/assets/{useAppFontEffects-ADlv1hDy.js → useAppFontEffects-DrAwGQSV.js} +6 -6
- package/dist/assets/{useDesktopWindowControlsLayout-D63tZVkG.js → useDesktopWindowControlsLayout-D0GD3nL8.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-DSPgEsnp.js → useEffectiveDirectory-D8Fay6-C.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-CaaSJtom.js → useMobileNavigationStore-DX_Dgij_.js} +3 -3
- package/dist/assets/{useWorkerHighlightedLines-D6B2J_UI.js → useWorkerHighlightedLines-Dztk8sDw.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/mini-chat.html +2 -2
- package/dist/mobile.html +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/assistant-attachment-cache-Bzewqov4.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-auth-C8w0nlKy.js","assets/runtime-switch-3ad3yzM7.js","assets/runtime-fetch-QCWYlAx0.js","assets/dualLimitLru-D8Sphgua.js","assets/relay-image-stream-qI2NTXbG.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,l as r,n as i}from"./runtime-switch-3ad3yzM7.js";import{n as a}from"./runtime-fetch-QCWYlAx0.js";import{Mn as o,h as s,l as c,m as l,nn as u,on as d,ot as f,rn as p}from"./persistence-DUPZl7Oy.js";import{h as m}from"./desktopHosts-BKeEWmL5.js";import{i as h,n as g,r as _}from"./desktopRelayRestore-FWm2fXr6.js";import{A as v,D as y,F as b,I as x,L as S,M as C,N as w,O as T,P as E,it as D,j as O,nt as k,rt as A}from"./vendor-base-ui-CdzJ6My_.js";import{Ln as j,Nt as ee}from"./platform-z2erC6Bs.js";import{n as te}from"./useUIStore-pl39iO82.js";import{n as ne}from"./vendor-react-BP2cRVqX.js";import{o as M}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{n as re}from"./vendor-tanstack-query-core-BWz0ose6.js";import{i as ie,l as ae,n as N,r as oe,s as P}from"./vendor-tanstack-react-query-CdqCAt40.js";import{P as F,V as I,a as se,f as L,l as ce}from"./vendor-codemirror-autocomplete-DHomsvW7.js";import{c as R,o as z,r as B}from"./vendor-codemirror-lang-angular-BDXnzWgq.js";import{n as V,r as le}from"./vendor-codemirror-lang-json-tHviF6YN.js";import{n as ue}from"./vendor-codemirror-lang-markdown-Bt-vLz9k.js";import{n as de}from"./vendor-codemirror-lang-python-B4naLXMo.js";import{O as fe}from"./vendor-codemirror-legacy-modes-DwltVFbT.js";import{n as pe}from"./vendor-reactuses-core-BpfIZ1tg.js";import{d as me,f as he,l as ge,p as H,r as U,t as _e}from"./button-kJNzMb1G.js";import{i as ve,t as ye}from"./store-D5OeM4wB.js";import{Ar as be,Dr as xe,Fa as Se,Na as Ce,Pr as we,Va as Te,ba as W,br as Ee,d as De,mo as Oe,to as ke,va as Ae}from"./useMobileNavigationStore-CaaSJtom.js";import{t as je}from"./AgentAvatar-Ah1nMt7y.js";import{t as Me}from"./useThemeSystem-8jhE4Zyk.js";import{n as G}from"./Icon-DewMAW7N.js";import{i as Ne,n as Pe,r as Fe,t as Ie}from"./vendor-simplewebauthn-browser-Dwhcdg_5.js";import{C as Le,D as Re,O as ze,S as Be,T as Ve,w as He}from"./projectMeta-CRGyp6h1.js";import{t as Ue}from"./input-02eTmC8w.js";import{i as We}from"./OverlayScrollbar-C24-p2ns.js";import{_ as Ge,g as Ke,h as qe,i as Je,n as Ye,v as Xe}from"./textarea-yLPH5NYp.js";import{c as Ze,d as Qe,f as $e,h as et,l as tt,m as nt,n as rt,p as it,r as at,s as ot,t as st,u as ct}from"./dropdown-menu.styles-BXvVFEkh.js";import{t as lt}from"./vendor-codemirror-language-data-DGDYune4.js";var K=ne(),ut=[`desktopHostSwitch`],dt=class extends Error{result;host;constructor(e,t){super(e.reason),this.name=`DesktopHostSwitchError`,this.result=e,this.host=t}},ft=(e,t)=>ye(ve.getState().dictionary,e,t),pt=async e=>{let{host:t}=e;if(t.id===`local`){let n=(e.localApiOrigin||``).trim();if(!n)throw new dt({ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unreachable`},t);return r({apiBaseUrl:n,clientToken:e.localClientToken||null,runtimeKey:_(t)}),{ok:!0,via:`direct`,status:{status:`ok`,latencyMs:0}}}let n=await h(t,{cachedProbe:e.cachedProbe});if(!n.ok)throw new dt(n,t);return n},mt=null,ht=()=>mt||(mt=new re(l,{mutationKey:ut,mutationFn:pt,onError:(e,t)=>{if(e instanceof dt&&e.result.reason!==`unsupported`){if(e.result.status.status===`auth`){we.error(ft(`desktopHostSwitcher.status.authRequired`));return}we.error(ft(`desktopHostSwitcher.toast.instanceUnreachable`,{host:m(t.host.label)}))}}}),mt.subscribe(()=>void 0),mt),gt=async e=>{if(g(e.host))return{ok:!0,via:`direct`,status:e.cachedProbe?.status===`ok`?e.cachedProbe:{status:`ok`,latencyMs:0}};if(l.isMutating({mutationKey:ut})>0)return{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unsupported`};try{return await ht().mutate(e)}catch(e){if(e instanceof dt)return e.result;throw e}},_t=()=>{let e=(0,K.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={mutationKey:ut},e[0]=t):t=e[0],oe(t)>0},vt=()=>{let e=(0,K.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={filters:{mutationKey:ut,status:`pending`},select:yt},e[0]=t):t=e[0],ie(t)[0]?.host.id??null};function yt(e){return e.state.variables}var q=e=>typeof e==`object`&&!!e,J=(e,t)=>{let n=e[t];return typeof n==`string`?n:null},Y=(e,t)=>{let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:null},X=(e,t)=>{let n=e[t];return typeof n==`boolean`?n:null},bt=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],xt=()=>u()?(e,t)=>p(e,t):null,St=e=>{if(!q(e))return;let t=X(e,`enabled`)??!1,n=J(e,`store`)?.toLowerCase()===`settings`?`settings`:`never`,r=J(e,`value`);return{enabled:t,store:n,...r?{value:r}:{}}},Ct=e=>e===`remote`||e===`dynamic`?e:`local`,wt=e=>{if(!q(e))return null;let t=J(e,`id`);if(!t)return null;let n=X(e,`enabled`)??!0,r=Ct(J(e,`type`)),i=J(e,`localHost`)||J(e,`local_host`)||void 0,a=Y(e,`localPort`)??Y(e,`local_port`)??void 0,o=J(e,`remoteHost`)||J(e,`remote_host`)||void 0,s=Y(e,`remotePort`)??Y(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}:{}}},Tt=e=>{if(!q(e))return null;let t=J(e,`id`),n=J(e,`sshCommand`)||J(e,`ssh_command`);if(!t||!n)return null;let r=J(e,`nickname`),i=e.sshParsed,a=q(i)?{destination:J(i,`destination`)||``,args:bt(i.args)}:void 0,o=q(e.remoteOpenchamber)?e.remoteOpenchamber:q(e.remote_openchamber)?e.remote_openchamber:{},s=q(e.localForward)?e.localForward:q(e.local_forward)?e.local_forward:{},c=q(e.auth)?e.auth:{},l=J(o,`mode`)?.toLowerCase()===`external`?`external`:`managed`,u=J(o,`installMethod`)||J(o,`install_method`),d=u===`npm`||u===`download_release`||u===`upload_bundle`?u:`bun`,f=J(s,`bindHost`)||J(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=>wt(e)).filter(e=>!!e),h=Y(o,`preferredPort`)??Y(o,`preferred_port`),g=Y(s,`preferredLocalPort`)??Y(s,`preferred_local_port`),_=St(c.sshPassword||c.ssh_password),v=St(c.openchamberPassword||c.openchamber_password);return{id:t,...r?{nickname:r}:{},sshCommand:n,...a&&a.destination?{sshParsed:a}:{},connectionTimeoutSec:Y(e,`connectionTimeoutSec`)??Y(e,`connection_timeout_sec`)??60,remoteOpenchamber:{mode:l,keepRunning:X(o,`keepRunning`)??X(o,`keep_running`)??!0,relayHost:X(o,`relayHost`)??X(o,`relay_host`)??!0,...h?{preferredPort:h}:{},installMethod:d,uploadBundleOverSsh:X(o,`uploadBundleOverSsh`)??X(o,`upload_bundle_over_ssh`)??!1},localForward:{...g?{preferredLocalPort:g}:{},bindHost:p},auth:{..._?{sshPassword:_}:{},...v?{openchamberPassword:v}:{}},portForwards:m}},Et=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`}},Dt=e=>{if(!q(e))return null;let t=J(e,`id`);return t?{id:t,phase:Et(J(e,`phase`)),...J(e,`detail`)?{detail:J(e,`detail`)||void 0}:{},...J(e,`localUrl`)||J(e,`local_url`)?{localUrl:J(e,`localUrl`)||J(e,`local_url`)||void 0}:{},...typeof(Y(e,`localPort`)??Y(e,`local_port`))==`number`?{localPort:Y(e,`localPort`)??Y(e,`local_port`)??void 0}:{},...typeof(Y(e,`remotePort`)??Y(e,`remote_port`))==`number`?{remotePort:Y(e,`remotePort`)??Y(e,`remote_port`)??void 0}:{},startedByUs:X(e,`startedByUs`)??X(e,`started_by_us`)??!1,retryAttempt:Y(e,`retryAttempt`)??Y(e,`retry_attempt`)??0,requiresUserAction:X(e,`requiresUserAction`)??X(e,`requires_user_action`)??!1,...J(e,`errorCode`)||J(e,`error_code`)?{errorCode:J(e,`errorCode`)||J(e,`error_code`)||void 0}:{},updatedAtMs:Y(e,`updatedAtMs`)??Y(e,`updated_at_ms`)??Date.now()}:null},Ot=e=>{if(!q(e))return null;let t=J(e,`host`),n=J(e,`source`),r=J(e,`sshCommand`)||J(e,`ssh_command`);return!t||!n||!r?null:{host:t,source:n,sshCommand:r,pattern:X(e,`pattern`)??!1}},kt=(e,t)=>({id:e,sshCommand:t,connectionTimeoutSec:60,remoteOpenchamber:{mode:`managed`,keepRunning:!0,relayHost:!0,installMethod:`bun`,uploadBundleOverSsh:!1},localForward:{bindHost:`127.0.0.1`},auth:{},portForwards:[]}),At=async()=>{let e=xt();if(!e)return{instances:[]};let t=await e(`desktop_ssh_instances_get`);return q(t)?{instances:(Array.isArray(t.instances)?t.instances:Array.isArray(t.desktopSshInstances)?t.desktopSshInstances:[]).map(e=>Tt(e)).filter(e=>!!e)}:{instances:[]}},jt=async e=>{let t=xt();t&&await t(`desktop_ssh_instances_set`,{config:{instances:e.instances}})},Mt=async()=>{let e=xt();if(!e)return[];let t=await e(`desktop_ssh_import_hosts`);return Array.isArray(t)?t.map(e=>Ot(e)).filter(e=>!!e):[]},Nt=async e=>{let t=xt();t&&await t(`desktop_ssh_connect`,{id:e})},Pt=async e=>{let t=xt();t&&await t(`desktop_ssh_disconnect`,{id:e})},Ft=async e=>{let t=xt();if(!t)return[];let n=await t(`desktop_ssh_status`,{...e?{id:e}:{}});return Array.isArray(n)?n.map(e=>Dt(e)).filter(e=>!!e):[]},It=async(e,t)=>{let n=xt();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`):[]},Lt=async e=>{let t=xt();t&&await t(`desktop_ssh_logs_clear`,{id:e})},Rt=(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}},zt=e=>{if(!q(e))return null;let t=J(e,`path`),n=Y(e,`bytes`);return!t||n===null?null:{path:t,bytes:n}},Bt=e=>{if(!q(e))return null;let t=J(e,`path`),n=Y(e,`fileCount`)??Y(e,`file_count`),r=Y(e,`bytes`);return!t||n===null||r===null?null:{path:t,fileCount:n,bytes:r}},Vt=e=>{if(e==null||!q(e))return null;let t=Y(e,`fileCount`)??Y(e,`file_count`),n=Y(e,`bytes`);return t===null||n===null?null:{fileCount:t,bytes:n}},Ht=e=>{if(e==null||!q(e))return null;let t=Y(e,`bytes`);return t===null?null:{bytes:t}},Ut=e=>{if(!q(e))return null;let t=Array.isArray(e.files)?e.files:null,n=Array.isArray(e.directories)?e.directories:null,r=bt(e.deletes),i=Y(e,`totalBytes`)??Y(e,`total_bytes`);if(!t||!n||i===null||!(`agentsRoot`in e)&&!(`agents_root`in e))return null;let a=t.map(e=>zt(e)).filter(e=>!!e),o=n.map(e=>Bt(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:Vt(s);if(s!=null&&c===null)return null;let l=e.authFile??e.auth_file,u=l==null?null:Ht(l),d=e.direction===`pull`||e.direction===`push`?e.direction:void 0,f=e.selections,p=q(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=Wt(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}:{}}},Wt=e=>{if(!q(e))return null;let t=Y(e,`fileGroups`)??Y(e,`file_groups`),n=Y(e,`singleFiles`)??Y(e,`single_files`),r=Y(e,`directories`);return t===null||n===null||r===null||t<0||n<0||r<0?null:{fileGroups:t,singleFiles:n,directories:r}},Gt=e=>{if(!q(e))return null;let t=Ut(e.plan);if(!t)return null;let n=Wt(e.selectionShape??e.selection_shape)??t.selectionShape??null;return{plan:t,remoteExisting:bt(e.remoteExisting??e.remote_existing),remoteAgentsRootExists:X(e,`remoteAgentsRootExists`)??X(e,`remote_agents_root_exists`)??!1,remoteAuthFileExists:X(e,`remoteAuthFileExists`)??X(e,`remote_auth_file_exists`)??!1,...n?{selectionShape:n}:{}}},Kt=e=>{if(!q(e)||X(e,`ok`)!==!0)return null;let t=Y(e,`files`),n=Y(e,`directories`),r=Y(e,`deletes`),i=Y(e,`totalBytes`)??Y(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(!q(a))return null;let e=Y(a,`fileCount`)??Y(a,`file_count`);if(e===null)return null;o={fileCount:e}}let s=e.authFile??e.auth_file,c=s==null?null:Ht(s);return{ok:!0,files:t,directories:n,deletes:r,totalBytes:i,agentsRoot:o,authFile:c}},qt=async(e={})=>{let t=xt();if(!t)return console.error(`[desktopSsh] config sync local scan skipped: desktop IPC bridge is unavailable in this window`),null;let n=await t(`desktop_ssh_sync_opencode_config`,{stage:`local`,...e.direction?{direction:e.direction}:{},...e.selections?{selections:e.selections}:{}});if(!q(n))return console.error(`[desktopSsh] config sync local scan returned a non-object payload`,n),null;let r=Ut(n.plan);if(!r)return console.error(`[desktopSsh] config sync local scan plan payload was not recognized`,n),null;let i=Wt(n.selectionShape??n.selection_shape)??r.selectionShape??null;return i?{...r,selectionShape:i}:r},Jt=async(e,t={})=>{let n=xt();if(!n)return console.error(`[desktopSsh] config sync preview skipped: desktop IPC bridge is unavailable in this window`),null;let r=await n(`desktop_ssh_sync_opencode_config`,{id:e,...t.targetKind?{targetKind:t.targetKind}:{},...t.direction?{direction:t.direction}:{},...t.selections?{selections:t.selections}:{}}),i=Gt(r);return i||console.error(`[desktopSsh] config sync preview payload was not recognized`,r),i},Yt=async(e,t={})=>{let n=xt();if(!n)return console.error(`[desktopSsh] config sync apply skipped: desktop IPC bridge is unavailable in this window`),null;let r=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}:{}}),i=Kt(r);return i||console.error(`[desktopSsh] config sync apply payload was not recognized`,r),i},Xt=async(e,t={})=>{let n=xt();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=>q(e)&&typeof e.syncRunId==`string`&&typeof e.targetId==`string`):[]},Zt=async e=>{if(!u())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=Dt(t?.payload);n&&e(n)});return async()=>{await n()}},Qt=new Set([`nodeRuntimeMissing`,`packageManagerMissing`,`nativeBinding`,`openchamberCliMissing`,`openchamberRegistry`,`openchamberInstall`,`openchamberCliIncompatible`,`opencodeInstall`,`serverStart`,`sshAuth`,`sshUnreachable`,`timeout`,`unknown`]),$t=e=>typeof e==`string`&&Qt.has(e),en=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`:/OpenChamber installation completed but the executable is unavailable/i.test(t)?`openchamberCliMissing`:/could not reach the npm registry|ENOTFOUND|ECONNREFUSED|ETIMEDOUT|EAI_AGAIN|CERT_HAS_EXPIRED|UNABLE_TO_GET_ISSUER_CERT|self-signed certificate|registry\.npmjs|npm error code E404|npm ERR! code E404|getaddrinfo/i.test(t)?`openchamberRegistry`:/Failed to install OpenChamber/i.test(t)?`openchamberInstall`:/Unknown option:\s*--relay-host|does not advertise --relay-host|does not support --relay-host/i.test(t)||/Unknown option:/i.test(t)?`openchamberCliIncompatible`:/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`},tn=(e,t)=>$t(e)?e:en(t),nn=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`openchamberCliMissing`:return`desktopHostSwitcher.sshError.openchamberCliMissing.title`;case`openchamberRegistry`:return`desktopHostSwitcher.sshError.openchamberRegistry.title`;case`openchamberInstall`:return`desktopHostSwitcher.sshError.openchamberInstall.title`;case`openchamberCliIncompatible`:return`desktopHostSwitcher.sshError.openchamberCliIncompatible.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`}},rn=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`openchamberCliMissing`:return`desktopHostSwitcher.sshError.openchamberCliMissing.guidance`;case`openchamberRegistry`:return`desktopHostSwitcher.sshError.openchamberRegistry.guidance`;case`openchamberInstall`:return`desktopHostSwitcher.sshError.openchamberInstall.guidance`;case`openchamberCliIncompatible`:return`desktopHostSwitcher.sshError.openchamberCliIncompatible.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`}},an=e=>e===`unknown`||e===`openchamberCliIncompatible`,on=(e,t,n)=>{let r=typeof n==`string`?n.trim():``;return!an(t)||!r||r===e?e:`${e}\n${r}`},Z=A();function sn(e){let t=(0,K.c)(27),{errorCode:n,detail:r,className:i}=e,{t:a}=he(),o,s,c,l,u,d;if(t[0]!==i||t[1]!==r||t[2]!==n||t[3]!==a){let e=tn(n,r);o=a(rn(e));let f;t[10]===r?f=t[11]:(f=typeof r==`string`?r.trim():``,t[10]=r,t[11]=f),s=f,c=an(e)&&!!s&&s!==o,t[12]===i?d=t[13]:(d=U(`space-y-1`,i),t[12]=i,t[13]=d),l=`typography-ui-label text-[var(--status-error)]`,u=a(nn(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,t[8]=u,t[9]=d}else o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9];let f;t[14]!==l||t[15]!==u?(f=(0,Z.jsx)(`p`,{className:l,children:u}),t[14]=l,t[15]=u,t[16]=f):f=t[16];let p;t[17]===o?p=t[18]:(p=(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:o}),t[17]=o,t[18]=p);let m;t[19]!==s||t[20]!==c?(m=c?(0,Z.jsx)(`p`,{className:`typography-meta break-words text-muted-foreground`,children:s}):null,t[19]=s,t[20]=c,t[21]=m):m=t[21];let h;return t[22]!==d||t[23]!==f||t[24]!==p||t[25]!==m?(h=(0,Z.jsxs)(`div`,{className:d,children:[f,p,m]}),t[22]=d,t[23]=f,t[24]=p,t[25]=m,t[26]=h):h=t[26],h}var Q=e(D(),1),cn=[.2,.45,.15,.55,.35,.1,.5,.25,.4,.3,.45,.15,.55,.2,.35,.1],ln=[.3,.15,.45,.25,.5,.35,.1,.4,.2,.55,.3,.15,.45,.25,.4,.2],un=(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},dn=({className:e=``,width:t=70,height:n=70,isAnimated:r=!1})=>{let{t:i}=he(),a=Me(),o=!0;a?o=a.currentTheme.metadata.variant!==`light`:typeof window<`u`&&(o=window.matchMedia(`(prefers-color-scheme: dark)`).matches);let s=(0,Q.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,Q.useMemo)(()=>typeof window>`u`||typeof CSS>`u`||typeof CSS.supports!=`function`?!1:CSS.supports(`color`,`color-mix(in srgb, white 50%, transparent)`),[]),l=(0,Q.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,Q.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=un(h,_,b,v),C=un(_,g,y,b);return(0,Z.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,Z.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,Z.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,Z.jsx)(`path`,{d:e.path,fill:u,opacity:cn[e.row*4+(3-e.col)]??.35},`left-${t}`)),(0,Z.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,Z.jsx)(`path`,{d:e.path,fill:u,opacity:ln[e.row*4+e.col]??.35},`right-${t}`)),(0,Z.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,Z.jsx)(`g`,{opacity:1,className:r?`oc-logo-glow`:void 0,style:r?{"--oc-glow-color":s}:void 0,children:(0,Z.jsxs)(`g`,{transform:`${x} scale(0.75)`,children:[(0,Z.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,Z.jsx)(`path`,{d:`M-8 -4 L8 -4 L8 12 L-8 12 Z`,fill:d,fillOpacity:`0.4`})]})})]})},fn=`/auth/passkey/authenticate/options`,pn=`/auth/passkey/authenticate/verify`,mn=`/auth/passkey/register/options`,hn=`/auth/passkey/register/verify`,gn=`/api/passkeys`,_n=`/auth/passkey/status`,vn=`/api/auth/reset`,yn={enabled:!1,hasPasskeys:!1,passkeyCount:0,rpID:null},bn=async(e,t)=>a(e,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:t===void 0?void 0:JSON.stringify(t)}),xn=async(e,t)=>{try{let t=await e.json();if(t&&typeof t.error==`string`&&t.error.trim())return t.error}catch{}return t},Sn=e=>e instanceof Ne&&e.code===`ERROR_CEREMONY_ABORTED`,Cn=()=>{Fe.cancelCeremony()},wn=()=>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.`},Tn=async()=>{let e=wn();if(!e.supported)throw Error(e.reason);let t=await bn(mn,{label:typeof navigator.userAgent==`string`&&navigator.userAgent.trim()?navigator.userAgent:`This device`});if(!t.ok)throw Error(await xn(t,`Could not start passkey setup.`));let{requestId:n,optionsJSON:r}=await t.json(),i=await bn(hn,{requestId:n,response:await Pe({optionsJSON:r})});if(!i.ok)throw Error(await xn(i,`Could not finish passkey setup.`));return i.json().catch(()=>null)},En=async(e,t={})=>{let n=wn();if(!n.supported)throw Error(n.reason);let r=await bn(fn);if(!r.ok)throw Error(await xn(r,`Passkey sign-in is not available right now.`));let{requestId:i,optionsJSON:a}=await r.json(),o=await bn(pn,{requestId:i,response:await Ie({optionsJSON:a}),trustDevice:e,issueClientToken:t.issueClientToken===!0,clientLabel:t.clientLabel,clientKind:t.clientKind,dedupeKey:t.dedupeKey});if(!o.ok)throw Error(await xn(o,`Passkey sign-in failed.`));return o.json().catch(()=>null)},Dn=async()=>{let e=await a(_n,{method:`GET`,credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return yn;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}},On=async()=>{let e=await a(gn,{method:`GET`,credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(await xn(e,`Could not load passkeys.`));let t=await e.json().catch(()=>null);return Array.isArray(t?.passkeys)?t.passkeys:[]},kn=async e=>{let t=await a(`${gn}/${encodeURIComponent(e)}`,{method:`DELETE`,credentials:`include`,headers:{Accept:`application/json`}});if(!t.ok)throw Error(await xn(t,`Could not remove passkey.`));return t.json().catch(()=>null)},An=async()=>{let e=await bn(vn);if(!e.ok)throw Error(await xn(e,`Could not clear saved authentication.`));try{let{clearAssistantAttachmentCacheAll:e}=await M(async()=>{let{clearAssistantAttachmentCacheAll:e}=await import(`./assistant-attachment-cache-Bzewqov4.js`).then(e=>e.t);return{clearAssistantAttachmentCacheAll:e}},__vite__mapDeps([0,1,2,3,4,5,6,7])),{invalidateRuntimeAuthSession:t}=await M(async()=>{let{invalidateRuntimeAuthSession:e}=await import(`./runtime-auth-C8w0nlKy.js`).then(e=>e.m);return{invalidateRuntimeAuthSession:e}},__vite__mapDeps([2,1]));await e(`auth-reset`),t()}catch{}return e.json().catch(()=>null)};function jn(e){let t=(0,K.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=U(`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,Z.jsx)(`div`,{"data-slot":`card`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Mn(e){let t=(0,K.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=U(`@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,Z.jsx)(`div`,{"data-slot":`card-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Nn(e){let t=(0,K.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=U(`leading-none font-semibold`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`card-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Pn(e){let t=(0,K.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=U(`px-6`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`card-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var Fn=class extends Q.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 me(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,Z.jsx)(`div`,{className:`p-4 flex items-center justify-center min-h-screen`,children:(0,Z.jsxs)(jn,{className:`w-full max-w-md`,children:[(0,Z.jsx)(Mn,{className:`text-center`,children:(0,Z.jsxs)(Nn,{className:`flex items-center justify-center gap-2 text-destructive`,children:[(0,Z.jsx)(G,{name:`error-warning`,className:`h-5 w-5`}),e.title]})}),(0,Z.jsxs)(Pn,{className:`space-y-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground text-center`,children:e.description}),this.state.error&&(0,Z.jsxs)(`details`,{className:`text-xs font-mono bg-muted p-3 rounded`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer hover:bg-interactive-hover/80`,children:e.detailsSummary}),(0,Z.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,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsxs)(_e,{onClick:this.handleReset,variant:`outline`,className:`flex-1`,children:[(0,Z.jsx)(G,{name:`restart`,className:`h-4 w-4 mr-2`}),e.tryAgain]}),(0,Z.jsx)(_e,{onClick:this.handleCopy,variant:`outline`,className:`flex-1`,children:this.state.copied?e.copied:e.copy})]})]})]})}):this.props.children}},In=e=>{let t=(0,K.c)(29),{children:n,fallback:r}=e,{t:i}=he(),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,Z.jsx)(Fn,{fallback:r,strings:m,children:n}),t[25]=n,t[26]=r,t[27]=m,t[28]=h):h=t[28],h},Ln=`__unassigned__`,Rn={mod:`mod`,shift:`shift`,alt:`alt`,option:`alt`,ctrl:`ctrl`,meta:`mod`,cmd:`mod`,command:`mod`},zn={mod:ge()?`⌘`:`Ctrl`,shift:`⇧`,alt:`⌥`,option:`⌥`,ctrl:`⌃`},Bn={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:`-`,"-":`-`},Vn=[`mod`,`ctrl`,`shift`,`alt`],Hn={"{":`[`,"}":`]`,":":`;`,'"':`'`,"<":`,`,">":`.`,"?":`/`,"|":`\\`,"~":"`","!":`1`,"@":`2`,"#":`3`,$:`4`,"%":`5`,"^":`6`,"&":`7`,"*":`8`,"(":`9`,")":`0`};function Un(e){return e.trim().toLowerCase()===Ln}function Wn(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`:Hn[t]??t}var Gn=[{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_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 Kn(e){if(Un(e))return Ln;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=Rn[t];if(i){n.add(i);continue}r=t}return[...Vn.filter(e=>n.has(e)),r].filter(Boolean).join(`+`)}function qn(e){return Un(e)?!0:Jn(e).key.trim().length>0}function Jn(e){if(Un(e))return{modifiers:new Set,key:Ln};let t=Kn(e).split(`+`),n=new Set,r=``;for(let e of t){let t=Rn[e];t?n.add(t):r=e}return{modifiers:n,key:r}}function Yn(e){if(Un(e))return`Unassigned`;let t=Jn(e);if(!t.key&&t.modifiers.size===0)return`Unassigned`;let n=[];for(let e of Vn)t.modifiers.has(e)&&n.push(zn[e]);if(t.key){let e=Bn[t.key.toLowerCase()]||t.key.toUpperCase();n.push(e)}return n.join(` + `)}function Xn(e){return Gn.find(t=>t.id===e)}function Zn(){return Gn.filter(e=>e.customizable===!0)}function Qn(e,t){let n=Xn(e);if(!n)return``;let r=t?.[e];if(typeof r==`string`){if(r.trim().toLowerCase()===`__unassigned__`)return``;let e=Kn(r);if(e===`__unassigned__`)return Ln;if(qn(e))return e}return n.defaultCombo}function $n(e,t){let n=Xn(e);if(!n)return[];let r=Qn(e,t);return r===n.defaultCombo?[n.defaultCombo,...n.defaultAliases??[]]:r?[r]:[]}function er(e){if(Un(e))return!1;let t=Jn(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 tr(e,t){let n=typeof t==`string`?t:t.defaultCombo;if(Un(n))return!1;let r=Jn(n),i=r.modifiers.has(`mod`),a=r.modifiers.has(`shift`),o=r.modifiers.has(`alt`),s=r.modifiers.has(`ctrl`),c=ge()&&d(),l=ge(),u=c?e.metaKey:l&&e.metaKey||e.ctrlKey;if(i&&!u||!i&&e.metaKey||a!==e.shiftKey||o!==e.altKey)return!1;if(s){if(!e.ctrlKey)return!1}else{let t=i&&!c&&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))),Wn(f)===Wn(r.key)}function nr(){return ge()?`⌘`:`Ctrl`}function rr(e,t,n){if(tr(e,n))return!0;let r=Kn(n),i=ge()&&d(),a=ge();return!(i?e.metaKey:a&&e.metaKey||e.ctrlKey)||e.altKey||i&&e.ctrlKey&&!e.metaKey?!1:t===`in`&&r===`mod+=`?e.key===`+`||e.code===`NumpadAdd`:t===`out`&&(r===`mod+-`||r===`mod+minus`)?e.key===`_`||e.code===`NumpadSubtract`:!1}var ir=Q.createContext(null),ar=e=>e?e.closest(`[data-slot="dialog-content"], [role="dialog"]`):null;function or(e,t){return e&&Q.isValidElement(t)?{render:t}:{children:t}}function sr(e){let t=(0,K.c)(9),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let[r,i]=Q.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,Z.jsx)(v,{...n}),t[4]=n,t[5]=s);let c;return t[6]!==o||t[7]!==s?(c=(0,Z.jsx)(ir.Provider,{value:o,children:s}),t[6]=o,t[7]=s,t[8]=c):c=t[8],c}function cr(e){let t=(0,K.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=Q.useContext(ir),c;t[6]===s?c=t[7]:(c=e=>{if(!s)return;let t=e instanceof HTMLElement?e:null;s.setPortalContainer(ar(t))},t[6]=s,t[7]=c);let l=c,u;t[8]!==n||t[9]!==r?(u=or(n,r),t[8]=n,t[9]=r,t[10]=u):u=t[10];let d=u,f;t[11]!==a||t[12]!==l?(f=e=>{l(e.currentTarget),a?.(e)},t[11]=a,t[12]=l,t[13]=f):f=t[13];let p;t[14]!==i||t[15]!==l?(p=e=>{l(e.currentTarget),i?.(e)},t[14]=i,t[15]=l,t[16]=p):p=t[16];let m;return t[17]!==o||t[18]!==d||t[19]!==f||t[20]!==p?(m=(0,Z.jsx)(T,{"data-slot":`dropdown-menu-trigger`,onPointerDownCapture:f,onFocusCapture:p,...o,...d}),t[17]=o,t[18]=d,t[19]=f,t[20]=p,t[21]=m):m=t[21],m}function lr(e){let t=(0,K.c)(40),n,r,i,a,o,s,c,l,u,d,f,p,m;if(t[0]!==e){let{className:h,sideOffset:g,align:_,side:v,alignOffset:y,anchor:b,portalToBody:x,positionerClassName:S,style:C,children:w,onCloseAutoFocus:T,collisionPadding:E,collisionAvoidance:D,...O}=e;o=h,d=g,n=_,l=v,r=y,i=b,f=x,s=S,u=C,a=w,p=E,m=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]=d,t[11]=f,t[12]=p,t[13]=m}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],d=t[10],f=t[11],p=t[12],m=t[13];let h=d===void 0?4:d,g=f!==void 0&&f,_=p===void 0?8:p,v;t[14]===m?v=t[15]:(v=m===void 0?{side:`shift`,align:`shift`}:m,t[14]=m,t[15]=v);let y=v,S=Q.useContext(ir),C=g?void 0:S?.portalContainer||void 0,w;t[16]===s?w=t[17]:(w=U(`app-region-no-drag z-50`,s),t[16]=s,t[17]=w);let T;t[18]===u?T=t[19]:(T={backgroundColor:`var(--surface-elevated)`,color:`var(--surface-elevated-foreground)`,...u},t[18]=u,t[19]=T);let D;t[20]===o?D=t[21]:(D=U(rt,o),t[20]=o,t[21]=D);let O;t[22]!==a||t[23]!==c||t[24]!==T||t[25]!==D?(O=(0,Z.jsx)(x,{"data-slot":`dropdown-menu-content`,style:T,className:D,...c,children:a}),t[22]=a,t[23]=c,t[24]=T,t[25]=D,t[26]=O):O=t[26];let k;t[27]!==n||t[28]!==r||t[29]!==i||t[30]!==y||t[31]!==_||t[32]!==l||t[33]!==h||t[34]!==O||t[35]!==w?(k=(0,Z.jsx)(E,{anchor:i,sideOffset:h,align:n,side:l,alignOffset:r,collisionPadding:_,collisionAvoidance:y,className:w,children:O}),t[27]=n,t[28]=r,t[29]=i,t[30]=y,t[31]=_,t[32]=l,t[33]=h,t[34]=O,t[35]=w,t[36]=k):k=t[36];let A;return t[37]!==k||t[38]!==C?(A=(0,Z.jsx)(b,{container:C,children:k}),t[37]=k,t[38]=C,t[39]=A):A=t[39],A}function ur(e){let t=(0,K.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=or(n,r),t[9]=n,t[10]=r,t[11]=d):d=t[11];let f=d,p;t[12]!==o||t[13]!==s?(p=e=>{o?.(e),e.defaultPrevented||s?.(e)},t[12]=o,t[13]=s,t[14]=p):p=t[14];let m=p,h;t[15]===i?h=t[16]:(h=U(st,i),t[15]=i,t[16]=h);let g;return t[17]!==m||t[18]!==a||t[19]!==c||t[20]!==f||t[21]!==h||t[22]!==u?(g=(0,Z.jsx)(S,{"data-slot":`dropdown-menu-item`,"data-inset":a,"data-variant":u,className:h,...c,onClick:m,...f}),t[17]=m,t[18]=a,t[19]=c,t[20]=f,t[21]=h,t[22]=u,t[23]=g):g=t[23],g}function dr(e){let t=(0,K.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,Z.jsx)(w,{"data-slot":`dropdown-menu-radio-group`,...n}),t[2]=n,t[3]=r),r}function fr(e){let t=(0,K.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=U(`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,Z.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-3.5 items-center justify-center text-primary`,children:(0,Z.jsx)(O,{children:(0,Z.jsx)(G,{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,Z.jsxs)(C,{"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 pr(e){let t=(0,K.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=U(`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,Z.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 mr(e){let t=(0,K.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=U(at,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(y,{"data-slot":`dropdown-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function hr(){let e=(0,K.c)(5),t=W(yr),n=W(vr),r=W(_r),i=W(gr),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 gr(e){return e.providers.length>0}function _r(e){return e.lastDisconnectReason}function vr(e){return e.connectionPhase}function yr(e){return e.isInitialized}var br=e=>{let t=(0,K.c)(41),{agentName:n,onChange:r,className:i,filter:a,dropdownPortalToBody:o,showIcon:s,agents:c}=e,l=o!==void 0&&o,u=s===void 0||s,{t:d}=he(),{isReady:f,isUnavailable:p}=hr(),m=W(xr),h=Te(Sr),g=W(Cr),{data:_}=ke(),v;t[0]===_?v=t[1]:(v=_===void 0?[]:_,t[0]=_,t[1]=v);let y=v,b;bb0:{if(c){b=c;break bb0}if(Array.isArray(m)&&m.length>0){b=m;break bb0}b=y}let x=b,S;if(t[2]!==a||t[3]!==x){let e=Se(x);S=a?e.filter(a):e,t[2]=a,t[3]=x,t[4]=S}else S=t[4];let C=S,w=te(wr),{isMobile:T}=We(),E=w||T,[D,O]=Q.useState(!1),k;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(k=()=>{O(!0),W.getState().refreshCatalogsOnPickerOpen({source:`agentSelector:mobilePanel`})},t[5]=k):k=t[5];let A=pe(k),j=pe(Tr),ee=Q.useId(),ne,M;t[6]!==c||t[7]!==h||t[8]!==g||t[9]!==x.length?(ne=()=>{c||x.length>0||(g(),h())},M=[c,x.length,g,h],t[6]=c,t[7]=h,t[8]=g,t[9]=x.length,t[10]=ne,t[11]=M):(ne=t[10],M=t[11]),Q.useEffect(ne,M);let re;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>O(!1),t[12]=re):re=t[12];let ie=re,ae;t[13]===r?ae=t[14]:(ae=e=>{r(e)},t[13]=r,t[14]=ae);let N=ae,oe;t[15]!==n||t[16]!==C||t[17]!==N||t[18]!==E||t[19]!==D||t[20]!==ee||t[21]!==d?(oe=()=>E?(0,Z.jsx)(Je,{id:`mobile-agent-selector-sheet-${ee}`,open:D,onOpenChange:e=>{e||ie()},ariaLabel:d(`settings.commands.agentSelector.title`),closeAriaLabel:d(`mobile.surface.closeAria`),resizeAriaLabel:d(`mobile.sessions.sheet.resizeAria`),bodyClassName:`px-2`,children:(0,Z.jsxs)(Ye,{useScrollShadow:!0,disableHorizontal:!0,preventOverscroll:!0,outerClassName:`min-h-0 flex-1`,className:`flex flex-col gap-1 overscroll-contain`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:U(`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`,n?`text-foreground`:`bg-primary/10 text-primary`),onClick:()=>{N(``),ie()},children:[(0,Z.jsx)(je,{name:`default`,size:16}),(0,Z.jsx)(`span`,{className:U(`min-w-0 typography-meta`,n?`text-muted-foreground`:`font-medium`),children:d(`settings.commands.agentSelector.notSelected`)}),!n&&(0,Z.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-primary`})]}),C.map(e=>{let t=e.name===n;return(0,Z.jsxs)(`button`,{type:`button`,className:U(`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:()=>{N(e.name),ie()},children:[(0,Z.jsx)(je,{name:e.name,size:16,className:`mt-1.5`}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`typography-meta font-medium`,children:e.name}),e.description&&(0,Z.jsx)(`span`,{className:`mt-0.5 block whitespace-normal break-words typography-micro text-muted-foreground`,children:e.description})]}),t&&(0,Z.jsx)(`div`,{className:`mt-2 h-2 w-2 rounded-full bg-primary`})]},e.name)})]})}):null,t[15]=n,t[16]=C,t[17]=N,t[18]=E,t[19]=D,t[20]=ee,t[21]=d,t[22]=oe):oe=t[22];let P=oe,F;t[23]!==n||t[24]!==C||t[25]!==i||t[26]!==l||t[27]!==N||t[28]!==j||t[29]!==E||t[30]!==f||t[31]!==p||t[32]!==A||t[33]!==u||t[34]!==d?(F=E?(0,Z.jsxs)(`button`,{type:`button`,onClick:f?A:void 0,disabled:!f,className:U(`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`,!f&&`opacity-60 cursor-not-allowed`,i),children:[(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:f?(0,Z.jsxs)(Z.Fragment,{children:[u?(0,Z.jsx)(je,{name:n||`default`,size:14}):null,(0,Z.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:n||d(`settings.commands.agentSelector.selectAgentPlaceholder`)})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(G,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:d(p?`common.unavailable`:`common.loading`)})]})}),(0,Z.jsx)(G,{name:`arrow-down-s`,className:`h-3 w-3 text-muted-foreground`})]}):f?(0,Z.jsxs)(sr,{onOpenChange:j,children:[(0,Z.jsx)(cr,{asChild:!0,children:(0,Z.jsxs)(`div`,{className:U(`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`,i),children:[u?(0,Z.jsx)(je,{name:n||`default`,size:14}):null,(0,Z.jsx)(`span`,{className:`typography-micro font-medium whitespace-nowrap`,children:n||d(`settings.commands.agentSelector.notSelected`)}),(0,Z.jsx)(G,{name:`arrow-down-s`,className:`h-3 w-3 flex-shrink-0 text-muted-foreground`})]})}),(0,Z.jsxs)(lr,{className:`max-w-[300px]`,portalToBody:l,children:[(0,Z.jsxs)(ur,{className:`typography-meta`,onSelect:()=>N(``),children:[(0,Z.jsx)(je,{name:`default`,size:14}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:d(`settings.commands.agentSelector.notSelected`)})]}),C.map(e=>(0,Z.jsxs)(ur,{className:`typography-meta`,onSelect:()=>N(e.name),children:[(0,Z.jsx)(je,{name:e.name,size:14}),(0,Z.jsx)(`span`,{className:`font-medium`,children:e.name})]},e.name))]})]}):(0,Z.jsxs)(`div`,{className:U(`flex items-center gap-2 px-2 rounded-lg bg-interactive-selection/20 border border-border/20 h-6 w-fit opacity-60`,i),children:[(0,Z.jsx)(G,{name:`loader-4`,className:`h-3 w-3 animate-spin text-muted-foreground flex-shrink-0`}),(0,Z.jsx)(`span`,{className:`typography-micro font-medium whitespace-nowrap text-muted-foreground`,children:d(p?`common.unavailable`:`common.loading`)})]}),t[23]=n,t[24]=C,t[25]=i,t[26]=l,t[27]=N,t[28]=j,t[29]=E,t[30]=f,t[31]=p,t[32]=A,t[33]=u,t[34]=d,t[35]=F):F=t[35];let I;t[36]===P?I=t[37]:(I=P(),t[36]=P,t[37]=I);let se;return t[38]!==F||t[39]!==I?(se=(0,Z.jsxs)(Z.Fragment,{children:[F,I]}),t[38]=F,t[39]=I,t[40]=se):se=t[40],se};function xr(e){return e.agents}function Sr(e){return e.loadAgents}function Cr(e){return e.loadAgents}function wr(e){return e.isMobile}function Tr(e){e&&W.getState().refreshCatalogsOnPickerOpen({source:`agentSelector:desktopMenu`})}var Er={compact:{notation:`compact`,compactDisplay:`short`,maximumFractionDigits:1,minimumFractionDigits:0},compactTokensShort:{notation:`compact`,compactDisplay:`short`,maximumFractionDigits:1},usd:{style:`currency`,currency:`USD`,maximumFractionDigits:4,minimumFractionDigits:2}},Dr=null,Or={},kr=(e,t)=>{Dr!==t&&(Dr=t,Or.compact=void 0,Or.compactTokensShort=void 0,Or.usd=void 0);let n=Or[e];if(n)return n;let r=new Intl.NumberFormat(t,Er[e]);return Or[e]=r,r},Ar=(e,t=H())=>kr(`compact`,t).format(e),jr=(e,t=H())=>kr(`compactTokensShort`,t).format(e),Mr=(e,t=H())=>kr(`usd`,t).format(e),Nr=(e,t=H())=>e.toLocaleDateString(t,{month:`short`,day:`numeric`,year:`numeric`}),Pr=(e,t=H())=>new Date(e).toLocaleDateString(t,{year:`numeric`,month:`short`,day:`numeric`}),Fr=(e,t=H())=>new Date(e).toLocaleTimeString(t,{hour:`numeric`,minute:`2-digit`}),Ir=8,Lr=e=>typeof e!=`number`||Number.isNaN(e)?``:jr(e),Rr=(e,t,n)=>{let r=e.find(e=>e.id===t)?.models?.find(e=>e.id===n);return r?.variants?Object.keys(r.variants):[]},zr=e=>{let t=(0,K.c)(54),{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}=he(),T=Q.useId(),[E,D]=Q.useState(``),O;t[2]===i?O=t[3]:(O=()=>new Set(i?[i]:[]),t[2]=i,t[3]=O);let[k,A]=Q.useState(O),[j,ee]=Q.useState(null),[te,ne]=Q.useState(`model`),[M,re]=Q.useState(null),ie=Q.useRef(!1),ae=y??te,N,oe;t[4]!==n||t[5]!==i?(N=()=>{n&&!ie.current&&A(new Set(i?[i]:[])),n||(D(``),ee(null),ne(`model`),re(null)),ie.current=n},oe=[n,i],t[4]=n,t[5]=i,t[6]=N,t[7]=oe):(N=t[6],oe=t[7]),Q.useEffect(N,oe);let P;t[8]===b?P=t[9]:(P=e=>{ne(e),b?.(e)},t[8]=b,t[9]=P);let F=P,I=ae===`variant`&&!!(M??(i&&a)),se=`mobile-model-picker-sheet-${T}`,L;t[10]===r?L=t[11]:(L=e=>{e||r()},t[10]=r,t[11]=L);let ce;t[12]!==I||t[13]!==F||t[14]!==w?(ce=I?(0,Z.jsx)(_e,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>F(`model`),"aria-label":w(`onboarding.common.actions.back`),children:(0,Z.jsx)(G,{name:`arrow-left`,className:`size-5`})}):void 0,t[12]=I,t[13]=F,t[14]=w,t[15]=ce):ce=t[15];let R;t[16]!==I||t[17]!==w?(R=w(I?`chat.modelControls.thinking`:`chat.modelControls.selectModel`),t[16]=I,t[17]=w,t[18]=R):R=t[18];let z;t[19]===w?z=t[20]:(z=w(`mobile.surface.closeAria`),t[19]=w,t[20]=z);let B;t[21]===w?B=t[22]:(B=w(`mobile.sessions.sheet.resizeAria`),t[21]=w,t[22]=B);let V;t[23]!==ae||t[24]!==p||t[25]!==f||t[26]!==j||t[27]!==k||t[28]!==l||t[29]!==v||t[30]!==S||t[31]!==g||t[32]!==s||t[33]!==_||t[34]!==m||t[35]!==c||t[36]!==E||t[37]!==u||t[38]!==o||t[39]!==a||t[40]!==i||t[41]!==F||t[42]!==C||t[43]!==M?(V=(0,Z.jsx)(Br,{query:E,onQueryChange:D,expandedProviders:k,onExpandedProvidersChange:A,expandedModelKey:j,onExpandedModelKeyChange:ee,activeView:ae,setView:F,variantTarget:M,onVariantTargetChange:re,selectedProviderID:i,selectedModelID:a,resolveSelectedVariant:o,onSelect:s,providers:c,favoriteModels:l,recentModels:u,hiddenModels:S,allowedProviderIds:f,allowedModelIdsByProvider:p,providerOrder:m,variantSelectionEnabled:C,isFavorite:g,onToggleFavorite:_,getMetadata:v}),t[23]=ae,t[24]=p,t[25]=f,t[26]=j,t[27]=k,t[28]=l,t[29]=v,t[30]=S,t[31]=g,t[32]=s,t[33]=_,t[34]=m,t[35]=c,t[36]=E,t[37]=u,t[38]=o,t[39]=a,t[40]=i,t[41]=F,t[42]=C,t[43]=M,t[44]=V):V=t[44];let le;return t[45]!==n||t[46]!==ce||t[47]!==R||t[48]!==z||t[49]!==B||t[50]!==V||t[51]!==se||t[52]!==L?(le=(0,Z.jsx)(Je,{id:se,open:n,onOpenChange:L,leading:ce,ariaLabel:R,closeAriaLabel:z,resizeAriaLabel:B,bodyClassName:`px-2`,children:V}),t[45]=n,t[46]=ce,t[47]=R,t[48]=z,t[49]=B,t[50]=V,t[51]=se,t[52]=L,t[53]=le):le=t[53],le},Br=e=>{let t=(0,K.c)(117),{query:n,onQueryChange:r,expandedProviders:i,onExpandedProvidersChange:a,expandedModelKey:o,onExpandedModelKeyChange:s,activeView:c,setView:l,variantTarget:u,onVariantTargetChange:d,selectedProviderID:f,selectedModelID:p,resolveSelectedVariant:m,onSelect:h,providers:g,favoriteModels:_,recentModels:v,hiddenModels:y,allowedProviderIds:b,allowedModelIdsByProvider:x,providerOrder:S,variantSelectionEnabled:C,isFavorite:w,onToggleFavorite:T,getMetadata:E}=e,{t:D}=he(),O;t[0]===b?O=t[1]:(O=b&&b.length>0?new Set(b):null,t[0]=b,t[1]=O);let k=O,A;t[2]===x?A=t[3]:(A=x?new Map(Object.entries(x).map(Vr)):null,t[2]=x,t[3]=A);let j=A,ee;t[4]===y?ee=t[5]:(ee=new Set(y.map(Hr)),t[4]=y,t[5]=ee);let te=ee,ne;t[6]===g?ne=t[7]:(ne=new Map(g.map(Ur)),t[6]=g,t[7]=ne);let M=ne,re;bb0:{if(!S?.length){re=g;break bb0}let e;t[8]===S?e=t[9]:(e=new Map(S.map(Wr)),t[8]=S,t[9]=e);let n=e,r;if(t[10]!==g||t[11]!==n){let e;t[13]===n?e=t[14]:(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[13]=n,t[14]=e),r=[...g].sort(e),t[10]=g,t[11]=n,t[12]=r}else r=t[12];re=r}let ie=re,ae;t[15]!==j||t[16]!==k||t[17]!==te?(ae=(e,t)=>k&&!k.has(e)||j&&j.get(e)?.has(t)!==!0?!1:!te.has(`${e}:${t}`),t[15]=j,t[16]=k,t[17]=te,t[18]=ae):ae=t[18];let N=ae,oe;t[19]!==M||t[20]!==n?(oe=e=>{let t=n.trim();if(!t)return!0;let r=M.get(e.providerID)?.name||e.providerID,i=Ce(e.model,e.modelID,{maxLength:40});return Le(i,t)||Le(e.modelID,t)||Le(r,t)},t[19]=M,t[20]=n,t[21]=oe):oe=t[21];let P=oe,F;if(t[22]!==_||t[23]!==N||t[24]!==P){let e;t[26]!==N||t[27]!==P?(e=e=>N(e.providerID,e.modelID)&&P(e),t[26]=N,t[27]=P,t[28]=e):e=t[28],F=_.filter(e),t[22]=_,t[23]=N,t[24]=P,t[25]=F}else F=t[25];let I=F,se;if(t[29]!==N||t[30]!==P||t[31]!==v){let e;t[33]!==N||t[34]!==P?(e=e=>N(e.providerID,e.modelID)&&P(e),t[33]=N,t[34]=P,t[35]=e):e=t[35],se=v.filter(e),t[29]=N,t[30]=P,t[31]=v,t[32]=se}else se=t[32];let L=se,ce;if(t[36]!==k||t[37]!==N||t[38]!==ie||t[39]!==n){let e=n.trim(),r;t[41]===k?r=t[42]:(r=e=>!k||k.has(e.id),t[41]=k,t[42]=r),ce=ie.filter(r).map(t=>{let n=e.length>0&&(Le(t.name||t.id,e)||Le(t.id,e));return{provider:t,models:(t.models??[]).filter(r=>{let i=typeof r.id==`string`?r.id:``;return!i||!N(t.id,i)?!1:n||!e?!0:Le(Ce(r,i,{maxLength:40}),e)||Le(i,e)})}}).filter(Gr),t[36]=k,t[37]=N,t[38]=ie,t[39]=n,t[40]=ce}else ce=t[40];let R=ce,z;t[43]===D?z=t[44]:(z=e=>{if(!e?.trim())return D(`chat.modelControls.default`);let t=e.trim();return/^\d+(\.\d+)?$/.test(t)?t:t.charAt(0).toUpperCase()+t.slice(1)},t[43]=D,t[44]=z);let B=z,V;t[45]===D?V=t[46]:(V=e=>{let t=[];e?.tool_call&&t.push({key:`tool_call`,icon:`tools`,label:D(`chat.modelControls.capability.toolCalling`)}),e?.reasoning&&t.push({key:`reasoning`,icon:`brain-ai-3`,label:D(`chat.modelControls.capability.reasoning`)});let n={text:{icon:`text`,label:D(`chat.modelControls.modality.text`)},image:{icon:`file-image`,label:D(`chat.modelControls.modality.image`)},video:{icon:`file-video`,label:D(`chat.modelControls.modality.video`)},audio:{icon:`file-music`,label:D(`chat.modelControls.modality.audio`)},pdf:{icon:`file-pdf`,label:D(`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[45]=D,t[46]=V);let le=V,ue;t[47]!==d||t[48]!==l?(ue=(e,t,n)=>{d(n===void 0?{providerID:e,modelID:t}:{providerID:e,modelID:t,variant:n}),l(`variant`)},t[47]=d,t[48]=l,t[49]=ue):ue=t[49];let de=ue,fe;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(fe={onPointerDown:Ke,onClickCapture:Kr},t[50]=fe):fe=t[50];let pe=fe,me;t[51]!==o||t[52]!==B||t[53]!==E||t[54]!==le||t[55]!==w||t[56]!==s||t[57]!==h||t[58]!==T||t[59]!==de||t[60]!==M||t[61]!==g||t[62]!==m||t[63]!==p||t[64]!==f||t[65]!==D||t[66]!==C?(me=(e,t)=>{let n=t===void 0?{}:t,{model:r,providerID:i,modelID:a}=e,c=`${i}:${a}`,l=i===f&&a===p,u=He(i,r,E?.(i,a)),d=C?Rr(g,i,a):[],_=m(i,a),v=n.preferRememberedVariant&&e.variant!==void 0&&d.includes(e.variant)?e.variant:void 0,y=v===void 0?_:v,b=l||v===void 0?_:v,x=[void 0,...d].slice(0,Ir),S=o===c,O=le(u),k=u?.limit?.context?`${Lr(u.limit.context)} ctx`:null;return(0,Z.jsxs)(`div`,{className:U(`border-b border-border/30 last:border-b-0`,l&&`bg-interactive-selection/15 text-interactive-selection-foreground`),children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[(0,Z.jsx)(`button`,{type:`button`,...pe,onClick:()=>h(i,a,y),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,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[n.showProvider?(0,Z.jsx)(`span`,{className:`truncate text-[10px] leading-none text-muted-foreground/60`,children:M.get(i)?.name||i}):null,(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Z.jsx)(ze,{modelId:a,providerId:i,className:`size-3.5 flex-shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate typography-meta font-medium text-foreground`,children:Ce(r,a,{maxLength:40})}),l?(0,Z.jsx)(G,{name:`check`,className:`size-4 flex-shrink-0 text-primary`}):null]}),k||O.length>0?(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 overflow-hidden typography-micro text-muted-foreground`,children:[k?(0,Z.jsx)(`span`,{className:`flex-shrink-0 whitespace-nowrap`,children:k}):null,k&&O.length>0?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-px flex-shrink-0 bg-border/50`}):null,(0,Z.jsx)(`div`,{className:`flex min-w-0 items-center gap-1 overflow-hidden whitespace-nowrap pl-0.5`,children:O.map(e=>{let{key:t,icon:n,label:r}=e;return(0,Z.jsx)(`span`,{className:`flex size-4 flex-shrink-0 items-center justify-center text-muted-foreground`,title:r,"aria-label":r,children:(0,Z.jsx)(G,{name:n,className:`size-3`})},`${c}-${t}`)})})]}):null]})}),d.length>0?(0,Z.jsxs)(`button`,{type:`button`,...pe,onClick:()=>s(e=>e===c?null:c),className:`flex flex-shrink-0 items-center gap-0.5 typography-micro font-medium text-muted-foreground hover:text-foreground`,"aria-expanded":S,"aria-label":D(S?`chat.modelControls.hideThinkingModes`:`chat.modelControls.showThinkingModes`),children:[(0,Z.jsx)(`span`,{className:`whitespace-nowrap`,children:B(b)}),(0,Z.jsx)(G,{name:S?`arrow-down-s`:`arrow-right-s`,className:`size-3.5`})]}):null,(0,Z.jsx)(`button`,{type:`button`,...pe,onClick:e=>{e.preventDefault(),e.stopPropagation(),T(i,a)},className:U(`model-favorite-button flex size-5 flex-shrink-0 items-center justify-center hover:text-primary/80`,w(i,a)?`text-primary`:`text-muted-foreground`),"aria-label":w(i,a)?D(`chat.modelControls.unfavoriteAria`):D(`chat.modelControls.favoriteAria`),title:w(i,a)?D(`chat.modelControls.removeFromFavorites`):D(`chat.modelControls.addToFavorites`),children:(0,Z.jsx)(G,{name:w(i,a)?`star-fill`:`star`,className:`size-4`})})]}),S&&d.length>0?(0,Z.jsx)(`div`,{className:`border-t border-border/30 p-2`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[x.map(e=>{let t=e===b||!e&&!b;return(0,Z.jsx)(`button`,{type:`button`,...pe,onClick:()=>h(i,a,e),className:U(`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:B(e)},`${c}-${e??`default`}`)}),x.length<d.length+1?(0,Z.jsx)(`button`,{type:`button`,...pe,onClick:()=>de(i,a,b),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":D(`chat.modelControls.moreThinkingModes`),children:D(`inlineComment.actions.showMore`)}):null]})}):null]},`mobile-model-${c}`)},t[51]=o,t[52]=B,t[53]=E,t[54]=le,t[55]=w,t[56]=s,t[57]=h,t[58]=T,t[59]=de,t[60]=M,t[61]=g,t[62]=m,t[63]=p,t[64]=f,t[65]=D,t[66]=C,t[67]=me):me=t[67];let ge=me,H,_e,ve,ye,be,xe,Se,we,Te,W;if(t[68]!==c||t[69]!==i||t[70]!==I||t[71]!==R||t[72]!==L||t[73]!==B||t[74]!==s||t[75]!==a||t[76]!==r||t[77]!==h||t[78]!==g||t[79]!==n||t[80]!==ge||t[81]!==m||t[82]!==p||t[83]!==f||t[84]!==D||t[85]!==u){let e=u??(c===`variant`&&f&&p?{providerID:f,modelID:p}:null),o=e?Rr(g,e.providerID,e.modelID):[],l;bb1:{if(!e){l=void 0;break bb1}if(e.providerID===f&&e.modelID===p){l=m(e.providerID,e.modelID);break bb1}l=(e.variant!==void 0&&o.includes(e.variant)?e.variant:void 0)??m(e.providerID,e.modelID)}let d=l,_=I.length>0||L.length>0||R.length>0,v=c===`variant`&&!!e;Te=`flex min-h-0 flex-1 flex-col gap-2`,t[96]!==v||t[97]!==s||t[98]!==r||t[99]!==n||t[100]!==D?(W=v?null:(0,Z.jsxs)(`div`,{className:`relative z-10 shrink-0`,"data-mobile-sheet-no-dismiss":``,"data-mobile-sheet-search":``,children:[(0,Z.jsx)(G,{name:`search`,className:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,Z.jsx)(Ue,{type:`text`,value:n,onChange:e=>{r(e.target.value),s(null)},placeholder:D(`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`}),n?(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{r(``),s(null)},className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,"aria-label":D(`chat.modelControls.clearSearch`),children:(0,Z.jsx)(G,{name:`close-circle`,className:`size-4`})}):null]}),t[96]=v,t[97]=s,t[98]=r,t[99]=n,t[100]=D,t[101]=W):W=t[101],H=Ye,ye=!0,be=!0,xe=!0,Se=`min-h-0 flex-1`,we=`overscroll-contain`,_e=`flex flex-col gap-2`,ve=v&&e?(0,Z.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:[void 0,...o].map(t=>{let n=t===d||!t&&!d;return(0,Z.jsxs)(`button`,{type:`button`,className:U(`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`),...pe,onClick:()=>h(e.providerID,e.modelID,t),children:[(0,Z.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:B(t)}),n?(0,Z.jsx)(G,{name:`check`,className:`size-4 flex-shrink-0 text-primary`}):null]},t??`default`)})}):(0,Z.jsxs)(Z.Fragment,{children:[_?null:(0,Z.jsx)(`div`,{className:`px-3 py-8 text-center typography-meta text-muted-foreground`,children:D(`chat.modelControls.noProvidersOrModelsFound`)}),I.length>0?(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border/40 bg-[var(--surface-elevated)]`,children:[(0,Z.jsxs)(`div`,{className:`px-2 py-1.5 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,Z.jsx)(G,{name:`star-fill`,className:`mr-1.5 inline-block size-3 text-primary`}),D(`chat.modelControls.favorites`)]}),(0,Z.jsx)(`div`,{className:`flex flex-col border-t border-border/30`,children:I.map(e=>ge(e,{showProvider:!0,preferRememberedVariant:!0}))})]}):null,L.length>0?(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border/40 bg-[var(--surface-elevated)]`,children:[(0,Z.jsxs)(`div`,{className:`px-2 py-1.5 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,Z.jsx)(G,{name:`time`,className:`mr-1.5 inline-block size-3`}),D(`chat.modelControls.recent`)]}),(0,Z.jsx)(`div`,{className:`flex flex-col border-t border-border/30`,children:L.map(e=>ge(e,{showProvider:!0,preferRememberedVariant:!0}))})]}):null,R.map(e=>{let{provider:t,models:r}=e,o=i.has(t.id)||n.trim().length>0;return(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border/40 bg-[var(--surface-elevated)]`,children:[(0,Z.jsxs)(`button`,{type:`button`,...pe,onClick:()=>{n.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":o,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Ve,{providerId:t.id,className:`size-3.5`}),(0,Z.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:t.name||t.id}),t.id===f?(0,Z.jsx)(`span`,{className:`typography-micro text-primary/80`,children:D(`chat.modelControls.current`)}):null]}),(0,Z.jsx)(G,{name:o?`arrow-down-s`:`arrow-right-s`,className:`size-3 text-muted-foreground`})]}),o?(0,Z.jsx)(`div`,{className:`flex flex-col border-t border-border/30`,children:r.map(e=>ge({model:e,providerID:t.id,modelID:e.id}))}):null]},t.id)})]}),t[68]=c,t[69]=i,t[70]=I,t[71]=R,t[72]=L,t[73]=B,t[74]=s,t[75]=a,t[76]=r,t[77]=h,t[78]=g,t[79]=n,t[80]=ge,t[81]=m,t[82]=p,t[83]=f,t[84]=D,t[85]=u,t[86]=H,t[87]=_e,t[88]=ve,t[89]=ye,t[90]=be,t[91]=xe,t[92]=Se,t[93]=we,t[94]=Te,t[95]=W}else H=t[86],_e=t[87],ve=t[88],ye=t[89],be=t[90],xe=t[91],Se=t[92],we=t[93],Te=t[94],W=t[95];let Ee;t[102]!==_e||t[103]!==ve?(Ee=(0,Z.jsx)(`div`,{className:_e,children:ve}),t[102]=_e,t[103]=ve,t[104]=Ee):Ee=t[104];let De;t[105]!==H||t[106]!==ye||t[107]!==be||t[108]!==xe||t[109]!==Se||t[110]!==we||t[111]!==Ee?(De=(0,Z.jsx)(H,{useScrollShadow:ye,disableHorizontal:be,preventOverscroll:xe,outerClassName:Se,className:we,children:Ee}),t[105]=H,t[106]=ye,t[107]=be,t[108]=xe,t[109]=Se,t[110]=we,t[111]=Ee,t[112]=De):De=t[112];let Oe;return t[113]!==Te||t[114]!==W||t[115]!==De?(Oe=(0,Z.jsxs)(`div`,{className:Te,children:[W,De]}),t[113]=Te,t[114]=W,t[115]=De,t[116]=Oe):Oe=t[116],Oe};function Vr(e){let[t,n]=e;return[t,new Set(n)]}function Hr(e){return`${e.providerID}:${e.modelID}`}function Ur(e){return[e.id,e]}function Wr(e,t){return[e,t]}function Gr(e){return e.models.length>0}function Kr(e){qe(e)||(e.preventDefault(),e.stopPropagation())}var qr=e=>{let t=(0,K.c)(217),{providerId:n,modelId:r,variant:i,onChange:a,className:o,allowedProviderIds:s,allowedModelIdsByProvider:c,placeholder:l,tooltipsEnabled:u,dropdownPortalToBody:d,showIcon:f,providers:p}=e,m=u===void 0||u,h=d!==void 0&&d,g=f===void 0||f,{t:_}=he(),{isReady:v,isUnavailable:y}=hr(),b=W(Jr),x=p??b,S=W(Yr),C=te(Xr),w=te(Zr),T=te(Qr),E=te($r),D=te(ei),O=te(ti),k;t[0]!==r||t[1]!==n?(k={currentProviderID:n,currentModelID:r},t[0]=r,t[1]=n,t[2]=k):k=t[2];let{favoriteModelsList:A,recentModelsList:j}=Re(k),{isMobile:ee}=We(),ne=C||ee,[M,re]=Q.useState(!1),[ie,ae]=Q.useState(!1),N;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(N=()=>{re(!0),W.getState().refreshCatalogsOnPickerOpen({source:`modelSelector:mobilePanel`})},t[3]=N):N=t[3];let oe=pe(N),P;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(P=e=>{ae(e),e&&W.getState().refreshCatalogsOnPickerOpen({source:`modelSelector:desktopMenu`})},t[4]=P):P=t[4];let F=pe(P),[I,se]=Q.useState(``),[L,ce]=Q.useState(null),R=i!==void 0,z;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(z=()=>{re(!1),ae(!1),se(``),ce(null)},t[5]=z):z=t[5];let B=z,V;t[6]===x?V=t[7]:(V=e=>{let t=x.find(t=>t.id===e.providerID)?.models?.find(t=>t.id===e.modelID);return t?.variants?Object.keys(t.variants):[]},t[6]=x,t[7]=V);let le=V,ue;t[8]!==D||t[9]!==le||t[10]!==r||t[11]!==a||t[12]!==n||t[13]!==i||t[14]!==R?(ue=e=>{let t=le(e),o=e.providerID===n&&e.modelID===r,s=e.variant!==void 0&&t.includes(e.variant)?e.variant:void 0,c=o&&i&&t.includes(i)?i:s??``;a(e.providerID,e.modelID,R?c:void 0),D(e.providerID,e.modelID,R&&c||void 0),B()},t[8]=D,t[9]=le,t[10]=r,t[11]=a,t[12]=n,t[13]=i,t[14]=R,t[15]=ue):ue=t[15];let de=ue,fe;t[16]!==a||t[17]!==R?(fe=()=>{a(``,``,R?``:void 0),B()},t[16]=a,t[17]=R,t[18]=fe):fe=t[18];let me=fe,ge;t[19]!==D||t[20]!==a||t[21]!==L?(ge=e=>{L&&(a(L.providerID,L.modelID,e),D(L.providerID,L.modelID,e||void 0),B())},t[19]=D,t[20]=a,t[21]=L,t[22]=ge):ge=t[22];let H=ge,_e;t[23]===_?_e=t[24]:(_e=_(`settings.agents.modelSelector.searchPlaceholder`),t[23]=_,t[24]=_e);let ve;t[25]===_?ve=t[26]:(ve=_(`settings.agents.modelSelector.state.noModelsFound`),t[25]=_,t[26]=ve);let ye;t[27]===_?ye=t[28]:(ye=_(`settings.agents.modelSelector.section.favorites`),t[27]=_,t[28]=ye);let be;t[29]===_?be=t[30]:(be=_(`settings.agents.modelSelector.section.recent`),t[29]=_,t[30]=be);let xe;t[31]===_?xe=t[32]:(xe=_(`settings.agents.modelSelector.keyboardHints`),t[31]=_,t[32]=xe);let Se;t[33]!==l||t[34]!==_?(Se=l||_(`settings.agents.modelSelector.notSelected`),t[33]=l,t[34]=_,t[35]=Se):Se=t[35];let Ce;t[36]===_?Ce=t[37]:(Ce=_(`settings.agents.modelSelector.actions.favorite`),t[36]=_,t[37]=Ce);let we;t[38]===_?we=t[39]:(we=_(`settings.agents.modelSelector.actions.unfavorite`),t[38]=_,t[39]=we);let Te;t[40]===_?Te=t[41]:(Te=_(`chat.modelControls.provider`),t[40]=_,t[41]=Te);let Ee;t[42]===_?Ee=t[43]:(Ee=_(`chat.modelControls.capabilities`),t[42]=_,t[43]=Ee);let De;t[44]===_?De=t[45]:(De=_(`chat.modelControls.capability.toolCalling`),t[44]=_,t[45]=De);let Oe;t[46]===_?Oe=t[47]:(Oe=_(`chat.modelControls.capability.reasoning`),t[46]=_,t[47]=Oe);let ke;t[48]===_?ke=t[49]:(ke=_(`chat.modelControls.modality.image`),t[48]=_,t[49]=ke);let Ae;t[50]===_?Ae=t[51]:(Ae=_(`chat.modelControls.modality.video`),t[50]=_,t[51]=Ae);let je;t[52]===_?je=t[53]:(je=_(`chat.modelControls.modality.audio`),t[52]=_,t[53]=je);let Me;t[54]===_?Me=t[55]:(Me=_(`chat.modelControls.costPerMillion`),t[54]=_,t[55]=Me);let Ne;t[56]===_?Ne=t[57]:(Ne=_(`chat.modelControls.costInput`),t[56]=_,t[57]=Ne);let Pe;t[58]===_?Pe=t[59]:(Pe=_(`chat.modelControls.costOutput`),t[58]=_,t[59]=Pe);let Fe;t[60]!==_e||t[61]!==ve||t[62]!==ye||t[63]!==be||t[64]!==xe||t[65]!==Se||t[66]!==Ce||t[67]!==we||t[68]!==Te||t[69]!==Ee||t[70]!==De||t[71]!==Oe||t[72]!==ke||t[73]!==Ae||t[74]!==je||t[75]!==Me||t[76]!==Ne||t[77]!==Pe?(Fe={searchPlaceholder:_e,noResults:ve,favorites:ye,recent:be,keyboardHint:xe,notSelected:Se,favorite:Ce,unfavorite:we,provider:Te,capabilities:Ee,capabilityToolCalling:De,capabilityReasoning:Oe,modalityImage:ke,modalityVideo:Ae,modalityAudio:je,costPerMillion:Me,costInput:Ne,costOutput:Pe},t[60]=_e,t[61]=ve,t[62]=ye,t[63]=be,t[64]=xe,t[65]=Se,t[66]=Ce,t[67]=we,t[68]=Te,t[69]=Ee,t[70]=De,t[71]=Oe,t[72]=ke,t[73]=Ae,t[74]=je,t[75]=Me,t[76]=Ne,t[77]=Pe,t[78]=Fe):Fe=t[78];let Ie=Fe,Le;t[79]!==r||t[80]!==n?(Le=n&&r?{providerID:n,modelID:r}:null,t[79]=r,t[80]=n,t[81]=Le):Le=t[81];let Ve=Le,He;t[82]!==r||t[83]!==l||t[84]!==n||t[85]!==_?(He=n&&r?`${n}/${r}`:l||_(`settings.agents.modelSelector.notSelected`),t[82]=r,t[83]=l,t[84]=n,t[85]=_,t[86]=He):He=t[86];let Ue=He,Ge;t[87]!==_||t[88]!==i||t[89]!==R?(Ge=R?i||_(`chat.modelControls.default`):null,t[87]=_,t[88]=i,t[89]=R,t[90]=Ge):Ge=t[90];let Ke=Ge,qe;t[91]!==r||t[92]!==n||t[93]!==i||t[94]!==R?(qe=(e,t)=>{if(!(!R||e!==n||t!==r))return i||void 0},t[91]=r,t[92]=n,t[93]=i,t[94]=R,t[95]=qe):qe=t[95];let Je=qe,Ye;t[96]!==D||t[97]!==a||t[98]!==R?(Ye=(e,t,n)=>{a(e,t,R?n??``:void 0),D(e,t,R&&n||void 0),B()},t[96]=D,t[97]=a,t[98]=R,t[99]=Ye):Ye=t[99];let Xe=Ye,Ze;t[100]!==le||t[101]!==_||t[102]!==i||t[103]!==R?(Ze=(e,t)=>{let n=le(e);if(!R||n.length===0)return null;let r=e.variant!==void 0&&n.includes(e.variant)?e.variant:void 0,a=t.isSelected?i:r??``;return(0,Z.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(),ce(e)},"aria-label":_(`chat.modelControls.showThinkingModes`),children:[(0,Z.jsx)(`span`,{className:`max-w-24 truncate`,children:a||_(`chat.modelControls.default`)}),(0,Z.jsx)(G,{name:`arrow-right-s`,className:`size-3.5`})]})},t[100]=le,t[101]=_,t[102]=i,t[103]=R,t[104]=Ze):Ze=t[104];let Qe=Ze,$e=ne?`max-h-none flex-1`:void 0,et=m&&(ne?M:ie),tt;t[105]===E?tt=t[106]:(tt=e=>E(e.providerID,e.modelID),t[105]=E,t[106]=tt);let nt;t[107]!==r||t[108]!==n||t[109]!==T||t[110]!==i?(nt=e=>T(e.providerID,e.modelID,e.providerID===n&&e.modelID===r?i||void 0:e.variant),t[107]=r,t[108]=n,t[109]=T,t[110]=i,t[111]=nt):nt=t[111];let rt;t[112]!==c||t[113]!==s||t[114]!==A||t[115]!==S||t[116]!==de||t[117]!==me||t[118]!==w||t[119]!==Ie||t[120]!==O||t[121]!==x||t[122]!==j||t[123]!==Qe||t[124]!==I||t[125]!==Ve||t[126]!==$e||t[127]!==et||t[128]!==tt||t[129]!==nt?(rt=(0,Z.jsx)(Be,{providers:x,providerOrder:O,favoriteModels:A,recentModels:j,getMetadata:S,searchQuery:I,onSearchQueryChange:se,onSelect:de,labels:Ie,selectedModel:Ve,hiddenModels:w,allowedProviderIds:s,allowedModelIdsByProvider:c,includeNotSelected:!0,onSelectNone:me,onEscape:B,maxHeightClassName:$e,tooltipsEnabled:et,isFavorite:tt,onToggleFavorite:nt,renderRowEnd:Qe}),t[112]=c,t[113]=s,t[114]=A,t[115]=S,t[116]=de,t[117]=me,t[118]=w,t[119]=Ie,t[120]=O,t[121]=x,t[122]=j,t[123]=Qe,t[124]=I,t[125]=Ve,t[126]=$e,t[127]=et,t[128]=tt,t[129]=nt,t[130]=rt):rt=t[130];let it=rt,at;t[131]!==le||t[132]!==L?(at=L?le(L):[],t[131]=le,t[132]=L,t[133]=at):at=t[133];let ot=at,st;bb0:{if(!L){st=``;break bb0}if(L.providerID===n&&L.modelID===r){st=i||``;break bb0}st=L.variant!==void 0&&ot.includes(L.variant)?L.variant:``}let ct=st,lt;t[134]!==H||t[135]!==_||t[136]!==L||t[137]!==ct||t[138]!==ot?(lt=L?(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,Z.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:()=>ce(null),"aria-label":_(`header.actions.backAria`),children:[(0,Z.jsx)(G,{name:`arrow-left`,className:`size-4`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:L.modelID})]}),(0,Z.jsx)(`div`,{className:`space-y-1 p-2`,role:`listbox`,"aria-label":_(`chat.modelControls.thinking`),children:[``,...ot].map(e=>{let t=ct===e;return(0,Z.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,className:U(`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:()=>H(e),children:[(0,Z.jsx)(`span`,{className:`truncate`,children:e||_(`chat.modelControls.default`)}),t?(0,Z.jsx)(G,{name:`check`,className:`size-4 shrink-0`}):null]},e||`__default`)})})]}):null,t[134]=H,t[135]=_,t[136]=L,t[137]=ct,t[138]=ot,t[139]=lt):lt=t[139];let ut=lt||it;if(ne){let e=v?oe:void 0,a=!v,l=!v&&`opacity-60 cursor-not-allowed`,u;t[140]!==o||t[141]!==l?(u=U(`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`,l,o),t[140]=o,t[141]=l,t[142]=u):u=t[142];let d;t[143]!==v||t[144]!==y||t[145]!==r||t[146]!==n||t[147]!==g||t[148]!==_?(d=v?g&&(n||r)?(0,Z.jsx)(ze,{modelId:r,providerId:n,className:`h-3.5 w-3.5 flex-shrink-0`}):g?(0,Z.jsx)(G,{name:`pencil-ai`,className:`h-3 w-3 text-muted-foreground`}):null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(G,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:_(y?`common.unavailable`:`common.loading`)})]}),t[143]=v,t[144]=y,t[145]=r,t[146]=n,t[147]=g,t[148]=_,t[149]=d):d=t[149];let f;t[150]!==v||t[151]!==Ue?(f=v?(0,Z.jsx)(`span`,{className:`typography-meta font-medium text-foreground truncate`,children:Ue}):null,t[150]=v,t[151]=Ue,t[152]=f):f=t[152];let p;t[153]!==v||t[154]!==Ke?(p=v&&Ke?(0,Z.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground`,children:Ke}):null,t[153]=v,t[154]=Ke,t[155]=p):p=t[155];let m;t[156]!==d||t[157]!==f||t[158]!==p?(m=(0,Z.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,Z.jsx)(G,{name:`arrow-down-s`,className:`h-3 w-3 flex-shrink-0 text-muted-foreground`}),t[160]=h):h=t[160];let b;t[161]!==e||t[162]!==a||t[163]!==u||t[164]!==m?(b=(0,Z.jsxs)(`button`,{type:`button`,onClick:e,disabled:a,className:u,children:[m,h]}),t[161]=e,t[162]=a,t[163]=u,t[164]=m,t[165]=b):b=t[165];let C;t[166]!==A||t[167]!==r||t[168]!==n||t[169]!==j||t[170]!==T||t[171]!==i?(C=(e,t)=>T(e,t,e===n&&t===r?i||void 0:A.find(n=>n.providerID===e&&n.modelID===t)?.variant??j.find(n=>n.providerID===e&&n.modelID===t)?.variant),t[166]=A,t[167]=r,t[168]=n,t[169]=j,t[170]=T,t[171]=i,t[172]=C):C=t[172];let D;t[173]!==c||t[174]!==s||t[175]!==A||t[176]!==S||t[177]!==Xe||t[178]!==w||t[179]!==E||t[180]!==M||t[181]!==r||t[182]!==n||t[183]!==O||t[184]!==x||t[185]!==j||t[186]!==Je||t[187]!==C||t[188]!==R?(D=(0,Z.jsx)(zr,{open:M,onClose:B,selectedProviderID:n,selectedModelID:r,resolveSelectedVariant:Je,onSelect:Xe,providers:x,favoriteModels:A,recentModels:j,getMetadata:S,hiddenModels:w,allowedProviderIds:s,allowedModelIdsByProvider:c,providerOrder:O,variantSelectionEnabled:R,isFavorite:E,onToggleFavorite:C}),t[173]=c,t[174]=s,t[175]=A,t[176]=S,t[177]=Xe,t[178]=w,t[179]=E,t[180]=M,t[181]=r,t[182]=n,t[183]=O,t[184]=x,t[185]=j,t[186]=Je,t[187]=C,t[188]=R,t[189]=D):D=t[189];let k;return t[190]!==b||t[191]!==D?(k=(0,Z.jsxs)(Z.Fragment,{children:[b,D]}),t[190]=b,t[191]=D,t[192]=k):k=t[192],k}let dt=v&&ie,ft=v?F:void 0,pt=!v&&`opacity-60 cursor-not-allowed`,mt;t[193]!==o||t[194]!==pt?(mt=U(`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`,pt,o),t[193]=o,t[194]=pt,t[195]=mt):mt=t[195];let ht;t[196]!==v||t[197]!==y||t[198]!==r||t[199]!==n||t[200]!==g||t[201]!==_||t[202]!==Ue||t[203]!==Ke?(ht=v?(0,Z.jsxs)(Z.Fragment,{children:[g?n||r?(0,Z.jsx)(ze,{modelId:r,providerId:n,className:`h-3.5 w-3.5 flex-shrink-0`}):(0,Z.jsx)(G,{name:`pencil-ai`,className:`h-3.5 w-3.5 flex-shrink-0 text-muted-foreground`}):null,(0,Z.jsx)(`span`,{className:`typography-ui-label min-w-0 flex-1 truncate text-left font-normal text-foreground`,children:Ue}),Ke?(0,Z.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground`,children:Ke}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(G,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin text-muted-foreground flex-shrink-0`}),(0,Z.jsx)(`span`,{className:`typography-ui-label font-normal whitespace-nowrap text-muted-foreground`,children:_(y?`common.unavailable`:`common.loading`)})]}),t[196]=v,t[197]=y,t[198]=r,t[199]=n,t[200]=g,t[201]=_,t[202]=Ue,t[203]=Ke,t[204]=ht):ht=t[204];let gt;t[205]===Symbol.for(`react.memo_cache_sentinel`)?(gt=(0,Z.jsx)(G,{name:`arrow-down-s`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground/50`}),t[205]=gt):gt=t[205];let _t;t[206]!==mt||t[207]!==ht?(_t=(0,Z.jsx)(cr,{asChild:!0,children:(0,Z.jsxs)(`div`,{className:mt,children:[ht,gt]})}),t[206]=mt,t[207]=ht,t[208]=_t):_t=t[208];let vt;t[209]!==h||t[210]!==ut?(vt=(0,Z.jsx)(lr,{className:`w-[min(380px,calc(100vw-2rem))] p-0 flex flex-col`,align:`start`,portalToBody:h,children:ut}),t[209]=h,t[210]=ut,t[211]=vt):vt=t[211];let yt;return t[212]!==dt||t[213]!==ft||t[214]!==_t||t[215]!==vt?(yt=(0,Z.jsxs)(sr,{open:dt,onOpenChange:ft,children:[_t,vt]}),t[212]=dt,t[213]=ft,t[214]=_t,t[215]=vt,t[216]=yt):yt=t[216],yt};function Jr(e){return e.providers}function Yr(e){return e.getModelMetadata}function Xr(e){return e.isMobile}function Zr(e){return e.hiddenModels}function Qr(e){return e.toggleFavoriteModel}function $r(e){return e.isFavoriteModel}function ei(e){return e.addRecentModel}function ti(e){return e.providerOrder}var ni=e(k(),1),ri=`mobile-overlay-root`,ii=16,ai=200,oi=[],si=0,ci=``,li=0,ui=()=>{if(typeof document>`u`)return null;let e=document.getElementById(ri);return e||(e=document.createElement(`div`),e.id=ri,document.body.appendChild(e)),e},di=({open:e,title:t,onClose:n,children:r,footer:i,className:a,contentMaxHeightClassName:o,renderHeader:s,containedBody:c=!1,closeAriaLabel:l})=>{let u=Q.useRef(null),d=Q.useRef(Symbol(`mobile-overlay`)),f=Q.useRef(n);f.current=n;let[p,m]=Q.useState(!1),[h,g]=Q.useState(!1);if(typeof document<`u`&&!u.current&&(u.current=ui()),Q.useEffect(()=>{if(!e){m(!1),g(!1);return}let t=window.setTimeout(()=>m(!0),ii),n=window.setTimeout(()=>g(!0),266);return()=>{window.clearTimeout(t),window.clearTimeout(n)}},[e]),Q.useLayoutEffect(()=>{if(e)return li===0&&window.dispatchEvent(new Event(`oc:mobile-overlay-opened`)),li+=1,()=>{li=Math.max(0,li-1),li===0&&window.dispatchEvent(new Event(`oc:mobile-overlay-closed`))}},[e]),Q.useEffect(()=>{if(!e)return;let t=d.current;oi.push(t),si===0&&(ci=document.body.style.overflow),si+=1,document.body.style.overflow=`hidden`;let n=e=>{e.key===`Escape`&&oi[oi.length-1]===t&&f.current()};return document.addEventListener(`keydown`,n),()=>{let e=oi.lastIndexOf(t);e>=0&&oi.splice(e,1),si=Math.max(0,si-1),si===0&&(document.body.style.overflow=ci),document.removeEventListener(`keydown`,n)}},[e]),!e||!u.current)return null;let _=o??`max-h-[min(70vh,520px)]`,v=(0,Z.jsx)(`div`,{className:U(`oc-keyboard-inset-surface fixed inset-0 z-[60] flex flex-col bg-[rgb(0_0_0_/_0.45)] transition-opacity duration-200 ease-out`,!h&&`oc-keyboard-inset-snap`,p?`opacity-100`:`opacity-0`),role:`dialog`,"aria-modal":`true`,"aria-label":t,onPointerDown:Ge,onClick:e=>{Xe(e)&&n()},children:(0,Z.jsxs)(`div`,{className:U(`mt-auto flex max-h-[calc(100dvh-0.75rem)] min-h-0 w-full flex-col rounded-t-xl border-x border-t border-border/50 bg-background pb-[max(0.5rem,var(--oc-app-bottom-safe,0px),var(--oc-safe-area-bottom,env(safe-area-inset-bottom,0px)))] shadow-none pwa-overlay-panel`,`mx-auto max-w-lg`,a),style:{transform:p?`none`:`translateY(100%)`,transition:`transform ${ai}ms cubic-bezier(0.32, 0.72, 0, 1)`},onClick:e=>e.stopPropagation(),children:[(()=>{let e=(0,Z.jsx)(`button`,{type:`button`,onClick:n,className:U(`flex items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover`,c?`size-11`:`h-8 w-8`),"aria-label":l??t,children:(0,Z.jsx)(G,{name:`close`,className:`h-4 w-4`})});return s?s(e):(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border/40`,children:[(0,Z.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:t}),e]})})(),c?(0,Z.jsx)(`div`,{className:U(`flex min-h-0 flex-1 flex-col overflow-hidden`,_),children:r}):(0,Z.jsx)(Ye,{useScrollShadow:!0,disableHorizontal:!0,preventOverscroll:!0,outerClassName:U(`min-h-0 flex-1`,_),className:`px-2 py-2 pwa-overlay-scroll`,children:r}),i?(0,Z.jsx)(`div`,{className:`shrink-0 border-t border-border/40 px-3 py-2`,children:i}):null]})});return(0,ni.createPortal)(v,u.current)},fi=e=>e??o()?.github,pi=(e=n())=>s.github.auth(e),mi=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},hi=(e,t=n())=>{let r=fi(e);return{queryKey:pi(t),queryFn:async({signal:e})=>mi(r,e),retry:2}},gi=e=>!!e&&typeof e==`object`&&`authStatus`in e,_i=e=>{let t=(0,K.c)(5),n=gi(e)?e:void 0,r=gi(e)?void 0:e?.enabled,i;t[0]===n?i=t[1]:(i=hi(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],P(a)},vi=(e=l,t=n())=>e.getQueryData(pi(t))??null,yi=async(e,t,r)=>n()===r?e.fetchQuery({...hi(t,r),staleTime:0}):e.getQueryData(pi(r))??null,bi=(e=l,t,r=n())=>{e.setQueryData(pi(r),t)},xi=L.define(fe),Si=le.data.of({commentTokens:{line:`//`,block:{open:`/*`,close:`*/`}}});function Ci(e){let t=e.trim().toLowerCase();switch(t){case`bash`:case`sh`:case`zsh`:case`shell`:case`shellsession`:case`console`:return xi;case`json`:case`jsonc`:case`json5`:return V().language;case`js`:case`javascript`:return z().language;case`jsx`:return z({jsx:!0}).language;case`ts`:case`typescript`:return z({typescript:!0}).language;case`tsx`:return z({typescript:!0,jsx:!0}).language;case`html`:return B().language;case`css`:return R().language;case`py`:case`python`:return de().language;case`md`:case`markdown`:case`mdown`:case`mkd`:return ue().language;case`heex`:case`eex`:case`leex`:return B().language;default:return ce.matchLanguageName(lt,t,!0)}}var wi=e=>e.split(`/`).pop()?.toLowerCase()??``,Ti=e=>{let t=wi(e);return t?ce.matchFilename(lt,t):null},Ei=()=>F(se.define([{tag:[I.heading1,I.heading2,I.heading3,I.heading4,I.heading5,I.heading6],fontWeight:`600`},{tag:I.strong,fontWeight:`600`},{tag:I.emphasis,fontStyle:`italic`},{tag:I.strikethrough,textDecoration:`line-through`},{tag:[I.link,I.url],color:`var(--markdown-link, currentColor)`,textDecoration:`underline`},{tag:I.monospace,color:`var(--markdown-inline-code, currentColor)`,backgroundColor:`var(--markdown-inline-code-bg, transparent)`},{tag:I.quote,color:`var(--markdown-blockquote, currentColor)`,fontStyle:`italic`},{tag:I.list,color:`color-mix(in srgb, var(--muted-foreground) 40%, var(--foreground) 60%)`},{tag:I.heading,color:`var(--markdown-heading1, currentColor)`}]));function Di(e){let t=e.toLowerCase();switch(wi(t)){case`makefile`:case`gnumakefile`:return xi}let n=t.lastIndexOf(`.`),r=n>=0?t.slice(n+1):``;switch(r){case`ts`:case`tsx`:case`mts`:case`cts`:return z({typescript:!0,jsx:r===`tsx`});case`js`:case`jsx`:case`mjs`:case`cjs`:return z({typescript:!1,jsx:r===`jsx`});case`jsonc`:case`json5`:return[V(),Si];case`json`:case`jsonl`:case`ndjson`:case`geojson`:return V();case`css`:case`scss`:case`sass`:case`less`:return R();case`html`:case`htm`:case`xml`:case`drawio`:case`dio`:return B();case`md`:case`mdx`:case`markdown`:case`mdown`:case`mkd`:return[ue({codeLanguages:Ci}),Ei()];case`sh`:case`bash`:case`zsh`:case`fish`:case`env`:return xi;case`py`:case`pyw`:case`pyi`:return de();default:return null}}async function Oi(e){let t=Ti(e);if(!t)return null;if(t.support)return t.support;try{return await t.load()}catch{return null}}var ki=e=>e===`allow`||e===`deny`||e===`ask`;function Ai(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function ji(e){return Ai(e)?typeof e.action==`string`&&typeof e.resource==`string`&&ki(e.effect)?{action:e.action,resource:e.resource,effect:e.effect}:typeof e.permission==`string`&&typeof e.pattern==`string`&&ki(e.action)?{action:e.permission,resource:e.pattern,effect:e.action}:null:null}function Mi(e){if(Array.isArray(e))return e.flatMap(e=>{let t=ji(e);return t?[t]:[]});if(ki(e))return[{action:`*`,resource:`*`,effect:e}];if(!Ai(e))return[];let t=[];for(let[n,r]of Object.entries(e))if(n!==`__originalKeys`){if(ki(r)){t.push({action:n,resource:`*`,effect:r});continue}if(Ai(r))for(let[e,i]of Object.entries(r))ki(i)&&t.push({action:n,resource:e,effect:i})}return t}function Ni(e){return Mi(e)}async function Pi(e,t,n){if(!e.body)throw Error(`Speech response has no stream`);let r=e.body.getReader(),i=t.createGain();i.gain.value=n.volume,i.connect(t.destination);let a=new Set,o=new Set,s=new TextDecoder,c=t.currentTime,l=``,u,d=!1,f=!1,p=0,m=2**(n.pitch-1),h=[],g=0,_=!0,v=()=>{r.cancel().catch(()=>void 0);for(let e of a)e.stop()};n.signal.addEventListener(`abort`,v,{once:!0});let y=async e=>{for(;c-t.currentTime>2&&o.size;)await Promise.race(o),n.signal.throwIfAborted();n.signal.throwIfAborted();let r=t.createBufferSource();r.buffer=e,r.detune.value=(n.pitch-1)*1200,r.connect(i);let s,l=new Promise(e=>{s=e});o.add(l),a.add(r),r.onended=()=>{a.delete(r),o.delete(l),r.disconnect(),s()};let u=Math.max(c,t.currentTime+.02);r.start(u),c=u+e.duration/m,d||(d=!0,n.onStart())},b=async()=>{for(let e of h)await y(e);h.length=0,g=0,_=!1},x=async e=>{if(!e.trim())return;if(f)throw Error(`Unexpected audio after speech completion`);let n=JSON.parse(e);if(n.type===`error`)throw Error(`Speech synthesis interrupted or failed`);if(n.type===`done`){f=!0,await b();return}if(n.type!==`audio`||typeof n.data!=`string`||n.data.length>12800)throw Error(`Invalid speech audio frame`);let r=atob(n.data),i=new Uint8Array(r.length+(u===void 0?0:1)),a=0;u!==void 0&&(i[a++]=u);for(let e=0;e<r.length;e++)i[a+e]=r.charCodeAt(e);u=i.length%2?i[i.length-1]:void 0;let o=Math.floor(i.length/2);if(!o)return;let s=t.createBuffer(1,o,24e3),l=s.getChannelData(0),d=new DataView(i.buffer);for(let e=0;e<o;e++)l[e]=d.getInt16(e*2,!0)/32768;c<t.currentTime+.02&&(_=!0),h.push(s),g+=s.duration/m,(!_||g>=.4)&&await b()};try{for(n.signal.throwIfAborted();;){let e=await r.read();if(n.signal.throwIfAborted(),e.done)break;if(p+=e.value.length,p>33554432)throw Error(`Speech stream exceeds the size limit`);l+=s.decode(e.value,{stream:!0});let t;for(;(t=l.indexOf(`
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,l as r,n as i}from"./runtime-switch-3ad3yzM7.js";import{n as a}from"./runtime-fetch-QCWYlAx0.js";import{Mn as o,h as s,l as c,m as l,nn as u,on as d,ot as f,rn as p}from"./persistence-DUPZl7Oy.js";import{h as m}from"./desktopHosts-BKeEWmL5.js";import{i as h,n as g,r as _}from"./desktopRelayRestore-FWm2fXr6.js";import{A as v,D as y,F as b,I as x,L as S,M as C,N as w,O as T,P as E,it as D,j as O,nt as k,rt as A}from"./vendor-base-ui-CdzJ6My_.js";import{Ln as j,Nt as ee}from"./platform-z2erC6Bs.js";import{n as te}from"./useUIStore-pl39iO82.js";import{n as ne}from"./vendor-react-BP2cRVqX.js";import{o as M}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{n as re}from"./vendor-tanstack-query-core-BWz0ose6.js";import{i as ie,l as ae,n as N,r as oe,s as P}from"./vendor-tanstack-react-query-CdqCAt40.js";import{P as F,V as I,a as se,f as L,l as ce}from"./vendor-codemirror-autocomplete-DHomsvW7.js";import{c as R,o as z,r as B}from"./vendor-codemirror-lang-angular-BDXnzWgq.js";import{n as V,r as le}from"./vendor-codemirror-lang-json-tHviF6YN.js";import{n as ue}from"./vendor-codemirror-lang-markdown-Bt-vLz9k.js";import{n as de}from"./vendor-codemirror-lang-python-B4naLXMo.js";import{O as fe}from"./vendor-codemirror-legacy-modes-DwltVFbT.js";import{n as pe}from"./vendor-reactuses-core-BpfIZ1tg.js";import{d as me,f as he,l as ge,p as H,r as U,t as _e}from"./button-kJNzMb1G.js";import{i as ve,t as ye}from"./store-D5OeM4wB.js";import{Ar as be,Dr as xe,Fa as Se,Na as Ce,Pr as we,Va as Te,ba as W,br as Ee,d as De,mo as Oe,to as ke,va as Ae}from"./useMobileNavigationStore-DX_Dgij_.js";import{t as je}from"./AgentAvatar-Ah1nMt7y.js";import{t as Me}from"./useThemeSystem-8jhE4Zyk.js";import{n as G}from"./Icon-DewMAW7N.js";import{i as Ne,n as Pe,r as Fe,t as Ie}from"./vendor-simplewebauthn-browser-Dwhcdg_5.js";import{C as Le,D as Re,O as ze,S as Be,T as Ve,w as He}from"./projectMeta-2C2lGY_I.js";import{t as Ue}from"./input-02eTmC8w.js";import{i as We}from"./OverlayScrollbar-C24-p2ns.js";import{_ as Ge,g as Ke,h as qe,i as Je,n as Ye,v as Xe}from"./textarea-yLPH5NYp.js";import{c as Ze,d as Qe,f as $e,h as et,l as tt,m as nt,n as rt,p as it,r as at,s as ot,t as st,u as ct}from"./dropdown-menu.styles-BXvVFEkh.js";import{t as lt}from"./vendor-codemirror-language-data-DGDYune4.js";var K=ne(),ut=[`desktopHostSwitch`],dt=class extends Error{result;host;constructor(e,t){super(e.reason),this.name=`DesktopHostSwitchError`,this.result=e,this.host=t}},ft=(e,t)=>ye(ve.getState().dictionary,e,t),pt=async e=>{let{host:t}=e;if(t.id===`local`){let n=(e.localApiOrigin||``).trim();if(!n)throw new dt({ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unreachable`},t);return r({apiBaseUrl:n,clientToken:e.localClientToken||null,runtimeKey:_(t)}),{ok:!0,via:`direct`,status:{status:`ok`,latencyMs:0}}}let n=await h(t,{cachedProbe:e.cachedProbe});if(!n.ok)throw new dt(n,t);return n},mt=null,ht=()=>mt||(mt=new re(l,{mutationKey:ut,mutationFn:pt,onError:(e,t)=>{if(e instanceof dt&&e.result.reason!==`unsupported`){if(e.result.status.status===`auth`){we.error(ft(`desktopHostSwitcher.status.authRequired`));return}we.error(ft(`desktopHostSwitcher.toast.instanceUnreachable`,{host:m(t.host.label)}))}}}),mt.subscribe(()=>void 0),mt),gt=async e=>{if(g(e.host))return{ok:!0,via:`direct`,status:e.cachedProbe?.status===`ok`?e.cachedProbe:{status:`ok`,latencyMs:0}};if(l.isMutating({mutationKey:ut})>0)return{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unsupported`};try{return await ht().mutate(e)}catch(e){if(e instanceof dt)return e.result;throw e}},_t=()=>{let e=(0,K.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={mutationKey:ut},e[0]=t):t=e[0],oe(t)>0},vt=()=>{let e=(0,K.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={filters:{mutationKey:ut,status:`pending`},select:yt},e[0]=t):t=e[0],ie(t)[0]?.host.id??null};function yt(e){return e.state.variables}var q=e=>typeof e==`object`&&!!e,J=(e,t)=>{let n=e[t];return typeof n==`string`?n:null},Y=(e,t)=>{let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:null},X=(e,t)=>{let n=e[t];return typeof n==`boolean`?n:null},bt=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],xt=()=>u()?(e,t)=>p(e,t):null,St=e=>{if(!q(e))return;let t=X(e,`enabled`)??!1,n=J(e,`store`)?.toLowerCase()===`settings`?`settings`:`never`,r=J(e,`value`);return{enabled:t,store:n,...r?{value:r}:{}}},Ct=e=>e===`remote`||e===`dynamic`?e:`local`,wt=e=>{if(!q(e))return null;let t=J(e,`id`);if(!t)return null;let n=X(e,`enabled`)??!0,r=Ct(J(e,`type`)),i=J(e,`localHost`)||J(e,`local_host`)||void 0,a=Y(e,`localPort`)??Y(e,`local_port`)??void 0,o=J(e,`remoteHost`)||J(e,`remote_host`)||void 0,s=Y(e,`remotePort`)??Y(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}:{}}},Tt=e=>{if(!q(e))return null;let t=J(e,`id`),n=J(e,`sshCommand`)||J(e,`ssh_command`);if(!t||!n)return null;let r=J(e,`nickname`),i=e.sshParsed,a=q(i)?{destination:J(i,`destination`)||``,args:bt(i.args)}:void 0,o=q(e.remoteOpenchamber)?e.remoteOpenchamber:q(e.remote_openchamber)?e.remote_openchamber:{},s=q(e.localForward)?e.localForward:q(e.local_forward)?e.local_forward:{},c=q(e.auth)?e.auth:{},l=J(o,`mode`)?.toLowerCase()===`external`?`external`:`managed`,u=J(o,`installMethod`)||J(o,`install_method`),d=u===`npm`||u===`download_release`||u===`upload_bundle`?u:`bun`,f=J(s,`bindHost`)||J(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=>wt(e)).filter(e=>!!e),h=Y(o,`preferredPort`)??Y(o,`preferred_port`),g=Y(s,`preferredLocalPort`)??Y(s,`preferred_local_port`),_=St(c.sshPassword||c.ssh_password),v=St(c.openchamberPassword||c.openchamber_password);return{id:t,...r?{nickname:r}:{},sshCommand:n,...a&&a.destination?{sshParsed:a}:{},connectionTimeoutSec:Y(e,`connectionTimeoutSec`)??Y(e,`connection_timeout_sec`)??60,remoteOpenchamber:{mode:l,keepRunning:X(o,`keepRunning`)??X(o,`keep_running`)??!0,relayHost:X(o,`relayHost`)??X(o,`relay_host`)??!0,...h?{preferredPort:h}:{},installMethod:d,uploadBundleOverSsh:X(o,`uploadBundleOverSsh`)??X(o,`upload_bundle_over_ssh`)??!1},localForward:{...g?{preferredLocalPort:g}:{},bindHost:p},auth:{..._?{sshPassword:_}:{},...v?{openchamberPassword:v}:{}},portForwards:m}},Et=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`}},Dt=e=>{if(!q(e))return null;let t=J(e,`id`);return t?{id:t,phase:Et(J(e,`phase`)),...J(e,`detail`)?{detail:J(e,`detail`)||void 0}:{},...J(e,`localUrl`)||J(e,`local_url`)?{localUrl:J(e,`localUrl`)||J(e,`local_url`)||void 0}:{},...typeof(Y(e,`localPort`)??Y(e,`local_port`))==`number`?{localPort:Y(e,`localPort`)??Y(e,`local_port`)??void 0}:{},...typeof(Y(e,`remotePort`)??Y(e,`remote_port`))==`number`?{remotePort:Y(e,`remotePort`)??Y(e,`remote_port`)??void 0}:{},startedByUs:X(e,`startedByUs`)??X(e,`started_by_us`)??!1,retryAttempt:Y(e,`retryAttempt`)??Y(e,`retry_attempt`)??0,requiresUserAction:X(e,`requiresUserAction`)??X(e,`requires_user_action`)??!1,...J(e,`errorCode`)||J(e,`error_code`)?{errorCode:J(e,`errorCode`)||J(e,`error_code`)||void 0}:{},updatedAtMs:Y(e,`updatedAtMs`)??Y(e,`updated_at_ms`)??Date.now()}:null},Ot=e=>{if(!q(e))return null;let t=J(e,`host`),n=J(e,`source`),r=J(e,`sshCommand`)||J(e,`ssh_command`);return!t||!n||!r?null:{host:t,source:n,sshCommand:r,pattern:X(e,`pattern`)??!1}},kt=(e,t)=>({id:e,sshCommand:t,connectionTimeoutSec:60,remoteOpenchamber:{mode:`managed`,keepRunning:!0,relayHost:!0,installMethod:`bun`,uploadBundleOverSsh:!1},localForward:{bindHost:`127.0.0.1`},auth:{},portForwards:[]}),At=async()=>{let e=xt();if(!e)return{instances:[]};let t=await e(`desktop_ssh_instances_get`);return q(t)?{instances:(Array.isArray(t.instances)?t.instances:Array.isArray(t.desktopSshInstances)?t.desktopSshInstances:[]).map(e=>Tt(e)).filter(e=>!!e)}:{instances:[]}},jt=async e=>{let t=xt();t&&await t(`desktop_ssh_instances_set`,{config:{instances:e.instances}})},Mt=async()=>{let e=xt();if(!e)return[];let t=await e(`desktop_ssh_import_hosts`);return Array.isArray(t)?t.map(e=>Ot(e)).filter(e=>!!e):[]},Nt=async e=>{let t=xt();t&&await t(`desktop_ssh_connect`,{id:e})},Pt=async e=>{let t=xt();t&&await t(`desktop_ssh_disconnect`,{id:e})},Ft=async e=>{let t=xt();if(!t)return[];let n=await t(`desktop_ssh_status`,{...e?{id:e}:{}});return Array.isArray(n)?n.map(e=>Dt(e)).filter(e=>!!e):[]},It=async(e,t)=>{let n=xt();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`):[]},Lt=async e=>{let t=xt();t&&await t(`desktop_ssh_logs_clear`,{id:e})},Rt=(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}},zt=e=>{if(!q(e))return null;let t=J(e,`path`),n=Y(e,`bytes`);return!t||n===null?null:{path:t,bytes:n}},Bt=e=>{if(!q(e))return null;let t=J(e,`path`),n=Y(e,`fileCount`)??Y(e,`file_count`),r=Y(e,`bytes`);return!t||n===null||r===null?null:{path:t,fileCount:n,bytes:r}},Vt=e=>{if(e==null||!q(e))return null;let t=Y(e,`fileCount`)??Y(e,`file_count`),n=Y(e,`bytes`);return t===null||n===null?null:{fileCount:t,bytes:n}},Ht=e=>{if(e==null||!q(e))return null;let t=Y(e,`bytes`);return t===null?null:{bytes:t}},Ut=e=>{if(!q(e))return null;let t=Array.isArray(e.files)?e.files:null,n=Array.isArray(e.directories)?e.directories:null,r=bt(e.deletes),i=Y(e,`totalBytes`)??Y(e,`total_bytes`);if(!t||!n||i===null||!(`agentsRoot`in e)&&!(`agents_root`in e))return null;let a=t.map(e=>zt(e)).filter(e=>!!e),o=n.map(e=>Bt(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:Vt(s);if(s!=null&&c===null)return null;let l=e.authFile??e.auth_file,u=l==null?null:Ht(l),d=e.direction===`pull`||e.direction===`push`?e.direction:void 0,f=e.selections,p=q(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=Wt(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}:{}}},Wt=e=>{if(!q(e))return null;let t=Y(e,`fileGroups`)??Y(e,`file_groups`),n=Y(e,`singleFiles`)??Y(e,`single_files`),r=Y(e,`directories`);return t===null||n===null||r===null||t<0||n<0||r<0?null:{fileGroups:t,singleFiles:n,directories:r}},Gt=e=>{if(!q(e))return null;let t=Ut(e.plan);if(!t)return null;let n=Wt(e.selectionShape??e.selection_shape)??t.selectionShape??null;return{plan:t,remoteExisting:bt(e.remoteExisting??e.remote_existing),remoteAgentsRootExists:X(e,`remoteAgentsRootExists`)??X(e,`remote_agents_root_exists`)??!1,remoteAuthFileExists:X(e,`remoteAuthFileExists`)??X(e,`remote_auth_file_exists`)??!1,...n?{selectionShape:n}:{}}},Kt=e=>{if(!q(e)||X(e,`ok`)!==!0)return null;let t=Y(e,`files`),n=Y(e,`directories`),r=Y(e,`deletes`),i=Y(e,`totalBytes`)??Y(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(!q(a))return null;let e=Y(a,`fileCount`)??Y(a,`file_count`);if(e===null)return null;o={fileCount:e}}let s=e.authFile??e.auth_file,c=s==null?null:Ht(s);return{ok:!0,files:t,directories:n,deletes:r,totalBytes:i,agentsRoot:o,authFile:c}},qt=async(e={})=>{let t=xt();if(!t)return console.error(`[desktopSsh] config sync local scan skipped: desktop IPC bridge is unavailable in this window`),null;let n=await t(`desktop_ssh_sync_opencode_config`,{stage:`local`,...e.direction?{direction:e.direction}:{},...e.selections?{selections:e.selections}:{}});if(!q(n))return console.error(`[desktopSsh] config sync local scan returned a non-object payload`,n),null;let r=Ut(n.plan);if(!r)return console.error(`[desktopSsh] config sync local scan plan payload was not recognized`,n),null;let i=Wt(n.selectionShape??n.selection_shape)??r.selectionShape??null;return i?{...r,selectionShape:i}:r},Jt=async(e,t={})=>{let n=xt();if(!n)return console.error(`[desktopSsh] config sync preview skipped: desktop IPC bridge is unavailable in this window`),null;let r=await n(`desktop_ssh_sync_opencode_config`,{id:e,...t.targetKind?{targetKind:t.targetKind}:{},...t.direction?{direction:t.direction}:{},...t.selections?{selections:t.selections}:{}}),i=Gt(r);return i||console.error(`[desktopSsh] config sync preview payload was not recognized`,r),i},Yt=async(e,t={})=>{let n=xt();if(!n)return console.error(`[desktopSsh] config sync apply skipped: desktop IPC bridge is unavailable in this window`),null;let r=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}:{}}),i=Kt(r);return i||console.error(`[desktopSsh] config sync apply payload was not recognized`,r),i},Xt=async(e,t={})=>{let n=xt();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=>q(e)&&typeof e.syncRunId==`string`&&typeof e.targetId==`string`):[]},Zt=async e=>{if(!u())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=Dt(t?.payload);n&&e(n)});return async()=>{await n()}},Qt=new Set([`nodeRuntimeMissing`,`packageManagerMissing`,`nativeBinding`,`openchamberCliMissing`,`openchamberRegistry`,`openchamberInstall`,`openchamberCliIncompatible`,`opencodeInstall`,`serverStart`,`sshAuth`,`sshUnreachable`,`timeout`,`unknown`]),$t=e=>typeof e==`string`&&Qt.has(e),en=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`:/OpenChamber installation completed but the executable is unavailable/i.test(t)?`openchamberCliMissing`:/could not reach the npm registry|ENOTFOUND|ECONNREFUSED|ETIMEDOUT|EAI_AGAIN|CERT_HAS_EXPIRED|UNABLE_TO_GET_ISSUER_CERT|self-signed certificate|registry\.npmjs|npm error code E404|npm ERR! code E404|getaddrinfo/i.test(t)?`openchamberRegistry`:/Failed to install OpenChamber/i.test(t)?`openchamberInstall`:/Unknown option:\s*--relay-host|does not advertise --relay-host|does not support --relay-host/i.test(t)||/Unknown option:/i.test(t)?`openchamberCliIncompatible`:/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`},tn=(e,t)=>$t(e)?e:en(t),nn=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`openchamberCliMissing`:return`desktopHostSwitcher.sshError.openchamberCliMissing.title`;case`openchamberRegistry`:return`desktopHostSwitcher.sshError.openchamberRegistry.title`;case`openchamberInstall`:return`desktopHostSwitcher.sshError.openchamberInstall.title`;case`openchamberCliIncompatible`:return`desktopHostSwitcher.sshError.openchamberCliIncompatible.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`}},rn=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`openchamberCliMissing`:return`desktopHostSwitcher.sshError.openchamberCliMissing.guidance`;case`openchamberRegistry`:return`desktopHostSwitcher.sshError.openchamberRegistry.guidance`;case`openchamberInstall`:return`desktopHostSwitcher.sshError.openchamberInstall.guidance`;case`openchamberCliIncompatible`:return`desktopHostSwitcher.sshError.openchamberCliIncompatible.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`}},an=e=>e===`unknown`||e===`openchamberCliIncompatible`,on=(e,t,n)=>{let r=typeof n==`string`?n.trim():``;return!an(t)||!r||r===e?e:`${e}\n${r}`},Z=A();function sn(e){let t=(0,K.c)(27),{errorCode:n,detail:r,className:i}=e,{t:a}=he(),o,s,c,l,u,d;if(t[0]!==i||t[1]!==r||t[2]!==n||t[3]!==a){let e=tn(n,r);o=a(rn(e));let f;t[10]===r?f=t[11]:(f=typeof r==`string`?r.trim():``,t[10]=r,t[11]=f),s=f,c=an(e)&&!!s&&s!==o,t[12]===i?d=t[13]:(d=U(`space-y-1`,i),t[12]=i,t[13]=d),l=`typography-ui-label text-[var(--status-error)]`,u=a(nn(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,t[8]=u,t[9]=d}else o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9];let f;t[14]!==l||t[15]!==u?(f=(0,Z.jsx)(`p`,{className:l,children:u}),t[14]=l,t[15]=u,t[16]=f):f=t[16];let p;t[17]===o?p=t[18]:(p=(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:o}),t[17]=o,t[18]=p);let m;t[19]!==s||t[20]!==c?(m=c?(0,Z.jsx)(`p`,{className:`typography-meta break-words text-muted-foreground`,children:s}):null,t[19]=s,t[20]=c,t[21]=m):m=t[21];let h;return t[22]!==d||t[23]!==f||t[24]!==p||t[25]!==m?(h=(0,Z.jsxs)(`div`,{className:d,children:[f,p,m]}),t[22]=d,t[23]=f,t[24]=p,t[25]=m,t[26]=h):h=t[26],h}var Q=e(D(),1),cn=[.2,.45,.15,.55,.35,.1,.5,.25,.4,.3,.45,.15,.55,.2,.35,.1],ln=[.3,.15,.45,.25,.5,.35,.1,.4,.2,.55,.3,.15,.45,.25,.4,.2],un=(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},dn=({className:e=``,width:t=70,height:n=70,isAnimated:r=!1})=>{let{t:i}=he(),a=Me(),o=!0;a?o=a.currentTheme.metadata.variant!==`light`:typeof window<`u`&&(o=window.matchMedia(`(prefers-color-scheme: dark)`).matches);let s=(0,Q.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,Q.useMemo)(()=>typeof window>`u`||typeof CSS>`u`||typeof CSS.supports!=`function`?!1:CSS.supports(`color`,`color-mix(in srgb, white 50%, transparent)`),[]),l=(0,Q.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,Q.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=un(h,_,b,v),C=un(_,g,y,b);return(0,Z.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,Z.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,Z.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,Z.jsx)(`path`,{d:e.path,fill:u,opacity:cn[e.row*4+(3-e.col)]??.35},`left-${t}`)),(0,Z.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,Z.jsx)(`path`,{d:e.path,fill:u,opacity:ln[e.row*4+e.col]??.35},`right-${t}`)),(0,Z.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,Z.jsx)(`g`,{opacity:1,className:r?`oc-logo-glow`:void 0,style:r?{"--oc-glow-color":s}:void 0,children:(0,Z.jsxs)(`g`,{transform:`${x} scale(0.75)`,children:[(0,Z.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,Z.jsx)(`path`,{d:`M-8 -4 L8 -4 L8 12 L-8 12 Z`,fill:d,fillOpacity:`0.4`})]})})]})},fn=`/auth/passkey/authenticate/options`,pn=`/auth/passkey/authenticate/verify`,mn=`/auth/passkey/register/options`,hn=`/auth/passkey/register/verify`,gn=`/api/passkeys`,_n=`/auth/passkey/status`,vn=`/api/auth/reset`,yn={enabled:!1,hasPasskeys:!1,passkeyCount:0,rpID:null},bn=async(e,t)=>a(e,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:t===void 0?void 0:JSON.stringify(t)}),xn=async(e,t)=>{try{let t=await e.json();if(t&&typeof t.error==`string`&&t.error.trim())return t.error}catch{}return t},Sn=e=>e instanceof Ne&&e.code===`ERROR_CEREMONY_ABORTED`,Cn=()=>{Fe.cancelCeremony()},wn=()=>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.`},Tn=async()=>{let e=wn();if(!e.supported)throw Error(e.reason);let t=await bn(mn,{label:typeof navigator.userAgent==`string`&&navigator.userAgent.trim()?navigator.userAgent:`This device`});if(!t.ok)throw Error(await xn(t,`Could not start passkey setup.`));let{requestId:n,optionsJSON:r}=await t.json(),i=await bn(hn,{requestId:n,response:await Pe({optionsJSON:r})});if(!i.ok)throw Error(await xn(i,`Could not finish passkey setup.`));return i.json().catch(()=>null)},En=async(e,t={})=>{let n=wn();if(!n.supported)throw Error(n.reason);let r=await bn(fn);if(!r.ok)throw Error(await xn(r,`Passkey sign-in is not available right now.`));let{requestId:i,optionsJSON:a}=await r.json(),o=await bn(pn,{requestId:i,response:await Ie({optionsJSON:a}),trustDevice:e,issueClientToken:t.issueClientToken===!0,clientLabel:t.clientLabel,clientKind:t.clientKind,dedupeKey:t.dedupeKey});if(!o.ok)throw Error(await xn(o,`Passkey sign-in failed.`));return o.json().catch(()=>null)},Dn=async()=>{let e=await a(_n,{method:`GET`,credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return yn;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}},On=async()=>{let e=await a(gn,{method:`GET`,credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(await xn(e,`Could not load passkeys.`));let t=await e.json().catch(()=>null);return Array.isArray(t?.passkeys)?t.passkeys:[]},kn=async e=>{let t=await a(`${gn}/${encodeURIComponent(e)}`,{method:`DELETE`,credentials:`include`,headers:{Accept:`application/json`}});if(!t.ok)throw Error(await xn(t,`Could not remove passkey.`));return t.json().catch(()=>null)},An=async()=>{let e=await bn(vn);if(!e.ok)throw Error(await xn(e,`Could not clear saved authentication.`));try{let{clearAssistantAttachmentCacheAll:e}=await M(async()=>{let{clearAssistantAttachmentCacheAll:e}=await import(`./assistant-attachment-cache-Bzewqov4.js`).then(e=>e.t);return{clearAssistantAttachmentCacheAll:e}},__vite__mapDeps([0,1,2,3,4,5,6,7])),{invalidateRuntimeAuthSession:t}=await M(async()=>{let{invalidateRuntimeAuthSession:e}=await import(`./runtime-auth-C8w0nlKy.js`).then(e=>e.m);return{invalidateRuntimeAuthSession:e}},__vite__mapDeps([2,1]));await e(`auth-reset`),t()}catch{}return e.json().catch(()=>null)};function jn(e){let t=(0,K.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=U(`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,Z.jsx)(`div`,{"data-slot":`card`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Mn(e){let t=(0,K.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=U(`@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,Z.jsx)(`div`,{"data-slot":`card-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Nn(e){let t=(0,K.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=U(`leading-none font-semibold`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`card-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Pn(e){let t=(0,K.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=U(`px-6`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`card-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var Fn=class extends Q.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 me(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,Z.jsx)(`div`,{className:`p-4 flex items-center justify-center min-h-screen`,children:(0,Z.jsxs)(jn,{className:`w-full max-w-md`,children:[(0,Z.jsx)(Mn,{className:`text-center`,children:(0,Z.jsxs)(Nn,{className:`flex items-center justify-center gap-2 text-destructive`,children:[(0,Z.jsx)(G,{name:`error-warning`,className:`h-5 w-5`}),e.title]})}),(0,Z.jsxs)(Pn,{className:`space-y-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground text-center`,children:e.description}),this.state.error&&(0,Z.jsxs)(`details`,{className:`text-xs font-mono bg-muted p-3 rounded`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer hover:bg-interactive-hover/80`,children:e.detailsSummary}),(0,Z.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,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsxs)(_e,{onClick:this.handleReset,variant:`outline`,className:`flex-1`,children:[(0,Z.jsx)(G,{name:`restart`,className:`h-4 w-4 mr-2`}),e.tryAgain]}),(0,Z.jsx)(_e,{onClick:this.handleCopy,variant:`outline`,className:`flex-1`,children:this.state.copied?e.copied:e.copy})]})]})]})}):this.props.children}},In=e=>{let t=(0,K.c)(29),{children:n,fallback:r}=e,{t:i}=he(),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,Z.jsx)(Fn,{fallback:r,strings:m,children:n}),t[25]=n,t[26]=r,t[27]=m,t[28]=h):h=t[28],h},Ln=`__unassigned__`,Rn={mod:`mod`,shift:`shift`,alt:`alt`,option:`alt`,ctrl:`ctrl`,meta:`mod`,cmd:`mod`,command:`mod`},zn={mod:ge()?`⌘`:`Ctrl`,shift:`⇧`,alt:`⌥`,option:`⌥`,ctrl:`⌃`},Bn={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:`-`,"-":`-`},Vn=[`mod`,`ctrl`,`shift`,`alt`],Hn={"{":`[`,"}":`]`,":":`;`,'"':`'`,"<":`,`,">":`.`,"?":`/`,"|":`\\`,"~":"`","!":`1`,"@":`2`,"#":`3`,$:`4`,"%":`5`,"^":`6`,"&":`7`,"*":`8`,"(":`9`,")":`0`};function Un(e){return e.trim().toLowerCase()===Ln}function Wn(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`:Hn[t]??t}var Gn=[{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_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 Kn(e){if(Un(e))return Ln;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=Rn[t];if(i){n.add(i);continue}r=t}return[...Vn.filter(e=>n.has(e)),r].filter(Boolean).join(`+`)}function qn(e){return Un(e)?!0:Jn(e).key.trim().length>0}function Jn(e){if(Un(e))return{modifiers:new Set,key:Ln};let t=Kn(e).split(`+`),n=new Set,r=``;for(let e of t){let t=Rn[e];t?n.add(t):r=e}return{modifiers:n,key:r}}function Yn(e){if(Un(e))return`Unassigned`;let t=Jn(e);if(!t.key&&t.modifiers.size===0)return`Unassigned`;let n=[];for(let e of Vn)t.modifiers.has(e)&&n.push(zn[e]);if(t.key){let e=Bn[t.key.toLowerCase()]||t.key.toUpperCase();n.push(e)}return n.join(` + `)}function Xn(e){return Gn.find(t=>t.id===e)}function Zn(){return Gn.filter(e=>e.customizable===!0)}function Qn(e,t){let n=Xn(e);if(!n)return``;let r=t?.[e];if(typeof r==`string`){if(r.trim().toLowerCase()===`__unassigned__`)return``;let e=Kn(r);if(e===`__unassigned__`)return Ln;if(qn(e))return e}return n.defaultCombo}function $n(e,t){let n=Xn(e);if(!n)return[];let r=Qn(e,t);return r===n.defaultCombo?[n.defaultCombo,...n.defaultAliases??[]]:r?[r]:[]}function er(e){if(Un(e))return!1;let t=Jn(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 tr(e,t){let n=typeof t==`string`?t:t.defaultCombo;if(Un(n))return!1;let r=Jn(n),i=r.modifiers.has(`mod`),a=r.modifiers.has(`shift`),o=r.modifiers.has(`alt`),s=r.modifiers.has(`ctrl`),c=ge()&&d(),l=ge(),u=c?e.metaKey:l&&e.metaKey||e.ctrlKey;if(i&&!u||!i&&e.metaKey||a!==e.shiftKey||o!==e.altKey)return!1;if(s){if(!e.ctrlKey)return!1}else{let t=i&&!c&&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))),Wn(f)===Wn(r.key)}function nr(){return ge()?`⌘`:`Ctrl`}function rr(e,t,n){if(tr(e,n))return!0;let r=Kn(n),i=ge()&&d(),a=ge();return!(i?e.metaKey:a&&e.metaKey||e.ctrlKey)||e.altKey||i&&e.ctrlKey&&!e.metaKey?!1:t===`in`&&r===`mod+=`?e.key===`+`||e.code===`NumpadAdd`:t===`out`&&(r===`mod+-`||r===`mod+minus`)?e.key===`_`||e.code===`NumpadSubtract`:!1}var ir=Q.createContext(null),ar=e=>e?e.closest(`[data-slot="dialog-content"], [role="dialog"]`):null;function or(e,t){return e&&Q.isValidElement(t)?{render:t}:{children:t}}function sr(e){let t=(0,K.c)(9),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let[r,i]=Q.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,Z.jsx)(v,{...n}),t[4]=n,t[5]=s);let c;return t[6]!==o||t[7]!==s?(c=(0,Z.jsx)(ir.Provider,{value:o,children:s}),t[6]=o,t[7]=s,t[8]=c):c=t[8],c}function cr(e){let t=(0,K.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=Q.useContext(ir),c;t[6]===s?c=t[7]:(c=e=>{if(!s)return;let t=e instanceof HTMLElement?e:null;s.setPortalContainer(ar(t))},t[6]=s,t[7]=c);let l=c,u;t[8]!==n||t[9]!==r?(u=or(n,r),t[8]=n,t[9]=r,t[10]=u):u=t[10];let d=u,f;t[11]!==a||t[12]!==l?(f=e=>{l(e.currentTarget),a?.(e)},t[11]=a,t[12]=l,t[13]=f):f=t[13];let p;t[14]!==i||t[15]!==l?(p=e=>{l(e.currentTarget),i?.(e)},t[14]=i,t[15]=l,t[16]=p):p=t[16];let m;return t[17]!==o||t[18]!==d||t[19]!==f||t[20]!==p?(m=(0,Z.jsx)(T,{"data-slot":`dropdown-menu-trigger`,onPointerDownCapture:f,onFocusCapture:p,...o,...d}),t[17]=o,t[18]=d,t[19]=f,t[20]=p,t[21]=m):m=t[21],m}function lr(e){let t=(0,K.c)(40),n,r,i,a,o,s,c,l,u,d,f,p,m;if(t[0]!==e){let{className:h,sideOffset:g,align:_,side:v,alignOffset:y,anchor:b,portalToBody:x,positionerClassName:S,style:C,children:w,onCloseAutoFocus:T,collisionPadding:E,collisionAvoidance:D,...O}=e;o=h,d=g,n=_,l=v,r=y,i=b,f=x,s=S,u=C,a=w,p=E,m=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]=d,t[11]=f,t[12]=p,t[13]=m}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],d=t[10],f=t[11],p=t[12],m=t[13];let h=d===void 0?4:d,g=f!==void 0&&f,_=p===void 0?8:p,v;t[14]===m?v=t[15]:(v=m===void 0?{side:`shift`,align:`shift`}:m,t[14]=m,t[15]=v);let y=v,S=Q.useContext(ir),C=g?void 0:S?.portalContainer||void 0,w;t[16]===s?w=t[17]:(w=U(`app-region-no-drag z-50`,s),t[16]=s,t[17]=w);let T;t[18]===u?T=t[19]:(T={backgroundColor:`var(--surface-elevated)`,color:`var(--surface-elevated-foreground)`,...u},t[18]=u,t[19]=T);let D;t[20]===o?D=t[21]:(D=U(rt,o),t[20]=o,t[21]=D);let O;t[22]!==a||t[23]!==c||t[24]!==T||t[25]!==D?(O=(0,Z.jsx)(x,{"data-slot":`dropdown-menu-content`,style:T,className:D,...c,children:a}),t[22]=a,t[23]=c,t[24]=T,t[25]=D,t[26]=O):O=t[26];let k;t[27]!==n||t[28]!==r||t[29]!==i||t[30]!==y||t[31]!==_||t[32]!==l||t[33]!==h||t[34]!==O||t[35]!==w?(k=(0,Z.jsx)(E,{anchor:i,sideOffset:h,align:n,side:l,alignOffset:r,collisionPadding:_,collisionAvoidance:y,className:w,children:O}),t[27]=n,t[28]=r,t[29]=i,t[30]=y,t[31]=_,t[32]=l,t[33]=h,t[34]=O,t[35]=w,t[36]=k):k=t[36];let A;return t[37]!==k||t[38]!==C?(A=(0,Z.jsx)(b,{container:C,children:k}),t[37]=k,t[38]=C,t[39]=A):A=t[39],A}function ur(e){let t=(0,K.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=or(n,r),t[9]=n,t[10]=r,t[11]=d):d=t[11];let f=d,p;t[12]!==o||t[13]!==s?(p=e=>{o?.(e),e.defaultPrevented||s?.(e)},t[12]=o,t[13]=s,t[14]=p):p=t[14];let m=p,h;t[15]===i?h=t[16]:(h=U(st,i),t[15]=i,t[16]=h);let g;return t[17]!==m||t[18]!==a||t[19]!==c||t[20]!==f||t[21]!==h||t[22]!==u?(g=(0,Z.jsx)(S,{"data-slot":`dropdown-menu-item`,"data-inset":a,"data-variant":u,className:h,...c,onClick:m,...f}),t[17]=m,t[18]=a,t[19]=c,t[20]=f,t[21]=h,t[22]=u,t[23]=g):g=t[23],g}function dr(e){let t=(0,K.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,Z.jsx)(w,{"data-slot":`dropdown-menu-radio-group`,...n}),t[2]=n,t[3]=r),r}function fr(e){let t=(0,K.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=U(`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,Z.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-3.5 items-center justify-center text-primary`,children:(0,Z.jsx)(O,{children:(0,Z.jsx)(G,{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,Z.jsxs)(C,{"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 pr(e){let t=(0,K.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=U(`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,Z.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 mr(e){let t=(0,K.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=U(at,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(y,{"data-slot":`dropdown-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function hr(){let e=(0,K.c)(5),t=W(yr),n=W(vr),r=W(_r),i=W(gr),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 gr(e){return e.providers.length>0}function _r(e){return e.lastDisconnectReason}function vr(e){return e.connectionPhase}function yr(e){return e.isInitialized}var br=e=>{let t=(0,K.c)(41),{agentName:n,onChange:r,className:i,filter:a,dropdownPortalToBody:o,showIcon:s,agents:c}=e,l=o!==void 0&&o,u=s===void 0||s,{t:d}=he(),{isReady:f,isUnavailable:p}=hr(),m=W(xr),h=Te(Sr),g=W(Cr),{data:_}=ke(),v;t[0]===_?v=t[1]:(v=_===void 0?[]:_,t[0]=_,t[1]=v);let y=v,b;bb0:{if(c){b=c;break bb0}if(Array.isArray(m)&&m.length>0){b=m;break bb0}b=y}let x=b,S;if(t[2]!==a||t[3]!==x){let e=Se(x);S=a?e.filter(a):e,t[2]=a,t[3]=x,t[4]=S}else S=t[4];let C=S,w=te(wr),{isMobile:T}=We(),E=w||T,[D,O]=Q.useState(!1),k;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(k=()=>{O(!0),W.getState().refreshCatalogsOnPickerOpen({source:`agentSelector:mobilePanel`})},t[5]=k):k=t[5];let A=pe(k),j=pe(Tr),ee=Q.useId(),ne,M;t[6]!==c||t[7]!==h||t[8]!==g||t[9]!==x.length?(ne=()=>{c||x.length>0||(g(),h())},M=[c,x.length,g,h],t[6]=c,t[7]=h,t[8]=g,t[9]=x.length,t[10]=ne,t[11]=M):(ne=t[10],M=t[11]),Q.useEffect(ne,M);let re;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>O(!1),t[12]=re):re=t[12];let ie=re,ae;t[13]===r?ae=t[14]:(ae=e=>{r(e)},t[13]=r,t[14]=ae);let N=ae,oe;t[15]!==n||t[16]!==C||t[17]!==N||t[18]!==E||t[19]!==D||t[20]!==ee||t[21]!==d?(oe=()=>E?(0,Z.jsx)(Je,{id:`mobile-agent-selector-sheet-${ee}`,open:D,onOpenChange:e=>{e||ie()},ariaLabel:d(`settings.commands.agentSelector.title`),closeAriaLabel:d(`mobile.surface.closeAria`),resizeAriaLabel:d(`mobile.sessions.sheet.resizeAria`),bodyClassName:`px-2`,children:(0,Z.jsxs)(Ye,{useScrollShadow:!0,disableHorizontal:!0,preventOverscroll:!0,outerClassName:`min-h-0 flex-1`,className:`flex flex-col gap-1 overscroll-contain`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:U(`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`,n?`text-foreground`:`bg-primary/10 text-primary`),onClick:()=>{N(``),ie()},children:[(0,Z.jsx)(je,{name:`default`,size:16}),(0,Z.jsx)(`span`,{className:U(`min-w-0 typography-meta`,n?`text-muted-foreground`:`font-medium`),children:d(`settings.commands.agentSelector.notSelected`)}),!n&&(0,Z.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-primary`})]}),C.map(e=>{let t=e.name===n;return(0,Z.jsxs)(`button`,{type:`button`,className:U(`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:()=>{N(e.name),ie()},children:[(0,Z.jsx)(je,{name:e.name,size:16,className:`mt-1.5`}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`typography-meta font-medium`,children:e.name}),e.description&&(0,Z.jsx)(`span`,{className:`mt-0.5 block whitespace-normal break-words typography-micro text-muted-foreground`,children:e.description})]}),t&&(0,Z.jsx)(`div`,{className:`mt-2 h-2 w-2 rounded-full bg-primary`})]},e.name)})]})}):null,t[15]=n,t[16]=C,t[17]=N,t[18]=E,t[19]=D,t[20]=ee,t[21]=d,t[22]=oe):oe=t[22];let P=oe,F;t[23]!==n||t[24]!==C||t[25]!==i||t[26]!==l||t[27]!==N||t[28]!==j||t[29]!==E||t[30]!==f||t[31]!==p||t[32]!==A||t[33]!==u||t[34]!==d?(F=E?(0,Z.jsxs)(`button`,{type:`button`,onClick:f?A:void 0,disabled:!f,className:U(`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`,!f&&`opacity-60 cursor-not-allowed`,i),children:[(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:f?(0,Z.jsxs)(Z.Fragment,{children:[u?(0,Z.jsx)(je,{name:n||`default`,size:14}):null,(0,Z.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:n||d(`settings.commands.agentSelector.selectAgentPlaceholder`)})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(G,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:d(p?`common.unavailable`:`common.loading`)})]})}),(0,Z.jsx)(G,{name:`arrow-down-s`,className:`h-3 w-3 text-muted-foreground`})]}):f?(0,Z.jsxs)(sr,{onOpenChange:j,children:[(0,Z.jsx)(cr,{asChild:!0,children:(0,Z.jsxs)(`div`,{className:U(`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`,i),children:[u?(0,Z.jsx)(je,{name:n||`default`,size:14}):null,(0,Z.jsx)(`span`,{className:`typography-micro font-medium whitespace-nowrap`,children:n||d(`settings.commands.agentSelector.notSelected`)}),(0,Z.jsx)(G,{name:`arrow-down-s`,className:`h-3 w-3 flex-shrink-0 text-muted-foreground`})]})}),(0,Z.jsxs)(lr,{className:`max-w-[300px]`,portalToBody:l,children:[(0,Z.jsxs)(ur,{className:`typography-meta`,onSelect:()=>N(``),children:[(0,Z.jsx)(je,{name:`default`,size:14}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:d(`settings.commands.agentSelector.notSelected`)})]}),C.map(e=>(0,Z.jsxs)(ur,{className:`typography-meta`,onSelect:()=>N(e.name),children:[(0,Z.jsx)(je,{name:e.name,size:14}),(0,Z.jsx)(`span`,{className:`font-medium`,children:e.name})]},e.name))]})]}):(0,Z.jsxs)(`div`,{className:U(`flex items-center gap-2 px-2 rounded-lg bg-interactive-selection/20 border border-border/20 h-6 w-fit opacity-60`,i),children:[(0,Z.jsx)(G,{name:`loader-4`,className:`h-3 w-3 animate-spin text-muted-foreground flex-shrink-0`}),(0,Z.jsx)(`span`,{className:`typography-micro font-medium whitespace-nowrap text-muted-foreground`,children:d(p?`common.unavailable`:`common.loading`)})]}),t[23]=n,t[24]=C,t[25]=i,t[26]=l,t[27]=N,t[28]=j,t[29]=E,t[30]=f,t[31]=p,t[32]=A,t[33]=u,t[34]=d,t[35]=F):F=t[35];let I;t[36]===P?I=t[37]:(I=P(),t[36]=P,t[37]=I);let se;return t[38]!==F||t[39]!==I?(se=(0,Z.jsxs)(Z.Fragment,{children:[F,I]}),t[38]=F,t[39]=I,t[40]=se):se=t[40],se};function xr(e){return e.agents}function Sr(e){return e.loadAgents}function Cr(e){return e.loadAgents}function wr(e){return e.isMobile}function Tr(e){e&&W.getState().refreshCatalogsOnPickerOpen({source:`agentSelector:desktopMenu`})}var Er={compact:{notation:`compact`,compactDisplay:`short`,maximumFractionDigits:1,minimumFractionDigits:0},compactTokensShort:{notation:`compact`,compactDisplay:`short`,maximumFractionDigits:1},usd:{style:`currency`,currency:`USD`,maximumFractionDigits:4,minimumFractionDigits:2}},Dr=null,Or={},kr=(e,t)=>{Dr!==t&&(Dr=t,Or.compact=void 0,Or.compactTokensShort=void 0,Or.usd=void 0);let n=Or[e];if(n)return n;let r=new Intl.NumberFormat(t,Er[e]);return Or[e]=r,r},Ar=(e,t=H())=>kr(`compact`,t).format(e),jr=(e,t=H())=>kr(`compactTokensShort`,t).format(e),Mr=(e,t=H())=>kr(`usd`,t).format(e),Nr=(e,t=H())=>e.toLocaleDateString(t,{month:`short`,day:`numeric`,year:`numeric`}),Pr=(e,t=H())=>new Date(e).toLocaleDateString(t,{year:`numeric`,month:`short`,day:`numeric`}),Fr=(e,t=H())=>new Date(e).toLocaleTimeString(t,{hour:`numeric`,minute:`2-digit`}),Ir=8,Lr=e=>typeof e!=`number`||Number.isNaN(e)?``:jr(e),Rr=(e,t,n)=>{let r=e.find(e=>e.id===t)?.models?.find(e=>e.id===n);return r?.variants?Object.keys(r.variants):[]},zr=e=>{let t=(0,K.c)(54),{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}=he(),T=Q.useId(),[E,D]=Q.useState(``),O;t[2]===i?O=t[3]:(O=()=>new Set(i?[i]:[]),t[2]=i,t[3]=O);let[k,A]=Q.useState(O),[j,ee]=Q.useState(null),[te,ne]=Q.useState(`model`),[M,re]=Q.useState(null),ie=Q.useRef(!1),ae=y??te,N,oe;t[4]!==n||t[5]!==i?(N=()=>{n&&!ie.current&&A(new Set(i?[i]:[])),n||(D(``),ee(null),ne(`model`),re(null)),ie.current=n},oe=[n,i],t[4]=n,t[5]=i,t[6]=N,t[7]=oe):(N=t[6],oe=t[7]),Q.useEffect(N,oe);let P;t[8]===b?P=t[9]:(P=e=>{ne(e),b?.(e)},t[8]=b,t[9]=P);let F=P,I=ae===`variant`&&!!(M??(i&&a)),se=`mobile-model-picker-sheet-${T}`,L;t[10]===r?L=t[11]:(L=e=>{e||r()},t[10]=r,t[11]=L);let ce;t[12]!==I||t[13]!==F||t[14]!==w?(ce=I?(0,Z.jsx)(_e,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>F(`model`),"aria-label":w(`onboarding.common.actions.back`),children:(0,Z.jsx)(G,{name:`arrow-left`,className:`size-5`})}):void 0,t[12]=I,t[13]=F,t[14]=w,t[15]=ce):ce=t[15];let R;t[16]!==I||t[17]!==w?(R=w(I?`chat.modelControls.thinking`:`chat.modelControls.selectModel`),t[16]=I,t[17]=w,t[18]=R):R=t[18];let z;t[19]===w?z=t[20]:(z=w(`mobile.surface.closeAria`),t[19]=w,t[20]=z);let B;t[21]===w?B=t[22]:(B=w(`mobile.sessions.sheet.resizeAria`),t[21]=w,t[22]=B);let V;t[23]!==ae||t[24]!==p||t[25]!==f||t[26]!==j||t[27]!==k||t[28]!==l||t[29]!==v||t[30]!==S||t[31]!==g||t[32]!==s||t[33]!==_||t[34]!==m||t[35]!==c||t[36]!==E||t[37]!==u||t[38]!==o||t[39]!==a||t[40]!==i||t[41]!==F||t[42]!==C||t[43]!==M?(V=(0,Z.jsx)(Br,{query:E,onQueryChange:D,expandedProviders:k,onExpandedProvidersChange:A,expandedModelKey:j,onExpandedModelKeyChange:ee,activeView:ae,setView:F,variantTarget:M,onVariantTargetChange:re,selectedProviderID:i,selectedModelID:a,resolveSelectedVariant:o,onSelect:s,providers:c,favoriteModels:l,recentModels:u,hiddenModels:S,allowedProviderIds:f,allowedModelIdsByProvider:p,providerOrder:m,variantSelectionEnabled:C,isFavorite:g,onToggleFavorite:_,getMetadata:v}),t[23]=ae,t[24]=p,t[25]=f,t[26]=j,t[27]=k,t[28]=l,t[29]=v,t[30]=S,t[31]=g,t[32]=s,t[33]=_,t[34]=m,t[35]=c,t[36]=E,t[37]=u,t[38]=o,t[39]=a,t[40]=i,t[41]=F,t[42]=C,t[43]=M,t[44]=V):V=t[44];let le;return t[45]!==n||t[46]!==ce||t[47]!==R||t[48]!==z||t[49]!==B||t[50]!==V||t[51]!==se||t[52]!==L?(le=(0,Z.jsx)(Je,{id:se,open:n,onOpenChange:L,leading:ce,ariaLabel:R,closeAriaLabel:z,resizeAriaLabel:B,bodyClassName:`px-2`,children:V}),t[45]=n,t[46]=ce,t[47]=R,t[48]=z,t[49]=B,t[50]=V,t[51]=se,t[52]=L,t[53]=le):le=t[53],le},Br=e=>{let t=(0,K.c)(117),{query:n,onQueryChange:r,expandedProviders:i,onExpandedProvidersChange:a,expandedModelKey:o,onExpandedModelKeyChange:s,activeView:c,setView:l,variantTarget:u,onVariantTargetChange:d,selectedProviderID:f,selectedModelID:p,resolveSelectedVariant:m,onSelect:h,providers:g,favoriteModels:_,recentModels:v,hiddenModels:y,allowedProviderIds:b,allowedModelIdsByProvider:x,providerOrder:S,variantSelectionEnabled:C,isFavorite:w,onToggleFavorite:T,getMetadata:E}=e,{t:D}=he(),O;t[0]===b?O=t[1]:(O=b&&b.length>0?new Set(b):null,t[0]=b,t[1]=O);let k=O,A;t[2]===x?A=t[3]:(A=x?new Map(Object.entries(x).map(Vr)):null,t[2]=x,t[3]=A);let j=A,ee;t[4]===y?ee=t[5]:(ee=new Set(y.map(Hr)),t[4]=y,t[5]=ee);let te=ee,ne;t[6]===g?ne=t[7]:(ne=new Map(g.map(Ur)),t[6]=g,t[7]=ne);let M=ne,re;bb0:{if(!S?.length){re=g;break bb0}let e;t[8]===S?e=t[9]:(e=new Map(S.map(Wr)),t[8]=S,t[9]=e);let n=e,r;if(t[10]!==g||t[11]!==n){let e;t[13]===n?e=t[14]:(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[13]=n,t[14]=e),r=[...g].sort(e),t[10]=g,t[11]=n,t[12]=r}else r=t[12];re=r}let ie=re,ae;t[15]!==j||t[16]!==k||t[17]!==te?(ae=(e,t)=>k&&!k.has(e)||j&&j.get(e)?.has(t)!==!0?!1:!te.has(`${e}:${t}`),t[15]=j,t[16]=k,t[17]=te,t[18]=ae):ae=t[18];let N=ae,oe;t[19]!==M||t[20]!==n?(oe=e=>{let t=n.trim();if(!t)return!0;let r=M.get(e.providerID)?.name||e.providerID,i=Ce(e.model,e.modelID,{maxLength:40});return Le(i,t)||Le(e.modelID,t)||Le(r,t)},t[19]=M,t[20]=n,t[21]=oe):oe=t[21];let P=oe,F;if(t[22]!==_||t[23]!==N||t[24]!==P){let e;t[26]!==N||t[27]!==P?(e=e=>N(e.providerID,e.modelID)&&P(e),t[26]=N,t[27]=P,t[28]=e):e=t[28],F=_.filter(e),t[22]=_,t[23]=N,t[24]=P,t[25]=F}else F=t[25];let I=F,se;if(t[29]!==N||t[30]!==P||t[31]!==v){let e;t[33]!==N||t[34]!==P?(e=e=>N(e.providerID,e.modelID)&&P(e),t[33]=N,t[34]=P,t[35]=e):e=t[35],se=v.filter(e),t[29]=N,t[30]=P,t[31]=v,t[32]=se}else se=t[32];let L=se,ce;if(t[36]!==k||t[37]!==N||t[38]!==ie||t[39]!==n){let e=n.trim(),r;t[41]===k?r=t[42]:(r=e=>!k||k.has(e.id),t[41]=k,t[42]=r),ce=ie.filter(r).map(t=>{let n=e.length>0&&(Le(t.name||t.id,e)||Le(t.id,e));return{provider:t,models:(t.models??[]).filter(r=>{let i=typeof r.id==`string`?r.id:``;return!i||!N(t.id,i)?!1:n||!e?!0:Le(Ce(r,i,{maxLength:40}),e)||Le(i,e)})}}).filter(Gr),t[36]=k,t[37]=N,t[38]=ie,t[39]=n,t[40]=ce}else ce=t[40];let R=ce,z;t[43]===D?z=t[44]:(z=e=>{if(!e?.trim())return D(`chat.modelControls.default`);let t=e.trim();return/^\d+(\.\d+)?$/.test(t)?t:t.charAt(0).toUpperCase()+t.slice(1)},t[43]=D,t[44]=z);let B=z,V;t[45]===D?V=t[46]:(V=e=>{let t=[];e?.tool_call&&t.push({key:`tool_call`,icon:`tools`,label:D(`chat.modelControls.capability.toolCalling`)}),e?.reasoning&&t.push({key:`reasoning`,icon:`brain-ai-3`,label:D(`chat.modelControls.capability.reasoning`)});let n={text:{icon:`text`,label:D(`chat.modelControls.modality.text`)},image:{icon:`file-image`,label:D(`chat.modelControls.modality.image`)},video:{icon:`file-video`,label:D(`chat.modelControls.modality.video`)},audio:{icon:`file-music`,label:D(`chat.modelControls.modality.audio`)},pdf:{icon:`file-pdf`,label:D(`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[45]=D,t[46]=V);let le=V,ue;t[47]!==d||t[48]!==l?(ue=(e,t,n)=>{d(n===void 0?{providerID:e,modelID:t}:{providerID:e,modelID:t,variant:n}),l(`variant`)},t[47]=d,t[48]=l,t[49]=ue):ue=t[49];let de=ue,fe;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(fe={onPointerDown:Ke,onClickCapture:Kr},t[50]=fe):fe=t[50];let pe=fe,me;t[51]!==o||t[52]!==B||t[53]!==E||t[54]!==le||t[55]!==w||t[56]!==s||t[57]!==h||t[58]!==T||t[59]!==de||t[60]!==M||t[61]!==g||t[62]!==m||t[63]!==p||t[64]!==f||t[65]!==D||t[66]!==C?(me=(e,t)=>{let n=t===void 0?{}:t,{model:r,providerID:i,modelID:a}=e,c=`${i}:${a}`,l=i===f&&a===p,u=He(i,r,E?.(i,a)),d=C?Rr(g,i,a):[],_=m(i,a),v=n.preferRememberedVariant&&e.variant!==void 0&&d.includes(e.variant)?e.variant:void 0,y=v===void 0?_:v,b=l||v===void 0?_:v,x=[void 0,...d].slice(0,Ir),S=o===c,O=le(u),k=u?.limit?.context?`${Lr(u.limit.context)} ctx`:null;return(0,Z.jsxs)(`div`,{className:U(`border-b border-border/30 last:border-b-0`,l&&`bg-interactive-selection/15 text-interactive-selection-foreground`),children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[(0,Z.jsx)(`button`,{type:`button`,...pe,onClick:()=>h(i,a,y),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,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[n.showProvider?(0,Z.jsx)(`span`,{className:`truncate text-[10px] leading-none text-muted-foreground/60`,children:M.get(i)?.name||i}):null,(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Z.jsx)(ze,{modelId:a,providerId:i,className:`size-3.5 flex-shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate typography-meta font-medium text-foreground`,children:Ce(r,a,{maxLength:40})}),l?(0,Z.jsx)(G,{name:`check`,className:`size-4 flex-shrink-0 text-primary`}):null]}),k||O.length>0?(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 overflow-hidden typography-micro text-muted-foreground`,children:[k?(0,Z.jsx)(`span`,{className:`flex-shrink-0 whitespace-nowrap`,children:k}):null,k&&O.length>0?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-px flex-shrink-0 bg-border/50`}):null,(0,Z.jsx)(`div`,{className:`flex min-w-0 items-center gap-1 overflow-hidden whitespace-nowrap pl-0.5`,children:O.map(e=>{let{key:t,icon:n,label:r}=e;return(0,Z.jsx)(`span`,{className:`flex size-4 flex-shrink-0 items-center justify-center text-muted-foreground`,title:r,"aria-label":r,children:(0,Z.jsx)(G,{name:n,className:`size-3`})},`${c}-${t}`)})})]}):null]})}),d.length>0?(0,Z.jsxs)(`button`,{type:`button`,...pe,onClick:()=>s(e=>e===c?null:c),className:`flex flex-shrink-0 items-center gap-0.5 typography-micro font-medium text-muted-foreground hover:text-foreground`,"aria-expanded":S,"aria-label":D(S?`chat.modelControls.hideThinkingModes`:`chat.modelControls.showThinkingModes`),children:[(0,Z.jsx)(`span`,{className:`whitespace-nowrap`,children:B(b)}),(0,Z.jsx)(G,{name:S?`arrow-down-s`:`arrow-right-s`,className:`size-3.5`})]}):null,(0,Z.jsx)(`button`,{type:`button`,...pe,onClick:e=>{e.preventDefault(),e.stopPropagation(),T(i,a)},className:U(`model-favorite-button flex size-5 flex-shrink-0 items-center justify-center hover:text-primary/80`,w(i,a)?`text-primary`:`text-muted-foreground`),"aria-label":w(i,a)?D(`chat.modelControls.unfavoriteAria`):D(`chat.modelControls.favoriteAria`),title:w(i,a)?D(`chat.modelControls.removeFromFavorites`):D(`chat.modelControls.addToFavorites`),children:(0,Z.jsx)(G,{name:w(i,a)?`star-fill`:`star`,className:`size-4`})})]}),S&&d.length>0?(0,Z.jsx)(`div`,{className:`border-t border-border/30 p-2`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[x.map(e=>{let t=e===b||!e&&!b;return(0,Z.jsx)(`button`,{type:`button`,...pe,onClick:()=>h(i,a,e),className:U(`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:B(e)},`${c}-${e??`default`}`)}),x.length<d.length+1?(0,Z.jsx)(`button`,{type:`button`,...pe,onClick:()=>de(i,a,b),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":D(`chat.modelControls.moreThinkingModes`),children:D(`inlineComment.actions.showMore`)}):null]})}):null]},`mobile-model-${c}`)},t[51]=o,t[52]=B,t[53]=E,t[54]=le,t[55]=w,t[56]=s,t[57]=h,t[58]=T,t[59]=de,t[60]=M,t[61]=g,t[62]=m,t[63]=p,t[64]=f,t[65]=D,t[66]=C,t[67]=me):me=t[67];let ge=me,H,_e,ve,ye,be,xe,Se,we,Te,W;if(t[68]!==c||t[69]!==i||t[70]!==I||t[71]!==R||t[72]!==L||t[73]!==B||t[74]!==s||t[75]!==a||t[76]!==r||t[77]!==h||t[78]!==g||t[79]!==n||t[80]!==ge||t[81]!==m||t[82]!==p||t[83]!==f||t[84]!==D||t[85]!==u){let e=u??(c===`variant`&&f&&p?{providerID:f,modelID:p}:null),o=e?Rr(g,e.providerID,e.modelID):[],l;bb1:{if(!e){l=void 0;break bb1}if(e.providerID===f&&e.modelID===p){l=m(e.providerID,e.modelID);break bb1}l=(e.variant!==void 0&&o.includes(e.variant)?e.variant:void 0)??m(e.providerID,e.modelID)}let d=l,_=I.length>0||L.length>0||R.length>0,v=c===`variant`&&!!e;Te=`flex min-h-0 flex-1 flex-col gap-2`,t[96]!==v||t[97]!==s||t[98]!==r||t[99]!==n||t[100]!==D?(W=v?null:(0,Z.jsxs)(`div`,{className:`relative z-10 shrink-0`,"data-mobile-sheet-no-dismiss":``,"data-mobile-sheet-search":``,children:[(0,Z.jsx)(G,{name:`search`,className:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,Z.jsx)(Ue,{type:`text`,value:n,onChange:e=>{r(e.target.value),s(null)},placeholder:D(`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`}),n?(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{r(``),s(null)},className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,"aria-label":D(`chat.modelControls.clearSearch`),children:(0,Z.jsx)(G,{name:`close-circle`,className:`size-4`})}):null]}),t[96]=v,t[97]=s,t[98]=r,t[99]=n,t[100]=D,t[101]=W):W=t[101],H=Ye,ye=!0,be=!0,xe=!0,Se=`min-h-0 flex-1`,we=`overscroll-contain`,_e=`flex flex-col gap-2`,ve=v&&e?(0,Z.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:[void 0,...o].map(t=>{let n=t===d||!t&&!d;return(0,Z.jsxs)(`button`,{type:`button`,className:U(`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`),...pe,onClick:()=>h(e.providerID,e.modelID,t),children:[(0,Z.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:B(t)}),n?(0,Z.jsx)(G,{name:`check`,className:`size-4 flex-shrink-0 text-primary`}):null]},t??`default`)})}):(0,Z.jsxs)(Z.Fragment,{children:[_?null:(0,Z.jsx)(`div`,{className:`px-3 py-8 text-center typography-meta text-muted-foreground`,children:D(`chat.modelControls.noProvidersOrModelsFound`)}),I.length>0?(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border/40 bg-[var(--surface-elevated)]`,children:[(0,Z.jsxs)(`div`,{className:`px-2 py-1.5 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,Z.jsx)(G,{name:`star-fill`,className:`mr-1.5 inline-block size-3 text-primary`}),D(`chat.modelControls.favorites`)]}),(0,Z.jsx)(`div`,{className:`flex flex-col border-t border-border/30`,children:I.map(e=>ge(e,{showProvider:!0,preferRememberedVariant:!0}))})]}):null,L.length>0?(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border/40 bg-[var(--surface-elevated)]`,children:[(0,Z.jsxs)(`div`,{className:`px-2 py-1.5 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,Z.jsx)(G,{name:`time`,className:`mr-1.5 inline-block size-3`}),D(`chat.modelControls.recent`)]}),(0,Z.jsx)(`div`,{className:`flex flex-col border-t border-border/30`,children:L.map(e=>ge(e,{showProvider:!0,preferRememberedVariant:!0}))})]}):null,R.map(e=>{let{provider:t,models:r}=e,o=i.has(t.id)||n.trim().length>0;return(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border/40 bg-[var(--surface-elevated)]`,children:[(0,Z.jsxs)(`button`,{type:`button`,...pe,onClick:()=>{n.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":o,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Ve,{providerId:t.id,className:`size-3.5`}),(0,Z.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:t.name||t.id}),t.id===f?(0,Z.jsx)(`span`,{className:`typography-micro text-primary/80`,children:D(`chat.modelControls.current`)}):null]}),(0,Z.jsx)(G,{name:o?`arrow-down-s`:`arrow-right-s`,className:`size-3 text-muted-foreground`})]}),o?(0,Z.jsx)(`div`,{className:`flex flex-col border-t border-border/30`,children:r.map(e=>ge({model:e,providerID:t.id,modelID:e.id}))}):null]},t.id)})]}),t[68]=c,t[69]=i,t[70]=I,t[71]=R,t[72]=L,t[73]=B,t[74]=s,t[75]=a,t[76]=r,t[77]=h,t[78]=g,t[79]=n,t[80]=ge,t[81]=m,t[82]=p,t[83]=f,t[84]=D,t[85]=u,t[86]=H,t[87]=_e,t[88]=ve,t[89]=ye,t[90]=be,t[91]=xe,t[92]=Se,t[93]=we,t[94]=Te,t[95]=W}else H=t[86],_e=t[87],ve=t[88],ye=t[89],be=t[90],xe=t[91],Se=t[92],we=t[93],Te=t[94],W=t[95];let Ee;t[102]!==_e||t[103]!==ve?(Ee=(0,Z.jsx)(`div`,{className:_e,children:ve}),t[102]=_e,t[103]=ve,t[104]=Ee):Ee=t[104];let De;t[105]!==H||t[106]!==ye||t[107]!==be||t[108]!==xe||t[109]!==Se||t[110]!==we||t[111]!==Ee?(De=(0,Z.jsx)(H,{useScrollShadow:ye,disableHorizontal:be,preventOverscroll:xe,outerClassName:Se,className:we,children:Ee}),t[105]=H,t[106]=ye,t[107]=be,t[108]=xe,t[109]=Se,t[110]=we,t[111]=Ee,t[112]=De):De=t[112];let Oe;return t[113]!==Te||t[114]!==W||t[115]!==De?(Oe=(0,Z.jsxs)(`div`,{className:Te,children:[W,De]}),t[113]=Te,t[114]=W,t[115]=De,t[116]=Oe):Oe=t[116],Oe};function Vr(e){let[t,n]=e;return[t,new Set(n)]}function Hr(e){return`${e.providerID}:${e.modelID}`}function Ur(e){return[e.id,e]}function Wr(e,t){return[e,t]}function Gr(e){return e.models.length>0}function Kr(e){qe(e)||(e.preventDefault(),e.stopPropagation())}var qr=e=>{let t=(0,K.c)(217),{providerId:n,modelId:r,variant:i,onChange:a,className:o,allowedProviderIds:s,allowedModelIdsByProvider:c,placeholder:l,tooltipsEnabled:u,dropdownPortalToBody:d,showIcon:f,providers:p}=e,m=u===void 0||u,h=d!==void 0&&d,g=f===void 0||f,{t:_}=he(),{isReady:v,isUnavailable:y}=hr(),b=W(Jr),x=p??b,S=W(Yr),C=te(Xr),w=te(Zr),T=te(Qr),E=te($r),D=te(ei),O=te(ti),k;t[0]!==r||t[1]!==n?(k={currentProviderID:n,currentModelID:r},t[0]=r,t[1]=n,t[2]=k):k=t[2];let{favoriteModelsList:A,recentModelsList:j}=Re(k),{isMobile:ee}=We(),ne=C||ee,[M,re]=Q.useState(!1),[ie,ae]=Q.useState(!1),N;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(N=()=>{re(!0),W.getState().refreshCatalogsOnPickerOpen({source:`modelSelector:mobilePanel`})},t[3]=N):N=t[3];let oe=pe(N),P;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(P=e=>{ae(e),e&&W.getState().refreshCatalogsOnPickerOpen({source:`modelSelector:desktopMenu`})},t[4]=P):P=t[4];let F=pe(P),[I,se]=Q.useState(``),[L,ce]=Q.useState(null),R=i!==void 0,z;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(z=()=>{re(!1),ae(!1),se(``),ce(null)},t[5]=z):z=t[5];let B=z,V;t[6]===x?V=t[7]:(V=e=>{let t=x.find(t=>t.id===e.providerID)?.models?.find(t=>t.id===e.modelID);return t?.variants?Object.keys(t.variants):[]},t[6]=x,t[7]=V);let le=V,ue;t[8]!==D||t[9]!==le||t[10]!==r||t[11]!==a||t[12]!==n||t[13]!==i||t[14]!==R?(ue=e=>{let t=le(e),o=e.providerID===n&&e.modelID===r,s=e.variant!==void 0&&t.includes(e.variant)?e.variant:void 0,c=o&&i&&t.includes(i)?i:s??``;a(e.providerID,e.modelID,R?c:void 0),D(e.providerID,e.modelID,R&&c||void 0),B()},t[8]=D,t[9]=le,t[10]=r,t[11]=a,t[12]=n,t[13]=i,t[14]=R,t[15]=ue):ue=t[15];let de=ue,fe;t[16]!==a||t[17]!==R?(fe=()=>{a(``,``,R?``:void 0),B()},t[16]=a,t[17]=R,t[18]=fe):fe=t[18];let me=fe,ge;t[19]!==D||t[20]!==a||t[21]!==L?(ge=e=>{L&&(a(L.providerID,L.modelID,e),D(L.providerID,L.modelID,e||void 0),B())},t[19]=D,t[20]=a,t[21]=L,t[22]=ge):ge=t[22];let H=ge,_e;t[23]===_?_e=t[24]:(_e=_(`settings.agents.modelSelector.searchPlaceholder`),t[23]=_,t[24]=_e);let ve;t[25]===_?ve=t[26]:(ve=_(`settings.agents.modelSelector.state.noModelsFound`),t[25]=_,t[26]=ve);let ye;t[27]===_?ye=t[28]:(ye=_(`settings.agents.modelSelector.section.favorites`),t[27]=_,t[28]=ye);let be;t[29]===_?be=t[30]:(be=_(`settings.agents.modelSelector.section.recent`),t[29]=_,t[30]=be);let xe;t[31]===_?xe=t[32]:(xe=_(`settings.agents.modelSelector.keyboardHints`),t[31]=_,t[32]=xe);let Se;t[33]!==l||t[34]!==_?(Se=l||_(`settings.agents.modelSelector.notSelected`),t[33]=l,t[34]=_,t[35]=Se):Se=t[35];let Ce;t[36]===_?Ce=t[37]:(Ce=_(`settings.agents.modelSelector.actions.favorite`),t[36]=_,t[37]=Ce);let we;t[38]===_?we=t[39]:(we=_(`settings.agents.modelSelector.actions.unfavorite`),t[38]=_,t[39]=we);let Te;t[40]===_?Te=t[41]:(Te=_(`chat.modelControls.provider`),t[40]=_,t[41]=Te);let Ee;t[42]===_?Ee=t[43]:(Ee=_(`chat.modelControls.capabilities`),t[42]=_,t[43]=Ee);let De;t[44]===_?De=t[45]:(De=_(`chat.modelControls.capability.toolCalling`),t[44]=_,t[45]=De);let Oe;t[46]===_?Oe=t[47]:(Oe=_(`chat.modelControls.capability.reasoning`),t[46]=_,t[47]=Oe);let ke;t[48]===_?ke=t[49]:(ke=_(`chat.modelControls.modality.image`),t[48]=_,t[49]=ke);let Ae;t[50]===_?Ae=t[51]:(Ae=_(`chat.modelControls.modality.video`),t[50]=_,t[51]=Ae);let je;t[52]===_?je=t[53]:(je=_(`chat.modelControls.modality.audio`),t[52]=_,t[53]=je);let Me;t[54]===_?Me=t[55]:(Me=_(`chat.modelControls.costPerMillion`),t[54]=_,t[55]=Me);let Ne;t[56]===_?Ne=t[57]:(Ne=_(`chat.modelControls.costInput`),t[56]=_,t[57]=Ne);let Pe;t[58]===_?Pe=t[59]:(Pe=_(`chat.modelControls.costOutput`),t[58]=_,t[59]=Pe);let Fe;t[60]!==_e||t[61]!==ve||t[62]!==ye||t[63]!==be||t[64]!==xe||t[65]!==Se||t[66]!==Ce||t[67]!==we||t[68]!==Te||t[69]!==Ee||t[70]!==De||t[71]!==Oe||t[72]!==ke||t[73]!==Ae||t[74]!==je||t[75]!==Me||t[76]!==Ne||t[77]!==Pe?(Fe={searchPlaceholder:_e,noResults:ve,favorites:ye,recent:be,keyboardHint:xe,notSelected:Se,favorite:Ce,unfavorite:we,provider:Te,capabilities:Ee,capabilityToolCalling:De,capabilityReasoning:Oe,modalityImage:ke,modalityVideo:Ae,modalityAudio:je,costPerMillion:Me,costInput:Ne,costOutput:Pe},t[60]=_e,t[61]=ve,t[62]=ye,t[63]=be,t[64]=xe,t[65]=Se,t[66]=Ce,t[67]=we,t[68]=Te,t[69]=Ee,t[70]=De,t[71]=Oe,t[72]=ke,t[73]=Ae,t[74]=je,t[75]=Me,t[76]=Ne,t[77]=Pe,t[78]=Fe):Fe=t[78];let Ie=Fe,Le;t[79]!==r||t[80]!==n?(Le=n&&r?{providerID:n,modelID:r}:null,t[79]=r,t[80]=n,t[81]=Le):Le=t[81];let Ve=Le,He;t[82]!==r||t[83]!==l||t[84]!==n||t[85]!==_?(He=n&&r?`${n}/${r}`:l||_(`settings.agents.modelSelector.notSelected`),t[82]=r,t[83]=l,t[84]=n,t[85]=_,t[86]=He):He=t[86];let Ue=He,Ge;t[87]!==_||t[88]!==i||t[89]!==R?(Ge=R?i||_(`chat.modelControls.default`):null,t[87]=_,t[88]=i,t[89]=R,t[90]=Ge):Ge=t[90];let Ke=Ge,qe;t[91]!==r||t[92]!==n||t[93]!==i||t[94]!==R?(qe=(e,t)=>{if(!(!R||e!==n||t!==r))return i||void 0},t[91]=r,t[92]=n,t[93]=i,t[94]=R,t[95]=qe):qe=t[95];let Je=qe,Ye;t[96]!==D||t[97]!==a||t[98]!==R?(Ye=(e,t,n)=>{a(e,t,R?n??``:void 0),D(e,t,R&&n||void 0),B()},t[96]=D,t[97]=a,t[98]=R,t[99]=Ye):Ye=t[99];let Xe=Ye,Ze;t[100]!==le||t[101]!==_||t[102]!==i||t[103]!==R?(Ze=(e,t)=>{let n=le(e);if(!R||n.length===0)return null;let r=e.variant!==void 0&&n.includes(e.variant)?e.variant:void 0,a=t.isSelected?i:r??``;return(0,Z.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(),ce(e)},"aria-label":_(`chat.modelControls.showThinkingModes`),children:[(0,Z.jsx)(`span`,{className:`max-w-24 truncate`,children:a||_(`chat.modelControls.default`)}),(0,Z.jsx)(G,{name:`arrow-right-s`,className:`size-3.5`})]})},t[100]=le,t[101]=_,t[102]=i,t[103]=R,t[104]=Ze):Ze=t[104];let Qe=Ze,$e=ne?`max-h-none flex-1`:void 0,et=m&&(ne?M:ie),tt;t[105]===E?tt=t[106]:(tt=e=>E(e.providerID,e.modelID),t[105]=E,t[106]=tt);let nt;t[107]!==r||t[108]!==n||t[109]!==T||t[110]!==i?(nt=e=>T(e.providerID,e.modelID,e.providerID===n&&e.modelID===r?i||void 0:e.variant),t[107]=r,t[108]=n,t[109]=T,t[110]=i,t[111]=nt):nt=t[111];let rt;t[112]!==c||t[113]!==s||t[114]!==A||t[115]!==S||t[116]!==de||t[117]!==me||t[118]!==w||t[119]!==Ie||t[120]!==O||t[121]!==x||t[122]!==j||t[123]!==Qe||t[124]!==I||t[125]!==Ve||t[126]!==$e||t[127]!==et||t[128]!==tt||t[129]!==nt?(rt=(0,Z.jsx)(Be,{providers:x,providerOrder:O,favoriteModels:A,recentModels:j,getMetadata:S,searchQuery:I,onSearchQueryChange:se,onSelect:de,labels:Ie,selectedModel:Ve,hiddenModels:w,allowedProviderIds:s,allowedModelIdsByProvider:c,includeNotSelected:!0,onSelectNone:me,onEscape:B,maxHeightClassName:$e,tooltipsEnabled:et,isFavorite:tt,onToggleFavorite:nt,renderRowEnd:Qe}),t[112]=c,t[113]=s,t[114]=A,t[115]=S,t[116]=de,t[117]=me,t[118]=w,t[119]=Ie,t[120]=O,t[121]=x,t[122]=j,t[123]=Qe,t[124]=I,t[125]=Ve,t[126]=$e,t[127]=et,t[128]=tt,t[129]=nt,t[130]=rt):rt=t[130];let it=rt,at;t[131]!==le||t[132]!==L?(at=L?le(L):[],t[131]=le,t[132]=L,t[133]=at):at=t[133];let ot=at,st;bb0:{if(!L){st=``;break bb0}if(L.providerID===n&&L.modelID===r){st=i||``;break bb0}st=L.variant!==void 0&&ot.includes(L.variant)?L.variant:``}let ct=st,lt;t[134]!==H||t[135]!==_||t[136]!==L||t[137]!==ct||t[138]!==ot?(lt=L?(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,Z.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:()=>ce(null),"aria-label":_(`header.actions.backAria`),children:[(0,Z.jsx)(G,{name:`arrow-left`,className:`size-4`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:L.modelID})]}),(0,Z.jsx)(`div`,{className:`space-y-1 p-2`,role:`listbox`,"aria-label":_(`chat.modelControls.thinking`),children:[``,...ot].map(e=>{let t=ct===e;return(0,Z.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,className:U(`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:()=>H(e),children:[(0,Z.jsx)(`span`,{className:`truncate`,children:e||_(`chat.modelControls.default`)}),t?(0,Z.jsx)(G,{name:`check`,className:`size-4 shrink-0`}):null]},e||`__default`)})})]}):null,t[134]=H,t[135]=_,t[136]=L,t[137]=ct,t[138]=ot,t[139]=lt):lt=t[139];let ut=lt||it;if(ne){let e=v?oe:void 0,a=!v,l=!v&&`opacity-60 cursor-not-allowed`,u;t[140]!==o||t[141]!==l?(u=U(`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`,l,o),t[140]=o,t[141]=l,t[142]=u):u=t[142];let d;t[143]!==v||t[144]!==y||t[145]!==r||t[146]!==n||t[147]!==g||t[148]!==_?(d=v?g&&(n||r)?(0,Z.jsx)(ze,{modelId:r,providerId:n,className:`h-3.5 w-3.5 flex-shrink-0`}):g?(0,Z.jsx)(G,{name:`pencil-ai`,className:`h-3 w-3 text-muted-foreground`}):null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(G,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:_(y?`common.unavailable`:`common.loading`)})]}),t[143]=v,t[144]=y,t[145]=r,t[146]=n,t[147]=g,t[148]=_,t[149]=d):d=t[149];let f;t[150]!==v||t[151]!==Ue?(f=v?(0,Z.jsx)(`span`,{className:`typography-meta font-medium text-foreground truncate`,children:Ue}):null,t[150]=v,t[151]=Ue,t[152]=f):f=t[152];let p;t[153]!==v||t[154]!==Ke?(p=v&&Ke?(0,Z.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground`,children:Ke}):null,t[153]=v,t[154]=Ke,t[155]=p):p=t[155];let m;t[156]!==d||t[157]!==f||t[158]!==p?(m=(0,Z.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,Z.jsx)(G,{name:`arrow-down-s`,className:`h-3 w-3 flex-shrink-0 text-muted-foreground`}),t[160]=h):h=t[160];let b;t[161]!==e||t[162]!==a||t[163]!==u||t[164]!==m?(b=(0,Z.jsxs)(`button`,{type:`button`,onClick:e,disabled:a,className:u,children:[m,h]}),t[161]=e,t[162]=a,t[163]=u,t[164]=m,t[165]=b):b=t[165];let C;t[166]!==A||t[167]!==r||t[168]!==n||t[169]!==j||t[170]!==T||t[171]!==i?(C=(e,t)=>T(e,t,e===n&&t===r?i||void 0:A.find(n=>n.providerID===e&&n.modelID===t)?.variant??j.find(n=>n.providerID===e&&n.modelID===t)?.variant),t[166]=A,t[167]=r,t[168]=n,t[169]=j,t[170]=T,t[171]=i,t[172]=C):C=t[172];let D;t[173]!==c||t[174]!==s||t[175]!==A||t[176]!==S||t[177]!==Xe||t[178]!==w||t[179]!==E||t[180]!==M||t[181]!==r||t[182]!==n||t[183]!==O||t[184]!==x||t[185]!==j||t[186]!==Je||t[187]!==C||t[188]!==R?(D=(0,Z.jsx)(zr,{open:M,onClose:B,selectedProviderID:n,selectedModelID:r,resolveSelectedVariant:Je,onSelect:Xe,providers:x,favoriteModels:A,recentModels:j,getMetadata:S,hiddenModels:w,allowedProviderIds:s,allowedModelIdsByProvider:c,providerOrder:O,variantSelectionEnabled:R,isFavorite:E,onToggleFavorite:C}),t[173]=c,t[174]=s,t[175]=A,t[176]=S,t[177]=Xe,t[178]=w,t[179]=E,t[180]=M,t[181]=r,t[182]=n,t[183]=O,t[184]=x,t[185]=j,t[186]=Je,t[187]=C,t[188]=R,t[189]=D):D=t[189];let k;return t[190]!==b||t[191]!==D?(k=(0,Z.jsxs)(Z.Fragment,{children:[b,D]}),t[190]=b,t[191]=D,t[192]=k):k=t[192],k}let dt=v&&ie,ft=v?F:void 0,pt=!v&&`opacity-60 cursor-not-allowed`,mt;t[193]!==o||t[194]!==pt?(mt=U(`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`,pt,o),t[193]=o,t[194]=pt,t[195]=mt):mt=t[195];let ht;t[196]!==v||t[197]!==y||t[198]!==r||t[199]!==n||t[200]!==g||t[201]!==_||t[202]!==Ue||t[203]!==Ke?(ht=v?(0,Z.jsxs)(Z.Fragment,{children:[g?n||r?(0,Z.jsx)(ze,{modelId:r,providerId:n,className:`h-3.5 w-3.5 flex-shrink-0`}):(0,Z.jsx)(G,{name:`pencil-ai`,className:`h-3.5 w-3.5 flex-shrink-0 text-muted-foreground`}):null,(0,Z.jsx)(`span`,{className:`typography-ui-label min-w-0 flex-1 truncate text-left font-normal text-foreground`,children:Ue}),Ke?(0,Z.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground`,children:Ke}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(G,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin text-muted-foreground flex-shrink-0`}),(0,Z.jsx)(`span`,{className:`typography-ui-label font-normal whitespace-nowrap text-muted-foreground`,children:_(y?`common.unavailable`:`common.loading`)})]}),t[196]=v,t[197]=y,t[198]=r,t[199]=n,t[200]=g,t[201]=_,t[202]=Ue,t[203]=Ke,t[204]=ht):ht=t[204];let gt;t[205]===Symbol.for(`react.memo_cache_sentinel`)?(gt=(0,Z.jsx)(G,{name:`arrow-down-s`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground/50`}),t[205]=gt):gt=t[205];let _t;t[206]!==mt||t[207]!==ht?(_t=(0,Z.jsx)(cr,{asChild:!0,children:(0,Z.jsxs)(`div`,{className:mt,children:[ht,gt]})}),t[206]=mt,t[207]=ht,t[208]=_t):_t=t[208];let vt;t[209]!==h||t[210]!==ut?(vt=(0,Z.jsx)(lr,{className:`w-[min(380px,calc(100vw-2rem))] p-0 flex flex-col`,align:`start`,portalToBody:h,children:ut}),t[209]=h,t[210]=ut,t[211]=vt):vt=t[211];let yt;return t[212]!==dt||t[213]!==ft||t[214]!==_t||t[215]!==vt?(yt=(0,Z.jsxs)(sr,{open:dt,onOpenChange:ft,children:[_t,vt]}),t[212]=dt,t[213]=ft,t[214]=_t,t[215]=vt,t[216]=yt):yt=t[216],yt};function Jr(e){return e.providers}function Yr(e){return e.getModelMetadata}function Xr(e){return e.isMobile}function Zr(e){return e.hiddenModels}function Qr(e){return e.toggleFavoriteModel}function $r(e){return e.isFavoriteModel}function ei(e){return e.addRecentModel}function ti(e){return e.providerOrder}var ni=e(k(),1),ri=`mobile-overlay-root`,ii=16,ai=200,oi=[],si=0,ci=``,li=0,ui=()=>{if(typeof document>`u`)return null;let e=document.getElementById(ri);return e||(e=document.createElement(`div`),e.id=ri,document.body.appendChild(e)),e},di=({open:e,title:t,onClose:n,children:r,footer:i,className:a,contentMaxHeightClassName:o,renderHeader:s,containedBody:c=!1,closeAriaLabel:l})=>{let u=Q.useRef(null),d=Q.useRef(Symbol(`mobile-overlay`)),f=Q.useRef(n);f.current=n;let[p,m]=Q.useState(!1),[h,g]=Q.useState(!1);if(typeof document<`u`&&!u.current&&(u.current=ui()),Q.useEffect(()=>{if(!e){m(!1),g(!1);return}let t=window.setTimeout(()=>m(!0),ii),n=window.setTimeout(()=>g(!0),266);return()=>{window.clearTimeout(t),window.clearTimeout(n)}},[e]),Q.useLayoutEffect(()=>{if(e)return li===0&&window.dispatchEvent(new Event(`oc:mobile-overlay-opened`)),li+=1,()=>{li=Math.max(0,li-1),li===0&&window.dispatchEvent(new Event(`oc:mobile-overlay-closed`))}},[e]),Q.useEffect(()=>{if(!e)return;let t=d.current;oi.push(t),si===0&&(ci=document.body.style.overflow),si+=1,document.body.style.overflow=`hidden`;let n=e=>{e.key===`Escape`&&oi[oi.length-1]===t&&f.current()};return document.addEventListener(`keydown`,n),()=>{let e=oi.lastIndexOf(t);e>=0&&oi.splice(e,1),si=Math.max(0,si-1),si===0&&(document.body.style.overflow=ci),document.removeEventListener(`keydown`,n)}},[e]),!e||!u.current)return null;let _=o??`max-h-[min(70vh,520px)]`,v=(0,Z.jsx)(`div`,{className:U(`oc-keyboard-inset-surface fixed inset-0 z-[60] flex flex-col bg-[rgb(0_0_0_/_0.45)] transition-opacity duration-200 ease-out`,!h&&`oc-keyboard-inset-snap`,p?`opacity-100`:`opacity-0`),role:`dialog`,"aria-modal":`true`,"aria-label":t,onPointerDown:Ge,onClick:e=>{Xe(e)&&n()},children:(0,Z.jsxs)(`div`,{className:U(`mt-auto flex max-h-[calc(100dvh-0.75rem)] min-h-0 w-full flex-col rounded-t-xl border-x border-t border-border/50 bg-background pb-[max(0.5rem,var(--oc-app-bottom-safe,0px),var(--oc-safe-area-bottom,env(safe-area-inset-bottom,0px)))] shadow-none pwa-overlay-panel`,`mx-auto max-w-lg`,a),style:{transform:p?`none`:`translateY(100%)`,transition:`transform ${ai}ms cubic-bezier(0.32, 0.72, 0, 1)`},onClick:e=>e.stopPropagation(),children:[(()=>{let e=(0,Z.jsx)(`button`,{type:`button`,onClick:n,className:U(`flex items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover`,c?`size-11`:`h-8 w-8`),"aria-label":l??t,children:(0,Z.jsx)(G,{name:`close`,className:`h-4 w-4`})});return s?s(e):(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border/40`,children:[(0,Z.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:t}),e]})})(),c?(0,Z.jsx)(`div`,{className:U(`flex min-h-0 flex-1 flex-col overflow-hidden`,_),children:r}):(0,Z.jsx)(Ye,{useScrollShadow:!0,disableHorizontal:!0,preventOverscroll:!0,outerClassName:U(`min-h-0 flex-1`,_),className:`px-2 py-2 pwa-overlay-scroll`,children:r}),i?(0,Z.jsx)(`div`,{className:`shrink-0 border-t border-border/40 px-3 py-2`,children:i}):null]})});return(0,ni.createPortal)(v,u.current)},fi=e=>e??o()?.github,pi=(e=n())=>s.github.auth(e),mi=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},hi=(e,t=n())=>{let r=fi(e);return{queryKey:pi(t),queryFn:async({signal:e})=>mi(r,e),retry:2}},gi=e=>!!e&&typeof e==`object`&&`authStatus`in e,_i=e=>{let t=(0,K.c)(5),n=gi(e)?e:void 0,r=gi(e)?void 0:e?.enabled,i;t[0]===n?i=t[1]:(i=hi(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],P(a)},vi=(e=l,t=n())=>e.getQueryData(pi(t))??null,yi=async(e,t,r)=>n()===r?e.fetchQuery({...hi(t,r),staleTime:0}):e.getQueryData(pi(r))??null,bi=(e=l,t,r=n())=>{e.setQueryData(pi(r),t)},xi=L.define(fe),Si=le.data.of({commentTokens:{line:`//`,block:{open:`/*`,close:`*/`}}});function Ci(e){let t=e.trim().toLowerCase();switch(t){case`bash`:case`sh`:case`zsh`:case`shell`:case`shellsession`:case`console`:return xi;case`json`:case`jsonc`:case`json5`:return V().language;case`js`:case`javascript`:return z().language;case`jsx`:return z({jsx:!0}).language;case`ts`:case`typescript`:return z({typescript:!0}).language;case`tsx`:return z({typescript:!0,jsx:!0}).language;case`html`:return B().language;case`css`:return R().language;case`py`:case`python`:return de().language;case`md`:case`markdown`:case`mdown`:case`mkd`:return ue().language;case`heex`:case`eex`:case`leex`:return B().language;default:return ce.matchLanguageName(lt,t,!0)}}var wi=e=>e.split(`/`).pop()?.toLowerCase()??``,Ti=e=>{let t=wi(e);return t?ce.matchFilename(lt,t):null},Ei=()=>F(se.define([{tag:[I.heading1,I.heading2,I.heading3,I.heading4,I.heading5,I.heading6],fontWeight:`600`},{tag:I.strong,fontWeight:`600`},{tag:I.emphasis,fontStyle:`italic`},{tag:I.strikethrough,textDecoration:`line-through`},{tag:[I.link,I.url],color:`var(--markdown-link, currentColor)`,textDecoration:`underline`},{tag:I.monospace,color:`var(--markdown-inline-code, currentColor)`,backgroundColor:`var(--markdown-inline-code-bg, transparent)`},{tag:I.quote,color:`var(--markdown-blockquote, currentColor)`,fontStyle:`italic`},{tag:I.list,color:`color-mix(in srgb, var(--muted-foreground) 40%, var(--foreground) 60%)`},{tag:I.heading,color:`var(--markdown-heading1, currentColor)`}]));function Di(e){let t=e.toLowerCase();switch(wi(t)){case`makefile`:case`gnumakefile`:return xi}let n=t.lastIndexOf(`.`),r=n>=0?t.slice(n+1):``;switch(r){case`ts`:case`tsx`:case`mts`:case`cts`:return z({typescript:!0,jsx:r===`tsx`});case`js`:case`jsx`:case`mjs`:case`cjs`:return z({typescript:!1,jsx:r===`jsx`});case`jsonc`:case`json5`:return[V(),Si];case`json`:case`jsonl`:case`ndjson`:case`geojson`:return V();case`css`:case`scss`:case`sass`:case`less`:return R();case`html`:case`htm`:case`xml`:case`drawio`:case`dio`:return B();case`md`:case`mdx`:case`markdown`:case`mdown`:case`mkd`:return[ue({codeLanguages:Ci}),Ei()];case`sh`:case`bash`:case`zsh`:case`fish`:case`env`:return xi;case`py`:case`pyw`:case`pyi`:return de();default:return null}}async function Oi(e){let t=Ti(e);if(!t)return null;if(t.support)return t.support;try{return await t.load()}catch{return null}}var ki=e=>e===`allow`||e===`deny`||e===`ask`;function Ai(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function ji(e){return Ai(e)?typeof e.action==`string`&&typeof e.resource==`string`&&ki(e.effect)?{action:e.action,resource:e.resource,effect:e.effect}:typeof e.permission==`string`&&typeof e.pattern==`string`&&ki(e.action)?{action:e.permission,resource:e.pattern,effect:e.action}:null:null}function Mi(e){if(Array.isArray(e))return e.flatMap(e=>{let t=ji(e);return t?[t]:[]});if(ki(e))return[{action:`*`,resource:`*`,effect:e}];if(!Ai(e))return[];let t=[];for(let[n,r]of Object.entries(e))if(n!==`__originalKeys`){if(ki(r)){t.push({action:n,resource:`*`,effect:r});continue}if(Ai(r))for(let[e,i]of Object.entries(r))ki(i)&&t.push({action:n,resource:e,effect:i})}return t}function Ni(e){return Mi(e)}async function Pi(e,t,n){if(!e.body)throw Error(`Speech response has no stream`);let r=e.body.getReader(),i=t.createGain();i.gain.value=n.volume,i.connect(t.destination);let a=new Set,o=new Set,s=new TextDecoder,c=t.currentTime,l=``,u,d=!1,f=!1,p=0,m=2**(n.pitch-1),h=[],g=0,_=!0,v=()=>{r.cancel().catch(()=>void 0);for(let e of a)e.stop()};n.signal.addEventListener(`abort`,v,{once:!0});let y=async e=>{for(;c-t.currentTime>2&&o.size;)await Promise.race(o),n.signal.throwIfAborted();n.signal.throwIfAborted();let r=t.createBufferSource();r.buffer=e,r.detune.value=(n.pitch-1)*1200,r.connect(i);let s,l=new Promise(e=>{s=e});o.add(l),a.add(r),r.onended=()=>{a.delete(r),o.delete(l),r.disconnect(),s()};let u=Math.max(c,t.currentTime+.02);r.start(u),c=u+e.duration/m,d||(d=!0,n.onStart())},b=async()=>{for(let e of h)await y(e);h.length=0,g=0,_=!1},x=async e=>{if(!e.trim())return;if(f)throw Error(`Unexpected audio after speech completion`);let n=JSON.parse(e);if(n.type===`error`)throw Error(`Speech synthesis interrupted or failed`);if(n.type===`done`){f=!0,await b();return}if(n.type!==`audio`||typeof n.data!=`string`||n.data.length>12800)throw Error(`Invalid speech audio frame`);let r=atob(n.data),i=new Uint8Array(r.length+(u===void 0?0:1)),a=0;u!==void 0&&(i[a++]=u);for(let e=0;e<r.length;e++)i[a+e]=r.charCodeAt(e);u=i.length%2?i[i.length-1]:void 0;let o=Math.floor(i.length/2);if(!o)return;let s=t.createBuffer(1,o,24e3),l=s.getChannelData(0),d=new DataView(i.buffer);for(let e=0;e<o;e++)l[e]=d.getInt16(e*2,!0)/32768;c<t.currentTime+.02&&(_=!0),h.push(s),g+=s.duration/m,(!_||g>=.4)&&await b()};try{for(n.signal.throwIfAborted();;){let e=await r.read();if(n.signal.throwIfAborted(),e.done)break;if(p+=e.value.length,p>33554432)throw Error(`Speech stream exceeds the size limit`);l+=s.decode(e.value,{stream:!0});let t;for(;(t=l.indexOf(`
|
|
3
3
|
`))!==-1;)await x(l.slice(0,t)),l=l.slice(t+1);if(l.length>16e3)throw Error(`Speech frame exceeds the size limit`)}if(l+=s.decode(),l.trim()&&await x(l),!f||!d||u!==void 0)throw Error(`Incomplete speech audio stream`);await Promise.all(o),n.signal.throwIfAborted()}finally{n.signal.removeEventListener(`abort`,v),await r.cancel().catch(()=>void 0),r.releaseLock();for(let e of a)e.onended=null,e.stop(),e.disconnect();i.disconnect()}}async function*Fi(e,t,n){let r=await Qe(et(e,`tts`),n),i=crypto.randomUUID(),a=new TextEncoder,o={speaker:e.voice,audio_params:{format:`pcm`,sample_rate:24e3,speech_rate:Math.round((e.speed-1)*100)},...e.resourceId===`seed-tts-2.0`&&e.voice===`zh_female_vv_uranus_bigtts`?{additions:JSON.stringify({context_texts:[`请用自然、温暖的对话语气朗读,根据文本内容表达恰当的情感,保持清晰自然的停顿与重音,避免夸张的播音腔。`]})}:{}},s=(e,n=!1)=>({user:{uid:`openchamber`},namespace:`BidirectionalTTS`,event:e,req_params:{...o,...n?{text:t}:{}}}),c=`connection`,l=0;try{for(r.send(it(1));;){let e=await ct(await r.read(),`tts`);if(n.throwIfAborted(),e.event===51||e.event===153||e.event===151)throw Error(`Speech synthesis failed`);if(e.event>=100&&e.sessionId!==i)throw Error(`Unexpected speech session`);if(e.event===50&&c===`connection`)c=`session`,r.send(it(100,i,s(100)));else if(e.event===150&&c===`session`)c=`audio`,r.send(it(200,i,s(200,!0))),r.send(it(102,i));else if(e.event===352&&c===`audio`&&e.type===11){if(l+=e.payload.length,l>33554432)throw Error(`Speech audio exceeds size limit`);for(let t=0;t<e.payload.length;t+=9600){let n=e.payload.subarray(t,t+9600),r=``;for(let e of n)r+=String.fromCharCode(e);yield a.encode(`${JSON.stringify({type:`audio`,data:btoa(r)})}\n`)}}else if(e.event===152&&c===`audio`){let t=$e(e.payload);if(t.status_code!==void 0&&t.status_code!==0&&t.status_code!==2e7)throw Error(`Speech synthesis failed`);if(!l)throw Error(`Speech returned no audio`);try{r.send(it(2))}catch{}yield a.encode(`{"type":"done"}
|
|
4
4
|
`);return}else if(e.event!==350&&e.event!==351)throw Error(`Unexpected speech synthesis event`)}}finally{r.close()}}async function Ii(e,t){if(!e.trim())throw Error(`Speech text is required`);let n=await nt(`tts`,t);if(!n)return a(`/api/tts/speak`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/x-ndjson, audio/*`},body:JSON.stringify({text:e.trim()}),signal:t});if(e.length>1e4)throw Error(`Speech text must contain 1–10000 characters`);let r=new AbortController,i=Fi(n,e.trim(),AbortSignal.any([t,r.signal])),o=new ReadableStream({async pull(e){try{let t=await i.next();t.done?e.close():e.enqueue(t.value)}catch(t){e.error(t)}},async cancel(){r.abort(),await i.return(void 0)}});return new Response(o,{headers:{"Content-Type":`application/x-ndjson`,"X-Speech-Pitch":String(n.pitch),"X-Speech-Volume":String(n.volume)}})}var Li=3e4,Ri=new Map,zi=new Map;async function Bi(e){let t=Date.now(),n=Ri.get(e);if(n&&t-n.checkedAt<Li)return n.available;let r=zi.get(e);if(r)return r;let i=(async()=>{try{let t=await a(`/api/tts/status`);if(!t.ok)return Ri.set(e,{available:!1,checkedAt:Date.now()}),!1;let n=!!(await t.json()).available;return Ri.set(e,{available:n,checkedAt:Date.now()}),n}catch{return Ri.set(e,{available:!1,checkedAt:Date.now()}),!1}finally{zi.delete(e)}})();return zi.set(e,i),i}var Vi=null;function Hi(){return Ze(),Vi||=new(window.AudioContext||window.webkitAudioContext),Vi}function Ui(e={}){let r=e.enabled??!0,[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),u=(0,Q.useRef)(null),d=(0,Q.useRef)(null),f=(0,Q.useRef)(0),p=(0,Q.useCallback)(async()=>{let e=++f.current,t=n(),i=r=>(e===f.current&&n()===t&&s(r),r);if(!r)return i(!1);try{return i(await Bi(t))}catch{return i(!1)}},[r]);(0,Q.useEffect)(()=>{p()},[p]),(0,Q.useEffect)(()=>t(()=>{p()}),[p]);let m=(0,Q.useCallback)(()=>{let e=d.current;if(d.current=null,e?.abort.abort(),u.current){try{u.current.onended=null,u.current.stop()}catch{}u.current=null}a(!1)},[]),h=(0,Q.useCallback)(async()=>{try{let e=Hi();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(e){console.error(`[useServerTTS] Failed to unlock audio:`,e)}},[]),g=(0,Q.useCallback)(async(e,t)=>{if(m(),!e.trim()){l(`No text to speak`),t?.onError?.(`No text to speak`);return}l(null);let n={abort:new AbortController};d.current=n;try{let r=Hi();r.state===`suspended`&&await r.resume();let i=r.createBuffer(1,1,22050),o=r.createBufferSource();o.buffer=i,o.connect(r.destination),o.start(0);let s=await Ii(e.trim(),n.abort.signal);if(d.current!==n)return;if(!s.ok){let e=await s.json().catch(()=>({error:`Unknown error`}));throw Error(e.error||`HTTP ${s.status}`)}let c=Number(s.headers.get(`X-Speech-Pitch`)??1),l=Number(s.headers.get(`X-Speech-Volume`)??1);if(s.headers.get(`content-type`)?.includes(`application/x-ndjson`)){await Pi(s,r,{signal:n.abort.signal,pitch:c,volume:l,onStart:()=>{d.current===n&&(a(!0),t?.onStart?.())}}),d.current===n&&(d.current=null,a(!1),t?.onEnd?.());return}let f=await(await s.blob()).arrayBuffer();if(d.current!==n)return;let p=await r.decodeAudioData(f);if(d.current!==n)return;let m=r.createBufferSource();m.buffer=p,c!==1&&(m.detune.value=(c-1)*1200);let h=r.createGain();if(h.gain.value=l,m.connect(h),h.connect(r.destination),u.current=m,m.onended=()=>{d.current===n&&u.current===m&&(a(!1),u.current=null,d.current=null,t?.onEnd?.())},a(!0),t?.onStart?.(),d.current!==n||u.current!==m)return;m.start(0)}catch(e){if(e.name===`AbortError`||d.current!==n)return;let r=e instanceof Error?e.message:`Failed to speak`;console.error(`[useServerTTS] Error:`,r),l(r),t?.onError?.(r),a(!1),u.current&&=(u.current.onended=null,null),d.current=null}},[m]);return(0,Q.useEffect)(()=>t(m),[m]),(0,Q.useEffect)(()=>tt(m),[m]),(0,Q.useEffect)(()=>()=>{m()},[m]),{isPlaying:i,isAvailable:o,error:c,speak:g,stop:m,checkAvailability:p,unlockAudio:h}}var Wi=60,Gi=400;function Ki(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+=Gi){let n=e.slice(t,t+Gi);i&&i.length+n.length>Gi&&(r.push(i.trim()),i=``),i+=n,i.length>=Wi&&/[.!?…]["')\]]*\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 qi=null;function Ji(){return Ze(),qi||=new(window.AudioContext||window.webkitAudioContext),qi}function Yi(){let[e,t]=(0,Q.useState)(!1),[n,r]=(0,Q.useState)(null),i=(0,Q.useRef)(null),o=(0,Q.useRef)(null),s=(0,Q.useCallback)(async()=>{try{let e=Ji();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,Q.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,Q.useCallback)(async(e,n)=>{c();let s=Ki(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}),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=Ji();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,Q.useEffect)(()=>tt(c),[c]),(0,Q.useEffect)(()=>()=>{c()},[c]),{isPlaying:e,error:n,speak:l,stop:c,unlockAudio:s}}var Xi=new class{recognition=null;isListening=!1;currentLang=`en-US`;onResultCallback=null;onErrorCallback=null;restartOnEnd=!1;conversationMode=!1;isSpeaking=!1;audioContext=null;audioUnlockRequired=!1;speechGeneration=0;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 ot(),(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(),ot(),this.isSpeaking=!1;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(){Ze(),this.audioContext||=new(window.AudioContext||window.webkitAudioContext),this.audioContext.state===`suspended`&&await this.audioContext.resume()}isAudioUnlockRequired(){return this.audioUnlockRequired}async unlockAudio(){Ze();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`);let i=++this.speechGeneration;await this.resumeAudioContext();let a=await this.waitForVoices();if(await new Promise(e=>setTimeout(e,50)),i!==this.speechGeneration)return;this.isSpeaking=!0,this.pauseListening(),window.speechSynthesis.cancel();let o=new SpeechSynthesisUtterance(e);o.lang=t,o.rate=r?.rate??1,o.pitch=r?.pitch??1,o.volume=r?.volume??1;let s=null;return r?.voiceName&&(s=a.find(e=>e.name===r.voiceName)||null,s?`${s.name}${s.lang}`:console.warn(`[BrowserVoiceService] Selected voice "${r.voiceName}" not found, falling back to language match`)),s||(s=this.findBestVoice(a,t),s?`${s.name}${s.lang}`:console.warn(`[BrowserVoiceService] No voice found for language: ${t}, using default`)),s&&(o.voice=s),`${e.length}${t}`,new Promise((e,t)=>{let r=!1;o.onstart=()=>{r=!0,e()},o.onend=()=>{this.isSpeaking=!1,n?.()},o.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(o)})}cancelSpeech(){this.speechGeneration+=1,this.isSpeaking=!1,`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}`}};tt(()=>Xi.cancelSpeech());var Zi=e=>{if(e===`12h`)return!0;if(e===`24h`)return!1},Qi=(e,t,n={})=>{let r=e instanceof Date?e:new Date(e);return Number.isFinite(r.getTime())?r.toLocaleTimeString(H(),{hour:n.hour??`numeric`,minute:`2-digit`,second:n.precision===`second`?`2-digit`:void 0,hour12:Zi(t)}):n.fallback??``},$i=(e,t,n)=>{let r=e instanceof Date?e:new Date(e);return Number.isFinite(r.getTime())?r.toLocaleString(H(),{...n,hour12:n.hour?Zi(t):n.hour12}):``},$=e=>ye(ve.getState().dictionary,e),ea=e=>typeof e!=`number`||!Number.isFinite(e)?null:Math.max(0,Math.min(100,Math.round(e))),ta=e=>typeof e!=`number`||!Number.isFinite(e)?`-`:`${Math.round(e)}%`,na=(e,t)=>e??ta(t),ra=(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()?Qi(r,n,{fallback:t??``}):$i(r,n,{month:`short`,day:`numeric`,weekday:`short`,hour:`numeric`,minute:`2-digit`})}catch{return t??``}},ia=e=>e===null?`safe`:e>=80?`critical`:e>=50?`warn`:`safe`,aa=e=>e===`5h`?$(`quota.window.5h`):e===`7d`?$(`quota.window.7d`):e===`7d-sonnet`?$(`quota.window.7dSonnet`):e===`7d-opus`?$(`quota.window.7dOpus`):e===`weekly`?$(`quota.window.weekly`):e===`daily`?$(`quota.window.daily`):e===`monthly`?$(`quota.window.monthly`):e===`credits`?$(`quota.window.credits`):e===`credits_balance`?$(`quota.window.creditsBalance`):e===`billing_cycle`?$(`quota.window.billingCycle`):e===`auto`?$(`quota.window.auto`):e===`api`?$(`quota.window.api`):e===`plan_limit`?$(`quota.window.planLimit`):e===`on_demand`?$(`quota.window.onDemand`):e===`session`?$(`quota.window.session`):e===`premium`?$(`quota.window.premium`):e===`chat`?$(`quota.window.chat`):e===`completions`?$(`quota.window.completions`):e===`premium_interactions`?$(`quota.window.premiumInteractions`):e,oa=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},sa=(e,t,n,r)=>{let i=n;if(i===null&&r&&(i=oa(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}},ca=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)`}},la=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`},ua=e=>Math.min(100,Math.max(0,e*100)),da=(e,t)=>ye(ve.getState().dictionary,e,t),fa=e=>{let t=new Date(e),n=new Date,r=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),i=new Date(n);return i.setDate(n.getDate()-1),r(t,n)?da(`common.date.today`):r(t,i)?da(`common.date.yesterday`):t.toLocaleDateString(H(),{month:`short`,day:`numeric`,year:`numeric`}).replace(`,`,``)},pa=e=>{let t=new Date;if(((e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate())(new Date(e),t)){let t=Date.now()-e;return t<6e4?da(`common.relative.justNow`):t<36e5?da(`common.relative.minutesAgoShort`,{count:Math.floor(t/6e4)}):da(`common.relative.hoursAgoShort`,{count:Math.floor(t/36e5)})}return fa(e)},ma=e=>{let t=Math.max(0,Date.now()-e),n=6e4,r=60*n,i=24*r,a=7*i,o=365*i;return t<r?da(`common.relative.minutesAgoCompact`,{count:Math.max(1,Math.floor(t/n))}):t<i?da(`common.relative.hoursAgoCompact`,{count:Math.floor(t/r)}):t<a?da(`common.relative.daysAgoCompact`,{count:Math.floor(t/i)}):t<5*a?da(`common.relative.weeksAgoCompact`,{count:Math.floor(t/a)}):t<o?da(`common.relative.monthsAgoCompact`,{count:Math.floor(t/2592e6)}):da(`common.relative.yearsAgoCompact`,{count:Math.floor(t/o)})},ha=(e,t)=>ga(f(e),f(t)),ga=(e,t)=>!e||!t?!1:e===t?!0:t===`/`?e.startsWith(`/`):e.startsWith(`${t}/`),_a=e=>e.toLowerCase().replace(/^opencode[/-]?/i,``).replace(/[-_]/g,``).trim(),va=(e,t)=>e?_a(e)!==_a(t):!1,ya=e=>{if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`string`&&e.trim().length>0){let t=Number(e);if(Number.isFinite(t))return t}},ba=e=>ya(e.time?.created)??0,xa=(e,t,n)=>{let r=n.has(e.id),i=n.has(t.id);return r===i?r&&i?ba(t)-ba(e):Ae(t)-Ae(e):r?-1:1},Sa=e=>{let t=new Map;return e.forEach(e=>{t.set(e.id,e)}),Array.from(t.values())},Ca=e=>`__archived__:${e}`,wa=(e,t)=>{let n=f(e.directory??null),r=f(e.project?.worktree??null),i=n??r;if(!i)return`unassigned`;if(t&&i===t)return`project root`;let a=(t&&i.startsWith(`${t}/`)?i.slice(t.length+1):i).split(`/`).filter(Boolean);return a[a.length-1]??`unassigned`},Ta=`box-border w-full px-2 py-1.5 text-left typography-micro text-muted-foreground/70 select-none`,Ea=`bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] dark:bg-[color-mix(in_srgb,var(--surface-foreground)_11%,transparent)]`,Da=`hover:bg-[color-mix(in_srgb,var(--surface-foreground)_3.5%,transparent)] dark:hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)]`,Oa=e=>{let t=Math.max(0,e);return t===0?8:30+(t-1)*14},ka=(e,t)=>{if(!t)return e;let n=e.toLowerCase(),r=t.toLowerCase(),i=r.length;if(i===0)return e;let a=[],o=0,s=n.indexOf(r,o);for(;s!==-1;){s>o&&a.push(e.slice(o,s));let t=e.slice(s,s+i);a.push((0,Z.jsx)(`mark`,{className:`bg-transparent font-[inherit] text-[var(--primary-base)]`,children:t},`${s}-${t}`)),o=s+i,s=n.indexOf(r,o)}return o<e.length&&a.push(e.slice(o)),a.length>0?a:e},Aa=`/api/browser-providers`,ja=`/api/browser-providers/selection`,Ma=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/,Na=200,Pa=e=>`/api/browser-providers/${encodeURIComponent(e)}/surface/ws`,Fa=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Ia=e=>typeof e==`string`&&Ma.test(e)?e:null,La=e=>{if(!Fa(e))return null;let t=Ia(e.id),n=typeof e.name==`string`?e.name.trim():``;return!t||!n||n.length>Na?null:{id:t,name:n,surface:e.surface===!0}},Ra=e=>{if(!Fa(e)||!Array.isArray(e.providers))return null;let t=[],n=new Set;for(let r of e.providers){let e=La(r);!e||n.has(e.id)||(n.add(e.id),t.push(e))}let r=Ia(e.selectedId);return{providers:t,selectedId:r&&n.has(r)?r:null}},za=e=>{if(!Fa(e))return null;let t=Ia(e.selectedId);return t?{selectedId:t}:null},Ba=e=>e?.selectedId?e.providers.find(t=>t.id===e.selectedId)??null:null,Va=e=>!!(e&&e.providers.length>0),Ha=e=>Ba(e)!==null,Ua=e=>typeof e==`number`&&Number.isFinite(e),Wa=e=>{if(!Fa(e)||typeof e.type!=`string`)return null;if(e.type===`hello`&&typeof e.viewerId==`string`&&e.viewerId.length>0)return{type:`hello`,viewerId:e.viewerId};if(e.type===`frame`){let t=e.mime===`image/jpeg`||e.mime===`image/png`?e.mime:null;if(!t||!Ua(e.seq)||!Ua(e.width)||!Ua(e.height)||!Ua(e.bytes)||e.bytes<1||typeof e.agentActive!=`boolean`)return null;let n=typeof e.title==`string`?e.title:void 0;return{type:`frame`,seq:e.seq,width:e.width,height:e.height,mime:t,bytes:e.bytes,title:n,agentActive:e.agentActive}}if(e.type===`control`){let t=e.controller===`none`||e.controller===`agent`||e.controller===`user`?e.controller:null;return!t||typeof e.mine!=`boolean`?null:{type:`control`,controller:t,mine:e.mine}}return e.type===`resized`&&Ua(e.width)&&Ua(e.height)?{type:`resized`,width:e.width,height:e.height}:e.type===`error`&&typeof e.code==`string`&&typeof e.message==`string`?{type:`error`,code:e.code,message:e.message}:e.type===`ended`&&(e.reason===`service-stopped`||e.reason===`extension-unavailable`||e.reason===`host-shutdown`)?{type:`ended`,reason:e.reason}:null},Ga=class extends Error{status;constructor(e){super(`browser_provider_request_failed:${e}`),this.name=`BrowserProviderRequestError`,this.status=e}},Ka=(e=n())=>s.browserProviders.catalog(e),qa=async e=>{let t=await e.text();if(!t)return null;try{return JSON.parse(t)}catch{return null}},Ja=async e=>{let t=await a(Aa,{method:`GET`,headers:{Accept:`application/json`},signal:e}),n=await qa(t);if(!t.ok)throw new Ga(t.status);let r=Ra(n);if(!r)throw new Ga(t.status||502);return r},Ya=(e=n())=>({queryKey:Ka(e),queryFn:({signal:e})=>Ja(e),staleTime:5e3,refetchOnWindowFocus:!0,refetchInterval:e=>{let t=e.state.error;return t instanceof Ga&&(t.status===404||t.status===501)?!1:15e3}}),Xa=()=>{let e=(0,K.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=Ya(),e[0]=t):t=e[0],P(t)},Za=(e=l,t=n())=>e.getQueryData(Ka(t))??null,Qa=(e,t)=>e?.providers.some(e=>e.id===t)?{providers:e.providers,selectedId:t}:null,$a=async(e,t=l,r)=>{let i=n(),o=await a(ja,{method:`PUT`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({id:e}),signal:r}),s=await qa(o);if(!o.ok)throw new Ga(o.status);let c=za(s);if(!c||c.selectedId!==e||n()!==i)throw new Ga(o.status||502);let u=Qa(t.getQueryData(Ka(i)),c.selectedId);if(!u)throw new Ga(409);return u},eo=()=>{let e=(0,K.c)(2),t=ae(),r;return e[0]===t?r=e[1]:(r={mutationFn:e=>$a(e,t),onMutate:async e=>{let r=n(),i=Ka(r);await t.cancelQueries({queryKey:i});let a=t.getQueryData(i),o=Qa(a,e);return o&&t.setQueryData(i,o),{previous:a,key:i,transport:r}},onError:(e,r,i)=>{!i||n()!==i.transport||t.setQueryData(i.key,i.previous)},onSuccess:(e,r,i)=>{!i||n()!==i.transport||t.setQueryData(i.key,e)}},e[0]=t,e[1]=r),N(r)},to=[`standalone`,`minimal-ui`,`fullscreen`,`window-controls-overlay`],no=`openchamber.pwaRecentSessions`,ro=e=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(display-mode: ${e})`).matches,io=()=>typeof window>`u`?`browser`:typeof document<`u`&&document.referrer.startsWith(`android-app://`)?`twa`:window.navigator.standalone?`standalone`:to.find(e=>ro(e))??`browser`,ao=864e5,oo=5,so=864e5,co=e=>e.time?.updated??e.time?.created??0,lo=({sessions:e,currentSessionId:t,cutoffDays:n,keepRecent:r=oo,now:i=Date.now()})=>{if(!Array.isArray(e)||n<=0)return[];let a=i-n*ao,o=[...e].sort((e,t)=>co(t)-co(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=co(e);return n?n<a:!1}).map(e=>e.id)},uo=e=>{let t=typeof e==`object`?e:void 0,n=t?.autoRun!==!1,r=typeof e==`boolean`?e:t?.enabled??!0,i=De(e=>e.currentSessionId),a=De(e=>e.isLoading),o=be(e=>e.activeSessions),s=be(e=>e.hasLoadedFullCatalog),c=te(e=>e.autoDeleteEnabled),l=te(e=>e.autoDeleteAfterDays),u=te(e=>e.sessionRetentionAction),d=te(e=>e.autoDeleteLastRunAt),f=te(e=>e.setAutoDeleteLastRunAt),[p,m]=Q.useState(!1),h=Q.useRef(!1);Q.useEffect(()=>{if(!r||!n||!c||l<=0)return;let e=window.setTimeout(()=>{Ee(j())},8e3);return()=>window.clearTimeout(e)},[l,c,n,r]);let g=Q.useMemo(()=>l<=0?[]:lo({sessions:o,currentSessionId:i,cutoffDays:l}),[l,i,o]),_=Q.useCallback(async({force:e=!1}={})=>{if(h.current)return{completedIds:[],failedIds:[],action:u,skippedReason:`running`};if((!c||l<=0)&&!e)return{completedIds:[],failedIds:[],action:u,skippedReason:`disabled`};if(a)return{completedIds:[],failedIds:[],action:u,skippedReason:`loading`};let t=Date.now();if(!e&&d&&t-d<so)return{completedIds:[],failedIds:[],action:u,skippedReason:`cooldown`};let{activeSessions:n}=await Ee(j());if(n.length===0)return{completedIds:[],failedIds:[],action:u,skippedReason:`no-candidates`};let r=lo({sessions:n,currentSessionId:i,cutoffDays:l,now:t});if(r.length===0)return f(t),{completedIds:[],failedIds:[],action:u,skippedReason:`no-candidates`};h.current=!0,m(!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?xe(r):null;if(!a){i.push(n);continue}try{u===`archive`?await ee.updateSession(n,{time:{archived:Date.now()}},a):await ee.deleteSession(n,a),t.push(n)}catch{i.push(n)}}return u===`archive`?be.getState().archiveSessions(t):be.getState().removeSessions(t),{completedIds:t,failedIds:i,action:u}}finally{h.current=!1,m(!1),f(Date.now())}},[l,c,d,i,a,u,f]);return Q.useEffect(()=>{r&&n&&(!c||l<=0||a||!s||o.length===0||d&&Date.now()-d<so||_())},[l,c,d,n,r,s,o.length,a,_]),{candidates:g,isRunning:p,runCleanup:_,keepRecentCount:oo,action:u}},fo=(e=n())=>({queryKey:[e,`speech`,`settings`],queryFn:({signal:e})=>c(e,async e=>{let t=await a(`/api/voice/settings`,{signal:e});if(!t.ok)throw Error(`Unable to load speech settings`);return Oe(await t.json())}),staleTime:3e4,networkMode:`always`,retry:1,refetchOnWindowFocus:!0}),po=()=>{let e=(0,K.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=fo(),e[0]=t):t=e[0],P(t)};async function mo(e,t=i(),r=n()){let{queryKey:o}=fo(r);if(await l.cancelQueries({queryKey:o,exact:!0}),t!==i())throw Error(`Runtime changed`);let s=await c(new AbortController().signal,async t=>{let n=await a(`/api/voice/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),signal:t});if(!n.ok)throw Error(`Unable to save speech settings`);return Oe(await n.json())});if(t!==i()||r!==n()||(await l.cancelQueries({queryKey:o,exact:!0}),t!==i()))throw Error(`Runtime changed`);return l.setQueryData(o,s),s}export{zr as $,At as $t,ea as A,Mn as At,Yi as B,An as Bt,va as C,Xn as Ct,wa as D,In as Dt,ka as E,Kn as Et,ca as F,Dn as Ft,Di as G,tn as Gt,Ni as H,dn as Ht,ia as I,On as It,yi as J,Rt as Jt,Oi as K,rn as Kt,$i as L,wn as Lt,na as M,En as Mt,la as N,Cn as Nt,ua as O,jn as Ot,aa as P,yn as Pt,qr as Q,Mt as Qt,Qi as R,Sn as Rt,Oa as S,nr as St,_a as T,Wn as Tt,Mi as U,sn as Ut,Ui as V,kn as Vt,Ci as W,on as Wt,_i as X,Nt as Xt,bi as Y,kt as Yt,di as Z,Pt as Zt,xa as _,rr as _t,no as a,qt as an,br as at,pa as b,Qn as bt,Xa as c,Zt as cn,lr as ct,Wa as d,vt as dn,dr as dt,jt as en,Ar as et,Ha as f,fr as ft,Da as g,tr as gt,Ea as h,Ln as ht,uo as i,Yt as in,Mr as it,ra as j,Nn as jt,sa as k,Pn as kt,eo as l,gt as ln,ur as lt,Ta as m,cr as mt,fo as n,Lt as nn,Pr as nt,io as o,Jt as on,hr as ot,Va as p,mr as pt,vi as q,nn as qt,po as r,Ft as rn,Fr as rt,Za as s,Xt as sn,sr as st,mo as t,It as tn,Nr as tt,Pa as u,_t as un,pr as ut,Sa as v,Yn as vt,ha as w,er as wt,Ca as x,$n as xt,ma as y,Zn as yt,Xi as z,Tn as zt};
|