@xopcai/xopc 0.0.85 → 0.0.86

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 (60) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{agents-D3_-kNlZ.js → agents-mS3_HpRI.js} +10 -10
  4. package/dist/gateway/static/root/assets/{apps-page-D7v7649T.js → apps-page-DrfytjOb.js} +1 -1
  5. package/dist/gateway/static/root/assets/{channels-settings-nCaMb0a7.js → channels-settings-BG6b9KrW.js} +1 -1
  6. package/dist/gateway/static/root/assets/{channels-status-swr-C1gZBcJV.js → channels-status-swr-Bs5kMCMI.js} +1 -1
  7. package/dist/gateway/static/root/assets/{cron-api-CoYK0hlm.js → cron-api-BuVcZ5zR.js} +1 -1
  8. package/dist/gateway/static/root/assets/{cron-page-DeGo-Vjc.js → cron-page-BMrloeFH.js} +1 -1
  9. package/dist/gateway/static/root/assets/{dist-DaK4dsss.js → dist-CKU1OOTf.js} +1 -1
  10. package/dist/gateway/static/root/assets/{extension-debug-page-BZngZWbO.js → extension-debug-page-BdW_46sN.js} +1 -1
  11. package/dist/gateway/static/root/assets/{extension-page-D6JSyV27.js → extension-page-DW47KI82.js} +1 -1
  12. package/dist/gateway/static/root/assets/extension-settings-page-B-W4x2xP.js +1 -0
  13. package/dist/gateway/static/root/assets/{field-primitives-Zzl22MvN.js → field-primitives-DPG-oJmx.js} +1 -1
  14. package/dist/gateway/static/root/assets/{heartbeat-config-api-BtIcpG0O.js → heartbeat-config-api-C8dNts9i.js} +1 -1
  15. package/dist/gateway/static/root/assets/{index-D4vM3-P7.js → index-BmVYculr.js} +20 -20
  16. package/dist/gateway/static/root/assets/{logs-page-_d4UJ-qQ.js → logs-page-sTsVWz0X.js} +1 -1
  17. package/dist/gateway/static/root/assets/{sessions-page-5N4aF2Wk.js → sessions-page-FaG_Vlkb.js} +1 -1
  18. package/dist/gateway/static/root/assets/settings-form-section-DuvRQW--.js +1 -0
  19. package/dist/gateway/static/root/assets/settings-page-Bet1OerL.js +3 -0
  20. package/dist/gateway/static/root/assets/{share-preview-page-D4EG_vM1.js → share-preview-page-BtG2kLDh.js} +1 -1
  21. package/dist/gateway/static/root/assets/{skills-page-sPAXhh8w.js → skills-page-DhUO235y.js} +1 -1
  22. package/dist/gateway/static/root/assets/{utils-CYO9eTCM.js → utils-BY7bU1DT.js} +1 -1
  23. package/dist/gateway/static/root/assets/{voice-api-key-field-Ds51havm.js → voice-api-key-field-CGEydndO.js} +1 -1
  24. package/dist/gateway/static/root/index.html +1 -1
  25. package/dist/package.js +1 -1
  26. package/dist/src/agent/tools/workflow-tool.js +3 -3
  27. package/dist/src/agent/tools/workflow-tool.js.map +1 -1
  28. package/dist/src/agent/workflow/builtins/audit-repo.d.ts +5 -1
  29. package/dist/src/agent/workflow/builtins/audit-repo.js +52 -11
  30. package/dist/src/agent/workflow/builtins/audit-repo.js.map +1 -1
  31. package/dist/src/agent/workflow/builtins/debug-incident.d.ts +13 -0
  32. package/dist/src/agent/workflow/builtins/debug-incident.js +155 -0
  33. package/dist/src/agent/workflow/builtins/debug-incident.js.map +1 -0
  34. package/dist/src/agent/workflow/builtins/index.d.ts +3 -1
  35. package/dist/src/agent/workflow/builtins/index.js +11 -1
  36. package/dist/src/agent/workflow/builtins/index.js.map +1 -1
  37. package/dist/src/agent/workflow/builtins/multi-perspective-review.d.ts +6 -1
  38. package/dist/src/agent/workflow/builtins/multi-perspective-review.js +66 -30
  39. package/dist/src/agent/workflow/builtins/multi-perspective-review.js.map +1 -1
  40. package/dist/src/agent/workflow/builtins/pr-review.d.ts +12 -0
  41. package/dist/src/agent/workflow/builtins/pr-review.js +156 -0
  42. package/dist/src/agent/workflow/builtins/pr-review.js.map +1 -0
  43. package/dist/src/agent/workflow/builtins/research.d.ts +5 -1
  44. package/dist/src/agent/workflow/builtins/research.js +37 -6
  45. package/dist/src/agent/workflow/builtins/research.js.map +1 -1
  46. package/dist/src/agent/workflow/catalog.d.ts +5 -0
  47. package/dist/src/agent/workflow/catalog.js +6 -2
  48. package/dist/src/agent/workflow/catalog.js.map +1 -1
  49. package/dist/src/agent/workflow/index.d.ts +1 -1
  50. package/dist/src/agent/workflow/parser.js +9 -0
  51. package/dist/src/agent/workflow/parser.js.map +1 -1
  52. package/dist/src/agent/workflow/types.d.ts +8 -0
  53. package/dist/src/chat-commands/builtins/workflow.js +7 -2
  54. package/dist/src/chat-commands/builtins/workflow.js.map +1 -1
  55. package/dist/src/gateway/heartbeat/service.js +1 -1
  56. package/dist/src/heartbeat/index.js +1 -1
  57. package/package.json +1 -1
  58. package/dist/gateway/static/root/assets/extension-settings-page-8PZcmWI7.js +0 -1
  59. package/dist/gateway/static/root/assets/settings-form-section-D_tgb8r2.js +0 -1
  60. package/dist/gateway/static/root/assets/settings-page-C18xBt4X.js +0 -3
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/settings-page-C18xBt4X.js","assets/rolldown-runtime-aKtaBQYM.js","assets/dist-BTWC-BTN.js","assets/vendor-react-BOUWij0V.js","assets/cron-dreaming-jobs-DueM3rBz.js","assets/vendor-swr-BIWyz7Rc.js","assets/channels-status-swr-C1gZBcJV.js","assets/url-BwNL6Rgk.js","assets/cron-api-CoYK0hlm.js","assets/fetch-B2MYHbWg.js","assets/theme-store-DryYl3qD.js","assets/agents-D3_-kNlZ.js","assets/settings-form-section-D_tgb8r2.js","assets/heartbeat-config-api-BtIcpG0O.js","assets/utils-CYO9eTCM.js","assets/voice-api-key-field-Ds51havm.js","assets/sessions-page-5N4aF2Wk.js","assets/logs-page-_d4UJ-qQ.js","assets/cron-page-DeGo-Vjc.js","assets/dist-DaK4dsss.js","assets/skills-page-sPAXhh8w.js","assets/vendor-codemirror-D0yxdRpg.js","assets/attachment-preview-renderer-CpyoFbs4.js","assets/excel-worksheet-utils-EyvwNT4X.js","assets/attachment-process-heavy-CqVriadb.js","assets/channels-settings-nCaMb0a7.js","assets/field-primitives-Zzl22MvN.js","assets/apps-page-D7v7649T.js","assets/extension-page-D6JSyV27.js","assets/extension-settings-page-8PZcmWI7.js","assets/extension-debug-page-BZngZWbO.js","assets/share-preview-page-D4EG_vM1.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/settings-page-Bet1OerL.js","assets/rolldown-runtime-aKtaBQYM.js","assets/dist-BTWC-BTN.js","assets/vendor-react-BOUWij0V.js","assets/cron-dreaming-jobs-DueM3rBz.js","assets/vendor-swr-BIWyz7Rc.js","assets/channels-status-swr-Bs5kMCMI.js","assets/url-BwNL6Rgk.js","assets/cron-api-BuVcZ5zR.js","assets/fetch-B2MYHbWg.js","assets/theme-store-DryYl3qD.js","assets/agents-mS3_HpRI.js","assets/settings-form-section-DuvRQW--.js","assets/heartbeat-config-api-C8dNts9i.js","assets/utils-BY7bU1DT.js","assets/voice-api-key-field-CGEydndO.js","assets/sessions-page-FaG_Vlkb.js","assets/logs-page-sTsVWz0X.js","assets/cron-page-BMrloeFH.js","assets/dist-CKU1OOTf.js","assets/skills-page-DhUO235y.js","assets/vendor-codemirror-D0yxdRpg.js","assets/attachment-preview-renderer-CpyoFbs4.js","assets/excel-worksheet-utils-EyvwNT4X.js","assets/attachment-process-heavy-CqVriadb.js","assets/channels-settings-BG6b9KrW.js","assets/field-primitives-DPG-oJmx.js","assets/apps-page-DrfytjOb.js","assets/extension-page-DW47KI82.js","assets/extension-settings-page-B-W4x2xP.js","assets/extension-debug-page-BdW_46sN.js","assets/share-preview-page-BtG2kLDh.js"])))=>i.map(i=>d[i]);
2
2
  import{i as e,n as t,t as n}from"./rolldown-runtime-aKtaBQYM.js";import{a as r,i,n as a,r as o,t as s}from"./vendor-react-BOUWij0V.js";import{a as c,f as l,h as u,i as d,l as f,m as p,o as m,p as h,s as g,t as _}from"./url-BwNL6Rgk.js";import{i as v,n as y,o as b,s as x,t as S}from"./vendor-swr-BIWyz7Rc.js";import{a as C,c as w,d as T,f as E,g as D,h as O,i as k,l as A,m as j,n as M,o as N,p as P,r as F,s as I,t as L,u as R}from"./vendor-codemirror-D0yxdRpg.js";import{t as z}from"./createLucideIcon-DPHK1VkS.js";import{C as B,E as V,S as H,T as U,_ as W,a as G,c as ee,d as K,f as te,g as ne,h as re,i as ie,l as ae,m as oe,n as se,o as q,p as ce,r as le,s as ue,t as de,u as fe,v as pe,w as me,x as he,y as ge}from"./dist-BTWC-BTN.js";import{a as _e,i as ve,n as ye,r as be,t as xe}from"./theme-store-DryYl3qD.js";import{a as Se,i as Ce,n as we,r as Te,t as Ee}from"./fetch-B2MYHbWg.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var De=(e,t,n,r)=>{let i=[n,{code:t,...r||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(i,`warn`,`react-i18next::`,!0);Pe(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...i):console?.warn&&console.warn(...i)},Oe={},ke=(e,t,n,r)=>{Pe(n)&&Oe[n]||(Pe(n)&&(Oe[n]=new Date),De(e,t,n,r))},Ae=(e,t)=>()=>{if(e.isInitialized)t();else{let n=()=>{setTimeout(()=>{e.off(`initialized`,n)},0),t()};e.on(`initialized`,n)}},je=(e,t,n)=>{e.loadNamespaces(t,Ae(e,n))},Me=(e,t,n,r)=>{if(Pe(n)&&(n=[n]),e.options.preload&&e.options.preload.indexOf(t)>-1)return je(e,n,r);n.forEach(t=>{e.options.ns.indexOf(t)<0&&e.options.ns.push(t)}),e.loadLanguages(t,Ae(e,r))},Ne=(e,t,n={})=>!t.languages||!t.languages.length?(ke(t,`NO_LANGUAGES`,`i18n.languages were undefined or empty`,{languages:t.languages}),!0):t.hasLoadedNamespace(e,{lng:n.lng,precheck:(t,r)=>{if(n.bindI18n&&n.bindI18n.indexOf(`languageChanging`)>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!r(t.isLanguageChangingTo,e))return!1}}),Pe=e=>typeof e==`string`,Fe=e=>typeof e==`object`&&!!e,J=e(r()),Ie=(0,J.createContext)(),Le=class{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}},Re=x(),ze={t:(e,t)=>{if(Pe(t))return t;if(Fe(t)&&Pe(t.defaultValue))return t.defaultValue;if(typeof e==`function`)return``;if(Array.isArray(e)){let t=e[e.length-1];return typeof t==`function`?``:t}return e},ready:!1},Be=()=>()=>{},Ve=(e,t={})=>{let{i18n:n}=t,{i18n:r,defaultNS:i}=(0,J.useContext)(Ie)||{},a=n||r||h();a&&!a.reportNamespaces&&(a.reportNamespaces=new Le),a||ke(a,`NO_I18NEXT_INSTANCE`,`useTranslation: You will need to pass in an i18next instance by using initReactI18next`);let o=(0,J.useMemo)(()=>({...p(),...a?.options?.react,...t}),[a,t]),{useSuspense:s,keyPrefix:c}=o,l=e||i||a?.options?.defaultNS,u=Pe(l)?[l]:l||[`translation`],d=(0,J.useMemo)(()=>u,u);a?.reportNamespaces?.addUsedNamespaces?.(d);let f=(0,J.useRef)(0),m=(0,J.useCallback)(e=>{if(!a)return Be;let{bindI18n:t,bindI18nStore:n}=o,r=()=>{f.current+=1,e()};return t&&a.on(t,r),n&&a.store.on(n,r),()=>{t&&t.split(` `).forEach(e=>a.off(e,r)),n&&n.split(` `).forEach(e=>a.store.off(e,r))}},[a,o]),g=(0,J.useRef)(),_=(0,J.useCallback)(()=>{if(!a)return ze;let e=!!(a.isInitialized||a.initializedStoreOnce)&&d.every(e=>Ne(e,a,o)),n=t.lng||a.language,r=f.current,i=g.current;if(i&&i.ready===e&&i.lng===n&&i.keyPrefix===c&&i.revision===r)return i;let s={t:a.getFixedT(n,o.nsMode===`fallback`?d:d[0],c,{scopeNs:d}),ready:e,lng:n,keyPrefix:c,revision:r};return g.current=s,s},[a,d,c,o,t.lng]),[v,y]=(0,J.useState)(0),{t:b,ready:x}=(0,Re.useSyncExternalStore)(m,_,_);(0,J.useEffect)(()=>{if(a&&!x&&!s){let e=()=>y(e=>e+1);t.lng?Me(a,t.lng,d,e):je(a,d,e)}},[a,t.lng,d,x,s,v]);let S=a||{},C=(0,J.useRef)(null),w=(0,J.useRef)(),T=e=>{let t=Object.getOwnPropertyDescriptors(e);t.__original&&delete t.__original;let n=Object.create(Object.getPrototypeOf(e),t);if(!Object.prototype.hasOwnProperty.call(n,`__original`))try{Object.defineProperty(n,"__original",{value:e,writable:!1,enumerable:!1,configurable:!1})}catch{}return n},E=(0,J.useMemo)(()=>{let e=S,t=e?.language,n=e;e&&(C.current&&C.current.__original===e&&w.current===t?n=C.current:(n=T(e),C.current=n,w.current=t));let r=!x&&!s?(...e)=>(ke(a,`USE_T_BEFORE_READY`,`useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t.`),b(...e)):b,i=[r,n,x];return i.t=r,i.i18n=n,i.ready=x,i},[b,S,x,S.resolvedLanguage,S.language,S.languages]);if(a&&s&&!x)throw new Promise(e=>{let n=()=>e();t.lng?Me(a,t.lng,d,n):je(a,d,n)});return E};function He({i18n:e,defaultNS:t,children:n}){let r=(0,J.useMemo)(()=>({i18n:e,defaultNS:t}),[e,t]);return(0,J.createElement)(Ie.Provider,{value:r},n)}var Ue=e=>{throw TypeError(e)},We=(e,t,n)=>t.has(e)||Ue(`Cannot `+n),Ge=(e,t,n)=>(We(e,t,`read from private field`),n?n.call(e):t.get(e)),Ke=(e,t,n)=>t.has(e)?Ue(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),qe=(e,t,n,r)=>(We(e,t,`write to private field`),r?r.call(e,n):t.set(e,n),n),Je=`popstate`;function Ye(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function Xe(e={}){function t(e,t){let{pathname:n=`/`,search:r=``,hash:i=``}=rt(e.location.hash.substring(1));return!n.startsWith(`/`)&&!n.startsWith(`.`)&&(n=`/`+n),tt(``,{pathname:n,search:r,hash:i},t.state&&t.state.usr||null,t.state&&t.state.key||`default`)}function n(e,t){let n=e.document.querySelector(`base`),r=``;if(n&&n.getAttribute(`href`)){let t=e.location.href,n=t.indexOf(`#`);r=n===-1?t:t.slice(0,n)}return r+`#`+(typeof t==`string`?t:nt(t))}function r(e,t){Qe(e.pathname.charAt(0)===`/`,`relative pathnames are not supported in hash history.push(${JSON.stringify(t)})`)}return it(t,n,r,e)}function Ze(e,t){if(e===!1||e==null)throw Error(t)}function Qe(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function $e(){return Math.random().toString(36).substring(2,10)}function et(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function tt(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?rt(t):t,state:n,key:t&&t.key||r||$e(),mask:i}}function nt({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function rt(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function it(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=Ye(e)?e:tt(h.location,e,t);n&&n(r,e),l=u()+1;let d=et(r,l),f=h.createHref(r.mask||r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=Ye(e)?e:tt(h.location,e,t);n&&n(r,e),l=u();let i=et(r,l),d=h.createHref(r.mask||r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return at(i,e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(Je,d),c=e,()=>{i.removeEventListener(Je,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function at(e,t,n=!1){let r=`http://localhost`;e&&(r=e.location.origin===`null`?e.location.href:e.location.origin),Ze(r,`No window.location.(origin|href) available to create URL`);let i=typeof t==`string`?t:nt(t);return i=i.replace(/ $/,`%20`),!n&&i.startsWith(`//`)&&(i=r+i),new URL(i,r)}var ot,st=class{constructor(e){if(Ke(this,ot,new Map),e)for(let[t,n]of e)this.set(t,n)}get(e){if(Ge(this,ot).has(e))return Ge(this,ot).get(e);if(e.defaultValue!==void 0)return e.defaultValue;throw Error(`No value found for context`)}set(e,t){Ge(this,ot).set(e,t)}};ot=new WeakMap;var ct=new Set([`lazy`,`caseSensitive`,`path`,`id`,`index`,`children`]);function eee(e){return ct.has(e)}var tee=new Set([`lazy`,`caseSensitive`,`path`,`id`,`index`,`middleware`,`children`]);function lt(e){return tee.has(e)}function ut(e){return e.index===!0}function dt(e,t,n=[],r={},i=!1){return e.map((e,a)=>{let o=[...n,String(a)],s=typeof e.id==`string`?e.id:o.join(`-`);if(Ze(e.index!==!0||!e.children,`Cannot specify children on an index route`),Ze(i||!r[s],`Found a route id collision on id "${s}". Route id's must be globally unique within Data Router usages`),ut(e)){let n={...e,id:s};return r[s]=ft(n,t(n)),n}else{let n={...e,id:s,children:void 0};return r[s]=ft(n,t(n)),e.children&&(n.children=dt(e.children,t,o,r,i)),n}})}function ft(e,t){return Object.assign(e,{...t,...typeof t.lazy==`object`&&t.lazy!=null?{lazy:{...e.lazy,...t.lazy}}:{}})}function pt(e,t,n=`/`){return mt(e,t,n,!1)}function mt(e,t,n,r,i){let a=Mt((typeof t==`string`?rt(t):t).pathname||`/`,n);if(a==null)return null;let o=i??gt(e),s=null,c=nee(a);for(let e=0;s==null&&e<o.length;++e)s=kt(o[e],c,r);return s}function ht(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function gt(e){let t=_t(e);return yt(t),t}function _t(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;Ze(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=Vt([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(Ze(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),_t(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:Dt(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of vt(e.path))a(e,t,!0,n)}),t}function vt(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=vt(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function yt(e){e.sort((e,t)=>e.score===t.score?Ot(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var bt=/^:[\w-]+$/,xt=3,St=2,Ct=1,wt=10,Tt=-2,Et=e=>e===`*`;function Dt(e,t){let n=e.split(`/`),r=n.length;return n.some(Et)&&(r+=Tt),t&&(r+=St),n.filter(e=>!Et(e)).reduce((e,t)=>e+(bt.test(t)?xt:t===``?Ct:wt),r)}function Ot(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function kt(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u=At({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=At({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:Vt([a,u.pathname]),pathnameBase:Ut(Vt([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=Vt([a,u.pathnameBase]))}return o}function At(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=jt(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function jt(e,t=!1,n=!0){Qe(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n,i,a)=>{if(r.push({paramName:t,isOptional:n!=null}),n){let t=a.charAt(i+e.length);return t&&t!==`/`?`/([^\\/]*)`:`(?:/([^\\/]*))?`}return`/([^\\/]+)`}).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function nee(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return Qe(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Mt(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}function ree({basename:e,pathname:t}){return t===`/`?e:Vt([e,t])}var Nt=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Pt=e=>Nt.test(e);function iee(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?rt(e):e,a;return n?(n=Bt(n),a=n.startsWith(`/`)?Ft(n.substring(1),`/`):Ft(n,t)):a=t,{pathname:a,search:Wt(r),hash:Gt(i)}}function Ft(e,t){let n=Ht(t).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function It(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Lt(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function Rt(e){let t=Lt(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function zt(e,t,n,r=!1){let i;typeof e==`string`?i=rt(e):(i={...e},Ze(!i.pathname||!i.pathname.includes(`?`),It(`?`,`pathname`,`search`,i)),Ze(!i.pathname||!i.pathname.includes(`#`),It(`#`,`pathname`,`hash`,i)),Ze(!i.search||!i.search.includes(`#`),It(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=iee(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var Bt=e=>e.replace(/\/\/+/g,`/`),Vt=e=>Bt(e.join(`/`)),Ht=e=>e.replace(/\/+$/,``),Ut=e=>Ht(e).replace(/^\/*/,`/`),Wt=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,Gt=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,Kt=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function qt(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function Jt(e){return Vt(e.map(e=>e.route.path).filter(Boolean))||`/`}var Yt=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Xt(e,t){let n=e;if(typeof n!=`string`||!Nt.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Yt)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=Mt(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{Qe(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}var Zt=Symbol(`Uninstrumented`);function Qt(e,t){let n={lazy:[],"lazy.loader":[],"lazy.action":[],"lazy.middleware":[],middleware:[],loader:[],action:[]};e.forEach(e=>e({id:t.id,index:t.index,path:t.path,instrument(e){let t=Object.keys(n);for(let r of t)e[r]&&n[r].push(e[r])}}));let r={};if(typeof t.lazy==`function`&&n.lazy.length>0){let e=en(n.lazy,t.lazy,()=>void 0);e&&(r.lazy=e)}if(typeof t.lazy==`object`){let e=t.lazy;[`middleware`,`loader`,`action`].forEach(t=>{let i=e[t],a=n[`lazy.${t}`];if(typeof i==`function`&&a.length>0){let e=en(a,i,()=>void 0);e&&(r.lazy=Object.assign(r.lazy||{},{[t]:e}))}})}return[`loader`,`action`].forEach(e=>{let i=t[e];if(typeof i==`function`&&n[e].length>0){let t=i[Zt]??i,a=en(n[e],t,(...e)=>nn(e[0]));a&&(e===`loader`&&t.hydrate===!0&&(a.hydrate=!0),a[Zt]=t,r[e]=a)}}),t.middleware&&t.middleware.length>0&&n.middleware.length>0&&(r.middleware=t.middleware.map(e=>{let t=e[Zt]??e,r=en(n.middleware,t,(...e)=>nn(e[0]));return r?(r[Zt]=t,r):e})),r}function $t(e,t){let n={navigate:[],fetch:[]};if(t.forEach(e=>e({instrument(e){let t=Object.keys(e);for(let r of t)e[r]&&n[r].push(e[r])}})),n.navigate.length>0){let t=e.navigate[Zt]??e.navigate,r=en(n.navigate,t,(...t)=>{let[n,r]=t;return{to:typeof n==`number`||typeof n==`string`?n:n?nt(n):`.`,...rn(e,r??{})}});r&&(r[Zt]=t,e.navigate=r)}if(n.fetch.length>0){let t=e.fetch[Zt]??e.fetch,r=en(n.fetch,t,(...t)=>{let[n,,r,i]=t;return{href:r??`.`,fetcherKey:n,...rn(e,i??{})}});r&&(r[Zt]=t,e.fetch=r)}return e}function en(e,t,n){return e.length===0?null:async(...r)=>{let i=await tn(e,n(...r),()=>t(...r),e.length-1);if(i.type===`error`)throw i.value;return i.value}}async function tn(e,t,n,r){let i=e[r],a;if(i){let o,s=async()=>(o?console.error(`You cannot call instrumented handlers more than once`):o=tn(e,t,n,r-1),a=await o,Ze(a,`Expected a result`),a.type===`error`&&a.value instanceof Error?{status:`error`,error:a.value}:{status:`success`,error:void 0});try{await i(s,t)}catch(e){console.error(`An instrumentation function threw an error:`,e)}o||await s(),await o}else try{a={type:`success`,value:await n()}}catch(e){a={type:`error`,value:e}}return a||{type:`error`,value:Error(`No result assigned in instrumentation chain.`)}}function nn(e){let{request:t,context:n,params:r,pattern:i}=e;return{request:an(t),params:{...r},pattern:i,context:on(n)}}function rn(e,t){return{currentUrl:nt(e.state.location),...`formMethod`in t?{formMethod:t.formMethod}:{},...`formEncType`in t?{formEncType:t.formEncType}:{},...`formData`in t?{formData:t.formData}:{},...`body`in t?{body:t.body}:{}}}function an(e){return{method:e.method,url:e.url,headers:{get:(...t)=>e.headers.get(...t)}}}function on(e){if(cn(e)){let t={...e};return Object.freeze(t),t}else return{get:t=>e.get(t)}}var sn=Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);function cn(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getOwnPropertyNames(t).sort().join(`\0`)===sn}var ln=[`POST`,`PUT`,`PATCH`,`DELETE`],un=new Set(ln),dn=[`GET`,...ln],fn=new Set(dn),pn=new Set([301,302,303,307,308]),mn=new Set([307,308]),hn={state:`idle`,location:void 0,matches:void 0,historyAction:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},gn={state:`idle`,data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},_n={state:`unblocked`,proceed:void 0,reset:void 0,location:void 0},vn=e=>({hasErrorBoundary:!!e.hasErrorBoundary}),yn=`remix-router-transitions`,bn=Symbol(`ResetLoaderData`),xn,Sn,Cn,wn,Tn=class{constructor(e){Ke(this,xn),Ke(this,Sn),Ke(this,Cn),Ke(this,wn),qe(this,xn,e),qe(this,Sn,gt(e))}get stableRoutes(){return Ge(this,xn)}get activeRoutes(){return Ge(this,Cn)??Ge(this,xn)}get branches(){return Ge(this,wn)??Ge(this,Sn)}get hasHMRRoutes(){return Ge(this,Cn)!=null}setRoutes(e){qe(this,xn,e),qe(this,Sn,gt(e))}setHmrRoutes(e){qe(this,Cn,e),qe(this,wn,gt(e))}commitHmrRoutes(){Ge(this,Cn)&&(qe(this,xn,Ge(this,Cn)),qe(this,Sn,Ge(this,wn)),qe(this,Cn,void 0),qe(this,wn,void 0))}};xn=new WeakMap,Sn=new WeakMap,Cn=new WeakMap,wn=new WeakMap;function En(e){let t=e.window?e.window:typeof window<`u`?window:void 0,n=t!==void 0&&t.document!==void 0&&t.document.createElement!==void 0;Ze(e.routes.length>0,`You must provide a non-empty routes array to createRouter`);let r=e.hydrationRouteProperties||[],i=e.mapRouteProperties||vn,a=i;if(e.instrumentations){let t=e.instrumentations;a=e=>({...i(e),...Qt(t.map(e=>e.route).filter(Boolean),e)})}let o={},s=new Tn(dt(e.routes,a,void 0,o)),c=e.basename||`/`;c.startsWith(`/`)||(c=`/${c}`);let l=e.dataStrategy||see,u={...e.future},d=null,f=new Set,p=null,m=null,h=null,g=null,_=e.hydrationData!=null,v=mt(s.activeRoutes,e.history.location,c,!1,s.branches),y=!1,b=null,x,S;if(v==null&&!e.patchRoutesOnNavigation){let t=lr(404,{pathname:e.history.location.pathname}),{matches:n,route:r}=cr(s.activeRoutes);x=!0,S=!x,v=n,b={[r.id]:t}}else if(v&&!e.hydrationData&&J(v,s.activeRoutes,e.history.location.pathname).active&&(v=null),!v){x=!1,S=!x,v=[];let t=J(null,s.activeRoutes,e.history.location.pathname);t.active&&t.matches&&(y=!0,v=t.matches)}else if(v.some(e=>e.route.lazy))x=!1,S=!x;else if(!v.some(e=>jn(e.route)))x=!0,S=!x;else{let t=e.hydrationData?e.hydrationData.loaderData:null,n=e.hydrationData?e.hydrationData.errors:null,r=v;if(n){let e=v.findIndex(e=>n[e.route.id]!==void 0);r=r.slice(0,e+1)}S=!1,x=!0,r.forEach(e=>{let r=Mn(e.route,t,n);S||=r.renderFallback,x&&=!r.shouldLoad})}let C,w={historyAction:e.history.action,location:e.history.location,matches:v,initialized:x,renderFallback:S,navigation:hn,restoreScrollPosition:e.hydrationData==null?null:!1,preventScrollReset:!1,revalidation:`idle`,loaderData:e.hydrationData&&e.hydrationData.loaderData||{},actionData:e.hydrationData&&e.hydrationData.actionData||null,errors:e.hydrationData&&e.hydrationData.errors||b,fetchers:new Map,blockers:new Map},T=`POP`,E=null,D=!1,O,k=!1,A=new Map,j=null,M=!1,N=!1,P=new Set,F=new Map,I=0,L=-1,R=new Map,z=new Set,B=new Map,V=new Map,H=new Set,U=new Map,W,G=null;function ee(){if(d=e.history.listen(({action:t,location:n,delta:r})=>{if(W){W(),W=void 0;return}Qe(U.size===0||r!=null,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let i=Ae({currentLocation:w.location,nextLocation:n,historyAction:t});if(i&&r!=null){let t=new Promise(e=>{W=e});e.history.go(r*-1),ke(i,{state:`blocked`,location:n,proceed(){ke(i,{state:`proceeding`,proceed:void 0,reset:void 0,location:n}),t.then(()=>e.history.go(r))},reset(){let e=new Map(w.blockers);e.set(i,_n),ne({blockers:e})}}),E?.resolve(),E=null;return}return oe(t,n)}),n){Or(t,A);let e=()=>kr(t,A);t.addEventListener(`pagehide`,e),j=()=>t.removeEventListener(`pagehide`,e)}return w.initialized||oe(`POP`,w.location,{initialHydration:!0}),C}function K(){d&&d(),j&&j(),f.clear(),O&&O.abort(),w.fetchers.forEach((e,t)=>xe(w.fetchers,t)),w.blockers.forEach((e,t)=>Oe(t))}function te(e){if(f.add(e),p){let{newErrors:t}=p;p=null,e(w,{deletedFetchers:[],newErrors:t,viewTransitionOpts:void 0,flushSync:!1})}return()=>f.delete(e)}function ne(e,t={}){e.matches&&=e.matches.map(e=>{let t=o[e.route.id],n=e.route;return n.element!==t.element||n.errorElement!==t.errorElement||n.hydrateFallbackElement!==t.hydrateFallbackElement?{...e,route:t}:e}),w={...w,...e};let n=[],r=[];w.fetchers.forEach((e,t)=>{e.state===`idle`&&(H.has(t)?n.push(t):r.push(t))}),H.forEach(e=>{!w.fetchers.has(e)&&!F.has(e)&&n.push(e)}),f.size===0&&(p={newErrors:e.errors??null}),[...f].forEach(r=>r(w,{deletedFetchers:n,newErrors:e.errors??null,viewTransitionOpts:t.viewTransitionOpts,flushSync:t.flushSync===!0})),n.forEach(e=>xe(w.fetchers,e)),r.forEach(e=>w.fetchers.delete(e))}function re(t,n,{flushSync:r}={}){let i=w.actionData!=null&&w.navigation.formMethod!=null&&yr(w.navigation.formMethod)&&w.navigation.state===`loading`&&t.state?._isRedirect!==!0,a;a=n.actionData?Object.keys(n.actionData).length>0?n.actionData:null:i?w.actionData:null;let o=n.loaderData?ar(w.loaderData,n.loaderData,n.matches||[],n.errors):w.loaderData,c=w.blockers;c.size>0&&(c=new Map(c),c.forEach((e,t)=>c.set(t,_n)));let l=M?!1:Fe(t,n.matches||w.matches),u=D===!0||w.navigation.formMethod!=null&&yr(w.navigation.formMethod)&&t.state?._isRedirect!==!0;s.commitHmrRoutes(),M||T===`POP`||(T===`PUSH`?e.history.push(t,t.state):T===`REPLACE`&&e.history.replace(t,t.state));let d;if(T===`POP`){let e=A.get(w.location.pathname);e&&e.has(t.pathname)?d={currentLocation:w.location,nextLocation:t}:A.has(t.pathname)&&(d={currentLocation:t,nextLocation:w.location})}else if(k){let e=A.get(w.location.pathname);e?e.add(t.pathname):(e=new Set([t.pathname]),A.set(w.location.pathname,e)),d={currentLocation:w.location,nextLocation:t}}ne({...n,actionData:a,loaderData:o,historyAction:T,location:t,initialized:!0,renderFallback:!1,navigation:hn,revalidation:`idle`,restoreScrollPosition:l,preventScrollReset:u,blockers:c},{viewTransitionOpts:d,flushSync:r===!0}),T=`POP`,D=!1,k=!1,M=!1,N=!1,E?.resolve(),E=null,G?.resolve(),G=null}async function ie(t,n){if(E?.resolve(),E=null,typeof t==`number`){E||=Ar();let n=E.promise;return e.history.go(t),n}let{path:r,submission:i,error:a}=kn(!1,On(w.location,w.matches,c,t,n?.fromRouteId,n?.relative),n),o;n?.mask&&(o={pathname:``,search:``,hash:``,...typeof n.mask==`string`?rt(n.mask):{...w.location.mask,...n.mask}});let s=w.location,l=tt(s,r,n&&n.state,void 0,o);l={...l,...e.history.encodeLocation(l)};let u=n&&n.replace!=null?n.replace:void 0,d=`PUSH`;u===!0?d=`REPLACE`:u===!1||i!=null&&yr(i.formMethod)&&i.formAction===w.location.pathname+w.location.search&&(d=`REPLACE`);let f=n&&`preventScrollReset`in n?n.preventScrollReset===!0:void 0,p=(n&&n.flushSync)===!0,m=Ae({currentLocation:s,nextLocation:l,historyAction:d});if(m){ke(m,{state:`blocked`,location:l,proceed(){ke(m,{state:`proceeding`,proceed:void 0,reset:void 0,location:l}),ie(t,n)},reset(){let e=new Map(w.blockers);e.set(m,_n),ne({blockers:e})}});return}await oe(d,l,{submission:i,pendingError:a,preventScrollReset:f,replace:n&&n.replace,enableViewTransition:n&&n.viewTransition,flushSync:p,callSiteDefaultShouldRevalidate:n&&n.defaultShouldRevalidate})}function ae(){G||=Ar(),ge(),ne({revalidation:`loading`});let e=G.promise;return w.navigation.state===`submitting`?e:w.navigation.state===`idle`?(oe(w.historyAction,w.location,{startUninterruptedRevalidation:!0}),e):(oe(T||w.historyAction,w.navigation.location,{overrideNavigation:w.navigation,enableViewTransition:k===!0}),e)}async function oe(t,n,r){O&&O.abort(),O=null,T=t,M=(r&&r.startUninterruptedRevalidation)===!0,Pe(w.location,w.matches),D=(r&&r.preventScrollReset)===!0,k=(r&&r.enableViewTransition)===!0;let i=s.activeRoutes,a=r?.initialHydration&&w.matches&&w.matches.length>0&&!y?w.matches:mt(i,n,c,!1,s.branches),o=(r&&r.flushSync)===!0;if(a&&w.initialized&&!N&&lee(w.location,n)&&!(r&&r.submission&&yr(r.submission.formMethod))){re(n,{matches:a},{flushSync:o});return}let l=J(a,i,n.pathname);if(l.active&&l.matches&&(a=l.matches),!a){let{error:e,notFoundMatches:t,route:r}=je(n.pathname);re(n,{matches:t,loaderData:{},errors:{[r.id]:e}},{flushSync:o});return}let u=r&&r.overrideNavigation?{...r.overrideNavigation,matches:a,historyAction:t}:void 0;O=new AbortController;let d=$n(e.history,n,O.signal,r&&r.submission),f=e.getContext?await e.getContext():new st,p;if(r&&r.pendingError)p=[sr(a).route.id,{type:`error`,error:r.pendingError}];else if(r&&r.submission&&yr(r.submission.formMethod)){let i=await se(d,n,r.submission,a,t,f,l.active,r&&r.initialHydration===!0,{replace:r.replace,flushSync:o});if(i.shortCircuited)return;if(i.pendingActionResult){let[e,t]=i.pendingActionResult;if(fr(t)&&qt(t.error)&&t.error.status===404){O=null,re(n,{matches:i.matches,loaderData:{},errors:{[e]:t.error}});return}}a=i.matches||a,p=i.pendingActionResult,u=Cr(n,a,t,r.submission),o=!1,l.active=!1,d=$n(e.history,d.url,d.signal)}let{shortCircuited:m,matches:h,loaderData:g,errors:_,workingFetchers:v}=await q(d,n,a,t,f,l.active,u,r&&r.submission,r&&r.fetcherSubmission,r&&r.replace,r&&r.initialHydration===!0,o,p,r&&r.callSiteDefaultShouldRevalidate);m||(O=null,re(n,{matches:h||a,...or(p),loaderData:g,errors:_,...v?{fetchers:v}:{}}))}async function se(t,n,i,l,u,d,f,p,m={}){if(ge(),ne({navigation:wr(n,l,u,i)},{flushSync:m.flushSync===!0}),f){let e=await Ie(l,n.pathname,t.signal);if(e.type===`aborted`)return{shortCircuited:!0};if(e.type===`error`){if(e.partialMatches.length===0){let{matches:t,route:n}=cr(s.activeRoutes);return{matches:t,pendingActionResult:[n.id,{type:`error`,error:e.error}]}}let t=sr(e.partialMatches).route.id;return{matches:e.partialMatches,pendingActionResult:[t,{type:`error`,error:e.error}]}}else if(e.matches)l=e.matches;else{let{notFoundMatches:e,error:t,route:r}=je(n.pathname);return{matches:e,pendingActionResult:[r.id,{type:`error`,error:t}]}}}let h,g=xr(l,n);if(!g.route.action&&!g.route.lazy)h={type:`error`,error:lr(405,{method:t.method,pathname:n.pathname,routeId:g.route.id})};else{let e=await me(t,n,Gn(a,o,t,n,l,g,p?[]:r,d),d,null);if(h=e[g.route.id],!h){for(let t of l)if(e[t.route.id]){h=e[t.route.id];break}}if(t.signal.aborted)return{shortCircuited:!0}}if(pr(h)){let n;return n=m&&m.replace!=null?m.replace:Qn(h.response.headers.get(`Location`),new URL(t.url),c,e.history)===w.location.pathname+w.location.search,await pe(t,h,!0,{submission:i,replace:n}),{shortCircuited:!0}}if(fr(h)){let e=sr(l,g.route.id);return(m&&m.replace)!==!0&&(T=`PUSH`),{matches:l,pendingActionResult:[e.route.id,h,g.route.id]}}return{matches:l,pendingActionResult:[g.route.id,h]}}async function q(t,n,i,l,u,d,f,p,m,h,g,_,v,y){let b=f||Cr(n,i,l,p),x=p||m||Sr(b),S=!M&&!g;if(d){if(S){let e=ce(v);ne({navigation:b,...e===void 0?{}:{actionData:e}},{flushSync:_})}let e=await Ie(i,n.pathname,t.signal);if(e.type===`aborted`)return{shortCircuited:!0};if(e.type===`error`){if(e.partialMatches.length===0){let{matches:t,route:n}=cr(s.activeRoutes);return{matches:t,loaderData:{},errors:{[n.id]:e.error}}}let t=sr(e.partialMatches).route.id;return{matches:e.partialMatches,loaderData:{},errors:{[t]:e.error}}}else if(e.matches)i=e.matches;else{let{error:e,notFoundMatches:t,route:r}=je(n.pathname);return{matches:t,loaderData:{},errors:{[r.id]:e}}}}let C=s.activeRoutes,{dsMatches:T,revalidatingFetchers:E}=An(t,u,a,o,e.history,w,i,x,n,g?[]:r,g===!0,N,P,H,B,z,C,c,e.patchRoutesOnNavigation!=null,s.branches,v,y);if(L=++I,!e.dataStrategy&&!T.some(e=>e.shouldLoad)&&!T.some(e=>e.route.middleware&&e.route.middleware.length>0)&&E.length===0){let e=new Map(w.fetchers),t=Te(e);return re(n,{matches:i,loaderData:{},errors:v&&fr(v[1])?{[v[0]]:v[1].error}:null,...or(v),...t?{fetchers:e}:{}},{flushSync:_}),{shortCircuited:!0}}if(S){let e={};if(!d){e.navigation=b;let t=ce(v);t!==void 0&&(e.actionData=t)}E.length>0&&(e.fetchers=le(E)),ne(e,{flushSync:_})}E.forEach(e=>{Ce(e.key),e.controller&&F.set(e.key,e.controller)});let D=()=>E.forEach(e=>Ce(e.key));O&&O.signal.addEventListener(`abort`,D);let{loaderResults:k,fetcherResults:A}=await he(T,E,t,n,u);if(t.signal.aborted)return{shortCircuited:!0};O&&O.signal.removeEventListener(`abort`,D),E.forEach(e=>F.delete(e.key));let j=ur(k);if(j)return await pe(t,j.result,!0,{replace:h}),{shortCircuited:!0};if(j=ur(A),j)return z.add(j.key),await pe(t,j.result,!0,{replace:h}),{shortCircuited:!0};let R=new Map(w.fetchers),{loaderData:V,errors:U}=ir(w,i,k,v,E,A,R);g&&w.errors&&(U={...w.errors,...U});let W=Te(R),G=Ee(L,R),ee=W||G||E.length>0;return{matches:i,loaderData:V,errors:U,...ee?{workingFetchers:R}:{}}}function ce(e){if(e&&!fr(e[1]))return{[e[0]]:e[1].data};if(w.actionData)return Object.keys(w.actionData).length===0?null:w.actionData}function le(e){let t=new Map(w.fetchers);return e.forEach(e=>{let n=t.get(e.key),r=Tr(void 0,n?n.data:void 0);t.set(e.key,r)}),t}async function ue(t,n,r,i){Ce(t);let a=(i&&i.flushSync)===!0,o=s.activeRoutes,l=On(w.location,w.matches,c,r,n,i?.relative),u=mt(o,l,c,!1,s.branches),d=J(u,o,l);if(d.active&&d.matches&&(u=d.matches),!u){ve(t,n,lr(404,{pathname:l}),{flushSync:a});return}let{path:f,submission:p,error:m}=kn(!0,l,i);if(m){ve(t,n,m,{flushSync:a});return}let h=e.getContext?await e.getContext():new st,g=(i&&i.preventScrollReset)===!0;if(p&&yr(p.formMethod)){await de(t,n,f,u,h,d.active,a,g,p,i&&i.defaultShouldRevalidate);return}B.set(t,{routeId:n,path:f}),await fe(t,n,f,u,h,d.active,a,g,p)}async function de(t,n,i,l,u,d,f,p,m,h){ge(),B.delete(t),_e(t,Er(m,w.fetchers.get(t)),{flushSync:f});let g=new AbortController,_=$n(e.history,i,g.signal,m);if(d){let e=await Ie(l,new URL(_.url).pathname,_.signal,t);if(e.type===`aborted`)return;if(e.type===`error`){ve(t,n,e.error,{flushSync:f});return}else if(e.matches)l=e.matches;else{ve(t,n,lr(404,{pathname:i}),{flushSync:f});return}}let v=xr(l,i);if(!v.route.action&&!v.route.lazy){ve(t,n,lr(405,{method:m.formMethod,pathname:i,routeId:n}),{flushSync:f});return}F.set(t,g);let y=I,b=Gn(a,o,_,i,l,v,r,u),x=await me(_,i,b,u,t),S=x[v.route.id];if(!S){for(let e of b)if(x[e.route.id]){S=x[e.route.id];break}}if(_.signal.aborted){F.get(t)===g&&F.delete(t);return}if(H.has(t)){if(pr(S)||fr(S)){_e(t,Dr(void 0));return}}else{if(pr(S))if(F.delete(t),L>y){_e(t,Dr(void 0));return}else return z.add(t),_e(t,Tr(m)),pe(_,S,!1,{fetcherSubmission:m,preventScrollReset:p});if(fr(S)){ve(t,n,S.error);return}}let C=w.navigation.location||w.location,E=$n(e.history,C,g.signal),D=s.activeRoutes,k=w.navigation.state===`idle`?w.matches:mt(D,w.navigation.location,c,!1,s.branches);Ze(k,`Didn't find any matches after fetcher action`);let A=++I;R.set(t,A);let{dsMatches:j,revalidatingFetchers:M}=An(E,u,a,o,e.history,w,k,m,C,r,!1,N,P,H,B,z,D,c,e.patchRoutesOnNavigation!=null,s.branches,[v.route.id,S],h),V=Tr(m,S.data),U=new Map(w.fetchers);U.set(t,V),M.filter(e=>e.key!==t).forEach(e=>{let t=e.key,n=U.get(t),r=Tr(void 0,n?n.data:void 0);U.set(t,r),Ce(t),e.controller&&F.set(t,e.controller)}),ne({fetchers:U});let W=()=>M.forEach(e=>Ce(e.key));g.signal.addEventListener(`abort`,W);let{loaderResults:G,fetcherResults:ee}=await he(j,M,E,C,u);if(g.signal.aborted)return;g.signal.removeEventListener(`abort`,W),R.delete(t),F.delete(t),M.forEach(e=>F.delete(e.key));let K=w.fetchers.has(t),te=e=>{if(!K)return e;let n=new Map(e.fetchers);return n.set(t,Dr(S.data)),{...e,fetchers:n}},ie=ur(G);if(ie)return w=te(w),pe(E,ie.result,!1,{preventScrollReset:p});if(ie=ur(ee),ie)return z.add(ie.key),w=te(w),pe(E,ie.result,!1,{preventScrollReset:p});let ae=new Map(w.fetchers);K&&ae.set(t,Dr(S.data));let{loaderData:oe,errors:se}=ir(w,k,G,void 0,M,ee,ae);Ee(A,ae),w.navigation.state===`loading`&&A>L?(Ze(T,`Expected pending action`),O&&O.abort(),re(w.navigation.location,{matches:k,loaderData:oe,errors:se,fetchers:ae})):(ne({errors:se,loaderData:ar(w.loaderData,oe,k,se),fetchers:ae}),N=!1)}async function fe(t,n,i,s,c,l,u,d,f){let p=w.fetchers.get(t);_e(t,Tr(f,p?p.data:void 0),{flushSync:u});let m=new AbortController,h=$n(e.history,i,m.signal);if(l){let e=await Ie(s,new URL(h.url).pathname,h.signal,t);if(e.type===`aborted`)return;if(e.type===`error`){ve(t,n,e.error,{flushSync:u});return}else if(e.matches)s=e.matches;else{ve(t,n,lr(404,{pathname:i}),{flushSync:u});return}}let g=xr(s,i);F.set(t,m);let _=I,v=await me(h,i,Gn(a,o,h,i,s,g,r,c),c,t),y=v[g.route.id];if(!y){for(let e of s)if(v[e.route.id]){y=v[e.route.id];break}}if(F.get(t)===m&&F.delete(t),!h.signal.aborted){if(H.has(t)){_e(t,Dr(void 0));return}if(pr(y))if(L>_){_e(t,Dr(void 0));return}else{z.add(t),await pe(h,y,!1,{preventScrollReset:d});return}if(fr(y)){ve(t,n,y.error);return}_e(t,Dr(y.data))}}async function pe(r,i,a,{submission:o,fetcherSubmission:s,preventScrollReset:l,replace:u}={}){a||(E?.resolve(),E=null),i.response.headers.has(`X-Remix-Revalidate`)&&(N=!0);let d=i.response.headers.get(`Location`);Ze(d,`Expected a Location header on the redirect Response`),d=Qn(d,new URL(r.url),c,e.history);let f=tt(w.location,d,{_isRedirect:!0});if(n){let e=!1;if(i.response.headers.has(`X-Remix-Reload-Document`))e=!0;else if(Pt(d)){let n=at(t,d,!0);e=n.origin!==t.location.origin||Mt(n.pathname,c)==null}if(e){u?t.location.replace(d):t.location.assign(d);return}}O=null;let p=u===!0||i.response.headers.has(`X-Remix-Replace`)?`REPLACE`:`PUSH`,{formMethod:m,formAction:h,formEncType:g}=w.navigation;!o&&!s&&m&&h&&g&&(o=Sr(w.navigation));let _=o||s;mn.has(i.response.status)&&_&&yr(_.formMethod)?await oe(p,f,{submission:{..._,formAction:d},preventScrollReset:l||D,enableViewTransition:a?k:void 0}):await oe(p,f,{overrideNavigation:Cr(f,[],p,o),fetcherSubmission:s,preventScrollReset:l||D,enableViewTransition:a?k:void 0})}async function me(e,t,n,r,i){let a,o={};try{a=await Kn(l,e,t,n,i,r,!1)}catch(e){return n.filter(e=>e.shouldLoad).forEach(t=>{o[t.route.id]={type:`error`,error:e}}),o}if(e.signal.aborted)return o;if(!yr(e.method))for(let e of n){if(a[e.route.id]?.type===`error`)break;!a.hasOwnProperty(e.route.id)&&!w.loaderData.hasOwnProperty(e.route.id)&&(!w.errors||!w.errors.hasOwnProperty(e.route.id))&&e.shouldCallHandler()&&(a[e.route.id]={type:`error`,result:Error(`No result returned from dataStrategy for route ${e.route.id}`)})}for(let[t,r]of Object.entries(a))if(pee(r)){let i=r.result;o[t]={type:`redirect`,response:Xn(i,e,t,n,c)}}else o[t]=await Yn(r);return o}async function he(e,t,n,r,i){let a=me(n,r,e,i,null),o=Promise.all(t.map(async e=>{if(e.matches&&e.match&&e.request&&e.controller){let t=(await me(e.request,e.path,e.matches,i,e.key))[e.match.route.id];return{[e.key]:t}}else return Promise.resolve({[e.key]:{type:`error`,error:lr(404,{pathname:e.path})}})}));return{loaderResults:await a,fetcherResults:(await o).reduce((e,t)=>Object.assign(e,t),{})}}function ge(){N=!0,B.forEach((e,t)=>{F.has(t)&&P.add(t),Ce(t)})}function _e(e,t,n={}){let r=new Map(w.fetchers);r.set(e,t),ne({fetchers:r},{flushSync:(n&&n.flushSync)===!0})}function ve(e,t,n,r={}){let i=sr(w.matches,t),a=new Map(w.fetchers);xe(a,e),ne({errors:{[i.route.id]:n},fetchers:a},{flushSync:(r&&r.flushSync)===!0})}function ye(e){return V.set(e,(V.get(e)||0)+1),H.has(e)&&H.delete(e),w.fetchers.get(e)||gn}function be(e,t){Ce(e,t?.reason),_e(e,Dr(null))}function xe(e,t){let n=w.fetchers.get(t);F.has(t)&&!(n&&n.state===`loading`&&R.has(t))&&Ce(t),B.delete(t),R.delete(t),z.delete(t),H.delete(t),P.delete(t),e.delete(t)}function Se(e){let t=(V.get(e)||0)-1;t<=0?(V.delete(e),H.add(e)):V.set(e,t),ne({fetchers:new Map(w.fetchers)})}function Ce(e,t){let n=F.get(e);n&&(n.abort(t),F.delete(e))}function we(e,t){for(let n of e){let e=t.get(n);Ze(e,`Expected fetcher: ${n}`);let r=Dr(e.data);t.set(n,r)}}function Te(e){let t=[],n=!1;for(let r of z){let i=e.get(r);Ze(i,`Expected fetcher: ${r}`),i.state===`loading`&&(z.delete(r),t.push(r),n=!0)}return we(t,e),n}function Ee(e,t){let n=[];for(let[r,i]of R)if(i<e){let e=t.get(r);Ze(e,`Expected fetcher: ${r}`),e.state===`loading`&&(Ce(r),R.delete(r),n.push(r))}return we(n,t),n.length>0}function De(e,t){let n=w.blockers.get(e)||_n;return U.get(e)!==t&&U.set(e,t),n}function Oe(e){w.blockers.delete(e),U.delete(e)}function ke(e,t){let n=w.blockers.get(e)||_n;Ze(n.state===`unblocked`&&t.state===`blocked`||n.state===`blocked`&&t.state===`blocked`||n.state===`blocked`&&t.state===`proceeding`||n.state===`blocked`&&t.state===`unblocked`||n.state===`proceeding`&&t.state===`unblocked`,`Invalid blocker state transition: ${n.state} -> ${t.state}`);let r=new Map(w.blockers);r.set(e,t),ne({blockers:r})}function Ae({currentLocation:e,nextLocation:t,historyAction:n}){if(U.size===0)return;U.size>1&&Qe(!1,`A router only supports one blocker at a time`);let r=Array.from(U.entries()),[i,a]=r[r.length-1],o=w.blockers.get(i);if(!(o&&o.state===`proceeding`)&&a({currentLocation:e,nextLocation:t,historyAction:n}))return i}function je(e){let t=lr(404,{pathname:e}),n=s.activeRoutes,{matches:r,route:i}=cr(n);return{notFoundMatches:r,route:i,error:t}}function Me(e,t,n){if(m=e,g=t,h=n||null,!_&&w.navigation===hn){_=!0;let e=Fe(w.location,w.matches);e!=null&&ne({restoreScrollPosition:e})}return()=>{m=null,g=null,h=null}}function Ne(e,t){return h&&h(e,t.map(e=>ht(e,w.loaderData)))||e.key}function Pe(e,t){if(m&&g){let n=Ne(e,t);m[n]=g()}}function Fe(e,t){if(m){let n=Ne(e,t),r=m[n];if(typeof r==`number`)return r}return null}function J(t,n,r){if(e.patchRoutesOnNavigation){let e=s.branches;if(!t)return{active:!0,matches:mt(n,r,c,!0,e)||[]};if(Object.keys(t[0].params).length>0)return{active:!0,matches:mt(n,r,c,!0,e)}}return{active:!1,matches:null}}async function Ie(t,n,r,i){if(!e.patchRoutesOnNavigation)return{type:`success`,matches:t};let l=t;for(;;){let t=o;try{await e.patchRoutesOnNavigation({signal:r,path:n,matches:l,fetcherKey:i,patch:(e,n)=>{r.aborted||Fn(e,n,s,t,a,!1)}})}catch(e){return{type:`error`,error:e,partialMatches:l}}if(r.aborted)return{type:`aborted`};let u=s.branches,d=mt(s.activeRoutes,n,c,!1,u),f=null;if(d&&(Object.keys(d[0].params).length===0||(f=mt(s.activeRoutes,n,c,!0,u),!(f&&l.length<f.length&&Le(l,f.slice(0,l.length))))))return{type:`success`,matches:d};if(f||=mt(s.activeRoutes,n,c,!0,u),!f||Le(l,f))return{type:`success`,matches:null};l=f}}function Le(e,t){return e.length===t.length&&e.every((e,n)=>e.route.id===t[n].route.id)}function Re(e){o={},s.setHmrRoutes(dt(e,a,void 0,o))}function ze(e,t,n=!1){Fn(e,t,s,o,a,n),s.hasHMRRoutes||ne({})}return C={get basename(){return c},get future(){return u},get state(){return w},get routes(){return s.stableRoutes},get branches(){return s.branches},get manifest(){return o},get window(){return t},initialize:ee,subscribe:te,enableScrollRestoration:Me,navigate:ie,fetch:ue,revalidate:ae,createHref:t=>e.history.createHref(t),encodeLocation:t=>e.history.encodeLocation(t),getFetcher:ye,resetFetcher:be,deleteFetcher:Se,dispose:K,getBlocker:De,deleteBlocker:Oe,patchRoutes:ze,_internalFetchControllers:F,_internalSetRoutes:Re,_internalSetStateDoNotUseOrYouWillBreakYourApp(e){ne(e)}},e.instrumentations&&(C=$t(C,e.instrumentations.map(e=>e.router).filter(Boolean))),C}function Dn(e){return e!=null&&(`formData`in e&&e.formData!=null||`body`in e&&e.body!==void 0)}function On(e,t,n,r,i,a){let o,s;if(i){o=[];for(let e of t)if(o.push(e),e.route.id===i){s=e;break}}else o=t,s=t[t.length-1];let c=zt(r||`.`,Rt(o),Mt(e.pathname,n)||e.pathname,a===`path`);if(r??(c.search=e.search,c.hash=e.hash),(r==null||r===``||r===`.`)&&s){let e=br(c.search);if(s.route.index&&!e)c.search=c.search?c.search.replace(/^\?/,`?index&`):`?index`;else if(!s.route.index&&e){let e=new URLSearchParams(c.search),t=e.getAll(`index`);e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();c.search=n?`?${n}`:``}}return n!==`/`&&(c.pathname=ree({basename:n,pathname:c.pathname})),nt(c)}function kn(e,t,n){if(!n||!Dn(n))return{path:t};if(n.formMethod&&!vr(n.formMethod))return{path:t,error:lr(405,{method:n.formMethod})};let r=()=>({path:t,error:lr(400,{type:`invalid-body`})}),i=(n.formMethod||`get`).toUpperCase(),a=dr(t);if(n.body!==void 0){if(n.formEncType===`text/plain`){if(!yr(i))return r();let e=typeof n.body==`string`?n.body:n.body instanceof FormData||n.body instanceof URLSearchParams?Array.from(n.body.entries()).reduce((e,[t,n])=>`${e}${t}=${n}
3
3
  `,``):String(n.body);return{path:t,submission:{formMethod:i,formAction:a,formEncType:n.formEncType,formData:void 0,json:void 0,text:e}}}else if(n.formEncType===`application/json`){if(!yr(i))return r();try{let e=typeof n.body==`string`?JSON.parse(n.body):n.body;return{path:t,submission:{formMethod:i,formAction:a,formEncType:n.formEncType,formData:void 0,json:e,text:void 0}}}catch{return r()}}}Ze(typeof FormData==`function`,`FormData is not available in this environment`);let o,s;if(n.formData)o=tr(n.formData),s=n.formData;else if(n.body instanceof FormData)o=tr(n.body),s=n.body;else if(n.body instanceof URLSearchParams)o=n.body,s=nr(o);else if(n.body==null)o=new URLSearchParams,s=new FormData;else try{o=new URLSearchParams(n.body),s=nr(o)}catch{return r()}let c={formMethod:i,formAction:a,formEncType:n&&n.formEncType||`application/x-www-form-urlencoded`,formData:s,json:void 0,text:void 0};if(yr(c.formMethod))return{path:t,submission:c};let l=rt(t);return e&&l.search&&br(l.search)&&o.append(`index`,``),l.search=`?${o}`,{path:nt(l),submission:c}}function An(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x){let S=b?fr(b[1])?b[1].error:b[1].data:void 0,C=i.createURL(a.location),w=i.createURL(c),T;if(u&&a.errors){let e=Object.keys(a.errors)[0];T=o.findIndex(t=>t.route.id===e)}else if(b&&fr(b[1])){let e=b[0];T=o.findIndex(t=>t.route.id===e)-1}let E=b?b[1].statusCode:void 0,D=E&&E>=400,O={currentUrl:C,currentParams:a.matches[0]?.params||{},nextUrl:w,nextParams:o[0].params,...s,actionResult:S,actionStatus:E},k=Jt(o),A=o.map((i,o)=>{let{route:s}=i,f=null;if(T!=null&&o>T)f=!1;else if(s.lazy)f=!0;else if(!jn(s))f=!1;else if(u){let{shouldLoad:e}=Mn(s,a.loaderData,a.errors);f=e}else Nn(a.loaderData,a.matches[o],i)&&(f=!0);if(f!==null)return Wn(n,r,e,c,k,i,l,t,f);let p=!1;typeof x==`boolean`?p=x:D?p=!1:d||C.pathname+C.search===w.pathname+w.search?p=!0:C.search===w.search?aee(a.matches[o],i)&&(p=!0):p=!0;let m={...O,defaultShouldRevalidate:p};return Wn(n,r,e,c,k,i,l,t,Pn(i,m),m,x)}),j=[];return m.forEach((e,s)=>{if(u||!o.some(t=>t.route.id===e.routeId)||p.has(s))return;let c=a.fetchers.get(s),m=c&&c.state!==`idle`&&c.data===void 0,b=mt(g,e.path,_??`/`,!1,y);if(!b){if(v&&m)return;j.push({key:s,routeId:e.routeId,path:e.path,matches:null,match:null,request:null,controller:null});return}if(h.has(s))return;let S=xr(b,e.path),C=new AbortController,w=$n(i,e.path,C.signal),T=null;if(f.has(s))f.delete(s),T=Gn(n,r,w,e.path,b,S,l,t);else if(m)d&&(T=Gn(n,r,w,e.path,b,S,l,t));else{let i;i=typeof x==`boolean`?x:D?!1:d;let a={...O,defaultShouldRevalidate:i};Pn(S,a)&&(T=Gn(n,r,w,e.path,b,S,l,t,a))}T&&j.push({key:s,routeId:e.routeId,path:e.path,matches:T,match:S,request:w,controller:C})}),{dsMatches:A,revalidatingFetchers:j}}function jn(e){return e.loader!=null||e.middleware!=null&&e.middleware.length>0}function Mn(e,t,n){if(e.lazy)return{shouldLoad:!0,renderFallback:!0};if(!jn(e))return{shouldLoad:!1,renderFallback:!1};let r=t!=null&&e.id in t,i=n!=null&&n[e.id]!==void 0;if(!r&&i)return{shouldLoad:!1,renderFallback:!1};if(typeof e.loader==`function`&&e.loader.hydrate===!0)return{shouldLoad:!0,renderFallback:!r};let a=!r&&!i;return{shouldLoad:a,renderFallback:a}}function Nn(e,t,n){let r=!t||n.route.id!==t.route.id,i=!e.hasOwnProperty(n.route.id);return r||i}function aee(e,t){let n=e.route.path;return e.pathname!==t.pathname||n!=null&&n.endsWith(`*`)&&e.params[`*`]!==t.params[`*`]}function Pn(e,t){if(e.route.shouldRevalidate){let n=e.route.shouldRevalidate(t);if(typeof n==`boolean`)return n}return t.defaultShouldRevalidate}function Fn(e,t,n,r,i,a){let o;if(e){let t=r[e];Ze(t,`No route found to patch children into: routeId = ${e}`),t.children||=[],o=t.children}else o=n.activeRoutes;let s=[],c=[];if(t.forEach(e=>{let t=o.find(t=>In(e,t));t?c.push({existingRoute:t,newRoute:e}):s.push(e)}),s.length>0){let t=dt(s,i,[e||`_`,`patch`,String(o?.length||`0`)],r);o.push(...t)}if(a&&c.length>0)for(let e=0;e<c.length;e++){let{existingRoute:t,newRoute:n}=c[e],r=t,[a]=dt([n],i,[],{},!0);Object.assign(r,{element:a.element?a.element:r.element,errorElement:a.errorElement?a.errorElement:r.errorElement,hydrateFallbackElement:a.hydrateFallbackElement?a.hydrateFallbackElement:r.hydrateFallbackElement})}n.hasHMRRoutes||n.setRoutes([...n.activeRoutes])}function In(e,t){return`id`in e&&`id`in t&&e.id===t.id?!0:e.index===t.index&&e.path===t.path&&e.caseSensitive===t.caseSensitive?(!e.children||e.children.length===0)&&(!t.children||t.children.length===0)?!0:e.children?.every((e,n)=>t.children?.some(t=>In(e,t)))??!1:!1}var Ln=new WeakMap,Rn=({key:e,route:t,manifest:n,mapRouteProperties:r})=>{let i=n[t.id];if(Ze(i,`No route found in manifest`),!i.lazy||typeof i.lazy!=`object`)return;let a=i.lazy[e];if(!a)return;let o=Ln.get(i);o||(o={},Ln.set(i,o));let s=o[e];if(s)return s;let c=(async()=>{let t=eee(e),n=i[e]!==void 0&&e!==`hasErrorBoundary`;if(t)Qe(!t,`Route property `+e+` is not a supported lazy route property. This property will be ignored.`),o[e]=Promise.resolve();else if(n)Qe(!1,`Route "${i.id}" has a static property "${e}" defined. The lazy property will be ignored.`);else{let t=await a();t!=null&&(Object.assign(i,{[e]:t}),Object.assign(i,r(i)))}typeof i.lazy==`object`&&(i.lazy[e]=void 0,Object.values(i.lazy).every(e=>e===void 0)&&(i.lazy=void 0))})();return o[e]=c,c},zn=new WeakMap;function oee(e,t,n,r,i){let a=n[e.id];if(Ze(a,`No route found in manifest`),!e.lazy)return{lazyRoutePromise:void 0,lazyHandlerPromise:void 0};if(typeof e.lazy==`function`){let t=zn.get(a);if(t)return{lazyRoutePromise:t,lazyHandlerPromise:t};let n=(async()=>{Ze(typeof e.lazy==`function`,`No lazy route function found`);let t=await e.lazy(),n={};for(let e in t){let r=t[e];if(r===void 0)continue;let i=lt(e),o=a[e]!==void 0&&e!==`hasErrorBoundary`;i?Qe(!i,`Route property `+e+` is not a supported property to be returned from a lazy route function. This property will be ignored.`):o?Qe(!o,`Route "${a.id}" has a static property "${e}" defined but its lazy function is also returning a value for this property. The lazy route property "${e}" will be ignored.`):n[e]=r}Object.assign(a,n),Object.assign(a,{...r(a),lazy:void 0})})();return zn.set(a,n),n.catch(()=>{}),{lazyRoutePromise:n,lazyHandlerPromise:n}}let o=Object.keys(e.lazy),s=[],c;for(let a of o){if(i&&i.includes(a))continue;let o=Rn({key:a,route:e,manifest:n,mapRouteProperties:r});o&&(s.push(o),a===t&&(c=o))}let l=s.length>0?Promise.all(s).then(()=>{}):void 0;return l?.catch(()=>{}),c?.catch(()=>{}),{lazyRoutePromise:l,lazyHandlerPromise:c}}async function Bn(e){let t=e.matches.filter(e=>e.shouldLoad),n={};return(await Promise.all(t.map(e=>e.resolve()))).forEach((e,r)=>{n[t[r].route.id]=e}),n}async function see(e){return e.matches.some(e=>e.route.middleware)?Vn(e,()=>Bn(e)):Bn(e)}function Vn(e,t){return cee(e,t,e=>{if(_r(e))throw e;return e},dee,n);function n(t,n,r){if(r)return Promise.resolve(Object.assign(r.value,{[n]:{type:`error`,result:t}}));{let{matches:r}=e,i=sr(r,r[Math.min(Math.max(r.findIndex(e=>e.route.id===n),0),Math.max(r.findIndex(e=>e.shouldCallHandler()),0))].route.id).route.id;return Promise.resolve({[i]:{type:`error`,result:t}})}}}async function cee(e,t,n,r,i){let{matches:a,...o}=e;return await Hn(o,a.flatMap(e=>e.route.middleware?e.route.middleware.map(t=>[e.route.id,t]):[]),t,n,r,i)}async function Hn(e,t,n,r,i,a,o=0){let{request:s}=e;if(s.signal.aborted)throw s.signal.reason??Error(`Request aborted: ${s.method} ${s.url}`);let c=t[o];if(!c)return await n();let[l,u]=c,d,f=async()=>{if(d)throw Error("You may only call `next()` once per middleware");try{return d={value:await Hn(e,t,n,r,i,a,o+1)},d.value}catch(e){return d={value:await a(e,l,d)},d.value}};try{let t=await u(e,f),n=t==null?void 0:r(t);return i(n)?n:d?n??d.value:(d={value:await f()},d.value)}catch(e){return await a(e,l,d)}}function Un(e,t,n,r,i){let a=Rn({key:`middleware`,route:r.route,manifest:t,mapRouteProperties:e}),o=oee(r.route,yr(n.method)?`action`:`loader`,t,e,i);return{middleware:a,route:o.lazyRoutePromise,handler:o.lazyHandlerPromise}}function Wn(e,t,n,r,i,a,o,s,c,l=null,u){let d=!1,f=Un(e,t,n,a,o);return{...a,_lazyPromises:f,shouldLoad:c,shouldRevalidateArgs:l,shouldCallHandler(e){return d=!0,l?typeof u==`boolean`?Pn(a,{...l,defaultShouldRevalidate:u}):typeof e==`boolean`?Pn(a,{...l,defaultShouldRevalidate:e}):Pn(a,l):c},resolve(e){let{lazy:t,loader:o,middleware:l}=a.route,u=d||c||e&&!yr(n.method)&&(t||o),p=l&&l.length>0&&!o&&!t;return u&&(yr(n.method)||!p)?qn({request:n,path:r,pattern:i,match:a,lazyHandlerPromise:f?.handler,lazyRoutePromise:f?.route,handlerOverride:e,scopedContext:s}):Promise.resolve({type:`data`,result:void 0})}}}function Gn(e,t,n,r,i,a,o,s,c=null){return i.map(l=>l.route.id===a.route.id?Wn(e,t,n,r,Jt(i),l,o,s,!0,c):{...l,shouldLoad:!1,shouldRevalidateArgs:c,shouldCallHandler:()=>!1,_lazyPromises:Un(e,t,n,l,o),resolve:()=>Promise.resolve({type:`data`,result:void 0})})}async function Kn(e,t,n,r,i,a,o){r.some(e=>e._lazyPromises?.middleware)&&await Promise.all(r.map(e=>e._lazyPromises?.middleware));let s={request:t,url:er(t,n),pattern:Jt(r),params:r[0].params,context:a,matches:r},c=o?()=>{throw Error("You cannot call `runClientMiddleware()` from a static handler `dataStrategy`. Middleware is run outside of `dataStrategy` during SSR in order to bubble up the Response. You can enable middleware via the `respond` API in `query`/`queryRoute`")}:e=>{let t=s;return Vn(t,()=>e({...t,fetcherKey:i,runClientMiddleware:()=>{throw Error("Cannot call `runClientMiddleware()` from within an `runClientMiddleware` handler")}}))},l=await e({...s,fetcherKey:i,runClientMiddleware:c});try{await Promise.all(r.flatMap(e=>[e._lazyPromises?.handler,e._lazyPromises?.route]))}catch{}return l}async function qn({request:e,path:t,pattern:n,match:r,lazyHandlerPromise:i,lazyRoutePromise:a,handlerOverride:o,scopedContext:s}){let c,l,u=yr(e.method),d=u?`action`:`loader`,f=i=>{let a,c=new Promise((e,t)=>a=t);l=()=>a(),e.signal.addEventListener(`abort`,l);let u=a=>typeof i==`function`?i({request:e,url:er(e,t),pattern:n,params:r.params,context:s},...a===void 0?[]:[a]):Promise.reject(Error(`You cannot call the handler for a route which defines a boolean "${d}" [routeId: ${r.route.id}]`)),f=(async()=>{try{return{type:`data`,result:await(o?o(e=>u(e)):u())}}catch(e){return{type:`error`,result:e}}})();return Promise.race([f,c])};try{let t=u?r.route.action:r.route.loader;if(i||a)if(t){let e,[n]=await Promise.all([f(t).catch(t=>{e=t}),i,a]);if(e!==void 0)throw e;c=n}else{await i;let t=u?r.route.action:r.route.loader;if(t)[c]=await Promise.all([f(t),a]);else if(d===`action`){let t=new URL(e.url),n=t.pathname+t.search;throw lr(405,{method:e.method,pathname:n,routeId:r.route.id})}else return{type:`data`,result:void 0}}else if(t)c=await f(t);else{let t=new URL(e.url);throw lr(404,{pathname:t.pathname+t.search})}}catch(e){return{type:`error`,result:e}}finally{l&&e.signal.removeEventListener(`abort`,l)}return c}async function Jn(e){let t=e.headers.get(`Content-Type`);return t&&/\bapplication\/json\b/.test(t)?e.body==null?null:e.json():e.text()}async function Yn(e){let{result:t,type:n}=e;if(hr(t)){let e;try{e=await Jn(t)}catch(e){return{type:`error`,error:e}}return n===`error`?{type:`error`,error:new Kt(t.status,t.statusText,e),statusCode:t.status,headers:t.headers}:{type:`data`,data:e,statusCode:t.status,headers:t.headers}}return n===`error`?mr(t)?t.data instanceof Error?{type:`error`,error:t.data,statusCode:t.init?.status,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:`error`,error:uee(t),statusCode:qt(t)?t.status:void 0,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:`error`,error:t,statusCode:qt(t)?t.status:void 0}:mr(t)?{type:`data`,data:t.data,statusCode:t.init?.status,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:`data`,data:t}}function Xn(e,t,n,r,i){let a=e.headers.get(`Location`);if(Ze(a,`Redirects returned/thrown from loaders/actions must have a Location header`),!Pt(a)){let o=r.slice(0,r.findIndex(e=>e.route.id===n)+1);a=On(new URL(t.url),o,i,a),e.headers.set(`Location`,a)}return e}var Zn=[`about:`,`blob:`,`chrome:`,`chrome-untrusted:`,`content:`,`data:`,`devtools:`,`file:`,`filesystem:`,`javascript:`];function Qn(e,t,n,r){if(Pt(e)){let r=e,i=r.startsWith(`//`)?new URL(t.protocol+r):new URL(r);if(Zn.includes(i.protocol))throw Error(`Invalid redirect location`);let a=Mt(i.pathname,n)!=null;if(i.origin===t.origin&&a)return Bt(i.pathname)+i.search+i.hash}try{let t=r.createURL(e);if(Zn.includes(t.protocol))throw Error(`Invalid redirect location`)}catch{}return e}function $n(e,t,n,r){let i=e.createURL(dr(t)).toString(),a={signal:n};if(r&&yr(r.formMethod)){let{formMethod:e,formEncType:t}=r;a.method=e.toUpperCase(),t===`application/json`?(a.headers=new Headers({"Content-Type":t}),a.body=JSON.stringify(r.json)):t===`text/plain`?a.body=r.text:t===`application/x-www-form-urlencoded`&&r.formData?a.body=tr(r.formData):a.body=r.formData}return new Request(i,a)}function er(e,t){let n=new URL(e.url),r=typeof t==`string`?rt(t):t;if(n.pathname=r.pathname||`/`,r.search){let e=new URLSearchParams(r.search),t=e.getAll(`index`);e.delete(`index`);for(let n of t.filter(Boolean))e.append(`index`,n);n.search=e.size?`?${e.toString()}`:``}else n.search=``;return n.hash=r.hash||``,n}function tr(e){let t=new URLSearchParams;for(let[n,r]of e.entries())t.append(n,typeof r==`string`?r:r.name);return t}function nr(e){let t=new FormData;for(let[n,r]of e.entries())t.append(n,r);return t}function rr(e,t,n,r=!1,i=!1){let a={},o=null,s,c=!1,l={},u=n&&fr(n[1])?n[1].error:void 0;return e.forEach(n=>{if(!(n.route.id in t))return;let d=n.route.id,f=t[d];if(Ze(!pr(f),`Cannot handle redirect results in processLoaderData`),fr(f)){let t=f.error;if(u!==void 0&&(t=u,u=void 0),o||={},i)o[d]=t;else{let n=sr(e,d);o[n.route.id]??(o[n.route.id]=t)}r||(a[d]=bn),c||(c=!0,s=qt(f.error)?f.error.status:500),f.headers&&(l[d]=f.headers)}else a[d]=f.data,f.statusCode&&f.statusCode!==200&&!c&&(s=f.statusCode),f.headers&&(l[d]=f.headers)}),u!==void 0&&n&&(o={[n[0]]:u},n[2]&&(a[n[2]]=void 0)),{loaderData:a,errors:o,statusCode:s||200,loaderHeaders:l}}function ir(e,t,n,r,i,a,o){let{loaderData:s,errors:c}=rr(t,n,r);return i.filter(e=>!e.matches||e.matches.some(e=>e.shouldLoad)).forEach(t=>{let{key:n,match:r,controller:i}=t;if(i&&i.signal.aborted)return;let s=a[n];if(Ze(s,`Did not find corresponding fetcher result`),fr(s)){let t=sr(e.matches,r?.route.id);c&&c[t.route.id]||(c={...c,[t.route.id]:s.error}),o.delete(n)}else if(pr(s))Ze(!1,`Unhandled fetcher revalidation redirect`);else{let e=Dr(s.data);o.set(n,e)}}),{loaderData:s,errors:c}}function ar(e,t,n,r){let i=Object.entries(t).filter(([,e])=>e!==bn).reduce((e,[t,n])=>(e[t]=n,e),{});for(let a of n){let n=a.route.id;if(!t.hasOwnProperty(n)&&e.hasOwnProperty(n)&&a.route.loader&&(i[n]=e[n]),r&&r.hasOwnProperty(n))break}return i}function or(e){return e?fr(e[1])?{actionData:{}}:{actionData:{[e[0]]:e[1].data}}:{}}function sr(e,t){return(t?e.slice(0,e.findIndex(e=>e.route.id===t)+1):[...e]).reverse().find(e=>e.route.hasErrorBoundary===!0)||e[0]}function cr(e){let t=e.length===1?e[0]:e.find(e=>e.index||!e.path||e.path===`/`)||{id:`__shim-error-route__`};return{matches:[{params:{},pathname:``,pathnameBase:``,route:t}],route:t}}function lr(e,{pathname:t,routeId:n,method:r,type:i,message:a}={}){let o=`Unknown Server Error`,s=`Unknown @remix-run/router error`;return e===400?(o=`Bad Request`,r&&t&&n?s=`You made a ${r} request to "${t}" but did not provide a \`loader\` for route "${n}", so there is no way to handle the request.`:i===`invalid-body`&&(s=`Unable to encode submission body`)):e===403?(o=`Forbidden`,s=`Route "${n}" does not match URL "${t}"`):e===404?(o=`Not Found`,s=`No route matches URL "${t}"`):e===405&&(o=`Method Not Allowed`,r&&t&&n?s=`You made a ${r.toUpperCase()} request to "${t}" but did not provide an \`action\` for route "${n}", so there is no way to handle the request.`:r&&(s=`Invalid request method "${r.toUpperCase()}"`)),new Kt(e||500,o,Error(s),!0)}function ur(e){let t=Object.entries(e);for(let e=t.length-1;e>=0;e--){let[n,r]=t[e];if(pr(r))return{key:n,result:r}}}function dr(e){return nt({...typeof e==`string`?rt(e):e,hash:``})}function lee(e,t){return e.pathname!==t.pathname||e.search!==t.search?!1:e.hash===``?t.hash!==``:e.hash===t.hash?!0:t.hash!==``}function uee(e){return new Kt(e.init?.status??500,e.init?.statusText??`Internal Server Error`,e.data)}function dee(e){return typeof e==`object`&&!!e&&Object.entries(e).every(([e,t])=>typeof e==`string`&&fee(t))}function fee(e){return typeof e==`object`&&!!e&&`type`in e&&`result`in e&&(e.type===`data`||e.type===`error`)}function pee(e){return hr(e.result)&&pn.has(e.result.status)}function fr(e){return e.type===`error`}function pr(e){return(e&&e.type)===`redirect`}function mr(e){return typeof e==`object`&&!!e&&`type`in e&&`data`in e&&`init`in e&&e.type===`DataWithResponseInit`}function hr(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.headers==`object`&&e.body!==void 0}function gr(e){return pn.has(e)}function _r(e){return hr(e)&&gr(e.status)&&e.headers.has(`Location`)}function vr(e){return fn.has(e.toUpperCase())}function yr(e){return un.has(e.toUpperCase())}function br(e){return new URLSearchParams(e).getAll(`index`).some(e=>e===``)}function xr(e,t){let n=typeof t==`string`?rt(t).search:t.search;if(e[e.length-1].route.index&&br(n||``))return e[e.length-1];let r=Lt(e);return r[r.length-1]}function Sr(e){let{formMethod:t,formAction:n,formEncType:r,text:i,formData:a,json:o}=e;if(!(!t||!n||!r)){if(i!=null)return{formMethod:t,formAction:n,formEncType:r,formData:void 0,json:void 0,text:i};if(a!=null)return{formMethod:t,formAction:n,formEncType:r,formData:a,json:void 0,text:void 0};if(o!==void 0)return{formMethod:t,formAction:n,formEncType:r,formData:void 0,json:o,text:void 0}}}function Cr(e,t,n,r){return r?{state:`loading`,location:e,matches:t,historyAction:n,formMethod:r.formMethod,formAction:r.formAction,formEncType:r.formEncType,formData:r.formData,json:r.json,text:r.text}:{state:`loading`,location:e,matches:t,historyAction:n,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0}}function wr(e,t,n,r){return{state:`submitting`,location:e,matches:t,historyAction:n,formMethod:r.formMethod,formAction:r.formAction,formEncType:r.formEncType,formData:r.formData,json:r.json,text:r.text}}function Tr(e,t){return e?{state:`loading`,formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t}:{state:`loading`,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:t}}function Er(e,t){return{state:`submitting`,formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t?t.data:void 0}}function Dr(e){return{state:`idle`,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:e}}function Or(e,t){try{let n=e.sessionStorage.getItem(yn);if(n){let e=JSON.parse(n);for(let[n,r]of Object.entries(e||{}))r&&Array.isArray(r)&&t.set(n,new Set(r||[]))}}catch{}}function kr(e,t){if(t.size>0){let n={};for(let[e,r]of t)n[e]=[...r];try{e.sessionStorage.setItem(yn,JSON.stringify(n))}catch(e){Qe(!1,`Failed to save applied view transitions in sessionStorage (${e}).`)}}}function Ar(){let e,t,n=new Promise((r,i)=>{e=async e=>{r(e);try{await n}catch{}},t=async e=>{i(e);try{await n}catch{}}});return{promise:n,resolve:e,reject:t}}var jr=J.createContext(null);jr.displayName=`DataRouter`;var Mr=J.createContext(null);Mr.displayName=`DataRouterState`;var Nr=J.createContext(!1);function Pr(){return J.useContext(Nr)}var Fr=J.createContext({isTransitioning:!1});Fr.displayName=`ViewTransition`;var Ir=J.createContext(new Map);Ir.displayName=`Fetchers`;var Lr=J.createContext(null);Lr.displayName=`Await`;var Rr=J.createContext(null);Rr.displayName=`Navigation`;var zr=J.createContext(null);zr.displayName=`Location`;var Br=J.createContext({outlet:null,matches:[],isDataRoute:!1});Br.displayName=`Route`;var Vr=J.createContext(null);Vr.displayName=`RouteError`;var Hr=`REACT_ROUTER_ERROR`,Ur=`REDIRECT`,Wr=`ROUTE_ERROR_RESPONSE`;function Gr(e){if(e.startsWith(`${Hr}:${Ur}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function Kr(e){if(e.startsWith(`${Hr}:${Wr}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new Kt(t.status,t.statusText,t.data)}catch{}}function qr(e,{relative:t}={}){Ze(Jr(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=J.useContext(Rr),{hash:i,pathname:a,search:o}=ri(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:Vt([n,a])),r.createHref({pathname:s,search:o,hash:i})}function Jr(){return J.useContext(zr)!=null}function Yr(){return Ze(Jr(),`useLocation() may be used only in the context of a <Router> component.`),J.useContext(zr).location}var Xr=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function Zr(e){J.useContext(Rr).static||J.useLayoutEffect(e)}function Qr(){let{isDataRoute:e}=J.useContext(Br);return e?xi():$r()}function $r(){Ze(Jr(),`useNavigate() may be used only in the context of a <Router> component.`);let e=J.useContext(jr),{basename:t,navigator:n}=J.useContext(Rr),{matches:r}=J.useContext(Br),{pathname:i}=Yr(),a=JSON.stringify(Rt(r)),o=J.useRef(!1);return Zr(()=>{o.current=!0}),J.useCallback((r,s={})=>{if(Qe(o.current,Xr),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=zt(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:Vt([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}var ei=J.createContext(null);function ti(e){let t=J.useContext(Br).outlet;return J.useMemo(()=>t&&J.createElement(ei.Provider,{value:e},t),[t,e])}function ni(){let{matches:e}=J.useContext(Br);return e[e.length-1]?.params??{}}function ri(e,{relative:t}={}){let{matches:n}=J.useContext(Br),{pathname:r}=Yr(),i=JSON.stringify(Rt(n));return J.useMemo(()=>zt(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function ii(e,t,n){Ze(Jr(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:r}=J.useContext(Rr),{matches:i}=J.useContext(Br),a=i[i.length-1],o=a?a.params:{},s=a?a.pathname:`/`,c=a?a.pathnameBase:`/`,l=a&&a.route;{let e=l&&l.path||``;Ci(s,!l||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${s}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
4
4
 
@@ -6,7 +6,7 @@ Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}
6
6
 
7
7
  `,wF=/\r\n/g,TF=`xopc.npmPendingRestart`,EF=typeof window<`u`&&window.electronAPI?.updater!==void 0;function DF(){return null}function OF(e){if(!(!e||typeof window>`u`))try{let t=sessionStorage.getItem(TF);if(!t)return;let n=JSON.parse(t),r=typeof n.installedVersion==`string`?n.installedVersion.trim():``;r&&r===e&&sessionStorage.removeItem(TF)}catch{}}function kF(e){return OF(e.currentVersion),e}function AF(){let[e,t]=(0,J.useState)(null),[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(()=>DF()),[o,s]=(0,J.useState)(EF?{state:`idle`}:DF()),c=(0,J.useRef)(null),l=EF||i!==null;(0,J.useEffect)(()=>{if(l)return;MF().then(e=>t(kF(e))).catch(()=>{});let e=e=>{let n=e.detail;if(n===null)t(e=>e&&kF({...e,updateAvailable:!1,latestVersion:null,channel:null}));else if(n&&typeof n==`object`){let e=n;t(kF({currentVersion:e.currentVersion??``,updateAvailable:!0,latestVersion:e.latestVersion??null,channel:e.channel??null}))}};return window.addEventListener(`update-available`,e),()=>window.removeEventListener(`update-available`,e)},[l]),(0,J.useEffect)(()=>{if(!EF)return;let e=window.electronAPI.updater;return e.getStatus().then(e=>s(e)),e.onStatusChanged(e=>s(e))},[]),(0,J.useEffect)(()=>{},[]),(0,J.useEffect)(()=>()=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null)},[]);let u=(0,J.useCallback)(async()=>{if(l)return!1;try{let e=await Ee(_(`/api/update/check`),{method:`POST`});if(!e.ok)return!1;let n=await e.json();return n.payload?(t(kF(n.payload)),!0):!1}catch{return!1}},[l]),d=(0,J.useCallback)(async()=>{if(l)return{ok:!1,error:`not-applicable`,message:`npm update is not used in the desktop app.`,status:400};r(!0);try{let e=await Ee(_(`/api/update/run/stream`),{method:`POST`,headers:{Accept:`text/event-stream`}});if(!e.ok||!e.body){let t=await e.text().catch(()=>``),n=`HTTP ${e.status}`;try{let e=JSON.parse(t);typeof e.message==`string`&&(n=e.message)}catch{t&&(n=t.slice(0,500))}return{ok:!1,error:e.status===409?`busy`:`unknown`,message:n,status:e.status}}let t=await NF(e.body);if(t.ok&&t.result){let e=t.result;if(e&&typeof e==`object`&&e.status===`ok`&&typeof e.installedVersion==`string`){try{sessionStorage.setItem(TF,JSON.stringify({installedVersion:e.installedVersion}))}catch{}window.dispatchEvent(new CustomEvent(`xopc:npm-update-installed`,{detail:{version:e.installedVersion}}))}else e&&typeof e==`object`&&e.status===`up-to-date`&&typeof e.latestVersion==`string`&&window.dispatchEvent(new CustomEvent(`xopc:npm-update-installed`,{detail:{version:e.latestVersion}}))}return t}catch(e){return{ok:!1,error:`network`,message:e instanceof Error?e.message:String(e),status:0}}finally{r(!1)}},[l]),f=(0,J.useCallback)(()=>{if(EF){window.electronAPI.updater.check();return}},[i]),p=(0,J.useCallback)(()=>{EF&&window.electronAPI.updater.quitAndInstall()},[]);return{npm:e,electron:EF?o:i??o,isElectron:l,checkNow:u,runNpmUpdate:d,npmUpdateRunning:n,electronCheck:f,electronQuitAndInstall:p}}var jF=null;async function MF(){return jF||(jF=(async()=>{let e=await Ee(_(`/api/update/status`));if(!e.ok)throw Error(`HTTP ${e.status}`);return(await e.json()).payload})().finally(()=>{jF=null}),jF)}async function NF(e){let t=e.getReader(),n=new TextDecoder,r=``,i=null,a=e=>{try{let t=JSON.parse(e);typeof t.line==`string`&&window.dispatchEvent(new CustomEvent(`xopc:npm-update-progress`,{detail:{line:t.line,source:t.source===`stderr`?`stderr`:`stdout`}}))}catch{}},o=e=>{let t=``,n=``;for(let r of e.split(`
8
8
  `)){let e=r.replace(/\r$/,``);e.startsWith(`event:`)?t=e.slice(6).trim():e.startsWith(`data:`)&&(n+=e.slice(5).trimStart())}if(n){if(t===`progress`){a(n);return}if(t===`result`)try{let e=JSON.parse(n);i=e.ok?{ok:!0,result:e.result??null}:{ok:!1,error:String(e.error??`unknown`),message:String(e.message??`Update failed`),status:e.error===`busy`?409:400,result:e.result??null}}catch{i={ok:!1,error:`parse`,message:`Invalid update stream`,status:0}}}};try{let e=async()=>{if(i!==null)return i;let{done:a,value:s}=await t.read();if(a)return i;r+=n.decode(s,{stream:!0}),r=r.replace(wF,`
9
- `);let c=r.split(CF);r=c.pop()??``;for(let e of c)e.length&&o(e);return e()},a=await e();if(a)return a}finally{t.releaseLock()}return i??{ok:!1,error:`no-result`,message:`Update stream ended without a result`,status:0}}var PF=`xopc.updateReminder.dismissed`,FF=typeof window<`u`&&window.electronAPI?.updater!==void 0,IF=`xopc:electron-update-recheck`;function LF(){if(typeof window>`u`)return{};try{let e=localStorage.getItem(PF);if(!e)return{};let t=JSON.parse(e);return t&&typeof t==`object`?t:{}}catch{return{}}}var RF=160;function zF(e){let t=e.trim();return t.length<=RF?t:`${t.slice(0,RF-1)}…`}function BF(){let{npm:e,electron:t,isElectron:n,electronQuitAndInstall:r,runNpmUpdate:i,npmUpdateRunning:a}=AF(),[o,s]=(0,J.useState)(LF),[c,l]=(0,J.useState)({downloading:!1,electronError:!1}),[u,d]=(0,J.useState)(()=>{if(typeof window>`u`||FF)return null;try{let e=sessionStorage.getItem(TF);if(!e)return null;let t=JSON.parse(e);return(typeof t.installedVersion==`string`?t.installedVersion.trim():``)||null}catch{return null}}),f=(0,J.useRef)(t?.state);f.current!==t?.state&&(f.current=t?.state,t?.state!==`downloading`&&c.downloading&&l(e=>({...e,downloading:!1})),t?.state!==`error`&&c.electronError&&l(e=>({...e,electronError:!1})));let p=(0,J.useRef)(null);if(u&&e?.currentVersion===u&&p.current!==u){p.current=u;try{sessionStorage.removeItem(TF)}catch{}d(null)}(0,J.useEffect)(()=>{if(n)return;let e=()=>{try{let e=sessionStorage.getItem(TF);if(!e){d(null);return}let t=JSON.parse(e);d((typeof t.installedVersion==`string`?t.installedVersion.trim():``)||null)}catch{d(null)}};return e(),window.addEventListener(`xopc:npm-update-installed`,e),()=>window.removeEventListener(`xopc:npm-update-installed`,e)},[n]),(0,J.useEffect)(()=>{let e=()=>{l(e=>({...e,downloading:!1})),s(e=>{let t={...e};delete t.electronReady;try{localStorage.setItem(PF,JSON.stringify(t))}catch{}return t})};return window.addEventListener(IF,e),()=>window.removeEventListener(IF,e)},[]),(0,J.useEffect)(()=>{let e=e=>{let t=e.detail?.version?.trim();t&&s(e=>{let n={...e,npm:t};try{localStorage.setItem(PF,JSON.stringify(n))}catch{}return n})};return window.addEventListener(`xopc:npm-update-installed`,e),()=>window.removeEventListener(`xopc:npm-update-installed`,e)},[]);let m=(0,J.useMemo)(()=>n&&t?.state===`downloaded`&&t.version?o.electronReady===t.version?{kind:`none`}:{kind:`electron-ready`,version:t.version}:n&&t?.state===`downloading`&&!c.downloading?{kind:`electron-downloading`,percent:Math.round(t.percent??0)}:n&&t?.state===`error`&&t.message&&!c.electronError?{kind:`electron-error`,message:zF(t.message)}:!n&&u&&e&&e.currentVersion!==u?{kind:`npm-restart-required`,version:u}:!n&&e?.updateAvailable&&e.latestVersion?o.npm===e.latestVersion?{kind:`none`}:{kind:`npm`,version:e.latestVersion,channel:e.channel}:{kind:`none`},[o.npm,o.electronReady,t,c.downloading,c.electronError,n,e,u]);return{show:m,dismiss:(0,J.useCallback)(()=>{if(m.kind===`electron-downloading`){l(e=>({...e,downloading:!0}));return}if(m.kind===`electron-error`){l(e=>({...e,electronError:!0}));return}if(m.kind===`npm-restart-required`){try{sessionStorage.removeItem(TF)}catch{}d(null);return}if(m.kind===`none`)return;let e={...o};m.kind===`npm`?e.npm=m.version:m.kind===`electron-ready`&&(e.electronReady=m.version);try{localStorage.setItem(PF,JSON.stringify(e))}catch{}s(e)},[o,m]),electronQuitAndInstall:r,runNpmUpdate:i,npmUpdateRunning:a}}var VF={version:`0.0.85`,commit:`7e4a16cf3d0ae39ca2fb41463b088216d94f13bd`,buildTimeIso:`2026-06-03T16:27:05.460Z`};function HF(){return function(e,t){switch(t.type){case`start`:return e.loading?e:{...e,loading:!0,error:null};case`success`:return{data:t.data,loading:!1,error:null};case`error`:return{data:t.data,loading:!1,error:t.error};case`patch`:return{...e,data:t.updater(e.data)}}}}function UF(e,t,n){let{enabled:r=!0,initial:i,errorData:a}=n,[o,s]=(0,J.useReducer)(HF(),void 0,()=>({data:i,loading:!1,error:null})),c=(0,J.useRef)(e);c.current=e;let l=(0,J.useRef)(a);l.current=a;let u=(0,J.useRef)(i);u.current=i,(0,J.useEffect)(()=>{if(!r)return;let e=!1;return s({type:`start`}),c.current().then(t=>{e||s({type:`success`,data:t})}).catch(t=>{if(e)return;let n=l.current;s({type:`error`,data:typeof n==`function`?n(t):n===void 0?u.current:n,error:t})}),()=>{e=!0}},[r,...t]);let d=(0,J.useCallback)(e=>{s({type:`patch`,updater:typeof e==`function`?e:()=>e})},[]);return{...o,setData:d}}var WF=`https://github.com/xopcai/xopc`,GF=new Intl.DateTimeFormat(`zh-CN`,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}),KF=new Intl.DateTimeFormat(`en-US`,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1});function qF(e,t){let n=new Date(e);if(Number.isNaN(n.getTime()))return e;try{return(t===`zh`?GF:KF).format(n)}catch{return n.toISOString()}}function JF({open:e,onOpenChange:t}){let n=d(e=>e.language),r=m(n),i=r.aboutDialog,a=r.updatePanel,{isElectron:o,electron:s,electronCheck:c,checkNow:l,npm:u,runNpmUpdate:f,npmUpdateRunning:p}=AF(),[h,g]=(0,J.useState)(!1),[v,y]=(0,J.useState)(!1),[b,x]=(0,J.useState)(!1),{data:S}=UF(async()=>{let e=await we(_(`/health`));return typeof e.version==`string`?e.version:null},[e],{enabled:e,initial:null,errorData:null}),C=(0,J.useCallback)(e=>{e||(g(!1),y(!1),x(!1)),t(e)},[t]),w=(0,J.useCallback)(async()=>{let e=m(n).updatePanel,t=await f();if(t.ok){window.dispatchEvent(new CustomEvent(`extension-notification`,{detail:{type:`success`,title:e.updateSuccess,message:e.updateSuccessDetail}}));return}let r=t.error===`git-checkout`?e.updateErrorGit:t.error===`busy`?e.updateErrorBusy:e.updateErrorFailed;window.dispatchEvent(new CustomEvent(`extension-notification`,{detail:{type:`error`,title:r,message:t.message}}))},[f,n]),T=VF.commit,E=n===`zh`?`zh-CN`:`en-US`,D=qF(VF.buildTimeIso,E),O=new Date().getFullYear(),k=i.copyright.replace(`{year}`,String(O));return(0,Z.jsx)(q,{open:e,onOpenChange:C,children:(0,Z.jsxs)(G,{children:[(0,Z.jsx)(ie,{className:`xopc-dialog-overlay fixed inset-0 z-[200] bg-scrim`}),(0,Z.jsxs)(se,{className:X(`xopc-dialog-content fixed left-1/2 top-1/2 z-[201] w-[min(100%-2rem,26rem)] -translate-x-1/2 -translate-y-1/2`,`rounded-2xl border border-edge bg-surface-panel shadow-popover dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-4 pt-3`,"aria-hidden":!0,children:[(0,Z.jsx)(`span`,{className:`size-3 rounded-full bg-[#ff5f57]`}),(0,Z.jsx)(`span`,{className:`size-3 rounded-full bg-[#febc2e]`}),(0,Z.jsx)(`span`,{className:`size-3 rounded-full bg-[#28c840]`})]}),(0,Z.jsxs)(`div`,{className:`px-6 pb-2 pt-1`,children:[(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(de,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":i.close,children:(0,Z.jsx)(oO,{className:`size-4`,strokeWidth:2})})})}),(0,Z.jsxs)(`div`,{className:`-mt-2 flex flex-col items-center text-center`,children:[(0,Z.jsx)(uA,{className:`size-[4.5rem]`,alt:r.appBrand}),(0,Z.jsx)(ue,{className:`mt-3 text-xl font-semibold tracking-tight text-fg`,children:r.appBrand}),(0,Z.jsx)(le,{className:`sr-only`,children:i.windowTitle})]}),(0,Z.jsxs)(`div`,{className:`mt-6 space-y-3 text-sm`,children:[(0,Z.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-center gap-x-3 gap-y-1`,children:[(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:i.versionLabel}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-2 sm:justify-start`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-[13px] text-fg tabular-nums`,children:VF.version}),(0,Z.jsx)(`button`,{type:`button`,className:X(`shrink-0 rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] font-medium text-fg-muted`,`transition-colors hover:bg-surface-hover hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),onClick:()=>{o?(window.dispatchEvent(new CustomEvent(IF)),g(!0),c()):(g(!0),x(!1),y(!0),(async()=>{let e=await l();y(!1),e||x(!0)})())},disabled:o&&[`checking`,`available`,`downloading`,`downloaded`].includes(s?.state??``)||!o&&(v||p),children:o&&s?.state===`checking`||!o&&v?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(Cg,{className:`size-3 animate-spin`}),i.checkUpdatesChecking]}):i.checkUpdates})]})]}),o&&h&&(0,Z.jsx)(YF,{state:s?.state,version:s?.version,percent:s?.percent,d:i}),!o&&h&&(0,Z.jsx)(XF,{checking:v,checkFailed:b,npm:u,npmUpdateRunning:p,onUpgrade:w,d:i,tp:a}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] gap-x-3 gap-y-1`,children:[(0,Z.jsx)(`span`,{className:`pt-0.5 text-fg-muted`,children:i.commitLabel}),(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] leading-snug text-fg`,children:T})]}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-baseline gap-x-3 gap-y-1`,children:[(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:i.buildDateLabel}),(0,Z.jsx)(`span`,{className:`text-right text-[13px] text-fg sm:text-left`,children:D})]}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-baseline gap-x-3 gap-y-1`,children:[(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:i.gatewayVersionLabel}),(0,Z.jsx)(`span`,{className:`text-right font-mono text-[13px] text-fg sm:text-left`,children:S??i.gatewayUnavailable})]}),(0,Z.jsx)(`p`,{className:`pt-0.5 text-[11px] text-fg-subtle`,children:i.consoleBuildHint})]}),(0,Z.jsxs)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 text-center text-[11px] leading-relaxed text-fg-muted`,children:[(0,Z.jsxs)(`p`,{children:[i.openSourceLead,(0,Z.jsx)(`a`,{className:`text-accent-fg underline decoration-accent-fg/40 underline-offset-2 hover:decoration-accent-fg`,href:WF,target:`_blank`,rel:`noopener noreferrer`,children:i.openSourceLink})]}),(0,Z.jsx)(`p`,{className:`mt-2`,children:k})]})]})]})]})})}function YF(e){let t=(0,Y.c)(29),{state:n,version:r,percent:i,d:a}=e;if(!n||n===`idle`)return null;if(n===`checking`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Cg,{className:`size-3.5 animate-spin`}),t[0]=e):e=t[0];let n;return t[1]===a.checkUpdatesChecking?n=t[2]:(n=(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,Z.jsx)(`span`,{children:a.checkUpdatesChecking})]}),t[1]=a.checkUpdatesChecking,t[2]=n),n}if(n===`not-available`){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(zl,{className:`size-3.5`}),t[3]=e):e=t[3];let n;return t[4]===a.checkUpdatesUpToDate?n=t[5]:(n=(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-green-600 dark:text-green-400`,children:[e,(0,Z.jsx)(`span`,{children:a.checkUpdatesUpToDate})]}),t[4]=a.checkUpdatesUpToDate,t[5]=n),n}if(n===`available`){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(xy,{className:`size-3.5`}),t[6]=e):e=t[6];let n;t[7]!==a.checkUpdatesAvailable||t[8]!==r?(n=a.checkUpdatesAvailable.replace(`{version}`,r??`?`),t[7]=a.checkUpdatesAvailable,t[8]=r,t[9]=n):n=t[9];let i;return t[10]===n?i=t[11]:(i=(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-accent-fg`,children:[e,(0,Z.jsx)(`span`,{children:n})]}),t[10]=n,t[11]=i),i}if(n===`downloading`){let e;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Uu,{className:`size-3.5 motion-safe:animate-[bounce_1s_ease-out_infinite]`}),t[12]=e):e=t[12];let n=a.checkUpdatesDownloading,r;if(t[13]!==a.checkUpdatesDownloading||t[14]!==i){let e;t[16]===i?e=t[17]:(e=Math.round(i??0),t[16]=i,t[17]=e),r=n.replace(`{percent}`,String(e)),t[13]=a.checkUpdatesDownloading,t[14]=i,t[15]=r}else r=t[15];let o;return t[18]===r?o=t[19]:(o=(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,Z.jsx)(`span`,{children:r})]}),t[18]=r,t[19]=o),o}if(n===`downloaded`){let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Uu,{className:`size-3.5`}),t[20]=e):e=t[20];let n;t[21]!==a.checkUpdatesDownloaded||t[22]!==r?(n=a.checkUpdatesDownloaded.replace(`{version}`,r??`?`),t[21]=a.checkUpdatesDownloaded,t[22]=r,t[23]=n):n=t[23];let i;return t[24]===n?i=t[25]:(i=(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] font-semibold text-accent-fg`,children:[e,(0,Z.jsx)(`span`,{children:n})]}),t[24]=n,t[25]=i),i}if(n===`error`){let e;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Rl,{className:`size-3.5`}),t[26]=e):e=t[26];let n;return t[27]===a.checkUpdatesError?n=t[28]:(n=(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-red-500 dark:text-red-400`,children:[e,(0,Z.jsx)(`span`,{children:a.checkUpdatesError})]}),t[27]=a.checkUpdatesError,t[28]=n),n}return null}function XF(e){let t=(0,Y.c)(25),{checking:n,checkFailed:r,npm:i,npmUpdateRunning:a,onUpgrade:o,d:s,tp:c}=e;if(n){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Cg,{className:`size-3.5 animate-spin`}),t[0]=e):e=t[0];let n;return t[1]===s.checkUpdatesChecking?n=t[2]:(n=(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,Z.jsx)(`span`,{children:s.checkUpdatesChecking})]}),t[1]=s.checkUpdatesChecking,t[2]=n),n}if(r){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Rl,{className:`size-3.5`}),t[3]=e):e=t[3];let n;return t[4]===s.checkUpdatesError?n=t[5]:(n=(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-red-500 dark:text-red-400`,children:[e,(0,Z.jsx)(`span`,{children:s.checkUpdatesError})]}),t[4]=s.checkUpdatesError,t[5]=n),n}if(a){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Cg,{className:`size-3.5 animate-spin`}),t[6]=e):e=t[6];let n;return t[7]===c.updateRunning?n=t[8]:(n=(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,Z.jsx)(`span`,{children:c.updateRunning})]}),t[7]=c.updateRunning,t[8]=n),n}if(i?.updateAvailable&&i.latestVersion){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(xy,{className:`mt-0.5 size-3.5 shrink-0`}),t[9]=e):e=t[9];let n;t[10]!==i.latestVersion||t[11]!==c.reminderNpm?(n=c.reminderNpm.replace(`{{version}}`,i.latestVersion),t[10]=i.latestVersion,t[11]=c.reminderNpm,t[12]=n):n=t[12];let r;t[13]===n?r=t[14]:(r=(0,Z.jsxs)(`p`,{className:`flex items-start gap-2 text-[12px] text-accent-fg`,children:[e,(0,Z.jsx)(`span`,{children:n})]}),t[13]=n,t[14]=r);let a;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(a=X(`w-full rounded-lg bg-accent px-3 py-1.5 text-center text-xs font-medium text-white`,`hover:bg-accent/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`),t[15]=a):a=t[15];let s;t[16]!==o||t[17]!==c.updateNow?(s=(0,Z.jsx)(`button`,{type:`button`,onClick:o,className:a,children:c.updateNow}),t[16]=o,t[17]=c.updateNow,t[18]=s):s=t[18];let l;return t[19]!==r||t[20]!==s?(l=(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[r,s]}),t[19]=r,t[20]=s,t[21]=l):l=t[21],l}let l;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(zl,{className:`size-3.5`}),t[22]=l):l=t[22];let u;return t[23]===s.checkUpdatesUpToDate?u=t[24]:(u=(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-green-600 dark:text-green-400`,children:[l,(0,Z.jsx)(`span`,{children:s.checkUpdatesUpToDate})]}),t[23]=s.checkUpdatesUpToDate,t[24]=u),u}var ZF=X(`flex w-full items-center gap-2.5 rounded-lg px-3 py-2.5 text-left text-sm font-medium leading-5 text-fg`,`transition-colors duration-150 ease-out`,`hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),QF=X(`rounded-xl border border-edge bg-surface-panel p-1 shadow-popover`,`dark:border-edge`);function $F(e){let t=(0,Y.c)(7),{selected:n,label:r,onSelect:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=X(`flex w-full items-center justify-between gap-2 rounded-lg px-3 py-2 text-left text-sm font-medium leading-5 text-fg`,`transition-colors duration-150 ease-out hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),t[0]=a):a=t[0];let o;t[1]===r?o=t[2]:(o=(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:r}),t[1]=r,t[2]=o);let s;return t[3]!==i||t[4]!==n||t[5]!==o?(s=(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":n,className:a,onClick:i,children:o}),t[3]=i,t[4]=n,t[5]=o,t[6]=s):s=t[6],s}function eI(e){let t=(0,Y.c)(181),{onOpenFullSettings:n,onAboutClick:r}=e,[i,a]=(0,J.useState)(null),o=d(oI),s=d(aI),c=ve(iI),l=ve(rI),u=RA(nI),f=RA(tI),p;t[0]===o?p=t[1]:(p=m(o),t[0]=o,t[1]=p);let h=p,g=h.appearanceSettings,_;t[2]===i?_=t[3]:(_=e=>X(`absolute left-full top-0 z-[60] min-w-[11rem] max-w-[min(calc(100vw-2rem),16rem)]`,`ml-2 sm:ml-2.5`,i===e?`block`:`hidden`),t[2]=i,t[3]=_);let v=_,y;t[4]===i?y=t[5]:(y=e=>X(`absolute left-full top-0 z-[55] h-full w-8 sm:w-9`,i===e?`pointer-events-auto`:`pointer-events-none`),t[4]=i,t[5]=y);let b=y,x;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>a(null),t[6]=x):x=t[6];let S;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>a(`lang`),t[7]=S):S=t[7];let C=i===`lang`&&`bg-surface-hover`,w;t[8]===C?w=t[9]:(w=X(ZF,C),t[8]=C,t[9]=w);let T=i===`lang`,E;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsx)(km,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[10]=E):E=t[10];let D;t[11]===g.languageTitle?D=t[12]:(D=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:g.languageTitle}),t[11]=g.languageTitle,t[12]=D);let O;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(Fl,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[13]=O):O=t[13];let k;t[14]!==D||t[15]!==w||t[16]!==T?(k=(0,Z.jsxs)(`button`,{type:`button`,className:w,"aria-haspopup":`menu`,"aria-expanded":T,children:[E,D,O]}),t[14]=D,t[15]=w,t[16]=T,t[17]=k):k=t[17];let A;t[18]===b?A=t[19]:(A=b(`lang`),t[18]=b,t[19]=A);let j;t[20]===A?j=t[21]:(j=(0,Z.jsx)(`div`,{className:A,"aria-hidden":!0}),t[20]=A,t[21]=j);let M;t[22]===v?M=t[23]:(M=v(`lang`),t[22]=v,t[23]=M);let N=o===`en`,P;t[24]===s?P=t[25]:(P=()=>s(`en`),t[24]=s,t[25]=P);let F;t[26]!==g.langOptionEn||t[27]!==N||t[28]!==P?(F=(0,Z.jsx)($F,{selected:N,label:g.langOptionEn,onSelect:P}),t[26]=g.langOptionEn,t[27]=N,t[28]=P,t[29]=F):F=t[29];let I=o===`zh`,L;t[30]===s?L=t[31]:(L=()=>s(`zh`),t[30]=s,t[31]=L);let R;t[32]!==g.langOptionZh||t[33]!==I||t[34]!==L?(R=(0,Z.jsx)($F,{selected:I,label:g.langOptionZh,onSelect:L}),t[32]=g.langOptionZh,t[33]=I,t[34]=L,t[35]=R):R=t[35];let z;t[36]!==F||t[37]!==R?(z=(0,Z.jsxs)(`div`,{className:QF,children:[F,R]}),t[36]=F,t[37]=R,t[38]=z):z=t[38];let B;t[39]!==g.languageTitle||t[40]!==M||t[41]!==z?(B=(0,Z.jsx)(`div`,{className:M,role:`menu`,"aria-label":g.languageTitle,children:z}),t[39]=g.languageTitle,t[40]=M,t[41]=z,t[42]=B):B=t[42];let V;t[43]!==k||t[44]!==j||t[45]!==B?(V=(0,Z.jsxs)(`div`,{className:`relative`,onMouseEnter:S,children:[k,j,B]}),t[43]=k,t[44]=j,t[45]=B,t[46]=V):V=t[46];let H;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>a(`theme`),t[47]=H):H=t[47];let U=i===`theme`&&`bg-surface-hover`,W;t[48]===U?W=t[49]:(W=X(ZF,U),t[48]=U,t[49]=W);let G=i===`theme`,ee;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,Z.jsx)(r_,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[50]=ee):ee=t[50];let K;t[51]===g.themeTitle?K=t[52]:(K=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:g.themeTitle}),t[51]=g.themeTitle,t[52]=K);let te;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,Z.jsx)(Fl,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[53]=te):te=t[53];let ne;t[54]!==W||t[55]!==G||t[56]!==K?(ne=(0,Z.jsxs)(`button`,{type:`button`,className:W,"aria-haspopup":`menu`,"aria-expanded":G,children:[ee,K,te]}),t[54]=W,t[55]=G,t[56]=K,t[57]=ne):ne=t[57];let re;t[58]===b?re=t[59]:(re=b(`theme`),t[58]=b,t[59]=re);let ie;t[60]===re?ie=t[61]:(ie=(0,Z.jsx)(`div`,{className:re,"aria-hidden":!0}),t[60]=re,t[61]=ie);let ae;t[62]===v?ae=t[63]:(ae=v(`theme`),t[62]=v,t[63]=ae);let oe=c===`light`,se;t[64]===l?se=t[65]:(se=()=>l(`light`),t[64]=l,t[65]=se);let q;t[66]!==g.themeOptionLight||t[67]!==oe||t[68]!==se?(q=(0,Z.jsx)($F,{selected:oe,label:g.themeOptionLight,onSelect:se}),t[66]=g.themeOptionLight,t[67]=oe,t[68]=se,t[69]=q):q=t[69];let ce=c===`dark`,le;t[70]===l?le=t[71]:(le=()=>l(`dark`),t[70]=l,t[71]=le);let ue;t[72]!==g.themeOptionDark||t[73]!==ce||t[74]!==le?(ue=(0,Z.jsx)($F,{selected:ce,label:g.themeOptionDark,onSelect:le}),t[72]=g.themeOptionDark,t[73]=ce,t[74]=le,t[75]=ue):ue=t[75];let de=c===`system`,fe;t[76]===l?fe=t[77]:(fe=()=>l(`system`),t[76]=l,t[77]=fe);let pe;t[78]!==g.themeOptionSystem||t[79]!==de||t[80]!==fe?(pe=(0,Z.jsx)($F,{selected:de,label:g.themeOptionSystem,onSelect:fe}),t[78]=g.themeOptionSystem,t[79]=de,t[80]=fe,t[81]=pe):pe=t[81];let me;t[82]!==q||t[83]!==ue||t[84]!==pe?(me=(0,Z.jsxs)(`div`,{className:QF,children:[q,ue,pe]}),t[82]=q,t[83]=ue,t[84]=pe,t[85]=me):me=t[85];let he;t[86]!==g.themeTitle||t[87]!==ae||t[88]!==me?(he=(0,Z.jsx)(`div`,{className:ae,role:`menu`,"aria-label":g.themeTitle,children:me}),t[86]=g.themeTitle,t[87]=ae,t[88]=me,t[89]=he):he=t[89];let ge;t[90]!==ne||t[91]!==ie||t[92]!==he?(ge=(0,Z.jsxs)(`div`,{className:`relative`,onMouseEnter:H,children:[ne,ie,he]}),t[90]=ne,t[91]=ie,t[92]=he,t[93]=ge):ge=t[93];let _e;t[94]===Symbol.for(`react.memo_cache_sentinel`)?(_e=()=>a(`font`),t[94]=_e):_e=t[94];let ye=i===`font`&&`bg-surface-hover`,be;t[95]===ye?be=t[96]:(be=X(ZF,ye),t[95]=ye,t[96]=be);let xe=i===`font`,Se;t[97]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,Z.jsx)(fE,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[97]=Se):Se=t[97];let Ce;t[98]===g.fontScaleTitle?Ce=t[99]:(Ce=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:g.fontScaleTitle}),t[98]=g.fontScaleTitle,t[99]=Ce);let we;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(we=(0,Z.jsx)(Fl,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[100]=we):we=t[100];let Te;t[101]!==be||t[102]!==xe||t[103]!==Ce?(Te=(0,Z.jsxs)(`button`,{type:`button`,className:be,"aria-haspopup":`menu`,"aria-expanded":xe,children:[Se,Ce,we]}),t[101]=be,t[102]=xe,t[103]=Ce,t[104]=Te):Te=t[104];let Ee;t[105]===b?Ee=t[106]:(Ee=b(`font`),t[105]=b,t[106]=Ee);let De;t[107]===Ee?De=t[108]:(De=(0,Z.jsx)(`div`,{className:Ee,"aria-hidden":!0}),t[107]=Ee,t[108]=De);let Oe;t[109]===v?Oe=t[110]:(Oe=v(`font`),t[109]=v,t[110]=Oe);let ke=u===`compact`,Ae;t[111]===f?Ae=t[112]:(Ae=()=>f(`compact`),t[111]=f,t[112]=Ae);let je;t[113]!==g.fontScaleCompact||t[114]!==ke||t[115]!==Ae?(je=(0,Z.jsx)($F,{selected:ke,label:g.fontScaleCompact,onSelect:Ae}),t[113]=g.fontScaleCompact,t[114]=ke,t[115]=Ae,t[116]=je):je=t[116];let Me=u===`default`,Ne;t[117]===f?Ne=t[118]:(Ne=()=>f(`default`),t[117]=f,t[118]=Ne);let Pe;t[119]!==g.fontScaleDefault||t[120]!==Me||t[121]!==Ne?(Pe=(0,Z.jsx)($F,{selected:Me,label:g.fontScaleDefault,onSelect:Ne}),t[119]=g.fontScaleDefault,t[120]=Me,t[121]=Ne,t[122]=Pe):Pe=t[122];let Fe=u===`large`,Ie;t[123]===f?Ie=t[124]:(Ie=()=>f(`large`),t[123]=f,t[124]=Ie);let Le;t[125]!==g.fontScaleLarge||t[126]!==Fe||t[127]!==Ie?(Le=(0,Z.jsx)($F,{selected:Fe,label:g.fontScaleLarge,onSelect:Ie}),t[125]=g.fontScaleLarge,t[126]=Fe,t[127]=Ie,t[128]=Le):Le=t[128];let Re;t[129]!==je||t[130]!==Pe||t[131]!==Le?(Re=(0,Z.jsxs)(`div`,{className:QF,children:[je,Pe,Le]}),t[129]=je,t[130]=Pe,t[131]=Le,t[132]=Re):Re=t[132];let ze;t[133]!==g.fontScaleTitle||t[134]!==Oe||t[135]!==Re?(ze=(0,Z.jsx)(`div`,{className:Oe,role:`menu`,"aria-label":g.fontScaleTitle,children:Re}),t[133]=g.fontScaleTitle,t[134]=Oe,t[135]=Re,t[136]=ze):ze=t[136];let Be;t[137]!==Te||t[138]!==De||t[139]!==ze?(Be=(0,Z.jsxs)(`div`,{className:`relative`,onMouseEnter:_e,children:[Te,De,ze]}),t[137]=Te,t[138]=De,t[139]=ze,t[140]=Be):Be=t[140];let Ve;t[141]===Symbol.for(`react.memo_cache_sentinel`)?(Ve=(0,Z.jsx)(`div`,{className:`my-2 h-px bg-edge-subtle`,role:`separator`}),t[141]=Ve):Ve=t[141];let He;t[142]===r?He=t[143]:(He=()=>r?.(),t[142]=r,t[143]=He);let Ue,We,Ge;t[144]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=()=>a(null),We=()=>a(null),Ge=(0,Z.jsx)(ug,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[144]=Ue,t[145]=We,t[146]=Ge):(Ue=t[144],We=t[145],Ge=t[146]);let Ke;t[147]===g.aboutApp?Ke=t[148]:(Ke=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:g.aboutApp}),t[147]=g.aboutApp,t[148]=Ke);let qe;t[149]!==He||t[150]!==Ke?(qe=(0,Z.jsxs)(`button`,{type:`button`,className:ZF,onClick:He,onMouseEnter:Ue,onFocus:We,children:[Ge,Ke]}),t[149]=He,t[150]=Ke,t[151]=qe):qe=t[151];let Je;t[152]===o?Je=t[153]:(Je=ej(o),t[152]=o,t[153]=Je);let Ye,Xe,Ze;t[154]===Symbol.for(`react.memo_cache_sentinel`)?(Ye=()=>a(null),Xe=()=>a(null),Ze=(0,Z.jsx)(El,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[154]=Ye,t[155]=Xe,t[156]=Ze):(Ye=t[154],Xe=t[155],Ze=t[156]);let Qe;t[157]===h.sidebar.helpDocs?Qe=t[158]:(Qe=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:h.sidebar.helpDocs}),t[157]=h.sidebar.helpDocs,t[158]=Qe);let $e;t[159]===Symbol.for(`react.memo_cache_sentinel`)?($e=(0,Z.jsx)(yd,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[159]=$e):$e=t[159];let et;t[160]!==Je||t[161]!==Qe?(et=(0,Z.jsxs)(`a`,{href:Je,target:`_blank`,rel:`noopener noreferrer`,className:ZF,onMouseEnter:Ye,onFocus:Xe,children:[Ze,Qe,$e]}),t[160]=Je,t[161]=Qe,t[162]=et):et=t[162];let tt,nt,rt;t[163]===Symbol.for(`react.memo_cache_sentinel`)?(tt=X(ZF,`text-accent-fg hover:bg-accent-soft hover:text-accent-fg`),nt=()=>a(null),rt=()=>a(null),t[163]=tt,t[164]=nt,t[165]=rt):(tt=t[163],nt=t[164],rt=t[165]);let it;t[166]===n?it=t[167]:(it=()=>n?.(),t[166]=n,t[167]=it);let at;t[168]===Symbol.for(`react.memo_cache_sentinel`)?(at=(0,Z.jsx)(Jb,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[168]=at):at=t[168];let ot;t[169]===g.openFullPreferences?ot=t[170]:(ot=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1`,children:g.openFullPreferences}),t[169]=g.openFullPreferences,t[170]=ot);let st;t[171]!==it||t[172]!==ot?(st=(0,Z.jsxs)(ja,{to:`/settings/overview`,className:tt,onMouseEnter:nt,onFocus:rt,onClick:it,children:[at,ot]}),t[171]=it,t[172]=ot,t[173]=st):st=t[173];let ct;return t[174]!==V||t[175]!==ge||t[176]!==Be||t[177]!==qe||t[178]!==et||t[179]!==st?(ct=(0,Z.jsxs)(`div`,{className:`w-[min(calc(100vw-2rem),15rem)] shrink-0 py-1`,onMouseLeave:x,children:[V,ge,Be,Ve,qe,et,st]}),t[174]=V,t[175]=ge,t[176]=Be,t[177]=qe,t[178]=et,t[179]=st,t[180]=ct):ct=t[180],ct}function tI(e){return e.setPreference}function nI(e){return e.preference}function rI(e){return e.setPreference}function iI(e){return e.preference}function aI(e){return e.setLanguage}function oI(e){return e.language}function sI({collapsed:e=!1,onNavigate:t}){let n=m(d(e=>e.language)),r=n.appearanceSettings,[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(!1);return(0,J.useEffect)(()=>{D(()=>import(`./settings-page-C18xBt4X.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15])),D(()=>import(`./sessions-page-5N4aF2Wk.js`),__vite__mapDeps([16,1,2,3,5,7,12,9])),D(()=>import(`./logs-page-_d4UJ-qQ.js`),__vite__mapDeps([17,1,2,3,7,9])),D(()=>import(`./cron-page-DeGo-Vjc.js`),__vite__mapDeps([18,1,2,3,19,4,7,10,8,9,13,5])),D(()=>import(`./skills-page-sPAXhh8w.js`),__vite__mapDeps([20,1,21,2,3,19,7,9]))},[]),(0,Z.jsxs)(`div`,{className:X(`flex shrink-0 flex-col`,e&&`mt-auto`,e?`items-center px-1 py-2`:`p-3`),children:[(0,Z.jsxs)(gF,{open:i,onOpenChange:a,children:[e?(0,Z.jsx)(vF,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:X(`flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-full outline-none ring-offset-surface-base transition-transform`,`hover:opacity-95 active:scale-95`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2`,i&&`ring-2 ring-accent`,`motion-reduce:opacity-100 motion-reduce:active:scale-100`),"aria-expanded":i,"aria-haspopup":`dialog`,title:n.sidebar.appMenuAria,"aria-label":n.sidebar.appMenuAria,children:(0,Z.jsx)(uA,{className:`size-full rounded-full`,alt:n.appBrand})})}):(0,Z.jsx)(vF,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:X(`flex w-full min-w-0 items-center gap-2 rounded-xl p-1 text-left outline-none transition-colors duration-150 ease-out`,`hover:bg-surface-active/70`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i&&`bg-surface-active/70`),"aria-expanded":i,"aria-haspopup":`dialog`,title:n.sidebar.appMenuAria,"aria-label":n.sidebar.appMenuAria,children:[(0,Z.jsx)(`span`,{className:`size-8 shrink-0 overflow-hidden rounded-full`,"aria-hidden":!0,children:(0,Z.jsx)(uA,{className:`size-full rounded-full`,alt:``,"aria-hidden":!0})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold leading-tight text-fg`,children:n.appBrand}),(0,Z.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:r.quickMenuHint})]}),(0,Z.jsx)(`span`,{className:X(`flex size-9 shrink-0 items-center justify-center rounded-xl text-fg-muted transition-colors`,i&&`bg-accent-soft text-accent-fg`),"aria-hidden":!0,children:(0,Z.jsx)(Jb,{className:`size-[18px]`,strokeWidth:1.5})})]})}),(0,Z.jsx)(yF,{children:(0,Z.jsx)(bF,{className:X(`z-50 w-max max-w-[min(calc(100vw-1rem),28rem)] overflow-visible`,`rounded-xl border border-edge bg-surface-panel p-2 shadow-popover dark:border-edge`),side:`top`,align:e?`center`:`start`,sideOffset:8,collisionPadding:12,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),children:(0,Z.jsx)(eI,{onOpenFullSettings:()=>{a(!1),t?.()},onAboutClick:()=>{s(!0),a(!1)}})})})]}),(0,Z.jsx)(JF,{open:o,onOpenChange:s})]})}var cI=`xopc-web-sidebar-nav-order`;function lI(){try{let e=globalThis.localStorage?.getItem(cI);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function uI(e){try{globalThis.localStorage?.setItem(cI,JSON.stringify(e))}catch{}}function dI(e,t,n,r,i){if(t===n)return e;let a=e.filter(e=>e!==t),o=a.indexOf(n),s=o===-1?a.length:r===`before`?o:o+1;return pI([...a.slice(0,s),t,...a.slice(s)],i)}function fI(e,t,n){return pI([...e.filter(e=>e!==t),t],n)}function pI(e,t){let n=new Set(e),r=[];for(let e of t)n.has(e)||r.push(e);return r.length===0?e:[...e,...r]}var mI=c((e,t)=>({order:lI(),move:(n,r,i)=>{let a=dI(t().order,n,r,i,new Set(t().order));a!==t().order&&(e({order:a}),queueMicrotask(()=>uI(a)))},moveToEnd:n=>{let r=fI(t().order,n,new Set(t().order));r!==t().order&&(e({order:r}),queueMicrotask(()=>uI(r)))},setOrder:t=>{e({order:t}),queueMicrotask(()=>uI(t))}})),hI=null,gI=c((e,t)=>({variables:{},loaded:!1,updateContext:t=>e(e=>({variables:{...e.variables,...t}})),setContext:t=>e({variables:t,loaded:!0}),fetchContext:async()=>hI||(hI=(async()=>{let e=await we(_(`/api/context`));t().setContext(e)})().finally(()=>{hI=null}),hI)})),_I=function(e){return e[e.PermissionDenied=4001]=`PermissionDenied`,e[e.InvalidRequest=4002]=`InvalidRequest`,e[e.MethodNotFound=4003]=`MethodNotFound`,e[e.InternalError=4004]=`InternalError`,e[e.Timeout=4005]=`Timeout`,e[e.ExtensionNotFound=4006]=`ExtensionNotFound`,e[e.RateLimited=4007]=`RateLimited`,e}({}),vI=[`--color-surface-base`,`--color-surface-panel`,`--color-surface-hover`,`--color-fg`,`--color-fg-muted`,`--color-fg-subtle`,`--color-accent`,`--color-accent-hover`,`--color-accent-soft`,`--color-edge`,`--color-edge-subtle`,`--color-danger`,`--color-success`,`--color-warning`,`--radius-sm`,`--radius-lg`,`--radius-xl`];function yI(e){let t=getComputedStyle(document.documentElement),n={};for(let e of vI){let r=t.getPropertyValue(e).trim();r&&(n[e]=r)}return{mode:e,tokens:n,fontFamily:t.getPropertyValue(`font-family`).trim(),fontFamilyMono:t.getPropertyValue(`--font-mono`).trim()}}var bI={"agent.sendMessage":`agent.send`,"session.list":`session.read`,"session.navigate":`session.read`,"config.get":`config.read`,"config.set":`config.write`,"storage.get":`storage`,"storage.set":`storage`,"storage.remove":`storage`,"storage.keys":`storage`,"ui.notification":`notification`,"ui.navigate":`theme`,"theme.get":`theme`},xI=class{iframes=new Map;byContentWindow=new WeakMap;handlers=new Map;extensionPermissions=new Map;eventSubscribers=new Map;agentStreamSubscriptions=new Map;boundListener=e=>{this.onWindowMessage(e)};constructor(){window.addEventListener(`message`,this.boundListener)}dispose(){window.removeEventListener(`message`,this.boundListener),this.iframes.clear(),this.handlers.clear(),this.extensionPermissions.clear(),this.eventSubscribers.clear(),this.agentStreamSubscriptions.clear()}registerIframe(e,t,n){let r=this.iframes.get(e);r&&r!==t&&r.contentWindow&&this.byContentWindow.delete(r.contentWindow),this.iframes.set(e,t),this.extensionPermissions.set(e,new Set(n)),this.rememberIframeWindow(e,t)}unregisterIframe(e){let t=this.iframes.get(e);t?.contentWindow&&this.byContentWindow.delete(t.contentWindow),this.iframes.delete(e),this.extensionPermissions.delete(e),this.agentStreamSubscriptions.delete(e)}rememberIframeWindow(e,t){let n=t.contentWindow;n&&this.byContentWindow.set(n,{extensionId:e,iframe:t})}subscribeAgentStream(e,t){let n=this.agentStreamSubscriptions.get(e);n||(n=new Set,this.agentStreamSubscriptions.set(e,n)),n.add(t)}unsubscribeAgentStream(e,t){this.agentStreamSubscriptions.get(e)?.delete(t)}forwardAgentStreamEvent(e,t){for(let[n,r]of this.agentStreamSubscriptions)r.has(e)&&this.sendEvent(n,`agent.stream.${e}`,t)}broadcastExtensionEvent(e,t,n){let r=t.startsWith(`ext.`)?t:`ext.${t}`;for(let[t]of this.iframes)t!==e&&this.sendEvent(t,r,n)}handleExtensionEvent(e,t,n){if(t.startsWith(`ext.`)){let r=t.slice(4);this.broadcastExtensionEvent(e,r,n);return}if(t===`agent.subscribe`||t===`agent.unsubscribe`){if(!(this.extensionPermissions.get(e)??new Set).has(`agent.subscribe`))return;let{sessionKey:r}=n??{};if(typeof r!=`string`||!r.trim())return;let i=r.trim();t===`agent.subscribe`?this.subscribeAgentStream(e,i):this.unsubscribeAgentStream(e,i)}}registerMethod(e,t){this.handlers.set(e,t)}subscribeExtensionEvents(e,t){let n=this.eventSubscribers.get(e);return n||(n=new Set,this.eventSubscribers.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&this.eventSubscribers.delete(e)}}sendInit(e,t,n){let r=this.iframes.get(e);if(!r?.contentWindow)return;this.rememberIframeWindow(e,r);let i=[...this.extensionPermissions.get(e)??[]];r.contentWindow.postMessage({source:`xopc-host`,type:`init`,extensionId:e,permissions:i,theme:t,locale:n},`*`)}sendEvent(e,t,n){let r=this.iframes.get(e);r?.contentWindow&&r.contentWindow.postMessage({source:`xopc-host`,type:`event`,event:t,data:n},`*`)}broadcastEvent(e,t){for(let[,n]of this.iframes)n.contentWindow?.postMessage({source:`xopc-host`,type:`event`,event:e,data:t},`*`)}postResponse(e,t,n,r,i){let a=e.contentWindow??(t?.source instanceof Window?t.source:null),o={source:`xopc-host`,type:`response`,requestId:n,result:r,error:i};a&&a.postMessage(o,`*`)}isTrustedExtensionSource(e,t){if(t.source===null)return!0;let n=e.contentWindow;if(t.source===n)return!0;if(n&&typeof Window<`u`&&t.source instanceof Window)try{return t.source.frameElement===e}catch{}return!1}async onWindowMessage(e){let t=e.data;if(!t||t.source!==`xopc-extension`)return;let n,r=t.extensionId;if(e.source instanceof Window){let t=this.byContentWindow.get(e.source);t&&(n=t.iframe,r=t.extensionId)}if(n||(n=this.iframes.get(t.extensionId),r=t.extensionId),!n||!(e.source instanceof Window&&this.byContentWindow.has(e.source))&&!this.isTrustedExtensionSource(n,e))return;if(t.type===`event`){this.handleExtensionEvent(r,t.event,t.data);let e=this.eventSubscribers.get(r);if(e){let n={event:t.event,data:t.data};for(let t of e)try{t(n)}catch{}}return}if(t.type!==`request`)return;let{requestId:i,method:a,params:o}=t,s=this.handlers.get(a);if(!s){this.postResponse(n,e,i,void 0,{code:_I.MethodNotFound,message:`Unknown method: ${a}`});return}let c=bI[a],l=this.extensionPermissions.get(r)??new Set;if(c&&!l.has(c)){this.postResponse(n,e,i,void 0,{code:_I.PermissionDenied,message:`Missing permission: ${c}`});return}try{let t=await s(r,o);this.postResponse(n,e,i,t)}catch(t){let r=t instanceof Error?t.message:String(t);this.postResponse(n,e,i,void 0,{code:_I.InternalError,message:r})}}};function SI(e){e.registerMethod(`theme.get`,async()=>yI(ve.getState().resolved)),e.registerMethod(`ui.navigate`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`path`in t?String(t.path??``):``;n&&window.dispatchEvent(new CustomEvent(`extension-navigate`,{detail:{path:n}}))}),e.registerMethod(`ui.notification`,async(e,t)=>{window.dispatchEvent(new CustomEvent(`extension-notification`,{detail:t}))}),e.registerMethod(`session.navigate`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`sessionKey`in t?String(t.sessionKey??``):``;n&&window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:n},bubbles:!0}))}),e.registerMethod(`session.list`,async()=>{let e=await Ee(_(`/api/sessions`));if(!e.ok)throw Error(`Failed to list sessions: ${e.status}`);return((await e.json()).items??[]).map(e=>({sessionKey:e.key,title:e.name,lastMessageAt:e.updatedAt??e.lastAccessedAt,messageCount:e.messageCount}))}),e.registerMethod(`agent.sendMessage`,async(e,t)=>{let{message:n,sessionKey:r,newSession:i}=t,a=await Ee(_(`/api/agent`),{method:`POST`,headers:{Accept:`application/json`},body:JSON.stringify({message:n,channel:`webchat`,sessionKey:i?void 0:r,newSession:!!i})});if(!a.ok)throw Error(`Agent request failed: ${a.status}`);let o=await a.json();return{sessionKey:o.payload?.sessionKey??o.payload?.key??o.sessionKey??r??``}}),e.registerMethod(`config.get`,async e=>{let t=await Ee(_(`/api/extensions/${encodeURIComponent(e)}/config`));if(!t.ok)throw Error(`Failed to get config: ${t.status}`);return t.json()}),e.registerMethod(`config.set`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&!Array.isArray(t)?t:{},r=await Ee(_(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(n)});if(!r.ok)throw Error(`Failed to set config: ${r.status}`)}),e.registerMethod(`storage.get`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`key`in t?String(t.key??``):``,r=await Ee(_(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(n)}`));if(r.status!==404){if(!r.ok)throw Error(`Failed to get storage key: ${r.status}`);return(await r.json()).value}}),e.registerMethod(`storage.set`,async(e,t)=>{let n=t,r=n&&typeof n.key==`string`?n.key:``,i=await Ee(_(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(r)}`),{method:`PUT`,body:JSON.stringify({value:n?.value})});if(!i.ok)throw Error(`Failed to set storage key: ${i.status}`)}),e.registerMethod(`storage.remove`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`key`in t?String(t.key??``):``,r=await Ee(_(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(n)}`),{method:`DELETE`});if(r.status!==404&&!r.ok)throw Error(`Failed to remove storage key: ${r.status}`)}),e.registerMethod(`storage.keys`,async e=>{let t=await Ee(_(`/api/extensions/${encodeURIComponent(e)}/storage`));if(!t.ok)throw Error(`Failed to list storage keys: ${t.status}`);return(await t.json()).keys??[]})}var CI=(0,J.createContext)(null);function wI({children:e}){let t=(0,J.useRef)(null);if(!t.current){let e=new xI;SI(e),t.current=e}let n=t.current,r=Se(e=>!!e.token),{data:i,isLoading:a}=v(r?`gateway-extensions-list`:null,()=>we(_(`/api/extensions`)),{revalidateOnFocus:!1}),o=i?.extensions??[],s=ve(e=>e.resolved);(0,J.useEffect)(()=>{r&&gI.getState().fetchContext()},[r]),(0,J.useEffect)(()=>{let e=e=>{let t=e.detail;t&&typeof t==`object`&&!Array.isArray(t)&&gI.getState().updateContext(t)},t=()=>{gI.getState().fetchContext()};return window.addEventListener(`context-update`,e),window.addEventListener(`config-reload`,t),window.addEventListener(`registry-updated`,t),()=>{window.removeEventListener(`context-update`,e),window.removeEventListener(`config-reload`,t),window.removeEventListener(`registry-updated`,t)}},[]);let c=(0,J.useCallback)(e=>{let t=e.detail;t?.sessionKey&&n.forwardAgentStreamEvent(t.sessionKey,t.event??t)},[n]),l=(0,J.useRef)(c);l.current=c,(0,J.useEffect)(()=>{let e=e=>{l.current(e)};return window.addEventListener(`agent-stream-event`,e),()=>{window.removeEventListener(`agent-stream-event`,e)}},[]),(0,J.useEffect)(()=>{let e=yI(s);n.broadcastEvent(`theme.changed`,e)},[s,n]);let u=(0,J.useRef)(n);u.current=n,(0,J.useEffect)(()=>()=>{u.current.dispose(),t.current=null},[]);let d=(0,J.useMemo)(()=>({router:n,extensions:o,loading:a}),[n,o,a]);return(0,Z.jsx)(CI.Provider,{value:d,children:e})}function TI(){let e=(0,J.useContext)(CI);if(!e)throw Error(`useExtensionRouter must be used within ExtensionProvider`);return e.router}function EI(){let e=(0,J.useContext)(CI);if(!e)throw Error(`useExtensions must be used within ExtensionProvider`);return e.extensions}function DI(e){return e.active||e.activationEligible===!0}function OI(e){let t=e.ui?.contributions;return t?Array.isArray(t.pages)&&t.pages.length>0||Array.isArray(t.settingsPanels)&&t.settingsPanels.length>0||Array.isArray(t.chatWidgets)&&t.chatWidgets.length>0||Array.isArray(t.sidebarPanels)&&t.sidebarPanels.length>0:!1}function kI(e){return e.source===`bundled`&&e.hasUi===!0&&OI(e)}function AI(e){return MI(e)||kI(e)}function jI(e){return e.kind===`image-generation`||e.kind===`media-provider`}function MI(e){return DI(e)?e.hasConfigSchema||jI(e)?!0:e.hasUi?OI(e):!1:!1}function NI(){let e=(0,Y.c)(2),t=EI(),n;return e[0]===t?n=e[1]:(n=t.filter(MI),e[0]=t,e[1]=n),n}function PI(){let e=(0,J.useContext)(CI);if(!e)throw Error(`useExtensionsLoading must be used within ExtensionProvider`);return e.loading}function FI(e,t){return t.path.startsWith(`/apps/`)?t.path:`/apps/${e}/${t.id.startsWith(`${e}.`)?t.id.slice(e.length+1):t.id}`}function II(e){return wO[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]}var LI=[{id:`builtin:agents`,to:`/agents`,Icon:YE},{id:`builtin:skills`,to:`/skills`,Icon:hg},{id:`builtin:cron`,to:`/cron`,Icon:Zl},{id:`builtin:channels`,to:`/channels`,Icon:bv}];function RI(e,t){let n=new Map;for(let t of e)n.set(t.id,t);let r=[],i=new Set;for(let e of t){let t=n.get(e);!t||i.has(e)||(r.push(t),i.add(e))}for(let t of e)i.has(t.id)||(r.push(t),i.add(t.id));return r.length<=5?{visible:r,overflow:[],hasOverflow:!1}:{visible:r.slice(0,4),overflow:r.slice(4),hasOverflow:!0}}var zI=`text/plain`,BI=`xopc-nav:`;function VI(e){return`${BI}${e}`}function HI(e){return e.startsWith(BI)?e.slice(9):null}function UI(e){let t=e.currentTarget.getBoundingClientRect();return e.clientY<t.top+t.height/2?`before`:`after`}function WI({isActive:e},t,n,r){return X(`group relative flex w-full items-center text-sm font-medium leading-6 transition-colors duration-200 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,t?`justify-center rounded-xl p-2.5`:`gap-2 rounded-lg px-3 py-2 text-left`,e?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`,n&&`opacity-40`,r===`before`&&`shadow-[inset_0_2px_0_0_var(--color-accent)]`,r===`after`&&`shadow-[inset_0_-2px_0_0_var(--color-accent)]`)}function GI({isActive:e},t,n){return X(`group relative flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm font-medium leading-5 transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,e?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`,t&&`opacity-40`,n===`before`&&`shadow-[inset_0_2px_0_0_var(--color-accent)]`,n===`after`&&`shadow-[inset_0_-2px_0_0_var(--color-accent)]`)}function KI(e){let t=(0,Y.c)(11),{item:n,collapsed:r}=e,{Icon:i,letter:a}=n;if(i){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=X(`size-4`,`shrink-0 opacity-90`),t[0]=e):e=t[0];let n;return t[1]===i?n=t[2]:(n=(0,Z.jsx)(i,{className:e,strokeWidth:1.75,"aria-hidden":!0}),t[1]=i,t[2]=n),n}let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=X(`size-4`,`flex shrink-0 items-center justify-center text-[10px] font-bold opacity-70`),t[3]=o):o=t[3];let s;t[4]!==n.label||t[5]!==a?(s=a??n.label.charAt(0),t[4]=n.label,t[5]=a,t[6]=s):s=t[6];let c;t[7]===s?c=t[8]:(c=s.toUpperCase(),t[7]=s,t[8]=c);let l;return t[9]===c?l=t[10]:(l=(0,Z.jsx)(`span`,{className:o,"aria-hidden":!0,children:c}),t[9]=c,t[10]=l),l}function qI(e){let t=[];for(let n of e){if(n.activationEligible===!1)continue;let e=n.ui?.contributions?.pages;if(e)for(let r of e){if(!r.showInNav)continue;let e=r.navIcon?II(r.navIcon):void 0;t.push({id:`ext:${n.id}:${r.id}`,kind:`extension`,label:r.title,to:FI(n.id,r),Icon:e,letter:r.title.charAt(0),title:r.title})}}return t}function JI(e){let t=(0,Y.c)(52),{collapsed:n,onNavigate:r}=e,i=n===void 0?!1:n,a=d($I),o;t[0]===a?o=t[1]:(o=m(a),t[0]=a,t[1]=o);let s=o,c=NI(),l=mI(QI),u=mI(ZI),f=mI(XI),[p,h]=(0,J.useState)(null),[g,_]=(0,J.useState)(null),[v,y]=(0,J.useState)(!1),[b,x]=(0,J.useState)(!1),S;if(t[2]!==s.nav||t[3]!==c){let e;t[5]===s.nav?e=t[6]:(e=e=>{let t=e.id.slice(8);return{id:e.id,kind:`builtin`,label:s.nav[t],to:e.to,Icon:e.Icon}},t[5]=s.nav,t[6]=e);let n=LI.map(e),r=qI(c);S=[...n,...r],t[2]=s.nav,t[3]=c,t[4]=S}else S=t[4];let C=S,w;t[7]!==C||t[8]!==l?(w=RI(C,l),t[7]=C,t[8]=l,t[9]=w):w=t[9];let T=w,E;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(E=e=>t=>{t.dataTransfer.setData(zI,VI(e)),t.dataTransfer.effectAllowed=`move`,h(e)},t[10]=E):E=t[10];let D=E,O;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(O=()=>{h(null),_(null),y(!1)},t[11]=O):O=t[11];let k=O,A;t[12]!==p||t[13]!==g?(A=e=>t=>{if(!p)return;t.preventDefault(),t.dataTransfer.dropEffect=`move`;let n=UI(t);g?.id===e&&g.position===n||_({id:e,position:n})},t[12]=p,t[13]=g,t[14]=A):A=t[14];let j=A,M;t[15]===u?M=t[16]:(M=e=>t=>{t.preventDefault();let n=HI(t.dataTransfer.getData(zI));if(!n||n===e){k();return}u(n,e,UI(t)),k()},t[15]=u,t[16]=M);let N=M,P;t[17]===p?P=t[18]:(P=e=>{p&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,y(!0))},t[17]=p,t[18]=P);let F=P,I;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>y(!1),t[19]=I):I=t[19];let L=I,R;t[20]===f?R=t[21]:(R=e=>{e.preventDefault();let t=HI(e.dataTransfer.getData(zI));t&&f(t),k()},t[20]=f,t[21]=R);let z=R,B;t[22]!==i||t[23]!==p||t[24]!==g||t[25]!==r||t[26]!==j||t[27]!==N?(B=function(e){let t=p===e.id,n=g?.id===e.id?g.position:null;return(0,Z.jsxs)(Ma,{to:e.to,draggable:!0,onDragStart:D(e.id),onDragEnd:k,onDragOver:j(e.id),onDrop:N(e.id),className:e=>WI(e,i,t,n),title:e.title??e.label,onClick:()=>r?.(),children:[(0,Z.jsx)(KI,{item:e,collapsed:i}),i?null:(0,Z.jsx)(`span`,{className:`truncate`,children:e.label})]},e.id)},t[22]=i,t[23]=p,t[24]=g,t[25]=r,t[26]=j,t[27]=N,t[28]=B):B=t[28];let V=B,H;t[29]!==i||t[30]!==p||t[31]!==g||t[32]!==s.sidebar.moreApps||t[33]!==s.sidebar.moreAppsAria||t[34]!==v||t[35]!==F||t[36]!==z||t[37]!==r||t[38]!==j||t[39]!==N||t[40]!==b||t[41]!==T.overflow?(H=function(){return(0,Z.jsxs)(gF,{open:b,onOpenChange:x,children:[(0,Z.jsx)(vF,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,onDragOver:F,onDragLeave:L,onDrop:z,className:X(`flex w-full items-center text-sm font-medium leading-6 transition-colors duration-200 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i?`justify-center rounded-xl p-2.5`:`gap-2 rounded-lg px-3 py-2 text-left`,b?`bg-surface-hover text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`,v&&`ring-2 ring-accent ring-offset-2 ring-offset-surface-base`),"aria-label":s.sidebar.moreAppsAria,title:s.sidebar.moreApps,children:[(0,Z.jsx)(ud,{className:`size-4 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),i?null:(0,Z.jsx)(`span`,{className:`truncate`,children:s.sidebar.moreApps})]})}),(0,Z.jsx)(yF,{children:(0,Z.jsx)(bF,{side:`right`,align:`start`,sideOffset:8,collisionPadding:8,className:X(`z-50 min-w-[14rem] max-w-[20rem] rounded-lg border border-edge bg-surface-panel p-1 shadow-md`),onOpenAutoFocus:YI,children:(0,Z.jsx)(`ul`,{className:`flex flex-col gap-0.5`,role:`list`,"aria-label":s.sidebar.moreAppsAria,children:T.overflow.map(e=>{let t=p===e.id,n=g?.id===e.id?g.position:null;return(0,Z.jsx)(`li`,{className:`contents`,children:(0,Z.jsxs)(Ma,{to:e.to,draggable:!0,onDragStart:D(e.id),onDragEnd:k,onDragOver:j(e.id),onDrop:N(e.id),className:e=>GI(e,t,n),title:e.title??e.label,onClick:()=>{x(!1),r?.()},children:[(0,Z.jsx)(KI,{item:e}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.label})]})},e.id)})})})})]})},t[29]=i,t[30]=p,t[31]=g,t[32]=s.sidebar.moreApps,t[33]=s.sidebar.moreAppsAria,t[34]=v,t[35]=F,t[36]=z,t[37]=r,t[38]=j,t[39]=N,t[40]=b,t[41]=T.overflow,t[42]=H):H=t[42];let U=H,W;t[43]!==T.visible||t[44]!==V?(W=T.visible.map(V),t[43]=T.visible,t[44]=V,t[45]=W):W=t[45];let G;t[46]!==T.hasOverflow||t[47]!==U?(G=T.hasOverflow?U():null,t[46]=T.hasOverflow,t[47]=U,t[48]=G):G=t[48];let ee;return t[49]!==W||t[50]!==G?(ee=(0,Z.jsxs)(Z.Fragment,{children:[W,G]}),t[49]=W,t[50]=G,t[51]=ee):ee=t[51],ee}function YI(e){return e.preventDefault()}function XI(e){return e.moveToEnd}function ZI(e){return e.move}function QI(e){return e.order}function $I(e){return e.language}var eL={feishu:`/channel-icons/feishu.svg`,lark:`/channel-icons/lark.svg`};function tL(e){let t=(0,Y.c)(9),{sourceChannel:n,className:r}=e,i=eL[n.toLowerCase()];if(i){let e;t[0]===r?e=t[1]:(e=X(`shrink-0`,r),t[0]=r,t[1]=e);let n;return t[2]!==i||t[3]!==e?(n=(0,Z.jsx)(`img`,{src:i,alt:``,draggable:!1,className:e,"aria-hidden":!0}),t[2]=i,t[3]=e,t[4]=n):n=t[4],n}let a;t[5]===r?a=t[6]:(a=X(`shrink-0`,r),t[5]=r,t[6]=a);let o;return t[7]===a?o=t[8]:(o=(0,Z.jsx)(lh,{className:a,strokeWidth:1.75,"aria-hidden":!0}),t[7]=a,t[8]=o),o}var nL=`inline-flex items-center gap-px rounded-pill border border-edge bg-surface-hover p-1 dark:border-edge`,rL=`inline-flex shrink-0 items-center justify-center rounded-pill text-xs font-medium leading-none transition-[color,background-color,box-shadow] duration-150 ease-out text-fg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel active:scale-100`,iL=`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,aL=1;function oL(e,t){let n=0,r=0,i=e;for(;i&&i!==t;)n+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;return i===t?{x:n,y:r}:null}var sL=`pointer-events-none absolute left-0 top-0 z-[1] rounded-pill bg-surface-panel shadow-sm will-change-transform [backface-visibility:hidden] dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,cL=`relative z-[2] box-border flex h-6 min-h-0 min-w-0 flex-1 cursor-pointer items-center justify-center gap-1 rounded-pill border-0 bg-transparent px-2 py-0 text-center text-xs font-medium leading-none outline-none transition-[color,background-color,box-shadow] duration-150 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel active:scale-100 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50`;function lL({value:e,onChange:t,options:n,"aria-label":r,className:i,buttonClassName:a}){let o=(0,J.useRef)(null),s=(0,J.useRef)([]),[c,l]=(0,J.useState)({x:0,y:0,w:0,h:0}),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(!1),m=(0,J.useCallback)(()=>{let t=o.current;if(!t)return;let r=n.findIndex(t=>t.value===e);if(r<0)return;let i=s.current[r];if(!i)return;let a=aL,c=t.getBoundingClientRect(),u=i.getBoundingClientRect(),f=oL(i,t),p,m;if(f)p=f.x,m=f.y;else{let e=getComputedStyle(t),n=parseFloat(e.borderLeftWidth)||0,r=parseFloat(e.borderTopWidth)||0;p=u.left-c.left-n,m=u.top-c.top-r}l({x:p+a,y:m+a,w:Math.max(0,u.width-a*2),h:Math.max(0,u.height-a*2)}),d(!0)},[n,e]),h=(0,J.useRef)(m);return h.current=m,(0,J.useLayoutEffect)(()=>{let e=requestAnimationFrame(()=>m());return()=>cancelAnimationFrame(e)},[m]),(0,J.useEffect)(()=>{let e=requestAnimationFrame(()=>{requestAnimationFrame(()=>p(!0))});return()=>cancelAnimationFrame(e)},[]),(0,J.useEffect)(()=>{let e=o.current;if(!e)return;let t=()=>{requestAnimationFrame(()=>h.current())},n=new ResizeObserver(t);return n.observe(e),window.addEventListener(`resize`,t),()=>{n.disconnect(),window.removeEventListener(`resize`,t)}},[]),(0,Z.jsxs)(`div`,{ref:o,className:X(nL,`relative isolate flex w-full max-w-full flex-row items-center`,i),role:`group`,"aria-label":r,children:[(0,Z.jsx)(`div`,{"aria-hidden":!0,className:X(sL,`motion-reduce:!transition-none motion-reduce:!duration-0`,f&&`transition-[transform,width,height] duration-300 [transition-timing-function:cubic-bezier(0.32,0.72,0,1)]`),style:{width:c.w,height:c.h,transform:`translate3d(${c.x}px, ${c.y}px, 0)`,opacity:u&&c.w>0?1:0}}),n.map((n,r)=>{let i=n.icon,o=e===n.value;return(0,Z.jsxs)(`button`,{ref:e=>{s.current[r]=e},type:`button`,"aria-pressed":o,title:n.title??n.label,onClick:()=>t(n.value),className:X(cL,o?`text-fg`:`text-fg-subtle`,a),children:[i?(0,Z.jsx)(i,{className:`block size-3 shrink-0 opacity-80`,strokeWidth:1.75,"aria-hidden":!0}):null,(0,Z.jsx)(`span`,{className:`min-w-0 shrink truncate leading-none`,children:n.label})]},n.value)})]})}function uL(){return _(`/api/config`)}var dL=null;async function fL(){return dL||(dL=we(uL()).finally(()=>{dL=null}),dL)}function pL(e){let t=(0,Y.c)(6),n;t[0]===e?n=t[1]:(n=e?uL():null,t[0]=e,t[1]=n);let r=n,i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i={revalidateOnFocus:!1},t[2]=i):i=t[2];let a=v(r,fL,i),o,s;return t[3]===e?(o=t[4],s=t[5]):(o=()=>{if(!e)return;let t=uL(),n=()=>{b(t)};return window.addEventListener(`config-reload`,n),()=>window.removeEventListener(`config-reload`,n)},s=[e],t[3]=e,t[4]=o,t[5]=s),(0,J.useEffect)(o,s),a}function mL(){return b(uL())}var hL=null;async function gL(){return hL||(hL=_L().finally(()=>{hL=null}),hL)}async function _L(){let e=await Ee(_(`/api/agents`));if(e.ok){let t=await e.json();if(t.ok&&t.payload?.defaultId&&Array.isArray(t.payload.agents)){let e=t.payload.defaultId.trim().toLowerCase(),n=t.payload.agents.filter(e=>!!(e&&typeof e.id==`string`&&e.id.trim())).map(e=>({id:e.id.trim().toLowerCase(),name:typeof e.name==`string`&&e.name.trim()?e.name.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,...typeof e.avatar==`string`&&e.avatar.trim()?{avatar:e.avatar.trim()}:{}}));if(n.length>0)return{defaultId:e,items:n}}}let t=(await fL()).payload?.config?.agents,n=(t?.defaultId??`main`).trim().toLowerCase(),r=(Array.isArray(t?.list)?t.list:[]).filter(e=>!!(e&&typeof e.id==`string`&&e.id.trim())).map(e=>({id:e.id.trim().toLowerCase(),name:typeof e.name==`string`&&e.name.trim()?e.name.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,...typeof e.avatar==`string`&&e.avatar.trim()?{avatar:e.avatar.trim()}:{}}));return r.length===0?{defaultId:n,items:[{id:n}]}:{defaultId:n,items:r}}function vL(e){return typeof e==`object`&&!!e&&`role`in e}function yL(e){if(!e||typeof e!=`object`)return!1;let t=e.type;return t===`tool_use`||t===`tool_call`||t===`toolCall`}function bL(e){return typeof e==`object`&&!!e}function xL(e){return typeof e.id==`string`&&e.id.length>0?e.id:crypto.randomUUID()}function SL(e){if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}}function CL(e){return SL(e.args??e.arguments??e.input??e.function?.arguments)??{}}function wL(e){if(typeof e==`string`){let t=Date.parse(e);return Number.isNaN(t)?Date.now():t}return Date.now()}var TL=3e5;function EL(e,t){let n=e.replace(/\\/g,`/`),r=encodeURIComponent(n),i=n.startsWith(`tts/`)?`/api/workspace/tts-file?rel=${r}`:`/api/workspace/inbound-file?rel=${r}`,a=t?.sessionKey?.trim();return a?`${i}&sessionKey=${encodeURIComponent(a)}`:i}function DL(e){if(typeof e.content==`string`&&e.content.length>0)return e.content;if(typeof e.data==`string`&&e.data.length>0)return e.data}var OL=[`.txt`,`.md`,`.json`,`.xml`,`.html`,`.css`,`.js`,`.ts`,`.jsx`,`.tsx`,`.yml`,`.yaml`];function kL(e){let t=e.mimeType?.toLowerCase()??``;if(t.startsWith(`text/`)||t===`application/json`||t===`application/xml`||t===`application/javascript`||t===`application/typescript`)return!0;let n=e.name?.toLowerCase()??``;return OL.some(e=>n.endsWith(e))}function AL(e){if(e.extractedText!=null&&e.extractedText!==``)return e.extractedText;if(!kL(e))return;let t=DL(e);if(t)try{let e=NL(t);return new TextDecoder(`utf-8`,{fatal:!1}).decode(new Uint8Array(e))}catch{return}}function jL(e,t){let n=t.trim();if(n.startsWith(`data:`))return n;let r=n.replace(/\s/g,``);return`data:${e&&typeof e==`string`&&e.includes(`/`)?e:`application/octet-stream`};base64,${r}`}function ML(e){let t=new Uint8Array(e),n=``,r=32768;for(let e=0;e<t.length;e+=r){let i=t.subarray(e,e+r);n+=String.fromCharCode(...i)}return btoa(n)}function NL(e){if(e==null||e===``)throw Error(`Missing file data`);let t=e;if(e.startsWith(`data:`)){let n=e.match(/base64,(.+)/);n&&(t=n[1])}let n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r.buffer}function PL(e){let t=[`B`,`KB`,`MB`,`GB`],n=0,r=e;for(;r>=1024&&n<t.length-1;)r/=1024,n++;return`${r.toFixed(1)} ${t[n]}`}function FL(e){let t=(e.mimeType??``).toLowerCase(),n=t.split(`;`)[0]?.trim()??``,r=e.name?.toLowerCase()??``;return e.type===`image`||n.startsWith(`image/`)?`image`:n===`application/pdf`||t.includes(`application/pdf`)||r.endsWith(`.pdf`)?`pdf`:n===`application/vnd.openxmlformats-officedocument.wordprocessingml.document`||t.includes(`wordprocessingml`)||r.endsWith(`.docx`)?`docx`:n===`application/vnd.openxmlformats-officedocument.presentationml.presentation`||t.includes(`presentationml`)||r.endsWith(`.pptx`)?`pptx`:[`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,`application/vnd.ms-excel`].includes(n)||t.includes(`spreadsheetml`)||t.includes(`ms-excel`)||r.endsWith(`.xlsx`)||r.endsWith(`.xls`)?`excel`:[`.jpg`,`.jpeg`,`.png`,`.gif`,`.webp`,`.bmp`,`.svg`].some(e=>r.endsWith(e))?`image`:`text`}function IL(e){let t=e.toLowerCase();for(let[e,n]of[[`.pdf`,`application/pdf`],[`.docx`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`],[`.pptx`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`],[`.xlsx`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`],[`.xls`,`application/vnd.ms-excel`],[`.png`,`image/png`],[`.jpg`,`image/jpeg`],[`.jpeg`,`image/jpeg`],[`.gif`,`image/gif`],[`.webp`,`image/webp`],[`.bmp`,`image/bmp`],[`.svg`,`image/svg+xml`],[`.svgz`,`image/svg+xml`],[`.ico`,`image/x-icon`],[`.tif`,`image/tiff`],[`.tiff`,`image/tiff`],[`.avif`,`image/avif`],[`.jxl`,`image/jxl`]])if(t.endsWith(e))return n}function LL(e,t){return(t?.startsWith(`text/`)??!1)||OL.some(t=>e.toLowerCase().endsWith(t))}function RL(e){if(Array.isArray(e))return e.map(e=>zL(e))}function zL(e){if(!e||typeof e!=`object`)return{name:`file`,mimeType:`application/octet-stream`};let t=e,n=typeof t.data==`string`?t.data:void 0,r=typeof t.content==`string`&&t.content.length>0?t.content:n,i=typeof t.name==`string`&&t.name.length>0?t.name:`file`,a=typeof t.mimeType==`string`&&t.mimeType.length>0?t.mimeType:``;!a&&typeof t.type==`string`&&t.type.includes(`/`)&&(a=t.type),a||=`application/octet-stream`;let o=a.split(`;`)[0]?.trim().toLowerCase()??``;if(o===`application/octet-stream`||o===``){let e=IL(i);e&&(a=e)}let s=typeof t.preview==`string`&&t.preview.length>0?t.preview:a.startsWith(`image/`)&&r?r:void 0,c=typeof t.durationSeconds==`number`&&Number.isFinite(t.durationSeconds)&&t.durationSeconds>0?t.durationSeconds:void 0;return{id:typeof t.id==`string`?t.id:void 0,name:i,mimeType:a,type:typeof t.type==`string`?t.type:void 0,size:typeof t.size==`number`?t.size:void 0,content:r,data:n??r,preview:s,extractedText:typeof t.extractedText==`string`?t.extractedText:void 0,workspaceRelativePath:typeof t.workspaceRelativePath==`string`&&t.workspaceRelativePath.length>0?t.workspaceRelativePath:void 0,durationSeconds:c}}function BL(e){let t=e.match(/^([^(]+?)\s*\(/),n=t?t[1].trim():`file`,r=e.match(/\(\s*([^,]+)\s*,\s*(\d+)\s*bytes\s*\)/i);return{name:n,mimeType:r?r[1].trim():`application/octet-stream`,size:r?parseInt(r[2],10):0}}function VL(e){let t=[];if(typeof e==`string`)t.push(e);else if(Array.isArray(e)){for(let n of e)if(n&&typeof n==`object`&&n.type===`text`){let e=n.text;typeof e==`string`&&t.push(e)}}let n=t.join(`
9
+ `);let c=r.split(CF);r=c.pop()??``;for(let e of c)e.length&&o(e);return e()},a=await e();if(a)return a}finally{t.releaseLock()}return i??{ok:!1,error:`no-result`,message:`Update stream ended without a result`,status:0}}var PF=`xopc.updateReminder.dismissed`,FF=typeof window<`u`&&window.electronAPI?.updater!==void 0,IF=`xopc:electron-update-recheck`;function LF(){if(typeof window>`u`)return{};try{let e=localStorage.getItem(PF);if(!e)return{};let t=JSON.parse(e);return t&&typeof t==`object`?t:{}}catch{return{}}}var RF=160;function zF(e){let t=e.trim();return t.length<=RF?t:`${t.slice(0,RF-1)}…`}function BF(){let{npm:e,electron:t,isElectron:n,electronQuitAndInstall:r,runNpmUpdate:i,npmUpdateRunning:a}=AF(),[o,s]=(0,J.useState)(LF),[c,l]=(0,J.useState)({downloading:!1,electronError:!1}),[u,d]=(0,J.useState)(()=>{if(typeof window>`u`||FF)return null;try{let e=sessionStorage.getItem(TF);if(!e)return null;let t=JSON.parse(e);return(typeof t.installedVersion==`string`?t.installedVersion.trim():``)||null}catch{return null}}),f=(0,J.useRef)(t?.state);f.current!==t?.state&&(f.current=t?.state,t?.state!==`downloading`&&c.downloading&&l(e=>({...e,downloading:!1})),t?.state!==`error`&&c.electronError&&l(e=>({...e,electronError:!1})));let p=(0,J.useRef)(null);if(u&&e?.currentVersion===u&&p.current!==u){p.current=u;try{sessionStorage.removeItem(TF)}catch{}d(null)}(0,J.useEffect)(()=>{if(n)return;let e=()=>{try{let e=sessionStorage.getItem(TF);if(!e){d(null);return}let t=JSON.parse(e);d((typeof t.installedVersion==`string`?t.installedVersion.trim():``)||null)}catch{d(null)}};return e(),window.addEventListener(`xopc:npm-update-installed`,e),()=>window.removeEventListener(`xopc:npm-update-installed`,e)},[n]),(0,J.useEffect)(()=>{let e=()=>{l(e=>({...e,downloading:!1})),s(e=>{let t={...e};delete t.electronReady;try{localStorage.setItem(PF,JSON.stringify(t))}catch{}return t})};return window.addEventListener(IF,e),()=>window.removeEventListener(IF,e)},[]),(0,J.useEffect)(()=>{let e=e=>{let t=e.detail?.version?.trim();t&&s(e=>{let n={...e,npm:t};try{localStorage.setItem(PF,JSON.stringify(n))}catch{}return n})};return window.addEventListener(`xopc:npm-update-installed`,e),()=>window.removeEventListener(`xopc:npm-update-installed`,e)},[]);let m=(0,J.useMemo)(()=>n&&t?.state===`downloaded`&&t.version?o.electronReady===t.version?{kind:`none`}:{kind:`electron-ready`,version:t.version}:n&&t?.state===`downloading`&&!c.downloading?{kind:`electron-downloading`,percent:Math.round(t.percent??0)}:n&&t?.state===`error`&&t.message&&!c.electronError?{kind:`electron-error`,message:zF(t.message)}:!n&&u&&e&&e.currentVersion!==u?{kind:`npm-restart-required`,version:u}:!n&&e?.updateAvailable&&e.latestVersion?o.npm===e.latestVersion?{kind:`none`}:{kind:`npm`,version:e.latestVersion,channel:e.channel}:{kind:`none`},[o.npm,o.electronReady,t,c.downloading,c.electronError,n,e,u]);return{show:m,dismiss:(0,J.useCallback)(()=>{if(m.kind===`electron-downloading`){l(e=>({...e,downloading:!0}));return}if(m.kind===`electron-error`){l(e=>({...e,electronError:!0}));return}if(m.kind===`npm-restart-required`){try{sessionStorage.removeItem(TF)}catch{}d(null);return}if(m.kind===`none`)return;let e={...o};m.kind===`npm`?e.npm=m.version:m.kind===`electron-ready`&&(e.electronReady=m.version);try{localStorage.setItem(PF,JSON.stringify(e))}catch{}s(e)},[o,m]),electronQuitAndInstall:r,runNpmUpdate:i,npmUpdateRunning:a}}var VF={version:`0.0.86`,commit:`9d2865df2b665f6d19bea4cef67aab617df4df3d`,buildTimeIso:`2026-06-03T17:25:23.402Z`};function HF(){return function(e,t){switch(t.type){case`start`:return e.loading?e:{...e,loading:!0,error:null};case`success`:return{data:t.data,loading:!1,error:null};case`error`:return{data:t.data,loading:!1,error:t.error};case`patch`:return{...e,data:t.updater(e.data)}}}}function UF(e,t,n){let{enabled:r=!0,initial:i,errorData:a}=n,[o,s]=(0,J.useReducer)(HF(),void 0,()=>({data:i,loading:!1,error:null})),c=(0,J.useRef)(e);c.current=e;let l=(0,J.useRef)(a);l.current=a;let u=(0,J.useRef)(i);u.current=i,(0,J.useEffect)(()=>{if(!r)return;let e=!1;return s({type:`start`}),c.current().then(t=>{e||s({type:`success`,data:t})}).catch(t=>{if(e)return;let n=l.current;s({type:`error`,data:typeof n==`function`?n(t):n===void 0?u.current:n,error:t})}),()=>{e=!0}},[r,...t]);let d=(0,J.useCallback)(e=>{s({type:`patch`,updater:typeof e==`function`?e:()=>e})},[]);return{...o,setData:d}}var WF=`https://github.com/xopcai/xopc`,GF=new Intl.DateTimeFormat(`zh-CN`,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}),KF=new Intl.DateTimeFormat(`en-US`,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1});function qF(e,t){let n=new Date(e);if(Number.isNaN(n.getTime()))return e;try{return(t===`zh`?GF:KF).format(n)}catch{return n.toISOString()}}function JF({open:e,onOpenChange:t}){let n=d(e=>e.language),r=m(n),i=r.aboutDialog,a=r.updatePanel,{isElectron:o,electron:s,electronCheck:c,checkNow:l,npm:u,runNpmUpdate:f,npmUpdateRunning:p}=AF(),[h,g]=(0,J.useState)(!1),[v,y]=(0,J.useState)(!1),[b,x]=(0,J.useState)(!1),{data:S}=UF(async()=>{let e=await we(_(`/health`));return typeof e.version==`string`?e.version:null},[e],{enabled:e,initial:null,errorData:null}),C=(0,J.useCallback)(e=>{e||(g(!1),y(!1),x(!1)),t(e)},[t]),w=(0,J.useCallback)(async()=>{let e=m(n).updatePanel,t=await f();if(t.ok){window.dispatchEvent(new CustomEvent(`extension-notification`,{detail:{type:`success`,title:e.updateSuccess,message:e.updateSuccessDetail}}));return}let r=t.error===`git-checkout`?e.updateErrorGit:t.error===`busy`?e.updateErrorBusy:e.updateErrorFailed;window.dispatchEvent(new CustomEvent(`extension-notification`,{detail:{type:`error`,title:r,message:t.message}}))},[f,n]),T=VF.commit,E=n===`zh`?`zh-CN`:`en-US`,D=qF(VF.buildTimeIso,E),O=new Date().getFullYear(),k=i.copyright.replace(`{year}`,String(O));return(0,Z.jsx)(q,{open:e,onOpenChange:C,children:(0,Z.jsxs)(G,{children:[(0,Z.jsx)(ie,{className:`xopc-dialog-overlay fixed inset-0 z-[200] bg-scrim`}),(0,Z.jsxs)(se,{className:X(`xopc-dialog-content fixed left-1/2 top-1/2 z-[201] w-[min(100%-2rem,26rem)] -translate-x-1/2 -translate-y-1/2`,`rounded-2xl border border-edge bg-surface-panel shadow-popover dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-4 pt-3`,"aria-hidden":!0,children:[(0,Z.jsx)(`span`,{className:`size-3 rounded-full bg-[#ff5f57]`}),(0,Z.jsx)(`span`,{className:`size-3 rounded-full bg-[#febc2e]`}),(0,Z.jsx)(`span`,{className:`size-3 rounded-full bg-[#28c840]`})]}),(0,Z.jsxs)(`div`,{className:`px-6 pb-2 pt-1`,children:[(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(de,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":i.close,children:(0,Z.jsx)(oO,{className:`size-4`,strokeWidth:2})})})}),(0,Z.jsxs)(`div`,{className:`-mt-2 flex flex-col items-center text-center`,children:[(0,Z.jsx)(uA,{className:`size-[4.5rem]`,alt:r.appBrand}),(0,Z.jsx)(ue,{className:`mt-3 text-xl font-semibold tracking-tight text-fg`,children:r.appBrand}),(0,Z.jsx)(le,{className:`sr-only`,children:i.windowTitle})]}),(0,Z.jsxs)(`div`,{className:`mt-6 space-y-3 text-sm`,children:[(0,Z.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-center gap-x-3 gap-y-1`,children:[(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:i.versionLabel}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-2 sm:justify-start`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-[13px] text-fg tabular-nums`,children:VF.version}),(0,Z.jsx)(`button`,{type:`button`,className:X(`shrink-0 rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] font-medium text-fg-muted`,`transition-colors hover:bg-surface-hover hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),onClick:()=>{o?(window.dispatchEvent(new CustomEvent(IF)),g(!0),c()):(g(!0),x(!1),y(!0),(async()=>{let e=await l();y(!1),e||x(!0)})())},disabled:o&&[`checking`,`available`,`downloading`,`downloaded`].includes(s?.state??``)||!o&&(v||p),children:o&&s?.state===`checking`||!o&&v?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(Cg,{className:`size-3 animate-spin`}),i.checkUpdatesChecking]}):i.checkUpdates})]})]}),o&&h&&(0,Z.jsx)(YF,{state:s?.state,version:s?.version,percent:s?.percent,d:i}),!o&&h&&(0,Z.jsx)(XF,{checking:v,checkFailed:b,npm:u,npmUpdateRunning:p,onUpgrade:w,d:i,tp:a}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] gap-x-3 gap-y-1`,children:[(0,Z.jsx)(`span`,{className:`pt-0.5 text-fg-muted`,children:i.commitLabel}),(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] leading-snug text-fg`,children:T})]}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-baseline gap-x-3 gap-y-1`,children:[(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:i.buildDateLabel}),(0,Z.jsx)(`span`,{className:`text-right text-[13px] text-fg sm:text-left`,children:D})]}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-baseline gap-x-3 gap-y-1`,children:[(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:i.gatewayVersionLabel}),(0,Z.jsx)(`span`,{className:`text-right font-mono text-[13px] text-fg sm:text-left`,children:S??i.gatewayUnavailable})]}),(0,Z.jsx)(`p`,{className:`pt-0.5 text-[11px] text-fg-subtle`,children:i.consoleBuildHint})]}),(0,Z.jsxs)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 text-center text-[11px] leading-relaxed text-fg-muted`,children:[(0,Z.jsxs)(`p`,{children:[i.openSourceLead,(0,Z.jsx)(`a`,{className:`text-accent-fg underline decoration-accent-fg/40 underline-offset-2 hover:decoration-accent-fg`,href:WF,target:`_blank`,rel:`noopener noreferrer`,children:i.openSourceLink})]}),(0,Z.jsx)(`p`,{className:`mt-2`,children:k})]})]})]})]})})}function YF(e){let t=(0,Y.c)(29),{state:n,version:r,percent:i,d:a}=e;if(!n||n===`idle`)return null;if(n===`checking`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Cg,{className:`size-3.5 animate-spin`}),t[0]=e):e=t[0];let n;return t[1]===a.checkUpdatesChecking?n=t[2]:(n=(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,Z.jsx)(`span`,{children:a.checkUpdatesChecking})]}),t[1]=a.checkUpdatesChecking,t[2]=n),n}if(n===`not-available`){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(zl,{className:`size-3.5`}),t[3]=e):e=t[3];let n;return t[4]===a.checkUpdatesUpToDate?n=t[5]:(n=(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-green-600 dark:text-green-400`,children:[e,(0,Z.jsx)(`span`,{children:a.checkUpdatesUpToDate})]}),t[4]=a.checkUpdatesUpToDate,t[5]=n),n}if(n===`available`){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(xy,{className:`size-3.5`}),t[6]=e):e=t[6];let n;t[7]!==a.checkUpdatesAvailable||t[8]!==r?(n=a.checkUpdatesAvailable.replace(`{version}`,r??`?`),t[7]=a.checkUpdatesAvailable,t[8]=r,t[9]=n):n=t[9];let i;return t[10]===n?i=t[11]:(i=(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-accent-fg`,children:[e,(0,Z.jsx)(`span`,{children:n})]}),t[10]=n,t[11]=i),i}if(n===`downloading`){let e;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Uu,{className:`size-3.5 motion-safe:animate-[bounce_1s_ease-out_infinite]`}),t[12]=e):e=t[12];let n=a.checkUpdatesDownloading,r;if(t[13]!==a.checkUpdatesDownloading||t[14]!==i){let e;t[16]===i?e=t[17]:(e=Math.round(i??0),t[16]=i,t[17]=e),r=n.replace(`{percent}`,String(e)),t[13]=a.checkUpdatesDownloading,t[14]=i,t[15]=r}else r=t[15];let o;return t[18]===r?o=t[19]:(o=(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,Z.jsx)(`span`,{children:r})]}),t[18]=r,t[19]=o),o}if(n===`downloaded`){let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Uu,{className:`size-3.5`}),t[20]=e):e=t[20];let n;t[21]!==a.checkUpdatesDownloaded||t[22]!==r?(n=a.checkUpdatesDownloaded.replace(`{version}`,r??`?`),t[21]=a.checkUpdatesDownloaded,t[22]=r,t[23]=n):n=t[23];let i;return t[24]===n?i=t[25]:(i=(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] font-semibold text-accent-fg`,children:[e,(0,Z.jsx)(`span`,{children:n})]}),t[24]=n,t[25]=i),i}if(n===`error`){let e;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Rl,{className:`size-3.5`}),t[26]=e):e=t[26];let n;return t[27]===a.checkUpdatesError?n=t[28]:(n=(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-red-500 dark:text-red-400`,children:[e,(0,Z.jsx)(`span`,{children:a.checkUpdatesError})]}),t[27]=a.checkUpdatesError,t[28]=n),n}return null}function XF(e){let t=(0,Y.c)(25),{checking:n,checkFailed:r,npm:i,npmUpdateRunning:a,onUpgrade:o,d:s,tp:c}=e;if(n){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Cg,{className:`size-3.5 animate-spin`}),t[0]=e):e=t[0];let n;return t[1]===s.checkUpdatesChecking?n=t[2]:(n=(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,Z.jsx)(`span`,{children:s.checkUpdatesChecking})]}),t[1]=s.checkUpdatesChecking,t[2]=n),n}if(r){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Rl,{className:`size-3.5`}),t[3]=e):e=t[3];let n;return t[4]===s.checkUpdatesError?n=t[5]:(n=(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-red-500 dark:text-red-400`,children:[e,(0,Z.jsx)(`span`,{children:s.checkUpdatesError})]}),t[4]=s.checkUpdatesError,t[5]=n),n}if(a){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Cg,{className:`size-3.5 animate-spin`}),t[6]=e):e=t[6];let n;return t[7]===c.updateRunning?n=t[8]:(n=(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,Z.jsx)(`span`,{children:c.updateRunning})]}),t[7]=c.updateRunning,t[8]=n),n}if(i?.updateAvailable&&i.latestVersion){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(xy,{className:`mt-0.5 size-3.5 shrink-0`}),t[9]=e):e=t[9];let n;t[10]!==i.latestVersion||t[11]!==c.reminderNpm?(n=c.reminderNpm.replace(`{{version}}`,i.latestVersion),t[10]=i.latestVersion,t[11]=c.reminderNpm,t[12]=n):n=t[12];let r;t[13]===n?r=t[14]:(r=(0,Z.jsxs)(`p`,{className:`flex items-start gap-2 text-[12px] text-accent-fg`,children:[e,(0,Z.jsx)(`span`,{children:n})]}),t[13]=n,t[14]=r);let a;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(a=X(`w-full rounded-lg bg-accent px-3 py-1.5 text-center text-xs font-medium text-white`,`hover:bg-accent/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`),t[15]=a):a=t[15];let s;t[16]!==o||t[17]!==c.updateNow?(s=(0,Z.jsx)(`button`,{type:`button`,onClick:o,className:a,children:c.updateNow}),t[16]=o,t[17]=c.updateNow,t[18]=s):s=t[18];let l;return t[19]!==r||t[20]!==s?(l=(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[r,s]}),t[19]=r,t[20]=s,t[21]=l):l=t[21],l}let l;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(zl,{className:`size-3.5`}),t[22]=l):l=t[22];let u;return t[23]===s.checkUpdatesUpToDate?u=t[24]:(u=(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-green-600 dark:text-green-400`,children:[l,(0,Z.jsx)(`span`,{children:s.checkUpdatesUpToDate})]}),t[23]=s.checkUpdatesUpToDate,t[24]=u),u}var ZF=X(`flex w-full items-center gap-2.5 rounded-lg px-3 py-2.5 text-left text-sm font-medium leading-5 text-fg`,`transition-colors duration-150 ease-out`,`hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),QF=X(`rounded-xl border border-edge bg-surface-panel p-1 shadow-popover`,`dark:border-edge`);function $F(e){let t=(0,Y.c)(7),{selected:n,label:r,onSelect:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=X(`flex w-full items-center justify-between gap-2 rounded-lg px-3 py-2 text-left text-sm font-medium leading-5 text-fg`,`transition-colors duration-150 ease-out hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),t[0]=a):a=t[0];let o;t[1]===r?o=t[2]:(o=(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:r}),t[1]=r,t[2]=o);let s;return t[3]!==i||t[4]!==n||t[5]!==o?(s=(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":n,className:a,onClick:i,children:o}),t[3]=i,t[4]=n,t[5]=o,t[6]=s):s=t[6],s}function eI(e){let t=(0,Y.c)(181),{onOpenFullSettings:n,onAboutClick:r}=e,[i,a]=(0,J.useState)(null),o=d(oI),s=d(aI),c=ve(iI),l=ve(rI),u=RA(nI),f=RA(tI),p;t[0]===o?p=t[1]:(p=m(o),t[0]=o,t[1]=p);let h=p,g=h.appearanceSettings,_;t[2]===i?_=t[3]:(_=e=>X(`absolute left-full top-0 z-[60] min-w-[11rem] max-w-[min(calc(100vw-2rem),16rem)]`,`ml-2 sm:ml-2.5`,i===e?`block`:`hidden`),t[2]=i,t[3]=_);let v=_,y;t[4]===i?y=t[5]:(y=e=>X(`absolute left-full top-0 z-[55] h-full w-8 sm:w-9`,i===e?`pointer-events-auto`:`pointer-events-none`),t[4]=i,t[5]=y);let b=y,x;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>a(null),t[6]=x):x=t[6];let S;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>a(`lang`),t[7]=S):S=t[7];let C=i===`lang`&&`bg-surface-hover`,w;t[8]===C?w=t[9]:(w=X(ZF,C),t[8]=C,t[9]=w);let T=i===`lang`,E;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsx)(km,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[10]=E):E=t[10];let D;t[11]===g.languageTitle?D=t[12]:(D=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:g.languageTitle}),t[11]=g.languageTitle,t[12]=D);let O;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(Fl,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[13]=O):O=t[13];let k;t[14]!==D||t[15]!==w||t[16]!==T?(k=(0,Z.jsxs)(`button`,{type:`button`,className:w,"aria-haspopup":`menu`,"aria-expanded":T,children:[E,D,O]}),t[14]=D,t[15]=w,t[16]=T,t[17]=k):k=t[17];let A;t[18]===b?A=t[19]:(A=b(`lang`),t[18]=b,t[19]=A);let j;t[20]===A?j=t[21]:(j=(0,Z.jsx)(`div`,{className:A,"aria-hidden":!0}),t[20]=A,t[21]=j);let M;t[22]===v?M=t[23]:(M=v(`lang`),t[22]=v,t[23]=M);let N=o===`en`,P;t[24]===s?P=t[25]:(P=()=>s(`en`),t[24]=s,t[25]=P);let F;t[26]!==g.langOptionEn||t[27]!==N||t[28]!==P?(F=(0,Z.jsx)($F,{selected:N,label:g.langOptionEn,onSelect:P}),t[26]=g.langOptionEn,t[27]=N,t[28]=P,t[29]=F):F=t[29];let I=o===`zh`,L;t[30]===s?L=t[31]:(L=()=>s(`zh`),t[30]=s,t[31]=L);let R;t[32]!==g.langOptionZh||t[33]!==I||t[34]!==L?(R=(0,Z.jsx)($F,{selected:I,label:g.langOptionZh,onSelect:L}),t[32]=g.langOptionZh,t[33]=I,t[34]=L,t[35]=R):R=t[35];let z;t[36]!==F||t[37]!==R?(z=(0,Z.jsxs)(`div`,{className:QF,children:[F,R]}),t[36]=F,t[37]=R,t[38]=z):z=t[38];let B;t[39]!==g.languageTitle||t[40]!==M||t[41]!==z?(B=(0,Z.jsx)(`div`,{className:M,role:`menu`,"aria-label":g.languageTitle,children:z}),t[39]=g.languageTitle,t[40]=M,t[41]=z,t[42]=B):B=t[42];let V;t[43]!==k||t[44]!==j||t[45]!==B?(V=(0,Z.jsxs)(`div`,{className:`relative`,onMouseEnter:S,children:[k,j,B]}),t[43]=k,t[44]=j,t[45]=B,t[46]=V):V=t[46];let H;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>a(`theme`),t[47]=H):H=t[47];let U=i===`theme`&&`bg-surface-hover`,W;t[48]===U?W=t[49]:(W=X(ZF,U),t[48]=U,t[49]=W);let G=i===`theme`,ee;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,Z.jsx)(r_,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[50]=ee):ee=t[50];let K;t[51]===g.themeTitle?K=t[52]:(K=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:g.themeTitle}),t[51]=g.themeTitle,t[52]=K);let te;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,Z.jsx)(Fl,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[53]=te):te=t[53];let ne;t[54]!==W||t[55]!==G||t[56]!==K?(ne=(0,Z.jsxs)(`button`,{type:`button`,className:W,"aria-haspopup":`menu`,"aria-expanded":G,children:[ee,K,te]}),t[54]=W,t[55]=G,t[56]=K,t[57]=ne):ne=t[57];let re;t[58]===b?re=t[59]:(re=b(`theme`),t[58]=b,t[59]=re);let ie;t[60]===re?ie=t[61]:(ie=(0,Z.jsx)(`div`,{className:re,"aria-hidden":!0}),t[60]=re,t[61]=ie);let ae;t[62]===v?ae=t[63]:(ae=v(`theme`),t[62]=v,t[63]=ae);let oe=c===`light`,se;t[64]===l?se=t[65]:(se=()=>l(`light`),t[64]=l,t[65]=se);let q;t[66]!==g.themeOptionLight||t[67]!==oe||t[68]!==se?(q=(0,Z.jsx)($F,{selected:oe,label:g.themeOptionLight,onSelect:se}),t[66]=g.themeOptionLight,t[67]=oe,t[68]=se,t[69]=q):q=t[69];let ce=c===`dark`,le;t[70]===l?le=t[71]:(le=()=>l(`dark`),t[70]=l,t[71]=le);let ue;t[72]!==g.themeOptionDark||t[73]!==ce||t[74]!==le?(ue=(0,Z.jsx)($F,{selected:ce,label:g.themeOptionDark,onSelect:le}),t[72]=g.themeOptionDark,t[73]=ce,t[74]=le,t[75]=ue):ue=t[75];let de=c===`system`,fe;t[76]===l?fe=t[77]:(fe=()=>l(`system`),t[76]=l,t[77]=fe);let pe;t[78]!==g.themeOptionSystem||t[79]!==de||t[80]!==fe?(pe=(0,Z.jsx)($F,{selected:de,label:g.themeOptionSystem,onSelect:fe}),t[78]=g.themeOptionSystem,t[79]=de,t[80]=fe,t[81]=pe):pe=t[81];let me;t[82]!==q||t[83]!==ue||t[84]!==pe?(me=(0,Z.jsxs)(`div`,{className:QF,children:[q,ue,pe]}),t[82]=q,t[83]=ue,t[84]=pe,t[85]=me):me=t[85];let he;t[86]!==g.themeTitle||t[87]!==ae||t[88]!==me?(he=(0,Z.jsx)(`div`,{className:ae,role:`menu`,"aria-label":g.themeTitle,children:me}),t[86]=g.themeTitle,t[87]=ae,t[88]=me,t[89]=he):he=t[89];let ge;t[90]!==ne||t[91]!==ie||t[92]!==he?(ge=(0,Z.jsxs)(`div`,{className:`relative`,onMouseEnter:H,children:[ne,ie,he]}),t[90]=ne,t[91]=ie,t[92]=he,t[93]=ge):ge=t[93];let _e;t[94]===Symbol.for(`react.memo_cache_sentinel`)?(_e=()=>a(`font`),t[94]=_e):_e=t[94];let ye=i===`font`&&`bg-surface-hover`,be;t[95]===ye?be=t[96]:(be=X(ZF,ye),t[95]=ye,t[96]=be);let xe=i===`font`,Se;t[97]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,Z.jsx)(fE,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[97]=Se):Se=t[97];let Ce;t[98]===g.fontScaleTitle?Ce=t[99]:(Ce=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:g.fontScaleTitle}),t[98]=g.fontScaleTitle,t[99]=Ce);let we;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(we=(0,Z.jsx)(Fl,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[100]=we):we=t[100];let Te;t[101]!==be||t[102]!==xe||t[103]!==Ce?(Te=(0,Z.jsxs)(`button`,{type:`button`,className:be,"aria-haspopup":`menu`,"aria-expanded":xe,children:[Se,Ce,we]}),t[101]=be,t[102]=xe,t[103]=Ce,t[104]=Te):Te=t[104];let Ee;t[105]===b?Ee=t[106]:(Ee=b(`font`),t[105]=b,t[106]=Ee);let De;t[107]===Ee?De=t[108]:(De=(0,Z.jsx)(`div`,{className:Ee,"aria-hidden":!0}),t[107]=Ee,t[108]=De);let Oe;t[109]===v?Oe=t[110]:(Oe=v(`font`),t[109]=v,t[110]=Oe);let ke=u===`compact`,Ae;t[111]===f?Ae=t[112]:(Ae=()=>f(`compact`),t[111]=f,t[112]=Ae);let je;t[113]!==g.fontScaleCompact||t[114]!==ke||t[115]!==Ae?(je=(0,Z.jsx)($F,{selected:ke,label:g.fontScaleCompact,onSelect:Ae}),t[113]=g.fontScaleCompact,t[114]=ke,t[115]=Ae,t[116]=je):je=t[116];let Me=u===`default`,Ne;t[117]===f?Ne=t[118]:(Ne=()=>f(`default`),t[117]=f,t[118]=Ne);let Pe;t[119]!==g.fontScaleDefault||t[120]!==Me||t[121]!==Ne?(Pe=(0,Z.jsx)($F,{selected:Me,label:g.fontScaleDefault,onSelect:Ne}),t[119]=g.fontScaleDefault,t[120]=Me,t[121]=Ne,t[122]=Pe):Pe=t[122];let Fe=u===`large`,Ie;t[123]===f?Ie=t[124]:(Ie=()=>f(`large`),t[123]=f,t[124]=Ie);let Le;t[125]!==g.fontScaleLarge||t[126]!==Fe||t[127]!==Ie?(Le=(0,Z.jsx)($F,{selected:Fe,label:g.fontScaleLarge,onSelect:Ie}),t[125]=g.fontScaleLarge,t[126]=Fe,t[127]=Ie,t[128]=Le):Le=t[128];let Re;t[129]!==je||t[130]!==Pe||t[131]!==Le?(Re=(0,Z.jsxs)(`div`,{className:QF,children:[je,Pe,Le]}),t[129]=je,t[130]=Pe,t[131]=Le,t[132]=Re):Re=t[132];let ze;t[133]!==g.fontScaleTitle||t[134]!==Oe||t[135]!==Re?(ze=(0,Z.jsx)(`div`,{className:Oe,role:`menu`,"aria-label":g.fontScaleTitle,children:Re}),t[133]=g.fontScaleTitle,t[134]=Oe,t[135]=Re,t[136]=ze):ze=t[136];let Be;t[137]!==Te||t[138]!==De||t[139]!==ze?(Be=(0,Z.jsxs)(`div`,{className:`relative`,onMouseEnter:_e,children:[Te,De,ze]}),t[137]=Te,t[138]=De,t[139]=ze,t[140]=Be):Be=t[140];let Ve;t[141]===Symbol.for(`react.memo_cache_sentinel`)?(Ve=(0,Z.jsx)(`div`,{className:`my-2 h-px bg-edge-subtle`,role:`separator`}),t[141]=Ve):Ve=t[141];let He;t[142]===r?He=t[143]:(He=()=>r?.(),t[142]=r,t[143]=He);let Ue,We,Ge;t[144]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=()=>a(null),We=()=>a(null),Ge=(0,Z.jsx)(ug,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[144]=Ue,t[145]=We,t[146]=Ge):(Ue=t[144],We=t[145],Ge=t[146]);let Ke;t[147]===g.aboutApp?Ke=t[148]:(Ke=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:g.aboutApp}),t[147]=g.aboutApp,t[148]=Ke);let qe;t[149]!==He||t[150]!==Ke?(qe=(0,Z.jsxs)(`button`,{type:`button`,className:ZF,onClick:He,onMouseEnter:Ue,onFocus:We,children:[Ge,Ke]}),t[149]=He,t[150]=Ke,t[151]=qe):qe=t[151];let Je;t[152]===o?Je=t[153]:(Je=ej(o),t[152]=o,t[153]=Je);let Ye,Xe,Ze;t[154]===Symbol.for(`react.memo_cache_sentinel`)?(Ye=()=>a(null),Xe=()=>a(null),Ze=(0,Z.jsx)(El,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[154]=Ye,t[155]=Xe,t[156]=Ze):(Ye=t[154],Xe=t[155],Ze=t[156]);let Qe;t[157]===h.sidebar.helpDocs?Qe=t[158]:(Qe=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:h.sidebar.helpDocs}),t[157]=h.sidebar.helpDocs,t[158]=Qe);let $e;t[159]===Symbol.for(`react.memo_cache_sentinel`)?($e=(0,Z.jsx)(yd,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[159]=$e):$e=t[159];let et;t[160]!==Je||t[161]!==Qe?(et=(0,Z.jsxs)(`a`,{href:Je,target:`_blank`,rel:`noopener noreferrer`,className:ZF,onMouseEnter:Ye,onFocus:Xe,children:[Ze,Qe,$e]}),t[160]=Je,t[161]=Qe,t[162]=et):et=t[162];let tt,nt,rt;t[163]===Symbol.for(`react.memo_cache_sentinel`)?(tt=X(ZF,`text-accent-fg hover:bg-accent-soft hover:text-accent-fg`),nt=()=>a(null),rt=()=>a(null),t[163]=tt,t[164]=nt,t[165]=rt):(tt=t[163],nt=t[164],rt=t[165]);let it;t[166]===n?it=t[167]:(it=()=>n?.(),t[166]=n,t[167]=it);let at;t[168]===Symbol.for(`react.memo_cache_sentinel`)?(at=(0,Z.jsx)(Jb,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[168]=at):at=t[168];let ot;t[169]===g.openFullPreferences?ot=t[170]:(ot=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1`,children:g.openFullPreferences}),t[169]=g.openFullPreferences,t[170]=ot);let st;t[171]!==it||t[172]!==ot?(st=(0,Z.jsxs)(ja,{to:`/settings/overview`,className:tt,onMouseEnter:nt,onFocus:rt,onClick:it,children:[at,ot]}),t[171]=it,t[172]=ot,t[173]=st):st=t[173];let ct;return t[174]!==V||t[175]!==ge||t[176]!==Be||t[177]!==qe||t[178]!==et||t[179]!==st?(ct=(0,Z.jsxs)(`div`,{className:`w-[min(calc(100vw-2rem),15rem)] shrink-0 py-1`,onMouseLeave:x,children:[V,ge,Be,Ve,qe,et,st]}),t[174]=V,t[175]=ge,t[176]=Be,t[177]=qe,t[178]=et,t[179]=st,t[180]=ct):ct=t[180],ct}function tI(e){return e.setPreference}function nI(e){return e.preference}function rI(e){return e.setPreference}function iI(e){return e.preference}function aI(e){return e.setLanguage}function oI(e){return e.language}function sI({collapsed:e=!1,onNavigate:t}){let n=m(d(e=>e.language)),r=n.appearanceSettings,[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(!1);return(0,J.useEffect)(()=>{D(()=>import(`./settings-page-Bet1OerL.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15])),D(()=>import(`./sessions-page-FaG_Vlkb.js`),__vite__mapDeps([16,1,2,3,5,7,12,9])),D(()=>import(`./logs-page-sTsVWz0X.js`),__vite__mapDeps([17,1,2,3,7,9])),D(()=>import(`./cron-page-BMrloeFH.js`),__vite__mapDeps([18,1,2,3,19,4,7,10,8,9,13,5])),D(()=>import(`./skills-page-DhUO235y.js`),__vite__mapDeps([20,1,21,2,3,19,7,9]))},[]),(0,Z.jsxs)(`div`,{className:X(`flex shrink-0 flex-col`,e&&`mt-auto`,e?`items-center px-1 py-2`:`p-3`),children:[(0,Z.jsxs)(gF,{open:i,onOpenChange:a,children:[e?(0,Z.jsx)(vF,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:X(`flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-full outline-none ring-offset-surface-base transition-transform`,`hover:opacity-95 active:scale-95`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2`,i&&`ring-2 ring-accent`,`motion-reduce:opacity-100 motion-reduce:active:scale-100`),"aria-expanded":i,"aria-haspopup":`dialog`,title:n.sidebar.appMenuAria,"aria-label":n.sidebar.appMenuAria,children:(0,Z.jsx)(uA,{className:`size-full rounded-full`,alt:n.appBrand})})}):(0,Z.jsx)(vF,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:X(`flex w-full min-w-0 items-center gap-2 rounded-xl p-1 text-left outline-none transition-colors duration-150 ease-out`,`hover:bg-surface-active/70`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i&&`bg-surface-active/70`),"aria-expanded":i,"aria-haspopup":`dialog`,title:n.sidebar.appMenuAria,"aria-label":n.sidebar.appMenuAria,children:[(0,Z.jsx)(`span`,{className:`size-8 shrink-0 overflow-hidden rounded-full`,"aria-hidden":!0,children:(0,Z.jsx)(uA,{className:`size-full rounded-full`,alt:``,"aria-hidden":!0})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold leading-tight text-fg`,children:n.appBrand}),(0,Z.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:r.quickMenuHint})]}),(0,Z.jsx)(`span`,{className:X(`flex size-9 shrink-0 items-center justify-center rounded-xl text-fg-muted transition-colors`,i&&`bg-accent-soft text-accent-fg`),"aria-hidden":!0,children:(0,Z.jsx)(Jb,{className:`size-[18px]`,strokeWidth:1.5})})]})}),(0,Z.jsx)(yF,{children:(0,Z.jsx)(bF,{className:X(`z-50 w-max max-w-[min(calc(100vw-1rem),28rem)] overflow-visible`,`rounded-xl border border-edge bg-surface-panel p-2 shadow-popover dark:border-edge`),side:`top`,align:e?`center`:`start`,sideOffset:8,collisionPadding:12,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),children:(0,Z.jsx)(eI,{onOpenFullSettings:()=>{a(!1),t?.()},onAboutClick:()=>{s(!0),a(!1)}})})})]}),(0,Z.jsx)(JF,{open:o,onOpenChange:s})]})}var cI=`xopc-web-sidebar-nav-order`;function lI(){try{let e=globalThis.localStorage?.getItem(cI);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function uI(e){try{globalThis.localStorage?.setItem(cI,JSON.stringify(e))}catch{}}function dI(e,t,n,r,i){if(t===n)return e;let a=e.filter(e=>e!==t),o=a.indexOf(n),s=o===-1?a.length:r===`before`?o:o+1;return pI([...a.slice(0,s),t,...a.slice(s)],i)}function fI(e,t,n){return pI([...e.filter(e=>e!==t),t],n)}function pI(e,t){let n=new Set(e),r=[];for(let e of t)n.has(e)||r.push(e);return r.length===0?e:[...e,...r]}var mI=c((e,t)=>({order:lI(),move:(n,r,i)=>{let a=dI(t().order,n,r,i,new Set(t().order));a!==t().order&&(e({order:a}),queueMicrotask(()=>uI(a)))},moveToEnd:n=>{let r=fI(t().order,n,new Set(t().order));r!==t().order&&(e({order:r}),queueMicrotask(()=>uI(r)))},setOrder:t=>{e({order:t}),queueMicrotask(()=>uI(t))}})),hI=null,gI=c((e,t)=>({variables:{},loaded:!1,updateContext:t=>e(e=>({variables:{...e.variables,...t}})),setContext:t=>e({variables:t,loaded:!0}),fetchContext:async()=>hI||(hI=(async()=>{let e=await we(_(`/api/context`));t().setContext(e)})().finally(()=>{hI=null}),hI)})),_I=function(e){return e[e.PermissionDenied=4001]=`PermissionDenied`,e[e.InvalidRequest=4002]=`InvalidRequest`,e[e.MethodNotFound=4003]=`MethodNotFound`,e[e.InternalError=4004]=`InternalError`,e[e.Timeout=4005]=`Timeout`,e[e.ExtensionNotFound=4006]=`ExtensionNotFound`,e[e.RateLimited=4007]=`RateLimited`,e}({}),vI=[`--color-surface-base`,`--color-surface-panel`,`--color-surface-hover`,`--color-fg`,`--color-fg-muted`,`--color-fg-subtle`,`--color-accent`,`--color-accent-hover`,`--color-accent-soft`,`--color-edge`,`--color-edge-subtle`,`--color-danger`,`--color-success`,`--color-warning`,`--radius-sm`,`--radius-lg`,`--radius-xl`];function yI(e){let t=getComputedStyle(document.documentElement),n={};for(let e of vI){let r=t.getPropertyValue(e).trim();r&&(n[e]=r)}return{mode:e,tokens:n,fontFamily:t.getPropertyValue(`font-family`).trim(),fontFamilyMono:t.getPropertyValue(`--font-mono`).trim()}}var bI={"agent.sendMessage":`agent.send`,"session.list":`session.read`,"session.navigate":`session.read`,"config.get":`config.read`,"config.set":`config.write`,"storage.get":`storage`,"storage.set":`storage`,"storage.remove":`storage`,"storage.keys":`storage`,"ui.notification":`notification`,"ui.navigate":`theme`,"theme.get":`theme`},xI=class{iframes=new Map;byContentWindow=new WeakMap;handlers=new Map;extensionPermissions=new Map;eventSubscribers=new Map;agentStreamSubscriptions=new Map;boundListener=e=>{this.onWindowMessage(e)};constructor(){window.addEventListener(`message`,this.boundListener)}dispose(){window.removeEventListener(`message`,this.boundListener),this.iframes.clear(),this.handlers.clear(),this.extensionPermissions.clear(),this.eventSubscribers.clear(),this.agentStreamSubscriptions.clear()}registerIframe(e,t,n){let r=this.iframes.get(e);r&&r!==t&&r.contentWindow&&this.byContentWindow.delete(r.contentWindow),this.iframes.set(e,t),this.extensionPermissions.set(e,new Set(n)),this.rememberIframeWindow(e,t)}unregisterIframe(e){let t=this.iframes.get(e);t?.contentWindow&&this.byContentWindow.delete(t.contentWindow),this.iframes.delete(e),this.extensionPermissions.delete(e),this.agentStreamSubscriptions.delete(e)}rememberIframeWindow(e,t){let n=t.contentWindow;n&&this.byContentWindow.set(n,{extensionId:e,iframe:t})}subscribeAgentStream(e,t){let n=this.agentStreamSubscriptions.get(e);n||(n=new Set,this.agentStreamSubscriptions.set(e,n)),n.add(t)}unsubscribeAgentStream(e,t){this.agentStreamSubscriptions.get(e)?.delete(t)}forwardAgentStreamEvent(e,t){for(let[n,r]of this.agentStreamSubscriptions)r.has(e)&&this.sendEvent(n,`agent.stream.${e}`,t)}broadcastExtensionEvent(e,t,n){let r=t.startsWith(`ext.`)?t:`ext.${t}`;for(let[t]of this.iframes)t!==e&&this.sendEvent(t,r,n)}handleExtensionEvent(e,t,n){if(t.startsWith(`ext.`)){let r=t.slice(4);this.broadcastExtensionEvent(e,r,n);return}if(t===`agent.subscribe`||t===`agent.unsubscribe`){if(!(this.extensionPermissions.get(e)??new Set).has(`agent.subscribe`))return;let{sessionKey:r}=n??{};if(typeof r!=`string`||!r.trim())return;let i=r.trim();t===`agent.subscribe`?this.subscribeAgentStream(e,i):this.unsubscribeAgentStream(e,i)}}registerMethod(e,t){this.handlers.set(e,t)}subscribeExtensionEvents(e,t){let n=this.eventSubscribers.get(e);return n||(n=new Set,this.eventSubscribers.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&this.eventSubscribers.delete(e)}}sendInit(e,t,n){let r=this.iframes.get(e);if(!r?.contentWindow)return;this.rememberIframeWindow(e,r);let i=[...this.extensionPermissions.get(e)??[]];r.contentWindow.postMessage({source:`xopc-host`,type:`init`,extensionId:e,permissions:i,theme:t,locale:n},`*`)}sendEvent(e,t,n){let r=this.iframes.get(e);r?.contentWindow&&r.contentWindow.postMessage({source:`xopc-host`,type:`event`,event:t,data:n},`*`)}broadcastEvent(e,t){for(let[,n]of this.iframes)n.contentWindow?.postMessage({source:`xopc-host`,type:`event`,event:e,data:t},`*`)}postResponse(e,t,n,r,i){let a=e.contentWindow??(t?.source instanceof Window?t.source:null),o={source:`xopc-host`,type:`response`,requestId:n,result:r,error:i};a&&a.postMessage(o,`*`)}isTrustedExtensionSource(e,t){if(t.source===null)return!0;let n=e.contentWindow;if(t.source===n)return!0;if(n&&typeof Window<`u`&&t.source instanceof Window)try{return t.source.frameElement===e}catch{}return!1}async onWindowMessage(e){let t=e.data;if(!t||t.source!==`xopc-extension`)return;let n,r=t.extensionId;if(e.source instanceof Window){let t=this.byContentWindow.get(e.source);t&&(n=t.iframe,r=t.extensionId)}if(n||(n=this.iframes.get(t.extensionId),r=t.extensionId),!n||!(e.source instanceof Window&&this.byContentWindow.has(e.source))&&!this.isTrustedExtensionSource(n,e))return;if(t.type===`event`){this.handleExtensionEvent(r,t.event,t.data);let e=this.eventSubscribers.get(r);if(e){let n={event:t.event,data:t.data};for(let t of e)try{t(n)}catch{}}return}if(t.type!==`request`)return;let{requestId:i,method:a,params:o}=t,s=this.handlers.get(a);if(!s){this.postResponse(n,e,i,void 0,{code:_I.MethodNotFound,message:`Unknown method: ${a}`});return}let c=bI[a],l=this.extensionPermissions.get(r)??new Set;if(c&&!l.has(c)){this.postResponse(n,e,i,void 0,{code:_I.PermissionDenied,message:`Missing permission: ${c}`});return}try{let t=await s(r,o);this.postResponse(n,e,i,t)}catch(t){let r=t instanceof Error?t.message:String(t);this.postResponse(n,e,i,void 0,{code:_I.InternalError,message:r})}}};function SI(e){e.registerMethod(`theme.get`,async()=>yI(ve.getState().resolved)),e.registerMethod(`ui.navigate`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`path`in t?String(t.path??``):``;n&&window.dispatchEvent(new CustomEvent(`extension-navigate`,{detail:{path:n}}))}),e.registerMethod(`ui.notification`,async(e,t)=>{window.dispatchEvent(new CustomEvent(`extension-notification`,{detail:t}))}),e.registerMethod(`session.navigate`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`sessionKey`in t?String(t.sessionKey??``):``;n&&window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:n},bubbles:!0}))}),e.registerMethod(`session.list`,async()=>{let e=await Ee(_(`/api/sessions`));if(!e.ok)throw Error(`Failed to list sessions: ${e.status}`);return((await e.json()).items??[]).map(e=>({sessionKey:e.key,title:e.name,lastMessageAt:e.updatedAt??e.lastAccessedAt,messageCount:e.messageCount}))}),e.registerMethod(`agent.sendMessage`,async(e,t)=>{let{message:n,sessionKey:r,newSession:i}=t,a=await Ee(_(`/api/agent`),{method:`POST`,headers:{Accept:`application/json`},body:JSON.stringify({message:n,channel:`webchat`,sessionKey:i?void 0:r,newSession:!!i})});if(!a.ok)throw Error(`Agent request failed: ${a.status}`);let o=await a.json();return{sessionKey:o.payload?.sessionKey??o.payload?.key??o.sessionKey??r??``}}),e.registerMethod(`config.get`,async e=>{let t=await Ee(_(`/api/extensions/${encodeURIComponent(e)}/config`));if(!t.ok)throw Error(`Failed to get config: ${t.status}`);return t.json()}),e.registerMethod(`config.set`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&!Array.isArray(t)?t:{},r=await Ee(_(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(n)});if(!r.ok)throw Error(`Failed to set config: ${r.status}`)}),e.registerMethod(`storage.get`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`key`in t?String(t.key??``):``,r=await Ee(_(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(n)}`));if(r.status!==404){if(!r.ok)throw Error(`Failed to get storage key: ${r.status}`);return(await r.json()).value}}),e.registerMethod(`storage.set`,async(e,t)=>{let n=t,r=n&&typeof n.key==`string`?n.key:``,i=await Ee(_(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(r)}`),{method:`PUT`,body:JSON.stringify({value:n?.value})});if(!i.ok)throw Error(`Failed to set storage key: ${i.status}`)}),e.registerMethod(`storage.remove`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`key`in t?String(t.key??``):``,r=await Ee(_(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(n)}`),{method:`DELETE`});if(r.status!==404&&!r.ok)throw Error(`Failed to remove storage key: ${r.status}`)}),e.registerMethod(`storage.keys`,async e=>{let t=await Ee(_(`/api/extensions/${encodeURIComponent(e)}/storage`));if(!t.ok)throw Error(`Failed to list storage keys: ${t.status}`);return(await t.json()).keys??[]})}function CI(e){return e.active||e.activationEligible===!0}function wI(e){let t=e.ui?.contributions;return t?Array.isArray(t.pages)&&t.pages.length>0||Array.isArray(t.settingsPanels)&&t.settingsPanels.length>0||Array.isArray(t.chatWidgets)&&t.chatWidgets.length>0||Array.isArray(t.sidebarPanels)&&t.sidebarPanels.length>0:!1}function TI(e){return e.source===`bundled`&&e.hasUi===!0&&wI(e)}function EI(e){return e.kind===`image-generation`||e.kind===`media-provider`}function DI(e){return CI(e)?e.hasConfigSchema||EI(e)?!0:e.hasUi?wI(e):!1:!1}function OI(e){return DI(e)||TI(e)}var kI=(0,J.createContext)(null);function AI({children:e}){let t=(0,J.useRef)(null);if(!t.current){let e=new xI;SI(e),t.current=e}let n=t.current,r=Se(e=>!!e.token),{data:i,isLoading:a}=v(r?`gateway-extensions-list`:null,()=>we(_(`/api/extensions`)),{revalidateOnFocus:!1}),o=i?.extensions??[],s=ve(e=>e.resolved);(0,J.useEffect)(()=>{r&&gI.getState().fetchContext()},[r]),(0,J.useEffect)(()=>{let e=e=>{let t=e.detail;t&&typeof t==`object`&&!Array.isArray(t)&&gI.getState().updateContext(t)},t=()=>{gI.getState().fetchContext()};return window.addEventListener(`context-update`,e),window.addEventListener(`config-reload`,t),window.addEventListener(`registry-updated`,t),()=>{window.removeEventListener(`context-update`,e),window.removeEventListener(`config-reload`,t),window.removeEventListener(`registry-updated`,t)}},[]);let c=(0,J.useCallback)(e=>{let t=e.detail;t?.sessionKey&&n.forwardAgentStreamEvent(t.sessionKey,t.event??t)},[n]),l=(0,J.useRef)(c);l.current=c,(0,J.useEffect)(()=>{let e=e=>{l.current(e)};return window.addEventListener(`agent-stream-event`,e),()=>{window.removeEventListener(`agent-stream-event`,e)}},[]),(0,J.useEffect)(()=>{let e=yI(s);n.broadcastEvent(`theme.changed`,e)},[s,n]);let u=(0,J.useRef)(n);u.current=n,(0,J.useEffect)(()=>()=>{u.current.dispose(),t.current=null},[]);let d=(0,J.useMemo)(()=>({router:n,extensions:o,loading:a}),[n,o,a]);return(0,Z.jsx)(kI.Provider,{value:d,children:e})}function jI(){let e=(0,J.useContext)(kI);if(!e)throw Error(`useExtensionRouter must be used within ExtensionProvider`);return e.router}function MI(){let e=(0,J.useContext)(kI);if(!e)throw Error(`useExtensions must be used within ExtensionProvider`);return e.extensions}function NI(){let e=(0,Y.c)(2),t=MI(),n;return e[0]===t?n=e[1]:(n=t.filter(DI),e[0]=t,e[1]=n),n}function PI(){let e=(0,J.useContext)(kI);if(!e)throw Error(`useExtensionsLoading must be used within ExtensionProvider`);return e.loading}function FI(e,t){return t.path.startsWith(`/apps/`)?t.path:`/apps/${e}/${t.id.startsWith(`${e}.`)?t.id.slice(e.length+1):t.id}`}function II(e){return wO[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]}var LI=[{id:`builtin:agents`,to:`/agents`,Icon:YE},{id:`builtin:skills`,to:`/skills`,Icon:hg},{id:`builtin:cron`,to:`/cron`,Icon:Zl},{id:`builtin:channels`,to:`/channels`,Icon:bv}];function RI(e,t){let n=new Map;for(let t of e)n.set(t.id,t);let r=[],i=new Set;for(let e of t){let t=n.get(e);!t||i.has(e)||(r.push(t),i.add(e))}for(let t of e)i.has(t.id)||(r.push(t),i.add(t.id));return r.length<=5?{visible:r,overflow:[],hasOverflow:!1}:{visible:r.slice(0,4),overflow:r.slice(4),hasOverflow:!0}}var zI=`text/plain`,BI=`xopc-nav:`;function VI(e){return`${BI}${e}`}function HI(e){return e.startsWith(BI)?e.slice(9):null}function UI(e){let t=e.currentTarget.getBoundingClientRect();return e.clientY<t.top+t.height/2?`before`:`after`}function WI({isActive:e},t,n,r){return X(`group relative flex w-full items-center text-sm font-medium leading-6 transition-colors duration-200 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,t?`justify-center rounded-xl p-2.5`:`gap-2 rounded-lg px-3 py-2 text-left`,e?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`,n&&`opacity-40`,r===`before`&&`shadow-[inset_0_2px_0_0_var(--color-accent)]`,r===`after`&&`shadow-[inset_0_-2px_0_0_var(--color-accent)]`)}function GI({isActive:e},t,n){return X(`group relative flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm font-medium leading-5 transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,e?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`,t&&`opacity-40`,n===`before`&&`shadow-[inset_0_2px_0_0_var(--color-accent)]`,n===`after`&&`shadow-[inset_0_-2px_0_0_var(--color-accent)]`)}function KI(e){let t=(0,Y.c)(11),{item:n,collapsed:r}=e,{Icon:i,letter:a}=n;if(i){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=X(`size-4`,`shrink-0 opacity-90`),t[0]=e):e=t[0];let n;return t[1]===i?n=t[2]:(n=(0,Z.jsx)(i,{className:e,strokeWidth:1.75,"aria-hidden":!0}),t[1]=i,t[2]=n),n}let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=X(`size-4`,`flex shrink-0 items-center justify-center text-[10px] font-bold opacity-70`),t[3]=o):o=t[3];let s;t[4]!==n.label||t[5]!==a?(s=a??n.label.charAt(0),t[4]=n.label,t[5]=a,t[6]=s):s=t[6];let c;t[7]===s?c=t[8]:(c=s.toUpperCase(),t[7]=s,t[8]=c);let l;return t[9]===c?l=t[10]:(l=(0,Z.jsx)(`span`,{className:o,"aria-hidden":!0,children:c}),t[9]=c,t[10]=l),l}function qI(e){let t=[];for(let n of e){if(n.activationEligible===!1)continue;let e=n.ui?.contributions?.pages;if(e)for(let r of e){if(!r.showInNav)continue;let e=r.navIcon?II(r.navIcon):void 0;t.push({id:`ext:${n.id}:${r.id}`,kind:`extension`,label:r.title,to:FI(n.id,r),Icon:e,letter:r.title.charAt(0),title:r.title})}}return t}function JI(e){let t=(0,Y.c)(52),{collapsed:n,onNavigate:r}=e,i=n===void 0?!1:n,a=d($I),o;t[0]===a?o=t[1]:(o=m(a),t[0]=a,t[1]=o);let s=o,c=NI(),l=mI(QI),u=mI(ZI),f=mI(XI),[p,h]=(0,J.useState)(null),[g,_]=(0,J.useState)(null),[v,y]=(0,J.useState)(!1),[b,x]=(0,J.useState)(!1),S;if(t[2]!==s.nav||t[3]!==c){let e;t[5]===s.nav?e=t[6]:(e=e=>{let t=e.id.slice(8);return{id:e.id,kind:`builtin`,label:s.nav[t],to:e.to,Icon:e.Icon}},t[5]=s.nav,t[6]=e);let n=LI.map(e),r=qI(c);S=[...n,...r],t[2]=s.nav,t[3]=c,t[4]=S}else S=t[4];let C=S,w;t[7]!==C||t[8]!==l?(w=RI(C,l),t[7]=C,t[8]=l,t[9]=w):w=t[9];let T=w,E;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(E=e=>t=>{t.dataTransfer.setData(zI,VI(e)),t.dataTransfer.effectAllowed=`move`,h(e)},t[10]=E):E=t[10];let D=E,O;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(O=()=>{h(null),_(null),y(!1)},t[11]=O):O=t[11];let k=O,A;t[12]!==p||t[13]!==g?(A=e=>t=>{if(!p)return;t.preventDefault(),t.dataTransfer.dropEffect=`move`;let n=UI(t);g?.id===e&&g.position===n||_({id:e,position:n})},t[12]=p,t[13]=g,t[14]=A):A=t[14];let j=A,M;t[15]===u?M=t[16]:(M=e=>t=>{t.preventDefault();let n=HI(t.dataTransfer.getData(zI));if(!n||n===e){k();return}u(n,e,UI(t)),k()},t[15]=u,t[16]=M);let N=M,P;t[17]===p?P=t[18]:(P=e=>{p&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,y(!0))},t[17]=p,t[18]=P);let F=P,I;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>y(!1),t[19]=I):I=t[19];let L=I,R;t[20]===f?R=t[21]:(R=e=>{e.preventDefault();let t=HI(e.dataTransfer.getData(zI));t&&f(t),k()},t[20]=f,t[21]=R);let z=R,B;t[22]!==i||t[23]!==p||t[24]!==g||t[25]!==r||t[26]!==j||t[27]!==N?(B=function(e){let t=p===e.id,n=g?.id===e.id?g.position:null;return(0,Z.jsxs)(Ma,{to:e.to,draggable:!0,onDragStart:D(e.id),onDragEnd:k,onDragOver:j(e.id),onDrop:N(e.id),className:e=>WI(e,i,t,n),title:e.title??e.label,onClick:()=>r?.(),children:[(0,Z.jsx)(KI,{item:e,collapsed:i}),i?null:(0,Z.jsx)(`span`,{className:`truncate`,children:e.label})]},e.id)},t[22]=i,t[23]=p,t[24]=g,t[25]=r,t[26]=j,t[27]=N,t[28]=B):B=t[28];let V=B,H;t[29]!==i||t[30]!==p||t[31]!==g||t[32]!==s.sidebar.moreApps||t[33]!==s.sidebar.moreAppsAria||t[34]!==v||t[35]!==F||t[36]!==z||t[37]!==r||t[38]!==j||t[39]!==N||t[40]!==b||t[41]!==T.overflow?(H=function(){return(0,Z.jsxs)(gF,{open:b,onOpenChange:x,children:[(0,Z.jsx)(vF,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,onDragOver:F,onDragLeave:L,onDrop:z,className:X(`flex w-full items-center text-sm font-medium leading-6 transition-colors duration-200 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i?`justify-center rounded-xl p-2.5`:`gap-2 rounded-lg px-3 py-2 text-left`,b?`bg-surface-hover text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`,v&&`ring-2 ring-accent ring-offset-2 ring-offset-surface-base`),"aria-label":s.sidebar.moreAppsAria,title:s.sidebar.moreApps,children:[(0,Z.jsx)(ud,{className:`size-4 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),i?null:(0,Z.jsx)(`span`,{className:`truncate`,children:s.sidebar.moreApps})]})}),(0,Z.jsx)(yF,{children:(0,Z.jsx)(bF,{side:`right`,align:`start`,sideOffset:8,collisionPadding:8,className:X(`z-50 min-w-[14rem] max-w-[20rem] rounded-lg border border-edge bg-surface-panel p-1 shadow-md`),onOpenAutoFocus:YI,children:(0,Z.jsx)(`ul`,{className:`flex flex-col gap-0.5`,role:`list`,"aria-label":s.sidebar.moreAppsAria,children:T.overflow.map(e=>{let t=p===e.id,n=g?.id===e.id?g.position:null;return(0,Z.jsx)(`li`,{className:`contents`,children:(0,Z.jsxs)(Ma,{to:e.to,draggable:!0,onDragStart:D(e.id),onDragEnd:k,onDragOver:j(e.id),onDrop:N(e.id),className:e=>GI(e,t,n),title:e.title??e.label,onClick:()=>{x(!1),r?.()},children:[(0,Z.jsx)(KI,{item:e}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.label})]})},e.id)})})})})]})},t[29]=i,t[30]=p,t[31]=g,t[32]=s.sidebar.moreApps,t[33]=s.sidebar.moreAppsAria,t[34]=v,t[35]=F,t[36]=z,t[37]=r,t[38]=j,t[39]=N,t[40]=b,t[41]=T.overflow,t[42]=H):H=t[42];let U=H,W;t[43]!==T.visible||t[44]!==V?(W=T.visible.map(V),t[43]=T.visible,t[44]=V,t[45]=W):W=t[45];let G;t[46]!==T.hasOverflow||t[47]!==U?(G=T.hasOverflow?U():null,t[46]=T.hasOverflow,t[47]=U,t[48]=G):G=t[48];let ee;return t[49]!==W||t[50]!==G?(ee=(0,Z.jsxs)(Z.Fragment,{children:[W,G]}),t[49]=W,t[50]=G,t[51]=ee):ee=t[51],ee}function YI(e){return e.preventDefault()}function XI(e){return e.moveToEnd}function ZI(e){return e.move}function QI(e){return e.order}function $I(e){return e.language}var eL={feishu:`/channel-icons/feishu.svg`,lark:`/channel-icons/lark.svg`};function tL(e){let t=(0,Y.c)(9),{sourceChannel:n,className:r}=e,i=eL[n.toLowerCase()];if(i){let e;t[0]===r?e=t[1]:(e=X(`shrink-0`,r),t[0]=r,t[1]=e);let n;return t[2]!==i||t[3]!==e?(n=(0,Z.jsx)(`img`,{src:i,alt:``,draggable:!1,className:e,"aria-hidden":!0}),t[2]=i,t[3]=e,t[4]=n):n=t[4],n}let a;t[5]===r?a=t[6]:(a=X(`shrink-0`,r),t[5]=r,t[6]=a);let o;return t[7]===a?o=t[8]:(o=(0,Z.jsx)(lh,{className:a,strokeWidth:1.75,"aria-hidden":!0}),t[7]=a,t[8]=o),o}var nL=`inline-flex items-center gap-px rounded-pill border border-edge bg-surface-hover p-1 dark:border-edge`,rL=`inline-flex shrink-0 items-center justify-center rounded-pill text-xs font-medium leading-none transition-[color,background-color,box-shadow] duration-150 ease-out text-fg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel active:scale-100`,iL=`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,aL=1;function oL(e,t){let n=0,r=0,i=e;for(;i&&i!==t;)n+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;return i===t?{x:n,y:r}:null}var sL=`pointer-events-none absolute left-0 top-0 z-[1] rounded-pill bg-surface-panel shadow-sm will-change-transform [backface-visibility:hidden] dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,cL=`relative z-[2] box-border flex h-6 min-h-0 min-w-0 flex-1 cursor-pointer items-center justify-center gap-1 rounded-pill border-0 bg-transparent px-2 py-0 text-center text-xs font-medium leading-none outline-none transition-[color,background-color,box-shadow] duration-150 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel active:scale-100 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50`;function lL({value:e,onChange:t,options:n,"aria-label":r,className:i,buttonClassName:a}){let o=(0,J.useRef)(null),s=(0,J.useRef)([]),[c,l]=(0,J.useState)({x:0,y:0,w:0,h:0}),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(!1),m=(0,J.useCallback)(()=>{let t=o.current;if(!t)return;let r=n.findIndex(t=>t.value===e);if(r<0)return;let i=s.current[r];if(!i)return;let a=aL,c=t.getBoundingClientRect(),u=i.getBoundingClientRect(),f=oL(i,t),p,m;if(f)p=f.x,m=f.y;else{let e=getComputedStyle(t),n=parseFloat(e.borderLeftWidth)||0,r=parseFloat(e.borderTopWidth)||0;p=u.left-c.left-n,m=u.top-c.top-r}l({x:p+a,y:m+a,w:Math.max(0,u.width-a*2),h:Math.max(0,u.height-a*2)}),d(!0)},[n,e]),h=(0,J.useRef)(m);return h.current=m,(0,J.useLayoutEffect)(()=>{let e=requestAnimationFrame(()=>m());return()=>cancelAnimationFrame(e)},[m]),(0,J.useEffect)(()=>{let e=requestAnimationFrame(()=>{requestAnimationFrame(()=>p(!0))});return()=>cancelAnimationFrame(e)},[]),(0,J.useEffect)(()=>{let e=o.current;if(!e)return;let t=()=>{requestAnimationFrame(()=>h.current())},n=new ResizeObserver(t);return n.observe(e),window.addEventListener(`resize`,t),()=>{n.disconnect(),window.removeEventListener(`resize`,t)}},[]),(0,Z.jsxs)(`div`,{ref:o,className:X(nL,`relative isolate flex w-full max-w-full flex-row items-center`,i),role:`group`,"aria-label":r,children:[(0,Z.jsx)(`div`,{"aria-hidden":!0,className:X(sL,`motion-reduce:!transition-none motion-reduce:!duration-0`,f&&`transition-[transform,width,height] duration-300 [transition-timing-function:cubic-bezier(0.32,0.72,0,1)]`),style:{width:c.w,height:c.h,transform:`translate3d(${c.x}px, ${c.y}px, 0)`,opacity:u&&c.w>0?1:0}}),n.map((n,r)=>{let i=n.icon,o=e===n.value;return(0,Z.jsxs)(`button`,{ref:e=>{s.current[r]=e},type:`button`,"aria-pressed":o,title:n.title??n.label,onClick:()=>t(n.value),className:X(cL,o?`text-fg`:`text-fg-subtle`,a),children:[i?(0,Z.jsx)(i,{className:`block size-3 shrink-0 opacity-80`,strokeWidth:1.75,"aria-hidden":!0}):null,(0,Z.jsx)(`span`,{className:`min-w-0 shrink truncate leading-none`,children:n.label})]},n.value)})]})}function uL(){return _(`/api/config`)}var dL=null;async function fL(){return dL||(dL=we(uL()).finally(()=>{dL=null}),dL)}function pL(e){let t=(0,Y.c)(6),n;t[0]===e?n=t[1]:(n=e?uL():null,t[0]=e,t[1]=n);let r=n,i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i={revalidateOnFocus:!1},t[2]=i):i=t[2];let a=v(r,fL,i),o,s;return t[3]===e?(o=t[4],s=t[5]):(o=()=>{if(!e)return;let t=uL(),n=()=>{b(t)};return window.addEventListener(`config-reload`,n),()=>window.removeEventListener(`config-reload`,n)},s=[e],t[3]=e,t[4]=o,t[5]=s),(0,J.useEffect)(o,s),a}function mL(){return b(uL())}var hL=null;async function gL(){return hL||(hL=_L().finally(()=>{hL=null}),hL)}async function _L(){let e=await Ee(_(`/api/agents`));if(e.ok){let t=await e.json();if(t.ok&&t.payload?.defaultId&&Array.isArray(t.payload.agents)){let e=t.payload.defaultId.trim().toLowerCase(),n=t.payload.agents.filter(e=>!!(e&&typeof e.id==`string`&&e.id.trim())).map(e=>({id:e.id.trim().toLowerCase(),name:typeof e.name==`string`&&e.name.trim()?e.name.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,...typeof e.avatar==`string`&&e.avatar.trim()?{avatar:e.avatar.trim()}:{}}));if(n.length>0)return{defaultId:e,items:n}}}let t=(await fL()).payload?.config?.agents,n=(t?.defaultId??`main`).trim().toLowerCase(),r=(Array.isArray(t?.list)?t.list:[]).filter(e=>!!(e&&typeof e.id==`string`&&e.id.trim())).map(e=>({id:e.id.trim().toLowerCase(),name:typeof e.name==`string`&&e.name.trim()?e.name.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,...typeof e.avatar==`string`&&e.avatar.trim()?{avatar:e.avatar.trim()}:{}}));return r.length===0?{defaultId:n,items:[{id:n}]}:{defaultId:n,items:r}}function vL(e){return typeof e==`object`&&!!e&&`role`in e}function yL(e){if(!e||typeof e!=`object`)return!1;let t=e.type;return t===`tool_use`||t===`tool_call`||t===`toolCall`}function bL(e){return typeof e==`object`&&!!e}function xL(e){return typeof e.id==`string`&&e.id.length>0?e.id:crypto.randomUUID()}function SL(e){if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}}function CL(e){return SL(e.args??e.arguments??e.input??e.function?.arguments)??{}}function wL(e){if(typeof e==`string`){let t=Date.parse(e);return Number.isNaN(t)?Date.now():t}return Date.now()}var TL=3e5;function EL(e,t){let n=e.replace(/\\/g,`/`),r=encodeURIComponent(n),i=n.startsWith(`tts/`)?`/api/workspace/tts-file?rel=${r}`:`/api/workspace/inbound-file?rel=${r}`,a=t?.sessionKey?.trim();return a?`${i}&sessionKey=${encodeURIComponent(a)}`:i}function DL(e){if(typeof e.content==`string`&&e.content.length>0)return e.content;if(typeof e.data==`string`&&e.data.length>0)return e.data}var OL=[`.txt`,`.md`,`.json`,`.xml`,`.html`,`.css`,`.js`,`.ts`,`.jsx`,`.tsx`,`.yml`,`.yaml`];function kL(e){let t=e.mimeType?.toLowerCase()??``;if(t.startsWith(`text/`)||t===`application/json`||t===`application/xml`||t===`application/javascript`||t===`application/typescript`)return!0;let n=e.name?.toLowerCase()??``;return OL.some(e=>n.endsWith(e))}function AL(e){if(e.extractedText!=null&&e.extractedText!==``)return e.extractedText;if(!kL(e))return;let t=DL(e);if(t)try{let e=NL(t);return new TextDecoder(`utf-8`,{fatal:!1}).decode(new Uint8Array(e))}catch{return}}function jL(e,t){let n=t.trim();if(n.startsWith(`data:`))return n;let r=n.replace(/\s/g,``);return`data:${e&&typeof e==`string`&&e.includes(`/`)?e:`application/octet-stream`};base64,${r}`}function ML(e){let t=new Uint8Array(e),n=``,r=32768;for(let e=0;e<t.length;e+=r){let i=t.subarray(e,e+r);n+=String.fromCharCode(...i)}return btoa(n)}function NL(e){if(e==null||e===``)throw Error(`Missing file data`);let t=e;if(e.startsWith(`data:`)){let n=e.match(/base64,(.+)/);n&&(t=n[1])}let n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r.buffer}function PL(e){let t=[`B`,`KB`,`MB`,`GB`],n=0,r=e;for(;r>=1024&&n<t.length-1;)r/=1024,n++;return`${r.toFixed(1)} ${t[n]}`}function FL(e){let t=(e.mimeType??``).toLowerCase(),n=t.split(`;`)[0]?.trim()??``,r=e.name?.toLowerCase()??``;return e.type===`image`||n.startsWith(`image/`)?`image`:n===`application/pdf`||t.includes(`application/pdf`)||r.endsWith(`.pdf`)?`pdf`:n===`application/vnd.openxmlformats-officedocument.wordprocessingml.document`||t.includes(`wordprocessingml`)||r.endsWith(`.docx`)?`docx`:n===`application/vnd.openxmlformats-officedocument.presentationml.presentation`||t.includes(`presentationml`)||r.endsWith(`.pptx`)?`pptx`:[`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,`application/vnd.ms-excel`].includes(n)||t.includes(`spreadsheetml`)||t.includes(`ms-excel`)||r.endsWith(`.xlsx`)||r.endsWith(`.xls`)?`excel`:[`.jpg`,`.jpeg`,`.png`,`.gif`,`.webp`,`.bmp`,`.svg`].some(e=>r.endsWith(e))?`image`:`text`}function IL(e){let t=e.toLowerCase();for(let[e,n]of[[`.pdf`,`application/pdf`],[`.docx`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`],[`.pptx`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`],[`.xlsx`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`],[`.xls`,`application/vnd.ms-excel`],[`.png`,`image/png`],[`.jpg`,`image/jpeg`],[`.jpeg`,`image/jpeg`],[`.gif`,`image/gif`],[`.webp`,`image/webp`],[`.bmp`,`image/bmp`],[`.svg`,`image/svg+xml`],[`.svgz`,`image/svg+xml`],[`.ico`,`image/x-icon`],[`.tif`,`image/tiff`],[`.tiff`,`image/tiff`],[`.avif`,`image/avif`],[`.jxl`,`image/jxl`]])if(t.endsWith(e))return n}function LL(e,t){return(t?.startsWith(`text/`)??!1)||OL.some(t=>e.toLowerCase().endsWith(t))}function RL(e){if(Array.isArray(e))return e.map(e=>zL(e))}function zL(e){if(!e||typeof e!=`object`)return{name:`file`,mimeType:`application/octet-stream`};let t=e,n=typeof t.data==`string`?t.data:void 0,r=typeof t.content==`string`&&t.content.length>0?t.content:n,i=typeof t.name==`string`&&t.name.length>0?t.name:`file`,a=typeof t.mimeType==`string`&&t.mimeType.length>0?t.mimeType:``;!a&&typeof t.type==`string`&&t.type.includes(`/`)&&(a=t.type),a||=`application/octet-stream`;let o=a.split(`;`)[0]?.trim().toLowerCase()??``;if(o===`application/octet-stream`||o===``){let e=IL(i);e&&(a=e)}let s=typeof t.preview==`string`&&t.preview.length>0?t.preview:a.startsWith(`image/`)&&r?r:void 0,c=typeof t.durationSeconds==`number`&&Number.isFinite(t.durationSeconds)&&t.durationSeconds>0?t.durationSeconds:void 0;return{id:typeof t.id==`string`?t.id:void 0,name:i,mimeType:a,type:typeof t.type==`string`?t.type:void 0,size:typeof t.size==`number`?t.size:void 0,content:r,data:n??r,preview:s,extractedText:typeof t.extractedText==`string`?t.extractedText:void 0,workspaceRelativePath:typeof t.workspaceRelativePath==`string`&&t.workspaceRelativePath.length>0?t.workspaceRelativePath:void 0,durationSeconds:c}}function BL(e){let t=e.match(/^([^(]+?)\s*\(/),n=t?t[1].trim():`file`,r=e.match(/\(\s*([^,]+)\s*,\s*(\d+)\s*bytes\s*\)/i);return{name:n,mimeType:r?r[1].trim():`application/octet-stream`,size:r?parseInt(r[2],10):0}}function VL(e){let t=[];if(typeof e==`string`)t.push(e);else if(Array.isArray(e)){for(let n of e)if(n&&typeof n==`object`&&n.type===`text`){let e=n.text;typeof e==`string`&&t.push(e)}}let n=t.join(`
10
10
  `);if(!n.includes(`xopc-path:rel:`))return;let r=[],i=new Set,a=/\[File: ([^\]]+)\]\s*xopc-path:rel:(\S+)\s*xopc-path:abs:\S+/g,o;for(;(o=a.exec(n))!==null;){let e=o[2].trim();if(i.has(e))continue;i.add(e);let{name:t,mimeType:n,size:a}=BL(o[1]);r.push({name:t,mimeType:n,size:a,type:`document`,workspaceRelativePath:e})}let s=/\[File: ([^\]]+)\]\s*\r?\nxopc-path:rel:([^\r\n]+)\r?\n\s*xopc-path:abs:[^\r\n]+/g;for(;(o=s.exec(n))!==null;){let e=o[2].trim();if(i.has(e))continue;i.add(e);let{name:t,mimeType:n,size:a}=BL(o[1]);r.push({name:t,mimeType:n,size:a,type:`document`,workspaceRelativePath:e})}return r.length?r:void 0}function HL(e){let t=e.workspaceRelativePath?.replace(/\\/g,`/`).trim();return t?`rel:${t}`:e.id?`id:${e.id}`:`name:${e.name??`file`}|${e.mimeType??``}`}function UL(e){if(!e?.length)return;let t=[],n=new Set;for(let r of e){let e=HL(r);n.has(e)||(n.add(e),t.push(r))}return t.length?t:void 0}function WL(e,t){return UL([...e??[],...t??[]])}var GL=`[Startup context loaded by runtime]`,KL=`...[additional startup memory truncated]...`,qL=`END_QUOTED_NOTES`;function JL(e){if(!e.includes(GL))return e;let t=e.replace(/^\uFEFF/,``);if(!t.startsWith(GL))return e;let n=-1,r=t.lastIndexOf(qL);if(r>=0)n=r+16;else{let e=t.indexOf(KL);e>=0&&(n=e+43)}if(n<0){let n=t.slice(35),r=n.indexOf(`
11
11
 
12
12
  `);return r>=0?n.slice(r+2).replace(/^\s+/,``):e}return t.slice(n).replace(/^\s+/,``)}function YL(e){if(typeof e!=`string`||!e.includes(`## Skill:`))return e;let t=e.match(/## Skill:\s*([^\s\r\n]+)/);if(!t)return e;let n=t[1]??``;if(!n)return e;let r=[...e.matchAll(/\*\*Arguments\*\*:\s*([^\r\n]+)/g)],i=r.length>0?(r[r.length-1]?.[1]??``).trim():``;return i?`/skill:${n} ${i}`:`/skill:${n}`}function XL(e){return e.includes(`<file path=`)?e.replace(/<file\s+path="[^"]*">\r?\n[\s\S]*?<\/file>(?:\r?\n)*/g,``).replace(/\n{3,}/g,`
@@ -4676,25 +4676,25 @@ void main() {
4676
4676
  float alpha = vAlpha * pulse * 0.35 * globalOpacity;
4677
4677
  gl_FragColor = vec4(lineColor, alpha);
4678
4678
  }
4679
- `,transparent:!0,depthTest:!1,depthWrite:!1,blending:2}),this.lineSystem=new Bde(i,this.lineMaterial),this.lineSystem.renderOrder=1,e.add(this.lineSystem),this.materials=[this.backgroundMaterial,this.starMaterial,this.lineMaterial]}update(e,t){this.backgroundMaterial.uniforms.time.value=e,this.starMaterial.uniforms.time.value=e,this.lineMaterial.uniforms.time.value=e;for(let n=0;n<Z6;n++){let r=n*3,i=n*2;if(this.starPositions[r]+=this.starVelocities[i]*t*60,this.starPositions[r+1]+=this.starVelocities[i+1]*t*60,this.starCluster[n]>=0){let e=0,t=0,a=0;for(let i=0;i<Z6;i++){if(n===i||this.starCluster[i]!==this.starCluster[n])continue;let o=this.starPositions[i*3]-this.starPositions[r],s=this.starPositions[i*3+1]-this.starPositions[r+1],c=Math.sqrt(o*o+s*s);c>.01&&c<.8&&(e+=o/c*3e-5,t+=s/c*3e-5,a++)}a>0&&(this.starVelocities[i]+=e,this.starVelocities[i+1]+=t,this.starVelocities[i]*=.999,this.starVelocities[i+1]*=.999)}this.starPositions[r]>this.aspect+.2&&(this.starPositions[r]=-this.aspect-.2),this.starPositions[r]<-this.aspect-.2&&(this.starPositions[r]=this.aspect+.2),this.starPositions[r+1]>1.2&&(this.starPositions[r+1]=-1.2),this.starPositions[r+1]<-1.2&&(this.starPositions[r+1]=1.2),this.starBrightness[n]=.3+.5*(.5+.3*Math.sin(e*1.5+this.starPhases[n])+.2*Math.sin(e*2.7+this.starPhases[n]*2))}let n=this.starSystem.geometry.getAttribute(`position`);n.needsUpdate=!0;let r=this.starSystem.geometry.getAttribute(`brightness`);r.needsUpdate=!0,this.connectionThreshold=.2+Math.min(e*.008,.3)+Math.sin(e*.25)*.06,this.connectionThreshold=Math.min(this.connectionThreshold,.6),this.updateConnections()}buildSpatialGrid(){this.spatialGrid.clear();let e=1/this.gridCellSize;for(let t=0;t<Z6;t++){let n=Math.floor(this.starPositions[t*3]*e),r=Math.floor(this.starPositions[t*3+1]*e),i=n*73856093+r*19349663,a=this.spatialGrid.get(i);a?a.push(t):this.spatialGrid.set(i,[t])}}updateConnections(){this.buildSpatialGrid();let e=0,t=this.connectionThreshold*this.connectionThreshold,n=this.connectionThreshold*1.4,r=n*n,i=1/this.gridCellSize,a=new Set;for(let o=0;o<Z6&&e<Q6;o++){let s=o*3,c=this.starPositions[s],l=this.starPositions[s+1],u=Math.floor(c*i),d=Math.floor(l*i),f=this.starCluster[o];for(let i=-1;i<=1&&e<Q6;i++)for(let s=-1;s<=1&&e<Q6;s++){let p=(u+i)*73856093+(d+s)*19349663,m=this.spatialGrid.get(p);if(m)for(let i=0;i<m.length&&e<Q6;i++){let s=m[i];if(s<=o)continue;let u=o*Z6+s;if(a.has(u))continue;a.add(u);let d=s*3,p=c-this.starPositions[d],h=l-this.starPositions[d+1],g=p*p+h*h,_=f>=0&&f===this.starCluster[s];if(g<(_?r:t)){let t=1-Math.sqrt(g)/(_?n:this.connectionThreshold);_&&(t*=1.3),t=Math.min(t,1);let r=e*6;this.linePositions[r]=c,this.linePositions[r+1]=l,this.linePositions[r+2]=0,this.linePositions[r+3]=this.starPositions[d],this.linePositions[r+4]=this.starPositions[d+1],this.linePositions[r+5]=0;let i=e*2;this.lineAlphas[i]=t*this.starBrightness[o],this.lineAlphas[i+1]=t*this.starBrightness[s],e++}}}}let o=this.lineSystem.geometry.getAttribute(`position`);o.needsUpdate=!0;let s=this.lineSystem.geometry.getAttribute(`alpha`);s.needsUpdate=!0,this.lineSystem.geometry.setDrawRange(0,e*2)}resize(e,t,n){this.aspect=n,this.backgroundMaterial.uniforms.resolution.value.set(e,t),this.backgroundMesh.scale.set(n,1,1)}dispose(){this.backgroundMaterial.dispose(),this.starSystem.geometry.dispose(),this.starMaterial.dispose(),this.lineSystem.geometry.dispose(),this.lineMaterial.dispose(),this.scene.remove(this.backgroundMesh),this.scene.remove(this.starSystem),this.scene.remove(this.lineSystem),this.spatialGrid.clear()}},Hme=class{canvas;renderer;camera;clock;animationFrameId=null;currentScene=null;currentAnimation=null;currentPhase=null;currentElapsed=0;outgoingScene=null;outgoingAnimation=null;outgoingElapsed=0;isTransitioning=!1;transitionT=0;transitionSeconds=1.2;disposed=!1;fadeOpacity=0;fadeTarget=0;fadeSpeed=2.5;timeScale=.35;constructor(e){this.canvas=e,this.renderer=new Pme({canvas:e,alpha:!0,antialias:!0,powerPreference:`low-power`}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.renderer.setClearColor(0,0),this.renderer.autoClear=!1;let t=e.clientWidth,n=e.clientHeight;this.camera=new L3(-1,1,1,-1,.1,100),this.camera.position.z=1,this.clock=new vfe(!1),this.resize(t,n)}resize(e,t){if(this.disposed)return;let n=Math.min(window.devicePixelRatio,2);this.renderer.setSize(e,t),this.renderer.setPixelRatio(n);let r=e/t;this.camera.left=-r,this.camera.right=r,this.camera.top=1,this.camera.bottom=-1,this.camera.updateProjectionMatrix(),this.currentAnimation?.resize(e,t,r),this.outgoingAnimation?.resize(e,t,r)}startPhase(e){if(this.disposed||this.currentPhase===e&&this.currentAnimation&&!this.isTransitioning)return;this.isTransitioning&&this.finalizeTransition();let t=this.canvas.clientWidth,n=this.canvas.clientHeight,r=t/n,i=new Ode,a=this.createAnimation(i,e,r);a.resize(t,n,r),!this.currentAnimation||!this.currentScene||!this.currentPhase?(this.currentScene=i,this.currentAnimation=a,this.currentPhase=e,this.currentElapsed=0):(this.outgoingScene=this.currentScene,this.outgoingAnimation=this.currentAnimation,this.outgoingElapsed=this.currentElapsed,this.currentScene=i,this.currentAnimation=a,this.currentPhase=e,this.currentElapsed=0,this.isTransitioning=!0,this.transitionT=0),this.fadeTarget=1,this.clock.start(),this.animationFrameId||this.tick()}fadeOut(){this.fadeTarget=0}get isFullyFadedOut(){return this.fadeOpacity<=.001&&this.fadeTarget===0}tick=()=>{if(this.disposed)return;let e=this.clock.getDelta()*this.timeScale;if(this.fadeOpacity<this.fadeTarget?this.fadeOpacity=Math.min(this.fadeOpacity+e*this.fadeSpeed,this.fadeTarget):this.fadeOpacity>this.fadeTarget&&(this.fadeOpacity=Math.max(this.fadeOpacity-e*this.fadeSpeed,this.fadeTarget)),this.fadeOpacity<=.001&&this.fadeTarget===0){this.stopAllAnimations(),this.animationFrameId=null;return}this.outgoingAnimation&&this.outgoingScene&&this.isTransitioning&&(this.outgoingElapsed+=e,this.outgoingAnimation.update(this.outgoingElapsed,e)),this.currentAnimation&&this.currentScene&&(this.currentElapsed+=e,this.currentAnimation.update(this.currentElapsed,e));let t=1;if(this.isTransitioning){this.transitionT=Math.min(1,this.transitionT+e/this.transitionSeconds);let n=this.transitionT;t=n*n*(3-2*n),this.transitionT>=1&&(this.finalizeTransition(),t=1)}let n=this.isTransitioning?1-t:0;this.renderer.clear(),this.outgoingScene&&this.outgoingAnimation&&n>.001&&(this.setMaterialsOpacity(this.outgoingAnimation,this.fadeOpacity*n),this.renderer.render(this.outgoingScene,this.camera)),this.currentScene&&this.currentAnimation&&(this.setMaterialsOpacity(this.currentAnimation,this.fadeOpacity*t),this.renderer.render(this.currentScene,this.camera)),this.animationFrameId=requestAnimationFrame(this.tick)};createAnimation(e,t,n){switch(t){case`light`:return new Lme(e,n);case`deep`:return new zme(e,n);case`rem`:return new Vme(e,n)}}setMaterialsOpacity(e,t){for(let n of e.materials)n.uniforms.globalOpacity.value=t}finalizeTransition(){this.isTransitioning=!1,this.transitionT=1,this.outgoingAnimation&&this.outgoingAnimation.dispose(),this.outgoingScene=null,this.outgoingAnimation=null,this.outgoingElapsed=0}stopAllAnimations(){this.currentAnimation&&this.currentAnimation.dispose(),this.outgoingAnimation&&this.outgoingAnimation.dispose(),this.currentScene=null,this.currentAnimation=null,this.currentPhase=null,this.currentElapsed=0,this.outgoingScene=null,this.outgoingAnimation=null,this.outgoingElapsed=0,this.isTransitioning=!1,this.transitionT=0}dispose(){this.disposed=!0,this.animationFrameId&&=(cancelAnimationFrame(this.animationFrameId),null),this.stopAllAnimations(),this.renderer.dispose()}},$6=new Set([`light`,`deep`,`rem`]),Ume=3e3;function Wme(){let e=(0,Y.c)(11),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={status:`idle`},e[0]=t):t=e[0];let[n,r]=(0,J.useState)(t),i=(0,J.useRef)(0),a=(0,J.useRef)(null),o;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{a.current&&=(clearTimeout(a.current),null)},e[1]=o):o=e[1];let s=o,c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>{s(),i.current=Date.now(),r({status:`running`,phase:e})},e[2]=c):c=e[2];let l=c,u;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=e=>{s(),r({status:`fading-out`,phase:e}),a.current=setTimeout(()=>{r({status:`idle`})},1500)},e[3]=u):u=e[3];let d=u,f;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{s(),r(Gme),a.current=setTimeout(()=>{r({status:`idle`})},800)},e[4]=f):f=e[4];let p=f,m,h;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{let e=e=>{let t=e.detail,n=typeof t==`object`&&t&&typeof t.phase==`string`?t.phase:typeof t==`string`?t:null;n&&$6.has(n)&&l(n)},t=e=>{let t=e.detail,n=typeof t==`object`&&t&&typeof t.phase==`string`?t.phase:null;if(!n||!$6.has(n))return;let r=Date.now()-i.current,o=Math.max(0,Ume-r);s(),a.current=setTimeout(()=>{d(n)},o)};return window.addEventListener(`dreaming-phase-start`,e),window.addEventListener(`dreaming-phase-end`,t),()=>{window.removeEventListener(`dreaming-phase-start`,e),window.removeEventListener(`dreaming-phase-end`,t),s()}},h=[l,d,s],e[5]=m,e[6]=h):(m=e[5],h=e[6]),(0,J.useEffect)(m,h);let g,_;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>s,_=[s],e[7]=g,e[8]=_):(g=e[7],_=e[8]),(0,J.useEffect)(g,_);let v;return e[9]===n?v=e[10]:(v={state:n,triggerPhase:l,dismiss:p},e[9]=n,e[10]=v),v}function Gme(e){return e.status===`idle`?e:{status:`fading-out`,phase:e.phase}}var e8={light:`💤 Light Sleep — scanning memories…`,deep:`🌙 Deep Sleep — promoting memories…`,rem:`🌈 REM Sleep — discovering patterns…`};function Kme(){return typeof window<`u`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function qme(){let e=(0,Y.c)(28),t=(0,J.useRef)(null),n=(0,J.useRef)(null),r=(0,J.useRef)(null),{state:i,dismiss:a}=Wme(),o,s;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{let e=t.current;if(!e)return;let r=new Hme(e);return n.current=r,()=>{r.dispose(),n.current=null}},s=[],e[0]=o,e[1]=s):(o=e[0],s=e[1]),(0,J.useEffect)(o,s);let c,l;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=()=>{let e=r.current;!e||!n.current||n.current.resize(e.clientWidth,e.clientHeight)};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},l=[],e[2]=c,e[3]=l):(c=e[2],l=e[3]),(0,J.useEffect)(c,l);let u;e[4]!==i.phase||e[5]!==i.status?(u=()=>{let e=n.current;if(e)if(i.status===`running`){if(Kme())return;e.startPhase(i.phase)}else i.status===`fading-out`&&e.fadeOut()},e[4]=i.phase,e[5]=i.status,e[6]=u):u=e[6];let d;e[7]===i?d=e[8]:(d=[i],e[7]=i,e[8]=d),(0,J.useEffect)(u,d);let f,p;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{let e=r.current;!e||!n.current||n.current.resize(e.clientWidth,e.clientHeight)},p=[],e[9]=f,e[10]=p):(f=e[9],p=e[10]),(0,J.useEffect)(f,p);let m=i.status!==`idle`,h=i.status===`idle`?null:i.phase,g=i.status===`fading-out`,_;e[11]===a?_=e[12]:(_=()=>{a()},e[11]=a,e[12]=_);let v=_;if(!m&&!g){let n;return e[13]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`div`,{ref:r,className:`pointer-events-none fixed inset-0 z-[90] opacity-0`,"aria-hidden":!0,children:(0,Z.jsx)(`canvas`,{ref:t,className:`size-full`})}),e[13]=n):n=e[13],n}let y=g?`dreaming-overlay-exit pointer-events-none`:`dreaming-overlay-enter`,b;e[14]===y?b=e[15]:(b=X(`fixed inset-0 z-[90] bg-[#1c1c1e]/70 transition-opacity`,y),e[14]=y,e[15]=b);let x=h?e8[h]:void 0,S;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(`canvas`,{ref:t,className:`pointer-events-none size-full`}),e[16]=S):S=e[16];let C;e[17]===h?C=e[18]:(C=h?(0,Z.jsxs)(`div`,{className:X(`flex items-center gap-2 rounded-full border px-4 py-2 text-sm font-medium shadow-elevated backdrop-blur-sm`,`dreaming-pill-enter`,h===`light`&&`border-emerald-400/30 bg-emerald-950/60 text-emerald-300`,h===`deep`&&`border-indigo-400/30 bg-indigo-950/60 text-indigo-300`,h===`rem`&&`border-purple-400/30 bg-purple-950/60 text-purple-300`),children:[(0,Z.jsx)(`span`,{className:`dreaming-pulse-dot`}),(0,Z.jsx)(`span`,{children:e8[h]})]}):null,e[17]=h,e[18]=C);let w;e[19]===v?w=e[20]:(w=(0,Z.jsx)(`button`,{type:`button`,onClick:v,className:`rounded-full border border-edge-subtle bg-surface-panel/80 px-3 py-1.5 text-xs text-fg-muted shadow-elevated backdrop-blur-sm transition-colors hover:bg-surface-hover hover:text-fg`,"aria-label":`Dismiss dreaming animation`,children:`✕`}),e[19]=v,e[20]=w);let T;e[21]!==C||e[22]!==w?(T=(0,Z.jsxs)(`div`,{className:`pointer-events-auto absolute bottom-6 left-1/2 flex -translate-x-1/2 items-center gap-3`,children:[C,w]}),e[21]=C,e[22]=w,e[23]=T):T=e[23];let E;return e[24]!==b||e[25]!==x||e[26]!==T?(E=(0,Z.jsxs)(`div`,{ref:r,className:b,role:`status`,"aria-live":`polite`,"aria-label":x,children:[S,T]}),e[24]=b,e[25]=x,e[26]=T,e[27]=E):E=e[27],E}var Jme=new Intl.DateTimeFormat(`zh-CN`,{dateStyle:`medium`,timeStyle:`short`}),Yme=new Intl.DateTimeFormat(`en`,{dateStyle:`medium`,timeStyle:`short`});function Xme(e,t){return(t===`zh`?Jme:Yme).format(new Date(e))}function Zme(e){let t=(0,Y.c)(137),{filePath:n,onClose:r,sessionKey:i,agentId:a}=e,o=d(the),s;t[0]===o?s=t[1]:(s=m(o),t[0]=o,t[1]=s);let c=s,l=ve(ehe),u;t[2]!==a||t[3]!==n||t[4]!==i?(u={filePath:n,sessionKey:i,agentId:a},t[2]=a,t[3]=n,t[4]=i,t[5]=u):u=t[5];let f=EU(u),{rootRef:p,active:h,enter:g,exit:_}=oU(),{dialogOpen:v,loading:y,result:b,error:x,createShareLink:S,handleOpenChange:C}=XZ(),[w,T]=(0,J.useState)(!1),E;t[6]===n?E=t[7]:(E=n?dU(n):``,t[6]=n,t[7]=E);let D=E,O;t[8]===n?O=t[9]:(O=n?fU(n):``,t[8]=n,t[9]=O);let k=O,A=D===`.md`,j=D===`.html`||D===`.htm`,M;t[10]!==n||t[11]!==c.clipboard.copyFailed||t[12]!==c.workspace.pathCopied?(M=async()=>{if(n){if(await lH(n)){T(!0),window.setTimeout(()=>T(!1),2e3),fH(`success`,c.workspace.pathCopied,void 0,{duration:2e3});return}fH(`warning`,c.clipboard.copyFailed,void 0,{duration:4e3})}},t[10]=n,t[11]=c.clipboard.copyFailed,t[12]=c.workspace.pathCopied,t[13]=M):M=t[13];let N=M,P;t[14]!==a||t[15]!==S||t[16]!==n||t[17]!==i?(P=()=>{n&&S({path:n,...i==null?a?.trim()?{agentId:a.trim()}:{}:{sessionKey:i}})},t[14]=a,t[15]=S,t[16]=n,t[17]=i,t[18]=P):P=t[18];let F=P,I=!!(n&&!f.loading&&!f.loadError),L;t[19]!==_||t[20]!==r?(L=()=>{_(),r()},t[19]=_,t[20]=r,t[21]=L):L=t[21];let R=L;if(!n)return null;let z;t[22]===k?z=t[23]:(z=(0,Z.jsx)(`h2`,{className:`truncate text-base font-semibold leading-tight tracking-tight text-fg`,title:k,children:k}),t[22]=k,t[23]=z);let B;t[24]!==o||t[25]!==c.workspace.lastModified||t[26]!==f.loading||t[27]!==f.mtimeMs?(B=!f.loading&&f.mtimeMs!=null?(0,Z.jsxs)(`p`,{suppressHydrationWarning:!0,className:`mt-0.5 truncate text-xs leading-tight text-fg-muted`,title:new Date(f.mtimeMs).toISOString(),children:[c.workspace.lastModified,`: `,Xme(f.mtimeMs,o)]}):null,t[24]=o,t[25]=c.workspace.lastModified,t[26]=f.loading,t[27]=f.mtimeMs,t[28]=B):B=t[28];let V;t[29]!==z||t[30]!==B?(V=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[z,B]}),t[29]=z,t[30]=B,t[31]=V):V=t[31];let H;t[32]!==j||t[33]!==A||t[34]!==c.workspace.saved||t[35]!==c.workspace.saving||t[36]!==f.htmlCodeMode||t[37]!==f.saveStatus?(H=(A||j&&f.htmlCodeMode)&&f.saveStatus!==`idle`?(0,Z.jsx)(`span`,{className:`shrink-0 text-xs leading-tight text-fg-muted`,children:f.saveStatus===`saving`?c.workspace.saving:c.workspace.saved}):null,t[32]=j,t[33]=A,t[34]=c.workspace.saved,t[35]=c.workspace.saving,t[36]=f.htmlCodeMode,t[37]=f.saveStatus,t[38]=H):H=t[38];let U;t[39]!==j||t[40]!==A||t[41]!==c.workspace.edit||t[42]!==c.workspace.preview||t[43]!==c.workspace.viewing||t[44]!==f?(U=A?(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,title:f.markdownEditMode?c.workspace.viewing:c.workspace.edit,"aria-label":f.markdownEditMode?c.workspace.viewing:c.workspace.edit,onClick:()=>f.setMarkdownEditMode($me),children:f.markdownEditMode?(0,Z.jsx)(Cd,{className:`size-4`}):(0,Z.jsx)(H_,{className:`size-4`})}):j?(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,title:f.htmlCodeMode?c.workspace.preview:c.workspace.edit,"aria-label":f.htmlCodeMode?c.workspace.preview:c.workspace.edit,onClick:()=>f.setHtmlCodeMode(Qme),children:f.htmlCodeMode?(0,Z.jsx)(Cd,{className:`size-4`}):(0,Z.jsx)(H_,{className:`size-4`})}):null,t[39]=j,t[40]=A,t[41]=c.workspace.edit,t[42]=c.workspace.preview,t[43]=c.workspace.viewing,t[44]=f,t[45]=U):U=t[45];let W;t[46]!==h||t[47]!==I||t[48]!==g||t[49]!==_||t[50]!==c.chat?(W=I?(0,Z.jsx)(`button`,{type:`button`,className:X(`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,AX.focusRingPanel),title:h?c.chat.attachmentPreviewExitFullscreen:c.chat.attachmentPreviewFullscreen,"aria-label":h?c.chat.attachmentPreviewExitFullscreen:c.chat.attachmentPreviewFullscreen,onClick:()=>void(h?_():g()),children:h?(0,Z.jsx)(Ng,{className:`size-4`,strokeWidth:1.75}):(0,Z.jsx)(Dg,{className:`size-4`,strokeWidth:1.75})}):null,t[46]=h,t[47]=I,t[48]=g,t[49]=_,t[50]=c.chat,t[51]=W):W=t[51];let G;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(G=X(`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,AX.focusRingPanel),t[52]=G):G=t[52];let ee;t[53]===N?ee=t[54]:(ee=()=>void N(),t[53]=N,t[54]=ee);let K;t[55]===w?K=t[56]:(K=w?(0,Z.jsx)(Ml,{className:`size-4`}):(0,Z.jsx)(tu,{className:`size-4`}),t[55]=w,t[56]=K);let te;t[57]!==c.workspace.copyPath||t[58]!==ee||t[59]!==K?(te=(0,Z.jsx)(`button`,{type:`button`,className:G,title:c.workspace.copyPath,"aria-label":c.workspace.copyPath,onClick:ee,children:K}),t[57]=c.workspace.copyPath,t[58]=ee,t[59]=K,t[60]=te):te=t[60];let ne;t[61]!==c.workspace.revealInFolder||t[62]!==f?(ne=f.canRevealInFolder?(0,Z.jsx)(`button`,{type:`button`,className:X(`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,AX.focusRingPanel),title:c.workspace.revealInFolder,"aria-label":c.workspace.revealInFolder,onClick:()=>void f.onRevealInFolder(),children:(0,Z.jsx)(Sp,{className:`size-4`})}):null,t[61]=c.workspace.revealInFolder,t[62]=f,t[63]=ne):ne=t[63];let re;t[64]===y?re=t[65]:(re=y?(0,Z.jsx)(Cg,{className:`size-4 animate-spin`}):(0,Z.jsx)(bg,{className:`size-4`}),t[64]=y,t[65]=re);let ie;t[66]!==F||t[67]!==y||t[68]!==c.workspace.shareLink||t[69]!==re?(ie=(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:opacity-50`,title:c.workspace.shareLink,"aria-label":c.workspace.shareLink,onClick:F,disabled:y,children:re}),t[66]=F,t[67]=y,t[68]=c.workspace.shareLink,t[69]=re,t[70]=ie):ie=t[70];let ae;t[71]===f?ae=t[72]:(ae=()=>void f.onDownload(),t[71]=f,t[72]=ae);let oe=!f.canDownload,se;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Z.jsx)(Uu,{className:`size-4`}),t[73]=se):se=t[73];let q;t[74]!==c.workspace.download||t[75]!==ae||t[76]!==oe?(q=(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:opacity-50`,title:c.workspace.download,"aria-label":c.workspace.download,onClick:ae,disabled:oe,children:se}),t[74]=c.workspace.download,t[75]=ae,t[76]=oe,t[77]=q):q=t[77];let ce;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,Z.jsx)(oO,{className:`size-4`,strokeWidth:1.75}),t[78]=ce):ce=t[78];let le;t[79]!==R||t[80]!==c.workspace.close?(le=(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,title:c.workspace.close,"aria-label":c.workspace.close,onClick:R,children:ce}),t[79]=R,t[80]=c.workspace.close,t[81]=le):le=t[81];let ue;t[82]!==H||t[83]!==U||t[84]!==W||t[85]!==te||t[86]!==ne||t[87]!==ie||t[88]!==q||t[89]!==le?(ue=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pt-0.5`,children:[H,U,W,te,ne,ie,q,le]}),t[82]=H,t[83]=U,t[84]=W,t[85]=te,t[86]=ne,t[87]=ie,t[88]=q,t[89]=le,t[90]=ue):ue=t[90];let de;t[91]!==V||t[92]!==ue?(de=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2 border-b border-edge px-4 py-2 dark:border-edge`,children:[V,ue]}),t[91]=V,t[92]=ue,t[93]=de):de=t[93];let fe=l===`dark`,pe;t[94]!==f.htmlCodeMode||t[95]!==f.markdownEditMode||t[96]!==f.onHtmlChange||t[97]!==f.onSaveMarkdown||t[98]!==fe?(pe={markdownEditMode:f.markdownEditMode,onSaveMarkdown:f.onSaveMarkdown,htmlCodeMode:f.htmlCodeMode,onHtmlChange:f.onHtmlChange,isDark:fe},t[94]=f.htmlCodeMode,t[95]=f.markdownEditMode,t[96]=f.onHtmlChange,t[97]=f.onSaveMarkdown,t[98]=fe,t[99]=pe):pe=t[99];let me;t[100]===f?me=t[101]:(me=()=>void f.onDownload(),t[100]=f,t[101]=me);let he;t[102]===f?he=t[103]:(he=()=>void f.onOpenWithSystemApp(),t[102]=f,t[103]=he);let ge;t[104]!==f.canDownload||t[105]!==f.canOpenWithSystemApp||t[106]!==me||t[107]!==he?(ge={onDownload:me,canDownload:f.canDownload,onOpenWithSystemApp:he,canOpenWithSystemApp:f.canOpenWithSystemApp},t[104]=f.canDownload,t[105]=f.canOpenWithSystemApp,t[106]=me,t[107]=he,t[108]=ge):ge=t[108];let _e;t[109]!==n||t[110]!==o||t[111]!==k||t[112]!==l||t[113]!==f.binaryBuffer||t[114]!==f.loadError||t[115]!==f.loading||t[116]!==f.pptxError||t[117]!==f.pptxText||t[118]!==f.pptxTruncated||t[119]!==f.previewKind||t[120]!==f.textContent||t[121]!==pe||t[122]!==ge?(_e=(0,Z.jsx)(RX,{context:`workspace`,language:o,resolvedTheme:l,fileKey:n,fileName:k,loading:f.loading,loadError:f.loadError,previewKind:f.previewKind,textContent:f.textContent,binaryBuffer:f.binaryBuffer,pptxText:f.pptxText,pptxTruncated:f.pptxTruncated,pptxError:f.pptxError,workspaceEditing:pe,actions:ge}),t[109]=n,t[110]=o,t[111]=k,t[112]=l,t[113]=f.binaryBuffer,t[114]=f.loadError,t[115]=f.loading,t[116]=f.pptxError,t[117]=f.pptxText,t[118]=f.pptxTruncated,t[119]=f.previewKind,t[120]=f.textContent,t[121]=pe,t[122]=ge,t[123]=_e):_e=t[123];let ye;t[124]!==p||t[125]!==de||t[126]!==_e?(ye=(0,Z.jsxs)(`div`,{ref:p,className:`flex h-full min-h-0 flex-col bg-surface-panel`,children:[de,_e]}),t[124]=p,t[125]=de,t[126]=_e,t[127]=ye):ye=t[127];let be;t[128]!==v||t[129]!==x||t[130]!==C||t[131]!==y||t[132]!==b?(be=(0,Z.jsx)(UZ,{open:v,onOpenChange:C,loading:y,error:x,result:b}),t[128]=v,t[129]=x,t[130]=C,t[131]=y,t[132]=b,t[133]=be):be=t[133];let xe;return t[134]!==ye||t[135]!==be?(xe=(0,Z.jsxs)(Z.Fragment,{children:[ye,be]}),t[134]=ye,t[135]=be,t[136]=xe):xe=t[136],xe}function Qme(e){return!e}function $me(e){return!e}function ehe(e){return e.resolved}function the(e){return e.language}function nhe(e,t){let n=globalThis.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)}function rhe(e){return globalThis.matchMedia(e).matches}function t8(e,t){let n=(0,Y.c)(5),r=t===void 0?!1:t,i,a;n[0]===e?(i=n[1],a=n[2]):(i=t=>nhe(e,t),a=()=>rhe(e),n[0]=e,n[1]=i,n[2]=a);let o;return n[3]===r?o=n[4]:(o=()=>r,n[3]=r,n[4]=o),(0,J.useSyncExternalStore)(i,a,o)}var ihe=`(min-width: 768px)`,ahe=`(min-width: 1024px)`;function ohe(){let e=(0,Y.c)(6),t=Cj(uhe),n=Cj(lhe),r=cQ(che),i=cQ(she),a=t8(ihe,!0),o=t8(ahe,!0),s;bb0:{if(!a){let t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={top:`0`,left:`0`,right:`0`,bottom:`0`},e[0]=t):t=e[0],s=t;break bb0}let c=r?`${i}px`:`0`;if(!o){let t;e[1]===c?t=e[2]:(t={top:`0`,left:`0`,right:c,bottom:`0`},e[1]=c,e[2]=t),s=t;break bb0}let l=t?`4.5rem`:`${n}px`,u;e[3]!==l||e[4]!==c?(u={top:`0`,left:l,right:c,bottom:`0`},e[3]=l,e[4]=c,e[5]=u):u=e[5],s=u}return s}function she(e){return e.widthPx}function che(e){return e.open}function lhe(e){return e.expandedWidthPx}function uhe(e){return e.collapsed}var dhe=(0,J.memo)(function(){let e=(0,Y.c)(41),{pathname:t}=Yr(),{sessionKey:n}=ni(),r;e[0]!==t||e[1]!==n?(r=t.startsWith(`/chat`)&&n?decodeURIComponent(n):void 0,e[0]=t,e[1]=n,e[2]=r):r=e[2];let i=r,a=lQ(fhe),o=lQ(phe),s=eQ(mhe),c=ohe(),l=!!a,u,d;e[3]!==t||e[4]!==o?(u=()=>{t.startsWith(`/chat`)||o(null)},d=[t,o],e[3]=t,e[4]=o,e[5]=u,e[6]=d):(u=e[5],d=e[6]),(0,J.useEffect)(u,d);let f;e[7]!==c.bottom||e[8]!==c.left||e[9]!==c.right||e[10]!==c.top?(f={top:c.top,left:c.left,right:c.right,bottom:c.bottom},e[7]=c.bottom,e[8]=c.left,e[9]=c.right,e[10]=c.top,e[11]=f):f=e[11];let p=f,m;e[12]===o?m=e[13]:(m=e=>!e&&o(null),e[12]=o,e[13]=m);let h;e[14]===p?h=e[15]:(h=(0,Z.jsx)(ie,{className:`xopc-dialog-overlay fixed z-[65] bg-scrim`,style:p}),e[14]=p,e[15]=h);let g;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(g=X(`xopc-dialog-content-pane fixed z-[66] flex min-h-0 flex-col overflow-hidden border border-edge bg-surface-panel shadow-popover outline-none`,`dark:border-edge`),e[16]=g):g=e[16];let _;e[17]===a?_=e[18]:(_=a?fU(a):`Preview`,e[17]=a,e[18]=_);let v;e[19]===_?v=e[20]:(v=(0,Z.jsx)(ue,{className:`sr-only`,children:_}),e[19]=_,e[20]=v);let y;e[21]===s?y=e[22]:(y=s.trim()||void 0,e[21]=s,e[22]=y);let b;e[23]===o?b=e[24]:(b=()=>o(null),e[23]=o,e[24]=b);let x;e[25]!==i||e[26]!==a||e[27]!==b||e[28]!==y?(x=(0,Z.jsx)(Zme,{filePath:a,sessionKey:i,agentId:y,onClose:b}),e[25]=i,e[26]=a,e[27]=b,e[28]=y,e[29]=x):x=e[29];let S;e[30]!==p||e[31]!==x||e[32]!==v?(S=(0,Z.jsxs)(se,{className:g,style:p,"aria-describedby":void 0,children:[v,x]}),e[30]=p,e[31]=x,e[32]=v,e[33]=S):S=e[33];let C;e[34]!==S||e[35]!==h?(C=(0,Z.jsxs)(G,{children:[h,S]}),e[34]=S,e[35]=h,e[36]=C):C=e[36];let w;return e[37]!==l||e[38]!==C||e[39]!==m?(w=(0,Z.jsx)(q,{open:l,onOpenChange:m,children:C}),e[37]=l,e[38]=C,e[39]=m,e[40]=w):w=e[40],w});function fhe(e){return e.path}function phe(e){return e.setPath}function mhe(e){return e.agentId}async function n8(){let e=await FR(_(`/api/models`));if(!e.ok)throw Error(`Models: HTTP ${e.status}`);return(await e.json()).payload?.models??[]}var r8=null,i8=0,a8=null,o8=6e4,s8=`gateway-configured-models`;async function hhe(){r8=null,i8=0;let{mutate:e}=await D(async()=>{let{mutate:e}=await import(`./vendor-swr-BIWyz7Rc.js`).then(e=>e.r);return{mutate:e}},__vite__mapDeps([5,1,3]));await e(s8)}async function c8(e=!1){if(!e&&r8&&Date.now()<i8)return r8;if(e){let e=await n8();return r8=e,i8=Date.now()+o8,e}return a8||(a8=n8().then(e=>(r8=e,i8=Date.now()+o8,e)).finally(()=>{a8=null}),a8)}function ghe(e){let t=(0,Y.c)(9),{models:n,selectedId:r,onSelectedChange:i}=e;if(n.length===0)return null;let a;if(t[0]!==n||t[1]!==i||t[2]!==r){let e;t[4]!==i||t[5]!==r?(e=e=>{let t=r===e.id;return(0,Z.jsxs)(`label`,{className:X(`flex cursor-pointer items-start gap-3 rounded-xl border border-edge px-3 py-2.5 transition-colors`,t?`border-accent bg-accent-soft`:`hover:bg-surface-hover`),children:[(0,Z.jsx)(`input`,{type:`radio`,name:`onboarding-model`,className:`mt-1`,checked:t,onChange:()=>i(e.id),"aria-label":e.name||e.id}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.name||e.id}),(0,Z.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:e.id})]})]},e.id)},t[4]=i,t[5]=r,t[6]=e):e=t[6],a=n.map(e),t[0]=n,t[1]=i,t[2]=r,t[3]=a}else a=t[3];let o;return t[7]===a?o=t[8]:(o=(0,Z.jsx)(`div`,{className:`flex max-h-[min(50vh,22rem)] flex-col gap-2 overflow-y-auto pr-1`,role:`radiogroup`,children:a}),t[7]=a,t[8]=o),o}function l8(e){let t=(0,Y.c)(10),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=X(`shrink-0`,r),t[4]=r,t[5]=a);let o;return t[6]!==n||t[7]!==i||t[8]!==a?(o=(0,Z.jsx)(`svg`,{viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,className:a,...i,children:n}),t[6]=n,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function _he(e){let t=(0,Y.c)(7),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]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`path`,{fill:`#4D6BFE`,d:`M12.63 5.43c-.377-.222-.676-.093-.676.28v1.63c0 .55.18 1.8.52 1.52l.026.03 3.99 2.28 6.43 2.14 1.48-.085 3.13-.284 4.99-1.86.47.23.96.32 1.78.39.63.05 1.23-.031 1.70-.129.73-.155.68-.836.41-.961-2.15-1.00-1.68-.595-2.11-.926 1.09-1.29 2.76-3.59 3.28-6.73.05-.346.11-.834.10-1.11-.004-.171.03-.238.23-.257a4.2 4.2 0 0 0 1.54-.475c1.39-.763 1.96-2.01 2.09-3.51.02-.23-.004-.467-.247-.588M11.58 18.16c-2.08-1.64-3.10-2.18-3.52-2.16-.39.02-.32.47-.234.76.09.28.21.48.37.74.11.17.19.42-.113.60-.673.41-1.84-.14-1.89-.168-1.36-.801-2.5-1.86-3.30-3.30-.775-1.39-1.22-2.88-1.29-4.48-.02-.385.09-.522.47-.592a4.7 4.7 0 0 1 1.53-.038c2.13.31 3.94 1.26 5.46 2.77.87.86 1.52 1.88 2.20 2.89.72 1.06 1.49 2.08 2.48 2.91.35.29.63.51.89.67-.802.09-2.14.10-3.05-.615zm1.00-6.44a.306.30 0 0 1 .415-.287.3.3 0 0 1 .113.07.3.3 0 0 1 .086.21c0 .17-.136.30-.308.30a.303.30 0 0 1-.306-.307m3.11 1.59c-.2.08-.4.15-.591.16a1.25 1.25 0 0 1-.798-.254c-.274-.23-.47-.358-.551-.758a1.7 1.7 0 0 1 .015-.588c.07-.327-.007-.537-.238-.727-.188-.156-.426-.199-.689-.199a.6.6 0 0 1-.254-.078.25.25 0 0 1-.114-.358 1 1 0 0 1 .192-.21c.356-.202.76-.136 1.14.02.35.14.61.41 1.0.78.39.45.46.58.68.92.17.26.33.54.44.85.6.19-.02.35-.25.45`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,Z.jsx)(l8,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function vhe(e){let t=(0,Y.c)(7),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]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`path`,{fill:`currentColor`,d:`M11.43 3.92a.86.86 0 1 0-1.71 0v14.23a1.99 1.99 0 0 1-3.99 0V9.02a.86.86 0 1 0-1.71 0v3.87a1.99 1.99 0 0 1-3.99 0V11.49a.57.57 0 0 1 1.13 0v1.40a.86.86 0 0 0 1.71 0V9.02a1.99 1.99 0 0 1 3.99 0v9.13a.86.86 0 0 0 1.71 0V3.92a1.99 1.99 0 1 1 3.99 0v11.78a.57.57 0 1 1-1.13 0zm10.57 3.10a2 2 0 0 0-1.99 1.99v7.63a.86.86 0 0 1-1.71 0V3.92a1.99 1.99 0 0 0-3.99 0v16.16a.86.86 0 0 1-1.71 0V18.08a.57.57 0 1 0-1.13 0v2a1.99 1.99 0 0 0 3.99 0V3.92a.86.86 0 0 1 1.71 0v12.73a1.99 1.99 0 0 0 3.99 0V9.02a.86.86 0 1 1 1.72 0v6.68a.57.57 0 0 0 1.13 0V9.02a2 2 0 0 0-1.99-1.99`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,Z.jsx)(l8,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function u8(e){let t=(0,Y.c)(7),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]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`path`,{fill:`#1A1A2E`,d:`m1.05 16.91 9.53 2.55a21 20.98 0 0 0 .06 2.03l5.95 1.59a12 11.99 0 0 1-15.55-6.17m-1.02-5.79 11.35 3.03a21 20.98 0 0 0-.469 2.01l10.81 2.89a12 11.99 0 0 1-1.84 2.00L.658 15.91a12 11.99 0 0 1-.625-4.79m1.59-5.14L13.57 9.17a21 20.98 0 0 0-1.01 1.87l11.29 3.02a21 20.98 0 0 1-.67 2.36l-11.55-3.08L.125 10.26a12 11.99 0 0 1 1.49-4.28ZM6.06 1.58l11.28 3.01a21 20.98 0 0 0-1.68 1.71l7.82 2.09a21 20.98 0 0 1 .513 2.66L2.10 5.21a12 11.99 0 0 1 3.96-3.63M21.68 4.86 7.22 1.00A12 11.99 0 0 1 21.68 4.86`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,Z.jsx)(l8,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function yhe(e){let t=(0,Y.c)(7),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]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`path`,{fill:`currentColor`,d:`M22.28 9.82a5.98 5.98 0 0 0-.516-4.91 6.04 6.04 0 0 0-6.51-2.9A6.06 6.06 0 0 0 4.98 4.18a5.98 5.98 0 0 0-3.99 2.9 6.04 6.04 0 0 0 .743 7.09 5.98 5.98 0 0 0 .511 4.91 6.05 6.05 0 0 0 6.51 2.9A5.98 5.98 0 0 0 13.26 24a6.05 6.05 0 0 0 5.77-4.20 5.98 5.98 0 0 0 3.99-2.9 6.05 6.05 0 0 0-.748-7.07zm-9.02 12.60a4.47 4.47 0 0 1-2.87-1.04l.142-.08 4.77-2.75a.795.79 0 0 0 .393-.681v-6.73l2.02 1.16a.071.07 0 0 1 .038.05v5.58a4.50 4.50 0 0 1-4.49 4.49zm-9.66-4.12a4.47 4.47 0 0 1-.535-3.01l.142.08 4.78 2.75a.771.77 0 0 0 .781 0l5.84-3.36v2.33a.08.08 0 0 1-.033.06L9.74 19.95a4.49 4.49 0 0 1-6.14-1.64zM2.34 7.89a4.48 4.48 0 0 1 2.36-1.97V11.6a.766.76 0 0 0 .388.67l5.81 3.35-2.02 1.16a.076.07 0 0 1-.071 0l-4.83-2.78A4.50 4.50 0 0 1 2.34 7.87zm16.59 3.85L13.10 8.36 15.11 7.2a.076.07 0 0 1 .071 0l4.83 2.79a4.49 4.49 0 0 1-.677 8.10v-5.67a.79.79 0 0 0-.407-.667zm2.01-3.02-.142-.085-4.77-2.78a.776.77 0 0 0-.785 0L9.40 9.23V6.89a.066.06 0 0 1 .028-.062l4.83-2.78a4.49 4.49 0 0 1 6.68 4.66zM8.30 12.86l-2.02-1.16a.08.08 0 0 1-.038-.057V6.07a4.49 4.49 0 0 1 7.37-3.45l-.142.08L8.70 5.45a.795.79 0 0 0-.393.68zm1.09-2.36 2.60-1.5 2.60 1.5v2.99l-2.59 1.5-2.60-1.5Z`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,Z.jsx)(l8,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function bhe(e){let t=(0,Y.c)(7),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]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`path`,{fill:`#D4A27F`,d:`M17.30 3.54h-3.67l6.69 16.91H24Zm-10.60 0L0 20.45h3.74l1.36-3.55h7.00l1.36 3.55h3.74L10.53 3.54Zm-.371 10.22 2.29-5.94 2.29 5.94Z`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,Z.jsx)(l8,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function xhe(e){let t=(0,Y.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,a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`defs`,{children:(0,Z.jsxs)(`linearGradient`,{id:`gemini-grad`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,Z.jsx)(`stop`,{offset:`0%`,stopColor:`#4285F4`}),(0,Z.jsx)(`stop`,{offset:`50%`,stopColor:`#9B72CB`}),(0,Z.jsx)(`stop`,{offset:`100%`,stopColor:`#D96570`})]})}),a=(0,Z.jsx)(`path`,{fill:`url(#gemini-grad)`,d:`M11.04 19.32Q12 21.51 12 24q0-2.49.93-4.68.96-2.19 2.58-3.81t3.81-2.55Q21.51 12 24 12q-2.49 0-4.68-.93a12.3 12.3 0 0 1-3.81-2.58 12.3 12.3 0 0 1-2.58-3.81Q12 2.49 12 0q0 2.49-.96 4.68-.93 2.19-2.55 3.81a12.3 12.3 0 0 1-3.81 2.58Q2.49 12 0 12q2.49 0 4.68.96 2.19.93 3.81 2.55t2.55 3.81`}),t[3]=i,t[4]=a):(i=t[3],a=t[4]);let o;return t[5]!==n||t[6]!==r?(o=(0,Z.jsxs)(l8,{className:n,...r,children:[i,a]}),t[5]=n,t[6]=r,t[7]=o):o=t[7],o}function She(e){let t=(0,Y.c)(20),{providerId:n,className:r}=e,i;t[0]===r?i=t[1]:(i={className:r,"aria-hidden":!0},t[0]=r,t[1]=i);let a=i;switch(n){case`deepseek`:{let e;return t[2]===a?e=t[3]:(e=(0,Z.jsx)(_he,{...a}),t[2]=a,t[3]=e),e}case`minimax`:{let e;return t[4]===a?e=t[5]:(e=(0,Z.jsx)(vhe,{...a}),t[4]=a,t[5]=e),e}case`kimi-coding`:{let e;return t[6]===a?e=t[7]:(e=(0,Z.jsx)(u8,{...a}),t[6]=a,t[7]=e),e}case`moonshotai`:case`moonshotai-cn`:{let e;return t[8]===a?e=t[9]:(e=(0,Z.jsx)(u8,{...a}),t[8]=a,t[9]=e),e}case`openai`:{let e;return t[10]===a?e=t[11]:(e=(0,Z.jsx)(yhe,{...a}),t[10]=a,t[11]=e),e}case`anthropic`:{let e;return t[12]===a?e=t[13]:(e=(0,Z.jsx)(bhe,{...a}),t[12]=a,t[13]=e),e}case`google`:{let e;return t[14]===a?e=t[15]:(e=(0,Z.jsx)(xhe,{...a}),t[14]=a,t[15]=e),e}default:{let e;t[16]===r?e=t[17]:(e=X(`flex items-center justify-center text-2xl`,r),t[16]=r,t[17]=e);let n;return t[18]===e?n=t[19]:(n=(0,Z.jsx)(`span`,{className:e,children:`🤖`}),t[18]=e,t[19]=n),n}}}var Che=[{id:`deepseek`,name:`DeepSeek`,recommended:!0},{id:`minimax`,name:`MiniMax`,recommended:!1},{id:`kimi-coding`,name:`Kimi Coding`,recommended:!1},{id:`openai`,name:`OpenAI`,recommended:!1},{id:`anthropic`,name:`Anthropic`,recommended:!1},{id:`google`,name:`Google AI`,recommended:!1}];function whe(e){let t=(0,Y.c)(7),{onSelect:n}=e,r=d(The),i;t[0]===r?i=t[1]:(i=m(r),t[0]=r,t[1]=i);let a=i.onboarding.providerRecommended,o;t[2]!==n||t[3]!==a?(o=Che.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),className:X(`relative flex flex-col items-center gap-1.5 rounded-xl border border-edge p-4 text-center transition-colors`,`hover:border-accent hover:bg-accent-soft`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,e.recommended&&`border-accent/50 bg-accent-soft/30`),children:[e.recommended&&(0,Z.jsx)(`span`,{className:`absolute -top-2 right-2 rounded-full bg-accent px-2 py-0.5 text-[10px] font-semibold text-white`,children:a}),(0,Z.jsx)(She,{providerId:e.id,className:`size-8`}),(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.name})]},e.id)),t[2]=n,t[3]=a,t[4]=o):o=t[4];let s;return t[5]===o?s=t[6]:(s=(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3`,children:o}),t[5]=o,t[6]=s),s}function The(e){return e.language}function Ehe(e,t){return e===`single`?t.getApiKey:e===`intl`?t.getApiKeyIntl:t.getApiKeyCn}var d8={openai:{apiKeyUrl:`https://platform.openai.com/api-keys`,pricingUrl:`https://openai.com/pricing`,docsUrl:`https://platform.openai.com/docs`,description:`The most widely used LLM provider. Powers ChatGPT.`,descriptionZh:`最广泛使用的 LLM 服务商,ChatGPT 背后的技术。`,bestFor:[`general`,`coding`,`vision`],freeTier:!1,freeTierNote:`Pay-as-you-go; new accounts may receive trial credits.`,aliases:[`chatgpt`,`gpt`,`gpt-4`,`gpt4`,`gpt-4o`,`gpt4o`],envVars:[`OPENAI_API_KEY`]},anthropic:{apiKeyUrl:`https://console.anthropic.com/settings/keys`,pricingUrl:`https://www.anthropic.com/pricing`,docsUrl:`https://docs.anthropic.com`,description:`Known for Claude — excellent at long documents, coding, and nuanced reasoning.`,descriptionZh:`Claude 系列模型,擅长长文档处理、代码和复杂推理。`,bestFor:[`long context`,`coding`,`reasoning`],freeTier:!1,aliases:[`claude`,`claude 3`,`claude sonnet`,`claude opus`,`claude haiku`],envVars:[`ANTHROPIC_OAUTH_TOKEN`,`ANTHROPIC_API_KEY`]},google:{apiKeyUrl:`https://aistudio.google.com/app/apikey`,pricingUrl:`https://ai.google.dev/pricing`,docsUrl:`https://ai.google.dev/docs`,description:`Google Gemini models — strong multimodal and long-context capabilities.`,descriptionZh:`Google Gemini 系列,多模态能力强,支持超长上下文。`,bestFor:[`multimodal`,`long context`,`general`],freeTier:!0,freeTierNote:`Free tier available via Google AI Studio.`,aliases:[`gemini`,`google gemini`,`bard`,`google ai`],envVars:[`GEMINI_API_KEY`,`GOOGLE_API_KEY`]},"google-vertex":{apiKeyUrl:`https://console.cloud.google.com/apis/credentials`,pricingUrl:`https://cloud.google.com/vertex-ai/pricing`,docsUrl:`https://cloud.google.com/vertex-ai/docs`,description:`Google Vertex AI — enterprise-grade Gemini and other models on GCP.`,descriptionZh:`Google Vertex AI,企业级 GCP 托管模型,支持 Gemini 等。`,bestFor:[`enterprise`,`multimodal`,`compliance`],freeTier:!1,aliases:[`vertex`,`vertex ai`,`gcp`,`google cloud`],envVars:[`GOOGLE_CLOUD_API_KEY`,`GOOGLE_CLOUD_PROJECT`,`GOOGLE_CLOUD_LOCATION`]},"google-gemini-cli":{apiKeyUrl:`https://aistudio.google.com/app/apikey`,pricingUrl:`https://ai.google.dev/pricing`,docsUrl:`https://ai.google.dev/docs`,description:`Gemini via CLI token — for users authenticated with the Gemini CLI tool.`,descriptionZh:`通过 Gemini CLI 令牌访问 Gemini,适合已安装 CLI 工具的用户。`,bestFor:[`general`,`multimodal`],freeTier:!0,freeTierNote:`Uses your existing Gemini CLI authentication.`,aliases:[`gemini cli`,`gemini-cli`],envVars:[`GEMINI_CLI_TOKEN`,`GOOGLE_TOKEN`]},"google-antigravity":{apiKeyUrl:`https://console.cloud.google.com/apis/credentials`,pricingUrl:`https://cloud.google.com/pricing`,docsUrl:`https://cloud.google.com/docs`,description:`Google Antigravity — internal/experimental Google AI endpoint.`,descriptionZh:`Google Antigravity,Google 内部/实验性 AI 端点。`,bestFor:[`experimental`],freeTier:!1,aliases:[`antigravity`,`google antigravity`],envVars:[`ANTIGRAVITY_API_KEY`]},groq:{apiKeyUrl:`https://console.groq.com/keys`,pricingUrl:`https://groq.com/pricing/`,docsUrl:`https://console.groq.com/docs`,description:`Extremely fast inference — ideal for latency-sensitive applications.`,descriptionZh:`推理速度极快,适合对延迟敏感的场景。`,bestFor:[`speed`,`cheap`],freeTier:!0,freeTierNote:`Generous free tier with rate limits.`,aliases:[`groq`,`llama on groq`,`mixtral on groq`],envVars:[`GROQ_API_KEY`]},deepseek:{apiKeyUrl:`https://platform.deepseek.com/api_keys`,pricingUrl:`https://api-docs.deepseek.com/quick_start/pricing/`,docsUrl:`https://platform.deepseek.com/api-docs/`,description:`DeepSeek models — OpenAI-compatible API with strong reasoning and low costs.`,descriptionZh:`DeepSeek 模型:OpenAI 兼容 API,推理强、成本低。`,bestFor:[`reasoning`,`cheap`,`coding`],freeTier:!0,freeTierNote:`Free credits may be available for new accounts.`,aliases:[`deepseek`,`deep seek`,`deepseek v4`,`deepseek-v4`,`r1`],envVars:[`DEEPSEEK_API_KEY`]},xai:{apiKeyUrl:`https://console.x.ai/`,pricingUrl:`https://x.ai/api`,docsUrl:`https://docs.x.ai/`,description:`xAI Grok models — real-time web access, strong reasoning.`,descriptionZh:`xAI Grok 系列,支持实时联网,推理能力强。`,bestFor:[`reasoning`,`real-time`],freeTier:!1,aliases:[`grok`,`xai`,`x.ai`],envVars:[`XAI_API_KEY`]},cerebras:{apiKeyUrl:`https://cloud.cerebras.ai/platform/`,pricingUrl:`https://cloud.cerebras.ai/platform/`,docsUrl:`https://inference-docs.cerebras.ai/`,description:`Ultra-fast inference on custom AI chips. Fastest Llama inference available.`,descriptionZh:`基于专用 AI 芯片的超快推理,Llama 推理速度业界最快。`,bestFor:[`speed`],freeTier:!0,freeTierNote:`Free tier available.`,aliases:[`cerebras`],envVars:[`CEREBRAS_API_KEY`]},mistral:{apiKeyUrl:`https://console.mistral.ai/api-keys/`,pricingUrl:`https://mistral.ai/technology/#pricing`,docsUrl:`https://docs.mistral.ai/`,description:`European open-weight models. Good balance of quality and cost.`,descriptionZh:`欧洲开源模型,质量与成本平衡好。`,bestFor:[`general`,`cheap`,`coding`],freeTier:!1,aliases:[`mistral`,`mixtral`,`codestral`],envVars:[`MISTRAL_API_KEY`]},openrouter:{apiKeyUrl:`https://openrouter.ai/keys`,pricingUrl:`https://openrouter.ai/models`,docsUrl:`https://openrouter.ai/docs`,description:`API gateway to 100+ models from many providers with a single key.`,descriptionZh:`统一 API 网关,一个 Key 访问 100+ 模型。`,bestFor:[`general`,`flexibility`],freeTier:!0,freeTierNote:`Some models are free; pay-per-use for others.`,aliases:[`openrouter`,`open router`],envVars:[`OPENROUTER_API_KEY`]},"azure-openai-responses":{apiKeyUrl:`https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/OpenAI`,pricingUrl:`https://azure.microsoft.com/en-us/pricing/details/cognitive-services/openai-service/`,docsUrl:`https://learn.microsoft.com/en-us/azure/ai-services/openai/`,description:`OpenAI models hosted on Azure. Enterprise SLA and data residency.`,descriptionZh:`Azure 托管的 OpenAI 模型,企业级 SLA 和数据合规。`,bestFor:[`enterprise`,`compliance`,`coding`],freeTier:!1,aliases:[`azure`,`azure openai`,`aoai`],envVars:[`AZURE_OPENAI_API_KEY`,`AZURE_OPENAI_BASE_URL`]},"amazon-bedrock":{apiKeyUrl:`https://console.aws.amazon.com/iam/home#/security_credentials`,pricingUrl:`https://aws.amazon.com/bedrock/pricing/`,docsUrl:`https://docs.aws.amazon.com/bedrock/`,description:`AWS-hosted models including Claude, Llama, Titan. Enterprise-grade.`,descriptionZh:`AWS 托管模型,包含 Claude、Llama 等,企业级可靠性。`,bestFor:[`enterprise`,`compliance`],freeTier:!1,aliases:[`bedrock`,`aws`,`amazon`],envVars:[`AWS_ACCESS_KEY_ID`,`AWS_SECRET_ACCESS_KEY`,`AWS_REGION`]},minimax:{apiKeyUrl:`https://platform.minimax.io/user-center/basic-information/interface-key`,pricingUrl:`https://platform.minimax.io/docs/guides/models-intro`,docsUrl:`https://platform.minimax.io/docs/guides/quickstart-preparation`,description:`MiniMax — Chinese multimodal model with strong text and audio capabilities.`,descriptionZh:`MiniMax,国产多模态模型,文本和音频能力强。`,bestFor:[`multimodal`,`chinese`],freeTier:!0,freeTierNote:`注册赠送免费额度。`,aliases:[`minimax`,`mini max`,`abab`],envVars:[`MINIMAX_API_KEY`]},"minimax-cn":{apiKeyUrl:`https://platform.minimaxi.com/user-center/basic-information/interface-key`,pricingUrl:`https://platform.minimaxi.com/document/Price`,docsUrl:`https://platform.minimaxi.com/document/Announcement`,description:`MiniMax (China endpoint) — domestic access for Chinese users.`,descriptionZh:`MiniMax 国内端点,国内用户直连访问。`,bestFor:[`multimodal`,`chinese`],freeTier:!0,freeTierNote:`注册赠送免费额度。`,aliases:[`minimax cn`,`minimax china`,`abab`],envVars:[`MINIMAX_CN_API_KEY`,`MINIMAX_API_KEY`]},"kimi-coding":{apiKeyUrl:`https://platform.kimi.com/console/api-keys`,pricingUrl:`https://platform.kimi.com/docs/pricing/chat`,docsUrl:`https://platform.kimi.com/docs`,description:`Kimi Coding — Moonshot model optimized for code generation tasks.`,descriptionZh:`Kimi Coding,Moonshot 专为代码生成优化的模型。`,bestFor:[`coding`,`chinese`],freeTier:!0,freeTierNote:`注册赠送免费额度。`,aliases:[`kimi coding`,`moonshot coding`,`kimi code`],envVars:[`KIMI_API_KEY`,`MOONSHOT_API_KEY`]},moonshotai:{apiKeyUrl:`https://platform.moonshot.ai/console/api-keys`,pricingUrl:`https://platform.moonshot.ai/docs/pricing`,docsUrl:`https://platform.moonshot.ai/docs`,description:`Moonshot Kimi — international API (api.moonshot.ai).`,descriptionZh:`月之暗面 Kimi 国际版 API(api.moonshot.ai)。`,bestFor:[`coding`,`chinese`,`long context`],freeTier:!0,aliases:[`moonshot`,`kimi`,`moonshot ai`],envVars:[`MOONSHOT_API_KEY`]},"moonshotai-cn":{apiKeyUrl:`https://platform.moonshot.cn/console/api-keys`,pricingUrl:`https://platform.moonshot.cn/docs/pricing/chat`,docsUrl:`https://platform.moonshot.cn/docs`,description:`Moonshot Kimi — China region endpoint.`,descriptionZh:`月之暗面 Kimi 中国区域端点。`,bestFor:[`coding`,`chinese`,`long context`],freeTier:!0,aliases:[`moonshot cn`,`kimi cn`],envVars:[`MOONSHOT_API_KEY`]},fal:{apiKeyUrl:`https://fal.ai/dashboard/keys`,pricingUrl:`https://fal.ai/pricing`,docsUrl:`https://fal.ai/docs`,description:`fal — serverless image and media generation APIs.`,descriptionZh:`fal:无服务器图像与媒体生成 API。`,bestFor:[`image`,`video`],freeTier:!0,aliases:[`fal ai`,`fal.ai`],envVars:[`FAL_KEY`,`FAL_API_KEY`]},fireworks:{apiKeyUrl:`https://fireworks.ai/account/api-keys`,pricingUrl:`https://fireworks.ai/pricing`,docsUrl:`https://docs.fireworks.ai`,description:`Fireworks AI — fast inference for open and proprietary models.`,descriptionZh:`Fireworks AI,多种开源与商业模型的高速推理服务。`,bestFor:[`speed`,`coding`,`open weights`],freeTier:!0,aliases:[`fireworks ai`,`fireworks`],envVars:[`FIREWORKS_API_KEY`]},together:{apiKeyUrl:`https://api.together.xyz/settings/api-keys`,pricingUrl:`https://www.together.ai/pricing`,docsUrl:`https://docs.together.ai`,description:`Together AI — hosted Llama, Qwen, DeepSeek, and more.`,descriptionZh:`Together AI,托管 Llama、Qwen、DeepSeek 等模型。`,bestFor:[`open source`,`flexibility`],freeTier:!0,aliases:[`together ai`,`together.xyz`],envVars:[`TOGETHER_API_KEY`]},"cloudflare-workers-ai":{apiKeyUrl:`https://dash.cloudflare.com/?to=/:account/ai/workers-ai`,pricingUrl:`https://developers.cloudflare.com/workers-ai/platform/pricing/`,docsUrl:`https://developers.cloudflare.com/workers-ai/`,description:`Cloudflare Workers AI — models at the edge via Cloudflare API.`,descriptionZh:`Cloudflare Workers AI,通过 Cloudflare API 在边缘运行模型。`,bestFor:[`edge`,`latency`],freeTier:!0,aliases:[`workers ai`,`cf workers ai`],envVars:[`CLOUDFLARE_API_KEY`]},"cloudflare-ai-gateway":{apiKeyUrl:`https://dash.cloudflare.com/?to=/:account/ai/ai-gateway`,pricingUrl:`https://developers.cloudflare.com/ai-gateway/pricing/`,docsUrl:`https://developers.cloudflare.com/ai-gateway/`,description:`Cloudflare AI Gateway — unified OpenAI/Anthropic-compatible routing.`,descriptionZh:`Cloudflare AI Gateway,统一 OpenAI/Anthropic 兼容路由。`,bestFor:[`routing`,`observability`,`enterprise`],freeTier:!0,aliases:[`cf ai gateway`,`cloudflare gateway`],envVars:[`CLOUDFLARE_API_KEY`]},xiaomi:{apiKeyUrl:`https://platform.xiaomimimo.com/#/console/api-keys`,pricingUrl:`https://mimo.mi.com/`,docsUrl:`https://platform.xiaomimimo.com/`,description:`Xiaomi MiMo — API billing (Anthropic-compatible). Keys from the MiMo open platform; endpoint api.xiaomimimo.com.`,descriptionZh:`小米 MiMo 按量计费线路(Anthropic 兼容),在开放平台创建密钥;接口域名为 api.xiaomimimo.com。`,bestFor:[`general`,`coding`],freeTier:!1,aliases:[`xiaomi`,`mimo`,`小米`,`xiaomimimo`],envVars:[`XIAOMI_API_KEY`]},"xiaomi-token-plan-cn":{apiKeyUrl:`https://platform.xiaomimimo.com/#/console/api-keys`,pricingUrl:`https://mimo.mi.com/`,docsUrl:`https://platform.xiaomimimo.com/`,description:`Xiaomi MiMo Token Plan — China region (token-plan-cn.xiaomimimo.com).`,descriptionZh:`小米 MiMo Token 套餐 · 中国区(token-plan-cn.xiaomimimo.com)。`,bestFor:[`general`,`coding`],freeTier:!1,aliases:[`xiaomi token cn`,`mimo token cn`],envVars:[`XIAOMI_TOKEN_PLAN_CN_API_KEY`]},"xiaomi-token-plan-ams":{apiKeyUrl:`https://platform.xiaomimimo.com/#/console/api-keys`,pricingUrl:`https://mimo.mi.com/`,docsUrl:`https://platform.xiaomimimo.com/`,description:`Xiaomi MiMo Token Plan — Amsterdam region (token-plan-ams.xiaomimimo.com).`,descriptionZh:`小米 MiMo Token 套餐 · 阿姆斯特丹(token-plan-ams.xiaomimimo.com)。`,bestFor:[`general`,`coding`],freeTier:!1,aliases:[`xiaomi token ams`,`mimo token ams`],envVars:[`XIAOMI_TOKEN_PLAN_AMS_API_KEY`]},"xiaomi-token-plan-sgp":{apiKeyUrl:`https://platform.xiaomimimo.com/#/console/api-keys`,pricingUrl:`https://mimo.mi.com/`,docsUrl:`https://platform.xiaomimimo.com/`,description:`Xiaomi MiMo Token Plan — Singapore region (token-plan-sgp.xiaomimimo.com).`,descriptionZh:`小米 MiMo Token 套餐 · 新加坡(token-plan-sgp.xiaomimimo.com)。`,bestFor:[`general`,`coding`],freeTier:!1,aliases:[`xiaomi token sgp`,`mimo token sgp`],envVars:[`XIAOMI_TOKEN_PLAN_SGP_API_KEY`]},huggingface:{apiKeyUrl:`https://huggingface.co/settings/tokens`,pricingUrl:`https://huggingface.co/pricing`,docsUrl:`https://huggingface.co/docs/api-inference/`,description:`Access thousands of open-source models via Hugging Face Inference API.`,descriptionZh:`通过 Hugging Face 访问数千个开源模型。`,bestFor:[`open source`,`flexibility`],freeTier:!0,freeTierNote:`Free tier with rate limits.`,aliases:[`huggingface`,`hugging face`,`hf`],envVars:[`HF_TOKEN`,`HUGGINGFACE_TOKEN`]},opencode:{apiKeyUrl:`https://opencode.ai/auth`,pricingUrl:`https://opencode.ai/docs`,docsUrl:`https://opencode.ai/docs/providers/`,description:`OpenCode — AI coding assistant provider.`,descriptionZh:`OpenCode,AI 代码助手服务商。`,bestFor:[`coding`],freeTier:!1,aliases:[`opencode`,`open code`],envVars:[`OPENCODE_API_KEY`]},"opencode-go":{apiKeyUrl:`https://opencode.ai/auth`,pricingUrl:`https://opencode.ai/docs`,docsUrl:`https://opencode.ai/docs/providers/`,description:`OpenCode Go — AI coding assistant provider (Go variant).`,descriptionZh:`OpenCode Go,AI 代码助手服务商(Go 版本)。`,bestFor:[`coding`],freeTier:!1,aliases:[`opencode go`,`opencode-go`],envVars:[`OPENCODE_API_KEY`]},zai:{apiKeyUrl:`https://z.ai/manage-apikey/apikey-list`,pricingUrl:`https://z.ai/manage-apikey/billing`,docsUrl:`https://docs.z.ai/guides/overview/quick-start`,description:`01.AI Yi models — strong multilingual capabilities.`,descriptionZh:`零一万物 Yi 系列模型,多语言能力强。`,bestFor:[`general`,`chinese`],freeTier:!1,aliases:[`yi`,`01.ai`,`zero one`,`零一万物`],envVars:[`ZAI_API_KEY`]},dashscope:{apiKeyUrl:`https://modelstudio.console.alibabacloud.com/`,apiKeyUrlCn:`https://dashscope.console.aliyun.com/apiKey`,pricingUrl:`https://help.aliyun.com/zh/dashscope/developer-reference/tongyi-thousand-questions-metering-and-billing`,docsUrl:`https://help.aliyun.com/zh/dashscope/`,description:"Alibaba DashScope — image generation, speech, and STT HTTP APIs (service id `dashscope`, not a pi-ai LLM provider).",descriptionZh:`阿里 DashScope:文生图、语音等 HTTP API(服务 id 为 dashscope,非 pi-ai 内置 LLM)。`,bestFor:[`image`,`speech`,`chinese`],freeTier:!0,aliases:[`dash scope`,`alibaba dashscope`],envVars:[`DASHSCOPE_API_KEY`]},"vercel-ai-gateway":{apiKeyUrl:`https://vercel.com/account/tokens`,pricingUrl:`https://vercel.com/pricing`,docsUrl:`https://vercel.com/docs/ai/ai-gateway`,description:`Vercel AI Gateway — route requests to multiple LLM providers via Vercel.`,descriptionZh:`Vercel AI Gateway,通过 Vercel 路由请求到多个 LLM 服务商。`,bestFor:[`flexibility`,`enterprise`],freeTier:!1,aliases:[`vercel gateway`,`vercel ai gateway`],envVars:[`AI_GATEWAY_API_KEY`,`VERCEL_AI_GATEWAY_API_KEY`]},"github-copilot":{apiKeyUrl:`https://github.com/settings/tokens`,pricingUrl:`https://github.com/features/copilot#pricing`,docsUrl:`https://docs.github.com/en/copilot`,description:`GitHub Copilot — use your GitHub token to access Copilot models.`,descriptionZh:`使用 GitHub 令牌访问 Copilot 模型。`,bestFor:[`coding`],freeTier:!0,freeTierNote:`Free for verified students and open-source maintainers.`,aliases:[`github copilot`,`copilot`,`github`],envVars:[`COPILOT_GITHUB_TOKEN`,`GH_TOKEN`,`GITHUB_TOKEN`,`GITHUB_COPILOT_TOKEN`]}};function Dhe(e,t){let n=d8[e];if(!n)return[];let r=n.apiKeyUrl,i=n.apiKeyUrlCn;return r&&i?t===`zh`?[{href:i,kind:`cn`},{href:r,kind:`intl`}]:[{href:r,kind:`intl`},{href:i,kind:`cn`}]:r?[{href:r,kind:`single`}]:i?[{href:i,kind:`single`}]:[]}function Ohe(e){return e===`***`||e===`••••••••••••`||/^•+$/.test(e)}async function khe(){return(await we(_(`/api/providers/meta`))).payload?.providers??[]}function Ahe(e){if(!e||typeof e!=`object`||!(`providers`in e))return{};let t=e.providers;if(!t||typeof t!=`object`||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t))typeof r==`string`&&(n[e]=r);return n}function jhe(e,t,n){let r=new Set(n.map(e=>e.provider));return e.map(e=>({...e,configured:e.configured||r.has(e.id),apiKey:t[e.id]||(e.configured||r.has(e.id)?`***`:``)}))}async function f8(e){await we(_(`/api/config`),{method:`PATCH`,body:JSON.stringify({providers:e})}),Promise.all([mL(),b(_(`/api/providers/meta`))])}async function Mhe(e){await we(_(`/api/providers/${encodeURIComponent(e)}/key`),{method:`DELETE`}),Promise.all([mL(),b(_(`/api/providers/meta`))])}async function Nhe(e){return(await we(_(`/api/models-json/test-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({value:e})})).payload??{type:`literal`,error:`No response`}}var Phe={step:`provider`,selectedProvider:null,apiKey:``,busy:!1,error:null,models:[],selectedModelId:null,modelsLoading:!1};function Fhe(e,t){switch(t.type){case`patch`:return{...e,...t.patch};case`reset-models`:return{...e,models:[],selectedModelId:null}}}function Ihe({onComplete:e,onDismiss:t}){let n=d(e=>e.language),r=m(n).onboarding,[i,a]=(0,J.useReducer)(Fhe,Phe),{step:o,selectedProvider:s,apiKey:c,busy:l,error:u,models:f,selectedModelId:p,modelsLoading:h}=i,g=(0,J.useMemo)(()=>r.stepOf.replace(`{{current}}`,String(o===`provider`?1:o===`apiKey`?2:3)).replace(`{{total}}`,`3`),[r.stepOf,o]),v=(0,J.useCallback)(async e=>{a({type:`patch`,patch:{modelsLoading:!0,error:null}});try{let t=(await c8(!0)).filter(t=>t.provider===e);a({type:`patch`,patch:{models:t,selectedModelId:t[0]?.id??null}})}catch(e){a({type:`patch`,patch:{error:e instanceof Error?e.message:String(e),models:[],selectedModelId:null}})}finally{a({type:`patch`,patch:{modelsLoading:!1}})}},[]),y=async()=>{if(!(!s||!c.trim())){a({type:`patch`,patch:{busy:!0,error:null}});try{await f8({[s]:c.trim()}),await v(s),a({type:`patch`,patch:{step:`model`}})}catch(e){a({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{busy:!1}})}}},b=async()=>{if(!s||!p)return;let t=f.find(e=>e.id===p)?.id??p;a({type:`patch`,patch:{busy:!0,error:null}});try{await we(_(`/api/config`),{method:`PATCH`,body:JSON.stringify({agents:{defaults:{model:t}}})}),mL(),hhe(),P1(),e()}catch(e){a({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{busy:!1}})}};return(0,Z.jsxs)(`div`,{className:`w-full max-w-xl rounded-2xl border border-edge bg-surface-panel p-6 shadow-elevated`,children:[(0,Z.jsxs)(`div`,{className:`text-center`,children:[(0,Z.jsx)(`div`,{className:`text-3xl`,"aria-hidden":!0,children:`🤖`}),(0,Z.jsx)(`h2`,{className:`mt-3 text-lg font-semibold tracking-tight text-fg`,children:r.title}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle}),(0,Z.jsx)(`p`,{className:`mt-2 text-xs font-medium uppercase tracking-wide text-fg-muted`,children:g})]}),(0,Z.jsxs)(`div`,{className:`mt-6`,children:[o===`provider`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-base font-medium text-fg`,children:r.step1Title}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.step1Subtitle})]}),(0,Z.jsx)(whe,{onSelect:e=>{a({type:`patch`,patch:{selectedProvider:e,step:`apiKey`,apiKey:``,error:null}})}}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 pt-2`,children:[(0,Z.jsx)(ja,{to:`/settings/providers`,className:`text-xs font-medium text-accent-fg hover:underline`,children:n===`zh`?`高级设置…`:`More settings…`}),(0,Z.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-fg-muted hover:text-fg hover:underline`,onClick:t,children:r.skipSetup})]})]}):null,o===`apiKey`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h3`,{className:`text-base font-medium text-fg`,children:[r.step2Title,s?` (${s})`:``]}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.step2Subtitle})]}),s&&(()=>{let e=d8[s],t=e?.apiKeyUrl,r=e?.apiKeyUrlCn;return t?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-xl border border-edge-subtle bg-surface-base px-3.5 py-2.5`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n===`zh`?`获取 API Key:`:`Get your API Key:`}),(0,Z.jsxs)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-xs font-medium text-accent-fg hover:underline`,children:[r?n===`zh`?`国际版`:`International`:n===`zh`?`前往获取`:`Get API Key`,(0,Z.jsx)(yd,{className:`size-3`})]}),r&&(0,Z.jsxs)(`a`,{href:r,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-xs font-medium text-accent-fg hover:underline`,children:[n===`zh`?`中国版`:`China`,(0,Z.jsx)(yd,{className:`size-3`})]})]}):null})(),(0,Z.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[(0,Z.jsx)(`span`,{className:`sr-only`,children:r.step2Placeholder}),(0,Z.jsx)(`input`,{type:`password`,autoComplete:`off`,value:c,onChange:e=>a({type:`patch`,patch:{apiKey:e.target.value}}),placeholder:r.step2Placeholder,className:`mt-1 w-full rounded-xl border border-edge bg-surface-panel px-3 py-2.5 text-sm text-fg outline-none ring-accent placeholder:text-fg-muted focus:border-accent focus:ring-2 focus:ring-accent/30`})]}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.step2SecurityNote}),u?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:u}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2`,children:[(0,Z.jsx)(wA,{type:`button`,variant:`secondary`,disabled:l,onClick:()=>a({type:`patch`,patch:{step:`provider`}}),children:r.back}),(0,Z.jsx)(wA,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,disabled:l||!c.trim(),onClick:()=>void y(),children:r.continue})]})]}):null,o===`model`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-base font-medium text-fg`,children:r.step3Title}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.step3Subtitle})]}),h?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n===`zh`?`加载模型…`:`Loading models…`}):u&&f.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:u}),(0,Z.jsx)(`button`,{type:`button`,className:`text-left text-sm font-medium text-accent-fg hover:underline`,onClick:()=>s&&void v(s),children:n===`zh`?`重试`:`Retry`})]}):(0,Z.jsx)(ghe,{models:f,selectedId:p,onSelectedChange:e=>a({type:`patch`,patch:{selectedModelId:e}})}),u&&f.length>0?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:u}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2`,children:[(0,Z.jsx)(wA,{type:`button`,variant:`secondary`,disabled:l,onClick:()=>a({type:`patch`,patch:{step:`apiKey`}}),children:r.back}),(0,Z.jsx)(wA,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,disabled:l||!p||h,onClick:()=>void b(),children:r.startChatting})]})]}):null]})]})}function Lhe(e){if(!e||typeof e!=`object`)return!0;let t=e,n=t.providers,r=Object.values(n&&typeof n==`object`&&!Array.isArray(n)?n:{}).some(e=>e===`***`),i=t.agents,a=``;if(i&&typeof i==`object`&&!Array.isArray(i)){let e=i.defaults;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.model;typeof t==`string`&&(a=t)}}let o=a.trim().length>0;return!r||!o}function Rhe(e){let{enabled:t,ready:n,configError:r,modelsError:i,config:a,modelsData:o}=e;if(!t||!n||r||i)return!1;let s=Lhe(a),c=!Array.isArray(o)||o.length===0;return s||c}var zhe=`xopc-onboarding-model-setup-dismissed`;function Bhe(e){let t=(0,Y.c)(21),[n,r]=(0,J.useState)(Vhe),{data:i,error:a,isLoading:o,mutate:s}=pL(e),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={revalidateOnFocus:!1},t[0]=c):c=t[0];let{data:l,isLoading:u,error:d,mutate:f}=v(e?s8:null,c8,c),p=!e||!o&&!u,m=i?.payload?.config,h;t[1]!==a||t[2]!==e||t[3]!==l||t[4]!==d||t[5]!==p||t[6]!==m?(h=Rhe({enabled:e,ready:p,configError:a,modelsError:d,config:m,modelsData:l}),t[1]=a,t[2]=e,t[3]=l,t[4]=d,t[5]=p,t[6]=m,t[7]=h):h=t[7];let g=h,_;t[8]!==s||t[9]!==f?(_=async()=>{await Promise.all([s(),f()])},t[8]=s,t[9]=f,t[10]=_):_=t[10];let y=_,b,x;t[11]!==e||t[12]!==f?(b=()=>{if(!e)return;let t=()=>{f()};return window.addEventListener(`config-reload`,t),()=>window.removeEventListener(`config-reload`,t)},x=[e,f],t[11]=e,t[12]=f,t[13]=b,t[14]=x):(b=t[13],x=t[14]),(0,J.useEffect)(b,x);let S;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>{try{localStorage.setItem(zhe,`1`)}catch{}r(!0)},t[15]=S):S=t[15];let C=S,w;return t[16]!==n||t[17]!==g||t[18]!==p||t[19]!==y?(w={needsSetup:g,ready:p,refresh:y,guideDismissed:n,dismissPermanently:C},t[16]=n,t[17]=g,t[18]=p,t[19]=y,t[20]=w):w=t[20],w}function Vhe(){return typeof localStorage<`u`&&localStorage.getItem(`xopc-onboarding-model-setup-dismissed`)===`1`}function Hhe(){let e=(0,Y.c)(20),t=Se(qhe),n=d(Khe),r;e[0]===n?r=e[1]:(r=m(n),e[0]=n,e[1]=r);let i=r,a=Bhe(!!t),o=!!t&&a.ready&&a.needsSetup&&!a.guideDismissed,s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(ie,{className:`fixed inset-0 z-[55] bg-scrim backdrop-blur-[2px]`}),e[2]=s):s=e[2];let c;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=X(`fixed left-1/2 top-1/2 z-[56] max-h-[min(100dvh-2rem,44rem)] w-[min(100%-2rem,36rem)] -translate-x-1/2 -translate-y-1/2 overflow-y-auto`,`rounded-xl p-2 outline-none sm:p-3`),e[3]=c):c=e[3];let l;e[4]===i.onboarding.title?l=e[5]:(l=(0,Z.jsx)(ue,{className:`sr-only`,children:i.onboarding.title}),e[4]=i.onboarding.title,e[5]=l);let u;e[6]===i.onboarding.subtitle?u=e[7]:(u=(0,Z.jsx)(le,{className:`sr-only`,children:i.onboarding.subtitle}),e[6]=i.onboarding.subtitle,e[7]=u);let f;e[8]===a?f=e[9]:(f=()=>void a.refresh(),e[8]=a,e[9]=f);let p;e[10]!==a.dismissPermanently||e[11]!==f?(p=(0,Z.jsx)(Ihe,{onComplete:f,onDismiss:a.dismissPermanently}),e[10]=a.dismissPermanently,e[11]=f,e[12]=p):p=e[12];let h;e[13]!==l||e[14]!==u||e[15]!==p?(h=(0,Z.jsxs)(G,{children:[s,(0,Z.jsxs)(se,{className:c,onPointerDownOutside:Ghe,onEscapeKeyDown:Whe,onOpenAutoFocus:Uhe,children:[l,u,p]})]}),e[13]=l,e[14]=u,e[15]=p,e[16]=h):h=e[16];let g;return e[17]!==o||e[18]!==h?(g=(0,Z.jsx)(q,{open:o,children:h}),e[17]=o,e[18]=h,e[19]=g):g=e[19],g}function Uhe(e){return e.preventDefault()}function Whe(e){return e.preventDefault()}function Ghe(e){return e.preventDefault()}function Khe(e){return e.language}function qhe(e){return e.token}function Jhe(){let e=(0,Y.c)(3),t=Qr(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{let e=e=>{let n=e.detail;n?.sessionKey&&t(`/chat/${encodeURIComponent(n.sessionKey)}`)};return window.addEventListener(`navigate-to-chat`,e),()=>window.removeEventListener(`navigate-to-chat`,e)},r=[t],e[0]=t,e[1]=n,e[2]=r),(0,J.useEffect)(n,r),null}function Yhe(){let e=(0,Y.c)(3),t=Qr(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{let e=e=>{let n=e.detail,r=typeof n?.path==`string`?n.path.trim():``;r&&t(r.startsWith(`/`)?r:`/${r}`)};return window.addEventListener(`extension-navigate`,e),()=>window.removeEventListener(`extension-navigate`,e)},r=[t],e[0]=t,e[1]=n,e[2]=r),(0,J.useEffect)(n,r),null}function Xhe(){let e=(0,Y.c)(10),[t,n]=(0,J.useState)(null),r,i;if(e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=e=>{let t=e.detail;if(!t||typeof t.title!=`string`||!t.title.trim())return;n({type:t.type??`info`,title:t.title.trim(),message:typeof t.message==`string`?t.message:void 0,duration:t.duration});let r=t.duration===0?0:t.duration??5e3;r>0&&window.setTimeout(()=>n(null),r)};return window.addEventListener(`extension-notification`,e),()=>window.removeEventListener(`extension-notification`,e)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,J.useEffect)(r,i),!t)return null;let a=`pointer-events-none fixed bottom-4 right-4 z-[100] flex max-w-sm flex-col gap-1 rounded-lg border px-4 py-3 text-sm shadow-elevated ${t.type===`error`?`border-red-500/40 bg-red-500/10`:t.type===`warning`?`border-amber-500/40 bg-amber-500/10`:t.type===`success`?`border-emerald-500/40 bg-emerald-500/10`:`border-edge bg-surface-panel`}`,o;e[2]===t.title?o=e[3]:(o=(0,Z.jsx)(`div`,{className:`pointer-events-auto font-medium text-fg`,children:t.title}),e[2]=t.title,e[3]=o);let s;e[4]===t.message?s=e[5]:(s=t.message?(0,Z.jsx)(`div`,{className:`pointer-events-auto text-fg-muted`,children:t.message}):null,e[4]=t.message,e[5]=s);let c;return e[6]!==a||e[7]!==o||e[8]!==s?(c=(0,Z.jsxs)(`div`,{className:a,role:`status`,"aria-live":`polite`,children:[o,s]}),e[6]=a,e[7]=o,e[8]=s,e[9]=c):c=e[9],c}function Zhe(){let e=(0,Y.c)(47),t=Se($he),{pathname:n}=Yr(),r;e[0]===n?r=e[1]:(r=n.startsWith(`/settings`),e[0]=n,e[1]=r);let i=r,a=d(Qhe),o=BF();if(!t){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-1 flex-col overflow-hidden bg-surface-base`,children:[(0,Z.jsx)(FQ,{}),(0,Z.jsx)(aj,{})]}),e[2]=t):t=e[2],t}let s;e[3]===n?s=e[4]:(s=n.split(`/`)[1]??`root`,e[3]=n,e[4]=s);let c=s,l=a===`zh`?`跳到主要内容`:`Skip to main content`,u;e[5]===l?u=e[6]:(u=(0,Z.jsx)(`a`,{href:`#app-main-content`,className:`sr-only z-[80] rounded-lg bg-surface-panel px-3 py-2 text-sm text-fg shadow-elevated focus:not-sr-only focus:absolute focus:left-4 focus:top-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:l}),e[5]=l,e[6]=u);let f,p,m,h,g,_,v,y,b,x,S;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Z.jsx)(pue,{}),v=(0,Z.jsx)(qme,{}),y=(0,Z.jsx)(OQ,{}),b=(0,Z.jsx)(FQ,{}),x=(0,Z.jsx)(Jhe,{}),S=(0,Z.jsx)(Yhe,{}),f=(0,Z.jsx)(rue,{}),p=(0,Z.jsx)(Xhe,{}),m=(0,Z.jsx)(dQ,{}),h=(0,Z.jsx)(Hhe,{}),g=(0,Z.jsx)(NQ,{}),e[7]=f,e[8]=p,e[9]=m,e[10]=h,e[11]=g,e[12]=_,e[13]=v,e[14]=y,e[15]=b,e[16]=x,e[17]=S):(f=e[7],p=e[8],m=e[9],h=e[10],g=e[11],_=e[12],v=e[13],y=e[14],b=e[15],x=e[16],S=e[17]);let C;e[18]===o?C=e[19]:(C=(0,Z.jsx)(n$,{reminder:o}),e[18]=o,e[19]=C);let w;e[20]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(zQ,{}),e[20]=w):w=e[20];let T;e[21]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(jH,{}),e[21]=T):T=e[21];let E;e[22]===i?E=e[23]:(E=i?null:(0,Z.jsx)(Kj,{}),e[22]=i,e[23]=E);let D=c===`settings`?`page-enter--gentle overflow-hidden`:`overflow-y-auto overscroll-contain [scrollbar-gutter:stable_both-edges]`,O;e[24]===D?O=e[25]:(O=X(`page-enter flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden`,D),e[24]=D,e[25]=O);let k;e[26]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Z.jsx)(Li,{}),e[26]=k):k=e[26];let A;e[27]!==c||e[28]!==O?(A=(0,Z.jsx)(`main`,{id:`app-main-content`,className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,Z.jsx)(`div`,{className:O,children:k},c)}),e[27]=c,e[28]=O,e[29]=A):A=e[29];let j;e[30]!==E||e[31]!==A?(j=(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[E,A]}),e[30]=E,e[31]=A,e[32]=j):j=e[32];let M;e[33]===i?M=e[34]:(M=i?null:(0,Z.jsx)(uQ,{}),e[33]=i,e[34]=M);let N;e[35]!==j||e[36]!==M?(N=(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-row overflow-hidden`,children:[T,(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 min-w-0 flex-col overflow-hidden bg-surface-panel`,children:(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-row overflow-hidden`,children:[j,M]})})]}),e[35]=j,e[36]=M,e[37]=N):N=e[37];let P;e[38]!==C||e[39]!==N?(P=(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[C,w,N]}),e[38]=C,e[39]=N,e[40]=P):P=e[40];let F;e[41]===i?F=e[42]:(F=i?null:(0,Z.jsx)(dhe,{}),e[41]=i,e[42]=F);let I;return e[43]!==P||e[44]!==F||e[45]!==u?(I=(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-1 flex-col overflow-hidden bg-surface-base`,children:[u,_,v,y,b,x,S,f,p,m,h,g,P,F]}),e[43]=P,e[44]=F,e[45]=u,e[46]=I):I=e[46],I}function Qhe(e){return e.language}function $he(e){return e.token}var ege={chat:jg,sessions:Sp,cron:Zl,skills:hg,channels:bv,agents:YE,logs:xf,settingsOverview:no,settingsCredentials:pg,settingsAgentDefaults:Ux,settingsAppearance:r_,settingsSystem:px,settingsAppManagement:Qg,settingsAgentChat:uu,settingsAgentWorkspace:Np,settingsAgentBrowser:km,settingsAgentRuntime:CT,settingsAgentContext:mg,settingsAgentMemory:kl,settingsAgentTools:iO,settingsAgentSkills:El,settingsAgentMcp:jl,settingsAgentSystemPrompt:kb,settingsAgents:YE,settingsProviders:Ql,settingsModels:uu,settingsImageModels:ig,settingsChannels:bv,settingsVoice:Mg,settingsGateway:km,settingsHeartbeat:jh,settingsTunnel:Jv,settingsSearch:Ib,settingsShares:Xb,settingsDreams:Fg,settingsCron:Zl,settingsGoals:Vw};function tge(e){let t=(0,Y.c)(3),{tab:n,className:r}=e,i=ege[n],a;return t[0]!==i||t[1]!==r?(a=(0,Z.jsx)(i,{className:r,strokeWidth:1.75,"aria-hidden":!0}),t[0]=i,t[1]=r,t[2]=a):a=t[2],a}function nge(e){let t=(0,Y.c)(44),{navLinkClassName:n}=e,{t:r}=Ve(),i=d(rge),a;t[0]===i?a=t[1]:(a=m(i),t[0]=i,t[1]=a);let o=a,s=NI(),c,l,u,f,p;if(t[2]!==o.nav.apps||t[3]!==o.settingsNavGroups.extensions||t[4]!==n||t[5]!==r||t[6]!==s){let e=ige(s);t[12]===o.settingsNavGroups.extensions?p=t[13]:(p=(0,Z.jsx)(`p`,{className:`px-4 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wider text-fg-muted`,children:o.settingsNavGroups.extensions}),t[12]=o.settingsNavGroups.extensions,t[13]=p),c=`flex flex-col gap-0.5`;let i;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(gg,{className:`size-5 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),t[14]=i):i=t[14];let a;t[15]===o.nav.apps?a=t[16]:(a=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:o.nav.apps}),t[15]=o.nav.apps,t[16]=a),t[17]!==n||t[18]!==a?(l=(0,Z.jsxs)(Ma,{to:`/settings/apps`,className:n,children:[i,a]}),t[17]=n,t[18]=a,t[19]=l):l=t[19];let d;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(Al,{className:`size-5 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),t[20]=d):d=t[20];let m;t[21]===r?m=t[22]:(m=r(`extensionDebug.nav`),t[21]=r,t[22]=m);let h;t[23]===m?h=t[24]:(h=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:m}),t[23]=m,t[24]=h),t[25]!==n||t[26]!==h?(u=(0,Z.jsxs)(Ma,{to:`/settings/extensions/debug`,className:n,children:[d,h]}),t[25]=n,t[26]=h,t[27]=u):u=t[27];let g;t[28]===n?g=t[29]:(g=e=>{let{extension:t,panel:r}=e;return(0,Z.jsxs)(Ma,{to:`/settings/ext/${t.id}/${r.id}`,className:n,children:[(0,Z.jsx)(Lv,{className:`size-5 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r.title})]},`${t.id}:${r.id}`)},t[28]=n,t[29]=g),f=e.map(g),t[2]=o.nav.apps,t[3]=o.settingsNavGroups.extensions,t[4]=n,t[5]=r,t[6]=s,t[7]=c,t[8]=l,t[9]=u,t[10]=f,t[11]=p}else c=t[7],l=t[8],u=t[9],f=t[10],p=t[11];let h;if(t[30]!==n||t[31]!==s){let e;t[33]===n?e=t[34]:(e=e=>(0,Z.jsxs)(Ma,{to:`/settings/ext/${e.id}`,className:n,children:[(0,Z.jsx)(Lv,{className:`size-5 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name})]},`${e.id}:config`),t[33]=n,t[34]=e),h=age(s).map(e),t[30]=n,t[31]=s,t[32]=h}else h=t[32];let g;t[35]!==c||t[36]!==l||t[37]!==u||t[38]!==f||t[39]!==h?(g=(0,Z.jsxs)(`div`,{className:c,children:[l,u,f,h]}),t[35]=c,t[36]=l,t[37]=u,t[38]=f,t[39]=h,t[40]=g):g=t[40];let _;return t[41]!==p||t[42]!==g?(_=(0,Z.jsxs)(`div`,{children:[p,g]}),t[41]=p,t[42]=g,t[43]=_):_=t[43],_}function rge(e){return e.language}function ige(e){let t=[];for(let n of e){let e=n.ui?.contributions?.settingsPanels;if(e)for(let r of e)t.push({extension:n,panel:r})}return t.sort((e,t)=>{let n=e.panel.order??999,r=t.panel.order??999;return n===r?e.panel.title.localeCompare(t.panel.title):n-r}),t}function age(e){return e.filter(e=>(!!e.hasConfigSchema||jI(e))&&!(Array.isArray(e.ui?.contributions?.settingsPanels)&&e.ui.contributions.settingsPanels.length>0))}var p8=[`chat`,`workspace`,`runtime`,`context`,`memory`,`tools`,`skills`,`system-prompt`];function m8(e){let t=(e??``).trim();return p8.includes(t)?t:`chat`}var h8={settingsAgentDefaults:`chat`,settingsAgentChat:`chat`,settingsAgentWorkspace:`workspace`,settingsAgentRuntime:`runtime`,settingsAgentContext:`context`,settingsAgentMemory:`memory`,settingsAgentTools:`tools`,settingsAgentSkills:`skills`,settingsAgentSystemPrompt:`system-prompt`};function g8(e){return e in h8}function oge(e,t){if(!g8(e))return!1;let n=h8[e];return!n||!t.pathname.replace(/\/+$/,``).endsWith(`/settings/agent-defaults`)?!1:m8(new URLSearchParams(t.search).get(`tab`))===n}var _8=`(max-width: 1199px)`,sge=`z-[58]`,v8=`z-[75]`,y8=`z-[76]`,b8=`z-[74]`,cge=`z-[77]`,x8=`/agents`;function lge(e){return`${x8}/${encodeURIComponent(e)}`}var S8=`settingsBackPath`;function C8(e){if(!e||typeof e!=`object`)return`/chat`;let t=e[S8];if(typeof t!=`string`)return`/chat`;let n=t.trim();return!n.startsWith(`/`)||n.startsWith(`//`)?`/chat`:n}var w8=`xopc-web-settings-rail-width-px`;function T8(e){return Math.min(360,Math.max(192,Math.round(e)))}function uge(){try{let e=globalThis.localStorage?.getItem(w8);if(e==null)return T8(228);let t=Number.parseInt(e,10);return T8(Number.isFinite(t)?t:228)}catch{return T8(228)}}function dge(e){try{globalThis.localStorage?.setItem(w8,String(e))}catch{}}var E8=c(e=>({widthPx:uge(),setWidthPx:t=>{let n=T8(t);e({widthPx:n}),queueMicrotask(()=>dge(n))}}));function D8({isActive:e}){return X(`flex w-full shrink-0 items-center gap-2.5 rounded-xl px-4 py-2 text-sm font-medium leading-6 transition-colors duration-200 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,e?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`)}var fge=X(`inline-flex max-w-full items-center gap-2 rounded-xl px-3 py-2 text-sm font-medium transition-colors duration-200 ease-out`,`text-fg-muted hover:bg-surface-hover hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`sm:px-4`);function pge(e){return e.tabs.filter(e=>!XA.has(e)||Oj())}function mge(e){let t=(0,Y.c)(25),{group:n,groupIndex:r,language:i,location:a}=e,o;t[0]===i?o=t[1]:(o=m(i),t[0]=i,t[1]=o);let s=o,c,l,u,d;if(t[2]!==n||t[3]!==r||t[4]!==i||t[5]!==a||t[6]!==s){d=Symbol.for(`react.early_return_sentinel`);bb0:{let e=pge(n);if(e.length===0){d=null;break bb0}let o=r===0&&`pt-0`,f;t[11]===o?f=t[12]:(f=X(`px-4 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wider text-fg-muted`,o),t[11]=o,t[12]=f);let p=s.settingsNavGroups[n.id];t[13]!==f||t[14]!==p?(u=(0,Z.jsx)(`p`,{className:f,children:p}),t[13]=f,t[14]=p,t[15]=u):u=t[15],c=`flex flex-col gap-0.5`;let m;t[16]!==i||t[17]!==a?(m=e=>(0,Z.jsxs)(Ma,{to:ij(e),className:t=>{let{isActive:n}=t;return D8({isActive:g8(e)?oge(e,a):n})},children:[(0,Z.jsx)(tge,{tab:e,className:`size-5 shrink-0 opacity-90`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:g(i,e)})]},e),t[16]=i,t[17]=a,t[18]=m):m=t[18],l=e.map(m)}t[2]=n,t[3]=r,t[4]=i,t[5]=a,t[6]=s,t[7]=c,t[8]=l,t[9]=u,t[10]=d}else c=t[7],l=t[8],u=t[9],d=t[10];if(d!==Symbol.for(`react.early_return_sentinel`))return d;let f;t[19]!==c||t[20]!==l?(f=(0,Z.jsx)(`div`,{className:c,children:l}),t[19]=c,t[20]=l,t[21]=f):f=t[21];let p;return t[22]!==u||t[23]!==f?(p=(0,Z.jsxs)(`div`,{children:[u,f]}),t[22]=u,t[23]=f,t[24]=p):p=t[24],p}var hge=(0,J.memo)(function(){let e=(0,Y.c)(66),t=d(gge),n;e[0]===t?n=e[1]:(n=m(t),e[0]=t,e[1]=n);let r=n,i=Yr(),a=E8(_ge),o=E8(vge),[s,c]=(0,J.useState)(!1),l=t8(_8),u,f,p,h,g,_,v;if(e[2]!==i.state||e[3]!==r.sidebar.back||e[4]!==r.sidebar.backToAgents||e[5]!==r.sidebar.backToApp||e[6]!==o||e[7]!==l||e[8]!==a||e[9]!==s){let t=l&&jj()?Mj():``,n;e[17]===o?n=e[18]:(n=e=>{e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId),c(!0);let n=e.clientX,r=E8.getState().widthPx,i=e.pointerId,a=e=>{o(r+(e.clientX-n))},s=()=>{try{t.releasePointerCapture(i)}catch{}c(!1),window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},e[17]=o,e[18]=n),f=n;let d;e[19]===i.state?d=e[20]:(d=C8(i.state),e[19]=i.state,e[20]=d);let m=d,y=m===`/chat`?r.sidebar.backToApp:m===`/agents`?r.sidebar.backToAgents:r.sidebar.back,b;e[21]===Symbol.for(`react.memo_cache_sentinel`)?(b=X(fge,dj),e[21]=b):b=e[21];let x;e[22]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(Ss,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),e[22]=x):x=e[22];let S;e[23]===y?S=e[24]:(S=(0,Z.jsx)(`span`,{children:y}),e[23]=y,e[24]=S);let C;e[25]!==y||e[26]!==m||e[27]!==S?(C=(0,Z.jsxs)(ja,{to:m,replace:!1,className:b,title:y,children:[x,S]}),e[25]=y,e[26]=m,e[27]=S,e[28]=C):C=e[28],u=C;let w;e[29]===Symbol.for(`react.memo_cache_sentinel`)?(w=[...QA,...Oj()?[ZA]:[]],e[29]=w):w=e[29],p=w,v=`flex min-h-0 flex-1 flex-col overflow-hidden md:flex-row`;let T=s&&`settings-page-rail-resizing`;e[30]===T?g=e[31]:(g=X(`relative flex shrink-0 flex-col bg-surface-base`,`md:h-full md:min-h-0 md:shrink-0 md:overflow-hidden`,`settings-page-rail`,T),e[30]=T,e[31]=g);let E=`${a}px`,D;e[32]===E?D=e[33]:(D={"--settings-rail-px":E},e[32]=E,e[33]=D),_=D;let O;e[34]===l?O=e[35]:(O=l&&jj()?`pr-4`:`px-4`,e[34]=l,e[35]=O),h=X(`flex shrink-0 items-center justify-start pb-2 pt-4`,uj,t,O),e[2]=i.state,e[3]=r.sidebar.back,e[4]=r.sidebar.backToAgents,e[5]=r.sidebar.backToApp,e[6]=o,e[7]=l,e[8]=a,e[9]=s,e[10]=u,e[11]=f,e[12]=p,e[13]=h,e[14]=g,e[15]=_,e[16]=v}else u=e[10],f=e[11],p=e[12],h=e[13],g=e[14],_=e[15],v=e[16];let y;e[36]!==u||e[37]!==h?(y=(0,Z.jsx)(`div`,{className:h,children:u}),e[36]=u,e[37]=h,e[38]=y):y=e[38];let b;e[39]===Symbol.for(`react.memo_cache_sentinel`)?(b=X(`min-h-0 overflow-y-auto overflow-x-hidden px-4 pb-3 pt-2 md:pb-4`,`max-h-[min(42vh,20rem)] md:max-h-none md:flex-1`),e[39]=b):b=e[39];let x=r.nav.settings,S;e[40]!==t||e[41]!==i||e[42]!==p?(S=p.map((e,n)=>(0,Z.jsx)(mge,{group:e,groupIndex:n,language:t,location:i},e.id)),e[40]=t,e[41]=i,e[42]=p,e[43]=S):S=e[43];let C;e[44]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Z.jsx)(nge,{navLinkClassName:D8}),e[44]=C):C=e[44];let w;e[45]===S?w=e[46]:(w=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[S,C]}),e[45]=S,e[46]=w);let T;e[47]!==r.nav.settings||e[48]!==w?(T=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col md:min-h-0`,children:(0,Z.jsx)(`nav`,{className:b,"aria-label":x,children:w})}),e[47]=r.nav.settings,e[48]=w,e[49]=T):T=e[49];let E=r.sidebar.resizeHandleAria,D=s&&`bg-surface-hover/30 before:!bg-edge/80 dark:before:!bg-edge/85`,O;e[50]===D?O=e[51]:(O=X(`pointer-events-auto absolute right-0 top-0 z-10 hidden h-full w-2 shrink-0 cursor-col-resize md:block`,`before:content-[''] before:pointer-events-none before:absolute before:left-1/2 before:top-0 before:z-0 before:h-full before:w-px before:-translate-x-1/2`,`before:bg-transparent before:transition-[background-color] before:duration-150`,`hover:bg-surface-hover/20 hover:before:bg-edge/65 dark:hover:before:bg-edge/75`,D,`transition-[background-color] duration-150`,`touch-none select-none`,dj),e[50]=D,e[51]=O);let k;e[52]!==r.sidebar.resizeHandleAria||e[53]!==f||e[54]!==O?(k=(0,Z.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":E,onPointerDown:f,className:O}),e[52]=r.sidebar.resizeHandleAria,e[53]=f,e[54]=O,e[55]=k):k=e[55];let A;e[56]!==T||e[57]!==k||e[58]!==g||e[59]!==_||e[60]!==y?(A=(0,Z.jsxs)(`div`,{className:g,style:_,children:[y,T,k]}),e[56]=T,e[57]=k,e[58]=g,e[59]=_,e[60]=y,e[61]=A):A=e[61];let j;e[62]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Z.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overflow-x-hidden overscroll-contain bg-surface-panel [scrollbar-gutter:stable_both-edges]`,children:(0,Z.jsx)(Li,{})}),e[62]=j):j=e[62];let M;return e[63]!==A||e[64]!==v?(M=(0,Z.jsxs)(`div`,{className:v,children:[A,j]}),e[63]=A,e[64]=v,e[65]=M):M=e[65],M});function gge(e){return e.language}function _ge(e){return e.widthPx}function vge(e){return e.setWidthPx}var O8=(0,J.createContext)(`default`);function yge(e,t){return e===`modal`||t===`modal`?`modal`:e===`page`||t===`page`?`page`:`default`}function bge(e){switch(e){case`modal`:return cge;case`page`:return b8;default:return`z-50`}}function k8(e){let t=(0,Y.c)(6),{layer:n,children:r}=e,i=(0,J.useContext)(O8),a;t[0]!==n||t[1]!==i?(a=yge(i,n),t[0]=n,t[1]=i,t[2]=a):a=t[2];let o;return t[3]!==r||t[4]!==a?(o=(0,Z.jsx)(O8.Provider,{value:a,children:r}),t[3]=r,t[4]=a,t[5]=o):o=t[5],o}function xge(){return(0,J.useContext)(O8)}var Sge=(0,J.memo)(function(e){let t=(0,Y.c)(26),{children:n}=e,r=Qr(),i=Yr(),a=d(Cge),o;t[0]===a?o=t[1]:(o=m(a),t[0]=a,t[1]=o);let s=o,c;t[2]===i.state?c=t[3]:(c=C8(i.state),t[2]=i.state,t[3]=c);let l=c,u=t8(_8),f,p;t[4]!==l||t[5]!==r?(f=()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),r(l))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},p=[r,l],t[4]=l,t[5]=r,t[6]=f,t[7]=p):(f=t[6],p=t[7]),(0,J.useEffect)(f,p);let h;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(h=[],t[8]=h):h=t[8],(0,J.useEffect)(wge,h);let g;t[9]!==l||t[10]!==r?(g=(0,Z.jsx)(`div`,{role:`presentation`,className:`absolute inset-0 z-40 bg-scrim/55 backdrop-blur-[2px] dark:bg-black/50`,onClick:()=>r(l)}),t[9]=l,t[10]=r,t[11]=g):g=t[11];let _=g,v;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(v=X(`relative z-50 flex min-h-0 flex-1 flex-col overflow-hidden bg-surface-panel`,`max-md:shadow-elevated`,`md:m-3 md:max-h-[calc(100dvh-1.5rem)] md:rounded-2xl md:border md:border-edge md:shadow-elevated`,`settings-sheet-enter`),t[12]=v):v=t[12];let y;t[13]===n?y=t[14]:(y=(0,Z.jsx)(k8,{layer:`page`,children:n}),t[13]=n,t[14]=y);let b;t[15]!==s.nav.settings||t[16]!==y?(b=(0,Z.jsx)(`div`,{className:v,role:`dialog`,"aria-modal":`true`,"aria-label":s.nav.settings,children:y}),t[15]=s.nav.settings,t[16]=y,t[17]=b):b=t[17];let x=b,S;t[18]!==x||t[19]!==_?(S=(0,Z.jsxs)(Z.Fragment,{children:[_,x]}),t[18]=x,t[19]=_,t[20]=S):S=t[20];let C=S;if(u){let e;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(e=X(`fixed inset-0 flex min-h-0 flex-col bg-surface-base`,sge),t[21]=e):e=t[21];let n;return t[22]===C?n=t[23]:(n=(0,Xa.createPortal)((0,Z.jsx)(`div`,{className:e,children:C}),document.body),t[22]=C,t[23]=n),n}let w;return t[24]===C?w=t[25]:(w=(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-h-[100dvh] flex-1 flex-col md:min-h-0`,children:C}),t[24]=C,t[25]=w),w});function Cge(e){return e.language}function wge(){let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}}var Tge=t({loadAttachment:()=>Ege});async function Ege(e,t){let n,r=t||`unnamed`,i=`application/octet-stream`,a=0;if(typeof e==`string`){let o=await fetch(e);if(!o.ok)throw Error(`Failed to fetch file`);if(n=await o.arrayBuffer(),a=n.byteLength,i=o.headers.get(`content-type`)||i,!t){let t=e.split(`/`);r=t[t.length-1]||`document`}}else if(e instanceof File)n=await e.arrayBuffer(),a=e.size,i=e.type||i,r=t||e.name;else if(e instanceof Blob)n=await e.arrayBuffer(),a=e.size,i=e.type||i;else if(e instanceof ArrayBuffer)n=e,a=e.byteLength;else throw Error(`Invalid source type`);let o=new Uint8Array(n),s=``,c=32768;for(let e=0;e<o.length;e+=c){let t=o.slice(e,e+c);s+=String.fromCharCode(...t)}let l=btoa(s),u=`${r}_${Date.now()}_${Math.random()}`;if(i===`application/pdf`||r.toLowerCase().endsWith(`.pdf`)){let{processPdf:e}=await D(async()=>{let{processPdf:e}=await import(`./attachment-process-heavy-CqVriadb.js`);return{processPdf:e}},__vite__mapDeps([24,1,21,23])),{extractedText:t,preview:i}=await e(n,r);return{id:u,type:`document`,name:r,mimeType:`application/pdf`,size:a,content:l,extractedText:t,preview:i}}if(i===`application/vnd.openxmlformats-officedocument.wordprocessingml.document`||r.toLowerCase().endsWith(`.docx`)){let{processDocx:e}=await D(async()=>{let{processDocx:e}=await import(`./attachment-process-heavy-CqVriadb.js`);return{processDocx:e}},__vite__mapDeps([24,1,21,23])),{extractedText:t}=await e(n,r);return{id:u,type:`document`,name:r,mimeType:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,size:a,content:l,extractedText:t}}if(i===`application/vnd.openxmlformats-officedocument.presentationml.presentation`||r.toLowerCase().endsWith(`.pptx`)){let{processPptx:e}=await D(async()=>{let{processPptx:e}=await import(`./attachment-process-heavy-CqVriadb.js`);return{processPptx:e}},__vite__mapDeps([24,1,21,23])),{extractedText:t}=await e(n,r);return{id:u,type:`document`,name:r,mimeType:`application/vnd.openxmlformats-officedocument.presentationml.presentation`,size:a,content:l,extractedText:t}}if([`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,`application/vnd.ms-excel`].includes(i)||r.toLowerCase().endsWith(`.xlsx`)||r.toLowerCase().endsWith(`.xls`)){let{processExcel:e}=await D(async()=>{let{processExcel:e}=await import(`./attachment-process-heavy-CqVriadb.js`);return{processExcel:e}},__vite__mapDeps([24,1,21,23])),{extractedText:t}=await e(n,r);return{id:u,type:`document`,name:r,mimeType:i&&i.startsWith(`application/vnd`)?i:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,size:a,content:l,extractedText:t}}if(i?.startsWith(`image/`))return{id:u,type:`image`,name:r,mimeType:i,size:a,content:l,preview:l};if(i?.startsWith(`audio/`))return{id:u,type:`voice`,name:r,mimeType:i,size:a,content:l};if(LL(r,i??``)){let e=new TextDecoder().decode(n);return{id:u,type:`document`,name:r,mimeType:i?.startsWith(`text/`)?i:`text/plain`,size:a,content:l,extractedText:e}}throw Error(`Unsupported file type: ${i}`)}var A8=`image/*,application/pdf,.docx,.pptx,.xlsx,.xls,.txt,.md,.json,.xml,.html,.css,.js,.ts,.jsx,.tsx,.yml,.yaml,.zip`,Dge=A8.split(`,`).flatMap(e=>{let t=e.trim();return t?[t]:[]});function Oge(e){return`${e.name}\0${e.size}`}function kge(e){let t=(e.type||``).toLowerCase(),n=e.name.toLowerCase();for(let e of Dge){let r=e.toLowerCase();if(r.endsWith(`/*`)){let e=r.slice(0,-1);if(t.startsWith(e))return!0}else if(e.startsWith(`.`)){if(n.endsWith(e.toLowerCase()))return!0}else if(t===r)return!0}return!1}function Age(e){if(!e)return[];let t=new Set,n=[],r=e=>{if(!e||e.size===0)return;let r=Oge(e);t.has(r)||(t.add(r),n.push(e))},{files:i}=e;if(i?.length)for(let e=0;e<i.length;e++)r(i.item(e));for(let t of Array.from(e.items??[]))t.kind===`file`&&r(t.getAsFile());return n}var j8=String.raw`a-zA-Z0-9_./\-\p{L}\p{N}`,M8=`[${j8}]+`,N8=String.raw`(?:[^"\\]|\\.)*`,P8=String.raw`((?:[^"\\]|\\.)*)`,jge=RegExp(`^[${j8}]+$`,`u`);function Mge(e){return e.replace(/\\(.)/g,(e,t)=>t)}var Nge=RegExp(`@file:(?:"${P8}"|(${M8}))`,`gu`),Pge=RegExp(`(@file:(?:"${N8}"|${M8}))$`,`u`),Fge=RegExp(`(@file:(?:"${N8}"|${M8}))([ \\t\\f\\v]*)$`,`u`),F8=`(?:"${N8}"|${M8})`;function Ige(e){let t=e.lastIndexOf(`@file:`);return t===-1?!1:RegExp(`^@file:${F8}$`,`u`).test(e.slice(t))}function I8(e){let t=e[2];if(t!=null&&t!==``)return t;let n=e[1];return n==null?``:Mge(n)}function L8(e){return jge.test(e)?e:`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function R8(){return new RegExp(Nge.source,`gu`)}var z8=RegExp(`^@file:(?:"${P8}"|(${M8}))`,`u`),B8=`​`,V8=`⁠`,H8=RegExp(`^\\/skill:(${V$})`);function Lge(e){return!!e.dataset.skill}function Rge(e){return!!e.dataset.file}function zge(e){return e.dataset.slashCommand!=null&&e.dataset.slashCommand!==``}function Bge(e){let t=e.replace(/\/$/,``);return`@${t.split(`/`).pop()??t}`}function U8(e){let t=``;for(let n of e)if(n){if(t.length>0){let e=t[t.length-1],r=n[0];if(!/\s/.test(e)&&!/\s/.test(r)){let e=Ige(t)||/\/skill:\S+$/.test(t)||n1(t),r=n.startsWith(`@file:`)||n.startsWith(`/skill:`)||r1(n);(e||r)&&(t+=` `)}}t+=n}return t}function W8(e,t){if(e.nodeType===Node.TEXT_NODE)t.push((e.textContent??``).replaceAll(B8,``));else if(e.nodeType===Node.ELEMENT_NODE){let n=e;if(Lge(n)){let e=n.dataset.skill??``;e&&t.push(`/skill:${e}`)}else if(Rge(n)){let e=n.dataset.file??``;e&&t.push(`@file:${L8(e)}`)}else if(zge(n)){let e=n.dataset.slashCommand??``;e&&t.push(`/${e}`)}else n.tagName===`BR`?t.push(`
4680
- `):n.childNodes.forEach(e=>W8(e,t))}}function G8(e){let t=[];return e.childNodes.forEach(e=>W8(e,t)),U8(t).replaceAll(V8,``)}function Vge(e){let t=window.getSelection();if(!t)return;let n=document.createRange(),r=e.firstChild;r&&r.nodeType===Node.TEXT_NODE?(n.setStart(r,0),n.collapse(!0)):(n.setStart(e,0),n.collapse(!0)),t.removeAllRanges(),t.addRange(n)}function K8(e){let t=G8(e);return t.length>0||e.childNodes.length===0?t:(J8(e,``),Vge(e),``)}function Hge(e){let t=new Set,n=U$(),r;for(;(r=n.exec(e))!==null;){let e=r[1];e&&t.add(e)}return t}function q8(e){let t=window.getSelection();if(!t||t.rangeCount===0)return G8(e).length;let n=t.getRangeAt(0),r=document.createTextNode(V8);try{n.insertNode(r)}catch{return G8(e).length}let i=[];e.childNodes.forEach(e=>W8(e,i));let a=U8(i);r.parentNode?.removeChild(r);let o=a.indexOf(V8);return o>=0?o:a.replaceAll(V8,``).length}function Uge(e,t){let n=document.createElement(`span`);n.contentEditable=`false`,n.dataset.skill=t,n.className=`chat-skill-pill`,n.textContent=`/${t}`,e.appendChild(n),e.appendChild(document.createTextNode(B8))}function Wge(e,t){let n=document.createElement(`span`);n.contentEditable=`false`,n.dataset.file=t,n.className=`chat-file-pill`,n.textContent=Bge(t),e.appendChild(n),e.appendChild(document.createTextNode(B8))}function Gge(e,t){let n=document.createElement(`span`);n.contentEditable=`false`,n.dataset.slashCommand=t,n.className=`chat-command-pill`,n.textContent=`/${t}`,e.appendChild(n),e.appendChild(document.createTextNode(B8))}function Kge(e){let t=[],n=n=>{let r,i=new RegExp(n.source,n.flags);for(;(r=i.exec(e))!==null;)t.push({start:r.index,end:r.index+r[0].length})};n(U$()),n(R8());for(let n of t1(e))t.push(n);return t.sort((e,t)=>e.start-t.start),t}function qge(e,t){for(let{start:n,end:r}of Kge(e))if(t>n&&t<=r)return{wire:e.slice(0,n)+e.slice(r),caret:n};return null}function Jge(e,t){if(t<=0)return null;let n=e.slice(0,t),r=r=>{let i=n.match(r);if(i?.[1]){let r=i[1],a=n.length-r.length;return{wire:e.slice(0,a)+e.slice(t),caret:a}}return null},i=[W$,Pge];for(let e of i){let t=r(e);if(t)return t}let a=o1(n);if(a){let n=a.tokenStart;return{wire:e.slice(0,n)+e.slice(t),caret:n}}if(t===e.length){let r=[G$,Fge];for(let i of r){let r=n.match(i);if(r?.[1]){let i=r[0],a=n.length-i.length;return{wire:e.slice(0,a)+e.slice(t),caret:a}}}let i=s1(n);if(i){let n=i.tokenStart;return{wire:e.slice(0,n)+e.slice(t),caret:n}}}return null}function Yge(e){let t=window.getSelection();if(!t||t.rangeCount===0||!t.isCollapsed)return!1;let n=t.getRangeAt(0),r=G8(e),i=q8(e);i===0&&r.length>0&&n.startContainer===e&&n.startOffset===e.childNodes.length&&(i=r.length);let a=qge(r,i);return a||=Jge(r,i),a?(J8(e,a.wire,a.caret),e.dispatchEvent(new InputEvent(`input`,{bubbles:!0})),!0):!1}function Xge(e,t){let n=e.slice(t);return H8.test(n)||z8.test(n)?!0:e1(e,t)!=null}function Zge(e,t,n){let r=t.slice(n),i=[],a=r.match(H8);a?.[0]&&i.push({len:a[0].length,apply:()=>Uge(e,a[1]??``)});let o=r.match(z8);o?.[0]&&i.push({len:o[0].length,apply:()=>Wge(e,I8(o))});let s=e1(t,n);if(s&&i.push({len:s.len,apply:()=>Gge(e,s.matchedKey)}),i.length===0){let r=n+1;for(;r<t.length&&!Xge(t,r);)r+=1;let i=t.slice(n,r);return i&&e.appendChild(document.createTextNode(i)),r}return i.sort((e,t)=>t.len-e.len),i[0].apply(),n+i[0].len}function J8(e,t,n){e.replaceChildren();let r=t;if(n!==void 0){let e=Math.max(0,Math.min(n,t.length));r=t.slice(0,e)+V8+t.slice(e)}let i=0;for(;i<r.length;)i=Zge(e,r,i);if(n===void 0)return;let a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),o;for(;o=a.nextNode();){let e=o.textContent??``,t=-1;for(let n=0;n<e.length;n++)if(e[n]===V8){t=n;break}if(t>=0){let n=o;n.textContent=e.slice(0,t)+e.slice(t+1);let r=window.getSelection(),i=document.createRange();i.setStart(n,t),i.collapse(!0),r?.removeAllRanges(),r?.addRange(i);return}}}function Qge(e,t){for(let n of e)if(n.isActive()&&n.handleKey(t))return!0;return!1}function Y8(e,t){e.classList.toggle(`composer-input-empty`,t.length===0)}function $ge(e){let{disabled:t,welcomeDraftSeed:n,onExternalTextReplace:r,shouldSyncSelectionRef:i}=e,[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(0),[l,u]=(0,J.useState)(!1),d=(0,J.useRef)(null),f=(0,J.useRef)(a),p=(0,J.useRef)(s),m=(0,J.useRef)(0),h=(0,J.useRef)(!0);f.current=a,p.current=s;let g=(0,J.useCallback)(()=>{let e=d.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,128)}px`)},[]),_=(0,J.useCallback)(e=>{let t=e?.nextText??``,n=e?.caretOffset??t.length;o(t),f.current=t,c(n),requestAnimationFrame(()=>{let r=d.current;r&&(J8(r,t,n),Y8(r,t),e?.focus&&r.focus({preventScroll:!0})),g()})},[g]);(0,J.useEffect)(()=>{g()},[a,g]);let v=(0,J.useRef)(n?.id??0);return n&&n.id!==v.current&&(v.current=n.id,m.current=n.id,r?.(),_({nextText:n.text,focus:!0})),(0,J.useLayoutEffect)(()=>{if(t){h.current=!0;return}if(!h.current)return;h.current=!1;let e=requestAnimationFrame(()=>{typeof globalThis.matchMedia==`function`&&globalThis.matchMedia(`(hover: hover) and (pointer: fine)`).matches&&d.current?.focus({preventScroll:!0})});return()=>cancelAnimationFrame(e)},[t]),(0,J.useEffect)(()=>{let e=d.current;if(!e)return;let t=!1,n=null,r=!1,a=-1,o=()=>{if(n=null,r=!1,document.activeElement!==e)return;let t=q8(e);p.current=t,t!==a&&(a=t,i.current&&c(t))},s=()=>{t&&(r||(r=!0,n=requestAnimationFrame(o)))},l=()=>{t||(t=!0,document.addEventListener(`selectionchange`,s),s())},u=()=>{t&&(t=!1,document.removeEventListener(`selectionchange`,s),n!=null&&cancelAnimationFrame(n),n=null,r=!1)},f=()=>l(),m=()=>u();return e.addEventListener(`focus`,f),e.addEventListener(`blur`,m),document.activeElement===e&&l(),()=>{e.removeEventListener(`focus`,f),e.removeEventListener(`blur`,m),u()}},[i]),(0,J.useEffect)(()=>{let e=e=>{let t=e.detail;typeof t?.text!=`string`||t.text.length===0||(r?.(),_({nextText:t.text,focus:!0}))};return window.addEventListener(b1,e),()=>window.removeEventListener(b1,e)},[r,_]),{value:a,cursor:s,isComposing:l,setIsComposing:u,editorRef:d,valueRef:f,setValue:o,setCursor:c,adjustHeight:g,resetEditor:_,onWireInput:(0,J.useCallback)((e,t)=>{f.current=e,o(e),c(t)},[])}}var e_e=(0,J.memo)(function(e){let t=(0,Y.c)(26),{editorRef:n,disabled:r,placeholder:i,onWireInput:a,adjustHeight:o,processFiles:s,setIsComposing:c,kbdRef:l,chatMessages:u}=e,d=(0,J.useRef)(!1),f=!r,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=X(`composer-input box-border m-0 max-h-32 min-h-10 w-full overflow-y-auto border-0 bg-transparent px-0 py-2 text-[0.9375rem] leading-6 text-fg focus:outline-none focus:ring-0 disabled:opacity-50`,`composer-input-empty`),t[0]=p):p=t[0];let m;t[1]!==o||t[2]!==a?(m=e=>{let t=e.currentTarget,n=d.current?G8(t):K8(t);Y8(t,n),a(n,q8(t)),o()},t[1]=o,t[2]=a,t[3]=m):m=t[3];let h;t[4]===c?h=t[5]:(h=()=>{d.current=!0,c(!0)},t[4]=c,t[5]=h);let g;t[6]!==o||t[7]!==n||t[8]!==a||t[9]!==c?(g=()=>{d.current=!1,c(!1),queueMicrotask(()=>{let e=n.current;if(!e||d.current)return;let t=K8(e);Y8(e,t),a(t,q8(e)),o()})},t[6]=o,t[7]=n,t[8]=a,t[9]=c,t[10]=g):g=t[10];let _;t[11]!==u||t[12]!==s?(_=async e=>{let t=e.clipboardData,n=Age(t??null),r=n.filter(kge);if(r.length>0){e.preventDefault(),await s(r);return}if(n.length>0){e.preventDefault(),fH(`warning`,u.clipboardFileTypeUnsupported);return}let i=t?.getData(`text/plain`);i&&(e.preventDefault(),document.execCommand(`insertText`,!1,i))},t[11]=u,t[12]=s,t[13]=_):_=t[13];let v;t[14]!==n||t[15]!==l?(v=e=>{let t=l.current;if(e.key===`Backspace`&&!t.isComposing&&n.current&&Yge(n.current)){e.preventDefault();return}if(Qge(t.adapters,e))return;if(!t.isComposing&&(e.key===`ArrowUp`||e.key===`ArrowDown`)){let n=e.key===`ArrowUp`?`up`:`down`;if(t.tryInputHistoryArrow?.(n)){e.preventDefault(),t.adjustHeight();return}}if(e.key===`Escape`&&!t.isComposing&&t.editingFollowUpId){e.preventDefault(),t.onCancelEditFollowUp?.();return}if(e.key===`Enter`&&e.shiftKey&&!t.isComposing){e.preventDefault(),document.execCommand(`insertText`,!1,`
4681
- `);return}let r=typeof KeyboardEvent<`u`&&e.nativeEvent instanceof KeyboardEvent&&e.nativeEvent.isComposing;if(e.key===`Enter`&&!e.shiftKey&&!t.isComposing&&!r){e.preventDefault();let n=!!(t.valueRef.current.trim()||t.attachmentsLen>0);if(t.runBusy||t.pendingFollowUpsCount>0){if((e.metaKey||e.ctrlKey)&&n){t.interruptDraft?.();return}if(!e.metaKey&&!e.ctrlKey&&!e.altKey&&n){t.flushSteeringDraft?.();return}return}n&&t.send()}},t[14]=n,t[15]=l,t[16]=v):v=t[16];let y;return t[17]!==n||t[18]!==i||t[19]!==f||t[20]!==m||t[21]!==h||t[22]!==g||t[23]!==_||t[24]!==v?(y=(0,Z.jsx)(`div`,{ref:n,role:`textbox`,"aria-multiline":`true`,"aria-label":i,contentEditable:f,suppressContentEditableWarning:!0,spellCheck:!0,className:p,"data-placeholder":i,onInput:m,onCompositionStart:h,onCompositionEnd:g,onPaste:_,onKeyDown:v}),t[17]=n,t[18]=i,t[19]=f,t[20]=m,t[21]=h,t[22]=g,t[23]=_,t[24]=v,t[25]=y):y=t[25],y}),t_e=(0,J.memo)(function(e){let t=(0,Y.c)(55),{items:n,disabled:r,editingFollowUpId:i,onEditInComposer:a,onRemove:o,onMove:s,onReorder:c,onSteer:l,steeringBusyId:u}=e,f=d(n_e),p;t[0]===f?p=t[1]:(p=m(f),t[0]=f,t[1]=p);let h=p,g=r_e,_;t[2]===c?_=t[3]:(_=e=>t=>{t.preventDefault();let n=t.dataTransfer.getData(`text/plain`);if(!n.startsWith(`xopc-followup:`))return;let r=Number.parseInt(n.slice(14),10);Number.isNaN(r)||r===e||c(r,e)},t[2]=c,t[3]=_);let v=_;if(n.length===0)return null;let y=h.chat.followUpQueueAria,b;t[4]===h.chat.followUpQueueHeading?b=t[5]:(b=(0,Z.jsx)(`span`,{className:`text-[0.65rem] font-medium uppercase tracking-wide text-fg-muted`,children:h.chat.followUpQueueHeading}),t[4]=h.chat.followUpQueueHeading,t[5]=b);let x;t[6]===n.length?x=t[7]:(x=(0,Z.jsxs)(`span`,{className:`tabular-nums text-[0.65rem] text-fg-muted`,children:[n.length,`/`,10]}),t[6]=n.length,t[7]=x);let S;t[8]!==b||t[9]!==x?(S=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-1 pb-0.5`,children:[b,x]}),t[8]=b,t[9]=x,t[10]=S):S=t[10];let C;if(t[11]!==r||t[12]!==i||t[13]!==n||t[14]!==h.chat.followUpQueueAttachmentOnly||t[15]!==h.chat.followUpQueueClickToEdit||t[16]!==h.chat.followUpQueueDrag||t[17]!==h.chat.followUpQueueEmptyPreview||t[18]!==h.chat.followUpQueueMoveDown||t[19]!==h.chat.followUpQueueMoveUp||t[20]!==h.chat.followUpQueueRemove||t[21]!==h.chat.followUpQueueSteerNow||t[22]!==v||t[23]!==a||t[24]!==s||t[25]!==o||t[26]!==l||t[27]!==u){let e;t[29]!==r||t[30]!==i||t[31]!==n.length||t[32]!==h.chat.followUpQueueAttachmentOnly||t[33]!==h.chat.followUpQueueClickToEdit||t[34]!==h.chat.followUpQueueDrag||t[35]!==h.chat.followUpQueueEmptyPreview||t[36]!==h.chat.followUpQueueMoveDown||t[37]!==h.chat.followUpQueueMoveUp||t[38]!==h.chat.followUpQueueRemove||t[39]!==h.chat.followUpQueueSteerNow||t[40]!==v||t[41]!==a||t[42]!==s||t[43]!==o||t[44]!==l||t[45]!==u?(e=(e,t)=>{let c=!e.attachments?.length&&e.text.trim().length>0,d=u===e.id,f=e.text.trim();return!f&&e.attachments?.length&&(f=e.attachments[0]?.name?.trim()||h.chat.followUpQueueAttachmentOnly),f||=h.chat.followUpQueueEmptyPreview,(0,Z.jsxs)(`div`,{role:`listitem`,onDragOver:g,onDrop:r?void 0:v(t),className:X(`flex h-7 items-center gap-1 rounded border px-1`,i===e.id?`border-accent/50 bg-accent-soft/20 dark:border-accent/50 dark:bg-accent-soft/10`:`border-edge-subtle/80 bg-surface-hover/25 dark:border-edge-subtle/90 dark:bg-surface-hover/15`),children:[(0,Z.jsx)(`div`,{draggable:!r,onDragStart:e=>{e.dataTransfer.setData(`text/plain`,`xopc-followup:${t}`),e.dataTransfer.effectAllowed=`move`},className:X(`flex shrink-0 cursor-grab items-center active:cursor-grabbing`,r&&`cursor-not-allowed opacity-40`),title:h.chat.followUpQueueDrag,children:(0,Z.jsx)(Um,{className:`size-3.5 text-fg-muted`,"aria-hidden":!0})}),(0,Z.jsx)(`button`,{type:`button`,disabled:r,title:h.chat.followUpQueueClickToEdit,"aria-label":h.chat.followUpQueueClickToEdit,className:X(`h-6 min-w-0 flex-1 truncate rounded px-1.5 text-left text-[0.75rem] leading-none text-fg hover:bg-surface-panel/60 dark:hover:bg-surface-panel/40`,AX.press,AX.focusRingPanel,`disabled:pointer-events-none disabled:opacity-50`),onClick:()=>a(e.id),children:e.attachments?.length?(0,Z.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1`,children:[(0,Z.jsx)(Af,{className:`size-3 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:f})]}):(0,Z.jsx)(`span`,{className:`block truncate`,children:f})}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-px`,children:[(0,Z.jsx)(`button`,{type:`button`,disabled:r||t===0,className:X(`inline-flex size-6 items-center justify-center rounded text-fg-muted hover:bg-surface-hover hover:text-fg`,AX.press,AX.focusRingPanel,`disabled:pointer-events-none disabled:opacity-25`),title:h.chat.followUpQueueMoveUp,"aria-label":h.chat.followUpQueueMoveUp,onClick:t=>{t.stopPropagation(),s(e.id,`up`)},children:(0,Z.jsx)(Il,{className:`size-3.5`,"aria-hidden":!0})}),(0,Z.jsx)(`button`,{type:`button`,disabled:r||t>=n.length-1,className:X(`inline-flex size-6 items-center justify-center rounded text-fg-muted hover:bg-surface-hover hover:text-fg`,AX.press,AX.focusRingPanel,`disabled:pointer-events-none disabled:opacity-25`),title:h.chat.followUpQueueMoveDown,"aria-label":h.chat.followUpQueueMoveDown,onClick:t=>{t.stopPropagation(),s(e.id,`down`)},children:(0,Z.jsx)(Nl,{className:`size-3.5`,"aria-hidden":!0})}),(0,Z.jsx)(`button`,{type:`button`,disabled:r||!c||d,className:X(`inline-flex size-6 items-center justify-center rounded text-accent-fg hover:bg-accent-soft/80`,AX.press,AX.focusRingPanel,`disabled:pointer-events-none disabled:opacity-35`),title:h.chat.followUpQueueSteerNow,"aria-label":h.chat.followUpQueueSteerNow,onClick:t=>{t.stopPropagation(),l(e.id)},children:(0,Z.jsx)(oS,{className:X(`size-3.5`,d&&`animate-pulse`),"aria-hidden":!0})}),(0,Z.jsx)(`button`,{type:`button`,disabled:r,className:X(`inline-flex size-6 items-center justify-center rounded text-fg-muted hover:bg-red-500/15 hover:text-red-600 dark:hover:text-red-400`,AX.press,AX.focusRingPanel),title:h.chat.followUpQueueRemove,"aria-label":h.chat.followUpQueueRemove,onClick:t=>{t.stopPropagation(),o(e.id)},children:(0,Z.jsx)(oO,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id)},t[29]=r,t[30]=i,t[31]=n.length,t[32]=h.chat.followUpQueueAttachmentOnly,t[33]=h.chat.followUpQueueClickToEdit,t[34]=h.chat.followUpQueueDrag,t[35]=h.chat.followUpQueueEmptyPreview,t[36]=h.chat.followUpQueueMoveDown,t[37]=h.chat.followUpQueueMoveUp,t[38]=h.chat.followUpQueueRemove,t[39]=h.chat.followUpQueueSteerNow,t[40]=v,t[41]=a,t[42]=s,t[43]=o,t[44]=l,t[45]=u,t[46]=e):e=t[46],C=n.map(e),t[11]=r,t[12]=i,t[13]=n,t[14]=h.chat.followUpQueueAttachmentOnly,t[15]=h.chat.followUpQueueClickToEdit,t[16]=h.chat.followUpQueueDrag,t[17]=h.chat.followUpQueueEmptyPreview,t[18]=h.chat.followUpQueueMoveDown,t[19]=h.chat.followUpQueueMoveUp,t[20]=h.chat.followUpQueueRemove,t[21]=h.chat.followUpQueueSteerNow,t[22]=v,t[23]=a,t[24]=s,t[25]=o,t[26]=l,t[27]=u,t[28]=C}else C=t[28];let w;t[47]!==n||t[48]!==h.chat.followUpQueueAttachmentsNote?(w=n.some(i_e)?(0,Z.jsx)(`p`,{className:`px-1 pt-0.5 text-[0.65rem] leading-tight text-fg-muted`,children:h.chat.followUpQueueAttachmentsNote}):null,t[47]=n,t[48]=h.chat.followUpQueueAttachmentsNote,t[49]=w):w=t[49];let T;return t[50]!==h.chat.followUpQueueAria||t[51]!==S||t[52]!==C||t[53]!==w?(T=(0,Z.jsxs)(`div`,{className:`space-y-0.5 px-2 py-1.5`,role:`list`,"aria-label":y,children:[S,C,w]}),t[50]=h.chat.followUpQueueAria,t[51]=S,t[52]=C,t[53]=w,t[54]=T):T=t[54],T});function n_e(e){return e.language}function r_e(e){e.preventDefault(),e.dataTransfer.dropEffect=`move`}function i_e(e){return e.attachments?.length}function a_e(e){let t=(0,Y.c)(10),{attachments:n,topPadded:r,onRemove:i}=e;if(n.length===0)return null;let a=r?`pt-2`:`pt-3`,o;t[0]===a?o=t[1]:(o=X(`flex flex-wrap gap-2 border-b border-edge-subtle/90 bg-surface-hover/20 px-4 pb-2 dark:border-edge-subtle`,a),t[0]=a,t[1]=o);let s;if(t[2]!==n||t[3]!==i){let e;t[5]===i?e=t[6]:(e=(e,t)=>(0,Z.jsxs)(`div`,{className:`flex max-w-[200px] items-center gap-1.5 rounded-lg bg-surface-hover px-2 py-1 text-xs dark:bg-surface-hover/80`,children:[e.mimeType?.startsWith(`image/`)&&e.content?(0,Z.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.content}`,alt:``,className:`size-6 rounded object-cover`}):e.type===`voice`||e.mimeType?.startsWith(`audio/`)?(0,Z.jsx)(Mg,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,Z.jsx)(Af,{className:`size-3.5 shrink-0 text-fg-muted`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,Z.jsx)(`span`,{className:`text-fg-disabled`,children:PL(e.size)}),(0,Z.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,onClick:()=>i(t),children:`×`})]},e.id??`${e.name}-${e.size}-${e.mimeType}-${e.content?.slice(0,16)??``}`),t[5]=i,t[6]=e),s=n.map(e),t[2]=n,t[3]=i,t[4]=s}else s=t[4];let c;return t[7]!==o||t[8]!==s?(c=(0,Z.jsx)(`div`,{className:o,children:s}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}var o_e=4;function X8(e){return!Number.isFinite(e)||e<=0?0:Math.ceil(e/o_e)}function s_e(e){return e.inputTokens!=null||e.outputTokens!=null?(e.inputTokens??0)+(e.outputTokens??0):e.totalTokens==null?null:e.totalTokens}function Z8(e){let t=0;for(let n of e.content)n.type===`text`||n.type===`thinking`?t+=n.text.length:n.type===`tool_use`&&(t+=JSON.stringify(n.input??``).length,n.result!=null&&(t+=typeof n.result==`string`?n.result.length:JSON.stringify(n.result).length));if(e.attachments?.length)for(let n of e.attachments)t+=(n.extractedText?.length??0)+(n.name?.length??0);return X8(t)}function c_e(e,t=0){for(let n=e.length-1;n>=0;n--){let r=e[n];if(r.role!==`assistant`||!r.usage)continue;let i=s_e(r.usage);if(i==null||i<=0)continue;let a=0;for(let t=n+1;t<e.length;t++)a+=Z8(e[t]);return i+a+X8(t)}let n=0;for(let t of e)n+=Z8(t);return n+X8(t)}function Q8(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var $8=7,e5=2.25,t5=2*Math.PI*$8;function n5(e){if(!Number.isFinite(e)||e<0)return`0`;if(e>=1e6){let t=e/1e6;return`${t>=10?Math.round(t):t.toFixed(1)}M`.replace(/\.0M$/,`M`)}if(e>=1e4)return`${Math.round(e/1e3)}k`;if(e>=1e3){let t=e/1e3;return`${t>=10?Math.round(t):t.toFixed(1)}k`.replace(/\.0k$/,`k`)}return String(Math.round(e))}function l_e(e,t){if(!Number.isFinite(e)||!Number.isFinite(t)||t<=0)return`0`;let n=Math.min(100,Math.max(0,100*e/t));return n>=10||n===0?String(Math.round(n)):n.toFixed(1).replace(/\.0$/,``)}var u_e=(0,J.memo)(function(e){let t=(0,Y.c)(35),{sessionModel:n,messages:r,draftChars:i,chat:a,disabled:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},t[0]=s):s=t[0];let{data:c}=v(s8,c8,s),l;t[1]===c?l=t[2]:(l=c===void 0?[]:c,t[1]=c,t[2]=l);let u=l,d;t[3]!==u||t[4]!==n?(d=u.find(e=>e.id===n)?.contextWindow,t[3]=u,t[4]=n,t[5]=d):d=t[5];let f=d,p=c_e(r,i),m=(f!=null&&f>0?Math.min(1,Math.max(0,p/f)):0)*t5,h;bb0:{if(f!=null&&f>0){let e;t[6]!==a.contextWindowAriaSummary||t[7]!==f||t[8]!==p?(e=Q8(a.contextWindowAriaSummary,{used:n5(p),limit:n5(f)}),t[6]=a.contextWindowAriaSummary,t[7]=f,t[8]=p,t[9]=e):e=t[9],h=e;break bb0}let e;t[10]!==a.contextWindowAriaSummaryNoLimit||t[11]!==p?(e=Q8(a.contextWindowAriaSummaryNoLimit,{used:n5(p)}),t[10]=a.contextWindowAriaSummaryNoLimit,t[11]=p,t[12]=e):e=t[12],h=e}let g=h,_;bb1:{if(f!=null&&f>0){let e;t[13]!==a.contextWindowHoverShort||t[14]!==f||t[15]!==p?(e=Q8(a.contextWindowHoverShort,{percent:l_e(p,f)}),t[13]=a.contextWindowHoverShort,t[14]=f,t[15]=p,t[16]=e):e=t[16],_=e;break bb1}let e;t[17]!==a.contextWindowHoverNoLimit||t[18]!==p?(e=Q8(a.contextWindowHoverNoLimit,{used:n5(p)}),t[17]=a.contextWindowHoverNoLimit,t[18]=p,t[19]=e):e=t[19],_=e}let y=_,b=o||void 0,x=o&&`cursor-default opacity-40`,S;t[20]===x?S=t[21]:(S=X(`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-subtle`,`hover:bg-surface-hover hover:text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,x),t[20]=x,t[21]=S);let C;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Z.jsx)(`circle`,{cx:`9`,cy:`9`,r:$8,fill:`none`,stroke:`currentColor`,className:`text-fg-subtle opacity-[0.35]`,strokeWidth:e5}),t[22]=C):C=t[22];let w=`${m} ${t5}`,T;t[23]===w?T=t[24]:(T=(0,Z.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 18 18`,className:`shrink-0`,"aria-hidden":!0,children:[C,(0,Z.jsx)(`circle`,{cx:`9`,cy:`9`,r:$8,fill:`none`,stroke:`currentColor`,className:`text-fg-muted`,strokeWidth:e5,strokeLinecap:`round`,strokeDasharray:w,transform:`rotate(-90 9 9)`})]}),t[23]=w,t[24]=T);let E;t[25]!==g||t[26]!==T||t[27]!==b||t[28]!==S?(E=(0,Z.jsx)(wZ,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,"aria-disabled":b,"aria-label":g,className:S,children:T})}),t[25]=g,t[26]=T,t[27]=b,t[28]=S,t[29]=E):E=t[29];let D;t[30]===y?D=t[31]:(D=(0,Z.jsx)(TZ,{children:(0,Z.jsx)(EZ,{side:`top`,sideOffset:6,collisionPadding:12,className:`!z-[10000] whitespace-nowrap rounded-lg border border-edge bg-surface-panel px-2 py-1 text-xs font-medium text-fg shadow-md`,children:y})}),t[30]=y,t[31]=D);let O;return t[32]!==E||t[33]!==D?(O=(0,Z.jsx)(SZ,{delayDuration:280,children:(0,Z.jsxs)(CZ,{children:[E,D]})}),t[32]=E,t[33]=D,t[34]=O):O=t[34],O});function d_e(e){return`${e.id} ${e.name} ${e.provider}`.toLowerCase()}function f_e(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=n.split(/\s+/).filter(Boolean);return e.filter(e=>{let t=d_e(e);return r.every(e=>t.includes(e))})}function p_e(e,t,n){if(t!==`vision`)return e;let r=e.filter(e=>e.vision===!0);if(!n||r.some(e=>e.id===n))return r;let i=e.find(e=>e.id===n);if(i)return[i,...r];let a=n.indexOf(`/`),o=a>=0?n.slice(0,a):``;return[{id:n,name:(a>=0?n.slice(a+1):n)||n,provider:o||`—`,vision:!1},...r]}function r5(e){let t=(0,Y.c)(84),{value:n,disabled:r,placeholder:i,searchPlaceholder:a,noMatches:o,capabilitiesFilter:s,outOfFilterNote:c,registryEmptyHint:l,compact:u,showProviderInTrigger:f,contentSide:p,contentAlign:h,className:g,popoverContentClassName:_,showProviderSettingsFooter:y,onChange:b}=e,x=f===void 0?!0:f,S=p===void 0?`bottom`:p,C=h===void 0?`end`:h,w=Qr(),T=d(h_e),E;t[0]===T?E=t[1]:(E=m(T),t[0]=T,t[1]=E);let D=E.chat,[O,k]=(0,J.useState)(!1),[A,j]=(0,J.useState)(``),M=bge(xge()),N;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(N={revalidateOnFocus:!1},t[2]=N):N=t[2];let{data:P,isLoading:F,error:I}=v(s8,c8,N),L;t[3]===P?L=t[4]:(L=P===void 0?[]:P,t[3]=P,t[4]=L);let R=L,z;t[5]===n?z=t[6]:(z=n.trim(),t[5]=n,t[6]=z);let B=z,V;t[7]!==s||t[8]!==R||t[9]!==B?(V=p_e(R,s,B),t[7]=s,t[8]=R,t[9]=B,t[10]=V):V=t[10];let H=V,U;t[11]!==H||t[12]!==A?(U=f_e(H,A),t[11]=H,t[12]=A,t[13]=U):U=t[13];let W=U,G;t[14]!==R||t[15]!==H||t[16]!==n?(G=R.find(e=>e.id===n)??H.find(e=>e.id===n),t[14]=R,t[15]=H,t[16]=n,t[17]=G):G=t[17];let ee=G,K=ee?x?`${ee.name} (${ee.provider})`:ee.name:n||i,te=!I&&s===`vision`&&H.length===0,ne=UP,re=r||F,ie=ee?`${ee.name} (${ee.provider})`:i,ae=u&&`py-1.5 text-[13px]`,oe;t[18]!==g||t[19]!==ae?(oe=X(jA,`items-center gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2 text-left text-sm font-normal text-fg`,AX.transition,`hover:border-edge hover:bg-surface-hover/45`,DA,`disabled:cursor-not-allowed disabled:opacity-50`,`dark:border-edge-subtle dark:hover:bg-surface-hover/55`,ae,g),t[18]=g,t[19]=ae,t[20]=oe):oe=t[20];let se=F?`…`:K,q;t[21]===se?q=t[22]:(q=(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:se}),t[21]=se,t[22]=q);let ce;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,Z.jsx)(Ll,{className:`size-4 shrink-0 text-fg-subtle opacity-70`,"aria-hidden":!0}),t[23]=ce):ce=t[23];let le;t[24]!==re||t[25]!==ie||t[26]!==oe||t[27]!==q?(le=(0,Z.jsx)(vF,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,disabled:re,title:ie,className:oe,children:[q,ce]})}),t[24]=re,t[25]=ie,t[26]=oe,t[27]=q,t[28]=le):le=t[28];let ue=UP,de=UP,fe=X(M,`w-[min(22rem,calc(100vw-2rem))] rounded-xl border border-edge-subtle bg-surface-panel p-1 shadow-elevated dark:border-edge-subtle`,_),pe;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(pe=X(`mb-1 w-full rounded-lg border border-edge-subtle bg-surface-base px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-disabled dark:bg-surface-hover/40`,OA),t[29]=pe):pe=t[29];let me;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(me=e=>j(e.target.value),t[30]=me):me=t[30];let he;t[31]!==A||t[32]!==a?(he=(0,Z.jsx)(`input`,{type:`search`,className:pe,placeholder:a,value:A,onChange:me}),t[31]=A,t[32]=a,t[33]=he):he=t[33];let ge;t[34]===I?ge=t[35]:(ge=I?(0,Z.jsx)(`div`,{className:`p-2 text-xs text-red-600 dark:text-red-400`,children:I instanceof Error?I.message:`Failed to load models`}):null,t[34]=I,t[35]=ge);let _e;t[36]!==I||t[37]!==o||t[38]!==l||t[39]!==te?(_e=!I&&te?(0,Z.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:l??o}):null,t[36]=I,t[37]=o,t[38]=l,t[39]=te,t[40]=_e):_e=t[40];let ve;t[41]!==I||t[42]!==W.length||t[43]!==o||t[44]!==te?(ve=!I&&!te&&W.length===0?(0,Z.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:o}):null,t[41]=I,t[42]=W.length,t[43]=o,t[44]=te,t[45]=ve):ve=t[45];let ye;if(t[46]!==s||t[47]!==W||t[48]!==b||t[49]!==c||t[50]!==n||t[51]!==B){let e;t[53]!==s||t[54]!==b||t[55]!==c||t[56]!==n||t[57]!==B?(e=e=>{let t=!!c&&s===`vision`&&e.vision!==!0&&e.id===B;return(0,Z.jsxs)(`button`,{type:`button`,className:X(`flex w-full flex-col gap-0.5 rounded-md px-2 py-1.5 text-left text-sm text-fg hover:bg-surface-hover`,e.id===n&&`bg-surface-hover/90 font-medium dark:bg-surface-hover/70`),onClick:()=>{b(e.id),k(!1),j(``)},children:[(0,Z.jsxs)(`span`,{className:`flex w-full min-w-0 items-center gap-2`,children:[(0,Z.jsx)(Ml,{className:X(`size-4 shrink-0`,e.id!==n&&`invisible`),"aria-hidden":!0}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:e.name}),` `,(0,Z.jsxs)(`span`,{className:`text-fg-muted`,children:[`(`,e.provider,`)`]})]})]}),t?(0,Z.jsx)(`span`,{className:`pl-6 text-[11px] leading-snug text-amber-700 dark:text-amber-300`,children:c}):null]},e.id)},t[53]=s,t[54]=b,t[55]=c,t[56]=n,t[57]=B,t[58]=e):e=t[58],ye=W.map(e),t[46]=s,t[47]=W,t[48]=b,t[49]=c,t[50]=n,t[51]=B,t[52]=ye}else ye=t[52];let be;t[59]!==ge||t[60]!==_e||t[61]!==ve||t[62]!==ye?(be=(0,Z.jsxs)(`div`,{className:`max-h-60 overflow-auto`,children:[ge,_e,ve,ye]}),t[59]=ge,t[60]=_e,t[61]=ve,t[62]=ye,t[63]=be):be=t[63];let xe;t[64]!==D||t[65]!==w||t[66]!==y?(xe=y?(0,Z.jsx)(`div`,{className:`mt-1 border-t border-edge-subtle pt-1`,children:(0,Z.jsxs)(`button`,{type:`button`,className:X(`flex w-full items-center gap-2 rounded-md p-2 text-left text-sm font-medium text-accent`,AX.transition,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),onClick:()=>{w(`/settings/providers`),k(!1),j(``)},children:[(0,Z.jsx)(qb,{className:`size-4 shrink-0 opacity-90`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0`,children:D.modelProviderSettingsLink})]})}):null,t[64]=D,t[65]=w,t[66]=y,t[67]=xe):xe=t[67];let Se;t[68]!==C||t[69]!==S||t[70]!==de.Content||t[71]!==fe||t[72]!==he||t[73]!==be||t[74]!==xe?(Se=(0,Z.jsxs)(de.Content,{className:fe,side:S,sideOffset:4,align:C,onOpenAutoFocus:m_e,children:[he,be,xe]}),t[68]=C,t[69]=S,t[70]=de.Content,t[71]=fe,t[72]=he,t[73]=be,t[74]=xe,t[75]=Se):Se=t[75];let Ce;t[76]!==ue.Portal||t[77]!==Se?(Ce=(0,Z.jsx)(ue.Portal,{children:Se}),t[76]=ue.Portal,t[77]=Se,t[78]=Ce):Ce=t[78];let we;return t[79]!==O||t[80]!==ne.Root||t[81]!==le||t[82]!==Ce?(we=(0,Z.jsxs)(ne.Root,{open:O,onOpenChange:k,children:[le,Ce]}),t[79]=O,t[80]=ne.Root,t[81]=le,t[82]=Ce,t[83]=we):we=t[83],we}function m_e(e){return e.preventDefault()}function h_e(e){return e.language}var i5=`xopc.recentWorkspaceDirs.v1`,g_e=10;function __e(){try{let e=localStorage.getItem(i5);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`&&e.trim().length>0):[]}catch{return[]}}function v_e(e){let t=e.trim();if(t)try{let e=[t,...__e().filter(e=>e!==t)].slice(0,g_e);localStorage.setItem(i5,JSON.stringify(e))}catch{}}function a5(e){let t=e.trim().replace(/[/\\]+$/,``);if(!t)return e;let n=t.split(/[/\\]/);return n[n.length-1]||t}function o5(e){let t=(0,Y.c)(27),{value:n,onPick:r,disabled:i,placeholder:a,title:o,className:s,maxWidthClass:c,compact:l,"aria-label":u}=e,d=c===void 0?`max-w-[min(12rem,40vw)]`:c,f=l===void 0?!1:l,p,m;t[0]!==a||t[1]!==n?(m=n.trim(),p=m?a5(m):a??``,t[0]=a,t[1]=n,t[2]=p,t[3]=m):(p=t[2],m=t[3]);let h=p,g=o??(m||void 0),_=u??o??h,v=f?`inline-flex size-9 shrink-0 items-center justify-center rounded-lg p-0`:`inline-flex min-h-8 min-w-0 shrink-0 items-center gap-1 rounded-lg px-2 py-1 text-xs`,y=!f&&d,b=i&&`cursor-not-allowed opacity-60`,x;t[4]!==s||t[5]!==v||t[6]!==y||t[7]!==b?(x=X(v,`border border-edge-subtle/80 bg-surface-hover/40 dark:border-edge-subtle`,AX.transition,AX.focusRingPanel,`cursor-pointer hover:bg-surface-hover/70 dark:hover:bg-surface-hover/50`,y,b,s),t[4]=s,t[5]=v,t[6]=y,t[7]=b,t[8]=x):x=t[8];let S;t[9]!==i||t[10]!==r?(S=e=>{e.stopPropagation(),i||r()},t[9]=i,t[10]=r,t[11]=S):S=t[11];let C=f?`size-4`:`size-3.5`,w;t[12]===C?w=t[13]:(w=X(`shrink-0 text-fg-muted`,C),t[12]=C,t[13]=w);let T;t[14]===w?T=t[15]:(T=(0,Z.jsx)(hp,{className:w,"aria-hidden":!0}),t[14]=w,t[15]=T);let E;t[16]!==f||t[17]!==h?(E=f?null:(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-left font-medium text-fg`,children:h}),t[16]=f,t[17]=h,t[18]=E):E=t[18];let D;return t[19]!==i||t[20]!==S||t[21]!==T||t[22]!==E||t[23]!==g||t[24]!==_||t[25]!==x?(D=(0,Z.jsxs)(`button`,{type:`button`,disabled:i,title:g,"aria-label":_,className:x,onClick:S,children:[T,E]}),t[19]=i,t[20]=S,t[21]=T,t[22]=E,t[23]=g,t[24]=_,t[25]=x,t[26]=D):D=t[26],D}async function y_e(e){let t=typeof window<`u`?window.electronAPI?.file?.openDirectory:void 0;if(!t)return null;let n=e?.trim();return n?t({defaultPath:n}):t()}function s5(e={}){let{initialPath:t,onPicked:n,trackRecent:r=!0}=e,[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(!1),c=typeof window<`u`&&!!window.electronAPI?.file?.openDirectory,l=(0,J.useCallback)(async e=>{let t=e.trim();t&&(r&&v_e(t),await n?.(t))},[n,r]);return{hasNativePicker:c,modalOpen:i,setModalOpen:a,pick:(0,J.useCallback)(()=>{if(c){(async()=>{s(!0);try{let e=await y_e(t);e&&await l(e)}finally{s(!1)}})();return}a(!0)},[l,c,t]),confirmPick:l,picking:o}}function b_e(){return function(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`patch`:return{...e,form:e.form?{...e.form,...t.patch}:null};case`discard`:return e.baseline?{form:structuredClone(e.baseline),baseline:e.baseline}:e;case`saved`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`set-form`:return e.form?{...e,form:t.updater(e.form)}:e}}}function c5(e,t){return{...e,...t.patch}}function x_e(e){let{enabled:t,parsed:n,dirty:r,trackedParsedRef:i,dispatch:a,onResetDirty:o}=e;if(!t){i.current!==null&&(i.current=null,a({type:`reset`}),o?.());return}n!==null&&!r&&i.current!==n&&(i.current=n,a({type:`sync`,value:n}))}async function l5(e){let t=new URLSearchParams;e!=null&&e!==``&&t.set(`path`,e);let n=t.toString();return(await we(_(`/api/host/fs/list${n?`?${n}`:``}`))).payload}async function S_e(){return(await we(_(`/api/host/fs/meta`))).payload}function C_e(){return X(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-sm text-fg`,`placeholder:text-fg-subtle`,kA,`dark:border-edge`)}function u5(e){return/^[A-Za-z]:\\?$/.test(e.replace(/\\$/,`\\`))}function w_e(e){return!e||e.currentPath===``?!1:e.parentPath===null?e.currentPath===`/`?!1:!!u5(e.currentPath):!0}var T_e={metaHostname:null,listState:null,listLoading:!1,listError:null,manualPath:``};function d5({open:e,onOpenChange:t,initialAbsolutePath:n,onConfirm:r,wd:i}){let a=(0,J.useId)(),[o,s]=(0,J.useReducer)(c5,T_e),{metaHostname:c,listState:l,listLoading:u,listError:d,manualPath:f}=o,p=(0,J.useCallback)(async e=>{s({type:`patch`,patch:{listLoading:!0,listError:null}});try{s({type:`patch`,patch:{listState:await l5(e)}})}catch(e){s({type:`patch`,patch:{listError:e instanceof Error?e.message:String(e),listState:null}})}finally{s({type:`patch`,patch:{listLoading:!1}})}},[]);(0,J.useEffect)(()=>{if(!e)return;let t=!1;return(async()=>{try{let e=await S_e();t||s({type:`patch`,patch:{metaHostname:e.hostname}})}catch{t||s({type:`patch`,patch:{metaHostname:null}})}})(),()=>{t=!0}},[e]),(0,J.useEffect)(()=>{if(!e)return;let t=n?.trim()??``;s({type:`patch`,patch:{manualPath:t}});let r=!1;return(async()=>{s({type:`patch`,patch:{listLoading:!0,listError:null}});try{if(t)try{let e=await l5(t);r||s({type:`patch`,patch:{listState:e}})}catch{let e=await l5();r||s({type:`patch`,patch:{listState:e}})}else{let e=await l5();r||s({type:`patch`,patch:{listState:e}})}}catch(e){let t=e instanceof Error?e.message:String(e);r||s({type:`patch`,patch:{listError:t,listState:null}})}finally{r||s({type:`patch`,patch:{listLoading:!1}})}})(),()=>{r=!0}},[e,n]);let m=e=>{e.isDirectory&&p(e.absolutePath)},h=()=>{if(!l)return;let{parentPath:e,currentPath:t}=l;if(e!==null){p(e);return}t===`/`||t===``||u5(t)&&p(void 0)},g=l?.currentPath===``?i.pickerDrives:l?.currentPath??``,_=!!l&&l.currentPath!==``&&!u&&!d,v=async()=>{if(!(!l||l.currentPath===``))try{await r(l.currentPath),t(!1)}catch{}},y=async()=>{let e=f.trim();if(e)try{await r(e),t(!1)}catch{}},b=u&&l;return(0,Z.jsx)(q,{open:e,onOpenChange:t,children:(0,Z.jsxs)(G,{children:[(0,Z.jsx)(ie,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Z.jsxs)(se,{className:X(`fixed left-1/2 top-1/2 z-[81] flex max-h-[min(90vh,32rem)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 flex-col rounded-xl border border-edge bg-surface-panel p-4 shadow-popover`,`dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsx)(ue,{className:`text-base font-semibold text-fg`,children:i.pathModalTitle}),(0,Z.jsx)(le,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:i.pathModalDescription}),c?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:i.pickerHostHint.replace(`{{hostname}}`,c)}):null,(0,Z.jsxs)(`div`,{className:`mt-3 flex min-h-0 flex-1 flex-col gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(wA,{type:`button`,variant:`secondary`,className:`shrink-0 gap-1 px-2 py-1.5 text-xs`,disabled:u||!w_e(l)||!!d,onClick:()=>h(),title:i.pickerUp,children:[(0,Z.jsx)(Il,{className:`size-4`,"aria-hidden":!0}),i.pickerUp]}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 truncate rounded-md border border-edge-subtle/80 bg-surface-hover/30 px-2 py-1.5 font-mono text-xs text-fg`,title:g,children:u&&!l?i.pickerLoading:g||`—`})]}),(0,Z.jsxs)(`div`,{className:X(`relative min-h-[12rem] overflow-y-auto rounded-lg border border-edge-subtle/80 bg-surface-hover/20 p-1 dark:border-edge-subtle`,AX.focusRingPanel),role:`listbox`,"aria-label":i.pathModalTitle,children:[b?(0,Z.jsx)(`div`,{className:`absolute inset-0 z-[1] flex items-center justify-center rounded-lg bg-surface-panel/60`,"aria-hidden":!0,children:(0,Z.jsx)(Cg,{className:`size-6 animate-spin text-fg-muted`})}):null,u&&!l?(0,Z.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-12 text-sm text-fg-muted`,children:[(0,Z.jsx)(Cg,{className:`size-4 animate-spin`,"aria-hidden":!0}),i.pickerLoading]}):null,d?(0,Z.jsx)(`p`,{className:`px-2 py-8 text-center text-sm text-fg-muted`,children:i.pickerListError}):null,!u&&l&&!d&&l.entries.length===0?(0,Z.jsx)(`p`,{className:`px-2 py-8 text-center text-sm text-fg-muted`,children:i.pickerEmptyFolder}):null,l?.entries.map(e=>(0,Z.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":!1,disabled:!e.isDirectory,className:X(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm`,e.isDirectory?`cursor-pointer text-fg hover:bg-surface-hover`:`cursor-default text-fg-muted opacity-60`),onClick:()=>m(e),children:[(0,Z.jsx)(hp,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name})]},e.absolutePath))]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:a,className:`text-xs text-fg-muted`,children:i.pickerManualPath}),(0,Z.jsx)(`input`,{id:a,type:`text`,value:f,onChange:e=>s({type:`patch`,patch:{manualPath:e.target.value}}),placeholder:i.pathInputPlaceholder,className:C_e(),autoComplete:`off`,spellCheck:!1,onKeyDown:e=>{e.key===`Enter`&&f.trim()&&(e.preventDefault(),y())}})]})]}),(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-end gap-2 border-t border-edge-subtle/60 pt-3`,children:[(0,Z.jsx)(wA,{type:`button`,variant:`ghost`,onClick:()=>t(!1),children:i.pathModalCancel}),(0,Z.jsx)(wA,{type:`button`,variant:`secondary`,disabled:!f.trim(),onClick:()=>void y(),children:i.pickerApplyManual}),(0,Z.jsx)(wA,{type:`button`,disabled:!_,onClick:()=>void v(),children:i.pickerUseThisFolder})]})]})]})})}var E_e=(0,J.memo)(function({sessionKey:e,disabled:t,canSelectWorkingDirectory:n,sessionMgr:r}){let i=m(d(e=>e.language)).chat.workingDirectory,a=cQ(e=>e.toggleOpen),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(!1),[u,f]=(0,J.useState)(!1),[p,h]=(0,J.useState)(null),g=(0,J.useCallback)(async()=>{if(!e){s(``);return}l(!0);try{s((await r.loadSessionAgentConfig(e)).effectiveWorkspacePath)}catch{s(``)}finally{l(!1)}},[e,r]);(0,J.useEffect)(()=>{g()},[g]);let _=s5({initialPath:o,onPicked:(0,J.useCallback)(async t=>{if(!(!e?.trim()||!t.trim()))try{await r.patchSessionAgentConfig(e,{workingDirectory:t.trim()}),await g()}catch(e){throw h(e instanceof Error?e.message:String(e)),f(!0),e}},[e,r,g])}),v=(0,J.useCallback)(()=>{window.dispatchEvent(new CustomEvent(`extension-notification`,{detail:{type:`info`,title:i.lockedTapTitle,message:i.lockedTapBody,duration:6500}}))},[i.lockedTapBody,i.lockedTapTitle]);if(!e)return null;let y=o.trim(),b=!!y,x=b?a5(y):i.notSet,S=X(`inline-flex min-h-8 max-w-[min(12rem,40vw)] min-w-0 shrink-0 items-center gap-1 rounded-lg px-2 py-1 text-xs`,`border border-edge-subtle/80 bg-surface-hover/40 dark:border-edge-subtle`,AX.transition,AX.focusRingPanel),C=e=>{let{hasPath:t,fullPath:n,canSelect:r}=e,a;return a=!r&&t?i.tooltipOpenProjectFiles:r?t?i.chooseFolder:i.selectWorkingDirectory:i.selectionOnlyAtNewChat,(0,Z.jsxs)(`div`,{className:`max-w-[min(22rem,90vw)] space-y-1.5`,children:[(0,Z.jsx)(`p`,{className:`font-semibold text-fg`,children:i.tooltipAgentWorkspace}),t?(0,Z.jsx)(`p`,{className:`break-words font-mono text-[11px] leading-snug text-fg-muted`,children:n}):(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-muted`,children:i.notSet}),(0,Z.jsx)(`p`,{className:`text-[11px] leading-snug text-fg-subtle`,children:a})]})},w=(e,t)=>(0,Z.jsxs)(CZ,{delayDuration:350,children:[(0,Z.jsx)(wZ,{asChild:!0,children:t}),(0,Z.jsx)(TZ,{children:(0,Z.jsx)(EZ,{side:`top`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-w-[min(22rem,90vw)] rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-snug text-fg shadow-lg`,children:e})})]}),T=()=>w(C({hasPath:!1,fullPath:``,canSelect:!1}),(0,Z.jsxs)(`button`,{type:`button`,className:X(S,`cursor-pointer text-left text-fg-muted hover:bg-surface-hover/70 dark:hover:bg-surface-hover/50`),"aria-label":`${i.notSet}. ${i.selectionOnlyAtNewChat}`,onClick:e=>{e.stopPropagation(),v()},children:[(0,Z.jsx)(hp,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-left font-medium text-fg`,children:x})]})),E=()=>w(C({hasPath:!0,fullPath:y,canSelect:!1}),(0,Z.jsxs)(`button`,{type:`button`,disabled:t||c||!b,className:X(S,b&&`cursor-pointer hover:bg-surface-hover/70 dark:hover:bg-surface-hover/50`,(t||c||!b)&&`cursor-not-allowed opacity-60`),"aria-label":`${i.tooltipAgentWorkspace}: ${y}`,onClick:e=>{e.stopPropagation(),b&&!t&&!c&&a()},children:[(0,Z.jsx)(hp,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-left font-medium text-fg`,children:x})]}));if(!n)return b?(0,Z.jsx)(SZ,{delayDuration:350,children:(0,Z.jsx)(`div`,{className:`inline-flex items-center`,children:E()})}):(0,Z.jsx)(SZ,{delayDuration:350,children:(0,Z.jsx)(`div`,{className:`inline-flex items-center`,children:T()})});let D=b&&!t&&!c?`${i.tooltipAgentWorkspace}: ${y}. ${i.chooseFolder}`:b?`${i.tooltipAgentWorkspace}: ${y}`:i.selectWorkingDirectory;return(0,Z.jsx)(SZ,{delayDuration:350,children:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`inline-flex items-center`,children:w(C({hasPath:b,fullPath:y,canSelect:!0}),(0,Z.jsx)(o5,{value:y,onPick:_.pick,disabled:t||c||_.picking,placeholder:i.notSet,"aria-label":D,className:X((t||c||_.picking)&&`cursor-not-allowed opacity-60`)}))}),_.hasNativePicker?null:(0,Z.jsx)(d5,{open:_.modalOpen,onOpenChange:_.setModalOpen,initialAbsolutePath:y||void 0,onConfirm:_.confirmPick,wd:i}),(0,Z.jsx)(q,{open:u,onOpenChange:e=>{f(e),e||h(null)},children:(0,Z.jsxs)(G,{children:[(0,Z.jsx)(ie,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Z.jsxs)(se,{className:X(`fixed left-1/2 top-1/2 z-[81] w-[min(100%-2rem,26rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-4 shadow-popover`,`dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsx)(ue,{className:`text-base font-semibold text-fg`,children:i.applyErrorTitle}),p?(0,Z.jsx)(le,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-fg-muted`,children:p}):null,(0,Z.jsx)(`div`,{className:`mt-4 flex items-center justify-end border-t border-edge-subtle/60 pt-3`,children:(0,Z.jsx)(wA,{type:`button`,onClick:()=>f(!1),children:i.applyErrorClose})})]})]})})]})})});function D_e(e){return e===`off`?yc:oS}var O_e=(0,J.memo)(function(e){let t=(0,Y.c)(87),{sessionKey:n,sessionManager:r,disabled:i,sending:a,streaming:o,canSelectWorkingDirectory:s,runBusy:c,chat:l,hasDraft:u,showSteeringInterrupt:d,attachmentCount:f,maxAttachments:p,onPickFiles:m,thinkingLevel:h,showThinkingSelector:g,onThinkingChange:_,voiceActive:v,onStartVoiceInput:y,onSend:b,onAbort:x,onInterrupt:S,sessionModel:C,showModelSelector:w,onModelChange:T,modelDisabled:E,contextUsageMessages:D,composerDraftChars:O}=e,[k,A]=(0,J.useState)(!1),j=h,M;t[0]===j?M=t[1]:(M=D_e(j),t[0]=j,t[1]=M);let N=M,P=f>=p,F;t[2]!==f||t[3]!==P||t[4]!==l.attachFile||t[5]!==l.maxAttachmentsReached||t[6]!==p?(F=P?Q8(l.maxAttachmentsReached,{max:p}):`${l.attachFile} (${f}/${p})`,t[2]=f,t[3]=P,t[4]=l.attachFile,t[5]=l.maxAttachmentsReached,t[6]=p,t[7]=F):F=t[7];let I=F,L;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(L=X(`flex flex-wrap items-center gap-2 border-t border-edge-subtle/90 px-4 py-2.5 dark:border-edge-subtle`),t[8]=L):L=t[8];let R=i||c,z;t[9]!==s||t[10]!==n||t[11]!==r||t[12]!==R?(z=(0,Z.jsx)(E_e,{sessionKey:n,sessionMgr:r,canSelectWorkingDirectory:s,disabled:R}),t[9]=s,t[10]=n,t[11]=r,t[12]=R,t[13]=z):z=t[13];let B;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(B=X(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover/70 text-fg-subtle hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/50`,AX.transition,AX.press,AX.focusRingPanel),t[14]=B):B=t[14];let V;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Z.jsx)(xv,{className:`size-4`}),t[15]=V):V=t[15];let H;t[16]!==l.moreActions||t[17]!==k?(H=(0,Z.jsx)(vF,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:B,title:l.moreActions,"aria-label":l.moreActions,"aria-expanded":k,children:V})}),t[16]=l.moreActions,t[17]=k,t[18]=H):H=t[18];let U;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(U=X(`z-50 min-w-[12rem] rounded-xl border border-edge bg-surface-panel p-1.5 shadow-popover dark:border-edge`),t[19]=U):U=t[19];let W;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(W=X(`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:cursor-not-allowed disabled:opacity-50`),t[20]=W):W=t[20];let G=P||i||c,ee;t[21]===m?ee=t[22]:(ee=()=>{m(),A(!1)},t[21]=m,t[22]=ee);let K;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,Z.jsx)(Af,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[23]=K):K=t[23];let te;t[24]===l.attachFile?te=t[25]:(te=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:l.attachFile}),t[24]=l.attachFile,t[25]=te);let ne;t[26]!==f||t[27]!==p?(ne=(0,Z.jsxs)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:[f,`/`,p]}),t[26]=f,t[27]=p,t[28]=ne):ne=t[28];let re;t[29]!==I||t[30]!==G||t[31]!==ee||t[32]!==te||t[33]!==ne?(re=(0,Z.jsxs)(`button`,{type:`button`,className:W,disabled:G,title:I,onClick:ee,children:[K,te,ne]}),t[29]=I,t[30]=G,t[31]=ee,t[32]=te,t[33]=ne,t[34]=re):re=t[34];let ie;t[35]!==N||t[36]!==i||t[37]!==l.thinkingLevelLabel||t[38]!==l.thinkingLevels||t[39]!==_||t[40]!==a||t[41]!==g||t[42]!==o||t[43]!==h?(ie=g?(0,Z.jsxs)(`label`,{className:X(`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-sm text-fg`,`hover:bg-surface-hover`),title:`${l.thinkingLevelLabel}: ${l.thinkingLevels[h]??h}`,children:[(0,Z.jsx)(N,{className:`size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:l.thinkingLevelLabel}),(0,Z.jsx)(`select`,{className:`min-w-0 flex-1 cursor-pointer appearance-none rounded-md bg-surface-hover/80 px-2 py-0.5 text-sm font-medium text-fg focus:outline-none focus-visible:ring-2 focus-visible:ring-accent`,value:h,disabled:i||a&&!o,onChange:e=>_(e.target.value),children:Object.keys(l.thinkingLevels).map(e=>(0,Z.jsx)(`option`,{value:e,children:l.thinkingLevels[e]},e))})]}):null,t[35]=N,t[36]=i,t[37]=l.thinkingLevelLabel,t[38]=l.thinkingLevels,t[39]=_,t[40]=a,t[41]=g,t[42]=o,t[43]=h,t[44]=ie):ie=t[44];let ae;t[45]!==re||t[46]!==ie?(ae=(0,Z.jsx)(yF,{children:(0,Z.jsx)(bF,{className:U,side:`top`,align:`start`,sideOffset:8,collisionPadding:12,onOpenAutoFocus:k_e,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[re,ie]})})}),t[45]=re,t[46]=ie,t[47]=ae):ae=t[47];let oe;t[48]!==k||t[49]!==ae||t[50]!==H?(oe=(0,Z.jsxs)(gF,{open:k,onOpenChange:A,children:[H,ae]}),t[48]=k,t[49]=ae,t[50]=H,t[51]=oe):oe=t[51];let se;t[52]!==O||t[53]!==D||t[54]!==l||t[55]!==E||t[56]!==T||t[57]!==C||t[58]!==w?(se=w?(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 w-fit max-w-[min(20rem,calc(100vw-10rem))] shrink-0`,children:(0,Z.jsx)(r5,{value:C,disabled:E,placeholder:l.modelPlaceholder,searchPlaceholder:l.modelSearchPlaceholder,noMatches:l.modelNoMatches,compact:!0,showProviderInTrigger:!1,contentSide:`top`,contentAlign:`end`,showProviderSettingsFooter:!0,onChange:T})}),(0,Z.jsx)(u_e,{sessionModel:C,messages:D,draftChars:O,chat:l,disabled:E})]}):null,t[52]=O,t[53]=D,t[54]=l,t[55]=E,t[56]=T,t[57]=C,t[58]=w,t[59]=se):se=t[59];let q;t[60]!==i||t[61]!==l.voiceInput||t[62]!==y||t[63]!==v?(q=v?null:(0,Z.jsx)(`button`,{type:`button`,className:X(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg border border-transparent text-fg-subtle hover:bg-surface-hover hover:text-fg`,AX.transition,AX.press,AX.focusRingPanel,`disabled:cursor-not-allowed disabled:opacity-50`),disabled:i,title:l.voiceInput,"aria-label":l.voiceInput,onClick:()=>void y(),children:(0,Z.jsx)(Mg,{className:`size-4 stroke-[1.75]`})}),t[60]=i,t[61]=l.voiceInput,t[62]=y,t[63]=v,t[64]=q):q=t[64];let ce;t[65]!==i||t[66]!==u||t[67]!==l.abort||t[68]!==l.sendMessage||t[69]!==l.steeringInterruptSend||t[70]!==x||t[71]!==S||t[72]!==b||t[73]!==c||t[74]!==d||t[75]!==v?(ce=c?(0,Z.jsxs)(Z.Fragment,{children:[d&&S?(0,Z.jsx)(`button`,{type:`button`,className:X(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg border border-transparent text-accent-fg hover:bg-accent-soft dark:hover:bg-accent-soft`,AX.transition,AX.press,AX.focusRingPanel),title:l.steeringInterruptSend,"aria-label":l.steeringInterruptSend,onClick:()=>void S(),children:(0,Z.jsx)(Vb,{className:`size-4 stroke-[1.75]`})}):null,(0,Z.jsx)(`button`,{type:`button`,className:X(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover/70 text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/50`,AX.transition,AX.press,AX.focusRingPanel),title:l.abort,"aria-label":l.abort,onClick:x,children:(0,Z.jsx)(NC,{className:`size-4 stroke-[1.75]`})})]}):(0,Z.jsx)(`button`,{type:`button`,className:X(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg border transition-colors duration-150 ease-out`,AX.press,AX.focusRingPanel,u?`border-transparent text-accent-fg hover:bg-accent-soft dark:text-accent-fg dark:hover:bg-accent-soft`:`border-transparent text-fg-disabled`),disabled:i||v||!u,title:l.sendMessage,"aria-label":l.sendMessage,onClick:b,children:(0,Z.jsx)(Vb,{className:`size-4 stroke-[1.75]`})}),t[65]=i,t[66]=u,t[67]=l.abort,t[68]=l.sendMessage,t[69]=l.steeringInterruptSend,t[70]=x,t[71]=S,t[72]=b,t[73]=c,t[74]=d,t[75]=v,t[76]=ce):ce=t[76];let le;t[77]!==q||t[78]!==ce?(le=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[q,ce]}),t[77]=q,t[78]=ce,t[79]=le):le=t[79];let ue;t[80]!==se||t[81]!==le?(ue=(0,Z.jsxs)(`div`,{className:`ml-auto flex min-w-0 items-center gap-2`,children:[se,le]}),t[80]=se,t[81]=le,t[82]=ue):ue=t[82];let de;return t[83]!==oe||t[84]!==ue||t[85]!==z?(de=(0,Z.jsxs)(`div`,{className:L,children:[z,oe,ue]}),t[83]=oe,t[84]=ue,t[85]=z,t[86]=de):de=t[86],de});function k_e(e){return e.preventDefault()}function A_e(e){return e.map(e=>({type:e.type===`voice`?`voice`:(e.mimeType??``).startsWith(`image/`)?`image`:`document`,mimeType:e.mimeType??`application/octet-stream`,content:e.data??``,name:e.name??`file`,size:e.size??0,workspaceRelativePath:e.workspaceRelativePath,...typeof e.durationSeconds==`number`&&Number.isFinite(e.durationSeconds)&&e.durationSeconds>0?{durationSeconds:e.durationSeconds}:{}}))}var j_e=100,M_e=400,f5=900;function N_e(e,t){switch(t.type){case`reset`:return{box:null,hoverPreview:null};case`set-box`:return{...e,box:t.box};case`set-hover`:return{...e,hoverPreview:t.hoverPreview}}}function P_e(e,t){let n=t.trim().toLowerCase();if(!n)return[];let r=e.toLowerCase(),i=[],a=0;for(let e=0;e<r.length&&a<n.length;e++)r[e]===n[a]&&(i.push([e,e+1]),a++);return i}function F_e(e){let t=(0,Y.c)(8),{name:n,query:r}=e,i;t[0]!==n||t[1]!==r?(i=P_e(n,r),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a=i;if(a.length===0){let e;return t[3]===n?e=t[4]:(e=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n}),t[3]=n,t[4]=e),e}let o;if(t[5]!==n||t[6]!==a){let e=[],r=0;a.forEach(t=>{let[i,a]=t;i>r&&e.push((0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n.slice(r,i)},`pre-${i}`)),e.push((0,Z.jsx)(`span`,{className:`font-semibold text-accent-fg`,children:n.slice(i,a)},`hl-${i}-${a}`)),r=a}),r<n.length&&e.push((0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n.slice(r)},`tail`)),o=(0,Z.jsx)(Z.Fragment,{children:e}),t[5]=n,t[6]=a,t[7]=o}else o=t[7];return o}var I_e=(0,J.memo)(function(e){let t=(0,Y.c)(39),{open:n,anchorRef:r,items:i,selectedIndex:a,loading:o,query:s,noResults:c,sessionKey:l,recentLabel:u,ariaLabel:d,onSelectItem:f,shiftHint:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m={box:null,hoverPreview:null},t[0]=m):m=t[0];let[h,g]=(0,J.useReducer)(N_e,m),_=h.box,v=h.hoverPreview,y=(0,J.useRef)(null),b=(0,J.useRef)(0),x;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{y.current&&=(clearTimeout(y.current),null)},t[1]=x):x=t[1];let S=x,C;t[2]===l?C=t[3]:(C=(e,t,n)=>{S(),b.current+=1;let r=b.current,i=e.relativePath;if(!l?.trim()||e.isDirectory||e.isBrowseUp||!i){g({type:`set-hover`,hoverPreview:null});return}y.current=setTimeout(()=>{y.current=null,r===b.current&&qH(i,{sessionKey:l}).then(e=>{let{content:i}=e,a=i.length>f5?`${i.slice(0,f5)}…`:i;r===b.current&&g({type:`set-hover`,hoverPreview:{text:a,x:t,y:n}})}).catch(()=>{r===b.current&&g({type:`set-hover`,hoverPreview:null})})},420)},t[2]=l,t[3]=C);let w=C,T,E;if(t[4]!==r||t[5]!==n?(T=()=>{if(!n){g({type:`reset`}),S(),b.current+=1;return}let e=()=>{let e=r.current;if(!e)return;let t=e.getBoundingClientRect();g({type:`set-box`,box:{left:t.left,top:t.top,width:t.width}})};e();let t=r.current,i=t&&typeof ResizeObserver<`u`?new ResizeObserver(()=>{e()}):null;return t&&i&&i.observe(t),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{t&&i&&i.disconnect(),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},E=[n,r],t[4]=r,t[5]=n,t[6]=T,t[7]=E):(T=t[6],E=t[7]),(0,J.useLayoutEffect)(T,E),!n||typeof document>`u`||_===null)return null;let D=i.length,O=Math.min(_.width,M_e),k;t[8]!==_.left||t[9]!==_.top||t[10]!==O?(k={position:`fixed`,left:_.left,top:_.top,width:O,transform:`translateY(calc(-100% - 8px))`,zIndex:j_e},t[8]=_.left,t[9]=_.top,t[10]=O,t[11]=k):k=t[11];let A=a>=0&&a<D?`at-mention-${a}`:void 0,j;t[12]!==o||t[13]!==D?(j=o&&D===0?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2.5 text-sm text-fg-muted`,children:[(0,Z.jsx)(Cg,{className:`size-4 shrink-0 animate-spin`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:`…`})]}):null,t[12]=o,t[13]=D,t[14]=j):j=t[14];let M;t[15]!==i||t[16]!==o||t[17]!==c||t[18]!==f||t[19]!==s||t[20]!==u||t[21]!==w||t[22]!==a||t[23]!==D?(M=!o&&D===0?(0,Z.jsx)(`div`,{className:`px-3 py-2 text-sm text-fg-muted`,children:c}):(0,Z.jsx)(Z.Fragment,{children:i.map((e,t)=>(0,Z.jsxs)(`div`,{id:`at-mention-${t}`,role:`option`,"aria-selected":a===t,tabIndex:-1,className:X(`flex cursor-pointer items-start gap-2 px-3 py-2 text-left text-sm`,a===t?`bg-surface-hover text-fg`:`text-fg-subtle hover:bg-surface-hover/80`,e.isRecent&&`border-l-2 border-l-accent/60`),onPointerDown:t=>{t.pointerType===`mouse`&&t.button!==0||(t.preventDefault(),f(e,{shiftKey:t.shiftKey}))},onPointerEnter:t=>w(e,t.clientX,t.clientY),onPointerLeave:()=>{S(),b.current+=1,g({type:`set-hover`,hoverPreview:null})},children:[(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:e.isBrowseUp?(0,Z.jsx)(Np,{className:`size-3.5 text-fg-muted`,"aria-hidden":!0}):e.isDirectory?(0,Z.jsx)(Np,{className:`size-3.5 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}):(0,Z.jsx)(xf,{className:X(`size-3.5`,RH(e.name)),"aria-hidden":!0})}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 truncate`,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:(0,Z.jsx)(F_e,{name:e.name,query:s})}),e.isRecent?(0,Z.jsx)(`span`,{className:`shrink-0 rounded bg-accent-soft px-1 py-0 text-[0.65rem] text-accent-fg`,children:u}):null]}),(0,Z.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:e.relativePath||`—`})]})]},`${e.relativePath}-${e.name}`))}),t[15]=i,t[16]=o,t[17]=c,t[18]=f,t[19]=s,t[20]=u,t[21]=w,t[22]=a,t[23]=D,t[24]=M):M=t[24];let N;t[25]!==d||t[26]!==A||t[27]!==j||t[28]!==M?(N=(0,Z.jsxs)(`div`,{className:`max-h-[min(26rem,54vh)] overflow-y-auto`,role:`listbox`,"aria-label":d,"aria-activedescendant":A,children:[j,M]}),t[25]=d,t[26]=A,t[27]=j,t[28]=M,t[29]=N):N=t[29];let P;t[30]===p?P=t[31]:(P=p?(0,Z.jsx)(`div`,{className:`border-t border-edge-subtle px-3 py-1.5 text-[0.65rem] text-fg-muted`,children:p}):null,t[30]=p,t[31]=P);let F;t[32]===v?F=t[33]:(F=v?(0,Z.jsx)(`div`,{className:`pointer-events-none fixed z-[200] max-h-48 max-w-sm overflow-auto rounded-md border border-edge bg-surface-panel p-2 font-mono text-[0.7rem] text-fg shadow-lg`,style:{left:Math.min(v.x+12,window.innerWidth-320),top:Math.min(v.y+12,window.innerHeight-200)},children:v.text}):null,t[32]=v,t[33]=F);let I;return t[34]!==N||t[35]!==P||t[36]!==F||t[37]!==k?(I=(0,Xa.createPortal)((0,Z.jsxs)(`div`,{className:`pointer-events-auto max-h-[min(28rem,60vh)] min-h-[2.5rem] overflow-hidden rounded-lg border border-edge bg-surface-panel shadow-lg dark:bg-surface-panel/95`,style:k,role:`presentation`,children:[N,P,F]}),document.body),t[34]=N,t[35]=P,t[36]=F,t[37]=k,t[38]=I):I=t[38],I}),p5=new Set([`abort`,`stop`,`cancel`]);function L_e(e){if(e.kind!==`command`)return!1;if(p5.has(e.name.toLowerCase()))return!0;for(let t of e.aliases??[])if(p5.has(t.toLowerCase()))return!0;return!1}function m5(e,t,n,r){return e.slice(0,t)+r+e.slice(n)}var R_e={skill:(e,t)=>{let n=t.slashRange;if(!n)return;let r=`/skill:${e.name} `,i=m5(t.editor.valueRef.current,n.start,n.end,r),a=n.start+r.length;t.editor.resetEditor({nextText:i,caretOffset:a,focus:!0})},command:(e,t)=>{let n=t.slashRange;if(!n||n.start!==0)return;if(e.acceptsArgs===!0){let r=`/${e.name} `,i=m5(t.editor.valueRef.current,n.start,n.end,r),a=n.start+r.length;t.editor.resetEditor({nextText:i,caretOffset:a,focus:!0});return}let r=`/${e.name}`;if(t.runBusy||t.pendingFollowUpsCount>0){if(L_e(e)){if(!t.callbacks.onAbort)return;t.callbacks.onAbort();let e=t.editor.valueRef.current,r=e.slice(0,n.start)+e.slice(n.end);t.editor.resetEditor({nextText:r,caretOffset:n.start});return}if(!t.callbacks.onAddPendingFollowUp||t.pendingFollowUpsCount>=t.maxPendingFollowUps)return;t.callbacks.onAddPendingFollowUp(r,void 0),t.callbacks.onUserTextCommitted?.(r),t.attachments.clearAttachments(),t.editor.resetEditor();return}t.callbacks.onSend(r,void 0,t.thinkingLevel),t.callbacks.onUserTextCommitted?.(r),t.attachments.clearAttachments(),t.editor.resetEditor()},agent:(e,t)=>{let n=t.slashRange;if(!n||n.start!==0||!t.callbacks.onChatAgentChange)return;let r=t.editor.valueRef.current,i=r.slice(0,n.start)+r.slice(n.end);t.editor.resetEditor({nextText:i,caretOffset:n.start}),t.attachments.clearAttachments(),t.callbacks.onChatAgentChange(e.name)}};function z_e(e,t){let n=R_e[e.kind];n&&n(e,t)}var h5={new:10,help:11,list:12,clear:13,switch:14,models:15,usage:16,skills:17,settings:18,start:19,think:20,reasoning:21,verbose:22,status:23,tts:24},B_e=new Set([`abort`,`archive`]);function g5(e){if(e.kind===`command`){let t=e.name.toLowerCase();if(h5[t]!==void 0)return 0;if(B_e.has(t))return 2}return 1}function _5(e,t){let n=g5(e),r=g5(t);if(n!==r)return n-r;if(n===0){let n=h5[e.name.toLowerCase()]??999,r=h5[t.name.toLowerCase()]??999;if(n!==r)return n-r}let i=e.name.localeCompare(t.name);return i===0?e.id.localeCompare(t.id):i}var V_e=RegExp(`^@file:${F8}`,`u`);function v5(e){if(e.kind!==`command`)return!1;if(p5.has(e.name.toLowerCase()))return!0;for(let t of e.aliases??[])if(p5.has(t.toLowerCase()))return!0;return!1}function y5(e,t){return e.kind!==`command`||e.acceptsArgs===!0||v5(e)||!(t.runBusy||t.pendingFollowUpsCount>0)?!1:t.pendingFollowUpsCount>=t.maxPendingFollowUps}function H_e(e,t){return e.kind!==`command`||e.acceptsArgs===!0||v5(e)||!(t.runBusy||t.pendingFollowUpsCount>0)?!1:t.pendingFollowUpsCount<t.maxPendingFollowUps}function U_e(e,t){let n=0;for(;n<e.length;){let r=e.indexOf(`@file:`,n);if(r===-1)return null;let i=e.slice(r).match(V_e);if(!i){n=r+1;continue}let a=r+i[0].length;if(t>=r&&t<a)return{start:r,end:a};n=a}return null}var W_e=20,b5=3;function G_e(e){return e.includes(`/`)||/^[A-Za-z]:/u.test(e)?!0:/^(Users|home|var|tmp|etc|opt|private|Volumes|System|Applications|Library|usr|dev|bin|sbin|proc|sys)(\/|$)/iu.test(e)}function K_e(e,t){if(t===0)return!1;let n=e[t-1];if(n===void 0||n===`.`||n===`:`||n===`/`)return!0;let r=e.slice(0,t);return/[a-zA-Z0-9-]+\.[a-zA-Z0-9.-]+$/u.test(r)}function q_e(e,t){let n=e.length,r=Math.min(Math.max(t,0),n);if(r<1&&e===`/`&&(r=1),r<1)return null;let i=e.slice(0,r).match(/\/[^\s]*$/);if(!i||i.index===void 0||U_e(e,i.index))return null;let a=i.index;if(K_e(e,a))return null;let o=i[0],s=o.slice(1);return G_e(s)||o.startsWith(`/skill:`)?null:{start:i.index,end:r,query:s}}function J_e(e,t){let n=t.trim().toLowerCase();if(!n)return 0;let r=e.name.toLowerCase();if(r===n)return 0;for(let t of e.aliases??[])if(t.toLowerCase()===n)return 1;if(r.startsWith(n))return 2;for(let t of e.aliases??[])if(t.toLowerCase().startsWith(n))return 3;if(r.includes(n))return 4;for(let t of e.aliases??[])if(t.toLowerCase().includes(n))return 5;return(e.description??``).toLowerCase().includes(n)?100:(e.category??``).toLowerCase().includes(n)?101:e.kind===`skill`&&(e.source??``).toLowerCase().includes(n)?102:null}function Y_e(e,t){return t===0?0:Math.min(e,t-1)}function X_e(e,t,n){let r=(0,Y.c)(52),[i,a]=(0,J.useState)(0),[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(!1),[u,f]=(0,J.useState)(!1),p=d(uve);n?.isComposing;let m;r[0]!==t||r[1]!==n?.isComposing||r[2]!==e?(m=n?.isComposing?null:q_e(e,t),r[0]=t,r[1]=n?.isComposing,r[2]=e,r[3]=m):m=r[3];let h=m,g=!!(h&&!n?.suppress);!g&&(o||c||u)&&(s(!1),l(!1),f(!1));let _,v;r[4]===p?(_=r[5],v=r[6]):(_=async()=>{let[e,t,n]=await Promise.all([v1(),y1(p),gL().catch(lve)]),r=e.map(cve),i=t.catalog.flatMap(sve),a=n&&n.items.length>1?n.items.map(ove):[];return[...i,...r,...a]},v=[p],r[4]=p,r[5]=_,r[6]=v);let y;r[7]===Symbol.for(`react.memo_cache_sentinel`)?(y=[],r[7]=y):y=r[7];let b;r[8]===Symbol.for(`react.memo_cache_sentinel`)?(b=[],r[8]=b):b=r[8];let x;r[9]===g?x=r[10]:(x={enabled:g,initial:y,errorData:b},r[9]=g,r[10]=x);let S=UF(_,v,x),C=S.data,w=S.error==null?null:S.error instanceof Error?S.error.message:String(S.error),T=h?.query??``,E=h!==null&&h.start===0,D=E,O;r[11]===T?O=r[12]:(O=T.trim(),r[11]=T,r[12]=O);let k=O===``,A=g&&k&&o,j=g&&k&&c,M=g&&k&&u,N;r[13]===Symbol.for(`react.memo_cache_sentinel`)?(N=()=>{s(!0)},r[13]=N):N=r[13];let P=N,F;r[14]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>{l(!0)},r[14]=F):F=r[14];let I=F,L;r[15]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>{f(!0)},r[15]=L):L=r[15];let R=L,z;if(r[16]!==D||r[17]!==C||r[18]!==E||r[19]!==M||r[20]!==j||r[21]!==A||r[22]!==k||r[23]!==T||r[24]!==e){bb0:{let t=Hge(e),n=[];for(let e of C){if(e.kind===`command`&&!E||e.kind===`agent`&&!D||e.kind===`skill`&&t.has(e.name))continue;let r=J_e(e,T);r!==null&&n.push({item:e,rank:r})}if(k){let e=ave,t=n.filter(ive).sort(e).map(rve),r=n.filter(nve).sort(e).map(tve),i=n.filter(eve).sort(e).map($_e),a=A?t:t.slice(0,b5),o=j?r:r.slice(0,b5),s=M?i:i.slice(0,b5),c=A?0:Math.max(0,t.length-b5),l=j?0:Math.max(0,r.length-b5),u=M?0:Math.max(0,i.length-b5);z={items:[...a,...o,...s],skillRowCount:a.length,commandRowCount:o.length,groupedHasSkills:t.length>0,groupedHasCommands:r.length>0,groupedHasAgents:i.length>0,groupedSkillsMoreCount:c,groupedCommandsMoreCount:l,groupedAgentsMoreCount:u};break bb0}n.sort(Q_e);let i;r[26]===n?i=r[27]:(i={items:n.slice(0,W_e).map(Z_e),skillRowCount:0,commandRowCount:0,groupedHasSkills:!1,groupedHasCommands:!1,groupedHasAgents:!1,groupedSkillsMoreCount:0,groupedCommandsMoreCount:0,groupedAgentsMoreCount:0},r[26]=n,r[27]=i),z=i}r[16]=D,r[17]=C,r[18]=E,r[19]=M,r[20]=j,r[21]=A,r[22]=k,r[23]=T,r[24]=e,r[25]=z}else z=r[25];let{items:B,skillRowCount:V,commandRowCount:H,groupedHasSkills:U,groupedHasCommands:W,groupedHasAgents:G,groupedSkillsMoreCount:ee,groupedCommandsMoreCount:K,groupedAgentsMoreCount:te}=z,ne=h?T:``,re=(0,J.useRef)(ne);re.current!==ne&&(re.current=ne,i!==0&&a(0));let ie;r[28]!==B.length||r[29]!==i?(ie=Y_e(i,B.length),r[28]=B.length,r[29]=i,r[30]=ie):ie=r[30];let ae=ie,oe;r[31]===B.length?oe=r[32]:(oe=e=>{B.length!==0&&a(t=>e===`down`?(t+1)%B.length:(t-1+B.length)%B.length)},r[31]=B.length,r[32]=oe);let se=oe,q;return r[33]!==D||r[34]!==H||r[35]!==E||r[36]!==k||r[37]!==te||r[38]!==K||r[39]!==G||r[40]!==W||r[41]!==U||r[42]!==ee||r[43]!==B||r[44]!==w||r[45]!==se||r[46]!==g||r[47]!==T||r[48]!==ae||r[49]!==V||r[50]!==h?(q={open:g,slashRange:h,commandsAllowed:E,agentsAllowed:D,grouped:k,skillRowCount:V,commandRowCount:H,groupedHasSkills:U,groupedHasCommands:W,groupedHasAgents:G,groupedSkillsMoreCount:ee,groupedCommandsMoreCount:K,groupedAgentsMoreCount:te,items:B,selectedIndex:ae,query:T,loadError:w,onNavigate:se,setSelectedIndex:a,expandGroupedSkills:P,expandGroupedCommands:I,expandGroupedAgents:R},r[33]=D,r[34]=H,r[35]=E,r[36]=k,r[37]=te,r[38]=K,r[39]=G,r[40]=W,r[41]=U,r[42]=ee,r[43]=B,r[44]=w,r[45]=se,r[46]=g,r[47]=T,r[48]=ae,r[49]=V,r[50]=h,r[51]=q):q=r[51],q}function Z_e(e){return e.item}function Q_e(e,t){if(e.rank!==t.rank)return e.rank-t.rank;let n=_5(e.item,t.item);return n===0?0:n}function $_e(e){return e.item}function eve(e){return e.item.kind===`agent`}function tve(e){return e.item}function nve(e){return e.item.kind===`command`}function rve(e){return e.item}function ive(e){return e.item.kind===`skill`}function ave(e,t){let n=_5(e.item,t.item);return n===0?e.item.id.localeCompare(t.item.id):n}function ove(e){return{kind:`agent`,id:`agent:${e.id}`,name:e.id,description:e.description??``,category:`agent`,...e.avatar?{avatar:e.avatar}:{},...e.name?{aliases:[e.name]}:{}}}function sve(e){return!e.enabled||e.disableModelInvocation?[]:[{kind:`skill`,id:`skill:${e.name}`,name:e.name,description:e.description,category:`skill`,source:e.source}]}function cve(e){return{kind:`command`,id:`cmd:${e.id}`,name:e.name,description:e.description,category:e.category,aliases:e.aliases,acceptsArgs:e.acceptsArgs}}function lve(){return null}function uve(e){return e.language}var dve=100,fve=280;function x5(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase().indexOf(n);if(r>=0)return(0,Z.jsxs)(Z.Fragment,{children:[e.slice(0,r),(0,Z.jsx)(`span`,{className:`text-accent-fg`,children:e.slice(r,r+n.length)}),e.slice(r+n.length)]});let i=[],a=0,o=0;for(let t of e){let e=n[a],r=`${String(o)}-${t}`;e!==void 0&&t.toLowerCase()===e?(i.push((0,Z.jsx)(`span`,{className:`text-accent-fg`,children:t},r)),a+=1):i.push((0,Z.jsx)(J.Fragment,{children:t},r)),o+=1}return(0,Z.jsx)(Z.Fragment,{children:i})}function pve(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase().indexOf(n);return r<0?e:(0,Z.jsxs)(Z.Fragment,{children:[e.slice(0,r),(0,Z.jsx)(`span`,{className:`text-accent-fg`,children:e.slice(r,r+n.length)}),e.slice(r+n.length)]})}var mve=(0,J.memo)(function(e){let t=(0,Y.c)(43),{open:n,anchorRef:r,items:i,selectedIndex:a,noResults:o,grouped:s,skillRowCount:c,commandRowCount:l,query:u,skillsLabel:d,commandsLabel:f,agentsLabel:p,groupedHasSkills:m,groupedHasCommands:h,groupedHasAgents:g,groupedSkillsShowMoreLabel:_,groupedCommandsShowMoreLabel:v,groupedAgentsShowMoreLabel:y,currentAgentId:b,currentBadgeLabel:x,runBusy:S,pendingFollowUpsCount:C,maxPendingFollowUps:w,queueBadgeLabel:T,queueFullBadgeLabel:E,queueFullTooltip:D,onExpandSkills:O,onExpandCommands:k,onExpandAgents:A,onSelectItem:j,panelRef:M}=e,[N,P]=(0,J.useState)(null),F,I;if(t[0]!==r||t[1]!==n?(F=()=>{if(!n){P(null);return}let e=()=>{let e=r.current;if(!e)return;let t=e.getBoundingClientRect();P({left:t.left,top:t.top,width:t.width})};e();let t=r.current,i=t&&typeof ResizeObserver<`u`?new ResizeObserver(()=>{e()}):null;return t&&i&&i.observe(t),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{t&&i&&i.disconnect(),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},I=[n,r],t[0]=r,t[1]=n,t[2]=F,t[3]=I):(F=t[2],I=t[3]),(0,J.useLayoutEffect)(F,I),!n||typeof document>`u`||N===null)return null;let L=i.length,R=Math.min(N.width,fve),z;if(t[4]!==p||t[5]!==l||t[6]!==f||t[7]!==b||t[8]!==x||t[9]!==s||t[10]!==y||t[11]!==v||t[12]!==g||t[13]!==h||t[14]!==m||t[15]!==_||t[16]!==i||t[17]!==w||t[18]!==o||t[19]!==A||t[20]!==k||t[21]!==O||t[22]!==j||t[23]!==C||t[24]!==u||t[25]!==T||t[26]!==E||t[27]!==D||t[28]!==S||t[29]!==a||t[30]!==c||t[31]!==d||t[32]!==L){let e=u.trim(),n=!s&&e.length>0,r={runBusy:S,pendingFollowUpsCount:C,maxPendingFollowUps:w},M=(t,i)=>{let o=t.kind===`skill`,s=t.kind===`agent`,c=s?(0,Z.jsx)(rH,{agentId:t.name,avatar:t.avatar,size:18,className:`size-[18px] shrink-0`}):o?(0,Z.jsx)(oS,{className:`size-3 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,Z.jsx)(cO,{className:`size-3 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),l=s?n?(0,Z.jsx)(Z.Fragment,{children:x5(t.name,e)}):(0,Z.jsx)(`span`,{className:`text-fg`,children:t.name}):n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`text-fg`,children:`/`}),x5(t.name,e)]}):(0,Z.jsxs)(`span`,{className:`text-fg`,children:[`/`,t.name]}),u=s&&b!=null&&b.length>0&&t.name===b,d=H_e(t,r),f=y5(t,r),p=null;return u?p=(0,Z.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-accent-soft px-1 py-px text-[0.6rem] font-medium leading-none text-accent-fg`,"aria-label":x,children:x}):f?p=(0,Z.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-red-100 px-1 py-px text-[0.6rem] font-medium leading-none text-red-700 dark:bg-red-900/40 dark:text-red-300`,"aria-label":E,children:E}):d&&(p=(0,Z.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-surface-hover px-1 py-px text-[0.6rem] font-medium leading-none text-fg-muted`,"aria-label":T,children:T})),(0,Z.jsx)(hve,{item:t,icon:c,selected:a===i,id:`palette-${i}`,nameLine:l,descriptionLine:t.description?n?pve(t.description,e):t.description:null,dimCategoryBadge:n,trailingBadge:p,disabled:f,disabledTooltip:f?D:void 0,onSelect:()=>j(t)})};z=L===0?(0,Z.jsx)(`div`,{className:`p-2.5 text-xs leading-normal text-fg-muted`,children:o}):s?(0,Z.jsxs)(Z.Fragment,{children:[m?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mb-1.5 px-2.5 pt-2.5 text-[0.6rem] font-medium uppercase leading-none tracking-wide text-fg-muted`,"aria-hidden":!0,children:d}),i.slice(0,c).map((e,t)=>(0,Z.jsx)(J.Fragment,{children:M(e,t)},e.id)),_?(0,Z.jsx)(`button`,{type:`button`,className:`w-full px-2.5 py-1 text-left text-[11px] leading-tight text-fg-muted transition hover:bg-surface-hover/80 hover:text-fg`,onClick:e=>{e.preventDefault(),O()},children:_}):null]}):null,h?(0,Z.jsxs)(`div`,{className:X(m&&`mt-1 border-t border-edge-subtle`),children:[(0,Z.jsx)(`div`,{className:`mb-1.5 px-2.5 pt-2.5 text-[0.6rem] font-medium uppercase leading-none tracking-wide text-fg-muted`,"aria-hidden":!0,children:f}),i.slice(c,c+l).map((e,t)=>(0,Z.jsx)(J.Fragment,{children:M(e,c+t)},e.id)),v?(0,Z.jsx)(`button`,{type:`button`,className:`w-full px-2.5 py-1 text-left text-[11px] leading-tight text-fg-muted transition hover:bg-surface-hover/80 hover:text-fg`,onClick:e=>{e.preventDefault(),k()},children:v}):null]}):null,g?(0,Z.jsxs)(`div`,{className:X((m||h)&&`mt-1 border-t border-edge-subtle`),children:[(0,Z.jsx)(`div`,{className:`mb-1.5 px-2.5 pt-2.5 text-[0.6rem] font-medium uppercase leading-none tracking-wide text-fg-muted`,"aria-hidden":!0,children:p}),i.slice(c+l).map((e,t)=>(0,Z.jsx)(J.Fragment,{children:M(e,c+l+t)},e.id)),y?(0,Z.jsx)(`button`,{type:`button`,className:`w-full px-2.5 py-1 text-left text-[11px] leading-tight text-fg-muted transition hover:bg-surface-hover/80 hover:text-fg`,onClick:e=>{e.preventDefault(),A()},children:y}):null]}):null]}):i.map((e,t)=>(0,Z.jsx)(J.Fragment,{children:M(e,t)},e.id)),t[4]=p,t[5]=l,t[6]=f,t[7]=b,t[8]=x,t[9]=s,t[10]=y,t[11]=v,t[12]=g,t[13]=h,t[14]=m,t[15]=_,t[16]=i,t[17]=w,t[18]=o,t[19]=A,t[20]=k,t[21]=O,t[22]=j,t[23]=C,t[24]=u,t[25]=T,t[26]=E,t[27]=D,t[28]=S,t[29]=a,t[30]=c,t[31]=d,t[32]=L,t[33]=z}else z=t[33];let B=z,V;t[34]!==N.left||t[35]!==N.top||t[36]!==R?(V={position:`fixed`,left:N.left,top:N.top,width:R,transform:`translateY(calc(-100% - 8px))`,zIndex:dve},t[34]=N.left,t[35]=N.top,t[36]=R,t[37]=V):V=t[37];let H=a>=0&&a<L?`palette-${a}`:void 0,U;return t[38]!==B||t[39]!==M||t[40]!==V||t[41]!==H?(U=(0,Xa.createPortal)((0,Z.jsx)(SZ,{delayDuration:0,skipDelayDuration:0,disableHoverableContent:!1,children:(0,Z.jsx)(`div`,{ref:M,className:`pointer-events-auto max-h-[min(24rem,55vh)] min-h-8 overflow-y-auto rounded-md border border-edge bg-surface-panel text-xs leading-4 shadow-lg dark:bg-surface-panel/95`,style:V,role:`listbox`,"aria-label":`Commands`,"aria-activedescendant":H,children:B})}),document.body),t[38]=B,t[39]=M,t[40]=V,t[41]=H,t[42]=U):U=t[42],U}),hve=(0,J.memo)(function(e){let t=(0,Y.c)(39),{item:n,icon:r,selected:i,id:a,nameLine:o,descriptionLine:s,dimCategoryBadge:c,trailingBadge:l,disabled:u,disabledTooltip:d,onSelect:f}=e,p=n.description??``,m;t[0]===p?m=t[1]:(m=p.trim(),t[0]=p,t[1]=m);let h=m,g=h.length>0&&s!=null,_=h.length>0,v=n.description??``,y=n.category&&n.kind!==`skill`&&!c&&!(n.kind===`agent`&&l),b;t[2]===o?b=t[3]:(b=(0,Z.jsx)(`span`,{className:`min-w-0 max-w-[min(12rem,46%)] shrink-0 truncate font-semibold text-fg`,children:o}),t[2]=o,t[3]=b);let x;t[4]!==n.category||t[5]!==y?(x=y?(0,Z.jsx)(`span`,{className:`shrink-0 rounded bg-surface-hover px-1 py-px text-[0.6rem] font-normal leading-none text-fg-muted`,children:n.category}):null,t[4]=n.category,t[5]=y,t[6]=x):x=t[6];let S;t[7]!==s||t[8]!==g?(S=g?(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] font-normal leading-tight text-fg-muted`,children:s}):null,t[7]=s,t[8]=g,t[9]=S):S=t[9];let C;t[10]!==b||t[11]!==x||t[12]!==S?(C=(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-1`,children:[b,x,S]}),t[10]=b,t[11]=x,t[12]=S,t[13]=C):C=t[13];let w=C,T=u?`cursor-not-allowed opacity-50 text-fg-muted`:i?`cursor-pointer bg-surface-hover text-fg`:`cursor-pointer text-fg-subtle hover:bg-surface-hover/80`,E;t[14]===T?E=t[15]:(E=X(`flex w-full min-w-0 items-center gap-1.5 px-2.5 py-1 text-left text-xs leading-4`,T),t[14]=T,t[15]=E);let D=E,O;t[16]!==u||t[17]!==f?(O=e=>{u||e.pointerType===`mouse`&&e.button!==0||(e.preventDefault(),f())},t[16]=u,t[17]=f,t[18]=O):O=t[18];let k=O,A;t[19]===r?A=t[20]:(A=(0,Z.jsx)(`span`,{className:`shrink-0 [&_svg]:align-middle`,children:r}),t[19]=r,t[20]=A);let j;t[21]!==A||t[22]!==w||t[23]!==l?(j=(0,Z.jsxs)(Z.Fragment,{children:[A,w,l]}),t[21]=A,t[22]=w,t[23]=l,t[24]=j):j=t[24];let M=j,N=u&&d?d:_?v:null,P=u||void 0,F;t[25]!==a||t[26]!==k||t[27]!==D||t[28]!==M||t[29]!==i||t[30]!==P?(F=(0,Z.jsx)(`div`,{id:a,role:`option`,"aria-selected":i,"aria-disabled":P,tabIndex:-1,className:D,onPointerDown:k,children:M}),t[25]=a,t[26]=k,t[27]=D,t[28]=M,t[29]=i,t[30]=P,t[31]=F):F=t[31];let I=F;if(N!==null){let e;t[32]===I?e=t[33]:(e=(0,Z.jsx)(wZ,{asChild:!0,children:I}),t[32]=I,t[33]=e);let n;t[34]===N?n=t[35]:(n=(0,Z.jsx)(TZ,{children:(0,Z.jsx)(EZ,{side:`right`,align:`start`,sideOffset:8,collisionPadding:12,className:`!z-[10000] max-h-[min(12rem,40vh)] max-w-sm overflow-y-auto rounded-md border border-edge bg-surface-panel px-2 py-1.5 text-left text-[11px] leading-snug text-fg shadow-lg select-text [max-width:min(20rem,90vw)]`,"data-slash-palette-tooltip":``,children:(0,Z.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:N})})}),t[34]=N,t[35]=n);let r;return t[36]!==e||t[37]!==n?(r=(0,Z.jsxs)(CZ,{delayDuration:0,children:[e,n]}),t[36]=e,t[37]=n,t[38]=r):r=t[38],r}return I}),S5=20,gve=`xopc.composer.inputHistory:`;function C5(e){return`${gve}${e.trim()}`}function w5(e){let t=e?.trim();if(!t||typeof localStorage>`u`)return[];try{let e=localStorage.getItem(C5(t));if(!e)return[];let n=JSON.parse(e);return Array.isArray(n)?n.filter(e=>typeof e==`string`).slice(0,S5):[]}catch{return[]}}function _ve(e,t){let n=e?.trim(),r=t.trim();if(!(!n||!r||typeof localStorage>`u`))try{let e=w5(n);if(e[0]===r)return;let t=[r,...e].slice(0,S5);localStorage.setItem(C5(n),JSON.stringify(t))}catch{}}function vve(e){let t=(0,Y.c)(17),{sessionKey:n,editorRef:r,valueRef:i,resetEditor:a,onWireInput:o}=e,s=(0,J.useRef)(null),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{s.current=null},t[0]=c):c=t[0];let l=c,u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{l()},t[1]=u):u=t[1];let d;t[2]===n?d=t[3]:(d=[n,l],t[2]=n,t[3]=d),(0,J.useEffect)(u,d);let f;t[4]===n?f=t[5]:(f=e=>{_ve(n,e),l()},t[4]=n,t[5]=f);let p=f,m;t[6]===o?m=t[7]:(m=(e,t)=>{s.current=null,o(e,t)},t[6]=o,t[7]=m);let h=m,g;t[8]!==r||t[9]!==a||t[10]!==n||t[11]!==i?(g=e=>{let t=n?.trim();if(!t)return!1;let o=w5(t);if(o.length===0)return!1;let c=s.current,l=r.current,u=l?q8(l):0,d=i.current;if(e===`up`){if(c==null){if(u!==0)return!1;s.current={index:0,stash:d};let e=o[0];return e?(a({nextText:e,caretOffset:e.length,focus:!0}),!0):!1}if(c.index>=o.length-1)return!0;c.index+=1;let e=o[c.index];return e?(a({nextText:e,caretOffset:e.length,focus:!0}),!0):!1}if(c==null)return!1;if(--c.index,c.index<0){let e=c.stash;return s.current=null,a({nextText:e,caretOffset:e.length,focus:!0}),!0}let f=o[c.index];return f?(a({nextText:f,caretOffset:f.length,focus:!0}),!0):!1},t[8]=r,t[9]=a,t[10]=n,t[11]=i,t[12]=g):g=t[12];let _=g,v;return t[13]!==p||t[14]!==h||t[15]!==_?(v={onUserTextCommitted:p,onWireInputClearWalk:h,tryInputHistoryArrow:_},t[13]=p,t[14]=h,t[15]=_,t[16]=v):v=t[16],v}function T5(e){if(e.voiceActive)return e.cancelVoiceInput(),null;let t=e.getTextValue();return!t.trim()&&e.getAttachmentCount()===0?null:{text:t,attachments:e.wireAttachmentsPayload()}}function yve(e){let{chat:t,runBusy:n,voiceActive:r,cancelVoiceInput:i,editingFollowUpId:a,getTextValue:o,getAttachmentCount:s,wireAttachmentsPayload:c,getThinkingLevel:l,onSend:u,onAddPendingFollowUp:d,onSteeringInterrupt:f,onCommitEditFollowUp:p,onPendingFollowUpRemove:m,pendingFollowUpsCount:h,resetEditor:g,clearAttachments:_,clearEditFollowUpRef:v,onUserTextCommitted:y}=e,b={getTextValue:o,getAttachmentCount:s,wireAttachmentsPayload:c};return{send:(0,J.useCallback)(()=>{if(n)return;let e=T5({voiceActive:r,cancelVoiceInput:i,...b});e&&(u(e.text,e.attachments.length>0?e.attachments:void 0,l()),y?.(e.text),g(),_())},[n,r,i,u,l,y,g,_,o,s,c]),flushSteeringDraft:(0,J.useCallback)(async()=>{if(!n&&h===0)return;let e=T5({voiceActive:r,cancelVoiceInput:i,...b});if(e){if(a){p(a,e.text,e.attachments.length>0?e.attachments:void 0,l()),y?.(e.text),v(),g(),_();return}if(d){if(h>=10){fH(`warning`,t.followUpQueueMaxReached,{max:10});return}await d(e.text,e.attachments.length>0?e.attachments:void 0),y?.(e.text),g(),_()}}},[n,r,i,a,h,d,p,l,t.followUpQueueMaxReached,v,y,g,_,o,s,c]),interruptDraft:(0,J.useCallback)(()=>{if(!n||!f)return;let e=T5({voiceActive:r,cancelVoiceInput:i,...b});e&&(f(e.text,e.attachments.length>0?e.attachments:void 0),y?.(e.text),a&&(v(),m(a)),g(),_())},[n,r,i,a,m,f,y,v,g,_,o,s,c])}}function bve(e){let{chat:t}=e,[n,r]=(0,J.useState)([]),[i,a]=(0,J.useState)(!1),o=(0,J.useRef)(null),s=(0,J.useRef)(n);s.current=n;let c=(0,J.useCallback)(()=>{r([])},[]),l=(0,J.useCallback)(e=>{r(t=>t.filter((t,n)=>n!==e))},[]),u=(0,J.useCallback)(()=>s.current.map(e=>({type:e.type===`voice`?`voice`:e.type||`file`,mimeType:e.mimeType,data:e.content,name:e.name,size:e.size,...e.workspaceRelativePath?{workspaceRelativePath:e.workspaceRelativePath}:{},...typeof e.durationSeconds==`number`&&Number.isFinite(e.durationSeconds)&&e.durationSeconds>0?{durationSeconds:e.durationSeconds}:{}})),[]);return{attachments:n,setAttachments:r,attachmentsRef:s,isDragging:i,setIsDragging:a,fileInputRef:o,processFiles:(0,J.useCallback)(async e=>{if(e.length===0)return;let n=10-s.current.length;if(n<=0){fH(`warning`,t.maxAttachmentsReached,{max:10});return}let i=e.slice(0,n);e.length>i.length&&fH(`warning`,t.maxAttachmentsTruncated,{max:10,dropped:e.length-i.length});let{loadAttachment:a}=await D(async()=>{let{loadAttachment:e}=await Promise.resolve().then(()=>Tge);return{loadAttachment:e}},void 0),o=(await Promise.all(i.map(async e=>{if(e.size>33554432)return fH(`warning`,t.attachmentFileTooLarge,{name:e.name,maxSize:PL(bR)}),null;try{return await a(e,e.name)}catch{return fH(`error`,t.attachmentLoadFailed,{name:e.name}),null}}))).filter(e=>e!==null);r(e=>[...e,...o])},[t.attachmentFileTooLarge,t.attachmentLoadFailed,t.maxAttachmentsReached,t.maxAttachmentsTruncated]),removeAttachment:l,clearAttachments:c,wireAttachmentsPayload:u}}function xve(e){let t=(0,Y.c)(6),{active:n,anchors:r,ignoreSelector:i,onDismiss:a}=e,o,s;t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a?(o=()=>{if(!n)return;let e=e=>{let t=e.target;if(t instanceof Node){for(let e of r){let n=e.current;if(n&&n.contains(t))return}i&&t instanceof Element&&t.closest(i)||a()}};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},s=[n,r,i,a],t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s):(o=t[4],s=t[5]),(0,J.useEffect)(o,s)}var E5=20,Sve=`xopc.atMention.recent:`;function D5(e){return`${Sve}${e.trim()}`}function O5(e){let t=e?.trim();if(!t||typeof localStorage>`u`)return[];try{let e=localStorage.getItem(D5(t));if(!e)return[];let n=JSON.parse(e);return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0).slice(0,E5):[]}catch{return[]}}function Cve(e,t){let n=e?.trim(),r=t.trim();if(!(!n||!r||typeof localStorage>`u`))try{let e=[r,...O5(n).filter(e=>e!==r)].slice(0,E5);localStorage.setItem(D5(n),JSON.stringify(e))}catch{}}var wve=150,Tve=15;function k5(e,t){let n=e.length,r=Math.min(Math.max(t,0),n);if(r<1)return null;let i=e.slice(0,r),a=i.match(/@([^\s]*)$/);if(!a||a.index===void 0)return null;let o=a.index;if(o>0&&/[a-zA-Z0-9_]/.test(e[o-1]))return null;let s=i.slice(o);return/^@(file|doc|url|symbol):/.test(s)?null:{start:o,end:r,query:a[1]??``}}function Eve(e){let t=e.trim();return t.length>0&&t.endsWith(`/`)&&!/^https?:\/\//i.test(t)}function A5(e){return e.replace(/\/+$/,``).trim()}function Dve(e){let t=e.replace(/\/+$/,``);if(!t)return``;let n=t.lastIndexOf(`/`);return n<=0?``:t.slice(0,n)}function Ove(e,t){return t===0?0:Math.min(e,t-1)}function kve(e,t,n){let[r,i]=(0,J.useState)(0),a=(0,J.useMemo)(()=>n.precomputedAtRange===void 0?n.isComposing||n.slashPaletteOpen?null:k5(e,t):n.isComposing||n.slashPaletteOpen?null:n.precomputedAtRange,[e,t,n.slashPaletteOpen,n.isComposing,n.precomputedAtRange]),o=a!==null,[s]=uU(o?a?.query??``:``,wve),c=o?s:``,l=n.sessionKey?.trim()??``,u=UF(async()=>{if(!l)return[];if(Eve(c)){let e=A5(c),t=(await Mle(e,{sessionKey:l})).map(e=>({name:e.name,relativePath:e.path,isDirectory:e.isDirectory}));return e?[{name:`..`,relativePath:``,isDirectory:!0,isBrowseUp:!0},...t]:t}let e=await E1(c,{sessionKey:l,limit:Tve}),t=O5(l),n=[],r=new Set(e.map(e=>e.relativePath));for(let e of t){if(r.has(e))continue;r.add(e);let t=e.replace(/\/$/,``).split(`/`).pop()??e;if(n.push({name:t,relativePath:e,isDirectory:e.endsWith(`/`),isRecent:!0}),n.length>=5)break}return[...n,...e]},[c,l],{enabled:o&&!!l,initial:[],errorData:[]}),d=o?u.data:[],f=o?u.loading:!1,p=o&&u.error!=null?u.error instanceof Error?u.error.message:String(u.error):null,m=a?.start,h=a?.end,g=`${m??``}:${h??``}:${c}`,_=(0,J.useRef)(g);_.current!==g&&(_.current=g,r!==0&&i(0));let v=Ove(r,d.length),y=(0,J.useCallback)(e=>{d.length!==0&&i(t=>e===`down`?(t+1)%d.length:(t-1+d.length)%d.length)},[d.length]);return{open:o,atRange:a,items:d,selectedIndex:v,query:a?.query??``,loading:f,error:p,onNavigate:y,setSelectedIndex:i}}function Ave(e){let{sessionKey:t,editorValue:n,editorCursor:r,isComposing:i,runBusy:a,thinkingLevel:o,editorRef:s,valueRef:c,resetEditor:l,clearAttachments:u,onSend:d,onUserTextCommitted:f,onChatAgentChange:p,onAddPendingFollowUp:m,onAbort:h,pendingFollowUpsCount:g,maxPendingFollowUps:_,commandPalettePanelRef:v}=e,y=(0,J.useMemo)(()=>k5(n,r),[n,r]),b=X_e(n,r,{suppress:y!=null,isComposing:i}),x=kve(n,r,{sessionKey:t,slashPaletteOpen:b.open,isComposing:i,precomputedAtRange:y}),S=b.open||x.open||y!=null,C=(0,J.useCallback)(()=>({slashRange:b.slashRange,runBusy:a,pendingFollowUpsCount:g,maxPendingFollowUps:_,thinkingLevel:o,editor:{valueRef:c,resetEditor:l},attachments:{clearAttachments:u},callbacks:{onSend:d,onUserTextCommitted:f,onChatAgentChange:p,onAddPendingFollowUp:m,onAbort:h}}),[b.slashRange,a,g,_,o,c,l,u,d,f,p,m,h]),w=(0,J.useCallback)(e=>{z_e(e,C())},[C]),T=(0,J.useCallback)((e,n)=>{let r=x.atRange;if(!r)return;if(e.isBrowseUp){let e=Dve(A5(r.query)),t=`@${e?`${e}/`:``}`;l({nextText:m5(c.current,r.start,r.end,t),caretOffset:r.start+t.length,focus:!0});return}let i=e.isDirectory&&!e.relativePath.endsWith(`/`)?`${e.relativePath}/`:e.relativePath,a=`@file:${L8(i)}`;t&&!e.isDirectory&&Cve(t,i.replace(/\/$/,``));let o=a+(n?.stayOpen?` @`:` `);l({nextText:m5(c.current,r.start,r.end,o),caretOffset:r.start+o.length,focus:!0})},[x.atRange,t,c,l]),E=(0,J.useRef)(b.slashRange);E.current=b.slashRange;let D=c,O=(0,J.useCallback)(()=>{let e=E.current;if(!e)return;let t=D.current;l({nextText:t.slice(0,e.start)+t.slice(e.end),caretOffset:e.start})},[l,D]),k=(0,J.useMemo)(()=>[s,v],[s,v]);xve({active:b.open,anchors:k,ignoreSelector:`[data-slash-palette-tooltip]`,onDismiss:O});let A=(0,J.useRef)(x);A.current=x;let j=(0,J.useRef)(b);j.current=b;let M=(0,J.useRef)(i);M.current=i;let N=(0,J.useRef)(w);N.current=w;let P=(0,J.useRef)(T);P.current=T;let F=(0,J.useRef)({runBusy:a,pendingFollowUpsCount:g,maxPendingFollowUps:_});F.current={runBusy:a,pendingFollowUpsCount:g,maxPendingFollowUps:_};let I=(0,J.useMemo)(()=>({name:`at-mention`,isActive:()=>{let e=A.current;return e.open&&e.atRange!=null&&!M.current},handleKey:e=>{let t=A.current;if(!t.atRange)return!1;if(e.key===`Escape`){e.preventDefault();let n=t.atRange,r=D.current;return l({nextText:m5(r,n.start,n.end,``),caretOffset:n.start,focus:!0}),!0}if(t.items.length===0)return!1;if(e.key===`ArrowDown`)return e.preventDefault(),t.onNavigate(`down`),!0;if(e.key===`ArrowUp`)return e.preventDefault(),t.onNavigate(`up`),!0;if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let n=t.items[t.selectedIndex];return n&&P.current(n,{stayOpen:e.shiftKey}),!0}return!1}}),[l,D]),L=(0,J.useMemo)(()=>({name:`slash-palette`,isActive:()=>j.current.open&&!M.current,handleKey:e=>{let t=j.current;if(t.items.length>0){if(e.key===`ArrowDown`)return e.preventDefault(),t.onNavigate(`down`),!0;if(e.key===`ArrowUp`)return e.preventDefault(),t.onNavigate(`up`),!0;if((e.key===`Enter`||e.key===`Tab`)&&!e.shiftKey){e.preventDefault();let n=t.items[t.selectedIndex];return!n||y5(n,F.current)||N.current(n),!0}}if(e.key===`Escape`){e.preventDefault();let n=t.slashRange;if(n){let e=D.current;l({nextText:m5(e,n.start,n.end,``),caretOffset:n.start,focus:!0})}return!0}return!1}}),[l,D]);return{palette:b,atPicker:x,shouldSyncSelection:S,adapters:(0,J.useMemo)(()=>[I,L],[I,L]),applyPalette:w,applyAtMention:T}}function jve(e,t){let n=t.trim();if(!n)return e;let r=e.trim();return r?`${r} ${n}`:n}var j5=X(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,AX.transition,AX.press,AX.focusRingPanel,`disabled:cursor-not-allowed disabled:opacity-50`),Mve=(0,J.memo)(function(e){let t=(0,Y.c)(30),{phase:n,elapsedLabel:r,disabled:i,chat:a,onCancel:o,onConfirm:s}=e,c=n===`transcribing`,l=a.voiceInput,u=!c&&`animate-pulse`,d;t[0]===u?d=t[1]:(d=X(`size-2 shrink-0 rounded-full bg-red-500`,u),t[0]=u,t[1]=d);let f;t[2]===d?f=t[3]:(f=(0,Z.jsx)(`span`,{className:d,"aria-hidden":!0}),t[2]=d,t[3]=f);let p=c?a.voiceTranscribing:a.voiceRecordingStatus,m;t[4]===p?m=t[5]:(m=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg-muted`,children:p}),t[4]=p,t[5]=m);let h=c?``:r,g;t[6]===h?g=t[7]:(g=(0,Z.jsx)(`span`,{className:`shrink-0 tabular-nums text-sm text-fg-subtle`,"aria-live":`polite`,children:h}),t[6]=h,t[7]=g);let _=i||c,v;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(oO,{className:`size-4`}),t[8]=v):v=t[8];let y;t[9]!==a.voiceInputCancel||t[10]!==o||t[11]!==_?(y=(0,Z.jsx)(`button`,{type:`button`,className:j5,disabled:_,title:a.voiceInputCancel,"aria-label":a.voiceInputCancel,onClick:o,children:v}),t[9]=a.voiceInputCancel,t[10]=o,t[11]=_,t[12]=y):y=t[12];let b;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(b=X(j5,`text-fg`),t[13]=b):b=t[13];let x=i||c,S;t[14]===c?S=t[15]:(S=c?(0,Z.jsx)(Cg,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(Ml,{className:`size-4`}),t[14]=c,t[15]=S);let C;t[16]!==a.voiceInputConfirm||t[17]!==s||t[18]!==x||t[19]!==S?(C=(0,Z.jsx)(`button`,{type:`button`,className:b,disabled:x,title:a.voiceInputConfirm,"aria-label":a.voiceInputConfirm,onClick:s,children:S}),t[16]=a.voiceInputConfirm,t[17]=s,t[18]=x,t[19]=S,t[20]=C):C=t[20];let w;t[21]!==y||t[22]!==C?(w=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[y,C]}),t[21]=y,t[22]=C,t[23]=w):w=t[23];let T;return t[24]!==a.voiceInput||t[25]!==w||t[26]!==f||t[27]!==m||t[28]!==g?(T=(0,Z.jsxs)(`div`,{className:`flex min-h-10 w-full items-center gap-2 py-2`,role:`region`,"aria-label":l,children:[f,m,g,w]}),t[24]=a.voiceInput,t[25]=w,t[26]=f,t[27]=m,t[28]=g,t[29]=T):T=t[29],T});async function Nve(e){return ML(await e.arrayBuffer())}async function Pve(e,t){let n=await Nve(e),r=await we(_(`/api/voice/transcribe`),{method:`POST`,body:JSON.stringify({audio:n,mimeType:t})});if(!r.payload)throw Error(`Missing transcription payload`);return r.payload}var M5=null;async function Fve(){if(M5!==null)return M5;try{M5=(await we(_(`/api/status`))).voice?.sttAvailable===!0}catch{M5=!1}return M5}function Ive(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e%60);return`${Math.floor(e/60)}:${t.toString().padStart(2,`0`)}`}function Lve(e){let{disabled:t,chat:n,onTranscript:r}=e,[i,a]=(0,J.useState)(`idle`),[o,s]=(0,J.useState)(0),c=(0,J.useRef)(null),l=(0,J.useRef)([]),u=(0,J.useRef)(null),d=(0,J.useRef)(``),f=(0,J.useRef)(!1),p=(0,J.useRef)(!1),m=(0,J.useRef)(null),h=(0,J.useRef)(null),g=(0,J.useRef)(r);g.current=r;let _=(0,J.useCallback)(()=>{h.current!=null&&(clearInterval(h.current),h.current=null)},[]),v=(0,J.useCallback)(()=>{u.current?.getTracks().forEach(e=>e.stop()),u.current=null},[]),y=(0,J.useCallback)(()=>{_(),v(),c.current=null,l.current=[],m.current=null,p.current=!1,f.current=!1,s(0),a(`idle`)},[_,v]),b=(0,J.useCallback)(()=>{let e=c.current;e&&e.state!==`inactive`?e.stop():y(),c.current=null},[y]),x=(0,J.useCallback)(()=>{f.current=!0,p.current=!1,b()},[b]),S=(0,J.useCallback)(async(e,t)=>{a(`transcribing`);let r=new Blob(e,{type:t||`audio/webm`});if(r.size<32){fH(`warning`,n.voiceTranscribeEmpty),y();return}try{let e=await Pve(r,r.type||t||`audio/webm`),i=(e.refined??e.raw).trim();if(!i){fH(`warning`,n.voiceTranscribeEmpty),y();return}g.current(i),y()}catch(e){let t=e instanceof Error?e.message:String(e);t.includes(`STT is not configured`)||t.includes(`503`)?fH(`error`,n.voiceSttNotConfigured):fH(`error`,n.voiceTranscribeFailed),y()}},[y,n.voiceSttNotConfigured,n.voiceTranscribeEmpty,n.voiceTranscribeFailed]),C=(0,J.useCallback)(()=>{_(),h.current=setInterval(()=>{let e=m.current;typeof e==`number`&&s(Math.max(0,(performance.now()-e)/1e3))},200)},[_]),w=(0,J.useCallback)(async()=>{if(!(t||i!==`idle`)){if(!await Fve()){fH(`error`,n.voiceSttNotConfigured);return}f.current=!1,p.current=!1;try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});u.current=e;let t=MediaRecorder.isTypeSupported(`audio/webm;codecs=opus`)?`audio/webm;codecs=opus`:MediaRecorder.isTypeSupported(`audio/webm`)?`audio/webm`:``;d.current=t;let n=t?new MediaRecorder(e,{mimeType:t}):new MediaRecorder(e);l.current=[],n.ondataavailable=e=>{e.data.size>0&&l.current.push(e.data)},n.onstop=()=>{(async()=>{try{let e=l.current;l.current=[];let t=d.current||n.mimeType;if(f.current){y();return}if(p.current){p.current=!1,await S(e,t);return}y()}finally{v()}})()},c.current=n,m.current=performance.now(),s(0),n.start(250),a(`recording`),C()}catch{y(),fH(`error`,n.voiceMicDenied)}}},[t,y,n.voiceMicDenied,n.voiceSttNotConfigured,i,S,C,v]),T=(0,J.useCallback)(()=>{i===`recording`&&(p.current=!0,f.current=!1,a(`transcribing`),_(),b())},[i,b,_]);return(0,J.useEffect)(()=>()=>{f.current=!0,p.current=!1,b()},[b]),{phase:i,voiceActive:i!==`idle`,elapsedLabel:Ive(o),startVoiceInput:w,cancelVoiceInput:x,confirmVoiceInput:T}}var Rve=(0,J.memo)(function({disabled:e,sending:t,streaming:n,sessionKey:r,sessionManager:i,canSelectWorkingDirectory:a,thinkingLevel:o,showThinkingSelector:s,onThinkingChange:c,onSend:l,onAbort:u,onAddPendingFollowUp:f,onSteeringInterrupt:p,pendingFollowUps:h,editingFollowUpId:g,onBeginEditFollowUp:_,onCancelEditFollowUp:v,onCommitEditFollowUp:y,onPendingFollowUpRemove:b,onPendingFollowUpMove:x,onPendingFollowUpReorder:S,onPendingFollowUpSteer:C,steeringFollowUpId:w,welcomeDraftSeed:T,sessionModel:E,showModelSelector:D,onModelChange:O,modelDisabled:k,contextUsageMessages:A,onChatAgentChange:j,currentAgentId:M}){let N=m(d(e=>e.language));(0,J.useEffect)(()=>{v1()},[]);let P=(0,J.useRef)(!1),F=(0,J.useRef)(null),I=(0,J.useRef)(null),L=(0,J.useRef)(null),R=(0,J.useRef)(!1),z=(0,J.useRef)(l),B=(0,J.useRef)(o);z.current=l,B.current=o;let V=bve({chat:N.chat}),H=$ge({disabled:e,welcomeDraftSeed:T,onExternalTextReplace:(0,J.useCallback)(()=>{V.clearAttachments()},[V.clearAttachments]),shouldSyncSelectionRef:P}),{onUserTextCommitted:U,onWireInputClearWalk:W,tryInputHistoryArrow:G}=vve({sessionKey:r,editorRef:H.editorRef,valueRef:H.valueRef,resetEditor:H.resetEditor,onWireInput:H.onWireInput}),ee=t||n;R.current=ee;let K=Ave({sessionKey:r,editorValue:H.value,editorCursor:H.cursor,isComposing:H.isComposing,runBusy:ee,thinkingLevel:o,editorRef:H.editorRef,valueRef:H.valueRef,resetEditor:H.resetEditor,clearAttachments:V.clearAttachments,onSend:l,onUserTextCommitted:U,onChatAgentChange:j,onAddPendingFollowUp:f,onAbort:u,pendingFollowUpsCount:h.length,maxPendingFollowUps:10,commandPalettePanelRef:F});P.current=K.shouldSyncSelection;let te=(0,J.useMemo)(()=>H.value.length,[H.value]),ne=Lve({disabled:e,chat:N.chat,onTranscript:e=>{let t=H.valueRef.current,n=jve(t,e);H.resetEditor({nextText:n,caretOffset:n.length,focus:!0})}}),re=(0,J.useCallback)(()=>{L.current=null},[]),ie=yve({chat:N.chat,runBusy:ee,voiceActive:ne.voiceActive,cancelVoiceInput:ne.cancelVoiceInput,editingFollowUpId:g,getTextValue:()=>H.valueRef.current,getAttachmentCount:()=>V.attachmentsRef.current.length,wireAttachmentsPayload:V.wireAttachmentsPayload,getThinkingLevel:()=>B.current,onSend:l,onAddPendingFollowUp:f,onSteeringInterrupt:p,onCommitEditFollowUp:y,onPendingFollowUpRemove:b,pendingFollowUpsCount:h.length,resetEditor:()=>{H.resetEditor()},clearAttachments:V.clearAttachments,clearEditFollowUpRef:re,onUserTextCommitted:U});(0,J.useLayoutEffect)(()=>{if(!g){L.current&&=(V.clearAttachments(),H.resetEditor(),null);return}if(g===L.current)return;let e=h.find(e=>e.id===g);if(!e){v();return}L.current=g,e.thinkingLevel!=null&&s&&c(e.thinkingLevel),V.setAttachments(A_e(e.attachments??[])),H.resetEditor({nextText:e.text,focus:!0})},[V.clearAttachments,V.setAttachments,H.resetEditor,g,v,c,h,s]);let ae=(0,J.useCallback)(e=>{_(e)},[_]),oe=(0,J.useRef)({});oe.current={adapters:K.adapters,send:ie.send,runBusy:ee,pendingFollowUpsCount:h.length,flushSteeringDraft:ie.flushSteeringDraft,interruptDraft:ie.interruptDraft,editingFollowUpId:g,onCancelEditFollowUp:v,attachmentsLen:V.attachments.length,isComposing:H.isComposing,valueRef:H.valueRef,adjustHeight:H.adjustHeight,editorRef:H.editorRef,tryInputHistoryArrow:G};let se=ee,q=!!H.value.trim()||V.attachments.length>0,ce=q&&!!p;return(0,Z.jsxs)(`div`,{className:X(`relative flex min-h-0 w-full flex-col overflow-hidden rounded-xl bg-surface-panel shadow-surface ring-1 ring-inset ring-edge dark:bg-surface-panel/60 dark:shadow-none`,V.isDragging&&`ring-2 ring-accent ring-inset`),onDragOver:e=>{e.dataTransfer?.types.includes(`Files`)&&(e.preventDefault(),V.setIsDragging(!0))},onDragLeave:e=>{e.relatedTarget===null&&V.setIsDragging(!1)},onDrop:async e=>{e.preventDefault(),V.setIsDragging(!1);let t=e.dataTransfer?.files;t?.length&&await V.processFiles(Array.from(t))},children:[V.isDragging?(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-xl bg-accent-soft/80 text-sm font-medium text-accent-fg backdrop-blur-[1px]`,children:N.chat.dropFiles}):null,h.length>0?(0,Z.jsx)(`div`,{className:`max-h-[min(30vh,11rem)] shrink-0 overflow-y-auto overflow-x-hidden border-b border-edge-subtle/80 [scrollbar-gutter:stable] dark:border-edge-subtle/70`,children:(0,Z.jsx)(t_e,{items:h,disabled:e,editingFollowUpId:g,onEditInComposer:ae,onRemove:b,onMove:x,onReorder:S,onSteer:C,steeringBusyId:w})}):null,(0,Z.jsx)(a_e,{attachments:V.attachments,topPadded:h.length>0,onRemove:V.removeAttachment}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 shrink-0 flex-col`,children:[(0,Z.jsx)(`input`,{ref:I,type:`file`,multiple:!0,accept:A8,className:`hidden`,onChange:async e=>{let t=e.target.files;t&&await V.processFiles(Array.from(t)),e.target.value=``}}),(0,Z.jsxs)(`div`,{className:X(`relative px-4 pb-0 pt-1`,V.attachments.length>0&&`pt-2`),children:[(0,Z.jsx)(I_e,{open:K.atPicker.open,anchorRef:H.editorRef,items:K.atPicker.items,selectedIndex:K.atPicker.selectedIndex,loading:K.atPicker.loading,query:K.atPicker.query,noResults:K.atPicker.error??N.chat.atMention.noResults,sessionKey:r,recentLabel:N.chat.atMention.recentBadge,ariaLabel:N.chat.atMention.placeholder,shiftHint:N.chat.atMention.shiftHint,onSelectItem:(e,t)=>K.applyAtMention(e,{stayOpen:t?.shiftKey===!0})}),(0,Z.jsx)(mve,{open:K.palette.open,anchorRef:H.editorRef,panelRef:F,items:K.palette.loadError?[]:K.palette.items,selectedIndex:K.palette.selectedIndex,noResults:K.palette.loadError??N.chat.commandPalette.noResults,grouped:K.palette.loadError?!1:K.palette.grouped,skillRowCount:K.palette.loadError?0:K.palette.skillRowCount,commandRowCount:K.palette.loadError?0:K.palette.commandRowCount,query:K.palette.query,skillsLabel:N.chat.commandPalette.skillsSection,commandsLabel:N.chat.commandPalette.commandsSection,agentsLabel:N.chat.commandPalette.agentsSection,groupedHasSkills:K.palette.loadError?!1:K.palette.groupedHasSkills,groupedHasCommands:K.palette.loadError?!1:K.palette.groupedHasCommands,groupedHasAgents:K.palette.loadError?!1:K.palette.groupedHasAgents,groupedSkillsShowMoreLabel:K.palette.loadError||!K.palette.grouped?null:K.palette.groupedSkillsMoreCount>0?Q8(N.chat.commandPalette.showGroupedMore,{count:K.palette.groupedSkillsMoreCount}):null,groupedCommandsShowMoreLabel:K.palette.loadError||!K.palette.grouped?null:K.palette.groupedCommandsMoreCount>0?Q8(N.chat.commandPalette.showGroupedMore,{count:K.palette.groupedCommandsMoreCount}):null,groupedAgentsShowMoreLabel:K.palette.loadError||!K.palette.grouped?null:K.palette.groupedAgentsMoreCount>0?Q8(N.chat.commandPalette.showGroupedMore,{count:K.palette.groupedAgentsMoreCount}):null,onExpandSkills:K.palette.expandGroupedSkills,onExpandCommands:K.palette.expandGroupedCommands,onExpandAgents:K.palette.expandGroupedAgents,currentAgentId:M,currentBadgeLabel:N.chat.commandPalette.currentBadge,runBusy:ee,pendingFollowUpsCount:h.length,maxPendingFollowUps:10,queueBadgeLabel:N.chat.commandPalette.queueBadge,queueFullBadgeLabel:N.chat.commandPalette.queueFullBadge,queueFullTooltip:N.chat.commandPalette.queueFullTooltip,onSelectItem:K.applyPalette}),ne.voiceActive?(0,Z.jsx)(Mve,{phase:ne.phase,elapsedLabel:ne.elapsedLabel,disabled:e,chat:N.chat,onCancel:ne.cancelVoiceInput,onConfirm:ne.confirmVoiceInput}):(0,Z.jsx)(e_e,{editorRef:H.editorRef,disabled:e,placeholder:se?g?N.chat.inputPlaceholderSteeringEdit:N.chat.inputPlaceholderSteering:N.chat.inputPlaceholder,onWireInput:W,adjustHeight:H.adjustHeight,processFiles:V.processFiles,setIsComposing:H.setIsComposing,kbdRef:oe,chatMessages:N.chat})]}),(0,Z.jsx)(O_e,{sessionKey:r,sessionManager:i,disabled:e,sending:t,streaming:n,canSelectWorkingDirectory:a,runBusy:se,chat:N.chat,hasDraft:q,showSteeringInterrupt:ce,attachmentCount:V.attachments.length,maxAttachments:10,onPickFiles:()=>I.current?.click(),thinkingLevel:o,showThinkingSelector:s,onThinkingChange:c,voiceActive:ne.voiceActive,onStartVoiceInput:ne.startVoiceInput,onSend:ie.send,onAbort:u,onInterrupt:ie.interruptDraft,sessionModel:E,showModelSelector:D,onModelChange:O,modelDisabled:k,contextUsageMessages:A,composerDraftChars:te})]})]})});function zve(e,t){let n=e.createdAt;if(!Number.isFinite(n)||n<=0)return 0;let r=typeof e.lastTurnAt==`number`&&Number.isFinite(e.lastTurnAt)?e.lastTurnAt:0,i=e.status===`done`&&r>=n?r:t;return Math.max(0,i-n)}function Bve(e,t){let n=Math.max(0,Math.floor(e/1e3));if(n<60)return t===`zh`?`${n}秒`:`${n}s`;let r=Math.floor(n/60),i=n%60;if(r<60)return t===`zh`?`${r}分${String(i).padStart(2,`0`)}秒`:`${r}m ${i}s`;let a=Math.floor(r/60),o=r%60;return t===`zh`?`${a}小时${o}分`:`${a}h ${o}m`}async function N5(e,t){let n=new URLSearchParams({sessionKey:e});return t?.uiLocale&&n.set(`uiLocale`,t.uiLocale),we(_(`/api/goals/webchat?${n.toString()}`))}async function Vve(e,t,n){return we(_(`/api/goals/webchat`),{method:`POST`,body:JSON.stringify({sessionKey:e,action:t,...n?.uiLocale?{uiLocale:n.uiLocale}:{}})})}async function Hve(e,t,n){let r={sessionKey:e,op:t.op};return t.op===`add`&&(r.text=t.text),(t.op===`remove`||t.op===`mark`)&&(r.index=t.index),t.op===`mark`&&(r.status=t.status),n?.uiLocale&&(r.uiLocale=n.uiLocale),we(_(`/api/goals/webchat/checklist`),{method:`POST`,body:JSON.stringify(r)})}async function P5(e,t){let n=new URLSearchParams({sessionKey:e});return t?.limit!=null&&Number.isFinite(t.limit)&&n.set(`limit`,String(Math.min(500,Math.max(1,Math.floor(t.limit))))),we(_(`/api/goals/webchat/runs?${n.toString()}`))}function Uve(e){let t=(0,Y.c)(45),{goal:n,canEditChecklist:r,mutationBusy:i,t:a,onAction:o,onChecklist:s}=e,c=i||n.status!==`active`,l;t[0]===o?l=t[1]:(l=()=>void o(`pause`),t[0]=o,t[1]=l);let u;t[2]!==a.pause||t[3]!==c||t[4]!==l?(u=(0,Z.jsx)(wA,{type:`button`,variant:`primary`,className:`h-8 px-3 text-xs`,disabled:c,onClick:l,children:a.pause}),t[2]=a.pause,t[3]=c,t[4]=l,t[5]=u):u=t[5];let d=i||n.status!==`paused`&&n.status!==`done`,f;t[6]===o?f=t[7]:(f=()=>void o(`resume`),t[6]=o,t[7]=f);let p;t[8]!==a.resume||t[9]!==d||t[10]!==f?(p=(0,Z.jsx)(wA,{type:`button`,variant:`secondary`,className:`h-8 px-3 text-xs`,disabled:d,onClick:f,children:a.resume}),t[8]=a.resume,t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(m=X(`flex h-8 cursor-pointer list-none items-center rounded-md border border-edge bg-surface-panel px-2.5 text-xs text-fg-muted`,`marker:hidden [&::-webkit-details-marker]:hidden`,`hover:bg-surface-hover hover:text-fg`),t[12]=m):m=t[12];let h;t[13]!==a.moreActions||t[14]!==a.moreHint?(h=(0,Z.jsx)(`summary`,{className:m,title:a.moreHint,children:a.moreActions}),t[13]=a.moreActions,t[14]=a.moreHint,t[15]=h):h=t[15];let g;t[16]===o?g=t[17]:(g=()=>void o(`restart`),t[16]=o,t[17]=g);let _;t[18]!==i||t[19]!==a.restart||t[20]!==g?(_=(0,Z.jsx)(`button`,{type:`button`,className:`block w-full px-3 py-1.5 text-left text-xs text-fg hover:bg-surface-hover`,disabled:i,onClick:g,children:a.restart}),t[18]=i,t[19]=a.restart,t[20]=g,t[21]=_):_=t[21];let v=i||!r,y;t[22]===s?y=t[23]:(y=()=>void s({op:`reset`}),t[22]=s,t[23]=y);let b;t[24]!==a.resetChecklist||t[25]!==v||t[26]!==y?(b=(0,Z.jsx)(`button`,{type:`button`,className:`block w-full px-3 py-1.5 text-left text-xs text-fg hover:bg-surface-hover`,disabled:v,onClick:y,children:a.resetChecklist}),t[24]=a.resetChecklist,t[25]=v,t[26]=y,t[27]=b):b=t[27];let x;t[28]===o?x=t[29]:(x=()=>void o(`clear`),t[28]=o,t[29]=x);let S;t[30]!==i||t[31]!==a.clear||t[32]!==x?(S=(0,Z.jsx)(`button`,{type:`button`,className:`block w-full px-3 py-1.5 text-left text-xs text-destructive hover:bg-surface-hover`,disabled:i,onClick:x,children:a.clear}),t[30]=i,t[31]=a.clear,t[32]=x,t[33]=S):S=t[33];let C;t[34]!==_||t[35]!==b||t[36]!==S?(C=(0,Z.jsxs)(`div`,{className:`absolute right-0 z-30 mt-1 min-w-[11rem] rounded-md border border-edge bg-surface-panel py-1 shadow-surface`,children:[_,b,S]}),t[34]=_,t[35]=b,t[36]=S,t[37]=C):C=t[37];let w;t[38]!==C||t[39]!==h?(w=(0,Z.jsxs)(`details`,{className:`group relative`,children:[h,C]}),t[38]=C,t[39]=h,t[40]=w):w=t[40];let T;return t[41]!==w||t[42]!==u||t[43]!==p?(T=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[u,p,w]}),t[41]=w,t[42]=u,t[43]=p,t[44]=T):T=t[44],T}function Wve(e){return e!==null&&e.status!==`cleared`}function F5(e){let t=e.checklist??[];return{total:t.length,done:t.filter(e=>e.status===`completed`||e.status===`impossible`).length}}function Gve(e){let t=Math.max(0,e.maxTurns),n=Math.max(0,e.turnsUsed);return{used:n,total:t,percent:t>0?Math.min(100,100*n/t):0}}function Kve(e){let{done:t,total:n}=F5(e);return{done:t,total:n,percent:n>0?Math.min(100,100*t/n):0}}function qve(e,t){return t?`agent_running`:e.status===`paused`?`paused`:e.status===`done`?`done`:e.lastVerdict?`judge_recently_completed`:`idle`}function I5(e,t){let n=t;return e===`agent_running`?n.phaseAgentRunning??t.agentRunning:e===`paused`?n.phasePaused??t.statusPaused:e===`done`?n.phaseDone??t.statusDone:e===`judge_recently_completed`?n.phaseJudged??t.lastVerdict:n.missionHeading??t.heading}function Jve(e,t){return e.status===`active`?t.statusActive:e.status===`paused`?t.statusPaused:e.status===`done`?t.statusDone:e.status}function L5(e,t){return e===`done`?t.verdictDone:e===`continue`?t.verdictContinue:e===`skipped`?t.verdictSkipped:e===`decompose`?t.verdictDecompose:e??``}function R5(e,t){return e===`inactive`?t.verdictInactive:L5(e,t)}function z5(e,t){return e===`active`?t.statusActive:e===`paused`?t.statusPaused:e===`done`?t.statusDone:e}function B5(e){return`xopc:goalBannerCollapsed:${e}`}function Yve(e){return e.status===`completed`?`✓`:e.status===`impossible`?`!`:`○`}function Xve(e){let t={pending:[],completed:[],impossible:[]};return e.forEach((e,n)=>{t[e.status].push({...e,index1Based:n+1})}),t}function Zve(e){let t=(0,Y.c)(30),{goal:n,canEdit:r,mutationBusy:i,t:a,onMutate:o}=e,[s,c]=(0,J.useState)(``),l,u,d;if(t[0]!==r||t[1]!==n.checklist||t[2]!==i||t[3]!==o||t[4]!==a){let e=n.checklist??[],s=Xve(e),c=a,f;t[8]!==r||t[9]!==c||t[10]!==i||t[11]!==o||t[12]!==a.markBlocked||t[13]!==a.markDone||t[14]!==a.removeItem?(f=(e,t)=>t.length===0?null:(0,Z.jsxs)(`section`,{className:`space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:e}),(0,Z.jsx)(`span`,{children:t.length})]}),(0,Z.jsx)(`ul`,{className:`space-y-1.5`,children:t.map(e=>(0,Z.jsx)(`li`,{className:`rounded-md border border-transparent px-1.5 py-1 hover:border-edge/60 hover:bg-surface-panel/70`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(`span`,{className:`mt-0.5 w-4 shrink-0 text-center text-fg-muted`,title:e.status,children:Yve(e)}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`p`,{className:`break-words text-fg`,children:e.text}),(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1.5 text-[10px] text-fg-muted`,children:[(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-panel px-1.5 py-0.5`,children:e.addedBy===`user`?c.userAdded??`User`:c.judgeGenerated??`Judge`}),e.evidence?(0,Z.jsxs)(`span`,{className:`min-w-0 break-words`,children:[c.evidenceLabel??`Evidence`,`: `,e.evidence]}):null]})]}),r&&e.status===`pending`?(0,Z.jsxs)(`span`,{className:`flex shrink-0 flex-wrap justify-end gap-0.5`,children:[(0,Z.jsx)(wA,{type:`button`,variant:`ghost`,className:`h-7 px-1.5 text-[11px] text-accent`,disabled:i,onClick:()=>void o({op:`mark`,index:e.index1Based,status:`completed`}),children:a.markDone}),(0,Z.jsx)(wA,{type:`button`,variant:`ghost`,className:`h-7 px-1.5 text-[11px] text-fg-muted`,disabled:i,onClick:()=>void o({op:`mark`,index:e.index1Based,status:`impossible`}),children:a.markBlocked}),(0,Z.jsx)(wA,{type:`button`,variant:`ghost`,className:`h-7 px-1.5 text-[11px] text-destructive`,disabled:i,onClick:()=>void o({op:`remove`,index:e.index1Based}),children:a.removeItem})]}):null]})},`${e.index1Based}-${e.text.slice(0,24)}`))})]}),t[8]=r,t[9]=c,t[10]=i,t[11]=o,t[12]=a.markBlocked,t[13]=a.markDone,t[14]=a.removeItem,t[15]=f):f=t[15];let p=f;l=`rounded-xl bg-surface-muted/70 px-2.5 py-2 dark:bg-surface-muted/40`,t[16]===a.checklistHeading?u=t[17]:(u=(0,Z.jsx)(`p`,{className:`mb-1.5 text-[11px] font-medium uppercase tracking-wide text-fg-muted`,children:a.checklistHeading}),t[16]=a.checklistHeading,t[17]=u),d=e.length===0?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.checklistEmpty}):(0,Z.jsxs)(`div`,{className:`max-h-48 space-y-2 overflow-y-auto pr-0.5 text-xs`,children:[p(c.pendingGroup??`Pending`,s.pending),p(c.completedGroup??`Completed`,s.completed),p(c.impossibleGroup??`Blocked`,s.impossible)]}),t[0]=r,t[1]=n.checklist,t[2]=i,t[3]=o,t[4]=a,t[5]=l,t[6]=u,t[7]=d}else l=t[5],u=t[6],d=t[7];let f;t[18]!==r||t[19]!==i||t[20]!==s||t[21]!==o||t[22]!==a.addCriterion||t[23]!==a.addCriterionPlaceholder?(f=r?(0,Z.jsxs)(`div`,{className:`mt-2 flex gap-1.5`,children:[(0,Z.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:a.addCriterionPlaceholder,className:X(`min-w-0 flex-1 rounded-md border border-edge bg-surface-muted px-2 py-1.5 text-xs text-fg`,`placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`),onKeyDown:e=>{e.key===`Enter`&&s.trim()&&(e.preventDefault(),Promise.resolve(o({op:`add`,text:s.trim()})).then(()=>c(``)))}}),(0,Z.jsx)(wA,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 px-2.5 text-xs`,disabled:i||!s.trim(),onClick:()=>void Promise.resolve(o({op:`add`,text:s.trim()})).then(()=>c(``)),children:a.addCriterion})]}):null,t[18]=r,t[19]=i,t[20]=s,t[21]=o,t[22]=a.addCriterion,t[23]=a.addCriterionPlaceholder,t[24]=f):f=t[24];let p;return t[25]!==l||t[26]!==u||t[27]!==d||t[28]!==f?(p=(0,Z.jsxs)(`div`,{className:l,children:[u,d,f]}),t[25]=l,t[26]=u,t[27]=d,t[28]=f,t[29]=p):p=t[29],p}function Qve(e){let t=(0,Y.c)(23),{goal:n,agentBusy:r,pillTitle:i,phase:a,statusShort:o,turnsShort:s,clLine:c,t:l,onExpand:u}=e,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=X(`pointer-events-none absolute z-30`,`right-[max(0.75rem,env(safe-area-inset-right,0px))] top-[max(0.5rem,env(safe-area-inset-top,0px))]`,`sm:right-[max(1.25rem,env(safe-area-inset-right,0px))] xl:right-[max(1.5rem,env(safe-area-inset-right,0px))]`),t[0]=d):d=t[0];let f;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(f=X(`pointer-events-auto flex h-11 min-w-11 max-w-[min(calc(100vw-1.5rem),16rem)] items-center gap-1.5 rounded-full border border-edge/60 bg-surface-panel/95 px-2.5 py-1 text-left shadow-elevated backdrop-blur-sm`,`transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),t[1]=f):f=t[1];let p=`${i}${c?` · ${c}`:``}${n.lastVerdict?`\n${l.lastVerdict}: ${n.lastVerdict}`:``}${n.lastReason?`\n${l.lastReason}: ${n.lastReason}`:``}\n${n.goal}`,m=l.expandAria,h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(Vw,{className:`size-4 text-accent`,"aria-hidden":!0}),t[2]=h):h=t[2];let g;t[3]!==r||t[4]!==n.status?(g=(0,Z.jsxs)(`span`,{className:`relative flex size-8 shrink-0 items-center justify-center rounded-full bg-surface-muted`,children:[h,r?(0,Z.jsx)(`span`,{className:`absolute -right-0.5 -top-0.5 flex size-2.5 rounded-full border-2 border-surface-panel bg-accent motion-safe:animate-pulse`}):(0,Z.jsx)(`span`,{className:X(`absolute -right-0.5 -top-0.5 size-2.5 rounded-full border-2 border-surface-panel`,n.status===`active`&&`bg-accent`,n.status===`paused`&&`bg-fg-muted`,n.status===`done`&&`bg-fg-muted`)})]}),t[3]=r,t[4]=n.status,t[5]=g):g=t[5];let _;t[6]!==a||t[7]!==l?(_=I5(a,l),t[6]=a,t[7]=l,t[8]=_):_=t[8];let v;t[9]!==o||t[10]!==_?(v=(0,Z.jsxs)(`span`,{className:`block truncate text-[10px] font-medium leading-tight text-fg`,children:[_,` · `,o]}),t[9]=o,t[10]=_,t[11]=v):v=t[11];let y=c?`${s} · ${c}`:s,b;t[12]===y?b=t[13]:(b=(0,Z.jsx)(`span`,{className:`block truncate text-[10px] leading-tight text-fg-muted`,children:y}),t[12]=y,t[13]=b);let x;t[14]!==b||t[15]!==v?(x=(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 pr-0.5`,children:[v,b]}),t[14]=b,t[15]=v,t[16]=x):x=t[16];let S;return t[17]!==u||t[18]!==l.expandAria||t[19]!==x||t[20]!==p||t[21]!==g?(S=(0,Z.jsx)(`div`,{className:`relative h-0 shrink-0 overflow-visible`,children:(0,Z.jsx)(`div`,{className:d,children:(0,Z.jsxs)(`button`,{type:`button`,className:f,title:p,"aria-label":m,onClick:u,children:[g,x]})})}),t[17]=u,t[18]=l.expandAria,t[19]=x,t[20]=p,t[21]=g,t[22]=S):S=t[22],S}function $ve(e){let t=(0,Y.c)(37),{goal:n,t:r}=e,[i,a]=(0,J.useState)(!1);if(!(n.lastVerdict||n.lastReason||n.pausedReason))return null;let o=r,s;t[0]!==n.lastVerdict||t[1]!==r?(s=n.lastVerdict?L5(n.lastVerdict,r):``,t[0]=n.lastVerdict,t[1]=r,t[2]=s):s=t[2];let c=s,l=n.pausedReason||n.lastReason,u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>a(eye),t[3]=u):u=t[3];let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(`span`,{className:`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-panel text-accent`,children:(0,Z.jsx)(db,{className:`size-3.5`,"aria-hidden":!0})}),t[4]=d):d=t[4];let f=o.lastJudgementTitle??r.detailsToggle,p;t[5]===f?p=t[6]:(p=(0,Z.jsx)(`span`,{className:`font-medium`,children:f}),t[5]=f,t[6]=p);let m;t[7]===c?m=t[8]:(m=c?(0,Z.jsx)(`span`,{className:`rounded-full border border-edge px-1.5 py-0.5 text-[10px] text-fg-muted`,children:c}):null,t[7]=c,t[8]=m);let h;t[9]!==p||t[10]!==m?(h=(0,Z.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5 text-fg`,children:[p,m]}),t[9]=p,t[10]=m,t[11]=h):h=t[11];let g;t[12]===l?g=t[13]:(g=l?(0,Z.jsx)(`span`,{className:`mt-0.5 line-clamp-2 block text-fg-muted`,children:l}):null,t[12]=l,t[13]=g);let _;t[14]!==h||t[15]!==g?(_=(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[h,g]}),t[14]=h,t[15]=g,t[16]=_):_=t[16];let v=i?o.hideDetails??r.detailsToggle:o.showDetails??r.detailsToggle,y;t[17]===v?y=t[18]:(y=(0,Z.jsx)(`span`,{className:`shrink-0 text-[10px] text-fg-muted`,children:v}),t[17]=v,t[18]=y);let b;t[19]!==y||t[20]!==_?(b=(0,Z.jsxs)(`button`,{type:`button`,className:`flex w-full min-w-0 items-start gap-2 text-left`,onClick:u,children:[d,_,y]}),t[19]=y,t[20]=_,t[21]=b):b=t[21];let x;t[22]!==o.judgeModel||t[23]!==o.parseFailures||t[24]!==o.pausedReason||t[25]!==n.consecutiveParseFailures||t[26]!==n.judgeModelRef||t[27]!==n.lastReason||t[28]!==n.lastVerdict||t[29]!==n.pausedReason||t[30]!==i||t[31]!==r||t[32]!==c?(x=i?(0,Z.jsxs)(`div`,{className:`mt-2 space-y-1.5 rounded-lg border border-edge/70 bg-surface-panel px-2 py-1.5 text-fg-muted`,children:[n.lastVerdict?(0,Z.jsxs)(`p`,{children:[(0,Z.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.lastVerdict,`:`]}),` `,c]}):null,n.lastReason?(0,Z.jsxs)(`p`,{className:`whitespace-pre-wrap break-words`,children:[(0,Z.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.lastReason,`:`]}),` `,n.lastReason]}):null,n.pausedReason?(0,Z.jsxs)(`p`,{className:`whitespace-pre-wrap break-words`,children:[(0,Z.jsxs)(`span`,{className:`font-medium text-fg`,children:[o.pausedReason??r.statusPaused,`:`]}),` `,n.pausedReason]}):null,n.judgeModelRef?(0,Z.jsxs)(`p`,{className:`break-words`,children:[(0,Z.jsxs)(`span`,{className:`font-medium text-fg`,children:[o.judgeModel??`Judge model`,`:`]}),` `,n.judgeModelRef]}):null,n.consecutiveParseFailures?(0,Z.jsxs)(`p`,{children:[(0,Z.jsxs)(`span`,{className:`font-medium text-fg`,children:[o.parseFailures??`Parse failures`,`:`]}),` `,n.consecutiveParseFailures]}):null]}):null,t[22]=o.judgeModel,t[23]=o.parseFailures,t[24]=o.pausedReason,t[25]=n.consecutiveParseFailures,t[26]=n.judgeModelRef,t[27]=n.lastReason,t[28]=n.lastVerdict,t[29]=n.pausedReason,t[30]=i,t[31]=r,t[32]=c,t[33]=x):x=t[33];let S;return t[34]!==b||t[35]!==x?(S=(0,Z.jsxs)(`section`,{className:`rounded-xl border border-edge/70 bg-surface-muted/45 px-2.5 py-2 text-xs dark:bg-surface-muted/25`,children:[b,x]}),t[34]=b,t[35]=x,t[36]=S):S=t[36],S}function eye(e){return!e}function tye(e){let t=(0,Y.c)(3),{goal:n,t:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,Z.jsx)($ve,{goal:n,t:r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}var nye=new Intl.DateTimeFormat(`zh-CN`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}),rye=new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`});function iye(e,t){let n=typeof e==`string`?new Date(e):e;return(t===`zh`?nye:rye).format(n)}function aye(e){let t=(0,Y.c)(25),{sessionKey:n,goal:r,language:i,t:a}=e,o;t[0]===n?o=t[1]:(o=async()=>(await P5(n,{limit:1})).runs,t[0]=n,t[1]=o);let s;t[2]!==r.lastTurnAt||t[3]!==r.lastVerdict||t[4]!==r.turnsUsed||t[5]!==n?(s=[n,r.turnsUsed,r.lastTurnAt,r.lastVerdict],t[2]=r.lastTurnAt,t[3]=r.lastVerdict,t[4]=r.turnsUsed,t[5]=n,t[6]=s):s=t[6];let c;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],t[7]=c):c=t[7];let l;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(l={initial:c,errorData:[]},t[8]=l):l=t[8];let{data:u,loading:d}=UF(o,s,l),f=u[0];if(!f&&!d)return null;let p=a,m=p.latestRunTitle??a.runHistory,h;t[9]===m?h=t[10]:(h=(0,Z.jsx)(`span`,{className:`font-medium uppercase tracking-wide`,children:m}),t[9]=m,t[10]=h);let g;t[11]!==i||t[12]!==f?(g=f?(0,Z.jsx)(`time`,{suppressHydrationWarning:!0,dateTime:new Date(f.at).toISOString(),children:iye(f.at,i)}):null,t[11]=i,t[12]=f,t[13]=g):g=t[13];let _;t[14]!==h||t[15]!==g?(_=(0,Z.jsxs)(`div`,{className:`mb-1 flex flex-wrap items-center justify-between gap-2 text-[10px] text-fg-muted`,children:[h,g]}),t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==p.nextStepContinue||t[18]!==p.nextStepStop||t[19]!==f||t[20]!==a?(v=f?(0,Z.jsxs)(`div`,{className:`grid gap-1.5 sm:grid-cols-[auto_1fr_auto] sm:items-start`,children:[(0,Z.jsx)(`div`,{className:`rounded-full border border-edge bg-surface-muted px-2 py-0.5 text-[10px] text-fg-muted`,children:a.runHistoryTurns.replace(`{{used}}`,String(f.turnsUsed)).replace(`{{max}}`,String(f.maxTurns))}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-fg`,children:[(0,Z.jsx)(`span`,{children:R5(f.verdict,a)}),(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:`·`}),(0,Z.jsx)(`span`,{children:z5(f.statusAfter,a)}),f.checklistProgress?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:`·`}),(0,Z.jsx)(`span`,{children:a.checklistProgress.replace(`{{done}}`,String(f.checklistProgress.done)).replace(`{{total}}`,String(f.checklistProgress.total))})]}):null]}),f.reason?(0,Z.jsx)(`p`,{className:`mt-1 line-clamp-2 break-words text-fg-muted`,children:f.reason}):null]}),(0,Z.jsx)(`div`,{className:`text-[10px] text-accent sm:text-right`,children:f.willContinue?p.nextStepContinue??a.runHistoryContinue:p.nextStepStop??a.runHistoryStop})]}):(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:a.runHistoryLoading}),t[17]=p.nextStepContinue,t[18]=p.nextStepStop,t[19]=f,t[20]=a,t[21]=v):v=t[21];let y;return t[22]!==_||t[23]!==v?(y=(0,Z.jsxs)(`section`,{className:`rounded-xl border border-edge/70 bg-surface-panel px-2.5 py-2 text-xs`,children:[_,v]}),t[22]=_,t[23]=v,t[24]=y):y=t[24],y}function oye(e){let t=(0,Y.c)(49),{goal:n,phase:r,statusShort:i,turnsShort:a,clLine:o,elapsedStr:s,t:c,onCollapse:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(xg,{className:`size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),t[0]=u):u=t[0];let d;t[1]!==r||t[2]!==c?(d=I5(r,c),t[1]=r,t[2]=c,t[3]=d):d=t[3];let f;t[4]===d?f=t[5]:(f=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:d}),t[4]=d,t[5]=f);let p=n.status===`active`&&`border-accent/40 text-accent`,m=n.status===`paused`&&`border-edge text-fg-muted`,h=n.status===`done`&&`border-edge text-fg-muted`,g;t[6]!==p||t[7]!==m||t[8]!==h?(g=X(`rounded-full border px-1.5 py-0.5`,p,m,h),t[6]=p,t[7]=m,t[8]=h,t[9]=g):g=t[9];let _;t[10]!==i||t[11]!==g?(_=(0,Z.jsx)(`span`,{className:g,children:i}),t[10]=i,t[11]=g,t[12]=_):_=t[12];let v;t[13]!==n.maxTurns||t[14]!==n.turnsUsed||t[15]!==c.turns?(v=c.turns.replace(`{{used}}`,String(n.turnsUsed)).replace(`{{max}}`,String(n.maxTurns)),t[13]=n.maxTurns,t[14]=n.turnsUsed,t[15]=c.turns,t[16]=v):v=t[16];let y;t[17]===v?y=t[18]:(y=(0,Z.jsx)(`span`,{children:v}),t[17]=v,t[18]=y);let b;t[19]===o?b=t[20]:(b=o?(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-panel px-1.5 py-0.5 text-fg`,children:o}):null,t[19]=o,t[20]=b);let x;t[21]===s?x=t[22]:(x=(0,Z.jsx)(`span`,{className:`text-fg`,children:s}),t[21]=s,t[22]=x);let S;t[23]!==c.elapsedLabel||t[24]!==x?(S=(0,Z.jsxs)(`span`,{className:`text-fg-muted`,children:[c.elapsedLabel,`: `,x]}),t[23]=c.elapsedLabel,t[24]=x,t[25]=S):S=t[25];let C;t[26]!==y||t[27]!==b||t[28]!==S||t[29]!==f||t[30]!==_?(C=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[u,f,_,y,b,S]}),t[26]=y,t[27]=b,t[28]=S,t[29]=f,t[30]=_,t[31]=C):C=t[31];let w;t[32]===n.goal?w=t[33]:(w=(0,Z.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-snug text-fg`,title:n.goal,children:n.goal}),t[32]=n.goal,t[33]=w);let T;t[34]!==C||t[35]!==w?(T=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[C,w]}),t[34]=C,t[35]=w,t[36]=T):T=t[36];let E;t[37]===a?E=t[38]:(E=(0,Z.jsx)(`span`,{className:`hidden rounded-full bg-surface-muted px-2 py-1 text-[10px] text-fg-muted sm:inline-flex`,children:a}),t[37]=a,t[38]=E);let D;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(Il,{className:`size-4`,"aria-hidden":!0}),t[39]=D):D=t[39];let O;t[40]!==l||t[41]!==c.collapseAria?(O=(0,Z.jsx)(wA,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 rounded-full p-0 text-fg-muted hover:text-fg`,"aria-label":c.collapseAria,onClick:l,children:D}),t[40]=l,t[41]=c.collapseAria,t[42]=O):O=t[42];let k;t[43]!==E||t[44]!==O?(k=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[E,O]}),t[43]=E,t[44]=O,t[45]=k):k=t[45];let A;return t[46]!==T||t[47]!==k?(A=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-2`,children:[T,k]}),t[46]=T,t[47]=k,t[48]=A):A=t[48],A}function sye(e){let t=(0,Y.c)(20),{goal:n,t:r}=e,i;t[0]===n?i=t[1]:(i=Gve(n),t[0]=n,t[1]=i);let a=i,o;t[2]===n?o=t[3]:(o=Kve(n),t[2]=n,t[3]=o);let s=o,c=r.heading,l=n.status===`done`?`bg-accent`:`bg-accent/75`,u;t[4]===l?u=t[5]:(u=X(`h-full rounded-full transition-[width] duration-300`,l),t[4]=l,t[5]=u);let d=`${a.percent}%`,f;t[6]===d?f=t[7]:(f={width:d},t[6]=d,t[7]=f);let p;t[8]!==u||t[9]!==f?(p=(0,Z.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-elevated`,children:(0,Z.jsx)(`div`,{className:u,style:f})}),t[8]=u,t[9]=f,t[10]=p):p=t[10];let m;t[11]!==s.done||t[12]!==s.percent||t[13]!==s.total||t[14]!==r.checklistProgress?(m=s.total>0?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-fg-muted`,children:[(0,Z.jsx)(`span`,{className:`shrink-0`,children:r.checklistProgress.replace(`{{done}}`,String(s.done)).replace(`{{total}}`,String(s.total))}),(0,Z.jsx)(`div`,{className:`h-1 min-w-10 flex-1 overflow-hidden rounded-full bg-surface-muted`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-fg-muted/55 transition-[width] duration-300`,style:{width:`${s.percent}%`}})})]}):null,t[11]=s.done,t[12]=s.percent,t[13]=s.total,t[14]=r.checklistProgress,t[15]=m):m=t[15];let h;return t[16]!==r.heading||t[17]!==p||t[18]!==m?(h=(0,Z.jsxs)(`div`,{className:`space-y-1.5`,"aria-label":c,children:[p,m]}),t[16]=r.heading,t[17]=p,t[18]=m,t[19]=h):h=t[19],h}var cye=new Intl.DateTimeFormat(`zh-CN`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}),lye=new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`});function uye(e,t){let n=typeof e==`string`?new Date(e):e;return(t===`zh`?cye:lye).format(n)}function dye(e){let t=(0,Y.c)(25),{sessionKey:n,goal:r,language:i,t:a}=e,[o,s]=(0,J.useState)(!1),c;t[0]===n?c=t[1]:(c=async()=>(await P5(n,{limit:40})).runs,t[0]=n,t[1]=c);let l;t[2]!==r.lastTurnAt||t[3]!==r.lastVerdict||t[4]!==r.turnsUsed||t[5]!==o||t[6]!==n?(l=[o,n,r.turnsUsed,r.lastTurnAt,r.lastVerdict],t[2]=r.lastTurnAt,t[3]=r.lastVerdict,t[4]=r.turnsUsed,t[5]=o,t[6]=n,t[7]=l):l=t[7];let u;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=[],t[8]=u):u=t[8];let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=[],t[9]=d):d=t[9];let f;t[10]===o?f=t[11]:(f={enabled:o,initial:u,errorData:d},t[10]=o,t[11]=f);let{data:p,loading:m,error:h}=UF(c,l,f),g=h==null?null:h instanceof Error?h.message:a.runHistoryLoadFailed,_;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>s(fye),t[12]=_):_=t[12];let v;t[13]===a.runHistory?v=t[14]:(v=(0,Z.jsx)(`button`,{type:`button`,className:`text-xs text-fg-muted underline-offset-2 hover:underline`,onClick:_,children:a.runHistory}),t[13]=a.runHistory,t[14]=v);let y;t[15]!==i||t[16]!==p||t[17]!==g||t[18]!==m||t[19]!==o||t[20]!==a?(y=o?(0,Z.jsxs)(`div`,{className:`mt-1 max-h-52 space-y-2 overflow-y-auto rounded-md border border-edge bg-surface-panel p-2 text-xs text-fg-muted`,children:[m?(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:a.runHistoryLoading}):null,g?(0,Z.jsx)(`p`,{className:`text-destructive`,children:g}):null,!m&&!g&&p.length===0?(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:a.runHistoryEmpty}):null,!m&&p.length>0?(0,Z.jsx)(`ul`,{className:`space-y-2`,children:p.map(e=>(0,Z.jsxs)(`li`,{className:`rounded-md border border-edge/80 bg-surface-muted/40 px-2 py-1.5 dark:bg-surface-muted/25`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-2 gap-y-0.5 text-[10px] text-fg-muted`,children:[(0,Z.jsx)(`time`,{suppressHydrationWarning:!0,dateTime:new Date(e.at).toISOString(),children:uye(e.at,i)}),(0,Z.jsx)(`span`,{children:a.runHistoryTurns.replace(`{{used}}`,String(e.turnsUsed)).replace(`{{max}}`,String(e.maxTurns))})]}),(0,Z.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-fg`,children:[(0,Z.jsx)(`span`,{children:R5(e.verdict,a)}),(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:`·`}),(0,Z.jsx)(`span`,{children:z5(e.statusAfter,a)}),(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:`·`}),(0,Z.jsx)(`span`,{children:e.willContinue?a.runHistoryContinue:a.runHistoryStop}),e.checklistProgress?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:`·`}),(0,Z.jsx)(`span`,{children:a.checklistProgress.replace(`{{done}}`,String(e.checklistProgress.done)).replace(`{{total}}`,String(e.checklistProgress.total))})]}):null]}),e.reason?(0,Z.jsxs)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-fg-muted`,children:[(0,Z.jsxs)(`span`,{className:`font-medium text-fg`,children:[a.lastReason,`:`]}),` `,e.reason]}):null,e.assistantPreview?(0,Z.jsx)(`p`,{className:`mt-1 line-clamp-3 break-words text-[10px] leading-snug text-fg-muted`,children:e.assistantPreview}):null]},e.id))}):null]}):null,t[15]=i,t[16]=p,t[17]=g,t[18]=m,t[19]=o,t[20]=a,t[21]=y):y=t[21];let b;return t[22]!==v||t[23]!==y?(b=(0,Z.jsxs)(`div`,{children:[v,y]}),t[22]=v,t[23]=y,t[24]=b):b=t[24],b}function fye(e){return!e}function pye(e,t){switch(t.type){case`start`:return{busy:!0,error:null};case`error`:return{busy:!1,error:t.error};case`done`:return{busy:!1,error:null}}}function mye(e){try{return sessionStorage.getItem(B5(e))===`1`}catch{return!1}}function hye(e){let t=(0,Y.c)(3),{onTick:n}=e,r,i;return t[0]===n?(r=t[1],i=t[2]):(r=()=>{let e=window.setInterval(n,1e3);return()=>clearInterval(e)},i=[n],t[0]=n,t[1]=r,t[2]=i),(0,J.useEffect)(r,i),null}function gye({sessionKey:e,streaming:t,sending:n}){let r=d(e=>e.language),i=m(r).chat.goal,[a,o]=(0,J.useState)(()=>mye(e)),[s,c]=(0,J.useReducer)(pye,{busy:!1,error:null}),[l,u]=(0,J.useState)(()=>Date.now()),f=(0,J.useRef)(t||n),p=(0,J.useRef)(!1),h=t||n;f.current&&!h&&(p.current=!0),f.current=h;let g=(0,J.useCallback)(t=>{o(t);try{t?sessionStorage.setItem(B5(e),`1`):sessionStorage.removeItem(B5(e))}catch{}},[e]),{data:_,loading:v,error:y,setData:b}=UF(async()=>(await N5(e,{uiLocale:r})).persistentGoal,[e,r],{initial:null,errorData:null}),x=(0,J.useCallback)(async()=>{try{b((await N5(e,{uiLocale:r})).persistentGoal)}catch(e){c({type:`error`,error:e instanceof Error?e.message:i.loadFailed})}},[e,r,b,i.loadFailed]),S=(0,J.useEffectEvent)(()=>{x()});(0,J.useEffect)(()=>{let t=t=>{t.detail?.key===e&&S()};return window.addEventListener(`session-updated`,t),()=>window.removeEventListener(`session-updated`,t)},[e]),(0,J.useLayoutEffect)(()=>{p.current&&(p.current=!1,S())});let C=(0,J.useCallback)(()=>{u(Date.now())},[]),w=async t=>{c({type:`start`});try{await Vve(e,t,{uiLocale:r}),await x(),c({type:`done`})}catch(e){c({type:`error`,error:e instanceof Error?e.message:i.loadFailed})}},T=async t=>{c({type:`start`});try{await Hve(e,t,{uiLocale:r}),await x(),c({type:`done`})}catch(e){c({type:`error`,error:e instanceof Error?e.message:i.loadFailed})}},E=!v||y!=null||_!=null,D=s.error??(y==null?null:y instanceof Error?y.message:i.loadFailed);if(!E||!Wve(_))return null;let O=_,k=t||n,A=`${O.turnsUsed}/${O.maxTurns}`,j=Jve(O,i),{total:M,done:N}=F5(O),P=M>0?i.checklistProgress.replace(`{{done}}`,String(N)).replace(`{{total}}`,String(M)):``,F=Bve(zve(O,l),r),I=qve(O,k),L=i.pillTitle.replace(`{{status}}`,j).replace(`{{turns}}`,A),R=!a&&O.status!==`done`&&O.status!==`cleared`;if(a)return(0,Z.jsx)(Qve,{goal:O,agentBusy:k,pillTitle:L,phase:I,statusShort:j,turnsShort:A,clLine:P,t:i,onExpand:()=>g(!1)});let z=O.status===`active`||O.status===`paused`;return(0,Z.jsxs)(`div`,{className:`shrink-0 w-full px-3 pt-1.5 sm:px-5 sm:pt-2 xl:px-6`,children:[R?(0,Z.jsx)(hye,{onTick:C}):null,(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[var(--max-width-chat)] flex-col gap-2.5 rounded-2xl bg-surface-panel px-3 py-2.5 shadow-elevated sm:px-4 sm:py-3`,children:[(0,Z.jsx)(oye,{goal:O,phase:I,statusShort:j,turnsShort:A,clLine:P,elapsedStr:F,t:i,onCollapse:()=>g(!0)}),(0,Z.jsx)(sye,{goal:O,t:i}),(0,Z.jsx)(Zve,{goal:O,canEdit:z,mutationBusy:s.busy,t:i,onMutate:T}),(0,Z.jsx)(Uve,{goal:O,canEditChecklist:z,mutationBusy:s.busy,t:i,onAction:w,onChecklist:T}),(0,Z.jsx)(tye,{goal:O,t:i}),(0,Z.jsx)(aye,{sessionKey:e,goal:O,language:r,t:i}),(0,Z.jsx)(dye,{sessionKey:e,goal:O,language:r,t:i}),D?(0,Z.jsx)(`p`,{className:`text-xs text-destructive`,children:D}):null]})]})}function _ye(e){let t=(0,Y.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Z.jsx)(gye,{...e},e.sessionKey),t[0]=e,t[1]=n),n}function vye(e,t){let n=A1(e,t),r=j1(e,t);return`${e.id} ${n} ${r}`.toLowerCase()}function yye(e,t,n){let r=t.trim().toLowerCase();if(!r)return e;let i=r.split(/\s+/).filter(Boolean);return e.filter(e=>{let t=vye(e,n);return i.every(e=>t.includes(e))})}function bye(e){let t=(0,Y.c)(56),{items:n,value:r,disabled:i,placeholder:a,searchPlaceholder:o,noMatches:s,compact:c,contentSide:l,contentAlign:u,className:f,onChange:p}=e,h=l===void 0?`bottom`:l,g=u===void 0?`end`:u,_=d(Sye),v;t[0]===_?v=t[1]:(v=m(_),t[0]=_,t[1]=v);let y=v.agentsSettings,[b,x]=(0,J.useState)(!1),[S,C]=(0,J.useState)(``),w;t[2]!==y||t[3]!==n||t[4]!==S?(w=yye(n,S,y),t[2]=y,t[3]=n,t[4]=S,t[5]=w):w=t[5];let T=w,E,D,O;if(t[6]!==y||t[7]!==n||t[8]!==a||t[9]!==r){let e;t[13]===r?e=t[14]:(e=e=>e.id===r,t[13]=r,t[14]=e),D=n.find(e),E=D?A1(D,y):r||a,O=D?[A1(D,y),j1(D,y)].filter(Boolean).join(` — `):void 0,t[6]=y,t[7]=n,t[8]=a,t[9]=r,t[10]=E,t[11]=D,t[12]=O}else E=t[10],D=t[11],O=t[12];let k=O??a,A=c&&`min-w-0 max-w-[min(calc(15ch+3rem),calc(100vw-8rem))] py-1.5 text-[13px]`,j;t[15]!==f||t[16]!==A?(j=X(jA,`items-center gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-2 text-left text-sm font-normal text-fg`,AX.transition,`hover:border-edge hover:bg-surface-hover/45`,OA,DA,`disabled:cursor-not-allowed disabled:opacity-50`,`dark:border-edge-subtle dark:hover:bg-surface-hover/55`,A,f),t[15]=f,t[16]=A,t[17]=j):j=t[17];let M;t[18]!==D?.avatar||t[19]!==r?(M=r?(0,Z.jsx)(rH,{agentId:r,avatar:D?.avatar,size:28,className:`shrink-0`}):null,t[18]=D?.avatar,t[19]=r,t[20]=M):M=t[20];let N=c?`max-w-[15ch] shrink`:`flex-1`,P;t[21]===N?P=t[22]:(P=X(`min-w-0 truncate text-left`,N),t[21]=N,t[22]=P);let F;t[23]!==E||t[24]!==P?(F=(0,Z.jsx)(`span`,{className:P,children:E}),t[23]=E,t[24]=P,t[25]=F):F=t[25];let I;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(Ll,{className:`size-4 shrink-0 text-fg-subtle opacity-70`,"aria-hidden":!0}),t[26]=I):I=t[26];let L;t[27]!==i||t[28]!==F||t[29]!==k||t[30]!==j||t[31]!==M?(L=(0,Z.jsx)(vF,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,disabled:i,title:k,className:j,children:[M,F,I]})}),t[27]=i,t[28]=F,t[29]=k,t[30]=j,t[31]=M,t[32]=L):L=t[32];let R;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(R=X(`z-50 w-[var(--radix-popover-trigger-width)] min-w-[12rem] max-h-[min(20rem,calc(100vh-6rem))] overflow-hidden rounded-lg border border-edge bg-surface-panel shadow-md`,AX),t[33]=R):R=t[33];let z;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>C(e.target.value),t[34]=z):z=t[34];let B;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(B=X(`w-full rounded-md border border-edge bg-surface-elevated px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-muted`,OA),t[35]=B):B=t[35];let V;t[36]!==S||t[37]!==o?(V=(0,Z.jsx)(`div`,{className:`border-b border-edge p-2`,children:(0,Z.jsx)(`input`,{type:`search`,value:S,onChange:z,placeholder:o,className:B,"aria-label":o})}),t[36]=S,t[37]=o,t[38]=V):V=t[38];let H;t[39]!==y||t[40]!==T||t[41]!==s||t[42]!==p||t[43]!==r?(H=T.length===0?(0,Z.jsx)(`li`,{className:`p-2 text-sm text-fg-muted`,children:s}):T.map(e=>{let t=e.id===r,n=A1(e,y),i=j1(e,y),a=i.length>0?i:void 0;return(0,Z.jsx)(`li`,{role:`option`,"aria-selected":t,children:(0,Z.jsxs)(`button`,{type:`button`,className:X(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-fg`,t?`bg-surface-hover`:`hover:bg-surface-hover`),onClick:()=>{p(e.id),x(!1),C(``)},children:[(0,Z.jsx)(Ml,{className:X(`size-4 shrink-0`,t?`opacity-100`:`opacity-0`),"aria-hidden":!0}),(0,Z.jsx)(rH,{agentId:e.id,avatar:e.avatar,size:32,className:`shrink-0`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`block truncate font-medium leading-tight`,title:n,children:n}),i?(0,Z.jsx)(`span`,{className:`mt-0.5 block truncate text-xs leading-tight text-fg-muted`,title:a,children:i}):null]})]})},e.id)}),t[39]=y,t[40]=T,t[41]=s,t[42]=p,t[43]=r,t[44]=H):H=t[44];let U;t[45]===H?U=t[46]:(U=(0,Z.jsx)(`ul`,{className:`max-h-[min(16rem,calc(100vh-10rem))] overflow-y-auto p-1`,role:`listbox`,children:H}),t[45]=H,t[46]=U);let W;t[47]!==g||t[48]!==h||t[49]!==V||t[50]!==U?(W=(0,Z.jsx)(yF,{children:(0,Z.jsxs)(bF,{side:h,align:g,sideOffset:4,collisionPadding:8,className:R,onOpenAutoFocus:xye,children:[V,U]})}),t[47]=g,t[48]=h,t[49]=V,t[50]=U,t[51]=W):W=t[51];let G;return t[52]!==b||t[53]!==L||t[54]!==W?(G=(0,Z.jsxs)(gF,{open:b,onOpenChange:x,children:[L,W]}),t[52]=b,t[53]=L,t[54]=W,t[55]=G):G=t[55],G}function xye(e){return e.preventDefault()}function Sye(e){return e.language}var Cye=`(max-width: 767px)`,wye=(0,J.memo)(function(e){let t=(0,Y.c)(24),{chatHeadline:n,chatAgents:r,showChatAgentSelector:i,chatAgentId:a,onChatAgentChange:o,chatAgentDisabled:s}=e,c=d(Tye),l;t[0]===c?l=t[1]:(l=m(c),t[0]=c,t[1]=l);let u=l,f=Cj(Eye),p=cQ(Dye),h=cQ(Oye),g=zj(kye),_=Gj(Aye),v=Gj(jye),y=t8(Cye),b;t[2]!==y||t[3]!==g||t[4]!==f?(b=y?!g:f&&!jj(),t[2]=y,t[3]=g,t[4]=f,t[5]=b):b=t[5];let x=b,S,C;return t[6]!==s||t[7]!==a||t[8]!==r||t[9]!==n||t[10]!==v||t[11]!==u.chat.agentNoMatches||t[12]!==u.chat.agentPlaceholder||t[13]!==u.chat.agentSearchPlaceholder||t[14]!==u.sidebar.newTask||t[15]!==u.workspace.openFiles||t[16]!==o||t[17]!==_||t[18]!==i||t[19]!==x||t[20]!==h||t[21]!==p?(S=()=>(_({startExtra:x?(0,Z.jsx)(ja,{to:`/chat/new`,className:X(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-panel text-sm font-medium leading-none text-fg transition-colors hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,dj),title:u.sidebar.newTask,children:(0,Z.jsx)(xv,{className:`size-4 shrink-0 text-accent-fg`,strokeWidth:2,"aria-hidden":!0})}):null,main:(0,Z.jsx)(`div`,{className:`w-full min-w-0 max-w-(--max-width-chat) px-3 sm:px-5 xl:px-6`,children:(0,Z.jsx)(`h1`,{className:X(`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,x?`text-left md:text-center`:`text-left`),title:n,children:n})}),end:(0,Z.jsxs)(`div`,{className:X(`flex min-w-0 max-w-[min(32rem,calc(100vw-8rem))] shrink-0 items-center justify-end gap-2`,dj),children:[i?(0,Z.jsx)(`div`,{className:`min-w-0 w-fit shrink-0`,children:(0,Z.jsx)(bye,{items:r,value:a,disabled:s,placeholder:u.chat.agentPlaceholder,searchPlaceholder:u.chat.agentSearchPlaceholder,noMatches:u.chat.agentNoMatches,compact:!0,contentSide:`bottom`,contentAlign:`end`,onChange:o})}):null,(0,Z.jsx)(`button`,{type:`button`,className:X(`rounded-md p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,p&&`bg-surface-hover text-fg`),title:u.workspace.openFiles,"aria-label":u.workspace.openFiles,"aria-pressed":p,onClick:h,children:(0,Z.jsx)(Sp,{className:`size-4`})})]})}),()=>v()),C=[n,r,i,a,o,s,x,u.chat.agentPlaceholder,u.chat.agentSearchPlaceholder,u.chat.agentNoMatches,u.sidebar.newTask,u.workspace.openFiles,p,h,_,v],t[6]=s,t[7]=a,t[8]=r,t[9]=n,t[10]=v,t[11]=u.chat.agentNoMatches,t[12]=u.chat.agentPlaceholder,t[13]=u.chat.agentSearchPlaceholder,t[14]=u.sidebar.newTask,t[15]=u.workspace.openFiles,t[16]=o,t[17]=_,t[18]=i,t[19]=x,t[20]=h,t[21]=p,t[22]=S,t[23]=C):(S=t[22],C=t[23]),(0,J.useLayoutEffect)(S,C),null});function Tye(e){return e.language}function Eye(e){return e.collapsed}function Dye(e){return e.open}function Oye(e){return e.toggleOpen}function kye(e){return e.mobileNavOpen}function Aye(e){return e.setPageHeader}function jye(e){return e.clearPageHeader}var Mye=(0,J.memo)(function(){let e=(0,Y.c)(13),t=d(Nye),n;e[0]===t?n=e[1]:(n=m(t),e[0]=t,e[1]=n);let r=n,i=R1(Pye),a=R1(Fye);if(i===`idle`)return null;if(i===`error`&&a){let t;e[2]===a?t=e[3]:(t=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:a}),e[2]=a,e[3]=t);let n;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(n=X(`shrink-0 rounded-xl border border-red-200 bg-white px-2.5 py-1 text-xs font-medium text-red-700`,`hover:bg-red-50 dark:border-red-800 dark:bg-red-950/40 dark:text-red-300 dark:hover:bg-red-950/70`,AX.transition,AX.press,AX.focusRingPanel),e[4]=n):n=e[4];let i;e[5]===r.connection.reconnect?i=e[6]:(i=(0,Z.jsx)(`button`,{type:`button`,className:n,onClick:Iye,children:r.connection.reconnect}),e[5]=r.connection.reconnect,e[6]=i);let o;return e[7]!==t||e[8]!==i?(o=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-red-100 bg-red-50 px-4 py-2 text-sm text-red-600 dark:border-red-900/40 dark:bg-red-950/50 dark:text-red-400`,children:[t,i]}),e[7]=t,e[8]=i,e[9]=o):o=e[9],o}if(i===`connecting`||i===`reconnecting`){let t;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`span`,{className:`inline-block size-3 animate-spin rounded-full border-2 border-amber-500 border-t-transparent`,"aria-hidden":!0}),e[10]=t):t=e[10];let n=i===`reconnecting`?r.connection.reconnecting:r.connection.connecting,a;return e[11]===n?a=e[12]:(a=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-amber-100 bg-amber-50 px-4 py-2 text-sm text-amber-800 dark:border-amber-900/40 dark:bg-amber-950/50 dark:text-amber-200`,children:[t,(0,Z.jsx)(`span`,{children:n})]}),e[11]=n,e[12]=a),a}return null});function Nye(e){return e.language}function Pye(e){return e.connectionState}function Fye(e){return e.error}function Iye(){return cue()}function Lye(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function V5(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function H5(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var U5=(e,t)=>Math.abs(e-t)<1.01,Rye=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},W5,G5=()=>{if(W5!==void 0)return W5;if(typeof navigator>`u`)return W5=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return W5=!0;let e=navigator.maxTouchPoints;return W5=navigator.platform===`MacIntel`&&e!==void 0&&e>0},K5=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},zye=e=>e,Bye=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},Vye=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(K5(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(K5(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},q5={passive:!0},Hye=typeof window>`u`?!0:`onscrollend`in window,Uye=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&Hye,o=0,s=a?null:Rye(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,q5),a&&r.addEventListener(`scrollend`,u,q5),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},Wye=(e,t)=>Uye(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),J5=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},Gye=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},Kye=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:zye,rangeExtractor:Bye,onChange:()=>{},measureElement:J5,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,a=t.count,o=this.getMeasurements(),s=e>0?o[0]?.key??n.getItemKey(0):null,c=e>0?o[e-1]?.key??n.getItemKey(e-1):null;if(a!==e||e>0&&a>0&&(t.getItemKey(0)!==s||t.getItemKey(a-1)!==c)){let s=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??o[0]:null;s&&(r=[s.key,this.getScrollOffset()-s.start]);let l=t.followOnAppend===!0?`auto`:t.followOnAppend||null;l&&a>e&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(a-1)!==c)&&(i=l)}}this.options=t,(r||i)&&(this.pendingScrollAnchor=[r?.[0]??null,r?.[1]??0,i])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=V5(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!G5()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,q5),e.addEventListener(`touchend`,n,q5),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r]=t;if(e!==null){let{count:t,getItemKey:r}=this.options,i=0;for(;i<t&&r(i)!==e;)i++;let a=i<t?this.getMeasurements()[i]:void 0;if(a){let e=a.start+n-this.getScrollOffset();U5(e,0)||this.applyScrollAdjustment(e)}}r&&this.scrollToEnd({behavior:r})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=V5(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=V5(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{let c=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let l=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=this.options.gap,a=e*2,o=this._flatMeasurements;if(!o||o.length<a){let e=new Float64Array(a);o&&l>0&&e.set(o.subarray(0,l*2)),o=e,this._flatMeasurements=o}let s;if(l===0)s=t+n;else{let e=l-1;s=o[e*2]+o[e*2+1]+i}for(let t=l;t<e;t++){let e=r(t),n=c.get(e),a=typeof n==`number`?n:this.options.estimateSize(t);o[t*2]=s,o[t*2+1]=a,s+=a+i}let u=Lye(e,o,r);return this.measurementsCache=u,u}let u=this.measurementsCache.slice(0,l),d=Array(a).fill(void 0);for(let e=0;e<l;e++){let t=u[e];t&&(d[t.lane]=e)}for(let i=l;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,l,f=o===`estimate`||c.has(e);if(a!==void 0&&this.options.lanes>1){s=a;let e=d[s],r=e===void 0?void 0:u[e];l=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?u[i-1]:this.getFurthestMeasurement(u,i);l=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,s)}let p=c.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=l+m;u[i]={index:i,start:l,size:m,end:h,key:e,lane:s},d[s]=i}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=V5(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?qye({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:r===1&&this._flatMeasurements!=null?this._flatMeasurements:null}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=V5(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(e<0||e>=this.options.count)return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=t-(this.itemSizeCache.get(i)??n);if(o!==0){let a=this.options.anchorTo===`end`&&this.scrollState?.behavior!==`smooth`&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,s=a?this.getTotalSize():0,c=this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?r<this.getScrollOffset()+this.scrollAdjustments&&this.scrollDirection!==`backward`:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},o,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++,a?this.applyScrollAdjustment(this.getTotalSize()-s):c&&this.applyScrollAdjustment(o),this.notify(!1)}},this.getVirtualItems=V5(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return H5(t[Y5(0,t.length-1,r?e=>n[e*2]:e=>H5(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:`end`,behavior:e});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){e!==0&&(G5()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=e:this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&U5(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},Y5=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function qye({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:i}){let a=e.length-1,o=i?e=>i[e*2]:t=>e[t].start,s=i?e=>i[e*2]+i[e*2+1]:t=>e[t].end;if(e.length<=r)return{startIndex:0,endIndex:a};let c=Y5(0,a,o,n),l=c;if(r===1)for(;l<a&&s(l)<n+t;)l++;else if(r>1){let i=Array(r).fill(0);for(;l<a&&i.some(e=>e<n+t);){let t=e[l];i[t.lane]=t.end,l++}let o=Array(r).fill(n+t);for(;c>=0&&o.some(e=>e>=n);){let t=e[c];o[t.lane]=t.start,c--}c=Math.max(0,c-c%r),l=Math.min(a,l+(r-1-l%r))}return{startIndex:c,endIndex:l}}var X5=typeof document<`u`?J.useLayoutEffect:J.useEffect;function Jye({useFlushSync:e=!0,...t}){let n=J.useReducer(e=>e+1,0)[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,Xa.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=J.useState(()=>new Kye(r));return i.setOptions(r),X5(()=>i._didMount(),[]),X5(()=>i._willUpdate()),i}function Yye(e){return Jye({observeElementRect:Vye,observeElementOffset:Wye,scrollToFn:Gye,...e})}var Xye={folder:Sp,content:P_,documents:Fd,globe:km};function Zye(e){let t=(0,Y.c)(2),{name:n}=e,r=Xye[n]??Sp,i;return t[0]===r?i=t[1]:(i=(0,Z.jsx)(r,{className:`size-[1.125rem] text-accent-fg sm:size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=r,t[1]=i),i}var Qye=(0,J.memo)(function(e){let t=(0,Y.c)(28),{chat:n,onPickPrompt:r}=e,i=n.welcomeSpotlight,a=(0,J.useId)(),[o,s]=(0,J.useState)(null),c;t[0]!==i?.categories||t[1]!==o?(c=i?.categories.find(e=>e.id===o),t[0]=i?.categories,t[1]=o,t[2]=c):c=t[2];let l=c;if(!i)return null;let u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(uA,{className:`size-12 shrink-0 sm:size-14`,"aria-hidden":!0}),t[3]=u):u=t[3];let d;t[4]===i.headline?d=t[5]:(d=(0,Z.jsx)(`h1`,{className:`text-balance text-lg font-semibold tracking-tight text-fg sm:text-xl`,children:i.headline}),t[4]=i.headline,t[5]=d);let f;t[6]===i.tagline?f=t[7]:(f=(0,Z.jsx)(`p`,{className:`max-w-md text-pretty text-sm leading-snug text-fg-muted sm:text-[0.9375rem]`,children:i.tagline}),t[6]=i.tagline,t[7]=f);let p;t[8]!==d||t[9]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 px-1 pt-8 text-center sm:gap-2 sm:pt-10`,children:[u,d,f]}),t[8]=d,t[9]=f,t[10]=p):p=t[10];let m;if(t[11]!==a||t[12]!==i.categories||t[13]!==o){let e;t[15]!==a||t[16]!==o?(e=e=>{let t=o===e.id;return(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":t,"aria-controls":t?a:void 0,onClick:()=>s(t=>t===e.id?null:e.id),className:X(`flex flex-row items-start gap-2.5 rounded-xl border bg-surface-panel p-2.5 text-left shadow-surface sm:flex-col sm:gap-2`,AX.transition,AX.press,AX.focusRingPanel,t?`border-accent ring-1 ring-accent/25`:`border-edge hover:border-edge-strong hover:bg-surface-hover/40 dark:hover:bg-surface-hover/30`),children:[(0,Z.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-accent-soft sm:size-10`,children:(0,Z.jsx)(Zye,{name:e.icon})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium leading-snug text-fg sm:text-[0.9375rem]`,children:e.title}),(0,Z.jsx)(`div`,{className:`mt-0.5 text-xs leading-snug text-fg-muted sm:text-sm`,children:e.description})]})]},e.id)},t[15]=a,t[16]=o,t[17]=e):e=t[17],m=i.categories.map(e),t[11]=a,t[12]=i.categories,t[13]=o,t[14]=m}else m=t[14];let h;t[18]===m?h=t[19]:(h=(0,Z.jsx)(`div`,{className:`mt-10 grid w-full grid-cols-1 gap-2 sm:mt-12 sm:grid-cols-2 sm:gap-2.5 lg:grid-cols-4`,children:m}),t[18]=m,t[19]=h);let g;t[20]!==r||t[21]!==a||t[22]!==l?(g=l&&l.scenarios.length>0?(0,Z.jsx)(`div`,{id:a,role:`region`,"aria-label":l.title,className:`flex flex-col gap-1.5 rounded-xl border border-edge bg-surface-base/80 p-2.5 dark:bg-surface-hover/20`,children:(0,Z.jsx)(`ul`,{className:`flex flex-col gap-1`,children:l.scenarios.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>r(e.prompt),className:X(`flex w-full gap-2 rounded-lg border border-transparent px-2 py-1.5 text-left text-sm leading-snug text-fg`,AX.transition,AX.press,AX.focusRingPanel,`hover:border-edge hover:bg-surface-panel dark:hover:bg-surface-panel/40`),children:[(0,Z.jsx)(kg,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 text-pretty`,children:e.prompt})]})},e.prompt))})}):null,t[20]=r,t[21]=a,t[22]=l,t[23]=g):g=t[23];let _;return t[24]!==p||t[25]!==h||t[26]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3.5 pb-2 sm:gap-4 sm:pb-3`,children:[p,h,g]}),t[24]=p,t[25]=h,t[26]=g,t[27]=_):_=t[27],_}),$ye=String.raw`png|jpe?g|gif|webp|bmp|svg|pdf|docx?|xlsx?|pptx?|txt|md|json|html?|css|mjs?|cjs|js|ts|mp3|wav|ogg|m4a|mp4|mov|webm`;function Z5(){return`(?:${$ye})`}var ebe=RegExp(`(/[^\\s"'"<>|*?\\n]+?\\.(?:${Z5()}))`,`gi`),tbe=RegExp(`([A-Za-z]:[\\\\/][^"'\`<>*?\\n|=]+?\\.(?:${Z5()}))`,`gi`),nbe={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,bmp:`image/bmp`,svg:`image/svg+xml`,pdf:`application/pdf`,doc:`application/msword`,docx:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,xls:`application/vnd.ms-excel`,xlsx:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,ppt:`application/vnd.ms-powerpoint`,pptx:`application/vnd.openxmlformats-officedocument.presentationml.presentation`,txt:`text/plain`,md:`text/markdown`,json:`application/json`,html:`text/html`,htm:`text/html`,css:`text/css`,mjs:`text/javascript`,cjs:`text/javascript`,js:`text/javascript`,ts:`text/typescript`,mp3:`audio/mpeg`,wav:`audio/wav`,ogg:`audio/ogg`,m4a:`audio/mp4`,mp4:`video/mp4`,mov:`video/quicktime`,webm:`video/webm`};function Q5(e){let t=e.lastIndexOf(`.`);return t<0?`application/octet-stream`:nbe[e.slice(t+1).toLowerCase()]??`application/octet-stream`}function $5(e){return e.startsWith(`image/`)}function e7(e){let t=e.trim();if(t.length<4||t.startsWith(`//`)&&!t.startsWith(`//Users`)||t.startsWith(`http:`)||t.startsWith(`https:`)||t.startsWith(`data:`)||t.startsWith(`file://`))return!1;if(t.startsWith(`/`))return/^\/(?:Users|usr|var|opt|tmp|home|root|System|private|dev|media|mnt|Volumes|data)(?:\/|[\s]|$)/i.test(t);if(/^[A-Za-z]:[\\/]/.test(t)){let e=t.replace(/\\/g,`/`);return!/^[A-Za-z]:\/{2,}/.test(e)}return!!t.startsWith(`\\\\`)}function t7(e){let t=e.replace(/\\/g,`/`).split(`/`).filter(Boolean);return t[t.length-1]||e}function n7(e){let t=e.trim();return t.includes(`
4682
- `)||t.includes(`\r`)?t:t.replace(/^(?:File written|File edited)\s*:\s*/i,``).replace(/^Saved\s*:\s*/i,``).trim()}function r7(e){let t=e.trim();if(t.includes(`
4683
- `)||t.includes(`\r`))return t;let n=t.match(/^[fd?] (.+)$/);return n?n[1].trim():t}function i7(e,t,n,r,i){let a=e.trim();if(!a||!e7(a)||!/\.(png|jpe?g|gif|webp|bmp|svg|pdf|docx?|xlsx?|pptx?|txt|md|json|html?|css|mjs?|cjs|js|ts|mp3|wav|ogg|m4a|mp4|mov|webm)$/i.test(a))return;let o=t7(a);t.push({absolutePath:a,fileName:o,mimeType:Q5(o),startIndex:r,endIndex:i})}var rbe=new Set([`SOUL.md`,`IDENTITY.md`,`USER.md`,`TOOLS.md`,`AGENTS.md`,`HEARTBEAT.md`,`MEMORY.md`,`BOOTSTRAP.md`].map(e=>e.toLowerCase()));function ibe(e){let t=t7(e.replace(/\\/g,`/`));return!t||t===`.`||t===`..`?!1:rbe.has(t.toLowerCase())}function abe(e){let t=e.trim();return t.includes(`
4684
- `)||t.includes(`\r`)?!1:/^[fd?] .+$/i.test(t)}function a7(e){let t=e.trim().replace(/\\/g,`/`);return t.length<4||t.includes(`..`)||t.startsWith(`/`)||/^[A-Za-z]:/i.test(t)||t.startsWith(`\\\\`)||/^[a-z][a-z0-9+.-]*:/i.test(t)||ibe(t)?!1:/\.(png|jpe?g|gif|webp|bmp|svg|pdf|docx?|xlsx?|pptx?|txt|md|json|html?|css|mjs?|cjs|js|ts|mp3|wav|ogg|m4a|mp4|mov|webm)$/i.test(t)}function o7(e,t,n){let r=r7(n7(e)).trim().replace(/\\/g,`/`);if(!a7(r))return;let i=t7(r);t.push({absolutePath:`rel:${r}`,fileName:i,mimeType:Q5(i),workspaceRelativePath:r,startIndex:0,endIndex:0})}function s7(e,t,n){if(typeof e==`string`){if(abe(e)){let r=r7(n7(e)).trim().replace(/\\/g,`/`);if(e7(r)&&/\.[a-z0-9]+$/i.test(r)){let i=n.indexOf(e);i>=0?i7(r,t,n,i,i+e.length):i7(r,t,n,0,0)}return}let r=r7(n7(e)).trim().replace(/\\/g,`/`);if(e7(r)&&/\.[a-z0-9]+$/i.test(r)){let i=n.indexOf(e);i>=0?i7(r,t,n,i,i+e.length):i7(r,t,n,0,0);return}let i=t.length;if(c7(r,t),t.length>i)return;a7(r)&&o7(e,t,n);return}if(Array.isArray(e)){for(let r of e)s7(r,t,n);return}if(e&&typeof e==`object`){let r=e,i=r.workspaceRelativePaths,a=Array.isArray(i)&&i.length>0&&i.every(e=>typeof e==`string`);if(a)for(let e of i)o7(e,t,n);for(let[e,i]of Object.entries(r))a&&e===`paths`||s7(i,t,n)}}function c7(e,t){for(let n of[ebe,tbe]){n.lastIndex=0;let r;for(;(r=n.exec(e))!==null;){let n=r[1];if(n){let i=r.indices?.[1]?.[0]??r.index??0;i7(n,t,e,i,i+n.length)}}}}function obe(){return`(?:[A-Za-z0-9_.-]+\\/)*[A-Za-z0-9_.-]+\\.(?:${Z5()})`}function sbe(e){let t=`(${obe()})`,n=[RegExp(`\\*\\*${t}\\*\\*`,`gi`),RegExp("`"+t+"`",`gi`),RegExp(`\\]\\(${t}\\)`,`gi`)],r=[];for(let t of n){t.lastIndex=0;let n;for(;(n=t.exec(e))!==null;){let t=n[1]?.trim().replace(/^<|>$/g,``);if(t)try{o7(decodeURIComponent(t),r,e)}catch{o7(t,r,e)}}}let i=new Set;return r.reduce((e,t)=>{let n=t.workspaceRelativePath??t.absolutePath;return i.has(n)?e:(i.add(n),e.push({...t,origin:`assistant-markdown`}),e)},[])}function l7(e,t){let n=e.trim().replace(/\\/g,`/`),r=t.trim().replace(/\\/g,`/`).replace(/^\/+/,``);return!r||n.length<r.length?!1:n===r||n.endsWith(`/${r}`)}function cbe(e){let t=e.map(e=>e.workspaceRelativePath).filter(e=>!!e);return t.length===0?e:e.filter(e=>e.workspaceRelativePath||!e7(e.absolutePath)?!0:!t.some(t=>l7(e.absolutePath,t)))}function u7(e){let t=[];if(!e?.trim())return[];try{s7(JSON.parse(e),t,e)}catch{}t.some(e=>e.workspaceRelativePath)||c7(e,t);let n=cbe(t),r=new Set;return n.reduce((e,t)=>{let n=t.absolutePath;return r.has(n)?e:(r.add(n),e.push({...t,origin:`tool-result`}),e)},[])}var d7=new Set([`write_file`,`edit_file`,`image_generate`]);function lbe(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function f7(e){return(e??``).replace(/\\/g,`/`).replace(/^\/+/,``).trim()}function ube(e,t){let n=f7(e.workspaceRelativePath),r=f7(t.workspaceRelativePath),i=e.absolutePath,a=t.absolutePath;return n&&r?n===r:n&&e7(a)?l7(a,n):r&&e7(i)?l7(i,r):e7(i)&&e7(a)?i.replace(/\\/g,`/`).trim()===a.replace(/\\/g,`/`).trim():i===a}function dbe(e,t){let n=e7(e.absolutePath)?e.absolutePath:e7(t.absolutePath)?t.absolutePath:e.absolutePath;return{...e,absolutePath:n,workspaceRelativePath:e.workspaceRelativePath??t.workspaceRelativePath,fileName:e.fileName||t.fileName,mimeType:e.mimeType||t.mimeType}}function p7(e){let t=[],n=f7(e.workspaceRelativePath);n&&t.push(`rel:${n}`);let r=e.absolutePath?.replace(/\\/g,`/`).trim();return e7(r)&&t.push(`abs:${r}`),t}function fbe(e){let t=new Map;return e.forEach((e,n)=>{for(let r of p7(e))t.set(r,n)}),t}function pbe(e,t,n){for(let e of p7(n)){let n=t.get(e);if(n!==void 0)return n}for(let t=0;t<e.length;t++)if(ube(e[t],n))return t;return-1}function m7(e,t){let n=fbe(e);for(let r of t){let t=pbe(e,n,r);if(t>=0){e[t]=dbe(e[t],r);for(let r of p7(e[t]))n.set(r,t);continue}let i=e.length;e.push(r);for(let e of p7(r))n.set(e,i)}}function mbe(e){return!(e.type===`voice`||e.type===`audio`||e.type===`image`||e.mimeType?.startsWith(`image/`)||e.mimeType?.startsWith(`audio/`))}function hbe(e,t){if(!e?.length||!t.length)return e;let n=e.filter(e=>mbe(e)?!gbe(e,t):!0);return n.length===e.length?e:n.length?n:void 0}function h7(e){let t=e.replace(/\\/g,`/`).split(`/`).filter(Boolean);return(t[t.length-1]??e).trim().toLowerCase()}function gbe(e,t){let n=f7(e.workspaceRelativePath),r=(e.name??``).trim().toLowerCase();for(let e of t){let t=f7(e.workspaceRelativePath);if(t&&n&&n===t||t&&!n&&r&&h7(t)===r||e7(e.absolutePath)&&n&&l7(e.absolutePath,n)||!t&&!n&&r&&e7(e.absolutePath)&&h7(e.absolutePath)===r)return!0}return!1}function _be(e){if(!e?.length)return[];let t=[];for(let n of e){if(n.type!==`tool_use`)continue;let e=n;if(e.status!==`done`||!d7.has(e.name))continue;let r=lbe(e.result);r.trim()&&m7(t,u7(r))}let n=new Set(t.flatMap(e=>{let t=f7(e.workspaceRelativePath);return t?[t]:[]})),r=new Set;for(let e of t)if(e7(e.absolutePath)){let t=h7(e.absolutePath);t&&r.add(t)}for(let i of e){if(i.type!==`text`)continue;let e=(i.text??``).trim();!e||n.size===0&&r.size===0||m7(t,sbe(e).filter(e=>{let t=f7(e.workspaceRelativePath);if(!t)return!1;if(n.has(t))return!0;if(t.split(`/`).length<2)return!1;let i=h7(t);return i.length>0&&r.has(i)}))}return t}function g7(e,t){let n=e.source?.data?.trim();if(!n)return null;let r=n.match(/^data:([^;]+);base64,([\s\S]+)$/i);if(r?.[1]&&r[2]){let e=r[2].replace(/\s/g,``);return{name:`image-${t+1}`,mimeType:r[1],type:`image`,content:e,data:e}}if(n.startsWith(`data:`))return{name:`image-${t+1}`,mimeType:`image/png`,type:`image`,content:n,data:n};let i=n.replace(/\s/g,``);return{name:`image-${t+1}`,mimeType:`image/png`,type:`image`,content:i,data:i}}function vbe(e){if(!e?.length)return[];let t=[];for(let n=0;n<e.length;n+=1){let r=g7(e[n],n);r&&t.push(r)}return t}function _7(e){return e.toLowerCase().replace(/-/g,`_`).trim()}function ybe(e,t){let n=_7(e);return n===`shell`?t.runCommand:n===`list_dir`||n===`ls`?t.listDirectory:n===`write_file`?t.writeFile:n===`edit_file`?t.editFile:n===`web_fetch`?t.fetchUrl:n===`open_url`?t.openUrl:n===`web_search`||n===`brave_search`||n.includes(`search`)?t.searchedWeb:n===`read_file`||n.includes(`read_file`)||n.includes(`file_read`)?t.readFile:t.unknownTool.replace(`{{name}}`,e.trim()||`tool`)}function bbe(e){if(e===void 0)return``;try{return JSON.stringify(JSON.parse(e),null,2)}catch{try{return JSON.stringify(e,null,2)}catch{return String(e)}}}function v7(e){if(e==null)return null;try{return typeof e==`string`?JSON.parse(e):e}catch{return null}}function xbe(e){let t=v7(e),n=t?.query??t?.q??t?.query_string??t?.search_term??t?.searchQuery;return typeof n==`string`?n:typeof n==`number`?String(n):``}function y7(e){let t=v7(e),n=t?.path??t?.file_path??t?.filepath??t?.file;return typeof n==`string`?n:``}function b7(e){let t=v7(e),n=t?.url??t?.href??t?.uri??t?.website;return typeof n==`string`?n:``}function x7(e){let t=v7(e),n=t?.command??t?.cmd??t?.shell??t?.script;return typeof n==`string`?n:``}var S7=120;function C7(e){if(e==null)return``;let t=v7(e);if(!t)return typeof e==`string`?e.trim():``;let n=[t.command,t.cmd,t.shell,t.script,t.path,t.file_path,t.filepath,t.file,t.url,t.href,t.uri,t.website,t.query,t.q,t.query_string,t.search_term,t.searchQuery];for(let e of n){if(typeof e==`string`&&e.trim()){let t=e.trim();return t.length>S7?`${t.slice(0,S7)}…`:t}if(typeof e==`number`&&Number.isFinite(e))return String(e)}return``}function Sbe(e){try{return new URL(e).hostname}catch{return e}}function Cbe(e){if(!e?.trim())return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!t||typeof t!=`object`)return[];let n=t,r=n.details,i=[];if(r&&typeof r==`object`){let e=r.results;Array.isArray(e)&&(i=e)}i.length===0&&Array.isArray(n.results)&&(i=n.results);let a=[],o=new Set;for(let e of i){if(!e||typeof e!=`object`)continue;let t=e,n=t.url;if(typeof n!=`string`||!n.trim())continue;let r=n.trim();if(!/^https?:\/\//i.test(r)||o.has(r))continue;o.add(r);let i=t.title,s=typeof i==`string`&&i.trim().length>0?i.trim():Sbe(r);a.push({url:r,title:s})}return a}function w7(e){let t=e.trim().toLowerCase();return t===`web_search`||t===`brave_search`}function wbe(e){let t=(0,Y.c)(4),{links:n}=e;if(n.length===0)return null;let r;t[0]===n?r=t[1]:(r=n.map(Tbe),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,Z.jsx)(`div`,{className:`mt-1.5 flex min-w-0 flex-wrap gap-2`,children:r}),t[2]=r,t[3]=i),i}function Tbe(e){let{url:t,title:n}=e;return(0,Z.jsxs)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,className:X(`inline-flex max-w-full min-w-0 items-center gap-1 rounded-md bg-accent-soft/40 px-2 py-1 text-xs font-medium text-accent-fg`,`max-w-xs transition-colors hover:bg-accent-soft/60 [overflow-wrap:anywhere]`,AX.focusRingPanel,AX.press),title:t,children:[(0,Z.jsx)(yd,{className:`size-3.5 shrink-0 opacity-70`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:n})]},t)}var Ebe=120,T7=240,Dbe=3,E7=[`readFile`,`editFile`,`writeFile`,`runCommand`,`search`,`fetchUrl`,`openUrl`,`listDir`,`other`];function D7(e){let t=_7(e);return t===`shell`?`runCommand`:t===`list_dir`||t===`ls`?`listDir`:t===`write_file`?`writeFile`:t===`edit_file`?`editFile`:t===`web_fetch`?`fetchUrl`:t===`open_url`?`openUrl`:w7(e)||t.includes(`search`)?`search`:t===`read_file`||t.includes(`read_file`)||t.includes(`file_read`)?`readFile`:`other`}function O7(e){let t=new Map;for(let n of e){if(n.type!==`tool_use`)continue;let e=D7(n.name),r=t.get(e)??{total:0,running:0};r.total+=1,n.status===`running`&&(r.running+=1),t.set(e,r)}return t}function k7(e,t,n){return n[t===1?`${e}_one`:`${e}_other`].replace(/\{\{count\}\}/g,String(t))}function Obe(e,t){switch(e){case`search`:return t.search;case`readFile`:return t.readFile;case`editFile`:return t.editFile;case`writeFile`:return t.writeFile;case`runCommand`:return t.runCommand;case`listDir`:return t.listDir;case`openUrl`:return t.openUrl;case`fetchUrl`:return t.fetchUrl;case`other`:return t.other}}function kbe(e){let t=[];for(let n of E7)e.has(n)&&t.push(n);return t}function Abe(e,t){return e.length===0?``:e.length===1?e[0]:e.length===2?`${e[0]}${t.joinFinal}${e[1]}`:`${e.slice(0,-1).join(t.join)}${t.joinFinal}${e[e.length-1]}`}function A7(e,t){return e.length>t?`${e.slice(0,t)}…`:e}function jbe(e,t,n,r){let i=e.input,a=``;return a=t===`search`?xbe(i).trim():t===`runCommand`?x7(i).trim():t===`readFile`||t===`editFile`||t===`writeFile`?y7(i).trim():t===`fetchUrl`||t===`openUrl`?b7(i).trim():C7(i).trim(),a?A7(`${k7(t,1,n)}${r===`zh`?`:`:`: `}${A7(a,Ebe)}`,T7):null}function Mbe(e,t,n,r){let i=O7(e);if(i.size===0)return null;let a=i.size===1?[...i.keys()][0]:null;if(a&&i.get(a).total===1){let n=e.find(e=>e.type===`tool_use`&&D7(e.name)===a);if(n){let e=jbe(n,a,t,r);if(e)return e}}let o=kbe(i),s=o.slice(0,Dbe),c=o.length-s.length,l=Abe(s.map(e=>k7(e,i.get(e).total,t)),n);return c>0&&(l=`${l}${n.moreSuffix}`),A7(l,T7)}function Nbe(e,t){let n=O7(e),r=[];for(let e of E7){let t=n.get(e);t&&t.running>0&&r.push(e)}return r.length===1?Obe(r[0],t):r.length>1?t.mixed:e.some(e=>e.type===`thinking`&&e.streaming)?t.thinking:n.size>0?t.mixed:null}function j7(e){return e.filter(e=>e.type!==`thinking`||!!e.text?.trim()||!!e.streaming)}function M7(e,t){return(e===1?t.viewSteps_one:t.viewSteps_other).replace(/\{\{count\}\}/g,String(e))}function Pbe(e,t,n,r,i){return Mbe(e,t,n,r)??i}function Fbe(e,t){return Nbe(e,t)}function Ibe(e){return e.startsWith(`@@`)?`hunk`:e.startsWith(`+++`)||e.startsWith(`---`)||e.startsWith(`diff `)||e.startsWith(`index `)?`meta`:e.startsWith(`+`)?`add`:e.startsWith(`-`)?`del`:`context`}function Lbe(e){let t=e.details?.diff;if(typeof t!=`string`||t.length===0)return null;let n=t.split(`
4685
- `),r=[],i=0,a=0;for(let e of n){let t=Ibe(e);t===`add`&&!e.startsWith(`+++`)&&i++,t===`del`&&!e.startsWith(`---`)&&a++,r.push({kind:t,text:e})}return{raw:t,lines:r,added:i,removed:a}}function N7(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function P7(e){if(typeof e==`string`)return e;if(!Array.isArray(e))return``;let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;e.type===`text`&&typeof e.text==`string`&&t.push(e.text)}return t.join(`
4686
- `)}function F7(e){if(e==null)return{details:null,text:``,isStructured:!1};if(typeof e==`object`&&!Array.isArray(e)){let t=e;return`content`in t||`details`in t?{details:N7(t.details),text:P7(t.content),isStructured:!0}:{details:null,text:``,isStructured:!1}}if(typeof e==`string`){let t=e.trim();if(t.startsWith(`{`))try{let e=N7(JSON.parse(t));if(e&&(`content`in e||`details`in e))return{details:N7(e.details),text:P7(e.content),isStructured:!0}}catch{}return{details:null,text:e,isStructured:!1}}return{details:null,text:String(e),isStructured:!1}}var Rbe=`inline-flex max-w-full min-w-0 items-center gap-1 rounded-md bg-accent-soft/40 px-1.5 py-0.5 text-[11px] font-medium text-fg-muted [overflow-wrap:anywhere] dark:bg-accent-soft/25`,zbe=`inline-flex max-w-full min-w-0 items-center break-words rounded-md bg-surface-hover/60 px-1.5 py-0.5 font-mono text-xs text-fg [overflow-wrap:anywhere] dark:bg-surface-hover/35`,Bbe=`max-h-72 w-full min-w-0 max-w-full overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-md bg-surface-hover/60 p-2 font-mono text-xs text-fg-muted [overflow-wrap:anywhere] dark:bg-surface-hover/35`,Vbe=`cursor-pointer select-none text-xs text-fg-subtle underline-offset-2 hover:text-fg-muted group-open:text-fg-muted`;function I7(e){let t=(0,Y.c)(5),{children:n,tone:r}=e,i=r===void 0?`neutral`:r,a=i===`positive`?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:i===`negative`?`bg-red-500/15 text-red-700 dark:text-red-300`:i===`warning`?`bg-amber-500/15 text-amber-700 dark:text-amber-300`:i===`accent`?`bg-accent-soft/70 text-accent-fg dark:bg-accent-soft/50`:``,o;t[0]===a?o=t[1]:(o=X(Rbe,a),t[0]=a,t[1]=o);let s;return t[2]!==n||t[3]!==o?(s=(0,Z.jsx)(`span`,{className:o,children:n}),t[2]=n,t[3]=o,t[4]=s):s=t[4],s}function L7(e){let t=(0,Y.c)(3),{children:n,title:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,Z.jsx)(`code`,{className:zbe,title:r,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}var R7=(0,J.memo)(function(e){let t=(0,Y.c)(11),{text:n,label:r,copiedLabel:i}=e,[a,o]=(0,J.useState)(!1),s;t[0]===n?s=t[1]:(s=async e=>{e.preventDefault(),e.stopPropagation(),await lH(n)&&(o(!0),window.setTimeout(()=>o(!1),1200))},t[0]=n,t[1]=s);let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=X(`inline-flex shrink-0 items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,AX.transition,AX.focusRingPanel),t[2]=c):c=t[2];let l;t[3]!==a||t[4]!==i||t[5]!==r?(l=a?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ml,{className:`size-3`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:i})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(tu,{className:`size-3`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`hidden sm:inline`,children:r})]}),t[3]=a,t[4]=i,t[5]=r,t[6]=l):l=t[6];let u;return t[7]!==r||t[8]!==s||t[9]!==l?(u=(0,Z.jsx)(`button`,{type:`button`,onClick:s,className:c,"aria-label":r,title:r,children:l}),t[7]=r,t[8]=s,t[9]=l,t[10]=u):u=t[10],u});function z7(e){let t=(0,Y.c)(8),{summary:n,children:r,defaultOpen:i}=e,a=i===void 0?!1:i,o;t[0]===n?o=t[1]:(o=(0,Z.jsx)(`summary`,{className:Vbe,children:n}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,Z.jsx)(`div`,{className:`mt-1.5 min-w-0`,children:r}),t[2]=r,t[3]=s);let c;return t[4]!==a||t[5]!==o||t[6]!==s?(c=(0,Z.jsxs)(`details`,{className:`group min-w-0 text-xs`,open:a,children:[o,s]}),t[4]=a,t[5]=o,t[6]=s,t[7]=c):c=t[7],c}function B7(e){let t=(0,Y.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`pre`,{className:Bbe,children:n}),t[0]=n,t[1]=r),r}function V7(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>{let r=t[n];return r==null?``:String(r)})}function H7(e){return e.details??{}}var U7=/\[(\d+)\/(\d+) lines\]\s*$/;function Hbe(e){let t=e.match(U7);if(!t)return null;let n=Number(t[1]),r=Number(t[2]);return!Number.isFinite(n)||!Number.isFinite(r)?null:{shown:n,total:r}}function Ube(e){return e.replace(U7,``).trimEnd()}var Wbe=(0,J.memo)(function(e){let t=(0,Y.c)(32),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=y7(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=F7(n.result),t[2]=n.result,t[3]=o);let s=o.text,c;t[4]===s?c=t[5]:(c=Hbe(s),t[4]=s,t[5]=c);let l=c,u;t[6]===s?u=t[7]:(u=Ube(s),t[6]=s,t[7]=u);let d=u,f;bb0:{if(l){f=l.total;break bb0}if(!d){f=0;break bb0}let e;t[8]===d?e=t[9]:(e=d.split(`
4679
+ `,transparent:!0,depthTest:!1,depthWrite:!1,blending:2}),this.lineSystem=new Bde(i,this.lineMaterial),this.lineSystem.renderOrder=1,e.add(this.lineSystem),this.materials=[this.backgroundMaterial,this.starMaterial,this.lineMaterial]}update(e,t){this.backgroundMaterial.uniforms.time.value=e,this.starMaterial.uniforms.time.value=e,this.lineMaterial.uniforms.time.value=e;for(let n=0;n<Z6;n++){let r=n*3,i=n*2;if(this.starPositions[r]+=this.starVelocities[i]*t*60,this.starPositions[r+1]+=this.starVelocities[i+1]*t*60,this.starCluster[n]>=0){let e=0,t=0,a=0;for(let i=0;i<Z6;i++){if(n===i||this.starCluster[i]!==this.starCluster[n])continue;let o=this.starPositions[i*3]-this.starPositions[r],s=this.starPositions[i*3+1]-this.starPositions[r+1],c=Math.sqrt(o*o+s*s);c>.01&&c<.8&&(e+=o/c*3e-5,t+=s/c*3e-5,a++)}a>0&&(this.starVelocities[i]+=e,this.starVelocities[i+1]+=t,this.starVelocities[i]*=.999,this.starVelocities[i+1]*=.999)}this.starPositions[r]>this.aspect+.2&&(this.starPositions[r]=-this.aspect-.2),this.starPositions[r]<-this.aspect-.2&&(this.starPositions[r]=this.aspect+.2),this.starPositions[r+1]>1.2&&(this.starPositions[r+1]=-1.2),this.starPositions[r+1]<-1.2&&(this.starPositions[r+1]=1.2),this.starBrightness[n]=.3+.5*(.5+.3*Math.sin(e*1.5+this.starPhases[n])+.2*Math.sin(e*2.7+this.starPhases[n]*2))}let n=this.starSystem.geometry.getAttribute(`position`);n.needsUpdate=!0;let r=this.starSystem.geometry.getAttribute(`brightness`);r.needsUpdate=!0,this.connectionThreshold=.2+Math.min(e*.008,.3)+Math.sin(e*.25)*.06,this.connectionThreshold=Math.min(this.connectionThreshold,.6),this.updateConnections()}buildSpatialGrid(){this.spatialGrid.clear();let e=1/this.gridCellSize;for(let t=0;t<Z6;t++){let n=Math.floor(this.starPositions[t*3]*e),r=Math.floor(this.starPositions[t*3+1]*e),i=n*73856093+r*19349663,a=this.spatialGrid.get(i);a?a.push(t):this.spatialGrid.set(i,[t])}}updateConnections(){this.buildSpatialGrid();let e=0,t=this.connectionThreshold*this.connectionThreshold,n=this.connectionThreshold*1.4,r=n*n,i=1/this.gridCellSize,a=new Set;for(let o=0;o<Z6&&e<Q6;o++){let s=o*3,c=this.starPositions[s],l=this.starPositions[s+1],u=Math.floor(c*i),d=Math.floor(l*i),f=this.starCluster[o];for(let i=-1;i<=1&&e<Q6;i++)for(let s=-1;s<=1&&e<Q6;s++){let p=(u+i)*73856093+(d+s)*19349663,m=this.spatialGrid.get(p);if(m)for(let i=0;i<m.length&&e<Q6;i++){let s=m[i];if(s<=o)continue;let u=o*Z6+s;if(a.has(u))continue;a.add(u);let d=s*3,p=c-this.starPositions[d],h=l-this.starPositions[d+1],g=p*p+h*h,_=f>=0&&f===this.starCluster[s];if(g<(_?r:t)){let t=1-Math.sqrt(g)/(_?n:this.connectionThreshold);_&&(t*=1.3),t=Math.min(t,1);let r=e*6;this.linePositions[r]=c,this.linePositions[r+1]=l,this.linePositions[r+2]=0,this.linePositions[r+3]=this.starPositions[d],this.linePositions[r+4]=this.starPositions[d+1],this.linePositions[r+5]=0;let i=e*2;this.lineAlphas[i]=t*this.starBrightness[o],this.lineAlphas[i+1]=t*this.starBrightness[s],e++}}}}let o=this.lineSystem.geometry.getAttribute(`position`);o.needsUpdate=!0;let s=this.lineSystem.geometry.getAttribute(`alpha`);s.needsUpdate=!0,this.lineSystem.geometry.setDrawRange(0,e*2)}resize(e,t,n){this.aspect=n,this.backgroundMaterial.uniforms.resolution.value.set(e,t),this.backgroundMesh.scale.set(n,1,1)}dispose(){this.backgroundMaterial.dispose(),this.starSystem.geometry.dispose(),this.starMaterial.dispose(),this.lineSystem.geometry.dispose(),this.lineMaterial.dispose(),this.scene.remove(this.backgroundMesh),this.scene.remove(this.starSystem),this.scene.remove(this.lineSystem),this.spatialGrid.clear()}},Hme=class{canvas;renderer;camera;clock;animationFrameId=null;currentScene=null;currentAnimation=null;currentPhase=null;currentElapsed=0;outgoingScene=null;outgoingAnimation=null;outgoingElapsed=0;isTransitioning=!1;transitionT=0;transitionSeconds=1.2;disposed=!1;fadeOpacity=0;fadeTarget=0;fadeSpeed=2.5;timeScale=.35;constructor(e){this.canvas=e,this.renderer=new Pme({canvas:e,alpha:!0,antialias:!0,powerPreference:`low-power`}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.renderer.setClearColor(0,0),this.renderer.autoClear=!1;let t=e.clientWidth,n=e.clientHeight;this.camera=new L3(-1,1,1,-1,.1,100),this.camera.position.z=1,this.clock=new vfe(!1),this.resize(t,n)}resize(e,t){if(this.disposed)return;let n=Math.min(window.devicePixelRatio,2);this.renderer.setSize(e,t),this.renderer.setPixelRatio(n);let r=e/t;this.camera.left=-r,this.camera.right=r,this.camera.top=1,this.camera.bottom=-1,this.camera.updateProjectionMatrix(),this.currentAnimation?.resize(e,t,r),this.outgoingAnimation?.resize(e,t,r)}startPhase(e){if(this.disposed||this.currentPhase===e&&this.currentAnimation&&!this.isTransitioning)return;this.isTransitioning&&this.finalizeTransition();let t=this.canvas.clientWidth,n=this.canvas.clientHeight,r=t/n,i=new Ode,a=this.createAnimation(i,e,r);a.resize(t,n,r),!this.currentAnimation||!this.currentScene||!this.currentPhase?(this.currentScene=i,this.currentAnimation=a,this.currentPhase=e,this.currentElapsed=0):(this.outgoingScene=this.currentScene,this.outgoingAnimation=this.currentAnimation,this.outgoingElapsed=this.currentElapsed,this.currentScene=i,this.currentAnimation=a,this.currentPhase=e,this.currentElapsed=0,this.isTransitioning=!0,this.transitionT=0),this.fadeTarget=1,this.clock.start(),this.animationFrameId||this.tick()}fadeOut(){this.fadeTarget=0}get isFullyFadedOut(){return this.fadeOpacity<=.001&&this.fadeTarget===0}tick=()=>{if(this.disposed)return;let e=this.clock.getDelta()*this.timeScale;if(this.fadeOpacity<this.fadeTarget?this.fadeOpacity=Math.min(this.fadeOpacity+e*this.fadeSpeed,this.fadeTarget):this.fadeOpacity>this.fadeTarget&&(this.fadeOpacity=Math.max(this.fadeOpacity-e*this.fadeSpeed,this.fadeTarget)),this.fadeOpacity<=.001&&this.fadeTarget===0){this.stopAllAnimations(),this.animationFrameId=null;return}this.outgoingAnimation&&this.outgoingScene&&this.isTransitioning&&(this.outgoingElapsed+=e,this.outgoingAnimation.update(this.outgoingElapsed,e)),this.currentAnimation&&this.currentScene&&(this.currentElapsed+=e,this.currentAnimation.update(this.currentElapsed,e));let t=1;if(this.isTransitioning){this.transitionT=Math.min(1,this.transitionT+e/this.transitionSeconds);let n=this.transitionT;t=n*n*(3-2*n),this.transitionT>=1&&(this.finalizeTransition(),t=1)}let n=this.isTransitioning?1-t:0;this.renderer.clear(),this.outgoingScene&&this.outgoingAnimation&&n>.001&&(this.setMaterialsOpacity(this.outgoingAnimation,this.fadeOpacity*n),this.renderer.render(this.outgoingScene,this.camera)),this.currentScene&&this.currentAnimation&&(this.setMaterialsOpacity(this.currentAnimation,this.fadeOpacity*t),this.renderer.render(this.currentScene,this.camera)),this.animationFrameId=requestAnimationFrame(this.tick)};createAnimation(e,t,n){switch(t){case`light`:return new Lme(e,n);case`deep`:return new zme(e,n);case`rem`:return new Vme(e,n)}}setMaterialsOpacity(e,t){for(let n of e.materials)n.uniforms.globalOpacity.value=t}finalizeTransition(){this.isTransitioning=!1,this.transitionT=1,this.outgoingAnimation&&this.outgoingAnimation.dispose(),this.outgoingScene=null,this.outgoingAnimation=null,this.outgoingElapsed=0}stopAllAnimations(){this.currentAnimation&&this.currentAnimation.dispose(),this.outgoingAnimation&&this.outgoingAnimation.dispose(),this.currentScene=null,this.currentAnimation=null,this.currentPhase=null,this.currentElapsed=0,this.outgoingScene=null,this.outgoingAnimation=null,this.outgoingElapsed=0,this.isTransitioning=!1,this.transitionT=0}dispose(){this.disposed=!0,this.animationFrameId&&=(cancelAnimationFrame(this.animationFrameId),null),this.stopAllAnimations(),this.renderer.dispose()}},$6=new Set([`light`,`deep`,`rem`]),Ume=3e3;function Wme(){let e=(0,Y.c)(11),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={status:`idle`},e[0]=t):t=e[0];let[n,r]=(0,J.useState)(t),i=(0,J.useRef)(0),a=(0,J.useRef)(null),o;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{a.current&&=(clearTimeout(a.current),null)},e[1]=o):o=e[1];let s=o,c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>{s(),i.current=Date.now(),r({status:`running`,phase:e})},e[2]=c):c=e[2];let l=c,u;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=e=>{s(),r({status:`fading-out`,phase:e}),a.current=setTimeout(()=>{r({status:`idle`})},1500)},e[3]=u):u=e[3];let d=u,f;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{s(),r(Gme),a.current=setTimeout(()=>{r({status:`idle`})},800)},e[4]=f):f=e[4];let p=f,m,h;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{let e=e=>{let t=e.detail,n=typeof t==`object`&&t&&typeof t.phase==`string`?t.phase:typeof t==`string`?t:null;n&&$6.has(n)&&l(n)},t=e=>{let t=e.detail,n=typeof t==`object`&&t&&typeof t.phase==`string`?t.phase:null;if(!n||!$6.has(n))return;let r=Date.now()-i.current,o=Math.max(0,Ume-r);s(),a.current=setTimeout(()=>{d(n)},o)};return window.addEventListener(`dreaming-phase-start`,e),window.addEventListener(`dreaming-phase-end`,t),()=>{window.removeEventListener(`dreaming-phase-start`,e),window.removeEventListener(`dreaming-phase-end`,t),s()}},h=[l,d,s],e[5]=m,e[6]=h):(m=e[5],h=e[6]),(0,J.useEffect)(m,h);let g,_;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>s,_=[s],e[7]=g,e[8]=_):(g=e[7],_=e[8]),(0,J.useEffect)(g,_);let v;return e[9]===n?v=e[10]:(v={state:n,triggerPhase:l,dismiss:p},e[9]=n,e[10]=v),v}function Gme(e){return e.status===`idle`?e:{status:`fading-out`,phase:e.phase}}var e8={light:`💤 Light Sleep — scanning memories…`,deep:`🌙 Deep Sleep — promoting memories…`,rem:`🌈 REM Sleep — discovering patterns…`};function Kme(){return typeof window<`u`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function qme(){let e=(0,Y.c)(28),t=(0,J.useRef)(null),n=(0,J.useRef)(null),r=(0,J.useRef)(null),{state:i,dismiss:a}=Wme(),o,s;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{let e=t.current;if(!e)return;let r=new Hme(e);return n.current=r,()=>{r.dispose(),n.current=null}},s=[],e[0]=o,e[1]=s):(o=e[0],s=e[1]),(0,J.useEffect)(o,s);let c,l;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=()=>{let e=r.current;!e||!n.current||n.current.resize(e.clientWidth,e.clientHeight)};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},l=[],e[2]=c,e[3]=l):(c=e[2],l=e[3]),(0,J.useEffect)(c,l);let u;e[4]!==i.phase||e[5]!==i.status?(u=()=>{let e=n.current;if(e)if(i.status===`running`){if(Kme())return;e.startPhase(i.phase)}else i.status===`fading-out`&&e.fadeOut()},e[4]=i.phase,e[5]=i.status,e[6]=u):u=e[6];let d;e[7]===i?d=e[8]:(d=[i],e[7]=i,e[8]=d),(0,J.useEffect)(u,d);let f,p;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{let e=r.current;!e||!n.current||n.current.resize(e.clientWidth,e.clientHeight)},p=[],e[9]=f,e[10]=p):(f=e[9],p=e[10]),(0,J.useEffect)(f,p);let m=i.status!==`idle`,h=i.status===`idle`?null:i.phase,g=i.status===`fading-out`,_;e[11]===a?_=e[12]:(_=()=>{a()},e[11]=a,e[12]=_);let v=_;if(!m&&!g){let n;return e[13]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`div`,{ref:r,className:`pointer-events-none fixed inset-0 z-[90] opacity-0`,"aria-hidden":!0,children:(0,Z.jsx)(`canvas`,{ref:t,className:`size-full`})}),e[13]=n):n=e[13],n}let y=g?`dreaming-overlay-exit pointer-events-none`:`dreaming-overlay-enter`,b;e[14]===y?b=e[15]:(b=X(`fixed inset-0 z-[90] bg-[#1c1c1e]/70 transition-opacity`,y),e[14]=y,e[15]=b);let x=h?e8[h]:void 0,S;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(`canvas`,{ref:t,className:`pointer-events-none size-full`}),e[16]=S):S=e[16];let C;e[17]===h?C=e[18]:(C=h?(0,Z.jsxs)(`div`,{className:X(`flex items-center gap-2 rounded-full border px-4 py-2 text-sm font-medium shadow-elevated backdrop-blur-sm`,`dreaming-pill-enter`,h===`light`&&`border-emerald-400/30 bg-emerald-950/60 text-emerald-300`,h===`deep`&&`border-indigo-400/30 bg-indigo-950/60 text-indigo-300`,h===`rem`&&`border-purple-400/30 bg-purple-950/60 text-purple-300`),children:[(0,Z.jsx)(`span`,{className:`dreaming-pulse-dot`}),(0,Z.jsx)(`span`,{children:e8[h]})]}):null,e[17]=h,e[18]=C);let w;e[19]===v?w=e[20]:(w=(0,Z.jsx)(`button`,{type:`button`,onClick:v,className:`rounded-full border border-edge-subtle bg-surface-panel/80 px-3 py-1.5 text-xs text-fg-muted shadow-elevated backdrop-blur-sm transition-colors hover:bg-surface-hover hover:text-fg`,"aria-label":`Dismiss dreaming animation`,children:`✕`}),e[19]=v,e[20]=w);let T;e[21]!==C||e[22]!==w?(T=(0,Z.jsxs)(`div`,{className:`pointer-events-auto absolute bottom-6 left-1/2 flex -translate-x-1/2 items-center gap-3`,children:[C,w]}),e[21]=C,e[22]=w,e[23]=T):T=e[23];let E;return e[24]!==b||e[25]!==x||e[26]!==T?(E=(0,Z.jsxs)(`div`,{ref:r,className:b,role:`status`,"aria-live":`polite`,"aria-label":x,children:[S,T]}),e[24]=b,e[25]=x,e[26]=T,e[27]=E):E=e[27],E}var Jme=new Intl.DateTimeFormat(`zh-CN`,{dateStyle:`medium`,timeStyle:`short`}),Yme=new Intl.DateTimeFormat(`en`,{dateStyle:`medium`,timeStyle:`short`});function Xme(e,t){return(t===`zh`?Jme:Yme).format(new Date(e))}function Zme(e){let t=(0,Y.c)(138),{filePath:n,onClose:r,sessionKey:i,agentId:a}=e,o=d(the),s;t[0]===o?s=t[1]:(s=m(o),t[0]=o,t[1]=s);let c=s,l=ve(ehe),u;t[2]!==a||t[3]!==n||t[4]!==i?(u={filePath:n,sessionKey:i,agentId:a},t[2]=a,t[3]=n,t[4]=i,t[5]=u):u=t[5];let f=EU(u),{rootRef:p,active:h,enter:g,exit:_}=oU(),{dialogOpen:v,loading:y,result:b,error:x,createShareLink:S,handleOpenChange:C}=XZ(),[w,T]=(0,J.useState)(!1),E;t[6]===n?E=t[7]:(E=n?dU(n):``,t[6]=n,t[7]=E);let D=E,O;t[8]===n?O=t[9]:(O=n?fU(n):``,t[8]=n,t[9]=O);let k=O,A=D===`.md`,j=D===`.html`||D===`.htm`,M;t[10]!==n||t[11]!==c.clipboard.copyFailed||t[12]!==c.workspace.pathCopied?(M=async()=>{if(n){if(await lH(n)){T(!0),window.setTimeout(()=>T(!1),2e3),fH(`success`,c.workspace.pathCopied,void 0,{duration:2e3});return}fH(`warning`,c.clipboard.copyFailed,void 0,{duration:4e3})}},t[10]=n,t[11]=c.clipboard.copyFailed,t[12]=c.workspace.pathCopied,t[13]=M):M=t[13];let N=M,P;t[14]!==a||t[15]!==S||t[16]!==n||t[17]!==i?(P=()=>{n&&S({path:n,...i==null?a?.trim()?{agentId:a.trim()}:{}:{sessionKey:i}})},t[14]=a,t[15]=S,t[16]=n,t[17]=i,t[18]=P):P=t[18];let F=P,I=!!(n&&!f.loading&&!f.loadError),L;t[19]!==_||t[20]!==r?(L=()=>{_(),r()},t[19]=_,t[20]=r,t[21]=L):L=t[21];let R=L;if(!n)return null;let z;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(z=X(`flex shrink-0 items-start gap-2 border-b border-edge px-4 py-2 dark:border-edge`,dj),t[22]=z):z=t[22];let B;t[23]===k?B=t[24]:(B=(0,Z.jsx)(`h2`,{className:`truncate text-base font-semibold leading-tight tracking-tight text-fg`,title:k,children:k}),t[23]=k,t[24]=B);let V;t[25]!==o||t[26]!==c.workspace.lastModified||t[27]!==f.loading||t[28]!==f.mtimeMs?(V=!f.loading&&f.mtimeMs!=null?(0,Z.jsxs)(`p`,{suppressHydrationWarning:!0,className:`mt-0.5 truncate text-xs leading-tight text-fg-muted`,title:new Date(f.mtimeMs).toISOString(),children:[c.workspace.lastModified,`: `,Xme(f.mtimeMs,o)]}):null,t[25]=o,t[26]=c.workspace.lastModified,t[27]=f.loading,t[28]=f.mtimeMs,t[29]=V):V=t[29];let H;t[30]!==V||t[31]!==B?(H=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[B,V]}),t[30]=V,t[31]=B,t[32]=H):H=t[32];let U;t[33]!==j||t[34]!==A||t[35]!==c.workspace.saved||t[36]!==c.workspace.saving||t[37]!==f.htmlCodeMode||t[38]!==f.saveStatus?(U=(A||j&&f.htmlCodeMode)&&f.saveStatus!==`idle`?(0,Z.jsx)(`span`,{className:`shrink-0 text-xs leading-tight text-fg-muted`,children:f.saveStatus===`saving`?c.workspace.saving:c.workspace.saved}):null,t[33]=j,t[34]=A,t[35]=c.workspace.saved,t[36]=c.workspace.saving,t[37]=f.htmlCodeMode,t[38]=f.saveStatus,t[39]=U):U=t[39];let W;t[40]!==j||t[41]!==A||t[42]!==c.workspace.edit||t[43]!==c.workspace.preview||t[44]!==c.workspace.viewing||t[45]!==f?(W=A?(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,title:f.markdownEditMode?c.workspace.viewing:c.workspace.edit,"aria-label":f.markdownEditMode?c.workspace.viewing:c.workspace.edit,onClick:()=>f.setMarkdownEditMode($me),children:f.markdownEditMode?(0,Z.jsx)(Cd,{className:`size-4`}):(0,Z.jsx)(H_,{className:`size-4`})}):j?(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,title:f.htmlCodeMode?c.workspace.preview:c.workspace.edit,"aria-label":f.htmlCodeMode?c.workspace.preview:c.workspace.edit,onClick:()=>f.setHtmlCodeMode(Qme),children:f.htmlCodeMode?(0,Z.jsx)(Cd,{className:`size-4`}):(0,Z.jsx)(H_,{className:`size-4`})}):null,t[40]=j,t[41]=A,t[42]=c.workspace.edit,t[43]=c.workspace.preview,t[44]=c.workspace.viewing,t[45]=f,t[46]=W):W=t[46];let G;t[47]!==h||t[48]!==I||t[49]!==g||t[50]!==_||t[51]!==c.chat?(G=I?(0,Z.jsx)(`button`,{type:`button`,className:X(`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,AX.focusRingPanel),title:h?c.chat.attachmentPreviewExitFullscreen:c.chat.attachmentPreviewFullscreen,"aria-label":h?c.chat.attachmentPreviewExitFullscreen:c.chat.attachmentPreviewFullscreen,onClick:()=>void(h?_():g()),children:h?(0,Z.jsx)(Ng,{className:`size-4`,strokeWidth:1.75}):(0,Z.jsx)(Dg,{className:`size-4`,strokeWidth:1.75})}):null,t[47]=h,t[48]=I,t[49]=g,t[50]=_,t[51]=c.chat,t[52]=G):G=t[52];let ee;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(ee=X(`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,AX.focusRingPanel),t[53]=ee):ee=t[53];let K;t[54]===N?K=t[55]:(K=()=>void N(),t[54]=N,t[55]=K);let te;t[56]===w?te=t[57]:(te=w?(0,Z.jsx)(Ml,{className:`size-4`}):(0,Z.jsx)(tu,{className:`size-4`}),t[56]=w,t[57]=te);let ne;t[58]!==c.workspace.copyPath||t[59]!==K||t[60]!==te?(ne=(0,Z.jsx)(`button`,{type:`button`,className:ee,title:c.workspace.copyPath,"aria-label":c.workspace.copyPath,onClick:K,children:te}),t[58]=c.workspace.copyPath,t[59]=K,t[60]=te,t[61]=ne):ne=t[61];let re;t[62]!==c.workspace.revealInFolder||t[63]!==f?(re=f.canRevealInFolder?(0,Z.jsx)(`button`,{type:`button`,className:X(`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,AX.focusRingPanel),title:c.workspace.revealInFolder,"aria-label":c.workspace.revealInFolder,onClick:()=>void f.onRevealInFolder(),children:(0,Z.jsx)(Sp,{className:`size-4`})}):null,t[62]=c.workspace.revealInFolder,t[63]=f,t[64]=re):re=t[64];let ie;t[65]===y?ie=t[66]:(ie=y?(0,Z.jsx)(Cg,{className:`size-4 animate-spin`}):(0,Z.jsx)(bg,{className:`size-4`}),t[65]=y,t[66]=ie);let ae;t[67]!==F||t[68]!==y||t[69]!==c.workspace.shareLink||t[70]!==ie?(ae=(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:opacity-50`,title:c.workspace.shareLink,"aria-label":c.workspace.shareLink,onClick:F,disabled:y,children:ie}),t[67]=F,t[68]=y,t[69]=c.workspace.shareLink,t[70]=ie,t[71]=ae):ae=t[71];let oe;t[72]===f?oe=t[73]:(oe=()=>void f.onDownload(),t[72]=f,t[73]=oe);let se=!f.canDownload,q;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,Z.jsx)(Uu,{className:`size-4`}),t[74]=q):q=t[74];let ce;t[75]!==c.workspace.download||t[76]!==oe||t[77]!==se?(ce=(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:opacity-50`,title:c.workspace.download,"aria-label":c.workspace.download,onClick:oe,disabled:se,children:q}),t[75]=c.workspace.download,t[76]=oe,t[77]=se,t[78]=ce):ce=t[78];let le;t[79]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,Z.jsx)(oO,{className:`size-4`,strokeWidth:1.75}),t[79]=le):le=t[79];let ue;t[80]!==R||t[81]!==c.workspace.close?(ue=(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,title:c.workspace.close,"aria-label":c.workspace.close,onClick:R,children:le}),t[80]=R,t[81]=c.workspace.close,t[82]=ue):ue=t[82];let de;t[83]!==U||t[84]!==W||t[85]!==G||t[86]!==ne||t[87]!==re||t[88]!==ae||t[89]!==ce||t[90]!==ue?(de=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pt-0.5`,children:[U,W,G,ne,re,ae,ce,ue]}),t[83]=U,t[84]=W,t[85]=G,t[86]=ne,t[87]=re,t[88]=ae,t[89]=ce,t[90]=ue,t[91]=de):de=t[91];let fe;t[92]!==H||t[93]!==de?(fe=(0,Z.jsxs)(`div`,{className:z,children:[H,de]}),t[92]=H,t[93]=de,t[94]=fe):fe=t[94];let pe=l===`dark`,me;t[95]!==f.htmlCodeMode||t[96]!==f.markdownEditMode||t[97]!==f.onHtmlChange||t[98]!==f.onSaveMarkdown||t[99]!==pe?(me={markdownEditMode:f.markdownEditMode,onSaveMarkdown:f.onSaveMarkdown,htmlCodeMode:f.htmlCodeMode,onHtmlChange:f.onHtmlChange,isDark:pe},t[95]=f.htmlCodeMode,t[96]=f.markdownEditMode,t[97]=f.onHtmlChange,t[98]=f.onSaveMarkdown,t[99]=pe,t[100]=me):me=t[100];let he;t[101]===f?he=t[102]:(he=()=>void f.onDownload(),t[101]=f,t[102]=he);let ge;t[103]===f?ge=t[104]:(ge=()=>void f.onOpenWithSystemApp(),t[103]=f,t[104]=ge);let _e;t[105]!==f.canDownload||t[106]!==f.canOpenWithSystemApp||t[107]!==he||t[108]!==ge?(_e={onDownload:he,canDownload:f.canDownload,onOpenWithSystemApp:ge,canOpenWithSystemApp:f.canOpenWithSystemApp},t[105]=f.canDownload,t[106]=f.canOpenWithSystemApp,t[107]=he,t[108]=ge,t[109]=_e):_e=t[109];let ye;t[110]!==n||t[111]!==o||t[112]!==k||t[113]!==l||t[114]!==f.binaryBuffer||t[115]!==f.loadError||t[116]!==f.loading||t[117]!==f.pptxError||t[118]!==f.pptxText||t[119]!==f.pptxTruncated||t[120]!==f.previewKind||t[121]!==f.textContent||t[122]!==me||t[123]!==_e?(ye=(0,Z.jsx)(RX,{context:`workspace`,language:o,resolvedTheme:l,fileKey:n,fileName:k,loading:f.loading,loadError:f.loadError,previewKind:f.previewKind,textContent:f.textContent,binaryBuffer:f.binaryBuffer,pptxText:f.pptxText,pptxTruncated:f.pptxTruncated,pptxError:f.pptxError,workspaceEditing:me,actions:_e}),t[110]=n,t[111]=o,t[112]=k,t[113]=l,t[114]=f.binaryBuffer,t[115]=f.loadError,t[116]=f.loading,t[117]=f.pptxError,t[118]=f.pptxText,t[119]=f.pptxTruncated,t[120]=f.previewKind,t[121]=f.textContent,t[122]=me,t[123]=_e,t[124]=ye):ye=t[124];let be;t[125]!==p||t[126]!==fe||t[127]!==ye?(be=(0,Z.jsxs)(`div`,{ref:p,className:`flex h-full min-h-0 flex-col bg-surface-panel`,children:[fe,ye]}),t[125]=p,t[126]=fe,t[127]=ye,t[128]=be):be=t[128];let xe;t[129]!==v||t[130]!==x||t[131]!==C||t[132]!==y||t[133]!==b?(xe=(0,Z.jsx)(UZ,{open:v,onOpenChange:C,loading:y,error:x,result:b}),t[129]=v,t[130]=x,t[131]=C,t[132]=y,t[133]=b,t[134]=xe):xe=t[134];let Se;return t[135]!==be||t[136]!==xe?(Se=(0,Z.jsxs)(Z.Fragment,{children:[be,xe]}),t[135]=be,t[136]=xe,t[137]=Se):Se=t[137],Se}function Qme(e){return!e}function $me(e){return!e}function ehe(e){return e.resolved}function the(e){return e.language}function nhe(e,t){let n=globalThis.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)}function rhe(e){return globalThis.matchMedia(e).matches}function t8(e,t){let n=(0,Y.c)(5),r=t===void 0?!1:t,i,a;n[0]===e?(i=n[1],a=n[2]):(i=t=>nhe(e,t),a=()=>rhe(e),n[0]=e,n[1]=i,n[2]=a);let o;return n[3]===r?o=n[4]:(o=()=>r,n[3]=r,n[4]=o),(0,J.useSyncExternalStore)(i,a,o)}var ihe=`(min-width: 768px)`,ahe=`(min-width: 1024px)`;function ohe(){let e=(0,Y.c)(6),t=Cj(uhe),n=Cj(lhe),r=cQ(che),i=cQ(she),a=t8(ihe,!0),o=t8(ahe,!0),s;bb0:{if(!a){let t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={top:`0`,left:`0`,right:`0`,bottom:`0`},e[0]=t):t=e[0],s=t;break bb0}let c=r?`${i}px`:`0`;if(!o){let t;e[1]===c?t=e[2]:(t={top:`0`,left:`0`,right:c,bottom:`0`},e[1]=c,e[2]=t),s=t;break bb0}let l=t?`4.5rem`:`${n}px`,u;e[3]!==l||e[4]!==c?(u={top:`0`,left:l,right:c,bottom:`0`},e[3]=l,e[4]=c,e[5]=u):u=e[5],s=u}return s}function she(e){return e.widthPx}function che(e){return e.open}function lhe(e){return e.expandedWidthPx}function uhe(e){return e.collapsed}var dhe=(0,J.memo)(function(){let e=(0,Y.c)(41),{pathname:t}=Yr(),{sessionKey:n}=ni(),r;e[0]!==t||e[1]!==n?(r=t.startsWith(`/chat`)&&n?decodeURIComponent(n):void 0,e[0]=t,e[1]=n,e[2]=r):r=e[2];let i=r,a=lQ(fhe),o=lQ(phe),s=eQ(mhe),c=ohe(),l=!!a,u,d;e[3]!==t||e[4]!==o?(u=()=>{t.startsWith(`/chat`)||o(null)},d=[t,o],e[3]=t,e[4]=o,e[5]=u,e[6]=d):(u=e[5],d=e[6]),(0,J.useEffect)(u,d);let f;e[7]!==c.bottom||e[8]!==c.left||e[9]!==c.right||e[10]!==c.top?(f={top:c.top,left:c.left,right:c.right,bottom:c.bottom},e[7]=c.bottom,e[8]=c.left,e[9]=c.right,e[10]=c.top,e[11]=f):f=e[11];let p=f,m;e[12]===o?m=e[13]:(m=e=>!e&&o(null),e[12]=o,e[13]=m);let h;e[14]===p?h=e[15]:(h=(0,Z.jsx)(ie,{className:`xopc-dialog-overlay fixed z-[65] bg-scrim`,style:p}),e[14]=p,e[15]=h);let g;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(g=X(`xopc-dialog-content-pane fixed z-[66] flex min-h-0 flex-col overflow-hidden border border-edge bg-surface-panel shadow-popover outline-none`,`dark:border-edge`,dj),e[16]=g):g=e[16];let _;e[17]===a?_=e[18]:(_=a?fU(a):`Preview`,e[17]=a,e[18]=_);let v;e[19]===_?v=e[20]:(v=(0,Z.jsx)(ue,{className:`sr-only`,children:_}),e[19]=_,e[20]=v);let y;e[21]===s?y=e[22]:(y=s.trim()||void 0,e[21]=s,e[22]=y);let b;e[23]===o?b=e[24]:(b=()=>o(null),e[23]=o,e[24]=b);let x;e[25]!==i||e[26]!==a||e[27]!==b||e[28]!==y?(x=(0,Z.jsx)(Zme,{filePath:a,sessionKey:i,agentId:y,onClose:b}),e[25]=i,e[26]=a,e[27]=b,e[28]=y,e[29]=x):x=e[29];let S;e[30]!==p||e[31]!==x||e[32]!==v?(S=(0,Z.jsxs)(se,{className:g,style:p,"aria-describedby":void 0,children:[v,x]}),e[30]=p,e[31]=x,e[32]=v,e[33]=S):S=e[33];let C;e[34]!==S||e[35]!==h?(C=(0,Z.jsxs)(G,{children:[h,S]}),e[34]=S,e[35]=h,e[36]=C):C=e[36];let w;return e[37]!==l||e[38]!==C||e[39]!==m?(w=(0,Z.jsx)(q,{open:l,onOpenChange:m,children:C}),e[37]=l,e[38]=C,e[39]=m,e[40]=w):w=e[40],w});function fhe(e){return e.path}function phe(e){return e.setPath}function mhe(e){return e.agentId}async function n8(){let e=await FR(_(`/api/models`));if(!e.ok)throw Error(`Models: HTTP ${e.status}`);return(await e.json()).payload?.models??[]}var r8=null,i8=0,a8=null,o8=6e4,s8=`gateway-configured-models`;async function hhe(){r8=null,i8=0;let{mutate:e}=await D(async()=>{let{mutate:e}=await import(`./vendor-swr-BIWyz7Rc.js`).then(e=>e.r);return{mutate:e}},__vite__mapDeps([5,1,3]));await e(s8)}async function c8(e=!1){if(!e&&r8&&Date.now()<i8)return r8;if(e){let e=await n8();return r8=e,i8=Date.now()+o8,e}return a8||(a8=n8().then(e=>(r8=e,i8=Date.now()+o8,e)).finally(()=>{a8=null}),a8)}function ghe(e){let t=(0,Y.c)(9),{models:n,selectedId:r,onSelectedChange:i}=e;if(n.length===0)return null;let a;if(t[0]!==n||t[1]!==i||t[2]!==r){let e;t[4]!==i||t[5]!==r?(e=e=>{let t=r===e.id;return(0,Z.jsxs)(`label`,{className:X(`flex cursor-pointer items-start gap-3 rounded-xl border border-edge px-3 py-2.5 transition-colors`,t?`border-accent bg-accent-soft`:`hover:bg-surface-hover`),children:[(0,Z.jsx)(`input`,{type:`radio`,name:`onboarding-model`,className:`mt-1`,checked:t,onChange:()=>i(e.id),"aria-label":e.name||e.id}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.name||e.id}),(0,Z.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:e.id})]})]},e.id)},t[4]=i,t[5]=r,t[6]=e):e=t[6],a=n.map(e),t[0]=n,t[1]=i,t[2]=r,t[3]=a}else a=t[3];let o;return t[7]===a?o=t[8]:(o=(0,Z.jsx)(`div`,{className:`flex max-h-[min(50vh,22rem)] flex-col gap-2 overflow-y-auto pr-1`,role:`radiogroup`,children:a}),t[7]=a,t[8]=o),o}function l8(e){let t=(0,Y.c)(10),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=X(`shrink-0`,r),t[4]=r,t[5]=a);let o;return t[6]!==n||t[7]!==i||t[8]!==a?(o=(0,Z.jsx)(`svg`,{viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,className:a,...i,children:n}),t[6]=n,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function _he(e){let t=(0,Y.c)(7),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]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`path`,{fill:`#4D6BFE`,d:`M12.63 5.43c-.377-.222-.676-.093-.676.28v1.63c0 .55.18 1.8.52 1.52l.026.03 3.99 2.28 6.43 2.14 1.48-.085 3.13-.284 4.99-1.86.47.23.96.32 1.78.39.63.05 1.23-.031 1.70-.129.73-.155.68-.836.41-.961-2.15-1.00-1.68-.595-2.11-.926 1.09-1.29 2.76-3.59 3.28-6.73.05-.346.11-.834.10-1.11-.004-.171.03-.238.23-.257a4.2 4.2 0 0 0 1.54-.475c1.39-.763 1.96-2.01 2.09-3.51.02-.23-.004-.467-.247-.588M11.58 18.16c-2.08-1.64-3.10-2.18-3.52-2.16-.39.02-.32.47-.234.76.09.28.21.48.37.74.11.17.19.42-.113.60-.673.41-1.84-.14-1.89-.168-1.36-.801-2.5-1.86-3.30-3.30-.775-1.39-1.22-2.88-1.29-4.48-.02-.385.09-.522.47-.592a4.7 4.7 0 0 1 1.53-.038c2.13.31 3.94 1.26 5.46 2.77.87.86 1.52 1.88 2.20 2.89.72 1.06 1.49 2.08 2.48 2.91.35.29.63.51.89.67-.802.09-2.14.10-3.05-.615zm1.00-6.44a.306.30 0 0 1 .415-.287.3.3 0 0 1 .113.07.3.3 0 0 1 .086.21c0 .17-.136.30-.308.30a.303.30 0 0 1-.306-.307m3.11 1.59c-.2.08-.4.15-.591.16a1.25 1.25 0 0 1-.798-.254c-.274-.23-.47-.358-.551-.758a1.7 1.7 0 0 1 .015-.588c.07-.327-.007-.537-.238-.727-.188-.156-.426-.199-.689-.199a.6.6 0 0 1-.254-.078.25.25 0 0 1-.114-.358 1 1 0 0 1 .192-.21c.356-.202.76-.136 1.14.02.35.14.61.41 1.0.78.39.45.46.58.68.92.17.26.33.54.44.85.6.19-.02.35-.25.45`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,Z.jsx)(l8,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function vhe(e){let t=(0,Y.c)(7),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]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`path`,{fill:`currentColor`,d:`M11.43 3.92a.86.86 0 1 0-1.71 0v14.23a1.99 1.99 0 0 1-3.99 0V9.02a.86.86 0 1 0-1.71 0v3.87a1.99 1.99 0 0 1-3.99 0V11.49a.57.57 0 0 1 1.13 0v1.40a.86.86 0 0 0 1.71 0V9.02a1.99 1.99 0 0 1 3.99 0v9.13a.86.86 0 0 0 1.71 0V3.92a1.99 1.99 0 1 1 3.99 0v11.78a.57.57 0 1 1-1.13 0zm10.57 3.10a2 2 0 0 0-1.99 1.99v7.63a.86.86 0 0 1-1.71 0V3.92a1.99 1.99 0 0 0-3.99 0v16.16a.86.86 0 0 1-1.71 0V18.08a.57.57 0 1 0-1.13 0v2a1.99 1.99 0 0 0 3.99 0V3.92a.86.86 0 0 1 1.71 0v12.73a1.99 1.99 0 0 0 3.99 0V9.02a.86.86 0 1 1 1.72 0v6.68a.57.57 0 0 0 1.13 0V9.02a2 2 0 0 0-1.99-1.99`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,Z.jsx)(l8,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function u8(e){let t=(0,Y.c)(7),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]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`path`,{fill:`#1A1A2E`,d:`m1.05 16.91 9.53 2.55a21 20.98 0 0 0 .06 2.03l5.95 1.59a12 11.99 0 0 1-15.55-6.17m-1.02-5.79 11.35 3.03a21 20.98 0 0 0-.469 2.01l10.81 2.89a12 11.99 0 0 1-1.84 2.00L.658 15.91a12 11.99 0 0 1-.625-4.79m1.59-5.14L13.57 9.17a21 20.98 0 0 0-1.01 1.87l11.29 3.02a21 20.98 0 0 1-.67 2.36l-11.55-3.08L.125 10.26a12 11.99 0 0 1 1.49-4.28ZM6.06 1.58l11.28 3.01a21 20.98 0 0 0-1.68 1.71l7.82 2.09a21 20.98 0 0 1 .513 2.66L2.10 5.21a12 11.99 0 0 1 3.96-3.63M21.68 4.86 7.22 1.00A12 11.99 0 0 1 21.68 4.86`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,Z.jsx)(l8,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function yhe(e){let t=(0,Y.c)(7),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]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`path`,{fill:`currentColor`,d:`M22.28 9.82a5.98 5.98 0 0 0-.516-4.91 6.04 6.04 0 0 0-6.51-2.9A6.06 6.06 0 0 0 4.98 4.18a5.98 5.98 0 0 0-3.99 2.9 6.04 6.04 0 0 0 .743 7.09 5.98 5.98 0 0 0 .511 4.91 6.05 6.05 0 0 0 6.51 2.9A5.98 5.98 0 0 0 13.26 24a6.05 6.05 0 0 0 5.77-4.20 5.98 5.98 0 0 0 3.99-2.9 6.05 6.05 0 0 0-.748-7.07zm-9.02 12.60a4.47 4.47 0 0 1-2.87-1.04l.142-.08 4.77-2.75a.795.79 0 0 0 .393-.681v-6.73l2.02 1.16a.071.07 0 0 1 .038.05v5.58a4.50 4.50 0 0 1-4.49 4.49zm-9.66-4.12a4.47 4.47 0 0 1-.535-3.01l.142.08 4.78 2.75a.771.77 0 0 0 .781 0l5.84-3.36v2.33a.08.08 0 0 1-.033.06L9.74 19.95a4.49 4.49 0 0 1-6.14-1.64zM2.34 7.89a4.48 4.48 0 0 1 2.36-1.97V11.6a.766.76 0 0 0 .388.67l5.81 3.35-2.02 1.16a.076.07 0 0 1-.071 0l-4.83-2.78A4.50 4.50 0 0 1 2.34 7.87zm16.59 3.85L13.10 8.36 15.11 7.2a.076.07 0 0 1 .071 0l4.83 2.79a4.49 4.49 0 0 1-.677 8.10v-5.67a.79.79 0 0 0-.407-.667zm2.01-3.02-.142-.085-4.77-2.78a.776.77 0 0 0-.785 0L9.40 9.23V6.89a.066.06 0 0 1 .028-.062l4.83-2.78a4.49 4.49 0 0 1 6.68 4.66zM8.30 12.86l-2.02-1.16a.08.08 0 0 1-.038-.057V6.07a4.49 4.49 0 0 1 7.37-3.45l-.142.08L8.70 5.45a.795.79 0 0 0-.393.68zm1.09-2.36 2.60-1.5 2.60 1.5v2.99l-2.59 1.5-2.60-1.5Z`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,Z.jsx)(l8,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function bhe(e){let t=(0,Y.c)(7),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]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`path`,{fill:`#D4A27F`,d:`M17.30 3.54h-3.67l6.69 16.91H24Zm-10.60 0L0 20.45h3.74l1.36-3.55h7.00l1.36 3.55h3.74L10.53 3.54Zm-.371 10.22 2.29-5.94 2.29 5.94Z`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,Z.jsx)(l8,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function xhe(e){let t=(0,Y.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,a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`defs`,{children:(0,Z.jsxs)(`linearGradient`,{id:`gemini-grad`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,Z.jsx)(`stop`,{offset:`0%`,stopColor:`#4285F4`}),(0,Z.jsx)(`stop`,{offset:`50%`,stopColor:`#9B72CB`}),(0,Z.jsx)(`stop`,{offset:`100%`,stopColor:`#D96570`})]})}),a=(0,Z.jsx)(`path`,{fill:`url(#gemini-grad)`,d:`M11.04 19.32Q12 21.51 12 24q0-2.49.93-4.68.96-2.19 2.58-3.81t3.81-2.55Q21.51 12 24 12q-2.49 0-4.68-.93a12.3 12.3 0 0 1-3.81-2.58 12.3 12.3 0 0 1-2.58-3.81Q12 2.49 12 0q0 2.49-.96 4.68-.93 2.19-2.55 3.81a12.3 12.3 0 0 1-3.81 2.58Q2.49 12 0 12q2.49 0 4.68.96 2.19.93 3.81 2.55t2.55 3.81`}),t[3]=i,t[4]=a):(i=t[3],a=t[4]);let o;return t[5]!==n||t[6]!==r?(o=(0,Z.jsxs)(l8,{className:n,...r,children:[i,a]}),t[5]=n,t[6]=r,t[7]=o):o=t[7],o}function She(e){let t=(0,Y.c)(20),{providerId:n,className:r}=e,i;t[0]===r?i=t[1]:(i={className:r,"aria-hidden":!0},t[0]=r,t[1]=i);let a=i;switch(n){case`deepseek`:{let e;return t[2]===a?e=t[3]:(e=(0,Z.jsx)(_he,{...a}),t[2]=a,t[3]=e),e}case`minimax`:{let e;return t[4]===a?e=t[5]:(e=(0,Z.jsx)(vhe,{...a}),t[4]=a,t[5]=e),e}case`kimi-coding`:{let e;return t[6]===a?e=t[7]:(e=(0,Z.jsx)(u8,{...a}),t[6]=a,t[7]=e),e}case`moonshotai`:case`moonshotai-cn`:{let e;return t[8]===a?e=t[9]:(e=(0,Z.jsx)(u8,{...a}),t[8]=a,t[9]=e),e}case`openai`:{let e;return t[10]===a?e=t[11]:(e=(0,Z.jsx)(yhe,{...a}),t[10]=a,t[11]=e),e}case`anthropic`:{let e;return t[12]===a?e=t[13]:(e=(0,Z.jsx)(bhe,{...a}),t[12]=a,t[13]=e),e}case`google`:{let e;return t[14]===a?e=t[15]:(e=(0,Z.jsx)(xhe,{...a}),t[14]=a,t[15]=e),e}default:{let e;t[16]===r?e=t[17]:(e=X(`flex items-center justify-center text-2xl`,r),t[16]=r,t[17]=e);let n;return t[18]===e?n=t[19]:(n=(0,Z.jsx)(`span`,{className:e,children:`🤖`}),t[18]=e,t[19]=n),n}}}var Che=[{id:`deepseek`,name:`DeepSeek`,recommended:!0},{id:`minimax`,name:`MiniMax`,recommended:!1},{id:`kimi-coding`,name:`Kimi Coding`,recommended:!1},{id:`openai`,name:`OpenAI`,recommended:!1},{id:`anthropic`,name:`Anthropic`,recommended:!1},{id:`google`,name:`Google AI`,recommended:!1}];function whe(e){let t=(0,Y.c)(7),{onSelect:n}=e,r=d(The),i;t[0]===r?i=t[1]:(i=m(r),t[0]=r,t[1]=i);let a=i.onboarding.providerRecommended,o;t[2]!==n||t[3]!==a?(o=Che.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),className:X(`relative flex flex-col items-center gap-1.5 rounded-xl border border-edge p-4 text-center transition-colors`,`hover:border-accent hover:bg-accent-soft`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,e.recommended&&`border-accent/50 bg-accent-soft/30`),children:[e.recommended&&(0,Z.jsx)(`span`,{className:`absolute -top-2 right-2 rounded-full bg-accent px-2 py-0.5 text-[10px] font-semibold text-white`,children:a}),(0,Z.jsx)(She,{providerId:e.id,className:`size-8`}),(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.name})]},e.id)),t[2]=n,t[3]=a,t[4]=o):o=t[4];let s;return t[5]===o?s=t[6]:(s=(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3`,children:o}),t[5]=o,t[6]=s),s}function The(e){return e.language}function Ehe(e,t){return e===`single`?t.getApiKey:e===`intl`?t.getApiKeyIntl:t.getApiKeyCn}var d8={openai:{apiKeyUrl:`https://platform.openai.com/api-keys`,pricingUrl:`https://openai.com/pricing`,docsUrl:`https://platform.openai.com/docs`,description:`The most widely used LLM provider. Powers ChatGPT.`,descriptionZh:`最广泛使用的 LLM 服务商,ChatGPT 背后的技术。`,bestFor:[`general`,`coding`,`vision`],freeTier:!1,freeTierNote:`Pay-as-you-go; new accounts may receive trial credits.`,aliases:[`chatgpt`,`gpt`,`gpt-4`,`gpt4`,`gpt-4o`,`gpt4o`],envVars:[`OPENAI_API_KEY`]},anthropic:{apiKeyUrl:`https://console.anthropic.com/settings/keys`,pricingUrl:`https://www.anthropic.com/pricing`,docsUrl:`https://docs.anthropic.com`,description:`Known for Claude — excellent at long documents, coding, and nuanced reasoning.`,descriptionZh:`Claude 系列模型,擅长长文档处理、代码和复杂推理。`,bestFor:[`long context`,`coding`,`reasoning`],freeTier:!1,aliases:[`claude`,`claude 3`,`claude sonnet`,`claude opus`,`claude haiku`],envVars:[`ANTHROPIC_OAUTH_TOKEN`,`ANTHROPIC_API_KEY`]},google:{apiKeyUrl:`https://aistudio.google.com/app/apikey`,pricingUrl:`https://ai.google.dev/pricing`,docsUrl:`https://ai.google.dev/docs`,description:`Google Gemini models — strong multimodal and long-context capabilities.`,descriptionZh:`Google Gemini 系列,多模态能力强,支持超长上下文。`,bestFor:[`multimodal`,`long context`,`general`],freeTier:!0,freeTierNote:`Free tier available via Google AI Studio.`,aliases:[`gemini`,`google gemini`,`bard`,`google ai`],envVars:[`GEMINI_API_KEY`,`GOOGLE_API_KEY`]},"google-vertex":{apiKeyUrl:`https://console.cloud.google.com/apis/credentials`,pricingUrl:`https://cloud.google.com/vertex-ai/pricing`,docsUrl:`https://cloud.google.com/vertex-ai/docs`,description:`Google Vertex AI — enterprise-grade Gemini and other models on GCP.`,descriptionZh:`Google Vertex AI,企业级 GCP 托管模型,支持 Gemini 等。`,bestFor:[`enterprise`,`multimodal`,`compliance`],freeTier:!1,aliases:[`vertex`,`vertex ai`,`gcp`,`google cloud`],envVars:[`GOOGLE_CLOUD_API_KEY`,`GOOGLE_CLOUD_PROJECT`,`GOOGLE_CLOUD_LOCATION`]},"google-gemini-cli":{apiKeyUrl:`https://aistudio.google.com/app/apikey`,pricingUrl:`https://ai.google.dev/pricing`,docsUrl:`https://ai.google.dev/docs`,description:`Gemini via CLI token — for users authenticated with the Gemini CLI tool.`,descriptionZh:`通过 Gemini CLI 令牌访问 Gemini,适合已安装 CLI 工具的用户。`,bestFor:[`general`,`multimodal`],freeTier:!0,freeTierNote:`Uses your existing Gemini CLI authentication.`,aliases:[`gemini cli`,`gemini-cli`],envVars:[`GEMINI_CLI_TOKEN`,`GOOGLE_TOKEN`]},"google-antigravity":{apiKeyUrl:`https://console.cloud.google.com/apis/credentials`,pricingUrl:`https://cloud.google.com/pricing`,docsUrl:`https://cloud.google.com/docs`,description:`Google Antigravity — internal/experimental Google AI endpoint.`,descriptionZh:`Google Antigravity,Google 内部/实验性 AI 端点。`,bestFor:[`experimental`],freeTier:!1,aliases:[`antigravity`,`google antigravity`],envVars:[`ANTIGRAVITY_API_KEY`]},groq:{apiKeyUrl:`https://console.groq.com/keys`,pricingUrl:`https://groq.com/pricing/`,docsUrl:`https://console.groq.com/docs`,description:`Extremely fast inference — ideal for latency-sensitive applications.`,descriptionZh:`推理速度极快,适合对延迟敏感的场景。`,bestFor:[`speed`,`cheap`],freeTier:!0,freeTierNote:`Generous free tier with rate limits.`,aliases:[`groq`,`llama on groq`,`mixtral on groq`],envVars:[`GROQ_API_KEY`]},deepseek:{apiKeyUrl:`https://platform.deepseek.com/api_keys`,pricingUrl:`https://api-docs.deepseek.com/quick_start/pricing/`,docsUrl:`https://platform.deepseek.com/api-docs/`,description:`DeepSeek models — OpenAI-compatible API with strong reasoning and low costs.`,descriptionZh:`DeepSeek 模型:OpenAI 兼容 API,推理强、成本低。`,bestFor:[`reasoning`,`cheap`,`coding`],freeTier:!0,freeTierNote:`Free credits may be available for new accounts.`,aliases:[`deepseek`,`deep seek`,`deepseek v4`,`deepseek-v4`,`r1`],envVars:[`DEEPSEEK_API_KEY`]},xai:{apiKeyUrl:`https://console.x.ai/`,pricingUrl:`https://x.ai/api`,docsUrl:`https://docs.x.ai/`,description:`xAI Grok models — real-time web access, strong reasoning.`,descriptionZh:`xAI Grok 系列,支持实时联网,推理能力强。`,bestFor:[`reasoning`,`real-time`],freeTier:!1,aliases:[`grok`,`xai`,`x.ai`],envVars:[`XAI_API_KEY`]},cerebras:{apiKeyUrl:`https://cloud.cerebras.ai/platform/`,pricingUrl:`https://cloud.cerebras.ai/platform/`,docsUrl:`https://inference-docs.cerebras.ai/`,description:`Ultra-fast inference on custom AI chips. Fastest Llama inference available.`,descriptionZh:`基于专用 AI 芯片的超快推理,Llama 推理速度业界最快。`,bestFor:[`speed`],freeTier:!0,freeTierNote:`Free tier available.`,aliases:[`cerebras`],envVars:[`CEREBRAS_API_KEY`]},mistral:{apiKeyUrl:`https://console.mistral.ai/api-keys/`,pricingUrl:`https://mistral.ai/technology/#pricing`,docsUrl:`https://docs.mistral.ai/`,description:`European open-weight models. Good balance of quality and cost.`,descriptionZh:`欧洲开源模型,质量与成本平衡好。`,bestFor:[`general`,`cheap`,`coding`],freeTier:!1,aliases:[`mistral`,`mixtral`,`codestral`],envVars:[`MISTRAL_API_KEY`]},openrouter:{apiKeyUrl:`https://openrouter.ai/keys`,pricingUrl:`https://openrouter.ai/models`,docsUrl:`https://openrouter.ai/docs`,description:`API gateway to 100+ models from many providers with a single key.`,descriptionZh:`统一 API 网关,一个 Key 访问 100+ 模型。`,bestFor:[`general`,`flexibility`],freeTier:!0,freeTierNote:`Some models are free; pay-per-use for others.`,aliases:[`openrouter`,`open router`],envVars:[`OPENROUTER_API_KEY`]},"azure-openai-responses":{apiKeyUrl:`https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/OpenAI`,pricingUrl:`https://azure.microsoft.com/en-us/pricing/details/cognitive-services/openai-service/`,docsUrl:`https://learn.microsoft.com/en-us/azure/ai-services/openai/`,description:`OpenAI models hosted on Azure. Enterprise SLA and data residency.`,descriptionZh:`Azure 托管的 OpenAI 模型,企业级 SLA 和数据合规。`,bestFor:[`enterprise`,`compliance`,`coding`],freeTier:!1,aliases:[`azure`,`azure openai`,`aoai`],envVars:[`AZURE_OPENAI_API_KEY`,`AZURE_OPENAI_BASE_URL`]},"amazon-bedrock":{apiKeyUrl:`https://console.aws.amazon.com/iam/home#/security_credentials`,pricingUrl:`https://aws.amazon.com/bedrock/pricing/`,docsUrl:`https://docs.aws.amazon.com/bedrock/`,description:`AWS-hosted models including Claude, Llama, Titan. Enterprise-grade.`,descriptionZh:`AWS 托管模型,包含 Claude、Llama 等,企业级可靠性。`,bestFor:[`enterprise`,`compliance`],freeTier:!1,aliases:[`bedrock`,`aws`,`amazon`],envVars:[`AWS_ACCESS_KEY_ID`,`AWS_SECRET_ACCESS_KEY`,`AWS_REGION`]},minimax:{apiKeyUrl:`https://platform.minimax.io/user-center/basic-information/interface-key`,pricingUrl:`https://platform.minimax.io/docs/guides/models-intro`,docsUrl:`https://platform.minimax.io/docs/guides/quickstart-preparation`,description:`MiniMax — Chinese multimodal model with strong text and audio capabilities.`,descriptionZh:`MiniMax,国产多模态模型,文本和音频能力强。`,bestFor:[`multimodal`,`chinese`],freeTier:!0,freeTierNote:`注册赠送免费额度。`,aliases:[`minimax`,`mini max`,`abab`],envVars:[`MINIMAX_API_KEY`]},"minimax-cn":{apiKeyUrl:`https://platform.minimaxi.com/user-center/basic-information/interface-key`,pricingUrl:`https://platform.minimaxi.com/document/Price`,docsUrl:`https://platform.minimaxi.com/document/Announcement`,description:`MiniMax (China endpoint) — domestic access for Chinese users.`,descriptionZh:`MiniMax 国内端点,国内用户直连访问。`,bestFor:[`multimodal`,`chinese`],freeTier:!0,freeTierNote:`注册赠送免费额度。`,aliases:[`minimax cn`,`minimax china`,`abab`],envVars:[`MINIMAX_CN_API_KEY`,`MINIMAX_API_KEY`]},"kimi-coding":{apiKeyUrl:`https://platform.kimi.com/console/api-keys`,pricingUrl:`https://platform.kimi.com/docs/pricing/chat`,docsUrl:`https://platform.kimi.com/docs`,description:`Kimi Coding — Moonshot model optimized for code generation tasks.`,descriptionZh:`Kimi Coding,Moonshot 专为代码生成优化的模型。`,bestFor:[`coding`,`chinese`],freeTier:!0,freeTierNote:`注册赠送免费额度。`,aliases:[`kimi coding`,`moonshot coding`,`kimi code`],envVars:[`KIMI_API_KEY`,`MOONSHOT_API_KEY`]},moonshotai:{apiKeyUrl:`https://platform.moonshot.ai/console/api-keys`,pricingUrl:`https://platform.moonshot.ai/docs/pricing`,docsUrl:`https://platform.moonshot.ai/docs`,description:`Moonshot Kimi — international API (api.moonshot.ai).`,descriptionZh:`月之暗面 Kimi 国际版 API(api.moonshot.ai)。`,bestFor:[`coding`,`chinese`,`long context`],freeTier:!0,aliases:[`moonshot`,`kimi`,`moonshot ai`],envVars:[`MOONSHOT_API_KEY`]},"moonshotai-cn":{apiKeyUrl:`https://platform.moonshot.cn/console/api-keys`,pricingUrl:`https://platform.moonshot.cn/docs/pricing/chat`,docsUrl:`https://platform.moonshot.cn/docs`,description:`Moonshot Kimi — China region endpoint.`,descriptionZh:`月之暗面 Kimi 中国区域端点。`,bestFor:[`coding`,`chinese`,`long context`],freeTier:!0,aliases:[`moonshot cn`,`kimi cn`],envVars:[`MOONSHOT_API_KEY`]},fal:{apiKeyUrl:`https://fal.ai/dashboard/keys`,pricingUrl:`https://fal.ai/pricing`,docsUrl:`https://fal.ai/docs`,description:`fal — serverless image and media generation APIs.`,descriptionZh:`fal:无服务器图像与媒体生成 API。`,bestFor:[`image`,`video`],freeTier:!0,aliases:[`fal ai`,`fal.ai`],envVars:[`FAL_KEY`,`FAL_API_KEY`]},fireworks:{apiKeyUrl:`https://fireworks.ai/account/api-keys`,pricingUrl:`https://fireworks.ai/pricing`,docsUrl:`https://docs.fireworks.ai`,description:`Fireworks AI — fast inference for open and proprietary models.`,descriptionZh:`Fireworks AI,多种开源与商业模型的高速推理服务。`,bestFor:[`speed`,`coding`,`open weights`],freeTier:!0,aliases:[`fireworks ai`,`fireworks`],envVars:[`FIREWORKS_API_KEY`]},together:{apiKeyUrl:`https://api.together.xyz/settings/api-keys`,pricingUrl:`https://www.together.ai/pricing`,docsUrl:`https://docs.together.ai`,description:`Together AI — hosted Llama, Qwen, DeepSeek, and more.`,descriptionZh:`Together AI,托管 Llama、Qwen、DeepSeek 等模型。`,bestFor:[`open source`,`flexibility`],freeTier:!0,aliases:[`together ai`,`together.xyz`],envVars:[`TOGETHER_API_KEY`]},"cloudflare-workers-ai":{apiKeyUrl:`https://dash.cloudflare.com/?to=/:account/ai/workers-ai`,pricingUrl:`https://developers.cloudflare.com/workers-ai/platform/pricing/`,docsUrl:`https://developers.cloudflare.com/workers-ai/`,description:`Cloudflare Workers AI — models at the edge via Cloudflare API.`,descriptionZh:`Cloudflare Workers AI,通过 Cloudflare API 在边缘运行模型。`,bestFor:[`edge`,`latency`],freeTier:!0,aliases:[`workers ai`,`cf workers ai`],envVars:[`CLOUDFLARE_API_KEY`]},"cloudflare-ai-gateway":{apiKeyUrl:`https://dash.cloudflare.com/?to=/:account/ai/ai-gateway`,pricingUrl:`https://developers.cloudflare.com/ai-gateway/pricing/`,docsUrl:`https://developers.cloudflare.com/ai-gateway/`,description:`Cloudflare AI Gateway — unified OpenAI/Anthropic-compatible routing.`,descriptionZh:`Cloudflare AI Gateway,统一 OpenAI/Anthropic 兼容路由。`,bestFor:[`routing`,`observability`,`enterprise`],freeTier:!0,aliases:[`cf ai gateway`,`cloudflare gateway`],envVars:[`CLOUDFLARE_API_KEY`]},xiaomi:{apiKeyUrl:`https://platform.xiaomimimo.com/#/console/api-keys`,pricingUrl:`https://mimo.mi.com/`,docsUrl:`https://platform.xiaomimimo.com/`,description:`Xiaomi MiMo — API billing (Anthropic-compatible). Keys from the MiMo open platform; endpoint api.xiaomimimo.com.`,descriptionZh:`小米 MiMo 按量计费线路(Anthropic 兼容),在开放平台创建密钥;接口域名为 api.xiaomimimo.com。`,bestFor:[`general`,`coding`],freeTier:!1,aliases:[`xiaomi`,`mimo`,`小米`,`xiaomimimo`],envVars:[`XIAOMI_API_KEY`]},"xiaomi-token-plan-cn":{apiKeyUrl:`https://platform.xiaomimimo.com/#/console/api-keys`,pricingUrl:`https://mimo.mi.com/`,docsUrl:`https://platform.xiaomimimo.com/`,description:`Xiaomi MiMo Token Plan — China region (token-plan-cn.xiaomimimo.com).`,descriptionZh:`小米 MiMo Token 套餐 · 中国区(token-plan-cn.xiaomimimo.com)。`,bestFor:[`general`,`coding`],freeTier:!1,aliases:[`xiaomi token cn`,`mimo token cn`],envVars:[`XIAOMI_TOKEN_PLAN_CN_API_KEY`]},"xiaomi-token-plan-ams":{apiKeyUrl:`https://platform.xiaomimimo.com/#/console/api-keys`,pricingUrl:`https://mimo.mi.com/`,docsUrl:`https://platform.xiaomimimo.com/`,description:`Xiaomi MiMo Token Plan — Amsterdam region (token-plan-ams.xiaomimimo.com).`,descriptionZh:`小米 MiMo Token 套餐 · 阿姆斯特丹(token-plan-ams.xiaomimimo.com)。`,bestFor:[`general`,`coding`],freeTier:!1,aliases:[`xiaomi token ams`,`mimo token ams`],envVars:[`XIAOMI_TOKEN_PLAN_AMS_API_KEY`]},"xiaomi-token-plan-sgp":{apiKeyUrl:`https://platform.xiaomimimo.com/#/console/api-keys`,pricingUrl:`https://mimo.mi.com/`,docsUrl:`https://platform.xiaomimimo.com/`,description:`Xiaomi MiMo Token Plan — Singapore region (token-plan-sgp.xiaomimimo.com).`,descriptionZh:`小米 MiMo Token 套餐 · 新加坡(token-plan-sgp.xiaomimimo.com)。`,bestFor:[`general`,`coding`],freeTier:!1,aliases:[`xiaomi token sgp`,`mimo token sgp`],envVars:[`XIAOMI_TOKEN_PLAN_SGP_API_KEY`]},huggingface:{apiKeyUrl:`https://huggingface.co/settings/tokens`,pricingUrl:`https://huggingface.co/pricing`,docsUrl:`https://huggingface.co/docs/api-inference/`,description:`Access thousands of open-source models via Hugging Face Inference API.`,descriptionZh:`通过 Hugging Face 访问数千个开源模型。`,bestFor:[`open source`,`flexibility`],freeTier:!0,freeTierNote:`Free tier with rate limits.`,aliases:[`huggingface`,`hugging face`,`hf`],envVars:[`HF_TOKEN`,`HUGGINGFACE_TOKEN`]},opencode:{apiKeyUrl:`https://opencode.ai/auth`,pricingUrl:`https://opencode.ai/docs`,docsUrl:`https://opencode.ai/docs/providers/`,description:`OpenCode — AI coding assistant provider.`,descriptionZh:`OpenCode,AI 代码助手服务商。`,bestFor:[`coding`],freeTier:!1,aliases:[`opencode`,`open code`],envVars:[`OPENCODE_API_KEY`]},"opencode-go":{apiKeyUrl:`https://opencode.ai/auth`,pricingUrl:`https://opencode.ai/docs`,docsUrl:`https://opencode.ai/docs/providers/`,description:`OpenCode Go — AI coding assistant provider (Go variant).`,descriptionZh:`OpenCode Go,AI 代码助手服务商(Go 版本)。`,bestFor:[`coding`],freeTier:!1,aliases:[`opencode go`,`opencode-go`],envVars:[`OPENCODE_API_KEY`]},zai:{apiKeyUrl:`https://z.ai/manage-apikey/apikey-list`,pricingUrl:`https://z.ai/manage-apikey/billing`,docsUrl:`https://docs.z.ai/guides/overview/quick-start`,description:`01.AI Yi models — strong multilingual capabilities.`,descriptionZh:`零一万物 Yi 系列模型,多语言能力强。`,bestFor:[`general`,`chinese`],freeTier:!1,aliases:[`yi`,`01.ai`,`zero one`,`零一万物`],envVars:[`ZAI_API_KEY`]},dashscope:{apiKeyUrl:`https://modelstudio.console.alibabacloud.com/`,apiKeyUrlCn:`https://dashscope.console.aliyun.com/apiKey`,pricingUrl:`https://help.aliyun.com/zh/dashscope/developer-reference/tongyi-thousand-questions-metering-and-billing`,docsUrl:`https://help.aliyun.com/zh/dashscope/`,description:"Alibaba DashScope — image generation, speech, and STT HTTP APIs (service id `dashscope`, not a pi-ai LLM provider).",descriptionZh:`阿里 DashScope:文生图、语音等 HTTP API(服务 id 为 dashscope,非 pi-ai 内置 LLM)。`,bestFor:[`image`,`speech`,`chinese`],freeTier:!0,aliases:[`dash scope`,`alibaba dashscope`],envVars:[`DASHSCOPE_API_KEY`]},"vercel-ai-gateway":{apiKeyUrl:`https://vercel.com/account/tokens`,pricingUrl:`https://vercel.com/pricing`,docsUrl:`https://vercel.com/docs/ai/ai-gateway`,description:`Vercel AI Gateway — route requests to multiple LLM providers via Vercel.`,descriptionZh:`Vercel AI Gateway,通过 Vercel 路由请求到多个 LLM 服务商。`,bestFor:[`flexibility`,`enterprise`],freeTier:!1,aliases:[`vercel gateway`,`vercel ai gateway`],envVars:[`AI_GATEWAY_API_KEY`,`VERCEL_AI_GATEWAY_API_KEY`]},"github-copilot":{apiKeyUrl:`https://github.com/settings/tokens`,pricingUrl:`https://github.com/features/copilot#pricing`,docsUrl:`https://docs.github.com/en/copilot`,description:`GitHub Copilot — use your GitHub token to access Copilot models.`,descriptionZh:`使用 GitHub 令牌访问 Copilot 模型。`,bestFor:[`coding`],freeTier:!0,freeTierNote:`Free for verified students and open-source maintainers.`,aliases:[`github copilot`,`copilot`,`github`],envVars:[`COPILOT_GITHUB_TOKEN`,`GH_TOKEN`,`GITHUB_TOKEN`,`GITHUB_COPILOT_TOKEN`]}};function Dhe(e,t){let n=d8[e];if(!n)return[];let r=n.apiKeyUrl,i=n.apiKeyUrlCn;return r&&i?t===`zh`?[{href:i,kind:`cn`},{href:r,kind:`intl`}]:[{href:r,kind:`intl`},{href:i,kind:`cn`}]:r?[{href:r,kind:`single`}]:i?[{href:i,kind:`single`}]:[]}function Ohe(e){return e===`***`||e===`••••••••••••`||/^•+$/.test(e)}async function khe(){return(await we(_(`/api/providers/meta`))).payload?.providers??[]}function Ahe(e){if(!e||typeof e!=`object`||!(`providers`in e))return{};let t=e.providers;if(!t||typeof t!=`object`||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t))typeof r==`string`&&(n[e]=r);return n}function jhe(e,t,n){let r=new Set(n.map(e=>e.provider));return e.map(e=>({...e,configured:e.configured||r.has(e.id),apiKey:t[e.id]||(e.configured||r.has(e.id)?`***`:``)}))}async function f8(e){await we(_(`/api/config`),{method:`PATCH`,body:JSON.stringify({providers:e})}),Promise.all([mL(),b(_(`/api/providers/meta`))])}async function Mhe(e){await we(_(`/api/providers/${encodeURIComponent(e)}/key`),{method:`DELETE`}),Promise.all([mL(),b(_(`/api/providers/meta`))])}async function Nhe(e){return(await we(_(`/api/models-json/test-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({value:e})})).payload??{type:`literal`,error:`No response`}}var Phe={step:`provider`,selectedProvider:null,apiKey:``,busy:!1,error:null,models:[],selectedModelId:null,modelsLoading:!1};function Fhe(e,t){switch(t.type){case`patch`:return{...e,...t.patch};case`reset-models`:return{...e,models:[],selectedModelId:null}}}function Ihe({onComplete:e,onDismiss:t}){let n=d(e=>e.language),r=m(n).onboarding,[i,a]=(0,J.useReducer)(Fhe,Phe),{step:o,selectedProvider:s,apiKey:c,busy:l,error:u,models:f,selectedModelId:p,modelsLoading:h}=i,g=(0,J.useMemo)(()=>r.stepOf.replace(`{{current}}`,String(o===`provider`?1:o===`apiKey`?2:3)).replace(`{{total}}`,`3`),[r.stepOf,o]),v=(0,J.useCallback)(async e=>{a({type:`patch`,patch:{modelsLoading:!0,error:null}});try{let t=(await c8(!0)).filter(t=>t.provider===e);a({type:`patch`,patch:{models:t,selectedModelId:t[0]?.id??null}})}catch(e){a({type:`patch`,patch:{error:e instanceof Error?e.message:String(e),models:[],selectedModelId:null}})}finally{a({type:`patch`,patch:{modelsLoading:!1}})}},[]),y=async()=>{if(!(!s||!c.trim())){a({type:`patch`,patch:{busy:!0,error:null}});try{await f8({[s]:c.trim()}),await v(s),a({type:`patch`,patch:{step:`model`}})}catch(e){a({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{busy:!1}})}}},b=async()=>{if(!s||!p)return;let t=f.find(e=>e.id===p)?.id??p;a({type:`patch`,patch:{busy:!0,error:null}});try{await we(_(`/api/config`),{method:`PATCH`,body:JSON.stringify({agents:{defaults:{model:t}}})}),mL(),hhe(),P1(),e()}catch(e){a({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{busy:!1}})}};return(0,Z.jsxs)(`div`,{className:`w-full max-w-xl rounded-2xl border border-edge bg-surface-panel p-6 shadow-elevated`,children:[(0,Z.jsxs)(`div`,{className:`text-center`,children:[(0,Z.jsx)(`div`,{className:`text-3xl`,"aria-hidden":!0,children:`🤖`}),(0,Z.jsx)(`h2`,{className:`mt-3 text-lg font-semibold tracking-tight text-fg`,children:r.title}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle}),(0,Z.jsx)(`p`,{className:`mt-2 text-xs font-medium uppercase tracking-wide text-fg-muted`,children:g})]}),(0,Z.jsxs)(`div`,{className:`mt-6`,children:[o===`provider`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-base font-medium text-fg`,children:r.step1Title}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.step1Subtitle})]}),(0,Z.jsx)(whe,{onSelect:e=>{a({type:`patch`,patch:{selectedProvider:e,step:`apiKey`,apiKey:``,error:null}})}}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 pt-2`,children:[(0,Z.jsx)(ja,{to:`/settings/providers`,className:`text-xs font-medium text-accent-fg hover:underline`,children:n===`zh`?`高级设置…`:`More settings…`}),(0,Z.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-fg-muted hover:text-fg hover:underline`,onClick:t,children:r.skipSetup})]})]}):null,o===`apiKey`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h3`,{className:`text-base font-medium text-fg`,children:[r.step2Title,s?` (${s})`:``]}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.step2Subtitle})]}),s&&(()=>{let e=d8[s],t=e?.apiKeyUrl,r=e?.apiKeyUrlCn;return t?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-xl border border-edge-subtle bg-surface-base px-3.5 py-2.5`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n===`zh`?`获取 API Key:`:`Get your API Key:`}),(0,Z.jsxs)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-xs font-medium text-accent-fg hover:underline`,children:[r?n===`zh`?`国际版`:`International`:n===`zh`?`前往获取`:`Get API Key`,(0,Z.jsx)(yd,{className:`size-3`})]}),r&&(0,Z.jsxs)(`a`,{href:r,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-xs font-medium text-accent-fg hover:underline`,children:[n===`zh`?`中国版`:`China`,(0,Z.jsx)(yd,{className:`size-3`})]})]}):null})(),(0,Z.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[(0,Z.jsx)(`span`,{className:`sr-only`,children:r.step2Placeholder}),(0,Z.jsx)(`input`,{type:`password`,autoComplete:`off`,value:c,onChange:e=>a({type:`patch`,patch:{apiKey:e.target.value}}),placeholder:r.step2Placeholder,className:`mt-1 w-full rounded-xl border border-edge bg-surface-panel px-3 py-2.5 text-sm text-fg outline-none ring-accent placeholder:text-fg-muted focus:border-accent focus:ring-2 focus:ring-accent/30`})]}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.step2SecurityNote}),u?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:u}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2`,children:[(0,Z.jsx)(wA,{type:`button`,variant:`secondary`,disabled:l,onClick:()=>a({type:`patch`,patch:{step:`provider`}}),children:r.back}),(0,Z.jsx)(wA,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,disabled:l||!c.trim(),onClick:()=>void y(),children:r.continue})]})]}):null,o===`model`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-base font-medium text-fg`,children:r.step3Title}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.step3Subtitle})]}),h?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n===`zh`?`加载模型…`:`Loading models…`}):u&&f.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:u}),(0,Z.jsx)(`button`,{type:`button`,className:`text-left text-sm font-medium text-accent-fg hover:underline`,onClick:()=>s&&void v(s),children:n===`zh`?`重试`:`Retry`})]}):(0,Z.jsx)(ghe,{models:f,selectedId:p,onSelectedChange:e=>a({type:`patch`,patch:{selectedModelId:e}})}),u&&f.length>0?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:u}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2`,children:[(0,Z.jsx)(wA,{type:`button`,variant:`secondary`,disabled:l,onClick:()=>a({type:`patch`,patch:{step:`apiKey`}}),children:r.back}),(0,Z.jsx)(wA,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,disabled:l||!p||h,onClick:()=>void b(),children:r.startChatting})]})]}):null]})]})}function Lhe(e){if(!e||typeof e!=`object`)return!0;let t=e,n=t.providers,r=Object.values(n&&typeof n==`object`&&!Array.isArray(n)?n:{}).some(e=>e===`***`),i=t.agents,a=``;if(i&&typeof i==`object`&&!Array.isArray(i)){let e=i.defaults;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.model;typeof t==`string`&&(a=t)}}let o=a.trim().length>0;return!r||!o}function Rhe(e){let{enabled:t,ready:n,configError:r,modelsError:i,config:a,modelsData:o}=e;if(!t||!n||r||i)return!1;let s=Lhe(a),c=!Array.isArray(o)||o.length===0;return s||c}var zhe=`xopc-onboarding-model-setup-dismissed`;function Bhe(e){let t=(0,Y.c)(21),[n,r]=(0,J.useState)(Vhe),{data:i,error:a,isLoading:o,mutate:s}=pL(e),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={revalidateOnFocus:!1},t[0]=c):c=t[0];let{data:l,isLoading:u,error:d,mutate:f}=v(e?s8:null,c8,c),p=!e||!o&&!u,m=i?.payload?.config,h;t[1]!==a||t[2]!==e||t[3]!==l||t[4]!==d||t[5]!==p||t[6]!==m?(h=Rhe({enabled:e,ready:p,configError:a,modelsError:d,config:m,modelsData:l}),t[1]=a,t[2]=e,t[3]=l,t[4]=d,t[5]=p,t[6]=m,t[7]=h):h=t[7];let g=h,_;t[8]!==s||t[9]!==f?(_=async()=>{await Promise.all([s(),f()])},t[8]=s,t[9]=f,t[10]=_):_=t[10];let y=_,b,x;t[11]!==e||t[12]!==f?(b=()=>{if(!e)return;let t=()=>{f()};return window.addEventListener(`config-reload`,t),()=>window.removeEventListener(`config-reload`,t)},x=[e,f],t[11]=e,t[12]=f,t[13]=b,t[14]=x):(b=t[13],x=t[14]),(0,J.useEffect)(b,x);let S;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>{try{localStorage.setItem(zhe,`1`)}catch{}r(!0)},t[15]=S):S=t[15];let C=S,w;return t[16]!==n||t[17]!==g||t[18]!==p||t[19]!==y?(w={needsSetup:g,ready:p,refresh:y,guideDismissed:n,dismissPermanently:C},t[16]=n,t[17]=g,t[18]=p,t[19]=y,t[20]=w):w=t[20],w}function Vhe(){return typeof localStorage<`u`&&localStorage.getItem(`xopc-onboarding-model-setup-dismissed`)===`1`}function Hhe(){let e=(0,Y.c)(20),t=Se(qhe),n=d(Khe),r;e[0]===n?r=e[1]:(r=m(n),e[0]=n,e[1]=r);let i=r,a=Bhe(!!t),o=!!t&&a.ready&&a.needsSetup&&!a.guideDismissed,s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(ie,{className:`fixed inset-0 z-[55] bg-scrim backdrop-blur-[2px]`}),e[2]=s):s=e[2];let c;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=X(`fixed left-1/2 top-1/2 z-[56] max-h-[min(100dvh-2rem,44rem)] w-[min(100%-2rem,36rem)] -translate-x-1/2 -translate-y-1/2 overflow-y-auto`,`rounded-xl p-2 outline-none sm:p-3`),e[3]=c):c=e[3];let l;e[4]===i.onboarding.title?l=e[5]:(l=(0,Z.jsx)(ue,{className:`sr-only`,children:i.onboarding.title}),e[4]=i.onboarding.title,e[5]=l);let u;e[6]===i.onboarding.subtitle?u=e[7]:(u=(0,Z.jsx)(le,{className:`sr-only`,children:i.onboarding.subtitle}),e[6]=i.onboarding.subtitle,e[7]=u);let f;e[8]===a?f=e[9]:(f=()=>void a.refresh(),e[8]=a,e[9]=f);let p;e[10]!==a.dismissPermanently||e[11]!==f?(p=(0,Z.jsx)(Ihe,{onComplete:f,onDismiss:a.dismissPermanently}),e[10]=a.dismissPermanently,e[11]=f,e[12]=p):p=e[12];let h;e[13]!==l||e[14]!==u||e[15]!==p?(h=(0,Z.jsxs)(G,{children:[s,(0,Z.jsxs)(se,{className:c,onPointerDownOutside:Ghe,onEscapeKeyDown:Whe,onOpenAutoFocus:Uhe,children:[l,u,p]})]}),e[13]=l,e[14]=u,e[15]=p,e[16]=h):h=e[16];let g;return e[17]!==o||e[18]!==h?(g=(0,Z.jsx)(q,{open:o,children:h}),e[17]=o,e[18]=h,e[19]=g):g=e[19],g}function Uhe(e){return e.preventDefault()}function Whe(e){return e.preventDefault()}function Ghe(e){return e.preventDefault()}function Khe(e){return e.language}function qhe(e){return e.token}function Jhe(){let e=(0,Y.c)(3),t=Qr(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{let e=e=>{let n=e.detail;n?.sessionKey&&t(`/chat/${encodeURIComponent(n.sessionKey)}`)};return window.addEventListener(`navigate-to-chat`,e),()=>window.removeEventListener(`navigate-to-chat`,e)},r=[t],e[0]=t,e[1]=n,e[2]=r),(0,J.useEffect)(n,r),null}function Yhe(){let e=(0,Y.c)(3),t=Qr(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{let e=e=>{let n=e.detail,r=typeof n?.path==`string`?n.path.trim():``;r&&t(r.startsWith(`/`)?r:`/${r}`)};return window.addEventListener(`extension-navigate`,e),()=>window.removeEventListener(`extension-navigate`,e)},r=[t],e[0]=t,e[1]=n,e[2]=r),(0,J.useEffect)(n,r),null}function Xhe(){let e=(0,Y.c)(10),[t,n]=(0,J.useState)(null),r,i;if(e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=e=>{let t=e.detail;if(!t||typeof t.title!=`string`||!t.title.trim())return;n({type:t.type??`info`,title:t.title.trim(),message:typeof t.message==`string`?t.message:void 0,duration:t.duration});let r=t.duration===0?0:t.duration??5e3;r>0&&window.setTimeout(()=>n(null),r)};return window.addEventListener(`extension-notification`,e),()=>window.removeEventListener(`extension-notification`,e)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,J.useEffect)(r,i),!t)return null;let a=`pointer-events-none fixed bottom-4 right-4 z-[100] flex max-w-sm flex-col gap-1 rounded-lg border px-4 py-3 text-sm shadow-elevated ${t.type===`error`?`border-red-500/40 bg-red-500/10`:t.type===`warning`?`border-amber-500/40 bg-amber-500/10`:t.type===`success`?`border-emerald-500/40 bg-emerald-500/10`:`border-edge bg-surface-panel`}`,o;e[2]===t.title?o=e[3]:(o=(0,Z.jsx)(`div`,{className:`pointer-events-auto font-medium text-fg`,children:t.title}),e[2]=t.title,e[3]=o);let s;e[4]===t.message?s=e[5]:(s=t.message?(0,Z.jsx)(`div`,{className:`pointer-events-auto text-fg-muted`,children:t.message}):null,e[4]=t.message,e[5]=s);let c;return e[6]!==a||e[7]!==o||e[8]!==s?(c=(0,Z.jsxs)(`div`,{className:a,role:`status`,"aria-live":`polite`,children:[o,s]}),e[6]=a,e[7]=o,e[8]=s,e[9]=c):c=e[9],c}function Zhe(){let e=(0,Y.c)(47),t=Se($he),{pathname:n}=Yr(),r;e[0]===n?r=e[1]:(r=n.startsWith(`/settings`),e[0]=n,e[1]=r);let i=r,a=d(Qhe),o=BF();if(!t){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-1 flex-col overflow-hidden bg-surface-base`,children:[(0,Z.jsx)(FQ,{}),(0,Z.jsx)(aj,{})]}),e[2]=t):t=e[2],t}let s;e[3]===n?s=e[4]:(s=n.split(`/`)[1]??`root`,e[3]=n,e[4]=s);let c=s,l=a===`zh`?`跳到主要内容`:`Skip to main content`,u;e[5]===l?u=e[6]:(u=(0,Z.jsx)(`a`,{href:`#app-main-content`,className:`sr-only z-[80] rounded-lg bg-surface-panel px-3 py-2 text-sm text-fg shadow-elevated focus:not-sr-only focus:absolute focus:left-4 focus:top-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:l}),e[5]=l,e[6]=u);let f,p,m,h,g,_,v,y,b,x,S;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Z.jsx)(pue,{}),v=(0,Z.jsx)(qme,{}),y=(0,Z.jsx)(OQ,{}),b=(0,Z.jsx)(FQ,{}),x=(0,Z.jsx)(Jhe,{}),S=(0,Z.jsx)(Yhe,{}),f=(0,Z.jsx)(rue,{}),p=(0,Z.jsx)(Xhe,{}),m=(0,Z.jsx)(dQ,{}),h=(0,Z.jsx)(Hhe,{}),g=(0,Z.jsx)(NQ,{}),e[7]=f,e[8]=p,e[9]=m,e[10]=h,e[11]=g,e[12]=_,e[13]=v,e[14]=y,e[15]=b,e[16]=x,e[17]=S):(f=e[7],p=e[8],m=e[9],h=e[10],g=e[11],_=e[12],v=e[13],y=e[14],b=e[15],x=e[16],S=e[17]);let C;e[18]===o?C=e[19]:(C=(0,Z.jsx)(n$,{reminder:o}),e[18]=o,e[19]=C);let w;e[20]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(zQ,{}),e[20]=w):w=e[20];let T;e[21]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(jH,{}),e[21]=T):T=e[21];let E;e[22]===i?E=e[23]:(E=i?null:(0,Z.jsx)(Kj,{}),e[22]=i,e[23]=E);let D=c===`settings`?`page-enter--gentle overflow-hidden`:`overflow-y-auto overscroll-contain [scrollbar-gutter:stable_both-edges]`,O;e[24]===D?O=e[25]:(O=X(`page-enter flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden`,D),e[24]=D,e[25]=O);let k;e[26]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Z.jsx)(Li,{}),e[26]=k):k=e[26];let A;e[27]!==c||e[28]!==O?(A=(0,Z.jsx)(`main`,{id:`app-main-content`,className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,Z.jsx)(`div`,{className:O,children:k},c)}),e[27]=c,e[28]=O,e[29]=A):A=e[29];let j;e[30]!==E||e[31]!==A?(j=(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[E,A]}),e[30]=E,e[31]=A,e[32]=j):j=e[32];let M;e[33]===i?M=e[34]:(M=i?null:(0,Z.jsx)(uQ,{}),e[33]=i,e[34]=M);let N;e[35]!==j||e[36]!==M?(N=(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-row overflow-hidden`,children:[T,(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 min-w-0 flex-col overflow-hidden bg-surface-panel`,children:(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-row overflow-hidden`,children:[j,M]})})]}),e[35]=j,e[36]=M,e[37]=N):N=e[37];let P;e[38]!==C||e[39]!==N?(P=(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[C,w,N]}),e[38]=C,e[39]=N,e[40]=P):P=e[40];let F;e[41]===i?F=e[42]:(F=i?null:(0,Z.jsx)(dhe,{}),e[41]=i,e[42]=F);let I;return e[43]!==P||e[44]!==F||e[45]!==u?(I=(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-1 flex-col overflow-hidden bg-surface-base`,children:[u,_,v,y,b,x,S,f,p,m,h,g,P,F]}),e[43]=P,e[44]=F,e[45]=u,e[46]=I):I=e[46],I}function Qhe(e){return e.language}function $he(e){return e.token}var ege={chat:jg,sessions:Sp,cron:Zl,skills:hg,channels:bv,agents:YE,logs:xf,settingsOverview:no,settingsCredentials:pg,settingsAgentDefaults:Ux,settingsAppearance:r_,settingsSystem:px,settingsAppManagement:Qg,settingsAgentChat:uu,settingsAgentWorkspace:Np,settingsAgentBrowser:km,settingsAgentRuntime:CT,settingsAgentContext:mg,settingsAgentMemory:kl,settingsAgentTools:iO,settingsAgentSkills:El,settingsAgentMcp:jl,settingsAgentSystemPrompt:kb,settingsAgents:YE,settingsProviders:Ql,settingsModels:uu,settingsImageModels:ig,settingsChannels:bv,settingsVoice:Mg,settingsGateway:km,settingsHeartbeat:jh,settingsTunnel:Jv,settingsSearch:Ib,settingsShares:Xb,settingsDreams:Fg,settingsCron:Zl,settingsGoals:Vw};function tge(e){let t=(0,Y.c)(3),{tab:n,className:r}=e,i=ege[n],a;return t[0]!==i||t[1]!==r?(a=(0,Z.jsx)(i,{className:r,strokeWidth:1.75,"aria-hidden":!0}),t[0]=i,t[1]=r,t[2]=a):a=t[2],a}function nge(e){let t=(0,Y.c)(44),{navLinkClassName:n}=e,{t:r}=Ve(),i=d(rge),a;t[0]===i?a=t[1]:(a=m(i),t[0]=i,t[1]=a);let o=a,s=NI(),c,l,u,f,p;if(t[2]!==o.nav.apps||t[3]!==o.settingsNavGroups.extensions||t[4]!==n||t[5]!==r||t[6]!==s){let e=ige(s);t[12]===o.settingsNavGroups.extensions?p=t[13]:(p=(0,Z.jsx)(`p`,{className:`px-4 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wider text-fg-muted`,children:o.settingsNavGroups.extensions}),t[12]=o.settingsNavGroups.extensions,t[13]=p),c=`flex flex-col gap-0.5`;let i;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(gg,{className:`size-5 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),t[14]=i):i=t[14];let a;t[15]===o.nav.apps?a=t[16]:(a=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:o.nav.apps}),t[15]=o.nav.apps,t[16]=a),t[17]!==n||t[18]!==a?(l=(0,Z.jsxs)(Ma,{to:`/settings/apps`,className:n,children:[i,a]}),t[17]=n,t[18]=a,t[19]=l):l=t[19];let d;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(Al,{className:`size-5 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),t[20]=d):d=t[20];let m;t[21]===r?m=t[22]:(m=r(`extensionDebug.nav`),t[21]=r,t[22]=m);let h;t[23]===m?h=t[24]:(h=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:m}),t[23]=m,t[24]=h),t[25]!==n||t[26]!==h?(u=(0,Z.jsxs)(Ma,{to:`/settings/extensions/debug`,className:n,children:[d,h]}),t[25]=n,t[26]=h,t[27]=u):u=t[27];let g;t[28]===n?g=t[29]:(g=e=>{let{extension:t,panel:r}=e;return(0,Z.jsxs)(Ma,{to:`/settings/ext/${t.id}/${r.id}`,className:n,children:[(0,Z.jsx)(Lv,{className:`size-5 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r.title})]},`${t.id}:${r.id}`)},t[28]=n,t[29]=g),f=e.map(g),t[2]=o.nav.apps,t[3]=o.settingsNavGroups.extensions,t[4]=n,t[5]=r,t[6]=s,t[7]=c,t[8]=l,t[9]=u,t[10]=f,t[11]=p}else c=t[7],l=t[8],u=t[9],f=t[10],p=t[11];let h;if(t[30]!==n||t[31]!==s){let e;t[33]===n?e=t[34]:(e=e=>(0,Z.jsxs)(Ma,{to:`/settings/ext/${e.id}`,className:n,children:[(0,Z.jsx)(Lv,{className:`size-5 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name})]},`${e.id}:config`),t[33]=n,t[34]=e),h=age(s).map(e),t[30]=n,t[31]=s,t[32]=h}else h=t[32];let g;t[35]!==c||t[36]!==l||t[37]!==u||t[38]!==f||t[39]!==h?(g=(0,Z.jsxs)(`div`,{className:c,children:[l,u,f,h]}),t[35]=c,t[36]=l,t[37]=u,t[38]=f,t[39]=h,t[40]=g):g=t[40];let _;return t[41]!==p||t[42]!==g?(_=(0,Z.jsxs)(`div`,{children:[p,g]}),t[41]=p,t[42]=g,t[43]=_):_=t[43],_}function rge(e){return e.language}function ige(e){let t=[];for(let n of e){let e=n.ui?.contributions?.settingsPanels;if(e)for(let r of e)t.push({extension:n,panel:r})}return t.sort((e,t)=>{let n=e.panel.order??999,r=t.panel.order??999;return n===r?e.panel.title.localeCompare(t.panel.title):n-r}),t}function age(e){return e.filter(e=>(!!e.hasConfigSchema||EI(e))&&!(Array.isArray(e.ui?.contributions?.settingsPanels)&&e.ui.contributions.settingsPanels.length>0))}var p8=[`chat`,`workspace`,`runtime`,`context`,`memory`,`tools`,`skills`,`system-prompt`];function m8(e){let t=(e??``).trim();return p8.includes(t)?t:`chat`}var h8={settingsAgentDefaults:`chat`,settingsAgentChat:`chat`,settingsAgentWorkspace:`workspace`,settingsAgentRuntime:`runtime`,settingsAgentContext:`context`,settingsAgentMemory:`memory`,settingsAgentTools:`tools`,settingsAgentSkills:`skills`,settingsAgentSystemPrompt:`system-prompt`};function g8(e){return e in h8}function oge(e,t){if(!g8(e))return!1;let n=h8[e];return!n||!t.pathname.replace(/\/+$/,``).endsWith(`/settings/agent-defaults`)?!1:m8(new URLSearchParams(t.search).get(`tab`))===n}var _8=`(max-width: 1199px)`,sge=`z-[58]`,v8=`z-[75]`,y8=`z-[76]`,b8=`z-[74]`,cge=`z-[77]`,x8=`/agents`;function lge(e){return`${x8}/${encodeURIComponent(e)}`}var S8=`settingsBackPath`;function C8(e){if(!e||typeof e!=`object`)return`/chat`;let t=e[S8];if(typeof t!=`string`)return`/chat`;let n=t.trim();return!n.startsWith(`/`)||n.startsWith(`//`)?`/chat`:n}var w8=`xopc-web-settings-rail-width-px`;function T8(e){return Math.min(360,Math.max(192,Math.round(e)))}function uge(){try{let e=globalThis.localStorage?.getItem(w8);if(e==null)return T8(228);let t=Number.parseInt(e,10);return T8(Number.isFinite(t)?t:228)}catch{return T8(228)}}function dge(e){try{globalThis.localStorage?.setItem(w8,String(e))}catch{}}var E8=c(e=>({widthPx:uge(),setWidthPx:t=>{let n=T8(t);e({widthPx:n}),queueMicrotask(()=>dge(n))}}));function D8({isActive:e}){return X(`flex w-full shrink-0 items-center gap-2.5 rounded-xl px-4 py-2 text-sm font-medium leading-6 transition-colors duration-200 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,e?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`)}var fge=X(`inline-flex max-w-full items-center gap-2 rounded-xl px-3 py-2 text-sm font-medium transition-colors duration-200 ease-out`,`text-fg-muted hover:bg-surface-hover hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`sm:px-4`);function pge(e){return e.tabs.filter(e=>!XA.has(e)||Oj())}function mge(e){let t=(0,Y.c)(25),{group:n,groupIndex:r,language:i,location:a}=e,o;t[0]===i?o=t[1]:(o=m(i),t[0]=i,t[1]=o);let s=o,c,l,u,d;if(t[2]!==n||t[3]!==r||t[4]!==i||t[5]!==a||t[6]!==s){d=Symbol.for(`react.early_return_sentinel`);bb0:{let e=pge(n);if(e.length===0){d=null;break bb0}let o=r===0&&`pt-0`,f;t[11]===o?f=t[12]:(f=X(`px-4 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wider text-fg-muted`,o),t[11]=o,t[12]=f);let p=s.settingsNavGroups[n.id];t[13]!==f||t[14]!==p?(u=(0,Z.jsx)(`p`,{className:f,children:p}),t[13]=f,t[14]=p,t[15]=u):u=t[15],c=`flex flex-col gap-0.5`;let m;t[16]!==i||t[17]!==a?(m=e=>(0,Z.jsxs)(Ma,{to:ij(e),className:t=>{let{isActive:n}=t;return D8({isActive:g8(e)?oge(e,a):n})},children:[(0,Z.jsx)(tge,{tab:e,className:`size-5 shrink-0 opacity-90`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:g(i,e)})]},e),t[16]=i,t[17]=a,t[18]=m):m=t[18],l=e.map(m)}t[2]=n,t[3]=r,t[4]=i,t[5]=a,t[6]=s,t[7]=c,t[8]=l,t[9]=u,t[10]=d}else c=t[7],l=t[8],u=t[9],d=t[10];if(d!==Symbol.for(`react.early_return_sentinel`))return d;let f;t[19]!==c||t[20]!==l?(f=(0,Z.jsx)(`div`,{className:c,children:l}),t[19]=c,t[20]=l,t[21]=f):f=t[21];let p;return t[22]!==u||t[23]!==f?(p=(0,Z.jsxs)(`div`,{children:[u,f]}),t[22]=u,t[23]=f,t[24]=p):p=t[24],p}var hge=(0,J.memo)(function(){let e=(0,Y.c)(66),t=d(gge),n;e[0]===t?n=e[1]:(n=m(t),e[0]=t,e[1]=n);let r=n,i=Yr(),a=E8(_ge),o=E8(vge),[s,c]=(0,J.useState)(!1),l=t8(_8),u,f,p,h,g,_,v;if(e[2]!==i.state||e[3]!==r.sidebar.back||e[4]!==r.sidebar.backToAgents||e[5]!==r.sidebar.backToApp||e[6]!==o||e[7]!==l||e[8]!==a||e[9]!==s){let t=l&&jj()?Mj():``,n;e[17]===o?n=e[18]:(n=e=>{e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId),c(!0);let n=e.clientX,r=E8.getState().widthPx,i=e.pointerId,a=e=>{o(r+(e.clientX-n))},s=()=>{try{t.releasePointerCapture(i)}catch{}c(!1),window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},e[17]=o,e[18]=n),f=n;let d;e[19]===i.state?d=e[20]:(d=C8(i.state),e[19]=i.state,e[20]=d);let m=d,y=m===`/chat`?r.sidebar.backToApp:m===`/agents`?r.sidebar.backToAgents:r.sidebar.back,b;e[21]===Symbol.for(`react.memo_cache_sentinel`)?(b=X(fge,dj),e[21]=b):b=e[21];let x;e[22]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(Ss,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),e[22]=x):x=e[22];let S;e[23]===y?S=e[24]:(S=(0,Z.jsx)(`span`,{children:y}),e[23]=y,e[24]=S);let C;e[25]!==y||e[26]!==m||e[27]!==S?(C=(0,Z.jsxs)(ja,{to:m,replace:!1,className:b,title:y,children:[x,S]}),e[25]=y,e[26]=m,e[27]=S,e[28]=C):C=e[28],u=C;let w;e[29]===Symbol.for(`react.memo_cache_sentinel`)?(w=[...QA,...Oj()?[ZA]:[]],e[29]=w):w=e[29],p=w,v=`flex min-h-0 flex-1 flex-col overflow-hidden md:flex-row`;let T=s&&`settings-page-rail-resizing`;e[30]===T?g=e[31]:(g=X(`relative flex shrink-0 flex-col bg-surface-base`,`md:h-full md:min-h-0 md:shrink-0 md:overflow-hidden`,`settings-page-rail`,T),e[30]=T,e[31]=g);let E=`${a}px`,D;e[32]===E?D=e[33]:(D={"--settings-rail-px":E},e[32]=E,e[33]=D),_=D;let O;e[34]===l?O=e[35]:(O=l&&jj()?`pr-4`:`px-4`,e[34]=l,e[35]=O),h=X(`flex shrink-0 items-center justify-start pb-2 pt-4`,uj,t,O),e[2]=i.state,e[3]=r.sidebar.back,e[4]=r.sidebar.backToAgents,e[5]=r.sidebar.backToApp,e[6]=o,e[7]=l,e[8]=a,e[9]=s,e[10]=u,e[11]=f,e[12]=p,e[13]=h,e[14]=g,e[15]=_,e[16]=v}else u=e[10],f=e[11],p=e[12],h=e[13],g=e[14],_=e[15],v=e[16];let y;e[36]!==u||e[37]!==h?(y=(0,Z.jsx)(`div`,{className:h,children:u}),e[36]=u,e[37]=h,e[38]=y):y=e[38];let b;e[39]===Symbol.for(`react.memo_cache_sentinel`)?(b=X(`min-h-0 overflow-y-auto overflow-x-hidden px-4 pb-3 pt-2 md:pb-4`,`max-h-[min(42vh,20rem)] md:max-h-none md:flex-1`),e[39]=b):b=e[39];let x=r.nav.settings,S;e[40]!==t||e[41]!==i||e[42]!==p?(S=p.map((e,n)=>(0,Z.jsx)(mge,{group:e,groupIndex:n,language:t,location:i},e.id)),e[40]=t,e[41]=i,e[42]=p,e[43]=S):S=e[43];let C;e[44]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Z.jsx)(nge,{navLinkClassName:D8}),e[44]=C):C=e[44];let w;e[45]===S?w=e[46]:(w=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[S,C]}),e[45]=S,e[46]=w);let T;e[47]!==r.nav.settings||e[48]!==w?(T=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col md:min-h-0`,children:(0,Z.jsx)(`nav`,{className:b,"aria-label":x,children:w})}),e[47]=r.nav.settings,e[48]=w,e[49]=T):T=e[49];let E=r.sidebar.resizeHandleAria,D=s&&`bg-surface-hover/30 before:!bg-edge/80 dark:before:!bg-edge/85`,O;e[50]===D?O=e[51]:(O=X(`pointer-events-auto absolute right-0 top-0 z-10 hidden h-full w-2 shrink-0 cursor-col-resize md:block`,`before:content-[''] before:pointer-events-none before:absolute before:left-1/2 before:top-0 before:z-0 before:h-full before:w-px before:-translate-x-1/2`,`before:bg-transparent before:transition-[background-color] before:duration-150`,`hover:bg-surface-hover/20 hover:before:bg-edge/65 dark:hover:before:bg-edge/75`,D,`transition-[background-color] duration-150`,`touch-none select-none`,dj),e[50]=D,e[51]=O);let k;e[52]!==r.sidebar.resizeHandleAria||e[53]!==f||e[54]!==O?(k=(0,Z.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":E,onPointerDown:f,className:O}),e[52]=r.sidebar.resizeHandleAria,e[53]=f,e[54]=O,e[55]=k):k=e[55];let A;e[56]!==T||e[57]!==k||e[58]!==g||e[59]!==_||e[60]!==y?(A=(0,Z.jsxs)(`div`,{className:g,style:_,children:[y,T,k]}),e[56]=T,e[57]=k,e[58]=g,e[59]=_,e[60]=y,e[61]=A):A=e[61];let j;e[62]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Z.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overflow-x-hidden overscroll-contain bg-surface-panel [scrollbar-gutter:stable_both-edges]`,children:(0,Z.jsx)(Li,{})}),e[62]=j):j=e[62];let M;return e[63]!==A||e[64]!==v?(M=(0,Z.jsxs)(`div`,{className:v,children:[A,j]}),e[63]=A,e[64]=v,e[65]=M):M=e[65],M});function gge(e){return e.language}function _ge(e){return e.widthPx}function vge(e){return e.setWidthPx}var O8=(0,J.createContext)(`default`);function yge(e,t){return e===`modal`||t===`modal`?`modal`:e===`page`||t===`page`?`page`:`default`}function k8(e){let t=(0,Y.c)(6),{layer:n,children:r}=e,i=(0,J.useContext)(O8),a;t[0]!==n||t[1]!==i?(a=yge(i,n),t[0]=n,t[1]=i,t[2]=a):a=t[2];let o;return t[3]!==r||t[4]!==a?(o=(0,Z.jsx)(O8.Provider,{value:a,children:r}),t[3]=r,t[4]=a,t[5]=o):o=t[5],o}function bge(){return(0,J.useContext)(O8)}var xge=(0,J.memo)(function(e){let t=(0,Y.c)(26),{children:n}=e,r=Qr(),i=Yr(),a=d(Sge),o;t[0]===a?o=t[1]:(o=m(a),t[0]=a,t[1]=o);let s=o,c;t[2]===i.state?c=t[3]:(c=C8(i.state),t[2]=i.state,t[3]=c);let l=c,u=t8(_8),f,p;t[4]!==l||t[5]!==r?(f=()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),r(l))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},p=[r,l],t[4]=l,t[5]=r,t[6]=f,t[7]=p):(f=t[6],p=t[7]),(0,J.useEffect)(f,p);let h;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(h=[],t[8]=h):h=t[8],(0,J.useEffect)(Cge,h);let g;t[9]!==l||t[10]!==r?(g=(0,Z.jsx)(`div`,{role:`presentation`,className:`absolute inset-0 z-40 bg-scrim/55 backdrop-blur-[2px] dark:bg-black/50`,onClick:()=>r(l)}),t[9]=l,t[10]=r,t[11]=g):g=t[11];let _=g,v;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(v=X(`relative z-50 flex min-h-0 flex-1 flex-col overflow-hidden bg-surface-panel`,`max-md:shadow-elevated`,`md:m-3 md:max-h-[calc(100dvh-1.5rem)] md:rounded-2xl md:border md:border-edge md:shadow-elevated`,`settings-sheet-enter`),t[12]=v):v=t[12];let y;t[13]===n?y=t[14]:(y=(0,Z.jsx)(k8,{layer:`page`,children:n}),t[13]=n,t[14]=y);let b;t[15]!==s.nav.settings||t[16]!==y?(b=(0,Z.jsx)(`div`,{className:v,role:`dialog`,"aria-modal":`true`,"aria-label":s.nav.settings,children:y}),t[15]=s.nav.settings,t[16]=y,t[17]=b):b=t[17];let x=b,S;t[18]!==x||t[19]!==_?(S=(0,Z.jsxs)(Z.Fragment,{children:[_,x]}),t[18]=x,t[19]=_,t[20]=S):S=t[20];let C=S;if(u){let e;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(e=X(`fixed inset-0 flex min-h-0 flex-col bg-surface-base`,sge),t[21]=e):e=t[21];let n;return t[22]===C?n=t[23]:(n=(0,Xa.createPortal)((0,Z.jsx)(`div`,{className:e,children:C}),document.body),t[22]=C,t[23]=n),n}let w;return t[24]===C?w=t[25]:(w=(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-h-[100dvh] flex-1 flex-col md:min-h-0`,children:C}),t[24]=C,t[25]=w),w});function Sge(e){return e.language}function Cge(){let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}}var wge=t({loadAttachment:()=>Tge});async function Tge(e,t){let n,r=t||`unnamed`,i=`application/octet-stream`,a=0;if(typeof e==`string`){let o=await fetch(e);if(!o.ok)throw Error(`Failed to fetch file`);if(n=await o.arrayBuffer(),a=n.byteLength,i=o.headers.get(`content-type`)||i,!t){let t=e.split(`/`);r=t[t.length-1]||`document`}}else if(e instanceof File)n=await e.arrayBuffer(),a=e.size,i=e.type||i,r=t||e.name;else if(e instanceof Blob)n=await e.arrayBuffer(),a=e.size,i=e.type||i;else if(e instanceof ArrayBuffer)n=e,a=e.byteLength;else throw Error(`Invalid source type`);let o=new Uint8Array(n),s=``,c=32768;for(let e=0;e<o.length;e+=c){let t=o.slice(e,e+c);s+=String.fromCharCode(...t)}let l=btoa(s),u=`${r}_${Date.now()}_${Math.random()}`;if(i===`application/pdf`||r.toLowerCase().endsWith(`.pdf`)){let{processPdf:e}=await D(async()=>{let{processPdf:e}=await import(`./attachment-process-heavy-CqVriadb.js`);return{processPdf:e}},__vite__mapDeps([24,1,21,23])),{extractedText:t,preview:i}=await e(n,r);return{id:u,type:`document`,name:r,mimeType:`application/pdf`,size:a,content:l,extractedText:t,preview:i}}if(i===`application/vnd.openxmlformats-officedocument.wordprocessingml.document`||r.toLowerCase().endsWith(`.docx`)){let{processDocx:e}=await D(async()=>{let{processDocx:e}=await import(`./attachment-process-heavy-CqVriadb.js`);return{processDocx:e}},__vite__mapDeps([24,1,21,23])),{extractedText:t}=await e(n,r);return{id:u,type:`document`,name:r,mimeType:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,size:a,content:l,extractedText:t}}if(i===`application/vnd.openxmlformats-officedocument.presentationml.presentation`||r.toLowerCase().endsWith(`.pptx`)){let{processPptx:e}=await D(async()=>{let{processPptx:e}=await import(`./attachment-process-heavy-CqVriadb.js`);return{processPptx:e}},__vite__mapDeps([24,1,21,23])),{extractedText:t}=await e(n,r);return{id:u,type:`document`,name:r,mimeType:`application/vnd.openxmlformats-officedocument.presentationml.presentation`,size:a,content:l,extractedText:t}}if([`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,`application/vnd.ms-excel`].includes(i)||r.toLowerCase().endsWith(`.xlsx`)||r.toLowerCase().endsWith(`.xls`)){let{processExcel:e}=await D(async()=>{let{processExcel:e}=await import(`./attachment-process-heavy-CqVriadb.js`);return{processExcel:e}},__vite__mapDeps([24,1,21,23])),{extractedText:t}=await e(n,r);return{id:u,type:`document`,name:r,mimeType:i&&i.startsWith(`application/vnd`)?i:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,size:a,content:l,extractedText:t}}if(i?.startsWith(`image/`))return{id:u,type:`image`,name:r,mimeType:i,size:a,content:l,preview:l};if(i?.startsWith(`audio/`))return{id:u,type:`voice`,name:r,mimeType:i,size:a,content:l};if(LL(r,i??``)){let e=new TextDecoder().decode(n);return{id:u,type:`document`,name:r,mimeType:i?.startsWith(`text/`)?i:`text/plain`,size:a,content:l,extractedText:e}}throw Error(`Unsupported file type: ${i}`)}var A8=`image/*,application/pdf,.docx,.pptx,.xlsx,.xls,.txt,.md,.json,.xml,.html,.css,.js,.ts,.jsx,.tsx,.yml,.yaml,.zip`,Ege=A8.split(`,`).flatMap(e=>{let t=e.trim();return t?[t]:[]});function Dge(e){return`${e.name}\0${e.size}`}function Oge(e){let t=(e.type||``).toLowerCase(),n=e.name.toLowerCase();for(let e of Ege){let r=e.toLowerCase();if(r.endsWith(`/*`)){let e=r.slice(0,-1);if(t.startsWith(e))return!0}else if(e.startsWith(`.`)){if(n.endsWith(e.toLowerCase()))return!0}else if(t===r)return!0}return!1}function kge(e){if(!e)return[];let t=new Set,n=[],r=e=>{if(!e||e.size===0)return;let r=Dge(e);t.has(r)||(t.add(r),n.push(e))},{files:i}=e;if(i?.length)for(let e=0;e<i.length;e++)r(i.item(e));for(let t of Array.from(e.items??[]))t.kind===`file`&&r(t.getAsFile());return n}var j8=String.raw`a-zA-Z0-9_./\-\p{L}\p{N}`,M8=`[${j8}]+`,N8=String.raw`(?:[^"\\]|\\.)*`,P8=String.raw`((?:[^"\\]|\\.)*)`,Age=RegExp(`^[${j8}]+$`,`u`);function jge(e){return e.replace(/\\(.)/g,(e,t)=>t)}var Mge=RegExp(`@file:(?:"${P8}"|(${M8}))`,`gu`),Nge=RegExp(`(@file:(?:"${N8}"|${M8}))$`,`u`),Pge=RegExp(`(@file:(?:"${N8}"|${M8}))([ \\t\\f\\v]*)$`,`u`),F8=`(?:"${N8}"|${M8})`;function Fge(e){let t=e.lastIndexOf(`@file:`);return t===-1?!1:RegExp(`^@file:${F8}$`,`u`).test(e.slice(t))}function I8(e){let t=e[2];if(t!=null&&t!==``)return t;let n=e[1];return n==null?``:jge(n)}function L8(e){return Age.test(e)?e:`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function R8(){return new RegExp(Mge.source,`gu`)}var z8=RegExp(`^@file:(?:"${P8}"|(${M8}))`,`u`),B8=`​`,V8=`⁠`,H8=RegExp(`^\\/skill:(${V$})`);function Ige(e){return!!e.dataset.skill}function Lge(e){return!!e.dataset.file}function Rge(e){return e.dataset.slashCommand!=null&&e.dataset.slashCommand!==``}function zge(e){let t=e.replace(/\/$/,``);return`@${t.split(`/`).pop()??t}`}function U8(e){let t=``;for(let n of e)if(n){if(t.length>0){let e=t[t.length-1],r=n[0];if(!/\s/.test(e)&&!/\s/.test(r)){let e=Fge(t)||/\/skill:\S+$/.test(t)||n1(t),r=n.startsWith(`@file:`)||n.startsWith(`/skill:`)||r1(n);(e||r)&&(t+=` `)}}t+=n}return t}function W8(e,t){if(e.nodeType===Node.TEXT_NODE)t.push((e.textContent??``).replaceAll(B8,``));else if(e.nodeType===Node.ELEMENT_NODE){let n=e;if(Ige(n)){let e=n.dataset.skill??``;e&&t.push(`/skill:${e}`)}else if(Lge(n)){let e=n.dataset.file??``;e&&t.push(`@file:${L8(e)}`)}else if(Rge(n)){let e=n.dataset.slashCommand??``;e&&t.push(`/${e}`)}else n.tagName===`BR`?t.push(`
4680
+ `):n.childNodes.forEach(e=>W8(e,t))}}function G8(e){let t=[];return e.childNodes.forEach(e=>W8(e,t)),U8(t).replaceAll(V8,``)}function Bge(e){let t=window.getSelection();if(!t)return;let n=document.createRange(),r=e.firstChild;r&&r.nodeType===Node.TEXT_NODE?(n.setStart(r,0),n.collapse(!0)):(n.setStart(e,0),n.collapse(!0)),t.removeAllRanges(),t.addRange(n)}function K8(e){let t=G8(e);return t.length>0||e.childNodes.length===0?t:(J8(e,``),Bge(e),``)}function Vge(e){let t=new Set,n=U$(),r;for(;(r=n.exec(e))!==null;){let e=r[1];e&&t.add(e)}return t}function q8(e){let t=window.getSelection();if(!t||t.rangeCount===0)return G8(e).length;let n=t.getRangeAt(0),r=document.createTextNode(V8);try{n.insertNode(r)}catch{return G8(e).length}let i=[];e.childNodes.forEach(e=>W8(e,i));let a=U8(i);r.parentNode?.removeChild(r);let o=a.indexOf(V8);return o>=0?o:a.replaceAll(V8,``).length}function Hge(e,t){let n=document.createElement(`span`);n.contentEditable=`false`,n.dataset.skill=t,n.className=`chat-skill-pill`,n.textContent=`/${t}`,e.appendChild(n),e.appendChild(document.createTextNode(B8))}function Uge(e,t){let n=document.createElement(`span`);n.contentEditable=`false`,n.dataset.file=t,n.className=`chat-file-pill`,n.textContent=zge(t),e.appendChild(n),e.appendChild(document.createTextNode(B8))}function Wge(e,t){let n=document.createElement(`span`);n.contentEditable=`false`,n.dataset.slashCommand=t,n.className=`chat-command-pill`,n.textContent=`/${t}`,e.appendChild(n),e.appendChild(document.createTextNode(B8))}function Gge(e){let t=[],n=n=>{let r,i=new RegExp(n.source,n.flags);for(;(r=i.exec(e))!==null;)t.push({start:r.index,end:r.index+r[0].length})};n(U$()),n(R8());for(let n of t1(e))t.push(n);return t.sort((e,t)=>e.start-t.start),t}function Kge(e,t){for(let{start:n,end:r}of Gge(e))if(t>n&&t<=r)return{wire:e.slice(0,n)+e.slice(r),caret:n};return null}function qge(e,t){if(t<=0)return null;let n=e.slice(0,t),r=r=>{let i=n.match(r);if(i?.[1]){let r=i[1],a=n.length-r.length;return{wire:e.slice(0,a)+e.slice(t),caret:a}}return null},i=[W$,Nge];for(let e of i){let t=r(e);if(t)return t}let a=o1(n);if(a){let n=a.tokenStart;return{wire:e.slice(0,n)+e.slice(t),caret:n}}if(t===e.length){let r=[G$,Pge];for(let i of r){let r=n.match(i);if(r?.[1]){let i=r[0],a=n.length-i.length;return{wire:e.slice(0,a)+e.slice(t),caret:a}}}let i=s1(n);if(i){let n=i.tokenStart;return{wire:e.slice(0,n)+e.slice(t),caret:n}}}return null}function Jge(e){let t=window.getSelection();if(!t||t.rangeCount===0||!t.isCollapsed)return!1;let n=t.getRangeAt(0),r=G8(e),i=q8(e);i===0&&r.length>0&&n.startContainer===e&&n.startOffset===e.childNodes.length&&(i=r.length);let a=Kge(r,i);return a||=qge(r,i),a?(J8(e,a.wire,a.caret),e.dispatchEvent(new InputEvent(`input`,{bubbles:!0})),!0):!1}function Yge(e,t){let n=e.slice(t);return H8.test(n)||z8.test(n)?!0:e1(e,t)!=null}function Xge(e,t,n){let r=t.slice(n),i=[],a=r.match(H8);a?.[0]&&i.push({len:a[0].length,apply:()=>Hge(e,a[1]??``)});let o=r.match(z8);o?.[0]&&i.push({len:o[0].length,apply:()=>Uge(e,I8(o))});let s=e1(t,n);if(s&&i.push({len:s.len,apply:()=>Wge(e,s.matchedKey)}),i.length===0){let r=n+1;for(;r<t.length&&!Yge(t,r);)r+=1;let i=t.slice(n,r);return i&&e.appendChild(document.createTextNode(i)),r}return i.sort((e,t)=>t.len-e.len),i[0].apply(),n+i[0].len}function J8(e,t,n){e.replaceChildren();let r=t;if(n!==void 0){let e=Math.max(0,Math.min(n,t.length));r=t.slice(0,e)+V8+t.slice(e)}let i=0;for(;i<r.length;)i=Xge(e,r,i);if(n===void 0)return;let a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),o;for(;o=a.nextNode();){let e=o.textContent??``,t=-1;for(let n=0;n<e.length;n++)if(e[n]===V8){t=n;break}if(t>=0){let n=o;n.textContent=e.slice(0,t)+e.slice(t+1);let r=window.getSelection(),i=document.createRange();i.setStart(n,t),i.collapse(!0),r?.removeAllRanges(),r?.addRange(i);return}}}function Zge(e,t){for(let n of e)if(n.isActive()&&n.handleKey(t))return!0;return!1}function Y8(e,t){e.classList.toggle(`composer-input-empty`,t.length===0)}function Qge(e){let{disabled:t,welcomeDraftSeed:n,onExternalTextReplace:r,shouldSyncSelectionRef:i}=e,[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(0),[l,u]=(0,J.useState)(!1),d=(0,J.useRef)(null),f=(0,J.useRef)(a),p=(0,J.useRef)(s),m=(0,J.useRef)(0),h=(0,J.useRef)(!0);f.current=a,p.current=s;let g=(0,J.useCallback)(()=>{let e=d.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,128)}px`)},[]),_=(0,J.useCallback)(e=>{let t=e?.nextText??``,n=e?.caretOffset??t.length;o(t),f.current=t,c(n),requestAnimationFrame(()=>{let r=d.current;r&&(J8(r,t,n),Y8(r,t),e?.focus&&r.focus({preventScroll:!0})),g()})},[g]);(0,J.useEffect)(()=>{g()},[a,g]);let v=(0,J.useRef)(n?.id??0);return n&&n.id!==v.current&&(v.current=n.id,m.current=n.id,r?.(),_({nextText:n.text,focus:!0})),(0,J.useLayoutEffect)(()=>{if(t){h.current=!0;return}if(!h.current)return;h.current=!1;let e=requestAnimationFrame(()=>{typeof globalThis.matchMedia==`function`&&globalThis.matchMedia(`(hover: hover) and (pointer: fine)`).matches&&d.current?.focus({preventScroll:!0})});return()=>cancelAnimationFrame(e)},[t]),(0,J.useEffect)(()=>{let e=d.current;if(!e)return;let t=!1,n=null,r=!1,a=-1,o=()=>{if(n=null,r=!1,document.activeElement!==e)return;let t=q8(e);p.current=t,t!==a&&(a=t,i.current&&c(t))},s=()=>{t&&(r||(r=!0,n=requestAnimationFrame(o)))},l=()=>{t||(t=!0,document.addEventListener(`selectionchange`,s),s())},u=()=>{t&&(t=!1,document.removeEventListener(`selectionchange`,s),n!=null&&cancelAnimationFrame(n),n=null,r=!1)},f=()=>l(),m=()=>u();return e.addEventListener(`focus`,f),e.addEventListener(`blur`,m),document.activeElement===e&&l(),()=>{e.removeEventListener(`focus`,f),e.removeEventListener(`blur`,m),u()}},[i]),(0,J.useEffect)(()=>{let e=e=>{let t=e.detail;typeof t?.text!=`string`||t.text.length===0||(r?.(),_({nextText:t.text,focus:!0}))};return window.addEventListener(b1,e),()=>window.removeEventListener(b1,e)},[r,_]),{value:a,cursor:s,isComposing:l,setIsComposing:u,editorRef:d,valueRef:f,setValue:o,setCursor:c,adjustHeight:g,resetEditor:_,onWireInput:(0,J.useCallback)((e,t)=>{f.current=e,o(e),c(t)},[])}}var $ge=(0,J.memo)(function(e){let t=(0,Y.c)(26),{editorRef:n,disabled:r,placeholder:i,onWireInput:a,adjustHeight:o,processFiles:s,setIsComposing:c,kbdRef:l,chatMessages:u}=e,d=(0,J.useRef)(!1),f=!r,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=X(`composer-input box-border m-0 max-h-32 min-h-10 w-full overflow-y-auto border-0 bg-transparent px-0 py-2 text-[0.9375rem] leading-6 text-fg focus:outline-none focus:ring-0 disabled:opacity-50`,`composer-input-empty`),t[0]=p):p=t[0];let m;t[1]!==o||t[2]!==a?(m=e=>{let t=e.currentTarget,n=d.current?G8(t):K8(t);Y8(t,n),a(n,q8(t)),o()},t[1]=o,t[2]=a,t[3]=m):m=t[3];let h;t[4]===c?h=t[5]:(h=()=>{d.current=!0,c(!0)},t[4]=c,t[5]=h);let g;t[6]!==o||t[7]!==n||t[8]!==a||t[9]!==c?(g=()=>{d.current=!1,c(!1),queueMicrotask(()=>{let e=n.current;if(!e||d.current)return;let t=K8(e);Y8(e,t),a(t,q8(e)),o()})},t[6]=o,t[7]=n,t[8]=a,t[9]=c,t[10]=g):g=t[10];let _;t[11]!==u||t[12]!==s?(_=async e=>{let t=e.clipboardData,n=kge(t??null),r=n.filter(Oge);if(r.length>0){e.preventDefault(),await s(r);return}if(n.length>0){e.preventDefault(),fH(`warning`,u.clipboardFileTypeUnsupported);return}let i=t?.getData(`text/plain`);i&&(e.preventDefault(),document.execCommand(`insertText`,!1,i))},t[11]=u,t[12]=s,t[13]=_):_=t[13];let v;t[14]!==n||t[15]!==l?(v=e=>{let t=l.current;if(e.key===`Backspace`&&!t.isComposing&&n.current&&Jge(n.current)){e.preventDefault();return}if(Zge(t.adapters,e))return;if(!t.isComposing&&(e.key===`ArrowUp`||e.key===`ArrowDown`)){let n=e.key===`ArrowUp`?`up`:`down`;if(t.tryInputHistoryArrow?.(n)){e.preventDefault(),t.adjustHeight();return}}if(e.key===`Escape`&&!t.isComposing&&t.editingFollowUpId){e.preventDefault(),t.onCancelEditFollowUp?.();return}if(e.key===`Enter`&&e.shiftKey&&!t.isComposing){e.preventDefault(),document.execCommand(`insertText`,!1,`
4681
+ `);return}let r=typeof KeyboardEvent<`u`&&e.nativeEvent instanceof KeyboardEvent&&e.nativeEvent.isComposing;if(e.key===`Enter`&&!e.shiftKey&&!t.isComposing&&!r){e.preventDefault();let n=!!(t.valueRef.current.trim()||t.attachmentsLen>0);if(t.runBusy||t.pendingFollowUpsCount>0){if((e.metaKey||e.ctrlKey)&&n){t.interruptDraft?.();return}if(!e.metaKey&&!e.ctrlKey&&!e.altKey&&n){t.flushSteeringDraft?.();return}return}n&&t.send()}},t[14]=n,t[15]=l,t[16]=v):v=t[16];let y;return t[17]!==n||t[18]!==i||t[19]!==f||t[20]!==m||t[21]!==h||t[22]!==g||t[23]!==_||t[24]!==v?(y=(0,Z.jsx)(`div`,{ref:n,role:`textbox`,"aria-multiline":`true`,"aria-label":i,contentEditable:f,suppressContentEditableWarning:!0,spellCheck:!0,className:p,"data-placeholder":i,onInput:m,onCompositionStart:h,onCompositionEnd:g,onPaste:_,onKeyDown:v}),t[17]=n,t[18]=i,t[19]=f,t[20]=m,t[21]=h,t[22]=g,t[23]=_,t[24]=v,t[25]=y):y=t[25],y}),e_e=(0,J.memo)(function(e){let t=(0,Y.c)(55),{items:n,disabled:r,editingFollowUpId:i,onEditInComposer:a,onRemove:o,onMove:s,onReorder:c,onSteer:l,steeringBusyId:u}=e,f=d(t_e),p;t[0]===f?p=t[1]:(p=m(f),t[0]=f,t[1]=p);let h=p,g=n_e,_;t[2]===c?_=t[3]:(_=e=>t=>{t.preventDefault();let n=t.dataTransfer.getData(`text/plain`);if(!n.startsWith(`xopc-followup:`))return;let r=Number.parseInt(n.slice(14),10);Number.isNaN(r)||r===e||c(r,e)},t[2]=c,t[3]=_);let v=_;if(n.length===0)return null;let y=h.chat.followUpQueueAria,b;t[4]===h.chat.followUpQueueHeading?b=t[5]:(b=(0,Z.jsx)(`span`,{className:`text-[0.65rem] font-medium uppercase tracking-wide text-fg-muted`,children:h.chat.followUpQueueHeading}),t[4]=h.chat.followUpQueueHeading,t[5]=b);let x;t[6]===n.length?x=t[7]:(x=(0,Z.jsxs)(`span`,{className:`tabular-nums text-[0.65rem] text-fg-muted`,children:[n.length,`/`,10]}),t[6]=n.length,t[7]=x);let S;t[8]!==b||t[9]!==x?(S=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-1 pb-0.5`,children:[b,x]}),t[8]=b,t[9]=x,t[10]=S):S=t[10];let C;if(t[11]!==r||t[12]!==i||t[13]!==n||t[14]!==h.chat.followUpQueueAttachmentOnly||t[15]!==h.chat.followUpQueueClickToEdit||t[16]!==h.chat.followUpQueueDrag||t[17]!==h.chat.followUpQueueEmptyPreview||t[18]!==h.chat.followUpQueueMoveDown||t[19]!==h.chat.followUpQueueMoveUp||t[20]!==h.chat.followUpQueueRemove||t[21]!==h.chat.followUpQueueSteerNow||t[22]!==v||t[23]!==a||t[24]!==s||t[25]!==o||t[26]!==l||t[27]!==u){let e;t[29]!==r||t[30]!==i||t[31]!==n.length||t[32]!==h.chat.followUpQueueAttachmentOnly||t[33]!==h.chat.followUpQueueClickToEdit||t[34]!==h.chat.followUpQueueDrag||t[35]!==h.chat.followUpQueueEmptyPreview||t[36]!==h.chat.followUpQueueMoveDown||t[37]!==h.chat.followUpQueueMoveUp||t[38]!==h.chat.followUpQueueRemove||t[39]!==h.chat.followUpQueueSteerNow||t[40]!==v||t[41]!==a||t[42]!==s||t[43]!==o||t[44]!==l||t[45]!==u?(e=(e,t)=>{let c=!e.attachments?.length&&e.text.trim().length>0,d=u===e.id,f=e.text.trim();return!f&&e.attachments?.length&&(f=e.attachments[0]?.name?.trim()||h.chat.followUpQueueAttachmentOnly),f||=h.chat.followUpQueueEmptyPreview,(0,Z.jsxs)(`div`,{role:`listitem`,onDragOver:g,onDrop:r?void 0:v(t),className:X(`flex h-7 items-center gap-1 rounded border px-1`,i===e.id?`border-accent/50 bg-accent-soft/20 dark:border-accent/50 dark:bg-accent-soft/10`:`border-edge-subtle/80 bg-surface-hover/25 dark:border-edge-subtle/90 dark:bg-surface-hover/15`),children:[(0,Z.jsx)(`div`,{draggable:!r,onDragStart:e=>{e.dataTransfer.setData(`text/plain`,`xopc-followup:${t}`),e.dataTransfer.effectAllowed=`move`},className:X(`flex shrink-0 cursor-grab items-center active:cursor-grabbing`,r&&`cursor-not-allowed opacity-40`),title:h.chat.followUpQueueDrag,children:(0,Z.jsx)(Um,{className:`size-3.5 text-fg-muted`,"aria-hidden":!0})}),(0,Z.jsx)(`button`,{type:`button`,disabled:r,title:h.chat.followUpQueueClickToEdit,"aria-label":h.chat.followUpQueueClickToEdit,className:X(`h-6 min-w-0 flex-1 truncate rounded px-1.5 text-left text-[0.75rem] leading-none text-fg hover:bg-surface-panel/60 dark:hover:bg-surface-panel/40`,AX.press,AX.focusRingPanel,`disabled:pointer-events-none disabled:opacity-50`),onClick:()=>a(e.id),children:e.attachments?.length?(0,Z.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1`,children:[(0,Z.jsx)(Af,{className:`size-3 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:f})]}):(0,Z.jsx)(`span`,{className:`block truncate`,children:f})}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-px`,children:[(0,Z.jsx)(`button`,{type:`button`,disabled:r||t===0,className:X(`inline-flex size-6 items-center justify-center rounded text-fg-muted hover:bg-surface-hover hover:text-fg`,AX.press,AX.focusRingPanel,`disabled:pointer-events-none disabled:opacity-25`),title:h.chat.followUpQueueMoveUp,"aria-label":h.chat.followUpQueueMoveUp,onClick:t=>{t.stopPropagation(),s(e.id,`up`)},children:(0,Z.jsx)(Il,{className:`size-3.5`,"aria-hidden":!0})}),(0,Z.jsx)(`button`,{type:`button`,disabled:r||t>=n.length-1,className:X(`inline-flex size-6 items-center justify-center rounded text-fg-muted hover:bg-surface-hover hover:text-fg`,AX.press,AX.focusRingPanel,`disabled:pointer-events-none disabled:opacity-25`),title:h.chat.followUpQueueMoveDown,"aria-label":h.chat.followUpQueueMoveDown,onClick:t=>{t.stopPropagation(),s(e.id,`down`)},children:(0,Z.jsx)(Nl,{className:`size-3.5`,"aria-hidden":!0})}),(0,Z.jsx)(`button`,{type:`button`,disabled:r||!c||d,className:X(`inline-flex size-6 items-center justify-center rounded text-accent-fg hover:bg-accent-soft/80`,AX.press,AX.focusRingPanel,`disabled:pointer-events-none disabled:opacity-35`),title:h.chat.followUpQueueSteerNow,"aria-label":h.chat.followUpQueueSteerNow,onClick:t=>{t.stopPropagation(),l(e.id)},children:(0,Z.jsx)(oS,{className:X(`size-3.5`,d&&`animate-pulse`),"aria-hidden":!0})}),(0,Z.jsx)(`button`,{type:`button`,disabled:r,className:X(`inline-flex size-6 items-center justify-center rounded text-fg-muted hover:bg-red-500/15 hover:text-red-600 dark:hover:text-red-400`,AX.press,AX.focusRingPanel),title:h.chat.followUpQueueRemove,"aria-label":h.chat.followUpQueueRemove,onClick:t=>{t.stopPropagation(),o(e.id)},children:(0,Z.jsx)(oO,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id)},t[29]=r,t[30]=i,t[31]=n.length,t[32]=h.chat.followUpQueueAttachmentOnly,t[33]=h.chat.followUpQueueClickToEdit,t[34]=h.chat.followUpQueueDrag,t[35]=h.chat.followUpQueueEmptyPreview,t[36]=h.chat.followUpQueueMoveDown,t[37]=h.chat.followUpQueueMoveUp,t[38]=h.chat.followUpQueueRemove,t[39]=h.chat.followUpQueueSteerNow,t[40]=v,t[41]=a,t[42]=s,t[43]=o,t[44]=l,t[45]=u,t[46]=e):e=t[46],C=n.map(e),t[11]=r,t[12]=i,t[13]=n,t[14]=h.chat.followUpQueueAttachmentOnly,t[15]=h.chat.followUpQueueClickToEdit,t[16]=h.chat.followUpQueueDrag,t[17]=h.chat.followUpQueueEmptyPreview,t[18]=h.chat.followUpQueueMoveDown,t[19]=h.chat.followUpQueueMoveUp,t[20]=h.chat.followUpQueueRemove,t[21]=h.chat.followUpQueueSteerNow,t[22]=v,t[23]=a,t[24]=s,t[25]=o,t[26]=l,t[27]=u,t[28]=C}else C=t[28];let w;t[47]!==n||t[48]!==h.chat.followUpQueueAttachmentsNote?(w=n.some(r_e)?(0,Z.jsx)(`p`,{className:`px-1 pt-0.5 text-[0.65rem] leading-tight text-fg-muted`,children:h.chat.followUpQueueAttachmentsNote}):null,t[47]=n,t[48]=h.chat.followUpQueueAttachmentsNote,t[49]=w):w=t[49];let T;return t[50]!==h.chat.followUpQueueAria||t[51]!==S||t[52]!==C||t[53]!==w?(T=(0,Z.jsxs)(`div`,{className:`space-y-0.5 px-2 py-1.5`,role:`list`,"aria-label":y,children:[S,C,w]}),t[50]=h.chat.followUpQueueAria,t[51]=S,t[52]=C,t[53]=w,t[54]=T):T=t[54],T});function t_e(e){return e.language}function n_e(e){e.preventDefault(),e.dataTransfer.dropEffect=`move`}function r_e(e){return e.attachments?.length}function i_e(e){let t=(0,Y.c)(10),{attachments:n,topPadded:r,onRemove:i}=e;if(n.length===0)return null;let a=r?`pt-2`:`pt-3`,o;t[0]===a?o=t[1]:(o=X(`flex flex-wrap gap-2 border-b border-edge-subtle/90 bg-surface-hover/20 px-4 pb-2 dark:border-edge-subtle`,a),t[0]=a,t[1]=o);let s;if(t[2]!==n||t[3]!==i){let e;t[5]===i?e=t[6]:(e=(e,t)=>(0,Z.jsxs)(`div`,{className:`flex max-w-[200px] items-center gap-1.5 rounded-lg bg-surface-hover px-2 py-1 text-xs dark:bg-surface-hover/80`,children:[e.mimeType?.startsWith(`image/`)&&e.content?(0,Z.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.content}`,alt:``,className:`size-6 rounded object-cover`}):e.type===`voice`||e.mimeType?.startsWith(`audio/`)?(0,Z.jsx)(Mg,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,Z.jsx)(Af,{className:`size-3.5 shrink-0 text-fg-muted`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,Z.jsx)(`span`,{className:`text-fg-disabled`,children:PL(e.size)}),(0,Z.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,onClick:()=>i(t),children:`×`})]},e.id??`${e.name}-${e.size}-${e.mimeType}-${e.content?.slice(0,16)??``}`),t[5]=i,t[6]=e),s=n.map(e),t[2]=n,t[3]=i,t[4]=s}else s=t[4];let c;return t[7]!==o||t[8]!==s?(c=(0,Z.jsx)(`div`,{className:o,children:s}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}var a_e=4;function X8(e){return!Number.isFinite(e)||e<=0?0:Math.ceil(e/a_e)}function o_e(e){return e.inputTokens!=null||e.outputTokens!=null?(e.inputTokens??0)+(e.outputTokens??0):e.totalTokens==null?null:e.totalTokens}function Z8(e){let t=0;for(let n of e.content)n.type===`text`||n.type===`thinking`?t+=n.text.length:n.type===`tool_use`&&(t+=JSON.stringify(n.input??``).length,n.result!=null&&(t+=typeof n.result==`string`?n.result.length:JSON.stringify(n.result).length));if(e.attachments?.length)for(let n of e.attachments)t+=(n.extractedText?.length??0)+(n.name?.length??0);return X8(t)}function s_e(e,t=0){for(let n=e.length-1;n>=0;n--){let r=e[n];if(r.role!==`assistant`||!r.usage)continue;let i=o_e(r.usage);if(i==null||i<=0)continue;let a=0;for(let t=n+1;t<e.length;t++)a+=Z8(e[t]);return i+a+X8(t)}let n=0;for(let t of e)n+=Z8(t);return n+X8(t)}function Q8(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var $8=7,e5=2.25,t5=2*Math.PI*$8;function n5(e){if(!Number.isFinite(e)||e<0)return`0`;if(e>=1e6){let t=e/1e6;return`${t>=10?Math.round(t):t.toFixed(1)}M`.replace(/\.0M$/,`M`)}if(e>=1e4)return`${Math.round(e/1e3)}k`;if(e>=1e3){let t=e/1e3;return`${t>=10?Math.round(t):t.toFixed(1)}k`.replace(/\.0k$/,`k`)}return String(Math.round(e))}function c_e(e,t){if(!Number.isFinite(e)||!Number.isFinite(t)||t<=0)return`0`;let n=Math.min(100,Math.max(0,100*e/t));return n>=10||n===0?String(Math.round(n)):n.toFixed(1).replace(/\.0$/,``)}var l_e=(0,J.memo)(function(e){let t=(0,Y.c)(35),{sessionModel:n,messages:r,draftChars:i,chat:a,disabled:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},t[0]=s):s=t[0];let{data:c}=v(s8,c8,s),l;t[1]===c?l=t[2]:(l=c===void 0?[]:c,t[1]=c,t[2]=l);let u=l,d;t[3]!==u||t[4]!==n?(d=u.find(e=>e.id===n)?.contextWindow,t[3]=u,t[4]=n,t[5]=d):d=t[5];let f=d,p=s_e(r,i),m=(f!=null&&f>0?Math.min(1,Math.max(0,p/f)):0)*t5,h;bb0:{if(f!=null&&f>0){let e;t[6]!==a.contextWindowAriaSummary||t[7]!==f||t[8]!==p?(e=Q8(a.contextWindowAriaSummary,{used:n5(p),limit:n5(f)}),t[6]=a.contextWindowAriaSummary,t[7]=f,t[8]=p,t[9]=e):e=t[9],h=e;break bb0}let e;t[10]!==a.contextWindowAriaSummaryNoLimit||t[11]!==p?(e=Q8(a.contextWindowAriaSummaryNoLimit,{used:n5(p)}),t[10]=a.contextWindowAriaSummaryNoLimit,t[11]=p,t[12]=e):e=t[12],h=e}let g=h,_;bb1:{if(f!=null&&f>0){let e;t[13]!==a.contextWindowHoverShort||t[14]!==f||t[15]!==p?(e=Q8(a.contextWindowHoverShort,{percent:c_e(p,f)}),t[13]=a.contextWindowHoverShort,t[14]=f,t[15]=p,t[16]=e):e=t[16],_=e;break bb1}let e;t[17]!==a.contextWindowHoverNoLimit||t[18]!==p?(e=Q8(a.contextWindowHoverNoLimit,{used:n5(p)}),t[17]=a.contextWindowHoverNoLimit,t[18]=p,t[19]=e):e=t[19],_=e}let y=_,b=o||void 0,x=o&&`cursor-default opacity-40`,S;t[20]===x?S=t[21]:(S=X(`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-subtle`,`hover:bg-surface-hover hover:text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,x),t[20]=x,t[21]=S);let C;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Z.jsx)(`circle`,{cx:`9`,cy:`9`,r:$8,fill:`none`,stroke:`currentColor`,className:`text-fg-subtle opacity-[0.35]`,strokeWidth:e5}),t[22]=C):C=t[22];let w=`${m} ${t5}`,T;t[23]===w?T=t[24]:(T=(0,Z.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 18 18`,className:`shrink-0`,"aria-hidden":!0,children:[C,(0,Z.jsx)(`circle`,{cx:`9`,cy:`9`,r:$8,fill:`none`,stroke:`currentColor`,className:`text-fg-muted`,strokeWidth:e5,strokeLinecap:`round`,strokeDasharray:w,transform:`rotate(-90 9 9)`})]}),t[23]=w,t[24]=T);let E;t[25]!==g||t[26]!==T||t[27]!==b||t[28]!==S?(E=(0,Z.jsx)(wZ,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,"aria-disabled":b,"aria-label":g,className:S,children:T})}),t[25]=g,t[26]=T,t[27]=b,t[28]=S,t[29]=E):E=t[29];let D;t[30]===y?D=t[31]:(D=(0,Z.jsx)(TZ,{children:(0,Z.jsx)(EZ,{side:`top`,sideOffset:6,collisionPadding:12,className:`!z-[10000] whitespace-nowrap rounded-lg border border-edge bg-surface-panel px-2 py-1 text-xs font-medium text-fg shadow-md`,children:y})}),t[30]=y,t[31]=D);let O;return t[32]!==E||t[33]!==D?(O=(0,Z.jsx)(SZ,{delayDuration:280,children:(0,Z.jsxs)(CZ,{children:[E,D]})}),t[32]=E,t[33]=D,t[34]=O):O=t[34],O});function u_e(e){switch(e){case`modal`:return cge;case`page`:return b8;default:return`z-50`}}function d_e(e){return`${e.id} ${e.name} ${e.provider}`.toLowerCase()}function f_e(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=n.split(/\s+/).filter(Boolean);return e.filter(e=>{let t=d_e(e);return r.every(e=>t.includes(e))})}function p_e(e,t,n){if(t!==`vision`)return e;let r=e.filter(e=>e.vision===!0);if(!n||r.some(e=>e.id===n))return r;let i=e.find(e=>e.id===n);if(i)return[i,...r];let a=n.indexOf(`/`),o=a>=0?n.slice(0,a):``;return[{id:n,name:(a>=0?n.slice(a+1):n)||n,provider:o||`—`,vision:!1},...r]}function r5(e){let t=(0,Y.c)(84),{value:n,disabled:r,placeholder:i,searchPlaceholder:a,noMatches:o,capabilitiesFilter:s,outOfFilterNote:c,registryEmptyHint:l,compact:u,showProviderInTrigger:f,contentSide:p,contentAlign:h,className:g,popoverContentClassName:_,showProviderSettingsFooter:y,onChange:b}=e,x=f===void 0?!0:f,S=p===void 0?`bottom`:p,C=h===void 0?`end`:h,w=Qr(),T=d(h_e),E;t[0]===T?E=t[1]:(E=m(T),t[0]=T,t[1]=E);let D=E.chat,[O,k]=(0,J.useState)(!1),[A,j]=(0,J.useState)(``),M=u_e(bge()),N;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(N={revalidateOnFocus:!1},t[2]=N):N=t[2];let{data:P,isLoading:F,error:I}=v(s8,c8,N),L;t[3]===P?L=t[4]:(L=P===void 0?[]:P,t[3]=P,t[4]=L);let R=L,z;t[5]===n?z=t[6]:(z=n.trim(),t[5]=n,t[6]=z);let B=z,V;t[7]!==s||t[8]!==R||t[9]!==B?(V=p_e(R,s,B),t[7]=s,t[8]=R,t[9]=B,t[10]=V):V=t[10];let H=V,U;t[11]!==H||t[12]!==A?(U=f_e(H,A),t[11]=H,t[12]=A,t[13]=U):U=t[13];let W=U,G;t[14]!==R||t[15]!==H||t[16]!==n?(G=R.find(e=>e.id===n)??H.find(e=>e.id===n),t[14]=R,t[15]=H,t[16]=n,t[17]=G):G=t[17];let ee=G,K=ee?x?`${ee.name} (${ee.provider})`:ee.name:n||i,te=!I&&s===`vision`&&H.length===0,ne=UP,re=r||F,ie=ee?`${ee.name} (${ee.provider})`:i,ae=u&&`py-1.5 text-[13px]`,oe;t[18]!==g||t[19]!==ae?(oe=X(jA,`items-center gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2 text-left text-sm font-normal text-fg`,AX.transition,`hover:border-edge hover:bg-surface-hover/45`,DA,`disabled:cursor-not-allowed disabled:opacity-50`,`dark:border-edge-subtle dark:hover:bg-surface-hover/55`,ae,g),t[18]=g,t[19]=ae,t[20]=oe):oe=t[20];let se=F?`…`:K,q;t[21]===se?q=t[22]:(q=(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:se}),t[21]=se,t[22]=q);let ce;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,Z.jsx)(Ll,{className:`size-4 shrink-0 text-fg-subtle opacity-70`,"aria-hidden":!0}),t[23]=ce):ce=t[23];let le;t[24]!==re||t[25]!==ie||t[26]!==oe||t[27]!==q?(le=(0,Z.jsx)(vF,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,disabled:re,title:ie,className:oe,children:[q,ce]})}),t[24]=re,t[25]=ie,t[26]=oe,t[27]=q,t[28]=le):le=t[28];let ue=UP,de=UP,fe=X(M,`w-[min(22rem,calc(100vw-2rem))] rounded-xl border border-edge-subtle bg-surface-panel p-1 shadow-elevated dark:border-edge-subtle`,_),pe;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(pe=X(`mb-1 w-full rounded-lg border border-edge-subtle bg-surface-base px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-disabled dark:bg-surface-hover/40`,OA),t[29]=pe):pe=t[29];let me;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(me=e=>j(e.target.value),t[30]=me):me=t[30];let he;t[31]!==A||t[32]!==a?(he=(0,Z.jsx)(`input`,{type:`search`,className:pe,placeholder:a,value:A,onChange:me}),t[31]=A,t[32]=a,t[33]=he):he=t[33];let ge;t[34]===I?ge=t[35]:(ge=I?(0,Z.jsx)(`div`,{className:`p-2 text-xs text-red-600 dark:text-red-400`,children:I instanceof Error?I.message:`Failed to load models`}):null,t[34]=I,t[35]=ge);let _e;t[36]!==I||t[37]!==o||t[38]!==l||t[39]!==te?(_e=!I&&te?(0,Z.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:l??o}):null,t[36]=I,t[37]=o,t[38]=l,t[39]=te,t[40]=_e):_e=t[40];let ve;t[41]!==I||t[42]!==W.length||t[43]!==o||t[44]!==te?(ve=!I&&!te&&W.length===0?(0,Z.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:o}):null,t[41]=I,t[42]=W.length,t[43]=o,t[44]=te,t[45]=ve):ve=t[45];let ye;if(t[46]!==s||t[47]!==W||t[48]!==b||t[49]!==c||t[50]!==n||t[51]!==B){let e;t[53]!==s||t[54]!==b||t[55]!==c||t[56]!==n||t[57]!==B?(e=e=>{let t=!!c&&s===`vision`&&e.vision!==!0&&e.id===B;return(0,Z.jsxs)(`button`,{type:`button`,className:X(`flex w-full flex-col gap-0.5 rounded-md px-2 py-1.5 text-left text-sm text-fg hover:bg-surface-hover`,e.id===n&&`bg-surface-hover/90 font-medium dark:bg-surface-hover/70`),onClick:()=>{b(e.id),k(!1),j(``)},children:[(0,Z.jsxs)(`span`,{className:`flex w-full min-w-0 items-center gap-2`,children:[(0,Z.jsx)(Ml,{className:X(`size-4 shrink-0`,e.id!==n&&`invisible`),"aria-hidden":!0}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:e.name}),` `,(0,Z.jsxs)(`span`,{className:`text-fg-muted`,children:[`(`,e.provider,`)`]})]})]}),t?(0,Z.jsx)(`span`,{className:`pl-6 text-[11px] leading-snug text-amber-700 dark:text-amber-300`,children:c}):null]},e.id)},t[53]=s,t[54]=b,t[55]=c,t[56]=n,t[57]=B,t[58]=e):e=t[58],ye=W.map(e),t[46]=s,t[47]=W,t[48]=b,t[49]=c,t[50]=n,t[51]=B,t[52]=ye}else ye=t[52];let be;t[59]!==ge||t[60]!==_e||t[61]!==ve||t[62]!==ye?(be=(0,Z.jsxs)(`div`,{className:`max-h-60 overflow-auto`,children:[ge,_e,ve,ye]}),t[59]=ge,t[60]=_e,t[61]=ve,t[62]=ye,t[63]=be):be=t[63];let xe;t[64]!==D||t[65]!==w||t[66]!==y?(xe=y?(0,Z.jsx)(`div`,{className:`mt-1 border-t border-edge-subtle pt-1`,children:(0,Z.jsxs)(`button`,{type:`button`,className:X(`flex w-full items-center gap-2 rounded-md p-2 text-left text-sm font-medium text-accent`,AX.transition,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),onClick:()=>{w(`/settings/providers`),k(!1),j(``)},children:[(0,Z.jsx)(qb,{className:`size-4 shrink-0 opacity-90`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0`,children:D.modelProviderSettingsLink})]})}):null,t[64]=D,t[65]=w,t[66]=y,t[67]=xe):xe=t[67];let Se;t[68]!==C||t[69]!==S||t[70]!==de.Content||t[71]!==fe||t[72]!==he||t[73]!==be||t[74]!==xe?(Se=(0,Z.jsxs)(de.Content,{className:fe,side:S,sideOffset:4,align:C,onOpenAutoFocus:m_e,children:[he,be,xe]}),t[68]=C,t[69]=S,t[70]=de.Content,t[71]=fe,t[72]=he,t[73]=be,t[74]=xe,t[75]=Se):Se=t[75];let Ce;t[76]!==ue.Portal||t[77]!==Se?(Ce=(0,Z.jsx)(ue.Portal,{children:Se}),t[76]=ue.Portal,t[77]=Se,t[78]=Ce):Ce=t[78];let we;return t[79]!==O||t[80]!==ne.Root||t[81]!==le||t[82]!==Ce?(we=(0,Z.jsxs)(ne.Root,{open:O,onOpenChange:k,children:[le,Ce]}),t[79]=O,t[80]=ne.Root,t[81]=le,t[82]=Ce,t[83]=we):we=t[83],we}function m_e(e){return e.preventDefault()}function h_e(e){return e.language}var i5=`xopc.recentWorkspaceDirs.v1`,g_e=10;function __e(){try{let e=localStorage.getItem(i5);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`&&e.trim().length>0):[]}catch{return[]}}function v_e(e){let t=e.trim();if(t)try{let e=[t,...__e().filter(e=>e!==t)].slice(0,g_e);localStorage.setItem(i5,JSON.stringify(e))}catch{}}function a5(e){let t=e.trim().replace(/[/\\]+$/,``);if(!t)return e;let n=t.split(/[/\\]/);return n[n.length-1]||t}function o5(e){let t=(0,Y.c)(27),{value:n,onPick:r,disabled:i,placeholder:a,title:o,className:s,maxWidthClass:c,compact:l,"aria-label":u}=e,d=c===void 0?`max-w-[min(12rem,40vw)]`:c,f=l===void 0?!1:l,p,m;t[0]!==a||t[1]!==n?(m=n.trim(),p=m?a5(m):a??``,t[0]=a,t[1]=n,t[2]=p,t[3]=m):(p=t[2],m=t[3]);let h=p,g=o??(m||void 0),_=u??o??h,v=f?`inline-flex size-9 shrink-0 items-center justify-center rounded-lg p-0`:`inline-flex min-h-8 min-w-0 shrink-0 items-center gap-1 rounded-lg px-2 py-1 text-xs`,y=!f&&d,b=i&&`cursor-not-allowed opacity-60`,x;t[4]!==s||t[5]!==v||t[6]!==y||t[7]!==b?(x=X(v,`border border-edge-subtle/80 bg-surface-hover/40 dark:border-edge-subtle`,AX.transition,AX.focusRingPanel,`cursor-pointer hover:bg-surface-hover/70 dark:hover:bg-surface-hover/50`,y,b,s),t[4]=s,t[5]=v,t[6]=y,t[7]=b,t[8]=x):x=t[8];let S;t[9]!==i||t[10]!==r?(S=e=>{e.stopPropagation(),i||r()},t[9]=i,t[10]=r,t[11]=S):S=t[11];let C=f?`size-4`:`size-3.5`,w;t[12]===C?w=t[13]:(w=X(`shrink-0 text-fg-muted`,C),t[12]=C,t[13]=w);let T;t[14]===w?T=t[15]:(T=(0,Z.jsx)(hp,{className:w,"aria-hidden":!0}),t[14]=w,t[15]=T);let E;t[16]!==f||t[17]!==h?(E=f?null:(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-left font-medium text-fg`,children:h}),t[16]=f,t[17]=h,t[18]=E):E=t[18];let D;return t[19]!==i||t[20]!==S||t[21]!==T||t[22]!==E||t[23]!==g||t[24]!==_||t[25]!==x?(D=(0,Z.jsxs)(`button`,{type:`button`,disabled:i,title:g,"aria-label":_,className:x,onClick:S,children:[T,E]}),t[19]=i,t[20]=S,t[21]=T,t[22]=E,t[23]=g,t[24]=_,t[25]=x,t[26]=D):D=t[26],D}async function y_e(e){let t=typeof window<`u`?window.electronAPI?.file?.openDirectory:void 0;if(!t)return null;let n=e?.trim();return n?t({defaultPath:n}):t()}function s5(e={}){let{initialPath:t,onPicked:n,trackRecent:r=!0}=e,[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(!1),c=typeof window<`u`&&!!window.electronAPI?.file?.openDirectory,l=(0,J.useCallback)(async e=>{let t=e.trim();t&&(r&&v_e(t),await n?.(t))},[n,r]);return{hasNativePicker:c,modalOpen:i,setModalOpen:a,pick:(0,J.useCallback)(()=>{if(c){(async()=>{s(!0);try{let e=await y_e(t);e&&await l(e)}finally{s(!1)}})();return}a(!0)},[l,c,t]),confirmPick:l,picking:o}}function b_e(){return function(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`patch`:return{...e,form:e.form?{...e.form,...t.patch}:null};case`discard`:return e.baseline?{form:structuredClone(e.baseline),baseline:e.baseline}:e;case`saved`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`set-form`:return e.form?{...e,form:t.updater(e.form)}:e}}}function c5(e,t){return{...e,...t.patch}}function x_e(e){let{enabled:t,parsed:n,dirty:r,trackedParsedRef:i,dispatch:a,onResetDirty:o}=e;if(!t){i.current!==null&&(i.current=null,a({type:`reset`}),o?.());return}n!==null&&!r&&i.current!==n&&(i.current=n,a({type:`sync`,value:n}))}async function l5(e){let t=new URLSearchParams;e!=null&&e!==``&&t.set(`path`,e);let n=t.toString();return(await we(_(`/api/host/fs/list${n?`?${n}`:``}`))).payload}async function S_e(){return(await we(_(`/api/host/fs/meta`))).payload}function C_e(){return X(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-sm text-fg`,`placeholder:text-fg-subtle`,kA,`dark:border-edge`)}function u5(e){return/^[A-Za-z]:\\?$/.test(e.replace(/\\$/,`\\`))}function w_e(e){return!e||e.currentPath===``?!1:e.parentPath===null?e.currentPath===`/`?!1:!!u5(e.currentPath):!0}var T_e={metaHostname:null,listState:null,listLoading:!1,listError:null,manualPath:``};function d5({open:e,onOpenChange:t,initialAbsolutePath:n,onConfirm:r,wd:i}){let a=(0,J.useId)(),[o,s]=(0,J.useReducer)(c5,T_e),{metaHostname:c,listState:l,listLoading:u,listError:d,manualPath:f}=o,p=(0,J.useCallback)(async e=>{s({type:`patch`,patch:{listLoading:!0,listError:null}});try{s({type:`patch`,patch:{listState:await l5(e)}})}catch(e){s({type:`patch`,patch:{listError:e instanceof Error?e.message:String(e),listState:null}})}finally{s({type:`patch`,patch:{listLoading:!1}})}},[]);(0,J.useEffect)(()=>{if(!e)return;let t=!1;return(async()=>{try{let e=await S_e();t||s({type:`patch`,patch:{metaHostname:e.hostname}})}catch{t||s({type:`patch`,patch:{metaHostname:null}})}})(),()=>{t=!0}},[e]),(0,J.useEffect)(()=>{if(!e)return;let t=n?.trim()??``;s({type:`patch`,patch:{manualPath:t}});let r=!1;return(async()=>{s({type:`patch`,patch:{listLoading:!0,listError:null}});try{if(t)try{let e=await l5(t);r||s({type:`patch`,patch:{listState:e}})}catch{let e=await l5();r||s({type:`patch`,patch:{listState:e}})}else{let e=await l5();r||s({type:`patch`,patch:{listState:e}})}}catch(e){let t=e instanceof Error?e.message:String(e);r||s({type:`patch`,patch:{listError:t,listState:null}})}finally{r||s({type:`patch`,patch:{listLoading:!1}})}})(),()=>{r=!0}},[e,n]);let m=e=>{e.isDirectory&&p(e.absolutePath)},h=()=>{if(!l)return;let{parentPath:e,currentPath:t}=l;if(e!==null){p(e);return}t===`/`||t===``||u5(t)&&p(void 0)},g=l?.currentPath===``?i.pickerDrives:l?.currentPath??``,_=!!l&&l.currentPath!==``&&!u&&!d,v=async()=>{if(!(!l||l.currentPath===``))try{await r(l.currentPath),t(!1)}catch{}},y=async()=>{let e=f.trim();if(e)try{await r(e),t(!1)}catch{}},b=u&&l;return(0,Z.jsx)(q,{open:e,onOpenChange:t,children:(0,Z.jsxs)(G,{children:[(0,Z.jsx)(ie,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Z.jsxs)(se,{className:X(`fixed left-1/2 top-1/2 z-[81] flex max-h-[min(90vh,32rem)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 flex-col rounded-xl border border-edge bg-surface-panel p-4 shadow-popover`,`dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsx)(ue,{className:`text-base font-semibold text-fg`,children:i.pathModalTitle}),(0,Z.jsx)(le,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:i.pathModalDescription}),c?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:i.pickerHostHint.replace(`{{hostname}}`,c)}):null,(0,Z.jsxs)(`div`,{className:`mt-3 flex min-h-0 flex-1 flex-col gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(wA,{type:`button`,variant:`secondary`,className:`shrink-0 gap-1 px-2 py-1.5 text-xs`,disabled:u||!w_e(l)||!!d,onClick:()=>h(),title:i.pickerUp,children:[(0,Z.jsx)(Il,{className:`size-4`,"aria-hidden":!0}),i.pickerUp]}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 truncate rounded-md border border-edge-subtle/80 bg-surface-hover/30 px-2 py-1.5 font-mono text-xs text-fg`,title:g,children:u&&!l?i.pickerLoading:g||`—`})]}),(0,Z.jsxs)(`div`,{className:X(`relative min-h-[12rem] overflow-y-auto rounded-lg border border-edge-subtle/80 bg-surface-hover/20 p-1 dark:border-edge-subtle`,AX.focusRingPanel),role:`listbox`,"aria-label":i.pathModalTitle,children:[b?(0,Z.jsx)(`div`,{className:`absolute inset-0 z-[1] flex items-center justify-center rounded-lg bg-surface-panel/60`,"aria-hidden":!0,children:(0,Z.jsx)(Cg,{className:`size-6 animate-spin text-fg-muted`})}):null,u&&!l?(0,Z.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-12 text-sm text-fg-muted`,children:[(0,Z.jsx)(Cg,{className:`size-4 animate-spin`,"aria-hidden":!0}),i.pickerLoading]}):null,d?(0,Z.jsx)(`p`,{className:`px-2 py-8 text-center text-sm text-fg-muted`,children:i.pickerListError}):null,!u&&l&&!d&&l.entries.length===0?(0,Z.jsx)(`p`,{className:`px-2 py-8 text-center text-sm text-fg-muted`,children:i.pickerEmptyFolder}):null,l?.entries.map(e=>(0,Z.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":!1,disabled:!e.isDirectory,className:X(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm`,e.isDirectory?`cursor-pointer text-fg hover:bg-surface-hover`:`cursor-default text-fg-muted opacity-60`),onClick:()=>m(e),children:[(0,Z.jsx)(hp,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name})]},e.absolutePath))]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:a,className:`text-xs text-fg-muted`,children:i.pickerManualPath}),(0,Z.jsx)(`input`,{id:a,type:`text`,value:f,onChange:e=>s({type:`patch`,patch:{manualPath:e.target.value}}),placeholder:i.pathInputPlaceholder,className:C_e(),autoComplete:`off`,spellCheck:!1,onKeyDown:e=>{e.key===`Enter`&&f.trim()&&(e.preventDefault(),y())}})]})]}),(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-end gap-2 border-t border-edge-subtle/60 pt-3`,children:[(0,Z.jsx)(wA,{type:`button`,variant:`ghost`,onClick:()=>t(!1),children:i.pathModalCancel}),(0,Z.jsx)(wA,{type:`button`,variant:`secondary`,disabled:!f.trim(),onClick:()=>void y(),children:i.pickerApplyManual}),(0,Z.jsx)(wA,{type:`button`,disabled:!_,onClick:()=>void v(),children:i.pickerUseThisFolder})]})]})]})})}var E_e=(0,J.memo)(function({sessionKey:e,disabled:t,canSelectWorkingDirectory:n,sessionMgr:r}){let i=m(d(e=>e.language)).chat.workingDirectory,a=cQ(e=>e.toggleOpen),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(!1),[u,f]=(0,J.useState)(!1),[p,h]=(0,J.useState)(null),g=(0,J.useCallback)(async()=>{if(!e){s(``);return}l(!0);try{s((await r.loadSessionAgentConfig(e)).effectiveWorkspacePath)}catch{s(``)}finally{l(!1)}},[e,r]);(0,J.useEffect)(()=>{g()},[g]);let _=s5({initialPath:o,onPicked:(0,J.useCallback)(async t=>{if(!(!e?.trim()||!t.trim()))try{await r.patchSessionAgentConfig(e,{workingDirectory:t.trim()}),await g()}catch(e){throw h(e instanceof Error?e.message:String(e)),f(!0),e}},[e,r,g])}),v=(0,J.useCallback)(()=>{window.dispatchEvent(new CustomEvent(`extension-notification`,{detail:{type:`info`,title:i.lockedTapTitle,message:i.lockedTapBody,duration:6500}}))},[i.lockedTapBody,i.lockedTapTitle]);if(!e)return null;let y=o.trim(),b=!!y,x=b?a5(y):i.notSet,S=X(`inline-flex min-h-8 max-w-[min(12rem,40vw)] min-w-0 shrink-0 items-center gap-1 rounded-lg px-2 py-1 text-xs`,`border border-edge-subtle/80 bg-surface-hover/40 dark:border-edge-subtle`,AX.transition,AX.focusRingPanel),C=e=>{let{hasPath:t,fullPath:n,canSelect:r}=e,a;return a=!r&&t?i.tooltipOpenProjectFiles:r?t?i.chooseFolder:i.selectWorkingDirectory:i.selectionOnlyAtNewChat,(0,Z.jsxs)(`div`,{className:`max-w-[min(22rem,90vw)] space-y-1.5`,children:[(0,Z.jsx)(`p`,{className:`font-semibold text-fg`,children:i.tooltipAgentWorkspace}),t?(0,Z.jsx)(`p`,{className:`break-words font-mono text-[11px] leading-snug text-fg-muted`,children:n}):(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-muted`,children:i.notSet}),(0,Z.jsx)(`p`,{className:`text-[11px] leading-snug text-fg-subtle`,children:a})]})},w=(e,t)=>(0,Z.jsxs)(CZ,{delayDuration:350,children:[(0,Z.jsx)(wZ,{asChild:!0,children:t}),(0,Z.jsx)(TZ,{children:(0,Z.jsx)(EZ,{side:`top`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-w-[min(22rem,90vw)] rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-snug text-fg shadow-lg`,children:e})})]}),T=()=>w(C({hasPath:!1,fullPath:``,canSelect:!1}),(0,Z.jsxs)(`button`,{type:`button`,className:X(S,`cursor-pointer text-left text-fg-muted hover:bg-surface-hover/70 dark:hover:bg-surface-hover/50`),"aria-label":`${i.notSet}. ${i.selectionOnlyAtNewChat}`,onClick:e=>{e.stopPropagation(),v()},children:[(0,Z.jsx)(hp,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-left font-medium text-fg`,children:x})]})),E=()=>w(C({hasPath:!0,fullPath:y,canSelect:!1}),(0,Z.jsxs)(`button`,{type:`button`,disabled:t||c||!b,className:X(S,b&&`cursor-pointer hover:bg-surface-hover/70 dark:hover:bg-surface-hover/50`,(t||c||!b)&&`cursor-not-allowed opacity-60`),"aria-label":`${i.tooltipAgentWorkspace}: ${y}`,onClick:e=>{e.stopPropagation(),b&&!t&&!c&&a()},children:[(0,Z.jsx)(hp,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-left font-medium text-fg`,children:x})]}));if(!n)return b?(0,Z.jsx)(SZ,{delayDuration:350,children:(0,Z.jsx)(`div`,{className:`inline-flex items-center`,children:E()})}):(0,Z.jsx)(SZ,{delayDuration:350,children:(0,Z.jsx)(`div`,{className:`inline-flex items-center`,children:T()})});let D=b&&!t&&!c?`${i.tooltipAgentWorkspace}: ${y}. ${i.chooseFolder}`:b?`${i.tooltipAgentWorkspace}: ${y}`:i.selectWorkingDirectory;return(0,Z.jsx)(SZ,{delayDuration:350,children:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`inline-flex items-center`,children:w(C({hasPath:b,fullPath:y,canSelect:!0}),(0,Z.jsx)(o5,{value:y,onPick:_.pick,disabled:t||c||_.picking,placeholder:i.notSet,"aria-label":D,className:X((t||c||_.picking)&&`cursor-not-allowed opacity-60`)}))}),_.hasNativePicker?null:(0,Z.jsx)(d5,{open:_.modalOpen,onOpenChange:_.setModalOpen,initialAbsolutePath:y||void 0,onConfirm:_.confirmPick,wd:i}),(0,Z.jsx)(q,{open:u,onOpenChange:e=>{f(e),e||h(null)},children:(0,Z.jsxs)(G,{children:[(0,Z.jsx)(ie,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Z.jsxs)(se,{className:X(`fixed left-1/2 top-1/2 z-[81] w-[min(100%-2rem,26rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-4 shadow-popover`,`dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsx)(ue,{className:`text-base font-semibold text-fg`,children:i.applyErrorTitle}),p?(0,Z.jsx)(le,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-fg-muted`,children:p}):null,(0,Z.jsx)(`div`,{className:`mt-4 flex items-center justify-end border-t border-edge-subtle/60 pt-3`,children:(0,Z.jsx)(wA,{type:`button`,onClick:()=>f(!1),children:i.applyErrorClose})})]})]})})]})})});function D_e(e){return e===`off`?yc:oS}var O_e=(0,J.memo)(function(e){let t=(0,Y.c)(87),{sessionKey:n,sessionManager:r,disabled:i,sending:a,streaming:o,canSelectWorkingDirectory:s,runBusy:c,chat:l,hasDraft:u,showSteeringInterrupt:d,attachmentCount:f,maxAttachments:p,onPickFiles:m,thinkingLevel:h,showThinkingSelector:g,onThinkingChange:_,voiceActive:v,onStartVoiceInput:y,onSend:b,onAbort:x,onInterrupt:S,sessionModel:C,showModelSelector:w,onModelChange:T,modelDisabled:E,contextUsageMessages:D,composerDraftChars:O}=e,[k,A]=(0,J.useState)(!1),j=h,M;t[0]===j?M=t[1]:(M=D_e(j),t[0]=j,t[1]=M);let N=M,P=f>=p,F;t[2]!==f||t[3]!==P||t[4]!==l.attachFile||t[5]!==l.maxAttachmentsReached||t[6]!==p?(F=P?Q8(l.maxAttachmentsReached,{max:p}):`${l.attachFile} (${f}/${p})`,t[2]=f,t[3]=P,t[4]=l.attachFile,t[5]=l.maxAttachmentsReached,t[6]=p,t[7]=F):F=t[7];let I=F,L;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(L=X(`flex flex-wrap items-center gap-2 border-t border-edge-subtle/90 px-4 py-2.5 dark:border-edge-subtle`),t[8]=L):L=t[8];let R=i||c,z;t[9]!==s||t[10]!==n||t[11]!==r||t[12]!==R?(z=(0,Z.jsx)(E_e,{sessionKey:n,sessionMgr:r,canSelectWorkingDirectory:s,disabled:R}),t[9]=s,t[10]=n,t[11]=r,t[12]=R,t[13]=z):z=t[13];let B;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(B=X(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover/70 text-fg-subtle hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/50`,AX.transition,AX.press,AX.focusRingPanel),t[14]=B):B=t[14];let V;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Z.jsx)(xv,{className:`size-4`}),t[15]=V):V=t[15];let H;t[16]!==l.moreActions||t[17]!==k?(H=(0,Z.jsx)(vF,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:B,title:l.moreActions,"aria-label":l.moreActions,"aria-expanded":k,children:V})}),t[16]=l.moreActions,t[17]=k,t[18]=H):H=t[18];let U;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(U=X(`z-50 min-w-[12rem] rounded-xl border border-edge bg-surface-panel p-1.5 shadow-popover dark:border-edge`),t[19]=U):U=t[19];let W;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(W=X(`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:cursor-not-allowed disabled:opacity-50`),t[20]=W):W=t[20];let G=P||i||c,ee;t[21]===m?ee=t[22]:(ee=()=>{m(),A(!1)},t[21]=m,t[22]=ee);let K;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,Z.jsx)(Af,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[23]=K):K=t[23];let te;t[24]===l.attachFile?te=t[25]:(te=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:l.attachFile}),t[24]=l.attachFile,t[25]=te);let ne;t[26]!==f||t[27]!==p?(ne=(0,Z.jsxs)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:[f,`/`,p]}),t[26]=f,t[27]=p,t[28]=ne):ne=t[28];let re;t[29]!==I||t[30]!==G||t[31]!==ee||t[32]!==te||t[33]!==ne?(re=(0,Z.jsxs)(`button`,{type:`button`,className:W,disabled:G,title:I,onClick:ee,children:[K,te,ne]}),t[29]=I,t[30]=G,t[31]=ee,t[32]=te,t[33]=ne,t[34]=re):re=t[34];let ie;t[35]!==N||t[36]!==i||t[37]!==l.thinkingLevelLabel||t[38]!==l.thinkingLevels||t[39]!==_||t[40]!==a||t[41]!==g||t[42]!==o||t[43]!==h?(ie=g?(0,Z.jsxs)(`label`,{className:X(`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-sm text-fg`,`hover:bg-surface-hover`),title:`${l.thinkingLevelLabel}: ${l.thinkingLevels[h]??h}`,children:[(0,Z.jsx)(N,{className:`size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:l.thinkingLevelLabel}),(0,Z.jsx)(`select`,{className:`min-w-0 flex-1 cursor-pointer appearance-none rounded-md bg-surface-hover/80 px-2 py-0.5 text-sm font-medium text-fg focus:outline-none focus-visible:ring-2 focus-visible:ring-accent`,value:h,disabled:i||a&&!o,onChange:e=>_(e.target.value),children:Object.keys(l.thinkingLevels).map(e=>(0,Z.jsx)(`option`,{value:e,children:l.thinkingLevels[e]},e))})]}):null,t[35]=N,t[36]=i,t[37]=l.thinkingLevelLabel,t[38]=l.thinkingLevels,t[39]=_,t[40]=a,t[41]=g,t[42]=o,t[43]=h,t[44]=ie):ie=t[44];let ae;t[45]!==re||t[46]!==ie?(ae=(0,Z.jsx)(yF,{children:(0,Z.jsx)(bF,{className:U,side:`top`,align:`start`,sideOffset:8,collisionPadding:12,onOpenAutoFocus:k_e,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[re,ie]})})}),t[45]=re,t[46]=ie,t[47]=ae):ae=t[47];let oe;t[48]!==k||t[49]!==ae||t[50]!==H?(oe=(0,Z.jsxs)(gF,{open:k,onOpenChange:A,children:[H,ae]}),t[48]=k,t[49]=ae,t[50]=H,t[51]=oe):oe=t[51];let se;t[52]!==O||t[53]!==D||t[54]!==l||t[55]!==E||t[56]!==T||t[57]!==C||t[58]!==w?(se=w?(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 w-fit max-w-[min(20rem,calc(100vw-10rem))] shrink-0`,children:(0,Z.jsx)(r5,{value:C,disabled:E,placeholder:l.modelPlaceholder,searchPlaceholder:l.modelSearchPlaceholder,noMatches:l.modelNoMatches,compact:!0,showProviderInTrigger:!1,contentSide:`top`,contentAlign:`end`,showProviderSettingsFooter:!0,onChange:T})}),(0,Z.jsx)(l_e,{sessionModel:C,messages:D,draftChars:O,chat:l,disabled:E})]}):null,t[52]=O,t[53]=D,t[54]=l,t[55]=E,t[56]=T,t[57]=C,t[58]=w,t[59]=se):se=t[59];let q;t[60]!==i||t[61]!==l.voiceInput||t[62]!==y||t[63]!==v?(q=v?null:(0,Z.jsx)(`button`,{type:`button`,className:X(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg border border-transparent text-fg-subtle hover:bg-surface-hover hover:text-fg`,AX.transition,AX.press,AX.focusRingPanel,`disabled:cursor-not-allowed disabled:opacity-50`),disabled:i,title:l.voiceInput,"aria-label":l.voiceInput,onClick:()=>void y(),children:(0,Z.jsx)(Mg,{className:`size-4 stroke-[1.75]`})}),t[60]=i,t[61]=l.voiceInput,t[62]=y,t[63]=v,t[64]=q):q=t[64];let ce;t[65]!==i||t[66]!==u||t[67]!==l.abort||t[68]!==l.sendMessage||t[69]!==l.steeringInterruptSend||t[70]!==x||t[71]!==S||t[72]!==b||t[73]!==c||t[74]!==d||t[75]!==v?(ce=c?(0,Z.jsxs)(Z.Fragment,{children:[d&&S?(0,Z.jsx)(`button`,{type:`button`,className:X(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg border border-transparent text-accent-fg hover:bg-accent-soft dark:hover:bg-accent-soft`,AX.transition,AX.press,AX.focusRingPanel),title:l.steeringInterruptSend,"aria-label":l.steeringInterruptSend,onClick:()=>void S(),children:(0,Z.jsx)(Vb,{className:`size-4 stroke-[1.75]`})}):null,(0,Z.jsx)(`button`,{type:`button`,className:X(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover/70 text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/50`,AX.transition,AX.press,AX.focusRingPanel),title:l.abort,"aria-label":l.abort,onClick:x,children:(0,Z.jsx)(NC,{className:`size-4 stroke-[1.75]`})})]}):(0,Z.jsx)(`button`,{type:`button`,className:X(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg border transition-colors duration-150 ease-out`,AX.press,AX.focusRingPanel,u?`border-transparent text-accent-fg hover:bg-accent-soft dark:text-accent-fg dark:hover:bg-accent-soft`:`border-transparent text-fg-disabled`),disabled:i||v||!u,title:l.sendMessage,"aria-label":l.sendMessage,onClick:b,children:(0,Z.jsx)(Vb,{className:`size-4 stroke-[1.75]`})}),t[65]=i,t[66]=u,t[67]=l.abort,t[68]=l.sendMessage,t[69]=l.steeringInterruptSend,t[70]=x,t[71]=S,t[72]=b,t[73]=c,t[74]=d,t[75]=v,t[76]=ce):ce=t[76];let le;t[77]!==q||t[78]!==ce?(le=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[q,ce]}),t[77]=q,t[78]=ce,t[79]=le):le=t[79];let ue;t[80]!==se||t[81]!==le?(ue=(0,Z.jsxs)(`div`,{className:`ml-auto flex min-w-0 items-center gap-2`,children:[se,le]}),t[80]=se,t[81]=le,t[82]=ue):ue=t[82];let de;return t[83]!==oe||t[84]!==ue||t[85]!==z?(de=(0,Z.jsxs)(`div`,{className:L,children:[z,oe,ue]}),t[83]=oe,t[84]=ue,t[85]=z,t[86]=de):de=t[86],de});function k_e(e){return e.preventDefault()}function A_e(e){return e.map(e=>({type:e.type===`voice`?`voice`:(e.mimeType??``).startsWith(`image/`)?`image`:`document`,mimeType:e.mimeType??`application/octet-stream`,content:e.data??``,name:e.name??`file`,size:e.size??0,workspaceRelativePath:e.workspaceRelativePath,...typeof e.durationSeconds==`number`&&Number.isFinite(e.durationSeconds)&&e.durationSeconds>0?{durationSeconds:e.durationSeconds}:{}}))}var j_e=100,M_e=400,f5=900;function N_e(e,t){switch(t.type){case`reset`:return{box:null,hoverPreview:null};case`set-box`:return{...e,box:t.box};case`set-hover`:return{...e,hoverPreview:t.hoverPreview}}}function P_e(e,t){let n=t.trim().toLowerCase();if(!n)return[];let r=e.toLowerCase(),i=[],a=0;for(let e=0;e<r.length&&a<n.length;e++)r[e]===n[a]&&(i.push([e,e+1]),a++);return i}function F_e(e){let t=(0,Y.c)(8),{name:n,query:r}=e,i;t[0]!==n||t[1]!==r?(i=P_e(n,r),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a=i;if(a.length===0){let e;return t[3]===n?e=t[4]:(e=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n}),t[3]=n,t[4]=e),e}let o;if(t[5]!==n||t[6]!==a){let e=[],r=0;a.forEach(t=>{let[i,a]=t;i>r&&e.push((0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n.slice(r,i)},`pre-${i}`)),e.push((0,Z.jsx)(`span`,{className:`font-semibold text-accent-fg`,children:n.slice(i,a)},`hl-${i}-${a}`)),r=a}),r<n.length&&e.push((0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n.slice(r)},`tail`)),o=(0,Z.jsx)(Z.Fragment,{children:e}),t[5]=n,t[6]=a,t[7]=o}else o=t[7];return o}var I_e=(0,J.memo)(function(e){let t=(0,Y.c)(39),{open:n,anchorRef:r,items:i,selectedIndex:a,loading:o,query:s,noResults:c,sessionKey:l,recentLabel:u,ariaLabel:d,onSelectItem:f,shiftHint:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m={box:null,hoverPreview:null},t[0]=m):m=t[0];let[h,g]=(0,J.useReducer)(N_e,m),_=h.box,v=h.hoverPreview,y=(0,J.useRef)(null),b=(0,J.useRef)(0),x;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{y.current&&=(clearTimeout(y.current),null)},t[1]=x):x=t[1];let S=x,C;t[2]===l?C=t[3]:(C=(e,t,n)=>{S(),b.current+=1;let r=b.current,i=e.relativePath;if(!l?.trim()||e.isDirectory||e.isBrowseUp||!i){g({type:`set-hover`,hoverPreview:null});return}y.current=setTimeout(()=>{y.current=null,r===b.current&&qH(i,{sessionKey:l}).then(e=>{let{content:i}=e,a=i.length>f5?`${i.slice(0,f5)}…`:i;r===b.current&&g({type:`set-hover`,hoverPreview:{text:a,x:t,y:n}})}).catch(()=>{r===b.current&&g({type:`set-hover`,hoverPreview:null})})},420)},t[2]=l,t[3]=C);let w=C,T,E;if(t[4]!==r||t[5]!==n?(T=()=>{if(!n){g({type:`reset`}),S(),b.current+=1;return}let e=()=>{let e=r.current;if(!e)return;let t=e.getBoundingClientRect();g({type:`set-box`,box:{left:t.left,top:t.top,width:t.width}})};e();let t=r.current,i=t&&typeof ResizeObserver<`u`?new ResizeObserver(()=>{e()}):null;return t&&i&&i.observe(t),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{t&&i&&i.disconnect(),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},E=[n,r],t[4]=r,t[5]=n,t[6]=T,t[7]=E):(T=t[6],E=t[7]),(0,J.useLayoutEffect)(T,E),!n||typeof document>`u`||_===null)return null;let D=i.length,O=Math.min(_.width,M_e),k;t[8]!==_.left||t[9]!==_.top||t[10]!==O?(k={position:`fixed`,left:_.left,top:_.top,width:O,transform:`translateY(calc(-100% - 8px))`,zIndex:j_e},t[8]=_.left,t[9]=_.top,t[10]=O,t[11]=k):k=t[11];let A=a>=0&&a<D?`at-mention-${a}`:void 0,j;t[12]!==o||t[13]!==D?(j=o&&D===0?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2.5 text-sm text-fg-muted`,children:[(0,Z.jsx)(Cg,{className:`size-4 shrink-0 animate-spin`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:`…`})]}):null,t[12]=o,t[13]=D,t[14]=j):j=t[14];let M;t[15]!==i||t[16]!==o||t[17]!==c||t[18]!==f||t[19]!==s||t[20]!==u||t[21]!==w||t[22]!==a||t[23]!==D?(M=!o&&D===0?(0,Z.jsx)(`div`,{className:`px-3 py-2 text-sm text-fg-muted`,children:c}):(0,Z.jsx)(Z.Fragment,{children:i.map((e,t)=>(0,Z.jsxs)(`div`,{id:`at-mention-${t}`,role:`option`,"aria-selected":a===t,tabIndex:-1,className:X(`flex cursor-pointer items-start gap-2 px-3 py-2 text-left text-sm`,a===t?`bg-surface-hover text-fg`:`text-fg-subtle hover:bg-surface-hover/80`,e.isRecent&&`border-l-2 border-l-accent/60`),onPointerDown:t=>{t.pointerType===`mouse`&&t.button!==0||(t.preventDefault(),f(e,{shiftKey:t.shiftKey}))},onPointerEnter:t=>w(e,t.clientX,t.clientY),onPointerLeave:()=>{S(),b.current+=1,g({type:`set-hover`,hoverPreview:null})},children:[(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:e.isBrowseUp?(0,Z.jsx)(Np,{className:`size-3.5 text-fg-muted`,"aria-hidden":!0}):e.isDirectory?(0,Z.jsx)(Np,{className:`size-3.5 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}):(0,Z.jsx)(xf,{className:X(`size-3.5`,RH(e.name)),"aria-hidden":!0})}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 truncate`,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:(0,Z.jsx)(F_e,{name:e.name,query:s})}),e.isRecent?(0,Z.jsx)(`span`,{className:`shrink-0 rounded bg-accent-soft px-1 py-0 text-[0.65rem] text-accent-fg`,children:u}):null]}),(0,Z.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:e.relativePath||`—`})]})]},`${e.relativePath}-${e.name}`))}),t[15]=i,t[16]=o,t[17]=c,t[18]=f,t[19]=s,t[20]=u,t[21]=w,t[22]=a,t[23]=D,t[24]=M):M=t[24];let N;t[25]!==d||t[26]!==A||t[27]!==j||t[28]!==M?(N=(0,Z.jsxs)(`div`,{className:`max-h-[min(26rem,54vh)] overflow-y-auto`,role:`listbox`,"aria-label":d,"aria-activedescendant":A,children:[j,M]}),t[25]=d,t[26]=A,t[27]=j,t[28]=M,t[29]=N):N=t[29];let P;t[30]===p?P=t[31]:(P=p?(0,Z.jsx)(`div`,{className:`border-t border-edge-subtle px-3 py-1.5 text-[0.65rem] text-fg-muted`,children:p}):null,t[30]=p,t[31]=P);let F;t[32]===v?F=t[33]:(F=v?(0,Z.jsx)(`div`,{className:`pointer-events-none fixed z-[200] max-h-48 max-w-sm overflow-auto rounded-md border border-edge bg-surface-panel p-2 font-mono text-[0.7rem] text-fg shadow-lg`,style:{left:Math.min(v.x+12,window.innerWidth-320),top:Math.min(v.y+12,window.innerHeight-200)},children:v.text}):null,t[32]=v,t[33]=F);let I;return t[34]!==N||t[35]!==P||t[36]!==F||t[37]!==k?(I=(0,Xa.createPortal)((0,Z.jsxs)(`div`,{className:`pointer-events-auto max-h-[min(28rem,60vh)] min-h-[2.5rem] overflow-hidden rounded-lg border border-edge bg-surface-panel shadow-lg dark:bg-surface-panel/95`,style:k,role:`presentation`,children:[N,P,F]}),document.body),t[34]=N,t[35]=P,t[36]=F,t[37]=k,t[38]=I):I=t[38],I}),p5=new Set([`abort`,`stop`,`cancel`]);function L_e(e){if(e.kind!==`command`)return!1;if(p5.has(e.name.toLowerCase()))return!0;for(let t of e.aliases??[])if(p5.has(t.toLowerCase()))return!0;return!1}function m5(e,t,n,r){return e.slice(0,t)+r+e.slice(n)}var R_e={skill:(e,t)=>{let n=t.slashRange;if(!n)return;let r=`/skill:${e.name} `,i=m5(t.editor.valueRef.current,n.start,n.end,r),a=n.start+r.length;t.editor.resetEditor({nextText:i,caretOffset:a,focus:!0})},command:(e,t)=>{let n=t.slashRange;if(!n||n.start!==0)return;if(e.acceptsArgs===!0){let r=`/${e.name} `,i=m5(t.editor.valueRef.current,n.start,n.end,r),a=n.start+r.length;t.editor.resetEditor({nextText:i,caretOffset:a,focus:!0});return}let r=`/${e.name}`;if(t.runBusy||t.pendingFollowUpsCount>0){if(L_e(e)){if(!t.callbacks.onAbort)return;t.callbacks.onAbort();let e=t.editor.valueRef.current,r=e.slice(0,n.start)+e.slice(n.end);t.editor.resetEditor({nextText:r,caretOffset:n.start});return}if(!t.callbacks.onAddPendingFollowUp||t.pendingFollowUpsCount>=t.maxPendingFollowUps)return;t.callbacks.onAddPendingFollowUp(r,void 0),t.callbacks.onUserTextCommitted?.(r),t.attachments.clearAttachments(),t.editor.resetEditor();return}t.callbacks.onSend(r,void 0,t.thinkingLevel),t.callbacks.onUserTextCommitted?.(r),t.attachments.clearAttachments(),t.editor.resetEditor()},agent:(e,t)=>{let n=t.slashRange;if(!n||n.start!==0||!t.callbacks.onChatAgentChange)return;let r=t.editor.valueRef.current,i=r.slice(0,n.start)+r.slice(n.end);t.editor.resetEditor({nextText:i,caretOffset:n.start}),t.attachments.clearAttachments(),t.callbacks.onChatAgentChange(e.name)}};function z_e(e,t){let n=R_e[e.kind];n&&n(e,t)}var h5={new:10,help:11,list:12,clear:13,switch:14,models:15,usage:16,skills:17,settings:18,start:19,think:20,reasoning:21,verbose:22,status:23,tts:24},B_e=new Set([`abort`,`archive`]);function g5(e){if(e.kind===`command`){let t=e.name.toLowerCase();if(h5[t]!==void 0)return 0;if(B_e.has(t))return 2}return 1}function _5(e,t){let n=g5(e),r=g5(t);if(n!==r)return n-r;if(n===0){let n=h5[e.name.toLowerCase()]??999,r=h5[t.name.toLowerCase()]??999;if(n!==r)return n-r}let i=e.name.localeCompare(t.name);return i===0?e.id.localeCompare(t.id):i}var V_e=RegExp(`^@file:${F8}`,`u`);function v5(e){if(e.kind!==`command`)return!1;if(p5.has(e.name.toLowerCase()))return!0;for(let t of e.aliases??[])if(p5.has(t.toLowerCase()))return!0;return!1}function y5(e,t){return e.kind!==`command`||e.acceptsArgs===!0||v5(e)||!(t.runBusy||t.pendingFollowUpsCount>0)?!1:t.pendingFollowUpsCount>=t.maxPendingFollowUps}function H_e(e,t){return e.kind!==`command`||e.acceptsArgs===!0||v5(e)||!(t.runBusy||t.pendingFollowUpsCount>0)?!1:t.pendingFollowUpsCount<t.maxPendingFollowUps}function U_e(e,t){let n=0;for(;n<e.length;){let r=e.indexOf(`@file:`,n);if(r===-1)return null;let i=e.slice(r).match(V_e);if(!i){n=r+1;continue}let a=r+i[0].length;if(t>=r&&t<a)return{start:r,end:a};n=a}return null}var W_e=20,b5=3;function G_e(e){return e.includes(`/`)||/^[A-Za-z]:/u.test(e)?!0:/^(Users|home|var|tmp|etc|opt|private|Volumes|System|Applications|Library|usr|dev|bin|sbin|proc|sys)(\/|$)/iu.test(e)}function K_e(e,t){if(t===0)return!1;let n=e[t-1];if(n===void 0||n===`.`||n===`:`||n===`/`)return!0;let r=e.slice(0,t);return/[a-zA-Z0-9-]+\.[a-zA-Z0-9.-]+$/u.test(r)}function q_e(e,t){let n=e.length,r=Math.min(Math.max(t,0),n);if(r<1&&e===`/`&&(r=1),r<1)return null;let i=e.slice(0,r).match(/\/[^\s]*$/);if(!i||i.index===void 0||U_e(e,i.index))return null;let a=i.index;if(K_e(e,a))return null;let o=i[0],s=o.slice(1);return G_e(s)||o.startsWith(`/skill:`)?null:{start:i.index,end:r,query:s}}function J_e(e,t){let n=t.trim().toLowerCase();if(!n)return 0;let r=e.name.toLowerCase();if(r===n)return 0;for(let t of e.aliases??[])if(t.toLowerCase()===n)return 1;if(r.startsWith(n))return 2;for(let t of e.aliases??[])if(t.toLowerCase().startsWith(n))return 3;if(r.includes(n))return 4;for(let t of e.aliases??[])if(t.toLowerCase().includes(n))return 5;return(e.description??``).toLowerCase().includes(n)?100:(e.category??``).toLowerCase().includes(n)?101:e.kind===`skill`&&(e.source??``).toLowerCase().includes(n)?102:null}function Y_e(e,t){return t===0?0:Math.min(e,t-1)}function X_e(e,t,n){let r=(0,Y.c)(52),[i,a]=(0,J.useState)(0),[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(!1),[u,f]=(0,J.useState)(!1),p=d(uve);n?.isComposing;let m;r[0]!==t||r[1]!==n?.isComposing||r[2]!==e?(m=n?.isComposing?null:q_e(e,t),r[0]=t,r[1]=n?.isComposing,r[2]=e,r[3]=m):m=r[3];let h=m,g=!!(h&&!n?.suppress);!g&&(o||c||u)&&(s(!1),l(!1),f(!1));let _,v;r[4]===p?(_=r[5],v=r[6]):(_=async()=>{let[e,t,n]=await Promise.all([v1(),y1(p),gL().catch(lve)]),r=e.map(cve),i=t.catalog.flatMap(sve),a=n&&n.items.length>1?n.items.map(ove):[];return[...i,...r,...a]},v=[p],r[4]=p,r[5]=_,r[6]=v);let y;r[7]===Symbol.for(`react.memo_cache_sentinel`)?(y=[],r[7]=y):y=r[7];let b;r[8]===Symbol.for(`react.memo_cache_sentinel`)?(b=[],r[8]=b):b=r[8];let x;r[9]===g?x=r[10]:(x={enabled:g,initial:y,errorData:b},r[9]=g,r[10]=x);let S=UF(_,v,x),C=S.data,w=S.error==null?null:S.error instanceof Error?S.error.message:String(S.error),T=h?.query??``,E=h!==null&&h.start===0,D=E,O;r[11]===T?O=r[12]:(O=T.trim(),r[11]=T,r[12]=O);let k=O===``,A=g&&k&&o,j=g&&k&&c,M=g&&k&&u,N;r[13]===Symbol.for(`react.memo_cache_sentinel`)?(N=()=>{s(!0)},r[13]=N):N=r[13];let P=N,F;r[14]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>{l(!0)},r[14]=F):F=r[14];let I=F,L;r[15]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>{f(!0)},r[15]=L):L=r[15];let R=L,z;if(r[16]!==D||r[17]!==C||r[18]!==E||r[19]!==M||r[20]!==j||r[21]!==A||r[22]!==k||r[23]!==T||r[24]!==e){bb0:{let t=Vge(e),n=[];for(let e of C){if(e.kind===`command`&&!E||e.kind===`agent`&&!D||e.kind===`skill`&&t.has(e.name))continue;let r=J_e(e,T);r!==null&&n.push({item:e,rank:r})}if(k){let e=ave,t=n.filter(ive).sort(e).map(rve),r=n.filter(nve).sort(e).map(tve),i=n.filter(eve).sort(e).map($_e),a=A?t:t.slice(0,b5),o=j?r:r.slice(0,b5),s=M?i:i.slice(0,b5),c=A?0:Math.max(0,t.length-b5),l=j?0:Math.max(0,r.length-b5),u=M?0:Math.max(0,i.length-b5);z={items:[...a,...o,...s],skillRowCount:a.length,commandRowCount:o.length,groupedHasSkills:t.length>0,groupedHasCommands:r.length>0,groupedHasAgents:i.length>0,groupedSkillsMoreCount:c,groupedCommandsMoreCount:l,groupedAgentsMoreCount:u};break bb0}n.sort(Q_e);let i;r[26]===n?i=r[27]:(i={items:n.slice(0,W_e).map(Z_e),skillRowCount:0,commandRowCount:0,groupedHasSkills:!1,groupedHasCommands:!1,groupedHasAgents:!1,groupedSkillsMoreCount:0,groupedCommandsMoreCount:0,groupedAgentsMoreCount:0},r[26]=n,r[27]=i),z=i}r[16]=D,r[17]=C,r[18]=E,r[19]=M,r[20]=j,r[21]=A,r[22]=k,r[23]=T,r[24]=e,r[25]=z}else z=r[25];let{items:B,skillRowCount:V,commandRowCount:H,groupedHasSkills:U,groupedHasCommands:W,groupedHasAgents:G,groupedSkillsMoreCount:ee,groupedCommandsMoreCount:K,groupedAgentsMoreCount:te}=z,ne=h?T:``,re=(0,J.useRef)(ne);re.current!==ne&&(re.current=ne,i!==0&&a(0));let ie;r[28]!==B.length||r[29]!==i?(ie=Y_e(i,B.length),r[28]=B.length,r[29]=i,r[30]=ie):ie=r[30];let ae=ie,oe;r[31]===B.length?oe=r[32]:(oe=e=>{B.length!==0&&a(t=>e===`down`?(t+1)%B.length:(t-1+B.length)%B.length)},r[31]=B.length,r[32]=oe);let se=oe,q;return r[33]!==D||r[34]!==H||r[35]!==E||r[36]!==k||r[37]!==te||r[38]!==K||r[39]!==G||r[40]!==W||r[41]!==U||r[42]!==ee||r[43]!==B||r[44]!==w||r[45]!==se||r[46]!==g||r[47]!==T||r[48]!==ae||r[49]!==V||r[50]!==h?(q={open:g,slashRange:h,commandsAllowed:E,agentsAllowed:D,grouped:k,skillRowCount:V,commandRowCount:H,groupedHasSkills:U,groupedHasCommands:W,groupedHasAgents:G,groupedSkillsMoreCount:ee,groupedCommandsMoreCount:K,groupedAgentsMoreCount:te,items:B,selectedIndex:ae,query:T,loadError:w,onNavigate:se,setSelectedIndex:a,expandGroupedSkills:P,expandGroupedCommands:I,expandGroupedAgents:R},r[33]=D,r[34]=H,r[35]=E,r[36]=k,r[37]=te,r[38]=K,r[39]=G,r[40]=W,r[41]=U,r[42]=ee,r[43]=B,r[44]=w,r[45]=se,r[46]=g,r[47]=T,r[48]=ae,r[49]=V,r[50]=h,r[51]=q):q=r[51],q}function Z_e(e){return e.item}function Q_e(e,t){if(e.rank!==t.rank)return e.rank-t.rank;let n=_5(e.item,t.item);return n===0?0:n}function $_e(e){return e.item}function eve(e){return e.item.kind===`agent`}function tve(e){return e.item}function nve(e){return e.item.kind===`command`}function rve(e){return e.item}function ive(e){return e.item.kind===`skill`}function ave(e,t){let n=_5(e.item,t.item);return n===0?e.item.id.localeCompare(t.item.id):n}function ove(e){return{kind:`agent`,id:`agent:${e.id}`,name:e.id,description:e.description??``,category:`agent`,...e.avatar?{avatar:e.avatar}:{},...e.name?{aliases:[e.name]}:{}}}function sve(e){return!e.enabled||e.disableModelInvocation?[]:[{kind:`skill`,id:`skill:${e.name}`,name:e.name,description:e.description,category:`skill`,source:e.source}]}function cve(e){return{kind:`command`,id:`cmd:${e.id}`,name:e.name,description:e.description,category:e.category,aliases:e.aliases,acceptsArgs:e.acceptsArgs}}function lve(){return null}function uve(e){return e.language}var dve=100,fve=280;function x5(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase().indexOf(n);if(r>=0)return(0,Z.jsxs)(Z.Fragment,{children:[e.slice(0,r),(0,Z.jsx)(`span`,{className:`text-accent-fg`,children:e.slice(r,r+n.length)}),e.slice(r+n.length)]});let i=[],a=0,o=0;for(let t of e){let e=n[a],r=`${String(o)}-${t}`;e!==void 0&&t.toLowerCase()===e?(i.push((0,Z.jsx)(`span`,{className:`text-accent-fg`,children:t},r)),a+=1):i.push((0,Z.jsx)(J.Fragment,{children:t},r)),o+=1}return(0,Z.jsx)(Z.Fragment,{children:i})}function pve(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase().indexOf(n);return r<0?e:(0,Z.jsxs)(Z.Fragment,{children:[e.slice(0,r),(0,Z.jsx)(`span`,{className:`text-accent-fg`,children:e.slice(r,r+n.length)}),e.slice(r+n.length)]})}var mve=(0,J.memo)(function(e){let t=(0,Y.c)(43),{open:n,anchorRef:r,items:i,selectedIndex:a,noResults:o,grouped:s,skillRowCount:c,commandRowCount:l,query:u,skillsLabel:d,commandsLabel:f,agentsLabel:p,groupedHasSkills:m,groupedHasCommands:h,groupedHasAgents:g,groupedSkillsShowMoreLabel:_,groupedCommandsShowMoreLabel:v,groupedAgentsShowMoreLabel:y,currentAgentId:b,currentBadgeLabel:x,runBusy:S,pendingFollowUpsCount:C,maxPendingFollowUps:w,queueBadgeLabel:T,queueFullBadgeLabel:E,queueFullTooltip:D,onExpandSkills:O,onExpandCommands:k,onExpandAgents:A,onSelectItem:j,panelRef:M}=e,[N,P]=(0,J.useState)(null),F,I;if(t[0]!==r||t[1]!==n?(F=()=>{if(!n){P(null);return}let e=()=>{let e=r.current;if(!e)return;let t=e.getBoundingClientRect();P({left:t.left,top:t.top,width:t.width})};e();let t=r.current,i=t&&typeof ResizeObserver<`u`?new ResizeObserver(()=>{e()}):null;return t&&i&&i.observe(t),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{t&&i&&i.disconnect(),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},I=[n,r],t[0]=r,t[1]=n,t[2]=F,t[3]=I):(F=t[2],I=t[3]),(0,J.useLayoutEffect)(F,I),!n||typeof document>`u`||N===null)return null;let L=i.length,R=Math.min(N.width,fve),z;if(t[4]!==p||t[5]!==l||t[6]!==f||t[7]!==b||t[8]!==x||t[9]!==s||t[10]!==y||t[11]!==v||t[12]!==g||t[13]!==h||t[14]!==m||t[15]!==_||t[16]!==i||t[17]!==w||t[18]!==o||t[19]!==A||t[20]!==k||t[21]!==O||t[22]!==j||t[23]!==C||t[24]!==u||t[25]!==T||t[26]!==E||t[27]!==D||t[28]!==S||t[29]!==a||t[30]!==c||t[31]!==d||t[32]!==L){let e=u.trim(),n=!s&&e.length>0,r={runBusy:S,pendingFollowUpsCount:C,maxPendingFollowUps:w},M=(t,i)=>{let o=t.kind===`skill`,s=t.kind===`agent`,c=s?(0,Z.jsx)(rH,{agentId:t.name,avatar:t.avatar,size:18,className:`size-[18px] shrink-0`}):o?(0,Z.jsx)(oS,{className:`size-3 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,Z.jsx)(cO,{className:`size-3 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),l=s?n?(0,Z.jsx)(Z.Fragment,{children:x5(t.name,e)}):(0,Z.jsx)(`span`,{className:`text-fg`,children:t.name}):n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`text-fg`,children:`/`}),x5(t.name,e)]}):(0,Z.jsxs)(`span`,{className:`text-fg`,children:[`/`,t.name]}),u=s&&b!=null&&b.length>0&&t.name===b,d=H_e(t,r),f=y5(t,r),p=null;return u?p=(0,Z.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-accent-soft px-1 py-px text-[0.6rem] font-medium leading-none text-accent-fg`,"aria-label":x,children:x}):f?p=(0,Z.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-red-100 px-1 py-px text-[0.6rem] font-medium leading-none text-red-700 dark:bg-red-900/40 dark:text-red-300`,"aria-label":E,children:E}):d&&(p=(0,Z.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-surface-hover px-1 py-px text-[0.6rem] font-medium leading-none text-fg-muted`,"aria-label":T,children:T})),(0,Z.jsx)(hve,{item:t,icon:c,selected:a===i,id:`palette-${i}`,nameLine:l,descriptionLine:t.description?n?pve(t.description,e):t.description:null,dimCategoryBadge:n,trailingBadge:p,disabled:f,disabledTooltip:f?D:void 0,onSelect:()=>j(t)})};z=L===0?(0,Z.jsx)(`div`,{className:`p-2.5 text-xs leading-normal text-fg-muted`,children:o}):s?(0,Z.jsxs)(Z.Fragment,{children:[m?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mb-1.5 px-2.5 pt-2.5 text-[0.6rem] font-medium uppercase leading-none tracking-wide text-fg-muted`,"aria-hidden":!0,children:d}),i.slice(0,c).map((e,t)=>(0,Z.jsx)(J.Fragment,{children:M(e,t)},e.id)),_?(0,Z.jsx)(`button`,{type:`button`,className:`w-full px-2.5 py-1 text-left text-[11px] leading-tight text-fg-muted transition hover:bg-surface-hover/80 hover:text-fg`,onClick:e=>{e.preventDefault(),O()},children:_}):null]}):null,h?(0,Z.jsxs)(`div`,{className:X(m&&`mt-1 border-t border-edge-subtle`),children:[(0,Z.jsx)(`div`,{className:`mb-1.5 px-2.5 pt-2.5 text-[0.6rem] font-medium uppercase leading-none tracking-wide text-fg-muted`,"aria-hidden":!0,children:f}),i.slice(c,c+l).map((e,t)=>(0,Z.jsx)(J.Fragment,{children:M(e,c+t)},e.id)),v?(0,Z.jsx)(`button`,{type:`button`,className:`w-full px-2.5 py-1 text-left text-[11px] leading-tight text-fg-muted transition hover:bg-surface-hover/80 hover:text-fg`,onClick:e=>{e.preventDefault(),k()},children:v}):null]}):null,g?(0,Z.jsxs)(`div`,{className:X((m||h)&&`mt-1 border-t border-edge-subtle`),children:[(0,Z.jsx)(`div`,{className:`mb-1.5 px-2.5 pt-2.5 text-[0.6rem] font-medium uppercase leading-none tracking-wide text-fg-muted`,"aria-hidden":!0,children:p}),i.slice(c+l).map((e,t)=>(0,Z.jsx)(J.Fragment,{children:M(e,c+l+t)},e.id)),y?(0,Z.jsx)(`button`,{type:`button`,className:`w-full px-2.5 py-1 text-left text-[11px] leading-tight text-fg-muted transition hover:bg-surface-hover/80 hover:text-fg`,onClick:e=>{e.preventDefault(),A()},children:y}):null]}):null]}):i.map((e,t)=>(0,Z.jsx)(J.Fragment,{children:M(e,t)},e.id)),t[4]=p,t[5]=l,t[6]=f,t[7]=b,t[8]=x,t[9]=s,t[10]=y,t[11]=v,t[12]=g,t[13]=h,t[14]=m,t[15]=_,t[16]=i,t[17]=w,t[18]=o,t[19]=A,t[20]=k,t[21]=O,t[22]=j,t[23]=C,t[24]=u,t[25]=T,t[26]=E,t[27]=D,t[28]=S,t[29]=a,t[30]=c,t[31]=d,t[32]=L,t[33]=z}else z=t[33];let B=z,V;t[34]!==N.left||t[35]!==N.top||t[36]!==R?(V={position:`fixed`,left:N.left,top:N.top,width:R,transform:`translateY(calc(-100% - 8px))`,zIndex:dve},t[34]=N.left,t[35]=N.top,t[36]=R,t[37]=V):V=t[37];let H=a>=0&&a<L?`palette-${a}`:void 0,U;return t[38]!==B||t[39]!==M||t[40]!==V||t[41]!==H?(U=(0,Xa.createPortal)((0,Z.jsx)(SZ,{delayDuration:0,skipDelayDuration:0,disableHoverableContent:!1,children:(0,Z.jsx)(`div`,{ref:M,className:`pointer-events-auto max-h-[min(24rem,55vh)] min-h-8 overflow-y-auto rounded-md border border-edge bg-surface-panel text-xs leading-4 shadow-lg dark:bg-surface-panel/95`,style:V,role:`listbox`,"aria-label":`Commands`,"aria-activedescendant":H,children:B})}),document.body),t[38]=B,t[39]=M,t[40]=V,t[41]=H,t[42]=U):U=t[42],U}),hve=(0,J.memo)(function(e){let t=(0,Y.c)(39),{item:n,icon:r,selected:i,id:a,nameLine:o,descriptionLine:s,dimCategoryBadge:c,trailingBadge:l,disabled:u,disabledTooltip:d,onSelect:f}=e,p=n.description??``,m;t[0]===p?m=t[1]:(m=p.trim(),t[0]=p,t[1]=m);let h=m,g=h.length>0&&s!=null,_=h.length>0,v=n.description??``,y=n.category&&n.kind!==`skill`&&!c&&!(n.kind===`agent`&&l),b;t[2]===o?b=t[3]:(b=(0,Z.jsx)(`span`,{className:`min-w-0 max-w-[min(12rem,46%)] shrink-0 truncate font-semibold text-fg`,children:o}),t[2]=o,t[3]=b);let x;t[4]!==n.category||t[5]!==y?(x=y?(0,Z.jsx)(`span`,{className:`shrink-0 rounded bg-surface-hover px-1 py-px text-[0.6rem] font-normal leading-none text-fg-muted`,children:n.category}):null,t[4]=n.category,t[5]=y,t[6]=x):x=t[6];let S;t[7]!==s||t[8]!==g?(S=g?(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] font-normal leading-tight text-fg-muted`,children:s}):null,t[7]=s,t[8]=g,t[9]=S):S=t[9];let C;t[10]!==b||t[11]!==x||t[12]!==S?(C=(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-1`,children:[b,x,S]}),t[10]=b,t[11]=x,t[12]=S,t[13]=C):C=t[13];let w=C,T=u?`cursor-not-allowed opacity-50 text-fg-muted`:i?`cursor-pointer bg-surface-hover text-fg`:`cursor-pointer text-fg-subtle hover:bg-surface-hover/80`,E;t[14]===T?E=t[15]:(E=X(`flex w-full min-w-0 items-center gap-1.5 px-2.5 py-1 text-left text-xs leading-4`,T),t[14]=T,t[15]=E);let D=E,O;t[16]!==u||t[17]!==f?(O=e=>{u||e.pointerType===`mouse`&&e.button!==0||(e.preventDefault(),f())},t[16]=u,t[17]=f,t[18]=O):O=t[18];let k=O,A;t[19]===r?A=t[20]:(A=(0,Z.jsx)(`span`,{className:`shrink-0 [&_svg]:align-middle`,children:r}),t[19]=r,t[20]=A);let j;t[21]!==A||t[22]!==w||t[23]!==l?(j=(0,Z.jsxs)(Z.Fragment,{children:[A,w,l]}),t[21]=A,t[22]=w,t[23]=l,t[24]=j):j=t[24];let M=j,N=u&&d?d:_?v:null,P=u||void 0,F;t[25]!==a||t[26]!==k||t[27]!==D||t[28]!==M||t[29]!==i||t[30]!==P?(F=(0,Z.jsx)(`div`,{id:a,role:`option`,"aria-selected":i,"aria-disabled":P,tabIndex:-1,className:D,onPointerDown:k,children:M}),t[25]=a,t[26]=k,t[27]=D,t[28]=M,t[29]=i,t[30]=P,t[31]=F):F=t[31];let I=F;if(N!==null){let e;t[32]===I?e=t[33]:(e=(0,Z.jsx)(wZ,{asChild:!0,children:I}),t[32]=I,t[33]=e);let n;t[34]===N?n=t[35]:(n=(0,Z.jsx)(TZ,{children:(0,Z.jsx)(EZ,{side:`right`,align:`start`,sideOffset:8,collisionPadding:12,className:`!z-[10000] max-h-[min(12rem,40vh)] max-w-sm overflow-y-auto rounded-md border border-edge bg-surface-panel px-2 py-1.5 text-left text-[11px] leading-snug text-fg shadow-lg select-text [max-width:min(20rem,90vw)]`,"data-slash-palette-tooltip":``,children:(0,Z.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:N})})}),t[34]=N,t[35]=n);let r;return t[36]!==e||t[37]!==n?(r=(0,Z.jsxs)(CZ,{delayDuration:0,children:[e,n]}),t[36]=e,t[37]=n,t[38]=r):r=t[38],r}return I}),S5=20,gve=`xopc.composer.inputHistory:`;function C5(e){return`${gve}${e.trim()}`}function w5(e){let t=e?.trim();if(!t||typeof localStorage>`u`)return[];try{let e=localStorage.getItem(C5(t));if(!e)return[];let n=JSON.parse(e);return Array.isArray(n)?n.filter(e=>typeof e==`string`).slice(0,S5):[]}catch{return[]}}function _ve(e,t){let n=e?.trim(),r=t.trim();if(!(!n||!r||typeof localStorage>`u`))try{let e=w5(n);if(e[0]===r)return;let t=[r,...e].slice(0,S5);localStorage.setItem(C5(n),JSON.stringify(t))}catch{}}function vve(e){let t=(0,Y.c)(17),{sessionKey:n,editorRef:r,valueRef:i,resetEditor:a,onWireInput:o}=e,s=(0,J.useRef)(null),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{s.current=null},t[0]=c):c=t[0];let l=c,u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{l()},t[1]=u):u=t[1];let d;t[2]===n?d=t[3]:(d=[n,l],t[2]=n,t[3]=d),(0,J.useEffect)(u,d);let f;t[4]===n?f=t[5]:(f=e=>{_ve(n,e),l()},t[4]=n,t[5]=f);let p=f,m;t[6]===o?m=t[7]:(m=(e,t)=>{s.current=null,o(e,t)},t[6]=o,t[7]=m);let h=m,g;t[8]!==r||t[9]!==a||t[10]!==n||t[11]!==i?(g=e=>{let t=n?.trim();if(!t)return!1;let o=w5(t);if(o.length===0)return!1;let c=s.current,l=r.current,u=l?q8(l):0,d=i.current;if(e===`up`){if(c==null){if(u!==0)return!1;s.current={index:0,stash:d};let e=o[0];return e?(a({nextText:e,caretOffset:e.length,focus:!0}),!0):!1}if(c.index>=o.length-1)return!0;c.index+=1;let e=o[c.index];return e?(a({nextText:e,caretOffset:e.length,focus:!0}),!0):!1}if(c==null)return!1;if(--c.index,c.index<0){let e=c.stash;return s.current=null,a({nextText:e,caretOffset:e.length,focus:!0}),!0}let f=o[c.index];return f?(a({nextText:f,caretOffset:f.length,focus:!0}),!0):!1},t[8]=r,t[9]=a,t[10]=n,t[11]=i,t[12]=g):g=t[12];let _=g,v;return t[13]!==p||t[14]!==h||t[15]!==_?(v={onUserTextCommitted:p,onWireInputClearWalk:h,tryInputHistoryArrow:_},t[13]=p,t[14]=h,t[15]=_,t[16]=v):v=t[16],v}function T5(e){if(e.voiceActive)return e.cancelVoiceInput(),null;let t=e.getTextValue();return!t.trim()&&e.getAttachmentCount()===0?null:{text:t,attachments:e.wireAttachmentsPayload()}}function yve(e){let{chat:t,runBusy:n,voiceActive:r,cancelVoiceInput:i,editingFollowUpId:a,getTextValue:o,getAttachmentCount:s,wireAttachmentsPayload:c,getThinkingLevel:l,onSend:u,onAddPendingFollowUp:d,onSteeringInterrupt:f,onCommitEditFollowUp:p,onPendingFollowUpRemove:m,pendingFollowUpsCount:h,resetEditor:g,clearAttachments:_,clearEditFollowUpRef:v,onUserTextCommitted:y}=e,b={getTextValue:o,getAttachmentCount:s,wireAttachmentsPayload:c};return{send:(0,J.useCallback)(()=>{if(n)return;let e=T5({voiceActive:r,cancelVoiceInput:i,...b});e&&(u(e.text,e.attachments.length>0?e.attachments:void 0,l()),y?.(e.text),g(),_())},[n,r,i,u,l,y,g,_,o,s,c]),flushSteeringDraft:(0,J.useCallback)(async()=>{if(!n&&h===0)return;let e=T5({voiceActive:r,cancelVoiceInput:i,...b});if(e){if(a){p(a,e.text,e.attachments.length>0?e.attachments:void 0,l()),y?.(e.text),v(),g(),_();return}if(d){if(h>=10){fH(`warning`,t.followUpQueueMaxReached,{max:10});return}await d(e.text,e.attachments.length>0?e.attachments:void 0),y?.(e.text),g(),_()}}},[n,r,i,a,h,d,p,l,t.followUpQueueMaxReached,v,y,g,_,o,s,c]),interruptDraft:(0,J.useCallback)(()=>{if(!n||!f)return;let e=T5({voiceActive:r,cancelVoiceInput:i,...b});e&&(f(e.text,e.attachments.length>0?e.attachments:void 0),y?.(e.text),a&&(v(),m(a)),g(),_())},[n,r,i,a,m,f,y,v,g,_,o,s,c])}}function bve(e){let{chat:t}=e,[n,r]=(0,J.useState)([]),[i,a]=(0,J.useState)(!1),o=(0,J.useRef)(null),s=(0,J.useRef)(n);s.current=n;let c=(0,J.useCallback)(()=>{r([])},[]),l=(0,J.useCallback)(e=>{r(t=>t.filter((t,n)=>n!==e))},[]),u=(0,J.useCallback)(()=>s.current.map(e=>({type:e.type===`voice`?`voice`:e.type||`file`,mimeType:e.mimeType,data:e.content,name:e.name,size:e.size,...e.workspaceRelativePath?{workspaceRelativePath:e.workspaceRelativePath}:{},...typeof e.durationSeconds==`number`&&Number.isFinite(e.durationSeconds)&&e.durationSeconds>0?{durationSeconds:e.durationSeconds}:{}})),[]);return{attachments:n,setAttachments:r,attachmentsRef:s,isDragging:i,setIsDragging:a,fileInputRef:o,processFiles:(0,J.useCallback)(async e=>{if(e.length===0)return;let n=10-s.current.length;if(n<=0){fH(`warning`,t.maxAttachmentsReached,{max:10});return}let i=e.slice(0,n);e.length>i.length&&fH(`warning`,t.maxAttachmentsTruncated,{max:10,dropped:e.length-i.length});let{loadAttachment:a}=await D(async()=>{let{loadAttachment:e}=await Promise.resolve().then(()=>wge);return{loadAttachment:e}},void 0),o=(await Promise.all(i.map(async e=>{if(e.size>33554432)return fH(`warning`,t.attachmentFileTooLarge,{name:e.name,maxSize:PL(bR)}),null;try{return await a(e,e.name)}catch{return fH(`error`,t.attachmentLoadFailed,{name:e.name}),null}}))).filter(e=>e!==null);r(e=>[...e,...o])},[t.attachmentFileTooLarge,t.attachmentLoadFailed,t.maxAttachmentsReached,t.maxAttachmentsTruncated]),removeAttachment:l,clearAttachments:c,wireAttachmentsPayload:u}}function xve(e){let t=(0,Y.c)(6),{active:n,anchors:r,ignoreSelector:i,onDismiss:a}=e,o,s;t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a?(o=()=>{if(!n)return;let e=e=>{let t=e.target;if(t instanceof Node){for(let e of r){let n=e.current;if(n&&n.contains(t))return}i&&t instanceof Element&&t.closest(i)||a()}};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},s=[n,r,i,a],t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s):(o=t[4],s=t[5]),(0,J.useEffect)(o,s)}var E5=20,Sve=`xopc.atMention.recent:`;function D5(e){return`${Sve}${e.trim()}`}function O5(e){let t=e?.trim();if(!t||typeof localStorage>`u`)return[];try{let e=localStorage.getItem(D5(t));if(!e)return[];let n=JSON.parse(e);return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0).slice(0,E5):[]}catch{return[]}}function Cve(e,t){let n=e?.trim(),r=t.trim();if(!(!n||!r||typeof localStorage>`u`))try{let e=[r,...O5(n).filter(e=>e!==r)].slice(0,E5);localStorage.setItem(D5(n),JSON.stringify(e))}catch{}}var wve=150,Tve=15;function k5(e,t){let n=e.length,r=Math.min(Math.max(t,0),n);if(r<1)return null;let i=e.slice(0,r),a=i.match(/@([^\s]*)$/);if(!a||a.index===void 0)return null;let o=a.index;if(o>0&&/[a-zA-Z0-9_]/.test(e[o-1]))return null;let s=i.slice(o);return/^@(file|doc|url|symbol):/.test(s)?null:{start:o,end:r,query:a[1]??``}}function Eve(e){let t=e.trim();return t.length>0&&t.endsWith(`/`)&&!/^https?:\/\//i.test(t)}function A5(e){return e.replace(/\/+$/,``).trim()}function Dve(e){let t=e.replace(/\/+$/,``);if(!t)return``;let n=t.lastIndexOf(`/`);return n<=0?``:t.slice(0,n)}function Ove(e,t){return t===0?0:Math.min(e,t-1)}function kve(e,t,n){let[r,i]=(0,J.useState)(0),a=(0,J.useMemo)(()=>n.precomputedAtRange===void 0?n.isComposing||n.slashPaletteOpen?null:k5(e,t):n.isComposing||n.slashPaletteOpen?null:n.precomputedAtRange,[e,t,n.slashPaletteOpen,n.isComposing,n.precomputedAtRange]),o=a!==null,[s]=uU(o?a?.query??``:``,wve),c=o?s:``,l=n.sessionKey?.trim()??``,u=UF(async()=>{if(!l)return[];if(Eve(c)){let e=A5(c),t=(await Mle(e,{sessionKey:l})).map(e=>({name:e.name,relativePath:e.path,isDirectory:e.isDirectory}));return e?[{name:`..`,relativePath:``,isDirectory:!0,isBrowseUp:!0},...t]:t}let e=await E1(c,{sessionKey:l,limit:Tve}),t=O5(l),n=[],r=new Set(e.map(e=>e.relativePath));for(let e of t){if(r.has(e))continue;r.add(e);let t=e.replace(/\/$/,``).split(`/`).pop()??e;if(n.push({name:t,relativePath:e,isDirectory:e.endsWith(`/`),isRecent:!0}),n.length>=5)break}return[...n,...e]},[c,l],{enabled:o&&!!l,initial:[],errorData:[]}),d=o?u.data:[],f=o?u.loading:!1,p=o&&u.error!=null?u.error instanceof Error?u.error.message:String(u.error):null,m=a?.start,h=a?.end,g=`${m??``}:${h??``}:${c}`,_=(0,J.useRef)(g);_.current!==g&&(_.current=g,r!==0&&i(0));let v=Ove(r,d.length),y=(0,J.useCallback)(e=>{d.length!==0&&i(t=>e===`down`?(t+1)%d.length:(t-1+d.length)%d.length)},[d.length]);return{open:o,atRange:a,items:d,selectedIndex:v,query:a?.query??``,loading:f,error:p,onNavigate:y,setSelectedIndex:i}}function Ave(e){let{sessionKey:t,editorValue:n,editorCursor:r,isComposing:i,runBusy:a,thinkingLevel:o,editorRef:s,valueRef:c,resetEditor:l,clearAttachments:u,onSend:d,onUserTextCommitted:f,onChatAgentChange:p,onAddPendingFollowUp:m,onAbort:h,pendingFollowUpsCount:g,maxPendingFollowUps:_,commandPalettePanelRef:v}=e,y=(0,J.useMemo)(()=>k5(n,r),[n,r]),b=X_e(n,r,{suppress:y!=null,isComposing:i}),x=kve(n,r,{sessionKey:t,slashPaletteOpen:b.open,isComposing:i,precomputedAtRange:y}),S=b.open||x.open||y!=null,C=(0,J.useCallback)(()=>({slashRange:b.slashRange,runBusy:a,pendingFollowUpsCount:g,maxPendingFollowUps:_,thinkingLevel:o,editor:{valueRef:c,resetEditor:l},attachments:{clearAttachments:u},callbacks:{onSend:d,onUserTextCommitted:f,onChatAgentChange:p,onAddPendingFollowUp:m,onAbort:h}}),[b.slashRange,a,g,_,o,c,l,u,d,f,p,m,h]),w=(0,J.useCallback)(e=>{z_e(e,C())},[C]),T=(0,J.useCallback)((e,n)=>{let r=x.atRange;if(!r)return;if(e.isBrowseUp){let e=Dve(A5(r.query)),t=`@${e?`${e}/`:``}`;l({nextText:m5(c.current,r.start,r.end,t),caretOffset:r.start+t.length,focus:!0});return}let i=e.isDirectory&&!e.relativePath.endsWith(`/`)?`${e.relativePath}/`:e.relativePath,a=`@file:${L8(i)}`;t&&!e.isDirectory&&Cve(t,i.replace(/\/$/,``));let o=a+(n?.stayOpen?` @`:` `);l({nextText:m5(c.current,r.start,r.end,o),caretOffset:r.start+o.length,focus:!0})},[x.atRange,t,c,l]),E=(0,J.useRef)(b.slashRange);E.current=b.slashRange;let D=c,O=(0,J.useCallback)(()=>{let e=E.current;if(!e)return;let t=D.current;l({nextText:t.slice(0,e.start)+t.slice(e.end),caretOffset:e.start})},[l,D]),k=(0,J.useMemo)(()=>[s,v],[s,v]);xve({active:b.open,anchors:k,ignoreSelector:`[data-slash-palette-tooltip]`,onDismiss:O});let A=(0,J.useRef)(x);A.current=x;let j=(0,J.useRef)(b);j.current=b;let M=(0,J.useRef)(i);M.current=i;let N=(0,J.useRef)(w);N.current=w;let P=(0,J.useRef)(T);P.current=T;let F=(0,J.useRef)({runBusy:a,pendingFollowUpsCount:g,maxPendingFollowUps:_});F.current={runBusy:a,pendingFollowUpsCount:g,maxPendingFollowUps:_};let I=(0,J.useMemo)(()=>({name:`at-mention`,isActive:()=>{let e=A.current;return e.open&&e.atRange!=null&&!M.current},handleKey:e=>{let t=A.current;if(!t.atRange)return!1;if(e.key===`Escape`){e.preventDefault();let n=t.atRange,r=D.current;return l({nextText:m5(r,n.start,n.end,``),caretOffset:n.start,focus:!0}),!0}if(t.items.length===0)return!1;if(e.key===`ArrowDown`)return e.preventDefault(),t.onNavigate(`down`),!0;if(e.key===`ArrowUp`)return e.preventDefault(),t.onNavigate(`up`),!0;if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let n=t.items[t.selectedIndex];return n&&P.current(n,{stayOpen:e.shiftKey}),!0}return!1}}),[l,D]),L=(0,J.useMemo)(()=>({name:`slash-palette`,isActive:()=>j.current.open&&!M.current,handleKey:e=>{let t=j.current;if(t.items.length>0){if(e.key===`ArrowDown`)return e.preventDefault(),t.onNavigate(`down`),!0;if(e.key===`ArrowUp`)return e.preventDefault(),t.onNavigate(`up`),!0;if((e.key===`Enter`||e.key===`Tab`)&&!e.shiftKey){e.preventDefault();let n=t.items[t.selectedIndex];return!n||y5(n,F.current)||N.current(n),!0}}if(e.key===`Escape`){e.preventDefault();let n=t.slashRange;if(n){let e=D.current;l({nextText:m5(e,n.start,n.end,``),caretOffset:n.start,focus:!0})}return!0}return!1}}),[l,D]);return{palette:b,atPicker:x,shouldSyncSelection:S,adapters:(0,J.useMemo)(()=>[I,L],[I,L]),applyPalette:w,applyAtMention:T}}function jve(e,t){let n=t.trim();if(!n)return e;let r=e.trim();return r?`${r} ${n}`:n}var j5=X(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,AX.transition,AX.press,AX.focusRingPanel,`disabled:cursor-not-allowed disabled:opacity-50`),Mve=(0,J.memo)(function(e){let t=(0,Y.c)(30),{phase:n,elapsedLabel:r,disabled:i,chat:a,onCancel:o,onConfirm:s}=e,c=n===`transcribing`,l=a.voiceInput,u=!c&&`animate-pulse`,d;t[0]===u?d=t[1]:(d=X(`size-2 shrink-0 rounded-full bg-red-500`,u),t[0]=u,t[1]=d);let f;t[2]===d?f=t[3]:(f=(0,Z.jsx)(`span`,{className:d,"aria-hidden":!0}),t[2]=d,t[3]=f);let p=c?a.voiceTranscribing:a.voiceRecordingStatus,m;t[4]===p?m=t[5]:(m=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg-muted`,children:p}),t[4]=p,t[5]=m);let h=c?``:r,g;t[6]===h?g=t[7]:(g=(0,Z.jsx)(`span`,{className:`shrink-0 tabular-nums text-sm text-fg-subtle`,"aria-live":`polite`,children:h}),t[6]=h,t[7]=g);let _=i||c,v;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(oO,{className:`size-4`}),t[8]=v):v=t[8];let y;t[9]!==a.voiceInputCancel||t[10]!==o||t[11]!==_?(y=(0,Z.jsx)(`button`,{type:`button`,className:j5,disabled:_,title:a.voiceInputCancel,"aria-label":a.voiceInputCancel,onClick:o,children:v}),t[9]=a.voiceInputCancel,t[10]=o,t[11]=_,t[12]=y):y=t[12];let b;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(b=X(j5,`text-fg`),t[13]=b):b=t[13];let x=i||c,S;t[14]===c?S=t[15]:(S=c?(0,Z.jsx)(Cg,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(Ml,{className:`size-4`}),t[14]=c,t[15]=S);let C;t[16]!==a.voiceInputConfirm||t[17]!==s||t[18]!==x||t[19]!==S?(C=(0,Z.jsx)(`button`,{type:`button`,className:b,disabled:x,title:a.voiceInputConfirm,"aria-label":a.voiceInputConfirm,onClick:s,children:S}),t[16]=a.voiceInputConfirm,t[17]=s,t[18]=x,t[19]=S,t[20]=C):C=t[20];let w;t[21]!==y||t[22]!==C?(w=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[y,C]}),t[21]=y,t[22]=C,t[23]=w):w=t[23];let T;return t[24]!==a.voiceInput||t[25]!==w||t[26]!==f||t[27]!==m||t[28]!==g?(T=(0,Z.jsxs)(`div`,{className:`flex min-h-10 w-full items-center gap-2 py-2`,role:`region`,"aria-label":l,children:[f,m,g,w]}),t[24]=a.voiceInput,t[25]=w,t[26]=f,t[27]=m,t[28]=g,t[29]=T):T=t[29],T});async function Nve(e){return ML(await e.arrayBuffer())}async function Pve(e,t){let n=await Nve(e),r=await we(_(`/api/voice/transcribe`),{method:`POST`,body:JSON.stringify({audio:n,mimeType:t})});if(!r.payload)throw Error(`Missing transcription payload`);return r.payload}var M5=null;async function Fve(){if(M5!==null)return M5;try{M5=(await we(_(`/api/status`))).voice?.sttAvailable===!0}catch{M5=!1}return M5}function Ive(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e%60);return`${Math.floor(e/60)}:${t.toString().padStart(2,`0`)}`}function Lve(e){let{disabled:t,chat:n,onTranscript:r}=e,[i,a]=(0,J.useState)(`idle`),[o,s]=(0,J.useState)(0),c=(0,J.useRef)(null),l=(0,J.useRef)([]),u=(0,J.useRef)(null),d=(0,J.useRef)(``),f=(0,J.useRef)(!1),p=(0,J.useRef)(!1),m=(0,J.useRef)(null),h=(0,J.useRef)(null),g=(0,J.useRef)(r);g.current=r;let _=(0,J.useCallback)(()=>{h.current!=null&&(clearInterval(h.current),h.current=null)},[]),v=(0,J.useCallback)(()=>{u.current?.getTracks().forEach(e=>e.stop()),u.current=null},[]),y=(0,J.useCallback)(()=>{_(),v(),c.current=null,l.current=[],m.current=null,p.current=!1,f.current=!1,s(0),a(`idle`)},[_,v]),b=(0,J.useCallback)(()=>{let e=c.current;e&&e.state!==`inactive`?e.stop():y(),c.current=null},[y]),x=(0,J.useCallback)(()=>{f.current=!0,p.current=!1,b()},[b]),S=(0,J.useCallback)(async(e,t)=>{a(`transcribing`);let r=new Blob(e,{type:t||`audio/webm`});if(r.size<32){fH(`warning`,n.voiceTranscribeEmpty),y();return}try{let e=await Pve(r,r.type||t||`audio/webm`),i=(e.refined??e.raw).trim();if(!i){fH(`warning`,n.voiceTranscribeEmpty),y();return}g.current(i),y()}catch(e){let t=e instanceof Error?e.message:String(e);t.includes(`STT is not configured`)||t.includes(`503`)?fH(`error`,n.voiceSttNotConfigured):fH(`error`,n.voiceTranscribeFailed),y()}},[y,n.voiceSttNotConfigured,n.voiceTranscribeEmpty,n.voiceTranscribeFailed]),C=(0,J.useCallback)(()=>{_(),h.current=setInterval(()=>{let e=m.current;typeof e==`number`&&s(Math.max(0,(performance.now()-e)/1e3))},200)},[_]),w=(0,J.useCallback)(async()=>{if(!(t||i!==`idle`)){if(!await Fve()){fH(`error`,n.voiceSttNotConfigured);return}f.current=!1,p.current=!1;try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});u.current=e;let t=MediaRecorder.isTypeSupported(`audio/webm;codecs=opus`)?`audio/webm;codecs=opus`:MediaRecorder.isTypeSupported(`audio/webm`)?`audio/webm`:``;d.current=t;let n=t?new MediaRecorder(e,{mimeType:t}):new MediaRecorder(e);l.current=[],n.ondataavailable=e=>{e.data.size>0&&l.current.push(e.data)},n.onstop=()=>{(async()=>{try{let e=l.current;l.current=[];let t=d.current||n.mimeType;if(f.current){y();return}if(p.current){p.current=!1,await S(e,t);return}y()}finally{v()}})()},c.current=n,m.current=performance.now(),s(0),n.start(250),a(`recording`),C()}catch{y(),fH(`error`,n.voiceMicDenied)}}},[t,y,n.voiceMicDenied,n.voiceSttNotConfigured,i,S,C,v]),T=(0,J.useCallback)(()=>{i===`recording`&&(p.current=!0,f.current=!1,a(`transcribing`),_(),b())},[i,b,_]);return(0,J.useEffect)(()=>()=>{f.current=!0,p.current=!1,b()},[b]),{phase:i,voiceActive:i!==`idle`,elapsedLabel:Ive(o),startVoiceInput:w,cancelVoiceInput:x,confirmVoiceInput:T}}var Rve=(0,J.memo)(function({disabled:e,sending:t,streaming:n,sessionKey:r,sessionManager:i,canSelectWorkingDirectory:a,thinkingLevel:o,showThinkingSelector:s,onThinkingChange:c,onSend:l,onAbort:u,onAddPendingFollowUp:f,onSteeringInterrupt:p,pendingFollowUps:h,editingFollowUpId:g,onBeginEditFollowUp:_,onCancelEditFollowUp:v,onCommitEditFollowUp:y,onPendingFollowUpRemove:b,onPendingFollowUpMove:x,onPendingFollowUpReorder:S,onPendingFollowUpSteer:C,steeringFollowUpId:w,welcomeDraftSeed:T,sessionModel:E,showModelSelector:D,onModelChange:O,modelDisabled:k,contextUsageMessages:A,onChatAgentChange:j,currentAgentId:M}){let N=m(d(e=>e.language));(0,J.useEffect)(()=>{v1()},[]);let P=(0,J.useRef)(!1),F=(0,J.useRef)(null),I=(0,J.useRef)(null),L=(0,J.useRef)(null),R=(0,J.useRef)(!1),z=(0,J.useRef)(l),B=(0,J.useRef)(o);z.current=l,B.current=o;let V=bve({chat:N.chat}),H=Qge({disabled:e,welcomeDraftSeed:T,onExternalTextReplace:(0,J.useCallback)(()=>{V.clearAttachments()},[V.clearAttachments]),shouldSyncSelectionRef:P}),{onUserTextCommitted:U,onWireInputClearWalk:W,tryInputHistoryArrow:G}=vve({sessionKey:r,editorRef:H.editorRef,valueRef:H.valueRef,resetEditor:H.resetEditor,onWireInput:H.onWireInput}),ee=t||n;R.current=ee;let K=Ave({sessionKey:r,editorValue:H.value,editorCursor:H.cursor,isComposing:H.isComposing,runBusy:ee,thinkingLevel:o,editorRef:H.editorRef,valueRef:H.valueRef,resetEditor:H.resetEditor,clearAttachments:V.clearAttachments,onSend:l,onUserTextCommitted:U,onChatAgentChange:j,onAddPendingFollowUp:f,onAbort:u,pendingFollowUpsCount:h.length,maxPendingFollowUps:10,commandPalettePanelRef:F});P.current=K.shouldSyncSelection;let te=(0,J.useMemo)(()=>H.value.length,[H.value]),ne=Lve({disabled:e,chat:N.chat,onTranscript:e=>{let t=H.valueRef.current,n=jve(t,e);H.resetEditor({nextText:n,caretOffset:n.length,focus:!0})}}),re=(0,J.useCallback)(()=>{L.current=null},[]),ie=yve({chat:N.chat,runBusy:ee,voiceActive:ne.voiceActive,cancelVoiceInput:ne.cancelVoiceInput,editingFollowUpId:g,getTextValue:()=>H.valueRef.current,getAttachmentCount:()=>V.attachmentsRef.current.length,wireAttachmentsPayload:V.wireAttachmentsPayload,getThinkingLevel:()=>B.current,onSend:l,onAddPendingFollowUp:f,onSteeringInterrupt:p,onCommitEditFollowUp:y,onPendingFollowUpRemove:b,pendingFollowUpsCount:h.length,resetEditor:()=>{H.resetEditor()},clearAttachments:V.clearAttachments,clearEditFollowUpRef:re,onUserTextCommitted:U});(0,J.useLayoutEffect)(()=>{if(!g){L.current&&=(V.clearAttachments(),H.resetEditor(),null);return}if(g===L.current)return;let e=h.find(e=>e.id===g);if(!e){v();return}L.current=g,e.thinkingLevel!=null&&s&&c(e.thinkingLevel),V.setAttachments(A_e(e.attachments??[])),H.resetEditor({nextText:e.text,focus:!0})},[V.clearAttachments,V.setAttachments,H.resetEditor,g,v,c,h,s]);let ae=(0,J.useCallback)(e=>{_(e)},[_]),oe=(0,J.useRef)({});oe.current={adapters:K.adapters,send:ie.send,runBusy:ee,pendingFollowUpsCount:h.length,flushSteeringDraft:ie.flushSteeringDraft,interruptDraft:ie.interruptDraft,editingFollowUpId:g,onCancelEditFollowUp:v,attachmentsLen:V.attachments.length,isComposing:H.isComposing,valueRef:H.valueRef,adjustHeight:H.adjustHeight,editorRef:H.editorRef,tryInputHistoryArrow:G};let se=ee,q=!!H.value.trim()||V.attachments.length>0,ce=q&&!!p;return(0,Z.jsxs)(`div`,{className:X(`relative flex min-h-0 w-full flex-col overflow-hidden rounded-xl bg-surface-panel shadow-surface ring-1 ring-inset ring-edge dark:bg-surface-panel/60 dark:shadow-none`,V.isDragging&&`ring-2 ring-accent ring-inset`),onDragOver:e=>{e.dataTransfer?.types.includes(`Files`)&&(e.preventDefault(),V.setIsDragging(!0))},onDragLeave:e=>{e.relatedTarget===null&&V.setIsDragging(!1)},onDrop:async e=>{e.preventDefault(),V.setIsDragging(!1);let t=e.dataTransfer?.files;t?.length&&await V.processFiles(Array.from(t))},children:[V.isDragging?(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-xl bg-accent-soft/80 text-sm font-medium text-accent-fg backdrop-blur-[1px]`,children:N.chat.dropFiles}):null,h.length>0?(0,Z.jsx)(`div`,{className:`max-h-[min(30vh,11rem)] shrink-0 overflow-y-auto overflow-x-hidden border-b border-edge-subtle/80 [scrollbar-gutter:stable] dark:border-edge-subtle/70`,children:(0,Z.jsx)(e_e,{items:h,disabled:e,editingFollowUpId:g,onEditInComposer:ae,onRemove:b,onMove:x,onReorder:S,onSteer:C,steeringBusyId:w})}):null,(0,Z.jsx)(i_e,{attachments:V.attachments,topPadded:h.length>0,onRemove:V.removeAttachment}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 shrink-0 flex-col`,children:[(0,Z.jsx)(`input`,{ref:I,type:`file`,multiple:!0,accept:A8,className:`hidden`,onChange:async e=>{let t=e.target.files;t&&await V.processFiles(Array.from(t)),e.target.value=``}}),(0,Z.jsxs)(`div`,{className:X(`relative px-4 pb-0 pt-1`,V.attachments.length>0&&`pt-2`),children:[(0,Z.jsx)(I_e,{open:K.atPicker.open,anchorRef:H.editorRef,items:K.atPicker.items,selectedIndex:K.atPicker.selectedIndex,loading:K.atPicker.loading,query:K.atPicker.query,noResults:K.atPicker.error??N.chat.atMention.noResults,sessionKey:r,recentLabel:N.chat.atMention.recentBadge,ariaLabel:N.chat.atMention.placeholder,shiftHint:N.chat.atMention.shiftHint,onSelectItem:(e,t)=>K.applyAtMention(e,{stayOpen:t?.shiftKey===!0})}),(0,Z.jsx)(mve,{open:K.palette.open,anchorRef:H.editorRef,panelRef:F,items:K.palette.loadError?[]:K.palette.items,selectedIndex:K.palette.selectedIndex,noResults:K.palette.loadError??N.chat.commandPalette.noResults,grouped:K.palette.loadError?!1:K.palette.grouped,skillRowCount:K.palette.loadError?0:K.palette.skillRowCount,commandRowCount:K.palette.loadError?0:K.palette.commandRowCount,query:K.palette.query,skillsLabel:N.chat.commandPalette.skillsSection,commandsLabel:N.chat.commandPalette.commandsSection,agentsLabel:N.chat.commandPalette.agentsSection,groupedHasSkills:K.palette.loadError?!1:K.palette.groupedHasSkills,groupedHasCommands:K.palette.loadError?!1:K.palette.groupedHasCommands,groupedHasAgents:K.palette.loadError?!1:K.palette.groupedHasAgents,groupedSkillsShowMoreLabel:K.palette.loadError||!K.palette.grouped?null:K.palette.groupedSkillsMoreCount>0?Q8(N.chat.commandPalette.showGroupedMore,{count:K.palette.groupedSkillsMoreCount}):null,groupedCommandsShowMoreLabel:K.palette.loadError||!K.palette.grouped?null:K.palette.groupedCommandsMoreCount>0?Q8(N.chat.commandPalette.showGroupedMore,{count:K.palette.groupedCommandsMoreCount}):null,groupedAgentsShowMoreLabel:K.palette.loadError||!K.palette.grouped?null:K.palette.groupedAgentsMoreCount>0?Q8(N.chat.commandPalette.showGroupedMore,{count:K.palette.groupedAgentsMoreCount}):null,onExpandSkills:K.palette.expandGroupedSkills,onExpandCommands:K.palette.expandGroupedCommands,onExpandAgents:K.palette.expandGroupedAgents,currentAgentId:M,currentBadgeLabel:N.chat.commandPalette.currentBadge,runBusy:ee,pendingFollowUpsCount:h.length,maxPendingFollowUps:10,queueBadgeLabel:N.chat.commandPalette.queueBadge,queueFullBadgeLabel:N.chat.commandPalette.queueFullBadge,queueFullTooltip:N.chat.commandPalette.queueFullTooltip,onSelectItem:K.applyPalette}),ne.voiceActive?(0,Z.jsx)(Mve,{phase:ne.phase,elapsedLabel:ne.elapsedLabel,disabled:e,chat:N.chat,onCancel:ne.cancelVoiceInput,onConfirm:ne.confirmVoiceInput}):(0,Z.jsx)($ge,{editorRef:H.editorRef,disabled:e,placeholder:se?g?N.chat.inputPlaceholderSteeringEdit:N.chat.inputPlaceholderSteering:N.chat.inputPlaceholder,onWireInput:W,adjustHeight:H.adjustHeight,processFiles:V.processFiles,setIsComposing:H.setIsComposing,kbdRef:oe,chatMessages:N.chat})]}),(0,Z.jsx)(O_e,{sessionKey:r,sessionManager:i,disabled:e,sending:t,streaming:n,canSelectWorkingDirectory:a,runBusy:se,chat:N.chat,hasDraft:q,showSteeringInterrupt:ce,attachmentCount:V.attachments.length,maxAttachments:10,onPickFiles:()=>I.current?.click(),thinkingLevel:o,showThinkingSelector:s,onThinkingChange:c,voiceActive:ne.voiceActive,onStartVoiceInput:ne.startVoiceInput,onSend:ie.send,onAbort:u,onInterrupt:ie.interruptDraft,sessionModel:E,showModelSelector:D,onModelChange:O,modelDisabled:k,contextUsageMessages:A,composerDraftChars:te})]})]})});function zve(e,t){let n=e.createdAt;if(!Number.isFinite(n)||n<=0)return 0;let r=typeof e.lastTurnAt==`number`&&Number.isFinite(e.lastTurnAt)?e.lastTurnAt:0,i=e.status===`done`&&r>=n?r:t;return Math.max(0,i-n)}function Bve(e,t){let n=Math.max(0,Math.floor(e/1e3));if(n<60)return t===`zh`?`${n}秒`:`${n}s`;let r=Math.floor(n/60),i=n%60;if(r<60)return t===`zh`?`${r}分${String(i).padStart(2,`0`)}秒`:`${r}m ${i}s`;let a=Math.floor(r/60),o=r%60;return t===`zh`?`${a}小时${o}分`:`${a}h ${o}m`}async function N5(e,t){let n=new URLSearchParams({sessionKey:e});return t?.uiLocale&&n.set(`uiLocale`,t.uiLocale),we(_(`/api/goals/webchat?${n.toString()}`))}async function Vve(e,t,n){return we(_(`/api/goals/webchat`),{method:`POST`,body:JSON.stringify({sessionKey:e,action:t,...n?.uiLocale?{uiLocale:n.uiLocale}:{}})})}async function Hve(e,t,n){let r={sessionKey:e,op:t.op};return t.op===`add`&&(r.text=t.text),(t.op===`remove`||t.op===`mark`)&&(r.index=t.index),t.op===`mark`&&(r.status=t.status),n?.uiLocale&&(r.uiLocale=n.uiLocale),we(_(`/api/goals/webchat/checklist`),{method:`POST`,body:JSON.stringify(r)})}async function P5(e,t){let n=new URLSearchParams({sessionKey:e});return t?.limit!=null&&Number.isFinite(t.limit)&&n.set(`limit`,String(Math.min(500,Math.max(1,Math.floor(t.limit))))),we(_(`/api/goals/webchat/runs?${n.toString()}`))}function Uve(e){let t=(0,Y.c)(45),{goal:n,canEditChecklist:r,mutationBusy:i,t:a,onAction:o,onChecklist:s}=e,c=i||n.status!==`active`,l;t[0]===o?l=t[1]:(l=()=>void o(`pause`),t[0]=o,t[1]=l);let u;t[2]!==a.pause||t[3]!==c||t[4]!==l?(u=(0,Z.jsx)(wA,{type:`button`,variant:`primary`,className:`h-8 px-3 text-xs`,disabled:c,onClick:l,children:a.pause}),t[2]=a.pause,t[3]=c,t[4]=l,t[5]=u):u=t[5];let d=i||n.status!==`paused`&&n.status!==`done`,f;t[6]===o?f=t[7]:(f=()=>void o(`resume`),t[6]=o,t[7]=f);let p;t[8]!==a.resume||t[9]!==d||t[10]!==f?(p=(0,Z.jsx)(wA,{type:`button`,variant:`secondary`,className:`h-8 px-3 text-xs`,disabled:d,onClick:f,children:a.resume}),t[8]=a.resume,t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(m=X(`flex h-8 cursor-pointer list-none items-center rounded-md border border-edge bg-surface-panel px-2.5 text-xs text-fg-muted`,`marker:hidden [&::-webkit-details-marker]:hidden`,`hover:bg-surface-hover hover:text-fg`),t[12]=m):m=t[12];let h;t[13]!==a.moreActions||t[14]!==a.moreHint?(h=(0,Z.jsx)(`summary`,{className:m,title:a.moreHint,children:a.moreActions}),t[13]=a.moreActions,t[14]=a.moreHint,t[15]=h):h=t[15];let g;t[16]===o?g=t[17]:(g=()=>void o(`restart`),t[16]=o,t[17]=g);let _;t[18]!==i||t[19]!==a.restart||t[20]!==g?(_=(0,Z.jsx)(`button`,{type:`button`,className:`block w-full px-3 py-1.5 text-left text-xs text-fg hover:bg-surface-hover`,disabled:i,onClick:g,children:a.restart}),t[18]=i,t[19]=a.restart,t[20]=g,t[21]=_):_=t[21];let v=i||!r,y;t[22]===s?y=t[23]:(y=()=>void s({op:`reset`}),t[22]=s,t[23]=y);let b;t[24]!==a.resetChecklist||t[25]!==v||t[26]!==y?(b=(0,Z.jsx)(`button`,{type:`button`,className:`block w-full px-3 py-1.5 text-left text-xs text-fg hover:bg-surface-hover`,disabled:v,onClick:y,children:a.resetChecklist}),t[24]=a.resetChecklist,t[25]=v,t[26]=y,t[27]=b):b=t[27];let x;t[28]===o?x=t[29]:(x=()=>void o(`clear`),t[28]=o,t[29]=x);let S;t[30]!==i||t[31]!==a.clear||t[32]!==x?(S=(0,Z.jsx)(`button`,{type:`button`,className:`block w-full px-3 py-1.5 text-left text-xs text-destructive hover:bg-surface-hover`,disabled:i,onClick:x,children:a.clear}),t[30]=i,t[31]=a.clear,t[32]=x,t[33]=S):S=t[33];let C;t[34]!==_||t[35]!==b||t[36]!==S?(C=(0,Z.jsxs)(`div`,{className:`absolute right-0 z-30 mt-1 min-w-[11rem] rounded-md border border-edge bg-surface-panel py-1 shadow-surface`,children:[_,b,S]}),t[34]=_,t[35]=b,t[36]=S,t[37]=C):C=t[37];let w;t[38]!==C||t[39]!==h?(w=(0,Z.jsxs)(`details`,{className:`group relative`,children:[h,C]}),t[38]=C,t[39]=h,t[40]=w):w=t[40];let T;return t[41]!==w||t[42]!==u||t[43]!==p?(T=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[u,p,w]}),t[41]=w,t[42]=u,t[43]=p,t[44]=T):T=t[44],T}function Wve(e){return e!==null&&e.status!==`cleared`}function F5(e){let t=e.checklist??[];return{total:t.length,done:t.filter(e=>e.status===`completed`||e.status===`impossible`).length}}function Gve(e){let t=Math.max(0,e.maxTurns),n=Math.max(0,e.turnsUsed);return{used:n,total:t,percent:t>0?Math.min(100,100*n/t):0}}function Kve(e){let{done:t,total:n}=F5(e);return{done:t,total:n,percent:n>0?Math.min(100,100*t/n):0}}function qve(e,t){return t?`agent_running`:e.status===`paused`?`paused`:e.status===`done`?`done`:e.lastVerdict?`judge_recently_completed`:`idle`}function I5(e,t){let n=t;return e===`agent_running`?n.phaseAgentRunning??t.agentRunning:e===`paused`?n.phasePaused??t.statusPaused:e===`done`?n.phaseDone??t.statusDone:e===`judge_recently_completed`?n.phaseJudged??t.lastVerdict:n.missionHeading??t.heading}function Jve(e,t){return e.status===`active`?t.statusActive:e.status===`paused`?t.statusPaused:e.status===`done`?t.statusDone:e.status}function L5(e,t){return e===`done`?t.verdictDone:e===`continue`?t.verdictContinue:e===`skipped`?t.verdictSkipped:e===`decompose`?t.verdictDecompose:e??``}function R5(e,t){return e===`inactive`?t.verdictInactive:L5(e,t)}function z5(e,t){return e===`active`?t.statusActive:e===`paused`?t.statusPaused:e===`done`?t.statusDone:e}function B5(e){return`xopc:goalBannerCollapsed:${e}`}function Yve(e){return e.status===`completed`?`✓`:e.status===`impossible`?`!`:`○`}function Xve(e){let t={pending:[],completed:[],impossible:[]};return e.forEach((e,n)=>{t[e.status].push({...e,index1Based:n+1})}),t}function Zve(e){let t=(0,Y.c)(30),{goal:n,canEdit:r,mutationBusy:i,t:a,onMutate:o}=e,[s,c]=(0,J.useState)(``),l,u,d;if(t[0]!==r||t[1]!==n.checklist||t[2]!==i||t[3]!==o||t[4]!==a){let e=n.checklist??[],s=Xve(e),c=a,f;t[8]!==r||t[9]!==c||t[10]!==i||t[11]!==o||t[12]!==a.markBlocked||t[13]!==a.markDone||t[14]!==a.removeItem?(f=(e,t)=>t.length===0?null:(0,Z.jsxs)(`section`,{className:`space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:e}),(0,Z.jsx)(`span`,{children:t.length})]}),(0,Z.jsx)(`ul`,{className:`space-y-1.5`,children:t.map(e=>(0,Z.jsx)(`li`,{className:`rounded-md border border-transparent px-1.5 py-1 hover:border-edge/60 hover:bg-surface-panel/70`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(`span`,{className:`mt-0.5 w-4 shrink-0 text-center text-fg-muted`,title:e.status,children:Yve(e)}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`p`,{className:`break-words text-fg`,children:e.text}),(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1.5 text-[10px] text-fg-muted`,children:[(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-panel px-1.5 py-0.5`,children:e.addedBy===`user`?c.userAdded??`User`:c.judgeGenerated??`Judge`}),e.evidence?(0,Z.jsxs)(`span`,{className:`min-w-0 break-words`,children:[c.evidenceLabel??`Evidence`,`: `,e.evidence]}):null]})]}),r&&e.status===`pending`?(0,Z.jsxs)(`span`,{className:`flex shrink-0 flex-wrap justify-end gap-0.5`,children:[(0,Z.jsx)(wA,{type:`button`,variant:`ghost`,className:`h-7 px-1.5 text-[11px] text-accent`,disabled:i,onClick:()=>void o({op:`mark`,index:e.index1Based,status:`completed`}),children:a.markDone}),(0,Z.jsx)(wA,{type:`button`,variant:`ghost`,className:`h-7 px-1.5 text-[11px] text-fg-muted`,disabled:i,onClick:()=>void o({op:`mark`,index:e.index1Based,status:`impossible`}),children:a.markBlocked}),(0,Z.jsx)(wA,{type:`button`,variant:`ghost`,className:`h-7 px-1.5 text-[11px] text-destructive`,disabled:i,onClick:()=>void o({op:`remove`,index:e.index1Based}),children:a.removeItem})]}):null]})},`${e.index1Based}-${e.text.slice(0,24)}`))})]}),t[8]=r,t[9]=c,t[10]=i,t[11]=o,t[12]=a.markBlocked,t[13]=a.markDone,t[14]=a.removeItem,t[15]=f):f=t[15];let p=f;l=`rounded-xl bg-surface-muted/70 px-2.5 py-2 dark:bg-surface-muted/40`,t[16]===a.checklistHeading?u=t[17]:(u=(0,Z.jsx)(`p`,{className:`mb-1.5 text-[11px] font-medium uppercase tracking-wide text-fg-muted`,children:a.checklistHeading}),t[16]=a.checklistHeading,t[17]=u),d=e.length===0?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.checklistEmpty}):(0,Z.jsxs)(`div`,{className:`max-h-48 space-y-2 overflow-y-auto pr-0.5 text-xs`,children:[p(c.pendingGroup??`Pending`,s.pending),p(c.completedGroup??`Completed`,s.completed),p(c.impossibleGroup??`Blocked`,s.impossible)]}),t[0]=r,t[1]=n.checklist,t[2]=i,t[3]=o,t[4]=a,t[5]=l,t[6]=u,t[7]=d}else l=t[5],u=t[6],d=t[7];let f;t[18]!==r||t[19]!==i||t[20]!==s||t[21]!==o||t[22]!==a.addCriterion||t[23]!==a.addCriterionPlaceholder?(f=r?(0,Z.jsxs)(`div`,{className:`mt-2 flex gap-1.5`,children:[(0,Z.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:a.addCriterionPlaceholder,className:X(`min-w-0 flex-1 rounded-md border border-edge bg-surface-muted px-2 py-1.5 text-xs text-fg`,`placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`),onKeyDown:e=>{e.key===`Enter`&&s.trim()&&(e.preventDefault(),Promise.resolve(o({op:`add`,text:s.trim()})).then(()=>c(``)))}}),(0,Z.jsx)(wA,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 px-2.5 text-xs`,disabled:i||!s.trim(),onClick:()=>void Promise.resolve(o({op:`add`,text:s.trim()})).then(()=>c(``)),children:a.addCriterion})]}):null,t[18]=r,t[19]=i,t[20]=s,t[21]=o,t[22]=a.addCriterion,t[23]=a.addCriterionPlaceholder,t[24]=f):f=t[24];let p;return t[25]!==l||t[26]!==u||t[27]!==d||t[28]!==f?(p=(0,Z.jsxs)(`div`,{className:l,children:[u,d,f]}),t[25]=l,t[26]=u,t[27]=d,t[28]=f,t[29]=p):p=t[29],p}function Qve(e){let t=(0,Y.c)(23),{goal:n,agentBusy:r,pillTitle:i,phase:a,statusShort:o,turnsShort:s,clLine:c,t:l,onExpand:u}=e,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=X(`pointer-events-none absolute z-30`,`right-[max(0.75rem,env(safe-area-inset-right,0px))] top-[max(0.5rem,env(safe-area-inset-top,0px))]`,`sm:right-[max(1.25rem,env(safe-area-inset-right,0px))] xl:right-[max(1.5rem,env(safe-area-inset-right,0px))]`),t[0]=d):d=t[0];let f;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(f=X(`pointer-events-auto flex h-11 min-w-11 max-w-[min(calc(100vw-1.5rem),16rem)] items-center gap-1.5 rounded-full border border-edge/60 bg-surface-panel/95 px-2.5 py-1 text-left shadow-elevated backdrop-blur-sm`,`transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),t[1]=f):f=t[1];let p=`${i}${c?` · ${c}`:``}${n.lastVerdict?`\n${l.lastVerdict}: ${n.lastVerdict}`:``}${n.lastReason?`\n${l.lastReason}: ${n.lastReason}`:``}\n${n.goal}`,m=l.expandAria,h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(Vw,{className:`size-4 text-accent`,"aria-hidden":!0}),t[2]=h):h=t[2];let g;t[3]!==r||t[4]!==n.status?(g=(0,Z.jsxs)(`span`,{className:`relative flex size-8 shrink-0 items-center justify-center rounded-full bg-surface-muted`,children:[h,r?(0,Z.jsx)(`span`,{className:`absolute -right-0.5 -top-0.5 flex size-2.5 rounded-full border-2 border-surface-panel bg-accent motion-safe:animate-pulse`}):(0,Z.jsx)(`span`,{className:X(`absolute -right-0.5 -top-0.5 size-2.5 rounded-full border-2 border-surface-panel`,n.status===`active`&&`bg-accent`,n.status===`paused`&&`bg-fg-muted`,n.status===`done`&&`bg-fg-muted`)})]}),t[3]=r,t[4]=n.status,t[5]=g):g=t[5];let _;t[6]!==a||t[7]!==l?(_=I5(a,l),t[6]=a,t[7]=l,t[8]=_):_=t[8];let v;t[9]!==o||t[10]!==_?(v=(0,Z.jsxs)(`span`,{className:`block truncate text-[10px] font-medium leading-tight text-fg`,children:[_,` · `,o]}),t[9]=o,t[10]=_,t[11]=v):v=t[11];let y=c?`${s} · ${c}`:s,b;t[12]===y?b=t[13]:(b=(0,Z.jsx)(`span`,{className:`block truncate text-[10px] leading-tight text-fg-muted`,children:y}),t[12]=y,t[13]=b);let x;t[14]!==b||t[15]!==v?(x=(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 pr-0.5`,children:[v,b]}),t[14]=b,t[15]=v,t[16]=x):x=t[16];let S;return t[17]!==u||t[18]!==l.expandAria||t[19]!==x||t[20]!==p||t[21]!==g?(S=(0,Z.jsx)(`div`,{className:`relative h-0 shrink-0 overflow-visible`,children:(0,Z.jsx)(`div`,{className:d,children:(0,Z.jsxs)(`button`,{type:`button`,className:f,title:p,"aria-label":m,onClick:u,children:[g,x]})})}),t[17]=u,t[18]=l.expandAria,t[19]=x,t[20]=p,t[21]=g,t[22]=S):S=t[22],S}function $ve(e){let t=(0,Y.c)(37),{goal:n,t:r}=e,[i,a]=(0,J.useState)(!1);if(!(n.lastVerdict||n.lastReason||n.pausedReason))return null;let o=r,s;t[0]!==n.lastVerdict||t[1]!==r?(s=n.lastVerdict?L5(n.lastVerdict,r):``,t[0]=n.lastVerdict,t[1]=r,t[2]=s):s=t[2];let c=s,l=n.pausedReason||n.lastReason,u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>a(eye),t[3]=u):u=t[3];let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(`span`,{className:`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-panel text-accent`,children:(0,Z.jsx)(db,{className:`size-3.5`,"aria-hidden":!0})}),t[4]=d):d=t[4];let f=o.lastJudgementTitle??r.detailsToggle,p;t[5]===f?p=t[6]:(p=(0,Z.jsx)(`span`,{className:`font-medium`,children:f}),t[5]=f,t[6]=p);let m;t[7]===c?m=t[8]:(m=c?(0,Z.jsx)(`span`,{className:`rounded-full border border-edge px-1.5 py-0.5 text-[10px] text-fg-muted`,children:c}):null,t[7]=c,t[8]=m);let h;t[9]!==p||t[10]!==m?(h=(0,Z.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5 text-fg`,children:[p,m]}),t[9]=p,t[10]=m,t[11]=h):h=t[11];let g;t[12]===l?g=t[13]:(g=l?(0,Z.jsx)(`span`,{className:`mt-0.5 line-clamp-2 block text-fg-muted`,children:l}):null,t[12]=l,t[13]=g);let _;t[14]!==h||t[15]!==g?(_=(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[h,g]}),t[14]=h,t[15]=g,t[16]=_):_=t[16];let v=i?o.hideDetails??r.detailsToggle:o.showDetails??r.detailsToggle,y;t[17]===v?y=t[18]:(y=(0,Z.jsx)(`span`,{className:`shrink-0 text-[10px] text-fg-muted`,children:v}),t[17]=v,t[18]=y);let b;t[19]!==y||t[20]!==_?(b=(0,Z.jsxs)(`button`,{type:`button`,className:`flex w-full min-w-0 items-start gap-2 text-left`,onClick:u,children:[d,_,y]}),t[19]=y,t[20]=_,t[21]=b):b=t[21];let x;t[22]!==o.judgeModel||t[23]!==o.parseFailures||t[24]!==o.pausedReason||t[25]!==n.consecutiveParseFailures||t[26]!==n.judgeModelRef||t[27]!==n.lastReason||t[28]!==n.lastVerdict||t[29]!==n.pausedReason||t[30]!==i||t[31]!==r||t[32]!==c?(x=i?(0,Z.jsxs)(`div`,{className:`mt-2 space-y-1.5 rounded-lg border border-edge/70 bg-surface-panel px-2 py-1.5 text-fg-muted`,children:[n.lastVerdict?(0,Z.jsxs)(`p`,{children:[(0,Z.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.lastVerdict,`:`]}),` `,c]}):null,n.lastReason?(0,Z.jsxs)(`p`,{className:`whitespace-pre-wrap break-words`,children:[(0,Z.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.lastReason,`:`]}),` `,n.lastReason]}):null,n.pausedReason?(0,Z.jsxs)(`p`,{className:`whitespace-pre-wrap break-words`,children:[(0,Z.jsxs)(`span`,{className:`font-medium text-fg`,children:[o.pausedReason??r.statusPaused,`:`]}),` `,n.pausedReason]}):null,n.judgeModelRef?(0,Z.jsxs)(`p`,{className:`break-words`,children:[(0,Z.jsxs)(`span`,{className:`font-medium text-fg`,children:[o.judgeModel??`Judge model`,`:`]}),` `,n.judgeModelRef]}):null,n.consecutiveParseFailures?(0,Z.jsxs)(`p`,{children:[(0,Z.jsxs)(`span`,{className:`font-medium text-fg`,children:[o.parseFailures??`Parse failures`,`:`]}),` `,n.consecutiveParseFailures]}):null]}):null,t[22]=o.judgeModel,t[23]=o.parseFailures,t[24]=o.pausedReason,t[25]=n.consecutiveParseFailures,t[26]=n.judgeModelRef,t[27]=n.lastReason,t[28]=n.lastVerdict,t[29]=n.pausedReason,t[30]=i,t[31]=r,t[32]=c,t[33]=x):x=t[33];let S;return t[34]!==b||t[35]!==x?(S=(0,Z.jsxs)(`section`,{className:`rounded-xl border border-edge/70 bg-surface-muted/45 px-2.5 py-2 text-xs dark:bg-surface-muted/25`,children:[b,x]}),t[34]=b,t[35]=x,t[36]=S):S=t[36],S}function eye(e){return!e}function tye(e){let t=(0,Y.c)(3),{goal:n,t:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,Z.jsx)($ve,{goal:n,t:r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}var nye=new Intl.DateTimeFormat(`zh-CN`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}),rye=new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`});function iye(e,t){let n=typeof e==`string`?new Date(e):e;return(t===`zh`?nye:rye).format(n)}function aye(e){let t=(0,Y.c)(25),{sessionKey:n,goal:r,language:i,t:a}=e,o;t[0]===n?o=t[1]:(o=async()=>(await P5(n,{limit:1})).runs,t[0]=n,t[1]=o);let s;t[2]!==r.lastTurnAt||t[3]!==r.lastVerdict||t[4]!==r.turnsUsed||t[5]!==n?(s=[n,r.turnsUsed,r.lastTurnAt,r.lastVerdict],t[2]=r.lastTurnAt,t[3]=r.lastVerdict,t[4]=r.turnsUsed,t[5]=n,t[6]=s):s=t[6];let c;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],t[7]=c):c=t[7];let l;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(l={initial:c,errorData:[]},t[8]=l):l=t[8];let{data:u,loading:d}=UF(o,s,l),f=u[0];if(!f&&!d)return null;let p=a,m=p.latestRunTitle??a.runHistory,h;t[9]===m?h=t[10]:(h=(0,Z.jsx)(`span`,{className:`font-medium uppercase tracking-wide`,children:m}),t[9]=m,t[10]=h);let g;t[11]!==i||t[12]!==f?(g=f?(0,Z.jsx)(`time`,{suppressHydrationWarning:!0,dateTime:new Date(f.at).toISOString(),children:iye(f.at,i)}):null,t[11]=i,t[12]=f,t[13]=g):g=t[13];let _;t[14]!==h||t[15]!==g?(_=(0,Z.jsxs)(`div`,{className:`mb-1 flex flex-wrap items-center justify-between gap-2 text-[10px] text-fg-muted`,children:[h,g]}),t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==p.nextStepContinue||t[18]!==p.nextStepStop||t[19]!==f||t[20]!==a?(v=f?(0,Z.jsxs)(`div`,{className:`grid gap-1.5 sm:grid-cols-[auto_1fr_auto] sm:items-start`,children:[(0,Z.jsx)(`div`,{className:`rounded-full border border-edge bg-surface-muted px-2 py-0.5 text-[10px] text-fg-muted`,children:a.runHistoryTurns.replace(`{{used}}`,String(f.turnsUsed)).replace(`{{max}}`,String(f.maxTurns))}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-fg`,children:[(0,Z.jsx)(`span`,{children:R5(f.verdict,a)}),(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:`·`}),(0,Z.jsx)(`span`,{children:z5(f.statusAfter,a)}),f.checklistProgress?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:`·`}),(0,Z.jsx)(`span`,{children:a.checklistProgress.replace(`{{done}}`,String(f.checklistProgress.done)).replace(`{{total}}`,String(f.checklistProgress.total))})]}):null]}),f.reason?(0,Z.jsx)(`p`,{className:`mt-1 line-clamp-2 break-words text-fg-muted`,children:f.reason}):null]}),(0,Z.jsx)(`div`,{className:`text-[10px] text-accent sm:text-right`,children:f.willContinue?p.nextStepContinue??a.runHistoryContinue:p.nextStepStop??a.runHistoryStop})]}):(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:a.runHistoryLoading}),t[17]=p.nextStepContinue,t[18]=p.nextStepStop,t[19]=f,t[20]=a,t[21]=v):v=t[21];let y;return t[22]!==_||t[23]!==v?(y=(0,Z.jsxs)(`section`,{className:`rounded-xl border border-edge/70 bg-surface-panel px-2.5 py-2 text-xs`,children:[_,v]}),t[22]=_,t[23]=v,t[24]=y):y=t[24],y}function oye(e){let t=(0,Y.c)(49),{goal:n,phase:r,statusShort:i,turnsShort:a,clLine:o,elapsedStr:s,t:c,onCollapse:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(xg,{className:`size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),t[0]=u):u=t[0];let d;t[1]!==r||t[2]!==c?(d=I5(r,c),t[1]=r,t[2]=c,t[3]=d):d=t[3];let f;t[4]===d?f=t[5]:(f=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:d}),t[4]=d,t[5]=f);let p=n.status===`active`&&`border-accent/40 text-accent`,m=n.status===`paused`&&`border-edge text-fg-muted`,h=n.status===`done`&&`border-edge text-fg-muted`,g;t[6]!==p||t[7]!==m||t[8]!==h?(g=X(`rounded-full border px-1.5 py-0.5`,p,m,h),t[6]=p,t[7]=m,t[8]=h,t[9]=g):g=t[9];let _;t[10]!==i||t[11]!==g?(_=(0,Z.jsx)(`span`,{className:g,children:i}),t[10]=i,t[11]=g,t[12]=_):_=t[12];let v;t[13]!==n.maxTurns||t[14]!==n.turnsUsed||t[15]!==c.turns?(v=c.turns.replace(`{{used}}`,String(n.turnsUsed)).replace(`{{max}}`,String(n.maxTurns)),t[13]=n.maxTurns,t[14]=n.turnsUsed,t[15]=c.turns,t[16]=v):v=t[16];let y;t[17]===v?y=t[18]:(y=(0,Z.jsx)(`span`,{children:v}),t[17]=v,t[18]=y);let b;t[19]===o?b=t[20]:(b=o?(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-panel px-1.5 py-0.5 text-fg`,children:o}):null,t[19]=o,t[20]=b);let x;t[21]===s?x=t[22]:(x=(0,Z.jsx)(`span`,{className:`text-fg`,children:s}),t[21]=s,t[22]=x);let S;t[23]!==c.elapsedLabel||t[24]!==x?(S=(0,Z.jsxs)(`span`,{className:`text-fg-muted`,children:[c.elapsedLabel,`: `,x]}),t[23]=c.elapsedLabel,t[24]=x,t[25]=S):S=t[25];let C;t[26]!==y||t[27]!==b||t[28]!==S||t[29]!==f||t[30]!==_?(C=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[u,f,_,y,b,S]}),t[26]=y,t[27]=b,t[28]=S,t[29]=f,t[30]=_,t[31]=C):C=t[31];let w;t[32]===n.goal?w=t[33]:(w=(0,Z.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-snug text-fg`,title:n.goal,children:n.goal}),t[32]=n.goal,t[33]=w);let T;t[34]!==C||t[35]!==w?(T=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[C,w]}),t[34]=C,t[35]=w,t[36]=T):T=t[36];let E;t[37]===a?E=t[38]:(E=(0,Z.jsx)(`span`,{className:`hidden rounded-full bg-surface-muted px-2 py-1 text-[10px] text-fg-muted sm:inline-flex`,children:a}),t[37]=a,t[38]=E);let D;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(Il,{className:`size-4`,"aria-hidden":!0}),t[39]=D):D=t[39];let O;t[40]!==l||t[41]!==c.collapseAria?(O=(0,Z.jsx)(wA,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 rounded-full p-0 text-fg-muted hover:text-fg`,"aria-label":c.collapseAria,onClick:l,children:D}),t[40]=l,t[41]=c.collapseAria,t[42]=O):O=t[42];let k;t[43]!==E||t[44]!==O?(k=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[E,O]}),t[43]=E,t[44]=O,t[45]=k):k=t[45];let A;return t[46]!==T||t[47]!==k?(A=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-2`,children:[T,k]}),t[46]=T,t[47]=k,t[48]=A):A=t[48],A}function sye(e){let t=(0,Y.c)(20),{goal:n,t:r}=e,i;t[0]===n?i=t[1]:(i=Gve(n),t[0]=n,t[1]=i);let a=i,o;t[2]===n?o=t[3]:(o=Kve(n),t[2]=n,t[3]=o);let s=o,c=r.heading,l=n.status===`done`?`bg-accent`:`bg-accent/75`,u;t[4]===l?u=t[5]:(u=X(`h-full rounded-full transition-[width] duration-300`,l),t[4]=l,t[5]=u);let d=`${a.percent}%`,f;t[6]===d?f=t[7]:(f={width:d},t[6]=d,t[7]=f);let p;t[8]!==u||t[9]!==f?(p=(0,Z.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-elevated`,children:(0,Z.jsx)(`div`,{className:u,style:f})}),t[8]=u,t[9]=f,t[10]=p):p=t[10];let m;t[11]!==s.done||t[12]!==s.percent||t[13]!==s.total||t[14]!==r.checklistProgress?(m=s.total>0?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-fg-muted`,children:[(0,Z.jsx)(`span`,{className:`shrink-0`,children:r.checklistProgress.replace(`{{done}}`,String(s.done)).replace(`{{total}}`,String(s.total))}),(0,Z.jsx)(`div`,{className:`h-1 min-w-10 flex-1 overflow-hidden rounded-full bg-surface-muted`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-fg-muted/55 transition-[width] duration-300`,style:{width:`${s.percent}%`}})})]}):null,t[11]=s.done,t[12]=s.percent,t[13]=s.total,t[14]=r.checklistProgress,t[15]=m):m=t[15];let h;return t[16]!==r.heading||t[17]!==p||t[18]!==m?(h=(0,Z.jsxs)(`div`,{className:`space-y-1.5`,"aria-label":c,children:[p,m]}),t[16]=r.heading,t[17]=p,t[18]=m,t[19]=h):h=t[19],h}var cye=new Intl.DateTimeFormat(`zh-CN`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}),lye=new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`});function uye(e,t){let n=typeof e==`string`?new Date(e):e;return(t===`zh`?cye:lye).format(n)}function dye(e){let t=(0,Y.c)(25),{sessionKey:n,goal:r,language:i,t:a}=e,[o,s]=(0,J.useState)(!1),c;t[0]===n?c=t[1]:(c=async()=>(await P5(n,{limit:40})).runs,t[0]=n,t[1]=c);let l;t[2]!==r.lastTurnAt||t[3]!==r.lastVerdict||t[4]!==r.turnsUsed||t[5]!==o||t[6]!==n?(l=[o,n,r.turnsUsed,r.lastTurnAt,r.lastVerdict],t[2]=r.lastTurnAt,t[3]=r.lastVerdict,t[4]=r.turnsUsed,t[5]=o,t[6]=n,t[7]=l):l=t[7];let u;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=[],t[8]=u):u=t[8];let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=[],t[9]=d):d=t[9];let f;t[10]===o?f=t[11]:(f={enabled:o,initial:u,errorData:d},t[10]=o,t[11]=f);let{data:p,loading:m,error:h}=UF(c,l,f),g=h==null?null:h instanceof Error?h.message:a.runHistoryLoadFailed,_;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>s(fye),t[12]=_):_=t[12];let v;t[13]===a.runHistory?v=t[14]:(v=(0,Z.jsx)(`button`,{type:`button`,className:`text-xs text-fg-muted underline-offset-2 hover:underline`,onClick:_,children:a.runHistory}),t[13]=a.runHistory,t[14]=v);let y;t[15]!==i||t[16]!==p||t[17]!==g||t[18]!==m||t[19]!==o||t[20]!==a?(y=o?(0,Z.jsxs)(`div`,{className:`mt-1 max-h-52 space-y-2 overflow-y-auto rounded-md border border-edge bg-surface-panel p-2 text-xs text-fg-muted`,children:[m?(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:a.runHistoryLoading}):null,g?(0,Z.jsx)(`p`,{className:`text-destructive`,children:g}):null,!m&&!g&&p.length===0?(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:a.runHistoryEmpty}):null,!m&&p.length>0?(0,Z.jsx)(`ul`,{className:`space-y-2`,children:p.map(e=>(0,Z.jsxs)(`li`,{className:`rounded-md border border-edge/80 bg-surface-muted/40 px-2 py-1.5 dark:bg-surface-muted/25`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-2 gap-y-0.5 text-[10px] text-fg-muted`,children:[(0,Z.jsx)(`time`,{suppressHydrationWarning:!0,dateTime:new Date(e.at).toISOString(),children:uye(e.at,i)}),(0,Z.jsx)(`span`,{children:a.runHistoryTurns.replace(`{{used}}`,String(e.turnsUsed)).replace(`{{max}}`,String(e.maxTurns))})]}),(0,Z.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-fg`,children:[(0,Z.jsx)(`span`,{children:R5(e.verdict,a)}),(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:`·`}),(0,Z.jsx)(`span`,{children:z5(e.statusAfter,a)}),(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:`·`}),(0,Z.jsx)(`span`,{children:e.willContinue?a.runHistoryContinue:a.runHistoryStop}),e.checklistProgress?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:`·`}),(0,Z.jsx)(`span`,{children:a.checklistProgress.replace(`{{done}}`,String(e.checklistProgress.done)).replace(`{{total}}`,String(e.checklistProgress.total))})]}):null]}),e.reason?(0,Z.jsxs)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-fg-muted`,children:[(0,Z.jsxs)(`span`,{className:`font-medium text-fg`,children:[a.lastReason,`:`]}),` `,e.reason]}):null,e.assistantPreview?(0,Z.jsx)(`p`,{className:`mt-1 line-clamp-3 break-words text-[10px] leading-snug text-fg-muted`,children:e.assistantPreview}):null]},e.id))}):null]}):null,t[15]=i,t[16]=p,t[17]=g,t[18]=m,t[19]=o,t[20]=a,t[21]=y):y=t[21];let b;return t[22]!==v||t[23]!==y?(b=(0,Z.jsxs)(`div`,{children:[v,y]}),t[22]=v,t[23]=y,t[24]=b):b=t[24],b}function fye(e){return!e}function pye(e,t){switch(t.type){case`start`:return{busy:!0,error:null};case`error`:return{busy:!1,error:t.error};case`done`:return{busy:!1,error:null}}}function mye(e){try{return sessionStorage.getItem(B5(e))===`1`}catch{return!1}}function hye(e){let t=(0,Y.c)(3),{onTick:n}=e,r,i;return t[0]===n?(r=t[1],i=t[2]):(r=()=>{let e=window.setInterval(n,1e3);return()=>clearInterval(e)},i=[n],t[0]=n,t[1]=r,t[2]=i),(0,J.useEffect)(r,i),null}function gye({sessionKey:e,streaming:t,sending:n}){let r=d(e=>e.language),i=m(r).chat.goal,[a,o]=(0,J.useState)(()=>mye(e)),[s,c]=(0,J.useReducer)(pye,{busy:!1,error:null}),[l,u]=(0,J.useState)(()=>Date.now()),f=(0,J.useRef)(t||n),p=(0,J.useRef)(!1),h=t||n;f.current&&!h&&(p.current=!0),f.current=h;let g=(0,J.useCallback)(t=>{o(t);try{t?sessionStorage.setItem(B5(e),`1`):sessionStorage.removeItem(B5(e))}catch{}},[e]),{data:_,loading:v,error:y,setData:b}=UF(async()=>(await N5(e,{uiLocale:r})).persistentGoal,[e,r],{initial:null,errorData:null}),x=(0,J.useCallback)(async()=>{try{b((await N5(e,{uiLocale:r})).persistentGoal)}catch(e){c({type:`error`,error:e instanceof Error?e.message:i.loadFailed})}},[e,r,b,i.loadFailed]),S=(0,J.useEffectEvent)(()=>{x()});(0,J.useEffect)(()=>{let t=t=>{t.detail?.key===e&&S()};return window.addEventListener(`session-updated`,t),()=>window.removeEventListener(`session-updated`,t)},[e]),(0,J.useLayoutEffect)(()=>{p.current&&(p.current=!1,S())});let C=(0,J.useCallback)(()=>{u(Date.now())},[]),w=async t=>{c({type:`start`});try{await Vve(e,t,{uiLocale:r}),await x(),c({type:`done`})}catch(e){c({type:`error`,error:e instanceof Error?e.message:i.loadFailed})}},T=async t=>{c({type:`start`});try{await Hve(e,t,{uiLocale:r}),await x(),c({type:`done`})}catch(e){c({type:`error`,error:e instanceof Error?e.message:i.loadFailed})}},E=!v||y!=null||_!=null,D=s.error??(y==null?null:y instanceof Error?y.message:i.loadFailed);if(!E||!Wve(_))return null;let O=_,k=t||n,A=`${O.turnsUsed}/${O.maxTurns}`,j=Jve(O,i),{total:M,done:N}=F5(O),P=M>0?i.checklistProgress.replace(`{{done}}`,String(N)).replace(`{{total}}`,String(M)):``,F=Bve(zve(O,l),r),I=qve(O,k),L=i.pillTitle.replace(`{{status}}`,j).replace(`{{turns}}`,A),R=!a&&O.status!==`done`&&O.status!==`cleared`;if(a)return(0,Z.jsx)(Qve,{goal:O,agentBusy:k,pillTitle:L,phase:I,statusShort:j,turnsShort:A,clLine:P,t:i,onExpand:()=>g(!1)});let z=O.status===`active`||O.status===`paused`;return(0,Z.jsxs)(`div`,{className:`shrink-0 w-full px-3 pt-1.5 sm:px-5 sm:pt-2 xl:px-6`,children:[R?(0,Z.jsx)(hye,{onTick:C}):null,(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[var(--max-width-chat)] flex-col gap-2.5 rounded-2xl bg-surface-panel px-3 py-2.5 shadow-elevated sm:px-4 sm:py-3`,children:[(0,Z.jsx)(oye,{goal:O,phase:I,statusShort:j,turnsShort:A,clLine:P,elapsedStr:F,t:i,onCollapse:()=>g(!0)}),(0,Z.jsx)(sye,{goal:O,t:i}),(0,Z.jsx)(Zve,{goal:O,canEdit:z,mutationBusy:s.busy,t:i,onMutate:T}),(0,Z.jsx)(Uve,{goal:O,canEditChecklist:z,mutationBusy:s.busy,t:i,onAction:w,onChecklist:T}),(0,Z.jsx)(tye,{goal:O,t:i}),(0,Z.jsx)(aye,{sessionKey:e,goal:O,language:r,t:i}),(0,Z.jsx)(dye,{sessionKey:e,goal:O,language:r,t:i}),D?(0,Z.jsx)(`p`,{className:`text-xs text-destructive`,children:D}):null]})]})}function _ye(e){let t=(0,Y.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Z.jsx)(gye,{...e},e.sessionKey),t[0]=e,t[1]=n),n}function vye(e,t){let n=A1(e,t),r=j1(e,t);return`${e.id} ${n} ${r}`.toLowerCase()}function yye(e,t,n){let r=t.trim().toLowerCase();if(!r)return e;let i=r.split(/\s+/).filter(Boolean);return e.filter(e=>{let t=vye(e,n);return i.every(e=>t.includes(e))})}function bye(e){let t=(0,Y.c)(56),{items:n,value:r,disabled:i,placeholder:a,searchPlaceholder:o,noMatches:s,compact:c,contentSide:l,contentAlign:u,className:f,onChange:p}=e,h=l===void 0?`bottom`:l,g=u===void 0?`end`:u,_=d(Sye),v;t[0]===_?v=t[1]:(v=m(_),t[0]=_,t[1]=v);let y=v.agentsSettings,[b,x]=(0,J.useState)(!1),[S,C]=(0,J.useState)(``),w;t[2]!==y||t[3]!==n||t[4]!==S?(w=yye(n,S,y),t[2]=y,t[3]=n,t[4]=S,t[5]=w):w=t[5];let T=w,E,D,O;if(t[6]!==y||t[7]!==n||t[8]!==a||t[9]!==r){let e;t[13]===r?e=t[14]:(e=e=>e.id===r,t[13]=r,t[14]=e),D=n.find(e),E=D?A1(D,y):r||a,O=D?[A1(D,y),j1(D,y)].filter(Boolean).join(` — `):void 0,t[6]=y,t[7]=n,t[8]=a,t[9]=r,t[10]=E,t[11]=D,t[12]=O}else E=t[10],D=t[11],O=t[12];let k=O??a,A=c&&`min-w-0 max-w-[min(calc(15ch+3rem),calc(100vw-8rem))] py-1.5 text-[13px]`,j;t[15]!==f||t[16]!==A?(j=X(jA,`items-center gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-2 text-left text-sm font-normal text-fg`,AX.transition,`hover:border-edge hover:bg-surface-hover/45`,OA,DA,`disabled:cursor-not-allowed disabled:opacity-50`,`dark:border-edge-subtle dark:hover:bg-surface-hover/55`,A,f),t[15]=f,t[16]=A,t[17]=j):j=t[17];let M;t[18]!==D?.avatar||t[19]!==r?(M=r?(0,Z.jsx)(rH,{agentId:r,avatar:D?.avatar,size:28,className:`shrink-0`}):null,t[18]=D?.avatar,t[19]=r,t[20]=M):M=t[20];let N=c?`max-w-[15ch] shrink`:`flex-1`,P;t[21]===N?P=t[22]:(P=X(`min-w-0 truncate text-left`,N),t[21]=N,t[22]=P);let F;t[23]!==E||t[24]!==P?(F=(0,Z.jsx)(`span`,{className:P,children:E}),t[23]=E,t[24]=P,t[25]=F):F=t[25];let I;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(Ll,{className:`size-4 shrink-0 text-fg-subtle opacity-70`,"aria-hidden":!0}),t[26]=I):I=t[26];let L;t[27]!==i||t[28]!==F||t[29]!==k||t[30]!==j||t[31]!==M?(L=(0,Z.jsx)(vF,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,disabled:i,title:k,className:j,children:[M,F,I]})}),t[27]=i,t[28]=F,t[29]=k,t[30]=j,t[31]=M,t[32]=L):L=t[32];let R;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(R=X(`z-50 w-[var(--radix-popover-trigger-width)] min-w-[12rem] max-h-[min(20rem,calc(100vh-6rem))] overflow-hidden rounded-lg border border-edge bg-surface-panel shadow-md`,AX),t[33]=R):R=t[33];let z;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>C(e.target.value),t[34]=z):z=t[34];let B;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(B=X(`w-full rounded-md border border-edge bg-surface-elevated px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-muted`,OA),t[35]=B):B=t[35];let V;t[36]!==S||t[37]!==o?(V=(0,Z.jsx)(`div`,{className:`border-b border-edge p-2`,children:(0,Z.jsx)(`input`,{type:`search`,value:S,onChange:z,placeholder:o,className:B,"aria-label":o})}),t[36]=S,t[37]=o,t[38]=V):V=t[38];let H;t[39]!==y||t[40]!==T||t[41]!==s||t[42]!==p||t[43]!==r?(H=T.length===0?(0,Z.jsx)(`li`,{className:`p-2 text-sm text-fg-muted`,children:s}):T.map(e=>{let t=e.id===r,n=A1(e,y),i=j1(e,y),a=i.length>0?i:void 0;return(0,Z.jsx)(`li`,{role:`option`,"aria-selected":t,children:(0,Z.jsxs)(`button`,{type:`button`,className:X(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-fg`,t?`bg-surface-hover`:`hover:bg-surface-hover`),onClick:()=>{p(e.id),x(!1),C(``)},children:[(0,Z.jsx)(Ml,{className:X(`size-4 shrink-0`,t?`opacity-100`:`opacity-0`),"aria-hidden":!0}),(0,Z.jsx)(rH,{agentId:e.id,avatar:e.avatar,size:32,className:`shrink-0`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`block truncate font-medium leading-tight`,title:n,children:n}),i?(0,Z.jsx)(`span`,{className:`mt-0.5 block truncate text-xs leading-tight text-fg-muted`,title:a,children:i}):null]})]})},e.id)}),t[39]=y,t[40]=T,t[41]=s,t[42]=p,t[43]=r,t[44]=H):H=t[44];let U;t[45]===H?U=t[46]:(U=(0,Z.jsx)(`ul`,{className:`max-h-[min(16rem,calc(100vh-10rem))] overflow-y-auto p-1`,role:`listbox`,children:H}),t[45]=H,t[46]=U);let W;t[47]!==g||t[48]!==h||t[49]!==V||t[50]!==U?(W=(0,Z.jsx)(yF,{children:(0,Z.jsxs)(bF,{side:h,align:g,sideOffset:4,collisionPadding:8,className:R,onOpenAutoFocus:xye,children:[V,U]})}),t[47]=g,t[48]=h,t[49]=V,t[50]=U,t[51]=W):W=t[51];let G;return t[52]!==b||t[53]!==L||t[54]!==W?(G=(0,Z.jsxs)(gF,{open:b,onOpenChange:x,children:[L,W]}),t[52]=b,t[53]=L,t[54]=W,t[55]=G):G=t[55],G}function xye(e){return e.preventDefault()}function Sye(e){return e.language}var Cye=`(max-width: 767px)`,wye=(0,J.memo)(function(e){let t=(0,Y.c)(24),{chatHeadline:n,chatAgents:r,showChatAgentSelector:i,chatAgentId:a,onChatAgentChange:o,chatAgentDisabled:s}=e,c=d(Tye),l;t[0]===c?l=t[1]:(l=m(c),t[0]=c,t[1]=l);let u=l,f=Cj(Eye),p=cQ(Dye),h=cQ(Oye),g=zj(kye),_=Gj(Aye),v=Gj(jye),y=t8(Cye),b;t[2]!==y||t[3]!==g||t[4]!==f?(b=y?!g:f&&!jj(),t[2]=y,t[3]=g,t[4]=f,t[5]=b):b=t[5];let x=b,S,C;return t[6]!==s||t[7]!==a||t[8]!==r||t[9]!==n||t[10]!==v||t[11]!==u.chat.agentNoMatches||t[12]!==u.chat.agentPlaceholder||t[13]!==u.chat.agentSearchPlaceholder||t[14]!==u.sidebar.newTask||t[15]!==u.workspace.openFiles||t[16]!==o||t[17]!==_||t[18]!==i||t[19]!==x||t[20]!==h||t[21]!==p?(S=()=>(_({startExtra:x?(0,Z.jsx)(ja,{to:`/chat/new`,className:X(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-panel text-sm font-medium leading-none text-fg transition-colors hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,dj),title:u.sidebar.newTask,children:(0,Z.jsx)(xv,{className:`size-4 shrink-0 text-accent-fg`,strokeWidth:2,"aria-hidden":!0})}):null,main:(0,Z.jsx)(`div`,{className:`w-full min-w-0 max-w-(--max-width-chat) px-3 sm:px-5 xl:px-6`,children:(0,Z.jsx)(`h1`,{className:X(`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,x?`text-left md:text-center`:`text-left`),title:n,children:n})}),end:(0,Z.jsxs)(`div`,{className:X(`flex min-w-0 max-w-[min(32rem,calc(100vw-8rem))] shrink-0 items-center justify-end gap-2`,dj),children:[i?(0,Z.jsx)(`div`,{className:`min-w-0 w-fit shrink-0`,children:(0,Z.jsx)(bye,{items:r,value:a,disabled:s,placeholder:u.chat.agentPlaceholder,searchPlaceholder:u.chat.agentSearchPlaceholder,noMatches:u.chat.agentNoMatches,compact:!0,contentSide:`bottom`,contentAlign:`end`,onChange:o})}):null,(0,Z.jsx)(`button`,{type:`button`,className:X(`rounded-md p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,p&&`bg-surface-hover text-fg`),title:u.workspace.openFiles,"aria-label":u.workspace.openFiles,"aria-pressed":p,onClick:h,children:(0,Z.jsx)(Sp,{className:`size-4`})})]})}),()=>v()),C=[n,r,i,a,o,s,x,u.chat.agentPlaceholder,u.chat.agentSearchPlaceholder,u.chat.agentNoMatches,u.sidebar.newTask,u.workspace.openFiles,p,h,_,v],t[6]=s,t[7]=a,t[8]=r,t[9]=n,t[10]=v,t[11]=u.chat.agentNoMatches,t[12]=u.chat.agentPlaceholder,t[13]=u.chat.agentSearchPlaceholder,t[14]=u.sidebar.newTask,t[15]=u.workspace.openFiles,t[16]=o,t[17]=_,t[18]=i,t[19]=x,t[20]=h,t[21]=p,t[22]=S,t[23]=C):(S=t[22],C=t[23]),(0,J.useLayoutEffect)(S,C),null});function Tye(e){return e.language}function Eye(e){return e.collapsed}function Dye(e){return e.open}function Oye(e){return e.toggleOpen}function kye(e){return e.mobileNavOpen}function Aye(e){return e.setPageHeader}function jye(e){return e.clearPageHeader}var Mye=(0,J.memo)(function(){let e=(0,Y.c)(13),t=d(Nye),n;e[0]===t?n=e[1]:(n=m(t),e[0]=t,e[1]=n);let r=n,i=R1(Pye),a=R1(Fye);if(i===`idle`)return null;if(i===`error`&&a){let t;e[2]===a?t=e[3]:(t=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:a}),e[2]=a,e[3]=t);let n;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(n=X(`shrink-0 rounded-xl border border-red-200 bg-white px-2.5 py-1 text-xs font-medium text-red-700`,`hover:bg-red-50 dark:border-red-800 dark:bg-red-950/40 dark:text-red-300 dark:hover:bg-red-950/70`,AX.transition,AX.press,AX.focusRingPanel),e[4]=n):n=e[4];let i;e[5]===r.connection.reconnect?i=e[6]:(i=(0,Z.jsx)(`button`,{type:`button`,className:n,onClick:Iye,children:r.connection.reconnect}),e[5]=r.connection.reconnect,e[6]=i);let o;return e[7]!==t||e[8]!==i?(o=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-red-100 bg-red-50 px-4 py-2 text-sm text-red-600 dark:border-red-900/40 dark:bg-red-950/50 dark:text-red-400`,children:[t,i]}),e[7]=t,e[8]=i,e[9]=o):o=e[9],o}if(i===`connecting`||i===`reconnecting`){let t;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`span`,{className:`inline-block size-3 animate-spin rounded-full border-2 border-amber-500 border-t-transparent`,"aria-hidden":!0}),e[10]=t):t=e[10];let n=i===`reconnecting`?r.connection.reconnecting:r.connection.connecting,a;return e[11]===n?a=e[12]:(a=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-amber-100 bg-amber-50 px-4 py-2 text-sm text-amber-800 dark:border-amber-900/40 dark:bg-amber-950/50 dark:text-amber-200`,children:[t,(0,Z.jsx)(`span`,{children:n})]}),e[11]=n,e[12]=a),a}return null});function Nye(e){return e.language}function Pye(e){return e.connectionState}function Fye(e){return e.error}function Iye(){return cue()}function Lye(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function V5(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function H5(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var U5=(e,t)=>Math.abs(e-t)<1.01,Rye=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},W5,G5=()=>{if(W5!==void 0)return W5;if(typeof navigator>`u`)return W5=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return W5=!0;let e=navigator.maxTouchPoints;return W5=navigator.platform===`MacIntel`&&e!==void 0&&e>0},K5=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},zye=e=>e,Bye=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},Vye=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(K5(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(K5(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},q5={passive:!0},Hye=typeof window>`u`?!0:`onscrollend`in window,Uye=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&Hye,o=0,s=a?null:Rye(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,q5),a&&r.addEventListener(`scrollend`,u,q5),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},Wye=(e,t)=>Uye(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),J5=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},Gye=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},Kye=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:zye,rangeExtractor:Bye,onChange:()=>{},measureElement:J5,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,a=t.count,o=this.getMeasurements(),s=e>0?o[0]?.key??n.getItemKey(0):null,c=e>0?o[e-1]?.key??n.getItemKey(e-1):null;if(a!==e||e>0&&a>0&&(t.getItemKey(0)!==s||t.getItemKey(a-1)!==c)){let s=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??o[0]:null;s&&(r=[s.key,this.getScrollOffset()-s.start]);let l=t.followOnAppend===!0?`auto`:t.followOnAppend||null;l&&a>e&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(a-1)!==c)&&(i=l)}}this.options=t,(r||i)&&(this.pendingScrollAnchor=[r?.[0]??null,r?.[1]??0,i])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=V5(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!G5()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,q5),e.addEventListener(`touchend`,n,q5),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r]=t;if(e!==null){let{count:t,getItemKey:r}=this.options,i=0;for(;i<t&&r(i)!==e;)i++;let a=i<t?this.getMeasurements()[i]:void 0;if(a){let e=a.start+n-this.getScrollOffset();U5(e,0)||this.applyScrollAdjustment(e)}}r&&this.scrollToEnd({behavior:r})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=V5(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=V5(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{let c=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let l=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=this.options.gap,a=e*2,o=this._flatMeasurements;if(!o||o.length<a){let e=new Float64Array(a);o&&l>0&&e.set(o.subarray(0,l*2)),o=e,this._flatMeasurements=o}let s;if(l===0)s=t+n;else{let e=l-1;s=o[e*2]+o[e*2+1]+i}for(let t=l;t<e;t++){let e=r(t),n=c.get(e),a=typeof n==`number`?n:this.options.estimateSize(t);o[t*2]=s,o[t*2+1]=a,s+=a+i}let u=Lye(e,o,r);return this.measurementsCache=u,u}let u=this.measurementsCache.slice(0,l),d=Array(a).fill(void 0);for(let e=0;e<l;e++){let t=u[e];t&&(d[t.lane]=e)}for(let i=l;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,l,f=o===`estimate`||c.has(e);if(a!==void 0&&this.options.lanes>1){s=a;let e=d[s],r=e===void 0?void 0:u[e];l=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?u[i-1]:this.getFurthestMeasurement(u,i);l=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,s)}let p=c.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=l+m;u[i]={index:i,start:l,size:m,end:h,key:e,lane:s},d[s]=i}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=V5(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?qye({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:r===1&&this._flatMeasurements!=null?this._flatMeasurements:null}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=V5(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(e<0||e>=this.options.count)return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=t-(this.itemSizeCache.get(i)??n);if(o!==0){let a=this.options.anchorTo===`end`&&this.scrollState?.behavior!==`smooth`&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,s=a?this.getTotalSize():0,c=this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?r<this.getScrollOffset()+this.scrollAdjustments&&this.scrollDirection!==`backward`:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},o,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++,a?this.applyScrollAdjustment(this.getTotalSize()-s):c&&this.applyScrollAdjustment(o),this.notify(!1)}},this.getVirtualItems=V5(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return H5(t[Y5(0,t.length-1,r?e=>n[e*2]:e=>H5(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:`end`,behavior:e});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){e!==0&&(G5()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=e:this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&U5(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},Y5=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function qye({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:i}){let a=e.length-1,o=i?e=>i[e*2]:t=>e[t].start,s=i?e=>i[e*2]+i[e*2+1]:t=>e[t].end;if(e.length<=r)return{startIndex:0,endIndex:a};let c=Y5(0,a,o,n),l=c;if(r===1)for(;l<a&&s(l)<n+t;)l++;else if(r>1){let i=Array(r).fill(0);for(;l<a&&i.some(e=>e<n+t);){let t=e[l];i[t.lane]=t.end,l++}let o=Array(r).fill(n+t);for(;c>=0&&o.some(e=>e>=n);){let t=e[c];o[t.lane]=t.start,c--}c=Math.max(0,c-c%r),l=Math.min(a,l+(r-1-l%r))}return{startIndex:c,endIndex:l}}var X5=typeof document<`u`?J.useLayoutEffect:J.useEffect;function Jye({useFlushSync:e=!0,...t}){let n=J.useReducer(e=>e+1,0)[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,Xa.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=J.useState(()=>new Kye(r));return i.setOptions(r),X5(()=>i._didMount(),[]),X5(()=>i._willUpdate()),i}function Yye(e){return Jye({observeElementRect:Vye,observeElementOffset:Wye,scrollToFn:Gye,...e})}var Xye={folder:Sp,content:P_,documents:Fd,globe:km};function Zye(e){let t=(0,Y.c)(2),{name:n}=e,r=Xye[n]??Sp,i;return t[0]===r?i=t[1]:(i=(0,Z.jsx)(r,{className:`size-[1.125rem] text-accent-fg sm:size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=r,t[1]=i),i}var Qye=(0,J.memo)(function(e){let t=(0,Y.c)(28),{chat:n,onPickPrompt:r}=e,i=n.welcomeSpotlight,a=(0,J.useId)(),[o,s]=(0,J.useState)(null),c;t[0]!==i?.categories||t[1]!==o?(c=i?.categories.find(e=>e.id===o),t[0]=i?.categories,t[1]=o,t[2]=c):c=t[2];let l=c;if(!i)return null;let u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(uA,{className:`size-12 shrink-0 sm:size-14`,"aria-hidden":!0}),t[3]=u):u=t[3];let d;t[4]===i.headline?d=t[5]:(d=(0,Z.jsx)(`h1`,{className:`text-balance text-lg font-semibold tracking-tight text-fg sm:text-xl`,children:i.headline}),t[4]=i.headline,t[5]=d);let f;t[6]===i.tagline?f=t[7]:(f=(0,Z.jsx)(`p`,{className:`max-w-md text-pretty text-sm leading-snug text-fg-muted sm:text-[0.9375rem]`,children:i.tagline}),t[6]=i.tagline,t[7]=f);let p;t[8]!==d||t[9]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 px-1 pt-8 text-center sm:gap-2 sm:pt-10`,children:[u,d,f]}),t[8]=d,t[9]=f,t[10]=p):p=t[10];let m;if(t[11]!==a||t[12]!==i.categories||t[13]!==o){let e;t[15]!==a||t[16]!==o?(e=e=>{let t=o===e.id;return(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":t,"aria-controls":t?a:void 0,onClick:()=>s(t=>t===e.id?null:e.id),className:X(`flex flex-row items-start gap-2.5 rounded-xl border bg-surface-panel p-2.5 text-left shadow-surface sm:flex-col sm:gap-2`,AX.transition,AX.press,AX.focusRingPanel,t?`border-accent ring-1 ring-accent/25`:`border-edge hover:border-edge-strong hover:bg-surface-hover/40 dark:hover:bg-surface-hover/30`),children:[(0,Z.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-accent-soft sm:size-10`,children:(0,Z.jsx)(Zye,{name:e.icon})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium leading-snug text-fg sm:text-[0.9375rem]`,children:e.title}),(0,Z.jsx)(`div`,{className:`mt-0.5 text-xs leading-snug text-fg-muted sm:text-sm`,children:e.description})]})]},e.id)},t[15]=a,t[16]=o,t[17]=e):e=t[17],m=i.categories.map(e),t[11]=a,t[12]=i.categories,t[13]=o,t[14]=m}else m=t[14];let h;t[18]===m?h=t[19]:(h=(0,Z.jsx)(`div`,{className:`mt-10 grid w-full grid-cols-1 gap-2 sm:mt-12 sm:grid-cols-2 sm:gap-2.5 lg:grid-cols-4`,children:m}),t[18]=m,t[19]=h);let g;t[20]!==r||t[21]!==a||t[22]!==l?(g=l&&l.scenarios.length>0?(0,Z.jsx)(`div`,{id:a,role:`region`,"aria-label":l.title,className:`flex flex-col gap-1.5 rounded-xl border border-edge bg-surface-base/80 p-2.5 dark:bg-surface-hover/20`,children:(0,Z.jsx)(`ul`,{className:`flex flex-col gap-1`,children:l.scenarios.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>r(e.prompt),className:X(`flex w-full gap-2 rounded-lg border border-transparent px-2 py-1.5 text-left text-sm leading-snug text-fg`,AX.transition,AX.press,AX.focusRingPanel,`hover:border-edge hover:bg-surface-panel dark:hover:bg-surface-panel/40`),children:[(0,Z.jsx)(kg,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 text-pretty`,children:e.prompt})]})},e.prompt))})}):null,t[20]=r,t[21]=a,t[22]=l,t[23]=g):g=t[23];let _;return t[24]!==p||t[25]!==h||t[26]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3.5 pb-2 sm:gap-4 sm:pb-3`,children:[p,h,g]}),t[24]=p,t[25]=h,t[26]=g,t[27]=_):_=t[27],_});function $ye(e){let t=[];for(let n of e.content??[])(n.type===`thinking`||n.type===`tool_use`)&&t.push(n);return t.length>0?t:[]}function ebe(e,t){switch(e){case`pdf`:return t.attachmentPreviewPdf;case`docx`:return t.attachmentPreviewDocument;case`pptx`:return t.attachmentPreviewPresentation;case`excel`:return t.attachmentPreviewSpreadsheet;default:return``}}function Z5(e){let t=(0,Y.c)(69),{open:n,attachment:r,authToken:i,sessionKey:a,onClose:o}=e,s=d(tbe),c=m(s).chat,l;t[0]!==r||t[1]!==i||t[2]!==s||t[3]!==n||t[4]!==a?(l={open:n,attachment:r,authToken:i,sessionKey:a,language:s},t[0]=r,t[1]=i,t[2]=s,t[3]=n,t[4]=a,t[5]=l):l=t[5];let u=OU(l),{rootRef:f,active:p,enter:h,exit:g}=oU(),{preview:_,fileType:v,hasExtractedText:y,showExtractedText:b}=u,x=v!==`image`&&v!==`text`&&v!==`pptx`&&y,S=!!(_&&!u.loading&&!u.loadError),C;t[6]!==g||t[7]!==o?(C=()=>{g(),o()},t[6]=g,t[7]=o,t[8]=C):C=t[8];let w=C,T;t[9]===_?T=t[10]:(T=()=>{if(!_)return;let e=DL(_);if(!e)return;let t=atob(e),n=Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);let r=new Uint8Array(n),i=new Blob([r],{type:_.mimeType||`application/octet-stream`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=_.name??`download`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a)},t[9]=_,t[10]=T);let E=T,D;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(D=X(`min-h-0 min-w-0 flex-1 cursor-pointer border-0 p-0`,`bg-surface-base transition-colors`,`hover:bg-surface-hover/90 dark:bg-black/60 dark:hover:bg-black/70`,AX.focusRingBase),t[11]=D):D=t[11];let O=D,k;t[12]===w?k=t[13]:(k=e=>!e&&w(),t[12]=w,t[13]=k);let A;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(A=X(`xopc-dialog-content-fullscreen fixed inset-0 z-[81] flex h-[100dvh] w-full flex-row overflow-hidden`,`border-0 bg-transparent p-0 shadow-none outline-none`),t[14]=A):A=t[14];let j,M;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(j=X(`flex h-full min-h-0 w-[min(100%,var(--max-width-app-main))] shrink-0 flex-col overflow-hidden`,`bg-surface-panel sm:border-x sm:border-edge dark:sm:border-edge`,`shadow-float dark:shadow-elevated`),M=X(`shrink-0 border-b border-edge bg-surface-panel dark:border-edge`,dj),t[15]=j,t[16]=M):(j=t[15],M=t[16]);let N=_?.name??``,P;t[17]===N?P=t[18]:(P=(0,Z.jsx)(ue,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-fg`,children:N}),t[17]=N,t[18]=P);let F=x?(0,Z.jsxs)(`div`,{className:`mr-2 flex rounded-lg border border-edge p-0.5 dark:border-edge`,role:`group`,"aria-label":c.attachmentPreviewText,children:[(0,Z.jsx)(`button`,{type:`button`,className:`rounded-md px-2.5 py-1 text-xs font-medium ${b?`text-fg-muted hover:text-fg`:`bg-surface-hover text-fg`}`,onClick:()=>{u.setShowExtractedText(!1),u.clearLoadError()},children:ebe(v,c)}),(0,Z.jsx)(`button`,{type:`button`,className:`rounded-md px-2.5 py-1 text-xs font-medium ${b?`bg-surface-hover text-fg`:`text-fg-muted hover:text-fg`}`,onClick:()=>{u.setShowExtractedText(!0),u.clearLoadError()},children:c.attachmentPreviewText})]}):null,I;t[19]!==p||t[20]!==S||t[21]!==h||t[22]!==g||t[23]!==c.attachmentPreviewExitFullscreen||t[24]!==c.attachmentPreviewFullscreen?(I=S?(0,Z.jsx)(`button`,{type:`button`,className:`rounded-md p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,title:p?c.attachmentPreviewExitFullscreen:c.attachmentPreviewFullscreen,"aria-label":p?c.attachmentPreviewExitFullscreen:c.attachmentPreviewFullscreen,onClick:()=>void(p?g():h()),children:p?(0,Z.jsx)(Ng,{className:`size-4`}):(0,Z.jsx)(Dg,{className:`size-4`})}):null,t[19]=p,t[20]=S,t[21]=h,t[22]=g,t[23]=c.attachmentPreviewExitFullscreen,t[24]=c.attachmentPreviewFullscreen,t[25]=I):I=t[25];let L;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Z.jsx)(Uu,{className:`size-4`}),t[26]=L):L=t[26];let R;t[27]!==E||t[28]!==c.attachmentPreviewDownload?(R=(0,Z.jsx)(`button`,{type:`button`,className:`rounded-md p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,title:c.attachmentPreviewDownload,"aria-label":c.attachmentPreviewDownload,onClick:E,children:L}),t[27]=E,t[28]=c.attachmentPreviewDownload,t[29]=R):R=t[29];let z;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Z.jsx)(oO,{className:`size-4`}),t[30]=z):z=t[30];let B;t[31]===c.attachmentPreviewClose?B=t[32]:(B=(0,Z.jsx)(de,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`rounded-md p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,title:c.attachmentPreviewClose,"aria-label":c.attachmentPreviewClose,children:z})}),t[31]=c.attachmentPreviewClose,t[32]=B);let V;t[33]!==F||t[34]!==I||t[35]!==R||t[36]!==B?(V=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[F,I,R,B]}),t[33]=F,t[34]=I,t[35]=R,t[36]=B,t[37]=V):V=t[37];let H;t[38]!==P||t[39]!==V?(H=(0,Z.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-2 px-4 py-3 sm:px-8`,children:[P,V]}),t[38]=P,t[39]=V,t[40]=H):H=t[40];let U;t[41]!==H||t[42]!==M?(U=(0,Z.jsx)(`div`,{className:M,children:H}),t[41]=H,t[42]=M,t[43]=U):U=t[43];let W;t[44]!==E||t[45]!==s||t[46]!==_||t[47]!==u.binaryBuffer||t[48]!==u.extractedText||t[49]!==u.extractedTextTruncated||t[50]!==u.fileKey||t[51]!==u.fileName||t[52]!==u.loadError||t[53]!==u.loading||t[54]!==u.previewKind||t[55]!==u.showExtractedText||t[56]!==u.textContent?(W=_?(0,Z.jsx)(RX,{context:`attachment`,language:s,fileKey:u.fileKey,fileName:u.fileName,loading:u.loading,loadError:u.loadError,previewKind:u.previewKind,textContent:u.textContent,binaryBuffer:u.binaryBuffer,showExtractedText:u.showExtractedText,extractedText:u.extractedText,extractedTextTruncated:u.extractedTextTruncated,actions:{onDownload:E,canDownload:!!DL(_)}}):null,t[44]=E,t[45]=s,t[46]=_,t[47]=u.binaryBuffer,t[48]=u.extractedText,t[49]=u.extractedTextTruncated,t[50]=u.fileKey,t[51]=u.fileName,t[52]=u.loadError,t[53]=u.loading,t[54]=u.previewKind,t[55]=u.showExtractedText,t[56]=u.textContent,t[57]=W):W=t[57];let ee;t[58]===W?ee=t[59]:(ee=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-4 pb-4 pt-2 sm:px-8`,children:W}),t[58]=W,t[59]=ee);let K;t[60]!==f||t[61]!==U||t[62]!==ee||t[63]!==j?(K=(0,Z.jsxs)(`div`,{ref:f,className:j,children:[U,ee]}),t[60]=f,t[61]=U,t[62]=ee,t[63]=j,t[64]=K):K=t[64];let te;return t[65]!==w||t[66]!==c.attachmentPreviewClose||t[67]!==O?(te=(0,Z.jsx)(`button`,{type:`button`,className:O,onClick:w,"aria-label":c.attachmentPreviewClose}),t[65]=w,t[66]=c.attachmentPreviewClose,t[67]=O,t[68]=te):te=t[68],(0,Z.jsx)(q,{open:n,onOpenChange:k,children:(0,Z.jsx)(G,{children:(0,Z.jsxs)(se,{className:A,children:[(0,Z.jsx)(`button`,{type:`button`,className:O,onClick:w,"aria-label":c.attachmentPreviewClose}),K,te]})})})}function tbe(e){return e.language}function Q5(e){let t=(0,Y.c)(45),{attachment:n,authToken:r,sessionKey:i,showDelete:a,onDelete:o,onOpen:s}=e,c=a===void 0?!1:a,l=d(nbe),u;t[0]===l?u=t[1]:(u=m(l),t[0]=l,t[1]=u);let f=u,p=(0,J.useId)(),[h,g]=(0,J.useState)(null),_=h?.src===n?h.data:n,v;t[2]===n?v=t[3]:(v=!!n.workspaceRelativePath&&!DL(n),t[2]=n,t[3]=v);let y=v,b;t[4]!==r||t[5]!==y?(b=y&&!String(r??``).trim(),t[4]=r,t[5]=y,t[6]=b):b=t[6];let x=b,S,C;t[7]!==n||t[8]!==r||t[9]!==i?(S=()=>{let e=n;if(!e?.workspaceRelativePath||DL(e)||!String(r??``).trim())return;let t=!1;return(async()=>{let n=await nU({workspaceRelativePath:e.workspaceRelativePath,sessionKey:i});if(!n.ok||t)return;let r=n.base64,a=e.mimeType?.startsWith(`image/`)||e.type===`image`;g({src:e,data:{...e,content:r,data:r,preview:a?r:e.preview,type:a?`image`:`document`}})})(),()=>{t=!0}},C=[n,r,i],t[7]=n,t[8]=r,t[9]=i,t[10]=S,t[11]=C):(S=t[10],C=t[11]),(0,J.useEffect)(S,C);let w;t[12]===_?w=t[13]:(w=_.preview??DL(_),t[12]=_,t[13]=w);let T=w,E;t[14]!==_.mimeType||t[15]!==_.type?(E=_.mimeType?.startsWith(`image/`)||_.type===`image`,t[14]=_.mimeType,t[15]=_.type,t[16]=E):E=t[16];let D=E,O=_.mimeType===`application/pdf`,k;t[17]!==_.mimeType||t[18]!==_.name?(k=_.mimeType?.includes(`spreadsheetml`)||_.name?.toLowerCase().endsWith(`.xlsx`)||_.name?.toLowerCase().endsWith(`.xls`),t[17]=_.mimeType,t[18]=_.name,t[19]=k):k=t[19];let A=k,j=_.name??`file`,M;t[20]===_.mimeType?M=t[21]:(M=_.mimeType?.startsWith(`image/`)?_.mimeType:`image/png`,t[20]=_.mimeType,t[21]=M);let N=M,P;t[22]!==N||t[23]!==D||t[24]!==T?(P=T&&D?jL(N,T):``,t[22]=N,t[23]=D,t[24]=T,t[25]=P):P=t[25];let F=P,I=!!F,L=x?`${j} — ${f.chat.attachmentPreviewMissingAuth}`:j,R=f.chat.attachmentPreviewMissingAuth,z;t[26]!==j||t[27]!==_||t[28]!==A||t[29]!==O||t[30]!==L||t[31]!==p||t[32]!==R||t[33]!==s||t[34]!==I||t[35]!==x||t[36]!==F?(z=I?(0,Z.jsxs)(`div`,{className:`max-w-[10rem]`,children:[(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(`button`,{type:`button`,className:X(`block w-full overflow-hidden rounded-md border border-edge dark:border-edge`,AX.transition,AX.press,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),onClick:()=>s(_),title:L,"aria-label":L,"aria-describedby":x?p:void 0,children:(0,Z.jsx)(`img`,{src:F,alt:j,className:`max-h-16 w-full object-cover`})}),O?(0,Z.jsx)(`div`,{className:`pointer-events-none absolute bottom-1 right-1 rounded bg-black/60 px-1.5 py-0.5 text-[10px] font-semibold text-white`,"aria-hidden":!0,children:`PDF`}):null]}),x?(0,Z.jsx)(`p`,{id:p,className:`mt-1 line-clamp-2 text-[10px] leading-snug text-amber-600 dark:text-amber-500`,children:R}):null]}):(0,Z.jsx)(`div`,{className:`max-w-[14rem]`,children:(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>s(_),title:L,"aria-label":L,"aria-describedby":x?p:void 0,className:X(`flex w-full min-w-0 gap-2 rounded-md border border-edge bg-surface-hover px-2 py-1.5 text-left text-xs text-fg-muted hover:bg-surface-active dark:border-edge`,x?`items-start`:`items-center`,AX.transition,AX.press,AX.focusRingPanel),children:[A?(0,Z.jsx)(_f,{className:`size-8 shrink-0 text-fg-subtle`,"aria-hidden":!0}):(0,Z.jsx)(xf,{className:`size-8 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`block truncate text-fg`,children:j}),x?(0,Z.jsx)(`span`,{id:p,className:`mt-0.5 line-clamp-2 block text-[10px] font-normal leading-snug text-amber-600 dark:text-amber-500`,children:R}):null]})]})}),t[26]=j,t[27]=_,t[28]=A,t[29]=O,t[30]=L,t[31]=p,t[32]=R,t[33]=s,t[34]=I,t[35]=x,t[36]=F,t[37]=z):z=t[37];let B;t[38]!==f.chat.attachmentPreviewRemove||t[39]!==o||t[40]!==c?(B=c?(0,Z.jsx)(`button`,{type:`button`,className:X(`absolute -right-1 -top-1 flex size-5 items-center justify-center rounded-full border border-edge bg-surface-panel text-fg-muted shadow-surface hover:text-fg dark:border-edge`,AX.transition,AX.press,AX.focusRingPanel),onClick:e=>{e.stopPropagation(),o?.()},title:f.chat.attachmentPreviewRemove,"aria-label":f.chat.attachmentPreviewRemove,children:(0,Z.jsx)(oO,{className:`size-3`})}):null,t[38]=f.chat.attachmentPreviewRemove,t[39]=o,t[40]=c,t[41]=B):B=t[41];let V;return t[42]!==z||t[43]!==B?(V=(0,Z.jsxs)(`div`,{className:`group relative inline-block`,children:[z,B]}),t[42]=z,t[43]=B,t[44]=V):V=t[44],V}function nbe(e){return e.language}function rbe(e){return typeof e==`number`&&Number.isFinite(e)&&e>0&&e!==1/0}function $5(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e%60);return`${Math.floor(e/60)}:${t.toString().padStart(2,`0`)}`}function ibe(e){return e.type===`voice`||e.type===`audio`||e.mimeType?.startsWith(`audio/`)===!0}function abe({att:e,align:t=`start`,variant:n=`default`,sessionKey:r}){let i=m(d(e=>e.language)),a=(0,J.useRef)(null),[o,s]=(0,J.useState)(),[c,l]=(0,J.useState)(!1),u=(0,J.useMemo)(()=>{let t=e.durationSeconds;return typeof t==`number`&&Number.isFinite(t)&&t>0?t:0},[e.durationSeconds]),[f,p]=(0,J.useState)(u),h=(0,J.useRef)(u);h.current!==u&&(h.current=u,p(u));let[g,v]=(0,J.useState)(0),y=(0,J.useCallback)(()=>{let e=a.current;if(!e)return;let t=e.duration;rbe(t)&&p(t)},[]),b=`${e.workspaceRelativePath??``}:${e.content?.length??0}:${e.mimeType??``}:${r??``}`,x=(0,J.useRef)(b);x.current!==b&&(x.current=b,v(0),l(!1)),(0,J.useEffect)(()=>{let t,n=!1;return(async()=>{let i=e.content??e.data;if(i){s(`data:${e.mimeType?.includes(`/`)?e.mimeType:`audio/mpeg`};base64,${i.replace(/\s/g,``)}`);return}if(e.workspaceRelativePath)try{let i=await Ee(_(EL(e.workspaceRelativePath,{sessionKey:r})));if(!i.ok||n)return;let a=await i.blob(),o=URL.createObjectURL(a);t=o,s(o)}catch{}})(),()=>{n=!0,t&&URL.revokeObjectURL(t)}},[e,r]);let S=(0,J.useCallback)(()=>{let e=a.current;!e||!o||(c?e.pause():e.play().catch(()=>{}))},[c,o]);if(!ibe(e))return null;let C=f>0?Math.min(100,Number.isFinite(f)?g/f*100:0):0,w=typeof f==`number`&&f>0&&Number.isFinite(f),T=!!(o&&!w),E=o?(0,Z.jsxs)(`span`,{className:`tabular-nums tracking-tight text-fg-muted`,"aria-live":`polite`,children:[(0,Z.jsx)(`span`,{children:$5(g)}),(0,Z.jsx)(`span`,{className:`mx-0.5 text-fg-subtle`,children:`/`}),w?(0,Z.jsx)(`span`,{children:$5(f)}):(0,Z.jsx)(`span`,{className:`text-fg-subtle`,title:i.chat.voiceAwaitingMeta,children:`—`})]}):(0,Z.jsx)(`span`,{className:`tabular-nums tracking-tight text-fg-subtle`,children:`— / —`}),D=o?(0,Z.jsx)(`audio`,{ref:a,src:o,preload:`metadata`,className:`hidden`,onLoadedMetadata:y,onLoadedData:y,onDurationChange:y,onTimeUpdate:e=>v(e.currentTarget.currentTime),onPlay:()=>l(!0),onPause:()=>l(!1),onEnded:()=>{l(!1),v(0)}}):(0,Z.jsx)(`span`,{className:`sr-only`,children:i.chat.voiceLoading}),O=(0,Z.jsx)(`button`,{type:`button`,onClick:S,disabled:!o,className:X(`flex size-8 shrink-0 items-center justify-center rounded-full border text-accent-fg`,`border-edge-subtle bg-surface-panel transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`motion-safe:active:scale-[0.97]`,`dark:bg-surface-panel/90 dark:border-edge`,n===`compact`&&X(`border-white/55 bg-white/92 shadow-[inset_0_1px_0_rgb(255_255_255/0.65)]`,`dark:border-white/14 dark:bg-surface-hover/98 dark:shadow-none`),!o&&`opacity-50`),"aria-label":c?i.chat.voicePause:i.chat.voicePlay,title:c?i.chat.voicePause:i.chat.voicePlay,children:c?(0,Z.jsx)(j_,{className:`size-[14px]`,strokeWidth:2}):(0,Z.jsx)(vv,{className:`size-[14px] ml-px`,strokeWidth:2})}),k=X(`relative h-0.5 min-h-[2px] w-full overflow-hidden rounded-full bg-edge-subtle dark:bg-edge/65`,n===`compact`&&`bg-white/45 dark:bg-white/14`),A=X(`inline-flex min-w-0 items-center rounded-full border`,n===`compact`?`max-w-[min(220px,88vw)] gap-2 px-2 py-1.5 backdrop-blur-[2px]`:`min-w-[min(160px,80vw)] max-w-[17rem] gap-2 px-2 py-1.5`,n===`compact`?`border-white/58 bg-white/86 shadow-none dark:border-white/13 dark:bg-black/[0.22] dark:backdrop-blur-sm`:`border-edge-subtle bg-surface-panel/[0.96] shadow-surface dark:border-edge dark:bg-surface-panel/92`),j=`${i.chat.voiceAriaRegion}${e.name?` · ${e.name}`:``}`;return(0,Z.jsx)(`div`,{className:X(`flex min-w-0`,t===`end`&&`justify-end`,t===`center`&&`justify-center`),children:(0,Z.jsxs)(`div`,{role:`group`,"aria-label":j,className:A,children:[O,(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col justify-center gap-1 py-px`,children:[n===`default`?(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[11px] leading-snug tracking-tight text-fg-muted`,children:[(0,Z.jsx)(Mg,{className:`size-3 shrink-0 opacity-90 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate font-normal`,children:i.chat.voiceMessage})]}):(0,Z.jsx)(`span`,{className:`sr-only`,children:i.chat.voiceMessage}),(0,Z.jsx)(`div`,{className:k,"aria-hidden":!0,children:o?T?(0,Z.jsx)(`span`,{className:X(`absolute inset-y-0 left-[18%] w-[42%] max-w-[4.5rem] rounded-full bg-accent/45 motion-safe:animate-pulse`)}):(0,Z.jsx)(`div`,{className:X(`h-full rounded-full bg-accent motion-safe:transition-[width] motion-safe:duration-150 motion-safe:ease-linear`),style:{width:`${C}%`}}):null}),(0,Z.jsx)(`div`,{className:X(`flex justify-end text-[10px] leading-snug tracking-tight text-fg-muted`),children:E})]}),D]})})}function e7(e){return e.type===`voice`||e.type===`audio`||e.mimeType?.startsWith(`audio/`)===!0}function t7(e){let t=(0,Y.c)(23),{attachments:n,authToken:r,sessionKey:i,layout:a,centerUserVoiceRow:o}=e,s=a===void 0?`assistant`:a,c=o===void 0?!1:o,[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(null);if(!n?.length)return null;let p,m,h,g;if(t[0]!==n||t[1]!==r||t[2]!==c||t[3]!==s||t[4]!==i){let e=n.filter(sbe),a=n.filter(e7),o=n.filter(obe);p=`flex flex-col gap-2`,m=e.length>0?(0,Z.jsx)(`div`,{className:X(`grid w-full max-w-40 gap-1`,e.length===1&&`grid-cols-1`,e.length===2&&`grid-cols-2`,e.length>=3&&`grid-cols-2 sm:grid-cols-3`),children:e.map((e,t)=>(0,Z.jsx)(Q5,{attachment:e,authToken:r,sessionKey:i,onOpen:e=>{f(e),u(!0)}},e.id??`${e.name}-${t}`))}):null,h=a.length>0?(0,Z.jsx)(`div`,{className:X(`flex flex-col gap-2`,s===`user`&&(c?`items-center`:`items-end`)),children:a.map((e,t)=>(0,Z.jsx)(abe,{att:e,sessionKey:i,align:s===`user`?c?`center`:`end`:`start`,variant:s===`user`?`compact`:`default`},e.id??`${e.name}-${t}`))}):null,g=o.length>0?(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:o.map((e,t)=>(0,Z.jsx)(Q5,{attachment:e,authToken:r,sessionKey:i,onOpen:e=>{f(e),u(!0)}},e.id??`${e.name}-${t}`))}):null,t[0]=n,t[1]=r,t[2]=c,t[3]=s,t[4]=i,t[5]=p,t[6]=m,t[7]=h,t[8]=g}else p=t[5],m=t[6],h=t[7],g=t[8];let _;t[9]!==p||t[10]!==m||t[11]!==h||t[12]!==g?(_=(0,Z.jsxs)(`div`,{className:p,children:[m,h,g]}),t[9]=p,t[10]=m,t[11]=h,t[12]=g,t[13]=_):_=t[13];let v;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(v=()=>{u(!1),f(null)},t[14]=v):v=t[14];let y;t[15]!==d||t[16]!==r||t[17]!==l||t[18]!==i?(y=(0,Z.jsx)(Z5,{open:l,attachment:d,authToken:r,sessionKey:i,onClose:v}),t[15]=d,t[16]=r,t[17]=l,t[18]=i,t[19]=y):y=t[19];let b;return t[20]!==_||t[21]!==y?(b=(0,Z.jsxs)(Z.Fragment,{children:[_,y]}),t[20]=_,t[21]=y,t[22]=b):b=t[22],b}function obe(e){return e.type!==`image`&&!e.mimeType?.startsWith(`image/`)&&!e7(e)}function sbe(e){return e.type===`image`||e.mimeType?.startsWith(`image/`)}function cbe(e){let t=[];for(let n of e)if(!(!n.name.toLowerCase().includes(`search`)||n.result==null))try{let e=typeof n.result==`string`?JSON.parse(n.result):n.result,r=Array.isArray(e)?e:e?.results??[];for(let e of r)e.url&&t.push({url:e.url,title:e.title??e.url,snippet:e.snippet})}catch{}return t}function lbe(e){let t=(0,Y.c)(16),{blocks:n}=e,r=d(fbe),i,a,o,s,c;if(t[0]!==n||t[1]!==r){c=Symbol.for(`react.early_return_sentinel`);bb0:{let e=m(r),l=cbe(n.filter(dbe));if(l.length===0){c=null;break bb0}o=`mt-6`;let u=e.chat.searchSourcesHeading.replace(`{{count}}`,String(l.length));t[7]===u?s=t[8]:(s=(0,Z.jsx)(`p`,{className:`mb-3 text-xs font-medium text-fg-muted`,children:u}),t[7]=u,t[8]=s),i=`space-y-3`,a=l.map(ube)}t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6];if(c!==Symbol.for(`react.early_return_sentinel`))return c;let l;t[9]!==i||t[10]!==a?(l=(0,Z.jsx)(`ol`,{className:i,children:a}),t[9]=i,t[10]=a,t[11]=l):l=t[11];let u;return t[12]!==o||t[13]!==s||t[14]!==l?(u=(0,Z.jsxs)(`div`,{className:o,children:[s,l]}),t[12]=o,t[13]=s,t[14]=l,t[15]=u):u=t[15],u}function ube(e,t){let n=(()=>{try{return new URL(e.url).hostname}catch{return``}})(),r=n?`https://www.google.com/s2/favicons?domain=${n}&sz=16`:void 0;return(0,Z.jsxs)(`li`,{className:`flex min-w-0 gap-2.5`,children:[(0,Z.jsxs)(`span`,{className:`mt-0.5 shrink-0 text-xs text-fg-disabled`,children:[t+1,`.`]}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-1.5`,children:[r?(0,Z.jsx)(`img`,{src:r,alt:``,className:`mt-0.5 size-3.5 shrink-0 rounded-sm`,"aria-hidden":!0}):null,(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`min-w-0 flex-1 break-words text-xs font-medium text-accent-fg [overflow-wrap:anywhere] hover:underline`,children:e.title})]}),e.snippet?(0,Z.jsx)(`p`,{className:`mt-0.5 line-clamp-4 text-xs break-words text-fg-muted [overflow-wrap:anywhere]`,children:e.snippet}):null]})]},e.url)}function dbe(e){return e.type===`tool_use`}function fbe(e){return e.language}var pbe=String.raw`png|jpe?g|gif|webp|bmp|svg|pdf|docx?|xlsx?|pptx?|txt|md|json|html?|css|mjs?|cjs|js|ts|mp3|wav|ogg|m4a|mp4|mov|webm`;function n7(){return`(?:${pbe})`}var mbe=RegExp(`(/[^\\s"'"<>|*?\\n]+?\\.(?:${n7()}))`,`gi`),hbe=RegExp(`([A-Za-z]:[\\\\/][^"'\`<>*?\\n|=]+?\\.(?:${n7()}))`,`gi`),gbe={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,bmp:`image/bmp`,svg:`image/svg+xml`,pdf:`application/pdf`,doc:`application/msword`,docx:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,xls:`application/vnd.ms-excel`,xlsx:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,ppt:`application/vnd.ms-powerpoint`,pptx:`application/vnd.openxmlformats-officedocument.presentationml.presentation`,txt:`text/plain`,md:`text/markdown`,json:`application/json`,html:`text/html`,htm:`text/html`,css:`text/css`,mjs:`text/javascript`,cjs:`text/javascript`,js:`text/javascript`,ts:`text/typescript`,mp3:`audio/mpeg`,wav:`audio/wav`,ogg:`audio/ogg`,m4a:`audio/mp4`,mp4:`video/mp4`,mov:`video/quicktime`,webm:`video/webm`};function r7(e){let t=e.lastIndexOf(`.`);return t<0?`application/octet-stream`:gbe[e.slice(t+1).toLowerCase()]??`application/octet-stream`}function i7(e){return e.startsWith(`image/`)}function a7(e){let t=e.trim();if(t.length<4||t.startsWith(`//`)&&!t.startsWith(`//Users`)||t.startsWith(`http:`)||t.startsWith(`https:`)||t.startsWith(`data:`)||t.startsWith(`file://`))return!1;if(t.startsWith(`/`))return/^\/(?:Users|usr|var|opt|tmp|home|root|System|private|dev|media|mnt|Volumes|data)(?:\/|[\s]|$)/i.test(t);if(/^[A-Za-z]:[\\/]/.test(t)){let e=t.replace(/\\/g,`/`);return!/^[A-Za-z]:\/{2,}/.test(e)}return!!t.startsWith(`\\\\`)}function o7(e){let t=e.replace(/\\/g,`/`).split(`/`).filter(Boolean);return t[t.length-1]||e}function s7(e){let t=e.trim();return t.includes(`
4682
+ `)||t.includes(`\r`)?t:t.replace(/^(?:File written|File edited)\s*:\s*/i,``).replace(/^Saved\s*:\s*/i,``).trim()}function c7(e){let t=e.trim();if(t.includes(`
4683
+ `)||t.includes(`\r`))return t;let n=t.match(/^[fd?] (.+)$/);return n?n[1].trim():t}function l7(e,t,n,r,i){let a=e.trim();if(!a||!a7(a)||!/\.(png|jpe?g|gif|webp|bmp|svg|pdf|docx?|xlsx?|pptx?|txt|md|json|html?|css|mjs?|cjs|js|ts|mp3|wav|ogg|m4a|mp4|mov|webm)$/i.test(a))return;let o=o7(a);t.push({absolutePath:a,fileName:o,mimeType:r7(o),startIndex:r,endIndex:i})}var _be=new Set([`SOUL.md`,`IDENTITY.md`,`USER.md`,`TOOLS.md`,`AGENTS.md`,`HEARTBEAT.md`,`MEMORY.md`,`BOOTSTRAP.md`].map(e=>e.toLowerCase()));function vbe(e){let t=o7(e.replace(/\\/g,`/`));return!t||t===`.`||t===`..`?!1:_be.has(t.toLowerCase())}function ybe(e){let t=e.trim();return t.includes(`
4684
+ `)||t.includes(`\r`)?!1:/^[fd?] .+$/i.test(t)}function u7(e){let t=e.trim().replace(/\\/g,`/`);return t.length<4||t.includes(`..`)||t.startsWith(`/`)||/^[A-Za-z]:/i.test(t)||t.startsWith(`\\\\`)||/^[a-z][a-z0-9+.-]*:/i.test(t)||vbe(t)?!1:/\.(png|jpe?g|gif|webp|bmp|svg|pdf|docx?|xlsx?|pptx?|txt|md|json|html?|css|mjs?|cjs|js|ts|mp3|wav|ogg|m4a|mp4|mov|webm)$/i.test(t)}function d7(e,t,n){let r=c7(s7(e)).trim().replace(/\\/g,`/`);if(!u7(r))return;let i=o7(r);t.push({absolutePath:`rel:${r}`,fileName:i,mimeType:r7(i),workspaceRelativePath:r,startIndex:0,endIndex:0})}function f7(e,t,n){if(typeof e==`string`){if(ybe(e)){let r=c7(s7(e)).trim().replace(/\\/g,`/`);if(a7(r)&&/\.[a-z0-9]+$/i.test(r)){let i=n.indexOf(e);i>=0?l7(r,t,n,i,i+e.length):l7(r,t,n,0,0)}return}let r=c7(s7(e)).trim().replace(/\\/g,`/`);if(a7(r)&&/\.[a-z0-9]+$/i.test(r)){let i=n.indexOf(e);i>=0?l7(r,t,n,i,i+e.length):l7(r,t,n,0,0);return}let i=t.length;if(p7(r,t),t.length>i)return;u7(r)&&d7(e,t,n);return}if(Array.isArray(e)){for(let r of e)f7(r,t,n);return}if(e&&typeof e==`object`){let r=e,i=r.workspaceRelativePaths,a=Array.isArray(i)&&i.length>0&&i.every(e=>typeof e==`string`);if(a)for(let e of i)d7(e,t,n);for(let[e,i]of Object.entries(r))a&&e===`paths`||f7(i,t,n)}}function p7(e,t){for(let n of[mbe,hbe]){n.lastIndex=0;let r;for(;(r=n.exec(e))!==null;){let n=r[1];if(n){let i=r.indices?.[1]?.[0]??r.index??0;l7(n,t,e,i,i+n.length)}}}}function bbe(){return`(?:[A-Za-z0-9_.-]+\\/)*[A-Za-z0-9_.-]+\\.(?:${n7()})`}function xbe(e){let t=`(${bbe()})`,n=[RegExp(`\\*\\*${t}\\*\\*`,`gi`),RegExp("`"+t+"`",`gi`),RegExp(`\\]\\(${t}\\)`,`gi`)],r=[];for(let t of n){t.lastIndex=0;let n;for(;(n=t.exec(e))!==null;){let t=n[1]?.trim().replace(/^<|>$/g,``);if(t)try{d7(decodeURIComponent(t),r,e)}catch{d7(t,r,e)}}}let i=new Set;return r.reduce((e,t)=>{let n=t.workspaceRelativePath??t.absolutePath;return i.has(n)?e:(i.add(n),e.push({...t,origin:`assistant-markdown`}),e)},[])}function m7(e,t){let n=e.trim().replace(/\\/g,`/`),r=t.trim().replace(/\\/g,`/`).replace(/^\/+/,``);return!r||n.length<r.length?!1:n===r||n.endsWith(`/${r}`)}function Sbe(e){let t=e.map(e=>e.workspaceRelativePath).filter(e=>!!e);return t.length===0?e:e.filter(e=>e.workspaceRelativePath||!a7(e.absolutePath)?!0:!t.some(t=>m7(e.absolutePath,t)))}function h7(e){let t=[];if(!e?.trim())return[];try{f7(JSON.parse(e),t,e)}catch{}t.some(e=>e.workspaceRelativePath)||p7(e,t);let n=Sbe(t),r=new Set;return n.reduce((e,t)=>{let n=t.absolutePath;return r.has(n)?e:(r.add(n),e.push({...t,origin:`tool-result`}),e)},[])}function Cbe({workspaceRel:e,sessionKey:t,onOpen:n,className:r}){let[i,a]=(0,J.useState)(null);return(0,J.useEffect)(()=>{let n=null,r=!1;return(async()=>{try{let i=await ZH(e,{sessionKey:t?.trim()||void 0});if(r)return;let o=URL.createObjectURL(i);n=o,a(o)}catch{r||a(null)}})(),()=>{r=!0,n&&URL.revokeObjectURL(n)}},[e,t]),i?(0,Z.jsxs)(`button`,{type:`button`,onClick:n,className:X(`group relative size-20 overflow-hidden rounded-lg border border-edge-subtle text-left`,AX.press,AX.focusRingPanel,`hover:border-accent`,r),title:e,"aria-label":e,children:[(0,Z.jsx)(`img`,{src:i,className:`size-full object-cover`,alt:``}),(0,Z.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/0 transition-colors group-hover:bg-black/25`,children:(0,Z.jsx)(Cd,{className:`size-4 text-white opacity-0 transition-opacity group-hover:opacity-100`,strokeWidth:1.75})})]}):null}function g7(e){let t=(0,Y.c)(10),{icon:n,label:r,copiedLabel:i,onClick:a,copied:o}=e,s=i??r,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=X(`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,AX.focusRingPanel,AX.press),t[0]=c):c=t[0];let l;t[1]!==o||t[2]!==n?(l=o?(0,Z.jsx)(Ml,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0}):n,t[1]=o,t[2]=n,t[3]=l):l=t[3];let u=o?s:r,d;t[4]===u?d=t[5]:(d=(0,Z.jsx)(`span`,{children:u}),t[4]=u,t[5]=d);let f;return t[6]!==a||t[7]!==l||t[8]!==d?(f=(0,Z.jsxs)(`button`,{type:`button`,onClick:a,className:c,children:[l,d]}),t[6]=a,t[7]=l,t[8]=d,t[9]=f):f=t[9],f}function wbe(e){return e===`external`||e===`agent-profile`||e===`session-artifact`}function Tbe(e,t){return e?t.locationKind[e]??t.externalBadge:t.externalBadge}function Ebe(e){let t=(0,Y.c)(71),{path:n,refInfo:r,sessionKey:i,onImported:a}=e,o=Qr(),s=m(d(Dbe)).chat,c=s.fileReference,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=Oj()&&!!window.electronAPI?.shell,t[0]=l):l=t[0];let u=l,f=r.absolutePath??n.absolutePath,[p,h]=(0,J.useState)(!1),g;t[1]!==u||t[2]!==r.fileRefId||t[3]!==i?(g=async e=>{if(!r.fileRefId||!u)return;let t=await XH(r.fileRefId,e,{sessionKey:i?.trim()||void 0});t&&(e===`openExternal`?await window.electronAPI?.shell?.openPath(t.absolutePath):await window.electronAPI?.shell?.showItemInFolder(t.absolutePath))},t[1]=u,t[2]=r.fileRefId,t[3]=i,t[4]=g):g=t[4];let _=g,v;t[5]===f?v=t[6]:(v=()=>{lH(f).then(e=>{e&&(h(!0),window.setTimeout(()=>h(!1),2e3))})},t[5]=f,t[6]=v);let y=v,[b,x]=(0,J.useState)(!1),S;t[7]!==r.capabilities||t[8]!==r.fileRefId?(S=r.capabilities.includes(`importToWorkspace`)&&!!r.fileRefId,t[7]=r.capabilities,t[8]=r.fileRefId,t[9]=S):S=t[9];let C=S,w=`imports/${n.fileName||r.displayName}`,T=r.scope===`missing`,E=r.scope===`invalid`,D=wbe(r.scope)&&r.exists,O=T?c.missingDescription:E?c.invalidDescription:D?u?c.offWorkspaceBaseDescription:c.browserOffWorkspaceDescription:u?c.externalDescription:c.browserExternalDescription,k=D||r.scope===`external`||r.scope===`agent-profile`?Tbe(r.locationKind,c):null,A=T||E?`border-warning/30 bg-warning/5 text-fg-muted`:`border-edge-subtle bg-surface-panel text-fg`,j;t[10]===A?j=t[11]:(j=X(`flex max-w-xl min-w-0 flex-col gap-1 rounded-lg border px-2.5 py-2 text-xs`,A),t[10]=A,t[11]=j);let M;t[12]!==E||t[13]!==T?(M=T||E?(0,Z.jsx)(Rl,{className:`size-3.5 shrink-0 text-warning`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(Af,{className:`size-3.5 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=E,t[13]=T,t[14]=M):M=t[14];let N=n.fileName||r.displayName,P;t[15]===N?P=t[16]:(P=(0,Z.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:N}),t[15]=N,t[16]=P);let F;t[17]===k?F=t[18]:(F=k?(0,Z.jsx)(`span`,{className:`shrink-0 rounded bg-surface-muted px-1.5 py-0.5 text-[10px] text-fg-muted`,children:k}):null,t[17]=k,t[18]=F);let I;t[19]!==F||t[20]!==M||t[21]!==P?(I=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[M,P,F]}),t[19]=F,t[20]=M,t[21]=P,t[22]=I):I=t[22];let L;t[23]===O?L=t[24]:(L=(0,Z.jsx)(`p`,{className:`line-clamp-2 text-[11px] leading-snug text-fg-muted`,children:O}),t[23]=O,t[24]=L);let R;t[25]!==c||t[26]!==o||t[27]!==r.manageRoute?(R=r.manageRoute?(0,Z.jsx)(g7,{icon:(0,Z.jsx)(qb,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0}),label:c.openInSettings,onClick:()=>o(r.manageRoute)}):null,t[25]=c,t[26]=o,t[27]=r.manageRoute,t[28]=R):R=t[28];let z;t[29]!==u||t[30]!==c||t[31]!==_||t[32]!==r.capabilities?(z=u&&r.capabilities.includes(`openExternal`)?(0,Z.jsx)(g7,{icon:(0,Z.jsx)(yd,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0}),label:c.openExternal,onClick:()=>void _(`openExternal`)}):null,t[29]=u,t[30]=c,t[31]=_,t[32]=r.capabilities,t[33]=z):z=t[33];let B;t[34]!==u||t[35]!==c||t[36]!==_||t[37]!==r.capabilities?(B=u&&r.capabilities.includes(`revealInFolder`)?(0,Z.jsx)(g7,{icon:(0,Z.jsx)(Sp,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0}),label:c.revealInFolder,onClick:()=>void _(`revealInFolder`)}):null,t[34]=u,t[35]=c,t[36]=_,t[37]=r.capabilities,t[38]=B):B=t[38];let V;t[39]!==s||t[40]!==y||t[41]!==c||t[42]!==p||t[43]!==r.capabilities?(V=r.capabilities.includes(`copyPath`)?(0,Z.jsx)(g7,{icon:(0,Z.jsx)(tu,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0}),label:c.copyPath,copiedLabel:s.messageCopied,copied:p,onClick:y}):null,t[39]=s,t[40]=y,t[41]=c,t[42]=p,t[43]=r.capabilities,t[44]=V):V=t[44];let H;t[45]!==C||t[46]!==c||t[47]!==x?(H=C?(0,Z.jsx)(g7,{icon:(0,Z.jsx)(ms,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0}),label:c.importToWorkspace,onClick:()=>x(!0)}):null,t[45]=C,t[46]=c,t[47]=x,t[48]=H):H=t[48];let U;t[49]!==R||t[50]!==z||t[51]!==B||t[52]!==V||t[53]!==H?(U=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1 pt-0.5`,children:[R,z,B,V,H]}),t[49]=R,t[50]=z,t[51]=B,t[52]=V,t[53]=H,t[54]=U):U=t[54];let W;t[55]!==C||t[56]!==w||t[57]!==f||t[58]!==b||t[59]!==a||t[60]!==r.fileRefId||t[61]!==i||t[62]!==x?(W=C&&b?(0,Z.jsx)(Obe,{open:!0,onOpenChange:x,fileRefId:r.fileRefId,sessionKey:i,sourceLabel:f,defaultDestination:w,onImported:e=>{x(!1),a(e)}},`${r.fileRefId}:${w}`):null,t[55]=C,t[56]=w,t[57]=f,t[58]=b,t[59]=a,t[60]=r.fileRefId,t[61]=i,t[62]=x,t[63]=W):W=t[63];let G;return t[64]!==f||t[65]!==I||t[66]!==L||t[67]!==U||t[68]!==W||t[69]!==j?(G=(0,Z.jsxs)(`div`,{className:j,title:f,children:[I,L,U,W]}),t[64]=f,t[65]=I,t[66]=L,t[67]=U,t[68]=W,t[69]=j,t[70]=G):G=t[70],G}function Dbe(e){return e.language}function Obe(e){let t=(0,Y.c)(68),{open:n,onOpenChange:r,fileRefId:i,sessionKey:a,sourceLabel:o,defaultDestination:s,onImported:c}=e,l=d(Abe),u;t[0]===l?u=t[1]:(u=m(l),t[0]=l,t[1]=u);let f=u.chat.fileReference,p=f.importErrors,[h,g]=(0,J.useState)(s),[_,v]=(0,J.useState)(!1),[y,b]=(0,J.useState)(null),x;t[2]!==h||t[3]!==p||t[4]!==i||t[5]!==c||t[6]!==a?(x=async()=>{v(!0),b(null);let e=await QH(i,{sessionKey:a?.trim()||void 0,destination:h.trim()||void 0,onConflict:`rename`});if(e.ok){c(e.payload);return}v(!1);let t=p;b(t[e.error.code]??t.UNKNOWN??e.error.message)},t[2]=h,t[3]=p,t[4]=i,t[5]=c,t[6]=a,t[7]=x):x=t[7];let S=x,C;t[8]!==_||t[9]!==r?(C=e=>{_||r(e)},t[8]=_,t[9]=r,t[10]=C):C=t[10];let w;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(ie,{className:X(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,v8)}),t[11]=w):w=t[11];let T;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(T=X(`fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,y8,`rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),t[12]=T):T=t[12];let E;t[13]===f.importDialogTitle?E=t[14]:(E=(0,Z.jsx)(ue,{className:`text-base font-semibold text-fg`,children:f.importDialogTitle}),t[13]=f.importDialogTitle,t[14]=E);let D;t[15]===f.importDialogSourceLabel?D=t[16]:(D=(0,Z.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-fg-disabled`,children:f.importDialogSourceLabel}),t[15]=f.importDialogSourceLabel,t[16]=D);let O;t[17]===o?O=t[18]:(O=(0,Z.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg-muted`,children:o}),t[17]=o,t[18]=O);let k;t[19]!==D||t[20]!==O?(k=(0,Z.jsxs)(`div`,{children:[D,O]}),t[19]=D,t[20]=O,t[21]=k):k=t[21];let A;t[22]===f.importDialogDestinationLabel?A=t[23]:(A=(0,Z.jsx)(`span`,{className:`text-[11px] uppercase tracking-wide text-fg-disabled`,children:f.importDialogDestinationLabel}),t[22]=f.importDialogDestinationLabel,t[23]=A);let j;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>g(e.target.value),t[24]=j):j=t[24];let M=f.importDialogDestinationLabel,N;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(N=X(`mt-1 w-full rounded-md border border-edge bg-surface px-2 py-1.5 font-mono text-xs text-fg outline-none`,`focus:border-accent focus:ring-1 focus:ring-accent disabled:opacity-60`),t[25]=N):N=t[25];let P;t[26]!==_||t[27]!==h||t[28]!==f.importDialogDestinationLabel?(P=(0,Z.jsx)(`input`,{type:`text`,value:h,onChange:j,disabled:_,"aria-label":M,className:N,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`}),t[26]=_,t[27]=h,t[28]=f.importDialogDestinationLabel,t[29]=P):P=t[29];let F;t[30]!==A||t[31]!==P?(F=(0,Z.jsxs)(`label`,{className:`block`,children:[A,P]}),t[30]=A,t[31]=P,t[32]=F):F=t[32];let I;t[33]===y?I=t[34]:(I=y?(0,Z.jsx)(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-2 py-1.5 text-xs text-danger`,children:y}):null,t[33]=y,t[34]=I);let L;t[35]!==F||t[36]!==I||t[37]!==k?(L=(0,Z.jsxs)(`div`,{className:`mt-3 space-y-3 text-sm`,children:[k,F,I]}),t[35]=F,t[36]=I,t[37]=k,t[38]=L):L=t[38];let R;t[39]===r?R=t[40]:(R=()=>r(!1),t[39]=r,t[40]=R);let z;t[41]!==_||t[42]!==f.importDialogCancel||t[43]!==R?(z=(0,Z.jsx)(wA,{type:`button`,variant:`secondary`,onClick:R,disabled:_,children:f.importDialogCancel}),t[41]=_,t[42]=f.importDialogCancel,t[43]=R,t[44]=z):z=t[44];let B;t[45]===S?B=t[46]:(B=()=>void S(),t[45]=S,t[46]=B);let V;t[47]!==_||t[48]!==h?(V=_||!h.trim(),t[47]=_,t[48]=h,t[49]=V):V=t[49];let H;t[50]===_?H=t[51]:(H=_?(0,Z.jsx)(Cg,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,t[50]=_,t[51]=H);let U=_?f.importInProgress:f.importDialogConfirm,W;t[52]!==B||t[53]!==V||t[54]!==H||t[55]!==U?(W=(0,Z.jsxs)(wA,{type:`button`,variant:`secondary`,onClick:B,disabled:V,className:`inline-flex items-center gap-1.5`,children:[H,U]}),t[52]=B,t[53]=V,t[54]=H,t[55]=U,t[56]=W):W=t[56];let ee;t[57]!==z||t[58]!==W?(ee=(0,Z.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[z,W]}),t[57]=z,t[58]=W,t[59]=ee):ee=t[59];let K;t[60]!==L||t[61]!==ee||t[62]!==E?(K=(0,Z.jsxs)(G,{children:[w,(0,Z.jsxs)(se,{className:T,onOpenAutoFocus:kbe,children:[E,L,ee]})]}),t[60]=L,t[61]=ee,t[62]=E,t[63]=K):K=t[63];let te;return t[64]!==n||t[65]!==K||t[66]!==C?(te=(0,Z.jsx)(q,{open:n,onOpenChange:C,children:K}),t[64]=n,t[65]=K,t[66]=C,t[67]=te):te=t[67],te}function kbe(e){return e.preventDefault()}function Abe(e){return e.language}function _7(e){let t=(0,Y.c)(29),{paths:n,sessionKey:r}=e,i=lQ(Ibe),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a={},t[0]=a):a=t[0];let[o,s]=(0,J.useState)(a),c;t[1]===n?c=t[2]:(c=n.map(Fbe).join(`
4685
+ `),t[1]=n,t[2]=c);let l=c,u;t[3]===r?u=t[4]:(u=r?.trim()||void 0,t[3]=r,t[4]=u);let d=u,f;t[5]!==n||t[6]!==d?(f=async()=>{let e={};return await Promise.all(n.map(async t=>{let n=a7(t.absolutePath),r;if(t.workspaceRelativePath){if(r=await YH(t.workspaceRelativePath,{sessionKey:d}),r&&(r.scope===`missing`||r.scope===`invalid`)&&n){let e=await YH(t.absolutePath,{sessionKey:d});e&&e.scope!==`missing`&&e.scope!==`invalid`&&(r=e)}}else r=await YH(t.absolutePath,{sessionKey:d});e[t.absolutePath]=r})),e},t[5]=n,t[6]=d,t[7]=f):f=t[7];let p;t[8]!==l||t[9]!==d?(p=[l,d],t[8]=l,t[9]=d,t[10]=p):p=t[10];let m=n.length>0,h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h={},t[11]=h):h=t[11];let g;t[12]===m?g=t[13]:(g={enabled:m,initial:null,errorData:h},t[12]=m,t[13]=g);let _=UF(f,p,g);if(n.length===0||_.data===null)return null;let v=_.data,y,b,x,S,C;if(t[14]!==n||t[15]!==o||t[16]!==_.data||t[17]!==r||t[18]!==i){C=Symbol.for(`react.early_return_sentinel`);bb0:{let e={...v,...o},t=n.flatMap(t=>{let n=e[t.absolutePath]??null;return!n||t.origin===`assistant-markdown`&&(n.scope===`missing`||n.scope===`invalid`)?[]:[{...t,refInfo:n}]});if(t.length===0){C=null;break bb0}let a=t.filter(Pbe),c=a.filter(Nbe),l=a.filter(Mbe),u=t.filter(jbe);y=`mt-1.5 min-w-0 space-y-1.5`,b=c.length>0?(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:c.map(e=>{let t=e.refInfo.workspaceRelativePath;return(0,Z.jsx)(Cbe,{workspaceRel:t,sessionKey:r,onOpen:()=>i(t)},e.absolutePath)})}):null,x=l.length>0?(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:l.map(e=>{let t=e.refInfo.workspaceRelativePath;return(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>i(t),className:X(`inline-flex max-w-full items-center gap-1.5 rounded-md bg-accent-soft/40 px-2 py-1 text-left text-xs text-accent-fg`,`max-w-xs transition-colors hover:bg-accent-soft/60`,AX.focusRingPanel,AX.press),title:e.absolutePath,children:[(0,Z.jsx)(Af,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.fileName}),(0,Z.jsx)(Cd,{className:`size-3 shrink-0 opacity-60`,strokeWidth:1.75,"aria-hidden":!0})]},e.absolutePath)})}):null,S=u.length>0?(0,Z.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:u.map(t=>(0,Z.jsx)(Ebe,{path:t,refInfo:t.refInfo,sessionKey:r,onImported:n=>{s(r=>({...r,[t.absolutePath]:{...e[t.absolutePath],fileRefId:n.newFileRefId,scope:`workspace`,locationKind:void 0,manageRoute:void 0,exists:!0,isDirectory:!1,absolutePath:n.absolutePath,workspaceRelativePath:n.workspaceRelativePath,capabilities:[`preview`,`edit`,`openExternal`,`revealInFolder`,`copyPath`],mtimeMs:n.mtimeMs,errorCode:void 0}})),i(n.workspaceRelativePath)}},t.absolutePath))}):null}t[14]=n,t[15]=o,t[16]=_.data,t[17]=r,t[18]=i,t[19]=y,t[20]=b,t[21]=x,t[22]=S,t[23]=C}else y=t[19],b=t[20],x=t[21],S=t[22],C=t[23];if(C!==Symbol.for(`react.early_return_sentinel`))return C;let w;return t[24]!==y||t[25]!==b||t[26]!==x||t[27]!==S?(w=(0,Z.jsxs)(`div`,{className:y,children:[b,x,S]}),t[24]=y,t[25]=b,t[26]=x,t[27]=S,t[28]=w):w=t[28],w}function jbe(e){return e.refInfo.scope!==`workspace`}function Mbe(e){return!i7(e.mimeType)}function Nbe(e){return i7(e.mimeType)}function Pbe(e){return e.refInfo.scope===`workspace`&&!!e.refInfo.workspaceRelativePath}function Fbe(e){return`${e.absolutePath}\0${e.workspaceRelativePath??``}`}function Ibe(e){return e.setPath}var v7=new Set([`write_file`,`edit_file`,`image_generate`]);function Lbe(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function y7(e){return(e??``).replace(/\\/g,`/`).replace(/^\/+/,``).trim()}function Rbe(e,t){let n=y7(e.workspaceRelativePath),r=y7(t.workspaceRelativePath),i=e.absolutePath,a=t.absolutePath;return n&&r?n===r:n&&a7(a)?m7(a,n):r&&a7(i)?m7(i,r):a7(i)&&a7(a)?i.replace(/\\/g,`/`).trim()===a.replace(/\\/g,`/`).trim():i===a}function zbe(e,t){let n=a7(e.absolutePath)?e.absolutePath:a7(t.absolutePath)?t.absolutePath:e.absolutePath;return{...e,absolutePath:n,workspaceRelativePath:e.workspaceRelativePath??t.workspaceRelativePath,fileName:e.fileName||t.fileName,mimeType:e.mimeType||t.mimeType}}function b7(e){let t=[],n=y7(e.workspaceRelativePath);n&&t.push(`rel:${n}`);let r=e.absolutePath?.replace(/\\/g,`/`).trim();return a7(r)&&t.push(`abs:${r}`),t}function Bbe(e){let t=new Map;return e.forEach((e,n)=>{for(let r of b7(e))t.set(r,n)}),t}function Vbe(e,t,n){for(let e of b7(n)){let n=t.get(e);if(n!==void 0)return n}for(let t=0;t<e.length;t++)if(Rbe(e[t],n))return t;return-1}function x7(e,t){let n=Bbe(e);for(let r of t){let t=Vbe(e,n,r);if(t>=0){e[t]=zbe(e[t],r);for(let r of b7(e[t]))n.set(r,t);continue}let i=e.length;e.push(r);for(let e of b7(r))n.set(e,i)}}function Hbe(e){return!(e.type===`voice`||e.type===`audio`||e.type===`image`||e.mimeType?.startsWith(`image/`)||e.mimeType?.startsWith(`audio/`))}function Ube(e,t){if(!e?.length||!t.length)return e;let n=e.filter(e=>Hbe(e)?!Wbe(e,t):!0);return n.length===e.length?e:n.length?n:void 0}function S7(e){let t=e.replace(/\\/g,`/`).split(`/`).filter(Boolean);return(t[t.length-1]??e).trim().toLowerCase()}function Wbe(e,t){let n=y7(e.workspaceRelativePath),r=(e.name??``).trim().toLowerCase();for(let e of t){let t=y7(e.workspaceRelativePath);if(t&&n&&n===t||t&&!n&&r&&S7(t)===r||a7(e.absolutePath)&&n&&m7(e.absolutePath,n)||!t&&!n&&r&&a7(e.absolutePath)&&S7(e.absolutePath)===r)return!0}return!1}function Gbe(e){if(!e?.length)return[];let t=[];for(let n of e){if(n.type!==`tool_use`)continue;let e=n;if(e.status!==`done`||!v7.has(e.name))continue;let r=Lbe(e.result);r.trim()&&x7(t,h7(r))}let n=new Set(t.flatMap(e=>{let t=y7(e.workspaceRelativePath);return t?[t]:[]})),r=new Set;for(let e of t)if(a7(e.absolutePath)){let t=S7(e.absolutePath);t&&r.add(t)}for(let i of e){if(i.type!==`text`)continue;let e=(i.text??``).trim();!e||n.size===0&&r.size===0||x7(t,xbe(e).filter(e=>{let t=y7(e.workspaceRelativePath);if(!t)return!1;if(n.has(t))return!0;if(t.split(`/`).length<2)return!1;let i=S7(t);return i.length>0&&r.has(i)}))}return t}function C7(e,t){let n=e.source?.data?.trim();if(!n)return null;let r=n.match(/^data:([^;]+);base64,([\s\S]+)$/i);if(r?.[1]&&r[2]){let e=r[2].replace(/\s/g,``);return{name:`image-${t+1}`,mimeType:r[1],type:`image`,content:e,data:e}}if(n.startsWith(`data:`))return{name:`image-${t+1}`,mimeType:`image/png`,type:`image`,content:n,data:n};let i=n.replace(/\s/g,``);return{name:`image-${t+1}`,mimeType:`image/png`,type:`image`,content:i,data:i}}function Kbe(e){if(!e?.length)return[];let t=[];for(let n=0;n<e.length;n+=1){let r=C7(e[n],n);r&&t.push(r)}return t}function qbe(e){let t=[];for(let n of e)n.type===`thinking`||n.type===`tool_use`||(n.type===`text`?t.push(n.text):n.type===`image`&&t.push(`[image]`));return t.join(`
4686
+
4687
+ `).trim()}function Jbe(e){if(!e.trim())return``;let t=EK.parse(e,{gfm:!0,breaks:!1});return new DOMParser().parseFromString(`<div>${t}</div>`,`text/html`).body.textContent?.trim()??``}function Ybe(e){let t=[];for(let n of e)n.type===`thinking`||n.type===`tool_use`||(n.type===`text`?t.push(Jbe(n.text)):n.type===`image`&&t.push(`[image]`));return t.join(`
4688
+
4689
+ `).trim()}function w7(e){return e.toLowerCase().replace(/-/g,`_`).trim()}function Xbe(e,t){let n=w7(e);return n===`shell`?t.runCommand:n===`list_dir`||n===`ls`?t.listDirectory:n===`write_file`?t.writeFile:n===`edit_file`?t.editFile:n===`web_fetch`?t.fetchUrl:n===`open_url`?t.openUrl:n===`web_search`||n===`brave_search`||n.includes(`search`)?t.searchedWeb:n===`read_file`||n.includes(`read_file`)||n.includes(`file_read`)?t.readFile:t.unknownTool.replace(`{{name}}`,e.trim()||`tool`)}function Zbe(e){if(e===void 0)return``;try{return JSON.stringify(JSON.parse(e),null,2)}catch{try{return JSON.stringify(e,null,2)}catch{return String(e)}}}function T7(e){if(e==null)return null;try{return typeof e==`string`?JSON.parse(e):e}catch{return null}}function Qbe(e){let t=T7(e),n=t?.query??t?.q??t?.query_string??t?.search_term??t?.searchQuery;return typeof n==`string`?n:typeof n==`number`?String(n):``}function E7(e){let t=T7(e),n=t?.path??t?.file_path??t?.filepath??t?.file;return typeof n==`string`?n:``}function D7(e){let t=T7(e),n=t?.url??t?.href??t?.uri??t?.website;return typeof n==`string`?n:``}function O7(e){let t=T7(e),n=t?.command??t?.cmd??t?.shell??t?.script;return typeof n==`string`?n:``}var k7=120;function A7(e){if(e==null)return``;let t=T7(e);if(!t)return typeof e==`string`?e.trim():``;let n=[t.command,t.cmd,t.shell,t.script,t.path,t.file_path,t.filepath,t.file,t.url,t.href,t.uri,t.website,t.query,t.q,t.query_string,t.search_term,t.searchQuery];for(let e of n){if(typeof e==`string`&&e.trim()){let t=e.trim();return t.length>k7?`${t.slice(0,k7)}…`:t}if(typeof e==`number`&&Number.isFinite(e))return String(e)}return``}function $be(e){try{return new URL(e).hostname}catch{return e}}function exe(e){if(!e?.trim())return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!t||typeof t!=`object`)return[];let n=t,r=n.details,i=[];if(r&&typeof r==`object`){let e=r.results;Array.isArray(e)&&(i=e)}i.length===0&&Array.isArray(n.results)&&(i=n.results);let a=[],o=new Set;for(let e of i){if(!e||typeof e!=`object`)continue;let t=e,n=t.url;if(typeof n!=`string`||!n.trim())continue;let r=n.trim();if(!/^https?:\/\//i.test(r)||o.has(r))continue;o.add(r);let i=t.title,s=typeof i==`string`&&i.trim().length>0?i.trim():$be(r);a.push({url:r,title:s})}return a}function j7(e){let t=e.trim().toLowerCase();return t===`web_search`||t===`brave_search`}var txe=120,M7=240,nxe=3,N7=[`readFile`,`editFile`,`writeFile`,`runCommand`,`search`,`fetchUrl`,`openUrl`,`listDir`,`other`];function P7(e){let t=w7(e);return t===`shell`?`runCommand`:t===`list_dir`||t===`ls`?`listDir`:t===`write_file`?`writeFile`:t===`edit_file`?`editFile`:t===`web_fetch`?`fetchUrl`:t===`open_url`?`openUrl`:j7(e)||t.includes(`search`)?`search`:t===`read_file`||t.includes(`read_file`)||t.includes(`file_read`)?`readFile`:`other`}function F7(e){let t=new Map;for(let n of e){if(n.type!==`tool_use`)continue;let e=P7(n.name),r=t.get(e)??{total:0,running:0};r.total+=1,n.status===`running`&&(r.running+=1),t.set(e,r)}return t}function I7(e,t,n){return n[t===1?`${e}_one`:`${e}_other`].replace(/\{\{count\}\}/g,String(t))}function rxe(e,t){switch(e){case`search`:return t.search;case`readFile`:return t.readFile;case`editFile`:return t.editFile;case`writeFile`:return t.writeFile;case`runCommand`:return t.runCommand;case`listDir`:return t.listDir;case`openUrl`:return t.openUrl;case`fetchUrl`:return t.fetchUrl;case`other`:return t.other}}function ixe(e){let t=[];for(let n of N7)e.has(n)&&t.push(n);return t}function axe(e,t){return e.length===0?``:e.length===1?e[0]:e.length===2?`${e[0]}${t.joinFinal}${e[1]}`:`${e.slice(0,-1).join(t.join)}${t.joinFinal}${e[e.length-1]}`}function L7(e,t){return e.length>t?`${e.slice(0,t)}…`:e}function oxe(e,t,n,r){let i=e.input,a=``;return a=t===`search`?Qbe(i).trim():t===`runCommand`?O7(i).trim():t===`readFile`||t===`editFile`||t===`writeFile`?E7(i).trim():t===`fetchUrl`||t===`openUrl`?D7(i).trim():A7(i).trim(),a?L7(`${I7(t,1,n)}${r===`zh`?`:`:`: `}${L7(a,txe)}`,M7):null}function sxe(e,t,n,r){let i=F7(e);if(i.size===0)return null;let a=i.size===1?[...i.keys()][0]:null;if(a&&i.get(a).total===1){let n=e.find(e=>e.type===`tool_use`&&P7(e.name)===a);if(n){let e=oxe(n,a,t,r);if(e)return e}}let o=ixe(i),s=o.slice(0,nxe),c=o.length-s.length,l=axe(s.map(e=>I7(e,i.get(e).total,t)),n);return c>0&&(l=`${l}${n.moreSuffix}`),L7(l,M7)}function cxe(e,t){let n=F7(e),r=[];for(let e of N7){let t=n.get(e);t&&t.running>0&&r.push(e)}return r.length===1?rxe(r[0],t):r.length>1?t.mixed:e.some(e=>e.type===`thinking`&&e.streaming)?t.thinking:n.size>0?t.mixed:null}function R7(e){return e.filter(e=>e.type!==`thinking`||!!e.text?.trim()||!!e.streaming)}function z7(e,t){return(e===1?t.viewSteps_one:t.viewSteps_other).replace(/\{\{count\}\}/g,String(e))}function lxe(e,t,n,r,i){return sxe(e,t,n,r)??i}function uxe(e,t){return cxe(e,t)}function dxe(e){return e.startsWith(`@@`)?`hunk`:e.startsWith(`+++`)||e.startsWith(`---`)||e.startsWith(`diff `)||e.startsWith(`index `)?`meta`:e.startsWith(`+`)?`add`:e.startsWith(`-`)?`del`:`context`}function fxe(e){let t=e.details?.diff;if(typeof t!=`string`||t.length===0)return null;let n=t.split(`
4690
+ `),r=[],i=0,a=0;for(let e of n){let t=dxe(e);t===`add`&&!e.startsWith(`+++`)&&i++,t===`del`&&!e.startsWith(`---`)&&a++,r.push({kind:t,text:e})}return{raw:t,lines:r,added:i,removed:a}}function B7(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function V7(e){if(typeof e==`string`)return e;if(!Array.isArray(e))return``;let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;e.type===`text`&&typeof e.text==`string`&&t.push(e.text)}return t.join(`
4691
+ `)}function H7(e){if(e==null)return{details:null,text:``,isStructured:!1};if(typeof e==`object`&&!Array.isArray(e)){let t=e;return`content`in t||`details`in t?{details:B7(t.details),text:V7(t.content),isStructured:!0}:{details:null,text:``,isStructured:!1}}if(typeof e==`string`){let t=e.trim();if(t.startsWith(`{`))try{let e=B7(JSON.parse(t));if(e&&(`content`in e||`details`in e))return{details:B7(e.details),text:V7(e.content),isStructured:!0}}catch{}return{details:null,text:e,isStructured:!1}}return{details:null,text:String(e),isStructured:!1}}var pxe=`inline-flex max-w-full min-w-0 items-center gap-1 rounded-md bg-accent-soft/40 px-1.5 py-0.5 text-[11px] font-medium text-fg-muted [overflow-wrap:anywhere] dark:bg-accent-soft/25`,mxe=`inline-flex max-w-full min-w-0 items-center break-words rounded-md bg-surface-hover/60 px-1.5 py-0.5 font-mono text-xs text-fg [overflow-wrap:anywhere] dark:bg-surface-hover/35`,hxe=`max-h-72 w-full min-w-0 max-w-full overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-md bg-surface-hover/60 p-2 font-mono text-xs text-fg-muted [overflow-wrap:anywhere] dark:bg-surface-hover/35`,gxe=`cursor-pointer select-none text-xs text-fg-subtle underline-offset-2 hover:text-fg-muted group-open:text-fg-muted`;function U7(e){let t=(0,Y.c)(5),{children:n,tone:r}=e,i=r===void 0?`neutral`:r,a=i===`positive`?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:i===`negative`?`bg-red-500/15 text-red-700 dark:text-red-300`:i===`warning`?`bg-amber-500/15 text-amber-700 dark:text-amber-300`:i===`accent`?`bg-accent-soft/70 text-accent-fg dark:bg-accent-soft/50`:``,o;t[0]===a?o=t[1]:(o=X(pxe,a),t[0]=a,t[1]=o);let s;return t[2]!==n||t[3]!==o?(s=(0,Z.jsx)(`span`,{className:o,children:n}),t[2]=n,t[3]=o,t[4]=s):s=t[4],s}function W7(e){let t=(0,Y.c)(3),{children:n,title:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,Z.jsx)(`code`,{className:mxe,title:r,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}var G7=(0,J.memo)(function(e){let t=(0,Y.c)(11),{text:n,label:r,copiedLabel:i}=e,[a,o]=(0,J.useState)(!1),s;t[0]===n?s=t[1]:(s=async e=>{e.preventDefault(),e.stopPropagation(),await lH(n)&&(o(!0),window.setTimeout(()=>o(!1),1200))},t[0]=n,t[1]=s);let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=X(`inline-flex shrink-0 items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,AX.transition,AX.focusRingPanel),t[2]=c):c=t[2];let l;t[3]!==a||t[4]!==i||t[5]!==r?(l=a?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ml,{className:`size-3`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:i})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(tu,{className:`size-3`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`hidden sm:inline`,children:r})]}),t[3]=a,t[4]=i,t[5]=r,t[6]=l):l=t[6];let u;return t[7]!==r||t[8]!==s||t[9]!==l?(u=(0,Z.jsx)(`button`,{type:`button`,onClick:s,className:c,"aria-label":r,title:r,children:l}),t[7]=r,t[8]=s,t[9]=l,t[10]=u):u=t[10],u});function K7(e){let t=(0,Y.c)(8),{summary:n,children:r,defaultOpen:i}=e,a=i===void 0?!1:i,o;t[0]===n?o=t[1]:(o=(0,Z.jsx)(`summary`,{className:gxe,children:n}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,Z.jsx)(`div`,{className:`mt-1.5 min-w-0`,children:r}),t[2]=r,t[3]=s);let c;return t[4]!==a||t[5]!==o||t[6]!==s?(c=(0,Z.jsxs)(`details`,{className:`group min-w-0 text-xs`,open:a,children:[o,s]}),t[4]=a,t[5]=o,t[6]=s,t[7]=c):c=t[7],c}function q7(e){let t=(0,Y.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`pre`,{className:hxe,children:n}),t[0]=n,t[1]=r),r}function J7(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>{let r=t[n];return r==null?``:String(r)})}function Y7(e){return e.details??{}}var X7=/\[(\d+)\/(\d+) lines\]\s*$/;function _xe(e){let t=e.match(X7);if(!t)return null;let n=Number(t[1]),r=Number(t[2]);return!Number.isFinite(n)||!Number.isFinite(r)?null:{shown:n,total:r}}function vxe(e){return e.replace(X7,``).trimEnd()}var yxe=(0,J.memo)(function(e){let t=(0,Y.c)(32),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=E7(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=H7(n.result),t[2]=n.result,t[3]=o);let s=o.text,c;t[4]===s?c=t[5]:(c=_xe(s),t[4]=s,t[5]=c);let l=c,u;t[6]===s?u=t[7]:(u=vxe(s),t[6]=s,t[7]=u);let d=u,f;bb0:{if(l){f=l.total;break bb0}if(!d){f=0;break bb0}let e;t[8]===d?e=t[9]:(e=d.split(`
4687
4692
  `),t[8]=d,t[9]=e),f=e.length}let p=f,m;if(t[10]!==d){bb1:{if(!d){m=``;break bb1}let e=d.split(`
4688
4693
  `);if(e.length<=12){m=d;break bb1}m=`${e.slice(0,12).join(`
4689
- `)}\n…`}t[10]=d,t[11]=m}else m=t[11];let h=m,g;t[12]===a?g=t[13]:(g=a?(0,Z.jsx)(L7,{title:a,children:a}):null,t[12]=a,t[13]=g);let _;t[14]!==r||t[15]!==l||t[16]!==p?(_=p>0?(0,Z.jsx)(I7,{children:l&&l.shown<l.total?V7(r.linesPartial,{shown:l.shown,total:l.total}):V7(r.linesBadge,{count:p})}):null,t[14]=r,t[15]=l,t[16]=p,t[17]=_):_=t[17];let v;t[18]!==r||t[19]!==a?(v=a?(0,Z.jsx)(R7,{text:a,label:r.copyPath,copiedLabel:r.copied}):null,t[18]=r,t[19]=a,t[20]=v):v=t[20];let y;t[21]!==g||t[22]!==_||t[23]!==v?(y=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,children:[g,_,v]}),t[21]=g,t[22]=_,t[23]=v,t[24]=y):y=t[24];let b;t[25]!==d||t[26]!==r||t[27]!==h?(b=d?(0,Z.jsx)(z7,{summary:r.viewContent,children:(0,Z.jsx)(B7,{children:h})}):null,t[25]=d,t[26]=r,t[27]=h,t[28]=b):b=t[28];let x;return t[29]!==y||t[30]!==b?(x=(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[y,b]}),t[29]=y,t[30]=b,t[31]=x):x=t[31],x});function Gbe(e){let t=(0,Y.c)(4),{lines:n}=e,r;t[0]===n?r=t[1]:(r=n.map(Kbe),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,Z.jsx)(`pre`,{className:`max-h-80 w-full min-w-0 max-w-full overflow-auto rounded-md bg-surface-hover/60 p-2 font-mono text-xs leading-snug text-fg-muted dark:bg-surface-hover/35`,children:r}),t[2]=r,t[3]=i),i}function Kbe(e,t){return(0,Z.jsx)(`div`,{className:X(`whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,e.kind===`add`&&`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`,e.kind===`del`&&`bg-red-500/15 text-red-700 dark:text-red-300`,e.kind===`hunk`&&`text-fg-subtle`,e.kind===`meta`&&`text-fg-disabled`),children:e.text||`\xA0`},t)}var qbe=(0,J.memo)(function(e){let t=(0,Y.c)(25),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=y7(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=F7(n.result),t[2]=n.result,t[3]=o);let s=o,c;t[4]===s?c=t[5]:(c=Lbe(s),t[4]=s,t[5]=c);let l=c,u;t[6]===a?u=t[7]:(u=a?(0,Z.jsx)(L7,{title:a,children:a}):null,t[6]=a,t[7]=u);let d;t[8]!==l||t[9]!==r?(d=l?(0,Z.jsx)(I7,{tone:`accent`,children:V7(r.diffStats,{added:l.added,removed:l.removed})}):null,t[8]=l,t[9]=r,t[10]=d):d=t[10];let f;t[11]!==r||t[12]!==a?(f=a?(0,Z.jsx)(R7,{text:a,label:r.copyPath,copiedLabel:r.copied}):null,t[11]=r,t[12]=a,t[13]=f):f=t[13];let p;t[14]!==u||t[15]!==d||t[16]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,children:[u,d,f]}),t[14]=u,t[15]=d,t[16]=f,t[17]=p):p=t[17];let m;t[18]!==l||t[19]!==r||t[20]!==s?(m=l?(0,Z.jsx)(z7,{summary:r.viewDiff,defaultOpen:!0,children:(0,Z.jsx)(Gbe,{lines:l.lines})}):s.text?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted [overflow-wrap:anywhere]`,children:s.text}):null,t[18]=l,t[19]=r,t[20]=s,t[21]=m):m=t[21];let h;return t[22]!==p||t[23]!==m?(h=(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[p,m]}),t[22]=p,t[23]=m,t[24]=h):h=t[24],h});function Jbe(e){return!Number.isFinite(e)||e<0?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var Ybe=(0,J.memo)(function(e){let t=(0,Y.c)(20),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=y7(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=F7(n.result),t[2]=n.result,t[3]=o);let s=o,c,l,u;if(t[4]!==r||t[5]!==s||t[6]!==a){let e=H7(s),n=typeof e.size==`number`?e.size:null;c=`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,t[10]===a?l=t[11]:(l=a?(0,Z.jsx)(L7,{title:a,children:a}):null,t[10]=a,t[11]=l),u=n==null?null:(0,Z.jsx)(I7,{children:V7(r.sizeBadge,{size:Jbe(n)})}),t[4]=r,t[5]=s,t[6]=a,t[7]=c,t[8]=l,t[9]=u}else c=t[7],l=t[8],u=t[9];let d;t[12]!==r||t[13]!==a?(d=a?(0,Z.jsx)(R7,{text:a,label:r.copyPath,copiedLabel:r.copied}):null,t[12]=r,t[13]=a,t[14]=d):d=t[14];let f;return t[15]!==c||t[16]!==l||t[17]!==u||t[18]!==d?(f=(0,Z.jsxs)(`div`,{className:c,children:[l,u,d]}),t[15]=c,t[16]=l,t[17]=u,t[18]=d,t[19]=f):f=t[19],f}),W7=12;function Xbe(e){if(!e)return{preview:``,truncated:!1};let t=e.split(`
4690
- `);return t.length<=W7?{preview:e,truncated:!1}:{preview:`${t.slice(0,W7).join(`
4691
- `)}\n…`,truncated:!0}}var Zbe=(0,J.memo)(function(e){let t=(0,Y.c)(35),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=x7(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=F7(n.result),t[2]=n.result,t[3]=o);let s=o,c,l,u,d,f;if(t[4]!==n.status||t[5]!==r||t[6]!==s){let e=H7(s),i=typeof e.exitCode==`number`?e.exitCode:null,a=!!e.timedOut;f=!!e.truncated,c=n.status===`running`;let o=n.status===`error`;l=s.text;let p;t[12]===l?p=t[13]:(p=Xbe(l),t[12]=l,t[13]=p),{preview:u}=p,d=c?(0,Z.jsxs)(I7,{children:[(0,Z.jsx)(Cg,{className:`size-3 animate-spin`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:r.exitCodeUnknown})]}):a?(0,Z.jsx)(I7,{tone:`warning`,children:r.timedOut}):i===0?(0,Z.jsx)(I7,{tone:`positive`,children:r.exitCodeOk}):i==null?o?(0,Z.jsx)(I7,{tone:`negative`,children:r.exitCodeUnknown}):null:(0,Z.jsx)(I7,{tone:`negative`,children:V7(r.exitCodeNonZero,{code:i})}),t[4]=n.status,t[5]=r,t[6]=s,t[7]=c,t[8]=l,t[9]=u,t[10]=d,t[11]=f}else c=t[7],l=t[8],u=t[9],d=t[10],f=t[11];let p=d,m;t[14]===a?m=t[15]:(m=a?(0,Z.jsxs)(L7,{title:a,children:[(0,Z.jsx)(`span`,{className:`mr-1 text-fg-disabled`,children:`$`}),a]}):null,t[14]=a,t[15]=m);let h;t[16]!==r||t[17]!==f?(h=f?(0,Z.jsx)(I7,{tone:`warning`,children:r.truncatedBadge}):null,t[16]=r,t[17]=f,t[18]=h):h=t[18];let g;t[19]!==a||t[20]!==r?(g=a?(0,Z.jsx)(R7,{text:a,label:r.copyCommand,copiedLabel:r.copied}):null,t[19]=a,t[20]=r,t[21]=g):g=t[21];let _;t[22]!==p||t[23]!==m||t[24]!==h||t[25]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,children:[m,p,h,g]}),t[22]=p,t[23]=m,t[24]=h,t[25]=g,t[26]=_):_=t[26];let v;t[27]!==c||t[28]!==r||t[29]!==l||t[30]!==u?(v=l?(0,Z.jsx)(z7,{summary:r.viewOutput,children:(0,Z.jsx)(B7,{children:u})}):c?null:(0,Z.jsx)(`p`,{className:`text-xs text-fg-disabled`,children:r.noOutput}),t[27]=c,t[28]=r,t[29]=l,t[30]=u,t[31]=v):v=t[31];let y;return t[32]!==_||t[33]!==v?(y=(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[_,v]}),t[32]=_,t[33]=v,t[34]=y):y=t[34],y}),Qbe=(0,J.memo)(function(e){let t=(0,Y.c)(27),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=b7(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=F7(n.result),t[2]=n.result,t[3]=o);let s=o,c,l,u,d,f;if(t[4]!==r||t[5]!==s||t[6]!==a){let e=H7(s),n=typeof e.extractedLength==`number`?e.extractedLength:null,i;if(t[12]!==s.text){bb0:{if(!s.text){i=``;break bb0}let e=s.text.split(`
4694
+ `)}\n…`}t[10]=d,t[11]=m}else m=t[11];let h=m,g;t[12]===a?g=t[13]:(g=a?(0,Z.jsx)(W7,{title:a,children:a}):null,t[12]=a,t[13]=g);let _;t[14]!==r||t[15]!==l||t[16]!==p?(_=p>0?(0,Z.jsx)(U7,{children:l&&l.shown<l.total?J7(r.linesPartial,{shown:l.shown,total:l.total}):J7(r.linesBadge,{count:p})}):null,t[14]=r,t[15]=l,t[16]=p,t[17]=_):_=t[17];let v;t[18]!==r||t[19]!==a?(v=a?(0,Z.jsx)(G7,{text:a,label:r.copyPath,copiedLabel:r.copied}):null,t[18]=r,t[19]=a,t[20]=v):v=t[20];let y;t[21]!==g||t[22]!==_||t[23]!==v?(y=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,children:[g,_,v]}),t[21]=g,t[22]=_,t[23]=v,t[24]=y):y=t[24];let b;t[25]!==d||t[26]!==r||t[27]!==h?(b=d?(0,Z.jsx)(K7,{summary:r.viewContent,children:(0,Z.jsx)(q7,{children:h})}):null,t[25]=d,t[26]=r,t[27]=h,t[28]=b):b=t[28];let x;return t[29]!==y||t[30]!==b?(x=(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[y,b]}),t[29]=y,t[30]=b,t[31]=x):x=t[31],x});function bxe(e){let t=(0,Y.c)(4),{lines:n}=e,r;t[0]===n?r=t[1]:(r=n.map(xxe),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,Z.jsx)(`pre`,{className:`max-h-80 w-full min-w-0 max-w-full overflow-auto rounded-md bg-surface-hover/60 p-2 font-mono text-xs leading-snug text-fg-muted dark:bg-surface-hover/35`,children:r}),t[2]=r,t[3]=i),i}function xxe(e,t){return(0,Z.jsx)(`div`,{className:X(`whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,e.kind===`add`&&`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`,e.kind===`del`&&`bg-red-500/15 text-red-700 dark:text-red-300`,e.kind===`hunk`&&`text-fg-subtle`,e.kind===`meta`&&`text-fg-disabled`),children:e.text||`\xA0`},t)}var Sxe=(0,J.memo)(function(e){let t=(0,Y.c)(25),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=E7(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=H7(n.result),t[2]=n.result,t[3]=o);let s=o,c;t[4]===s?c=t[5]:(c=fxe(s),t[4]=s,t[5]=c);let l=c,u;t[6]===a?u=t[7]:(u=a?(0,Z.jsx)(W7,{title:a,children:a}):null,t[6]=a,t[7]=u);let d;t[8]!==l||t[9]!==r?(d=l?(0,Z.jsx)(U7,{tone:`accent`,children:J7(r.diffStats,{added:l.added,removed:l.removed})}):null,t[8]=l,t[9]=r,t[10]=d):d=t[10];let f;t[11]!==r||t[12]!==a?(f=a?(0,Z.jsx)(G7,{text:a,label:r.copyPath,copiedLabel:r.copied}):null,t[11]=r,t[12]=a,t[13]=f):f=t[13];let p;t[14]!==u||t[15]!==d||t[16]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,children:[u,d,f]}),t[14]=u,t[15]=d,t[16]=f,t[17]=p):p=t[17];let m;t[18]!==l||t[19]!==r||t[20]!==s?(m=l?(0,Z.jsx)(K7,{summary:r.viewDiff,defaultOpen:!0,children:(0,Z.jsx)(bxe,{lines:l.lines})}):s.text?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted [overflow-wrap:anywhere]`,children:s.text}):null,t[18]=l,t[19]=r,t[20]=s,t[21]=m):m=t[21];let h;return t[22]!==p||t[23]!==m?(h=(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[p,m]}),t[22]=p,t[23]=m,t[24]=h):h=t[24],h});function Cxe(e){return!Number.isFinite(e)||e<0?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var wxe=(0,J.memo)(function(e){let t=(0,Y.c)(20),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=E7(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=H7(n.result),t[2]=n.result,t[3]=o);let s=o,c,l,u;if(t[4]!==r||t[5]!==s||t[6]!==a){let e=Y7(s),n=typeof e.size==`number`?e.size:null;c=`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,t[10]===a?l=t[11]:(l=a?(0,Z.jsx)(W7,{title:a,children:a}):null,t[10]=a,t[11]=l),u=n==null?null:(0,Z.jsx)(U7,{children:J7(r.sizeBadge,{size:Cxe(n)})}),t[4]=r,t[5]=s,t[6]=a,t[7]=c,t[8]=l,t[9]=u}else c=t[7],l=t[8],u=t[9];let d;t[12]!==r||t[13]!==a?(d=a?(0,Z.jsx)(G7,{text:a,label:r.copyPath,copiedLabel:r.copied}):null,t[12]=r,t[13]=a,t[14]=d):d=t[14];let f;return t[15]!==c||t[16]!==l||t[17]!==u||t[18]!==d?(f=(0,Z.jsxs)(`div`,{className:c,children:[l,u,d]}),t[15]=c,t[16]=l,t[17]=u,t[18]=d,t[19]=f):f=t[19],f}),Z7=12;function Txe(e){if(!e)return{preview:``,truncated:!1};let t=e.split(`
4695
+ `);return t.length<=Z7?{preview:e,truncated:!1}:{preview:`${t.slice(0,Z7).join(`
4696
+ `)}\n…`,truncated:!0}}var Exe=(0,J.memo)(function(e){let t=(0,Y.c)(35),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=O7(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=H7(n.result),t[2]=n.result,t[3]=o);let s=o,c,l,u,d,f;if(t[4]!==n.status||t[5]!==r||t[6]!==s){let e=Y7(s),i=typeof e.exitCode==`number`?e.exitCode:null,a=!!e.timedOut;f=!!e.truncated,c=n.status===`running`;let o=n.status===`error`;l=s.text;let p;t[12]===l?p=t[13]:(p=Txe(l),t[12]=l,t[13]=p),{preview:u}=p,d=c?(0,Z.jsxs)(U7,{children:[(0,Z.jsx)(Cg,{className:`size-3 animate-spin`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:r.exitCodeUnknown})]}):a?(0,Z.jsx)(U7,{tone:`warning`,children:r.timedOut}):i===0?(0,Z.jsx)(U7,{tone:`positive`,children:r.exitCodeOk}):i==null?o?(0,Z.jsx)(U7,{tone:`negative`,children:r.exitCodeUnknown}):null:(0,Z.jsx)(U7,{tone:`negative`,children:J7(r.exitCodeNonZero,{code:i})}),t[4]=n.status,t[5]=r,t[6]=s,t[7]=c,t[8]=l,t[9]=u,t[10]=d,t[11]=f}else c=t[7],l=t[8],u=t[9],d=t[10],f=t[11];let p=d,m;t[14]===a?m=t[15]:(m=a?(0,Z.jsxs)(W7,{title:a,children:[(0,Z.jsx)(`span`,{className:`mr-1 text-fg-disabled`,children:`$`}),a]}):null,t[14]=a,t[15]=m);let h;t[16]!==r||t[17]!==f?(h=f?(0,Z.jsx)(U7,{tone:`warning`,children:r.truncatedBadge}):null,t[16]=r,t[17]=f,t[18]=h):h=t[18];let g;t[19]!==a||t[20]!==r?(g=a?(0,Z.jsx)(G7,{text:a,label:r.copyCommand,copiedLabel:r.copied}):null,t[19]=a,t[20]=r,t[21]=g):g=t[21];let _;t[22]!==p||t[23]!==m||t[24]!==h||t[25]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,children:[m,p,h,g]}),t[22]=p,t[23]=m,t[24]=h,t[25]=g,t[26]=_):_=t[26];let v;t[27]!==c||t[28]!==r||t[29]!==l||t[30]!==u?(v=l?(0,Z.jsx)(K7,{summary:r.viewOutput,children:(0,Z.jsx)(q7,{children:u})}):c?null:(0,Z.jsx)(`p`,{className:`text-xs text-fg-disabled`,children:r.noOutput}),t[27]=c,t[28]=r,t[29]=l,t[30]=u,t[31]=v):v=t[31];let y;return t[32]!==_||t[33]!==v?(y=(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[_,v]}),t[32]=_,t[33]=v,t[34]=y):y=t[34],y}),Dxe=(0,J.memo)(function(e){let t=(0,Y.c)(27),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=D7(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=H7(n.result),t[2]=n.result,t[3]=o);let s=o,c,l,u,d,f;if(t[4]!==r||t[5]!==s||t[6]!==a){let e=Y7(s),n=typeof e.extractedLength==`number`?e.extractedLength:null,i;if(t[12]!==s.text){bb0:{if(!s.text){i=``;break bb0}let e=s.text.split(`
4692
4697
  `);if(e.length<=12){i=s.text;break bb0}i=`${e.slice(0,12).join(`
4693
- `)}\n…`}t[12]=s.text,t[13]=i}else i=t[13];c=i,f=`space-y-1.5`,l=`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,t[14]===a?u=t[15]:(u=a?(0,Z.jsx)(`a`,{href:a,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex max-w-full min-w-0 items-center break-words rounded-md bg-surface-hover/60 px-1.5 py-0.5 font-mono text-xs text-accent-fg underline-offset-2 hover:underline [overflow-wrap:anywhere] dark:bg-surface-hover/35`,title:a,children:a}):null,t[14]=a,t[15]=u),d=n!=null&&n>0?(0,Z.jsx)(I7,{children:V7(r.linesBadge,{count:n})}):null,t[4]=r,t[5]=s,t[6]=a,t[7]=c,t[8]=l,t[9]=u,t[10]=d,t[11]=f}else c=t[7],l=t[8],u=t[9],d=t[10],f=t[11];let p;t[16]!==l||t[17]!==u||t[18]!==d?(p=(0,Z.jsxs)(`div`,{className:l,children:[u,d]}),t[16]=l,t[17]=u,t[18]=d,t[19]=p):p=t[19];let m;t[20]!==r||t[21]!==c?(m=c?(0,Z.jsx)(z7,{summary:r.viewContent,children:(0,Z.jsx)(B7,{children:c})}):null,t[20]=r,t[21]=c,t[22]=m):m=t[22];let h;return t[23]!==f||t[24]!==p||t[25]!==m?(h=(0,Z.jsxs)(`div`,{className:f,children:[p,m]}),t[23]=f,t[24]=p,t[25]=m,t[26]=h):h=t[26],h}),G7=c(_e(e=>({showRawToolData:!1,setShowRawToolData:t=>e({showRawToolData:t})}),{name:`xopc-web-dev-view`}));function K7(e,t){if(!Number.isFinite(e)||e<=0)return t===`zh`?`不到1秒`:`<1s`;let n=Math.floor(e/1e3);if(n===0)return t===`zh`?`不到1秒`:`<1s`;let r=Math.floor(n/60),i=n%60;return t===`zh`?r===0?`${i}秒`:i===0?`${r}分`:`${r}分${i}秒`:r===0?`${i}s`:i===0?`${r}m`:`${r}m ${i}s`}var $be=new Set([`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`]),exe=new Set([`extension_not_installed`,`extension_bridge_offline`,`extension_not_connected`,`local_chromium_missing`,`cloakbrowser_not_installed`,`cdp_unreachable`,`cloud_api_key_missing`]);function txe(e){if(!e?.trim())return null;let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=`object`)return null;let n=t;if(n.kind!==`browser_setup_required`)return null;let r=n.backend,i=n.reason,a=n.deepLink;return typeof r!=`string`||!$be.has(r)||typeof i!=`string`||!exe.has(i)||typeof a!=`string`||!a.startsWith(`/settings/`)?null:{kind:`browser_setup_required`,backend:r,reason:i,deepLink:a,detail:typeof n.detail==`string`?n.detail:void 0,message:typeof n.message==`string`?n.message:void 0}}var nxe={extension:Lv,local:Pg,cloakbrowser:sx,cdp:Gw,cloud:Ql};function rxe(e){let t=(0,Y.c)(29),{payload:n}=e,r=Qr(),i=d(ixe),a;t[0]===i?a=t[1]:(a=m(i),t[0]=i,t[1]=a);let o=a.chat,s=nxe[n.backend]??km,c=o.browserSetupRequiredTitle,l=o.browserSetupRequiredReasons[n.reason]??o.browserSetupRequiredReasons.generic,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=X(`mt-2 flex flex-col gap-2 rounded-xl border border-amber-300/60 bg-amber-50/70 px-3 py-3`,`dark:border-amber-500/30 dark:bg-amber-500/10`),t[2]=u):u=t[2];let f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=X(`flex size-8 shrink-0 items-center justify-center rounded-lg`,`bg-amber-100 text-amber-700 dark:bg-amber-500/20 dark:text-amber-300`),t[3]=f):f=t[3];let p;t[4]===s?p=t[5]:(p=(0,Z.jsx)(`span`,{className:f,"aria-hidden":!0,children:(0,Z.jsx)(s,{className:`size-4`,strokeWidth:1.75})}),t[4]=s,t[5]=p);let h;t[6]===c?h=t[7]:(h=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-amber-900 dark:text-amber-100`,children:c}),t[6]=c,t[7]=h);let g;t[8]===l?g=t[9]:(g=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-amber-900/85 dark:text-amber-100/80`,children:l}),t[8]=l,t[9]=g);let _;t[10]!==h||t[11]!==g?(_=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[h,g]}),t[10]=h,t[11]=g,t[12]=_):_=t[12];let v;t[13]!==p||t[14]!==_?(v=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[p,_]}),t[13]=p,t[14]=_,t[15]=v):v=t[15];let y;t[16]!==r||t[17]!==n.deepLink?(y=()=>r(n.deepLink),t[16]=r,t[17]=n.deepLink,t[18]=y):y=t[18];let b;t[19]!==o.browserSetupRequiredCta||t[20]!==y?(b=(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,Z.jsx)(wA,{type:`button`,variant:`primary`,className:`h-8 px-3 py-1.5 text-xs`,onClick:y,children:o.browserSetupRequiredCta})}),t[19]=o.browserSetupRequiredCta,t[20]=y,t[21]=b):b=t[21];let x;t[22]!==o.browserSetupRequiredDetailToggle||t[23]!==n.detail?(x=n.detail?(0,Z.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer select-none text-amber-800/80 underline-offset-2 hover:text-amber-900 dark:text-amber-200/80 dark:hover:text-amber-100`,children:o.browserSetupRequiredDetailToggle}),(0,Z.jsx)(`pre`,{className:`mt-2 max-h-40 w-full min-w-0 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-md bg-amber-100/60 p-2 font-mono text-[11px] text-amber-900 dark:bg-amber-500/15 dark:text-amber-100 [overflow-wrap:anywhere]`,children:n.detail})]}):null,t[22]=o.browserSetupRequiredDetailToggle,t[23]=n.detail,t[24]=x):x=t[24];let S;return t[25]!==b||t[26]!==x||t[27]!==v?(S=(0,Z.jsxs)(`section`,{role:`status`,"aria-live":`polite`,className:u,children:[v,b,x]}),t[25]=b,t[26]=x,t[27]=v,t[28]=S):S=t[28],S}function ixe(e){return e.language}function axe({workspaceRel:e,sessionKey:t,onOpen:n,className:r}){let[i,a]=(0,J.useState)(null);return(0,J.useEffect)(()=>{let n=null,r=!1;return(async()=>{try{let i=await ZH(e,{sessionKey:t?.trim()||void 0});if(r)return;let o=URL.createObjectURL(i);n=o,a(o)}catch{r||a(null)}})(),()=>{r=!0,n&&URL.revokeObjectURL(n)}},[e,t]),i?(0,Z.jsxs)(`button`,{type:`button`,onClick:n,className:X(`group relative size-20 overflow-hidden rounded-lg border border-edge-subtle text-left`,AX.press,AX.focusRingPanel,`hover:border-accent`,r),title:e,"aria-label":e,children:[(0,Z.jsx)(`img`,{src:i,className:`size-full object-cover`,alt:``}),(0,Z.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/0 transition-colors group-hover:bg-black/25`,children:(0,Z.jsx)(Cd,{className:`size-4 text-white opacity-0 transition-opacity group-hover:opacity-100`,strokeWidth:1.75})})]}):null}function q7(e){let t=(0,Y.c)(10),{icon:n,label:r,copiedLabel:i,onClick:a,copied:o}=e,s=i??r,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=X(`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,AX.focusRingPanel,AX.press),t[0]=c):c=t[0];let l;t[1]!==o||t[2]!==n?(l=o?(0,Z.jsx)(Ml,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0}):n,t[1]=o,t[2]=n,t[3]=l):l=t[3];let u=o?s:r,d;t[4]===u?d=t[5]:(d=(0,Z.jsx)(`span`,{children:u}),t[4]=u,t[5]=d);let f;return t[6]!==a||t[7]!==l||t[8]!==d?(f=(0,Z.jsxs)(`button`,{type:`button`,onClick:a,className:c,children:[l,d]}),t[6]=a,t[7]=l,t[8]=d,t[9]=f):f=t[9],f}function oxe(e){return e===`external`||e===`agent-profile`||e===`session-artifact`}function sxe(e,t){return e?t.locationKind[e]??t.externalBadge:t.externalBadge}function cxe(e){let t=(0,Y.c)(71),{path:n,refInfo:r,sessionKey:i,onImported:a}=e,o=Qr(),s=m(d(lxe)).chat,c=s.fileReference,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=Oj()&&!!window.electronAPI?.shell,t[0]=l):l=t[0];let u=l,f=r.absolutePath??n.absolutePath,[p,h]=(0,J.useState)(!1),g;t[1]!==u||t[2]!==r.fileRefId||t[3]!==i?(g=async e=>{if(!r.fileRefId||!u)return;let t=await XH(r.fileRefId,e,{sessionKey:i?.trim()||void 0});t&&(e===`openExternal`?await window.electronAPI?.shell?.openPath(t.absolutePath):await window.electronAPI?.shell?.showItemInFolder(t.absolutePath))},t[1]=u,t[2]=r.fileRefId,t[3]=i,t[4]=g):g=t[4];let _=g,v;t[5]===f?v=t[6]:(v=()=>{lH(f).then(e=>{e&&(h(!0),window.setTimeout(()=>h(!1),2e3))})},t[5]=f,t[6]=v);let y=v,[b,x]=(0,J.useState)(!1),S;t[7]!==r.capabilities||t[8]!==r.fileRefId?(S=r.capabilities.includes(`importToWorkspace`)&&!!r.fileRefId,t[7]=r.capabilities,t[8]=r.fileRefId,t[9]=S):S=t[9];let C=S,w=`imports/${n.fileName||r.displayName}`,T=r.scope===`missing`,E=r.scope===`invalid`,D=oxe(r.scope)&&r.exists,O=T?c.missingDescription:E?c.invalidDescription:D?u?c.offWorkspaceBaseDescription:c.browserOffWorkspaceDescription:u?c.externalDescription:c.browserExternalDescription,k=D||r.scope===`external`||r.scope===`agent-profile`?sxe(r.locationKind,c):null,A=T||E?`border-warning/30 bg-warning/5 text-fg-muted`:`border-edge-subtle bg-surface-panel text-fg`,j;t[10]===A?j=t[11]:(j=X(`flex max-w-xl min-w-0 flex-col gap-1 rounded-lg border px-2.5 py-2 text-xs`,A),t[10]=A,t[11]=j);let M;t[12]!==E||t[13]!==T?(M=T||E?(0,Z.jsx)(Rl,{className:`size-3.5 shrink-0 text-warning`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(Af,{className:`size-3.5 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=E,t[13]=T,t[14]=M):M=t[14];let N=n.fileName||r.displayName,P;t[15]===N?P=t[16]:(P=(0,Z.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:N}),t[15]=N,t[16]=P);let F;t[17]===k?F=t[18]:(F=k?(0,Z.jsx)(`span`,{className:`shrink-0 rounded bg-surface-muted px-1.5 py-0.5 text-[10px] text-fg-muted`,children:k}):null,t[17]=k,t[18]=F);let I;t[19]!==F||t[20]!==M||t[21]!==P?(I=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[M,P,F]}),t[19]=F,t[20]=M,t[21]=P,t[22]=I):I=t[22];let L;t[23]===O?L=t[24]:(L=(0,Z.jsx)(`p`,{className:`line-clamp-2 text-[11px] leading-snug text-fg-muted`,children:O}),t[23]=O,t[24]=L);let R;t[25]!==c||t[26]!==o||t[27]!==r.manageRoute?(R=r.manageRoute?(0,Z.jsx)(q7,{icon:(0,Z.jsx)(qb,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0}),label:c.openInSettings,onClick:()=>o(r.manageRoute)}):null,t[25]=c,t[26]=o,t[27]=r.manageRoute,t[28]=R):R=t[28];let z;t[29]!==u||t[30]!==c||t[31]!==_||t[32]!==r.capabilities?(z=u&&r.capabilities.includes(`openExternal`)?(0,Z.jsx)(q7,{icon:(0,Z.jsx)(yd,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0}),label:c.openExternal,onClick:()=>void _(`openExternal`)}):null,t[29]=u,t[30]=c,t[31]=_,t[32]=r.capabilities,t[33]=z):z=t[33];let B;t[34]!==u||t[35]!==c||t[36]!==_||t[37]!==r.capabilities?(B=u&&r.capabilities.includes(`revealInFolder`)?(0,Z.jsx)(q7,{icon:(0,Z.jsx)(Sp,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0}),label:c.revealInFolder,onClick:()=>void _(`revealInFolder`)}):null,t[34]=u,t[35]=c,t[36]=_,t[37]=r.capabilities,t[38]=B):B=t[38];let V;t[39]!==s||t[40]!==y||t[41]!==c||t[42]!==p||t[43]!==r.capabilities?(V=r.capabilities.includes(`copyPath`)?(0,Z.jsx)(q7,{icon:(0,Z.jsx)(tu,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0}),label:c.copyPath,copiedLabel:s.messageCopied,copied:p,onClick:y}):null,t[39]=s,t[40]=y,t[41]=c,t[42]=p,t[43]=r.capabilities,t[44]=V):V=t[44];let H;t[45]!==C||t[46]!==c||t[47]!==x?(H=C?(0,Z.jsx)(q7,{icon:(0,Z.jsx)(ms,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0}),label:c.importToWorkspace,onClick:()=>x(!0)}):null,t[45]=C,t[46]=c,t[47]=x,t[48]=H):H=t[48];let U;t[49]!==R||t[50]!==z||t[51]!==B||t[52]!==V||t[53]!==H?(U=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1 pt-0.5`,children:[R,z,B,V,H]}),t[49]=R,t[50]=z,t[51]=B,t[52]=V,t[53]=H,t[54]=U):U=t[54];let W;t[55]!==C||t[56]!==w||t[57]!==f||t[58]!==b||t[59]!==a||t[60]!==r.fileRefId||t[61]!==i||t[62]!==x?(W=C&&b?(0,Z.jsx)(uxe,{open:!0,onOpenChange:x,fileRefId:r.fileRefId,sessionKey:i,sourceLabel:f,defaultDestination:w,onImported:e=>{x(!1),a(e)}},`${r.fileRefId}:${w}`):null,t[55]=C,t[56]=w,t[57]=f,t[58]=b,t[59]=a,t[60]=r.fileRefId,t[61]=i,t[62]=x,t[63]=W):W=t[63];let G;return t[64]!==f||t[65]!==I||t[66]!==L||t[67]!==U||t[68]!==W||t[69]!==j?(G=(0,Z.jsxs)(`div`,{className:j,title:f,children:[I,L,U,W]}),t[64]=f,t[65]=I,t[66]=L,t[67]=U,t[68]=W,t[69]=j,t[70]=G):G=t[70],G}function lxe(e){return e.language}function uxe(e){let t=(0,Y.c)(68),{open:n,onOpenChange:r,fileRefId:i,sessionKey:a,sourceLabel:o,defaultDestination:s,onImported:c}=e,l=d(fxe),u;t[0]===l?u=t[1]:(u=m(l),t[0]=l,t[1]=u);let f=u.chat.fileReference,p=f.importErrors,[h,g]=(0,J.useState)(s),[_,v]=(0,J.useState)(!1),[y,b]=(0,J.useState)(null),x;t[2]!==h||t[3]!==p||t[4]!==i||t[5]!==c||t[6]!==a?(x=async()=>{v(!0),b(null);let e=await QH(i,{sessionKey:a?.trim()||void 0,destination:h.trim()||void 0,onConflict:`rename`});if(e.ok){c(e.payload);return}v(!1);let t=p;b(t[e.error.code]??t.UNKNOWN??e.error.message)},t[2]=h,t[3]=p,t[4]=i,t[5]=c,t[6]=a,t[7]=x):x=t[7];let S=x,C;t[8]!==_||t[9]!==r?(C=e=>{_||r(e)},t[8]=_,t[9]=r,t[10]=C):C=t[10];let w;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(ie,{className:X(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,v8)}),t[11]=w):w=t[11];let T;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(T=X(`fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,y8,`rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),t[12]=T):T=t[12];let E;t[13]===f.importDialogTitle?E=t[14]:(E=(0,Z.jsx)(ue,{className:`text-base font-semibold text-fg`,children:f.importDialogTitle}),t[13]=f.importDialogTitle,t[14]=E);let D;t[15]===f.importDialogSourceLabel?D=t[16]:(D=(0,Z.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-fg-disabled`,children:f.importDialogSourceLabel}),t[15]=f.importDialogSourceLabel,t[16]=D);let O;t[17]===o?O=t[18]:(O=(0,Z.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg-muted`,children:o}),t[17]=o,t[18]=O);let k;t[19]!==D||t[20]!==O?(k=(0,Z.jsxs)(`div`,{children:[D,O]}),t[19]=D,t[20]=O,t[21]=k):k=t[21];let A;t[22]===f.importDialogDestinationLabel?A=t[23]:(A=(0,Z.jsx)(`span`,{className:`text-[11px] uppercase tracking-wide text-fg-disabled`,children:f.importDialogDestinationLabel}),t[22]=f.importDialogDestinationLabel,t[23]=A);let j;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>g(e.target.value),t[24]=j):j=t[24];let M=f.importDialogDestinationLabel,N;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(N=X(`mt-1 w-full rounded-md border border-edge bg-surface px-2 py-1.5 font-mono text-xs text-fg outline-none`,`focus:border-accent focus:ring-1 focus:ring-accent disabled:opacity-60`),t[25]=N):N=t[25];let P;t[26]!==_||t[27]!==h||t[28]!==f.importDialogDestinationLabel?(P=(0,Z.jsx)(`input`,{type:`text`,value:h,onChange:j,disabled:_,"aria-label":M,className:N,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`}),t[26]=_,t[27]=h,t[28]=f.importDialogDestinationLabel,t[29]=P):P=t[29];let F;t[30]!==A||t[31]!==P?(F=(0,Z.jsxs)(`label`,{className:`block`,children:[A,P]}),t[30]=A,t[31]=P,t[32]=F):F=t[32];let I;t[33]===y?I=t[34]:(I=y?(0,Z.jsx)(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-2 py-1.5 text-xs text-danger`,children:y}):null,t[33]=y,t[34]=I);let L;t[35]!==F||t[36]!==I||t[37]!==k?(L=(0,Z.jsxs)(`div`,{className:`mt-3 space-y-3 text-sm`,children:[k,F,I]}),t[35]=F,t[36]=I,t[37]=k,t[38]=L):L=t[38];let R;t[39]===r?R=t[40]:(R=()=>r(!1),t[39]=r,t[40]=R);let z;t[41]!==_||t[42]!==f.importDialogCancel||t[43]!==R?(z=(0,Z.jsx)(wA,{type:`button`,variant:`secondary`,onClick:R,disabled:_,children:f.importDialogCancel}),t[41]=_,t[42]=f.importDialogCancel,t[43]=R,t[44]=z):z=t[44];let B;t[45]===S?B=t[46]:(B=()=>void S(),t[45]=S,t[46]=B);let V;t[47]!==_||t[48]!==h?(V=_||!h.trim(),t[47]=_,t[48]=h,t[49]=V):V=t[49];let H;t[50]===_?H=t[51]:(H=_?(0,Z.jsx)(Cg,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,t[50]=_,t[51]=H);let U=_?f.importInProgress:f.importDialogConfirm,W;t[52]!==B||t[53]!==V||t[54]!==H||t[55]!==U?(W=(0,Z.jsxs)(wA,{type:`button`,variant:`secondary`,onClick:B,disabled:V,className:`inline-flex items-center gap-1.5`,children:[H,U]}),t[52]=B,t[53]=V,t[54]=H,t[55]=U,t[56]=W):W=t[56];let ee;t[57]!==z||t[58]!==W?(ee=(0,Z.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[z,W]}),t[57]=z,t[58]=W,t[59]=ee):ee=t[59];let K;t[60]!==L||t[61]!==ee||t[62]!==E?(K=(0,Z.jsxs)(G,{children:[w,(0,Z.jsxs)(se,{className:T,onOpenAutoFocus:dxe,children:[E,L,ee]})]}),t[60]=L,t[61]=ee,t[62]=E,t[63]=K):K=t[63];let te;return t[64]!==n||t[65]!==K||t[66]!==C?(te=(0,Z.jsx)(q,{open:n,onOpenChange:C,children:K}),t[64]=n,t[65]=K,t[66]=C,t[67]=te):te=t[67],te}function dxe(e){return e.preventDefault()}function fxe(e){return e.language}function J7(e){let t=(0,Y.c)(29),{paths:n,sessionKey:r}=e,i=lQ(vxe),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a={},t[0]=a):a=t[0];let[o,s]=(0,J.useState)(a),c;t[1]===n?c=t[2]:(c=n.map(_xe).join(`
4694
- `),t[1]=n,t[2]=c);let l=c,u;t[3]===r?u=t[4]:(u=r?.trim()||void 0,t[3]=r,t[4]=u);let d=u,f;t[5]!==n||t[6]!==d?(f=async()=>{let e={};return await Promise.all(n.map(async t=>{let n=e7(t.absolutePath),r;if(t.workspaceRelativePath){if(r=await YH(t.workspaceRelativePath,{sessionKey:d}),r&&(r.scope===`missing`||r.scope===`invalid`)&&n){let e=await YH(t.absolutePath,{sessionKey:d});e&&e.scope!==`missing`&&e.scope!==`invalid`&&(r=e)}}else r=await YH(t.absolutePath,{sessionKey:d});e[t.absolutePath]=r})),e},t[5]=n,t[6]=d,t[7]=f):f=t[7];let p;t[8]!==l||t[9]!==d?(p=[l,d],t[8]=l,t[9]=d,t[10]=p):p=t[10];let m=n.length>0,h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h={},t[11]=h):h=t[11];let g;t[12]===m?g=t[13]:(g={enabled:m,initial:null,errorData:h},t[12]=m,t[13]=g);let _=UF(f,p,g);if(n.length===0||_.data===null)return null;let v=_.data,y,b,x,S,C;if(t[14]!==n||t[15]!==o||t[16]!==_.data||t[17]!==r||t[18]!==i){C=Symbol.for(`react.early_return_sentinel`);bb0:{let e={...v,...o},t=n.flatMap(t=>{let n=e[t.absolutePath]??null;return!n||t.origin===`assistant-markdown`&&(n.scope===`missing`||n.scope===`invalid`)?[]:[{...t,refInfo:n}]});if(t.length===0){C=null;break bb0}let a=t.filter(gxe),c=a.filter(hxe),l=a.filter(mxe),u=t.filter(pxe);y=`mt-1.5 min-w-0 space-y-1.5`,b=c.length>0?(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:c.map(e=>{let t=e.refInfo.workspaceRelativePath;return(0,Z.jsx)(axe,{workspaceRel:t,sessionKey:r,onOpen:()=>i(t)},e.absolutePath)})}):null,x=l.length>0?(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:l.map(e=>{let t=e.refInfo.workspaceRelativePath;return(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>i(t),className:X(`inline-flex max-w-full items-center gap-1.5 rounded-md bg-accent-soft/40 px-2 py-1 text-left text-xs text-accent-fg`,`max-w-xs transition-colors hover:bg-accent-soft/60`,AX.focusRingPanel,AX.press),title:e.absolutePath,children:[(0,Z.jsx)(Af,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.fileName}),(0,Z.jsx)(Cd,{className:`size-3 shrink-0 opacity-60`,strokeWidth:1.75,"aria-hidden":!0})]},e.absolutePath)})}):null,S=u.length>0?(0,Z.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:u.map(t=>(0,Z.jsx)(cxe,{path:t,refInfo:t.refInfo,sessionKey:r,onImported:n=>{s(r=>({...r,[t.absolutePath]:{...e[t.absolutePath],fileRefId:n.newFileRefId,scope:`workspace`,locationKind:void 0,manageRoute:void 0,exists:!0,isDirectory:!1,absolutePath:n.absolutePath,workspaceRelativePath:n.workspaceRelativePath,capabilities:[`preview`,`edit`,`openExternal`,`revealInFolder`,`copyPath`],mtimeMs:n.mtimeMs,errorCode:void 0}})),i(n.workspaceRelativePath)}},t.absolutePath))}):null}t[14]=n,t[15]=o,t[16]=_.data,t[17]=r,t[18]=i,t[19]=y,t[20]=b,t[21]=x,t[22]=S,t[23]=C}else y=t[19],b=t[20],x=t[21],S=t[22],C=t[23];if(C!==Symbol.for(`react.early_return_sentinel`))return C;let w;return t[24]!==y||t[25]!==b||t[26]!==x||t[27]!==S?(w=(0,Z.jsxs)(`div`,{className:y,children:[b,x,S]}),t[24]=y,t[25]=b,t[26]=x,t[27]=S,t[28]=w):w=t[28],w}function pxe(e){return e.refInfo.scope!==`workspace`}function mxe(e){return!$5(e.mimeType)}function hxe(e){return $5(e.mimeType)}function gxe(e){return e.refInfo.scope===`workspace`&&!!e.refInfo.workspaceRelativePath}function _xe(e){return`${e.absolutePath}\0${e.workspaceRelativePath??``}`}function vxe(e){return e.setPath}var Y7=`xopc.extensionUiGrants.v1`;function X7(e){return e.flatMap(e=>{let t=e.trim();return t?[t]:[]}).toSorted().join(`\0`)}function Z7(e,t){try{let n=localStorage.getItem(Y7);return(n?JSON.parse(n):{})[e]===X7(t)}catch{return!1}}function yxe(e,t){let n=localStorage.getItem(Y7),r=(n?JSON.parse(n):{})??{};r[e]=X7(t),localStorage.setItem(Y7,JSON.stringify(r))}var bxe={theme:`Read theme (light / dark)`,"agent.send":`Send messages to the assistant`,"agent.subscribe":`Receive live agent stream events for a chat`,"session.read":`List and open chat sessions`,"session.write":`Modify chat sessions`,"config.read":`Read extension configuration`,"config.write":`Write extension configuration`,storage:`Read and write extension storage`,notification:`Show in-app notifications`,clipboard:`Use the clipboard`,"workspace.read":`Read workspace files`,"workspace.write":`Write workspace files`},Q7={theme:`读取主题(浅色/深色)`,"agent.send":`向助手发送消息`,"agent.subscribe":`接收会话的实时助手流式事件`,"session.read":`列出并打开聊天会话`,"session.write":`修改聊天会话`,"config.read":`读取扩展配置`,"config.write":`写入扩展配置`,storage:`读写扩展存储`,notification:`显示应用内通知`,clipboard:`使用剪贴板`,"workspace.read":`读取工作区文件`,"workspace.write":`写入工作区文件`};function xxe(e,t){let n=bxe[e];return t===`zh`&&Q7[e]?Q7[e]:n??e}function Sxe(e){let t=(0,Y.c)(41),{open:n,onOpenChange:r,extensionId:i,extensionName:a,permissions:o,onConfirm:s}=e,{t:c}=Ve(),l=d(wxe),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(ie,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[0]=u):u=t[0];let f;t[1]!==a||t[2]!==c?(f=c(`extensionUi.permissionTitle`,{name:a}),t[1]=a,t[2]=c,t[3]=f):f=t[3];let p;t[4]===f?p=t[5]:(p=(0,Z.jsx)(ue,{className:`text-base font-semibold text-fg`,children:f}),t[4]=f,t[5]=p);let m;t[6]===c?m=t[7]:(m=c(`extensionUi.permissionSubtitle`),t[6]=c,t[7]=m);let h;t[8]===i?h=t[9]:(h=(0,Z.jsxs)(`span`,{className:`font-mono text-xs text-fg-muted`,title:i,children:[`(`,i,`)`]}),t[8]=i,t[9]=h);let g;t[10]!==m||t[11]!==h?(g=(0,Z.jsxs)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:[m,` `,h]}),t[10]=m,t[11]=h,t[12]=g):g=t[12];let _;t[13]!==l||t[14]!==o||t[15]!==c?(_=o.length===0?(0,Z.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:c(`extensionUi.permissionsNone`)}):(0,Z.jsx)(`ul`,{className:`mt-4 max-h-48 list-inside list-disc space-y-1 overflow-y-auto text-sm text-fg`,children:o.map(e=>(0,Z.jsx)(`li`,{children:xxe(e,l)},e))}),t[13]=l,t[14]=o,t[15]=c,t[16]=_):_=t[16];let v;t[17]===c?v=t[18]:(v=c(`extensionUi.deny`),t[17]=c,t[18]=v);let y;t[19]===v?y=t[20]:(y=(0,Z.jsx)(de,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`rounded-lg border border-edge px-3 py-2 text-sm text-fg hover:bg-surface-muted`,children:v})}),t[19]=v,t[20]=y);let b;t[21]!==s||t[22]!==r?(b=()=>{s(),r(!1)},t[21]=s,t[22]=r,t[23]=b):b=t[23];let x;t[24]===c?x=t[25]:(x=c(`extensionUi.allow`),t[24]=c,t[25]=x);let S;t[26]!==b||t[27]!==x?(S=(0,Z.jsx)(`button`,{type:`button`,className:`rounded-lg bg-accent px-3 py-2 text-sm font-medium text-white hover:opacity-90`,onClick:b,children:x}),t[26]=b,t[27]=x,t[28]=S):S=t[28];let C;t[29]!==S||t[30]!==y?(C=(0,Z.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[y,S]}),t[29]=S,t[30]=y,t[31]=C):C=t[31];let w;t[32]!==C||t[33]!==p||t[34]!==g||t[35]!==_?(w=(0,Z.jsxs)(G,{children:[u,(0,Z.jsxs)(se,{className:`fixed left-1/2 top-1/2 z-[131] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-5 shadow-elevated`,onOpenAutoFocus:Cxe,children:[p,g,_,C]})]}),t[32]=C,t[33]=p,t[34]=g,t[35]=_,t[36]=w):w=t[36];let T;return t[37]!==r||t[38]!==n||t[39]!==w?(T=(0,Z.jsx)(q,{open:n,onOpenChange:r,children:w}),t[37]=r,t[38]=n,t[39]=w,t[40]=T):T=t[40],T}function Cxe(e){return e.preventDefault()}function wxe(e){return e.language}var Txe=48,Exe=2e3,Dxe=`allow-scripts allow-forms allow-popups`;function Oxe(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function $7({extensionId:e,extensionName:t,entrypoint:n,permissions:r,title:i,className:a,fixedHeight:o,maxHeight:s=Exe,minHeight:c=Txe,initialData:l}){let{t:u}=Ve(),f=TI(),p=(0,J.useRef)(null),m=Se(e=>e.token),h=ve(e=>e.resolved),g=t?.trim()||e,v=i?.trim()||`Extension ${e}`,y=(0,J.useMemo)(()=>JSON.stringify(Array.from(r??[]).toSorted()),[r]),b=(0,J.useMemo)(()=>JSON.parse(y),[y]),x=Z7(e,b),[S,C]=(0,J.useReducer)(c5,{allowed:x,dialogOpen:!x,reloadKey:0,loadError:!1,dynamicHeight:o??Math.min(s,Math.max(c,320))}),{allowed:w,dialogOpen:T,reloadKey:E,loadError:D,dynamicHeight:O}=S,k=(0,J.useRef)({id:e,k:y});if(k.current.id!==e||k.current.k!==y){k.current={id:e,k:y};let t=Z7(e,b);C({type:`patch`,patch:{allowed:t,dialogOpen:!t}})}let A=(0,J.useCallback)(e=>C({type:`patch`,patch:{dialogOpen:e}}),[]),j=(0,J.useMemo)(()=>{let t=Oxe(n),r=_(`/api/extensions/${encodeURIComponent(e)}/assets/${t}`);if(!m?.trim())return r;let i=new URL(r);return i.searchParams.set(`token`,m.trim()),i.toString()},[e,n,m]);(0,J.useLayoutEffect)(()=>{if(!w)return;let t=p.current;if(!t)return;f.registerIframe(e,t,b);let n=f.subscribeExtensionEvents(e,e=>{if(e.event!==`ui.resize`||!e.data||typeof e.data!=`object`||e.data===null)return;let t=Number(e.data.height);Number.isFinite(t)&&o===void 0&&C({type:`patch`,patch:{dynamicHeight:Math.min(s,Math.max(c,t))}})});return()=>{n(),f.unregisterIframe(e)}},[w,e,o,s,c,b,f]),(0,J.useEffect)(()=>{if(!w)return;let t=yI(h);f.sendEvent(e,`theme.changed`,t)},[w,e,h,f]);let M=o===void 0?{width:`100%`,height:O,border:`none`}:{width:`100%`,height:o,border:`none`};return w?(0,Z.jsxs)(`div`,{className:`flex flex-1 min-h-0 min-w-0 flex-col`,children:[D?(0,Z.jsxs)(`div`,{className:`mb-2 rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-sm text-fg`,children:[(0,Z.jsx)(`p`,{children:u(`extensionUi.loadFailed`)}),(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:u(`extensionUi.loadFailedConnectionHint`)}),(0,Z.jsx)(`button`,{type:`button`,className:`mt-2 font-medium text-accent underline-offset-2 hover:underline`,onClick:()=>{C({type:`patch`,patch:{loadError:!1,reloadKey:E+1}})},children:u(`extensionUi.retryLoad`)})]}):null,(0,Z.jsx)(`iframe`,{ref:p,className:a,title:v,src:j,style:M,sandbox:Dxe,referrerPolicy:`no-referrer`,onError:()=>C({type:`patch`,patch:{loadError:!0}}),onLoad:()=>{C({type:`patch`,patch:{loadError:!1}});let t=d.getState().language;f.sendInit(e,yI(ve.getState().resolved),t),l!==void 0&&f.sendEvent(e,`widget.data`,l)}},`${e}-${n}-${E}`)]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Sxe,{open:T,onOpenChange:A,extensionId:e,extensionName:g,permissions:b,onConfirm:()=>{yxe(e,b),C({type:`patch`,patch:{allowed:!0}})}}),T?null:(0,Z.jsxs)(`div`,{className:a?`${a} rounded-lg border border-edge border-dashed bg-surface-base p-4 text-sm text-fg-muted`:`rounded-lg border border-edge border-dashed bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,Z.jsx)(`p`,{children:u(`extensionUi.deniedHint`)}),(0,Z.jsx)(`button`,{type:`button`,className:`mt-2 text-sm font-medium text-accent underline-offset-2 hover:underline`,onClick:()=>C({type:`patch`,patch:{dialogOpen:!0}}),children:u(`extensionUi.reviewPermissions`)})]})]})}function kxe(e){let t=(0,Y.c)(8),{extensionId:n,extensionName:r,entrypoint:i,title:a,toolResult:o,maxHeight:s,interactive:c,permissions:l}=e,u=s===void 0?400:s,d;return t[0]!==i||t[1]!==n||t[2]!==r||t[3]!==u||t[4]!==l||t[5]!==a||t[6]!==o?(d=(0,Z.jsx)(`div`,{className:`mt-2 w-full min-w-0 overflow-hidden rounded-xl border border-edge bg-surface-base`,children:(0,Z.jsx)($7,{extensionId:n,extensionName:r,entrypoint:i,permissions:l,title:a,className:`w-full`,minHeight:80,maxHeight:u,initialData:o})}),t[0]=i,t[1]=n,t[2]=r,t[3]=u,t[4]=l,t[5]=a,t[6]=o,t[7]=d):d=t[7],d}function Axe(e){let t=NI();return(0,J.useMemo)(()=>{for(let n of t){let t=n.ui?.contributions?.chatWidgets;if(t){for(let r of t)if(r.match.toolName&&r.match.toolName===e)return{...r,extensionId:n.id}}}return null},[t,e])}var jxe=(0,J.memo)(function(e){let t=(0,Y.c)(2),{active:n}=e;if(n){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Cg,{className:`mt-0.5 size-4 shrink-0 animate-spin text-accent-fg`,"aria-hidden":!0}),t[0]=e):e=t[0],e}let r;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(Bl,{className:`mt-0.5 size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),t[1]=r):r=t[1],r}),e9=(0,J.memo)(function({active:e,roundStartRef:t,frozenMs:n,language:r,className:i}){let[,a]=(0,J.useState)(0);(0,J.useEffect)(()=>{if(!e)return;let t=window.setInterval(()=>a(e=>e+1),500);return()=>window.clearInterval(t)},[e]);let o=t.current,s=e&&o!=null?Math.max(0,Date.now()-o):0,c=e&&o!=null?K7(s,r):n==null?null:K7(n,r);return c?(0,Z.jsx)(`span`,{className:i,children:c}):null});function Mxe({blocks:e,toolLabels:t,stepLabels:n,clusterLabels:r,cardLabels:i,sessionKey:a,isMessageStreaming:o=!1,finalAnswerStarted:s=!1}){let c=d(e=>e.language),l=(0,J.useMemo)(()=>j7(e),[e]),u=l.length,f=l.some(e=>e.type===`thinking`&&e.streaming||e.type===`tool_use`&&e.status===`running`),p=!!o&&!s,m=(0,J.useRef)(null),h=(0,J.useRef)(p),[g,_]=(0,J.useState)(null),[v,y]=(0,J.useState)(null);f&&m.current===null&&(m.current=Date.now()),(0,J.useEffect)(()=>{p&&!h.current?(y(null),_(null)):!p&&h.current&&(m.current!==null&&_(Date.now()-m.current),y(!1)),h.current=p},[p]);let b=v??p,x=(0,J.useMemo)(()=>f?``:Pbe(l,r.done,r.join,c,M7(u,n)),[f,l,c,u,n,r]),S=(0,J.useMemo)(()=>f?Fbe(l,r.ing):null,[f,l,r]);if(u===0)return null;let C={thoughts:n.thoughts,thoughtsStreaming:n.thoughtsStreaming,searchedWeb:n.searchedWeb,readFile:n.readFile,stepDetails:n.stepDetails,runCommand:n.runCommand,listDirectory:n.listDirectory,writeFile:n.writeFile,editFile:n.editFile,openUrl:n.openUrl,fetchUrl:n.fetchUrl,unknownTool:n.unknownTool},w=f?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:S??M7(u,n)}),(0,Z.jsx)(e9,{active:f,roundStartRef:m,frozenMs:null,language:c,className:`ml-1.5 tabular-nums text-fg-muted`})]}):(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:x})}),T=f?null:(0,Z.jsx)(e9,{active:!1,roundStartRef:m,frozenMs:g,language:c,className:`mt-0.5 tabular-nums text-xs text-fg-muted`});return(0,Z.jsxs)(`div`,{className:`my-1 w-full min-w-0 overflow-hidden rounded-xl bg-surface-hover/50 dark:bg-surface-hover/30`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:X(`grid w-full min-w-0 grid-cols-[auto_minmax(0,1fr)_auto_auto] items-start gap-x-2 rounded-t-xl px-3 py-2 text-left`,AX.transition,`hover:bg-surface-hover/80 dark:hover:bg-surface-hover/50`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),onClick:()=>y(e=>!(e??p)),"aria-expanded":b,children:[(0,Z.jsx)(jxe,{active:f}),(0,Z.jsx)(`div`,{className:`min-w-0`,children:(0,Z.jsx)(`span`,{className:`inline-flex max-w-full flex-wrap items-baseline rounded-md bg-accent-soft/70 px-2 py-0.5 text-xs font-medium text-fg dark:bg-accent-soft/40`,children:w})}),(0,Z.jsx)(`span`,{className:`flex items-start justify-end`,children:T}),(0,Z.jsx)(Nl,{className:X(`mt-0.5 size-4 shrink-0 text-fg-muted transition-transform`,b&&`rotate-180`),"aria-hidden":!0})]}),b?(0,Z.jsx)(`div`,{className:`border-t border-edge-subtle/90 px-3 pb-3 pt-2 dark:border-edge-subtle`,children:(0,Z.jsx)(Pxe,{blocks:e,toolLabels:t,stepLabels:C,cardLabels:i,sessionKey:a})}):null]})}function Nxe(e){let t=[];for(let n of e.content??[])(n.type===`thinking`||n.type===`tool_use`)&&t.push(n);return t.length>0?t:[]}function Pxe(e){let t=(0,Y.c)(23),{blocks:n,toolLabels:r,stepLabels:i,cardLabels:a,className:o,sessionKey:s}=e,c,l,u,d;if(t[0]!==n||t[1]!==a||t[2]!==o||t[3]!==s||t[4]!==i||t[5]!==r){d=Symbol.for(`react.early_return_sentinel`);bb0:{let e=j7(n);if(e.length===0){d=null;break bb0}t[10]===o?u=t[11]:(u=X(`min-w-0 overflow-x-hidden`,o),t[10]=o,t[11]=u),c=`ml-1 min-w-0 space-y-3 border-l border-edge-subtle pl-3 dark:border-edge-subtle`;let f;t[12]!==a||t[13]!==s||t[14]!==i||t[15]!==r?(f=(e,t)=>(0,Z.jsx)(Lxe,{block:e,toolLabels:r,stepLabels:i,cardLabels:a,sessionKey:s},e.type===`tool_use`?e.id:`thinking-${t}`),t[12]=a,t[13]=s,t[14]=i,t[15]=r,t[16]=f):f=t[16],l=e.map(f)}t[0]=n,t[1]=a,t[2]=o,t[3]=s,t[4]=i,t[5]=r,t[6]=c,t[7]=l,t[8]=u,t[9]=d}else c=t[6],l=t[7],u=t[8],d=t[9];if(d!==Symbol.for(`react.early_return_sentinel`))return d;let f;t[17]!==c||t[18]!==l?(f=(0,Z.jsx)(`div`,{className:c,children:l}),t[17]=c,t[18]=l,t[19]=f):f=t[19];let p;return t[20]!==u||t[21]!==f?(p=(0,Z.jsx)(`div`,{className:u,children:f}),t[20]=u,t[21]=f,t[22]=p):p=t[22],p}function Fxe(e){let t=(0,Y.c)(15),{toolName:n,toolResult:r}=e,i=NI(),a=Axe(n);if(!a||i.length===0)return null;let o;if(t[0]!==i||t[1]!==a.extensionId){let e;t[3]===a.extensionId?e=t[4]:(e=e=>e.id===a.extensionId,t[3]=a.extensionId,t[4]=e),o=i.find(e),t[0]=i,t[1]=a.extensionId,t[2]=o}else o=t[2];let s=o,c=s?.name??a.extensionId,l=a.maxHeight??400,u=a.interactive??!1,d=s?.ui?.permissions,f;return t[5]!==c||t[6]!==l||t[7]!==u||t[8]!==d||t[9]!==r||t[10]!==a.entrypoint||t[11]!==a.extensionId||t[12]!==a.id||t[13]!==a.title?(f=(0,Z.jsx)(kxe,{extensionId:a.extensionId,extensionName:c,widgetId:a.id,entrypoint:a.entrypoint,title:a.title,toolResult:r,maxHeight:l,interactive:u,permissions:d}),t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=r,t[10]=a.entrypoint,t[11]=a.extensionId,t[12]=a.id,t[13]=a.title,t[14]=f):f=t[14],f}var Ixe=new Set([`readFile`,`editFile`,`writeFile`,`runCommand`,`fetchUrl`]);function Lxe(e){let t=(0,Y.c)(106),{block:n,toolLabels:r,stepLabels:i,cardLabels:a,sessionKey:o}=e,s=G7(Rxe),c;bb0:{if(n.type!==`tool_use`){c=``;break bb0}if(n.status===`running`){c=``;break bb0}let e=n.result;if(e==null){c=``;break bb0}if(typeof e==`string`){let n;t[0]===e?n=t[1]:(n=e.trim(),t[0]=e,t[1]=n),c=n;break bb0}try{let n;t[2]===e?n=t[3]:(n=JSON.stringify(e,null,2),t[2]=e,t[3]=n),c=n}catch{c=String(e)}}let l=c,u;bb1:{if(n.type!==`tool_use`||n.status===`running`||n.status===`error`){let e;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[4]=e):e=t[4],u=e;break bb1}if(!d7.has(n.name)){let e;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[5]=e):e=t[5],u=e;break bb1}if(!l){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[6]=e):e=t[6],u=e;break bb1}let e;t[7]===l?e=t[8]:(e=u7(l),t[7]=l,t[8]=e),u=e}let d=u,f;bb2:{if(n.type!==`tool_use`||n.status===`running`||n.status===`error`){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[9]=e):e=t[9],f=e;break bb2}if(!w7(n.name)||!l){let e;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[10]=e):e=t[10],f=e;break bb2}let e;t[11]===l?e=t[12]:(e=Cbe(l),t[11]=l,t[12]=e),f=e}let p=f,m;bb3:{if(n.type!==`tool_use`||n.status===`running`){m=null;break bb3}if(n.name!==`browser_use`){m=null;break bb3}let e;t[13]===l?e=t[14]:(e=txe(l),t[13]=l,t[14]=e),m=e}let h=m;if(n.type===`thinking`){let e=!!n.streaming,r;t[15]===n.text?r=t[16]:(r=n.text?.trim()??``,t[15]=n.text,t[16]=r);let a=r;if(!a&&!e)return null;let o;t[17]===e?o=t[18]:(o=(0,Z.jsx)(`div`,{className:`mt-0.5 shrink-0`,children:e?(0,Z.jsx)(Cg,{className:`size-4 animate-spin text-fg-muted`,"aria-hidden":!0}):(0,Z.jsx)(Bl,{className:`size-4 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0})}),t[17]=e,t[18]=o);let s=e?i.thoughtsStreaming:i.thoughts,c;t[19]===s?c=t[20]:(c=(0,Z.jsx)(`span`,{className:`inline-flex max-w-full min-w-0 break-words rounded-md bg-accent-soft/60 px-1.5 py-0.5 text-xs font-medium text-fg [overflow-wrap:anywhere] dark:bg-accent-soft/35`,children:s}),t[19]=s,t[20]=c);let l;t[21]!==e||t[22]!==a?(l=a?(0,Z.jsx)(`p`,{className:`line-clamp-4 whitespace-pre-wrap break-words text-xs leading-relaxed text-fg-muted [overflow-wrap:anywhere]`,children:a}):e?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`…`}):null,t[21]=e,t[22]=a,t[23]=l):l=t[23];let u;t[24]!==c||t[25]!==l?(u=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[c,l]}),t[24]=c,t[25]=l,t[26]=u):u=t[26];let d;return t[27]!==u||t[28]!==o?(d=(0,Z.jsxs)(`div`,{className:`flex min-w-0 gap-2.5`,children:[o,u]}),t[27]=u,t[28]=o,t[29]=d):d=t[29],d}let g=n.status===`running`,_=n.status===`error`,v=l??``;if(v)try{let e;t[30]===v?e=t[31]:(e=JSON.stringify(JSON.parse(v),null,2),t[30]=v,t[31]=e),v=e}catch{}let y,b;t[32]===n.name?(y=t[33],b=t[34]):(y=D7(n.name),b=Ixe.has(y),t[32]=n.name,t[33]=y,t[34]=b);let x=b,S;t[35]!==n.name||t[36]!==i.editFile||t[37]!==i.fetchUrl||t[38]!==i.listDirectory||t[39]!==i.openUrl||t[40]!==i.readFile||t[41]!==i.runCommand||t[42]!==i.searchedWeb||t[43]!==i.unknownTool||t[44]!==i.writeFile?(S=ybe(n.name,{searchedWeb:i.searchedWeb,readFile:i.readFile,runCommand:i.runCommand,listDirectory:i.listDirectory,writeFile:i.writeFile,editFile:i.editFile,openUrl:i.openUrl,fetchUrl:i.fetchUrl,unknownTool:i.unknownTool}),t[35]=n.name,t[36]=i.editFile,t[37]=i.fetchUrl,t[38]=i.listDirectory,t[39]=i.openUrl,t[40]=i.readFile,t[41]=i.runCommand,t[42]=i.searchedWeb,t[43]=i.unknownTool,t[44]=i.writeFile,t[45]=S):S=t[45];let C=S,w;t[46]===n.input?w=t[47]:(w=C7(n.input),t[46]=n.input,t[47]=w);let T=w,E;t[48]===n.input?E=t[49]:(E=n.input===void 0?``:bbe(n.input),t[48]=n.input,t[49]=E);let D=E,O;t[50]!==n||t[51]!==a||t[52]!==x||t[53]!==y?(O=x?y===`readFile`?(0,Z.jsx)(Wbe,{block:n,labels:a}):y===`editFile`?(0,Z.jsx)(qbe,{block:n,labels:a}):y===`writeFile`?(0,Z.jsx)(Ybe,{block:n,labels:a}):y===`runCommand`?(0,Z.jsx)(Zbe,{block:n,labels:a}):y===`fetchUrl`?(0,Z.jsx)(Qbe,{block:n,labels:a}):null:null,t[50]=n,t[51]=a,t[52]=x,t[53]=y,t[54]=O):O=t[54];let k=O,A=!g&&(s||!x&&!h),j;t[55]!==_||t[56]!==g?(j=(0,Z.jsx)(`div`,{className:`mt-0.5 shrink-0`,children:g?(0,Z.jsx)(Cg,{className:`size-4 animate-spin text-fg-muted`,"aria-hidden":!0}):_?(0,Z.jsx)(ql,{className:`size-4 text-red-600 dark:text-red-400`,"aria-hidden":!0}):(0,Z.jsx)(Bl,{className:`size-4 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0})}),t[55]=_,t[56]=g,t[57]=j):j=t[57];let M;t[58]===C?M=t[59]:(M=(0,Z.jsx)(`span`,{className:`inline-flex max-w-full min-w-0 break-words rounded-md bg-accent-soft/60 px-1.5 py-0.5 text-xs font-medium text-fg [overflow-wrap:anywhere] dark:bg-accent-soft/35`,children:C}),t[58]=C,t[59]=M);let N;t[60]!==_||t[61]!==g?(N=g?(0,Z.jsx)(`span`,{className:`text-xs text-fg-disabled`,children:`running…`}):_?(0,Z.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:`error`}):null,t[60]=_,t[61]=g,t[62]=N):N=t[62];let P;t[63]!==M||t[64]!==N?(P=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,children:[M,N]}),t[63]=M,t[64]=N,t[65]=P):P=t[65];let F;t[66]!==T||t[67]!==x?(F=!x&&T?(0,Z.jsx)(`p`,{className:`min-w-0 rounded-md bg-accent-soft/40 px-1.5 py-1 text-xs break-words text-fg-muted [overflow-wrap:anywhere] dark:bg-accent-soft/25`,children:T}):null,t[66]=T,t[67]=x,t[68]=F):F=t[68];let I;t[69]!==a||t[70]!==x||t[71]!==v||t[72]!==D||t[73]!==A||t[74]!==i.stepDetails||t[75]!==r?(I=A?(0,Z.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer select-none text-fg-subtle underline-offset-2 hover:text-fg-muted group-open:text-fg-muted`,children:x?a.rawDetails:i.stepDetails}),(0,Z.jsxs)(`div`,{className:`mt-2 max-h-48 w-full min-w-0 max-w-full overflow-y-auto overflow-x-hidden rounded-md bg-surface-hover/60 p-2 font-mono dark:bg-surface-hover/35`,children:[D?(0,Z.jsxs)(`div`,{className:`mb-2 min-w-0`,children:[(0,Z.jsx)(`div`,{className:`mb-0.5 text-[10px] uppercase tracking-wide text-fg-disabled`,children:r.input}),(0,Z.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-fg-muted [overflow-wrap:anywhere]`,children:D})]}):null,(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`mb-0.5 text-[10px] uppercase tracking-wide text-fg-disabled`,children:r.output}),(0,Z.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-fg-muted [overflow-wrap:anywhere]`,children:v||r.noOutput})]})]})]}):null,t[69]=a,t[70]=x,t[71]=v,t[72]=D,t[73]=A,t[74]=i.stepDetails,t[75]=r,t[76]=I):I=t[76];let L;t[77]!==n.name||t[78]!==n.result||t[79]!==_||t[80]!==g?(L=!g&&!_?(0,Z.jsx)(Fxe,{toolName:n.name,toolResult:n.result}):null,t[77]=n.name,t[78]=n.result,t[79]=_,t[80]=g,t[81]=L):L=t[81];let R;t[82]!==_||t[83]!==g||t[84]!==p?(R=!g&&!_&&p.length>0?(0,Z.jsx)(wbe,{links:p}):null,t[82]=_,t[83]=g,t[84]=p,t[85]=R):R=t[85];let z;t[86]!==d||t[87]!==_||t[88]!==g||t[89]!==o?(z=!g&&!_&&d.length>0?(0,Z.jsx)(J7,{paths:d,sessionKey:o}):null,t[86]=d,t[87]=_,t[88]=g,t[89]=o,t[90]=z):z=t[90];let B;t[91]!==h||t[92]!==g?(B=!g&&h?(0,Z.jsx)(rxe,{payload:h}):null,t[91]=h,t[92]=g,t[93]=B):B=t[93];let V;t[94]!==k||t[95]!==P||t[96]!==F||t[97]!==I||t[98]!==L||t[99]!==R||t[100]!==z||t[101]!==B?(V=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1.5`,children:[P,k,F,I,L,R,z,B]}),t[94]=k,t[95]=P,t[96]=F,t[97]=I,t[98]=L,t[99]=R,t[100]=z,t[101]=B,t[102]=V):V=t[102];let H;return t[103]!==j||t[104]!==V?(H=(0,Z.jsxs)(`div`,{className:`flex min-w-0 gap-2.5`,children:[j,V]}),t[103]=j,t[104]=V,t[105]=H):H=t[105],H}function Rxe(e){return e.showRawToolData}function zxe(e,t){switch(e){case`pdf`:return t.attachmentPreviewPdf;case`docx`:return t.attachmentPreviewDocument;case`pptx`:return t.attachmentPreviewPresentation;case`excel`:return t.attachmentPreviewSpreadsheet;default:return``}}function t9(e){let t=(0,Y.c)(65),{open:n,attachment:r,authToken:i,sessionKey:a,onClose:o}=e,s=d(Bxe),c=m(s).chat,l;t[0]!==r||t[1]!==i||t[2]!==s||t[3]!==n||t[4]!==a?(l={open:n,attachment:r,authToken:i,sessionKey:a,language:s},t[0]=r,t[1]=i,t[2]=s,t[3]=n,t[4]=a,t[5]=l):l=t[5];let u=OU(l),{rootRef:f,active:p,enter:h,exit:g}=oU(),{preview:_,fileType:v,hasExtractedText:y,showExtractedText:b}=u,x=v!==`image`&&v!==`text`&&v!==`pptx`&&y,S=!!(_&&!u.loading&&!u.loadError),C;t[6]!==g||t[7]!==o?(C=()=>{g(),o()},t[6]=g,t[7]=o,t[8]=C):C=t[8];let w=C,T;t[9]===_?T=t[10]:(T=()=>{if(!_)return;let e=DL(_);if(!e)return;let t=atob(e),n=Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);let r=new Uint8Array(n),i=new Blob([r],{type:_.mimeType||`application/octet-stream`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=_.name??`download`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a)},t[9]=_,t[10]=T);let E=T,D;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(D=X(`min-h-0 min-w-0 flex-1 cursor-pointer border-0 p-0`,`bg-surface-base transition-colors`,`hover:bg-surface-hover/90 dark:bg-black/60 dark:hover:bg-black/70`,AX.focusRingBase),t[11]=D):D=t[11];let O=D,k;t[12]===w?k=t[13]:(k=e=>!e&&w(),t[12]=w,t[13]=k);let A;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(A=X(`xopc-dialog-content-fullscreen fixed inset-0 z-[81] flex h-[100dvh] w-full flex-row overflow-hidden`,`border-0 bg-transparent p-0 shadow-none outline-none`),t[14]=A):A=t[14];let j;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(j=X(`flex h-full min-h-0 w-[min(100%,var(--max-width-app-main))] shrink-0 flex-col overflow-hidden`,`bg-surface-panel sm:border-x sm:border-edge dark:sm:border-edge`,`shadow-float dark:shadow-elevated`),t[15]=j):j=t[15];let M=_?.name??``,N;t[16]===M?N=t[17]:(N=(0,Z.jsx)(ue,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-fg`,children:M}),t[16]=M,t[17]=N);let P=x?(0,Z.jsxs)(`div`,{className:`mr-2 flex rounded-lg border border-edge p-0.5 dark:border-edge`,role:`group`,"aria-label":c.attachmentPreviewText,children:[(0,Z.jsx)(`button`,{type:`button`,className:`rounded-md px-2.5 py-1 text-xs font-medium ${b?`text-fg-muted hover:text-fg`:`bg-surface-hover text-fg`}`,onClick:()=>{u.setShowExtractedText(!1),u.clearLoadError()},children:zxe(v,c)}),(0,Z.jsx)(`button`,{type:`button`,className:`rounded-md px-2.5 py-1 text-xs font-medium ${b?`bg-surface-hover text-fg`:`text-fg-muted hover:text-fg`}`,onClick:()=>{u.setShowExtractedText(!0),u.clearLoadError()},children:c.attachmentPreviewText})]}):null,F;t[18]!==p||t[19]!==S||t[20]!==h||t[21]!==g||t[22]!==c.attachmentPreviewExitFullscreen||t[23]!==c.attachmentPreviewFullscreen?(F=S?(0,Z.jsx)(`button`,{type:`button`,className:`rounded-md p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,title:p?c.attachmentPreviewExitFullscreen:c.attachmentPreviewFullscreen,"aria-label":p?c.attachmentPreviewExitFullscreen:c.attachmentPreviewFullscreen,onClick:()=>void(p?g():h()),children:p?(0,Z.jsx)(Ng,{className:`size-4`}):(0,Z.jsx)(Dg,{className:`size-4`})}):null,t[18]=p,t[19]=S,t[20]=h,t[21]=g,t[22]=c.attachmentPreviewExitFullscreen,t[23]=c.attachmentPreviewFullscreen,t[24]=F):F=t[24];let I;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(Uu,{className:`size-4`}),t[25]=I):I=t[25];let L;t[26]!==E||t[27]!==c.attachmentPreviewDownload?(L=(0,Z.jsx)(`button`,{type:`button`,className:`rounded-md p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,title:c.attachmentPreviewDownload,"aria-label":c.attachmentPreviewDownload,onClick:E,children:I}),t[26]=E,t[27]=c.attachmentPreviewDownload,t[28]=L):L=t[28];let R;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,Z.jsx)(oO,{className:`size-4`}),t[29]=R):R=t[29];let z;t[30]===c.attachmentPreviewClose?z=t[31]:(z=(0,Z.jsx)(de,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`rounded-md p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,title:c.attachmentPreviewClose,"aria-label":c.attachmentPreviewClose,children:R})}),t[30]=c.attachmentPreviewClose,t[31]=z);let B;t[32]!==P||t[33]!==F||t[34]!==L||t[35]!==z?(B=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[P,F,L,z]}),t[32]=P,t[33]=F,t[34]=L,t[35]=z,t[36]=B):B=t[36];let V;t[37]!==N||t[38]!==B?(V=(0,Z.jsx)(`div`,{className:`shrink-0 border-b border-edge bg-surface-panel dark:border-edge`,children:(0,Z.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-2 px-4 py-3 sm:px-8`,children:[N,B]})}),t[37]=N,t[38]=B,t[39]=V):V=t[39];let H;t[40]!==E||t[41]!==s||t[42]!==_||t[43]!==u.binaryBuffer||t[44]!==u.extractedText||t[45]!==u.extractedTextTruncated||t[46]!==u.fileKey||t[47]!==u.fileName||t[48]!==u.loadError||t[49]!==u.loading||t[50]!==u.previewKind||t[51]!==u.showExtractedText||t[52]!==u.textContent?(H=_?(0,Z.jsx)(RX,{context:`attachment`,language:s,fileKey:u.fileKey,fileName:u.fileName,loading:u.loading,loadError:u.loadError,previewKind:u.previewKind,textContent:u.textContent,binaryBuffer:u.binaryBuffer,showExtractedText:u.showExtractedText,extractedText:u.extractedText,extractedTextTruncated:u.extractedTextTruncated,actions:{onDownload:E,canDownload:!!DL(_)}}):null,t[40]=E,t[41]=s,t[42]=_,t[43]=u.binaryBuffer,t[44]=u.extractedText,t[45]=u.extractedTextTruncated,t[46]=u.fileKey,t[47]=u.fileName,t[48]=u.loadError,t[49]=u.loading,t[50]=u.previewKind,t[51]=u.showExtractedText,t[52]=u.textContent,t[53]=H):H=t[53];let U;t[54]===H?U=t[55]:(U=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-4 pb-4 pt-2 sm:px-8`,children:H}),t[54]=H,t[55]=U);let W;t[56]!==f||t[57]!==V||t[58]!==U||t[59]!==j?(W=(0,Z.jsxs)(`div`,{ref:f,className:j,children:[V,U]}),t[56]=f,t[57]=V,t[58]=U,t[59]=j,t[60]=W):W=t[60];let ee;return t[61]!==w||t[62]!==c.attachmentPreviewClose||t[63]!==O?(ee=(0,Z.jsx)(`button`,{type:`button`,className:O,onClick:w,"aria-label":c.attachmentPreviewClose}),t[61]=w,t[62]=c.attachmentPreviewClose,t[63]=O,t[64]=ee):ee=t[64],(0,Z.jsx)(q,{open:n,onOpenChange:k,children:(0,Z.jsx)(G,{children:(0,Z.jsxs)(se,{className:A,children:[(0,Z.jsx)(`button`,{type:`button`,className:O,onClick:w,"aria-label":c.attachmentPreviewClose}),W,ee]})})})}function Bxe(e){return e.language}function n9(e){let t=(0,Y.c)(45),{attachment:n,authToken:r,sessionKey:i,showDelete:a,onDelete:o,onOpen:s}=e,c=a===void 0?!1:a,l=d(Vxe),u;t[0]===l?u=t[1]:(u=m(l),t[0]=l,t[1]=u);let f=u,p=(0,J.useId)(),[h,g]=(0,J.useState)(null),_=h?.src===n?h.data:n,v;t[2]===n?v=t[3]:(v=!!n.workspaceRelativePath&&!DL(n),t[2]=n,t[3]=v);let y=v,b;t[4]!==r||t[5]!==y?(b=y&&!String(r??``).trim(),t[4]=r,t[5]=y,t[6]=b):b=t[6];let x=b,S,C;t[7]!==n||t[8]!==r||t[9]!==i?(S=()=>{let e=n;if(!e?.workspaceRelativePath||DL(e)||!String(r??``).trim())return;let t=!1;return(async()=>{let n=await nU({workspaceRelativePath:e.workspaceRelativePath,sessionKey:i});if(!n.ok||t)return;let r=n.base64,a=e.mimeType?.startsWith(`image/`)||e.type===`image`;g({src:e,data:{...e,content:r,data:r,preview:a?r:e.preview,type:a?`image`:`document`}})})(),()=>{t=!0}},C=[n,r,i],t[7]=n,t[8]=r,t[9]=i,t[10]=S,t[11]=C):(S=t[10],C=t[11]),(0,J.useEffect)(S,C);let w;t[12]===_?w=t[13]:(w=_.preview??DL(_),t[12]=_,t[13]=w);let T=w,E;t[14]!==_.mimeType||t[15]!==_.type?(E=_.mimeType?.startsWith(`image/`)||_.type===`image`,t[14]=_.mimeType,t[15]=_.type,t[16]=E):E=t[16];let D=E,O=_.mimeType===`application/pdf`,k;t[17]!==_.mimeType||t[18]!==_.name?(k=_.mimeType?.includes(`spreadsheetml`)||_.name?.toLowerCase().endsWith(`.xlsx`)||_.name?.toLowerCase().endsWith(`.xls`),t[17]=_.mimeType,t[18]=_.name,t[19]=k):k=t[19];let A=k,j=_.name??`file`,M;t[20]===_.mimeType?M=t[21]:(M=_.mimeType?.startsWith(`image/`)?_.mimeType:`image/png`,t[20]=_.mimeType,t[21]=M);let N=M,P;t[22]!==N||t[23]!==D||t[24]!==T?(P=T&&D?jL(N,T):``,t[22]=N,t[23]=D,t[24]=T,t[25]=P):P=t[25];let F=P,I=!!F,L=x?`${j} — ${f.chat.attachmentPreviewMissingAuth}`:j,R=f.chat.attachmentPreviewMissingAuth,z;t[26]!==j||t[27]!==_||t[28]!==A||t[29]!==O||t[30]!==L||t[31]!==p||t[32]!==R||t[33]!==s||t[34]!==I||t[35]!==x||t[36]!==F?(z=I?(0,Z.jsxs)(`div`,{className:`max-w-[10rem]`,children:[(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(`button`,{type:`button`,className:X(`block w-full overflow-hidden rounded-md border border-edge dark:border-edge`,AX.transition,AX.press,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),onClick:()=>s(_),title:L,"aria-label":L,"aria-describedby":x?p:void 0,children:(0,Z.jsx)(`img`,{src:F,alt:j,className:`max-h-16 w-full object-cover`})}),O?(0,Z.jsx)(`div`,{className:`pointer-events-none absolute bottom-1 right-1 rounded bg-black/60 px-1.5 py-0.5 text-[10px] font-semibold text-white`,"aria-hidden":!0,children:`PDF`}):null]}),x?(0,Z.jsx)(`p`,{id:p,className:`mt-1 line-clamp-2 text-[10px] leading-snug text-amber-600 dark:text-amber-500`,children:R}):null]}):(0,Z.jsx)(`div`,{className:`max-w-[14rem]`,children:(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>s(_),title:L,"aria-label":L,"aria-describedby":x?p:void 0,className:X(`flex w-full min-w-0 gap-2 rounded-md border border-edge bg-surface-hover px-2 py-1.5 text-left text-xs text-fg-muted hover:bg-surface-active dark:border-edge`,x?`items-start`:`items-center`,AX.transition,AX.press,AX.focusRingPanel),children:[A?(0,Z.jsx)(_f,{className:`size-8 shrink-0 text-fg-subtle`,"aria-hidden":!0}):(0,Z.jsx)(xf,{className:`size-8 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`block truncate text-fg`,children:j}),x?(0,Z.jsx)(`span`,{id:p,className:`mt-0.5 line-clamp-2 block text-[10px] font-normal leading-snug text-amber-600 dark:text-amber-500`,children:R}):null]})]})}),t[26]=j,t[27]=_,t[28]=A,t[29]=O,t[30]=L,t[31]=p,t[32]=R,t[33]=s,t[34]=I,t[35]=x,t[36]=F,t[37]=z):z=t[37];let B;t[38]!==f.chat.attachmentPreviewRemove||t[39]!==o||t[40]!==c?(B=c?(0,Z.jsx)(`button`,{type:`button`,className:X(`absolute -right-1 -top-1 flex size-5 items-center justify-center rounded-full border border-edge bg-surface-panel text-fg-muted shadow-surface hover:text-fg dark:border-edge`,AX.transition,AX.press,AX.focusRingPanel),onClick:e=>{e.stopPropagation(),o?.()},title:f.chat.attachmentPreviewRemove,"aria-label":f.chat.attachmentPreviewRemove,children:(0,Z.jsx)(oO,{className:`size-3`})}):null,t[38]=f.chat.attachmentPreviewRemove,t[39]=o,t[40]=c,t[41]=B):B=t[41];let V;return t[42]!==z||t[43]!==B?(V=(0,Z.jsxs)(`div`,{className:`group relative inline-block`,children:[z,B]}),t[42]=z,t[43]=B,t[44]=V):V=t[44],V}function Vxe(e){return e.language}function Hxe(e){return typeof e==`number`&&Number.isFinite(e)&&e>0&&e!==1/0}function r9(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e%60);return`${Math.floor(e/60)}:${t.toString().padStart(2,`0`)}`}function Uxe(e){return e.type===`voice`||e.type===`audio`||e.mimeType?.startsWith(`audio/`)===!0}function Wxe({att:e,align:t=`start`,variant:n=`default`,sessionKey:r}){let i=m(d(e=>e.language)),a=(0,J.useRef)(null),[o,s]=(0,J.useState)(),[c,l]=(0,J.useState)(!1),u=(0,J.useMemo)(()=>{let t=e.durationSeconds;return typeof t==`number`&&Number.isFinite(t)&&t>0?t:0},[e.durationSeconds]),[f,p]=(0,J.useState)(u),h=(0,J.useRef)(u);h.current!==u&&(h.current=u,p(u));let[g,v]=(0,J.useState)(0),y=(0,J.useCallback)(()=>{let e=a.current;if(!e)return;let t=e.duration;Hxe(t)&&p(t)},[]),b=`${e.workspaceRelativePath??``}:${e.content?.length??0}:${e.mimeType??``}:${r??``}`,x=(0,J.useRef)(b);x.current!==b&&(x.current=b,v(0),l(!1)),(0,J.useEffect)(()=>{let t,n=!1;return(async()=>{let i=e.content??e.data;if(i){s(`data:${e.mimeType?.includes(`/`)?e.mimeType:`audio/mpeg`};base64,${i.replace(/\s/g,``)}`);return}if(e.workspaceRelativePath)try{let i=await Ee(_(EL(e.workspaceRelativePath,{sessionKey:r})));if(!i.ok||n)return;let a=await i.blob(),o=URL.createObjectURL(a);t=o,s(o)}catch{}})(),()=>{n=!0,t&&URL.revokeObjectURL(t)}},[e,r]);let S=(0,J.useCallback)(()=>{let e=a.current;!e||!o||(c?e.pause():e.play().catch(()=>{}))},[c,o]);if(!Uxe(e))return null;let C=f>0?Math.min(100,Number.isFinite(f)?g/f*100:0):0,w=typeof f==`number`&&f>0&&Number.isFinite(f),T=!!(o&&!w),E=o?(0,Z.jsxs)(`span`,{className:`tabular-nums tracking-tight text-fg-muted`,"aria-live":`polite`,children:[(0,Z.jsx)(`span`,{children:r9(g)}),(0,Z.jsx)(`span`,{className:`mx-0.5 text-fg-subtle`,children:`/`}),w?(0,Z.jsx)(`span`,{children:r9(f)}):(0,Z.jsx)(`span`,{className:`text-fg-subtle`,title:i.chat.voiceAwaitingMeta,children:`—`})]}):(0,Z.jsx)(`span`,{className:`tabular-nums tracking-tight text-fg-subtle`,children:`— / —`}),D=o?(0,Z.jsx)(`audio`,{ref:a,src:o,preload:`metadata`,className:`hidden`,onLoadedMetadata:y,onLoadedData:y,onDurationChange:y,onTimeUpdate:e=>v(e.currentTarget.currentTime),onPlay:()=>l(!0),onPause:()=>l(!1),onEnded:()=>{l(!1),v(0)}}):(0,Z.jsx)(`span`,{className:`sr-only`,children:i.chat.voiceLoading}),O=(0,Z.jsx)(`button`,{type:`button`,onClick:S,disabled:!o,className:X(`flex size-8 shrink-0 items-center justify-center rounded-full border text-accent-fg`,`border-edge-subtle bg-surface-panel transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`motion-safe:active:scale-[0.97]`,`dark:bg-surface-panel/90 dark:border-edge`,n===`compact`&&X(`border-white/55 bg-white/92 shadow-[inset_0_1px_0_rgb(255_255_255/0.65)]`,`dark:border-white/14 dark:bg-surface-hover/98 dark:shadow-none`),!o&&`opacity-50`),"aria-label":c?i.chat.voicePause:i.chat.voicePlay,title:c?i.chat.voicePause:i.chat.voicePlay,children:c?(0,Z.jsx)(j_,{className:`size-[14px]`,strokeWidth:2}):(0,Z.jsx)(vv,{className:`size-[14px] ml-px`,strokeWidth:2})}),k=X(`relative h-0.5 min-h-[2px] w-full overflow-hidden rounded-full bg-edge-subtle dark:bg-edge/65`,n===`compact`&&`bg-white/45 dark:bg-white/14`),A=X(`inline-flex min-w-0 items-center rounded-full border`,n===`compact`?`max-w-[min(220px,88vw)] gap-2 px-2 py-1.5 backdrop-blur-[2px]`:`min-w-[min(160px,80vw)] max-w-[17rem] gap-2 px-2 py-1.5`,n===`compact`?`border-white/58 bg-white/86 shadow-none dark:border-white/13 dark:bg-black/[0.22] dark:backdrop-blur-sm`:`border-edge-subtle bg-surface-panel/[0.96] shadow-surface dark:border-edge dark:bg-surface-panel/92`),j=`${i.chat.voiceAriaRegion}${e.name?` · ${e.name}`:``}`;return(0,Z.jsx)(`div`,{className:X(`flex min-w-0`,t===`end`&&`justify-end`,t===`center`&&`justify-center`),children:(0,Z.jsxs)(`div`,{role:`group`,"aria-label":j,className:A,children:[O,(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col justify-center gap-1 py-px`,children:[n===`default`?(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[11px] leading-snug tracking-tight text-fg-muted`,children:[(0,Z.jsx)(Mg,{className:`size-3 shrink-0 opacity-90 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate font-normal`,children:i.chat.voiceMessage})]}):(0,Z.jsx)(`span`,{className:`sr-only`,children:i.chat.voiceMessage}),(0,Z.jsx)(`div`,{className:k,"aria-hidden":!0,children:o?T?(0,Z.jsx)(`span`,{className:X(`absolute inset-y-0 left-[18%] w-[42%] max-w-[4.5rem] rounded-full bg-accent/45 motion-safe:animate-pulse`)}):(0,Z.jsx)(`div`,{className:X(`h-full rounded-full bg-accent motion-safe:transition-[width] motion-safe:duration-150 motion-safe:ease-linear`),style:{width:`${C}%`}}):null}),(0,Z.jsx)(`div`,{className:X(`flex justify-end text-[10px] leading-snug tracking-tight text-fg-muted`),children:E})]}),D]})})}function i9(e){return e.type===`voice`||e.type===`audio`||e.mimeType?.startsWith(`audio/`)===!0}function a9(e){let t=(0,Y.c)(23),{attachments:n,authToken:r,sessionKey:i,layout:a,centerUserVoiceRow:o}=e,s=a===void 0?`assistant`:a,c=o===void 0?!1:o,[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(null);if(!n?.length)return null;let p,m,h,g;if(t[0]!==n||t[1]!==r||t[2]!==c||t[3]!==s||t[4]!==i){let e=n.filter(Kxe),a=n.filter(i9),o=n.filter(Gxe);p=`flex flex-col gap-2`,m=e.length>0?(0,Z.jsx)(`div`,{className:X(`grid w-full max-w-40 gap-1`,e.length===1&&`grid-cols-1`,e.length===2&&`grid-cols-2`,e.length>=3&&`grid-cols-2 sm:grid-cols-3`),children:e.map((e,t)=>(0,Z.jsx)(n9,{attachment:e,authToken:r,sessionKey:i,onOpen:e=>{f(e),u(!0)}},e.id??`${e.name}-${t}`))}):null,h=a.length>0?(0,Z.jsx)(`div`,{className:X(`flex flex-col gap-2`,s===`user`&&(c?`items-center`:`items-end`)),children:a.map((e,t)=>(0,Z.jsx)(Wxe,{att:e,sessionKey:i,align:s===`user`?c?`center`:`end`:`start`,variant:s===`user`?`compact`:`default`},e.id??`${e.name}-${t}`))}):null,g=o.length>0?(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:o.map((e,t)=>(0,Z.jsx)(n9,{attachment:e,authToken:r,sessionKey:i,onOpen:e=>{f(e),u(!0)}},e.id??`${e.name}-${t}`))}):null,t[0]=n,t[1]=r,t[2]=c,t[3]=s,t[4]=i,t[5]=p,t[6]=m,t[7]=h,t[8]=g}else p=t[5],m=t[6],h=t[7],g=t[8];let _;t[9]!==p||t[10]!==m||t[11]!==h||t[12]!==g?(_=(0,Z.jsxs)(`div`,{className:p,children:[m,h,g]}),t[9]=p,t[10]=m,t[11]=h,t[12]=g,t[13]=_):_=t[13];let v;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(v=()=>{u(!1),f(null)},t[14]=v):v=t[14];let y;t[15]!==d||t[16]!==r||t[17]!==l||t[18]!==i?(y=(0,Z.jsx)(t9,{open:l,attachment:d,authToken:r,sessionKey:i,onClose:v}),t[15]=d,t[16]=r,t[17]=l,t[18]=i,t[19]=y):y=t[19];let b;return t[20]!==_||t[21]!==y?(b=(0,Z.jsxs)(Z.Fragment,{children:[_,y]}),t[20]=_,t[21]=y,t[22]=b):b=t[22],b}function Gxe(e){return e.type!==`image`&&!e.mimeType?.startsWith(`image/`)&&!i9(e)}function Kxe(e){return e.type===`image`||e.mimeType?.startsWith(`image/`)}function qxe(e){let t=[];for(let n of e)if(!(!n.name.toLowerCase().includes(`search`)||n.result==null))try{let e=typeof n.result==`string`?JSON.parse(n.result):n.result,r=Array.isArray(e)?e:e?.results??[];for(let e of r)e.url&&t.push({url:e.url,title:e.title??e.url,snippet:e.snippet})}catch{}return t}function Jxe(e){let t=(0,Y.c)(16),{blocks:n}=e,r=d(Zxe),i,a,o,s,c;if(t[0]!==n||t[1]!==r){c=Symbol.for(`react.early_return_sentinel`);bb0:{let e=m(r),l=qxe(n.filter(Xxe));if(l.length===0){c=null;break bb0}o=`mt-6`;let u=e.chat.searchSourcesHeading.replace(`{{count}}`,String(l.length));t[7]===u?s=t[8]:(s=(0,Z.jsx)(`p`,{className:`mb-3 text-xs font-medium text-fg-muted`,children:u}),t[7]=u,t[8]=s),i=`space-y-3`,a=l.map(Yxe)}t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6];if(c!==Symbol.for(`react.early_return_sentinel`))return c;let l;t[9]!==i||t[10]!==a?(l=(0,Z.jsx)(`ol`,{className:i,children:a}),t[9]=i,t[10]=a,t[11]=l):l=t[11];let u;return t[12]!==o||t[13]!==s||t[14]!==l?(u=(0,Z.jsxs)(`div`,{className:o,children:[s,l]}),t[12]=o,t[13]=s,t[14]=l,t[15]=u):u=t[15],u}function Yxe(e,t){let n=(()=>{try{return new URL(e.url).hostname}catch{return``}})(),r=n?`https://www.google.com/s2/favicons?domain=${n}&sz=16`:void 0;return(0,Z.jsxs)(`li`,{className:`flex min-w-0 gap-2.5`,children:[(0,Z.jsxs)(`span`,{className:`mt-0.5 shrink-0 text-xs text-fg-disabled`,children:[t+1,`.`]}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-1.5`,children:[r?(0,Z.jsx)(`img`,{src:r,alt:``,className:`mt-0.5 size-3.5 shrink-0 rounded-sm`,"aria-hidden":!0}):null,(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`min-w-0 flex-1 break-words text-xs font-medium text-accent-fg [overflow-wrap:anywhere] hover:underline`,children:e.title})]}),e.snippet?(0,Z.jsx)(`p`,{className:`mt-0.5 line-clamp-4 text-xs break-words text-fg-muted [overflow-wrap:anywhere]`,children:e.snippet}):null]})]},e.url)}function Xxe(e){return e.type===`tool_use`}function Zxe(e){return e.language}function Qxe(e){let t=[];for(let n of e)n.type===`thinking`||n.type===`tool_use`||(n.type===`text`?t.push(n.text):n.type===`image`&&t.push(`[image]`));return t.join(`
4695
-
4696
- `).trim()}function $xe(e){if(!e.trim())return``;let t=EK.parse(e,{gfm:!0,breaks:!1});return new DOMParser().parseFromString(`<div>${t}</div>`,`text/html`).body.textContent?.trim()??``}function eSe(e){let t=[];for(let n of e)n.type===`thinking`||n.type===`tool_use`||(n.type===`text`?t.push($xe(n.text)):n.type===`image`&&t.push(`[image]`));return t.join(`
4697
-
4698
- `).trim()}function tSe(e){let t=e.replace(/\/$/,``);return`@${t.split(`/`).pop()??t}`}function nSe(e){let t=[],n=(n,r)=>{let i=new RegExp(n.source,n.flags),a;for(;(a=i.exec(e))!==null;)t.push({start:a.index,end:a.index+a[0].length,seg:r(a)})};n(U$(),e=>({kind:`skill`,name:e[1]??``})),n(R8(),e=>({kind:`file`,path:I8(e)}));for(let n of t1(e))t.push({start:n.start,end:n.end,seg:{kind:`command`,name:e.slice(n.start+1,n.end)}});t.sort((e,t)=>e.start===t.start?t.end-e.end:e.start-t.start);let r=[],i=0;for(let n of t)n.start<i||(n.start>i&&r.push({kind:`text`,text:e.slice(i,n.start)}),r.push(n.seg),i=n.end);return i<e.length&&r.push({kind:`text`,text:e.slice(i)}),r.length===0&&r.push({kind:`text`,text:e}),r}function rSe(e){return e.kind===`text`?`t:${e.text}`:e.kind===`skill`?`s:${e.name}`:e.kind===`file`?`f:${e.path}`:`c:${e.name}`}var iSe=(0,J.memo)(function(e){let t=(0,Y.c)(10),{text:n}=e,r;t[0]===n?r=t[1]:(r=nSe(n),t[0]=n,t[1]=r);let i=r,a;if(t[2]!==i){let e=new Map;a=i.map(t=>{let n=rSe(t),r=e.get(n)??0;return e.set(n,r+1),{part:t,key:`${n}#${String(r)}`}}),t[2]=i,t[3]=a}else a=t[3];let o=a;if(!i.some(aSe)){let e;return t[4]===n?e=t[5]:(e=(0,Z.jsx)(`div`,{className:`markdown-content min-w-0`,children:(0,Z.jsx)(OX,{content:n,compact:!0})}),t[4]=n,t[5]=e),e}let s;t[6]===o?s=t[7]:(s=o.map(oSe),t[6]=o,t[7]=s);let c;return t[8]===s?c=t[9]:(c=(0,Z.jsx)(`span`,{className:`inline-flex max-w-full flex-wrap items-baseline gap-x-1.5 gap-y-1 [text-align:inherit]`,children:s}),t[8]=s,t[9]=c),c});function aSe(e){return e.kind!==`text`}function oSe(e){let{part:t,key:n}=e;return t.kind===`skill`?(0,Z.jsxs)(`span`,{className:`chat-skill-pill max-w-full shrink-0`,"data-skill":t.name,children:[`/`,t.name]},n):t.kind===`command`?(0,Z.jsxs)(`span`,{className:`chat-command-pill max-w-full shrink-0`,"data-slash-command":t.name,children:[`/`,t.name]},n):t.kind===`file`?(0,Z.jsx)(`span`,{className:`chat-file-pill max-w-full shrink-0`,"data-file":t.path,children:tSe(t.path)},n):t.text?(0,Z.jsx)(`div`,{className:`markdown-content inline-block min-w-0 max-w-full align-baseline text-fg`,children:(0,Z.jsx)(OX,{content:t.text,compact:!0,breaks:!0})},n):null}var sSe=(0,J.memo)(function(e){let t=(0,Y.c)(37),{name:n,description:r,status:i,doneCount:a,totalCount:o,durationText:s,collapsed:c,onToggleCollapsed:l,actions:u,labels:d}=e,f=o>0?`${a}/${o}`:i===`running`?`…`:`0`,p;t[0]!==f||t[1]!==s||t[2]!==d||t[3]!==i?(p=i===`running`?d.runningMeta(f,s):i===`completed`?d.completedMeta(f,s):d.failedMeta,t[0]=f,t[1]=s,t[2]=d,t[3]=i,t[4]=p):p=t[4];let m=p,h=i===`failed`&&`border-rose-300/40`,g;t[5]===h?g=t[6]:(g=X(`flex min-w-0 items-center gap-2 border-b border-edge-subtle px-3 py-2`,h),t[5]=h,t[6]=g);let _;t[7]===i?_=t[8]:(_=(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-fg-subtle`,children:i===`running`?(0,Z.jsx)(Cg,{className:`size-4 animate-spin text-accent-fg`}):(0,Z.jsx)(Nh,{className:`size-4`})}),t[7]=i,t[8]=_);let v;t[9]===n?v=t[10]:(v=(0,Z.jsx)(`div`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,children:n}),t[9]=n,t[10]=v);let y;t[11]===m?y=t[12]:(y=(0,Z.jsx)(`div`,{className:`shrink-0 text-xs tabular-nums text-fg-subtle`,children:m}),t[11]=m,t[12]=y);let b;t[13]!==v||t[14]!==y?(b=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[v,y]}),t[13]=v,t[14]=y,t[15]=b):b=t[15];let x;t[16]===r?x=t[17]:(x=r?(0,Z.jsx)(`div`,{className:`mt-0.5 line-clamp-1 text-xs text-fg-subtle`,children:r}):null,t[16]=r,t[17]=x);let S;t[18]!==b||t[19]!==x?(S=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[b,x]}),t[18]=b,t[19]=x,t[20]=S):S=t[20];let C;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(C=X(`inline-flex size-7 items-center justify-center rounded-md`,`text-fg-muted hover:bg-surface-hover hover:text-fg`,AX.transition,AX.focusRingPanel),t[21]=C):C=t[21];let w=c?d.expand:d.collapse,T=c?d.expand:d.collapse,E;t[22]===c?E=t[23]:(E=c?(0,Z.jsx)(Nl,{className:`size-4`}):(0,Z.jsx)(Il,{className:`size-4`}),t[22]=c,t[23]=E);let D;t[24]!==l||t[25]!==w||t[26]!==T||t[27]!==E?(D=(0,Z.jsx)(`button`,{type:`button`,onClick:l,className:C,"aria-label":w,title:T,children:E}),t[24]=l,t[25]=w,t[26]=T,t[27]=E,t[28]=D):D=t[28];let O;t[29]!==u||t[30]!==D?(O=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[u,D]}),t[29]=u,t[30]=D,t[31]=O):O=t[31];let k;return t[32]!==O||t[33]!==g||t[34]!==_||t[35]!==S?(k=(0,Z.jsxs)(`div`,{className:g,children:[_,S,O]}),t[32]=O,t[33]=g,t[34]=_,t[35]=S,t[36]=k):k=t[36],k}),cSe={parse_error:(0,Z.jsx)(zg,{className:`size-4 shrink-0 text-rose-600 dark:text-rose-400`,"aria-hidden":!0}),aborted:(0,Z.jsx)(ql,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),timeout:(0,Z.jsx)(xT,{className:`size-4 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),runtime_error:(0,Z.jsx)(QT,{className:`size-4 shrink-0 text-rose-600 dark:text-rose-400`,"aria-hidden":!0})},lSe=(0,J.memo)(function(e){let t=(0,Y.c)(20),{kind:n,reason:r,scriptPreview:i,labels:a,className:o}=e,s=n===`parse_error`?a.titleParse:n===`aborted`?a.titleAbort:n===`timeout`?a.titleTimeout:a.titleRuntime,c;t[0]===o?c=t[1]:(c=X(`min-w-0 rounded-xl border border-edge bg-surface-panel shadow-surface`,`p-3`,o),t[0]=o,t[1]=c);let l=cSe[n],u;t[2]===s?u=t[3]:(u=(0,Z.jsx)(`div`,{className:`text-sm font-semibold tracking-tight text-fg`,children:s}),t[2]=s,t[3]=u);let d;t[4]===r?d=t[5]:(d=r?(0,Z.jsx)(`div`,{className:`mt-1 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:r}):null,t[4]=r,t[5]=d);let f;t[6]!==u||t[7]!==d?(f=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[u,d]}),t[6]=u,t[7]=d,t[8]=f):f=t[8];let p;t[9]!==l||t[10]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[l,f]}),t[9]=l,t[10]=f,t[11]=p):p=t[11];let m;t[12]!==a.viewScriptHeading||t[13]!==i?(m=i?(0,Z.jsxs)(`details`,{className:`group mt-2`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer select-none text-xs text-fg-subtle underline-offset-2 hover:text-fg-muted`,children:a.viewScriptHeading}),(0,Z.jsx)(`pre`,{className:`mt-1 max-h-60 min-w-0 overflow-y-auto whitespace-pre-wrap break-words rounded-md bg-surface-hover/60 p-2 font-mono text-xs text-fg-muted dark:bg-surface-hover/35`,children:i})]}):null,t[12]=a.viewScriptHeading,t[13]=i,t[14]=m):m=t[14];let h;return t[15]!==c||t[16]!==p||t[17]!==m||t[18]!==s?(h=(0,Z.jsxs)(`div`,{className:c,role:`group`,"aria-label":s,children:[p,m]}),t[15]=c,t[16]=p,t[17]=m,t[18]=s,t[19]=h):h=t[19],h}),uSe={queued:(0,Z.jsx)(Vl,{className:`size-3.5 shrink-0 text-fg-disabled`,"aria-hidden":!0}),running:(0,Z.jsx)(Cg,{className:`size-3.5 shrink-0 animate-spin text-accent-fg`,"aria-hidden":!0}),done:(0,Z.jsx)(Bl,{className:`size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),error:(0,Z.jsx)(Rl,{className:`size-3.5 shrink-0 text-rose-600 dark:text-rose-400`,"aria-hidden":!0}),skipped:(0,Z.jsx)(Wl,{className:`size-3.5 shrink-0 text-fg-disabled`,"aria-hidden":!0})},dSe=(0,J.memo)(function(e){let t=(0,Y.c)(38),{agent:n,labels:r}=e,[i,a]=(0,J.useState)(!1),o=!!(n.prompt||n.resultPreview||n.error),s;t[0]===n.status?s=t[1]:(s=uSe[n.status]??(0,Z.jsx)(Hl,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[0]=n.status,t[1]=s);let c=s,l;t[2]===o?l=t[3]:(l=()=>o&&a(fSe),t[2]=o,t[3]=l);let u=!o,d=o?i:void 0,f=o&&`hover:bg-surface-hover hover:text-fg`,p;t[4]===f?p=t[5]:(p=X(`flex w-full min-w-0 items-center gap-2 rounded-md px-1.5 py-0.5 text-left`,`text-sm leading-6 text-fg-muted`,f,AX.transition,AX.focusRingPanel,AX.disabled),t[4]=f,t[5]=p);let m;t[6]!==o||t[7]!==i?(m=o?(0,Z.jsx)(Fl,{className:X(`size-3.5 shrink-0 text-fg-disabled transition-transform duration-150`,i&&`rotate-90 text-fg-subtle`),"aria-hidden":!0}):(0,Z.jsx)(`span`,{className:`inline-block size-3.5 shrink-0`,"aria-hidden":!0}),t[6]=o,t[7]=i,t[8]=m):m=t[8];let h;t[9]!==n.id||t[10]!==r?(h=r.agentNumber(n.id),t[9]=n.id,t[10]=r,t[11]=h):h=t[11];let g;t[12]===h?g=t[13]:(g=(0,Z.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-fg-disabled`,children:h}),t[12]=h,t[13]=g);let _;t[14]===n.label?_=t[15]:(_=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-fg`,children:n.label}),t[14]=n.label,t[15]=_);let v;t[16]!==c||t[17]!==_||t[18]!==l||t[19]!==u||t[20]!==d||t[21]!==p||t[22]!==m||t[23]!==g?(v=(0,Z.jsxs)(`button`,{type:`button`,onClick:l,disabled:u,"aria-expanded":d,className:p,children:[m,c,g,_]}),t[16]=c,t[17]=_,t[18]=l,t[19]=u,t[20]=d,t[21]=p,t[22]=m,t[23]=g,t[24]=v):v=t[24];let y;t[25]!==n.error||t[26]!==n.prompt||t[27]!==n.resultPreview||t[28]!==o||t[29]!==r.emptyPreview||t[30]!==r.errorHeading||t[31]!==r.promptHeading||t[32]!==r.resultPreviewHeading||t[33]!==i?(y=i&&o?(0,Z.jsxs)(`div`,{className:`ml-7 mt-1 space-y-2 rounded-md border border-edge-subtle bg-surface-hover/30 p-2 text-xs`,children:[n.prompt?(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`mb-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:r.promptHeading}),(0,Z.jsx)(`pre`,{className:`max-h-48 min-w-0 overflow-y-auto whitespace-pre-wrap break-words font-mono text-fg-muted`,children:n.prompt})]}):null,n.resultPreview?(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`mb-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:r.resultPreviewHeading}),(0,Z.jsx)(`div`,{className:`max-h-48 min-w-0 overflow-y-auto whitespace-pre-wrap break-words font-mono text-fg-muted`,children:n.resultPreview})]}):null,n.error?(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`mb-0.5 text-[10px] font-medium uppercase tracking-wide text-rose-600 dark:text-rose-400`,children:r.errorHeading}),(0,Z.jsx)(`div`,{className:`font-mono text-rose-600 dark:text-rose-400`,children:n.error})]}):null,!n.prompt&&!n.resultPreview&&!n.error?(0,Z.jsx)(`div`,{className:`text-fg-disabled`,children:r.emptyPreview}):null]}):null,t[25]=n.error,t[26]=n.prompt,t[27]=n.resultPreview,t[28]=o,t[29]=r.emptyPreview,t[30]=r.errorHeading,t[31]=r.promptHeading,t[32]=r.resultPreviewHeading,t[33]=i,t[34]=y):y=t[34];let b;return t[35]!==v||t[36]!==y?(b=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[v,y]}),t[35]=v,t[36]=y,t[37]=b):b=t[37],b});function fSe(e){return!e}var o9=(0,J.memo)(function(e){let t=(0,Y.c)(47),{rollup:n,isCurrent:r,labels:i}=e,[a,o]=(0,J.useState)(r||n.running>0||n.errored>0||n.skipped>0||!n.complete),s,c;t[0]===r?(s=t[1],c=t[2]):(s=()=>{r&&o(!0)},c=[r],t[0]=r,t[1]=s,t[2]=c),(0,J.useEffect)(s,c);let l=n.agents.length,u;t[3]!==n.complete||t[4]!==n.running?(u=n.running>0?(0,Z.jsx)(Cg,{className:`size-3.5 shrink-0 animate-spin text-accent-fg`,"aria-hidden":!0}):n.complete?(0,Z.jsx)(Bl,{className:`size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):(0,Z.jsx)(Jl,{className:`size-3.5 shrink-0 text-fg-disabled`,"aria-hidden":!0}),t[3]=n.complete,t[4]=n.running,t[5]=u):u=t[5];let d=u,f;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>o(pSe),t[6]=f):f=t[6];let p;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(p=X(`flex w-full min-w-0 items-center gap-2 rounded-md px-1 py-1 text-left`,`text-sm font-medium text-fg`,`hover:bg-surface-hover`,AX.transition,AX.focusRingPanel),t[7]=p):p=t[7];let m=a&&`rotate-90`,h;t[8]===m?h=t[9]:(h=X(`size-3.5 shrink-0 text-fg-subtle transition-transform duration-150`,m),t[8]=m,t[9]=h);let g;t[10]===h?g=t[11]:(g=(0,Z.jsx)(Fl,{className:h,"aria-hidden":!0}),t[10]=h,t[11]=g);let _;t[12]===n.title?_=t[13]:(_=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.title}),t[12]=n.title,t[13]=_);let v;t[14]!==i||t[15]!==n.done||t[16]!==l?(v=i.countTpl(n.done,l),t[14]=i,t[15]=n.done,t[16]=l,t[17]=v):v=t[17];let y;t[18]===v?y=t[19]:(y=(0,Z.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-fg-subtle`,children:v}),t[18]=v,t[19]=y);let b;t[20]!==i||t[21]!==n.running?(b=n.running>0?(0,Z.jsx)(`span`,{className:`text-accent-fg`,children:i.runningTag(n.running)}):null,t[20]=i,t[21]=n.running,t[22]=b):b=t[22];let x;t[23]!==i||t[24]!==n.errored?(x=n.errored>0?(0,Z.jsx)(`span`,{className:`text-rose-600 dark:text-rose-400`,children:i.errorsTag(n.errored)}):null,t[23]=i,t[24]=n.errored,t[25]=x):x=t[25];let S;t[26]!==i||t[27]!==n.skipped?(S=n.skipped>0?(0,Z.jsx)(`span`,{children:i.skippedTag(n.skipped)}):null,t[26]=i,t[27]=n.skipped,t[28]=S):S=t[28];let C;t[29]!==b||t[30]!==x||t[31]!==S?(C=(0,Z.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-xs text-fg-disabled`,children:[b,x,S]}),t[29]=b,t[30]=x,t[31]=S,t[32]=C):C=t[32];let w;t[33]!==a||t[34]!==d||t[35]!==y||t[36]!==C||t[37]!==g||t[38]!==_?(w=(0,Z.jsxs)(`button`,{type:`button`,onClick:f,"aria-expanded":a,className:p,children:[g,d,_,y,C]}),t[33]=a,t[34]=d,t[35]=y,t[36]=C,t[37]=g,t[38]=_,t[39]=w):w=t[39];let T;t[40]!==i||t[41]!==a||t[42]!==n.agents?(T=a?(0,Z.jsxs)(`div`,{className:`ml-4 mt-0.5 space-y-0.5 border-l border-edge-subtle pl-2`,children:[n.agents.map(e=>(0,Z.jsx)(dSe,{agent:e,labels:i},e.id)),n.agents.length===0?(0,Z.jsx)(`div`,{className:`px-1.5 py-0.5 text-xs text-fg-disabled`,children:`…`}):null]}):null,t[40]=i,t[41]=a,t[42]=n.agents,t[43]=T):T=t[43];let E;return t[44]!==w||t[45]!==T?(E=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[w,T]}),t[44]=w,t[45]=T,t[46]=E):E=t[46],E});function pSe(e){return!e}var mSe=`workflow`;function s9(e){return e.name===mSe}function hSe(e){if(e.result!=null){let t=c9(F7(e.result).details);if(t)return t}return c9(e.details)}function c9(e){if(!e||typeof e!=`object`)return null;let t=e;return typeof t.name!=`string`||!Array.isArray(t.agents)?null:e}function gSe(e){return e.status===`running`?`running`:e.status===`error`?`failed`:`completed`}function l9(e){let t=u9(e);if(!t)return`runtime_error`;let n=t.toLowerCase();return n.includes(`parse error`)||n.includes(`snake_case`)||n.includes(`first statement`)?`parse_error`:n.includes(`abort`)?`aborted`:n.includes(`timed out`)||n.includes(`timeout`)?`timeout`:`runtime_error`}function u9(e){if(e.result==null)return``;let t=F7(e.result);return t.text?t.text:typeof e.result==`string`?e.result:``}function _Se(e){let t=e.agents.map(e=>e.phase).filter(e=>!!e),n=[],r=new Set;for(let i of[e.phases,t,e.currentPhase?[e.currentPhase]:[]])for(let e of i)r.has(e)||(r.add(e),n.push(e));let i=[],a=new Set;for(let t of n){let n=e.agents.filter(e=>e.phase===t);if(!(n.length===0&&e.currentPhase!==t)){for(let e of n)a.add(e.id);i.push(d9(t,n))}}let o=e.agents.filter(e=>!a.has(e.id));return{phases:i,unphased:o.length>0?d9(`unphased`,o):null}}function d9(e,t){let n=0,r=0,i=0,a=0;for(let e of t)e.status===`done`?n++:e.status===`running`?r++:e.status===`error`?i++:e.status===`skipped`&&a++;let o=t.length>0&&n+i+a===t.length;return{title:e,agents:t,done:n,running:r,errored:i,skipped:a,complete:o}}function f9(e){if(!Number.isFinite(e)||e<0)return``;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;if(n<60)return r?`${n}m ${r}s`:`${n}m`;let i=Math.floor(n/60),a=n%60;return a?`${i}h ${a}m`:`${i}h`}function vSe(e){let t=String(e??``).toLowerCase();return t===`high`||t===`critical`||t===`h`?`high`:t===`med`||t===`medium`||t===`m`?`med`:t===`low`||t===`l`?`low`:`neutral`}var p9=5,ySe=(0,J.memo)(function(e){let t=(0,Y.c)(38),{result:n,labels:r}=e;if(n==null){let e;return t[0]===r.emptyResult?e=t[1]:(e=(0,Z.jsx)(`div`,{className:`text-sm text-fg-disabled`,children:r.emptyResult}),t[0]=r.emptyResult,t[1]=e),e}if(typeof n!=`object`){let e;return t[2]!==r.rawHeading||t[3]!==n?(e=(0,Z.jsx)(g9,{value:n,heading:r.rawHeading}),t[2]=r.rawHeading,t[3]=n,t[4]=e):e=t[4],e}let i=n,a;if(t[5]!==r||t[6]!==i.executiveSummary||t[7]!==i.findings||t[8]!==i.openQuestions||t[9]!==i.summary||t[10]!==i.topFindings||t[11]!==i.topRisks){if(a=[],typeof i.executiveSummary==`string`&&i.executiveSummary.trim()){let e;t[13]!==r.executiveSummaryHeading||t[14]!==i.executiveSummary?(e=(0,Z.jsx)(m9,{heading:r.executiveSummaryHeading,text:i.executiveSummary},`exec`),t[13]=r.executiveSummaryHeading,t[14]=i.executiveSummary,t[15]=e):e=t[15],a.push(e)}else if(typeof i.summary==`string`&&i.summary.trim()){let e;t[16]!==r.summaryHeading||t[17]!==i.summary?(e=(0,Z.jsx)(m9,{heading:r.summaryHeading,text:i.summary},`sum`),t[16]=r.summaryHeading,t[17]=i.summary,t[18]=e):e=t[18],a.push(e)}let e=_9(i.topFindings)??_9(i.findings);e&&e.length>0&&a.push((0,Z.jsx)(h9,{items:e,heading:r.topFindingsHeading(e.length),moreSuffix:r.moreSuffix},`findings`));let n=_9(i.topRisks);n&&n.length>0&&a.push((0,Z.jsx)(h9,{items:n,heading:r.topRisksHeading(n.length),moreSuffix:r.moreSuffix},`risks`));let o=SSe(i.openQuestions);if(o&&o.length>0){let e;t[19]===r.openQuestionsHeading?e=t[20]:(e=(0,Z.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:r.openQuestionsHeading}),t[19]=r.openQuestionsHeading,t[20]=e);let n=(0,Z.jsxs)(`ul`,{className:`space-y-0.5 text-sm text-fg-muted`,children:[o.slice(0,p9).map(CSe),o.length>p9?(0,Z.jsx)(`li`,{className:`pl-4 text-xs text-fg-disabled`,children:r.moreSuffix(o.length-p9)}):null]}),i;t[21]!==e||t[22]!==n?(i=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[e,n]},`oq`),t[21]=e,t[22]=n,t[23]=i):i=t[23],a.push(i)}t[5]=r,t[6]=i.executiveSummary,t[7]=i.findings,t[8]=i.openQuestions,t[9]=i.summary,t[10]=i.topFindings,t[11]=i.topRisks,t[12]=a}else a=t[12];if(a.length===0){let e;return t[24]!==r.rawHeading||t[25]!==n?(e=(0,Z.jsx)(g9,{value:n,heading:r.rawHeading}),t[24]=r.rawHeading,t[25]=n,t[26]=e):e=t[26],e}let o;t[27]===r.rawHeading?o=t[28]:(o=(0,Z.jsx)(`summary`,{className:`cursor-pointer select-none text-xs text-fg-subtle underline-offset-2 hover:text-fg-muted`,children:r.rawHeading}),t[27]=r.rawHeading,t[28]=o);let s;t[29]!==r.rawHeading||t[30]!==n?(s=(0,Z.jsx)(g9,{value:n,heading:r.rawHeading,hideHeading:!0}),t[29]=r.rawHeading,t[30]=n,t[31]=s):s=t[31];let c;t[32]!==o||t[33]!==s?(c=(0,Z.jsxs)(`details`,{className:`group`,children:[o,s]}),t[32]=o,t[33]=s,t[34]=c):c=t[34];let l;return t[35]!==a||t[36]!==c?(l=(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[a,c]}),t[35]=a,t[36]=c,t[37]=l):l=t[37],l});function m9(e){let t=(0,Y.c)(7),{heading:n,text:r}=e,i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,Z.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-sm text-fg`,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function h9(e){let t=(0,Y.c)(21),{items:n,heading:r,moreSuffix:i}=e,a,o,s,c,l;t[0]!==r||t[1]!==n?(l=n.slice(0,p9),s=`min-w-0`,t[7]===r?c=t[8]:(c=(0,Z.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:r}),t[7]=r,t[8]=c),a=`space-y-1`,o=l.map(bSe),t[0]=r,t[1]=n,t[2]=a,t[3]=o,t[4]=s,t[5]=c,t[6]=l):(a=t[2],o=t[3],s=t[4],c=t[5],l=t[6]);let u;t[9]!==a||t[10]!==o?(u=(0,Z.jsx)(`ul`,{className:a,children:o}),t[9]=a,t[10]=o,t[11]=u):u=t[11];let d;t[12]!==n.length||t[13]!==i||t[14]!==l.length?(d=n.length>l.length?(0,Z.jsx)(`div`,{className:`mt-1 pl-1 text-xs text-fg-disabled`,children:i(n.length-l.length)}):null,t[12]=n.length,t[13]=i,t[14]=l.length,t[15]=d):d=t[15];let f;return t[16]!==s||t[17]!==c||t[18]!==u||t[19]!==d?(f=(0,Z.jsxs)(`div`,{className:s,children:[c,u,d]}),t[16]=s,t[17]=c,t[18]=u,t[19]=d,t[20]=f):f=t[20],f}function bSe(e,t){return(0,Z.jsx)(xSe,{item:e},t)}function xSe(e){let t=(0,Y.c)(21),{item:n}=e,r=vSe(n.severity),i=r===`high`?`bg-rose-500/15 text-rose-700 dark:text-rose-300`:r===`med`?`bg-amber-500/15 text-amber-700 dark:text-amber-300`:`bg-surface-hover text-fg-muted`,a=n.file?n.line===void 0?n.file:`${n.file}:${n.line}`:n.source??``,o=n.dimension??n.lens??``,s;t[0]!==n.severity||t[1]!==i?(s=n.severity?(0,Z.jsx)(`span`,{className:X(`mt-0.5 shrink-0 rounded px-1.5 py-px text-[10px] font-medium uppercase`,i),children:String(n.severity).slice(0,4)}):(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0 text-fg-disabled`,children:`•`}),t[0]=n.severity,t[1]=i,t[2]=s):s=t[2];let c;t[3]===o?c=t[4]:(c=o?(0,Z.jsx)(`span`,{className:`mr-1.5 text-xs text-fg-subtle`,children:o}):null,t[3]=o,t[4]=c);let l=n.title??n.reason??`(no title)`,u;t[5]===l?u=t[6]:(u=(0,Z.jsx)(`span`,{className:`text-fg`,children:l}),t[5]=l,t[6]=u);let d;t[7]!==c||t[8]!==u?(d=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[c,u]}),t[7]=c,t[8]=u,t[9]=d):d=t[9];let f;t[10]===a?f=t[11]:(f=a?(0,Z.jsx)(`div`,{className:`truncate font-mono text-xs text-fg-subtle`,title:a,children:a}):null,t[10]=a,t[11]=f);let p;t[12]===n.fix?p=t[13]:(p=n.fix?(0,Z.jsxs)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:[`↳ `,n.fix]}):null,t[12]=n.fix,t[13]=p);let m;t[14]!==d||t[15]!==f||t[16]!==p?(m=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[d,f,p]}),t[14]=d,t[15]=f,t[16]=p,t[17]=m):m=t[17];let h;return t[18]!==s||t[19]!==m?(h=(0,Z.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2 text-sm`,children:[s,m]}),t[18]=s,t[19]=m,t[20]=h):h=t[20],h}function g9(e){let t=(0,Y.c)(10),{value:n,heading:r,hideHeading:i}=e,a;try{let e;t[0]===n?e=t[1]:(e=JSON.stringify(n,null,2),t[0]=n,t[1]=e),a=e}catch{a=String(n)}let o;t[2]!==r||t[3]!==i?(o=i?null:(0,Z.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:r}),t[2]=r,t[3]=i,t[4]=o):o=t[4];let s;t[5]===a?s=t[6]:(s=(0,Z.jsx)(`pre`,{className:`max-h-72 min-w-0 overflow-y-auto whitespace-pre-wrap break-words rounded-md bg-surface-hover/60 p-2 font-mono text-xs text-fg-muted dark:bg-surface-hover/35`,children:a}),t[5]=a,t[6]=s);let c;return t[7]!==o||t[8]!==s?(c=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function _9(e){return Array.isArray(e)&&e.length>0?e:null}function SSe(e){if(!Array.isArray(e))return null;let t=e.filter(e=>typeof e==`string`&&e.trim().length>0);return t.length>0?t:null}function CSe(e,t){return(0,Z.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-fg-disabled`,children:`•`}),(0,Z.jsx)(`span`,{className:`min-w-0 break-words`,children:e})]},t)}var wSe=(0,J.memo)(function({block:e,startedAt:t,onAbort:n,onSendChatMessage:r,labels:i,className:a}){let o=gSe(e),s=(0,J.useMemo)(()=>hSe(e),[e]),c=o===`failed`?l9(e):null,l=o===`failed`?u9(e):``,[u,d]=(0,J.useState)(!1);(0,J.useEffect)(()=>{o===`completed`&&d(!0),(o===`running`||o===`failed`)&&d(!1)},[o]);let[f,p]=(0,J.useState)(!1),[,m]=(0,J.useState)(0);(0,J.useEffect)(()=>{if(o!==`running`)return;let e=window.setInterval(()=>m(e=>e+1),1e3);return()=>window.clearInterval(e)},[o]);let h=(0,J.useMemo)(()=>o===`running`?t?f9(Date.now()-t):``:s?.durationMs==null?``:f9(s.durationMs),[o,t,s?.durationMs]),[g,_]=(0,J.useState)(!1),v=(0,J.useCallback)(async()=>{s&&await lH(typeof s.result==`string`?s.result:DSe(s.result))&&(_(!0),window.setTimeout(()=>_(!1),1500))},[s]),[y,b]=(0,J.useState)(!1),[x,S]=(0,J.useState)(``),C=(0,J.useRef)(null);(0,J.useEffect)(()=>{y&&(x||S(s?.name??``),window.setTimeout(()=>C.current?.focus(),0))},[y,x,s?.name]);let w=(0,J.useCallback)(()=>{let e=x.trim();!e||!r||(r(`/workflow save ${e}`),b(!1))},[x,r]);if(o===`failed`||o===`completed`&&!s){let t=c??l9(e),n=ESe(e);return(0,Z.jsx)(lSe,{kind:t,reason:l||`workflow failed`,scriptPreview:n,labels:i.error,className:a})}let T=s?.agentCount??0,E=s?.doneCount??0,D=s?_Se(s):{phases:[],unphased:null},O=(0,Z.jsxs)(Z.Fragment,{children:[o===`running`&&n?(0,Z.jsx)(`button`,{type:`button`,onClick:n,className:X(`inline-flex size-7 items-center justify-center rounded-md text-fg-muted`,`hover:bg-surface-hover hover:text-rose-600 dark:hover:text-rose-400`,AX.transition,AX.focusRingPanel),"aria-label":i.cancel,title:i.cancel,children:(0,Z.jsx)(Gl,{className:`size-4`})}):null,o===`completed`&&s?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`button`,{type:`button`,onClick:v,className:X(`inline-flex size-7 items-center justify-center rounded-md text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,AX.transition,AX.focusRingPanel),"aria-label":g?i.copyDoneAria:i.copyAria,title:g?i.copyDoneAria:i.copyAria,children:g?(0,Z.jsx)(Ml,{className:`size-4 text-emerald-600 dark:text-emerald-400`}):(0,Z.jsx)(tu,{className:`size-4`})}),r?(0,Z.jsx)(`button`,{type:`button`,onClick:()=>b(e=>!e),className:X(`inline-flex size-7 items-center justify-center rounded-md text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,AX.transition,AX.focusRingPanel),"aria-label":i.saveAria,title:i.saveTitle,children:(0,Z.jsx)(ub,{className:`size-4`})}):null,(0,Z.jsx)(`button`,{type:`button`,className:X(`inline-flex size-7 items-center justify-center rounded-md text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,AX.transition,AX.focusRingPanel,`invisible`),"aria-label":i.moreAria,title:i.moreAria,children:(0,Z.jsx)(ud,{className:`size-4`})})]}):null]});return(0,Z.jsxs)(`div`,{className:X(`min-w-0 rounded-xl border border-edge bg-surface-panel shadow-surface`,a),role:`group`,"aria-label":s?`Workflow ${s.name}`:`Workflow`,children:[(0,Z.jsx)(sSe,{name:s?.name??e.name,description:s?.description,status:o,doneCount:E,totalCount:T,durationText:h,collapsed:u,onToggleCollapsed:()=>d(e=>!e),actions:O,labels:i.header}),y&&o===`completed`?(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 border-b border-edge-subtle px-3 py-2`,children:[(0,Z.jsx)(`input`,{ref:C,type:`text`,value:x,onChange:e=>S(e.target.value),onKeyDown:e=>{e.key===`Enter`?w():e.key===`Escape`&&b(!1)},placeholder:i.savePlaceholder,className:X(`min-w-0 flex-1 rounded-md border border-edge bg-surface-base px-2 py-1 text-sm text-fg`,`placeholder:text-fg-disabled`,AX.focusRingPanel)}),(0,Z.jsx)(`button`,{type:`button`,onClick:w,disabled:!x.trim(),className:X(`inline-flex h-7 items-center rounded-md bg-accent px-2.5 text-xs font-medium text-fg-onAccent`,`hover:bg-accent-hover`,AX.transition,AX.focusRingPanel,AX.disabled),children:i.saveSubmit}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>b(!1),className:X(`inline-flex h-7 items-center rounded-md px-2 text-xs text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,AX.transition,AX.focusRingPanel),children:i.saveCancel})]}):null,u?null:(0,Z.jsxs)(`div`,{className:`space-y-3 px-3 py-2.5`,children:[o===`completed`&&s?(0,Z.jsx)(ySe,{result:s.result,labels:i.result}):null,o===`running`&&s?(0,Z.jsx)(v9,{rollup:D,currentPhase:s.currentPhase,labels:i.phase,recentLogs:s.logs.slice(-2),recentLogsHeading:i.recentLogsHeading}):null,o===`running`&&!s?(0,Z.jsxs)(`div`,{className:`py-1 text-sm text-fg-subtle`,children:[(0,Z.jsx)(`span`,{className:`inline-block size-2 animate-pulse rounded-full bg-accent align-middle`}),(0,Z.jsx)(`span`,{className:`ml-2 align-middle`,children:i.viewSubagentsHeading})]}):null,o===`completed`&&s&&(D.phases.length>0||D.unphased)?(0,Z.jsxs)(`details`,{className:`group`,open:f,onToggle:e=>p(e.target.open),children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer select-none text-xs text-fg-subtle underline-offset-2 hover:text-fg-muted`,children:i.viewSubagentsHeading}),(0,Z.jsx)(`div`,{className:`mt-2`,children:(0,Z.jsx)(v9,{rollup:D,currentPhase:void 0,labels:i.phase,recentLogs:[],recentLogsHeading:i.recentLogsHeading})})]}):null]})]})});function v9(e){let t=(0,Y.c)(17),{rollup:n,currentPhase:r,labels:i,recentLogs:a,recentLogsHeading:o}=e,s;if(t[0]!==r||t[1]!==i||t[2]!==n.phases){let e;t[4]!==r||t[5]!==i?(e=e=>(0,Z.jsx)(o9,{rollup:e,isCurrent:e.title===r,labels:i},e.title),t[4]=r,t[5]=i,t[6]=e):e=t[6],s=n.phases.map(e),t[0]=r,t[1]=i,t[2]=n.phases,t[3]=s}else s=t[3];let c;t[7]!==i||t[8]!==n.unphased?(c=n.unphased?(0,Z.jsx)(o9,{rollup:n.unphased,isCurrent:!1,labels:i}):null,t[7]=i,t[8]=n.unphased,t[9]=c):c=t[9];let l;t[10]!==a||t[11]!==o?(l=a.length>0?(0,Z.jsxs)(`div`,{className:`mt-2 border-t border-edge-subtle pt-2`,children:[(0,Z.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:o}),(0,Z.jsx)(`div`,{className:`space-y-0.5`,children:a.map(TSe)})]}):null,t[10]=a,t[11]=o,t[12]=l):l=t[12];let u;return t[13]!==s||t[14]!==c||t[15]!==l?(u=(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[s,c,l]}),t[13]=s,t[14]=c,t[15]=l,t[16]=u):u=t[16],u}function TSe(e,t){return(0,Z.jsx)(`div`,{className:`truncate font-mono text-xs text-fg-subtle`,children:e},t)}function ESe(e){if(!e.input||typeof e.input!=`object`)return;let t=e.input;if(typeof t.script==`string`&&t.script.trim())return t.script.split(`
4698
+ `)}\n…`}t[12]=s.text,t[13]=i}else i=t[13];c=i,f=`space-y-1.5`,l=`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,t[14]===a?u=t[15]:(u=a?(0,Z.jsx)(`a`,{href:a,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex max-w-full min-w-0 items-center break-words rounded-md bg-surface-hover/60 px-1.5 py-0.5 font-mono text-xs text-accent-fg underline-offset-2 hover:underline [overflow-wrap:anywhere] dark:bg-surface-hover/35`,title:a,children:a}):null,t[14]=a,t[15]=u),d=n!=null&&n>0?(0,Z.jsx)(U7,{children:J7(r.linesBadge,{count:n})}):null,t[4]=r,t[5]=s,t[6]=a,t[7]=c,t[8]=l,t[9]=u,t[10]=d,t[11]=f}else c=t[7],l=t[8],u=t[9],d=t[10],f=t[11];let p;t[16]!==l||t[17]!==u||t[18]!==d?(p=(0,Z.jsxs)(`div`,{className:l,children:[u,d]}),t[16]=l,t[17]=u,t[18]=d,t[19]=p):p=t[19];let m;t[20]!==r||t[21]!==c?(m=c?(0,Z.jsx)(K7,{summary:r.viewContent,children:(0,Z.jsx)(q7,{children:c})}):null,t[20]=r,t[21]=c,t[22]=m):m=t[22];let h;return t[23]!==f||t[24]!==p||t[25]!==m?(h=(0,Z.jsxs)(`div`,{className:f,children:[p,m]}),t[23]=f,t[24]=p,t[25]=m,t[26]=h):h=t[26],h}),Q7=c(_e(e=>({showRawToolData:!1,setShowRawToolData:t=>e({showRawToolData:t})}),{name:`xopc-web-dev-view`}));function $7(e,t){if(!Number.isFinite(e)||e<=0)return t===`zh`?`不到1秒`:`<1s`;let n=Math.floor(e/1e3);if(n===0)return t===`zh`?`不到1秒`:`<1s`;let r=Math.floor(n/60),i=n%60;return t===`zh`?r===0?`${i}秒`:i===0?`${r}分`:`${r}分${i}秒`:r===0?`${i}s`:i===0?`${r}m`:`${r}m ${i}s`}var Oxe={extension:Lv,local:Pg,cloakbrowser:sx,cdp:Gw,cloud:Ql};function kxe(e){let t=(0,Y.c)(29),{payload:n}=e,r=Qr(),i=d(Axe),a;t[0]===i?a=t[1]:(a=m(i),t[0]=i,t[1]=a);let o=a.chat,s=Oxe[n.backend]??km,c=o.browserSetupRequiredTitle,l=o.browserSetupRequiredReasons[n.reason]??o.browserSetupRequiredReasons.generic,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=X(`mt-2 flex flex-col gap-2 rounded-xl border border-amber-300/60 bg-amber-50/70 px-3 py-3`,`dark:border-amber-500/30 dark:bg-amber-500/10`),t[2]=u):u=t[2];let f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=X(`flex size-8 shrink-0 items-center justify-center rounded-lg`,`bg-amber-100 text-amber-700 dark:bg-amber-500/20 dark:text-amber-300`),t[3]=f):f=t[3];let p;t[4]===s?p=t[5]:(p=(0,Z.jsx)(`span`,{className:f,"aria-hidden":!0,children:(0,Z.jsx)(s,{className:`size-4`,strokeWidth:1.75})}),t[4]=s,t[5]=p);let h;t[6]===c?h=t[7]:(h=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-amber-900 dark:text-amber-100`,children:c}),t[6]=c,t[7]=h);let g;t[8]===l?g=t[9]:(g=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-amber-900/85 dark:text-amber-100/80`,children:l}),t[8]=l,t[9]=g);let _;t[10]!==h||t[11]!==g?(_=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[h,g]}),t[10]=h,t[11]=g,t[12]=_):_=t[12];let v;t[13]!==p||t[14]!==_?(v=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[p,_]}),t[13]=p,t[14]=_,t[15]=v):v=t[15];let y;t[16]!==r||t[17]!==n.deepLink?(y=()=>r(n.deepLink),t[16]=r,t[17]=n.deepLink,t[18]=y):y=t[18];let b;t[19]!==o.browserSetupRequiredCta||t[20]!==y?(b=(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,Z.jsx)(wA,{type:`button`,variant:`primary`,className:`h-8 px-3 py-1.5 text-xs`,onClick:y,children:o.browserSetupRequiredCta})}),t[19]=o.browserSetupRequiredCta,t[20]=y,t[21]=b):b=t[21];let x;t[22]!==o.browserSetupRequiredDetailToggle||t[23]!==n.detail?(x=n.detail?(0,Z.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer select-none text-amber-800/80 underline-offset-2 hover:text-amber-900 dark:text-amber-200/80 dark:hover:text-amber-100`,children:o.browserSetupRequiredDetailToggle}),(0,Z.jsx)(`pre`,{className:`mt-2 max-h-40 w-full min-w-0 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-md bg-amber-100/60 p-2 font-mono text-[11px] text-amber-900 dark:bg-amber-500/15 dark:text-amber-100 [overflow-wrap:anywhere]`,children:n.detail})]}):null,t[22]=o.browserSetupRequiredDetailToggle,t[23]=n.detail,t[24]=x):x=t[24];let S;return t[25]!==b||t[26]!==x||t[27]!==v?(S=(0,Z.jsxs)(`section`,{role:`status`,"aria-live":`polite`,className:u,children:[v,b,x]}),t[25]=b,t[26]=x,t[27]=v,t[28]=S):S=t[28],S}function Axe(e){return e.language}var jxe=new Set([`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`]),Mxe=new Set([`extension_not_installed`,`extension_bridge_offline`,`extension_not_connected`,`local_chromium_missing`,`cloakbrowser_not_installed`,`cdp_unreachable`,`cloud_api_key_missing`]);function Nxe(e){if(!e?.trim())return null;let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=`object`)return null;let n=t;if(n.kind!==`browser_setup_required`)return null;let r=n.backend,i=n.reason,a=n.deepLink;return typeof r!=`string`||!jxe.has(r)||typeof i!=`string`||!Mxe.has(i)||typeof a!=`string`||!a.startsWith(`/settings/`)?null:{kind:`browser_setup_required`,backend:r,reason:i,deepLink:a,detail:typeof n.detail==`string`?n.detail:void 0,message:typeof n.message==`string`?n.message:void 0}}function Pxe(e){let t=(0,Y.c)(4),{links:n}=e;if(n.length===0)return null;let r;t[0]===n?r=t[1]:(r=n.map(Fxe),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,Z.jsx)(`div`,{className:`mt-1.5 flex min-w-0 flex-wrap gap-2`,children:r}),t[2]=r,t[3]=i),i}function Fxe(e){let{url:t,title:n}=e;return(0,Z.jsxs)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,className:X(`inline-flex max-w-full min-w-0 items-center gap-1 rounded-md bg-accent-soft/40 px-2 py-1 text-xs font-medium text-accent-fg`,`max-w-xs transition-colors hover:bg-accent-soft/60 [overflow-wrap:anywhere]`,AX.focusRingPanel,AX.press),title:t,children:[(0,Z.jsx)(yd,{className:`size-3.5 shrink-0 opacity-70`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:n})]},t)}var e9=`xopc.extensionUiGrants.v1`;function t9(e){return e.flatMap(e=>{let t=e.trim();return t?[t]:[]}).toSorted().join(`\0`)}function n9(e,t){try{let n=localStorage.getItem(e9);return(n?JSON.parse(n):{})[e]===t9(t)}catch{return!1}}function Ixe(e,t){let n=localStorage.getItem(e9),r=(n?JSON.parse(n):{})??{};r[e]=t9(t),localStorage.setItem(e9,JSON.stringify(r))}var Lxe={theme:`Read theme (light / dark)`,"agent.send":`Send messages to the assistant`,"agent.subscribe":`Receive live agent stream events for a chat`,"session.read":`List and open chat sessions`,"session.write":`Modify chat sessions`,"config.read":`Read extension configuration`,"config.write":`Write extension configuration`,storage:`Read and write extension storage`,notification:`Show in-app notifications`,clipboard:`Use the clipboard`,"workspace.read":`Read workspace files`,"workspace.write":`Write workspace files`},r9={theme:`读取主题(浅色/深色)`,"agent.send":`向助手发送消息`,"agent.subscribe":`接收会话的实时助手流式事件`,"session.read":`列出并打开聊天会话`,"session.write":`修改聊天会话`,"config.read":`读取扩展配置`,"config.write":`写入扩展配置`,storage:`读写扩展存储`,notification:`显示应用内通知`,clipboard:`使用剪贴板`,"workspace.read":`读取工作区文件`,"workspace.write":`写入工作区文件`};function Rxe(e,t){let n=Lxe[e];return t===`zh`&&r9[e]?r9[e]:n??e}function zxe(e){let t=(0,Y.c)(41),{open:n,onOpenChange:r,extensionId:i,extensionName:a,permissions:o,onConfirm:s}=e,{t:c}=Ve(),l=d(Vxe),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(ie,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[0]=u):u=t[0];let f;t[1]!==a||t[2]!==c?(f=c(`extensionUi.permissionTitle`,{name:a}),t[1]=a,t[2]=c,t[3]=f):f=t[3];let p;t[4]===f?p=t[5]:(p=(0,Z.jsx)(ue,{className:`text-base font-semibold text-fg`,children:f}),t[4]=f,t[5]=p);let m;t[6]===c?m=t[7]:(m=c(`extensionUi.permissionSubtitle`),t[6]=c,t[7]=m);let h;t[8]===i?h=t[9]:(h=(0,Z.jsxs)(`span`,{className:`font-mono text-xs text-fg-muted`,title:i,children:[`(`,i,`)`]}),t[8]=i,t[9]=h);let g;t[10]!==m||t[11]!==h?(g=(0,Z.jsxs)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:[m,` `,h]}),t[10]=m,t[11]=h,t[12]=g):g=t[12];let _;t[13]!==l||t[14]!==o||t[15]!==c?(_=o.length===0?(0,Z.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:c(`extensionUi.permissionsNone`)}):(0,Z.jsx)(`ul`,{className:`mt-4 max-h-48 list-inside list-disc space-y-1 overflow-y-auto text-sm text-fg`,children:o.map(e=>(0,Z.jsx)(`li`,{children:Rxe(e,l)},e))}),t[13]=l,t[14]=o,t[15]=c,t[16]=_):_=t[16];let v;t[17]===c?v=t[18]:(v=c(`extensionUi.deny`),t[17]=c,t[18]=v);let y;t[19]===v?y=t[20]:(y=(0,Z.jsx)(de,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`rounded-lg border border-edge px-3 py-2 text-sm text-fg hover:bg-surface-muted`,children:v})}),t[19]=v,t[20]=y);let b;t[21]!==s||t[22]!==r?(b=()=>{s(),r(!1)},t[21]=s,t[22]=r,t[23]=b):b=t[23];let x;t[24]===c?x=t[25]:(x=c(`extensionUi.allow`),t[24]=c,t[25]=x);let S;t[26]!==b||t[27]!==x?(S=(0,Z.jsx)(`button`,{type:`button`,className:`rounded-lg bg-accent px-3 py-2 text-sm font-medium text-white hover:opacity-90`,onClick:b,children:x}),t[26]=b,t[27]=x,t[28]=S):S=t[28];let C;t[29]!==S||t[30]!==y?(C=(0,Z.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[y,S]}),t[29]=S,t[30]=y,t[31]=C):C=t[31];let w;t[32]!==C||t[33]!==p||t[34]!==g||t[35]!==_?(w=(0,Z.jsxs)(G,{children:[u,(0,Z.jsxs)(se,{className:`fixed left-1/2 top-1/2 z-[131] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-5 shadow-elevated`,onOpenAutoFocus:Bxe,children:[p,g,_,C]})]}),t[32]=C,t[33]=p,t[34]=g,t[35]=_,t[36]=w):w=t[36];let T;return t[37]!==r||t[38]!==n||t[39]!==w?(T=(0,Z.jsx)(q,{open:n,onOpenChange:r,children:w}),t[37]=r,t[38]=n,t[39]=w,t[40]=T):T=t[40],T}function Bxe(e){return e.preventDefault()}function Vxe(e){return e.language}var Hxe=48,Uxe=2e3,Wxe=`allow-scripts allow-forms allow-popups`;function Gxe(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function i9({extensionId:e,extensionName:t,entrypoint:n,permissions:r,title:i,className:a,fixedHeight:o,maxHeight:s=Uxe,minHeight:c=Hxe,initialData:l}){let{t:u}=Ve(),f=jI(),p=(0,J.useRef)(null),m=Se(e=>e.token),h=ve(e=>e.resolved),g=t?.trim()||e,v=i?.trim()||`Extension ${e}`,y=(0,J.useMemo)(()=>JSON.stringify(Array.from(r??[]).toSorted()),[r]),b=(0,J.useMemo)(()=>JSON.parse(y),[y]),x=n9(e,b),[S,C]=(0,J.useReducer)(c5,{allowed:x,dialogOpen:!x,reloadKey:0,loadError:!1,dynamicHeight:o??Math.min(s,Math.max(c,320))}),{allowed:w,dialogOpen:T,reloadKey:E,loadError:D,dynamicHeight:O}=S,k=(0,J.useRef)({id:e,k:y});if(k.current.id!==e||k.current.k!==y){k.current={id:e,k:y};let t=n9(e,b);C({type:`patch`,patch:{allowed:t,dialogOpen:!t}})}let A=(0,J.useCallback)(e=>C({type:`patch`,patch:{dialogOpen:e}}),[]),j=(0,J.useMemo)(()=>{let t=Gxe(n),r=_(`/api/extensions/${encodeURIComponent(e)}/assets/${t}`);if(!m?.trim())return r;let i=new URL(r);return i.searchParams.set(`token`,m.trim()),i.toString()},[e,n,m]);(0,J.useLayoutEffect)(()=>{if(!w)return;let t=p.current;if(!t)return;f.registerIframe(e,t,b);let n=f.subscribeExtensionEvents(e,e=>{if(e.event!==`ui.resize`||!e.data||typeof e.data!=`object`||e.data===null)return;let t=Number(e.data.height);Number.isFinite(t)&&o===void 0&&C({type:`patch`,patch:{dynamicHeight:Math.min(s,Math.max(c,t))}})});return()=>{n(),f.unregisterIframe(e)}},[w,e,o,s,c,b,f]),(0,J.useEffect)(()=>{if(!w)return;let t=yI(h);f.sendEvent(e,`theme.changed`,t)},[w,e,h,f]);let M=o===void 0?{width:`100%`,height:O,border:`none`}:{width:`100%`,height:o,border:`none`};return w?(0,Z.jsxs)(`div`,{className:`flex flex-1 min-h-0 min-w-0 flex-col`,children:[D?(0,Z.jsxs)(`div`,{className:`mb-2 rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-sm text-fg`,children:[(0,Z.jsx)(`p`,{children:u(`extensionUi.loadFailed`)}),(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:u(`extensionUi.loadFailedConnectionHint`)}),(0,Z.jsx)(`button`,{type:`button`,className:`mt-2 font-medium text-accent underline-offset-2 hover:underline`,onClick:()=>{C({type:`patch`,patch:{loadError:!1,reloadKey:E+1}})},children:u(`extensionUi.retryLoad`)})]}):null,(0,Z.jsx)(`iframe`,{ref:p,className:a,title:v,src:j,style:M,sandbox:Wxe,referrerPolicy:`no-referrer`,onError:()=>C({type:`patch`,patch:{loadError:!0}}),onLoad:()=>{C({type:`patch`,patch:{loadError:!1}});let t=d.getState().language;f.sendInit(e,yI(ve.getState().resolved),t),l!==void 0&&f.sendEvent(e,`widget.data`,l)}},`${e}-${n}-${E}`)]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(zxe,{open:T,onOpenChange:A,extensionId:e,extensionName:g,permissions:b,onConfirm:()=>{Ixe(e,b),C({type:`patch`,patch:{allowed:!0}})}}),T?null:(0,Z.jsxs)(`div`,{className:a?`${a} rounded-lg border border-edge border-dashed bg-surface-base p-4 text-sm text-fg-muted`:`rounded-lg border border-edge border-dashed bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,Z.jsx)(`p`,{children:u(`extensionUi.deniedHint`)}),(0,Z.jsx)(`button`,{type:`button`,className:`mt-2 text-sm font-medium text-accent underline-offset-2 hover:underline`,onClick:()=>C({type:`patch`,patch:{dialogOpen:!0}}),children:u(`extensionUi.reviewPermissions`)})]})]})}function Kxe(e){let t=(0,Y.c)(8),{extensionId:n,extensionName:r,entrypoint:i,title:a,toolResult:o,maxHeight:s,interactive:c,permissions:l}=e,u=s===void 0?400:s,d;return t[0]!==i||t[1]!==n||t[2]!==r||t[3]!==u||t[4]!==l||t[5]!==a||t[6]!==o?(d=(0,Z.jsx)(`div`,{className:`mt-2 w-full min-w-0 overflow-hidden rounded-xl border border-edge bg-surface-base`,children:(0,Z.jsx)(i9,{extensionId:n,extensionName:r,entrypoint:i,permissions:l,title:a,className:`w-full`,minHeight:80,maxHeight:u,initialData:o})}),t[0]=i,t[1]=n,t[2]=r,t[3]=u,t[4]=l,t[5]=a,t[6]=o,t[7]=d):d=t[7],d}function qxe(e){let t=NI();return(0,J.useMemo)(()=>{for(let n of t){let t=n.ui?.contributions?.chatWidgets;if(t){for(let r of t)if(r.match.toolName&&r.match.toolName===e)return{...r,extensionId:n.id}}}return null},[t,e])}var Jxe=(0,J.memo)(function(e){let t=(0,Y.c)(2),{active:n}=e;if(n){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Cg,{className:`mt-0.5 size-4 shrink-0 animate-spin text-accent-fg`,"aria-hidden":!0}),t[0]=e):e=t[0],e}let r;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(Bl,{className:`mt-0.5 size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),t[1]=r):r=t[1],r}),a9=(0,J.memo)(function({active:e,roundStartRef:t,frozenMs:n,language:r,className:i}){let[,a]=(0,J.useState)(0);(0,J.useEffect)(()=>{if(!e)return;let t=window.setInterval(()=>a(e=>e+1),500);return()=>window.clearInterval(t)},[e]);let o=t.current,s=e&&o!=null?Math.max(0,Date.now()-o):0,c=e&&o!=null?$7(s,r):n==null?null:$7(n,r);return c?(0,Z.jsx)(`span`,{className:i,children:c}):null});function Yxe({blocks:e,toolLabels:t,stepLabels:n,clusterLabels:r,cardLabels:i,sessionKey:a,isMessageStreaming:o=!1,finalAnswerStarted:s=!1}){let c=d(e=>e.language),l=(0,J.useMemo)(()=>R7(e),[e]),u=l.length,f=l.some(e=>e.type===`thinking`&&e.streaming||e.type===`tool_use`&&e.status===`running`),p=!!o&&!s,m=(0,J.useRef)(null),h=(0,J.useRef)(p),[g,_]=(0,J.useState)(null),[v,y]=(0,J.useState)(null);f&&m.current===null&&(m.current=Date.now()),(0,J.useEffect)(()=>{p&&!h.current?(y(null),_(null)):!p&&h.current&&(m.current!==null&&_(Date.now()-m.current),y(!1)),h.current=p},[p]);let b=v??p,x=(0,J.useMemo)(()=>f?``:lxe(l,r.done,r.join,c,z7(u,n)),[f,l,c,u,n,r]),S=(0,J.useMemo)(()=>f?uxe(l,r.ing):null,[f,l,r]);if(u===0)return null;let C={thoughts:n.thoughts,thoughtsStreaming:n.thoughtsStreaming,searchedWeb:n.searchedWeb,readFile:n.readFile,stepDetails:n.stepDetails,runCommand:n.runCommand,listDirectory:n.listDirectory,writeFile:n.writeFile,editFile:n.editFile,openUrl:n.openUrl,fetchUrl:n.fetchUrl,unknownTool:n.unknownTool},w=f?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:S??z7(u,n)}),(0,Z.jsx)(a9,{active:f,roundStartRef:m,frozenMs:null,language:c,className:`ml-1.5 tabular-nums text-fg-muted`})]}):(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:x})}),T=f?null:(0,Z.jsx)(a9,{active:!1,roundStartRef:m,frozenMs:g,language:c,className:`mt-0.5 tabular-nums text-xs text-fg-muted`});return(0,Z.jsxs)(`div`,{className:`my-1 w-full min-w-0 overflow-hidden rounded-xl bg-surface-hover/50 dark:bg-surface-hover/30`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:X(`grid w-full min-w-0 grid-cols-[auto_minmax(0,1fr)_auto_auto] items-start gap-x-2 rounded-t-xl px-3 py-2 text-left`,AX.transition,`hover:bg-surface-hover/80 dark:hover:bg-surface-hover/50`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),onClick:()=>y(e=>!(e??p)),"aria-expanded":b,children:[(0,Z.jsx)(Jxe,{active:f}),(0,Z.jsx)(`div`,{className:`min-w-0`,children:(0,Z.jsx)(`span`,{className:`inline-flex max-w-full flex-wrap items-baseline rounded-md bg-accent-soft/70 px-2 py-0.5 text-xs font-medium text-fg dark:bg-accent-soft/40`,children:w})}),(0,Z.jsx)(`span`,{className:`flex items-start justify-end`,children:T}),(0,Z.jsx)(Nl,{className:X(`mt-0.5 size-4 shrink-0 text-fg-muted transition-transform`,b&&`rotate-180`),"aria-hidden":!0})]}),b?(0,Z.jsx)(`div`,{className:`border-t border-edge-subtle/90 px-3 pb-3 pt-2 dark:border-edge-subtle`,children:(0,Z.jsx)(Xxe,{blocks:e,toolLabels:t,stepLabels:C,cardLabels:i,sessionKey:a})}):null]})}function Xxe(e){let t=(0,Y.c)(23),{blocks:n,toolLabels:r,stepLabels:i,cardLabels:a,className:o,sessionKey:s}=e,c,l,u,d;if(t[0]!==n||t[1]!==a||t[2]!==o||t[3]!==s||t[4]!==i||t[5]!==r){d=Symbol.for(`react.early_return_sentinel`);bb0:{let e=R7(n);if(e.length===0){d=null;break bb0}t[10]===o?u=t[11]:(u=X(`min-w-0 overflow-x-hidden`,o),t[10]=o,t[11]=u),c=`ml-1 min-w-0 space-y-3 border-l border-edge-subtle pl-3 dark:border-edge-subtle`;let f;t[12]!==a||t[13]!==s||t[14]!==i||t[15]!==r?(f=(e,t)=>(0,Z.jsx)($xe,{block:e,toolLabels:r,stepLabels:i,cardLabels:a,sessionKey:s},e.type===`tool_use`?e.id:`thinking-${t}`),t[12]=a,t[13]=s,t[14]=i,t[15]=r,t[16]=f):f=t[16],l=e.map(f)}t[0]=n,t[1]=a,t[2]=o,t[3]=s,t[4]=i,t[5]=r,t[6]=c,t[7]=l,t[8]=u,t[9]=d}else c=t[6],l=t[7],u=t[8],d=t[9];if(d!==Symbol.for(`react.early_return_sentinel`))return d;let f;t[17]!==c||t[18]!==l?(f=(0,Z.jsx)(`div`,{className:c,children:l}),t[17]=c,t[18]=l,t[19]=f):f=t[19];let p;return t[20]!==u||t[21]!==f?(p=(0,Z.jsx)(`div`,{className:u,children:f}),t[20]=u,t[21]=f,t[22]=p):p=t[22],p}function Zxe(e){let t=(0,Y.c)(15),{toolName:n,toolResult:r}=e,i=NI(),a=qxe(n);if(!a||i.length===0)return null;let o;if(t[0]!==i||t[1]!==a.extensionId){let e;t[3]===a.extensionId?e=t[4]:(e=e=>e.id===a.extensionId,t[3]=a.extensionId,t[4]=e),o=i.find(e),t[0]=i,t[1]=a.extensionId,t[2]=o}else o=t[2];let s=o,c=s?.name??a.extensionId,l=a.maxHeight??400,u=a.interactive??!1,d=s?.ui?.permissions,f;return t[5]!==c||t[6]!==l||t[7]!==u||t[8]!==d||t[9]!==r||t[10]!==a.entrypoint||t[11]!==a.extensionId||t[12]!==a.id||t[13]!==a.title?(f=(0,Z.jsx)(Kxe,{extensionId:a.extensionId,extensionName:c,widgetId:a.id,entrypoint:a.entrypoint,title:a.title,toolResult:r,maxHeight:l,interactive:u,permissions:d}),t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=r,t[10]=a.entrypoint,t[11]=a.extensionId,t[12]=a.id,t[13]=a.title,t[14]=f):f=t[14],f}var Qxe=new Set([`readFile`,`editFile`,`writeFile`,`runCommand`,`fetchUrl`]);function $xe(e){let t=(0,Y.c)(106),{block:n,toolLabels:r,stepLabels:i,cardLabels:a,sessionKey:o}=e,s=Q7(eSe),c;bb0:{if(n.type!==`tool_use`){c=``;break bb0}if(n.status===`running`){c=``;break bb0}let e=n.result;if(e==null){c=``;break bb0}if(typeof e==`string`){let n;t[0]===e?n=t[1]:(n=e.trim(),t[0]=e,t[1]=n),c=n;break bb0}try{let n;t[2]===e?n=t[3]:(n=JSON.stringify(e,null,2),t[2]=e,t[3]=n),c=n}catch{c=String(e)}}let l=c,u;bb1:{if(n.type!==`tool_use`||n.status===`running`||n.status===`error`){let e;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[4]=e):e=t[4],u=e;break bb1}if(!v7.has(n.name)){let e;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[5]=e):e=t[5],u=e;break bb1}if(!l){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[6]=e):e=t[6],u=e;break bb1}let e;t[7]===l?e=t[8]:(e=h7(l),t[7]=l,t[8]=e),u=e}let d=u,f;bb2:{if(n.type!==`tool_use`||n.status===`running`||n.status===`error`){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[9]=e):e=t[9],f=e;break bb2}if(!j7(n.name)||!l){let e;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[10]=e):e=t[10],f=e;break bb2}let e;t[11]===l?e=t[12]:(e=exe(l),t[11]=l,t[12]=e),f=e}let p=f,m;bb3:{if(n.type!==`tool_use`||n.status===`running`){m=null;break bb3}if(n.name!==`browser_use`){m=null;break bb3}let e;t[13]===l?e=t[14]:(e=Nxe(l),t[13]=l,t[14]=e),m=e}let h=m;if(n.type===`thinking`){let e=!!n.streaming,r;t[15]===n.text?r=t[16]:(r=n.text?.trim()??``,t[15]=n.text,t[16]=r);let a=r;if(!a&&!e)return null;let o;t[17]===e?o=t[18]:(o=(0,Z.jsx)(`div`,{className:`mt-0.5 shrink-0`,children:e?(0,Z.jsx)(Cg,{className:`size-4 animate-spin text-fg-muted`,"aria-hidden":!0}):(0,Z.jsx)(Bl,{className:`size-4 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0})}),t[17]=e,t[18]=o);let s=e?i.thoughtsStreaming:i.thoughts,c;t[19]===s?c=t[20]:(c=(0,Z.jsx)(`span`,{className:`inline-flex max-w-full min-w-0 break-words rounded-md bg-accent-soft/60 px-1.5 py-0.5 text-xs font-medium text-fg [overflow-wrap:anywhere] dark:bg-accent-soft/35`,children:s}),t[19]=s,t[20]=c);let l;t[21]!==e||t[22]!==a?(l=a?(0,Z.jsx)(`p`,{className:`line-clamp-4 whitespace-pre-wrap break-words text-xs leading-relaxed text-fg-muted [overflow-wrap:anywhere]`,children:a}):e?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`…`}):null,t[21]=e,t[22]=a,t[23]=l):l=t[23];let u;t[24]!==c||t[25]!==l?(u=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[c,l]}),t[24]=c,t[25]=l,t[26]=u):u=t[26];let d;return t[27]!==u||t[28]!==o?(d=(0,Z.jsxs)(`div`,{className:`flex min-w-0 gap-2.5`,children:[o,u]}),t[27]=u,t[28]=o,t[29]=d):d=t[29],d}let g=n.status===`running`,_=n.status===`error`,v=l??``;if(v)try{let e;t[30]===v?e=t[31]:(e=JSON.stringify(JSON.parse(v),null,2),t[30]=v,t[31]=e),v=e}catch{}let y,b;t[32]===n.name?(y=t[33],b=t[34]):(y=P7(n.name),b=Qxe.has(y),t[32]=n.name,t[33]=y,t[34]=b);let x=b,S;t[35]!==n.name||t[36]!==i.editFile||t[37]!==i.fetchUrl||t[38]!==i.listDirectory||t[39]!==i.openUrl||t[40]!==i.readFile||t[41]!==i.runCommand||t[42]!==i.searchedWeb||t[43]!==i.unknownTool||t[44]!==i.writeFile?(S=Xbe(n.name,{searchedWeb:i.searchedWeb,readFile:i.readFile,runCommand:i.runCommand,listDirectory:i.listDirectory,writeFile:i.writeFile,editFile:i.editFile,openUrl:i.openUrl,fetchUrl:i.fetchUrl,unknownTool:i.unknownTool}),t[35]=n.name,t[36]=i.editFile,t[37]=i.fetchUrl,t[38]=i.listDirectory,t[39]=i.openUrl,t[40]=i.readFile,t[41]=i.runCommand,t[42]=i.searchedWeb,t[43]=i.unknownTool,t[44]=i.writeFile,t[45]=S):S=t[45];let C=S,w;t[46]===n.input?w=t[47]:(w=A7(n.input),t[46]=n.input,t[47]=w);let T=w,E;t[48]===n.input?E=t[49]:(E=n.input===void 0?``:Zbe(n.input),t[48]=n.input,t[49]=E);let D=E,O;t[50]!==n||t[51]!==a||t[52]!==x||t[53]!==y?(O=x?y===`readFile`?(0,Z.jsx)(yxe,{block:n,labels:a}):y===`editFile`?(0,Z.jsx)(Sxe,{block:n,labels:a}):y===`writeFile`?(0,Z.jsx)(wxe,{block:n,labels:a}):y===`runCommand`?(0,Z.jsx)(Exe,{block:n,labels:a}):y===`fetchUrl`?(0,Z.jsx)(Dxe,{block:n,labels:a}):null:null,t[50]=n,t[51]=a,t[52]=x,t[53]=y,t[54]=O):O=t[54];let k=O,A=!g&&(s||!x&&!h),j;t[55]!==_||t[56]!==g?(j=(0,Z.jsx)(`div`,{className:`mt-0.5 shrink-0`,children:g?(0,Z.jsx)(Cg,{className:`size-4 animate-spin text-fg-muted`,"aria-hidden":!0}):_?(0,Z.jsx)(ql,{className:`size-4 text-red-600 dark:text-red-400`,"aria-hidden":!0}):(0,Z.jsx)(Bl,{className:`size-4 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0})}),t[55]=_,t[56]=g,t[57]=j):j=t[57];let M;t[58]===C?M=t[59]:(M=(0,Z.jsx)(`span`,{className:`inline-flex max-w-full min-w-0 break-words rounded-md bg-accent-soft/60 px-1.5 py-0.5 text-xs font-medium text-fg [overflow-wrap:anywhere] dark:bg-accent-soft/35`,children:C}),t[58]=C,t[59]=M);let N;t[60]!==_||t[61]!==g?(N=g?(0,Z.jsx)(`span`,{className:`text-xs text-fg-disabled`,children:`running…`}):_?(0,Z.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:`error`}):null,t[60]=_,t[61]=g,t[62]=N):N=t[62];let P;t[63]!==M||t[64]!==N?(P=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,children:[M,N]}),t[63]=M,t[64]=N,t[65]=P):P=t[65];let F;t[66]!==T||t[67]!==x?(F=!x&&T?(0,Z.jsx)(`p`,{className:`min-w-0 rounded-md bg-accent-soft/40 px-1.5 py-1 text-xs break-words text-fg-muted [overflow-wrap:anywhere] dark:bg-accent-soft/25`,children:T}):null,t[66]=T,t[67]=x,t[68]=F):F=t[68];let I;t[69]!==a||t[70]!==x||t[71]!==v||t[72]!==D||t[73]!==A||t[74]!==i.stepDetails||t[75]!==r?(I=A?(0,Z.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer select-none text-fg-subtle underline-offset-2 hover:text-fg-muted group-open:text-fg-muted`,children:x?a.rawDetails:i.stepDetails}),(0,Z.jsxs)(`div`,{className:`mt-2 max-h-48 w-full min-w-0 max-w-full overflow-y-auto overflow-x-hidden rounded-md bg-surface-hover/60 p-2 font-mono dark:bg-surface-hover/35`,children:[D?(0,Z.jsxs)(`div`,{className:`mb-2 min-w-0`,children:[(0,Z.jsx)(`div`,{className:`mb-0.5 text-[10px] uppercase tracking-wide text-fg-disabled`,children:r.input}),(0,Z.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-fg-muted [overflow-wrap:anywhere]`,children:D})]}):null,(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`mb-0.5 text-[10px] uppercase tracking-wide text-fg-disabled`,children:r.output}),(0,Z.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-fg-muted [overflow-wrap:anywhere]`,children:v||r.noOutput})]})]})]}):null,t[69]=a,t[70]=x,t[71]=v,t[72]=D,t[73]=A,t[74]=i.stepDetails,t[75]=r,t[76]=I):I=t[76];let L;t[77]!==n.name||t[78]!==n.result||t[79]!==_||t[80]!==g?(L=!g&&!_?(0,Z.jsx)(Zxe,{toolName:n.name,toolResult:n.result}):null,t[77]=n.name,t[78]=n.result,t[79]=_,t[80]=g,t[81]=L):L=t[81];let R;t[82]!==_||t[83]!==g||t[84]!==p?(R=!g&&!_&&p.length>0?(0,Z.jsx)(Pxe,{links:p}):null,t[82]=_,t[83]=g,t[84]=p,t[85]=R):R=t[85];let z;t[86]!==d||t[87]!==_||t[88]!==g||t[89]!==o?(z=!g&&!_&&d.length>0?(0,Z.jsx)(_7,{paths:d,sessionKey:o}):null,t[86]=d,t[87]=_,t[88]=g,t[89]=o,t[90]=z):z=t[90];let B;t[91]!==h||t[92]!==g?(B=!g&&h?(0,Z.jsx)(kxe,{payload:h}):null,t[91]=h,t[92]=g,t[93]=B):B=t[93];let V;t[94]!==k||t[95]!==P||t[96]!==F||t[97]!==I||t[98]!==L||t[99]!==R||t[100]!==z||t[101]!==B?(V=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1.5`,children:[P,k,F,I,L,R,z,B]}),t[94]=k,t[95]=P,t[96]=F,t[97]=I,t[98]=L,t[99]=R,t[100]=z,t[101]=B,t[102]=V):V=t[102];let H;return t[103]!==j||t[104]!==V?(H=(0,Z.jsxs)(`div`,{className:`flex min-w-0 gap-2.5`,children:[j,V]}),t[103]=j,t[104]=V,t[105]=H):H=t[105],H}function eSe(e){return e.showRawToolData}function tSe(e){let t=[],n=(n,r)=>{let i=new RegExp(n.source,n.flags),a;for(;(a=i.exec(e))!==null;)t.push({start:a.index,end:a.index+a[0].length,seg:r(a)})};n(U$(),e=>({kind:`skill`,name:e[1]??``})),n(R8(),e=>({kind:`file`,path:I8(e)}));for(let n of t1(e))t.push({start:n.start,end:n.end,seg:{kind:`command`,name:e.slice(n.start+1,n.end)}});t.sort((e,t)=>e.start===t.start?t.end-e.end:e.start-t.start);let r=[],i=0;for(let n of t)n.start<i||(n.start>i&&r.push({kind:`text`,text:e.slice(i,n.start)}),r.push(n.seg),i=n.end);return i<e.length&&r.push({kind:`text`,text:e.slice(i)}),r.length===0&&r.push({kind:`text`,text:e}),r}function nSe(e){let t=e.replace(/\/$/,``);return`@${t.split(`/`).pop()??t}`}function rSe(e){return e.kind===`text`?`t:${e.text}`:e.kind===`skill`?`s:${e.name}`:e.kind===`file`?`f:${e.path}`:`c:${e.name}`}var iSe=(0,J.memo)(function(e){let t=(0,Y.c)(10),{text:n}=e,r;t[0]===n?r=t[1]:(r=tSe(n),t[0]=n,t[1]=r);let i=r,a;if(t[2]!==i){let e=new Map;a=i.map(t=>{let n=rSe(t),r=e.get(n)??0;return e.set(n,r+1),{part:t,key:`${n}#${String(r)}`}}),t[2]=i,t[3]=a}else a=t[3];let o=a;if(!i.some(aSe)){let e;return t[4]===n?e=t[5]:(e=(0,Z.jsx)(`div`,{className:`markdown-content min-w-0`,children:(0,Z.jsx)(OX,{content:n,compact:!0})}),t[4]=n,t[5]=e),e}let s;t[6]===o?s=t[7]:(s=o.map(oSe),t[6]=o,t[7]=s);let c;return t[8]===s?c=t[9]:(c=(0,Z.jsx)(`span`,{className:`inline-flex max-w-full flex-wrap items-baseline gap-x-1.5 gap-y-1 [text-align:inherit]`,children:s}),t[8]=s,t[9]=c),c});function aSe(e){return e.kind!==`text`}function oSe(e){let{part:t,key:n}=e;return t.kind===`skill`?(0,Z.jsxs)(`span`,{className:`chat-skill-pill max-w-full shrink-0`,"data-skill":t.name,children:[`/`,t.name]},n):t.kind===`command`?(0,Z.jsxs)(`span`,{className:`chat-command-pill max-w-full shrink-0`,"data-slash-command":t.name,children:[`/`,t.name]},n):t.kind===`file`?(0,Z.jsx)(`span`,{className:`chat-file-pill max-w-full shrink-0`,"data-file":t.path,children:nSe(t.path)},n):t.text?(0,Z.jsx)(`div`,{className:`markdown-content inline-block min-w-0 max-w-full align-baseline text-fg`,children:(0,Z.jsx)(OX,{content:t.text,compact:!0,breaks:!0})},n):null}var sSe=(0,J.memo)(function(e){let t=(0,Y.c)(37),{name:n,description:r,status:i,doneCount:a,totalCount:o,durationText:s,collapsed:c,onToggleCollapsed:l,actions:u,labels:d}=e,f=o>0?`${a}/${o}`:i===`running`?`…`:`0`,p;t[0]!==f||t[1]!==s||t[2]!==d||t[3]!==i?(p=i===`running`?d.runningMeta(f,s):i===`completed`?d.completedMeta(f,s):d.failedMeta,t[0]=f,t[1]=s,t[2]=d,t[3]=i,t[4]=p):p=t[4];let m=p,h=i===`failed`&&`border-rose-300/40`,g;t[5]===h?g=t[6]:(g=X(`flex min-w-0 items-center gap-2 border-b border-edge-subtle px-3 py-2`,h),t[5]=h,t[6]=g);let _;t[7]===i?_=t[8]:(_=(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-fg-subtle`,children:i===`running`?(0,Z.jsx)(Cg,{className:`size-4 animate-spin text-accent-fg`}):(0,Z.jsx)(Nh,{className:`size-4`})}),t[7]=i,t[8]=_);let v;t[9]===n?v=t[10]:(v=(0,Z.jsx)(`div`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,children:n}),t[9]=n,t[10]=v);let y;t[11]===m?y=t[12]:(y=(0,Z.jsx)(`div`,{className:`shrink-0 text-xs tabular-nums text-fg-subtle`,children:m}),t[11]=m,t[12]=y);let b;t[13]!==v||t[14]!==y?(b=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[v,y]}),t[13]=v,t[14]=y,t[15]=b):b=t[15];let x;t[16]===r?x=t[17]:(x=r?(0,Z.jsx)(`div`,{className:`mt-0.5 line-clamp-1 text-xs text-fg-subtle`,children:r}):null,t[16]=r,t[17]=x);let S;t[18]!==b||t[19]!==x?(S=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[b,x]}),t[18]=b,t[19]=x,t[20]=S):S=t[20];let C;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(C=X(`inline-flex size-7 items-center justify-center rounded-md`,`text-fg-muted hover:bg-surface-hover hover:text-fg`,AX.transition,AX.focusRingPanel),t[21]=C):C=t[21];let w=c?d.expand:d.collapse,T=c?d.expand:d.collapse,E;t[22]===c?E=t[23]:(E=c?(0,Z.jsx)(Nl,{className:`size-4`}):(0,Z.jsx)(Il,{className:`size-4`}),t[22]=c,t[23]=E);let D;t[24]!==l||t[25]!==w||t[26]!==T||t[27]!==E?(D=(0,Z.jsx)(`button`,{type:`button`,onClick:l,className:C,"aria-label":w,title:T,children:E}),t[24]=l,t[25]=w,t[26]=T,t[27]=E,t[28]=D):D=t[28];let O;t[29]!==u||t[30]!==D?(O=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[u,D]}),t[29]=u,t[30]=D,t[31]=O):O=t[31];let k;return t[32]!==O||t[33]!==g||t[34]!==_||t[35]!==S?(k=(0,Z.jsxs)(`div`,{className:g,children:[_,S,O]}),t[32]=O,t[33]=g,t[34]=_,t[35]=S,t[36]=k):k=t[36],k}),cSe={parse_error:(0,Z.jsx)(zg,{className:`size-4 shrink-0 text-rose-600 dark:text-rose-400`,"aria-hidden":!0}),aborted:(0,Z.jsx)(ql,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),timeout:(0,Z.jsx)(xT,{className:`size-4 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),runtime_error:(0,Z.jsx)(QT,{className:`size-4 shrink-0 text-rose-600 dark:text-rose-400`,"aria-hidden":!0})},lSe=(0,J.memo)(function(e){let t=(0,Y.c)(20),{kind:n,reason:r,scriptPreview:i,labels:a,className:o}=e,s=n===`parse_error`?a.titleParse:n===`aborted`?a.titleAbort:n===`timeout`?a.titleTimeout:a.titleRuntime,c;t[0]===o?c=t[1]:(c=X(`min-w-0 rounded-xl border border-edge bg-surface-panel shadow-surface`,`p-3`,o),t[0]=o,t[1]=c);let l=cSe[n],u;t[2]===s?u=t[3]:(u=(0,Z.jsx)(`div`,{className:`text-sm font-semibold tracking-tight text-fg`,children:s}),t[2]=s,t[3]=u);let d;t[4]===r?d=t[5]:(d=r?(0,Z.jsx)(`div`,{className:`mt-1 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:r}):null,t[4]=r,t[5]=d);let f;t[6]!==u||t[7]!==d?(f=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[u,d]}),t[6]=u,t[7]=d,t[8]=f):f=t[8];let p;t[9]!==l||t[10]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[l,f]}),t[9]=l,t[10]=f,t[11]=p):p=t[11];let m;t[12]!==a.viewScriptHeading||t[13]!==i?(m=i?(0,Z.jsxs)(`details`,{className:`group mt-2`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer select-none text-xs text-fg-subtle underline-offset-2 hover:text-fg-muted`,children:a.viewScriptHeading}),(0,Z.jsx)(`pre`,{className:`mt-1 max-h-60 min-w-0 overflow-y-auto whitespace-pre-wrap break-words rounded-md bg-surface-hover/60 p-2 font-mono text-xs text-fg-muted dark:bg-surface-hover/35`,children:i})]}):null,t[12]=a.viewScriptHeading,t[13]=i,t[14]=m):m=t[14];let h;return t[15]!==c||t[16]!==p||t[17]!==m||t[18]!==s?(h=(0,Z.jsxs)(`div`,{className:c,role:`group`,"aria-label":s,children:[p,m]}),t[15]=c,t[16]=p,t[17]=m,t[18]=s,t[19]=h):h=t[19],h}),uSe={queued:(0,Z.jsx)(Vl,{className:`size-3.5 shrink-0 text-fg-disabled`,"aria-hidden":!0}),running:(0,Z.jsx)(Cg,{className:`size-3.5 shrink-0 animate-spin text-accent-fg`,"aria-hidden":!0}),done:(0,Z.jsx)(Bl,{className:`size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),error:(0,Z.jsx)(Rl,{className:`size-3.5 shrink-0 text-rose-600 dark:text-rose-400`,"aria-hidden":!0}),skipped:(0,Z.jsx)(Wl,{className:`size-3.5 shrink-0 text-fg-disabled`,"aria-hidden":!0})},dSe=(0,J.memo)(function(e){let t=(0,Y.c)(38),{agent:n,labels:r}=e,[i,a]=(0,J.useState)(!1),o=!!(n.prompt||n.resultPreview||n.error),s;t[0]===n.status?s=t[1]:(s=uSe[n.status]??(0,Z.jsx)(Hl,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[0]=n.status,t[1]=s);let c=s,l;t[2]===o?l=t[3]:(l=()=>o&&a(fSe),t[2]=o,t[3]=l);let u=!o,d=o?i:void 0,f=o&&`hover:bg-surface-hover hover:text-fg`,p;t[4]===f?p=t[5]:(p=X(`flex w-full min-w-0 items-center gap-2 rounded-md px-1.5 py-0.5 text-left`,`text-sm leading-6 text-fg-muted`,f,AX.transition,AX.focusRingPanel,AX.disabled),t[4]=f,t[5]=p);let m;t[6]!==o||t[7]!==i?(m=o?(0,Z.jsx)(Fl,{className:X(`size-3.5 shrink-0 text-fg-disabled transition-transform duration-150`,i&&`rotate-90 text-fg-subtle`),"aria-hidden":!0}):(0,Z.jsx)(`span`,{className:`inline-block size-3.5 shrink-0`,"aria-hidden":!0}),t[6]=o,t[7]=i,t[8]=m):m=t[8];let h;t[9]!==n.id||t[10]!==r?(h=r.agentNumber(n.id),t[9]=n.id,t[10]=r,t[11]=h):h=t[11];let g;t[12]===h?g=t[13]:(g=(0,Z.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-fg-disabled`,children:h}),t[12]=h,t[13]=g);let _;t[14]===n.label?_=t[15]:(_=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-fg`,children:n.label}),t[14]=n.label,t[15]=_);let v;t[16]!==c||t[17]!==_||t[18]!==l||t[19]!==u||t[20]!==d||t[21]!==p||t[22]!==m||t[23]!==g?(v=(0,Z.jsxs)(`button`,{type:`button`,onClick:l,disabled:u,"aria-expanded":d,className:p,children:[m,c,g,_]}),t[16]=c,t[17]=_,t[18]=l,t[19]=u,t[20]=d,t[21]=p,t[22]=m,t[23]=g,t[24]=v):v=t[24];let y;t[25]!==n.error||t[26]!==n.prompt||t[27]!==n.resultPreview||t[28]!==o||t[29]!==r.emptyPreview||t[30]!==r.errorHeading||t[31]!==r.promptHeading||t[32]!==r.resultPreviewHeading||t[33]!==i?(y=i&&o?(0,Z.jsxs)(`div`,{className:`ml-7 mt-1 space-y-2 rounded-md border border-edge-subtle bg-surface-hover/30 p-2 text-xs`,children:[n.prompt?(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`mb-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:r.promptHeading}),(0,Z.jsx)(`pre`,{className:`max-h-48 min-w-0 overflow-y-auto whitespace-pre-wrap break-words font-mono text-fg-muted`,children:n.prompt})]}):null,n.resultPreview?(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`mb-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:r.resultPreviewHeading}),(0,Z.jsx)(`div`,{className:`max-h-48 min-w-0 overflow-y-auto whitespace-pre-wrap break-words font-mono text-fg-muted`,children:n.resultPreview})]}):null,n.error?(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`mb-0.5 text-[10px] font-medium uppercase tracking-wide text-rose-600 dark:text-rose-400`,children:r.errorHeading}),(0,Z.jsx)(`div`,{className:`font-mono text-rose-600 dark:text-rose-400`,children:n.error})]}):null,!n.prompt&&!n.resultPreview&&!n.error?(0,Z.jsx)(`div`,{className:`text-fg-disabled`,children:r.emptyPreview}):null]}):null,t[25]=n.error,t[26]=n.prompt,t[27]=n.resultPreview,t[28]=o,t[29]=r.emptyPreview,t[30]=r.errorHeading,t[31]=r.promptHeading,t[32]=r.resultPreviewHeading,t[33]=i,t[34]=y):y=t[34];let b;return t[35]!==v||t[36]!==y?(b=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[v,y]}),t[35]=v,t[36]=y,t[37]=b):b=t[37],b});function fSe(e){return!e}var o9=(0,J.memo)(function(e){let t=(0,Y.c)(47),{rollup:n,isCurrent:r,labels:i}=e,[a,o]=(0,J.useState)(r||n.running>0||n.errored>0||n.skipped>0||!n.complete),s,c;t[0]===r?(s=t[1],c=t[2]):(s=()=>{r&&o(!0)},c=[r],t[0]=r,t[1]=s,t[2]=c),(0,J.useEffect)(s,c);let l=n.agents.length,u;t[3]!==n.complete||t[4]!==n.running?(u=n.running>0?(0,Z.jsx)(Cg,{className:`size-3.5 shrink-0 animate-spin text-accent-fg`,"aria-hidden":!0}):n.complete?(0,Z.jsx)(Bl,{className:`size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):(0,Z.jsx)(Jl,{className:`size-3.5 shrink-0 text-fg-disabled`,"aria-hidden":!0}),t[3]=n.complete,t[4]=n.running,t[5]=u):u=t[5];let d=u,f;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>o(pSe),t[6]=f):f=t[6];let p;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(p=X(`flex w-full min-w-0 items-center gap-2 rounded-md px-1 py-1 text-left`,`text-sm font-medium text-fg`,`hover:bg-surface-hover`,AX.transition,AX.focusRingPanel),t[7]=p):p=t[7];let m=a&&`rotate-90`,h;t[8]===m?h=t[9]:(h=X(`size-3.5 shrink-0 text-fg-subtle transition-transform duration-150`,m),t[8]=m,t[9]=h);let g;t[10]===h?g=t[11]:(g=(0,Z.jsx)(Fl,{className:h,"aria-hidden":!0}),t[10]=h,t[11]=g);let _;t[12]===n.title?_=t[13]:(_=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.title}),t[12]=n.title,t[13]=_);let v;t[14]!==i||t[15]!==n.done||t[16]!==l?(v=i.countTpl(n.done,l),t[14]=i,t[15]=n.done,t[16]=l,t[17]=v):v=t[17];let y;t[18]===v?y=t[19]:(y=(0,Z.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-fg-subtle`,children:v}),t[18]=v,t[19]=y);let b;t[20]!==i||t[21]!==n.running?(b=n.running>0?(0,Z.jsx)(`span`,{className:`text-accent-fg`,children:i.runningTag(n.running)}):null,t[20]=i,t[21]=n.running,t[22]=b):b=t[22];let x;t[23]!==i||t[24]!==n.errored?(x=n.errored>0?(0,Z.jsx)(`span`,{className:`text-rose-600 dark:text-rose-400`,children:i.errorsTag(n.errored)}):null,t[23]=i,t[24]=n.errored,t[25]=x):x=t[25];let S;t[26]!==i||t[27]!==n.skipped?(S=n.skipped>0?(0,Z.jsx)(`span`,{children:i.skippedTag(n.skipped)}):null,t[26]=i,t[27]=n.skipped,t[28]=S):S=t[28];let C;t[29]!==b||t[30]!==x||t[31]!==S?(C=(0,Z.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-xs text-fg-disabled`,children:[b,x,S]}),t[29]=b,t[30]=x,t[31]=S,t[32]=C):C=t[32];let w;t[33]!==a||t[34]!==d||t[35]!==y||t[36]!==C||t[37]!==g||t[38]!==_?(w=(0,Z.jsxs)(`button`,{type:`button`,onClick:f,"aria-expanded":a,className:p,children:[g,d,_,y,C]}),t[33]=a,t[34]=d,t[35]=y,t[36]=C,t[37]=g,t[38]=_,t[39]=w):w=t[39];let T;t[40]!==i||t[41]!==a||t[42]!==n.agents?(T=a?(0,Z.jsxs)(`div`,{className:`ml-4 mt-0.5 space-y-0.5 border-l border-edge-subtle pl-2`,children:[n.agents.map(e=>(0,Z.jsx)(dSe,{agent:e,labels:i},e.id)),n.agents.length===0?(0,Z.jsx)(`div`,{className:`px-1.5 py-0.5 text-xs text-fg-disabled`,children:`…`}):null]}):null,t[40]=i,t[41]=a,t[42]=n.agents,t[43]=T):T=t[43];let E;return t[44]!==w||t[45]!==T?(E=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[w,T]}),t[44]=w,t[45]=T,t[46]=E):E=t[46],E});function pSe(e){return!e}var mSe=`workflow`;function s9(e){return e.name===mSe}function hSe(e){if(e.result!=null){let t=c9(H7(e.result).details);if(t)return t}return c9(e.details)}function c9(e){if(!e||typeof e!=`object`)return null;let t=e;return typeof t.name!=`string`||!Array.isArray(t.agents)?null:e}function gSe(e){return e.status===`running`?`running`:e.status===`error`?`failed`:`completed`}function l9(e){let t=u9(e);if(!t)return`runtime_error`;let n=t.toLowerCase();return n.includes(`parse error`)||n.includes(`snake_case`)||n.includes(`first statement`)?`parse_error`:n.includes(`abort`)?`aborted`:n.includes(`timed out`)||n.includes(`timeout`)?`timeout`:`runtime_error`}function u9(e){if(e.result==null)return``;let t=H7(e.result);return t.text?t.text:typeof e.result==`string`?e.result:``}function _Se(e){let t=e.agents.map(e=>e.phase).filter(e=>!!e),n=[],r=new Set;for(let i of[e.phases,t,e.currentPhase?[e.currentPhase]:[]])for(let e of i)r.has(e)||(r.add(e),n.push(e));let i=[],a=new Set;for(let t of n){let n=e.agents.filter(e=>e.phase===t);if(!(n.length===0&&e.currentPhase!==t)){for(let e of n)a.add(e.id);i.push(d9(t,n))}}let o=e.agents.filter(e=>!a.has(e.id));return{phases:i,unphased:o.length>0?d9(`unphased`,o):null}}function d9(e,t){let n=0,r=0,i=0,a=0;for(let e of t)e.status===`done`?n++:e.status===`running`?r++:e.status===`error`?i++:e.status===`skipped`&&a++;let o=t.length>0&&n+i+a===t.length;return{title:e,agents:t,done:n,running:r,errored:i,skipped:a,complete:o}}function f9(e){if(!Number.isFinite(e)||e<0)return``;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;if(n<60)return r?`${n}m ${r}s`:`${n}m`;let i=Math.floor(n/60),a=n%60;return a?`${i}h ${a}m`:`${i}h`}function vSe(e){let t=String(e??``).toLowerCase();return t===`high`||t===`critical`||t===`h`?`high`:t===`med`||t===`medium`||t===`m`?`med`:t===`low`||t===`l`?`low`:`neutral`}var p9=5,ySe=(0,J.memo)(function(e){let t=(0,Y.c)(38),{result:n,labels:r}=e;if(n==null){let e;return t[0]===r.emptyResult?e=t[1]:(e=(0,Z.jsx)(`div`,{className:`text-sm text-fg-disabled`,children:r.emptyResult}),t[0]=r.emptyResult,t[1]=e),e}if(typeof n!=`object`){let e;return t[2]!==r.rawHeading||t[3]!==n?(e=(0,Z.jsx)(g9,{value:n,heading:r.rawHeading}),t[2]=r.rawHeading,t[3]=n,t[4]=e):e=t[4],e}let i=n,a;if(t[5]!==r||t[6]!==i.executiveSummary||t[7]!==i.findings||t[8]!==i.openQuestions||t[9]!==i.summary||t[10]!==i.topFindings||t[11]!==i.topRisks){if(a=[],typeof i.executiveSummary==`string`&&i.executiveSummary.trim()){let e;t[13]!==r.executiveSummaryHeading||t[14]!==i.executiveSummary?(e=(0,Z.jsx)(m9,{heading:r.executiveSummaryHeading,text:i.executiveSummary},`exec`),t[13]=r.executiveSummaryHeading,t[14]=i.executiveSummary,t[15]=e):e=t[15],a.push(e)}else if(typeof i.summary==`string`&&i.summary.trim()){let e;t[16]!==r.summaryHeading||t[17]!==i.summary?(e=(0,Z.jsx)(m9,{heading:r.summaryHeading,text:i.summary},`sum`),t[16]=r.summaryHeading,t[17]=i.summary,t[18]=e):e=t[18],a.push(e)}let e=_9(i.topFindings)??_9(i.findings);e&&e.length>0&&a.push((0,Z.jsx)(h9,{items:e,heading:r.topFindingsHeading(e.length),moreSuffix:r.moreSuffix},`findings`));let n=_9(i.topRisks);n&&n.length>0&&a.push((0,Z.jsx)(h9,{items:n,heading:r.topRisksHeading(n.length),moreSuffix:r.moreSuffix},`risks`));let o=SSe(i.openQuestions);if(o&&o.length>0){let e;t[19]===r.openQuestionsHeading?e=t[20]:(e=(0,Z.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:r.openQuestionsHeading}),t[19]=r.openQuestionsHeading,t[20]=e);let n=(0,Z.jsxs)(`ul`,{className:`space-y-0.5 text-sm text-fg-muted`,children:[o.slice(0,p9).map(CSe),o.length>p9?(0,Z.jsx)(`li`,{className:`pl-4 text-xs text-fg-disabled`,children:r.moreSuffix(o.length-p9)}):null]}),i;t[21]!==e||t[22]!==n?(i=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[e,n]},`oq`),t[21]=e,t[22]=n,t[23]=i):i=t[23],a.push(i)}t[5]=r,t[6]=i.executiveSummary,t[7]=i.findings,t[8]=i.openQuestions,t[9]=i.summary,t[10]=i.topFindings,t[11]=i.topRisks,t[12]=a}else a=t[12];if(a.length===0){let e;return t[24]!==r.rawHeading||t[25]!==n?(e=(0,Z.jsx)(g9,{value:n,heading:r.rawHeading}),t[24]=r.rawHeading,t[25]=n,t[26]=e):e=t[26],e}let o;t[27]===r.rawHeading?o=t[28]:(o=(0,Z.jsx)(`summary`,{className:`cursor-pointer select-none text-xs text-fg-subtle underline-offset-2 hover:text-fg-muted`,children:r.rawHeading}),t[27]=r.rawHeading,t[28]=o);let s;t[29]!==r.rawHeading||t[30]!==n?(s=(0,Z.jsx)(g9,{value:n,heading:r.rawHeading,hideHeading:!0}),t[29]=r.rawHeading,t[30]=n,t[31]=s):s=t[31];let c;t[32]!==o||t[33]!==s?(c=(0,Z.jsxs)(`details`,{className:`group`,children:[o,s]}),t[32]=o,t[33]=s,t[34]=c):c=t[34];let l;return t[35]!==a||t[36]!==c?(l=(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[a,c]}),t[35]=a,t[36]=c,t[37]=l):l=t[37],l});function m9(e){let t=(0,Y.c)(7),{heading:n,text:r}=e,i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,Z.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-sm text-fg`,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function h9(e){let t=(0,Y.c)(21),{items:n,heading:r,moreSuffix:i}=e,a,o,s,c,l;t[0]!==r||t[1]!==n?(l=n.slice(0,p9),s=`min-w-0`,t[7]===r?c=t[8]:(c=(0,Z.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:r}),t[7]=r,t[8]=c),a=`space-y-1`,o=l.map(bSe),t[0]=r,t[1]=n,t[2]=a,t[3]=o,t[4]=s,t[5]=c,t[6]=l):(a=t[2],o=t[3],s=t[4],c=t[5],l=t[6]);let u;t[9]!==a||t[10]!==o?(u=(0,Z.jsx)(`ul`,{className:a,children:o}),t[9]=a,t[10]=o,t[11]=u):u=t[11];let d;t[12]!==n.length||t[13]!==i||t[14]!==l.length?(d=n.length>l.length?(0,Z.jsx)(`div`,{className:`mt-1 pl-1 text-xs text-fg-disabled`,children:i(n.length-l.length)}):null,t[12]=n.length,t[13]=i,t[14]=l.length,t[15]=d):d=t[15];let f;return t[16]!==s||t[17]!==c||t[18]!==u||t[19]!==d?(f=(0,Z.jsxs)(`div`,{className:s,children:[c,u,d]}),t[16]=s,t[17]=c,t[18]=u,t[19]=d,t[20]=f):f=t[20],f}function bSe(e,t){return(0,Z.jsx)(xSe,{item:e},t)}function xSe(e){let t=(0,Y.c)(21),{item:n}=e,r=vSe(n.severity),i=r===`high`?`bg-rose-500/15 text-rose-700 dark:text-rose-300`:r===`med`?`bg-amber-500/15 text-amber-700 dark:text-amber-300`:`bg-surface-hover text-fg-muted`,a=n.file?n.line===void 0?n.file:`${n.file}:${n.line}`:n.source??``,o=n.dimension??n.lens??``,s;t[0]!==n.severity||t[1]!==i?(s=n.severity?(0,Z.jsx)(`span`,{className:X(`mt-0.5 shrink-0 rounded px-1.5 py-px text-[10px] font-medium uppercase`,i),children:String(n.severity).slice(0,4)}):(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0 text-fg-disabled`,children:`•`}),t[0]=n.severity,t[1]=i,t[2]=s):s=t[2];let c;t[3]===o?c=t[4]:(c=o?(0,Z.jsx)(`span`,{className:`mr-1.5 text-xs text-fg-subtle`,children:o}):null,t[3]=o,t[4]=c);let l=n.title??n.reason??`(no title)`,u;t[5]===l?u=t[6]:(u=(0,Z.jsx)(`span`,{className:`text-fg`,children:l}),t[5]=l,t[6]=u);let d;t[7]!==c||t[8]!==u?(d=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[c,u]}),t[7]=c,t[8]=u,t[9]=d):d=t[9];let f;t[10]===a?f=t[11]:(f=a?(0,Z.jsx)(`div`,{className:`truncate font-mono text-xs text-fg-subtle`,title:a,children:a}):null,t[10]=a,t[11]=f);let p;t[12]===n.fix?p=t[13]:(p=n.fix?(0,Z.jsxs)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:[`↳ `,n.fix]}):null,t[12]=n.fix,t[13]=p);let m;t[14]!==d||t[15]!==f||t[16]!==p?(m=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[d,f,p]}),t[14]=d,t[15]=f,t[16]=p,t[17]=m):m=t[17];let h;return t[18]!==s||t[19]!==m?(h=(0,Z.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2 text-sm`,children:[s,m]}),t[18]=s,t[19]=m,t[20]=h):h=t[20],h}function g9(e){let t=(0,Y.c)(10),{value:n,heading:r,hideHeading:i}=e,a;try{let e;t[0]===n?e=t[1]:(e=JSON.stringify(n,null,2),t[0]=n,t[1]=e),a=e}catch{a=String(n)}let o;t[2]!==r||t[3]!==i?(o=i?null:(0,Z.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:r}),t[2]=r,t[3]=i,t[4]=o):o=t[4];let s;t[5]===a?s=t[6]:(s=(0,Z.jsx)(`pre`,{className:`max-h-72 min-w-0 overflow-y-auto whitespace-pre-wrap break-words rounded-md bg-surface-hover/60 p-2 font-mono text-xs text-fg-muted dark:bg-surface-hover/35`,children:a}),t[5]=a,t[6]=s);let c;return t[7]!==o||t[8]!==s?(c=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function _9(e){return Array.isArray(e)&&e.length>0?e:null}function SSe(e){if(!Array.isArray(e))return null;let t=e.filter(e=>typeof e==`string`&&e.trim().length>0);return t.length>0?t:null}function CSe(e,t){return(0,Z.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-fg-disabled`,children:`•`}),(0,Z.jsx)(`span`,{className:`min-w-0 break-words`,children:e})]},t)}var wSe=(0,J.memo)(function({block:e,startedAt:t,onAbort:n,onSendChatMessage:r,labels:i,className:a}){let o=gSe(e),s=(0,J.useMemo)(()=>hSe(e),[e]),c=o===`failed`?l9(e):null,l=o===`failed`?u9(e):``,[u,d]=(0,J.useState)(!1);(0,J.useEffect)(()=>{o===`completed`&&d(!0),(o===`running`||o===`failed`)&&d(!1)},[o]);let[f,p]=(0,J.useState)(!1),[,m]=(0,J.useState)(0);(0,J.useEffect)(()=>{if(o!==`running`)return;let e=window.setInterval(()=>m(e=>e+1),1e3);return()=>window.clearInterval(e)},[o]);let h=(0,J.useMemo)(()=>o===`running`?t?f9(Date.now()-t):``:s?.durationMs==null?``:f9(s.durationMs),[o,t,s?.durationMs]),[g,_]=(0,J.useState)(!1),v=(0,J.useCallback)(async()=>{s&&await lH(typeof s.result==`string`?s.result:DSe(s.result))&&(_(!0),window.setTimeout(()=>_(!1),1500))},[s]),[y,b]=(0,J.useState)(!1),[x,S]=(0,J.useState)(``),C=(0,J.useRef)(null);(0,J.useEffect)(()=>{y&&(x||S(s?.name??``),window.setTimeout(()=>C.current?.focus(),0))},[y,x,s?.name]);let w=(0,J.useCallback)(()=>{let e=x.trim();!e||!r||(r(`/workflow save ${e}`),b(!1))},[x,r]);if(o===`failed`||o===`completed`&&!s){let t=c??l9(e),n=ESe(e);return(0,Z.jsx)(lSe,{kind:t,reason:l||`workflow failed`,scriptPreview:n,labels:i.error,className:a})}let T=s?.agentCount??0,E=s?.doneCount??0,D=s?_Se(s):{phases:[],unphased:null},O=(0,Z.jsxs)(Z.Fragment,{children:[o===`running`&&n?(0,Z.jsx)(`button`,{type:`button`,onClick:n,className:X(`inline-flex size-7 items-center justify-center rounded-md text-fg-muted`,`hover:bg-surface-hover hover:text-rose-600 dark:hover:text-rose-400`,AX.transition,AX.focusRingPanel),"aria-label":i.cancel,title:i.cancel,children:(0,Z.jsx)(Gl,{className:`size-4`})}):null,o===`completed`&&s?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`button`,{type:`button`,onClick:v,className:X(`inline-flex size-7 items-center justify-center rounded-md text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,AX.transition,AX.focusRingPanel),"aria-label":g?i.copyDoneAria:i.copyAria,title:g?i.copyDoneAria:i.copyAria,children:g?(0,Z.jsx)(Ml,{className:`size-4 text-emerald-600 dark:text-emerald-400`}):(0,Z.jsx)(tu,{className:`size-4`})}),r?(0,Z.jsx)(`button`,{type:`button`,onClick:()=>b(e=>!e),className:X(`inline-flex size-7 items-center justify-center rounded-md text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,AX.transition,AX.focusRingPanel),"aria-label":i.saveAria,title:i.saveTitle,children:(0,Z.jsx)(ub,{className:`size-4`})}):null,(0,Z.jsx)(`button`,{type:`button`,className:X(`inline-flex size-7 items-center justify-center rounded-md text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,AX.transition,AX.focusRingPanel,`invisible`),"aria-label":i.moreAria,title:i.moreAria,children:(0,Z.jsx)(ud,{className:`size-4`})})]}):null]});return(0,Z.jsxs)(`div`,{className:X(`min-w-0 rounded-xl border border-edge bg-surface-panel shadow-surface`,a),role:`group`,"aria-label":s?`Workflow ${s.name}`:`Workflow`,children:[(0,Z.jsx)(sSe,{name:s?.name??e.name,description:s?.description,status:o,doneCount:E,totalCount:T,durationText:h,collapsed:u,onToggleCollapsed:()=>d(e=>!e),actions:O,labels:i.header}),y&&o===`completed`?(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 border-b border-edge-subtle px-3 py-2`,children:[(0,Z.jsx)(`input`,{ref:C,type:`text`,value:x,onChange:e=>S(e.target.value),onKeyDown:e=>{e.key===`Enter`?w():e.key===`Escape`&&b(!1)},placeholder:i.savePlaceholder,className:X(`min-w-0 flex-1 rounded-md border border-edge bg-surface-base px-2 py-1 text-sm text-fg`,`placeholder:text-fg-disabled`,AX.focusRingPanel)}),(0,Z.jsx)(`button`,{type:`button`,onClick:w,disabled:!x.trim(),className:X(`inline-flex h-7 items-center rounded-md bg-accent px-2.5 text-xs font-medium text-fg-onAccent`,`hover:bg-accent-hover`,AX.transition,AX.focusRingPanel,AX.disabled),children:i.saveSubmit}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>b(!1),className:X(`inline-flex h-7 items-center rounded-md px-2 text-xs text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,AX.transition,AX.focusRingPanel),children:i.saveCancel})]}):null,u?null:(0,Z.jsxs)(`div`,{className:`space-y-3 px-3 py-2.5`,children:[o===`completed`&&s?(0,Z.jsx)(ySe,{result:s.result,labels:i.result}):null,o===`running`&&s?(0,Z.jsx)(v9,{rollup:D,currentPhase:s.currentPhase,labels:i.phase,recentLogs:s.logs.slice(-2),recentLogsHeading:i.recentLogsHeading}):null,o===`running`&&!s?(0,Z.jsxs)(`div`,{className:`py-1 text-sm text-fg-subtle`,children:[(0,Z.jsx)(`span`,{className:`inline-block size-2 animate-pulse rounded-full bg-accent align-middle`}),(0,Z.jsx)(`span`,{className:`ml-2 align-middle`,children:i.viewSubagentsHeading})]}):null,o===`completed`&&s&&(D.phases.length>0||D.unphased)?(0,Z.jsxs)(`details`,{className:`group`,open:f,onToggle:e=>p(e.target.open),children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer select-none text-xs text-fg-subtle underline-offset-2 hover:text-fg-muted`,children:i.viewSubagentsHeading}),(0,Z.jsx)(`div`,{className:`mt-2`,children:(0,Z.jsx)(v9,{rollup:D,currentPhase:void 0,labels:i.phase,recentLogs:[],recentLogsHeading:i.recentLogsHeading})})]}):null]})]})});function v9(e){let t=(0,Y.c)(17),{rollup:n,currentPhase:r,labels:i,recentLogs:a,recentLogsHeading:o}=e,s;if(t[0]!==r||t[1]!==i||t[2]!==n.phases){let e;t[4]!==r||t[5]!==i?(e=e=>(0,Z.jsx)(o9,{rollup:e,isCurrent:e.title===r,labels:i},e.title),t[4]=r,t[5]=i,t[6]=e):e=t[6],s=n.phases.map(e),t[0]=r,t[1]=i,t[2]=n.phases,t[3]=s}else s=t[3];let c;t[7]!==i||t[8]!==n.unphased?(c=n.unphased?(0,Z.jsx)(o9,{rollup:n.unphased,isCurrent:!1,labels:i}):null,t[7]=i,t[8]=n.unphased,t[9]=c):c=t[9];let l;t[10]!==a||t[11]!==o?(l=a.length>0?(0,Z.jsxs)(`div`,{className:`mt-2 border-t border-edge-subtle pt-2`,children:[(0,Z.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:o}),(0,Z.jsx)(`div`,{className:`space-y-0.5`,children:a.map(TSe)})]}):null,t[10]=a,t[11]=o,t[12]=l):l=t[12];let u;return t[13]!==s||t[14]!==c||t[15]!==l?(u=(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[s,c,l]}),t[13]=s,t[14]=c,t[15]=l,t[16]=u):u=t[16],u}function TSe(e,t){return(0,Z.jsx)(`div`,{className:`truncate font-mono text-xs text-fg-subtle`,children:e},t)}function ESe(e){if(!e.input||typeof e.input!=`object`)return;let t=e.input;if(typeof t.script==`string`&&t.script.trim())return t.script.split(`
4699
4699
  `).slice(0,80).join(`
4700
- `)}function DSe(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function OSe(e){return e===`zh`?ASe():y9()}function kSe(){return y9()}function y9(){return{header:{collapse:`Collapse`,expand:`Expand`,runningMeta:(e,t)=>t?`${e} · ${t}`:`${e}`,completedMeta:(e,t)=>t?`✓ ${e} · ${t}`:`✓ ${e}`,failedMeta:`failed`},phase:{countTpl:(e,t)=>`${e}/${t}`,runningTag:e=>`· ${e} running`,errorsTag:e=>`· ${e} errors`,skippedTag:e=>`· ${e} skipped`,showPrompt:`Show prompt`,hidePrompt:`Hide prompt`,promptHeading:`Prompt`,resultPreviewHeading:`Result`,errorHeading:`Error`,emptyPreview:`(no preview)`,agentNumber:e=>`#${e}`},result:{topFindingsHeading:e=>`Top findings (${e})`,topRisksHeading:e=>`Top risks (${e})`,executiveSummaryHeading:`Executive summary`,summaryHeading:`Summary`,openQuestionsHeading:`Open questions`,moreSuffix:e=>`${e} more…`,rawHeading:`View raw result`,emptyResult:`(no result)`},error:{titleParse:`Workflow parse error`,titleAbort:`Workflow aborted`,titleTimeout:`Workflow timed out`,titleRuntime:`Workflow failed`,viewScriptHeading:`View submitted script`},cancel:`Cancel workflow`,saveAria:`Save workflow…`,saveTitle:`Save this workflow under a name (~/.xopc/workflows/)`,savePlaceholder:`snake_case_name`,saveSubmit:`Save`,saveCancel:`Cancel`,saveDispatched:`Saved`,copyAria:`Copy result`,copyDoneAria:`Copied`,moreAria:`More actions`,viewSubagentsHeading:`View subagents`,recentLogsHeading:`Logs`}}function ASe(){return{header:{collapse:`收起`,expand:`展开`,runningMeta:(e,t)=>t?`${e} · ${t}`:`${e}`,completedMeta:(e,t)=>t?`✓ ${e} · ${t}`:`✓ ${e}`,failedMeta:`失败`},phase:{countTpl:(e,t)=>`${e}/${t}`,runningTag:e=>`· ${e} 运行中`,errorsTag:e=>`· ${e} 失败`,skippedTag:e=>`· ${e} 已跳过`,showPrompt:`查看 prompt`,hidePrompt:`收起 prompt`,promptHeading:`Prompt`,resultPreviewHeading:`结果预览`,errorHeading:`错误`,emptyPreview:`(暂无预览)`,agentNumber:e=>`#${e}`},result:{topFindingsHeading:e=>`主要发现(${e})`,topRisksHeading:e=>`主要风险(${e})`,executiveSummaryHeading:`摘要`,summaryHeading:`总结`,openQuestionsHeading:`待解决的问题`,moreSuffix:e=>`还有 ${e} 条…`,rawHeading:`查看原始结果`,emptyResult:`(无结果)`},error:{titleParse:`工作流解析失败`,titleAbort:`工作流已中止`,titleTimeout:`工作流超时`,titleRuntime:`工作流执行失败`,viewScriptHeading:`查看提交的脚本`},cancel:`取消工作流`,saveAria:`保存工作流…`,saveTitle:`把这个工作流保存到 ~/.xopc/workflows/`,savePlaceholder:`snake_case 名字`,saveSubmit:`保存`,saveCancel:`取消`,saveDispatched:`已保存`,copyAria:`复制结果`,copyDoneAria:`已复制`,moreAria:`更多操作`,viewSubagentsHeading:`查看子 agent`,recentLogsHeading:`日志`}}function jSe(e,t,n,r,i,a){if(e.type===`text`)return n?(0,Z.jsx)(`div`,{className:`min-w-0`,children:(0,Z.jsx)(iSe,{text:dR(JL(e.text??``))})},t):(0,Z.jsx)(`div`,{className:`markdown-content min-w-0`,children:(0,Z.jsx)(OX,{content:e.text,compact:!0})},t);if(e.type===`image`&&e.source?.data){let n=a??0;return i?(0,Z.jsx)(`button`,{type:`button`,className:X(`inline-block max-w-full rounded-lg p-0 text-left`,AX.press,AX.focusRingPanel,`cursor-pointer`),onClick:()=>i(e,n),title:r,"aria-label":r,children:(0,Z.jsx)(`img`,{src:e.source.data,className:`max-h-96 max-w-full rounded-lg align-top`,alt:``})},t):(0,Z.jsx)(`img`,{src:e.source.data,className:`max-h-96 max-w-full rounded-lg`,alt:``},t)}return null}function MSe(e,t){for(let n=t;n<e.length;n++){let t=e[n];if(t.type===`text`&&(t.text??``).length>0)return!0}return!1}function NSe(e,t,n,r,i,a,o,s,c,l,u){let d=[],f=u??{},p=f.labels??kSe(),m=0,h=0;for(;m<e.length;){let u=e[m];if(u.type===`tool_use`&&s9(u)){d.push((0,Z.jsx)(wSe,{block:u,startedAt:f.getStartedAt?.(u),onAbort:f.onAbort,onSendChatMessage:f.onSendChatMessage,labels:p},`workflow-${u.id??m}`)),m++;continue}if(u.type===`thinking`||u.type===`tool_use`){let s=m;for(;m<e.length;){let t=e[m];if(t.type===`thinking`){m++;continue}if(t.type===`tool_use`&&!s9(t)){m++;continue}break}let c=e.slice(s,m);if(c.length>0){let u=!t&&MSe(e,m);d.push((0,Z.jsx)(Mxe,{blocks:c,toolLabels:r,stepLabels:i,clusterLabels:a,cardLabels:o,sessionKey:l,isMessageStreaming:!t&&n,finalAnswerStarted:u},`steps-${s}`))}}else{let e=u.type===`image`?h++:0,n=jSe(u,`block-${m}`,t,s,c,u.type===`image`?e:m);n&&d.push(n),m++}}return d}function b9(e){let t=(0,Y.c)(28),{open:n,title:r,description:i,confirmLabel:a,cancelLabel:o,destructive:s,onConfirm:c,onCancel:l}=e,u;t[0]===l?u=t[1]:(u=e=>{e||l()},t[0]=l,t[1]=u);let d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(ie,{className:X(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,v8)}),t[2]=d):d=t[2];let f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=X(`fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,y8,`rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),t[3]=f):f=t[3];let p;t[4]===r?p=t[5]:(p=(0,Z.jsx)(ue,{className:`text-base font-semibold text-fg`,children:r}),t[4]=r,t[5]=p);let m;t[6]===i?m=t[7]:(m=(0,Z.jsx)(le,{className:`mt-2 max-h-[min(50vh,16rem)] overflow-y-auto text-sm text-fg-muted whitespace-pre-wrap break-all`,children:i}),t[6]=i,t[7]=m);let h;t[8]!==o||t[9]!==l?(h=(0,Z.jsx)(wA,{type:`button`,variant:`secondary`,onClick:l,children:o}),t[8]=o,t[9]=l,t[10]=h):h=t[10];let g=s&&`border-danger/40 bg-danger text-white hover:bg-danger/90 dark:border-danger/40`,_;t[11]===g?_=t[12]:(_=X(g),t[11]=g,t[12]=_);let v;t[13]!==a||t[14]!==c||t[15]!==_?(v=(0,Z.jsx)(wA,{type:`button`,variant:`secondary`,className:_,onClick:c,children:a}),t[13]=a,t[14]=c,t[15]=_,t[16]=v):v=t[16];let y;t[17]!==h||t[18]!==v?(y=(0,Z.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[h,v]}),t[17]=h,t[18]=v,t[19]=y):y=t[19];let b;t[20]!==y||t[21]!==p||t[22]!==m?(b=(0,Z.jsxs)(G,{children:[d,(0,Z.jsxs)(se,{className:f,children:[p,m,y]})]}),t[20]=y,t[21]=p,t[22]=m,t[23]=b):b=t[23];let x;return t[24]!==n||t[25]!==u||t[26]!==b?(x=(0,Z.jsx)(q,{open:n,onOpenChange:u,children:b}),t[24]=n,t[25]=u,t[26]=b,t[27]=x):x=t[27],x}function x9(e){return e?new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}):``}var S9=X(`inline-flex size-9 shrink-0 items-center justify-center rounded-lg`,`text-fg-muted transition-colors transition-transform duration-150 ease-out`,`hover:bg-surface-hover hover:text-fg active:scale-95`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,AX.disabled),C9=X(`inline-flex h-8 shrink-0 items-center justify-center gap-1 rounded-md px-2 text-xs text-fg-muted transition-colors`,`hover:bg-surface-hover hover:text-fg active:scale-[0.98]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,AX.disabled),PSe=(0,J.memo)(function(e){let t=(0,Y.c)(202),{message:n,authToken:r,sessionKey:i,isStreaming:a,progress:o,reasoningLevel:s,messageIndex:c,onDeleteRound:l,onRetryUserMessageRound:u,userMessageCanRetry:f,deleteRoundDisabled:p,onAbortCurrentTurn:h,onSendUserMessage:g}=e,_=s===void 0?`stream`:s,v=f===void 0?!1:f,y=p===void 0?!1:p,b=d(FSe),x;t[0]===b?x=t[1]:(x=m(b),t[0]=b,t[1]=x);let S=x,C=n.role===`user`||n.role===`user-with-attachments`,w=n.role===`assistant`,T=C?S.chat.you:w?S.chat.assistant:S.chat.tool,E;t[2]!==S.chat.noOutput||t[3]!==S.chat.toolInput||t[4]!==S.chat.toolOutput?(E={input:S.chat.toolInput,output:S.chat.toolOutput,noOutput:S.chat.noOutput},t[2]=S.chat.noOutput,t[3]=S.chat.toolInput,t[4]=S.chat.toolOutput,t[5]=E):E=t[5];let D=E,O;t[6]!==S.chat.stepDetails||t[7]!==S.chat.stepEditFile||t[8]!==S.chat.stepFetchUrl||t[9]!==S.chat.stepListDirectory||t[10]!==S.chat.stepOpenUrl||t[11]!==S.chat.stepReadFile||t[12]!==S.chat.stepRunCommand||t[13]!==S.chat.stepSearchedWeb||t[14]!==S.chat.stepUnknownTool||t[15]!==S.chat.stepWriteFile||t[16]!==S.chat.thoughts||t[17]!==S.chat.thoughtsStreaming||t[18]!==S.chat.viewSteps_one||t[19]!==S.chat.viewSteps_other?(O={thoughts:S.chat.thoughts,thoughtsStreaming:S.chat.thoughtsStreaming,viewSteps_one:S.chat.viewSteps_one,viewSteps_other:S.chat.viewSteps_other,searchedWeb:S.chat.stepSearchedWeb,readFile:S.chat.stepReadFile,stepDetails:S.chat.stepDetails,runCommand:S.chat.stepRunCommand,listDirectory:S.chat.stepListDirectory,writeFile:S.chat.stepWriteFile,editFile:S.chat.stepEditFile,openUrl:S.chat.stepOpenUrl,fetchUrl:S.chat.stepFetchUrl,unknownTool:S.chat.stepUnknownTool},t[6]=S.chat.stepDetails,t[7]=S.chat.stepEditFile,t[8]=S.chat.stepFetchUrl,t[9]=S.chat.stepListDirectory,t[10]=S.chat.stepOpenUrl,t[11]=S.chat.stepReadFile,t[12]=S.chat.stepRunCommand,t[13]=S.chat.stepSearchedWeb,t[14]=S.chat.stepUnknownTool,t[15]=S.chat.stepWriteFile,t[16]=S.chat.thoughts,t[17]=S.chat.thoughtsStreaming,t[18]=S.chat.viewSteps_one,t[19]=S.chat.viewSteps_other,t[20]=O):O=t[20];let k=O,A;t[21]!==S.chat.stepsClusterJoin||t[22]!==S.chat.stepsClusterJoinFinal||t[23]!==S.chat.stepsClusterMoreSuffix?(A={join:S.chat.stepsClusterJoin,joinFinal:S.chat.stepsClusterJoinFinal,moreSuffix:S.chat.stepsClusterMoreSuffix},t[21]=S.chat.stepsClusterJoin,t[22]=S.chat.stepsClusterJoinFinal,t[23]=S.chat.stepsClusterMoreSuffix,t[24]=A):A=t[24];let j;t[25]!==S.chat.stepsClusterDone||t[26]!==S.chat.stepsClusterIng||t[27]!==A?(j={done:S.chat.stepsClusterDone,ing:S.chat.stepsClusterIng,join:A},t[25]=S.chat.stepsClusterDone,t[26]=S.chat.stepsClusterIng,t[27]=A,t[28]=j):j=t[28];let M=j,N=S.chat.toolCard,P=_===`off`,F;bb0:{if(!P){let e;t[29]===n.content?e=t[30]:(e=n.content??[],t[29]=n.content,t[30]=e),F=e;break bb0}let e;t[31]===n.content?e=t[32]:(e=n.content??[],t[31]=n.content,t[32]=e);let r;t[33]===e?r=t[34]:(r=e.filter(ISe),t[33]=e,t[34]=r),F=r}let I=F,L;bb1:{if(!w){L=I;break bb1}let e;t[35]===I?e=t[36]:(e=I??[],t[35]=I,t[36]=e);let n;t[37]===e?n=t[38]:(n=e.filter(LSe),t[37]=e,t[38]=n),L=n}let R=L,z;t[39]!==w||t[40]!==n.content?(z=w?_be(n.content):[],t[39]=w,t[40]=n.content,t[41]=z):z=t[41];let B=z,V;t[42]!==w||t[43]!==n.content?(V=w?(n.content??[]).filter(RSe):[],t[42]=w,t[43]=n.content,t[44]=V):V=t[44];let H=V,U;t[45]!==H||t[46]!==w?(U=w?vbe(H):[],t[45]=H,t[46]=w,t[47]=U):U=t[47];let W=U,G=w&&(B.length>0||W.length>0),ee;bb2:{if(!w){ee=n.attachments;break bb2}let e;t[48]!==B||t[49]!==n.attachments?(e=hbe(n.attachments,B),t[48]=B,t[49]=n.attachments,t[50]=e):e=t[50],ee=e}let K=ee,te=P&&o?.stage===`thinking`?null:o,ne;t[51]!==n.content||t[52]!==P?(ne=P?!1:!!n.content?.some(zSe),t[51]=n.content,t[52]=P,t[53]=ne):ne=t[53];let re=ne,ie=!!n.timestamp||!!te?.message||a&&!re,ae;t[54]!==w||t[55]!==n.content?(ae=w?Qxe(n.content??[]):``,t[54]=w,t[55]=n.content,t[56]=ae):ae=t[56];let oe=ae,se;t[57]!==oe||t[58]!==w||t[59]!==n.content?(se=w&&oe?eSe(n.content??[]):``,t[57]=oe,t[58]=w,t[59]=n.content,t[60]=se):se=t[60];let q=se,ce;bb3:{if(!C){ce=``;break bb3}let e;t[61]===n.content?e=t[62]:(e=fR(n.content),t[61]=n.content,t[62]=e),ce=e}let le=ce,[ue,de]=(0,J.useState)(null),[fe,pe]=(0,J.useState)(!1),[me,he]=(0,J.useState)(null),ge;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(e,t)=>{let n=g7(e,t);n&&he(n)},t[63]=ge):ge=t[63];let _e=ge,ve;t[64]===q?ve=t[65]:(ve=()=>{q&&lH(q).then(e=>{e&&(de(`plain`),window.setTimeout(()=>de(BSe),2e3))})},t[64]=q,t[65]=ve);let ye=ve,be;t[66]===oe?be=t[67]:(be=()=>{oe&&lH(oe).then(e=>{e&&(de(`markdown`),window.setTimeout(()=>de(VSe),2e3))})},t[66]=oe,t[67]=be);let xe=be,Se;t[68]===le?Se=t[69]:(Se=()=>{le&&lH(le).then(e=>{e&&(de(`user`),window.setTimeout(()=>de(HSe),2e3))})},t[68]=le,t[69]=Se);let Ce=Se,we;t[70]!==c||t[71]!==l?(we=()=>{c==null||!l||pe(!0)},t[70]=c,t[71]=l,t[72]=we):we=t[72];let Te=we,Ee;t[73]!==c||t[74]!==l?(Ee=()=>{c==null||!l||(l(c),pe(!1))},t[73]=c,t[74]=l,t[75]=Ee):Ee=t[75];let De=Ee,Oe;t[76]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=()=>{pe(!1)},t[76]=Oe):Oe=t[76];let ke=Oe,Ae;if(t[77]!==n||t[78]!==P){bb4:{let e=Nxe(n);if(P){Ae=e.filter(USe);break bb4}Ae=e}t[77]=n,t[78]=P,t[79]=Ae}else Ae=t[79];let je=Ae,Me=y||!v,Ne=C?`justify-end`:`justify-start`,Pe;t[80]===Ne?Pe=t[81]:(Pe=X(`group/msg flex w-full min-w-0`,Ne),t[80]=Ne,t[81]=Pe);let Fe=C?`flex w-full flex-col items-end`:`w-full`,Ie;t[82]===Fe?Ie=t[83]:(Ie=X(`min-w-0 max-w-[min(85%,var(--max-width-chat))]`,Fe),t[82]=Fe,t[83]=Ie);let Le;t[84]===T?Le=t[85]:(Le=(0,Z.jsx)(`span`,{className:`sr-only`,children:T}),t[84]=T,t[85]=Le);let Re;t[86]!==a||t[87]!==C||t[88]!==S.chat.thinkingLabel||t[89]!==n.timestamp||t[90]!==te||t[91]!==ie||t[92]!==re?(Re=C&&ie?(0,Z.jsxs)(`div`,{className:`mb-2 flex w-full min-w-0 flex-wrap items-center justify-end gap-x-2 gap-y-0.5 text-xs`,children:[n.timestamp?(0,Z.jsx)(`time`,{suppressHydrationWarning:!0,className:`shrink-0 tabular-nums text-fg-disabled`,dateTime:new Date(n.timestamp).toISOString(),children:x9(n.timestamp)}):null,te?.message?(0,Z.jsx)(`span`,{className:`text-fg-subtle`,title:te.detail??``,children:te.message}):null,a&&!re&&!te?.message?(0,Z.jsx)(`span`,{className:`text-fg-subtle`,children:S.chat.thinkingLabel}):null]}):null,t[86]=a,t[87]=C,t[88]=S.chat.thinkingLabel,t[89]=n.timestamp,t[90]=te,t[91]=ie,t[92]=re,t[93]=Re):Re=t[93];let ze;t[94]!==a||t[95]!==C||t[96]!==S.chat.thinkingLabel||t[97]!==n.timestamp||t[98]!==te||t[99]!==ie||t[100]!==re?(ze=!C&&ie?(0,Z.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-baseline gap-x-2 gap-y-0.5 text-xs text-fg-disabled`,children:[n.timestamp?(0,Z.jsx)(`time`,{suppressHydrationWarning:!0,className:`tabular-nums`,dateTime:new Date(n.timestamp).toISOString(),children:x9(n.timestamp)}):null,te?.message?(0,Z.jsx)(`span`,{className:`text-fg-subtle`,title:te.detail??``,children:te.message}):null,a&&!re&&!te?.message?(0,Z.jsx)(`span`,{className:`text-fg-subtle`,children:S.chat.thinkingLabel}):null]}):null,t[94]=a,t[95]=C,t[96]=S.chat.thinkingLabel,t[97]=n.timestamp,t[98]=te,t[99]=ie,t[100]=re,t[101]=ze):ze=t[101];let Be=C?`ltr`:void 0,Ve=C&&`w-fit max-w-full rounded-xl border border-edge-subtle/70 bg-surface-hover/90 px-4 py-3 text-left shadow-sm dark:border-edge-subtle dark:bg-surface-hover/50`,He;t[102]===Ve?He=t[103]:(He=X(`min-w-0 text-sm leading-relaxed text-fg`,Ve),t[102]=Ve,t[103]=He);let Ue;t[104]!==N||t[105]!==M||t[106]!==R||t[107]!==w||t[108]!==a||t[109]!==C||t[110]!==b||t[111]!==S.chat.attachmentPreviewImage||t[112]!==h||t[113]!==g||t[114]!==i||t[115]!==k||t[116]!==D?(Ue=(R?.length??0)>0?(0,Z.jsxs)(Z.Fragment,{children:[NSe(R,C,w&&a,D,k,M,N,S.chat.attachmentPreviewImage,_e,i,{labels:OSe(b),onAbort:w&&a?h:void 0,onSendChatMessage:g}),a?(0,Z.jsx)(`span`,{className:`inline-block h-3 w-0.5 animate-pulse bg-accent align-middle`}):null]}):a?(0,Z.jsx)(`span`,{className:`inline-block h-3 w-0.5 animate-pulse bg-accent`}):null,t[104]=N,t[105]=M,t[106]=R,t[107]=w,t[108]=a,t[109]=C,t[110]=b,t[111]=S.chat.attachmentPreviewImage,t[112]=h,t[113]=g,t[114]=i,t[115]=k,t[116]=D,t[117]=Ue):Ue=t[117];let We;t[118]!==w||t[119]!==je?(We=w&&je.length>0?(0,Z.jsx)(Jxe,{blocks:je}):null,t[118]=w,t[119]=je,t[120]=We):We=t[120];let Ge;t[121]!==W||t[122]!==B||t[123]!==r||t[124]!==S.chat.messageArtifactsHeading||t[125]!==i||t[126]!==G?(Ge=G?(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle/60 bg-surface-elevated/20 px-3 py-2.5`,role:`group`,"aria-label":S.chat.messageArtifactsHeading,children:[(0,Z.jsx)(`div`,{className:`mb-1.5 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:S.chat.messageArtifactsHeading}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[B.length>0?(0,Z.jsx)(J7,{paths:B,sessionKey:i}):null,W.length>0?(0,Z.jsx)(a9,{attachments:W,authToken:r,sessionKey:i,layout:`assistant`}):null]})]}):null,t[121]=W,t[122]=B,t[123]=r,t[124]=S.chat.messageArtifactsHeading,t[125]=i,t[126]=G,t[127]=Ge):Ge=t[127];let Ke;t[128]!==K||t[129]!==r||t[130]!==C||t[131]!==i||t[132]!==le?(Ke=K?.length?C?(0,Z.jsx)(a9,{attachments:K,authToken:r,sessionKey:i,layout:`user`,centerUserVoiceRow:le.length===0}):(0,Z.jsx)(a9,{attachments:K,authToken:r,sessionKey:i,layout:`assistant`}):null,t[128]=K,t[129]=r,t[130]=C,t[131]=i,t[132]=le,t[133]=Ke):Ke=t[133];let qe;t[134]!==Ue||t[135]!==We||t[136]!==Ge||t[137]!==Ke?(qe=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[Ue,We,Ge,Ke]}),t[134]=Ue,t[135]=We,t[136]=Ge,t[137]=Ke,t[138]=qe):qe=t[138];let Je;t[139]!==Be||t[140]!==He||t[141]!==qe?(Je=(0,Z.jsx)(`div`,{dir:Be,className:He,children:qe}),t[139]=Be,t[140]=He,t[141]=qe,t[142]=Je):Je=t[142];let Ye;t[143]!==ue||t[144]!==y||t[145]!==Ce||t[146]!==a||t[147]!==C||t[148]!==S.chat.messageCopied||t[149]!==S.chat.userMessageActionsWait||t[150]!==S.chat.userMessageCopy||t[151]!==S.chat.userMessageDelete||t[152]!==S.chat.userMessageEdit||t[153]!==S.chat.userMessageRetry||t[154]!==S.chat.userMessageRetryDisabledHint||t[155]!==c||t[156]!==l||t[157]!==u||t[158]!==Te||t[159]!==Me||t[160]!==le||t[161]!==v?(Ye=C&&!a?(0,Z.jsx)(`div`,{className:`mt-1.5 flex h-8 w-full min-w-0 shrink-0 justify-end`,children:(0,Z.jsxs)(`div`,{className:X(`flex h-full max-w-full items-center justify-end gap-0.5 sm:gap-2`,`pointer-events-none opacity-0 transition-opacity duration-150 ease-out`,`group-hover/msg:pointer-events-auto group-hover/msg:opacity-100`,`group-focus-within/msg:pointer-events-auto group-focus-within/msg:opacity-100`,`[@media(hover:none)_and_(pointer:coarse)]:pointer-events-auto [@media(hover:none)_and_(pointer:coarse)]:opacity-100`),children:[u&&c!=null?(0,Z.jsxs)(`button`,{type:`button`,className:X(C9,Me&&`opacity-40`),onClick:()=>u(c),disabled:Me,title:y?S.chat.userMessageActionsWait:v?S.chat.userMessageRetry:S.chat.userMessageRetryDisabledHint,"aria-label":S.chat.userMessageRetry,children:[(0,Z.jsx)(xy,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`max-w-[4.5rem] truncate sm:max-w-none`,children:S.chat.userMessageRetry})]}):null,(0,Z.jsx)(`button`,{type:`button`,className:X(C9,`size-8 px-0`),onClick:()=>x1(le),disabled:!le,title:S.chat.userMessageEdit,"aria-label":S.chat.userMessageEdit,children:(0,Z.jsx)(H_,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}),(0,Z.jsx)(`button`,{type:`button`,className:X(C9,`size-8 px-0`),onClick:Ce,disabled:!le,title:ue===`user`?S.chat.messageCopied:S.chat.userMessageCopy,"aria-label":ue===`user`?S.chat.messageCopied:S.chat.userMessageCopy,children:ue===`user`?(0,Z.jsx)(Ml,{className:`size-3.5 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(tu,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}),l&&c!=null&&!y?(0,Z.jsx)(`button`,{type:`button`,className:X(C9,`size-8 px-0 hover:text-red-500 dark:hover:text-red-400`),onClick:Te,title:S.chat.userMessageDelete,"aria-label":S.chat.userMessageDelete,children:(0,Z.jsx)(UT,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}):null]})}):null,t[143]=ue,t[144]=y,t[145]=Ce,t[146]=a,t[147]=C,t[148]=S.chat.messageCopied,t[149]=S.chat.userMessageActionsWait,t[150]=S.chat.userMessageCopy,t[151]=S.chat.userMessageDelete,t[152]=S.chat.userMessageEdit,t[153]=S.chat.userMessageRetry,t[154]=S.chat.userMessageRetryDisabledHint,t[155]=c,t[156]=l,t[157]=u,t[158]=Te,t[159]=Me,t[160]=le,t[161]=v,t[162]=Ye):Ye=t[162];let Xe;t[163]!==ue||t[164]!==oe||t[165]!==q||t[166]!==xe||t[167]!==ye||t[168]!==w||t[169]!==S.chat.messageCopied||t[170]!==S.chat.messageCopyMarkdown||t[171]!==S.chat.messageCopyPlainText?(Xe=w&&oe?(0,Z.jsxs)(`div`,{className:`mt-2 flex shrink-0 flex-wrap items-center gap-2 overflow-visible`,children:[(0,Z.jsx)(`button`,{type:`button`,className:S9,onClick:ye,disabled:!q,title:ue===`plain`?S.chat.messageCopied:S.chat.messageCopyPlainText,"aria-label":ue===`plain`?S.chat.messageCopied:S.chat.messageCopyPlainText,children:ue===`plain`?(0,Z.jsx)(Ml,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(tu,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),(0,Z.jsx)(`button`,{type:`button`,className:S9,onClick:xe,title:ue===`markdown`?S.chat.messageCopied:S.chat.messageCopyMarkdown,"aria-label":ue===`markdown`?S.chat.messageCopied:S.chat.messageCopyMarkdown,children:ue===`markdown`?(0,Z.jsx)(Ml,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(Hd,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})})]}):null,t[163]=ue,t[164]=oe,t[165]=q,t[166]=xe,t[167]=ye,t[168]=w,t[169]=S.chat.messageCopied,t[170]=S.chat.messageCopyMarkdown,t[171]=S.chat.messageCopyPlainText,t[172]=Xe):Xe=t[172];let Ze;t[173]!==Ie||t[174]!==Le||t[175]!==Re||t[176]!==ze||t[177]!==Je||t[178]!==Ye||t[179]!==Xe?(Ze=(0,Z.jsxs)(`div`,{className:Ie,children:[Le,Re,ze,Je,Ye,Xe]}),t[173]=Ie,t[174]=Le,t[175]=Re,t[176]=ze,t[177]=Je,t[178]=Ye,t[179]=Xe,t[180]=Ze):Ze=t[180];let Qe;t[181]!==De||t[182]!==fe||t[183]!==C||t[184]!==S.chat.userMessageDeleteCancel||t[185]!==S.chat.userMessageDeleteConfirm||t[186]!==S.chat.userMessageDeleteConfirmTitle||t[187]!==S.chat.userMessageDeleteOk||t[188]!==c||t[189]!==l?(Qe=C&&l&&c!=null?(0,Z.jsx)(b9,{open:fe,title:S.chat.userMessageDeleteConfirmTitle,description:S.chat.userMessageDeleteConfirm,confirmLabel:S.chat.userMessageDeleteOk,cancelLabel:S.chat.userMessageDeleteCancel,destructive:!0,onConfirm:De,onCancel:ke}):null,t[181]=De,t[182]=fe,t[183]=C,t[184]=S.chat.userMessageDeleteCancel,t[185]=S.chat.userMessageDeleteConfirm,t[186]=S.chat.userMessageDeleteConfirmTitle,t[187]=S.chat.userMessageDeleteOk,t[188]=c,t[189]=l,t[190]=Qe):Qe=t[190];let $e=me!==null,et;t[191]===Symbol.for(`react.memo_cache_sentinel`)?(et=()=>he(null),t[191]=et):et=t[191];let tt;t[192]!==r||t[193]!==me||t[194]!==i||t[195]!==$e?(tt=(0,Z.jsx)(t9,{open:$e,attachment:me,authToken:r,sessionKey:i,onClose:et}),t[192]=r,t[193]=me,t[194]=i,t[195]=$e,t[196]=tt):tt=t[196];let nt;return t[197]!==Pe||t[198]!==Ze||t[199]!==Qe||t[200]!==tt?(nt=(0,Z.jsxs)(`article`,{className:Pe,children:[Ze,Qe,tt]}),t[197]=Pe,t[198]=Ze,t[199]=Qe,t[200]=tt,t[201]=nt):nt=t[201],nt});function FSe(e){return e.language}function ISe(e){return e.type!==`thinking`}function LSe(e){return e.type!==`image`}function RSe(e){return e.type===`image`&&!!e.source?.data}function zSe(e){return e.type===`thinking`&&e.streaming}function BSe(e){return e===`plain`?null:e}function VSe(e){return e===`markdown`?null:e}function HSe(e){return e===`user`?null:e}function USe(e){return e.type!==`thinking`}var WSe=1.5;function w9(e){return e.scrollHeight-e.scrollTop-e.clientHeight}function T9(e){return w9(e)<=4}function GSe(e){return w9(e)<2}function KSe(e,t,n,r){if(!r)return!1;if(T9(e))return!0;let i=e.scrollHeight>n+1,a=e.scrollTop<t-WSe;return i&&!a}function qSe(e,t){return`${e.timestamp??`n`}-${t}`}var JSe=40,YSe=32,XSe=(0,J.memo)(function({messages:e,authToken:t,sessionKey:n,streaming:r,progress:i,reasoningLevel:a,scrollElementRef:o,pinToBottom:s,onPickWelcomePrompt:c,welcomeOverlay:l,onDeleteRound:u,onRetryUserMessageRound:f,deleteRoundDisabled:p,onAbortCurrentTurn:h,onSendUserMessage:g}){let _=m(d(e=>e.language)),v=e.length===0&&!r,y=Yye({count:v?0:e.length,enabled:!v,useFlushSync:!1,useAnimationFrameWithResizeObserver:!0,getScrollElement:()=>o.current,estimateSize:()=>200,gap:JSe,paddingEnd:YSe,overscan:8,getItemKey:t=>qSe(e[t],t),measureElement:J5}),b=(0,J.useRef)(null),x=(0,J.useRef)(s);x.current=s;let S=(0,J.useRef)(null),C=(0,J.useCallback)(()=>{let e=y.options.count;if(e===0)return;let t=o.current;if(!t){y.scrollToIndex(e-1,{align:`end`,behavior:`auto`});return}x.current&&(w9(t)<=1||(t.scrollTop=t.scrollHeight))},[y,o]),w=(0,J.useCallback)(()=>{S.current!=null&&cancelAnimationFrame(S.current),S.current=requestAnimationFrame(()=>{S.current=null,x.current&&C()})},[C]);return(0,J.useLayoutEffect)(()=>{!s||e.length===0||C()},[s,e.length,C]),(0,J.useEffect)(()=>{if(!s||e.length===0||r)return;let t=b.current;if(!t)return;let n=new ResizeObserver(()=>{w()});return n.observe(t),()=>{n.disconnect(),S.current!=null&&(cancelAnimationFrame(S.current),S.current=null)}},[s,e.length,w,r]),v?l?(0,Z.jsx)(`div`,{className:`flex w-full flex-col items-center pb-6 pt-4`,children:l}):c&&_.chat.welcomeSpotlight?(0,Z.jsx)(`div`,{className:`pb-1.5`,children:(0,Z.jsx)(Qye,{chat:_.chat,onPickPrompt:c})}):(0,Z.jsx)(`div`,{className:`flex flex-col gap-10 pb-8`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 py-20 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-4xl`,"aria-hidden":!0,children:`🤖`}),(0,Z.jsx)(`div`,{className:`text-xl font-semibold tracking-tight text-fg`,children:_.chat.welcomeTitle}),(0,Z.jsx)(`div`,{className:`max-w-sm text-sm leading-relaxed text-fg-muted`,children:_.chat.welcomeDescription})]})}):(0,Z.jsx)(`div`,{ref:b,className:`relative w-full min-w-0`,style:{height:y.getTotalSize()},children:y.getVirtualItems().map(o=>{let s=e[o.index];if(!s)return null;let c=o.index===e.length-1,l=!!(r&&c&&s.role===`assistant`);return(0,Z.jsx)(`div`,{"data-index":o.index,ref:y.measureElement,className:`absolute left-0 w-full min-w-0`,style:{top:o.start},children:(0,Z.jsx)(PSe,{message:s,authToken:t,sessionKey:n,isStreaming:l,progress:l?i:null,reasoningLevel:a,messageIndex:o.index,onDeleteRound:u,onRetryUserMessageRound:f,userMessageCanRetry:!!f&&pR(e,o.index),deleteRoundDisabled:p,onAbortCurrentTurn:h,onSendUserMessage:g})},o.key)})})}),ZSe=(0,J.memo)(function(e){let t=(0,Y.c)(7),{visible:n,onClick:r}=e,i=d(QSe),a;t[0]===i?a=t[1]:(a=m(i),t[0]=i,t[1]=a);let o=a;if(!n)return null;let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=X(`fixed bottom-[calc(11rem+env(safe-area-inset-bottom,0px))] right-6 z-20 flex size-11 items-center justify-center rounded-full border border-edge bg-surface-panel text-fg-subtle shadow-float`,`hover:bg-surface-hover hover:text-fg dark:border-edge dark:shadow-none md:right-10`,AX.transition,AX.press,AX.focusRingPanel),t[2]=s):s=t[2];let c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(Nl,{className:`size-6`,"aria-hidden":!0}),t[3]=c):c=t[3];let l;return t[4]!==o.chat.scrollToBottom||t[5]!==r?(l=(0,Z.jsx)(`button`,{type:`button`,className:s,onClick:r,title:o.chat.scrollToBottom,"aria-label":o.chat.scrollToBottom,children:c}),t[4]=o.chat.scrollToBottom,t[5]=r,t[6]=l):l=t[6],l});function QSe(e){return e.language}var E9=.5,D9=.75;function O9(e){return e.webkitDirectionInvertedFromDevice===!0?e.deltaY>0:e.deltaY<0}function $Se({hasToken:e,showSessionLoading:t,sessionKey:n,sending:r,chatMessages:i,hasMore:a,loadingMore:o,loadMoreMessages:s}){let c=(0,J.useRef)(null),[l,u]=(0,J.useState)(!0),d=(0,J.useRef)(!0),f=(0,J.useRef)(!0),p=(0,J.useRef)(!1),m=(0,J.useRef)({first:void 0,len:0,scrollHeight:0}),h=(0,J.useRef)(null),g=(0,J.useRef)(0),_=(0,J.useRef)(0);d.current=l;let v=e&&r&&!p.current&&!t;v&&(d.current=!0,l||u(!0)),p.current=r;let y=(0,J.useCallback)((e=!0,t=!1)=>{let n=c.current;if(!n)return;let r=w9(n);if(!t&&r>5){d.current&&(d.current=!1,u(!1));return}t&&!e&&(n.scrollTop=n.scrollHeight),requestAnimationFrame(()=>{n.scrollTo({top:n.scrollHeight,behavior:e?`smooth`:`auto`});let t=n.scrollHeight;requestAnimationFrame(()=>{c.current&&c.current.scrollHeight>t&&c.current.scrollTo({top:c.current.scrollHeight,behavior:e?`smooth`:`auto`})})})},[]),b=(0,J.useCallback)(()=>{let e=c.current;if(!e)return;let{scrollTop:t,scrollHeight:n}=e;d.current?T9(e)||(d.current=!1,u(!1)):GSe(e)&&(d.current=!0,u(!0)),g.current=t,_.current=n,t<100&&!d.current&&a&&!o&&s()},[a,o,s]),x=(0,J.useCallback)(()=>{d.current&&(d.current=!1,(0,J.startTransition)(()=>u(!1)))},[]),S=(0,J.useCallback)((e,t,n)=>KSe(e,t,n,d.current)?!0:(d.current&&(d.current=!1,u(!1)),!1),[]);return(0,J.useLayoutEffect)(()=>{if(!e)return;if(t){f.current=!0;return}if(f.current!==!0)return;f.current=!1,u(!0);let n=c.current;n&&(n.scrollTop=n.scrollHeight,g.current=n.scrollTop,_.current=n.scrollHeight),requestAnimationFrame(()=>{y(!1,!0),requestAnimationFrame(()=>y(!1,!0))})},[t,e,y]),(0,J.useLayoutEffect)(()=>{if(!e||t)return;m.current={first:void 0,len:0,scrollHeight:0},d.current=!0,u(!0);let n=c.current;n&&(n.scrollTop=n.scrollHeight,g.current=n.scrollTop,_.current=n.scrollHeight),requestAnimationFrame(()=>{y(!1,!0),requestAnimationFrame(()=>y(!1,!0))})},[n,e,t,y]),(0,J.useLayoutEffect)(()=>{v&&y(!1,!0)},[v,y]),(0,J.useLayoutEffect)(()=>{if(!e||t)return;let n=c.current;if(!n)return;let r=e=>{if(Math.abs(e.deltaY)<Math.abs(e.deltaX)||Math.abs(e.deltaY)<.25)return;if(d.current&&O9(e)){x();return}if(!d.current)return;let t=n.scrollTop,r=w9(n),i=()=>{let n=c.current;if(!n||!d.current)return;let i=n.scrollTop,a=w9(n);if(i<t-E9||a>r+D9){x();return}Math.abs(i-t)<E9&&Math.abs(a-r)<D9&&r<=4&&Math.abs(e.deltaY)>=.5&&O9(e)&&x()};requestAnimationFrame(()=>{requestAnimationFrame(i)})},i=0,a=e=>{e.touches.length===1&&(i=e.touches[0].clientY)},o=e=>{if(e.touches.length!==1)return;let t=e.touches[0].clientY,n=t-i;i=t,n>2&&x()};return n.addEventListener(`wheel`,r,{passive:!0}),n.addEventListener(`touchstart`,a,{passive:!0}),n.addEventListener(`touchmove`,o,{passive:!0}),()=>{n.removeEventListener(`wheel`,r),n.removeEventListener(`touchstart`,a),n.removeEventListener(`touchmove`,o)}},[e,t,x]),(0,J.useLayoutEffect)(()=>{if(t)return;let e=c.current;if(!e)return;if(!d.current){g.current=e.scrollTop,_.current=e.scrollHeight;return}let n=e.scrollTop,r=e.scrollHeight,i=g.current,a=_.current;if(n<i-1.5){if(!(r<a-1)){d.current&&(d.current=!1,u(!1)),g.current=n,_.current=r;return}g.current=n,_.current=r}return h.current!=null&&cancelAnimationFrame(h.current),h.current=requestAnimationFrame(()=>{h.current=null;let e=c.current;if(!e)return;let t=g.current,n=_.current;S(e,t,n)&&(y(!1,!0),g.current=e.scrollTop,_.current=e.scrollHeight)}),()=>{h.current!=null&&(cancelAnimationFrame(h.current),h.current=null)}},[i,y,t,S]),(0,J.useLayoutEffect)(()=>{let e=c.current;if(!e||t)return;let n=m.current,r=i[0],a=i.length,o=e.scrollHeight;a>n.len&&n.len>0&&r!==void 0&&r!==n.first&&n.scrollHeight>0&&(e.scrollTop+=o-n.scrollHeight),m.current={first:r,len:a,scrollHeight:o}},[i,t]),{scrollRef:c,atBottom:l,scrollToBottom:y,onScroll:b}}function k9(e){let t=String(e??``).trim();return!t||t===`new`?null:t}function eCe(e){let t=String(e.streamSessionKey??``).trim(),n=k9(e.routeSessionKey);return!t||!n?!1:t===n}function tCe(e){let t=k9(e.routeSessionKey);return t?e.cacheSessionKey===t:!1}function nCe(e){let t=String(e.chatId??``).trim();if(!t)return!1;let n=k9(e.routeSessionKey);return n?n===t:!1}function rCe(e,t){return e?`new`:t??null}function iCe(e){return!e.viewSessionKey||e.sessionKey!==e.viewSessionKey?[]:e.streamingMsg?[...e.messages,e.streamingMsg]:e.messages}function aCe(e){e()}function A9(e){return e===`on`||e===`stream`||e===`off`?e:`stream`}function oCe(e,t){let n=String(e??``).trim();n&&Oz.getState().patchSessionMeta(n,{model:t.model,thinkingLevel:t.thinkingLevel||`medium`,reasoningLevel:A9(t.reasoningLevel??void 0)})}function sCe(e){e.sendingRef.current=!1,e.streamingRef.current=!1}var cCe=`xopc.chat.clarifyPrompt:v1:`;function j9(e){return`${cCe}${encodeURIComponent(e.trim())}`}function M9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function lCe(e){if(!M9(e))return null;let t=e.requestId,n=e.question;if(typeof t!=`string`||!t.trim()||typeof n!=`string`||!n.trim())return null;let r=Array.isArray(e.choices)?e.choices.filter(e=>typeof e==`string`&&e.trim().length>0):void 0,i=typeof e.default==`string`&&e.default.trim()?e.default.trim():void 0;return{requestId:t.trim(),question:n.trim(),choices:r&&r.length>=2?r:void 0,default:i}}function uCe(e){let t=e?.trim();if(!t||typeof localStorage>`u`)return null;try{let e=localStorage.getItem(j9(t));if(!e)return null;let n=JSON.parse(e);return M9(n)?lCe(n.prompt??n):null}catch{return null}}function N9(e,t){let n=e?.trim();if(!(!n||typeof localStorage>`u`))try{localStorage.setItem(j9(n),JSON.stringify({v:1,prompt:t}))}catch{}}function P9(e){let t=e?.trim();if(!(!t||typeof localStorage>`u`))try{localStorage.removeItem(j9(t))}catch{}}var dCe=`xopc.chat.followUpQueue:v2:`;function F9(e){return`${dCe}${encodeURIComponent(e.trim())}`}function I9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function fCe(e){if(!I9(e))return null;let t=e.type;if(typeof t!=`string`||!t.trim())return null;let n={type:t.trim()};return typeof e.mimeType==`string`&&(n.mimeType=e.mimeType),typeof e.name==`string`&&(n.name=e.name),typeof e.size==`number`&&Number.isFinite(e.size)&&(n.size=e.size),typeof e.workspaceRelativePath==`string`&&(n.workspaceRelativePath=e.workspaceRelativePath),typeof e.durationSeconds==`number`&&Number.isFinite(e.durationSeconds)&&(n.durationSeconds=e.durationSeconds),n}function pCe(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!I9(n))continue;let e=n.id,r=n.text;if(typeof e!=`string`||!e.trim()||typeof r!=`string`)continue;let i={id:e.trim(),text:r};if(typeof n.thinkingLevel==`string`&&n.thinkingLevel.trim()&&(i.thinkingLevel=n.thinkingLevel.trim()),Array.isArray(n.attachments)){let e=n.attachments.flatMap(e=>{let t=fCe(e);return t?[t]:[]});e.length&&(i.attachments=e)}if(t.push(i),t.length>=50)break}return t}function mCe(e){return{editingId:e.editingId,pending:e.pending.map(e=>({...e,attachments:e.attachments?.map(e=>{let{data:t,...n}=e;return n})}))}}function hCe(e){let t=e?.trim();if(!t||typeof localStorage>`u`)return null;try{let e=localStorage.getItem(F9(t));if(!e)return null;let n=JSON.parse(e);if(!I9(n))return null;let r=pCe(n.pending),i=n.editingId===null?null:typeof n.editingId==`string`&&n.editingId.trim()?n.editingId.trim():null;return r.length===0&&i==null?null:{pending:r,editingId:i}}catch{return null}}function L9(e,t){let n=e?.trim();if(!n||typeof localStorage>`u`)return;let r=mCe(t);if(r.pending.length===0&&r.editingId==null){R9(n);return}try{localStorage.setItem(F9(n),JSON.stringify({v:2,...r}))}catch{}}function R9(e){let t=e?.trim();if(!(!t||typeof localStorage>`u`))try{localStorage.removeItem(F9(t))}catch{}}function gCe(e){let{sessionKey:t,decodedKey:n,sessionKeyRef:r,activeStreamSessionKeyRef:i,sendingRef:a,streamingRef:o,modelSupportsThinking:s,thinkingLevel:c,shouldApplyStreamUpdate:l,sendMessageRef:u}=e,[d,f]=(0,J.useState)(null),[p,m]=(0,J.useState)(!1),[h,g]=(0,J.useState)(null),v=(0,J.useRef)(null),[y,b]=(0,J.useState)([]),x=(0,J.useRef)([]),[S,C]=(0,J.useState)(null),[w,T]=(0,J.useState)(null),E=(0,J.useRef)(null),[D,O]=(0,J.useState)(null),k=(0,J.useRef)(void 0),A=(0,J.useRef)(null);v.current=d,x.current=y,E.current=w,(0,J.useLayoutEffect)(()=>{let e=k.current;e!=null&&e!==n&&(L9(e,{pending:structuredClone(x.current),editingId:E.current}),v.current!=null&&N9(e,v.current),C(null)),k.current=n;let r=A.current;if(r!=null&&r!==t&&(L9(r,{pending:structuredClone(x.current),editingId:E.current}),v.current!=null&&N9(r,v.current)),A.current=t,!t&&!n){(x.current.length>0||E.current!==null||D!==null)&&(x.current=[],b([]),T(null),O(null)),v.current!=null&&(f(null),g(null));return}let i=t&&n&&t===n?t:null;if(i!=null&&i!==D){let e=hCe(i),t=e?structuredClone(e.pending):[];x.current=t,b(t),T(e?.editingId??null),f(uCe(i)),g(null),O(i)}t!=null&&t!==n&&v.current!=null&&(N9(t,v.current),f(null),g(null))},[t,n,D]),(0,J.useEffect)(()=>{let e=t!=null&&n!=null&&t!==n?t:t??n??null;if(!e)return;let i=window.setTimeout(()=>{r.current===e&&L9(e,{pending:structuredClone(x.current),editingId:E.current})},280);return()=>window.clearTimeout(i)},[t,n,y,w,r]);let j=(0,J.useCallback)(()=>{g(null),f(null)},[]),M=(0,J.useCallback)(e=>{let t=String(e??``).trim();t&&(P9(t),r.current===t&&(g(null),f(null)))},[r]),N=(0,J.useCallback)(()=>{let e=r.current;e&&P9(e),g(null),f(null)},[r]),P=(0,J.useCallback)(()=>{let e=r.current;e&&R9(e),x.current=[],b([]),T(null),O(e)},[r]),F=(0,J.useCallback)(()=>{let e=r.current;e&&(R9(e),P9(e)),x.current=[],b([]),g(null),f(null),T(null),O(e)},[r]),I=(0,J.useCallback)(e=>{M(e)},[M]),L=(0,J.useCallback)(e=>t=>{N9(e,t),l(e)&&(a.current=!1,o.current=!1,Oz.getState().setSessionFlags(e,{sending:!1,streaming:!1}),Oz.getState().setSessionProgress(e,null),g(null),f(t))},[l,a,o]),R=(0,J.useCallback)(async e=>{let t=r.current;if(e!=null&&e!==t)return;let n=t;if(!n)return;let s=x.current;for(;s.length>0&&!s[0].text.trim()&&!s[0].attachments?.length;)s=s.slice(1);if(s.length===0){x.current=[],b([]);return}s.length!==x.current.length&&(x.current=s,b(s));let[c,...l]=s,d=c.text?.trim()??``,f=c.attachments;!d&&!f?.length||i.current===n&&(a.current||o.current)||(E.current===c.id&&T(null),x.current=l,b(l),await u.current(c.text,c.attachments,c.thinkingLevel))},[u,r,i,a,o]),z=(0,J.useEffectEvent)(e=>{R(e)});return(0,J.useEffect)(()=>{if(!t||t!==n||d||y.length===0||a.current||o.current)return;let e=y[0];if(!e||!e.text.trim()&&!e.attachments?.length)return;let i=window.setTimeout(()=>{r.current===t&&(a.current||o.current||v.current||z(t))},72);return()=>window.clearTimeout(i)},[t,n,d,y,a,o,r]),{clarifyPrompt:d,clarifySubmitting:p,clarifySubmitError:h,clarifyPromptRef:v,pendingFollowUps:y,pendingFollowUpsRef:x,steeringFollowUpId:S,editingFollowUpId:w,addPendingFollowUp:(0,J.useCallback)((e,t)=>{let n=e.trim();if(!n&&!t?.length||x.current.length>=10)return;let r=s?c:`off`,i={id:crypto.randomUUID(),text:n||e,attachments:t?.length?t:void 0,thinkingLevel:r};b(e=>{let t=[...e,i];return x.current=t,t})},[s,c]),beginEditFollowUp:(0,J.useCallback)(e=>{T(e)},[]),cancelEditFollowUp:(0,J.useCallback)(()=>{T(null)},[]),commitEditFollowUp:(0,J.useCallback)((e,t,n,r)=>{let i=t.trim(),a=x.current,o=a.findIndex(t=>t.id===e);if(o<0){T(null);return}if(!i&&!n?.length){let t=a.filter(t=>t.id!==e);x.current=t,b(t),T(null);return}let l=[...a],u=s?r??c:`off`;l[o]={...l[o],text:i||t,attachments:n?.length?n:void 0,thinkingLevel:u},x.current=l,b(l),T(null)},[s,c]),removePendingFollowUp:(0,J.useCallback)(e=>{E.current===e&&T(null),b(t=>{let n=t.filter(t=>t.id!==e);return x.current=n,n})},[]),movePendingFollowUp:(0,J.useCallback)((e,t)=>{b(n=>{let r=n.findIndex(t=>t.id===e);if(r<0)return n;let i=t===`up`?r-1:r+1;if(i<0||i>=n.length)return n;let a=[...n];return[a[r],a[i]]=[a[i],a[r]],x.current=a,a})},[]),reorderPendingFollowUp:(0,J.useCallback)((e,t)=>{b(n=>{if(e<0||e>=n.length||t<0||t>=n.length)return n;let r=[...n],[i]=r.splice(e,1);return r.splice(t,0,i),x.current=r,r})},[]),steerPendingFollowUp:(0,J.useCallback)(async e=>{let t=r.current;if(!t)return;let n=x.current.find(t=>t.id===e);if(!(!n?.text.trim()||n.attachments?.length)){C(e);try{(await Ee(_(`/api/agent/steer`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({chatId:t,message:n.text.trim()})})).ok&&(b(t=>{let n=t.filter(t=>t.id!==e);return x.current=n,n}),E.current===e&&T(null))}catch{}finally{C(null)}}},[r]),submitClarifyAnswer:(0,J.useCallback)(async e=>{let t=v.current;if(t){m(!0),g(null);try{let n=await Ee(_(`/api/clarify/${encodeURIComponent(t.requestId)}`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({answer:e})});if(!n.ok){g((await n.json().catch(()=>({}))).error?.message??n.statusText??`Clarify failed`);return}let i=r.current;i&&P9(i),f(null),g(null)}finally{m(!1)}}},[r]),cancelClarifyAnswer:(0,J.useCallback)(async()=>{let e=v.current;if(e){m(!0),g(null);try{let t=await Ee(_(`/api/clarify/${encodeURIComponent(e.requestId)}`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({skip:!0})});if(!t.ok){g((await t.json().catch(()=>({}))).error?.message??t.statusText??`Clarify failed`);return}let n=r.current;n&&P9(n),f(null),g(null)}finally{m(!1)}}},[r]),clearVisibleClarify:j,dismissClarify:N,dismissClarifyForSession:M,clearPendingFollowUps:P,dismissClarifyAndClearPending:F,onClarifyToolEnd:I,makeOnClarifyRequest:L,flushSteeringQueue:R}}function _Ce(e){let{navigate:t,sessionKeyRef:n,sessionKey:r,isNewRoute:i,locationState:a}=e,o=Se(e=>e.token),{data:s,mutate:c}=v(o?[`gateway-chat-agents`,o]:null,gL,{revalidateOnFocus:!1});(0,J.useEffect)(()=>{let e=()=>void c();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[c]);let[l,u]=(0,J.useState)(()=>az()),d=(0,J.useRef)(s??null),f=(0,J.useRef)(az());(0,J.useEffect)(()=>{d.current=s??null},[s]),(0,J.useEffect)(()=>{f.current=l},[l]),(0,J.useEffect)(()=>{if(!s)return;let e=new Set(s.items.map(e=>e.id));u(t=>t==null||t===``||!e.has(t)?s.defaultId:t)},[s]);let p=(0,J.useCallback)(()=>{let e=n.current,t=e?aH(e):null;if(t)return t;let r=d.current,i=(f.current??``).trim().toLowerCase();if(!r)return i||void 0;let a=new Set(r.items.map(e=>e.id));return i&&a.has(i)?i:r.defaultId},[n]),m=(0,J.useCallback)(e=>{let r=e.trim().toLowerCase();u(r);try{globalThis.localStorage?.setItem(iz,r)}catch{}let i=n.current;(i?aH(i):null)!==r&&t(`/chat/new`,{replace:!1})},[t,n]);return(0,J.useEffect)(()=>{let e=e=>{let t=e.detail?.agentId;typeof t!=`string`||!t.trim()||m(t)};return window.addEventListener(`xopc-set-chat-agent`,e),()=>window.removeEventListener(`xopc-set-chat-agent`,e)},[m]),(0,J.useLayoutEffect)(()=>{if(!r)return;let e=aH(r);if(!(!e||f.current===e)){f.current=e,u(e);try{globalThis.localStorage?.setItem(iz,e)}catch{}}},[r]),(0,J.useLayoutEffect)(()=>{if(!i)return;let e=a,t=typeof e?.agentId==`string`?e.agentId.trim().toLowerCase():``;if(t){f.current=t,u(t);try{globalThis.localStorage?.setItem(iz,t)}catch{}}},[i,a]),{token:o,chatAgentsData:s,resolveAgentIdForPost:p,onChatAgentChange:m,displayAgentId:(0,J.useMemo)(()=>r&&aH(r)||l||s?.defaultId||`main`,[r,l,s]),showChatAgentSelector:(s?.items.length??0)>1}}function vCe(e){let t=e.startsWith(`?`)?e.slice(1):e;if(!t)return``;let n=new URLSearchParams(t),r=new URLSearchParams,i=n.get(`skill`),a=n.get(`slash`);i&&r.set(`skill`,i),a&&r.set(`slash`,a);let o=r.toString();return o?`?${o}`:``}var z9=null;function B9(e){z9=String(e??``).trim()||null}function yCe(e){let t=String(e??``).trim();return!t||z9!==t?!1:(z9=null,!0)}function bCe(e){let t=(0,Y.c)(15),{token:n,isNewRoute:r,decodedKey:i,locationSearch:a,sessionMgrRef:o,resolveAgentIdForPost:s,navigateToSession:c,loadSessionById:l,tryResumeAgentRun:u,restoreLiveCacheIfNeeded:d,adoptEmptySession:f,applyAgentConfig:p,patchInitUi:m}=e,h=(0,J.useRef)(0),g,_;t[0]!==f||t[1]!==p||t[2]!==i||t[3]!==r||t[4]!==l||t[5]!==a||t[6]!==c||t[7]!==m||t[8]!==s||t[9]!==d||t[10]!==o||t[11]!==n||t[12]!==u?(g=()=>{if(!n){m({loading:!1});return}let e=h.current+=1,t=!1,g=()=>!t&&e===h.current,_=e=>{g()&&o.current.loadSessionAgentConfig(e).then(t=>{g()&&p(e,t)}).catch(SCe)},v=()=>{if(!g())return Promise.resolve();let e=s();return o.current.createSession(e?{agentId:e}:void 0).then(e=>{g()&&(B9(e.key),f(e.key,e.name??null),c(e.key,!0,vCe(a)),_(e.key))})},y=(e,t)=>g()?(d(e),u(e,Az(e)?.messages??t??jz(e))):Promise.resolve();return m({loading:r||i===void 0,error:null}),(r?v():i?(e=>g()?yCe(e)?(_(e),y(e,jz(e))):l(e,0).then(t=>{if(g())return y(e,t??jz(e))}):Promise.resolve())(i):g()?o.current.loadSessions().then(e=>{if(!g())return;let t=e.filter(xCe)[0]??e[0];if(t)return g()?l(t.key,0).then(e=>{if(!g())return;d(t.key);let n=Az(t.key)?.messages??e??jz(t.key);return o.current.parseSessionFromHash()||c(t.key,!0),u(t.key,n)}):void 0;if(!g())return;let n=s();return o.current.createSession(n?{agentId:n}:void 0).then(e=>{g()&&(B9(e.key),f(e.key,e.name??null),c(e.key),_(e.key))})}):Promise.resolve()).then(()=>{g()&&m({loading:!1})}).catch(e=>{t?g()&&m({loading:!1}):m({error:e instanceof Error?e.message:`Chat init failed`,loading:!1})}),()=>{t=!0}},_=[n,r,i,a,o,s,c,l,u,d,f,p,m],t[0]=f,t[1]=p,t[2]=i,t[3]=r,t[4]=l,t[5]=a,t[6]=c,t[7]=m,t[8]=s,t[9]=d,t[10]=o,t[11]=n,t[12]=u,t[13]=g,t[14]=_):(g=t[13],_=t[14]),(0,J.useEffect)(g,_)}function xCe(e){return(e.messageCount??0)>0}function SCe(){}async function CCe(e){let t=e.trim();if(!t)return!1;try{return!!(await c8()).find(e=>e.id===t)?.reasoning}catch{return!1}}function wCe(e){let{sessionMgrRef:t,routeSessionKeyRef:n,sendingRef:r,streamingRef:i,activeStreamSessionKeyRef:a,loadingSessionRef:o,messagesLenRef:s,thinkingSupportGenRef:c,navigateToSession:l,resolveAgentIdForPost:u,dismissClarifyOnSessionLoad:d,detachForNewConversation:f,sessionKey:p,hasMore:m}=e,h=()=>Oz.getState(),g=(0,J.useRef)(Promise.resolve(void 0)),_=(0,J.useRef)(null),v=(0,J.useRef)(0),y=(0,J.useCallback)(e=>{let t=h().focusedSessionKey;if(!e.trim())return++c.current===c.current&&t&&h().patchSessionMeta(t,{modelSupportsThinking:!1}),Promise.resolve();let n=++c.current;return CCe(e).then(e=>{if(n!==c.current)return;let t=h().focusedSessionKey;t&&h().patchSessionMeta(t,{modelSupportsThinking:e})})},[c]),b=(0,J.useCallback)(()=>{let e=h().focusedSessionKey;if(!e||(h().sessions[e]?.name)?.trim())return;let n=++v.current,r=[700,900,900,1e3,1e3],i=a=>{a>=5||n===v.current&&h().focusedSessionKey===e&&(h().sessions[e]?.name?.trim()||window.setTimeout(()=>{n===v.current&&h().focusedSessionKey===e&&(h().sessions[e]?.name?.trim()||t.current.fetchSessionName(e).then(t=>{if(n===v.current){if(t){h().patchSessionMeta(e,{name:t});return}i(a+1)}}).catch(()=>{i(a+1)}))},r[a]??900))};i(0)},[t]),x=(0,J.useCallback)(e=>nCe({chatId:e,routeSessionKey:n.current}),[n]),S=(0,J.useCallback)((e,t)=>{let n=h().getSessionSnapshot(e);n&&(n.streaming||n.sending||n.streamingMsg)?(h().mergeCommittedFromServer(e,t.messages,t.hasMore),t.name!==void 0&&h().patchSessionMeta(e,{name:t.name||null})):h().setCommittedSnapshot(e,{messages:t.messages,hasMore:t.hasMore,name:t.name}),x(e)&&(_.current=t.nextBeforeCursor??null)},[x]),C=(0,J.useCallback)(async(e,r=0,i)=>{let a=async(e,r,i)=>{let s=r===0&&!i;s&&!wR(e)&&d(),o.current=!0;try{let{messages:n,hasMore:a,name:o,nextBeforeCursor:c}=await t.current.loadSession(e,r,i);if(s){if(h().setCommittedSnapshot(e,{messages:n,hasMore:a,name:o??null}),!x(e))return n;_.current=c??null,h().setShellError(null);try{let r=await t.current.loadSessionAgentConfig(e);if(!x(e))return n;h().patchSessionMeta(e,{model:r.model,thinkingLevel:r.thinkingLevel||`medium`,reasoningLevel:A9(r.reasoningLevel)}),y(r.model)}catch{}return n}if(_.current=c??null,!x(e))return;h().prependHistoryMessages(e,n,a);return}catch{if(r===0&&!i){_.current=null,h().setShellError(`Failed to load session`);let r=k9(n.current);if(r&&r===e)return;let i=await t.current.loadSessions().catch(()=>[]),o=i.filter(e=>(e.messageCount??0)>0)[0]??i[0];if(o)return l(o.key,!0),await a(o.key,0,null);try{let e=u(),n=await t.current.createSession(e?{agentId:e}:void 0);l(n.key,!0),_.current=null,B9(n.key),h().setCommittedSnapshot(n.key,{messages:[],hasMore:!1});try{let e=await t.current.loadSessionAgentConfig(n.key);h().patchSessionMeta(n.key,{model:e.model,thinkingLevel:e.thinkingLevel||`medium`,reasoningLevel:A9(e.reasoningLevel)}),y(e.model)}catch{}}catch{h().setShellError(`Could not open a session`)}}return}finally{o.current=!1}},s=g.current,c,f=new Promise(e=>{c=e});g.current=s.then(()=>f),await s;try{return await a(e,r,i)}finally{c()}},[n,x,r,i,a,o,d,l,y,u,t]);return{refreshModelThinkingSupport:y,pollSessionNameAfterTurn:b,applyLoadedSessionSnapshot:S,loadSessionById:C,loadMoreMessages:(0,J.useCallback)(async()=>{let e=h().focusedSessionKey;if(!(!e||h().loadingMore||!m)){h().setLoadingMore(!0);try{await C(e,s.current,_.current)}finally{h().setLoadingMore(!1)}}},[m,C,s]),onSessionModelChange:(0,J.useCallback)(async e=>{if(p)try{h().setShellError(null),await t.current.patchSessionAgentConfig(p,{model:e}),h().patchSessionMeta(p,{model:e}),y(e)}catch(e){h().setShellError(e instanceof Error?e.message:`Failed to switch model`)}},[p,t,y]),onSessionThinkingLevelChange:(0,J.useCallback)(async e=>{if(p)try{h().setShellError(null),await t.current.patchSessionAgentConfig(p,{thinkingLevel:e}),h().patchSessionMeta(p,{thinkingLevel:e})}catch(e){h().setShellError(e instanceof Error?e.message:`Failed to update thinking level`)}},[p,t]),createNewSession:(0,J.useCallback)(async()=>{d(),f();try{let e=u(),n=await t.current.createSession(e?{agentId:e}:void 0);_.current=null,B9(n.key),h().setCommittedSnapshot(n.key,{messages:[],hasMore:!1,name:n.name??null}),l(n.key);try{let e=await t.current.loadSessionAgentConfig(n.key);h().patchSessionMeta(n.key,{model:e.model,thinkingLevel:e.thinkingLevel||`medium`,reasoningLevel:A9(e.reasoningLevel)}),y(e.model)}catch{}}catch(e){console.error(`[chat] createNewSession failed:`,e)}},[d,f,l,y,u,t])}}var V9={current:null};function TCe(){let e=Yr(),{sessionKey:t}=ni(),n=e.pathname.endsWith(`/new`),r=t?decodeURIComponent(t):void 0,i=rCe(n,r),a=k9(i),o=n?null:r??null,s=(0,J.useRef)(i);return s.current=i,V9.current=o,(0,J.useLayoutEffect)(()=>{Oz.getState().focusedSessionKey!==o&&Oz.getState().setFocusedSessionKey(o)},[o]),{isNewRoute:n,decodedKey:r,routedSessionKey:i,viewSessionKey:a,routedFocusedSessionKey:o,routeSessionKeyRef:s,locationSearch:e.search,locationState:e.state}}var H9={get current(){return V9.current},set current(e){V9.current=e,Oz.getState().setFocusedSessionKey(e)}};function U9(e){let{chatId:t,shouldApplyStreamUpdate:n,beforeAssistantDelta:r,setStreamingOnStreamStart:i,clearResumeRunIdOnBackgroundTerminal:a,clearResumeRunIdOnVisibleError:o,setError:s,sessionMgrRef:c,applyLoadedSessionSnapshot:l,finalizeMessage:u,fq:d}=e,f=()=>Oz.getState(),p=()=>{c.current.loadSession(t,0).then(e=>l(t,e)).catch(()=>{})},m=()=>{f().clearStreamingState(t),oz.clearActiveStreamSessionKey(t),a&&(oz.activeResumeRunId=null),f().setSessionFlags(t,{sending:!1,streaming:!1}),f().setSessionProgress(t,null),d.dismissClarifyForSession(t),p()};return{onUserMessage:e=>{n(t)&&f().appendUserMessageIfMissing(t,e)},onStreamStart:()=>{r(),f().mutateSessionStreaming(t,()=>{}),f().setSessionFlags(t,{streaming:!0})},onToken:e=>{r(),f().mutateSessionStreaming(t,t=>{yz(t.content,e)}),n(t)&&f().setSessionFlags(t,{streaming:!0})},onThinking:(e,n)=>{r(),f().mutateSessionStreaming(t,t=>{!n&&e===``?mz(t.content):hz(t.content,e,n)})},onThinkingEnd:()=>{r(),f().mutateSessionStreaming(t,e=>{gz(e.content)})},onToolStart:(e,n,i)=>{r(),f().mutateSessionStreaming(t,t=>{bz(t.content,e,n,i)}),f().setSessionFlags(t,{streaming:!0})},onToolEnd:(e,n,i)=>{e===`clarify`&&d.onClarifyToolEnd(t),r(),f().mutateSessionStreaming(t,t=>{xz(t.content,e,n,i)})},onToolUpdate:(e,n,i)=>{r(),f().mutateSessionStreaming(t,t=>{Sz(t.content,e,n,i)})},onProgress:e=>{f().setSessionProgress(t,e)},onTtsAudio:e=>{r(),f().mutateSessionStreaming(t,t=>{let n=e.workspaceRelativePath?.replace(/\\/g,`/`).trim(),r=t.attachments??[];if(n&&r.some(e=>e.workspaceRelativePath?.replace(/\\/g,`/`).trim()===n))return;let i={name:e.name,mimeType:e.mimeType,type:`voice`,workspaceRelativePath:e.workspaceRelativePath,size:0};t.attachments=[...r,i]})},onCompaction:e=>{if(n(t))if(e.status===`started`)f().setSessionProgress(t,{stage:`compaction`,message:`Compacting context…`,timestamp:Date.now()});else if(e.status===`completed`){let n=e.tokensBefore&&e.tokensAfter?` (${Math.round((e.tokensBefore-e.tokensAfter)/1e3)}k tokens freed)`:``;f().setSessionProgress(t,{stage:`compaction`,message:`Context compacted${n}`,timestamp:Date.now()})}else f().setSessionProgress(t,null)},onClarifyRequest:d.makeOnClarifyRequest(t),onResult:()=>{if(!n(t)){m();return}if(oz.userAborted){oz.userAborted=!1;return}u()},onError:e=>{if(!n(t)){m();return}f().clearStreamingState(t),o&&(oz.activeResumeRunId=null),f().setSessionFlags(t,{sending:!1,streaming:!1}),f().setSessionProgress(t,null),s(e),d.dismissClarifyForSession(t)}}}function ECe(e){return Az(e)?.streamingMsg??null}function DCe(e){let{sessionKey:t,thinkingLevel:n,modelSupportsThinking:r,sessionKeyRef:i,sendingRef:a,streamingRef:o,sessionMgrRef:s,sendMessageRef:c,shouldApplyStreamUpdate:l,fq:u,applyLoadedSessionSnapshot:d,loadSessionById:f,createNewSession:p,pollSessionNameAfterTurn:m}=e,h=(0,J.useRef)(u.flushSteeringQueue);h.current=u.flushSteeringQueue;let g=()=>Oz.getState(),_=e=>g().setShellError(e),v=()=>g().setShellError(null),y=(0,J.useCallback)(e=>{let t=oz.activeStreamSessionKey??i.current;if(t&&!l(t))return;let n=t?ECe(t):null,r=null;if(n){let e=uz(n,Date.now());gz(e.content),_z(e.content),r=dz(e)}if(r&&lz(r)&&t){let e=Az(t)?.messages??jz(t);g().finalizeStreamingTurn(t,eR([...e,r]))}else t&&g().clearStreamingState(t);if(a.current=!1,o.current=!1,oz.resetRunTracking(),u.dismissClarify(),m(),!e?.skipSteeringQueueFlush){let e=t??i.current;e&&window.setTimeout(()=>{h.current(e)},72)}let s=i.current;s&&window.setTimeout(()=>{i.current===s&&(a.current||o.current||u.pendingFollowUpsRef.current.length>0||f(s,0))},400)},[a,o,i,u.dismissClarify,u.pendingFollowUpsRef,m,f,l]),b=(0,J.useCallback)(async(e,t)=>{if(!l(e)||oz.isStreamingFor(e)||oz.isSending)return;let n=await OR(e);if(!n||oz.activeResumeRunId===n)return;let r=t??jz(e),i=Az(e)?.hasMore??!1;try{let t=await s.current.loadSession(e,0);g().mergeCommittedFromServer(e,t.messages,t.hasMore),r=t.messages,i=t.hasMore}catch{}oz.userAborted=!1,oz.activeResumeRunId=n,oz.activeStreamSessionKey=e,a.current=!0,o.current=!0,g().seedSessionIfEmpty(e,r,!0,!0,i),g().setSessionFlags(e,{sending:!0,streaming:!0}),g().setSessionProgress(e,null);let c=!1,f=()=>{if(c||!l(e))return;c=!0;let t=jz(e);if(t.length===0)return;let n=t[t.length-1];if(n?.role!==`assistant`)return;let r=dz(n),i=t.slice(0,-1);g().applyHydratedTail(e,i,r)};try{let t=U9({chatId:e,shouldApplyStreamUpdate:l,beforeAssistantDelta:f,setStreamingOnStreamStart:!1,clearResumeRunIdOnBackgroundTerminal:!0,clearResumeRunIdOnVisibleError:!0,setError:_,sessionMgrRef:s,applyLoadedSessionSnapshot:d,finalizeMessage:y,fq:u});await oz.sender.resume(n,e,t)}catch(t){if(t.name!==`AbortError`&&console.error(`[chat] resume failed:`,t),g().clearStreamingState(e),oz.activeResumeRunId=null,!l(e)){oz.clearActiveStreamSessionKey(e);return}a.current=!1,o.current=!1,oz.clearActiveStreamSessionKey(e)}},[a,o,l,s,d,y]),x=(0,J.useCallback)(async(e,t,s)=>{if(!e.trim()&&!t?.length||!a.current&&!o.current&&!oz.isSending)return;if(e.trim()===`/new`&&!t?.length){await p();return}if(!i.current)return;u.dismissClarifyAndClearPending();let l=r?s??n:`off`;oz.userAborted=!0,oz.resetRunTracking(),oz.abort(),a.current=!1,o.current=!1,y({skipSteeringQueueFlush:!0}),queueMicrotask(()=>{c.current(e,t,l)})},[a,o,i,u.dismissClarifyAndClearPending,r,n,y,c,p]);return{finalizeMessage:y,tryResumeAgentRun:b,sendMessage:(0,J.useCallback)(async(e,i,c)=>{if(!t||!l(t)||!e.trim()&&!i?.length||oz.activeStreamSessionKey===t&&(a.current||o.current))return;if(e.trim()===`/new`&&!i?.length){await p();return}let f=r?c??n:`off`,m=t;oz.userAborted=!1,oz.activeStreamSessionKey=m,a.current=!0,o.current=!1,v(),u.dismissClarify();let h=[...jz(m),{role:`user`,content:e?[{type:`text`,text:e}]:[],attachments:i,timestamp:Date.now()}],b=Az(m);g().initSessionSnapshot(m,{...b??{...rz(),hasMore:!1,streamingMsg:null,progress:null,sending:!1,streaming:!1},messages:h,hasMore:b?.hasMore??!1,streamingMsg:null,progress:null,sending:!0,streaming:!1});try{let t=U9({chatId:m,shouldApplyStreamUpdate:l,beforeAssistantDelta:()=>{},setStreamingOnStreamStart:!0,clearResumeRunIdOnBackgroundTerminal:!1,clearResumeRunIdOnVisibleError:!1,setError:_,sessionMgrRef:s,applyLoadedSessionSnapshot:d,finalizeMessage:y,fq:u});await oz.sender.send(e,m,i,f,t)}catch(e){e.name!==`AbortError`&&(g().clearStreamingState(m),_(e instanceof Error?e.message:`Send failed`))}finally{a.current=!1,o.current=!1,g().setSessionFlags(m,{sending:!1}),oz.clearActiveStreamSessionKey(m)}},[t,n,r,a,o,l,s,d,y,u.dismissClarify,p]),interruptAndSend:x,abort:(0,J.useCallback)(()=>{oz.userAborted=!0,oz.resetRunTracking(),u.dismissClarifyAndClearPending(),oz.abort(),a.current=!1,o.current=!1,y({skipSteeringQueueFlush:!0});let e=i.current;e&&window.setTimeout(()=>{f(e,0)},300)},[u.dismissClarifyAndClearPending,a,o,y,i,f]),deleteMessageRound:(0,J.useCallback)(e=>{let t=i.current;if(!t||a.current||o.current)return;let n=jz(t),r=n[e];if(!r||!hR(r.role))return;let c=gR(n,e);if(c===null)return;let l=_R(n,e),u=[...n];u.splice(e,l),g().updateSessionMessages(t,()=>u),s.current.deleteMessages(t,{userRoundIndex:c}).catch(()=>{f(t,0)})},[i,a,o,s,f]),retryUserMessageRound:(0,J.useCallback)(e=>{let t=i.current;if(!t||a.current||o.current)return;let n=jz(t),r=n[e];if(!r||!hR(r.role))return;for(let t=e+1;t<n.length;t++){let e=n[t];if(e&&hR(e.role))return}let l=fR(r.content),u=mR(r.attachments);if(!l.trim()&&!u?.length)return;let d=gR(n,e);if(d===null)return;let p=_R(n,e),m=[...n];m.splice(e,p),g().updateSessionMessages(t,()=>m),(async()=>{try{await s.current.deleteMessages(t,{userRoundIndex:d}),await c.current(l,u)}catch{f(t,0)}})()},[i,a,o,s,f,c])}}function OCe(e){let t=(0,Y.c)(12),{sessionKey:n,sessionKeyRef:r,sessionMgrRef:i,loadSessionById:a,applyAgentConfig:o}=e,s,c;t[0]===n?(s=t[1],c=t[2]):(s=()=>{let e=e=>{let t=e.detail;!t?.key||t.name===void 0||t.key===n&&Oz.getState().patchSessionMeta(t.key,{name:t.name||null})};return window.addEventListener(`session-updated`,e),()=>window.removeEventListener(`session-updated`,e)},c=[n],t[0]=n,t[1]=s,t[2]=c),(0,J.useEffect)(s,c);let l,u;t[3]!==a||t[4]!==n?(l=()=>{let e=e=>{let t=e.detail;!t?.key||t.key!==n||a(n,0)};return window.addEventListener(`session-transcript-updated`,e),()=>window.removeEventListener(`session-transcript-updated`,e)},u=[n,a],t[3]=a,t[4]=n,t[5]=l,t[6]=u):(l=t[5],u=t[6]),(0,J.useEffect)(l,u);let d,f;t[7]!==o||t[8]!==r||t[9]!==i?(d=()=>{let e=()=>{let e=r.current;e&&i.current.loadSessionAgentConfig(e).then(t=>{o(e,t)}).catch(kCe)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},f=[r,i,o],t[7]=o,t[8]=r,t[9]=i,t[10]=d,t[11]=f):(d=t[10],f=t[11]),(0,J.useEffect)(d,f)}function kCe(){}function ACe(){let e=Qr(),{isNewRoute:t,decodedKey:n,viewSessionKey:r,routedFocusedSessionKey:i,routeSessionKeyRef:a,locationSearch:o,locationState:s}=TCe(),c=(0,J.useRef)(new $R),l=(0,J.useRef)(!1),u=(0,J.useRef)(!1),d=(0,J.useRef)(!1),f=(0,J.useRef)(0),p=(0,J.useRef)(!1),m=(0,J.useRef)(async()=>{}),h=(0,J.useRef)(0),g=i,_=Oz(e=>e.initLoading),v=Oz(e=>e.loadingMore),y=Oz(e=>e.shellError),b=r,x=Oz(e=>b?e.sessions[b]:void 0),S=b?kz(x):!1,C=S?x?.streaming??!1:!1,w=S?x?.sending??!1:!1,T=S?x?.progress??null:null,E=x?.hasMore??!1,D=x?.name??null,O=x?.model??``,k=x?.thinkingLevel??`medium`,A=x?.reasoningLevel??`stream`,j=x?.modelSupportsThinking??!1;(0,J.useEffect)(()=>{h.current=x?.messages.length??0},[x?.messages.length]),(0,J.useEffect)(()=>{u.current=w,d.current=C},[w,C]);let{token:M,chatAgentsData:N,resolveAgentIdForPost:P,onChatAgentChange:F,displayAgentId:I,showChatAgentSelector:L}=_Ce({navigate:e,sessionKeyRef:H9,sessionKey:g,isNewRoute:t,locationState:s}),R=n!==void 0&&g!==n,z=(0,J.useMemo)(()=>_&&(g==null||n===void 0),[_,g,n]),B=(0,J.useCallback)((t,n=!1,r)=>{let i=r??``;e({pathname:`/chat/${encodeURIComponent(t)}`,search:i},{replace:n})},[e]),V=(0,J.useCallback)(e=>eCe({streamSessionKey:e,routeSessionKey:a.current}),[a]),H=(0,J.useCallback)(()=>{sCe({sendingRef:u,streamingRef:d})},[]),U=gCe({sessionKey:g,decodedKey:n,sessionKeyRef:H9,activeStreamSessionKeyRef:sz,sendingRef:u,streamingRef:d,modelSupportsThinking:j,thinkingLevel:k,shouldApplyStreamUpdate:V,sendMessageRef:m}),W=(0,J.useCallback)(()=>{U.clearVisibleClarify(),oz.activeResumeRunId=null,oz.userAborted=!1,aCe(H)},[U.clearVisibleClarify,H]),{refreshModelThinkingSupport:G,pollSessionNameAfterTurn:ee,applyLoadedSessionSnapshot:K,loadSessionById:te,loadMoreMessages:ne,onSessionModelChange:re,onSessionThinkingLevelChange:ie,createNewSession:ae}=wCe({sessionMgrRef:c,routeSessionKeyRef:a,sendingRef:u,streamingRef:d,activeStreamSessionKeyRef:sz,loadingSessionRef:l,messagesLenRef:h,thinkingSupportGenRef:f,navigateToSession:B,resolveAgentIdForPost:P,dismissClarifyOnSessionLoad:U.clearVisibleClarify,detachForNewConversation:W,sessionKey:g,hasMore:E}),oe=(0,J.useCallback)(e=>{if(!tCe({cacheSessionKey:e,routeSessionKey:a.current}))return!1;let t=Az(e);return!t||!kz(t)&&!wR(e)&&!oz.isStreamingFor(e)?!1:(oz.activeStreamSessionKey=e,u.current=t.sending,d.current=t.streaming,!0)},[a]),{tryResumeAgentRun:se,sendMessage:q,interruptAndSend:ce,abort:le,deleteMessageRound:ue,retryUserMessageRound:de}=DCe({sessionKey:g,thinkingLevel:k,modelSupportsThinking:j,sessionKeyRef:H9,sendingRef:u,streamingRef:d,sessionMgrRef:c,sendMessageRef:m,shouldApplyStreamUpdate:V,fq:U,applyLoadedSessionSnapshot:K,loadSessionById:te,createNewSession:ae,pollSessionNameAfterTurn:ee});(0,J.useEffect)(()=>{t&&W()},[t,W]);let fe=(0,J.useMemo)(()=>iCe({viewSessionKey:r,sessionKey:b,messages:x?.messages??[],streamingMsg:S?x?.streamingMsg??null:null}),[r,b,x?.messages,x?.streamingMsg,S]),pe=(0,J.useCallback)((e,t)=>{Oz.getState().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:t}),H()},[H]),me=(0,J.useCallback)((e,t)=>{oCe(e,t),G(t.model)},[G]),he=(0,J.useCallback)(e=>{let t=Oz.getState();e.loading!==void 0&&t.setInitLoading(e.loading),e.error!==void 0&&t.setShellError(e.error)},[]);return OCe({sessionKey:g,sessionKeyRef:H9,sendingRef:u,streamingRef:d,sessionMgrRef:c,loadSessionById:te,applyAgentConfig:me}),bCe({token:M,isNewRoute:t,decodedKey:n,locationSearch:o,sessionMgrRef:c,resolveAgentIdForPost:P,navigateToSession:B,loadSessionById:te,tryResumeAgentRun:se,restoreLiveCacheIfNeeded:oe,adoptEmptySession:pe,applyAgentConfig:me,patchInitUi:he}),(0,J.useEffect)(()=>{let e=e=>{let t=e.detail;if(!t?.sessionKey)return;let n=t.event;if(!n||typeof n.type!=`string`)return;let r=t.sessionKey;if(n.type===`user_message`||n.type===`user_transcript`){let e=vR(n);e&&V(r)&&Oz.getState().appendUserMessageIfMissing(r,e);return}n.type!==`status`||typeof n.runId!=`string`||!n.runId.trim()||(TR(r,n.runId),V(r)&&(oz.isStreamingFor(r)||queueMicrotask(()=>{V(r)&&(oz.isStreamingFor(r)||se(r,jz(r)))})))};return window.addEventListener(`agent-stream`,e),()=>window.removeEventListener(`agent-stream`,e)},[se,V]),(0,J.useEffect)(()=>{let e=C||w,t=p.current;if(p.current=e,!t||e)return;let n=H9.current;n&&queueMicrotask(()=>{!n||!V(n)||oz.isStreamingFor(n)||wR(n)&&se(n,jz(n))})},[C,w,se,V]),m.current=q,{auth:{hasToken:!!M},session:{sessionKey:g,sessionName:D,decodedKey:n,sessionRoutePending:R,showSessionLoading:z,loading:_,sessionModel:O,thinkingLevel:k,onSessionThinkingLevelChange:ie,reasoningLevel:A,modelSupportsThinking:j,hasMore:E,loadingMore:v,loadMoreMessages:ne,onSessionModelChange:re,createNewSession:ae,sessionManager:c.current},messages:{items:fe},stream:{error:y,streaming:C,sending:w,progress:T,sendMessage:q,abort:le,interruptAndSend:ce,deleteMessageRound:ue,retryUserMessageRound:de},followUp:{addPendingFollowUp:U.addPendingFollowUp,pendingFollowUps:U.pendingFollowUps,editingFollowUpId:U.editingFollowUpId,beginEditFollowUp:U.beginEditFollowUp,cancelEditFollowUp:U.cancelEditFollowUp,commitEditFollowUp:U.commitEditFollowUp,removePendingFollowUp:U.removePendingFollowUp,movePendingFollowUp:U.movePendingFollowUp,reorderPendingFollowUp:U.reorderPendingFollowUp,steerPendingFollowUp:U.steerPendingFollowUp,steeringFollowUpId:U.steeringFollowUpId},clarify:{clarifyPrompt:U.clarifyPrompt,clarifySubmitting:U.clarifySubmitting,clarifySubmitError:U.clarifySubmitError,submitClarifyAnswer:U.submitClarifyAnswer,cancelClarifyAnswer:U.cancelClarifyAnswer},agents:{chatAgents:N,displayAgentId:I,showChatAgentSelector:L,onChatAgentChange:F}}}var W9=300*1e3,jCe=Math.round(W9/6e4);function MCe(e){return`${Math.floor(e/60)}:${(e%60).toString().padStart(2,`0`)}`}function NCe(e){let t=(0,Y.c)(7),{prompt:n,submitting:r,submitError:i,labels:a,onSubmit:o,onCancel:s}=e;if(!n)return null;let c;return t[0]!==a||t[1]!==s||t[2]!==o||t[3]!==n||t[4]!==i||t[5]!==r?(c=(0,Z.jsx)(PCe,{prompt:n,submitting:r,submitError:i,labels:a,onSubmit:o,onCancel:s},n.requestId),t[0]=a,t[1]=s,t[2]=o,t[3]=n,t[4]=i,t[5]=r,t[6]=c):c=t[6],c}function PCe(e){let t=(0,Y.c)(70),{prompt:n,submitting:r,submitError:i,labels:a,onSubmit:o,onCancel:s}=e,[c,l]=(0,J.useState)(``),[u]=(0,J.useState)(ICe),[d,f]=(0,J.useState)(0),p=(0,J.useRef)(null),m,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{let e=window.setInterval(()=>f(FCe),1e3);return()=>window.clearInterval(e)},h=[],t[0]=m,t[1]=h):(m=t[0],h=t[1]),(0,J.useEffect)(m,h);let g,_;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{p.current?.focus()},_=[],t[2]=g,t[3]=_):(g=t[2],_=t[3]),(0,J.useEffect)(g,_);let v;t[4]===o?v=t[5]:(v=e=>{o(e)},t[4]=o,t[5]=v);let y=v,b=Math.max(0,Math.ceil((u-Date.now())/1e3)),x=`clarify-meta-${n.requestId}`,S=i?`clarify-err-${n.requestId}`:void 0,C;t[6]!==s||t[7]!==r?(C=e=>{e.key===`Escape`&&!r&&(e.preventDefault(),e.stopPropagation(),s())},t[6]=s,t[7]=r,t[8]=C):C=t[8];let w=C,T=Array.isArray(n.choices)&&n.choices.length>=2,E;t[9]!==a.clarifyDefaultChoice||t[10]!==n.default?(E=n.default?a.clarifyDefaultChoice.replace(`{{text}}`,n.default):null,t[9]=a.clarifyDefaultChoice,t[10]=n.default,t[11]=E):E=t[11];let D=E,O;t[12]===a.clarifyServerTimeout?O=t[13]:(O=a.clarifyServerTimeout.replace(`{{minutes}}`,String(jCe)),t[12]=a.clarifyServerTimeout,t[13]=O);let k=O,A;t[14]!==a.clarifyTimeRemaining||t[15]!==b?(A=a.clarifyTimeRemaining.replace(`{{time}}`,MCe(b)),t[14]=a.clarifyTimeRemaining,t[15]=b,t[16]=A):A=t[16];let j=A,M=a.clarifyRegionAria,N;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(N=X(`mb-4 rounded-lg border border-edge bg-surface-elevated px-4 py-3 text-sm text-fg shadow-sm outline-none`,AX.focusRingPanel),t[17]=N):N=t[17];let P;t[18]===a.clarifyResumeHint?P=t[19]:(P=(0,Z.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:a.clarifyResumeHint}),t[18]=a.clarifyResumeHint,t[19]=P);let F;t[20]===n.question?F=t[21]:(F=(0,Z.jsx)(OX,{content:n.question,compact:!0,className:`mb-3`}),t[20]=n.question,t[21]=F);let I;t[22]===k?I=t[23]:(I=(0,Z.jsx)(`li`,{children:k}),t[22]=k,t[23]=I);let L;t[24]!==a.clarifyDefaultTimeoutNote||t[25]!==n.default?(L=n.default?(0,Z.jsx)(`li`,{children:a.clarifyDefaultTimeoutNote}):null,t[24]=a.clarifyDefaultTimeoutNote,t[25]=n.default,t[26]=L):L=t[26];let R;t[27]===a.clarifySkipNote?R=t[28]:(R=(0,Z.jsx)(`li`,{children:a.clarifySkipNote}),t[27]=a.clarifySkipNote,t[28]=R);let z;t[29]===j?z=t[30]:(z=(0,Z.jsx)(`li`,{children:j}),t[29]=j,t[30]=z);let B;t[31]!==x||t[32]!==I||t[33]!==L||t[34]!==R||t[35]!==z?(B=(0,Z.jsxs)(`ul`,{id:x,className:`mb-3 list-inside list-disc space-y-1 text-xs text-fg-muted`,children:[I,L,R,z]}),t[31]=x,t[32]=I,t[33]=L,t[34]=R,t[35]=z,t[36]=B):B=t[36];let V;t[37]!==S||t[38]!==i?(V=i?(0,Z.jsx)(`div`,{id:S,role:`alert`,className:`mb-3 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:i}):null,t[37]=S,t[38]=i,t[39]=V):V=t[39];let H;t[40]!==c||t[41]!==D||t[42]!==T||t[43]!==a.clarifyChoicesGroupAria||t[44]!==a.clarifyCustomLabel||t[45]!==a.clarifyPlaceholder||t[46]!==a.clarifySend||t[47]!==a.clarifyUseDefault||t[48]!==o||t[49]!==y||t[50]!==n.choices||t[51]!==n.default||t[52]!==r?(H=T?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`max-h-[min(40vh,16rem)] overflow-y-auto overflow-x-hidden pr-1 [scrollbar-gutter:stable]`,"aria-label":a.clarifyChoicesGroupAria,children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:[n.choices.map(e=>(0,Z.jsx)(wA,{type:`button`,variant:`secondary`,disabled:r,className:X(`min-h-9 w-full justify-start rounded-lg px-3 py-2 text-left text-sm font-normal shadow-none`,`hover:border-edge`),onClick:()=>y(e),children:e},e)),n.default?(0,Z.jsx)(wA,{type:`button`,variant:`ghost`,disabled:r,className:X(`min-h-9 w-full justify-start rounded-lg border border-dashed border-edge px-3 py-2 text-left text-sm font-normal text-fg-muted`,`hover:border-edge hover:text-fg`),onClick:()=>y(n.default),children:D}):null]})}),(0,Z.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[(0,Z.jsx)(`p`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:a.clarifyCustomLabel}),(0,Z.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row sm:items-end`,onSubmit:e=>{e.preventDefault();let t=c.trim();t&&o(t)},children:[(0,Z.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),disabled:r,placeholder:a.clarifyPlaceholder,"aria-label":a.clarifyPlaceholder,className:`min-w-0 flex-1 rounded-md border border-edge bg-surface-panel px-3 py-2 text-fg placeholder:text-fg-muted focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent disabled:opacity-50`}),(0,Z.jsx)(wA,{type:`submit`,variant:`primary`,disabled:r||!c.trim(),className:`shrink-0 rounded-lg px-4 py-2 shadow-surface`,children:a.clarifySend})]})]})]}):(0,Z.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row sm:items-end`,onSubmit:e=>{e.preventDefault();let t=c.trim();t&&(o(t),l(``))},children:[(0,Z.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),disabled:r,placeholder:a.clarifyPlaceholder,"aria-label":a.clarifyPlaceholder,className:`min-w-0 flex-1 rounded-md border border-edge bg-surface-panel px-3 py-2 text-fg placeholder:text-fg-muted focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent disabled:opacity-50`}),(0,Z.jsx)(wA,{type:`submit`,variant:`primary`,disabled:r||!c.trim(),className:`shrink-0 rounded-lg px-4 py-2 shadow-surface`,children:a.clarifySend}),n.default?(0,Z.jsx)(wA,{type:`button`,variant:`secondary`,disabled:r,className:`shrink-0 rounded-lg px-3 py-2 text-sm font-normal text-fg-muted shadow-none hover:text-fg`,onClick:()=>y(n.default),children:a.clarifyUseDefault}):null]}),t[40]=c,t[41]=D,t[42]=T,t[43]=a.clarifyChoicesGroupAria,t[44]=a.clarifyCustomLabel,t[45]=a.clarifyPlaceholder,t[46]=a.clarifySend,t[47]=a.clarifyUseDefault,t[48]=o,t[49]=y,t[50]=n.choices,t[51]=n.default,t[52]=r,t[53]=H):H=t[53];let U;t[54]===s?U=t[55]:(U=()=>void s(),t[54]=s,t[55]=U);let W;t[56]!==a.clarifySkip||t[57]!==r||t[58]!==U?(W=(0,Z.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center justify-end gap-2 border-t border-edge-subtle pt-3`,children:(0,Z.jsx)(wA,{type:`button`,variant:`ghost`,disabled:r,className:`text-fg-muted hover:text-fg`,onClick:U,children:a.clarifySkip})}),t[56]=a.clarifySkip,t[57]=r,t[58]=U,t[59]=W):W=t[59];let G;return t[60]!==a.clarifyRegionAria||t[61]!==x||t[62]!==w||t[63]!==P||t[64]!==F||t[65]!==B||t[66]!==V||t[67]!==H||t[68]!==W?(G=(0,Z.jsxs)(`section`,{ref:p,tabIndex:-1,"aria-label":M,"aria-describedby":x,onKeyDown:w,className:N,children:[P,F,B,V,H,W]}),t[60]=a.clarifyRegionAria,t[61]=x,t[62]=w,t[63]=P,t[64]=F,t[65]=B,t[66]=V,t[67]=H,t[68]=W,t[69]=G):G=t[69],G}function FCe(e){return e+1}function ICe(){return Date.now()+W9}function G9(){let e=m(d(e=>e.language)),t=Se(e=>e.token),n=Qr(),{pathname:r}=Yr(),[i]=za(),a=(0,J.useRef)(null),o=(0,J.useRef)(0),[s,c]=(0,J.useState)(null),{auth:l,session:u,messages:f,stream:p,followUp:h,clarify:g,agents:_}=ACe(),v=i.get(`skill`)?.trim()??``,y=i.get(`slash`)?.trim()??``;(0,J.useEffect)(()=>{a.current=null},[u.sessionKey]),(0,J.useEffect)(()=>{if(!l.hasToken||!v&&!y||u.showSessionLoading||u.sessionRoutePending||!u.sessionKey)return;let e=()=>{let e=new URLSearchParams(i);e.delete(`skill`),e.delete(`slash`);let t=e.toString();n({pathname:r,search:t?`?${t}`:``},{replace:!0})},t=(t,n)=>{a.current!==n&&(a.current=n,queueMicrotask(()=>{o.current+=1,c({id:o.current,text:t}),e()}))};if(v){if(!q$(v)){e();return}let n=`${u.sessionKey}:skill:${v}`;t(`/skill:${v} `,n);return}if(!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(y)){e();return}let s=`${u.sessionKey}:slash:${y}`;a.current!==s&&queueMicrotask(()=>{(async()=>{try{let e=await v1(),t=y.toLowerCase(),n=e.find(e=>e.name.toLowerCase()===t||Array.isArray(e.aliases)&&e.aliases.some(e=>e.toLowerCase()===t));if(n){if(a.current===s)return;a.current=s,o.current+=1,c({id:o.current,text:S1(n)})}}finally{e()}})()})},[l.hasToken,v,y,i,u.showSessionLoading,u.sessionRoutePending,u.sessionKey,n,r]);let{scrollRef:b,atBottom:x,scrollToBottom:S,onScroll:C}=$Se({hasToken:l.hasToken,showSessionLoading:u.showSessionLoading,sessionKey:u.sessionKey,sending:p.sending,chatMessages:f.items,hasMore:u.hasMore,loadingMore:u.loadingMore,loadMoreMessages:u.loadMoreMessages});(0,J.useEffect)(()=>{c(null)},[u.sessionKey]);let w=(0,J.useCallback)(e=>{o.current+=1,c({id:o.current,text:e})},[]),T=(0,J.useMemo)(()=>!!u.sessionKey&&!u.showSessionLoading&&!u.sessionRoutePending&&f.items.length===0,[u.sessionKey,u.showSessionLoading,u.sessionRoutePending,f.items.length]),E=eQ(e=>e.setAgentId);(0,J.useEffect)(()=>{if(l.hasToken)return E(_.displayAgentId),()=>E(``)},[l.hasToken,_.displayAgentId,E]);let D=!u.showSessionLoading&&f.items.length===0&&!p.streaming,O=(0,J.useMemo)(()=>(u.sessionRoutePending&&u.decodedKey?u.decodedKey:u.sessionKey)?u.sessionName?.trim()||e.chat.newSession:e.nav.chat,[u.sessionKey,u.sessionName,u.sessionRoutePending,u.decodedKey,e.nav.chat,e.chat.newSession]);return l.hasToken?(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col bg-surface-panel`,children:[(0,Z.jsx)(Mye,{}),(0,Z.jsx)(wye,{chatHeadline:O,chatAgents:_.chatAgents?.items??[],showChatAgentSelector:_.showChatAgentSelector,chatAgentId:_.displayAgentId,onChatAgentChange:_.onChatAgentChange,chatAgentDisabled:u.showSessionLoading||u.sessionRoutePending}),(0,Z.jsxs)(`div`,{className:`relative mx-auto flex min-h-0 w-full max-w-[var(--max-width-chat)] flex-1 flex-col`,children:[u.sessionKey&&YR(u.sessionKey)&&!u.showSessionLoading&&!u.sessionRoutePending?(0,Z.jsx)(_ye,{sessionKey:u.sessionKey,streaming:p.streaming,sending:p.sending}):null,(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col px-3 sm:px-5 xl:px-6`,children:(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,Z.jsx)(`div`,{ref:b,className:X(`chat-messages min-h-0 flex-1 overflow-y-auto overflow-x-hidden [scrollbar-gutter:stable_both-edges]`,D?`chat-messages--compact-welcome pt-5 pb-2`:`py-4`),onScroll:C,children:u.showSessionLoading?(0,Z.jsx)(`div`,{className:`flex min-h-[min(40vh,20rem)] flex-col items-center justify-center gap-3 py-12 text-center text-sm text-fg-muted`,children:e.chat.loading}):(0,Z.jsxs)(Z.Fragment,{children:[u.loadingMore?(0,Z.jsx)(`div`,{className:`mb-3 text-center text-xs text-fg-muted`,children:e.chat.loadOlder}):null,p.error?(0,Z.jsx)(`div`,{className:`mb-4 rounded-md border border-edge bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-edge dark:bg-red-950/40 dark:text-red-300`,children:p.error}):null,(0,Z.jsx)(XSe,{messages:f.items,authToken:t??void 0,sessionKey:u.decodedKey??u.sessionKey,streaming:p.streaming,progress:p.progress,reasoningLevel:u.reasoningLevel,scrollElementRef:b,pinToBottom:x,onPickWelcomePrompt:w,onDeleteRound:p.deleteMessageRound,onRetryUserMessageRound:p.retryUserMessageRound,deleteRoundDisabled:p.streaming||p.sending,onAbortCurrentTurn:p.abort,onSendUserMessage:e=>{p.sendMessage(e)}},u.decodedKey??`new`)]})}),(0,Z.jsxs)(`div`,{className:X(`sticky bottom-0 z-10 shrink-0 bg-surface-panel`,D?`py-2.5`:`py-4`),children:[(0,Z.jsx)(NCe,{prompt:g.clarifyPrompt,submitting:g.clarifySubmitting,submitError:g.clarifySubmitError,labels:e.chat,onSubmit:g.submitClarifyAnswer,onCancel:g.cancelClarifyAnswer}),(0,Z.jsx)(Rve,{disabled:u.showSessionLoading||u.sessionRoutePending||!!g.clarifyPrompt,sending:p.sending,streaming:p.streaming,sessionKey:u.sessionKey,sessionManager:u.sessionManager,welcomeDraftSeed:s,canSelectWorkingDirectory:T,thinkingLevel:u.thinkingLevel,showThinkingSelector:u.modelSupportsThinking,onThinkingChange:u.onSessionThinkingLevelChange,onSend:p.sendMessage,onAbort:p.abort,onAddPendingFollowUp:(e,t)=>void h.addPendingFollowUp(e,t),onSteeringInterrupt:(e,t)=>void p.interruptAndSend(e,t),pendingFollowUps:h.pendingFollowUps,editingFollowUpId:h.editingFollowUpId,onBeginEditFollowUp:h.beginEditFollowUp,onCancelEditFollowUp:h.cancelEditFollowUp,onCommitEditFollowUp:(e,t,n,r)=>void h.commitEditFollowUp(e,t,n,r),onPendingFollowUpRemove:h.removePendingFollowUp,onPendingFollowUpMove:h.movePendingFollowUp,onPendingFollowUpReorder:h.reorderPendingFollowUp,onPendingFollowUpSteer:e=>void h.steerPendingFollowUp(e),steeringFollowUpId:h.steeringFollowUpId,sessionModel:u.sessionModel,showModelSelector:!!(u.sessionKey&&!u.sessionRoutePending),onModelChange:u.onSessionModelChange,modelDisabled:u.showSessionLoading||u.sessionRoutePending||p.streaming,contextUsageMessages:f.items,onChatAgentChange:_.showChatAgentSelector?_.onChatAgentChange:void 0,currentAgentId:_.displayAgentId})]})]})})]}),(0,Z.jsx)(ZSe,{visible:!u.showSessionLoading&&!x,onClick:()=>S(!0,!0)})]}):(0,Z.jsx)(`div`,{className:`mx-auto w-full max-w-[var(--max-width-chat)] px-3 py-16 text-center text-sm leading-relaxed text-fg-muted sm:px-5`,children:e.chat.needToken})}function LCe(){let e=(0,Y.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col`,children:(0,Z.jsx)(Li,{})}),e[0]=t):t=e[0],t}async function RCe(e){let t=await Ee(e);if(!t.ok){let e=await t.json().catch(()=>({})),n=Te(t.status,t.statusText,e.error?.message);throw Error(n)}return t.json()}function zCe(e){let t=(0,Y.c)(3),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={fetcher:RCe,revalidateOnFocus:!1,dedupingInterval:2e3,shouldRetryOnError:!0,errorRetryCount:2},t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,Z.jsx)(y,{value:r,children:n}),t[1]=n,t[2]=i),i}var BCe=(0,J.lazy)(()=>D(()=>import(`./sessions-page-5N4aF2Wk.js`).then(e=>({default:e.SessionsPage})),__vite__mapDeps([16,1,2,3,5,7,12,9]))),VCe=(0,J.lazy)(()=>D(()=>import(`./cron-page-DeGo-Vjc.js`).then(e=>({default:e.CronPage})),__vite__mapDeps([18,1,2,3,19,4,7,10,8,9,13,5]))),HCe=(0,J.lazy)(()=>D(()=>import(`./skills-page-sPAXhh8w.js`).then(e=>({default:e.SkillsPage})),__vite__mapDeps([20,1,21,2,3,19,7,9]))),UCe=(0,J.lazy)(()=>D(()=>import(`./logs-page-_d4UJ-qQ.js`).then(e=>({default:e.LogsPage})),__vite__mapDeps([17,1,2,3,7,9]))),WCe=(0,J.lazy)(()=>D(()=>import(`./settings-page-C18xBt4X.js`).then(e=>({default:e.SettingsPage})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]))),K9=(0,J.lazy)(()=>D(()=>import(`./agents-D3_-kNlZ.js`).then(e=>({default:e.AgentsSettingsPanel})),__vite__mapDeps([11,1,2,3,4,5,7,10,8,9,12]))),q9=(0,J.lazy)(()=>D(()=>import(`./channels-settings-nCaMb0a7.js`).then(e=>({default:e.ChannelsSettingsPanel})),__vite__mapDeps([25,1,2,3,5,6,7,8,9,26,14]))),J9=(0,J.lazy)(()=>D(()=>import(`./apps-page-D7v7649T.js`).then(e=>({default:e.AppsPage})),__vite__mapDeps([27,1,2,3,5,7,9]))),Y9=(0,J.lazy)(()=>D(()=>import(`./extension-page-D6JSyV27.js`).then(e=>({default:e.ExtensionPage})),__vite__mapDeps([28,1,3]))),X9=(0,J.lazy)(()=>D(()=>import(`./extension-settings-page-8PZcmWI7.js`).then(e=>({default:e.ExtensionSettingsPage})),__vite__mapDeps([29,1,5,3,7,26,14,15,9]))),GCe=(0,J.lazy)(()=>D(()=>import(`./extension-debug-page-BZngZWbO.js`).then(e=>({default:e.ExtensionDebugPage})),__vite__mapDeps([30,1,3]))),KCe=(0,J.lazy)(()=>D(()=>import(`./share-preview-page-D4EG_vM1.js`).then(e=>({default:e.SharePreviewPage})),__vite__mapDeps([31,1,21,7,3])));function Z9(){let e=(0,Y.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-1 items-center justify-center text-sm text-fg-muted`,"aria-busy":!0,children:`Loading…`}),e[0]=t):t=e[0],t}function Q9(e){let t=(0,Y.c)(2),{tab:n}=e,r=n?`/settings/agent-defaults?tab=${encodeURIComponent(n)}`:`/settings/agent-defaults`,i;return t[0]===r?i=t[1]:(i=(0,Z.jsx)(Ii,{to:r,replace:!0}),t[0]=r,t[1]=i),i}function qCe(){let e=(0,Y.c)(4),{agentId:t}=ni(),n;e[0]===t?n=e[1]:(n=typeof t==`string`?t.trim():``,e[0]=t,e[1]=n);let r=n,i=r?`/agents/${encodeURIComponent(r)}`:`/agents`,a;return e[2]===i?a=e[3]:(a=(0,Z.jsx)(Ii,{to:i,replace:!0}),e[2]=i,e[3]=a),a}function $9(){let e=(0,Y.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"aria-busy":!0,children:(0,Z.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main flex-1 px-4 py-8`,children:[(0,Z.jsx)(`div`,{className:`h-8 w-48 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,Z.jsx)(`div`,{className:`mt-6 h-36 animate-pulse rounded-xl bg-surface-hover`}),(0,Z.jsx)(`div`,{className:`mt-4 h-24 animate-pulse rounded-xl bg-surface-hover`}),(0,Z.jsx)(`p`,{className:`mt-6 text-sm text-fg-muted`,children:`Loading…`})]})}),e[0]=t):t=e[0],t}var JCe=Ea([{path:`/share/:token`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)(Z9,{}),children:(0,Z.jsx)(KCe,{})})},{path:`/`,element:(0,Z.jsx)(Zhe,{}),children:[{index:!0,element:(0,Z.jsx)(Ii,{to:`/chat`,replace:!0})},{path:`chat`,element:(0,Z.jsx)(LCe,{}),children:[{index:!0,element:(0,Z.jsx)(G9,{})},{path:`new`,element:(0,Z.jsx)(G9,{})},{path:`:sessionKey`,element:(0,Z.jsx)(G9,{})}]},{path:`sessions`,element:(0,Z.jsx)(Ii,{to:`/settings/sessions`,replace:!0})},{path:`logs`,element:(0,Z.jsx)(Ii,{to:`/settings/logs`,replace:!0})},{path:`cron`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)(Z9,{}),children:(0,Z.jsx)(VCe,{})})},{path:`skills`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)(Z9,{}),children:(0,Z.jsx)(HCe,{})})},{path:`channels`,children:[{index:!0,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)(Z9,{}),children:(0,Z.jsx)(q9,{})})},{path:`:channelId`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)(Z9,{}),children:(0,Z.jsx)(q9,{})})}]},{path:`mcp`,element:(0,Z.jsx)(Ii,{to:`/settings/agent-mcp`,replace:!0})},{path:`agents`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)(Z9,{}),children:(0,Z.jsx)(K9,{})})},{path:`agents/:agentId`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)(Z9,{}),children:(0,Z.jsx)(K9,{})})},{path:`apps`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)(Z9,{}),children:(0,Z.jsx)(J9,{})})},{path:`apps/:extensionId`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)(Z9,{}),children:(0,Z.jsx)(Y9,{})})},{path:`apps/:extensionId/:pageId`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)(Z9,{}),children:(0,Z.jsx)(Y9,{})})},{path:`settings`,element:(0,Z.jsx)(Sge,{children:(0,Z.jsx)(hge,{})}),children:[{index:!0,element:(0,Z.jsx)(Ii,{to:`overview`,replace:!0})},{path:`skills`,element:(0,Z.jsx)(Ii,{to:`/skills`,replace:!0})},{path:`channels`,element:(0,Z.jsx)(Ii,{to:`/channels`,replace:!0})},{path:`mcp`,element:(0,Z.jsx)(Ii,{to:`/settings/agent-mcp`,replace:!0})},{path:`sessions`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)(Z9,{}),children:(0,Z.jsx)(BCe,{})})},{path:`logs`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)(Z9,{}),children:(0,Z.jsx)(UCe,{})})},{path:`apps`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)($9,{}),children:(0,Z.jsx)(J9,{})})},{path:`agents`,element:(0,Z.jsx)(Ii,{to:`/agents`,replace:!0})},{path:`agents/:agentId`,element:(0,Z.jsx)(qCe,{})},{path:`agent-chat`,element:(0,Z.jsx)(Q9,{})},{path:`agent-workspace`,element:(0,Z.jsx)(Q9,{tab:`workspace`})},{path:`agent-runtime`,element:(0,Z.jsx)(Q9,{tab:`runtime`})},{path:`agent-context`,element:(0,Z.jsx)(Q9,{tab:`context`})},{path:`agent-memory`,element:(0,Z.jsx)(Q9,{tab:`memory`})},{path:`agent-tools`,element:(0,Z.jsx)(Q9,{tab:`tools`})},{path:`agent-skills`,element:(0,Z.jsx)(Q9,{tab:`skills`})},{path:`agent-system-prompt`,element:(0,Z.jsx)(Q9,{tab:`system-prompt`})},{path:`agent-models`,element:(0,Z.jsx)(Ii,{to:`/settings/models`,replace:!0})},{path:`extensions/debug`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)($9,{}),children:(0,Z.jsx)(GCe,{})})},{path:`ext/:extensionId`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)($9,{}),children:(0,Z.jsx)(X9,{})})},{path:`ext/:extensionId/:panelId`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)($9,{}),children:(0,Z.jsx)(X9,{})})},{path:`:section`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)($9,{}),children:(0,Z.jsx)(WCe,{})})}]}]}]);function YCe(){let e=(0,Y.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],(0,J.useEffect)(XCe,t),null}function XCe(){let e=ve.persist.onFinishHydration(QCe),t=RA.persist.onFinishHydration(ZCe),n=ye();return()=>{e?.(),t?.(),n()}}function ZCe(){zA()}function QCe(){be()}function $Ce(){let e=(0,Y.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(YCe,{}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(He,{i18n:u,children:(0,Z.jsx)(zCe,{children:(0,Z.jsx)(wI,{children:(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[t,(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col [&>*]:min-h-0 [&>*]:flex-1`,children:(0,Z.jsx)(Za,{router:JCe})})]})})})}),e[1]=n):n=e[1],n}document.documentElement.setAttribute(`lang`,l(f())),xe(),LA(),Ce(),(0,TO.createRoot)(document.getElementById(`root`)).render((0,Z.jsx)(J.StrictMode,{children:(0,Z.jsx)($Ce,{})}));export{B$ as $,El as $i,EA as $n,jg as $r,WV as $t,s8 as A,tu as Ai,xF as An,qb as Ar,YZ as At,Hle as B,Ul as Bi,Gj as Bn,jv as Br,OX as Bt,jhe as C,Cd as Ci,FI as Cn,qx as Cr,JQ as Ct,d8 as D,Uu as Di,PI as Dn,rx as Dr,$Z as Dt,Nhe as E,ld as Ei,EI as En,px as Er,eQ as Et,A1 as F,Xl as Fi,BP as Fn,vb as Fr,IZ as Ft,zle as G,Fl as Gi,ij as Gn,fv as Gr,lH as Gt,O1 as H,zl as Hi,kj as Hn,bv as Hr,cU as Ht,Ple as I,Yl as Ii,HP as In,ub as Ir,AZ as It,Kle as J,Ml as Ji,AA as Jn,Qg as Jr,oH as Jt,Ule as K,Pl as Ki,nj as Kn,uv as Kr,dH as Kt,Fle as L,Jl as Li,VP as Ln,Ky as Lr,PX as Lt,R1 as M,$l as Mi,yF as Mn,Ib as Mr,qZ as Mt,P1 as N,Ql as Ni,gF as Nn,kb as Nr,BZ as Nt,Dhe as O,Su as Oi,UF as On,tx as Or,JZ as Ot,j1 as P,Zl as Pi,vF as Pn,Tb as Pr,UZ as Pt,z$ as Q,Dl as Qi,DA as Qn,Mg as Qr,KV as Qt,qle as R,ql as Ri,zP as Rn,xy as Rr,jX as Rt,Ohe as S,kd as Si,tL as Sn,oS as Sr,qQ as St,Ahe as T,yd as Ti,AI as Tn,zx as Tr,DQ as Tt,Ble as U,Rl as Ui,rj as Un,vv as Ur,uU as Ut,Vle as V,Bl as Vi,Oj as Vn,xv as Vr,AU as Vt,Rle as W,Ll as Wi,tj as Wn,_v as Wr,WH as Wt,P$ as X,kl as Xi,OA as Xn,Fg as Xr,YV as Xt,j$ as Y,jl as Yi,jA as Yn,Ig as Yr,rH as Yt,I$ as Z,Ol as Zi,TA as Zn,Pg as Zr,JV as Zt,b8 as _,km as _i,pL as _n,fw as _r,YQ as _t,b_e as a,no as aa,Sg as ai,WR as an,iO as ar,k$ as at,Mhe as b,Sp as bi,rL as bn,NC as br,KQ as bt,s5 as c,Yr as ca,vg as ci,VR as cn,JE as cr,h$ as ct,k8 as d,za as da,hg as di,KR as dn,TE as dr,$Q as dt,yc as ea,Ag as ei,QV as en,kA as er,F$ as et,S8 as f,Ve as fa,mg as fi,GR as fn,QT as fr,e$ as ft,v8 as g,jh as gi,mL as gn,Vw as gr,UQ as gt,y8 as h,ig as hi,fL as hn,Gw as hr,WQ as ht,d5 as i,uo as ia,Cg as ii,iz as in,oO as ir,M$ as it,c8 as j,eu as ji,bF as jn,Kb as jr,GZ as jt,Ehe as k,uu as ki,SF as kn,Jb as kr,KZ as kt,o5 as l,Qr as la,_g as li,BR as ln,FE as lr,m$ as lt,lge as m,ug as mi,gL as mn,CT as mr,XQ as mt,$7 as n,Xo as na,Tg as ni,XV as nn,X as nr,O$ as nt,x_e as o,ja as oa,bg as oi,HR as on,RD as or,A$ as ot,x8 as p,pg as pi,qR as pn,UT as pr,t$ as pt,Ile as q,Nl as qi,VA as qn,H_ as qr,sH as qt,G7 as r,Jo as ra,wg as ri,$V as rn,cO as rr,L$ as rt,c5 as s,Ii as sa,yg as si,JR as sn,gD as sr,f$ as st,b9 as t,Ss as ta,Eg as ti,eH as tn,wA as tr,R$ as tt,r5 as u,ni as ua,gg as ui,zR as un,EE as ur,g$ as ut,p8 as v,Kp as vi,lL as vn,rw as vr,GQ as vt,f8 as w,xd as wi,jI as wn,Ux as wr,CQ as wt,khe as x,xf as xi,nL as xn,dC as xr,ZQ as xt,m8 as y,Np as yi,iL as yn,WC as yr,QQ as yt,Lle as z,Kl as zi,CP as zn,Lv as zr,AX as zt};
4700
+ `)}function DSe(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function OSe(e){return e===`zh`?ASe():y9()}function kSe(){return y9()}function y9(){return{header:{collapse:`Collapse`,expand:`Expand`,runningMeta:(e,t)=>t?`${e} · ${t}`:`${e}`,completedMeta:(e,t)=>t?`✓ ${e} · ${t}`:`✓ ${e}`,failedMeta:`failed`},phase:{countTpl:(e,t)=>`${e}/${t}`,runningTag:e=>`· ${e} running`,errorsTag:e=>`· ${e} errors`,skippedTag:e=>`· ${e} skipped`,showPrompt:`Show prompt`,hidePrompt:`Hide prompt`,promptHeading:`Prompt`,resultPreviewHeading:`Result`,errorHeading:`Error`,emptyPreview:`(no preview)`,agentNumber:e=>`#${e}`},result:{topFindingsHeading:e=>`Top findings (${e})`,topRisksHeading:e=>`Top risks (${e})`,executiveSummaryHeading:`Executive summary`,summaryHeading:`Summary`,openQuestionsHeading:`Open questions`,moreSuffix:e=>`${e} more…`,rawHeading:`View raw result`,emptyResult:`(no result)`},error:{titleParse:`Workflow parse error`,titleAbort:`Workflow aborted`,titleTimeout:`Workflow timed out`,titleRuntime:`Workflow failed`,viewScriptHeading:`View submitted script`},cancel:`Cancel workflow`,saveAria:`Save workflow…`,saveTitle:`Save this workflow under a name (~/.xopc/workflows/)`,savePlaceholder:`snake_case_name`,saveSubmit:`Save`,saveCancel:`Cancel`,saveDispatched:`Saved`,copyAria:`Copy result`,copyDoneAria:`Copied`,moreAria:`More actions`,viewSubagentsHeading:`View subagents`,recentLogsHeading:`Logs`}}function ASe(){return{header:{collapse:`收起`,expand:`展开`,runningMeta:(e,t)=>t?`${e} · ${t}`:`${e}`,completedMeta:(e,t)=>t?`✓ ${e} · ${t}`:`✓ ${e}`,failedMeta:`失败`},phase:{countTpl:(e,t)=>`${e}/${t}`,runningTag:e=>`· ${e} 运行中`,errorsTag:e=>`· ${e} 失败`,skippedTag:e=>`· ${e} 已跳过`,showPrompt:`查看 prompt`,hidePrompt:`收起 prompt`,promptHeading:`Prompt`,resultPreviewHeading:`结果预览`,errorHeading:`错误`,emptyPreview:`(暂无预览)`,agentNumber:e=>`#${e}`},result:{topFindingsHeading:e=>`主要发现(${e})`,topRisksHeading:e=>`主要风险(${e})`,executiveSummaryHeading:`摘要`,summaryHeading:`总结`,openQuestionsHeading:`待解决的问题`,moreSuffix:e=>`还有 ${e} 条…`,rawHeading:`查看原始结果`,emptyResult:`(无结果)`},error:{titleParse:`工作流解析失败`,titleAbort:`工作流已中止`,titleTimeout:`工作流超时`,titleRuntime:`工作流执行失败`,viewScriptHeading:`查看提交的脚本`},cancel:`取消工作流`,saveAria:`保存工作流…`,saveTitle:`把这个工作流保存到 ~/.xopc/workflows/`,savePlaceholder:`snake_case 名字`,saveSubmit:`保存`,saveCancel:`取消`,saveDispatched:`已保存`,copyAria:`复制结果`,copyDoneAria:`已复制`,moreAria:`更多操作`,viewSubagentsHeading:`查看子 agent`,recentLogsHeading:`日志`}}function jSe(e,t,n,r,i,a){if(e.type===`text`)return n?(0,Z.jsx)(`div`,{className:`min-w-0`,children:(0,Z.jsx)(iSe,{text:dR(JL(e.text??``))})},t):(0,Z.jsx)(`div`,{className:`markdown-content min-w-0`,children:(0,Z.jsx)(OX,{content:e.text,compact:!0})},t);if(e.type===`image`&&e.source?.data){let n=a??0;return i?(0,Z.jsx)(`button`,{type:`button`,className:X(`inline-block max-w-full rounded-lg p-0 text-left`,AX.press,AX.focusRingPanel,`cursor-pointer`),onClick:()=>i(e,n),title:r,"aria-label":r,children:(0,Z.jsx)(`img`,{src:e.source.data,className:`max-h-96 max-w-full rounded-lg align-top`,alt:``})},t):(0,Z.jsx)(`img`,{src:e.source.data,className:`max-h-96 max-w-full rounded-lg`,alt:``},t)}return null}function MSe(e,t){for(let n=t;n<e.length;n++){let t=e[n];if(t.type===`text`&&(t.text??``).length>0)return!0}return!1}function NSe(e,t,n,r,i,a,o,s,c,l,u){let d=[],f=u??{},p=f.labels??kSe(),m=0,h=0;for(;m<e.length;){let u=e[m];if(u.type===`tool_use`&&s9(u)){d.push((0,Z.jsx)(wSe,{block:u,startedAt:f.getStartedAt?.(u),onAbort:f.onAbort,onSendChatMessage:f.onSendChatMessage,labels:p},`workflow-${u.id??m}`)),m++;continue}if(u.type===`thinking`||u.type===`tool_use`){let s=m;for(;m<e.length;){let t=e[m];if(t.type===`thinking`){m++;continue}if(t.type===`tool_use`&&!s9(t)){m++;continue}break}let c=e.slice(s,m);if(c.length>0){let u=!t&&MSe(e,m);d.push((0,Z.jsx)(Yxe,{blocks:c,toolLabels:r,stepLabels:i,clusterLabels:a,cardLabels:o,sessionKey:l,isMessageStreaming:!t&&n,finalAnswerStarted:u},`steps-${s}`))}}else{let e=u.type===`image`?h++:0,n=jSe(u,`block-${m}`,t,s,c,u.type===`image`?e:m);n&&d.push(n),m++}}return d}function b9(e){let t=(0,Y.c)(28),{open:n,title:r,description:i,confirmLabel:a,cancelLabel:o,destructive:s,onConfirm:c,onCancel:l}=e,u;t[0]===l?u=t[1]:(u=e=>{e||l()},t[0]=l,t[1]=u);let d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(ie,{className:X(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,v8)}),t[2]=d):d=t[2];let f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=X(`fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,y8,`rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),t[3]=f):f=t[3];let p;t[4]===r?p=t[5]:(p=(0,Z.jsx)(ue,{className:`text-base font-semibold text-fg`,children:r}),t[4]=r,t[5]=p);let m;t[6]===i?m=t[7]:(m=(0,Z.jsx)(le,{className:`mt-2 max-h-[min(50vh,16rem)] overflow-y-auto text-sm text-fg-muted whitespace-pre-wrap break-all`,children:i}),t[6]=i,t[7]=m);let h;t[8]!==o||t[9]!==l?(h=(0,Z.jsx)(wA,{type:`button`,variant:`secondary`,onClick:l,children:o}),t[8]=o,t[9]=l,t[10]=h):h=t[10];let g=s&&`border-danger/40 bg-danger text-white hover:bg-danger/90 dark:border-danger/40`,_;t[11]===g?_=t[12]:(_=X(g),t[11]=g,t[12]=_);let v;t[13]!==a||t[14]!==c||t[15]!==_?(v=(0,Z.jsx)(wA,{type:`button`,variant:`secondary`,className:_,onClick:c,children:a}),t[13]=a,t[14]=c,t[15]=_,t[16]=v):v=t[16];let y;t[17]!==h||t[18]!==v?(y=(0,Z.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[h,v]}),t[17]=h,t[18]=v,t[19]=y):y=t[19];let b;t[20]!==y||t[21]!==p||t[22]!==m?(b=(0,Z.jsxs)(G,{children:[d,(0,Z.jsxs)(se,{className:f,children:[p,m,y]})]}),t[20]=y,t[21]=p,t[22]=m,t[23]=b):b=t[23];let x;return t[24]!==n||t[25]!==u||t[26]!==b?(x=(0,Z.jsx)(q,{open:n,onOpenChange:u,children:b}),t[24]=n,t[25]=u,t[26]=b,t[27]=x):x=t[27],x}function x9(e){return e?new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}):``}var S9=X(`inline-flex size-9 shrink-0 items-center justify-center rounded-lg`,`text-fg-muted transition-colors transition-transform duration-150 ease-out`,`hover:bg-surface-hover hover:text-fg active:scale-95`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,AX.disabled),C9=X(`inline-flex h-8 shrink-0 items-center justify-center gap-1 rounded-md px-2 text-xs text-fg-muted transition-colors`,`hover:bg-surface-hover hover:text-fg active:scale-[0.98]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,AX.disabled),PSe=(0,J.memo)(function(e){let t=(0,Y.c)(202),{message:n,authToken:r,sessionKey:i,isStreaming:a,progress:o,reasoningLevel:s,messageIndex:c,onDeleteRound:l,onRetryUserMessageRound:u,userMessageCanRetry:f,deleteRoundDisabled:p,onAbortCurrentTurn:h,onSendUserMessage:g}=e,_=s===void 0?`stream`:s,v=f===void 0?!1:f,y=p===void 0?!1:p,b=d(FSe),x;t[0]===b?x=t[1]:(x=m(b),t[0]=b,t[1]=x);let S=x,C=n.role===`user`||n.role===`user-with-attachments`,w=n.role===`assistant`,T=C?S.chat.you:w?S.chat.assistant:S.chat.tool,E;t[2]!==S.chat.noOutput||t[3]!==S.chat.toolInput||t[4]!==S.chat.toolOutput?(E={input:S.chat.toolInput,output:S.chat.toolOutput,noOutput:S.chat.noOutput},t[2]=S.chat.noOutput,t[3]=S.chat.toolInput,t[4]=S.chat.toolOutput,t[5]=E):E=t[5];let D=E,O;t[6]!==S.chat.stepDetails||t[7]!==S.chat.stepEditFile||t[8]!==S.chat.stepFetchUrl||t[9]!==S.chat.stepListDirectory||t[10]!==S.chat.stepOpenUrl||t[11]!==S.chat.stepReadFile||t[12]!==S.chat.stepRunCommand||t[13]!==S.chat.stepSearchedWeb||t[14]!==S.chat.stepUnknownTool||t[15]!==S.chat.stepWriteFile||t[16]!==S.chat.thoughts||t[17]!==S.chat.thoughtsStreaming||t[18]!==S.chat.viewSteps_one||t[19]!==S.chat.viewSteps_other?(O={thoughts:S.chat.thoughts,thoughtsStreaming:S.chat.thoughtsStreaming,viewSteps_one:S.chat.viewSteps_one,viewSteps_other:S.chat.viewSteps_other,searchedWeb:S.chat.stepSearchedWeb,readFile:S.chat.stepReadFile,stepDetails:S.chat.stepDetails,runCommand:S.chat.stepRunCommand,listDirectory:S.chat.stepListDirectory,writeFile:S.chat.stepWriteFile,editFile:S.chat.stepEditFile,openUrl:S.chat.stepOpenUrl,fetchUrl:S.chat.stepFetchUrl,unknownTool:S.chat.stepUnknownTool},t[6]=S.chat.stepDetails,t[7]=S.chat.stepEditFile,t[8]=S.chat.stepFetchUrl,t[9]=S.chat.stepListDirectory,t[10]=S.chat.stepOpenUrl,t[11]=S.chat.stepReadFile,t[12]=S.chat.stepRunCommand,t[13]=S.chat.stepSearchedWeb,t[14]=S.chat.stepUnknownTool,t[15]=S.chat.stepWriteFile,t[16]=S.chat.thoughts,t[17]=S.chat.thoughtsStreaming,t[18]=S.chat.viewSteps_one,t[19]=S.chat.viewSteps_other,t[20]=O):O=t[20];let k=O,A;t[21]!==S.chat.stepsClusterJoin||t[22]!==S.chat.stepsClusterJoinFinal||t[23]!==S.chat.stepsClusterMoreSuffix?(A={join:S.chat.stepsClusterJoin,joinFinal:S.chat.stepsClusterJoinFinal,moreSuffix:S.chat.stepsClusterMoreSuffix},t[21]=S.chat.stepsClusterJoin,t[22]=S.chat.stepsClusterJoinFinal,t[23]=S.chat.stepsClusterMoreSuffix,t[24]=A):A=t[24];let j;t[25]!==S.chat.stepsClusterDone||t[26]!==S.chat.stepsClusterIng||t[27]!==A?(j={done:S.chat.stepsClusterDone,ing:S.chat.stepsClusterIng,join:A},t[25]=S.chat.stepsClusterDone,t[26]=S.chat.stepsClusterIng,t[27]=A,t[28]=j):j=t[28];let M=j,N=S.chat.toolCard,P=_===`off`,F;bb0:{if(!P){let e;t[29]===n.content?e=t[30]:(e=n.content??[],t[29]=n.content,t[30]=e),F=e;break bb0}let e;t[31]===n.content?e=t[32]:(e=n.content??[],t[31]=n.content,t[32]=e);let r;t[33]===e?r=t[34]:(r=e.filter(ISe),t[33]=e,t[34]=r),F=r}let I=F,L;bb1:{if(!w){L=I;break bb1}let e;t[35]===I?e=t[36]:(e=I??[],t[35]=I,t[36]=e);let n;t[37]===e?n=t[38]:(n=e.filter(LSe),t[37]=e,t[38]=n),L=n}let R=L,z;t[39]!==w||t[40]!==n.content?(z=w?Gbe(n.content):[],t[39]=w,t[40]=n.content,t[41]=z):z=t[41];let B=z,V;t[42]!==w||t[43]!==n.content?(V=w?(n.content??[]).filter(RSe):[],t[42]=w,t[43]=n.content,t[44]=V):V=t[44];let H=V,U;t[45]!==H||t[46]!==w?(U=w?Kbe(H):[],t[45]=H,t[46]=w,t[47]=U):U=t[47];let W=U,G=w&&(B.length>0||W.length>0),ee;bb2:{if(!w){ee=n.attachments;break bb2}let e;t[48]!==B||t[49]!==n.attachments?(e=Ube(n.attachments,B),t[48]=B,t[49]=n.attachments,t[50]=e):e=t[50],ee=e}let K=ee,te=P&&o?.stage===`thinking`?null:o,ne;t[51]!==n.content||t[52]!==P?(ne=P?!1:!!n.content?.some(zSe),t[51]=n.content,t[52]=P,t[53]=ne):ne=t[53];let re=ne,ie=!!n.timestamp||!!te?.message||a&&!re,ae;t[54]!==w||t[55]!==n.content?(ae=w?qbe(n.content??[]):``,t[54]=w,t[55]=n.content,t[56]=ae):ae=t[56];let oe=ae,se;t[57]!==oe||t[58]!==w||t[59]!==n.content?(se=w&&oe?Ybe(n.content??[]):``,t[57]=oe,t[58]=w,t[59]=n.content,t[60]=se):se=t[60];let q=se,ce;bb3:{if(!C){ce=``;break bb3}let e;t[61]===n.content?e=t[62]:(e=fR(n.content),t[61]=n.content,t[62]=e),ce=e}let le=ce,[ue,de]=(0,J.useState)(null),[fe,pe]=(0,J.useState)(!1),[me,he]=(0,J.useState)(null),ge;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(e,t)=>{let n=C7(e,t);n&&he(n)},t[63]=ge):ge=t[63];let _e=ge,ve;t[64]===q?ve=t[65]:(ve=()=>{q&&lH(q).then(e=>{e&&(de(`plain`),window.setTimeout(()=>de(BSe),2e3))})},t[64]=q,t[65]=ve);let ye=ve,be;t[66]===oe?be=t[67]:(be=()=>{oe&&lH(oe).then(e=>{e&&(de(`markdown`),window.setTimeout(()=>de(VSe),2e3))})},t[66]=oe,t[67]=be);let xe=be,Se;t[68]===le?Se=t[69]:(Se=()=>{le&&lH(le).then(e=>{e&&(de(`user`),window.setTimeout(()=>de(HSe),2e3))})},t[68]=le,t[69]=Se);let Ce=Se,we;t[70]!==c||t[71]!==l?(we=()=>{c==null||!l||pe(!0)},t[70]=c,t[71]=l,t[72]=we):we=t[72];let Te=we,Ee;t[73]!==c||t[74]!==l?(Ee=()=>{c==null||!l||(l(c),pe(!1))},t[73]=c,t[74]=l,t[75]=Ee):Ee=t[75];let De=Ee,Oe;t[76]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=()=>{pe(!1)},t[76]=Oe):Oe=t[76];let ke=Oe,Ae;if(t[77]!==n||t[78]!==P){bb4:{let e=$ye(n);if(P){Ae=e.filter(USe);break bb4}Ae=e}t[77]=n,t[78]=P,t[79]=Ae}else Ae=t[79];let je=Ae,Me=y||!v,Ne=C?`justify-end`:`justify-start`,Pe;t[80]===Ne?Pe=t[81]:(Pe=X(`group/msg flex w-full min-w-0`,Ne),t[80]=Ne,t[81]=Pe);let Fe=C?`flex w-full flex-col items-end`:`w-full`,Ie;t[82]===Fe?Ie=t[83]:(Ie=X(`min-w-0 max-w-[min(85%,var(--max-width-chat))]`,Fe),t[82]=Fe,t[83]=Ie);let Le;t[84]===T?Le=t[85]:(Le=(0,Z.jsx)(`span`,{className:`sr-only`,children:T}),t[84]=T,t[85]=Le);let Re;t[86]!==a||t[87]!==C||t[88]!==S.chat.thinkingLabel||t[89]!==n.timestamp||t[90]!==te||t[91]!==ie||t[92]!==re?(Re=C&&ie?(0,Z.jsxs)(`div`,{className:`mb-2 flex w-full min-w-0 flex-wrap items-center justify-end gap-x-2 gap-y-0.5 text-xs`,children:[n.timestamp?(0,Z.jsx)(`time`,{suppressHydrationWarning:!0,className:`shrink-0 tabular-nums text-fg-disabled`,dateTime:new Date(n.timestamp).toISOString(),children:x9(n.timestamp)}):null,te?.message?(0,Z.jsx)(`span`,{className:`text-fg-subtle`,title:te.detail??``,children:te.message}):null,a&&!re&&!te?.message?(0,Z.jsx)(`span`,{className:`text-fg-subtle`,children:S.chat.thinkingLabel}):null]}):null,t[86]=a,t[87]=C,t[88]=S.chat.thinkingLabel,t[89]=n.timestamp,t[90]=te,t[91]=ie,t[92]=re,t[93]=Re):Re=t[93];let ze;t[94]!==a||t[95]!==C||t[96]!==S.chat.thinkingLabel||t[97]!==n.timestamp||t[98]!==te||t[99]!==ie||t[100]!==re?(ze=!C&&ie?(0,Z.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-baseline gap-x-2 gap-y-0.5 text-xs text-fg-disabled`,children:[n.timestamp?(0,Z.jsx)(`time`,{suppressHydrationWarning:!0,className:`tabular-nums`,dateTime:new Date(n.timestamp).toISOString(),children:x9(n.timestamp)}):null,te?.message?(0,Z.jsx)(`span`,{className:`text-fg-subtle`,title:te.detail??``,children:te.message}):null,a&&!re&&!te?.message?(0,Z.jsx)(`span`,{className:`text-fg-subtle`,children:S.chat.thinkingLabel}):null]}):null,t[94]=a,t[95]=C,t[96]=S.chat.thinkingLabel,t[97]=n.timestamp,t[98]=te,t[99]=ie,t[100]=re,t[101]=ze):ze=t[101];let Be=C?`ltr`:void 0,Ve=C&&`w-fit max-w-full rounded-xl border border-edge-subtle/70 bg-surface-hover/90 px-4 py-3 text-left shadow-sm dark:border-edge-subtle dark:bg-surface-hover/50`,He;t[102]===Ve?He=t[103]:(He=X(`min-w-0 text-sm leading-relaxed text-fg`,Ve),t[102]=Ve,t[103]=He);let Ue;t[104]!==N||t[105]!==M||t[106]!==R||t[107]!==w||t[108]!==a||t[109]!==C||t[110]!==b||t[111]!==S.chat.attachmentPreviewImage||t[112]!==h||t[113]!==g||t[114]!==i||t[115]!==k||t[116]!==D?(Ue=(R?.length??0)>0?(0,Z.jsxs)(Z.Fragment,{children:[NSe(R,C,w&&a,D,k,M,N,S.chat.attachmentPreviewImage,_e,i,{labels:OSe(b),onAbort:w&&a?h:void 0,onSendChatMessage:g}),a?(0,Z.jsx)(`span`,{className:`inline-block h-3 w-0.5 animate-pulse bg-accent align-middle`}):null]}):a?(0,Z.jsx)(`span`,{className:`inline-block h-3 w-0.5 animate-pulse bg-accent`}):null,t[104]=N,t[105]=M,t[106]=R,t[107]=w,t[108]=a,t[109]=C,t[110]=b,t[111]=S.chat.attachmentPreviewImage,t[112]=h,t[113]=g,t[114]=i,t[115]=k,t[116]=D,t[117]=Ue):Ue=t[117];let We;t[118]!==w||t[119]!==je?(We=w&&je.length>0?(0,Z.jsx)(lbe,{blocks:je}):null,t[118]=w,t[119]=je,t[120]=We):We=t[120];let Ge;t[121]!==W||t[122]!==B||t[123]!==r||t[124]!==S.chat.messageArtifactsHeading||t[125]!==i||t[126]!==G?(Ge=G?(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle/60 bg-surface-elevated/20 px-3 py-2.5`,role:`group`,"aria-label":S.chat.messageArtifactsHeading,children:[(0,Z.jsx)(`div`,{className:`mb-1.5 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:S.chat.messageArtifactsHeading}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[B.length>0?(0,Z.jsx)(_7,{paths:B,sessionKey:i}):null,W.length>0?(0,Z.jsx)(t7,{attachments:W,authToken:r,sessionKey:i,layout:`assistant`}):null]})]}):null,t[121]=W,t[122]=B,t[123]=r,t[124]=S.chat.messageArtifactsHeading,t[125]=i,t[126]=G,t[127]=Ge):Ge=t[127];let Ke;t[128]!==K||t[129]!==r||t[130]!==C||t[131]!==i||t[132]!==le?(Ke=K?.length?C?(0,Z.jsx)(t7,{attachments:K,authToken:r,sessionKey:i,layout:`user`,centerUserVoiceRow:le.length===0}):(0,Z.jsx)(t7,{attachments:K,authToken:r,sessionKey:i,layout:`assistant`}):null,t[128]=K,t[129]=r,t[130]=C,t[131]=i,t[132]=le,t[133]=Ke):Ke=t[133];let qe;t[134]!==Ue||t[135]!==We||t[136]!==Ge||t[137]!==Ke?(qe=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[Ue,We,Ge,Ke]}),t[134]=Ue,t[135]=We,t[136]=Ge,t[137]=Ke,t[138]=qe):qe=t[138];let Je;t[139]!==Be||t[140]!==He||t[141]!==qe?(Je=(0,Z.jsx)(`div`,{dir:Be,className:He,children:qe}),t[139]=Be,t[140]=He,t[141]=qe,t[142]=Je):Je=t[142];let Ye;t[143]!==ue||t[144]!==y||t[145]!==Ce||t[146]!==a||t[147]!==C||t[148]!==S.chat.messageCopied||t[149]!==S.chat.userMessageActionsWait||t[150]!==S.chat.userMessageCopy||t[151]!==S.chat.userMessageDelete||t[152]!==S.chat.userMessageEdit||t[153]!==S.chat.userMessageRetry||t[154]!==S.chat.userMessageRetryDisabledHint||t[155]!==c||t[156]!==l||t[157]!==u||t[158]!==Te||t[159]!==Me||t[160]!==le||t[161]!==v?(Ye=C&&!a?(0,Z.jsx)(`div`,{className:`mt-1.5 flex h-8 w-full min-w-0 shrink-0 justify-end`,children:(0,Z.jsxs)(`div`,{className:X(`flex h-full max-w-full items-center justify-end gap-0.5 sm:gap-2`,`pointer-events-none opacity-0 transition-opacity duration-150 ease-out`,`group-hover/msg:pointer-events-auto group-hover/msg:opacity-100`,`group-focus-within/msg:pointer-events-auto group-focus-within/msg:opacity-100`,`[@media(hover:none)_and_(pointer:coarse)]:pointer-events-auto [@media(hover:none)_and_(pointer:coarse)]:opacity-100`),children:[u&&c!=null?(0,Z.jsxs)(`button`,{type:`button`,className:X(C9,Me&&`opacity-40`),onClick:()=>u(c),disabled:Me,title:y?S.chat.userMessageActionsWait:v?S.chat.userMessageRetry:S.chat.userMessageRetryDisabledHint,"aria-label":S.chat.userMessageRetry,children:[(0,Z.jsx)(xy,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`max-w-[4.5rem] truncate sm:max-w-none`,children:S.chat.userMessageRetry})]}):null,(0,Z.jsx)(`button`,{type:`button`,className:X(C9,`size-8 px-0`),onClick:()=>x1(le),disabled:!le,title:S.chat.userMessageEdit,"aria-label":S.chat.userMessageEdit,children:(0,Z.jsx)(H_,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}),(0,Z.jsx)(`button`,{type:`button`,className:X(C9,`size-8 px-0`),onClick:Ce,disabled:!le,title:ue===`user`?S.chat.messageCopied:S.chat.userMessageCopy,"aria-label":ue===`user`?S.chat.messageCopied:S.chat.userMessageCopy,children:ue===`user`?(0,Z.jsx)(Ml,{className:`size-3.5 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(tu,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}),l&&c!=null&&!y?(0,Z.jsx)(`button`,{type:`button`,className:X(C9,`size-8 px-0 hover:text-red-500 dark:hover:text-red-400`),onClick:Te,title:S.chat.userMessageDelete,"aria-label":S.chat.userMessageDelete,children:(0,Z.jsx)(UT,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}):null]})}):null,t[143]=ue,t[144]=y,t[145]=Ce,t[146]=a,t[147]=C,t[148]=S.chat.messageCopied,t[149]=S.chat.userMessageActionsWait,t[150]=S.chat.userMessageCopy,t[151]=S.chat.userMessageDelete,t[152]=S.chat.userMessageEdit,t[153]=S.chat.userMessageRetry,t[154]=S.chat.userMessageRetryDisabledHint,t[155]=c,t[156]=l,t[157]=u,t[158]=Te,t[159]=Me,t[160]=le,t[161]=v,t[162]=Ye):Ye=t[162];let Xe;t[163]!==ue||t[164]!==oe||t[165]!==q||t[166]!==xe||t[167]!==ye||t[168]!==w||t[169]!==S.chat.messageCopied||t[170]!==S.chat.messageCopyMarkdown||t[171]!==S.chat.messageCopyPlainText?(Xe=w&&oe?(0,Z.jsxs)(`div`,{className:`mt-2 flex shrink-0 flex-wrap items-center gap-2 overflow-visible`,children:[(0,Z.jsx)(`button`,{type:`button`,className:S9,onClick:ye,disabled:!q,title:ue===`plain`?S.chat.messageCopied:S.chat.messageCopyPlainText,"aria-label":ue===`plain`?S.chat.messageCopied:S.chat.messageCopyPlainText,children:ue===`plain`?(0,Z.jsx)(Ml,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(tu,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),(0,Z.jsx)(`button`,{type:`button`,className:S9,onClick:xe,title:ue===`markdown`?S.chat.messageCopied:S.chat.messageCopyMarkdown,"aria-label":ue===`markdown`?S.chat.messageCopied:S.chat.messageCopyMarkdown,children:ue===`markdown`?(0,Z.jsx)(Ml,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(Hd,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})})]}):null,t[163]=ue,t[164]=oe,t[165]=q,t[166]=xe,t[167]=ye,t[168]=w,t[169]=S.chat.messageCopied,t[170]=S.chat.messageCopyMarkdown,t[171]=S.chat.messageCopyPlainText,t[172]=Xe):Xe=t[172];let Ze;t[173]!==Ie||t[174]!==Le||t[175]!==Re||t[176]!==ze||t[177]!==Je||t[178]!==Ye||t[179]!==Xe?(Ze=(0,Z.jsxs)(`div`,{className:Ie,children:[Le,Re,ze,Je,Ye,Xe]}),t[173]=Ie,t[174]=Le,t[175]=Re,t[176]=ze,t[177]=Je,t[178]=Ye,t[179]=Xe,t[180]=Ze):Ze=t[180];let Qe;t[181]!==De||t[182]!==fe||t[183]!==C||t[184]!==S.chat.userMessageDeleteCancel||t[185]!==S.chat.userMessageDeleteConfirm||t[186]!==S.chat.userMessageDeleteConfirmTitle||t[187]!==S.chat.userMessageDeleteOk||t[188]!==c||t[189]!==l?(Qe=C&&l&&c!=null?(0,Z.jsx)(b9,{open:fe,title:S.chat.userMessageDeleteConfirmTitle,description:S.chat.userMessageDeleteConfirm,confirmLabel:S.chat.userMessageDeleteOk,cancelLabel:S.chat.userMessageDeleteCancel,destructive:!0,onConfirm:De,onCancel:ke}):null,t[181]=De,t[182]=fe,t[183]=C,t[184]=S.chat.userMessageDeleteCancel,t[185]=S.chat.userMessageDeleteConfirm,t[186]=S.chat.userMessageDeleteConfirmTitle,t[187]=S.chat.userMessageDeleteOk,t[188]=c,t[189]=l,t[190]=Qe):Qe=t[190];let $e=me!==null,et;t[191]===Symbol.for(`react.memo_cache_sentinel`)?(et=()=>he(null),t[191]=et):et=t[191];let tt;t[192]!==r||t[193]!==me||t[194]!==i||t[195]!==$e?(tt=(0,Z.jsx)(Z5,{open:$e,attachment:me,authToken:r,sessionKey:i,onClose:et}),t[192]=r,t[193]=me,t[194]=i,t[195]=$e,t[196]=tt):tt=t[196];let nt;return t[197]!==Pe||t[198]!==Ze||t[199]!==Qe||t[200]!==tt?(nt=(0,Z.jsxs)(`article`,{className:Pe,children:[Ze,Qe,tt]}),t[197]=Pe,t[198]=Ze,t[199]=Qe,t[200]=tt,t[201]=nt):nt=t[201],nt});function FSe(e){return e.language}function ISe(e){return e.type!==`thinking`}function LSe(e){return e.type!==`image`}function RSe(e){return e.type===`image`&&!!e.source?.data}function zSe(e){return e.type===`thinking`&&e.streaming}function BSe(e){return e===`plain`?null:e}function VSe(e){return e===`markdown`?null:e}function HSe(e){return e===`user`?null:e}function USe(e){return e.type!==`thinking`}var WSe=1.5;function w9(e){return e.scrollHeight-e.scrollTop-e.clientHeight}function T9(e){return w9(e)<=4}function GSe(e){return w9(e)<2}function KSe(e,t,n,r){if(!r)return!1;if(T9(e))return!0;let i=e.scrollHeight>n+1,a=e.scrollTop<t-WSe;return i&&!a}function qSe(e,t){return`${e.timestamp??`n`}-${t}`}var JSe=40,YSe=32,XSe=(0,J.memo)(function({messages:e,authToken:t,sessionKey:n,streaming:r,progress:i,reasoningLevel:a,scrollElementRef:o,pinToBottom:s,onPickWelcomePrompt:c,welcomeOverlay:l,onDeleteRound:u,onRetryUserMessageRound:f,deleteRoundDisabled:p,onAbortCurrentTurn:h,onSendUserMessage:g}){let _=m(d(e=>e.language)),v=e.length===0&&!r,y=Yye({count:v?0:e.length,enabled:!v,useFlushSync:!1,useAnimationFrameWithResizeObserver:!0,getScrollElement:()=>o.current,estimateSize:()=>200,gap:JSe,paddingEnd:YSe,overscan:8,getItemKey:t=>qSe(e[t],t),measureElement:J5}),b=(0,J.useRef)(null),x=(0,J.useRef)(s);x.current=s;let S=(0,J.useRef)(null),C=(0,J.useCallback)(()=>{let e=y.options.count;if(e===0)return;let t=o.current;if(!t){y.scrollToIndex(e-1,{align:`end`,behavior:`auto`});return}x.current&&(w9(t)<=1||(t.scrollTop=t.scrollHeight))},[y,o]),w=(0,J.useCallback)(()=>{S.current!=null&&cancelAnimationFrame(S.current),S.current=requestAnimationFrame(()=>{S.current=null,x.current&&C()})},[C]);return(0,J.useLayoutEffect)(()=>{!s||e.length===0||C()},[s,e.length,C]),(0,J.useEffect)(()=>{if(!s||e.length===0||r)return;let t=b.current;if(!t)return;let n=new ResizeObserver(()=>{w()});return n.observe(t),()=>{n.disconnect(),S.current!=null&&(cancelAnimationFrame(S.current),S.current=null)}},[s,e.length,w,r]),v?l?(0,Z.jsx)(`div`,{className:`flex w-full flex-col items-center pb-6 pt-4`,children:l}):c&&_.chat.welcomeSpotlight?(0,Z.jsx)(`div`,{className:`pb-1.5`,children:(0,Z.jsx)(Qye,{chat:_.chat,onPickPrompt:c})}):(0,Z.jsx)(`div`,{className:`flex flex-col gap-10 pb-8`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 py-20 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-4xl`,"aria-hidden":!0,children:`🤖`}),(0,Z.jsx)(`div`,{className:`text-xl font-semibold tracking-tight text-fg`,children:_.chat.welcomeTitle}),(0,Z.jsx)(`div`,{className:`max-w-sm text-sm leading-relaxed text-fg-muted`,children:_.chat.welcomeDescription})]})}):(0,Z.jsx)(`div`,{ref:b,className:`relative w-full min-w-0`,style:{height:y.getTotalSize()},children:y.getVirtualItems().map(o=>{let s=e[o.index];if(!s)return null;let c=o.index===e.length-1,l=!!(r&&c&&s.role===`assistant`);return(0,Z.jsx)(`div`,{"data-index":o.index,ref:y.measureElement,className:`absolute left-0 w-full min-w-0`,style:{top:o.start},children:(0,Z.jsx)(PSe,{message:s,authToken:t,sessionKey:n,isStreaming:l,progress:l?i:null,reasoningLevel:a,messageIndex:o.index,onDeleteRound:u,onRetryUserMessageRound:f,userMessageCanRetry:!!f&&pR(e,o.index),deleteRoundDisabled:p,onAbortCurrentTurn:h,onSendUserMessage:g})},o.key)})})}),ZSe=(0,J.memo)(function(e){let t=(0,Y.c)(7),{visible:n,onClick:r}=e,i=d(QSe),a;t[0]===i?a=t[1]:(a=m(i),t[0]=i,t[1]=a);let o=a;if(!n)return null;let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=X(`fixed bottom-[calc(11rem+env(safe-area-inset-bottom,0px))] right-6 z-20 flex size-11 items-center justify-center rounded-full border border-edge bg-surface-panel text-fg-subtle shadow-float`,`hover:bg-surface-hover hover:text-fg dark:border-edge dark:shadow-none md:right-10`,AX.transition,AX.press,AX.focusRingPanel),t[2]=s):s=t[2];let c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(Nl,{className:`size-6`,"aria-hidden":!0}),t[3]=c):c=t[3];let l;return t[4]!==o.chat.scrollToBottom||t[5]!==r?(l=(0,Z.jsx)(`button`,{type:`button`,className:s,onClick:r,title:o.chat.scrollToBottom,"aria-label":o.chat.scrollToBottom,children:c}),t[4]=o.chat.scrollToBottom,t[5]=r,t[6]=l):l=t[6],l});function QSe(e){return e.language}var E9=.5,D9=.75;function O9(e){return e.webkitDirectionInvertedFromDevice===!0?e.deltaY>0:e.deltaY<0}function $Se({hasToken:e,showSessionLoading:t,sessionKey:n,sending:r,chatMessages:i,hasMore:a,loadingMore:o,loadMoreMessages:s}){let c=(0,J.useRef)(null),[l,u]=(0,J.useState)(!0),d=(0,J.useRef)(!0),f=(0,J.useRef)(!0),p=(0,J.useRef)(!1),m=(0,J.useRef)({first:void 0,len:0,scrollHeight:0}),h=(0,J.useRef)(null),g=(0,J.useRef)(0),_=(0,J.useRef)(0);d.current=l;let v=e&&r&&!p.current&&!t;v&&(d.current=!0,l||u(!0)),p.current=r;let y=(0,J.useCallback)((e=!0,t=!1)=>{let n=c.current;if(!n)return;let r=w9(n);if(!t&&r>5){d.current&&(d.current=!1,u(!1));return}t&&!e&&(n.scrollTop=n.scrollHeight),requestAnimationFrame(()=>{n.scrollTo({top:n.scrollHeight,behavior:e?`smooth`:`auto`});let t=n.scrollHeight;requestAnimationFrame(()=>{c.current&&c.current.scrollHeight>t&&c.current.scrollTo({top:c.current.scrollHeight,behavior:e?`smooth`:`auto`})})})},[]),b=(0,J.useCallback)(()=>{let e=c.current;if(!e)return;let{scrollTop:t,scrollHeight:n}=e;d.current?T9(e)||(d.current=!1,u(!1)):GSe(e)&&(d.current=!0,u(!0)),g.current=t,_.current=n,t<100&&!d.current&&a&&!o&&s()},[a,o,s]),x=(0,J.useCallback)(()=>{d.current&&(d.current=!1,(0,J.startTransition)(()=>u(!1)))},[]),S=(0,J.useCallback)((e,t,n)=>KSe(e,t,n,d.current)?!0:(d.current&&(d.current=!1,u(!1)),!1),[]);return(0,J.useLayoutEffect)(()=>{if(!e)return;if(t){f.current=!0;return}if(f.current!==!0)return;f.current=!1,u(!0);let n=c.current;n&&(n.scrollTop=n.scrollHeight,g.current=n.scrollTop,_.current=n.scrollHeight),requestAnimationFrame(()=>{y(!1,!0),requestAnimationFrame(()=>y(!1,!0))})},[t,e,y]),(0,J.useLayoutEffect)(()=>{if(!e||t)return;m.current={first:void 0,len:0,scrollHeight:0},d.current=!0,u(!0);let n=c.current;n&&(n.scrollTop=n.scrollHeight,g.current=n.scrollTop,_.current=n.scrollHeight),requestAnimationFrame(()=>{y(!1,!0),requestAnimationFrame(()=>y(!1,!0))})},[n,e,t,y]),(0,J.useLayoutEffect)(()=>{v&&y(!1,!0)},[v,y]),(0,J.useLayoutEffect)(()=>{if(!e||t)return;let n=c.current;if(!n)return;let r=e=>{if(Math.abs(e.deltaY)<Math.abs(e.deltaX)||Math.abs(e.deltaY)<.25)return;if(d.current&&O9(e)){x();return}if(!d.current)return;let t=n.scrollTop,r=w9(n),i=()=>{let n=c.current;if(!n||!d.current)return;let i=n.scrollTop,a=w9(n);if(i<t-E9||a>r+D9){x();return}Math.abs(i-t)<E9&&Math.abs(a-r)<D9&&r<=4&&Math.abs(e.deltaY)>=.5&&O9(e)&&x()};requestAnimationFrame(()=>{requestAnimationFrame(i)})},i=0,a=e=>{e.touches.length===1&&(i=e.touches[0].clientY)},o=e=>{if(e.touches.length!==1)return;let t=e.touches[0].clientY,n=t-i;i=t,n>2&&x()};return n.addEventListener(`wheel`,r,{passive:!0}),n.addEventListener(`touchstart`,a,{passive:!0}),n.addEventListener(`touchmove`,o,{passive:!0}),()=>{n.removeEventListener(`wheel`,r),n.removeEventListener(`touchstart`,a),n.removeEventListener(`touchmove`,o)}},[e,t,x]),(0,J.useLayoutEffect)(()=>{if(t)return;let e=c.current;if(!e)return;if(!d.current){g.current=e.scrollTop,_.current=e.scrollHeight;return}let n=e.scrollTop,r=e.scrollHeight,i=g.current,a=_.current;if(n<i-1.5){if(!(r<a-1)){d.current&&(d.current=!1,u(!1)),g.current=n,_.current=r;return}g.current=n,_.current=r}return h.current!=null&&cancelAnimationFrame(h.current),h.current=requestAnimationFrame(()=>{h.current=null;let e=c.current;if(!e)return;let t=g.current,n=_.current;S(e,t,n)&&(y(!1,!0),g.current=e.scrollTop,_.current=e.scrollHeight)}),()=>{h.current!=null&&(cancelAnimationFrame(h.current),h.current=null)}},[i,y,t,S]),(0,J.useLayoutEffect)(()=>{let e=c.current;if(!e||t)return;let n=m.current,r=i[0],a=i.length,o=e.scrollHeight;a>n.len&&n.len>0&&r!==void 0&&r!==n.first&&n.scrollHeight>0&&(e.scrollTop+=o-n.scrollHeight),m.current={first:r,len:a,scrollHeight:o}},[i,t]),{scrollRef:c,atBottom:l,scrollToBottom:y,onScroll:b}}function k9(e){let t=String(e??``).trim();return!t||t===`new`?null:t}function eCe(e){let t=String(e.streamSessionKey??``).trim(),n=k9(e.routeSessionKey);return!t||!n?!1:t===n}function tCe(e){let t=k9(e.routeSessionKey);return t?e.cacheSessionKey===t:!1}function nCe(e){let t=String(e.chatId??``).trim();if(!t)return!1;let n=k9(e.routeSessionKey);return n?n===t:!1}function rCe(e,t){return e?`new`:t??null}function iCe(e){return!e.viewSessionKey||e.sessionKey!==e.viewSessionKey?[]:e.streamingMsg?[...e.messages,e.streamingMsg]:e.messages}function aCe(e){e()}function A9(e){return e===`on`||e===`stream`||e===`off`?e:`stream`}function oCe(e,t){let n=String(e??``).trim();n&&Oz.getState().patchSessionMeta(n,{model:t.model,thinkingLevel:t.thinkingLevel||`medium`,reasoningLevel:A9(t.reasoningLevel??void 0)})}function sCe(e){e.sendingRef.current=!1,e.streamingRef.current=!1}var cCe=`xopc.chat.clarifyPrompt:v1:`;function j9(e){return`${cCe}${encodeURIComponent(e.trim())}`}function M9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function lCe(e){if(!M9(e))return null;let t=e.requestId,n=e.question;if(typeof t!=`string`||!t.trim()||typeof n!=`string`||!n.trim())return null;let r=Array.isArray(e.choices)?e.choices.filter(e=>typeof e==`string`&&e.trim().length>0):void 0,i=typeof e.default==`string`&&e.default.trim()?e.default.trim():void 0;return{requestId:t.trim(),question:n.trim(),choices:r&&r.length>=2?r:void 0,default:i}}function uCe(e){let t=e?.trim();if(!t||typeof localStorage>`u`)return null;try{let e=localStorage.getItem(j9(t));if(!e)return null;let n=JSON.parse(e);return M9(n)?lCe(n.prompt??n):null}catch{return null}}function N9(e,t){let n=e?.trim();if(!(!n||typeof localStorage>`u`))try{localStorage.setItem(j9(n),JSON.stringify({v:1,prompt:t}))}catch{}}function P9(e){let t=e?.trim();if(!(!t||typeof localStorage>`u`))try{localStorage.removeItem(j9(t))}catch{}}var dCe=`xopc.chat.followUpQueue:v2:`;function F9(e){return`${dCe}${encodeURIComponent(e.trim())}`}function I9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function fCe(e){if(!I9(e))return null;let t=e.type;if(typeof t!=`string`||!t.trim())return null;let n={type:t.trim()};return typeof e.mimeType==`string`&&(n.mimeType=e.mimeType),typeof e.name==`string`&&(n.name=e.name),typeof e.size==`number`&&Number.isFinite(e.size)&&(n.size=e.size),typeof e.workspaceRelativePath==`string`&&(n.workspaceRelativePath=e.workspaceRelativePath),typeof e.durationSeconds==`number`&&Number.isFinite(e.durationSeconds)&&(n.durationSeconds=e.durationSeconds),n}function pCe(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!I9(n))continue;let e=n.id,r=n.text;if(typeof e!=`string`||!e.trim()||typeof r!=`string`)continue;let i={id:e.trim(),text:r};if(typeof n.thinkingLevel==`string`&&n.thinkingLevel.trim()&&(i.thinkingLevel=n.thinkingLevel.trim()),Array.isArray(n.attachments)){let e=n.attachments.flatMap(e=>{let t=fCe(e);return t?[t]:[]});e.length&&(i.attachments=e)}if(t.push(i),t.length>=50)break}return t}function mCe(e){return{editingId:e.editingId,pending:e.pending.map(e=>({...e,attachments:e.attachments?.map(e=>{let{data:t,...n}=e;return n})}))}}function hCe(e){let t=e?.trim();if(!t||typeof localStorage>`u`)return null;try{let e=localStorage.getItem(F9(t));if(!e)return null;let n=JSON.parse(e);if(!I9(n))return null;let r=pCe(n.pending),i=n.editingId===null?null:typeof n.editingId==`string`&&n.editingId.trim()?n.editingId.trim():null;return r.length===0&&i==null?null:{pending:r,editingId:i}}catch{return null}}function L9(e,t){let n=e?.trim();if(!n||typeof localStorage>`u`)return;let r=mCe(t);if(r.pending.length===0&&r.editingId==null){R9(n);return}try{localStorage.setItem(F9(n),JSON.stringify({v:2,...r}))}catch{}}function R9(e){let t=e?.trim();if(!(!t||typeof localStorage>`u`))try{localStorage.removeItem(F9(t))}catch{}}function gCe(e){let{sessionKey:t,decodedKey:n,sessionKeyRef:r,activeStreamSessionKeyRef:i,sendingRef:a,streamingRef:o,modelSupportsThinking:s,thinkingLevel:c,shouldApplyStreamUpdate:l,sendMessageRef:u}=e,[d,f]=(0,J.useState)(null),[p,m]=(0,J.useState)(!1),[h,g]=(0,J.useState)(null),v=(0,J.useRef)(null),[y,b]=(0,J.useState)([]),x=(0,J.useRef)([]),[S,C]=(0,J.useState)(null),[w,T]=(0,J.useState)(null),E=(0,J.useRef)(null),[D,O]=(0,J.useState)(null),k=(0,J.useRef)(void 0),A=(0,J.useRef)(null);v.current=d,x.current=y,E.current=w,(0,J.useLayoutEffect)(()=>{let e=k.current;e!=null&&e!==n&&(L9(e,{pending:structuredClone(x.current),editingId:E.current}),v.current!=null&&N9(e,v.current),C(null)),k.current=n;let r=A.current;if(r!=null&&r!==t&&(L9(r,{pending:structuredClone(x.current),editingId:E.current}),v.current!=null&&N9(r,v.current)),A.current=t,!t&&!n){(x.current.length>0||E.current!==null||D!==null)&&(x.current=[],b([]),T(null),O(null)),v.current!=null&&(f(null),g(null));return}let i=t&&n&&t===n?t:null;if(i!=null&&i!==D){let e=hCe(i),t=e?structuredClone(e.pending):[];x.current=t,b(t),T(e?.editingId??null),f(uCe(i)),g(null),O(i)}t!=null&&t!==n&&v.current!=null&&(N9(t,v.current),f(null),g(null))},[t,n,D]),(0,J.useEffect)(()=>{let e=t!=null&&n!=null&&t!==n?t:t??n??null;if(!e)return;let i=window.setTimeout(()=>{r.current===e&&L9(e,{pending:structuredClone(x.current),editingId:E.current})},280);return()=>window.clearTimeout(i)},[t,n,y,w,r]);let j=(0,J.useCallback)(()=>{g(null),f(null)},[]),M=(0,J.useCallback)(e=>{let t=String(e??``).trim();t&&(P9(t),r.current===t&&(g(null),f(null)))},[r]),N=(0,J.useCallback)(()=>{let e=r.current;e&&P9(e),g(null),f(null)},[r]),P=(0,J.useCallback)(()=>{let e=r.current;e&&R9(e),x.current=[],b([]),T(null),O(e)},[r]),F=(0,J.useCallback)(()=>{let e=r.current;e&&(R9(e),P9(e)),x.current=[],b([]),g(null),f(null),T(null),O(e)},[r]),I=(0,J.useCallback)(e=>{M(e)},[M]),L=(0,J.useCallback)(e=>t=>{N9(e,t),l(e)&&(a.current=!1,o.current=!1,Oz.getState().setSessionFlags(e,{sending:!1,streaming:!1}),Oz.getState().setSessionProgress(e,null),g(null),f(t))},[l,a,o]),R=(0,J.useCallback)(async e=>{let t=r.current;if(e!=null&&e!==t)return;let n=t;if(!n)return;let s=x.current;for(;s.length>0&&!s[0].text.trim()&&!s[0].attachments?.length;)s=s.slice(1);if(s.length===0){x.current=[],b([]);return}s.length!==x.current.length&&(x.current=s,b(s));let[c,...l]=s,d=c.text?.trim()??``,f=c.attachments;!d&&!f?.length||i.current===n&&(a.current||o.current)||(E.current===c.id&&T(null),x.current=l,b(l),await u.current(c.text,c.attachments,c.thinkingLevel))},[u,r,i,a,o]),z=(0,J.useEffectEvent)(e=>{R(e)});return(0,J.useEffect)(()=>{if(!t||t!==n||d||y.length===0||a.current||o.current)return;let e=y[0];if(!e||!e.text.trim()&&!e.attachments?.length)return;let i=window.setTimeout(()=>{r.current===t&&(a.current||o.current||v.current||z(t))},72);return()=>window.clearTimeout(i)},[t,n,d,y,a,o,r]),{clarifyPrompt:d,clarifySubmitting:p,clarifySubmitError:h,clarifyPromptRef:v,pendingFollowUps:y,pendingFollowUpsRef:x,steeringFollowUpId:S,editingFollowUpId:w,addPendingFollowUp:(0,J.useCallback)((e,t)=>{let n=e.trim();if(!n&&!t?.length||x.current.length>=10)return;let r=s?c:`off`,i={id:crypto.randomUUID(),text:n||e,attachments:t?.length?t:void 0,thinkingLevel:r};b(e=>{let t=[...e,i];return x.current=t,t})},[s,c]),beginEditFollowUp:(0,J.useCallback)(e=>{T(e)},[]),cancelEditFollowUp:(0,J.useCallback)(()=>{T(null)},[]),commitEditFollowUp:(0,J.useCallback)((e,t,n,r)=>{let i=t.trim(),a=x.current,o=a.findIndex(t=>t.id===e);if(o<0){T(null);return}if(!i&&!n?.length){let t=a.filter(t=>t.id!==e);x.current=t,b(t),T(null);return}let l=[...a],u=s?r??c:`off`;l[o]={...l[o],text:i||t,attachments:n?.length?n:void 0,thinkingLevel:u},x.current=l,b(l),T(null)},[s,c]),removePendingFollowUp:(0,J.useCallback)(e=>{E.current===e&&T(null),b(t=>{let n=t.filter(t=>t.id!==e);return x.current=n,n})},[]),movePendingFollowUp:(0,J.useCallback)((e,t)=>{b(n=>{let r=n.findIndex(t=>t.id===e);if(r<0)return n;let i=t===`up`?r-1:r+1;if(i<0||i>=n.length)return n;let a=[...n];return[a[r],a[i]]=[a[i],a[r]],x.current=a,a})},[]),reorderPendingFollowUp:(0,J.useCallback)((e,t)=>{b(n=>{if(e<0||e>=n.length||t<0||t>=n.length)return n;let r=[...n],[i]=r.splice(e,1);return r.splice(t,0,i),x.current=r,r})},[]),steerPendingFollowUp:(0,J.useCallback)(async e=>{let t=r.current;if(!t)return;let n=x.current.find(t=>t.id===e);if(!(!n?.text.trim()||n.attachments?.length)){C(e);try{(await Ee(_(`/api/agent/steer`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({chatId:t,message:n.text.trim()})})).ok&&(b(t=>{let n=t.filter(t=>t.id!==e);return x.current=n,n}),E.current===e&&T(null))}catch{}finally{C(null)}}},[r]),submitClarifyAnswer:(0,J.useCallback)(async e=>{let t=v.current;if(t){m(!0),g(null);try{let n=await Ee(_(`/api/clarify/${encodeURIComponent(t.requestId)}`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({answer:e})});if(!n.ok){g((await n.json().catch(()=>({}))).error?.message??n.statusText??`Clarify failed`);return}let i=r.current;i&&P9(i),f(null),g(null)}finally{m(!1)}}},[r]),cancelClarifyAnswer:(0,J.useCallback)(async()=>{let e=v.current;if(e){m(!0),g(null);try{let t=await Ee(_(`/api/clarify/${encodeURIComponent(e.requestId)}`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({skip:!0})});if(!t.ok){g((await t.json().catch(()=>({}))).error?.message??t.statusText??`Clarify failed`);return}let n=r.current;n&&P9(n),f(null),g(null)}finally{m(!1)}}},[r]),clearVisibleClarify:j,dismissClarify:N,dismissClarifyForSession:M,clearPendingFollowUps:P,dismissClarifyAndClearPending:F,onClarifyToolEnd:I,makeOnClarifyRequest:L,flushSteeringQueue:R}}function _Ce(e){let{navigate:t,sessionKeyRef:n,sessionKey:r,isNewRoute:i,locationState:a}=e,o=Se(e=>e.token),{data:s,mutate:c}=v(o?[`gateway-chat-agents`,o]:null,gL,{revalidateOnFocus:!1});(0,J.useEffect)(()=>{let e=()=>void c();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[c]);let[l,u]=(0,J.useState)(()=>az()),d=(0,J.useRef)(s??null),f=(0,J.useRef)(az());(0,J.useEffect)(()=>{d.current=s??null},[s]),(0,J.useEffect)(()=>{f.current=l},[l]),(0,J.useEffect)(()=>{if(!s)return;let e=new Set(s.items.map(e=>e.id));u(t=>t==null||t===``||!e.has(t)?s.defaultId:t)},[s]);let p=(0,J.useCallback)(()=>{let e=n.current,t=e?aH(e):null;if(t)return t;let r=d.current,i=(f.current??``).trim().toLowerCase();if(!r)return i||void 0;let a=new Set(r.items.map(e=>e.id));return i&&a.has(i)?i:r.defaultId},[n]),m=(0,J.useCallback)(e=>{let r=e.trim().toLowerCase();u(r);try{globalThis.localStorage?.setItem(iz,r)}catch{}let i=n.current;(i?aH(i):null)!==r&&t(`/chat/new`,{replace:!1})},[t,n]);return(0,J.useEffect)(()=>{let e=e=>{let t=e.detail?.agentId;typeof t!=`string`||!t.trim()||m(t)};return window.addEventListener(`xopc-set-chat-agent`,e),()=>window.removeEventListener(`xopc-set-chat-agent`,e)},[m]),(0,J.useLayoutEffect)(()=>{if(!r)return;let e=aH(r);if(!(!e||f.current===e)){f.current=e,u(e);try{globalThis.localStorage?.setItem(iz,e)}catch{}}},[r]),(0,J.useLayoutEffect)(()=>{if(!i)return;let e=a,t=typeof e?.agentId==`string`?e.agentId.trim().toLowerCase():``;if(t){f.current=t,u(t);try{globalThis.localStorage?.setItem(iz,t)}catch{}}},[i,a]),{token:o,chatAgentsData:s,resolveAgentIdForPost:p,onChatAgentChange:m,displayAgentId:(0,J.useMemo)(()=>r&&aH(r)||l||s?.defaultId||`main`,[r,l,s]),showChatAgentSelector:(s?.items.length??0)>1}}function vCe(e){let t=e.startsWith(`?`)?e.slice(1):e;if(!t)return``;let n=new URLSearchParams(t),r=new URLSearchParams,i=n.get(`skill`),a=n.get(`slash`);i&&r.set(`skill`,i),a&&r.set(`slash`,a);let o=r.toString();return o?`?${o}`:``}var z9=null;function B9(e){z9=String(e??``).trim()||null}function yCe(e){let t=String(e??``).trim();return!t||z9!==t?!1:(z9=null,!0)}function bCe(e){let t=(0,Y.c)(15),{token:n,isNewRoute:r,decodedKey:i,locationSearch:a,sessionMgrRef:o,resolveAgentIdForPost:s,navigateToSession:c,loadSessionById:l,tryResumeAgentRun:u,restoreLiveCacheIfNeeded:d,adoptEmptySession:f,applyAgentConfig:p,patchInitUi:m}=e,h=(0,J.useRef)(0),g,_;t[0]!==f||t[1]!==p||t[2]!==i||t[3]!==r||t[4]!==l||t[5]!==a||t[6]!==c||t[7]!==m||t[8]!==s||t[9]!==d||t[10]!==o||t[11]!==n||t[12]!==u?(g=()=>{if(!n){m({loading:!1});return}let e=h.current+=1,t=!1,g=()=>!t&&e===h.current,_=e=>{g()&&o.current.loadSessionAgentConfig(e).then(t=>{g()&&p(e,t)}).catch(SCe)},v=()=>{if(!g())return Promise.resolve();let e=s();return o.current.createSession(e?{agentId:e}:void 0).then(e=>{g()&&(B9(e.key),f(e.key,e.name??null),c(e.key,!0,vCe(a)),_(e.key))})},y=(e,t)=>g()?(d(e),u(e,Az(e)?.messages??t??jz(e))):Promise.resolve();return m({loading:r||i===void 0,error:null}),(r?v():i?(e=>g()?yCe(e)?(_(e),y(e,jz(e))):l(e,0).then(t=>{if(g())return y(e,t??jz(e))}):Promise.resolve())(i):g()?o.current.loadSessions().then(e=>{if(!g())return;let t=e.filter(xCe)[0]??e[0];if(t)return g()?l(t.key,0).then(e=>{if(!g())return;d(t.key);let n=Az(t.key)?.messages??e??jz(t.key);return o.current.parseSessionFromHash()||c(t.key,!0),u(t.key,n)}):void 0;if(!g())return;let n=s();return o.current.createSession(n?{agentId:n}:void 0).then(e=>{g()&&(B9(e.key),f(e.key,e.name??null),c(e.key),_(e.key))})}):Promise.resolve()).then(()=>{g()&&m({loading:!1})}).catch(e=>{t?g()&&m({loading:!1}):m({error:e instanceof Error?e.message:`Chat init failed`,loading:!1})}),()=>{t=!0}},_=[n,r,i,a,o,s,c,l,u,d,f,p,m],t[0]=f,t[1]=p,t[2]=i,t[3]=r,t[4]=l,t[5]=a,t[6]=c,t[7]=m,t[8]=s,t[9]=d,t[10]=o,t[11]=n,t[12]=u,t[13]=g,t[14]=_):(g=t[13],_=t[14]),(0,J.useEffect)(g,_)}function xCe(e){return(e.messageCount??0)>0}function SCe(){}async function CCe(e){let t=e.trim();if(!t)return!1;try{return!!(await c8()).find(e=>e.id===t)?.reasoning}catch{return!1}}function wCe(e){let{sessionMgrRef:t,routeSessionKeyRef:n,sendingRef:r,streamingRef:i,activeStreamSessionKeyRef:a,loadingSessionRef:o,messagesLenRef:s,thinkingSupportGenRef:c,navigateToSession:l,resolveAgentIdForPost:u,dismissClarifyOnSessionLoad:d,detachForNewConversation:f,sessionKey:p,hasMore:m}=e,h=()=>Oz.getState(),g=(0,J.useRef)(Promise.resolve(void 0)),_=(0,J.useRef)(null),v=(0,J.useRef)(0),y=(0,J.useCallback)(e=>{let t=h().focusedSessionKey;if(!e.trim())return++c.current===c.current&&t&&h().patchSessionMeta(t,{modelSupportsThinking:!1}),Promise.resolve();let n=++c.current;return CCe(e).then(e=>{if(n!==c.current)return;let t=h().focusedSessionKey;t&&h().patchSessionMeta(t,{modelSupportsThinking:e})})},[c]),b=(0,J.useCallback)(()=>{let e=h().focusedSessionKey;if(!e||(h().sessions[e]?.name)?.trim())return;let n=++v.current,r=[700,900,900,1e3,1e3],i=a=>{a>=5||n===v.current&&h().focusedSessionKey===e&&(h().sessions[e]?.name?.trim()||window.setTimeout(()=>{n===v.current&&h().focusedSessionKey===e&&(h().sessions[e]?.name?.trim()||t.current.fetchSessionName(e).then(t=>{if(n===v.current){if(t){h().patchSessionMeta(e,{name:t});return}i(a+1)}}).catch(()=>{i(a+1)}))},r[a]??900))};i(0)},[t]),x=(0,J.useCallback)(e=>nCe({chatId:e,routeSessionKey:n.current}),[n]),S=(0,J.useCallback)((e,t)=>{let n=h().getSessionSnapshot(e);n&&(n.streaming||n.sending||n.streamingMsg)?(h().mergeCommittedFromServer(e,t.messages,t.hasMore),t.name!==void 0&&h().patchSessionMeta(e,{name:t.name||null})):h().setCommittedSnapshot(e,{messages:t.messages,hasMore:t.hasMore,name:t.name}),x(e)&&(_.current=t.nextBeforeCursor??null)},[x]),C=(0,J.useCallback)(async(e,r=0,i)=>{let a=async(e,r,i)=>{let s=r===0&&!i;s&&!wR(e)&&d(),o.current=!0;try{let{messages:n,hasMore:a,name:o,nextBeforeCursor:c}=await t.current.loadSession(e,r,i);if(s){if(h().setCommittedSnapshot(e,{messages:n,hasMore:a,name:o??null}),!x(e))return n;_.current=c??null,h().setShellError(null);try{let r=await t.current.loadSessionAgentConfig(e);if(!x(e))return n;h().patchSessionMeta(e,{model:r.model,thinkingLevel:r.thinkingLevel||`medium`,reasoningLevel:A9(r.reasoningLevel)}),y(r.model)}catch{}return n}if(_.current=c??null,!x(e))return;h().prependHistoryMessages(e,n,a);return}catch{if(r===0&&!i){_.current=null,h().setShellError(`Failed to load session`);let r=k9(n.current);if(r&&r===e)return;let i=await t.current.loadSessions().catch(()=>[]),o=i.filter(e=>(e.messageCount??0)>0)[0]??i[0];if(o)return l(o.key,!0),await a(o.key,0,null);try{let e=u(),n=await t.current.createSession(e?{agentId:e}:void 0);l(n.key,!0),_.current=null,B9(n.key),h().setCommittedSnapshot(n.key,{messages:[],hasMore:!1});try{let e=await t.current.loadSessionAgentConfig(n.key);h().patchSessionMeta(n.key,{model:e.model,thinkingLevel:e.thinkingLevel||`medium`,reasoningLevel:A9(e.reasoningLevel)}),y(e.model)}catch{}}catch{h().setShellError(`Could not open a session`)}}return}finally{o.current=!1}},s=g.current,c,f=new Promise(e=>{c=e});g.current=s.then(()=>f),await s;try{return await a(e,r,i)}finally{c()}},[n,x,r,i,a,o,d,l,y,u,t]);return{refreshModelThinkingSupport:y,pollSessionNameAfterTurn:b,applyLoadedSessionSnapshot:S,loadSessionById:C,loadMoreMessages:(0,J.useCallback)(async()=>{let e=h().focusedSessionKey;if(!(!e||h().loadingMore||!m)){h().setLoadingMore(!0);try{await C(e,s.current,_.current)}finally{h().setLoadingMore(!1)}}},[m,C,s]),onSessionModelChange:(0,J.useCallback)(async e=>{if(p)try{h().setShellError(null),await t.current.patchSessionAgentConfig(p,{model:e}),h().patchSessionMeta(p,{model:e}),y(e)}catch(e){h().setShellError(e instanceof Error?e.message:`Failed to switch model`)}},[p,t,y]),onSessionThinkingLevelChange:(0,J.useCallback)(async e=>{if(p)try{h().setShellError(null),await t.current.patchSessionAgentConfig(p,{thinkingLevel:e}),h().patchSessionMeta(p,{thinkingLevel:e})}catch(e){h().setShellError(e instanceof Error?e.message:`Failed to update thinking level`)}},[p,t]),createNewSession:(0,J.useCallback)(async()=>{d(),f();try{let e=u(),n=await t.current.createSession(e?{agentId:e}:void 0);_.current=null,B9(n.key),h().setCommittedSnapshot(n.key,{messages:[],hasMore:!1,name:n.name??null}),l(n.key);try{let e=await t.current.loadSessionAgentConfig(n.key);h().patchSessionMeta(n.key,{model:e.model,thinkingLevel:e.thinkingLevel||`medium`,reasoningLevel:A9(e.reasoningLevel)}),y(e.model)}catch{}}catch(e){console.error(`[chat] createNewSession failed:`,e)}},[d,f,l,y,u,t])}}var V9={current:null};function TCe(){let e=Yr(),{sessionKey:t}=ni(),n=e.pathname.endsWith(`/new`),r=t?decodeURIComponent(t):void 0,i=rCe(n,r),a=k9(i),o=n?null:r??null,s=(0,J.useRef)(i);return s.current=i,V9.current=o,(0,J.useLayoutEffect)(()=>{Oz.getState().focusedSessionKey!==o&&Oz.getState().setFocusedSessionKey(o)},[o]),{isNewRoute:n,decodedKey:r,routedSessionKey:i,viewSessionKey:a,routedFocusedSessionKey:o,routeSessionKeyRef:s,locationSearch:e.search,locationState:e.state}}var H9={get current(){return V9.current},set current(e){V9.current=e,Oz.getState().setFocusedSessionKey(e)}};function U9(e){let{chatId:t,shouldApplyStreamUpdate:n,beforeAssistantDelta:r,setStreamingOnStreamStart:i,clearResumeRunIdOnBackgroundTerminal:a,clearResumeRunIdOnVisibleError:o,setError:s,sessionMgrRef:c,applyLoadedSessionSnapshot:l,finalizeMessage:u,fq:d}=e,f=()=>Oz.getState(),p=()=>{c.current.loadSession(t,0).then(e=>l(t,e)).catch(()=>{})},m=()=>{f().clearStreamingState(t),oz.clearActiveStreamSessionKey(t),a&&(oz.activeResumeRunId=null),f().setSessionFlags(t,{sending:!1,streaming:!1}),f().setSessionProgress(t,null),d.dismissClarifyForSession(t),p()};return{onUserMessage:e=>{n(t)&&f().appendUserMessageIfMissing(t,e)},onStreamStart:()=>{r(),f().mutateSessionStreaming(t,()=>{}),f().setSessionFlags(t,{streaming:!0})},onToken:e=>{r(),f().mutateSessionStreaming(t,t=>{yz(t.content,e)}),n(t)&&f().setSessionFlags(t,{streaming:!0})},onThinking:(e,n)=>{r(),f().mutateSessionStreaming(t,t=>{!n&&e===``?mz(t.content):hz(t.content,e,n)})},onThinkingEnd:()=>{r(),f().mutateSessionStreaming(t,e=>{gz(e.content)})},onToolStart:(e,n,i)=>{r(),f().mutateSessionStreaming(t,t=>{bz(t.content,e,n,i)}),f().setSessionFlags(t,{streaming:!0})},onToolEnd:(e,n,i)=>{e===`clarify`&&d.onClarifyToolEnd(t),r(),f().mutateSessionStreaming(t,t=>{xz(t.content,e,n,i)})},onToolUpdate:(e,n,i)=>{r(),f().mutateSessionStreaming(t,t=>{Sz(t.content,e,n,i)})},onProgress:e=>{f().setSessionProgress(t,e)},onTtsAudio:e=>{r(),f().mutateSessionStreaming(t,t=>{let n=e.workspaceRelativePath?.replace(/\\/g,`/`).trim(),r=t.attachments??[];if(n&&r.some(e=>e.workspaceRelativePath?.replace(/\\/g,`/`).trim()===n))return;let i={name:e.name,mimeType:e.mimeType,type:`voice`,workspaceRelativePath:e.workspaceRelativePath,size:0};t.attachments=[...r,i]})},onCompaction:e=>{if(n(t))if(e.status===`started`)f().setSessionProgress(t,{stage:`compaction`,message:`Compacting context…`,timestamp:Date.now()});else if(e.status===`completed`){let n=e.tokensBefore&&e.tokensAfter?` (${Math.round((e.tokensBefore-e.tokensAfter)/1e3)}k tokens freed)`:``;f().setSessionProgress(t,{stage:`compaction`,message:`Context compacted${n}`,timestamp:Date.now()})}else f().setSessionProgress(t,null)},onClarifyRequest:d.makeOnClarifyRequest(t),onResult:()=>{if(!n(t)){m();return}if(oz.userAborted){oz.userAborted=!1;return}u()},onError:e=>{if(!n(t)){m();return}f().clearStreamingState(t),o&&(oz.activeResumeRunId=null),f().setSessionFlags(t,{sending:!1,streaming:!1}),f().setSessionProgress(t,null),s(e),d.dismissClarifyForSession(t)}}}function ECe(e){return Az(e)?.streamingMsg??null}function DCe(e){let{sessionKey:t,thinkingLevel:n,modelSupportsThinking:r,sessionKeyRef:i,sendingRef:a,streamingRef:o,sessionMgrRef:s,sendMessageRef:c,shouldApplyStreamUpdate:l,fq:u,applyLoadedSessionSnapshot:d,loadSessionById:f,createNewSession:p,pollSessionNameAfterTurn:m}=e,h=(0,J.useRef)(u.flushSteeringQueue);h.current=u.flushSteeringQueue;let g=()=>Oz.getState(),_=e=>g().setShellError(e),v=()=>g().setShellError(null),y=(0,J.useCallback)(e=>{let t=oz.activeStreamSessionKey??i.current;if(t&&!l(t))return;let n=t?ECe(t):null,r=null;if(n){let e=uz(n,Date.now());gz(e.content),_z(e.content),r=dz(e)}if(r&&lz(r)&&t){let e=Az(t)?.messages??jz(t);g().finalizeStreamingTurn(t,eR([...e,r]))}else t&&g().clearStreamingState(t);if(a.current=!1,o.current=!1,oz.resetRunTracking(),u.dismissClarify(),m(),!e?.skipSteeringQueueFlush){let e=t??i.current;e&&window.setTimeout(()=>{h.current(e)},72)}let s=i.current;s&&window.setTimeout(()=>{i.current===s&&(a.current||o.current||u.pendingFollowUpsRef.current.length>0||f(s,0))},400)},[a,o,i,u.dismissClarify,u.pendingFollowUpsRef,m,f,l]),b=(0,J.useCallback)(async(e,t)=>{if(!l(e)||oz.isStreamingFor(e)||oz.isSending)return;let n=await OR(e);if(!n||oz.activeResumeRunId===n)return;let r=t??jz(e),i=Az(e)?.hasMore??!1;try{let t=await s.current.loadSession(e,0);g().mergeCommittedFromServer(e,t.messages,t.hasMore),r=t.messages,i=t.hasMore}catch{}oz.userAborted=!1,oz.activeResumeRunId=n,oz.activeStreamSessionKey=e,a.current=!0,o.current=!0,g().seedSessionIfEmpty(e,r,!0,!0,i),g().setSessionFlags(e,{sending:!0,streaming:!0}),g().setSessionProgress(e,null);let c=!1,f=()=>{if(c||!l(e))return;c=!0;let t=jz(e);if(t.length===0)return;let n=t[t.length-1];if(n?.role!==`assistant`)return;let r=dz(n),i=t.slice(0,-1);g().applyHydratedTail(e,i,r)};try{let t=U9({chatId:e,shouldApplyStreamUpdate:l,beforeAssistantDelta:f,setStreamingOnStreamStart:!1,clearResumeRunIdOnBackgroundTerminal:!0,clearResumeRunIdOnVisibleError:!0,setError:_,sessionMgrRef:s,applyLoadedSessionSnapshot:d,finalizeMessage:y,fq:u});await oz.sender.resume(n,e,t)}catch(t){if(t.name!==`AbortError`&&console.error(`[chat] resume failed:`,t),g().clearStreamingState(e),oz.activeResumeRunId=null,!l(e)){oz.clearActiveStreamSessionKey(e);return}a.current=!1,o.current=!1,oz.clearActiveStreamSessionKey(e)}},[a,o,l,s,d,y]),x=(0,J.useCallback)(async(e,t,s)=>{if(!e.trim()&&!t?.length||!a.current&&!o.current&&!oz.isSending)return;if(e.trim()===`/new`&&!t?.length){await p();return}if(!i.current)return;u.dismissClarifyAndClearPending();let l=r?s??n:`off`;oz.userAborted=!0,oz.resetRunTracking(),oz.abort(),a.current=!1,o.current=!1,y({skipSteeringQueueFlush:!0}),queueMicrotask(()=>{c.current(e,t,l)})},[a,o,i,u.dismissClarifyAndClearPending,r,n,y,c,p]);return{finalizeMessage:y,tryResumeAgentRun:b,sendMessage:(0,J.useCallback)(async(e,i,c)=>{if(!t||!l(t)||!e.trim()&&!i?.length||oz.activeStreamSessionKey===t&&(a.current||o.current))return;if(e.trim()===`/new`&&!i?.length){await p();return}let f=r?c??n:`off`,m=t;oz.userAborted=!1,oz.activeStreamSessionKey=m,a.current=!0,o.current=!1,v(),u.dismissClarify();let h=[...jz(m),{role:`user`,content:e?[{type:`text`,text:e}]:[],attachments:i,timestamp:Date.now()}],b=Az(m);g().initSessionSnapshot(m,{...b??{...rz(),hasMore:!1,streamingMsg:null,progress:null,sending:!1,streaming:!1},messages:h,hasMore:b?.hasMore??!1,streamingMsg:null,progress:null,sending:!0,streaming:!1});try{let t=U9({chatId:m,shouldApplyStreamUpdate:l,beforeAssistantDelta:()=>{},setStreamingOnStreamStart:!0,clearResumeRunIdOnBackgroundTerminal:!1,clearResumeRunIdOnVisibleError:!1,setError:_,sessionMgrRef:s,applyLoadedSessionSnapshot:d,finalizeMessage:y,fq:u});await oz.sender.send(e,m,i,f,t)}catch(e){e.name!==`AbortError`&&(g().clearStreamingState(m),_(e instanceof Error?e.message:`Send failed`))}finally{a.current=!1,o.current=!1,g().setSessionFlags(m,{sending:!1}),oz.clearActiveStreamSessionKey(m)}},[t,n,r,a,o,l,s,d,y,u.dismissClarify,p]),interruptAndSend:x,abort:(0,J.useCallback)(()=>{oz.userAborted=!0,oz.resetRunTracking(),u.dismissClarifyAndClearPending(),oz.abort(),a.current=!1,o.current=!1,y({skipSteeringQueueFlush:!0});let e=i.current;e&&window.setTimeout(()=>{f(e,0)},300)},[u.dismissClarifyAndClearPending,a,o,y,i,f]),deleteMessageRound:(0,J.useCallback)(e=>{let t=i.current;if(!t||a.current||o.current)return;let n=jz(t),r=n[e];if(!r||!hR(r.role))return;let c=gR(n,e);if(c===null)return;let l=_R(n,e),u=[...n];u.splice(e,l),g().updateSessionMessages(t,()=>u),s.current.deleteMessages(t,{userRoundIndex:c}).catch(()=>{f(t,0)})},[i,a,o,s,f]),retryUserMessageRound:(0,J.useCallback)(e=>{let t=i.current;if(!t||a.current||o.current)return;let n=jz(t),r=n[e];if(!r||!hR(r.role))return;for(let t=e+1;t<n.length;t++){let e=n[t];if(e&&hR(e.role))return}let l=fR(r.content),u=mR(r.attachments);if(!l.trim()&&!u?.length)return;let d=gR(n,e);if(d===null)return;let p=_R(n,e),m=[...n];m.splice(e,p),g().updateSessionMessages(t,()=>m),(async()=>{try{await s.current.deleteMessages(t,{userRoundIndex:d}),await c.current(l,u)}catch{f(t,0)}})()},[i,a,o,s,f,c])}}function OCe(e){let t=(0,Y.c)(12),{sessionKey:n,sessionKeyRef:r,sessionMgrRef:i,loadSessionById:a,applyAgentConfig:o}=e,s,c;t[0]===n?(s=t[1],c=t[2]):(s=()=>{let e=e=>{let t=e.detail;!t?.key||t.name===void 0||t.key===n&&Oz.getState().patchSessionMeta(t.key,{name:t.name||null})};return window.addEventListener(`session-updated`,e),()=>window.removeEventListener(`session-updated`,e)},c=[n],t[0]=n,t[1]=s,t[2]=c),(0,J.useEffect)(s,c);let l,u;t[3]!==a||t[4]!==n?(l=()=>{let e=e=>{let t=e.detail;!t?.key||t.key!==n||a(n,0)};return window.addEventListener(`session-transcript-updated`,e),()=>window.removeEventListener(`session-transcript-updated`,e)},u=[n,a],t[3]=a,t[4]=n,t[5]=l,t[6]=u):(l=t[5],u=t[6]),(0,J.useEffect)(l,u);let d,f;t[7]!==o||t[8]!==r||t[9]!==i?(d=()=>{let e=()=>{let e=r.current;e&&i.current.loadSessionAgentConfig(e).then(t=>{o(e,t)}).catch(kCe)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},f=[r,i,o],t[7]=o,t[8]=r,t[9]=i,t[10]=d,t[11]=f):(d=t[10],f=t[11]),(0,J.useEffect)(d,f)}function kCe(){}function ACe(){let e=Qr(),{isNewRoute:t,decodedKey:n,viewSessionKey:r,routedFocusedSessionKey:i,routeSessionKeyRef:a,locationSearch:o,locationState:s}=TCe(),c=(0,J.useRef)(new $R),l=(0,J.useRef)(!1),u=(0,J.useRef)(!1),d=(0,J.useRef)(!1),f=(0,J.useRef)(0),p=(0,J.useRef)(!1),m=(0,J.useRef)(async()=>{}),h=(0,J.useRef)(0),g=i,_=Oz(e=>e.initLoading),v=Oz(e=>e.loadingMore),y=Oz(e=>e.shellError),b=r,x=Oz(e=>b?e.sessions[b]:void 0),S=b?kz(x):!1,C=S?x?.streaming??!1:!1,w=S?x?.sending??!1:!1,T=S?x?.progress??null:null,E=x?.hasMore??!1,D=x?.name??null,O=x?.model??``,k=x?.thinkingLevel??`medium`,A=x?.reasoningLevel??`stream`,j=x?.modelSupportsThinking??!1;(0,J.useEffect)(()=>{h.current=x?.messages.length??0},[x?.messages.length]),(0,J.useEffect)(()=>{u.current=w,d.current=C},[w,C]);let{token:M,chatAgentsData:N,resolveAgentIdForPost:P,onChatAgentChange:F,displayAgentId:I,showChatAgentSelector:L}=_Ce({navigate:e,sessionKeyRef:H9,sessionKey:g,isNewRoute:t,locationState:s}),R=n!==void 0&&g!==n,z=(0,J.useMemo)(()=>_&&(g==null||n===void 0),[_,g,n]),B=(0,J.useCallback)((t,n=!1,r)=>{let i=r??``;e({pathname:`/chat/${encodeURIComponent(t)}`,search:i},{replace:n})},[e]),V=(0,J.useCallback)(e=>eCe({streamSessionKey:e,routeSessionKey:a.current}),[a]),H=(0,J.useCallback)(()=>{sCe({sendingRef:u,streamingRef:d})},[]),U=gCe({sessionKey:g,decodedKey:n,sessionKeyRef:H9,activeStreamSessionKeyRef:sz,sendingRef:u,streamingRef:d,modelSupportsThinking:j,thinkingLevel:k,shouldApplyStreamUpdate:V,sendMessageRef:m}),W=(0,J.useCallback)(()=>{U.clearVisibleClarify(),oz.activeResumeRunId=null,oz.userAborted=!1,aCe(H)},[U.clearVisibleClarify,H]),{refreshModelThinkingSupport:G,pollSessionNameAfterTurn:ee,applyLoadedSessionSnapshot:K,loadSessionById:te,loadMoreMessages:ne,onSessionModelChange:re,onSessionThinkingLevelChange:ie,createNewSession:ae}=wCe({sessionMgrRef:c,routeSessionKeyRef:a,sendingRef:u,streamingRef:d,activeStreamSessionKeyRef:sz,loadingSessionRef:l,messagesLenRef:h,thinkingSupportGenRef:f,navigateToSession:B,resolveAgentIdForPost:P,dismissClarifyOnSessionLoad:U.clearVisibleClarify,detachForNewConversation:W,sessionKey:g,hasMore:E}),oe=(0,J.useCallback)(e=>{if(!tCe({cacheSessionKey:e,routeSessionKey:a.current}))return!1;let t=Az(e);return!t||!kz(t)&&!wR(e)&&!oz.isStreamingFor(e)?!1:(oz.activeStreamSessionKey=e,u.current=t.sending,d.current=t.streaming,!0)},[a]),{tryResumeAgentRun:se,sendMessage:q,interruptAndSend:ce,abort:le,deleteMessageRound:ue,retryUserMessageRound:de}=DCe({sessionKey:g,thinkingLevel:k,modelSupportsThinking:j,sessionKeyRef:H9,sendingRef:u,streamingRef:d,sessionMgrRef:c,sendMessageRef:m,shouldApplyStreamUpdate:V,fq:U,applyLoadedSessionSnapshot:K,loadSessionById:te,createNewSession:ae,pollSessionNameAfterTurn:ee});(0,J.useEffect)(()=>{t&&W()},[t,W]);let fe=(0,J.useMemo)(()=>iCe({viewSessionKey:r,sessionKey:b,messages:x?.messages??[],streamingMsg:S?x?.streamingMsg??null:null}),[r,b,x?.messages,x?.streamingMsg,S]),pe=(0,J.useCallback)((e,t)=>{Oz.getState().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:t}),H()},[H]),me=(0,J.useCallback)((e,t)=>{oCe(e,t),G(t.model)},[G]),he=(0,J.useCallback)(e=>{let t=Oz.getState();e.loading!==void 0&&t.setInitLoading(e.loading),e.error!==void 0&&t.setShellError(e.error)},[]);return OCe({sessionKey:g,sessionKeyRef:H9,sendingRef:u,streamingRef:d,sessionMgrRef:c,loadSessionById:te,applyAgentConfig:me}),bCe({token:M,isNewRoute:t,decodedKey:n,locationSearch:o,sessionMgrRef:c,resolveAgentIdForPost:P,navigateToSession:B,loadSessionById:te,tryResumeAgentRun:se,restoreLiveCacheIfNeeded:oe,adoptEmptySession:pe,applyAgentConfig:me,patchInitUi:he}),(0,J.useEffect)(()=>{let e=e=>{let t=e.detail;if(!t?.sessionKey)return;let n=t.event;if(!n||typeof n.type!=`string`)return;let r=t.sessionKey;if(n.type===`user_message`||n.type===`user_transcript`){let e=vR(n);e&&V(r)&&Oz.getState().appendUserMessageIfMissing(r,e);return}n.type!==`status`||typeof n.runId!=`string`||!n.runId.trim()||(TR(r,n.runId),V(r)&&(oz.isStreamingFor(r)||queueMicrotask(()=>{V(r)&&(oz.isStreamingFor(r)||se(r,jz(r)))})))};return window.addEventListener(`agent-stream`,e),()=>window.removeEventListener(`agent-stream`,e)},[se,V]),(0,J.useEffect)(()=>{let e=C||w,t=p.current;if(p.current=e,!t||e)return;let n=H9.current;n&&queueMicrotask(()=>{!n||!V(n)||oz.isStreamingFor(n)||wR(n)&&se(n,jz(n))})},[C,w,se,V]),m.current=q,{auth:{hasToken:!!M},session:{sessionKey:g,sessionName:D,decodedKey:n,sessionRoutePending:R,showSessionLoading:z,loading:_,sessionModel:O,thinkingLevel:k,onSessionThinkingLevelChange:ie,reasoningLevel:A,modelSupportsThinking:j,hasMore:E,loadingMore:v,loadMoreMessages:ne,onSessionModelChange:re,createNewSession:ae,sessionManager:c.current},messages:{items:fe},stream:{error:y,streaming:C,sending:w,progress:T,sendMessage:q,abort:le,interruptAndSend:ce,deleteMessageRound:ue,retryUserMessageRound:de},followUp:{addPendingFollowUp:U.addPendingFollowUp,pendingFollowUps:U.pendingFollowUps,editingFollowUpId:U.editingFollowUpId,beginEditFollowUp:U.beginEditFollowUp,cancelEditFollowUp:U.cancelEditFollowUp,commitEditFollowUp:U.commitEditFollowUp,removePendingFollowUp:U.removePendingFollowUp,movePendingFollowUp:U.movePendingFollowUp,reorderPendingFollowUp:U.reorderPendingFollowUp,steerPendingFollowUp:U.steerPendingFollowUp,steeringFollowUpId:U.steeringFollowUpId},clarify:{clarifyPrompt:U.clarifyPrompt,clarifySubmitting:U.clarifySubmitting,clarifySubmitError:U.clarifySubmitError,submitClarifyAnswer:U.submitClarifyAnswer,cancelClarifyAnswer:U.cancelClarifyAnswer},agents:{chatAgents:N,displayAgentId:I,showChatAgentSelector:L,onChatAgentChange:F}}}var W9=300*1e3,jCe=Math.round(W9/6e4);function MCe(e){return`${Math.floor(e/60)}:${(e%60).toString().padStart(2,`0`)}`}function NCe(e){let t=(0,Y.c)(7),{prompt:n,submitting:r,submitError:i,labels:a,onSubmit:o,onCancel:s}=e;if(!n)return null;let c;return t[0]!==a||t[1]!==s||t[2]!==o||t[3]!==n||t[4]!==i||t[5]!==r?(c=(0,Z.jsx)(PCe,{prompt:n,submitting:r,submitError:i,labels:a,onSubmit:o,onCancel:s},n.requestId),t[0]=a,t[1]=s,t[2]=o,t[3]=n,t[4]=i,t[5]=r,t[6]=c):c=t[6],c}function PCe(e){let t=(0,Y.c)(70),{prompt:n,submitting:r,submitError:i,labels:a,onSubmit:o,onCancel:s}=e,[c,l]=(0,J.useState)(``),[u]=(0,J.useState)(ICe),[d,f]=(0,J.useState)(0),p=(0,J.useRef)(null),m,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{let e=window.setInterval(()=>f(FCe),1e3);return()=>window.clearInterval(e)},h=[],t[0]=m,t[1]=h):(m=t[0],h=t[1]),(0,J.useEffect)(m,h);let g,_;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{p.current?.focus()},_=[],t[2]=g,t[3]=_):(g=t[2],_=t[3]),(0,J.useEffect)(g,_);let v;t[4]===o?v=t[5]:(v=e=>{o(e)},t[4]=o,t[5]=v);let y=v,b=Math.max(0,Math.ceil((u-Date.now())/1e3)),x=`clarify-meta-${n.requestId}`,S=i?`clarify-err-${n.requestId}`:void 0,C;t[6]!==s||t[7]!==r?(C=e=>{e.key===`Escape`&&!r&&(e.preventDefault(),e.stopPropagation(),s())},t[6]=s,t[7]=r,t[8]=C):C=t[8];let w=C,T=Array.isArray(n.choices)&&n.choices.length>=2,E;t[9]!==a.clarifyDefaultChoice||t[10]!==n.default?(E=n.default?a.clarifyDefaultChoice.replace(`{{text}}`,n.default):null,t[9]=a.clarifyDefaultChoice,t[10]=n.default,t[11]=E):E=t[11];let D=E,O;t[12]===a.clarifyServerTimeout?O=t[13]:(O=a.clarifyServerTimeout.replace(`{{minutes}}`,String(jCe)),t[12]=a.clarifyServerTimeout,t[13]=O);let k=O,A;t[14]!==a.clarifyTimeRemaining||t[15]!==b?(A=a.clarifyTimeRemaining.replace(`{{time}}`,MCe(b)),t[14]=a.clarifyTimeRemaining,t[15]=b,t[16]=A):A=t[16];let j=A,M=a.clarifyRegionAria,N;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(N=X(`mb-4 rounded-lg border border-edge bg-surface-elevated px-4 py-3 text-sm text-fg shadow-sm outline-none`,AX.focusRingPanel),t[17]=N):N=t[17];let P;t[18]===a.clarifyResumeHint?P=t[19]:(P=(0,Z.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:a.clarifyResumeHint}),t[18]=a.clarifyResumeHint,t[19]=P);let F;t[20]===n.question?F=t[21]:(F=(0,Z.jsx)(OX,{content:n.question,compact:!0,className:`mb-3`}),t[20]=n.question,t[21]=F);let I;t[22]===k?I=t[23]:(I=(0,Z.jsx)(`li`,{children:k}),t[22]=k,t[23]=I);let L;t[24]!==a.clarifyDefaultTimeoutNote||t[25]!==n.default?(L=n.default?(0,Z.jsx)(`li`,{children:a.clarifyDefaultTimeoutNote}):null,t[24]=a.clarifyDefaultTimeoutNote,t[25]=n.default,t[26]=L):L=t[26];let R;t[27]===a.clarifySkipNote?R=t[28]:(R=(0,Z.jsx)(`li`,{children:a.clarifySkipNote}),t[27]=a.clarifySkipNote,t[28]=R);let z;t[29]===j?z=t[30]:(z=(0,Z.jsx)(`li`,{children:j}),t[29]=j,t[30]=z);let B;t[31]!==x||t[32]!==I||t[33]!==L||t[34]!==R||t[35]!==z?(B=(0,Z.jsxs)(`ul`,{id:x,className:`mb-3 list-inside list-disc space-y-1 text-xs text-fg-muted`,children:[I,L,R,z]}),t[31]=x,t[32]=I,t[33]=L,t[34]=R,t[35]=z,t[36]=B):B=t[36];let V;t[37]!==S||t[38]!==i?(V=i?(0,Z.jsx)(`div`,{id:S,role:`alert`,className:`mb-3 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:i}):null,t[37]=S,t[38]=i,t[39]=V):V=t[39];let H;t[40]!==c||t[41]!==D||t[42]!==T||t[43]!==a.clarifyChoicesGroupAria||t[44]!==a.clarifyCustomLabel||t[45]!==a.clarifyPlaceholder||t[46]!==a.clarifySend||t[47]!==a.clarifyUseDefault||t[48]!==o||t[49]!==y||t[50]!==n.choices||t[51]!==n.default||t[52]!==r?(H=T?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`max-h-[min(40vh,16rem)] overflow-y-auto overflow-x-hidden pr-1 [scrollbar-gutter:stable]`,"aria-label":a.clarifyChoicesGroupAria,children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:[n.choices.map(e=>(0,Z.jsx)(wA,{type:`button`,variant:`secondary`,disabled:r,className:X(`min-h-9 w-full justify-start rounded-lg px-3 py-2 text-left text-sm font-normal shadow-none`,`hover:border-edge`),onClick:()=>y(e),children:e},e)),n.default?(0,Z.jsx)(wA,{type:`button`,variant:`ghost`,disabled:r,className:X(`min-h-9 w-full justify-start rounded-lg border border-dashed border-edge px-3 py-2 text-left text-sm font-normal text-fg-muted`,`hover:border-edge hover:text-fg`),onClick:()=>y(n.default),children:D}):null]})}),(0,Z.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[(0,Z.jsx)(`p`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:a.clarifyCustomLabel}),(0,Z.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row sm:items-end`,onSubmit:e=>{e.preventDefault();let t=c.trim();t&&o(t)},children:[(0,Z.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),disabled:r,placeholder:a.clarifyPlaceholder,"aria-label":a.clarifyPlaceholder,className:`min-w-0 flex-1 rounded-md border border-edge bg-surface-panel px-3 py-2 text-fg placeholder:text-fg-muted focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent disabled:opacity-50`}),(0,Z.jsx)(wA,{type:`submit`,variant:`primary`,disabled:r||!c.trim(),className:`shrink-0 rounded-lg px-4 py-2 shadow-surface`,children:a.clarifySend})]})]})]}):(0,Z.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row sm:items-end`,onSubmit:e=>{e.preventDefault();let t=c.trim();t&&(o(t),l(``))},children:[(0,Z.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),disabled:r,placeholder:a.clarifyPlaceholder,"aria-label":a.clarifyPlaceholder,className:`min-w-0 flex-1 rounded-md border border-edge bg-surface-panel px-3 py-2 text-fg placeholder:text-fg-muted focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent disabled:opacity-50`}),(0,Z.jsx)(wA,{type:`submit`,variant:`primary`,disabled:r||!c.trim(),className:`shrink-0 rounded-lg px-4 py-2 shadow-surface`,children:a.clarifySend}),n.default?(0,Z.jsx)(wA,{type:`button`,variant:`secondary`,disabled:r,className:`shrink-0 rounded-lg px-3 py-2 text-sm font-normal text-fg-muted shadow-none hover:text-fg`,onClick:()=>y(n.default),children:a.clarifyUseDefault}):null]}),t[40]=c,t[41]=D,t[42]=T,t[43]=a.clarifyChoicesGroupAria,t[44]=a.clarifyCustomLabel,t[45]=a.clarifyPlaceholder,t[46]=a.clarifySend,t[47]=a.clarifyUseDefault,t[48]=o,t[49]=y,t[50]=n.choices,t[51]=n.default,t[52]=r,t[53]=H):H=t[53];let U;t[54]===s?U=t[55]:(U=()=>void s(),t[54]=s,t[55]=U);let W;t[56]!==a.clarifySkip||t[57]!==r||t[58]!==U?(W=(0,Z.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center justify-end gap-2 border-t border-edge-subtle pt-3`,children:(0,Z.jsx)(wA,{type:`button`,variant:`ghost`,disabled:r,className:`text-fg-muted hover:text-fg`,onClick:U,children:a.clarifySkip})}),t[56]=a.clarifySkip,t[57]=r,t[58]=U,t[59]=W):W=t[59];let G;return t[60]!==a.clarifyRegionAria||t[61]!==x||t[62]!==w||t[63]!==P||t[64]!==F||t[65]!==B||t[66]!==V||t[67]!==H||t[68]!==W?(G=(0,Z.jsxs)(`section`,{ref:p,tabIndex:-1,"aria-label":M,"aria-describedby":x,onKeyDown:w,className:N,children:[P,F,B,V,H,W]}),t[60]=a.clarifyRegionAria,t[61]=x,t[62]=w,t[63]=P,t[64]=F,t[65]=B,t[66]=V,t[67]=H,t[68]=W,t[69]=G):G=t[69],G}function FCe(e){return e+1}function ICe(){return Date.now()+W9}function G9(){let e=m(d(e=>e.language)),t=Se(e=>e.token),n=Qr(),{pathname:r}=Yr(),[i]=za(),a=(0,J.useRef)(null),o=(0,J.useRef)(0),[s,c]=(0,J.useState)(null),{auth:l,session:u,messages:f,stream:p,followUp:h,clarify:g,agents:_}=ACe(),v=i.get(`skill`)?.trim()??``,y=i.get(`slash`)?.trim()??``;(0,J.useEffect)(()=>{a.current=null},[u.sessionKey]),(0,J.useEffect)(()=>{if(!l.hasToken||!v&&!y||u.showSessionLoading||u.sessionRoutePending||!u.sessionKey)return;let e=()=>{let e=new URLSearchParams(i);e.delete(`skill`),e.delete(`slash`);let t=e.toString();n({pathname:r,search:t?`?${t}`:``},{replace:!0})},t=(t,n)=>{a.current!==n&&(a.current=n,queueMicrotask(()=>{o.current+=1,c({id:o.current,text:t}),e()}))};if(v){if(!q$(v)){e();return}let n=`${u.sessionKey}:skill:${v}`;t(`/skill:${v} `,n);return}if(!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(y)){e();return}let s=`${u.sessionKey}:slash:${y}`;a.current!==s&&queueMicrotask(()=>{(async()=>{try{let e=await v1(),t=y.toLowerCase(),n=e.find(e=>e.name.toLowerCase()===t||Array.isArray(e.aliases)&&e.aliases.some(e=>e.toLowerCase()===t));if(n){if(a.current===s)return;a.current=s,o.current+=1,c({id:o.current,text:S1(n)})}}finally{e()}})()})},[l.hasToken,v,y,i,u.showSessionLoading,u.sessionRoutePending,u.sessionKey,n,r]);let{scrollRef:b,atBottom:x,scrollToBottom:S,onScroll:C}=$Se({hasToken:l.hasToken,showSessionLoading:u.showSessionLoading,sessionKey:u.sessionKey,sending:p.sending,chatMessages:f.items,hasMore:u.hasMore,loadingMore:u.loadingMore,loadMoreMessages:u.loadMoreMessages});(0,J.useEffect)(()=>{c(null)},[u.sessionKey]);let w=(0,J.useCallback)(e=>{o.current+=1,c({id:o.current,text:e})},[]),T=(0,J.useMemo)(()=>!!u.sessionKey&&!u.showSessionLoading&&!u.sessionRoutePending&&f.items.length===0,[u.sessionKey,u.showSessionLoading,u.sessionRoutePending,f.items.length]),E=eQ(e=>e.setAgentId);(0,J.useEffect)(()=>{if(l.hasToken)return E(_.displayAgentId),()=>E(``)},[l.hasToken,_.displayAgentId,E]);let D=!u.showSessionLoading&&f.items.length===0&&!p.streaming,O=(0,J.useMemo)(()=>(u.sessionRoutePending&&u.decodedKey?u.decodedKey:u.sessionKey)?u.sessionName?.trim()||e.chat.newSession:e.nav.chat,[u.sessionKey,u.sessionName,u.sessionRoutePending,u.decodedKey,e.nav.chat,e.chat.newSession]);return l.hasToken?(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col bg-surface-panel`,children:[(0,Z.jsx)(Mye,{}),(0,Z.jsx)(wye,{chatHeadline:O,chatAgents:_.chatAgents?.items??[],showChatAgentSelector:_.showChatAgentSelector,chatAgentId:_.displayAgentId,onChatAgentChange:_.onChatAgentChange,chatAgentDisabled:u.showSessionLoading||u.sessionRoutePending}),(0,Z.jsxs)(`div`,{className:`relative mx-auto flex min-h-0 w-full max-w-[var(--max-width-chat)] flex-1 flex-col`,children:[u.sessionKey&&YR(u.sessionKey)&&!u.showSessionLoading&&!u.sessionRoutePending?(0,Z.jsx)(_ye,{sessionKey:u.sessionKey,streaming:p.streaming,sending:p.sending}):null,(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col px-3 sm:px-5 xl:px-6`,children:(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,Z.jsx)(`div`,{ref:b,className:X(`chat-messages min-h-0 flex-1 overflow-y-auto overflow-x-hidden [scrollbar-gutter:stable_both-edges]`,D?`chat-messages--compact-welcome pt-5 pb-2`:`py-4`),onScroll:C,children:u.showSessionLoading?(0,Z.jsx)(`div`,{className:`flex min-h-[min(40vh,20rem)] flex-col items-center justify-center gap-3 py-12 text-center text-sm text-fg-muted`,children:e.chat.loading}):(0,Z.jsxs)(Z.Fragment,{children:[u.loadingMore?(0,Z.jsx)(`div`,{className:`mb-3 text-center text-xs text-fg-muted`,children:e.chat.loadOlder}):null,p.error?(0,Z.jsx)(`div`,{className:`mb-4 rounded-md border border-edge bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-edge dark:bg-red-950/40 dark:text-red-300`,children:p.error}):null,(0,Z.jsx)(XSe,{messages:f.items,authToken:t??void 0,sessionKey:u.decodedKey??u.sessionKey,streaming:p.streaming,progress:p.progress,reasoningLevel:u.reasoningLevel,scrollElementRef:b,pinToBottom:x,onPickWelcomePrompt:w,onDeleteRound:p.deleteMessageRound,onRetryUserMessageRound:p.retryUserMessageRound,deleteRoundDisabled:p.streaming||p.sending,onAbortCurrentTurn:p.abort,onSendUserMessage:e=>{p.sendMessage(e)}},u.decodedKey??`new`)]})}),(0,Z.jsxs)(`div`,{className:X(`sticky bottom-0 z-10 shrink-0 bg-surface-panel`,D?`py-2.5`:`py-4`),children:[(0,Z.jsx)(NCe,{prompt:g.clarifyPrompt,submitting:g.clarifySubmitting,submitError:g.clarifySubmitError,labels:e.chat,onSubmit:g.submitClarifyAnswer,onCancel:g.cancelClarifyAnswer}),(0,Z.jsx)(Rve,{disabled:u.showSessionLoading||u.sessionRoutePending||!!g.clarifyPrompt,sending:p.sending,streaming:p.streaming,sessionKey:u.sessionKey,sessionManager:u.sessionManager,welcomeDraftSeed:s,canSelectWorkingDirectory:T,thinkingLevel:u.thinkingLevel,showThinkingSelector:u.modelSupportsThinking,onThinkingChange:u.onSessionThinkingLevelChange,onSend:p.sendMessage,onAbort:p.abort,onAddPendingFollowUp:(e,t)=>void h.addPendingFollowUp(e,t),onSteeringInterrupt:(e,t)=>void p.interruptAndSend(e,t),pendingFollowUps:h.pendingFollowUps,editingFollowUpId:h.editingFollowUpId,onBeginEditFollowUp:h.beginEditFollowUp,onCancelEditFollowUp:h.cancelEditFollowUp,onCommitEditFollowUp:(e,t,n,r)=>void h.commitEditFollowUp(e,t,n,r),onPendingFollowUpRemove:h.removePendingFollowUp,onPendingFollowUpMove:h.movePendingFollowUp,onPendingFollowUpReorder:h.reorderPendingFollowUp,onPendingFollowUpSteer:e=>void h.steerPendingFollowUp(e),steeringFollowUpId:h.steeringFollowUpId,sessionModel:u.sessionModel,showModelSelector:!!(u.sessionKey&&!u.sessionRoutePending),onModelChange:u.onSessionModelChange,modelDisabled:u.showSessionLoading||u.sessionRoutePending||p.streaming,contextUsageMessages:f.items,onChatAgentChange:_.showChatAgentSelector?_.onChatAgentChange:void 0,currentAgentId:_.displayAgentId})]})]})})]}),(0,Z.jsx)(ZSe,{visible:!u.showSessionLoading&&!x,onClick:()=>S(!0,!0)})]}):(0,Z.jsx)(`div`,{className:`mx-auto w-full max-w-[var(--max-width-chat)] px-3 py-16 text-center text-sm leading-relaxed text-fg-muted sm:px-5`,children:e.chat.needToken})}function LCe(){let e=(0,Y.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col`,children:(0,Z.jsx)(Li,{})}),e[0]=t):t=e[0],t}async function RCe(e){let t=await Ee(e);if(!t.ok){let e=await t.json().catch(()=>({})),n=Te(t.status,t.statusText,e.error?.message);throw Error(n)}return t.json()}function zCe(e){let t=(0,Y.c)(3),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={fetcher:RCe,revalidateOnFocus:!1,dedupingInterval:2e3,shouldRetryOnError:!0,errorRetryCount:2},t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,Z.jsx)(y,{value:r,children:n}),t[1]=n,t[2]=i),i}var BCe=(0,J.lazy)(()=>D(()=>import(`./sessions-page-FaG_Vlkb.js`).then(e=>({default:e.SessionsPage})),__vite__mapDeps([16,1,2,3,5,7,12,9]))),VCe=(0,J.lazy)(()=>D(()=>import(`./cron-page-BMrloeFH.js`).then(e=>({default:e.CronPage})),__vite__mapDeps([18,1,2,3,19,4,7,10,8,9,13,5]))),HCe=(0,J.lazy)(()=>D(()=>import(`./skills-page-DhUO235y.js`).then(e=>({default:e.SkillsPage})),__vite__mapDeps([20,1,21,2,3,19,7,9]))),UCe=(0,J.lazy)(()=>D(()=>import(`./logs-page-sTsVWz0X.js`).then(e=>({default:e.LogsPage})),__vite__mapDeps([17,1,2,3,7,9]))),WCe=(0,J.lazy)(()=>D(()=>import(`./settings-page-Bet1OerL.js`).then(e=>({default:e.SettingsPage})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]))),K9=(0,J.lazy)(()=>D(()=>import(`./agents-mS3_HpRI.js`).then(e=>({default:e.AgentsSettingsPanel})),__vite__mapDeps([11,1,2,3,4,5,7,10,8,9,12]))),q9=(0,J.lazy)(()=>D(()=>import(`./channels-settings-BG6b9KrW.js`).then(e=>({default:e.ChannelsSettingsPanel})),__vite__mapDeps([25,1,2,3,5,6,7,8,9,26,14]))),J9=(0,J.lazy)(()=>D(()=>import(`./apps-page-DrfytjOb.js`).then(e=>({default:e.AppsPage})),__vite__mapDeps([27,1,2,3,5,7,9]))),Y9=(0,J.lazy)(()=>D(()=>import(`./extension-page-DW47KI82.js`).then(e=>({default:e.ExtensionPage})),__vite__mapDeps([28,1,3]))),X9=(0,J.lazy)(()=>D(()=>import(`./extension-settings-page-B-W4x2xP.js`).then(e=>({default:e.ExtensionSettingsPage})),__vite__mapDeps([29,1,5,3,7,26,14,15,9]))),GCe=(0,J.lazy)(()=>D(()=>import(`./extension-debug-page-BdW_46sN.js`).then(e=>({default:e.ExtensionDebugPage})),__vite__mapDeps([30,1,3]))),KCe=(0,J.lazy)(()=>D(()=>import(`./share-preview-page-BtG2kLDh.js`).then(e=>({default:e.SharePreviewPage})),__vite__mapDeps([31,1,21,7,3])));function Z9(){let e=(0,Y.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-1 items-center justify-center text-sm text-fg-muted`,"aria-busy":!0,children:`Loading…`}),e[0]=t):t=e[0],t}function Q9(e){let t=(0,Y.c)(2),{tab:n}=e,r=n?`/settings/agent-defaults?tab=${encodeURIComponent(n)}`:`/settings/agent-defaults`,i;return t[0]===r?i=t[1]:(i=(0,Z.jsx)(Ii,{to:r,replace:!0}),t[0]=r,t[1]=i),i}function qCe(){let e=(0,Y.c)(4),{agentId:t}=ni(),n;e[0]===t?n=e[1]:(n=typeof t==`string`?t.trim():``,e[0]=t,e[1]=n);let r=n,i=r?`/agents/${encodeURIComponent(r)}`:`/agents`,a;return e[2]===i?a=e[3]:(a=(0,Z.jsx)(Ii,{to:i,replace:!0}),e[2]=i,e[3]=a),a}function $9(){let e=(0,Y.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"aria-busy":!0,children:(0,Z.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main flex-1 px-4 py-8`,children:[(0,Z.jsx)(`div`,{className:`h-8 w-48 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,Z.jsx)(`div`,{className:`mt-6 h-36 animate-pulse rounded-xl bg-surface-hover`}),(0,Z.jsx)(`div`,{className:`mt-4 h-24 animate-pulse rounded-xl bg-surface-hover`}),(0,Z.jsx)(`p`,{className:`mt-6 text-sm text-fg-muted`,children:`Loading…`})]})}),e[0]=t):t=e[0],t}var JCe=Ea([{path:`/share/:token`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)(Z9,{}),children:(0,Z.jsx)(KCe,{})})},{path:`/`,element:(0,Z.jsx)(Zhe,{}),children:[{index:!0,element:(0,Z.jsx)(Ii,{to:`/chat`,replace:!0})},{path:`chat`,element:(0,Z.jsx)(LCe,{}),children:[{index:!0,element:(0,Z.jsx)(G9,{})},{path:`new`,element:(0,Z.jsx)(G9,{})},{path:`:sessionKey`,element:(0,Z.jsx)(G9,{})}]},{path:`sessions`,element:(0,Z.jsx)(Ii,{to:`/settings/sessions`,replace:!0})},{path:`logs`,element:(0,Z.jsx)(Ii,{to:`/settings/logs`,replace:!0})},{path:`cron`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)(Z9,{}),children:(0,Z.jsx)(VCe,{})})},{path:`skills`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)(Z9,{}),children:(0,Z.jsx)(HCe,{})})},{path:`channels`,children:[{index:!0,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)(Z9,{}),children:(0,Z.jsx)(q9,{})})},{path:`:channelId`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)(Z9,{}),children:(0,Z.jsx)(q9,{})})}]},{path:`mcp`,element:(0,Z.jsx)(Ii,{to:`/settings/agent-mcp`,replace:!0})},{path:`agents`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)(Z9,{}),children:(0,Z.jsx)(K9,{})})},{path:`agents/:agentId`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)(Z9,{}),children:(0,Z.jsx)(K9,{})})},{path:`apps`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)(Z9,{}),children:(0,Z.jsx)(J9,{})})},{path:`apps/:extensionId`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)(Z9,{}),children:(0,Z.jsx)(Y9,{})})},{path:`apps/:extensionId/:pageId`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)(Z9,{}),children:(0,Z.jsx)(Y9,{})})},{path:`settings`,element:(0,Z.jsx)(xge,{children:(0,Z.jsx)(hge,{})}),children:[{index:!0,element:(0,Z.jsx)(Ii,{to:`overview`,replace:!0})},{path:`skills`,element:(0,Z.jsx)(Ii,{to:`/skills`,replace:!0})},{path:`channels`,element:(0,Z.jsx)(Ii,{to:`/channels`,replace:!0})},{path:`mcp`,element:(0,Z.jsx)(Ii,{to:`/settings/agent-mcp`,replace:!0})},{path:`sessions`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)(Z9,{}),children:(0,Z.jsx)(BCe,{})})},{path:`logs`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)(Z9,{}),children:(0,Z.jsx)(UCe,{})})},{path:`apps`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)($9,{}),children:(0,Z.jsx)(J9,{})})},{path:`agents`,element:(0,Z.jsx)(Ii,{to:`/agents`,replace:!0})},{path:`agents/:agentId`,element:(0,Z.jsx)(qCe,{})},{path:`agent-chat`,element:(0,Z.jsx)(Q9,{})},{path:`agent-workspace`,element:(0,Z.jsx)(Q9,{tab:`workspace`})},{path:`agent-runtime`,element:(0,Z.jsx)(Q9,{tab:`runtime`})},{path:`agent-context`,element:(0,Z.jsx)(Q9,{tab:`context`})},{path:`agent-memory`,element:(0,Z.jsx)(Q9,{tab:`memory`})},{path:`agent-tools`,element:(0,Z.jsx)(Q9,{tab:`tools`})},{path:`agent-skills`,element:(0,Z.jsx)(Q9,{tab:`skills`})},{path:`agent-system-prompt`,element:(0,Z.jsx)(Q9,{tab:`system-prompt`})},{path:`agent-models`,element:(0,Z.jsx)(Ii,{to:`/settings/models`,replace:!0})},{path:`extensions/debug`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)($9,{}),children:(0,Z.jsx)(GCe,{})})},{path:`ext/:extensionId`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)($9,{}),children:(0,Z.jsx)(X9,{})})},{path:`ext/:extensionId/:panelId`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)($9,{}),children:(0,Z.jsx)(X9,{})})},{path:`:section`,element:(0,Z.jsx)(J.Suspense,{fallback:(0,Z.jsx)($9,{}),children:(0,Z.jsx)(WCe,{})})}]}]}]);function YCe(){let e=(0,Y.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],(0,J.useEffect)(XCe,t),null}function XCe(){let e=ve.persist.onFinishHydration(QCe),t=RA.persist.onFinishHydration(ZCe),n=ye();return()=>{e?.(),t?.(),n()}}function ZCe(){zA()}function QCe(){be()}function $Ce(){let e=(0,Y.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(YCe,{}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(He,{i18n:u,children:(0,Z.jsx)(zCe,{children:(0,Z.jsx)(AI,{children:(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[t,(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col [&>*]:min-h-0 [&>*]:flex-1`,children:(0,Z.jsx)(Za,{router:JCe})})]})})})}),e[1]=n):n=e[1],n}document.documentElement.setAttribute(`lang`,l(f())),xe(),LA(),Ce(),(0,TO.createRoot)(document.getElementById(`root`)).render((0,Z.jsx)(J.StrictMode,{children:(0,Z.jsx)($Ce,{})}));export{B$ as $,El as $i,EA as $n,jg as $r,WV as $t,s8 as A,tu as Ai,xF as An,qb as Ar,YZ as At,Hle as B,Ul as Bi,Gj as Bn,jv as Br,OX as Bt,jhe as C,Cd as Ci,FI as Cn,qx as Cr,JQ as Ct,d8 as D,Uu as Di,OI as Dn,rx as Dr,$Z as Dt,Nhe as E,ld as Ei,EI as En,px as Er,eQ as Et,A1 as F,Xl as Fi,BP as Fn,vb as Fr,IZ as Ft,zle as G,Fl as Gi,ij as Gn,fv as Gr,lH as Gt,O1 as H,zl as Hi,kj as Hn,bv as Hr,cU as Ht,Ple as I,Yl as Ii,HP as In,ub as Ir,AZ as It,Kle as J,Ml as Ji,AA as Jn,Qg as Jr,oH as Jt,Ule as K,Pl as Ki,nj as Kn,uv as Kr,dH as Kt,Fle as L,Jl as Li,VP as Ln,Ky as Lr,PX as Lt,R1 as M,$l as Mi,yF as Mn,Ib as Mr,qZ as Mt,P1 as N,Ql as Ni,gF as Nn,kb as Nr,BZ as Nt,Dhe as O,Su as Oi,UF as On,tx as Or,JZ as Ot,j1 as P,Zl as Pi,vF as Pn,Tb as Pr,UZ as Pt,z$ as Q,Dl as Qi,DA as Qn,Mg as Qr,KV as Qt,qle as R,ql as Ri,zP as Rn,xy as Rr,jX as Rt,Ohe as S,kd as Si,tL as Sn,oS as Sr,qQ as St,Ahe as T,yd as Ti,PI as Tn,zx as Tr,DQ as Tt,Ble as U,Rl as Ui,rj as Un,vv as Ur,uU as Ut,Vle as V,Bl as Vi,Oj as Vn,xv as Vr,AU as Vt,Rle as W,Ll as Wi,tj as Wn,_v as Wr,WH as Wt,P$ as X,kl as Xi,OA as Xn,Fg as Xr,YV as Xt,j$ as Y,jl as Yi,jA as Yn,Ig as Yr,rH as Yt,I$ as Z,Ol as Zi,TA as Zn,Pg as Zr,JV as Zt,b8 as _,km as _i,pL as _n,fw as _r,YQ as _t,b_e as a,no as aa,Sg as ai,WR as an,iO as ar,k$ as at,Mhe as b,Sp as bi,rL as bn,NC as br,KQ as bt,s5 as c,Yr as ca,vg as ci,VR as cn,JE as cr,h$ as ct,k8 as d,za as da,hg as di,KR as dn,TE as dr,$Q as dt,yc as ea,Ag as ei,QV as en,kA as er,F$ as et,S8 as f,Ve as fa,mg as fi,GR as fn,QT as fr,e$ as ft,v8 as g,jh as gi,mL as gn,Vw as gr,UQ as gt,y8 as h,ig as hi,fL as hn,Gw as hr,WQ as ht,d5 as i,uo as ia,Cg as ii,iz as in,oO as ir,M$ as it,c8 as j,eu as ji,bF as jn,Kb as jr,GZ as jt,Ehe as k,uu as ki,SF as kn,Jb as kr,KZ as kt,o5 as l,Qr as la,_g as li,BR as ln,FE as lr,m$ as lt,lge as m,ug as mi,gL as mn,CT as mr,XQ as mt,i9 as n,Xo as na,Tg as ni,XV as nn,X as nr,O$ as nt,x_e as o,ja as oa,bg as oi,HR as on,RD as or,A$ as ot,x8 as p,pg as pi,qR as pn,UT as pr,t$ as pt,Ile as q,Nl as qi,VA as qn,H_ as qr,sH as qt,Q7 as r,Jo as ra,wg as ri,$V as rn,cO as rr,L$ as rt,c5 as s,Ii as sa,yg as si,JR as sn,gD as sr,f$ as st,b9 as t,Ss as ta,Eg as ti,eH as tn,wA as tr,R$ as tt,r5 as u,ni as ua,gg as ui,zR as un,EE as ur,g$ as ut,p8 as v,Kp as vi,lL as vn,rw as vr,GQ as vt,f8 as w,xd as wi,MI as wn,Ux as wr,CQ as wt,khe as x,xf as xi,nL as xn,dC as xr,ZQ as xt,m8 as y,Np as yi,iL as yn,WC as yr,QQ as yt,Lle as z,Kl as zi,CP as zn,Lv as zr,AX as zt};