@openchambery/web 2.0.5-beta.2 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/assets/{AssistantView-B2cKivcI.js → AssistantView-kXN4mz6j.js} +3 -3
  2. package/dist/assets/{DiagramView-DTEGhZ5W.js → DiagramView-CGLAl3iS.js} +1 -1
  3. package/dist/assets/MarkdownRenderer-DA08bZsM.js +2 -0
  4. package/dist/assets/{MarkdownRendererImpl-BPzp9tJC.js → MarkdownRendererImpl-qaVTVCHe.js} +1 -1
  5. package/dist/assets/{MarkstreamRendererImpl-D9QIVGm7.js → MarkstreamRendererImpl-CQdVI8Vx.js} +1 -1
  6. package/dist/assets/{MobileDetailNavigation-aYp44pDd.js → MobileDetailNavigation-xaAVkxD-.js} +1 -1
  7. package/dist/assets/{MobileShareBridge-HjnqqHZ7.js → MobileShareBridge-z2TFroKY.js} +1 -1
  8. package/dist/assets/MobileTabPageHeader-DPlvhJFe.js +2 -0
  9. package/dist/assets/{MultiRunWindow-n7eHJXwc.js → MultiRunWindow-vJc2NLzu.js} +1 -1
  10. package/dist/assets/{SettingsView-CI838_aL.js → SettingsView-BG7DgHmP.js} +6 -6
  11. package/dist/assets/{SettingsWindow-DoPGXpMp.js → SettingsWindow-3QrhPfuk.js} +1 -1
  12. package/dist/assets/{TerminalView-D2JXXNMy.js → TerminalView-Ciw0BIiz.js} +1 -1
  13. package/dist/assets/{ToolOutputDialog-BWp96snp.js → ToolOutputDialog-D_23USz-.js} +1 -1
  14. package/dist/assets/{appThemeRegistry-DeunlP8v.js → appThemeRegistry-lhAKuFFB.js} +1 -1
  15. package/dist/assets/{fileMentionTouchSelection-CQDL-tY1.js → fileMentionTouchSelection-DPSC4Fx2.js} +1 -1
  16. package/dist/assets/{gitApi-CWT__XuO.js → gitApi-DeWWyR94.js} +3 -3
  17. package/dist/assets/insertionBoundaries-aV1Cm6zA.js +1 -0
  18. package/dist/assets/{main-BMWdT13l.js → main-0XIuL0dd.js} +11 -11
  19. package/dist/assets/{main-DoEga-Rx.js → main-DZGXa6wk.js} +2 -2
  20. package/dist/assets/{mcpQueries-o7eJn0o6.js → mcpQueries-pTPWjOQO.js} +1 -1
  21. package/dist/assets/{miniChat-CuxjddEP.js → miniChat-C8K4fwOO.js} +2 -2
  22. package/dist/assets/{mobile-CBTA-4pc.js → mobile-Brtl2UnC.js} +2 -2
  23. package/dist/assets/multirun-B7FPVrQ-.js +3 -0
  24. package/dist/assets/{projectMeta-DqmtxS1O.js → projectMeta-D_jCNzjw.js} +1 -1
  25. package/dist/assets/{renderElectronMiniChatApp-DVvioeYa.js → renderElectronMiniChatApp-e6XqcsYi.js} +2 -2
  26. package/dist/assets/renderMobileApp-BQenfg50.js +28 -0
  27. package/dist/assets/{runtimeConfig-Bi3ZSSO_.js → runtimeConfig-CJE7T1Sr.js} +1 -1
  28. package/dist/assets/{runtimeEndpointReset-uBgv2tJJ.js → runtimeEndpointReset-DULSaOrI.js} +6 -6
  29. package/dist/assets/{sessionChangeSummary-sOlMM_Ae.js → sessionChangeSummary-CVZBClsA.js} +1 -1
  30. package/dist/assets/{sessionLookup-DnMv1umH.js → sessionLookup--qnazVNO.js} +1 -1
  31. package/dist/assets/{useAppFontEffects-BDWd2e-G.js → useAppFontEffects-BHenW5Q2.js} +53 -53
  32. package/dist/assets/{useDesktopWindowControlsLayout-Az2iIylx.js → useDesktopWindowControlsLayout-BGgoqF_n.js} +1 -1
  33. package/dist/assets/{useEffectiveDirectory-BaxTMaJc.js → useEffectiveDirectory-CF16bcpx.js} +1 -1
  34. package/dist/assets/useMobileNavigationStore-DBML5LIl.js +415 -0
  35. package/dist/assets/{useSessionAutoCleanup-BwPPCXI7.js → useSessionAutoCleanup-moxr9XbA.js} +1 -1
  36. package/dist/assets/{useWorkerHighlightedLines-xIKQgP7L.js → useWorkerHighlightedLines-DYVg-cuB.js} +1 -1
  37. package/dist/index.html +2 -2
  38. package/dist/mini-chat.html +2 -2
  39. package/dist/mobile.html +2 -2
  40. package/package.json +1 -1
  41. package/server/lib/question-auto-delegate/DOCUMENTATION.md +4 -0
  42. package/server/lib/question-auto-delegate/core.d.ts +5 -0
  43. package/server/lib/question-auto-delegate/core.js +62 -13
  44. package/server/lib/question-auto-delegate/form-io.js +4 -1
  45. package/server/lib/question-auto-delegate/pause-store.d.ts +7 -0
  46. package/server/lib/question-auto-delegate/pause-store.js +39 -0
  47. package/server/lib/question-auto-delegate/runtime.js +3 -0
  48. package/server/lib/question-auto-delegate/runtime.test.js +128 -1
  49. package/dist/assets/MarkdownRenderer-CYMeciqE.js +0 -2
  50. package/dist/assets/MobileTabPageHeader-BR0Wft7i.js +0 -2
  51. package/dist/assets/insertionBoundaries-BYJsPuWp.js +0 -1
  52. package/dist/assets/multirun-BSaqapqR.js +0 -3
  53. package/dist/assets/renderMobileApp-CGdrg3tm.js +0 -28
  54. package/dist/assets/useMobileNavigationStore-CcDPbboc.js +0 -415
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/assistant-attachment-cache-sG8YQsVs.js","assets/rolldown-runtime-C0FnF6B9.js","assets/runtime-auth-D66yq6ie.js","assets/runtime-switch-BJM2k_uH.js","assets/runtime-fetch-CiqQd__Y.js","assets/relay-image-stream-D2XooXKZ.js","assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js","assets/dualLimitLru-D8Sphgua.js"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{i as t,l as n}from"./runtime-switch-BJM2k_uH.js";import{n as r}from"./runtime-fetch-CiqQd__Y.js";import{$t as i,On as a,d as o,en as s,f as c,it as l,rn as u}from"./persistence-Dnj1QOdX.js";import{h as d}from"./desktopHosts-DuftEj8B.js";import{i as f,n as p,r as m}from"./desktopRelayRestore-g378BdZf.js";import{A as h,D as g,E as _,F as v,I as y,M as b,N as x,P as S,j as C,k as w,nt as T,rt as E,tt as D}from"./vendor-base-ui-CnHfUmDN.js";import{Fn as O,Nt as k}from"./platform-wu6wSDfg.js";import{n as A}from"./useUIStore-Dfx6TKvi.js";import{n as j}from"./vendor-react-DLPElpoQ.js";import{o as M}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as ee}from"./vendor-tanstack-query-core-BWz0ose6.js";import{i as te,l as N,n as ne,r as re,s as ie}from"./vendor-tanstack-react-query-D7pys_c9.js";import{P,V as F,a as I,f as L,l as R}from"./vendor-codemirror-autocomplete-DHomsvW7.js";import{c as ae,o as z,r as oe}from"./vendor-codemirror-lang-angular-DShkBD6m.js";import{n as B,r as se}from"./vendor-codemirror-lang-json-CYJRHck9.js";import{n as V}from"./vendor-codemirror-lang-markdown-WORgx6ZD.js";import{n as ce}from"./vendor-codemirror-lang-python-Du6XQ8Zw.js";import{O as le}from"./vendor-codemirror-legacy-modes-DuRAjNvB.js";import{n as ue}from"./vendor-reactuses-core-Dq5ocTF8.js";import{d as de,f as fe,l as pe,p as H,r as U,t as me}from"./button-CUwjpv-i.js";import{i as he,t as ge}from"./store-l_X_jQNz.js";import{Dr as _e,Ea as ve,Ja as ye,Oa as be,Pa as xe,_r as Se,d as Ce,da as we,jr as Te,pa as W,wr as Ee}from"./useMobileNavigationStore-CcDPbboc.js";import{t as De}from"./AgentAvatar-C1MGZ7qC.js";import{n as G}from"./Icon-BdzPRCSy.js";import{i as Oe,n as ke,r as Ae,t as je}from"./vendor-simplewebauthn-browser-Dwhcdg_5.js";import{C as Me,D as Ne,O as Pe,S as Fe,T as Ie,w as Le}from"./projectMeta-DqmtxS1O.js";import{t as Re}from"./input-BeVw4D0W.js";import{t as ze}from"./useThemeSystem-DMzWVJaW.js";import{i as Be}from"./OverlayScrollbar-C1C2aKOe.js";import{_ as Ve,g as He,h as Ue,i as We,n as Ge,v as Ke}from"./textarea-Kl-rTWJe.js";import{n as qe,r as Je,t as Ye}from"./dropdown-menu.styles-ayLWk2gf.js";import{t as Xe}from"./vendor-codemirror-language-data-BfYFhIH1.js";var K=j(),Ze=[`desktopHostSwitch`],Qe=class extends Error{result;host;constructor(e,t){super(e.reason),this.name=`DesktopHostSwitchError`,this.result=e,this.host=t}},$e=(e,t)=>ge(he.getState().dictionary,e,t),et=async e=>{let{host:t}=e;if(t.id===`local`){let r=(e.localApiOrigin||``).trim();if(!r)throw new Qe({ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unreachable`},t);return n({apiBaseUrl:r,clientToken:e.localClientToken||null,runtimeKey:m(t)}),{ok:!0,via:`direct`,status:{status:`ok`,latencyMs:0}}}let r=await f(t,{cachedProbe:e.cachedProbe});if(!r.ok)throw new Qe(r,t);return r},tt=null,nt=()=>tt||(tt=new ee(o,{mutationKey:Ze,mutationFn:et,onError:(e,t)=>{if(e instanceof Qe&&e.result.reason!==`unsupported`){if(e.result.status.status===`auth`){Te.error($e(`desktopHostSwitcher.status.authRequired`));return}Te.error($e(`desktopHostSwitcher.toast.instanceUnreachable`,{host:d(t.host.label)}))}}}),tt.subscribe(()=>void 0),tt),rt=async e=>{if(p(e.host))return{ok:!0,via:`direct`,status:e.cachedProbe?.status===`ok`?e.cachedProbe:{status:`ok`,latencyMs:0}};if(o.isMutating({mutationKey:Ze})>0)return{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unsupported`};try{return await nt().mutate(e)}catch(e){if(e instanceof Qe)return e.result;throw e}},it=()=>{let e=(0,K.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={mutationKey:Ze},e[0]=t):t=e[0],re(t)>0},at=()=>{let e=(0,K.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={filters:{mutationKey:Ze,status:`pending`},select:ot},e[0]=t):t=e[0],te(t)[0]?.host.id??null};function ot(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},st=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],ct=()=>i()?(e,t)=>s(e,t):null,lt=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}:{}}},ut=e=>e===`remote`||e===`dynamic`?e:`local`,dt=e=>{if(!q(e))return null;let t=J(e,`id`);if(!t)return null;let n=X(e,`enabled`)??!0,r=ut(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}:{}}},ft=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:st(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=>dt(e)).filter(e=>!!e),h=Y(o,`preferredPort`)??Y(o,`preferred_port`),g=Y(s,`preferredLocalPort`)??Y(s,`preferred_local_port`),_=lt(c.sshPassword||c.ssh_password),v=lt(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}},pt=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`}},mt=e=>{if(!q(e))return null;let t=J(e,`id`);return t?{id:t,phase:pt(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},ht=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}},gt=(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:[]}),_t=async()=>{let e=ct();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=>ft(e)).filter(e=>!!e)}:{instances:[]}},vt=async e=>{let t=ct();t&&await t(`desktop_ssh_instances_set`,{config:{instances:e.instances}})},yt=async()=>{let e=ct();if(!e)return[];let t=await e(`desktop_ssh_import_hosts`);return Array.isArray(t)?t.map(e=>ht(e)).filter(e=>!!e):[]},bt=async e=>{let t=ct();t&&await t(`desktop_ssh_connect`,{id:e})},xt=async e=>{let t=ct();t&&await t(`desktop_ssh_disconnect`,{id:e})},St=async e=>{let t=ct();if(!t)return[];let n=await t(`desktop_ssh_status`,{...e?{id:e}:{}});return Array.isArray(n)?n.map(e=>mt(e)).filter(e=>!!e):[]},Ct=async(e,t)=>{let n=ct();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`):[]},wt=async e=>{let t=ct();t&&await t(`desktop_ssh_logs_clear`,{id:e})},Tt=(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}},Et=e=>{if(!q(e))return null;let t=J(e,`path`),n=Y(e,`bytes`);return!t||n===null?null:{path:t,bytes:n}},Dt=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}},Ot=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}},kt=e=>{if(e==null||!q(e))return null;let t=Y(e,`bytes`);return t===null?null:{bytes:t}},At=e=>{if(!q(e))return null;let t=Array.isArray(e.files)?e.files:null,n=Array.isArray(e.directories)?e.directories:null,r=st(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=>Et(e)).filter(e=>!!e),o=n.map(e=>Dt(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:Ot(s);if(s!=null&&c===null)return null;let l=e.authFile??e.auth_file,u=l==null?null:kt(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=jt(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}:{}}},jt=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}},Mt=e=>{if(!q(e))return null;let t=At(e.plan);if(!t)return null;let n=jt(e.selectionShape??e.selection_shape)??t.selectionShape??null;return{plan:t,remoteExisting:st(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}:{}}},Nt=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:kt(s);return{ok:!0,files:t,directories:n,deletes:r,totalBytes:i,agentsRoot:o,authFile:c}},Pt=async(e={})=>{let t=ct();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=At(n.plan);if(!r)return console.error(`[desktopSsh] config sync local scan plan payload was not recognized`,n),null;let i=jt(n.selectionShape??n.selection_shape)??r.selectionShape??null;return i?{...r,selectionShape:i}:r},Ft=async(e,t={})=>{let n=ct();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=Mt(r);return i||console.error(`[desktopSsh] config sync preview payload was not recognized`,r),i},It=async(e,t={})=>{let n=ct();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=Nt(r);return i||console.error(`[desktopSsh] config sync apply payload was not recognized`,r),i},Lt=async(e,t={})=>{let n=ct();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`):[]},Rt=async e=>{if(!i())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=mt(t?.payload);n&&e(n)});return async()=>{await n()}},zt=new Set([`nodeRuntimeMissing`,`packageManagerMissing`,`nativeBinding`,`openchamberCliMissing`,`openchamberRegistry`,`openchamberInstall`,`openchamberCliIncompatible`,`opencodeInstall`,`serverStart`,`sshAuth`,`sshUnreachable`,`timeout`,`unknown`]),Bt=e=>typeof e==`string`&&zt.has(e),Vt=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`},Ht=(e,t)=>Bt(e)?e:Vt(t),Ut=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`}},Wt=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`}},Gt=e=>e===`unknown`||e===`openchamberCliIncompatible`,Kt=(e,t,n)=>{let r=typeof n==`string`?n.trim():``;return!Gt(t)||!r||r===e?e:`${e}\n${r}`},Z=T();function qt(e){let t=(0,K.c)(27),{errorCode:n,detail:r,className:i}=e,{t:a}=fe(),o,s,c,l,u,d;if(t[0]!==i||t[1]!==r||t[2]!==n||t[3]!==a){let e=Ht(n,r);o=a(Wt(e));let f;t[10]===r?f=t[11]:(f=typeof r==`string`?r.trim():``,t[10]=r,t[11]=f),s=f,c=Gt(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(Ut(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(E(),1),Jt=[.2,.45,.15,.55,.35,.1,.5,.25,.4,.3,.45,.15,.55,.2,.35,.1],Yt=[.3,.15,.45,.25,.5,.35,.1,.4,.2,.55,.3,.15,.45,.25,.4,.2],Xt=(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},Zt=({className:e=``,width:t=70,height:n=70,isAnimated:r=!1})=>{let{t:i}=fe(),a=ze(),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=Xt(h,_,b,v),C=Xt(_,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:Jt[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:Yt[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`})]})})]})},Qt=`/auth/passkey/authenticate/options`,$t=`/auth/passkey/authenticate/verify`,en=`/auth/passkey/register/options`,tn=`/auth/passkey/register/verify`,nn=`/api/passkeys`,rn=`/auth/passkey/status`,an=`/api/auth/reset`,on={enabled:!1,hasPasskeys:!1,passkeyCount:0,rpID:null},sn=async(e,t)=>r(e,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:t===void 0?void 0:JSON.stringify(t)}),cn=async(e,t)=>{try{let t=await e.json();if(t&&typeof t.error==`string`&&t.error.trim())return t.error}catch{}return t},ln=e=>e instanceof Oe&&e.code===`ERROR_CEREMONY_ABORTED`,un=()=>{Ae.cancelCeremony()},dn=()=>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.`},fn=async()=>{let e=dn();if(!e.supported)throw Error(e.reason);let t=await sn(en,{label:typeof navigator.userAgent==`string`&&navigator.userAgent.trim()?navigator.userAgent:`This device`});if(!t.ok)throw Error(await cn(t,`Could not start passkey setup.`));let{requestId:n,optionsJSON:r}=await t.json(),i=await sn(tn,{requestId:n,response:await ke({optionsJSON:r})});if(!i.ok)throw Error(await cn(i,`Could not finish passkey setup.`));return i.json().catch(()=>null)},pn=async(e,t={})=>{let n=dn();if(!n.supported)throw Error(n.reason);let r=await sn(Qt);if(!r.ok)throw Error(await cn(r,`Passkey sign-in is not available right now.`));let{requestId:i,optionsJSON:a}=await r.json(),o=await sn($t,{requestId:i,response:await je({optionsJSON:a}),trustDevice:e,issueClientToken:t.issueClientToken===!0,clientLabel:t.clientLabel,clientKind:t.clientKind,dedupeKey:t.dedupeKey});if(!o.ok)throw Error(await cn(o,`Passkey sign-in failed.`));return o.json().catch(()=>null)},mn=async()=>{let e=await r(rn,{method:`GET`,credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return on;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}},hn=async()=>{let e=await r(nn,{method:`GET`,credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(await cn(e,`Could not load passkeys.`));let t=await e.json().catch(()=>null);return Array.isArray(t?.passkeys)?t.passkeys:[]},gn=async e=>{let t=await r(`${nn}/${encodeURIComponent(e)}`,{method:`DELETE`,credentials:`include`,headers:{Accept:`application/json`}});if(!t.ok)throw Error(await cn(t,`Could not remove passkey.`));return t.json().catch(()=>null)},_n=async()=>{let e=await sn(an);if(!e.ok)throw Error(await cn(e,`Could not clear saved authentication.`));try{let{clearAssistantAttachmentCacheAll:e}=await M(async()=>{let{clearAssistantAttachmentCacheAll:e}=await import(`./assistant-attachment-cache-sG8YQsVs.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-D66yq6ie.js`).then(e=>e.m);return{invalidateRuntimeAuthSession:e}},__vite__mapDeps([2,1]));await e(`auth-reset`),t()}catch{}return e.json().catch(()=>null)};function vn(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 yn(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 bn(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 xn(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 Sn=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 de(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)(vn,{className:`w-full max-w-md`,children:[(0,Z.jsx)(yn,{className:`text-center`,children:(0,Z.jsxs)(bn,{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)(xn,{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)(me,{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)(me,{onClick:this.handleCopy,variant:`outline`,className:`flex-1`,children:this.state.copied?e.copied:e.copy})]})]})]})}):this.props.children}},Cn=e=>{let t=(0,K.c)(29),{children:n,fallback:r}=e,{t:i}=fe(),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)(Sn,{fallback:r,strings:m,children:n}),t[25]=n,t[26]=r,t[27]=m,t[28]=h):h=t[28],h},wn=`__unassigned__`,Tn={mod:`mod`,shift:`shift`,alt:`alt`,option:`alt`,ctrl:`ctrl`,meta:`mod`,cmd:`mod`,command:`mod`},En={mod:pe()?`⌘`:`Ctrl`,shift:`⇧`,alt:`⌥`,option:`⌥`,ctrl:`⌃`},Dn={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:`-`,"-":`-`},On=[`mod`,`ctrl`,`shift`,`alt`],kn={"{":`[`,"}":`]`,":":`;`,'"':`'`,"<":`,`,">":`.`,"?":`/`,"|":`\\`,"~":"`","!":`1`,"@":`2`,"#":`3`,$:`4`,"%":`5`,"^":`6`,"&":`7`,"*":`8`,"(":`9`,")":`0`};function An(e){return e.trim().toLowerCase()===wn}function jn(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`:kn[t]??t}var Mn=[{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 Nn(e){if(An(e))return wn;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=Tn[t];if(i){n.add(i);continue}r=t}return[...On.filter(e=>n.has(e)),r].filter(Boolean).join(`+`)}function Pn(e){return An(e)?!0:Fn(e).key.trim().length>0}function Fn(e){if(An(e))return{modifiers:new Set,key:wn};let t=Nn(e).split(`+`),n=new Set,r=``;for(let e of t){let t=Tn[e];t?n.add(t):r=e}return{modifiers:n,key:r}}function In(e){if(An(e))return`Unassigned`;let t=Fn(e);if(!t.key&&t.modifiers.size===0)return`Unassigned`;let n=[];for(let e of On)t.modifiers.has(e)&&n.push(En[e]);if(t.key){let e=Dn[t.key.toLowerCase()]||t.key.toUpperCase();n.push(e)}return n.join(` + `)}function Ln(e){return Mn.find(t=>t.id===e)}function Rn(){return Mn.filter(e=>e.customizable===!0)}function zn(e,t){let n=Ln(e);if(!n)return``;let r=t?.[e];if(typeof r==`string`){if(r.trim().toLowerCase()===`__unassigned__`)return``;let e=Nn(r);if(e===`__unassigned__`)return wn;if(Pn(e))return e}return n.defaultCombo}function Bn(e,t){let n=Ln(e);if(!n)return[];let r=zn(e,t);return r===n.defaultCombo?[n.defaultCombo,...n.defaultAliases??[]]:r?[r]:[]}function Vn(e){if(An(e))return!1;let t=Fn(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 Hn(e,t){let n=typeof t==`string`?t:t.defaultCombo;if(An(n))return!1;let r=Fn(n),i=r.modifiers.has(`mod`),a=r.modifiers.has(`shift`),o=r.modifiers.has(`alt`),s=r.modifiers.has(`ctrl`),c=pe()&&u(),l=pe(),d=c?e.metaKey:l&&e.metaKey||e.ctrlKey;if(i&&!d||!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))),jn(f)===jn(r.key)}function Un(){return pe()?`⌘`:`Ctrl`}function Wn(e,t,n){if(Hn(e,n))return!0;let r=Nn(n),i=pe()&&u(),a=pe();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 Gn=Q.createContext(null),Kn=e=>e?e.closest(`[data-slot="dialog-content"], [role="dialog"]`):null;function qn(e,t){return e&&Q.isValidElement(t)?{render:t}:{children:t}}function Jn(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)(w,{...n}),t[4]=n,t[5]=s);let c;return t[6]!==o||t[7]!==s?(c=(0,Z.jsx)(Gn.Provider,{value:o,children:s}),t[6]=o,t[7]=s,t[8]=c):c=t[8],c}function Yn(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(Gn),c;t[6]===s?c=t[7]:(c=e=>{if(!s)return;let t=e instanceof HTMLElement?e:null;s.setPortalContainer(Kn(t))},t[6]=s,t[7]=c);let l=c,u;t[8]!==n||t[9]!==r?(u=qn(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)(g,{"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 Xn(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,y;t[14]===m?y=t[15]:(y=m===void 0?{side:`shift`,align:`shift`}:m,t[14]=m,t[15]=y);let b=y,C=Q.useContext(Gn),w=g?void 0:C?.portalContainer||void 0,T;t[16]===s?T=t[17]:(T=U(`app-region-no-drag z-50`,s),t[16]=s,t[17]=T);let E;t[18]===u?E=t[19]:(E={backgroundColor:`var(--surface-elevated)`,color:`var(--surface-elevated-foreground)`,...u},t[18]=u,t[19]=E);let D;t[20]===o?D=t[21]:(D=U(qe,o),t[20]=o,t[21]=D);let O;t[22]!==a||t[23]!==c||t[24]!==E||t[25]!==D?(O=(0,Z.jsx)(v,{"data-slot":`dropdown-menu-content`,style:E,className:D,...c,children:a}),t[22]=a,t[23]=c,t[24]=E,t[25]=D,t[26]=O):O=t[26];let k;t[27]!==n||t[28]!==r||t[29]!==i||t[30]!==b||t[31]!==_||t[32]!==l||t[33]!==h||t[34]!==O||t[35]!==T?(k=(0,Z.jsx)(x,{anchor:i,sideOffset:h,align:n,side:l,alignOffset:r,collisionPadding:_,collisionAvoidance:b,className:T,children:O}),t[27]=n,t[28]=r,t[29]=i,t[30]=b,t[31]=_,t[32]=l,t[33]=h,t[34]=O,t[35]=T,t[36]=k):k=t[36];let A;return t[37]!==k||t[38]!==w?(A=(0,Z.jsx)(S,{container:w,children:k}),t[37]=k,t[38]=w,t[39]=A):A=t[39],A}function Zn(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=qn(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(Ye,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)(y,{"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 Qn(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)(b,{"data-slot":`dropdown-menu-radio-group`,...n}),t[2]=n,t[3]=r),r}function $n(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)(h,{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 er(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 tr(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(Je,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(_,{"data-slot":`dropdown-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function nr(){let e=(0,K.c)(5),t=W(or),n=W(ar),r=W(ir),i=W(rr),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 rr(e){return e.providers.length>0}function ir(e){return e.lastDisconnectReason}function ar(e){return e.connectionPhase}function or(e){return e.isInitialized}var sr=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}=fe(),{isReady:f,isUnavailable:p}=nr(),m=W(cr),h=xe(lr),g=W(ur),{data:_}=ye(),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=be(x);S=a?e.filter(a):e,t[2]=a,t[3]=x,t[4]=S}else S=t[4];let C=S,w=A(dr),{isMobile:T}=Be(),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 j=ue(k),M=ue(fr),ee=Q.useId(),te,N;t[6]!==c||t[7]!==h||t[8]!==g||t[9]!==x.length?(te=()=>{c||x.length>0||(g(),h())},N=[c,x.length,g,h],t[6]=c,t[7]=h,t[8]=g,t[9]=x.length,t[10]=te,t[11]=N):(te=t[10],N=t[11]),Q.useEffect(te,N);let ne;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(ne=()=>O(!1),t[12]=ne):ne=t[12];let re=ne,ie;t[13]===r?ie=t[14]:(ie=e=>{r(e)},t[13]=r,t[14]=ie);let P=ie,F;t[15]!==n||t[16]!==C||t[17]!==P||t[18]!==E||t[19]!==D||t[20]!==ee||t[21]!==d?(F=()=>E?(0,Z.jsx)(We,{id:`mobile-agent-selector-sheet-${ee}`,open:D,onOpenChange:e=>{e||re()},ariaLabel:d(`settings.commands.agentSelector.title`),closeAriaLabel:d(`mobile.surface.closeAria`),resizeAriaLabel:d(`mobile.sessions.sheet.resizeAria`),bodyClassName:`px-2`,children:(0,Z.jsxs)(Ge,{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:()=>{P(``),re()},children:[(0,Z.jsx)(De,{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:()=>{P(e.name),re()},children:[(0,Z.jsx)(De,{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]=P,t[18]=E,t[19]=D,t[20]=ee,t[21]=d,t[22]=F):F=t[22];let I=F,L;t[23]!==n||t[24]!==C||t[25]!==i||t[26]!==l||t[27]!==P||t[28]!==M||t[29]!==E||t[30]!==f||t[31]!==p||t[32]!==j||t[33]!==u||t[34]!==d?(L=E?(0,Z.jsxs)(`button`,{type:`button`,onClick:f?j: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)(De,{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)(Jn,{onOpenChange:M,children:[(0,Z.jsx)(Yn,{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)(De,{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)(Xn,{className:`max-w-[300px]`,portalToBody:l,children:[(0,Z.jsxs)(Zn,{className:`typography-meta`,onSelect:()=>P(``),children:[(0,Z.jsx)(De,{name:`default`,size:14}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:d(`settings.commands.agentSelector.notSelected`)})]}),C.map(e=>(0,Z.jsxs)(Zn,{className:`typography-meta`,onSelect:()=>P(e.name),children:[(0,Z.jsx)(De,{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]=P,t[28]=M,t[29]=E,t[30]=f,t[31]=p,t[32]=j,t[33]=u,t[34]=d,t[35]=L):L=t[35];let R;t[36]===I?R=t[37]:(R=I(),t[36]=I,t[37]=R);let ae;return t[38]!==L||t[39]!==R?(ae=(0,Z.jsxs)(Z.Fragment,{children:[L,R]}),t[38]=L,t[39]=R,t[40]=ae):ae=t[40],ae};function cr(e){return e.agents}function lr(e){return e.loadAgents}function ur(e){return e.loadAgents}function dr(e){return e.isMobile}function fr(e){e&&W.getState().refreshCatalogsOnPickerOpen({source:`agentSelector:desktopMenu`})}var pr={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}},mr=null,hr={},gr=(e,t)=>{mr!==t&&(mr=t,hr.compact=void 0,hr.compactTokensShort=void 0,hr.usd=void 0);let n=hr[e];if(n)return n;let r=new Intl.NumberFormat(t,pr[e]);return hr[e]=r,r},_r=(e,t=H())=>gr(`compact`,t).format(e),vr=(e,t=H())=>gr(`compactTokensShort`,t).format(e),yr=(e,t=H())=>gr(`usd`,t).format(e),br=(e,t=H())=>e.toLocaleDateString(t,{month:`short`,day:`numeric`,year:`numeric`}),xr=(e,t=H())=>new Date(e).toLocaleDateString(t,{year:`numeric`,month:`short`,day:`numeric`}),Sr=(e,t=H())=>new Date(e).toLocaleTimeString(t,{hour:`numeric`,minute:`2-digit`}),Cr=8,wr=e=>typeof e!=`number`||Number.isNaN(e)?``:vr(e),Tr=(e,t,n)=>{let r=e.find(e=>e.id===t)?.models?.find(e=>e.id===n);return r?.variants?Object.keys(r.variants):[]},Er=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}=fe(),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,M]=Q.useState(null),[ee,te]=Q.useState(`model`),[N,ne]=Q.useState(null),re=Q.useRef(!1),ie=y??ee,P,F;t[4]!==n||t[5]!==i?(P=()=>{n&&!re.current&&A(new Set(i?[i]:[])),n||(D(``),M(null),te(`model`),ne(null)),re.current=n},F=[n,i],t[4]=n,t[5]=i,t[6]=P,t[7]=F):(P=t[6],F=t[7]),Q.useEffect(P,F);let I;t[8]===b?I=t[9]:(I=e=>{te(e),b?.(e)},t[8]=b,t[9]=I);let L=I,R=ie===`variant`&&!!(N??(i&&a)),ae=`mobile-model-picker-sheet-${T}`,z;t[10]===r?z=t[11]:(z=e=>{e||r()},t[10]=r,t[11]=z);let oe;t[12]!==R||t[13]!==L||t[14]!==w?(oe=R?(0,Z.jsx)(me,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>L(`model`),"aria-label":w(`onboarding.common.actions.back`),children:(0,Z.jsx)(G,{name:`arrow-left`,className:`size-5`})}):void 0,t[12]=R,t[13]=L,t[14]=w,t[15]=oe):oe=t[15];let B;t[16]!==R||t[17]!==w?(B=w(R?`chat.modelControls.thinking`:`chat.modelControls.selectModel`),t[16]=R,t[17]=w,t[18]=B):B=t[18];let se;t[19]===w?se=t[20]:(se=w(`mobile.surface.closeAria`),t[19]=w,t[20]=se);let V;t[21]===w?V=t[22]:(V=w(`mobile.sessions.sheet.resizeAria`),t[21]=w,t[22]=V);let ce;t[23]!==ie||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]!==L||t[42]!==C||t[43]!==N?(ce=(0,Z.jsx)(Dr,{query:E,onQueryChange:D,expandedProviders:k,onExpandedProvidersChange:A,expandedModelKey:j,onExpandedModelKeyChange:M,activeView:ie,setView:L,variantTarget:N,onVariantTargetChange:ne,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]=ie,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]=L,t[42]=C,t[43]=N,t[44]=ce):ce=t[44];let le;return t[45]!==n||t[46]!==oe||t[47]!==B||t[48]!==se||t[49]!==V||t[50]!==ce||t[51]!==ae||t[52]!==z?(le=(0,Z.jsx)(We,{id:ae,open:n,onOpenChange:z,leading:oe,ariaLabel:B,closeAriaLabel:se,resizeAriaLabel:V,bodyClassName:`px-2`,children:ce}),t[45]=n,t[46]=oe,t[47]=B,t[48]=se,t[49]=V,t[50]=ce,t[51]=ae,t[52]=z,t[53]=le):le=t[53],le},Dr=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}=fe(),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(Or)):null,t[2]=x,t[3]=A);let j=A,M;t[4]===y?M=t[5]:(M=new Set(y.map(kr)),t[4]=y,t[5]=M);let ee=M,te;t[6]===g?te=t[7]:(te=new Map(g.map(Ar)),t[6]=g,t[7]=te);let N=te,ne;bb0:{if(!S?.length){ne=g;break bb0}let e;t[8]===S?e=t[9]:(e=new Map(S.map(jr)),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];ne=r}let re=ne,ie;t[15]!==j||t[16]!==k||t[17]!==ee?(ie=(e,t)=>k&&!k.has(e)||j&&j.get(e)?.has(t)!==!0?!1:!ee.has(`${e}:${t}`),t[15]=j,t[16]=k,t[17]=ee,t[18]=ie):ie=t[18];let P=ie,F;t[19]!==N||t[20]!==n?(F=e=>{let t=n.trim();if(!t)return!0;let r=N.get(e.providerID)?.name||e.providerID,i=ve(e.model,e.modelID,{maxLength:40});return Me(i,t)||Me(e.modelID,t)||Me(r,t)},t[19]=N,t[20]=n,t[21]=F):F=t[21];let I=F,L;if(t[22]!==_||t[23]!==P||t[24]!==I){let e;t[26]!==P||t[27]!==I?(e=e=>P(e.providerID,e.modelID)&&I(e),t[26]=P,t[27]=I,t[28]=e):e=t[28],L=_.filter(e),t[22]=_,t[23]=P,t[24]=I,t[25]=L}else L=t[25];let R=L,ae;if(t[29]!==P||t[30]!==I||t[31]!==v){let e;t[33]!==P||t[34]!==I?(e=e=>P(e.providerID,e.modelID)&&I(e),t[33]=P,t[34]=I,t[35]=e):e=t[35],ae=v.filter(e),t[29]=P,t[30]=I,t[31]=v,t[32]=ae}else ae=t[32];let z=ae,oe;if(t[36]!==k||t[37]!==P||t[38]!==re||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),oe=re.filter(r).map(t=>{let n=e.length>0&&(Me(t.name||t.id,e)||Me(t.id,e));return{provider:t,models:(t.models??[]).filter(r=>{let i=typeof r.id==`string`?r.id:``;return!i||!P(t.id,i)?!1:n||!e?!0:Me(ve(r,i,{maxLength:40}),e)||Me(i,e)})}}).filter(Mr),t[36]=k,t[37]=P,t[38]=re,t[39]=n,t[40]=oe}else oe=t[40];let B=oe,se;t[43]===D?se=t[44]:(se=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]=se);let V=se,ce;t[45]===D?ce=t[46]:(ce=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]=ce);let le=ce,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,pe;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(pe={onPointerDown:He,onClickCapture:Nr},t[50]=pe):pe=t[50];let H=pe,me;t[51]!==o||t[52]!==V||t[53]!==E||t[54]!==le||t[55]!==w||t[56]!==s||t[57]!==h||t[58]!==T||t[59]!==de||t[60]!==N||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=Le(i,r,E?.(i,a)),d=C?Tr(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,Cr),S=o===c,O=le(u),k=u?.limit?.context?`${wr(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`,...H,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:N.get(i)?.name||i}):null,(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Z.jsx)(Pe,{modelId:a,providerId:i,className:`size-3.5 flex-shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate typography-meta font-medium text-foreground`,children:ve(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`,...H,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:V(b)}),(0,Z.jsx)(G,{name:S?`arrow-down-s`:`arrow-right-s`,className:`size-3.5`})]}):null,(0,Z.jsx)(`button`,{type:`button`,...H,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`,...H,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:V(e)},`${c}-${e??`default`}`)}),x.length<d.length+1?(0,Z.jsx)(`button`,{type:`button`,...H,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]=V,t[53]=E,t[54]=le,t[55]=w,t[56]=s,t[57]=h,t[58]=T,t[59]=de,t[60]=N,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 he=me,ge,_e,ye,be,xe,Se,Ce,we,Te,W;if(t[68]!==c||t[69]!==i||t[70]!==R||t[71]!==B||t[72]!==z||t[73]!==V||t[74]!==s||t[75]!==a||t[76]!==r||t[77]!==h||t[78]!==g||t[79]!==n||t[80]!==he||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?Tr(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,_=R.length>0||z.length>0||B.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)(Re,{type:`text`,value:n,onChange:e=>{r(e.target.value),s(null)},onPointerUp:Pr,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],ge=Ge,be=!0,xe=!0,Se=!0,Ce=`min-h-0 flex-1`,we=`overscroll-contain`,_e=`flex flex-col gap-2`,ye=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`),...H,onClick:()=>h(e.providerID,e.modelID,t),children:[(0,Z.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:V(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`)}),R.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:R.map(e=>he(e,{showProvider:!0,preferRememberedVariant:!0}))})]}):null,z.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:z.map(e=>he(e,{showProvider:!0,preferRememberedVariant:!0}))})]}):null,B.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`,...H,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)(Ie,{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=>he({model:e,providerID:t.id,modelID:e.id}))}):null]},t.id)})]}),t[68]=c,t[69]=i,t[70]=R,t[71]=B,t[72]=z,t[73]=V,t[74]=s,t[75]=a,t[76]=r,t[77]=h,t[78]=g,t[79]=n,t[80]=he,t[81]=m,t[82]=p,t[83]=f,t[84]=D,t[85]=u,t[86]=ge,t[87]=_e,t[88]=ye,t[89]=be,t[90]=xe,t[91]=Se,t[92]=Ce,t[93]=we,t[94]=Te,t[95]=W}else ge=t[86],_e=t[87],ye=t[88],be=t[89],xe=t[90],Se=t[91],Ce=t[92],we=t[93],Te=t[94],W=t[95];let Ee;t[102]!==_e||t[103]!==ye?(Ee=(0,Z.jsx)(`div`,{className:_e,children:ye}),t[102]=_e,t[103]=ye,t[104]=Ee):Ee=t[104];let De;t[105]!==ge||t[106]!==be||t[107]!==xe||t[108]!==Se||t[109]!==Ce||t[110]!==we||t[111]!==Ee?(De=(0,Z.jsx)(ge,{useScrollShadow:be,disableHorizontal:xe,preventOverscroll:Se,outerClassName:Ce,className:we,children:Ee}),t[105]=ge,t[106]=be,t[107]=xe,t[108]=Se,t[109]=Ce,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 Or(e){let[t,n]=e;return[t,new Set(n)]}function kr(e){return`${e.providerID}:${e.modelID}`}function Ar(e){return[e.id,e]}function jr(e,t){return[e,t]}function Mr(e){return e.models.length>0}function Nr(e){Ue(e)||(e.preventDefault(),e.stopPropagation())}function Pr(e){document.activeElement!==e.currentTarget&&e.currentTarget.focus({preventScroll:!0})}var Fr=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:_}=fe(),{isReady:v,isUnavailable:y}=nr(),b=W(Ir),x=p??b,S=W(Lr),C=A(Rr),w=A(zr),T=A(Br),E=A(Vr),D=A(Hr),O=A(Ur),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:j,recentModelsList:M}=Ne(k),{isMobile:ee}=Be(),te=C||ee,[N,ne]=Q.useState(!1),[re,ie]=Q.useState(!1),P;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(P=()=>{ne(!0),W.getState().refreshCatalogsOnPickerOpen({source:`modelSelector:mobilePanel`})},t[3]=P):P=t[3];let F=ue(P),I;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(I=e=>{ie(e),e&&W.getState().refreshCatalogsOnPickerOpen({source:`modelSelector:desktopMenu`})},t[4]=I):I=t[4];let L=ue(I),[R,ae]=Q.useState(``),[z,oe]=Q.useState(null),B=i!==void 0,se;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(se=()=>{ne(!1),ie(!1),ae(``),oe(null)},t[5]=se):se=t[5];let V=se,ce;t[6]===x?ce=t[7]:(ce=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]=ce);let le=ce,de;t[8]!==D||t[9]!==le||t[10]!==r||t[11]!==a||t[12]!==n||t[13]!==i||t[14]!==B?(de=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,B?c:void 0),D(e.providerID,e.modelID,B&&c||void 0),V()},t[8]=D,t[9]=le,t[10]=r,t[11]=a,t[12]=n,t[13]=i,t[14]=B,t[15]=de):de=t[15];let pe=de,H;t[16]!==a||t[17]!==B?(H=()=>{a(``,``,B?``:void 0),V()},t[16]=a,t[17]=B,t[18]=H):H=t[18];let me=H,he;t[19]!==D||t[20]!==a||t[21]!==z?(he=e=>{z&&(a(z.providerID,z.modelID,e),D(z.providerID,z.modelID,e||void 0),V())},t[19]=D,t[20]=a,t[21]=z,t[22]=he):he=t[22];let ge=he,_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 Ie;t[56]===_?Ie=t[57]:(Ie=_(`chat.modelControls.costInput`),t[56]=_,t[57]=Ie);let Le;t[58]===_?Le=t[59]:(Le=_(`chat.modelControls.costOutput`),t[58]=_,t[59]=Le);let Re;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]!==Ie||t[77]!==Le?(Re={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:Ie,costOutput:Le},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]=Ie,t[77]=Le,t[78]=Re):Re=t[78];let ze=Re,Ve;t[79]!==r||t[80]!==n?(Ve=n&&r?{providerID:n,modelID:r}:null,t[79]=r,t[80]=n,t[81]=Ve):Ve=t[81];let He=Ve,Ue;t[82]!==r||t[83]!==l||t[84]!==n||t[85]!==_?(Ue=n&&r?`${n}/${r}`:l||_(`settings.agents.modelSelector.notSelected`),t[82]=r,t[83]=l,t[84]=n,t[85]=_,t[86]=Ue):Ue=t[86];let We=Ue,Ge;t[87]!==_||t[88]!==i||t[89]!==B?(Ge=B?i||_(`chat.modelControls.default`):null,t[87]=_,t[88]=i,t[89]=B,t[90]=Ge):Ge=t[90];let Ke=Ge,qe;t[91]!==r||t[92]!==n||t[93]!==i||t[94]!==B?(qe=(e,t)=>{if(!(!B||e!==n||t!==r))return i||void 0},t[91]=r,t[92]=n,t[93]=i,t[94]=B,t[95]=qe):qe=t[95];let Je=qe,Ye;t[96]!==D||t[97]!==a||t[98]!==B?(Ye=(e,t,n)=>{a(e,t,B?n??``:void 0),D(e,t,B&&n||void 0),V()},t[96]=D,t[97]=a,t[98]=B,t[99]=Ye):Ye=t[99];let Xe=Ye,Ze;t[100]!==le||t[101]!==_||t[102]!==i||t[103]!==B?(Ze=(e,t)=>{let n=le(e);if(!B||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(),oe(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]=B,t[104]=Ze):Ze=t[104];let Qe=Ze,$e=te?`max-h-none flex-1`:void 0,et=m&&(te?N:re),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]!==j||t[115]!==S||t[116]!==pe||t[117]!==me||t[118]!==w||t[119]!==ze||t[120]!==O||t[121]!==x||t[122]!==M||t[123]!==Qe||t[124]!==R||t[125]!==He||t[126]!==$e||t[127]!==et||t[128]!==tt||t[129]!==nt?(rt=(0,Z.jsx)(Fe,{providers:x,providerOrder:O,favoriteModels:j,recentModels:M,getMetadata:S,searchQuery:R,onSearchQueryChange:ae,onSelect:pe,labels:ze,selectedModel:He,hiddenModels:w,allowedProviderIds:s,allowedModelIdsByProvider:c,includeNotSelected:!0,onSelectNone:me,onEscape:V,maxHeightClassName:$e,tooltipsEnabled:et,isFavorite:tt,onToggleFavorite:nt,renderRowEnd:Qe}),t[112]=c,t[113]=s,t[114]=j,t[115]=S,t[116]=pe,t[117]=me,t[118]=w,t[119]=ze,t[120]=O,t[121]=x,t[122]=M,t[123]=Qe,t[124]=R,t[125]=He,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]!==z?(at=z?le(z):[],t[131]=le,t[132]=z,t[133]=at):at=t[133];let ot=at,q;bb0:{if(!z){q=``;break bb0}if(z.providerID===n&&z.modelID===r){q=i||``;break bb0}q=z.variant!==void 0&&ot.includes(z.variant)?z.variant:``}let J=q,Y;t[134]!==ge||t[135]!==_||t[136]!==z||t[137]!==J||t[138]!==ot?(Y=z?(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:()=>oe(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:z.modelID})]}),(0,Z.jsx)(`div`,{className:`space-y-1 p-2`,role:`listbox`,"aria-label":_(`chat.modelControls.thinking`),children:[``,...ot].map(e=>{let t=J===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:()=>ge(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]=ge,t[135]=_,t[136]=z,t[137]=J,t[138]=ot,t[139]=Y):Y=t[139];let X=Y||it;if(te){let e=v?F: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)(Pe,{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]!==We?(f=v?(0,Z.jsx)(`span`,{className:`typography-meta font-medium text-foreground truncate`,children:We}):null,t[150]=v,t[151]=We,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]!==j||t[167]!==r||t[168]!==n||t[169]!==M||t[170]!==T||t[171]!==i?(C=(e,t)=>T(e,t,e===n&&t===r?i||void 0:j.find(n=>n.providerID===e&&n.modelID===t)?.variant??M.find(n=>n.providerID===e&&n.modelID===t)?.variant),t[166]=j,t[167]=r,t[168]=n,t[169]=M,t[170]=T,t[171]=i,t[172]=C):C=t[172];let D;t[173]!==c||t[174]!==s||t[175]!==j||t[176]!==S||t[177]!==Xe||t[178]!==w||t[179]!==E||t[180]!==N||t[181]!==r||t[182]!==n||t[183]!==O||t[184]!==x||t[185]!==M||t[186]!==Je||t[187]!==C||t[188]!==B?(D=(0,Z.jsx)(Er,{open:N,onClose:V,selectedProviderID:n,selectedModelID:r,resolveSelectedVariant:Je,onSelect:Xe,providers:x,favoriteModels:j,recentModels:M,getMetadata:S,hiddenModels:w,allowedProviderIds:s,allowedModelIdsByProvider:c,providerOrder:O,variantSelectionEnabled:B,isFavorite:E,onToggleFavorite:C}),t[173]=c,t[174]=s,t[175]=j,t[176]=S,t[177]=Xe,t[178]=w,t[179]=E,t[180]=N,t[181]=r,t[182]=n,t[183]=O,t[184]=x,t[185]=M,t[186]=Je,t[187]=C,t[188]=B,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 st=v&&re,ct=v?L:void 0,lt=!v&&`opacity-60 cursor-not-allowed`,ut;t[193]!==o||t[194]!==lt?(ut=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`,lt,o),t[193]=o,t[194]=lt,t[195]=ut):ut=t[195];let dt;t[196]!==v||t[197]!==y||t[198]!==r||t[199]!==n||t[200]!==g||t[201]!==_||t[202]!==We||t[203]!==Ke?(dt=v?(0,Z.jsxs)(Z.Fragment,{children:[g?n||r?(0,Z.jsx)(Pe,{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:We}),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]=We,t[203]=Ke,t[204]=dt):dt=t[204];let ft;t[205]===Symbol.for(`react.memo_cache_sentinel`)?(ft=(0,Z.jsx)(G,{name:`arrow-down-s`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground/50`}),t[205]=ft):ft=t[205];let pt;t[206]!==ut||t[207]!==dt?(pt=(0,Z.jsx)(Yn,{asChild:!0,children:(0,Z.jsxs)(`div`,{className:ut,children:[dt,ft]})}),t[206]=ut,t[207]=dt,t[208]=pt):pt=t[208];let mt;t[209]!==h||t[210]!==X?(mt=(0,Z.jsx)(Xn,{className:`w-[min(380px,calc(100vw-2rem))] p-0 flex flex-col`,align:`start`,portalToBody:h,children:X}),t[209]=h,t[210]=X,t[211]=mt):mt=t[211];let ht;return t[212]!==st||t[213]!==ct||t[214]!==pt||t[215]!==mt?(ht=(0,Z.jsxs)(Jn,{open:st,onOpenChange:ct,children:[pt,mt]}),t[212]=st,t[213]=ct,t[214]=pt,t[215]=mt,t[216]=ht):ht=t[216],ht};function Ir(e){return e.providers}function Lr(e){return e.getModelMetadata}function Rr(e){return e.isMobile}function zr(e){return e.hiddenModels}function Br(e){return e.toggleFavoriteModel}function Vr(e){return e.isFavoriteModel}function Hr(e){return e.addRecentModel}function Ur(e){return e.providerOrder}var Wr=e(D(),1),Gr=`mobile-overlay-root`,Kr=16,qr=200,Jr=[],Yr=0,Xr=``,Zr=0,Qr=()=>{if(typeof document>`u`)return null;let e=document.getElementById(Gr);return e||(e=document.createElement(`div`),e.id=Gr,document.body.appendChild(e)),e},$r=({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=Qr()),Q.useEffect(()=>{if(!e){m(!1),g(!1);return}let t=window.setTimeout(()=>m(!0),Kr),n=window.setTimeout(()=>g(!0),266);return()=>{window.clearTimeout(t),window.clearTimeout(n)}},[e]),Q.useLayoutEffect(()=>{if(e)return Zr===0&&window.dispatchEvent(new Event(`oc:mobile-overlay-opened`)),Zr+=1,()=>{Zr=Math.max(0,Zr-1),Zr===0&&window.dispatchEvent(new Event(`oc:mobile-overlay-closed`))}},[e]),Q.useEffect(()=>{if(!e)return;let t=d.current;Jr.push(t),Yr===0&&(Xr=document.body.style.overflow),Yr+=1,document.body.style.overflow=`hidden`;let n=e=>{e.key===`Escape`&&Jr[Jr.length-1]===t&&f.current()};return document.addEventListener(`keydown`,n),()=>{let e=Jr.lastIndexOf(t);e>=0&&Jr.splice(e,1),Yr=Math.max(0,Yr-1),Yr===0&&(document.body.style.overflow=Xr),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:Ve,onClick:e=>{Ke(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 ${qr}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)(Ge,{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,Wr.createPortal)(v,u.current)},ei=e=>e??a()?.github,ti=(e=t())=>c.github.auth(e),ni=async(e,t)=>{if(e)return e.authStatus();let n=await r(`/api/github/auth/status`,{method:`GET`,headers:{Accept:`application/json`},signal:t}),i=await n.json().catch(()=>null);if(!n.ok||!i)throw Error(i?.error||n.statusText||`Failed to load GitHub status`);return i},ri=(e,n=t())=>{let r=ei(e);return{queryKey:ti(n),queryFn:async({signal:e})=>ni(r,e),retry:2}},ii=e=>!!e&&typeof e==`object`&&`authStatus`in e,ai=e=>{let t=(0,K.c)(5),n=ii(e)?e:void 0,r=ii(e)?void 0:e?.enabled,i;t[0]===n?i=t[1]:(i=ri(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],ie(a)},oi=(e=o,n=t())=>e.getQueryData(ti(n))??null,si=async(e,n,r)=>t()===r?e.fetchQuery({...ri(n,r),staleTime:0}):e.getQueryData(ti(r))??null,ci=(e=o,n,r=t())=>{e.setQueryData(ti(r),n)},li=L.define(le),ui=se.data.of({commentTokens:{line:`//`,block:{open:`/*`,close:`*/`}}});function di(e){let t=e.trim().toLowerCase();switch(t){case`bash`:case`sh`:case`zsh`:case`shell`:case`shellsession`:case`console`:return li;case`json`:case`jsonc`:case`json5`:return B().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 oe().language;case`css`:return ae().language;case`py`:case`python`:return ce().language;case`md`:case`markdown`:case`mdown`:case`mkd`:return V().language;case`heex`:case`eex`:case`leex`:return oe().language;default:return R.matchLanguageName(Xe,t,!0)}}var fi=e=>e.split(`/`).pop()?.toLowerCase()??``,pi=e=>{let t=fi(e);return t?R.matchFilename(Xe,t):null},mi=()=>P(I.define([{tag:[F.heading1,F.heading2,F.heading3,F.heading4,F.heading5,F.heading6],fontWeight:`600`},{tag:F.strong,fontWeight:`600`},{tag:F.emphasis,fontStyle:`italic`},{tag:F.strikethrough,textDecoration:`line-through`},{tag:[F.link,F.url],color:`var(--markdown-link, currentColor)`,textDecoration:`underline`},{tag:F.monospace,color:`var(--markdown-inline-code, currentColor)`,backgroundColor:`var(--markdown-inline-code-bg, transparent)`},{tag:F.quote,color:`var(--markdown-blockquote, currentColor)`,fontStyle:`italic`},{tag:F.list,color:`color-mix(in srgb, var(--muted-foreground) 40%, var(--foreground) 60%)`},{tag:F.heading,color:`var(--markdown-heading1, currentColor)`}]));function hi(e){let t=e.toLowerCase();switch(fi(t)){case`makefile`:case`gnumakefile`:return li}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[B(),ui];case`json`:case`jsonl`:case`ndjson`:case`geojson`:return B();case`css`:case`scss`:case`sass`:case`less`:return ae();case`html`:case`htm`:case`xml`:case`drawio`:case`dio`:return oe();case`md`:case`mdx`:case`markdown`:case`mdown`:case`mkd`:return[V({codeLanguages:di}),mi()];case`sh`:case`bash`:case`zsh`:case`fish`:case`env`:return li;case`py`:case`pyw`:case`pyi`:return ce();default:return null}}async function gi(e){let t=pi(e);if(!t)return null;if(t.support)return t.support;try{return await t.load()}catch{return null}}var _i=e=>e===`allow`||e===`deny`||e===`ask`;function vi(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function yi(e){return vi(e)?typeof e.action==`string`&&typeof e.resource==`string`&&_i(e.effect)?{action:e.action,resource:e.resource,effect:e.effect}:typeof e.permission==`string`&&typeof e.pattern==`string`&&_i(e.action)?{action:e.permission,resource:e.pattern,effect:e.action}:null:null}function bi(e){if(Array.isArray(e))return e.flatMap(e=>{let t=yi(e);return t?[t]:[]});if(_i(e))return[{action:`*`,resource:`*`,effect:e}];if(!vi(e))return[];let t=[];for(let[n,r]of Object.entries(e))if(n!==`__originalKeys`){if(_i(r)){t.push({action:n,resource:`*`,effect:r});continue}if(vi(r))for(let[e,i]of Object.entries(r))_i(i)&&t.push({action:n,resource:e,effect:i})}return t}function xi(e){return bi(e)}var Si=60,Ci=400;function wi(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+=Ci){let n=e.slice(t,t+Ci);i&&i.length+n.length>Ci&&(r.push(i.trim()),i=``),i+=n,i.length>=Si&&/[.!?…]["')\]]*\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 Ti=null;function Ei(){return Ti||=new(window.AudioContext||window.webkitAudioContext),Ti}function Di(){let[e,t]=(0,Q.useState)(!1),[n,i]=(0,Q.useState)(null),a=(0,Q.useRef)(null),o=(0,Q.useRef)(null),s=(0,Q.useCallback)(async()=>{try{let e=Ei();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),a.current){try{a.current.onended=null,a.current.stop()}catch{}a.current=null}t(!1)},[]),l=(0,Q.useCallback)(async(e,n)=>{c();let s=wi(e);if(s.length===0){i(`No text to speak`),n?.onError?.(`No text to speak`);return}i(null);let l={cancelled:!1,abort:new AbortController};o.current=l;let u=async e=>{let t=await r(`/api/dictation/tts/speak`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e,...typeof n?.speakerId==`number`?{speakerId:n.speakerId}:{},...typeof n?.speed==`number`?{speed:n.speed}:{}}),signal:l.abort.signal});if(!t.ok){let e=await t.json().catch(()=>({error:`Unknown error`}));throw Error(e.error||`HTTP ${t.status}`)}return(await t.blob()).arrayBuffer()},d=async e=>{let t=Ei();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),a.current=r,r.onended=()=>{a.current===r&&(a.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 r=e instanceof Error?e.message:`Failed to speak`;i(r),n?.onError?.(r),t(!1)}finally{o.current===l&&(o.current=null)}},[c]);return(0,Q.useEffect)(()=>()=>{c()},[c]),{isPlaying:e,error:n,speak:l,stop:c,unlockAudio:s}}var Oi=new class{recognition=null;isListening=!1;currentLang=`en-US`;onResultCallback=null;onErrorCallback=null;restartOnEnd=!1;conversationMode=!1;isSpeaking=!1;audioContext=null;audioUnlockRequired=!1;isSupported(){let e=`SpeechRecognition`in window||`webkitSpeechRecognition`in window,t=`speechSynthesis`in window;return e&&t}getSupportDetails(){return{recognition:`SpeechRecognition`in window||`webkitSpeechRecognition`in window,synthesis:`speechSynthesis`in window,prefixed:!(`SpeechRecognition`in window)&&`webkitSpeechRecognition`in window,secureContext:window.isSecureContext}}setConversationMode(e){this.conversationMode=e,e||(this.restartOnEnd=!1)}isConversationMode(){return this.conversationMode}pauseListening(){if(this.restartOnEnd=!1,this.recognition)try{this.recognition.stop()}catch{}this.isListening=!1}resumeListening(){if(this.conversationMode,this.onResultCallback,this.isSpeaking,this.currentLang,this.conversationMode&&this.onResultCallback&&!this.isSpeaking)try{this.startListeningSync(this.currentLang,this.onResultCallback,this.onErrorCallback||void 0)}catch(e){console.error(`[BrowserVoiceService] Failed to resume listening:`,e)}}async checkMicrophonePermission(){try{return`permissions`in navigator&&(await navigator.permissions.query({name:`microphone`})).state===`granted`}catch{return!1}}async prepareListening(){if(!this.isSupported())throw Error(`Web Speech API not supported in this browser`);if(typeof navigator>`u`||typeof navigator.mediaDevices?.getUserMedia!=`function`)return!0;try{return(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(e=>e.stop()),!0}catch(e){let t=typeof e==`object`&&e&&`name`in e?String(e.name):``;if(t===`NotAllowedError`)throw Error(`Microphone permission denied`);if(t===`NotFoundError`)throw Error(`No microphone found`);let n=e instanceof Error?e.message:`Unable to access microphone`;throw Error(n)}}startListeningSync(e,t,n){if(!this.isSupported()){let e=`Web Speech API not supported in this browser`;throw n?.(e),Error(e)}this.stopListening();let r=window.SpeechRecognition||window.webkitSpeechRecognition;if(!r){let e=`Web Speech API not supported in this browser`;throw n?.(e),Error(e)}let i=new r;this.recognition=i,this.currentLang=e,this.onResultCallback=t,this.onErrorCallback=n||null,i.continuous=!0,i.interimResults=!0,i.lang=e,i.onstart=()=>{this.isListening=!0,this.restartOnEnd=!0},i.onaudiostart=()=>{},i.onsoundstart=()=>{},i.onresult=e=>{e.results.length;let t=``,n=``;for(let r=e.resultIndex;r<e.results.length;r++){let i=e.results[r];i.isFinal?t+=i[0].transcript:n+=i[0].transcript}n&&this.onResultCallback?.(n,!1),t&&this.onResultCallback?.(t,!0)},i.onerror=e=>{if(e.error===`aborted`)return;let t=this.getErrorMessage(e.error);this.onErrorCallback?.(t),(e.error===`not-allowed`||e.error===`service-not-allowed`||e.error===`network`)&&(this.restartOnEnd=!1,this.isListening=!1)},i.onend=()=>{if(this.isListening=!1,this.restartOnEnd&&this.recognition&&!this.isSpeaking)try{this.recognition.start()}catch{}};try{i.start()}catch(e){let t=e instanceof Error?e.message:`Failed to start speech recognition`;throw n?.(t),Error(t)}}async startListening(e,t,n){this.startListeningSync(e,t,n)}stopListening(){if(this.restartOnEnd=!1,this.recognition){try{this.recognition.stop()}catch{}this.recognition=null}this.isListening=!1}getIsListening(){return this.isListening}getCurrentLang(){return this.currentLang}async resumeAudioContext(){this.audioContext||=new(window.AudioContext||window.webkitAudioContext),this.audioContext.state===`suspended`&&await this.audioContext.resume()}isAudioUnlockRequired(){return this.audioUnlockRequired}async unlockAudio(){try{let e=new Audio;if(e.src=`data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA`,e.volume=.01,await e.play(),await this.resumeAudioContext(),this.isMobileDevice()&&`speechSynthesis`in window){let e=new SpeechSynthesisUtterance(``);e.volume=0,window.speechSynthesis.speak(e),window.speechSynthesis.cancel()}return this.audioUnlockRequired=!1,!0}catch(e){return console.error(`[BrowserVoiceService] Failed to unlock audio:`,e),!1}}async speakText(e,t,n,r){if(!(`speechSynthesis`in window))throw Error(`Speech synthesis not supported`);await this.resumeAudioContext();let i=await this.waitForVoices();await new Promise(e=>setTimeout(e,50)),this.isSpeaking=!0,this.pauseListening(),window.speechSynthesis.cancel();let a=new SpeechSynthesisUtterance(e);a.lang=t,a.rate=r?.rate??1,a.pitch=r?.pitch??1,a.volume=r?.volume??1;let o=null;return r?.voiceName&&(o=i.find(e=>e.name===r.voiceName)||null,o?`${o.name}${o.lang}`:console.warn(`[BrowserVoiceService] Selected voice "${r.voiceName}" not found, falling back to language match`)),o||(o=this.findBestVoice(i,t),o?`${o.name}${o.lang}`:console.warn(`[BrowserVoiceService] No voice found for language: ${t}, using default`)),o&&(a.voice=o),`${e.length}${t}`,new Promise((e,t)=>{let r=!1;a.onstart=()=>{r=!0,e()},a.onend=()=>{this.isSpeaking=!1,n?.()},a.onerror=e=>{this.isSpeaking=!1,console.error(`[BrowserVoiceService] Speech synthesis error:`,e.error),(e.error===`not-allowed`||e.error===`interrupted`)&&(this.audioUnlockRequired=!0);let n=`Speech synthesis error: ${e.error||`unknown`}`;e.error===`not-allowed`?n=`Audio blocked by browser autoplay policy. Please interact with the page first.`:e.error===`interrupted`&&(n=`Speech was interrupted. Please try again.`),t(Error(n))},setTimeout(()=>{r||(console.warn(`[BrowserVoiceService] Speech start timeout - audio may be blocked`),this.audioUnlockRequired=!0)},2e3),window.speechSynthesis.speak(a)})}cancelSpeech(){`speechSynthesis`in window&&window.speechSynthesis.cancel()}getVoices(){return`speechSynthesis`in window?window.speechSynthesis.getVoices():[]}async waitForVoices(){if(!(`speechSynthesis`in window))return[];let e=window.speechSynthesis.getVoices();return e.length>0?e:new Promise(e=>{let t=()=>{e(window.speechSynthesis.getVoices()),window.speechSynthesis.onvoiceschanged=null};window.speechSynthesis.onvoiceschanged=t,setTimeout(()=>{e(window.speechSynthesis.getVoices()),window.speechSynthesis.onvoiceschanged=null},1e3)})}findBestVoice(e,t){let n=e.find(e=>e.lang===t);if(!n){let r=t.split(`-`)[0];n=e.find(e=>e.lang.startsWith(r))}return n||=e.find(e=>e.lang.startsWith(t.split(`-`)[0])&&e.localService),n||null}isMobileDevice(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent.toLowerCase();return/iphone|ipad|ipod|android|mobile|webos|blackberry|iemobile|opera mini/i.test(e)}isIOSSafari(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent.toLowerCase(),t=/iphone|ipad|ipod/i.test(e),n=/safari/i.test(e)&&!/chrome|crios|crmo/i.test(e);return t&&n}getErrorMessage(e){let t=this.isMobileDevice(),n=this.isIOSSafari();return{"no-speech":`No speech detected`,aborted:`Speech recognition aborted`,"audio-capture":`No microphone found`,network:`Network error - check connection`,"not-allowed":t?`Microphone permission denied. Check Settings > Safari > Microphone`:`Microphone permission denied`,"service-not-allowed":n?`Speech recognition requires a user gesture. Please tap the microphone button again.`:`Speech recognition service not allowed`,"bad-grammar":`Grammar error`,"language-not-supported":`Language not supported`}[e]||`Speech recognition error: ${e}`}},ki=e=>{if(e===`12h`)return!0;if(e===`24h`)return!1},Ai=(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:ki(t)}):n.fallback??``},ji=(e,t,n)=>{let r=e instanceof Date?e:new Date(e);return Number.isFinite(r.getTime())?r.toLocaleString(H(),{...n,hour12:n.hour?ki(t):n.hour12}):``},$=e=>ge(he.getState().dictionary,e),Mi=e=>typeof e!=`number`||!Number.isFinite(e)?null:Math.max(0,Math.min(100,Math.round(e))),Ni=e=>typeof e!=`number`||!Number.isFinite(e)?`-`:`${Math.round(e)}%`,Pi=(e,t)=>e??Ni(t),Fi=(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()?Ai(r,n,{fallback:t??``}):ji(r,n,{month:`short`,day:`numeric`,weekday:`short`,hour:`numeric`,minute:`2-digit`})}catch{return t??``}},Ii=e=>e===null?`safe`:e>=80?`critical`:e>=50?`warn`:`safe`,Li=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,Ri=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},zi=(e,t,n,r)=>{let i=n;if(i===null&&r&&(i=Ri(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}},Bi=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)`}},Vi=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`},Hi=e=>Math.min(100,Math.max(0,e*100)),Ui=(e,t)=>ge(he.getState().dictionary,e,t),Wi=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)?Ui(`common.date.today`):r(t,i)?Ui(`common.date.yesterday`):t.toLocaleDateString(H(),{month:`short`,day:`numeric`,year:`numeric`}).replace(`,`,``)},Gi=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?Ui(`common.relative.justNow`):t<36e5?Ui(`common.relative.minutesAgoShort`,{count:Math.floor(t/6e4)}):Ui(`common.relative.hoursAgoShort`,{count:Math.floor(t/36e5)})}return Wi(e)},Ki=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?Ui(`common.relative.minutesAgoCompact`,{count:Math.max(1,Math.floor(t/n))}):t<i?Ui(`common.relative.hoursAgoCompact`,{count:Math.floor(t/r)}):t<a?Ui(`common.relative.daysAgoCompact`,{count:Math.floor(t/i)}):t<5*a?Ui(`common.relative.weeksAgoCompact`,{count:Math.floor(t/a)}):t<o?Ui(`common.relative.monthsAgoCompact`,{count:Math.floor(t/2592e6)}):Ui(`common.relative.yearsAgoCompact`,{count:Math.floor(t/o)})},qi=(e,t)=>Ji(l(e),l(t)),Ji=(e,t)=>!e||!t?!1:e===t?!0:t===`/`?e.startsWith(`/`):e.startsWith(`${t}/`),Yi=e=>e.toLowerCase().replace(/^opencode[/-]?/i,``).replace(/[-_]/g,``).trim(),Xi=(e,t)=>e?Yi(e)!==Yi(t):!1,Zi=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}},Qi=e=>Zi(e.time?.created)??0,$i=(e,t,n)=>{let r=n.has(e.id),i=n.has(t.id);return r===i?r&&i?Qi(t)-Qi(e):we(t)-we(e):r?-1:1},ea=e=>{let t=new Map;return e.forEach(e=>{t.set(e.id,e)}),Array.from(t.values())},ta=e=>`__archived__:${e}`,na=(e,t)=>{let n=l(e.directory??null),r=l(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`},ra=`box-border w-full px-2 py-1.5 text-left typography-micro text-muted-foreground/70 select-none`,ia=`bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] dark:bg-[color-mix(in_srgb,var(--surface-foreground)_11%,transparent)]`,aa=`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},sa=(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},ca=`/api/browser-providers`,la=`/api/browser-providers/selection`,ua=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/,da=200,fa=e=>`/api/browser-providers/${encodeURIComponent(e)}/surface/ws`,pa=e=>!!e&&typeof e==`object`&&!Array.isArray(e),ma=e=>typeof e==`string`&&ua.test(e)?e:null,ha=e=>{if(!pa(e))return null;let t=ma(e.id),n=typeof e.name==`string`?e.name.trim():``;return!t||!n||n.length>da?null:{id:t,name:n,surface:e.surface===!0}},ga=e=>{if(!pa(e)||!Array.isArray(e.providers))return null;let t=[],n=new Set;for(let r of e.providers){let e=ha(r);!e||n.has(e.id)||(n.add(e.id),t.push(e))}let r=ma(e.selectedId);return{providers:t,selectedId:r&&n.has(r)?r:null}},_a=e=>{if(!pa(e))return null;let t=ma(e.selectedId);return t?{selectedId:t}:null},va=e=>e?.selectedId?e.providers.find(t=>t.id===e.selectedId)??null:null,ya=e=>!!(e&&e.providers.length>0),ba=e=>va(e)!==null,xa=e=>typeof e==`number`&&Number.isFinite(e),Sa=e=>{if(!pa(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||!xa(e.seq)||!xa(e.width)||!xa(e.height)||!xa(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`&&xa(e.width)&&xa(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},Ca=class extends Error{status;constructor(e){super(`browser_provider_request_failed:${e}`),this.name=`BrowserProviderRequestError`,this.status=e}},wa=(e=t())=>c.browserProviders.catalog(e),Ta=async e=>{let t=await e.text();if(!t)return null;try{return JSON.parse(t)}catch{return null}},Ea=async e=>{let t=await r(ca,{method:`GET`,headers:{Accept:`application/json`},signal:e}),n=await Ta(t);if(!t.ok)throw new Ca(t.status);let i=ga(n);if(!i)throw new Ca(t.status||502);return i},Da=(e=t())=>({queryKey:wa(e),queryFn:({signal:e})=>Ea(e),staleTime:5e3,refetchOnWindowFocus:!0,refetchInterval:e=>{let t=e.state.error;return t instanceof Ca&&(t.status===404||t.status===501)?!1:15e3}}),Oa=()=>{let e=(0,K.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=Da(),e[0]=t):t=e[0],ie(t)},ka=(e=o,n=t())=>e.getQueryData(wa(n))??null,Aa=(e,t)=>e?.providers.some(e=>e.id===t)?{providers:e.providers,selectedId:t}:null,ja=async(e,n=o,i)=>{let a=t(),s=await r(la,{method:`PUT`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({id:e}),signal:i}),c=await Ta(s);if(!s.ok)throw new Ca(s.status);let l=_a(c);if(!l||l.selectedId!==e||t()!==a)throw new Ca(s.status||502);let u=Aa(n.getQueryData(wa(a)),l.selectedId);if(!u)throw new Ca(409);return u},Ma=()=>{let e=(0,K.c)(2),n=N(),r;return e[0]===n?r=e[1]:(r={mutationFn:e=>ja(e,n),onMutate:async e=>{let r=t(),i=wa(r);await n.cancelQueries({queryKey:i});let a=n.getQueryData(i),o=Aa(a,e);return o&&n.setQueryData(i,o),{previous:a,key:i,transport:r}},onError:(e,r,i)=>{!i||t()!==i.transport||n.setQueryData(i.key,i.previous)},onSuccess:(e,r,i)=>{!i||t()!==i.transport||n.setQueryData(i.key,e)}},e[0]=n,e[1]=r),ne(r)},Na=[`standalone`,`minimal-ui`,`fullscreen`,`window-controls-overlay`],Pa=`openchamber.pwaRecentSessions`,Fa=e=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(display-mode: ${e})`).matches,Ia=()=>typeof window>`u`?`browser`:typeof document<`u`&&document.referrer.startsWith(`android-app://`)?`twa`:window.navigator.standalone?`standalone`:Na.find(e=>Fa(e))??`browser`,La=864e5,Ra=5,za=864e5,Ba=e=>e.time?.updated??e.time?.created??0,Va=({sessions:e,currentSessionId:t,cutoffDays:n,keepRecent:r=Ra,now:i=Date.now()})=>{if(!Array.isArray(e)||n<=0)return[];let a=i-n*La,o=[...e].sort((e,t)=>Ba(t)-Ba(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=Ba(e);return n?n<a:!1}).map(e=>e.id)},Ha=e=>{let t=typeof e==`object`?e:void 0,n=t?.autoRun!==!1,r=typeof e==`boolean`?e:t?.enabled??!0,i=Ce(e=>e.currentSessionId),a=Ce(e=>e.isLoading),o=_e(e=>e.activeSessions),s=_e(e=>e.hasLoadedFullCatalog),c=A(e=>e.autoDeleteEnabled),l=A(e=>e.autoDeleteAfterDays),u=A(e=>e.sessionRetentionAction),d=A(e=>e.autoDeleteLastRunAt),f=A(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(()=>{Se(O())},8e3);return()=>window.clearTimeout(e)},[l,c,n,r]);let g=Q.useMemo(()=>l<=0?[]:Va({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<za)return{completedIds:[],failedIds:[],action:u,skippedReason:`cooldown`};let{activeSessions:n}=await Se(O());if(n.length===0)return{completedIds:[],failedIds:[],action:u,skippedReason:`no-candidates`};let r=Va({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?Ee(r):null;if(!a){i.push(n);continue}try{u===`archive`?await k.updateSession(n,{time:{archived:Date.now()}},a):await k.deleteSession(n,a),t.push(n)}catch{i.push(n)}}return u===`archive`?_e.getState().archiveSessions(t):_e.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<za||_())},[l,c,d,n,r,s,o.length,a,_]),{candidates:g,isRunning:p,runCleanup:_,keepRecentCount:Ra,action:u}};export{Sr as $,St as $t,Vi as A,on as At,di as B,Kt as Bt,sa as C,Cn as Ct,Mi as D,bn as Dt,zi as E,yn as Et,Ai as F,fn as Ft,ci as G,gt as Gt,gi as H,Wt as Ht,Oi as I,_n as It,Fr as J,yt as Jt,ai as K,bt as Kt,Di as L,gn as Lt,Bi as M,hn as Mt,Ii as N,dn as Nt,Fi as O,pn as Ot,ji as P,ln as Pt,xr as Q,wt as Qt,xi as R,Zt as Rt,Yi as S,Nn as St,Hi as T,xn as Tt,oi as U,Ut,hi as V,Ht as Vt,si as W,Tt as Wt,_r as X,vt as Xt,Er as Y,_t as Yt,br as Z,Ct as Zt,Gi as _,Bn as _t,Oa as a,rt as an,Zn as at,Xi as b,Vn as bt,Sa as c,$n as ct,ra as d,wn as dt,It as en,yr as et,ia as f,Hn as ft,Ki as g,zn as gt,ea as h,Rn as ht,ka as i,Rt as in,Xn as it,Li as j,mn as jt,Pi as k,un as kt,ba as l,tr as lt,$i as m,In as mt,Pa as n,Ft as nn,nr as nt,Ma as o,it as on,er as ot,aa as p,Wn as pt,$r as q,xt as qt,Ia as r,Lt as rn,Jn as rt,fa as s,at as sn,Qn as st,Ha as t,Pt as tn,sr as tt,ya as u,Yn as ut,ta as v,Un as vt,na as w,vn as wt,qi as x,jn as xt,oa as y,Ln as yt,bi as z,qt as zt};
2
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{i as t,l as n}from"./runtime-switch-BJM2k_uH.js";import{n as r}from"./runtime-fetch-CiqQd__Y.js";import{$t as i,On as a,d as o,en as s,f as c,it as l,rn as u}from"./persistence-Dnj1QOdX.js";import{h as d}from"./desktopHosts-DuftEj8B.js";import{i as f,n as p,r as m}from"./desktopRelayRestore-g378BdZf.js";import{A as h,D as g,E as _,F as v,I as y,M as b,N as x,P as S,j as C,k as w,nt as T,rt as E,tt as D}from"./vendor-base-ui-CnHfUmDN.js";import{Fn as O,Nt as k}from"./platform-wu6wSDfg.js";import{n as A}from"./useUIStore-Dfx6TKvi.js";import{n as j}from"./vendor-react-DLPElpoQ.js";import{o as M}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as ee}from"./vendor-tanstack-query-core-BWz0ose6.js";import{i as te,l as N,n as ne,r as re,s as ie}from"./vendor-tanstack-react-query-D7pys_c9.js";import{P,V as F,a as I,f as L,l as R}from"./vendor-codemirror-autocomplete-DHomsvW7.js";import{c as ae,o as z,r as oe}from"./vendor-codemirror-lang-angular-DShkBD6m.js";import{n as B,r as se}from"./vendor-codemirror-lang-json-CYJRHck9.js";import{n as V}from"./vendor-codemirror-lang-markdown-WORgx6ZD.js";import{n as ce}from"./vendor-codemirror-lang-python-Du6XQ8Zw.js";import{O as le}from"./vendor-codemirror-legacy-modes-DuRAjNvB.js";import{n as ue}from"./vendor-reactuses-core-Dq5ocTF8.js";import{d as de,f as fe,l as pe,p as H,r as U,t as me}from"./button-CUwjpv-i.js";import{i as he,t as ge}from"./store-l_X_jQNz.js";import{$a as _e,Ir as ve,Mr as ye,Na as be,Sr as xe,d as Se,ga as Ce,ja as we,kr as Te,va as W,za as Ee}from"./useMobileNavigationStore-DBML5LIl.js";import{t as De}from"./AgentAvatar-C1MGZ7qC.js";import{n as G}from"./Icon-BdzPRCSy.js";import{i as Oe,n as ke,r as Ae,t as je}from"./vendor-simplewebauthn-browser-Dwhcdg_5.js";import{C as Me,D as Ne,O as Pe,S as Fe,T as Ie,w as Le}from"./projectMeta-D_jCNzjw.js";import{t as Re}from"./input-BeVw4D0W.js";import{t as ze}from"./useThemeSystem-DMzWVJaW.js";import{i as Be}from"./OverlayScrollbar-C1C2aKOe.js";import{_ as Ve,g as He,h as Ue,i as We,n as Ge,v as Ke}from"./textarea-Kl-rTWJe.js";import{n as qe,r as Je,t as Ye}from"./dropdown-menu.styles-ayLWk2gf.js";import{t as Xe}from"./vendor-codemirror-language-data-BfYFhIH1.js";var K=j(),Ze=[`desktopHostSwitch`],Qe=class extends Error{result;host;constructor(e,t){super(e.reason),this.name=`DesktopHostSwitchError`,this.result=e,this.host=t}},$e=(e,t)=>ge(he.getState().dictionary,e,t),et=async e=>{let{host:t}=e;if(t.id===`local`){let r=(e.localApiOrigin||``).trim();if(!r)throw new Qe({ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unreachable`},t);return n({apiBaseUrl:r,clientToken:e.localClientToken||null,runtimeKey:m(t)}),{ok:!0,via:`direct`,status:{status:`ok`,latencyMs:0}}}let r=await f(t,{cachedProbe:e.cachedProbe});if(!r.ok)throw new Qe(r,t);return r},tt=null,nt=()=>tt||(tt=new ee(o,{mutationKey:Ze,mutationFn:et,onError:(e,t)=>{if(e instanceof Qe&&e.result.reason!==`unsupported`){if(e.result.status.status===`auth`){ve.error($e(`desktopHostSwitcher.status.authRequired`));return}ve.error($e(`desktopHostSwitcher.toast.instanceUnreachable`,{host:d(t.host.label)}))}}}),tt.subscribe(()=>void 0),tt),rt=async e=>{if(p(e.host))return{ok:!0,via:`direct`,status:e.cachedProbe?.status===`ok`?e.cachedProbe:{status:`ok`,latencyMs:0}};if(o.isMutating({mutationKey:Ze})>0)return{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unsupported`};try{return await nt().mutate(e)}catch(e){if(e instanceof Qe)return e.result;throw e}},it=()=>{let e=(0,K.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={mutationKey:Ze},e[0]=t):t=e[0],re(t)>0},at=()=>{let e=(0,K.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={filters:{mutationKey:Ze,status:`pending`},select:ot},e[0]=t):t=e[0],te(t)[0]?.host.id??null};function ot(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},st=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],ct=()=>i()?(e,t)=>s(e,t):null,lt=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}:{}}},ut=e=>e===`remote`||e===`dynamic`?e:`local`,dt=e=>{if(!q(e))return null;let t=J(e,`id`);if(!t)return null;let n=X(e,`enabled`)??!0,r=ut(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}:{}}},ft=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:st(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=>dt(e)).filter(e=>!!e),h=Y(o,`preferredPort`)??Y(o,`preferred_port`),g=Y(s,`preferredLocalPort`)??Y(s,`preferred_local_port`),_=lt(c.sshPassword||c.ssh_password),v=lt(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}},pt=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`}},mt=e=>{if(!q(e))return null;let t=J(e,`id`);return t?{id:t,phase:pt(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},ht=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}},gt=(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:[]}),_t=async()=>{let e=ct();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=>ft(e)).filter(e=>!!e)}:{instances:[]}},vt=async e=>{let t=ct();t&&await t(`desktop_ssh_instances_set`,{config:{instances:e.instances}})},yt=async()=>{let e=ct();if(!e)return[];let t=await e(`desktop_ssh_import_hosts`);return Array.isArray(t)?t.map(e=>ht(e)).filter(e=>!!e):[]},bt=async e=>{let t=ct();t&&await t(`desktop_ssh_connect`,{id:e})},xt=async e=>{let t=ct();t&&await t(`desktop_ssh_disconnect`,{id:e})},St=async e=>{let t=ct();if(!t)return[];let n=await t(`desktop_ssh_status`,{...e?{id:e}:{}});return Array.isArray(n)?n.map(e=>mt(e)).filter(e=>!!e):[]},Ct=async(e,t)=>{let n=ct();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`):[]},wt=async e=>{let t=ct();t&&await t(`desktop_ssh_logs_clear`,{id:e})},Tt=(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}},Et=e=>{if(!q(e))return null;let t=J(e,`path`),n=Y(e,`bytes`);return!t||n===null?null:{path:t,bytes:n}},Dt=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}},Ot=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}},kt=e=>{if(e==null||!q(e))return null;let t=Y(e,`bytes`);return t===null?null:{bytes:t}},At=e=>{if(!q(e))return null;let t=Array.isArray(e.files)?e.files:null,n=Array.isArray(e.directories)?e.directories:null,r=st(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=>Et(e)).filter(e=>!!e),o=n.map(e=>Dt(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:Ot(s);if(s!=null&&c===null)return null;let l=e.authFile??e.auth_file,u=l==null?null:kt(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=jt(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}:{}}},jt=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}},Mt=e=>{if(!q(e))return null;let t=At(e.plan);if(!t)return null;let n=jt(e.selectionShape??e.selection_shape)??t.selectionShape??null;return{plan:t,remoteExisting:st(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}:{}}},Nt=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:kt(s);return{ok:!0,files:t,directories:n,deletes:r,totalBytes:i,agentsRoot:o,authFile:c}},Pt=async(e={})=>{let t=ct();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=At(n.plan);if(!r)return console.error(`[desktopSsh] config sync local scan plan payload was not recognized`,n),null;let i=jt(n.selectionShape??n.selection_shape)??r.selectionShape??null;return i?{...r,selectionShape:i}:r},Ft=async(e,t={})=>{let n=ct();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=Mt(r);return i||console.error(`[desktopSsh] config sync preview payload was not recognized`,r),i},It=async(e,t={})=>{let n=ct();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=Nt(r);return i||console.error(`[desktopSsh] config sync apply payload was not recognized`,r),i},Lt=async(e,t={})=>{let n=ct();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`):[]},Rt=async e=>{if(!i())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=mt(t?.payload);n&&e(n)});return async()=>{await n()}},zt=new Set([`nodeRuntimeMissing`,`packageManagerMissing`,`nativeBinding`,`openchamberCliMissing`,`openchamberRegistry`,`openchamberInstall`,`openchamberCliIncompatible`,`opencodeInstall`,`serverStart`,`sshAuth`,`sshUnreachable`,`timeout`,`unknown`]),Bt=e=>typeof e==`string`&&zt.has(e),Vt=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`},Ht=(e,t)=>Bt(e)?e:Vt(t),Ut=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`}},Wt=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`}},Gt=e=>e===`unknown`||e===`openchamberCliIncompatible`,Kt=(e,t,n)=>{let r=typeof n==`string`?n.trim():``;return!Gt(t)||!r||r===e?e:`${e}\n${r}`},Z=T();function qt(e){let t=(0,K.c)(27),{errorCode:n,detail:r,className:i}=e,{t:a}=fe(),o,s,c,l,u,d;if(t[0]!==i||t[1]!==r||t[2]!==n||t[3]!==a){let e=Ht(n,r);o=a(Wt(e));let f;t[10]===r?f=t[11]:(f=typeof r==`string`?r.trim():``,t[10]=r,t[11]=f),s=f,c=Gt(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(Ut(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(E(),1),Jt=[.2,.45,.15,.55,.35,.1,.5,.25,.4,.3,.45,.15,.55,.2,.35,.1],Yt=[.3,.15,.45,.25,.5,.35,.1,.4,.2,.55,.3,.15,.45,.25,.4,.2],Xt=(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},Zt=({className:e=``,width:t=70,height:n=70,isAnimated:r=!1})=>{let{t:i}=fe(),a=ze(),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=Xt(h,_,b,v),C=Xt(_,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:Jt[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:Yt[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`})]})})]})},Qt=`/auth/passkey/authenticate/options`,$t=`/auth/passkey/authenticate/verify`,en=`/auth/passkey/register/options`,tn=`/auth/passkey/register/verify`,nn=`/api/passkeys`,rn=`/auth/passkey/status`,an=`/api/auth/reset`,on={enabled:!1,hasPasskeys:!1,passkeyCount:0,rpID:null},sn=async(e,t)=>r(e,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:t===void 0?void 0:JSON.stringify(t)}),cn=async(e,t)=>{try{let t=await e.json();if(t&&typeof t.error==`string`&&t.error.trim())return t.error}catch{}return t},ln=e=>e instanceof Oe&&e.code===`ERROR_CEREMONY_ABORTED`,un=()=>{Ae.cancelCeremony()},dn=()=>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.`},fn=async()=>{let e=dn();if(!e.supported)throw Error(e.reason);let t=await sn(en,{label:typeof navigator.userAgent==`string`&&navigator.userAgent.trim()?navigator.userAgent:`This device`});if(!t.ok)throw Error(await cn(t,`Could not start passkey setup.`));let{requestId:n,optionsJSON:r}=await t.json(),i=await sn(tn,{requestId:n,response:await ke({optionsJSON:r})});if(!i.ok)throw Error(await cn(i,`Could not finish passkey setup.`));return i.json().catch(()=>null)},pn=async(e,t={})=>{let n=dn();if(!n.supported)throw Error(n.reason);let r=await sn(Qt);if(!r.ok)throw Error(await cn(r,`Passkey sign-in is not available right now.`));let{requestId:i,optionsJSON:a}=await r.json(),o=await sn($t,{requestId:i,response:await je({optionsJSON:a}),trustDevice:e,issueClientToken:t.issueClientToken===!0,clientLabel:t.clientLabel,clientKind:t.clientKind,dedupeKey:t.dedupeKey});if(!o.ok)throw Error(await cn(o,`Passkey sign-in failed.`));return o.json().catch(()=>null)},mn=async()=>{let e=await r(rn,{method:`GET`,credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return on;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}},hn=async()=>{let e=await r(nn,{method:`GET`,credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(await cn(e,`Could not load passkeys.`));let t=await e.json().catch(()=>null);return Array.isArray(t?.passkeys)?t.passkeys:[]},gn=async e=>{let t=await r(`${nn}/${encodeURIComponent(e)}`,{method:`DELETE`,credentials:`include`,headers:{Accept:`application/json`}});if(!t.ok)throw Error(await cn(t,`Could not remove passkey.`));return t.json().catch(()=>null)},_n=async()=>{let e=await sn(an);if(!e.ok)throw Error(await cn(e,`Could not clear saved authentication.`));try{let{clearAssistantAttachmentCacheAll:e}=await M(async()=>{let{clearAssistantAttachmentCacheAll:e}=await import(`./assistant-attachment-cache-sG8YQsVs.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-D66yq6ie.js`).then(e=>e.m);return{invalidateRuntimeAuthSession:e}},__vite__mapDeps([2,1]));await e(`auth-reset`),t()}catch{}return e.json().catch(()=>null)};function vn(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 yn(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 bn(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 xn(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 Sn=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 de(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)(vn,{className:`w-full max-w-md`,children:[(0,Z.jsx)(yn,{className:`text-center`,children:(0,Z.jsxs)(bn,{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)(xn,{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)(me,{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)(me,{onClick:this.handleCopy,variant:`outline`,className:`flex-1`,children:this.state.copied?e.copied:e.copy})]})]})]})}):this.props.children}},Cn=e=>{let t=(0,K.c)(29),{children:n,fallback:r}=e,{t:i}=fe(),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)(Sn,{fallback:r,strings:m,children:n}),t[25]=n,t[26]=r,t[27]=m,t[28]=h):h=t[28],h},wn=`__unassigned__`,Tn={mod:`mod`,shift:`shift`,alt:`alt`,option:`alt`,ctrl:`ctrl`,meta:`mod`,cmd:`mod`,command:`mod`},En={mod:pe()?`⌘`:`Ctrl`,shift:`⇧`,alt:`⌥`,option:`⌥`,ctrl:`⌃`},Dn={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:`-`,"-":`-`},On=[`mod`,`ctrl`,`shift`,`alt`],kn={"{":`[`,"}":`]`,":":`;`,'"':`'`,"<":`,`,">":`.`,"?":`/`,"|":`\\`,"~":"`","!":`1`,"@":`2`,"#":`3`,$:`4`,"%":`5`,"^":`6`,"&":`7`,"*":`8`,"(":`9`,")":`0`};function An(e){return e.trim().toLowerCase()===wn}function jn(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`:kn[t]??t}var Mn=[{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 Nn(e){if(An(e))return wn;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=Tn[t];if(i){n.add(i);continue}r=t}return[...On.filter(e=>n.has(e)),r].filter(Boolean).join(`+`)}function Pn(e){return An(e)?!0:Fn(e).key.trim().length>0}function Fn(e){if(An(e))return{modifiers:new Set,key:wn};let t=Nn(e).split(`+`),n=new Set,r=``;for(let e of t){let t=Tn[e];t?n.add(t):r=e}return{modifiers:n,key:r}}function In(e){if(An(e))return`Unassigned`;let t=Fn(e);if(!t.key&&t.modifiers.size===0)return`Unassigned`;let n=[];for(let e of On)t.modifiers.has(e)&&n.push(En[e]);if(t.key){let e=Dn[t.key.toLowerCase()]||t.key.toUpperCase();n.push(e)}return n.join(` + `)}function Ln(e){return Mn.find(t=>t.id===e)}function Rn(){return Mn.filter(e=>e.customizable===!0)}function zn(e,t){let n=Ln(e);if(!n)return``;let r=t?.[e];if(typeof r==`string`){if(r.trim().toLowerCase()===`__unassigned__`)return``;let e=Nn(r);if(e===`__unassigned__`)return wn;if(Pn(e))return e}return n.defaultCombo}function Bn(e,t){let n=Ln(e);if(!n)return[];let r=zn(e,t);return r===n.defaultCombo?[n.defaultCombo,...n.defaultAliases??[]]:r?[r]:[]}function Vn(e){if(An(e))return!1;let t=Fn(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 Hn(e,t){let n=typeof t==`string`?t:t.defaultCombo;if(An(n))return!1;let r=Fn(n),i=r.modifiers.has(`mod`),a=r.modifiers.has(`shift`),o=r.modifiers.has(`alt`),s=r.modifiers.has(`ctrl`),c=pe()&&u(),l=pe(),d=c?e.metaKey:l&&e.metaKey||e.ctrlKey;if(i&&!d||!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))),jn(f)===jn(r.key)}function Un(){return pe()?`⌘`:`Ctrl`}function Wn(e,t,n){if(Hn(e,n))return!0;let r=Nn(n),i=pe()&&u(),a=pe();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 Gn=Q.createContext(null),Kn=e=>e?e.closest(`[data-slot="dialog-content"], [role="dialog"]`):null;function qn(e,t){return e&&Q.isValidElement(t)?{render:t}:{children:t}}function Jn(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)(w,{...n}),t[4]=n,t[5]=s);let c;return t[6]!==o||t[7]!==s?(c=(0,Z.jsx)(Gn.Provider,{value:o,children:s}),t[6]=o,t[7]=s,t[8]=c):c=t[8],c}function Yn(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(Gn),c;t[6]===s?c=t[7]:(c=e=>{if(!s)return;let t=e instanceof HTMLElement?e:null;s.setPortalContainer(Kn(t))},t[6]=s,t[7]=c);let l=c,u;t[8]!==n||t[9]!==r?(u=qn(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)(g,{"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 Xn(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,y;t[14]===m?y=t[15]:(y=m===void 0?{side:`shift`,align:`shift`}:m,t[14]=m,t[15]=y);let b=y,C=Q.useContext(Gn),w=g?void 0:C?.portalContainer||void 0,T;t[16]===s?T=t[17]:(T=U(`app-region-no-drag z-50`,s),t[16]=s,t[17]=T);let E;t[18]===u?E=t[19]:(E={backgroundColor:`var(--surface-elevated)`,color:`var(--surface-elevated-foreground)`,...u},t[18]=u,t[19]=E);let D;t[20]===o?D=t[21]:(D=U(qe,o),t[20]=o,t[21]=D);let O;t[22]!==a||t[23]!==c||t[24]!==E||t[25]!==D?(O=(0,Z.jsx)(v,{"data-slot":`dropdown-menu-content`,style:E,className:D,...c,children:a}),t[22]=a,t[23]=c,t[24]=E,t[25]=D,t[26]=O):O=t[26];let k;t[27]!==n||t[28]!==r||t[29]!==i||t[30]!==b||t[31]!==_||t[32]!==l||t[33]!==h||t[34]!==O||t[35]!==T?(k=(0,Z.jsx)(x,{anchor:i,sideOffset:h,align:n,side:l,alignOffset:r,collisionPadding:_,collisionAvoidance:b,className:T,children:O}),t[27]=n,t[28]=r,t[29]=i,t[30]=b,t[31]=_,t[32]=l,t[33]=h,t[34]=O,t[35]=T,t[36]=k):k=t[36];let A;return t[37]!==k||t[38]!==w?(A=(0,Z.jsx)(S,{container:w,children:k}),t[37]=k,t[38]=w,t[39]=A):A=t[39],A}function Zn(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=qn(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(Ye,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)(y,{"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 Qn(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)(b,{"data-slot":`dropdown-menu-radio-group`,...n}),t[2]=n,t[3]=r),r}function $n(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)(h,{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 er(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 tr(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(Je,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(_,{"data-slot":`dropdown-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function nr(){let e=(0,K.c)(5),t=W(or),n=W(ar),r=W(ir),i=W(rr),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 rr(e){return e.providers.length>0}function ir(e){return e.lastDisconnectReason}function ar(e){return e.connectionPhase}function or(e){return e.isInitialized}var sr=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}=fe(),{isReady:f,isUnavailable:p}=nr(),m=W(cr),h=Ee(lr),g=W(ur),{data:_}=_e(),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=be(x);S=a?e.filter(a):e,t[2]=a,t[3]=x,t[4]=S}else S=t[4];let C=S,w=A(dr),{isMobile:T}=Be(),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 j=ue(k),M=ue(fr),ee=Q.useId(),te,N;t[6]!==c||t[7]!==h||t[8]!==g||t[9]!==x.length?(te=()=>{c||x.length>0||(g(),h())},N=[c,x.length,g,h],t[6]=c,t[7]=h,t[8]=g,t[9]=x.length,t[10]=te,t[11]=N):(te=t[10],N=t[11]),Q.useEffect(te,N);let ne;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(ne=()=>O(!1),t[12]=ne):ne=t[12];let re=ne,ie;t[13]===r?ie=t[14]:(ie=e=>{r(e)},t[13]=r,t[14]=ie);let P=ie,F;t[15]!==n||t[16]!==C||t[17]!==P||t[18]!==E||t[19]!==D||t[20]!==ee||t[21]!==d?(F=()=>E?(0,Z.jsx)(We,{id:`mobile-agent-selector-sheet-${ee}`,open:D,onOpenChange:e=>{e||re()},ariaLabel:d(`settings.commands.agentSelector.title`),closeAriaLabel:d(`mobile.surface.closeAria`),resizeAriaLabel:d(`mobile.sessions.sheet.resizeAria`),bodyClassName:`px-2`,children:(0,Z.jsxs)(Ge,{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:()=>{P(``),re()},children:[(0,Z.jsx)(De,{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:()=>{P(e.name),re()},children:[(0,Z.jsx)(De,{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]=P,t[18]=E,t[19]=D,t[20]=ee,t[21]=d,t[22]=F):F=t[22];let I=F,L;t[23]!==n||t[24]!==C||t[25]!==i||t[26]!==l||t[27]!==P||t[28]!==M||t[29]!==E||t[30]!==f||t[31]!==p||t[32]!==j||t[33]!==u||t[34]!==d?(L=E?(0,Z.jsxs)(`button`,{type:`button`,onClick:f?j: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)(De,{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)(Jn,{onOpenChange:M,children:[(0,Z.jsx)(Yn,{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)(De,{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)(Xn,{className:`max-w-[300px]`,portalToBody:l,children:[(0,Z.jsxs)(Zn,{className:`typography-meta`,onSelect:()=>P(``),children:[(0,Z.jsx)(De,{name:`default`,size:14}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:d(`settings.commands.agentSelector.notSelected`)})]}),C.map(e=>(0,Z.jsxs)(Zn,{className:`typography-meta`,onSelect:()=>P(e.name),children:[(0,Z.jsx)(De,{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]=P,t[28]=M,t[29]=E,t[30]=f,t[31]=p,t[32]=j,t[33]=u,t[34]=d,t[35]=L):L=t[35];let R;t[36]===I?R=t[37]:(R=I(),t[36]=I,t[37]=R);let ae;return t[38]!==L||t[39]!==R?(ae=(0,Z.jsxs)(Z.Fragment,{children:[L,R]}),t[38]=L,t[39]=R,t[40]=ae):ae=t[40],ae};function cr(e){return e.agents}function lr(e){return e.loadAgents}function ur(e){return e.loadAgents}function dr(e){return e.isMobile}function fr(e){e&&W.getState().refreshCatalogsOnPickerOpen({source:`agentSelector:desktopMenu`})}var pr={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}},mr=null,hr={},gr=(e,t)=>{mr!==t&&(mr=t,hr.compact=void 0,hr.compactTokensShort=void 0,hr.usd=void 0);let n=hr[e];if(n)return n;let r=new Intl.NumberFormat(t,pr[e]);return hr[e]=r,r},_r=(e,t=H())=>gr(`compact`,t).format(e),vr=(e,t=H())=>gr(`compactTokensShort`,t).format(e),yr=(e,t=H())=>gr(`usd`,t).format(e),br=(e,t=H())=>e.toLocaleDateString(t,{month:`short`,day:`numeric`,year:`numeric`}),xr=(e,t=H())=>new Date(e).toLocaleDateString(t,{year:`numeric`,month:`short`,day:`numeric`}),Sr=(e,t=H())=>new Date(e).toLocaleTimeString(t,{hour:`numeric`,minute:`2-digit`}),Cr=8,wr=e=>typeof e!=`number`||Number.isNaN(e)?``:vr(e),Tr=(e,t,n)=>{let r=e.find(e=>e.id===t)?.models?.find(e=>e.id===n);return r?.variants?Object.keys(r.variants):[]},Er=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}=fe(),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,M]=Q.useState(null),[ee,te]=Q.useState(`model`),[N,ne]=Q.useState(null),re=Q.useRef(!1),ie=y??ee,P,F;t[4]!==n||t[5]!==i?(P=()=>{n&&!re.current&&A(new Set(i?[i]:[])),n||(D(``),M(null),te(`model`),ne(null)),re.current=n},F=[n,i],t[4]=n,t[5]=i,t[6]=P,t[7]=F):(P=t[6],F=t[7]),Q.useEffect(P,F);let I;t[8]===b?I=t[9]:(I=e=>{te(e),b?.(e)},t[8]=b,t[9]=I);let L=I,R=ie===`variant`&&!!(N??(i&&a)),ae=`mobile-model-picker-sheet-${T}`,z;t[10]===r?z=t[11]:(z=e=>{e||r()},t[10]=r,t[11]=z);let oe;t[12]!==R||t[13]!==L||t[14]!==w?(oe=R?(0,Z.jsx)(me,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>L(`model`),"aria-label":w(`onboarding.common.actions.back`),children:(0,Z.jsx)(G,{name:`arrow-left`,className:`size-5`})}):void 0,t[12]=R,t[13]=L,t[14]=w,t[15]=oe):oe=t[15];let B;t[16]!==R||t[17]!==w?(B=w(R?`chat.modelControls.thinking`:`chat.modelControls.selectModel`),t[16]=R,t[17]=w,t[18]=B):B=t[18];let se;t[19]===w?se=t[20]:(se=w(`mobile.surface.closeAria`),t[19]=w,t[20]=se);let V;t[21]===w?V=t[22]:(V=w(`mobile.sessions.sheet.resizeAria`),t[21]=w,t[22]=V);let ce;t[23]!==ie||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]!==L||t[42]!==C||t[43]!==N?(ce=(0,Z.jsx)(Dr,{query:E,onQueryChange:D,expandedProviders:k,onExpandedProvidersChange:A,expandedModelKey:j,onExpandedModelKeyChange:M,activeView:ie,setView:L,variantTarget:N,onVariantTargetChange:ne,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]=ie,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]=L,t[42]=C,t[43]=N,t[44]=ce):ce=t[44];let le;return t[45]!==n||t[46]!==oe||t[47]!==B||t[48]!==se||t[49]!==V||t[50]!==ce||t[51]!==ae||t[52]!==z?(le=(0,Z.jsx)(We,{id:ae,open:n,onOpenChange:z,leading:oe,ariaLabel:B,closeAriaLabel:se,resizeAriaLabel:V,bodyClassName:`px-2`,children:ce}),t[45]=n,t[46]=oe,t[47]=B,t[48]=se,t[49]=V,t[50]=ce,t[51]=ae,t[52]=z,t[53]=le):le=t[53],le},Dr=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}=fe(),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(Or)):null,t[2]=x,t[3]=A);let j=A,M;t[4]===y?M=t[5]:(M=new Set(y.map(kr)),t[4]=y,t[5]=M);let ee=M,te;t[6]===g?te=t[7]:(te=new Map(g.map(Ar)),t[6]=g,t[7]=te);let N=te,ne;bb0:{if(!S?.length){ne=g;break bb0}let e;t[8]===S?e=t[9]:(e=new Map(S.map(jr)),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];ne=r}let re=ne,ie;t[15]!==j||t[16]!==k||t[17]!==ee?(ie=(e,t)=>k&&!k.has(e)||j&&j.get(e)?.has(t)!==!0?!1:!ee.has(`${e}:${t}`),t[15]=j,t[16]=k,t[17]=ee,t[18]=ie):ie=t[18];let P=ie,F;t[19]!==N||t[20]!==n?(F=e=>{let t=n.trim();if(!t)return!0;let r=N.get(e.providerID)?.name||e.providerID,i=we(e.model,e.modelID,{maxLength:40});return Me(i,t)||Me(e.modelID,t)||Me(r,t)},t[19]=N,t[20]=n,t[21]=F):F=t[21];let I=F,L;if(t[22]!==_||t[23]!==P||t[24]!==I){let e;t[26]!==P||t[27]!==I?(e=e=>P(e.providerID,e.modelID)&&I(e),t[26]=P,t[27]=I,t[28]=e):e=t[28],L=_.filter(e),t[22]=_,t[23]=P,t[24]=I,t[25]=L}else L=t[25];let R=L,ae;if(t[29]!==P||t[30]!==I||t[31]!==v){let e;t[33]!==P||t[34]!==I?(e=e=>P(e.providerID,e.modelID)&&I(e),t[33]=P,t[34]=I,t[35]=e):e=t[35],ae=v.filter(e),t[29]=P,t[30]=I,t[31]=v,t[32]=ae}else ae=t[32];let z=ae,oe;if(t[36]!==k||t[37]!==P||t[38]!==re||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),oe=re.filter(r).map(t=>{let n=e.length>0&&(Me(t.name||t.id,e)||Me(t.id,e));return{provider:t,models:(t.models??[]).filter(r=>{let i=typeof r.id==`string`?r.id:``;return!i||!P(t.id,i)?!1:n||!e?!0:Me(we(r,i,{maxLength:40}),e)||Me(i,e)})}}).filter(Mr),t[36]=k,t[37]=P,t[38]=re,t[39]=n,t[40]=oe}else oe=t[40];let B=oe,se;t[43]===D?se=t[44]:(se=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]=se);let V=se,ce;t[45]===D?ce=t[46]:(ce=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]=ce);let le=ce,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,pe;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(pe={onPointerDown:He,onClickCapture:Nr},t[50]=pe):pe=t[50];let H=pe,me;t[51]!==o||t[52]!==V||t[53]!==E||t[54]!==le||t[55]!==w||t[56]!==s||t[57]!==h||t[58]!==T||t[59]!==de||t[60]!==N||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=Le(i,r,E?.(i,a)),d=C?Tr(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,Cr),S=o===c,O=le(u),k=u?.limit?.context?`${wr(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`,...H,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:N.get(i)?.name||i}):null,(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Z.jsx)(Pe,{modelId:a,providerId:i,className:`size-3.5 flex-shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate typography-meta font-medium text-foreground`,children:we(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`,...H,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:V(b)}),(0,Z.jsx)(G,{name:S?`arrow-down-s`:`arrow-right-s`,className:`size-3.5`})]}):null,(0,Z.jsx)(`button`,{type:`button`,...H,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`,...H,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:V(e)},`${c}-${e??`default`}`)}),x.length<d.length+1?(0,Z.jsx)(`button`,{type:`button`,...H,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]=V,t[53]=E,t[54]=le,t[55]=w,t[56]=s,t[57]=h,t[58]=T,t[59]=de,t[60]=N,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 he=me,ge,_e,ve,ye,be,xe,Se,Ce,Te,W;if(t[68]!==c||t[69]!==i||t[70]!==R||t[71]!==B||t[72]!==z||t[73]!==V||t[74]!==s||t[75]!==a||t[76]!==r||t[77]!==h||t[78]!==g||t[79]!==n||t[80]!==he||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?Tr(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,_=R.length>0||z.length>0||B.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)(Re,{type:`text`,value:n,onChange:e=>{r(e.target.value),s(null)},onPointerUp:Pr,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],ge=Ge,ye=!0,be=!0,xe=!0,Se=`min-h-0 flex-1`,Ce=`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`),...H,onClick:()=>h(e.providerID,e.modelID,t),children:[(0,Z.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:V(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`)}),R.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:R.map(e=>he(e,{showProvider:!0,preferRememberedVariant:!0}))})]}):null,z.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:z.map(e=>he(e,{showProvider:!0,preferRememberedVariant:!0}))})]}):null,B.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`,...H,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)(Ie,{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=>he({model:e,providerID:t.id,modelID:e.id}))}):null]},t.id)})]}),t[68]=c,t[69]=i,t[70]=R,t[71]=B,t[72]=z,t[73]=V,t[74]=s,t[75]=a,t[76]=r,t[77]=h,t[78]=g,t[79]=n,t[80]=he,t[81]=m,t[82]=p,t[83]=f,t[84]=D,t[85]=u,t[86]=ge,t[87]=_e,t[88]=ve,t[89]=ye,t[90]=be,t[91]=xe,t[92]=Se,t[93]=Ce,t[94]=Te,t[95]=W}else ge=t[86],_e=t[87],ve=t[88],ye=t[89],be=t[90],xe=t[91],Se=t[92],Ce=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]!==ge||t[106]!==ye||t[107]!==be||t[108]!==xe||t[109]!==Se||t[110]!==Ce||t[111]!==Ee?(De=(0,Z.jsx)(ge,{useScrollShadow:ye,disableHorizontal:be,preventOverscroll:xe,outerClassName:Se,className:Ce,children:Ee}),t[105]=ge,t[106]=ye,t[107]=be,t[108]=xe,t[109]=Se,t[110]=Ce,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 Or(e){let[t,n]=e;return[t,new Set(n)]}function kr(e){return`${e.providerID}:${e.modelID}`}function Ar(e){return[e.id,e]}function jr(e,t){return[e,t]}function Mr(e){return e.models.length>0}function Nr(e){Ue(e)||(e.preventDefault(),e.stopPropagation())}function Pr(e){document.activeElement!==e.currentTarget&&e.currentTarget.focus({preventScroll:!0})}var Fr=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:_}=fe(),{isReady:v,isUnavailable:y}=nr(),b=W(Ir),x=p??b,S=W(Lr),C=A(Rr),w=A(zr),T=A(Br),E=A(Vr),D=A(Hr),O=A(Ur),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:j,recentModelsList:M}=Ne(k),{isMobile:ee}=Be(),te=C||ee,[N,ne]=Q.useState(!1),[re,ie]=Q.useState(!1),P;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(P=()=>{ne(!0),W.getState().refreshCatalogsOnPickerOpen({source:`modelSelector:mobilePanel`})},t[3]=P):P=t[3];let F=ue(P),I;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(I=e=>{ie(e),e&&W.getState().refreshCatalogsOnPickerOpen({source:`modelSelector:desktopMenu`})},t[4]=I):I=t[4];let L=ue(I),[R,ae]=Q.useState(``),[z,oe]=Q.useState(null),B=i!==void 0,se;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(se=()=>{ne(!1),ie(!1),ae(``),oe(null)},t[5]=se):se=t[5];let V=se,ce;t[6]===x?ce=t[7]:(ce=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]=ce);let le=ce,de;t[8]!==D||t[9]!==le||t[10]!==r||t[11]!==a||t[12]!==n||t[13]!==i||t[14]!==B?(de=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,B?c:void 0),D(e.providerID,e.modelID,B&&c||void 0),V()},t[8]=D,t[9]=le,t[10]=r,t[11]=a,t[12]=n,t[13]=i,t[14]=B,t[15]=de):de=t[15];let pe=de,H;t[16]!==a||t[17]!==B?(H=()=>{a(``,``,B?``:void 0),V()},t[16]=a,t[17]=B,t[18]=H):H=t[18];let me=H,he;t[19]!==D||t[20]!==a||t[21]!==z?(he=e=>{z&&(a(z.providerID,z.modelID,e),D(z.providerID,z.modelID,e||void 0),V())},t[19]=D,t[20]=a,t[21]=z,t[22]=he):he=t[22];let ge=he,_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 Ie;t[56]===_?Ie=t[57]:(Ie=_(`chat.modelControls.costInput`),t[56]=_,t[57]=Ie);let Le;t[58]===_?Le=t[59]:(Le=_(`chat.modelControls.costOutput`),t[58]=_,t[59]=Le);let Re;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]!==Ie||t[77]!==Le?(Re={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:Ie,costOutput:Le},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]=Ie,t[77]=Le,t[78]=Re):Re=t[78];let ze=Re,Ve;t[79]!==r||t[80]!==n?(Ve=n&&r?{providerID:n,modelID:r}:null,t[79]=r,t[80]=n,t[81]=Ve):Ve=t[81];let He=Ve,Ue;t[82]!==r||t[83]!==l||t[84]!==n||t[85]!==_?(Ue=n&&r?`${n}/${r}`:l||_(`settings.agents.modelSelector.notSelected`),t[82]=r,t[83]=l,t[84]=n,t[85]=_,t[86]=Ue):Ue=t[86];let We=Ue,Ge;t[87]!==_||t[88]!==i||t[89]!==B?(Ge=B?i||_(`chat.modelControls.default`):null,t[87]=_,t[88]=i,t[89]=B,t[90]=Ge):Ge=t[90];let Ke=Ge,qe;t[91]!==r||t[92]!==n||t[93]!==i||t[94]!==B?(qe=(e,t)=>{if(!(!B||e!==n||t!==r))return i||void 0},t[91]=r,t[92]=n,t[93]=i,t[94]=B,t[95]=qe):qe=t[95];let Je=qe,Ye;t[96]!==D||t[97]!==a||t[98]!==B?(Ye=(e,t,n)=>{a(e,t,B?n??``:void 0),D(e,t,B&&n||void 0),V()},t[96]=D,t[97]=a,t[98]=B,t[99]=Ye):Ye=t[99];let Xe=Ye,Ze;t[100]!==le||t[101]!==_||t[102]!==i||t[103]!==B?(Ze=(e,t)=>{let n=le(e);if(!B||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(),oe(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]=B,t[104]=Ze):Ze=t[104];let Qe=Ze,$e=te?`max-h-none flex-1`:void 0,et=m&&(te?N:re),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]!==j||t[115]!==S||t[116]!==pe||t[117]!==me||t[118]!==w||t[119]!==ze||t[120]!==O||t[121]!==x||t[122]!==M||t[123]!==Qe||t[124]!==R||t[125]!==He||t[126]!==$e||t[127]!==et||t[128]!==tt||t[129]!==nt?(rt=(0,Z.jsx)(Fe,{providers:x,providerOrder:O,favoriteModels:j,recentModels:M,getMetadata:S,searchQuery:R,onSearchQueryChange:ae,onSelect:pe,labels:ze,selectedModel:He,hiddenModels:w,allowedProviderIds:s,allowedModelIdsByProvider:c,includeNotSelected:!0,onSelectNone:me,onEscape:V,maxHeightClassName:$e,tooltipsEnabled:et,isFavorite:tt,onToggleFavorite:nt,renderRowEnd:Qe}),t[112]=c,t[113]=s,t[114]=j,t[115]=S,t[116]=pe,t[117]=me,t[118]=w,t[119]=ze,t[120]=O,t[121]=x,t[122]=M,t[123]=Qe,t[124]=R,t[125]=He,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]!==z?(at=z?le(z):[],t[131]=le,t[132]=z,t[133]=at):at=t[133];let ot=at,q;bb0:{if(!z){q=``;break bb0}if(z.providerID===n&&z.modelID===r){q=i||``;break bb0}q=z.variant!==void 0&&ot.includes(z.variant)?z.variant:``}let J=q,Y;t[134]!==ge||t[135]!==_||t[136]!==z||t[137]!==J||t[138]!==ot?(Y=z?(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:()=>oe(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:z.modelID})]}),(0,Z.jsx)(`div`,{className:`space-y-1 p-2`,role:`listbox`,"aria-label":_(`chat.modelControls.thinking`),children:[``,...ot].map(e=>{let t=J===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:()=>ge(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]=ge,t[135]=_,t[136]=z,t[137]=J,t[138]=ot,t[139]=Y):Y=t[139];let X=Y||it;if(te){let e=v?F: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)(Pe,{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]!==We?(f=v?(0,Z.jsx)(`span`,{className:`typography-meta font-medium text-foreground truncate`,children:We}):null,t[150]=v,t[151]=We,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]!==j||t[167]!==r||t[168]!==n||t[169]!==M||t[170]!==T||t[171]!==i?(C=(e,t)=>T(e,t,e===n&&t===r?i||void 0:j.find(n=>n.providerID===e&&n.modelID===t)?.variant??M.find(n=>n.providerID===e&&n.modelID===t)?.variant),t[166]=j,t[167]=r,t[168]=n,t[169]=M,t[170]=T,t[171]=i,t[172]=C):C=t[172];let D;t[173]!==c||t[174]!==s||t[175]!==j||t[176]!==S||t[177]!==Xe||t[178]!==w||t[179]!==E||t[180]!==N||t[181]!==r||t[182]!==n||t[183]!==O||t[184]!==x||t[185]!==M||t[186]!==Je||t[187]!==C||t[188]!==B?(D=(0,Z.jsx)(Er,{open:N,onClose:V,selectedProviderID:n,selectedModelID:r,resolveSelectedVariant:Je,onSelect:Xe,providers:x,favoriteModels:j,recentModels:M,getMetadata:S,hiddenModels:w,allowedProviderIds:s,allowedModelIdsByProvider:c,providerOrder:O,variantSelectionEnabled:B,isFavorite:E,onToggleFavorite:C}),t[173]=c,t[174]=s,t[175]=j,t[176]=S,t[177]=Xe,t[178]=w,t[179]=E,t[180]=N,t[181]=r,t[182]=n,t[183]=O,t[184]=x,t[185]=M,t[186]=Je,t[187]=C,t[188]=B,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 st=v&&re,ct=v?L:void 0,lt=!v&&`opacity-60 cursor-not-allowed`,ut;t[193]!==o||t[194]!==lt?(ut=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`,lt,o),t[193]=o,t[194]=lt,t[195]=ut):ut=t[195];let dt;t[196]!==v||t[197]!==y||t[198]!==r||t[199]!==n||t[200]!==g||t[201]!==_||t[202]!==We||t[203]!==Ke?(dt=v?(0,Z.jsxs)(Z.Fragment,{children:[g?n||r?(0,Z.jsx)(Pe,{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:We}),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]=We,t[203]=Ke,t[204]=dt):dt=t[204];let ft;t[205]===Symbol.for(`react.memo_cache_sentinel`)?(ft=(0,Z.jsx)(G,{name:`arrow-down-s`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground/50`}),t[205]=ft):ft=t[205];let pt;t[206]!==ut||t[207]!==dt?(pt=(0,Z.jsx)(Yn,{asChild:!0,children:(0,Z.jsxs)(`div`,{className:ut,children:[dt,ft]})}),t[206]=ut,t[207]=dt,t[208]=pt):pt=t[208];let mt;t[209]!==h||t[210]!==X?(mt=(0,Z.jsx)(Xn,{className:`w-[min(380px,calc(100vw-2rem))] p-0 flex flex-col`,align:`start`,portalToBody:h,children:X}),t[209]=h,t[210]=X,t[211]=mt):mt=t[211];let ht;return t[212]!==st||t[213]!==ct||t[214]!==pt||t[215]!==mt?(ht=(0,Z.jsxs)(Jn,{open:st,onOpenChange:ct,children:[pt,mt]}),t[212]=st,t[213]=ct,t[214]=pt,t[215]=mt,t[216]=ht):ht=t[216],ht};function Ir(e){return e.providers}function Lr(e){return e.getModelMetadata}function Rr(e){return e.isMobile}function zr(e){return e.hiddenModels}function Br(e){return e.toggleFavoriteModel}function Vr(e){return e.isFavoriteModel}function Hr(e){return e.addRecentModel}function Ur(e){return e.providerOrder}var Wr=e(D(),1),Gr=`mobile-overlay-root`,Kr=16,qr=200,Jr=[],Yr=0,Xr=``,Zr=0,Qr=()=>{if(typeof document>`u`)return null;let e=document.getElementById(Gr);return e||(e=document.createElement(`div`),e.id=Gr,document.body.appendChild(e)),e},$r=({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=Qr()),Q.useEffect(()=>{if(!e){m(!1),g(!1);return}let t=window.setTimeout(()=>m(!0),Kr),n=window.setTimeout(()=>g(!0),266);return()=>{window.clearTimeout(t),window.clearTimeout(n)}},[e]),Q.useLayoutEffect(()=>{if(e)return Zr===0&&window.dispatchEvent(new Event(`oc:mobile-overlay-opened`)),Zr+=1,()=>{Zr=Math.max(0,Zr-1),Zr===0&&window.dispatchEvent(new Event(`oc:mobile-overlay-closed`))}},[e]),Q.useEffect(()=>{if(!e)return;let t=d.current;Jr.push(t),Yr===0&&(Xr=document.body.style.overflow),Yr+=1,document.body.style.overflow=`hidden`;let n=e=>{e.key===`Escape`&&Jr[Jr.length-1]===t&&f.current()};return document.addEventListener(`keydown`,n),()=>{let e=Jr.lastIndexOf(t);e>=0&&Jr.splice(e,1),Yr=Math.max(0,Yr-1),Yr===0&&(document.body.style.overflow=Xr),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:Ve,onClick:e=>{Ke(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 ${qr}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)(Ge,{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,Wr.createPortal)(v,u.current)},ei=e=>e??a()?.github,ti=(e=t())=>c.github.auth(e),ni=async(e,t)=>{if(e)return e.authStatus();let n=await r(`/api/github/auth/status`,{method:`GET`,headers:{Accept:`application/json`},signal:t}),i=await n.json().catch(()=>null);if(!n.ok||!i)throw Error(i?.error||n.statusText||`Failed to load GitHub status`);return i},ri=(e,n=t())=>{let r=ei(e);return{queryKey:ti(n),queryFn:async({signal:e})=>ni(r,e),retry:2}},ii=e=>!!e&&typeof e==`object`&&`authStatus`in e,ai=e=>{let t=(0,K.c)(5),n=ii(e)?e:void 0,r=ii(e)?void 0:e?.enabled,i;t[0]===n?i=t[1]:(i=ri(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],ie(a)},oi=(e=o,n=t())=>e.getQueryData(ti(n))??null,si=async(e,n,r)=>t()===r?e.fetchQuery({...ri(n,r),staleTime:0}):e.getQueryData(ti(r))??null,ci=(e=o,n,r=t())=>{e.setQueryData(ti(r),n)},li=L.define(le),ui=se.data.of({commentTokens:{line:`//`,block:{open:`/*`,close:`*/`}}});function di(e){let t=e.trim().toLowerCase();switch(t){case`bash`:case`sh`:case`zsh`:case`shell`:case`shellsession`:case`console`:return li;case`json`:case`jsonc`:case`json5`:return B().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 oe().language;case`css`:return ae().language;case`py`:case`python`:return ce().language;case`md`:case`markdown`:case`mdown`:case`mkd`:return V().language;case`heex`:case`eex`:case`leex`:return oe().language;default:return R.matchLanguageName(Xe,t,!0)}}var fi=e=>e.split(`/`).pop()?.toLowerCase()??``,pi=e=>{let t=fi(e);return t?R.matchFilename(Xe,t):null},mi=()=>P(I.define([{tag:[F.heading1,F.heading2,F.heading3,F.heading4,F.heading5,F.heading6],fontWeight:`600`},{tag:F.strong,fontWeight:`600`},{tag:F.emphasis,fontStyle:`italic`},{tag:F.strikethrough,textDecoration:`line-through`},{tag:[F.link,F.url],color:`var(--markdown-link, currentColor)`,textDecoration:`underline`},{tag:F.monospace,color:`var(--markdown-inline-code, currentColor)`,backgroundColor:`var(--markdown-inline-code-bg, transparent)`},{tag:F.quote,color:`var(--markdown-blockquote, currentColor)`,fontStyle:`italic`},{tag:F.list,color:`color-mix(in srgb, var(--muted-foreground) 40%, var(--foreground) 60%)`},{tag:F.heading,color:`var(--markdown-heading1, currentColor)`}]));function hi(e){let t=e.toLowerCase();switch(fi(t)){case`makefile`:case`gnumakefile`:return li}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[B(),ui];case`json`:case`jsonl`:case`ndjson`:case`geojson`:return B();case`css`:case`scss`:case`sass`:case`less`:return ae();case`html`:case`htm`:case`xml`:case`drawio`:case`dio`:return oe();case`md`:case`mdx`:case`markdown`:case`mdown`:case`mkd`:return[V({codeLanguages:di}),mi()];case`sh`:case`bash`:case`zsh`:case`fish`:case`env`:return li;case`py`:case`pyw`:case`pyi`:return ce();default:return null}}async function gi(e){let t=pi(e);if(!t)return null;if(t.support)return t.support;try{return await t.load()}catch{return null}}var _i=e=>e===`allow`||e===`deny`||e===`ask`;function vi(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function yi(e){return vi(e)?typeof e.action==`string`&&typeof e.resource==`string`&&_i(e.effect)?{action:e.action,resource:e.resource,effect:e.effect}:typeof e.permission==`string`&&typeof e.pattern==`string`&&_i(e.action)?{action:e.permission,resource:e.pattern,effect:e.action}:null:null}function bi(e){if(Array.isArray(e))return e.flatMap(e=>{let t=yi(e);return t?[t]:[]});if(_i(e))return[{action:`*`,resource:`*`,effect:e}];if(!vi(e))return[];let t=[];for(let[n,r]of Object.entries(e))if(n!==`__originalKeys`){if(_i(r)){t.push({action:n,resource:`*`,effect:r});continue}if(vi(r))for(let[e,i]of Object.entries(r))_i(i)&&t.push({action:n,resource:e,effect:i})}return t}function xi(e){return bi(e)}var Si=60,Ci=400;function wi(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+=Ci){let n=e.slice(t,t+Ci);i&&i.length+n.length>Ci&&(r.push(i.trim()),i=``),i+=n,i.length>=Si&&/[.!?…]["')\]]*\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 Ti=null;function Ei(){return Ti||=new(window.AudioContext||window.webkitAudioContext),Ti}function Di(){let[e,t]=(0,Q.useState)(!1),[n,i]=(0,Q.useState)(null),a=(0,Q.useRef)(null),o=(0,Q.useRef)(null),s=(0,Q.useCallback)(async()=>{try{let e=Ei();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),a.current){try{a.current.onended=null,a.current.stop()}catch{}a.current=null}t(!1)},[]),l=(0,Q.useCallback)(async(e,n)=>{c();let s=wi(e);if(s.length===0){i(`No text to speak`),n?.onError?.(`No text to speak`);return}i(null);let l={cancelled:!1,abort:new AbortController};o.current=l;let u=async e=>{let t=await r(`/api/dictation/tts/speak`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e,...typeof n?.speakerId==`number`?{speakerId:n.speakerId}:{},...typeof n?.speed==`number`?{speed:n.speed}:{}}),signal:l.abort.signal});if(!t.ok){let e=await t.json().catch(()=>({error:`Unknown error`}));throw Error(e.error||`HTTP ${t.status}`)}return(await t.blob()).arrayBuffer()},d=async e=>{let t=Ei();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),a.current=r,r.onended=()=>{a.current===r&&(a.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 r=e instanceof Error?e.message:`Failed to speak`;i(r),n?.onError?.(r),t(!1)}finally{o.current===l&&(o.current=null)}},[c]);return(0,Q.useEffect)(()=>()=>{c()},[c]),{isPlaying:e,error:n,speak:l,stop:c,unlockAudio:s}}var Oi=new class{recognition=null;isListening=!1;currentLang=`en-US`;onResultCallback=null;onErrorCallback=null;restartOnEnd=!1;conversationMode=!1;isSpeaking=!1;audioContext=null;audioUnlockRequired=!1;isSupported(){let e=`SpeechRecognition`in window||`webkitSpeechRecognition`in window,t=`speechSynthesis`in window;return e&&t}getSupportDetails(){return{recognition:`SpeechRecognition`in window||`webkitSpeechRecognition`in window,synthesis:`speechSynthesis`in window,prefixed:!(`SpeechRecognition`in window)&&`webkitSpeechRecognition`in window,secureContext:window.isSecureContext}}setConversationMode(e){this.conversationMode=e,e||(this.restartOnEnd=!1)}isConversationMode(){return this.conversationMode}pauseListening(){if(this.restartOnEnd=!1,this.recognition)try{this.recognition.stop()}catch{}this.isListening=!1}resumeListening(){if(this.conversationMode,this.onResultCallback,this.isSpeaking,this.currentLang,this.conversationMode&&this.onResultCallback&&!this.isSpeaking)try{this.startListeningSync(this.currentLang,this.onResultCallback,this.onErrorCallback||void 0)}catch(e){console.error(`[BrowserVoiceService] Failed to resume listening:`,e)}}async checkMicrophonePermission(){try{return`permissions`in navigator&&(await navigator.permissions.query({name:`microphone`})).state===`granted`}catch{return!1}}async prepareListening(){if(!this.isSupported())throw Error(`Web Speech API not supported in this browser`);if(typeof navigator>`u`||typeof navigator.mediaDevices?.getUserMedia!=`function`)return!0;try{return(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(e=>e.stop()),!0}catch(e){let t=typeof e==`object`&&e&&`name`in e?String(e.name):``;if(t===`NotAllowedError`)throw Error(`Microphone permission denied`);if(t===`NotFoundError`)throw Error(`No microphone found`);let n=e instanceof Error?e.message:`Unable to access microphone`;throw Error(n)}}startListeningSync(e,t,n){if(!this.isSupported()){let e=`Web Speech API not supported in this browser`;throw n?.(e),Error(e)}this.stopListening();let r=window.SpeechRecognition||window.webkitSpeechRecognition;if(!r){let e=`Web Speech API not supported in this browser`;throw n?.(e),Error(e)}let i=new r;this.recognition=i,this.currentLang=e,this.onResultCallback=t,this.onErrorCallback=n||null,i.continuous=!0,i.interimResults=!0,i.lang=e,i.onstart=()=>{this.isListening=!0,this.restartOnEnd=!0},i.onaudiostart=()=>{},i.onsoundstart=()=>{},i.onresult=e=>{e.results.length;let t=``,n=``;for(let r=e.resultIndex;r<e.results.length;r++){let i=e.results[r];i.isFinal?t+=i[0].transcript:n+=i[0].transcript}n&&this.onResultCallback?.(n,!1),t&&this.onResultCallback?.(t,!0)},i.onerror=e=>{if(e.error===`aborted`)return;let t=this.getErrorMessage(e.error);this.onErrorCallback?.(t),(e.error===`not-allowed`||e.error===`service-not-allowed`||e.error===`network`)&&(this.restartOnEnd=!1,this.isListening=!1)},i.onend=()=>{if(this.isListening=!1,this.restartOnEnd&&this.recognition&&!this.isSpeaking)try{this.recognition.start()}catch{}};try{i.start()}catch(e){let t=e instanceof Error?e.message:`Failed to start speech recognition`;throw n?.(t),Error(t)}}async startListening(e,t,n){this.startListeningSync(e,t,n)}stopListening(){if(this.restartOnEnd=!1,this.recognition){try{this.recognition.stop()}catch{}this.recognition=null}this.isListening=!1}getIsListening(){return this.isListening}getCurrentLang(){return this.currentLang}async resumeAudioContext(){this.audioContext||=new(window.AudioContext||window.webkitAudioContext),this.audioContext.state===`suspended`&&await this.audioContext.resume()}isAudioUnlockRequired(){return this.audioUnlockRequired}async unlockAudio(){try{let e=new Audio;if(e.src=`data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA`,e.volume=.01,await e.play(),await this.resumeAudioContext(),this.isMobileDevice()&&`speechSynthesis`in window){let e=new SpeechSynthesisUtterance(``);e.volume=0,window.speechSynthesis.speak(e),window.speechSynthesis.cancel()}return this.audioUnlockRequired=!1,!0}catch(e){return console.error(`[BrowserVoiceService] Failed to unlock audio:`,e),!1}}async speakText(e,t,n,r){if(!(`speechSynthesis`in window))throw Error(`Speech synthesis not supported`);await this.resumeAudioContext();let i=await this.waitForVoices();await new Promise(e=>setTimeout(e,50)),this.isSpeaking=!0,this.pauseListening(),window.speechSynthesis.cancel();let a=new SpeechSynthesisUtterance(e);a.lang=t,a.rate=r?.rate??1,a.pitch=r?.pitch??1,a.volume=r?.volume??1;let o=null;return r?.voiceName&&(o=i.find(e=>e.name===r.voiceName)||null,o?`${o.name}${o.lang}`:console.warn(`[BrowserVoiceService] Selected voice "${r.voiceName}" not found, falling back to language match`)),o||(o=this.findBestVoice(i,t),o?`${o.name}${o.lang}`:console.warn(`[BrowserVoiceService] No voice found for language: ${t}, using default`)),o&&(a.voice=o),`${e.length}${t}`,new Promise((e,t)=>{let r=!1;a.onstart=()=>{r=!0,e()},a.onend=()=>{this.isSpeaking=!1,n?.()},a.onerror=e=>{this.isSpeaking=!1,console.error(`[BrowserVoiceService] Speech synthesis error:`,e.error),(e.error===`not-allowed`||e.error===`interrupted`)&&(this.audioUnlockRequired=!0);let n=`Speech synthesis error: ${e.error||`unknown`}`;e.error===`not-allowed`?n=`Audio blocked by browser autoplay policy. Please interact with the page first.`:e.error===`interrupted`&&(n=`Speech was interrupted. Please try again.`),t(Error(n))},setTimeout(()=>{r||(console.warn(`[BrowserVoiceService] Speech start timeout - audio may be blocked`),this.audioUnlockRequired=!0)},2e3),window.speechSynthesis.speak(a)})}cancelSpeech(){`speechSynthesis`in window&&window.speechSynthesis.cancel()}getVoices(){return`speechSynthesis`in window?window.speechSynthesis.getVoices():[]}async waitForVoices(){if(!(`speechSynthesis`in window))return[];let e=window.speechSynthesis.getVoices();return e.length>0?e:new Promise(e=>{let t=()=>{e(window.speechSynthesis.getVoices()),window.speechSynthesis.onvoiceschanged=null};window.speechSynthesis.onvoiceschanged=t,setTimeout(()=>{e(window.speechSynthesis.getVoices()),window.speechSynthesis.onvoiceschanged=null},1e3)})}findBestVoice(e,t){let n=e.find(e=>e.lang===t);if(!n){let r=t.split(`-`)[0];n=e.find(e=>e.lang.startsWith(r))}return n||=e.find(e=>e.lang.startsWith(t.split(`-`)[0])&&e.localService),n||null}isMobileDevice(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent.toLowerCase();return/iphone|ipad|ipod|android|mobile|webos|blackberry|iemobile|opera mini/i.test(e)}isIOSSafari(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent.toLowerCase(),t=/iphone|ipad|ipod/i.test(e),n=/safari/i.test(e)&&!/chrome|crios|crmo/i.test(e);return t&&n}getErrorMessage(e){let t=this.isMobileDevice(),n=this.isIOSSafari();return{"no-speech":`No speech detected`,aborted:`Speech recognition aborted`,"audio-capture":`No microphone found`,network:`Network error - check connection`,"not-allowed":t?`Microphone permission denied. Check Settings > Safari > Microphone`:`Microphone permission denied`,"service-not-allowed":n?`Speech recognition requires a user gesture. Please tap the microphone button again.`:`Speech recognition service not allowed`,"bad-grammar":`Grammar error`,"language-not-supported":`Language not supported`}[e]||`Speech recognition error: ${e}`}},ki=e=>{if(e===`12h`)return!0;if(e===`24h`)return!1},Ai=(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:ki(t)}):n.fallback??``},ji=(e,t,n)=>{let r=e instanceof Date?e:new Date(e);return Number.isFinite(r.getTime())?r.toLocaleString(H(),{...n,hour12:n.hour?ki(t):n.hour12}):``},$=e=>ge(he.getState().dictionary,e),Mi=e=>typeof e!=`number`||!Number.isFinite(e)?null:Math.max(0,Math.min(100,Math.round(e))),Ni=e=>typeof e!=`number`||!Number.isFinite(e)?`-`:`${Math.round(e)}%`,Pi=(e,t)=>e??Ni(t),Fi=(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()?Ai(r,n,{fallback:t??``}):ji(r,n,{month:`short`,day:`numeric`,weekday:`short`,hour:`numeric`,minute:`2-digit`})}catch{return t??``}},Ii=e=>e===null?`safe`:e>=80?`critical`:e>=50?`warn`:`safe`,Li=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,Ri=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},zi=(e,t,n,r)=>{let i=n;if(i===null&&r&&(i=Ri(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}},Bi=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)`}},Vi=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`},Hi=e=>Math.min(100,Math.max(0,e*100)),Ui=(e,t)=>ge(he.getState().dictionary,e,t),Wi=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)?Ui(`common.date.today`):r(t,i)?Ui(`common.date.yesterday`):t.toLocaleDateString(H(),{month:`short`,day:`numeric`,year:`numeric`}).replace(`,`,``)},Gi=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?Ui(`common.relative.justNow`):t<36e5?Ui(`common.relative.minutesAgoShort`,{count:Math.floor(t/6e4)}):Ui(`common.relative.hoursAgoShort`,{count:Math.floor(t/36e5)})}return Wi(e)},Ki=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?Ui(`common.relative.minutesAgoCompact`,{count:Math.max(1,Math.floor(t/n))}):t<i?Ui(`common.relative.hoursAgoCompact`,{count:Math.floor(t/r)}):t<a?Ui(`common.relative.daysAgoCompact`,{count:Math.floor(t/i)}):t<5*a?Ui(`common.relative.weeksAgoCompact`,{count:Math.floor(t/a)}):t<o?Ui(`common.relative.monthsAgoCompact`,{count:Math.floor(t/2592e6)}):Ui(`common.relative.yearsAgoCompact`,{count:Math.floor(t/o)})},qi=(e,t)=>Ji(l(e),l(t)),Ji=(e,t)=>!e||!t?!1:e===t?!0:t===`/`?e.startsWith(`/`):e.startsWith(`${t}/`),Yi=e=>e.toLowerCase().replace(/^opencode[/-]?/i,``).replace(/[-_]/g,``).trim(),Xi=(e,t)=>e?Yi(e)!==Yi(t):!1,Zi=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}},Qi=e=>Zi(e.time?.created)??0,$i=(e,t,n)=>{let r=n.has(e.id),i=n.has(t.id);return r===i?r&&i?Qi(t)-Qi(e):Ce(t)-Ce(e):r?-1:1},ea=e=>{let t=new Map;return e.forEach(e=>{t.set(e.id,e)}),Array.from(t.values())},ta=e=>`__archived__:${e}`,na=(e,t)=>{let n=l(e.directory??null),r=l(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`},ra=`box-border w-full px-2 py-1.5 text-left typography-micro text-muted-foreground/70 select-none`,ia=`bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] dark:bg-[color-mix(in_srgb,var(--surface-foreground)_11%,transparent)]`,aa=`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},sa=(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},ca=`/api/browser-providers`,la=`/api/browser-providers/selection`,ua=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/,da=200,fa=e=>`/api/browser-providers/${encodeURIComponent(e)}/surface/ws`,pa=e=>!!e&&typeof e==`object`&&!Array.isArray(e),ma=e=>typeof e==`string`&&ua.test(e)?e:null,ha=e=>{if(!pa(e))return null;let t=ma(e.id),n=typeof e.name==`string`?e.name.trim():``;return!t||!n||n.length>da?null:{id:t,name:n,surface:e.surface===!0}},ga=e=>{if(!pa(e)||!Array.isArray(e.providers))return null;let t=[],n=new Set;for(let r of e.providers){let e=ha(r);!e||n.has(e.id)||(n.add(e.id),t.push(e))}let r=ma(e.selectedId);return{providers:t,selectedId:r&&n.has(r)?r:null}},_a=e=>{if(!pa(e))return null;let t=ma(e.selectedId);return t?{selectedId:t}:null},va=e=>e?.selectedId?e.providers.find(t=>t.id===e.selectedId)??null:null,ya=e=>!!(e&&e.providers.length>0),ba=e=>va(e)!==null,xa=e=>typeof e==`number`&&Number.isFinite(e),Sa=e=>{if(!pa(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||!xa(e.seq)||!xa(e.width)||!xa(e.height)||!xa(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`&&xa(e.width)&&xa(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},Ca=class extends Error{status;constructor(e){super(`browser_provider_request_failed:${e}`),this.name=`BrowserProviderRequestError`,this.status=e}},wa=(e=t())=>c.browserProviders.catalog(e),Ta=async e=>{let t=await e.text();if(!t)return null;try{return JSON.parse(t)}catch{return null}},Ea=async e=>{let t=await r(ca,{method:`GET`,headers:{Accept:`application/json`},signal:e}),n=await Ta(t);if(!t.ok)throw new Ca(t.status);let i=ga(n);if(!i)throw new Ca(t.status||502);return i},Da=(e=t())=>({queryKey:wa(e),queryFn:({signal:e})=>Ea(e),staleTime:5e3,refetchOnWindowFocus:!0,refetchInterval:e=>{let t=e.state.error;return t instanceof Ca&&(t.status===404||t.status===501)?!1:15e3}}),Oa=()=>{let e=(0,K.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=Da(),e[0]=t):t=e[0],ie(t)},ka=(e=o,n=t())=>e.getQueryData(wa(n))??null,Aa=(e,t)=>e?.providers.some(e=>e.id===t)?{providers:e.providers,selectedId:t}:null,ja=async(e,n=o,i)=>{let a=t(),s=await r(la,{method:`PUT`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({id:e}),signal:i}),c=await Ta(s);if(!s.ok)throw new Ca(s.status);let l=_a(c);if(!l||l.selectedId!==e||t()!==a)throw new Ca(s.status||502);let u=Aa(n.getQueryData(wa(a)),l.selectedId);if(!u)throw new Ca(409);return u},Ma=()=>{let e=(0,K.c)(2),n=N(),r;return e[0]===n?r=e[1]:(r={mutationFn:e=>ja(e,n),onMutate:async e=>{let r=t(),i=wa(r);await n.cancelQueries({queryKey:i});let a=n.getQueryData(i),o=Aa(a,e);return o&&n.setQueryData(i,o),{previous:a,key:i,transport:r}},onError:(e,r,i)=>{!i||t()!==i.transport||n.setQueryData(i.key,i.previous)},onSuccess:(e,r,i)=>{!i||t()!==i.transport||n.setQueryData(i.key,e)}},e[0]=n,e[1]=r),ne(r)},Na=[`standalone`,`minimal-ui`,`fullscreen`,`window-controls-overlay`],Pa=`openchamber.pwaRecentSessions`,Fa=e=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(display-mode: ${e})`).matches,Ia=()=>typeof window>`u`?`browser`:typeof document<`u`&&document.referrer.startsWith(`android-app://`)?`twa`:window.navigator.standalone?`standalone`:Na.find(e=>Fa(e))??`browser`,La=864e5,Ra=5,za=864e5,Ba=e=>e.time?.updated??e.time?.created??0,Va=({sessions:e,currentSessionId:t,cutoffDays:n,keepRecent:r=Ra,now:i=Date.now()})=>{if(!Array.isArray(e)||n<=0)return[];let a=i-n*La,o=[...e].sort((e,t)=>Ba(t)-Ba(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=Ba(e);return n?n<a:!1}).map(e=>e.id)},Ha=e=>{let t=typeof e==`object`?e:void 0,n=t?.autoRun!==!1,r=typeof e==`boolean`?e:t?.enabled??!0,i=Se(e=>e.currentSessionId),a=Se(e=>e.isLoading),o=ye(e=>e.activeSessions),s=ye(e=>e.hasLoadedFullCatalog),c=A(e=>e.autoDeleteEnabled),l=A(e=>e.autoDeleteAfterDays),u=A(e=>e.sessionRetentionAction),d=A(e=>e.autoDeleteLastRunAt),f=A(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(()=>{xe(O())},8e3);return()=>window.clearTimeout(e)},[l,c,n,r]);let g=Q.useMemo(()=>l<=0?[]:Va({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<za)return{completedIds:[],failedIds:[],action:u,skippedReason:`cooldown`};let{activeSessions:n}=await xe(O());if(n.length===0)return{completedIds:[],failedIds:[],action:u,skippedReason:`no-candidates`};let r=Va({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?Te(r):null;if(!a){i.push(n);continue}try{u===`archive`?await k.updateSession(n,{time:{archived:Date.now()}},a):await k.deleteSession(n,a),t.push(n)}catch{i.push(n)}}return u===`archive`?ye.getState().archiveSessions(t):ye.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<za||_())},[l,c,d,n,r,s,o.length,a,_]),{candidates:g,isRunning:p,runCleanup:_,keepRecentCount:Ra,action:u}};export{Sr as $,St as $t,Vi as A,on as At,di as B,Kt as Bt,sa as C,Cn as Ct,Mi as D,bn as Dt,zi as E,yn as Et,Ai as F,fn as Ft,ci as G,gt as Gt,gi as H,Wt as Ht,Oi as I,_n as It,Fr as J,yt as Jt,ai as K,bt as Kt,Di as L,gn as Lt,Bi as M,hn as Mt,Ii as N,dn as Nt,Fi as O,pn as Ot,ji as P,ln as Pt,xr as Q,wt as Qt,xi as R,Zt as Rt,Yi as S,Nn as St,Hi as T,xn as Tt,oi as U,Ut,hi as V,Ht as Vt,si as W,Tt as Wt,_r as X,vt as Xt,Er as Y,_t as Yt,br as Z,Ct as Zt,Gi as _,Bn as _t,Oa as a,rt as an,Zn as at,Xi as b,Vn as bt,Sa as c,$n as ct,ra as d,wn as dt,It as en,yr as et,ia as f,Hn as ft,Ki as g,zn as gt,ea as h,Rn as ht,ka as i,Rt as in,Xn as it,Li as j,mn as jt,Pi as k,un as kt,ba as l,tr as lt,$i as m,In as mt,Pa as n,Ft as nn,nr as nt,Ma as o,it as on,er as ot,aa as p,Wn as pt,$r as q,xt as qt,Ia as r,Lt as rn,Jn as rt,fa as s,at as sn,Qn as st,Ha as t,Pt as tn,sr as tt,ya as u,Yn as ut,ta as v,Un as vt,na as w,vn as wt,qi as x,jn as xt,oa as y,Ln as yt,bi as z,qt as zt};